This commit was manufactured by cvs2svn to create branch
authorPlanet-Lab Support <support@planet-lab.org>
Thu, 4 Nov 2004 16:32:46 +0000 (16:32 +0000)
committerPlanet-Lab Support <support@planet-lab.org>
Thu, 4 Nov 2004 16:32:46 +0000 (16:32 +0000)
'planetlab-3_0-branch'.

1546 files changed:
Documentation/COPYING.modules [new file with mode: 0644]
Documentation/arm/SA1100/PCMCIA [deleted file]
Documentation/arm/XScale/ADIFCC/80200EVB [deleted file]
Documentation/arm/XScale/IOP3XX/IQ80310 [deleted file]
Documentation/arm/XScale/IOP3XX/IQ80321 [deleted file]
Documentation/arm/XScale/IOP3XX/aau.txt [deleted file]
Documentation/arm/XScale/IOP3XX/dma.txt [deleted file]
Documentation/arm/XScale/IOP3XX/message.txt [deleted file]
Documentation/arm/XScale/IOP3XX/pmon.txt [deleted file]
Documentation/arm/XScale/cache-lock.txt [deleted file]
Documentation/arm/XScale/pmu.txt [deleted file]
Documentation/arm/XScale/tlb-lock.txt [deleted file]
Documentation/as-iosched.txt [deleted file]
Documentation/ckrm/block_io [new file with mode: 0644]
Documentation/ckrm/ckrm_basics [new file with mode: 0644]
Documentation/ckrm/core_usage [new file with mode: 0644]
Documentation/ckrm/crbce [new file with mode: 0644]
Documentation/ckrm/installation [new file with mode: 0644]
Documentation/ckrm/mem_rc.design [new file with mode: 0644]
Documentation/ckrm/mem_rc.usage [new file with mode: 0644]
Documentation/ckrm/rbce_basics [new file with mode: 0644]
Documentation/ckrm/rbce_usage [new file with mode: 0644]
Documentation/filesystems/relayfs.txt [new file with mode: 0644]
Documentation/i2c/i2c-pport [deleted file]
Documentation/i2c/i2c-velleman [deleted file]
Documentation/powerpc/hvcs.txt [deleted file]
Documentation/powerpc/mpc52xx.txt [deleted file]
Documentation/sysrq.txt
Documentation/vm/hugetlbpage.txt
Documentation/vserver/debug.txt [new file with mode: 0644]
Makefile
arch/alpha/Kconfig
arch/alpha/kernel/ptrace.c
arch/alpha/kernel/systbls.S
arch/arm/Kconfig
arch/arm/boot/compressed/head-ftvpci.S [deleted file]
arch/arm/common/platform.c [deleted file]
arch/arm/common/plx90x0.c [deleted file]
arch/arm/configs/adi_evb_defconfig [deleted file]
arch/arm/configs/ixp4xx_defconfig [deleted file]
arch/arm/configs/mainstone_defconfig [deleted file]
arch/arm/configs/smdk2410_defconfig [deleted file]
arch/arm/kernel/ptrace.c
arch/arm/kernel/time-acorn.c [deleted file]
arch/arm/mach-adifcc/Makefile [deleted file]
arch/arm/mach-adifcc/arch.c [deleted file]
arch/arm/mach-adifcc/irq.c [deleted file]
arch/arm/mach-adifcc/mm.c [deleted file]
arch/arm/mach-ftvpci/Makefile [deleted file]
arch/arm/mach-ftvpci/core.c [deleted file]
arch/arm/mach-ftvpci/leds.c [deleted file]
arch/arm/mach-ftvpci/pci.c [deleted file]
arch/arm/mach-ixp4xx/common-pci.c [deleted file]
arch/arm/mach-ixp4xx/coyote-setup.c [deleted file]
arch/arm/mach-ixp4xx/ixdp425-setup.c [deleted file]
arch/arm/mach-ixp4xx/prpmc1100-setup.c [deleted file]
arch/arm/mach-lh7a40x/fiq.S [deleted file]
arch/arm/mach-lh7a40x/ide-lpd7a40x.c [deleted file]
arch/arm/mach-omap/innovator1510.c [deleted file]
arch/arm/mach-omap/innovator1610.c [deleted file]
arch/arm/mach-omap/irq.h [deleted file]
arch/arm/mach-omap/omap-generic.c [deleted file]
arch/arm/mach-omap/omap-perseus2.c [deleted file]
arch/arm/mach-s3c2410/gpio.c [deleted file]
arch/arm/mach-s3c2410/mach-smdk2410.c [deleted file]
arch/arm/mach-sa1100/collie.c [deleted file]
arch/arm/mach-tbox/Makefile [deleted file]
arch/arm/mach-tbox/core.c [deleted file]
arch/arm26/Kconfig
arch/arm26/kernel/ptrace.c
arch/cris/Kconfig
arch/cris/kernel/hexify.c [deleted file]
arch/cris/kernel/ksyms.c [deleted file]
arch/h8300/Kconfig
arch/h8300/kernel/ptrace.c
arch/i386/Kconfig
arch/i386/Makefile
arch/i386/boot/Makefile
arch/i386/boot/setup.S
arch/i386/boot/video.S
arch/i386/boot98/Makefile [deleted file]
arch/i386/boot98/bootsect.S [deleted file]
arch/i386/boot98/compressed/Makefile [deleted file]
arch/i386/boot98/compressed/head.S [deleted file]
arch/i386/boot98/compressed/misc.c [deleted file]
arch/i386/boot98/compressed/vmlinux.scr [deleted file]
arch/i386/boot98/install.sh [deleted file]
arch/i386/boot98/mtools.conf.in [deleted file]
arch/i386/boot98/setup.S [deleted file]
arch/i386/boot98/tools/build.c [deleted file]
arch/i386/boot98/video.S [deleted file]
arch/i386/crypto/Makefile [deleted file]
arch/i386/crypto/aes-i586-asm.S [deleted file]
arch/i386/crypto/aes.c [deleted file]
arch/i386/kernel/Makefile
arch/i386/kernel/acpi/boot.c
arch/i386/kernel/acpi/sleep.c
arch/i386/kernel/acpi/wakeup.S
arch/i386/kernel/asm-offsets.c
arch/i386/kernel/cpu/common.c
arch/i386/kernel/cpu/cpufreq/powernow-k8.c
arch/i386/kernel/cpu/intel.c
arch/i386/kernel/doublefault.c
arch/i386/kernel/entry.S
arch/i386/kernel/entry_trampoline.c [new file with mode: 0644]
arch/i386/kernel/i386_ksyms.c
arch/i386/kernel/i387.c
arch/i386/kernel/init_task.c
arch/i386/kernel/io_apic.c
arch/i386/kernel/irq.c
arch/i386/kernel/ldt.c
arch/i386/kernel/microcode.c
arch/i386/kernel/mpparse.c
arch/i386/kernel/nmi.c
arch/i386/kernel/process.c
arch/i386/kernel/ptrace.c
arch/i386/kernel/reboot.c
arch/i386/kernel/setup.c
arch/i386/kernel/signal.c
arch/i386/kernel/smp.c
arch/i386/kernel/std_resources.c [deleted file]
arch/i386/kernel/sys_i386.c
arch/i386/kernel/sysenter.c
arch/i386/kernel/timers/timer.c
arch/i386/kernel/traps.c
arch/i386/kernel/vm86.c
arch/i386/kernel/vmlinux.lds.S
arch/i386/kernel/vsyscall-sysenter.S
arch/i386/kernel/vsyscall.lds
arch/i386/lib/checksum.S
arch/i386/lib/getuser.S
arch/i386/lib/usercopy.c
arch/i386/mach-es7000/es7000.c [deleted file]
arch/i386/mach-es7000/setup.c [deleted file]
arch/i386/mach-es7000/topology.c [deleted file]
arch/i386/mach-generic/bigsmp.c
arch/i386/mach-pc9800/Makefile [deleted file]
arch/i386/mach-pc9800/setup.c [deleted file]
arch/i386/mach-pc9800/std_resources.c [deleted file]
arch/i386/mach-pc9800/topology.c [deleted file]
arch/i386/math-emu/fpu_system.h
arch/i386/mm/Makefile
arch/i386/mm/fault.c
arch/i386/mm/highmem.c
arch/i386/mm/hugetlbpage.c
arch/i386/mm/init.c
arch/i386/mm/mmap.c [deleted file]
arch/i386/mm/pageattr.c
arch/i386/mm/pgtable.c
arch/i386/power/cpu.c
arch/ia64/Kconfig
arch/ia64/Makefile
arch/ia64/ia32/binfmt_elf32.c
arch/ia64/kernel/entry.S
arch/ia64/kernel/ia64_ksyms.c
arch/ia64/kernel/perfmon.c
arch/ia64/kernel/perfmon_hpsim.h [deleted file]
arch/ia64/kernel/ptrace.c
arch/ia64/kernel/traps.c
arch/ia64/mm/fault.c
arch/ia64/mm/hugetlbpage.c
arch/ia64/mm/init.c
arch/m68k/Kconfig
arch/m68k/atari/stram.c
arch/m68k/kernel/ptrace.c
arch/m68knommu/Kconfig
arch/m68knommu/kernel/ptrace.c
arch/mips/Kconfig
arch/mips/configs/eagle_defconfig [deleted file]
arch/mips/configs/ocelot_g_defconfig [deleted file]
arch/mips/kernel/irixelf.c
arch/mips/kernel/linux32.c
arch/mips/kernel/ptrace.c
arch/mips/kernel/syscall.c
arch/mips/kernel/sysirix.c
arch/mips/mm-32/Makefile [deleted file]
arch/mips/mm-32/tlbex-r4k.S [deleted file]
arch/mips/mm-64/Makefile [deleted file]
arch/mips/mm-64/tlb-dbg-r4k.c [deleted file]
arch/mips/mm-64/tlb-glue-r4k.S [deleted file]
arch/mips/mm-64/tlb-glue-sb1.S [deleted file]
arch/mips/mm-64/tlbex-r4k.S [deleted file]
arch/mips/mm/tlbex-r3k.S [deleted file]
arch/mips/momentum/ocelot_c/pci-irq.c [deleted file]
arch/mips/momentum/ocelot_g/gt64240.h [deleted file]
arch/mips/momentum/ocelot_g/gt64240_dep.h [deleted file]
arch/mips/momentum/ocelot_g/pci-irq.c [deleted file]
arch/mips/pci/fixup-eagle.c [deleted file]
arch/mips/pci/fixup-mv64340.c [deleted file]
arch/mips/pci/fixup-tb0229.c [deleted file]
arch/mips/pci/fixup-victor-mpc30x.c [deleted file]
arch/mips/pci/ops-mv64340.c [deleted file]
arch/mips/pci/ops-vrc4173.c [deleted file]
arch/mips/vr41xx/nec-eagle/Makefile [deleted file]
arch/mips/vr41xx/nec-eagle/irq.c [deleted file]
arch/mips/vr41xx/nec-eagle/setup.c [deleted file]
arch/mips/vr41xx/tanbac-tb0229/reboot.c [deleted file]
arch/parisc/Kconfig
arch/parisc/kernel/ptrace.c
arch/parisc/kernel/sys_parisc32.c
arch/parisc/kernel/unwind.c [deleted file]
arch/ppc/8260_io/commproc.c [deleted file]
arch/ppc/8260_io/uart.c [deleted file]
arch/ppc/Kconfig
arch/ppc/Makefile
arch/ppc/boot/simple/misc-mv64x60.S [deleted file]
arch/ppc/boot/simple/mpc52xx_tty.c [deleted file]
arch/ppc/boot/simple/mv64x60_stub.c [deleted file]
arch/ppc/boot/simple/mv64x60_tty.c [deleted file]
arch/ppc/configs/ads8272_defconfig [deleted file]
arch/ppc/configs/bubinga_defconfig [deleted file]
arch/ppc/configs/lite5200_defconfig [deleted file]
arch/ppc/configs/rpx8260_defconfig [deleted file]
arch/ppc/kernel/dma-mapping.c [deleted file]
arch/ppc/kernel/head_e500.S [deleted file]
arch/ppc/kernel/misc.S
arch/ppc/kernel/pci-dma.c [deleted file]
arch/ppc/kernel/ptrace.c
arch/ppc/kernel/syscalls.c
arch/ppc/kernel/vecemu.c [deleted file]
arch/ppc/lib/rheap.c [deleted file]
arch/ppc/mm/cachemap.c [deleted file]
arch/ppc/mm/init.c
arch/ppc/ocp/Makefile [deleted file]
arch/ppc/ocp/ocp-driver.c [deleted file]
arch/ppc/ocp/ocp-probe.c [deleted file]
arch/ppc/ocp/ocp.c [deleted file]
arch/ppc/platforms/85xx/Kconfig [deleted file]
arch/ppc/platforms/85xx/Makefile [deleted file]
arch/ppc/platforms/85xx/mpc8540_ads.c [deleted file]
arch/ppc/platforms/85xx/mpc8540_ads.h [deleted file]
arch/ppc/platforms/85xx/mpc8555.c [deleted file]
arch/ppc/platforms/85xx/mpc8555_cds.h [deleted file]
arch/ppc/platforms/85xx/mpc8560_ads.c [deleted file]
arch/ppc/platforms/85xx/mpc8560_ads.h [deleted file]
arch/ppc/platforms/85xx/mpc85xx_cds_common.c [deleted file]
arch/ppc/platforms/85xx/mpc85xx_cds_common.h [deleted file]
arch/ppc/platforms/85xx/sbc8560.c [deleted file]
arch/ppc/platforms/85xx/sbc8560.h [deleted file]
arch/ppc/platforms/error_log.c [deleted file]
arch/ppc/platforms/error_log.h [deleted file]
arch/ppc/platforms/ev64260.c [deleted file]
arch/ppc/platforms/lite5200.c [deleted file]
arch/ppc/platforms/lite5200.h [deleted file]
arch/ppc/platforms/mpc5200.c [deleted file]
arch/ppc/platforms/proc_rtas.c [deleted file]
arch/ppc/platforms/rpx8260.c [deleted file]
arch/ppc/platforms/rpx8260.h [deleted file]
arch/ppc/platforms/rpxsuper.h [deleted file]
arch/ppc/syslib/cpm2_common.c [deleted file]
arch/ppc/syslib/m8260_pci_erratum9.c [deleted file]
arch/ppc/syslib/mpc52xx_pic.c [deleted file]
arch/ppc/syslib/mpc52xx_setup.c [deleted file]
arch/ppc/syslib/mv64360_pic.c [deleted file]
arch/ppc/syslib/mv64x60.c [deleted file]
arch/ppc/syslib/ppc4xx_sgdma.c [deleted file]
arch/ppc/syslib/ppc8260_pic.c [deleted file]
arch/ppc/syslib/ppc8260_pic.h [deleted file]
arch/ppc/syslib/ppc85xx_setup.c [deleted file]
arch/ppc/syslib/ppc85xx_setup.h [deleted file]
arch/ppc64/Kconfig
arch/ppc64/Makefile
arch/ppc64/kernel/hvcserver.c [deleted file]
arch/ppc64/kernel/misc.S
arch/ppc64/kernel/ptrace.c
arch/ppc64/kernel/rtas.c
arch/ppc64/kernel/smp.c
arch/ppc64/kernel/sys_ppc32.c
arch/ppc64/kernel/sysfs.c
arch/ppc64/kernel/traps.c
arch/ppc64/mm/Makefile
arch/ppc64/mm/hugetlbpage.c
arch/ppc64/mm/slb.c [deleted file]
arch/ppc64/mm/slb_low.S [deleted file]
arch/s390/Kconfig
arch/s390/Makefile
arch/s390/boot/Makefile
arch/s390/boot/install.sh
arch/s390/kernel/compat_exec.c
arch/s390/kernel/ptrace.c
arch/s390/kernel/syscalls.S
arch/s390/kernel/traps.c
arch/s390/lib/memset.S [deleted file]
arch/s390/lib/memset64.S [deleted file]
arch/s390/lib/strcmp.S [deleted file]
arch/s390/lib/strcmp64.S [deleted file]
arch/s390/lib/strcpy.S [deleted file]
arch/s390/lib/strcpy64.S [deleted file]
arch/s390/lib/strncpy.S [deleted file]
arch/s390/lib/strncpy64.S [deleted file]
arch/s390/mm/Makefile
arch/s390/mm/init.c
arch/s390/mm/mmap.c [deleted file]
arch/sh/Kconfig
arch/sh/boards/systemh/Makefile [deleted file]
arch/sh/boards/systemh/io.c [deleted file]
arch/sh/boards/systemh/irq.c [deleted file]
arch/sh/boards/systemh/setup.c [deleted file]
arch/sh/configs/rts7751r2d_defconfig [deleted file]
arch/sh/kernel/ptrace.c
arch/sh/mm/hugetlbpage.c
arch/sh64/configs/cayman_defconfig [deleted file]
arch/sh64/defconfig [deleted file]
arch/sparc/Kconfig
arch/sparc/Makefile
arch/sparc/kernel/ptrace.c
arch/sparc/kernel/sys_sparc.c
arch/sparc/kernel/systbls.S
arch/sparc64/Kconfig
arch/sparc64/Makefile
arch/sparc64/kernel/binfmt_aout32.c
arch/sparc64/kernel/ptrace.c
arch/sparc64/kernel/sys_sparc.c
arch/sparc64/kernel/systbls.S
arch/sparc64/lib/blockops.S [deleted file]
arch/sparc64/lib/splock.S [deleted file]
arch/sparc64/mm/hugetlbpage.c
arch/sparc64/solaris/fs.c
arch/um/Kconfig
arch/um/Kconfig_block
arch/um/Kconfig_char
arch/um/Kconfig_net
arch/um/Makefile
arch/um/Makefile-i386
arch/um/Makefile-skas
arch/um/config.release
arch/um/defconfig
arch/um/drivers/Makefile
arch/um/drivers/chan_kern.c
arch/um/drivers/chan_user.c
arch/um/drivers/cow.h [deleted file]
arch/um/drivers/cow_user.c [deleted file]
arch/um/drivers/daemon_user.c
arch/um/drivers/fd.c
arch/um/drivers/harddog_user.c
arch/um/drivers/hostaudio_kern.c
arch/um/drivers/hostaudio_user.c
arch/um/drivers/line.c
arch/um/drivers/mcast_user.c
arch/um/drivers/mconsole_kern.c
arch/um/drivers/mconsole_user.c
arch/um/drivers/mmapper_kern.c
arch/um/drivers/net_kern.c
arch/um/drivers/net_user.c
arch/um/drivers/null.c
arch/um/drivers/port_kern.c
arch/um/drivers/port_user.c
arch/um/drivers/pty.c
arch/um/drivers/slip_user.c
arch/um/drivers/slirp_user.c
arch/um/drivers/ssl.c
arch/um/drivers/stdio_console.c
arch/um/drivers/tty.c
arch/um/drivers/ubd_kern.c
arch/um/drivers/ubd_user.c
arch/um/drivers/xterm.c
arch/um/drivers/xterm_kern.c
arch/um/dyn.lds.S
arch/um/include/2_5compat.h
arch/um/include/init.h
arch/um/include/irq_kern.h [deleted file]
arch/um/include/irq_user.h
arch/um/include/kern_util.h
arch/um/include/line.h
arch/um/include/mconsole.h
arch/um/include/mem.h
arch/um/include/mem_kern.h [deleted file]
arch/um/include/mem_user.h
arch/um/include/os.h
arch/um/include/signal_user.h
arch/um/include/skas_ptrace.h
arch/um/include/sysdep-i386/checksum.h
arch/um/include/sysdep-i386/frame_user.h
arch/um/include/sysdep-i386/sigcontext.h
arch/um/include/sysdep-i386/syscalls.h
arch/um/include/time_user.h
arch/um/include/ubd_user.h
arch/um/include/um_uaccess.h
arch/um/include/user.h
arch/um/include/user_util.h
arch/um/kernel/Makefile
arch/um/kernel/config.c.in
arch/um/kernel/exec_kern.c
arch/um/kernel/frame.c
arch/um/kernel/frame_kern.c
arch/um/kernel/helper.c
arch/um/kernel/init_task.c
arch/um/kernel/initrd_user.c
arch/um/kernel/irq.c
arch/um/kernel/irq_user.c
arch/um/kernel/ksyms.c
arch/um/kernel/mem.c
arch/um/kernel/mem_user.c
arch/um/kernel/physmem.c [deleted file]
arch/um/kernel/process.c
arch/um/kernel/process_kern.c
arch/um/kernel/ptrace.c
arch/um/kernel/reboot.c
arch/um/kernel/sigio_kern.c
arch/um/kernel/sigio_user.c
arch/um/kernel/signal_kern.c
arch/um/kernel/skas/Makefile
arch/um/kernel/skas/exec_user.c
arch/um/kernel/skas/include/mode.h
arch/um/kernel/skas/include/skas.h
arch/um/kernel/skas/include/uaccess.h
arch/um/kernel/skas/mem_user.c
arch/um/kernel/skas/mmu.c
arch/um/kernel/skas/process.c
arch/um/kernel/skas/process_kern.c
arch/um/kernel/skas/sys-i386/Makefile
arch/um/kernel/skas/sys-i386/sigcontext.c
arch/um/kernel/skas/syscall_kern.c
arch/um/kernel/skas/syscall_user.c
arch/um/kernel/skas/trap_user.c
arch/um/kernel/skas/uaccess.c [deleted file]
arch/um/kernel/skas/util/Makefile
arch/um/kernel/skas/util/mk_ptregs.c
arch/um/kernel/smp.c
arch/um/kernel/sys_call_table.c
arch/um/kernel/syscall_kern.c
arch/um/kernel/sysrq.c
arch/um/kernel/tempfile.c
arch/um/kernel/time.c
arch/um/kernel/time_kern.c
arch/um/kernel/trap_kern.c
arch/um/kernel/trap_user.c
arch/um/kernel/tt/Makefile
arch/um/kernel/tt/exec_kern.c
arch/um/kernel/tt/exec_user.c
arch/um/kernel/tt/include/mode.h
arch/um/kernel/tt/include/uaccess.h
arch/um/kernel/tt/mem.c
arch/um/kernel/tt/mem_user.c
arch/um/kernel/tt/process_kern.c
arch/um/kernel/tt/ptproxy/Makefile
arch/um/kernel/tt/ptproxy/proxy.c
arch/um/kernel/tt/ptproxy/sysdep.c
arch/um/kernel/tt/ptproxy/wait.c
arch/um/kernel/tt/sys-i386/Makefile
arch/um/kernel/tt/syscall_kern.c
arch/um/kernel/tt/syscall_user.c
arch/um/kernel/tt/tlb.c
arch/um/kernel/tt/tracer.c
arch/um/kernel/tt/trap_user.c
arch/um/kernel/tt/uaccess.c [deleted file]
arch/um/kernel/tt/uaccess_user.c
arch/um/kernel/tt/unmap.c
arch/um/kernel/tty_log.c
arch/um/kernel/uaccess_user.c
arch/um/kernel/um_arch.c
arch/um/kernel/umid.c
arch/um/kernel/user_syms.c [deleted file]
arch/um/kernel/user_util.c
arch/um/main.c
arch/um/os-Linux/Makefile
arch/um/os-Linux/drivers/ethertap_kern.c
arch/um/os-Linux/drivers/ethertap_user.c
arch/um/os-Linux/drivers/tuntap_user.c
arch/um/os-Linux/file.c
arch/um/os-Linux/process.c
arch/um/os-Linux/tty.c
arch/um/os-Linux/user_syms.c [deleted file]
arch/um/sys-i386/Makefile
arch/um/sys-i386/bugs.c
arch/um/sys-i386/extable.c [deleted file]
arch/um/sys-i386/fault.c
arch/um/sys-i386/ldt.c
arch/um/sys-i386/ptrace_user.c
arch/um/sys-i386/util/Makefile
arch/um/sys-i386/util/mk_sc.c
arch/um/sys-ia64/Makefile
arch/um/sys-ppc/Makefile
arch/um/uml.lds.S
arch/um/util/Makefile
arch/um/util/mk_constants_kern.c
arch/v850/Kconfig
arch/v850/kernel/ptrace.c
arch/x86_64/Kconfig
arch/x86_64/ia32/ia32_aout.c
arch/x86_64/ia32/ia32_binfmt.c
arch/x86_64/ia32/ia32entry.S
arch/x86_64/ia32/sys_ia32.c
arch/x86_64/kernel/ptrace.c
arch/x86_64/kernel/sys_x86_64.c
arch/x86_64/kernel/traps.c
arch/x86_64/kernel/x8664_ksyms.c
arch/x86_64/mm/Makefile
arch/x86_64/mm/init.c
configs/kernel-2.6.8-i686-planetlab-desktop.config [new file with mode: 0644]
configs/kernel-2.6.8-i686-planetlab.config [new file with mode: 0644]
configs/kernel-2.6.8-i686-uml-planetlab.config [new file with mode: 0644]
crypto/Kconfig
crypto/Makefile
crypto/api.c
crypto/digest.c
crypto/mpi/Makefile [new file with mode: 0644]
crypto/mpi/generic_mpi-asm-defs.h [new file with mode: 0644]
crypto/mpi/generic_mpih-add1.c [new file with mode: 0644]
crypto/mpi/generic_mpih-lshift.c [new file with mode: 0644]
crypto/mpi/generic_mpih-mul1.c [new file with mode: 0644]
crypto/mpi/generic_mpih-mul2.c [new file with mode: 0644]
crypto/mpi/generic_mpih-mul3.c [new file with mode: 0644]
crypto/mpi/generic_mpih-rshift.c [new file with mode: 0644]
crypto/mpi/generic_mpih-sub1.c [new file with mode: 0644]
crypto/mpi/generic_udiv-w-sdiv.c [new file with mode: 0644]
crypto/mpi/longlong.h [new file with mode: 0644]
crypto/mpi/mpi-add.c [new file with mode: 0644]
crypto/mpi/mpi-bit.c [new file with mode: 0644]
crypto/mpi/mpi-cmp.c [new file with mode: 0644]
crypto/mpi/mpi-div.c [new file with mode: 0644]
crypto/mpi/mpi-gcd.c [new file with mode: 0644]
crypto/mpi/mpi-inline.c [new file with mode: 0644]
crypto/mpi/mpi-inline.h [new file with mode: 0644]
crypto/mpi/mpi-internal.h [new file with mode: 0644]
crypto/mpi/mpi-inv.c [new file with mode: 0644]
crypto/mpi/mpi-mpow.c [new file with mode: 0644]
crypto/mpi/mpi-mul.c [new file with mode: 0644]
crypto/mpi/mpi-pow.c [new file with mode: 0644]
crypto/mpi/mpi-scan.c [new file with mode: 0644]
crypto/mpi/mpicoder.c [new file with mode: 0644]
crypto/mpi/mpih-cmp.c [new file with mode: 0644]
crypto/mpi/mpih-div.c [new file with mode: 0644]
crypto/mpi/mpih-mul.c [new file with mode: 0644]
crypto/mpi/mpiutil.c [new file with mode: 0644]
crypto/signature/Makefile [new file with mode: 0644]
crypto/signature/dsa.c [new file with mode: 0644]
crypto/signature/key.h [new file with mode: 0644]
crypto/signature/ksign-parse.c [new file with mode: 0644]
crypto/signature/ksign-publickey.c [new file with mode: 0644]
crypto/signature/local.h [new file with mode: 0644]
drivers/Makefile
drivers/acpi/dispatcher/dsopcode.c
drivers/acpi/ec.c
drivers/block/DAC960.c
drivers/block/Makefile
drivers/block/carmel.c [deleted file]
drivers/block/cciss.c
drivers/block/cfq-iosched-orig.c [new file with mode: 0644]
drivers/block/cfq-iosched.c
drivers/block/ckrm-io.c [new file with mode: 0644]
drivers/block/ckrm-iostub.c [new file with mode: 0644]
drivers/block/elevator.c
drivers/block/floppy98.c [deleted file]
drivers/block/ll_rw_blk.c
drivers/block/scsi_ioctl.c
drivers/char/Kconfig
drivers/char/Makefile
drivers/char/crash.c [new file with mode: 0644]
drivers/char/drm/drm_irq.h [deleted file]
drivers/char/drm/i810_dma.c
drivers/char/drm/i830_dma.c
drivers/char/dz.c [deleted file]
drivers/char/dz.h [deleted file]
drivers/char/h8.c [deleted file]
drivers/char/h8.h [deleted file]
drivers/char/hangcheck-timer.c
drivers/char/hpet.c [deleted file]
drivers/char/hvcs.c [deleted file]
drivers/char/lp.c
drivers/char/lp_old98.c [deleted file]
drivers/char/mem.c
drivers/char/random.c
drivers/char/sh-sci.c [deleted file]
drivers/char/sh-sci.h [deleted file]
drivers/char/sn_serial.c [deleted file]
drivers/char/sysrq.c
drivers/char/tty_io.c
drivers/char/upd4990a.c [deleted file]
drivers/char/watchdog/ixp2000_wdt.c [deleted file]
drivers/char/watchdog/ixp4xx_wdt.c [deleted file]
drivers/dump/Makefile [new file with mode: 0644]
drivers/dump/dump_arm.c [new file with mode: 0644]
drivers/dump/dump_blockdev.c [new file with mode: 0644]
drivers/dump/dump_execute.c [new file with mode: 0644]
drivers/dump/dump_filters.c [new file with mode: 0644]
drivers/dump/dump_fmt.c [new file with mode: 0644]
drivers/dump/dump_gzip.c [new file with mode: 0644]
drivers/dump/dump_i386.c [new file with mode: 0644]
drivers/dump/dump_memdev.c [new file with mode: 0644]
drivers/dump/dump_methods.h [new file with mode: 0644]
drivers/dump/dump_netdev.c [new file with mode: 0644]
drivers/dump/dump_overlay.c [new file with mode: 0644]
drivers/dump/dump_ppc64.c [new file with mode: 0644]
drivers/dump/dump_rle.c [new file with mode: 0644]
drivers/dump/dump_scheme.c [new file with mode: 0644]
drivers/dump/dump_setup.c [new file with mode: 0644]
drivers/firmware/pcdp.c [deleted file]
drivers/firmware/pcdp.h [deleted file]
drivers/i2c/busses/i2c-ixp42x.c [deleted file]
drivers/ide/ide-tcq.c [deleted file]
drivers/ide/legacy/hd98.c [deleted file]
drivers/ide/legacy/pc9800.c [deleted file]
drivers/ide/pci/alim15x3.h [deleted file]
drivers/ide/pci/amd74xx.h [deleted file]
drivers/ide/pci/cmd640.h [deleted file]
drivers/ide/pci/cs5520.c
drivers/ide/pci/cs5520.h [deleted file]
drivers/ide/pci/cs5530.h [deleted file]
drivers/ide/pci/ns87415.h [deleted file]
drivers/ide/pci/rz1000.h [deleted file]
drivers/ide/pci/sc1200.h [deleted file]
drivers/ide/pci/siimage.h [deleted file]
drivers/ide/pci/sis5513.h [deleted file]
drivers/ide/pci/sl82c105.h [deleted file]
drivers/ide/pci/slc90e66.h [deleted file]
drivers/ide/pci/triflex.h [deleted file]
drivers/ide/pci/trm290.h [deleted file]
drivers/ide/pci/via82cxxx.h [deleted file]
drivers/ide/ppc/swarm.c [deleted file]
drivers/input/keyboard/98kbd.c [deleted file]
drivers/input/misc/98spkr.c [deleted file]
drivers/input/mouse/98busmouse.c [deleted file]
drivers/input/serio/98kbd-io.c [deleted file]
drivers/input/serio/i8042.c
drivers/md/Makefile
drivers/mtd/devices/phram.c [deleted file]
drivers/mtd/maps/ichxrom.c [deleted file]
drivers/mtd/nand/diskonchip.c [deleted file]
drivers/mtd/nand/nand.c [deleted file]
drivers/mtd/nand/nand_base.c [deleted file]
drivers/mtd/nand/tx4925ndfmc.c [deleted file]
drivers/net/3c59x.c
drivers/net/Kconfig
drivers/net/Makefile
drivers/net/acenic.c
drivers/net/auto_irq.c [deleted file]
drivers/net/gianfar.c [deleted file]
drivers/net/gianfar.h [deleted file]
drivers/net/gianfar_ethtool.c [deleted file]
drivers/net/gianfar_phy.c [deleted file]
drivers/net/gianfar_phy.h [deleted file]
drivers/net/ne2k_cbus.c [deleted file]
drivers/net/ne2k_cbus.h [deleted file]
drivers/net/netconsole.c
drivers/net/netdump.c [new file with mode: 0644]
drivers/net/netdump.h [new file with mode: 0644]
drivers/net/rcif.h [deleted file]
drivers/net/rclanmtl.c [deleted file]
drivers/net/rclanmtl.h [deleted file]
drivers/net/rcpci45.c [deleted file]
drivers/net/sk98lin/skge.c
drivers/net/tokenring/ibmtr.c
drivers/net/via-velocity.c [deleted file]
drivers/net/wan/comx-hw-comx.c [deleted file]
drivers/net/wan/comx-hw-locomx.c [deleted file]
drivers/net/wan/comx-hw-mixcom.c [deleted file]
drivers/net/wan/comx-hw-munich.c [deleted file]
drivers/net/wan/comx-proto-fr.c [deleted file]
drivers/net/wan/comx-proto-lapb.c [deleted file]
drivers/net/wan/comx-proto-ppp.c [deleted file]
drivers/net/wan/comx.c [deleted file]
drivers/net/wan/comx.h [deleted file]
drivers/net/wan/comxhw.h [deleted file]
drivers/net/wan/falc-lh.h [deleted file]
drivers/net/wan/hscx.h [deleted file]
drivers/net/wan/mixcom.h [deleted file]
drivers/net/wan/munich32x.h [deleted file]
drivers/net/wan/wanxlfw.inc [deleted file]
drivers/pci/search.c
drivers/pcmcia/pd6729.c [deleted file]
drivers/pcmcia/sa1100.h [deleted file]
drivers/pcmcia/sa11xx_core.c [deleted file]
drivers/pcmcia/sa11xx_core.h [deleted file]
drivers/s390/Kconfig
drivers/s390/cio/qdio.c
drivers/s390/cio/qdio.h
drivers/s390/cio/requestirq.c [deleted file]
drivers/s390/net/ctcdbug.c [deleted file]
drivers/s390/net/ctcdbug.h [deleted file]
drivers/scsi/3w-9xxx.c [deleted file]
drivers/scsi/ide-scsi.c
drivers/scsi/megaraid.c
drivers/scsi/pc980155.c [deleted file]
drivers/scsi/pc980155.h [deleted file]
drivers/scsi/pcmcia/qlogic_core.c [deleted file]
drivers/scsi/qla2xxx/qla_os.h [deleted file]
drivers/scsi/qlogicfas.h [deleted file]
drivers/scsi/sata_nv.c [deleted file]
drivers/scsi/scsi_pc98.c [deleted file]
drivers/scsi/sg.c
drivers/serial/8250_hcdp.c [deleted file]
drivers/serial/8250_hcdp.h [deleted file]
drivers/serial/cpm_uart/cpm_uart_core.c [deleted file]
drivers/serial/cpm_uart/cpm_uart_cpm1.c [deleted file]
drivers/serial/cpm_uart/cpm_uart_cpm1.h [deleted file]
drivers/serial/cpm_uart/cpm_uart_cpm2.c [deleted file]
drivers/serial/cpm_uart/cpm_uart_cpm2.h [deleted file]
drivers/serial/mpc52xx_uart.c [deleted file]
drivers/serial/serial98.c [deleted file]
drivers/serial/sn_console.c [deleted file]
drivers/usb/core/driverfs.c [deleted file]
drivers/usb/host/ehci-hcd.c
drivers/usb/media/w9968cf_externaldef.h [deleted file]
drivers/usb/storage/scsiglue.c
drivers/video/aty/radeon_base.c
drivers/video/pxafb.c [deleted file]
drivers/w1/Kconfig [deleted file]
drivers/w1/matrox_w1.c [deleted file]
drivers/w1/w1.c [deleted file]
drivers/w1/w1_int.c [deleted file]
drivers/w1/w1_io.c [deleted file]
fs/Kconfig
fs/Makefile
fs/afs/mntpt.c
fs/attr.c
fs/befs/debug.c
fs/binfmt_aout.c
fs/binfmt_elf.c
fs/binfmt_flat.c
fs/binfmt_som.c
fs/buffer.c
fs/cifs/cifsfs.c
fs/cifs/cifsfs.h
fs/cifs/link.c
fs/dcache.c
fs/devpts/inode.c
fs/exec.c
fs/ext2/acl.c
fs/ext2/balloc.c
fs/ext2/ialloc.c
fs/ext2/inode.c
fs/ext2/ioctl.c
fs/ext2/super.c
fs/ext2/xattr.c
fs/ext3/acl.c
fs/ext3/balloc.c
fs/ext3/ialloc.c
fs/ext3/inode.c
fs/ext3/ioctl.c
fs/ext3/resize.c [deleted file]
fs/ext3/super.c
fs/ext3/xattr.c
fs/fcntl.c
fs/file_table.c
fs/fs-writeback.c
fs/hfsplus/ioctl.c
fs/hostfs/Makefile [deleted file]
fs/hostfs/hostfs.h [deleted file]
fs/hostfs/hostfs_kern.c [deleted file]
fs/hostfs/hostfs_user.c [deleted file]
fs/hppfs/Makefile [deleted file]
fs/hppfs/hppfs_kern.c [deleted file]
fs/hugetlbfs/inode.c
fs/inode.c
fs/intermezzo/Makefile [deleted file]
fs/intermezzo/cache.c [deleted file]
fs/intermezzo/dcache.c [deleted file]
fs/intermezzo/dir.c [deleted file]
fs/intermezzo/ext_attr.c [deleted file]
fs/intermezzo/file.c [deleted file]
fs/intermezzo/fileset.c [deleted file]
fs/intermezzo/inode.c [deleted file]
fs/intermezzo/intermezzo_fs.h [deleted file]
fs/intermezzo/intermezzo_idl.h [deleted file]
fs/intermezzo/intermezzo_journal.h [deleted file]
fs/intermezzo/intermezzo_kml.h [deleted file]
fs/intermezzo/intermezzo_lib.h [deleted file]
fs/intermezzo/intermezzo_psdev.h [deleted file]
fs/intermezzo/intermezzo_upcall.h [deleted file]
fs/intermezzo/journal.c [deleted file]
fs/intermezzo/journal_ext2.c [deleted file]
fs/intermezzo/journal_ext3.c [deleted file]
fs/intermezzo/journal_obdfs.c [deleted file]
fs/intermezzo/journal_reiserfs.c [deleted file]
fs/intermezzo/journal_tmpfs.c [deleted file]
fs/intermezzo/journal_xfs.c [deleted file]
fs/intermezzo/kml.c [deleted file]
fs/intermezzo/kml_decode.c [deleted file]
fs/intermezzo/kml_reint.c [deleted file]
fs/intermezzo/kml_setup.c [deleted file]
fs/intermezzo/kml_unpack.c [deleted file]
fs/intermezzo/kml_utils.c [deleted file]
fs/intermezzo/methods.c [deleted file]
fs/intermezzo/presto.c [deleted file]
fs/intermezzo/psdev.c [deleted file]
fs/intermezzo/replicator.c [deleted file]
fs/intermezzo/super.c [deleted file]
fs/intermezzo/sysctl.c [deleted file]
fs/intermezzo/upcall.c [deleted file]
fs/intermezzo/vfs.c [deleted file]
fs/ioctl.c
fs/jbd/commit.c
fs/jbd/revoke.c
fs/jffs2/compr.h [deleted file]
fs/jfs/acl.c
fs/jfs/jfs_imap.c
fs/lockd/clntlock.c
fs/namei.c
fs/namespace.c
fs/ncpfs/file.c
fs/ncpfs/inode.c
fs/ncpfs/mmap.c
fs/nfs/dir.c
fs/nfs/file.c
fs/nfs/inode.c
fs/nfs/nfs3xdr.c
fs/nfs/nfsroot.c
fs/nfs/symlink.c
fs/nfsd/auth.c
fs/nfsd/nfs3xdr.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfsxdr.c
fs/nfsd/vfs.c
fs/open.c
fs/partitions/nec98.c [deleted file]
fs/partitions/nec98.h [deleted file]
fs/pipe.c
fs/proc/array.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/inode.c
fs/proc/kcore.c
fs/proc/proc_misc.c
fs/proc/root.c
fs/proc/task_mmu.c
fs/rcfs/Makefile [new file with mode: 0644]
fs/rcfs/dir.c [new file with mode: 0644]
fs/rcfs/inode.c [new file with mode: 0644]
fs/rcfs/magic.c [new file with mode: 0644]
fs/rcfs/rootdir.c [new file with mode: 0644]
fs/rcfs/socket_fs.c [new file with mode: 0644]
fs/rcfs/super.c [new file with mode: 0644]
fs/rcfs/tc_magic.c [new file with mode: 0644]
fs/read_write.c
fs/reiserfs/file.c
fs/reiserfs/inode.c
fs/reiserfs/ioctl.c
fs/reiserfs/super.c
fs/reiserfs/xattr.c
fs/relayfs/Makefile [new file with mode: 0644]
fs/relayfs/inode.c [new file with mode: 0644]
fs/relayfs/klog.c [new file with mode: 0644]
fs/relayfs/relay.c [new file with mode: 0644]
fs/relayfs/relay_locking.c [new file with mode: 0644]
fs/relayfs/relay_locking.h [new file with mode: 0644]
fs/relayfs/relay_lockless.c [new file with mode: 0644]
fs/relayfs/relay_lockless.h [new file with mode: 0644]
fs/relayfs/resize.c [new file with mode: 0644]
fs/relayfs/resize.h [new file with mode: 0644]
fs/select.c
fs/stat.c
fs/super.c
fs/sysfs/mount.c
fs/sysfs/symlink.c
fs/sysfs/sysfs.h
fs/xfs/linux-2.6/xfs_ioctl.c
fs/xfs/linux-2.6/xfs_iops.c
fs/xfs/linux-2.6/xfs_super.c
fs/xfs/linux-2.6/xfs_sysctl.c [deleted file]
fs/xfs/linux-2.6/xfs_vnode.c
fs/xfs/linux/kmem.h [deleted file]
fs/xfs/linux/mrlock.h [deleted file]
fs/xfs/linux/mutex.h [deleted file]
fs/xfs/linux/sema.h [deleted file]
fs/xfs/linux/spin.h [deleted file]
fs/xfs/linux/sv.h [deleted file]
fs/xfs/linux/time.h [deleted file]
fs/xfs/linux/xfs_aops.c [deleted file]
fs/xfs/linux/xfs_buf.c [deleted file]
fs/xfs/linux/xfs_buf.h [deleted file]
fs/xfs/linux/xfs_cred.h [deleted file]
fs/xfs/linux/xfs_file.c [deleted file]
fs/xfs/linux/xfs_fs_subr.c [deleted file]
fs/xfs/linux/xfs_fs_subr.h [deleted file]
fs/xfs/linux/xfs_globals.c [deleted file]
fs/xfs/linux/xfs_globals.h [deleted file]
fs/xfs/linux/xfs_ioctl.c [deleted file]
fs/xfs/linux/xfs_iops.c [deleted file]
fs/xfs/linux/xfs_iops.h [deleted file]
fs/xfs/linux/xfs_linux.h [deleted file]
fs/xfs/linux/xfs_lrw.c [deleted file]
fs/xfs/linux/xfs_lrw.h [deleted file]
fs/xfs/linux/xfs_stats.c [deleted file]
fs/xfs/linux/xfs_stats.h [deleted file]
fs/xfs/linux/xfs_super.c [deleted file]
fs/xfs/linux/xfs_super.h [deleted file]
fs/xfs/linux/xfs_sysctl.c [deleted file]
fs/xfs/linux/xfs_sysctl.h [deleted file]
fs/xfs/linux/xfs_version.h [deleted file]
fs/xfs/linux/xfs_vfs.c [deleted file]
fs/xfs/linux/xfs_vfs.h [deleted file]
fs/xfs/linux/xfs_vnode.c [deleted file]
fs/xfs/linux/xfs_vnode.h [deleted file]
fs/xfs/xfs_dinode.h
fs/xfs/xfs_fs.h
fs/xfs/xfs_inode.c
fs/xfs/xfs_vnodeops.c
include/acpi/platform/aclinux.h
include/asm-alpha/cpumask.h [deleted file]
include/asm-alpha/fcntl.h
include/asm-alpha/init.h [deleted file]
include/asm-alpha/page.h
include/asm-alpha/relay.h [new file with mode: 0644]
include/asm-alpha/resource.h
include/asm-alpha/rmap.h [deleted file]
include/asm-alpha/uaccess.h
include/asm-alpha/unistd.h
include/asm-arm/arch-adifcc/adi_evb.h [deleted file]
include/asm-arm/arch-adifcc/dma.h [deleted file]
include/asm-arm/arch-adifcc/hardware.h [deleted file]
include/asm-arm/arch-adifcc/io.h [deleted file]
include/asm-arm/arch-adifcc/irqs.h [deleted file]
include/asm-arm/arch-adifcc/memory.h [deleted file]
include/asm-arm/arch-adifcc/param.h [deleted file]
include/asm-arm/arch-adifcc/serial.h [deleted file]
include/asm-arm/arch-adifcc/system.h [deleted file]
include/asm-arm/arch-adifcc/time.h [deleted file]
include/asm-arm/arch-adifcc/timex.h [deleted file]
include/asm-arm/arch-adifcc/uncompress.h [deleted file]
include/asm-arm/arch-adifcc/vmalloc.h [deleted file]
include/asm-arm/arch-cl7500/ide.h [deleted file]
include/asm-arm/arch-cl7500/keyboard.h [deleted file]
include/asm-arm/arch-cl7500/time.h [deleted file]
include/asm-arm/arch-clps711x/keyboard.h [deleted file]
include/asm-arm/arch-ebsa110/ide.h [deleted file]
include/asm-arm/arch-ebsa110/time.h [deleted file]
include/asm-arm/arch-ebsa285/ide.h [deleted file]
include/asm-arm/arch-ebsa285/time.h [deleted file]
include/asm-arm/arch-epxa10db/time.h [deleted file]
include/asm-arm/arch-iop3xx/ide.h [deleted file]
include/asm-arm/arch-iop3xx/time.h [deleted file]
include/asm-arm/arch-ixp4xx/time.h [deleted file]
include/asm-arm/arch-l7200/ide.h [deleted file]
include/asm-arm/arch-l7200/keyboard.h [deleted file]
include/asm-arm/arch-lh7a40x/ide.h [deleted file]
include/asm-arm/arch-lh7a40x/time.h [deleted file]
include/asm-arm/arch-nexuspci/dma.h [deleted file]
include/asm-arm/arch-nexuspci/hardware.h [deleted file]
include/asm-arm/arch-nexuspci/ide.h [deleted file]
include/asm-arm/arch-nexuspci/io.h [deleted file]
include/asm-arm/arch-nexuspci/irqs.h [deleted file]
include/asm-arm/arch-nexuspci/memory.h [deleted file]
include/asm-arm/arch-nexuspci/param.h [deleted file]
include/asm-arm/arch-nexuspci/system.h [deleted file]
include/asm-arm/arch-nexuspci/time.h [deleted file]
include/asm-arm/arch-nexuspci/timex.h [deleted file]
include/asm-arm/arch-nexuspci/uncompress.h [deleted file]
include/asm-arm/arch-nexuspci/vmalloc.h [deleted file]
include/asm-arm/arch-omap/omap-h2.h [deleted file]
include/asm-arm/arch-omap/omap-innovator.h [deleted file]
include/asm-arm/arch-omap/omap-perseus2.h [deleted file]
include/asm-arm/arch-omap/time.h [deleted file]
include/asm-arm/arch-pxa/ide.h [deleted file]
include/asm-arm/arch-pxa/keyboard.h [deleted file]
include/asm-arm/arch-pxa/time.h [deleted file]
include/asm-arm/arch-rpc/ide.h [deleted file]
include/asm-arm/arch-rpc/time.h [deleted file]
include/asm-arm/arch-s3c2410/ide.h [deleted file]
include/asm-arm/arch-s3c2410/time.h [deleted file]
include/asm-arm/arch-sa1100/keyboard.h [deleted file]
include/asm-arm/arch-sa1100/time.h [deleted file]
include/asm-arm/arch-shark/ide.h [deleted file]
include/asm-arm/arch-shark/keyboard.h [deleted file]
include/asm-arm/arch-shark/time.h [deleted file]
include/asm-arm/arch-tbox/dma.h [deleted file]
include/asm-arm/arch-tbox/hardware.h [deleted file]
include/asm-arm/arch-tbox/ide.h [deleted file]
include/asm-arm/arch-tbox/io.h [deleted file]
include/asm-arm/arch-tbox/irqs.h [deleted file]
include/asm-arm/arch-tbox/memory.h [deleted file]
include/asm-arm/arch-tbox/param.h [deleted file]
include/asm-arm/arch-tbox/serial.h [deleted file]
include/asm-arm/arch-tbox/system.h [deleted file]
include/asm-arm/arch-tbox/time.h [deleted file]
include/asm-arm/arch-tbox/timex.h [deleted file]
include/asm-arm/arch-tbox/uncompress.h [deleted file]
include/asm-arm/arch-tbox/vmalloc.h [deleted file]
include/asm-arm/arch-versatile/time.h [deleted file]
include/asm-arm/cpumask.h [deleted file]
include/asm-arm/page.h
include/asm-arm/relay.h [new file with mode: 0644]
include/asm-arm/resource.h
include/asm-arm/rmap.h [deleted file]
include/asm-arm/tlb.h
include/asm-arm/uaccess.h
include/asm-arm26/cpumask.h [deleted file]
include/asm-arm26/page.h
include/asm-arm26/relay.h [new file with mode: 0644]
include/asm-arm26/resource.h
include/asm-arm26/rmap.h [deleted file]
include/asm-arm26/tlb.h
include/asm-arm26/uaccess.h
include/asm-cris/cpumask.h [deleted file]
include/asm-cris/page.h
include/asm-cris/relay.h [new file with mode: 0644]
include/asm-cris/resource.h
include/asm-cris/rmap.h [deleted file]
include/asm-cris/uaccess.h
include/asm-generic/cpumask.h [deleted file]
include/asm-generic/cpumask_arith.h [deleted file]
include/asm-generic/cpumask_array.h [deleted file]
include/asm-generic/cpumask_const_reference.h [deleted file]
include/asm-generic/cpumask_const_value.h [deleted file]
include/asm-generic/cpumask_up.h [deleted file]
include/asm-generic/netdump.h [new file with mode: 0644]
include/asm-generic/relay.h [new file with mode: 0644]
include/asm-generic/rmap.h [deleted file]
include/asm-generic/tlb.h
include/asm-h8300/aki3068net/machine-depend.h [deleted file]
include/asm-h8300/cpumask.h [deleted file]
include/asm-h8300/edosk2674/machine-depend.h [deleted file]
include/asm-h8300/generic/machine-depend.h [deleted file]
include/asm-h8300/generic/timer_rate.h [deleted file]
include/asm-h8300/h8300_ne.h [deleted file]
include/asm-h8300/h8300_smsc.h [deleted file]
include/asm-h8300/h8max/machine-depend.h [deleted file]
include/asm-h8300/init.h [deleted file]
include/asm-h8300/page.h
include/asm-h8300/relay.h [new file with mode: 0644]
include/asm-h8300/resource.h
include/asm-h8300/uaccess.h
include/asm-i386/atomic_kmap.h [new file with mode: 0644]
include/asm-i386/checksum.h
include/asm-i386/cpumask.h [deleted file]
include/asm-i386/crash.h [new file with mode: 0644]
include/asm-i386/desc.h
include/asm-i386/dump.h [new file with mode: 0644]
include/asm-i386/elf.h
include/asm-i386/fcntl.h
include/asm-i386/fixmap.h
include/asm-i386/highmem.h
include/asm-i386/init.h [deleted file]
include/asm-i386/irq.h
include/asm-i386/kmap_types.h
include/asm-i386/mach-default/irq_vectors.h
include/asm-i386/mach-pc9800/apm.h [deleted file]
include/asm-i386/mach-pc9800/bios_ebda.h [deleted file]
include/asm-i386/mach-pc9800/do_timer.h [deleted file]
include/asm-i386/mach-pc9800/io_ports.h [deleted file]
include/asm-i386/mach-pc9800/irq_vectors.h [deleted file]
include/asm-i386/mach-pc9800/mach_reboot.h [deleted file]
include/asm-i386/mach-pc9800/mach_time.h [deleted file]
include/asm-i386/mach-pc9800/mach_timer.h [deleted file]
include/asm-i386/mach-pc9800/mach_traps.h [deleted file]
include/asm-i386/mach-pc9800/mach_wakecpu.h [deleted file]
include/asm-i386/mach-pc9800/pci-functions.h [deleted file]
include/asm-i386/mach-pc9800/setup_arch_post.h [deleted file]
include/asm-i386/mach-pc9800/setup_arch_pre.h [deleted file]
include/asm-i386/mach-pc9800/smpboot_hooks.h [deleted file]
include/asm-i386/mmu.h
include/asm-i386/mmu_context.h
include/asm-i386/module.h
include/asm-i386/netdump.h [new file with mode: 0644]
include/asm-i386/page.h
include/asm-i386/pc9800.h [deleted file]
include/asm-i386/pc9800_sca.h [deleted file]
include/asm-i386/pgalloc.h
include/asm-i386/pgtable.h
include/asm-i386/processor.h
include/asm-i386/relay.h [new file with mode: 0644]
include/asm-i386/resource.h
include/asm-i386/rmap.h [deleted file]
include/asm-i386/smp.h
include/asm-i386/std_resources.h [deleted file]
include/asm-i386/string.h
include/asm-i386/thread_info.h
include/asm-i386/tlbflush.h
include/asm-i386/uaccess.h
include/asm-i386/unistd.h
include/asm-i386/upd4990a.h [deleted file]
include/asm-ia64/cpumask.h [deleted file]
include/asm-ia64/crash.h [new file with mode: 0644]
include/asm-ia64/fcntl.h
include/asm-ia64/netdump.h [new file with mode: 0644]
include/asm-ia64/page.h
include/asm-ia64/pgalloc.h
include/asm-ia64/relay.h [new file with mode: 0644]
include/asm-ia64/resource.h
include/asm-ia64/rmap.h [deleted file]
include/asm-ia64/sn/pda.h
include/asm-ia64/tlb.h
include/asm-ia64/uaccess.h
include/asm-ia64/unistd.h
include/asm-m68k/cpumask.h [deleted file]
include/asm-m68k/init.h [deleted file]
include/asm-m68k/page.h
include/asm-m68k/relay.h [new file with mode: 0644]
include/asm-m68k/resource.h
include/asm-m68k/rmap.h [deleted file]
include/asm-m68k/uaccess.h
include/asm-m68k/unistd.h
include/asm-m68knommu/cpumask.h [deleted file]
include/asm-m68knommu/init.h [deleted file]
include/asm-m68knommu/page.h
include/asm-m68knommu/relay.h [new file with mode: 0644]
include/asm-m68knommu/rmap.h [deleted file]
include/asm-m68knommu/uaccess.h
include/asm-m68knommu/unistd.h
include/asm-mips/cpumask.h [deleted file]
include/asm-mips/init.h [deleted file]
include/asm-mips/page.h
include/asm-mips/processor.h
include/asm-mips/relay.h [new file with mode: 0644]
include/asm-mips/rmap.h [deleted file]
include/asm-mips/uaccess.h
include/asm-mips/vr41xx/eagle.h [deleted file]
include/asm-mips/vr41xx/tb0229.h [deleted file]
include/asm-mips64/relay.h [new file with mode: 0644]
include/asm-parisc/cpumask.h [deleted file]
include/asm-parisc/page.h
include/asm-parisc/relay.h [new file with mode: 0644]
include/asm-parisc/resource.h
include/asm-parisc/rmap.h [deleted file]
include/asm-parisc/uaccess.h
include/asm-parisc/unistd.h
include/asm-parisc/unwind.h [deleted file]
include/asm-ppc/cpm2.h [deleted file]
include/asm-ppc/cpm_8260.h [deleted file]
include/asm-ppc/cpumask.h [deleted file]
include/asm-ppc/fcntl.h
include/asm-ppc/immap_8260.h [deleted file]
include/asm-ppc/mpc52xx.h [deleted file]
include/asm-ppc/mpc52xx_psc.h [deleted file]
include/asm-ppc/mpc85xx.h [deleted file]
include/asm-ppc/mv64x60.h [deleted file]
include/asm-ppc/mv64x60_defs.h [deleted file]
include/asm-ppc/page.h
include/asm-ppc/pgalloc.h
include/asm-ppc/ppc405_dma.h [deleted file]
include/asm-ppc/ppc4xx_dma.h [deleted file]
include/asm-ppc/relay.h [new file with mode: 0644]
include/asm-ppc/resource.h
include/asm-ppc/rmap.h [deleted file]
include/asm-ppc/setup.h
include/asm-ppc/uaccess.h
include/asm-ppc/unistd.h
include/asm-ppc64/cpumask.h [deleted file]
include/asm-ppc64/fcntl.h
include/asm-ppc64/hvcserver.h [deleted file]
include/asm-ppc64/init.h [deleted file]
include/asm-ppc64/netdump.h [new file with mode: 0644]
include/asm-ppc64/page.h
include/asm-ppc64/pgalloc.h
include/asm-ppc64/processor.h
include/asm-ppc64/relay.h [new file with mode: 0644]
include/asm-ppc64/resource.h
include/asm-ppc64/rmap.h [deleted file]
include/asm-ppc64/uaccess.h
include/asm-ppc64/unistd.h
include/asm-s390/cpumask.h [deleted file]
include/asm-s390/fcntl.h
include/asm-s390/init.h [deleted file]
include/asm-s390/netdump.h [new file with mode: 0644]
include/asm-s390/page.h
include/asm-s390/pgalloc.h
include/asm-s390/processor.h
include/asm-s390/relay.h [new file with mode: 0644]
include/asm-s390/resource.h
include/asm-s390/rmap.h [deleted file]
include/asm-s390/uaccess.h
include/asm-s390/unistd.h
include/asm-sh/cpumask.h [deleted file]
include/asm-sh/init.h [deleted file]
include/asm-sh/page.h
include/asm-sh/relay.h [new file with mode: 0644]
include/asm-sh/resource.h
include/asm-sh/rmap.h [deleted file]
include/asm-sh/uaccess.h
include/asm-sh64/page.h [deleted file]
include/asm-sh64/uaccess.h
include/asm-sparc/cpumask.h [deleted file]
include/asm-sparc/fcntl.h
include/asm-sparc/init.h [deleted file]
include/asm-sparc/page.h
include/asm-sparc/pgalloc.h
include/asm-sparc/relay.h [new file with mode: 0644]
include/asm-sparc/resource.h
include/asm-sparc/rmap.h [deleted file]
include/asm-sparc/uaccess.h
include/asm-sparc/unistd.h
include/asm-sparc64/cpumask.h [deleted file]
include/asm-sparc64/fcntl.h
include/asm-sparc64/init.h [deleted file]
include/asm-sparc64/page.h
include/asm-sparc64/pgalloc.h
include/asm-sparc64/relay.h [new file with mode: 0644]
include/asm-sparc64/resource.h
include/asm-sparc64/rmap.h [deleted file]
include/asm-sparc64/uaccess.h
include/asm-sparc64/unistd.h
include/asm-um/archparam-i386.h
include/asm-um/bug.h
include/asm-um/common.lds.S
include/asm-um/cpufeature.h [deleted file]
include/asm-um/cpumask.h [deleted file]
include/asm-um/current.h
include/asm-um/dma-mapping.h
include/asm-um/elf.h
include/asm-um/fixmap.h
include/asm-um/init.h [deleted file]
include/asm-um/irq.h
include/asm-um/local.h [deleted file]
include/asm-um/mmu_context.h
include/asm-um/module-generic.h [deleted file]
include/asm-um/page.h
include/asm-um/pgalloc.h
include/asm-um/pgtable.h
include/asm-um/processor-generic.h
include/asm-um/processor-i386.h
include/asm-um/rmap.h [deleted file]
include/asm-um/sections.h [deleted file]
include/asm-um/smp.h
include/asm-um/smplock.h [deleted file]
include/asm-um/spinlock.h [deleted file]
include/asm-um/system-generic.h
include/asm-um/system-i386.h
include/asm-um/thread_info.h
include/asm-um/timex.h
include/asm-um/uaccess.h
include/asm-um/unistd.h
include/asm-v850/cpumask.h [deleted file]
include/asm-v850/page.h
include/asm-v850/relay.h [new file with mode: 0644]
include/asm-v850/resource.h
include/asm-v850/rmap.h [deleted file]
include/asm-v850/uaccess.h
include/asm-x86_64/cpumask.h [deleted file]
include/asm-x86_64/fcntl.h
include/asm-x86_64/init.h [deleted file]
include/asm-x86_64/netdump.h [new file with mode: 0644]
include/asm-x86_64/page.h
include/asm-x86_64/pgalloc.h
include/asm-x86_64/processor.h
include/asm-x86_64/relay.h [new file with mode: 0644]
include/asm-x86_64/resource.h
include/asm-x86_64/rmap.h [deleted file]
include/asm-x86_64/uaccess.h
include/asm-x86_64/unistd.h
include/linux/802_11.h [deleted file]
include/linux/acpi_serial.h [deleted file]
include/linux/adb_mouse.h [deleted file]
include/linux/atapi.h [deleted file]
include/linux/buffer_head.h
include/linux/capability.h
include/linux/ckrm-io.h [new file with mode: 0644]
include/linux/ckrm.h [new file with mode: 0644]
include/linux/ckrm_ce.h [new file with mode: 0644]
include/linux/ckrm_classqueue.h [new file with mode: 0644]
include/linux/ckrm_mem.h [new file with mode: 0644]
include/linux/ckrm_mem_inline.h [new file with mode: 0644]
include/linux/ckrm_net.h [new file with mode: 0644]
include/linux/ckrm_rc.h [new file with mode: 0644]
include/linux/ckrm_sched.h [new file with mode: 0644]
include/linux/ckrm_tc.h [new file with mode: 0644]
include/linux/ckrm_tsk.h [new file with mode: 0644]
include/linux/compat_ioctl.h
include/linux/config.h
include/linux/crbce.h [new file with mode: 0644]
include/linux/crypto.h
include/linux/crypto/ksign.h [new file with mode: 0644]
include/linux/crypto/mpi.h [new file with mode: 0644]
include/linux/dcache.h
include/linux/delay.h
include/linux/devpts_fs.h
include/linux/dump.h [new file with mode: 0644]
include/linux/dump_netdev.h [new file with mode: 0644]
include/linux/dumpdev.h [new file with mode: 0644]
include/linux/elevator.h
include/linux/errno.h
include/linux/ext2_fs.h
include/linux/ext3_fs.h
include/linux/file.h
include/linux/fs.h
include/linux/fsfilter.h [deleted file]
include/linux/gfp.h
include/linux/highmem.h
include/linux/hugetlb.h
include/linux/in_systm.h [deleted file]
include/linux/init_task.h
include/linux/ip.h
include/linux/ipc.h
include/linux/isdn_lzscomp.h [deleted file]
include/linux/kernel.h
include/linux/kernel_stat.h
include/linux/klog.h [new file with mode: 0644]
include/linux/kmalloc_sizes.h
include/linux/libata.h
include/linux/miscdevice.h
include/linux/mm.h
include/linux/mm_inline.h
include/linux/mmzone.h
include/linux/module.h
include/linux/mount.h
include/linux/mpp.h [deleted file]
include/linux/mtd/physmap.h [deleted file]
include/linux/namei.h
include/linux/namespace.h
include/linux/net.h
include/linux/netbeui.h [deleted file]
include/linux/netdevice.h
include/linux/netfilter_ddp.h [deleted file]
include/linux/netfilter_ipv4/ip_conntrack.h
include/linux/netfilter_ipx.h [deleted file]
include/linux/netfilter_x25.h [deleted file]
include/linux/netpoll.h
include/linux/nfs_mount.h
include/linux/page-flags.h
include/linux/pagemap.h
include/linux/pci.h
include/linux/personality.h
include/linux/proc_fs.h
include/linux/ptrace.h
include/linux/random.h
include/linux/rbce.h [new file with mode: 0644]
include/linux/rcfs.h [new file with mode: 0644]
include/linux/reiserfs_fs.h
include/linux/reiserfs_fs_sb.h
include/linux/relayfs_fs.h [new file with mode: 0644]
include/linux/resource.h
include/linux/sched.h
include/linux/shm.h
include/linux/shmem_fs.h
include/linux/skbuff.h
include/linux/smp_lock.h
include/linux/snmp.h [deleted file]
include/linux/socket.h
include/linux/stat.h
include/linux/sunrpc/auth.h
include/linux/sunrpc/clnt.h
include/linux/swap.h
include/linux/sysctl.h
include/linux/sysfs.h
include/linux/taskdelays.h [new file with mode: 0644]
include/linux/tcp.h
include/linux/time.h
include/linux/types.h
include/linux/upd4990a.h [deleted file]
include/linux/vs_base.h [new file with mode: 0644]
include/linux/vs_context.h [new file with mode: 0644]
include/linux/vs_cvirt.h [new file with mode: 0644]
include/linux/vs_dlimit.h [new file with mode: 0644]
include/linux/vs_limit.h [new file with mode: 0644]
include/linux/vs_memory.h [new file with mode: 0644]
include/linux/vs_network.h [new file with mode: 0644]
include/linux/vs_socket.h [new file with mode: 0644]
include/linux/vserver.h [new file with mode: 0644]
include/linux/vserver/context.h [new file with mode: 0644]
include/linux/vserver/cvirt.h [new file with mode: 0644]
include/linux/vserver/debug.h [new file with mode: 0644]
include/linux/vserver/dlimit.h [new file with mode: 0644]
include/linux/vserver/inode.h [new file with mode: 0644]
include/linux/vserver/legacy.h [new file with mode: 0644]
include/linux/vserver/limit.h [new file with mode: 0644]
include/linux/vserver/namespace.h [new file with mode: 0644]
include/linux/vserver/network.h [new file with mode: 0644]
include/linux/vserver/sched.h [new file with mode: 0644]
include/linux/vserver/signal.h [new file with mode: 0644]
include/linux/vserver/switch.h [new file with mode: 0644]
include/linux/vserver/xid.h [new file with mode: 0644]
include/linux/wait.h
include/linux/writeback.h
include/mtd/mtd-abi.h [deleted file]
include/net/af_unix.h
include/net/route.h
include/net/scm.h
include/net/sock.h
include/net/tcp.h
include/net/tux.h [new file with mode: 0644]
include/net/tux_u.h [new file with mode: 0644]
include/scsi/scsi_host.h
init/Kconfig
init/Makefile
init/kerntypes.c [new file with mode: 0644]
init/main.c
init/version.c
ipc/msg.c
ipc/sem.c
ipc/shm.c
ipc/util.c
kernel/Makefile
kernel/ckrm/Makefile [new file with mode: 0644]
kernel/ckrm/ckrm.c [new file with mode: 0644]
kernel/ckrm/ckrm_cpu_class.c [new file with mode: 0644]
kernel/ckrm/ckrm_cpu_monitor.c [new file with mode: 0644]
kernel/ckrm/ckrm_laq.c [new file with mode: 0644]
kernel/ckrm/ckrm_listenaq.c [new file with mode: 0644]
kernel/ckrm/ckrm_mem.c [new file with mode: 0644]
kernel/ckrm/ckrm_numtasks.c [new file with mode: 0644]
kernel/ckrm/ckrm_numtasks_stub.c [new file with mode: 0644]
kernel/ckrm/ckrm_sockc.c [new file with mode: 0644]
kernel/ckrm/ckrm_tc.c [new file with mode: 0644]
kernel/ckrm/ckrmutils.c [new file with mode: 0644]
kernel/ckrm/rbce/Makefile [new file with mode: 0644]
kernel/ckrm/rbce/bitvector.h [new file with mode: 0644]
kernel/ckrm/rbce/crbce.h [new file with mode: 0644]
kernel/ckrm/rbce/crbcemod.c [new file with mode: 0644]
kernel/ckrm/rbce/info.h [new file with mode: 0644]
kernel/ckrm/rbce/rbce.h [new file with mode: 0644]
kernel/ckrm/rbce/rbce_fs.c [new file with mode: 0644]
kernel/ckrm/rbce/rbcemod.c [new file with mode: 0644]
kernel/ckrm/rbce/rbcemod_ext.c [new file with mode: 0644]
kernel/ckrm/rbce/token.c [new file with mode: 0644]
kernel/ckrm_classqueue.c [new file with mode: 0644]
kernel/ckrm_sched.c [new file with mode: 0644]
kernel/exit.c
kernel/fork.c
kernel/kallsyms.c
kernel/module-verify.c [new file with mode: 0644]
kernel/module-verify.h [new file with mode: 0644]
kernel/module.c
kernel/panic.c
kernel/pid.c
kernel/printk.c
kernel/sched.c
kernel/signal.c
kernel/sys.c
kernel/sysctl.c
kernel/timer.c
kernel/user.c
kernel/vserver/Kconfig [new file with mode: 0644]
kernel/vserver/Makefile [new file with mode: 0644]
kernel/vserver/context.c [new file with mode: 0644]
kernel/vserver/cvirt.c [new file with mode: 0644]
kernel/vserver/dlimit.c [new file with mode: 0644]
kernel/vserver/helper.c [new file with mode: 0644]
kernel/vserver/init.c [new file with mode: 0644]
kernel/vserver/inode.c [new file with mode: 0644]
kernel/vserver/legacy.c [new file with mode: 0644]
kernel/vserver/limit.c [new file with mode: 0644]
kernel/vserver/namespace.c [new file with mode: 0644]
kernel/vserver/network.c [new file with mode: 0644]
kernel/vserver/proc.c [new file with mode: 0644]
kernel/vserver/sched.c [new file with mode: 0644]
kernel/vserver/signal.c [new file with mode: 0644]
kernel/vserver/switch.c [new file with mode: 0644]
kernel/vserver/sysctl.c [new file with mode: 0644]
mm/Makefile
mm/bootmem.c
mm/filemap.c
mm/fremap.c
mm/memory.c
mm/mempool.c
mm/mlock.c
mm/mmap.c
mm/mprotect.c
mm/mremap.c
mm/oom_kill.c
mm/oom_panic.c [new file with mode: 0644]
mm/page_alloc.c
mm/pdflush.c
mm/rmap.c
mm/shmem.c
mm/slab.c
mm/swapfile.c
mm/usercopy.c [new file with mode: 0644]
mm/vmscan.c
net/Kconfig
net/Makefile
net/bluetooth/hidp/core.c [deleted file]
net/bluetooth/syms.c [deleted file]
net/core/dev.c
net/core/netfilter.c
net/core/netpoll.c
net/core/skbuff.c
net/core/sock.c
net/ipv4/Kconfig
net/ipv4/af_inet.c
net/ipv4/datagram.c [deleted file]
net/ipv4/icmp.c
net/ipv4/netfilter/ip_conntrack_core.c
net/ipv4/netfilter/ip_conntrack_standalone.c
net/ipv4/netfilter/ipt_MARK.c
net/ipv4/raw.c
net/ipv4/sysctl_net_ipv4.c
net/ipv4/tcp.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_timer.c
net/ipv4/udp.c
net/ipv4/xfrm4_output.c [deleted file]
net/ipv6/tcp_ipv6.c
net/ipv6/xfrm6_output.c [deleted file]
net/ipv6/xfrm6_tunnel.c [deleted file]
net/irda/crc.c [deleted file]
net/packet/af_packet.c
net/sched/sch_api.c
net/sched/sch_csz.c [deleted file]
net/sched/sch_delay.c [deleted file]
net/sched/sch_netem.c [deleted file]
net/socket.c
net/sunrpc/auth.c
net/sunrpc/auth_unix.c
net/sunrpc/clnt.c
net/tux/Kconfig [new file with mode: 0644]
net/tux/Makefile [new file with mode: 0644]
net/tux/abuf.c [new file with mode: 0644]
net/tux/accept.c [new file with mode: 0644]
net/tux/cachemiss.c [new file with mode: 0644]
net/tux/cgi.c [new file with mode: 0644]
net/tux/directory.c [new file with mode: 0644]
net/tux/extcgi.c [new file with mode: 0644]
net/tux/gzip.c [new file with mode: 0644]
net/tux/input.c [new file with mode: 0644]
net/tux/logger.c [new file with mode: 0644]
net/tux/main.c [new file with mode: 0644]
net/tux/mod.c [new file with mode: 0644]
net/tux/output.c [new file with mode: 0644]
net/tux/parser.h [new file with mode: 0644]
net/tux/postpone.c [new file with mode: 0644]
net/tux/proc.c [new file with mode: 0644]
net/tux/proto_ftp.c [new file with mode: 0644]
net/tux/proto_http.c [new file with mode: 0644]
net/tux/redirect.c [new file with mode: 0644]
net/tux/times.c [new file with mode: 0644]
net/tux/times.h [new file with mode: 0644]
net/tux/userspace.c [new file with mode: 0644]
net/unix/af_unix.c
net/xfrm/xfrm_output.c [deleted file]
scripts/empty.c [deleted file]
scripts/file2alias.c [deleted file]
scripts/kconfig/Makefile
scripts/kconfig/conf.c
scripts/kernel-2.6-planetlab.spec [new file with mode: 0644]
scripts/mk_elfconfig.c [deleted file]
scripts/mkcompile_h
scripts/mkconfigs [deleted file]
scripts/mkmakefile [deleted file]
scripts/mkspec [deleted file]
scripts/mod/Makefile [deleted file]
scripts/mod/empty.c [deleted file]
scripts/mod/file2alias.c [deleted file]
scripts/mod/mk_elfconfig.c [deleted file]
scripts/mod/modpost.c [deleted file]
scripts/mod/modpost.h [deleted file]
scripts/mod/sumversion.c [deleted file]
scripts/modpost.c [deleted file]
scripts/modpost.h [deleted file]
scripts/modsign/Makefile [new file with mode: 0644]
scripts/modsign/mod-extract.c [new file with mode: 0644]
scripts/modsign/mod-extract.sh [new file with mode: 0644]
scripts/modsign/modsign.sh [new file with mode: 0644]
scripts/package/Makefile [deleted file]
scripts/package/mkspec [deleted file]
scripts/reference_discarded.pl
scripts/reference_init.pl
scripts/sumversion.c [deleted file]
security/commoncap.c
sound/core/oss/Makefile
sound/core/oss/pcm_oss.c
sound/isa/cs423x/pc98.c [deleted file]
sound/isa/cs423x/pc9801_118_magic.h [deleted file]
sound/isa/cs423x/sound_pc9800.h [deleted file]
sound/pci/ice1712/prodigy.c [deleted file]
sound/pci/ice1712/prodigy.h [deleted file]
sound/pci/nm256/nm256.c

diff --git a/Documentation/COPYING.modules b/Documentation/COPYING.modules
new file mode 100644 (file)
index 0000000..da0266e
--- /dev/null
@@ -0,0 +1,708 @@
+Date:  Thu, 29 Apr 2004 14:10:41 -0700 (PDT)
+From:  Linus Torvalds <torvalds@osdl.org>
+To:    Giuliano Colla
+cc:    Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
+Subject: Re: [hsflinux] [PATCH] Blacklist binary-only modules lying about
+       their license
+Message-ID: <Pine.LNX.4.58.0404291404100.1629@ppc970.osdl.org>
+
+On Thu, 29 Apr 2004, Giuliano Colla wrote:
+> 
+> Let's try not to be ridiculous, please.
+
+It's not abotu being ridiculous. It's about honoring peoples copyrights.
+
+> As an end user, if I buy a full fledged modem, I get some amount of 
+> proprietary, non GPL, code  which executes within the board or the 
+> PCMCIA card of the modem. The GPL driver may even support the 
+> functionality of downloading a new version of *proprietary* code into 
+> the flash Eprom of the device. The GPL linux driver interfaces with it, 
+> and all is kosher.
+
+Indeed. Everything is kosher, because the other piece of hardware and 
+software has _nothing_ to do with the kernel. It's not linked into it, it 
+cannot reasonably corrupt internal kernel data structures with random 
+pointer bugs, and in general you can think of firmware as part of the 
+_hardware_, not the software of the machine.
+
+> On the other hand, I have the misfortune of being stuck with a 
+> soft-modem, roughly the *same* proprietary code is provided as a binary 
+> file, and a linux driver (source provided) interfaces with it. In that 
+> case the kernel is flagged as "tainted".
+
+It is flagged as tainted, because your argument that it is "the same code" 
+is totally BOGUS AND UNTRUE!
+
+In the binary kernel module case, a bug in the code corrupts random data 
+structures, or accesses kernel internals without holding the proper locks, 
+or does a million other things wrong, BECAUSE A KERNEL MODULE IS VERY 
+INTIMATELY LINKED WITH THE KERNEL.
+
+A kernel module is _not_ a separate work, and can in _no_ way be seen as 
+"part of the hardware". It's very much a part of the _kernel_. And the 
+kernel developers require that such code be GPL'd so that it can be fixed, 
+or if there's a valid argument that it's not a derived work and not GPL'd, 
+then the kernel developers who have to support the end result mess most 
+definitely do need to know about the taint.
+
+You are not the first (and sadly, you likely won't be the last) person to 
+equate binary kernel modules with binary firmware. And I tell you that 
+such a comparison is ABSOLUTE CRAPOLA. There's a damn big difference 
+between running firmware on another chip behind a PCI bus, and linking 
+into the kernel directly.
+
+And if you don't see that difference, then you are either terminally 
+stupid, or you have some ulterior reason to claim that they are the same 
+case even though they clearly are NOT.
+
+> Can you honestly tell apart the two cases, if you don't make a it a case 
+> of "religion war"?
+
+It has absolutely nothing to do with religion.
+
+               Linus
+
+Date:  Fri, 5 Dec 2003 09:19:52 -0800 (PST)
+From:  Linus Torvalds <torvalds@osdl.org>
+To:    Peter Chubb 
+cc:    linux-kernel@vger.kernel.org
+Subject: Re: Linux GPL and binary module exception clause?
+Message-ID: <Pine.LNX.4.58.0312050853200.9125@home.osdl.org>
+
+On Fri, 5 Dec 2003, Peter Chubb wrote:
+>
+> As I understand it, SCO is/was claiming that JFS and XFS are derived
+> works of the UNIX source base, because they were developed to match
+> the internal interfaces of UNIX, and with knowledge of the internals
+> of UNIX -- and they hold the copyrights of and are the licensor of UNIX.
+
+Yes, and I'm not claiming anything like that.
+
+I claim that a "binary linux kernel module" is a derived work of the
+kernel, and thus has to come with sources.
+
+But if you use those same sources (and _you_ wrote them) they do not
+contain any Linux code, they are _clearly_ not derived from Linux, and you
+can license and use your own code any way you want.
+
+You just can't make a binary module for Linux, and claim that that module
+isn't derived from the kernel. Because it generally is - the binary
+module not only included header files, but more importantly it clearly is
+_not_ a standalone work any more. So even if you made your own prototypes
+and tried hard to avoid kernel headers, it would _still_ be connected and
+dependent on the kernel.
+
+And note that I'm very much talking about just the _binary_. Your source
+code is still very much yours, and you have the right to distribute it
+separately any which way you want. You wrote it, you own the copyrights to
+it, and it is an independent work.
+
+But when you distribute it in a way that is CLEARLY tied to the GPL'd
+kernel (and a binary module is just one such clear tie - a "patch" to
+build it or otherwise tie it to the kernel is also such a tie, even if you
+distribute it as source under some other license), you're BY DEFINITION
+not an independent work any more.
+
+(But exactly because I'm not a black-and-white person, I reserve the right
+to make a balanced decision on any particular case. I have several times
+felt that the module author had a perfectly valid argument for why the
+"default assumption" of being derived wasn't the case. That's why things
+like the AFS module were accepted - but not liked - in the first place).
+
+This is why SCO's arguments are specious. IBM wrote their code, retained
+their copyrights to their code AND THEY SEVERED THE CONNECTION TO SCO'S
+CODE (and, arguably the connections didn't even exist in the first place,
+since apparently things like JFS were written for OS/2 as well, and the
+Linux port was based on that one - but that's a separate argument and
+independent of my point).
+
+See the definition of "derivative" in USC 17.1.101:
+
+       A "derivative work" is a work based upon one or more preexisting
+       works, such as a translation, musical arrangement, dramatization,
+       fictionalization, motion picture version, sound recording, art
+       reproduction, abridgment, condensation, or any other form in which
+       a work may be recast, transformed, or adapted. A work consisting
+       of editorial revisions, annotations, elaborations, or other
+       modifications which, as a whole, represent an original work of
+       authorship, is a "derivative work".
+
+And a binary module is an "elaboration" on the kernel. Sorry, but that is
+how it IS.
+
+In short: your code is yours. The code you write is automatically
+copyrighted by YOU, and as such you have the right to license and use it
+any way you want (well, modulo _other_ laws, of course - in the US your
+license can't be racist, for example, but that has nothing to do with
+copyright laws, and would fall under a totally different legal framework).
+
+But when you use that code to create an "elaboration" to the kernel, that
+makes it a derived work, and you cannot distribute it except as laid out
+by the GPL. A binary module is one such case, but even just a source patch
+is _also_ one such case. The lines you added are yours, but when you
+distribute it as an elaboration, you are bound by the restriction on
+derivative works.
+
+Or you had better have some other strong argument why it isn't. Which has
+been my point all along.
+
+                       Linus
+
+
+Date:  Wed, 10 Dec 2003 09:10:18 -0800 (PST)
+From:  Linus Torvalds <torvalds@osdl.org>
+To:    Larry McVoy 
+Subject: Re: Linux GPL and binary module exception clause?
+
+On Wed, 10 Dec 2003, Larry McVoy wrote:
+>
+> Which is?  How is it that you can spend a page of text saying a judge doesn't
+> care about technicalities and then base the rest of your argument on the
+> distinction between a "plugin" and a "kernel module"?
+
+I'll stop arguing, since you obviously do not get it.
+
+I explained the technicalities to _you_, and you are a technical person.
+
+But if you want to explain something to a judge, you get a real lawyer,
+and you make sure that the lawyer tries to explain the issue in _non_
+technical terms. Because, quite frankly, the judge is not going to buy a
+technical discussion he or she doesn't understand.
+
+Just as an example, how do you explain to a judge how much code the Linux
+kernel contains? Do you say "it's 6 million lines of C code and header
+files and documentation, for a total of about 175MB of data"?
+
+Yeah, maybe you'd _mention_ that, but to actually _illustrate_ the point
+you'd say that if you printed it out, it would be a solid stack of papers
+100 feet high.  And you'd compare it to the height of the court building
+you're in, or something. Maybe you'd print out _one_ file, bind it as a
+book, and wave it around as one out of 15,000 files.
+
+But when _you_ ask me about how big the kernel is, I'd say "5 million
+lines". See the difference? It would be silly for me to tell you how many
+feet of paper the kernel would print out to, because we don't have those
+kinds of associations.
+
+Similarly, if you want to explain the notion of a kernel module, you'd
+compare it to maybe an extra chapter in a book. You'd make an analogy to
+something that never _ever_ mentions "linking".
+
+Just imagine: distributing a compiled binary-only kernel module that can
+be loaded into the kernel is not like distributing a new book: it's more
+like distributing a extra chapter to a book that somebody else wrote, that
+uses all the same characters and the plot, but more importantly it
+literally can only be read _together_ with the original work. It doesn't
+stand alone.
+
+In short, your honour, this extra chapter without any meaning on its own
+is a derived work of the book.
+
+In contrast, maybe you can re-write your code and distribute it as a
+short-story, which can be run on its own, and maybe the author has been
+influenced by another book, but the short-story could be bound AS IS, and
+a recipient would find it useful even without that other book. In that
+case, the short story is not a derived work - it's only inspired.
+
+Notice? This is actually _exactly_ what I've been arguing all along,
+except I've been arguing with a technical audience, so I've been using
+technical examples and terminology. But my argument is that just the fact
+that somebody compiled the code for Linux into a binary module that is
+useless without a particular version of the kernel DOES MAKE IT A DERIVED
+WORK.
+
+But also note how it's only the BINARY MODULE that is a derived work. Your
+source code is _not_ necessarily a derived work, and if you compile it for
+another operating system, I'd clearly not complain.
+
+This is the "stand-alone short story" vs "extra chapter without meaning
+outside the book" argument. See? One is a work in its own right, the other
+isn't.
+
+                       Linus
+
+
+Please read the FAQ at  http://www.tux.org/lkml/
+Date:  Thu, 4 Dec 2003 22:43:42 -0800 (PST)
+From:  Linus Torvalds <torvalds@osdl.org>
+To:    David Schwartz 
+cc:    linux-kernel@vger.kernel.org
+Subject: RE: Linux GPL and binary module exception clause?
+
+On Thu, 4 Dec 2003, David Schwartz wrote:
+>
+> Yes, but they will cite the prohibition against *creating* derived
+> works.
+
+So?
+
+The same prohibition exists with the GPL. You are not allowed to create
+and distribute a derived work unless it is GPL'd.
+
+I don't see what you are arguing against. It is very clear: a kernel
+module is a derived work of the kernel by default. End of story.
+
+You can then try to prove (through development history etc) that there
+would be major reasons why it's not really derived. But your argument
+seems to be that _nothing_ is derived, which is clearly totally false, as
+you yourself admit when you replace "kernel" with "Harry Potter".
+
+               Linus
+
+Date:  Wed, 3 Dec 2003 16:00:21 -0800 (PST)
+From:  Linus Torvalds <torvalds@osdl.org>
+To:    Kendall Bennet
+cc:    linux-kernel@vger.kernel.org
+Subject: Re: Linux GPL and binary module exception clause?
+
+On Wed, 3 Dec 2003, Kendall Bennett wrote:
+>
+> I have heard many people reference the fact that the although the Linux
+> Kernel is under the GNU GPL license, that the code is licensed with an
+> exception clause that says binary loadable modules do not have to be
+> under the GPL.
+
+Nope. No such exception exists.
+
+There's a clarification that user-space programs that use the standard
+system call interfaces aren't considered derived works, but even that
+isn't an "exception" - it's just a statement of a border of what is
+clearly considered a "derived work". User programs are _clearly_ not
+derived works of the kernel, and as such whatever the kernel license is
+just doesn't matter.
+
+And in fact, when it comes to modules, the GPL issue is exactly the same.
+The kernel _is_ GPL. No ifs, buts and maybe's about it. As a result,
+anything that is a derived work has to be GPL'd. It's that simple.
+
+Now, the "derived work" issue in copyright law is the only thing that
+leads to any gray areas. There are areas that are not gray at all: user
+space is clearly not a derived work, while kernel patches clearly _are_
+derived works.
+
+But one gray area in particular is something like a driver that was
+originally written for another operating system (ie clearly not a derived
+work of Linux in origin). At exactly what point does it become a derived
+work of the kernel (and thus fall under the GPL)?
+
+THAT is a gray area, and _that_ is the area where I personally believe
+that some modules may be considered to not be derived works simply because
+they weren't designed for Linux and don't depend on any special Linux
+behaviour.
+
+Basically:
+ - anything that was written with Linux in mind (whether it then _also_
+   works on other operating systems or not) is clearly partially a derived
+   work.
+ - anything that has knowledge of and plays with fundamental internal
+   Linux behaviour is clearly a derived work. If you need to muck around
+   with core code, you're derived, no question about it.
+
+Historically, there's been things like the original Andrew filesystem
+module: a standard filesystem that really wasn't written for Linux in the
+first place, and just implements a UNIX filesystem. Is that derived just
+because it got ported to Linux that had a reasonably similar VFS interface
+to what other UNIXes did? Personally, I didn't feel that I could make that
+judgment call. Maybe it was, maybe it wasn't, but it clearly is a gray
+area.
+
+Personally, I think that case wasn't a derived work, and I was willing to
+tell the AFS guys so.
+
+Does that mean that any kernel module is automatically not a derived work?
+HELL NO! It has nothing to do with modules per se, except that non-modules
+clearly are derived works (if they are so central to the kenrel that you
+can't load them as a module, they are clearly derived works just by virtue
+of being very intimate - and because the GPL expressly mentions linking).
+
+So being a module is not a sign of not being a derived work. It's just
+one sign that _maybe_ it might have other arguments for why it isn't
+derived.
+
+               Linus
+
+
+Date:  Wed, 3 Dec 2003 16:23:33 -0800 (PST)
+From:  Linus Torvalds <torvalds@osdl.org>
+To:    Kendall Bennett
+cc:    linux-kernel@vger.kernel.org
+Subject: Re: Linux GPL and binary module exception clause?
+
+
+On Wed, 3 Dec 2003, Linus Torvalds wrote:
+>
+> So being a module is not a sign of not being a derived work. It's just
+> one sign that _maybe_ it might have other arguments for why it isn't
+> derived.
+
+Side note: historically, the Linux kernel module interfaces were really
+quite weak, and only exported a few tens of entry-points, and really
+mostly effectively only allowed character and block device drivers with
+standard interfaces, and loadable filesystems.
+
+So historically, the fact that you could load a module using nothing but
+these standard interfaces tended to be a much stronger argument for not
+being very tightly coupled with the kernel.
+
+That has changed, and the kernel module interfaces we have today are MUCH
+more extensive than they were back in '95 or so. These days modules are
+used for pretty much everything, including stuff that is very much
+"internal kernel" stuff and as a result the kind of historic "implied
+barrier" part of modules really has weakened, and as a result there is not
+avery strong argument for being an independent work from just the fact
+that you're a module.
+
+Similarly, historically there was a much stronger argument for things like
+AFS and some of the binary drivers (long forgotten now) for having been
+developed totally independently of Linux: they literally were developed
+before Linux even existed, by people who had zero knowledge of Linux. That
+tends to strengthen the argument that they clearly aren't derived.
+
+In contrast, these days it would be hard to argue that a new driver or
+filesystem was developed without any thought of Linux. I think the NVidia
+people can probably reasonably honestly say that the code they ported had
+_no_ Linux origin. But quite frankly, I'd be less inclined to believe that
+for some other projects out there..
+
+                       Linus
+
+
+
+
+Date: Thu, 17 Oct 2002 10:08:19 -0700 (PDT)
+From: Linus Torvalds <torvalds@transmeta.com>
+To: Christoph Hellwig 
+Cc: <linux-kernel@vger.kernel.org>
+Subject: Re: [PATCH] make LSM register functions GPLonly exports
+In-Reply-To: <20021017175403.A32516@infradead.org>
+Message-ID: <Pine.LNX.4.44.0210170958340.6739-100000@home.transmeta.com>
+
+Note that if this fight ends up being a major issue, I'm just going to 
+remove LSM and let the security vendors do their own thing. So far
+
+ - I have not seen a lot of actual usage of the hooks
+ - seen a number of people who still worry that the hooks degrade 
+   performance in critical areas
+ - the worry that people use it for non-GPL'd modules is apparently real, 
+   considering Crispin's reply.
+
+I will re-iterate my stance on the GPL and kernel modules:
+
+  There is NOTHING in the kernel license that allows modules to be 
+  non-GPL'd. 
+
+  The _only_ thing that allows for non-GPL modules is copyright law, and 
+  in particular the "derived work" issue. A vendor who distributes non-GPL 
+  modules is _not_ protected by the module interface per se, and should 
+  feel very confident that they can show in a court of law that the code 
+  is not derived.
+
+  The module interface has NEVER been documented or meant to be a GPL 
+  barrier. The COPYING clearly states that the system call layer is such a 
+  barrier, so if you do your work in user land you're not in any way 
+  beholden to the GPL. The module interfaces are not system calls: there 
+  are system calls used to _install_ them, but the actual interfaces are
+  not.
+
+  The original binary-only modules were for things that were pre-existing 
+  works of code, ie drivers and filesystems ported from other operating 
+  systems, which thus could clearly be argued to not be derived works, and 
+  the original limited export table also acted somewhat as a barrier to 
+  show a level of distance.
+
+In short, Crispin: I'm going to apply the patch, and if you as a copyright 
+holder of that file disagree, I will simply remove all of he LSM code from 
+the kernel. I think it's very clear that a LSM module is a derived work, 
+and thus copyright law and the GPL are not in any way unclear about it. 
+
+If people think they can avoid the GPL by using function pointers, they 
+are WRONG. And they have always been wrong.
+
+                       Linus
+
+------------------------------------------------------------------------
+Date: Fri, 19 Oct 2001 13:16:45 -0700 (PDT)
+From: Linus Torvalds <torvalds@transmeta.com>
+To: Barnes
+Subject: Re: GPL, Richard Stallman, and the Linux kernel
+
+[ This is not, of course, a legal document, but if you want to forward it
+  to anybody else, feel free to do so. And if you want to argue legal
+  points with me or point somehting out, I'm always interested. To a
+  point ;-]
+
+On Fri, 19 Oct 2001, Barnes wrote:
+>
+> I've been exchanging e-mail with Richard Stallman for a couple of
+> weeks about the finer points of the GPL.
+
+I feel your pain.
+
+> I've have spent time pouring through mailing list archives, usenet,
+> and web search engines to find out what's already been covered about
+> your statement of allowing dynamically loaded kernel modules with
+> proprietary code to co-exist with the Linux kernel.  So far I've
+> been unable to find anything beyond vague statements attributed to
+> you.  If these issues are addressed somewhere already, please refer
+> me.
+
+Well, it really boils down to the equivalent of "_all_ derived modules
+have to be GPL'd". An external module doesn't really change the GPL in
+that respect.
+
+There are (mainly historical) examples of UNIX device drivers and some
+UNIX filesystems that were pre-existing pieces of work, and which had
+fairly well-defined and clear interfaces and that I personally could not
+really consider any kind of "derived work" at all, and that were thus
+acceptable. The clearest example of this is probably the AFS (the Andrew
+Filesystem), but there have been various device drivers ported from SCO
+too.
+
+> Issue #1
+> ========
+> Currently the GPL version 2 license is the only license covering the
+> Linux kernel.  I cannot find any alternative license explaining the
+> loadable kernel module exception which makes your position difficult
+> to legally analyze.
+>
+> There is a note at the top of www.kernel.org/pub/linux/kernel/COPYING,
+> but that states "user programs" which would clearly not apply to
+> kernel modules.
+>
+> Could you clarify in writing what the exception precisely states?
+
+Well, there really is no exception. However, copyright law obviously
+hinges on the definition of "derived work", and as such anything can
+always be argued on that point.
+
+I personally consider anything a "derived work" that needs special hooks
+in the kernel to function with Linux (ie it is _not_ acceptable to make a
+small piece of GPL-code as a hook for the larger piece), as that obviously
+implies that the bigger module needs "help" from the main kernel.
+
+Similarly, I consider anything that has intimate knowledge about kernel
+internals to be a derived work.
+
+What is left in the gray area tends to be clearly separate modules: code
+that had a life outside Linux from the beginning, and that do something
+self-containted that doesn't really have any impact on the rest of the
+kernel. A device driver that was originally written for something else,
+and that doesn't need any but the standard UNIX read/write kind of
+interfaces, for example.
+
+> Issue #2
+> ========
+> I've found statements attributed to you that you think only 10% of
+> the code in the current kernel was written by you.  By not being the
+> sole copyright holder of the Linux kernel, a stated exception to
+> the GPL seems invalid unless all kernel copyright holders agreed on
+> this exception.  How does the exception cover GPL'd kernel code not
+> written by you?  Has everyone contributing to the kernel forfeited
+> their copyright to you or agreed with the exception?
+
+Well, see above about the lack of exception, and about the fundamental
+gray area in _any_ copyright issue. The "derived work" issue is obviously
+a gray area, and I know lawyers don't like them. Crazy people (even
+judges) have, as we know, claimed that even obvious spoofs of a work that
+contain nothing of the original work itself, can be ruled to be "derived".
+
+I don't hold views that extreme, but at the same time I do consider a
+module written for Linux and using kernel infrastructures to get its work
+done, even if not actually copying any existing Linux code, to be a
+derived work by default. You'd have to have a strong case to _not_
+consider your code a derived work..
+
+> Issue #3
+> ========
+> This issue is related to issue #1.  Exactly what is covered by the
+> exception?  For example, all code shipped with the Linux kernel
+> archive and typically installed under /usr/src/linux, all code under
+> /usr/src/linux except /usr/src/linux/drivers, or just the code in
+> the /usr/src/linux/kernel directory?
+
+See above, and I think you'll see my point.
+
+The "user program" exception is not an exception at all, for example, it's
+just a more clearly stated limitation on the "derived work" issue. If you
+use standard UNIX system calls (with accepted Linux extensions), your
+program obviously doesn't "derive" from the kernel itself.
+
+Whenever you link into the kernel, either directly or through a module,
+the case is just a _lot_ more muddy. But as stated, by default it's
+obviously derived - the very fact that you _need_ to do something as
+fundamental as linking against the kernel very much argues that your
+module is not a stand-alone thing, regardless of where the module source
+code itself has come from.
+
+> Issue #4
+> ========
+> This last issue is not so much a issue for the Linux kernel
+> exception, but a request for comment.
+>
+> Richard and I both agree that a "plug-in" and a "dynamically
+> loaded kernel module" are effectively the same under the GPL.
+
+Agreed.
+
+The Linux kernel modules had (a long time ago), a more limited interface,
+and not very many functions were actually exported. So five or six years
+ago, we could believably claim that "if you only use these N interfaces
+that are exported from the standard kernel, you've kind of implicitly
+proven that you do not need the kernel infrastructure".
+
+That was never really documented either (more of a guideline for me and
+others when we looked at the "derived work" issue), and as modules were
+more-and-more used not for external stuff, but just for dynamic loading of
+standard linux modules that were distributed as part of the kernel anyway,
+the "limited interfaces" argument is no longer a very good guideline for
+"derived work".
+
+So these days, we export many internal interfaces, not because we don't
+think that they would "taint" the linker, but simply because it's useful
+to do dynamic run-time loading of modules even with standard kernel
+modules that _are_ supposed to know a lot about kernel internals, and are
+obviously "derived works"..
+
+> However we disagree that a plug-in for a GPL'd program falls
+> under the GPL as asserted in the GPL FAQ found in the answer:
+> http://www.gnu.org/licenses/gpl-faq.html#GPLAndPlugins.
+
+I think you really just disagree on what is derived, and what is not.
+Richard is very extreme: _anything_ that links is derived, regardless of
+what the arguments against it are. I'm less extreme, and I bet you're even
+less so (at least you would like to argue so for your company).
+
+> My assertion is that plug-ins are written to an interface, not a
+> program.  Since interfaces are not GPL'd, a plug-in cannot be GPL'd
+> until the plug-in and program are placed together and run.  That is
+> done by the end user, not the plug-in creator.
+
+I agree, but also disrespectfully disagree ;)
+
+It's an issue of what a "plug-in" is - is it a way for the program to
+internally load more modules as it needs them, or is it _meant_ to be a
+public, published interface.
+
+For example, the "system call" interface could be considered a "plug-in
+interface", and running a user mode program under Linux could easily be
+construed as running a "plug-in" for the Linux kernel. No?
+
+And there, I obviously absolutely agree with you 100%: the interface is
+published, and it's _meant_ for external and independent users. It's an
+interface that we go to great lengths to preserve as well as we can, and
+it's an interface that is designed to be independent of kernel versions.
+
+But maybe somebody wrote his program with the intention to dynamically
+load "actors" as they were needed, as a way to maintain a good modularity,
+and to try to keep the problem spaces well-defined. In that case, the
+"plug-in" may technically follow all the same rules as the system call
+interface, even though the author doesn't intend it that way.
+
+So I think it's to a large degree a matter of intent, but it could
+arguably also be considered a matter of stability and documentation (ie
+"require recompilation of the plug-in between version changes"  would tend
+to imply that it's an internal interface, while "documented binary
+compatibility across many releases" implies a more stable external
+interface, and less of a derived work)
+
+Does that make sense to you?
+
+> I asked Richard to comment on several scenarios involving plug-ins
+> explain whether or not they were in violation of the GPL.  So far he
+> as only addressed one and has effectively admitted a hole.  This is
+> the one I asked that he's responded to:
+>     [A] non-GPL'd plug-in writer writes a plug-in for a non-GPL'd
+>     program.  Another author writes a GPL'd program making the
+>     first author's plug-ins compatible with his program.  Are now
+>     the plug-in author's plug-ins now retroactively required to be
+>     GPL'd?
+>
+> His response:
+>     No, because the plug-in was not written to extend this program.
+>
+> I find it suspicious that whether or not the GPL would apply to the
+> plug-in depends on the mindset of the author.
+
+The above makes no sense if you think of it as a "plug in" issue, but it
+makes sense if you think of it as a "derived work" issue, along with
+taking "intent" into account.
+
+I know lawyers tend to not like the notion of "intent", because it brings
+in another whole range of gray areas, but it's obviously a legal reality.
+
+Ok, enough blathering from me. I'd just like to finish off with a few
+comments, just to clarify my personal stand:
+
+ - I'm obviously not the only copyright holder of Linux, and I did so on
+   purpose for several reasons. One reason is just because I hate the
+   paperwork and other cr*p that goes along with copyright assignments.
+
+   Another is that I don't much like copyright assignments at all: the
+   author is the author, and he may be bound by my requirement for GPL,
+   but that doesn't mean that he should give his copyright to me.
+
+   A third reason, and the most relevant reason here, is that I want
+   people to _know_ that I cannot control the sources. I can write you a
+   note to say that "for use XXX, I do not consider module YYY to be a
+   derived work of my kernel", but that would not really matter that much.
+   Any other Linux copyright holder might still sue you.
+
+   This third reason is what makes people who otherwise might not trust me
+   realize that I cannot screw people over. I am bound by the same
+   agreement that I require of everybody else, and the only special status
+   I really have is a totally non-legal issue: people trust me.
+
+   (Yes, I realize that I probably would end up having more legal status
+   than most, even apart from the fact that I still am the largest single
+   copyright holder, if only because of appearances)
+
+ - I don't really care about copyright law itself. What I care about is my
+   own morals. Whether I'd ever sue somebody or not (and quite frankly,
+   it's the last thing I ever want to do - if I never end up talking to
+   lawyers in a professional context, I'll be perfectly happy. No
+   disrespect intended) will be entirely up to whether I consider what
+   people do to me "moral" or not. Which is why intent matters to me a
+   lot - both the intent of the person/corporation doign the infringement,
+   _and_ the intent of me and others in issues like the module export
+   interface.
+
+   Another way of putting this: I don't care about "legal loopholes" and
+   word-wrangling.
+
+ - Finally: I don't trust the FSF. I like the GPL a lot - although not
+   necessarily as a legal piece of paper, but more as an intent. Which
+   explains why, if you've looked at the Linux COPYING file, you may have
+   noticed the explicit comment about "only _this_ particular version of
+   the GPL covers the kernel by default".
+
+   That's because I agree with the GPL as-is, but I do not agree with the
+   FSF on many other matters. I don't like software patents much, for
+   example, but I do not want the code I write to be used as a weapon
+   against companies that have them. The FSF has long been discussing and
+   is drafting the "next generation" GPL, and they generally suggest that
+   people using the GPL should say "v2 or at your choice any later
+   version".
+
+   Linux doesn't do that. The Linux kernel is v2 ONLY, apart from a few
+   files where the author put in the FSF extension (and see above about
+   copyright assignments why I would never remove such an extension).
+
+The "v2 only" issue might change some day, but only after all documented
+copyright holders agree on it, and only after we've seen what the FSF
+suggests. From what I've seen so far from the FSF drafts, we're not likely
+to change our v2-only stance, but there might of course be legal reasons
+why we'd have to do something like it (ie somebody challenging the GPLv2
+in court, and part of it to be found unenforceable or similar would
+obviously mean that we'd have to reconsider the license).
+
+               Linus
+
+PS. Historically, binary-only modules have not worked well under Linux,
+quite regardless of any copyright issues. The kernel just develops too
+quickly for binary modules to work well, and nobody really supports them.
+Companies like Red Hat etc tend to refuse to have anything to do with
+binary modules, because if something goes wrong there is nothing they can
+do about it. So I just wanted to let you know that the _legal_ issue is
+just the beginning. Even though you probably don't personally care ;)
+
+
diff --git a/Documentation/arm/SA1100/PCMCIA b/Documentation/arm/SA1100/PCMCIA
deleted file mode 100644 (file)
index 5eb5d3a..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-Kernel Low-Level PCMCIA Interface Documentation
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-John G Dorsey <john+@cs.cmu.edu>
-Updated: 30 June, 2000
-
-
-Note: this interface has not been finalized!
-See also: http://www.cs.cmu.edu/~wearable/software/pcmcia-arm.html
-
-
-Introduction
-
-Early versions of PCMCIA Card Services for StrongARM were designed to
-permit a single socket driver to run on a variety of SA-1100 boards by
-using a userland configuration process. During the conversion to the 2.3
-kernel series, all of the configuration has moved into sub-drivers in the
-kernel proper (see linux/drivers/pcmcia/sa1100*). This document describes
-the low-level interface between those sub-drivers and the sa1100 socket
-driver module.
-
-Presently, there are six operations which must be provided by the
-board-specific code. Only functions whose implementation is likely to
-differ across board designs are required at this level. Some examples
-include:
-
-  - configuring card detect lines to generate interrupts
-  - sensing the legal voltage levels for inserted cards
-  - asserting the reset signal for a card
-
-Functions which are assumed to be the same across all designs are
-performed within the generic socket driver itself. Some examples of these
-kinds of operations include:
-
-  - configuring memory access times based on the core clock frequency
-  - reads/writes on memory, byte swizzling, ...
-
-The current implementation allows the specific per-board set of low-level
-operations to be determined at run time. For each specific board, the
-following structure should be filled in:
-
-  struct pcmcia_low_level {
-    int (*init)(struct pcmcia_init *);
-    int (*shutdown)(void);
-    int (*socket_state)(struct pcmcia_state_array *);
-    int (*get_irq_info)(struct pcmcia_irq_info *);
-    int (*configure_socket)(const struct pcmcia_configure *);
-  };
-
-The component functions are described in detail below. Using the
-machine_is_*() tests, the pointer `pcmcia_low_level' should be assigned to
-the location of the table for your board.
-
-
-0. init(struct pcmcia_init *init)
-
-This operation has three responsibilities:
-
-  - perform any board-specific initialization tasks
-  - associate the given handler with any interrupt-generating signals
-    such as card detection, or battery voltage detection
-  - set up any necessary edge detection for card ready signals
-
-Argument passing for this operation is implemented by the following
-structure:
-
-  struct pcmcia_init {
-    void (*handler)(int irq, void *dev, struct pt_regs *regs);
-    struct pcmcia_maps *maps;
-  };
-
-Here, `handler' is provided by the socket driver, and `maps' must be
-modified if the default mapping isn't appropriate. This operation should
-return one of two values:
-
-  - the highest-numbered socket available, plus one
-  - a negative number, indicating an error in configuration
-
-Note that the former case is _not_ the same as "the number of sockets
-available." In particular, if your design uses SA-1100 slot "one" but
-not slot "zero," you MUST report "2" to the socket driver.
-
-
-1. shutdown(void)
-
-This operation takes no arguments, and will be called during cleanup for
-the socket driver module. Any state associated with the socket controller,
-including allocated data structures, reserved IRQs, etc. should be
-released in this routine.
-
-The return value for this operation is not examined.
-
-
-2. socket_state(struct pcmcia_state_array *state_array)
-
-This operation will be invoked from the interrupt handler which was set up
-in the earlier call to init(). Note, however, that it should not include
-any side effects which would be inappropriate if the operation were to
-occur when no interrupt is pending. (An extra invocation of this operation
-currently takes place to initialize state in the socket driver.)
-
-Argument passing for this operation is handled by a structure which
-contains an array of the following type:
-
-  struct pcmcia_state {
-    unsigned detect: 1,
-              ready: 1,
-               bvd1: 1,
-               bvd2: 1,
-             wrprot: 1,
-              vs_3v: 1,
-              vs_Xv: 1;
-  };
-
-Upon return from the operation, a struct pcmcia_state should be filled in
-for each socket available in the hardware. For every array element (up to
-`size' in the struct pcmcia_state_saarray) which does not correspond to an
-available socket, zero the element bits. (This includes element [0] if
-socket zero is not used.)
-
-Regardless of how the various signals are routed to the SA-1100, the bits
-in struct pcmcia_state always have the following semantics:
-
-  detect - 1 if a card is fully inserted, 0 otherwise
-  ready  - 1 if the card ready signal is asserted, 0 otherwise
-  bvd1   - the value of the Battery Voltage Detect 1 signal
-  bvd2   - the value of the Battery Voltage Detect 2 signal
-  wrprot - 1 if the card is write-protected, 0 otherwise
-  vs_3v  - 1 if the card must be operated at 3.3V, 0 otherwise
-  vs_Xv  - 1 if the card must be operated at X.XV, 0 otherwise
-
-A note about the BVD signals: if your board does not make both lines
-directly observable to the processor, just return reasonable values. The
-standard interpretation of the BVD signals is:
-
-  BVD1  BVD2
-
-   0     x    battery is dead
-   1     0    battery warning
-   1     1    battery ok
-
-Regarding the voltage sense flags (vs_3v, vs_Xv), these bits should be set
-based on a sampling of the Voltage Sense pins, if available. The standard
-interpretation of the VS signals (for a "low-voltage" socket) is:
-
-  VS1   VS2
-
-   0     0    X.XV, else 3.3V, else none
-   0     1    3.3V, else none
-   1     0    X.XV, else none
-   1     1    5V, else none
-
-More information about the BVD and VS conventions is available in chapter
-5 of "PCMCIA System Architecture," 2nd ed., by Don Anderson.
-
-This operation should return 1 if an IRQ is actually pending for the
-socket controller, 0 if no IRQ is pending (but no error condition exists,
-such as an undersized state array), or -1 on any error.
-
-
-3. get_irq_info(struct pcmcia_irq_info *info)
-
-This operation obtains the IRQ assignment which is legal for the given
-socket. An argument of the following type is passed:
-
-  struct pcmcia_irq_info {
-    unsigned int sock;
-    unsigned int irq ;
-  };
-
-The `sock' field contains the socket index being queried. The `irq' field
-should contain the IRQ number corresponding to the card ready signal from
-the device.
-
-This operation should return 0 on success, or -1 on any error.
-
-
-4. configure_socket(const struct pcmcia_configure *configure)
-
-This operation allows the caller to apply power to the socket, issue a
-reset, or enable various outputs. The argument is of the following type:
-
-  struct pcmcia_configure {
-    unsigned sock: 8,
-              vcc: 8,
-              vpp: 8,
-           output: 1,
-          speaker: 1,
-            reset: 1;
-  };
-
-The `sock' field contains the index of the socket to be configured. The
-`vcc' and `vpp' fields contain the voltages to be applied for Vcc and Vpp,
-respectively, in units of 0.1V. (Note that vpp==120 indicates that
-programming voltage should be applied.)
-
-The two output enables, `output' and `speaker', refer to the card data
-signal enable and the card speaker enable, respectively. The `reset' bit,
-when set, indicates that the card reset should be asserted.
-
-This operation should return 0 on success, or -1 on any error.
-
-
-Board-Specific Notes
-
-The following information is known about various SA-11x0 board designs
-which may be used as reference while adding support to the kernel.
-
-
-Carnegie Mellon Itsy/Cue (http://www.cs.cmu.edu/~wearable/itsy/)
-
-  Itsy Chip Select 3 (CS3) Interface
-  ("ITSY MEMORY/PCMCIA ADD-ON BOARD with BATTERY and CHARGER CIRCUITRY,"
-   memo dated 5-20-99, from Tim Manns to Richard Martin, et. al)
-
-  Read:
-    ABVD2    (SS)D0          A slot, Battery Voltage Detect
-    ABVD1    (SS)D1
-    AVSS2    (SS)D2          A slot, Voltage Sense
-    AVSS1    (SS)D3
-    GND      (SS)D4
-    GND      (SS)D5
-    GND      (SS)D6
-    GND      (SS)D7
-  
-    BBVD2    (SS)D8          B slot, Battery Voltage Detect
-    BBVD1    (SS)D9
-    BVSS2    (SS)D10         B slot, Voltage Sense
-    BVSS1    (SS)D11
-    GND      (SS)D12
-    GND      (SS)D13
-    GND      (SS)D14
-    GND      (SS)D15
-  
-  Write:
-    (SS)D0   A_VPP_VCC       LTC1472 VPPEN1
-    (SS)D1   A_VPP_PGM       LTC1472 VPPEN0
-    (SS)D2   A_VCC_3         LTC1472 VCCEN0
-    (SS)D3   A_VCC_5         LTC1472 VCCEN1
-    (SS)D4   RESET (A SLOT)
-    (SS)D5   GND
-    (SS)D6   GND
-    (SS)D7   GND
-    (SS)D8   B_VPP_VCC       LTC1472 VPPEN1
-    (SS)D9   B_VPP_PGM       LTC1472 VPPEN0
-    (SS)D10  B_VCC_3         LTC1472 VCCEN0
-    (SS)D11  B_VCC_5         LTC1472 VCCEN1
-    (SS)D12  RESET (B SLOT)
-    (SS)D13  GND
-    (SS)D14  GND
-    (SS)D15  GND
-  GPIO pin assignments are as follows: (from schematics)
-    GPIO 10                  Slot 0 Card Detect
-    GPIO 11                  Slot 1 Card Detect
-    GPIO 12                  Slot 0 Ready/Interrupt
-    GPIO 13                  Slot 1 Ready/Interrupt
-
-
-
-Intel SA-1100 Multimedia Board (http://developer.intel.com/design/strong/)
-
-  CPLD Registers
-  SA-1100 Multimedia Development Board with Companion SA-1101 Development
-    Board User's Guide, p.4-42
-
-  This SA-1100/1101 development package uses only one GPIO pin (24) to
-  signal changes in card status, and requires software to inspect a
-  PCMCIA status register to determine the source.
-
-  Read: (PCMCIA Power Sense Register - 0x19400000)
-    S0VS1           0        Slot 0 voltage sense
-    S0VS2           1
-    S0BVD1          2        Slot 0 battery voltage sense
-    S0BVD2          3
-    S1VS1           4        Slot 1 voltage sense
-    S1VS2           5
-    S1BVD1          6        Slot 1 battery voltage sense
-    S1BVD2          7
-
-  Read/Write: (PCMCIA Power Control Register - 0x19400002)
-    S0VPP0          0        Slot 0 Vpp
-    S0VPP1          1
-    S0VCC0          2        Slot 0 Vcc
-    S0VCC1          3
-    S1VPP0          4        Slot 1 Vpp
-    S1VPP1          5
-    S1VCC0          6        Slot 1 Vcc
-    S1VCC1          7
-
-  Read: (PCMCIA Status Register - 0x19400004)
-    S0CD1           0        Slot 0 Card Detect 1
-    S0RDY           1        Slot 0 Ready/Interrupt
-    S0STSCHG        2        Slot 0 Status Change
-    S0Reset         3        Slot 0 Reset (RW)
-    S1CD1           4        Slot 1 Card Detect 1
-    S1RDY           5        Slot 1 Ready/Interrupt
-    S1STSCHG        6        Slot 1 Status Change
-    S1Reset         7        Slot 1 Reset (RW)
-
-
-
-Intel SA-1100 Evaluation Platform (http://developer.intel.com/design/strong/)
-
-  Brutus I/O Pins and Chipselect Register
-  pcmcia-brutus.c, by Ivo Clarysse
-  (What's the official reference for this info?)
-
-  This SA-1100 development board uses more GPIO pins than say, the Itsy
-  or the SA-1100/1101 multimedia package. The pin assignments are as
-  follows:
-
-    GPIO 2                   Slot 0 Battery Voltage Detect 1
-    GPIO 3                   Slot 0 Ready/Interrupt
-    GPIO 4                   Slot 0 Card Detect
-    GPIO 5                   Slot 1 Battery Voltage Detect 1
-    GPIO 6                   Slot 1 Ready/Interrupt
-    GPIO 7                   Slot 1 Card Detect
-
-  Like the Itsy, Brutus uses a chipselect register in static memory
-  bank 3 for the other signals, such as voltage sense or reset:
-
-  Read:
-    P0_VS1          8        Slot 0 Voltage Sense
-    P0_VS2          9
-    P0_STSCHG      10        Slot 0 Status Change
-    P1_VS1         12        Slot 1 Voltage Sense
-    P1_VS2         13
-    P1_STSCHG      14        Slot 1 Status Change
-
-  Read/Write:
-    P0_            16        Slot 0 MAX1600EAI control line
-    P0_            17        Slot 0 MAX1600EAI control line
-    P0_            18        Slot 0 MAX1600EAI control line
-    P0_            19        Slot 0 MAX1600EAI control line
-    P0_            20        Slot 0 12V
-    P0_            21        Slot 0 Vpp to Vcc (CONFIRM?)
-    P0_            22        Slot 0 enable fan-out drivers & xcvrs
-    P0_SW_RST      23        Slot 0 Reset
-    P1_            24        Slot 1 MAX1600EAI control line
-    P1_            25        Slot 1 MAX1600EAI control line
-    P1_            26        Slot 1 MAX1600EAI control line
-    P1_            27        Slot 1 MAX1600EAI control line
-    P1_            28        Slot 1 12V
-    P1_            29        Slot 1 Vpp to Vcc (CONFIRM?)
-    P1_            30        Slot 1 enable fan-out drivers & xcvrs
-    P1_SW_RST      31        Slot 1 Reset
-
-  For each slot, the bits labelled "MAX1600EAI" should (apparently)
-  be written with the value 0101 for Vcc 3.3V, and 1001 for Vcc 5V.
-
-
-
-Intel SA-1110 Development Platform (http://developer.intel.com/design/strong/)
-
-  GPIO Pin Descriptions and Board Control Register
-  SA-1110 Microprocessor Development Board User's Guide, p.4-7, 4-10
-
-  The Assabet board contains only a single Compact Flash slot,
-  attached to slot 1 on the SA-1110. Card detect, ready, and BVD
-  signals are routed through GPIO, with power and reset placed in a
-  control register. Note that the CF bus must be enabled before use.
-
-    GPIO 21                  Slot 1 Compact Flash interrupt
-    GPIO 22                  Slot 1 card detect (CD1 NOR CD2)
-    GPIO 24                  Slot 1 Battery Voltage Detect 2
-    GPIO 25                  Slot 1 Battery Voltage Detect 1
-
-  Write-only: (Board Control Register - 0x12000000)
-    CF_PWR          0        CF bus power (3.3V)
-    CF_RST          1        CF reset
-    CF_Bus_On       7        CF bus enable
-
diff --git a/Documentation/arm/XScale/ADIFCC/80200EVB b/Documentation/arm/XScale/ADIFCC/80200EVB
deleted file mode 100644 (file)
index 3762de4..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-
-Board Overview
------------------------------
-
-This is an beta release of the Xscale Linux port to the ADI 80200EVB
-evaluation board.
-
-The 80200EVB is an evaluation platform for ADI Engineering's high-performance
-80200FCC chipset for the Intel 80200 XScale CPU. The 80200FCC is an open
-source FPGA based system that contains a PCI unit and a high performance
-memory controller.
-
-In addition to the 80200FCC, the board also contains a 16C550 UART, and 4MB
-of flash.
-
-The board is still under development and currently only the UART is functional
-as the PCI bits have not been programmed into the FPGA.
-
-For more information on the board, see http://www.adiengineering.com
-
-Port Status
------------------------------
-
-Supported:
-
-- Onboard UART (Polled operation only)
-- Cache/TLB locking on 80200 CPU
-
-TODO:
-
-- PCI when hardware supports it
-
-Building the Kernel
------------------------------
-change Linux makefile
-make adi_evb_config
-make oldconfig
-make zImage
-
-Loading Linux
------------------------------
-
-Before you can use Linux on the ADI board, you need to grab the following:
-
-ADI 80200EVB Monitor:
-       ftp://source.mvista.com/pub/xscale/ADI_EVB/monitor.srec
-
-ADI JFFS2 Image:
-       ftp://source.mvista.com/pub/xscale/ADI_EVB/adi.jffs2
-
-Once you've got the Cygnus prompt, type in the following command:
-
-       load
-
-On another terminal window:
-
-       cat monitor.srec > /dev/ttyS0
-
-(replace ttyS0 with the serial port you are using)
-
-Once completed, just type 'go' at the cygmon prompt and you should see:
-
-       MontaVista IQ80310 Monitor Version 0.1
-       monitor>
-
-Type 'b 115200' at the prompt and change your terminal speed to 115200
-
-The first thing to do is to upload and burn the jffs2 filesystem image
-onto the boards 4MB of flash:
-
-       monitor> u c1000000
-       Uploading file at 0xc1000000
-       Now send file with ymodem
-
-Do as the monitor says and transfer the file adi.jffs2.  Once complete,
-the following will copy the jffs2 image to location 0x80000 in the flash.
-
-       monitor> f 8000 c1000000 200000
-       Erasing sector 0x00080000
-       Writing sector 0x00080000 with data at 0xC1000000
-       Erasing sector 0x000A0000
-       Writing sector 0x000A0000 with data at 0xC1020000
-       Erasing sector 0x000C0000
-       ...
-
-Now use the same command as above to upload your zImage to location c1000000.
-When you've done that, type 'j c1000000' to run Linux.  Login as
-root and you're all set to go.
-
-Misc Notes
------------------------------
-
-The current version of the HW does not have an onboard timer, so the 80200
-PMU is not available for general use as it is being used for a timer source.
-
-By default, the MTD driver reserves the first 512K for bootloaders and
-the remaining 3.5MB for the filesystem. You can edit drivers/mtd/map/adi_evb.c
-to change this as needed for your application.
-
-Contributors
------------------------------
-
-Thanks to ADI Engineering for providing the hardware for development
-
-Deepak Saxena <dsaxena@mvista.com> - Initial port
-
------------------------------
-Enjoy.  If you have any problem please contact Deepak Saxena
-dsaxena@mvista.com
-
diff --git a/Documentation/arm/XScale/IOP3XX/IQ80310 b/Documentation/arm/XScale/IOP3XX/IQ80310
deleted file mode 100644 (file)
index 5312a57..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-
-Board Overview
------------------------------
-
-The Cyclone IQ80310 board is an evaluation platform for Intel's 80200 Xscale
-CPU and 80312 Intelligent I/O chipset (collectively called IOP310 chipset).
-
-The 80312 contains dual PCI hoses (called the ATUs), a PCI-to-PCI bridge,
-three DMA channels (1 on secondary PCI, one on primary PCI ), I2C, I2O
-messaging unit, XOR unit for RAID operations, a bus performance monitoring
-unit, and a memory controller with ECC features.
-
-For more information on the board, see http://developer.intel.com/iio
-
-Port Status
------------------------------
-
-Supported:
-
-- MTD/JFFS/JFFS2
-- NFS root
-- RAMDISK root
-- 2ndary PCI slots
-- Onboard ethernet
-- Serial ports (ttyS0/S1)
-- Cache/TLB locking on 80200 CPU
-- Performance monitoring unit on 80200 CPU
-- 80200 Performance Monitoring Unit
-- Acting as a system controller on Cyclone 80303BP PCI backplane
-- DMA engines (EXPERIMENTAL)
-- 80312 Bus Performance Monitor (EXPERIMENTAL)
-- Application Accelerator Unit (XOR engine for RAID) (EXPERIMENTAL)
-- Messaging Unit (EXPERIMENTAL)
-
-TODO:
-- I2C
-
-Building the Kernel
------------------------------
-make iq80310_config
-make oldconfig
-make zImage
-
-This will build an image setup for BOOTP/NFS root support.  To change this,
-just run make menuconfig and disable nfs root or add a "root=" option.
-
-Preparing the Hardware
------------------------------
-
-This document assumes you're using a Rev D or newer board running
-Redboot as the bootloader.  Note that the version of RedBoot provided
-with the boards has a major issue and you need to replace it with the
-latest RedBoot. You can grab the source from the ECOS CVS or you can
-get a prebuilt image and burn it in using FRU at:
-
-   ftp://source.mvista.com/pub/xscale/iq80310/redboot.bin
-
-Make sure you do an 'fis init' command once you boot with the new
-RedBoot image.
-
-
-
-Downloading Linux
------------------------------
-
-Assuming you have your development system setup to act as a bootp/dhcp
-server and running tftp:
-
-   RedBoot> load -r -b 0xa1008000 /tftpboot/zImage.xs
-   Raw file loaded 0xa1008000-0xa1094bd8
-
-If you're not using dhcp/tftp, you can use y-modem instead:
-
-   RedBoot> load -r -b 0xa1008000 -m y
-
-Note that on Rev D. of the board, tftp does not work due to intermittent
-interrupt issues, so you need to download using ymodem.
-
-Once the download is completed:
-
-   RedBoot> go 0xa1008000
-
-Root Devices
------------------------------
-
-A kernel is not useful without a root filesystem, and you have several
-choices with this board:  NFS root, RAMDISK, or JFFS/JFFS2.  For development
-purposes, it is suggested that you use NFS root for easy access to various
-tools.  Once you're ready to deploy, probably want to utilize JFFS/JFFS2 on
-the flash device.
-
-MTD on the IQ80310
------------------------------
-
-Linux on the IQ80310 supports RedBoot FIS paritioning if it is enabled.
-Out of the box, once you've done 'fis init' on RedBoot, you will get
-the following partitioning scheme:
-
-   root@192.168.0.14:~# cat /proc/mtd
-   dev:    size   erasesize  name
-   mtd0: 00040000 00020000 "RedBoot"
-   mtd1: 00040000 00020000 "RedBoot[backup]"
-   mtd2: 0075f000 00020000 "unallocated space"
-   mtd3: 00001000 00020000 "RedBoot config"
-   mtd4: 00020000 00020000 "FIS directory"
-
-To create an FIS directory, you need to use the fis command in RedBoot.
-As an example, you can burn the kernel into the flash once it's downloaded:
-
-   RedBoot> fis create -b 0xa1008000 -l 0x8CBAC -r 0xa1008000 -f 0x80000 kernel
-   ... Erase from 0x00080000-0x00120000: .....
-   ... Program from 0xa1008000-0xa1094bac at 0x00080000: .....
-   ... Unlock from 0x007e0000-0x00800000: .
-   ... Erase from 0x007e0000-0x00800000: .
-   ... Program from 0xa1fdf000-0xa1fff000 at 0x007e0000: .
-   ... Lock from 0x007e0000-0x00800000: .
-
-   RedBoot> fis list
-   Name              FLASH addr  Mem addr    Length      Entry point
-   RedBoot           0x00000000  0x00000000  0x00040000  0x00000000
-   RedBoot[backup]   0x00040000  0x00040000  0x00040000  0x00000000
-   RedBoot config    0x007DF000  0x007DF000  0x00001000  0x00000000
-   FIS directory     0x007E0000  0x007E0000  0x00020000  0x00000000
-   kernel            0x00080000  0xA1008000  0x000A0000  0x00000000
-
-This leads to the following Linux MTD setup:
-
-   mtroot@192.168.0.14:~# cat /proc/mtd
-   dev:    size   erasesize  name
-   mtd0: 00040000 00020000 "RedBoot"
-   mtd1: 00040000 00020000 "RedBoot[backup]"
-   mtd2: 000a0000 00020000 "kernel"
-   mtd3: 006bf000 00020000 "unallocated space"
-   mtd4: 00001000 00020000 "RedBoot config"
-   mtd5: 00020000 00020000 "FIS directory"
-
-Note that there is not a 1:1 mapping to the number of RedBoot paritions to
-MTD partitions as unused space also gets allocated into MTD partitions.
-
-As an aside, the -r option when creating the Kernel entry allows you to
-simply do an 'fis load kernel' to copy the image from flash into memory.
-You can then do an 'fis go 0xa1008000' to start Linux.
-
-If you choose to use static partitioning instead of the RedBoot partioning:
-
-   /dev/mtd0  0x00000000 - 0x0007ffff: Boot Monitor     (512k)
-   /dev/mtd1  0x00080000 - 0x0011ffff: Kernel Image     (640K)
-   /dev/mtd2  0x00120000 - 0x0071ffff: File System      (6M)
-   /dev/mtd3  0x00720000 - 0x00800000: RedBoot Reserved (896K)
-
-To use a JFFS1/2 root FS, you need to donwload the JFFS image using either
-tftp or ymodem, and then copy it to flash:
-
-   RedBoot> load -r -b 0xa1000000 /tftpboot/jffs.img
-   Raw file loaded 0xa1000000-0xa1600000
-   RedBoot> fis create -b 0xa1000000 -l 0x600000 -f 0x120000 jffs
-   ... Erase from 0x00120000-0x00720000: ..................................
-   ... Program from 0xa1000000-0xa1600000 at 0x00120000: ..................
-   ......................
-   ... Unlock from 0x007e0000-0x00800000: .
-   ... Erase from 0x007e0000-0x00800000: .
-   ... Program from 0xa1fdf000-0xa1fff000 at 0x007e0000: .
-   ... Lock from 0x007e0000-0x00800000: .
-   RedBoot> fis list
-   Name              FLASH addr  Mem addr    Length      Entry point
-   RedBoot           0x00000000  0x00000000  0x00040000  0x00000000
-   RedBoot[backup]   0x00040000  0x00040000  0x00040000  0x00000000
-   RedBoot config    0x007DF000  0x007DF000  0x00001000  0x00000000
-   FIS directory     0x007E0000  0x007E0000  0x00020000  0x00000000
-   kernel            0x00080000  0xA1008000  0x000A0000  0xA1008000
-   jffs              0x00120000  0x00120000  0x00600000  0x00000000
-
-This looks like this in Linux:
-
-   root@192.168.0.14:~# cat /proc/mtd
-   dev:    size   erasesize  name
-   mtd0: 00040000 00020000 "RedBoot"
-   mtd1: 00040000 00020000 "RedBoot[backup]"
-   mtd2: 000a0000 00020000 "kernel"
-   mtd3: 00600000 00020000 "jffs"
-   mtd4: 000bf000 00020000 "unallocated space"
-   mtd5: 00001000 00020000 "RedBoot config"
-   mtd6: 00020000 00020000 "FIS directory"
-
-You need to boot the kernel once and watch the boot messages to see how the
-JFFS RedBoot partition mapped into the MTD partition scheme.
-
-You can grab a pre-built JFFS image to use as a root file system at:
-
-   ftp://source.mvista.com/pub/xscale/iq80310/jffs.img
-
-For detailed info on using MTD and creating a JFFS image go to:
-
-   http://www.linux-mtd.infradead.org.
-
-For details on using RedBoot's FIS commands, type 'fis help' or consult
-your RedBoot manual.
-
-Contributors
------------------------------
-
-Thanks to Intel Corporation for providing the hardware.
-
-John Clark <jclark@teamasa.com> - Initial discovery of RedBoot issues
-Dave Jiang <dave.jiang@intel.com> - IRQ demux fixes, AAU, DMA, MU
-Nicolas Pitre <nico@cam.org> - Initial port, cleanup, debugging
-Matt Porter <mporter@mvista.com> - PCI subsystem development, debugging
-Tim Sanders <tsanders@sanders.org> - Initial PCI code
-Mark Salter <msalter@redhat.com> - RedBoot fixes
-Deepak Saxena <dsaxena@mvista.com> - Cleanup, debug, cache lock, PMU
-
------------------------------
-Enjoy.
-
-If you have any problems please contact Deepak Saxena <dsaxena@mvista.com>
-
-A few notes from rmk
------------------------------
-
-These are notes of my initial experience getting the IQ80310 Rev D up and
-running.  In total, it has taken many hours to work out what's going on...
-The version of redboot used is:
-
- RedBoot(tm) bootstrap and debug environment, version UNKNOWN - built 14:58:21, Aug 15 2001
-
-
-1. I've had a corrupted download of the redboot.bin file from Montavista's
-   FTP site.  It would be a good idea if there were md5sums, sum or gpg
-   signatures available to ensure the integrity of the downloaded files.
-   The result of this was an apparantly 100% dead card.
-
-2. RedBoot Intel EtherExpress Pro 100 driver seems to be very unstable -
-   I've had it take out the whole of a 100mbit network for several minutes.
-   The Hub indiates ZERO activity, despite machines attempting to communicate.
-   Further to this, while tftping the kernel, the transfer will stall regularly,
-   and might even drop the link LED.
-
-3. There appears to be a bug in the Intel Documentation Pack that comes with
-   the IQ80310 board.  Serial port 1, which is the socket next to the LEDs
-   is address 0xfe810000, not 0xfe800000.
-
-   Note that RedBoot uses either serial port 1 OR serial port 2, so if you
-   have your console connected to the wrong port, you'll see redboot messages
-   but not kernel boot messages.
-
-4. Trying to use fconfig to setup a boot script fails - it hangs when trying
-   to erase the flash.
diff --git a/Documentation/arm/XScale/IOP3XX/IQ80321 b/Documentation/arm/XScale/IOP3XX/IQ80321
deleted file mode 100644 (file)
index e325327..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-
-Board Overview
------------------------------
-
-The Worcester IQ80321 board is an evaluation platform for Intel's 80321 Xscale
-CPU (sometimes called IOP321 chipset).
-
-The 80321 contains a single PCI hose (called the ATUs), a PCI-to-PCI bridge,
-two DMA channels, I2C, I2O messaging unit, XOR unit for RAID operations,
-a bus performance monitoring unit, and a memory controller with ECC features.
-
-For more information on the board, see http://developer.intel.com/iio
-
-Port Status
------------------------------
-
-Supported:
-
-- MTD/JFFS/JFFS2 root
-- NFS root
-- RAMDISK root
-- Serial port (ttyS0)
-- Cache/TLB locking on 80321 CPU
-- Performance monitoring unit on 80321 CPU
-
-TODO:
-
-- DMA engines
-- I2C
-- 80321 Bus Performance Monitor
-- Application Accelerator Unit (XOR engine for RAID)
-- I2O Messaging Unit
-- I2C unit
-- SSP
-
-Building the Kernel
------------------------------
-make iq80321_config
-make oldconfig
-make zImage
-
-This will build an image setup for BOOTP/NFS root support.  To change this,
-just run make menuconfig and disable nfs root or add a "root=" option.
-
-Preparing the Hardware
------------------------------
-
-Make sure you do an 'fis init' command once you boot with the new
-RedBoot image.
-
-Downloading Linux
------------------------------
-
-Assuming you have your development system setup to act as a bootp/dhcp
-server and running tftp:
-
-NOTE: The 80321 board uses a different default memory map than the 80310.
-
-   RedBoot> load -r -b 0x01008000 -m y
-
-Once the download is completed:
-
-   RedBoot> go 0x01008000
-
-There is a version of RedBoot floating around that has DHCP support, but
-I've never been able to cleanly transfer a kernel image and have it run.
-
-Root Devices
------------------------------
-
-A kernel is not useful without a root filesystem, and you have several
-choices with this board:  NFS root, RAMDISK, or JFFS/JFFS2.  For development
-purposes, it is suggested that you use NFS root for easy access to various
-tools.  Once you're ready to deploy, probably want to utilize JFFS/JFFS2 on
-the flash device.
-
-MTD on the IQ80321
------------------------------
-
-Linux on the IQ80321 supports RedBoot FIS paritioning if it is enabled.
-Out of the box, once you've done 'fis init' on RedBoot, you will get
-the following partitioning scheme:
-
-   root@192.168.0.14:~# cat /proc/mtd
-   dev:    size   erasesize  name
-   mtd0: 00040000 00020000 "RedBoot"
-   mtd1: 00040000 00020000 "RedBoot[backup]"
-   mtd2: 0075f000 00020000 "unallocated space"
-   mtd3: 00001000 00020000 "RedBoot config"
-   mtd4: 00020000 00020000 "FIS directory"
-
-To create an FIS directory, you need to use the fis command in RedBoot.
-As an example, you can burn the kernel into the flash once it's downloaded:
-
-   RedBoot> fis create -b 0x01008000 -l 0x8CBAC -r 0x01008000 -f 0x80000 kernel
-   ... Erase from 0x00080000-0x00120000: .....
-   ... Program from 0x01008000-0x01094bac at 0x00080000: .....
-   ... Unlock from 0x007e0000-0x00800000: .
-   ... Erase from 0x007e0000-0x00800000: .
-   ... Program from 0x01fdf000-0x01fff000 at 0x007e0000: .
-   ... Lock from 0x007e0000-0x00800000: .
-
-   RedBoot> fis list
-   Name              FLASH addr  Mem addr    Length      Entry point
-   RedBoot           0x00000000  0x00000000  0x00040000  0x00000000
-   RedBoot[backup]   0x00040000  0x00040000  0x00040000  0x00000000
-   RedBoot config    0x007DF000  0x007DF000  0x00001000  0x00000000
-   FIS directory     0x007E0000  0x007E0000  0x00020000  0x00000000
-   kernel            0x00080000  0x01008000  0x000A0000  0x00000000
-
-This leads to the following Linux MTD setup:
-
-   mtroot@192.168.0.14:~# cat /proc/mtd
-   dev:    size   erasesize  name
-   mtd0: 00040000 00020000 "RedBoot"
-   mtd1: 00040000 00020000 "RedBoot[backup]"
-   mtd2: 000a0000 00020000 "kernel"
-   mtd3: 006bf000 00020000 "unallocated space"
-   mtd4: 00001000 00020000 "RedBoot config"
-   mtd5: 00020000 00020000 "FIS directory"
-
-Note that there is not a 1:1 mapping to the number of RedBoot paritions to
-MTD partitions as unused space also gets allocated into MTD partitions.
-
-As an aside, the -r option when creating the Kernel entry allows you to
-simply do an 'fis load kernel' to copy the image from flash into memory.
-You can then do an 'fis go 0x01008000' to start Linux.
-
-If you choose to use static partitioning instead of the RedBoot partioning:
-
-   /dev/mtd0  0x00000000 - 0x0007ffff: Boot Monitor     (512k)
-   /dev/mtd1  0x00080000 - 0x0011ffff: Kernel Image     (640K)
-   /dev/mtd2  0x00120000 - 0x0071ffff: File System      (6M)
-   /dev/mtd3  0x00720000 - 0x00800000: RedBoot Reserved (896K)
-
-To use a JFFS1/2 root FS, you need to donwload the JFFS image using either
-tftp or ymodem, and then copy it to flash:
-
-   RedBoot> load -r -b 0x01000000 /tftpboot/jffs.img
-   Raw file loaded 0x01000000-0x01600000
-   RedBoot> fis create -b 0x01000000 -l 0x600000 -f 0x120000 jffs
-   ... Erase from 0x00120000-0x00720000: ..................................
-   ... Program from 0x01000000-0x01600000 at 0x00120000: ..................
-   ......................
-   ... Unlock from 0x007e0000-0x00800000: .
-   ... Erase from 0x007e0000-0x00800000: .
-   ... Program from 0x01fdf000-0x01fff000 at 0x007e0000: .
-   ... Lock from 0x007e0000-0x00800000: .
-   RedBoot> fis list
-   Name              FLASH addr  Mem addr    Length      Entry point
-   RedBoot           0x00000000  0x00000000  0x00040000  0x00000000
-   RedBoot[backup]   0x00040000  0x00040000  0x00040000  0x00000000
-   RedBoot config    0x007DF000  0x007DF000  0x00001000  0x00000000
-   FIS directory     0x007E0000  0x007E0000  0x00020000  0x00000000
-   kernel            0x00080000  0x01008000  0x000A0000  0x01008000
-   jffs              0x00120000  0x00120000  0x00600000  0x00000000
-
-This looks like this in Linux:
-
-   root@192.168.0.14:~# cat /proc/mtd
-   dev:    size   erasesize  name
-   mtd0: 00040000 00020000 "RedBoot"
-   mtd1: 00040000 00020000 "RedBoot[backup]"
-   mtd2: 000a0000 00020000 "kernel"
-   mtd3: 00600000 00020000 "jffs"
-   mtd4: 000bf000 00020000 "unallocated space"
-   mtd5: 00001000 00020000 "RedBoot config"
-   mtd6: 00020000 00020000 "FIS directory"
-
-You need to boot the kernel once and watch the boot messages to see how the
-JFFS RedBoot partition mapped into the MTD partition scheme.
-
-You can grab a pre-built JFFS image to use as a root file system at:
-
-   ftp://source.mvista.com/pub/xscale/iq80310/jffs.img
-
-For detailed info on using MTD and creating a JFFS image go to:
-
-   http://www.linux-mtd.infradead.org.
-
-For details on using RedBoot's FIS commands, type 'fis help' or consult
-your RedBoot manual.
-
-BUGS and ISSUES
------------------------------
-
-* As shipped from Intel, pre-production boards have two issues:
-
-- The on board ethernet is disabled S8E1-2 is off. You will need to turn it on.
-
-- The PCIXCAPs are configured for a 100Mhz clock, but the clock selected is
-  actually only 66Mhz. This causes the wrong PPL multiplier to be used and the
-  board only runs at 400Mhz instead of 600Mhz. The way to observe this is to
-  use a independent clock to time a "sleep 10" command from the prompt. If it
-  takes 15 seconds instead of 10, you are running at 400Mhz.
-
-- The experimental IOP310 drivers for the AAU, DMA, etc. are not supported yet.
-
-Contributors
------------------------------
-The port to the IQ80321 was performed by:
-
-Rory Bolt <rorybolt@pacbell.net> - Initial port, debugging.
-
-This port was based on the IQ80310 port with the following contributors:
-
-Nicolas Pitre <nico@cam.org> - Initial port, cleanup, debugging
-Matt Porter <mporter@mvista.com> - PCI subsystem development, debugging
-Tim Sanders <tsanders@sanders.org> - Initial PCI code
-Deepak Saxena <dsaxena@mvista.com> - Cleanup, debug, cache lock, PMU
-
-The port is currently maintained by Deepak Saxena <dsaxena@mvista.com>
-
------------------------------
-Enjoy.
diff --git a/Documentation/arm/XScale/IOP3XX/aau.txt b/Documentation/arm/XScale/IOP3XX/aau.txt
deleted file mode 100644 (file)
index e3852cc..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-Support functions for the Intel 80310 AAU
-===========================================
-
-Dave Jiang <dave.jiang@intel.com>
-Last updated: 09/18/2001
-
-The Intel 80312 companion chip in the 80310 chipset contains an AAU. The
-AAU is capable of processing up to 8 data block sources and perform XOR
-operations on them. This unit is typically used to accelerated XOR
-operations utilized by RAID storage device drivers such as RAID 5. This
-API is designed to provide a set of functions to take adventage of the
-AAU. The AAU can also be used to transfer data blocks and used as a memory
-copier. The AAU transfer the memory faster than the operation performed by
-using CPU copy therefore it is recommended to use the AAU for memory copy.
-
-------------------
-int aau_request(u32 *aau_context, const char *device_id);
-This function allows the user the acquire the control of the the AAU. The
-function will return a context of AAU to the user and allocate
-an interrupt for the AAU. The user must pass the context as a parameter to
-various AAU API calls.
-
-int aau_queue_buffer(u32 aau_context, aau_head_t *listhead);
-This function starts the AAU operation. The user must create a SGL
-header with a SGL attached. The format is presented below. The SGL is
-built from kernel memory.
-
-/* hardware descriptor */
-typedef struct _aau_desc
-{
-    u32 NDA;                    /* next descriptor address [READONLY] */
-    u32 SAR[AAU_SAR_GROUP];     /* src addrs */
-    u32 DAR;                    /* destination addr */
-    u32 BC;                     /* byte count */
-    u32 DC;                     /* descriptor control */
-    u32 SARE[AAU_SAR_GROUP];    /* extended src addrs */
-} aau_desc_t;
-
-/* user SGL format */
-typedef struct _aau_sgl
-{
-    aau_desc_t          aau_desc;  /* AAU HW Desc */
-    u32                        status;    /* status of SGL [READONLY] */
-    struct _aau_sgl    *next;     /* pointer to next SG [READONLY] */
-    void                *dest;     /* destination addr */
-    void                *src[AAU_SAR_GROUP];       /* source addr[4] */
-    void                *ext_src[AAU_SAR_GROUP];    /* ext src addr[4] */
-    u32                 total_src; /* total number of source */
-} aau_sgl_t;
-
-/* header for user SGL */
-typedef struct _aau_head
-{
-    u32                total;      /* total descriptors allocated */
-    u32         status;     /* SGL status */
-    aau_sgl_t   *list;      /* ptr to head of list */
-    aau_callback_t  callback;  /* callback func ptr */
-} aau_head_t;
-
-
-The function will call aau_start() and start the AAU after it queues
-the SGL to the processing queue. When the function will either
-a. Sleep on the wait queue aau->wait_q if no callback has been provided, or
-b. Continue and then call the provided callback function when DMA interrupt
-   has been triggered.
-
-int aau_suspend(u32 aau_context);
-Stops/Suspends the AAU operation
-
-int aau_free(u32 aau_context);
-Frees the ownership of AAU. Called when no longer need AAU service.
-
-aau_sgl_t * aau_get_buffer(u32 aau_context, int num_buf);
-This function obtains an AAU SGL for the user. User must specify the number
-of descriptors to be allocated in the chain that is returned.
-
-void aau_return_buffer(u32 aau_context, aau_sgl_t *list);
-This function returns all SGL back to the API after user is done.
-
-int aau_memcpy(void *dest, void *src, u32 size);
-This function is a short cut for user to do memory copy utilizing the AAU for
-better large block memory copy vs using the CPU. This is similar to using
-typical memcpy() call.
-
-* User is responsible for the source address(es) and the destination address.
-  The source and destination should all be cached memory.
-
-
-
-void aau_test()
-{
-       u32 aau;
-       char dev_id[] = "AAU";
-       int size = 2;
-       int err = 0;
-       aau_head_t *head;
-       aau_sgl_t *list;
-       u32 i;
-       u32 result = 0;
-       void *src, *dest;
-
-       printk("Starting AAU test\n");
-       if((err = aau_request(&aau, dev_id))<0)
-       {
-               printk("test - AAU request failed: %d\n", err);
-               return;
-       }
-       else
-       {
-               printk("test - AAU request successful\n");
-       }
-
-       head = kmalloc(sizeof(aau_head_t), GFP_KERNEL);
-       head->total = size;
-       head->status = 0;
-       head->callback = NULL;
-
-       list = aau_get_buffer(aau, size);
-       if(!list)
-       {
-               printk("Can't get buffers\n");
-               return;
-       }
-       head->list = list;
-
-       src = kmalloc(1024, GFP_KERNEL);
-       dest = kmalloc(1024, GFP_KERNEL);
-
-       while(list)
-       {
-               list->status = 0;
-               list->aau_desc->SAR[0] = (u32)src;
-               list->aau_desc->DAR = (u32)dest;
-               list->aau_desc->BC = 1024;
-
-               /* see iop310-aau.h for more DCR commands */
-               list->aau_desc->DC = AAU_DCR_WRITE | AAU_DCR_BLKCTRL_1_DF;
-               if(!list->next)
-               {
-                       list->aau_desc->DC = AAU_DCR_IE;
-                       break;
-               }
-               list = list->next;
-       }
-
-       printk("test- Queueing buffer for AAU operation\n");
-       err = aau_queue_buffer(aau, head);
-       if(err >= 0)
-       {
-               printk("AAU Queue Buffer is done...\n");
-       }
-       else
-       {
-               printk("AAU Queue Buffer failed...: %d\n", err);
-       }
-
-
-
-#if 1
-       printk("freeing the AAU\n");
-       aau_return_buffer(aau, head->list);
-       aau_free(aau);
-       kfree(src);
-       kfree(dest);
-       kfree((void *)head);
-#endif
-}
-
-All Disclaimers apply. Use this at your own discretion. Neither Intel nor I
-will be responsible if anything goes wrong. =)
-
-
-TODO
-____
-* Testing
-* Do zero-size AAU transfer/channel at init
-  so all we have to do is chainining
-
diff --git a/Documentation/arm/XScale/IOP3XX/dma.txt b/Documentation/arm/XScale/IOP3XX/dma.txt
deleted file mode 100644 (file)
index 50c7f99..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-Support functions forthe Intel 80310 DMA channels
-==================================================
-
-Dave Jiang <dave.jiang@intel.com>
-Last updated: 09/18/2001
-
-The Intel 80310 XScale chipset provides 3 DMA channels via the 80312 I/O
-companion chip. Two of them resides on the primary PCI bus and one on the
-secondary PCI bus.
-
-The DMA API provided is not compatible with the generic interface in the
-ARM tree unfortunately due to how the 80312 DMACs work. Hopefully some time
-in the near future a software interface can be done to bridge the differences.
-The DMA API has been modeled after Nicholas Pitre's SA11x0 DMA API therefore
-they will look somewhat similar.
-
-
-80310 DMA API
--------------
-
-int dma_request(dmach_t channel, const char *device_id);
-
-This function will attempt to allocate the channel depending on what the
-user requests:
-
-IOP310_DMA_P0: PCI Primary 1
-IOP310_DMA_P1: PCI Primary 2
-IOP310_DMA_S0: PCI Secondary 1
-/*EOF*/
-
-Once the user allocates the DMA channel it is owned until released. Although
-other users can also use the same DMA channel, but no new resources will be
-allocated. The function will return the allocated channel number if successful.
-
-int dma_queue_buffer(dmach_t channel, dma_sghead_t *listhead);
-
-The user will construct a SGL in the form of below:
-/*
- * Scattered Gather DMA List for user
- */
-typedef struct _dma_desc
-{
-    u32  NDAR;       /* next descriptor adress [READONLY] */
-    u32  PDAR;       /* PCI address */
-    u32  PUADR;      /* upper PCI address */
-    u32  LADR;       /* local address */
-    u32  BC;         /* byte count */
-    u32  DC;         /* descriptor control */
-} dma_desc_t;
-
-typedef struct _dma_sgl
-{
-    dma_desc_t      dma_desc;     /* DMA descriptor */
-    u32             status;       /* descriptor status [READONLY] */
-    u32                    data;         /* user defined data */
-    struct _dma_sgl *next;       /* next descriptor [READONLY] */
-} dma_sgl_t;
-
-/* dma sgl head */
-typedef struct _dma_head
-{
-    u32                    total;      /* total elements in SGL */
-    u32                    status;     /* status of sgl */
-    u32                    mode;       /* read or write mode */
-    dma_sgl_t      *list;      /* pointer to list */
-    dma_callback_t  callback;   /* callback function */
-} dma_head_t;
-
-
-The user shall allocate user SGL elements by calling the function:
-dma_get_buffer(). This function will give the user an SGL element. The user
-is responsible for creating the SGL head however. The user is also
-responsible for allocating the memory for DMA data. The following code segment
-shows how a DMA operation can be performed:
-
-#include <asm/arch/iop310-dma.h>
-
-void dma_test(void)
-{
-       char dev_id[] = "Primary 0";
-       dma_head_t *sgl_head = NULL;
-       dma_sgl_t *sgl = NULL;
-       int err = 0;
-       int channel = -1;
-       u32 *test_ptr = 0;
-       DECLARE_WAIT_QUEUE_HEAD(wait_q);
-
-
-       *(IOP310_ATUCR) = (IOP310_ATUCR_PRIM_OUT_ENAB |
-                       IOP310_ATUCR_DIR_ADDR_ENAB);
-
-       channel = dma_request(IOP310_DMA_P0, dev_id);
-
-       sgl_head = (dma_head_t *)kmalloc(sizeof(dma_head_t), GFP_KERNEL);
-       sgl_head->callback = NULL;      /* no callback created */
-       sgl_head->total = 2; /* allocating 2 DMA descriptors */
-       sgl_head->mode = (DMA_MOD_WRITE);
-       sgl_head->status = 0;
-
-       /* now we get the two descriptors */
-       sgl = dma_get_buffer(channel, 2);
-
-       /* we set the header to point to the list we allocated */
-       sgl_head->list = sgl;
-
-       /* allocate 1k of DMA data */
-       sgl->data = (u32)kmalloc(1024, GFP_KERNEL);
-
-       /* Local address is physical */
-       sgl->dma_desc.LADR = (u32)virt_to_phys(sgl->data);
-
-       /* write to arbitrary location over the PCI bus */
-       sgl->dma_desc.PDAR = 0x00600000;
-       sgl->dma_desc.PUADR = 0;
-       sgl->dma_desc.BC = 1024;
-
-       /* set write & invalidate PCI command */
-       sgl->dma_desc.DC = DMA_DCR_PCI_MWI;
-       sgl->status = 0;
-
-       /* set a pattern */
-       memset(sgl->data, 0xFF, 1024);
-
-       /* User's responsibility to keep buffers cached coherent */
-       cpu_dcache_clean(sgl->data, sgl->data + 1024);
-
-       sgl = sgl->next;
-
-       sgl->data = (u32)kmalloc(1024, GFP_KERNEL);
-       sgl->dma_desc.LADR = (u32)virt_to_phys(sgl->data);
-       sgl->dma_desc.PDAR = 0x00610000;
-       sgl->dma_desc.PUADR = 0;
-       sgl->dma_desc.BC = 1024;
-
-       /* second descriptor has interrupt flag enabled */
-       sgl->dma_desc.DC = (DMA_DCR_PCI_MWI | DMA_DCR_IE);
-
-       /* must set end of chain flag */
-       sgl->status = DMA_END_CHAIN; /* DO NOT FORGET THIS!!!! */
-
-       memset(sgl->data, 0x0f, 1024);
-       /* User's responsibility to keep buffers cached coherent */
-       cpu_dcache_clean(sgl->data, sgl->data + 1024);
-
-       /* queuing the buffer, this function will sleep since no callback */
-       err = dma_queue_buffer(channel, sgl_head);
-
-       /* now we are woken from DMA complete */
-
-       /* do data operations here */
-
-       /* free DMA data if necessary */
-
-       /* return the descriptors */
-       dma_return_buffer(channel, sgl_head->list);
-
-       /* free the DMA */
-       dma_free(channel);
-
-       kfree((void *)sgl_head);
-}
-
-
-dma_sgl_t * dma_get_buffer(dmach_t channel, int buf_num);
-
-This call allocates DMA descriptors for the user.
-
-
-void dma_return_buffer(dmach_t channel, dma_sgl_t *list);
-
-This call returns the allocated descriptors back to the API.
-
-
-int dma_suspend(dmach_t channel);
-
-This call suspends any DMA transfer on the given channel.
-
-
-
-int dma_resume(dmach_t channel);
-
-This call resumes a DMA transfer which would have been stopped through
-dma_suspend().
-
-
-int dma_flush_all(dmach_t channel);
-
-This completely flushes all queued buffers and on-going DMA transfers on a
-given channel. This is called when DMA channel errors have occurred.
-
-
-void dma_free(dmach_t channel);
-
-This clears all activities on a given DMA channel and releases it for future
-requests.
-
-
-
-Buffer Allocation
------------------
-It is the user's responsibility to allocate, free, and keep track of the
-allocated DMA data memory. Upon calling dma_queue_buffer() the user must
-relinquish the control of the buffers to the kernel and not change the
-state of the buffers that it has passed to the kernel. The user will regain
-the control of the buffers when it has been woken up by the bottom half of
-the DMA interrupt handler. The user can allocate cached buffers or non-cached
-via pci_alloc_consistent(). It is the user's responsibility to ensure that
-the data is cache coherent.
-
-*Reminder*
-The user is responsble to ensure the ATU is setup properly for DMA transfers.
-
-All Disclaimers apply. Use this at your own discretion. Neither Intel nor I
-will be responsible ifanything goes wrong.
diff --git a/Documentation/arm/XScale/IOP3XX/message.txt b/Documentation/arm/XScale/IOP3XX/message.txt
deleted file mode 100644 (file)
index 480d13e..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-Support functions for the Intel 80310 MU
-===========================================
-
-Dave Jiang <dave.jiang@intel.com>
-Last updated: 10/11/2001
-
-The messaging unit of the IOP310 contains 4 components and is utilized for
-passing messages between the PCI agents on the primary bus and the Intel(R)
-80200 CPU. The four components are:
-Messaging Component
-Doorbell Component
-Circular Queues Component
-Index Registers Component
-
-Messaging Component:
-Contains 4 32bit registers, 2 in and 2 out. Writing to the registers assert
-interrupt on the PCI bus or to the 80200 depend on incoming or outgoing.
-
-int mu_msg_request(u32 *mu_context);
-Request the usage of Messaging Component. mu_context is written back by the
-API. The MU context is passed to other Messaging calls as a parameter.
-
-int mu_msg_set_callback(u32 mu_context, u8 reg, mu_msg_cb_t func);
-Setup the callback function for incoming messages. Callback can be setup for
-outbound 0, 1, or both outbound registers.
-
-int mu_msg_post(u32 mu_context, u32 val, u8 reg);
-Posting a message in the val parameter. The reg parameter denotes whether
-to use register 0, 1.
-
-int mu_msg_free(u32 mu_context, u8 mode);
-Free the usage of messaging component. mode can be specified soft or hard. In
-hardmode all resources are unallocated.
-
-Doorbell Component:
-The doorbell registers contains 1 inbound and 1 outbound. Depending on the bits
-being set different interrupts are asserted.
-
-int mu_db_request(u32 *mu_context);
-Request the usage of the doorbell register.
-
-int mu_db_set_callback(u32 mu_context, mu_db_cb_t func);
-Setting up the inbound callback.
-
-void mu_db_ring(u32 mu_context, u32 mask);
-Write to the outbound db register with mask.
-
-int mu_db_free(u32 mu_context);
-Free the usage of doorbell component.
-
-Circular Queues Component:
-The circular queue component has 4 circular queues. Inbound post, inbound free,
-outbound post, outbound free. These queues are used to pass messages.
-
-int mu_cq_request(u32 *mu_context, u32 q_size);
-Request the usage of the queue. See code comment header for q_size. It tells
-the API how big of queues to setup.
-
-int mu_cq_inbound_init(u32 mu_context, mfa_list_t *list, u32 size,
-                       mu_cq_cb_t func);
-Init inbound queues. The user must provide a list of free message frames to
-be put in inbound free queue and the callback function to handle the inbound
-messages.
-
-int mu_cq_enable(u32 mu_context);
-Enables the circular queues mechanism. Called once all the setup functions
-are called.
-
-u32 mu_cq_get_frame(u32 mu_context);
-Obtain the address of an outbound free frame for the user.
-
-int mu_cq_post_frame(u32 mu_context, u32 mfa);
-The user can post the frame once getting the frame and put information in the
-frame.
-
-int mu_cq_free(u32 mu_context);
-Free the usage of circular queues mechanism.
-
-Index Registers Component:
-The index register provides the mechanism to receive inbound messages.
-
-int mu_ir_request(u32 *mu_context);
-Request of Index Register component usage.
-
-int mu_ir_set_callback(u32 mu_context, mu_ir_cb_t callback);
-Setting up callback for inbound messages. The callback will receive the
-value of the register that IAR offsets to.
-
-int mu_ir_free(u32 mu_context);
-Free the usage of Index Registers component.
-
-void mu_set_irq_threshold(u32 mu_context, int thresh);
-Setup the IRQ threshold before relinquish processing in IRQ space. Default
-is set at 10 loops.
-
-
-*NOTE: Example of host driver that utilize the MU can be found in the Linux I2O
-driver. Specifically i2o_pci and some functions of i2o_core. The I2O driver
-only utilize the circular queues mechanism. The other 3 components are simple
-enough that they can be easily setup. The MU API provides no flow control for
-the messaging mechanism. Flow control of the messaging needs to be established
-by a higher layer of software on the IOP or the host driver.
-
-All Disclaimers apply. Use this at your own discretion. Neither Intel nor I
-will be responsible if anything goes wrong. =)
-
-
-TODO
-____
-
diff --git a/Documentation/arm/XScale/IOP3XX/pmon.txt b/Documentation/arm/XScale/IOP3XX/pmon.txt
deleted file mode 100644 (file)
index 7978494..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-
-Intel's XScale Microarchitecture 80312 companion processor provides a
-Performance Monitoring Unit (PMON) that can be utilized to provide
-information that can be useful for fine tuning of code.  This text
-file describes the API that's been developed for use by Linux kernel
-programmers.  Note that to get the most usage out of the PMON,
-I highly reccomend getting the XScale reference manual from Intel[1]
-and looking at chapter 12.
-
-To use the PMON, you must #include <asm-arm/arch-iop310/pmon.h> in your
-source file.
-
-Since there's only one PMON, only one user can currently use the PMON
-at a given time.  To claim the PMON for usage, call iop310_pmon_claim() which
-returns an identifier.  When you are done using the PMON, call
-iop310_pmon_release() with the id you were given earlier.
-
-The PMON consists of 14 registers that can be used for performance measurements.
-By combining different statistics, you can derive complex performance metrics.
-
-To start the PMON, just call iop310_pmon_start(mode).  Mode tells the PMON what
-statistics to capture and can each be one of:
-
-    IOP310_PMU_MODE0
-    Performance Monitoring Disabled
-
-    IOP310_PMU_MODE1
-    Primary PCI bus and internal agents (bridge, dma Ch0, dam Ch1, patu)
-
-    IOP310_PMU_MODE2
-    Secondary PCI bus and internal agents (bridge, dma Ch0, dam Ch1, patu)
-
-    IOP310_PMU_MODE3
-    Secondary PCI bus and internal agents (external masters 0..2 and Intel
-    80312 I/O companion chip)
-
-    IOP310_PMU_MODE4
-    Secondary PCI bus and internal agents (external masters 3..5 and Intel
-    80312 I/O companion chip)
-
-    IOP310_PMU_MODE5
-    Intel 80312 I/O companion chip internal bus, DMA Channels and Application
-    Accelerator
-
-    IOP310_PMU_MODE6
-    Intel 80312 I/O companion chip internal bus, PATU, SATU and Intel 80200
-    processor
-
-    IOP310_PMU_MODE7
-    Intel 80312 I/O companion chip internal bus, Primary PCI bus, Secondary
-    PCI bus and Secondary PCI agents (external masters 0..5 & Intel 80312 I/O
-    companion chip)
-
-To get the results back, call iop310_pmon_stop(&results) where results is
-defined as follows:
-
-typedef struct _iop310_pmon_result
-{
-       u32 timestamp;                  /* Global Time Stamp Register */
-       u32 timestamp_overflow;         /* Time Stamp overflow count */
-       u32 event_count[14];            /* Programmable Event Counter
-                                          Registers 1-14 */
-       u32 event_overflow[14];         /* Overflow counter for PECR1-14 */
-} iop310_pmon_res_t;
-
-
---
-This code is still under development, so please feel free to send patches,
-questions, comments, etc to me.
-
-Deepak Saxena <dsaxena@mvista.com>
diff --git a/Documentation/arm/XScale/cache-lock.txt b/Documentation/arm/XScale/cache-lock.txt
deleted file mode 100644 (file)
index 9728c94..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-
-Intel's XScale Microarchitecture provides support for locking of data
-and instructions into the appropriate caches. This  file provides
-an overview of the API that has been developed to take advantage of this
-feature from kernel space. Note that there is NO support for user space
-cache locking.
-
-For example usage of this code, grab:
-
-       ftp://source.mvista.com/pub/xscale/cache-test.c
-
-If you have any questions, comments, patches, etc, please contact me.
-
-Deepak Saxena <dsaxena@mvista.com>
-
-API DESCRIPTION
-
-
-I. Header File
-
-   #include <asm/xscale-lock.h>
-
-II. Cache Capability Discovery
-
-   SYNOPSIS
-
-   int cache_query(u8 cache_type,
-                           struct cache_capabilities *pcache);
-
-   struct cache_capabilities
-   {
-      u32   flags;      /* Flags defining capabilities  */
-      u32   cache_size; /* Cache size in K (1024 bytes) */
-      u32   max_lock;   /* Maximum lockable region in K */
-   }
-
-   /*
-    * Flags
-    */
-
-   /*
-    * Bit 0: Cache lockability
-    * Bits 1-31: Reserved for future use
-    */
-   #define CACHE_LOCKABLE    0x00000001   /* Cache can be locked */
-
-   /*
-    * Cache Types
-    */
-   #define ICACHE            0x00
-   #define DCACHE            0x01
-
-   DESCRIPTION
-
-   This function fills out the pcache capability identifier for the
-   requested cache. cache_type is either DCACHE or ICACHE. This
-   function is not very useful at the moment as all XScale CPU's
-   have the same size Cache, but is is provided for future XScale
-   based processors that may have larger cache sizes.
-
-   RETURN VALUE
-
-   This function returns 0 if no error occurs, otherwise it returns
-   a negative, errno compatible value.
-
-      -EIO   Unknown hardware error
-
-III. Cache Locking
-
-   SYNOPSIS
-
-   int cache_lock(void *addr, u32 len, u8 cache_type, const char *desc);
-
-   DESCRIPTION
-
-   This function locks a physically contigous portion of memory starting
-   at the virtual address pointed to by addr into the cache referenced
-   by cache_type.
-
-   The address of the data/instruction that is to be locked must be
-   aligned on a cache line boundary (L1_CACHE_ALIGNEMENT).
-
-   The desc parameter is an optional (pass NULL if not used) human readable
-   descriptor of the locked memory region that is used by the cache
-   management code to build the /proc/cache_locks table.
-
-   Note that this function does not check whether the address is valid
-   or not before locking it into the cache.  That duty is up to the
-   caller.  Also, it does not check for duplicate or overlaping
-   entries.
-
-   RETURN VALUE
-
-   If the function is successful in locking the entry into cache, a
-   zero is returned.
-
-   If an error occurs, an appropriate error value is returned.
-
-      -EINVAL   The memory address provided was not cache line aligned
-      -ENOMEM   Could not allocate memory to complete operation
-      -ENOSPC   Not enough space left on cache to lock in requested region
-      -EIO      Unknown error
-
-III. Cache Unlocking
-
-   SYNOPSIS
-
-   int cache_unlock(void *addr)
-
-   DESCRIPTION
-
-   This function unlocks a portion of memory that was previously locked
-   into either the I or D cache.
-
-   RETURN VALUE
-
-   If the entry is cleanly unlocked from the cache, a 0 is returned.
-   In the case of an error, an appropriate error is returned.
-
-      -ENOENT    No entry with given address associated with this cache
-      -EIO       Unknown error
-
-
diff --git a/Documentation/arm/XScale/pmu.txt b/Documentation/arm/XScale/pmu.txt
deleted file mode 100644 (file)
index 508575d..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-
-Intel's XScale Microarchitecture processors provide a Performance
-Monitoring Unit (PMU) that can be utilized to provide information
-that can be useful for fine tuning of code.  This text file describes
-the API that's been developed for use by Linux kernel programmers.
-When I have some extra time on my hand, I will extend the code to
-provide support for user mode performance monitoring (which is
-probably much more useful).  Note that to get the most usage out
-of the PMU, I highly reccomend getting the XScale reference manual
-from Intel and looking at chapter 12.
-
-To use the PMU, you must #include <asm/xscale-pmu.h> in your source file.
-
-Since there's only one PMU, only one user can currently use the PMU
-at a given time.  To claim the PMU for usage, call pmu_claim() which
-returns an identifier.  When you are done using the PMU, call
-pmu_release() with the identifier that you were given by pmu_claim.
-
-In addition, the PMU can only be used on XScale based systems that
-provide an external timer.  Systems that the PMU is currently supported
-on are:
-
-       - Cyclone IQ80310
-
-Before delving into how to use the PMU code, let's do a quick overview
-of the PMU itself.  The PMU consists of three registers that can be
-used for performance measurements.  The first is the CCNT register with
-provides the number of clock cycles elapsed since the PMU was started.
-The next two register, PMN0 and PMN1, are eace user programmable to
-provide 1 of 20 different performance statistics.  By combining different
-statistics, you can derive complex performance metrics.
-
-To start the PMU, just call pmu_start(pm0, pmn1).  pmn0 and pmn1 tell
-the PMU what statistics to capture and can each be one of:
-
-EVT_ICACHE_MISS
-       Instruction fetches requiring access to external memory
-
-EVT_ICACHE_NO_DELIVER
-       Instruction cache could not deliver an instruction.  Either an
-       ICACHE miss or an instruction TLB miss.
-
-EVT_ICACHE_DATA_STALL
-       Stall in execution due to a data dependency. This counter is
-       incremented each cycle in which the condition is present.
-
-EVT_ITLB_MISS
-       Instruction TLB miss
-
-EVT_DTLB_MISS
-       Data TLB miss
-
-EVT_BRANCH
-       A branch instruction was executed and it may or may not have
-       changed program flow
-
-EVT_BRANCH_MISS
-       A branch (B or BL instructions only) was mispredicted
-
-EVT_INSTRUCTION
-       An instruction was executed
-
-EVT_DCACHE_FULL_STALL
-       Stall because data cache buffers are full.  Incremented on every
-       cycle in which condition is present.
-
-EVT_DCACHE_FULL_STALL_CONTIG
-       Stall because data cache buffers are full.  Incremented on every
-       cycle in which condition is contigous.
-
-EVT_DCACHE_ACCESS
-       Data cache access (data fetch)
-
-EVT_DCACHE_MISS
-       Data cache miss
-
-EVT_DCACHE_WRITE_BACK
-       Data cache write back.  This counter is incremented for every
-       1/2 line (four words) that are written back.
-
-EVT_PC_CHANGED
-       Software changed the PC.  This is incremented only when the
-       software changes the PC and there is no mode change.  For example,
-       a MOV instruction that targets the PC would increment the counter.
-       An SWI would not as it triggers a mode change.
-
-EVT_BCU_REQUEST
-       The Bus Control Unit(BCU) received a request from the core
-
-EVT_BCU_FULL
-       The BCU request queue if full.  A high value for this event means
-       that the BCU is often waiting for to complete on the external bus.
-
-EVT_BCU_DRAIN
-       The BCU queues were drained due to either a Drain Write Buffer
-       command or an I/O transaction for a page that was marked as
-       uncacheable and unbufferable.
-
-EVT_BCU_ECC_NO_ELOG
-       The BCU detected an ECC error on the memory bus but noe ELOG
-       register was available to to log the errors.
-
-EVT_BCU_1_BIT_ERR
-       The BCU detected a 1-bit error while reading from the bus.
-
-EVT_RMW
-       An RMW cycle occurred due to narrow write on ECC protected memory.
-
-To get the results back, call pmu_stop(&results) where results is defined
-as a struct pmu_results:
-
-       struct pmu_results
-       {
-               u32     ccnt;   /* Clock Counter Register */
-               u32     ccnt_of; /
-               u32     pmn0;   /* Performance Counter Register 0 */
-               u32     pmn0_of;
-               u32     pmn1;   /* Performance Counter Register 1 */
-               u32     pmn1_of;
-       };
-
-Pretty simple huh?  Following are some examples of how to get some commonly
-wanted numbers out of the PMU data.  Note that since you will be dividing
-things, this isn't super useful from the kernel and you need to printk the
-data out to syslog.  See [1] for more examples.
-
-Instruction Cache Efficiency
-
-       pmu_start(EVT_INSTRUCTION, EVT_ICACHE_MISS);
-       ...
-       pmu_stop(&results);
-
-       icache_miss_rage = results.pmn1 / results.pmn0;
-       cycles_per_instruction = results.ccnt / results.pmn0;
-
-Data Cache Efficiency
-
-       pmu_start(EVT_DCACHE_ACCESS, EVT_DCACHE_MISS);
-       ...
-       pmu_stop(&results);
-
-       dcache_miss_rage = results.pmn1 / results.pmn0;
-
-Instruction Fetch Latency
-
-       pmu_start(EVT_ICACHE_NO_DELIVER, EVT_ICACHE_MISS);
-       ...
-       pmu_stop(&results);
-
-       average_stall_waiting_for_instruction_fetch =
-               results.pmn0 / results.pmn1;
-
-       percent_stall_cycles_due_to_instruction_fetch =
-               results.pmn0 / results.ccnt;
-
-
-ToDo:
-
-- Add support for usermode PMU usage.  This might require hooking into
-  the scheduler so that we pause the PMU when the task that requested
-  statistics is scheduled out.
-
---
-This code is still under development, so please feel free to send patches,
-questions, comments, etc to me.
-
-Deepak Saxena <dsaxena@mvista.com>
-
diff --git a/Documentation/arm/XScale/tlb-lock.txt b/Documentation/arm/XScale/tlb-lock.txt
deleted file mode 100644 (file)
index 1ba3e11..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-
-Intel's XScale Microarchitecture provides support for locking of TLB
-entries in both the instruction and data TLBs.  This  file provides
-an overview of the API that has been developed to take advantage of this
-feature from kernel space. Note that there is NO support for user space.
-
-In general, this feature should be used in conjunction with locking
-data or instructions into the appropriate caches.  See the file
-cache-lock.txt in this directory.
-
-If you have any questions, comments, patches, etc, please contact me.
-
-Deepak Saxena <dsaxena@mvista.com>
-
-
-API DESCRIPTION
-
-I. Header file
-
-   #include <asm/xscale-lock.h>
-
-II. Locking an entry into the TLB
-
-    SYNOPSIS
-
-    xscale_tlb_lock(u8 tlb_type, u32 addr);
-
-    /*
-     * TLB types
-     */
-    #define ITLB       0x0
-    #define DTLB       0x1
-
-    DESCRIPTION
-
-    This function locks the virtual to physical mapping for virtual
-    address addr into the requested TLB.
-
-    RETURN VALUE
-
-    If the entry is properly locked into the TLB, a 0 is returned.
-    In case of an error, an appropriate error is returned.
-
-       -ENOSPC No more entries left in the TLB
-       -EIO    Unknown error
-
-III. Unlocking an entry from a TLB
-
-     SYNOPSIS
-
-     xscale_tlb_unlock(u8 tlb_type, u32 addr);
-
-     DESCRIPTION
-
-     This function unlocks the entry for virtual address addr from the
-     specified cache.
-
-     RETURN VALUE
-
-     If the TLB entry is properly unlocked, a 0 is returned.
-     In case of an error, an appropriate error is returned.
-
-        -ENOENT  No entry for given address in specified TLB
-
diff --git a/Documentation/as-iosched.txt b/Documentation/as-iosched.txt
deleted file mode 100644 (file)
index 0dba00d..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-Anticipatory IO scheduler
--------------------------
-Nick Piggin <piggin@cyberone.com.au>    13 Sep 2003
-
-Attention! Database servers, especially those using "TCQ" disks should
-investigate performance with the 'deadline' IO scheduler. Any system with high
-disk performance requirements should do so, in fact.
-
-If you see unusual performance characteristics of your disk systems, or you
-see big performance regressions versus the deadline scheduler, please email
-me. Database users don't bother unless you're willing to test a lot of patches
-from me ;) its a known issue.
-
-Also, users with hardware RAID controllers, doing striping, may find
-highly variable performance results with using the as-iosched. The
-as-iosched anticipatory implementation is based on the notion that a disk
-device has only one physical seeking head.  A striped RAID controller
-actually has a head for each physical device in the logical RAID device.
-
-However, setting the antic_expire (see tunable parameters below) produces
-very similar behavior to the deadline IO scheduler.
-
-
-Selecting IO schedulers
------------------------
-To choose IO schedulers at boot time, use the argument 'elevator=deadline'.
-'noop' and 'as' (the default) are also available. IO schedulers are assigned
-globally at boot time only presently.
-
-
-Anticipatory IO scheduler Policies
-----------------------------------
-The as-iosched implementation implements several layers of policies
-to determine when an IO request is dispatched to the disk controller.
-Here are the policies outlined, in order of application.
-
-1. one-way Elevator algorithm.
-
-The elevator algorithm is similar to that used in deadline scheduler, with
-the addition that it allows limited backward movement of the elevator
-(i.e. seeks backwards).  A seek backwards can occur when choosing between
-two IO requests where one is behind the elevator's current position, and
-the other is in front of the elevator's position. If the seek distance to
-the request in back of the elevator is less than half the seek distance to
-the request in front of the elevator, then the request in back can be chosen.
-Backward seeks are also limited to a maximum of MAXBACK (1024*1024) sectors.
-This favors forward movement of the elevator, while allowing opportunistic
-"short" backward seeks.
-
-2. FIFO expiration times for reads and for writes.
-
-This is again very similar to the deadline IO scheduler.  The expiration
-times for requests on these lists is tunable using the parameters read_expire
-and write_expire discussed below.  When a read or a write expires in this way,
-the IO scheduler will interrupt its current elevator sweep or read anticipation
-to service the expired request.
-
-3. Read and write request batching
-
-A batch is a collection of read requests or a collection of write
-requests.  The as scheduler alternates dispatching read and write batches
-to the driver.  In the case a read batch, the scheduler submits read
-requests to the driver as long as there are read requests to submit, and
-the read batch time limit has not been exceeded (read_batch_expire).
-The read batch time limit begins counting down only when there are
-competing write requests pending.
-
-In the case of a write batch, the scheduler submits write requests to
-the driver as long as there are write requests available, and the
-write batch time limit has not been exceeded (write_batch_expire).
-However, the length of write batches will be gradually shortened
-when read batches frequently exceed their time limit.
-
-When changing between batch types, the scheduler waits for all requests
-from the previous batch to complete before scheduling requests for the
-next batch.
-
-The read and write fifo expiration times described in policy 2 above
-are checked only when in scheduling IO of a batch for the corresponding
-(read/write) type.  So for example, the read FIFO timeout values are
-tested only during read batches.  Likewise, the write FIFO timeout
-values are tested only during write batches.  For this reason,
-it is generally not recommended for the read batch time
-to be longer than the write expiration time, nor for the write batch
-time to exceed the read expiration time (see tunable parameters below).
-
-When the IO scheduler changes from a read to a write batch,
-it begins the elevator from the request that is on the head of the
-write expiration FIFO.  Likewise, when changing from a write batch to
-a read batch, scheduler begins the elevator from the first entry
-on the read expiration FIFO.
-
-4. Read anticipation.
-
-Read anticipation occurs only when scheduling a read batch.
-This implementation of read anticipation allows only one read request
-to be dispatched to the disk controller at a time.  In
-contrast, many write requests may be dispatched to the disk controller
-at a time during a write batch.  It is this characteristic that can make
-the anticipatory scheduler perform anomalously with controllers supporting
-TCQ, or with hardware striped RAID devices. Setting the antic_expire
-queue paramter (see below) to zero disables this behavior, and the anticipatory
-scheduler behaves essentially like the deadline scheduler.
-
-When read anticipation is enabled (antic_expire is not zero), reads
-are dispatched to the disk controller one at a time.
-At the end of each read request, the IO scheduler examines its next
-candidate read request from its sorted read list.  If that next request
-is from the same process as the request that just completed,
-or if the next request in the queue is "very close" to the
-just completed request, it is dispatched immediately.  Otherwise,
-statistics (average think time, average seek distance) on the process
-that submitted the just completed request are examined.  If it seems
-likely that that process will submit another request soon, and that
-request is likely to be near the just completed request, then the IO
-scheduler will stop dispatching more read requests for up time (antic_expire)
-milliseconds, hoping that process will submit a new request near the one
-that just completed.  If such a request is made, then it is dispatched
-immediately.  If the antic_expire wait time expires, then the IO scheduler
-will dispatch the next read request from the sorted read queue.
-
-To decide whether an anticipatory wait is worthwhile, the scheduler
-maintains statistics for each process that can be used to compute
-mean "think time" (the time between read requests), and mean seek
-distance for that process.  One observation is that these statistics
-are associated with each process, but those statistics are not associated
-with a specific IO device.  So for example, if a process is doing IO
-on several file systems on separate devices, the statistics will be
-a combination of IO behavior from all those devices.
-
-
-Tuning the anticipatory IO scheduler
-------------------------------------
-When using 'as', the anticipatory IO scheduler there are 5 parameters under
-/sys/block/*/iosched/. All are units of milliseconds.
-
-The parameters are:
-* read_expire
-    Controls how long until a read request becomes "expired". It also controls the
-    interval between which expired requests are served, so set to 50, a request
-    might take anywhere < 100ms to be serviced _if_ it is the next on the
-    expired list. Obviously request expiration strategies won't make the disk
-    go faster. The result basically equates to the timeslice a single reader
-    gets in the presence of other IO. 100*((seek time / read_expire) + 1) is
-    very roughly the % streaming read efficiency your disk should get with
-    multiple readers.
-
-* read_batch_expire
-    Controls how much time a batch of reads is given before pending writes are
-    served. A higher value is more efficient. This might be set below read_expire
-    if writes are to be given higher priority than reads, but reads are to be
-    as efficient as possible when there are no writes. Generally though, it
-    should be some multiple of read_expire.
-   
-* write_expire, and
-* write_batch_expire are equivalent to the above, for writes.
-
-* antic_expire
-    Controls the maximum amount of time we can anticipate a good read (one
-    with a short seek distance from the most recently completed request) before
-    giving up. Many other factors may cause anticipation to be stopped early,
-    or some processes will not be "anticipated" at all. Should be a bit higher
-    for big seek time devices though not a linear correspondence - most
-    processes have only a few ms thinktime.
-
diff --git a/Documentation/ckrm/block_io b/Documentation/ckrm/block_io
new file mode 100644 (file)
index 0000000..e4a0b8b
--- /dev/null
@@ -0,0 +1,154 @@
+CKRM I/O controller
+
+Last updated: Sep 21, 2004
+
+
+Intro
+-----
+
+CKRM's I/O scheduler is developed as a delta over a modified version of
+the Complete Fair Queuing scheduler (CFQ) that implements I/O priorities.
+The latter's original posting can be found at:
+    http://www.ussg.iu.edu/hypermail/linux/kernel/0311.1/0019.html
+
+Please note that this is not the CFQ version currently in the linus kernel 
+(2.6.8.1 at time of writing) which provides equal, not prioritized, 
+bandwidth allocation amongst processes. Since the CFQ in the kernel is likely
+to eventually move towards I/O priority implementation, CKRM has not renamed
+the underlying I/O scheduler and simply replaces drivers/block/cfq-iosched.c
+with the modified version.
+
+Installation
+------------
+
+1. Configure "Disk I/O Resource Controller" under CKRM (see
+Documentation/ckrm/installation) 
+
+2. After booting into the new kernel, load ckrm-io
+   # modprobe ckrm-io
+
+3. Verify that reading /rcfs/taskclass/shares displays values for the
+I/O controller (res=cki).
+
+4. Mount sysfs for monitoring bandwidth received (temporary solution till
+a userlevel tool is developed)
+   # mount -t sysfs none /sys
+
+
+Usage
+-----
+
+For brevity, we assume we are in the /rcfs/taskclass directory for all the 
+code snippets below.
+
+Initially, the systemwide default class gets 100% of the I/O bandwidth. 
+
+       $ cat stats
+
+       <display from other controllers, snipped>
+       20 total ioprio
+       20 unused/default ioprio
+
+The first value is the share of a class, as a parent. The second is the share
+of its default subclass. Initially the two are equal. As named subclasses get
+created and assigned shares, the default subclass' share (which equals the
+"unused" portion of the parent's allocation) dwindles.
+
+
+CFQ assigns one of  20 I/O priorities to all I/O requests. Each priority level
+gets a fixed proportion of the total bandwidth in increments of 5%. e.g.
+     ioprio=1 gets 5%, 
+     ioprio=2 gets 10%.....
+     all the way through ioprio=19 getting 95%
+
+ioprio=0 gets bandwidth only if no other priority level submits I/O i.e. it can
+get starved.
+ioprio=20 is considered realtime I/O and always gets priority.
+
+CKRM's I/O scheduler distributes these 20 priority levels amongst the hierarchy
+of classes according to the relative share of each class. Thus, root starts out
+with the total allocation of 20 initially. As children get created and shares
+assigned to them, root's allocation reduces. At any time, the sum of absolute
+share values of all classes equals 20.
+
+
+Class creation 
+--------------
+
+       $ mkdir a
+
+Its initial share is zero. The parent's share values will be unchanged. Note
+that even classes with zero share get unused bandwidth under CFQ.
+
+Setting a new class share
+-------------------------
+       
+       $ echo "res=cki,guarantee=20" > /rcfs/taskclass/a/shares
+       Set cki shares to 20 -1 -1 -1
+
+       $ echo a/shares 
+       
+       res=cki,guarantee=20,limit=100,total_guarantee=100,max_limit=100
+
+The limit and max_limit fields can be ignored as they are not implemented.
+The absolute share of a is 20% of parent's absolute total (20) and can be seen
+through
+       $ echo a/stats
+
+       <snip>
+       4 total ioprio
+       4 unused/default ioprio
+
+Since a gets 4, parent's default's share diminishes accordingly. Thus
+
+       $ echo stats
+       
+       <snip>
+       20 total ioprio
+       16 unused/default ioprio
+
+
+Monitoring
+----------
+
+Each priority level's request service rate can be viewed through sysfs (mounted
+during installation). To view the servicing of priority 4's requests,
+
+       $  while : ; echo /sys/block/<device>/queue/iosched/p4 ; sleep 1 ; done
+       rq (10,15) sec (20,30) q (40,50)
+
+       <data above updated in a loop>
+
+where 
+      rq = cumulative I/O requests received (10) and serviced (15)
+      sec = cumulative sectors requested (20) and served (30)
+      q = cumulative number of times the queue was created(40)/destroyed (50)
+
+The rate at which requests or sectors are serviced should differ for different
+priority levels. The difference in received and serviced values indicates queue
+depth - with insufficient depth, differentiation between I/O priority levels
+will not be observed.
+
+The rate of q creation is not significant for CKRM. 
+
+
+Caveats
+-------
+
+CFQ's I/O differentiation is still being worked upon so its better to choose
+widely separated share values to observe differences in delivered I/O
+bandwidth.
+
+CFQ, and consequently CKRM, does not provide limits yet. So it is not possible
+to completely limit an I/O hog process by putting it in a class with a low I/O
+share. Only if the competing classes maintain sufficient queue depth (i.e a
+high I/O issue rate) will they get preferential treatment. However, they may
+still see latency degradation due to seeks caused by servicing of the low
+priority class.
+
+When limits are implemented, this behaviour will be rectified. 
+
+Please post questions on the CKRM I/O scheduler on ckrm-tech@lists.sf.net.
+
+
diff --git a/Documentation/ckrm/ckrm_basics b/Documentation/ckrm/ckrm_basics
new file mode 100644 (file)
index 0000000..cfd9a92
--- /dev/null
@@ -0,0 +1,66 @@
+CKRM Basics
+-------------
+A brief review of CKRM concepts and terminology will help make installation
+and testing easier. For more details, please visit http://ckrm.sf.net. 
+
+Currently there are two class types, taskclass and socketclass for grouping,
+regulating and monitoring tasks and sockets respectively.
+
+To avoid repeating instructions for each classtype, this document assumes a
+task to be the kernel object being grouped. By and large, one can replace task
+with socket and taskclass with socketclass.
+
+RCFS depicts a CKRM class as a directory. Hierarchy of classes can be
+created in which children of a class share resources allotted to
+the parent. Tasks can be classified to any class which is at any level.
+There is no correlation between parent-child relationship of tasks and
+the parent-child relationship of classes they belong to.
+
+Without a Classification Engine, class is inherited by a task. A privileged
+user can reassigned a task to a class as described below, after which all
+the child tasks under that task will be assigned to that class, unless the
+user reassigns any of them.
+
+A Classification Engine, if one exists, will be used by CKRM to
+classify a task to a class. The Rule based classification engine uses some
+of the attributes of the task to classify a task. When a CE is present
+class is not inherited by a task.
+
+Characteristics of a class can be accessed/changed through the following magic
+files under the directory representing the class:
+
+shares:  allows to change the shares of different resources managed by the
+         class
+stats:   allows to see the statistics associated with each resources managed
+         by the class
+target:  allows to assign a task to a class. If a CE is present, assigning
+         a task to a class through this interface will prevent CE from
+                reassigning the task to any class during reclassification.
+members: allows to see which tasks has been assigned to a class
+config:  allow to view and modify configuration information of different
+         resources in a class.
+
+Resource allocations for a class is controlled by the parameters:
+
+guarantee: specifies how much of a resource is guranteed to a class. A
+           special value DONT_CARE(-2) mean that there is no specific
+          guarantee of a resource is specified, this class may not get
+          any resource if the system is runing short of resources
+limit:     specifies the maximum amount of resource that is allowed to be
+           allocated by a class. A special value DONT_CARE(-2) mean that
+          there is no specific limit is specified, this class can get all
+          the resources available.
+total_guarantee: total guarantee that is allowed among the children of this
+           class. In other words, the sum of "guarantee"s of all children
+          of this class cannot exit this number.
+max_limit: Maximum "limit" allowed for any of this class's children. In
+          other words, "limit" of any children of this class cannot exceed
+          this value.
+
+None of this parameters are absolute or have any units associated with
+them. These are just numbers(that are relative to its parents') that are
+used to calculate the absolute number of resource available for a specific
+class.
+
+Note: The root class has an absolute number of resource units associated with it.
+
diff --git a/Documentation/ckrm/core_usage b/Documentation/ckrm/core_usage
new file mode 100644 (file)
index 0000000..6b5d808
--- /dev/null
@@ -0,0 +1,72 @@
+Usage of CKRM without a classification engine
+-----------------------------------------------
+
+1. Create a class
+
+   # mkdir /rcfs/taskclass/c1
+   creates a taskclass named c1 , while
+   # mkdir /rcfs/socket_class/s1
+   creates a socketclass named s1 
+
+The newly created class directory is automatically populated by magic files
+shares, stats, members, target and config.
+
+2. View default shares 
+
+   # cat /rcfs/taskclass/c1/shares
+
+   "guarantee=-2,limit=-2,total_guarantee=100,max_limit=100" is the default
+   value set for resources that have controllers registered with CKRM.
+
+3. change shares of a <class>
+
+   One or more of the following fields can/must be specified
+       res=<res_name> #mandatory
+       guarantee=<number>
+       limit=<number>
+       total_guarantee=<number>
+       max_limit=<number>
+   e.g.
+       # echo "res=numtasks,limit=20" > /rcfs/taskclass/c1
+
+   If any of these parameters are not specified, the current value will be
+   retained. 
+
+4. Reclassify a task (listening socket)
+
+   write the pid of the process to the destination class' target file
+   # echo 1004 > /rcfs/taskclass/c1/target     
+
+   write the "<ipaddress>\<port>" string to the destination class' target file 
+   # echo "0.0.0.0\32770"  > /rcfs/taskclass/c1/target
+
+5. Get a list of tasks (sockets) assigned to a taskclass (socketclass)
+
+   # cat /rcfs/taskclass/c1/members
+   lists pids of tasks belonging to c1
+
+   # cat /rcfs/socket_class/s1/members
+   lists the ipaddress\port of all listening sockets in s1 
+
+6. Get the statictics of different resources of a class
+
+   # cat /rcfs/tasksclass/c1/stats
+   shows c1's statistics for each resource with a registered resource
+   controller.
+
+   # cat /rcfs/socket_class/s1/stats
+   show's s1's stats for the listenaq controller.      
+
+7. View the configuration values of the resources associated with a class
+
+   # cat /rcfs/taskclass/c1/config
+   shows per-controller config values for c1.
+
+8. Change the configuration values of resources associated with a class
+   Configuration values are different for different resources. the comman
+   field "res=<resname>" must always be specified.
+
+   # echo "res=numtasks,parameter=value" > /rcfs/taskclass/c1/config
+   to change (without any effect), the value associated with <parameter>.
+
+
diff --git a/Documentation/ckrm/crbce b/Documentation/ckrm/crbce
new file mode 100644 (file)
index 0000000..dfb4b1e
--- /dev/null
@@ -0,0 +1,33 @@
+CRBCE
+----------
+
+crbce is a superset of rbce. In addition to providing automatic
+classification, the crbce module
+- monitors per-process delay data that is collected by the delay 
+accounting patch
+- collects data on significant kernel events where reclassification
+could occur e.g. fork/exec/setuid/setgid etc., and
+- uses relayfs to supply both these datapoints to userspace
+
+To illustrate the utility of the data gathered by crbce, we provide a
+userspace daemon called crbcedmn that prints the header info received
+from the records sent by the crbce module.
+
+0. Ensure that a CKRM-enabled kernel with following options configured
+   has been compiled. At a minimum, core, rcfs, atleast one classtype,
+   delay-accounting patch and relayfs. For testing, it is recommended
+   all classtypes and resource controllers be compiled as modules.
+
+1. Ensure that the Makefile's BUILD_CRBCE=1 and KDIR points to the
+   kernel of step 1 and call make.
+   This also builds the userspace daemon, crbcedmn.
+
+2..9 Same as rbce installation and testing instructions, 
+     except replacing rbce.ko with crbce.ko
+
+10. Read the pseudo daemon help file
+    # ./crbcedmn -h
+
+11. Run the crbcedmn to display all records being processed
+    # ./crbcedmn 
+
diff --git a/Documentation/ckrm/installation b/Documentation/ckrm/installation
new file mode 100644 (file)
index 0000000..0c90338
--- /dev/null
@@ -0,0 +1,70 @@
+Kernel installation
+------------------------------
+
+<kernver> = version of mainline Linux kernel
+<ckrmver> = version of CKRM
+
+Note: It is expected that CKRM versions will change fairly rapidly. Hence once
+a CKRM version has been released for some <kernver>, it will only be made
+available for future <kernver>'s until the next CKRM version is released. 
+
+1. Patch 
+
+    Apply ckrm/kernel/<kernver>/ckrm-<ckrmversion>.patch to a mainline kernel
+    tree with version <kernver>. 
+
+    If CRBCE will be used, additionally apply the following patches, in order: 
+       delayacctg-<ckrmversion>.patch 
+       relayfs-<ckrmversion>.patch
+    
+2. Configure
+
+Select appropriate configuration options:
+
+a. for taskclasses 
+
+   General Setup-->Class Based Kernel Resource Management
+
+   [*] Class Based Kernel Resource Management
+   <M> Resource Class File System (User API)
+   [*]   Class Manager for Task Groups  
+   <M>     Number of Tasks Resource Manager
+
+b. To test socket_classes and multiple accept queue controller 
+
+   General Setup-->Class Based Kernel Resource Management
+   [*] Class Based Kernel Resource Management
+   <M> Resource Class File System (User API)
+   [*]   Class Manager for socket groups
+   <M>     Multiple Accept Queues Resource Manager    
+   
+   Device Drivers-->Networking Support-->Networking options-->
+   [*] Network packet filtering (replaces ipchains)  
+   [*] IP: TCP Multiple accept queues support
+
+c. To test CRBCE later (requires 2a.)
+
+   File Systems-->Pseudo filesystems-->
+   <M> Relayfs filesystem support 
+   (enable all sub fields)
+   
+   General Setup-->
+   [*] Enable delay accounting
+   
+
+3. Build, boot into kernel
+
+4. Enable rcfs
+
+    # insmod <patchedtree>/fs/rcfs/rcfs.ko
+    # mount -t rcfs rcfs /rcfs
+    This will create the directories /rcfs/taskclass and
+    /rcfs/socketclass which are the "roots" of subtrees for creating
+    taskclasses and socketclasses respectively.
+       
+5. Load numtasks and listenaq controllers
+
+    # insmod <patchedtree>/kernel/ckrm/ckrm_tasks.ko
+    # insmod <patchedtree>/kernel/ckrm/ckrm_listenaq.ko
diff --git a/Documentation/ckrm/mem_rc.design b/Documentation/ckrm/mem_rc.design
new file mode 100644 (file)
index 0000000..bc565c6
--- /dev/null
@@ -0,0 +1,134 @@
+0. Lifecycle of a LRU Page:
+----------------------------
+These are the events in a page's lifecycle:
+   - allocation of the page
+     there are multiple high level page alloc functions; __alloc_pages()
+        is the lowest level function that does the real allocation.
+   - get into LRU list (active list or inactive list)
+   - get out of LRU list
+   - freeing the page
+     there are multiple high level page free functions; free_pages_bulk()
+        is the lowest level function that does the real free.
+
+When the memory subsystem runs low on LRU pages, pages are reclaimed by
+    - moving pages from active list to inactive list (refill_inactive_zone())
+       - freeing pages from the inactive list (shrink_zone)
+depending on the recent usage of the page(approximately).
+
+1. Introduction
+---------------
+Memory resource controller controls the number of lru physical pages
+(active and inactive list) a class uses. It does not restrict any
+other physical pages (slabs etc.,)
+
+For simplicity, this document will always refer lru physical pages as
+physical pages or simply pages.
+
+There are two parameters(that are set by the user) that affect the number
+of pages a class is allowed to have in active/inactive list.
+They are
+  - guarantee - specifies the number of pages a class is
+       guaranteed to get. In other words, if a class is using less than
+       'guarantee' number of pages, its pages will not be freed when the
+       memory subsystem tries to free some pages.
+  - limit - specifies the maximum number of pages a class can get;
+    'limit' in essence can be considered as the 'hard limit'
+
+Rest of this document details how these two parameters are used in the
+memory allocation logic.
+
+Note that the numbers that are specified in the shares file, doesn't
+directly correspond to the number of pages. But, the user can make
+it so by making the total_guarantee and max_limit of the default class
+(/rcfs/taskclass) to be the total number of pages(given in config file)
+available in the system.
+
+  for example: 
+   # cd /rcfs/taskclass
+   # cat config
+   res=mem;tot_pages=239778,active=60473,inactive=135285,free=44555
+   # cat shares
+   res=mem,guarantee=-2,limit=-2,total_guarantee=100,max_limit=100
+
+  "tot_pages=239778" above mean there are 239778 lru pages in
+  the system.
+  
+  By making total_guarantee and max_limit to be same as this number at 
+  this level (/rcfs/taskclass), one can make guarantee and limit in all 
+  classes refer to the number of pages.
+
+  # echo 'res=mem,total_guarantee=239778,max_limit=239778' > shares
+  # cat shares
+  res=mem,guarantee=-2,limit=-2,total_guarantee=239778,max_limit=239778
+
+
+The number of pages a class can use be anywhere between its guarantee and
+limit. CKRM memory controller springs into action when the system needs
+to choose a victim page to swap out. While the number of pages a class can
+have allocated may be anywhere between its guarantee and limit, victim
+pages will be choosen from classes that are above their guarantee.
+
+Pages will be freed from classes that are close to their "limit" before
+freeing pages from the classes that are close to their guarantee. Pages
+belonging to classes that are below their guarantee will not be chosen as
+a victim.
+
+2. Core Design
+--------------------------
+
+CKRM memory resource controller taps at appropriate low level memory 
+management functions to associate a page with a class and to charge
+a class that brings the page to the LRU list.
+
+2.1 Changes in page allocation function(__alloc_pages())
+--------------------------------------------------------
+- If the class that the current task belong to is over 110% of its 'limit',
+  allocation of page(s) fail.
+- After succesful allocation of a page, the page is attached with the class
+  to which the current task belongs to.
+- Note that the class is _not_ charged for the page(s) here.
+
+2.2 Changes in page free(free_pages_bulk())
+-------------------------------------------
+- page is freed from the class it belongs to.
+
+2.3 Adding/Deleting page to active/inactive list
+-------------------------------------------------
+When a page is added to the active or inactive list, the class that the
+page belongs to is charged for the page usage.
+
+When a page is deleted from the active or inactive list, the class that the
+page belongs to is credited back.
+
+If a class uses upto its limit, attempt is made to shrink the class's usage
+to 90% of its limit, in order to help the class stay within its limit.
+But, if the class is aggressive, and keep getting over the class's limit
+often(more than 10 shrink events in 10 seconds), then the memory resource
+controller gives up on the class and doesn't try to shrink the class, which
+will eventually lead the class to reach its 110% of its limit and then the
+page allocations will start failing.
+
+2.4 Chages in the page reclaimation path (refill_inactive_zone and shrink_zone)
+-------------------------------------------------------------------------------
+Pages will be moved from active to inactive list(refill_inactive_zone) and
+pages from inactive list will be freed in the following order:
+(range is calculated by subtracting 'guarantee' from 'limit')
+  - Classes that are over 110% of their range
+  - Classes that are over 100% of their range
+  - Classes that are over 75%  of their range
+  - Classes that are over 50%  of their range
+  - Classes that are over 25%  of their range
+  - Classes whose parent is over 110% of its range
+  - Classes that are over their guarantee
+
+2.5 Handling of Shared pages
+----------------------------
+Even if a mm is shared by tasks, the pages that belong to the mm will be
+charged against the individual tasks that bring the page into LRU. 
+
+But, when any task that is using a mm moves to a different class or exits,
+then all pages that belong to the mm will be charged against the richest
+class among the tasks that are using the mm.
+
+Note: Shared page handling need to be improved with a better policy.
+
diff --git a/Documentation/ckrm/mem_rc.usage b/Documentation/ckrm/mem_rc.usage
new file mode 100644 (file)
index 0000000..faddbf8
--- /dev/null
@@ -0,0 +1,72 @@
+Installation
+------------
+
+1. Configure "Class based physical memory controller" under CKRM (see
+      Documentation/ckrm/installation) 
+
+2. Reboot the system with the new kernel.
+
+3. Verify that the memory controller is present by reading the file
+   /rcfs/taskclass/config (should show a line with res=mem)
+
+Usage
+-----
+
+For brevity, unless otherwise specified all the following commands are
+executed in the default class (/rcfs/taskclass).
+
+Initially, the systemwide default class gets 100% of the LRU pages, and the
+config file displays the total number of physical pages.
+
+   # cd /rcfs/taskclass
+   # cat config
+   res=mem;tot_pages=239778,active=60473,inactive=135285,free=44555
+   # cat shares
+   res=mem,guarantee=-2,limit=-2,total_guarantee=100,max_limit=100
+
+   tot_pages - total number of pages
+   active    - number of pages in the active list ( sum of all zones)
+   inactive  - number of pages in the inactive list ( sum of all zones )
+   free      -  number of free pages (sum of all pages)
+
+   By making total_guarantee and max_limit to be same as tot_pages, one make 
+   make the numbers in shares file be same as the number of pages for a
+   class.
+
+   # echo 'res=mem,total_guarantee=239778,max_limit=239778' > shares
+   # cat shares
+   res=mem,guarantee=-2,limit=-2,total_guarantee=239778,max_limit=239778
+
+
+Class creation 
+--------------
+
+   # mkdir c1
+
+Its initial share is don't care. The parent's share values will be unchanged.
+
+Setting a new class share
+-------------------------
+       
+   # echo 'res=mem,guarantee=25000,limit=50000' > c1/shares
+
+   # cat c1/shares     
+   res=mem,guarantee=25000,limit=50000,total_guarantee=100,max_limit=100
+       
+   'guarantee' specifies the number of pages this class entitled to get
+   'limit' is the maximum number of pages this class can get.
+
+Monitoring
+----------
+
+stats file shows statistics of the page usage of a class
+   # cat stats
+   ----------- Memory Resource stats start -----------
+   Number of pages used(including pages lent to children): 196654
+   Number of pages guaranteed: 239778
+   Maximum limit of pages: 239778
+   Total number of pages available(after serving guarantees to children): 214778
+   Number of pages lent to children: 0
+   Number of pages borrowed from the parent: 0
+   ----------- Memory Resource stats end -----------
+
diff --git a/Documentation/ckrm/rbce_basics b/Documentation/ckrm/rbce_basics
new file mode 100644 (file)
index 0000000..fd66ef2
--- /dev/null
@@ -0,0 +1,67 @@
+Rule-based Classification Engine (RBCE)
+-------------------------------------------
+
+The ckrm/rbce directory contains the sources for two classification engines
+called rbce and crbce. Both are optional, built as kernel modules and share much
+of their codebase. Only one classification engine (CE) can be loaded at a time
+in CKRM.
+
+
+With RBCE, user can specify rules for how tasks are classified to a
+class.  Rules are specified by one or more attribute-value pairs and
+an associated class. The tasks that match all the attr-value pairs
+will get classified to the class attached with the rule.
+
+The file rbce_info under /rcfs/ce directory details the functionality
+of different files available under the directory and also details
+about attributes that can are used to define rules.
+
+order: When multiple rules are defined the rules are executed
+          according to the order of a rule. Order can be specified
+          while defining a rule.  If order is not specified, the
+          highest order will be assigned to the rule(i.e, the new
+          rule will be executed after all the previously defined
+          evaluate false). So, order of rules is important as that
+          will decide, which class a task will get assigned to. For
+          example, if we have the two following rules: r1:
+          uid=1004,order=10,class=/rcfs/taskclass/c1 r2:
+          uid=1004,cmd=grep,order=20,class=/rcfs/taskclass/c2 then,
+          the task "grep" executed by user 1004 will always be
+          assigned to class /rcfs/taskclass/c1, as rule r1 will be
+          executed before r2 and the task successfully matched the
+          rule's attr-value pairs. Rule r2 will never be consulted
+          for the command.  Note: The order in which the rules are
+          displayed(by ls) has no correlation with the order of the
+          rule.
+
+dependency: Rules can be defined to be depend on another rule. i.e a
+          rule can be dependent on one rule and has its own
+          additional attr-value pairs. the dependent rule will
+          evaluate true only if all the attr-value pairs of both
+          rules are satisfied.  ex: r1: gid=502,class=/rcfs/taskclass
+          r2: depend=r1,cmd=grep,class=rcfstaskclass/c1 r2 is a
+          dependent rule that depends on r1, a task will be assigned
+          to /rcfs/taskclass/c1 if its gid is 502 and the executable
+          command name is "grep". If a task's gid is 502 but the
+          command name is _not_ "grep" then it will be assigned to
+          /rcfs/taskclass
+
+          Note: The order of dependent rule must be _lesser_ than the
+          rule it depends on, so that it is evaluated _before the
+          base rule is evaluated. Otherwise the base rule will
+          evaluate true and the task will be assigned to the class of
+          that rule without the dependent rule ever getting
+          evaluated. In the example above, order of r2 must be lesser
+          than order of r1.
+
+app_tag: a task can be attached with a tag(ascii string), that becomes
+          an attribute of that task and rules can be defined with the
+          tag value.
+
+state: states are at two levels in RBCE. The entire RBCE can be
+          enabled or disabled which writing 1 or 0 to the file
+          rbce_state under /rcfs/ce.  Disabling RBCE, would mean that
+          the rules defined in RBCE will not be utilized for
+          classifying a task to a class.  A specific rule can be
+          enabled/disabled by changing the state of that rule. Once
+          it is disabled, the rule will not be evaluated.
diff --git a/Documentation/ckrm/rbce_usage b/Documentation/ckrm/rbce_usage
new file mode 100644 (file)
index 0000000..6d15926
--- /dev/null
@@ -0,0 +1,98 @@
+Usage of CKRM with RBCE
+--------------------------
+
+0. Ensure that a CKRM-enabled kernel with following options configured
+   has been compiled. At a minimum, core, rcfs and atleast one
+   classtype. For testing, it is recommended all classtypes and
+   resource controllers be compiled as modules.
+
+1. Change ckrm/rbce/Makefile's KDIR to point to this compiled kernel's source
+   tree and call make
+
+2. Load rbce module.
+   # insmod ckrm/rbce/rbce.ko 
+   Note that /rcfs has to be mounted before this.
+   Note: this command should populate the directory /rcfs/ce with files
+   rbce_reclassify, rbce_tag, rbce_info, rbce_state and a directory
+   rules.
+
+   Note2: If these are not created automatically, just create them by
+   using the commands touch and mkdir.(bug that needs to be fixed)
+
+3. Defining a rule
+   Rules are defined by creating(by writing) to a file under the
+   /rcfs/ce/rules directory by concatinating multiple attribute value
+   pairs.
+
+   Note that the classes must be defined before defining rules that
+   uses the classes.  eg: the command # echo
+   "uid=1004,class=/rcfs/taskclass/c1" > /rcfs/ce/rules/r1 will define
+   a rule r1 that classifies all tasks belong to user id 1004 to class
+   /rcfs/taskclass/c1
+
+4. Viewing a rule
+   read the corresponding file.
+   to read rule r1, issue the command:
+      # cat /rcfs/ce/rules/r1
+
+5. Changing a rule
+
+   Changing a rule is done the same way as defining a rule, the new
+   rule will include the old set of attr-value pairs slapped with new
+   attr-value pairs.  eg: if the current r2 is
+   uid=1004,depend=r1,class=/rcfs/taskclass/c1
+   (r1 as defined in step 3)
+
+   the command:
+     # echo gid=502 > /rcfs/ce/rules/r1
+   will change the rule to
+     r1: uid=1004,gid=502,depend=r1,class=/rcfs/taskclass/c1
+
+   the command:
+     # echo uid=1005 > /rcfs/ce/rules/r1
+   will change the rule to
+     r1: uid=1005,class=/rcfs/taskclass/c1
+
+   the command:
+     # echo class=/rcfs/taskclass/c2 > /rcfs/ce/rules/r1
+   will change the rule to
+     r1: uid=1004,depend=r1,class=/rcfs/taskclass/c2
+   
+   the command:
+     # echo depend=r4 > /rcfs/ce/rules/r1
+   will change the rule to
+     r1: uid=1004,depend=r4,class=/rcfs/taskclass/c2
+   
+   the command:
+     # echo +depend=r4 > /rcfs/ce/rules/r1
+   will change the rule to
+     r1: uid=1004,depend=r1,depend=r4,class=/rcfs/taskclass/c2
+   
+   the command:
+     # echo -depend=r1 > /rcfs/ce/rules/r1
+   will change the rule to
+     r1: uid=1004,class=/rcfs/taskclass/c2
+
+6. Checking the state of RBCE
+   State(enabled/disabled) of RBCE can be checked by reading the file
+   /rcfs/ce/rbce_state, it will show 1(enabled) or 0(disabled).
+   By default, RBCE is enabled(1).
+   ex: # cat /rcfs/ce/rbce_state
+
+7. Changing the state of RBCE
+   State of RBCE can be changed by writing 1(enable) or 0(disable).
+   ex: # echo 1 > cat /rcfs/ce/rbce_state
+
+8. Checking the state of a rule
+   State of a rule is displayed in the rule. Rule can be viewed by
+   reading the rule file.  ex: # cat /rcfs/ce/rules/r1
+
+9. Changing the state of a rule
+
+   State of a rule can be changed by writing "state=1"(enable) or
+   "state=0"(disable) to the corresponding rule file. By defeault, the
+   rule is enabled when defined.  ex: to disable an existing rule r1,
+   issue the command 
+   # echo "state=0" > /rcfs/ce/rules/r1
+
+
diff --git a/Documentation/filesystems/relayfs.txt b/Documentation/filesystems/relayfs.txt
new file mode 100644 (file)
index 0000000..7397bdb
--- /dev/null
@@ -0,0 +1,812 @@
+
+relayfs - a high-speed data relay filesystem
+============================================
+
+relayfs is a filesystem designed to provide an efficient mechanism for
+tools and facilities to relay large amounts of data from kernel space
+to user space.
+
+The main idea behind relayfs is that every data flow is put into a
+separate "channel" and each channel is a file.  In practice, each
+channel is a separate memory buffer allocated from within kernel space
+upon channel instantiation. Software needing to relay data to user
+space would open a channel or a number of channels, depending on its
+needs, and would log data to that channel. All the buffering and
+locking mechanics are taken care of by relayfs.  The actual format and
+protocol used for each channel is up to relayfs' clients.
+
+relayfs makes no provisions for copying the same data to more than a
+single channel. This is for the clients of the relay to take care of,
+and so is any form of data filtering. The purpose is to keep relayfs
+as simple as possible.
+
+
+Usage
+=====
+
+In addition to the relayfs kernel API described below, relayfs
+implements basic file operations.  Here are the file operations that
+are available and some comments regarding their behavior:
+
+open()  enables user to open an _existing_ channel.  A channel can be
+        opened in blocking or non-blocking mode, and can be opened
+        for reading as well as for writing.  Readers will by default
+        be auto-consuming.
+
+mmap()  results in channel's memory buffer being mmapped into the
+        caller's memory space.
+
+read()  since we are dealing with circular buffers, the user is only
+        allowed to read forward.  Some apps may want to loop around
+        read() waiting for incoming data - if there is no data
+        available, read will put the reader on a wait queue until
+        data is available (blocking mode).  Non-blocking reads return
+        -EAGAIN if data is not available.
+
+
+write()         writing from user space operates exactly as relay_write() does
+        (described below).
+
+poll() POLLIN/POLLRDNORM/POLLOUT/POLLWRNORM/POLLERR supported.
+
+close()  decrements the channel's refcount.  When the refcount reaches
+        0 i.e. when no process or kernel client has the file open
+        (see relay_close() below), the channel buffer is freed.
+
+
+In order for a user application to make use of relayfs files, the
+relayfs filesystem must be mounted.  For example,
+
+       mount -t relayfs relayfs /mountpoint
+
+
+The relayfs kernel API
+======================
+
+relayfs channels are implemented as circular buffers subdivided into
+'sub-buffers'.  kernel clients write data into the channel using
+relay_write(), and are notified via a set of callbacks when
+significant events occur within the channel.  'Significant events'
+include:
+
+- a sub-buffer has been filled i.e. the current write won't fit into the
+  current sub-buffer, and a 'buffer-switch' is triggered, after which
+  the data is written into the next buffer (if the next buffer is
+  empty).  The client is notified of this condition via two callbacks,
+  one providing an opportunity to perform start-of-buffer tasks, the
+  other end-of-buffer tasks.
+
+- data is ready for the client to process.  The client can choose to
+  be notified either on a per-sub-buffer basis (bulk delivery) or
+  per-write basis (packet delivery).
+
+- data has been written to the channel from user space.  The client can
+  use this notification to accept and process 'commands' sent to the
+  channel via write(2).
+
+- the channel has been opened/closed/mapped/unmapped from user space.
+  The client can use this notification to trigger actions within the
+  kernel application, such as enabling/disabling logging to the
+  channel.  It can also return result codes from the callback,
+  indicating that the operation should fail e.g. in order to restrict
+  more than one user space open or mmap.
+
+- the channel needs resizing, or needs to update its
+  state based on the results of the resize.  Resizing the channel is
+  up to the kernel client to actually perform.  If the channel is
+  configured for resizing, the client is notified when the unread data
+  in the channel passes a preset threshold, giving it the opportunity
+  to allocate a new channel buffer and replace the old one.
+
+Reader objects
+--------------
+
+Channel readers use an opaque rchan_reader object to read from
+channels.  For VFS readers (those using read(2) to read from a
+channel), these objects are automatically created and used internally;
+only kernel clients that need to directly read from channels, or whose
+userspace applications use mmap to access channel data, need to know
+anything about rchan_readers - others may skip this section.
+
+A relay channel can have any number of readers, each represented by an
+rchan_reader instance, which is used to encapsulate reader settings
+and state.  rchan_reader objects should be treated as opaque by kernel
+clients.  To create a reader object for directly accessing a channel
+from kernel space, call the add_rchan_reader() kernel API function:
+
+rchan_reader *add_rchan_reader(rchan_id, auto_consume)
+
+This function returns an rchan_reader instance if successful, which
+should then be passed to relay_read() when the kernel client is
+interested in reading from the channel.
+
+The auto_consume parameter indicates whether a read done by this
+reader will automatically 'consume' that portion of the unread channel
+buffer when relay_read() is called (see below for more details).
+
+To close the reader, call
+
+remove_rchan_reader(reader)
+
+which will remove the reader from the list of current readers.
+
+
+To create a reader object representing a userspace mmap reader in the
+kernel application, call the add_map_reader() kernel API function:
+
+rchan_reader *add_map_reader(rchan_id)
+
+This function returns an rchan_reader instance if successful, whose
+main purpose is as an argument to be passed into
+relay_buffers_consumed() when the kernel client becomes aware that
+data has been read by a user application using mmap to read from the
+channel buffer.  There is no auto_consume option in this case, since
+only the kernel client/user application knows when data has been read.
+
+To close the map reader, call
+
+remove_map_reader(reader)
+
+which will remove the reader from the list of current readers.
+
+Consumed count
+--------------
+
+A relayfs channel is a circular buffer, which means that if there is
+no reader reading from it or a reader reading too slowly, at some
+point the channel writer will 'lap' the reader and data will be lost.
+In normal use, readers will always be able to keep up with writers and
+the buffer is thus never in danger of becoming full.  In many
+applications, it's sufficient to ensure that this is practically
+speaking always the case, by making the buffers large enough.  These
+types of applications can basically open the channel as
+RELAY_MODE_CONTINOUS (the default anyway) and not worry about the
+meaning of 'consume' and skip the rest of this section.
+
+If it's important for the application that a kernel client never allow
+writers to overwrite unread data, the channel should be opened using
+RELAY_MODE_NO_OVERWRITE and must be kept apprised of the count of
+bytes actually read by the (typically) user-space channel readers.
+This count is referred to as the 'consumed count'.  read(2) channel
+readers automatically update the channel's 'consumed count' as they
+read.  If the usage mode is to have only read(2) readers, which is
+typically the case, the kernel client doesn't need to worry about any
+of the relayfs functions having to do with 'bytes consumed' and can
+skip the rest of this section.  (Note that it is possible to have
+multiple read(2) or auto-consuming readers, but like having multiple
+readers on a pipe, these readers will race with each other i.e. it's
+supported, but doesn't make much sense).
+
+If the kernel client cannot rely on an auto-consuming reader to keep
+the 'consumed count' up-to-date, then it must do so manually, by
+making the appropriate calls to relay_buffers_consumed() or
+relay_bytes_consumed().  In most cases, this should only be necessary
+for bulk mmap clients - almost all packet clients should be covered by
+having auto-consuming read(2) readers.  For mmapped bulk clients, for
+instance, there are no auto-consuming VFS readers, so the kernel
+client needs to make the call to relay_buffers_consumed() after
+sub-buffers are read.
+
+Kernel API
+----------
+
+Here's a summary of the API relayfs provides to in-kernel clients:
+
+int    relay_open(channel_path, bufsize, nbufs, channel_flags,
+                 channel_callbacks, start_reserve, end_reserve,
+                 rchan_start_reserve, resize_min, resize_max, mode,
+                 init_buf, init_buf_size)
+int    relay_write(channel_id, *data_ptr, count, time_delta_offset, **wrote)
+rchan_reader *add_rchan_reader(channel_id, auto_consume)
+int    remove_rchan_reader(rchan_reader *reader)
+rchan_reader *add_map_reader(channel_id)
+int    remove_map_reader(rchan_reader *reader)
+int    relay_read(reader, buf, count, wait, *actual_read_offset)
+void   relay_buffers_consumed(reader, buffers_consumed)
+void   relay_bytes_consumed(reader, bytes_consumed, read_offset)
+int    relay_bytes_avail(reader)
+int    rchan_full(reader)
+int    rchan_empty(reader)
+int    relay_info(channel_id, *channel_info)
+int    relay_close(channel_id)
+int    relay_realloc_buffer(channel_id, nbufs, async)
+int    relay_replace_buffer(channel_id)
+int    relay_reset(int rchan_id)
+
+----------
+int relay_open(channel_path, bufsize, nbufs, 
+        channel_flags, channel_callbacks, start_reserve,
+        end_reserve, rchan_start_reserve, resize_min, resize_max, mode)
+
+relay_open() is used to create a new entry in relayfs.  This new entry
+is created according to channel_path.  channel_path contains the
+absolute path to the channel file on relayfs.  If, for example, the
+caller sets channel_path to "/xlog/9", a "xlog/9" entry will appear
+within relayfs automatically and the "xlog" directory will be created
+in the filesystem's root.  relayfs does not implement any policy on
+its content, except to disallow the opening of two channels using the
+same file. There are, nevertheless a set of guidelines for using
+relayfs. Basically, each facility using relayfs should use a top-level
+directory identifying it. The entry created above, for example,
+presumably belongs to the "xlog" software.
+
+The remaining parameters for relay_open() are as follows:
+
+- channel_flags - an ORed combination of attribute values controlling
+  common channel characteristics:
+
+       - logging scheme - relayfs use 2 mutually exclusive schemes
+         for logging data to a channel.  The 'lockless scheme'
+         reserves and writes data to a channel without the need of
+         any type of locking on the channel.  This is the preferred
+         scheme, but may not be available on a given architecture (it
+         relies on the presence of a cmpxchg instruction).  It's
+         specified by the RELAY_SCHEME_LOCKLESS flag.  The 'locking
+         scheme' either obtains a lock on the channel for writing or
+         disables interrupts, depending on whether the channel was
+         opened for SMP or global usage (see below).  It's specified
+         by the RELAY_SCHEME_LOCKING flag.  While a client may want
+         to explicitly specify a particular scheme to use, it's more
+         convenient to specify RELAY_SCHEME_ANY for this flag, which
+         will allow relayfs to choose the best available scheme i.e.
+         lockless if supported.
+
+       - overwrite mode (default is RELAY_MODE_CONTINUOUS) -
+        If RELAY_MODE_CONTINUOUS is specified, writes to the channel
+        will succeed regardless of whether there are up-to-date
+        consumers or not.  If RELAY_MODE_NO_OVERWRITE is specified,
+        the channel becomes 'full' when the total amount of buffer
+        space unconsumed by readers equals or exceeds the total
+        buffer size.  With the buffer in this state, writes to the
+        buffer will fail - clients need to check the return code from
+        relay_write() to determine if this is the case and act
+        accordingly - 0 or a negative value indicate the write failed.
+
+       - SMP usage - this applies only when the locking scheme is in
+        use.  If RELAY_USAGE_SMP is specified, it's assumed that the
+        channel will be used in a per-CPU fashion and consequently,
+        the only locking that will be done for writes is to disable
+        local irqs.  If RELAY_USAGE_GLOBAL is specified, it's assumed
+        that writes to the buffer can occur within any CPU context,
+        and spinlock_irq_save will be used to lock the buffer.
+
+       - delivery mode - if RELAY_DELIVERY_BULK is specified, the
+        client will be notified via its deliver() callback whenever a
+        sub-buffer has been filled.  Alternatively,
+        RELAY_DELIVERY_PACKET will cause delivery to occur after the
+        completion of each write.  See the description of the channel
+        callbacks below for more details.
+
+       - timestamping - if RELAY_TIMESTAMP_TSC is specified and the
+        architecture supports it, efficient TSC 'timestamps' can be
+        associated with each write, otherwise more expensive
+        gettimeofday() timestamping is used.  At the beginning of
+        each sub-buffer, a gettimeofday() timestamp and the current
+        TSC, if supported, are read, and are passed on to the client
+        via the buffer_start() callback.  This allows correlation of
+        the current time with the current TSC for subsequent writes.
+        Each subsequent write is associated with a 'time delta',
+        which is either the current TSC, if the channel is using
+        TSCs, or the difference between the buffer_start gettimeofday
+        timestamp and the gettimeofday time read for the current
+        write.  Note that relayfs never writes either a timestamp or
+        time delta into the buffer unless explicitly asked to (see
+        the description of relay_write() for details).
+- bufsize - the size of the 'sub-buffers' making up the circular channel
+  buffer.  For the lockless scheme, this must be a power of 2.
+
+- nbufs - the number of 'sub-buffers' making up the circular
+  channel buffer.  This must be a power of 2.
+
+  The total size of the channel buffer is bufsize * nbufs rounded up 
+  to the next kernel page size.  If the lockless scheme is used, both
+  bufsize and nbufs must be a power of 2.  If the locking scheme is
+  used, the bufsize can be anything and nbufs must be a power of 2.  If
+  RELAY_SCHEME_ANY is used, the bufsize and nbufs should be a power of 2.
+
+  NOTE: if nbufs is 1, relayfs will bypass the normal size
+  checks and will allocate an rvmalloced buffer of size bufsize.
+  This buffer will be freed when relay_close() is called, if the channel
+  isn't still being referenced.
+
+- callbacks - a table of callback functions called when events occur
+  within the data relay that clients need to know about:
+          
+         - int buffer_start(channel_id, current_write_pos, buffer_id,
+           start_time, start_tsc, using_tsc) -
+
+           called at the beginning of a new sub-buffer, the
+           buffer_start() callback gives the client an opportunity to
+           write data into space reserved at the beginning of a
+           sub-buffer.  The client should only write into the buffer
+           if it specified a value for start_reserve and/or
+           channel_start_reserve (see below) when the channel was
+           opened.  In the latter case, the client can determine
+           whether to write its one-time rchan_start_reserve data by
+           examining the value of buffer_id, which will be 0 for the
+           first sub-buffer.  The address that the client can write
+           to is contained in current_write_pos (the client by
+           definition knows how much it can write i.e. the value it
+           passed to relay_open() for start_reserve/
+           channel_start_reserve).  start_time contains the
+           gettimeofday() value for the start of the buffer and start
+           TSC contains the TSC read at the same time.  The using_tsc
+           param indicates whether or not start_tsc is valid (it
+           wouldn't be if TSC timestamping isn't being used).
+
+           The client should return the number of bytes it wrote to
+           the channel, 0 if none.
+
+         - int buffer_end(channel_id, current_write_pos, end_of_buffer,
+           end_time, end_tsc, using_tsc)
+
+           called at the end of a sub-buffer, the buffer_end()
+           callback gives the client an opportunity to perform
+           end-of-buffer processing.  Note that the current_write_pos
+           is the position where the next write would occur, but
+           since the current write wouldn't fit (which is the trigger
+           for the buffer_end event), the buffer is considered full
+           even though there may be unused space at the end.  The
+           end_of_buffer param pointer value can be used to determine
+           exactly the size of the unused space.  The client should
+           only write into the buffer if it specified a value for
+           end_reserve when the channel was opened.  If the client
+           doesn't write anything i.e. returns 0, the unused space at
+           the end of the sub-buffer is available via relay_info() -
+           this data may be needed by the client later if it needs to
+           process raw sub-buffers (an alternative would be to save
+           the unused bytes count value in end_reserve space at the
+           end of each sub-buffer during buffer_end processing and
+           read it when needed at a later time.  The other
+           alternative would be to use read(2), which makes the
+           unused count invisible to the caller).  end_time contains
+           the gettimeofday() value for the end of the buffer and end
+           TSC contains the TSC read at the same time.  The using_tsc
+           param indicates whether or not end_tsc is valid (it
+           wouldn't be if TSC timestamping isn't being used).
+
+           The client should return the number of bytes it wrote to
+           the channel, 0 if none.
+
+         - void deliver(channel_id, from, len)
+
+           called when data is ready for the client.  This callback
+           is used to notify a client when a sub-buffer is complete
+           (in the case of bulk delivery) or a single write is
+           complete (packet delivery).  A bulk delivery client might
+           wish to then signal a daemon that a sub-buffer is ready.
+           A packet delivery client might wish to process the packet
+           or send it elsewhere.  The from param is a pointer to the
+           delivered data and len specifies how many bytes are ready.
+
+         - void user_deliver(channel_id, from, len)
+
+           called when data has been written to the channel from user
+           space.  This callback is used to notify a client when a
+           successful write from userspace has occurred, independent
+           of whether bulk or packet delivery is in use.  This can be
+           used to allow userspace programs to communicate with the
+           kernel client through the channel via out-of-band write(2)
+           'commands' instead of via ioctls, for instance.  The from
+           param is a pointer to the delivered data and len specifies
+           how many bytes are ready.  Note that this callback occurs
+           after the bytes have been successfully written into the
+           channel, which means that channel readers must be able to
+           deal with the 'command' data which will appear in the
+           channel data stream just as any other userspace or
+           non-userspace write would.
+
+         - int needs_resize(channel_id, resize_type,
+                            suggested_buf_size, suggested_n_bufs)
+
+           called when a channel's buffers are in danger of becoming
+           full i.e. the number of unread bytes in the channel passes
+           a preset threshold, or when the current capacity of a
+           channel's buffer is no longer needed.  Also called to
+           notify the client when a channel's buffer has been
+           replaced.  If resize_type is RELAY_RESIZE_EXPAND or
+           RELAY_RESIZE_SHRINK, the kernel client should arrange to
+           call relay_realloc_buffer() with the suggested buffer size
+           and buffer count, which will allocate (but will not
+           replace the old one) a new buffer of the recommended size
+           for the channel.  When the allocation has completed,
+           needs_resize() is again called, this time with a
+           resize_type of RELAY_RESIZE_REPLACE.  The kernel client
+           should then arrange to call relay_replace_buffer() to
+           actually replace the old channel buffer with the newly
+           allocated buffer.  Finally, once the buffer replacement
+           has completed, needs_resize() is again called, this time
+           with a resize_type of RELAY_RESIZE_REPLACED, to inform the
+           client that the replacement is complete and additionally
+           confirming the current sub-buffer size and number of
+           sub-buffers.  Note that a resize can be canceled if
+           relay_realloc_buffer() is called with the async param
+           non-zero and the resize conditions no longer hold.  In
+           this case, the RELAY_RESIZE_REPLACED suggested number of
+           sub-buffers will be the same as the number of sub-buffers
+           that existed before the RELAY_RESIZE_SHRINK or EXPAND i.e.
+           values indicating that the resize didn't actually occur.
+
+         - int fileop_notify(channel_id, struct file *filp, enum relay_fileop)
+
+           called when a userspace file operation has occurred or
+           will occur on a relayfs channel file.  These notifications
+           can be used by the kernel client to trigger actions within
+           the kernel client when the corresponding event occurs,
+           such as enabling logging only when a userspace application
+           opens or mmaps a relayfs file and disabling it again when
+           the file is closed or unmapped.  The kernel client can
+           also return its own return value, which can affect the
+           outcome of file operation - returning 0 indicates that the
+           operation should succeed, and returning a negative value
+           indicates that the operation should be failed, and that
+           the returned value should be returned to the ultimate
+           caller e.g. returning -EPERM from the open fileop will
+           cause the open to fail with -EPERM.  Among other things,
+           the return value can be used to restrict a relayfs file
+           from being opened or mmap'ed more than once.  The currently
+           implemented fileops are:
+
+           RELAY_FILE_OPEN - a relayfs file is being opened.  Return
+                             0 to allow it to succeed, negative to
+                             have it fail.  A negative return value will
+                             be passed on unmodified to the open fileop.
+           RELAY_FILE_CLOSE- a relayfs file is being closed.  The return
+                             value is ignored.
+           RELAY_FILE_MAP - a relayfs file is being mmap'ed.  Return 0
+                            to allow it to succeed, negative to have
+                            it fail.  A negative return value will be
+                            passed on unmodified to the mmap fileop.
+           RELAY_FILE_UNMAP- a relayfs file is being unmapped.  The return
+                             value is ignored.
+
+         - void ioctl(rchan_id, cmd, arg)
+
+           called when an ioctl call is made using a relayfs file
+           descriptor.  The cmd and arg are passed along to this
+           callback unmodified for it to do as it wishes with.  The
+           return value from this callback is used as the return value
+           of the ioctl call.
+
+  If the callbacks param passed to relay_open() is NULL, a set of
+  default do-nothing callbacks will be defined for the channel.
+  Likewise, any NULL rchan_callback function contained in a non-NULL
+  callbacks struct will be filled in with a default callback function
+  that does nothing.
+
+- start_reserve - the number of bytes to be reserved at the start of
+  each sub-buffer.  The client can do what it wants with this number
+  of bytes when the buffer_start() callback is invoked.  Typically
+  clients would use this to write per-sub-buffer header data.
+
+- end_reserve - the number of bytes to be reserved at the end of each
+  sub-buffer.  The client can do what it wants with this number of
+  bytes when the buffer_end() callback is invoked.  Typically clients
+  would use this to write per-sub-buffer footer data.
+
+- channel_start_reserve - the number of bytes to be reserved, in
+  addition to start_reserve, at the beginning of the first sub-buffer
+  in the channel.  The client can do what it wants with this number of
+  bytes when the buffer_start() callback is invoked.  Typically
+  clients would use this to write per-channel header data.
+
+- resize_min - if set, this signifies that the channel is
+  auto-resizeable.  The value specifies the size that the channel will
+  try to maintain as a normal working size, and that it won't go
+  below.  The client makes use of the resizing callbacks and
+  relay_realloc_buffer() and relay_replace_buffer() to actually effect
+  the resize.
+
+- resize_max - if set, this signifies that the channel is
+  auto-resizeable.  The value specifies the maximum size the channel
+  can have as a result of resizing.
+
+- mode - if non-zero, specifies the file permissions that will be given
+  to the channel file.  If 0, the default rw user perms will be used.
+
+- init_buf - if non-NULL, rather than allocating the channel buffer,
+  this buffer will be used as the initial channel buffer.  The kernel
+  API function relay_discard_init_buf() can later be used to have
+  relayfs allocate a normal mmappable channel buffer and switch over
+  to using it after copying the init_buf contents into it.  Currently,
+  the size of init_buf must be exactly buf_size * n_bufs.  The caller
+  is responsible for managing the init_buf memory.  This feature is
+  typically used for init-time channel use and should normally be
+  specified as NULL.
+
+- init_buf_size - the total size of init_buf, if init_buf is specified
+  as non-NULL.  Currently, the size of init_buf must be exactly
+  buf_size * n_bufs.
+
+Upon successful completion, relay_open() returns a channel id
+to be used for all other operations with the relay. All buffers
+managed by the relay are allocated using rvmalloc/rvfree to allow
+for easy mmapping to user-space.
+
+----------
+int relay_write(channel_id, *data_ptr, count, time_delta_offset, **wrote_pos)
+
+relay_write() reserves space in the channel and writes count bytes of
+data pointed to by data_ptr to it.  Automatically performs any
+necessary locking, depending on the scheme and SMP usage in effect (no
+locking is done for the lockless scheme regardless of usage).  It
+returns the number of bytes written, or 0/negative on failure.  If
+time_delta_offset is >= 0, the internal time delta, the internal time
+delta calculated when the slot was reserved will be written at that
+offset.  This is the TSC or gettimeofday() delta between the current
+write and the beginning of the buffer, whichever method is being used
+by the channel.  Trying to write a count larger than the bufsize
+specified to relay_open() (taking into account the reserved
+start-of-buffer and end-of-buffer space as well) will fail.  If
+wrote_pos is non-NULL, it will receive the location the data was
+written to, which may be needed for some applications but is not
+normally interesting.  Most applications should pass in NULL for this
+param.
+
+----------
+struct rchan_reader *add_rchan_reader(int rchan_id, int auto_consume)
+
+add_rchan_reader creates and initializes a reader object for a
+channel.  An opaque rchan_reader object is returned on success, and is
+passed to relay_read() when reading the channel.  If the boolean
+auto_consume parameter is 1, the reader is defined to be
+auto-consuming.  auto-consuming reader objects are automatically
+created and used for VFS read(2) readers.
+
+----------
+void remove_rchan_reader(struct rchan_reader *reader)
+
+remove_rchan_reader finds and removes the given reader from the
+channel.  This function is used only by non-VFS read(2) readers.  VFS
+read(2) readers are automatically removed when the corresponding file
+object is closed.
+
+----------
+reader add_map_reader(int rchan_id)
+
+Creates and initializes an rchan_reader object for channel map
+readers, and is needed for updating relay_bytes/buffers_consumed()
+when kernel clients become aware of the need to do so by their mmap
+user clients.
+
+----------
+int remove_map_reader(reader)
+
+Finds and removes the given map reader from the channel.  This function
+is useful only for map readers.
+
+----------
+int relay_read(reader, buf, count, wait, *actual_read_offset)
+
+Reads count bytes from the channel, or as much as is available within
+the sub-buffer currently being read.  The read offset that will be
+read from is the position contained within the reader object.  If the
+wait flag is set, buf is non-NULL, and there is nothing available, it
+will wait until there is.  If the wait flag is 0 and there is nothing
+available, -EAGAIN is returned.  If buf is NULL, the value returned is
+the number of bytes that would have been read.  actual_read_offset is
+the value that should be passed as the read offset to
+relay_bytes_consumed, needed only if the reader is not auto-consuming
+and the channel is MODE_NO_OVERWRITE, but in any case, it must not be
+NULL.
+
+---------- 
+
+int relay_bytes_avail(reader)
+
+Returns the number of bytes available relative to the reader's current
+read position within the corresponding sub-buffer, 0 if there is
+nothing available.  Note that this doesn't return the total bytes
+available in the channel buffer - this is enough though to know if
+anything is available, however, or how many bytes might be returned
+from the next read.
+
+----------
+void relay_buffers_consumed(reader, buffers_consumed)
+
+Adds to the channel's consumed buffer count.  buffers_consumed should
+be the number of buffers newly consumed, not the total number
+consumed.  NOTE: kernel clients don't need to call this function if
+the reader is auto-consuming or the channel is MODE_CONTINUOUS.
+
+In order for the relay to detect the 'buffers full' condition for a
+channel, it must be kept up-to-date with respect to the number of
+buffers consumed by the client.  If the addition of the value of the
+bufs_consumed param to the current bufs_consumed count for the channel
+would exceed the bufs_produced count for the channel, the channel's
+bufs_consumed count will be set to the bufs_produced count for the
+channel.  This allows clients to 'catch up' if necessary.
+
+----------
+void relay_bytes_consumed(reader, bytes_consumed, read_offset)
+
+Adds to the channel's consumed count.  bytes_consumed should be the
+number of bytes actually read e.g. return value of relay_read() and
+the read_offset should be the actual offset the bytes were read from
+e.g. the actual_read_offset set by relay_read().  NOTE: kernel clients
+don't need to call this function if the reader is auto-consuming or
+the channel is MODE_CONTINUOUS.
+
+In order for the relay to detect the 'buffers full' condition for a
+channel, it must be kept up-to-date with respect to the number of
+bytes consumed by the client.  For packet clients, it makes more sense
+to update after each read rather than after each complete sub-buffer
+read.  The bytes_consumed count updates bufs_consumed when a buffer
+has been consumed so this count remains consistent.
+
+----------
+int relay_info(channel_id, *channel_info)
+
+relay_info() fills in an rchan_info struct with channel status and
+attribute information such as usage modes, sub-buffer size and count,
+the allocated size of the entire buffer, buffers produced and
+consumed, current buffer id, count of writes lost due to buffers full
+condition.
+
+The virtual address of the channel buffer is also available here, for
+those clients that need it.
+
+Clients may need to know how many 'unused' bytes there are at the end
+of a given sub-buffer.  This would only be the case if the client 1)
+didn't either write this count to the end of the sub-buffer or
+otherwise note it (it's available as the difference between the buffer
+end and current write pos params in the buffer_end callback) (if the
+client returned 0 from the buffer_end callback, it's assumed that this
+is indeed the case) 2) isn't using the read() system call to read the
+buffer.  In other words, if the client isn't annotating the stream and
+is reading the buffer by mmaping it, this information would be needed
+in order for the client to 'skip over' the unused bytes at the ends of
+sub-buffers.
+
+Additionally, for the lockless scheme, clients may need to know
+whether a particular sub-buffer is actually complete.  An array of
+boolean values, one per sub-buffer, contains non-zero if the buffer is
+complete, non-zero otherwise.
+
+----------
+int relay_close(channel_id)
+
+relay_close() is used to close the channel.  It finalizes the last
+sub-buffer (the one currently being written to) and marks the channel
+as finalized.  The channel buffer and channel data structure are then
+freed automatically when the last reference to the channel is given
+up.
+
+----------
+int relay_realloc_buffer(channel_id, nbufs, async)
+
+Allocates a new channel buffer using the specified sub-buffer count
+(note that resizing can't change sub-buffer sizes).  If async is
+non-zero, the allocation is done in the background using a work queue.
+When the allocation has completed, the needs_resize() callback is
+called with a resize_type of RELAY_RESIZE_REPLACE.  This function
+doesn't replace the old buffer with the new - see
+relay_replace_buffer().
+
+This function is called by kernel clients in response to a
+needs_resize() callback call with a resize type of RELAY_RESIZE_EXPAND
+or RELAY_RESIZE_SHRINK.  That callback also includes a suggested
+new_bufsize and new_nbufs which should be used when calling this
+function.
+
+Returns 0 on success, or errcode if the channel is busy or if
+the allocation couldn't happen for some reason.
+
+NOTE: if async is not set, this function should not be called with a
+lock held, as it may sleep.
+
+----------
+int relay_replace_buffer(channel_id)
+
+Replaces the current channel buffer with the new buffer allocated by
+relay_realloc_buffer and contained in the channel struct.  When the
+replacement is complete, the needs_resize() callback is called with
+RELAY_RESIZE_REPLACED.  This function is called by kernel clients in
+response to a needs_resize() callback having a resize type of
+RELAY_RESIZE_REPLACE.
+
+Returns 0 on success, or errcode if the channel is busy or if the
+replacement or previous allocation didn't happen for some reason.
+
+NOTE: This function will not sleep, so can called in any context and
+with locks held.  The client should, however, ensure that the channel
+isn't actively being read from or written to.
+
+----------
+int relay_reset(rchan_id)
+
+relay_reset() has the effect of erasing all data from the buffer and
+restarting the channel in its initial state.  The buffer itself is not
+freed, so any mappings are still in effect.  NOTE: Care should be
+taken that the channnel isn't actually being used by anything when
+this call is made.
+
+----------
+int rchan_full(reader)
+
+returns 1 if the channel is full with respect to the reader, 0 if not.
+
+----------
+int rchan_empty(reader)
+
+returns 1 if the channel is empty with respect to the reader, 0 if not.
+
+----------
+int relay_discard_init_buf(rchan_id)
+
+allocates an mmappable channel buffer, copies the contents of init_buf
+into it, and sets the current channel buffer to the newly allocated
+buffer.  This function is used only in conjunction with the init_buf
+and init_buf_size params to relay_open(), and is typically used when
+the ability to write into the channel at init-time is needed.  The
+basic usage is to specify an init_buf and init_buf_size to relay_open,
+then call this function when it's safe to switch over to a normally
+allocated channel buffer.  'Safe' means that the caller is in a
+context that can sleep and that nothing is actively writing to the
+channel.  Returns 0 if successful, negative otherwise.
+
+
+Writing directly into the channel
+=================================
+
+Using the relay_write() API function as described above is the
+preferred means of writing into a channel.  In some cases, however,
+in-kernel clients might want to write directly into a relay channel
+rather than have relay_write() copy it into the buffer on the client's
+behalf.  Clients wishing to do this should follow the model used to
+implement relay_write itself.  The general sequence is:
+
+- get a pointer to the channel via rchan_get().  This increments the
+  channel's reference count.
+- call relay_lock_channel().  This will perform the proper locking for
+  the channel given the scheme in use and the SMP usage.
+- reserve a slot in the channel via relay_reserve()
+- write directly to the reserved address
+- call relay_commit() to commit the write
+- call relay_unlock_channel()
+- call rchan_put() to release the channel reference
+
+In particular, clients should make sure they call rchan_get() and
+rchan_put() and not hold on to references to the channel pointer.
+Also, forgetting to use relay_lock_channel()/relay_unlock_channel()
+has no effect if the lockless scheme is being used, but could result
+in corrupted buffer contents if the locking scheme is used.
+
+
+Limitations
+===========
+
+Writes made via the write() system call are currently limited to 2
+pages worth of data.  There is no such limit on the in-kernel API
+function relay_write().
+
+User applications can currently only mmap the complete buffer (it
+doesn't really make sense to mmap only part of it, given its purpose).
+
+
+Latest version
+==============
+
+The latest version can be found at:
+
+http://www.opersys.com/relayfs
+
+Example relayfs clients, such as dynamic printk and the Linux Trace
+Toolkit, can also be found there.
+
+
+Credits
+=======
+
+The ideas and specs for relayfs came about as a result of discussions
+on tracing involving the following:
+
+Michel Dagenais                <michel.dagenais@polymtl.ca>
+Richard Moore          <richardj_moore@uk.ibm.com>
+Bob Wisniewski         <bob@watson.ibm.com>
+Karim Yaghmour         <karim@opersys.com>
+Tom Zanussi            <zanussi@us.ibm.com>
+
+Also thanks to Hubertus Franke for a lot of useful suggestions and bug
+reports, and for contributing the klog code.
diff --git a/Documentation/i2c/i2c-pport b/Documentation/i2c/i2c-pport
deleted file mode 100644 (file)
index ce68c67..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-Primitive parallel port is driver for i2c bus, which exploits 
-features of modern bidirectional parallel ports. 
-
-Bidirectional ports have particular bits connected in following way:
-   
-                        |
-            /-----|     R
-         --o|     |-----|
-      read  \-----|     /------- Out pin
-                      |/
-                   - -|\
-                write   V
-                        |
-                       ---  
-
-
-It means when output is set to 1 we can read the port. Therefore 
-we can use 2 pins of parallel port as SDA and SCL for i2c bus. It 
-is not necessary to add any external - additional parts, we can 
-read and write the same port simultaneously.
-       I only use register base+2 so it is possible to use all 
-8 data bits of parallel port for other applications (I have 
-connected EEPROM and LCD display). I do not use bit Enable Bi-directional
- Port. The only disadvantage is we can only support 5V chips.
-
-Layout:
-
-Cannon 25 pin
-
-SDA - connect to pin 14 (Auto Linefeed)
-SCL - connect to pin 16 (Initialize Printer)
-GND - connect to pin 18-25
-+5V - use external supply (I use 5V from 3.5" floppy connector)
-      
-no pullups  requied
-
-Module parameters:
-
-base = 0xXXX
-XXX - 278 or 378
-
-That's all.
-
-Daniel Smolik
-marvin@sitour.cz
diff --git a/Documentation/i2c/i2c-velleman b/Documentation/i2c/i2c-velleman
deleted file mode 100644 (file)
index 04be638..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-i2c-velleman driver
--------------------
-This is a driver for i2c-hw access for Velleman K8000 and other adapters.
-
-Useful links
-------------
-Velleman:
-       http://www.velleman.be/
-
-Velleman K8000 Howto:
-       http://howto.htlw16.ac.at/k8000-howto.html
-
-K8000 and K8005 libraries
--------------------------
-The project has lead to new libs for the Velleman K8000 and K8005:
-LIBK8000 v1.99.1 and LIBK8005 v0.21
-
-With these libs, you can control the K8000 interface card and the K8005
-stepper motor card with the simple commands which are in the original
-Velleman software, like SetIOchannel, ReadADchannel, SendStepCCWFull and
-many more, using /dev/velleman.
-
-The libs can be found on http://groups.yahoo.com/group/k8000/files/linux/
diff --git a/Documentation/powerpc/hvcs.txt b/Documentation/powerpc/hvcs.txt
deleted file mode 100644 (file)
index 111ad15..0000000
+++ /dev/null
@@ -1,534 +0,0 @@
-===========================================================================
-                                  HVCS
-       IBM "Hypervisor Virtual Console Server" Installation Guide
-                         for Linux Kernel 2.6.4+
-                   Copyright (C) 2004 IBM Corporation
-
-===========================================================================
-NOTE:Eight space tabs are the optimum editor setting for reading this file.
-===========================================================================
-
-              Author(s) :  Ryan S. Arnold <rsa@us.ibm.com>
-                      Date Created: March, 02, 2004
-                      Last Changed: July, 07, 2004
-
----------------------------------------------------------------------------
-Table of contents:
-
-       1.  Driver Introduction:
-       2.  System Requirements
-       3.  Build Options:
-               3.1  Built-in:
-               3.2  Module:
-       4.  Installation:
-       5.  Connection:
-       6.  Disconnection:
-       7.  Configuration:
-       8.  Questions & Answers:
-       9.  Reporting Bugs:
-
----------------------------------------------------------------------------
-1. Driver Introduction:
-
-This is the device driver for the IBM Hypervisor Virtual Console Server,
-"hvcs".  The IBM hvcs provides a tty driver interface to allow Linux user
-space applications access to the system consoles of logically partitioned
-operating systems (Linux and AIX) running on the same partitioned Power5
-ppc64 system.  Physical hardware consoles per partition are not practical
-on this hardware so system consoles are accessed by this driver using
-firmware interfaces to virtual terminal devices.
-
----------------------------------------------------------------------------
-2. System Requirements:
-
-This device driver was written using 2.6.4 Linux kernel APIs and will only
-build and run on kernels of this version or later.
-
-This driver was written to operate solely on IBM Power5 ppc64 hardware
-though some care was taken to abstract the architecture dependent firmware
-calls from the driver code.
-
-Sysfs must be mounted on the system so that the user can determine which
-major and minor numbers are associated with each vty-server.  Directions
-for sysfs mounting are outside the scope of this document.
-
----------------------------------------------------------------------------
-3. Build Options:
-
-The hvcs driver registers itself as a tty driver.  The tty layer
-dynamically allocates a block of major and minor numbers in a quantity
-requested by the registering driver.  The hvcs driver asks the tty layer
-for 64 of these major/minor numbers by default to use for hvcs device node
-entries.
-
-If the default number of device entries is adequate then this driver can be
-built into the kernel.  If not, the default can be over-ridden by inserting
-the driver as a module with insmod parameters.
-
----------------------------------------------------------------------------
-3.1 Built-in:
-
-The following menuconfig example demonstrates selecting to build this
-driver into the kernel.
-
-       Device Drivers  --->
-               Character devices  --->
-                       <*> IBM Hypervisor Virtual Console Server Support
-
-Begin the kernel make process.
-
----------------------------------------------------------------------------
-3.2 Module:
-
-The following menuconfig example demonstrates selecting to build this
-driver as a kernel module.
-
-       Device Drivers  --->
-               Character devices  --->
-                       <M> IBM Hypervisor Virtual Console Server Support
-
-The make process will build the following kernel modules:
-
-       hvcs.ko
-       hvcserver.ko
-
-To insert the module with the default allocation execute the following
-commands in the order they appear:
-
-       insmod hvcserver.ko
-       insmod hvcs.ko
-
-The hvcserver module contains architecture specific firmware calls and must
-be inserted first, otherwise the hvcs module will not find some of the
-symbols it expects.
-
-To override the default use an insmod parameter as follows (requesting 4
-tty devices as an example):
-
-       insmod hvcs.ko hvcs_parm_num_devs=4
-
-There is a maximum number of dev entries that can be specified on insmod.
-We think that 1024 is currently a decent maximum number of server adapters
-to allow.  This can always be changed by modifying the constant in the
-source file before building.
-
-NOTE: The length of time it takes to insmod the driver seems to be related
-to the number of tty interfaces the registering driver requests.
-
-In order to remove the driver module execute the following command:
-
-       rmmod hvcs.ko
-
-The recommended method for installing hvcs as a module is to use depmod to
-build a current modules.dep file in /lib/modules/`uname -r` and then
-execute:
-
-modprobe hvcs hvcs_parm_num_devs=4
-
-The modules.dep file indicates that hvcserver.ko needs to be inserted
-before hvcs.ko and modprobe uses this file to smartly insert the modules in
-the proper order.
-
-The following modprobe command is used to remove hvcs and hvcserver in the
-proper order:
-
-modprobe -r hvcs
-
----------------------------------------------------------------------------
-4. Installation:
-
-The tty layer creates sysfs entries which contain the major and minor
-numbers allocated for the hvcs driver.  The following snippet of "tree"
-output of the sysfs directory shows where these numbers are presented:
-
-       sys/
-       |-- *other sysfs base dirs*
-       |
-       |-- class
-       |   |-- *other classes of devices*
-       |   |
-       |   `-- tty
-       |       |-- *other tty devices*
-       |       |
-       |       |-- hvcs0
-       |       |   `-- dev
-       |       |-- hvcs1
-       |       |   `-- dev
-       |       |-- hvcs2
-       |       |   `-- dev
-       |       |-- hvcs3
-       |       |   `-- dev
-       |       |
-       |       |-- *other tty devices*
-       |
-       |-- *other sysfs base dirs*
-
-For the above examples the following output is a result of cat'ing the
-"dev" entry in the hvcs directory:
-
-       Pow5:/sys/class/tty/hvcs0/ # cat dev
-       254:0
-
-       Pow5:/sys/class/tty/hvcs1/ # cat dev
-       254:1
-
-       Pow5:/sys/class/tty/hvcs2/ # cat dev
-       254:2
-
-       Pow5:/sys/class/tty/hvcs3/ # cat dev
-       254:3
-
-The output from reading the "dev" attribute is the char device major and
-minor numbers that the tty layer has allocated for this driver's use.  Most
-systems running hvcs will already have the device entries created or udev
-will do it automatically.
-
-Given the example output above, to manually create a /dev/hvcs* node entry
-mknod can be used as follows:
-
-       mknod /dev/hvcs0 c 254 0
-       mknod /dev/hvcs1 c 254 1
-       mknod /dev/hvcs2 c 254 2
-       mknod /dev/hvcs3 c 254 3
-
-Using mknod to manually create the device entries makes these device nodes
-persistent.  Once created they will exist prior to the driver insmod.
-
-Attempting to connect an application to /dev/hvcs* prior to insertion of
-the hvcs module will result in an error message similar to the following:
-
-       "/dev/hvcs*: No such device".
-
-NOTE: Just because there is a device node present doesn't mean that there
-is a vty-server device configured for that node.
-
----------------------------------------------------------------------------
-5. Connection
-
-Since this driver controls devices that provide a tty interface a user can
-interact with the device node entries using any standard tty-interactive
-method (e.g. "cat", "dd", "echo").  The intent of this driver however, is
-to provide real time console interaction with a Linux partition's console,
-which requires the use of applications that provide bi-directional,
-interactive I/O with a tty device.
-
-Applications (e.g. "minicom" and "screen") that act as terminal emulators
-or perform terminal type control sequence conversion on the data being
-passed through them are NOT acceptable for providing interactive console
-I/O.  These programs often emulate antiquated terminal types (vt100 and
-ANSI) and expect inbound data to take the form of one of these supported
-terminal types but they either do not convert, or do not _adequately_
-convert, outbound data into the terminal type of the terminal which invoked
-them (though screen makes an attempt and can apparently be configured with
-much termcap wrestling.)
-
-For this reason kermit and cu are two of the recommended applications for
-interacting with a Linux console via an hvcs device.  These programs simply
-act as a conduit for data transfer to and from the tty device.  They do not
-require inbound data to take the form of a particular terminal type, nor do
-they cook outbound data to a particular terminal type.
-
-In order to ensure proper functioning of console applications one must make
-sure that once connected to a /dev/hvcs console that the console's $TERM
-env variable is set to the exact terminal type of the terminal emulator
-used to launch the interactive I/O application.  If one is using xterm and
-kermit to connect to /dev/hvcs0 when the console prompt becomes available
-one should "export TERM=xterm" on the console.  This tells ncurses
-applications that are invoked from the console that they should output
-control sequences that xterm can understand.
-
-As a precautionary measure an hvcs user should always "exit" from their
-session before disconnecting an application such as kermit from the device
-node.  If this is not done, the next user to connect to the console will
-continue using the previous user's logged in session which includes
-using the $TERM variable that the previous user supplied.
-
----------------------------------------------------------------------------
-6. Disconnection
-
-As a security feature to prevent the delivery of stale data to an
-unintended target the Power5 system firmware disables the fetching of data
-and discards that data when a connection between a vty-server and a vty has
-been severed.  As an example, when a vty-server is immediately disconnected
-from a vty following output of data to the vty the vty adapter may not have
-enough time between when it received the data interrupt and when the
-connection was severed to fetch the data from firmware before the fetch is
-disabled by firmware.
-
-When hvcs is being used to serve consoles this behavior is not a huge issue
-because the adapter stays connected for large amounts of time following
-almost all data writes.  When hvcs is being used as a tty conduit to tunnel
-data between two partitions [see Q & A below] this is a huge problem
-because the standard Linux behavior when cat'ing or dd'ing data to a device
-is to open the tty, send the data, and then close the tty.  If this driver
-manually terminated vty-server connections on tty close this would close
-the vty-server and vty connection before the target vty has had a chance to
-fetch the data.
-
-Additionally, disconnecting a vty-server and vty only on module removal or
-adapter removal is impractical because other vty-servers in other
-partitions may require the usage of the target vty at any time.
-
-Due to this behavioral restriction disconnection of vty-servers from the
-connected vty is a manual procedure using a write to a sysfs attribute
-outlined below, on the other hand the initial vty-server connection to a
-vty is established automatically by this driver.  Manual vty-server
-connection is never required.
-
-In order to terminate the connection between a vty-server and vty the
-"vterm_state" sysfs attribute within each vty-server's sysfs entry is used.
-Reading this attribute reveals the current connection state of the
-vty-server adapter.  A zero means that the vty-server is not connected to a
-vty.  A one indicates that a connection is active.
-
-Writing a '0' (zero) to the vterm_state attribute will disconnect the VTERM
-connection between the vty-server and target vty ONLY if the vterm_state
-previously read '1'.  The write directive is ignored if the vterm_state
-read '0' or if any value other than '0' was written to the vterm_state
-attribute.  The following example will show the method used for verifying
-the vty-server connection status and disconnecting a vty-server connection.
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # cat vterm_state
-       1
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # echo 0 > vterm_state
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # cat vterm_state
-       0
-
-All vty-server connections are automatically terminated when the device is
-hotplug removed and when the module is removed.
-
----------------------------------------------------------------------------
-7. Configuration
-
-Each vty-server has a sysfs entry in the /sys/devices/vio directory, which
-is symlinked in several other sysfs tree directories, notably under the
-hvcs driver entry, which looks like the following example:
-
-       Pow5:/sys/bus/vio/drivers/hvcs # ls
-       .  ..  30000003  30000004  rescan
-
-By design, firmware notifies the hvcs driver of vty-server lifetimes and
-partner vty removals but not the addition of partner vtys.  Since an HMC
-Super Admin can add partner info dynamically we have provided the hvcs
-driver sysfs directory with the "rescan" update attribute which will query
-firmware and update the partner info for all the vty-servers that this
-driver manages.  Writing a '1' to the attribute triggers the update.  An
-explicit example follows:
-
-       Pow5:/sys/bus/vio/drivers/hvcs # echo 1 > rescan
-
-Reading the attribute will indicate a state of '1' or '0'.  A one indicates
-that an update is in process.  A zero indicates that an update has
-completed or was never executed.
-
-Vty-server entries in this directory are a 32 bit partition unique unit
-address that is created by firmware.  An example vty-server sysfs entry
-looks like the following:
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls
-       .   current_vty   devspec  partner_clcs  vterm_state
-       ..  detach_state  name     partner_vtys
-
-Each entry is provided, by default with a "name" attribute.  Reading the
-"name" attribute will reveal the device type as shown in the following
-example:
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000003 # cat name
-       vty-server
-
-Each entry is also provided, by default, with a "devspec" attribute which
-reveals the full device specification when read, as shown in the following
-example:
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # cat devspec
-       /vdevice/vty-server@30000004
-
-Each vty-server sysfs dir is provided with two read-only attributes that
-provide lists of easily parsed partner vty data: "partner_vtys" and
-"partner_clcs".
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # cat partner_vtys
-       30000000
-       30000001
-       30000002
-       30000000
-       30000000
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # cat partner_clcs
-       U5112.428.103048A-V3-C0
-       U5112.428.103048A-V3-C2
-       U5112.428.103048A-V3-C3
-       U5112.428.103048A-V4-C0
-       U5112.428.103048A-V5-C0
-
-Reading partner_vtys returns a list of partner vtys.  Vty unit address
-numbering is only per-partition-unique so entries will frequently repeat.
-
-Reading partner_clcs returns a list of "converged location codes" which are
-composed of a system serial number followed by "-V*", where the '*' is the
-target partition number, and "-C*", where the '*' is the slot of the
-adapter.  The first vty partner corresponds to the first clc item, the
-second vty partner to the second clc item, etc.
-
-A vty-server can only be connected to a single vty at a time.  The entry,
-"current_vty" prints the clc of the currently selected partner vty when
-read.
-
-The current_vty can be changed by writing a valid partner clc to the entry
-as in the following example:
-
-       Pow5:/sys/bus/vio/drivers/hvcs/30000004 # echo U5112.428.10304
-       8A-V4-C0 > current_vty
-
-Changing the current_vty when a vty-server is already connected to a vty
-does not affect the current connection.  The change takes effect when the
-currently open connection is freed.
-
-Information on the "vterm_state" attribute was covered earlier on the
-chapter entitled "disconnection".
-
----------------------------------------------------------------------------
-8. Questions & Answers:
-===========================================================================
-Q: What are the security concerns involving hvcs?
-
-A: There are three main security concerns:
-
-       1. The creator of the /dev/hvcs* nodes has the ability to restrict
-       the access of the device entries to certain users or groups.  It
-       may be best to create a special hvcs group privilege for providing
-       access to system consoles.
-
-       2. To provide network security when grabbing the console it is
-       suggested that the user connect to the console hosting partition
-       using a secure method, such as SSH or sit at a hardware console.
-
-       3. Make sure to exit the user session when done with a console or
-       the next vty-server connection (which may be from another
-       partition) will experience the previously logged in session.
-
----------------------------------------------------------------------------
-Q: How do I multiplex a console that I grab through hvcs so that other
-people can see it:
-
-A: You can use "screen" to directly connect to the /dev/hvcs* device and
-setup a session on your machine with the console group privileges.  As
-pointed out earlier by default screen doesn't provide the termcap settings
-for most terminal emulators to provide adequate character conversion from
-term type "screen" to others.  This means that curses based programs may
-not display properly in screen sessions.
-
----------------------------------------------------------------------------
-Q: Why are the colors all messed up?
-Q: Why are the control characters acting strange or not working?
-Q: Why is the console output all strange and unintelligible?
-
-A: Please see the preceding section on "Connection" for a discussion of how
-applications can affect the display of character control sequences.
-Additionally, just because you logged into the console using and xterm
-doesn't mean someone else didn't log into the console with the HMC console
-(vt320) before you and leave the session logged in.  The best thing to do
-is to export TERM to the terminal type of your terminal emulator when you
-get the console.  Additionally make sure to "exit" the console before you
-disconnect from the console.  This will ensure that the next user gets
-their own TERM type set when they login.
-
----------------------------------------------------------------------------
-Q: When I try to CONNECT kermit to an hvcs device I get:
-"Sorry, can't open connection: /dev/hvcs*"What is happening?
-
-A: Some other Power5 console mechanism has a connection to the vty and
-isn't giving it up.  You can try to force disconnect the consoles from the
-HMC by right clicking on the partition and then selecting "close terminal".
-Otherwise you have to hunt down the people who have console authority.  It
-is possible that you already have the console open using another kermit
-session and just forgot about it.  Please review the console options for
-Power5 systems to determine the many ways a system console can be held.
-
-OR
-
-A: Another user may not have a connectivity method currently attached to a
-/dev/hvcs device but the vterm_state may reveal that they still have the
-vty-server connection established.  They need to free this using the method
-outlined in the section on "Disconnection" in order for others to connect
-to the target vty.
-
-OR
-
-A: The user profile you are using to execute kermit probably doesn't have
-permissions to use the /dev/hvcs* device.
-
-OR
-
-A: You probably haven't inserted the hvcs.ko module yet but the /dev/hvcs*
-entry still exists (on systems without udev).
-
-OR
-
-A: There is not a corresponding vty-server device that maps to an existing
-/dev/hvcs* entry.
-
----------------------------------------------------------------------------
-Q: When I try to CONNECT kermit to an hvcs device I get:
-"Sorry, write access to UUCP lockfile directory denied."
-
-A: The /dev/hvcs* entry you have specified doesn't exist where you said it
-does?  Maybe you haven't inserted the module (on systems with udev).
-
----------------------------------------------------------------------------
-Q: If I already have one Linux partition installed can I use hvcs on said
-partition to provide the console for the install of a second Linux
-partition?
-
-A: Yes granted that your are connected to the /dev/hvcs* device using
-kermit or cu or some other program that doesn't provide terminal emulation.
-
----------------------------------------------------------------------------
-Q: Can I connect to more than one partition's console at a time using this
-driver?
-
-A: Yes.  Of course this means that there must be more than one vty-server
-configured for this partition and each must point to a disconnected vty.
-
----------------------------------------------------------------------------
-Q: Does the hvcs driver support dynamic (hotplug) addition of devices?
-
-A: Yes, if you have dlpar and hotplug enabled for your system and it has
-been built into the kernel the hvcs drivers is configured to dynamically
-handle additions of new devices and removals of unused devices.
-
----------------------------------------------------------------------------
-Q: Can I use /dev/hvcs* as a conduit to another partition and use a tty
-device on that partition as the other end of the pipe?
-
-A: Yes, on Power5 platforms the hvc_console driver provides a tty interface
-for extra /dev/hvc* devices (where /dev/hvc0 is most likely the console).
-In order to get a tty conduit working between the two partitions the HMC
-Super Admin must create an additional "serial server" for the target
-partition with the HMC gui which will show up as /dev/hvc* when the target
-partition is rebooted.
-
-The HMC Super Admin then creates an additional "serial client" for the
-current partition and points this at the target partition's newly created
-"serial server" adapter (remember the slot).  This shows up as an
-additional /dev/hvcs* device.
-
-Now a program on the target system can be configured to read or write to
-/dev/hvc* and another program on the current partition can be configured to
-read or write to /dev/hvcs*.  Now you have a tty conduit between two
-partitions.
-
----------------------------------------------------------------------------
-9. Reporting Bugs:
-
-The proper channel for reporting bugs is either through the Linux OS
-distribution company that provided your OS or by posting issues to the
-ppc64 development mailing list at:
-
-linuxppc64-dev@lists.linuxppc.org
-
-This request is to provide a documented and searchable public exchange
-of the problems and solutions surrounding this driver for the benefit of
-all users.
diff --git a/Documentation/powerpc/mpc52xx.txt b/Documentation/powerpc/mpc52xx.txt
deleted file mode 100644 (file)
index 6efe0a0..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-Linux 2.6.x on MPC52xx family
------------------------------
-
-For the latest info, go to http://www.246tNt.com/mpc52xx/state.txt
-To compile/use :
-
-  - U-Boot:
-     # <edit Makefile to set ARCH=ppc & CROSS_COMPILE=... ( also EXTRAVERSION
-        if you wish to ).
-     # make lite5200_defconfig
-     # make uImage
-    
-     then, on U-boot:
-     => tftpboot 200000 uImage
-     => tftpboot 400000 pRamdisk
-     => bootm 200000 400000
-    
-  - DBug:
-     # <edit Makefile to set ARCH=ppc & CROSS_COMPILE=... ( also EXTRAVERSION
-        if you wish to ).
-     # make lite5200_defconfig
-     # cp your_initrd.gz arch/ppc/boot/images/ramdisk.image.gz
-     # make zImage.initrd 
-     # make 
-
-     then in DBug:
-     DBug> dn -i zImage.initrd.lite5200
-     
-
-Some remarks :
- - The port is named mpc52xxx, and config options are PPC_MPC52xx. The MGT5100
-   is not supported, and I'm not sure anyone is interesting in working on it
-   so. I didn't took 5xxx because there's apparently a lot of 5xxx that have
-   nothing to do with the MPC5200. I also included the 'MPC' for the same
-   reason.
- - Of course, I inspired myself from the 2.4 port. If you think I forgot to
-   mention you/your company in the copyright of some code, I'll correct it
-   ASAP.
- - The codes wants the MBAR to be set at 0xf0000000 by the bootloader. It's
-   mapped 1:1 with the MMU. If for whatever reason, you want to change this,
-   beware that some code depends on the 0xf0000000 address and other depends
-   on the 1:1 mapping.
- - Most of the code assumes that port multiplexing, frequency selection, ...
-   has already been done. IMHO this should be done as early as possible, in
-   the bootloader. If for whatever reason you can't do it there, do it in the
-   platform setup code (if U-Boot) or in the arch/ppc/boot/simple/... (if
-   DBug)
index 63581ae..d298eaf 100644 (file)
@@ -53,6 +53,10 @@ On all -  write a character to /proc/sysrq-trigger.  eg:
 'b'     - Will immediately reboot the system without syncing or unmounting
           your disks.
 
+'c'     - Intentionally crash the system without syncing or unmounting
+          your disks.  This is most useful if the NETDUMP client package
+          has been installed.
+
 'o'     - Will shut your system off (if configured and supported).
 
 's'     - Will attempt to sync all mounted filesystems.
@@ -101,6 +105,10 @@ useful when you want to exit a program that will not let you switch consoles.
 re'B'oot is good when you're unable to shut down. But you should also 'S'ync
 and 'U'mount first.
 
+'C'rash immediately crashes your system.  This is most useful if the machine
+has been configured as a NETDUMP client because an OOPS report is generated
+and a kernel crash dump is sent to the NETDUMP server.
+
 'S'ync is great when your system is locked up, it allows you to sync your
 disks and will certainly lessen the chance of data loss and fscking. Note
 that the sync hasn't taken place until you see the "OK" and "Done" appear
index 47a7121..61ae09f 100644 (file)
@@ -91,12 +91,9 @@ A regular chown, chgrp and chmod commands (with right permissions) could be
 used to change the file attributes on hugetlbfs.
 
 Also, it is important to note that no such mount command is required if the
-applications are going to use only shmat/shmget system calls.  Users who
-wish to use hugetlb page via shared memory segment should be a member of
-a supplementary group and system admin needs to configure that gid into
-/proc/sys/vm/hugetlb_shm_group.  It is possible for same or different
-applications to use any combination of mmaps and shm* calls.  Though the
-mount of filesystem will be required for using mmaps.
+applications are going to use only shmat/shmget system calls.  It is possible
+for same or different applications to use any combination of mmaps and shm*
+calls.  Though the mount of filesystem will be required for using mmaps.
 
 /* Example of using hugepage in user application using Sys V shared memory
  * system calls.  In this example, app is requesting memory of size 256MB that
diff --git a/Documentation/vserver/debug.txt b/Documentation/vserver/debug.txt
new file mode 100644 (file)
index 0000000..38be457
--- /dev/null
@@ -0,0 +1,170 @@
+
+debug_switch:
+
+ 0   1 
+
+ 1   2 
+
+ 2   4 
+
+ 3   8 
+
+ 4  16 
+
+ 5  32 
+
+ 6  64 
+
+ 7 128 
+
+
+debug_xid:
+
+ 0   1 "alloc_vx_info(%d) = %p\n"
+       "dealloc_vx_info(%p)"
+       "loc_vx_info(%d) = %p (not available)"
+       "loc_vx_info(%d) = %p (found)"
+       "loc_vx_info(%d) = %p (new)"
+
+ 1   2 "alloc_vx_info(%d)*"
+       "loc_vx_info(%d)*"
+       "locate_vx_info(%d)"
+               
+ 2   4 "get_vx_info(%p[#%d.%d])"
+       "put_vx_info(%p[#%d.%d])"
+       
+ 3   8 "set_vx_info(%p[#%d.%d.%d])"
+       "clr_vx_info(%p[#%d.%d.%d])"
+       "rcu_free_vx_info(%p): uc=%d"
+
+ 4  16 "__hash_vx_info: %p[#%d]"
+       "__unhash_vx_info: %p[#%d]"
+       "__vx_dynamic_id: [#%d]"
+
+ 5  32 "vx_migrate_task(%p,%p[#%d.%d])"
+       "task_get_vx_info(%p)"
+
+ 6  64 
+
+ 7 128 
+
+
+debug_nid:
+
+ 0   1 "alloc_nx_info() = %p"
+       "dealloc_nx_info(%p)"
+       "loc_nx_info(%d) = %p (not available)"
+       "loc_nx_info(%d) = %p (found)"
+       "loc_nx_info(%d) = %p (new)"
+
+ 1   2 "alloc_nx_info(%d)*"
+       "loc_nx_info(%d)*"
+               
+ 2   4 "get_nx_info(%p[#%d.%d])"
+       "put_nx_info(%p[#%d.%d])"
+       
+ 3   8 "set_nx_info(%p[#%d.%d.%d])"
+       "clr_nx_info(%p[#%d.%d.%d])"
+       "rcu_free_nx_info(%p): uc=%d"
+
+ 4  16 "__hash_nx_info: %p[#%d]"
+       "__unhash_nx_info: %p[#%d]"
+       "__nx_dynamic_id: [#%d]"
+
+ 5  32 "nx_migrate_task(%p,%p[#%d.%d])"
+       "task_get_nx_info(%p)"
+       "create_nx_info()"
+
+ 6  64 
+
+ 7 128 
+
+
+debug_dlim:
+
+ 0   1 "alloc_dl_info(%p,%d) = %p"
+       "dealloc_dl_info(%p)"
+       "locate_dl_info(%p,#%d) = %p"
+
+ 1   2 "alloc_dl_info(%p,%d)*"
+
+ 2   4 "get_dl_info(%p[#%d.%d])"
+       "put_dl_info(%p[#%d.%d])"
+       
+ 3   8 "rcu_free_dl_info(%p)"
+       "__hash_dl_info: %p[#%d]"
+       "__unhash_dl_info: %p[#%d]"
+       
+
+ 4  16 "ALLOC (%p,#%d)%c inode (%d)"
+       "FREE  (%p,#%d)%c inode"
+
+ 5  32 "ALLOC (%p,#%d)%c %lld bytes (%d)"
+       "FREE  (%p,#%d)%c %lld bytes"
+
+ 6  64 "ADJUST: %lld,%lld on %d,%d [mult=%d]"
+
+ 7 128 "ext3_has_free_blocks(%p): free=%u, root=%u"
+       "ext3_has_free_blocks(%p): %u<%u+1, %c, %u!=%u r=%d"
+
+
+
+debug_cvirt:
+
+
+ 0   1 
+
+ 1   2 
+
+ 2   4 "vx_map_tgid: %p/%llx: %d -> %d"
+       "vx_rmap_tgid: %p/%llx: %d -> %d"
+       
+ 3   8 
+
+ 4  16 
+
+ 5  32 
+
+ 6  64 
+
+ 7 128 
+       
+       
+       
+debug_net:
+
+
+ 0   1 
+
+ 1   2 
+
+ 2   4 "tcp_in_list(%p) %p,%p;%lx"
+       
+ 3   8 "inet_bind(%p) %p,%p;%lx"
+
+ 4  16 "ip_route_connect(%p) %p,%p;%lx"
+
+ 5  32 "tcp_ipv4_addr_conflict(%p,%p) %p,%p;%lx %p,%p;%lx"
+
+ 6  64 "sk: %p [#%d] (from %d)"
+       "sk,req: %p [#%d] (from %d)"
+       "sk,egf: %p [#%d] (from %d)"
+       "sk,egn: %p [#%d] (from %d)"
+       "tw: %p [#%d] (from %d)"
+
+ 7 128 "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
+       "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
+
+
+
+
+debug_limit:
+
+ n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
+       "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
+       
+ m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
+       "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
+       "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
+       
+       
index 86d8af5..bb1bbb3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 8
-EXTRAVERSION = .1
+EXTRAVERSION = -1.521.2.planetlab
 NAME=Zonked Quokka
 
 # *DOCUMENTATION*
index e1f20ca..d770bb8 100644 (file)
@@ -692,6 +692,8 @@ config DEBUG_INFO
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index aa654cc..5d9aae6 100644 (file)
@@ -287,6 +287,8 @@ do_sys_ptrace(long request, long pid, long addr, long data,
        read_unlock(&tasklist_lock);
        if (!child)
                goto out_notsk;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out;
 
        if (request == PTRACE_ATTACH) {
                ret = ptrace_attach(child);
index 7caf209..57052d8 100644 (file)
@@ -240,7 +240,15 @@ sys_call_table:
        .quad alpha_ni_syscall
        .quad alpha_ni_syscall                  /* 220 */
        .quad alpha_ni_syscall
+#ifdef CONFIG_TUX
+       .quad __sys_tux
+#else
+# ifdef CONFIG_TUX_MODULE
+       .quad sys_tux
+# else
        .quad alpha_ni_syscall
+# endif
+#endif
        .quad alpha_ni_syscall
        .quad alpha_ni_syscall
        .quad alpha_ni_syscall                  /* 225 */
@@ -291,7 +299,7 @@ sys_call_table:
        .quad alpha_ni_syscall                  /* 270 */
        .quad alpha_ni_syscall
        .quad alpha_ni_syscall
-       .quad alpha_ni_syscall
+       .quad sys_vserver                       /* 273 sys_vserver */
        .quad alpha_ni_syscall
        .quad alpha_ni_syscall                  /* 275 */
        .quad alpha_ni_syscall
index 43adecf..e4435a4 100644 (file)
@@ -821,6 +821,8 @@ config DEBUG_S3C2410_UART
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
diff --git a/arch/arm/boot/compressed/head-ftvpci.S b/arch/arm/boot/compressed/head-ftvpci.S
deleted file mode 100644 (file)
index aa272a3..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* 
- * linux/arch/arm/boot/compressed/head-ftvpci.S
- * 
- * Copyright (C) 2000 FutureTV Labs Ltd.
- * 
- * Special startup code for FTV PCI board.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-       .section        ".start", "ax"
-ftv_start:
-       mcr     p15, 0, r0, c7, c5, 0           @ flush I cache
-       mrc     p15, 0, r0, c1, c0
-       orr     r0, r0, #1 << 12
-       mcr     p15, 0, r0, c1, c0              @ enable I cache
-       mov     r0, #0
-       mcreq   p15, 0, r0, c15, c1, 2          @ enable clock switching
-
-       /* check to see if the kernel must be relocated */
-       ldr     ip, =ftv_start
-       adr     sl, ftv_start
-       teq     ip, sl
-       beq     2f                              @ no need to copy
-
-       /* in the wrong place -> presumably, executing out of ROM */
-       sub     ip, ip, sl                      @ displacement
-       ldr     lr, =_start                     @ destination
-       sub     sp, lr, ip                      @ source
-       ldr     fp, =_edata                     @ end of copied area
-1:     ldmia   sp!, {r0, r1, r2, r3, r4, r5, r6, r10}
-       stmia   lr!, {r0, r1, r2, r3, r4, r5, r6, r10}
-       cmp     lr, fp
-       ble     1b
-
-2:
-       mov     r8, #0
-       mov     r7, #3
-       b       1f
-.ltorg
-1:
-       /* fall back into head.S */
diff --git a/arch/arm/common/platform.c b/arch/arm/common/platform.c
deleted file mode 100644 (file)
index 441f321..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <linux/ioport.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-int __init platform_add_device(struct platform_device *dev)
-{
-       int i;
-
-       for (i = 0; i < dev->num_resources; i++) {
-               struct resource *r = &dev->resource[i];
-
-               r->name = dev->dev.bus_id;
-
-               if (r->flags & IORESOURCE_MEM &&
-                   request_resource(&iomem_resource, r)) {
-                       printk(KERN_ERR
-                              "%s%d: failed to claim resource %d\n",
-                              dev->name, dev->id, i);
-                       break;
-               }
-       }
-       if (i == dev->num_resources)
-               platform_device_register(dev);
-       return 0;
-}
-
-int __init platform_add_devices(struct platform_device **devs, int num)
-{
-       int i;
-
-       for (i = 0; i < num; i++)
-               platform_add_device(devs[i]);
-
-       return 0;
-}
diff --git a/arch/arm/common/plx90x0.c b/arch/arm/common/plx90x0.c
deleted file mode 100644 (file)
index 60d7d35..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/* 
- * Driver for PLX Technology PCI9000-series host bridge.
- *
- * Copyright (C) 1997, 1998, 1999, 2000 FutureTV Labs Ltd
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/ptrace.h>
-#include <asm/irq.h>
-#include <asm/mach/pci.h>
-
-/*
- * Since the following functions are all very similar, the common parts
- * are pulled out into these macros.
- */
-
-#define PLX_CLEAR_CONFIG                                               \
-       __raw_writel(0, PLX_BASE + 0xac);                               \
-       local_irq_restore(flags); }
-
-#define PLX_SET_CONFIG                                                 \
-       { unsigned long flags;                                          \
-       local_irq_save(flags);                                          \
-       __raw_writel((1<<31 | (bus->number << 16)                       \
-               | (devfn << 8) | (where & ~3)                           \
-               | ((bus->number == 0)?0:1)), PLX_BASE + 0xac);          \
-
-#define PLX_CONFIG_WRITE(size)                                         \
-       PLX_SET_CONFIG                                                  \
-       __raw_write##size(value, PCIO_BASE + (where & 3));              \
-       if (__raw_readw(PLX_BASE + 0x6) & 0x2000)                       \
-               __raw_writew(0x2000, PLX_BASE + 0x6);                   \
-       PLX_CLEAR_CONFIG                                                \
-       return PCIBIOS_SUCCESSFUL;
-
-#define PLX_CONFIG_READ(size)                                          \
-       PLX_SET_CONFIG                                                  \
-       *value = __raw_read##size(PCIO_BASE + (where & 3));             \
-       if (__raw_readw(PLX_BASE + 0x6) & 0x2000) {                     \
-               __raw_writew(0x2000, PLX_BASE + 0x6);                   \
-               *value = 0xffffffffUL;                                  \
-       }                                                               \
-       PLX_CLEAR_CONFIG                                                \
-       return PCIBIOS_SUCCESSFUL;
-
-/* Configuration space access routines */
-
-static int 
-plx90x0_read_config (struct pci_bus *bus, unsigned int devfn, int where,
-                    int where, int size, u32 *value)
-{
-       switch (size) {
-       case 1:
-               PLX_CONFIG_READ(b)
-               break;
-       case 2:
-               PLX_CONFIG_READ(w)
-               break;
-       case 4:
-               PLX_CONFIG_READ(l)
-               break;
-       }
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static int 
-plx90x0_write_config (struct pci_bus *bus, unsigned int devfn, int where,
-                     int where, int size, u32 value)
-{
-       switch (size) {
-       case 1:
-               PLX_CONFIG_WRITE(b)
-               break;
-       case 2:
-               PLX_CONFIG_WRITE(w)
-               break;
-       case 4:
-               PLX_CONFIG_WRITE(l)
-               break;
-       }
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops plx90x0_ops = 
-{
-       .read   = plx90x0_read_config,
-       .write  = plx90x0_write_config,
-};
-
-static void 
-plx_syserr_handler(int irq, void *handle, struct pt_regs *regs)
-{
-       printk("PLX90x0: machine check %04x (pc=%08lx)\n", 
-              readw(PLX_BASE + 6), regs->ARM_pc);
-       __raw_writew(0xf000, PLX_BASE + 6);
-}
-
-/*
- * Initialise the PCI system.
- */
-
-void __init
-plx90x0_init(struct arm_sysdata *sysdata)
-{
-       static const unsigned long int base = PLX_BASE;
-       char *what;
-       unsigned long bar = (unsigned long)virt_to_bus((void *)PAGE_OFFSET);
-
-       /* Have a sniff around and see which PLX device is present. */
-       unsigned long id = __raw_readl(base + 0xf0);
-       
-#if 0
-       /* This check was a good idea, but can fail.  The PLX9060 puts no
-          default value in these registers unless NB# is asserted (which it
-          isn't on these cards).  */
-       if ((id & 0xffff) != PCI_VENDOR_ID_PLX)
-               return;         /* Nothing found */
-#endif
-
-       /* Found one - now work out what it is. */
-       switch (id >> 16) {
-       case 0:         /* PCI_DEVICE_ID_PLX_9060 */
-               what = "PCI9060";
-               break;
-       case PCI_DEVICE_ID_PLX_9060ES:
-               what = "PCI9060ES";
-               break;
-       case PCI_DEVICE_ID_PLX_9060SD:
-               what = "PCI9060SD";             /* uhuhh.. */
-               break;
-       case PCI_DEVICE_ID_PLX_9080:
-               what = "PCI9080";
-               break;
-       default:
-               printk("PCI: Unknown PLX device %04lx found -- ignored.\n",
-                      id >> 16);
-               return;
-       }
-       
-       printk("PCI: PLX Technology %s host bridge found.\n", what);
-       
-       /* Now set it up for both master and slave accesses. */
-       __raw_writel(0xffff0147,        base + 0x4);
-       __raw_writeb(32,                base + 0xd);
-       __raw_writel(0x8 | bar,         base + 0x18);
-       __raw_writel(0xf8000008,        base + 0x80);
-       __raw_writel(0x40000001,        base + 0x84);
-       __raw_writel(0,                 base + 0x88);
-       __raw_writel(0,                 base + 0x8c);
-       __raw_writel(0x11,              base + 0x94);
-       __raw_writel(0xC3 + (4 << 28)
-               + (8 << 11) + (1 << 10)
-                    + (1 << 24),       base + 0x98);
-       __raw_writel(0xC0000000,        base + 0x9c);
-       __raw_writel(PLX_MEM_START,     base + 0xa0);
-       __raw_writel(PLX_IO_START,      base + 0xa4);
-       __raw_writel(0x3,               base + 0xa8);
-       __raw_writel(0,                 base + 0xac);
-       __raw_writel(0x10001,           base + 0xe8);
-       __raw_writel(0x8000767e,        base + 0xec);
-       
-       request_irq(IRQ_SYSERR, plx_syserr_handler, 0, 
-                   "system error", NULL);
-
-       pci_scan_bus(0, &plx90x0_ops, sysdata);
-}
diff --git a/arch/arm/configs/adi_evb_defconfig b/arch/arm/configs/adi_evb_defconfig
deleted file mode 100644 (file)
index bae4866..0000000
+++ /dev/null
@@ -1,678 +0,0 @@
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_GENERIC_BUST_SPINLOCK is not set
-# CONFIG_GENERIC_ISA_DMA is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-CONFIG_ARCH_ADIFCC=y
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP310 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_H3600 is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_CDB89712 is not set
-# CONFIG_ARCH_CLEP7312 is not set
-# CONFIG_ARCH_EDB7211 is not set
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_EP7211 is not set
-# CONFIG_ARCH_EP7212 is not set
-CONFIG_ARCH_ADI_EVB=y
-CONFIG_XSCALE_PMU_TIMER=y
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-# CONFIG_CPU_32v4 is not set
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM926T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-# CONFIG_CPU_SA1100 is not set
-CONFIG_CPU_32v4=y
-CONFIG_CPU_XSCALE=y
-CONFIG_ARM_THUMB=y
-# CONFIG_XSCALE_TOOLS is not set
-CONFIG_XSCALE_WRITE_ALLOC=y
-CONFIG_XSCALE_PMU=y
-CONFIG_ARM_THUMB=y
-# CONFIG_DISCONTIGMEM is not set
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock1 mem=32M initrd=0xc0800000,3M"
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_BOOTLDR_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_JEDEC is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_CDB89712 is not set
-# CONFIG_MTD_SA1100 is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-CONFIG_MTD_ADI_EVB=y
-# CONFIG_MTD_PCI is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP is not set
-# CONFIG_PNPBIOS is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_CISS_SCSI_TAPE is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_MD_LINEAR is not set
-# CONFIG_MD_RAID0 is not set
-# CONFIG_MD_RAID1 is not set
-# CONFIG_MD_RAID5 is not set
-# CONFIG_MD_MULTIPATH is not set
-# CONFIG_BLK_DEV_LVM is not set
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-CONFIG_NETLINK=y
-CONFIG_RTNETLINK=y
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
-CONFIG_UNIX=y
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_IPV6 is not set
-# CONFIG_KHTTPD is not set
-# CONFIG_ATM is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_LLC is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_ARM_AM79C961A is not set
-# CONFIG_SUNLANCE is not set
-# CONFIG_SUNBMAC is not set
-# CONFIG_SUNQE is not set
-# CONFIG_SUNLANCE is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_LANCE is not set
-# CONFIG_NET_VENDOR_SMC is not set
-# CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_NET_ISA is not set
-# CONFIG_NET_PCI is not set
-# CONFIG_NET_POCKET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_MYRI_SBUS is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PLIP is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_NET_FC is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-# CONFIG_INPUT_KEYBDEV is not set
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-CONFIG_SERIAL=y
-CONFIG_SERIAL_CONSOLE=y
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_UART00 is not set
-# CONFIG_SERIAL_UART00_CONSOLE is not set
-# CONFIG_SERIAL_SA1100 is not set
-# CONFIG_SERIAL_SA1100_CONSOLE is not set
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-# CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-# CONFIG_SERIAL_8250_SHARE_IRQ is not set
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_HUB6 is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# L3 serial bus support
-#
-# CONFIG_L3 is not set
-# CONFIG_L3_ALGOBIT is not set
-# CONFIG_L3_BIT_SA1100_GPIO is not set
-# CONFIG_L3_SA1111 is not set
-# CONFIG_BIT_SA1100_GPIO is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-CONFIG_MOUSE=y
-CONFIG_PSMOUSE=y
-# CONFIG_82C710_MOUSE is not set
-# CONFIG_PC110_PAD is not set
-
-#
-# Joysticks
-#
-# CONFIG_INPUT_GAMEPORT is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_INTEL_RNG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# File systems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_ADFS_FS_RW is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_CMS_FS is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_JBD_DEBUG is not set
-# CONFIG_FAT_FS is not set
-# CONFIG_MSDOS_FS is not set
-# CONFIG_UMSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_CRAMFS is not set
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_FREEVXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_QNX4FS_RW is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
-# CONFIG_SYSV_FS is not set
-# CONFIG_UDF_FS is not set
-# CONFIG_UDF_RW is not set
-# CONFIG_UFS_FS is not set
-# CONFIG_UFS_FS_WRITE is not set
-
-#
-# Network File Systems
-#
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_NFS_FS is not set
-# CONFIG_NFS_V3 is not set
-# CONFIG_ROOT_NFS is not set
-# CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-# CONFIG_SUNRPC is not set
-# CONFIG_LOCKD is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_NCPFS_PACKET_SIGNING is not set
-# CONFIG_NCPFS_IOCTL_LOCKING is not set
-# CONFIG_NCPFS_STRONG is not set
-# CONFIG_NCPFS_NFS_NS is not set
-# CONFIG_NCPFS_OS2_NS is not set
-# CONFIG_NCPFS_SMALLDOS is not set
-# CONFIG_NCPFS_NLS is not set
-# CONFIG_NCPFS_EXTRAS is not set
-# CONFIG_ZISOFS_FS is not set
-# CONFIG_ZLIB_FS_INFLATE is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_SMB_NLS is not set
-# CONFIG_NLS is not set
-
-#
-# Multimedia Capabilities Port drivers
-#
-# CONFIG_MCP is not set
-# CONFIG_MCP_SA1100 is not set
-# CONFIG_MCP_UCB1200 is not set
-# CONFIG_MCP_UCB1200_AUDIO is not set
-# CONFIG_MCP_UCB1200_TS is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-# CONFIG_USB_OHCI is not set
-# CONFIG_USB_OHCI_SA1111 is not set
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_STORAGE_DEBUG is not set
-# CONFIG_USB_STORAGE_DATAFAB is not set
-# CONFIG_USB_STORAGE_FREECOM is not set
-# CONFIG_USB_STORAGE_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
-# CONFIG_USB_STORAGE_HP8200e is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-# CONFIG_USB_DC2XX is not set
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_SCANNER is not set
-# CONFIG_USB_MICROTEK is not set
-# CONFIG_USB_HPUSBSCSI is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_CDCETHER is not set
-# CONFIG_USB_USBNET is not set
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-# CONFIG_USB_SERIAL_GENERIC is not set
-# CONFIG_USB_SERIAL_BELKIN is not set
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
-# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
-# CONFIG_USB_SERIAL_EMPEG is not set
-# CONFIG_USB_SERIAL_FTDI_SIO is not set
-# CONFIG_USB_SERIAL_VISOR is not set
-# CONFIG_USB_SERIAL_IR is not set
-# CONFIG_USB_SERIAL_EDGEPORT is not set
-# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
-# CONFIG_USB_SERIAL_KEYSPAN is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XA is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XB is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
-# CONFIG_USB_SERIAL_MCT_U232 is not set
-# CONFIG_USB_SERIAL_PL2303 is not set
-# CONFIG_USB_SERIAL_CYBERJACK is not set
-# CONFIG_USB_SERIAL_XIRCOM is not set
-# CONFIG_USB_SERIAL_OMNINET is not set
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_ID75 is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_DEBUG_SLAB=y
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
diff --git a/arch/arm/configs/ixp4xx_defconfig b/arch/arm/configs/ixp4xx_defconfig
deleted file mode 100644 (file)
index 1933c70..0000000
+++ /dev/null
@@ -1,1080 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-CONFIG_BSD_PROCESS_ACCT=y
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODULE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# System Type
-#
-# CONFIG_ARCH_ADIFCC is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP3XX is not set
-CONFIG_ARCH_IXP4XX=y
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_SHARK is not set
-# CONFIG_ARCH_S3C2410 is not set
-# CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_LH7A40X is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-
-#
-# Epxa10db
-#
-
-#
-# Footbridge Implementations
-#
-
-#
-# IOP3xx Implementation Options
-#
-# CONFIG_ARCH_IOP310 is not set
-# CONFIG_ARCH_IOP321 is not set
-
-#
-# IOP3xx Chipset Features
-#
-CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
-
-#
-# Intel IXP4xx Implementation Options
-#
-
-#
-# IXP4xx Platforms
-#
-CONFIG_ARCH_IXDP425=y
-CONFIG_ARCH_IXCDP1100=y
-CONFIG_ARCH_PRPMC1100=y
-CONFIG_ARCH_ADI_COYOTE=y
-# CONFIG_ARCH_AVILA is not set
-CONFIG_ARCH_IXDP4XX=y
-
-#
-# IXP4xx Options
-#
-# CONFIG_IXP4XX_INDIRECT_PCI is not set
-
-#
-# Intel PXA250/210 Implementations
-#
-
-#
-# SA11x0 Implementations
-#
-
-#
-# TI OMAP Implementations
-#
-
-#
-# OMAP Core Type
-#
-
-#
-# OMAP Board Type
-#
-
-#
-# OMAP Feature Selections
-#
-
-#
-# S3C2410 Implementations
-#
-
-#
-# LH7A40X Implementations
-#
-CONFIG_DMABOUNCE=y
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_XSCALE=y
-CONFIG_CPU_32v5=y
-CONFIG_CPU_ABRT_EV5T=y
-CONFIG_CPU_TLB_V4WBI=y
-CONFIG_CPU_MINICACHE=y
-
-#
-# Processor Features
-#
-# CONFIG_ARM_THUMB is not set
-CONFIG_CPU_BIG_ENDIAN=y
-CONFIG_XSCALE_PMU=y
-
-#
-# General setup
-#
-CONFIG_PCI=y
-# CONFIG_ZBOOT_ROM is not set
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
-
-#
-# At least one math emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_NWFPE_XP is not set
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_AOUT is not set
-# CONFIG_BINFMT_MISC is not set
-
-#
-# Generic Driver Options
-#
-# CONFIG_DEBUG_DRIVER is not set
-CONFIG_PM=y
-# CONFIG_PREEMPT is not set
-CONFIG_APM=y
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="console=ttyS0,115200 ip=bootp root=/dev/nfs"
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_CMDLINE_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-CONFIG_MTD_COMPLEX_MAPPINGS=y
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-CONFIG_MTD_IXP4XX=y
-# CONFIG_MTD_EDB7312 is not set
-# CONFIG_MTD_PCI is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-CONFIG_MTD_NAND=m
-# CONFIG_MTD_NAND_VERIFY_WRITE is not set
-CONFIG_MTD_NAND_IDS=m
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=m
-CONFIG_PACKET_MMAP=y
-CONFIG_NETLINK_DEV=m
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-CONFIG_IP_ADVANCED_ROUTER=y
-CONFIG_IP_MULTIPLE_TABLES=y
-CONFIG_IP_ROUTE_FWMARK=y
-CONFIG_IP_ROUTE_NAT=y
-CONFIG_IP_ROUTE_MULTIPATH=y
-CONFIG_IP_ROUTE_TOS=y
-CONFIG_IP_ROUTE_VERBOSE=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-CONFIG_NET_IPIP=m
-CONFIG_NET_IPGRE=m
-CONFIG_NET_IPGRE_BROADCAST=y
-CONFIG_IP_MROUTE=y
-CONFIG_IP_PIMSM_V1=y
-CONFIG_IP_PIMSM_V2=y
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Virtual Server Configuration
-#
-CONFIG_IP_VS=m
-CONFIG_IP_VS_DEBUG=y
-CONFIG_IP_VS_TAB_BITS=12
-
-#
-# IPVS transport protocol load balancing support
-#
-# CONFIG_IP_VS_PROTO_TCP is not set
-# CONFIG_IP_VS_PROTO_UDP is not set
-# CONFIG_IP_VS_PROTO_ESP is not set
-# CONFIG_IP_VS_PROTO_AH is not set
-
-#
-# IPVS scheduler
-#
-CONFIG_IP_VS_RR=m
-CONFIG_IP_VS_WRR=m
-CONFIG_IP_VS_LC=m
-CONFIG_IP_VS_WLC=m
-CONFIG_IP_VS_LBLC=m
-CONFIG_IP_VS_LBLCR=m
-CONFIG_IP_VS_DH=m
-CONFIG_IP_VS_SH=m
-# CONFIG_IP_VS_SED is not set
-# CONFIG_IP_VS_NQ is not set
-
-#
-# IPVS application helper
-#
-# CONFIG_IPV6 is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-CONFIG_BRIDGE_NETFILTER=y
-
-#
-# IP: Netfilter Configuration
-#
-CONFIG_IP_NF_CONNTRACK=m
-CONFIG_IP_NF_FTP=m
-CONFIG_IP_NF_IRC=m
-# CONFIG_IP_NF_TFTP is not set
-# CONFIG_IP_NF_AMANDA is not set
-CONFIG_IP_NF_QUEUE=m
-CONFIG_IP_NF_IPTABLES=m
-CONFIG_IP_NF_MATCH_LIMIT=m
-# CONFIG_IP_NF_MATCH_IPRANGE is not set
-CONFIG_IP_NF_MATCH_MAC=m
-# CONFIG_IP_NF_MATCH_PKTTYPE is not set
-CONFIG_IP_NF_MATCH_MARK=m
-CONFIG_IP_NF_MATCH_MULTIPORT=m
-CONFIG_IP_NF_MATCH_TOS=m
-# CONFIG_IP_NF_MATCH_RECENT is not set
-# CONFIG_IP_NF_MATCH_ECN is not set
-# CONFIG_IP_NF_MATCH_DSCP is not set
-CONFIG_IP_NF_MATCH_AH_ESP=m
-CONFIG_IP_NF_MATCH_LENGTH=m
-CONFIG_IP_NF_MATCH_TTL=m
-CONFIG_IP_NF_MATCH_TCPMSS=m
-# CONFIG_IP_NF_MATCH_HELPER is not set
-CONFIG_IP_NF_MATCH_STATE=m
-# CONFIG_IP_NF_MATCH_CONNTRACK is not set
-CONFIG_IP_NF_MATCH_OWNER=m
-# CONFIG_IP_NF_MATCH_PHYSDEV is not set
-CONFIG_IP_NF_FILTER=m
-CONFIG_IP_NF_TARGET_REJECT=m
-CONFIG_IP_NF_NAT=m
-CONFIG_IP_NF_NAT_NEEDED=y
-CONFIG_IP_NF_TARGET_MASQUERADE=m
-CONFIG_IP_NF_TARGET_REDIRECT=m
-# CONFIG_IP_NF_TARGET_NETMAP is not set
-# CONFIG_IP_NF_TARGET_SAME is not set
-CONFIG_IP_NF_NAT_LOCAL=y
-CONFIG_IP_NF_NAT_SNMP_BASIC=m
-CONFIG_IP_NF_NAT_IRC=m
-CONFIG_IP_NF_NAT_FTP=m
-CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_TOS=m
-# CONFIG_IP_NF_TARGET_ECN is not set
-# CONFIG_IP_NF_TARGET_DSCP is not set
-CONFIG_IP_NF_TARGET_MARK=m
-# CONFIG_IP_NF_TARGET_CLASSIFY is not set
-CONFIG_IP_NF_TARGET_LOG=m
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=m
-CONFIG_IP_NF_ARPTABLES=m
-CONFIG_IP_NF_ARPFILTER=m
-# CONFIG_IP_NF_ARP_MANGLE is not set
-CONFIG_IP_NF_COMPAT_IPCHAINS=m
-CONFIG_IP_NF_COMPAT_IPFWADM=m
-# CONFIG_IP_NF_RAW is not set
-
-#
-# Bridge: Netfilter Configuration
-#
-# CONFIG_BRIDGE_NF_EBTABLES is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-CONFIG_ATM=y
-CONFIG_ATM_CLIP=y
-# CONFIG_ATM_CLIP_NO_ICMP is not set
-CONFIG_ATM_LANE=m
-CONFIG_ATM_MPOA=m
-CONFIG_ATM_BR2684=m
-# CONFIG_ATM_BR2684_IPFILTER is not set
-CONFIG_BRIDGE=m
-CONFIG_VLAN_8021Q=m
-# CONFIG_DECNET is not set
-CONFIG_LLC=m
-# CONFIG_LLC2 is not set
-CONFIG_IPX=m
-# CONFIG_IPX_INTERN is not set
-CONFIG_ATALK=m
-CONFIG_DEV_APPLETALK=y
-CONFIG_IPDDP=m
-CONFIG_IPDDP_ENCAP=y
-CONFIG_IPDDP_DECAP=y
-CONFIG_X25=m
-CONFIG_LAPB=m
-# CONFIG_NET_DIVERT is not set
-CONFIG_ECONET=m
-CONFIG_ECONET_AUNUDP=y
-CONFIG_ECONET_NATIVE=y
-CONFIG_WAN_ROUTER=m
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-CONFIG_NET_SCHED=y
-CONFIG_NET_SCH_CBQ=m
-CONFIG_NET_SCH_HTB=m
-# CONFIG_NET_SCH_HFSC is not set
-CONFIG_NET_SCH_CSZ=m
-# CONFIG_NET_SCH_ATM is not set
-CONFIG_NET_SCH_PRIO=m
-CONFIG_NET_SCH_RED=m
-CONFIG_NET_SCH_SFQ=m
-CONFIG_NET_SCH_TEQL=m
-CONFIG_NET_SCH_TBF=m
-CONFIG_NET_SCH_GRED=m
-CONFIG_NET_SCH_DSMARK=m
-# CONFIG_NET_SCH_DELAY is not set
-CONFIG_NET_SCH_INGRESS=m
-CONFIG_NET_QOS=y
-CONFIG_NET_ESTIMATOR=y
-CONFIG_NET_CLS=y
-CONFIG_NET_CLS_TCINDEX=m
-CONFIG_NET_CLS_ROUTE4=m
-CONFIG_NET_CLS_ROUTE=y
-CONFIG_NET_CLS_FW=m
-CONFIG_NET_CLS_U32=m
-CONFIG_NET_CLS_RSVP=m
-CONFIG_NET_CLS_RSVP6=m
-CONFIG_NET_CLS_POLICE=y
-
-#
-# Network testing
-#
-CONFIG_NET_PKTGEN=m
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-CONFIG_DUMMY=y
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PIO is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-CONFIG_NET_RADIO=y
-
-#
-# Obsolete Wireless cards support (pre-802.11)
-#
-# CONFIG_STRIP is not set
-
-#
-# Wireless 802.11b ISA/PCI cards support
-#
-# CONFIG_AIRO is not set
-CONFIG_HERMES=y
-# CONFIG_PLX_HERMES is not set
-# CONFIG_TMD_HERMES is not set
-CONFIG_PCI_HERMES=y
-# CONFIG_ATMEL is not set
-
-#
-# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
-#
-CONFIG_NET_WIRELESS=y
-
-#
-# Wan interfaces
-#
-CONFIG_WAN=y
-# CONFIG_DSCC4 is not set
-# CONFIG_LANMEDIA is not set
-# CONFIG_SYNCLINK_SYNCPPP is not set
-CONFIG_HDLC=m
-CONFIG_HDLC_RAW=y
-# CONFIG_HDLC_RAW_ETH is not set
-CONFIG_HDLC_CISCO=y
-CONFIG_HDLC_FR=y
-CONFIG_HDLC_PPP=y
-CONFIG_HDLC_X25=y
-# CONFIG_PCI200SYN is not set
-# CONFIG_WANXL is not set
-# CONFIG_PC300 is not set
-# CONFIG_FARSYNC is not set
-CONFIG_DLCI=m
-CONFIG_DLCI_COUNT=24
-CONFIG_DLCI_MAX=8
-CONFIG_WAN_ROUTER_DRIVERS=y
-# CONFIG_CYCLADES_SYNC is not set
-# CONFIG_LAPBETHER is not set
-# CONFIG_X25_ASY is not set
-
-#
-# ATM drivers
-#
-CONFIG_ATM_TCP=m
-# CONFIG_ATM_LANAI is not set
-# CONFIG_ATM_ENI is not set
-# CONFIG_ATM_FIRESTREAM is not set
-# CONFIG_ATM_ZATM is not set
-# CONFIG_ATM_NICSTAR is not set
-# CONFIG_ATM_IDT77252 is not set
-# CONFIG_ATM_AMBASSADOR is not set
-# CONFIG_ATM_HORIZON is not set
-# CONFIG_ATM_IA is not set
-# CONFIG_ATM_FORE200E_MAYBE is not set
-# CONFIG_ATM_HE is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
-
-#
-# IDE chipset support/bugfixes
-#
-CONFIG_IDE_GENERIC=y
-CONFIG_BLK_DEV_IDEPCI=y
-# CONFIG_IDEPCI_SHARE_IRQ is not set
-# CONFIG_BLK_DEV_OFFBOARD is not set
-# CONFIG_BLK_DEV_GENERIC is not set
-# CONFIG_BLK_DEV_OPTI621 is not set
-# CONFIG_BLK_DEV_SL82C105 is not set
-CONFIG_BLK_DEV_IDEDMA_PCI=y
-# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
-# CONFIG_IDEDMA_PCI_AUTO is not set
-CONFIG_BLK_DEV_ADMA=y
-# CONFIG_BLK_DEV_AEC62XX is not set
-# CONFIG_BLK_DEV_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD74XX is not set
-CONFIG_BLK_DEV_CMD64X=y
-# CONFIG_BLK_DEV_TRIFLEX is not set
-# CONFIG_BLK_DEV_CY82C693 is not set
-# CONFIG_BLK_DEV_CS5520 is not set
-# CONFIG_BLK_DEV_CS5530 is not set
-# CONFIG_BLK_DEV_HPT34X is not set
-CONFIG_BLK_DEV_HPT366=y
-# CONFIG_BLK_DEV_SC1200 is not set
-# CONFIG_BLK_DEV_PIIX is not set
-# CONFIG_BLK_DEV_NS87415 is not set
-# CONFIG_BLK_DEV_PDC202XX_OLD is not set
-CONFIG_BLK_DEV_PDC202XX_NEW=y
-# CONFIG_PDC202XX_FORCE is not set
-# CONFIG_BLK_DEV_SVWKS is not set
-# CONFIG_BLK_DEV_SIIMAGE is not set
-# CONFIG_BLK_DEV_SLC90E66 is not set
-# CONFIG_BLK_DEV_TRM290 is not set
-# CONFIG_BLK_DEV_VIA82CXXX is not set
-CONFIG_BLK_DEV_IDEDMA=y
-# CONFIG_IDEDMA_IVB is not set
-# CONFIG_IDEDMA_AUTO is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=2
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-CONFIG_IXP4XX_WATCHDOG=y
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_CHARDEV=y
-
-#
-# I2C Algorithms
-#
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ALGOPCF is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_ALI1535 is not set
-# CONFIG_I2C_ALI1563 is not set
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_I810 is not set
-# CONFIG_I2C_ISA is not set
-CONFIG_I2C_IXP4XX=y
-# CONFIG_I2C_NFORCE2 is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PIIX4 is not set
-# CONFIG_I2C_PROSAVAGE is not set
-# CONFIG_I2C_SAVAGE4 is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_SIS5595 is not set
-# CONFIG_I2C_SIS630 is not set
-# CONFIG_I2C_SIS96X is not set
-# CONFIG_I2C_VIA is not set
-# CONFIG_I2C_VIAPRO is not set
-# CONFIG_I2C_VOODOO3 is not set
-
-#
-# Hardware Sensors Chip support
-#
-CONFIG_I2C_SENSOR=y
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_ASB100 is not set
-# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_FSCHER is not set
-# CONFIG_SENSORS_GL518SM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM80 is not set
-# CONFIG_SENSORS_LM83 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_LM90 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_SENSORS_W83L785TS is not set
-# CONFIG_SENSORS_W83627HF is not set
-
-#
-# Other I2C Chip support
-#
-CONFIG_SENSORS_EEPROM=y
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# Misc devices
-#
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-# CONFIG_DEBUG_USER is not set
-# CONFIG_DEBUG_INFO is not set
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_ICEDCC is not set
-# CONFIG_DEBUG_BDI2000_XSCALE is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/mainstone_defconfig b/arch/arm/configs/mainstone_defconfig
deleted file mode 100644 (file)
index 4ab6e26..0000000
+++ /dev/null
@@ -1,713 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODULE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ADIFCC is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP3XX is not set
-# CONFIG_ARCH_IXP4XX is not set
-# CONFIG_ARCH_L7200 is not set
-CONFIG_ARCH_PXA=y
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_S3C2410 is not set
-# CONFIG_ARCH_SHARK is not set
-# CONFIG_ARCH_LH7A40X is not set
-# CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
-
-#
-# Intel PXA2xx Implementations
-#
-# CONFIG_ARCH_LUBBOCK is not set
-CONFIG_MACH_MAINSTONE=y
-# CONFIG_ARCH_PXA_IDP is not set
-CONFIG_PXA27x=y
-CONFIG_IWMMXT=y
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_XSCALE=y
-CONFIG_CPU_32v5=y
-CONFIG_CPU_ABRT_EV5T=y
-CONFIG_CPU_TLB_V4WBI=y
-CONFIG_CPU_MINICACHE=y
-
-#
-# Processor Features
-#
-# CONFIG_ARM_THUMB is not set
-CONFIG_XSCALE_PMU=y
-
-#
-# General setup
-#
-# CONFIG_ZBOOT_ROM is not set
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_TCIC is not set
-CONFIG_PCMCIA_PXA2XX=y
-
-#
-# At least one math emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_NWFPE_XP is not set
-# CONFIG_FPE_FASTFPE is not set
-# CONFIG_VFP is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_AOUT is not set
-# CONFIG_BINFMT_MISC is not set
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
-# CONFIG_DEBUG_DRIVER is not set
-# CONFIG_PM is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=/dev/nfs ip=bootp console=ttyS0,115200 mem=64M"
-CONFIG_LEDS=y
-CONFIG_LEDS_TIMER=y
-CONFIG_LEDS_CPU=y
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_CMDLINE_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-CONFIG_MTD_CFI_ADV_OPTIONS=y
-CONFIG_MTD_CFI_NOSWAP=y
-# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-CONFIG_MTD_CFI_GEOMETRY=y
-# CONFIG_MTD_CFI_B1 is not set
-# CONFIG_MTD_CFI_B2 is not set
-CONFIG_MTD_CFI_B4=y
-# CONFIG_MTD_CFI_B8 is not set
-# CONFIG_MTD_CFI_I1 is not set
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_EDB7312 is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_RAM is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-CONFIG_SMC91X=y
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-# CONFIG_NET_PCMCIA is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-CONFIG_BLK_DEV_IDECS=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_IDE_GENERIC is not set
-# CONFIG_IDE_ARM is not set
-# CONFIG_BLK_DEV_IDEDMA is not set
-# CONFIG_IDEDMA_AUTO is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_PXA=y
-CONFIG_SERIAL_PXA_CONSOLE=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-# CONFIG_VFAT_FS is not set
-CONFIG_FAT_DEFAULT_CODEPAGE=437
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-
-#
-# Native Language Support
-#
-CONFIG_NLS=y
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-CONFIG_NLS_ISO8859_1=y
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Graphics support
-#
-CONFIG_FB=y
-CONFIG_FB_PXA=y
-# CONFIG_FB_PXA_PARAMETERS is not set
-# CONFIG_FB_VIRTUAL is not set
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE=y
-CONFIG_PCI_CONSOLE=y
-# CONFIG_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-
-#
-# Logo configuration
-#
-CONFIG_LOGO=y
-CONFIG_LOGO_LINUX_MONO=y
-CONFIG_LOGO_LINUX_VGA16=y
-CONFIG_LOGO_LINUX_CLUT224=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# Misc devices
-#
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-CONFIG_DEBUG_INFO=y
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_ICEDCC is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/smdk2410_defconfig b/arch/arm/configs/smdk2410_defconfig
deleted file mode 100644 (file)
index 1309997..0000000
+++ /dev/null
@@ -1,666 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# System Type
-#
-# CONFIG_ARCH_ADIFCC is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP3XX is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_SHARK is not set
-CONFIG_ARCH_S3C2410=y
-# CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_LH7A40X is not set
-# CONFIG_ARCH_VERSATILE_PB is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-
-#
-# Epxa10db
-#
-
-#
-# Footbridge Implementations
-#
-
-#
-# IOP3xx Implementation Options
-#
-# CONFIG_ARCH_IOP310 is not set
-# CONFIG_ARCH_IOP321 is not set
-
-#
-# IOP3xx Chipset Features
-#
-
-#
-# Intel PXA250/210 Implementations
-#
-
-#
-# SA11x0 Implementations
-#
-
-#
-# TI OMAP Implementations
-#
-
-#
-# OMAP Core Type
-#
-
-#
-# OMAP Board Type
-#
-
-#
-# OMAP Feature Selections
-#
-
-#
-# S3C2410 Implementations
-#
-# CONFIG_ARCH_BAST is not set
-# CONFIG_ARCH_H1940 is not set
-CONFIG_ARCH_SMDK2410=y
-# CONFIG_MACH_VR1000 is not set
-
-#
-# LH7A40X Implementations
-#
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_ARM920T=y
-CONFIG_CPU_32v4=y
-CONFIG_CPU_ABRT_EV4T=y
-CONFIG_CPU_CACHE_V4WT=y
-CONFIG_CPU_COPY_V4WB=y
-CONFIG_CPU_TLB_V4WBI=y
-
-#
-# Processor Features
-#
-CONFIG_ARM_THUMB=y
-# CONFIG_CPU_ICACHE_DISABLE is not set
-# CONFIG_CPU_DCACHE_DISABLE is not set
-# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
-
-#
-# General setup
-#
-# CONFIG_ZBOOT_ROM is not set
-CONFIG_ZBOOT_ROM_TEXT=0
-CONFIG_ZBOOT_ROM_BSS=0
-
-#
-# At least one math emulation must be selected
-#
-# CONFIG_FPE_NWFPE is not set
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_AOUT=y
-# CONFIG_BINFMT_MISC is not set
-
-#
-# Generic Driver Options
-#
-# CONFIG_DEBUG_DRIVER is not set
-# CONFIG_PM is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="root=1f04 mem=32M"
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_PARTITIONS is not set
-# CONFIG_MTD_CONCAT is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_EDB7312 is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-# CONFIG_BLK_DEV_INITRD is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-CONFIG_INPUT_MOUSE=y
-CONFIG_MOUSE_PS2=y
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_MOUSE_VSXXXAA is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_S3C2410=y
-CONFIG_SERIAL_S3C2410_CONSOLE=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-CONFIG_ROMFS_FS=y
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Graphics support
-#
-CONFIG_FB=y
-CONFIG_FB_VIRTUAL=y
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE=y
-CONFIG_PCI_CONSOLE=y
-# CONFIG_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-
-#
-# Logo configuration
-#
-# CONFIG_LOGO is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# Misc devices
-#
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
-# CONFIG_DEBUG_BUGVERBOSE is not set
-# CONFIG_DEBUG_ERRORS is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_ICEDCC is not set
-CONFIG_DEBUG_LL_PRINTK=y
-CONFIG_DEBUG_S3C2410_PORT=y
-CONFIG_DEBUG_S3C2410_UART=0
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-CONFIG_LIBCRC32C=y
index d4195fd..d99255a 100644 (file)
@@ -754,6 +754,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
diff --git a/arch/arm/kernel/time-acorn.c b/arch/arm/kernel/time-acorn.c
deleted file mode 100644 (file)
index a4dd9f0..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *  linux/arch/arm/kernel/time-acorn.c
- *
- *  Copyright (c) 1996-2000 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Changelog:
- *   24-Sep-1996       RMK     Created
- *   10-Oct-1996       RMK     Brought up to date with arch-sa110eval
- *   04-Dec-1997       RMK     Updated for new arch/arm/time.c
- */
-#include <linux/timex.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/hardware/ioc.h>
-
-extern unsigned long (*gettimeoffset)(void);
-
-static unsigned long ioctime_gettimeoffset(void)
-{
-       unsigned int count1, count2, status;
-       long offset;
-
-       ioc_writeb (0, IOC_T0LATCH);
-       barrier ();
-       count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
-       barrier ();
-       status = ioc_readb(IOC_IRQREQA);
-       barrier ();
-       ioc_writeb (0, IOC_T0LATCH);
-       barrier ();
-       count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
-
-       offset = count2;
-       if (count2 < count1) {
-               /*
-                * We have not had an interrupt between reading count1
-                * and count2.
-                */
-               if (status & (1 << 5))
-                       offset -= LATCH;
-       } else if (count2 > count1) {
-               /*
-                * We have just had another interrupt between reading
-                * count1 and count2.
-                */
-               offset -= LATCH;
-       }
-
-       offset = (LATCH - offset) * (tick_nsec / 1000);
-       return (offset + LATCH/2) / LATCH;
-}
-
-void __init ioctime_init(void)
-{
-       ioc_writeb(LATCH & 255, IOC_T0LTCHL);
-       ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
-       ioc_writeb(0, IOC_T0GO);
-
-       gettimeoffset = ioctime_gettimeoffset;
-}
diff --git a/arch/arm/mach-adifcc/Makefile b/arch/arm/mach-adifcc/Makefile
deleted file mode 100644 (file)
index d8c1959..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-# Object file lists.
-
-obj-y                  := arch.o irq.o mm.o
-obj-m                  :=
-obj-n                  :=
-obj-                   :=
-
diff --git a/arch/arm/mach-adifcc/arch.c b/arch/arm/mach-adifcc/arch.c
deleted file mode 100644 (file)
index bfc5955..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *  linux/arch/arm/mach-adifcc/arch.c
- *
- *  Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/major.h>
-#include <linux/fs.h>
-
-#include <asm/setup.h>
-#include <asm/memory.h>
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-
-extern void adifcc_map_io(void);
-extern void adifcc_init_irq(void);
-
-#ifdef CONFIG_ARCH_ADI_EVB
-MACHINE_START(ADI_EVB, "ADI 80200FCC Evaluation Board")
-       MAINTAINER("MontaVista Software Inc.")
-       BOOT_MEM(0xc0000000, 0x00400000, 0xff400000)
-       MAPIO(adifcc_map_io)
-       INITIRQ(adifcc_init_irq)
-MACHINE_END
-#endif
-
diff --git a/arch/arm/mach-adifcc/irq.c b/arch/arm/mach-adifcc/irq.c
deleted file mode 100644 (file)
index 4163c60..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * linux/arch/arm/mach-xscale/irq.c
- *
- * Author:  Deepak Saxena
- * Copyright:   (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Based on IOP80310 code.  Currently there's nothing more than the
- * 80200 on chip interrupts. That'll change once the hardware adds
- * support for PCI though.
- */
-#include <linux/init.h>
-#include <linux/interrupt.h>
-
-#include <asm/mach/irq.h>
-#include <asm/irq.h>
-#include <asm/hardware.h>
-
-static void xs80200_irq_mask (unsigned int irq)
-{
-       long INTCTL;
-       asm ("mrc p13, 0, %0, c0, c0, 0" : "=r" (INTCTL));
-       switch (irq) {
-           case IRQ_XS80200_BCU:     INTCTL &= ~(1<<3); break;
-           case IRQ_XS80200_PMU:     INTCTL &= ~(1<<2); break;
-           case IRQ_XS80200_EXTIRQ:  INTCTL &= ~(1<<1); break;
-           case IRQ_XS80200_EXTFIQ:  INTCTL &= ~(1<<0); break;
-       }
-       asm ("mcr p13, 0, %0, c0, c0, 0" : : "r" (INTCTL));
-}
-
-static void xs80200_irq_unmask (unsigned int irq)
-{
-       long INTCTL;
-       asm ("mrc p13, 0, %0, c0, c0, 0" : "=r" (INTCTL));
-       switch (irq) {
-           case IRQ_XS80200_BCU:       INTCTL |= (1<<3); break;
-           case IRQ_XS80200_PMU:       INTCTL |= (1<<2); break;
-           case IRQ_XS80200_EXTIRQ:    INTCTL |= (1<<1); break;
-           case IRQ_XS80200_EXTFIQ:    INTCTL |= (1<<0); break;
-       }
-       asm ("mcr p13, 0, %0, c0, c0, 0" : : "r" (INTCTL));
-}
-
-void __init adifcc_init_irq(void)
-{
-       int i;
-
-       for (i = 0; i < NR_XS80200_IRQS; i++) {
-               irq_desc[i].valid       = 1;
-               irq_desc[i].probe_ok    = 0;
-               irq_desc[i].mask_ack    = xs80200_irq_mask;
-               irq_desc[i].mask        = xs80200_irq_mask;
-               irq_desc[i].unmask      = xs80200_irq_unmask;
-       }
-}
-
-
diff --git a/arch/arm/mach-adifcc/mm.c b/arch/arm/mach-adifcc/mm.c
deleted file mode 100644 (file)
index a81a979..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- *  linux/arch/arm/mach-xscale/mm.c
- */
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/map.h>
-
-
-static struct map_desc adifcc_io_desc[] __initdata = {
- /* on-board devices */
- { 0xff400000,   0x00400000,   0x00300000,   MT_DEVICE }
-};
-
-void __init adifcc_map_io(void)
-{
-       iotable_init(adifcc_io_desc, ARRAY_SIZE(adifcc_io_desc));
-}
diff --git a/arch/arm/mach-ftvpci/Makefile b/arch/arm/mach-ftvpci/Makefile
deleted file mode 100644 (file)
index 8b1ad14..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-# Object file lists.
-
-obj-y                  := core.o
-obj-m                  :=
-obj-n                  :=
-obj-                   :=
-
-obj-$(CONFIG_PCI)      += pci.o
-obj-$(CONFIG_LEDS)     += leds.o
diff --git a/arch/arm/mach-ftvpci/core.c b/arch/arm/mach-ftvpci/core.c
deleted file mode 100644 (file)
index ea6d5c3..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *  linux/arch/arm/mach-ftvpci/core.c
- *
- *  Architecture specific fixups.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include <asm/setup.h>
-#include <asm/mach-types.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-extern unsigned long soft_irq_mask;
-
-static const unsigned char irq_cmd[] =
-{
-       INTCONT_IRQ_DUART,
-       INTCONT_IRQ_PLX,
-       INTCONT_IRQ_D,
-       INTCONT_IRQ_C,
-       INTCONT_IRQ_B,
-       INTCONT_IRQ_A,
-       INTCONT_IRQ_SYSERR
-};
-
-static void ftvpci_mask_irq(unsigned int irq)
-{
-       __raw_writel(irq_cmd[irq], INTCONT_BASE);
-       soft_irq_mask &= ~(1<<irq);
-}
-
-static void ftvpci_unmask_irq(unsigned int irq)
-{
-       soft_irq_mask |= (1<<irq);
-       __raw_writel(irq_cmd[irq] | 1, INTCONT_BASE);
-}
-static void __init ftvpci_init_irq(void)
-{
-       unsigned int i;
-
-       /* Mask all FIQs */
-       __raw_writel(INTCONT_FIQ_PLX, INTCONT_BASE);
-       __raw_writel(INTCONT_FIQ_D, INTCONT_BASE);
-       __raw_writel(INTCONT_FIQ_C, INTCONT_BASE);
-       __raw_writel(INTCONT_FIQ_B, INTCONT_BASE);
-       __raw_writel(INTCONT_FIQ_A, INTCONT_BASE);
-       __raw_writel(INTCONT_FIQ_SYSERR, INTCONT_BASE);
-
-       /* Disable all interrupts initially. */
-       for (i = 0; i < NR_IRQS; i++) {
-               if (i >= FIRST_IRQ && i <= LAST_IRQ) {
-                       irq_desc[i].valid       = 1;
-                       irq_desc[i].probe_ok    = 1;
-                       irq_desc[i].mask_ack    = ftvpci_mask_irq;
-                       irq_desc[i].mask        = ftvpci_mask_irq;
-                       irq_desc[i].unmask      = ftvpci_unmask_irq;
-                       ftvpci_mask_irq(i);
-               } else {
-                       irq_desc[i].valid       = 0;
-                       irq_desc[i].probe_ok    = 0;
-               }       
-       }               
-}
-
-static struct map_desc ftvpci_io_desc[] __initdata = {
-       { INTCONT_BASE, INTCONT_START,  0x00001000, MT_DEVICE },
-       { PLX_BASE,     PLX_START,      0x00001000, MT_DEVICE },
-       { PCIO_BASE,    PLX_IO_START,   0x00100000, MT_DEVICE },
-       { DUART_BASE,   DUART_START,    0x00001000, MT_DEVICE },
-       { STATUS_BASE,  STATUS_START,   0x00001000, MT_DEVICE }
-};
-
-static void __init ftvpci_map_io(void)
-{
-       iotable_init(ftvpci_io_desc, ARRAY_SIZE(ftvpci_io_desc));
-}
-
-MACHINE_START(NEXUSPCI, "FTV/PCI")
-       MAINTAINER("Philip Blundell")
-       BOOT_MEM(0x40000000, 0x10000000, 0xe0000000)
-       MAPIO(ftvpci_map_io)
-       INITIRQ(ftvpci_init_irq)
-MACHINE_END
diff --git a/arch/arm/mach-ftvpci/leds.c b/arch/arm/mach-ftvpci/leds.c
deleted file mode 100644 (file)
index 64345ac..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *  linux/arch/arm/kernel/leds-ftvpci.c
- *
- *  Copyright (C) 1999 FutureTV Labs Ltd
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-#include <asm/io.h>
-
-static void ftvpci_leds_event(led_event_t ledevt)
-{
-       static int led_state = 0;
-
-       switch(ledevt) {
-       case led_timer:
-               led_state ^= 1;
-               raw_writeb(0x1a | led_state, INTCONT_BASE);
-               break;
-
-       default:
-               break;
-       }
-}
-
-static int __init ftvpci_leds_init(void)
-{
-       leds_event = ftvpci_leds_event;
-       return 0;
-}
-
-arch_initcall(ftvpci_leds_init);
diff --git a/arch/arm/mach-ftvpci/pci.c b/arch/arm/mach-ftvpci/pci.c
deleted file mode 100644 (file)
index a9941a1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  linux/arch/arm/kernel/ftv-pci.c
- *
- *  PCI bios-type initialisation for PCI machines
- *
- *  Bits taken from various places.
- */
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-#include <asm/irq.h>
-#include <asm/mach/pci.h>
-#include <asm/mach-types.h>
-
-/*
- * Owing to a PCB cockup, issue A backplanes are wired thus:
- *
- * Slot 1    2    3    4    5   Bridge   S1    S2    S3    S4
- * IRQ  D    C    B    A    A            C     B     A     D
- *      A    D    C    B    B            D     C     B     A
- *      B    A    D    C    C            A     D     C     B
- *      C    B    A    D    D            B     A     D     C
- *
- * ID A31  A30  A29  A28  A27   A26      DEV4  DEV5  DEV6  DEV7
- *
- * Actually, this isn't too bad, because with the processor card
- * in slot 5 on the primary bus, the IRQs rotate on both sides
- * as you'd expect.
- */
-
-static int irqmap_ftv[] __initdata = { IRQ_PCI_D, IRQ_PCI_C, IRQ_PCI_B, IRQ_PCI_A };
-
-static int __init ftv_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-       if (slot > 0x10)
-               slot--;
-       return irqmap_ftv[(slot - pin) & 3];
-}
-
-static u8 __init ftv_swizzle(struct pci_dev *dev, u8 *pin)
-{
-       return PCI_SLOT(dev->devfn);
-}
-
-/* ftv host-specific stuff */
-static struct hw_pci ftv_pci __initdata = {
-       .init           = plx90x0_init,
-       .swizzle        = ftv_swizzle,
-       .map_irq        = ftv_map_irq,
-};
-
-static int __init ftv_pci_init(void)
-{
-       if (machine_is_ftvpci())
-               pci_common_init(&ftv_pci);
-       return 0;
-}
-
-subsys_initcall(ftv_pci_init);
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
deleted file mode 100644 (file)
index 6645218..0000000
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * arch/arm/mach-ixp4xx/common-pci.c 
- *
- * IXP4XX PCI routines for all platforms
- *
- * Maintainer: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright (C) 2002 Intel Corporation.
- * Copyright (C) 2003 Greg Ungerer <gerg@snapgear.com>
- * Copyright (C) 2003-2004 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <asm/dma-mapping.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/sizes.h>
-#include <asm/system.h>
-#include <asm/mach/pci.h>
-#include <asm/hardware.h>
-#include <asm/sizes.h>
-
-
-/*
- * IXP4xx PCI read function is dependent on whether we are 
- * running A0 or B0 (AppleGate) silicon.
- */
-int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data);
-
-/*
- * Base address for PCI regsiter region
- */
-unsigned long ixp4xx_pci_reg_base = 0;
-
-/*
- * PCI cfg an I/O routines are done by programming a 
- * command/byte enable register, and then read/writing
- * the data from a data regsiter. We need to ensure
- * these transactions are atomic or we will end up
- * with corrupt data on the bus or in a driver.
- */
-static spinlock_t ixp4xx_pci_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * Read from PCI config space
- */
-static void crp_read(u32 ad_cbe, u32 *data)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&ixp4xx_pci_lock, flags);
-       *PCI_CRP_AD_CBE = ad_cbe;
-       *data = *PCI_CRP_RDATA;
-       spin_unlock_irqrestore(&ixp4xx_pci_lock, flags);
-}
-
-/*
- * Write to PCI config space
- */
-static void crp_write(u32 ad_cbe, u32 data)
-{ 
-       unsigned long flags;
-       spin_lock_irqsave(&ixp4xx_pci_lock, flags);
-       *PCI_CRP_AD_CBE = CRP_AD_CBE_WRITE | ad_cbe;
-       *PCI_CRP_WDATA = data;
-       spin_unlock_irqrestore(&ixp4xx_pci_lock, flags);
-}
-
-static inline int check_master_abort(void)
-{
-       /* check Master Abort bit after access */
-       unsigned long isr = *PCI_ISR;
-
-       if (isr & PCI_ISR_PFE) {
-               /* make sure the Master Abort bit is reset */    
-               *PCI_ISR = PCI_ISR_PFE;
-               pr_debug("%s failed\n", __FUNCTION__);
-               return 1;
-       }
-
-       return 0;
-}
-
-int ixp4xx_pci_read_errata(u32 addr, u32 cmd, u32* data)
-{
-       unsigned long flags;
-       int retval = 0;
-       int i;
-
-       spin_lock_irqsave(&ixp4xx_pci_lock, flags);
-
-       *PCI_NP_AD = addr;
-
-       /* 
-        * PCI workaround  - only works if NP PCI space reads have 
-        * no side effects!!! Read 8 times. last one will be good.
-        */
-       for (i = 0; i < 8; i++) {
-               *PCI_NP_CBE = cmd;
-               *data = *PCI_NP_RDATA;
-               *data = *PCI_NP_RDATA;
-       }
-
-       if(check_master_abort())
-               retval = 1;
-
-       spin_unlock_irqrestore(&ixp4xx_pci_lock, flags);
-       return retval;
-}
-
-int ixp4xx_pci_read_no_errata(u32 addr, u32 cmd, u32* data)
-{
-       unsigned long flags;
-       int retval = 0;
-
-       spin_lock_irqsave(&ixp4xx_pci_lock, flags);
-
-       *PCI_NP_AD = addr;
-
-       /* set up and execute the read */    
-       *PCI_NP_CBE = cmd;
-
-       /* the result of the read is now in NP_RDATA */
-       *data = *PCI_NP_RDATA; 
-
-       if(check_master_abort())
-               retval = 1;
-
-       spin_unlock_irqrestore(&ixp4xx_pci_lock, flags);
-       return retval;
-}
-
-int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data)
-{    
-       unsigned long flags;
-       int retval = 0;
-
-       spin_lock_irqsave(&ixp4xx_pci_lock, flags);
-
-       *PCI_NP_AD = addr;
-
-       /* set up the write */
-       *PCI_NP_CBE = cmd;
-
-       /* execute the write by writing to NP_WDATA */
-       *PCI_NP_WDATA = data;
-
-       if(check_master_abort())
-               retval = 1;
-
-       spin_unlock_irqrestore(&ixp4xx_pci_lock, flags);
-       return retval;
-}
-
-static u32 ixp4xx_config_addr(u8 bus_num, u16 devfn, int where)
-{
-       u32 addr;
-       if (!bus_num) {
-               /* type 0 */
-               addr = BIT(32-PCI_SLOT(devfn)) | ((PCI_FUNC(devfn)) << 8) | 
-                   (where & ~3);       
-       } else {
-               /* type 1 */
-               addr = (bus_num << 16) | ((PCI_SLOT(devfn)) << 11) | 
-                       ((PCI_FUNC(devfn)) << 8) | (where & ~3) | 1;
-       }
-       return addr;
-}
-
-/*
- * Mask table, bits to mask for quantity of size 1, 2 or 4 bytes.
- * 0 and 3 are not valid indexes...
- */
-static u32 bytemask[] = {
-       /*0*/   0,
-       /*1*/   0xff,
-       /*2*/   0xffff,
-       /*3*/   0,
-       /*4*/   0xffffffff,
-};
-
-static u32 local_byte_lane_enable_bits(u32 n, int size)
-{
-       if (size == 1)
-               return (0xf & ~BIT(n)) << CRP_AD_CBE_BESL;
-       if (size == 2)
-               return (0xf & ~(BIT(n) | BIT(n+1))) << CRP_AD_CBE_BESL;
-       if (size == 4)
-               return 0;
-       return 0xffffffff;
-}
-
-static int local_read_config(int where, int size, u32 *value)
-{ 
-       u32 n, data;
-       pr_debug("local_read_config from %d size %d\n", where, size);
-       n = where % 4;
-       crp_read(where & ~3, &data);
-       *value = (data >> (8*n)) & bytemask[size];
-       pr_debug("local_read_config read %#x\n", *value);
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static int local_write_config(int where, int size, u32 value)
-{
-       u32 n, byte_enables, data;
-       pr_debug("local_write_config %#x to %d size %d\n", value, where, size);
-       n = where % 4;
-       byte_enables = local_byte_lane_enable_bits(n, size);
-       if (byte_enables == 0xffffffff)
-               return PCIBIOS_BAD_REGISTER_NUMBER;
-       data = value << (8*n);
-       crp_write((where & ~3) | byte_enables, data);
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static u32 byte_lane_enable_bits(u32 n, int size)
-{
-       if (size == 1)
-               return (0xf & ~BIT(n)) << 4;
-       if (size == 2)
-               return (0xf & ~(BIT(n) | BIT(n+1))) << 4;
-       if (size == 4)
-               return 0;
-       return 0xffffffff;
-}
-
-static int read_config(u8 bus_num, u16 devfn, int where, int size, u32 *value)
-{
-       u32 n, byte_enables, addr, data;
-
-       pr_debug("read_config from %d size %d dev %d:%d:%d\n", where, size,
-               bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn));
-
-       *value = 0xffffffff;
-       n = where % 4;
-       byte_enables = byte_lane_enable_bits(n, size);
-       if (byte_enables == 0xffffffff)
-               return PCIBIOS_BAD_REGISTER_NUMBER;
-
-       addr = ixp4xx_config_addr(bus_num, devfn, where);
-       if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_CONFIGREAD, &data))
-               return PCIBIOS_DEVICE_NOT_FOUND;
-
-       *value = (data >> (8*n)) & bytemask[size];
-       pr_debug("read_config_byte read %#x\n", *value);
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static int write_config(u8 bus_num, u16 devfn, int where, int size, u32 value)
-{
-       u32 n, byte_enables, addr, data;
-
-       pr_debug("write_config_byte %#x to %d size %d dev %d:%d:%d\n", value, where,
-               size, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn));
-
-       n = where % 4;
-       byte_enables = byte_lane_enable_bits(n, size);
-       if (byte_enables == 0xffffffff)
-               return PCIBIOS_BAD_REGISTER_NUMBER;
-
-       addr = ixp4xx_config_addr(bus_num, devfn, where);
-       data = value << (8*n);
-       if (ixp4xx_pci_write(addr, byte_enables | NP_CMD_CONFIGWRITE, data))
-               return PCIBIOS_DEVICE_NOT_FOUND;
-
-       return PCIBIOS_SUCCESSFUL;
-}
-
-/*
- *     Generalized PCI config access functions.
- */
-static int ixp4xx_read_config(struct pci_bus *bus, unsigned int devfn,
-       int where, int size, u32 *value)
-{
-       if (bus->number && !PCI_SLOT(devfn))
-               return local_read_config(where, size, value);
-       return read_config(bus->number, devfn, where, size, value);
-}
-
-static int ixp4xx_write_config(struct pci_bus *bus, unsigned int devfn,
-       int where, int size, u32 value)
-{
-       if (bus->number && !PCI_SLOT(devfn))
-               return local_write_config(where, size, value);
-       return write_config(bus->number, devfn, where, size, value);
-}
-
-struct pci_ops ixp4xx_ops = {
-       .read =  ixp4xx_read_config,
-       .write = ixp4xx_write_config,
-};
-
-
-/*
- * PCI abort handler
- */
-static int abort_handler(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
-{
-       u32 isr, status;
-
-       isr = *PCI_ISR;
-       local_read_config(PCI_STATUS, 2, &status);
-       pr_debug("PCI: abort_handler addr = %#lx, isr = %#x, "
-               "status = %#x\n", addr, isr, status);
-
-       /* make sure the Master Abort bit is reset */    
-       *PCI_ISR = PCI_ISR_PFE;
-       status |= PCI_STATUS_REC_MASTER_ABORT;
-       local_write_config(PCI_STATUS, 2, status);
-
-       /*
-        * If it was an imprecise abort, then we need to correct the
-        * return address to be _after_ the instruction.
-        */
-       if (fsr & (1 << 10))
-               regs->ARM_pc += 4;
-
-       return 0;
-}
-
-
-/*
- * Setup DMA mask to 64MB on PCI devices. Ignore all other devices.
- */
-static int ixp4xx_pci_platform_notify(struct device *dev)
-{
-       if(dev->bus == &pci_bus_type) {
-               *dev->dma_mask =  SZ_64M - 1;
-               dev->coherent_dma_mask = SZ_64M - 1;
-               dmabounce_register_dev(dev, 2048, 4096);
-       }
-       return 0;
-}
-
-static int ixp4xx_pci_platform_notify_remove(struct device *dev)
-{
-       if(dev->bus == &pci_bus_type) {
-               dmabounce_unregister_dev(dev);
-       }
-       return 0;
-}
-
-int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)
-{
-       return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M);
-}
-
-void __init ixp4xx_pci_preinit(void)
-{  
-       unsigned long processor_id;
-
-       asm("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(processor_id) :);
-
-       /*
-        * Determine which PCI read method to use
-        */
-       if (!(processor_id & 0xf)) {
-               printk("PCI: IXP4xx A0 silicon detected - "
-                       "PCI Non-Prefetch Workaround Enabled\n");
-               ixp4xx_pci_read = ixp4xx_pci_read_errata;
-       } else
-               ixp4xx_pci_read = ixp4xx_pci_read_no_errata;
-
-
-       /* hook in our fault handler for PCI errors */
-       hook_fault_code(16+6, abort_handler, SIGBUS, "imprecise external abort");
-
-       pr_debug("setup PCI-AHB(inbound) and AHB-PCI(outbound) address mappings\n");
-
-       /* 
-        * We use identity AHB->PCI address translation
-        * in the 0x48000000 to 0x4bffffff address space
-        */
-       *PCI_PCIMEMBASE = 0x48494A4B;
-
-       /* 
-        * We also use identity PCI->AHB address translation
-        * in 4 16MB BARs that begin at the physical memory start
-        */
-       *PCI_AHBMEMBASE = (PHYS_OFFSET & 0xFF000000) + 
-               ((PHYS_OFFSET & 0xFF000000) >> 8) +
-               ((PHYS_OFFSET & 0xFF000000) >> 16) +
-               ((PHYS_OFFSET & 0xFF000000) >> 24) +
-               0x00010203;
-
-       if (*PCI_CSR & PCI_CSR_HOST) {
-               printk("PCI: IXP4xx is host\n");
-
-               pr_debug("setup BARs in controller\n");
-
-               /*
-                * We configure the PCI inbound memory windows to be 
-                * 1:1 mapped to SDRAM
-                */
-               local_write_config(PCI_BASE_ADDRESS_0, 4, PHYS_OFFSET + 0x00000000);
-               local_write_config(PCI_BASE_ADDRESS_1, 4, PHYS_OFFSET + 0x01000000);
-               local_write_config(PCI_BASE_ADDRESS_2, 4, PHYS_OFFSET + 0x02000000);
-               local_write_config(PCI_BASE_ADDRESS_3, 4, PHYS_OFFSET + 0x03000000);
-
-               /*
-                * Enable CSR window at 0xff000000.
-                */
-               local_write_config(PCI_BASE_ADDRESS_4, 4, 0xff000008);
-
-               /*
-                * Enable the IO window to be way up high, at 0xfffffc00
-                */
-               local_write_config(PCI_BASE_ADDRESS_5, 4, 0xfffffc01);
-       } else {
-               printk("PCI: IXP4xx is target - No bus scan performed\n");
-       }
-
-       printk("PCI: IXP4xx Using %s access for memory space\n",
-#ifndef CONFIG_IXP4XX_INDIRECT_PCI
-                       "direct"
-#else
-                       "indirect"
-#endif
-               );
-
-       pr_debug("clear error bits in ISR\n");
-       *PCI_ISR = PCI_ISR_PSE | PCI_ISR_PFE | PCI_ISR_PPE | PCI_ISR_AHBE;
-
-       /*
-        * Set Initialize Complete in PCI Control Register: allow IXP4XX to
-        * respond to PCI configuration cycles. Specify that the AHB bus is
-        * operating in big endian mode. Set up byte lane swapping between 
-        * little-endian PCI and the big-endian AHB bus 
-        */
-#ifdef __ARMEB__
-       *PCI_CSR = PCI_CSR_IC | PCI_CSR_ABE | PCI_CSR_PDS | PCI_CSR_ADS;
-#else
-       *PCI_CSR = PCI_CSR_IC;
-#endif
-
-       pr_debug("DONE\n");
-}
-
-int ixp4xx_setup(int nr, struct pci_sys_data *sys)
-{
-       struct resource *res;
-
-       if (nr >= 1)
-               return 0;
-
-       res = kmalloc(sizeof(*res) * 2, GFP_KERNEL);
-       if (res == NULL) {
-               /* 
-                * If we're out of memory this early, something is wrong,
-                * so we might as well catch it here.
-                */
-               panic("PCI: unable to allocate resources?\n");
-       }
-       memset(res, 0, sizeof(*res) * 2);
-
-       local_write_config(PCI_COMMAND, 2, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
-
-       res[0].name = "PCI I/O Space";
-       res[0].start = 0x00001000;
-       res[0].end = 0xffff0000;
-       res[0].flags = IORESOURCE_IO;
-
-       res[1].name = "PCI Memory Space";
-       res[1].start = 0x48000000;
-#ifndef CONFIG_IXP4XX_INDIRECT_PCI
-       res[1].end = 0x4bffffff;
-#else
-       res[1].end = 0x4fffffff;
-#endif
-       res[1].flags = IORESOURCE_MEM;
-
-       request_resource(&ioport_resource, &res[0]);
-       request_resource(&iomem_resource, &res[1]);
-
-       sys->resource[0] = &res[0];
-       sys->resource[1] = &res[1];
-       sys->resource[2] = NULL;
-
-       platform_notify = ixp4xx_pci_platform_notify;
-       platform_notify_remove = ixp4xx_pci_platform_notify_remove;
-
-       return 1;
-}
-
-struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys)
-{
-       return pci_scan_bus(sys->busnr, &ixp4xx_ops, sys);
-}
-
-/*
- * We override these so we properly do dmabounce otherwise drivers
- * are able to set the dma_mask to 0xffffffff and we can no longer
- * trap bounces. :(
- *
- * We just return true on everyhing except for < 64MB in which case 
- * we will fail miseralby and die since we can't handle that case.
- */
-int
-pci_set_dma_mask(struct pci_dev *dev, u64 mask)
-{
-       if (mask >= SZ_64M - 1 )
-               return 0;
-
-       return -EIO;
-}
-    
-int
-pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
-{
-       if (mask >= SZ_64M - 1 )
-               return 0;
-
-       return -EIO;
-}
-
-int
-pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
-{
-       if (mask >= SZ_64M - 1 )
-               return 0;
-
-       return -EIO;
-}
-
-EXPORT_SYMBOL(pci_set_dma_mask);
-EXPORT_SYMBOL(pci_dac_set_dma_mask);
-EXPORT_SYMBOL(pci_set_consistent_dma_mask);
-EXPORT_SYMBOL(ixp4xx_pci_read);
-EXPORT_SYMBOL(ixp4xx_pci_write);
-
diff --git a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c
deleted file mode 100644 (file)
index 03ad0b7..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * arch/arm/mach-ixp4xx/coyote-setup.c
- *
- * ADI Engineering Coyote board-setup 
- *
- * Copyright (C) 2003-2004 MontaVista Software, Inc.
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- */
-
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/serial.h>
-#include <linux/tty.h>
-#include <linux/serial_core.h>
-
-#include <asm/types.h>
-#include <asm/setup.h>
-#include <asm/memory.h>
-#include <asm/hardware.h>
-#include <asm/irq.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
-
-#ifdef __ARMEB__
-#define        REG_OFFSET      3
-#else
-#define        REG_OFFSET      0
-#endif
-
-/*
- * Only one serial port is connected on the Coyote.
- */
-static struct uart_port coyote_serial_port = {
-       .membase        = (char*)(IXP4XX_UART2_BASE_VIRT + REG_OFFSET),
-       .mapbase        = (IXP4XX_UART2_BASE_PHYS),
-       .irq            = IRQ_IXP4XX_UART2,
-       .flags          = UPF_SKIP_TEST,
-       .iotype         = UPIO_MEM,     
-       .regshift       = 2,
-       .uartclk        = IXP4XX_UART_XTAL,
-       .line           = 0,
-       .type           = PORT_XSCALE,
-       .fifosize       = 32
-};
-
-void __init coyote_map_io(void)
-{
-       early_serial_setup(&coyote_serial_port);
-
-       ixp4xx_map_io();
-}
-
-static struct flash_platform_data coyote_flash_data = {
-       .map_name       = "cfi_probe",
-       .width          = 2,
-};
-
-static struct resource coyote_flash_resource = {
-       .start          = COYOTE_FLASH_BASE,
-       .end            = COYOTE_FLASH_BASE + COYOTE_FLASH_SIZE,
-       .flags          = IORESOURCE_MEM,
-};
-
-static struct platform_device coyote_flash = {
-       .name           = "IXP4XX-Flash",
-       .id             = 0,
-       .dev            = {
-               .platform_data = &coyote_flash_data,
-       },
-       .num_resources  = 1,
-       .resource       = &coyote_flash_resource,
-};
-
-static struct platform_device *coyote_devices[] __initdata = {
-       &coyote_flash
-};
-
-static void __init coyote_init(void)
-{
-       platform_add_devices(&coyote_devices, ARRAY_SIZE(coyote_devices));
-}
-
-MACHINE_START(ADI_COYOTE, "ADI Engineering IXP4XX Coyote Development Platform")
-        MAINTAINER("MontaVista Software, Inc.")
-        BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS,
-                IXP4XX_PERIPHERAL_BASE_VIRT)
-        MAPIO(coyote_map_io)
-        INITIRQ(ixp4xx_init_irq)
-       INITTIME(ixp4xx_init_time)
-        BOOT_PARAMS(0x0100)
-       INIT_MACHINE(coyote_init)
-MACHINE_END
-
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
deleted file mode 100644 (file)
index dbcaa46..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * arch/arm/mach-ixp4xx/ixdp425-setup.c
- *
- * IXDP425/IXCDP1100 board-setup 
- *
- * Copyright (C) 2003-2004 MontaVista Software, Inc.
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- */
-
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/serial.h>
-#include <linux/tty.h>
-#include <linux/serial_core.h>
-
-#include <asm/types.h>
-#include <asm/setup.h>
-#include <asm/memory.h>
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
-
-#ifdef __ARMEB__
-#define        REG_OFFSET      3
-#else
-#define        REG_OFFSET      0
-#endif
-
-/*
- * IXDP425 uses both chipset serial ports
- */
-static struct uart_port ixdp425_serial_ports[] = {
-       {
-               .membase        = (char*)(IXP4XX_UART1_BASE_VIRT + REG_OFFSET),
-               .mapbase        = (IXP4XX_UART1_BASE_PHYS),
-               .irq            = IRQ_IXP4XX_UART1,
-               .flags          = UPF_SKIP_TEST,
-               .iotype         = UPIO_MEM,     
-               .regshift       = 2,
-               .uartclk        = IXP4XX_UART_XTAL,
-               .line           = 0,
-               .type           = PORT_XSCALE,
-               .fifosize       = 32
-       } , {
-               .membase        = (char*)(IXP4XX_UART2_BASE_VIRT + REG_OFFSET),
-               .mapbase        = (IXP4XX_UART2_BASE_PHYS),
-               .irq            = IRQ_IXP4XX_UART2,
-               .flags          = UPF_SKIP_TEST,
-               .iotype         = UPIO_MEM,     
-               .regshift       = 2,
-               .uartclk        = IXP4XX_UART_XTAL,
-               .line           = 1,
-               .type           = PORT_XSCALE,
-               .fifosize       = 32
-       }
-};
-
-void __init ixdp425_map_io(void) 
-{
-       early_serial_setup(&ixdp425_serial_ports[0]);
-       early_serial_setup(&ixdp425_serial_ports[1]);
-
-       ixp4xx_map_io();
-}
-
-static struct flash_platform_data ixdp425_flash_data = {
-       .map_name       = "cfi_probe",
-       .width          = 2,
-};
-
-static struct resource ixdp425_flash_resource = {
-       .start          = IXDP425_FLASH_BASE,
-       .end            = IXDP425_FLASH_BASE + IXDP425_FLASH_SIZE,
-       .flags          = IORESOURCE_MEM,
-};
-
-static struct platform_device ixdp425_flash = {
-       .name           = "IXP4XX-Flash",
-       .id             = 0,
-       .dev            = {
-               .platform_data = &ixdp425_flash_data,
-       },
-       .num_resources  = 1,
-       .resource       = &ixdp425_flash_resource,
-};
-
-static struct ixp4xx_i2c_pins ixdp425_i2c_gpio_pins = {
-       .sda_pin        = IXDP425_SDA_PIN,
-       .scl_pin        = IXDP425_SCL_PIN,
-};
-
-static struct platform_device ixdp425_i2c_controller = {
-       .name           = "IXP4XX-I2C",
-       .id             = 0,
-       .dev            = {
-               .platform_data = &ixdp425_i2c_gpio_pins,
-       },
-       .num_resources  = 0
-};
-
-static struct platform_device *ixdp425_devices[] __initdata = {
-       &ixdp425_i2c_controller,
-       &ixdp425_flash
-};
-
-static void __init ixdp425_init(void)
-{
-       platform_add_devices(&ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
-}
-
-MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
-       MAINTAINER("MontaVista Software, Inc.")
-       BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS,
-               IXP4XX_PERIPHERAL_BASE_VIRT)
-       MAPIO(ixdp425_map_io)
-       INITIRQ(ixp4xx_init_irq)
-       INITTIME(ixp4xx_init_time)
-       BOOT_PARAMS(0x0100)
-       INIT_MACHINE(ixdp425_init)
-MACHINE_END
-
-MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
-       MAINTAINER("MontaVista Software, Inc.")
-       BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS,
-               IXP4XX_PERIPHERAL_BASE_VIRT)
-       MAPIO(ixdp425_map_io)
-       INITIRQ(ixp4xx_init_irq)
-       INITTIME(ixp4xx_init_time)
-       BOOT_PARAMS(0x0100)
-       INIT_MACHINE(ixdp425_init)
-MACHINE_END
-
-/*
- * Avila is functionally equivalent to IXDP425 except that it adds
- * a CF IDE slot hanging off the expansion bus. When we have a 
- * driver for IXP4xx CF IDE with driver model support we'll move
- * Avila to it's own setup file.
- */
-#ifdef CONFIG_ARCH_AVILA
-MACHINE_START(AVILA, "Gateworks Avila Network Platform")
-       MAINTAINER("Deepak Saxena <dsaxena@plexity.net>")
-       BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS,
-               IXP4XX_PERIPHERAL_BASE_VIRT)
-       MAPIO(ixdp425_map_io)
-       INITIRQ(ixp4xx_init_irq)
-       INITTIME(ixp4xx_init_time)
-       BOOT_PARAMS(0x0100)
-       INIT_MACHINE(ixdp425_init)
-MACHINE_END
-#endif
-
diff --git a/arch/arm/mach-ixp4xx/prpmc1100-setup.c b/arch/arm/mach-ixp4xx/prpmc1100-setup.c
deleted file mode 100644 (file)
index 01e98fd..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * arch/arm/mach-ixp4xx/prpmc1100-setup.c
- *
- * Motorola PrPMC1100 board setup
- *
- * Copyright (C) 2003-2004 MontaVista Software, Inc.
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- */
-
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/serial.h>
-#include <linux/tty.h>
-#include <linux/serial_core.h>
-
-#include <asm/types.h>
-#include <asm/setup.h>
-#include <asm/memory.h>
-#include <asm/hardware.h>
-#include <asm/irq.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
-
-#ifdef __ARMEB__
-#define        REG_OFFSET      3
-#else
-#define        REG_OFFSET      0
-#endif
-
-/*
- * Only one serial port is connected on the PrPMC1100
- */
-static struct uart_port prpmc1100_serial_port = {
-       .membase        = (char*)(IXP4XX_UART1_BASE_VIRT + REG_OFFSET),
-       .mapbase        = (IXP4XX_UART1_BASE_PHYS),
-       .irq            = IRQ_IXP4XX_UART1,
-       .flags          = UPF_SKIP_TEST,
-       .iotype         = UPIO_MEM,     
-       .regshift       = 2,
-       .uartclk        = IXP4XX_UART_XTAL,
-       .line           = 0,
-       .type           = PORT_XSCALE,
-       .fifosize       = 32
-};
-
-void __init prpmc1100_map_io(void)
-{
-       early_serial_setup(&prpmc1100_serial_port);
-
-       ixp4xx_map_io();
-}
-
-static struct flash_platform_data prpmc1100_flash_data = {
-       .map_name       = "cfi_probe",
-       .width          = 2,
-};
-
-static struct resource prpmc1100_flash_resource = {
-       .start          = PRPMC1100_FLASH_BASE,
-       .end            = PRPMC1100_FLASH_BASE + PRPMC1100_FLASH_SIZE,
-       .flags          = IORESOURCE_MEM,
-};
-
-static struct platform_device prpmc1100_flash = {
-       .name           = "IXP4XX-Flash",
-       .id             = 0,
-       .dev            = {
-               .platform_data = &prpmc1100_flash_data,
-       },
-       .num_resources  = 1,
-       .resource       = &prpmc1100_flash_resource,
-};
-
-static struct platform_device *prpmc1100_devices[] __initdata = {
-       &prpmc1100_flash
-};
-
-static void __init prpmc1100_init(void)
-{
-       platform_add_devices(&prpmc1100_devices, ARRAY_SIZE(prpmc1100_devices));
-}
-
-MACHINE_START(PRPMC1100, "Motorola PrPMC1100")
-        MAINTAINER("MontaVista Software, Inc.")
-        BOOT_MEM(PHYS_OFFSET, IXP4XX_PERIPHERAL_BASE_PHYS,
-                IXP4XX_PERIPHERAL_BASE_VIRT)
-        MAPIO(prpmc1100_map_io)
-        INITIRQ(ixp4xx_init_irq)
-       INITTIME(ixp4xx_init_time)
-        BOOT_PARAMS(0x0100)
-       INIT_MACHINE(prpmc1100_init)
-MACHINE_END
-
diff --git a/arch/arm/mach-lh7a40x/fiq.S b/arch/arm/mach-lh7a40x/fiq.S
deleted file mode 100644 (file)
index fefedf8..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *  linux/arch/arm/lib/lh7a400-fiqhandler.S
- *     Copyright (C) 2002, Lineo, Inc.
- *  based on  linux/arch/arm/lib/floppydma.S, which is
- *      Copyright (C) 1995, 1996 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/linkage.h>
-#include <asm/assembler.h>
-       .text
-
-       .global fiqhandler_end
-
-       @ register usage:
-       @        r8  &interrupt controller registers
-       @        r9  &gpio registers
-       @       r11  work
-       @       r12  work
-
-ENTRY(fiqhandler)
-
-       @ read the status register to find out which FIQ this is
-
-       ldr     r12, [r8]               @ intc->status
-       and     r12, r12, #0xf          @ only interested in low-order 4 bits
-
-       @ translate FIQ 0:3 to IRQ 23:26
-       @ disable this FIQ and enable the corresponding IRQ
-
-       str     r12, [r8, #0xc]         @ disable this FIQ
-       mov     r12, r12, lsl #23       @ get the corresopnding IRQ bit
-       str     r12, [r8, #0x8]         @ enable that IRQ
-
-       subs    pc, lr, #4
-fiqhandler_end:
-
diff --git a/arch/arm/mach-lh7a40x/ide-lpd7a40x.c b/arch/arm/mach-lh7a40x/ide-lpd7a40x.c
deleted file mode 100644 (file)
index fedca41..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/* arch/arm/mach-lh7a40x/ide-lpd7a40x.c
- *
- *  Copyright (C) 2004 Logic Product Development
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public License
- *  version 2 as published by the Free Software Foundation.
- *
- */
-
-
-#include <linux/config.h>
-#include <linux/ide.h>
-
-#include <asm/io.h>
-
-#define IOBARRIER_READ         readl (IOBARRIER_VIRT)
-
-static u8 lpd7a40x_ide_inb (unsigned long port)
-{
-       u16 v = (u16) readw (port & ~0x1);
-       IOBARRIER_READ;
-       if (port & 0x1)
-               v >>= 8;
-       return v & 0xff;
-}
-
-static u16 lpd7a40x_ide_inw (unsigned long port)
-{
-       u16 v = (u16) readw (port);
-       IOBARRIER_READ;
-       return v;
-}
-
-static void lpd7a40x_ide_insw (unsigned long port, void *addr, u32 count)
-{
-       while (count--) {
-               *((u16*) addr)++ = (u16) readw (port);
-               IOBARRIER_READ;
-       }
-}
-
-static u32 lpd7a40x_ide_inl (unsigned long port)
-{
-       u32 v = (u16) readw (port);
-       IOBARRIER_READ;
-       v |= (u16) readw (port + 2);
-       IOBARRIER_READ;
-
-       return v;
-}
-
-static void lpd7a40x_ide_insl (unsigned long port, void *addr, u32 count)
-{
-       while (count--) {
-               *((u16*) addr)++ = (u16) readw (port);
-               IOBARRIER_READ;
-               *((u16*) addr)++ = (u16) readw (port + 2);
-               IOBARRIER_READ;
-       }
-}
-
-/* lpd7a40x_ide_outb -- this function is complicated by the fact that
- * the user wants to be able to do byte IO and the hardware cannot.
- * In order to write the high byte, we need to write a short.  So, we
- * read before writing in order to maintain the register values that
- * shouldn't change.  This isn't a good idea for the data IO registers
- * since reading from them will not return the current value.  We
- * expect that this function handles the control register adequately.
-*/
-
-static void lpd7a40x_ide_outb (u8 valueUser, unsigned long port)
-{
-       /* Block writes to SELECT register.  Draconian, but the only
-        * way to cope with this hardware configuration without
-        * modifying the SELECT_DRIVE call in the ide driver. */
-       if ((port & 0xf) == 0x6)
-               return;
-
-       if (port & 0x1) {       /* Perform read before write.  Only
-                                * the COMMAND register needs
-                                * this.  */
-               u16 value = (u16) readw (port & ~0x1);
-               IOBARRIER_READ;
-               value = (value & 0x00ff) | (valueUser << 8);
-               writew (value, port & ~0x1);
-               IOBARRIER_READ;
-       }
-       else {                  /* Allow low-byte writes which seem to
-                                * be OK. */
-               writeb (valueUser, port);
-               IOBARRIER_READ;
-       }
-}
-
-static void lpd7a40x_ide_outbsync (ide_drive_t *drive, u8 value,
-                                  unsigned long port)
-{
-       lpd7a40x_ide_outb (value, port);
-}
-
-static void lpd7a40x_ide_outw (u16 value, unsigned long port)
-{
-       writew (value, port);
-       IOBARRIER_READ;
-}
-
-static void lpd7a40x_ide_outsw (unsigned long port, void *addr, u32 count)
-{
-       while (count-- > 0) {
-               writew (*((u16*) addr)++, port);
-               IOBARRIER_READ;
-       }
-}
-
-static void lpd7a40x_ide_outl (u32 value, unsigned long port)
-{
-       writel (value, port);
-       IOBARRIER_READ;
-}
-
-static void lpd7a40x_ide_outsl (unsigned long port, void *addr, u32 count)
-{
-       while (count-- > 0) {
-               writel (*((u32*) addr)++, port);
-               IOBARRIER_READ;
-       }
-}
-
-void lpd7a40x_SELECT_DRIVE (ide_drive_t *drive)
-{
-       unsigned jifStart = jiffies;
-#define WAIT_TIME      (30*HZ/1000)
-
-       /* Check for readiness. */
-       while ((HWIF(drive)->INB(IDE_STATUS_REG) & 0x40) == 0)
-               if (jifStart <= jiffies + WAIT_TIME)
-                       return;
-
-       /* Only allow one drive.
-          For more information, see Documentation/arm/Sharp-LH/ */
-       if (drive->select.all & (1<<4))
-               return;
-
-       /* OUTW so that the IDLE_IMMEDIATE (and not NOP) command is sent. */
-       HWIF(drive)->OUTW(drive->select.all | 0xe100, IDE_SELECT_REG);
-}
-
-void lpd7a40x_hwif_ioops (ide_hwif_t *hwif)
-{
-       hwif->mmio      = 2;    /* Just for show */
-       hwif->irq       = IDE_NO_IRQ;   /* Stop this probing */
-
-       hwif->OUTB      = lpd7a40x_ide_outb;
-       hwif->OUTBSYNC  = lpd7a40x_ide_outbsync;
-       hwif->OUTW      = lpd7a40x_ide_outw;
-       hwif->OUTL      = lpd7a40x_ide_outl;
-       hwif->OUTSW     = lpd7a40x_ide_outsw;
-       hwif->OUTSL     = lpd7a40x_ide_outsl;
-       hwif->INB       = lpd7a40x_ide_inb;
-       hwif->INW       = lpd7a40x_ide_inw;
-       hwif->INL       = lpd7a40x_ide_inl;
-       hwif->INSW      = lpd7a40x_ide_insw;
-       hwif->INSL      = lpd7a40x_ide_insl;
-       hwif->selectproc = lpd7a40x_SELECT_DRIVE;
-}
diff --git a/arch/arm/mach-omap/innovator1510.c b/arch/arm/mach-omap/innovator1510.c
deleted file mode 100644 (file)
index 1309f96..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * linux/arch/arm/mach-omap/innovator1510.c
- *
- * Board specific inits for OMAP-1510 Innovator
- *
- * Copyright (C) 2001 RidgeRun, Inc.
- * Author: Greg Lonnon <glonnon@ridgerun.com>
- *
- * Copyright (C) 2002 MontaVista Software, Inc.
- *
- * Separated FPGA interrupts from innovator1510.c and cleaned up for 2.6
- * Copyright (C) 2004 Nokia Corporation by Tony Lindrgen <tony@atomide.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <asm/arch/clocks.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/fpga.h>
-
-#include "common.h"
-
-extern int omap_gpio_init(void);
-
-void innovator_init_irq(void)
-{
-       omap_init_irq();
-       omap_gpio_init();
-       fpga_init_irq();
-}
-
-static struct resource smc91x_resources[] = {
-       [0] = {
-               .start  = OMAP1510P1_FPGA_ETHR_START,   /* Physical */
-               .end    = OMAP1510P1_FPGA_ETHR_START + 16,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = INT_ETHER,
-               .end    = INT_ETHER,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device smc91x_device = {
-       .name           = "smc91x",
-       .id             = 0,
-       .num_resources  = ARRAY_SIZE(smc91x_resources),
-       .resource       = smc91x_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-       &smc91x_device,
-};
-
-static void __init innovator_init(void)
-{
-       if (!machine_is_innovator())
-               return;
-
-       (void) platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-/* Only FPGA needs to be mapped here. All others are done with ioremap */
-static struct map_desc innovator_io_desc[] __initdata = {
-{ OMAP1510P1_FPGA_BASE, OMAP1510P1_FPGA_START, OMAP1510P1_FPGA_SIZE,
-       MT_DEVICE },
-};
-
-static void __init innovator_map_io(void)
-{
-       omap_map_io();
-       iotable_init(innovator_io_desc, ARRAY_SIZE(innovator_io_desc));
-
-       /* Dump the Innovator FPGA rev early - useful info for support. */
-       printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
-              fpga_read(OMAP1510P1_FPGA_REV_HIGH),
-              fpga_read(OMAP1510P1_FPGA_REV_LOW),
-              fpga_read(OMAP1510P1_FPGA_BOARD_REV));
-}
-
-MACHINE_START(INNOVATOR, "TI-Innovator/OMAP1510")
-       MAINTAINER("MontaVista Software, Inc.")
-       BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
-       BOOT_PARAMS(0x10000100)
-       MAPIO(innovator_map_io)
-       INITIRQ(innovator_init_irq)
-       INIT_MACHINE(innovator_init)
-MACHINE_END
diff --git a/arch/arm/mach-omap/innovator1610.c b/arch/arm/mach-omap/innovator1610.c
deleted file mode 100644 (file)
index 4081735..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * linux/arch/arm/mach-omap/innovator1610.c
- *
- * This file contains Innovator-specific code.
- *
- * Copyright (C) 2002 MontaVista Software, Inc.
- *
- * Copyright (C) 2001 RidgeRun, Inc.
- * Author: Greg Lonnon <glonnon@ridgerun.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/major.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/errno.h>
-
-#include <asm/setup.h>
-#include <asm/page.h>
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/arch/irqs.h>
-
-#include "common.h"
-
-void
-innovator_init_irq(void)
-{
-       omap_init_irq();
-}
-
-static struct resource smc91x_resources[] = {
-       [0] = {
-               .start  = OMAP1610_ETHR_START,          /* Physical */
-               .end    = OMAP1610_ETHR_START + SZ_4K,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 0,                            /* Really GPIO 0 */
-               .end    = 0,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device smc91x_device = {
-       .name           = "smc91x",
-       .id             = 0,
-       .num_resources  = ARRAY_SIZE(smc91x_resources),
-       .resource       = smc91x_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-       &smc91x_device,
-};
-
-static void __init innovator_init(void)
-{
-       if (!machine_is_innovator())
-               return;
-
-       (void) platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-static struct map_desc innovator_io_desc[] __initdata = {
-{ OMAP1610_ETHR_BASE, OMAP1610_ETHR_START, OMAP1610_ETHR_SIZE,MT_DEVICE },
-{ OMAP1610_NOR_FLASH_BASE, OMAP1610_NOR_FLASH_START, OMAP1610_NOR_FLASH_SIZE,
-       MT_DEVICE },
-};
-
-static void __init innovator_map_io(void)
-{
-       omap_map_io();
-       iotable_init(innovator_io_desc, ARRAY_SIZE(innovator_io_desc));
-}
-
-MACHINE_START(INNOVATOR, "TI-Innovator/OMAP1610")
-       MAINTAINER("MontaVista Software, Inc.")
-       BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
-       BOOT_PARAMS(0x10000100)
-       MAPIO(innovator_map_io)
-       INITIRQ(innovator_init_irq)
-       INIT_MACHINE(innovator_init)
-MACHINE_END
-
diff --git a/arch/arm/mach-omap/irq.h b/arch/arm/mach-omap/irq.h
deleted file mode 100644 (file)
index 8e1aa78..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * linux/arch/arm/mach-omap/irq.h
- *
- * OMAP specific interrupt bank definitions
- *
- * Copyright (C) 2004 Nokia Corporation
- * Written by Tony Lindgren <tony@atomide.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * You should have received a copy of the  GNU General Public License along
- * with this program; if not, write  to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define OMAP_IRQ_TYPE710       1
-#define OMAP_IRQ_TYPE730       2
-#define OMAP_IRQ_TYPE1510      3
-#define OMAP_IRQ_TYPE1610      4
-#define OMAP_IRQ_TYPE1710      5
-
-#define MAX_NR_IRQ_BANKS       4
-
-#define BANK_NR_IRQS           32
-
-struct omap_irq_desc {
-       unsigned int    cpu_type;
-       unsigned int    start_irq;
-       unsigned long   level_map;
-       unsigned long   base_reg;
-       unsigned long   mask_reg;
-       unsigned long   ack_reg;
-       struct irqchip  *handler;
-};
-
-struct omap_irq_bank {
-       unsigned int    start_irq;
-       unsigned long   level_map;
-       unsigned long   base_reg;
-       unsigned long   mask_reg;
-       unsigned long   ack_reg;
-       struct irqchip  *handler;
-};
-
-static void omap_offset_ack_irq(unsigned int irq);
-static void omap_offset_mask_irq(unsigned int irq);
-static void omap_offset_unmask_irq(unsigned int irq);
-static void omap_offset_mask_ack_irq(unsigned int irq);
-
-/* NOTE: These will not work if irq bank offset != 0x100 */
-#define IRQ_TO_BANK(irq)       (irq >> 5)
-#define IRQ_BIT(irq)           (irq & 0x1f)
-#define BANK_OFFSET(bank)      ((bank - 1) * 0x100)
-
-static struct irqchip omap_offset_irq = {
-       .ack    =  omap_offset_mask_ack_irq,
-       .mask   =  omap_offset_mask_irq,
-       .unmask =  omap_offset_unmask_irq,
-};
-
-/*
- * OMAP-730 interrupt banks
- */
-static struct omap_irq_desc omap730_bank0_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE730,
-       .start_irq      = 0,
-       .level_map      = 0xb3f8e22f,
-       .base_reg       = OMAP_IH1_BASE,
-       .mask_reg       = OMAP_IH1_BASE + IRQ_MIR,
-       .ack_reg        = OMAP_IH1_BASE + IRQ_CONTROL_REG,
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap730_bank1_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE730,
-       .start_irq      = 32,
-       .level_map      = 0xfdb9c1f2,
-       .base_reg       = OMAP_IH2_BASE,
-       .mask_reg       = OMAP_IH2_BASE + IRQ_MIR,
-       .ack_reg        = OMAP_IH2_BASE + IRQ_CONTROL_REG,
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap730_bank2_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE730,
-       .start_irq      = 64,
-       .level_map      = 0x800040f3,
-       .base_reg       = OMAP_IH2_BASE + 0x100,
-       .mask_reg       = OMAP_IH2_BASE + 0x100 + IRQ_MIR,
-       .ack_reg        = OMAP_IH2_BASE + IRQ_CONTROL_REG, /* Not replicated */
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-/*
- * OMAP-1510 interrupt banks
- */
-static struct omap_irq_desc omap1510_bank0_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE1510,
-       .start_irq      = 0,
-       .level_map      = 0xb3febfff,
-       .base_reg       = OMAP_IH1_BASE,
-       .mask_reg       = OMAP_IH1_BASE + IRQ_MIR,
-       .ack_reg        = OMAP_IH1_BASE + IRQ_CONTROL_REG,
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1510_bank1_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE1510,
-       .start_irq      = 32,
-       .level_map      = 0xffbfffed,
-       .base_reg       = OMAP_IH2_BASE,
-       .mask_reg       = OMAP_IH2_BASE + IRQ_MIR,
-       .ack_reg        = OMAP_IH2_BASE + IRQ_CONTROL_REG,
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-/*
- * OMAP-1610 interrupt banks
- */
-static struct omap_irq_desc omap1610_bank0_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE1610,
-       .start_irq      = 0,
-       .level_map      = 0xb3fefe8f,
-       .base_reg       = OMAP_IH1_BASE,
-       .mask_reg       = OMAP_IH1_BASE + IRQ_MIR,
-       .ack_reg        = OMAP_IH1_BASE + IRQ_CONTROL_REG,
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1610_bank1_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE1610,
-       .start_irq      = 32,
-       .level_map      = 0xfffff7ff,
-       .base_reg       = OMAP_IH2_BASE,
-       .mask_reg       = OMAP_IH2_BASE + IRQ_MIR,
-       .ack_reg        = OMAP_IH2_BASE + IRQ_CONTROL_REG,
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1610_bank2_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE1610,
-       .start_irq      = 64,
-       .level_map      = 0xffffffff,
-       .base_reg       = OMAP_IH2_BASE + 0x100,
-       .mask_reg       = OMAP_IH2_BASE + 0x100 + IRQ_MIR,
-       .ack_reg        = OMAP_IH2_BASE + IRQ_CONTROL_REG, /* Not replicated */
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1610_bank3_irqs __initdata = {
-       .cpu_type       = OMAP_IRQ_TYPE1610,
-       .start_irq      = 96,
-       .level_map      = 0xffffffff,
-       .base_reg       = OMAP_IH2_BASE + 0x200,
-       .mask_reg       = OMAP_IH2_BASE + 0x200 + IRQ_MIR,
-       .ack_reg        = OMAP_IH2_BASE + IRQ_CONTROL_REG, /* Not replicated */
-       .handler        = &omap_offset_irq,     /* IH2 regs at 0x100 offsets */
-};
diff --git a/arch/arm/mach-omap/omap-generic.c b/arch/arm/mach-omap/omap-generic.c
deleted file mode 100644 (file)
index 982830d..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * linux/arch/arm/mach-omap/generic.c
- *
- * Modified from innovator.c
- *
- * Code for generic OMAP board. Should work on many OMAP systems where
- * the device drivers take care of all the necessary hardware initialization.
- * Do not put any board specific code to this file; create a new machine
- * type if you need custom low-level initializations.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <asm/arch/clocks.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/mux.h>
-
-#include "common.h"
-
-static void __init omap_generic_init_irq(void)
-{
-       omap_init_irq();
-}
-
-/*
- * Muxes the serial ports on
- */
-static void __init omap_early_serial_init(void)
-{
-       omap_cfg_reg(UART1_TX);
-       omap_cfg_reg(UART1_RTS);
-
-       omap_cfg_reg(UART2_TX);
-       omap_cfg_reg(UART2_RTS);
-
-       omap_cfg_reg(UART3_TX);
-       omap_cfg_reg(UART3_RX);
-}
-
-static void __init omap_generic_init(void)
-{
-       if (!machine_is_omap_generic())
-               return;
-
-       /*
-        * Make sure the serial ports are muxed on at this point.
-        * You have to mux them off in device drivers later on
-        * if not needed.
-        */
-       if (cpu_is_omap1510()) {
-               omap_early_serial_init();
-       }
-}
-
-static void __init omap_generic_map_io(void)
-{
-       omap_map_io();
-}
-
-MACHINE_START(OMAP_GENERIC, "Generic OMAP-1510/1610")
-       MAINTAINER("Tony Lindgren <tony@atomide.com>")
-       BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
-       BOOT_PARAMS(0x10000100)
-       MAPIO(omap_generic_map_io)
-       INITIRQ(omap_generic_init_irq)
-       INIT_MACHINE(omap_generic_init)
-MACHINE_END
diff --git a/arch/arm/mach-omap/omap-perseus2.c b/arch/arm/mach-omap/omap-perseus2.c
deleted file mode 100644 (file)
index ec05093..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * linux/arch/arm/mach-omap/omap-perseus2.c
- *
- * Modified from omap-generic.c
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <asm/arch/clocks.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/mux.h>
-
-#include <asm/arch/omap-perseus2.h>
-
-#include "common.h"
-
-void omap_perseus2_init_irq(void)
-{
-       omap_init_irq();
-}
-
-static struct resource smc91x_resources[] = {
-       [0] = {
-               .start  = OMAP730_FPGA_ETHR_START,      /* Physical */
-               .end    = OMAP730_FPGA_ETHR_START + SZ_4K,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 0,
-               .end    = 0,
-               .flags  = INT_ETHER,
-       },
-};
-
-static struct platform_device smc91x_device = {
-       .name           = "smc91x",
-       .id             = 0,
-       .num_resources  = ARRAY_SIZE(smc91x_resources),
-       .resource       = smc91x_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-       &smc91x_device,
-};
-
-static void __init omap_perseus2_init(void)
-{
-       if (!machine_is_omap_perseus2())
-               return;
-
-       (void) platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-/* Only FPGA needs to be mapped here. All others are done with ioremap */
-static struct map_desc omap_perseus2_io_desc[] __initdata = {
-       {OMAP730_FPGA_BASE, OMAP730_FPGA_START, OMAP730_FPGA_SIZE,
-        MT_DEVICE},
-};
-
-static void __init omap_perseus2_map_io(void)
-{
-       omap_map_io();
-       iotable_init(omap_perseus2_io_desc,
-                    ARRAY_SIZE(omap_perseus2_io_desc));
-
-       /* Early, board-dependent init */
-
-       /*
-        * Hold GSM Reset until needed
-        */
-       *DSP_M_CTL &= ~1;
-
-       /*
-        * UARTs -> done automagically by 8250 driver
-        */
-
-       /*
-        * CSx timings, GPIO Mux ... setup
-        */
-
-       /* Flash: CS0 timings setup */
-       *((volatile __u32 *) OMAP_FLASH_CFG_0) = 0x0000fff3;
-       *((volatile __u32 *) OMAP_FLASH_ACFG_0) = 0x00000088;
-
-       /*
-        * Ethernet support trough the debug board
-        * CS1 timings setup
-        */
-       *((volatile __u32 *) OMAP_FLASH_CFG_1) = 0x0000fff3;
-       *((volatile __u32 *) OMAP_FLASH_ACFG_1) = 0x00000000;
-
-       /*
-        * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
-        * It is used as the Ethernet controller interrupt
-        */
-       *((volatile __u32 *) PERSEUS2_IO_CONF_9) &= 0x1FFFFFFF;
-}
-
-MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
-       MAINTAINER("Kevin Hilman <k-hilman@ti.com>")
-       BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
-       BOOT_PARAMS(0x10000100)
-       MAPIO(omap_perseus2_map_io)
-       INITIRQ(omap_perseus2_init_irq)
-       INIT_MACHINE(omap_perseus2_init)
-MACHINE_END
diff --git a/arch/arm/mach-s3c2410/gpio.c b/arch/arm/mach-s3c2410/gpio.c
deleted file mode 100644 (file)
index 450b132..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* linux/arch/arm/mach-s3c2410/gpio.c
- *
- * Copyright (c) 2004 Simtec Electronics
- * Ben Dooks <ben@simtec.co.uk>
- *
- * S3C2410 GPIO support
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-
-#include <asm/hardware.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-
-#include <asm/arch/regs-gpio.h>
-
-void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function)
-{
-       unsigned long base = S3C2410_GPIO_BASE(pin);
-       unsigned long shift = 1;
-       unsigned long mask = 3;
-       unsigned long con;
-       unsigned long flags;
-
-       if (pin < S3C2410_GPIO_BANKB) {
-               shift = 0;
-               mask  = 1;
-       }
-
-       mask <<= S3C2410_GPIO_OFFSET(pin);
-
-       local_irq_save(flags);
-
-       con = __raw_readl(base + 0x00);
-
-       con &= mask << shift;
-       con |= function;
-
-       __raw_writel(con, base + 0x00);
-
-       local_irq_restore(flags);
-}
-
-void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
-{
-       unsigned long base = S3C2410_GPIO_BASE(pin);
-       unsigned long offs = S3C2410_GPIO_OFFSET(pin);
-       unsigned long flags;
-       unsigned long up;
-
-       if (pin < S3C2410_GPIO_BANKB)
-               return;
-
-       local_irq_save(flags);
-
-       up = __raw_readl(base + 0x08);
-       up &= 1 << offs;
-       up |= to << offs;
-       __raw_writel(up, base + 0x08);
-
-       local_irq_restore(flags);
-}
-
-void s3c2410_gpio_setpin(unsigned int pin, unsigned int to)
-{
-       unsigned long base = S3C2410_GPIO_BASE(pin);
-       unsigned long offs = S3C2410_GPIO_OFFSET(pin);
-       unsigned long flags;
-       unsigned long dat;
-
-       local_irq_save(flags);
-
-       dat = __raw_readl(base + 0x04);
-       dat &= 1 << offs;
-       dat |= to << offs;
-       __raw_writel(dat, base + 0x04);
-
-       local_irq_restore(flags);
-}
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
deleted file mode 100644 (file)
index bfadbd4..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/***********************************************************************
- *
- * linux/arch/arm/mach-s3c2410/mach-smdk2410.c
- *
- * Copyright (C) 2004 by FS Forth-Systeme GmbH
- * All rights reserved.
- *
- * $Id: mach-smdk2410.c,v 1.1 2004/05/11 14:15:38 mpietrek Exp $
- * @Author: Jonas Dietsche
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- * @History:
- * derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by
- * Ben Dooks <ben@simtec.co.uk>
- ***********************************************************************/
-
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <linux/list.h>
-#include <linux/timer.h>
-#include <linux/init.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/irq.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/mach-types.h>
-
-#include <asm/arch/regs-serial.h>
-
-#include "s3c2410.h"
-
-
-static struct map_desc smdk2410_iodesc[] __initdata = {
-  /* nothing here yet */
-};
-
-#define UCON S3C2410_UCON_DEFAULT
-#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
-#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
-
-/* base baud rate for all our UARTs */
-static unsigned long smdk2410_serial_clock = 24*1000*1000;
-
-static struct s3c2410_uartcfg smdk2410_uartcfgs[] = {
-       [0] = {
-               .hwport      = 0,
-               .flags       = 0,
-               .clock       = &smdk2410_serial_clock,
-               .ucon        = UCON,
-               .ulcon       = ULCON,
-               .ufcon       = UFCON,
-       },
-       [1] = {
-               .hwport      = 1,
-               .flags       = 0,
-               .clock       = &smdk2410_serial_clock,
-               .ucon        = UCON,
-               .ulcon       = ULCON,
-               .ufcon       = UFCON,
-       },
-       [2] = {
-               .hwport      = 2,
-               .flags       = 0,
-               .clock       = &smdk2410_serial_clock,
-               .ucon        = UCON,
-               .ulcon       = ULCON,
-               .ufcon       = UFCON,
-       }
-};
-
-
-void __init smdk2410_map_io(void)
-{
-       s3c2410_map_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
-       s3c2410_uartcfgs = smdk2410_uartcfgs;
-}
-
-void __init smdk2410_init_irq(void)
-{
-       s3c2410_init_irq();
-}
-
-void __init smdk2410_init_time(void)
-{
-       s3c2410_init_time();
-}
-
-MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch
-                                   * to SMDK2410 */
-     MAINTAINER("Jonas Dietsche")
-     BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
-     BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
-     MAPIO(smdk2410_map_io)
-     INITIRQ(smdk2410_init_irq)
-     INITTIME(smdk2410_init_time)
-MACHINE_END
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
deleted file mode 100644 (file)
index 23bf73e..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * linux/arch/arm/mach-sa1100/collie.c
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains all Collie-specific tweaks.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * ChangeLog:
- *  03-06-2004 John Lenz <jelenz@wisc.edu>
- *  06-04-2002 Chris Larson <kergoth@digitalnemesis.net>
- *  04-16-2001 Lineo Japan,Inc. ...
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/timer.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/irq.h>
-#include <asm/setup.h>
-#include <asm/arch/collie.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach/serial_sa1100.h>
-
-#include <asm/hardware/locomo.h>
-
-#include "generic.h"
-
-static void __init scoop_init(void)
-{
-
-#define        COLLIE_SCP_INIT_DATA(adr,dat)   (((adr)<<16)|(dat))
-#define        COLLIE_SCP_INIT_DATA_END        ((unsigned long)-1)
-       static const unsigned long scp_init[] = {
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_MCR, 0x0140),   // 00
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_MCR, 0x0100),
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_CDR, 0x0000),   // 04
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_CPR, 0x0000),   // 0C
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_CCR, 0x0000),   // 10
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_IMR, 0x0000),   // 18
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_IRM, 0x00FF),   // 14
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_ISR, 0x0000),   // 1C
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_IRM, 0x0000),
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_GPCR, COLLIE_SCP_IO_DIR),       // 20
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_GPWR, COLLIE_SCP_IO_OUT),       // 24
-               COLLIE_SCP_INIT_DATA_END
-       };
-       int i;
-       for (i = 0; scp_init[i] != COLLIE_SCP_INIT_DATA_END; i++) {
-               int adr = scp_init[i] >> 16;
-               COLLIE_SCP_REG(adr) = scp_init[i] & 0xFFFF;
-       }
-
-}
-
-static struct resource locomo_resources[] = {
-       [0] = {
-               .start          = 0x40000000,
-               .end            = 0x40001fff,
-               .flags          = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start          = IRQ_GPIO25,
-               .end            = IRQ_GPIO25,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device locomo_device = {
-       .name           = "locomo",
-       .id             = 0,
-       .num_resources  = ARRAY_SIZE(locomo_resources),
-       .resource       = locomo_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
-       &locomo_device,
-};
-
-static void __init collie_init(void)
-{
-       int ret = 0;
-
-       /* cpu initialize */
-       GAFR = ( GPIO_SSP_TXD | \
-                GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SSP_CLK | GPIO_TIC_ACK | \
-                GPIO_32_768kHz );
-
-       GPDR = ( GPIO_LDD8 | GPIO_LDD9 | GPIO_LDD10 | GPIO_LDD11 | GPIO_LDD12 | \
-                GPIO_LDD13 | GPIO_LDD14 | GPIO_LDD15 | GPIO_SSP_TXD | \
-                GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SDLC_SCLK | \
-                GPIO_SDLC_AAF | GPIO_UART_SCLK1 | GPIO_32_768kHz );
-       GPLR = GPIO_GPIO18;
-
-       // PPC pin setting
-       PPDR = ( PPC_LDD0 | PPC_LDD1 | PPC_LDD2 | PPC_LDD3 | PPC_LDD4 | PPC_LDD5 | \
-                PPC_LDD6 | PPC_LDD7 | PPC_L_PCLK | PPC_L_LCLK | PPC_L_FCLK | PPC_L_BIAS | \
-                PPC_TXD1 | PPC_TXD2 | PPC_RXD2 | PPC_TXD3 | PPC_TXD4 | PPC_SCLK | PPC_SFRM );
-
-       PSDR = ( PPC_RXD1 | PPC_RXD2 | PPC_RXD3 | PPC_RXD4 );
-
-       GAFR |= GPIO_32_768kHz;
-       GPDR |= GPIO_32_768kHz;
-       TUCR  = TUCR_32_768kHz;
-
-       scoop_init();
-
-       ret = platform_add_devices(devices, ARRAY_SIZE(devices));
-       if (ret) {
-               printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
-       }
-}
-
-static struct map_desc collie_io_desc[] __initdata = {
-       /* virtual     physical    length      type */
-       {0xe8000000, 0x00000000, 0x02000000, MT_DEVICE},        /* 32M main flash (cs0) */
-       {0xea000000, 0x08000000, 0x02000000, MT_DEVICE},        /* 32M boot flash (cs1) */
-       {0xf0000000, 0x40000000, 0x01000000, MT_DEVICE},        /* 16M LOCOMO  & SCOOP (cs4) */
-};
-
-static void __init collie_map_io(void)
-{
-       sa1100_map_io();
-       iotable_init(collie_io_desc, ARRAY_SIZE(collie_io_desc));
-}
-
-MACHINE_START(COLLIE, "Sharp-Collie")
-       BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
-       MAPIO(collie_map_io)
-       INITIRQ(sa1100_init_irq)
-       INIT_MACHINE(collie_init)
-       INITTIME(sa1100_init_time)
-MACHINE_END
diff --git a/arch/arm/mach-tbox/Makefile b/arch/arm/mach-tbox/Makefile
deleted file mode 100644 (file)
index 4bd8ebd..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-# Object file lists.
-
-obj-y                  := core.o
-obj-m                  :=
-obj-n                  :=
-obj-                   :=
-
diff --git a/arch/arm/mach-tbox/core.c b/arch/arm/mach-tbox/core.c
deleted file mode 100644 (file)
index db9ac78..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *  linux/arch/arm/mm/mm-tbox.c
- *
- *  Copyright (C) 1998, 1999, 2000 Phil Blundell
- *  Copyright (C) 1998-1999 Russell King
- *
- *  Extra MM routines for the Tbox architecture
- */
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include <asm/elf.h>
-#include <asm/setup.h>
-#include <asm/mach-types.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-extern unsigned long soft_irq_mask;
-
-static void tbox_mask_irq(unsigned int irq)
-{
-       __raw_writel(0, INTCONT + (irq << 2));
-       soft_irq_mask &= ~(1<<irq);
-}
-
-static void tbox_unmask_irq(unsigned int irq)
-{
-       soft_irq_mask |= (1<<irq);
-       __raw_writel(1, INTCONT + (irq << 2));
-}
-static void tbox_init_irq(void)
-{
-       unsigned int i;
-
-       /* Disable all interrupts initially. */
-       for (i = 0; i < NR_IRQS; i++) {
-               if (i <= 10 || (i >= 12 && i <= 13)) {
-                       irq_desc[i].valid       = 1;
-                       irq_desc[i].probe_ok    = 0;
-                       irq_desc[i].mask_ack    = tbox_mask_irq;
-                       irq_desc[i].mask        = tbox_mask_irq;
-                       irq_desc[i].unmask      = tbox_unmask_irq;
-                       tbox_mask_irq(i);
-               } else {
-                       irq_desc[i].valid       = 0;
-                       irq_desc[i].probe_ok    = 0;
-               }
-       }
-}
-
-static struct map_desc tbox_io_desc[] __initdata = {
-       /* See hardware.h for details */
-       { IO_BASE,      IO_START,       0x00100000, MT_DEVICE }
-};
-
-static void __init tbox_map_io(void)
-{
-       iotable_init(tbox_io_desc, ARRAY_SIZE(tbox_io_desc));
-}
-
-MACHINE_START(TBOX, "unknown-TBOX")
-       MAINTAINER("Philip Blundell")
-       BOOT_MEM(0x80000000, 0x00400000, 0xe0000000)
-       MAPIO(tbox_map_io)
-       INITIRQ(tbox_init_irq)
-MACHINE_END
-
index ce96fd3..b40758b 100644 (file)
@@ -327,6 +327,8 @@ config DEBUG_LL
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 57b9fb1..78cd893 100644 (file)
@@ -691,6 +691,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 481edca..93d52b7 100644 (file)
@@ -210,6 +210,8 @@ config FRAME_POINTER
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
diff --git a/arch/cris/kernel/hexify.c b/arch/cris/kernel/hexify.c
deleted file mode 100644 (file)
index daa331f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <stdio.h>
-
-
-void main()
-{
-       int c;
-       int comma=0;
-       int count=0;
-       while((c=getchar())!=EOF)
-       {
-               unsigned char x=c;
-               if(comma)
-                       printf(",");
-               else
-                       comma=1;
-               if(count==8)
-               {
-                       count=0;
-                       printf("\n");
-               }
-               if(count==0)
-                       printf("\t");
-               printf("0x%02X",c);
-               count++;
-       }
-       if(count)
-               printf("\n");
-       exit(0);
-}
-
-               
diff --git a/arch/cris/kernel/ksyms.c b/arch/cris/kernel/ksyms.c
deleted file mode 100644 (file)
index 1161a25..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/user.h>
-#include <linux/elfcore.h>
-#include <linux/sched.h>
-#include <linux/in6.h>
-#include <linux/interrupt.h>
-#include <linux/smp_lock.h>
-#include <linux/pm.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/tty.h>
-#include <asm/semaphore.h>
-#include <asm/processor.h>
-#include <asm/uaccess.h>
-#include <asm/checksum.h>
-#include <asm/io.h>
-#include <asm/hardirq.h>
-#include <asm/delay.h>
-#include <asm/irq.h>
-#include <asm/pgtable.h>
-
-extern void dump_thread(struct pt_regs *, struct user *);
-extern unsigned long get_cmos_time(void);
-extern void __Udiv(void);
-extern void __Umod(void);
-extern void __Div(void);
-extern void __Mod(void);
-extern void __ashrdi3(void);
-extern void iounmap(void *addr);
-
-/* Platform dependent support */
-EXPORT_SYMBOL(dump_thread);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(kernel_thread);
-EXPORT_SYMBOL(get_cmos_time);
-EXPORT_SYMBOL(loops_per_usec);
-
-/* String functions */
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(strpbrk);
-EXPORT_SYMBOL(strstr);
-EXPORT_SYMBOL(strcpy);
-EXPORT_SYMBOL(strchr);
-EXPORT_SYMBOL(strcmp);
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strcat);
-EXPORT_SYMBOL(strncat);
-EXPORT_SYMBOL(strncmp);
-EXPORT_SYMBOL(strncpy);
-
-/* Math functions */
-EXPORT_SYMBOL(__Udiv);
-EXPORT_SYMBOL(__Umod);
-EXPORT_SYMBOL(__Div);
-EXPORT_SYMBOL(__Mod);
-EXPORT_SYMBOL(__ashrdi3);
-
-/* Memory functions */
-EXPORT_SYMBOL(__ioremap);
-EXPORT_SYMBOL(iounmap);
-
-/* Semaphore functions */
-EXPORT_SYMBOL(__up);
-EXPORT_SYMBOL(__down);
-EXPORT_SYMBOL(__down_interruptible);
-EXPORT_SYMBOL(__down_trylock);
-
-/* Export shadow registers for the CPU I/O pins */
-EXPORT_SYMBOL(genconfig_shadow);
-EXPORT_SYMBOL(port_pa_data_shadow);
-EXPORT_SYMBOL(port_pa_dir_shadow);
-EXPORT_SYMBOL(port_pb_data_shadow);
-EXPORT_SYMBOL(port_pb_dir_shadow);
-EXPORT_SYMBOL(port_pb_config_shadow);
-EXPORT_SYMBOL(port_g_data_shadow);
-
-/* Userspace access functions */
-EXPORT_SYMBOL(__copy_user_zeroing);
-EXPORT_SYMBOL(__copy_user);
-
-/* Cache flush functions */
-EXPORT_SYMBOL(flush_etrax_cache);
-EXPORT_SYMBOL(prepare_rx_descriptor);
-
-#undef memcpy
-#undef memset
-extern void * memset(void *, int, __kernel_size_t);
-extern void * memcpy(void *, const void *, __kernel_size_t);
-EXPORT_SYMBOL_NOVERS(memcpy);
-EXPORT_SYMBOL_NOVERS(memset);
-
-
index 8497cfb..4735658 100644 (file)
@@ -253,6 +253,8 @@ config CONFIG_BLKDEV_RESERVE_ADDRESS
          BLKDEV start address.
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 5905cee..5177700 100644 (file)
@@ -80,6 +80,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index af97501..15b003b 100644 (file)
@@ -424,6 +424,54 @@ config X86_OOSTORE
        depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6) && MTRR
        default y
 
+config X86_4G
+       bool "4 GB kernel-space and 4 GB user-space virtual memory support"
+       help
+          This option is only useful for systems that have more than 1 GB
+          of RAM.
+
+          The default kernel VM layout leaves 1 GB of virtual memory for
+          kernel-space mappings, and 3 GB of VM for user-space applications.
+          This option ups both the kernel-space VM and the user-space VM to
+          4 GB.
+
+          The cost of this option is additional TLB flushes done at
+          system-entry points that transition from user-mode into kernel-mode.
+          I.e. system calls and page faults, and IRQs that interrupt user-mode
+          code. There's also additional overhead to kernel operations that copy
+          memory to/from user-space. The overhead from this is hard to tell and
+          depends on the workload - it can be anything from no visible overhead
+          to 20-30% overhead. A good rule of thumb is to count with a runtime
+          overhead of 20%.
+
+          The upside is the much increased kernel-space VM, which more than
+          quadruples the maximum amount of RAM supported. Kernels compiled with
+          this option boot on 64GB of RAM and still have more than 3.1 GB of
+          'lowmem' left. Another bonus is that highmem IO bouncing decreases,
+          if used with drivers that still use bounce-buffers.
+
+          There's also a 33% increase in user-space VM size - database
+          applications might see a boost from this.
+
+          But the cost of the TLB flushes and the runtime overhead has to be
+          weighed against the bonuses offered by the larger VM spaces. The
+          dividing line depends on the actual workload - there might be 4 GB
+          systems that benefit from this option. Systems with less than 4 GB
+          of RAM will rarely see a benefit from this option - but it's not
+          out of question, the exact circumstances have to be considered.
+
+config X86_SWITCH_PAGETABLES
+       def_bool X86_4G
+
+config X86_4G_VM_LAYOUT
+       def_bool X86_4G
+
+config X86_UACCESS_INDIRECT
+       def_bool X86_4G
+
+config X86_HIGH_ENTRY
+       def_bool X86_4G
+
 config HPET_TIMER
        bool "HPET Timer Support"
        help
@@ -504,6 +552,19 @@ config PREEMPT
          Say Y here if you are building a kernel for a desktop, embedded
          or real-time system.  Say N if you are unsure.
 
+config PREEMPT_VOLUNTARY
+       bool "Voluntary Kernel Preemption"
+       depends on !PREEMPT
+       default y
+       help
+         This option reduces the latency of the kernel by adding more
+         "explicit preemption points" to the kernel code. These new
+         preemption points have been selected to minimize the maximum
+         latency of rescheduling, providing faster application reactions.
+
+         Say Y here if you are building a kernel for a desktop system.
+         Say N if you are unsure.
+
 config X86_UP_APIC
        bool "Local APIC support on uniprocessors" if !SMP
        depends on !(X86_VISWS || X86_VOYAGER)
@@ -1188,6 +1249,58 @@ source "arch/i386/oprofile/Kconfig"
 
 menu "Kernel hacking"
 
+config CRASH_DUMP
+       tristate "Crash dump support (EXPERIMENTAL)"
+       depends on EXPERIMENTAL
+       default n
+       ---help---
+         Say Y here to enable saving an image of system memory when a panic
+         or other error occurs. Dumps can also be forced with the SysRq+d
+         key if MAGIC_SYSRQ is enabled.
+
+config CRASH_DUMP_BLOCKDEV
+       tristate "Crash dump block device driver"
+       depends on CRASH_DUMP
+       help
+         Say Y to allow saving crash dumps directly to a disk device.
+
+config CRASH_DUMP_NETDEV
+       tristate "Crash dump network device driver"
+       depends on CRASH_DUMP
+       help
+         Say Y to allow saving crash dumps over a network device.
+
+config CRASH_DUMP_MEMDEV
+       bool "Crash dump staged memory driver"
+       depends on CRASH_DUMP
+       help
+         Say Y to allow intermediate saving crash dumps in spare 
+         memory pages which would then be written out to disk
+         later.
+
+config CRASH_DUMP_SOFTBOOT
+       bool "Save crash dump across a soft reboot"
+       depends on CRASH_DUMP_MEMDEV
+       help
+         Say Y to allow a crash dump to be preserved in memory
+         pages across a soft reboot and written out to disk
+         thereafter. For this to work, CRASH_DUMP must be 
+         configured as part of the kernel (not as a module).
+
+config CRASH_DUMP_COMPRESS_RLE
+       tristate "Crash dump RLE compression"
+       depends on CRASH_DUMP
+       help
+         Say Y to allow saving dumps with Run Length Encoding compression.
+
+config CRASH_DUMP_COMPRESS_GZIP
+       tristate "Crash dump GZIP compression"
+       select ZLIB_INFLATE
+       select ZLIB_DEFLATE
+       depends on CRASH_DUMP
+       help
+         Say Y to allow saving dumps with Gnu Zip compression.
+
 config DEBUG_KERNEL
        bool "Kernel debugging"
        help
@@ -1289,15 +1402,6 @@ config FRAME_POINTER
          If you don't debug the kernel, you can say N, but we may not be able
          to solve problems without frame pointers.
 
-config 4KSTACKS
-       bool "Use 4Kb for kernel stacks instead of 8Kb"
-       help
-         If you say Y here the kernel will use a 4Kb stacksize for the
-         kernel stack attached to each process/thread. This facilitates
-         running more threads on a system and also reduces the pressure
-         on the VM subsystem for higher order allocations. This option
-         will also use IRQ stacks to compensate for the reduced stackspace.
-
 config X86_FIND_SMP_CONFIG
        bool
        depends on X86_LOCAL_APIC || X86_VOYAGER
@@ -1310,6 +1414,8 @@ config X86_MPPARSE
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 1e446b2..acecbae 100644 (file)
@@ -20,7 +20,7 @@ OBJCOPYFLAGS  := -O binary -R .note -R .comment -S
 LDFLAGS_vmlinux :=
 CHECK          := $(CHECK) -D__i386__=1
 
-CFLAGS += -pipe -msoft-float
+CFLAGS += -pipe -msoft-float -m32 -fno-builtin-sprintf -fno-builtin-log2 -fno-builtin-puts 
 
 # prevent gcc from keeping the stack 16 byte aligned
 CFLAGS += $(call check_gcc,-mpreferred-stack-boundary=2,)
@@ -113,7 +113,7 @@ drivers-$(CONFIG_OPROFILE)          += arch/i386/oprofile/
 drivers-$(CONFIG_PM)                   += arch/i386/power/
 
 CFLAGS += $(mflags-y)
-AFLAGS += $(mflags-y)
+AFLAGS += $(mflags-y) -m32
 
 boot := arch/i386/boot
 
index d70853d..feb561e 100644 (file)
@@ -102,3 +102,4 @@ zlilo: $(BOOTIMAGE)
 
 install: $(BOOTIMAGE)
        sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
+       if [ -f init/kerntypes.o ]; then cp init/kerntypes.o $(INSTALL_PATH)/Kerntypes; fi
index d606d06..5dfd82f 100644 (file)
@@ -156,7 +156,7 @@ cmd_line_ptr:       .long 0                 # (Header version 0x0202 or later)
                                        # can be located anywhere in
                                        # low memory 0x10000 or higher.
 
-ramdisk_max:   .long (MAXMEM-1) & 0x7fffffff
+ramdisk_max:   .long (__MAXMEM-1) & 0x7fffffff
                                        # (Header version 0x0203 or later)
                                        # The highest safe address for
                                        # the contents of an initrd
index 7e2c665..f81130f 100644 (file)
@@ -126,8 +126,12 @@ video:     pushw   %ds             # We use different segments
        call    mode_set                        # Set the mode
        jc      vid1
 
+#if 0
        leaw    badmdt, %si                     # Invalid mode ID
        call    prtstr
+#else
+       jmp     vid1
+#endif /* CONFIG_VIDEO_IGNORE_BAD_MODE */
 vid2:  call    mode_menu
 vid1:
 #ifdef CONFIG_VIDEO_RETAIN
diff --git a/arch/i386/boot98/Makefile b/arch/i386/boot98/Makefile
deleted file mode 100644 (file)
index ccedae2..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# arch/i386/boot/Makefile
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1994 by Linus Torvalds
-#
-
-# ROOT_DEV specifies the default root-device when making the image.
-# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
-# the default of FLOPPY is used by 'build'.
-
-ROOT_DEV := CURRENT
-
-# If you want to preset the SVGA mode, uncomment the next line and
-# set SVGA_MODE to whatever number you want.
-# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
-# The number is the same as you would ordinarily press at bootup.
-
-SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
-
-# If you want the RAM disk device, define this to be the size in blocks.
-
-#RAMDISK := -DRAMDISK=512
-
-targets                := vmlinux.bin bootsect bootsect.o setup setup.o \
-                  zImage bzImage
-subdir-        := compressed
-
-host-progs     := tools/build
-
-# ---------------------------------------------------------------------------
-
-$(obj)/zImage:  IMAGE_OFFSET := 0x1000
-$(obj)/zImage:  EXTRA_AFLAGS := -traditional $(SVGA_MODE) $(RAMDISK)
-$(obj)/bzImage: IMAGE_OFFSET := 0x100000
-$(obj)/bzImage: EXTRA_AFLAGS := -traditional $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
-$(obj)/bzImage: BUILDFLAGS   := -b
-
-quiet_cmd_image = BUILD   $@
-cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
-           $(obj)/vmlinux.bin $(ROOT_DEV) > $@
-
-$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
-                             $(obj)/vmlinux.bin $(obj)/tools/build FORCE
-       $(call if_changed,image)
-       @echo 'Kernel: $@ is ready'
-
-$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
-       $(call if_changed,objcopy)
-
-LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary
-LDFLAGS_setup   := -Ttext 0x0 -s --oformat binary -e begtext
-
-$(obj)/setup $(obj)/bootsect: %: %.o FORCE
-       $(call if_changed,ld)
-
-$(obj)/compressed/vmlinux: FORCE
-       $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
-
-# Set this if you want to pass append arguments to the zdisk/fdimage kernel
-FDARGS = 
-
-$(obj)/mtools.conf: $(src)/mtools.conf.in
-       sed -e 's|@OBJ@|$(obj)|g' < $< > $@
-
-# This requires write access to /dev/fd0
-zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
-       MTOOLSRC=$(obj)/mtools.conf mformat a:                  ; sync
-       syslinux /dev/fd0                                       ; sync
-       echo 'default linux $(FDARGS)' | \
-               MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
-       MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux  ; sync
-
-# These require being root or having syslinux 2.02 or higher installed
-fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
-       dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
-       MTOOLSRC=$(obj)/mtools.conf mformat v:                  ; sync
-       syslinux $(obj)/fdimage                                 ; sync
-       echo 'default linux $(FDARGS)' | \
-               MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
-       MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux  ; sync
-
-fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
-       dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
-       MTOOLSRC=$(obj)/mtools.conf mformat w:                  ; sync
-       syslinux $(obj)/fdimage                                 ; sync
-       echo 'default linux $(FDARGS)' | \
-               MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
-       MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux  ; sync
-
-zlilo: $(BOOTIMAGE)
-       if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
-       if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
-       cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
-       cp System.map $(INSTALL_PATH)/
-       if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
-
-install: $(BOOTIMAGE)
-       sh $(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
diff --git a/arch/i386/boot98/bootsect.S b/arch/i386/boot98/bootsect.S
deleted file mode 100644 (file)
index dc7d86c..0000000
+++ /dev/null
@@ -1,397 +0,0 @@
-/*     
- *     bootsect.S - boot sector for NEC PC-9800 series
- *
- *     Linux/98 project at Kyoto University Microcomputer Club (KMC)
- *                 FUJITA Norimasa, TAKAI Kousuke  1997-1998
- *     rewritten by TAKAI Kousuke (as86 -> gas), Nov 1999
- *
- * Based on:
- *     bootsect.S              Copyright (C) 1991, 1992 Linus Torvalds
- *     modified by Drew Eckhardt
- *     modified by Bruce Evans (bde)
- *
- * bootsect.S is loaded at 0x1FC00 or 0x1FE00 by the bios-startup routines,
- * and moves itself out of the way to address 0x90000, and jumps there.
- *
- * It then loads 'setup' directly after itself (0x90200), and the system
- * at 0x10000, using BIOS interrupts. 
- *
- * NOTE! currently system is at most (8*65536-4096) bytes long. This should 
- * be no problem, even in the future. I want to keep it simple. This 508 kB
- * kernel size should be enough, especially as this doesn't contain the
- * buffer cache as in minix (and especially now that the kernel is 
- * compressed :-)
- *
- * The loader has been made as simple as possible, and continuous
- * read errors will result in a unbreakable loop. Reboot by hand. It
- * loads pretty fast by getting whole tracks at a time whenever possible.
- */
-
-#include <linux/config.h>              /* for CONFIG_ROOT_RDONLY */
-#include <asm/boot.h>
-
-SETUPSECTS     = 4                     /* default nr of setup-sectors */
-BOOTSEG                = 0x1FC0                /* original address of boot-sector */
-INITSEG                = DEF_INITSEG           /* we move boot here - out of the way */
-SETUPSEG       = DEF_SETUPSEG          /* setup starts here */
-SYSSEG         = DEF_SYSSEG            /* system loaded at 0x10000 (65536) */
-SYSSIZE                = DEF_SYSSIZE           /* system size: # of 16-byte clicks */
-                                       /* to be loaded */
-ROOT_DEV       = 0                     /* ROOT_DEV is now written by "build" */
-SWAP_DEV       = 0                     /* SWAP_DEV is now written by "build" */
-
-#ifndef SVGA_MODE
-#define SVGA_MODE ASK_VGA
-#endif
-
-#ifndef RAMDISK
-#define RAMDISK 0
-#endif 
-
-#ifndef ROOT_RDONLY
-#define ROOT_RDONLY 1
-#endif
-
-/* normal/hireso text VRAM segments */
-#define NORMAL_TEXT    0xa000
-#define HIRESO_TEXT    0xe000
-
-/* bios work area addresses */
-#define EXPMMSZ                0x0401
-#define BIOS_FLAG      0x0501
-#define        DISK_BOOT       0x0584
-
-.code16
-.text
-
-.global _start
-_start:
-
-#if 0 /* hook for debugger, harmless unless BIOS is fussy (old HP) */
-       int     $0x3
-#endif
-       jmp     real_start
-       .ascii  "Linux 98"
-       .word   0
-real_start:
-       xorw    %di, %di                /* %di = 0 */
-       movw    %di, %ss                /* %ss = 0 */
-       movw    $0x03F0, %sp
-       pushw   %cx                     /* for hint */
-
-       movw    $0x0A00, %ax            /* normal mode defaults (80x25) */
-
-       testb   $0x08, %ss:BIOS_FLAG    /* check hi-reso bit */
-       jnz     set_crt_mode
-/*
- * Hi-Reso (high-resolution) machine.
- *
- * Some hi-reso machines have no RAMs on bank 8/A (0x080000 - 0x0BFFFF).
- * On such machines we get two RAM banks from top of protect menory and
- * map them on bank 8/A.
- * These work-around must be done before moving myself on INITSEG (0x090000-).
- */
-       movw    $(HIRESO_TEXT >> 8), %cs:(vram + 1)     /* text VRAM segment */
-
-       /* set memory window */
-       movb    $0x08, %al
-       outb    %al, $0x91              /* map native RAM (if any) */
-       movb    $0x0A, %al
-       outb    %al, $0x93
-
-       /* check bank ram A */
-       pushw   $0xA500
-       popw    %ds
-       movw    (%di), %cx              /* %si == 0 from entry */
-       notw    %cx
-       movw    %cx, (%di)
-
-       movw    $0x43F, %dx             /* cache flush for 486 and up. */
-       movb    $0xA0, %al
-       outb    %al, %dx
-       
-       cmpw    %cx, (%di)
-       je      hireso_done
-
-       /* 
-        * Write test failed; we have no native RAM on 080000h - 0BFFFFh.
-        * Take 256KB of RAM from top of protected memory.
-        */
-       movb    %ss:EXPMMSZ, %al
-       subb    $2, %al                 /* reduce 2 x 128KB */
-       movb    %al, %ss:EXPMMSZ
-       addb    %al, %al
-       addb    $0x10, %al
-       outb    %al, $0x91
-       addb    $2, %al
-       outb    %al, $0x93
-
-hireso_done:
-       movb    $0x10, %al              /* CRT mode 80x31, %ah still 0Ah */
-
-set_crt_mode:
-       int     $0x18                   /* set CRT mode */
-
-       movb    $0x0C, %ah              /* turn on text displaying */
-       int     $0x18
-
-       xorw    %dx, %dx                /* position cursor to home */
-       movb    $0x13, %ah
-       int     $0x18
-
-       movb    $0x11, %ah              /* turn cursor displaying on */
-       int     $0x18
-
-       /* move 1 kilobytes from [BOOTSEG:0000h] to [INITSEG:0000h] */
-       cld
-       xorw    %si, %si
-       pushw   $INITSEG
-       popw    %es
-       movw    $512, %cx               /* %di == 0 from entry */
-       rep
-       cs
-       movsw
-
-       ljmp    $INITSEG, $go
-
-go:
-       pushw   %cs
-       popw    %ds             /* %ds = %cs */
-
-       popw    %dx             /* %dh = saved %ch passed from BIOS */
-       movb    %ss:DISK_BOOT, %al
-       andb    $0xf0, %al      /* %al = Device Address */
-       movb    $18, %ch        /* 18 secs/track,  512 b/sec (1440 KB) */
-       cmpb    $0x30, %al
-       je      try512
-       cmpb    $0x90, %al      /* 1 MB I/F, 1 MB floppy */
-       je      try1.2M
-       cmpb    $0xf0, %al      /* 640 KB I/F, 1 MB floppy */
-       je      try1.2M
-       movb    $9, %ch         /*  9 secs/track,  512 b/sec ( 720 KB) */
-       cmpb    $0x10, %al      /* 1 MB I/F, 640 KB floppy */
-       je      try512
-       cmpb    $0x70, %al      /* 640 KB I/F, 640 KB floppy */
-       jne     error           /* unknown device? */
-
-       /* XXX: Does it make sense to support 8 secs/track, 512 b/sec 
-               (640 KB) floppy? */
-
-try512:        movb    $2, %cl         /* 512 b/sec */
-lasttry:call   tryload
-/*
- * Display error message and halt
- */
-error: movw    $error_msg, %si
-       call    print
-wait_reboot:
-       movb    $0x0, %ah
-       int     $0x18                   /* wait keyboard input */
-1:     movb    $0, %al
-       outb    %al, $0xF0              /* reset CPU */
-       jmp     1b                      /* just in case... */
-
-try1.2M:cmpb   $2, %dh
-       je      try2HC
-       movw    $0x0803, %cx    /*  8 secs/track, 1024 b/sec (1232 KB) */
-       call    tryload
-       movb    $15, %ch        /* 15 secs/track,  512 b/sec (1200 KB) */
-       jmp     try512
-try2HC:        movw    $0x0F02, %cx    /* 15 secs/track,  512 b/sec (1200 KB) */
-       call    tryload
-       movw    $0x0803, %cx    /*  8 secs/track, 1024 b/sec (1232 KB) */
-       jmp     lasttry
-
-/*
- * Try to load SETUP and SYSTEM provided geometry information in %cx.
- * This routine *will not* return on successful load...
- */
-tryload:
-       movw    %cx, sectlen
-       movb    %ss:DISK_BOOT, %al
-       movb    $0x7, %ah               /* recalibrate the drive */
-       int     $0x1b
-       jc      error                   /* recalibration should succeed */
-
-       /*
-        * Load SETUP into memory. It is assumed that SETUP fits into
-        * first cylinder (2 tracks, 9KB on 2DD, 15-18KB on 2HD).
-        */
-       movb    $0, %bl
-       movb    setup_sects, %bh
-       incb    %bh
-       shlw    %bx                     /* %bx = (setup_sects + 1) * 512 */
-       movw    $128, %bp
-       shlw    %cl, %bp                /* %bp = <sector size> */
-       subw    %bp, %bx                /* length to load */
-       movw    $0x0002, %dx            /* head 0, sector 2 */
-       movb    %cl, %ch                /* `N' for sector address */
-       movb    $0, %cl                 /* cylinder 0 */
-       pushw   %cs
-       popw    %es                     /* %es = %cs (= INITSEG) */
-       movb    $0xd6, %ah              /* read, multi-track, MFM */
-       int     $0x1b                   /* load it! */
-       jc      read_error
-
-       movw    $loading_msg, %si
-       call    print
-
-       movw    $SYSSEG, %ax
-       movw    %ax, %es                /* %es = SYSSEG */
-
-/*
- * This routine loads the system at address 0x10000, making sure
- * no 64kB boundaries are crossed. We try to load it as fast as
- * possible, loading whole tracks whenever we can.
- *
- * in: es - starting address segment (normally 0x1000)
- */
-       movb    %ch, %cl
-       addb    $7, %cl                 /* %cl = log2 <sector_size> */
-       shrw    %cl, %bx                /* %bx = # of phys. sectors in SETUP */
-       addb    %bl, %dl                /* %dl = start sector # of SYSTEM */
-       decb    %dl                     /* %dl is 0-based in below loop */
-
-rp_read_newseg:
-       xorw    %bp, %bp                /* = starting address within segment */
-#ifdef __BIG_KERNEL__
-       bootsect_kludge = 0x220         /* 0x200 (size of bootsector) + 0x20 (offset */
-       lcall   *bootsect_kludge        /* of bootsect_kludge in setup.S */
-#else
-       movw    %es, %ax
-       subw    $SYSSEG, %ax
-#endif
-       cmpw    syssize, %ax
-       ja      boot                    /* done! */
-
-rp_read:
-       movb    sectors, %al
-       addb    %al, %al
-       movb    %al, %ch                /* # of sectors on both surface */
-       subb    %dl, %al                /* # of sectors left on this track */
-       movb    $0, %ah
-       shlw    %cl, %ax                /* # of bytes left on this track */
-       movw    %ax, %bx                /* transfer length */
-       addw    %bp, %ax                /* cross 64K boundary? */
-       jnc     1f                      /* ok. */
-       jz      1f                      /* also ok. */
-       /*
-        * Oops, we are crossing 64K boundary...
-        * Adjust transfer length to make transfer fit in the boundary.
-        *
-        * Note: sector size is assumed to be a measure of 65536.
-        */
-       xorw    %bx, %bx
-       subw    %bp, %bx
-1:     pushw   %dx
-       movw    $dot_msg, %si           /* give progress message */
-       call    print
-       xchgw   %ax, %dx
-       movb    $0, %ah
-       divb    sectors
-       xchgb   %al, %ah
-       xchgw   %ax, %dx                /* %dh = head # / %dl = sector # */
-       incb    %dl                     /* fix %dl to 1-based */
-       pushw   %cx
-       movw    cylinder, %cx
-       movb    $0xd6, %ah              /* read, multi-track, seek, MFM */
-       movb    %ss:DISK_BOOT, %al
-       int     $0x1b
-       popw    %cx
-       popw    %dx
-       jc      read_error
-       movw    %bx, %ax                /* # of bytes just read */
-       shrw    %cl, %ax                /* %ax = # of sectors just read */
-       addb    %al, %dl                /* advance sector # */
-       cmpb    %ch, %dl                /* %ch = # of sectors/cylinder */
-       jb      2f
-       incb    cylinder                /* next cylinder */
-       xorb    %dl, %dl                /* sector 0 */
-2:     addw    %bx, %bp                /* advance offset pointer */
-       jnc     rp_read
-       /* offset pointer wrapped; advance segment pointer. */
-       movw    %es, %ax
-       addw    $0x1000, %ax
-       movw    %ax, %es
-       jmp     rp_read_newseg
-
-read_error:
-       ret
-
-boot:  movw    %cs, %ax                /* = INITSEG */
-       /* movw %ax, %ds */
-       movw    %ax, %ss
-       movw    $0x4000, %sp            /* 0x4000 is arbitrary value >=
-                                        * length of bootsect + length of
-                                        * setup + room for stack;
-                                        * PC-9800 never have BIOS workareas
-                                        * on high memory.
-                                        */
-/*
- * After that we check which root-device to use. If the device is
- * not defined, /dev/fd0 (2, 0) will be used.
- */
-       cmpw    $0, root_dev
-       jne     3f
-       movb    $2, root_dev+1
-3:
-
-/*
- * After that (everything loaded), we jump to the setup-routine
- * loaded directly after the bootblock:
- */
-       ljmp    $SETUPSEG, $0
-
-/*
- * Subroutine for print string on console.
- *     %cs:%si - pointer to message
- */
-print:
-       pushaw
-       pushw   %ds
-       pushw   %es
-       pushw   %cs
-       popw    %ds
-       lesw    curpos, %di             /* %es:%di = current text VRAM addr. */
-1:     xorw    %ax, %ax
-       lodsb
-       testb   %al, %al
-       jz      2f                      /* end of string */
-       stosw                                   /* character code */
-       movb    $0xE1, %es:0x2000-2(%di)        /* character attribute */
-       jmp     1b
-2:     movw    %di, %dx
-       movb    $0x13, %ah
-       int     $0x18                   /* move cursor to current point */
-       popw    %es
-       popw    %ds
-       popaw
-       ret
-
-loading_msg:
-       .string "Loading"
-dot_msg:
-       .string "."
-error_msg:
-       .string "Read Error!"
-
-       .org    490
-
-curpos:        .word   160             /* current cursor position */
-vram:  .word   NORMAL_TEXT     /* text VRAM segment */
-
-cylinder:      .byte   0       /* current cylinder (lower byte)        */
-sectlen:       .byte   0       /* (log2 of <sector size>) - 7          */
-sectors:       .byte   0x0F    /* default is 2HD (15 sector/track)     */
-
-# XXX: This is a fairly snug fit.
-
-.org 497
-setup_sects:   .byte SETUPSECTS
-root_flags:    .word ROOT_RDONLY
-syssize:       .word SYSSIZE
-swap_dev:      .word SWAP_DEV
-ram_size:      .word RAMDISK
-vid_mode:      .word SVGA_MODE
-root_dev:      .word ROOT_DEV
-boot_flag:     .word 0xAA55
diff --git a/arch/i386/boot98/compressed/Makefile b/arch/i386/boot98/compressed/Makefile
deleted file mode 100644 (file)
index 258ea95..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# linux/arch/i386/boot/compressed/Makefile
-#
-# create a compressed vmlinux image from the original vmlinux
-#
-
-targets                := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
-EXTRA_AFLAGS   := -traditional
-
-LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32
-
-$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
-       $(call if_changed,ld)
-       @:
-
-$(obj)/vmlinux.bin: vmlinux FORCE
-       $(call if_changed,objcopy)
-
-$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
-       $(call if_changed,gzip)
-
-LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
-
-$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
-       $(call if_changed,ld)
diff --git a/arch/i386/boot98/compressed/head.S b/arch/i386/boot98/compressed/head.S
deleted file mode 100644 (file)
index c5e80b6..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- *  linux/boot/head.S
- *
- *  Copyright (C) 1991, 1992, 1993  Linus Torvalds
- */
-
-/*
- *  head.S contains the 32-bit startup code.
- *
- * NOTE!!! Startup happens at absolute address 0x00001000, which is also where
- * the page directory will exist. The startup code will be overwritten by
- * the page directory. [According to comments etc elsewhere on a compressed
- * kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC]
- *
- * Page 0 is deliberately kept safe, since System Management Mode code in 
- * laptops may need to access the BIOS data stored there.  This is also
- * useful for future device drivers that either access the BIOS via VM86 
- * mode.
- */
-
-/*
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-.text
-
-#include <linux/linkage.h>
-#include <asm/segment.h>
-
-       .globl startup_32
-       
-startup_32:
-       cld
-       cli
-       movl $(__BOOT_DS),%eax
-       movl %eax,%ds
-       movl %eax,%es
-       movl %eax,%fs
-       movl %eax,%gs
-
-       lss stack_start,%esp
-       xorl %eax,%eax
-1:     incl %eax               # check that A20 really IS enabled
-       movl %eax,0x000000      # loop forever if it isn't
-       cmpl %eax,0x100000
-       je 1b
-
-/*
- * Initialize eflags.  Some BIOS's leave bits like NT set.  This would
- * confuse the debugger if this code is traced.
- * XXX - best to initialize before switching to protected mode.
- */
-       pushl $0
-       popfl
-/*
- * Clear BSS
- */
-       xorl %eax,%eax
-       movl $_edata,%edi
-       movl $_end,%ecx
-       subl %edi,%ecx
-       cld
-       rep
-       stosb
-/*
- * Do the decompression, and jump to the new kernel..
- */
-       subl $16,%esp   # place for structure on the stack
-       movl %esp,%eax
-       pushl %esi      # real mode pointer as second arg
-       pushl %eax      # address of structure as first arg
-       call decompress_kernel
-       orl  %eax,%eax 
-       jnz  3f
-       popl %esi       # discard address
-       popl %esi       # real mode pointer
-       xorl %ebx,%ebx
-       ljmp $(__BOOT_CS), $0x100000
-
-/*
- * We come here, if we were loaded high.
- * We need to move the move-in-place routine down to 0x1000
- * and then start it with the buffer addresses in registers,
- * which we got from the stack.
- */
-3:
-       movl $move_routine_start,%esi
-       movl $0x1000,%edi
-       movl $move_routine_end,%ecx
-       subl %esi,%ecx
-       addl $3,%ecx
-       shrl $2,%ecx
-       cld
-       rep
-       movsl
-
-       popl %esi       # discard the address
-       popl %ebx       # real mode pointer
-       popl %esi       # low_buffer_start
-       popl %ecx       # lcount
-       popl %edx       # high_buffer_start
-       popl %eax       # hcount
-       movl $0x100000,%edi
-       cli             # make sure we don't get interrupted
-       ljmp $(__BOOT_CS), $0x1000 # and jump to the move routine
-
-/*
- * Routine (template) for moving the decompressed kernel in place,
- * if we were high loaded. This _must_ PIC-code !
- */
-move_routine_start:
-       movl %ecx,%ebp
-       shrl $2,%ecx
-       rep
-       movsl
-       movl %ebp,%ecx
-       andl $3,%ecx
-       rep
-       movsb
-       movl %edx,%esi
-       movl %eax,%ecx  # NOTE: rep movsb won't move if %ecx == 0
-       addl $3,%ecx
-       shrl $2,%ecx
-       rep
-       movsl
-       movl %ebx,%esi  # Restore setup pointer
-       xorl %ebx,%ebx
-       ljmp $(__BOOT_CS), $0x100000
-move_routine_end:
diff --git a/arch/i386/boot98/compressed/misc.c b/arch/i386/boot98/compressed/misc.c
deleted file mode 100644 (file)
index 5574009..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * misc.c
- * 
- * This is a collection of several routines from gzip-1.0.3 
- * adapted for Linux.
- *
- * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
- * puts by Nick Holloway 1993, better puts by Martin Mares 1995
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-
-#include <linux/linkage.h>
-#include <linux/vmalloc.h>
-#include <linux/tty.h>
-#include <asm/io.h>
-#ifdef STANDARD_MEMORY_BIOS_CALL
-#undef STANDARD_MEMORY_BIOS_CALL
-#endif
-
-/*
- * gzip declarations
- */
-
-#define OF(args)  args
-#define STATIC static
-
-#undef memset
-#undef memcpy
-
-/*
- * Why do we do this? Don't ask me..
- *
- * Incomprehensible are the ways of bootloaders.
- */
-static void* memset(void *, int, size_t);
-static void* memcpy(void *, __const void *, size_t);
-#define memzero(s, n)     memset ((s), 0, (n))
-
-typedef unsigned char  uch;
-typedef unsigned short ush;
-typedef unsigned long  ulg;
-
-#define WSIZE 0x8000           /* Window size must be at least 32k, */
-                               /* and a power of two */
-
-static uch *inbuf;          /* input buffer */
-static uch window[WSIZE];    /* Sliding window buffer */
-
-static unsigned insize = 0;  /* valid bytes in inbuf */
-static unsigned inptr = 0;   /* index of next byte to be processed in inbuf */
-static unsigned outcnt = 0;  /* bytes in output buffer */
-
-/* gzip flag byte */
-#define ASCII_FLAG   0x01 /* bit 0 set: file probably ASCII text */
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
-#define EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME    0x08 /* bit 3 set: original file name present */
-#define COMMENT      0x10 /* bit 4 set: file comment present */
-#define ENCRYPTED    0x20 /* bit 5 set: file is encrypted */
-#define RESERVED     0xC0 /* bit 6,7:   reserved */
-
-#define get_byte()  (inptr < insize ? inbuf[inptr++] : fill_inbuf())
-               
-/* Diagnostic functions */
-#ifdef DEBUG
-#  define Assert(cond,msg) {if(!(cond)) error(msg);}
-#  define Trace(x) fprintf x
-#  define Tracev(x) {if (verbose) fprintf x ;}
-#  define Tracevv(x) {if (verbose>1) fprintf x ;}
-#  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-#  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
-#else
-#  define Assert(cond,msg)
-#  define Trace(x)
-#  define Tracev(x)
-#  define Tracevv(x)
-#  define Tracec(c,x)
-#  define Tracecv(c,x)
-#endif
-
-static int  fill_inbuf(void);
-static void flush_window(void);
-static void error(char *m);
-static void gzip_mark(void **);
-static void gzip_release(void **);
-  
-/*
- * This is set up by the setup-routine at boot-time
- */
-static unsigned char *real_mode; /* Pointer to real-mode data */
-
-#define EXT_MEM_K   (*(unsigned short *)(real_mode + 0x2))
-#ifndef STANDARD_MEMORY_BIOS_CALL
-#define ALT_MEM_K   (*(unsigned long *)(real_mode + 0x1e0))
-#endif
-#define SCREEN_INFO (*(struct screen_info *)(real_mode+0))
-
-extern char input_data[];
-extern int input_len;
-
-static long bytes_out = 0;
-static uch *output_data;
-static unsigned long output_ptr = 0;
-
-static void *malloc(int size);
-static void free(void *where);
-
-static void puts(const char *);
-
-extern int end;
-static long free_mem_ptr = (long)&end;
-static long free_mem_end_ptr;
-
-#define INPLACE_MOVE_ROUTINE  0x1000
-#define LOW_BUFFER_START      0x2000
-#define LOW_BUFFER_MAX       0x90000
-#define HEAP_SIZE             0x3000
-static unsigned int low_buffer_end, low_buffer_size;
-static int high_loaded =0;
-static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/;
-
-static char *vidmem = (char *)0xa0000;
-static int lines, cols;
-
-#ifdef CONFIG_X86_NUMAQ
-static void * xquad_portio = NULL;
-#endif
-
-#include "../../../../lib/inflate.c"
-
-static void *malloc(int size)
-{
-       void *p;
-
-       if (size <0) error("Malloc error");
-       if (free_mem_ptr <= 0) error("Memory error");
-
-       free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
-
-       p = (void *)free_mem_ptr;
-       free_mem_ptr += size;
-
-       if (free_mem_ptr >= free_mem_end_ptr)
-               error("Out of memory");
-
-       return p;
-}
-
-static void free(void *where)
-{      /* Don't care */
-}
-
-static void gzip_mark(void **ptr)
-{
-       *ptr = (void *) free_mem_ptr;
-}
-
-static void gzip_release(void **ptr)
-{
-       free_mem_ptr = (long) *ptr;
-}
-static void scroll(void)
-{
-       int i;
-
-       memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
-       for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
-               vidmem[i] = ' ';
-}
-
-static void puts(const char *s)
-{
-       int x,y,pos;
-       char c;
-
-       x = SCREEN_INFO.orig_x;
-       y = SCREEN_INFO.orig_y;
-
-       while ( ( c = *s++ ) != '\0' ) {
-               if ( c == '\n' ) {
-                       x = 0;
-                       if ( ++y >= lines ) {
-                               scroll();
-                               y--;
-                       }
-               } else {
-                       vidmem [ ( x + cols * y ) * 2 ] = c; 
-                       if ( ++x >= cols ) {
-                               x = 0;
-                               if ( ++y >= lines ) {
-                                       scroll();
-                                       y--;
-                               }
-                       }
-               }
-       }
-
-       SCREEN_INFO.orig_x = x;
-       SCREEN_INFO.orig_y = y;
-
-       pos = x + cols * y;     /* Update cursor position */
-       while (!(inb_p(0x60) & 4));
-       outb_p(0x49, 0x62);
-       outb_p(pos & 0xff, 0x60);
-       outb_p((pos >> 8) & 0xff, 0x60);
-}
-
-static void* memset(void* s, int c, size_t n)
-{
-       int i;
-       char *ss = (char*)s;
-
-       for (i=0;i<n;i++) ss[i] = c;
-       return s;
-}
-
-static void* memcpy(void* __dest, __const void* __src,
-                           size_t __n)
-{
-       int i;
-       char *d = (char *)__dest, *s = (char *)__src;
-
-       for (i=0;i<__n;i++) d[i] = s[i];
-       return __dest;
-}
-
-/* ===========================================================================
- * Fill the input buffer. This is called only when the buffer is empty
- * and at least one byte is really needed.
- */
-static int fill_inbuf(void)
-{
-       if (insize != 0) {
-               error("ran out of input data");
-       }
-
-       inbuf = input_data;
-       insize = input_len;
-       inptr = 1;
-       return inbuf[0];
-}
-
-/* ===========================================================================
- * Write the output window window[0..outcnt-1] and update crc and bytes_out.
- * (Used for the decompressed data only.)
- */
-static void flush_window_low(void)
-{
-    ulg c = crc;         /* temporary variable */
-    unsigned n;
-    uch *in, *out, ch;
-    
-    in = window;
-    out = &output_data[output_ptr]; 
-    for (n = 0; n < outcnt; n++) {
-           ch = *out++ = *in++;
-           c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
-    }
-    crc = c;
-    bytes_out += (ulg)outcnt;
-    output_ptr += (ulg)outcnt;
-    outcnt = 0;
-}
-
-static void flush_window_high(void)
-{
-    ulg c = crc;         /* temporary variable */
-    unsigned n;
-    uch *in,  ch;
-    in = window;
-    for (n = 0; n < outcnt; n++) {
-       ch = *output_data++ = *in++;
-       if ((ulg)output_data == low_buffer_end) output_data=high_buffer_start;
-       c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
-    }
-    crc = c;
-    bytes_out += (ulg)outcnt;
-    outcnt = 0;
-}
-
-static void flush_window(void)
-{
-       if (high_loaded) flush_window_high();
-       else flush_window_low();
-}
-
-static void error(char *x)
-{
-       puts("\n\n");
-       puts(x);
-       puts("\n\n -- System halted");
-
-       while(1);       /* Halt */
-}
-
-#define STACK_SIZE (4096)
-
-long user_stack [STACK_SIZE];
-
-struct {
-       long * a;
-       short b;
-       } stack_start = { & user_stack [STACK_SIZE] , __BOOT_DS };
-
-static void setup_normal_output_buffer(void)
-{
-#ifdef STANDARD_MEMORY_BIOS_CALL
-       if (EXT_MEM_K < 1024) error("Less than 2MB of memory");
-#else
-       if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024) error("Less than 2MB of memory");
-#endif
-       output_data = (char *)0x100000; /* Points to 1M */
-       free_mem_end_ptr = (long)real_mode;
-}
-
-struct moveparams {
-       uch *low_buffer_start;  int lcount;
-       uch *high_buffer_start; int hcount;
-};
-
-static void setup_output_buffer_if_we_run_high(struct moveparams *mv)
-{
-       high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE);
-#ifdef STANDARD_MEMORY_BIOS_CALL
-       if (EXT_MEM_K < (3*1024)) error("Less than 4MB of memory");
-#else
-       if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory");
-#endif 
-       mv->low_buffer_start = output_data = (char *)LOW_BUFFER_START;
-       low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX
-         ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff;
-       low_buffer_size = low_buffer_end - LOW_BUFFER_START;
-       high_loaded = 1;
-       free_mem_end_ptr = (long)high_buffer_start;
-       if ( (0x100000 + low_buffer_size) > ((ulg)high_buffer_start)) {
-               high_buffer_start = (uch *)(0x100000 + low_buffer_size);
-               mv->hcount = 0; /* say: we need not to move high_buffer */
-       }
-       else mv->hcount = -1;
-       mv->high_buffer_start = high_buffer_start;
-}
-
-static void close_output_buffer_if_we_run_high(struct moveparams *mv)
-{
-       if (bytes_out > low_buffer_size) {
-               mv->lcount = low_buffer_size;
-               if (mv->hcount)
-                       mv->hcount = bytes_out - low_buffer_size;
-       } else {
-               mv->lcount = bytes_out;
-               mv->hcount = 0;
-       }
-}
-
-
-asmlinkage int decompress_kernel(struct moveparams *mv, void *rmode)
-{
-       real_mode = rmode;
-
-       vidmem = (char *)(((unsigned int)SCREEN_INFO.orig_video_page) << 4);
-
-       lines = SCREEN_INFO.orig_video_lines;
-       cols = SCREEN_INFO.orig_video_cols;
-
-       if (free_mem_ptr < 0x100000) setup_normal_output_buffer();
-       else setup_output_buffer_if_we_run_high(mv);
-
-       makecrc();
-       puts("Uncompressing Linux... ");
-       gunzip();
-       puts("Ok, booting the kernel.\n");
-       if (high_loaded) close_output_buffer_if_we_run_high(mv);
-       return high_loaded;
-}
-
-/* We don't actually check for stack overflows this early. */
-__asm__(".globl mcount ; mcount: ret\n");
-
diff --git a/arch/i386/boot98/compressed/vmlinux.scr b/arch/i386/boot98/compressed/vmlinux.scr
deleted file mode 100644 (file)
index 1ed9d79..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-SECTIONS
-{
-  .data : { 
-       input_len = .;
-       LONG(input_data_end - input_data) input_data = .; 
-       *(.data) 
-       input_data_end = .; 
-       }
-}
diff --git a/arch/i386/boot98/install.sh b/arch/i386/boot98/install.sh
deleted file mode 100644 (file)
index 90f2452..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-#
-# arch/i386/boot/install.sh
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-#
-# "make install" script for i386 architecture
-#
-# Arguments:
-#   $1 - kernel version
-#   $2 - kernel image file
-#   $3 - kernel map file
-#   $4 - default install path (blank if root directory)
-#
-
-# User may have a custom install script
-
-if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi
-if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi
-
-# Default install - same as make zlilo
-
-if [ -f $4/vmlinuz ]; then
-       mv $4/vmlinuz $4/vmlinuz.old
-fi
-
-if [ -f $4/System.map ]; then
-       mv $4/System.map $4/System.old
-fi
-
-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
-
-if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
diff --git a/arch/i386/boot98/mtools.conf.in b/arch/i386/boot98/mtools.conf.in
deleted file mode 100644 (file)
index efd6d24..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# mtools configuration file for "make (b)zdisk"
-#
-
-# Actual floppy drive
-drive a:
-  file="/dev/fd0"
-
-# 1.44 MB floppy disk image
-drive v:
-  file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=18 filter
-
-# 2.88 MB floppy disk image (mostly for virtual uses)
-drive w:
-  file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter
-
-
diff --git a/arch/i386/boot98/setup.S b/arch/i386/boot98/setup.S
deleted file mode 100644 (file)
index 4ed9141..0000000
+++ /dev/null
@@ -1,876 +0,0 @@
-/*
- *     setup.S         Copyright (C) 1991, 1992 Linus Torvalds
- *
- * setup.s is responsible for getting the system data from the BIOS,
- * and putting them into the appropriate places in system memory.
- * both setup.s and system has been loaded by the bootblock.
- *
- * This code asks the bios for memory/disk/other parameters, and
- * puts them in a "safe" place: 0x90000-0x901FF, ie where the
- * boot-block used to be. It is then up to the protected mode
- * system to read them from there before the area is overwritten
- * for buffer-blocks.
- *
- * Move PS/2 aux init code to psaux.c
- * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92
- *
- * some changes and additional features by Christoph Niemann,
- * March 1993/June 1994 (Christoph.Niemann@linux.org)
- *
- * add APM BIOS checking by Stephen Rothwell, May 1994
- * (sfr@canb.auug.org.au)
- *
- * High load stuff, initrd support and position independency
- * by Hans Lermen & Werner Almesberger, February 1996
- * <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch>
- *
- * Video handling moved to video.S by Martin Mares, March 1996
- * <mj@k332.feld.cvut.cz>
- *
- * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david
- * parsons) to avoid loadlin confusion, July 1997
- *
- * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999.
- * <stiker@northlink.com>
- *
- * Fix to work around buggy BIOSes which dont use carry bit correctly
- * and/or report extended memory in CX/DX for e801h memory size detection 
- * call.  As a result the kernel got wrong figures.  The int15/e801h docs
- * from Ralf Brown interrupt list seem to indicate AX/BX should be used
- * anyway.  So to avoid breaking many machines (presumably there was a reason
- * to orginally use CX/DX instead of AX/BX), we do a kludge to see
- * if CX/DX have been changed in the e801 call and if so use AX/BX .
- * Michael Miller, April 2001 <michaelm@mjmm.org>
- *
- * New A20 code ported from SYSLINUX by H. Peter Anvin. AMD Elan bugfixes
- * by Robert Schwebel, December 2001 <robert@schwebel.de>
- *
- * Heavily modified for NEC PC-9800 series by Kyoto University Microcomputer
- * Club (KMC) Linux/98 project <seraphim@kmc.kyoto-u.ac.jp>, 1997-1999
- */
-
-#include <linux/config.h>
-#include <asm/segment.h>
-#include <linux/version.h>
-#include <linux/compile.h>
-#include <asm/boot.h>
-#include <asm/e820.h>
-#include <asm/page.h>
-       
-/* Signature words to ensure LILO loaded us right */
-#define SIG1   0xAA55
-#define SIG2   0x5A5A
-
-#define HIRESO_TEXT    0xe000
-#define NORMAL_TEXT    0xa000
-
-#define BIOS_FLAG2     0x0400
-#define BIOS_FLAG5     0x0458
-#define RDISK_EQUIP    0x0488
-#define BIOS_FLAG      0x0501
-#define KB_SHFT_STS    0x053a
-#define DISK_EQUIP     0x055c
-
-INITSEG  = DEF_INITSEG         # 0x9000, we move boot here, out of the way
-SYSSEG   = DEF_SYSSEG          # 0x1000, system loaded at 0x10000 (65536).
-SETUPSEG = DEF_SETUPSEG                # 0x9020, this is the current segment
-                               # ... and the former contents of CS
-
-DELTA_INITSEG = SETUPSEG - INITSEG     # 0x0020
-
-.code16
-.globl begtext, begdata, begbss, endtext, enddata, endbss
-
-.text
-begtext:
-.data
-begdata:
-.bss
-begbss:
-.text
-
-start:
-       jmp     trampoline
-
-# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
-
-               .ascii  "HdrS"          # header signature
-               .word   0x0203          # header version number (>= 0x0105)
-                                       # or else old loadlin-1.5 will fail)
-realmode_swtch:        .word   0, 0            # default_switch, SETUPSEG
-start_sys_seg: .word   SYSSEG
-               .word   kernel_version  # pointing to kernel version string
-                                       # above section of header is compatible
-                                       # with loadlin-1.5 (header v1.5). Don't
-                                       # change it.
-
-type_of_loader:        .byte   0               # = 0, old one (LILO, Loadlin,
-                                       #      Bootlin, SYSLX, bootsect...)
-                                       # See Documentation/i386/boot.txt for
-                                       # assigned ids
-       
-# flags, unused bits must be zero (RFU) bit within loadflags
-loadflags:
-LOADED_HIGH    = 1                     # If set, the kernel is loaded high
-CAN_USE_HEAP   = 0x80                  # If set, the loader also has set
-                                       # heap_end_ptr to tell how much
-                                       # space behind setup.S can be used for
-                                       # heap purposes.
-                                       # Only the loader knows what is free
-#ifndef __BIG_KERNEL__
-               .byte   0
-#else
-               .byte   LOADED_HIGH
-#endif
-
-setup_move_size: .word  0x8000         # size to move, when setup is not
-                                       # loaded at 0x90000. We will move setup 
-                                       # to 0x90000 then just before jumping
-                                       # into the kernel. However, only the
-                                       # loader knows how much data behind
-                                       # us also needs to be loaded.
-
-code32_start:                          # here loaders can put a different
-                                       # start address for 32-bit code.
-#ifndef __BIG_KERNEL__
-               .long   0x1000          #   0x1000 = default for zImage
-#else
-               .long   0x100000        # 0x100000 = default for big kernel
-#endif
-
-ramdisk_image: .long   0               # address of loaded ramdisk image
-                                       # Here the loader puts the 32-bit
-                                       # address where it loaded the image.
-                                       # This only will be read by the kernel.
-
-ramdisk_size:  .long   0               # its size in bytes
-
-bootsect_kludge:
-               .long   0               # obsolete
-
-heap_end_ptr:  .word   modelist+1024   # (Header version 0x0201 or later)
-                                       # space from here (exclusive) down to
-                                       # end of setup code can be used by setup
-                                       # for local heap purposes.
-
-pad1:          .word   0
-cmd_line_ptr:  .long 0                 # (Header version 0x0202 or later)
-                                       # If nonzero, a 32-bit pointer
-                                       # to the kernel command line.
-                                       # The command line should be
-                                       # located between the start of
-                                       # setup and the end of low
-                                       # memory (0xa0000), or it may
-                                       # get overwritten before it
-                                       # gets read.  If this field is
-                                       # used, there is no longer
-                                       # anything magical about the
-                                       # 0x90000 segment; the setup
-                                       # can be located anywhere in
-                                       # low memory 0x10000 or higher.
-
-ramdisk_max:   .long MAXMEM-1          # (Header version 0x0203 or later)
-                                       # The highest safe address for
-                                       # the contents of an initrd
-
-trampoline:    call    start_of_setup
-               .space  1024
-# End of setup header #####################################################
-
-start_of_setup:
-# Set %ds = %cs, we know that SETUPSEG = %cs at this point
-       movw    %cs, %ax                # aka SETUPSEG
-       movw    %ax, %ds
-# Check signature at end of setup
-       cmpw    $SIG1, setup_sig1
-       jne     bad_sig
-
-       cmpw    $SIG2, setup_sig2
-       jne     bad_sig
-
-       jmp     good_sig1
-
-# Routine to print asciiz string at ds:si
-prtstr:
-       lodsb
-       andb    %al, %al
-       jz      fin
-
-       call    prtchr
-       jmp     prtstr
-
-fin:   ret
-
-no_sig_mess: .string   "No setup signature found ..."
-
-good_sig1:
-       jmp     good_sig
-
-# We now have to find the rest of the setup code/data
-bad_sig:
-       movw    %cs, %ax                        # SETUPSEG
-       subw    $DELTA_INITSEG, %ax             # INITSEG
-       movw    %ax, %ds
-       xorb    %bh, %bh
-       movb    (497), %bl                      # get setup sect from bootsect
-       subw    $4, %bx                         # LILO loads 4 sectors of setup
-       shlw    $8, %bx                         # convert to words (1sect=2^8 words)
-       movw    %bx, %cx
-       shrw    $3, %bx                         # convert to segment
-       addw    $SYSSEG, %bx
-       movw    %bx, %cs:start_sys_seg
-# Move rest of setup code/data to here
-       movw    $2048, %di                      # four sectors loaded by LILO
-       subw    %si, %si
-       pushw   %cs
-       popw    %es
-       movw    $SYSSEG, %ax
-       movw    %ax, %ds
-       rep
-       movsw
-       movw    %cs, %ax                        # aka SETUPSEG
-       movw    %ax, %ds
-       cmpw    $SIG1, setup_sig1
-       jne     no_sig
-
-       cmpw    $SIG2, setup_sig2
-       jne     no_sig
-
-       jmp     good_sig
-
-no_sig:
-       lea     no_sig_mess, %si
-       call    prtstr
-
-no_sig_loop:
-       hlt
-       jmp     no_sig_loop
-
-good_sig:
-       movw    %cs, %ax                        # aka SETUPSEG
-       subw    $DELTA_INITSEG, %ax             # aka INITSEG
-       movw    %ax, %ds
-# Check if an old loader tries to load a big-kernel
-       testb   $LOADED_HIGH, %cs:loadflags     # Do we have a big kernel?
-       jz      loader_ok                       # No, no danger for old loaders.
-
-       cmpb    $0, %cs:type_of_loader          # Do we have a loader that
-                                               # can deal with us?
-       jnz     loader_ok                       # Yes, continue.
-
-       pushw   %cs                             # No, we have an old loader,
-       popw    %ds                             # die. 
-       lea     loader_panic_mess, %si
-       call    prtstr
-
-       jmp     no_sig_loop
-
-loader_panic_mess: .string "Wrong loader, giving up..."
-
-loader_ok:
-# Get memory size (extended mem, kB)
-
-# On PC-9800, memory size detection is done completely in 32-bit
-# kernel initialize code (kernel/setup.c).
-       pushw   %es
-       xorl    %eax, %eax
-       movw    %ax, %es
-       movb    %al, (E820NR)           # PC-9800 has no E820
-       movb    %es:(0x401), %al
-       shll    $7, %eax
-       addw    $1024, %ax
-       movw    %ax, (2)
-       movl    %eax, (0x1e0)
-       movw    %es:(0x594), %ax
-       shll    $10, %eax
-       addl    %eax, (0x1e0)
-       popw    %es
-
-# Check for video adapter and its parameters and allow the
-# user to browse video modes.
-       call    video                           # NOTE: we need %ds pointing
-                                               # to bootsector
-
-# Get text video mode
-       movb    $0x0B, %ah
-       int     $0x18           # CRT mode sense
-       movw    $(20 << 8) + 40, %cx
-       testb   $0x10, %al
-       jnz     3f
-       movb    $20, %ch
-       testb   $0x01, %al
-       jnz     1f
-       movb    $25, %ch
-       jmp     1f
-3:     # If bit 4 was 1, it means either 1) 31 lines for hi-reso mode,
-       # or 2) 30 lines for PC-9821.
-       movb    $31, %ch        # hireso mode value
-       pushw   $0
-       popw    %es
-       testb   $0x08, %es:BIOS_FLAG
-       jnz     1f
-       movb    $30, %ch
-1:     # Now we got # of rows in %ch
-       movb    %ch, (14)
-
-       testb   $0x02, %al
-       jnz     2f
-       movb    $80, %cl
-2:     # Now we got # of columns in %cl
-       movb    %cl, (7)
-
-       # Next, get horizontal frequency if supported
-       movw    $0x3100, %ax
-       int     $0x18           # Call CRT bios
-       movb    %al, (6)        # If 31h is unsupported, %al remains 0
-
-# Get hd0-3 data...
-       pushw   %ds                             # aka INITSEG
-       popw    %es
-       xorw    %ax, %ax
-       movw    %ax, %ds
-       cld
-       movw    $0x0080, %di
-       movb    DISK_EQUIP+1, %ah
-       movb    $0x80, %al
-
-get_hd_info:
-       shrb    %ah
-       pushw   %ax
-       jnc     1f
-       movb    $0x84, %ah
-       int     $0x1b
-       jnc     2f                              # Success
-1:     xorw    %cx, %cx                        # `0 cylinders' means no drive
-2:     # Attention! Work area (drive_info) is arranged for PC-9800.
-       movw    %cx, %ax                        # # of cylinders
-       stosw
-       movw    %dx, %ax                        # # of sectors / # of heads
-       stosw
-       movw    %bx, %ax                        # sector size in bytes
-       stosw
-       popw    %ax
-       incb    %al
-       cmpb    $0x84, %al
-       jb      get_hd_info
-
-# Get fd data...
-       movw    DISK_EQUIP, %ax
-       andw    $0xf00f, %ax
-       orb     %al, %ah
-       movb    RDISK_EQUIP, %al
-       notb    %al
-       andb    %al, %ah                        # ignore all `RAM drive'
-
-       movb    $0x30, %al
-
-get_fd_info:
-       shrb    %ah
-       pushw   %ax
-       jnc     1f
-       movb    $0xc4, %ah
-       int     $0x1b
-       movb    %ah, %al
-       andb    $4, %al                         # 1.44MB support flag
-       shrb    %al
-       addb    $2, %al                         # %al = 2 (1.2MB) or 4 (1.44MB)
-       jmp     2f
-1:     movb    $0, %al                         # no drive
-2:     stosb
-       popw    %ax
-       incb    %al
-       testb   $0x04, %al
-       jz      get_fd_info
-
-       addb    $(0xb0 - 0x34), %al
-       jnc     get_fd_info                     # check FDs on 640KB I/F
-
-       pushw   %es
-       popw    %ds                             # %ds got bootsector again
-#if 0
-       mov     $0, (0x1ff)                     # default is no pointing device
-#endif
-
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
-# Then check for an APM BIOS...
-                                               # %ds points to the bootsector
-       movw    $0, 0x40                        # version = 0 means no APM BIOS
-       movw    $0x09a00, %ax                   # APM BIOS installation check
-       xorw    %bx, %bx
-       int     $0x1f
-       jc      done_apm_bios                   # Nope, no APM BIOS
-
-       cmpw    $0x0504d, %bx                   # Check for "PM" signature
-       jne     done_apm_bios                   # No signature, no APM BIOS
-
-       testb   $0x02, %cl                      # Is 32 bit supported?
-       je      done_apm_bios                   # No 32-bit, no (good) APM BIOS
-
-       movw    $0x09a04, %ax                   # Disconnect first just in case
-       xorw    %bx, %bx
-       int     $0x1f                           # ignore return code
-       movw    $0x09a03, %ax                   # 32 bit connect
-       xorl    %ebx, %ebx
-       int     $0x1f
-       jc      no_32_apm_bios                  # Ack, error.
-
-       movw    %ax,  (66)                      # BIOS code segment
-       movl    %ebx, (68)                      # BIOS entry point offset
-       movw    %cx,  (72)                      # BIOS 16 bit code segment
-       movw    %dx,  (74)                      # BIOS data segment
-       movl    %esi, (78)                      # BIOS code segment length
-       movw    %di,  (82)                      # BIOS data segment length
-# Redo the installation check as the 32 bit connect
-# modifies the flags returned on some BIOSs
-       movw    $0x09a00, %ax                   # APM BIOS installation check
-       xorw    %bx, %bx
-       int     $0x1f
-       jc      apm_disconnect                  # error -> shouldn't happen
-
-       cmpw    $0x0504d, %bx                   # check for "PM" signature
-       jne     apm_disconnect                  # no sig -> shouldn't happen
-
-       movw    %ax, (64)                       # record the APM BIOS version
-       movw    %cx, (76)                       # and flags
-       jmp     done_apm_bios
-
-apm_disconnect:                                        # Tidy up
-       movw    $0x09a04, %ax                   # Disconnect
-       xorw    %bx, %bx
-       int     $0x1f                           # ignore return code
-
-       jmp     done_apm_bios
-
-no_32_apm_bios:
-       andw    $0xfffd, (76)                   # remove 32 bit support bit
-done_apm_bios:
-#endif
-
-# Pass cursor position to kernel...
-       movw    %cs:cursor_address, %ax
-       shrw    %ax             # cursor_address is 2 bytes unit
-       movb    $80, %cl
-       divb    %cl
-       xchgb   %al, %ah        # (0) = %al = X, (1) = %ah = Y
-       movw    %ax, (0)
-
-#if 0
-       movw    $msg_cpos, %si
-       call    prtstr_cs
-       call    prthex
-       call    prtstr_cs
-       movw    %ds, %ax
-       call    prthex
-       call    prtstr_cs
-       movb    $0x11, %ah
-       int     $0x18
-       movb    $0, %ah
-       int     $0x18
-       .section .rodata, "a"
-msg_cpos:      .string "Cursor position: 0x"
-               .string ", %ds:0x"
-               .string "\r\n"
-       .previous
-#endif
-
-# Now we want to move to protected mode ...
-       cmpw    $0, %cs:realmode_swtch
-       jz      rmodeswtch_normal
-
-       lcall   *%cs:realmode_swtch
-
-       jmp     rmodeswtch_end
-
-rmodeswtch_normal:
-        pushw  %cs
-       call    default_switch
-
-rmodeswtch_end:
-# we get the code32 start address and modify the below 'jmpi'
-# (loader may have changed it)
-       movl    %cs:code32_start, %eax
-       movl    %eax, %cs:code32
-
-# Now we move the system to its rightful place ... but we check if we have a
-# big-kernel. In that case we *must* not move it ...
-       testb   $LOADED_HIGH, %cs:loadflags
-       jz      do_move0                        # .. then we have a normal low
-                                               # loaded zImage
-                                               # .. or else we have a high
-                                               # loaded bzImage
-       jmp     end_move                        # ... and we skip moving
-
-do_move0:
-       movw    $0x100, %ax                     # start of destination segment
-       movw    %cs, %bp                        # aka SETUPSEG
-       subw    $DELTA_INITSEG, %bp             # aka INITSEG
-       movw    %cs:start_sys_seg, %bx          # start of source segment
-       cld
-do_move:
-       movw    %ax, %es                        # destination segment
-       incb    %ah                             # instead of add ax,#0x100
-       movw    %bx, %ds                        # source segment
-       addw    $0x100, %bx
-       subw    %di, %di
-       subw    %si, %si
-       movw    $0x800, %cx
-       rep
-       movsw
-       cmpw    %bp, %bx                        # assume start_sys_seg > 0x200,
-                                               # so we will perhaps read one
-                                               # page more than needed, but
-                                               # never overwrite INITSEG
-                                               # because destination is a
-                                               # minimum one page below source
-       jb      do_move
-
-end_move:
-# then we load the segment descriptors
-       movw    %cs, %ax                        # aka SETUPSEG
-       movw    %ax, %ds
-               
-# Check whether we need to be downward compatible with version <=201
-       cmpl    $0, cmd_line_ptr
-       jne     end_move_self           # loader uses version >=202 features
-       cmpb    $0x20, type_of_loader
-       je      end_move_self           # bootsect loader, we know of it
-# Boot loader does not support boot protocol version 2.02.
-# If we have our code not at 0x90000, we need to move it there now.
-# We also then need to move the params behind it (commandline)
-# Because we would overwrite the code on the current IP, we move
-# it in two steps, jumping high after the first one.
-       movw    %cs, %ax
-       cmpw    $SETUPSEG, %ax
-       je      end_move_self
-
-       cli                                     # make sure we really have
-                                               # interrupts disabled !
-                                               # because after this the stack
-                                               # should not be used
-       subw    $DELTA_INITSEG, %ax             # aka INITSEG
-       movw    %ss, %dx
-       cmpw    %ax, %dx
-       jb      move_self_1
-
-       addw    $INITSEG, %dx
-       subw    %ax, %dx                        # this will go into %ss after
-                                               # the move
-move_self_1:
-       movw    %ax, %ds
-       movw    $INITSEG, %ax                   # real INITSEG
-       movw    %ax, %es
-       movw    %cs:setup_move_size, %cx
-       std                                     # we have to move up, so we use
-                                               # direction down because the
-                                               # areas may overlap
-       movw    %cx, %di
-       decw    %di
-       movw    %di, %si
-       subw    $move_self_here+0x200, %cx
-       rep
-       movsb
-       ljmp    $SETUPSEG, $move_self_here
-
-move_self_here:
-       movw    $move_self_here+0x200, %cx
-       rep
-       movsb
-       movw    $SETUPSEG, %ax
-       movw    %ax, %ds
-       movw    %dx, %ss
-
-end_move_self:                                 # now we are at the right place
-       lidt    idt_48                          # load idt with 0,0
-       xorl    %eax, %eax                      # Compute gdt_base
-       movw    %ds, %ax                        # (Convert %ds:gdt to a linear ptr)
-       shll    $4, %eax
-       addl    $gdt, %eax
-       movl    %eax, (gdt_48+2)
-       lgdt    gdt_48                          # load gdt with whatever is
-                                               # appropriate
-
-# that was painless, now we enable A20
-
-       outb    %al, $0xf2                      # A20 on
-       movb    $0x02, %al
-       outb    %al, $0xf6                      # also A20 on; making ITF's
-                                               # way our model
-
-       # PC-9800 seems to enable A20 at the moment of `outb';
-       # so we don't wait unlike IBM PCs (see ../setup.S).
-
-# enable DMA to access memory over 0x100000 (1MB).
-
-       movw    $0x439, %dx
-       inb     %dx, %al
-       andb    $(~4), %al
-       outb    %al, %dx
-
-# Set DMA to increment its bank address automatically at 16MB boundary.
-# Initial setting is 64KB boundary mode so that we can't run DMA crossing
-# physical address 0xXXXXFFFF.
-
-       movb    $0x0c, %al
-       outb    %al, $0x29                      # ch. 0
-       movb    $0x0d, %al
-       outb    %al, $0x29                      # ch. 1
-       movb    $0x0e, %al
-       outb    %al, $0x29                      # ch. 2
-       movb    $0x0f, %al
-       outb    %al, $0x29                      # ch. 3
-       movb    $0x50, %al
-       outb    %al, $0x11                      # reinitialize DMAC
-
-# make sure any possible coprocessor is properly reset..
-       movb    $0, %al
-       outb    %al, $0xf8
-       outb    %al, $0x5f                      # delay
-
-# well, that went ok, I hope. Now we mask all interrupts - the rest
-# is done in init_IRQ().
-       movb    $0xFF, %al                      # mask all interrupts for now
-       outb    %al, $0x0A
-       outb    %al, $0x5f                      # delay
-       
-       movb    $0x7F, %al                      # mask all irq's but irq7 which
-       outb    %al, $0x02                      # is cascaded
-
-# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't
-# need no steenking BIOS anyway (except for the initial loading :-).
-# The BIOS-routine wants lots of unnecessary data, and it's less
-# "interesting" anyway. This is how REAL programmers do it.
-#
-# Well, now's the time to actually move into protected mode. To make
-# things as simple as possible, we do no register set-up or anything,
-# we let the gnu-compiled 32-bit programs do that. We just jump to
-# absolute address 0x1000 (or the loader supplied one),
-# in 32-bit protected mode.
-#
-# Note that the short jump isn't strictly needed, although there are
-# reasons why it might be a good idea. It won't hurt in any case.
-       movw    $1, %ax                         # protected mode (PE) bit
-       lmsw    %ax                             # This is it!
-       jmp     flush_instr
-
-flush_instr:
-       xorw    %bx, %bx                        # Flag to indicate a boot
-       xorl    %esi, %esi                      # Pointer to real-mode code
-       movw    %cs, %si
-       subw    $DELTA_INITSEG, %si
-       shll    $4, %esi                        # Convert to 32-bit pointer
-# NOTE: For high loaded big kernels we need a
-#      jmpi    0x100000,__BOOT_CS
-#
-#      but we yet haven't reloaded the CS register, so the default size 
-#      of the target offset still is 16 bit.
-#       However, using an operand prefix (0x66), the CPU will properly
-#      take our 48 bit far pointer. (INTeL 80386 Programmer's Reference
-#      Manual, Mixing 16-bit and 32-bit code, page 16-6)
-
-       .byte 0x66, 0xea                        # prefix + jmpi-opcode
-code32:        .long   0x1000                          # will be set to 0x100000
-                                               # for big kernels
-       .word   __BOOT_CS
-
-# Here's a bunch of information about your current kernel..
-kernel_version:        .ascii  UTS_RELEASE
-               .ascii  " ("
-               .ascii  LINUX_COMPILE_BY
-               .ascii  "@"
-               .ascii  LINUX_COMPILE_HOST
-               .ascii  ") "
-               .ascii  UTS_VERSION
-               .byte   0
-
-# This is the default real mode switch routine.
-# to be called just before protected mode transition
-default_switch:
-       cli                                     # no interrupts allowed !
-       outb    %al, $0x50                      # disable NMI for bootup
-                                               # sequence
-       lret
-
-
-# This routine prints one character (in %al) on console.
-# PC-9800 doesn't have BIOS-function to do it like IBM PC's INT 10h - 0Eh,
-# so we hardcode `prtchr' subroutine here.
-prtchr:
-       pushaw
-       pushw   %es
-       cmpb    $0, %cs:prtchr_initialized
-       jnz     prtchr_ok
-       xorw    %cx, %cx
-       movw    %cx, %es
-       testb   $0x8, %es:BIOS_FLAG
-       jz      1f
-       movb    $(HIRESO_TEXT >> 8), %cs:cursor_address+3
-       movw    $(80 * 31 * 2), %cs:max_cursor_offset
-1:     pushw   %ax
-       call    get_cursor_position
-       movw    %ax, %cs:cursor_address
-       popw    %ax
-       movb    $1, %cs:prtchr_initialized
-prtchr_ok:
-       lesw    %cs:cursor_address, %di
-       movw    $160, %bx
-       movb    $0, %ah
-       cmpb    $13, %al
-       je      do_cr
-       cmpb    $10, %al
-       je      do_lf
-
-       # normal (printable) character
-       stosw
-       movb    $0xe1, %es:0x2000-2(%di)
-       jmp     1f
-
-do_cr: movw    %di, %ax
-       divb    %bl                             # %al = Y, %ah = X * 2
-       mulb    %bl
-       movw    %ax, %dx
-       jmp     2f
-
-do_lf: addw    %bx, %di
-1:     movw    %cs:max_cursor_offset, %cx
-       cmpw    %cx, %di
-       movw    %di, %dx
-       jb      2f
-       # cursor reaches bottom of screen; scroll it
-       subw    %bx, %dx
-       xorw    %di, %di
-       movw    %bx, %si
-       cld
-       subw    %bx, %cx
-       shrw    %cx
-       pushw   %cx
-       rep; es; movsw
-       movb    $32, %al                        # clear bottom line characters
-       movb    $80, %cl
-       rep; stosw
-       movw    $0x2000, %di
-       popw    %cx
-       leaw    (%bx,%di), %si
-       rep; es; movsw
-       movb    $0xe1, %al                      # clear bottom line attributes
-       movb    $80, %cl
-       rep; stosw
-2:     movw    %dx, %cs:cursor_address
-       movb    $0x13, %ah                      # move cursor to right position
-       int     $0x18
-       popw    %es
-       popaw
-       ret
-
-cursor_address:
-       .word   0
-       .word   NORMAL_TEXT
-max_cursor_offset:
-       .word   80 * 25 * 2                     # for normal 80x25 mode
-
-# putstr may called without running through start_of_setup (via bootsect_panic)
-# so we should initialize ourselves on demand.
-prtchr_initialized:
-       .byte   0
-
-# This routine queries GDC (graphic display controller) for current cursor
-# position. Cursor position is returned in %ax (CPU offset address).
-get_cursor_position:
-1:     inb     $0x60, %al
-       outb    %al, $0x5f                      # delay
-       outb    %al, $0x5f                      # delay
-       testb   $0x04, %al                      # Is FIFO empty?
-       jz      1b                              # no -> wait until empty
-
-       movb    $0xe0, %al                      # CSRR command
-       outb    %al, $0x62                      # command write
-       outb    %al, $0x5f                      # delay
-       outb    %al, $0x5f                      # delay
-
-2:     inb     $0x60, %al
-       outb    %al, $0x5f                      # delay
-       outb    %al, $0x5f                      # delay
-       testb   $0x01, %al                      # Is DATA READY?
-       jz      2b                              # no -> wait until ready
-
-       inb     $0x62, %al                      # read xAD (L)
-       outb    %al, $0x5f                      # delay
-       outb    %al, $0x5f                      # delay
-       movb    %al, %ah
-       inb     $0x62, %al                      # read xAD (H)
-       outb    %al, $0x5f                      # delay
-       outb    %al, $0x5f                      # delay
-       xchgb   %al, %ah                        # correct byte order
-       pushw   %ax
-       inb     $0x62, %al                      # read yAD (L)
-       outb    %al, $0x5f                      # delay
-       outb    %al, $0x5f                      # delay
-       inb     $0x62, %al                      # read yAD (M)
-       outb    %al, $0x5f                      # delay
-       outb    %al, $0x5f                      # delay
-       inb     $0x62, %al                      # read yAD (H)
-                                               # yAD is not our interest,
-                                               # so discard it.
-       popw    %ax
-       addw    %ax, %ax                        # convert to CPU address
-       ret
-
-# Descriptor tables
-#
-# NOTE: The intel manual says gdt should be sixteen bytes aligned for
-# efficiency reasons.  However, there are machines which are known not
-# to boot with misaligned GDTs, so alter this at your peril!  If you alter
-# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two
-# empty GDT entries (one for NULL and one reserved).
-#
-# NOTE:        On some CPUs, the GDT must be 8 byte aligned.  This is
-# true for the Voyager Quad CPU card which will not boot without
-# This directive.  16 byte aligment is recommended by intel.
-#
-       .align 16
-gdt:
-       .fill GDT_ENTRY_BOOT_CS,8,0
-
-       .word   0xFFFF                          # 4Gb - (0x100000*0x1000 = 4Gb)
-       .word   0                               # base address = 0
-       .word   0x9A00                          # code read/exec
-       .word   0x00CF                          # granularity = 4096, 386
-                                               #  (+5th nibble of limit)
-
-       .word   0xFFFF                          # 4Gb - (0x100000*0x1000 = 4Gb)
-       .word   0                               # base address = 0
-       .word   0x9200                          # data read/write
-       .word   0x00CF                          # granularity = 4096, 386
-                                               #  (+5th nibble of limit)
-gdt_end:
-       .align  4
-       
-       .word   0                               # alignment byte
-idt_48:
-       .word   0                               # idt limit = 0
-       .word   0, 0                            # idt base = 0L
-
-       .word   0                               # alignment byte
-gdt_48:
-       .word   gdt_end - gdt - 1               # gdt limit
-       .word   0, 0                            # gdt base (filled in later)
-
-# Include video setup & detection code
-
-#include "video.S"
-
-# Setup signature -- must be last
-setup_sig1:    .word   SIG1
-setup_sig2:    .word   SIG2
-
-# After this point, there is some free space which is used by the video mode
-# handling code to store the temporary mode table (not used by the kernel).
-
-modelist:
-
-.text
-endtext:
-.data
-enddata:
-.bss
-endbss:
diff --git a/arch/i386/boot98/tools/build.c b/arch/i386/boot98/tools/build.c
deleted file mode 100644 (file)
index 9b10395..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- *  $Id: build.c,v 1.5 1997/05/19 12:29:58 mj Exp $
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *  Copyright (C) 1997 Martin Mares
- */
-
-/*
- * This file builds a disk-image from three different files:
- *
- * - bootsect: exactly 512 bytes of 8086 machine code, loads the rest
- * - setup: 8086 machine code, sets up system parm
- * - system: 80386 code for actual system
- *
- * It does some checking that all files are of the correct type, and
- * just writes the result to stdout, removing headers and padding to
- * the right amount. It also writes some system data to stderr.
- */
-
-/*
- * Changes by tytso to allow root device specification
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- * Cross compiling fixes by Gertjan van Wingerde, July 1996
- * Rewritten by Martin Mares, April 1997
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <asm/boot.h>
-
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned long u32;
-
-#define DEFAULT_MAJOR_ROOT 0
-#define DEFAULT_MINOR_ROOT 0
-
-/* Minimal number of setup sectors (see also bootsect.S) */
-#define SETUP_SECTS 4
-
-byte buf[1024];
-int fd;
-int is_big_kernel;
-
-void die(const char * str, ...)
-{
-       va_list args;
-       va_start(args, str);
-       vfprintf(stderr, str, args);
-       fputc('\n', stderr);
-       exit(1);
-}
-
-void file_open(const char *name)
-{
-       if ((fd = open(name, O_RDONLY, 0)) < 0)
-               die("Unable to open `%s': %m", name);
-}
-
-void usage(void)
-{
-       die("Usage: build [-b] bootsect setup system [rootdev] [> image]");
-}
-
-int main(int argc, char ** argv)
-{
-       unsigned int i, c, sz, setup_sectors;
-       u32 sys_size;
-       byte major_root, minor_root;
-       struct stat sb;
-
-       if (argc > 2 && !strcmp(argv[1], "-b"))
-         {
-           is_big_kernel = 1;
-           argc--, argv++;
-         }
-       if ((argc < 4) || (argc > 5))
-               usage();
-       if (argc > 4) {
-               if (!strcmp(argv[4], "CURRENT")) {
-                       if (stat("/", &sb)) {
-                               perror("/");
-                               die("Couldn't stat /");
-                       }
-                       major_root = major(sb.st_dev);
-                       minor_root = minor(sb.st_dev);
-               } else if (strcmp(argv[4], "FLOPPY")) {
-                       if (stat(argv[4], &sb)) {
-                               perror(argv[4]);
-                               die("Couldn't stat root device.");
-                       }
-                       major_root = major(sb.st_rdev);
-                       minor_root = minor(sb.st_rdev);
-               } else {
-                       major_root = 0;
-                       minor_root = 0;
-               }
-       } else {
-               major_root = DEFAULT_MAJOR_ROOT;
-               minor_root = DEFAULT_MINOR_ROOT;
-       }
-       fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
-
-       file_open(argv[1]);
-       i = read(fd, buf, sizeof(buf));
-       fprintf(stderr,"Boot sector %d bytes.\n",i);
-       if (i != 512)
-               die("Boot block must be exactly 512 bytes");
-       if (buf[510] != 0x55 || buf[511] != 0xaa)
-               die("Boot block hasn't got boot flag (0xAA55)");
-       buf[508] = minor_root;
-       buf[509] = major_root;
-       if (write(1, buf, 512) != 512)
-               die("Write call failed");
-       close (fd);
-
-       file_open(argv[2]);                                 /* Copy the setup code */
-       for (i=0 ; (c=read(fd, buf, sizeof(buf)))>0 ; i+=c )
-               if (write(1, buf, c) != c)
-                       die("Write call failed");
-       if (c != 0)
-               die("read-error on `setup'");
-       close (fd);
-
-       setup_sectors = (i + 511) / 512;        /* Pad unused space with zeros */
-       if (!(setup_sectors & 1))
-               setup_sectors++;    /* setup_sectors must be odd on NEC PC-9800 */
-       fprintf(stderr, "Setup is %d bytes.\n", i);
-       memset(buf, 0, sizeof(buf));
-       while (i < setup_sectors * 512) {
-               c = setup_sectors * 512 - i;
-               if (c > sizeof(buf))
-                       c = sizeof(buf);
-               if (write(1, buf, c) != c)
-                       die("Write call failed");
-               i += c;
-       }
-
-       file_open(argv[3]);
-       if (fstat (fd, &sb))
-               die("Unable to stat `%s': %m", argv[3]);
-       sz = sb.st_size;
-       fprintf (stderr, "System is %d kB\n", sz/1024);
-       sys_size = (sz + 15) / 16;
-       /* 0x40000*16 = 4.0 MB, reasonable estimate for the current maximum */
-       if (sys_size > (is_big_kernel ? 0x40000 : DEF_SYSSIZE))
-               die("System is too big. Try using %smodules.",
-                       is_big_kernel ? "" : "bzImage or ");
-       while (sz > 0) {
-               int l, n;
-
-               l = (sz > sizeof(buf)) ? sizeof(buf) : sz;
-               if ((n=read(fd, buf, l)) != l) {
-                       if (n < 0)
-                               die("Error reading %s: %m", argv[3]);
-                       else
-                               die("%s: Unexpected EOF", argv[3]);
-               }
-               if (write(1, buf, l) != l)
-                       die("Write failed");
-               sz -= l;
-       }
-       close(fd);
-
-       if (lseek(1, 497, SEEK_SET) != 497)                 /* Write sizes to the bootsector */
-               die("Output: seek failed");
-       buf[0] = setup_sectors;
-       if (write(1, buf, 1) != 1)
-               die("Write of setup sector count failed");
-       if (lseek(1, 500, SEEK_SET) != 500)
-               die("Output: seek failed");
-       buf[0] = (sys_size & 0xff);
-       buf[1] = ((sys_size >> 8) & 0xff);
-       if (write(1, buf, 2) != 2)
-               die("Write of image length failed");
-
-       return 0;                                           /* Everything is OK */
-}
diff --git a/arch/i386/boot98/video.S b/arch/i386/boot98/video.S
deleted file mode 100644 (file)
index 1042619..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*     video.S
- *
- *  Video mode setup, etc. for NEC PC-9800 series.
- *
- *  Copyright (C) 1997,98,99  Linux/98 project  <seraphim@kmc.kyoto-u.ac.jp>
- *
- *  Based on the video.S for IBM PC:
- *     copyright (C) Martin Mares <mj@atrey.karlin.mff.cuni.cz>
- */
-
-/* Positions of various video parameters passed to the kernel */
-/* (see also include/linux/tty.h) */
-#define PARAM_CURSOR_POS       0x00
-#define PARAM_VIDEO_PAGE       0x04
-#define PARAM_VIDEO_MODE       0x06
-#define PARAM_VIDEO_COLS       0x07
-#define PARAM_VIDEO_EGA_BX     0x0a
-#define PARAM_VIDEO_LINES      0x0e
-#define PARAM_HAVE_VGA         0x0f
-#define PARAM_FONT_POINTS      0x10
-
-#define PARAM_VIDEO98_COMPAT   0x0a
-#define PARAM_VIDEO98_HIRESO   0x0b
-#define PARAM_VIDEO98_MACHTYPE 0x0c
-#define PARAM_VIDEO98_LINES    0x0e
-#define PARAM_VIDEO98_COLS     0x0f
-
-# PARAM_LFB_* and PARAM_VESAPM_* are unused on PC-9800.
-
-# This is the main entry point called by setup.S
-# %ds *must* be pointing to the bootsector
-video: xorw    %ax, %ax
-       movw    %ax, %es                        # %es = 0
-
-       movb    %es:BIOS_FLAG, %al
-       movb    %al, PARAM_VIDEO_MODE
-
-       movb    $0, PARAM_VIDEO98_HIRESO        # 0 = normal
-       movw    $NORMAL_TEXT, PARAM_VIDEO_PAGE
-       testb   $0x8, %al
-       movw    $(80 * 256 + 25), %ax
-       jz      1f
-       # hireso machine.
-       movb    $1, PARAM_VIDEO98_HIRESO        # !0 = hi-reso
-       movb    $(HIRESO_TEXT >> 8), PARAM_VIDEO_PAGE + 1
-       movw    $(80 * 256 + 31), %ax
-1:     movw    %ax, PARAM_VIDEO98_LINES        # also sets VIDEO98_COLS
-
-       movb    $0xc0, %ch                      # 400-line graphic mode
-       movb    $0x42, %ah
-       int     $0x18
-
-       movw    $80, PARAM_VIDEO_COLS
-
-       movw    $msg_probing, %si
-       call    prtstr_cs
-
-# Check vendor from font pattern of `A'...
-
-1:     inb     $0x60, %al                      # wait V-sync
-       testb   $0x20, %al
-       jnz     1b
-2:     inb     $0x60, %al
-       testb   $0x20, %al
-       jz      2b
-
-       movb    $0x00, %al                      # select font of `A'
-       outb    %al, $0xa1
-       movb    $0x41, %al
-       outb    %al, $0xa3
-
-       movw    $8, %cx
-       movw    PARAM_VIDEO_PAGE, %ax
-       cmpw    $NORMAL_TEXT, %ax
-       je      3f
-       movb    $24, %cl                        # for hi-reso machine
-3:     addw    $0x400, %ax                     # %ax = CG window segment
-       pushw   %ds
-       movw    %ax, %ds
-       xorw    %dx, %dx                        # get sum of `A' pattern...
-       xorw    %si, %si
-4:     lodsw
-       addw    %ax, %dx
-       loop    4b
-       popw    %ds
-
-       movw    %dx, %ax
-       movw    $msg_nec, %si
-       xorw    %bx, %bx                        # vendor info will go into %bx
-       testb   $8, %es:BIOS_FLAG
-       jnz     check_hireso_vendor
-       cmpw    $0xc7f8, %ax
-       je      5f
-       jmp     6f
-check_hireso_vendor:
-       cmpw    $0x9639, %ax                    # XXX: NOT VERIFIED!!!
-       je      5f
-6:     incw    %bx                             # compatible machine
-       movw    $msg_compat, %si
-5:     movb    %bl, PARAM_VIDEO98_COMPAT
-       call    prtstr_cs
-
-       movw    $msg_fontdata, %si
-       call    prtstr_cs                       # " (CG sum of A = 0x"
-       movw    %dx, %ax
-       call    prthex
-       call    prtstr_cs                       # ") PC-98"
-
-       movb    $'0', %al
-       pushw   %ds
-       pushw   $0xf8e8
-       popw    %ds
-       cmpw    $0x2198, (0)
-       popw    %ds
-       jne     7f
-       movb    $'2', %al
-7:     call    prtchr
-       call    prtstr_cs                       # "1 "
-
-       movb    $0, PARAM_VIDEO98_MACHTYPE
-#if 0  /* XXX - This check is bogus? [0000:BIOS_FLAG2]-bit7 does NOT
-                indicate whether it is a note machine, but merely indicates
-                whether it has ``RAM drive''. */
-# check note machine
-       testb   $0x80, %es:BIOS_FLAG2
-       jnz     is_note
-       pushw   %ds
-       pushw   $0xfd80
-       popw    %ds
-       movb    (4), %al
-       popw    %ds
-       cmpb    $0x20, %al                      # EPSON note A
-       je      epson_note
-       cmpb    $0x22, %al                      # EPSON note W
-       je      epson_note
-       cmpb    $0x27, %al                      # EPSON note AE
-       je      epson_note
-       cmpb    $0x2a, %al                      # EPSON note WR
-       jne     note_done
-epson_note:
-       movb    $1, PARAM_VIDEO98_MACHTYPE
-       movw    $msg_note, %si
-       call    prtstr_cs
-note_done:
-#endif
-       
-# print h98 ? (only NEC)
-       cmpb    $0, PARAM_VIDEO98_COMPAT
-       jnz     8f                              # not NEC -> not H98
-
-       testb   $0x80, %es:BIOS_FLAG5
-       jz      8f                              # have NESA bus -> H98
-       movw    $msg_h98, %si
-       call    prtstr_cs
-       orb     $2, PARAM_VIDEO98_MACHTYPE
-8:     testb   $0x40, %es:BIOS_FLAG5
-       jz      9f
-       movw    $msg_gs, %si
-       call    prtstr_cs                       # only prints it :-)
-9:
-       movw    $msg_normal, %si                # "normal"
-       testb   $0x8, %es:BIOS_FLAG
-       jz      1f
-       movw    $msg_hireso, %si
-1:     call    prtstr_cs
-
-       movw    $msg_sysclk, %si
-       call    prtstr_cs
-       movb    $'5', %al
-       testb   $0x80, %es:BIOS_FLAG
-       jz      2f
-       movb    $'8', %al
-2:     call    prtchr
-       call    prtstr_cs
-
-#if 0
-       testb   $0x40, %es:(0x45c)
-       jz      no_30line                       # no 30-line support
-
-       movb    %es:KB_SHFT_STS, %al
-       testb   $0x01, %al                      # is SHIFT key pressed?
-       jz      no_30line
-
-       testb   $0x10, %al                      # is CTRL key pressed?
-       jnz     line40
-
-       # switch to 30-line mode
-       movb    $30, PARAM_VIDEO98_LINES
-       movw    $msg_30line, %si
-       jmp     3f
-
-line40:
-       movb    $37, PARAM_VIDEO98_LINES
-       movw    $40, PARAM_VIDEO_LINES
-       movw    $msg_40line, %si
-3:     call    prtstr_cs
-
-       movb    $0x32, %bh
-       movw    $0x300c, %ax
-       int     $0x18                           # switch video mode
-       movb    $0x0c, %ah
-       int     $0x18                           # turn on text plane
-       movw    %cs:cursor_address, %dx
-       movb    $0x13, %ah
-       int     $0x18                           # move cursor to correct place
-       mov     $0x11, %ah
-       int     $0x18                           # turn on text plane
-
-       call    prtstr_cs                       # "Ok.\r\n"
-no_30line:
-#endif
-       ret
-
-prtstr_cs:
-       pushw   %ds
-       pushw   %cs
-       popw    %ds
-       call    prtstr
-       popw    %ds
-       ret
-
-# prthex is for debugging purposes, and prints %ax in hexadecimal.
-prthex:        pushw   %cx
-       movw    $4, %cx
-1:     rolw    $4, %ax
-       pushw   %ax
-       andb    $0xf, %al
-       cmpb    $10, %al
-       sbbb    $0x69, %al
-       das
-       call    prtchr
-       popw    %ax
-       loop    1b
-       popw    %cx
-       ret
-
-msg_probing:   .string "Probing machine: "
-
-msg_nec:       .string "NEC"
-msg_compat:    .string "compatible"
-
-msg_fontdata:  .string " (CG sum of A = 0x"
-               .string ") PC-98"
-               .string "1 "
-
-msg_gs:                .string "(GS) "
-msg_h98:       .string "(H98) "
-
-msg_normal:    .string "normal"
-msg_hireso:    .string "Hi-reso"
-
-msg_sysclk:    .string " mode, system clock "
-               .string "MHz\r\n"
-
-#if 0
-msg_40line:    # cpp will concat following lines, so the assembler can deal.
-               .ascii  "\
-Video mode will be adjusted to 37-line (so-called ``40-line'') mode later.\r\n\
-THIS MODE MAY DAMAGE YOUR MONITOR PHYSICALLY. USE AT YOUR OWN RISK.\r\n"
-msg_30line:    .string "Switching video mode to 30-line (640x480) mode... "
-               .string "Ok.\r\n"
-#endif
diff --git a/arch/i386/crypto/Makefile b/arch/i386/crypto/Makefile
deleted file mode 100644 (file)
index 103c353..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# 
-# i386/crypto/Makefile 
-# 
-# Arch-specific CryptoAPI modules.
-# 
-
-obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
-
-aes-i586-y := aes-i586-asm.o aes.o
diff --git a/arch/i386/crypto/aes-i586-asm.S b/arch/i386/crypto/aes-i586-asm.S
deleted file mode 100644 (file)
index e8a0471..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-// -------------------------------------------------------------------------
-// Copyright (c) 2001, Dr Brian Gladman <                 >, Worcester, UK.
-// All rights reserved.
-//
-// LICENSE TERMS
-//
-// The free distribution and use of this software in both source and binary 
-// form is allowed (with or without changes) provided that:
-//
-//   1. distributions of this source code include the above copyright 
-//      notice, this list of conditions and the following disclaimer//
-//
-//   2. distributions in binary form include the above copyright
-//      notice, this list of conditions and the following disclaimer
-//      in the documentation and/or other associated materials//
-//
-//   3. the copyright holder's name is not used to endorse products 
-//      built using this software without specific written permission.
-//
-//
-// ALTERNATIVELY, provided that this notice is retained in full, this product
-// may be distributed under the terms of the GNU General Public License (GPL),
-// in which case the provisions of the GPL apply INSTEAD OF those given above.
-//
-// Copyright (c) 2004 Linus Torvalds <torvalds@osdl.org>
-// Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
-
-// DISCLAIMER
-//
-// This software is provided 'as is' with no explicit or implied warranties
-// in respect of its properties including, but not limited to, correctness 
-// and fitness for purpose.
-// -------------------------------------------------------------------------
-// Issue Date: 29/07/2002
-
-.file "aes-i586-asm.S"
-.text
-
-// aes_rval aes_enc_blk(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])//
-// aes_rval aes_dec_blk(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])//
-       
-#define tlen 1024   // length of each of 4 'xor' arrays (256 32-bit words)
-
-// offsets to parameters with one register pushed onto stack
-
-#define in_blk    8  // input byte array address parameter
-#define out_blk  12  // output byte array address parameter
-#define ctx      16  // AES context structure
-
-// offsets in context structure
-
-#define ekey     0   // encryption key schedule base address
-#define nrnd   256   // number of rounds
-#define dkey   260   // decryption key schedule base address
-
-// register mapping for encrypt and decrypt subroutines
-
-#define r0  eax
-#define r1  ebx
-#define r2  ecx
-#define r3  edx
-#define r4  esi
-#define r5  edi
-#define r6  ebp
-
-#define eaxl  al
-#define eaxh  ah
-#define ebxl  bl
-#define ebxh  bh
-#define ecxl  cl
-#define ecxh  ch
-#define edxl  dl
-#define edxh  dh
-
-#define _h(reg) reg##h
-#define h(reg) _h(reg)
-
-#define _l(reg) reg##l
-#define l(reg) _l(reg)
-
-// This macro takes a 32-bit word representing a column and uses
-// each of its four bytes to index into four tables of 256 32-bit
-// words to obtain values that are then xored into the appropriate
-// output registers r0, r1, r4 or r5.  
-
-// Parameters:
-//   %1  out_state[0]
-//   %2  out_state[1]
-//   %3  out_state[2]
-//   %4  out_state[3]
-//   %5  table base address
-//   %6  input register for the round (destroyed)
-//   %7  scratch register for the round
-
-#define do_col(a1, a2, a3, a4, a5, a6, a7)     \
-       movzx   %l(a6),%a7;                     \
-       xor     a5(,%a7,4),%a1;                 \
-       movzx   %h(a6),%a7;                     \
-       shr     $16,%a6;                        \
-       xor     a5+tlen(,%a7,4),%a2;            \
-       movzx   %l(a6),%a7;                     \
-       movzx   %h(a6),%a6;                     \
-       xor     a5+2*tlen(,%a7,4),%a3;          \
-       xor     a5+3*tlen(,%a6,4),%a4;
-
-// initialise output registers from the key schedule
-
-#define do_fcol(a1, a2, a3, a4, a5, a6, a7, a8)        \
-       mov     0 a8,%a1;                       \
-       movzx   %l(a6),%a7;                     \
-       mov     12 a8,%a2;                      \
-       xor     a5(,%a7,4),%a1;                 \
-       mov     4 a8,%a4;                       \
-       movzx   %h(a6),%a7;                     \
-       shr     $16,%a6;                        \
-       xor     a5+tlen(,%a7,4),%a2;            \
-       movzx   %l(a6),%a7;                     \
-       movzx   %h(a6),%a6;                     \
-       xor     a5+3*tlen(,%a6,4),%a4;          \
-       mov     %a3,%a6;                        \
-       mov     8 a8,%a3;                       \
-       xor     a5+2*tlen(,%a7,4),%a3;
-
-// initialise output registers from the key schedule
-
-#define do_icol(a1, a2, a3, a4, a5, a6, a7, a8)        \
-       mov     0 a8,%a1;                       \
-       movzx   %l(a6),%a7;                     \
-       mov     4 a8,%a2;                       \
-       xor     a5(,%a7,4),%a1;                 \
-       mov     12 a8,%a4;                      \
-       movzx   %h(a6),%a7;                     \
-       shr     $16,%a6;                        \
-       xor     a5+tlen(,%a7,4),%a2;            \
-       movzx   %l(a6),%a7;                     \
-       movzx   %h(a6),%a6;                     \
-       xor     a5+3*tlen(,%a6,4),%a4;          \
-       mov     %a3,%a6;                        \
-       mov     8 a8,%a3;                       \
-       xor     a5+2*tlen(,%a7,4),%a3;
-
-
-// original Gladman had conditional saves to MMX regs.
-#define save(a1, a2)           \
-       mov     %a2,4*a1(%esp)
-
-#define restore(a1, a2)                \
-       mov     4*a2(%esp),%a1
-
-// This macro performs a forward encryption cycle. It is entered with
-// the first previous round column values in r0, r1, r4 and r5 and
-// exits with the final values in the same registers, using the MMX
-// registers mm0-mm1 or the stack for temporary storage
-
-// mov current column values into the MMX registers
-#define fwd_rnd(arg, table)                                    \
-       /* mov current column values into the MMX registers */  \
-       mov     %r0,%r2;                                        \
-       save   (0,r1);                                          \
-       save   (1,r5);                                          \
-                                                               \
-       /* compute new column values */                         \
-       do_fcol(r0,r5,r4,r1,table, r2,r3, arg);                 \
-       do_col (r4,r1,r0,r5,table, r2,r3);                      \
-       restore(r2,0);                                          \
-       do_col (r1,r0,r5,r4,table, r2,r3);                      \
-       restore(r2,1);                                          \
-       do_col (r5,r4,r1,r0,table, r2,r3);
-
-// This macro performs an inverse encryption cycle. It is entered with
-// the first previous round column values in r0, r1, r4 and r5 and
-// exits with the final values in the same registers, using the MMX
-// registers mm0-mm1 or the stack for temporary storage
-
-#define inv_rnd(arg, table)                                    \
-       /* mov current column values into the MMX registers */  \
-       mov     %r0,%r2;                                        \
-       save    (0,r1);                                         \
-       save    (1,r5);                                         \
-                                                               \
-       /* compute new column values */                         \
-       do_icol(r0,r1,r4,r5, table, r2,r3, arg);                \
-       do_col (r4,r5,r0,r1, table, r2,r3);                     \
-       restore(r2,0);                                          \
-       do_col (r1,r4,r5,r0, table, r2,r3);                     \
-       restore(r2,1);                                          \
-       do_col (r5,r0,r1,r4, table, r2,r3);
-
-// AES (Rijndael) Encryption Subroutine
-
-.global  aes_enc_blk
-
-.extern  ft_tab
-.extern  fl_tab
-
-.align 4
-
-aes_enc_blk:
-       push    %ebp
-       mov     ctx(%esp),%ebp      // pointer to context
-       xor     %eax,%eax
-
-// CAUTION: the order and the values used in these assigns 
-// rely on the register mappings
-
-1:     push    %ebx
-       mov     in_blk+4(%esp),%r2
-       push    %esi
-       mov     nrnd(%ebp),%r3   // number of rounds
-       push    %edi
-       lea     ekey(%ebp),%r6   // key pointer
-
-// input four columns and xor in first round key
-
-       mov     (%r2),%r0
-       mov     4(%r2),%r1
-       mov     8(%r2),%r4
-       mov     12(%r2),%r5
-       xor     (%r6),%r0
-       xor     4(%r6),%r1
-       xor     8(%r6),%r4
-       xor     12(%r6),%r5
-
-       sub     $8,%esp           // space for register saves on stack
-       add     $16,%r6           // increment to next round key   
-       sub     $10,%r3          
-       je      4f              // 10 rounds for 128-bit key
-       add     $32,%r6
-       sub     $2,%r3
-       je      3f              // 12 rounds for 128-bit key
-       add     $32,%r6
-
-2:     fwd_rnd( -64(%r6) ,ft_tab)      // 14 rounds for 128-bit key
-       fwd_rnd( -48(%r6) ,ft_tab)
-3:     fwd_rnd( -32(%r6) ,ft_tab)      // 12 rounds for 128-bit key
-       fwd_rnd( -16(%r6) ,ft_tab)
-4:     fwd_rnd(    (%r6) ,ft_tab)      // 10 rounds for 128-bit key
-       fwd_rnd( +16(%r6) ,ft_tab)
-       fwd_rnd( +32(%r6) ,ft_tab)
-       fwd_rnd( +48(%r6) ,ft_tab)
-       fwd_rnd( +64(%r6) ,ft_tab)
-       fwd_rnd( +80(%r6) ,ft_tab)
-       fwd_rnd( +96(%r6) ,ft_tab)
-       fwd_rnd(+112(%r6) ,ft_tab)
-       fwd_rnd(+128(%r6) ,ft_tab)
-       fwd_rnd(+144(%r6) ,fl_tab)      // last round uses a different table
-
-// move final values to the output array.  CAUTION: the 
-// order of these assigns rely on the register mappings
-
-       add     $8,%esp
-       mov     out_blk+12(%esp),%r6
-       mov     %r5,12(%r6)
-       pop     %edi
-       mov     %r4,8(%r6)
-       pop     %esi
-       mov     %r1,4(%r6)
-       pop     %ebx
-       mov     %r0,(%r6)
-       pop     %ebp
-       mov     $1,%eax
-       ret
-
-// AES (Rijndael) Decryption Subroutine
-
-.global  aes_dec_blk
-
-.extern  it_tab
-.extern  il_tab
-
-.align 4
-
-aes_dec_blk:
-       push    %ebp
-       mov     ctx(%esp),%ebp       // pointer to context
-       xor     %eax,%eax
-
-// CAUTION: the order and the values used in these assigns 
-// rely on the register mappings
-
-1:     push    %ebx
-       mov     in_blk+4(%esp),%r2
-       push    %esi
-       mov     nrnd(%ebp),%r3   // number of rounds
-       push    %edi
-       lea     dkey(%ebp),%r6   // key pointer
-       mov     %r3,%r0
-       shl     $4,%r0
-       add     %r0,%r6
-       
-// input four columns and xor in first round key
-
-       mov     (%r2),%r0
-       mov     4(%r2),%r1
-       mov     8(%r2),%r4
-       mov     12(%r2),%r5
-       xor     (%r6),%r0
-       xor     4(%r6),%r1
-       xor     8(%r6),%r4
-       xor     12(%r6),%r5
-
-       sub     $8,%esp           // space for register saves on stack
-       sub     $16,%r6           // increment to next round key   
-       sub     $10,%r3          
-       je      4f              // 10 rounds for 128-bit key
-       sub     $32,%r6
-       sub     $2,%r3
-       je      3f              // 12 rounds for 128-bit key
-       sub     $32,%r6
-
-2:     inv_rnd( +64(%r6), it_tab)      // 14 rounds for 128-bit key 
-       inv_rnd( +48(%r6), it_tab)
-3:     inv_rnd( +32(%r6), it_tab)      // 12 rounds for 128-bit key
-       inv_rnd( +16(%r6), it_tab)
-4:     inv_rnd(    (%r6), it_tab)      // 10 rounds for 128-bit key
-       inv_rnd( -16(%r6), it_tab)
-       inv_rnd( -32(%r6), it_tab)
-       inv_rnd( -48(%r6), it_tab)
-       inv_rnd( -64(%r6), it_tab)
-       inv_rnd( -80(%r6), it_tab)
-       inv_rnd( -96(%r6), it_tab)
-       inv_rnd(-112(%r6), it_tab)
-       inv_rnd(-128(%r6), it_tab)
-       inv_rnd(-144(%r6), il_tab)      // last round uses a different table
-
-// move final values to the output array.  CAUTION: the 
-// order of these assigns rely on the register mappings
-
-       add     $8,%esp
-       mov     out_blk+12(%esp),%r6
-       mov     %r5,12(%r6)
-       pop     %edi
-       mov     %r4,8(%r6)
-       pop     %esi
-       mov     %r1,4(%r6)
-       pop     %ebx
-       mov     %r0,(%r6)
-       pop     %ebp
-       mov     $1,%eax
-       ret
-
diff --git a/arch/i386/crypto/aes.c b/arch/i386/crypto/aes.c
deleted file mode 100644 (file)
index 5a34ee9..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-/* 
- * 
- * Glue Code for optimized 586 assembler version of AES
- *
- * Copyright (c) 2002, Dr Brian Gladman <>, Worcester, UK.
- * All rights reserved.
- *
- * LICENSE TERMS
- *
- * The free distribution and use of this software in both source and binary
- * form is allowed (with or without changes) provided that:
- *
- *   1. distributions of this source code include the above copyright
- *      notice, this list of conditions and the following disclaimer;
- *
- *   2. distributions in binary form include the above copyright
- *      notice, this list of conditions and the following disclaimer
- *      in the documentation and/or other associated materials;
- *
- *   3. the copyright holder's name is not used to endorse products
- *      built using this software without specific written permission.
- *
- * ALTERNATIVELY, provided that this notice is retained in full, this product
- * may be distributed under the terms of the GNU General Public License (GPL),
- * in which case the provisions of the GPL apply INSTEAD OF those given above.
- *
- * DISCLAIMER
- *
- * This software is provided 'as is' with no explicit or implied warranties
- * in respect of its properties, including, but not limited to, correctness
- * and/or fitness for purpose.
- *
- * Copyright (c) 2003, Adam J. Richter <adam@yggdrasil.com> (conversion to
- * 2.5 API).
- * Copyright (c) 2003, 2004 Fruhwirth Clemens <clemens@endorphin.org>
- * Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
- *
- */
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/crypto.h>
-#include <linux/linkage.h>
-
-asmlinkage void aes_enc_blk(const u8 *src, u8 *dst, void *ctx);
-asmlinkage void aes_dec_blk(const u8 *src, u8 *dst, void *ctx);
-
-#define AES_MIN_KEY_SIZE       16
-#define AES_MAX_KEY_SIZE       32
-#define AES_BLOCK_SIZE         16
-#define AES_KS_LENGTH          4 * AES_BLOCK_SIZE
-#define RC_LENGTH              29
-
-struct aes_ctx {
-       u32 ekey[AES_KS_LENGTH];
-       u32 rounds;
-       u32 dkey[AES_KS_LENGTH];
-};
-
-#define WPOLY 0x011b
-#define u32_in(x) le32_to_cpu(*(const u32 *)(x))
-#define bytes2word(b0, b1, b2, b3)  \
-       (((u32)(b3) << 24) | ((u32)(b2) << 16) | ((u32)(b1) << 8) | (b0))
-
-/* define the finite field multiplies required for Rijndael */
-#define f2(x) ((x) ? pow[log[x] + 0x19] : 0)
-#define f3(x) ((x) ? pow[log[x] + 0x01] : 0)
-#define f9(x) ((x) ? pow[log[x] + 0xc7] : 0)
-#define fb(x) ((x) ? pow[log[x] + 0x68] : 0)
-#define fd(x) ((x) ? pow[log[x] + 0xee] : 0)
-#define fe(x) ((x) ? pow[log[x] + 0xdf] : 0)
-#define fi(x) ((x) ?   pow[255 - log[x]]: 0)
-
-static inline u32 upr(u32 x, int n)
-{
-       return (x << 8 * n) | (x >> (32 - 8 * n));
-}
-
-static inline u8 bval(u32 x, int n)
-{
-       return x >> 8 * n;
-}
-
-/* The forward and inverse affine transformations used in the S-box */
-#define fwd_affine(x) \
-       (w = (u32)x, w ^= (w<<1)^(w<<2)^(w<<3)^(w<<4), 0x63^(u8)(w^(w>>8)))
-
-#define inv_affine(x) \
-       (w = (u32)x, w = (w<<1)^(w<<3)^(w<<6), 0x05^(u8)(w^(w>>8)))
-
-static u32 rcon_tab[RC_LENGTH];
-
-u32 ft_tab[4][256];
-u32 fl_tab[4][256];
-u32 ls_tab[4][256];
-u32 im_tab[4][256];
-u32 il_tab[4][256];
-u32 it_tab[4][256];
-
-void gen_tabs(void)
-{
-       u32 i, w;
-       u8 pow[512], log[256];
-
-       /*
-        * log and power tables for GF(2^8) finite field with
-        * WPOLY as modular polynomial - the simplest primitive
-        * root is 0x03, used here to generate the tables.
-        */
-       i = 0; w = 1; 
-       
-       do {
-               pow[i] = (u8)w;
-               pow[i + 255] = (u8)w;
-               log[w] = (u8)i++;
-               w ^=  (w << 1) ^ (w & 0x80 ? WPOLY : 0);
-       } while (w != 1);
-       
-       for(i = 0, w = 1; i < RC_LENGTH; ++i) {
-               rcon_tab[i] = bytes2word(w, 0, 0, 0);
-               w = f2(w);
-       }
-
-       for(i = 0; i < 256; ++i) {
-               u8 b;
-               
-               b = fwd_affine(fi((u8)i));
-               w = bytes2word(f2(b), b, b, f3(b));
-
-               /* tables for a normal encryption round */
-               ft_tab[0][i] = w;
-               ft_tab[1][i] = upr(w, 1);
-               ft_tab[2][i] = upr(w, 2);
-               ft_tab[3][i] = upr(w, 3);
-               w = bytes2word(b, 0, 0, 0);
-               
-               /*
-                * tables for last encryption round
-                * (may also be used in the key schedule)
-                */
-               fl_tab[0][i] = w;
-               fl_tab[1][i] = upr(w, 1);
-               fl_tab[2][i] = upr(w, 2);
-               fl_tab[3][i] = upr(w, 3);
-               
-               /*
-                * table for key schedule if fl_tab above is
-                * not of the required form
-                */
-               ls_tab[0][i] = w;
-               ls_tab[1][i] = upr(w, 1);
-               ls_tab[2][i] = upr(w, 2);
-               ls_tab[3][i] = upr(w, 3);
-               
-               b = fi(inv_affine((u8)i));
-               w = bytes2word(fe(b), f9(b), fd(b), fb(b));
-
-               /* tables for the inverse mix column operation  */
-               im_tab[0][b] = w;
-               im_tab[1][b] = upr(w, 1);
-               im_tab[2][b] = upr(w, 2);
-               im_tab[3][b] = upr(w, 3);
-
-               /* tables for a normal decryption round */
-               it_tab[0][i] = w;
-               it_tab[1][i] = upr(w,1);
-               it_tab[2][i] = upr(w,2);
-               it_tab[3][i] = upr(w,3);
-
-               w = bytes2word(b, 0, 0, 0);
-               
-               /* tables for last decryption round */
-               il_tab[0][i] = w;
-               il_tab[1][i] = upr(w,1);
-               il_tab[2][i] = upr(w,2);
-               il_tab[3][i] = upr(w,3);
-    }
-}
-
-#define four_tables(x,tab,vf,rf,c)             \
-(      tab[0][bval(vf(x,0,c),rf(0,c))] ^       \
-       tab[1][bval(vf(x,1,c),rf(1,c))] ^       \
-       tab[2][bval(vf(x,2,c),rf(2,c))] ^       \
-       tab[3][bval(vf(x,3,c),rf(3,c))]         \
-)
-
-#define vf1(x,r,c)  (x)
-#define rf1(r,c)    (r)
-#define rf2(r,c)    ((r-c)&3)
-
-#define inv_mcol(x) four_tables(x,im_tab,vf1,rf1,0)
-#define ls_box(x,c) four_tables(x,fl_tab,vf1,rf2,c)
-
-#define ff(x) inv_mcol(x)
-
-#define ke4(k,i)                                                       \
-{                                                                      \
-       k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ rcon_tab[i];            \
-       k[4*(i)+5] = ss[1] ^= ss[0];                                    \
-       k[4*(i)+6] = ss[2] ^= ss[1];                                    \
-       k[4*(i)+7] = ss[3] ^= ss[2];                                    \
-}
-
-#define kel4(k,i)                                                      \
-{                                                                      \
-       k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ rcon_tab[i];            \
-       k[4*(i)+5] = ss[1] ^= ss[0];                                    \
-       k[4*(i)+6] = ss[2] ^= ss[1]; k[4*(i)+7] = ss[3] ^= ss[2];       \
-}
-
-#define ke6(k,i)                                                       \
-{                                                                      \
-       k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i];           \
-       k[6*(i)+ 7] = ss[1] ^= ss[0];                                   \
-       k[6*(i)+ 8] = ss[2] ^= ss[1];                                   \
-       k[6*(i)+ 9] = ss[3] ^= ss[2];                                   \
-       k[6*(i)+10] = ss[4] ^= ss[3];                                   \
-       k[6*(i)+11] = ss[5] ^= ss[4];                                   \
-}
-
-#define kel6(k,i)                                                      \
-{                                                                      \
-       k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i];           \
-       k[6*(i)+ 7] = ss[1] ^= ss[0];                                   \
-       k[6*(i)+ 8] = ss[2] ^= ss[1];                                   \
-       k[6*(i)+ 9] = ss[3] ^= ss[2];                                   \
-}
-
-#define ke8(k,i)                                                       \
-{                                                                      \
-       k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i];           \
-       k[8*(i)+ 9] = ss[1] ^= ss[0];                                   \
-       k[8*(i)+10] = ss[2] ^= ss[1];                                   \
-       k[8*(i)+11] = ss[3] ^= ss[2];                                   \
-       k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0);                         \
-       k[8*(i)+13] = ss[5] ^= ss[4];                                   \
-       k[8*(i)+14] = ss[6] ^= ss[5];                                   \
-       k[8*(i)+15] = ss[7] ^= ss[6];                                   \
-}
-
-#define kel8(k,i)                                                      \
-{                                                                      \
-       k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i];           \
-       k[8*(i)+ 9] = ss[1] ^= ss[0];                                   \
-       k[8*(i)+10] = ss[2] ^= ss[1];                                   \
-       k[8*(i)+11] = ss[3] ^= ss[2];                                   \
-}
-
-#define kdf4(k,i)                                                      \
-{                                                                      \
-       ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3];                          \
-       ss[1] = ss[1] ^ ss[3];                                          \
-       ss[2] = ss[2] ^ ss[3];                                          \
-       ss[3] = ss[3];                                                  \
-       ss[4] = ls_box(ss[(i+3) % 4], 3) ^ rcon_tab[i];                 \
-       ss[i % 4] ^= ss[4];                                             \
-       ss[4] ^= k[4*(i)];                                              \
-       k[4*(i)+4] = ff(ss[4]);                                         \
-       ss[4] ^= k[4*(i)+1];                                            \
-       k[4*(i)+5] = ff(ss[4]);                                         \
-       ss[4] ^= k[4*(i)+2];                                            \
-       k[4*(i)+6] = ff(ss[4]);                                         \
-       ss[4] ^= k[4*(i)+3];                                            \
-       k[4*(i)+7] = ff(ss[4]);                                         \
-}
-
-#define kd4(k,i)                                                       \
-{                                                                      \
-       ss[4] = ls_box(ss[(i+3) % 4], 3) ^ rcon_tab[i];                 \
-       ss[i % 4] ^= ss[4];                                             \
-       ss[4] = ff(ss[4]);                                              \
-       k[4*(i)+4] = ss[4] ^= k[4*(i)];                                 \
-       k[4*(i)+5] = ss[4] ^= k[4*(i)+1];                               \
-       k[4*(i)+6] = ss[4] ^= k[4*(i)+2];                               \
-       k[4*(i)+7] = ss[4] ^= k[4*(i)+3];                               \
-}
-
-#define kdl4(k,i)                                                      \
-{                                                                      \
-       ss[4] = ls_box(ss[(i+3) % 4], 3) ^ rcon_tab[i];                 \
-       ss[i % 4] ^= ss[4];                                             \
-       k[4*(i)+4] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3];                  \
-       k[4*(i)+5] = ss[1] ^ ss[3];                                     \
-       k[4*(i)+6] = ss[0];                                             \
-       k[4*(i)+7] = ss[1];                                             \
-}
-
-#define kdf6(k,i)                                                      \
-{                                                                      \
-       ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i];                         \
-       k[6*(i)+ 6] = ff(ss[0]);                                        \
-       ss[1] ^= ss[0];                                                 \
-       k[6*(i)+ 7] = ff(ss[1]);                                        \
-       ss[2] ^= ss[1];                                                 \
-       k[6*(i)+ 8] = ff(ss[2]);                                        \
-       ss[3] ^= ss[2];                                                 \
-       k[6*(i)+ 9] = ff(ss[3]);                                        \
-       ss[4] ^= ss[3];                                                 \
-       k[6*(i)+10] = ff(ss[4]);                                        \
-       ss[5] ^= ss[4];                                                 \
-       k[6*(i)+11] = ff(ss[5]);                                        \
-}
-
-#define kd6(k,i)                                                       \
-{                                                                      \
-       ss[6] = ls_box(ss[5],3) ^ rcon_tab[i];                          \
-       ss[0] ^= ss[6]; ss[6] = ff(ss[6]);                              \
-       k[6*(i)+ 6] = ss[6] ^= k[6*(i)];                                \
-       ss[1] ^= ss[0];                                                 \
-       k[6*(i)+ 7] = ss[6] ^= k[6*(i)+ 1];                             \
-       ss[2] ^= ss[1];                                                 \
-       k[6*(i)+ 8] = ss[6] ^= k[6*(i)+ 2];                             \
-       ss[3] ^= ss[2];                                                 \
-       k[6*(i)+ 9] = ss[6] ^= k[6*(i)+ 3];                             \
-       ss[4] ^= ss[3];                                                 \
-       k[6*(i)+10] = ss[6] ^= k[6*(i)+ 4];                             \
-       ss[5] ^= ss[4];                                                 \
-       k[6*(i)+11] = ss[6] ^= k[6*(i)+ 5];                             \
-}
-
-#define kdl6(k,i)                                                      \
-{                                                                      \
-       ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i];                         \
-       k[6*(i)+ 6] = ss[0];                                            \
-       ss[1] ^= ss[0];                                                 \
-       k[6*(i)+ 7] = ss[1];                                            \
-       ss[2] ^= ss[1];                                                 \
-       k[6*(i)+ 8] = ss[2];                                            \
-       ss[3] ^= ss[2];                                                 \
-       k[6*(i)+ 9] = ss[3];                                            \
-}
-
-#define kdf8(k,i)                                                      \
-{                                                                      \
-       ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i];                         \
-       k[8*(i)+ 8] = ff(ss[0]);                                        \
-       ss[1] ^= ss[0];                                                 \
-       k[8*(i)+ 9] = ff(ss[1]);                                        \
-       ss[2] ^= ss[1];                                                 \
-       k[8*(i)+10] = ff(ss[2]);                                        \
-       ss[3] ^= ss[2];                                                 \
-       k[8*(i)+11] = ff(ss[3]);                                        \
-       ss[4] ^= ls_box(ss[3],0);                                       \
-       k[8*(i)+12] = ff(ss[4]);                                        \
-       ss[5] ^= ss[4];                                                 \
-       k[8*(i)+13] = ff(ss[5]);                                        \
-       ss[6] ^= ss[5];                                                 \
-       k[8*(i)+14] = ff(ss[6]);                                        \
-       ss[7] ^= ss[6];                                                 \
-       k[8*(i)+15] = ff(ss[7]);                                        \
-}
-
-#define kd8(k,i)                                                       \
-{                                                                      \
-       u32 __g = ls_box(ss[7],3) ^ rcon_tab[i];                        \
-       ss[0] ^= __g;                                                   \
-       __g = ff(__g);                                                  \
-       k[8*(i)+ 8] = __g ^= k[8*(i)];                                  \
-       ss[1] ^= ss[0];                                                 \
-       k[8*(i)+ 9] = __g ^= k[8*(i)+ 1];                               \
-       ss[2] ^= ss[1];                                                 \
-       k[8*(i)+10] = __g ^= k[8*(i)+ 2];                               \
-       ss[3] ^= ss[2];                                                 \
-       k[8*(i)+11] = __g ^= k[8*(i)+ 3];                               \
-       __g = ls_box(ss[3],0);                                          \
-       ss[4] ^= __g;                                                   \
-       __g = ff(__g);                                                  \
-       k[8*(i)+12] = __g ^= k[8*(i)+ 4];                               \
-       ss[5] ^= ss[4];                                                 \
-       k[8*(i)+13] = __g ^= k[8*(i)+ 5];                               \
-       ss[6] ^= ss[5];                                                 \
-       k[8*(i)+14] = __g ^= k[8*(i)+ 6];                               \
-       ss[7] ^= ss[6];                                                 \
-       k[8*(i)+15] = __g ^= k[8*(i)+ 7];                               \
-}
-
-#define kdl8(k,i)                                                      \
-{                                                                      \
-       ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i];                         \
-       k[8*(i)+ 8] = ss[0];                                            \
-       ss[1] ^= ss[0];                                                 \
-       k[8*(i)+ 9] = ss[1];                                            \
-       ss[2] ^= ss[1];                                                 \
-       k[8*(i)+10] = ss[2];                                            \
-       ss[3] ^= ss[2];                                                 \
-       k[8*(i)+11] = ss[3];                                            \
-}
-
-static int
-aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
-{
-       int i;
-       u32 ss[8];
-       struct aes_ctx *ctx = ctx_arg;
-
-       /* encryption schedule */
-       
-       ctx->ekey[0] = ss[0] = u32_in(in_key);
-       ctx->ekey[1] = ss[1] = u32_in(in_key + 4);
-       ctx->ekey[2] = ss[2] = u32_in(in_key + 8);
-       ctx->ekey[3] = ss[3] = u32_in(in_key + 12);
-
-       switch(key_len) {
-       case 16:
-               for (i = 0; i < 9; i++)
-                       ke4(ctx->ekey, i);
-               kel4(ctx->ekey, 9);
-               ctx->rounds = 10;
-               break;
-               
-       case 24:
-               ctx->ekey[4] = ss[4] = u32_in(in_key + 16);
-               ctx->ekey[5] = ss[5] = u32_in(in_key + 20);
-               for (i = 0; i < 7; i++)
-                       ke6(ctx->ekey, i);
-               kel6(ctx->ekey, 7); 
-               ctx->rounds = 12;
-               break;
-
-       case 32:
-               ctx->ekey[4] = ss[4] = u32_in(in_key + 16);
-               ctx->ekey[5] = ss[5] = u32_in(in_key + 20);
-               ctx->ekey[6] = ss[6] = u32_in(in_key + 24);
-               ctx->ekey[7] = ss[7] = u32_in(in_key + 28);
-               for (i = 0; i < 6; i++)
-                       ke8(ctx->ekey, i);
-               kel8(ctx->ekey, 6);
-               ctx->rounds = 14;
-               break;
-
-       default:
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       }
-       
-       /* decryption schedule */
-       
-       ctx->dkey[0] = ss[0] = u32_in(in_key);
-       ctx->dkey[1] = ss[1] = u32_in(in_key + 4);
-       ctx->dkey[2] = ss[2] = u32_in(in_key + 8);
-       ctx->dkey[3] = ss[3] = u32_in(in_key + 12);
-
-       switch (key_len) {
-       case 16:
-               kdf4(ctx->dkey, 0);
-               for (i = 1; i < 9; i++)
-                       kd4(ctx->dkey, i);
-               kdl4(ctx->dkey, 9);
-               break;
-               
-       case 24:
-               ctx->dkey[4] = ff(ss[4] = u32_in(in_key + 16));
-               ctx->dkey[5] = ff(ss[5] = u32_in(in_key + 20));
-               kdf6(ctx->dkey, 0);
-               for (i = 1; i < 7; i++)
-                       kd6(ctx->dkey, i);
-               kdl6(ctx->dkey, 7);
-               break;
-
-       case 32:
-               ctx->dkey[4] = ff(ss[4] = u32_in(in_key + 16));
-               ctx->dkey[5] = ff(ss[5] = u32_in(in_key + 20));
-               ctx->dkey[6] = ff(ss[6] = u32_in(in_key + 24));
-               ctx->dkey[7] = ff(ss[7] = u32_in(in_key + 28));
-               kdf8(ctx->dkey, 0);
-               for (i = 1; i < 6; i++)
-                       kd8(ctx->dkey, i);
-               kdl8(ctx->dkey, 6);
-               break;
-       }
-       return 0;
-}
-
-static inline void aes_encrypt(void *ctx, u8 *dst, const u8 *src)
-{
-       aes_enc_blk(src, dst, ctx);
-}
-static inline void aes_decrypt(void *ctx, u8 *dst, const u8 *src)
-{
-       aes_dec_blk(src, dst, ctx);
-}
-
-
-static struct crypto_alg aes_alg = {
-       .cra_name               =       "aes",
-       .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
-       .cra_blocksize          =       AES_BLOCK_SIZE,
-       .cra_ctxsize            =       sizeof(struct aes_ctx),
-       .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(aes_alg.cra_list),
-       .cra_u                  =       {
-               .cipher = {
-                       .cia_min_keysize        =       AES_MIN_KEY_SIZE,
-                       .cia_max_keysize        =       AES_MAX_KEY_SIZE,
-                       .cia_setkey             =       aes_set_key,
-                       .cia_encrypt            =       aes_encrypt,
-                       .cia_decrypt            =       aes_decrypt
-               }
-       }
-};
-
-static int __init aes_init(void)
-{
-       gen_tabs();
-       return crypto_register_alg(&aes_alg);
-}
-
-static void __exit aes_fini(void)
-{
-       crypto_unregister_alg(&aes_alg);
-}
-
-module_init(aes_init);
-module_exit(aes_fini);
-
-MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm, i586 asm optimized");
-MODULE_LICENSE("Dual BSD/GPL");
-MODULE_AUTHOR("Fruhwirth Clemens, James Morris, Brian Gladman, Adam Richter");
-MODULE_ALIAS("aes");
index 00cc32e..a056d50 100644 (file)
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.lds.s
 obj-y  := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \
                ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \
                pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
-               doublefault.o
+               doublefault.o entry_trampoline.o
 
 obj-y                          += cpu/
 obj-y                          += timers/
@@ -32,7 +32,7 @@ obj-$(CONFIG_HPET_TIMER)      += time_hpet.o
 obj-$(CONFIG_EFI)              += efi.o efi_stub.o
 obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
 
-EXTRA_AFLAGS   := -traditional
+EXTRA_AFLAGS   := -traditional -m32
 
 obj-$(CONFIG_SCx200)           += scx200.o
 
@@ -47,7 +47,7 @@ quiet_cmd_syscall = SYSCALL $@
       cmd_syscall = $(CC) -nostdlib $(SYSCFLAGS_$(@F)) \
                          -Wl,-T,$(filter-out FORCE,$^) -o $@
 
-vsyscall-flags = -shared -s -Wl,-soname=linux-gate.so.1
+vsyscall-flags = -m32 -shared -s -Wl,-soname=linux-gate.so.1
 SYSCFLAGS_vsyscall-sysenter.so = $(vsyscall-flags)
 SYSCFLAGS_vsyscall-int80.so    = $(vsyscall-flags)
 
@@ -62,6 +62,6 @@ extra-y += vsyscall-syms.o
 $(obj)/built-in.o: $(obj)/vsyscall-syms.o
 $(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
 
-SYSCFLAGS_vsyscall-syms.o = -r
+SYSCFLAGS_vsyscall-syms.o = -m32 -r
 $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds $(obj)/vsyscall-sysenter.o FORCE
        $(call if_changed,syscall)
index e54aefa..a85d8f7 100644 (file)
@@ -484,7 +484,7 @@ acpi_scan_rsdp (
         * RSDP signature.
         */
        for (offset = 0; offset < length; offset += 16) {
-               if (strncmp((char *) (start + offset), "RSD PTR ", sig_len))
+               if (strncmp((char *) __va(start + offset), "RSD PTR ", sig_len))
                        continue;
                return (start + offset);
        }
index 92fd176..629f7b8 100644 (file)
@@ -19,13 +19,29 @@ extern void zap_low_mappings(void);
 
 extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
 
-static void init_low_mapping(pgd_t *pgd, int pgd_limit)
+static void map_low(pgd_t *pgd_base, unsigned long start, unsigned long end)
 {
-       int pgd_ofs = 0;
+       unsigned long vaddr;
+       pmd_t *pmd;
+       pgd_t *pgd;
+       int i, j;
 
-       while ((pgd_ofs < pgd_limit) && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) {
-               set_pgd(pgd, *(pgd+USER_PTRS_PER_PGD));
-               pgd_ofs++, pgd++;
+       pgd = pgd_base;
+
+       for (i = 0; i < PTRS_PER_PGD; pgd++, i++) {
+               vaddr = i*PGDIR_SIZE;
+               if (end && (vaddr >= end))
+                       break;
+               pmd = pmd_offset(pgd, 0);
+               for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
+                       vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
+                       if (end && (vaddr >= end))
+                               break;
+                       if (vaddr < start)
+                               continue;
+                       set_pmd(pmd, __pmd(_KERNPG_TABLE + _PAGE_PSE +
+                                                               vaddr - start));
+               }
        }
 }
 
@@ -39,7 +55,9 @@ int acpi_save_state_mem (void)
 {
        if (!acpi_wakeup_address)
                return 1;
-       init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD);
+       if (!cpu_has_pse)
+               return 1;
+       map_low(swapper_pg_dir, 0, LOW_MAPPINGS_SIZE);
        memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start);
        acpi_copy_wakeup_routine(acpi_wakeup_address);
 
index 2c5de1d..c43349a 100644 (file)
@@ -67,6 +67,13 @@ wakeup_code:
        movw    $0x0e00 + 'i', %fs:(0x12)
        
        # need a gdt
+       #use the gdt copied in this low mem
+       lea     temp_gdt_table - wakeup_code, %eax
+       xor     %ebx, %ebx
+       movw    %ds, %bx
+       shll    $4, %ebx
+       addl    %ebx, %eax
+       movl    %eax, real_save_gdt + 2 - wakeup_code
        lgdt    real_save_gdt - wakeup_code
 
        movl    real_save_cr0 - wakeup_code, %eax
@@ -89,6 +96,7 @@ real_save_cr4:        .long 0
 real_magic:    .long 0
 video_mode:    .long 0
 video_flags:   .long 0
+temp_gdt_table: .fill GDT_ENTRIES, 8, 0
 
 bogus_real_magic:
        movw    $0x0e00 + 'B', %fs:(0x12)
@@ -231,6 +239,13 @@ ENTRY(acpi_copy_wakeup_routine)
        movl    %edx, real_save_cr0 - wakeup_start (%eax)
        sgdt    real_save_gdt - wakeup_start (%eax)
 
+       # gdt wont be addressable from real mode in 4g4g split
+       # copying it to the lower mem
+       xor     %ecx, %ecx
+       movw    saved_gdt, %cx
+       movl    saved_gdt + 2, %esi     
+       lea     temp_gdt_table - wakeup_start (%eax), %edi      
+       rep movsb
        movl    saved_videomode, %edx
        movl    %edx, video_mode - wakeup_start (%eax)
        movl    acpi_video_flags, %edx
index 6248bf2..43943f8 100644 (file)
@@ -52,6 +52,7 @@ void foo(void)
        OFFSET(TI_preempt_count, thread_info, preempt_count);
        OFFSET(TI_addr_limit, thread_info, addr_limit);
        OFFSET(TI_restart_block, thread_info, restart_block);
+       OFFSET(TI_sysenter_return, thread_info, sysenter_return);
        BLANK();
 
        OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
@@ -61,5 +62,21 @@ void foo(void)
        DEFINE(TSS_sysenter_esp0, offsetof(struct tss_struct, esp0) -
                 sizeof(struct tss_struct));
 
+       DEFINE(TI_task, offsetof (struct thread_info, task));
+       DEFINE(TI_exec_domain, offsetof (struct thread_info, exec_domain));
+       DEFINE(TI_flags, offsetof (struct thread_info, flags));
+       DEFINE(TI_preempt_count, offsetof (struct thread_info, preempt_count));
+       DEFINE(TI_addr_limit, offsetof (struct thread_info, addr_limit));
+       DEFINE(TI_sysenter_return,
+                       offsetof (struct thread_info, sysenter_return));
+       DEFINE(TI_real_stack, offsetof (struct thread_info, real_stack));
+       DEFINE(TI_virtual_stack, offsetof (struct thread_info, virtual_stack));
+       DEFINE(TI_user_pgd, offsetof (struct thread_info, user_pgd));
+
+       DEFINE(FIX_ENTRY_TRAMPOLINE_0_addr,
+                       __fix_to_virt(FIX_ENTRY_TRAMPOLINE_0));
+       DEFINE(FIX_VSYSCALL_addr, __fix_to_virt(FIX_VSYSCALL));
        DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
+       DEFINE(task_thread_db7,
+               offsetof (struct task_struct, thread.debugreg[7]));
 }
index 30e25e3..4f30473 100644 (file)
@@ -379,6 +379,10 @@ void __init identify_cpu(struct cpuinfo_x86 *c)
        if (disable_pse)
                clear_bit(X86_FEATURE_PSE, c->x86_capability);
 
+       /* hack: disable SEP for non-NX cpus; SEP breaks Execshield. */
+       if (!test_bit(X86_FEATURE_NX, c->x86_capability)) 
+               clear_bit(X86_FEATURE_SEP, c->x86_capability);
+
        /* If the model name is still unset, do table lookup. */
        if ( !c->x86_model_id[0] ) {
                char *p;
@@ -554,12 +558,16 @@ void __init cpu_init (void)
        set_tss_desc(cpu,t);
        cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff;
        load_TR_desc();
-       load_LDT(&init_mm.context);
+       if (cpu)
+               load_LDT(&init_mm.context);
 
        /* Set up doublefault TSS pointer in the GDT */
        __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
        cpu_gdt_table[cpu][GDT_ENTRY_DOUBLEFAULT_TSS].b &= 0xfffffdff;
 
+       if (cpu)
+               trap_init_virtual_GDT();
+
        /* Clear %fs and %gs. */
        asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs");
 
index 05ed902..20d875d 100644 (file)
@@ -1024,7 +1024,7 @@ err_out:
        return -ENODEV;
 }
 
-static int __exit powernowk8_cpu_exit (struct cpufreq_policy *pol)
+static int powernowk8_cpu_exit (struct cpufreq_policy *pol)
 {
        struct powernow_k8_data *data = powernow_data[pol->cpu];
 
@@ -1076,7 +1076,7 @@ static struct cpufreq_driver cpufreq_amd64_driver = {
        .verify = powernowk8_verify,
        .target = powernowk8_target,
        .init = powernowk8_cpu_init,
-       .exit = powernowk8_cpu_exit,
+       .exit = __devexit_p(powernowk8_cpu_exit),
        .get = powernowk8_get,
        .name = "powernow-k8",
        .owner = THIS_MODULE,
@@ -1105,7 +1105,7 @@ static int __init powernowk8_init(void)
 }
 
 /* driver entry point for term */
-static void __exit powernowk8_exit(void)
+static void powernowk8_exit(void)
 {
        dprintk(KERN_INFO PFX "exit\n");
 
index 09acdd7..f78243f 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/processor.h>
 #include <asm/msr.h>
 #include <asm/uaccess.h>
+#include <asm/desc.h>
 
 #include "cpu.h"
 
@@ -19,8 +20,6 @@
 #include <mach_apic.h>
 #endif
 
-extern int trap_init_f00f_bug(void);
-
 #ifdef CONFIG_X86_INTEL_USERCOPY
 /*
  * Alignment at which movsl is preferred for bulk memory copies.
@@ -147,7 +146,7 @@ static void __init init_intel(struct cpuinfo_x86 *c)
 
                c->f00f_bug = 1;
                if ( !f00f_workaround_enabled ) {
-                       trap_init_f00f_bug();
+                       trap_init_virtual_IDT();
                        printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n");
                        f00f_workaround_enabled = 1;
                }
index 6b4a8f3..3304416 100644 (file)
@@ -8,12 +8,13 @@
 #include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/desc.h>
+#include <asm/fixmap.h>
 
 #define DOUBLEFAULT_STACKSIZE (1024)
 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
 #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
 
-#define ptr_ok(x) ((x) > 0xc0000000 && (x) < 0xc1000000)
+#define ptr_ok(x) (((x) > __PAGE_OFFSET && (x) < (__PAGE_OFFSET + 0x01000000)) || ((x) >= FIXADDR_START))
 
 static void doublefault_fn(void)
 {
@@ -39,8 +40,8 @@ static void doublefault_fn(void)
 
                        printk("eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n",
                                t->eax, t->ebx, t->ecx, t->edx);
-                       printk("esi = %08lx, edi = %08lx\n",
-                               t->esi, t->edi);
+                       printk("esi = %08lx, edi = %08lx, ebp = %08lx\n",
+                               t->esi, t->edi, t->ebp);
                }
        }
 
index 7b68563..3ac7418 100644 (file)
 #include <linux/config.h>
 #include <linux/linkage.h>
 #include <asm/thread_info.h>
+#include <asm/asm_offsets.h>
 #include <asm/errno.h>
 #include <asm/segment.h>
+#include <asm/page.h>
 #include <asm/smp.h>
 #include <asm/page.h>
 #include "irq_vectors.h"
@@ -81,7 +83,102 @@ VM_MASK             = 0x00020000
 #define resume_kernel          restore_all
 #endif
 
-#define SAVE_ALL \
+#ifdef CONFIG_X86_HIGH_ENTRY
+
+#ifdef CONFIG_X86_SWITCH_PAGETABLES
+
+#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
+/*
+ * If task is preempted in __SWITCH_KERNELSPACE, and moved to another cpu,
+ * __switch_to repoints %esp to the appropriate virtual stack; but %ebp is
+ * left stale, so we must check whether to repeat the real stack calculation.
+ */
+#define repeat_if_esp_changed                          \
+       xorl %esp, %ebp;                                \
+       testl $-THREAD_SIZE, %ebp;                      \
+       jnz 0b
+#else
+#define repeat_if_esp_changed
+#endif
+
+/* clobbers ebx, edx and ebp */
+
+#define __SWITCH_KERNELSPACE                           \
+       cmpl $0xff000000, %esp;                         \
+       jb 1f;                                          \
+                                                       \
+       /*                                              \
+        * switch pagetables and load the real stack,   \
+        * keep the stack offset:                       \
+        */                                             \
+                                                       \
+       movl $swapper_pg_dir-__PAGE_OFFSET, %edx;       \
+                                                       \
+       /* GET_THREAD_INFO(%ebp) intermixed */          \
+0:                                                     \
+       movl %esp, %ebp;                                \
+       movl %esp, %ebx;                                \
+       andl $(-THREAD_SIZE), %ebp;                             \
+       andl $(THREAD_SIZE-1), %ebx;                            \
+       orl TI_real_stack(%ebp), %ebx;                  \
+       repeat_if_esp_changed;                          \
+                                                       \
+       movl %edx, %cr3;                                \
+       movl %ebx, %esp;                                \
+1:
+
+#endif
+
+
+#define __SWITCH_USERSPACE \
+       /* interrupted any of the user return paths? */ \
+                                                       \
+       movl EIP(%esp), %eax;                           \
+                                                       \
+       cmpl $int80_ret_start_marker, %eax;             \
+       jb 33f; /* nope - continue with sysexit check */\
+       cmpl $int80_ret_end_marker, %eax;               \
+       jb 22f; /* yes - switch to virtual stack */     \
+33:                                                    \
+       cmpl $sysexit_ret_start_marker, %eax;           \
+       jb 44f; /* nope - continue with user check */   \
+       cmpl $sysexit_ret_end_marker, %eax;             \
+       jb 22f; /* yes - switch to virtual stack */     \
+       /* return to userspace? */                      \
+44:                                                    \
+       movl EFLAGS(%esp),%ecx;                         \
+       movb CS(%esp),%cl;                              \
+       testl $(VM_MASK | 3),%ecx;                      \
+       jz 2f;                                          \
+22:                                                    \
+       /*                                              \
+        * switch to the virtual stack, then switch to  \
+        * the userspace pagetables.                    \
+        */                                             \
+                                                       \
+       GET_THREAD_INFO(%ebp);                          \
+       movl TI_virtual_stack(%ebp), %edx;              \
+       movl TI_user_pgd(%ebp), %ecx;                   \
+                                                       \
+       movl %esp, %ebx;                                \
+       andl $(THREAD_SIZE-1), %ebx;                            \
+       orl %ebx, %edx;                                 \
+int80_ret_start_marker:                                        \
+       movl %edx, %esp;                                \
+       movl %ecx, %cr3;                                \
+                                                       \
+       __RESTORE_ALL;                                  \
+int80_ret_end_marker:                                  \
+2:
+
+#else /* !CONFIG_X86_HIGH_ENTRY */
+
+#define __SWITCH_KERNELSPACE
+#define __SWITCH_USERSPACE
+
+#endif
+
+#define __SAVE_ALL \
        cld; \
        pushl %es; \
        pushl %ds; \
@@ -96,7 +193,7 @@ VM_MASK              = 0x00020000
        movl %edx, %ds; \
        movl %edx, %es;
 
-#define RESTORE_INT_REGS \
+#define __RESTORE_INT_REGS \
        popl %ebx;      \
        popl %ecx;      \
        popl %edx;      \
@@ -105,29 +202,28 @@ VM_MASK           = 0x00020000
        popl %ebp;      \
        popl %eax
 
-#define RESTORE_REGS   \
-       RESTORE_INT_REGS; \
-1:     popl %ds;       \
-2:     popl %es;       \
+#define __RESTORE_REGS \
+       __RESTORE_INT_REGS; \
+111:   popl %ds;       \
+222:   popl %es;       \
 .section .fixup,"ax";  \
-3:     movl $0,(%esp); \
-       jmp 1b;         \
-4:     movl $0,(%esp); \
-       jmp 2b;         \
+444:   movl $0,(%esp); \
+       jmp 111b;       \
+555:   movl $0,(%esp); \
+       jmp 222b;       \
 .previous;             \
 .section __ex_table,"a";\
        .align 4;       \
-       .long 1b,3b;    \
-       .long 2b,4b;    \
+       .long 111b,444b;\
+       .long 222b,555b;\
 .previous
 
-
-#define RESTORE_ALL    \
-       RESTORE_REGS    \
+#define __RESTORE_ALL  \
+       __RESTORE_REGS  \
        addl $4, %esp;  \
-1:     iret;           \
+333:   iret;           \
 .section .fixup,"ax";   \
-2:     sti;            \
+666:   sti;            \
        movl $(__USER_DS), %edx; \
        movl %edx, %ds; \
        movl %edx, %es; \
@@ -136,10 +232,18 @@ VM_MASK           = 0x00020000
 .previous;             \
 .section __ex_table,"a";\
        .align 4;       \
-       .long 1b,2b;    \
+       .long 333b,666b;\
 .previous
 
+#define SAVE_ALL \
+       __SAVE_ALL;                                     \
+       __SWITCH_KERNELSPACE;
+
+#define RESTORE_ALL                                    \
+       __SWITCH_USERSPACE;                             \
+       __RESTORE_ALL;
 
+.section .entry.text,"ax"
 
 ENTRY(lcall7)
        pushfl                  # We get a different stack layout with call
@@ -238,20 +342,15 @@ sysenter_past_esp:
        pushl %ebp
        pushfl
        pushl $(__USER_CS)
-       pushl $SYSENTER_RETURN
-
-/*
- * Load the potential sixth argument from user stack.
- * Careful about security.
- */
-       cmpl $__PAGE_OFFSET-3,%ebp
-       jae syscall_fault
-1:     movl (%ebp),%ebp
-.section __ex_table,"a"
-       .align 4
-       .long 1b,syscall_fault
-.previous
-
+       /*
+        * Push current_thread_info()->sysenter_return to the stack.
+        * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
+        * pushed above, and the word being pushed now:
+        */
+       pushl (TI_sysenter_return-THREAD_SIZE+4*4)(%esp)
+       /*
+        * No six-argument syscall is ever used with sysenter.
+        */
        pushl %eax
        SAVE_ALL
        GET_THREAD_INFO(%ebp)
@@ -266,12 +365,34 @@ sysenter_past_esp:
        movl TI_flags(%ebp), %ecx
        testw $_TIF_ALLWORK_MASK, %cx
        jne syscall_exit_work
+
+#ifdef CONFIG_X86_SWITCH_PAGETABLES
+
+       GET_THREAD_INFO(%ebp)
+       movl TI_virtual_stack(%ebp), %edx
+       movl TI_user_pgd(%ebp), %ecx
+       movl %esp, %ebx
+       andl $(THREAD_SIZE-1), %ebx
+       orl %ebx, %edx
+sysexit_ret_start_marker:
+       movl %edx, %esp
+       movl %ecx, %cr3
+       /*
+        * only ebx is not restored by the userspace sysenter vsyscall
+        * code, it assumes it to be callee-saved.
+        */
+       movl EBX(%esp), %ebx
+#endif
+
 /* if something modifies registers it must also disable sysexit */
        movl EIP(%esp), %edx
        movl OLDESP(%esp), %ecx
        sti
        sysexit
-
+#ifdef CONFIG_X86_SWITCH_PAGETABLES
+sysexit_ret_end_marker:
+       nop
+#endif
 
        # system call handler stub
 ENTRY(system_call)
@@ -321,6 +442,22 @@ work_notifysig:                            # deal with pending signals and
                                        # vm86-space
        xorl %edx, %edx
        call do_notify_resume
+
+#if CONFIG_X86_HIGH_ENTRY
+       /*
+        * Reload db7 if necessary:
+        */
+       movl TI_flags(%ebp), %ecx
+       testb $_TIF_DB7, %cl
+       jnz work_db7
+
+       jmp restore_all
+
+work_db7:
+       movl TI_task(%ebp), %edx;
+       movl task_thread_db7(%edx), %edx;
+       movl %edx, %db7;
+#endif
        jmp restore_all
 
        ALIGN
@@ -357,14 +494,6 @@ syscall_exit_work:
        call do_syscall_trace
        jmp resume_userspace
 
-       ALIGN
-syscall_fault:
-       pushl %eax                      # save orig_eax
-       SAVE_ALL
-       GET_THREAD_INFO(%ebp)
-       movl $-EFAULT,EAX(%esp)
-       jmp resume_userspace
-
        ALIGN
 syscall_badsys:
        movl $-ENOSYS,EAX(%esp)
@@ -376,7 +505,7 @@ syscall_badsys:
  */
 .data
 ENTRY(interrupt)
-.text
+.previous
 
 vector=0
 ENTRY(irq_entries_start)
@@ -386,7 +515,7 @@ ENTRY(irq_entries_start)
        jmp common_interrupt
 .data
        .long 1b
-.text
+.previous
 vector=vector+1
 .endr
 
@@ -427,12 +556,17 @@ error_code:
        movl ES(%esp), %edi             # get the function address
        movl %eax, ORIG_EAX(%esp)
        movl %ecx, ES(%esp)
-       movl %esp, %edx
        pushl %esi                      # push the error code
-       pushl %edx                      # push the pt_regs pointer
        movl $(__USER_DS), %edx
        movl %edx, %ds
        movl %edx, %es
+
+/* clobbers edx, ebx and ebp */
+       __SWITCH_KERNELSPACE
+
+       leal 4(%esp), %edx              # prepare pt_regs
+       pushl %edx                      # push pt_regs
+
        call *%edi
        addl $8, %esp
        jmp ret_from_exception
@@ -523,7 +657,7 @@ nmi_stack_correct:
        pushl %edx
        call do_nmi
        addl $8, %esp
-       RESTORE_ALL
+       jmp restore_all
 
 nmi_stack_fixup:
        FIX_STACK(12,nmi_stack_correct, 1)
@@ -600,6 +734,8 @@ ENTRY(spurious_interrupt_bug)
        pushl $do_spurious_interrupt_bug
        jmp error_code
 
+.previous
+
 .data
 ENTRY(sys_call_table)
        .long sys_restart_syscall       /* 0 - old "setup()" system call, used for restarting */
@@ -824,7 +960,15 @@ ENTRY(sys_call_table)
        .long sys_madvise
        .long sys_getdents64    /* 220 */
        .long sys_fcntl64
-       .long sys_ni_syscall    /* reserved for TUX */
+#ifdef CONFIG_TUX
+       .long __sys_tux
+#else
+# ifdef CONFIG_TUX_MODULE
+       .long sys_tux
+# else
+       .long sys_ni_syscall
+# endif
+#endif
        .long sys_ni_syscall
        .long sys_gettid
        .long sys_readahead     /* 225 */
@@ -875,7 +1019,7 @@ ENTRY(sys_call_table)
        .long sys_tgkill        /* 270 */
        .long sys_utimes
        .long sys_fadvise64_64
-       .long sys_ni_syscall    /* sys_vserver */
+       .long sys_vserver
        .long sys_mbind
        .long sys_get_mempolicy
        .long sys_set_mempolicy
@@ -886,5 +1030,7 @@ ENTRY(sys_call_table)
        .long sys_mq_notify
        .long sys_mq_getsetattr
        .long sys_ni_syscall            /* reserved for kexec */
+       .long sys_ioprio_set
+       .long sys_ioprio_get            /* 285 */
 
 syscall_table_size=(.-sys_call_table)
diff --git a/arch/i386/kernel/entry_trampoline.c b/arch/i386/kernel/entry_trampoline.c
new file mode 100644 (file)
index 0000000..db6f6ea
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * linux/arch/i386/kernel/entry_trampoline.c
+ *
+ * (C) Copyright 2003 Ingo Molnar
+ *
+ * This file contains the needed support code for 4GB userspace
+ */
+
+#include <linux/init.h>
+#include <linux/smp.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/highmem.h>
+#include <asm/desc.h>
+#include <asm/atomic_kmap.h>
+
+extern char __entry_tramp_start, __entry_tramp_end, __start___entry_text;
+
+void __init init_entry_mappings(void)
+{
+#ifdef CONFIG_X86_HIGH_ENTRY
+
+       void *tramp;
+       int p;
+
+       /*
+        * We need a high IDT and GDT for the 4G/4G split:
+        */
+       trap_init_virtual_IDT();
+
+       __set_fixmap(FIX_ENTRY_TRAMPOLINE_0, __pa((unsigned long)&__entry_tramp_start), PAGE_KERNEL_EXEC);
+       __set_fixmap(FIX_ENTRY_TRAMPOLINE_1, __pa((unsigned long)&__entry_tramp_start) + PAGE_SIZE, PAGE_KERNEL_EXEC);
+       tramp = (void *)fix_to_virt(FIX_ENTRY_TRAMPOLINE_0);
+
+       printk("mapped 4G/4G trampoline to %p.\n", tramp);
+       BUG_ON((void *)&__start___entry_text != tramp);
+       /*
+        * Virtual kernel stack:
+        */
+       BUG_ON(__kmap_atomic_vaddr(KM_VSTACK_TOP) & (THREAD_SIZE-1));
+       BUG_ON(sizeof(struct desc_struct)*NR_CPUS*GDT_ENTRIES > 2*PAGE_SIZE);
+       BUG_ON((unsigned int)&__entry_tramp_end - (unsigned int)&__entry_tramp_start > 2*PAGE_SIZE);
+
+       /*
+        * set up the initial thread's virtual stack related
+        * fields:
+        */
+       for (p = 0; p < ARRAY_SIZE(current->thread.stack_page); p++)
+               current->thread.stack_page[p] = virt_to_page((char *)current->thread_info + (p*PAGE_SIZE));
+
+       current->thread_info->virtual_stack = (void *)__kmap_atomic_vaddr(KM_VSTACK_TOP);
+
+       for (p = 0; p < ARRAY_SIZE(current->thread.stack_page); p++) {
+               __kunmap_atomic_type(KM_VSTACK_TOP-p);
+               __kmap_atomic(current->thread.stack_page[p], KM_VSTACK_TOP-p);
+       }
+#endif
+       current->thread_info->real_stack = (void *)current->thread_info;
+       current->thread_info->user_pgd = NULL;
+       current->thread.esp0 = (unsigned long)current->thread_info->real_stack + THREAD_SIZE;
+}
+
+
+
+void __init entry_trampoline_setup(void)
+{
+       /*
+        * old IRQ entries set up by the boot code will still hang
+        * around - they are a sign of hw trouble anyway, now they'll
+        * produce a double fault message.
+        */
+       trap_init_virtual_GDT();
+}
index 064d6fb..5a50c53 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/tty.h>
 #include <linux/highmem.h>
 #include <linux/time.h>
+#include <linux/nmi.h>
 
 #include <asm/semaphore.h>
 #include <asm/processor.h>
@@ -32,6 +33,7 @@
 #include <asm/tlbflush.h>
 #include <asm/nmi.h>
 #include <asm/ist.h>
+#include <asm/e820.h>
 
 extern void dump_thread(struct pt_regs *, struct user *);
 extern spinlock_t rtc_lock;
@@ -92,7 +94,6 @@ EXPORT_SYMBOL_NOVERS(__down_failed_interruptible);
 EXPORT_SYMBOL_NOVERS(__down_failed_trylock);
 EXPORT_SYMBOL_NOVERS(__up_wakeup);
 /* Networking helper routines. */
-EXPORT_SYMBOL(csum_partial_copy_generic);
 /* Delay loops */
 EXPORT_SYMBOL(__ndelay);
 EXPORT_SYMBOL(__udelay);
@@ -106,13 +107,17 @@ EXPORT_SYMBOL_NOVERS(__get_user_4);
 EXPORT_SYMBOL(strpbrk);
 EXPORT_SYMBOL(strstr);
 
+#if !defined(CONFIG_X86_UACCESS_INDIRECT)
 EXPORT_SYMBOL(strncpy_from_user);
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(__direct_strncpy_from_user);
 EXPORT_SYMBOL(clear_user);
 EXPORT_SYMBOL(__clear_user);
 EXPORT_SYMBOL(__copy_from_user_ll);
 EXPORT_SYMBOL(__copy_to_user_ll);
 EXPORT_SYMBOL(strnlen_user);
+#else /* CONFIG_X86_UACCESS_INDIRECT */
+EXPORT_SYMBOL(direct_csum_partial_copy_generic);
+#endif
 
 EXPORT_SYMBOL(dma_alloc_coherent);
 EXPORT_SYMBOL(dma_free_coherent);
@@ -196,3 +201,22 @@ EXPORT_SYMBOL(ist_info);
 #endif
 
 EXPORT_SYMBOL(csum_partial);
+
+EXPORT_SYMBOL_GPL(empty_zero_page);
+#ifdef CONFIG_CRASH_DUMP_MODULE
+#ifdef CONFIG_SMP
+extern irq_desc_t irq_desc[NR_IRQS];
+extern unsigned long irq_affinity[NR_IRQS];
+extern void stop_this_cpu(void *);
+EXPORT_SYMBOL(irq_desc);
+EXPORT_SYMBOL(irq_affinity);
+EXPORT_SYMBOL(stop_this_cpu);
+EXPORT_SYMBOL(dump_send_ipi);
+#endif
+extern int pfn_is_ram(unsigned long);
+EXPORT_SYMBOL(pfn_is_ram);
+#ifdef ARCH_HAS_NMI_WATCHDOG
+EXPORT_SYMBOL(touch_nmi_watchdog);
+#endif
+#endif
index 3da92c2..cc5628f 100644 (file)
@@ -227,6 +227,7 @@ void set_fpu_twd( struct task_struct *tsk, unsigned short twd )
 static int convert_fxsr_to_user( struct _fpstate __user *buf,
                                        struct i387_fxsave_struct *fxsave )
 {
+       struct _fpreg tmp[8]; /* 80 bytes scratch area */
        unsigned long env[7];
        struct _fpreg __user *to;
        struct _fpxreg *from;
@@ -243,23 +244,25 @@ static int convert_fxsr_to_user( struct _fpstate __user *buf,
        if ( __copy_to_user( buf, env, 7 * sizeof(unsigned long) ) )
                return 1;
 
-       to = &buf->_st[0];
+       to = tmp;
        from = (struct _fpxreg *) &fxsave->st_space[0];
        for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
                unsigned long __user *t = (unsigned long __user *)to;
                unsigned long *f = (unsigned long *)from;
 
-               if (__put_user(*f, t) ||
-                               __put_user(*(f + 1), t + 1) ||
-                               __put_user(from->exponent, &to->exponent))
-                       return 1;
+               *t = *f;
+               *(t + 1) = *(f+1);
+               to->exponent = from->exponent;
        }
+       if (copy_to_user(buf->_st, tmp, sizeof(struct _fpreg [8])))
+               return 1;
        return 0;
 }
 
 static int convert_fxsr_from_user( struct i387_fxsave_struct *fxsave,
                                          struct _fpstate __user *buf )
 {
+       struct _fpreg tmp[8]; /* 80 bytes scratch area */
        unsigned long env[7];
        struct _fpxreg *to;
        struct _fpreg __user *from;
@@ -267,6 +270,8 @@ static int convert_fxsr_from_user( struct i387_fxsave_struct *fxsave,
 
        if ( __copy_from_user( env, buf, 7 * sizeof(long) ) )
                return 1;
+       if (copy_from_user(tmp, buf->_st, sizeof(struct _fpreg [8])))
+               return 1;
 
        fxsave->cwd = (unsigned short)(env[0] & 0xffff);
        fxsave->swd = (unsigned short)(env[1] & 0xffff);
@@ -278,15 +283,14 @@ static int convert_fxsr_from_user( struct i387_fxsave_struct *fxsave,
        fxsave->fos = env[6];
 
        to = (struct _fpxreg *) &fxsave->st_space[0];
-       from = &buf->_st[0];
+       from = tmp;
        for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
                unsigned long *t = (unsigned long *)to;
                unsigned long __user *f = (unsigned long __user *)from;
 
-               if (__get_user(*t, f) ||
-                               __get_user(*(t + 1), f + 1) ||
-                               __get_user(to->exponent, &from->exponent))
-                       return 1;
+               *t = *f;
+               *(t + 1) = *(f + 1);
+               to->exponent = from->exponent;
        }
        return 0;
 }
index 5e18976..7422d73 100644 (file)
@@ -27,7 +27,7 @@ EXPORT_SYMBOL(init_mm);
  */
 union thread_union init_thread_union 
        __attribute__((__section__(".data.init_task"))) =
-               { INIT_THREAD_INFO(init_task) };
+               { INIT_THREAD_INFO(init_task, init_thread_union) };
 
 /*
  * Initial task structure.
@@ -45,5 +45,5 @@ EXPORT_SYMBOL(init_task);
  * section. Since TSS's are completely CPU-local, we want them
  * on exact cacheline boundaries, to eliminate cacheline ping-pong.
  */ 
-struct tss_struct init_tss[NR_CPUS] __cacheline_aligned = { [0 ... NR_CPUS-1] = INIT_TSS };
+struct tss_struct init_tss[NR_CPUS] __attribute__((__section__(".data.tss"))) = { [0 ... NR_CPUS-1] = INIT_TSS };
 
index a40687e..39af35d 100644 (file)
@@ -1714,7 +1714,7 @@ static void __init setup_ioapic_ids_from_mpc(void)
                reg_00.raw = io_apic_read(apic, 0);
                spin_unlock_irqrestore(&ioapic_lock, flags);
                if (reg_00.bits.ID != mp_ioapics[apic].mpc_apicid)
-                       panic("could not set ID!\n");
+                       printk("could not set ID!\n");
                else
                        printk(" ok.\n");
        }
index 355dc0e..22f7fc7 100644 (file)
@@ -76,10 +76,8 @@ static void register_irq_proc (unsigned int irq);
 /*
  * per-CPU IRQ handling stacks
  */
-#ifdef CONFIG_4KSTACKS
 union irq_ctx *hardirq_ctx[NR_CPUS];
 union irq_ctx *softirq_ctx[NR_CPUS];
-#endif
 
 /*
  * Special irq handlers.
@@ -222,9 +220,6 @@ asmlinkage int handle_IRQ_event(unsigned int irq,
        int status = 1; /* Force the "do bottom halves" bit */
        int retval = 0;
 
-       if (!(action->flags & SA_INTERRUPT))
-               local_irq_enable();
-
        do {
                status |= action->flags;
                retval |= action->handler(irq, action->dev_id, regs);
@@ -244,7 +239,8 @@ static void __report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
                printk(KERN_ERR "irq event %d: bogus return value %x\n",
                                irq, action_ret);
        } else {
-               printk(KERN_ERR "irq %d: nobody cared!\n", irq);
+               printk(KERN_ERR "irq %d: nobody cared! (screaming interrupt?)\n", irq);
+               printk(KERN_ERR "irq %d: Please try booting with acpi=off and report a bug\n", irq);
        }
        dump_stack();
        printk(KERN_ERR "handlers:\n");
@@ -487,7 +483,6 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
         * useful for irq hardware that does not mask cleanly in an
         * SMP environment.
         */
-#ifdef CONFIG_4KSTACKS
 
        for (;;) {
                irqreturn_t action_ret;
@@ -513,6 +508,8 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
                        /* build the stack frame on the IRQ stack */
                        isp = (u32*) ((char*)irqctx + sizeof(*irqctx));
                        irqctx->tinfo.task = curctx->tinfo.task;
+                       irqctx->tinfo.real_stack = curctx->tinfo.real_stack;
+                       irqctx->tinfo.virtual_stack = curctx->tinfo.virtual_stack;
                        irqctx->tinfo.previous_esp = current_stack_pointer();
 
                        *--isp = (u32) action;
@@ -540,23 +537,6 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
                desc->status &= ~IRQ_PENDING;
        }
 
-#else
-
-       for (;;) {
-               irqreturn_t action_ret;
-
-               spin_unlock(&desc->lock);
-
-               action_ret = handle_IRQ_event(irq, &regs, action);
-
-               spin_lock(&desc->lock);
-               if (!noirqdebug)
-                       note_interrupt(irq, desc, action_ret);
-               if (likely(!(desc->status & IRQ_PENDING)))
-                       break;
-               desc->status &= ~IRQ_PENDING;
-       }
-#endif
        desc->status &= ~IRQ_INPROGRESS;
 
 out:
@@ -1115,7 +1095,6 @@ void init_irq_proc (void)
 }
 
 
-#ifdef CONFIG_4KSTACKS
 /*
  * These should really be __section__(".bss.page_aligned") as well, but
  * gcc's 3.0 and earlier don't handle that correctly.
@@ -1173,6 +1152,8 @@ asmlinkage void do_softirq(void)
                curctx = current_thread_info();
                irqctx = softirq_ctx[smp_processor_id()];
                irqctx->tinfo.task = curctx->task;
+               irqctx->tinfo.real_stack = curctx->real_stack;
+               irqctx->tinfo.virtual_stack = curctx->virtual_stack;
                irqctx->tinfo.previous_esp = current_stack_pointer();
 
                /* build the stack frame on the softirq stack */
@@ -1193,4 +1174,3 @@ asmlinkage void do_softirq(void)
 }
 
 EXPORT_SYMBOL(do_softirq);
-#endif
index 038d300..fa96372 100644 (file)
@@ -2,7 +2,7 @@
  * linux/kernel/ldt.c
  *
  * Copyright (C) 1992 Krishna Balasubramanian and Linus Torvalds
- * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
+ * Copyright (C) 1999, 2003 Ingo Molnar <mingo@redhat.com>
  */
 
 #include <linux/errno.h>
@@ -18,6 +18,8 @@
 #include <asm/system.h>
 #include <asm/ldt.h>
 #include <asm/desc.h>
+#include <linux/highmem.h>
+#include <asm/atomic_kmap.h>
 
 #ifdef CONFIG_SMP /* avoids "defined but not used" warnig */
 static void flush_ldt(void *null)
@@ -29,34 +31,31 @@ static void flush_ldt(void *null)
 
 static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
 {
-       void *oldldt;
-       void *newldt;
-       int oldsize;
+       int oldsize, newsize, i;
 
        if (mincount <= pc->size)
                return 0;
+       /*
+        * LDT got larger - reallocate if necessary.
+        */
        oldsize = pc->size;
        mincount = (mincount+511)&(~511);
-       if (mincount*LDT_ENTRY_SIZE > PAGE_SIZE)
-               newldt = vmalloc(mincount*LDT_ENTRY_SIZE);
-       else
-               newldt = kmalloc(mincount*LDT_ENTRY_SIZE, GFP_KERNEL);
-
-       if (!newldt)
-               return -ENOMEM;
-
-       if (oldsize)
-               memcpy(newldt, pc->ldt, oldsize*LDT_ENTRY_SIZE);
-       oldldt = pc->ldt;
-       memset(newldt+oldsize*LDT_ENTRY_SIZE, 0, (mincount-oldsize)*LDT_ENTRY_SIZE);
-       pc->ldt = newldt;
-       wmb();
+       newsize = mincount*LDT_ENTRY_SIZE;
+       for (i = 0; i < newsize; i += PAGE_SIZE) {
+               int nr = i/PAGE_SIZE;
+               BUG_ON(i >= 64*1024);
+               if (!pc->ldt_pages[nr]) {
+                       pc->ldt_pages[nr] = alloc_page(GFP_HIGHUSER);
+                       if (!pc->ldt_pages[nr])
+                               return -ENOMEM;
+                       clear_highpage(pc->ldt_pages[nr]);
+               }
+       }
        pc->size = mincount;
-       wmb();
-
        if (reload) {
 #ifdef CONFIG_SMP
                cpumask_t mask;
+
                preempt_disable();
                load_LDT(pc);
                mask = cpumask_of_cpu(smp_processor_id());
@@ -67,21 +66,20 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
                load_LDT(pc);
 #endif
        }
-       if (oldsize) {
-               if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
-                       vfree(oldldt);
-               else
-                       kfree(oldldt);
-       }
        return 0;
 }
 
 static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
 {
-       int err = alloc_ldt(new, old->size, 0);
-       if (err < 0)
+       int i, err, size = old->size, nr_pages = (size*LDT_ENTRY_SIZE + PAGE_SIZE-1)/PAGE_SIZE;
+
+       err = alloc_ldt(new, size, 0);
+       if (err < 0) {
+               new->size = 0;
                return err;
-       memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
+       }
+       for (i = 0; i < nr_pages; i++)
+               copy_user_highpage(new->ldt_pages[i], old->ldt_pages[i], 0);
        return 0;
 }
 
@@ -96,6 +94,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 
        init_MUTEX(&mm->context.sem);
        mm->context.size = 0;
+       memset(mm->context.ldt_pages, 0, sizeof(struct page *) * MAX_LDT_PAGES);
        old_mm = current->mm;
        if (old_mm && old_mm->context.size > 0) {
                down(&old_mm->context.sem);
@@ -107,23 +106,21 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 
 /*
  * No need to lock the MM as we are the last user
+ * Do not touch the ldt register, we are already
+ * in the next thread.
  */
 void destroy_context(struct mm_struct *mm)
 {
-       if (mm->context.size) {
-               if (mm == current->active_mm)
-                       clear_LDT();
-               if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
-                       vfree(mm->context.ldt);
-               else
-                       kfree(mm->context.ldt);
-               mm->context.size = 0;
-       }
+       int i, nr_pages = (mm->context.size*LDT_ENTRY_SIZE + PAGE_SIZE-1) / PAGE_SIZE;
+
+       for (i = 0; i < nr_pages; i++)
+               __free_page(mm->context.ldt_pages[i]);
+       mm->context.size = 0;
 }
 
 static int read_ldt(void __user * ptr, unsigned long bytecount)
 {
-       int err;
+       int err, i;
        unsigned long size;
        struct mm_struct * mm = current->mm;
 
@@ -138,8 +135,25 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
                size = bytecount;
 
        err = 0;
-       if (copy_to_user(ptr, mm->context.ldt, size))
-               err = -EFAULT;
+       /*
+        * This is necessary just in case we got here straight from a
+        * context-switch where the ptes were set but no tlb flush
+        * was done yet. We rather avoid doing a TLB flush in the
+        * context-switch path and do it here instead.
+        */
+       __flush_tlb_global();
+
+       for (i = 0; i < size; i += PAGE_SIZE) {
+               int nr = i / PAGE_SIZE, bytes;
+               char *kaddr = kmap(mm->context.ldt_pages[nr]);
+
+               bytes = size - i;
+               if (bytes > PAGE_SIZE)
+                       bytes = PAGE_SIZE;
+               if (copy_to_user(ptr + i, kaddr, bytes))
+                       err = -EFAULT;
+               kunmap(mm->context.ldt_pages[nr]);
+       }
        up(&mm->context.sem);
        if (err < 0)
                return err;
@@ -158,7 +172,7 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
 
        err = 0;
        address = &default_ldt[0];
-       size = 5*sizeof(struct desc_struct);
+       size = 5*LDT_ENTRY_SIZE;
        if (size > bytecount)
                size = bytecount;
 
@@ -200,7 +214,15 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
                        goto out_unlock;
        }
 
-       lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt);
+       /*
+        * No rescheduling allowed from this point to the install.
+        *
+        * We do a TLB flush for the same reason as in the read_ldt() path.
+        */
+       preempt_disable();
+       __flush_tlb_global();
+       lp = (__u32 *) ((ldt_info.entry_number << 3) +
+                       (char *) __kmap_atomic_vaddr(KM_LDT_PAGE0));
 
        /* Allow LDTs to be cleared by the user. */
        if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
@@ -221,6 +243,7 @@ install:
        *lp     = entry_1;
        *(lp+1) = entry_2;
        error = 0;
+       preempt_enable();
 
 out_unlock:
        up(&mm->context.sem);
@@ -248,3 +271,26 @@ asmlinkage int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecoun
        }
        return ret;
 }
+
+/*
+ * load one particular LDT into the current CPU
+ */
+void load_LDT_nolock(mm_context_t *pc, int cpu)
+{
+       struct page **pages = pc->ldt_pages;
+       int count = pc->size;
+       int nr_pages, i;
+
+       if (likely(!count)) {
+               pages = &default_ldt_page;
+               count = 5;
+       }
+               nr_pages = (count*LDT_ENTRY_SIZE + PAGE_SIZE-1) / PAGE_SIZE;
+
+       for (i = 0; i < nr_pages; i++) {
+               __kunmap_atomic_type(KM_LDT_PAGE0 - i);
+               __kmap_atomic(pages[i], KM_LDT_PAGE0 - i);
+       }
+       set_ldt_desc(cpu, (void *)__kmap_atomic_vaddr(KM_LDT_PAGE0), count);
+       load_LDT_desc();
+}
index 12ccd65..c51ae3c 100644 (file)
@@ -369,7 +369,7 @@ static void do_update_one (void * unused)
        struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
 
        if (uci->mc == NULL) {
-               printk(KERN_INFO "microcode: No suitable data for CPU%d\n", cpu_num);
+               printk(KERN_INFO "microcode: No new microdata for cpu %d\n", cpu_num);
                return;
        }
 
index 41cb826..a1c13fb 100644 (file)
@@ -690,7 +690,7 @@ void __init get_smp_config (void)
                 * Read the physical hardware table.  Anything here will
                 * override the defaults.
                 */
-               if (!smp_read_mpc((void *)mpf->mpf_physptr)) {
+               if (!smp_read_mpc((void *)phys_to_virt(mpf->mpf_physptr))) {
                        smp_found_config = 0;
                        printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
                        printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
index 16d91e3..7a2cdb5 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/nmi.h>
 #include <linux/sysdev.h>
+#include <linux/dump.h>
 
 #include <asm/smp.h>
 #include <asm/mtrr.h>
@@ -477,7 +478,7 @@ void nmi_watchdog_tick (struct pt_regs * regs)
                 * wait a few IRQs (5 seconds) before doing the oops ...
                 */
                alert_counter[cpu]++;
-               if (alert_counter[cpu] == 5*nmi_hz) {
+               if (alert_counter[cpu] == 60*nmi_hz) {
                        spin_lock(&nmi_print_lock);
                        /*
                         * We are in trouble anyway, lets at least try
@@ -486,6 +487,7 @@ void nmi_watchdog_tick (struct pt_regs * regs)
                        bust_spinlocks(1);
                        printk("NMI Watchdog detected LOCKUP on CPU%d, eip %08lx, registers:\n", cpu, regs->eip);
                        show_registers(regs);
+                       dump("NMI Watchdog detected LOCKUP", regs);
                        printk("console shuts up ...\n");
                        console_silent();
                        spin_unlock(&nmi_print_lock);
@@ -524,3 +526,4 @@ EXPORT_SYMBOL(reserve_lapic_nmi);
 EXPORT_SYMBOL(release_lapic_nmi);
 EXPORT_SYMBOL(disable_timer_nmi_watchdog);
 EXPORT_SYMBOL(enable_timer_nmi_watchdog);
+EXPORT_SYMBOL_GPL(touch_nmi_watchdog);
index 75b2009..3093d1f 100644 (file)
@@ -36,6 +36,8 @@
 #include <linux/module.h>
 #include <linux/kallsyms.h>
 #include <linux/ptrace.h>
+#include <linux/mman.h>
+#include <linux/random.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -46,6 +48,7 @@
 #include <asm/i387.h>
 #include <asm/irq.h>
 #include <asm/desc.h>
+#include <asm/atomic_kmap.h>
 #ifdef CONFIG_MATH_EMULATION
 #include <asm/math_emu.h>
 #endif
@@ -249,6 +252,8 @@ void show_regs(struct pt_regs * regs)
        show_trace(NULL, &regs->esp);
 }
 
+EXPORT_SYMBOL_GPL(show_regs);
+
 /*
  * This gets run with %ebx containing the
  * function to call, and %edx containing
@@ -311,6 +316,9 @@ void flush_thread(void)
        struct task_struct *tsk = current;
 
        memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8);
+#ifdef CONFIG_X86_HIGH_ENTRY
+       clear_thread_flag(TIF_DB7);
+#endif
        memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));        
        /*
         * Forget coprocessor state..
@@ -324,9 +332,8 @@ void release_thread(struct task_struct *dead_task)
        if (dead_task->mm) {
                // temporary debugging check
                if (dead_task->mm->context.size) {
-                       printk("WARNING: dead process %8s still has LDT? <%p/%d>\n",
+                       printk("WARNING: dead process %8s still has LDT? <%d>\n",
                                        dead_task->comm,
-                                       dead_task->mm->context.ldt,
                                        dead_task->mm->context.size);
                        BUG();
                }
@@ -350,7 +357,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
 {
        struct pt_regs * childregs;
        struct task_struct *tsk;
-       int err;
+       int err, i;
 
        childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long) p->thread_info)) - 1;
        *childregs = *regs;
@@ -361,7 +368,18 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
        p->thread.esp = (unsigned long) childregs;
        p->thread.esp0 = (unsigned long) (childregs+1);
 
+       /*
+        * get the two stack pages, for the virtual stack.
+        *
+        * IMPORTANT: this code relies on the fact that the task
+        * structure is an THREAD_SIZE aligned piece of physical memory.
+        */
+       for (i = 0; i < ARRAY_SIZE(p->thread.stack_page); i++)
+               p->thread.stack_page[i] =
+                               virt_to_page((unsigned long)p->thread_info + (i*PAGE_SIZE));
+
        p->thread.eip = (unsigned long) ret_from_fork;
+       p->thread_info->real_stack = p->thread_info;
 
        savesegment(fs,p->thread.fs);
        savesegment(gs,p->thread.gs);
@@ -512,11 +530,45 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
        /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
 
        __unlazy_fpu(prev_p);
+       if (next_p->mm)
+               load_user_cs_desc(cpu, next_p->mm);
 
+#ifdef CONFIG_X86_HIGH_ENTRY
+{
+       int i;
+       /*
+        * Set the ptes of the virtual stack. (NOTE: a one-page TLB flush is
+        * needed because otherwise NMIs could interrupt the
+        * user-return code with a virtual stack and stale TLBs.)
+        */
+       for (i = 0; i < ARRAY_SIZE(next->stack_page); i++) {
+               __kunmap_atomic_type(KM_VSTACK_TOP-i);
+               __kmap_atomic(next->stack_page[i], KM_VSTACK_TOP-i);
+       }
+       /*
+        * NOTE: here we rely on the task being the stack as well
+        */
+       next_p->thread_info->virtual_stack =
+                       (void *)__kmap_atomic_vaddr(KM_VSTACK_TOP);
+}
+#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
+       /*
+        * If next was preempted on entry from userspace to kernel,
+        * and now it's on a different cpu, we need to adjust %esp.
+        * This assumes that entry.S does not copy %esp while on the
+        * virtual stack (with interrupts enabled): which is so,
+        * except within __SWITCH_KERNELSPACE itself.
+        */
+       if (unlikely(next->esp >= TASK_SIZE)) {
+               next->esp &= THREAD_SIZE - 1;
+               next->esp |= (unsigned long) next_p->thread_info->virtual_stack;
+       }
+#endif
+#endif
        /*
         * Reload esp0, LDT and the page table pointer:
         */
-       load_esp0(tss, next);
+       load_virtual_esp0(tss, next_p);
 
        /*
         * Load the per-thread Thread-Local Storage descriptor.
@@ -776,3 +828,62 @@ asmlinkage int sys_get_thread_area(struct user_desc __user *u_info)
        return 0;
 }
 
+
+unsigned long arch_align_stack(unsigned long sp)
+{
+       if (current->flags & PF_RELOCEXEC)
+               sp -= ((get_random_int() % 65536) << 4);
+       return sp & ~0xf;
+}
+
+
+void arch_add_exec_range(struct mm_struct *mm, unsigned long limit)
+{
+       if (limit > mm->context.exec_limit) {
+               mm->context.exec_limit = limit;
+               set_user_cs(&mm->context.user_cs, limit);
+               if (mm == current->mm)
+                       load_user_cs_desc(smp_processor_id(), mm);
+       }
+}
+
+void arch_remove_exec_range(struct mm_struct *mm, unsigned long old_end)
+{
+       struct vm_area_struct *vma;
+       unsigned long limit = 0;
+
+       if (old_end == mm->context.exec_limit) {
+               for (vma = mm->mmap; vma; vma = vma->vm_next)
+                       if ((vma->vm_flags & VM_EXEC) && (vma->vm_end > limit))
+                               limit = vma->vm_end;
+
+               mm->context.exec_limit = limit;
+               set_user_cs(&mm->context.user_cs, limit);
+               if (mm == current->mm)
+                       load_user_cs_desc(smp_processor_id(), mm);
+       }
+}
+
+void arch_flush_exec_range(struct mm_struct *mm)
+{
+       mm->context.exec_limit = 0;
+       set_user_cs(&mm->context.user_cs, 0);
+}
+
+/*
+ * Generate random brk address between 128MB and 196MB. (if the layout
+ * allows it.)
+ */
+void randomize_brk(unsigned long old_brk)
+{
+       unsigned long new_brk, range_start, range_end;
+
+       range_start = 0x08000000;
+       if (current->mm->brk >= range_start)
+               range_start = current->mm->brk;
+       range_end = range_start + 0x02000000;
+       new_brk = randomize_range(range_start, range_end, 0);
+       if (new_brk)
+               current->mm->brk = new_brk;
+}
+
index 0cf2f11..6f3a626 100644 (file)
@@ -259,6 +259,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 0697425..e8d5cd3 100644 (file)
@@ -233,12 +233,11 @@ void machine_real_restart(unsigned char *code, int length)
        CMOS_WRITE(0x00, 0x8f);
        spin_unlock_irqrestore(&rtc_lock, flags);
 
-       /* Remap the kernel at virtual address zero, as well as offset zero
-          from the kernel segment.  This assumes the kernel segment starts at
-          virtual address PAGE_OFFSET. */
-
-       memcpy (swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
-               sizeof (swapper_pg_dir [0]) * KERNEL_PGD_PTRS);
+       /*
+        * Remap the first 16 MB of RAM (which includes the kernel image)
+        * at virtual address zero:
+        */
+       setup_identity_mappings(swapper_pg_dir, 0, LOW_MAPPINGS_SIZE);
 
        /*
         * Use `swapper_pg_dir' as our page directory.
@@ -330,7 +329,8 @@ void machine_restart(char * __unused)
         * Stop all CPUs and turn off local APICs and the IO-APIC, so
         * other OSs see a clean IRQ state.
         */
-       smp_send_stop();
+       if (!netdump_mode)
+               smp_send_stop();
 #elif defined(CONFIG_X86_LOCAL_APIC)
        if (cpu_has_apic) {
                local_irq_disable();
index 375fd07..c0675d5 100644 (file)
@@ -656,6 +656,8 @@ static inline void copy_edd(void)
  */
 #define LOWMEMSIZE()   (0x9f000)
 
+unsigned long crashdump_addr = 0xdeadbeef;
+
 static void __init parse_cmdline_early (char ** cmdline_p)
 {
        char c = ' ', *to = command_line, *from = saved_command_line;
@@ -809,6 +811,9 @@ static void __init parse_cmdline_early (char ** cmdline_p)
                if (c == ' ' && !memcmp(from, "highmem=", 8))
                        highmem_pages = memparse(from+8, &from) >> PAGE_SHIFT;
        
+               if (c == ' ' && !memcmp(from, "crashdump=", 10))
+                       crashdump_addr = memparse(from+10, &from); 
+                       
                c = *(from++);
                if (!c)
                        break;
@@ -1260,6 +1265,10 @@ __setup("noreplacement", noreplacement_setup);
 
 static char * __init machine_specific_memory_setup(void);
 
+#ifdef CONFIG_CRASH_DUMP_SOFTBOOT
+extern void crashdump_reserve(void);
+#endif
+
 /*
  * Determine if we were loaded by an EFI loader.  If so, then we have also been
  * passed the efi memmap, systab, etc., so we should use these data structures
@@ -1356,6 +1365,10 @@ void __init setup_arch(char **cmdline_p)
 #endif
 
 
+#ifdef CONFIG_CRASH_DUMP_SOFTBOOT
+       crashdump_reserve(); /* Preserve crash dump state from prev boot */
+#endif
+
        dmi_scan_machine();
 
 #ifdef CONFIG_X86_GENERICARCH
index 57e88b6..7cebb68 100644 (file)
@@ -132,28 +132,29 @@ sys_sigaltstack(unsigned long ebx)
  */
 
 static int
-restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax)
+restore_sigcontext(struct pt_regs *regs,
+               struct sigcontext __user *__sc, int *peax)
 {
-       unsigned int err = 0;
+       struct sigcontext scratch; /* 88 bytes of scratch area */
 
        /* Always make any pending restarted system calls return -EINTR */
        current_thread_info()->restart_block.fn = do_no_restart_syscall;
 
-#define COPY(x)                err |= __get_user(regs->x, &sc->x)
+       if (copy_from_user(&scratch, __sc, sizeof(scratch)))
+               return -EFAULT;
+
+#define COPY(x)                regs->x = scratch.x
 
 #define COPY_SEG(seg)                                                  \
-       { unsigned short tmp;                                           \
-         err |= __get_user(tmp, &sc->seg);                             \
+       { unsigned short tmp = scratch.seg;                             \
          regs->x##seg = tmp; }
 
 #define COPY_SEG_STRICT(seg)                                           \
-       { unsigned short tmp;                                           \
-         err |= __get_user(tmp, &sc->seg);                             \
+       { unsigned short tmp = scratch.seg;                             \
          regs->x##seg = tmp|3; }
 
 #define GET_SEG(seg)                                                   \
-       { unsigned short tmp;                                           \
-         err |= __get_user(tmp, &sc->seg);                             \
+       { unsigned short tmp = scratch.seg;                             \
          loadsegment(seg,tmp); }
 
 #define        FIX_EFLAGS      (X86_EFLAGS_AC | X86_EFLAGS_OF | X86_EFLAGS_DF | \
@@ -176,27 +177,23 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax
        COPY_SEG_STRICT(ss);
        
        {
-               unsigned int tmpflags;
-               err |= __get_user(tmpflags, &sc->eflags);
+               unsigned int tmpflags = scratch.eflags;
                regs->eflags = (regs->eflags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
                regs->orig_eax = -1;            /* disable syscall checks */
        }
 
        {
-               struct _fpstate __user * buf;
-               err |= __get_user(buf, &sc->fpstate);
+               struct _fpstate * buf = scratch.fpstate;
                if (buf) {
                        if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
-                               goto badframe;
-                       err |= restore_i387(buf);
+                               return -EFAULT;
+                       if (restore_i387(buf))
+                               return -EFAULT;
                }
        }
 
-       err |= __get_user(*peax, &sc->eax);
-       return err;
-
-badframe:
-       return 1;
+       *peax = scratch.eax;
+       return 0;
 }
 
 asmlinkage int sys_sigreturn(unsigned long __unused)
@@ -265,46 +262,47 @@ badframe:
  */
 
 static int
-setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
+setup_sigcontext(struct sigcontext __user *__sc, struct _fpstate __user *fpstate,
                 struct pt_regs *regs, unsigned long mask)
 {
-       int tmp, err = 0;
+       struct sigcontext sc; /* 88 bytes of scratch area */
+       int tmp;
 
        tmp = 0;
        __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
-       err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
+       *(unsigned int *)&sc.gs = tmp;
        __asm__("movl %%fs,%0" : "=r"(tmp): "0"(tmp));
-       err |= __put_user(tmp, (unsigned int __user *)&sc->fs);
-
-       err |= __put_user(regs->xes, (unsigned int __user *)&sc->es);
-       err |= __put_user(regs->xds, (unsigned int __user *)&sc->ds);
-       err |= __put_user(regs->edi, &sc->edi);
-       err |= __put_user(regs->esi, &sc->esi);
-       err |= __put_user(regs->ebp, &sc->ebp);
-       err |= __put_user(regs->esp, &sc->esp);
-       err |= __put_user(regs->ebx, &sc->ebx);
-       err |= __put_user(regs->edx, &sc->edx);
-       err |= __put_user(regs->ecx, &sc->ecx);
-       err |= __put_user(regs->eax, &sc->eax);
-       err |= __put_user(current->thread.trap_no, &sc->trapno);
-       err |= __put_user(current->thread.error_code, &sc->err);
-       err |= __put_user(regs->eip, &sc->eip);
-       err |= __put_user(regs->xcs, (unsigned int __user *)&sc->cs);
-       err |= __put_user(regs->eflags, &sc->eflags);
-       err |= __put_user(regs->esp, &sc->esp_at_signal);
-       err |= __put_user(regs->xss, (unsigned int __user *)&sc->ss);
+       *(unsigned int *)&sc.fs = tmp;
+       *(unsigned int *)&sc.es = regs->xes;
+       *(unsigned int *)&sc.ds = regs->xds;
+       sc.edi = regs->edi;
+       sc.esi = regs->esi;
+       sc.ebp = regs->ebp;
+       sc.esp = regs->esp;
+       sc.ebx = regs->ebx;
+       sc.edx = regs->edx;
+       sc.ecx = regs->ecx;
+       sc.eax = regs->eax;
+       sc.trapno = current->thread.trap_no;
+       sc.err = current->thread.error_code;
+       sc.eip = regs->eip;
+       *(unsigned int *)&sc.cs = regs->xcs;
+       sc.eflags = regs->eflags;
+       sc.esp_at_signal = regs->esp;
+       *(unsigned int *)&sc.ss = regs->xss;
 
        tmp = save_i387(fpstate);
        if (tmp < 0)
-         err = 1;
-       else
-         err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate);
+               return 1;
+       sc.fpstate = tmp ? fpstate : NULL;
 
        /* non-iBCS2 extensions.. */
-       err |= __put_user(mask, &sc->oldmask);
-       err |= __put_user(current->thread.cr2, &sc->cr2);
+       sc.oldmask = mask;
+       sc.cr2 = current->thread.cr2;
 
-       return err;
+       if (copy_to_user(__sc, &sc, sizeof(sc)))
+               return 1;
+       return 0;
 }
 
 /*
@@ -371,7 +369,7 @@ static void setup_frame(int sig, struct k_sigaction *ka,
        if (err)
                goto give_sigsegv;
 
-       restorer = &__kernel_sigreturn;
+       restorer = current->mm->context.vdso + (long)&__kernel_sigreturn;
        if (ka->sa.sa_flags & SA_RESTORER)
                restorer = ka->sa.sa_restorer;
 
@@ -443,7 +441,7 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
        /* Create the ucontext.  */
        err |= __put_user(0, &frame->uc.uc_flags);
        err |= __put_user(0, &frame->uc.uc_link);
-       err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
+       err |= __put_user(current->sas_ss_sp, (unsigned long *)&frame->uc.uc_stack.ss_sp);
        err |= __put_user(sas_ss_flags(regs->esp),
                          &frame->uc.uc_stack.ss_flags);
        err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
@@ -454,9 +452,10 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
                goto give_sigsegv;
 
        /* Set up to return from userspace.  */
-       restorer = &__kernel_rt_sigreturn;
+       restorer = current->mm->context.vdso + (long)&__kernel_rt_sigreturn;
        if (ka->sa.sa_flags & SA_RESTORER)
                restorer = ka->sa.sa_restorer;
+
        err |= __put_user(restorer, &frame->pretcode);
         
        /*
index bb59601..2772f18 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/cache.h>
 #include <linux/interrupt.h>
+#include <linux/dump.h>
 
 #include <asm/mtrr.h>
 #include <asm/tlbflush.h>
@@ -143,6 +144,13 @@ inline void __send_IPI_shortcut(unsigned int shortcut, int vector)
         */
        cfg = __prepare_ICR(shortcut, vector);
 
+       if (vector == DUMP_VECTOR) {
+               /*
+                * Setup DUMP IPI to be delivered as an NMI
+                */
+               cfg = (cfg&~APIC_VECTOR_MASK)|APIC_DM_NMI;
+       }
+
        /*
         * Send the IPI. The write to APIC_ICR fires this off.
         */
@@ -220,7 +228,13 @@ inline void send_IPI_mask_sequence(cpumask_t mask, int vector)
                         * program the ICR 
                         */
                        cfg = __prepare_ICR(0, vector);
-                       
+               
+                       if (vector == DUMP_VECTOR) {
+                               /*
+                                * Setup DUMP IPI to be delivered as an NMI
+                                */
+                               cfg = (cfg&~APIC_VECTOR_MASK)|APIC_DM_NMI;
+                       }       
                        /*
                         * Send the IPI. The write to APIC_ICR fires this off.
                         */
@@ -326,10 +340,12 @@ asmlinkage void smp_invalidate_interrupt (void)
                 
        if (flush_mm == cpu_tlbstate[cpu].active_mm) {
                if (cpu_tlbstate[cpu].state == TLBSTATE_OK) {
+#ifndef CONFIG_X86_SWITCH_PAGETABLES
                        if (flush_va == FLUSH_ALL)
                                local_flush_tlb();
                        else
                                __flush_tlb_one(flush_va);
+#endif
                } else
                        leave_mm(cpu);
        }
@@ -395,21 +411,6 @@ static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
        spin_unlock(&tlbstate_lock);
 }
        
-void flush_tlb_current_task(void)
-{
-       struct mm_struct *mm = current->mm;
-       cpumask_t cpu_mask;
-
-       preempt_disable();
-       cpu_mask = mm->cpu_vm_mask;
-       cpu_clear(smp_processor_id(), cpu_mask);
-
-       local_flush_tlb();
-       if (!cpus_empty(cpu_mask))
-               flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
-       preempt_enable();
-}
-
 void flush_tlb_mm (struct mm_struct * mm)
 {
        cpumask_t cpu_mask;
@@ -441,7 +442,10 @@ void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
 
        if (current->active_mm == mm) {
                if(current->mm)
-                       __flush_tlb_one(va);
+#ifndef CONFIG_X86_SWITCH_PAGETABLES
+                       __flush_tlb_one(va)
+#endif
+                               ;
                 else
                        leave_mm(smp_processor_id());
        }
@@ -466,6 +470,11 @@ void flush_tlb_all(void)
        on_each_cpu(do_flush_tlb_all, NULL, 1, 1);
 }
 
+void dump_send_ipi(void)
+{
+       send_IPI_allbutself(DUMP_VECTOR);
+}
+
 /*
  * this function sends a 'reschedule' IPI to another CPU.
  * it goes straight through and wastes no time serializing
@@ -504,7 +513,10 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
  * <func> The function to run. This must be fast and non-blocking.
  * <info> An arbitrary pointer to pass to the function.
  * <nonatomic> currently unused.
- * <wait> If true, wait (atomically) until function has completed on other CPUs.
+ * <wait> If 1, wait (atomically) until function has completed on other CPUs.
+ *        If 0, wait for the IPI to be received by other CPUs, but do not wait 
+ *        for the completion of the function on each CPU.  
+ *        If -1, do not wait for other CPUs to receive IPI.
  * [RETURNS] 0 on success, else a negative status code. Does not return until
  * remote CPUs are nearly ready to execute <<func>> or are or have executed.
  *
@@ -519,13 +531,14 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
                return 0;
 
        /* Can deadlock when called with interrupts disabled */
-       WARN_ON(irqs_disabled());
+       /* Only if we are waiting for other CPU to ack */
+       WARN_ON(irqs_disabled() && wait >= 0);
 
        data.func = func;
        data.info = info;
        atomic_set(&data.started, 0);
-       data.wait = wait;
-       if (wait)
+       data.wait = wait > 0 ? wait : 0;
+       if (wait > 0)
                atomic_set(&data.finished, 0);
 
        spin_lock(&call_lock);
@@ -536,10 +549,11 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
        send_IPI_allbutself(CALL_FUNCTION_VECTOR);
 
        /* Wait for response */
-       while (atomic_read(&data.started) != cpus)
-               barrier();
+       if (wait >= 0)
+               while (atomic_read(&data.started) != cpus)
+                       barrier();
 
-       if (wait)
+       if (wait > 0)
                while (atomic_read(&data.finished) != cpus)
                        barrier();
        spin_unlock(&call_lock);
@@ -547,7 +561,7 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
        return 0;
 }
 
-static void stop_this_cpu (void * dummy)
+void stop_this_cpu (void * dummy)
 {
        /*
         * Remove this CPU:
@@ -573,6 +587,8 @@ void smp_send_stop(void)
        local_irq_enable();
 }
 
+EXPORT_SYMBOL(smp_send_stop);
+
 /*
  * Reschedule call back. Nothing to do,
  * all the work is done automatically when
@@ -608,4 +624,3 @@ asmlinkage void smp_call_function_interrupt(void)
                atomic_inc(&call_data->finished);
        }
 }
-
diff --git a/arch/i386/kernel/std_resources.c b/arch/i386/kernel/std_resources.c
deleted file mode 100644 (file)
index 9b56474..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- *  Machine specific resource allocation for generic.
- */
-
-#include <linux/ioport.h>
-#include <asm/io.h>
-#include <asm/std_resources.h>
-
-#define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
-
-static struct resource system_rom_resource = {
-       .name   = "System ROM",
-       .start  = 0xf0000,
-       .end    = 0xfffff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource extension_rom_resource = {
-       .name   = "Extension ROM",
-       .start  = 0xe0000,
-       .end    = 0xeffff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource adapter_rom_resources[] = { {
-       .name   = "Adapter ROM",
-       .start  = 0xc8000,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-       .name   = "Adapter ROM",
-       .start  = 0,
-       .end    = 0,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-} };
-
-#define ADAPTER_ROM_RESOURCES \
-       (sizeof adapter_rom_resources / sizeof adapter_rom_resources[0])
-
-static struct resource video_rom_resource = {
-       .name   = "Video ROM",
-       .start  = 0xc0000,
-       .end    = 0xc7fff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource vram_resource = {
-       .name   = "Video RAM area",
-       .start  = 0xa0000,
-       .end    = 0xbffff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
-};
-
-static struct resource standard_io_resources[] = { {
-       .name   = "dma1",
-       .start  = 0x0000,
-       .end    = 0x001f,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "pic1",
-       .start  = 0x0020,
-       .end    = 0x0021,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "timer",
-       .start  = 0x0040,
-       .end    = 0x005f,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "keyboard",
-       .start  = 0x0060,
-       .end    = 0x006f,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "dma page reg",
-       .start  = 0x0080,
-       .end    = 0x008f,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "pic2",
-       .start  = 0x00a0,
-       .end    = 0x00a1,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "dma2",
-       .start  = 0x00c0,
-       .end    = 0x00df,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
-       .name   = "fpu",
-       .start  = 0x00f0,
-       .end    = 0x00ff,
-       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
-} };
-
-#define STANDARD_IO_RESOURCES \
-       (sizeof standard_io_resources / sizeof standard_io_resources[0])
-
-static int __init checksum(unsigned char *rom, unsigned long length)
-{
-       unsigned char *p, sum = 0;
-
-       for (p = rom; p < rom + length; p++)
-               sum += *p;
-       return sum == 0;
-}
-
-void __init probe_roms(void)
-{
-       unsigned long start, length, upper;
-       unsigned char *rom;
-       int           i;
-
-       /* video rom */
-       upper = adapter_rom_resources[0].start;
-       for (start = video_rom_resource.start; start < upper; start += 2048) {
-               rom = isa_bus_to_virt(start);
-               if (!romsignature(rom))
-                       continue;
-
-               video_rom_resource.start = start;
-
-               /* 0 < length <= 0x7f * 512, historically */
-               length = rom[2] * 512;
-
-               /* if checksum okay, trust length byte */
-               if (length && checksum(rom, length))
-                       video_rom_resource.end = start + length - 1;
-
-               request_resource(&iomem_resource, &video_rom_resource);
-               break;
-       }
-
-       start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
-       if (start < upper)
-               start = upper;
-
-       /* system rom */
-       request_resource(&iomem_resource, &system_rom_resource);
-       upper = system_rom_resource.start;
-
-       /* check for extension rom (ignore length byte!) */
-       rom = isa_bus_to_virt(extension_rom_resource.start);
-       if (romsignature(rom)) {
-               length = extension_rom_resource.end - extension_rom_resource.start + 1;
-               if (checksum(rom, length)) {
-                       request_resource(&iomem_resource, &extension_rom_resource);
-                       upper = extension_rom_resource.start;
-               }
-       }
-
-       /* check for adapter roms on 2k boundaries */
-       for (i = 0; i < ADAPTER_ROM_RESOURCES && start < upper; start += 2048) {
-               rom = isa_bus_to_virt(start);
-               if (!romsignature(rom))
-                       continue;
-
-               /* 0 < length <= 0x7f * 512, historically */
-               length = rom[2] * 512;
-
-               /* but accept any length that fits if checksum okay */
-               if (!length || start + length > upper || !checksum(rom, length))
-                       continue;
-
-               adapter_rom_resources[i].start = start;
-               adapter_rom_resources[i].end = start + length - 1;
-               request_resource(&iomem_resource, &adapter_rom_resources[i]);
-
-               start = adapter_rom_resources[i++].end & ~2047UL;
-       }
-}
-
-void __init request_graphics_resource(void)
-{
-       request_resource(&iomem_resource, &vram_resource);
-}
-
-void __init request_standard_io_resources(void)
-{
-       int i;
-
-       for (i = 0; i < STANDARD_IO_RESOURCES; i++)
-               request_resource(&ioport_resource, &standard_io_resources[i]);
-}
index a4a6197..551e33c 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/mman.h>
 #include <linux/file.h>
 #include <linux/utsname.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
@@ -57,7 +58,7 @@ static inline long do_mmap2(
        }
 
        down_write(&current->mm->mmap_sem);
-       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+       error = do_mmap_pgoff(current->mm, file, addr, len, prot, flags, pgoff);
        up_write(&current->mm->mmap_sem);
 
        if (file)
@@ -217,7 +218,7 @@ asmlinkage int sys_uname(struct old_utsname __user * name)
        if (!name)
                return -EFAULT;
        down_read(&uts_sem);
-       err=copy_to_user(name, &system_utsname, sizeof (*name));
+       err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
        up_read(&uts_sem);
        return err?-EFAULT:0;
 }
@@ -225,6 +226,7 @@ asmlinkage int sys_uname(struct old_utsname __user * name)
 asmlinkage int sys_olduname(struct oldold_utsname __user * name)
 {
        int error;
+       struct new_utsname *ptr;
 
        if (!name)
                return -EFAULT;
@@ -233,15 +235,16 @@ asmlinkage int sys_olduname(struct oldold_utsname __user * name)
   
        down_read(&uts_sem);
        
-       error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
+       ptr = vx_new_utsname();
+       error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
        error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
+       error |= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
        error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
+       error |= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
        error |= __put_user(0,name->release+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
+       error |= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
        error |= __put_user(0,name->version+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
+       error |= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
        error |= __put_user(0,name->machine+__OLD_UTS_LEN);
        
        up_read(&uts_sem);
index 0daa404..f936357 100644 (file)
 #include <linux/gfp.h>
 #include <linux/string.h>
 #include <linux/elf.h>
+#include <linux/mman.h>
 
 #include <asm/cpufeature.h>
 #include <asm/msr.h>
 #include <asm/pgtable.h>
 #include <asm/unistd.h>
+#include <linux/highmem.h>
 
 extern asmlinkage void sysenter_entry(void);
 
 void enable_sep_cpu(void *info)
 {
        int cpu = get_cpu();
+#ifdef CONFIG_X86_HIGH_ENTRY
+       struct tss_struct *tss = (struct tss_struct *) __fix_to_virt(FIX_TSS_0) + cpu;
+#else
        struct tss_struct *tss = init_tss + cpu;
+#endif
 
        tss->ss1 = __KERNEL_CS;
        tss->esp1 = sizeof(struct tss_struct) + (unsigned long) tss;
@@ -41,11 +47,14 @@ void enable_sep_cpu(void *info)
 extern const char vsyscall_int80_start, vsyscall_int80_end;
 extern const char vsyscall_sysenter_start, vsyscall_sysenter_end;
 
+struct page *sysenter_page;
+
 static int __init sysenter_setup(void)
 {
        unsigned long page = get_zeroed_page(GFP_ATOMIC);
 
-       __set_fixmap(FIX_VSYSCALL, __pa(page), PAGE_READONLY_EXEC);
+       __set_fixmap(FIX_VSYSCALL, __pa(page), PAGE_KERNEL_RO);
+       sysenter_page = virt_to_page(page);
 
        if (!boot_cpu_has(X86_FEATURE_SEP)) {
                memcpy((void *) page,
@@ -59,7 +68,51 @@ static int __init sysenter_setup(void)
               &vsyscall_sysenter_end - &vsyscall_sysenter_start);
 
        on_each_cpu(enable_sep_cpu, NULL, 1, 1);
+
        return 0;
 }
 
 __initcall(sysenter_setup);
+
+extern void SYSENTER_RETURN_OFFSET;
+
+unsigned int vdso_enabled = 0;
+
+void map_vsyscall(void)
+{
+       struct thread_info *ti = current_thread_info();
+       struct vm_area_struct *vma;
+       unsigned long addr;
+
+       if (unlikely(!vdso_enabled)) {
+               current->mm->context.vdso = NULL;
+               return;
+       }
+
+       /*
+        * Map the vDSO (it will be randomized):
+        */
+       down_write(&current->mm->mmap_sem);
+       addr = do_mmap(NULL, 0, 4096, PROT_READ | PROT_EXEC, MAP_PRIVATE, 0);
+       current->mm->context.vdso = (void *)addr;
+       ti->sysenter_return = (void *)addr + (long)&SYSENTER_RETURN_OFFSET;
+       if (addr != -1) {
+               vma = find_vma(current->mm, addr);
+               if (vma) {
+                       pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
+                       get_page(sysenter_page);
+                       install_page(current->mm, vma, addr,
+                                       sysenter_page, vma->vm_page_prot);
+                       
+               }
+       }
+       up_write(&current->mm->mmap_sem);
+}
+
+static int __init vdso_setup(char *str)
+{
+        vdso_enabled = simple_strtoul(str, NULL, 0);
+        return 1;
+}
+__setup("vdso=", vdso_setup);
+
index 0526fc1..b2f722e 100644 (file)
@@ -19,10 +19,10 @@ static struct timer_opts* timers[] = {
 #ifdef CONFIG_HPET_TIMER
        &timer_hpet,
 #endif
+       &timer_tsc,
 #ifdef CONFIG_X86_PM_TIMER
        &timer_pmtmr,
 #endif
-       &timer_tsc,
        &timer_pit,
        NULL,
 };
index a3daea0..6e9ed08 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kallsyms.h>
 #include <linux/ptrace.h>
 #include <linux/version.h>
+#include <linux/dump.h>
 
 #ifdef CONFIG_EISA
 #include <linux/ioport.h>
 
 #include "mach_traps.h"
 
-asmlinkage int system_call(void);
-asmlinkage void lcall7(void);
-asmlinkage void lcall27(void);
-
-struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
-               { 0, 0 }, { 0, 0 } };
+struct desc_struct default_ldt[] __attribute__((__section__(".data.default_ldt"))) = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
+struct page *default_ldt_page;
 
 /* Do we ignore FPU interrupts ? */
 char ignore_fpu_irq = 0;
@@ -244,8 +241,10 @@ void show_registers(struct pt_regs *regs)
 
                for(i=0;i<20;i++)
                {
-                       unsigned char c;
-                       if(__get_user(c, &((unsigned char*)regs->eip)[i])) {
+                       unsigned char c = 0;
+                        if ((user_mode(regs) && get_user(c, &((unsigned char*)regs->eip)[i])) ||
+                            (!user_mode(regs) && __direct_get_user(c, &((unsigned char*)regs->eip)[i]))) {
+                       
 bad:
                                printk(" Bad EIP value.");
                                break;
@@ -269,16 +268,14 @@ static void handle_BUG(struct pt_regs *regs)
 
        eip = regs->eip;
 
-       if (eip < PAGE_OFFSET)
-               goto no_bug;
-       if (__get_user(ud2, (unsigned short *)eip))
+       if (__direct_get_user(ud2, (unsigned short *)eip))
                goto no_bug;
        if (ud2 != 0x0b0f)
                goto no_bug;
-       if (__get_user(line, (unsigned short *)(eip + 2)))
+       if (__direct_get_user(line, (unsigned short *)(eip + 2)))
                goto bug;
-       if (__get_user(file, (char **)(eip + 4)) ||
-               (unsigned long)file < PAGE_OFFSET || __get_user(c, file))
+       if (__direct_get_user(file, (char **)(eip + 4)) ||
+                       __direct_get_user(c, file))
                file = "<bad filename>";
 
        printk("------------[ cut here ]------------\n");
@@ -293,6 +290,7 @@ bug:
 }
 
 spinlock_t die_lock = SPIN_LOCK_UNLOCKED;
+static int die_owner = -1;
 
 void die(const char * str, struct pt_regs * regs, long err)
 {
@@ -300,7 +298,13 @@ void die(const char * str, struct pt_regs * regs, long err)
        int nl = 0;
 
        console_verbose();
-       spin_lock_irq(&die_lock);
+       local_irq_disable();
+       if (!spin_trylock(&die_lock)) {
+               if (smp_processor_id() != die_owner)
+                       spin_lock(&die_lock);
+               /* allow recursive die to fall through */
+       }
+       die_owner = smp_processor_id();
        bust_spinlocks(1);
        handle_BUG(regs);
        printk(KERN_ALERT "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
@@ -319,12 +323,18 @@ void die(const char * str, struct pt_regs * regs, long err)
        if (nl)
                printk("\n");
        show_registers(regs);
+       if (netdump_func)
+               netdump_func(regs);
+       dump((char *)str, regs);
        bust_spinlocks(0);
+       die_owner = -1;
        spin_unlock_irq(&die_lock);
        if (in_interrupt())
                panic("Fatal exception in interrupt");
 
        if (panic_on_oops) {
+               if (netdump_func)
+                       netdump_func = NULL;
                printk(KERN_EMERG "Fatal exception: panic in 5 seconds\n");
                set_current_state(TASK_UNINTERRUPTIBLE);
                schedule_timeout(5 * HZ);
@@ -429,6 +439,10 @@ DO_ERROR(11, SIGBUS,  "segment not present", segment_not_present)
 DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, get_cr2())
 
+/*
+ * the original non-exec stack patch was written by
+ * Solar Designer <solar at openwall.com>. Thanks!
+ */
 asmlinkage void do_general_protection(struct pt_regs * regs, long error_code)
 {
        if (regs->eflags & X86_EFLAGS_IF)
@@ -440,6 +454,46 @@ asmlinkage void do_general_protection(struct pt_regs * regs, long error_code)
        if (!(regs->xcs & 3))
                goto gp_in_kernel;
 
+       /*
+        * lazy-check for CS validity on exec-shield binaries:
+        */
+       if (current->mm) {
+               int cpu = smp_processor_id();
+               struct desc_struct *desc1, *desc2;
+               struct vm_area_struct *vma;
+               unsigned long limit = 0;
+               
+               spin_lock(&current->mm->page_table_lock);
+               for (vma = current->mm->mmap; vma; vma = vma->vm_next)
+                       if ((vma->vm_flags & VM_EXEC) && (vma->vm_end > limit))
+                               limit = vma->vm_end;
+               spin_unlock(&current->mm->page_table_lock);
+
+               current->mm->context.exec_limit = limit;
+               set_user_cs(&current->mm->context.user_cs, limit);
+
+               desc1 = &current->mm->context.user_cs;
+               desc2 = cpu_gdt_table[cpu] + GDT_ENTRY_DEFAULT_USER_CS;
+
+               /*
+                * The CS was not in sync - reload it and retry the
+                * instruction. If the instruction still faults then
+                * we wont hit this branch next time around.
+                */
+               if (desc1->a != desc2->a || desc1->b != desc2->b) {
+                       if (print_fatal_signals >= 2) {
+                               printk("#GPF fixup (%ld[seg:%lx]) at %08lx, CPU#%d.\n", error_code, error_code/8, regs->eip, smp_processor_id());
+                               printk(" exec_limit: %08lx, user_cs: %08lx/%08lx, CPU_cs: %08lx/%08lx.\n", current->mm->context.exec_limit, desc1->a, desc1->b, desc2->a, desc2->b);
+                       }
+                       load_user_cs_desc(cpu, current->mm);
+                       return;
+               }
+       }
+       if (print_fatal_signals) {
+               printk("#GPF(%ld[seg:%lx]) at %08lx, CPU#%d.\n", error_code, error_code/8, regs->eip, smp_processor_id());
+               printk(" exec_limit: %08lx, user_cs: %08lx/%08lx.\n", current->mm->context.exec_limit, current->mm->context.user_cs.a, current->mm->context.user_cs.b);
+       }
+
        current->thread.error_code = error_code;
        current->thread.trap_no = 13;
        force_sig(SIGSEGV, current);
@@ -459,7 +513,7 @@ static void mem_parity_error(unsigned char reason, struct pt_regs * regs)
 {
        printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n");
        printk("You probably have a hardware problem with your RAM chips\n");
-
+       panic("Halting\n");
        /* Clear and disable the memory parity error line. */
        clear_mem_error(reason);
 }
@@ -591,10 +645,18 @@ asmlinkage void do_debug(struct pt_regs * regs, long error_code)
        if (regs->eflags & X86_EFLAGS_IF)
                local_irq_enable();
 
-       /* Mask out spurious debug traps due to lazy DR7 setting */
+       /*
+        * Mask out spurious debug traps due to lazy DR7 setting or
+        * due to 4G/4G kernel mode:
+        */
        if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
                if (!tsk->thread.debugreg[7])
                        goto clear_dr7;
+               if (!user_mode(regs)) {
+                       // restore upon return-to-userspace:
+                       set_thread_flag(TIF_DB7);
+                       goto clear_dr7;
+               }
        }
 
        if (regs->eflags & VM_MASK)
@@ -836,19 +898,53 @@ asmlinkage void math_emulate(long arg)
 
 #endif /* CONFIG_MATH_EMULATION */
 
-#ifdef CONFIG_X86_F00F_BUG
-void __init trap_init_f00f_bug(void)
+void __init trap_init_virtual_IDT(void)
 {
-       __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
-
        /*
-        * Update the IDT descriptor and reload the IDT so that
-        * it uses the read-only mapped virtual address.
+        * "idt" is magic - it overlaps the idt_descr
+        * variable so that updating idt will automatically
+        * update the idt descriptor..
         */
-       idt_descr.address = fix_to_virt(FIX_F00F_IDT);
+       __set_fixmap(FIX_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
+       idt_descr.address = __fix_to_virt(FIX_IDT);
+
        __asm__ __volatile__("lidt %0" : : "m" (idt_descr));
 }
+
+void __init trap_init_virtual_GDT(void)
+{
+       int cpu = smp_processor_id();
+       struct Xgt_desc_struct *gdt_desc = cpu_gdt_descr + cpu;
+       struct Xgt_desc_struct tmp_desc = {0, 0};
+       struct tss_struct * t;
+
+       __asm__ __volatile__("sgdt %0": "=m" (tmp_desc): :"memory");
+
+#ifdef CONFIG_X86_HIGH_ENTRY
+       if (!cpu) {
+               __set_fixmap(FIX_GDT_0, __pa(cpu_gdt_table), PAGE_KERNEL);
+               __set_fixmap(FIX_GDT_1, __pa(cpu_gdt_table) + PAGE_SIZE, PAGE_KERNEL);
+               __set_fixmap(FIX_TSS_0, __pa(init_tss), PAGE_KERNEL);
+               __set_fixmap(FIX_TSS_1, __pa(init_tss) + 1*PAGE_SIZE, PAGE_KERNEL);
+               __set_fixmap(FIX_TSS_2, __pa(init_tss) + 2*PAGE_SIZE, PAGE_KERNEL);
+               __set_fixmap(FIX_TSS_3, __pa(init_tss) + 3*PAGE_SIZE, PAGE_KERNEL);
+       }
+
+       gdt_desc->address = __fix_to_virt(FIX_GDT_0) + sizeof(cpu_gdt_table[0]) * cpu;
+#else
+       gdt_desc->address = (unsigned long)cpu_gdt_table[cpu];
+#endif
+       __asm__ __volatile__("lgdt %0": "=m" (*gdt_desc));
+
+#ifdef CONFIG_X86_HIGH_ENTRY
+       t = (struct tss_struct *) __fix_to_virt(FIX_TSS_0) + cpu;
+#else
+       t = init_tss + cpu;
 #endif
+       set_tss_desc(cpu, t);
+       cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff;
+       load_TR_desc();
+}
 
 #define _set_gate(gate_addr,type,dpl,addr,seg) \
 do { \
@@ -875,17 +971,17 @@ void set_intr_gate(unsigned int n, void *addr)
        _set_gate(idt_table+n,14,0,addr,__KERNEL_CS);
 }
 
-static void __init set_trap_gate(unsigned int n, void *addr)
+void __init set_trap_gate(unsigned int n, void *addr)
 {
        _set_gate(idt_table+n,15,0,addr,__KERNEL_CS);
 }
 
-static void __init set_system_gate(unsigned int n, void *addr)
+void __init set_system_gate(unsigned int n, void *addr)
 {
        _set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
 }
 
-static void __init set_call_gate(void *a, void *addr)
+void __init set_call_gate(void *a, void *addr)
 {
        _set_gate(a,12,3,addr,__KERNEL_CS);
 }
@@ -907,6 +1003,7 @@ void __init trap_init(void)
 #ifdef CONFIG_X86_LOCAL_APIC
        init_apic_mappings();
 #endif
+       init_entry_mappings();
 
        set_trap_gate(0,&divide_error);
        set_intr_gate(1,&debug);
@@ -937,9 +1034,10 @@ void __init trap_init(void)
         * default LDT is a single-entry callgate to lcall7 for iBCS
         * and a callgate to lcall27 for Solaris/x86 binaries
         */
+#if 0   
        set_call_gate(&default_ldt[0],lcall7);
        set_call_gate(&default_ldt[4],lcall27);
-
+#endif
        /*
         * Should be a barrier for any external CPU state.
         */
index 4484e47..4b64f6b 100644 (file)
@@ -124,7 +124,7 @@ struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
        tss = init_tss + get_cpu();
        current->thread.esp0 = current->thread.saved_esp0;
        current->thread.sysenter_cs = __KERNEL_CS;
-       load_esp0(tss, &current->thread);
+       load_virtual_esp0(tss, current);
        current->thread.saved_esp0 = 0;
        put_cpu();
 
@@ -307,7 +307,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
        tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
        if (cpu_has_sep)
                tsk->thread.sysenter_cs = 0;
-       load_esp0(tss, &tsk->thread);
+       load_virtual_esp0(tss, tsk);
        put_cpu();
 
        tsk->thread.screen_bitmap = info->screen_bitmap;
index 829f1c9..c838508 100644 (file)
@@ -5,13 +5,17 @@
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/thread_info.h>
 
+#include <linux/config.h>
+#include <asm/page.h>
+#include <asm/asm_offsets.h>
+
 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
 OUTPUT_ARCH(i386)
 ENTRY(startup_32)
 jiffies = jiffies_64;
 SECTIONS
 {
-  . = 0xC0000000 + 0x100000;
+  . = __PAGE_OFFSET + 0x100000;
   /* read-only */
   _text = .;                   /* Text and read-only data */
   .text : {
@@ -21,6 +25,19 @@ SECTIONS
        *(.gnu.warning)
        } = 0x9090
 
+#ifdef CONFIG_X86_4G
+  . = ALIGN(PAGE_SIZE_asm);
+  __entry_tramp_start = .;
+  . = FIX_ENTRY_TRAMPOLINE_0_addr;
+  __start___entry_text = .;
+  .entry.text : AT (__entry_tramp_start) { *(.entry.text) }
+  __entry_tramp_end = __entry_tramp_start + SIZEOF(.entry.text);
+  . = __entry_tramp_end;
+  . = ALIGN(PAGE_SIZE_asm);
+#else
+  .entry.text : { *(.entry.text) }
+#endif
+
   _etext = .;                  /* End of text section */
 
   . = ALIGN(16);               /* Exception table */
@@ -36,15 +53,12 @@ SECTIONS
        CONSTRUCTORS
        }
 
-  . = ALIGN(4096);
+  . = ALIGN(PAGE_SIZE_asm);
   __nosave_begin = .;
   .data_nosave : { *(.data.nosave) }
-  . = ALIGN(4096);
+  . = ALIGN(PAGE_SIZE_asm);
   __nosave_end = .;
 
-  . = ALIGN(4096);
-  .data.page_aligned : { *(.data.idt) }
-
   . = ALIGN(32);
   .data.cacheline_aligned : { *(.data.cacheline_aligned) }
 
@@ -54,7 +68,7 @@ SECTIONS
   .data.init_task : { *(.data.init_task) }
 
   /* will be freed after init */
-  . = ALIGN(4096);             /* Init code and data */
+  . = ALIGN(PAGE_SIZE_asm);            /* Init code and data */
   __init_begin = .;
   .init.text : { 
        _sinittext = .;
@@ -93,7 +107,7 @@ SECTIONS
      from .altinstructions and .eh_frame */
   .exit.text : { *(.exit.text) }
   .exit.data : { *(.exit.data) }
-  . = ALIGN(4096);
+  . = ALIGN(PAGE_SIZE_asm);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
@@ -101,10 +115,22 @@ SECTIONS
   __per_cpu_start = .;
   .data.percpu  : { *(.data.percpu) }
   __per_cpu_end = .;
-  . = ALIGN(4096);
+  . = ALIGN(PAGE_SIZE_asm);
   __init_end = .;
   /* freed after init ends here */
-       
+
+  . = ALIGN(PAGE_SIZE_asm);
+  .data.page_aligned_tss : { *(.data.tss) }
+
+  . = ALIGN(PAGE_SIZE_asm);
+  .data.page_aligned_default_ldt : { *(.data.default_ldt) }
+
+  . = ALIGN(PAGE_SIZE_asm);
+  .data.page_aligned_idt : { *(.data.idt) }
+
+  . = ALIGN(PAGE_SIZE_asm);
+  .data.page_aligned_gdt : { *(.data.gdt) }
+
   __bss_start = .;             /* BSS */
   .bss : {
        *(.bss.page_aligned)
@@ -132,4 +158,6 @@ SECTIONS
   .stab.index 0 : { *(.stab.index) }
   .stab.indexstr 0 : { *(.stab.indexstr) }
   .comment 0 : { *(.comment) }
+
+
 }
index cb54c01..cb421be 100644 (file)
        .type __kernel_vsyscall,@function
 __kernel_vsyscall:
 .LSTART_vsyscall:
+       cmpl $192, %eax
+       jne 1f
+       int $0x80
+       ret
+1:
        push %ecx
 .Lpush_ecx:
        push %edx
@@ -24,11 +29,11 @@ __kernel_vsyscall:
        /* 7: align return point with nop's to make disassembly easier */
        .space 7,0x90
 
-       /* 14: System call restart point is here! (SYSENTER_RETURN - 2) */
+       /* 14: System call restart point is here! (SYSENTER_RETURN_OFFSET-2) */
        jmp .Lenter_kernel
        /* 16: System call normal return point is here! */
-       .globl SYSENTER_RETURN  /* Symbol used by entry.S.  */
-SYSENTER_RETURN:
+       .globl SYSENTER_RETURN_OFFSET   /* Symbol used by sysenter.c  */
+SYSENTER_RETURN_OFFSET:
        pop %ebp
 .Lpop_ebp:
        pop %edx
index 7ff7f8b..484e451 100644 (file)
@@ -1,15 +1,12 @@
 /*
  * Linker script for vsyscall DSO.  The vsyscall page is an ELF shared
- * object prelinked to its virtual address, and with only one read-only
- * segment (that fits in one page).  This script controls its layout.
+ * object with only one read-only segment (that fits in one page).
+ * This script controls its layout.
  */
 
-/* This must match <asm/fixmap.h>.  */
-VSYSCALL_BASE = 0xffffe000;
-
 SECTIONS
 {
-  . = VSYSCALL_BASE + SIZEOF_HEADERS;
+  . = SIZEOF_HEADERS;
 
   .hash           : { *(.hash) }               :text
   .dynsym         : { *(.dynsym) }
@@ -22,7 +19,7 @@ SECTIONS
      For the layouts to match, we need to skip more than enough
      space for the dynamic symbol table et al.  If this amount
      is insufficient, ld -shared will barf.  Just increase it here.  */
-  . = VSYSCALL_BASE + 0x400;
+  . = 0x400;
 
   .text           : { *(.text) }               :text =0x90909090
 
index 94c7867..638b3bf 100644 (file)
@@ -280,14 +280,14 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
        .previous
 
 .align 4
-.globl csum_partial_copy_generic
+.globl direct_csum_partial_copy_generic
                                
 #ifndef CONFIG_X86_USE_PPRO_CHECKSUM
 
 #define ARGBASE 16             
 #define FP             12
                
-csum_partial_copy_generic:
+direct_csum_partial_copy_generic:
        subl  $4,%esp   
        pushl %edi
        pushl %esi
@@ -422,7 +422,7 @@ DST(        movb %cl, (%edi)        )
 
 #define ARGBASE 12
                
-csum_partial_copy_generic:
+direct_csum_partial_copy_generic:
        pushl %ebx
        pushl %edi
        pushl %esi
index 62d7f17..1985ca1 100644 (file)
@@ -9,6 +9,7 @@
  * return value.
  */
 #include <asm/thread_info.h>
+#include <asm/asm_offsets.h>
 
 
 /*
index e1bcec2..6072db0 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/blkdev.h>
-#include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/mmx.h>
 
@@ -31,6 +30,7 @@ static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned lon
 #define __do_strncpy_from_user(dst,src,count,res)                         \
 do {                                                                      \
        int __d0, __d1, __d2;                                              \
+       might_sleep();                                                     \
        __asm__ __volatile__(                                              \
                "       testl %1,%1\n"                                     \
                "       jz 2f\n"                                           \
@@ -77,7 +77,7 @@ do {                                                                     \
  * and returns @count.
  */
 long
-__strncpy_from_user(char *dst, const char __user *src, long count)
+__direct_strncpy_from_user(char *dst, const char __user *src, long count)
 {
        long res;
        __do_strncpy_from_user(dst, src, count, res);
@@ -103,7 +103,7 @@ __strncpy_from_user(char *dst, const char __user *src, long count)
  * and returns @count.
  */
 long
-strncpy_from_user(char *dst, const char __user *src, long count)
+direct_strncpy_from_user(char *dst, const char __user *src, long count)
 {
        long res = -EFAULT;
        if (access_ok(VERIFY_READ, src, 1))
@@ -119,6 +119,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
 #define __do_clear_user(addr,size)                                     \
 do {                                                                   \
        int __d0;                                                       \
+       might_sleep();                                                  \
        __asm__ __volatile__(                                           \
                "0:     rep; stosl\n"                                   \
                "       movl %2,%0\n"                                   \
@@ -148,7 +149,7 @@ do {                                                                        \
  * On success, this will be zero.
  */
 unsigned long
-clear_user(void __user *to, unsigned long n)
+direct_clear_user(void __user *to, unsigned long n)
 {
        might_sleep();
        if (access_ok(VERIFY_WRITE, to, n))
@@ -168,7 +169,7 @@ clear_user(void __user *to, unsigned long n)
  * On success, this will be zero.
  */
 unsigned long
-__clear_user(void __user *to, unsigned long n)
+__direct_clear_user(void __user *to, unsigned long n)
 {
        __do_clear_user(to, n);
        return n;
@@ -185,7 +186,7 @@ __clear_user(void __user *to, unsigned long n)
  * On exception, returns 0.
  * If the string is too long, returns a value greater than @n.
  */
-long strnlen_user(const char __user *s, long n)
+long direct_strnlen_user(const char __user *s, long n)
 {
        unsigned long mask = -__addr_ok(s);
        unsigned long res, tmp;
@@ -568,8 +569,7 @@ survive:
        return n;
 }
 
-unsigned long
-__copy_from_user_ll(void *to, const void __user *from, unsigned long n)
+unsigned long __copy_from_user_ll(void *to, const void __user *from, unsigned long n)
 {
        if (movsl_is_ok(to, from, n))
                __copy_user_zeroing(to, from, n);
@@ -578,53 +578,3 @@ __copy_from_user_ll(void *to, const void __user *from, unsigned long n)
        return n;
 }
 
-/**
- * copy_to_user: - Copy a block of data into user space.
- * @to:   Destination address, in user space.
- * @from: Source address, in kernel space.
- * @n:    Number of bytes to copy.
- *
- * Context: User context only.  This function may sleep.
- *
- * Copy data from kernel space to user space.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- */
-unsigned long
-copy_to_user(void __user *to, const void *from, unsigned long n)
-{
-       might_sleep();
-       if (access_ok(VERIFY_WRITE, to, n))
-               n = __copy_to_user(to, from, n);
-       return n;
-}
-EXPORT_SYMBOL(copy_to_user);
-
-/**
- * copy_from_user: - Copy a block of data from user space.
- * @to:   Destination address, in kernel space.
- * @from: Source address, in user space.
- * @n:    Number of bytes to copy.
- *
- * Context: User context only.  This function may sleep.
- *
- * Copy data from user space to kernel space.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- *
- * If some data could not be copied, this function will pad the copied
- * data to the requested size using zero bytes.
- */
-unsigned long
-copy_from_user(void *to, const void __user *from, unsigned long n)
-{
-       might_sleep();
-       if (access_ok(VERIFY_READ, from, n))
-               n = __copy_from_user(to, from, n);
-       else
-               memset(to, 0, n);
-       return n;
-}
-EXPORT_SYMBOL(copy_from_user);
diff --git a/arch/i386/mach-es7000/es7000.c b/arch/i386/mach-es7000/es7000.c
deleted file mode 100644 (file)
index defe41e..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Written by: Garry Forsgren, Unisys Corporation
- *             Natalie Protasevich, Unisys Corporation
- * This file contains the code to configure and interface 
- * with Unisys ES7000 series hardware system manager.
- *
- * Copyright (c) 2003 Unisys Corporation.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Unisys Corporation, Township Line & Union Meeting 
- * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or:
- *
- * http://www.unisys.com
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/smp.h>
-#include <linux/string.h>
-#include <linux/spinlock.h>
-#include <linux/errno.h>
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-#include <linux/init.h>
-#include <linux/acpi.h>
-#include <asm/io.h>
-#include <asm/nmi.h>
-#include <asm/smp.h>
-#include <asm/apicdef.h>
-#include "es7000.h"
-
-/*
- * ES7000 Globals
- */
-
-volatile unsigned long *psai = NULL;
-struct mip_reg         *mip_reg;  
-struct mip_reg         *host_reg;
-int                    mip_port;
-unsigned long          mip_addr, host_addr;
-
-/*
- * Parse the OEM Table
- */
-
-void __init
-parse_unisys_oem (char *oemptr, int oem_entries)
-{
-       int                     i;
-       int                     success = 0;
-       unsigned char           type, size;
-       unsigned long           val;
-       char                    *tp = NULL;  
-       struct psai             *psaip = NULL;
-       struct mip_reg_info     *mi;
-       struct mip_reg          *host, *mip;
-
-       tp = oemptr;
-
-       tp += 8;
-
-       for (i=0; i <= oem_entries; i++) {
-               type = *tp++;
-               size = *tp++;
-               tp -= 2;
-               switch (type) {
-               case MIP_REG:
-                       mi = (struct mip_reg_info *)tp;
-                       val = MIP_RD_LO(mi->host_reg);
-                       host_addr = val;
-                       host = (struct mip_reg *)val;
-                       host_reg = __va(host);
-                       val = MIP_RD_LO(mi->mip_reg);
-                       mip_addr = val;
-                       mip = (struct mip_reg *)val;
-                       mip_reg = __va(mip);
-                       Dprintk("es7000_mipcfg: host_reg = 0x%lx \n", 
-                               (unsigned long)host_reg);
-                       Dprintk("es7000_mipcfg: mip_reg = 0x%lx \n", 
-                               (unsigned long)mip_reg);
-                       success++;
-                       break;
-               case MIP_PSAI_REG:
-                       psaip = (struct psai *)tp;
-                       if (tp != NULL) {
-                               if (psaip->addr)
-                                       psai = __va(psaip->addr);
-                               else
-                                       psai = NULL;
-                               success++;
-                       }
-                       break;
-               default:
-                       break;
-               }
-               if (i == 6) break;
-               tp += size;
-       }
-
-       if (success < 2) {
-               printk("\nNo ES7000 found.\n");
-               es7000_plat = 0;
-       } else {
-               printk("\nEnabling ES7000 specific features...\n");
-               es7000_plat = 1;
-       }
-       return;
-}
-
-int __init 
-find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length) 
-{
-       struct acpi_table_rsdp          *rsdp = NULL;
-       unsigned long                   rsdp_phys = 0;
-       struct acpi_table_header        *header = NULL;
-       int                             i;
-       struct acpi_table_sdt           sdt;
-
-       rsdp_phys = acpi_find_rsdp();
-       rsdp = __va(rsdp_phys);
-       if (rsdp->rsdt_address) {
-               struct acpi_table_rsdt  *mapped_rsdt = NULL;
-               sdt.pa = rsdp->rsdt_address;
-
-               header = (struct acpi_table_header *)
-                       __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
-               if (!header)
-                       return -ENODEV;
-
-               sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
-               mapped_rsdt = (struct acpi_table_rsdt *)
-                       __acpi_map_table(sdt.pa, header->length);
-               if (!mapped_rsdt)
-                       return -ENODEV;
-
-               header = &mapped_rsdt->header;
-
-               for (i = 0; i < sdt.count; i++)
-                       sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
-       };
-       for (i = 0; i < sdt.count; i++) {
-
-               header = (struct acpi_table_header *)
-                       __acpi_map_table(sdt.entry[i].pa,
-                               sizeof(struct acpi_table_header));
-               if (!header)
-                       continue;
-               if (!strncmp((char *) &header->signature, "OEM1", 4)) {
-                       if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
-                               void *addr;
-                               struct oem_table *t;
-                               acpi_table_print(header, sdt.entry[i].pa);
-                               t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
-                               addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
-                               *length = header->length;
-                               *oem_addr = (unsigned long) addr;
-                               return 0;
-                       }
-               }
-       }
-       printk("ES7000: did not find Unisys ACPI OEM table!\n");
-       return -1;
-}
-
-static void
-es7000_spin(int n)
-{
-       int i = 0;
-
-       while (i++ < n) 
-               rep_nop();
-}
-
-static int __init
-es7000_mip_write(struct mip_reg *mip_reg)
-{
-       int                     status = 0;
-       int                     spin;
-
-       spin = MIP_SPIN;
-       while (((unsigned long long)host_reg->off_38 &
-               (unsigned long long)MIP_VALID) != 0) {
-                       if (--spin <= 0) {
-                               printk("es7000_mip_write: Timeout waiting for Host Valid Flag");
-                               return -1;
-                       }
-               es7000_spin(MIP_SPIN);
-       }
-
-       memcpy(host_reg, mip_reg, sizeof(struct mip_reg));
-       outb(1, mip_port);
-
-       spin = MIP_SPIN;
-
-       while (((unsigned long long)mip_reg->off_38 &
-               (unsigned long long)MIP_VALID) == 0) {
-               if (--spin <= 0) {
-                       printk("es7000_mip_write: Timeout waiting for MIP Valid Flag");
-                       return -1;
-               }
-               es7000_spin(MIP_SPIN);
-       }
-
-       status = ((unsigned long long)mip_reg->off_0 &
-               (unsigned long long)0xffff0000000000) >> 48;
-       mip_reg->off_38 = ((unsigned long long)mip_reg->off_38 &
-               (unsigned long long)~MIP_VALID);
-       return status;
-}
-
-int 
-es7000_start_cpu(int cpu, unsigned long eip)
-{
-       unsigned long vect = 0, psaival = 0;
-
-       if (psai == NULL)
-               return -1;
-
-       vect = ((unsigned long)__pa(eip)/0x1000) << 16;
-       psaival = (0x1000000 | vect | cpu);
-
-       while (*psai & 0x1000000)
-                ;
-
-       *psai = psaival;
-
-       return 0;
-
-}
-
-int 
-es7000_stop_cpu(int cpu)
-{
-       int startup;
-
-       if (psai == NULL)
-               return -1;
-
-       startup= (0x1000000 | cpu);
-
-       while ((*psai & 0xff00ffff) != startup)
-               ;
-
-       startup = (*psai & 0xff0000) >> 16;
-       *psai &= 0xffffff;
-
-       return 0;
-
-}
-
-void __init
-es7000_sw_apic()
-{
-       if (es7000_plat) {
-               int mip_status;
-               struct mip_reg es7000_mip_reg;
-
-               printk("ES7000: Enabling APIC mode.\n");
-               memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
-               es7000_mip_reg.off_0 = MIP_SW_APIC;
-               es7000_mip_reg.off_38 = (MIP_VALID);
-               while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
-                       printk("es7000_sw_apic: command failed, status = %x\n", 
-                               mip_status);
-               return;
-       }
-}
diff --git a/arch/i386/mach-es7000/setup.c b/arch/i386/mach-es7000/setup.c
deleted file mode 100644 (file)
index 4caed0e..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *     Machine specific setup for es7000
- */
-
-#include <linux/config.h>
-#include <linux/smp.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <asm/acpi.h>
-#include <asm/arch_hooks.h>
-
-/**
- * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
- *
- * Description:
- *     Perform any necessary interrupt initialisation prior to setting up
- *     the "ordinary" interrupt call gates.  For legacy reasons, the ISA
- *     interrupts should be initialised here if the machine emulates a PC
- *     in any way.
- **/void __init pre_intr_init_hook(void)
-{
-       init_ISA_irqs();
-}
-
-/*
- * IRQ2 is cascade interrupt to second interrupt controller
- */
-static struct irqaction irq2 = { no_action, 0, 0, "cascade", NULL, NULL};
-
-/**
- * intr_init_hook - post gate setup interrupt initialisation
- *
- * Description:
- *     Fill in any interrupts that may have been left out by the general
- *     init_IRQ() routine.  interrupts having to do with the machine rather
- *     than the devices on the I/O bus (like APIC interrupts in intel MP
- *     systems) are started here.
- **/
-void __init intr_init_hook(void)
-{
-#ifdef CONFIG_X86_LOCAL_APIC
-       apic_intr_init();
-#endif
-
-       if (!acpi_ioapic)
-               setup_irq(2, &irq2);
-}
-
-/**
- * pre_setup_arch_hook - hook called prior to any setup_arch() execution
- *
- * Description:
- *     generally used to activate any machine specific identification
- *     routines that may be needed before setup_arch() runs.  On VISWS
- *     this is used to get the board revision and type.
- **/
-void __init pre_setup_arch_hook(void)
-{
-}
-
-/**
- * trap_init_hook - initialise system specific traps
- *
- * Description:
- *     Called as the final act of trap_init().  Used in VISWS to initialise
- *     the various board specific APIC traps.
- **/
-void __init trap_init_hook(void)
-{
-}
-
-static struct irqaction irq0  = { timer_interrupt, SA_INTERRUPT, 0, "timer", NULL, NULL};
-
-/**
- * time_init_hook - do any specific initialisations for the system timer.
- *
- * Description:
- *     Must plug the system timer interrupt source at HZ into the IRQ listed
- *     in irq_vectors.h:TIMER_IRQ
- **/
-void __init time_init_hook(void)
-{
-       setup_irq(0, &irq0);
-}
-
-#ifdef CONFIG_MCA
-/**
- * mca_nmi_hook - hook into MCA specific NMI chain
- *
- * Description:
- *     The MCA (Microchannel Arcitecture) has an NMI chain for NMI sources
- *     along the MCA bus.  Use this to hook into that chain if you will need
- *     it.
- **/
-void __init mca_nmi_hook(void)
-{
-       /* If I recall correctly, there's a whole bunch of other things that
-        * we can do to check for NMI problems, but that's all I know about
-        * at the moment.
-        */
-
-       printk("NMI generated from unknown source!\n");
-}
-
-#endif
diff --git a/arch/i386/mach-es7000/topology.c b/arch/i386/mach-es7000/topology.c
deleted file mode 100644 (file)
index e96d891..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * arch/i386/mach-generic/topology.c - Populate driverfs with topology information
- *
- * Written by: Matthew Dobson, IBM Corporation
- * Original Code: Paul Dorwin, IBM Corporation, Patrick Mochel, OSDL
- *
- * Copyright (C) 2002, IBM Corp.
- *
- * All rights reserved.          
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Send feedback to <colpatch@us.ibm.com>
- */
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <asm/cpu.h>
-
-struct i386_cpu cpu_devices[NR_CPUS];
-
-#ifdef CONFIG_NUMA
-#include <linux/mmzone.h>
-#include <asm/node.h>
-
-struct i386_node node_devices[MAX_NUMNODES];
-
-static int __init topology_init(void)
-{
-       int i;
-
-       for (i = 0; i < num_online_nodes(); i++)
-               arch_register_node(i);
-       for (i = 0; i < NR_CPUS; i++)
-               if (cpu_possible(i)) arch_register_cpu(i);
-       return 0;
-}
-
-#else /* !CONFIG_NUMA */
-
-static int __init topology_init(void)
-{
-       int i;
-
-       for (i = 0; i < NR_CPUS; i++)
-               if (cpu_possible(i)) arch_register_cpu(i);
-       return 0;
-}
-
-#endif /* CONFIG_NUMA */
-
-subsys_initcall(topology_init);
index f599d85..a22da86 100644 (file)
 #include <linux/kernel.h>
 #include <linux/smp.h>
 #include <linux/init.h>
+#include <linux/dmi.h>
 #include <asm/mach-bigsmp/mach_apic.h>
 #include <asm/mach-bigsmp/mach_apicdef.h>
 #include <asm/mach-bigsmp/mach_ipi.h>
 #include <asm/mach-default/mach_mpparse.h>
 
-int dmi_bigsmp; /* can be set by dmi scanners */
+static int dmi_bigsmp; /* can be set by dmi scanners */
+
+static __init int hp_ht_bigsmp(struct dmi_system_id *d) 
+{ 
+#ifdef CONFIG_X86_GENERICARCH
+       printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
+       dmi_bigsmp = 1;
+#endif
+       return 0;
+} 
+
+
+static struct dmi_system_id __initdata bigsmp_dmi_table[] = {
+       { hp_ht_bigsmp, "HP ProLiant DL760 G2", {
+               DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
+               DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
+       }},
+
+       { hp_ht_bigsmp, "HP ProLiant DL740", {
+               DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
+               DMI_MATCH(DMI_BIOS_VERSION, "P47-"),
+        }},
+        { }     
+};
+
 
 static __init int probe_bigsmp(void)
 { 
+       dmi_check_system(bigsmp_dmi_table);
        return dmi_bigsmp; 
 } 
 
diff --git a/arch/i386/mach-pc9800/Makefile b/arch/i386/mach-pc9800/Makefile
deleted file mode 100644 (file)
index 7fff765..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-obj-y                          := setup.o topology.o std_resources.o
diff --git a/arch/i386/mach-pc9800/setup.c b/arch/i386/mach-pc9800/setup.c
deleted file mode 100644 (file)
index d32fd17..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- *     Machine specific setup for pc9800
- */
-
-#include <linux/config.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <linux/apm_bios.h>
-#include <asm/setup.h>
-#include <asm/arch_hooks.h>
-
-struct sys_desc_table_struct {
-       unsigned short length;
-       unsigned char table[0];
-};
-
-/**
- * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
- *
- * Description:
- *     Perform any necessary interrupt initialisation prior to setting up
- *     the "ordinary" interrupt call gates.  For legacy reasons, the ISA
- *     interrupts should be initialised here if the machine emulates a PC
- *     in any way.
- **/
-void __init pre_intr_init_hook(void)
-{
-       init_ISA_irqs();
-}
-
-/*
- * IRQ7 is cascade interrupt to second interrupt controller
- */
-static struct irqaction irq7 = { no_action, 0, 0, "cascade", NULL, NULL};
-
-/**
- * intr_init_hook - post gate setup interrupt initialisation
- *
- * Description:
- *     Fill in any interrupts that may have been left out by the general
- *     init_IRQ() routine.  interrupts having to do with the machine rather
- *     than the devices on the I/O bus (like APIC interrupts in intel MP
- *     systems) are started here.
- **/
-void __init intr_init_hook(void)
-{
-#ifdef CONFIG_X86_LOCAL_APIC
-       apic_intr_init();
-#endif
-
-       setup_irq(7, &irq7);
-}
-
-/**
- * pre_setup_arch_hook - hook called prior to any setup_arch() execution
- *
- * Description:
- *     generally used to activate any machine specific identification
- *     routines that may be needed before setup_arch() runs.  On VISWS
- *     this is used to get the board revision and type.
- **/
-void __init pre_setup_arch_hook(void)
-{
-       SYS_DESC_TABLE.length = 0;
-       MCA_bus = 0;
-       /* In PC-9800, APM BIOS version is written in BCD...?? */
-       APM_BIOS_INFO.version = (APM_BIOS_INFO.version & 0xff00)
-                               | ((APM_BIOS_INFO.version & 0x00f0) >> 4);
-}
-
-/**
- * trap_init_hook - initialise system specific traps
- *
- * Description:
- *     Called as the final act of trap_init().  Used in VISWS to initialise
- *     the various board specific APIC traps.
- **/
-void __init trap_init_hook(void)
-{
-}
-
-static struct irqaction irq0  = { timer_interrupt, SA_INTERRUPT, 0, "timer", NULL, NULL};
-
-/**
- * time_init_hook - do any specific initialisations for the system timer.
- *
- * Description:
- *     Must plug the system timer interrupt source at HZ into the IRQ listed
- *     in irq_vectors.h:TIMER_IRQ
- **/
-void __init time_init_hook(void)
-{
-       setup_irq(0, &irq0);
-}
-
-#ifdef CONFIG_MCA
-/**
- * mca_nmi_hook - hook into MCA specific NMI chain
- *
- * Description:
- *     The MCA (Microchannel Architecture) has an NMI chain for NMI sources
- *     along the MCA bus.  Use this to hook into that chain if you will need
- *     it.
- **/
-void __init mca_nmi_hook(void)
-{
-       /* If I recall correctly, there's a whole bunch of other things that
-        * we can do to check for NMI problems, but that's all I know about
-        * at the moment.
-        */
-
-       printk("NMI generated from unknown source!\n");
-}
-#endif
diff --git a/arch/i386/mach-pc9800/std_resources.c b/arch/i386/mach-pc9800/std_resources.c
deleted file mode 100644 (file)
index 06290bf..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- *  Machine specific resource allocation for PC-9800.
- *  Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-
-#include <linux/ioport.h>
-#include <asm/io.h>
-#include <asm/std_resources.h>
-
-static char str_pic1[] = "pic1";
-static char str_dma[] = "dma";
-static char str_pic2[] = "pic2";
-static char str_calender_clock[] = "calender clock";
-static char str_system[] = "system";
-static char str_nmi_control[] = "nmi control";
-static char str_kanji_rom[] = "kanji rom";
-static char str_keyboard[] = "keyboard";
-static char str_text_gdc[] = "text gdc";
-static char str_crtc[] = "crtc";
-static char str_timer[] = "timer";
-static char str_graphic_gdc[] = "graphic gdc";
-static char str_dma_ex_bank[] = "dma ex. bank";
-static char str_beep_freq[] = "beep freq.";
-static char str_mouse_pio[] = "mouse pio";
-struct resource standard_io_resources[] = {
-       { str_pic1, 0x00, 0x00, IORESOURCE_BUSY },
-       { str_dma, 0x01, 0x01, IORESOURCE_BUSY },
-       { str_pic1, 0x02, 0x02, IORESOURCE_BUSY },
-       { str_dma, 0x03, 0x03, IORESOURCE_BUSY },
-       { str_dma, 0x05, 0x05, IORESOURCE_BUSY },
-       { str_dma, 0x07, 0x07, IORESOURCE_BUSY },
-       { str_pic2, 0x08, 0x08, IORESOURCE_BUSY },
-       { str_dma, 0x09, 0x09, IORESOURCE_BUSY },
-       { str_pic2, 0x0a, 0x0a, IORESOURCE_BUSY },
-       { str_dma, 0x0b, 0x0b, IORESOURCE_BUSY },
-       { str_dma, 0x0d, 0x0d, IORESOURCE_BUSY },
-       { str_dma, 0x0f, 0x0f, IORESOURCE_BUSY },
-       { str_dma, 0x11, 0x11, IORESOURCE_BUSY },
-       { str_dma, 0x13, 0x13, IORESOURCE_BUSY },
-       { str_dma, 0x15, 0x15, IORESOURCE_BUSY },
-       { str_dma, 0x17, 0x17, IORESOURCE_BUSY },
-       { str_dma, 0x19, 0x19, IORESOURCE_BUSY },
-       { str_dma, 0x1b, 0x1b, IORESOURCE_BUSY },
-       { str_dma, 0x1d, 0x1d, IORESOURCE_BUSY },
-       { str_dma, 0x1f, 0x1f, IORESOURCE_BUSY },
-       { str_calender_clock, 0x20, 0x20, 0 },
-       { str_dma, 0x21, 0x21, IORESOURCE_BUSY },
-       { str_calender_clock, 0x22, 0x22, 0 },
-       { str_dma, 0x23, 0x23, IORESOURCE_BUSY },
-       { str_dma, 0x25, 0x25, IORESOURCE_BUSY },
-       { str_dma, 0x27, 0x27, IORESOURCE_BUSY },
-       { str_dma, 0x29, 0x29, IORESOURCE_BUSY },
-       { str_dma, 0x2b, 0x2b, IORESOURCE_BUSY },
-       { str_dma, 0x2d, 0x2d, IORESOURCE_BUSY },
-       { str_system, 0x31, 0x31, IORESOURCE_BUSY },
-       { str_system, 0x33, 0x33, IORESOURCE_BUSY },
-       { str_system, 0x35, 0x35, IORESOURCE_BUSY },
-       { str_system, 0x37, 0x37, IORESOURCE_BUSY },
-       { str_nmi_control, 0x50, 0x50, IORESOURCE_BUSY },
-       { str_nmi_control, 0x52, 0x52, IORESOURCE_BUSY },
-       { "time stamp", 0x5c, 0x5f, IORESOURCE_BUSY },
-       { str_kanji_rom, 0xa1, 0xa1, IORESOURCE_BUSY },
-       { str_kanji_rom, 0xa3, 0xa3, IORESOURCE_BUSY },
-       { str_kanji_rom, 0xa5, 0xa5, IORESOURCE_BUSY },
-       { str_kanji_rom, 0xa7, 0xa7, IORESOURCE_BUSY },
-       { str_kanji_rom, 0xa9, 0xa9, IORESOURCE_BUSY },
-       { str_keyboard, 0x41, 0x41, IORESOURCE_BUSY },
-       { str_keyboard, 0x43, 0x43, IORESOURCE_BUSY },
-       { str_text_gdc, 0x60, 0x60, IORESOURCE_BUSY },
-       { str_text_gdc, 0x62, 0x62, IORESOURCE_BUSY },
-       { str_text_gdc, 0x64, 0x64, IORESOURCE_BUSY },
-       { str_text_gdc, 0x66, 0x66, IORESOURCE_BUSY },
-       { str_text_gdc, 0x68, 0x68, IORESOURCE_BUSY },
-       { str_text_gdc, 0x6a, 0x6a, IORESOURCE_BUSY },
-       { str_text_gdc, 0x6c, 0x6c, IORESOURCE_BUSY },
-       { str_text_gdc, 0x6e, 0x6e, IORESOURCE_BUSY },
-       { str_crtc, 0x70, 0x70, IORESOURCE_BUSY },
-       { str_crtc, 0x72, 0x72, IORESOURCE_BUSY },
-       { str_crtc, 0x74, 0x74, IORESOURCE_BUSY },
-       { str_crtc, 0x74, 0x74, IORESOURCE_BUSY },
-       { str_crtc, 0x76, 0x76, IORESOURCE_BUSY },
-       { str_crtc, 0x78, 0x78, IORESOURCE_BUSY },
-       { str_crtc, 0x7a, 0x7a, IORESOURCE_BUSY },
-       { str_timer, 0x71, 0x71, IORESOURCE_BUSY },
-       { str_timer, 0x73, 0x73, IORESOURCE_BUSY },
-       { str_timer, 0x75, 0x75, IORESOURCE_BUSY },
-       { str_timer, 0x77, 0x77, IORESOURCE_BUSY },
-       { str_graphic_gdc, 0xa0, 0xa0, IORESOURCE_BUSY },
-       { str_graphic_gdc, 0xa2, 0xa2, IORESOURCE_BUSY },
-       { str_graphic_gdc, 0xa4, 0xa4, IORESOURCE_BUSY },
-       { str_graphic_gdc, 0xa6, 0xa6, IORESOURCE_BUSY },
-       { "cpu", 0xf0, 0xf7, IORESOURCE_BUSY },
-       { "fpu", 0xf8, 0xff, IORESOURCE_BUSY },
-       { str_dma_ex_bank, 0x0e05, 0x0e05, 0 },
-       { str_dma_ex_bank, 0x0e07, 0x0e07, 0 },
-       { str_dma_ex_bank, 0x0e09, 0x0e09, 0 },
-       { str_dma_ex_bank, 0x0e0b, 0x0e0b, 0 },
-       { str_beep_freq, 0x3fd9, 0x3fd9, IORESOURCE_BUSY },
-       { str_beep_freq, 0x3fdb, 0x3fdb, IORESOURCE_BUSY },
-       { str_beep_freq, 0x3fdd, 0x3fdd, IORESOURCE_BUSY },
-       { str_beep_freq, 0x3fdf, 0x3fdf, IORESOURCE_BUSY },
-       /* All PC-9800 have (exactly) one mouse interface.  */
-       { str_mouse_pio, 0x7fd9, 0x7fd9, 0 },
-       { str_mouse_pio, 0x7fdb, 0x7fdb, 0 },
-       { str_mouse_pio, 0x7fdd, 0x7fdd, 0 },
-       { str_mouse_pio, 0x7fdf, 0x7fdf, 0 },
-       { "mouse timer", 0xbfdb, 0xbfdb, 0 },
-       { "mouse irq", 0x98d7, 0x98d7, 0 },
-};
-
-#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
-
-static struct resource tvram_resource = { "Text VRAM/CG window", 0xa0000, 0xa4fff, IORESOURCE_BUSY };
-static struct resource gvram_brg_resource = { "Graphic VRAM (B/R/G)", 0xa8000, 0xbffff, IORESOURCE_BUSY };
-static struct resource gvram_e_resource = { "Graphic VRAM (E)", 0xe0000, 0xe7fff, IORESOURCE_BUSY };
-
-/* System ROM resources */
-#define MAXROMS 6
-static struct resource rom_resources[MAXROMS] = {
-       { "System ROM", 0xe8000, 0xfffff, IORESOURCE_BUSY }
-};
-
-void __init probe_roms(void)
-{
-       int i;
-       __u8 *xrom_id;
-       int roms = 1;
-
-       request_resource(&iomem_resource, rom_resources+0);
-
-       xrom_id = (__u8 *) isa_bus_to_virt(PC9800SCA_XROM_ID + 0x10);
-
-       for (i = 0; i < 16; i++) {
-               if (xrom_id[i] & 0x80) {
-                       int j;
-
-                       for (j = i + 1; j < 16 && (xrom_id[j] & 0x80); j++)
-                               ;
-                       rom_resources[roms].start = 0x0d0000 + i * 0x001000;
-                       rom_resources[roms].end = 0x0d0000 + j * 0x001000 - 1;
-                       rom_resources[roms].name = "Extension ROM";
-                       rom_resources[roms].flags = IORESOURCE_BUSY;
-
-                       request_resource(&iomem_resource,
-                                         rom_resources + roms);
-                       if (++roms >= MAXROMS)
-                               return;
-               }
-       }
-}
-
-void __init request_graphics_resource(void)
-{
-       int i;
-
-       if (PC9800_HIGHRESO_P()) {
-               tvram_resource.start = 0xe0000;
-               tvram_resource.end   = 0xe4fff;
-               gvram_brg_resource.name  = "Graphic VRAM";
-               gvram_brg_resource.start = 0xc0000;
-               gvram_brg_resource.end   = 0xdffff;
-       }
-
-       request_resource(&iomem_resource, &tvram_resource);
-       request_resource(&iomem_resource, &gvram_brg_resource);
-       if (!PC9800_HIGHRESO_P())
-               request_resource(&iomem_resource, &gvram_e_resource);
-
-       if (PC9800_HIGHRESO_P() || PC9800_9821_P()) {
-               static char graphics[] = "graphics";
-               static struct resource graphics_resources[] = {
-                       { graphics, 0x9a0, 0x9a0, 0 },
-                       { graphics, 0x9a2, 0x9a2, 0 },
-                       { graphics, 0x9a4, 0x9a4, 0 },
-                       { graphics, 0x9a6, 0x9a6, 0 },
-                       { graphics, 0x9a8, 0x9a8, 0 },
-                       { graphics, 0x9aa, 0x9aa, 0 },
-                       { graphics, 0x9ac, 0x9ac, 0 },
-                       { graphics, 0x9ae, 0x9ae, 0 },
-               };
-
-#define GRAPHICS_RESOURCES (sizeof(graphics_resources)/sizeof(struct resource))
-
-               for (i = 0; i < GRAPHICS_RESOURCES; i++)
-                       request_resource(&ioport_resource, graphics_resources + i);
-       }
-}
-
-void __init request_standard_io_resources(void)
-{
-       int i;
-
-       for (i = 0; i < STANDARD_IO_RESOURCES; i++)
-               request_resource(&ioport_resource, standard_io_resources+i);
-}
diff --git a/arch/i386/mach-pc9800/topology.c b/arch/i386/mach-pc9800/topology.c
deleted file mode 100644 (file)
index de877f6..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * arch/i386/mach-pc9800/topology.c - Populate driverfs with topology information
- *
- * Written by: Matthew Dobson, IBM Corporation
- * Original Code: Paul Dorwin, IBM Corporation, Patrick Mochel, OSDL
- *
- * Copyright (C) 2002, IBM Corp.
- *
- * All rights reserved.          
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Modify for PC-9800 by Osamu Tomita <tomita@cinet.co.jp>
- *
- */
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <asm/cpu.h>
-
-struct i386_cpu cpu_devices[NR_CPUS];
-
-static int __init topology_init(void)
-{
-       int i;
-
-       for (i = 0; i < NR_CPUS; i++)
-               if (cpu_possible(i)) arch_register_cpu(i);
-       return 0;
-}
-
-subsys_initcall(topology_init);
index 2ddfe12..7ff3286 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <asm/atomic_kmap.h>
 
 /* This sets the pointer FPU_info to point to the argument part
    of the stack frame of math_emulate() */
@@ -22,7 +23,7 @@
 
 /* s is always from a cpu register, and the cpu does bounds checking
  * during register load --> no further bounds checks needed */
-#define LDT_DESCRIPTOR(s)      (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3])
+#define LDT_DESCRIPTOR(s)      (((struct desc_struct *)__kmap_atomic_vaddr(KM_LDT_PAGE0))[(s) >> 3])
 #define SEG_D_SIZE(x)          ((x).b & (3 << 21))
 #define SEG_G_BIT(x)           ((x).b & (1 << 23))
 #define SEG_GRANULARITY(x)     (((x).b & (1 << 23)) ? 4096 : 1)
index 87dd63c..fc32725 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the linux i386-specific parts of the memory manager.
 #
 
-obj-y  := init.o pgtable.o fault.o ioremap.o extable.o pageattr.o 
+obj-y  := init.o pgtable.o fault.o ioremap.o extable.o pageattr.o mmap.o
 
 obj-$(CONFIG_DISCONTIGMEM)     += discontig.o
 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
index debed47..60206e1 100644 (file)
@@ -26,6 +26,7 @@
 #include <asm/uaccess.h>
 #include <asm/hardirq.h>
 #include <asm/desc.h>
+#include <asm/tlbflush.h>
 
 extern void die(const char *,struct pt_regs *,long);
 
@@ -103,8 +104,17 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
        if (seg & (1<<2)) {
                /* Must lock the LDT while reading it. */
                down(&current->mm->context.sem);
+#if 1
+               /* horrible hack for 4/4 disabled kernels.
+                  I'm not quite sure what the TLB flush is good for,
+                  it's mindlessly copied from the read_ldt code */
+               __flush_tlb_global();
+               desc = kmap(current->mm->context.ldt_pages[(seg&~7)/PAGE_SIZE]);
+               desc = (void *)desc + ((seg & ~7) % PAGE_SIZE);
+#else
                desc = current->mm->context.ldt;
                desc = (void *)desc + (seg & ~7);
+#endif
        } else {
                /* Must disable preemption while reading the GDT. */
                desc = (u32 *)&cpu_gdt_table[get_cpu()];
@@ -117,6 +127,9 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
                 (desc[1] & 0xff000000);
 
        if (seg & (1<<2)) { 
+#if 1
+               kunmap((void *)((unsigned long)desc & PAGE_MASK));
+#endif
                up(&current->mm->context.sem);
        } else
                put_cpu();
@@ -247,6 +260,17 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
         * (error_code & 4) == 0, and that the fault was not a
         * protection error (error_code & 1) == 0.
         */
+#ifdef CONFIG_X86_4G
+       /*
+        * On 4/4 all kernels faults are either bugs, vmalloc or prefetch
+        */
+       /* If it's vm86 fall through */
+       if (unlikely(!(regs->eflags & VM_MASK) && ((regs->xcs & 3) == 0))) {
+               if (error_code & 3)
+                       goto bad_area_nosemaphore;
+               goto vmalloc_fault;
+       }
+#else
        if (unlikely(address >= TASK_SIZE)) { 
                if (!(error_code & 5))
                        goto vmalloc_fault;
@@ -256,6 +280,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
                 */
                goto bad_area_nosemaphore;
        } 
+#endif
 
        mm = tsk->mm;
 
index 5817532..83972da 100644 (file)
@@ -41,12 +41,47 @@ void *kmap_atomic(struct page *page, enum km_type type)
        if (!pte_none(*(kmap_pte-idx)))
                BUG();
 #endif
-       set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
+       /*
+        * If the page is not a normal RAM page, then map it
+        * uncached to be on the safe side - it could be device
+        * memory that must not be prefetched:
+        */
+       if (PageReserved(page))
+               set_pte(kmap_pte-idx, mk_pte(page, kmap_prot_nocache));
+       else
+               set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
        __flush_tlb_one(vaddr);
 
        return (void*) vaddr;
 }
 
+/*
+ * page frame number based kmaps - useful for PCI mappings.
+ * NOTE: we map the page with the dont-cache flag.
+ */
+void *kmap_atomic_nocache_pfn(unsigned long pfn, enum km_type type)
+{
+       enum fixed_addresses idx;
+       unsigned long vaddr;
+
+       /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
+       inc_preempt_count();
+       if (pfn < highstart_pfn)
+               return pfn_to_kaddr(pfn);
+
+       idx = type + KM_TYPE_NR*smp_processor_id();
+       vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+#ifdef CONFIG_DEBUG_HIGHMEM
+       if (!pte_none(*(kmap_pte-idx)))
+               BUG();
+#endif
+       set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot_nocache));
+       __flush_tlb_one(vaddr);
+
+       return (void*) vaddr;
+}
+
+
 void kunmap_atomic(void *kvaddr, enum km_type type)
 {
 #ifdef CONFIG_DEBUG_HIGHMEM
index 7e4b121..a0eab67 100644 (file)
@@ -42,7 +42,8 @@ static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma, struc
 {
        pte_t entry;
 
-       mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
        if (write_access) {
                entry =
                    pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
@@ -82,7 +83,8 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                ptepage = pte_page(entry);
                get_page(ptepage);
                set_pte(dst_pte, entry);
-               dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
                addr += HPAGE_SIZE;
        }
        return 0;
@@ -218,7 +220,8 @@ void unmap_hugepage_range(struct vm_area_struct *vma,
                page = pte_page(pte);
                put_page(page);
        }
-       mm->rss -= (end - start) >> PAGE_SHIFT;
+       // mm->rss -= (end - start) >> PAGE_SHIFT;
+       vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
        flush_tlb_range(vma, start, end);
 }
 
index a8bd054..a008d43 100644 (file)
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
+#include <asm/desc.h>
 
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 unsigned long highstart_pfn, highend_pfn;
 
 static int do_test_wp_bit(void);
 
-/*
- * Creates a middle page table and puts a pointer to it in the
- * given global directory entry. This only returns the gd entry
- * in non-PAE compilation mode, since the middle layer is folded.
- */
-static pmd_t * __init one_md_table_init(pgd_t *pgd)
-{
-       pmd_t *pmd_table;
-               
-#ifdef CONFIG_X86_PAE
-       pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
-       set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
-       if (pmd_table != pmd_offset(pgd, 0)) 
-               BUG();
-#else
-       pmd_table = pmd_offset(pgd, 0);
-#endif
-
-       return pmd_table;
-}
-
-/*
- * Create a page table and place a pointer to it in a middle page
- * directory entry.
- */
-static pte_t * __init one_page_table_init(pmd_t *pmd)
-{
-       if (pmd_none(*pmd)) {
-               pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
-               set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
-               if (page_table != pte_offset_kernel(pmd, 0))
-                       BUG();  
-
-               return page_table;
-       }
-       
-       return pte_offset_kernel(pmd, 0);
-}
-
-/*
- * This function initializes a certain range of kernel virtual memory 
- * with new bootmem page tables, everywhere page tables are missing in
- * the given range.
- */
-
-/*
- * NOTE: The pagetables are allocated contiguous on the physical space 
- * so we can cache the place of the first one and move around without 
- * checking the pgd every time.
- */
-static void __init page_table_range_init (unsigned long start, unsigned long end, pgd_t *pgd_base)
-{
-       pgd_t *pgd;
-       pmd_t *pmd;
-       int pgd_idx, pmd_idx;
-       unsigned long vaddr;
-
-       vaddr = start;
-       pgd_idx = pgd_index(vaddr);
-       pmd_idx = pmd_index(vaddr);
-       pgd = pgd_base + pgd_idx;
-
-       for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
-               if (pgd_none(*pgd)) 
-                       one_md_table_init(pgd);
-
-               pmd = pmd_offset(pgd, vaddr);
-               for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end); pmd++, pmd_idx++) {
-                       if (pmd_none(*pmd)) 
-                               one_page_table_init(pmd);
-
-                       vaddr += PMD_SIZE;
-               }
-               pmd_idx = 0;
-       }
-}
-
-static inline int is_kernel_text(unsigned long addr)
-{
-       if (addr >= (unsigned long)_stext && addr <= (unsigned long)__init_end)
-               return 1;
-       return 0;
-}
-
-/*
- * This maps the physical memory to kernel virtual address space, a total 
- * of max_low_pfn pages, by creating page tables starting from address 
- * PAGE_OFFSET.
- */
-static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
-{
-       unsigned long pfn;
-       pgd_t *pgd;
-       pmd_t *pmd;
-       pte_t *pte;
-       int pgd_idx, pmd_idx, pte_ofs;
-
-       pgd_idx = pgd_index(PAGE_OFFSET);
-       pgd = pgd_base + pgd_idx;
-       pfn = 0;
-
-       for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
-               pmd = one_md_table_init(pgd);
-               if (pfn >= max_low_pfn)
-                       continue;
-               for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn; pmd++, pmd_idx++) {
-                       unsigned int address = pfn * PAGE_SIZE + PAGE_OFFSET;
-
-                       /* Map with big pages if possible, otherwise create normal page tables. */
-                       if (cpu_has_pse) {
-                               unsigned int address2 = (pfn + PTRS_PER_PTE - 1) * PAGE_SIZE + PAGE_OFFSET + PAGE_SIZE-1;
-
-                               if (is_kernel_text(address) || is_kernel_text(address2))
-                                       set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE_EXEC));
-                               else
-                                       set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE));
-                               pfn += PTRS_PER_PTE;
-                       } else {
-                               pte = one_page_table_init(pmd);
-
-                               for (pte_ofs = 0; pte_ofs < PTRS_PER_PTE && pfn < max_low_pfn; pte++, pfn++, pte_ofs++) {
-                                               if (is_kernel_text(address))
-                                                       set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
-                                               else
-                                                       set_pte(pte, pfn_pte(pfn, PAGE_KERNEL));
-                               }
-                       }
-               }
-       }
-}
-
 static inline int page_kills_ppro(unsigned long pagenr)
 {
        if (pagenr >= 0x70000 && pagenr <= 0x7003F)
@@ -223,11 +93,35 @@ static inline int page_is_ram(unsigned long pagenr)
        return 0;
 }
 
-#ifdef CONFIG_HIGHMEM
+/* To enable modules to check if a page is in RAM */
+int pfn_is_ram(unsigned long pfn)
+{
+       return (page_is_ram(pfn));
+}
+
+
+/*
+ * devmem_is_allowed() checks to see if /dev/mem access to a certain address is
+ * valid. The argument is a physical page number.
+ *
+ *
+ * On x86, access has to be given to the first megabyte of ram because that area
+ * contains bios code and data regions used by X and dosemu and similar apps.
+ * Access has to be given to non-kernel-ram areas as well, these contain the PCI
+ * mmio resources as well as potential bios/acpi data regions.
+ */
+int devmem_is_allowed(unsigned long pagenr)
+{
+       if (pagenr <= 256)
+               return 1;
+       if (!page_is_ram(pagenr))
+               return 1;
+       return 0;
+}
+
+
 pte_t *kmap_pte;
-pgprot_t kmap_prot;
 
-EXPORT_SYMBOL(kmap_prot);
 EXPORT_SYMBOL(kmap_pte);
 
 #define kmap_get_fixmap_pte(vaddr)                                     \
@@ -235,29 +129,7 @@ EXPORT_SYMBOL(kmap_pte);
 
 void __init kmap_init(void)
 {
-       unsigned long kmap_vstart;
-
-       /* cache the first kmap pte */
-       kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
-       kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
-
-       kmap_prot = PAGE_KERNEL;
-}
-
-void __init permanent_kmaps_init(pgd_t *pgd_base)
-{
-       pgd_t *pgd;
-       pmd_t *pmd;
-       pte_t *pte;
-       unsigned long vaddr;
-
-       vaddr = PKMAP_BASE;
-       page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
-
-       pgd = swapper_pg_dir + pgd_index(vaddr);
-       pmd = pmd_offset(pgd, vaddr);
-       pte = pte_offset_kernel(pmd, vaddr);
-       pkmap_page_table = pte; 
+       kmap_pte = kmap_get_fixmap_pte(__fix_to_virt(FIX_KMAP_BEGIN));
 }
 
 void __init one_highpage_init(struct page *page, int pfn, int bad_ppro)
@@ -272,6 +144,10 @@ void __init one_highpage_init(struct page *page, int pfn, int bad_ppro)
                SetPageReserved(page);
 }
 
+EXPORT_SYMBOL_GPL(page_is_ram);
+
+#ifdef CONFIG_HIGHMEM
+
 #ifndef CONFIG_DISCONTIGMEM
 void __init set_highmem_pages_init(int bad_ppro) 
 {
@@ -283,12 +159,9 @@ void __init set_highmem_pages_init(int bad_ppro)
 #else
 extern void set_highmem_pages_init(int);
 #endif /* !CONFIG_DISCONTIGMEM */
-
 #else
-#define kmap_init() do { } while (0)
-#define permanent_kmaps_init(pgd_base) do { } while (0)
-#define set_highmem_pages_init(bad_ppro) do { } while (0)
-#endif /* CONFIG_HIGHMEM */
+# define set_highmem_pages_init(bad_ppro) do { } while (0)
+#endif
 
 unsigned long long __PAGE_KERNEL = _PAGE_KERNEL;
 unsigned long long __PAGE_KERNEL_EXEC = _PAGE_KERNEL_EXEC;
@@ -299,31 +172,125 @@ unsigned long long __PAGE_KERNEL_EXEC = _PAGE_KERNEL_EXEC;
 extern void __init remap_numa_kva(void);
 #endif
 
-static void __init pagetable_init (void)
+static __init void prepare_pagetables(pgd_t *pgd_base, unsigned long address)
+{
+       pgd_t *pgd;
+       pmd_t *pmd;
+       pte_t *pte;
+
+       pgd = pgd_base + pgd_index(address);
+       pmd = pmd_offset(pgd, address);
+       if (!pmd_present(*pmd)) {
+               pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
+               set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)));
+       }
+}
+
+static void __init fixrange_init (unsigned long start, unsigned long end, pgd_t *pgd_base)
 {
        unsigned long vaddr;
-       pgd_t *pgd_base = swapper_pg_dir;
 
+       for (vaddr = start; vaddr != end; vaddr += PAGE_SIZE)
+               prepare_pagetables(pgd_base, vaddr);
+}
+
+void setup_identity_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end)
+{
+       unsigned long vaddr;
+       pgd_t *pgd;
+       int i, j, k;
+       pmd_t *pmd;
+       pte_t *pte, *pte_base;
+
+       pgd = pgd_base;
+
+       for (i = 0; i < PTRS_PER_PGD; pgd++, i++) {
+               vaddr = i*PGDIR_SIZE;
+               if (end && (vaddr >= end))
+                       break;
+               pmd = pmd_offset(pgd, 0);
+               for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
+                       vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
+                       if (end && (vaddr >= end))
+                               break;
+                       if (vaddr < start)
+                               continue;
+                       if (cpu_has_pse) {
+                               unsigned long __pe;
+
+                               set_in_cr4(X86_CR4_PSE);
+                               boot_cpu_data.wp_works_ok = 1;
+                               __pe = _KERNPG_TABLE + _PAGE_PSE + vaddr - start;
+                               /* Make it "global" too if supported */
+                               if (cpu_has_pge) {
+                                       set_in_cr4(X86_CR4_PGE);
+#if !defined(CONFIG_X86_SWITCH_PAGETABLES)
+                                       __pe += _PAGE_GLOBAL;
+                                       __PAGE_KERNEL |= _PAGE_GLOBAL;
+#endif
+                               }
+                               set_pmd(pmd, __pmd(__pe));
+                               continue;
+                       }
+                       if (!pmd_present(*pmd))
+                               pte_base = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
+                       else
+                               pte_base = pte_offset_kernel(pmd, 0);
+                       pte = pte_base;
+                       for (k = 0; k < PTRS_PER_PTE; pte++, k++) {
+                               vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE;
+                               if (end && (vaddr >= end))
+                                       break;
+                               if (vaddr < start)
+                                       continue;
+                               *pte = mk_pte_phys(vaddr-start, PAGE_KERNEL);
+                       }
+                       set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base)));
+               }
+       }
+}
+
+static void __init pagetable_init (void)
+{
+       unsigned long vaddr, end;
+       pgd_t *pgd_base;
 #ifdef CONFIG_X86_PAE
        int i;
-       /* Init entries of the first-level page table to the zero page */
-       for (i = 0; i < PTRS_PER_PGD; i++)
-               set_pgd(pgd_base + i, __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
 #endif
 
-       /* Enable PSE if available */
-       if (cpu_has_pse) {
-               set_in_cr4(X86_CR4_PSE);
-       }
+       /*
+        * This can be zero as well - no problem, in that case we exit
+        * the loops anyway due to the PTRS_PER_* conditions.
+        */
+       end = (unsigned long)__va(max_low_pfn*PAGE_SIZE);
 
-       /* Enable PGE if available */
-       if (cpu_has_pge) {
-               set_in_cr4(X86_CR4_PGE);
-               __PAGE_KERNEL |= _PAGE_GLOBAL;
-               __PAGE_KERNEL_EXEC |= _PAGE_GLOBAL;
+       pgd_base = swapper_pg_dir;
+#ifdef CONFIG_X86_PAE
+       /*
+        * It causes too many problems if there's no proper pmd set up
+        * for all 4 entries of the PGD - so we allocate all of them.
+        * PAE systems will not miss this extra 4-8K anyway ...
+        */
+       for (i = 0; i < PTRS_PER_PGD; i++) {
+               pmd_t *pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
+               set_pgd(pgd_base + i, __pgd(__pa(pmd) + 0x1));
        }
+#endif
+       /*
+        * Set up lowmem-sized identity mappings at PAGE_OFFSET:
+        */
+       setup_identity_mappings(pgd_base, PAGE_OFFSET, end);
 
-       kernel_physical_mapping_init(pgd_base);
+       /*
+        * Add flat-mode identity-mappings - SMP needs it when
+        * starting up on an AP from real-mode. (In the non-PAE
+        * case we already have these mappings through head.S.)
+        * All user-space mappings are explicitly cleared after
+        * SMP startup.
+        */
+#if defined(CONFIG_SMP) && defined(CONFIG_X86_PAE)
+       setup_identity_mappings(pgd_base, 0, 16*1024*1024);
+#endif
        remap_numa_kva();
 
        /*
@@ -331,59 +298,64 @@ static void __init pagetable_init (void)
         * created - mappings will be set by set_fixmap():
         */
        vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
-       page_table_range_init(vaddr, 0, pgd_base);
+       fixrange_init(vaddr, 0, pgd_base);
 
-       permanent_kmaps_init(pgd_base);
+#ifdef CONFIG_HIGHMEM
+       {
+               pgd_t *pgd;
+               pmd_t *pmd;
+               pte_t *pte;
 
-#ifdef CONFIG_X86_PAE
-       /*
-        * Add low memory identity-mappings - SMP needs it when
-        * starting up on an AP from real-mode. In the non-PAE
-        * case we already have these mappings through head.S.
-        * All user-space mappings are explicitly cleared after
-        * SMP startup.
-        */
-       pgd_base[0] = pgd_base[USER_PTRS_PER_PGD];
+               /*
+                * Permanent kmaps:
+                */
+               vaddr = PKMAP_BASE;
+               fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
+
+               pgd = swapper_pg_dir + pgd_index(vaddr);
+               pmd = pmd_offset(pgd, vaddr);
+               pte = pte_offset_kernel(pmd, vaddr);
+               pkmap_page_table = pte;
+       }
 #endif
 }
 
-#if defined(CONFIG_PM_DISK) || defined(CONFIG_SOFTWARE_SUSPEND)
 /*
- * Swap suspend & friends need this for resume because things like the intel-agp
- * driver might have split up a kernel 4MB mapping.
+ * Clear kernel pagetables in a PMD_SIZE-aligned range.
  */
-char __nosavedata swsusp_pg_dir[PAGE_SIZE]
-       __attribute__ ((aligned (PAGE_SIZE)));
-
-static inline void save_pg_dir(void)
-{
-       memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE);
-}
-#else
-static inline void save_pg_dir(void)
+static void clear_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end)
 {
+       unsigned long vaddr;
+       pgd_t *pgd;
+       pmd_t *pmd;
+       int i, j;
+
+       pgd = pgd_base;
+
+       for (i = 0; i < PTRS_PER_PGD; pgd++, i++) {
+               vaddr = i*PGDIR_SIZE;
+               if (end && (vaddr >= end))
+                       break;
+               pmd = pmd_offset(pgd, 0);
+               for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
+                       vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
+                       if (end && (vaddr >= end))
+                               break;
+                       if (vaddr < start)
+                               continue;
+                       pmd_clear(pmd);
+               }
+       }
+       flush_tlb_all();
 }
-#endif
 
-void zap_low_mappings (void)
+void zap_low_mappings(void)
 {
-       int i;
-
-       save_pg_dir();
-
+       printk("zapping low mappings.\n");
        /*
         * Zap initial low-memory mappings.
-        *
-        * Note that "pgd_clear()" doesn't do it for
-        * us, because pgd_clear() is a no-op on i386.
         */
-       for (i = 0; i < USER_PTRS_PER_PGD; i++)
-#ifdef CONFIG_X86_PAE
-               set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
-#else
-               set_pgd(swapper_pg_dir+i, __pgd(0));
-#endif
-       flush_tlb_all();
+       clear_mappings(swapper_pg_dir, 0, 16*1024*1024);
 }
 
 #ifndef CONFIG_DISCONTIGMEM
@@ -420,7 +392,7 @@ u64 __supported_pte_mask = ~_PAGE_NX;
  * Control non executable mappings.
  *
  * on      Enable
- * off     Disable
+ * off     Disable (disables exec-shield too)
  */
 static int __init noexec_setup(char *str)
 {
@@ -430,6 +402,7 @@ static int __init noexec_setup(char *str)
        } else if (!strncmp(str,"off",3)) {
                disable_nx = 1;
                __supported_pte_mask &= ~_PAGE_NX;
+               exec_shield = 0;
        }
        return 1;
 }
@@ -454,7 +427,6 @@ static void __init set_nx(void)
                }
        }
 }
-
 /*
  * Enables/disables executability of a given kernel page and
  * returns the previous setting.
@@ -512,7 +484,15 @@ void __init paging_init(void)
                set_in_cr4(X86_CR4_PAE);
 #endif
        __flush_tlb_all();
-
+       /*
+        * Subtle. SMP is doing it's boot stuff late (because it has to
+        * fork idle threads) - but it also needs low mappings for the
+        * protected-mode entry to work. We zap these entries only after
+        * the WP-bit has been tested.
+        */
+#ifndef CONFIG_SMP
+       zap_low_mappings();
+#endif
        kmap_init();
        zone_sizes_init();
 }
@@ -631,22 +611,18 @@ void __init mem_init(void)
        if (boot_cpu_data.wp_works_ok < 0)
                test_wp_bit();
 
-       /*
-        * Subtle. SMP is doing it's boot stuff late (because it has to
-        * fork idle threads) - but it also needs low mappings for the
-        * protected-mode entry to work. We zap these entries only after
-        * the WP-bit has been tested.
-        */
-#ifndef CONFIG_SMP
-       zap_low_mappings();
-#endif
+       entry_trampoline_setup();
+       default_ldt_page = virt_to_page(default_ldt);
+       load_LDT(&init_mm.context);
 }
 
-kmem_cache_t *pgd_cache;
-kmem_cache_t *pmd_cache;
+kmem_cache_t *pgd_cache, *pmd_cache, *kpmd_cache;
 
 void __init pgtable_cache_init(void)
 {
+       void (*ctor)(void *, kmem_cache_t *, unsigned long);
+       void (*dtor)(void *, kmem_cache_t *, unsigned long);
+
        if (PTRS_PER_PMD > 1) {
                pmd_cache = kmem_cache_create("pmd",
                                        PTRS_PER_PMD*sizeof(pmd_t),
@@ -656,13 +632,36 @@ void __init pgtable_cache_init(void)
                                        NULL);
                if (!pmd_cache)
                        panic("pgtable_cache_init(): cannot create pmd cache");
+
+               if (TASK_SIZE > PAGE_OFFSET) {
+                       kpmd_cache = kmem_cache_create("kpmd",
+                                       PTRS_PER_PMD*sizeof(pmd_t),
+                                       PTRS_PER_PMD*sizeof(pmd_t),
+                                       0,
+                                       kpmd_ctor,
+                                       NULL);
+                       if (!kpmd_cache)
+                               panic("pgtable_cache_init(): "
+                                               "cannot create kpmd cache");
+               }
        }
+
+       if (PTRS_PER_PMD == 1 || TASK_SIZE <= PAGE_OFFSET)
+               ctor = pgd_ctor;
+       else
+               ctor = NULL;
+
+       if (PTRS_PER_PMD == 1 && TASK_SIZE <= PAGE_OFFSET)
+               dtor = pgd_dtor;
+       else
+               dtor = NULL;
+
        pgd_cache = kmem_cache_create("pgd",
                                PTRS_PER_PGD*sizeof(pgd_t),
                                PTRS_PER_PGD*sizeof(pgd_t),
                                0,
-                               pgd_ctor,
-                               PTRS_PER_PMD == 1 ? pgd_dtor : NULL);
+                               ctor,
+                               dtor);
        if (!pgd_cache)
                panic("pgtable_cache_init(): Cannot create pgd cache");
 }
@@ -671,7 +670,7 @@ void __init pgtable_cache_init(void)
  * This function cannot be __init, since exceptions don't work in that
  * section.  Put this after the callers, so that it cannot be inlined.
  */
-static int do_test_wp_bit(void)
+static int noinline do_test_wp_bit(void)
 {
        char tmp_reg;
        int flag;
diff --git a/arch/i386/mm/mmap.c b/arch/i386/mm/mmap.c
deleted file mode 100644 (file)
index f88a6c8..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *  linux/arch/i386/mm/mmap.c
- *
- *  flexible mmap layout support
- *
- * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *
- * Started by Ingo Molnar <mingo@elte.hu>
- */
-
-#include <linux/personality.h>
-#include <linux/mm.h>
-
-/*
- * Top of mmap area (just below the process stack).
- *
- * Leave an at least ~128 MB hole.
- */
-#define MIN_GAP (128*1024*1024)
-#define MAX_GAP (TASK_SIZE/6*5)
-
-static inline unsigned long mmap_base(struct mm_struct *mm)
-{
-       unsigned long gap = current->rlim[RLIMIT_STACK].rlim_cur;
-
-       if (gap < MIN_GAP)
-               gap = MIN_GAP;
-       else if (gap > MAX_GAP)
-               gap = MAX_GAP;
-
-       return TASK_SIZE - (gap & PAGE_MASK);
-}
-
-/*
- * This function, called very early during the creation of a new
- * process VM image, sets up which VM layout function to use:
- */
-void arch_pick_mmap_layout(struct mm_struct *mm)
-{
-       /*
-        * Fall back to the standard layout if the personality
-        * bit is set, or if the expected stack growth is unlimited:
-        */
-       if (sysctl_legacy_va_layout || (current->personality & ADDR_COMPAT_LAYOUT) ||
-                       current->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY) {
-               mm->mmap_base = TASK_UNMAPPED_BASE;
-               mm->get_unmapped_area = arch_get_unmapped_area;
-               mm->unmap_area = arch_unmap_area;
-       } else {
-               mm->mmap_base = mmap_base(mm);
-               mm->get_unmapped_area = arch_get_unmapped_area_topdown;
-               mm->get_unmapped_exec_area = arch_get_unmapped_exec_area;
-               mm->unmap_area = arch_unmap_area_topdown;
-       }
-}
index 8eb95be..f7d47e0 100644 (file)
@@ -67,22 +67,21 @@ static void flush_kernel_map(void *dummy)
 
 static void set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte) 
 { 
-       struct page *page;
-       unsigned long flags;
-
        set_pte_atomic(kpte, pte);      /* change init_mm */
-       if (PTRS_PER_PMD > 1)
-               return;
-
-       spin_lock_irqsave(&pgd_lock, flags);
-       for (page = pgd_list; page; page = (struct page *)page->index) {
-               pgd_t *pgd;
-               pmd_t *pmd;
-               pgd = (pgd_t *)page_address(page) + pgd_index(address);
-               pmd = pmd_offset(pgd, address);
-               set_pte_atomic((pte_t *)pmd, pte);
+#ifndef CONFIG_X86_PAE
+       {
+               struct list_head *l;
+               if (TASK_SIZE > PAGE_OFFSET)
+                       return;
+               spin_lock(&mmlist_lock);
+               list_for_each(l, &init_mm.mmlist) {
+                       struct mm_struct *mm = list_entry(l, struct mm_struct, mmlist);
+                       pmd_t *pmd = pmd_offset(pgd_offset(mm, address), address);
+                       set_pte_atomic((pte_t *)pmd, pte);
+               }
+               spin_unlock(&mmlist_lock);
        }
-       spin_unlock_irqrestore(&pgd_lock, flags);
+#endif
 }
 
 /* 
index 137d18d..58066fb 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/spinlock.h>
+#include <linux/module.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -21,6 +22,7 @@
 #include <asm/e820.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
+#include <asm/atomic_kmap.h>
 
 void show_mem(void)
 {
@@ -55,6 +57,8 @@ void show_mem(void)
        printk("%d pages swap cached\n",cached);
 }
 
+EXPORT_SYMBOL_GPL(show_mem);
+
 /*
  * Associate a virtual page frame with a given physical page frame 
  * and protection flags for that frame.
@@ -157,11 +161,20 @@ void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags)
        memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
 }
 
+void kpmd_ctor(void *__pmd, kmem_cache_t *cache, unsigned long flags)
+{
+       pmd_t *kpmd, *pmd;
+       kpmd = pmd_offset(&swapper_pg_dir[PTRS_PER_PGD-1],
+                               (PTRS_PER_PMD - NR_SHARED_PMDS)*PMD_SIZE);
+       pmd = (pmd_t *)__pmd + (PTRS_PER_PMD - NR_SHARED_PMDS);
+
+       memset(__pmd, 0, (PTRS_PER_PMD - NR_SHARED_PMDS)*sizeof(pmd_t));
+       memcpy(pmd, kpmd, NR_SHARED_PMDS*sizeof(pmd_t));
+}
+
 /*
- * List of all pgd's needed for non-PAE so it can invalidate entries
- * in both cached and uncached pgd's; not needed for PAE since the
- * kernel pmd is shared. If PAE were not to share the pmd a similar
- * tactic would be needed. This is essentially codepath-based locking
+ * List of all pgd's needed so it can invalidate entries in both cached
+ * and uncached pgd's. This is essentially codepath-based locking
  * against pageattr.c; it is the unique case in which a valid change
  * of kernel pagetables can't be lazily synchronized by vmalloc faults.
  * vmalloc faults work because attached pagetables are never freed.
@@ -169,6 +182,12 @@ void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags)
  * checks at dup_mmap(), exec(), and other mmlist addition points
  * could be used. The locking scheme was chosen on the basis of
  * manfred's recommendations and having no core impact whatsoever.
+ *
+ * Lexicon for #ifdefless conditions to config options:
+ * (a) PTRS_PER_PMD == 1 means non-PAE.
+ * (b) PTRS_PER_PMD > 1 means PAE.
+ * (c) TASK_SIZE > PAGE_OFFSET means 4:4.
+ * (d) TASK_SIZE <= PAGE_OFFSET means non-4:4.
  * -- wli
  */
 spinlock_t pgd_lock = SPIN_LOCK_UNLOCKED;
@@ -194,26 +213,38 @@ static inline void pgd_list_del(pgd_t *pgd)
                next->private = (unsigned long)pprev;
 }
 
-void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
+void pgd_ctor(void *__pgd, kmem_cache_t *cache, unsigned long unused)
 {
+       pgd_t *pgd = __pgd;
        unsigned long flags;
 
-       if (PTRS_PER_PMD == 1)
-               spin_lock_irqsave(&pgd_lock, flags);
+       if (PTRS_PER_PMD == 1) {
+               if (TASK_SIZE <= PAGE_OFFSET)
+                       spin_lock_irqsave(&pgd_lock, flags);
+               else
+                       memcpy(&pgd[PTRS_PER_PGD - NR_SHARED_PMDS],
+                               &swapper_pg_dir[PTRS_PER_PGD - NR_SHARED_PMDS],
+                               NR_SHARED_PMDS*sizeof(pgd_t));
+       }
 
-       memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
-                       swapper_pg_dir + USER_PTRS_PER_PGD,
-                       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
+       if (TASK_SIZE <= PAGE_OFFSET)
+               memcpy(&pgd[USER_PTRS_PER_PGD],
+                       &swapper_pg_dir[USER_PTRS_PER_PGD],
+                       (PTRS_PER_PGD - USER_PTRS_PER_PGD)*sizeof(pgd_t));
 
        if (PTRS_PER_PMD > 1)
                return;
 
-       pgd_list_add(pgd);
-       spin_unlock_irqrestore(&pgd_lock, flags);
-       memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
+       if (TASK_SIZE > PAGE_OFFSET)
+               memset(pgd, 0, (PTRS_PER_PGD - NR_SHARED_PMDS)*sizeof(pgd_t));
+       else {
+               pgd_list_add(pgd);
+               spin_unlock_irqrestore(&pgd_lock, flags);
+               memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
+       }
 }
 
-/* never called when PTRS_PER_PMD > 1 */
+/* Never called when PTRS_PER_PMD > 1 || TASK_SIZE > PAGE_OFFSET */
 void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused)
 {
        unsigned long flags; /* can be called from interrupt context */
@@ -231,15 +262,31 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
        if (PTRS_PER_PMD == 1 || !pgd)
                return pgd;
 
+       /*
+        * In the 4G userspace case alias the top 16 MB virtual
+        * memory range into the user mappings as well (these
+        * include the trampoline and CPU data structures).
+        */
        for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
-               pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
+               pmd_t *pmd;
+
+               if (TASK_SIZE > PAGE_OFFSET && i == USER_PTRS_PER_PGD - 1)
+                       pmd = kmem_cache_alloc(kpmd_cache, GFP_KERNEL);
+               else
+                       pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
+
                if (!pmd)
                        goto out_oom;
                set_pgd(&pgd[i], __pgd(1 + __pa((u64)((u32)pmd))));
        }
-       return pgd;
 
+       return pgd;
 out_oom:
+       /*
+        * we don't have to handle the kpmd_cache here, since it's the
+        * last allocation, and has either nothing to free or when it
+        * succeeds the whole operation succeeds.
+        */
        for (i--; i >= 0; i--)
                kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
        kmem_cache_free(pgd_cache, pgd);
@@ -250,10 +297,26 @@ void pgd_free(pgd_t *pgd)
 {
        int i;
 
-       /* in the PAE case user pgd entries are overwritten before usage */
-       if (PTRS_PER_PMD > 1)
-               for (i = 0; i < USER_PTRS_PER_PGD; ++i)
-                       kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
        /* in the non-PAE case, clear_page_tables() clears user pgd entries */
+       if (PTRS_PER_PMD == 1)
+               goto out_free;
+
+       /* in the PAE case user pgd entries are overwritten before usage */
+       for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
+               pmd_t *pmd = __va(pgd_val(pgd[i]) - 1);
+
+               /*
+                * only userspace pmd's are cleared for us
+                * by mm/memory.c; it's a slab cache invariant
+                * that we must separate the kernel pmd slab
+                * all times, else we'll have bad pmd's.
+                */
+               if (TASK_SIZE > PAGE_OFFSET && i == USER_PTRS_PER_PGD - 1)
+                       kmem_cache_free(kpmd_cache, pmd);
+               else
+                       kmem_cache_free(pmd_cache, pmd);
+       }
+out_free:
        kmem_cache_free(pgd_cache, pgd);
 }
+
index d58d307..28ea605 100644 (file)
@@ -83,9 +83,7 @@ do_fpu_end(void)
 static void fix_processor_context(void)
 {
        int cpu = smp_processor_id();
-       struct tss_struct * t = init_tss + cpu;
 
-       set_tss_desc(cpu,t);    /* This just modifies memory; should not be necessary. But... This is necessary, because 386 hardware has concept of busy TSS or some similar stupidity. */
         cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff;
 
        load_TR_desc();                         /* This does ltr */
index 72b48fb..7eef15f 100644 (file)
@@ -44,10 +44,7 @@ choice
 
 config IA64_GENERIC
        bool "generic"
-       select NUMA
-       select ACPI_NUMA
        select VIRTUAL_MEM_MAP
-       select DISCONTIGMEM
        help
          This selects the system type of your hardware.  A "generic" kernel
          will run on any supported IA-64 system.  However, if you configure
@@ -486,6 +483,8 @@ config SYSVIPC_COMPAT
        default y
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index f2ca1e2..d8b6b60 100644 (file)
@@ -74,6 +74,10 @@ boot := arch/ia64/hp/sim/boot
 
 all: compressed unwcheck
 
+bzImage: compressed
+       mkdir -p arch/ia64/boot
+       cp vmlinux.gz arch/ia64/boot/bzImage
+
 compressed: vmlinux.gz
 
 vmlinux.gz: vmlinux
index 9618f62..299c153 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/security.h>
+#include <linux/vs_memory.h>
 
 #include <asm/param.h>
 #include <asm/signal.h>
@@ -148,7 +149,7 @@ ia64_elf32_init (struct pt_regs *regs)
 int
 ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
 {
-       unsigned long stack_base;
+       unsigned long stack_base, grow;
        struct vm_area_struct *mpnt;
        struct mm_struct *mm = current->mm;
        int i;
@@ -165,8 +166,10 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
        if (!mpnt)
                return -ENOMEM;
 
-       if (security_vm_enough_memory((IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
-                                     >> PAGE_SHIFT)) {
+       grow = (IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
+               >> PAGE_SHIFT;
+       if (security_vm_enough_memory(grow) ||
+               !vx_vmpages_avail(mm, grow)) {
                kmem_cache_free(vm_area_cachep, mpnt);
                return -ENOMEM;
        }
@@ -187,7 +190,9 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
                mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC)?
                                        PAGE_COPY_EXEC: PAGE_COPY;
                insert_vm_struct(current->mm, mpnt);
-               current->mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               // current->mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               vx_vmpages_sub(current->mm, current->mm->total_vm -
+                       ((mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT));
        }
 
        for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
@@ -217,7 +222,7 @@ elf32_set_personality (void)
 }
 
 static unsigned long
-elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type)
+elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type, unsigned long unused)
 {
        unsigned long pgoff = (eppnt->p_vaddr) & ~IA32_PAGE_MASK;
 
index 52576c3..6c0fc63 100644 (file)
@@ -1377,7 +1377,15 @@ sys_call_table:
        data8 sys_syslog
        data8 sys_setitimer
        data8 sys_getitimer
+#ifdef CONFIG_TUX
+       data8 __sys_tux                         // 1120         /* was: ia64_oldstat */
+#else
+# ifdef CONFIG_TUX_MODULE
+       data8 sys_tux                           // 1120         /* was: ia64_oldstat */
+# else
        data8 sys_ni_syscall                    // 1120         /* was: ia64_oldstat */
+# endif
+#endif
        data8 sys_ni_syscall                                    /* was: ia64_oldlstat */
        data8 sys_ni_syscall                                    /* was: ia64_oldfstat */
        data8 sys_vhangup
@@ -1526,7 +1534,7 @@ sys_call_table:
        data8 sys_mq_notify
        data8 sys_mq_getsetattr
        data8 sys_ni_syscall                    // reserved for kexec_load
-       data8 sys_ni_syscall
+       data8 sys_vserver
        data8 sys_ni_syscall                    // 1270
        data8 sys_ni_syscall
        data8 sys_ni_syscall
index 605c4e9..4fc74cc 100644 (file)
@@ -58,8 +58,11 @@ EXPORT_SYMBOL(__strlen_user);
 EXPORT_SYMBOL(__strncpy_from_user);
 EXPORT_SYMBOL(__strnlen_user);
 
+#define __KERNEL_SYSCALLS__
 #include <asm/unistd.h>
 EXPORT_SYMBOL(__ia64_syscall);
+EXPORT_SYMBOL(execve);
+EXPORT_SYMBOL(clone);
 
 /* from arch/ia64/lib */
 extern void __divsi3(void);
@@ -103,6 +106,9 @@ EXPORT_SYMBOL(ia64_save_scratch_fpregs);
 #include <asm/unwind.h>
 EXPORT_SYMBOL(unw_init_running);
 
+#include <linux/efi.h>
+EXPORT_SYMBOL(efi_mem_type);
+
 #ifdef ASM_SUPPORTED
 # ifdef CONFIG_SMP
 #  if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
index 3a6ebc7..2f71b39 100644 (file)
@@ -2351,7 +2351,8 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
         */
        insert_vm_struct(mm, vma);
 
-       mm->total_vm  += size >> PAGE_SHIFT;
+       // mm->total_vm  += size >> PAGE_SHIFT;
+       vx_vmpages_add(mm, size >> PAGE_SHIFT);
 
        up_write(&task->mm->mmap_sem);
 
diff --git a/arch/ia64/kernel/perfmon_hpsim.h b/arch/ia64/kernel/perfmon_hpsim.h
deleted file mode 100644 (file)
index 9c6fe7f..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * This file contains the HP SKI Simulator PMU register description tables
- * and pmc checkers used by perfmon.c.
- *
- * Copyright (C) 2002-2003  Hewlett Packard Co
- *               Stephane Eranian <eranian@hpl.hp.com>
- *
- * File mostly contributed by Ian Wienand <ianw@gelato.unsw.edu.au>
- *
- * This file is included as a dummy template so the kernel does not
- * try to initalize registers the simulator can't handle.
- *
- * Note the simulator does not (currently) implement these registers, i.e.,
- * they do not count anything. But you can read/write them.
- */
-
-#define RDEP(x)        (1UL<<(x))
-
-#ifndef CONFIG_IA64_HP_SIM
-#error "This file should only be included for the HP Simulator"
-#endif
-
-static pfm_reg_desc_t pfm_hpsim_pmc_desc[PMU_MAX_PMCS]={
-/* pmc0  */ { PFM_REG_CONTROL , 0, 0x1UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc1  */ { PFM_REG_CONTROL , 0, 0x0UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc2  */ { PFM_REG_CONTROL , 0, 0x0UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc3  */ { PFM_REG_CONTROL , 0, 0x0UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc4  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(4), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc5  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(5), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc6  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(6), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc7  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(7), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc8  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(8), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc9  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(9), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc10 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(10), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc11 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(11), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc12 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(12), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc13 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(13), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc14 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(14), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc15 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(15), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-           { PFM_REG_END     , 0, 0x0UL, -1UL, NULL, NULL, {0,}, {0,}}, /* end marker */
-};
-
-static pfm_reg_desc_t pfm_hpsim_pmd_desc[PMU_MAX_PMDS]={
-/* pmd0  */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd1  */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd2  */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd3  */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd4  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(4),0UL, 0UL, 0UL}},
-/* pmd5  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(5),0UL, 0UL, 0UL}},
-/* pmd6  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(6),0UL, 0UL, 0UL}},
-/* pmd7  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(7),0UL, 0UL, 0UL}},
-/* pmd8  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(8),0UL, 0UL, 0UL}},
-/* pmd9  */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(9),0UL, 0UL, 0UL}},
-/* pmd10 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(10),0UL, 0UL, 0UL}},
-/* pmd11 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(11),0UL, 0UL, 0UL}},
-/* pmd12 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(12),0UL, 0UL, 0UL}},
-/* pmd13 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(13),0UL, 0UL, 0UL}},
-/* pmd14 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(14),0UL, 0UL, 0UL}},
-/* pmd15 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(15),0UL, 0UL, 0UL}},
-           { PFM_REG_END     , 0, 0x0UL, -1UL, NULL, NULL, {0,}, {0,}}, /* end marker */
-};
-
-/*
- * impl_pmcs, impl_pmds are computed at runtime to minimize errors!
- */
-static pmu_config_t pmu_conf={
-       .pmu_name   = "hpsim",
-       .pmu_family = 0x7, /* ski emulator reports as Itanium */
-       .enabled    = 0,
-       .ovfl_val   = (1UL << 32) - 1,
-       .num_ibrs   = 0, /* does not use */
-       .num_dbrs   = 0, /* does not use */
-       .pmd_desc   = pfm_hpsim_pmd_desc,
-       .pmc_desc   = pfm_hpsim_pmc_desc
-};
index 56ce1d4..4ca33df 100644 (file)
@@ -1310,6 +1310,9 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data,
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
+
        ret = -EPERM;
        if (pid == 1)           /* no messing around with init! */
                goto out_tsk;
index f899131..e0a9fcd 100644 (file)
@@ -92,6 +92,13 @@ die (const char *str, struct pt_regs *regs, long err)
        } else
                printk(KERN_ERR "Recursive die() failure, output suppressed\n");
 
+       if (netdump_func)
+               netdump_func(regs);
+       if (panic_on_oops) {
+               if (netdump_func)
+                       netdump_func = NULL;
+               panic("Fatal exception");
+       }
        bust_spinlocks(0);
        die.lock_owner = -1;
        spin_unlock_irq(&die.lock);
index d823ff8..8e63f14 100644 (file)
@@ -34,12 +34,19 @@ expand_backing_store (struct vm_area_struct *vma, unsigned long address)
 
        grow = PAGE_SIZE >> PAGE_SHIFT;
        if (address - vma->vm_start > current->rlim[RLIMIT_STACK].rlim_cur
-           || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur))
+           || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
+               current->rlim[RLIMIT_AS].rlim_cur))
+               return -ENOMEM;
+       if (!vx_vmpages_avail(vma->vm_mm, grow) ||
+               ((vma->vm_flags & VM_LOCKED) &&
+               !vx_vmlocked_avail(vma->vm_mm, grow)))
                return -ENOMEM;
        vma->vm_end += PAGE_SIZE;
-       vma->vm_mm->total_vm += grow;
+       // vma->vm_mm->total_vm += grow;
+       vx_vmpages_add(vma->vm_mm, grow);
        if (vma->vm_flags & VM_LOCKED)
-               vma->vm_mm->locked_vm += grow;
+               // vma->vm_mm->locked_vm += grow;
+               vx_vmlocked_add(vma->vm_mm, grow);
        return 0;
 }
 
index 4606968..fbd24a0 100644 (file)
@@ -65,7 +65,8 @@ set_huge_pte (struct mm_struct *mm, struct vm_area_struct *vma,
 {
        pte_t entry;
 
-       mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
        if (write_access) {
                entry =
                    pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
@@ -108,7 +109,8 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                ptepage = pte_page(entry);
                get_page(ptepage);
                set_pte(dst_pte, entry);
-               dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
                addr += HPAGE_SIZE;
        }
        return 0;
@@ -249,7 +251,8 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, unsig
                put_page(page);
                pte_clear(pte);
        }
-       mm->rss -= (end - start) >> PAGE_SHIFT;
+       // mm->rss -= (end - start) >> PAGE_SHIFT;
+       vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
        flush_tlb_range(vma, start, end);
 }
 
index 3ab0b37..90fecb3 100644 (file)
@@ -218,6 +218,13 @@ free_initrd_mem (unsigned long start, unsigned long end)
        }
 }
 
+int page_is_ram(unsigned long pagenr)
+{
+      //FIXME: implement w/efi walk
+      printk("page is ram is called!!!!!\n");  
+      return 1;
+}
+
 /*
  * This installs a clean page in the kernel's page table.
  */
index 1fa88d5..35ea688 100644 (file)
@@ -690,6 +690,8 @@ config DEBUG_INFO
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index f7cfaa6..9ab7d81 100644 (file)
@@ -635,7 +635,8 @@ static inline void unswap_pte(struct vm_area_struct * vma, unsigned long
        set_pte(dir, pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
        swap_free(entry);
        get_page(page);
-       ++vma->vm_mm->rss;
+       // ++vma->vm_mm->rss;
+       vx_rsspages_inc(vma->vm_mm);
 }
 
 static inline void unswap_pmd(struct vm_area_struct * vma, pmd_t *dir,
index 12e4acd..0f0b28d 100644 (file)
@@ -140,6 +140,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index f113177..b8f71e7 100644 (file)
@@ -566,6 +566,8 @@ config BDM_DISABLE
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 4f3df6d..0c57f87 100644 (file)
@@ -124,6 +124,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 6ab62cb..6c1c24b 100644 (file)
@@ -1686,6 +1686,8 @@ config DEBUG_HIGHMEM
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
diff --git a/arch/mips/configs/eagle_defconfig b/arch/mips/configs/eagle_defconfig
deleted file mode 100644 (file)
index 9a4517f..0000000
+++ /dev/null
@@ -1,749 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
-CONFIG_MACH_VR41XX=y
-# CONFIG_CASIO_E55 is not set
-# CONFIG_IBM_WORKPAD is not set
-CONFIG_NEC_EAGLE=y
-# CONFIG_TANBAC_TB0226 is not set
-# CONFIG_TANBAC_TB0229 is not set
-# CONFIG_VICTOR_MPC30X is not set
-# CONFIG_ZAO_CAPCELLA is not set
-CONFIG_VRC4173=y
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_DMA_NONCOHERENT=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_IRQ_CPU=y
-CONFIG_DUMMY_KEYB=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-# CONFIG_CPU_MIPS32 is not set
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-CONFIG_CPU_VR41XX=y
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_PCI=y
-CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
-CONFIG_MMU=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_YENTA is not set
-# CONFIG_I82092 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_VRC4173 is not set
-
-#
-# PCI Hotplug Support
-#
-# CONFIG_HOTPLUG_PCI is not set
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_PARTITIONS is not set
-# CONFIG_MTD_CONCAT is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-CONFIG_MTD_CFI_ADV_OPTIONS=y
-CONFIG_MTD_CFI_NOSWAP=y
-# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_GEOMETRY is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x1c000000
-CONFIG_MTD_PHYSMAP_LEN=0x2000000
-CONFIG_MTD_PHYSMAP_BUSWIDTH=4
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-CONFIG_BLK_DEV_IDEDISK=y
-CONFIG_IDEDISK_MULTI_MODE=y
-# CONFIG_IDEDISK_STROKE is not set
-CONFIG_BLK_DEV_IDECS=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
-
-#
-# IDE chipset support/bugfixes
-#
-CONFIG_IDE_GENERIC=y
-# CONFIG_BLK_DEV_IDEPCI is not set
-# CONFIG_BLK_DEV_IDEDMA is not set
-# CONFIG_IDEDMA_AUTO is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-CONFIG_PACKET_MMAP=y
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_PCI is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-CONFIG_PCMCIA_FMVJ18X=y
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_CS is not set
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=y
-CONFIG_AUTOFS4_FS=y
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_JFFS_FS=y
-CONFIG_JFFS_FS_VERBOSE=0
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=y
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-# CONFIG_CRYPTO_MD4 is not set
-# CONFIG_CRYPTO_MD5 is not set
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-CONFIG_CRYPTO_SHA512=y
-# CONFIG_CRYPTO_DES is not set
-# CONFIG_CRYPTO_BLOWFISH is not set
-CONFIG_CRYPTO_TWOFISH=y
-# CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_ARC4 is not set
-CONFIG_CRYPTO_DEFLATE=y
-CONFIG_CRYPTO_MICHAEL_MIC=y
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/mips/configs/ocelot_g_defconfig b/arch/mips/configs/ocelot_g_defconfig
deleted file mode 100644 (file)
index a6e9337..0000000
+++ /dev/null
@@ -1,591 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-CONFIG_MIPS64=y
-CONFIG_64BIT=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-CONFIG_MOMENCO_OCELOT_G=y
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP27 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_DMA_NONCOHERENT=y
-# CONFIG_CPU_LITTLE_ENDIAN is not set
-CONFIG_IRQ_CPU=y
-CONFIG_IRQ_CPU_RM7K=y
-CONFIG_PCI_MARVELL=y
-CONFIG_SWAP_IO_SPACE=y
-# CONFIG_SYSCLK_75 is not set
-# CONFIG_SYSCLK_83 is not set
-CONFIG_SYSCLK_100=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-# CONFIG_CPU_MIPS32 is not set
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-CONFIG_CPU_RM7000=y
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_8KB is not set
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_BOARD_SCACHE=y
-CONFIG_RM7000_CPU_SCACHE=y
-CONFIG_CPU_HAS_PREFETCH=y
-CONFIG_CPU_HAS_LLSC=y
-CONFIG_CPU_HAS_LLDSCD=y
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_HW_HAS_PCI=y
-CONFIG_PCI=y
-CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
-CONFIG_MMU=y
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_MIPS32_COMPAT=y
-CONFIG_COMPAT=y
-CONFIG_MIPS32_O32=y
-CONFIG_MIPS32_N32=y
-CONFIG_BINFMT_ELF32=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-# CONFIG_BLK_DEV_RAM is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-CONFIG_GALILEO_64240_ETH=y
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_PCI is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=y
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-CONFIG_CRC16=y
-# CONFIG_CRC32 is not set
-# CONFIG_LIBCRC32C is not set
index dc9f792..0bcfb5a 100644 (file)
@@ -686,7 +686,8 @@ static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        /* Do this so that we can load the interpreter, if need be.  We will
         * change some of these later.
         */
-       current->mm->rss = 0;
+       // current->mm->rss = 0;
+       vx_rsspages_sub(current->mm, current->mm->rss);
        setup_arg_pages(bprm, EXSTACK_DEFAULT);
        current->mm->start_stack = bprm->p;
 
index afd3630..a53f315 100644 (file)
@@ -1208,7 +1208,7 @@ asmlinkage long sys32_newuname(struct new_utsname * name)
        int ret = 0;
 
        down_read(&uts_sem);
-       if (copy_to_user(name,&system_utsname,sizeof *name))
+       if (copy_to_user(name, vx_new_utsname(), sizeof *name))
                ret = -EFAULT;
        up_read(&uts_sem);
 
index 6e85113..db86feb 100644 (file)
@@ -76,6 +76,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 16519f7..8cc462d 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/sem.h>
 #include <linux/msg.h>
 #include <linux/shm.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/branch.h>
 #include <asm/cachectl.h>
@@ -209,7 +210,7 @@ out:
  */
 asmlinkage int sys_uname(struct old_utsname * name)
 {
-       if (name && !copy_to_user(name, &system_utsname, sizeof (*name)))
+       if (name && !copy_to_user(name, vx_new_utsname(), sizeof (*name)))
                return 0;
        return -EFAULT;
 }
@@ -220,21 +221,23 @@ asmlinkage int sys_uname(struct old_utsname * name)
 asmlinkage int sys_olduname(struct oldold_utsname * name)
 {
        int error;
+       struct new_utsname *ptr;
 
        if (!name)
                return -EFAULT;
        if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
                return -EFAULT;
 
-       error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
+       ptr = vx_new_utsname();
+       error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
        error -= __put_user(0,name->sysname+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
        error -= __put_user(0,name->nodename+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
        error -= __put_user(0,name->release+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
        error -= __put_user(0,name->version+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
        error = __put_user(0,name->machine+__OLD_UTS_LEN);
        error = error ? -EFAULT : 0;
 
@@ -260,10 +263,10 @@ asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
                        return -EFAULT;
 
                down_write(&uts_sem);
-               strncpy(system_utsname.nodename, nodename, len);
+               strncpy(vx_new_uts(nodename), nodename, len);
                nodename[__NEW_UTS_LEN] = '\0';
-               strlcpy(system_utsname.nodename, nodename,
-                       sizeof(system_utsname.nodename));
+               strlcpy(vx_new_uts(nodename), nodename,
+                       sizeof(vx_new_uts(nodename)));
                up_write(&uts_sem);
                return 0;
        }
index 494d187..e82b61f 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/socket.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/ptrace.h>
 #include <asm/page.h>
@@ -577,7 +578,8 @@ asmlinkage int irix_brk(unsigned long brk)
        /*
         * Check if we have enough memory..
         */
-       if (security_vm_enough_memory((newbrk-oldbrk) >> PAGE_SHIFT)) {
+       if (security_vm_enough_memory((newbrk-oldbrk) >> PAGE_SHIFT) ||
+               !vx_vmpages_avail(mm, (newbrk-oldbrk) >> PAGE_SHIFT)) {
                ret = -ENOMEM;
                goto out;
        }
diff --git a/arch/mips/mm-32/Makefile b/arch/mips/mm-32/Makefile
deleted file mode 100644 (file)
index 956f4bb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Makefile for the Linux/MIPS-specific parts of the memory manager.
-#
-
-obj-$(CONFIG_CPU_TX49XX)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_R4300)                += tlbex-r4k.o
-obj-$(CONFIG_CPU_R4X00)                += tlbex-r4k.o
-obj-$(CONFIG_CPU_VR41XX)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_R5000)                += tlbex-r4k.o
-obj-$(CONFIG_CPU_NEVADA)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_R5432)                += tlbex-r4k.o
-obj-$(CONFIG_CPU_RM7000)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_RM9000)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_R10000)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_MIPS32)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_MIPS64)       += tlbex-r4k.o
-obj-$(CONFIG_CPU_SB1)          += tlbex-r4k.o
-
-EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/mm-32/tlbex-r4k.S b/arch/mips/mm-32/tlbex-r4k.S
deleted file mode 100644 (file)
index 4974271..0000000
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * TLB exception handling code for r4k.
- *
- * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse
- *
- * Multi-cpu abstraction and reworking:
- * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
- *
- * Carsten Langgaard, carstenl@mips.com
- * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
- */
-#include <linux/init.h>
-#include <linux/config.h>
-
-#include <asm/asm.h>
-#include <asm/offset.h>
-#include <asm/cachectl.h>
-#include <asm/fpregdef.h>
-#include <asm/mipsregs.h>
-#include <asm/page.h>
-#include <asm/pgtable-bits.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-#include <asm/war.h>
-
-#define TLB_OPTIMIZE /* If you are paranoid, disable this. */
-
-#ifdef CONFIG_64BIT_PHYS_ADDR
-#define PTE_L          ld
-#define PTE_S          sd
-#define PTE_SRL                dsrl
-#define P_MTC0         dmtc0
-#define PTE_SIZE       8
-#define PTEP_INDX_MSK  0xff0
-#define PTE_INDX_MSK   0xff8
-#define PTE_INDX_SHIFT 9
-#else
-#define PTE_L          lw
-#define PTE_S          sw
-#define PTE_SRL                srl
-#define P_MTC0         mtc0
-#define PTE_SIZE       4
-#define PTEP_INDX_MSK  0xff8
-#define PTE_INDX_MSK   0xffc
-#define PTE_INDX_SHIFT 10
-#endif
-
-/*
- * ABUSE of CPP macros 101.
- *
- * After this macro runs, the pte faulted on is
- * in register PTE, a ptr into the table in which
- * the pte belongs is in PTR.
- */
-
-#ifdef CONFIG_SMP
-#define GET_PGD(scratch, ptr)        \
-       mfc0    ptr, CP0_CONTEXT;    \
-       la      scratch, pgd_current;\
-       srl     ptr, 23;             \
-       sll     ptr, 2;              \
-       addu    ptr, scratch, ptr;   \
-       lw      ptr, (ptr);
-#else
-#define GET_PGD(scratch, ptr)    \
-       lw      ptr, pgd_current;
-#endif
-
-#define LOAD_PTE(pte, ptr) \
-       GET_PGD(pte, ptr)          \
-       mfc0    pte, CP0_BADVADDR; \
-       srl     pte, pte, _PGDIR_SHIFT; \
-       sll     pte, pte, 2; \
-       addu    ptr, ptr, pte; \
-       mfc0    pte, CP0_BADVADDR; \
-       lw      ptr, (ptr); \
-       srl     pte, pte, PTE_INDX_SHIFT; \
-       and     pte, pte, PTE_INDX_MSK; \
-       addu    ptr, ptr, pte; \
-       PTE_L   pte, (ptr);
-
-       /* This places the even/odd pte pair in the page
-        * table at PTR into ENTRYLO0 and ENTRYLO1 using
-        * TMP as a scratch register.
-        */
-#define PTE_RELOAD(ptr, tmp) \
-       ori     ptr, ptr, PTE_SIZE; \
-       xori    ptr, ptr, PTE_SIZE; \
-       PTE_L   tmp, PTE_SIZE(ptr); \
-       PTE_L   ptr, 0(ptr); \
-       PTE_SRL tmp, tmp, 6; \
-       P_MTC0  tmp, CP0_ENTRYLO1; \
-       PTE_SRL ptr, ptr, 6; \
-       P_MTC0  ptr, CP0_ENTRYLO0;
-
-#define DO_FAULT(write) \
-       .set    noat; \
-       SAVE_ALL; \
-       mfc0    a2, CP0_BADVADDR; \
-       KMODE; \
-       .set    at; \
-       move    a0, sp; \
-       jal     do_page_fault; \
-        li     a1, write; \
-       j       ret_from_exception; \
-        nop; \
-       .set    noat;
-
-       /* Check is PTE is present, if not then jump to LABEL.
-        * PTR points to the page table where this PTE is located,
-        * when the macro is done executing PTE will be restored
-        * with it's original value.
-        */
-#define PTE_PRESENT(pte, ptr, label) \
-       andi    pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
-       xori    pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
-       bnez    pte, label; \
-        PTE_L  pte, (ptr);
-
-       /* Make PTE valid, store result in PTR. */
-#define PTE_MAKEVALID(pte, ptr) \
-       ori     pte, pte, (_PAGE_VALID | _PAGE_ACCESSED); \
-       PTE_S   pte, (ptr);
-
-       /* Check if PTE can be written to, if not branch to LABEL.
-        * Regardless restore PTE with value from PTR when done.
-        */
-#define PTE_WRITABLE(pte, ptr, label) \
-       andi    pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
-       xori    pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
-       bnez    pte, label; \
-        PTE_L  pte, (ptr);
-
-       /* Make PTE writable, update software status bits as well,
-        * then store at PTR.
-        */
-#define PTE_MAKEWRITE(pte, ptr) \
-       ori     pte, pte, (_PAGE_ACCESSED | _PAGE_MODIFIED | \
-                          _PAGE_VALID | _PAGE_DIRTY); \
-       PTE_S   pte, (ptr);
-
-       __INIT
-
-#ifdef CONFIG_64BIT_PHYS_ADDR
-#define GET_PTE_OFF(reg)
-#elif CONFIG_CPU_VR41XX
-#define GET_PTE_OFF(reg)       srl     reg, reg, 3
-#else
-#define GET_PTE_OFF(reg)       srl     reg, reg, 1
-#endif
-
-/*
- * These handlers much be written in a relocatable manner
- * because based upon the cpu type an arbitrary one of the
- * following pieces of code will be copied to the KSEG0
- * vector location.
- */
-       /* TLB refill, EXL == 0, R4xx0, non-R4600 version */
-       .set    noreorder
-       .set    noat
-       LEAF(except_vec0_r4000)
-       .set    mips3
-       GET_PGD(k0, k1)                         # get pgd pointer
-       mfc0    k0, CP0_BADVADDR                # Get faulting address
-       srl     k0, k0, _PGDIR_SHIFT            # get pgd only bits
-
-       sll     k0, k0, 2
-       addu    k1, k1, k0                      # add in pgd offset
-       mfc0    k0, CP0_CONTEXT                 # get context reg
-       lw      k1, (k1)
-       GET_PTE_OFF(k0)                         # get pte offset
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0                      # add in offset
-       PTE_L   k0, 0(k1)                       # get even pte
-       PTE_L   k1, PTE_SIZE(k1)                # get odd pte
-       PTE_SRL k0, k0, 6                       # convert to entrylo0
-       P_MTC0  k0, CP0_ENTRYLO0                # load it
-       PTE_SRL k1, k1, 6                       # convert to entrylo1
-       P_MTC0  k1, CP0_ENTRYLO1                # load it
-       mtc0_tlbw_hazard
-       tlbwr                                   # write random tlb entry
-       tlbw_eret_hazard
-       eret                                    # return from trap
-       END(except_vec0_r4000)
-
-       /* TLB refill, EXL == 0, R4600 version */
-       LEAF(except_vec0_r4600)
-       .set    mips3
-       GET_PGD(k0, k1)                         # get pgd pointer
-       mfc0    k0, CP0_BADVADDR
-       srl     k0, k0, _PGDIR_SHIFT
-       sll     k0, k0, 2                       # log2(sizeof(pgd_t)
-       addu    k1, k1, k0
-       mfc0    k0, CP0_CONTEXT
-       lw      k1, (k1)
-       GET_PTE_OFF(k0)                         # get pte offset
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0
-       PTE_L   k0, 0(k1)
-       PTE_L   k1, PTE_SIZE(k1)
-       PTE_SRL k0, k0, 6
-       P_MTC0  k0, CP0_ENTRYLO0
-       PTE_SRL k1, k1, 6
-       P_MTC0  k1, CP0_ENTRYLO1
-       nop
-       tlbwr
-       nop
-       eret
-       END(except_vec0_r4600)
-
-       /* TLB refill, EXL == 0, R52x0 "Nevada" version */
-        /*
-         * This version has a bug workaround for the Nevada.  It seems
-         * as if under certain circumstances the move from cp0_context
-         * might produce a bogus result when the mfc0 instruction and
-         * it's consumer are in a different cacheline or a load instruction,
-         * probably any memory reference, is between them.  This is
-         * potencially slower than the R4000 version, so we use this
-         * special version.
-         */
-       .set    noreorder
-       .set    noat
-       LEAF(except_vec0_nevada)
-       .set    mips3
-       mfc0    k0, CP0_BADVADDR                # Get faulting address
-       srl     k0, k0, _PGDIR_SHIFT            # get pgd only bits
-       lw      k1, pgd_current                 # get pgd pointer
-       sll     k0, k0, 2                       # log2(sizeof(pgd_t)
-       addu    k1, k1, k0                      # add in pgd offset
-       lw      k1, (k1)
-       mfc0    k0, CP0_CONTEXT                 # get context reg
-       GET_PTE_OFF(k0)                         # get pte offset
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0                      # add in offset
-       PTE_L   k0, 0(k1)                       # get even pte
-       PTE_L   k1, PTE_SIZE(k1)                # get odd pte
-       PTE_SRL k0, k0, 6                       # convert to entrylo0
-       P_MTC0  k0, CP0_ENTRYLO0                # load it
-       PTE_SRL k1, k1, 6                       # convert to entrylo1
-       P_MTC0  k1, CP0_ENTRYLO1                # load it
-       nop                                     # QED specified nops
-       nop
-       tlbwr                                   # write random tlb entry
-       nop                                     # traditional nop
-       eret                                    # return from trap
-       END(except_vec0_nevada)
-
-       /* TLB refill, EXL == 0, SB1 with M3 errata handling version */
-       LEAF(except_vec0_sb1)
-#if BCM1250_M3_WAR
-       mfc0    k0, CP0_BADVADDR
-       mfc0    k1, CP0_ENTRYHI
-       xor     k0, k1
-       srl     k0, k0, PAGE_SHIFT+1
-       bnez    k0, 1f
-#endif
-       GET_PGD(k0, k1)                         # get pgd pointer
-       mfc0    k0, CP0_BADVADDR                # Get faulting address
-       srl     k0, k0, _PGDIR_SHIFT            # get pgd only bits
-       sll     k0, k0, 2
-       addu    k1, k1, k0                      # add in pgd offset
-       mfc0    k0, CP0_CONTEXT                 # get context reg
-       lw      k1, (k1)
-       GET_PTE_OFF(k0)                         # get pte offset
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0                      # add in offset
-       PTE_L   k0, 0(k1)                       # get even pte
-       PTE_L   k1, PTE_SIZE(k1)                # get odd pte
-       PTE_SRL k0, k0, 6                       # convert to entrylo0
-       P_MTC0  k0, CP0_ENTRYLO0                # load it
-       PTE_SRL k1, k1, 6                       # convert to entrylo1
-       P_MTC0  k1, CP0_ENTRYLO1                # load it
-       tlbwr                                   # write random tlb entry
-1:     eret                                    # return from trap
-       END(except_vec0_sb1)
-
-       /* TLB refill, EXL == 0, R4[40]00/R5000 badvaddr hwbug version */
-       LEAF(except_vec0_r45k_bvahwbug)
-       .set    mips3
-       GET_PGD(k0, k1)                         # get pgd pointer
-       mfc0    k0, CP0_BADVADDR
-       srl     k0, k0, _PGDIR_SHIFT
-       sll     k0, k0, 2                       # log2(sizeof(pgd_t)
-       addu    k1, k1, k0
-       mfc0    k0, CP0_CONTEXT
-       lw      k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-       srl     k0, k0, 1
-#endif
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0
-       PTE_L   k0, 0(k1)
-       PTE_L   k1, PTE_SIZE(k1)
-       nop                             /* XXX */
-       tlbp
-       PTE_SRL k0, k0, 6
-       P_MTC0  k0, CP0_ENTRYLO0
-       PTE_SRL k1, k1, 6
-       mfc0    k0, CP0_INDEX
-       P_MTC0  k1, CP0_ENTRYLO1
-       bltzl   k0, 1f
-       tlbwr
-1:
-       nop
-       eret
-       END(except_vec0_r45k_bvahwbug)
-
-#ifdef CONFIG_SMP
-       /* TLB refill, EXL == 0, R4000 MP badvaddr hwbug version */
-       LEAF(except_vec0_r4k_mphwbug)
-       .set    mips3
-       GET_PGD(k0, k1)                         # get pgd pointer
-       mfc0    k0, CP0_BADVADDR
-       srl     k0, k0, _PGDIR_SHIFT
-       sll     k0, k0, 2                       # log2(sizeof(pgd_t)
-       addu    k1, k1, k0
-       mfc0    k0, CP0_CONTEXT
-       lw      k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-       srl     k0, k0, 1
-#endif
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0
-       PTE_L   k0, 0(k1)
-       PTE_L   k1, PTE_SIZE(k1)
-       nop                             /* XXX */
-       tlbp
-       PTE_SRL k0, k0, 6
-       P_MTC0  k0, CP0_ENTRYLO0
-       PTE_SRL k1, k1, 6
-       mfc0    k0, CP0_INDEX
-       P_MTC0  k1, CP0_ENTRYLO1
-       bltzl   k0, 1f
-       tlbwr
-1:
-       nop
-       eret
-       END(except_vec0_r4k_mphwbug)
-#endif
-
-       /* TLB refill, EXL == 0, R4000 UP 250MHZ entrylo[01] hwbug version */
-       LEAF(except_vec0_r4k_250MHZhwbug)
-       .set    mips3
-       GET_PGD(k0, k1)                         # get pgd pointer
-       mfc0    k0, CP0_BADVADDR
-       srl     k0, k0, _PGDIR_SHIFT
-       sll     k0, k0, 2                       # log2(sizeof(pgd_t)
-       addu    k1, k1, k0
-       mfc0    k0, CP0_CONTEXT
-       lw      k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-       srl     k0, k0, 1
-#endif
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0
-       PTE_L   k0, 0(k1)
-       PTE_L   k1, PTE_SIZE(k1)
-       PTE_SRL k0, k0, 6
-       P_MTC0  zero, CP0_ENTRYLO0
-       P_MTC0  k0, CP0_ENTRYLO0
-       PTE_SRL k1, k1, 6
-       P_MTC0  zero, CP0_ENTRYLO1
-       P_MTC0  k1, CP0_ENTRYLO1
-       b       1f
-       tlbwr
-1:
-       nop
-       eret
-       END(except_vec0_r4k_250MHZhwbug)
-
-#ifdef CONFIG_SMP
-       /* TLB refill, EXL == 0, R4000 MP 250MHZ entrylo[01]+badvaddr bug version */
-       LEAF(except_vec0_r4k_MP250MHZhwbug)
-       .set    mips3
-       GET_PGD(k0, k1)                         # get pgd pointer
-       mfc0    k0, CP0_BADVADDR
-       srl     k0, k0, _PGDIR_SHIFT
-       sll     k0, k0, 2                       # log2(sizeof(pgd_t)
-       addu    k1, k1, k0
-       mfc0    k0, CP0_CONTEXT
-       lw      k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
-       srl     k0, k0, 1
-#endif
-       and     k0, k0, PTEP_INDX_MSK
-       addu    k1, k1, k0
-       PTE_L   k0, 0(k1)
-       PTE_L   k1, PTE_SIZE(k1)
-       nop                             /* XXX */
-       tlbp
-       PTE_SRL k0, k0, 6
-       P_MTC0  zero, CP0_ENTRYLO0
-       P_MTC0  k0, CP0_ENTRYLO0
-       mfc0    k0, CP0_INDEX
-       PTE_SRL k1, k1, 6
-       P_MTC0  zero, CP0_ENTRYLO1
-       P_MTC0  k1, CP0_ENTRYLO1
-       bltzl   k0, 1f
-       tlbwr
-1:
-       nop
-       eret
-       END(except_vec0_r4k_MP250MHZhwbug)
-#endif
-
-       __FINIT
-
-       .set    noreorder
-
-/*
- * From the IDT errata for the QED RM5230 (Nevada), processor revision 1.0:
- * 2. A timing hazard exists for the TLBP instruction.
- *
- *      stalling_instruction
- *      TLBP
- *
- * The JTLB is being read for the TLBP throughout the stall generated by the
- * previous instruction. This is not really correct as the stalling instruction
- * can modify the address used to access the JTLB.  The failure symptom is that
- * the TLBP instruction will use an address created for the stalling instruction
- * and not the address held in C0_ENHI and thus report the wrong results.
- *
- * The software work-around is to not allow the instruction preceding the TLBP
- * to stall - make it an NOP or some other instruction guaranteed not to stall.
- *
- * Errata 2 will not be fixed.  This errata is also on the R5000.
- *
- * As if we MIPS hackers wouldn't know how to nop pipelines happy ...
- */
-#define R5K_HAZARD nop
-
-       /*
-        * Note for many R4k variants tlb probes cannot be executed out
-        * of the instruction cache else you get bogus results.
-        */
-       .align  5
-       NESTED(handle_tlbl, PT_SIZE, sp)
-       .set    noat
-#if BCM1250_M3_WAR
-       mfc0    k0, CP0_BADVADDR
-       mfc0    k1, CP0_ENTRYHI
-       xor     k0, k1
-       srl     k0, k0, PAGE_SHIFT+1
-       beqz    k0, 1f
-        nop
-       .set    mips3
-       eret
-       .set    mips0
-1:
-#endif
-invalid_tlbl:
-#ifdef TLB_OPTIMIZE
-       .set    mips3
-       /* Test present bit in entry. */
-       LOAD_PTE(k0, k1)
-       R5K_HAZARD
-       tlbp
-       PTE_PRESENT(k0, k1, nopage_tlbl)
-       PTE_MAKEVALID(k0, k1)
-       PTE_RELOAD(k1, k0)
-       mtc0_tlbw_hazard
-       tlbwi
-       tlbw_eret_hazard
-       .set    mips3
-       eret
-       .set    mips0
-#endif
-
-nopage_tlbl:
-       DO_FAULT(0)
-       END(handle_tlbl)
-
-       .align  5
-       NESTED(handle_tlbs, PT_SIZE, sp)
-       .set    noat
-#ifdef TLB_OPTIMIZE
-       .set    mips3
-        li      k0,0
-       LOAD_PTE(k0, k1)
-       R5K_HAZARD
-       tlbp                            # find faulting entry
-       PTE_WRITABLE(k0, k1, nopage_tlbs)
-       PTE_MAKEWRITE(k0, k1)
-       PTE_RELOAD(k1, k0)
-       mtc0_tlbw_hazard
-       tlbwi
-       tlbw_eret_hazard
-       .set    mips3
-       eret
-       .set    mips0
-#endif
-
-nopage_tlbs:
-       DO_FAULT(1)
-       END(handle_tlbs)
-
-       .align  5
-       NESTED(handle_mod, PT_SIZE, sp)
-       .set    noat
-#ifdef TLB_OPTIMIZE
-       .set    mips3
-       LOAD_PTE(k0, k1)
-       R5K_HAZARD
-       tlbp                                    # find faulting entry
-       andi    k0, k0, _PAGE_WRITE
-       beqz    k0, nowrite_mod
-        PTE_L  k0, (k1)
-
-       /* Present and writable bits set, set accessed and dirty bits. */
-       PTE_MAKEWRITE(k0, k1)
-
-       /* Now reload the entry into the tlb. */
-       PTE_RELOAD(k1, k0)
-       mtc0_tlbw_hazard
-       tlbwi
-       tlbw_eret_hazard
-       .set    mips3
-       eret
-       .set    mips0
-#endif
-
-nowrite_mod:
-       DO_FAULT(1)
-       END(handle_mod)
diff --git a/arch/mips/mm-64/Makefile b/arch/mips/mm-64/Makefile
deleted file mode 100644 (file)
index 30b4d33..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Makefile for the Linux/MIPS-specific parts of the memory manager.
-#
-
-obj-y                          := tlbex-r4k.o
-
-obj-$(CONFIG_CPU_R4300)                += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R4X00)                += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R5000)                += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_NEVADA)       += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R5432)                += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_RM7000)       += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_RM9000)       += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R10000)       += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_SB1)          += tlb-glue-sb1.o
-obj-$(CONFIG_CPU_MIPS64)       += tlb-glue-r4k.o
-
-#
-# Debug TLB exception handler, currently unused
-#
-#obj-y                         +=  tlb-dbg-r4k.o
-
-AFLAGS_tlb-glue-r4k.o := -P
-
-EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/mm-64/tlb-dbg-r4k.c b/arch/mips/mm-64/tlb-dbg-r4k.c
deleted file mode 100644 (file)
index 44e64f7..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999 Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- *
- * TLB debugging routines.  These perform horribly slow but can easily be
- * modified for debugging purposes.
- */
-#include <linux/linkage.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/ptrace.h>
-#include <asm/system.h>
-
-asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
-                              unsigned long address);
-
-asmlinkage void tlb_refill_debug(struct pt_regs regs)
-{
-       show_regs(&regs);
-       panic("%s called.  This Does Not Happen (TM).", __FUNCTION__);
-}
-
-asmlinkage void xtlb_refill_debug(struct pt_regs *regs)
-{
-       unsigned long addr;
-       pgd_t *pgd;
-       pmd_t *pmd;
-       pte_t *pte;
-
-       addr = regs->cp0_badvaddr & ~((PAGE_SIZE << 1) - 1);
-       pgd = pgd_offset(current->active_mm, addr);
-       pmd = pmd_offset(pgd, addr);
-       pte = pte_offset(pmd, addr);
-
-       write_c0_entrylo0(pte_val(pte[0]) >> 6);
-       write_c0_entrylo1(pte_val(pte[1]) >> 6);
-       __asm__ __volatile__("nop;nop;nop");
-
-       tlb_write_random();
-}
-
-asmlinkage void xtlb_mod_debug(struct pt_regs *regs)
-{
-       unsigned long addr;
-
-       addr = regs->cp0_badvaddr;
-       do_page_fault(regs, 1, addr);
-}
-
-asmlinkage void xtlb_tlbl_debug(struct pt_regs *regs)
-{
-       unsigned long addr;
-
-       addr = regs->cp0_badvaddr;
-       do_page_fault(regs, 0, addr);
-}
-
-asmlinkage void xtlb_tlbs_debug(struct pt_regs *regs)
-{
-       unsigned long addr;
-
-       addr = regs->cp0_badvaddr;
-       do_page_fault(regs, 1, addr);
-}
diff --git a/arch/mips/mm-64/tlb-glue-r4k.S b/arch/mips/mm-64/tlb-glue-r4k.S
deleted file mode 100644 (file)
index 4e0194a..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999 Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- */
-#include <linux/init.h>
-#include <asm/mipsregs.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-
-       .macro  __BUILD_cli
-       CLI
-       .endm
-
-       .macro  __BUILD_sti
-       STI
-       .endm
-
-       .macro  __BUILD_kmode
-       KMODE
-       .endm
-
-       .macro  tlb_handler name interruptible writebit
-       NESTED(__\name, PT_SIZE, sp)
-       SAVE_ALL
-       dmfc0   a2, CP0_BADVADDR
-       __BUILD_\interruptible
-       li      a1, \writebit
-       sd      a2, PT_BVADDR(sp)
-       move    a0, sp
-       jal     do_page_fault
-       j       ret_from_exception
-       END(__\name)
-       .endm
-
-       tlb_handler     xtlb_mod kmode 1
-       tlb_handler     xtlb_tlbl kmode 0
-       tlb_handler     xtlb_tlbs kmode 1
diff --git a/arch/mips/mm-64/tlb-glue-sb1.S b/arch/mips/mm-64/tlb-glue-sb1.S
deleted file mode 100644 (file)
index 3c23653..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999 Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- */
-#include <linux/init.h>
-#include <asm/mipsregs.h>
-#include <asm/page.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-#include <asm/war.h>
-
-       .macro  __BUILD_cli
-       CLI
-       .endm
-
-       .macro  __BUILD_sti
-       STI
-       .endm
-
-       .macro  __BUILD_kmode
-       KMODE
-       .endm
-
-       .macro  tlb_handler name interruptible writebit
-       NESTED(__\name, PT_SIZE, sp)
-       SAVE_ALL
-       dmfc0   a2, CP0_BADVADDR
-       __BUILD_\interruptible
-       li      a1, \writebit
-       sd      a2, PT_BVADDR(sp)
-       move    a0, sp
-       jal     do_page_fault
-       j       ret_from_exception
-       END(__\name)
-       .endm
-
-       .macro  tlb_handler_m3 name interruptible writebit
-       NESTED(__\name, PT_SIZE, sp)
-       dmfc0   k0, CP0_BADVADDR
-       dmfc0   k1, CP0_ENTRYHI
-       xor     k0, k1
-       dsrl    k0, k0, PAGE_SHIFT + 1
-       bnez    k0, 1f
-       SAVE_ALL
-       dmfc0   a2, CP0_BADVADDR
-       __BUILD_\interruptible
-       li      a1, \writebit
-       sd      a2, PT_BVADDR(sp)
-       move    a0, sp
-       jal     do_page_fault
-1:
-       j       ret_from_exception
-       END(__\name)
-       .endm
-
-       tlb_handler     xtlb_mod kmode 1
-#if BCM1250_M3_WAR
-       tlb_handler_m3  xtlb_tlbl kmode 0
-#else
-       tlb_handler     xtlb_tlbl kmode 0
-#endif
-       tlb_handler     xtlb_tlbs kmode 1
diff --git a/arch/mips/mm-64/tlbex-r4k.S b/arch/mips/mm-64/tlbex-r4k.S
deleted file mode 100644 (file)
index 728d18f..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2000 Silicon Graphics, Inc.
- * Written by Ulf Carlsson (ulfc@engr.sgi.com)
- * Copyright (C) 2002  Maciej W. Rozycki
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/threads.h>
-
-#include <asm/asm.h>
-#include <asm/hazards.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-#include <asm/stackframe.h>
-#include <asm/war.h>
-
-#define _VMALLOC_START 0xc000000000000000
-
-       /*
-        * After this macro runs we have a pointer to the pte of the address
-        * that caused the fault in PTR.
-        */
-       .macro  LOAD_PTE2, ptr, tmp, kaddr
-#ifdef CONFIG_SMP
-       dmfc0   \ptr, CP0_CONTEXT
-       dmfc0   \tmp, CP0_BADVADDR
-       dsra    \ptr, 23                        # get pgd_current[cpu]
-#else
-       dmfc0   \tmp, CP0_BADVADDR
-       dla     \ptr, pgd_current
-#endif
-       bltz    \tmp, \kaddr
-        ld     \ptr, (\ptr)
-       dsrl    \tmp, (_PGDIR_SHIFT-3)          # get pgd offset in bytes
-       andi    \tmp, ((_PTRS_PER_PGD - 1)<<3)
-       daddu   \ptr, \tmp                      # add in pgd offset
-       dmfc0   \tmp, CP0_BADVADDR
-       ld      \ptr, (\ptr)                    # get pmd pointer
-       dsrl    \tmp, (_PMD_SHIFT-3)            # get pmd offset in bytes
-       andi    \tmp, ((_PTRS_PER_PMD - 1)<<3)
-       daddu   \ptr, \tmp                      # add in pmd offset
-       dmfc0   \tmp, CP0_XCONTEXT
-       ld      \ptr, (\ptr)                    # get pte pointer
-       andi    \tmp, 0xff0                     # get pte offset
-       daddu   \ptr, \tmp
-       .endm
-
-
-       /*
-        * Ditto for the kernel table.
-        */
-       .macro  LOAD_KPTE2, ptr, tmp, not_vmalloc
-       /*
-        * First, determine that the address is in/above vmalloc range.
-        */
-       dmfc0   \tmp, CP0_BADVADDR
-       dli     \ptr, _VMALLOC_START
-
-       /*
-        * Now find offset into kptbl.
-        */
-       dsubu   \tmp, \tmp, \ptr
-       dla     \ptr, kptbl
-       dsrl    \tmp, (_PAGE_SHIFT+1)           # get vpn2
-       dsll    \tmp, 4                         # byte offset of pte
-       daddu   \ptr, \ptr, \tmp
-
-       /*
-        * Determine that fault address is within vmalloc range.
-        */
-       dla     \tmp, ekptbl
-       slt     \tmp, \ptr, \tmp
-       beqz    \tmp, \not_vmalloc              # not vmalloc
-        nop
-       .endm
-
-
-       /*
-        * This places the even/odd pte pair in the page table at the pte
-        * entry pointed to by PTE into ENTRYLO0 and ENTRYLO1.
-        */
-       .macro  PTE_RELOAD, pte0, pte1
-       dsrl    \pte0, 6                        # convert to entrylo0
-       dmtc0   \pte0, CP0_ENTRYLO0             # load it
-       dsrl    \pte1, 6                        # convert to entrylo1
-       dmtc0   \pte1, CP0_ENTRYLO1             # load it
-       .endm
-
-
-       .text
-       .set    noreorder
-       .set    mips3
-
-       __INIT
-
-       /*
-        * TLB refill handlers for the R4000 and SB1.
-        * Attention:  We may only use 32 instructions / 128 bytes.
-        */
-       .align  5
-LEAF(except_vec1_r4k)
-       .set    noat
-       dla     k0, handle_vec1_r4k
-       jr      k0
-        nop
-END(except_vec1_r4k)
-
-LEAF(except_vec1_sb1)
-#if BCM1250_M3_WAR
-       dmfc0   k0, CP0_BADVADDR
-       dmfc0   k1, CP0_ENTRYHI
-       xor     k0, k1
-       dsrl    k0, k0, _PAGE_SHIFT+1
-       bnez    k0, 1f
-#endif
-       .set    noat
-       dla     k0, handle_vec1_r4k
-       jr      k0
-        nop
-
-1:     eret
-       nop
-END(except_vec1_sb1)
-
-       __FINIT
-
-       .align  5
-LEAF(handle_vec1_r4k)
-       .set    noat
-       LOAD_PTE2 k1 k0 9f
-       ld      k0, 0(k1)                       # get even pte
-       ld      k1, 8(k1)                       # get odd pte
-       PTE_RELOAD k0 k1
-       mtc0_tlbw_hazard
-       tlbwr
-       tlbw_eret_hazard
-       eret
-
-9:                                             # handle the vmalloc range
-       LOAD_KPTE2 k1 k0 invalid_vmalloc_address
-       ld      k0, 0(k1)                       # get even pte
-       ld      k1, 8(k1)                       # get odd pte
-       PTE_RELOAD k0 k1
-       mtc0_tlbw_hazard
-        tlbwr
-       tlbw_eret_hazard
-       eret
-END(handle_vec1_r4k)
-
-
-       __INIT
-
-       /*
-        * TLB refill handler for the R10000.
-        * Attention:  We may only use 32 instructions / 128 bytes.
-        */
-       .align  5
-LEAF(except_vec1_r10k)
-       .set    noat
-       dla     k0, handle_vec1_r10k
-       jr      k0
-        nop
-END(except_vec1_r10k)
-
-       __FINIT
-
-       .align  5
-LEAF(handle_vec1_r10k)
-       .set    noat
-       LOAD_PTE2 k1 k0 9f
-       ld      k0, 0(k1)                       # get even pte
-       ld      k1, 8(k1)                       # get odd pte
-       PTE_RELOAD k0 k1
-       nop
-       tlbwr
-       eret
-
-9:                                             # handle the vmalloc range
-       LOAD_KPTE2 k1 k0 invalid_vmalloc_address
-       ld      k0, 0(k1)                       # get even pte
-       ld      k1, 8(k1)                       # get odd pte
-       PTE_RELOAD k0 k1
-       nop
-       tlbwr
-       eret
-END(handle_vec1_r10k)
-
-
-       .align  5
-LEAF(invalid_vmalloc_address)
-       .set    noat
-       SAVE_ALL
-       CLI
-       dmfc0   t0, CP0_BADVADDR
-       sd      t0, PT_BVADDR(sp)
-       move    a0, sp
-       jal     show_regs
-       PANIC("Invalid kernel address")
-END(invalid_vmalloc_address)
diff --git a/arch/mips/mm/tlbex-r3k.S b/arch/mips/mm/tlbex-r3k.S
deleted file mode 100644 (file)
index cc4a464..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * TLB exception handling code for R2000/R3000.
- *
- * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse
- *
- * Multi-CPU abstraction reworking:
- * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
- *
- * Further modifications to make this work:
- * Copyright (c) 1998 Harald Koerfgen
- * Copyright (c) 1998, 1999 Gleb Raiko & Vladimir Roganov
- * Copyright (c) 2001 Ralf Baechle
- * Copyright (c) 2001 MIPS Technologies, Inc.
- */
-#include <linux/init.h>
-#include <asm/asm.h>
-#include <asm/cachectl.h>
-#include <asm/fpregdef.h>
-#include <asm/mipsregs.h>
-#include <asm/page.h>
-#include <asm/pgtable-bits.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-
-#define TLB_OPTIMIZE /* If you are paranoid, disable this. */
-
-       .text
-       .set    mips1
-       .set    noreorder
-
-       __INIT
-
-       /* TLB refill, R[23]00 version */
-       LEAF(except_vec0_r2300)
-       .set    noat
-       .set    mips1
-       mfc0    k0, CP0_BADVADDR
-       lw      k1, pgd_current                 # get pgd pointer
-       srl     k0, k0, 22
-       sll     k0, k0, 2
-       addu    k1, k1, k0
-       mfc0    k0, CP0_CONTEXT
-       lw      k1, (k1)
-       and     k0, k0, 0xffc
-       addu    k1, k1, k0
-       lw      k0, (k1)
-       nop
-       mtc0    k0, CP0_ENTRYLO0
-       mfc0    k1, CP0_EPC
-       tlbwr
-       jr      k1
-       rfe
-       END(except_vec0_r2300)
-
-       __FINIT
-
-       /* ABUSE of CPP macros 101. */
-
-       /* After this macro runs, the pte faulted on is
-        * in register PTE, a ptr into the table in which
-        * the pte belongs is in PTR.
-        */
-#define LOAD_PTE(pte, ptr) \
-       mfc0    pte, CP0_BADVADDR; \
-       lw      ptr, pgd_current; \
-       srl     pte, pte, 22; \
-       sll     pte, pte, 2; \
-       addu    ptr, ptr, pte; \
-       mfc0    pte, CP0_CONTEXT; \
-       lw      ptr, (ptr); \
-       andi    pte, pte, 0xffc; \
-       addu    ptr, ptr, pte; \
-       lw      pte, (ptr); \
-       nop;
-
-       /* This places the even/odd pte pair in the page
-        * table at PTR into ENTRYLO0 and ENTRYLO1 using
-        * TMP as a scratch register.
-        */
-#define PTE_RELOAD(ptr) \
-       lw      ptr, (ptr)      ; \
-       nop                     ; \
-       mtc0    ptr, CP0_ENTRYLO0; \
-       nop;
-
-#define DO_FAULT(write) \
-       .set    noat; \
-       .set    macro; \
-       SAVE_ALL; \
-       mfc0    a2, CP0_BADVADDR; \
-       KMODE; \
-       .set    at; \
-       move    a0, sp; \
-       jal     do_page_fault; \
-        li     a1, write; \
-       j       ret_from_exception; \
-        nop; \
-       .set    noat; \
-       .set    nomacro;
-
-       /* Check is PTE is present, if not then jump to LABEL.
-        * PTR points to the page table where this PTE is located,
-        * when the macro is done executing PTE will be restored
-        * with it's original value.
-        */
-#define PTE_PRESENT(pte, ptr, label) \
-       andi    pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
-       xori    pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
-       bnez    pte, label; \
-       .set    push;       \
-       .set    reorder;    \
-        lw     pte, (ptr); \
-       .set    pop;
-
-       /* Make PTE valid, store result in PTR. */
-#define PTE_MAKEVALID(pte, ptr) \
-       ori     pte, pte, (_PAGE_VALID | _PAGE_ACCESSED); \
-       sw      pte, (ptr);
-
-       /* Check if PTE can be written to, if not branch to LABEL.
-        * Regardless restore PTE with value from PTR when done.
-        */
-#define PTE_WRITABLE(pte, ptr, label) \
-       andi    pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
-       xori    pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
-       bnez    pte, label; \
-       .set    push;       \
-       .set    reorder;    \
-       lw      pte, (ptr); \
-       .set    pop;
-
-
-       /* Make PTE writable, update software status bits as well,
-        * then store at PTR.
-        */
-#define PTE_MAKEWRITE(pte, ptr) \
-       ori     pte, pte, (_PAGE_ACCESSED | _PAGE_MODIFIED | \
-                          _PAGE_VALID | _PAGE_DIRTY); \
-       sw      pte, (ptr);
-
-/*
- * The index register may have the probe fail bit set,
- * because we would trap on access kseg2, i.e. without refill.
- */
-#define TLB_WRITE(reg) \
-       mfc0    reg, CP0_INDEX; \
-       nop; \
-       bltz    reg, 1f; \
-        nop; \
-       tlbwi; \
-       j       2f; \
-        nop; \
-1:     tlbwr; \
-2:
-
-#define RET(reg) \
-       mfc0    reg, CP0_EPC; \
-       nop; \
-       jr      reg; \
-        rfe
-
-       .set    noreorder
-
-       .align  5
-NESTED(handle_tlbl, PT_SIZE, sp)
-       .set    noat
-
-#ifdef TLB_OPTIMIZE
-       /* Test present bit in entry. */
-       LOAD_PTE(k0, k1)
-        tlbp
-        PTE_PRESENT(k0, k1, nopage_tlbl)
-        PTE_MAKEVALID(k0, k1)
-        PTE_RELOAD(k1)
-       TLB_WRITE(k0)
-       RET(k0)
-nopage_tlbl:
-#endif
-
-       DO_FAULT(0)
-END(handle_tlbl)
-
-NESTED(handle_tlbs, PT_SIZE, sp)
-       .set    noat
-
-#ifdef TLB_OPTIMIZE
-       LOAD_PTE(k0, k1)
-       tlbp                            # find faulting entry
-       PTE_WRITABLE(k0, k1, nopage_tlbs)
-       PTE_MAKEWRITE(k0, k1)
-       PTE_RELOAD(k1)
-       TLB_WRITE(k0)
-       RET(k0)
-nopage_tlbs:
-#endif
-
-       DO_FAULT(1)
-END(handle_tlbs)
-
-       .align  5
-NESTED(handle_mod, PT_SIZE, sp)
-       .set    noat
-#ifdef TLB_OPTIMIZE
-       LOAD_PTE(k0, k1)
-       tlbp                                    # find faulting entry
-       andi    k0, k0, _PAGE_WRITE
-       beqz    k0, nowrite_mod
-       .set    push
-       .set    reorder
-       lw      k0, (k1)
-       .set    pop
-
-       /* Present and writable bits set, set accessed and dirty bits. */
-       PTE_MAKEWRITE(k0, k1)
-
-       /* Now reload the entry into the tlb. */
-       PTE_RELOAD(k1)
-       tlbwi
-       RET(k0)
-#endif
-
-nowrite_mod:
-       DO_FAULT(1)
-END(handle_mod)
diff --git a/arch/mips/momentum/ocelot_c/pci-irq.c b/arch/mips/momentum/ocelot_c/pci-irq.c
deleted file mode 100644 (file)
index c14b6d9..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2002 Momentum Computer Inc.
- * Author: Matthew Dharm <mdharm@momenco.com> 
- *
- * Based on work for the Linux port to the Ocelot board, which is
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/momentum/ocelot_g/pci.c
- *     Board-specific PCI routines for mv64340 controller.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/pci.h>
-
-
-void __init mv64340_board_pcibios_fixup_bus(struct pci_bus *bus)
-{
-       struct pci_bus *current_bus = bus;
-       struct pci_dev *devices;
-       struct list_head *devices_link;
-       u16 cmd;
-
-       /* loop over all known devices on this bus */
-       list_for_each(devices_link, &(current_bus->devices)) {
-
-               devices = pci_dev_b(devices_link);
-               if (devices == NULL)
-                       continue;
-
-               if ((current_bus->number == 0) &&
-                       (PCI_SLOT(devices->devfn) == 1) &&
-                       (PCI_FUNC(devices->devfn) == 0)) {
-                       /* LSI 53C10101R SCSI (A) */
-                       devices->irq = 2;
-               } else if ((current_bus->number == 0) &&
-                       (PCI_SLOT(devices->devfn) == 1) &&
-                       (PCI_FUNC(devices->devfn) == 1)) {
-                       /* LSI 53C10101R SCSI (B) */
-                       devices->irq = 2;
-               } else if ((current_bus->number == 1) &&
-                       (PCI_SLOT(devices->devfn) == 1)) {
-                       /* Intel 21555 bridge */
-                       devices->irq = 12;
-               } else if ((current_bus->number == 1) &&
-                       (PCI_SLOT(devices->devfn) == 2)) {
-                       /* PMC Slot */
-                       devices->irq = 4;
-               } else {
-                       /* We don't have assign interrupts for other devices. */
-                       devices->irq = 0xff;
-               }
-
-               /* Assign an interrupt number for the device */
-               bus->ops->write_byte(devices, PCI_INTERRUPT_LINE, devices->irq);
-
-               /* enable master for everything but the MV-64340 */
-               if (((current_bus->number != 0) && (current_bus->number != 1))
-                               || (PCI_SLOT(devices->devfn) != 0)) {
-                       bus->ops->read_word(devices, PCI_COMMAND, &cmd);
-                       cmd |= PCI_COMMAND_MASTER;
-                       bus->ops->write_word(devices, PCI_COMMAND, cmd);
-               }
-       }
-}
diff --git a/arch/mips/momentum/ocelot_g/gt64240.h b/arch/mips/momentum/ocelot_g/gt64240.h
deleted file mode 100644 (file)
index c6cfc0b..0000000
+++ /dev/null
@@ -1,1238 +0,0 @@
-/* gt64240r.h - GT-64240 Internal registers definition file */
-
-/* Copyright - Galileo technology. */
-
-#ifndef __INCgt64240rh
-#define __INCgt64240rh
-
-#define GTREG(v)        (((v) & 0xff) << 24) | (((v) & 0xff00) << 8) | \
-                        (((v) >> 24) & 0xff) | (((v) >> 8) & 0xff00)
-
-#if 0
-#define GTREG_SHORT(X) (((X) << 8) | ((X) >> 8))
-
-#define LONG_GTREG(X)  ((l64) \
-                       (((X)&0x00000000000000ffULL) << 56) | \
-                       (((X)&0x000000000000ff00ULL) << 40) | \
-                       (((X)&0x0000000000ff0000ULL) << 24) | \
-                       (((X)&0x00000000ff000000ULL) << 8)  | \
-                       (((X)&0x000000ff00000000ULL) >> 8)  | \
-                       (((X)&0x0000ff0000000000ULL) >> 24) | \
-                       (((X)&0x00ff000000000000ULL) >> 40) | \
-                       (((X)&0xff00000000000000ULL) >> 56))
-#endif
-
-#include "gt64240_dep.h"
-
-/****************************************/
-/* CPU Control Registers               */
-/****************************************/
-
-#define CPU_CONFIGURATION                                      0x000
-#define CPU_MODE                                               0x120
-#define CPU_READ_RESPONSE_CROSSBAR_LOW                         0x170
-#define CPU_READ_RESPONSE_CROSSBAR_HIGH                                0x178
-
-/****************************************/
-/* Processor Address Space             */
-/****************************************/
-
-/* Sdram's BAR'S */
-#define SCS_0_LOW_DECODE_ADDRESS                               0x008
-#define SCS_0_HIGH_DECODE_ADDRESS                              0x010
-#define SCS_1_LOW_DECODE_ADDRESS                               0x208
-#define SCS_1_HIGH_DECODE_ADDRESS                              0x210
-#define SCS_2_LOW_DECODE_ADDRESS                               0x018
-#define SCS_2_HIGH_DECODE_ADDRESS                              0x020
-#define SCS_3_LOW_DECODE_ADDRESS                               0x218
-#define SCS_3_HIGH_DECODE_ADDRESS                              0x220
-/* Devices BAR'S */
-#define CS_0_LOW_DECODE_ADDRESS                                        0x028
-#define CS_0_HIGH_DECODE_ADDRESS                               0x030
-#define CS_1_LOW_DECODE_ADDRESS                                        0x228
-#define CS_1_HIGH_DECODE_ADDRESS                               0x230
-#define CS_2_LOW_DECODE_ADDRESS                                        0x248
-#define CS_2_HIGH_DECODE_ADDRESS                               0x250
-#define CS_3_LOW_DECODE_ADDRESS                                        0x038
-#define CS_3_HIGH_DECODE_ADDRESS                               0x040
-#define BOOTCS_LOW_DECODE_ADDRESS                              0x238
-#define BOOTCS_HIGH_DECODE_ADDRESS                             0x240
-
-#define PCI_0I_O_LOW_DECODE_ADDRESS                            0x048
-#define PCI_0I_O_HIGH_DECODE_ADDRESS                           0x050
-#define PCI_0MEMORY0_LOW_DECODE_ADDRESS                                0x058
-#define PCI_0MEMORY0_HIGH_DECODE_ADDRESS                       0x060
-#define PCI_0MEMORY1_LOW_DECODE_ADDRESS                                0x080
-#define PCI_0MEMORY1_HIGH_DECODE_ADDRESS                       0x088
-#define PCI_0MEMORY2_LOW_DECODE_ADDRESS                                0x258
-#define PCI_0MEMORY2_HIGH_DECODE_ADDRESS                       0x260
-#define PCI_0MEMORY3_LOW_DECODE_ADDRESS                                0x280
-#define PCI_0MEMORY3_HIGH_DECODE_ADDRESS                       0x288
-
-#define PCI_1I_O_LOW_DECODE_ADDRESS                            0x090
-#define PCI_1I_O_HIGH_DECODE_ADDRESS                           0x098
-#define PCI_1MEMORY0_LOW_DECODE_ADDRESS                                0x0a0
-#define PCI_1MEMORY0_HIGH_DECODE_ADDRESS                       0x0a8
-#define PCI_1MEMORY1_LOW_DECODE_ADDRESS                                0x0b0
-#define PCI_1MEMORY1_HIGH_DECODE_ADDRESS                       0x0b8
-#define PCI_1MEMORY2_LOW_DECODE_ADDRESS                                0x2a0
-#define PCI_1MEMORY2_HIGH_DECODE_ADDRESS                       0x2a8
-#define PCI_1MEMORY3_LOW_DECODE_ADDRESS                                0x2b0
-#define PCI_1MEMORY3_HIGH_DECODE_ADDRESS                       0x2b8
-
-#define INTERNAL_SPACE_DECODE                                  0x068
-
-#define CPU_0_LOW_DECODE_ADDRESS                            0x290
-#define CPU_0_HIGH_DECODE_ADDRESS                           0x298
-#define CPU_1_LOW_DECODE_ADDRESS                            0x2c0
-#define CPU_1_HIGH_DECODE_ADDRESS                           0x2c8
-
-#define PCI_0I_O_ADDRESS_REMAP                                 0x0f0
-#define PCI_0MEMORY0_ADDRESS_REMAP                             0x0f8
-#define PCI_0MEMORY0_HIGH_ADDRESS_REMAP                                0x320
-#define PCI_0MEMORY1_ADDRESS_REMAP                             0x100
-#define PCI_0MEMORY1_HIGH_ADDRESS_REMAP                                0x328
-#define PCI_0MEMORY2_ADDRESS_REMAP                             0x2f8
-#define PCI_0MEMORY2_HIGH_ADDRESS_REMAP                                0x330
-#define PCI_0MEMORY3_ADDRESS_REMAP                             0x300
-#define PCI_0MEMORY3_HIGH_ADDRESS_REMAP                                0x338
-
-#define PCI_1I_O_ADDRESS_REMAP                                 0x108
-#define PCI_1MEMORY0_ADDRESS_REMAP                             0x110
-#define PCI_1MEMORY0_HIGH_ADDRESS_REMAP                                0x340
-#define PCI_1MEMORY1_ADDRESS_REMAP                             0x118
-#define PCI_1MEMORY1_HIGH_ADDRESS_REMAP                                0x348
-#define PCI_1MEMORY2_ADDRESS_REMAP                             0x310
-#define PCI_1MEMORY2_HIGH_ADDRESS_REMAP                                0x350
-#define PCI_1MEMORY3_ADDRESS_REMAP                             0x318
-#define PCI_1MEMORY3_HIGH_ADDRESS_REMAP                                0x358
-
-/****************************************/
-/* CPU Sync Barrier                            */
-/****************************************/
-
-#define PCI_0SYNC_BARIER_VIRTUAL_REGISTER                      0x0c0
-#define PCI_1SYNC_BARIER_VIRTUAL_REGISTER                      0x0c8
-
-
-/****************************************/
-/* CPU Access Protect                          */
-/****************************************/
-
-#define CPU_LOW_PROTECT_ADDRESS_0                           0X180
-#define CPU_HIGH_PROTECT_ADDRESS_0                          0X188
-#define CPU_LOW_PROTECT_ADDRESS_1                           0X190
-#define CPU_HIGH_PROTECT_ADDRESS_1                          0X198
-#define CPU_LOW_PROTECT_ADDRESS_2                           0X1a0
-#define CPU_HIGH_PROTECT_ADDRESS_2                          0X1a8
-#define CPU_LOW_PROTECT_ADDRESS_3                           0X1b0
-#define CPU_HIGH_PROTECT_ADDRESS_3                          0X1b8
-#define CPU_LOW_PROTECT_ADDRESS_4                           0X1c0
-#define CPU_HIGH_PROTECT_ADDRESS_4                          0X1c8
-#define CPU_LOW_PROTECT_ADDRESS_5                           0X1d0
-#define CPU_HIGH_PROTECT_ADDRESS_5                          0X1d8
-#define CPU_LOW_PROTECT_ADDRESS_6                           0X1e0
-#define CPU_HIGH_PROTECT_ADDRESS_6                          0X1e8
-#define CPU_LOW_PROTECT_ADDRESS_7                           0X1f0
-#define CPU_HIGH_PROTECT_ADDRESS_7                          0X1f8
-
-
-/****************************************/
-/*          Snoop Control                      */
-/****************************************/
-
-#define SNOOP_BASE_ADDRESS_0                                0x380
-#define SNOOP_TOP_ADDRESS_0                                 0x388
-#define SNOOP_BASE_ADDRESS_1                                0x390
-#define SNOOP_TOP_ADDRESS_1                                 0x398
-#define SNOOP_BASE_ADDRESS_2                                0x3a0
-#define SNOOP_TOP_ADDRESS_2                                 0x3a8
-#define SNOOP_BASE_ADDRESS_3                                0x3b0
-#define SNOOP_TOP_ADDRESS_3                                 0x3b8
-
-/****************************************/
-/*          CPU Error Report                   */
-/****************************************/
-
-#define CPU_ERROR_ADDRESS_LOW                              0x070
-#define CPU_ERROR_ADDRESS_HIGH                                     0x078
-#define CPU_ERROR_DATA_LOW                                  0x128
-#define CPU_ERROR_DATA_HIGH                                 0x130
-#define CPU_ERROR_PARITY                                    0x138
-#define CPU_ERROR_CAUSE                                     0x140
-#define CPU_ERROR_MASK                                      0x148
-
-/****************************************/
-/*          Pslave Debug                       */
-/****************************************/
-
-#define X_0_ADDRESS                                         0x360
-#define X_0_COMMAND_ID                                      0x368
-#define X_1_ADDRESS                                         0x370
-#define X_1_COMMAND_ID                                      0x378
-#define WRITE_DATA_LOW                                      0x3c0
-#define WRITE_DATA_HIGH                                     0x3c8
-#define WRITE_BYTE_ENABLE                                   0X3e0
-#define READ_DATA_LOW                                       0x3d0
-#define READ_DATA_HIGH                                      0x3d8
-#define READ_ID                                             0x3e8
-
-
-/****************************************/
-/* SDRAM and Device Address Space      */
-/****************************************/
-
-
-/****************************************/
-/* SDRAM Configuration                 */
-/****************************************/
-
-#define SDRAM_CONFIGURATION                            0x448
-#define SDRAM_OPERATION_MODE                           0x474
-#define SDRAM_ADDRESS_DECODE                           0x47C
-#define SDRAM_TIMING_PARAMETERS                         0x4b4
-#define SDRAM_UMA_CONTROL                               0x4a4
-#define SDRAM_CROSS_BAR_CONTROL_LOW                     0x4a8
-#define SDRAM_CROSS_BAR_CONTROL_HIGH                    0x4ac
-#define SDRAM_CROSS_BAR_TIMEOUT                         0x4b0
-
-
-/****************************************/
-/* SDRAM Parameters                    */
-/****************************************/
-
-#define SDRAM_BANK0PARAMETERS                          0x44C
-#define SDRAM_BANK1PARAMETERS                          0x450
-#define SDRAM_BANK2PARAMETERS                          0x454
-#define SDRAM_BANK3PARAMETERS                          0x458
-
-
-/****************************************/
-/* SDRAM Error Report                  */
-/****************************************/
-
-#define SDRAM_ERROR_DATA_LOW                            0x484
-#define SDRAM_ERROR_DATA_HIGH                           0x480
-#define SDRAM_AND_DEVICE_ERROR_ADDRESS                  0x490
-#define SDRAM_RECEIVED_ECC                              0x488
-#define SDRAM_CALCULATED_ECC                            0x48c
-#define SDRAM_ECC_CONTROL                               0x494
-#define SDRAM_ECC_ERROR_COUNTER                         0x498
-
-
-/****************************************/
-/* SDunit Debug (for internal use)     */
-/****************************************/
-
-#define X0_ADDRESS                                      0x500
-#define X0_COMMAND_AND_ID                               0x504
-#define X0_WRITE_DATA_LOW                               0x508
-#define X0_WRITE_DATA_HIGH                              0x50c
-#define X0_WRITE_BYTE_ENABLE                            0x518
-#define X0_READ_DATA_LOW                                0x510
-#define X0_READ_DATA_HIGH                               0x514
-#define X0_READ_ID                                      0x51c
-#define X1_ADDRESS                                      0x520
-#define X1_COMMAND_AND_ID                               0x524
-#define X1_WRITE_DATA_LOW                               0x528
-#define X1_WRITE_DATA_HIGH                              0x52c
-#define X1_WRITE_BYTE_ENABLE                            0x538
-#define X1_READ_DATA_LOW                                0x530
-#define X1_READ_DATA_HIGH                               0x534
-#define X1_READ_ID                                      0x53c
-#define X0_SNOOP_ADDRESS                                0x540
-#define X0_SNOOP_COMMAND                                0x544
-#define X1_SNOOP_ADDRESS                                0x548
-#define X1_SNOOP_COMMAND                                0x54c
-
-
-/****************************************/
-/* Device Parameters                   */
-/****************************************/
-
-#define DEVICE_BANK0PARAMETERS                         0x45c
-#define DEVICE_BANK1PARAMETERS                         0x460
-#define DEVICE_BANK2PARAMETERS                         0x464
-#define DEVICE_BANK3PARAMETERS                         0x468
-#define DEVICE_BOOT_BANK_PARAMETERS                    0x46c
-#define DEVICE_CONTROL                                  0x4c0
-#define DEVICE_CROSS_BAR_CONTROL_LOW                    0x4c8
-#define DEVICE_CROSS_BAR_CONTROL_HIGH                   0x4cc
-#define DEVICE_CROSS_BAR_TIMEOUT                        0x4c4
-
-
-/****************************************/
-/* Device Interrupt                    */
-/****************************************/
-
-#define DEVICE_INTERRUPT_CAUSE                              0x4d0
-#define DEVICE_INTERRUPT_MASK                               0x4d4
-#define DEVICE_ERROR_ADDRESS                                0x4d8
-
-/****************************************/
-/* DMA Record                          */
-/****************************************/
-
-#define CHANNEL0_DMA_BYTE_COUNT                                        0x800
-#define CHANNEL1_DMA_BYTE_COUNT                                        0x804
-#define CHANNEL2_DMA_BYTE_COUNT                                        0x808
-#define CHANNEL3_DMA_BYTE_COUNT                                        0x80C
-#define CHANNEL4_DMA_BYTE_COUNT                                        0x900
-#define CHANNEL5_DMA_BYTE_COUNT                                        0x904
-#define CHANNEL6_DMA_BYTE_COUNT                                        0x908
-#define CHANNEL7_DMA_BYTE_COUNT                                        0x90C
-#define CHANNEL0_DMA_SOURCE_ADDRESS                            0x810
-#define CHANNEL1_DMA_SOURCE_ADDRESS                            0x814
-#define CHANNEL2_DMA_SOURCE_ADDRESS                            0x818
-#define CHANNEL3_DMA_SOURCE_ADDRESS                            0x81C
-#define CHANNEL4_DMA_SOURCE_ADDRESS                            0x910
-#define CHANNEL5_DMA_SOURCE_ADDRESS                            0x914
-#define CHANNEL6_DMA_SOURCE_ADDRESS                            0x918
-#define CHANNEL7_DMA_SOURCE_ADDRESS                            0x91C
-#define CHANNEL0_DMA_DESTINATION_ADDRESS                       0x820
-#define CHANNEL1_DMA_DESTINATION_ADDRESS                       0x824
-#define CHANNEL2_DMA_DESTINATION_ADDRESS                       0x828
-#define CHANNEL3_DMA_DESTINATION_ADDRESS                       0x82C
-#define CHANNEL4_DMA_DESTINATION_ADDRESS                       0x920
-#define CHANNEL5_DMA_DESTINATION_ADDRESS                       0x924
-#define CHANNEL6_DMA_DESTINATION_ADDRESS                       0x928
-#define CHANNEL7_DMA_DESTINATION_ADDRESS                       0x92C
-#define CHANNEL0NEXT_RECORD_POINTER                            0x830
-#define CHANNEL1NEXT_RECORD_POINTER                            0x834
-#define CHANNEL2NEXT_RECORD_POINTER                            0x838
-#define CHANNEL3NEXT_RECORD_POINTER                            0x83C
-#define CHANNEL4NEXT_RECORD_POINTER                            0x930
-#define CHANNEL5NEXT_RECORD_POINTER                            0x934
-#define CHANNEL6NEXT_RECORD_POINTER                            0x938
-#define CHANNEL7NEXT_RECORD_POINTER                            0x93C
-#define CHANNEL0CURRENT_DESCRIPTOR_POINTER                     0x870
-#define CHANNEL1CURRENT_DESCRIPTOR_POINTER                     0x874
-#define CHANNEL2CURRENT_DESCRIPTOR_POINTER                     0x878
-#define CHANNEL3CURRENT_DESCRIPTOR_POINTER                     0x87C
-#define CHANNEL4CURRENT_DESCRIPTOR_POINTER                     0x970
-#define CHANNEL5CURRENT_DESCRIPTOR_POINTER                     0x974
-#define CHANNEL6CURRENT_DESCRIPTOR_POINTER                     0x978
-#define CHANNEL7CURRENT_DESCRIPTOR_POINTER                     0x97C
-#define CHANNEL0_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x890
-#define CHANNEL1_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x894
-#define CHANNEL2_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x898
-#define CHANNEL3_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x89c
-#define CHANNEL4_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x990
-#define CHANNEL5_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x994
-#define CHANNEL6_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x998
-#define CHANNEL7_DMA_SOURCE_HIGH_PCI_ADDRESS                   0x99c
-#define CHANNEL0_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x8a0
-#define CHANNEL1_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x8a4
-#define CHANNEL2_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x8a8
-#define CHANNEL3_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x8ac
-#define CHANNEL4_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x9a0
-#define CHANNEL5_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x9a4
-#define CHANNEL6_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x9a8
-#define CHANNEL7_DMA_DESTINATION_HIGH_PCI_ADDRESS              0x9ac
-#define CHANNEL0_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x8b0
-#define CHANNEL1_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x8b4
-#define CHANNEL2_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x8b8
-#define CHANNEL3_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x8bc
-#define CHANNEL4_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x9b0
-#define CHANNEL5_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x9b4
-#define CHANNEL6_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x9b8
-#define CHANNEL7_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS      0x9bc
-
-/****************************************/
-/* DMA Channel Control                 */
-/****************************************/
-
-#define CHANNEL0CONTROL                                        0x840
-#define CHANNEL0CONTROL_HIGH                                   0x880
-
-#define CHANNEL1CONTROL                                        0x844
-#define CHANNEL1CONTROL_HIGH                                   0x884
-
-#define CHANNEL2CONTROL                                        0x848
-#define CHANNEL2CONTROL_HIGH                                   0x888
-
-#define CHANNEL3CONTROL                                        0x84C
-#define CHANNEL3CONTROL_HIGH                                   0x88C
-
-#define CHANNEL4CONTROL                                        0x940
-#define CHANNEL4CONTROL_HIGH                                   0x980
-
-#define CHANNEL5CONTROL                                        0x944
-#define CHANNEL5CONTROL_HIGH                                   0x984
-
-#define CHANNEL6CONTROL                                        0x948
-#define CHANNEL6CONTROL_HIGH                                   0x988
-
-#define CHANNEL7CONTROL                                        0x94C
-#define CHANNEL7CONTROL_HIGH                                   0x98C
-
-
-/****************************************/
-/* DMA Arbiter                         */
-/****************************************/
-
-#define ARBITER_CONTROL_0_3                                    0x860
-#define ARBITER_CONTROL_4_7                                    0x960
-
-
-/****************************************/
-/* DMA Interrupt                       */
-/****************************************/
-
-#define CHANELS0_3_INTERRUPT_CAUSE                             0x8c0
-#define CHANELS0_3_INTERRUPT_MASK                              0x8c4
-#define CHANELS0_3_ERROR_ADDRESS                               0x8c8
-#define CHANELS0_3_ERROR_SELECT                                        0x8cc
-#define CHANELS4_7_INTERRUPT_CAUSE                             0x9c0
-#define CHANELS4_7_INTERRUPT_MASK                              0x9c4
-#define CHANELS4_7_ERROR_ADDRESS                               0x9c8
-#define CHANELS4_7_ERROR_SELECT                                        0x9cc
-
-
-/****************************************/
-/* DMA Debug (for internal use)         */
-/****************************************/
-
-#define DMA_X0_ADDRESS                                      0x8e0
-#define DMA_X0_COMMAND_AND_ID                               0x8e4
-#define DMA_X0_WRITE_DATA_LOW                               0x8e8
-#define DMA_X0_WRITE_DATA_HIGH                              0x8ec
-#define DMA_X0_WRITE_BYTE_ENABLE                            0x8f8
-#define DMA_X0_READ_DATA_LOW                                0x8f0
-#define DMA_X0_READ_DATA_HIGH                               0x8f4
-#define DMA_X0_READ_ID                                      0x8fc
-#define DMA_X1_ADDRESS                                      0x9e0
-#define DMA_X1_COMMAND_AND_ID                               0x9e4
-#define DMA_X1_WRITE_DATA_LOW                               0x9e8
-#define DMA_X1_WRITE_DATA_HIGH                              0x9ec
-#define DMA_X1_WRITE_BYTE_ENABLE                            0x9f8
-#define DMA_X1_READ_DATA_LOW                                0x9f0
-#define DMA_X1_READ_DATA_HIGH                               0x9f4
-#define DMA_X1_READ_ID                                      0x9fc
-
-/****************************************/
-/* Timer_Counter                                               */
-/****************************************/
-
-#define TIMER_COUNTER0                                         0x850
-#define TIMER_COUNTER1                                         0x854
-#define TIMER_COUNTER2                                         0x858
-#define TIMER_COUNTER3                                         0x85C
-#define TIMER_COUNTER_0_3_CONTROL                              0x864
-#define TIMER_COUNTER_0_3_INTERRUPT_CAUSE                      0x868
-#define TIMER_COUNTER_0_3_INTERRUPT_MASK                       0x86c
-#define TIMER_COUNTER4                                         0x950
-#define TIMER_COUNTER5                                         0x954
-#define TIMER_COUNTER6                                         0x958
-#define TIMER_COUNTER7                                         0x95C
-#define TIMER_COUNTER_4_7_CONTROL                              0x964
-#define TIMER_COUNTER_4_7_INTERRUPT_CAUSE                      0x968
-#define TIMER_COUNTER_4_7_INTERRUPT_MASK                       0x96c
-
-/****************************************/
-/* PCI Slave Address Decoding           */
-/****************************************/
-
-#define PCI_0SCS_0_BANK_SIZE                                   0xc08
-#define PCI_1SCS_0_BANK_SIZE                                   0xc88
-#define PCI_0SCS_1_BANK_SIZE                                   0xd08
-#define PCI_1SCS_1_BANK_SIZE                                   0xd88
-#define PCI_0SCS_2_BANK_SIZE                                   0xc0c
-#define PCI_1SCS_2_BANK_SIZE                                   0xc8c
-#define PCI_0SCS_3_BANK_SIZE                                   0xd0c
-#define PCI_1SCS_3_BANK_SIZE                                   0xd8c
-#define PCI_0CS_0_BANK_SIZE                                    0xc10
-#define PCI_1CS_0_BANK_SIZE                                    0xc90
-#define PCI_0CS_1_BANK_SIZE                                    0xd10
-#define PCI_1CS_1_BANK_SIZE                                    0xd90
-#define PCI_0CS_2_BANK_SIZE                                    0xd18
-#define PCI_1CS_2_BANK_SIZE                                    0xd98
-#define PCI_0CS_3_BANK_SIZE                                    0xc14
-#define PCI_1CS_3_BANK_SIZE                                    0xc94
-#define PCI_0CS_BOOT_BANK_SIZE                                 0xd14
-#define PCI_1CS_BOOT_BANK_SIZE                                 0xd94
-#define PCI_0P2P_MEM0_BAR_SIZE                              0xd1c
-#define PCI_1P2P_MEM0_BAR_SIZE                              0xd9c
-#define PCI_0P2P_MEM1_BAR_SIZE                              0xd20
-#define PCI_1P2P_MEM1_BAR_SIZE                              0xda0
-#define PCI_0P2P_I_O_BAR_SIZE                               0xd24
-#define PCI_1P2P_I_O_BAR_SIZE                               0xda4
-#define PCI_0CPU_BAR_SIZE                                   0xd28
-#define PCI_1CPU_BAR_SIZE                                   0xda8
-#define PCI_0DAC_SCS_0_BANK_SIZE                            0xe00
-#define PCI_1DAC_SCS_0_BANK_SIZE                            0xe80
-#define PCI_0DAC_SCS_1_BANK_SIZE                            0xe04
-#define PCI_1DAC_SCS_1_BANK_SIZE                            0xe84
-#define PCI_0DAC_SCS_2_BANK_SIZE                            0xe08
-#define PCI_1DAC_SCS_2_BANK_SIZE                            0xe88
-#define PCI_0DAC_SCS_3_BANK_SIZE                            0xe0c
-#define PCI_1DAC_SCS_3_BANK_SIZE                            0xe8c
-#define PCI_0DAC_CS_0_BANK_SIZE                             0xe10
-#define PCI_1DAC_CS_0_BANK_SIZE                             0xe90
-#define PCI_0DAC_CS_1_BANK_SIZE                             0xe14
-#define PCI_1DAC_CS_1_BANK_SIZE                             0xe94
-#define PCI_0DAC_CS_2_BANK_SIZE                             0xe18
-#define PCI_1DAC_CS_2_BANK_SIZE                             0xe98
-#define PCI_0DAC_CS_3_BANK_SIZE                             0xe1c
-#define PCI_1DAC_CS_3_BANK_SIZE                             0xe9c
-#define PCI_0DAC_BOOTCS_BANK_SIZE                           0xe20
-#define PCI_1DAC_BOOTCS_BANK_SIZE                           0xea0
-#define PCI_0DAC_P2P_MEM0_BAR_SIZE                          0xe24
-#define PCI_1DAC_P2P_MEM0_BAR_SIZE                          0xea4
-#define PCI_0DAC_P2P_MEM1_BAR_SIZE                          0xe28
-#define PCI_1DAC_P2P_MEM1_BAR_SIZE                          0xea8
-#define PCI_0DAC_CPU_BAR_SIZE                               0xe2c
-#define PCI_1DAC_CPU_BAR_SIZE                               0xeac
-#define PCI_0EXPANSION_ROM_BAR_SIZE                         0xd2c
-#define PCI_1EXPANSION_ROM_BAR_SIZE                         0xdac
-#define PCI_0BASE_ADDRESS_REGISTERS_ENABLE                     0xc3c
-#define PCI_1BASE_ADDRESS_REGISTERS_ENABLE                     0xcbc
-#define PCI_0SCS_0_BASE_ADDRESS_REMAP                          0xc48
-#define PCI_1SCS_0_BASE_ADDRESS_REMAP                          0xcc8
-#define PCI_0SCS_1_BASE_ADDRESS_REMAP                          0xd48
-#define PCI_1SCS_1_BASE_ADDRESS_REMAP                          0xdc8
-#define PCI_0SCS_2_BASE_ADDRESS_REMAP                          0xc4c
-#define PCI_1SCS_2_BASE_ADDRESS_REMAP                          0xccc
-#define PCI_0SCS_3_BASE_ADDRESS_REMAP                          0xd4c
-#define PCI_1SCS_3_BASE_ADDRESS_REMAP                          0xdcc
-#define PCI_0CS_0_BASE_ADDRESS_REMAP                           0xc50
-#define PCI_1CS_0_BASE_ADDRESS_REMAP                           0xcd0
-#define PCI_0CS_1_BASE_ADDRESS_REMAP                           0xd50
-#define PCI_1CS_1_BASE_ADDRESS_REMAP                           0xdd0
-#define PCI_0CS_2_BASE_ADDRESS_REMAP                           0xd58
-#define PCI_1CS_2_BASE_ADDRESS_REMAP                           0xdd8
-#define PCI_0CS_3_BASE_ADDRESS_REMAP                                   0xc54
-#define PCI_1CS_3_BASE_ADDRESS_REMAP                                   0xcd4
-#define PCI_0CS_BOOTCS_BASE_ADDRESS_REMAP                              0xd54
-#define PCI_1CS_BOOTCS_BASE_ADDRESS_REMAP                              0xdd4
-#define PCI_0P2P_MEM0_BASE_ADDRESS_REMAP_LOW                0xd5c
-#define PCI_1P2P_MEM0_BASE_ADDRESS_REMAP_LOW                0xddc
-#define PCI_0P2P_MEM0_BASE_ADDRESS_REMAP_HIGH               0xd60
-#define PCI_1P2P_MEM0_BASE_ADDRESS_REMAP_HIGH               0xde0
-#define PCI_0P2P_MEM1_BASE_ADDRESS_REMAP_LOW                0xd64
-#define PCI_1P2P_MEM1_BASE_ADDRESS_REMAP_LOW                0xde4
-#define PCI_0P2P_MEM1_BASE_ADDRESS_REMAP_HIGH               0xd68
-#define PCI_1P2P_MEM1_BASE_ADDRESS_REMAP_HIGH               0xde8
-#define PCI_0P2P_I_O_BASE_ADDRESS_REMAP                     0xd6c
-#define PCI_1P2P_I_O_BASE_ADDRESS_REMAP                     0xdec
-#define PCI_0CPU_BASE_ADDRESS_REMAP                         0xd70
-#define PCI_1CPU_BASE_ADDRESS_REMAP                         0xdf0
-#define PCI_0DAC_SCS_0_BASE_ADDRESS_REMAP                   0xf00
-#define PCI_1DAC_SCS_0_BASE_ADDRESS_REMAP                   0xff0
-#define PCI_0DAC_SCS_1_BASE_ADDRESS_REMAP                   0xf04
-#define PCI_1DAC_SCS_1_BASE_ADDRESS_REMAP                   0xf84
-#define PCI_0DAC_SCS_2_BASE_ADDRESS_REMAP                   0xf08
-#define PCI_1DAC_SCS_2_BASE_ADDRESS_REMAP                   0xf88
-#define PCI_0DAC_SCS_3_BASE_ADDRESS_REMAP                   0xf0c
-#define PCI_1DAC_SCS_3_BASE_ADDRESS_REMAP                   0xf8c
-#define PCI_0DAC_CS_0_BASE_ADDRESS_REMAP                    0xf10
-#define PCI_1DAC_CS_0_BASE_ADDRESS_REMAP                    0xf90
-#define PCI_0DAC_CS_1_BASE_ADDRESS_REMAP                    0xf14
-#define PCI_1DAC_CS_1_BASE_ADDRESS_REMAP                    0xf94
-#define PCI_0DAC_CS_2_BASE_ADDRESS_REMAP                    0xf18
-#define PCI_1DAC_CS_2_BASE_ADDRESS_REMAP                    0xf98
-#define PCI_0DAC_CS_3_BASE_ADDRESS_REMAP                    0xf1c
-#define PCI_1DAC_CS_3_BASE_ADDRESS_REMAP                    0xf9c
-#define PCI_0DAC_BOOTCS_BASE_ADDRESS_REMAP                  0xf20
-#define PCI_1DAC_BOOTCS_BASE_ADDRESS_REMAP                  0xfa0
-#define PCI_0DAC_P2P_MEM0_BASE_ADDRESS_REMAP_LOW            0xf24
-#define PCI_1DAC_P2P_MEM0_BASE_ADDRESS_REMAP_LOW            0xfa4
-#define PCI_0DAC_P2P_MEM0_BASE_ADDRESS_REMAP_HIGH           0xf28
-#define PCI_1DAC_P2P_MEM0_BASE_ADDRESS_REMAP_HIGH           0xfa8
-#define PCI_0DAC_P2P_MEM1_BASE_ADDRESS_REMAP_LOW            0xf2c
-#define PCI_1DAC_P2P_MEM1_BASE_ADDRESS_REMAP_LOW            0xfac
-#define PCI_0DAC_P2P_MEM1_BASE_ADDRESS_REMAP_HIGH           0xf30
-#define PCI_1DAC_P2P_MEM1_BASE_ADDRESS_REMAP_HIGH           0xfb0
-#define PCI_0DAC_CPU_BASE_ADDRESS_REMAP                     0xf34
-#define PCI_1DAC_CPU_BASE_ADDRESS_REMAP                     0xfb4
-#define PCI_0EXPANSION_ROM_BASE_ADDRESS_REMAP               0xf38
-#define PCI_1EXPANSION_ROM_BASE_ADDRESS_REMAP               0xfb8
-#define PCI_0ADDRESS_DECODE_CONTROL                         0xd3c
-#define PCI_1ADDRESS_DECODE_CONTROL                         0xdbc
-
-/****************************************/
-/* PCI Control                          */
-/****************************************/
-
-#define PCI_0COMMAND                                           0xc00
-#define PCI_1COMMAND                                           0xc80
-#define PCI_0MODE                                           0xd00
-#define PCI_1MODE                                           0xd80
-#define PCI_0TIMEOUT_RETRY                                     0xc04
-#define PCI_1TIMEOUT_RETRY                                     0xc84
-#define PCI_0READ_BUFFER_DISCARD_TIMER                      0xd04
-#define PCI_1READ_BUFFER_DISCARD_TIMER                      0xd84
-#define MSI_0TRIGGER_TIMER                                  0xc38
-#define MSI_1TRIGGER_TIMER                                  0xcb8
-#define PCI_0ARBITER_CONTROL                                0x1d00
-#define PCI_1ARBITER_CONTROL                                0x1d80
-/* changing untill here */
-#define PCI_0CROSS_BAR_CONTROL_LOW                           0x1d08
-#define PCI_0CROSS_BAR_CONTROL_HIGH                          0x1d0c
-#define PCI_0CROSS_BAR_TIMEOUT                               0x1d04
-#define PCI_0READ_RESPONSE_CROSS_BAR_CONTROL_LOW             0x1d18
-#define PCI_0READ_RESPONSE_CROSS_BAR_CONTROL_HIGH            0x1d1c
-#define PCI_0SYNC_BARRIER_VIRTUAL_REGISTER                   0x1d10
-#define PCI_0P2P_CONFIGURATION                               0x1d14
-#define PCI_0ACCESS_CONTROL_BASE_0_LOW                       0x1e00
-#define PCI_0ACCESS_CONTROL_BASE_0_HIGH                      0x1e04
-#define PCI_0ACCESS_CONTROL_TOP_0                            0x1e08
-#define PCI_0ACCESS_CONTROL_BASE_1_LOW                       0c1e10
-#define PCI_0ACCESS_CONTROL_BASE_1_HIGH                      0x1e14
-#define PCI_0ACCESS_CONTROL_TOP_1                            0x1e18
-#define PCI_0ACCESS_CONTROL_BASE_2_LOW                       0c1e20
-#define PCI_0ACCESS_CONTROL_BASE_2_HIGH                      0x1e24
-#define PCI_0ACCESS_CONTROL_TOP_2                            0x1e28
-#define PCI_0ACCESS_CONTROL_BASE_3_LOW                       0c1e30
-#define PCI_0ACCESS_CONTROL_BASE_3_HIGH                      0x1e34
-#define PCI_0ACCESS_CONTROL_TOP_3                            0x1e38
-#define PCI_0ACCESS_CONTROL_BASE_4_LOW                       0c1e40
-#define PCI_0ACCESS_CONTROL_BASE_4_HIGH                      0x1e44
-#define PCI_0ACCESS_CONTROL_TOP_4                            0x1e48
-#define PCI_0ACCESS_CONTROL_BASE_5_LOW                       0c1e50
-#define PCI_0ACCESS_CONTROL_BASE_5_HIGH                      0x1e54
-#define PCI_0ACCESS_CONTROL_TOP_5                            0x1e58
-#define PCI_0ACCESS_CONTROL_BASE_6_LOW                       0c1e60
-#define PCI_0ACCESS_CONTROL_BASE_6_HIGH                      0x1e64
-#define PCI_0ACCESS_CONTROL_TOP_6                            0x1e68
-#define PCI_0ACCESS_CONTROL_BASE_7_LOW                       0c1e70
-#define PCI_0ACCESS_CONTROL_BASE_7_HIGH                      0x1e74
-#define PCI_0ACCESS_CONTROL_TOP_7                            0x1e78
-#define PCI_1CROSS_BAR_CONTROL_LOW                           0x1d88
-#define PCI_1CROSS_BAR_CONTROL_HIGH                          0x1d8c
-#define PCI_1CROSS_BAR_TIMEOUT                               0x1d84
-#define PCI_1READ_RESPONSE_CROSS_BAR_CONTROL_LOW             0x1d98
-#define PCI_1READ_RESPONSE_CROSS_BAR_CONTROL_HIGH            0x1d9c
-#define PCI_1SYNC_BARRIER_VIRTUAL_REGISTER                   0x1d90
-#define PCI_1P2P_CONFIGURATION                               0x1d94
-#define PCI_1ACCESS_CONTROL_BASE_0_LOW                       0x1e80
-#define PCI_1ACCESS_CONTROL_BASE_0_HIGH                      0x1e84
-#define PCI_1ACCESS_CONTROL_TOP_0                            0x1e88
-#define PCI_1ACCESS_CONTROL_BASE_1_LOW                       0c1e90
-#define PCI_1ACCESS_CONTROL_BASE_1_HIGH                      0x1e94
-#define PCI_1ACCESS_CONTROL_TOP_1                            0x1e98
-#define PCI_1ACCESS_CONTROL_BASE_2_LOW                       0c1ea0
-#define PCI_1ACCESS_CONTROL_BASE_2_HIGH                      0x1ea4
-#define PCI_1ACCESS_CONTROL_TOP_2                            0x1ea8
-#define PCI_1ACCESS_CONTROL_BASE_3_LOW                       0c1eb0
-#define PCI_1ACCESS_CONTROL_BASE_3_HIGH                      0x1eb4
-#define PCI_1ACCESS_CONTROL_TOP_3                            0x1eb8
-#define PCI_1ACCESS_CONTROL_BASE_4_LOW                       0c1ec0
-#define PCI_1ACCESS_CONTROL_BASE_4_HIGH                      0x1ec4
-#define PCI_1ACCESS_CONTROL_TOP_4                            0x1ec8
-#define PCI_1ACCESS_CONTROL_BASE_5_LOW                       0c1ed0
-#define PCI_1ACCESS_CONTROL_BASE_5_HIGH                      0x1ed4
-#define PCI_1ACCESS_CONTROL_TOP_5                            0x1ed8
-#define PCI_1ACCESS_CONTROL_BASE_6_LOW                       0c1ee0
-#define PCI_1ACCESS_CONTROL_BASE_6_HIGH                      0x1ee4
-#define PCI_1ACCESS_CONTROL_TOP_6                            0x1ee8
-#define PCI_1ACCESS_CONTROL_BASE_7_LOW                       0c1ef0
-#define PCI_1ACCESS_CONTROL_BASE_7_HIGH                      0x1ef4
-#define PCI_1ACCESS_CONTROL_TOP_7                            0x1ef8
-
-/****************************************/
-/* PCI Snoop Control                    */
-/****************************************/
-
-#define PCI_0SNOOP_CONTROL_BASE_0_LOW                        0x1f00
-#define PCI_0SNOOP_CONTROL_BASE_0_HIGH                       0x1f04
-#define PCI_0SNOOP_CONTROL_TOP_0                             0x1f08
-#define PCI_0SNOOP_CONTROL_BASE_1_0_LOW                      0x1f10
-#define PCI_0SNOOP_CONTROL_BASE_1_0_HIGH                     0x1f14
-#define PCI_0SNOOP_CONTROL_TOP_1                             0x1f18
-#define PCI_0SNOOP_CONTROL_BASE_2_0_LOW                      0x1f20
-#define PCI_0SNOOP_CONTROL_BASE_2_0_HIGH                     0x1f24
-#define PCI_0SNOOP_CONTROL_TOP_2                             0x1f28
-#define PCI_0SNOOP_CONTROL_BASE_3_0_LOW                      0x1f30
-#define PCI_0SNOOP_CONTROL_BASE_3_0_HIGH                     0x1f34
-#define PCI_0SNOOP_CONTROL_TOP_3                             0x1f38
-#define PCI_1SNOOP_CONTROL_BASE_0_LOW                        0x1f80
-#define PCI_1SNOOP_CONTROL_BASE_0_HIGH                       0x1f84
-#define PCI_1SNOOP_CONTROL_TOP_0                             0x1f88
-#define PCI_1SNOOP_CONTROL_BASE_1_0_LOW                      0x1f90
-#define PCI_1SNOOP_CONTROL_BASE_1_0_HIGH                     0x1f94
-#define PCI_1SNOOP_CONTROL_TOP_1                             0x1f98
-#define PCI_1SNOOP_CONTROL_BASE_2_0_LOW                      0x1fa0
-#define PCI_1SNOOP_CONTROL_BASE_2_0_HIGH                     0x1fa4
-#define PCI_1SNOOP_CONTROL_TOP_2                             0x1fa8
-#define PCI_1SNOOP_CONTROL_BASE_3_0_LOW                      0x1fb0
-#define PCI_1SNOOP_CONTROL_BASE_3_0_HIGH                     0x1fb4
-#define PCI_1SNOOP_CONTROL_TOP_3                             0x1fb8
-
-/****************************************/
-/* PCI Configuration Address            */
-/****************************************/
-
-#define PCI_0CONFIGURATION_ADDRESS                             0xcf8
-#define PCI_0CONFIGURATION_DATA_VIRTUAL_REGISTER               0xcfc
-#define PCI_1CONFIGURATION_ADDRESS                             0xc78
-#define PCI_1CONFIGURATION_DATA_VIRTUAL_REGISTER               0xc7c
-#define PCI_0INTERRUPT_ACKNOWLEDGE_VIRTUAL_REGISTER            0xc34
-#define PCI_1INTERRUPT_ACKNOWLEDGE_VIRTUAL_REGISTER            0xcb4
-
-/****************************************/
-/* PCI Error Report                     */
-/****************************************/
-
-#define PCI_0SERR_MASK                                          0xc28
-#define PCI_0ERROR_ADDRESS_LOW                               0x1d40
-#define PCI_0ERROR_ADDRESS_HIGH                              0x1d44
-#define PCI_0ERROR_DATA_LOW                                  0x1d48
-#define PCI_0ERROR_DATA_HIGH                                 0x1d4c
-#define PCI_0ERROR_COMMAND                                   0x1d50
-#define PCI_0ERROR_CAUSE                                     0x1d58
-#define PCI_0ERROR_MASK                                      0x1d5c
-
-#define PCI_1SERR_MASK                                          0xca8
-#define PCI_1ERROR_ADDRESS_LOW                               0x1dc0
-#define PCI_1ERROR_ADDRESS_HIGH                              0x1dc4
-#define PCI_1ERROR_DATA_LOW                                  0x1dc8
-#define PCI_1ERROR_DATA_HIGH                                 0x1dcc
-#define PCI_1ERROR_COMMAND                                   0x1dd0
-#define PCI_1ERROR_CAUSE                                     0x1dd8
-#define PCI_1ERROR_MASK                                      0x1ddc
-
-
-/****************************************/
-/* Lslave Debug  (for internal use)     */
-/****************************************/
-
-#define L_SLAVE_X0_ADDRESS                                  0x1d20
-#define L_SLAVE_X0_COMMAND_AND_ID                           0x1d24
-#define L_SLAVE_X1_ADDRESS                                  0x1d28
-#define L_SLAVE_X1_COMMAND_AND_ID                           0x1d2c
-#define L_SLAVE_WRITE_DATA_LOW                              0x1d30
-#define L_SLAVE_WRITE_DATA_HIGH                             0x1d34
-#define L_SLAVE_WRITE_BYTE_ENABLE                           0x1d60
-#define L_SLAVE_READ_DATA_LOW                               0x1d38
-#define L_SLAVE_READ_DATA_HIGH                              0x1d3c
-#define L_SLAVE_READ_ID                                     0x1d64
-
-/****************************************/
-/* PCI Configuration Function 0         */
-/****************************************/
-
-#define PCI_DEVICE_AND_VENDOR_ID                               0x000
-#define PCI_STATUS_AND_COMMAND                                 0x004
-#define PCI_CLASS_CODE_AND_REVISION_ID                         0x008
-#define PCI_BIST_HEADER_TYPE_LATENCY_TIMER_CACHE_LINE          0x00C
-#define PCI_SCS_0_BASE_ADDRESS                                 0x010
-#define PCI_SCS_1_BASE_ADDRESS                                         0x014
-#define PCI_SCS_2_BASE_ADDRESS                                         0x018
-#define PCI_SCS_3_BASE_ADDRESS                                 0x01C
-#define PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS      0x020
-#define PCI_INTERNAL_REGISTERS_I_OMAPPED_BASE_ADDRESS          0x024
-#define PCI_SUBSYSTEM_ID_AND_SUBSYSTEM_VENDOR_ID               0x02C
-#define PCI_EXPANSION_ROM_BASE_ADDRESS_REGISTER                        0x030
-#define PCI_CAPABILTY_LIST_POINTER                          0x034
-#define PCI_INTERRUPT_PIN_AND_LINE                         0x03C
-#define PCI_POWER_MANAGEMENT_CAPABILITY                     0x040
-#define PCI_POWER_MANAGEMENT_STATUS_AND_CONTROL             0x044
-#define PCI_VPD_ADDRESS                                     0x048
-#define PCI_VPD_DATA                                        0X04c
-#define PCI_MSI_MESSAGE_CONTROL                             0x050
-#define PCI_MSI_MESSAGE_ADDRESS                             0x054
-#define PCI_MSI_MESSAGE_UPPER_ADDRESS                       0x058
-#define PCI_MSI_MESSAGE_DATA                                0x05c
-#define PCI_COMPACT_PCI_HOT_SWAP_CAPABILITY                 0x058
-
-/****************************************/
-/* PCI Configuration Function 1         */
-/****************************************/
-
-#define PCI_CS_0_BASE_ADDRESS                                  0x110
-#define PCI_CS_1_BASE_ADDRESS                                  0x114
-#define PCI_CS_2_BASE_ADDRESS                                  0x118
-#define PCI_CS_3_BASE_ADDRESS                                  0x11c
-#define PCI_BOOTCS_BASE_ADDRESS                            0x120
-
-/****************************************/
-/* PCI Configuration Function 2         */
-/****************************************/
-
-#define PCI_P2P_MEM0_BASE_ADDRESS                              0x210
-#define PCI_P2P_MEM1_BASE_ADDRESS                              0x214
-#define PCI_P2P_I_O_BASE_ADDRESS                               0x218
-#define PCI_CPU_BASE_ADDRESS                                   0x21c
-
-/****************************************/
-/* PCI Configuration Function 4         */
-/****************************************/
-
-#define PCI_DAC_SCS_0_BASE_ADDRESS_LOW                                 0x410
-#define PCI_DAC_SCS_0_BASE_ADDRESS_HIGH                                0x414
-#define PCI_DAC_SCS_1_BASE_ADDRESS_LOW                         0x418
-#define PCI_DAC_SCS_1_BASE_ADDRESS_HIGH                    0x41c
-#define PCI_DAC_P2P_MEM0_BASE_ADDRESS_LOW                          0x420
-#define PCI_DAC_P2P_MEM0_BASE_ADDRESS_HIGH                         0x424
-
-
-/****************************************/
-/* PCI Configuration Function 5         */
-/****************************************/
-
-#define PCI_DAC_SCS_2_BASE_ADDRESS_LOW                                 0x510
-#define PCI_DAC_SCS_2_BASE_ADDRESS_HIGH                                0x514
-#define PCI_DAC_SCS_3_BASE_ADDRESS_LOW                         0x518
-#define PCI_DAC_SCS_3_BASE_ADDRESS_HIGH                        0x51c
-#define PCI_DAC_P2P_MEM1_BASE_ADDRESS_LOW                          0x520
-#define PCI_DAC_P2P_MEM1_BASE_ADDRESS_HIGH                         0x524
-
-
-/****************************************/
-/* PCI Configuration Function 6         */
-/****************************************/
-
-#define PCI_DAC_CS_0_BASE_ADDRESS_LOW                          0x610
-#define PCI_DAC_CS_0_BASE_ADDRESS_HIGH                         0x614
-#define PCI_DAC_CS_1_BASE_ADDRESS_LOW                          0x618
-#define PCI_DAC_CS_1_BASE_ADDRESS_HIGH                         0x61c
-#define PCI_DAC_CS_2_BASE_ADDRESS_LOW                          0x620
-#define PCI_DAC_CS_2_BASE_ADDRESS_HIGH                         0x624
-
-/****************************************/
-/* PCI Configuration Function 7         */
-/****************************************/
-
-#define PCI_DAC_CS_3_BASE_ADDRESS_LOW                          0x710
-#define PCI_DAC_CS_3_BASE_ADDRESS_HIGH                         0x714
-#define PCI_DAC_BOOTCS_BASE_ADDRESS_LOW                        0x718
-#define PCI_DAC_BOOTCS_BASE_ADDRESS_HIGH                       0x71c
-#define PCI_DAC_CPU_BASE_ADDRESS_LOW                           0x720
-#define PCI_DAC_CPU_BASE_ADDRESS_HIGH                          0x724
-
-/****************************************/
-/* Interrupts                          */
-/****************************************/
-
-#define LOW_INTERRUPT_CAUSE_REGISTER                                   0xc18
-#define HIGH_INTERRUPT_CAUSE_REGISTER                          0xc68
-#define CPU_INTERRUPT_MASK_REGISTER_LOW                                0xc1c
-#define CPU_INTERRUPT_MASK_REGISTER_HIGH                       0xc6c
-#define CPU_SELECT_CAUSE_REGISTER                              0xc70
-#define PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW                 0xc24
-#define PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH                        0xc64
-#define PCI_0SELECT_CAUSE                                   0xc74
-#define PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW                 0xca4
-#define PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH                        0xce4
-#define PCI_1SELECT_CAUSE                                   0xcf4
-#define CPU_INT_0_MASK                                      0xe60
-#define CPU_INT_1_MASK                                      0xe64
-#define CPU_INT_2_MASK                                      0xe68
-#define CPU_INT_3_MASK                                      0xe6c
-
-/****************************************/
-/* I20 Support registers               */
-/****************************************/
-
-#define INBOUND_MESSAGE_REGISTER0_PCI0_SIDE                    0x010
-#define INBOUND_MESSAGE_REGISTER1_PCI0_SIDE                    0x014
-#define OUTBOUND_MESSAGE_REGISTER0_PCI0_SIDE                   0x018
-#define OUTBOUND_MESSAGE_REGISTER1_PCI0_SIDE                   0x01C
-#define INBOUND_DOORBELL_REGISTER_PCI0_SIDE                    0x020
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_PCI0_SIDE             0x024
-#define INBOUND_INTERRUPT_MASK_REGISTER_PCI0_SIDE              0x028
-#define OUTBOUND_DOORBELL_REGISTER_PCI0_SIDE                   0x02C
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_PCI0_SIDE            0x030
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_PCI0_SIDE             0x034
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI0_SIDE                  0x040
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI0_SIDE         0x044
-#define QUEUE_CONTROL_REGISTER_PCI0_SIDE                       0x050
-#define QUEUE_BASE_ADDRESS_REGISTER_PCI0_SIDE                  0x054
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_PCI0_SIDE           0x060
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_PCI0_SIDE           0x064
-#define INBOUND_POST_HEAD_POINTER_REGISTER_PCI0_SIDE           0x068
-#define INBOUND_POST_TAIL_POINTER_REGISTER_PCI0_SIDE           0x06C
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_PCI0_SIDE          0x070
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_PCI0_SIDE          0x074
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_PCI0_SIDE          0x0F8
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_PCI0_SIDE          0x0FC
-
-#define INBOUND_MESSAGE_REGISTER0_PCI1_SIDE                            0x090
-#define INBOUND_MESSAGE_REGISTER1_PCI1_SIDE                            0x094
-#define OUTBOUND_MESSAGE_REGISTER0_PCI1_SIDE                           0x098
-#define OUTBOUND_MESSAGE_REGISTER1_PCI1_SIDE                           0x09C
-#define INBOUND_DOORBELL_REGISTER_PCI1_SIDE                            0x0A0
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_PCI1_SIDE             0x0A4
-#define INBOUND_INTERRUPT_MASK_REGISTER_PCI1_SIDE                      0x0A8
-#define OUTBOUND_DOORBELL_REGISTER_PCI1_SIDE                           0x0AC
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_PCI1_SIDE            0x0B0
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_PCI1_SIDE             0x0B4
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI1_SIDE                  0x0C0
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI1_SIDE         0x0C4
-#define QUEUE_CONTROL_REGISTER_PCI1_SIDE                               0x0D0
-#define QUEUE_BASE_ADDRESS_REGISTER_PCI1_SIDE                          0x0D4
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_PCI1_SIDE           0x0E0
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_PCI1_SIDE           0x0E4
-#define INBOUND_POST_HEAD_POINTER_REGISTER_PCI1_SIDE           0x0E8
-#define INBOUND_POST_TAIL_POINTER_REGISTER_PCI1_SIDE           0x0EC
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_PCI1_SIDE          0x0F0
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_PCI1_SIDE          0x0F4
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_PCI1_SIDE          0x078
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_PCI1_SIDE          0x07C
-
-#define INBOUND_MESSAGE_REGISTER0_CPU0_SIDE                            0X1C10
-#define INBOUND_MESSAGE_REGISTER1_CPU0_SIDE                            0X1C14
-#define OUTBOUND_MESSAGE_REGISTER0_CPU0_SIDE                           0X1C18
-#define OUTBOUND_MESSAGE_REGISTER1_CPU0_SIDE                           0X1C1C
-#define INBOUND_DOORBELL_REGISTER_CPU0_SIDE                            0X1C20
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_CPU0_SIDE             0X1C24
-#define INBOUND_INTERRUPT_MASK_REGISTER_CPU0_SIDE                      0X1C28
-#define OUTBOUND_DOORBELL_REGISTER_CPU0_SIDE                           0X1C2C
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_CPU0_SIDE            0X1C30
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_CPU0_SIDE             0X1C34
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU0_SIDE                  0X1C40
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU0_SIDE         0X1C44
-#define QUEUE_CONTROL_REGISTER_CPU0_SIDE                               0X1C50
-#define QUEUE_BASE_ADDRESS_REGISTER_CPU0_SIDE                          0X1C54
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_CPU0_SIDE           0X1C60
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_CPU0_SIDE           0X1C64
-#define INBOUND_POST_HEAD_POINTER_REGISTER_CPU0_SIDE           0X1C68
-#define INBOUND_POST_TAIL_POINTER_REGISTER_CPU0_SIDE           0X1C6C
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_CPU0_SIDE          0X1C70
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_CPU0_SIDE          0X1C74
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_CPU0_SIDE          0X1CF8
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_CPU0_SIDE          0X1CFC
-
-#define INBOUND_MESSAGE_REGISTER0_CPU1_SIDE                            0X1C90
-#define INBOUND_MESSAGE_REGISTER1_CPU1_SIDE                            0X1C94
-#define OUTBOUND_MESSAGE_REGISTER0_CPU1_SIDE                           0X1C98
-#define OUTBOUND_MESSAGE_REGISTER1_CPU1_SIDE                           0X1C9C
-#define INBOUND_DOORBELL_REGISTER_CPU1_SIDE                            0X1CA0
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_CPU1_SIDE             0X1CA4
-#define INBOUND_INTERRUPT_MASK_REGISTER_CPU1_SIDE                      0X1CA8
-#define OUTBOUND_DOORBELL_REGISTER_CPU1_SIDE                           0X1CAC
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_CPU1_SIDE            0X1CB0
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_CPU1_SIDE             0X1CB4
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU1_SIDE                  0X1CC0
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU1_SIDE         0X1CC4
-#define QUEUE_CONTROL_REGISTER_CPU1_SIDE                               0X1CD0
-#define QUEUE_BASE_ADDRESS_REGISTER_CPU1_SIDE                          0X1CD4
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_CPU1_SIDE           0X1CE0
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_CPU1_SIDE           0X1CE4
-#define INBOUND_POST_HEAD_POINTER_REGISTER_CPU1_SIDE           0X1CE8
-#define INBOUND_POST_TAIL_POINTER_REGISTER_CPU1_SIDE           0X1CEC
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_CPU1_SIDE          0X1CF0
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_CPU1_SIDE          0X1CF4
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_CPU1_SIDE          0X1C78
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_CPU1_SIDE          0X1C7C
-
-/****************************************/
-/* Communication Unit Registers         */
-/****************************************/
-
-#define ETHERNET_0_ADDRESS_CONTROL_LOW
-#define ETHERNET_0_ADDRESS_CONTROL_HIGH                     0xf204
-#define ETHERNET_0_RECEIVE_BUFFER_PCI_HIGH_ADDRESS          0xf208
-#define ETHERNET_0_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS         0xf20c
-#define ETHERNET_0_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS      0xf210
-#define ETHERNET_0_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS     0xf214
-#define ETHERNET_0_HASH_TABLE_PCI_HIGH_ADDRESS              0xf218
-#define ETHERNET_1_ADDRESS_CONTROL_LOW                      0xf220
-#define ETHERNET_1_ADDRESS_CONTROL_HIGH                     0xf224
-#define ETHERNET_1_RECEIVE_BUFFER_PCI_HIGH_ADDRESS          0xf228
-#define ETHERNET_1_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS         0xf22c
-#define ETHERNET_1_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS      0xf230
-#define ETHERNET_1_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS     0xf234
-#define ETHERNET_1_HASH_TABLE_PCI_HIGH_ADDRESS              0xf238
-#define ETHERNET_2_ADDRESS_CONTROL_LOW                      0xf240
-#define ETHERNET_2_ADDRESS_CONTROL_HIGH                     0xf244
-#define ETHERNET_2_RECEIVE_BUFFER_PCI_HIGH_ADDRESS          0xf248
-#define ETHERNET_2_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS         0xf24c
-#define ETHERNET_2_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS      0xf250
-#define ETHERNET_2_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS     0xf254
-#define ETHERNET_2_HASH_TABLE_PCI_HIGH_ADDRESS              0xf258
-#define MPSC_0_ADDRESS_CONTROL_LOW                          0xf280
-#define MPSC_0_ADDRESS_CONTROL_HIGH                         0xf284
-#define MPSC_0_RECEIVE_BUFFER_PCI_HIGH_ADDRESS              0xf288
-#define MPSC_0_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS             0xf28c
-#define MPSC_0_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS          0xf290
-#define MPSC_0_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS         0xf294
-#define MPSC_1_ADDRESS_CONTROL_LOW                          0xf2a0
-#define MPSC_1_ADDRESS_CONTROL_HIGH                         0xf2a4
-#define MPSC_1_RECEIVE_BUFFER_PCI_HIGH_ADDRESS              0xf2a8
-#define MPSC_1_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS             0xf2ac
-#define MPSC_1_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS          0xf2b0
-#define MPSC_1_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS         0xf2b4
-#define MPSC_2_ADDRESS_CONTROL_LOW                          0xf2c0
-#define MPSC_2_ADDRESS_CONTROL_HIGH                         0xf2c4
-#define MPSC_2_RECEIVE_BUFFER_PCI_HIGH_ADDRESS              0xf2c8
-#define MPSC_2_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS             0xf2cc
-#define MPSC_2_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS          0xf2d0
-#define MPSC_2_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS         0xf2d4
-#define SERIAL_INIT_PCI_HIGH_ADDRESS                        0xf320
-#define SERIAL_INIT_LAST_DATA                               0xf324
-#define SERIAL_INIT_STATUS_AND_CONTROL                      0xf328
-#define COMM_UNIT_ARBITER_CONTROL                           0xf300
-#define COMM_UNIT_CROSS_BAR_TIMEOUT                         0xf304
-#define COMM_UNIT_INTERRUPT_CAUSE                           0xf310
-#define COMM_UNIT_INTERRUPT_MASK                            0xf314
-#define COMM_UNIT_ERROR_ADDRESS                             0xf314
-
-/****************************************/
-/* Cunit Debug  (for internal use)     */
-/****************************************/
-
-#define CUNIT_ADDRESS                                       0xf340
-#define CUNIT_COMMAND_AND_ID                                0xf344
-#define CUNIT_WRITE_DATA_LOW                                0xf348
-#define CUNIT_WRITE_DATA_HIGH                               0xf34c
-#define CUNIT_WRITE_BYTE_ENABLE                             0xf358
-#define CUNIT_READ_DATA_LOW                                 0xf350
-#define CUNIT_READ_DATA_HIGH                                0xf354
-#define CUNIT_READ_ID                                       0xf35c
-
-/****************************************/
-/* Fast Ethernet Unit Registers         */
-/****************************************/
-
-/* Ethernet */
-
-#define ETHERNET_PHY_ADDRESS_REGISTER                       0x2000
-#define ETHERNET_SMI_REGISTER                               0x2010
-
-/* Ethernet 0 */
-
-#define ETHERNET0_PORT_CONFIGURATION_REGISTER               0x2400
-#define ETHERNET0_PORT_CONFIGURATION_EXTEND_REGISTER        0x2408
-#define ETHERNET0_PORT_COMMAND_REGISTER                     0x2410
-#define ETHERNET0_PORT_STATUS_REGISTER                      0x2418
-#define ETHERNET0_SERIAL_PARAMETRS_REGISTER                 0x2420
-#define ETHERNET0_HASH_TABLE_POINTER_REGISTER               0x2428
-#define ETHERNET0_FLOW_CONTROL_SOURCE_ADDRESS_LOW           0x2430
-#define ETHERNET0_FLOW_CONTROL_SOURCE_ADDRESS_HIGH          0x2438
-#define ETHERNET0_SDMA_CONFIGURATION_REGISTER               0x2440
-#define ETHERNET0_SDMA_COMMAND_REGISTER                     0x2448
-#define ETHERNET0_INTERRUPT_CAUSE_REGISTER                  0x2450
-#define ETHERNET0_INTERRUPT_MASK_REGISTER                   0x2458
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER0              0x2480
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER1              0x2484
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER2              0x2488
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER3              0x248c
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER0            0x24a0
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER1            0x24a4
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER2            0x24a8
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER3            0x24ac
-#define ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER0            0x24e0
-#define ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER1            0x24e4
-#define ETHERNET0_MIB_COUNTER_BASE                          0x2500
-
-/* Ethernet 1 */
-
-#define ETHERNET1_PORT_CONFIGURATION_REGISTER               0x2800
-#define ETHERNET1_PORT_CONFIGURATION_EXTEND_REGISTER        0x2808
-#define ETHERNET1_PORT_COMMAND_REGISTER                     0x2810
-#define ETHERNET1_PORT_STATUS_REGISTER                      0x2818
-#define ETHERNET1_SERIAL_PARAMETRS_REGISTER                 0x2820
-#define ETHERNET1_HASH_TABLE_POINTER_REGISTER               0x2828
-#define ETHERNET1_FLOW_CONTROL_SOURCE_ADDRESS_LOW           0x2830
-#define ETHERNET1_FLOW_CONTROL_SOURCE_ADDRESS_HIGH          0x2838
-#define ETHERNET1_SDMA_CONFIGURATION_REGISTER               0x2840
-#define ETHERNET1_SDMA_COMMAND_REGISTER                     0x2848
-#define ETHERNET1_INTERRUPT_CAUSE_REGISTER                  0x2850
-#define ETHERNET1_INTERRUPT_MASK_REGISTER                   0x2858
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER0              0x2880
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER1              0x2884
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER2              0x2888
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER3              0x288c
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER0            0x28a0
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER1            0x28a4
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER2            0x28a8
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER3            0x28ac
-#define ETHERNET1_CURRENT_TX_DESCRIPTOR_POINTER0            0x28e0
-#define ETHERNET1_CURRENT_TX_DESCRIPTOR_POINTER1            0x28e4
-#define ETHERNET1_MIB_COUNTER_BASE                          0x2900
-
-/* Ethernet 2 */
-
-#define ETHERNET2_PORT_CONFIGURATION_REGISTER               0x2c00
-#define ETHERNET2_PORT_CONFIGURATION_EXTEND_REGISTER        0x2c08
-#define ETHERNET2_PORT_COMMAND_REGISTER                     0x2c10
-#define ETHERNET2_PORT_STATUS_REGISTER                      0x2c18
-#define ETHERNET2_SERIAL_PARAMETRS_REGISTER                 0x2c20
-#define ETHERNET2_HASH_TABLE_POINTER_REGISTER               0x2c28
-#define ETHERNET2_FLOW_CONTROL_SOURCE_ADDRESS_LOW           0x2c30
-#define ETHERNET2_FLOW_CONTROL_SOURCE_ADDRESS_HIGH          0x2c38
-#define ETHERNET2_SDMA_CONFIGURATION_REGISTER               0x2c40
-#define ETHERNET2_SDMA_COMMAND_REGISTER                     0x2c48
-#define ETHERNET2_INTERRUPT_CAUSE_REGISTER                  0x2c50
-#define ETHERNET2_INTERRUPT_MASK_REGISTER                   0x2c58
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER0              0x2c80
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER1              0x2c84
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER2              0x2c88
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER3              0x2c8c
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER0            0x2ca0
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER1            0x2ca4
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER2            0x2ca8
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER3            0x2cac
-#define ETHERNET2_CURRENT_TX_DESCRIPTOR_POINTER0            0x2ce0
-#define ETHERNET2_CURRENT_TX_DESCRIPTOR_POINTER1            0x2ce4
-#define ETHERNET2_MIB_COUNTER_BASE                          0x2d00
-
-/****************************************/
-/* SDMA Registers                       */
-/****************************************/
-
-#define SDMA_GROUP_CONFIGURATION_REGISTER                   0xb1f0
-#define CHANNEL0_CONFIGURATION_REGISTER                     0x4000
-#define CHANNEL0_COMMAND_REGISTER                           0x4008
-#define CHANNEL0_RX_CMD_STATUS                              0x4800
-#define CHANNEL0_RX_PACKET_AND_BUFFER_SIZES                 0x4804
-#define CHANNEL0_RX_BUFFER_POINTER                          0x4808
-#define CHANNEL0_RX_NEXT_POINTER                            0x480c
-#define CHANNEL0_CURRENT_RX_DESCRIPTOR_POINTER              0x4810
-#define CHANNEL0_TX_CMD_STATUS                              0x4C00
-#define CHANNEL0_TX_PACKET_SIZE                             0x4C04
-#define CHANNEL0_TX_BUFFER_POINTER                          0x4C08
-#define CHANNEL0_TX_NEXT_POINTER                            0x4C0c
-#define CHANNEL0_CURRENT_TX_DESCRIPTOR_POINTER              0x4c10
-#define CHANNEL0_FIRST_TX_DESCRIPTOR_POINTER                0x4c14
-#define CHANNEL1_CONFIGURATION_REGISTER                     0x6000
-#define CHANNEL1_COMMAND_REGISTER                           0x6008
-#define CHANNEL1_RX_CMD_STATUS                              0x6800
-#define CHANNEL1_RX_PACKET_AND_BUFFER_SIZES                 0x6804
-#define CHANNEL1_RX_BUFFER_POINTER                          0x6808
-#define CHANNEL1_RX_NEXT_POINTER                            0x680c
-#define CHANNEL1_CURRENT_RX_DESCRIPTOR_POINTER              0x6810
-#define CHANNEL1_TX_CMD_STATUS                              0x6C00
-#define CHANNEL1_TX_PACKET_SIZE                             0x6C04
-#define CHANNEL1_TX_BUFFER_POINTER                          0x6C08
-#define CHANNEL1_TX_NEXT_POINTER                            0x6C0c
-#define CHANNEL1_CURRENT_RX_DESCRIPTOR_POINTER              0x6810
-#define CHANNEL1_CURRENT_TX_DESCRIPTOR_POINTER              0x6c10
-#define CHANNEL1_FIRST_TX_DESCRIPTOR_POINTER                0x6c14
-
-/* SDMA Interrupt */
-
-#define SDMA_CAUSE                                          0xb820
-#define SDMA_MASK                                           0xb8a0
-
-
-/****************************************/
-/* Baude Rate Generators Registers      */
-/****************************************/
-
-/* BRG 0 */
-
-#define BRG0_CONFIGURATION_REGISTER                         0xb200
-#define BRG0_BAUDE_TUNING_REGISTER                          0xb204
-
-/* BRG 1 */
-
-#define BRG1_CONFIGURATION_REGISTER                         0xb208
-#define BRG1_BAUDE_TUNING_REGISTER                          0xb20c
-
-/* BRG 2 */
-
-#define BRG2_CONFIGURATION_REGISTER                         0xb210
-#define BRG2_BAUDE_TUNING_REGISTER                          0xb214
-
-/* BRG Interrupts */
-
-#define BRG_CAUSE_REGISTER                                  0xb834
-#define BRG_MASK_REGISTER                                   0xb8b4
-
-/* MISC */
-
-#define MAIN_ROUTING_REGISTER                               0xb400
-#define RECEIVE_CLOCK_ROUTING_REGISTER                      0xb404
-#define TRANSMIT_CLOCK_ROUTING_REGISTER                     0xb408
-#define COMM_UNIT_ARBITER_CONFIGURATION_REGISTER            0xb40c
-#define WATCHDOG_CONFIGURATION_REGISTER                     0xb410
-#define WATCHDOG_VALUE_REGISTER                             0xb414
-
-
-/****************************************/
-/* Flex TDM Registers                   */
-/****************************************/
-
-/* FTDM Port */
-
-#define FLEXTDM_TRANSMIT_READ_POINTER                       0xa800
-#define FLEXTDM_RECEIVE_READ_POINTER                        0xa804
-#define FLEXTDM_CONFIGURATION_REGISTER                      0xa808
-#define FLEXTDM_AUX_CHANNELA_TX_REGISTER                    0xa80c
-#define FLEXTDM_AUX_CHANNELA_RX_REGISTER                    0xa810
-#define FLEXTDM_AUX_CHANNELB_TX_REGISTER                    0xa814
-#define FLEXTDM_AUX_CHANNELB_RX_REGISTER                    0xa818
-
-/* FTDM Interrupts */
-
-#define FTDM_CAUSE_REGISTER                                 0xb830
-#define FTDM_MASK_REGISTER                                  0xb8b0
-
-
-/****************************************/
-/* GPP Interface Registers              */
-/****************************************/
-
-#define GPP_IO_CONTROL                                      0xf100
-#define GPP_LEVEL_CONTROL                                   0xf110
-#define GPP_VALUE                                           0xf104
-#define GPP_INTERRUPT_CAUSE                                 0xf108
-#define GPP_INTERRUPT_MASK                                  0xf10c
-
-#define MPP_CONTROL0                                        0xf000
-#define MPP_CONTROL1                                        0xf004
-#define MPP_CONTROL2                                        0xf008
-#define MPP_CONTROL3                                        0xf00c
-#define DEBUG_PORT_MULTIPLEX                                0xf014
-#define SERIAL_PORT_MULTIPLEX                               0xf010
-
-/****************************************/
-/* I2C Registers                        */
-/****************************************/
-
-#define I2C_SLAVE_ADDRESS                                   0xc000
-#define I2C_EXTENDED_SLAVE_ADDRESS                          0xc040
-#define I2C_DATA                                            0xc004
-#define I2C_CONTROL                                         0xc008
-#define I2C_STATUS_BAUDE_RATE                               0xc00C
-#define I2C_SOFT_RESET                                      0xc01c
-
-/****************************************/
-/* MPSC Registers                       */
-/****************************************/
-
-/* MPSC0  */
-
-#define MPSC0_MAIN_CONFIGURATION_LOW                        0x8000
-#define MPSC0_MAIN_CONFIGURATION_HIGH                       0x8004
-#define MPSC0_PROTOCOL_CONFIGURATION                        0x8008
-#define CHANNEL0_REGISTER1                                  0x800c
-#define CHANNEL0_REGISTER2                                  0x8010
-#define CHANNEL0_REGISTER3                                  0x8014
-#define CHANNEL0_REGISTER4                                  0x8018
-#define CHANNEL0_REGISTER5                                  0x801c
-#define CHANNEL0_REGISTER6                                  0x8020
-#define CHANNEL0_REGISTER7                                  0x8024
-#define CHANNEL0_REGISTER8                                  0x8028
-#define CHANNEL0_REGISTER9                                  0x802c
-#define CHANNEL0_REGISTER10                                 0x8030
-#define CHANNEL0_REGISTER11                                 0x8034
-
-/* MPSC1  */
-
-#define MPSC1_MAIN_CONFIGURATION_LOW                        0x9000
-#define MPSC1_MAIN_CONFIGURATION_HIGH                       0x9004
-#define MPSC1_PROTOCOL_CONFIGURATION                        0x9008
-#define CHANNEL1_REGISTER1                                  0x900c
-#define CHANNEL1_REGISTER2                                  0x9010
-#define CHANNEL1_REGISTER3                                  0x9014
-#define CHANNEL1_REGISTER4                                  0x9018
-#define CHANNEL1_REGISTER5                                  0x901c
-#define CHANNEL1_REGISTER6                                  0x9020
-#define CHANNEL1_REGISTER7                                  0x9024
-#define CHANNEL1_REGISTER8                                  0x9028
-#define CHANNEL1_REGISTER9                                  0x902c
-#define CHANNEL1_REGISTER10                                 0x9030
-#define CHANNEL1_REGISTER11                                 0x9034
-
-/* MPSCs Interupts  */
-
-#define MPSC0_CAUSE                                         0xb804
-#define MPSC0_MASK                                          0xb884
-#define MPSC1_CAUSE                                         0xb80c
-#define MPSC1_MASK                                          0xb88c
-
-#endif /* __INCgt64240rh */
diff --git a/arch/mips/momentum/ocelot_g/gt64240_dep.h b/arch/mips/momentum/ocelot_g/gt64240_dep.h
deleted file mode 100644 (file)
index f51bf0d..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/***********************************************************************
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/gt64240/gt64240-dep.h
- *     Board-dependent definitions for GT-64120 chip.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- ***********************************************************************
- */
-
-#ifndef _ASM_GT64240_DEP_H
-#define _ASM_GT64240_DEP_H
-
-#include <asm/addrspace.h>             /* for KSEG1ADDR() */
-#include <asm/byteorder.h>             /* for cpu_to_le32() */
-
-/*
- * PCI address allocation
- */
-#if 0
-#define GT_PCI_MEM_BASE    (0x22000000)
-#define GT_PCI_MEM_SIZE    GT_DEF_PCI0_MEM0_SIZE
-#define GT_PCI_IO_BASE     (0x20000000)
-#define GT_PCI_IO_SIZE     GT_DEF_PCI0_IO_SIZE
-#endif
-
-extern unsigned long gt64240_base;
-
-#define GT64240_BASE       (gt64240_base)
-
-/*
- * Because of an error/peculiarity in the Galileo chip, we need to swap the
- * bytes when running bigendian.
- */
-
-#define GT_WRITE(ofs, data)  \
-        *(volatile u32 *)(GT64240_BASE+(ofs)) = cpu_to_le32(data)
-#define GT_READ(ofs, data)   \
-        *(data) = le32_to_cpu(*(volatile u32 *)(GT64240_BASE+(ofs)))
-#define GT_READ_DATA(ofs)    \
-        le32_to_cpu(*(volatile u32 *)(GT64240_BASE+(ofs)))
-
-#define GT_WRITE_16(ofs, data)  \
-        *(volatile u16 *)(GT64240_BASE+(ofs)) = cpu_to_le16(data)
-#define GT_READ_16(ofs, data)   \
-        *(data) = le16_to_cpu(*(volatile u16 *)(GT64240_BASE+(ofs)))
-
-#define GT_WRITE_8(ofs, data)  \
-        *(volatile u8 *)(GT64240_BASE+(ofs)) = data
-#define GT_READ_8(ofs, data)   \
-        *(data) = *(volatile u8 *)(GT64240_BASE+(ofs))
-
-#endif  /* _ASM_GT64120_MOMENCO_OCELOT_GT64120_DEP_H */
diff --git a/arch/mips/momentum/ocelot_g/pci-irq.c b/arch/mips/momentum/ocelot_g/pci-irq.c
deleted file mode 100644 (file)
index e300e15..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2002 Momentum Computer Inc.
- * Author: Matthew Dharm <mdharm@momenco.com>
- *
- * Based on work for the Linux port to the Ocelot board, which is
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/momentum/ocelot_g/pci.c
- *     Board-specific PCI routines for gt64240 controller.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/pci.h>
-
-
-void __devinit gt64240_board_pcibios_fixup_bus(struct pci_bus *bus)
-{
-       struct pci_bus *current_bus = bus;
-       struct pci_dev *devices;
-       struct list_head *devices_link;
-       u16 cmd;
-
-       /* loop over all known devices on this bus */
-       list_for_each(devices_link, &(current_bus->devices)) {
-
-               devices = pci_dev_b(devices_link);
-               if (devices == NULL)
-                       continue;
-
-               if ((current_bus->number == 0) &&
-                               PCI_SLOT(devices->devfn) == 1) {
-                       /* Intel 82543 Gigabit MAC */
-                       devices->irq = 2;       /* irq_nr is 2 for INT0 */
-               } else if ((current_bus->number == 0) &&
-                               PCI_SLOT(devices->devfn) == 2) {
-                       /* Intel 82543 Gigabit MAC */
-                       devices->irq = 3;       /* irq_nr is 3 for INT1 */
-               } else if ((current_bus->number == 1) &&
-                               PCI_SLOT(devices->devfn) == 3) {
-                       /* Intel 21555 bridge */
-                       devices->irq = 5;       /* irq_nr is 8 for INT6 */
-               } else if ((current_bus->number == 1) &&
-                               PCI_SLOT(devices->devfn) == 4) {
-                       /* PMC Slot */
-                       devices->irq = 9;       /* irq_nr is 9 for INT7 */
-               } else {
-                       /* We don't have assign interrupts for other devices. */
-                       devices->irq = 0xff;
-               }
-
-               /* Assign an interrupt number for the device */
-               bus->ops->write(current_bus, devices,
-                       PCI_INTERRUPT_LINE, 1, devices->irq);
-
-               /* enable master for everything but the GT-64240 */
-               if (((current_bus->number != 0) && (current_bus->number != 1))
-                               || (PCI_SLOT(devices->devfn) != 0)) {
-                       bus->ops->read(current_bus, devices,
-                                       PCI_COMMAND, 2, &cmd);
-                       cmd |= PCI_COMMAND_MASTER;
-                       bus->ops->write(current_bus, devices,
-                                       PCI_COMMAND, 2, cmd);
-               }
-       }
-}
diff --git a/arch/mips/pci/fixup-eagle.c b/arch/mips/pci/fixup-eagle.c
deleted file mode 100644 (file)
index ac6f9d8..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * arch/mips/vr41xx/nec-eagle/pci_fixup.c
- *
- * The NEC Eagle/Hawk Board specific PCI fixups.
- *
- * Author: Yoichi Yuasa <you@mvista.com, or source@mvista.com>
- *
- * 2001-2002,2004 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/vr41xx/eagle.h>
-#include <asm/vr41xx/vrc4173.h>
-
-/*
- * Shortcuts
- */
-#define INTA   CP_INTA_IRQ
-#define INTB   CP_INTB_IRQ
-#define INTC   CP_INTC_IRQ
-#define INTD   CP_INTD_IRQ
-#define PCMCIA1        VRC4173_PCMCIA1_IRQ
-#define PCMCIA2        VRC4173_PCMCIA2_IRQ
-#define LAN    LANINTA_IRQ
-#define SLOT   PCISLOT_IRQ
-
-static char irq_tab_eagle[][5] __initdata = {
- [ 8] = { 0,    INTA, INTB, INTC, INTD },
- [ 9] = { 0,    INTD, INTA, INTB, INTC },
- [10] = { 0,    INTC, INTD, INTA, INTB },
- [12] = { 0, PCMCIA1,    0,    0,    0 },
- [13] = { 0, PCMCIA2,    0,    0,    0 },
- [28] = { 0,     LAN,    0,    0,    0 },
- [29] = { 0,    SLOT, INTB, INTC, INTD },
-};
-
-/*
- * This is a multifunction device.
- */
-static char irq_func_tab[] __initdata = {
-       VRC4173_CASCADE_IRQ,
-       VRC4173_AC97_IRQ,
-       VRC4173_USB_IRQ
-};
-
-int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-       if (slot == 30)
-               return irq_func_tab[PCI_FUNC(dev->devfn)];
-
-       return irq_tab_eagle[slot][pin];
-}
-
-struct pci_fixup pcibios_fixups[] __initdata = {
-       {       .pass = 0,      },
-};
diff --git a/arch/mips/pci/fixup-mv64340.c b/arch/mips/pci/fixup-mv64340.c
deleted file mode 100644 (file)
index fa78b9b..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Marvell MV64340 interrupt fixup code.
- *
- * Marvell wants an NDA for their docs so this was written without
- * documentation.  You've been warned.
- *
- * Copyright (C) 2004 Ralf Baechle
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/mipsregs.h>
-#include <asm/pci_channel.h>
-
-/*
- * WARNING: Example of how _NOT_ to do it.
- */
-int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-       int bus = dev->bus->number;
-
-       if (bus == 0 && slot == 1)
-               return 3;       /* PCI-X A */
-       if (bus == 0 && slot == 2)
-               return 4;       /* PCI-X B */
-       if (bus == 1 && slot == 1)
-               return 5;       /* PCI A */
-       if (bus == 1 && slot == 2)
-               return 6;       /* PCI B */
-
-return 0;
-       panic("Whooops in pcibios_map_irq");
-}
-
-struct pci_fixup pcibios_fixups[] = {
-       {0}
-};
diff --git a/arch/mips/pci/fixup-tb0229.c b/arch/mips/pci/fixup-tb0229.c
deleted file mode 100644 (file)
index 8109c05..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * FILE NAME
- *     arch/mips/vr41xx/tanbac-tb0229/pci_fixup.c
- *
- * BRIEF MODULE DESCRIPTION
- *     The TANBAC TB0229(VR4131DIMM) specific PCI fixups.
- *
- * Copyright 2003 Megasolution Inc.
- *                matsu@megasolution.jp
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2 of the License, or (at your
- *  option) any later version.
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/vr41xx/tb0229.h>
-
-void __init pcibios_fixup_irqs(void)
-{
-#ifdef CONFIG_TANBAC_TB0219
-       struct pci_dev *dev = NULL;
-       u8 slot;
-
-       while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-               slot = PCI_SLOT(dev->devfn);
-               dev->irq = 0;
-
-               switch (slot) {
-               case 12:
-                       vr41xx_set_irq_trigger(TB0219_PCI_SLOT1_PIN,
-                                              TRIGGER_LEVEL,
-                                              SIGNAL_THROUGH);
-                       vr41xx_set_irq_level(TB0219_PCI_SLOT1_PIN,
-                                            LEVEL_LOW);
-                       dev->irq = TB0219_PCI_SLOT1_IRQ;
-                       break;
-               case 13:
-                       vr41xx_set_irq_trigger(TB0219_PCI_SLOT2_PIN,
-                                              TRIGGER_LEVEL,
-                                              SIGNAL_THROUGH);
-                       vr41xx_set_irq_level(TB0219_PCI_SLOT2_PIN,
-                                            LEVEL_LOW);
-                       dev->irq = TB0219_PCI_SLOT2_IRQ;
-                       break;
-               case 14:
-                       vr41xx_set_irq_trigger(TB0219_PCI_SLOT3_PIN,
-                                              TRIGGER_LEVEL,
-                                              SIGNAL_THROUGH);
-                       vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN,
-                                            LEVEL_LOW);
-                       dev->irq = TB0219_PCI_SLOT3_IRQ;
-                       break;
-               default:
-                       break;
-               }
-
-               pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
-       }
-#endif
-}
diff --git a/arch/mips/pci/fixup-victor-mpc30x.c b/arch/mips/pci/fixup-victor-mpc30x.c
deleted file mode 100644 (file)
index 3ec5951..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * FILE NAME
- *     arch/mips/vr41xx/victor-mpc30x/pci_fixup.c
- *
- * BRIEF MODULE DESCRIPTION
- *     The Victor MP-C303/304 specific PCI fixups.
- *
- * Copyright 2002 Yoichi Yuasa
- *                yuasa@hh.iij4u.or.jp
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2 of the License, or (at your
- *  option) any later version.
- */
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/vr41xx/vrc4173.h>
-#include <asm/vr41xx/mpc30x.h>
-
-/*
- * Shortcuts
- */
-#define PCMCIA1        VRC4173_PCMCIA1_IRQ
-#define PCMCIA2        VRC4173_PCMCIA2_IRQ
-#define MQ     MQ200_IRQ
-
-static const int internal_func_irqs[8] __initdata = {
-       VRC4173_CASCADE_IRQ,
-       VRC4173_AC97_IRQ,
-       VRC4173_USB_IRQ,
-       
-};
-
-static char irq_tab_mpc30x[][5] __initdata = {
- [12] = { PCMCIA1, PCMCIA1, 0, 0 },
- [13] = { PCMCIA2, PCMCIA2, 0, 0 },
- [29] = {      MQ,      MQ, 0, 0 },            /* mediaQ MQ-200 */
-};
-
-int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-       if (slot == 30)
-               return internal_func_irqs[PCI_FUNC(dev->devfn)];
-
-       return irq_tab_mpc30x[slot][pin];
-}
diff --git a/arch/mips/pci/ops-mv64340.c b/arch/mips/pci/ops-mv64340.c
deleted file mode 100644 (file)
index 235e01b..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2002 Momentum Computer
- * Author: Matthew Dharm <mdharm@momenco.com>
- *
- * Copyright (C) 2003, 2004 Ralf Baechle (ralf@linux-mips.org)
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
- *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
- *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <asm/mv64340.h>
-
-/*
- * galileo_pcibios_(read/write)_config_(dword/word/byte) -
- *
- * reads/write a dword/word/byte register from the configuration space
- * of a device.
- *
- * Note that bus 0 and bus 1 are local, and we assume all other busses are
- * bridged from bus 1.  This is a safe assumption, since any other
- * configuration will require major modifications to the CP7000G
- *
- * Inputs :
- * bus - bus number
- * dev - device number
- * offset - register offset in the configuration space
- * val - value to be written / read
- *
- * Outputs :
- * PCIBIOS_SUCCESSFUL when operation was succesfull
- * PCIBIOS_DEVICE_NOT_FOUND when the bus or dev is errorneous
- * PCIBIOS_BAD_REGISTER_NUMBER when accessing non aligned
- */
-
-static int mv64340_read_config(struct pci_bus *bus, unsigned int devfn, int reg,
-       int size, u32 * val, u32 address_reg, u32 data_reg)
-{
-       u32 address;
-
-       /* Accessing device 31 crashes the MV-64340. */
-       if (PCI_SLOT(devfn) > 5)
-               return PCIBIOS_DEVICE_NOT_FOUND;
-
-       address = (bus->number << 16) | (devfn << 8) |
-                 (reg & 0xfc) | 0x80000000;
-
-       /* start the configuration cycle */
-       MV_WRITE(address_reg, address);
-
-       switch (size) {
-       case 1:
-               *val = MV_READ_8(data_reg + (reg & 0x3));
-               break;
-
-       case 2:
-               *val = MV_READ_16(data_reg + (reg & 0x3));
-               break;
-
-       case 4:
-               *val = MV_READ(data_reg);
-               break;
-       }
-
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static int mv64340_write_config(struct pci_bus *bus, unsigned int devfn,
-       int reg, int size, u32 val, u32 address_reg, u32 data_reg)
-{
-       u32 address;
-
-       /* Accessing device 31 crashes the MV-64340. */
-       if (PCI_SLOT(devfn) > 5)
-               return PCIBIOS_DEVICE_NOT_FOUND;
-
-       address = (bus->number << 16) | (devfn << 8) |
-                 (reg & 0xfc) | 0x80000000;
-
-       /* start the configuration cycle */
-       MV_WRITE(address_reg, address);
-
-       switch (size) {
-       case 1:
-               /* write the data */
-               MV_WRITE_8(data_reg + (reg & 0x3), val);
-               break;
-
-       case 2:
-               /* write the data */
-               MV_WRITE_16(data_reg + (reg & 0x3), val);
-               break;
-
-       case 4:
-               /* write the data */
-               MV_WRITE(data_reg, val);
-               break;
-       }
-
-       return PCIBIOS_SUCCESSFUL;
-}
-
-#define BUILD_PCI_OPS(host)                                            \
-                                                                       \
-static int mv64340_bus ## host ## _read_config(struct pci_bus *bus,    \
-       unsigned int devfn, int reg, int size, u32 * val)               \
-{                                                                      \
-       return mv64340_read_config(bus, devfn, reg, size, val,          \
-                  MV64340_PCI_ ## host ## _CONFIG_ADDR,                \
-                  MV64340_PCI_ ## host ## _CONFIG_DATA_VIRTUAL_REG);   \
-}                                                                      \
-                                                                       \
-static int mv64340_bus ## host ## _write_config(struct pci_bus *bus,   \
-       unsigned int devfn, int reg, int size, u32 val)                 \
-{                                                                      \
-       return mv64340_write_config(bus, devfn, reg, size, val,         \
-                  MV64340_PCI_ ## host ## _CONFIG_ADDR,                \
-                  MV64340_PCI_ ## host ## _CONFIG_DATA_VIRTUAL_REG);   \
-}                                                                      \
-                                                                       \
-struct pci_ops mv64340_bus ## host ## _pci_ops = {                     \
-       .read   = mv64340_bus ## host ## _read_config,                  \
-       .write  = mv64340_bus ## host ## _write_config                  \
-};
-
-BUILD_PCI_OPS(0)
-BUILD_PCI_OPS(1)
diff --git a/arch/mips/pci/ops-vrc4173.c b/arch/mips/pci/ops-vrc4173.c
deleted file mode 100644 (file)
index ce4e702..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * FILE NAME
- *     arch/mips/vr41xx/nec-eagle/vrc4173.c
- *
- * BRIEF MODULE DESCRIPTION
- *     Pre-setup for NEC VRC4173.
- *
- * Author: Yoichi Yuasa
- *         yyuasa@mvista.com or source@mvista.com
- *
- * Copyright 2001,2002 MontaVista Software Inc.
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2 of the License, or (at your
- *  option) any later version.
- *
- *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/module.h>
-
-#include <asm/io.h>
-#include <asm/vr41xx/eagle.h>
-#include <asm/vr41xx/vrc4173.h>
-
-#define PCI_CONFIG_ADDR        KSEG1ADDR(0x0f000c18)
-#define PCI_CONFIG_DATA        KSEG1ADDR(0x0f000c14)
-
-static inline void config_writeb(u8 reg, u8 val)
-{
-       u32 data;
-       int shift;
-
-       writel((1UL << 0x1e) | (reg & 0xfc), PCI_CONFIG_ADDR);
-       data = readl(PCI_CONFIG_DATA);
-
-       shift = (reg & 3) << 3;
-       data &= ~(0xff << shift);
-       data |= (((u32) val) << shift);
-
-       writel(data, PCI_CONFIG_DATA);
-}
-
-static inline u16 config_readw(u8 reg)
-{
-       u32 data;
-
-       writel(((1UL << 30) | (reg & 0xfc)), PCI_CONFIG_ADDR);
-       data = readl(PCI_CONFIG_DATA);
-
-       return (u16) (data >> ((reg & 2) << 3));
-}
-
-static inline u32 config_readl(u8 reg)
-{
-       writel(((1UL << 30) | (reg & 0xfc)), PCI_CONFIG_ADDR);
-
-       return readl(PCI_CONFIG_DATA);
-}
-
-static inline void config_writel(u8 reg, u32 val)
-{
-       writel((1UL << 0x1e) | (reg & 0xfc), PCI_CONFIG_ADDR);
-       writel(val, PCI_CONFIG_DATA);
-}
-
-void __init vrc4173_preinit(void)
-{
-       u32 cmdsts, base;
-       u16 cmu_mask;
-
-
-       if ((config_readw(PCI_VENDOR_ID) == PCI_VENDOR_ID_NEC) &&
-           (config_readw(PCI_DEVICE_ID) == PCI_DEVICE_ID_NEC_VRC4173)) {
-               /*
-                * Initialized NEC VRC4173 Bus Control Unit
-                */
-               cmdsts = config_readl(PCI_COMMAND);
-               config_writel(PCI_COMMAND,
-                             cmdsts |
-                             PCI_COMMAND_IO |
-                             PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
-
-               config_writeb(PCI_LATENCY_TIMER, 0x80);
-
-               config_writel(PCI_BASE_ADDRESS_0, VR41XX_PCI_IO_START);
-               base = config_readl(PCI_BASE_ADDRESS_0);
-               base &= PCI_BASE_ADDRESS_IO_MASK;
-               config_writeb(0x40, 0x01);
-
-               /* CARDU1 IDSEL = AD12, CARDU2 IDSEL = AD13 */
-               config_writeb(0x41, 0);
-
-               cmu_mask = 0x1000;
-               outw(cmu_mask, base + 0x040);
-               cmu_mask |= 0x0800;
-               outw(cmu_mask, base + 0x040);
-
-               outw(0x000f, base + 0x042);     /* Soft reset of CMU */
-               cmu_mask |= 0x05e0;
-               outw(cmu_mask, base + 0x040);
-               cmu_mask = inw(base + 0x040);   /* dummy read */
-               outw(0x0000, base + 0x042);
-       }
-}
diff --git a/arch/mips/vr41xx/nec-eagle/Makefile b/arch/mips/vr41xx/nec-eagle/Makefile
deleted file mode 100644 (file)
index 0b25725..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# Makefile for the NEC Eagle/Hawk specific parts of the kernel
-#
-# Author: Yoichi Yuasa
-#         yyuasa@mvista.com or source@mvista.com
-#
-# Copyright 2001,2002 MontaVista Software Inc.
-#
-
-obj-y                  += irq.o setup.o
diff --git a/arch/mips/vr41xx/nec-eagle/irq.c b/arch/mips/vr41xx/nec-eagle/irq.c
deleted file mode 100644 (file)
index 03f74a5..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- *  irq.c,  Interrupt routines for the NEC Eagle/Hawk board.
- *
- *  Copyright (C) 2002  MontaVista Software, Inc.
- *    Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
- *  Copyright (C) 2004  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-/*
- * Changes:
- *  MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com>
- *  - New creation, NEC Eagle is supported.
- *  - Added support for NEC Hawk.
- *
- *  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *  - Changed from board_irq_init to driver module.
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/types.h>
-
-#include <asm/io.h>
-#include <asm/vr41xx/eagle.h>
-
-MODULE_DESCRIPTION("IRQ module driver for NEC Eagle/Hawk");
-MODULE_AUTHOR("Yoichi Yuasa <yyuasa@mvista.com>");
-MODULE_LICENSE("GPL");
-
-static void enable_pciint_irq(unsigned int irq)
-{
-       uint8_t val;
-
-       val = readb(NEC_EAGLE_PCIINTMSKREG);
-       val |= (uint8_t)1 << (irq - PCIINT_IRQ_BASE);
-       writeb(val, NEC_EAGLE_PCIINTMSKREG);
-}
-
-static void disable_pciint_irq(unsigned int irq)
-{
-       uint8_t val;
-
-       val = readb(NEC_EAGLE_PCIINTMSKREG);
-       val &= ~((uint8_t)1 << (irq - PCIINT_IRQ_BASE));
-       writeb(val, NEC_EAGLE_PCIINTMSKREG);
-}
-
-static unsigned int startup_pciint_irq(unsigned int irq)
-{
-       enable_pciint_irq(irq);
-       return 0; /* never anything pending */
-}
-
-#define shutdown_pciint_irq    disable_pciint_irq
-#define ack_pciint_irq         disable_pciint_irq
-
-static void end_pciint_irq(unsigned int irq)
-{
-       if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               enable_pciint_irq(irq);
-}
-
-static struct hw_interrupt_type pciint_irq_type = {
-       .typename       = "PCIINT",
-       .startup        = startup_pciint_irq,
-       .shutdown       = shutdown_pciint_irq,
-       .enable         = enable_pciint_irq,
-       .disable        = disable_pciint_irq,
-       .ack            = ack_pciint_irq,
-       .end            = end_pciint_irq,
-};
-
-static void enable_sdbint_irq(unsigned int irq)
-{
-       uint8_t val;
-
-       val = readb(NEC_EAGLE_SDBINTMSK);
-       val |= (uint8_t)1 << (irq - SDBINT_IRQ_BASE);
-       writeb(val, NEC_EAGLE_SDBINTMSK);
-}
-
-static void disable_sdbint_irq(unsigned int irq)
-{
-       uint8_t val;
-
-       val = readb(NEC_EAGLE_SDBINTMSK);
-       val &= ~((uint8_t)1 << (irq - SDBINT_IRQ_BASE));
-       writeb(val, NEC_EAGLE_SDBINTMSK);
-}
-
-static unsigned int startup_sdbint_irq(unsigned int irq)
-{
-       enable_sdbint_irq(irq);
-       return 0; /* never anything pending */
-}
-
-#define shutdown_sdbint_irq    disable_sdbint_irq
-#define ack_sdbint_irq         disable_sdbint_irq
-
-static void end_sdbint_irq(unsigned int irq)
-{
-       if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               enable_sdbint_irq(irq);
-}
-
-static struct hw_interrupt_type sdbint_irq_type = {
-       .typename       = "SDBINT",
-       .startup        = startup_sdbint_irq,
-       .shutdown       = shutdown_sdbint_irq,
-       .enable         = enable_sdbint_irq,
-       .disable        = disable_sdbint_irq,
-       .ack            = ack_sdbint_irq,
-       .end            = end_sdbint_irq,
-};
-
-static int eagle_get_irq_number(int irq)
-{
-       uint8_t sdbint, pciint;
-       int i;
-
-       sdbint = readb(NEC_EAGLE_SDBINT);
-       sdbint &= (NEC_EAGLE_SDBINT_DEG | NEC_EAGLE_SDBINT_ENUM |
-                  NEC_EAGLE_SDBINT_SIO1INT | NEC_EAGLE_SDBINT_SIO2INT |
-                  NEC_EAGLE_SDBINT_PARINT);
-       pciint = readb(NEC_EAGLE_PCIINTREG);
-       pciint &= (NEC_EAGLE_PCIINT_CP_INTA | NEC_EAGLE_PCIINT_CP_INTB |
-                  NEC_EAGLE_PCIINT_CP_INTC | NEC_EAGLE_PCIINT_CP_INTD |
-                  NEC_EAGLE_PCIINT_LANINT);
-
-       for (i = 1; i < 6; i++)
-               if (sdbint & (0x01 << i))
-                       return SDBINT_IRQ_BASE + i;
-
-       for (i = 0; i < 5; i++)
-               if (pciint & (0x01 << i))
-                       return PCIINT_IRQ_BASE + i;
-
-       return -EINVAL;
-}
-
-static int __devinit eagle_irq_init(void)
-{
-       int i, retval;
-
-       writeb(0, NEC_EAGLE_SDBINTMSK);
-       writeb(0, NEC_EAGLE_PCIINTMSKREG);
-
-       vr41xx_set_irq_trigger(PCISLOT_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
-       vr41xx_set_irq_level(PCISLOT_PIN, LEVEL_HIGH);
-
-       vr41xx_set_irq_trigger(FPGA_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
-       vr41xx_set_irq_level(FPGA_PIN, LEVEL_HIGH);
-
-       vr41xx_set_irq_trigger(DCD_PIN, TRIGGER_EDGE, SIGNAL_HOLD);
-       vr41xx_set_irq_level(DCD_PIN, LEVEL_LOW);
-
-       for (i = SDBINT_IRQ_BASE; i <= SDBINT_IRQ_LAST; i++)
-               irq_desc[i].handler = &sdbint_irq_type;
-
-       for (i = PCIINT_IRQ_BASE; i <= PCIINT_IRQ_LAST; i++)
-               irq_desc[i].handler = &pciint_irq_type;
-
-       retval = vr41xx_cascade_irq(FPGA_CASCADE_IRQ, eagle_get_irq_number);
-       if (retval != 0)
-               printk(KERN_ERR "eagle: Cannot cascade IRQ %d\n", FPGA_CASCADE_IRQ);
-
-       return retval;
-}
-
-static void __devexit eagle_irq_exit(void)
-{
-       free_irq(FPGA_CASCADE_IRQ, NULL);
-}
-
-module_init(eagle_irq_init);
-module_exit(eagle_irq_exit);
diff --git a/arch/mips/vr41xx/nec-eagle/setup.c b/arch/mips/vr41xx/nec-eagle/setup.c
deleted file mode 100644 (file)
index cc055af..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * arch/mips/vr41xx/nec-eagle/setup.c
- *
- * Setup for the NEC Eagle/Hawk board.
- *
- * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
- *
- * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/config.h>
-#include <linux/ioport.h>
-
-#include <asm/io.h>
-#include <asm/pci_channel.h>
-#include <asm/vr41xx/eagle.h>
-
-#ifdef CONFIG_PCI
-
-extern void vrc4173_preinit(void);
-
-static struct resource vr41xx_pci_io_resource = {
-       "PCI I/O space",
-       VR41XX_PCI_IO_START,
-       VR41XX_PCI_IO_END,
-       IORESOURCE_IO
-};
-
-static struct resource vr41xx_pci_mem_resource = {
-       "PCI memory space",
-       VR41XX_PCI_MEM_START,
-       VR41XX_PCI_MEM_END,
-       IORESOURCE_MEM
-};
-
-extern struct pci_ops vr41xx_pci_ops;
-
-struct pci_controller vr41xx_controller = {
-       .pci_ops        = &vr41xx_pci_ops,
-       .io_resource    = &vr41xx_pci_io_resource,
-       .mem_resource   = &vr41xx_pci_mem_resource,
-};
-
-struct vr41xx_pci_address_space vr41xx_pci_mem1 = {
-       VR41XX_PCI_MEM1_BASE,
-       VR41XX_PCI_MEM1_MASK,
-       IO_MEM1_RESOURCE_START
-};
-
-struct vr41xx_pci_address_space vr41xx_pci_mem2 = {
-       VR41XX_PCI_MEM2_BASE,
-       VR41XX_PCI_MEM2_MASK,
-       IO_MEM2_RESOURCE_START
-};
-
-struct vr41xx_pci_address_space vr41xx_pci_io = {
-       VR41XX_PCI_IO_BASE,
-       VR41XX_PCI_IO_MASK,
-       IO_PORT_RESOURCE_START
-};
-
-static struct vr41xx_pci_address_map pci_address_map = {
-       &vr41xx_pci_mem1,
-       &vr41xx_pci_mem2,
-       &vr41xx_pci_io
-};
-#endif
-
-const char *get_system_type(void)
-{
-       return "NEC SDB-VR4122/VR4131(Eagle/Hawk)";
-}
-
-static int nec_eagle_setup(void)
-{
-       set_io_port_base(IO_PORT_BASE);
-       ioport_resource.start = IO_PORT_RESOURCE_START;
-       ioport_resource.end = IO_PORT_RESOURCE_END;
-
-#ifdef CONFIG_SERIAL_8250
-       vr41xx_select_siu_interface(SIU_RS232C, IRDA_NONE);
-       vr41xx_siu_init();
-       vr41xx_dsiu_init();
-#endif
-
-#ifdef CONFIG_PCI
-       vr41xx_pciu_init(&pci_address_map);
-
-       vrc4173_preinit();
-#endif
-
-       return 0;
-}
-
-early_initcall(nec_eagle_setup);
diff --git a/arch/mips/vr41xx/tanbac-tb0229/reboot.c b/arch/mips/vr41xx/tanbac-tb0229/reboot.c
deleted file mode 100644 (file)
index 02e8378..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * FILE NAME
- *     arch/mips/vr41xx/tanbac-tb0229/reboot.c
- *
- * BRIEF MODULE DESCRIPTION
- *     Depending on TANBAC TB0229(VR4131DIMM) of reboot system call.
- *
- * Copyright 2003 Megasolution Inc.
- *                matsu@megasolution.jp
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2 of the License, or (at your
- *  option) any later version.
- */
-#include <linux/config.h>
-#include <asm/io.h>
-#include <asm/vr41xx/tb0229.h>
-
-#define tb0229_hard_reset()    writew(0, TB0219_RESET_REGS)
-
-void tanbac_tb0229_restart(char *command)
-{
-       local_irq_disable();
-       tb0229_hard_reset();
-       while (1);
-}
index 9e37d3d..1c018a7 100644 (file)
@@ -255,6 +255,8 @@ config DEBUG_INFO
          
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 514e8b5..d45980c 100644 (file)
@@ -110,6 +110,9 @@ long sys_ptrace(long request, pid_t pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
+
        ret = -EPERM;
        if (pid == 1)           /* no messing around with init! */
                goto out_tsk;
index e783325..74db7f6 100644 (file)
@@ -677,6 +677,7 @@ asmlinkage int sys32_sysinfo(struct sysinfo32 *info)
 
        do {
                seq = read_seqbegin(&xtime_lock);
+               /* requires vx virtualization */
                val.uptime = jiffies / HZ;
 
                val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c
deleted file mode 100644 (file)
index abd7490..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Kernel unwinding support
- *
- * (c) 2002-2004 Randolph Chung <tausq@debian.org>
- *
- * Derived partially from the IA64 implementation. The PA-RISC
- * Runtime Architecture Document is also a useful reference to
- * understand what is happening here
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-
-#include <asm/uaccess.h>
-
-#include <asm/unwind.h>
-
-/* #define DEBUG 1 */
-#ifdef DEBUG
-#define dbg(x...) printk(x)
-#else
-#define dbg(x...)
-#endif
-
-extern struct unwind_table_entry __start___unwind[];
-extern struct unwind_table_entry __stop___unwind[];
-
-static spinlock_t unwind_lock;
-/*
- * the kernel unwind block is not dynamically allocated so that
- * we can call unwind_init as early in the bootup process as 
- * possible (before the slab allocator is initialized)
- */
-static struct unwind_table kernel_unwind_table;
-static struct unwind_table *unwind_tables, *unwind_tables_end;
-
-
-static inline const struct unwind_table_entry *
-find_unwind_entry_in_table(const struct unwind_table *table, unsigned long addr)
-{
-       const struct unwind_table_entry *e = 0;
-       unsigned long lo, hi, mid;
-
-       for (lo = 0, hi = table->length; lo < hi; )
-       {
-               mid = (lo + hi) / 2;
-               e = &table->table[mid];
-               if (addr < e->region_start)
-                       hi = mid;
-               else if (addr > e->region_end)
-                       lo = mid + 1;
-               else
-                       break;
-       }
-
-       return e;
-}
-
-static inline const struct unwind_table_entry *
-find_unwind_entry(unsigned long addr)
-{
-       struct unwind_table *table = unwind_tables;
-       const struct unwind_table_entry *e = NULL;
-
-       if (addr >= kernel_unwind_table.start && 
-           addr <= kernel_unwind_table.end)
-               e = find_unwind_entry_in_table(&kernel_unwind_table, addr);
-       else
-               for (; table; table = table->next)
-               {
-                       if (addr >= table->start && 
-                           addr <= table->end)
-                               e = find_unwind_entry_in_table(table, addr);
-                       if (e)
-                               break;
-               }
-
-       return e;
-}
-
-static void
-unwind_table_init(struct unwind_table *table, const char *name,
-                 unsigned long base_addr, unsigned long gp,
-                 void *table_start, void *table_end)
-{
-       struct unwind_table_entry *start = table_start;
-       struct unwind_table_entry *end = 
-               (struct unwind_table_entry *)table_end - 1;
-
-       table->name = name;
-       table->base_addr = base_addr;
-       table->gp = gp;
-       table->start = base_addr + start->region_start;
-       table->end = base_addr + end->region_end;
-       table->table = (struct unwind_table_entry *)table_start;
-       table->length = end - start + 1;
-       table->next = NULL;
-
-       for (; start <= end; start++) {
-               start->region_start += base_addr;
-               start->region_end += base_addr;
-       }
-}
-
-void *
-unwind_table_add(const char *name, unsigned long base_addr, 
-                unsigned long gp,
-                 void *start, void *end)
-{
-       struct unwind_table *table;
-       unsigned long flags;
-
-       table = kmalloc(sizeof(struct unwind_table), GFP_USER);
-       if (table == NULL)
-               return 0;
-       unwind_table_init(table, name, base_addr, gp, start, end);
-       spin_lock_irqsave(&unwind_lock, flags);
-       if (unwind_tables)
-       {
-               unwind_tables_end->next = table;
-               unwind_tables_end = table;
-       }
-       else
-       {
-               unwind_tables = unwind_tables_end = table;
-       }
-       spin_unlock_irqrestore(&unwind_lock, flags);
-
-       return table;
-}
-
-/* Called from setup_arch to import the kernel unwind info */
-static int unwind_init(void)
-{
-       long start, stop;
-       register unsigned long gp __asm__ ("r27");
-
-       start = (long)&__start___unwind[0];
-       stop = (long)&__stop___unwind[0];
-
-       printk("unwind_init: start = 0x%lx, end = 0x%lx, entries = %lu\n", 
-           start, stop,
-           (stop - start) / sizeof(struct unwind_table_entry));
-
-       unwind_table_init(&kernel_unwind_table, "kernel", KERNEL_START,
-                         gp, 
-                         &__start___unwind[0], &__stop___unwind[0]);
-#if 0
-       {
-               int i;
-               for (i = 0; i < 10; i++)
-               {
-                       printk("region 0x%x-0x%x\n", 
-                               __start___unwind[i].region_start, 
-                               __start___unwind[i].region_end);
-               }
-       }
-#endif
-       return 0;
-}
-
-static void unwind_frame_regs(struct unwind_frame_info *info)
-{
-       const struct unwind_table_entry *e;
-       unsigned long npc;
-       unsigned int insn;
-       long frame_size = 0;
-       int looking_for_rp, rpoffset = 0;
-
-       e = find_unwind_entry(info->ip);
-       if (!e) {
-               unsigned long sp;
-               extern char _stext[], _etext[];
-
-               dbg("Cannot find unwind entry for 0x%lx; forced unwinding\n", info->ip);
-
-               /* Since we are doing the unwinding blind, we don't know if
-                  we are adjusting the stack correctly or extracting the rp
-                  correctly. The rp is checked to see if it belongs to the
-                  kernel text section, if not we assume we don't have a 
-                  correct stack frame and we continue to unwind the stack.
-                  This is not quite correct, and will fail for loadable
-                  modules. */
-               sp = info->sp & ~63;
-               do {
-                       info->prev_sp = sp - 64;
-
-                       /* FIXME: what happens if we unwind too far so that 
-                          sp no longer falls in a mapped kernel page? */
-#ifndef __LP64__
-                       info->prev_ip = *(unsigned long *)(info->prev_sp - 20);
-#else
-                       info->prev_ip = *(unsigned long *)(info->prev_sp - 16);
-#endif
-
-                       sp = info->prev_sp;
-               } while (info->prev_ip < (unsigned long)_stext ||
-                        info->prev_ip > (unsigned long)_etext);
-
-               dbg("analyzing func @ %lx with no unwind info, setting prev_sp=%lx prev_ip=%lx\n", info->ip, info->prev_sp, info->prev_ip);
-       } else {
-
-               dbg("e->start = 0x%x, e->end = 0x%x, Save_SP = %d, Save_RP = %d size = %u\n",
-                               e->region_start, e->region_end, e->Save_SP, e->Save_RP, e->Total_frame_size);
-
-               looking_for_rp = e->Save_RP;
-
-               for (npc = e->region_start; 
-                    (frame_size < (e->Total_frame_size << 3) || looking_for_rp) && 
-                    npc < info->ip; 
-                    npc += 4) {
-
-                       insn = *(unsigned int *)npc;
-
-                       if ((insn & 0xffffc000) == 0x37de0000 ||
-                           (insn & 0xffe00000) == 0x6fc00000) {
-                               /* ldo X(sp), sp, or stwm X,D(sp) */
-                               frame_size += (insn & 0x1 ? -1 << 13 : 0) | 
-                                       ((insn & 0x3fff) >> 1);
-                               dbg("analyzing func @ %lx, insn=%08x @ %lx, frame_size = %ld\n", info->ip, insn, npc, frame_size);
-                       } else if ((insn & 0xffe00008) == 0x7ec00008) {
-                               /* std,ma X,D(sp) */
-                               frame_size += (insn & 0x1 ? -1 << 13 : 0) | 
-                                       (((insn >> 4) & 0x3ff) << 3);
-                               dbg("analyzing func @ %lx, insn=%08x @ %lx, frame_size = %ld\n", info->ip, insn, npc, frame_size);
-                       } else if (insn == 0x6bc23fd9) { 
-                               /* stw rp,-20(sp) */
-                               rpoffset = 20;
-                               looking_for_rp = 0;
-                               dbg("analyzing func @ %lx, insn=stw rp,-20(sp) @ %lx\n", info->ip, npc);
-                       } else if (insn == 0x0fc212c1) {
-                               /* std rp,-16(sr0,sp) */
-                               rpoffset = 16;
-                               looking_for_rp = 0;
-                               dbg("analyzing func @ %lx, insn=std rp,-16(sp) @ %lx\n", info->ip, npc);
-                       }
-               }
-
-               info->prev_sp = info->sp - frame_size;
-               if (rpoffset)
-                       info->rp = *(unsigned long *)(info->prev_sp - rpoffset);
-               info->prev_ip = info->rp;
-               info->rp = 0;
-
-               dbg("analyzing func @ %lx, setting prev_sp=%lx prev_ip=%lx\n", info->ip, info->prev_sp, info->prev_ip);
-       }
-}
-
-void unwind_frame_init(struct unwind_frame_info *info, struct task_struct *t, 
-                      unsigned long sp, unsigned long ip, unsigned long rp)
-{
-       memset(info, 0, sizeof(struct unwind_frame_info));
-       info->t = t;
-       info->sp = sp;
-       info->ip = ip;
-       info->rp = rp;
-
-       dbg("(%d) Start unwind from sp=%08lx ip=%08lx\n", t ? (int)t->pid : 0, info->sp, info->ip);
-}
-
-void unwind_frame_init_from_blocked_task(struct unwind_frame_info *info, struct task_struct *t)
-{
-       struct pt_regs *regs = &t->thread.regs;
-       unwind_frame_init(info, t, regs->ksp, regs->kpc, 0);
-}
-
-void unwind_frame_init_running(struct unwind_frame_info *info, struct pt_regs *regs)
-{
-       unwind_frame_init(info, current, regs->gr[30], regs->iaoq[0],
-                         regs->gr[2]);
-}
-
-int unwind_once(struct unwind_frame_info *next_frame)
-{
-       unwind_frame_regs(next_frame);
-
-       if (next_frame->prev_sp == 0 ||
-           next_frame->prev_ip == 0)
-               return -1;
-
-       next_frame->sp = next_frame->prev_sp;
-       next_frame->ip = next_frame->prev_ip;
-       next_frame->prev_sp = 0;
-       next_frame->prev_ip = 0;
-
-       dbg("(%d) Continue unwind to sp=%08lx ip=%08lx\n", (int)next_frame->t->pid, next_frame->sp, next_frame->ip);
-
-       return 0;
-}
-
-int unwind_to_user(struct unwind_frame_info *info)
-{
-       int ret;
-       
-       do {
-               ret = unwind_once(info);
-       } while (!ret && !(info->ip & 3));
-
-       return ret;
-}
-
-module_init(unwind_init);
diff --git a/arch/ppc/8260_io/commproc.c b/arch/ppc/8260_io/commproc.c
deleted file mode 100644 (file)
index e05b862..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * General Purpose functions for the global management of the
- * 8260 Communication Processor Module.
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- * Copyright (c) 2000 MontaVista Software, Inc (source@mvista.com)
- *     2.3.99 Updates
- *
- * In addition to the individual control of the communication
- * channels, there are a few functions that globally affect the
- * communication processor.
- *
- * Buffer descriptors must be allocated from the dual ported memory
- * space.  The allocator for that is here.  When the communication
- * process is reset, we reclaim the memory available.  There is
- * currently no deallocator for this memory.
- */
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/param.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/bootmem.h>
-#include <asm/irq.h>
-#include <asm/mpc8260.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/immap_8260.h>
-#include <asm/cpm_8260.h>
-
-static uint    dp_alloc_base;  /* Starting offset in DP ram */
-static uint    dp_alloc_top;   /* Max offset + 1 */
-static uint    host_buffer;    /* One page of host buffer */
-static uint    host_end;       /* end + 1 */
-cpm8260_t      *cpmp;          /* Pointer to comm processor space */
-
-/* We allocate this here because it is used almost exclusively for
- * the communication processor devices.
- */
-immap_t                *immr;
-
-void
-m8260_cpm_reset(void)
-{
-       volatile immap_t         *imp;
-       volatile cpm8260_t      *commproc;
-       uint                    vpgaddr;
-
-       immr = imp = (volatile immap_t *)IMAP_ADDR;
-       commproc = &imp->im_cpm;
-
-       /* Reclaim the DP memory for our use.
-       */
-       dp_alloc_base = CPM_DATAONLY_BASE;
-       dp_alloc_top = dp_alloc_base + CPM_DATAONLY_SIZE;
-
-       /* Set the host page for allocation.
-       */
-       host_buffer =
-               (uint) alloc_bootmem_pages(PAGE_SIZE * NUM_CPM_HOST_PAGES);
-       host_end = host_buffer + (PAGE_SIZE * NUM_CPM_HOST_PAGES);
-
-       vpgaddr = host_buffer;
-
-       /* Tell everyone where the comm processor resides.
-       */
-       cpmp = (cpm8260_t *)commproc;
-}
-
-/* Allocate some memory from the dual ported ram.
- * To help protocols with object alignment restrictions, we do that
- * if they ask.
- */
-uint
-m8260_cpm_dpalloc(uint size, uint align)
-{
-       uint    retloc;
-       uint    align_mask, off;
-       uint    savebase;
-
-       align_mask = align - 1;
-       savebase = dp_alloc_base;
-
-       if ((off = (dp_alloc_base & align_mask)) != 0)
-               dp_alloc_base += (align - off);
-
-       if ((dp_alloc_base + size) >= dp_alloc_top) {
-               dp_alloc_base = savebase;
-               return(CPM_DP_NOSPACE);
-       }
-
-       retloc = dp_alloc_base;
-       dp_alloc_base += size;
-
-       return(retloc);
-}
-
-/* We also own one page of host buffer space for the allocation of
- * UART "fifos" and the like.
- */
-uint
-m8260_cpm_hostalloc(uint size, uint align)
-{
-       uint    retloc;
-       uint    align_mask, off;
-       uint    savebase;
-
-       align_mask = align - 1;
-       savebase = host_buffer;
-
-       if ((off = (host_buffer & align_mask)) != 0)
-               host_buffer += (align - off);
-
-       if ((host_buffer + size) >= host_end) {
-               host_buffer = savebase;
-               return(0);
-       }
-
-       retloc = host_buffer;
-       host_buffer += size;
-
-       return(retloc);
-}
-
-/* Set a baud rate generator.  This needs lots of work.  There are
- * eight BRGs, which can be connected to the CPM channels or output
- * as clocks.  The BRGs are in two different block of internal
- * memory mapped space.
- * The baud rate clock is the system clock divided by something.
- * It was set up long ago during the initial boot phase and is
- * is given to us.
- * Baud rate clocks are zero-based in the driver code (as that maps
- * to port numbers).  Documentation uses 1-based numbering.
- */
-#define BRG_INT_CLK    (((bd_t *)__res)->bi_brgfreq)
-#define BRG_UART_CLK   (BRG_INT_CLK/16)
-
-/* This function is used by UARTS, or anything else that uses a 16x
- * oversampled clock.
- */
-void
-m8260_cpm_setbrg(uint brg, uint rate)
-{
-       volatile uint   *bp;
-
-       /* This is good enough to get SMCs running.....
-       */
-       if (brg < 4) {
-               bp = (uint *)&immr->im_brgc1;
-       }
-       else {
-               bp = (uint *)&immr->im_brgc5;
-               brg -= 4;
-       }
-       bp += brg;
-       *bp = ((BRG_UART_CLK / rate) << 1) | CPM_BRG_EN;
-}
-
-/* This function is used to set high speed synchronous baud rate
- * clocks.
- */
-void
-m8260_cpm_fastbrg(uint brg, uint rate, int div16)
-{
-       volatile uint   *bp;
-
-       if (brg < 4) {
-               bp = (uint *)&immr->im_brgc1;
-       }
-       else {
-               bp = (uint *)&immr->im_brgc5;
-               brg -= 4;
-       }
-       bp += brg;
-       *bp = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN;
-       if (div16)
-               *bp |= CPM_BRG_DIV16;
-}
diff --git a/arch/ppc/8260_io/uart.c b/arch/ppc/8260_io/uart.c
deleted file mode 100644 (file)
index 23c0322..0000000
+++ /dev/null
@@ -1,3061 +0,0 @@
-/*
- *  UART driver for MPC8260 CPM SCC or SMC
- *  Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- *  Copyright (c) 2000 MontaVista Software, Inc. (source@mvista.com)
- *     2.3.99 updates
- *  Copyright (c) 2002 Allen Curtis, Ones and Zeros, Inc. (acurtis@onz.com)
- *     2.5.50 updates
- *  Fix the console driver to be registered with initcalls and some minor fixup
- *  for 2.6.2, by Petter Larsen, moreCom as (petter.larsen@morecom.no) and
- *  Miguel Valero, AxxessIT ASA (miguel.valero@axxessit.no)
- *
- * I used the 8xx uart.c driver as the framework for this driver.
- * The original code was written for the EST8260 board.  I tried to make
- * it generic, but there may be some assumptions in the structures that
- * have to be fixed later.
- *
- * The 8xx and 8260 are similar, but not identical.  Over time we
- * could probably merge these two drivers.
- * To save porting time, I did not bother to change any object names
- * that are not accessed outside of this file.
- * It still needs lots of work........When it was easy, I included code
- * to support the SCCs.
- * Only the SCCs support modem control, so that is not complete either.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
-#include <linux/major.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <asm/uaccess.h>
-#include <asm/immap_8260.h>
-#include <asm/mpc8260.h>
-#include <asm/cpm_8260.h>
-#include <asm/irq.h>
-
-#ifdef CONFIG_MAGIC_SYSRQ
-#include <linux/sysrq.h>
-#endif
-
-#ifdef CONFIG_SERIAL_CONSOLE
-#include <linux/console.h>
-
-/* SCC Console configuration.  Not quite finished.  The SCC_CONSOLE
- * should be the number of the SCC to use, but only SCC1 will
- * work at this time.
- */
-#ifdef CONFIG_SCC_CONSOLE
-#define SCC_CONSOLE 1
-#endif
-
-/* this defines the index into rs_table for the port to use
-*/
-#ifndef CONFIG_SERIAL_CONSOLE_PORT
-#define CONFIG_SERIAL_CONSOLE_PORT     0
-#endif
-#endif
-#define CONFIG_SERIAL_CONSOLE_PORT     0
-
-#define TX_WAKEUP      ASYNC_SHARE_IRQ
-
-static char *serial_name = "CPM UART driver";
-static char *serial_version = "0.02";
-
-static struct tty_driver *serial_driver;
-static int __init serial_console_setup( struct console *co, char *options);
-static void serial_console_write(struct console *c, const char *s,
-                                               unsigned count);
-
-static struct tty_driver *serial_console_device(struct console *c, int *index);
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-static unsigned long break_pressed; /* break, really ... */
-#endif
-
-/*
- * Serial driver configuration section.  Here are the various options:
- */
-#define SERIAL_PARANOIA_CHECK
-#define CONFIG_SERIAL_NOPAUSE_IO
-#define SERIAL_DO_RESTART
-
-/* Set of debugging defines */
-
-#undef SERIAL_DEBUG_INTR
-#undef SERIAL_DEBUG_OPEN
-#undef SERIAL_DEBUG_FLOW
-#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-
-#define _INLINE_ inline
-
-#define DBG_CNT(s)
-
-/* We overload some of the items in the data structure to meet our
- * needs.  For example, the port address is the CPM parameter ram
- * offset for the SCC or SMC.  The maximum number of ports is 4 SCCs and
- * 2 SMCs.  The "hub6" field is used to indicate the channel number, with
- * 0 and 1 indicating the SMCs and 2, 3, 4, and 5 are the SCCs.
- * Since these ports are so versatile, I don't yet have a strategy for
- * their management.  For example, SCC1 is used for Ethernet.  Right
- * now, just don't put them in the table.  Of course, right now I just
- * want the SMC to work as a uart :-)..
- * The "type" field is currently set to 0, for PORT_UNKNOWN.  It is
- * not currently used.  I should probably use it to indicate the port
- * type of CMS or SCC.
- * The SMCs do not support any modem control signals.
- */
-#define smc_scc_num    hub6
-
-/* The choice of serial port to use for KGDB.  If the system has
- * two ports, you can use one for console and one for KGDB (which
- * doesn't make sense to me, but people asked for it).
- */
-#ifdef CONFIG_KGDB_TTYS1
-#define KGDB_SER_IDX 1         /* SCC2/SMC2 */
-#else
-#define KGDB_SER_IDX 0         /* SCC1/SMC1 */
-#endif
-
-#ifndef SCC_CONSOLE
-
-/* SMC2 is sometimes used for low performance TDM interfaces.  Define
- * this as 1 if you want SMC2 as a serial port UART managed by this driver.
- * Define this as 0 if you wish to use SMC2 for something else.
- */
-#define USE_SMC2 1
-
-/* Define SCC to ttySx mapping.
-*/
-#define SCC_NUM_BASE   (USE_SMC2 + 1)  /* SCC base tty "number" */
-
-/* Define which SCC is the first one to use for a serial port.  These
- * are 0-based numbers, i.e. this assumes the first SCC (SCC1) is used
- * for Ethernet, and the first available SCC for serial UART is SCC2.
- * NOTE:  IF YOU CHANGE THIS, you have to change the PROFF_xxx and
- * interrupt vectors in the table below to match.
- */
-#define SCC_IDX_BASE   1       /* table index */
-
-static struct serial_state rs_table[] = {
-       /* UART CLK   PORT          IRQ      FLAGS  NUM   */
-       { 0,     0, PROFF_SMC1, SIU_INT_SMC1,   0,    0 },    /* SMC1 ttyS0 */
-#ifdef USE_SMC2
-       { 0,     0, PROFF_SMC2, SIU_INT_SMC2,   0,    1 },    /* SMC2 ttyS1 */
-#endif
-#ifndef CONFIG_SCC1_ENET
-       { 0,     0, PROFF_SCC1, SIU_INT_SCC1,   0, SCC_NUM_BASE},    /* SCC1 ttyS2 */
-#endif
-#if !defined(CONFIG_SBC82xx) && !defined(CONFIG_SCC2_ENET)
-       { 0,     0, PROFF_SCC2, SIU_INT_SCC2,   0, SCC_NUM_BASE + 1},    /* SCC2 ttyS3 */
-#endif
-};
-
-#else /* SCC_CONSOLE */
-#define SCC_NUM_BASE   0       /* SCC base tty "number" */
-#define SCC_IDX_BASE   0       /* table index */
-static struct serial_state rs_table[] = {
-       /* UART CLK   PORT          IRQ      FLAGS  NUM   */
-       { 0,     0, PROFF_SCC1, SIU_INT_SCC1,   0, SCC_NUM_BASE},    /* SCC1 ttyS2 */
-       { 0,     0, PROFF_SCC2, SIU_INT_SCC2,   0, SCC_NUM_BASE + 1},    /* SCC2 ttyS3 */
-};
-#endif /* SCC_CONSOLE */
-
-#define PORT_NUM(P)    (((P) < (SCC_NUM_BASE)) ? (P) : (P)-(SCC_NUM_BASE))
-
-#define NR_PORTS       (sizeof(rs_table)/sizeof(struct serial_state))
-
-/* The number of buffer descriptors and their sizes.
-*/
-#define RX_NUM_FIFO    4
-#define RX_BUF_SIZE    32
-#define TX_NUM_FIFO    4
-#define TX_BUF_SIZE    32
-
-/* The async_struct in serial.h does not really give us what we
- * need, so define our own here.
- */
-typedef struct serial_info {
-       int                     magic;
-       int                     flags;
-       struct serial_state     *state;
-       struct tty_struct       *tty;
-       int                     read_status_mask;
-       int                     ignore_status_mask;
-       int                     timeout;
-       int                     line;
-       int                     x_char; /* xon/xoff character */
-       int                     close_delay;
-       unsigned short          closing_wait;
-       unsigned short          closing_wait2;
-       unsigned long           event;
-       unsigned long           last_active;
-       int                     blocked_open; /* # of blocked opens */
-       struct work_struct      tqueue;
-       struct work_struct      tqueue_hangup;
-       wait_queue_head_t       open_wait;
-       wait_queue_head_t       close_wait;
-
-       /* CPM Buffer Descriptor pointers.
-       */
-       cbd_t                   *rx_bd_base;
-       cbd_t                   *rx_cur;
-       cbd_t                   *tx_bd_base;
-       cbd_t                   *tx_cur;
-} ser_info_t;
-
-static struct console sercons = {
-       .name =         "ttyS",
-       .write =        serial_console_write,
-       .device =       serial_console_device,
-       .setup =        serial_console_setup,
-       .flags =        CON_PRINTBUFFER,
-       .index =        CONFIG_SERIAL_CONSOLE_PORT,
-};
-
-static void change_speed(ser_info_t *info);
-static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
-
-static inline int serial_paranoia_check(ser_info_t *info,
-                                       char *name, const char *routine)
-{
-#ifdef SERIAL_PARANOIA_CHECK
-       static const char *badmagic =
-               "Warning: bad magic number for serial struct (%s) in %s\n";
-       static const char *badinfo =
-               "Warning: null async_struct for (%s) in %s\n";
-
-       if (!info) {
-               printk(badinfo, name, routine);
-               return 1;
-       }
-       if (info->magic != SERIAL_MAGIC) {
-               printk(badmagic, name, routine);
-               return 1;
-       }
-#endif
-       return 0;
-}
-
-/*
- * This is used to figure out the divisor speeds and the timeouts,
- * indexed by the termio value.  The generic CPM functions are responsible
- * for setting and assigning baud rate generators for us.
- */
-static int baud_table[] = {
-       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
-       9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 };
-
-
-/*
- * ------------------------------------------------------------
- * rs_stop() and rs_start()
- *
- * This routines are called before setting or resetting tty->stopped.
- * They enable or disable transmitter interrupts, as necessary.
- * ------------------------------------------------------------
- */
-static void rs_8xx_stop(struct tty_struct *tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       int     idx;
-       unsigned long flags;
-       volatile scc_t  *sccp;
-       volatile smc_t  *smcp;
-
-       if (serial_paranoia_check(info, tty->name, "rs_stop"))
-               return;
-
-       save_flags(flags); cli();
-       if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               smcp = &immr->im_smc[idx];
-               smcp->smc_smcm &= ~SMCM_TX;
-       }
-       else {
-               sccp = &immr->im_scc[idx - SCC_IDX_BASE];
-               sccp->scc_sccm &= ~UART_SCCM_TX;
-       }
-       restore_flags(flags);
-}
-
-static void rs_8xx_start(struct tty_struct *tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       int     idx;
-       unsigned long flags;
-       volatile scc_t  *sccp;
-       volatile smc_t  *smcp;
-
-       if (serial_paranoia_check(info, tty->name, "rs_stop"))
-               return;
-
-       save_flags(flags); cli();
-       if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               smcp = &immr->im_smc[idx];
-               smcp->smc_smcm |= SMCM_TX;
-       }
-       else {
-               sccp = &immr->im_scc[idx - SCC_IDX_BASE];
-               sccp->scc_sccm |= UART_SCCM_TX;
-       }
-       restore_flags(flags);
-}
-
-/*
- * ----------------------------------------------------------------------
- *
- * Here starts the interrupt handling routines.  All of the following
- * subroutines are declared as inline and are folded into
- * rs_interrupt().  They were separated out for readability's sake.
- *
- * Note: rs_interrupt() is a "fast" interrupt, which means that it
- * runs with interrupts turned off.  People who may want to modify
- * rs_interrupt() should try to keep the interrupt handler as fast as
- * possible.  After you are done making modifications, it is not a bad
- * idea to do:
- *
- * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
- *
- * and look at the resulting assemble code in serial.s.
- *
- *                             - Ted Ts'o (tytso@mit.edu), 7-Mar-93
- * -----------------------------------------------------------------------
- */
-
-/*
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- */
-static _INLINE_ void rs_sched_event(ser_info_t *info,
-                                 int event)
-{
-       info->event |= 1 << event;
-       schedule_work(&info->tqueue);
-}
-
-static _INLINE_ void receive_chars(ser_info_t *info, struct pt_regs *regs)
-{
-       struct tty_struct *tty = info->tty;
-       unsigned char ch, *cp;
-       /*int   ignored = 0;*/
-       int     i;
-       ushort  status;
-       struct  async_icount *icount;
-       volatile cbd_t  *bdp;
-
-       icount = &info->state->icount;
-
-       /* Just loop through the closed BDs and copy the characters into
-        * the buffer.
-        */
-       bdp = info->rx_cur;
-       for (;;) {
-               if (bdp->cbd_sc & BD_SC_EMPTY)  /* If this one is empty */
-                       break;                  /*   we are all done */
-
-               /* The read status mask tell us what we should do with
-                * incoming characters, especially if errors occur.
-                * One special case is the use of BD_SC_EMPTY.  If
-                * this is not set, we are supposed to be ignoring
-                * inputs.  In this case, just mark the buffer empty and
-                * continue.
-               if (!(info->read_status_mask & BD_SC_EMPTY)) {
-                       bdp->cbd_sc |= BD_SC_EMPTY;
-                       bdp->cbd_sc &=
-                               ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
-                       if (bdp->cbd_sc & BD_SC_WRAP)
-                               bdp = info->rx_bd_base;
-                       else
-                               bdp++;
-                       continue;
-               }
-                */
-
-               /* Get the number of characters and the buffer pointer.
-               */
-               i = bdp->cbd_datlen;
-               cp = (unsigned char *)__va(bdp->cbd_bufaddr);
-               status = bdp->cbd_sc;
-#ifdef CONFIG_KGDB
-               if (info->state->smc_scc_num == KGDB_SER_IDX) {
-                       if (*cp == 0x03 || *cp == '$')
-                               breakpoint();
-                       return;
-               }
-#endif
-
-               /* Check to see if there is room in the tty buffer for
-                * the characters in our BD buffer.  If not, we exit
-                * now, leaving the BD with the characters.  We'll pick
-                * them up again on the next receive interrupt (which could
-                * be a timeout).
-                */
-               if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE)
-                       break;
-
-               while (i-- > 0) {
-                       ch = *cp++;
-                       *tty->flip.char_buf_ptr = ch;
-                       icount->rx++;
-
-#ifdef SERIAL_DEBUG_INTR
-                       printk("DR%02x:%02x...", ch, *status);
-#endif
-                       *tty->flip.flag_buf_ptr = 0;
-                       if (status & (BD_SC_BR | BD_SC_FR |
-                                      BD_SC_PR | BD_SC_OV)) {
-                               /*
-                                * For statistics only
-                                */
-                               if (status & BD_SC_BR)
-                                       icount->brk++;
-                               else if (status & BD_SC_PR)
-                                       icount->parity++;
-                               else if (status & BD_SC_FR)
-                                       icount->frame++;
-                               if (status & BD_SC_OV)
-                                       icount->overrun++;
-
-                               /*
-                                * Now check to see if character should be
-                                * ignored, and mask off conditions which
-                                * should be ignored.
-                               if (status & info->ignore_status_mask) {
-                                       if (++ignored > 100)
-                                               break;
-                                       continue;
-                               }
-                                */
-                               status &= info->read_status_mask;
-
-                               if (status & (BD_SC_BR)) {
-#ifdef SERIAL_DEBUG_INTR
-                                       printk("handling break....");
-#endif
-                                       *tty->flip.flag_buf_ptr = TTY_BREAK;
-                                       if (info->flags & ASYNC_SAK)
-                                               do_SAK(tty);
-                               } else if (status & BD_SC_PR)
-                                       *tty->flip.flag_buf_ptr = TTY_PARITY;
-                               else if (status & BD_SC_FR)
-                                       *tty->flip.flag_buf_ptr = TTY_FRAME;
-                               if (status & BD_SC_OV) {
-                                       /*
-                                        * Overrun is special, since it's
-                                        * reported immediately, and doesn't
-                                        * affect the current character
-                                        */
-                                       if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-                                               tty->flip.count++;
-                                               tty->flip.flag_buf_ptr++;
-                                               tty->flip.char_buf_ptr++;
-                                               *tty->flip.flag_buf_ptr =
-                                                               TTY_OVERRUN;
-                                       }
-                               }
-                       }
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-                       if (break_pressed && info->line == sercons.index) {
-                               if (ch != 0 && time_before(jiffies,
-                                                       break_pressed + HZ*5)) {
-                                       handle_sysrq(ch, regs, NULL);
-                                       break_pressed = 0;
-                                       goto ignore_char;
-                               } else
-                                       break_pressed = 0;
-                       }
-#endif
-       
-                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                               break;
-
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
-               }
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-       ignore_char:
-#endif
-
-               /* This BD is ready to be used again.  Clear status.
-                * Get next BD.
-                */
-               bdp->cbd_sc |= BD_SC_EMPTY;
-               bdp->cbd_sc &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
-               if (bdp->cbd_sc & BD_SC_WRAP)
-                       bdp = info->rx_bd_base;
-               else
-                       bdp++;
-       }
-
-       info->rx_cur = (cbd_t *)bdp;
-
-       schedule_delayed_work(&tty->flip.work, 1);
-}
-
-static _INLINE_ void receive_break(ser_info_t *info, struct pt_regs *regs)
-{
-       struct tty_struct *tty = info->tty;
-
-       info->state->icount.brk++;
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-       if (info->line == sercons.index) {
-               if (!break_pressed) {
-                       break_pressed = jiffies;
-                       return;
-               } else
-                       break_pressed = 0;
-       }
-#endif
-
-       /* Check to see if there is room in the tty buffer for
-        * the break.  If not, we exit now, losing the break.  FIXME
-        */
-       if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE)
-               return;
-       *(tty->flip.flag_buf_ptr++) = TTY_BREAK;
-       *(tty->flip.char_buf_ptr++) = 0;
-       tty->flip.count++;
-}
-
-
-static _INLINE_ void transmit_chars(ser_info_t *info, struct pt_regs *regs)
-{
-
-       if (info->flags & TX_WAKEUP) {
-               rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
-       }
-
-#ifdef SERIAL_DEBUG_INTR
-       printk("THRE...");
-#endif
-}
-
-#ifdef notdef
-       /* I need to do this for the SCCs, so it is left as a reminder.
-       */
-static _INLINE_ void check_modem_status(struct async_struct *info)
-{
-       int     status;
-       struct  async_icount *icount;
-
-       status = serial_in(info, UART_MSR);
-
-       if (status & UART_MSR_ANY_DELTA) {
-               icount = &info->state->icount;
-               /* update input line counters */
-               if (status & UART_MSR_TERI)
-                       icount->rng++;
-               if (status & UART_MSR_DDSR)
-                       icount->dsr++;
-               if (status & UART_MSR_DDCD) {
-                       icount->dcd++;
-#ifdef CONFIG_HARD_PPS
-                       if ((info->flags & ASYNC_HARDPPS_CD) &&
-                           (status & UART_MSR_DCD))
-                               hardpps();
-#endif
-               }
-               if (status & UART_MSR_DCTS)
-                       icount->cts++;
-               wake_up_interruptible(&info->delta_msr_wait);
-       }
-
-       if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
-#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
-               printk("ttys%d CD now %s...", info->line,
-                      (status & UART_MSR_DCD) ? "on" : "off");
-#endif
-               if (status & UART_MSR_DCD)
-                       wake_up_interruptible(&info->open_wait);
-               else {
-#ifdef SERIAL_DEBUG_OPEN
-                       printk("scheduling hangup...");
-#endif
-                       schedule_work(&info->tqueue_hangup);
-               }
-       }
-       if (info->flags & ASYNC_CTS_FLOW) {
-               if (info->tty->hw_stopped) {
-                       if (status & UART_MSR_CTS) {
-#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
-                               printk("CTS tx start...");
-#endif
-                               info->tty->hw_stopped = 0;
-                               info->IER |= UART_IER_THRI;
-                               serial_out(info, UART_IER, info->IER);
-                               rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
-                               return;
-                       }
-               } else {
-                       if (!(status & UART_MSR_CTS)) {
-#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
-                               printk("CTS tx stop...");
-#endif
-                               info->tty->hw_stopped = 1;
-                               info->IER &= ~UART_IER_THRI;
-                               serial_out(info, UART_IER, info->IER);
-                       }
-               }
-       }
-}
-#endif
-
-/*
- * This is the serial driver's interrupt routine for a single port
- */
-static irqreturn_t rs_8xx_interrupt(int irq, void * dev_id, struct pt_regs * regs)
-{
-       u_char  events;
-       int     idx;
-       ser_info_t *info;
-       volatile smc_t  *smcp;
-       volatile scc_t  *sccp;
-
-       info = (ser_info_t *)dev_id;
-
-       if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               smcp = &immr->im_smc[idx];
-               events = smcp->smc_smce;
-               if (events & SMCM_BRKE)
-                       receive_break(info, regs);
-               if (events & SMCM_RX)
-                       receive_chars(info, regs);
-               if (events & SMCM_TX)
-                       transmit_chars(info, regs);
-               smcp->smc_smce = events;
-       }
-       else {
-               sccp = &immr->im_scc[idx - SCC_IDX_BASE];
-               events = sccp->scc_scce;
-               if (events & SMCM_BRKE)
-                       receive_break(info, regs);
-               if (events & SCCM_RX)
-                       receive_chars(info, regs);
-               if (events & SCCM_TX)
-                       transmit_chars(info, regs);
-               sccp->scc_scce = events;
-       }
-
-#ifdef SERIAL_DEBUG_INTR
-       printk("rs_interrupt_single(%d, %x)...",
-                                       info->state->smc_scc_num, events);
-#endif
-#ifdef modem_control
-       check_modem_status(info);
-#endif
-       info->last_active = jiffies;
-#ifdef SERIAL_DEBUG_INTR
-       printk("end.\n");
-#endif
-       return IRQ_HANDLED;
-}
-
-
-/*
- * -------------------------------------------------------------------
- * Here ends the serial interrupt routines.
- * -------------------------------------------------------------------
- */
-
-/*
- * This routine is used to handle the "bottom half" processing for the
- * serial driver, known also the "software interrupt" processing.
- * This processing is done at the kernel interrupt level, after the
- * rs_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON.  This
- * is where time-consuming activities which can not be done in the
- * interrupt driver proper are done; the interrupt driver schedules
- * them using rs_sched_event(), and they get done here.
- */
-static void do_softint(void *private_)
-{
-       ser_info_t      *info = (ser_info_t *) private_;
-       struct tty_struct       *tty;
-
-       tty = info->tty;
-       if (!tty)
-               return;
-
-       if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
-               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                   tty->ldisc.write_wakeup)
-                       (tty->ldisc.write_wakeup)(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
-}
-
-/*
- * This routine is called from the scheduler work queue when the interrupt
- * routine has signalled that a hangup has occurred.  The path of
- * hangup processing is:
- *
- *     serial interrupt routine -> (scheduler tqueue) ->
- *     do_serial_hangup() -> tty->hangup() -> rs_hangup()
- *
- */
-static void do_serial_hangup(void *private_)
-{
-       struct async_struct     *info = (struct async_struct *) private_;
-       struct tty_struct       *tty;
-
-       tty = info->tty;
-       if (tty)
-               tty_hangup(tty);
-}
-
-/*static void rs_8xx_timer(void)
-{
-       printk("rs_8xx_timer\n");
-}*/
-
-
-static int startup(ser_info_t *info)
-{
-       unsigned long flags;
-       int     retval=0;
-       int     idx;
-       struct serial_state *state= info->state;
-       volatile smc_t          *smcp;
-       volatile scc_t          *sccp;
-       volatile smc_uart_t     *up;
-       volatile scc_uart_t     *scup;
-
-
-       save_flags(flags); cli();
-
-       if (info->flags & ASYNC_INITIALIZED) {
-               goto errout;
-       }
-
-#ifdef maybe
-       if (!state->port || !state->type) {
-               if (info->tty)
-                       set_bit(TTY_IO_ERROR, &info->tty->flags);
-               goto errout;
-       }
-#endif
-
-#ifdef SERIAL_DEBUG_OPEN
-       printk("starting up ttys%d (irq %d)...", info->line, state->irq);
-#endif
-
-
-#ifdef modem_control
-       info->MCR = 0;
-       if (info->tty->termios->c_cflag & CBAUD)
-               info->MCR = UART_MCR_DTR | UART_MCR_RTS;
-#endif
-
-       if (info->tty)
-               clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
-       /*
-        * and set the speed of the serial port
-        */
-       change_speed(info);
-
-       if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               smcp = &immr->im_smc[idx];
-
-               /* Enable interrupts and I/O.
-               */
-               smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
-               smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
-
-               /* We can tune the buffer length and idle characters
-                * to take advantage of the entire incoming buffer size.
-                * If mrblr is something other than 1, maxidl has to be
-                * non-zero or we never get an interrupt.  The maxidl
-                * is the number of character times we wait after reception
-                * of the last character before we decide no more characters
-                * are coming.
-                */
-               up = (smc_uart_t *)&immr->im_dprambase[state->port];
-#if 0
-               up->smc_mrblr = 1;      /* receive buffer length */
-               up->smc_maxidl = 0;     /* wait forever for next char */
-#else
-               up->smc_mrblr = RX_BUF_SIZE;
-               up->smc_maxidl = RX_BUF_SIZE;
-#endif
-               up->smc_brkcr = 1;      /* number of break chars */
-       }
-       else {
-               sccp = &immr->im_scc[idx - SCC_IDX_BASE];
-               scup = (scc_uart_t *)&immr->im_dprambase[state->port];
-#if 0
-               scup->scc_genscc.scc_mrblr = 1; /* receive buffer length */
-               scup->scc_maxidl = 0;   /* wait forever for next char */
-#else
-               scup->scc_genscc.scc_mrblr = RX_BUF_SIZE;
-               scup->scc_maxidl = RX_BUF_SIZE;
-#endif
-
-               sccp->scc_sccm |= (UART_SCCM_TX | UART_SCCM_RX);
-               sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       }
-
-       info->flags |= ASYNC_INITIALIZED;
-       restore_flags(flags);
-       return 0;
-
-errout:
-       restore_flags(flags);
-       return retval;
-}
-
-/*
- * This routine will shutdown a serial port; interrupts are disabled, and
- * DTR is dropped if the hangup on close termio flag is on.
- */
-static void shutdown(ser_info_t * info)
-{
-       unsigned long   flags;
-       struct serial_state *state;
-       int             idx;
-       volatile smc_t  *smcp;
-       volatile scc_t  *sccp;
-
-       if (!(info->flags & ASYNC_INITIALIZED))
-               return;
-
-       state = info->state;
-
-#ifdef SERIAL_DEBUG_OPEN
-       printk("Shutting down serial port %d (irq %d)....", info->line,
-              state->irq);
-#endif
-
-       save_flags(flags); cli(); /* Disable interrupts */
-
-       if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               smcp = &immr->im_smc[idx];
-
-               /* Disable interrupts and I/O.
-               */
-               smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
-#ifdef CONFIG_SERIAL_CONSOLE
-               /* We can't disable the transmitter if this is the
-                * system console.
-                */
-               if (idx != CONFIG_SERIAL_CONSOLE_PORT)
-#endif
-                       smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-       }
-       else {
-               sccp = &immr->im_scc[idx - SCC_IDX_BASE];
-               sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
-#ifdef CONFIG_SERIAL_CONSOLE
-               if (idx != CONFIG_SERIAL_CONSOLE_PORT)
-                       sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#endif
-       }
-
-       if (info->tty)
-               set_bit(TTY_IO_ERROR, &info->tty->flags);
-
-       info->flags &= ~ASYNC_INITIALIZED;
-       restore_flags(flags);
-}
-
-/*
- * This routine is called to set the UART divisor registers to match
- * the specified baud rate for a serial port.
- */
-static void change_speed(ser_info_t *info)
-{
-       int     baud_rate;
-       unsigned cflag, cval, scval, prev_mode;
-       int     i, bits, sbits, idx;
-       unsigned long   flags;
-       volatile smc_t  *smcp;
-       volatile scc_t  *sccp;
-
-       if (!info->tty || !info->tty->termios)
-               return;
-       cflag = info->tty->termios->c_cflag;
-
-       /* Character length programmed into the mode register is the
-        * sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
-        * 1 or 2 stop bits, minus 1.
-        * The value 'bits' counts this for us.
-        */
-       cval = 0;
-       scval = 0;
-
-       /* byte size and parity */
-       switch (cflag & CSIZE) {
-             case CS5: bits = 5; break;
-             case CS6: bits = 6; break;
-             case CS7: bits = 7; break;
-             case CS8: bits = 8; break;
-             /* Never happens, but GCC is too dumb to figure it out */
-             default:  bits = 8; break;
-       }
-       sbits = bits - 5;
-
-       if (cflag & CSTOPB) {
-               cval |= SMCMR_SL;       /* Two stops */
-               scval |= SCU_PMSR_SL;
-               bits++;
-       }
-       if (cflag & PARENB) {
-               cval |= SMCMR_PEN;
-               scval |= SCU_PMSR_PEN;
-               bits++;
-       }
-       if (!(cflag & PARODD)) {
-               cval |= SMCMR_PM_EVEN;
-               scval |= (SCU_PMSR_REVP | SCU_PMSR_TEVP);
-       }
-
-       /* Determine divisor based on baud rate */
-       i = cflag & CBAUD;
-       if (i >= (sizeof(baud_table)/sizeof(int)))
-               baud_rate = 9600;
-       else
-               baud_rate = baud_table[i];
-
-       info->timeout = (TX_BUF_SIZE*HZ*bits);
-       info->timeout += HZ/50;         /* Add .02 seconds of slop */
-
-#ifdef modem_control
-       /* CTS flow control flag and modem status interrupts */
-       info->IER &= ~UART_IER_MSI;
-       if (info->flags & ASYNC_HARDPPS_CD)
-               info->IER |= UART_IER_MSI;
-       if (cflag & CRTSCTS) {
-               info->flags |= ASYNC_CTS_FLOW;
-               info->IER |= UART_IER_MSI;
-       } else
-               info->flags &= ~ASYNC_CTS_FLOW;
-       if (cflag & CLOCAL)
-               info->flags &= ~ASYNC_CHECK_CD;
-       else {
-               info->flags |= ASYNC_CHECK_CD;
-               info->IER |= UART_IER_MSI;
-       }
-       serial_out(info, UART_IER, info->IER);
-#endif
-
-       /*
-        * Set up parity check flag
-        */
-#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
-       info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
-       if (I_INPCK(info->tty))
-               info->read_status_mask |= BD_SC_FR | BD_SC_PR;
-       if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
-               info->read_status_mask |= BD_SC_BR;
-
-       /*
-        * Characters to ignore
-        */
-       info->ignore_status_mask = 0;
-       if (I_IGNPAR(info->tty))
-               info->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
-       if (I_IGNBRK(info->tty)) {
-               info->ignore_status_mask |= BD_SC_BR;
-               /*
-                * If we're ignore parity and break indicators, ignore
-                * overruns too.  (For real raw support).
-                */
-               if (I_IGNPAR(info->tty))
-                       info->ignore_status_mask |= BD_SC_OV;
-       }
-       /*
-        * !!! ignore all characters if CREAD is not set
-        */
-       if ((cflag & CREAD) == 0)
-               info->read_status_mask &= ~BD_SC_EMPTY;
-       save_flags(flags); cli();
-
-       /* Start bit has not been added (so don't, because we would just
-        * subtract it later), and we need to add one for the number of
-        * stops bits (there is always at least one).
-        */
-       bits++;
-       if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               smcp = &immr->im_smc[idx];
-
-               /* Set the mode register.  We want to keep a copy of the
-                * enables, because we want to put them back if they were
-                * present.
-                */
-               prev_mode = smcp->smc_smcmr;
-               smcp->smc_smcmr = smcr_mk_clen(bits) | cval |  SMCMR_SM_UART;
-               smcp->smc_smcmr |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
-       }
-       else {
-               sccp = &immr->im_scc[idx - SCC_IDX_BASE];
-               sccp->scc_pmsr = (sbits << 12) | scval;
-       }
-
-       m8260_cpm_setbrg(info->state->smc_scc_num, baud_rate);
-
-       restore_flags(flags);
-}
-
-static void rs_8xx_put_char(struct tty_struct *tty, unsigned char ch)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       volatile cbd_t  *bdp;
-
-       if (serial_paranoia_check(info, tty->name, "rs_put_char"))
-               return;
-
-       if (!tty)
-               return;
-
-       bdp = info->tx_cur;
-       while (bdp->cbd_sc & BD_SC_READY);
-
-       *((char *)__va(bdp->cbd_bufaddr)) = ch;
-       bdp->cbd_datlen = 1;
-       bdp->cbd_sc |= BD_SC_READY;
-
-       /* Get next BD.
-       */
-       if (bdp->cbd_sc & BD_SC_WRAP)
-               bdp = info->tx_bd_base;
-       else
-               bdp++;
-
-       info->tx_cur = (cbd_t *)bdp;
-
-}
-
-static int rs_8xx_write(struct tty_struct * tty, int from_user,
-                   const unsigned char *buf, int count)
-{
-       int     c, ret = 0;
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       volatile cbd_t *bdp;
-
-       if (serial_paranoia_check(info, tty->name, "rs_write"))
-               return 0;
-
-       if (!tty)
-               return 0;
-
-       bdp = info->tx_cur;
-
-       while (1) {
-               c = min(count, TX_BUF_SIZE);
-
-               if (c <= 0)
-                       break;
-
-               if (bdp->cbd_sc & BD_SC_READY) {
-                       info->flags |= TX_WAKEUP;
-                       break;
-               }
-
-               if (from_user) {
-                       if (copy_from_user(__va(bdp->cbd_bufaddr), buf, c)) {
-                               if (!ret)
-                                       ret = -EFAULT;
-                               break;
-                       }
-               } else {
-                       memcpy(__va(bdp->cbd_bufaddr), buf, c);
-               }
-
-               bdp->cbd_datlen = c;
-               bdp->cbd_sc |= BD_SC_READY;
-
-               buf += c;
-               count -= c;
-               ret += c;
-
-               /* Get next BD.
-               */
-               if (bdp->cbd_sc & BD_SC_WRAP)
-                       bdp = info->tx_bd_base;
-               else
-                       bdp++;
-               info->tx_cur = (cbd_t *)bdp;
-       }
-       return ret;
-}
-
-static int rs_8xx_write_room(struct tty_struct *tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       int     ret;
-
-       if (serial_paranoia_check(info, tty->name, "rs_write_room"))
-               return 0;
-
-       if ((info->tx_cur->cbd_sc & BD_SC_READY) == 0) {
-               info->flags &= ~TX_WAKEUP;
-               ret = TX_BUF_SIZE;
-       }
-       else {
-               info->flags |= TX_WAKEUP;
-               ret = 0;
-       }
-       return ret;
-}
-
-/* I could track this with transmit counters....maybe later.
-*/
-static int rs_8xx_chars_in_buffer(struct tty_struct *tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-               
-       if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
-               return 0;
-       return 0;
-}
-
-static void rs_8xx_flush_buffer(struct tty_struct *tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-               
-       if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
-               return;
-
-       /* There is nothing to "flush", whatever we gave the CPM
-        * is on its way out.
-        */
-       wake_up_interruptible(&tty->write_wait);
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-           tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup)(tty);
-       info->flags &= ~TX_WAKEUP;
-}
-
-/*
- * This function is used to send a high-priority XON/XOFF character to
- * the device
- */
-static void rs_8xx_send_xchar(struct tty_struct *tty, char ch)
-{
-       volatile cbd_t  *bdp;
-
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-
-       if (serial_paranoia_check(info, tty->name, "rs_send_char"))
-               return;
-
-       bdp = info->tx_cur;
-       while (bdp->cbd_sc & BD_SC_READY);
-
-       *((char *)__va(bdp->cbd_bufaddr)) = ch;
-       bdp->cbd_datlen = 1;
-       bdp->cbd_sc |= BD_SC_READY;
-
-       /* Get next BD.
-       */
-       if (bdp->cbd_sc & BD_SC_WRAP)
-               bdp = info->tx_bd_base;
-       else
-               bdp++;
-
-       info->tx_cur = (cbd_t *)bdp;
-}
-
-/*
- * ------------------------------------------------------------
- * rs_throttle()
- *
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled.
- * ------------------------------------------------------------
- */
-static void rs_8xx_throttle(struct tty_struct * tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
-       char    buf[64];
-
-       printk("throttle %s: %d....\n", _tty_name(tty, buf),
-              tty->ldisc.chars_in_buffer(tty));
-#endif
-
-       if (serial_paranoia_check(info, tty->name, "rs_throttle"))
-               return;
-
-       if (I_IXOFF(tty))
-               rs_8xx_send_xchar(tty, STOP_CHAR(tty));
-
-#ifdef modem_control
-       if (tty->termios->c_cflag & CRTSCTS)
-               info->MCR &= ~UART_MCR_RTS;
-
-       cli();
-       serial_out(info, UART_MCR, info->MCR);
-       sti();
-#endif
-}
-
-static void rs_8xx_unthrottle(struct tty_struct * tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
-       char    buf[64];
-
-       printk("unthrottle %s: %d....\n", _tty_name(tty, buf),
-              tty->ldisc.chars_in_buffer(tty));
-#endif
-
-       if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
-               return;
-
-       if (I_IXOFF(tty)) {
-               if (info->x_char)
-                       info->x_char = 0;
-               else
-                       rs_8xx_send_xchar(tty, START_CHAR(tty));
-       }
-#ifdef modem_control
-       if (tty->termios->c_cflag & CRTSCTS)
-               info->MCR |= UART_MCR_RTS;
-       cli();
-       serial_out(info, UART_MCR, info->MCR);
-       sti();
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl() and friends
- * ------------------------------------------------------------
- */
-
-#ifdef maybe
-/*
- * get_lsr_info - get line status register info
- *
- * Purpose: Let user call ioctl() to get info when the UART physically
- *         is emptied.  On bus types like RS485, the transmitter must
- *         release the bus after transmitting. This must be done when
- *         the transmit shift register is empty, not be done when the
- *         transmit holding register is empty.  This functionality
- *         allows an RS485 driver to be written in user space.
- */
-static int get_lsr_info(struct async_struct * info, unsigned int *value)
-{
-       unsigned char status;
-       unsigned int result;
-
-       cli();
-       status = serial_in(info, UART_LSR);
-       sti();
-       result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
-       return put_user(result,value);
-}
-#endif
-
-static int get_modem_info(ser_info_t *info, unsigned int *value)
-{
-       unsigned int result = 0;
-#ifdef modem_control
-       unsigned char control, status;
-
-       control = info->MCR;
-       cli();
-       status = serial_in(info, UART_MSR);
-       sti();
-       result =  ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
-               | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
-#ifdef TIOCM_OUT1
-               | ((control & UART_MCR_OUT1) ? TIOCM_OUT1 : 0)
-               | ((control & UART_MCR_OUT2) ? TIOCM_OUT2 : 0)
-#endif
-               | ((status  & UART_MSR_DCD) ? TIOCM_CAR : 0)
-               | ((status  & UART_MSR_RI) ? TIOCM_RNG : 0)
-               | ((status  & UART_MSR_DSR) ? TIOCM_DSR : 0)
-               | ((status  & UART_MSR_CTS) ? TIOCM_CTS : 0);
-#endif
-       return put_user(result,value);
-}
-
-static int set_modem_info(ser_info_t *info, unsigned int cmd,
-                         unsigned int *value)
-{
-       int error;
-       unsigned int arg;
-
-       error = get_user(arg, value);
-       if (error)
-               return error;
-#ifdef modem_control
-       switch (cmd) {
-       case TIOCMBIS:
-               if (arg & TIOCM_RTS)
-                       info->MCR |= UART_MCR_RTS;
-               if (arg & TIOCM_DTR)
-                       info->MCR |= UART_MCR_DTR;
-#ifdef TIOCM_OUT1
-               if (arg & TIOCM_OUT1)
-                       info->MCR |= UART_MCR_OUT1;
-               if (arg & TIOCM_OUT2)
-                       info->MCR |= UART_MCR_OUT2;
-#endif
-               break;
-       case TIOCMBIC:
-               if (arg & TIOCM_RTS)
-                       info->MCR &= ~UART_MCR_RTS;
-               if (arg & TIOCM_DTR)
-                       info->MCR &= ~UART_MCR_DTR;
-#ifdef TIOCM_OUT1
-               if (arg & TIOCM_OUT1)
-                       info->MCR &= ~UART_MCR_OUT1;
-               if (arg & TIOCM_OUT2)
-                       info->MCR &= ~UART_MCR_OUT2;
-#endif
-               break;
-       case TIOCMSET:
-               info->MCR = ((info->MCR & ~(UART_MCR_RTS |
-#ifdef TIOCM_OUT1
-                                           UART_MCR_OUT1 |
-                                           UART_MCR_OUT2 |
-#endif
-                                           UART_MCR_DTR))
-                            | ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0)
-#ifdef TIOCM_OUT1
-                            | ((arg & TIOCM_OUT1) ? UART_MCR_OUT1 : 0)
-                            | ((arg & TIOCM_OUT2) ? UART_MCR_OUT2 : 0)
-#endif
-                            | ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0));
-               break;
-       default:
-               return -EINVAL;
-       }
-       cli();
-       serial_out(info, UART_MCR, info->MCR);
-       sti();
-#endif
-       return 0;
-}
-
-/* Sending a break is a two step process on the SMC/SCC.  It is accomplished
- * by sending a STOP TRANSMIT command followed by a RESTART TRANSMIT
- * command.  We take advantage of the begin/end functions to make this
- * happen.
- */
-static void begin_break(ser_info_t *info)
-{
-       volatile cpm8260_t *cp;
-       uint    page, sblock;
-       int     num;
-
-       cp = cpmp;
-
-       if ((num = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               if (num == 0) {
-                       page = CPM_CR_SMC1_PAGE;
-                       sblock = CPM_CR_SMC1_SBLOCK;
-               }
-               else {
-                       page = CPM_CR_SMC2_PAGE;
-                       sblock = CPM_CR_SMC2_SBLOCK;
-               }
-       }
-       else {
-               num -= SCC_NUM_BASE;
-               switch (num) {
-               case 0:
-                       page = CPM_CR_SCC1_PAGE;
-                       sblock = CPM_CR_SCC1_SBLOCK;
-                       break;
-               case 1:
-                       page = CPM_CR_SCC2_PAGE;
-                       sblock = CPM_CR_SCC2_SBLOCK;
-                       break;
-               case 2:
-                       page = CPM_CR_SCC3_PAGE;
-                       sblock = CPM_CR_SCC3_SBLOCK;
-                       break;
-               case 3:
-                       page = CPM_CR_SCC4_PAGE;
-                       sblock = CPM_CR_SCC4_SBLOCK;
-                       break;
-               default: return;
-               }
-       }
-       cp->cp_cpcr = mk_cr_cmd(page, sblock, 0, CPM_CR_STOP_TX) | CPM_CR_FLG;
-       while (cp->cp_cpcr & CPM_CR_FLG);
-}
-
-static void end_break(ser_info_t *info)
-{
-       volatile cpm8260_t *cp;
-       uint    page, sblock;
-       int     num;
-
-       cp = cpmp;
-
-       if ((num = info->state->smc_scc_num) < SCC_NUM_BASE) {
-               if (num == 0) {
-                       page = CPM_CR_SMC1_PAGE;
-                       sblock = CPM_CR_SMC1_SBLOCK;
-               }
-               else {
-                       page = CPM_CR_SMC2_PAGE;
-                       sblock = CPM_CR_SMC2_SBLOCK;
-               }
-       }
-       else {
-               num -= SCC_NUM_BASE;
-               switch (num) {
-               case 0:
-                       page = CPM_CR_SCC1_PAGE;
-                       sblock = CPM_CR_SCC1_SBLOCK;
-                       break;
-               case 1:
-                       page = CPM_CR_SCC2_PAGE;
-                       sblock = CPM_CR_SCC2_SBLOCK;
-                       break;
-               case 2:
-                       page = CPM_CR_SCC3_PAGE;
-                       sblock = CPM_CR_SCC3_SBLOCK;
-                       break;
-               case 3:
-                       page = CPM_CR_SCC4_PAGE;
-                       sblock = CPM_CR_SCC4_SBLOCK;
-                       break;
-               default: return;
-               }
-       }
-       cp->cp_cpcr = mk_cr_cmd(page, sblock, 0, CPM_CR_RESTART_TX) | CPM_CR_FLG;
-       while (cp->cp_cpcr & CPM_CR_FLG);
-}
-
-/*
- * This routine sends a break character out the serial port.
- */
-static void send_break(ser_info_t *info, int duration)
-{
-       current->state = TASK_INTERRUPTIBLE;
-#ifdef SERIAL_DEBUG_SEND_BREAK
-       printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
-#endif
-       begin_break(info);
-       schedule_timeout(duration);
-       end_break(info);
-#ifdef SERIAL_DEBUG_SEND_BREAK
-       printk("done jiffies=%lu\n", jiffies);
-#endif
-}
-
-
-static int rs_8xx_ioctl(struct tty_struct *tty, struct file * file,
-                   unsigned int cmd, unsigned long arg)
-{
-       int error;
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       int retval;
-       struct async_icount cnow;       /* kernel counter temps */
-       struct serial_icounter_struct *p_cuser; /* user space */
-
-       if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
-               return -ENODEV;
-
-       if ((cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
-                   return -EIO;
-       }
-
-       switch (cmd) {
-               case TCSBRK:    /* SVID version: non-zero arg --> no break */
-                       retval = tty_check_change(tty);
-                       if (retval)
-                               return retval;
-                       tty_wait_until_sent(tty, 0);
-                       if (signal_pending(current))
-                               return -EINTR;
-                       if (!arg) {
-                               send_break(info, HZ/4); /* 1/4 second */
-                               if (signal_pending(current))
-                                       return -EINTR;
-                       }
-                       return 0;
-               case TCSBRKP:   /* support for POSIX tcsendbreak() */
-                       retval = tty_check_change(tty);
-                       if (retval)
-                               return retval;
-                       tty_wait_until_sent(tty, 0);
-                       if (signal_pending(current))
-                               return -EINTR;
-                       send_break(info, arg ? arg*(HZ/10) : HZ/4);
-                       if (signal_pending(current))
-                               return -EINTR;
-                       return 0;
-               case TIOCSBRK:
-                       retval = tty_check_change(tty);
-                       if (retval)
-                               return retval;
-                       tty_wait_until_sent(tty, 0);
-                       begin_break(info);
-                       return 0;
-               case TIOCCBRK:
-                       retval = tty_check_change(tty);
-                       if (retval)
-                               return retval;
-                       end_break(info);
-                       return 0;
-               case TIOCGSOFTCAR:
-                       return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg);
-               case TIOCSSOFTCAR:
-                       error = get_user(arg, (unsigned int *) arg);
-                       if (error)
-                               return error;
-                       tty->termios->c_cflag =
-                               ((tty->termios->c_cflag & ~CLOCAL) |
-                                (arg ? CLOCAL : 0));
-                       return 0;
-               case TIOCMGET:
-                       return get_modem_info(info, (unsigned int *) arg);
-               case TIOCMBIS:
-               case TIOCMBIC:
-               case TIOCMSET:
-                       return set_modem_info(info, cmd, (unsigned int *) arg);
-#ifdef maybe
-               case TIOCSERGETLSR: /* Get line status register */
-                       return get_lsr_info(info, (unsigned int *) arg);
-#endif
-               /*
-                * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
-                * - mask passed in arg for lines of interest
-                *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
-                * Caller should use TIOCGICOUNT to see which one it was
-                */
-                case TIOCMIWAIT:
-#ifdef modem_control
-                       cli();
-                       /* note the counters on entry */
-                       cprev = info->state->icount;
-                       sti();
-                       while (1) {
-                               interruptible_sleep_on(&info->delta_msr_wait);
-                               /* see if a signal did it */
-                               if (signal_pending(current))
-                                       return -ERESTARTSYS;
-                               cli();
-                               cnow = info->state->icount; /* atomic copy */
-                               sti();
-                               if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
-                                   cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
-                                       return -EIO; /* no change => error */
-                               if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
-                                    ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
-                                    ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
-                                    ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
-                                       return 0;
-                               }
-                               cprev = cnow;
-                       }
-                       /* NOTREACHED */
-#else
-                       return 0;
-#endif
-
-               /*
-                * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
-                * Return: write counters to the user passed counter struct
-                * NB: both 1->0 and 0->1 transitions are counted except for
-                *     RI where only 0->1 is counted.
-                */
-               case TIOCGICOUNT:
-                       cli();
-                       cnow = info->state->icount;
-                       sti();
-                       p_cuser = (struct serial_icounter_struct *) arg;
-                       error = put_user(cnow.cts, &p_cuser->cts);
-                       if (error) return error;
-                       error = put_user(cnow.dsr, &p_cuser->dsr);
-                       if (error) return error;
-                       error = put_user(cnow.rng, &p_cuser->rng);
-                       if (error) return error;
-                       error = put_user(cnow.dcd, &p_cuser->dcd);
-                       if (error) return error;
-                       return 0;
-
-               default:
-                       return -ENOIOCTLCMD;
-               }
-       return 0;
-}
-
-/* FIX UP modem control here someday......
-*/
-static void rs_8xx_set_termios(struct tty_struct *tty, struct termios *old_termios)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-
-       if (   (tty->termios->c_cflag == old_termios->c_cflag)
-           && (   RELEVANT_IFLAG(tty->termios->c_iflag)
-               == RELEVANT_IFLAG(old_termios->c_iflag)))
-         return;
-
-       change_speed(info);
-
-#ifdef modem_control
-       /* Handle transition to B0 status */
-       if ((old_termios->c_cflag & CBAUD) &&
-           !(tty->termios->c_cflag & CBAUD)) {
-               info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
-               cli();
-               serial_out(info, UART_MCR, info->MCR);
-               sti();
-       }
-
-       /* Handle transition away from B0 status */
-       if (!(old_termios->c_cflag & CBAUD) &&
-           (tty->termios->c_cflag & CBAUD)) {
-               info->MCR |= UART_MCR_DTR;
-               if (!tty->hw_stopped ||
-                   !(tty->termios->c_cflag & CRTSCTS)) {
-                       info->MCR |= UART_MCR_RTS;
-               }
-               cli();
-               serial_out(info, UART_MCR, info->MCR);
-               sti();
-       }
-
-       /* Handle turning off CRTSCTS */
-       if ((old_termios->c_cflag & CRTSCTS) &&
-           !(tty->termios->c_cflag & CRTSCTS)) {
-               tty->hw_stopped = 0;
-               rs_8xx_start(tty);
-       }
-#endif
-
-#if 0
-       /*
-        * No need to wake up processes in open wait, since they
-        * sample the CLOCAL flag once, and don't recheck it.
-        * XXX  It's not clear whether the current behavior is correct
-        * or not.  Hence, this may change.....
-        */
-       if (!(old_termios->c_cflag & CLOCAL) &&
-           (tty->termios->c_cflag & CLOCAL))
-               wake_up_interruptible(&info->open_wait);
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * rs_close()
- *
- * This routine is called when the serial port gets closed.  First, we
- * wait for the last remaining data to be sent.  Then, we unlink its
- * async structure from the interrupt chain if necessary, and we free
- * that IRQ if nothing is left in the chain.
- * ------------------------------------------------------------
- */
-static void rs_8xx_close(struct tty_struct *tty, struct file * filp)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       struct serial_state *state;
-       unsigned long   flags;
-       int             idx;
-       volatile smc_t  *smcp;
-       volatile scc_t  *sccp;
-
-       if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
-               return;
-
-       state = info->state;
-
-       save_flags(flags); cli();
-
-       if (tty_hung_up_p(filp)) {
-               DBG_CNT("before DEC-hung");
-               restore_flags(flags);
-               return;
-       }
-
-#ifdef SERIAL_DEBUG_OPEN
-       printk("rs_close ttys%d, count = %d\n", info->line, state->count);
-#endif
-       if ((tty->count == 1) && (state->count != 1)) {
-               /*
-                * Uh, oh.  tty->count is 1, which means that the tty
-                * structure will be freed.  state->count should always
-                * be one in these conditions.  If it's greater than
-                * one, we've got real problems, since it means the
-                * serial port won't be shutdown.
-                */
-               printk("rs_close: bad serial port count; tty->count is 1, "
-                      "state->count is %d\n", state->count);
-               state->count = 1;
-       }
-       if (--state->count < 0) {
-               printk("rs_close: bad serial port count for ttys%d: %d\n",
-                      info->line, state->count);
-               state->count = 0;
-       }
-       if (state->count) {
-               DBG_CNT("before DEC-2");
-               restore_flags(flags);
-               return;
-       }
-       info->flags |= ASYNC_CLOSING;
-       /*
-        * Now we wait for the transmit buffer to clear; and we notify
-        * the line discipline to only process XON/XOFF characters.
-        */
-       tty->closing = 1;
-       if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
-               tty_wait_until_sent(tty, info->closing_wait);
-       /*
-        * At this point we stop accepting input.  To do this, we
-        * disable the receive line status interrupts, and tell the
-        * interrupt driver to stop checking the data ready bit in the
-        * line status register.
-        */
-       info->read_status_mask &= ~BD_SC_EMPTY;
-       if (info->flags & ASYNC_INITIALIZED) {
-               if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
-                       smcp = &immr->im_smc[idx];
-                       smcp->smc_smcm &= ~SMCM_RX;
-                       smcp->smc_smcmr &= ~SMCMR_REN;
-               }
-               else {
-                       sccp = &immr->im_scc[idx - SCC_IDX_BASE];
-                       sccp->scc_sccm &= ~UART_SCCM_RX;
-                       sccp->scc_gsmrl &= ~SCC_GSMRL_ENR;
-               }
-               /*
-                * Before we drop DTR, make sure the UART transmitter
-                * has completely drained; this is especially
-                * important if there is a transmit FIFO!
-                */
-               rs_8xx_wait_until_sent(tty, info->timeout);
-       }
-       shutdown(info);
-       if (tty->driver->flush_buffer)
-               tty->driver->flush_buffer(tty);
-       if (tty->ldisc.flush_buffer)
-               tty->ldisc.flush_buffer(tty);
-       tty->closing = 0;
-       info->event = 0;
-       info->tty = 0;
-       if (info->blocked_open) {
-               if (info->close_delay) {
-                       current->state = TASK_INTERRUPTIBLE;
-                       schedule_timeout(info->close_delay);
-               }
-               wake_up_interruptible(&info->open_wait);
-       }
-       info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-       wake_up_interruptible(&info->close_wait);
-       restore_flags(flags);
-}
-
-/*
- * rs_wait_until_sent() --- wait until the transmitter is empty
- */
-static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       unsigned long orig_jiffies, char_time;
-       /*int lsr;*/
-       volatile cbd_t *bdp;
-
-       if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
-               return;
-
-#ifdef maybe
-       if (info->state->type == PORT_UNKNOWN)
-               return;
-#endif
-
-       orig_jiffies = jiffies;
-       /*
-        * Set the check interval to be 1/5 of the estimated time to
-        * send a single character, and make it at least 1.  The check
-        * interval should also be less than the timeout.
-        *
-        * Note: we have to use pretty tight timings here to satisfy
-        * the NIST-PCTS.
-        */
-       char_time = 1;
-       if (timeout)
-               char_time = min(char_time, (unsigned long)timeout);
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-       printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
-       printk("jiff=%lu...", jiffies);
-#endif
-
-       /* We go through the loop at least once because we can't tell
-        * exactly when the last character exits the shifter.  There can
-        * be at least two characters waiting to be sent after the buffers
-        * are empty.
-        */
-       do {
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-               printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
-#endif
-               current->state = TASK_INTERRUPTIBLE;
-/*             current->dyn_prio = 0;   make us low-priority */
-               schedule_timeout(char_time);
-               if (signal_pending(current))
-                       break;
-               if (timeout && time_after(jiffies, orig_jiffies + timeout))
-                       break;
-               bdp = info->tx_cur;
-       } while (bdp->cbd_sc & BD_SC_READY);
-       current->state = TASK_RUNNING;
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-       printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
-#endif
-}
-
-/*
- * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
- */
-static void rs_8xx_hangup(struct tty_struct *tty)
-{
-       ser_info_t *info = (ser_info_t *)tty->driver_data;
-       struct serial_state *state = info->state;
-
-       if (serial_paranoia_check(info, tty->name, "rs_hangup"))
-               return;
-
-       state = info->state;
-
-       rs_8xx_flush_buffer(tty);
-       shutdown(info);
-       info->event = 0;
-       state->count = 0;
-       info->flags &= ~ASYNC_NORMAL_ACTIVE;
-       info->tty = 0;
-       wake_up_interruptible(&info->open_wait);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_open() and friends
- * ------------------------------------------------------------
- */
-static int block_til_ready(struct tty_struct *tty, struct file * filp,
-                          ser_info_t *info)
-{
-#ifdef DO_THIS_LATER
-       DECLARE_WAITQUEUE(wait, current);
-       struct serial_state *state = info->state;
-#endif
-       int             retval;
-       int             do_clocal = 0;
-
-       /*
-        * If the device is in the middle of being closed, then block
-        * until it's done, and then try again.
-        */
-       if (tty_hung_up_p(filp) ||
-           (info->flags & ASYNC_CLOSING)) {
-               if (info->flags & ASYNC_CLOSING)
-                       interruptible_sleep_on(&info->close_wait);
-#ifdef SERIAL_DO_RESTART
-               if (info->flags & ASYNC_HUP_NOTIFY)
-                       return -EAGAIN;
-               else
-                       return -ERESTARTSYS;
-#else
-               return -EAGAIN;
-#endif
-       }
-
-       /*
-        * If non-blocking mode is set, or the port is not enabled,
-        * then make the check up front and then exit.
-        * If this is an SMC port, we don't have modem control to wait
-        * for, so just get out here.
-        */
-       if ((filp->f_flags & O_NONBLOCK) ||
-           (tty->flags & (1 << TTY_IO_ERROR)) ||
-           (info->state->smc_scc_num < SCC_NUM_BASE)) {
-               info->flags |= ASYNC_NORMAL_ACTIVE;
-               return 0;
-       }
-
-       if (tty->termios->c_cflag & CLOCAL)
-               do_clocal = 1;
-
-       /*
-        * Block waiting for the carrier detect and the line to become
-        * free (i.e., not in use by the callout).  While we are in
-        * this loop, state->count is dropped by one, so that
-        * rs_close() knows when to free things.  We restore it upon
-        * exit, either normal or abnormal.
-        */
-       retval = 0;
-#ifdef DO_THIS_LATER
-       add_wait_queue(&info->open_wait, &wait);
-#ifdef SERIAL_DEBUG_OPEN
-       printk("block_til_ready before block: ttys%d, count = %d\n",
-              state->line, state->count);
-#endif
-       cli();
-       if (!tty_hung_up_p(filp))
-               state->count--;
-       sti();
-       info->blocked_open++;
-       while (1) {
-               cli();
-               if (tty->termios->c_cflag & CBAUD)
-                       serial_out(info, UART_MCR,
-                                  serial_inp(info, UART_MCR) |
-                                  (UART_MCR_DTR | UART_MCR_RTS));
-               sti();
-               set_current_state(TASK_INTERRUPTIBLE);
-               if (tty_hung_up_p(filp) ||
-                   !(info->flags & ASYNC_INITIALIZED)) {
-#ifdef SERIAL_DO_RESTART
-                       if (info->flags & ASYNC_HUP_NOTIFY)
-                               retval = -EAGAIN;
-                       else
-                               retval = -ERESTARTSYS;
-#else
-                       retval = -EAGAIN;
-#endif
-                       break;
-               }
-               if (!(info->flags & ASYNC_CLOSING) &&
-                   (do_clocal || (serial_in(info, UART_MSR) &
-                                  UART_MSR_DCD)))
-                       break;
-               if (signal_pending(current)) {
-                       retval = -ERESTARTSYS;
-                       break;
-               }
-#ifdef SERIAL_DEBUG_OPEN
-               printk("block_til_ready blocking: ttys%d, count = %d\n",
-                      info->line, state->count);
-#endif
-               schedule();
-       }
-       current->state = TASK_RUNNING;
-       remove_wait_queue(&info->open_wait, &wait);
-       if (!tty_hung_up_p(filp))
-               state->count++;
-       info->blocked_open--;
-#ifdef SERIAL_DEBUG_OPEN
-       printk("block_til_ready after blocking: ttys%d, count = %d\n",
-              info->line, state->count);
-#endif
-#endif /* DO_THIS_LATER */
-       if (retval)
-               return retval;
-       info->flags |= ASYNC_NORMAL_ACTIVE;
-       return 0;
-}
-
-static int get_async_struct(int line, ser_info_t **ret_info)
-{
-       struct serial_state *sstate;
-
-       sstate = rs_table + line;
-       if (sstate->info) {
-               sstate->count++;
-               *ret_info = (ser_info_t *)sstate->info;
-               return 0;
-       }
-       else {
-               return -ENOMEM;
-       }
-}
-
-/*
- * This routine is called whenever a serial port is opened.  It
- * enables interrupts for a serial port, linking in its async structure into
- * the IRQ chain.   It also performs the serial-specific
- * initialization for the tty structure.
- */
-static int rs_8xx_open(struct tty_struct *tty, struct file * filp)
-{
-       ser_info_t      *info;
-       int             retval, line;
-
-       line = tty->index;
-       if ((line < 0) || (line >= NR_PORTS))
-               return -ENODEV;
-       retval = get_async_struct(line, &info);
-       if (retval)
-               return retval;
-       if (serial_paranoia_check(info, tty->name, "rs_open"))
-               return -ENODEV;
-
-#ifdef SERIAL_DEBUG_OPEN
-       printk("rs_open %s, count = %d\n", tty->name, info->state->count);
-#endif
-       tty->driver_data = info;
-       info->tty = tty;
-
-       /*
-        * Start up serial port
-        */
-       retval = startup(info);
-       if (retval)
-               return retval;
-
-       retval = block_til_ready(tty, filp, info);
-       if (retval) {
-#ifdef SERIAL_DEBUG_OPEN
-               printk("rs_open returning after block_til_ready with %d\n",
-                      retval);
-#endif
-               return retval;
-       }
-
-#ifdef SERIAL_DEBUG_OPEN
-       printk("rs_open %s successful...", line);
-#endif
-       return 0;
-}
-
-/*
- * /proc fs routines....
- */
-
-static inline int line_info(char *buf, struct serial_state *state)
-{
-#ifdef notdef
-       struct async_struct *info = state->info, scr_info;
-       char    stat_buf[30], control, status;
-#endif
-       int     ret;
-
-       ret = sprintf(buf, "%d: uart:%s port:%X irq:%d",
-                     state->line,
-                     (state->smc_scc_num < SCC_NUM_BASE) ? "SMC" : "SCC",
-                     (unsigned int)(state->port), state->irq);
-
-       if (!state->port || (state->type == PORT_UNKNOWN)) {
-               ret += sprintf(buf+ret, "\n");
-               return ret;
-       }
-
-#ifdef notdef
-       /*
-        * Figure out the current RS-232 lines
-        */
-       if (!info) {
-               info = &scr_info;       /* This is just for serial_{in,out} */
-
-               info->magic = SERIAL_MAGIC;
-               info->port = state->port;
-               info->flags = state->flags;
-               info->quot = 0;
-               info->tty = 0;
-       }
-       cli();
-       status = serial_in(info, UART_MSR);
-       control = info ? info->MCR : serial_in(info, UART_MCR);
-       sti();
-
-       stat_buf[0] = 0;
-       stat_buf[1] = 0;
-       if (control & UART_MCR_RTS)
-               strcat(stat_buf, "|RTS");
-       if (status & UART_MSR_CTS)
-               strcat(stat_buf, "|CTS");
-       if (control & UART_MCR_DTR)
-               strcat(stat_buf, "|DTR");
-       if (status & UART_MSR_DSR)
-               strcat(stat_buf, "|DSR");
-       if (status & UART_MSR_DCD)
-               strcat(stat_buf, "|CD");
-       if (status & UART_MSR_RI)
-               strcat(stat_buf, "|RI");
-
-       if (info->quot) {
-               ret += sprintf(buf+ret, " baud:%d",
-                              state->baud_base / info->quot);
-       }
-
-       ret += sprintf(buf+ret, " tx:%d rx:%d",
-                     state->icount.tx, state->icount.rx);
-
-       if (state->icount.frame)
-               ret += sprintf(buf+ret, " fe:%d", state->icount.frame);
-
-       if (state->icount.parity)
-               ret += sprintf(buf+ret, " pe:%d", state->icount.parity);
-
-       if (state->icount.brk)
-               ret += sprintf(buf+ret, " brk:%d", state->icount.brk);
-
-       if (state->icount.overrun)
-               ret += sprintf(buf+ret, " oe:%d", state->icount.overrun);
-
-       /*
-        * Last thing is the RS-232 status lines
-        */
-       ret += sprintf(buf+ret, " %s\n", stat_buf+1);
-#endif
-       return ret;
-}
-
-int rs_8xx_read_proc(char *page, char **start, off_t off, int count,
-                int *eof, void *data)
-{
-       int i, len = 0;
-       off_t   begin = 0;
-
-       len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
-       for (i = 0; i < NR_PORTS && len < 4000; i++) {
-               len += line_info(page + len, &rs_table[i]);
-               if (len+begin > off+count)
-                       goto done;
-               if (len+begin < off) {
-                       begin += len;
-                       len = 0;
-               }
-       }
-       *eof = 1;
-done:
-       if (off >= len+begin)
-               return 0;
-       *start = page + (begin-off);
-       return ((count < begin+len-off) ? count : begin+len-off);
-}
-
-/*
- * ---------------------------------------------------------------------
- * rs_init() and friends
- *
- * rs_init() is called at boot-time to initialize the serial driver.
- * ---------------------------------------------------------------------
- */
-
-/*
- * This routine prints out the appropriate serial driver version
- * number, and identifies which options were configured into this
- * driver.
- */
-static _INLINE_ void show_serial_version(void)
-{
-       printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
-}
-
-
-/*
- * The serial console driver used during boot.  Note that these names
- * clash with those found in "serial.c", so we currently can't support
- * the 16xxx uarts and these at the same time.  I will fix this to become
- * an indirect function call from tty_io.c (or something).
- */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-
-/*
- * Print a string to the serial port trying not to disturb any possible
- * real use of the port...
- * These funcitons work equally well for SCC, even though they are
- * designed for SMC.  Our only interests are the transmit/receive
- * buffers, which are identically mapped for either the SCC or SMC.
- */
-static void my_console_write(int idx, const char *s,
-                               unsigned count)
-{
-       struct          serial_state    *ser;
-       ser_info_t                      *info;
-       unsigned                        i;
-       volatile        cbd_t           *bdp, *bdbase;
-       volatile        smc_uart_t      *up;
-       volatile        u_char          *cp;
-
-       ser = rs_table + idx;
-
-       /* If the port has been initialized for general use, we have
-        * to use the buffer descriptors allocated there.  Otherwise,
-        * we simply use the single buffer allocated.
-        */
-       if ((info = (ser_info_t *)ser->info) != NULL) {
-               bdp = info->tx_cur;
-               bdbase = info->tx_bd_base;
-       }
-       else {
-               /* Pointer to UART in parameter ram.
-               */
-               up = (smc_uart_t *)&immr->im_dprambase[ser->port];
-
-               /* Get the address of the host memory buffer.
-                */
-               bdp = bdbase = (cbd_t *)&immr->im_dprambase[up->smc_tbase];
-       }
-
-       /*
-        * We need to gracefully shut down the transmitter, disable
-        * interrupts, then send our bytes out.
-        */
-
-       /*
-        * Now, do each character.  This is not as bad as it looks
-        * since this is a holding FIFO and not a transmitting FIFO.
-        * We could add the complexity of filling the entire transmit
-        * buffer, but we would just wait longer between accesses......
-        */
-       for (i = 0; i < count; i++, s++) {
-               /* Wait for transmitter fifo to empty.
-                * Ready indicates output is ready, and xmt is doing
-                * that, not that it is ready for us to send.
-                */
-               while (bdp->cbd_sc & BD_SC_READY);
-
-               /* Send the character out.
-                * If the buffer address is in the CPM DPRAM, don't
-                * convert it.
-                */
-               if ((uint)(bdp->cbd_bufaddr) > (uint)IMAP_ADDR)
-                       cp = (u_char *)(bdp->cbd_bufaddr);
-               else
-                       cp = __va(bdp->cbd_bufaddr);
-               *cp = *s;
-
-               bdp->cbd_datlen = 1;
-               bdp->cbd_sc |= BD_SC_READY;
-
-               if (bdp->cbd_sc & BD_SC_WRAP)
-                       bdp = bdbase;
-               else
-                       bdp++;
-
-               /* if a LF, also do CR... */
-               if (*s == 10) {
-                       while (bdp->cbd_sc & BD_SC_READY);
-                       cp = __va(bdp->cbd_bufaddr);
-                       *cp = 13;
-                       bdp->cbd_datlen = 1;
-                       bdp->cbd_sc |= BD_SC_READY;
-
-                       if (bdp->cbd_sc & BD_SC_WRAP) {
-                               bdp = bdbase;
-                       }
-                       else {
-                               bdp++;
-                       }
-               }
-       }
-
-       /*
-        * Finally, Wait for transmitter & holding register to empty
-        *  and restore the IER
-        */
-       while (bdp->cbd_sc & BD_SC_READY);
-
-       if (info)
-               info->tx_cur = (cbd_t *)bdp;
-}
-
-static void serial_console_write(struct console *c, const char *s,
-                               unsigned count)
-{
-#if defined(CONFIG_KGDB_CONSOLE) && !defined(CONFIG_USE_SERIAL2_KGDB)
-       /* Try to let stub handle output. Returns true if it did. */
-       if (kgdb_output_string(s, count))
-               return;
-#endif
-       my_console_write(c->index, s, count);
-}
-
-#ifdef CONFIG_XMON
-int
-xmon_8xx_write(const char *s, unsigned count)
-{
-       my_console_write(KGDB_SER_IDX, s, count);
-       return(count);
-}
-#endif
-
-#ifdef CONFIG_KGDB
-void
-putDebugChar(char ch)
-{
-       my_console_write(KGDB_SER_IDX, &ch, 1);
-}
-#endif
-
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
-/*
- * Receive character from the serial port.  This only works well
- * before the port is initialize for real use.
- */
-static int my_console_wait_key(int idx, int xmon, char *obuf)
-{
-       struct serial_state             *ser;
-       u_char                          c, *cp;
-       ser_info_t                      *info;
-       volatile        cbd_t           *bdp;
-       volatile        smc_uart_t      *up;
-       int                             i;
-
-       ser = rs_table + idx;
-
-       /* Pointer to UART in parameter ram.
-       */
-       up = (smc_uart_t *)&immr->im_dprambase[ser->port];
-
-       /* Get the address of the host memory buffer.
-        * If the port has been initialized for general use, we must
-        * use information from the port structure.
-        */
-       if ((info = (ser_info_t *)ser->info))
-               bdp = info->rx_cur;
-       else
-               bdp = (cbd_t *)&immr->im_dprambase[up->smc_rbase];
-
-       /*
-        * We need to gracefully shut down the receiver, disable
-        * interrupts, then read the input.
-        * XMON just wants a poll.  If no character, return -1, else
-        * return the character.
-        */
-       if (!xmon) {
-               while (bdp->cbd_sc & BD_SC_EMPTY);
-       }
-       else {
-               if (bdp->cbd_sc & BD_SC_EMPTY)
-                       return -1;
-       }
-
-       /* If the buffer address is in the CPM DPRAM, don't
-        * convert it.
-        */
-       if ((uint)(bdp->cbd_bufaddr) > (uint)IMAP_ADDR)
-               cp = (u_char *)(bdp->cbd_bufaddr);
-       else
-               cp = __va(bdp->cbd_bufaddr);
-
-       if (obuf) {
-               i = c = bdp->cbd_datlen;
-               while (i-- > 0)
-                       *obuf++ = *cp++;
-       }
-       else {
-               c = *cp;
-       }
-       bdp->cbd_sc |= BD_SC_EMPTY;
-
-       if (info) {
-               if (bdp->cbd_sc & BD_SC_WRAP) {
-                       bdp = info->rx_bd_base;
-               }
-               else {
-                       bdp++;
-               }
-               info->rx_cur = (cbd_t *)bdp;
-       }
-
-       return((int)c);
-}
-#endif /* CONFIG_XMON || CONFIG_KGDB */
-
-#ifdef CONFIG_XMON
-int
-xmon_8xx_read_poll(void)
-{
-       return(my_console_wait_key(KGDB_SER_IDX, 1, NULL));
-}
-
-int
-xmon_8xx_read_char(void)
-{
-       return(my_console_wait_key(KGDB_SER_IDX, 0, NULL));
-}
-#endif
-
-#ifdef CONFIG_KGDB
-static char kgdb_buf[RX_BUF_SIZE], *kgdp;
-static int kgdb_chars;
-
-char
-getDebugChar(void)
-{
-       if (kgdb_chars <= 0) {
-               kgdb_chars = my_console_wait_key(KGDB_SER_IDX, 0, kgdb_buf);
-               kgdp = kgdb_buf;
-       }
-       kgdb_chars--;
-
-       return(*kgdp++);
-}
-
-void kgdb_interruptible(int yes)
-{
-       volatile smc_t  *smcp;
-
-       smcp = &immr->im_smc[KGDB_SER_IDX];
-
-       if (yes == 1)
-               smcp->smc_smcm |= SMCM_RX;
-       else
-               smcp->smc_smcm &= ~SMCM_RX;
-}
-
-void kgdb_map_scc(void)
-{
-       ushort          serbase;
-       uint            mem_addr;
-       volatile        cbd_t           *bdp;
-       volatile        smc_uart_t      *up;
-
-       /* The serial port has already been initialized before
-        * we get here.  We have to assign some pointers needed by
-        * the kernel, and grab a memory location in the CPM that will
-        * work until the driver is really initialized.
-        */
-       immr = (immap_t *)IMAP_ADDR;
-
-       /* Right now, assume we are using SMCs.
-       */
-#ifdef USE_KGDB_SMC2
-       *(ushort *)(&immr->im_dprambase[PROFF_SMC2_BASE]) = serbase = PROFF_SMC2;
-#else
-       *(ushort *)(&immr->im_dprambase[PROFF_SMC1_BASE]) = serbase = PROFF_SMC1;
-#endif
-       up = (smc_uart_t *)&immr->im_dprambase[serbase];
-
-       /* Allocate space for an input FIFO, plus a few bytes for output.
-        * Allocate bytes to maintain word alignment.
-        */
-       mem_addr = (uint)(&immr->im_dprambase[0x1000]);
-
-       /* Set the physical address of the host memory buffers in
-        * the buffer descriptors.
-        */
-       bdp = (cbd_t *)&immr->im_dprambase[up->smc_rbase];
-       bdp->cbd_bufaddr = mem_addr;
-
-       bdp = (cbd_t *)&immr->im_dprambase[up->smc_tbase];
-       bdp->cbd_bufaddr = mem_addr+RX_BUF_SIZE;
-
-       up->smc_mrblr = RX_BUF_SIZE;            /* receive buffer length */
-       up->smc_maxidl = RX_BUF_SIZE;
-}
-#endif
-
-static struct tty_driver *serial_console_device(struct console *c, int *index)
-{
-       *index = c->index;
-       return serial_driver;
-}
-
-/*
- *     Register console.
- */
-static int __init console_8xx_init(void)
-{
-       register_console(&sercons);
-       return 0;
-}
-
-console_initcall(console_8xx_init);
-
-#endif
-
-/* Default console baud rate as determined by the board information
- * structure.
- */
-static int     baud_idx;
-
-static struct tty_operations rs_8xx_ops = {
-       .open = rs_8xx_open,
-       .close = rs_8xx_close,
-       .write = rs_8xx_write,
-       .put_char = rs_8xx_put_char,
-       .write_room = rs_8xx_write_room,
-       .chars_in_buffer = rs_8xx_chars_in_buffer,
-       .flush_buffer = rs_8xx_flush_buffer,
-       .ioctl = rs_8xx_ioctl,
-       .throttle = rs_8xx_throttle,
-       .unthrottle = rs_8xx_unthrottle,
-       .send_xchar = rs_8xx_send_xchar,
-       .set_termios = rs_8xx_set_termios,
-       .stop = rs_8xx_stop,
-       .start = rs_8xx_start,
-       .hangup = rs_8xx_hangup,
-       .wait_until_sent = rs_8xx_wait_until_sent,
-       .read_proc = rs_8xx_read_proc,
-};
-
-/*
- * The serial driver boot-time initialization code!
- */
-static int __init rs_8xx_init(void)
-{
-       struct serial_state * state;
-       ser_info_t      *info;
-       uint            mem_addr, dp_addr;
-       int             i, j, idx;
-       uint            page, sblock;
-       volatile        cbd_t           *bdp;
-       volatile        cpm8260_t       *cp;
-       volatile        smc_t           *sp;
-       volatile        smc_uart_t      *up;
-       volatile        scc_t           *scp;
-       volatile        scc_uart_t      *sup;
-       volatile        immap_t         *immap;
-       volatile        iop8260_t       *io;
-
-       serial_driver = alloc_tty_driver(NR_PORTS);
-       if (!serial_driver)
-               return -ENOMEM;
-
-       show_serial_version();
-
-       /* Initialize the tty_driver structure */
-
-       serial_driver->owner = THIS_MODULE;
-       serial_driver->driver_name = "serial";
-       serial_driver->devfs_name = "tts/";
-       serial_driver->name = "ttyS";
-       serial_driver->major = TTY_MAJOR;
-       serial_driver->minor_start = 64;
-       serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
-       serial_driver->subtype = SERIAL_TYPE_NORMAL;
-       serial_driver->init_termios = tty_std_termios;
-       serial_driver->init_termios.c_cflag =
-               baud_idx | CS8 | CREAD | HUPCL | CLOCAL;
-       serial_driver->flags = TTY_DRIVER_REAL_RAW;
-       tty_set_operations(serial_driver, &rs_8xx_ops);
-       if (tty_register_driver(serial_driver))
-               panic("Couldn't register serial driver\n");
-
-       immap = immr;
-       cp = &immap->im_cpm;
-       io = &immap->im_ioport;
-
-       /* This should have been done long ago by the early boot code,
-        * but do it again to make sure.
-        */
-       *(ushort *)(&immap->im_dprambase[PROFF_SMC1_BASE]) = PROFF_SMC1;
-       *(ushort *)(&immap->im_dprambase[PROFF_SMC2_BASE]) = PROFF_SMC2;
-
-       /* Geeze, here we go....Picking I/O port bits....Lots of
-        * choices.  If you don't like mine, pick your own.
-        * Configure SMCs Tx/Rx.  SMC1 is only on Port D, SMC2 is
-        * only on Port A.  You either pick 'em, or not.
-        */
-#ifndef SCC_CONSOLE
-       io->iop_ppard |= 0x00c00000;
-       io->iop_pdird |= 0x00400000;
-       io->iop_pdird &= ~0x00800000;
-       io->iop_psord &= ~0x00c00000;
-#ifdef USE_SMC2
-       io->iop_ppara |= 0x00c00000;
-       io->iop_pdira |= 0x00400000;
-       io->iop_pdira &= ~0x00800000;
-       io->iop_psora &= ~0x00c00000;
-#endif
-
-       /* Configure SCC2 and SCC3.  Be careful about the fine print.
-        * Secondary options are only available when you take away
-        * the primary option.  Unless the pins are used for something
-        * else, SCC2 and SCC3 are on Port B.
-        *      Port B,  8 - SCC3 TxD
-        *      Port B, 12 - SCC2 TxD
-        *      Port B, 14 - SCC3 RxD
-        *      Port B, 15 - SCC2 RxD
-        */
-       io->iop_pparb |= 0x008b0000;
-       io->iop_pdirb |= 0x00880000;
-       io->iop_psorb |= 0x00880000;
-       io->iop_pdirb &= ~0x00030000;
-       io->iop_psorb &= ~0x00030000;
-
-       /* Wire BRG1 to SMC1 and BRG2 to SMC2.
-       */
-       immap->im_cpmux.cmx_smr = 0;
-
-       /* Connect SCC2 and SCC3 to NMSI.  Connect BRG3 to SCC2 and
-        * BRG4 to SCC3.
-        */
-       immap->im_cpmux.cmx_scr &= ~0x00ffff00;
-       immap->im_cpmux.cmx_scr |= 0x00121b00;
-#else
-       io->iop_pparb |= 0x008b0000;
-       io->iop_pdirb |= 0x00880000;
-       io->iop_psorb |= 0x00880000;
-       io->iop_pdirb &= ~0x00030000;
-       io->iop_psorb &= ~0x00030000;
-
-       /* Use Port D for SCC1 instead of other functions.
-       */
-       io->iop_ppard |= 0x00000003;
-       io->iop_psord &= ~0x00000001;   /* Rx */
-       io->iop_psord |= 0x00000002;    /* Tx */
-       io->iop_pdird &= ~0x00000001;   /* Rx */
-       io->iop_pdird |= 0x00000002;    /* Tx */
-
-       /* Connect SCC1, SCC2, SCC3 to NMSI.  Connect BRG1 to SCC1,
-        * BRG2 to SCC2, BRG3 to SCC3.
-        */
-       immap->im_cpmux.cmx_scr &= ~0xffffff00;
-       immap->im_cpmux.cmx_scr |= 0x00091200;
-#endif
-
-       for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
-               state->magic = SSTATE_MAGIC;
-               state->line = i;
-               state->type = PORT_UNKNOWN;
-               state->custom_divisor = 0;
-               state->close_delay = 5*HZ/10;
-               state->closing_wait = 30*HZ;
-               state->icount.cts = state->icount.dsr =
-                       state->icount.rng = state->icount.dcd = 0;
-               state->icount.rx = state->icount.tx = 0;
-               state->icount.frame = state->icount.parity = 0;
-               state->icount.overrun = state->icount.brk = 0;
-               printk (KERN_INFO "ttyS%d on %s%d at 0x%04x, BRG%d\n",
-                       i,
-                       (state->smc_scc_num < SCC_NUM_BASE) ? "SMC" : "SCC",
-                       PORT_NUM(state->smc_scc_num) + 1,
-                       (unsigned int)(state->port),
-                       state->smc_scc_num + 1);
-#ifdef CONFIG_SERIAL_CONSOLE
-               /* If we just printed the message on the console port, and
-                * we are about to initialize it for general use, we have
-                * to wait a couple of character times for the CR/NL to
-                * make it out of the transmit buffer.
-                */
-               if (i == CONFIG_SERIAL_CONSOLE_PORT)
-                       mdelay(300);
-#endif
-               info = kmalloc(sizeof(ser_info_t), GFP_KERNEL);
-               if (info) {
-                       /*memset(info, 0, sizeof(ser_info_t));*/
-                       __clear_user(info,sizeof(ser_info_t));
-                       init_waitqueue_head(&info->open_wait);
-                       init_waitqueue_head(&info->close_wait);
-                       info->magic = SERIAL_MAGIC;
-                       info->flags = state->flags;
-                       INIT_WORK(&info->tqueue, do_softint, info);
-                       INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info);
-                       info->line = i;
-                       info->state = state;
-                       state->info = (struct async_struct *)info;
-
-                       /* We need to allocate a transmit and receive buffer
-                        * descriptors from dual port ram, and a character
-                        * buffer area from host mem.
-                        */
-                       dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * RX_NUM_FIFO, 8);
-
-                       /* Allocate space for FIFOs in the host memory.
-                       */
-                       mem_addr = m8260_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE, 1);
-
-                       /* Set the physical address of the host memory
-                        * buffers in the buffer descriptors, and the
-                        * virtual address for us to work with.
-                        */
-                       bdp = (cbd_t *)&immap->im_dprambase[dp_addr];
-                       info->rx_cur = info->rx_bd_base = (cbd_t *)bdp;
-
-                       for (j=0; j<(RX_NUM_FIFO-1); j++) {
-                               bdp->cbd_bufaddr = __pa(mem_addr);
-                               bdp->cbd_sc = BD_SC_EMPTY | BD_SC_INTRPT;
-                               mem_addr += RX_BUF_SIZE;
-                               bdp++;
-                       }
-                       bdp->cbd_bufaddr = __pa(mem_addr);
-                       bdp->cbd_sc = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
-
-                       if ((idx = state->smc_scc_num) < SCC_NUM_BASE) {
-                               sp = &immap->im_smc[idx];
-                               up = (smc_uart_t *)&immap->im_dprambase[state->port];
-                               up->smc_rbase = dp_addr;
-                       }
-                       else {
-                               scp = &immap->im_scc[idx - SCC_IDX_BASE];
-                               sup = (scc_uart_t *)&immap->im_dprambase[state->port];
-                               scp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-                               sup->scc_genscc.scc_rbase = dp_addr;
-                       }
-
-                       dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * TX_NUM_FIFO, 8);
-
-                       /* Allocate space for FIFOs in the host memory.
-                       */
-                       mem_addr = m8260_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE, 1);
-
-                       /* Set the physical address of the host memory
-                        * buffers in the buffer descriptors, and the
-                        * virtual address for us to work with.
-                        */
-                       bdp = (cbd_t *)&immap->im_dprambase[dp_addr];
-                       info->tx_cur = info->tx_bd_base = (cbd_t *)bdp;
-
-                       for (j=0; j<(TX_NUM_FIFO-1); j++) {
-                               bdp->cbd_bufaddr = __pa(mem_addr);
-                               bdp->cbd_sc = BD_SC_INTRPT;
-                               mem_addr += TX_BUF_SIZE;
-                               bdp++;
-                       }
-                       bdp->cbd_bufaddr = __pa(mem_addr);
-                       bdp->cbd_sc = (BD_SC_WRAP | BD_SC_INTRPT);
-
-                       if (idx < SCC_NUM_BASE) {
-                               up->smc_tbase = dp_addr;
-
-                               /* Set up the uart parameters in the
-                                * parameter ram.
-                                */
-                               up->smc_rfcr = CPMFCR_GBL | CPMFCR_EB;
-                               up->smc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
-                               /* Set this to 1 for now, so we get single
-                                * character interrupts.  Using idle charater
-                                * time requires some additional tuning.
-                                */
-                               up->smc_mrblr = 1;
-                               up->smc_maxidl = 0;
-                               up->smc_brkcr = 1;
-
-                               /* Send the CPM an initialize command.
-                               */
-                               if (state->smc_scc_num == 0) {
-                                       page = CPM_CR_SMC1_PAGE;
-                                       sblock = CPM_CR_SMC1_SBLOCK;
-                               }
-                               else {
-                                       page = CPM_CR_SMC2_PAGE;
-                                       sblock = CPM_CR_SMC2_SBLOCK;
-                               }
-
-                               cp->cp_cpcr = mk_cr_cmd(page, sblock, 0,
-                                               CPM_CR_INIT_TRX) | CPM_CR_FLG;
-                               while (cp->cp_cpcr & CPM_CR_FLG);
-
-                               /* Set UART mode, 8 bit, no parity, one stop.
-                                * Enable receive and transmit.
-                                */
-                               sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
-
-                               /* Disable all interrupts and clear all pending
-                                * events.
-                                */
-                               sp->smc_smcm = 0;
-                               sp->smc_smce = 0xff;
-                       }
-                       else {
-                               sup->scc_genscc.scc_tbase = dp_addr;
-
-                               /* Set up the uart parameters in the
-                                * parameter ram.
-                                */
-                               sup->scc_genscc.scc_rfcr = CPMFCR_GBL | CPMFCR_EB;
-                               sup->scc_genscc.scc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
-                               /* Set this to 1 for now, so we get single
-                                * character interrupts.  Using idle charater
-                                * time requires some additional tuning.
-                                */
-                               sup->scc_genscc.scc_mrblr = 1;
-                               sup->scc_maxidl = 0;
-                               sup->scc_brkcr = 1;
-                               sup->scc_parec = 0;
-                               sup->scc_frmec = 0;
-                               sup->scc_nosec = 0;
-                               sup->scc_brkec = 0;
-                               sup->scc_uaddr1 = 0;
-                               sup->scc_uaddr2 = 0;
-                               sup->scc_toseq = 0;
-                               sup->scc_char1 = 0x8000;
-                               sup->scc_char2 = 0x8000;
-                               sup->scc_char3 = 0x8000;
-                               sup->scc_char4 = 0x8000;
-                               sup->scc_char5 = 0x8000;
-                               sup->scc_char6 = 0x8000;
-                               sup->scc_char7 = 0x8000;
-                               sup->scc_char8 = 0x8000;
-                               sup->scc_rccm = 0xc0ff;
-
-                               /* Send the CPM an initialize command.
-                               */
-#ifdef SCC_CONSOLE
-                               switch (state->smc_scc_num) {
-                               case 0:
-                                       page = CPM_CR_SCC1_PAGE;
-                                       sblock = CPM_CR_SCC1_SBLOCK;
-                                       break;
-                               case 1:
-                                       page = CPM_CR_SCC2_PAGE;
-                                       sblock = CPM_CR_SCC2_SBLOCK;
-                                       break;
-                               case 2:
-                                       page = CPM_CR_SCC3_PAGE;
-                                       sblock = CPM_CR_SCC3_SBLOCK;
-                                       break;
-                               }
-#else
-                               if (state->smc_scc_num == 2) {
-                                       page = CPM_CR_SCC2_PAGE;
-                                       sblock = CPM_CR_SCC2_SBLOCK;
-                               }
-                               else {
-                                       page = CPM_CR_SCC3_PAGE;
-                                       sblock = CPM_CR_SCC3_SBLOCK;
-                               }
-#endif
-
-                               cp->cp_cpcr = mk_cr_cmd(page, sblock, 0,
-                                               CPM_CR_INIT_TRX) | CPM_CR_FLG;
-                               while (cp->cp_cpcr & CPM_CR_FLG);
-
-                               /* Set UART mode, 8 bit, no parity, one stop.
-                                * Enable receive and transmit.
-                                */
-                               scp->scc_gsmrh = 0;
-                               scp->scc_gsmrl =
-                                       (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
-                               /* Disable all interrupts and clear all pending
-                                * events.
-                                */
-                               scp->scc_sccm = 0;
-                               scp->scc_scce = 0xffff;
-                               scp->scc_dsr = 0x7e7e;
-                               scp->scc_pmsr = 0x3000;
-                       }
-
-                       /* Install interrupt handler.
-                       */
-                       request_irq(state->irq, rs_8xx_interrupt, 0, "uart", info);
-
-                       /* Set up the baud rate generator.
-                       */
-                       m8260_cpm_setbrg(state->smc_scc_num,
-                                                       baud_table[baud_idx]);
-
-                       /* If the port is the console, enable Rx and Tx.
-                       */
-#ifdef CONFIG_SERIAL_CONSOLE
-                       if (i == CONFIG_SERIAL_CONSOLE_PORT) {
-                               if (idx < SCC_NUM_BASE)
-                                       sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
-                               else
-                                       scp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-                       }
-#endif
-               }
-       }
-       return 0;
-}
-module_init(rs_8xx_init);
-
-/* This must always be called before the rs_8xx_init() function, otherwise
- * it blows away the port control information.
-*/
-static int __init serial_console_setup(struct console *co, char *options)
-{
-       struct          serial_state *ser;
-       uint            mem_addr, dp_addr, bidx;
-       volatile        cbd_t           *bdp;
-       volatile        cpm8260_t       *cp;
-       volatile        immap_t         *immap;
-#ifndef SCC_CONSOLE
-       volatile        smc_t           *sp;
-       volatile        smc_uart_t      *up;
-#endif
-#ifdef SCC_CONSOLE
-       volatile        scc_t           *scp;
-       volatile        scc_uart_t      *sup;
-#endif
-       volatile        iop8260_t       *io;
-       bd_t                            *bd;
-
-       bd = (bd_t *)__res;
-
-       for (bidx = 0; bidx < (sizeof(baud_table) / sizeof(int)); bidx++)
-               if (bd->bi_baudrate == baud_table[bidx])
-                       break;
-
-       co->cflag = CREAD|CLOCAL|bidx|CS8;
-       baud_idx = bidx;
-
-       ser = rs_table + co->index;
-
-       immap = immr;
-       cp = &immap->im_cpm;
-       io = &immap->im_ioport;
-
-#ifdef SCC_CONSOLE
-       scp = (scc_t *)&(immap->im_scc[SCC_CONSOLE-1]);
-       sup = (scc_uart_t *)&immap->im_dprambase[PROFF_SCC1 + ((SCC_CONSOLE-1) << 8)];
-       scp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
-       scp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-
-       /* Use Port D for SCC1 instead of other functions.
-       */
-       io->iop_ppard |= 0x00000003;
-       io->iop_psord &= ~0x00000001;   /* Rx */
-       io->iop_psord |= 0x00000002;    /* Tx */
-       io->iop_pdird &= ~0x00000001;   /* Rx */
-       io->iop_pdird |= 0x00000002;    /* Tx */
-
-#else
-       /* This should have been done long ago by the early boot code,
-        * but do it again to make sure.
-        */
-       *(ushort *)(&immap->im_dprambase[PROFF_SMC1_BASE]) = PROFF_SMC1;
-       *(ushort *)(&immap->im_dprambase[PROFF_SMC2_BASE]) = PROFF_SMC2;
-
-       /* Right now, assume we are using SMCs.
-       */
-       sp = &immap->im_smc[ser->smc_scc_num];
-
-       /* When we get here, the CPM has been reset, so we need
-        * to configure the port.
-        * We need to allocate a transmit and receive buffer descriptor
-        * from dual port ram, and a character buffer area from host mem.
-        */
-       up = (smc_uart_t *)&immap->im_dprambase[ser->port];
-
-       /* Disable transmitter/receiver.
-       */
-       sp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-
-       /* Use Port D for SMC1 instead of other functions.
-       */
-       io->iop_ppard |= 0x00c00000;
-       io->iop_pdird |= 0x00400000;
-       io->iop_pdird &= ~0x00800000;
-       io->iop_psord &= ~0x00c00000;
-#endif
-
-       /* Allocate space for two buffer descriptors in the DP ram.
-       */
-       dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * 2, 8);
-
-       /* Allocate space for two 2 byte FIFOs in the host memory.
-       */
-       mem_addr = m8260_cpm_hostalloc(4, 1);
-
-       /* Set the physical address of the host memory buffers in
-        * the buffer descriptors.
-        */
-       bdp = (cbd_t *)&immap->im_dprambase[dp_addr];
-       bdp->cbd_bufaddr = __pa(mem_addr);
-       (bdp+1)->cbd_bufaddr = __pa(mem_addr+2);
-
-       /* For the receive, set empty and wrap.
-        * For transmit, set wrap.
-        */
-       bdp->cbd_sc = BD_SC_EMPTY | BD_SC_WRAP;
-       (bdp+1)->cbd_sc = BD_SC_WRAP;
-
-       /* Set up the uart parameters in the parameter ram.
-       */
-#ifdef SCC_CONSOLE
-       sup->scc_genscc.scc_rbase = dp_addr;
-       sup->scc_genscc.scc_tbase = dp_addr + sizeof(cbd_t);
-
-       /* Set up the uart parameters in the
-        * parameter ram.
-        */
-       sup->scc_genscc.scc_rfcr = CPMFCR_GBL | CPMFCR_EB;
-       sup->scc_genscc.scc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
-       sup->scc_genscc.scc_mrblr = 1;
-       sup->scc_maxidl = 0;
-       sup->scc_brkcr = 1;
-       sup->scc_parec = 0;
-       sup->scc_frmec = 0;
-       sup->scc_nosec = 0;
-       sup->scc_brkec = 0;
-       sup->scc_uaddr1 = 0;
-       sup->scc_uaddr2 = 0;
-       sup->scc_toseq = 0;
-       sup->scc_char1 = 0x8000;
-       sup->scc_char2 = 0x8000;
-       sup->scc_char3 = 0x8000;
-       sup->scc_char4 = 0x8000;
-       sup->scc_char5 = 0x8000;
-       sup->scc_char6 = 0x8000;
-       sup->scc_char7 = 0x8000;
-       sup->scc_char8 = 0x8000;
-       sup->scc_rccm = 0xc0ff;
-
-       /* Send the CPM an initialize command.
-       */
-       cp->cp_cpcr = mk_cr_cmd(CPM_CR_SCC1_PAGE, CPM_CR_SCC1_SBLOCK, 0,
-                       CPM_CR_INIT_TRX) | CPM_CR_FLG;
-       while (cp->cp_cpcr & CPM_CR_FLG);
-
-       /* Set UART mode, 8 bit, no parity, one stop.
-        * Enable receive and transmit.
-        */
-       scp->scc_gsmrh = 0;
-       scp->scc_gsmrl =
-               (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
-       /* Disable all interrupts and clear all pending
-        * events.
-        */
-       scp->scc_sccm = 0;
-       scp->scc_scce = 0xffff;
-       scp->scc_dsr = 0x7e7e;
-       scp->scc_pmsr = 0x3000;
-
-       /* Wire BRG1 to SCC1.  The serial init will take care of
-        * others.
-        */
-       immap->im_cpmux.cmx_scr = 0;
-
-       /* Set up the baud rate generator.
-       */
-       m8260_cpm_setbrg(ser->smc_scc_num, bd->bi_baudrate);
-
-       scp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#else
-       up->smc_rbase = dp_addr;        /* Base of receive buffer desc. */
-       up->smc_tbase = dp_addr+sizeof(cbd_t);  /* Base of xmt buffer desc. */
-       up->smc_rfcr = CPMFCR_GBL | CPMFCR_EB;
-       up->smc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
-       /* Set this to 1 for now, so we get single character interrupts.
-       */
-       up->smc_mrblr = 1;              /* receive buffer length */
-       up->smc_maxidl = 0;             /* wait forever for next char */
-
-       /* Send the CPM an initialize command.
-       */
-       cp->cp_cpcr = mk_cr_cmd(CPM_CR_SMC1_PAGE, CPM_CR_SMC1_SBLOCK, 0,
-                       CPM_CR_INIT_TRX) | CPM_CR_FLG;
-       while (cp->cp_cpcr & CPM_CR_FLG);
-
-       /* Set UART mode, 8 bit, no parity, one stop.
-        * Enable receive and transmit.
-        */
-       sp->smc_smcmr = smcr_mk_clen(9) |  SMCMR_SM_UART;
-
-       /* Set up the baud rate generator.
-       */
-       m8260_cpm_setbrg(ser->smc_scc_num, bd->bi_baudrate);
-
-       /* And finally, enable Rx and Tx.
-       */
-       sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
-#endif
-
-       return 0;
-}
index cc4e6b9..051832b 100644 (file)
@@ -1351,6 +1351,8 @@ config PPC_OCP
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index e15c691..6cf4405 100644 (file)
@@ -74,6 +74,7 @@ AFLAGS_vmlinux.lds.o  := -Upowerpc
 
 # All the instructions talk about "make bzImage".
 bzImage: zImage
+       cp vmlinux arch/ppc/boot/bzImage
 
 boot := arch/$(ARCH)/boot
 
diff --git a/arch/ppc/boot/simple/misc-mv64x60.S b/arch/ppc/boot/simple/misc-mv64x60.S
deleted file mode 100644 (file)
index 9c809c8..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * arch/ppc/boot/simple/misc-mv64x60.S
- * 
- * Code to change the base address of the host bridges and call board specific
- * init routine.
- *
- * Author: Mark Greer <mgreer@mvista.com>
- *
- * 2002 (c) MontaVista, Software, Inc.  This file is licensed under the terms
- * of the GNU General Public License version 2.  This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-#include <linux/config.h>
-#include <asm/ppc_asm.h>
-#include <asm/processor.h>
-#include <asm/cache.h>
-#include <asm/mv64x60_defs.h>
-
-       .globl  mv64x60_init
-mv64x60_init:
-       mflr    r27
-
-#if (CONFIG_MV64X60_NEW_BASE != CONFIG_MV64X60_BASE)
-       bl      move_base
-#endif
-       bl      mv64x60_board_init
-
-       mtlr    r27
-       blr
-
-#if (CONFIG_MV64X60_NEW_BASE != CONFIG_MV64X60_BASE)
-move_base:
-       li      r20,0
-       li      r23,20
-
-       /* Relocate bridge's regs */
-        addis  r25,0,CONFIG_MV64X60_BASE@h
-        ori    r25,r25,MV64x60_INTERNAL_SPACE_DECODE             
-        lwbrx  r26,0,(r25)
-       lis     r24,0xffff
-       and     r26,r26,r24
-       addis   r24,0,CONFIG_MV64X60_NEW_BASE@h
-       srw     r24,r24,r23
-       or      r26,r26,r24
-        stwbrx  r26,0,(r25)
-       sync
-
-       /* Wait for write to take effect */
-        addis  r25,0,CONFIG_MV64X60_NEW_BASE@h
-       ori     r25,r25,MV64x60_INTERNAL_SPACE_DECODE
-1:     lwbrx   r24,0,(r25)
-       cmpw    r24,r26
-       bne     1b
-
-       blr
-#endif
diff --git a/arch/ppc/boot/simple/mpc52xx_tty.c b/arch/ppc/boot/simple/mpc52xx_tty.c
deleted file mode 100644 (file)
index 8a1c663..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * arch/ppc/boot/simple/mpc52xx_tty.c
- *
- * Minimal serial functions needed to send messages out a MPC52xx
- * Programmable Serial Controller (PSC).
- *
- * Author: Dale Farnsworth <dfarnsworth@mvista.com>
- *
- * 2003-2004 (c) MontaVista, Software, Inc.  This file is licensed under the
- * terms of the GNU General Public License version 2.  This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <asm/uaccess.h>
-#include <asm/mpc52xx.h>
-#include <asm/mpc52xx_psc.h>
-#include <asm/serial.h>
-#include <asm/time.h>
-
-#if MPC52xx_PF_CONSOLE_PORT == 0
-#define MPC52xx_CONSOLE                MPC52xx_PSC1
-#define MPC52xx_PSC_CONFIG_SHIFT       0
-#elif MPC52xx_PF_CONSOLE_PORT == 1
-#define MPC52xx_CONSOLE                MPC52xx_PSC2
-#define MPC52xx_PSC_CONFIG_SHIFT       4
-#elif MPC52xx_PF_CONSOLE_PORT == 2
-#define MPC52xx_CONSOLE                MPC52xx_PSC3
-#define MPC52xx_PSC_CONFIG_SHIFT       8
-#else
-#error "MPC52xx_PF_CONSOLE_PORT not defined"
-#endif
-
-static struct mpc52xx_psc *psc = (struct mpc52xx_psc *)MPC52xx_CONSOLE;
-
-/* The decrementer counts at the system bus clock frequency
- * divided by four.  The most accurate time base is connected to the
- * rtc.  We read the decrementer change during one rtc tick (one second)
- * and multiply by 4 to get the system bus clock frequency.
- */
-int
-mpc52xx_ipbfreq(void)
-{
-       struct mpc52xx_rtc *rtc = (struct mpc52xx_rtc*)MPC52xx_RTC;
-       struct mpc52xx_cdm *cdm = (struct mpc52xx_cdm*)MPC52xx_CDM;
-       int current_time, previous_time;
-       int tbl_start, tbl_end;
-       int xlbfreq, ipbfreq;
-
-       out_be32(&rtc->dividers, 0x8f1f0000);   /* Set RTC 64x faster */
-       previous_time = in_be32(&rtc->time);
-       while ((current_time = in_be32(&rtc->time)) == previous_time) ;
-       tbl_start = get_tbl();
-       previous_time = current_time;
-       while ((current_time = in_be32(&rtc->time)) == previous_time) ;
-       tbl_end = get_tbl();
-       out_be32(&rtc->dividers, 0xffff0000);   /* Restore RTC */
-
-       xlbfreq = (tbl_end - tbl_start) << 8;
-       ipbfreq = (in_8(&cdm->ipb_clk_sel) & 1) ? xlbfreq / 2 : xlbfreq;
-
-       return ipbfreq;
-}
-
-unsigned long
-serial_init(int ignored, void *ignored2)
-{
-       struct mpc52xx_gpio *gpio = (struct mpc52xx_gpio *)MPC52xx_GPIO;
-       int divisor;
-       int mode1;
-       int mode2;
-       u32 val32;
-
-       static int been_here = 0;
-
-       if (been_here)
-               return 0;
-
-       been_here = 1;
-
-       val32 = in_be32(&gpio->port_config);
-       val32 &= ~(0x7 << MPC52xx_PSC_CONFIG_SHIFT);
-       val32 |= MPC52xx_GPIO_PSC_CONFIG_UART_WITHOUT_CD
-                               << MPC52xx_PSC_CONFIG_SHIFT;
-       out_be32(&gpio->port_config, val32);
-
-       out_8(&psc->command, MPC52xx_PSC_RST_TX
-                       | MPC52xx_PSC_RX_DISABLE | MPC52xx_PSC_TX_ENABLE);
-       out_8(&psc->command, MPC52xx_PSC_RST_RX);
-
-       out_be32(&psc->sicr, 0x0);
-       out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00);
-       out_be16(&psc->tfalarm, 0xf8);
-
-       out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1
-                       | MPC52xx_PSC_RX_ENABLE
-                       | MPC52xx_PSC_TX_ENABLE);
-
-       divisor = ((mpc52xx_ipbfreq()
-                       / (CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD * 16)) + 1) >> 1;
-
-       mode1 = MPC52xx_PSC_MODE_8_BITS | MPC52xx_PSC_MODE_PARNONE
-                       | MPC52xx_PSC_MODE_ERR;
-       mode2 = MPC52xx_PSC_MODE_ONE_STOP;
-
-       out_8(&psc->ctur, divisor>>8);
-       out_8(&psc->ctlr, divisor);
-       out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
-       out_8(&psc->mode, mode1);
-       out_8(&psc->mode, mode2);
-
-       return 0;       /* ignored */
-}
-
-void
-serial_putc(void *ignored, const char c)
-{
-       serial_init(0, 0);
-
-       while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP)) ;
-       out_8(&psc->mpc52xx_psc_buffer_8, c);
-       while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP)) ;
-}
-
-char
-serial_getc(void *ignored)
-{
-       while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY)) ;
-
-       return in_8(&psc->mpc52xx_psc_buffer_8);
-}
-
-int
-serial_tstc(void *ignored)
-{
-       return (in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY) != 0;
-}
diff --git a/arch/ppc/boot/simple/mv64x60_stub.c b/arch/ppc/boot/simple/mv64x60_stub.c
deleted file mode 100644 (file)
index 46d9924..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * arch/ppc/boot/simple/mv64x60_stub.c
- *
- * Stub for board_init() routine called from mv64x60_init().
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2002 (c) MontaVista, Software, Inc.  This file is licensed under the terms
- * of the GNU General Public License version 2.  This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-long   mv64x60_console_baud = 9600;            /* Default baud: 9600 */
-long   mv64x60_mpsc_clk_src = 8;               /* Default clk src: TCLK */
-long   mv64x60_mpsc_clk_freq = 100000000;      /* Default clk freq: 100 MHz */
-
-void
-mv64x60_board_init(void)
-{
-}
diff --git a/arch/ppc/boot/simple/mv64x60_tty.c b/arch/ppc/boot/simple/mv64x60_tty.c
deleted file mode 100644 (file)
index b1cb21a..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * arch/ppc/boot/simple/mv64x60_tty.c
- * 
- * Bootloader version of the embedded MPSC/UART driver for the Marvell 64x60.
- * Note: Due to a GT64260A erratum, DMA will be used for UART input (via SDMA).
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * Copyright 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-/* This code assumes that the data cache has been disabled (L1, L2, L3). */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/serial_reg.h>
-#include <asm/serial.h>
-#include <asm/mv64x60_defs.h>
-#include "../../../../drivers/serial/mpsc/mpsc_defs.h"
-
-extern void udelay(long);
-static void stop_dma(int chan);
-
-static u32     mv64x60_base = CONFIG_MV64X60_NEW_BASE;
-
-inline unsigned
-mv64x60_in_le32(volatile unsigned *addr)
-{
-       unsigned ret;
-
-       __asm__ __volatile__("lwbrx %0,0,%1; eieio" : "=r" (ret) :
-                                    "r" (addr), "m" (*addr));
-       return ret;
-}
-
-inline void
-mv64x60_out_le32(volatile unsigned *addr, int val)
-{
-       __asm__ __volatile__("stwbrx %1,0,%2; eieio" : "=m" (*addr) :
-                                    "r" (val), "r" (addr));
-}
-
-#define MV64x60_REG_READ(offs)                                         \
-       (mv64x60_in_le32((volatile uint *)(mv64x60_base + (offs))))
-#define MV64x60_REG_WRITE(offs, d)                                     \
-        (mv64x60_out_le32((volatile uint *)(mv64x60_base + (offs)), (int)(d)))
-
-
-typedef struct {
-       u32     sdc;
-       u32     sdcm;
-       u32     rx_desc;
-       u32     rx_buf_ptr;
-       u32     scrdp;
-       u32     tx_desc;
-       u32     sctdp;
-       u32     sftdp;
-} sdma_regs_t;
-
-static sdma_regs_t  sdma_regs[2];
-
-#define        SDMA_REGS_INIT(s, reg_base) {                   \
-       (s)->sdc        = (reg_base) + SDMA_SDC;        \
-       (s)->sdcm       = (reg_base) + SDMA_SDCM;       \
-       (s)->rx_desc    = (reg_base) + SDMA_RX_DESC;    \
-       (s)->rx_buf_ptr = (reg_base) + SDMA_RX_BUF_PTR; \
-       (s)->scrdp      = (reg_base) + SDMA_SCRDP;      \
-       (s)->tx_desc    = (reg_base) + SDMA_TX_DESC;    \
-       (s)->sctdp      = (reg_base) + SDMA_SCTDP;      \
-       (s)->sftdp      = (reg_base) + SDMA_SFTDP;      \
-}
-
-typedef struct {
-       volatile u16 bufsize;
-       volatile u16 bytecnt;
-       volatile u32 cmd_stat;
-       volatile u32 next_desc_ptr;
-       volatile u32 buffer;
-} mv64x60_rx_desc_t;
-
-typedef struct {
-       volatile u16 bytecnt;
-       volatile u16 shadow;
-       volatile u32 cmd_stat;
-       volatile u32 next_desc_ptr;
-       volatile u32 buffer;
-} mv64x60_tx_desc_t;
-
-#define        MAX_RESET_WAIT  10000
-#define        MAX_TX_WAIT     10000
-
-#define        RX_NUM_DESC     2
-#define        TX_NUM_DESC     2
-
-#define        RX_BUF_SIZE     16
-#define        TX_BUF_SIZE     16
-
-static mv64x60_rx_desc_t rd[2][RX_NUM_DESC] __attribute__ ((aligned(32)));
-static mv64x60_tx_desc_t td[2][TX_NUM_DESC] __attribute__ ((aligned(32)));
-
-static char rx_buf[2][RX_NUM_DESC * RX_BUF_SIZE] __attribute__ ((aligned(32)));
-static char tx_buf[2][TX_NUM_DESC * TX_BUF_SIZE] __attribute__ ((aligned(32)));
-
-static int cur_rd[2] = { 0, 0 };
-static int cur_td[2] = { 0, 0 };
-
-static char chan_initialized[2] = { 0, 0 };
-
-
-#define        RX_INIT_RDP(rdp) {                      \
-       (rdp)->bufsize = 2;                     \
-       (rdp)->bytecnt = 0;                     \
-       (rdp)->cmd_stat = SDMA_DESC_CMDSTAT_L | \
-                         SDMA_DESC_CMDSTAT_F | \
-                         SDMA_DESC_CMDSTAT_O;  \
-}
-
-unsigned long
-serial_init(int chan, void *ignored)
-{
-       u32             mpsc_base, mpsc_routing_base, sdma_base, brg_bcr, cdv;
-       int             i;
-       extern long     mv64x60_console_baud;
-       extern long     mv64x60_mpsc_clk_src;
-       extern long     mv64x60_mpsc_clk_freq;
-
-       chan = (chan == 1);  /* default to chan 0 if anything but 1 */
-
-       if (chan_initialized[chan]) return chan;
-
-       chan_initialized[chan] = 1;
-
-       if (chan == 0) {
-               mpsc_base = MV64x60_MPSC_0_OFFSET;
-               sdma_base = MV64x60_SDMA_0_OFFSET;
-               brg_bcr = MV64x60_BRG_0_OFFSET + BRG_BCR;
-               SDMA_REGS_INIT(&sdma_regs[0], MV64x60_SDMA_0_OFFSET);
-       }
-       else {
-               mpsc_base = MV64x60_MPSC_1_OFFSET;
-               sdma_base = MV64x60_SDMA_1_OFFSET;
-               brg_bcr = MV64x60_BRG_1_OFFSET + BRG_BCR;
-               SDMA_REGS_INIT(&sdma_regs[0], MV64x60_SDMA_1_OFFSET);
-       }
-
-       mpsc_routing_base = MV64x60_MPSC_ROUTING_OFFSET;
-
-       stop_dma(chan);
-
-       /* Set up ring buffers */
-       for (i=0; i<RX_NUM_DESC; i++) {
-               RX_INIT_RDP(&rd[chan][i]);
-               rd[chan][i].buffer = (u32)&rx_buf[chan][i * RX_BUF_SIZE];
-               rd[chan][i].next_desc_ptr = (u32)&rd[chan][i+1];
-       }
-       rd[chan][RX_NUM_DESC - 1].next_desc_ptr = (u32)&rd[chan][0];
-
-       for (i=0; i<TX_NUM_DESC; i++) {
-               td[chan][i].bytecnt = 0;
-               td[chan][i].shadow = 0;
-               td[chan][i].buffer = (u32)&tx_buf[chan][i * TX_BUF_SIZE];
-               td[chan][i].cmd_stat = SDMA_DESC_CMDSTAT_F|SDMA_DESC_CMDSTAT_L;
-               td[chan][i].next_desc_ptr = (u32)&td[chan][i+1];
-       }
-       td[chan][TX_NUM_DESC - 1].next_desc_ptr = (u32)&td[chan][0];
-
-       /* Set MPSC Routing */
-        MV64x60_REG_WRITE(mpsc_routing_base + MPSC_MRR, 0x3ffffe38);
-
-/* XXXX Not for 64360 XXXX*/
-        MV64x60_REG_WRITE(GT64260_MPP_SERIAL_PORTS_MULTIPLEX, 0x00001102);
-
-       /* MPSC 0/1 Rx & Tx get clocks BRG0/1 */
-        MV64x60_REG_WRITE(mpsc_routing_base + MPSC_RCRR, 0x00000100);
-        MV64x60_REG_WRITE(mpsc_routing_base + MPSC_TCRR, 0x00000100);
-
-       /* clear pending interrupts */
-        MV64x60_REG_WRITE(MV64x60_SDMA_INTR_OFFSET + SDMA_INTR_MASK, 0);
-
-       MV64x60_REG_WRITE(SDMA_SCRDP + sdma_base, &rd[chan][0]);
-       MV64x60_REG_WRITE(SDMA_SCTDP + sdma_base, &td[chan][TX_NUM_DESC - 1]);
-       MV64x60_REG_WRITE(SDMA_SFTDP + sdma_base, &td[chan][TX_NUM_DESC - 1]);
-
-       MV64x60_REG_WRITE(SDMA_SDC + sdma_base,
-                 SDMA_SDC_RFT | SDMA_SDC_SFM | SDMA_SDC_BLMR | SDMA_SDC_BLMT |
-                 (3 << 12));
-
-       cdv = ((mv64x60_mpsc_clk_freq/(32*mv64x60_console_baud))-1);
-       MV64x60_REG_WRITE(brg_bcr,
-               ((mv64x60_mpsc_clk_src << 18) | (1 << 16) | cdv));
-
-       /* Put MPSC into UART mode, no null modem, 16x clock mode */
-       MV64x60_REG_WRITE(MPSC_MMCRL + mpsc_base, 0x000004c4);
-       MV64x60_REG_WRITE(MPSC_MMCRH + mpsc_base, 0x04400400);
-
-        MV64x60_REG_WRITE(MPSC_CHR_1 + mpsc_base, 0);
-        MV64x60_REG_WRITE(MPSC_CHR_9 + mpsc_base, 0);
-        MV64x60_REG_WRITE(MPSC_CHR_10 + mpsc_base, 0);
-        MV64x60_REG_WRITE(MPSC_CHR_3 + mpsc_base, 4);
-        MV64x60_REG_WRITE(MPSC_CHR_4 + mpsc_base, 0);
-        MV64x60_REG_WRITE(MPSC_CHR_5 + mpsc_base, 0);
-        MV64x60_REG_WRITE(MPSC_CHR_6 + mpsc_base, 0);
-        MV64x60_REG_WRITE(MPSC_CHR_7 + mpsc_base, 0);
-        MV64x60_REG_WRITE(MPSC_CHR_8 + mpsc_base, 0);
-
-       /* 8 data bits, 1 stop bit */
-       MV64x60_REG_WRITE(MPSC_MPCR + mpsc_base, (3 << 12));
-       MV64x60_REG_WRITE(SDMA_SDCM + sdma_base, SDMA_SDCM_ERD);
-       MV64x60_REG_WRITE(MPSC_CHR_2 + mpsc_base, MPSC_CHR_2_EH);
-
-       udelay(100);
-
-       return chan;
-}
-
-static void
-stop_dma(int chan)
-{
-       int     i;
-
-       /* Abort SDMA Rx, Tx */
-       MV64x60_REG_WRITE(sdma_regs[chan].sdcm, SDMA_SDCM_AR | SDMA_SDCM_STD);
-
-       for (i=0; i<MAX_RESET_WAIT; i++) {
-               if ((MV64x60_REG_READ(sdma_regs[chan].sdcm) &
-                       (SDMA_SDCM_AR | SDMA_SDCM_AT)) == 0) {
-                       break;
-               }
-               udelay(100);
-       }
-
-       return;
-}
-
-static int
-wait_for_ownership(int chan)
-{
-       int     i;
-
-       for (i=0; i<MAX_TX_WAIT; i++) {
-               if ((MV64x60_REG_READ(sdma_regs[chan].sdcm) &
-                                       SDMA_SDCM_TXD) == 0)
-                       break;
-               udelay(1000);
-       }
-
-       return (i < MAX_TX_WAIT);
-}
-
-void
-serial_putc(unsigned long com_port, unsigned char c)
-{
-       mv64x60_tx_desc_t       *tdp;
-
-       if (wait_for_ownership(com_port) == 0) return;
-
-       tdp = &td[com_port][cur_td[com_port]];
-       if (++cur_td[com_port] >= TX_NUM_DESC) cur_td[com_port] = 0;
-
-       *(unchar *)(tdp->buffer ^ 7) = c;
-       tdp->bytecnt = 1;
-       tdp->shadow = 1;
-       tdp->cmd_stat = SDMA_DESC_CMDSTAT_L | SDMA_DESC_CMDSTAT_F |
-               SDMA_DESC_CMDSTAT_O;
-
-       MV64x60_REG_WRITE(sdma_regs[com_port].sctdp, tdp);
-       MV64x60_REG_WRITE(sdma_regs[com_port].sftdp, tdp);
-       MV64x60_REG_WRITE(sdma_regs[com_port].sdcm,
-               MV64x60_REG_READ(sdma_regs[com_port].sdcm) | SDMA_SDCM_TXD);
-
-       return;
-}
-
-unsigned char
-serial_getc(unsigned long com_port)
-{
-       mv64x60_rx_desc_t       *rdp;
-       unchar                  c = '\0';
-
-       rdp = &rd[com_port][cur_rd[com_port]];
-
-       if ((rdp->cmd_stat & (SDMA_DESC_CMDSTAT_O|SDMA_DESC_CMDSTAT_ES)) == 0) {
-               c = *(unchar *)(rdp->buffer ^ 7);
-               RX_INIT_RDP(rdp);
-               if (++cur_rd[com_port] >= RX_NUM_DESC) cur_rd[com_port] = 0;
-       }
-
-       return c;
-}
-
-int
-serial_tstc(unsigned long com_port)
-{
-       mv64x60_rx_desc_t       *rdp;
-       int                     loop_count = 0;
-       int                     rc = 0;
-
-       rdp = &rd[com_port][cur_rd[com_port]];
-
-       /* Go thru rcv desc's until empty looking for one with data (no error)*/
-       while (((rdp->cmd_stat & SDMA_DESC_CMDSTAT_O) == 0) &&
-              (loop_count++ < RX_NUM_DESC)) {
-
-               /* If there was an error, reinit the desc & continue */
-               if ((rdp->cmd_stat & SDMA_DESC_CMDSTAT_ES) != 0) {
-                       RX_INIT_RDP(rdp);
-                       if (++cur_rd[com_port] >= RX_NUM_DESC) {
-                               cur_rd[com_port] = 0;
-                       }
-                       rdp = (mv64x60_rx_desc_t *)rdp->next_desc_ptr;
-               }
-               else {
-                       rc = 1;
-                       break;
-               }
-       }
-
-       return rc;
-}
-
-void
-serial_close(unsigned long com_port)
-{
-       stop_dma(com_port);
-       return;
-}
diff --git a/arch/ppc/configs/ads8272_defconfig b/arch/ppc/configs/ads8272_defconfig
deleted file mode 100644 (file)
index d1db7d1..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_GENERIC_NVRAM=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-# CONFIG_KALLSYMS is not set
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# Processor
-#
-CONFIG_6xx=y
-# CONFIG_40x is not set
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_EMBEDDEDBOOT=y
-CONFIG_PPC_STD_MMU=y
-
-#
-# Platform options
-#
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_APUS is not set
-# CONFIG_WILLOW is not set
-# CONFIG_PCORE is not set
-# CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_SPRUCE is not set
-# CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
-# CONFIG_MVME5100 is not set
-# CONFIG_PPLUS is not set
-# CONFIG_PRPMC750 is not set
-# CONFIG_PRPMC800 is not set
-# CONFIG_SANDPOINT is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
-# CONFIG_PAL4 is not set
-# CONFIG_GEMINI is not set
-# CONFIG_EST8260 is not set
-# CONFIG_SBC82xx is not set
-# CONFIG_SBS8260 is not set
-# CONFIG_RPX6 is not set
-# CONFIG_TQM8260 is not set
-CONFIG_ADS8272=y
-CONFIG_PQ2ADS=y
-CONFIG_8260=y
-CONFIG_8272=y
-CONFIG_CPM2=y
-# CONFIG_PC_KEYBOARD is not set
-CONFIG_SERIAL_CONSOLE=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Bus options
-#
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-# CONFIG_PCI_LEGACY_PROC is not set
-# CONFIG_PCI_NAMES is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=32768
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Macintosh device drivers
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_PCI is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-# CONFIG_SCC_ENET is not set
-CONFIG_FEC_ENET=y
-# CONFIG_USE_MDIO is not set
-
-#
-# CPM2 Options
-#
-CONFIG_SCC_CONSOLE=y
-CONFIG_FCC1_ENET=y
-# CONFIG_FCC2_ENET is not set
-# CONFIG_FCC3_ENET is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-# CONFIG_LIBCRC32C is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KGDB_CONSOLE is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/bubinga_defconfig b/arch/ppc/configs/bubinga_defconfig
deleted file mode 100644 (file)
index ebec801..0000000
+++ /dev/null
@@ -1,592 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_GENERIC_NVRAM=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-# CONFIG_STANDALONE is not set
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-# CONFIG_KALLSYMS is not set
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# Processor
-#
-# CONFIG_6xx is not set
-CONFIG_40x=y
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-# CONFIG_MATH_EMULATION is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_4xx=y
-
-#
-# IBM 4xx options
-#
-# CONFIG_ASH is not set
-CONFIG_BUBINGA=y
-# CONFIG_CPCI405 is not set
-# CONFIG_EP405 is not set
-# CONFIG_OAK is not set
-# CONFIG_REDWOOD_5 is not set
-# CONFIG_REDWOOD_6 is not set
-# CONFIG_SYCAMORE is not set
-# CONFIG_WALNUT is not set
-CONFIG_IBM405_ERR77=y
-CONFIG_IBM405_ERR51=y
-CONFIG_IBM_OCP=y
-CONFIG_BIOS_FIXUP=y
-CONFIG_405EP=y
-CONFIG_IBM_OPENBIOS=y
-# CONFIG_PM is not set
-CONFIG_UART0_TTYS0=y
-# CONFIG_UART0_TTYS1 is not set
-CONFIG_NOT_COHERENT_CACHE=y
-
-#
-# Platform options
-#
-# CONFIG_PC_KEYBOARD is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Bus options
-#
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-CONFIG_PCI_LEGACY_PROC=y
-# CONFIG_PCI_NAMES is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Macintosh device drivers
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_OAKNET is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_PCI is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-CONFIG_IBM_EMAC=y
-# CONFIG_IBM_EMAC_ERRMSG is not set
-CONFIG_IBM_EMAC_RXB=64
-CONFIG_IBM_EMAC_TXB=8
-CONFIG_IBM_EMAC_FGAP=8
-CONFIG_IBM_EMAC_SKBRES=0
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# IBM 40x options
-#
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_SERIAL_TEXT_DEBUG is not set
-CONFIG_PPC_OCP=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/lite5200_defconfig b/arch/ppc/configs/lite5200_defconfig
deleted file mode 100644 (file)
index 7e7a943..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_GENERIC_NVRAM=y
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-#
-# Processor
-#
-CONFIG_6xx=y
-# CONFIG_40x is not set
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-# CONFIG_E500 is not set
-# CONFIG_ALTIVEC is not set
-# CONFIG_TAU is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_FSL_OCP=y
-CONFIG_PPC_STD_MMU=y
-#
-# Platform options
-#
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_APUS is not set
-# CONFIG_WILLOW is not set
-# CONFIG_PCORE is not set
-# CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_SPRUCE is not set
-# CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
-# CONFIG_MVME5100 is not set
-# CONFIG_PPLUS is not set
-# CONFIG_PRPMC750 is not set
-# CONFIG_PRPMC800 is not set
-# CONFIG_SANDPOINT is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
-# CONFIG_PAL4 is not set
-# CONFIG_GEMINI is not set
-# CONFIG_EST8260 is not set
-# CONFIG_SBC82xx is not set
-# CONFIG_SBS8260 is not set
-# CONFIG_RPX6 is not set
-# CONFIG_TQM8260 is not set
-# CONFIG_ADS8272 is not set
-CONFIG_LITE5200=y
-CONFIG_PPC_MPC52xx=y
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="console=ttyS0 root=/dev/ram0 rw"
-#
-# Bus options
-#
-CONFIG_GENERIC_ISA_DMA=y
-CONFIG_PCI=y
-CONFIG_PCI_DOMAINS=y
-# CONFIG_PCI_LEGACY_PROC is not set
-# CONFIG_PCI_NAMES is not set
-#
-# Advanced setup
-#
-CONFIG_ADVANCED_OPTIONS=y
-CONFIG_HIGHMEM_START=0xfe000000
-# CONFIG_LOWMEM_SIZE_BOOL is not set
-CONFIG_LOWMEM_SIZE=0x30000000
-# CONFIG_KERNEL_START_BOOL is not set
-CONFIG_KERNEL_START=0xc0000000
-# CONFIG_TASK_SIZE_BOOL is not set
-CONFIG_TASK_SIZE=0x80000000
-# CONFIG_BOOT_LOAD_BOOL is not set
-CONFIG_BOOT_LOAD=0x00800000
-#
-# Device Drivers
-#
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_DEBUG_DRIVER is not set
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-#
-# Plug and Play support
-#
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-#
-# Fusion MPT device support
-#
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-#
-# Macintosh device drivers
-#
-#
-# Networking support
-#
-# CONFIG_NET is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-#
-# ISDN subsystem
-#
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-#
-# Input device support
-#
-CONFIG_INPUT=y
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-CONFIG_INPUT_EVBUG=y
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_SERIAL_MPC52xx=y
-CONFIG_SERIAL_MPC52xx_CONSOLE=y
-CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=9600
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-#
-# Misc devices
-#
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-#
-# Digital Video Broadcasting Devices
-#
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-#
-# Console display driver support
-#
-CONFIG_VGA_CONSOLE=y
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-#
-# USB support
-#
-# CONFIG_USB is not set
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-#
-# Native Language Support
-#
-CONFIG_NLS=y
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-CONFIG_NLS_ISO8859_1=m
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-#
-# Library routines
-#
-# CONFIG_CRC16 is not set
-# CONFIG_CRC32 is not set
-# CONFIG_LIBCRC32C is not set
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-#
-# Kernel hacking
-#
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_DEBUG_SPINLOCK is not set
-CONFIG_DEBUG_SPINLOCK_SLEEP=y
-# CONFIG_KGDB is not set
-# CONFIG_XMON is not set
-# CONFIG_BDI_SWITCH is not set
-CONFIG_DEBUG_INFO=y
-CONFIG_SERIAL_TEXT_DEBUG=y
-CONFIG_PPC_OCP=y
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/configs/rpx8260_defconfig b/arch/ppc/configs/rpx8260_defconfig
deleted file mode 100644 (file)
index a9c4544..0000000
+++ /dev/null
@@ -1,555 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_PPC=y
-CONFIG_PPC32=y
-CONFIG_GENERIC_NVRAM=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-# CONFIG_SWAP is not set
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-# CONFIG_KALLSYMS is not set
-CONFIG_FUTEX=y
-# CONFIG_EPOLL is not set
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# Processor
-#
-CONFIG_6xx=y
-# CONFIG_40x is not set
-# CONFIG_44x is not set
-# CONFIG_POWER3 is not set
-# CONFIG_POWER4 is not set
-# CONFIG_8xx is not set
-# CONFIG_E500 is not set
-# CONFIG_CPU_FREQ is not set
-CONFIG_EMBEDDEDBOOT=y
-CONFIG_PPC_STD_MMU=y
-
-#
-# Platform options
-#
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_APUS is not set
-# CONFIG_WILLOW is not set
-# CONFIG_PCORE is not set
-# CONFIG_POWERPMC250 is not set
-# CONFIG_EV64260 is not set
-# CONFIG_SPRUCE is not set
-# CONFIG_LOPEC is not set
-# CONFIG_MCPN765 is not set
-# CONFIG_MVME5100 is not set
-# CONFIG_PPLUS is not set
-# CONFIG_PRPMC750 is not set
-# CONFIG_PRPMC800 is not set
-# CONFIG_SANDPOINT is not set
-# CONFIG_ADIR is not set
-# CONFIG_K2 is not set
-# CONFIG_PAL4 is not set
-# CONFIG_GEMINI is not set
-# CONFIG_EST8260 is not set
-# CONFIG_SBC82xx is not set
-# CONFIG_SBS8260 is not set
-CONFIG_RPX8260=y
-# CONFIG_TQM8260 is not set
-# CONFIG_ADS8272 is not set
-CONFIG_8260=y
-CONFIG_CPM2=y
-# CONFIG_PC_KEYBOARD is not set
-# CONFIG_SMP is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Bus options
-#
-# CONFIG_PCI is not set
-# CONFIG_PCI_DOMAINS is not set
-
-#
-# Advanced setup
-#
-# CONFIG_ADVANCED_OPTIONS is not set
-
-#
-# Default settings for advanced configuration options are used
-#
-CONFIG_HIGHMEM_START=0xfe000000
-CONFIG_LOWMEM_SIZE=0x30000000
-CONFIG_KERNEL_START=0xc0000000
-CONFIG_TASK_SIZE=0x80000000
-CONFIG_BOOT_LOAD=0x00400000
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# Macintosh device drivers
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_OAKNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-
-#
-# Ethernet (10000 Mbit)
-#
-
-#
-# Token Ring devices
-#
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_SERIAL_CPM=y
-CONFIG_SERIAL_CPM_CONSOLE=y
-# CONFIG_SERIAL_CPM_SCC1 is not set
-# CONFIG_SERIAL_CPM_SCC2 is not set
-# CONFIG_SERIAL_CPM_SCC3 is not set
-# CONFIG_SERIAL_CPM_SCC4 is not set
-CONFIG_SERIAL_CPM_SMC1=y
-# CONFIG_SERIAL_CPM_SMC2 is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Dallas's 1-wire bus
-#
-# CONFIG_W1 is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-# CONFIG_EXT3_FS_POSIX_ACL is not set
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-# CONFIG_SCC_ENET is not set
-CONFIG_FEC_ENET=y
-# CONFIG_USE_MDIO is not set
-
-#
-# CPM2 Options
-#
-# CONFIG_FCC1_ENET is not set
-# CONFIG_FCC2_ENET is not set
-CONFIG_FCC3_ENET=y
-
-#
-# Library routines
-#
-# CONFIG_CRC_CCITT is not set
-# CONFIG_CRC32 is not set
-# CONFIG_LIBCRC32C is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_DEBUG_KERNEL is not set
-# CONFIG_KGDB_CONSOLE is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
diff --git a/arch/ppc/kernel/dma-mapping.c b/arch/ppc/kernel/dma-mapping.c
deleted file mode 100644 (file)
index 54f9a3e..0000000
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- *  PowerPC version derived from arch/arm/mm/consistent.c
- *    Copyright (C) 2001 Dan Malek (dmalek@jlc.net)
- *
- *  Copyright (C) 2000 Russell King
- *
- * Consistent memory allocators.  Used for DMA devices that want to
- * share uncached memory with the processor core.  The function return
- * is the virtual address and 'dma_handle' is the physical address.
- * Mostly stolen from the ARM port, with some changes for PowerPC.
- *                                             -- Dan
- *
- * Reorganized to get rid of the arch-specific consistent_* functions
- * and provide non-coherent implementations for the DMA API. -Matt
- *
- * Added in_interrupt() safe dma_alloc_coherent()/dma_free_coherent()
- * implementation. This is pulled straight from ARM and barely
- * modified. -Matt
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/swap.h>
-#include <linux/stddef.h>
-#include <linux/vmalloc.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/bootmem.h>
-#include <linux/highmem.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/pgalloc.h>
-#include <asm/prom.h>
-#include <asm/io.h>
-#include <asm/hardirq.h>
-#include <asm/mmu_context.h>
-#include <asm/pgtable.h>
-#include <asm/mmu.h>
-#include <asm/uaccess.h>
-#include <asm/smp.h>
-#include <asm/machdep.h>
-
-int map_page(unsigned long va, phys_addr_t pa, int flags);
-
-#include <asm/tlbflush.h>
-
-/*
- * This address range defaults to a value that is safe for all
- * platforms which currently set CONFIG_NOT_COHERENT_CACHE. It
- * can be further configured for specific applications under
- * the "Advanced Setup" menu. -Matt
- */
-#define CONSISTENT_BASE        (CONFIG_CONSISTENT_START)
-#define CONSISTENT_END (CONFIG_CONSISTENT_START + CONFIG_CONSISTENT_SIZE)
-#define CONSISTENT_OFFSET(x)   (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT)
-
-/*
- * This is the page table (2MB) covering uncached, DMA consistent allocations
- */
-static pte_t *consistent_pte;
-static spinlock_t consistent_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * VM region handling support.
- *
- * This should become something generic, handling VM region allocations for
- * vmalloc and similar (ioremap, module space, etc).
- *
- * I envisage vmalloc()'s supporting vm_struct becoming:
- *
- *  struct vm_struct {
- *    struct vm_region region;
- *    unsigned long    flags;
- *    struct page      **pages;
- *    unsigned int     nr_pages;
- *    unsigned long    phys_addr;
- *  };
- *
- * get_vm_area() would then call vm_region_alloc with an appropriate
- * struct vm_region head (eg):
- *
- *  struct vm_region vmalloc_head = {
- *     .vm_list        = LIST_HEAD_INIT(vmalloc_head.vm_list),
- *     .vm_start       = VMALLOC_START,
- *     .vm_end         = VMALLOC_END,
- *  };
- *
- * However, vmalloc_head.vm_start is variable (typically, it is dependent on
- * the amount of RAM found at boot time.)  I would imagine that get_vm_area()
- * would have to initialise this each time prior to calling vm_region_alloc().
- */
-struct vm_region {
-       struct list_head        vm_list;
-       unsigned long           vm_start;
-       unsigned long           vm_end;
-};
-
-static struct vm_region consistent_head = {
-       .vm_list        = LIST_HEAD_INIT(consistent_head.vm_list),
-       .vm_start       = CONSISTENT_BASE,
-       .vm_end         = CONSISTENT_END,
-};
-
-static struct vm_region *
-vm_region_alloc(struct vm_region *head, size_t size, int gfp)
-{
-       unsigned long addr = head->vm_start, end = head->vm_end - size;
-       unsigned long flags;
-       struct vm_region *c, *new;
-
-       new = kmalloc(sizeof(struct vm_region), gfp);
-       if (!new)
-               goto out;
-
-       spin_lock_irqsave(&consistent_lock, flags);
-
-       list_for_each_entry(c, &head->vm_list, vm_list) {
-               if ((addr + size) < addr)
-                       goto nospc;
-               if ((addr + size) <= c->vm_start)
-                       goto found;
-               addr = c->vm_end;
-               if (addr > end)
-                       goto nospc;
-       }
-
- found:
-       /*
-        * Insert this entry _before_ the one we found.
-        */
-       list_add_tail(&new->vm_list, &c->vm_list);
-       new->vm_start = addr;
-       new->vm_end = addr + size;
-
-       spin_unlock_irqrestore(&consistent_lock, flags);
-       return new;
-
- nospc:
-       spin_unlock_irqrestore(&consistent_lock, flags);
-       kfree(new);
- out:
-       return NULL;
-}
-
-static struct vm_region *vm_region_find(struct vm_region *head, unsigned long addr)
-{
-       struct vm_region *c;
-
-       list_for_each_entry(c, &head->vm_list, vm_list) {
-               if (c->vm_start == addr)
-                       goto out;
-       }
-       c = NULL;
- out:
-       return c;
-}
-
-/*
- * Allocate DMA-coherent memory space and return both the kernel remapped
- * virtual and bus address for that space.
- */
-void *
-__dma_alloc_coherent(size_t size, dma_addr_t *handle, int gfp)
-{
-       struct page *page;
-       struct vm_region *c;
-       unsigned long order;
-       u64 mask = 0x00ffffff, limit; /* ISA default */
-
-       if (!consistent_pte) {
-               printk(KERN_ERR "%s: not initialised\n", __func__);
-               dump_stack();
-               return NULL;
-       }
-
-       size = PAGE_ALIGN(size);
-       limit = (mask + 1) & ~mask;
-       if ((limit && size >= limit) || size >= (CONSISTENT_END - CONSISTENT_BASE)) {
-               printk(KERN_WARNING "coherent allocation too big (requested %#x mask %#Lx)\n",
-                      size, mask);
-               return NULL;
-       }
-
-       order = get_order(size);
-
-       if (mask != 0xffffffff)
-               gfp |= GFP_DMA;
-
-       page = alloc_pages(gfp, order);
-       if (!page)
-               goto no_page;
-
-       /*
-        * Invalidate any data that might be lurking in the
-        * kernel direct-mapped region for device DMA.
-        */
-       {
-               unsigned long kaddr = (unsigned long)page_address(page);
-               memset(page_address(page), 0, size);
-               flush_dcache_range(kaddr, kaddr + size);
-       }
-
-       /*
-        * Allocate a virtual address in the consistent mapping region.
-        */
-       c = vm_region_alloc(&consistent_head, size,
-                           gfp & ~(__GFP_DMA | __GFP_HIGHMEM));
-       if (c) {
-               pte_t *pte = consistent_pte + CONSISTENT_OFFSET(c->vm_start);
-               struct page *end = page + (1 << order);
-
-               /*
-                * Set the "dma handle"
-                */
-               *handle = page_to_bus(page);
-
-               do {
-                       BUG_ON(!pte_none(*pte));
-
-                       set_page_count(page, 1);
-                       SetPageReserved(page);
-                       set_pte(pte, mk_pte(page, pgprot_noncached(PAGE_KERNEL)));
-                       page++;
-                       pte++;
-               } while (size -= PAGE_SIZE);
-
-               /*
-                * Free the otherwise unused pages.
-                */
-               while (page < end) {
-                       set_page_count(page, 1);
-                       __free_page(page);
-                       page++;
-               }
-
-               return (void *)c->vm_start;
-       }
-
-       if (page)
-               __free_pages(page, order);
- no_page:
-       return NULL;
-}
-EXPORT_SYMBOL(__dma_alloc_coherent);
-
-/*
- * free a page as defined by the above mapping.
- */
-void __dma_free_coherent(size_t size, void *vaddr)
-{
-       struct vm_region *c;
-       unsigned long flags;
-       pte_t *ptep;
-
-       size = PAGE_ALIGN(size);
-
-       spin_lock_irqsave(&consistent_lock, flags);
-
-       c = vm_region_find(&consistent_head, (unsigned long)vaddr);
-       if (!c)
-               goto no_area;
-
-       if ((c->vm_end - c->vm_start) != size) {
-               printk(KERN_ERR "%s: freeing wrong coherent size (%ld != %d)\n",
-                      __func__, c->vm_end - c->vm_start, size);
-               dump_stack();
-               size = c->vm_end - c->vm_start;
-       }
-
-       ptep = consistent_pte + CONSISTENT_OFFSET(c->vm_start);
-       do {
-               pte_t pte = ptep_get_and_clear(ptep);
-               unsigned long pfn;
-
-               ptep++;
-
-               if (!pte_none(pte) && pte_present(pte)) {
-                       pfn = pte_pfn(pte);
-
-                       if (pfn_valid(pfn)) {
-                               struct page *page = pfn_to_page(pfn);
-                               ClearPageReserved(page);
-
-                               __free_page(page);
-                               continue;
-                       }
-               }
-
-               printk(KERN_CRIT "%s: bad page in kernel page table\n",
-                      __func__);
-       } while (size -= PAGE_SIZE);
-
-       flush_tlb_kernel_range(c->vm_start, c->vm_end);
-
-       list_del(&c->vm_list);
-
-       spin_unlock_irqrestore(&consistent_lock, flags);
-
-       kfree(c);
-       return;
-
- no_area:
-       spin_unlock_irqrestore(&consistent_lock, flags);
-       printk(KERN_ERR "%s: trying to free invalid coherent area: %p\n",
-              __func__, vaddr);
-       dump_stack();
-}
-EXPORT_SYMBOL(__dma_free_coherent);
-
-/*
- * Initialise the consistent memory allocation.
- */
-static int __init dma_alloc_init(void)
-{
-       pgd_t *pgd;
-       pmd_t *pmd;
-       pte_t *pte;
-       int ret = 0;
-
-       spin_lock(&init_mm.page_table_lock);
-
-       do {
-               pgd = pgd_offset(&init_mm, CONSISTENT_BASE);
-               pmd = pmd_alloc(&init_mm, pgd, CONSISTENT_BASE);
-               if (!pmd) {
-                       printk(KERN_ERR "%s: no pmd tables\n", __func__);
-                       ret = -ENOMEM;
-                       break;
-               }
-               WARN_ON(!pmd_none(*pmd));
-
-               pte = pte_alloc_kernel(&init_mm, pmd, CONSISTENT_BASE);
-               if (!pte) {
-                       printk(KERN_ERR "%s: no pte tables\n", __func__);
-                       ret = -ENOMEM;
-                       break;
-               }
-
-               consistent_pte = pte;
-       } while (0);
-
-       spin_unlock(&init_mm.page_table_lock);
-
-       return ret;
-}
-
-core_initcall(dma_alloc_init);
-
-/*
- * make an area consistent.
- */
-void __dma_sync(void *vaddr, size_t size, int direction)
-{
-       unsigned long start = (unsigned long)vaddr;
-       unsigned long end   = start + size;
-
-       switch (direction) {
-       case DMA_NONE:
-               BUG();
-       case DMA_FROM_DEVICE:   /* invalidate only */
-               invalidate_dcache_range(start, end);
-               break;
-       case DMA_TO_DEVICE:             /* writeback only */
-               clean_dcache_range(start, end);
-               break;
-       case DMA_BIDIRECTIONAL: /* writeback and invalidate */
-               flush_dcache_range(start, end);
-               break;
-       }
-}
-
-#ifdef CONFIG_HIGHMEM
-/*
- * __dma_sync_page() implementation for systems using highmem.
- * In this case, each page of a buffer must be kmapped/kunmapped
- * in order to have a virtual address for __dma_sync(). This must
- * not sleep so kmap_atmomic()/kunmap_atomic() are used.
- *
- * Note: yes, it is possible and correct to have a buffer extend
- * beyond the first page.
- */
-static inline void __dma_sync_page_highmem(struct page *page,
-               unsigned long offset, size_t size, int direction)
-{
-       size_t seg_size = min((size_t)PAGE_SIZE, size) - offset;
-       size_t cur_size = seg_size;
-       unsigned long flags, start, seg_offset = offset;
-       int nr_segs = PAGE_ALIGN(size + (PAGE_SIZE - offset))/PAGE_SIZE;
-       int seg_nr = 0;
-
-       local_irq_save(flags);
-
-       do {
-               start = (unsigned long)kmap_atomic(page + seg_nr,
-                               KM_PPC_SYNC_PAGE) + seg_offset;
-
-               /* Sync this buffer segment */
-               __dma_sync((void *)start, seg_size, direction);
-               kunmap_atomic((void *)start, KM_PPC_SYNC_PAGE);
-               seg_nr++;
-
-               /* Calculate next buffer segment size */
-               seg_size = min((size_t)PAGE_SIZE, size - cur_size);
-
-               /* Add the segment size to our running total */
-               cur_size += seg_size;
-               seg_offset = 0;
-       } while (seg_nr < nr_segs);
-
-       local_irq_restore(flags);
-}
-#endif /* CONFIG_HIGHMEM */
-
-/*
- * __dma_sync_page makes memory consistent. identical to __dma_sync, but
- * takes a struct page instead of a virtual address
- */
-void __dma_sync_page(struct page *page, unsigned long offset,
-       size_t size, int direction)
-{
-#ifdef CONFIG_HIGHMEM
-       __dma_sync_page_highmem(page, offset, size, direction);
-#else
-       unsigned long start = (unsigned long)page_address(page) + offset;
-       __dma_sync((void *)start, size, direction);
-#endif
-}
diff --git a/arch/ppc/kernel/head_e500.S b/arch/ppc/kernel/head_e500.S
deleted file mode 100644 (file)
index ceb51d3..0000000
+++ /dev/null
@@ -1,1331 +0,0 @@
-/*
- * arch/ppc/kernel/head_e500.S
- *
- * Kernel execution entry point code.
- *
- *    Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
- *      Initial PowerPC version.
- *    Copyright (c) 1996 Cort Dougan <cort@cs.nmt.edu>
- *      Rewritten for PReP
- *    Copyright (c) 1996 Paul Mackerras <paulus@cs.anu.edu.au>
- *      Low-level exception handers, MMU support, and rewrite.
- *    Copyright (c) 1997 Dan Malek <dmalek@jlc.net>
- *      PowerPC 8xx modifications.
- *    Copyright (c) 1998-1999 TiVo, Inc.
- *      PowerPC 403GCX modifications.
- *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
- *      PowerPC 403GCX/405GP modifications.
- *    Copyright 2000 MontaVista Software Inc.
- *     PPC405 modifications
- *      PowerPC 403GCX/405GP modifications.
- *     Author: MontaVista Software, Inc.
- *             frank_rowand@mvista.com or source@mvista.com
- *             debbie_chu@mvista.com
- *    Copyright 2002-2004 MontaVista Software, Inc.
- *      PowerPC 44x support, Matt Porter <mporter@kernel.crashing.org>
- *    Copyright 2004 Freescale Semiconductor, Inc
- *      PowerPC e500 modifications, Kumar Gala <kumar.gala@freescale.com>
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <asm/processor.h>
-#include <asm/page.h>
-#include <asm/mmu.h>
-#include <asm/pgtable.h>
-#include <asm/cputable.h>
-#include <asm/thread_info.h>
-#include <asm/ppc_asm.h>
-#include <asm/offsets.h>
-
-/*
- * Macros
- */
-
-#define SET_IVOR(vector_number, vector_label)          \
-               li      r26,vector_label@l;             \
-               mtspr   SPRN_IVOR##vector_number,r26;   \
-               sync
-
-/* As with the other PowerPC ports, it is expected that when code
- * execution begins here, the following registers contain valid, yet
- * optional, information:
- *
- *   r3 - Board info structure pointer (DRAM, frequency, MAC address, etc.)
- *   r4 - Starting address of the init RAM disk
- *   r5 - Ending address of the init RAM disk
- *   r6 - Start of kernel command line string (e.g. "mem=128")
- *   r7 - End of kernel command line string
- *
- */
-       .text
-_GLOBAL(_stext)
-_GLOBAL(_start)
-       /*
-        * Reserve a word at a fixed location to store the address
-        * of abatron_pteptrs
-        */
-       nop
-/*
- * Save parameters we are passed
- */
-       mr      r31,r3
-       mr      r30,r4
-       mr      r29,r5
-       mr      r28,r6
-       mr      r27,r7
-       li      r24,0           /* CPU number */
-
-/* We try to not make any assumptions about how the boot loader
- * setup or used the TLBs.  We invalidate all mappings from the
- * boot loader and load a single entry in TLB1[0] to map the
- * first 16M of kernel memory.  Any boot info passed from the
- * bootloader needs to live in this first 16M.
- *
- * Requirement on bootloader:
- *  - The page we're executing in needs to reside in TLB1 and
- *    have IPROT=1.  If not an invalidate broadcast could
- *    evict the entry we're currently executing in.
- *
- *  r3 = Index of TLB1 were executing in
- *  r4 = Current MSR[IS]
- *  r5 = Index of TLB1 temp mapping
- *
- * Later in mapin_ram we will correctly map lowmem, and resize TLB1[0]
- * if needed
- */
-
-/* 1. Find the index of the entry we're executing in */
-       bl      invstr                          /* Find our address */
-invstr:        mflr    r6                              /* Make it accessible */
-       mfmsr   r7
-       rlwinm  r4,r7,27,31,31                  /* extract MSR[IS] */
-       mfspr   r7, SPRN_PID0
-       slwi    r7,r7,16
-       or      r7,r7,r4
-       mtspr   SPRN_MAS6,r7
-       tlbsx   0,r6                            /* search MSR[IS], SPID=PID0 */
-       mfspr   r7,SPRN_MAS1
-       andis.  r7,r7,MAS1_VALID@h
-       bne     match_TLB
-       mfspr   r7,SPRN_PID1
-       slwi    r7,r7,16
-       or      r7,r7,r4
-       mtspr   SPRN_MAS6,r7
-       tlbsx   0,r6                            /* search MSR[IS], SPID=PID1 */
-       mfspr   r7,SPRN_MAS1
-       andis.  r7,r7,MAS1_VALID@h
-       bne     match_TLB
-       mfspr   r7, SPRN_PID2
-       slwi    r7,r7,16
-       or      r7,r7,r4
-       mtspr   SPRN_MAS6,r7
-       tlbsx   0,r6                            /* Fall through, we had to match */
-match_TLB:
-       mfspr   r7,SPRN_MAS0
-       rlwinm  r3,r7,16,28,31                  /* Extract MAS0(Entry) */
-
-       mfspr   r7,SPRN_MAS1                    /* Insure IPROT set */
-       oris    r7,r7,MAS1_IPROT@h
-       mtspr   SPRN_MAS1,r7
-       tlbwe
-
-/* 2. Invalidate all entries except the entry we're executing in */
-       mfspr   r9,SPRN_TLB1CFG
-       andi.   r9,r9,0xfff
-       li      r6,0                            /* Set Entry counter to 0 */
-1:     lis     r7,0x1000                       /* Set MAS0(TLBSEL) = 1 */
-       rlwimi  r7,r6,16,12,15                  /* Setup MAS0 = TLBSEL | ESEL(r6) */
-       mtspr   SPRN_MAS0,r7
-       tlbre
-       mfspr   r7,SPRN_MAS1
-       rlwinm  r7,r7,0,2,31                    /* Clear MAS1 Valid and IPROT */
-       cmpw    r3,r6
-       beq     skpinv                          /* Dont update the current execution TLB */
-       mtspr   SPRN_MAS1,r7
-       tlbwe
-       isync
-skpinv:        addi    r6,r6,1                         /* Increment */
-       cmpw    r6,r9                           /* Are we done? */
-       bne     1b                              /* If not, repeat */
-
-       /* Invalidate TLB0 */
-       li      r6,0x04
-       tlbivax 0,r6
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
-       /* Invalidate TLB1 */
-       li      r6,0x0c
-       tlbivax 0,r6
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
-       msync
-
-/* 3. Setup a temp mapping and jump to it */
-       andi.   r5, r3, 0x1     /* Find an entry not used and is non-zero */
-       addi    r5, r5, 0x1
-       lis     r7,0x1000       /* Set MAS0(TLBSEL) = 1 */
-       rlwimi  r7,r3,16,12,15  /* Setup MAS0 = TLBSEL | ESEL(r3) */
-       mtspr   SPRN_MAS0,r7
-       tlbre
-
-       /* Just modify the entry ID and EPN for the temp mapping */
-       lis     r7,0x1000       /* Set MAS0(TLBSEL) = 1 */
-       rlwimi  r7,r5,16,12,15  /* Setup MAS0 = TLBSEL | ESEL(r5) */
-       mtspr   SPRN_MAS0,r7
-       xori    r6,r4,1         /* Setup TMP mapping in the other Address space */
-       slwi    r6,r6,12
-       oris    r6,r6,(MAS1_VALID|MAS1_IPROT)@h
-       ori     r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
-       mtspr   SPRN_MAS1,r6
-       mfspr   r6,SPRN_MAS2
-       li      r7,0            /* temp EPN = 0 */
-       rlwimi  r7,r6,0,20,31
-       mtspr   SPRN_MAS2,r7
-       tlbwe
-
-       xori    r6,r4,1
-       slwi    r6,r6,5         /* setup new context with other address space */
-       bl      1f              /* Find our address */
-1:     mflr    r9
-       rlwimi  r7,r9,0,20,31
-       addi    r7,r7,24
-       mtspr   SRR0,r7
-       mtspr   SRR1,r6
-       rfi
-
-/* 4. Clear out PIDs & Search info */
-       li      r6,0
-       mtspr   SPRN_PID0,r6
-       mtspr   SPRN_PID1,r6
-       mtspr   SPRN_PID2,r6
-       mtspr   SPRN_MAS6,r6
-
-/* 5. Invalidate mapping we started in */
-       lis     r7,0x1000       /* Set MAS0(TLBSEL) = 1 */
-       rlwimi  r7,r3,16,12,15  /* Setup MAS0 = TLBSEL | ESEL(r3) */
-       mtspr   SPRN_MAS0,r7
-       tlbre
-       li      r6,0
-       mtspr   SPRN_MAS1,r6
-       tlbwe
-       /* Invalidate TLB1 */
-       li      r9,0x0c
-       tlbivax 0,r9
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
-       msync
-
-/* 6. Setup KERNELBASE mapping in TLB1[0] */
-       lis     r6,0x1000               /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
-       mtspr   SPRN_MAS0,r6
-       lis     r6,(MAS1_VALID|MAS1_IPROT)@h
-       ori     r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_16M))@l
-       mtspr   SPRN_MAS1,r6
-       li      r7,0
-       lis     r6,KERNELBASE@h
-       ori     r6,r6,KERNELBASE@l
-       rlwimi  r6,r7,0,20,31
-       mtspr   SPRN_MAS2,r6
-       li      r7,(MAS3_SX|MAS3_SW|MAS3_SR)
-       mtspr   SPRN_MAS3,r7
-       tlbwe
-
-/* 7. Jump to KERNELBASE mapping */
-       li      r7,0
-       bl      1f                      /* Find our address */
-1:     mflr    r9
-       rlwimi  r6,r9,0,20,31
-       addi    r6,r6,24
-       mtspr   SRR0,r6
-       mtspr   SRR1,r7
-       rfi                             /* start execution out of TLB1[0] entry */
-
-/* 8. Clear out the temp mapping */
-       lis     r7,0x1000       /* Set MAS0(TLBSEL) = 1 */
-       rlwimi  r7,r5,16,12,15  /* Setup MAS0 = TLBSEL | ESEL(r5) */
-       mtspr   SPRN_MAS0,r7
-       tlbre
-       mtspr   SPRN_MAS1,r8
-       tlbwe
-       /* Invalidate TLB1 */
-       li      r9,0x0c
-       tlbivax 0,r9
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
-       msync
-
-       /* Establish the interrupt vector offsets */
-       SET_IVOR(0,  CriticalInput);
-       SET_IVOR(1,  MachineCheck);
-       SET_IVOR(2,  DataStorage);
-       SET_IVOR(3,  InstructionStorage);
-       SET_IVOR(4,  ExternalInput);
-       SET_IVOR(5,  Alignment);
-       SET_IVOR(6,  Program);
-       SET_IVOR(7,  FloatingPointUnavailable);
-       SET_IVOR(8,  SystemCall);
-       SET_IVOR(9,  AuxillaryProcessorUnavailable);
-       SET_IVOR(10, Decrementer);
-       SET_IVOR(11, FixedIntervalTimer);
-       SET_IVOR(12, WatchdogTimer);
-       SET_IVOR(13, DataTLBError);
-       SET_IVOR(14, InstructionTLBError);
-       SET_IVOR(15, Debug);
-       SET_IVOR(32, SPEUnavailable);
-       SET_IVOR(33, SPEFloatingPointData);
-       SET_IVOR(34, SPEFloatingPointRound);
-       SET_IVOR(35, PerformanceMonitor);
-
-       /* Establish the interrupt vector base */
-       lis     r4,interrupt_base@h     /* IVPR only uses the high 16-bits */
-       mtspr   SPRN_IVPR,r4
-
-       /* Setup the defaults for TLB entries */
-       li      r2,MAS4_TSIZED(BOOKE_PAGESZ_4K)
-       mtspr   SPRN_MAS4, r2
-
-#if 0
-       /* Enable DOZE */
-       mfspr   r2,SPRN_HID0
-       oris    r2,r2,HID0_DOZE@h
-       mtspr   SPRN_HID0, r2
-#endif
-
-       /*
-        * This is where the main kernel code starts.
-        */
-
-       /* ptr to current */
-       lis     r2,init_task@h
-       ori     r2,r2,init_task@l
-
-       /* ptr to current thread */
-       addi    r4,r2,THREAD    /* init task's THREAD */
-       mtspr   SPRG3,r4
-
-       /* stack */
-       lis     r1,init_thread_union@h
-       ori     r1,r1,init_thread_union@l
-       li      r0,0
-       stwu    r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
-
-       bl      early_init
-
-       mfspr   r3,SPRN_TLB1CFG
-       andi.   r3,r3,0xfff
-       lis     r4,num_tlbcam_entries@ha
-       stw     r3,num_tlbcam_entries@l(r4)
-/*
- * Decide what sort of machine this is and initialize the MMU.
- */
-       mr      r3,r31
-       mr      r4,r30
-       mr      r5,r29
-       mr      r6,r28
-       mr      r7,r27
-       bl      machine_init
-       bl      MMU_init
-
-       /* Setup PTE pointers for the Abatron bdiGDB */
-       lis     r6, swapper_pg_dir@h
-       ori     r6, r6, swapper_pg_dir@l
-       lis     r5, abatron_pteptrs@h
-       ori     r5, r5, abatron_pteptrs@l
-       lis     r4, KERNELBASE@h
-       ori     r4, r4, KERNELBASE@l
-       stw     r5, 0(r4)       /* Save abatron_pteptrs at a fixed location */
-       stw     r6, 0(r5)
-
-       /* Let's move on */
-       lis     r4,start_kernel@h
-       ori     r4,r4,start_kernel@l
-       lis     r3,MSR_KERNEL@h
-       ori     r3,r3,MSR_KERNEL@l
-       mtspr   SRR0,r4
-       mtspr   SRR1,r3
-       rfi                     /* change context and jump to start_kernel */
-
-/*
- * Interrupt vector entry code
- *
- * The Book E MMUs are always on so we don't need to handle
- * interrupts in real mode as with previous PPC processors. In
- * this case we handle interrupts in the kernel virtual address
- * space.
- *
- * Interrupt vectors are dynamically placed relative to the
- * interrupt prefix as determined by the address of interrupt_base.
- * The interrupt vectors offsets are programmed using the labels
- * for each interrupt vector entry.
- *
- * Interrupt vectors must be aligned on a 16 byte boundary.
- * We align on a 32 byte cache line boundary for good measure.
- */
-
-#define NORMAL_EXCEPTION_PROLOG                                                     \
-       mtspr   SPRN_SPRG0,r10;         /* save two registers to work with */\
-       mtspr   SPRN_SPRG1,r11;                                              \
-       mtspr   SPRN_SPRG4W,r1;                                              \
-       mfcr    r10;                    /* save CR in r10 for now          */\
-       mfspr   r11,SPRN_SRR1;          /* check whether user or kernel    */\
-       andi.   r11,r11,MSR_PR;                                              \
-       beq     1f;                                                          \
-       mfspr   r1,SPRG3;               /* if from user, start at top of   */\
-       lwz     r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack   */\
-       addi    r1,r1,THREAD_SIZE;                                           \
-1:     subi    r1,r1,INT_FRAME_SIZE;   /* Allocate an exception frame     */\
-       tophys(r11,r1);                                                      \
-       stw     r10,_CCR(r11);          /* save various registers          */\
-       stw     r12,GPR12(r11);                                              \
-       stw     r9,GPR9(r11);                                                \
-       mfspr   r10,SPRG0;                                                   \
-       stw     r10,GPR10(r11);                                              \
-       mfspr   r12,SPRG1;                                                   \
-       stw     r12,GPR11(r11);                                              \
-       mflr    r10;                                                         \
-       stw     r10,_LINK(r11);                                              \
-       mfspr   r10,SPRG4R;                                                  \
-       mfspr   r12,SRR0;                                                    \
-       stw     r10,GPR1(r11);                                               \
-       mfspr   r9,SRR1;                                                     \
-       stw     r10,0(r11);                                                  \
-       rlwinm  r9,r9,0,14,12;          /* clear MSR_WE (necessary?)       */\
-       stw     r0,GPR0(r11);                                                \
-       SAVE_4GPRS(3, r11);                                                  \
-       SAVE_2GPRS(7, r11)
-
-/*
- * Exception prolog for critical exceptions.  This is a little different
- * from the normal exception prolog above since a critical exception
- * can potentially occur at any point during normal exception processing.
- * Thus we cannot use the same SPRG registers as the normal prolog above.
- * Instead we use a couple of words of memory at low physical addresses.
- * This is OK since we don't support SMP on these processors. For Book E
- * processors, we also have a reserved register (SPRG2) that is only used
- * in critical exceptions so we can free up a GPR to use as the base for
- * indirect access to the critical exception save area.  This is necessary
- * since the MMU is always on and the save area is offset from KERNELBASE.
- */
-#define CRITICAL_EXCEPTION_PROLOG                                           \
-       mtspr   SPRG2,r8;               /* SPRG2 only used in criticals */   \
-       lis     r8,crit_save@ha;                                             \
-       stw     r10,crit_r10@l(r8);                                          \
-       stw     r11,crit_r11@l(r8);                                          \
-       mfspr   r10,SPRG0;                                                   \
-       stw     r10,crit_sprg0@l(r8);                                        \
-       mfspr   r10,SPRG1;                                                   \
-       stw     r10,crit_sprg1@l(r8);                                        \
-       mfspr   r10,SPRG4R;                                                  \
-       stw     r10,crit_sprg4@l(r8);                                        \
-       mfspr   r10,SPRG5R;                                                  \
-       stw     r10,crit_sprg5@l(r8);                                        \
-       mfspr   r10,SPRG7R;                                                  \
-       stw     r10,crit_sprg7@l(r8);                                        \
-       mfspr   r10,SPRN_PID;                                                \
-       stw     r10,crit_pid@l(r8);                                          \
-       mfspr   r10,SRR0;                                                    \
-       stw     r10,crit_srr0@l(r8);                                         \
-       mfspr   r10,SRR1;                                                    \
-       stw     r10,crit_srr1@l(r8);                                         \
-       mfspr   r8,SPRG2;               /* SPRG2 only used in criticals */   \
-       mfcr    r10;                    /* save CR in r10 for now          */\
-       mfspr   r11,SPRN_CSRR1;         /* check whether user or kernel    */\
-       andi.   r11,r11,MSR_PR;                                              \
-       lis     r11,critical_stack_top@h;                                    \
-       ori     r11,r11,critical_stack_top@l;                                \
-       beq     1f;                                                          \
-       /* COMING FROM USER MODE */                                          \
-       mfspr   r11,SPRG3;              /* if from user, start at top of   */\
-       lwz     r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
-       addi    r11,r11,THREAD_SIZE;                                         \
-1:     subi    r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame     */\
-       stw     r10,_CCR(r11);          /* save various registers          */\
-       stw     r12,GPR12(r11);                                              \
-       stw     r9,GPR9(r11);                                                \
-       mflr    r10;                                                         \
-       stw     r10,_LINK(r11);                                              \
-       mfspr   r12,SPRN_DEAR;          /* save DEAR and ESR in the frame  */\
-       stw     r12,_DEAR(r11);         /* since they may have had stuff   */\
-       mfspr   r9,SPRN_ESR;            /* in them at the point where the  */\
-       stw     r9,_ESR(r11);           /* exception was taken             */\
-       mfspr   r12,CSRR0;                                                   \
-       stw     r1,GPR1(r11);                                                \
-       mfspr   r9,CSRR1;                                                    \
-       stw     r1,0(r11);                                                   \
-       tovirt(r1,r11);                                                      \
-       rlwinm  r9,r9,0,14,12;          /* clear MSR_WE (necessary?)       */\
-       stw     r0,GPR0(r11);                                                \
-       SAVE_4GPRS(3, r11);                                                  \
-       SAVE_2GPRS(7, r11)
-
-/*
- * Exception prolog for machine check exceptions.  This is similar to
- * the critical exception prolog, except that machine check exceptions
- * have their own save area.  For Book E processors, we also have a
- * reserved register (SPRG6) that is only used in machine check exceptions
- * so we can free up a GPR to use as the base for indirect access to the
- * machine check exception save area.  This is necessary since the MMU
- * is always on and the save area is offset from KERNELBASE.
- */
-#define MCHECK_EXCEPTION_PROLOG                                             \
-       mtspr   SPRG6W,r8;              /* SPRG6 used in machine checks */   \
-       lis     r8,mcheck_save@ha;                                           \
-       stw     r10,mcheck_r10@l(r8);                                        \
-       stw     r11,mcheck_r11@l(r8);                                        \
-       mfspr   r10,SPRG0;                                                   \
-       stw     r10,mcheck_sprg0@l(r8);                                      \
-       mfspr   r10,SPRG1;                                                   \
-       stw     r10,mcheck_sprg1@l(r8);                                      \
-       mfspr   r10,SPRG4R;                                                  \
-       stw     r10,mcheck_sprg4@l(r8);                                      \
-       mfspr   r10,SPRG5R;                                                  \
-       stw     r10,mcheck_sprg5@l(r8);                                      \
-       mfspr   r10,SPRG7R;                                                  \
-       stw     r10,mcheck_sprg7@l(r8);                                      \
-       mfspr   r10,SPRN_PID;                                                \
-       stw     r10,mcheck_pid@l(r8);                                        \
-       mfspr   r10,SRR0;                                                    \
-       stw     r10,mcheck_srr0@l(r8);                                       \
-       mfspr   r10,SRR1;                                                    \
-       stw     r10,mcheck_srr1@l(r8);                                       \
-       mfspr   r10,CSRR0;                                                   \
-       stw     r10,mcheck_csrr0@l(r8);                                      \
-       mfspr   r10,CSRR1;                                                   \
-       stw     r10,mcheck_csrr1@l(r8);                                      \
-       mfspr   r8,SPRG6R;              /* SPRG6 used in machine checks */   \
-       mfcr    r10;                    /* save CR in r10 for now          */\
-       mfspr   r11,SPRN_MCSRR1;        /* check whether user or kernel    */\
-       andi.   r11,r11,MSR_PR;                                              \
-       lis     r11,mcheck_stack_top@h;                                      \
-       ori     r11,r11,mcheck_stack_top@l;                                  \
-       beq     1f;                                                          \
-       /* COMING FROM USER MODE */                                          \
-       mfspr   r11,SPRG3;              /* if from user, start at top of   */\
-       lwz     r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
-       addi    r11,r11,THREAD_SIZE;                                         \
-1:     subi    r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame     */\
-       stw     r10,_CCR(r11);          /* save various registers          */\
-       stw     r12,GPR12(r11);                                              \
-       stw     r9,GPR9(r11);                                                \
-       mflr    r10;                                                         \
-       stw     r10,_LINK(r11);                                              \
-       mfspr   r12,SPRN_DEAR;          /* save DEAR and ESR in the frame  */\
-       stw     r12,_DEAR(r11);         /* since they may have had stuff   */\
-       mfspr   r9,SPRN_ESR;            /* in them at the point where the  */\
-       stw     r9,_ESR(r11);           /* exception was taken             */\
-       mfspr   r12,MCSRR0;                                                  \
-       stw     r1,GPR1(r11);                                                \
-       mfspr   r9,MCSRR1;                                                   \
-       stw     r1,0(r11);                                                   \
-       tovirt(r1,r11);                                                      \
-       rlwinm  r9,r9,0,14,12;          /* clear MSR_WE (necessary?)       */\
-       stw     r0,GPR0(r11);                                                \
-       SAVE_4GPRS(3, r11);                                                  \
-       SAVE_2GPRS(7, r11)
-
-/*
- * Exception vectors.
- */
-#define        START_EXCEPTION(label)                                               \
-        .align 5;                                                                   \
-label:
-
-#define FINISH_EXCEPTION(func)                                 \
-       bl      transfer_to_handler_full;                       \
-       .long   func;                                           \
-       .long   ret_from_except_full
-
-#define EXCEPTION(n, label, hdlr, xfer)                                \
-       START_EXCEPTION(label);                                 \
-       NORMAL_EXCEPTION_PROLOG;                                \
-       addi    r3,r1,STACK_FRAME_OVERHEAD;                     \
-       xfer(n, hdlr)
-
-#define CRITICAL_EXCEPTION(n, label, hdlr)                     \
-       START_EXCEPTION(label);                                 \
-       CRITICAL_EXCEPTION_PROLOG;                              \
-       addi    r3,r1,STACK_FRAME_OVERHEAD;                     \
-       EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
-                         NOCOPY, transfer_to_handler_full, \
-                         ret_from_except_full)
-
-#define MCHECK_EXCEPTION(n, label, hdlr)                       \
-       START_EXCEPTION(label);                                 \
-       MCHECK_EXCEPTION_PROLOG;                                \
-       mfspr   r5,SPRN_ESR;                                    \
-       stw     r5,_ESR(r11);                                   \
-       addi    r3,r1,STACK_FRAME_OVERHEAD;                     \
-       EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
-                         NOCOPY, mcheck_transfer_to_handler,   \
-                         ret_from_mcheck_exc)
-
-#define EXC_XFER_TEMPLATE(hdlr, trap, msr, copyee, tfer, ret)  \
-       li      r10,trap;                                       \
-       stw     r10,TRAP(r11);                                  \
-       lis     r10,msr@h;                                      \
-       ori     r10,r10,msr@l;                                  \
-       copyee(r10, r9);                                        \
-       bl      tfer;                                           \
-       .long   hdlr;                                           \
-       .long   ret
-
-#define COPY_EE(d, s)          rlwimi d,s,0,16,16
-#define NOCOPY(d, s)
-
-#define EXC_XFER_STD(n, hdlr)          \
-       EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, NOCOPY, transfer_to_handler_full, \
-                         ret_from_except_full)
-
-#define EXC_XFER_LITE(n, hdlr)         \
-       EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, NOCOPY, transfer_to_handler, \
-                         ret_from_except)
-
-#define EXC_XFER_EE(n, hdlr)           \
-       EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, COPY_EE, transfer_to_handler_full, \
-                         ret_from_except_full)
-
-#define EXC_XFER_EE_LITE(n, hdlr)      \
-       EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \
-                         ret_from_except)
-
-interrupt_base:
-       /* Critical Input Interrupt */
-       CRITICAL_EXCEPTION(0x0100, CriticalInput, UnknownException)
-
-       /* Machine Check Interrupt */
-       MCHECK_EXCEPTION(0x0200, MachineCheck, MachineCheckException)
-
-       /* Data Storage Interrupt */
-       START_EXCEPTION(DataStorage)
-       mtspr   SPRG0, r10              /* Save some working registers */
-       mtspr   SPRG1, r11
-       mtspr   SPRG4W, r12
-       mtspr   SPRG5W, r13
-       mfcr    r11
-       mtspr   SPRG7W, r11
-
-       /*
-        * Check if it was a store fault, if not then bail
-        * because a user tried to access a kernel or
-        * read-protected page.  Otherwise, get the
-        * offending address and handle it.
-        */
-       mfspr   r10, SPRN_ESR
-       andis.  r10, r10, ESR_ST@h
-       beq     2f
-
-       mfspr   r10, SPRN_DEAR          /* Get faulting address */
-
-       /* If we are faulting a kernel address, we have to use the
-        * kernel page tables.
-        */
-       lis     r11, TASK_SIZE@h
-       ori     r11, r11, TASK_SIZE@l
-       cmplw   0, r10, r11
-       bge     2f
-
-       /* Get the PGD for the current thread */
-3:
-       mfspr   r11,SPRG3
-       lwz     r11,PGDIR(r11)
-4:
-       rlwimi  r11, r10, 12, 20, 29    /* Create L1 (pgdir/pmd) address */
-       lwz     r11, 0(r11)             /* Get L1 entry */
-       rlwinm. r12, r11, 0, 0, 19      /* Extract L2 (pte) base address */
-       beq     2f                      /* Bail if no table */
-
-       rlwimi  r12, r10, 22, 20, 29    /* Compute PTE address */
-       lwz     r11, 0(r12)             /* Get Linux PTE */
-
-       /* Are _PAGE_USER & _PAGE_RW set & _PAGE_HWWRITE not? */
-       andi.   r13, r11, _PAGE_RW|_PAGE_USER|_PAGE_HWWRITE
-       cmpwi   0, r13, _PAGE_RW|_PAGE_USER
-       bne     2f                      /* Bail if not */
-
-       /* Update 'changed'. */
-       ori     r11, r11, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
-       stw     r11, 0(r12)             /* Update Linux page table */
-
-       /* MAS2 not updated as the entry does exist in the tlb, this
-          fault taken to detect state transition (eg: COW -> DIRTY)
-        */
-       lis     r12, MAS3_RPN@h
-       ori     r12, r12, _PAGE_HWEXEC | MAS3_RPN@l
-       and     r11, r11, r12
-       rlwimi  r11, r11, 31, 27, 27    /* SX <- _PAGE_HWEXEC */
-       ori     r11, r11, (MAS3_UW|MAS3_SW|MAS3_UR|MAS3_SR)@l /* set static perms */
-
-       /* update search PID in MAS6, AS = 0 */
-       mfspr   r12, SPRN_PID0
-       slwi    r12, r12, 16
-       mtspr   SPRN_MAS6, r12
-
-       /* find the TLB index that caused the fault.  It has to be here. */
-       tlbsx   0, r10
-
-       mtspr   SPRN_MAS3,r11
-       tlbwe
-
-       /* Done...restore registers and get out of here.  */
-       mfspr   r11, SPRG7R
-       mtcr    r11
-       mfspr   r13, SPRG5R
-       mfspr   r12, SPRG4R
-       mfspr   r11, SPRG1
-       mfspr   r10, SPRG0
-       rfi                     /* Force context change */
-
-2:
-       /*
-        * The bailout.  Restore registers to pre-exception conditions
-        * and call the heavyweights to help us out.
-        */
-       mfspr   r11, SPRG7R
-       mtcr    r11
-       mfspr   r13, SPRG5R
-       mfspr   r12, SPRG4R
-       mfspr   r11, SPRG1
-       mfspr   r10, SPRG0
-       b       data_access
-
-       /* Instruction Storage Interrupt */
-       START_EXCEPTION(InstructionStorage)
-       NORMAL_EXCEPTION_PROLOG
-       mfspr   r5,SPRN_ESR             /* Grab the ESR and save it */
-       stw     r5,_ESR(r11)
-       mr      r4,r12                  /* Pass SRR0 as arg2 */
-       li      r5,0                    /* Pass zero as arg3 */
-       EXC_XFER_EE_LITE(0x0400, handle_page_fault)
-
-       /* External Input Interrupt */
-       EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
-
-       /* Alignment Interrupt */
-       START_EXCEPTION(Alignment)
-       NORMAL_EXCEPTION_PROLOG
-       mfspr   r4,SPRN_DEAR            /* Grab the DEAR and save it */
-       stw     r4,_DEAR(r11)
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_EE(0x0600, AlignmentException)
-
-       /* Program Interrupt */
-       START_EXCEPTION(Program)
-       NORMAL_EXCEPTION_PROLOG
-       mfspr   r4,SPRN_ESR             /* Grab the ESR and save it */
-       stw     r4,_ESR(r11)
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_STD(0x0700, ProgramCheckException)
-
-       /* Floating Point Unavailable Interrupt */
-       EXCEPTION(0x0800, FloatingPointUnavailable, UnknownException, EXC_XFER_EE)
-
-       /* System Call Interrupt */
-       START_EXCEPTION(SystemCall)
-       NORMAL_EXCEPTION_PROLOG
-       EXC_XFER_EE_LITE(0x0c00, DoSyscall)
-
-       /* Auxillary Processor Unavailable Interrupt */
-       EXCEPTION(0x2900, AuxillaryProcessorUnavailable, UnknownException, EXC_XFER_EE)
-
-       /* Decrementer Interrupt */
-       START_EXCEPTION(Decrementer)
-       NORMAL_EXCEPTION_PROLOG
-       lis     r0,TSR_DIS@h            /* Setup the DEC interrupt mask */
-       mtspr   SPRN_TSR,r0             /* Clear the DEC interrupt */
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_LITE(0x0900, timer_interrupt)
-
-       /* Fixed Internal Timer Interrupt */
-       /* TODO: Add FIT support */
-       EXCEPTION(0x3100, FixedIntervalTimer, UnknownException, EXC_XFER_EE)
-
-       /* Watchdog Timer Interrupt */
-       /* TODO: Add watchdog support */
-       CRITICAL_EXCEPTION(0x3200, WatchdogTimer, UnknownException)
-
-       /* Data TLB Error Interrupt */
-       START_EXCEPTION(DataTLBError)
-       mtspr   SPRG0, r10              /* Save some working registers */
-       mtspr   SPRG1, r11
-       mtspr   SPRG4W, r12
-       mtspr   SPRG5W, r13
-       mfcr    r11
-       mtspr   SPRG7W, r11
-       mfspr   r10, SPRN_DEAR          /* Get faulting address */
-
-       /* If we are faulting a kernel address, we have to use the
-        * kernel page tables.
-        */
-       lis     r11, TASK_SIZE@h
-       ori     r11, r11, TASK_SIZE@l
-       cmplw   5, r10, r11
-       blt     5, 3f
-       lis     r11, swapper_pg_dir@h
-       ori     r11, r11, swapper_pg_dir@l
-
-       mfspr   r12,SPRN_MAS1           /* Set TID to 0 */
-       li      r13,MAS1_TID@l
-       andc    r12,r12,r13
-       mtspr   SPRN_MAS1,r12
-
-       b       4f
-
-       /* Get the PGD for the current thread */
-3:
-       mfspr   r11,SPRG3
-       lwz     r11,PGDIR(r11)
-
-4:
-       rlwimi  r11, r10, 12, 20, 29    /* Create L1 (pgdir/pmd) address */
-       lwz     r11, 0(r11)             /* Get L1 entry */
-       rlwinm. r12, r11, 0, 0, 19      /* Extract L2 (pte) base address */
-       beq     2f                      /* Bail if no table */
-
-       rlwimi  r12, r10, 22, 20, 29    /* Compute PTE address */
-       lwz     r11, 0(r12)             /* Get Linux PTE */
-       andi.   r13, r11, _PAGE_PRESENT
-       beq     2f
-
-       ori     r11, r11, _PAGE_ACCESSED
-       stw     r11, 0(r12)
-
-        /* Jump to common tlb load */
-       b       finish_tlb_load
-2:
-       /* The bailout.  Restore registers to pre-exception conditions
-        * and call the heavyweights to help us out.
-        */
-       mfspr   r11, SPRG7R
-       mtcr    r11
-       mfspr   r13, SPRG5R
-       mfspr   r12, SPRG4R
-       mfspr   r11, SPRG1
-       mfspr   r10, SPRG0
-       b       data_access
-
-       /* Instruction TLB Error Interrupt */
-       /*
-        * Nearly the same as above, except we get our
-        * information from different registers and bailout
-        * to a different point.
-        */
-       START_EXCEPTION(InstructionTLBError)
-       mtspr   SPRG0, r10              /* Save some working registers */
-       mtspr   SPRG1, r11
-       mtspr   SPRG4W, r12
-       mtspr   SPRG5W, r13
-       mfcr    r11
-       mtspr   SPRG7W, r11
-       mfspr   r10, SRR0               /* Get faulting address */
-
-       /* If we are faulting a kernel address, we have to use the
-        * kernel page tables.
-        */
-       lis     r11, TASK_SIZE@h
-       ori     r11, r11, TASK_SIZE@l
-       cmplw   5, r10, r11
-       blt     5, 3f
-       lis     r11, swapper_pg_dir@h
-       ori     r11, r11, swapper_pg_dir@l
-
-       mfspr   r12,SPRN_MAS1           /* Set TID to 0 */
-       li      r13,MAS1_TID@l
-       andc    r12,r12,r13
-       mtspr   SPRN_MAS1,r12
-
-       b       4f
-
-       /* Get the PGD for the current thread */
-3:
-       mfspr   r11,SPRG3
-       lwz     r11,PGDIR(r11)
-
-4:
-       rlwimi  r11, r10, 12, 20, 29    /* Create L1 (pgdir/pmd) address */
-       lwz     r11, 0(r11)             /* Get L1 entry */
-       rlwinm. r12, r11, 0, 0, 19      /* Extract L2 (pte) base address */
-       beq     2f                      /* Bail if no table */
-
-       rlwimi  r12, r10, 22, 20, 29    /* Compute PTE address */
-       lwz     r11, 0(r12)             /* Get Linux PTE */
-       andi.   r13, r11, _PAGE_PRESENT
-       beq     2f
-
-       ori     r11, r11, _PAGE_ACCESSED
-       stw     r11, 0(r12)
-
-       /* Jump to common TLB load point */
-       b       finish_tlb_load
-
-2:
-       /* The bailout.  Restore registers to pre-exception conditions
-        * and call the heavyweights to help us out.
-        */
-       mfspr   r11, SPRG7R
-       mtcr    r11
-       mfspr   r13, SPRG5R
-       mfspr   r12, SPRG4R
-       mfspr   r11, SPRG1
-       mfspr   r10, SPRG0
-       b       InstructionStorage
-
-#ifdef CONFIG_SPE
-       /* SPE Unavailable */
-       START_EXCEPTION(SPEUnavailable)
-       NORMAL_EXCEPTION_PROLOG
-       bne     load_up_spe
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_EE_LITE(0x2010, KernelSPE)
-#else
-       EXCEPTION(0x2020, SPEUnavailable, UnknownException, EXC_XFER_EE)
-#endif /* CONFIG_SPE */
-
-       /* SPE Floating Point Data */
-#ifdef CONFIG_SPE
-       EXCEPTION(0x2030, SPEFloatingPointData, SPEFloatingPointException, EXC_XFER_EE);
-#else
-       EXCEPTION(0x2040, SPEFloatingPointData, UnknownException, EXC_XFER_EE)
-#endif /* CONFIG_SPE */
-
-       /* SPE Floating Point Round */
-       EXCEPTION(0x2050, SPEFloatingPointRound, UnknownException, EXC_XFER_EE)
-
-       /* Performance Monitor */
-       EXCEPTION(0x2060, PerformanceMonitor, UnknownException, EXC_XFER_EE)
-
-/* Check for a single step debug exception while in an exception
- * handler before state has been saved.  This is to catch the case
- * where an instruction that we are trying to single step causes
- * an exception (eg ITLB/DTLB miss) and thus the first instruction of
- * the exception handler generates a single step debug exception.
- *
- * If we get a debug trap on the first instruction of an exception handler,
- * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
- * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
- * The exception handler was handling a non-critical interrupt, so it will
- * save (and later restore) the MSR via SPRN_SRR1, which will still have
- * the MSR_DE bit set.
- */
-       /* Debug Interrupt */
-       START_EXCEPTION(Debug)
-       CRITICAL_EXCEPTION_PROLOG
-
-       /*
-        * If this is a single step or branch-taken exception in an
-        * exception entry sequence, it was probably meant to apply to
-        * the code where the exception occurred (since exception entry
-        * doesn't turn off DE automatically).  We simulate the effect
-        * of turning off DE on entry to an exception handler by turning
-        * off DE in the CSRR1 value and clearing the debug status.
-        */
-       mfspr   r10,SPRN_DBSR           /* check single-step/branch taken */
-       andis.  r10,r10,(DBSR_IC|DBSR_BT)@h
-       beq+    1f
-       andi.   r0,r9,MSR_PR            /* check supervisor */
-       beq     2f                      /* branch if we need to fix it up... */
-
-       /* continue normal handling for a critical exception... */
-1:     mfspr   r4,SPRN_DBSR
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_TEMPLATE(DebugException, 0x2002, \
-               (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
-               NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
-
-       /* here it looks like we got an inappropriate debug exception. */
-2:     rlwinm  r9,r9,0,~MSR_DE         /* clear DE in the CSRR1 value */
-       mtspr   SPRN_DBSR,r10           /* clear the IC/BT debug intr status */
-       /* restore state and get out */
-       lwz     r10,_CCR(r11)
-       lwz     r0,GPR0(r11)
-       lwz     r1,GPR1(r11)
-       mtcrf   0x80,r10
-       mtspr   CSRR0,r12
-       mtspr   CSRR1,r9
-       lwz     r9,GPR9(r11)
-
-       mtspr   SPRG2,r8;               /* SPRG2 only used in criticals */
-       lis     r8,crit_save@ha;
-       lwz     r10,crit_r10@l(r8)
-       lwz     r11,crit_r11@l(r8)
-       mfspr   r8,SPRG2
-
-       rfci
-       b       .
-
-/*
- * Local functions
- */
-       /*
-        * Data TLB exceptions will bail out to this point
-        * if they can't resolve the lightweight TLB fault.
-        */
-data_access:
-       NORMAL_EXCEPTION_PROLOG
-       mfspr   r5,SPRN_ESR             /* Grab the ESR, save it, pass arg3 */
-       stw     r5,_ESR(r11)
-       mfspr   r4,SPRN_DEAR            /* Grab the DEAR, save it, pass arg2 */
-       andis.  r10,r5,(ESR_ILK|ESR_DLK)@h
-       bne     1f
-       EXC_XFER_EE_LITE(0x0300, handle_page_fault)
-1:
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_EE_LITE(0x0300, CacheLockingException)
-
-/*
-
- * Both the instruction and data TLB miss get to this
- * point to load the TLB.
- *     r10 - EA of fault
- *     r11 - TLB (info from Linux PTE)
- *     r12, r13 - available to use
- *     CR5 - results of addr < TASK_SIZE
- *     MAS0, MAS1 - loaded with proper value when we get here
- *     MAS2, MAS3 - will need additional info from Linux PTE
- *     Upon exit, we reload everything and RFI.
- */
-finish_tlb_load:
-       /*
-        * We set execute, because we don't have the granularity to
-        * properly set this at the page level (Linux problem).
-        * Many of these bits are software only.  Bits we don't set
-        * here we (properly should) assume have the appropriate value.
-        */
-
-       mfspr   r12, SPRN_MAS2
-       rlwimi  r12, r11, 26, 27, 31    /* extract WIMGE from pte */
-       mtspr   SPRN_MAS2, r12
-
-       bge     5, 1f
-
-       /* addr > TASK_SIZE */
-       li      r10, (MAS3_UX | MAS3_UW | MAS3_UR)
-       andi.   r13, r11, (_PAGE_USER | _PAGE_HWWRITE | _PAGE_HWEXEC)
-       andi.   r12, r11, _PAGE_USER    /* Test for _PAGE_USER */
-       iseleq  r12, 0, r10
-       and     r10, r12, r13
-       srwi    r12, r10, 1
-       or      r12, r12, r10   /* Copy user perms into supervisor */
-       b       2f
-
-       /* addr <= TASK_SIZE */
-1:     rlwinm  r12, r11, 31, 29, 29    /* Extract _PAGE_HWWRITE into SW */
-       ori     r12, r12, (MAS3_SX | MAS3_SR)
-
-2:     rlwimi  r11, r12, 0, 20, 31     /* Extract RPN from PTE and merge with perms */
-       mtspr   SPRN_MAS3, r11
-       tlbwe
-
-       /* Done...restore registers and get out of here.  */
-       mfspr   r11, SPRG7R
-       mtcr    r11
-       mfspr   r13, SPRG5R
-       mfspr   r12, SPRG4R
-       mfspr   r11, SPRG1
-       mfspr   r10, SPRG0
-       rfi                                     /* Force context change */
-
-#ifdef CONFIG_SPE
-/* Note that the SPE support is closely modeled after the AltiVec
- * support.  Changes to one are likely to be applicable to the
- * other!  */
-load_up_spe:
-/*
- * Disable SPE for the task which had SPE previously,
- * and save its SPE registers in its thread_struct.
- * Enables SPE for use in the kernel on return.
- * On SMP we know the SPE units are free, since we give it up every
- * switch.  -- Kumar
- */
-       mfmsr   r5
-       oris    r5,r5,MSR_SPE@h
-       mtmsr   r5                      /* enable use of SPE now */
-       isync
-/*
- * For SMP, we don't do lazy SPE switching because it just gets too
- * horrendously complex, especially when a task switches from one CPU
- * to another.  Instead we call giveup_spe in switch_to.
- */
-#ifndef CONFIG_SMP
-       lis     r3,last_task_used_spe@ha
-       lwz     r4,last_task_used_spe@l(r3)
-       cmpi    0,r4,0
-       beq     1f
-       addi    r4,r4,THREAD    /* want THREAD of last_task_used_spe */
-       SAVE_32EVR(0,r10,r4)
-       evxor   evr10, evr10, evr10     /* clear out evr10 */
-       evmwumiaa evr10, evr10, evr10   /* evr10 <- ACC = 0 * 0 + ACC */
-       li      r5,THREAD_ACC
-       evstddx evr10, r4, r5           /* save off accumulator */
-       lwz     r5,PT_REGS(r4)
-       lwz     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
-       lis     r10,MSR_SPE@h
-       andc    r4,r4,r10       /* disable SPE for previous task */
-       stw     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
-1:
-#endif /* CONFIG_SMP */
-       /* enable use of SPE after return */
-       oris    r9,r9,MSR_SPE@h
-       mfspr   r5,SPRG3                /* current task's THREAD (phys) */
-       li      r4,1
-       li      r10,THREAD_ACC
-       stw     r4,THREAD_USED_SPE(r5)
-       evlddx  evr4,r10,r5
-       evmra   evr4,evr4
-       REST_32EVR(0,r10,r5)
-#ifndef CONFIG_SMP
-       subi    r4,r5,THREAD
-       stw     r4,last_task_used_spe@l(r3)
-#endif /* CONFIG_SMP */
-       /* restore registers and return */
-2:     REST_4GPRS(3, r11)
-       lwz     r10,_CCR(r11)
-       REST_GPR(1, r11)
-       mtcr    r10
-       lwz     r10,_LINK(r11)
-       mtlr    r10
-       REST_GPR(10, r11)
-       mtspr   SRR1,r9
-       mtspr   SRR0,r12
-       REST_GPR(9, r11)
-       REST_GPR(12, r11)
-       lwz     r11,GPR11(r11)
-       SYNC
-       rfi
-
-
-
-/*
- * SPE unavailable trap from kernel - print a message, but let
- * the task use SPE in the kernel until it returns to user mode.
- */
-KernelSPE:
-       lwz     r3,_MSR(r1)
-       oris    r3,r3,MSR_SPE@h
-       stw     r3,_MSR(r1)     /* enable use of SPE after return */
-       lis     r3,87f@h
-       ori     r3,r3,87f@l
-       mr      r4,r2           /* current */
-       lwz     r5,_NIP(r1)
-       bl      printk
-       b       ret_from_except
-87:    .string "SPE used in kernel  (task=%p, pc=%x)  \n"
-       .align  4,0
-
-#endif /* CONFIG_SPE */
-
-/*
- * Global functions
- */
-
-/*
- * extern void loadcam_entry(unsigned int index)
- *
- * Load TLBCAM[index] entry in to the L2 CAM MMU
- */
-_GLOBAL(loadcam_entry)
-       lis     r4,TLBCAM@ha
-       addi    r4,r4,TLBCAM@l
-       mulli   r5,r3,20
-       add     r3,r5,r4
-       lwz     r4,0(r3)
-       mtspr   SPRN_MAS0,r4
-       lwz     r4,4(r3)
-       mtspr   SPRN_MAS1,r4
-       lwz     r4,8(r3)
-       mtspr   SPRN_MAS2,r4
-       lwz     r4,12(r3)
-       mtspr   SPRN_MAS3,r4
-       tlbwe
-       isync
-       blr
-
-/*
- * extern void giveup_altivec(struct task_struct *prev)
- *
- * The e500 core does not have an AltiVec unit.
- */
-_GLOBAL(giveup_altivec)
-       blr
-
-#ifdef CONFIG_SPE
-/*
- * extern void giveup_spe(struct task_struct *prev)
- *
- */
-_GLOBAL(giveup_spe)
-       mfmsr   r5
-       oris    r5,r5,MSR_SPE@h
-       SYNC
-       mtmsr   r5                      /* enable use of SPE now */
-       isync
-       cmpi    0,r3,0
-       beqlr-                          /* if no previous owner, done */
-       addi    r3,r3,THREAD            /* want THREAD of task */
-       lwz     r5,PT_REGS(r3)
-       cmpi    0,r5,0
-       SAVE_32EVR(0, r4, r3)
-       evxor   evr6, evr6, evr6        /* clear out evr6 */
-       evmwumiaa evr6, evr6, evr6      /* evr6 <- ACC = 0 * 0 + ACC */
-       li      r4,THREAD_ACC
-       evstddx evr6, r4, r3            /* save off accumulator */
-       mfspr   r6,SPRN_SPEFSCR
-       stw     r6,THREAD_SPEFSCR(r3)   /* save spefscr register value */
-       beq     1f
-       lwz     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
-       lis     r3,MSR_SPE@h
-       andc    r4,r4,r3                /* disable SPE for previous task */
-       stw     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
-1:
-#ifndef CONFIG_SMP
-       li      r5,0
-       lis     r4,last_task_used_spe@ha
-       stw     r5,last_task_used_spe@l(r4)
-#endif /* CONFIG_SMP */
-       blr
-#endif /* CONFIG_SPE */
-
-/*
- * extern void giveup_fpu(struct task_struct *prev)
- *
- * The e500 core does not have an FPU.
- */
-_GLOBAL(giveup_fpu)
-       blr
-
-/*
- * extern void abort(void)
- *
- * At present, this routine just applies a system reset.
- */
-_GLOBAL(abort)
-       li      r13,0
-        mtspr   SPRN_DBCR0,r13         /* disable all debug events */
-       mfmsr   r13
-       ori     r13,r13,MSR_DE@l        /* Enable Debug Events */
-       mtmsr   r13
-        mfspr   r13,SPRN_DBCR0
-        lis    r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h
-        mtspr   SPRN_DBCR0,r13
-
-_GLOBAL(set_context)
-
-#ifdef CONFIG_BDI_SWITCH
-       /* Context switch the PTE pointer for the Abatron BDI2000.
-        * The PGDIR is the second parameter.
-        */
-       lis     r5, abatron_pteptrs@h
-       ori     r5, r5, abatron_pteptrs@l
-       stw     r4, 0x4(r5)
-#endif
-       mtspr   SPRN_PID,r3
-       isync                   /* Force context change */
-       blr
-
-/*
- * We put a few things here that have to be page-aligned. This stuff
- * goes at the beginning of the data segment, which is page-aligned.
- */
-       .data
-_GLOBAL(sdata)
-_GLOBAL(empty_zero_page)
-       .space  4096
-_GLOBAL(swapper_pg_dir)
-       .space  4096
-
-       .section .bss
-/* Stack for handling critical exceptions from kernel mode */
-critical_stack_bottom:
-       .space 4096
-critical_stack_top:
-       .previous
-
-/* Stack for handling machine check exceptions from kernel mode */
-mcheck_stack_bottom:
-       .space 4096
-mcheck_stack_top:
-       .previous
-
-/*
- * This area is used for temporarily saving registers during the
- * critical and machine check exception prologs. It must always
- * follow the page aligned allocations, so it starts on a page
- * boundary, ensuring that all crit_save areas are in a single
- * page.
- */
-
-/* crit_save */
-_GLOBAL(crit_save)
-       .space  4
-_GLOBAL(crit_r10)
-       .space  4
-_GLOBAL(crit_r11)
-       .space  4
-_GLOBAL(crit_sprg0)
-       .space  4
-_GLOBAL(crit_sprg1)
-       .space  4
-_GLOBAL(crit_sprg4)
-       .space  4
-_GLOBAL(crit_sprg5)
-       .space  4
-_GLOBAL(crit_sprg7)
-       .space  4
-_GLOBAL(crit_pid)
-       .space  4
-_GLOBAL(crit_srr0)
-       .space  4
-_GLOBAL(crit_srr1)
-       .space  4
-
-/* mcheck_save */
-_GLOBAL(mcheck_save)
-       .space  4
-_GLOBAL(mcheck_r10)
-       .space  4
-_GLOBAL(mcheck_r11)
-       .space  4
-_GLOBAL(mcheck_sprg0)
-       .space  4
-_GLOBAL(mcheck_sprg1)
-       .space  4
-_GLOBAL(mcheck_sprg4)
-       .space  4
-_GLOBAL(mcheck_sprg5)
-       .space  4
-_GLOBAL(mcheck_sprg7)
-       .space  4
-_GLOBAL(mcheck_pid)
-       .space  4
-_GLOBAL(mcheck_srr0)
-       .space  4
-_GLOBAL(mcheck_srr1)
-       .space  4
-_GLOBAL(mcheck_csrr0)
-       .space  4
-_GLOBAL(mcheck_csrr1)
-       .space  4
-
-/*
- * This space gets a copy of optional info passed to us by the bootstrap
- * which is used to pass parameters into the kernel like root=/dev/sda1, etc.
- */
-_GLOBAL(cmd_line)
-       .space  512
-
-/*
- * Room for two PTE pointers, usually the kernel and current user pointers
- * to their respective root page table.
- */
-abatron_pteptrs:
-       .space  8
-
-
index 873199e..81a7241 100644 (file)
@@ -1438,7 +1438,7 @@ _GLOBAL(sys_call_table)
        .long ppc_fadvise64_64
        .long sys_ni_syscall            /* 255 - rtas (used on ppc64) */
        .long sys_ni_syscall            /* 256 reserved for sys_debug_setcontext */
-       .long sys_ni_syscall            /* 257 reserved for vserver */
+       .long sys_vserver
        .long sys_ni_syscall            /* 258 reserved for new sys_remap_file_pages */
        .long sys_ni_syscall            /* 259 reserved for new sys_mbind */
        .long sys_ni_syscall            /* 260 reserved for new sys_get_mempolicy */
@@ -1450,3 +1450,5 @@ _GLOBAL(sys_call_table)
        .long sys_mq_notify
        .long sys_mq_getsetattr
        .long sys_ni_syscall            /* 268 reserved for sys_kexec_load */
+       .long sys_ioprio_set
+       .long sys_ioprio_get            
diff --git a/arch/ppc/kernel/pci-dma.c b/arch/ppc/kernel/pci-dma.c
deleted file mode 100644 (file)
index 63354f6..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2000   Ani Joshi <ajoshi@unixbox.com>
- *
- *
- * Dynamic DMA mapping support.
- *
- * swiped from i386
- *
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-                          dma_addr_t *dma_handle)
-{
-       void *ret;
-       int gfp = GFP_ATOMIC;
-
-       if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
-               gfp |= GFP_DMA;
-
-#ifdef CONFIG_NOT_COHERENT_CACHE
-       ret = consistent_alloc(gfp, size, dma_handle);
-#else
-       ret = (void *)__get_free_pages(gfp, get_order(size));
-#endif
-
-       if (ret != NULL) {
-               memset(ret, 0, size);
-#ifndef CONFIG_NOT_COHERENT_CACHE
-               *dma_handle = virt_to_bus(ret);
-#endif
-       }
-       return ret;
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-                        void *vaddr, dma_addr_t dma_handle)
-{
-#ifdef CONFIG_NOT_COHERENT_CACHE
-       consistent_free(vaddr);
-#else
-       free_pages((unsigned long)vaddr, get_order(size));
-#endif
-}
index 5cf5624..c243674 100644 (file)
@@ -261,6 +261,8 @@ int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 6d1c9c4..7e1dad4 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/utsname.h>
 #include <linux/file.h>
 #include <linux/unistd.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
@@ -229,7 +230,7 @@ int sys_uname(struct old_utsname __user * name)
        int err = -EFAULT;
 
        down_read(&uts_sem);
-       if (name && !copy_to_user(name, &system_utsname, sizeof (*name)))
+       if (name && !copy_to_user(name, vx_new_utsname(), sizeof (*name)))
                err = 0;
        up_read(&uts_sem);
        return err;
@@ -238,6 +239,7 @@ int sys_uname(struct old_utsname __user * name)
 int sys_olduname(struct oldold_utsname __user * name)
 {
        int error;
+       struct new_utsname *ptr;
 
        if (!name)
                return -EFAULT;
@@ -245,15 +247,16 @@ int sys_olduname(struct oldold_utsname __user * name)
                return -EFAULT;
 
        down_read(&uts_sem);
-       error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
+       ptr = vx_new_utsname();
+       error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
        error -= __put_user(0,name->sysname+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
        error -= __put_user(0,name->nodename+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
        error -= __put_user(0,name->release+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
        error -= __put_user(0,name->version+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
        error = __put_user(0,name->machine+__OLD_UTS_LEN);
        up_read(&uts_sem);
 
diff --git a/arch/ppc/kernel/vecemu.c b/arch/ppc/kernel/vecemu.c
deleted file mode 100644 (file)
index 604d094..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Routines to emulate some Altivec/VMX instructions, specifically
- * those that can trap when given denormalized operands in Java mode.
- */
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <asm/ptrace.h>
-#include <asm/processor.h>
-#include <asm/uaccess.h>
-
-/* Functions in vector.S */
-extern void vaddfp(vector128 *dst, vector128 *a, vector128 *b);
-extern void vsubfp(vector128 *dst, vector128 *a, vector128 *b);
-extern void vmaddfp(vector128 *dst, vector128 *a, vector128 *b, vector128 *c);
-extern void vnmsubfp(vector128 *dst, vector128 *a, vector128 *b, vector128 *c);
-extern void vrefp(vector128 *dst, vector128 *src);
-extern void vrsqrtefp(vector128 *dst, vector128 *src);
-extern void vexptep(vector128 *dst, vector128 *src);
-
-static unsigned int exp2s[8] = {
-       0x800000,
-       0x8b95c2,
-       0x9837f0,
-       0xa5fed7,
-       0xb504f3,
-       0xc5672a,
-       0xd744fd,
-       0xeac0c7
-};
-
-/*
- * Computes an estimate of 2^x.  The `s' argument is the 32-bit
- * single-precision floating-point representation of x.
- */
-static unsigned int eexp2(unsigned int s)
-{
-       int exp, pwr;
-       unsigned int mant, frac;
-
-       /* extract exponent field from input */
-       exp = ((s >> 23) & 0xff) - 127;
-       if (exp > 7) {
-               /* check for NaN input */
-               if (exp == 128 && (s & 0x7fffff) != 0)
-                       return s | 0x400000;    /* return QNaN */
-               /* 2^-big = 0, 2^+big = +Inf */
-               return (s & 0x80000000)? 0: 0x7f800000; /* 0 or +Inf */
-       }
-       if (exp < -23)
-               return 0x3f800000;      /* 1.0 */
-
-       /* convert to fixed point integer in 9.23 representation */
-       pwr = (s & 0x7fffff) | 0x800000;
-       if (exp > 0)
-               pwr <<= exp;
-       else
-               pwr >>= -exp;
-       if (s & 0x80000000)
-               pwr = -pwr;
-
-       /* extract integer part, which becomes exponent part of result */
-       exp = (pwr >> 23) + 126;
-       if (exp >= 254)
-               return 0x7f800000;
-       if (exp < -23)
-               return 0;
-
-       /* table lookup on top 3 bits of fraction to get mantissa */
-       mant = exp2s[(pwr >> 20) & 7];
-
-       /* linear interpolation using remaining 20 bits of fraction */
-       asm("mulhwu %0,%1,%2" : "=r" (frac)
-           : "r" (pwr << 12), "r" (0x172b83ff));
-       asm("mulhwu %0,%1,%2" : "=r" (frac) : "r" (frac), "r" (mant));
-       mant += frac;
-
-       if (exp >= 0)
-               return mant + (exp << 23);
-
-       /* denormalized result */
-       exp = -exp;
-       mant += 1 << (exp - 1);
-       return mant >> exp;
-}
-
-/*
- * Computes an estimate of log_2(x).  The `s' argument is the 32-bit
- * single-precision floating-point representation of x.
- */
-static unsigned int elog2(unsigned int s)
-{
-       int exp, mant, lz, frac;
-
-       exp = s & 0x7f800000;
-       mant = s & 0x7fffff;
-       if (exp == 0x7f800000) {        /* Inf or NaN */
-               if (mant != 0)
-                       s |= 0x400000;  /* turn NaN into QNaN */
-               return s;
-       }
-       if ((exp | mant) == 0)          /* +0 or -0 */
-               return 0xff800000;      /* return -Inf */
-
-       if (exp == 0) {
-               /* denormalized */
-               asm("cntlzw %0,%1" : "=r" (lz) : "r" (mant));
-               mant <<= lz - 8;
-               exp = (-118 - lz) << 23;
-       } else {
-               mant |= 0x800000;
-               exp -= 127 << 23;
-       }
-
-       if (mant >= 0xb504f3) {                         /* 2^0.5 * 2^23 */
-               exp |= 0x400000;                        /* 0.5 * 2^23 */
-               asm("mulhwu %0,%1,%2" : "=r" (mant)
-                   : "r" (mant), "r" (0xb504f334));    /* 2^-0.5 * 2^32 */
-       }
-       if (mant >= 0x9837f0) {                         /* 2^0.25 * 2^23 */
-               exp |= 0x200000;                        /* 0.25 * 2^23 */
-               asm("mulhwu %0,%1,%2" : "=r" (mant)
-                   : "r" (mant), "r" (0xd744fccb));    /* 2^-0.25 * 2^32 */
-       }
-       if (mant >= 0x8b95c2) {                         /* 2^0.125 * 2^23 */
-               exp |= 0x100000;                        /* 0.125 * 2^23 */
-               asm("mulhwu %0,%1,%2" : "=r" (mant)
-                   : "r" (mant), "r" (0xeac0c6e8));    /* 2^-0.125 * 2^32 */
-       }
-       if (mant > 0x800000) {                          /* 1.0 * 2^23 */
-               /* calculate (mant - 1) * 1.381097463 */
-               /* 1.381097463 == 0.125 / (2^0.125 - 1) */
-               asm("mulhwu %0,%1,%2" : "=r" (frac)
-                   : "r" ((mant - 0x800000) << 1), "r" (0xb0c7cd3a));
-               exp += frac;
-       }
-       s = exp & 0x80000000;
-       if (exp != 0) {
-               if (s)
-                       exp = -exp;
-               asm("cntlzw %0,%1" : "=r" (lz) : "r" (exp));
-               lz = 8 - lz;
-               if (lz > 0)
-                       exp >>= lz;
-               else if (lz < 0)
-                       exp <<= -lz;
-               s += ((lz + 126) << 23) + exp;
-       }
-       return s;
-}
-
-#define VSCR_SAT       1
-
-static int ctsxs(unsigned int x, int scale, unsigned int *vscrp)
-{
-       int exp, mant;
-
-       exp = (x >> 23) & 0xff;
-       mant = x & 0x7fffff;
-       if (exp == 255 && mant != 0)
-               return 0;               /* NaN -> 0 */
-       exp = exp - 127 + scale;
-       if (exp < 0)
-               return 0;               /* round towards zero */
-       if (exp >= 31) {
-               /* saturate, unless the result would be -2^31 */
-               if (x + (scale << 23) != 0xcf000000)
-                       *vscrp |= VSCR_SAT;
-               return (x & 0x80000000)? 0x80000000: 0x7fffffff;
-       }
-       mant |= 0x800000;
-       mant = (mant << 7) >> (30 - exp);
-       return (x & 0x80000000)? -mant: mant;
-}
-
-static unsigned int ctuxs(unsigned int x, int scale, unsigned int *vscrp)
-{
-       int exp;
-       unsigned int mant;
-
-       exp = (x >> 23) & 0xff;
-       mant = x & 0x7fffff;
-       if (exp == 255 && mant != 0)
-               return 0;               /* NaN -> 0 */
-       exp = exp - 127 + scale;
-       if (exp < 0)
-               return 0;               /* round towards zero */
-       if (x & 0x80000000) {
-               /* negative => saturate to 0 */
-               *vscrp |= VSCR_SAT;
-               return 0;
-       }
-       if (exp >= 32) {
-               /* saturate */
-               *vscrp |= VSCR_SAT;
-               return 0xffffffff;
-       }
-       mant |= 0x800000;
-       mant = (mant << 8) >> (31 - exp);
-       return mant;
-}
-
-/* Round to floating integer, towards 0 */
-static unsigned int rfiz(unsigned int x)
-{
-       int exp;
-
-       exp = ((x >> 23) & 0xff) - 127;
-       if (exp == 128 && (x & 0x7fffff) != 0)
-               return x | 0x400000;    /* NaN -> make it a QNaN */
-       if (exp >= 23)
-               return x;               /* it's an integer already (or Inf) */
-       if (exp < 0)
-               return x & 0x80000000;  /* |x| < 1.0 rounds to 0 */
-       return x & ~(0x7fffff >> exp);
-}
-
-/* Round to floating integer, towards +/- Inf */
-static unsigned int rfii(unsigned int x)
-{
-       int exp, mask;
-
-       exp = ((x >> 23) & 0xff) - 127;
-       if (exp == 128 && (x & 0x7fffff) != 0)
-               return x | 0x400000;    /* NaN -> make it a QNaN */
-       if (exp >= 23)
-               return x;               /* it's an integer already (or Inf) */
-       if ((x & 0x7fffffff) == 0)
-               return x;               /* +/-0 -> +/-0 */
-       if (exp < 0)
-               /* 0 < |x| < 1.0 rounds to +/- 1.0 */
-               return (x & 0x80000000) | 0x3f800000;
-       mask = 0x7fffff >> exp;
-       /* mantissa overflows into exponent - that's OK,
-          it can't overflow into the sign bit */
-       return (x + mask) & ~mask;
-}
-
-/* Round to floating integer, to nearest */
-static unsigned int rfin(unsigned int x)
-{
-       int exp, half;
-
-       exp = ((x >> 23) & 0xff) - 127;
-       if (exp == 128 && (x & 0x7fffff) != 0)
-               return x | 0x400000;    /* NaN -> make it a QNaN */
-       if (exp >= 23)
-               return x;               /* it's an integer already (or Inf) */
-       if (exp < -1)
-               return x & 0x80000000;  /* |x| < 0.5 -> +/-0 */
-       if (exp == -1)
-               /* 0.5 <= |x| < 1.0 rounds to +/- 1.0 */
-               return (x & 0x80000000) | 0x3f800000;
-       half = 0x400000 >> exp;
-       /* add 0.5 to the magnitude and chop off the fraction bits */
-       return (x + half) & ~(0x7fffff >> exp);
-}
-
-int emulate_altivec(struct pt_regs *regs)
-{
-       unsigned int instr, i;
-       unsigned int va, vb, vc, vd;
-       vector128 *vrs;
-
-       if (get_user(instr, (unsigned int __user *) regs->nip))
-               return -EFAULT;
-       if ((instr >> 26) != 4)
-               return -EINVAL;         /* not an altivec instruction */
-       vd = (instr >> 21) & 0x1f;
-       va = (instr >> 16) & 0x1f;
-       vb = (instr >> 11) & 0x1f;
-       vc = (instr >> 6) & 0x1f;
-
-       vrs = current->thread.vr;
-       switch (instr & 0x3f) {
-       case 10:
-               switch (vc) {
-               case 0: /* vaddfp */
-                       vaddfp(&vrs[vd], &vrs[va], &vrs[vb]);
-                       break;
-               case 1: /* vsubfp */
-                       vsubfp(&vrs[vd], &vrs[va], &vrs[vb]);
-                       break;
-               case 4: /* vrefp */
-                       vrefp(&vrs[vd], &vrs[vb]);
-                       break;
-               case 5: /* vrsqrtefp */
-                       vrsqrtefp(&vrs[vd], &vrs[vb]);
-                       break;
-               case 6: /* vexptefp */
-                       for (i = 0; i < 4; ++i)
-                               vrs[vd].u[i] = eexp2(vrs[vb].u[i]);
-                       break;
-               case 7: /* vlogefp */
-                       for (i = 0; i < 4; ++i)
-                               vrs[vd].u[i] = elog2(vrs[vb].u[i]);
-                       break;
-               case 8:         /* vrfin */
-                       for (i = 0; i < 4; ++i)
-                               vrs[vd].u[i] = rfin(vrs[vb].u[i]);
-                       break;
-               case 9:         /* vrfiz */
-                       for (i = 0; i < 4; ++i)
-                               vrs[vd].u[i] = rfiz(vrs[vb].u[i]);
-                       break;
-               case 10:        /* vrfip */
-                       for (i = 0; i < 4; ++i) {
-                               u32 x = vrs[vb].u[i];
-                               x = (x & 0x80000000)? rfiz(x): rfii(x);
-                               vrs[vd].u[i] = x;
-                       }
-                       break;
-               case 11:        /* vrfim */
-                       for (i = 0; i < 4; ++i) {
-                               u32 x = vrs[vb].u[i];
-                               x = (x & 0x80000000)? rfii(x): rfiz(x);
-                               vrs[vd].u[i] = x;
-                       }
-                       break;
-               case 14:        /* vctuxs */
-                       for (i = 0; i < 4; ++i)
-                               vrs[vd].u[i] = ctuxs(vrs[vb].u[i], va,
-                                               &current->thread.vscr.u[3]);
-                       break;
-               case 15:        /* vctsxs */
-                       for (i = 0; i < 4; ++i)
-                               vrs[vd].u[i] = ctsxs(vrs[vb].u[i], va,
-                                               &current->thread.vscr.u[3]);
-                       break;
-               default:
-                       return -EINVAL;
-               }
-               break;
-       case 46:        /* vmaddfp */
-               vmaddfp(&vrs[vd], &vrs[va], &vrs[vb], &vrs[vc]);
-               break;
-       case 47:        /* vnmsubfp */
-               vnmsubfp(&vrs[vd], &vrs[va], &vrs[vb], &vrs[vc]);
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
diff --git a/arch/ppc/lib/rheap.c b/arch/ppc/lib/rheap.c
deleted file mode 100644 (file)
index 1037656..0000000
+++ /dev/null
@@ -1,692 +0,0 @@
-/*
- * arch/ppc/syslib/rheap.c
- *
- * A Remote Heap.  Remote means that we don't touch the memory that the
- * heap points to. Normal heap implementations use the memory they manage
- * to place their list. We cannot do that because the memory we manage may
- * have special properties, for example it is uncachable or of different
- * endianess.
- *
- * Author: Pantelis Antoniou <panto@intracom.gr>
- *
- * 2004 (c) INTRACOM S.A. Greece. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-
-#include <asm/rheap.h>
-
-/*
- * Fixup a list_head, needed when copying lists.  If the pointers fall
- * between s and e, apply the delta.  This assumes that
- * sizeof(struct list_head *) == sizeof(unsigned long *).
- */
-static inline void fixup(unsigned long s, unsigned long e, int d,
-                        struct list_head *l)
-{
-       unsigned long *pp;
-
-       pp = (unsigned long *)&l->next;
-       if (*pp >= s && *pp < e)
-               *pp += d;
-
-       pp = (unsigned long *)&l->prev;
-       if (*pp >= s && *pp < e)
-               *pp += d;
-}
-
-/* Grow the allocated blocks */
-static int grow(rh_info_t * info, int max_blocks)
-{
-       rh_block_t *block, *blk;
-       int i, new_blocks;
-       int delta;
-       unsigned long blks, blke;
-
-       if (max_blocks <= info->max_blocks)
-               return -EINVAL;
-
-       new_blocks = max_blocks - info->max_blocks;
-
-       block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_KERNEL);
-       if (block == NULL)
-               return -ENOMEM;
-
-       if (info->max_blocks > 0) {
-
-               /* copy old block area */
-               memcpy(block, info->block,
-                      sizeof(rh_block_t) * info->max_blocks);
-
-               delta = (char *)block - (char *)info->block;
-
-               /* and fixup list pointers */
-               blks = (unsigned long)info->block;
-               blke = (unsigned long)(info->block + info->max_blocks);
-
-               for (i = 0, blk = block; i < info->max_blocks; i++, blk++)
-                       fixup(blks, blke, delta, &blk->list);
-
-               fixup(blks, blke, delta, &info->empty_list);
-               fixup(blks, blke, delta, &info->free_list);
-               fixup(blks, blke, delta, &info->taken_list);
-
-               /* free the old allocated memory */
-               if ((info->flags & RHIF_STATIC_BLOCK) == 0)
-                       kfree(info->block);
-       }
-
-       info->block = block;
-       info->empty_slots += new_blocks;
-       info->max_blocks = max_blocks;
-       info->flags &= ~RHIF_STATIC_BLOCK;
-
-       /* add all new blocks to the free list */
-       for (i = 0, blk = block + info->max_blocks; i < new_blocks; i++, blk++)
-               list_add(&blk->list, &info->empty_list);
-
-       return 0;
-}
-
-/*
- * Assure at least the required amount of empty slots.  If this function
- * causes a grow in the block area then all pointers kept to the block
- * area are invalid!
- */
-static int assure_empty(rh_info_t * info, int slots)
-{
-       int max_blocks;
-
-       /* This function is not meant to be used to grow uncontrollably */
-       if (slots >= 4)
-               return -EINVAL;
-
-       /* Enough space */
-       if (info->empty_slots >= slots)
-               return 0;
-
-       /* Next 16 sized block */
-       max_blocks = ((info->max_blocks + slots) + 15) & ~15;
-
-       return grow(info, max_blocks);
-}
-
-static rh_block_t *get_slot(rh_info_t * info)
-{
-       rh_block_t *blk;
-
-       /* If no more free slots, and failure to extend. */
-       /* XXX: You should have called assure_empty before */
-       if (info->empty_slots == 0) {
-               printk(KERN_ERR "rh: out of slots; crash is imminent.\n");
-               return NULL;
-       }
-
-       /* Get empty slot to use */
-       blk = list_entry(info->empty_list.next, rh_block_t, list);
-       list_del_init(&blk->list);
-       info->empty_slots--;
-
-       /* Initialize */
-       blk->start = NULL;
-       blk->size = 0;
-       blk->owner = NULL;
-
-       return blk;
-}
-
-static inline void release_slot(rh_info_t * info, rh_block_t * blk)
-{
-       list_add(&blk->list, &info->empty_list);
-       info->empty_slots++;
-}
-
-static void attach_free_block(rh_info_t * info, rh_block_t * blkn)
-{
-       rh_block_t *blk;
-       rh_block_t *before;
-       rh_block_t *after;
-       rh_block_t *next;
-       int size;
-       unsigned long s, e, bs, be;
-       struct list_head *l;
-
-       /* We assume that they are aligned properly */
-       size = blkn->size;
-       s = (unsigned long)blkn->start;
-       e = s + size;
-
-       /* Find the blocks immediately before and after the given one
-        * (if any) */
-       before = NULL;
-       after = NULL;
-       next = NULL;
-
-       list_for_each(l, &info->free_list) {
-               blk = list_entry(l, rh_block_t, list);
-
-               bs = (unsigned long)blk->start;
-               be = bs + blk->size;
-
-               if (next == NULL && s >= bs)
-                       next = blk;
-
-               if (be == s)
-                       before = blk;
-
-               if (e == bs)
-                       after = blk;
-
-               /* If both are not null, break now */
-               if (before != NULL && after != NULL)
-                       break;
-       }
-
-       /* Now check if they are really adjacent */
-       if (before != NULL && s != (unsigned long)before->start + before->size)
-               before = NULL;
-
-       if (after != NULL && e != (unsigned long)after->start)
-               after = NULL;
-
-       /* No coalescing; list insert and return */
-       if (before == NULL && after == NULL) {
-
-               if (next != NULL)
-                       list_add(&blkn->list, &next->list);
-               else
-                       list_add(&blkn->list, &info->free_list);
-
-               return;
-       }
-
-       /* We don't need it anymore */
-       release_slot(info, blkn);
-
-       /* Grow the before block */
-       if (before != NULL && after == NULL) {
-               before->size += size;
-               return;
-       }
-
-       /* Grow the after block backwards */
-       if (before == NULL && after != NULL) {
-               (int8_t *) after->start -= size;
-               after->size += size;
-               return;
-       }
-
-       /* Grow the before block, and release the after block */
-       before->size += size + after->size;
-       list_del(&after->list);
-       release_slot(info, after);
-}
-
-static void attach_taken_block(rh_info_t * info, rh_block_t * blkn)
-{
-       rh_block_t *blk;
-       struct list_head *l;
-
-       /* Find the block immediately before the given one (if any) */
-       list_for_each(l, &info->taken_list) {
-               blk = list_entry(l, rh_block_t, list);
-               if (blk->start > blkn->start) {
-                       list_add_tail(&blkn->list, &blk->list);
-                       return;
-               }
-       }
-
-       list_add_tail(&blkn->list, &info->taken_list);
-}
-
-/*
- * Create a remote heap dynamically.  Note that no memory for the blocks
- * are allocated.  It will upon the first allocation
- */
-rh_info_t *rh_create(unsigned int alignment)
-{
-       rh_info_t *info;
-
-       /* Alignment must be a power of two */
-       if ((alignment & (alignment - 1)) != 0)
-               return ERR_PTR(-EINVAL);
-
-       info = kmalloc(sizeof(*info), GFP_KERNEL);
-       if (info == NULL)
-               return ERR_PTR(-ENOMEM);
-
-       info->alignment = alignment;
-
-       /* Initially everything as empty */
-       info->block = NULL;
-       info->max_blocks = 0;
-       info->empty_slots = 0;
-       info->flags = 0;
-
-       INIT_LIST_HEAD(&info->empty_list);
-       INIT_LIST_HEAD(&info->free_list);
-       INIT_LIST_HEAD(&info->taken_list);
-
-       return info;
-}
-
-/*
- * Destroy a dynamically created remote heap.  Deallocate only if the areas
- * are not static
- */
-void rh_destroy(rh_info_t * info)
-{
-       if ((info->flags & RHIF_STATIC_BLOCK) == 0 && info->block != NULL)
-               kfree(info->block);
-
-       if ((info->flags & RHIF_STATIC_INFO) == 0)
-               kfree(info);
-}
-
-/*
- * Initialize in place a remote heap info block.  This is needed to support
- * operation very early in the startup of the kernel, when it is not yet safe
- * to call kmalloc.
- */
-void rh_init(rh_info_t * info, unsigned int alignment, int max_blocks,
-            rh_block_t * block)
-{
-       int i;
-       rh_block_t *blk;
-
-       /* Alignment must be a power of two */
-       if ((alignment & (alignment - 1)) != 0)
-               return;
-
-       info->alignment = alignment;
-
-       /* Initially everything as empty */
-       info->block = block;
-       info->max_blocks = max_blocks;
-       info->empty_slots = max_blocks;
-       info->flags = RHIF_STATIC_INFO | RHIF_STATIC_BLOCK;
-
-       INIT_LIST_HEAD(&info->empty_list);
-       INIT_LIST_HEAD(&info->free_list);
-       INIT_LIST_HEAD(&info->taken_list);
-
-       /* Add all new blocks to the free list */
-       for (i = 0, blk = block; i < max_blocks; i++, blk++)
-               list_add(&blk->list, &info->empty_list);
-}
-
-/* Attach a free memory region, coalesces regions if adjuscent */
-int rh_attach_region(rh_info_t * info, void *start, int size)
-{
-       rh_block_t *blk;
-       unsigned long s, e, m;
-       int r;
-
-       /* The region must be aligned */
-       s = (unsigned long)start;
-       e = s + size;
-       m = info->alignment - 1;
-
-       /* Round start up */
-       s = (s + m) & ~m;
-
-       /* Round end down */
-       e = e & ~m;
-
-       /* Take final values */
-       start = (void *)s;
-       size = (int)(e - s);
-
-       /* Grow the blocks, if needed */
-       r = assure_empty(info, 1);
-       if (r < 0)
-               return r;
-
-       blk = get_slot(info);
-       blk->start = start;
-       blk->size = size;
-       blk->owner = NULL;
-
-       attach_free_block(info, blk);
-
-       return 0;
-}
-
-/* Detatch given address range, splits free block if needed. */
-void *rh_detach_region(rh_info_t * info, void *start, int size)
-{
-       struct list_head *l;
-       rh_block_t *blk, *newblk;
-       unsigned long s, e, m, bs, be;
-
-       /* Validate size */
-       if (size <= 0)
-               return ERR_PTR(-EINVAL);
-
-       /* The region must be aligned */
-       s = (unsigned long)start;
-       e = s + size;
-       m = info->alignment - 1;
-
-       /* Round start up */
-       s = (s + m) & ~m;
-
-       /* Round end down */
-       e = e & ~m;
-
-       if (assure_empty(info, 1) < 0)
-               return ERR_PTR(-ENOMEM);
-
-       blk = NULL;
-       list_for_each(l, &info->free_list) {
-               blk = list_entry(l, rh_block_t, list);
-               /* The range must lie entirely inside one free block */
-               bs = (unsigned long)blk->start;
-               be = (unsigned long)blk->start + blk->size;
-               if (s >= bs && e <= be)
-                       break;
-               blk = NULL;
-       }
-
-       if (blk == NULL)
-               return ERR_PTR(-ENOMEM);
-
-       /* Perfect fit */
-       if (bs == s && be == e) {
-               /* Delete from free list, release slot */
-               list_del(&blk->list);
-               release_slot(info, blk);
-               return (void *)s;
-       }
-
-       /* blk still in free list, with updated start and/or size */
-       if (bs == s || be == e) {
-               if (bs == s)
-                       (int8_t *) blk->start += size;
-               blk->size -= size;
-
-       } else {
-               /* The front free fragment */
-               blk->size = s - bs;
-
-               /* the back free fragment */
-               newblk = get_slot(info);
-               newblk->start = (void *)e;
-               newblk->size = be - e;
-
-               list_add(&newblk->list, &blk->list);
-       }
-
-       return (void *)s;
-}
-
-void *rh_alloc(rh_info_t * info, int size, const char *owner)
-{
-       struct list_head *l;
-       rh_block_t *blk;
-       rh_block_t *newblk;
-       void *start;
-
-       /* Validate size */
-       if (size <= 0)
-               return ERR_PTR(-EINVAL);
-
-       /* Align to configured alignment */
-       size = (size + (info->alignment - 1)) & ~(info->alignment - 1);
-
-       if (assure_empty(info, 1) < 0)
-               return ERR_PTR(-ENOMEM);
-
-       blk = NULL;
-       list_for_each(l, &info->free_list) {
-               blk = list_entry(l, rh_block_t, list);
-               if (size <= blk->size)
-                       break;
-               blk = NULL;
-       }
-
-       if (blk == NULL)
-               return ERR_PTR(-ENOMEM);
-
-       /* Just fits */
-       if (blk->size == size) {
-               /* Move from free list to taken list */
-               list_del(&blk->list);
-               blk->owner = owner;
-               start = blk->start;
-
-               attach_taken_block(info, blk);
-
-               return start;
-       }
-
-       newblk = get_slot(info);
-       newblk->start = blk->start;
-       newblk->size = size;
-       newblk->owner = owner;
-
-       /* blk still in free list, with updated start, size */
-       (int8_t *) blk->start += size;
-       blk->size -= size;
-
-       start = newblk->start;
-
-       attach_taken_block(info, newblk);
-
-       return start;
-}
-
-/* allocate at precisely the given address */
-void *rh_alloc_fixed(rh_info_t * info, void *start, int size, const char *owner)
-{
-       struct list_head *l;
-       rh_block_t *blk, *newblk1, *newblk2;
-       unsigned long s, e, m, bs, be;
-
-       /* Validate size */
-       if (size <= 0)
-               return ERR_PTR(-EINVAL);
-
-       /* The region must be aligned */
-       s = (unsigned long)start;
-       e = s + size;
-       m = info->alignment - 1;
-
-       /* Round start up */
-       s = (s + m) & ~m;
-
-       /* Round end down */
-       e = e & ~m;
-
-       if (assure_empty(info, 2) < 0)
-               return ERR_PTR(-ENOMEM);
-
-       blk = NULL;
-       list_for_each(l, &info->free_list) {
-               blk = list_entry(l, rh_block_t, list);
-               /* The range must lie entirely inside one free block */
-               bs = (unsigned long)blk->start;
-               be = (unsigned long)blk->start + blk->size;
-               if (s >= bs && e <= be)
-                       break;
-       }
-
-       if (blk == NULL)
-               return ERR_PTR(-ENOMEM);
-
-       /* Perfect fit */
-       if (bs == s && be == e) {
-               /* Move from free list to taken list */
-               list_del(&blk->list);
-               blk->owner = owner;
-
-               start = blk->start;
-               attach_taken_block(info, blk);
-
-               return start;
-
-       }
-
-       /* blk still in free list, with updated start and/or size */
-       if (bs == s || be == e) {
-               if (bs == s)
-                       (int8_t *) blk->start += size;
-               blk->size -= size;
-
-       } else {
-               /* The front free fragment */
-               blk->size = s - bs;
-
-               /* The back free fragment */
-               newblk2 = get_slot(info);
-               newblk2->start = (void *)e;
-               newblk2->size = be - e;
-
-               list_add(&newblk2->list, &blk->list);
-       }
-
-       newblk1 = get_slot(info);
-       newblk1->start = (void *)s;
-       newblk1->size = e - s;
-       newblk1->owner = owner;
-
-       start = newblk1->start;
-       attach_taken_block(info, newblk1);
-
-       return start;
-}
-
-int rh_free(rh_info_t * info, void *start)
-{
-       rh_block_t *blk, *blk2;
-       struct list_head *l;
-       int size;
-
-       /* Linear search for block */
-       blk = NULL;
-       list_for_each(l, &info->taken_list) {
-               blk2 = list_entry(l, rh_block_t, list);
-               if (start < blk2->start)
-                       break;
-               blk = blk2;
-       }
-
-       if (blk == NULL || start > (blk->start + blk->size))
-               return -EINVAL;
-
-       /* Remove from taken list */
-       list_del(&blk->list);
-
-       /* Get size of freed block */
-       size = blk->size;
-       attach_free_block(info, blk);
-
-       return size;
-}
-
-int rh_get_stats(rh_info_t * info, int what, int max_stats, rh_stats_t * stats)
-{
-       rh_block_t *blk;
-       struct list_head *l;
-       struct list_head *h;
-       int nr;
-
-       switch (what) {
-
-       case RHGS_FREE:
-               h = &info->free_list;
-               break;
-
-       case RHGS_TAKEN:
-               h = &info->taken_list;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       /* Linear search for block */
-       nr = 0;
-       list_for_each(l, h) {
-               blk = list_entry(l, rh_block_t, list);
-               if (stats != NULL && nr < max_stats) {
-                       stats->start = blk->start;
-                       stats->size = blk->size;
-                       stats->owner = blk->owner;
-                       stats++;
-               }
-               nr++;
-       }
-
-       return nr;
-}
-
-int rh_set_owner(rh_info_t * info, void *start, const char *owner)
-{
-       rh_block_t *blk, *blk2;
-       struct list_head *l;
-       int size;
-
-       /* Linear search for block */
-       blk = NULL;
-       list_for_each(l, &info->taken_list) {
-               blk2 = list_entry(l, rh_block_t, list);
-               if (start < blk2->start)
-                       break;
-               blk = blk2;
-       }
-
-       if (blk == NULL || start > (blk->start + blk->size))
-               return -EINVAL;
-
-       blk->owner = owner;
-
-       return size;
-}
-
-void rh_dump(rh_info_t * info)
-{
-       static rh_stats_t st[32];       /* XXX maximum 32 blocks */
-       int maxnr;
-       int i, nr;
-
-       maxnr = sizeof(st) / sizeof(st[0]);
-
-       printk(KERN_INFO
-              "info @0x%p (%d slots empty / %d max)\n",
-              info, info->empty_slots, info->max_blocks);
-
-       printk(KERN_INFO "  Free:\n");
-       nr = rh_get_stats(info, RHGS_FREE, maxnr, st);
-       if (nr > maxnr)
-               nr = maxnr;
-       for (i = 0; i < nr; i++)
-               printk(KERN_INFO
-                      "    0x%p-0x%p (%u)\n",
-                      st[i].start, (int8_t *) st[i].start + st[i].size,
-                      st[i].size);
-       printk(KERN_INFO "\n");
-
-       printk(KERN_INFO "  Taken:\n");
-       nr = rh_get_stats(info, RHGS_TAKEN, maxnr, st);
-       if (nr > maxnr)
-               nr = maxnr;
-       for (i = 0; i < nr; i++)
-               printk(KERN_INFO
-                      "    0x%p-0x%p (%u) %s\n",
-                      st[i].start, (int8_t *) st[i].start + st[i].size,
-                      st[i].size, st[i].owner != NULL ? st[i].owner : "");
-       printk(KERN_INFO "\n");
-}
-
-void rh_dump_blk(rh_info_t * info, rh_block_t * blk)
-{
-       printk(KERN_INFO
-              "blk @0x%p: 0x%p-0x%p (%u)\n",
-              blk, blk->start, (int8_t *) blk->start + blk->size, blk->size);
-}
diff --git a/arch/ppc/mm/cachemap.c b/arch/ppc/mm/cachemap.c
deleted file mode 100644 (file)
index 2033eec..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- *  PowerPC version derived from arch/arm/mm/consistent.c
- *    Copyright (C) 2001 Dan Malek (dmalek@jlc.net)
- *
- *  arch/ppc/mm/cachemap.c
- *
- *  Copyright (C) 2000 Russell King
- *
- * Consistent memory allocators.  Used for DMA devices that want to
- * share uncached memory with the processor core.  The function return
- * is the virtual address and 'dma_handle' is the physical address.
- * Mostly stolen from the ARM port, with some changes for PowerPC.
- *                                             -- Dan
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/swap.h>
-#include <linux/stddef.h>
-#include <linux/vmalloc.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/bootmem.h>
-#include <linux/highmem.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/pgalloc.h>
-#include <asm/prom.h>
-#include <asm/io.h>
-#include <asm/hardirq.h>
-#include <asm/mmu_context.h>
-#include <asm/pgtable.h>
-#include <asm/mmu.h>
-#include <asm/uaccess.h>
-#include <asm/smp.h>
-#include <asm/machdep.h>
-
-int map_page(unsigned long va, phys_addr_t pa, int flags);
-
-/* This function will allocate the requested contiguous pages and
- * map them into the kernel's vmalloc() space.  This is done so we
- * get unique mapping for these pages, outside of the kernel's 1:1
- * virtual:physical mapping.  This is necessary so we can cover large
- * portions of the kernel with single large page TLB entries, and
- * still get unique uncached pages for consistent DMA.
- */
-void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
-{
-       int order, err;
-       struct page *page, *free, *end;
-       phys_addr_t pa;
-       unsigned long flags, offset;
-       struct vm_struct *area = NULL;
-       unsigned long va = 0;
-
-       BUG_ON(in_interrupt());
-
-       /* Only allocate page size areas */
-       size = PAGE_ALIGN(size);
-       order = get_order(size);
-
-       free = page = alloc_pages(gfp, order);
-       if (! page)
-               return NULL;
-
-       pa = page_to_phys(page);
-       *dma_handle = page_to_bus(page);
-       end = page + (1 << order);
-
-       /*
-        * we need to ensure that there are no cachelines in use,
-        * or worse dirty in this area.
-        */
-       invalidate_dcache_range((unsigned long)page_address(page),
-                               (unsigned long)page_address(page) + size);
-
-       /*
-        * alloc_pages() expects the block to be handled as a unit, so
-        * it only sets the page count on the first page.  We set the
-        * counts on each page so they can be freed individually
-        */
-       for (; page < end; page++)
-               set_page_count(page, 1);
-
-
-       /* Allocate some common virtual space to map the new pages*/
-       area = get_vm_area(size, VM_ALLOC);
-       if (! area)
-               goto out;
-
-       va = (unsigned long) area->addr;
-
-       flags = _PAGE_KERNEL | _PAGE_NO_CACHE;
-       
-       for (offset = 0; offset < size; offset += PAGE_SIZE) {
-               err = map_page(va+offset, pa+offset, flags);
-               if (err) {
-                       vfree((void *)va);
-                       va = 0;
-                       goto out;
-               }
-
-               free++;
-       }
-
- out:
-       /* Free pages which weren't mapped */
-       for (; free < end; free++) {
-               __free_page(free);
-       }
-
-       return (void *)va;
-}
-
-/*
- * free page(s) as defined by the above mapping.
- */
-void consistent_free(void *vaddr)
-{
-       BUG_ON(in_interrupt());
-       vfree(vaddr);
-}
-
-/*
- * make an area consistent.
- */
-void consistent_sync(void *vaddr, size_t size, int direction)
-{
-       unsigned long start = (unsigned long)vaddr;
-       unsigned long end   = start + size;
-
-       switch (direction) {
-       case DMA_NONE:
-               BUG();
-       case DMA_FROM_DEVICE:   /* invalidate only */
-               invalidate_dcache_range(start, end);
-               break;
-       case DMA_TO_DEVICE:             /* writeback only */
-               clean_dcache_range(start, end);
-               break;
-       case DMA_BIDIRECTIONAL: /* writeback and invalidate */
-               flush_dcache_range(start, end);
-               break;
-       }
-}
-
-/*
- * consistent_sync_page make a page are consistent. identical
- * to consistent_sync, but takes a struct page instead of a virtual address
- */
-
-void consistent_sync_page(struct page *page, unsigned long offset,
-       size_t size, int direction)
-{
-       unsigned long start;
-
-       start = (unsigned long)page_address(page) + offset;
-       consistent_sync((void *)start, size, direction);
-}
-
-EXPORT_SYMBOL(consistent_sync_page);
index 448e80c..ec0058c 100644 (file)
@@ -648,3 +648,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
        }
 #endif
 }
+
+int page_is_ram (unsigned long pagenr)
+{
+       return 1;
+}
diff --git a/arch/ppc/ocp/Makefile b/arch/ppc/ocp/Makefile
deleted file mode 100644 (file)
index f669ee0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-obj-y          := ocp.o ocp-driver.o ocp-probe.o
-
diff --git a/arch/ppc/ocp/ocp-driver.c b/arch/ppc/ocp/ocp-driver.c
deleted file mode 100644 (file)
index 9f6bb3f..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * FILE NAME: ocp-driver.c
- *
- * BRIEF MODULE DESCRIPTION:
- * driver callback, id matching and registration
- * Based on drivers/pci/pci-driver, Copyright (c) 1997--1999 Martin Mares
- *
- * Maintained by: Armin <akuster@mvista.com>
- *
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
- *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
- *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <asm/ocp.h>
-#include <linux/module.h>
-#include <linux/init.h>
-
-/*
- *  Registration of OCP drivers and handling of hot-pluggable devices.
- */
-
-static int
-ocp_device_probe(struct device *dev)
-{
-       int error = 0;
-       struct ocp_driver *drv;
-       struct ocp_device *ocp_dev;
-
-       drv = to_ocp_driver(dev->driver);
-       ocp_dev = to_ocp_dev(dev);
-
-       if (drv->probe) {
-               error = drv->probe(ocp_dev);
-               DBG("probe return code %d\n", error);
-               if (error >= 0) {
-                       ocp_dev->driver = drv;
-                       error = 0;
-               }
-       }
-       return error;
-}
-
-static int
-ocp_device_remove(struct device *dev)
-{
-       struct ocp_device *ocp_dev = to_ocp_dev(dev);
-
-       if (ocp_dev->driver) {
-               if (ocp_dev->driver->remove)
-                       ocp_dev->driver->remove(ocp_dev);
-               ocp_dev->driver = NULL;
-       }
-       return 0;
-}
-
-static int
-ocp_device_suspend(struct device *dev, u32 state, u32 level)
-{
-       struct ocp_device *ocp_dev = to_ocp_dev(dev);
-
-       int error = 0;
-
-       if (ocp_dev->driver) {
-               if (level == SUSPEND_SAVE_STATE && ocp_dev->driver->save_state)
-                       error = ocp_dev->driver->save_state(ocp_dev, state);
-               else if (level == SUSPEND_POWER_DOWN
-                        && ocp_dev->driver->suspend)
-                       error = ocp_dev->driver->suspend(ocp_dev, state);
-       }
-       return error;
-}
-
-static int
-ocp_device_resume(struct device *dev, u32 level)
-{
-       struct ocp_device *ocp_dev = to_ocp_dev(dev);
-
-       if (ocp_dev->driver) {
-               if (level == RESUME_POWER_ON && ocp_dev->driver->resume)
-                       ocp_dev->driver->resume(ocp_dev);
-       }
-       return 0;
-}
-
-/**
- * ocp_bus_match - Works out whether an OCP device matches any
- * of the IDs listed for a given OCP driver.
- * @dev: the generic device struct for the OCP device
- * @drv: the generic driver struct for the OCP driver
- *
- * Used by a driver to check whether a OCP device present in the
- * system is in its list of supported devices.  Returns 1 for a
- * match, or 0 if there is no match.
- */
-static int
-ocp_bus_match(struct device *dev, struct device_driver *drv)
-{
-       struct ocp_device *ocp_dev = to_ocp_dev(dev);
-       struct ocp_driver *ocp_drv = to_ocp_driver(drv);
-       const struct ocp_device_id *ids = ocp_drv->id_table;
-
-       if (!ids)
-               return 0;
-
-       while (ids->vendor || ids->device) {
-               if ((ids->vendor == OCP_ANY_ID
-                    || ids->vendor == ocp_dev->vendor)
-                   && (ids->device == OCP_ANY_ID
-                       || ids->device == ocp_dev->device)) {
-                       DBG("Bus match -vendor:%x device:%x\n", ids->vendor,
-                           ids->device);
-                       return 1;
-               }
-               ids++;
-       }
-       return 0;
-}
-
-struct bus_type ocp_bus_type = {
-       .name = "ocp",
-       .match = ocp_bus_match,
-};
-
-static int __init
-ocp_driver_init(void)
-{
-       return bus_register(&ocp_bus_type);
-}
-
-postcore_initcall(ocp_driver_init);
-
-/**
- * ocp_register_driver - register a new ocp driver
- * @drv: the driver structure to register
- *
- * Adds the driver structure to the list of registered drivers
- * Returns the number of ocp devices which were claimed by the driver
- * during registration.  The driver remains registered even if the
- * return value is zero.
- */
-int
-ocp_register_driver(struct ocp_driver *drv)
-{
-       int count = 0;
-
-       /* initialize common driver fields */
-       drv->driver.name = drv->name;
-       drv->driver.bus = &ocp_bus_type;
-       drv->driver.probe = ocp_device_probe;
-       drv->driver.resume = ocp_device_resume;
-       drv->driver.suspend = ocp_device_suspend;
-       drv->driver.remove = ocp_device_remove;
-
-       /* register with core */
-       count = driver_register(&drv->driver);
-       return count ? count : 1;
-}
-
-/**
- * ocp_unregister_driver - unregister a ocp driver
- * @drv: the driver structure to unregister
- *
- * Deletes the driver structure from the list of registered OCP drivers,
- * gives it a chance to clean up by calling its remove() function for
- * each device it was responsible for, and marks those devices as
- * driverless.
- */
-
-void
-ocp_unregister_driver(struct ocp_driver *drv)
-{
-       driver_unregister(&drv->driver);
-}
-
-EXPORT_SYMBOL(ocp_register_driver);
-EXPORT_SYMBOL(ocp_unregister_driver);
-EXPORT_SYMBOL(ocp_bus_type);
diff --git a/arch/ppc/ocp/ocp-probe.c b/arch/ppc/ocp/ocp-probe.c
deleted file mode 100644 (file)
index bb4aff7..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * FILE NAME: ocp-probe.c
- *
- * BRIEF MODULE DESCRIPTION:
- * Device scanning & bus set routines
- * Based on drivers/pci/probe, Copyright (c) 1997--1999 Martin Mares
- *
- * Maintained by: Armin <akuster@mvista.com>
- *
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
- *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
- *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <asm/ocp.h>
-
-LIST_HEAD(ocp_devices);
-struct device *ocp_bus;
-
-static struct ocp_device * __devinit
-ocp_setup_dev(struct ocp_def *odef, unsigned int index)
-{
-       struct ocp_device *dev;
-
-       dev = kmalloc(sizeof(*dev), GFP_KERNEL);
-       if (!dev)
-               return NULL;
-       memset(dev, 0, sizeof(*dev));
-
-       dev->vendor = odef->vendor;
-       dev->device = odef->device;
-       dev->num = ocp_get_num(dev->device);
-       dev->paddr = odef->paddr;
-       dev->irq = odef->irq;
-       dev->pm = odef->pm;
-       dev->current_state = 4;
-
-       sprintf(dev->name, "OCP device %04x:%04x", dev->vendor, dev->device);
-
-       DBG("%s %s 0x%lx irq:%d pm:0x%lx \n", dev->slot_name, dev->name,
-           (unsigned long) dev->paddr, dev->irq, dev->pm);
-
-       /* now put in global tree */
-       sprintf(dev->dev.bus_id, "%d", index);
-       dev->dev.parent = ocp_bus;
-       dev->dev.bus = &ocp_bus_type;
-       device_register(&dev->dev);
-
-       return dev;
-}
-
-static struct device * __devinit ocp_alloc_primary_bus(void)
-{
-       struct device *b;
-
-       b = kmalloc(sizeof(struct device), GFP_KERNEL);
-       if (b == NULL)
-               return NULL;
-       memset(b, 0, sizeof(struct device));
-       strcpy(b->bus_id, "ocp");
-
-       device_register(b);
-
-       return b;
-}
-
-void __devinit ocp_setup_devices(struct ocp_def *odef)
-{
-       int index;
-       struct ocp_device *dev;
-
-       if (ocp_bus == NULL)
-               ocp_bus = ocp_alloc_primary_bus();
-       for (index = 0; odef->vendor != OCP_VENDOR_INVALID; ++index, ++odef) {
-               dev = ocp_setup_dev(odef, index);
-               if (dev != NULL)
-                       list_add_tail(&dev->global_list, &ocp_devices);
-       }
-}
-
-extern struct ocp_def core_ocp[];
-
-static int __init
-ocparch_init(void)
-{
-       ocp_setup_devices(core_ocp);
-       return 0;
-}
-
-subsys_initcall(ocparch_init);
-
-EXPORT_SYMBOL(ocp_devices);
diff --git a/arch/ppc/ocp/ocp.c b/arch/ppc/ocp/ocp.c
deleted file mode 100644 (file)
index 8df60d7..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * ocp.c
- *
- *     The is drived from pci.c
- *
- *     Current Maintainer
- *      Armin Kuster akuster@dslextreme.com
- *      Jan, 2002
- *
- *
- *
- * This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
- *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
- *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/list.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <asm/io.h>
-#include <asm/ocp.h>
-#include <asm/errno.h>
-
-/**
- * ocp_get_num - This determines how many OCP devices of a given
- * device are registered
- * @device: OCP device such as HOST, PCI, GPT, UART, OPB, IIC, GPIO, EMAC, ZMII,
- *
- * The routine returns the number that devices which is registered
- */
-unsigned int ocp_get_num(unsigned int device)
-{
-       unsigned int count = 0;
-       struct ocp_device *ocp;
-       struct list_head *ocp_l;
-
-       list_for_each(ocp_l, &ocp_devices) {
-               ocp = list_entry(ocp_l, struct ocp_device, global_list);
-               if (device == ocp->device)
-                       count++;
-       }
-       return count;
-}
-
-/**
- * ocp_get_dev - get ocp driver pointer for ocp device and instance of it
- * @device: OCP device such as PCI, GPT, UART, OPB, IIC, GPIO, EMAC, ZMII
- * @dev_num: ocp device number whos paddr you want
- *
- * The routine returns ocp device pointer
- * in list based on device and instance of that device
- *
- */
-struct ocp_device *
-ocp_get_dev(unsigned int device, int dev_num)
-{
-       struct ocp_device *ocp;
-       struct list_head *ocp_l;
-       int count = 0;
-
-       list_for_each(ocp_l, &ocp_devices) {
-               ocp = list_entry(ocp_l, struct ocp_device, global_list);
-               if (device == ocp->device) {
-                       if (dev_num == count)
-                               return ocp;
-                       count++;
-               }
-       }
-       return NULL;
-}
-
-EXPORT_SYMBOL(ocp_get_dev);
-EXPORT_SYMBOL(ocp_get_num);
-
-#ifdef CONFIG_PM
-int ocp_generic_suspend(struct ocp_device *pdev, u32 state)
-{
-       ocp_force_power_off(pdev);
-       return 0;
-}
-
-int ocp_generic_resume(struct ocp_device *pdev)
-{
-       ocp_force_power_on(pdev);
-}
-
-EXPORT_SYMBOL(ocp_generic_suspend);
-EXPORT_SYMBOL(ocp_generic_resume);
-#endif /* CONFIG_PM */
diff --git a/arch/ppc/platforms/85xx/Kconfig b/arch/ppc/platforms/85xx/Kconfig
deleted file mode 100644 (file)
index e4666df..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-config 85xx
-       bool
-       depends on E500
-       default y
-
-config PPC_INDIRECT_PCI_BE
-       bool
-       depends on 85xx
-       default y
-
-menu "Freescale 85xx options"
-       depends on E500
-
-choice
-       prompt "Machine Type"
-       depends on 85xx
-       default MPC8540_ADS
-
-config MPC8540_ADS
-       bool "Freescale MPC8540 ADS"
-       help
-         This option enables support for the MPC 8540 ADS evaluation board.
-
-config MPC8555_CDS
-       bool "Freescale MPC8555 CDS"
-       help
-         This option enablese support for the MPC8555 CDS evaluation board.
-
-config MPC8560_ADS
-       bool "Freescale MPC8560 ADS"
-       help
-         This option enables support for the MPC 8560 ADS evaluation board.
-
-config SBC8560
-       bool "WindRiver PowerQUICC III SBC8560"
-       help
-         This option enables support for the WindRiver PowerQUICC III 
-         SBC8560 board.
-
-endchoice
-
-# It's often necessary to know the specific 85xx processor type.
-# Fortunately, it is implied (so far) from the board type, so we
-# don't need to ask more redundant questions.
-config MPC8540
-       bool
-       depends on MPC8540_ADS
-       default y
-
-config MPC8555
-       bool
-       depends on MPC8555_CDS
-       default y
-
-config MPC8560
-       bool
-       depends on SBC8560 || MPC8560_ADS
-       default y
-
-config 85xx_PCI2
-       bool "Supprt for 2nd PCI host controller"
-       depends on MPC8555_CDS
-       default y
-
-config FSL_OCP
-       bool
-       depends on 85xx
-       default y
-
-config PPC_GEN550
-       bool
-       depends on MPC8540 || SBC8560 || MPC8555
-       default y
-
-endmenu
diff --git a/arch/ppc/platforms/85xx/Makefile b/arch/ppc/platforms/85xx/Makefile
deleted file mode 100644 (file)
index 673b970..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Makefile for the PowerPC 85xx linux kernel.
-#
-
-obj-$(CONFIG_MPC8540_ADS)      += mpc85xx_ads_common.o mpc8540_ads.o
-obj-$(CONFIG_MPC8555_CDS)      += mpc85xx_cds_common.o
-obj-$(CONFIG_MPC8560_ADS)      += mpc85xx_ads_common.o mpc8560_ads.o
-obj-$(CONFIG_SBC8560)          += sbc85xx.o sbc8560.o
-
-obj-$(CONFIG_MPC8540)          += mpc8540.o
-obj-$(CONFIG_MPC8555)          += mpc8555.o
-obj-$(CONFIG_MPC8560)          += mpc8560.o
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.c b/arch/ppc/platforms/85xx/mpc8540_ads.c
deleted file mode 100644 (file)
index aada7e4..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * arch/ppc/platforms/85xx/mpc8540_ads.c
- *
- * MPC8540ADS board specific routines
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-#include <linux/serial.h>
-#include <linux/tty.h> /* for linux/serial_core.h */
-#include <linux/serial_core.h>
-#include <linux/initrd.h>
-#include <linux/module.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/atomic.h>
-#include <asm/time.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/prom.h>
-#include <asm/open_pic.h>
-#include <asm/bootinfo.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpc85xx.h>
-#include <asm/irq.h>
-#include <asm/immap_85xx.h>
-#include <asm/kgdb.h>
-#include <asm/ocp.h>
-#include <mm/mmu_decl.h>
-
-#include <syslib/ppc85xx_common.h>
-#include <syslib/ppc85xx_setup.h>
-
-struct ocp_gfar_data mpc85xx_tsec1_def = {
-       .interruptTransmit = MPC85xx_IRQ_TSEC1_TX,
-       .interruptError = MPC85xx_IRQ_TSEC1_ERROR,
-       .interruptReceive = MPC85xx_IRQ_TSEC1_RX,
-       .interruptPHY = MPC85xx_IRQ_EXT5,
-       .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
-                       | GFAR_HAS_RMON
-                       | GFAR_HAS_PHY_INTR | GFAR_HAS_COALESCE),
-       .phyid = 0,
-       .phyregidx = 0,
-};
-
-struct ocp_gfar_data mpc85xx_tsec2_def = {
-       .interruptTransmit = MPC85xx_IRQ_TSEC2_TX,
-       .interruptError = MPC85xx_IRQ_TSEC2_ERROR,
-       .interruptReceive = MPC85xx_IRQ_TSEC2_RX,
-       .interruptPHY = MPC85xx_IRQ_EXT5,
-       .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
-                       | GFAR_HAS_RMON
-                       | GFAR_HAS_PHY_INTR | GFAR_HAS_COALESCE),
-       .phyid = 1,
-       .phyregidx = 0,
-};
-
-struct ocp_gfar_data mpc85xx_fec_def = {
-       .interruptTransmit = MPC85xx_IRQ_FEC,
-       .interruptError = MPC85xx_IRQ_FEC,
-       .interruptReceive = MPC85xx_IRQ_FEC,
-       .interruptPHY = MPC85xx_IRQ_EXT5,
-       .flags = 0,
-       .phyid = 3,
-       .phyregidx = 0,
-};
-
-struct ocp_fs_i2c_data mpc85xx_i2c1_def = {
-       .flags = FS_I2C_SEPARATE_DFSRR,
-};
-
-/* ************************************************************************
- *
- * Setup the architecture
- *
- */
-static void __init
-mpc8540ads_setup_arch(void)
-{
-       struct ocp_def *def;
-       struct ocp_gfar_data *einfo;
-       bd_t *binfo = (bd_t *) __res;
-       unsigned int freq;
-
-       /* get the core frequency */
-       freq = binfo->bi_intfreq;
-
-       if (ppc_md.progress)
-               ppc_md.progress("mpc8540ads_setup_arch()", 0);
-
-       /* Set loops_per_jiffy to a half-way reasonable value,
-          for use until calibrate_delay gets called. */
-       loops_per_jiffy = freq / HZ;
-
-#ifdef CONFIG_PCI
-       /* setup PCI host bridges */
-       mpc85xx_setup_hose();
-#endif
-
-#ifdef CONFIG_DUMMY_CONSOLE
-       conswitchp = &dummy_con;
-#endif
-
-#ifdef CONFIG_SERIAL_8250
-       mpc85xx_early_serial_map();
-#endif
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       /* Invalidate the entry we stole earlier the serial ports
-        * should be properly mapped */
-       invalidate_tlbcam_entry(NUM_TLBCAMS - 1);
-#endif
-
-       def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 0);
-       if (def) {
-               einfo = (struct ocp_gfar_data *) def->additions;
-               memcpy(einfo->mac_addr, binfo->bi_enetaddr, 6);
-       }
-
-       def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 1);
-       if (def) {
-               einfo = (struct ocp_gfar_data *) def->additions;
-               memcpy(einfo->mac_addr, binfo->bi_enet1addr, 6);
-       }
-
-       def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 2);
-       if (def) {
-               einfo = (struct ocp_gfar_data *) def->additions;
-               memcpy(einfo->mac_addr, binfo->bi_enet2addr, 6);
-       }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-       else
-#endif
-#ifdef  CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_HDA1;
-#endif
-
-       ocp_for_each_device(mpc85xx_update_paddr_ocp, &(binfo->bi_immr_base));
-}
-
-/* ************************************************************************ */
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-       /* parse_bootinfo must always be called first */
-       parse_bootinfo(find_bootinfo());
-
-       /*
-        * If we were passed in a board information, copy it into the
-        * residual data area.
-        */
-       if (r3) {
-               memcpy((void *) __res, (void *) (r3 + KERNELBASE),
-                      sizeof (bd_t));
-       }
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       {
-               bd_t *binfo = (bd_t *) __res;
-
-               /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
-               settlbcam(NUM_TLBCAMS - 1, binfo->bi_immr_base,
-                         binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0);
-       }
-#endif
-
-#if defined(CONFIG_BLK_DEV_INITRD)
-       /*
-        * If the init RAM disk has been configured in, and there's a valid
-        * starting address for it, set it up.
-        */
-       if (r4) {
-               initrd_start = r4 + KERNELBASE;
-               initrd_end = r5 + KERNELBASE;
-       }
-#endif                         /* CONFIG_BLK_DEV_INITRD */
-
-       /* Copy the kernel command line arguments to a safe place. */
-
-       if (r6) {
-               *(char *) (r7 + KERNELBASE) = 0;
-               strcpy(cmd_line, (char *) (r6 + KERNELBASE));
-       }
-
-       /* setup the PowerPC module struct */
-       ppc_md.setup_arch = mpc8540ads_setup_arch;
-       ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
-
-       ppc_md.init_IRQ = mpc85xx_ads_init_IRQ;
-       ppc_md.get_irq = openpic_get_irq;
-
-       ppc_md.restart = mpc85xx_restart;
-       ppc_md.power_off = mpc85xx_power_off;
-       ppc_md.halt = mpc85xx_halt;
-
-       ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
-
-       ppc_md.time_init = NULL;
-       ppc_md.set_rtc_time = NULL;
-       ppc_md.get_rtc_time = NULL;
-       ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
-
-#if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
-       ppc_md.progress = gen550_progress;
-#endif /* CONFIG_SERIAL_8250 && CONFIG_SERIAL_TEXT_DEBUG */
-
-       if (ppc_md.progress)
-               ppc_md.progress("mpc8540ads_init(): exit", 0);
-
-       return;
-}
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.h b/arch/ppc/platforms/85xx/mpc8540_ads.h
deleted file mode 100644 (file)
index 0d602fc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/ppc/platforms/85xx/mpc8540_ads.h
- *
- * MPC8540ADS board definitions
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#ifndef __MACH_MPC8540ADS_H__
-#define __MACH_MPC8540ADS_H__
-
-#include <linux/config.h>
-#include <linux/initrd.h>
-#include <syslib/ppc85xx_setup.h>
-#include <platforms/85xx/mpc85xx_ads_common.h>
-
-#define SERIAL_PORT_DFNS       \
-       STD_UART_OP(0)          \
-       STD_UART_OP(1)
-
-#endif /* __MACH_MPC8540ADS_H__ */
diff --git a/arch/ppc/platforms/85xx/mpc8555.c b/arch/ppc/platforms/85xx/mpc8555.c
deleted file mode 100644 (file)
index 9427584..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * arch/ppc/platform/85xx/mpc8555.c
- *
- * MPC8555 I/O descriptions
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <asm/mpc85xx.h>
-#include <asm/ocp.h>
-
-/* These should be defined in platform code */
-extern struct ocp_gfar_data mpc85xx_tsec1_def;
-extern struct ocp_gfar_data mpc85xx_tsec2_def;
-extern struct ocp_mpc_i2c_data mpc85xx_i2c1_def;
-
-/* We use offsets for paddr since we do not know at compile time
- * what CCSRBAR is, platform code should fix this up in
- * setup_arch
- *
- * Only the first IRQ is given even if a device has
- * multiple lines associated with ita
- */
-struct ocp_def core_ocp[] = {
-        { .vendor       = OCP_VENDOR_FREESCALE,
-          .function     = OCP_FUNC_IIC,
-          .index        = 0,
-          .paddr        = MPC85xx_IIC1_OFFSET,
-          .irq          = MPC85xx_IRQ_IIC1,
-          .pm           = OCP_CPM_NA,
-         .additions    = &mpc85xx_i2c1_def,
-        },
-        { .vendor       = OCP_VENDOR_FREESCALE,
-          .function     = OCP_FUNC_16550,
-          .index        = 0,
-          .paddr        = MPC85xx_UART0_OFFSET,
-          .irq          = MPC85xx_IRQ_DUART,
-          .pm           = OCP_CPM_NA,
-        },
-        { .vendor       = OCP_VENDOR_FREESCALE,
-          .function     = OCP_FUNC_16550,
-          .index        = 1,
-          .paddr        = MPC85xx_UART1_OFFSET,
-          .irq          = MPC85xx_IRQ_DUART,
-          .pm           = OCP_CPM_NA,
-        },
-        { .vendor       = OCP_VENDOR_FREESCALE,
-          .function     = OCP_FUNC_GFAR,
-          .index        = 0,
-          .paddr        = MPC85xx_ENET1_OFFSET,
-          .irq          = MPC85xx_IRQ_TSEC1_TX,
-          .pm           = OCP_CPM_NA,
-          .additions    = &mpc85xx_tsec1_def,
-        },
-        { .vendor       = OCP_VENDOR_FREESCALE,
-          .function     = OCP_FUNC_GFAR,
-          .index        = 1,
-          .paddr        = MPC85xx_ENET2_OFFSET,
-          .irq          = MPC85xx_IRQ_TSEC2_TX,
-          .pm           = OCP_CPM_NA,
-          .additions    = &mpc85xx_tsec2_def,
-        },
-        { .vendor       = OCP_VENDOR_FREESCALE,
-          .function     = OCP_FUNC_DMA,
-          .index        = 0,
-          .paddr        = MPC85xx_DMA_OFFSET,
-          .irq          = MPC85xx_IRQ_DMA0,
-          .pm           = OCP_CPM_NA,
-        },
-        { .vendor       = OCP_VENDOR_FREESCALE,
-          .function     = OCP_FUNC_PERFMON,
-          .index        = 0,
-          .paddr        = MPC85xx_PERFMON_OFFSET,
-          .irq          = MPC85xx_IRQ_PERFMON,
-          .pm           = OCP_CPM_NA,
-        },
-        { .vendor       = OCP_VENDOR_INVALID
-        }
-};
diff --git a/arch/ppc/platforms/85xx/mpc8555_cds.h b/arch/ppc/platforms/85xx/mpc8555_cds.h
deleted file mode 100644 (file)
index 566e0e1..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * arch/ppc/platforms/mpc8555_cds.h
- *
- * MPC8555CDS board definitions
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#ifndef __MACH_MPC8555CDS_H__
-#define __MACH_MPC8555CDS_H__
-
-#include <linux/config.h>
-#include <linux/serial.h>
-#include <platforms/85xx/mpc85xx_cds_common.h>
-
-#define CPM_MAP_ADDR   (CCSRBAR + MPC85xx_CPM_OFFSET)
-
-#endif /* __MACH_MPC8555CDS_H__ */
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.c b/arch/ppc/platforms/85xx/mpc8560_ads.c
deleted file mode 100644 (file)
index 0cb2c34..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * arch/ppc/platforms/85xx/mpc8560_ads.c
- *
- * MPC8560ADS board specific routines
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-#include <linux/serial.h>
-#include <linux/tty.h> /* for linux/serial_core.h */
-#include <linux/serial_core.h>
-#include <linux/initrd.h>
-#include <linux/module.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/atomic.h>
-#include <asm/time.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/prom.h>
-#include <asm/open_pic.h>
-#include <asm/bootinfo.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpc85xx.h>
-#include <asm/irq.h>
-#include <asm/immap_85xx.h>
-#include <asm/kgdb.h>
-#include <asm/ocp.h>
-#include <asm/cpm2.h>
-#include <mm/mmu_decl.h>
-
-#include <syslib/cpm2_pic.h>
-#include <syslib/ppc85xx_common.h>
-#include <syslib/ppc85xx_setup.h>
-
-extern void cpm2_reset(void);
-
-struct ocp_gfar_data mpc85xx_tsec1_def = {
-        .interruptTransmit = MPC85xx_IRQ_TSEC1_TX,
-        .interruptError = MPC85xx_IRQ_TSEC1_ERROR,
-        .interruptReceive = MPC85xx_IRQ_TSEC1_RX,
-        .interruptPHY = MPC85xx_IRQ_EXT5,
-        .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
-                       | GFAR_HAS_RMON | GFAR_HAS_COALESCE
-                        | GFAR_HAS_PHY_INTR),
-        .phyid = 0,
-        .phyregidx = 0,
-};
-
-struct ocp_gfar_data mpc85xx_tsec2_def = {
-        .interruptTransmit = MPC85xx_IRQ_TSEC2_TX,
-        .interruptError = MPC85xx_IRQ_TSEC2_ERROR,
-        .interruptReceive = MPC85xx_IRQ_TSEC2_RX,
-        .interruptPHY = MPC85xx_IRQ_EXT5,
-        .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
-                       | GFAR_HAS_RMON | GFAR_HAS_COALESCE
-                        | GFAR_HAS_PHY_INTR),
-        .phyid = 1,
-        .phyregidx = 0,
-};
-
-struct ocp_fs_i2c_data mpc85xx_i2c1_def = {
-       .flags = FS_I2C_SEPARATE_DFSRR,
-};
-
-/* ************************************************************************
- *
- * Setup the architecture
- *
- */
-
-static void __init
-mpc8560ads_setup_arch(void)
-{
-       struct ocp_def *def;
-       struct ocp_gfar_data *einfo;
-       bd_t *binfo = (bd_t *) __res;
-       unsigned int freq;
-
-       cpm2_reset();
-
-       /* get the core frequency */
-       freq = binfo->bi_intfreq;
-
-       if (ppc_md.progress)
-               ppc_md.progress("mpc8560ads_setup_arch()", 0);
-
-       /* Set loops_per_jiffy to a half-way reasonable value,
-          for use until calibrate_delay gets called. */
-       loops_per_jiffy = freq / HZ;
-
-#ifdef CONFIG_PCI
-       /* setup PCI host bridges */
-       mpc85xx_setup_hose();
-#endif
-
-       def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 0);
-       if (def) {
-               einfo = (struct ocp_gfar_data *) def->additions;
-               memcpy(einfo->mac_addr, binfo->bi_enetaddr, 6);
-       }
-
-       def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 1);
-       if (def) {
-               einfo = (struct ocp_gfar_data *) def->additions;
-               memcpy(einfo->mac_addr, binfo->bi_enet1addr, 6);
-       }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-       else
-#endif
-#ifdef  CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_HDA1;
-#endif
-
-       ocp_for_each_device(mpc85xx_update_paddr_ocp, &(binfo->bi_immr_base));
-}
-
-static irqreturn_t cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
-{
-       while ((irq = cpm2_get_irq(regs)) >= 0) {
-               ppc_irq_dispatch_handler(regs, irq);
-       }
-       return IRQ_HANDLED;
-}
-
-static void __init
-mpc8560_ads_init_IRQ(void)
-{
-       int i;
-       volatile cpm2_map_t *immap = cpm2_immr;
-
-       /* Setup OpenPIC */
-       mpc85xx_ads_init_IRQ();
-
-       /* disable all CPM interupts */
-       immap->im_intctl.ic_simrh = 0x0;
-       immap->im_intctl.ic_simrl = 0x0;
-
-       for (i = CPM_IRQ_OFFSET; i < (NR_CPM_INTS + CPM_IRQ_OFFSET); i++)
-               irq_desc[i].handler = &cpm2_pic;
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       immap->im_intctl.ic_sicr = 0;
-       immap->im_intctl.ic_scprrh = 0x05309770;
-       immap->im_intctl.ic_scprrl = 0x05309770;
-
-       request_irq(MPC85xx_IRQ_CPM, cpm2_cascade, SA_INTERRUPT, "cpm2_cascade", NULL);
-
-       return;
-}
-
-
-
-/* ************************************************************************ */
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-       /* parse_bootinfo must always be called first */
-       parse_bootinfo(find_bootinfo());
-
-       /*
-        * If we were passed in a board information, copy it into the
-        * residual data area.
-        */
-       if (r3) {
-               memcpy((void *) __res, (void *) (r3 + KERNELBASE),
-                      sizeof (bd_t));
-
-       }
-#if defined(CONFIG_BLK_DEV_INITRD)
-       /*
-        * If the init RAM disk has been configured in, and there's a valid
-        * starting address for it, set it up.
-        */
-       if (r4) {
-               initrd_start = r4 + KERNELBASE;
-               initrd_end = r5 + KERNELBASE;
-       }
-#endif                         /* CONFIG_BLK_DEV_INITRD */
-
-       /* Copy the kernel command line arguments to a safe place. */
-
-       if (r6) {
-               *(char *) (r7 + KERNELBASE) = 0;
-               strcpy(cmd_line, (char *) (r6 + KERNELBASE));
-       }
-
-       /* setup the PowerPC module struct */
-       ppc_md.setup_arch = mpc8560ads_setup_arch;
-       ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
-
-       ppc_md.init_IRQ = mpc8560_ads_init_IRQ;
-       ppc_md.get_irq = openpic_get_irq;
-
-       ppc_md.restart = mpc85xx_restart;
-       ppc_md.power_off = mpc85xx_power_off;
-       ppc_md.halt = mpc85xx_halt;
-
-       ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
-
-       ppc_md.time_init = NULL;
-       ppc_md.set_rtc_time = NULL;
-       ppc_md.get_rtc_time = NULL;
-       ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
-
-       if (ppc_md.progress)
-               ppc_md.progress("mpc8560ads_init(): exit", 0);
-
-       return;
-}
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.h b/arch/ppc/platforms/85xx/mpc8560_ads.h
deleted file mode 100644 (file)
index 7df885d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * arch/ppc/platforms/mpc8560_ads.h
- *
- * MPC8540ADS board definitions
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#ifndef __MACH_MPC8560ADS_H
-#define __MACH_MPC8560ADS_H
-
-#include <linux/config.h>
-#include <syslib/ppc85xx_setup.h>
-#include <platforms/85xx/mpc85xx_ads_common.h>
-
-#define CPM_MAP_ADDR   (CCSRBAR + MPC85xx_CPM_OFFSET)
-#define PHY_INTERRUPT  MPC85xx_IRQ_EXT7
-
-#endif                         /* __MACH_MPC8560ADS_H */
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
deleted file mode 100644 (file)
index c7e53e3..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * arch/ppc/platform/85xx/mpc85xx_cds_common.c
- *
- * MPC85xx CDS board specific routines
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/serial.h>
-#include <linux/module.h>
-#include <linux/root_dev.h>
-#include <linux/initrd.h>
-#include <linux/tty.h>
-#include <linux/serial_core.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/atomic.h>
-#include <asm/time.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/prom.h>
-#include <asm/open_pic.h>
-#include <asm/bootinfo.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpc85xx.h>
-#include <asm/irq.h>
-#include <asm/immap_85xx.h>
-#include <asm/immap_cpm2.h>
-#include <asm/ocp.h>
-#include <asm/kgdb.h>
-
-#include <mm/mmu_decl.h>
-#include <syslib/cpm2_pic.h>
-#include <syslib/ppc85xx_common.h>
-#include <syslib/ppc85xx_setup.h>
-
-
-#ifndef CONFIG_PCI
-unsigned long isa_io_base = 0;
-unsigned long isa_mem_base = 0;
-#endif
-
-extern unsigned long total_memory;      /* in mm/init */
-
-unsigned char __res[sizeof (bd_t)];
-
-static int cds_pci_slot = 2;
-static volatile u8 * cadmus;
-
-/* Internal interrupts are all Level Sensitive, and Positive Polarity */
-
-static u_char mpc85xx_cds_openpic_initsenses[] __initdata = {
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  0: L2 Cache */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  1: ECM */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  2: DDR DRAM */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  3: LBIU */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  4: DMA 0 */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  5: DMA 1 */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  6: DMA 2 */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  7: DMA 3 */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  8: PCI/PCI-X */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal  9: RIO Inbound Port Write Error */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 10: RIO Doorbell Inbound */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 11: RIO Outbound Message */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 12: RIO Inbound Message */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 13: TSEC 0 Transmit */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 14: TSEC 0 Receive */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 15: Unused */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 16: Unused */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 17: Unused */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 18: TSEC 0 Receive/Transmit Error */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 19: TSEC 1 Transmit */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 20: TSEC 1 Receive */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 21: Unused */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 22: Unused */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 23: Unused */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 24: TSEC 1 Receive/Transmit Error */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 25: Fast Ethernet */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 26: DUART */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 27: I2C */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 28: Performance Monitor */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 29: Unused */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 30: CPM */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),        /* Internal 31: Unused */
-#if defined(CONFIG_PCI)
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 0: PCI1 slot */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 1: PCI1 slot */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 2: PCI1 slot */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 3: PCI1 slot */
-#else
-        0x0,                            /* External  0: */
-        0x0,                            /* External  1: */
-        0x0,                            /* External  2: */
-        0x0,                            /* External  3: */
-#endif
-        0x0,                            /* External  4: */
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 5: PHY */
-        0x0,                            /* External  6: */
-        0x0,                            /* External  7: */
-        0x0,                            /* External  8: */
-        0x0,                            /* External  9: */
-        0x0,                            /* External 10: */
-#if defined(CONFIG_85xx_PCI2) && defined(CONFIG_PCI)
-        (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 11: PCI2 slot 0 */
-#else
-        0x0,                            /* External 11: */
-#endif
-};
-
-struct ocp_gfar_data mpc85xx_tsec1_def = {
-        .interruptTransmit = MPC85xx_IRQ_TSEC1_TX,
-        .interruptError = MPC85xx_IRQ_TSEC1_ERROR,
-        .interruptReceive = MPC85xx_IRQ_TSEC1_RX,
-        .interruptPHY = MPC85xx_IRQ_EXT5,
-        .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR |
-                        GFAR_HAS_PHY_INTR),
-        .phyid = 0,
-        .phyregidx = 0,
-};
-
-struct ocp_gfar_data mpc85xx_tsec2_def = {
-        .interruptTransmit = MPC85xx_IRQ_TSEC2_TX,
-        .interruptError = MPC85xx_IRQ_TSEC2_ERROR,
-        .interruptReceive = MPC85xx_IRQ_TSEC2_RX,
-        .interruptPHY = MPC85xx_IRQ_EXT5,
-        .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR |
-                        GFAR_HAS_PHY_INTR),
-        .phyid = 1,
-        .phyregidx = 0,
-};
-
-struct ocp_fs_i2c_data mpc85xx_i2c1_def = {
-       .flags = FS_I2C_SEPARATE_DFSRR,
-};
-
-/* ************************************************************************ */
-int
-mpc85xx_cds_show_cpuinfo(struct seq_file *m)
-{
-        uint pvid, svid, phid1;
-        uint memsize = total_memory;
-        bd_t *binfo = (bd_t *) __res;
-        unsigned int freq;
-
-        /* get the core frequency */
-        freq = binfo->bi_intfreq;
-
-        pvid = mfspr(PVR);
-        svid = mfspr(SVR);
-
-        seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
-       seq_printf(m, "Machine\t\t: CDS (%x)\n", cadmus[CM_VER]);
-        seq_printf(m, "bus freq\t: %u.%.6u MHz\n", freq / 1000000,
-                   freq % 1000000);
-        seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
-        seq_printf(m, "SVR\t\t: 0x%x\n", svid);
-
-        /* Display cpu Pll setting */
-        phid1 = mfspr(HID1);
-        seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
-
-        /* Display the amount of memory */
-        seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
-
-        return 0;
-}
-
-#ifdef CONFIG_CPM2
-static void cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
-{
-       while((irq = cpm2_get_irq(regs)) >= 0)
-       {
-               ppc_irq_dispatch_handler(regs,irq);
-       }
-}
-#endif /* CONFIG_CPM2 */
-
-void __init
-mpc85xx_cds_init_IRQ(void)
-{
-       bd_t *binfo = (bd_t *) __res;
-#ifdef CONFIG_CPM2
-       volatile cpm2_map_t *immap = cpm2_immr;
-       int i;
-#endif
-
-        /* Determine the Physical Address of the OpenPIC regs */
-        phys_addr_t OpenPIC_PAddr = binfo->bi_immr_base + MPC85xx_OPENPIC_OFFSET;
-        OpenPIC_Addr = ioremap(OpenPIC_PAddr, MPC85xx_OPENPIC_SIZE);
-        OpenPIC_InitSenses = mpc85xx_cds_openpic_initsenses;
-        OpenPIC_NumInitSenses = sizeof (mpc85xx_cds_openpic_initsenses);
-
-        /* Skip reserved space and internal sources */
-        openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
-        /* Map PIC IRQs 0-11 */
-        openpic_set_sources(32, 12, OpenPIC_Addr + 0x10000);
-
-        /* we let openpic interrupts starting from an offset, to
-         * leave space for cascading interrupts underneath.
-         */
-        openpic_init(MPC85xx_OPENPIC_IRQ_OFFSET);
-
-#ifdef CONFIG_CPM2
-       /* disable all CPM interupts */
-       immap->im_intctl.ic_simrh = 0x0;
-       immap->im_intctl.ic_simrl = 0x0;
-
-       for (i = CPM_IRQ_OFFSET; i < (NR_CPM_INTS + CPM_IRQ_OFFSET); i++)
-               irq_desc[i].handler = &cpm2_pic;
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       immap->im_intctl.ic_sicr = 0;
-       immap->im_intctl.ic_scprrh = 0x05309770;
-       immap->im_intctl.ic_scprrl = 0x05309770;
-
-       request_irq(MPC85xx_IRQ_CPM, cpm2_cascade, SA_INTERRUPT, "cpm2_cascade", NULL);
-#endif
-
-        return;
-}
-
-#ifdef CONFIG_PCI
-/*
- * interrupt routing
- */
-int
-mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-       struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
-
-       if (!hose->index)
-       {
-               /* Handle PCI1 interrupts */
-               char pci_irq_table[][4] =
-                       /*
-                        *      PCI IDSEL/INTPIN->INTLINE
-                        *        A      B      C      D
-                        */
-
-                       /* Note IRQ assignment for slots is based on which slot the elysium is
-                        * in -- in this setup elysium is in slot #2 (this PIRQA as first
-                        * interrupt on slot */
-               {
-                       { 0, 1, 2, 3 }, /* 16 - PMC */
-                       { 3, 0, 0, 0 }, /* 17 P2P (Tsi320) */
-                       { 0, 1, 2, 3 }, /* 18 - Slot 1 */
-                       { 1, 2, 3, 0 }, /* 19 - Slot 2 */
-                       { 2, 3, 0, 1 }, /* 20 - Slot 3 */
-                       { 3, 0, 1, 2 }, /* 21 - Slot 4 */
-               };
-
-               const long min_idsel = 16, max_idsel = 21, irqs_per_slot = 4;
-               int i, j;
-
-               for (i = 0; i < 6; i++)
-                       for (j = 0; j < 4; j++)
-                               pci_irq_table[i][j] =
-                                       ((pci_irq_table[i][j] + 5 -
-                                         cds_pci_slot) & 0x3) + PIRQ0A;
-
-               return PCI_IRQ_TABLE_LOOKUP;
-       } else {
-               /* Handle PCI2 interrupts (if we have one) */
-               char pci_irq_table[][4] =
-               {
-                       /*
-                        * We only have one slot and one interrupt
-                        * going to PIRQA - PIRQD */
-                       { PIRQ1A, PIRQ1A, PIRQ1A, PIRQ1A }, /* 21 - slot 0 */
-               };
-
-               const long min_idsel = 21, max_idsel = 21, irqs_per_slot = 4;
-
-               return PCI_IRQ_TABLE_LOOKUP;
-       }
-}
-
-#define ARCADIA_HOST_BRIDGE_IDSEL     17
-#define ARCADIA_2ND_BRIDGE_IDSEL     3
-
-int
-mpc85xx_exclude_device(u_char bus, u_char devfn)
-{
-       if (bus == 0 && PCI_SLOT(devfn) == 0)
-               return PCIBIOS_DEVICE_NOT_FOUND;
-#if CONFIG_85xx_PCI2
-       /* With the current code we know PCI2 will be bus 2, however this may
-        * not be guarnteed */
-       if (bus == 2 && PCI_SLOT(devfn) == 0)
-               return PCIBIOS_DEVICE_NOT_FOUND;
-#endif
-       /* We explicitly do not go past the Tundra 320 Bridge */
-       if (bus == 1)
-               return PCIBIOS_DEVICE_NOT_FOUND;
-       if ((bus == 0) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
-               return PCIBIOS_DEVICE_NOT_FOUND;
-       else
-               return PCIBIOS_SUCCESSFUL;
-}
-#endif /* CONFIG_PCI */
-
-/* ************************************************************************
- *
- * Setup the architecture
- *
- */
-static void __init
-mpc85xx_cds_setup_arch(void)
-{
-        struct ocp_def *def;
-        struct ocp_gfar_data *einfo;
-        bd_t *binfo = (bd_t *) __res;
-        unsigned int freq;
-
-        /* get the core frequency */
-        freq = binfo->bi_intfreq;
-
-        printk("mpc85xx_cds_setup_arch\n");
-
-#ifdef CONFIG_CPM2
-       cpm2_reset();
-#endif
-
-       cadmus = ioremap(CADMUS_BASE, CADMUS_SIZE);
-       cds_pci_slot = ((cadmus[CM_CSR] >> 6) & 0x3) + 1;
-       printk("CDS Version = %x in PCI slot %d\n", cadmus[CM_VER], cds_pci_slot);
-
-        /* Set loops_per_jiffy to a half-way reasonable value,
-           for use until calibrate_delay gets called. */
-        loops_per_jiffy = freq / HZ;
-
-#ifdef CONFIG_PCI
-        /* setup PCI host bridges */
-        mpc85xx_setup_hose();
-#endif
-
-#ifdef CONFIG_DUMMY_CONSOLE
-        conswitchp = &dummy_con;
-#endif
-
-#ifdef CONFIG_SERIAL_8250
-        mpc85xx_early_serial_map();
-#endif
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       /* Invalidate the entry we stole earlier the serial ports
-        * should be properly mapped */
-       invalidate_tlbcam_entry(NUM_TLBCAMS - 1);
-#endif
-
-        def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 0);
-        if (def) {
-                einfo = (struct ocp_gfar_data *) def->additions;
-                memcpy(einfo->mac_addr, binfo->bi_enetaddr, 6);
-        }
-
-        def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 1);
-        if (def) {
-                einfo = (struct ocp_gfar_data *) def->additions;
-                memcpy(einfo->mac_addr, binfo->bi_enet1addr, 6);
-        }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-        if (initrd_start)
-                ROOT_DEV = Root_RAM0;
-        else
-#endif
-#ifdef  CONFIG_ROOT_NFS
-                ROOT_DEV = Root_NFS;
-#else
-                ROOT_DEV = Root_HDA1;
-#endif
-
-       ocp_for_each_device(mpc85xx_update_paddr_ocp, &(binfo->bi_immr_base));
-}
-
-/* ************************************************************************ */
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-              unsigned long r6, unsigned long r7)
-{
-        /* parse_bootinfo must always be called first */
-        parse_bootinfo(find_bootinfo());
-
-        /*
-         * If we were passed in a board information, copy it into the
-         * residual data area.
-         */
-        if (r3) {
-                memcpy((void *) __res, (void *) (r3 + KERNELBASE),
-                       sizeof (bd_t));
-
-        }
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       {
-               bd_t *binfo = (bd_t *) __res;
-
-               /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
-               settlbcam(NUM_TLBCAMS - 1, binfo->bi_immr_base,
-                       binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0);
-
-       }
-#endif
-
-#if defined(CONFIG_BLK_DEV_INITRD)
-        /*
-         * If the init RAM disk has been configured in, and there's a valid
-         * starting address for it, set it up.
-         */
-        if (r4) {
-                initrd_start = r4 + KERNELBASE;
-                initrd_end = r5 + KERNELBASE;
-        }
-#endif                          /* CONFIG_BLK_DEV_INITRD */
-
-        /* Copy the kernel command line arguments to a safe place. */
-
-        if (r6) {
-                *(char *) (r7 + KERNELBASE) = 0;
-                strcpy(cmd_line, (char *) (r6 + KERNELBASE));
-        }
-
-        /* setup the PowerPC module struct */
-        ppc_md.setup_arch = mpc85xx_cds_setup_arch;
-        ppc_md.show_cpuinfo = mpc85xx_cds_show_cpuinfo;
-
-        ppc_md.init_IRQ = mpc85xx_cds_init_IRQ;
-        ppc_md.get_irq = openpic_get_irq;
-
-        ppc_md.restart = mpc85xx_restart;
-        ppc_md.power_off = mpc85xx_power_off;
-        ppc_md.halt = mpc85xx_halt;
-
-        ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
-
-        ppc_md.time_init = NULL;
-        ppc_md.set_rtc_time = NULL;
-        ppc_md.get_rtc_time = NULL;
-        ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
-
-#if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
-        ppc_md.progress = gen550_progress;
-#endif /* CONFIG_SERIAL_8250 && CONFIG_SERIAL_TEXT_DEBUG */
-
-        if (ppc_md.progress)
-                ppc_md.progress("mpc85xx_cds_init(): exit", 0);
-
-        return;
-}
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.h b/arch/ppc/platforms/85xx/mpc85xx_cds_common.h
deleted file mode 100644 (file)
index a7290ed..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * arch/ppc/platforms/85xx/mpc85xx_cds_common.h
- *
- * MPC85xx CDS board definitions
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#ifndef __MACH_MPC85XX_CDS_H__
-#define __MACH_MPC85XX_CDS_H__
-
-#include <linux/config.h>
-#include <linux/serial.h>
-#include <asm/ppcboot.h>
-#include <linux/initrd.h>
-#include <syslib/ppc85xx_setup.h>
-
-#define BOARD_CCSRBAR           ((uint)0xe0000000)
-#define CCSRBAR_SIZE            ((uint)1024*1024)
-
-/* CADMUS info */
-#define CADMUS_BASE (0xf8004000)
-#define CADMUS_SIZE (256)
-#define CM_VER (0)
-#define CM_CSR (1)
-#define CM_RST (2)
-
-/* PCI config */
-#define PCI1_CFG_ADDR_OFFSET   (0x8000)
-#define PCI1_CFG_DATA_OFFSET   (0x8004)
-
-#define PCI2_CFG_ADDR_OFFSET   (0x9000)
-#define PCI2_CFG_DATA_OFFSET   (0x9004)
-
-/* PCI interrupt controller */
-#define PIRQ0A                   MPC85xx_IRQ_EXT0
-#define PIRQ0B                   MPC85xx_IRQ_EXT1
-#define PIRQ0C                   MPC85xx_IRQ_EXT2
-#define PIRQ0D                   MPC85xx_IRQ_EXT3
-#define PIRQ1A                   MPC85xx_IRQ_EXT11
-
-/* PCI 1 memory map */
-#define MPC85XX_PCI1_LOWER_IO        0x00000000
-#define MPC85XX_PCI1_UPPER_IO        0x00ffffff
-
-#define MPC85XX_PCI1_LOWER_MEM       0x80000000
-#define MPC85XX_PCI1_UPPER_MEM       0x9fffffff
-
-#define MPC85XX_PCI1_IO_BASE         0xe2000000
-#define MPC85XX_PCI1_MEM_OFFSET      0x00000000
-
-#define MPC85XX_PCI1_IO_SIZE         0x01000000
-
-/* PCI 2 memory map */
-#define MPC85XX_PCI2_LOWER_IO        0x01000000
-#define MPC85XX_PCI2_UPPER_IO        0x01ffffff
-
-#define MPC85XX_PCI2_LOWER_MEM       0xa0000000
-#define MPC85XX_PCI2_UPPER_MEM       0xbfffffff
-
-#define MPC85XX_PCI2_IO_BASE         0xe3000000
-#define MPC85XX_PCI2_MEM_OFFSET      0x00000000
-
-#define MPC85XX_PCI2_IO_SIZE         0x01000000
-
-#define SERIAL_PORT_DFNS               \
-              STD_UART_OP(0)           \
-              STD_UART_OP(1)
-
-#endif /* __MACH_MPC85XX_CDS_H__ */
diff --git a/arch/ppc/platforms/85xx/sbc8560.c b/arch/ppc/platforms/85xx/sbc8560.c
deleted file mode 100644 (file)
index a4a91aa..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * arch/ppc/platforms/85xx/sbc8560.c
- * 
- * Wind River SBC8560 board specific routines
- * 
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- * 
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-#include <linux/serial.h>
-#include <linux/tty.h> /* for linux/serial_core.h */
-#include <linux/serial_core.h>
-#include <linux/initrd.h>
-#include <linux/module.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/atomic.h>
-#include <asm/time.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/prom.h>
-#include <asm/open_pic.h>
-#include <asm/bootinfo.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpc85xx.h>
-#include <asm/irq.h>
-#include <asm/immap_85xx.h>
-#include <asm/kgdb.h>
-#include <asm/ocp.h>
-#include <mm/mmu_decl.h>
-
-#include <syslib/ppc85xx_common.h>
-#include <syslib/ppc85xx_setup.h>
-
-struct ocp_gfar_data mpc85xx_tsec1_def = {
-       .interruptTransmit = MPC85xx_IRQ_TSEC1_TX,
-       .interruptError = MPC85xx_IRQ_TSEC1_ERROR,
-       .interruptReceive = MPC85xx_IRQ_TSEC1_RX,
-       .interruptPHY = MPC85xx_IRQ_EXT6,
-       .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR | GFAR_HAS_PHY_INTR),
-       .phyid = 25,
-       .phyregidx = 0,
-};
-
-struct ocp_gfar_data mpc85xx_tsec2_def = {
-       .interruptTransmit = MPC85xx_IRQ_TSEC2_TX,
-       .interruptError = MPC85xx_IRQ_TSEC2_ERROR,
-       .interruptReceive = MPC85xx_IRQ_TSEC2_RX,
-       .interruptPHY = MPC85xx_IRQ_EXT7,
-       .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR | GFAR_HAS_PHY_INTR),
-       .phyid = 26,
-       .phyregidx = 0,
-};
-
-struct ocp_fs_i2c_data mpc85xx_i2c1_def = {
-       .flags = FS_I2C_SEPARATE_DFSRR,
-};
-
-
-#ifdef CONFIG_SERIAL_8250
-static void __init
-sbc8560_early_serial_map(void)
-{
-        struct uart_port uart_req;
-        /* Setup serial port access */
-        memset(&uart_req, 0, sizeof (uart_req));
-       uart_req.irq = MPC85xx_IRQ_EXT9;
-       uart_req.flags = STD_COM_FLAGS;
-       uart_req.uartclk = BASE_BAUD * 16;
-        uart_req.iotype = SERIAL_IO_MEM;
-        uart_req.mapbase = UARTA_ADDR;
-        uart_req.membase = ioremap(uart_req.mapbase, MPC85xx_UART0_SIZE);
-       uart_req.type = PORT_16650;
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-        gen550_init(0, &uart_req);
-#endif
-        if (early_serial_setup(&uart_req) != 0)
-                printk("Early serial init of port 0 failed\n");
-        /* Assume early_serial_setup() doesn't modify uart_req */
-       uart_req.line = 1;
-        uart_req.mapbase = UARTB_ADDR;
-        uart_req.membase = ioremap(uart_req.mapbase, MPC85xx_UART1_SIZE);
-       uart_req.irq = MPC85xx_IRQ_EXT10;
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-        gen550_init(1, &uart_req);
-#endif
-        if (early_serial_setup(&uart_req) != 0)
-                printk("Early serial init of port 1 failed\n");
-}
-#endif
-
-/* ************************************************************************
- *
- * Setup the architecture
- *
- */
-static void __init
-sbc8560_setup_arch(void)
-{
-       struct ocp_def *def;
-       struct ocp_gfar_data *einfo;
-       bd_t *binfo = (bd_t *) __res;
-       unsigned int freq;
-
-       /* get the core frequency */
-       freq = binfo->bi_intfreq;
-
-       if (ppc_md.progress)
-               ppc_md.progress("sbc8560_setup_arch()", 0);
-
-       /* Set loops_per_jiffy to a half-way reasonable value,
-          for use until calibrate_delay gets called. */
-       loops_per_jiffy = freq / HZ;
-
-#ifdef CONFIG_PCI
-       /* setup PCI host bridges */
-       mpc85xx_setup_hose();
-#endif
-#ifdef CONFIG_DUMMY_CONSOLE
-       conswitchp = &dummy_con;
-#endif
-#ifdef CONFIG_SERIAL_8250
-       sbc8560_early_serial_map();
-#endif
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       /* Invalidate the entry we stole earlier the serial ports
-        * should be properly mapped */ 
-       invalidate_tlbcam_entry(NUM_TLBCAMS - 1);
-#endif
-
-       /* Set up MAC addresses for the Ethernet devices */
-       def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 0);
-       if (def) {
-               einfo = (struct ocp_gfar_data *) def->additions;
-               memcpy(einfo->mac_addr, binfo->bi_enetaddr, 6);
-       }
-
-       def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 1);
-       if (def) {
-               einfo = (struct ocp_gfar_data *) def->additions;
-               memcpy(einfo->mac_addr, binfo->bi_enet1addr, 6);
-       }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-       else
-#endif
-#ifdef  CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_HDA1;
-#endif
-
-       ocp_for_each_device(mpc85xx_update_paddr_ocp, &(binfo->bi_immr_base));
-}
-
-/* ************************************************************************ */
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-       /* parse_bootinfo must always be called first */
-       parse_bootinfo(find_bootinfo());
-
-       /*
-        * If we were passed in a board information, copy it into the
-        * residual data area.
-        */
-       if (r3) {
-               memcpy((void *) __res, (void *) (r3 + KERNELBASE),
-                      sizeof (bd_t));
-       }
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
-       settlbcam(NUM_TLBCAMS - 1, UARTA_ADDR,
-                 UARTA_ADDR, 0x1000, _PAGE_IO, 0);
-#endif
-
-#if defined(CONFIG_BLK_DEV_INITRD)
-       /*
-        * If the init RAM disk has been configured in, and there's a valid
-        * starting address for it, set it up.
-        */
-       if (r4) {
-               initrd_start = r4 + KERNELBASE;
-               initrd_end = r5 + KERNELBASE;
-       }
-#endif                         /* CONFIG_BLK_DEV_INITRD */
-
-       /* Copy the kernel command line arguments to a safe place. */
-
-       if (r6) {
-               *(char *) (r7 + KERNELBASE) = 0;
-               strcpy(cmd_line, (char *) (r6 + KERNELBASE));
-       }
-
-       /* setup the PowerPC module struct */
-       ppc_md.setup_arch = sbc8560_setup_arch;
-       ppc_md.show_cpuinfo = sbc8560_show_cpuinfo;
-
-       ppc_md.init_IRQ = sbc8560_init_IRQ;
-       ppc_md.get_irq = openpic_get_irq;
-
-       ppc_md.restart = mpc85xx_restart;
-       ppc_md.power_off = mpc85xx_power_off;
-       ppc_md.halt = mpc85xx_halt;
-
-       ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
-
-       ppc_md.time_init = NULL;
-       ppc_md.set_rtc_time = NULL;
-       ppc_md.get_rtc_time = NULL;
-       ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
-
-#if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
-       ppc_md.progress = gen550_progress;
-#endif /* CONFIG_SERIAL_8250 && CONFIG_SERIAL_TEXT_DEBUG */
-
-       if (ppc_md.progress)
-               ppc_md.progress("sbc8560_init(): exit", 0);
-}
diff --git a/arch/ppc/platforms/85xx/sbc8560.h b/arch/ppc/platforms/85xx/sbc8560.h
deleted file mode 100644 (file)
index 5e1b00c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * arch/ppc/platforms/85xx/sbc8560.h
- *
- * Wind River SBC8560 board definitions
- *
- * Copyright 2003 Motorola Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-#ifndef __MACH_SBC8560_H__
-#define __MACH_SBC8560_H__
-#include <linux/config.h>
-#include <platforms/85xx/sbc85xx.h>
-
-#define CPM_MAP_ADDR    (CCSRBAR + MPC85xx_CPM_OFFSET)
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE  64
-#else
-#define RS_TABLE_SIZE  2
-#endif
-/* Rate for the 1.8432 Mhz clock for the onboard serial chip */
-#define BASE_BAUD ( 1843200 / 16 )
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_SKIP_TEST)
-#endif
-
-#define STD_SERIAL_PORT_DFNS \
-        { 0, BASE_BAUD, UARTA_ADDR, MPC85xx_IRQ_EXT9, STD_COM_FLAGS, /* ttyS0 */ \
-                iomem_base: (u8 *)UARTA_ADDR,                       \
-                io_type: SERIAL_IO_MEM },                                 \
-        { 0, BASE_BAUD, UARTB_ADDR, MPC85xx_IRQ_EXT10, STD_COM_FLAGS, /* ttyS1 */ \
-                iomem_base: (u8 *)UARTB_ADDR,                       \
-                io_type: SERIAL_IO_MEM },
-#define SERIAL_PORT_DFNS \
-        STD_SERIAL_PORT_DFNS
-#endif /* __MACH_SBC8560_H__ */
diff --git a/arch/ppc/platforms/error_log.c b/arch/ppc/platforms/error_log.c
deleted file mode 100644 (file)
index 4a71e18..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- *  arch/ppc/kernel/error_log.c
- *
- *  Copyright (c) 2000 Tilmann Bitterberg
- *  (tilmann@bitterberg.de)
- *
- *  Error processing of errors found by rtas even-scan routine
- *  which is done with every heartbeat. (chrp_setup.c)
- */
-
-#include <linux/sched.h>
-
-#include <asm/prom.h>
-
-#include "error_log.h"
-
-/* ****************************************************************** */
-/*
- * EVENT-SCAN
- * The whole stuff below here doesn't take any action when it found
- * an error, it just prints as much information as possible and
- * then its up to the user to decide what to do.
- *
- * Returns 0 if no errors were found
- * Returns 1 if there may be more errors
- */
-int ppc_rtas_errorlog_scan(void)
-{
-const char *_errlog_severity[] = {
-#ifdef VERBOSE_ERRORS
-       "No Error\n\t\
-Should require no further information",
-       "Event\n\t\
-This is not really an error, it is an event. I use events\n\t\
-to communicate with RTAS back and forth.",
-       "Warning\n\t\
-Indicates a non-state-losing error, either fully recovered\n\t\
-by RTAS or not needing recovery. Ignore it.",
-       "Error sync\n\t\
-May only be fatal to a certain program or thread. Recovery\n\t\
-and continuation is possible, if I only had a handler for\n\t\
-this. Less serious",
-       "Error\n\t\
-Less serious, but still causing a loss of data and state.\n\t\
-I can't tell you exactly what to do, You have to decide\n\t\
-with help from the target and initiator field, what kind\n\t\
-of further actions may take place.",
-       "Fatal\n\t\
-Represent a permanent hardware failure and I believe this\n\t\
-affects my overall performance and behaviour. I would not\n\t\
-attempt to continue normal operation."
-#else
-       "No Error",
-       "Event",
-       "Warning",
-       "Error sync",
-       "Error",
-       "Fatal"
-#endif /* VERBOSE_ERRORS */
-};
-
-#if 0 /* unused?? */
-const char *_errlog_disposition[] = {
-#ifdef VERBOSE_ERRORS
-       "Fully recovered\n\t\
-There was an error, but it is fully recovered by RTAS.",
-       "Limited recovery\n\t\
-RTAS was able to recover the state of the machine, but some\n\t\
-feature of the machine has been disabled or lost (for example\n\t\
-error checking) or performance may suffer.",
-       "Not recovered\n\t\
-Whether RTAS did not try to recover anything or recovery failed:\n\t\
-HOUSTON, WE HAVE A PROBLEM!"
-#else
-       "Fully recovered",
-       "Limited recovery",
-       "Not recovered"
-#endif /* VERBOSE_ERRORS */
-};
-#endif
-
-const char *_errlog_extended[] = {
-#ifdef VERBOSE_ERRORS
-       "Not present\n\t\
-Sad, the RTAS call didn't return an extended error log.",
-       "Present\n\t\
-The extended log is present and hopefully it contains a lot of\n\t\
-useful information, which leads to the solution of the problem."
-#else
-       "Not present",
-       "Present"
-#endif /* VERBOSE_ERRORS */
-};
-
-const char *_errlog_initiator[] = {
-       "Unknown or not applicable",
-       "CPU",
-       "PCI",
-       "ISA",
-       "Memory",
-       "Power management"
-};
-
-const char *_errlog_target[] = {
-       "Unknown or not applicable",
-       "CPU",
-       "PCI",
-       "ISA",
-       "Memory",
-       "Power management"
-};
-       rtas_error_log error_log;
-       char logdata[1024];
-       int error;
-#if 0 /* unused?? */
-       int retries = 0; /* if HW error, try 10 times */
-#endif
-
-       error = call_rtas ("event-scan", 4, 1, (unsigned long *)&error_log,
-                       INTERNAL_ERROR | EPOW_WARNING,
-                       0, __pa(logdata), 1024);
-
-       if (error == 1) /* no errors found */
-               return 0;
-
-       if (error == -1) {
-               printk(KERN_ERR "Unable to get errors. Do you a favor and throw this box away\n");
-               return 0;
-       }
-       if (error_log.version != 1)
-               printk(KERN_WARNING "Unknown version (%d), please implement me\n",
-                               error_log.version);
-
-       switch (error_log.disposition) {
-               case DISP_FULLY_RECOVERED:
-                       /* there was an error, but everything is fine now */
-                       return 0;
-               case DISP_NOT_RECOVERED:
-                       printk("We have a really serious Problem!\n");
-               case DISP_LIMITED_RECOVERY:
-                       printk("Error classification\n");
-                       printk("Severity  : %s\n",
-                                       ppc_rtas_errorlog_check_severity (error_log));
-                       printk("Initiator : %s\n",
-                                       ppc_rtas_errorlog_check_initiator (error_log));
-                       printk("Target    : %s\n",
-                                       ppc_rtas_errorlog_check_target (error_log));
-                       printk("Type      : %s\n",
-                                       ppc_rtas_errorlog_check_type (error_log));
-                       printk("Ext. log  : %s\n",
-                                       ppc_rtas_errorlog_check_extended (error_log));
-                       if (error_log.extended)
-                               ppc_rtas_errorlog_disect_extended (logdata);
-                       return 1;
-               default:
-                       /* nothing */
-                       break;
-       }
-       return 0;
-}
-/* ****************************************************************** */
-const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log)
-{
-       const char *_errlog_type[] = {
-               "unknown type",
-               "too many tries failed",
-               "TCE error",
-               "RTAS device failed",
-               "target timed out",
-               "parity error on data",                 /* 5 */
-               "parity error on address",
-               "parity error on external cache",
-               "access to invalid address",
-               "uncorrectable ECC error",
-               "corrected ECC error"                   /* 10 */
-       };
-       if (error_log.type == TYPE_EPOW)
-               return "EPOW";
-       if (error_log.type >= TYPE_PMGM_POWER_SW_ON)
-               return "PowerMGM Event (not handled right now)";
-       return _errlog_type[error_log.type];
-}
-
diff --git a/arch/ppc/platforms/error_log.h b/arch/ppc/platforms/error_log.h
deleted file mode 100644 (file)
index b8226ae..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef __ERROR_LOG_H__
-#define __ERROR_LOG_H__
-
-#define VERBOSE_ERRORS         1 /* Maybe I enlarge the kernel too much */
-#undef VERBOSE_ERRORS
-
-/* Event classes */
-/* XXX: Endianess correct? NOW*/
-#define INTERNAL_ERROR         0x80000000 /* set bit 0 */
-#define EPOW_WARNING           0x40000000 /* set bit 1 */
-#define POWERMGM_EVENTS                0x20000000 /* set bit 2 */
-
-/* event-scan returns */
-#define SEVERITY_FATAL         0x5
-#define SEVERITY_ERROR         0x4
-#define SEVERITY_ERROR_SYNC    0x3
-#define SEVERITY_WARNING       0x2
-#define SEVERITY_EVENT         0x1
-#define SEVERITY_NO_ERROR      0x0
-#define DISP_FULLY_RECOVERED   0x0
-#define DISP_LIMITED_RECOVERY  0x1
-#define DISP_NOT_RECOVERED     0x2
-#define PART_PRESENT           0x0
-#define PART_NOT_PRESENT       0x1
-#define INITIATOR_UNKNOWN      0x0
-#define INITIATOR_CPU          0x1
-#define INITIATOR_PCI          0x2
-#define INITIATOR_ISA          0x3
-#define INITIATOR_MEMORY       0x4
-#define INITIATOR_POWERMGM     0x5
-#define TARGET_UNKNOWN         0x0
-#define TARGET_CPU             0x1
-#define TARGET_PCI             0x2
-#define TARGET_ISA             0x3
-#define TARGET_MEMORY          0x4
-#define TARGET_POWERMGM                0x5
-#define TYPE_RETRY             0x01
-#define TYPE_TCE_ERR           0x02
-#define TYPE_INTERN_DEV_FAIL   0x03
-#define TYPE_TIMEOUT           0x04
-#define TYPE_DATA_PARITY       0x05
-#define TYPE_ADDR_PARITY       0x06
-#define TYPE_CACHE_PARITY      0x07
-#define TYPE_ADDR_INVALID      0x08
-#define TYPE_ECC_UNCORR                0x09
-#define TYPE_ECC_CORR          0x0a
-#define TYPE_EPOW              0x40
-/* I don't add PowerMGM events right now, this is a different topic */
-#define TYPE_PMGM_POWER_SW_ON  0x60
-#define TYPE_PMGM_POWER_SW_OFF 0x61
-#define TYPE_PMGM_LID_OPEN     0x62
-#define TYPE_PMGM_LID_CLOSE    0x63
-#define TYPE_PMGM_SLEEP_BTN    0x64
-#define TYPE_PMGM_WAKE_BTN     0x65
-#define TYPE_PMGM_BATTERY_WARN 0x66
-#define TYPE_PMGM_BATTERY_CRIT 0x67
-#define TYPE_PMGM_SWITCH_TO_BAT        0x68
-#define TYPE_PMGM_SWITCH_TO_AC 0x69
-#define TYPE_PMGM_KBD_OR_MOUSE 0x6a
-#define TYPE_PMGM_ENCLOS_OPEN  0x6b
-#define TYPE_PMGM_ENCLOS_CLOSED        0x6c
-#define TYPE_PMGM_RING_INDICATE        0x6d
-#define TYPE_PMGM_LAN_ATTENTION        0x6e
-#define TYPE_PMGM_TIME_ALARM   0x6f
-#define TYPE_PMGM_CONFIG_CHANGE        0x70
-#define TYPE_PMGM_SERVICE_PROC 0x71
-
-typedef struct _rtas_error_log {
-       unsigned long version:8;                /* Architectural version */
-       unsigned long severity:3;               /* Severity level of error */
-       unsigned long disposition:2;            /* Degree of recovery */
-       unsigned long extended:1;               /* extended log present? */
-       unsigned long /* reserved */ :2;        /* Reserved for future use */
-       unsigned long initiator:4;              /* Initiator of event */
-       unsigned long target:4;                 /* Target of failed operation */
-       unsigned long type:8;                   /* General event or error*/
-       unsigned long extended_log_length:32;   /* length in bytes */
-} rtas_error_log;
-
-/* ****************************************************************** */
-#define ppc_rtas_errorlog_check_severity(x) \
-       (_errlog_severity[x.severity])
-#define ppc_rtas_errorlog_check_target(x) \
-       (_errlog_target[x.target])
-#define ppc_rtas_errorlog_check_initiator(x) \
-       (_errlog_initiator[x.initiator])
-#define ppc_rtas_errorlog_check_extended(x) \
-       (_errlog_extended[x.extended])
-#define ppc_rtas_errorlog_disect_extended(x) \
-       do { /* implement me */ } while(0)
-extern const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log);
-extern int ppc_rtas_errorlog_scan(void);
-
-
-#endif /* __ERROR_LOG_H__ */
diff --git a/arch/ppc/platforms/ev64260.c b/arch/ppc/platforms/ev64260.c
deleted file mode 100644 (file)
index 1275889..0000000
+++ /dev/null
@@ -1,893 +0,0 @@
-/*
- * arch/ppc/platforms/ev64260.c
- *
- * Board setup routines for the Marvell/Galileo EV-64260-BP Evaluation Board.
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2001-2003 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-/*
- * The EV-64260-BP port is the result of hard work from many people from
- * many companies.  In particular, employees of Marvell/Galileo, Mission
- * Critical Linux, Xyterra, and MontaVista Software were heavily involved.
- *
- * Note: I have not been able to get *all* PCI slots to work reliably
- *     at 66 MHz.  I recommend setting jumpers J15 & J16 to short pins 1&2
- *     so that 33 MHz is used. --MAG
- * Note: The 750CXe and 7450 are not stable with a 125MHz or 133MHz TCLK/SYSCLK.
- *     At 100MHz, they are solid.
- */
-#include <linux/config.h>
-
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-#include <linux/irq.h>
-#include <linux/fs.h>
-#include <linux/seq_file.h>
-#include <linux/console.h>
-#include <linux/initrd.h>
-#include <linux/root_dev.h>
-#if !defined(CONFIG_SERIAL_MPSC_CONSOLE)
-#include <linux/serial.h>
-#include <linux/tty.h>
-#include <linux/serial_core.h>
-#endif
-#include <asm/bootinfo.h>
-#include <asm/machdep.h>
-#include <asm/mv64x60.h>
-#include <asm/ppcboot.h>
-#include <asm/todc.h>
-#include <asm/time.h>
-#include <asm/ocp.h>
-
-#include <platforms/ev64260.h>
-
-#define BOARD_VENDOR   "Marvell/Galileo"
-#define BOARD_MACHINE  "EV-64260-BP"
-
-/* Set IDE controllers into Native mode? */
-/* XXXX
-#define SET_PCI_IDE_NATIVE
-*/
-
-ulong  ev64260_mem_size = 0;
-bd_t   ppcboot_bd;
-int    ppcboot_bd_valid=0;
-
-static mv64x60_handle_t        bh;
-
-#if !defined(CONFIG_SERIAL_MPSC_CONSOLE)
-extern void gen550_progress(char *, unsigned short);
-extern void gen550_init(int, struct serial_struct *);
-#endif
-
-static const unsigned int cpu_7xx[16] = { /* 7xx & 74xx (but not 745x) */
-       18, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0
-};
-static const unsigned int cpu_745x[2][16] = { /* PLL_EXT 0 & 1 */
-       { 1, 15, 14,  2,  4, 13,  5,  9,  6, 11,  8, 10, 16, 12,  7,  0 },
-       { 0, 30,  0,  2,  0, 26,  0, 18,  0, 22, 20, 24, 28, 32,  0,  0 }
-};
-
-
-TODC_ALLOC();
-
-static int
-ev64260_get_bus_speed(void)
-{
-       int     speed;
-
-       if (ppcboot_bd_valid) {
-               speed = ppcboot_bd.bi_busfreq;
-       }
-       else {
-               speed = 100000000; /* Only 100MHz is stable */
-       }
-
-       return speed;
-}
-
-static int
-ev64260_get_cpu_speed(void)
-{
-       unsigned long   pvr, hid1, pll_ext;
-
-       pvr = PVR_VER(mfspr(PVR));
-
-       if (pvr != PVR_VER(PVR_7450)) {
-               hid1 = mfspr(HID1) >> 28;
-               return ev64260_get_bus_speed() * cpu_7xx[hid1]/2;
-       }
-       else {
-               hid1 = (mfspr(HID1) & 0x0001e000) >> 13;
-               pll_ext = 0; /* No way to read; must get from schematic */
-               return ev64260_get_bus_speed() * cpu_745x[pll_ext][hid1]/2;
-       }
-}
-
-unsigned long __init
-ev64260_find_end_of_memory(void)
-{
-       if(!ppcboot_bd_valid) {
-               return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
-                       MV64x60_TYPE_GT64260A);
-       }
-       return ppcboot_bd.bi_memsize;
-}
-
-#if 0  /* XXXX */
-#ifdef SET_PCI_IDE_NATIVE
-static void __init
-set_pci_native_mode(void)
-{
-       struct pci_dev *dev;
-
-       /* Better way of doing this ??? */
-       pci_for_each_dev(dev) { 
-               int class = dev->class >> 8;
-
-               /* enable pci native mode */
-               if (class == PCI_CLASS_STORAGE_IDE) {
-                       u8 reg;
-
-                       pci_read_config_byte(dev, 0x9, &reg);
-                       if (reg == 0x8a) {
-                               printk("PCI: Enabling PCI IDE native mode on %s\n", dev->slot_name); 
-                               pci_write_config_byte(dev, 0x9,  0x8f);
-
-                               /* let the pci code set this device up after we change it */
-                               pci_setup_device(dev); 
-                       } else if (reg != 0x8f) {
-                               printk("PCI: IDE chip in unknown mode 0x%02x on %s", reg, dev->slot_name);
-                       }
-               }
-       }
-}
-#endif
-#endif
-
-static void __init
-ev64260_pci_fixups(void)
-{
-#ifdef SET_PCI_IDE_NATIVE
-       set_pci_native_mode();
-#endif
-}
-
-
-/*
- * Marvell/Galileo EV-64260-BP Evaluation Board PCI interrupt routing.
- * Note: By playing with J8 and JP1-4, you can get 2 IRQ's from the first
- *     PCI bus (in which cast, INTPIN B would be EV64260_PCI_1_IRQ).
- *     This is the most IRQs you can get from one bus with this board, though.
- */
-static int __init
-ev64260_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
-       struct pci_controller   *hose = pci_bus_to_hose(dev->bus->number);
-
-       if (hose->index == 0) {
-               static char pci_irq_table[][4] =
-               /*
-                *      PCI IDSEL/INTPIN->INTLINE 
-                *         A   B   C   D
-                */
-               {
-                       {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 0 */
-                       {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 0 */
-               };
-
-               const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4;
-               return PCI_IRQ_TABLE_LOOKUP;
-       }
-       else {
-               static char pci_irq_table[][4] =
-               /*
-                *      PCI IDSEL/INTPIN->INTLINE 
-                *         A   B   C   D
-                */
-               {
-                       { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 1 */
-                       { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 1 */
-               };
-
-               const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4;
-               return PCI_IRQ_TABLE_LOOKUP;
-       }
-}
-
-static void __init
-ev64260_setup_peripherals(void)
-{
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
-               EV64260_EMB_FLASH_BASE, EV64260_EMB_FLASH_SIZE, 0);
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN,
-               EV64260_EXT_SRAM_BASE, EV64260_EXT_SRAM_SIZE, 0);
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN,
-               EV64260_TODC_BASE, EV64260_TODC_SIZE, 0);
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN,
-               EV64260_UART_BASE, EV64260_UART_SIZE, 0);
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN,
-               EV64260_EXT_FLASH_BASE, EV64260_EXT_FLASH_SIZE, 0);
-
-       TODC_INIT(TODC_TYPE_DS1501, 0, 0,
-                       ioremap(EV64260_TODC_BASE, EV64260_TODC_SIZE), 8);
-
-       mv64x60_clr_bits(&bh, MV64x60_CPU_CONFIG, ((1<<28) | (1<<29)));
-       mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<27));
-
-       if (ev64260_get_bus_speed() > 100000000) {
-               mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<23));
-       }
-
-       mv64x60_set_bits(&bh, MV64x60_PCI0_PCI_DECODE_CNTL,((1<<0) | (1<<3)));
-       mv64x60_set_bits(&bh, MV64x60_PCI1_PCI_DECODE_CNTL,((1<<0) | (1<<3)));
-
-        /*
-         * Enabling of PCI internal-vs-external arbitration
-         * is a platform- and errata-dependent decision.
-         */
-        if (bh.type == MV64x60_TYPE_GT64260A )  {
-                mv64x60_set_bits(&bh, MV64x60_PCI0_ARBITER_CNTL, (1<<31));
-                mv64x60_set_bits(&bh, MV64x60_PCI1_ARBITER_CNTL, (1<<31));
-        }
-
-        mv64x60_set_bits(&bh, MV64x60_CPU_MASTER_CNTL, (1<<9)); /* Only 1 cpu */
-
-       /*
-        * The EV-64260-BP uses several Multi-Purpose Pins (MPP) on the 64260
-        * bridge as interrupt inputs (via the General Purpose Ports (GPP)
-        * register).  Need to route the MPP inputs to the GPP and set the
-        * polarity correctly.
-        *
-        * In MPP Control 2 Register
-        *   MPP 21 -> GPP 21 (DUART channel A intr) bits 20-23 -> 0
-        *   MPP 22 -> GPP 22 (DUART channel B intr) bits 24-27 -> 0
-        */
-       mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_2, (0xf<<20) | (0xf<<24) );
-
-       /*
-        * In MPP Control 3 Register
-        *   MPP 26 -> GPP 26 (RTC INT)         bits  8-11 -> 0
-        *   MPP 27 -> GPP 27 (PCI 0 INTA)      bits 12-15 -> 0
-        *   MPP 29 -> GPP 29 (PCI 1 INTA)      bits 20-23 -> 0
-        */
-       mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_3,
-               (0xf<<8) | (0xf<<12) | (0xf<<20));
-
-#define GPP_EXTERNAL_INTERRUPTS \
-               ((1<<21) | (1<<22) | (1<<26) | (1<<27) | (1<<29))
-       /* DUART & PCI interrupts are inputs */
-       mv64x60_clr_bits(&bh, MV64x60_GPP_IO_CNTL, GPP_EXTERNAL_INTERRUPTS);
-       /* DUART & PCI interrupts are active low */
-       mv64x60_set_bits(&bh, MV64x60_GPP_LEVEL_CNTL, GPP_EXTERNAL_INTERRUPTS);
-
-       /* Clear any pending interrupts for these inputs and enable them. */
-       mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~GPP_EXTERNAL_INTERRUPTS);
-       mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, GPP_EXTERNAL_INTERRUPTS);
-
-       /*
-        * Set MPSC Multiplex RMII
-        * NOTE: ethernet driver modifies bit 0 and 1
-        */
-       mv64x60_write(&bh, GT64260_MPP_SERIAL_PORTS_MULTIPLEX, 0x00001102);
-       return;
-}
-
-
-static void __init
-ev64260_setup_bridge(void)
-{
-       mv64x60_setup_info_t    si;
-       int                     i;
-
-       memset(&si, 0, sizeof(si));
-
-       si.phys_reg_base = CONFIG_MV64X60_NEW_BASE;
-       si.map_irq = ev64260_map_irq;
-
-       si.pci_0.enable_bus = 1;
-       si.pci_0.enumerate_bus = 1;
-       si.pci_0.pci_io.cpu_base = 0xa0000000;
-       si.pci_0.pci_io.pci_base_hi = 0;
-       si.pci_0.pci_io.pci_base_lo = 0;
-       si.pci_0.pci_io.size = 0x01000000;
-       si.pci_0.pci_io.swap = 0x01000000; /* XXXX No swapping */
-       si.pci_0.pci_mem[0].cpu_base = 0x80000000;
-       si.pci_0.pci_mem[0].pci_base_hi = 0;
-       si.pci_0.pci_mem[0].pci_base_lo = 0x80000000;
-       si.pci_0.pci_mem[0].size = 0x10000000;
-       si.pci_0.pci_mem[0].swap = 0x01000000; /* XXXX No swapping */
-       si.pci_0.pci_mem[1].cpu_base = 0;
-       si.pci_0.pci_mem[1].pci_base_hi = 0;
-       si.pci_0.pci_mem[1].pci_base_lo = 0;
-       si.pci_0.pci_mem[1].size = 0;   /* Don't use this window */
-       si.pci_0.pci_mem[1].swap = 0;
-       si.pci_0.pci_mem[2].cpu_base = 0;
-       si.pci_0.pci_mem[2].pci_base_hi = 0;
-       si.pci_0.pci_mem[2].pci_base_lo = 0;
-       si.pci_0.pci_mem[2].size = 0;   /* Don't use this window */
-       si.pci_0.pci_mem[1].swap = 0;
-       si.pci_0.pci_cmd_bits = 0;
-       si.pci_0.latency_timer = 0x8;
-
-       si.pci_1.enable_bus = 1;
-       si.pci_1.enumerate_bus = 1;
-       si.pci_1.pci_io.cpu_base = 0xa1000000;
-       si.pci_1.pci_io.pci_base_hi = 0;
-       si.pci_1.pci_io.pci_base_lo = 0x01000000;
-       si.pci_1.pci_io.size = 0x01000000;
-       si.pci_1.pci_io.swap = 0x01000000; /* XXXX No swapping */
-       si.pci_1.pci_mem[0].cpu_base = 0x90000000;
-       si.pci_1.pci_mem[0].pci_base_hi = 0;
-       si.pci_1.pci_mem[0].pci_base_lo = 0x90000000;
-       si.pci_1.pci_mem[0].size = 0x10000000;
-       si.pci_1.pci_mem[0].swap = 0x01000000; /* XXXX No swapping */
-       si.pci_1.pci_mem[1].cpu_base = 0;
-       si.pci_1.pci_mem[1].pci_base_hi = 0;
-       si.pci_1.pci_mem[1].pci_base_lo = 0;
-       si.pci_1.pci_mem[1].size = 0;   /* Don't use this window */
-       si.pci_1.pci_mem[1].swap = 0;
-       si.pci_1.pci_mem[2].cpu_base = 0;
-       si.pci_1.pci_mem[2].pci_base_hi = 0;
-       si.pci_1.pci_mem[2].pci_base_lo = 0;
-       si.pci_1.pci_mem[2].size = 0;   /* Don't use this window */
-       si.pci_1.pci_mem[1].swap = 0;
-       si.pci_1.pci_cmd_bits = 0;
-       si.pci_1.latency_timer = 0x8;
-       si.pci_1.pci_cmd_bits = 0;
-       si.pci_1.latency_timer = 0x8;
-
-       for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
-               si.cpu_prot_options[i] = 0;
-               si.cpu_snoop_options[i] = GT64260_CPU_SNOOP_WB;
-               si.pci_0.acc_cntl_options[i] =
-                       /* Breaks PCI (especially slot 4)
-                       GT64260_PCI_ACC_CNTL_PREFETCHEN |
-                       */
-                       GT64260_PCI_ACC_CNTL_DREADEN |
-                       GT64260_PCI_ACC_CNTL_RDPREFETCH |
-                       GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |
-                       GT64260_PCI_ACC_CNTL_RDMULPREFETCH |
-                       GT64260_PCI_ACC_CNTL_SWAP_NONE |
-                       GT64260_PCI_ACC_CNTL_MBURST_32_BTYES;
-               si.pci_0.snoop_options[i] = GT64260_PCI_SNOOP_WB;
-               si.pci_1.acc_cntl_options[i] =
-                       /* Breaks PCI (especially slot 4)
-                       GT64260_PCI_ACC_CNTL_PREFETCHEN |
-                       */
-                       GT64260_PCI_ACC_CNTL_DREADEN |
-                       GT64260_PCI_ACC_CNTL_RDPREFETCH |
-                       GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |
-                       GT64260_PCI_ACC_CNTL_RDMULPREFETCH |
-                       GT64260_PCI_ACC_CNTL_SWAP_NONE |
-                       GT64260_PCI_ACC_CNTL_MBURST_32_BTYES;
-               si.pci_1.snoop_options[i] = GT64260_PCI_SNOOP_WB;
-       }
-
-        /* Lookup PCI host bridges */
-        if (mv64x60_init(&bh, &si)) {
-                printk("Bridge initialization failed.\n");
-        }
-
-       return;
-}
-
-#if defined(CONFIG_SERIAL_8250) && !defined(CONFIG_SERIAL_MPSC_CONSOLE)
-static void __init
-ev64260_early_serial_map(void)
-{
-       struct uart_port        port;
-       static char             first_time = 1;
-
-       if (first_time) {
-               memset(&port, 0, sizeof(port));
-
-               port.membase = ioremap(EV64260_SERIAL_0, EV64260_UART_SIZE);
-               port.irq = EV64260_UART_0_IRQ;
-               port.uartclk = BASE_BAUD * 16;
-               port.regshift = 2;
-               port.iotype = SERIAL_IO_MEM;
-               port.flags = STD_COM_FLAGS;
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-               gen550_init(0, &port);
-#endif
-
-               if (early_serial_setup(&port) != 0) {
-                       printk("Early serial init of port 0 failed\n");
-               }
-
-#if 0  /* XXXX */
-               /* Assume early_serial_setup() doesn't modify port */
-               port.membase = ioremap(EV64260_SERIAL_1, EV64260_UART_SIZE);
-               port.irq = EV64260_UART_1_IRQ;
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-               gen550_init(1, &port);
-#endif
-
-               if (early_serial_setup(&port) != 0) {
-                       printk("Early serial init of port 1 failed\n");
-               }
-#endif
-
-               first_time = 0;
-       }
-
-       return;
-}
-#elif defined(CONFIG_SERIAL_MPSC_CONSOLE)
-static void __init
-ev64260_early_serial_map(void)
-{
-#ifdef CONFIG_KGDB
-       static char     first_time = 1;
-
-
-#if defined(CONFIG_KGDB_TTYS0)
-#define KGDB_PORT 0
-#elif defined(CONFIG_KGDB_TTYS1)
-#define KGDB_PORT 1
-#else
-#error "Invalid kgdb_tty port"
-#endif
-
-       if (first_time) {
-               gt_early_mpsc_init(KGDB_PORT, B9600|CS8|CREAD|HUPCL|CLOCAL);
-               first_time = 0;
-       }
-
-       return;
-#endif
-}
-#endif
-
-static void __init
-ev64260_fixup_ocp(void)
-{
-#if defined(CONFIG_SERIAL_MPSC)
-       struct ocp_device       *dev;
-       mv64x60_ocp_mpsc_data_t *dp;
-
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
-                                                               != NULL) {
-               dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-
-               dp->max_idle = 40;      /* XXXX what should this be? */
-               dp->default_baud = EV64260_DEFAULT_BAUD;
-               dp->brg_clk_src = EV64260_MPSC_CLK_SRC;
-               dp->brg_clk_freq = EV64260_MPSC_CLK_FREQ;
-       }
-
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
-                                                               != NULL) {
-               dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-
-               dp->max_idle = 40;      /* XXXX what should this be? */
-               dp->default_baud = 9600;        /* XXXX */
-               dp->brg_clk_src = EV64260_MPSC_CLK_SRC;
-               dp->brg_clk_freq = EV64260_MPSC_CLK_FREQ;
-       }
-#endif
-
-       return;
-}
-
-static void __init
-ev64260_setup_arch(void)
-{
-       if ( ppc_md.progress )
-               ppc_md.progress("ev64260_setup_arch: enter", 0);
-
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               ROOT_DEV = Root_RAM0;
-       else
-#endif
-#ifdef CONFIG_ROOT_NFS
-               ROOT_DEV = Root_NFS;
-#else
-               ROOT_DEV = Root_SDA2;
-#endif
-
-       if ( ppc_md.progress )
-               ppc_md.progress("ev64260_setup_arch: Enabling L2 cache", 0);
-
-       /* Enable L2 and L3 caches (if 745x) */
-       _set_L2CR(_get_L2CR() | L2CR_L2E);
-       _set_L3CR(_get_L3CR() | L3CR_L3E);
-
-       if ( ppc_md.progress )
-               ppc_md.progress("ev64260_setup_arch: Initializing bridge", 0);
-
-       ev64260_setup_bridge();         /* set up PCI bridge(s) */
-       ev64260_setup_peripherals();    /* set up chip selects/GPP/MPP etc */
-
-       if ( ppc_md.progress )
-               ppc_md.progress("ev64260_setup_arch: bridge init complete", 0);
-
-       /* Set OCP values to reflect this board's setup */
-       ev64260_fixup_ocp();
-
-#ifdef CONFIG_DUMMY_CONSOLE
-       conswitchp = &dummy_con;
-#endif
-#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_MPSC_CONSOLE)
-       ev64260_early_serial_map();
-#endif
-
-       printk(BOARD_VENDOR " " BOARD_MACHINE "\n");
-       printk("EV-64260-BP port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
-
-       if ( ppc_md.progress )
-               ppc_md.progress("ev64260_setup_arch: exit", 0);
-
-       return;
-}
-
-static void
-ev64260_reset_board(void *addr)
-{
-       local_irq_disable();
-
-       /* disable and invalidate the L2 cache */
-       _set_L2CR(0);
-       _set_L2CR(0x200000);
-
-       /* flush and disable L1 I/D cache */
-       __asm__ __volatile__
-       ("mfspr   3,1008\n\t"
-        "ori   5,5,0xcc00\n\t"
-        "ori   4,3,0xc00\n\t"
-        "andc  5,3,5\n\t"
-        "sync\n\t"
-        "mtspr 1008,4\n\t"
-        "isync\n\t"
-        "sync\n\t"
-        "mtspr 1008,5\n\t"
-        "isync\n\t"
-        "sync\n\t");
-
-       /* unmap any other random cs's that might overlap with bootcs */
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, 0, 0, 0);
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, 0, 0, 0);
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN, 0, 0, 0);
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN, 0, 0, 0);
-
-       /* map bootrom back in to gt @ reset defaults */
-       mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
-                                               0xff800000, 8*1024*1024, 0);
-
-       /* move gt reg base back to default, setup default pci0 swapping
-        * config... */
-       mv64x60_write(&bh, MV64x60_INTERNAL_SPACE_DECODE,
-               (1<<24) | MV64x60_INTERNAL_SPACE_DEFAULT_ADDR>>20);
-
-       /* NOTE: FROM NOW ON no more GT_REGS accesses.. 0x1 is not mapped
-        * via BAT or MMU, and MSR IR/DR is ON */
-#if 0
-       /* BROKEN... IR/DR is still on !!  won't work!! */
-       /* Set exception prefix high - to the firmware */
-       _nmask_and_or_msr(0, MSR_IP);
-
-       out_8((u_char *)EV64260_BOARD_MODRST_REG, 0x01);
-#else
-       /* SRR0 has system reset vector, SRR1 has default MSR value */
-       /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
-       /* NOTE: assumes reset vector is at 0xfff00100 */
-       __asm__ __volatile__
-       ("mtspr   26, %0\n\t"
-        "li      4,(1<<6)\n\t"
-        "mtspr   27,4\n\t"
-        "rfi\n\t"
-        :: "r" (addr):"r4");
-#endif
-       return;
-}
-
-static void
-ev64260_restart(char *cmd)
-{
-       volatile ulong  i = 10000000;
-
-       ev64260_reset_board((void *)0xfff00100);
-
-       while (i-- > 0);
-       panic("restart failed\n");
-}
-
-static void
-ev64260_halt(void)
-{
-       local_irq_disable();
-       while (1);
-       /* NOTREACHED */
-}
-
-static void
-ev64260_power_off(void)
-{
-       ev64260_halt();
-       /* NOTREACHED */
-}
-
-static int
-ev64260_show_cpuinfo(struct seq_file *m)
-{
-       uint pvid;
-
-       pvid = mfspr(PVR);
-       seq_printf(m, "vendor\t\t: " BOARD_VENDOR "\n");
-       seq_printf(m, "machine\t\t: " BOARD_MACHINE "\n");
-       seq_printf(m, "cpu MHz\t\t: %d\n", ev64260_get_cpu_speed()/1000/1000);
-       seq_printf(m, "bus MHz\t\t: %d\n", ev64260_get_bus_speed()/1000/1000);
-
-       return 0;
-}
-
-/* DS1501 RTC has too much variation to use RTC for calibration */
-static void __init
-ev64260_calibrate_decr(void)
-{
-       ulong freq;
-
-       freq = ev64260_get_bus_speed()/4;
-
-       printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
-              freq/1000000, freq%1000000);
-
-       tb_ticks_per_jiffy = freq / HZ;
-       tb_to_us = mulhwu_scale_factor(freq, 1000000);
-
-       return;
-}
-
-#if 0  /* XXXX */
-#ifdef CONFIG_USE_PPCBOOT
-static void parse_ppcbootinfo(unsigned long r3,
-       unsigned long r4, unsigned long r5,
-       unsigned long r6, unsigned long r7)
-{
-    bd_t *bd=NULL;
-    char *cmdline_start=NULL;
-    int cmdline_len=0;
-
-    if(r3) {
-       if((r3 & 0xf0000000) == 0) r3 += KERNELBASE;
-       if((r3 & 0xf0000000) == KERNELBASE) {
-           bd=(void *)r3;
-
-           /* hack for ppcboot loaders that report freqs in Mhz */
-           if(bd->bi_intfreq<1000000) bd->bi_intfreq*=1000000;
-           if(bd->bi_busfreq<1000000) bd->bi_busfreq*=1000000;
-
-           memcpy(&ppcboot_bd,bd,sizeof(ppcboot_bd));
-           ppcboot_bd_valid=1;
-       }
-    }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-    if(r4 && r5 && r5>r4) {
-       if((r4 & 0xf0000000) == 0) r4 += KERNELBASE;
-       if((r5 & 0xf0000000) == 0) r5 += KERNELBASE;
-       if((r4 & 0xf0000000) == KERNELBASE) {
-           initrd_start=r4;
-           initrd_end=r5;
-           initrd_below_start_ok = 1;
-       }
-    }
-#endif /* CONFIG_BLK_DEV_INITRD */
-
-    if(r6 && r7 && r7>r6) {
-       if((r6 & 0xf0000000) == 0) r6 += KERNELBASE;
-       if((r7 & 0xf0000000) == 0) r7 += KERNELBASE;
-       if((r6 & 0xf0000000) == KERNELBASE) {
-           cmdline_start=(void *)r6;
-           cmdline_len=(r7-r6);
-           strncpy(cmd_line,cmdline_start,cmdline_len);
-       }
-    }
-
-    if(ppcboot_bd_valid) {                     
-       printk("found bd_t @%p\n", bd);
-       printk("memstart=%08lx\n", bd->bi_memstart);
-       printk("memsize=%08lx\n", bd->bi_memsize);
-       printk("enetaddr=%02x%02x%02x%02x%02x%02x\n",
-               bd->bi_enetaddr[0],
-               bd->bi_enetaddr[1],
-               bd->bi_enetaddr[2],
-               bd->bi_enetaddr[3],
-               bd->bi_enetaddr[4],
-               bd->bi_enetaddr[5]
-               );
-       printk("intfreq=%ld\n", bd->bi_intfreq);
-       printk("busfreq=%ld\n", bd->bi_busfreq);
-       printk("baudrate=%ld\n", bd->bi_baudrate);
-    }
-
-#ifdef CONFIG_BLK_DEV_INITRD
-    if(initrd_start) {
-       printk("found initrd @%lx-%lx\n", initrd_start, initrd_end);
-    }
-#endif /* CONFIG_BLK_DEV_INITRD */
-
-    if(cmdline_start && cmdline_len) {
-       printk("found cmdline: '%s'\n", cmd_line);
-    }
-}
-#endif /* USE PPC_BOOT */
-#endif
-
-#if 0  /* XXXX */
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-static int
-ev64260_ide_check_region(ide_ioreg_t from, unsigned int extent)
-{
-        return check_region(from, extent);
-}
-
-static void
-ev64260_ide_request_region(ide_ioreg_t from,
-                        unsigned int extent,
-                        const char *name)
-{
-        request_region(from, extent, name);
-       return;
-}
-
-static void
-ev64260_ide_release_region(ide_ioreg_t from,
-                        unsigned int extent)
-{
-        release_region(from, extent);
-       return;
-}
-
-static void __init
-ev64260_ide_pci_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port,
-                ide_ioreg_t ctrl_port, int *irq)
-{
-       struct pci_dev  *dev;
-#if 1 /* NTL */
-        int i;
-
-       //printk("regs %d to %d @ 0x%x\n", IDE_DATA_OFFSET, IDE_STATUS_OFFSET, data_port);
-        for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-                hw->io_ports[i] = data_port;
-                data_port++;
-        }
-
-       //printk("ctrl %d @ 0x%x\n", IDE_CONTROL_OFFSET, ctrl_port);
-        hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-#endif
-
-       pci_for_each_dev(dev) {
-               if (((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) ||
-                   ((dev->class >> 8) == PCI_CLASS_STORAGE_RAID)) {
-                       hw->irq = dev->irq;
-
-                       if (irq != NULL) {
-                               *irq = dev->irq;
-                       }
-               }
-       }
-
-       return;
-}
-#endif
-#endif
-
-#if !defined(CONFIG_USE_PPCBOOT)
-/*
- * Set BAT 3 to map 0xfb000000 to 0xfc000000 of physical memory space.
- */
-static __inline__ void
-ev64260_set_bat(void)
-{
-       mb();
-       mtspr(DBAT1U, 0xfb0001fe);
-       mtspr(DBAT1L, 0xfb00002a);
-       mb();
-
-       return;
-}
-#endif
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-static void __init
-ev64260_map_io(void)
-{
-       io_block_mapping(0xfb000000, 0xfb000000, 0x01000000, _PAGE_IO);
-}
-#endif
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
-       extern int      initrd_below_start_ok;
-
-       initrd_start=initrd_end=0;
-       initrd_below_start_ok=0;
-#endif /* CONFIG_BLK_DEV_INITRD */
-
-       ppcboot_bd_valid=0;
-       memset(&ppcboot_bd,0,sizeof(ppcboot_bd));
-
-#ifdef CONFIG_USE_PPCBOOT
-       parse_ppcbootinfo(r3, r4, r5, r6, r7);
-#else
-       parse_bootinfo(find_bootinfo());
-#endif
-
-       isa_mem_base = 0;
-       isa_io_base = 0xa0000000;       /* XXXX */
-       pci_dram_offset = 0x80000000;   /* XXXX */
-
-       loops_per_jiffy = ev64260_get_cpu_speed() / HZ;
-
-       ppc_md.setup_arch = ev64260_setup_arch;
-       ppc_md.show_cpuinfo = ev64260_show_cpuinfo;
-       ppc_md.init_IRQ = gt64260_init_irq;
-       ppc_md.get_irq = gt64260_get_irq;
-
-       ppc_md.pcibios_fixup = ev64260_pci_fixups;
-
-       ppc_md.restart = ev64260_restart;
-       ppc_md.power_off = ev64260_power_off;
-       ppc_md.halt = ev64260_halt;
-
-       ppc_md.find_end_of_memory = ev64260_find_end_of_memory;
-
-       ppc_md.init = NULL;
-
-       ppc_md.time_init = todc_time_init;
-       ppc_md.set_rtc_time = todc_set_rtc_time;
-       ppc_md.get_rtc_time = todc_get_rtc_time;
-
-       ppc_md.nvram_read_val = todc_direct_read_val;
-       ppc_md.nvram_write_val = todc_direct_write_val;
-
-       ppc_md.calibrate_decr = ev64260_calibrate_decr;
-
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-        ppc_ide_md.ide_init_hwif = ev64260_ide_pci_init_hwif_ports;
-#endif
-
-       bh.p_base = CONFIG_MV64X60_NEW_BASE;
-
-#if !defined(CONFIG_USE_PPCBOOT)
-       ev64260_set_bat();
-#endif
-
-#ifdef CONFIG_SERIAL_8250
-#if defined(CONFIG_SERIAL_TEXT_DEBUG)
-       ppc_md.setup_io_mappings = ev64260_map_io;
-       ppc_md.progress = gen550_progress;
-#endif
-#if defined(CONFIG_KGDB)
-       ppc_md.setup_io_mappings = ev64260_map_io;
-       ppc_md.early_serial_map = ev64260_early_serial_map;
-#endif
-#elif defined(CONFIG_SERIAL_MPSC_CONSOLE)
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       ppc_md.setup_io_mappings = ev64260_map_io;
-       ppc_md.progress = gt64260_mpsc_progress;
-#endif /* CONFIG_SERIAL_TEXT_DEBUG */
-#ifdef CONFIG_KGDB
-       ppc_md.setup_io_mappings = ev64260_map_io;
-       ppc_md.early_serial_map = ev64260_early_serial_map;
-#endif /* CONFIG_KGDB */
-
-#endif
-
-       return;
-}
diff --git a/arch/ppc/platforms/lite5200.c b/arch/ppc/platforms/lite5200.c
deleted file mode 100644 (file)
index 043040d..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * arch/ppc/platforms/lite5200.c
- *
- * Platform support file for the Freescale LITE5200 based on MPC52xx.
- * A maximum of this file should be moved to syslib/mpc52xx_?????
- * so that new platform based on MPC52xx need a minimal platform file
- * ( avoid code duplication )
- *
- * 
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- *
- * Based on the 2.4 code written by Kent Borg,
- * Dale Farnsworth <dale.farnsworth@mvista.com> and
- * Wolfgang Denk <wd@denx.de>
- * 
- * Copyright 2004 Sylvain Munaut <tnt@246tNt.com>
- * Copyright 2003 Motorola Inc.
- * Copyright 2003 MontaVista Software Inc.
- * Copyright 2003 DENX Software Engineering (wd@denx.de)
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#include <linux/config.h>
-#include <linux/initrd.h>
-#include <linux/seq_file.h>
-#include <linux/kdev_t.h>
-#include <linux/root_dev.h>
-#include <linux/console.h>
-
-#include <asm/bootinfo.h>
-#include <asm/io.h>
-#include <asm/ocp.h>
-#include <asm/mpc52xx.h>
-
-
-/* Board data given by U-Boot */
-bd_t __res;
-EXPORT_SYMBOL(__res);  /* For modules */
-
-
-/* ======================================================================== */
-/* OCP device definition                                                    */
-/* For board/shared resources like PSCs                                     */
-/* ======================================================================== */
-/* Be sure not to load conficting devices : e.g. loading the UART drivers for
- * PSC1 and then also loading a AC97 for this same PSC.
- * For details about how to create an entry, look in the doc of the concerned
- * driver ( eg drivers/serial/mpc52xx_uart.c for the PSC in uart mode )
- */
-
-struct ocp_def board_ocp[] = {
-       {
-               .vendor         = OCP_VENDOR_FREESCALE,
-               .function       = OCP_FUNC_PSC_UART,
-               .index          = 0,
-               .paddr          = MPC52xx_PSC1,
-               .irq            = MPC52xx_PSC1_IRQ,
-               .pm             = OCP_CPM_NA,
-       },
-       {       /* Terminating entry */
-               .vendor         = OCP_VENDOR_INVALID
-       }
-};
-       
-
-/* ======================================================================== */
-/* Platform specific code                                                   */
-/* ======================================================================== */
-
-static int
-icecube_show_cpuinfo(struct seq_file *m)
-{
-       seq_printf(m, "machine\t\t: Freescale LITE5200\n");
-       return 0;
-}
-
-static void __init
-icecube_setup_arch(void)
-{
-
-       /* Add board OCP definitions */
-       mpc52xx_add_board_devices(board_ocp);
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-              unsigned long r6, unsigned long r7)
-{
-       /* Generic MPC52xx platform initialization */
-       /* TODO Create one and move a max of stuff in it.
-          Put this init in the syslib */
-
-       struct bi_record *bootinfo = find_bootinfo();
-
-       if (bootinfo)
-               parse_bootinfo(bootinfo);
-       else {
-               /* Load the bd_t board info structure */
-               if (r3)
-                       memcpy((void*)&__res,(void*)(r3+KERNELBASE),
-                                       sizeof(bd_t));
-
-#ifdef CONFIG_BLK_DEV_INITRD
-               /* Load the initrd */
-               if (r4) {
-                       initrd_start = r4 + KERNELBASE;
-                       initrd_end = r5 + KERNELBASE;
-               }
-#endif
-       
-               /* Load the command line */
-               if (r6) {
-                       *(char *)(r7+KERNELBASE) = 0;
-                       strcpy(cmd_line, (char *)(r6+KERNELBASE));
-               }
-       }
-
-       /* BAT setup */
-       mpc52xx_set_bat();
-       
-       /* No ISA bus AFAIK */
-       isa_io_base             = 0;
-       isa_mem_base            = 0;
-
-       /* Setup the ppc_md struct */
-       ppc_md.setup_arch       = icecube_setup_arch;
-       ppc_md.show_cpuinfo     = icecube_show_cpuinfo;
-       ppc_md.show_percpuinfo  = NULL;
-       ppc_md.init_IRQ         = mpc52xx_init_irq;
-       ppc_md.get_irq          = mpc52xx_get_irq;
-
-       ppc_md.find_end_of_memory = mpc52xx_find_end_of_memory;
-       ppc_md.setup_io_mappings  = mpc52xx_map_io;
-
-       ppc_md.restart          = mpc52xx_restart;
-       ppc_md.power_off        = mpc52xx_power_off;
-       ppc_md.halt             = mpc52xx_halt;
-       
-               /* No time keeper on the IceCube */
-       ppc_md.time_init        = NULL;
-       ppc_md.get_rtc_time     = NULL;
-       ppc_md.set_rtc_time     = NULL;
-       
-       ppc_md.calibrate_decr   = mpc52xx_calibrate_decr;
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-       ppc_md.progress         = mpc52xx_progress;
-#endif
-}
-
diff --git a/arch/ppc/platforms/lite5200.h b/arch/ppc/platforms/lite5200.h
deleted file mode 100644 (file)
index 833134b..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * arch/ppc/platforms/lite5200.h
- * 
- * Definitions for Freescale LITE5200 : MPC52xx Standard Development
- * Platform board support
- * 
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- * 
- * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#ifndef __PLATFORMS_LITE5200_H__
-#define __PLATFORMS_LITE5200_H__
-
-/* Serial port used for low-level debug */
-#define MPC52xx_PF_CONSOLE_PORT 0      /* PSC1 */
-
-
-#endif /* __PLATFORMS_LITE5200_H__ */
diff --git a/arch/ppc/platforms/mpc5200.c b/arch/ppc/platforms/mpc5200.c
deleted file mode 100644 (file)
index 30b6936..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * arch/ppc/platforms/mpc5200.c
- *
- * OCP Definitions for the boards based on MPC5200 processor. Contains
- * definitions for every common peripherals. (Mostly all but PSCs)
- * 
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- *
- * Copyright 2004 Sylvain Munaut <tnt@246tNt.com>
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#include <asm/ocp.h>
-#include <asm/mpc52xx.h>
-
-/* Here is the core_ocp struct.
- * With all the devices common to all board. Even if port multiplexing is
- * not setup for them (if the user don't want them, just don't select the
- * config option). The potentially conflicting devices (like PSCs) goes in
- * board specific file.
- */
-struct ocp_def core_ocp[] = {
-       {       /* Terminating entry */
-               .vendor         = OCP_VENDOR_INVALID
-       }
-};
diff --git a/arch/ppc/platforms/proc_rtas.c b/arch/ppc/platforms/proc_rtas.c
deleted file mode 100644 (file)
index f24f399..0000000
+++ /dev/null
@@ -1,788 +0,0 @@
-/*
- *   arch/ppc/platforms/proc_rtas.c
- *   Copyright (C) 2000 Tilmann Bitterberg
- *   (tilmann@bitterberg.de)
- *
- *   RTAS (Runtime Abstraction Services) stuff
- *   Intention is to provide a clean user interface
- *   to use the RTAS.
- *
- *   TODO:
- *   Split off a header file and maybe move it to a different
- *   location. Write Documentation on what the /proc/rtas/ entries
- *   actually do.
- */
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/proc_fs.h>
-#include <linux/stat.h>
-#include <linux/ctype.h>
-#include <linux/time.h>
-#include <linux/string.h>
-#include <linux/init.h>
-
-#include <asm/uaccess.h>
-#include <asm/bitops.h>
-#include <asm/processor.h>
-#include <asm/io.h>
-#include <asm/prom.h>
-#include <asm/machdep.h> /* for ppc_md */
-#include <asm/time.h>
-
-/* Token for Sensors */
-#define KEY_SWITCH             0x0001
-#define ENCLOSURE_SWITCH       0x0002
-#define THERMAL_SENSOR         0x0003
-#define LID_STATUS             0x0004
-#define POWER_SOURCE           0x0005
-#define BATTERY_VOLTAGE                0x0006
-#define BATTERY_REMAINING      0x0007
-#define BATTERY_PERCENTAGE     0x0008
-#define EPOW_SENSOR            0x0009
-#define BATTERY_CYCLESTATE     0x000a
-#define BATTERY_CHARGING       0x000b
-
-/* IBM specific sensors */
-#define IBM_SURVEILLANCE       0x2328 /* 9000 */
-#define IBM_FANRPM             0x2329 /* 9001 */
-#define IBM_VOLTAGE            0x232a /* 9002 */
-#define IBM_DRCONNECTOR                0x232b /* 9003 */
-#define IBM_POWERSUPPLY                0x232c /* 9004 */
-#define IBM_INTQUEUE           0x232d /* 9005 */
-
-/* Status return values */
-#define SENSOR_CRITICAL_HIGH   13
-#define SENSOR_WARNING_HIGH    12
-#define SENSOR_NORMAL          11
-#define SENSOR_WARNING_LOW     10
-#define SENSOR_CRITICAL_LOW     9
-#define SENSOR_SUCCESS          0
-#define SENSOR_HW_ERROR                -1
-#define SENSOR_BUSY            -2
-#define SENSOR_NOT_EXIST       -3
-#define SENSOR_DR_ENTITY       -9000
-
-/* Location Codes */
-#define LOC_SCSI_DEV_ADDR      'A'
-#define LOC_SCSI_DEV_LOC       'B'
-#define LOC_CPU                        'C'
-#define LOC_DISKETTE           'D'
-#define LOC_ETHERNET           'E'
-#define LOC_FAN                        'F'
-#define LOC_GRAPHICS           'G'
-/* reserved / not used         'H' */
-#define LOC_IO_ADAPTER         'I'
-/* reserved / not used         'J' */
-#define LOC_KEYBOARD           'K'
-#define LOC_LCD                        'L'
-#define LOC_MEMORY             'M'
-#define LOC_NV_MEMORY          'N'
-#define LOC_MOUSE              'O'
-#define LOC_PLANAR             'P'
-#define LOC_OTHER_IO           'Q'
-#define LOC_PARALLEL           'R'
-#define LOC_SERIAL             'S'
-#define LOC_DEAD_RING          'T'
-#define LOC_RACKMOUNTED                'U' /* for _u_nit is rack mounted */
-#define LOC_VOLTAGE            'V'
-#define LOC_SWITCH_ADAPTER     'W'
-#define LOC_OTHER              'X'
-#define LOC_FIRMWARE           'Y'
-#define LOC_SCSI               'Z'
-
-/* Tokens for indicators */
-#define TONE_FREQUENCY         0x0001 /* 0 - 1000 (HZ)*/
-#define TONE_VOLUME            0x0002 /* 0 - 100 (%) */
-#define SYSTEM_POWER_STATE     0x0003
-#define WARNING_LIGHT          0x0004
-#define DISK_ACTIVITY_LIGHT    0x0005
-#define HEX_DISPLAY_UNIT       0x0006
-#define BATTERY_WARNING_TIME   0x0007
-#define CONDITION_CYCLE_REQUEST        0x0008
-#define SURVEILLANCE_INDICATOR 0x2328 /* 9000 */
-#define DR_ACTION              0x2329 /* 9001 */
-#define DR_INDICATOR           0x232a /* 9002 */
-/* 9003 - 9004: Vendor specific */
-#define GLOBAL_INTERRUPT_QUEUE 0x232d /* 9005 */
-/* 9006 - 9999: Vendor specific */
-
-/* other */
-#define MAX_SENSORS             17  /* I only know of 17 sensors */
-#define MAX_LINELENGTH          256
-#define SENSOR_PREFIX          "ibm,sensor-"
-#define cel_to_fahr(x)         ((x*9/5)+32)
-
-
-/* Globals */
-static struct proc_dir_entry *proc_rtas;
-static struct rtas_sensors sensors;
-static struct device_node *rtas;
-static unsigned long power_on_time = 0; /* Save the time the user set */
-static char progress_led[MAX_LINELENGTH];
-
-static unsigned long rtas_tone_frequency = 1000;
-static unsigned long rtas_tone_volume = 0;
-
-/* ****************STRUCTS******************************************* */
-struct individual_sensor {
-       unsigned int token;
-       unsigned int quant;
-};
-
-struct rtas_sensors {
-        struct individual_sensor sensor[MAX_SENSORS];
-       unsigned int quant;
-};
-
-/* ****************************************************************** */
-/* Declarations */
-static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
-               int count, int *eof, void *data);
-static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_clock_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_progress_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_progress_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_poweron_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos);
-
-static ssize_t ppc_rtas_tone_freq_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_tone_volume_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos);
-
-struct file_operations ppc_rtas_poweron_operations = {
-       .read =         ppc_rtas_poweron_read,
-       .write =        ppc_rtas_poweron_write
-};
-struct file_operations ppc_rtas_progress_operations = {
-       .read =         ppc_rtas_progress_read,
-       .write =        ppc_rtas_progress_write
-};
-
-struct file_operations ppc_rtas_clock_operations = {
-       .read =         ppc_rtas_clock_read,
-       .write =        ppc_rtas_clock_write
-};
-
-struct file_operations ppc_rtas_tone_freq_operations = {
-       .read =         ppc_rtas_tone_freq_read,
-       .write =        ppc_rtas_tone_freq_write
-};
-struct file_operations ppc_rtas_tone_volume_operations = {
-       .read =         ppc_rtas_tone_volume_read,
-       .write =        ppc_rtas_tone_volume_write
-};
-
-int ppc_rtas_find_all_sensors (void);
-int ppc_rtas_process_sensor(struct individual_sensor s, int state,
-               int error, char * buf);
-char * ppc_rtas_process_error(int error);
-int get_location_code(struct individual_sensor s, char * buf);
-int check_location_string (char *c, char * buf);
-int check_location (char *c, int idx, char * buf);
-
-/* ****************************************************************** */
-/* MAIN                                                               */
-/* ****************************************************************** */
-static int __init proc_rtas_init(void)
-{
-       struct proc_dir_entry *entry;
-
-       rtas = find_devices("rtas");
-       if ((rtas == 0) || (_machine != _MACH_chrp)) {
-               return 1;
-       }
-
-       proc_rtas = proc_mkdir("rtas", 0);
-       if (proc_rtas == 0)
-               return 1;
-
-       /* /proc/rtas entries */
-
-       entry = create_proc_entry("progress", S_IRUGO|S_IWUSR, proc_rtas);
-       if (entry) entry->proc_fops = &ppc_rtas_progress_operations;
-
-       entry = create_proc_entry("clock", S_IRUGO|S_IWUSR, proc_rtas);
-       if (entry) entry->proc_fops = &ppc_rtas_clock_operations;
-
-       entry = create_proc_entry("poweron", S_IWUSR|S_IRUGO, proc_rtas);
-       if (entry) entry->proc_fops = &ppc_rtas_poweron_operations;
-
-       create_proc_read_entry("sensors", S_IRUGO, proc_rtas,
-                       ppc_rtas_sensor_read, NULL);
-
-       entry = create_proc_entry("frequency", S_IWUSR|S_IRUGO, proc_rtas);
-       if (entry) entry->proc_fops = &ppc_rtas_tone_freq_operations;
-
-       entry = create_proc_entry("volume", S_IWUSR|S_IRUGO, proc_rtas);
-       if (entry) entry->proc_fops = &ppc_rtas_tone_volume_operations;
-
-       return 0;
-}
-__initcall(proc_rtas_init);
-
-/* ****************************************************************** */
-/* POWER-ON-TIME                                                      */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_poweron_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos)
-{
-       struct rtc_time tm;
-       unsigned long nowtime;
-       char *dest;
-       int error;
-
-       nowtime = simple_strtoul(buf, &dest, 10);
-       if (*dest != '\0' && *dest != '\n') {
-               printk("ppc_rtas_poweron_write: Invalid time\n");
-               return count;
-       }
-       power_on_time = nowtime; /* save the time */
-
-       to_tm(nowtime, &tm);
-
-       error = call_rtas("set-time-for-power-on", 7, 1, NULL,
-                       tm.tm_year, tm.tm_mon, tm.tm_mday,
-                       tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */);
-       if (error != 0)
-               printk(KERN_WARNING "error: setting poweron time returned: %s\n",
-                               ppc_rtas_process_error(error));
-       return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos)
-{
-       int n;
-       if (power_on_time == 0)
-               n = sprintf(buf, "Power on time not set\n");
-       else
-               n = sprintf(buf, "%lu\n", power_on_time);
-
-       if (*ppos >= strlen(buf))
-               return 0;
-       if (n > strlen(buf) - *ppos)
-               n = strlen(buf) - *ppos;
-       if (n > count)
-               n = count;
-       *ppos += n;
-       return n;
-}
-
-/* ****************************************************************** */
-/* PROGRESS                                                           */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_progress_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos)
-{
-       unsigned long hex;
-
-       strcpy(progress_led, buf); /* save the string */
-       /* Lets see if the user passed hexdigits */
-       hex = simple_strtoul(buf, NULL, 10);
-
-       ppc_md.progress ((char *)buf, hex);
-       return count;
-
-       /* clear the line */ /* ppc_md.progress("                   ", 0xffff);*/
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_progress_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos)
-{
-       int n = 0;
-       if (progress_led != NULL)
-               n = sprintf (buf, "%s\n", progress_led);
-       if (*ppos >= strlen(buf))
-               return 0;
-       if (n > strlen(buf) - *ppos)
-               n = strlen(buf) - *ppos;
-       if (n > count)
-               n = count;
-       *ppos += n;
-       return n;
-}
-
-/* ****************************************************************** */
-/* CLOCK                                                              */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_clock_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos)
-{
-       struct rtc_time tm;
-       unsigned long nowtime;
-       char *dest;
-       int error;
-
-       nowtime = simple_strtoul(buf, &dest, 10);
-       if (*dest != '\0' && *dest != '\n') {
-               printk("ppc_rtas_clock_write: Invalid time\n");
-               return count;
-       }
-
-       to_tm(nowtime, &tm);
-       error = call_rtas("set-time-of-day", 7, 1, NULL,
-                       tm.tm_year, tm.tm_mon, tm.tm_mday,
-                       tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
-       if (error != 0)
-               printk(KERN_WARNING "error: setting the clock returned: %s\n",
-                               ppc_rtas_process_error(error));
-       return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos)
-{
-       unsigned int year, mon, day, hour, min, sec;
-       unsigned long *ret = kmalloc(4*8, GFP_KERNEL);
-       int n, error;
-
-       error = call_rtas("get-time-of-day", 0, 8, ret);
-
-       year = ret[0]; mon  = ret[1]; day  = ret[2];
-       hour = ret[3]; min  = ret[4]; sec  = ret[5];
-
-       if (error != 0){
-               printk(KERN_WARNING "error: reading the clock returned: %s\n",
-                               ppc_rtas_process_error(error));
-               n = sprintf (buf, "0");
-       } else {
-               n = sprintf (buf, "%lu\n", mktime(year, mon, day, hour, min, sec));
-       }
-       kfree(ret);
-
-       if (*ppos >= strlen(buf))
-               return 0;
-       if (n > strlen(buf) - *ppos)
-               n = strlen(buf) - *ppos;
-       if (n > count)
-               n = count;
-       *ppos += n;
-       return n;
-}
-
-/* ****************************************************************** */
-/* SENSOR STUFF                                                       */
-/* ****************************************************************** */
-static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
-               int count, int *eof, void *data)
-{
-       int i,j,n;
-       unsigned long ret;
-       int state, error;
-       char buffer[MAX_LINELENGTH*MAX_SENSORS]; /* May not be enough */
-
-       if (count < 0)
-               return -EINVAL;
-
-       n  = sprintf ( buffer  , "RTAS (RunTime Abstraction Services) Sensor Information\n");
-       n += sprintf ( buffer+n, "Sensor\t\tValue\t\tCondition\tLocation\n");
-       n += sprintf ( buffer+n, "********************************************************\n");
-
-       if (ppc_rtas_find_all_sensors() != 0) {
-               n += sprintf ( buffer+n, "\nNo sensors are available\n");
-               goto return_string;
-       }
-
-       for (i=0; i<sensors.quant; i++) {
-               j = sensors.sensor[i].quant;
-               /* A sensor may have multiple instances */
-               while (j >= 0) {
-                       error = call_rtas("get-sensor-state", 2, 2, &ret,
-                                 sensors.sensor[i].token, sensors.sensor[i].quant-j);
-                       state = (int) ret;
-                       n += ppc_rtas_process_sensor(sensors.sensor[i], state, error, buffer+n );
-                       n += sprintf (buffer+n, "\n");
-                       j--;
-               } /* while */
-       } /* for */
-
-return_string:
-       if (off >= strlen(buffer)) {
-               *eof = 1;
-               return 0;
-       }
-       if (n > strlen(buffer) - off)
-               n = strlen(buffer) - off;
-       if (n > count)
-               n = count;
-       else
-               *eof = 1;
-       memcpy(buf, buffer + off, n);
-       *start = buf;
-       return n;
-}
-
-/* ****************************************************************** */
-
-int ppc_rtas_find_all_sensors (void)
-{
-       unsigned long *utmp;
-       int len, i, j;
-
-       utmp = (unsigned long *) get_property(rtas, "rtas-sensors", &len);
-       if (utmp == NULL) {
-               printk (KERN_ERR "error: could not get rtas-sensors\n");
-               return 1;
-       }
-
-       sensors.quant = len / 8;      /* int + int */
-
-       for (i=0, j=0; j<sensors.quant; i+=2, j++) {
-               sensors.sensor[j].token = utmp[i];
-               sensors.sensor[j].quant = utmp[i+1];
-       }
-       return 0;
-}
-
-/* ****************************************************************** */
-/*
- * Builds a string of what rtas returned
- */
-char * ppc_rtas_process_error(int error)
-{
-       switch (error) {
-               case SENSOR_CRITICAL_HIGH:
-                       return "(critical high)";
-               case SENSOR_WARNING_HIGH:
-                       return "(warning high)";
-               case SENSOR_NORMAL:
-                       return "(normal)";
-               case SENSOR_WARNING_LOW:
-                       return "(warning low)";
-               case SENSOR_CRITICAL_LOW:
-                       return "(critical low)";
-               case SENSOR_SUCCESS:
-                       return "(read ok)";
-               case SENSOR_HW_ERROR:
-                       return "(hardware error)";
-               case SENSOR_BUSY:
-                       return "(busy)";
-               case SENSOR_NOT_EXIST:
-                       return "(non existant)";
-               case SENSOR_DR_ENTITY:
-                       return "(dr entity removed)";
-               default:
-                       return "(UNKNOWN)";
-       }
-}
-
-/* ****************************************************************** */
-/*
- * Builds a string out of what the sensor said
- */
-
-int ppc_rtas_process_sensor(struct individual_sensor s, int state,
-               int error, char * buf)
-{
-       /* Defined return vales */
-       const char * key_switch[]        = { "Off\t", "Normal\t", "Secure\t", "Mainenance" };
-       const char * enclosure_switch[]  = { "Closed", "Open" };
-       const char * lid_status[]        = { " ", "Open", "Closed" };
-       const char * power_source[]      = { "AC\t", "Battery", "AC & Battery" };
-       const char * battery_remaining[] = { "Very Low", "Low", "Mid", "High" };
-       const char * epow_sensor[]       = {
-               "EPOW Reset", "Cooling warning", "Power warning",
-               "System shutdown", "System halt", "EPOW main enclosure",
-               "EPOW power off" };
-       const char * battery_cyclestate[]  = { "None", "In progress", "Requested" };
-       const char * battery_charging[]    = { "Charging", "Discharching", "No current flow" };
-       const char * ibm_drconnector[]     = { "Empty", "Present" };
-       const char * ibm_intqueue[]        = { "Disabled", "Enabled" };
-
-       int have_strings = 0;
-       int temperature = 0;
-       int unknown = 0;
-       int n = 0;
-
-       /* What kind of sensor do we have here? */
-       switch (s.token) {
-               case KEY_SWITCH:
-                       n += sprintf(buf+n, "Key switch:\t");
-                       n += sprintf(buf+n, "%s\t", key_switch[state]);
-                       have_strings = 1;
-                       break;
-               case ENCLOSURE_SWITCH:
-                       n += sprintf(buf+n, "Enclosure switch:\t");
-                       n += sprintf(buf+n, "%s\t", enclosure_switch[state]);
-                       have_strings = 1;
-                       break;
-               case THERMAL_SENSOR:
-                       n += sprintf(buf+n, "Temp. (°C/°F):\t");
-                       temperature = 1;
-                       break;
-               case LID_STATUS:
-                       n += sprintf(buf+n, "Lid status:\t");
-                       n += sprintf(buf+n, "%s\t", lid_status[state]);
-                       have_strings = 1;
-                       break;
-               case POWER_SOURCE:
-                       n += sprintf(buf+n, "Power source:\t");
-                       n += sprintf(buf+n, "%s\t", power_source[state]);
-                       have_strings = 1;
-                       break;
-               case BATTERY_VOLTAGE:
-                       n += sprintf(buf+n, "Battery voltage:\t");
-                       break;
-               case BATTERY_REMAINING:
-                       n += sprintf(buf+n, "Battery remaining:\t");
-                       n += sprintf(buf+n, "%s\t", battery_remaining[state]);
-                       have_strings = 1;
-                       break;
-               case BATTERY_PERCENTAGE:
-                       n += sprintf(buf+n, "Battery percentage:\t");
-                       break;
-               case EPOW_SENSOR:
-                       n += sprintf(buf+n, "EPOW Sensor:\t");
-                       n += sprintf(buf+n, "%s\t", epow_sensor[state]);
-                       have_strings = 1;
-                       break;
-               case BATTERY_CYCLESTATE:
-                       n += sprintf(buf+n, "Battery cyclestate:\t");
-                       n += sprintf(buf+n, "%s\t", battery_cyclestate[state]);
-                       have_strings = 1;
-                       break;
-               case BATTERY_CHARGING:
-                       n += sprintf(buf+n, "Battery Charging:\t");
-                       n += sprintf(buf+n, "%s\t", battery_charging[state]);
-                       have_strings = 1;
-                       break;
-               case IBM_SURVEILLANCE:
-                       n += sprintf(buf+n, "Surveillance:\t");
-                       break;
-               case IBM_FANRPM:
-                       n += sprintf(buf+n, "Fan (rpm):\t");
-                       break;
-               case IBM_VOLTAGE:
-                       n += sprintf(buf+n, "Voltage (mv):\t");
-                       break;
-               case IBM_DRCONNECTOR:
-                       n += sprintf(buf+n, "DR connector:\t");
-                       n += sprintf(buf+n, "%s\t", ibm_drconnector[state]);
-                       have_strings = 1;
-                       break;
-               case IBM_POWERSUPPLY:
-                       n += sprintf(buf+n, "Powersupply:\t");
-                       break;
-               case IBM_INTQUEUE:
-                       n += sprintf(buf+n, "Interrupt queue:\t");
-                       n += sprintf(buf+n, "%s\t", ibm_intqueue[state]);
-                       have_strings = 1;
-                       break;
-               default:
-                       n += sprintf(buf+n,  "Unkown sensor (type %d), ignoring it\n",
-                                       s.token);
-                       unknown = 1;
-                       have_strings = 1;
-                       break;
-       }
-       if (have_strings == 0) {
-               if (temperature) {
-                       n += sprintf(buf+n, "%4d /%4d\t", state, cel_to_fahr(state));
-               } else
-                       n += sprintf(buf+n, "%10d\t", state);
-       }
-       if (unknown == 0) {
-               n += sprintf ( buf+n, "%s\t", ppc_rtas_process_error(error));
-               n += get_location_code(s, buf+n);
-       }
-       return n;
-}
-
-/* ****************************************************************** */
-
-int check_location (char *c, int idx, char * buf)
-{
-       int n = 0;
-
-       switch (*(c+idx)) {
-               case LOC_PLANAR:
-                       n += sprintf ( buf, "Planar #%c", *(c+idx+1));
-                       break;
-               case LOC_CPU:
-                       n += sprintf ( buf, "CPU #%c", *(c+idx+1));
-                       break;
-               case LOC_FAN:
-                       n += sprintf ( buf, "Fan #%c", *(c+idx+1));
-                       break;
-               case LOC_RACKMOUNTED:
-                       n += sprintf ( buf, "Rack #%c", *(c+idx+1));
-                       break;
-               case LOC_VOLTAGE:
-                       n += sprintf ( buf, "Voltage #%c", *(c+idx+1));
-                       break;
-               case LOC_LCD:
-                       n += sprintf ( buf, "LCD #%c", *(c+idx+1));
-                       break;
-               case '.':
-                       n += sprintf ( buf, "- %c", *(c+idx+1));
-               default:
-                       n += sprintf ( buf, "Unknown location");
-                       break;
-       }
-       return n;
-}
-
-
-/* ****************************************************************** */
-/*
- * Format:
- * ${LETTER}${NUMBER}[[-/]${LETTER}${NUMBER} [ ... ] ]
- * the '.' may be an abbrevation
- */
-int check_location_string (char *c, char *buf)
-{
-       int n=0,i=0;
-
-       while (c[i]) {
-               if (isalpha(c[i]) || c[i] == '.') {
-                        n += check_location(c, i, buf+n);
-               }
-               else if (c[i] == '/' || c[i] == '-')
-                       n += sprintf(buf+n, " at ");
-               i++;
-       }
-       return n;
-}
-
-
-/* ****************************************************************** */
-
-int get_location_code(struct individual_sensor s, char * buffer)
-{
-       char rstr[512], tmp[10], tmp2[10];
-       int n=0, i=0, llen, len;
-       /* char *buf = kmalloc(MAX_LINELENGTH, GFP_KERNEL); */
-       char *ret;
-
-       static int pos = 0; /* remember position where buffer was */
-
-       /* construct the sensor number like 0003 */
-       /* fill with zeros */
-       n = sprintf(tmp, "%d", s.token);
-       len = strlen(tmp);
-       while (strlen(tmp) < 4)
-               n += sprintf (tmp+n, "0");
-
-       /* invert the string */
-       while (tmp[i]) {
-               if (i<len)
-                       tmp2[4-len+i] = tmp[i];
-               else
-                       tmp2[3-i] = tmp[i];
-               i++;
-       }
-       tmp2[4] = '\0';
-
-       sprintf (rstr, SENSOR_PREFIX"%s", tmp2);
-
-       ret = (char *) get_property(rtas, rstr, &llen);
-
-       n=0;
-       if (ret[0] == '\0')
-               n += sprintf ( buffer+n, "--- ");/* does not have a location */
-       else {
-               char t[50];
-               ret += pos;
-
-               n += check_location_string(ret, buffer + n);
-               n += sprintf ( buffer+n, " ");
-               /* see how many characters we have printed */
-               sprintf ( t, "%s ", ret);
-
-               pos += strlen(t);
-               if (pos >= llen) pos=0;
-       }
-       return n;
-}
-/* ****************************************************************** */
-/* INDICATORS - Tone Frequency                                        */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_freq_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos)
-{
-       unsigned long freq;
-       char *dest;
-       int error;
-       freq = simple_strtoul(buf, &dest, 10);
-       if (*dest != '\0' && *dest != '\n') {
-               printk("ppc_rtas_tone_freq_write: Invalid tone freqency\n");
-               return count;
-       }
-       if (freq < 0) freq = 0;
-       rtas_tone_frequency = freq; /* save it for later */
-       error = call_rtas("set-indicator", 3, 1, NULL,
-                       TONE_FREQUENCY, 0, freq);
-       if (error != 0)
-               printk(KERN_WARNING "error: setting tone frequency returned: %s\n",
-                               ppc_rtas_process_error(error));
-       return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos)
-{
-       int n;
-       n = sprintf(buf, "%lu\n", rtas_tone_frequency);
-
-       if (*ppos >= strlen(buf))
-               return 0;
-       if (n > strlen(buf) - *ppos)
-               n = strlen(buf) - *ppos;
-       if (n > count)
-               n = count;
-       *ppos += n;
-       return n;
-}
-/* ****************************************************************** */
-/* INDICATORS - Tone Volume                                           */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_volume_write(struct file * file, const char * buf,
-               size_t count, loff_t *ppos)
-{
-       unsigned long volume;
-       char *dest;
-       int error;
-       volume = simple_strtoul(buf, &dest, 10);
-       if (*dest != '\0' && *dest != '\n') {
-               printk("ppc_rtas_tone_volume_write: Invalid tone volume\n");
-               return count;
-       }
-       if (volume < 0) volume = 0;
-       if (volume > 100) volume = 100;
-
-        rtas_tone_volume = volume; /* save it for later */
-       error = call_rtas("set-indicator", 3, 1, NULL,
-                       TONE_VOLUME, 0, volume);
-       if (error != 0)
-               printk(KERN_WARNING "error: setting tone volume returned: %s\n",
-                               ppc_rtas_process_error(error));
-       return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
-               size_t count, loff_t *ppos)
-{
-       int n;
-       n = sprintf(buf, "%lu\n", rtas_tone_volume);
-
-       if (*ppos >= strlen(buf))
-               return 0;
-       if (n > strlen(buf) - *ppos)
-               n = strlen(buf) - *ppos;
-       if (n > count)
-               n = count;
-       *ppos += n;
-       return n;
-}
diff --git a/arch/ppc/platforms/rpx8260.c b/arch/ppc/platforms/rpx8260.c
deleted file mode 100644 (file)
index 07d78d4..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * arch/ppc/platforms/rpx8260.c
- *
- * RPC EP8260 platform support
- *
- * Author: Dan Malek <dan@embeddededge.com>
- * Derived from: pq2ads_setup.c by Kumar
- *
- * Copyright 2004 Embedded Edge, LLC
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/seq_file.h>
-
-#include <asm/mpc8260.h>
-#include <asm/machdep.h>
-
-static void (*callback_setup_arch)(void);
-
-extern unsigned char __res[sizeof(bd_t)];
-
-extern void m8260_init(unsigned long r3, unsigned long r4,
-       unsigned long r5, unsigned long r6, unsigned long r7);
-
-static int
-ep8260_show_cpuinfo(struct seq_file *m)
-{
-       bd_t    *binfo = (bd_t *)__res;
-
-       seq_printf(m, "vendor\t\t: RPC\n"
-                     "machine\t\t: EP8260 PPC\n"
-                     "\n"
-                     "mem size\t\t: 0x%08x\n"
-                     "console baud\t\t: %d\n"
-                     "\n",
-                     binfo->bi_memsize,
-                     binfo->bi_baudrate);
-       return 0;
-}
-
-static void __init
-ep8260_setup_arch(void)
-{
-       printk("RPC EP8260 Port\n");
-       callback_setup_arch();
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
-             unsigned long r6, unsigned long r7)
-{
-       /* Generic 8260 platform initialization */
-       m8260_init(r3, r4, r5, r6, r7);
-
-       /* Anything special for this platform */
-       ppc_md.show_cpuinfo     = ep8260_show_cpuinfo;
-
-       callback_setup_arch     = ppc_md.setup_arch;
-       ppc_md.setup_arch       = ep8260_setup_arch;
-}
diff --git a/arch/ppc/platforms/rpx8260.h b/arch/ppc/platforms/rpx8260.h
deleted file mode 100644 (file)
index 7d5cd88..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * A collection of structures, addresses, and values associated with
- * the Embedded Planet RPX6 (or RPX Super) MPC8260 board.
- * Copied from the RPX-Classic and SBS8260 stuff.
- *
- * Copyright (c) 2001 Dan Malek <dan@embeddededge.com>
- */
-#ifdef __KERNEL__
-#ifndef __ASM_PLATFORMS_RPX8260_H__
-#define __ASM_PLATFORMS_RPX8260_H__
-
-/* A Board Information structure that is given to a program when
- * prom starts it up.
- */
-typedef struct bd_info {
-       unsigned int    bi_memstart;    /* Memory start address */
-       unsigned int    bi_memsize;     /* Memory (end) size in bytes */
-       unsigned int    bi_nvsize;      /* NVRAM size in bytes (can be 0) */
-       unsigned int    bi_intfreq;     /* Internal Freq, in Hz */
-       unsigned int    bi_busfreq;     /* Bus Freq, in MHz */
-       unsigned int    bi_cpmfreq;     /* CPM Freq, in MHz */
-       unsigned int    bi_brgfreq;     /* BRG Freq, in MHz */
-       unsigned int    bi_vco;         /* VCO Out from PLL */
-       unsigned int    bi_baudrate;    /* Default console baud rate */
-       unsigned int    bi_immr;        /* IMMR when called from boot rom */
-       unsigned char   bi_enetaddr[6];
-} bd_t;
-
-extern bd_t m8xx_board_info;
-
-/* Memory map is configured by the PROM startup.
- * We just map a few things we need.  The CSR is actually 4 byte-wide
- * registers that can be accessed as 8-, 16-, or 32-bit values.
- */
-#define CPM_MAP_ADDR           ((uint)0xf0000000)
-#define RPX_CSR_ADDR           ((uint)0xfa000000)
-#define RPX_CSR_SIZE           ((uint)(512 * 1024))
-#define RPX_NVRTC_ADDR         ((uint)0xfa080000)
-#define RPX_NVRTC_SIZE         ((uint)(512 * 1024))
-
-/* The RPX6 has 16, byte wide control/status registers.
- * Not all are used (yet).
- */
-extern volatile u_char *rpx6_csr_addr;
-
-/* Things of interest in the CSR.
-*/
-#define BCSR0_ID_MASK          ((u_char)0xf0)          /* Read only */
-#define BCSR0_SWITCH_MASK      ((u_char)0x0f)          /* Read only */
-#define BCSR1_XCVR_SMC1                ((u_char)0x80)
-#define BCSR1_XCVR_SMC2                ((u_char)0x40)
-#define BCSR2_FLASH_WENABLE    ((u_char)0x20)
-#define BCSR2_NVRAM_ENABLE     ((u_char)0x10)
-#define BCSR2_ALT_IRQ2         ((u_char)0x08)
-#define BCSR2_ALT_IRQ3         ((u_char)0x04)
-#define BCSR2_PRST             ((u_char)0x02)          /* Force reset */
-#define BCSR2_ENPRST           ((u_char)0x01)          /* Enable POR */
-#define BCSR3_MODCLK_MASK      ((u_char)0xe0)
-#define BCSR3_ENCLKHDR         ((u_char)0x10)
-#define BCSR3_LED5             ((u_char)0x04)          /* 0 == on */
-#define BCSR3_LED6             ((u_char)0x02)          /* 0 == on */
-#define BCSR3_LED7             ((u_char)0x01)          /* 0 == on */
-#define BCSR4_EN_PHY           ((u_char)0x80)          /* Enable PHY */
-#define BCSR4_EN_MII           ((u_char)0x40)          /* Enable PHY */
-#define BCSR4_MII_READ         ((u_char)0x04)
-#define BCSR4_MII_MDC          ((u_char)0x02)
-#define BCSR4_MII_MDIO         ((u_char)0x01)
-#define BCSR13_FETH_IRQMASK    ((u_char)0xf0)
-#define BCSR15_FETH_IRQ                ((u_char)0x20)
-
-#define PHY_INTERRUPT  SIU_INT_IRQ7
-
-#endif /* __ASM_PLATFORMS_RPX8260_H__ */
-#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/rpxsuper.h b/arch/ppc/platforms/rpxsuper.h
deleted file mode 100644 (file)
index d767971..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * A collection of structures, addresses, and values associated with
- * the Embedded Planet RPX6 (or RPX Super) MPC8260 board.
- * Copied from the RPX-Classic and SBS8260 stuff.
- *
- * Copyright (c) 2001 Dan Malek <dan@embeddededge.com>
- */
-#ifdef __KERNEL__
-#ifndef __ASM_PLATFORMS_RPXSUPER_H__
-#define __ASM_PLATFORMS_RPXSUPER_H__
-
-/* A Board Information structure that is given to a program when
- * prom starts it up.
- */
-typedef struct bd_info {
-       unsigned int    bi_memstart;    /* Memory start address */
-       unsigned int    bi_memsize;     /* Memory (end) size in bytes */
-       unsigned int    bi_nvsize;      /* NVRAM size in bytes (can be 0) */
-       unsigned int    bi_intfreq;     /* Internal Freq, in Hz */
-       unsigned int    bi_busfreq;     /* Bus Freq, in MHz */
-       unsigned int    bi_cpmfreq;     /* CPM Freq, in MHz */
-       unsigned int    bi_brgfreq;     /* BRG Freq, in MHz */
-       unsigned int    bi_vco;         /* VCO Out from PLL */
-       unsigned int    bi_baudrate;    /* Default console baud rate */
-       unsigned int    bi_immr;        /* IMMR when called from boot rom */
-       unsigned char   bi_enetaddr[6];
-} bd_t;
-
-extern bd_t m8xx_board_info;
-
-/* Memory map is configured by the PROM startup.
- * We just map a few things we need.  The CSR is actually 4 byte-wide
- * registers that can be accessed as 8-, 16-, or 32-bit values.
- */
-#define IMAP_ADDR              ((uint)0xf0000000)
-#define RPX_CSR_ADDR           ((uint)0xfa000000)
-#define RPX_CSR_SIZE           ((uint)(512 * 1024))
-#define RPX_NVRTC_ADDR         ((uint)0xfa080000)
-#define RPX_NVRTC_SIZE         ((uint)(512 * 1024))
-
-/* The RPX6 has 16, byte wide control/status registers.
- * Not all are used (yet).
- */
-extern volatile u_char *rpx6_csr_addr;
-
-/* Things of interest in the CSR.
-*/
-#define BCSR0_ID_MASK          ((u_char)0xf0)          /* Read only */
-#define BCSR0_SWITCH_MASK      ((u_char)0x0f)          /* Read only */
-#define BCSR1_XCVR_SMC1                ((u_char)0x80)
-#define BCSR1_XCVR_SMC2                ((u_char)0x40)
-#define BCSR2_FLASH_WENABLE    ((u_char)0x20)
-#define BCSR2_NVRAM_ENABLE     ((u_char)0x10)
-#define BCSR2_ALT_IRQ2         ((u_char)0x08)
-#define BCSR2_ALT_IRQ3         ((u_char)0x04)
-#define BCSR2_PRST             ((u_char)0x02)          /* Force reset */
-#define BCSR2_ENPRST           ((u_char)0x01)          /* Enable POR */
-#define BCSR3_MODCLK_MASK      ((u_char)0xe0)
-#define BCSR3_ENCLKHDR         ((u_char)0x10)
-#define BCSR3_LED5             ((u_char)0x04)          /* 0 == on */
-#define BCSR3_LED6             ((u_char)0x02)          /* 0 == on */
-#define BCSR3_LED7             ((u_char)0x01)          /* 0 == on */
-#define BCSR4_EN_PHY           ((u_char)0x80)          /* Enable PHY */
-#define BCSR4_EN_MII           ((u_char)0x40)          /* Enable PHY */
-#define BCSR4_MII_READ         ((u_char)0x04)
-#define BCSR4_MII_MDC          ((u_char)0x02)
-#define BCSR4_MII_MDIO         ((u_char)0x02)
-#define BCSR13_FETH_IRQMASK    ((u_char)0xf0)
-#define BCSR15_FETH_IRQ                ((u_char)0x20)
-
-#endif /* __ASM_PLATFORMS_RPXSUPER_H__ */
-#endif /* __KERNEL__ */
diff --git a/arch/ppc/syslib/cpm2_common.c b/arch/ppc/syslib/cpm2_common.c
deleted file mode 100644 (file)
index ea5e770..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * General Purpose functions for the global management of the
- * 8260 Communication Processor Module.
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- * Copyright (c) 2000 MontaVista Software, Inc (source@mvista.com)
- *     2.3.99 Updates
- *
- * In addition to the individual control of the communication
- * channels, there are a few functions that globally affect the
- * communication processor.
- *
- * Buffer descriptors must be allocated from the dual ported memory
- * space.  The allocator for that is here.  When the communication
- * process is reset, we reclaim the memory available.  There is
- * currently no deallocator for this memory.
- */
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/param.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/bootmem.h>
-#include <linux/module.h>
-#include <asm/irq.h>
-#include <asm/mpc8260.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/immap_cpm2.h>
-#include <asm/cpm2.h>
-#include <asm/rheap.h>
-
-static void cpm2_dpinit(void);
-cpm_cpm2_t     *cpmp;          /* Pointer to comm processor space */
-
-/* We allocate this here because it is used almost exclusively for
- * the communication processor devices.
- */
-cpm2_map_t *cpm2_immr;
-
-#define CPM_MAP_SIZE   (0x40000)       /* 256k - the PQ3 reserve this amount
-                                          of space for CPM as it is larger
-                                          than on PQ2 */
-
-void
-cpm2_reset(void)
-{
-       cpm2_immr = (cpm2_map_t *)ioremap(CPM_MAP_ADDR, CPM_MAP_SIZE);
-
-       /* Reclaim the DP memory for our use.
-        */
-       cpm2_dpinit();
-
-       /* Tell everyone where the comm processor resides.
-        */
-       cpmp = &cpm2_immr->im_cpm;
-}
-
-/* Set a baud rate generator.  This needs lots of work.  There are
- * eight BRGs, which can be connected to the CPM channels or output
- * as clocks.  The BRGs are in two different block of internal
- * memory mapped space.
- * The baud rate clock is the system clock divided by something.
- * It was set up long ago during the initial boot phase and is
- * is given to us.
- * Baud rate clocks are zero-based in the driver code (as that maps
- * to port numbers).  Documentation uses 1-based numbering.
- */
-#define BRG_INT_CLK    (((bd_t *)__res)->bi_brgfreq)
-#define BRG_UART_CLK   (BRG_INT_CLK/16)
-
-/* This function is used by UARTS, or anything else that uses a 16x
- * oversampled clock.
- */
-void
-cpm_setbrg(uint brg, uint rate)
-{
-       volatile uint   *bp;
-
-       /* This is good enough to get SMCs running.....
-       */
-       if (brg < 4) {
-               bp = (uint *)&cpm2_immr->im_brgc1;
-       }
-       else {
-               bp = (uint *)&cpm2_immr->im_brgc5;
-               brg -= 4;
-       }
-       bp += brg;
-       *bp = ((BRG_UART_CLK / rate) << 1) | CPM_BRG_EN;
-}
-
-/* This function is used to set high speed synchronous baud rate
- * clocks.
- */
-void
-cpm2_fastbrg(uint brg, uint rate, int div16)
-{
-       volatile uint   *bp;
-
-       if (brg < 4) {
-               bp = (uint *)&cpm2_immr->im_brgc1;
-       }
-       else {
-               bp = (uint *)&cpm2_immr->im_brgc5;
-               brg -= 4;
-       }
-       bp += brg;
-       *bp = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN;
-       if (div16)
-               *bp |= CPM_BRG_DIV16;
-}
-
-/*
- * dpalloc / dpfree bits.
- */
-static spinlock_t cpm_dpmem_lock;
-/* 16 blocks should be enough to satisfy all requests
- * until the memory subsystem goes up... */
-static rh_block_t cpm_boot_dpmem_rh_block[16];
-static rh_info_t cpm_dpmem_info;
-
-static void cpm2_dpinit(void)
-{
-       spin_lock_init(&cpm_dpmem_lock);
-
-       /* initialize the info header */
-       rh_init(&cpm_dpmem_info, 1,
-                       sizeof(cpm_boot_dpmem_rh_block) /
-                       sizeof(cpm_boot_dpmem_rh_block[0]),
-                       cpm_boot_dpmem_rh_block);
-
-       /* Attach the usable dpmem area */
-       /* XXX: This is actually crap. CPM_DATAONLY_BASE and
-        * CPM_DATAONLY_SIZE is only a subset of the available dpram. It
-        * varies with the processor and the microcode patches activated.
-        * But the following should be at least safe.
-        */
-       rh_attach_region(&cpm_dpmem_info, (void *)CPM_DATAONLY_BASE,
-                       CPM_DATAONLY_SIZE);
-}
-
-/* This function returns an index into the DPRAM area.
- */
-uint cpm_dpalloc(uint size, uint align)
-{
-       void *start;
-       unsigned long flags;
-
-       spin_lock_irqsave(&cpm_dpmem_lock, flags);
-       cpm_dpmem_info.alignment = align;
-       start = rh_alloc(&cpm_dpmem_info, size, "commproc");
-       spin_unlock_irqrestore(&cpm_dpmem_lock, flags);
-
-       return (uint)start;
-}
-EXPORT_SYMBOL(cpm_dpalloc);
-
-int cpm_dpfree(uint offset)
-{
-       int ret;
-       unsigned long flags;
-
-       spin_lock_irqsave(&cpm_dpmem_lock, flags);
-       ret = rh_free(&cpm_dpmem_info, (void *)offset);
-       spin_unlock_irqrestore(&cpm_dpmem_lock, flags);
-
-       return ret;
-}
-EXPORT_SYMBOL(cpm_dpfree);
-
-/* not sure if this is ever needed */
-uint cpm_dpalloc_fixed(uint offset, uint size, uint align)
-{
-       void *start;
-       unsigned long flags;
-
-       spin_lock_irqsave(&cpm_dpmem_lock, flags);
-       cpm_dpmem_info.alignment = align;
-       start = rh_alloc_fixed(&cpm_dpmem_info, (void *)offset, size, "commproc");
-       spin_unlock_irqrestore(&cpm_dpmem_lock, flags);
-
-       return (uint)start;
-}
-EXPORT_SYMBOL(cpm_dpalloc_fixed);
-
-void cpm_dpdump(void)
-{
-       rh_dump(&cpm_dpmem_info);
-}
-EXPORT_SYMBOL(cpm_dpdump);
-
-void *cpm_dpram_addr(uint offset)
-{
-       return (void *)&cpm2_immr->im_dprambase[offset];
-}
-EXPORT_SYMBOL(cpm_dpram_addr);
diff --git a/arch/ppc/syslib/m8260_pci_erratum9.c b/arch/ppc/syslib/m8260_pci_erratum9.c
deleted file mode 100644 (file)
index 9c0582d..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * arch/ppc/platforms/mpc8260_pci9.c
- *
- * Workaround for device erratum PCI 9.
- * See Motorola's "XPC826xA Family Device Errata Reference."
- * The erratum applies to all 8260 family Hip4 processors.  It is scheduled 
- * to be fixed in HiP4 Rev C.  Erratum PCI 9 states that a simultaneous PCI 
- * inbound write transaction and PCI outbound read transaction can result in a 
- * bus deadlock.  The suggested workaround is to use the IDMA controller to 
- * perform all reads from PCI configuration, memory, and I/O space.
- *
- * Author:  andy_lowe@mvista.com
- *
- * 2003 (c) MontaVista Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/kernel.h>
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/types.h>
-#include <linux/string.h>
-
-#include <asm/io.h>
-#include <asm/pci-bridge.h>
-#include <asm/machdep.h>
-#include <asm/byteorder.h>
-#include <asm/mpc8260.h>
-#include <asm/immap_cpm2.h>
-#include <asm/cpm2.h>
-
-#include "m8260_pci.h"
-
-#ifdef CONFIG_8260_PCI9
-/*#include <asm/mpc8260_pci9.h>*/ /* included in asm/io.h */
-
-#define IDMA_XFER_BUF_SIZE 64  /* size of the IDMA transfer buffer */
-
-/* define a structure for the IDMA dpram usage */
-typedef struct idma_dpram_s {
-       idma_t pram;                            /* IDMA parameter RAM */
-       u_char xfer_buf[IDMA_XFER_BUF_SIZE];    /* IDMA transfer buffer */
-       idma_bd_t bd;                           /* buffer descriptor */
-} idma_dpram_t;
-
-/* define offsets relative to start of IDMA dpram */
-#define IDMA_XFER_BUF_OFFSET (sizeof(idma_t))
-#define IDMA_BD_OFFSET (sizeof(idma_t) + IDMA_XFER_BUF_SIZE)
-
-/* define globals */
-static volatile idma_dpram_t *idma_dpram;
-
-/* Exactly one of CONFIG_8260_PCI9_IDMAn must be defined, 
- * where n is 1, 2, 3, or 4.  This selects the IDMA channel used for 
- * the PCI9 workaround.
- */
-#ifdef CONFIG_8260_PCI9_IDMA1
-#define IDMA_CHAN 0
-#define PROFF_IDMA PROFF_IDMA1_BASE
-#define IDMA_PAGE CPM_CR_IDMA1_PAGE
-#define IDMA_SBLOCK CPM_CR_IDMA1_SBLOCK
-#endif
-#ifdef CONFIG_8260_PCI9_IDMA2
-#define IDMA_CHAN 1
-#define PROFF_IDMA PROFF_IDMA2_BASE
-#define IDMA_PAGE CPM_CR_IDMA2_PAGE
-#define IDMA_SBLOCK CPM_CR_IDMA2_SBLOCK
-#endif
-#ifdef CONFIG_8260_PCI9_IDMA3
-#define IDMA_CHAN 2
-#define PROFF_IDMA PROFF_IDMA3_BASE
-#define IDMA_PAGE CPM_CR_IDMA3_PAGE
-#define IDMA_SBLOCK CPM_CR_IDMA3_SBLOCK
-#endif
-#ifdef CONFIG_8260_PCI9_IDMA4
-#define IDMA_CHAN 3
-#define PROFF_IDMA PROFF_IDMA4_BASE
-#define IDMA_PAGE CPM_CR_IDMA4_PAGE
-#define IDMA_SBLOCK CPM_CR_IDMA4_SBLOCK
-#endif
-
-void idma_pci9_init(void)
-{
-       uint dpram_offset;
-       volatile idma_t *pram;
-       volatile im_idma_t *idma_reg;
-       volatile cpm2_map_t *immap = cpm2_immr;
-
-       /* allocate IDMA dpram */
-       dpram_offset = cpm_dpalloc(sizeof(idma_dpram_t), 64);
-       idma_dpram = cpm_dpram_addr(dpram_offset); 
-
-       /* initialize the IDMA parameter RAM */
-       memset((void *)idma_dpram, 0, sizeof(idma_dpram_t));
-       pram = &idma_dpram->pram;
-       pram->ibase = dpram_offset + IDMA_BD_OFFSET;
-       pram->dpr_buf = dpram_offset + IDMA_XFER_BUF_OFFSET;
-       pram->ss_max = 32;
-       pram->dts = 32;
-
-       /* initialize the IDMA_BASE pointer to the IDMA parameter RAM */
-       *((ushort *) &immap->im_dprambase[PROFF_IDMA]) = dpram_offset;
-
-       /* initialize the IDMA registers */
-       idma_reg = (volatile im_idma_t *) &immap->im_sdma.sdma_idsr1;
-       idma_reg[IDMA_CHAN].idmr = 0;           /* mask all IDMA interrupts */
-       idma_reg[IDMA_CHAN].idsr = 0xff;        /* clear all event flags */
-
-       printk("<4>Using IDMA%d for MPC8260 device erratum PCI 9 workaround\n",
-               IDMA_CHAN + 1);
-
-       return;
-}
-
-/* Use the IDMA controller to transfer data from I/O memory to local RAM.
- * The src address must be a physical address suitable for use by the DMA 
- * controller with no translation.  The dst address must be a kernel virtual 
- * address.  The dst address is translated to a physical address via 
- * virt_to_phys().
- * The sinc argument specifies whether or not the source address is incremented
- * by the DMA controller.  The source address is incremented if and only if sinc
- * is non-zero.  The destination address is always incremented since the 
- * destination is always host RAM.
- */
-static void 
-idma_pci9_read(u8 *dst, u8 *src, int bytes, int unit_size, int sinc)
-{
-       unsigned long flags;
-       volatile idma_t *pram = &idma_dpram->pram;
-       volatile idma_bd_t *bd = &idma_dpram->bd;
-       volatile cpm2_map_t *immap = cpm2_immr;
-
-       local_irq_save(flags);
-
-       /* initialize IDMA parameter RAM for this transfer */
-       if (sinc)
-               pram->dcm = IDMA_DCM_DMA_WRAP_64 | IDMA_DCM_SINC
-                         | IDMA_DCM_DINC | IDMA_DCM_SD_MEM2MEM;
-       else
-               pram->dcm = IDMA_DCM_DMA_WRAP_64 | IDMA_DCM_DINC 
-                         | IDMA_DCM_SD_MEM2MEM;
-       pram->ibdptr = pram->ibase;
-       pram->sts = unit_size;
-       pram->istate = 0;
-
-       /* initialize the buffer descriptor */
-       bd->dst = virt_to_phys(dst);
-       bd->src = (uint) src;
-       bd->len = bytes;
-       bd->flags = IDMA_BD_V | IDMA_BD_W | IDMA_BD_I | IDMA_BD_L | IDMA_BD_DGBL
-                 | IDMA_BD_DBO_BE | IDMA_BD_SBO_BE | IDMA_BD_SDTB;
-
-       /* issue the START_IDMA command to the CP */
-       while (immap->im_cpm.cp_cpcr & CPM_CR_FLG);
-       immap->im_cpm.cp_cpcr = mk_cr_cmd(IDMA_PAGE, IDMA_SBLOCK, 0,
-                                        CPM_CR_START_IDMA) | CPM_CR_FLG;
-       while (immap->im_cpm.cp_cpcr & CPM_CR_FLG);
-
-       /* wait for transfer to complete */
-       while(bd->flags & IDMA_BD_V);
-
-       local_irq_restore(flags);
-
-       return;
-}
-
-/* Use the IDMA controller to transfer data from I/O memory to local RAM.
- * The dst address must be a physical address suitable for use by the DMA 
- * controller with no translation.  The src address must be a kernel virtual 
- * address.  The src address is translated to a physical address via 
- * virt_to_phys().
- * The dinc argument specifies whether or not the dest address is incremented
- * by the DMA controller.  The source address is incremented if and only if sinc
- * is non-zero.  The source address is always incremented since the 
- * source is always host RAM.
- */
-static void 
-idma_pci9_write(u8 *dst, u8 *src, int bytes, int unit_size, int dinc)
-{
-       unsigned long flags;
-       volatile idma_t *pram = &idma_dpram->pram;
-       volatile idma_bd_t *bd = &idma_dpram->bd;
-       volatile cpm2_map_t *immap = cpm2_immr;
-
-       local_irq_save(flags);
-
-       /* initialize IDMA parameter RAM for this transfer */
-       if (dinc)
-               pram->dcm = IDMA_DCM_DMA_WRAP_64 | IDMA_DCM_SINC
-                         | IDMA_DCM_DINC | IDMA_DCM_SD_MEM2MEM;
-       else
-               pram->dcm = IDMA_DCM_DMA_WRAP_64 | IDMA_DCM_SINC 
-                         | IDMA_DCM_SD_MEM2MEM;
-       pram->ibdptr = pram->ibase;
-       pram->sts = unit_size;
-       pram->istate = 0;
-
-       /* initialize the buffer descriptor */
-       bd->dst = (uint) dst;
-       bd->src = virt_to_phys(src);
-       bd->len = bytes;
-       bd->flags = IDMA_BD_V | IDMA_BD_W | IDMA_BD_I | IDMA_BD_L | IDMA_BD_DGBL
-                 | IDMA_BD_DBO_BE | IDMA_BD_SBO_BE | IDMA_BD_SDTB;
-
-       /* issue the START_IDMA command to the CP */
-       while (immap->im_cpm.cp_cpcr & CPM_CR_FLG);
-       immap->im_cpm.cp_cpcr = mk_cr_cmd(IDMA_PAGE, IDMA_SBLOCK, 0,
-                                        CPM_CR_START_IDMA) | CPM_CR_FLG;
-       while (immap->im_cpm.cp_cpcr & CPM_CR_FLG);
-
-       /* wait for transfer to complete */
-       while(bd->flags & IDMA_BD_V);
-
-       local_irq_restore(flags);
-
-       return;
-}
-
-/* Same as idma_pci9_read, but 16-bit little-endian byte swapping is performed
- * if the unit_size is 2, and 32-bit little-endian byte swapping is performed if
- * the unit_size is 4.
- */
-static void 
-idma_pci9_read_le(u8 *dst, u8 *src, int bytes, int unit_size, int sinc)
-{
-       int i;
-       u8 *p;
-
-       idma_pci9_read(dst, src, bytes, unit_size, sinc);
-       switch(unit_size) {
-               case 2:
-                       for (i = 0, p = dst; i < bytes; i += 2, p += 2)
-                               swab16s((u16 *) p);
-                       break;
-               case 4:
-                       for (i = 0, p = dst; i < bytes; i += 4, p += 4)
-                               swab32s((u32 *) p);
-                       break;
-               default:
-                       break;
-       }
-}
-EXPORT_SYMBOL(idma_pci9_init);
-EXPORT_SYMBOL(idma_pci9_read);
-EXPORT_SYMBOL(idma_pci9_read_le);
-
-static inline int is_pci_mem(unsigned long addr)
-{
-       if (addr >= MPC826x_PCI_LOWER_MMIO &&
-           addr <= MPC826x_PCI_UPPER_MMIO)
-               return 1;
-       if (addr >= MPC826x_PCI_LOWER_MEM &&
-           addr <= MPC826x_PCI_UPPER_MEM)
-               return 1;
-       return 0;
-}
-
-#define is_pci_mem(pa) ( (pa > 0x80000000) && (pa < 0xc0000000))
-int readb(volatile unsigned char *addr)
-{
-       u8 val;
-       unsigned long pa = iopa((unsigned long) addr);
-
-       if (!is_pci_mem(pa))
-               return in_8(addr);
-
-       idma_pci9_read((u8 *)&val, (u8 *)pa, sizeof(val), sizeof(val), 0);
-       return val;
-}
-
-int readw(volatile unsigned short *addr)
-{
-       u16 val;
-       unsigned long pa = iopa((unsigned long) addr);
-
-       if (!is_pci_mem(pa))
-               return in_le16(addr);
-
-       idma_pci9_read((u8 *)&val, (u8 *)pa, sizeof(val), sizeof(val), 0);
-       return swab16(val);
-}
-
-unsigned readl(volatile unsigned *addr)
-{
-       u32 val;
-       unsigned long pa = iopa((unsigned long) addr);
-
-       if (!is_pci_mem(pa))
-               return in_le32(addr);
-
-       idma_pci9_read((u8 *)&val, (u8 *)pa, sizeof(val), sizeof(val), 0);
-       return swab32(val);
-}
-
-int inb(unsigned port)
-{
-       u8 val;
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)&val, (u8 *)addr, sizeof(val), sizeof(val), 0);
-       return val;
-}
-
-int inw(unsigned port)
-{
-       u16 val;
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)&val, (u8 *)addr, sizeof(val), sizeof(val), 0);
-       return swab16(val);
-}
-
-unsigned inl(unsigned port)
-{
-       u32 val;
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)&val, (u8 *)addr, sizeof(val), sizeof(val), 0);
-       return swab32(val);
-}
-
-void insb(unsigned port, void *buf, int ns)
-{
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)buf, (u8 *)addr, ns*sizeof(u8), sizeof(u8), 0);
-}
-
-void insw(unsigned port, void *buf, int ns)
-{
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)buf, (u8 *)addr, ns*sizeof(u16), sizeof(u16), 0);
-}
-
-void insl(unsigned port, void *buf, int nl)
-{
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)buf, (u8 *)addr, nl*sizeof(u32), sizeof(u32), 0);
-}
-
-void insw_ns(unsigned port, void *buf, int ns)
-{
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)buf, (u8 *)addr, ns*sizeof(u16), sizeof(u16), 0);
-}
-
-void insl_ns(unsigned port, void *buf, int nl)
-{
-       u8 *addr = (u8 *)(port + _IO_BASE);
-
-       idma_pci9_read((u8 *)buf, (u8 *)addr, nl*sizeof(u32), sizeof(u32), 0);
-}
-
-void *memcpy_fromio(void *dest, unsigned long src, size_t count)
-{
-       unsigned long pa = iopa((unsigned long) src);
-
-       if (is_pci_mem(pa))
-               idma_pci9_read((u8 *)dest, (u8 *)pa, count, 32, 1);
-       else
-               memcpy(dest, (void *)src, count);
-       return dest;
-}
-
-EXPORT_SYMBOL(readb);
-EXPORT_SYMBOL(readw);
-EXPORT_SYMBOL(readl);
-EXPORT_SYMBOL(inb);
-EXPORT_SYMBOL(inw);
-EXPORT_SYMBOL(inl);
-EXPORT_SYMBOL(insb);
-EXPORT_SYMBOL(insw);
-EXPORT_SYMBOL(insl);
-EXPORT_SYMBOL(insw_ns);
-EXPORT_SYMBOL(insl_ns);
-EXPORT_SYMBOL(memcpy_fromio);
-
-#endif /* ifdef CONFIG_8260_PCI9 */
-
-/* Indirect PCI routines adapted from arch/ppc/kernel/indirect_pci.c.
- * Copyright (C) 1998 Gabriel Paubert.
- */
-#ifndef CONFIG_8260_PCI9
-#define cfg_read(val, addr, type, op)  *val = op((type)(addr))
-#else
-#define cfg_read(val, addr, type, op) \
-       idma_pci9_read_le((u8*)(val),(u8*)(addr),sizeof(*(val)),sizeof(*(val)),0)
-#endif
-
-#define cfg_write(val, addr, type, op) op((type *)(addr), (val))
-
-static int indirect_write_config(struct pci_bus *pbus, unsigned int devfn, int where,
-                        int size, u32 value)
-{
-       struct pci_controller *hose = pbus->sysdata;
-       u8 cfg_type = 0;
-       if (ppc_md.pci_exclude_device)
-               if (ppc_md.pci_exclude_device(pbus->number, devfn))
-                       return PCIBIOS_DEVICE_NOT_FOUND;
-
-       if (hose->set_cfg_type)
-               if (pbus->number != hose->first_busno)
-                       cfg_type = 1;
-
-       out_be32(hose->cfg_addr,
-                (((where & 0xfc) | cfg_type) << 24) | (devfn << 16)
-                | ((pbus->number - hose->bus_offset) << 8) | 0x80);
-
-       switch (size)
-       {
-               case 1:
-                       cfg_write(value, hose->cfg_data + (where & 3), u8, out_8);
-                       break;
-               case 2:
-                       cfg_write(value, hose->cfg_data + (where & 2), u16, out_le16);
-                       break;
-               case 4:
-                       cfg_write(value, hose->cfg_data + (where & 0), u32, out_le32);
-                       break;
-       }               
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static int indirect_read_config(struct pci_bus *pbus, unsigned int devfn, int where,
-                        int size, u32 *value)
-{
-       struct pci_controller *hose = pbus->sysdata;
-       u8 cfg_type = 0;
-       if (ppc_md.pci_exclude_device)
-               if (ppc_md.pci_exclude_device(pbus->number, devfn))
-                       return PCIBIOS_DEVICE_NOT_FOUND;
-
-       if (hose->set_cfg_type)
-               if (pbus->number != hose->first_busno)
-                       cfg_type = 1;
-
-       out_be32(hose->cfg_addr,
-                (((where & 0xfc) | cfg_type) << 24) | (devfn << 16)
-                | ((pbus->number - hose->bus_offset) << 8) | 0x80);
-
-       switch (size)
-       {
-               case 1:
-                       cfg_read(value, hose->cfg_data + (where & 3), u8 *, in_8);
-                       break;
-               case 2:
-                       cfg_read(value, hose->cfg_data + (where & 2), u16 *, in_le16);
-                       break;
-               case 4:
-                       cfg_read(value, hose->cfg_data + (where & 0), u32 *, in_le32);
-                       break;
-       }               
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops indirect_pci_ops =
-{
-       .read = indirect_read_config,
-       .write = indirect_write_config,
-};
-
-void
-setup_m8260_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data)
-{
-       hose->ops = &indirect_pci_ops;
-       hose->cfg_addr = (unsigned int *) ioremap(cfg_addr, 4);
-       hose->cfg_data = (unsigned char *) ioremap(cfg_data, 4);
-}
diff --git a/arch/ppc/syslib/mpc52xx_pic.c b/arch/ppc/syslib/mpc52xx_pic.c
deleted file mode 100644 (file)
index 0f88e63..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * arch/ppc/syslib/mpc52xx_pic.c
- *
- * Programmable Interrupt Controller functions for the Freescale MPC52xx 
- * embedded CPU.
- *
- * 
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- *
- * Based on (well, mostly copied from) the code from the 2.4 kernel by
- * Dale Farnsworth <dfarnsworth@mvista.com> and Kent Borg.
- * 
- * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
- * Copyright (C) 2003 Montavista Software, Inc
- * 
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#include <linux/stddef.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/stddef.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/system.h>
-#include <asm/irq.h>
-#include <asm/mpc52xx.h>
-
-
-static struct mpc52xx_intr *intr;
-static struct mpc52xx_sdma *sdma;
-
-static void
-mpc52xx_ic_disable(unsigned int irq)
-{
-       u32 val;
-
-       if (irq == MPC52xx_IRQ0) {
-               val = in_be32(&intr->ctrl);
-               val &= ~(1 << 11);
-               out_be32(&intr->ctrl, val);
-       }
-       else if (irq < MPC52xx_IRQ1) {
-               BUG();
-       }
-       else if (irq <= MPC52xx_IRQ3) {
-               val = in_be32(&intr->ctrl);
-               val &= ~(1 << (10 - (irq - MPC52xx_IRQ1)));
-               out_be32(&intr->ctrl, val);
-       }
-       else if (irq < MPC52xx_SDMA_IRQ_BASE) {
-               val = in_be32(&intr->main_mask);
-               val |= 1 << (16 - (irq - MPC52xx_MAIN_IRQ_BASE));
-               out_be32(&intr->main_mask, val);
-       }
-       else if (irq < MPC52xx_PERP_IRQ_BASE) {
-               val = in_be32(&sdma->IntMask);
-               val |= 1 << (irq - MPC52xx_SDMA_IRQ_BASE);
-               out_be32(&sdma->IntMask, val);
-       }
-       else {
-               val = in_be32(&intr->per_mask);
-               val |= 1 << (31 - (irq - MPC52xx_PERP_IRQ_BASE));
-               out_be32(&intr->per_mask, val);
-       }
-}
-
-static void
-mpc52xx_ic_enable(unsigned int irq)
-{
-       u32 val;
-
-       if (irq == MPC52xx_IRQ0) {
-               val = in_be32(&intr->ctrl);
-               val |= 1 << 11;
-               out_be32(&intr->ctrl, val);
-       }
-       else if (irq < MPC52xx_IRQ1) {
-               BUG();
-       }
-       else if (irq <= MPC52xx_IRQ3) {
-               val = in_be32(&intr->ctrl);
-               val |= 1 << (10 - (irq - MPC52xx_IRQ1));
-               out_be32(&intr->ctrl, val);
-       }
-       else if (irq < MPC52xx_SDMA_IRQ_BASE) {
-               val = in_be32(&intr->main_mask);
-               val &= ~(1 << (16 - (irq - MPC52xx_MAIN_IRQ_BASE)));
-               out_be32(&intr->main_mask, val);
-       }
-       else if (irq < MPC52xx_PERP_IRQ_BASE) {
-               val = in_be32(&sdma->IntMask);
-               val &= ~(1 << (irq - MPC52xx_SDMA_IRQ_BASE));
-               out_be32(&sdma->IntMask, val);
-       }
-       else {
-               val = in_be32(&intr->per_mask);
-               val &= ~(1 << (31 - (irq - MPC52xx_PERP_IRQ_BASE)));
-               out_be32(&intr->per_mask, val);
-       }
-}
-
-static void
-mpc52xx_ic_ack(unsigned int irq)
-{
-       u32 val;
-
-       /*
-        * Only some irqs are reset here, others in interrupting hardware.
-        */
-                       
-       switch (irq) {
-       case MPC52xx_IRQ0:
-               val = in_be32(&intr->ctrl);
-               val |= 0x08000000;
-               out_be32(&intr->ctrl, val);
-               break;
-       case MPC52xx_CCS_IRQ:
-               val = in_be32(&intr->enc_status);
-               val |= 0x00000400;
-               out_be32(&intr->enc_status, val);
-               break;
-       case MPC52xx_IRQ1:
-               val = in_be32(&intr->ctrl);
-               val |= 0x04000000;
-               out_be32(&intr->ctrl, val);
-               break;
-       case MPC52xx_IRQ2:
-               val = in_be32(&intr->ctrl);
-               val |= 0x02000000;
-               out_be32(&intr->ctrl, val);
-               break;
-       case MPC52xx_IRQ3:
-               val = in_be32(&intr->ctrl);
-               val |= 0x01000000;
-               out_be32(&intr->ctrl, val);
-               break;
-       default:
-               if (irq >= MPC52xx_SDMA_IRQ_BASE
-                   && irq < (MPC52xx_SDMA_IRQ_BASE + MPC52xx_SDMA_IRQ_NUM)) {
-                       out_be32(&sdma->IntPend,
-                                1 << (irq - MPC52xx_SDMA_IRQ_BASE));
-               }
-               break;
-       }
-}
-
-static void
-mpc52xx_ic_disable_and_ack(unsigned int irq)
-{
-       mpc52xx_ic_disable(irq);
-       mpc52xx_ic_ack(irq);
-}
-
-static void
-mpc52xx_ic_end(unsigned int irq)
-{
-       if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
-               mpc52xx_ic_enable(irq);
-}
-
-static struct hw_interrupt_type mpc52xx_ic = {
-       "MPC52xx",
-       NULL,                           /* startup(irq) */
-       NULL,                           /* shutdown(irq) */
-       mpc52xx_ic_enable,              /* enable(irq) */
-       mpc52xx_ic_disable,             /* disable(irq) */
-       mpc52xx_ic_disable_and_ack,     /* disable_and_ack(irq) */
-       mpc52xx_ic_end,                 /* end(irq) */
-       0                               /* set_affinity(irq, cpumask) SMP. */
-};
-
-void __init
-mpc52xx_init_irq(void)
-{
-       int i;
-
-       /* Remap the necessary zones */
-       intr = (struct mpc52xx_intr *)
-               ioremap(MPC52xx_INTR, sizeof(struct mpc52xx_intr));
-       sdma = (struct mpc52xx_sdma *)
-               ioremap(MPC52xx_SDMA, sizeof(struct mpc52xx_sdma));
-       
-       if ((intr==NULL) || (sdma==NULL))
-               panic("Can't ioremap PIC/SDMA register for init_irq !");
-
-       /* Disable all interrupt sources. */
-       out_be32(&sdma->IntPend, 0xffffffff);   /* 1 means clear pending */
-       out_be32(&sdma->IntMask, 0xffffffff);   /* 1 means disabled */
-       out_be32(&intr->per_mask, 0x7ffffc00);  /* 1 means disabled */
-       out_be32(&intr->main_mask, 0x00010fff); /* 1 means disabled */
-       out_be32(&intr->ctrl,
-                       0x0f000000 |    /* clear IRQ 0-3 */
-                       0x00c00000 |    /* IRQ0: level-sensitive, active low */
-                       0x00001000 |    /* MEE master external enable */
-                       0x00000000 |    /* 0 means disable IRQ 0-3 */
-                       0x00000001);    /* CEb route critical normally */
-
-       /* Zero a bunch of the priority settings.  */
-       out_be32(&intr->per_pri1, 0);
-       out_be32(&intr->per_pri2, 0);
-       out_be32(&intr->per_pri3, 0);
-       out_be32(&intr->main_pri1, 0);
-       out_be32(&intr->main_pri2, 0);
-
-       /* Initialize irq_desc[i].handler's with mpc52xx_ic. */
-       for (i = 0; i < NR_IRQS; i++) {
-               irq_desc[i].handler = &mpc52xx_ic;
-               irq_desc[i].status = IRQ_LEVEL;
-       }
-}
-
-int
-mpc52xx_get_irq(struct pt_regs *regs)
-{
-       u32 status;
-       int irq = -1;
-
-       status = in_be32(&intr->enc_status);
-
-       if (status & 0x00000400) {              /* critical */
-               irq = (status >> 8) & 0x3;
-               if (irq == 2)                   /* high priority peripheral */
-                       goto peripheral;
-               irq += MPC52xx_CRIT_IRQ_BASE;
-       }
-       else if (status & 0x00200000) {         /* main */
-               irq = (status >> 16) & 0x1f;
-               if (irq == 4)                   /* low priority peripheral */
-                       goto peripheral;
-               irq += MPC52xx_MAIN_IRQ_BASE;
-       }
-       else if (status & 0x20000000) {         /* peripheral */
-peripheral:
-               irq = (status >> 24) & 0x1f;
-               if (irq == 0) {                 /* bestcomm */
-                       status = in_be32(&sdma->IntPend);
-                       irq = ffs(status) + MPC52xx_SDMA_IRQ_BASE-1;
-               }
-               else
-                       irq += MPC52xx_PERP_IRQ_BASE;
-       }
-
-       return irq;
-}
-
diff --git a/arch/ppc/syslib/mpc52xx_setup.c b/arch/ppc/syslib/mpc52xx_setup.c
deleted file mode 100644 (file)
index 631cea3..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * arch/ppc/syslib/mpc52xx_common.c
- *
- * Common code for the boards based on Freescale MPC52xx embedded CPU.
- *
- * 
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- *
- * Support for other bootloaders than UBoot by Dale Farnsworth 
- * <dfarnsworth@mvista.com>
- * 
- * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
- * Copyright (C) 2003 Montavista Software, Inc
- * 
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#include <linux/config.h>
-
-#include <asm/time.h>
-#include <asm/mpc52xx.h>
-#include <asm/mpc52xx_psc.h>
-#include <asm/ocp.h>
-#include <asm/ppcboot.h>
-
-extern bd_t __res;
-
-static int core_mult[] = {             /* CPU Frequency multiplier, taken    */
-       0,  0,  0,  10, 20, 20, 25, 45, /* from the datasheet used to compute */
-       30, 55, 40, 50, 0,  60, 35, 0,  /* CPU frequency from XLB freq and    */
-       30, 25, 65, 10, 70, 20, 75, 45, /* external jumper config             */
-       0,  55, 40, 50, 80, 60, 35, 0
-};
-
-void
-mpc52xx_restart(char *cmd)
-{
-       struct mpc52xx_gpt* gpt0 = (struct mpc52xx_gpt*) MPC52xx_GPTx(0);
-       
-       local_irq_disable();
-       
-       /* Turn on the watchdog and wait for it to expire. It effectively
-         does a reset */
-       if (gpt0 != NULL) {
-               out_be32(&gpt0->count, 0x000000ff);
-               out_be32(&gpt0->mode, 0x00009004);
-       } else
-               printk(KERN_ERR "mpc52xx_restart: Unable to ioremap GPT0 registers, -> looping ...");
-
-       while (1);
-}
-
-void
-mpc52xx_halt(void)
-{
-       local_irq_disable();
-
-       while (1);
-}
-
-void
-mpc52xx_power_off(void)
-{
-       /* By default we don't have any way of shut down.
-          If a specific board wants to, it can set the power down
-          code to any hardware implementation dependent code */
-       mpc52xx_halt();
-}
-
-
-void __init
-mpc52xx_set_bat(void)
-{
-       /* Set BAT 2 to map the 0xf0000000 area */
-       /* This mapping is used during mpc52xx_progress,
-        * mpc52xx_find_end_of_memory, and UARTs/GPIO access for debug
-        */
-       mb();
-       mtspr(DBAT2U, 0xf0001ffe);
-       mtspr(DBAT2L, 0xf000002a);
-       mb();
-}
-
-void __init
-mpc52xx_map_io(void)
-{
-       /* Here we only map the MBAR */
-       io_block_mapping(
-               MPC52xx_MBAR_VIRT, MPC52xx_MBAR, MPC52xx_MBAR_SIZE, _PAGE_IO);
-}
-
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-#ifdef MPC52xx_PF_CONSOLE_PORT
-#define MPC52xx_CONSOLE MPC52xx_PSCx(MPC52xx_PF_CONSOLE_PORT)
-#else
-#error "mpc52xx PSC for console not selected"
-#endif
-
-void
-mpc52xx_progress(char *s, unsigned short hex)
-{
-       struct mpc52xx_psc *psc = (struct mpc52xx_psc *)MPC52xx_CONSOLE;
-       char c;
-
-               /* Don't we need to disable serial interrupts ? */
-       
-       while ((c = *s++) != 0) {
-               if (c == '\n') {
-                       while (!(in_be16(&psc->mpc52xx_psc_status) &
-                                MPC52xx_PSC_SR_TXRDY)) ;
-                       out_8(&psc->mpc52xx_psc_buffer_8, '\r');
-               }
-               while (!(in_be16(&psc->mpc52xx_psc_status) &
-                        MPC52xx_PSC_SR_TXRDY)) ;
-               out_8(&psc->mpc52xx_psc_buffer_8, c);
-       }
-}
-
-#endif  /* CONFIG_SERIAL_TEXT_DEBUG */
-
-
-unsigned long __init
-mpc52xx_find_end_of_memory(void)
-{
-       u32 ramsize = __res.bi_memsize;
-
-       /*
-        * if bootloader passed a memsize, just use it
-        * else get size from sdram config registers
-        */
-       if (ramsize == 0) {
-               struct mpc52xx_mmap_ctl *mmap_ctl;
-               u32 sdram_config_0, sdram_config_1;
-
-               /* Temp BAT2 mapping active when this is called ! */
-               mmap_ctl = (struct mpc52xx_mmap_ctl*) MPC52xx_MMAP_CTL;
-                       
-               sdram_config_0 = in_be32(&mmap_ctl->sdram0);
-               sdram_config_1 = in_be32(&mmap_ctl->sdram1);
-
-               if ((sdram_config_0 & 0x1f) >= 0x13)
-                       ramsize = 1 << ((sdram_config_0 & 0xf) + 17);
-
-               if (((sdram_config_1 & 0x1f) >= 0x13) &&
-                               ((sdram_config_1 & 0xfff00000) == ramsize))
-                       ramsize += 1 << ((sdram_config_1 & 0xf) + 17);
-
-               iounmap(mmap_ctl);
-       }
-       
-       return ramsize;
-}
-
-void __init
-mpc52xx_calibrate_decr(void)
-{
-       int current_time, previous_time;
-       int tbl_start, tbl_end;
-       unsigned int xlbfreq, cpufreq, ipbfreq, pcifreq, divisor;
-
-       xlbfreq = __res.bi_busfreq;
-       /* if bootloader didn't pass bus frequencies, calculate them */
-       if (xlbfreq == 0) {
-               /* Get RTC & Clock manager modules */
-               struct mpc52xx_rtc *rtc;
-               struct mpc52xx_cdm *cdm;
-               
-               rtc = (struct mpc52xx_rtc*)
-                       ioremap(MPC52xx_RTC, sizeof(struct mpc52xx_rtc));
-               cdm = (struct mpc52xx_cdm*)
-                       ioremap(MPC52xx_CDM, sizeof(struct mpc52xx_cdm));
-
-               if ((rtc==NULL) || (cdm==NULL))
-                       panic("Can't ioremap RTC/CDM while computing bus freq");
-
-               /* Count bus clock during 1/64 sec */
-               out_be32(&rtc->dividers, 0x8f1f0000);   /* Set RTC 64x faster */
-               previous_time = in_be32(&rtc->time);
-               while ((current_time = in_be32(&rtc->time)) == previous_time) ;
-               tbl_start = get_tbl();
-               previous_time = current_time;
-               while ((current_time = in_be32(&rtc->time)) == previous_time) ;
-               tbl_end = get_tbl();
-               out_be32(&rtc->dividers, 0xffff0000);   /* Restore RTC */
-
-               /* Compute all frequency from that & CDM settings */
-               xlbfreq = (tbl_end - tbl_start) << 8;
-               cpufreq = (xlbfreq * core_mult[in_be32(&cdm->rstcfg)&0x1f])/10;
-               ipbfreq = (in_8(&cdm->ipb_clk_sel) & 1) ?
-                                       xlbfreq / 2 : xlbfreq;
-               switch (in_8(&cdm->pci_clk_sel) & 3) {
-               case 0:
-                       pcifreq = ipbfreq;
-                       break;
-               case 1:
-                       pcifreq = ipbfreq / 2;
-                       break;
-               default:
-                       pcifreq = xlbfreq / 4;
-                       break;
-               }
-               __res.bi_busfreq = xlbfreq;
-               __res.bi_intfreq = cpufreq;
-               __res.bi_ipbfreq = ipbfreq;
-               __res.bi_pcifreq = pcifreq;
-       
-               /* Release mapping */
-               iounmap((void*)rtc);
-               iounmap((void*)cdm);
-       }
-
-       divisor = 4;
-
-       tb_ticks_per_jiffy = xlbfreq / HZ / divisor;
-       tb_to_us = mulhwu_scale_factor(xlbfreq / divisor, 1000000);
-}
-
-
-void __init
-mpc52xx_add_board_devices(struct ocp_def board_ocp[]) {
-       while (board_ocp->vendor != OCP_VENDOR_INVALID)
-               if(ocp_add_one_device(board_ocp++))
-                       printk("mpc5200-ocp: Failed to add board device !\n");
-}
-
diff --git a/arch/ppc/syslib/mv64360_pic.c b/arch/ppc/syslib/mv64360_pic.c
deleted file mode 100644 (file)
index ef07629..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * arch/ppc/kernel/mv64360_pic.c
- * 
- * Interrupt controller support for Marvell's MV64360.
- *
- * Author: Rabeeh Khoury <rabeeh@galileo.co.il>
- * Based on MV64360 PIC written by
- * Chris Zankel <chris@mvista.com>
- * Mark A. Greer <mgreer@mvista.com>
- *
- * Copyright 2004 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-/*
- * This file contains the specific functions to support the MV64360
- * interrupt controller.
- *
- * The MV64360 has two main interrupt registers (high and low) that
- * summarizes the interrupts generated by the units of the MV64360.
- * Each bit is assigned to an interrupt number, where the low register
- * are assigned from IRQ0 to IRQ31 and the high cause register
- * from IRQ32 to IRQ63 
- * The GPP (General Purpose Pins) interrupts are assigned from IRQ64 (GPP0) 
- * to IRQ95 (GPP31). 
- * get_irq() returns the lowest interrupt number that is currently asserted.
- *
- * Note: 
- *  - This driver does not initialize the GPP when used as an interrupt 
- *    input.
- */
-
-#include <linux/stddef.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/stddef.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/system.h>
-#include <asm/irq.h>
-#include <asm/ocp.h>
-#include <asm/mv64x60.h>
-
-#ifdef CONFIG_IRQ_ALL_CPUS
-#error "The mv64360 does not support yet distribution of IRQs on all CPUs"
-#endif
-/* ========================== forward declaration ========================== */
-
-static void mv64360_unmask_irq(unsigned int);
-static void mv64360_mask_irq(unsigned int);
-static irqreturn_t mv64360_cpu_error_int_handler(int, void *, struct pt_regs *);
-static irqreturn_t mv64360_sram_error_int_handler(int, void *, struct pt_regs *);
-static irqreturn_t mv64360_pci_error_int_handler(int, void *, struct pt_regs *);
-
-/* ========================== local declarations =========================== */
-
-struct hw_interrupt_type mv64360_pic = {
-       .typename = " MV64360_PIC ",    /* typename */
-       .enable = mv64360_unmask_irq,   /* enable */
-       .disable = mv64360_mask_irq,    /* disable */
-       .ack = mv64360_mask_irq,        /* ack */
-};
-
-#define CPU_INTR_STR   "MV64360 CPU interface error"
-#define SRAM_INTR_STR  "MV64360 internal sram error"
-#define PCI0_INTR_STR  "MV64360 PCI 0 error"
-#define PCI1_INTR_STR  "MV64360 PCI 1 error"
-
-static mv64x60_handle_t        base_bh;
-
-u32 mv64360_irq_base = 0;      /* MV64360 handles the next 96 IRQs from here */
-
-/* mv64360_init_irq()
- *
- *  This function initializes the interrupt controller. It assigns
- *  all interrupts from IRQ0 to IRQ95 to the mv64360 interrupt controller.
- *
- * Input Variable(s):
- *  None.
- *
- * Outpu. Variable(s):
- *  None.
- *
- * Returns:
- *  void
- *
- * Note:
- *  We register all GPP inputs as interrupt source, but disable them.
- */
-
-__init void
-mv64360_init_irq(void)
-{
-       struct ocp_def  *def;
-       int i;
-
-       if (ppc_md.progress)
-               ppc_md.progress("mv64360_init_irq: enter", 0x0);
-
-       if ( ppc_md.progress ) ppc_md.progress("mv64360_init_irq: enter", 0x0);
-
-       if ((def = ocp_get_one_device(OCP_VENDOR_MARVELL, OCP_FUNC_HB,
-                                       OCP_ANY_INDEX)) == NULL) {
-               /* XXXX SCREAM */
-               return;
-       }
-       base_bh.v_base = (unsigned long)ioremap(def->paddr, 0x1000);
-
-       ppc_cached_irq_mask[0] = 0;
-       ppc_cached_irq_mask[1] = 0x0f000000;    /* Enable GPP intrs */
-       ppc_cached_irq_mask[2] = 0;
-
-       /* disable all interrupts and clear current interrupts */
-       mv64x60_write(&base_bh, MV64x60_GPP_INTR_CAUSE, 0);
-       mv64x60_write(&base_bh, MV64x60_GPP_INTR_MASK,
-               ppc_cached_irq_mask[2]);
-       mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_LO,
-               ppc_cached_irq_mask[0]);
-       mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_HI,
-               ppc_cached_irq_mask[1]);
-
-       /* use the mv64360 for all (possible) interrupt sources */
-       for (i = mv64360_irq_base; i < (mv64360_irq_base + 96); i++) {
-               /* All interrupts are level interrupts */
-               irq_desc[i].status |= IRQ_LEVEL;
-               irq_desc[i].handler = &mv64360_pic;
-       }
-
-       /* Register CPU interface error interrupt handler */
-       request_irq(MV64x60_IRQ_CPU_ERR, mv64360_cpu_error_int_handler,
-               SA_INTERRUPT, CPU_INTR_STR, 0);
-       mv64x60_write(&base_bh, MV64x60_CPU_ERR_MASK, 0x000000ff);
-
-       /* Register internal SRAM error interrupt handler */
-       request_irq(MV64360_IRQ_SRAM_PAR_ERR, mv64360_sram_error_int_handler,
-               SA_INTERRUPT, SRAM_INTR_STR, 0);
-
-       /* Register PCI 0 error interrupt handler */
-       request_irq(MV64360_IRQ_PCI0, mv64360_pci_error_int_handler,
-               SA_INTERRUPT, PCI0_INTR_STR, (void *) 0);
-       mv64x60_write(&base_bh, MV64x60_PCI0_ERR_MASK, 0x00a50c25);
-
-       /* Register PCI 1 error interrupt handler */
-       request_irq(MV64360_IRQ_PCI1, mv64360_pci_error_int_handler,
-               SA_INTERRUPT, PCI1_INTR_STR, (void *) 1);
-       mv64x60_write(&base_bh, MV64x60_PCI1_ERR_MASK, 0x00a50c25);
-
-       if (ppc_md.progress)
-               ppc_md.progress("mv64360_init_irq: exit", 0x0);
-}
-
-
-/* mv64360_get_irq()
- *
- *  This function returns the lowest interrupt number of all interrupts that
- *  are currently asserted. 
- *
- * Input Variable(s):
- *  struct pt_regs*    not used
- *
- * Output Variable(s):
- *  None.
- *
- * Returns:
- *  int        <interrupt number> or -2 (bogus interrupt)
- * 
- */
-int
-mv64360_get_irq(struct pt_regs *regs)
-{
-       int irq;
-       int irq_gpp;
-
-#ifdef CONFIG_SMP
-#define BIT28 (1<<28)
-       /* 
-        * Second CPU gets only doorbell (message) interrupts.
-        * The doorbell interrupt is BIT28 in the main interrupt low cause reg.
-        */
-       int cpu_nr = smp_processor_id();
-       if (cpu_nr == 1) {
-               irq = mv64x60_read(&base_bh, MV64360_IC_MAIN_CAUSE_LO);
-               if (!(irq & BIT28))
-                       return -1;
-               return 28;
-       }
-#endif
-
-       irq = mv64x60_read(&base_bh, MV64360_IC_MAIN_CAUSE_LO);
-       irq = __ilog2((irq & 0x3dfffffe) & ppc_cached_irq_mask[0]);
-       if (irq == -1) {
-               irq = mv64x60_read(&base_bh, MV64360_IC_MAIN_CAUSE_HI);
-               irq = __ilog2((irq & 0x1f0003f7) & ppc_cached_irq_mask[1]);
-               if (irq == -1) {
-                       irq = -2;       /* bogus interrupt, should never happen */
-               } else {
-                       if ((irq >= 24) && (irq < 28)) {
-                               irq_gpp =
-                                       mv64x60_read(&base_bh,
-                                               MV64x60_GPP_INTR_CAUSE);
-                               irq_gpp =
-                                       __ilog2(irq_gpp &
-                                       ppc_cached_irq_mask[2]);
-
-                               if (irq_gpp == -1) {
-                                       irq = -2;
-                               } else {
-                                       irq = irq_gpp + 64;
-                                       mv64x60_write(&base_bh,
-                                               MV64x60_GPP_INTR_CAUSE,
-                                               ~(1 << (irq - 64)));
-                               }
-                       } else {
-                               irq += 32;
-                       }
-               }
-       }
-
-       if (irq < 0) {
-               return (irq);
-       } else {
-               return (mv64360_irq_base + irq);
-       }
-}
-
-/* mv64360_unmask_irq()
- *
- *  This function enables an interrupt.
- *
- * Input Variable(s):
- *  unsigned int       interrupt number (IRQ0...IRQ95).
- *
- * Output Variable(s):
- *  None.
- *
- * Returns:
- *  void
- */
-
-static void
-mv64360_unmask_irq(unsigned int irq)
-{
-#ifdef CONFIG_SMP
-       /* second CPU gets only doorbell interrupts */
-       if ((irq - mv64360_irq_base) == 28) {
-               mv64x60_set_bits(&base_bh, MV64360_IC_CPU1_INTR_MASK_LO, BIT28);
-               return;
-       }
-#endif
-       irq -= mv64360_irq_base;
-       if (irq > 31) {
-               if (irq > 63) {
-                       /* unmask GPP irq */
-                       mv64x60_write(&base_bh, MV64x60_GPP_INTR_MASK,
-                               ppc_cached_irq_mask[2] |= (1 << (irq - 64)));
-               } else {
-                       /* mask high interrupt register */
-                       mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_HI,
-                               ppc_cached_irq_mask[1] |= (1 << (irq - 32)));
-               }
-       } else {
-               /* mask low interrupt register */
-               mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_LO,
-                       ppc_cached_irq_mask[0] |= (1 << irq));
-       }
-}
-
-
-/* mv64360_mask_irq()
- *
- *  This function disables the requested interrupt.
- *
- * Input Variable(s):
- *  unsigned int       interrupt number (IRQ0...IRQ95).
- *
- * Output Variable(s):
- *  None.
- *
- * Returns:
- *  void
- */
-
-static void
-mv64360_mask_irq(unsigned int irq)
-{
-#ifdef CONFIG_SMP
-       if ((irq - mv64360_irq_base) == 28) {
-               mv64x60_clr_bits(&base_bh, MV64360_IC_CPU1_INTR_MASK_LO, BIT28);
-               return;
-       }
-#endif
-       irq -= mv64360_irq_base;
-       if (irq > 31) {
-               if (irq > 63) {
-                       /* mask GPP irq */
-                       mv64x60_write(&base_bh, MV64x60_GPP_INTR_MASK,
-                               ppc_cached_irq_mask[2] &= ~(1 << (irq - 64)));
-               } else {
-                       /* mask high interrupt register */
-                       mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_HI,
-                               ppc_cached_irq_mask[1] &= ~(1 << (irq - 32)));
-               }
-       } else {
-               /* mask low interrupt register */
-               mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_LO,
-                       ppc_cached_irq_mask[0] &= ~(1 << irq));
-       }
-
-}
-
-static irqreturn_t
-mv64360_cpu_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
-       u32 val;
-       val = mv64x60_read(&base_bh, MV64x60_CPU_ERR_CAUSE);
-       printk(KERN_ERR
-               "mv64360_cpu_error_int_handler: Error on CPU interface - Cause regiser 0x%08x\n",
-               val);
-       printk(KERN_ERR "\tCPU error register dump:\n");
-       printk(KERN_ERR "\tAddress low  0x%08x\n",
-               mv64x60_read(&base_bh, MV64x60_CPU_ERR_ADDR_LO));
-       printk(KERN_ERR "\tAddress high 0x%08x\n",
-               mv64x60_read(&base_bh, MV64x60_CPU_ERR_ADDR_HI));
-       printk(KERN_ERR "\tData low     0x%08x\n",
-               mv64x60_read(&base_bh, MV64x60_CPU_ERR_DATA_LO));
-       printk(KERN_ERR "\tData high    0x%08x\n",
-               mv64x60_read(&base_bh, MV64x60_CPU_ERR_DATA_HI));
-       printk(KERN_ERR "\tParity       0x%08x\n",
-               mv64x60_read(&base_bh, MV64x60_CPU_ERR_PARITY));
-       mv64x60_write(&base_bh, MV64x60_CPU_ERR_CAUSE, 0);
-       return IRQ_HANDLED;
-}
-
-static irqreturn_t
-mv64360_sram_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
-       printk(KERN_ERR
-               "mv64360_sram_error_int_handler: Error in internal SRAM - Cause register 0x%08x\n",
-               mv64x60_read(&base_bh, MV64360_SRAM_ERR_CAUSE));
-       printk(KERN_ERR "\tSRAM error register dump:\n");
-       printk(KERN_ERR "\tAddress Low  0x%08x\n",
-               mv64x60_read(&base_bh, MV64360_SRAM_ERR_ADDR_LO));
-       printk(KERN_ERR "\tAddress High 0x%08x\n",
-               mv64x60_read(&base_bh, MV64360_SRAM_ERR_ADDR_HI));
-       printk(KERN_ERR "\tData Low     0x%08x\n",
-               mv64x60_read(&base_bh, MV64360_SRAM_ERR_DATA_LO));
-       printk(KERN_ERR "\tData High    0x%08x\n",
-               mv64x60_read(&base_bh, MV64360_SRAM_ERR_DATA_HI));
-       printk(KERN_ERR "\tParity       0x%08x\n",
-               mv64x60_read(&base_bh, MV64360_SRAM_ERR_PARITY));
-       mv64x60_write(&base_bh, MV64360_SRAM_ERR_CAUSE, 0);
-       return IRQ_HANDLED;
-}
-
-static irqreturn_t
-mv64360_pci_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
-       u32 val;
-       unsigned int pci_bus = (unsigned int) dev_id;
-       if (pci_bus == 0) {     /* Error on PCI 0 */
-               val = mv64x60_read(&base_bh, MV64x60_PCI0_ERR_CAUSE);
-               printk(KERN_ERR
-                       "mv64360_pci_error_int_handler: Error in PCI %d Interface\n",
-                       pci_bus);
-               printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
-               printk(KERN_ERR "\tCause register 0x%08x\n", val);
-               printk(KERN_ERR "\tAddress Low    0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI0_ERR_ADDR_LO));
-               printk(KERN_ERR "\tAddress High   0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI0_ERR_ADDR_HI));
-               printk(KERN_ERR "\tAttribute      0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI0_ERR_DATA_LO));
-               printk(KERN_ERR "\tCommand        0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI0_ERR_CMD));
-               mv64x60_write(&base_bh, MV64x60_PCI0_ERR_CAUSE, ~val);
-       }
-       if (pci_bus == 1) {     /* Error on PCI 1 */
-               val = mv64x60_read(&base_bh, MV64x60_PCI1_ERR_CAUSE);
-               printk(KERN_ERR
-                       "mv64360_pci_error_int_handler: Error in PCI %d Interface\n",
-                       pci_bus);
-               printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
-               printk(KERN_ERR "\tCause register 0x%08x\n", val);
-               printk(KERN_ERR "\tAddress Low    0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI1_ERR_ADDR_LO));
-               printk(KERN_ERR "\tAddress High   0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI1_ERR_ADDR_HI));
-               printk(KERN_ERR "\tAttribute      0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI1_ERR_DATA_LO));
-               printk(KERN_ERR "\tCommand        0x%08x\n",
-                       mv64x60_read(&base_bh, MV64x60_PCI1_ERR_CMD));
-               mv64x60_write(&base_bh, MV64x60_PCI1_ERR_CAUSE, ~val);
-       }
-       return IRQ_HANDLED;
-}
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
deleted file mode 100644 (file)
index c31fe53..0000000
+++ /dev/null
@@ -1,2872 +0,0 @@
-/*
- * arch/ppc/syslib/mv64x60.c
- * 
- * Common routines for the Marvell/Galileo Discovery line of host bridges
- * (e.g, gt64260 and mv64360).
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *        Rabeeh Khoury <rabeeh@galileo.co.il>
- *
- * 2001-2002 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/string.h>
-
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mv64x60.h>
-#include <asm/delay.h>
-#include <asm/ocp.h>
-
-
-#undef DEBUG
-
-#ifdef DEBUG
-#define        DBG(x...) printk(x)
-#else
-#define        DBG(x...)
-#endif /* DEBUG */
-
-
-static u32 mv64x60_mask(u32 val, u32 num_bits);
-static u32 mv64x60_shift_left(u32 val, u32 num_bits);
-static u32 mv64x60_shift_right(u32 val, u32 num_bits);
-static void mv64x60_early_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-static int mv64x60_get_type(mv64x60_handle_t *bh);
-static int mv64x60_setup_for_chip(mv64x60_handle_t *bh);
-static void mv64x60_get_mem_windows(mv64x60_handle_t *bh,
-       u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static u32 mv64x60_calc_mem_size(mv64x60_handle_t *bh,
-       u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static void mv64x60_config_cpu2mem_windows(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si, u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static void mv64x60_config_cpu2pci_windows(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si);
-static void mv64x60_set_cpu2pci_window(mv64x60_handle_t *bh,
-       mv64x60_pci_info_t *pi, u32 *win_tab, u32 *remap_tab);
-static void mv64x60_config_pci2mem_windows(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si, u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static void mv64x60_alloc_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-static void mv64x60_init_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-static void mv64x60_init_resources(struct pci_controller *hose,
-       mv64x60_pci_info_t *pi, u32 io_base);
-static void mv64x60_set_pci_params(struct pci_controller *hose,
-       mv64x60_pci_info_t *pi);
-static void mv64x60_enumerate_buses(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si);
-static int mv64x60_pci_exclude_device(u8 bus, u8 devfn);
-static void mv64x60_fixup_ocp(struct ocp_device *, void *arg);
-
-static u32 gt64260_translate_size(u32 base, u32 size, u32 num_bits);
-static u32 gt64260_untranslate_size(u32 base, u32 size, u32 num_bits);
-static void gt64260_set_pci2mem_window(struct pci_controller *hose,
-       u32 window, u32 base);
-static u32 gt64260_is_enabled_32bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_enable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_disable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_enable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_disable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_disable_all_windows(mv64x60_handle_t *bh,
-                                       mv64x60_setup_info_t *si);
-static void gt64260a_chip_specific_init(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si);
-static void gt64260b_chip_specific_init(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si);
-
-static u32 mv64360_translate_size(u32 base_addr, u32 size, u32 num_bits);
-static u32 mv64360_untranslate_size(u32 base_addr, u32 size, u32 num_bits);
-static void mv64360_set_pci2mem_window(struct pci_controller *hose,
-       u32 window, u32 base);
-static u32 mv64360_is_enabled_32bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_enable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_disable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_enable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_disable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_disable_all_windows(mv64x60_handle_t *bh,
-                                       mv64x60_setup_info_t *si);
-static void mv64360_chip_specific_init(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si);
-static void mv64460_chip_specific_init(mv64x60_handle_t *bh,
-       mv64x60_setup_info_t *si);
-
-
-u8     mv64x60_pci_exclude_bridge = TRUE;
-
-spinlock_t mv64x60_lock = SPIN_LOCK_UNLOCKED;
-spinlock_t mv64x60_rmw_lock = SPIN_LOCK_UNLOCKED;
-
-static mv64x60_32bit_window_t gt64260_32bit_windows[] __initdata = {
-       /* CPU->MEM Windows */
-       [MV64x60_CPU2MEM_0_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_0_BASE,
-               .size_reg               = MV64x60_CPU2MEM_0_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2MEM_1_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_1_BASE,
-               .size_reg               = MV64x60_CPU2MEM_1_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2MEM_2_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_2_BASE,
-               .size_reg               = MV64x60_CPU2MEM_2_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2MEM_3_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_3_BASE,
-               .size_reg               = MV64x60_CPU2MEM_3_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->Device Windows */
-       [MV64x60_CPU2DEV_0_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_0_BASE,
-               .size_reg               = MV64x60_CPU2DEV_0_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2DEV_1_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_1_BASE,
-               .size_reg               = MV64x60_CPU2DEV_1_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2DEV_2_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_2_BASE,
-               .size_reg               = MV64x60_CPU2DEV_2_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2DEV_3_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_3_BASE,
-               .size_reg               = MV64x60_CPU2DEV_3_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->Boot Window */
-       [MV64x60_CPU2BOOT_WIN] = {
-               .base_reg               = MV64x60_CPU2BOOT_0_BASE,
-               .size_reg               = MV64x60_CPU2BOOT_0_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->PCI 0 Windows */
-       [MV64x60_CPU2PCI0_IO_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_IO_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_IO_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_0_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_0_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_0_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_1_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_1_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_1_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_2_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_2_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_2_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_3_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_3_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_3_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->PCI 1 Windows */
-       [MV64x60_CPU2PCI1_IO_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_IO_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_IO_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_0_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_0_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_0_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_1_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_1_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_1_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_2_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_2_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_2_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_3_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_3_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_3_SIZE,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->SRAM Window (64260 has no integrated SRAM) */
-       /* CPU->PCI 0 Remap I/O Window */
-       [MV64x60_CPU2PCI0_IO_REMAP_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_IO_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->PCI 1 Remap I/O Window */
-       [MV64x60_CPU2PCI1_IO_REMAP_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_IO_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU Memory Protection Windows */
-       [MV64x60_CPU_PROT_0_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_0,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_0,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU_PROT_1_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_1,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_1,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU_PROT_2_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_2,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_2,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU_PROT_3_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_3,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_3,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU Snoop Windows */
-       [MV64x60_CPU_SNOOP_0_WIN] = {
-               .base_reg               = GT64260_CPU_SNOOP_BASE_0,
-               .size_reg               = GT64260_CPU_SNOOP_SIZE_0,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU_SNOOP_1_WIN] = {
-               .base_reg               = GT64260_CPU_SNOOP_BASE_1,
-               .size_reg               = GT64260_CPU_SNOOP_SIZE_1,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU_SNOOP_2_WIN] = {
-               .base_reg               = GT64260_CPU_SNOOP_BASE_2,
-               .size_reg               = GT64260_CPU_SNOOP_SIZE_2,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU_SNOOP_3_WIN] = {
-               .base_reg               = GT64260_CPU_SNOOP_BASE_3,
-               .size_reg               = GT64260_CPU_SNOOP_SIZE_3,
-               .base_bits              = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* PCI 0->System Memory Remap Windows */
-       [MV64x60_PCI02MEM_REMAP_0_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_0_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_REMAP_1_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_REMAP_2_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_REMAP_3_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       /* PCI 1->System Memory Remap Windows */
-       [MV64x60_PCI12MEM_REMAP_0_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_0_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_REMAP_1_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_REMAP_2_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_REMAP_3_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 20,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-};
-
-static mv64x60_64bit_window_t gt64260_64bit_windows[] __initdata = {
-       /* CPU->PCI 0 MEM Remap Windows */
-       [MV64x60_CPU2PCI0_MEM_0_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_0_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_0_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_1_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_1_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_1_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_2_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_2_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_2_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_3_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_3_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_3_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->PCI 1 MEM Remap Windows */
-       [MV64x60_CPU2PCI1_MEM_0_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_0_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_0_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_1_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_1_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_1_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_2_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_2_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_2_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_3_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_3_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_3_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 12,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* PCI 0->MEM Access Control Windows */
-       [MV64x60_PCI02MEM_ACC_CNTL_0_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_0_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_0_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_0_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_ACC_CNTL_1_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_1_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_1_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_1_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_ACC_CNTL_2_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_2_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_2_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_2_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_ACC_CNTL_3_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_3_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_3_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_3_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* PCI 1->MEM Access Control Windows */
-       [MV64x60_PCI12MEM_ACC_CNTL_0_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_0_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_0_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_0_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_ACC_CNTL_1_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_1_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_1_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_1_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_ACC_CNTL_2_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_2_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_2_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_2_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_ACC_CNTL_3_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_3_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_3_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_3_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* PCI 0->MEM Snoop Windows */
-       [MV64x60_PCI02MEM_SNOOP_0_WIN] = {
-               .base_hi_reg            = GT64260_PCI0_SNOOP_0_BASE_HI,
-               .base_lo_reg            = GT64260_PCI0_SNOOP_0_BASE_LO,
-               .size_reg               = GT64260_PCI0_SNOOP_0_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_SNOOP_1_WIN] = {
-               .base_hi_reg            = GT64260_PCI0_SNOOP_1_BASE_HI,
-               .base_lo_reg            = GT64260_PCI0_SNOOP_1_BASE_LO,
-               .size_reg               = GT64260_PCI0_SNOOP_1_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_SNOOP_2_WIN] = {
-               .base_hi_reg            = GT64260_PCI0_SNOOP_2_BASE_HI,
-               .base_lo_reg            = GT64260_PCI0_SNOOP_2_BASE_LO,
-               .size_reg               = GT64260_PCI0_SNOOP_2_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_SNOOP_3_WIN] = {
-               .base_hi_reg            = GT64260_PCI0_SNOOP_3_BASE_HI,
-               .base_lo_reg            = GT64260_PCI0_SNOOP_3_BASE_LO,
-               .size_reg               = GT64260_PCI0_SNOOP_3_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* PCI 1->MEM Snoop Windows */
-       [MV64x60_PCI12MEM_SNOOP_0_WIN] = {
-               .base_hi_reg            = GT64260_PCI1_SNOOP_0_BASE_HI,
-               .base_lo_reg            = GT64260_PCI1_SNOOP_0_BASE_LO,
-               .size_reg               = GT64260_PCI1_SNOOP_0_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_SNOOP_1_WIN] = {
-               .base_hi_reg            = GT64260_PCI1_SNOOP_1_BASE_HI,
-               .base_lo_reg            = GT64260_PCI1_SNOOP_1_BASE_LO,
-               .size_reg               = GT64260_PCI1_SNOOP_1_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_SNOOP_2_WIN] = {
-               .base_hi_reg            = GT64260_PCI1_SNOOP_2_BASE_HI,
-               .base_lo_reg            = GT64260_PCI1_SNOOP_2_BASE_LO,
-               .size_reg               = GT64260_PCI1_SNOOP_2_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_SNOOP_3_WIN] = {
-               .base_hi_reg            = GT64260_PCI1_SNOOP_3_BASE_HI,
-               .base_lo_reg            = GT64260_PCI1_SNOOP_3_BASE_LO,
-               .size_reg               = GT64260_PCI1_SNOOP_3_SIZE,
-               .base_lo_bits           = 12,
-               .size_bits              = 12,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-};
-
-static mv64x60_chip_info_t gt64260a_ci __initdata = {
-       .translate_size         = gt64260_translate_size,
-       .untranslate_size       = gt64260_untranslate_size,
-       .set_pci2mem_window     = gt64260_set_pci2mem_window,
-       .is_enabled_32bit       = gt64260_is_enabled_32bit,
-       .enable_window_32bit    = gt64260_enable_window_32bit,
-       .disable_window_32bit   = gt64260_disable_window_32bit,
-       .enable_window_64bit    = gt64260_enable_window_64bit,
-       .disable_window_64bit   = gt64260_disable_window_64bit,
-       .disable_all_windows    = gt64260_disable_all_windows,
-       .chip_specific_init     = gt64260a_chip_specific_init,
-       .window_tab_32bit       = gt64260_32bit_windows,
-       .window_tab_64bit       = gt64260_64bit_windows,
-};
-
-static mv64x60_chip_info_t gt64260b_ci __initdata = {
-       .translate_size         = gt64260_translate_size,
-       .untranslate_size       = gt64260_untranslate_size,
-       .set_pci2mem_window     = gt64260_set_pci2mem_window,
-       .is_enabled_32bit       = gt64260_is_enabled_32bit,
-       .enable_window_32bit    = gt64260_enable_window_32bit,
-       .disable_window_32bit   = gt64260_disable_window_32bit,
-       .enable_window_64bit    = gt64260_enable_window_64bit,
-       .disable_window_64bit   = gt64260_disable_window_64bit,
-       .disable_all_windows    = gt64260_disable_all_windows,
-       .chip_specific_init     = gt64260b_chip_specific_init,
-       .window_tab_32bit       = gt64260_32bit_windows,
-       .window_tab_64bit       = gt64260_64bit_windows,
-};
-
-
-static mv64x60_32bit_window_t mv64360_32bit_windows[] __initdata = {
-       /* CPU->MEM Windows */
-       [MV64x60_CPU2MEM_0_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_0_BASE,
-               .size_reg               = MV64x60_CPU2MEM_0_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2MEM_1_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_1_BASE,
-               .size_reg               = MV64x60_CPU2MEM_1_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 1 },
-       [MV64x60_CPU2MEM_2_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_2_BASE,
-               .size_reg               = MV64x60_CPU2MEM_2_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 2 },
-       [MV64x60_CPU2MEM_3_WIN] = {
-               .base_reg               = MV64x60_CPU2MEM_3_BASE,
-               .size_reg               = MV64x60_CPU2MEM_3_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 3 },
-       /* CPU->Device Windows */
-       [MV64x60_CPU2DEV_0_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_0_BASE,
-               .size_reg               = MV64x60_CPU2DEV_0_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 4 },
-       [MV64x60_CPU2DEV_1_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_1_BASE,
-               .size_reg               = MV64x60_CPU2DEV_1_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 5 },
-       [MV64x60_CPU2DEV_2_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_2_BASE,
-               .size_reg               = MV64x60_CPU2DEV_2_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 6 },
-       [MV64x60_CPU2DEV_3_WIN] = {
-               .base_reg               = MV64x60_CPU2DEV_3_BASE,
-               .size_reg               = MV64x60_CPU2DEV_3_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 7 },
-       /* CPU->Boot Window */
-       [MV64x60_CPU2BOOT_WIN] = {
-               .base_reg               = MV64x60_CPU2BOOT_0_BASE,
-               .size_reg               = MV64x60_CPU2BOOT_0_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 8 },
-       /* CPU->PCI 0 Windows */
-       [MV64x60_CPU2PCI0_IO_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_IO_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_IO_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 9 },
-       [MV64x60_CPU2PCI0_MEM_0_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_0_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_0_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 10 },
-       [MV64x60_CPU2PCI0_MEM_1_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_1_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_1_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 11 },
-       [MV64x60_CPU2PCI0_MEM_2_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_2_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_2_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 12 },
-       [MV64x60_CPU2PCI0_MEM_3_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_MEM_3_BASE,
-               .size_reg               = MV64x60_CPU2PCI0_MEM_3_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 13 },
-       /* CPU->PCI 1 Windows */
-       [MV64x60_CPU2PCI1_IO_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_IO_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_IO_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 14 },
-       [MV64x60_CPU2PCI1_MEM_0_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_0_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_0_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 15 },
-       [MV64x60_CPU2PCI1_MEM_1_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_1_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_1_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 16 },
-       [MV64x60_CPU2PCI1_MEM_2_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_2_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_2_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 17 },
-       [MV64x60_CPU2PCI1_MEM_3_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_MEM_3_BASE,
-               .size_reg               = MV64x60_CPU2PCI1_MEM_3_SIZE,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 18 },
-       /* CPU->SRAM Window */
-       [MV64x60_CPU2SRAM_WIN] = {
-               .base_reg               = MV64360_CPU2SRAM_BASE,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 19 },
-       /* CPU->PCI 0 Remap I/O Window */
-       [MV64x60_CPU2PCI0_IO_REMAP_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI0_IO_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->PCI 1 Remap I/O Window */
-       [MV64x60_CPU2PCI1_IO_REMAP_WIN] = {
-               .base_reg               = MV64x60_CPU2PCI1_IO_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU Memory Protection Windows */
-       [MV64x60_CPU_PROT_0_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_0,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_0,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0x80000000 | 31 },
-       [MV64x60_CPU_PROT_1_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_1,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_1,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0x80000000 | 31 },
-       [MV64x60_CPU_PROT_2_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_2,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_2,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0x80000000 | 31 },
-       [MV64x60_CPU_PROT_3_WIN] = {
-               .base_reg               = MV64x60_CPU_PROT_BASE_3,
-               .size_reg               = MV64x60_CPU_PROT_SIZE_3,
-               .base_bits              = 16,
-               .size_bits              = 16,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0x80000000 | 31 },
-       /* CPU Snoop Windows -- don't exist on 64360 */
-       /* PCI 0->System Memory Remap Windows */
-       [MV64x60_PCI02MEM_REMAP_0_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_0_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_REMAP_1_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_REMAP_2_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI02MEM_REMAP_3_WIN] = {
-               .base_reg               = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       /* PCI 1->System Memory Remap Windows */
-       [MV64x60_PCI12MEM_REMAP_0_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_0_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_REMAP_1_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_REMAP_2_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-       [MV64x60_PCI12MEM_REMAP_3_WIN] = {
-               .base_reg               = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
-               .size_reg               = 0,
-               .base_bits              = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0 },
-};
-
-static mv64x60_64bit_window_t mv64360_64bit_windows[MV64x60_64BIT_WIN_COUNT]
-                                                               __initdata = {
-       /* CPU->PCI 0 MEM Remap Windows */
-       [MV64x60_CPU2PCI0_MEM_0_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_0_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_0_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_1_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_1_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_1_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_2_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_2_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_2_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI0_MEM_3_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI0_MEM_3_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI0_MEM_3_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* CPU->PCI 1 MEM Remap Windows */
-       [MV64x60_CPU2PCI1_MEM_0_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_0_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_0_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_1_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_1_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_1_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_2_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_2_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_2_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       [MV64x60_CPU2PCI1_MEM_3_REMAP_WIN] = {
-               .base_hi_reg            = MV64x60_CPU2PCI1_MEM_3_REMAP_HI,
-               .base_lo_reg            = MV64x60_CPU2PCI1_MEM_3_REMAP_LO,
-               .size_reg               = 0,
-               .base_lo_bits           = 16,
-               .size_bits              = 0,
-               .get_from_field         = mv64x60_shift_left,
-               .map_to_field           = mv64x60_shift_right,
-               .extra                  = 0 },
-       /* PCI 0->MEM Access Control Windows */
-       [MV64x60_PCI02MEM_ACC_CNTL_0_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_0_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_0_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_0_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       [MV64x60_PCI02MEM_ACC_CNTL_1_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_1_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_1_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_1_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       [MV64x60_PCI02MEM_ACC_CNTL_2_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_2_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_2_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_2_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       [MV64x60_PCI02MEM_ACC_CNTL_3_WIN] = {
-               .base_hi_reg            = MV64x60_PCI0_ACC_CNTL_3_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI0_ACC_CNTL_3_BASE_LO,
-               .size_reg               = MV64x60_PCI0_ACC_CNTL_3_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       /* PCI 1->MEM Access Control Windows */
-       [MV64x60_PCI12MEM_ACC_CNTL_0_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_0_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_0_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_0_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       [MV64x60_PCI12MEM_ACC_CNTL_1_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_1_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_1_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_1_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       [MV64x60_PCI12MEM_ACC_CNTL_2_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_2_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_2_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_2_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       [MV64x60_PCI12MEM_ACC_CNTL_3_WIN] = {
-               .base_hi_reg            = MV64x60_PCI1_ACC_CNTL_3_BASE_HI,
-               .base_lo_reg            = MV64x60_PCI1_ACC_CNTL_3_BASE_LO,
-               .size_reg               = MV64x60_PCI1_ACC_CNTL_3_SIZE,
-               .base_lo_bits           = 20,
-               .size_bits              = 20,
-               .get_from_field         = mv64x60_mask,
-               .map_to_field           = mv64x60_mask,
-               .extra                  = 0x80000000 | 0 },
-       /* PCI 0->MEM Snoop Windows -- don't exist on 64360 */
-       /* PCI 1->MEM Snoop Windows -- don't exist on 64360 */
-};
-
-static mv64x60_chip_info_t mv64360_ci __initdata = {
-       .translate_size         = mv64360_translate_size,
-       .untranslate_size       = mv64360_untranslate_size,
-       .set_pci2mem_window     = mv64360_set_pci2mem_window,
-       .is_enabled_32bit       = mv64360_is_enabled_32bit,
-       .enable_window_32bit    = mv64360_enable_window_32bit,
-       .disable_window_32bit   = mv64360_disable_window_32bit,
-       .enable_window_64bit    = mv64360_enable_window_64bit,
-       .disable_window_64bit   = mv64360_disable_window_64bit,
-       .disable_all_windows    = mv64360_disable_all_windows,
-       .chip_specific_init     = mv64360_chip_specific_init,
-       .window_tab_32bit       = mv64360_32bit_windows,
-       .window_tab_64bit       = mv64360_64bit_windows,
-};
-
-static mv64x60_chip_info_t mv64460_ci __initdata = {
-       .translate_size         = mv64360_translate_size,
-       .untranslate_size       = mv64360_untranslate_size,
-       .set_pci2mem_window     = mv64360_set_pci2mem_window,
-       .is_enabled_32bit       = mv64360_is_enabled_32bit,
-       .enable_window_32bit    = mv64360_enable_window_32bit,
-       .disable_window_32bit   = mv64360_disable_window_32bit,
-       .enable_window_64bit    = mv64360_enable_window_64bit,
-       .disable_window_64bit   = mv64360_disable_window_64bit,
-       .disable_all_windows    = mv64360_disable_all_windows,
-       .chip_specific_init     = mv64460_chip_specific_init,
-       .window_tab_32bit       = mv64360_32bit_windows,
-       .window_tab_64bit       = mv64360_64bit_windows,
-};
-
-
-/*
- *****************************************************************************
- *
- *     Bridge Initialization Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_init()
- *
- * Initialze the bridge based on setting passed in via 'si'.  The bridge
- * handle, 'bh', will be set so that it can be used to make subsequent
- * calls to routines in this file.
- */
-int __init
-mv64x60_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       u32     mem_windows[MV64x60_CPU2MEM_WINDOWS][2];
-       int     rc = 0;
-
-       if (ppc_md.progress)
-               ppc_md.progress("mv64x60_init: Enter", 0x0);
-
-       mv64x60_early_init(bh, si);
-       mv64x60_alloc_hoses(bh, si); /* Allocate pci hose structures */
-       if (mv64x60_get_type(bh))
-               return -1;
-
-       if (mv64x60_setup_for_chip(bh) != 0) {
-               iounmap((void *)bh->v_base);
-
-               if (ppc_md.progress)
-                       ppc_md.progress("mv64x60_init: Exit--error", 0x0);
-               return -1;
-       }
-
-       bh->ci->disable_all_windows(bh, si); /* Disable windows except mem ctlr */
-       mv64x60_config_cpu2pci_windows(bh, si); /* Init CPU->PCI windows */
-       mv64x60_get_mem_windows(bh, mem_windows); /* Read mem ctlr regs */
-       mv64x60_config_cpu2mem_windows(bh, si, mem_windows); /* CPU->MEM setup*/
-       mv64x60_config_pci2mem_windows(bh, si, mem_windows); /* PCI->Sys MEM */
-       mv64x60_init_hoses(bh, si); /* Init hose structs & PCI params */
-       bh->ci->chip_specific_init(bh, si);
-       mv64x60_enumerate_buses(bh, si); /* Enumerate PCI buses */
-       ocp_for_each_device(mv64x60_fixup_ocp, (void *)bh);
-
-       if (ppc_md.progress)
-               ppc_md.progress("mv64x60_init: Exit", 0x0);
-
-       return rc;
-} /* mv64x60_init() */
-
-/*
- *****************************************************************************
- *
- *     Pre-Bridge-Init Routines (Externally Visible)
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_mem_size()
- *
- * Calculate the amount of memory that the memory controller is set up for.
- * This should only be used by board-specific code if there is no other
- * way to determine the amount of memory in the system.
- */
-u32 __init
-mv64x60_get_mem_size(u32 bridge_base, u32 chip_type)
-{
-       mv64x60_handle_t        bh;
-       u32                     mem_windows[MV64x60_CPU2MEM_WINDOWS][2];
-
-       memset(&bh, 0, sizeof(bh));
-
-       bh.type = chip_type;
-       bh.p_base = bridge_base;
-       bh.v_base = bridge_base;
-
-       (void)mv64x60_setup_for_chip(&bh);
-       mv64x60_get_mem_windows(&bh, mem_windows);
-       return mv64x60_calc_mem_size(&bh, mem_windows);
-}
-
-/*
- *****************************************************************************
- *
- *     Window Config Routines (Externally Visible)
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_32bit_window()
- *
- * Determine the base address and size of a 32-bit window on the bridge.
- */
-void __init
-mv64x60_get_32bit_window(mv64x60_handle_t *bh, u32 window, u32 *base, u32 *size)
-{
-       u32     val, base_reg, size_reg, base_bits, size_bits;
-       u32     (*get_from_field)(u32 val, u32 num_bits);
-
-       base_reg  = bh->ci->window_tab_32bit[window].base_reg;
-
-       if (base_reg != 0) {
-               size_reg  = bh->ci->window_tab_32bit[window].size_reg;
-               base_bits = bh->ci->window_tab_32bit[window].base_bits;
-               size_bits = bh->ci->window_tab_32bit[window].size_bits;
-               get_from_field= bh->ci->window_tab_32bit[window].get_from_field;
-
-               val = mv64x60_read(bh, base_reg);
-               *base = get_from_field(val, base_bits);
-
-               if (size_reg != 0) {
-                       val = mv64x60_read(bh, size_reg);
-                       val = get_from_field(val, size_bits);
-                       *size = bh->ci->untranslate_size(*base, val, size_bits);
-               }
-               else {
-                       *size = 0;
-               }
-       }
-       else {
-               *base = 0;
-               *size = 0;
-       }
-
-       DBG("get 32bit window: %d, base: 0x%x, size: 0x%x\n",
-               window, *base, *size);
-
-       return;
-}
-
-/*
- * mv64x60_set_32bit_window()
- *
- * Set the base address and size of a 32-bit window on the bridge.
- */
-void __init
-mv64x60_set_32bit_window(mv64x60_handle_t *bh, u32 window, u32 base, u32 size,
-                                                               u32 other_bits)
-{
-       u32     val, base_reg, size_reg, base_bits, size_bits;
-       u32     (*map_to_field)(u32 val, u32 num_bits);
-
-       DBG("set 32bit window: %d, base: 0x%x, size: 0x%x, other: 0x%x\n",
-               window, base, size, other_bits);
-
-       base_reg  = bh->ci->window_tab_32bit[window].base_reg;
-
-       if (base_reg != 0) {
-               size_reg  = bh->ci->window_tab_32bit[window].size_reg;
-               base_bits = bh->ci->window_tab_32bit[window].base_bits;
-               size_bits = bh->ci->window_tab_32bit[window].size_bits;
-               map_to_field = bh->ci->window_tab_32bit[window].map_to_field;
-
-               val = map_to_field(base, base_bits) | other_bits;
-               mv64x60_write(bh, base_reg, val);
-
-               if (size_reg != 0) {
-                       val = bh->ci->translate_size(base, size, size_bits);
-                       val = map_to_field(val, size_bits);
-                       mv64x60_write(bh, size_reg, val);
-               }
-               (void)mv64x60_read(bh, base_reg); /* Flush FIFO */
-       }
-
-       return;
-}
-
-/*
- * mv64x60_get_64bit_window()
- *
- * Determine the base address and size of a 64-bit window on the bridge.
- */
-void __init
-mv64x60_get_64bit_window(mv64x60_handle_t *bh, u32 window, u32 *base_hi,
-                                                       u32 *base_lo, u32 *size)
-{
-       u32     val, base_lo_reg, size_reg, base_lo_bits, size_bits;
-       u32     (*get_from_field)(u32 val, u32 num_bits);
-
-       base_lo_reg = bh->ci->window_tab_64bit[window].base_lo_reg;
-
-       if (base_lo_reg != 0) {
-               size_reg = bh->ci->window_tab_64bit[window].size_reg;
-               base_lo_bits = bh->ci->window_tab_64bit[window].base_lo_bits;
-               size_bits = bh->ci->window_tab_64bit[window].size_bits;
-               get_from_field= bh->ci->window_tab_64bit[window].get_from_field;
-
-               *base_hi = mv64x60_read(bh, 
-                       bh->ci->window_tab_64bit[window].base_hi_reg);
-
-               val = mv64x60_read(bh, base_lo_reg);
-               *base_lo = get_from_field(val, base_lo_bits);
-
-               if (size_reg != 0) {
-                       val = mv64x60_read(bh, size_reg);
-                       val = get_from_field(val, size_bits);
-                       *size = bh->ci->untranslate_size(*base_lo, val,
-                                                               size_bits);
-               }
-               else {
-                       *size = 0;
-               }
-       }
-       else {
-               *base_hi = 0;
-               *base_lo = 0;
-               *size = 0;
-       }
-
-       DBG("get 64bit window: %d, base hi: 0x%x, base lo: 0x%x, size: 0x%x\n",
-               window, *base_hi, *base_lo, *size);
-
-       return;
-}
-
-/*
- * mv64x60_set_64bit_window()
- *
- * Set the base address and size of a 64-bit window on the bridge.
- */
-void __init
-mv64x60_set_64bit_window(mv64x60_handle_t *bh, u32 window,
-                       u32 base_hi, u32 base_lo, u32 size, u32 other_bits)
-{
-       u32     val, base_lo_reg, size_reg, base_lo_bits, size_bits;
-       u32     (*map_to_field)(u32 val, u32 num_bits);
-
-       DBG("set 64bit window: %d, base hi: 0x%x, base lo: 0x%x, " \
-               "size: 0x%x, other: 0x%x\n",
-               window, base_hi, base_lo, size, other_bits);
-
-       base_lo_reg = bh->ci->window_tab_64bit[window].base_lo_reg;
-
-       if (base_lo_reg != 0) {
-               size_reg = bh->ci->window_tab_64bit[window].size_reg;
-               base_lo_bits = bh->ci->window_tab_64bit[window].base_lo_bits;
-               size_bits = bh->ci->window_tab_64bit[window].size_bits;
-               map_to_field = bh->ci->window_tab_64bit[window].map_to_field;
-
-               mv64x60_write(bh, bh->ci->window_tab_64bit[window].base_hi_reg,
-                       base_hi);
-
-               val = map_to_field(base_lo, base_lo_bits) | other_bits;
-               mv64x60_write(bh, base_lo_reg, val);
-
-               if (size_reg != 0) {
-                       val = bh->ci->translate_size(base_lo, size, size_bits);
-                       val = map_to_field(val, size_bits);
-                       mv64x60_write(bh, size_reg, val);
-               }
-
-               (void)mv64x60_read(bh, base_lo_reg); /* Flush FIFO */
-       }
-
-       return;
-}
-
-/*
- * mv64x60_mask()
- *
- * Take the high-order 'num_bits' of 'val' & mask off low bits.
- */
-static u32 __init
-mv64x60_mask(u32 val, u32 num_bits)
-{
-       DBG("mask val: 0x%x, num_bits: %d == 0x%x\n", val,
-               num_bits, val & (0xffffffff << (32 - num_bits)));
-
-       return val & (0xffffffff << (32 - num_bits));
-}
-
-/*
- * mv64x60_mask_shift_left()
- *
- * Take the low-order 'num_bits' of 'val', shift left to align at bit 31 (MSB).
- */
-static u32 __init
-mv64x60_shift_left(u32 val, u32 num_bits)
-{
-       DBG("shift left val: 0x%x, num_bits: %d == 0x%x\n", val,
-               num_bits, val << (32 - num_bits));
-
-       return val << (32 - num_bits);
-}
-
-/*
- * mv64x60_shift_right()
- *
- * Take the high-order 'num_bits' of 'val', shift right to align at bit 0 (LSB).
- */
-static u32 __init
-mv64x60_shift_right(u32 val, u32 num_bits)
-{
-       DBG("shift right val: 0x%x, num_bits: %d == 0x%x\n", val, num_bits,
-               val >> (32 - num_bits));
-
-       return val >> (32 - num_bits);
-}
-
-/*
- *****************************************************************************
- *
- *     Early Init Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_early_init()
- *
- * Do some bridge work that must take place before we start messing with
- * the bridge for real.
- */
-static void __init
-mv64x60_early_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       memset(bh, 0, sizeof(*bh));
-
-       bh->p_base = si->phys_reg_base;
-       bh->v_base = (u32)ioremap(bh->p_base, MV64x60_INTERNAL_SPACE_SIZE);
-       bh->base_irq = si->base_irq;
-
-       /* Bit 12 MUST be 0; set bit 27--don't auto-update cpu remap regs */
-       mv64x60_clr_bits(bh, MV64x60_CPU_CONFIG, (1<<12));
-       mv64x60_set_bits(bh, MV64x60_CPU_CONFIG, (1<<27));
-
-       /*
-        * Turn off timer/counters.  Not turning off watchdog timer because
-        * can't read its reg on the 64260A so don't know if we'll be enabling
-        * or disabling.
-        */
-       mv64x60_clr_bits(bh, MV64x60_TIMR_CNTR_0_3_CNTL,
-                       ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
-
-#ifdef CONFIG_GT64260
-       mv64x60_clr_bits(bh, GT64260_TIMR_CNTR_4_7_CNTL,
-                       ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
-#endif
-
-#if 0
-XXXX Put in PCI_x_RETRY adjustment XXXX
-#endif
-
-       return;
-}
-
-/*
- *****************************************************************************
- *
- *     Chip Identification Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_type()
- *
- * Determine the type of bridge chip we have.
- */
-static int __init mv64x60_get_type(struct mv64x60_handle *bh)
-{
-       struct pci_controller *hose = bh->hose_a;
-       int pcidev;
-       int devfn;
-       u16 val;
-       u8 save_exclude;
-
-       pcidev = (mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG) >> 24) & 0xf;
-       devfn = PCI_DEVFN(pcidev, 0); 
-
-       save_exclude = mv64x60_pci_exclude_bridge;
-       mv64x60_pci_exclude_bridge = FALSE;
-
-       /* Sanity check of bridge's Vendor ID */
-       early_read_config_word(hose, 0, devfn, PCI_VENDOR_ID, &val);
-
-       if (val != PCI_VENDOR_ID_MARVELL)
-               return -1;
-
-       /* Figure out the type of Marvell bridge it is */
-       early_read_config_word(hose, 0, devfn, PCI_DEVICE_ID, &val);
-
-       switch (val) {
-       case PCI_DEVICE_ID_MARVELL_GT64260:
-               early_read_config_word(hose, 0, devfn,
-                                      PCI_CLASS_REVISION, &val);
-
-               switch (val & 0xff) {
-               case GT64260_REV_A:
-                       bh->type = MV64x60_TYPE_GT64260A;
-                       break;
-               case GT64260_REV_B:
-                       bh->type = MV64x60_TYPE_GT64260B;
-                       break;
-               }
-               break;
-
-       case PCI_DEVICE_ID_MARVELL_MV64360:
-               /* Marvell won't tell me how to distinguish a 64361 & 64362 */
-               bh->type = MV64x60_TYPE_MV64360;
-               break;
-
-       case PCI_DEVICE_ID_MARVELL_MV64460:
-               bh->type = MV64x60_TYPE_MV64460;
-               break;
-
-       default:
-               printk(KERN_CRIT "Unknown Marvell bridge type %04x\n", val);
-               return -1;
-       }
-
-       mv64x60_pci_exclude_bridge = save_exclude;
-       return 0;
-}
-
-/*
- * mv64x60_setup_for_chip()
- *
- * Set 'bh' to use the proper set of routine for the bridge chip that we have.
- */
-static int __init
-mv64x60_setup_for_chip(mv64x60_handle_t *bh)
-{
-       int     rc = 0;
-
-       /* Set up chip-specific info based on the chip/bridge type */
-       switch(bh->type) {
-               case MV64x60_TYPE_GT64260A:
-                       bh->ci = &gt64260a_ci;
-                       break;
-
-               case MV64x60_TYPE_GT64260B:
-                       bh->ci = &gt64260b_ci;
-                       break;
-
-               case MV64x60_TYPE_MV64360:
-                       bh->ci = &mv64360_ci;
-                       break;
-
-#if 0 /* Marvell won't tell me how to distinguish--MAG */
-               case MV64x60_TYPE_MV64361:
-               case MV64x60_TYPE_MV64362:
-#endif
-               case MV64x60_TYPE_MV64460:
-                       bh->ci = &mv64460_ci;
-                       break;
-
-               case MV64x60_TYPE_INVALID:
-               default:
-                       if (ppc_md.progress)
-                               ppc_md.progress("mv64x60: Unsupported bridge",
-                                                                       0x0);
-                       printk("mv64x60: Unsupported bridge\n");
-                       rc = -1;
-       }
-
-       return rc;
-}
-
-/*
- *****************************************************************************
- *
- *     System Memory Window Related Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_mem_windows()
- *
- * Get the values in the memory controller & return in the 'mem_windows' array.
- */
-static void __init
-mv64x60_get_mem_windows(mv64x60_handle_t *bh,
-       u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
-       u32     i;
-       u32     windows[] = { MV64x60_CPU2MEM_0_WIN, MV64x60_CPU2MEM_1_WIN,
-                               MV64x60_CPU2MEM_2_WIN, MV64x60_CPU2MEM_3_WIN };
-
-       for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
-               if (bh->ci->is_enabled_32bit(bh, i)) {
-                       mv64x60_get_32bit_window(bh, windows[i],
-                               &mem_windows[i][0], &mem_windows[i][1]);
-               }
-               else {
-                       mem_windows[i][0] = 0;
-                       mem_windows[i][1] = 0;
-               }
-       }
-
-       return;
-}
-
-/*
- * mv64x60_calc_mem_size()
- *
- * Using the memory controller register values in 'mem_windows', determine
- * how much memory it is set up for.
- */
-static u32 __init
-mv64x60_calc_mem_size(mv64x60_handle_t *bh,
-       u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
-       u32     i, total = 0;
-
-       for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
-               total += mem_windows[i][1];
-       }
-
-       return total;
-}
-
-/*
- *****************************************************************************
- *
- *     CPU->System MEM Config Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_config_cpu2mem_windows()
- *
- * Configure CPU->Memory windows on the bridge.
- */
-static void __init
-mv64x60_config_cpu2mem_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si,
-       u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
-       u32     i;
-       u32     prot_windows[] = {
-                       MV64x60_CPU_PROT_0_WIN, MV64x60_CPU_PROT_1_WIN,
-                       MV64x60_CPU_PROT_2_WIN, MV64x60_CPU_PROT_3_WIN };
-       u32     cpu_snoop_windows[] = {
-                       MV64x60_CPU_SNOOP_0_WIN, MV64x60_CPU_SNOOP_1_WIN,
-                       MV64x60_CPU_SNOOP_2_WIN, MV64x60_CPU_SNOOP_3_WIN };
-
-       /* Set CPU protection & snoop windows */
-       for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
-               if (bh->ci->is_enabled_32bit(bh, i)) {
-                       mv64x60_set_32bit_window(bh, prot_windows[i],
-                               mem_windows[i][0], mem_windows[i][1],
-                               si->cpu_prot_options[i]);
-                       bh->ci->enable_window_32bit(bh, prot_windows[i]);
-
-                       if (bh->ci->window_tab_32bit[cpu_snoop_windows[i]].
-                                                               base_reg != 0) {
-                               mv64x60_set_32bit_window(bh,
-                                       cpu_snoop_windows[i], mem_windows[i][0],
-                                       mem_windows[i][1],
-                                       si->cpu_snoop_options[i]);
-                               bh->ci->enable_window_32bit(bh,
-                                       cpu_snoop_windows[i]);
-                       }
-
-               }
-       }
-
-       return;
-}
-
-/*
- *****************************************************************************
- *
- *     CPU->PCI Config Routines
- *
- *****************************************************************************
- */
-
-/*
- * mv64x60_config_cpu2pci_windows()
- *
- * Configure the CPU->PCI windows on the bridge.
- */
-static void __init
-mv64x60_config_cpu2pci_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       if (ppc_md.progress)
-               ppc_md.progress("mv64x60_config_bridge: Enter", 0x0);
-
-       /*
-        * Set up various parts of the bridge including CPU->PCI windows.
-        * Depending on the board, there may be only one hose that needs to
-        * be set up.
-        */
-       if (si->pci_0.enable_bus) {
-               u32     win_tab[] = { MV64x60_CPU2PCI0_IO_WIN,
-                               MV64x60_CPU2PCI0_MEM_0_WIN,
-                               MV64x60_CPU2PCI0_MEM_1_WIN,
-                               MV64x60_CPU2PCI0_MEM_2_WIN };
-               u32     remap_tab[] = { MV64x60_CPU2PCI0_IO_REMAP_WIN,
-                               MV64x60_CPU2PCI0_MEM_0_REMAP_WIN,
-                               MV64x60_CPU2PCI0_MEM_1_REMAP_WIN,
-                               MV64x60_CPU2PCI0_MEM_2_REMAP_WIN };
-
-               mv64x60_set_cpu2pci_window(bh, &si->pci_0, win_tab, remap_tab);
-       }
-
-       if (si->pci_1.enable_bus) {
-               u32     win_tab[] = { MV64x60_CPU2PCI1_IO_WIN,
-                               MV64x60_CPU2PCI1_MEM_0_WIN,
-                               MV64x60_CPU2PCI1_MEM_1_WIN,
-                               MV64x60_CPU2PCI1_MEM_2_WIN };
-               u32     remap_tab[] = { MV64x60_CPU2PCI1_IO_REMAP_WIN,
-                               MV64x60_CPU2PCI1_MEM_0_REMAP_WIN,
-                               MV64x60_CPU2PCI1_MEM_1_REMAP_WIN,
-                               MV64x60_CPU2PCI1_MEM_2_REMAP_WIN };
-
-               mv64x60_set_cpu2pci_window(bh, &si->pci_1, win_tab, remap_tab);
-       }
-
-       return;
-} /* mv64x60_config_bridge() */
-
-/*
- * mv64x60_set_cpu2pci_window()
- *
- * Configure the CPU->PCI windows for one of the PCI buses.
- */
-static void __init
-mv64x60_set_cpu2pci_window(mv64x60_handle_t *bh, mv64x60_pci_info_t *pi,
-                                               u32 *win_tab, u32 *remap_tab)
-{
-       int     i;
-
-       if (pi->pci_io.size > 0) {
-               mv64x60_set_32bit_window(bh, win_tab[0], pi->pci_io.cpu_base,
-                                       pi->pci_io.size, pi->pci_io.swap);
-               mv64x60_set_32bit_window(bh, remap_tab[0],
-                                       pi->pci_io.pci_base_lo, 0, 0);
-               bh->ci->enable_window_32bit(bh, win_tab[0]);
-       }
-       else { /* Actually, the window should already be disabled */
-               bh->ci->disable_window_32bit(bh, win_tab[0]);
-       }
-
-       for (i=0; i<3; i++) {
-               if (pi->pci_mem[i].size > 0) {
-                       mv64x60_set_32bit_window(bh, win_tab[i+1],
-                               pi->pci_mem[i].cpu_base, pi->pci_mem[i].size,
-                               pi->pci_mem[i].swap);
-                       mv64x60_set_64bit_window(bh, remap_tab[i+1],
-                               pi->pci_mem[i].pci_base_hi,
-                               pi->pci_mem[i].pci_base_lo, 0, 0);
-                       bh->ci->enable_window_32bit(bh, win_tab[i+1]);
-               }
-               else { /* Actually, the window should already be disabled */
-                       bh->ci->disable_window_32bit(bh, win_tab[i+1]);
-               }
-       }
-
-       return;
-}
-
-/*
- *****************************************************************************
- *
- *     PCI->System MEM Config Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_config_pci2mem_windows()
- *
- * Configure the PCI->Memory windows on the bridge.
- */
-static void __init
-mv64x60_config_pci2mem_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si,
-       u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
-       u32     i;
-       u32     pci_0_acc_windows[] = {
-                       MV64x60_PCI02MEM_ACC_CNTL_0_WIN,
-                       MV64x60_PCI02MEM_ACC_CNTL_1_WIN,
-                       MV64x60_PCI02MEM_ACC_CNTL_2_WIN,
-                       MV64x60_PCI02MEM_ACC_CNTL_3_WIN };
-       u32     pci_1_acc_windows[] = {
-                       MV64x60_PCI12MEM_ACC_CNTL_0_WIN,
-                       MV64x60_PCI12MEM_ACC_CNTL_1_WIN,
-                       MV64x60_PCI12MEM_ACC_CNTL_2_WIN,
-                       MV64x60_PCI12MEM_ACC_CNTL_3_WIN };
-       u32     pci_0_snoop_windows[] = {
-                       MV64x60_PCI02MEM_SNOOP_0_WIN,
-                       MV64x60_PCI02MEM_SNOOP_1_WIN,
-                       MV64x60_PCI02MEM_SNOOP_2_WIN,
-                       MV64x60_PCI02MEM_SNOOP_3_WIN };
-       u32     pci_1_snoop_windows[] = {
-                       MV64x60_PCI12MEM_SNOOP_0_WIN,
-                       MV64x60_PCI12MEM_SNOOP_1_WIN,
-                       MV64x60_PCI12MEM_SNOOP_2_WIN,
-                       MV64x60_PCI12MEM_SNOOP_3_WIN };
-       u32     pci_0_size[] = {
-                       MV64x60_PCI0_MEM_0_SIZE, MV64x60_PCI0_MEM_1_SIZE,
-                       MV64x60_PCI0_MEM_2_SIZE, MV64x60_PCI0_MEM_3_SIZE };
-       u32     pci_1_size[] = {
-                       MV64x60_PCI1_MEM_0_SIZE, MV64x60_PCI1_MEM_1_SIZE,
-                       MV64x60_PCI1_MEM_2_SIZE, MV64x60_PCI1_MEM_3_SIZE };
-
-       /* Clear bit 0 of PCI addr decode control so PCI->CPU remap 1:1 */
-       mv64x60_clr_bits(bh, MV64x60_PCI0_PCI_DECODE_CNTL, 0x00000001);
-       mv64x60_clr_bits(bh, MV64x60_PCI1_PCI_DECODE_CNTL, 0x00000001);
-
-       /*
-        * Set the access control, snoop, BAR size, and window base addresses.
-        * PCI->MEM windows base addresses will match exactly what the
-        * CPU->MEM windows are.
-        */
-       for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
-               if (bh->ci->is_enabled_32bit(bh, i)) {
-                       if (si->pci_0.enable_bus) {
-                               mv64x60_set_64bit_window(bh,
-                                       pci_0_acc_windows[i], 0,
-                                       mem_windows[i][0], mem_windows[i][1],
-                                       si->pci_0.acc_cntl_options[i]);
-                               bh->ci->enable_window_64bit(bh,
-                                       pci_0_acc_windows[i]);
-
-                               if (bh->ci->window_tab_64bit[
-                                       pci_0_snoop_windows[i]].base_lo_reg
-                                                                       != 0) {
-                                       mv64x60_set_64bit_window(bh,
-                                               pci_0_snoop_windows[i], 0,
-                                               mem_windows[i][0],
-                                               mem_windows[i][1],
-                                               si->pci_0.snoop_options[i]);
-                                       bh->ci->enable_window_64bit(bh,
-                                               pci_0_snoop_windows[i]);
-                               }
-
-                               bh->ci->set_pci2mem_window(bh->hose_a, i,
-                                       mem_windows[i][0]);
-                               mv64x60_write(bh, pci_0_size[i],
-                                       mv64x60_mask(mem_windows[i][1] -1, 20));
-
-                               /* Enable the window */
-                               mv64x60_clr_bits(bh, MV64x60_PCI0_BAR_ENABLE,
-                                                                       1 << i);
-                       }
-                       if (si->pci_1.enable_bus) {
-                               mv64x60_set_64bit_window(bh,
-                                       pci_1_acc_windows[i], 0,
-                                       mem_windows[i][0], mem_windows[i][1],
-                                       si->pci_1.acc_cntl_options[i]);
-                               bh->ci->enable_window_64bit(bh,
-                                       pci_1_acc_windows[i]);
-
-                               if (bh->ci->window_tab_64bit[
-                                       pci_1_snoop_windows[i]].base_lo_reg
-                                                                       != 0) {
-                                       mv64x60_set_64bit_window(bh,
-                                               pci_1_snoop_windows[i], 0,
-                                               mem_windows[i][0],
-                                               mem_windows[i][1],
-                                               si->pci_1.snoop_options[i]);
-                                       bh->ci->enable_window_64bit(bh,
-                                               pci_1_snoop_windows[i]);
-                               }
-
-                               bh->ci->set_pci2mem_window(bh->hose_b, i,
-                                       mem_windows[i][0]);
-                               mv64x60_write(bh, pci_1_size[i],
-                                       mv64x60_mask(mem_windows[i][1] -1, 20));
-
-                               /* Enable the window */
-                               mv64x60_clr_bits(bh, MV64x60_PCI1_BAR_ENABLE,
-                                                                       1 << i);
-                       }
-               }
-       }
-
-       return;
-}
-
-/*
- *****************************************************************************
- *
- *     Hose & Resource Alloc/Init Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_alloc_hoses()
- *
- * Allocate the PCI hose structures for the bridge's PCI buses.
- */
-static void __init
-mv64x60_alloc_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       /*
-        * Alloc first hose struct even when its not to be configured b/c the
-        * chip identification routines need to use it.
-        */
-       bh->hose_a = pcibios_alloc_controller();
-       setup_indirect_pci(bh->hose_a,
-               bh->p_base + MV64x60_PCI0_CONFIG_ADDR,
-               bh->p_base + MV64x60_PCI0_CONFIG_DATA);
-
-       if (si->pci_1.enable_bus) {
-               bh->hose_b = pcibios_alloc_controller();
-               setup_indirect_pci(bh->hose_b,
-                       bh->p_base + MV64x60_PCI1_CONFIG_ADDR,
-                       bh->p_base + MV64x60_PCI1_CONFIG_DATA);
-       }
-
-       return;
-}
-
-/*
- * mv64x60_init_hoses()
- *
- * Initialize the PCI hose structures for the bridge's PCI hoses.
- */
-static void __init
-mv64x60_init_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       if (si->pci_1.enable_bus) {
-               bh->io_base_b = (u32)ioremap(si->pci_1.pci_io.cpu_base,
-                                                       si->pci_1.pci_io.size);
-               isa_io_base = bh->io_base_b;
-       }
-
-       if (si->pci_0.enable_bus) {
-               bh->io_base_a = (u32)ioremap(si->pci_0.pci_io.cpu_base,
-                                                       si->pci_0.pci_io.size);
-               isa_io_base = bh->io_base_a;
-
-               mv64x60_init_resources(bh->hose_a, &si->pci_0, bh->io_base_a);
-               mv64x60_set_pci_params(bh->hose_a, &si->pci_0);
-       }
-
-       /* Must do here so proper isa_io_base is used in calculations */
-       if (si->pci_1.enable_bus) {
-               mv64x60_init_resources(bh->hose_b, &si->pci_1, bh->io_base_b);
-               mv64x60_set_pci_params(bh->hose_b, &si->pci_1);
-       }
-
-       return;
-}
-
-/*
- * mv64x60_init_resources()
- *
- * Calculate the offsets, etc. for the hose structures to reflect all of
- * the address remapping that happens as you go from CPU->PCI and PCI->MEM.
- */
-static void __init
-mv64x60_init_resources(struct pci_controller *hose, mv64x60_pci_info_t *pi,
-                               u32 io_base)
-{
-       int             i;
-       /* 2 hoses; 4 resources/hose; sting <= 64 bytes; not work if > 1 chip */
-       static char     s[2][4][64];
-
-       if (pi->pci_io.size != 0) {
-               sprintf(s[hose->index][0], "PCI hose %d I/O Space",
-                       hose->index);
-               pci_init_resource(&hose->io_resource, io_base - isa_io_base,
-                       io_base - isa_io_base + pi->pci_io.size - 1,
-                       IORESOURCE_IO, s[hose->index][0]);
-               hose->io_space.start = pi->pci_io.pci_base_lo;
-               hose->io_space.end = pi->pci_io.pci_base_lo + pi->pci_io.size-1;
-               hose->io_base_virt = (void *)isa_io_base;
-       }
-
-       for (i=0; i<3; i++) {
-               if (pi->pci_mem[i].size != 0) {
-                       sprintf(s[hose->index][i+1], "PCI hose %d MEM Space %d",
-                               hose->index, i);
-                       pci_init_resource(&hose->mem_resources[i],
-                               pi->pci_mem[i].cpu_base,
-                               pi->pci_mem[i].cpu_base + pi->pci_mem[i].size-1,
-                               IORESOURCE_MEM, s[hose->index][i+1]);
-               }
-       }
-       
-       hose->mem_space.end = pi->pci_mem[0].pci_base_lo +
-                                               pi->pci_mem[0].size - 1;
-       hose->pci_mem_offset = pi->pci_mem[0].cpu_base -
-                                               pi->pci_mem[0].pci_base_lo;
-
-       return;
-} /* mv64x60_init_resources() */
-
-/*
- * mv64x60_set_pci_params()
- *
- * Configure a hose's PCI config space parameters.
- */
-static void __init
-mv64x60_set_pci_params(struct pci_controller *hose, mv64x60_pci_info_t *pi)
-{
-       u32     devfn;
-       u16     u16_val;
-       u8      save_exclude;
-
-       devfn = PCI_DEVFN(0,0);
-
-       save_exclude = mv64x60_pci_exclude_bridge;
-       mv64x60_pci_exclude_bridge = FALSE;
-
-       /* Set class code to indicate host bridge */
-       u16_val = PCI_CLASS_BRIDGE_HOST; /* 0x0600 (host bridge) */
-       early_write_config_word(hose, 0, devfn, PCI_CLASS_DEVICE, u16_val);
-
-       /* Enable 64260 to be PCI master & respond to PCI MEM cycles */
-       early_read_config_word(hose, 0, devfn, PCI_COMMAND, &u16_val);
-       u16_val &= ~(PCI_COMMAND_IO | PCI_COMMAND_INVALIDATE |
-               PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK);
-       u16_val |= pi->pci_cmd_bits | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       early_write_config_word(hose, 0, devfn, PCI_COMMAND, u16_val);
-
-       /* Set latency timer, cache line size, clear BIST */
-       u16_val = (pi->latency_timer << 8) | (L1_CACHE_LINE_SIZE >> 2);
-       early_write_config_word(hose, 0, devfn, PCI_CACHE_LINE_SIZE, u16_val);
-
-       mv64x60_pci_exclude_bridge = save_exclude;
-       return;
-}
-
-/*
- *****************************************************************************
- *
- *     PCI Related Routine
- *
- *****************************************************************************
- */
-/*
- * mv64x60_enumerate_buses()
- *
- * If requested, enumerate the PCI buses and set the appropriate
- * info in the hose structures.
- */
-static void __init
-mv64x60_enumerate_buses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       u32     val;
-
-       pci_dram_offset = 0; /* System mem at same addr on PCI & cpu bus */
-
-       ppc_md.pci_exclude_device = mv64x60_pci_exclude_device;
-       ppc_md.pci_swizzle = common_swizzle;
-       ppc_md.pci_map_irq = si->map_irq;
-
-       /* Now that the bridge is set up, its safe to scan the PCI buses */
-       if (si->pci_0.enable_bus) {
-               if (si->pci_0.enumerate_bus) {
-                       /* Set bus number for PCI 0 to 0 */
-                       val = mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG);
-                       val &= 0xe0000000;
-                       val |= 0x000000ff;
-                       mv64x60_write(bh, MV64x60_PCI0_P2P_CONFIG, val);
-                       /* Flush FIFO*/
-                       (void)mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG);
-
-#if 0
-XXXX Different if in PCI-X mode (look at mv64360_find_bridges()) XXXX
-#endif
-
-                       bh->hose_a->first_busno = 0;
-                       bh->hose_a->last_busno  = 0xff;
-
-                       bh->hose_a->last_busno = pciauto_bus_scan(bh->hose_a,
-                                               bh->hose_a->first_busno);
-               }
-               else {
-                       /* Assume bridge set up correctly by someone else */
-                       val = mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG);
-                       bh->hose_a->first_busno = (val & 0x00ff0000) >> 16;
-               }
-       }
-
-       if (si->pci_1.enable_bus) {
-               if (si->pci_1.enumerate_bus) {
-                       if (si->pci_0.enable_bus) {
-                               bh->hose_b->first_busno =
-                                       bh->hose_a->last_busno + 1;
-
-                               /* Set bus number for PCI 1 hose */
-                               val = mv64x60_read(bh, MV64x60_PCI1_P2P_CONFIG);
-                               val &= 0xe0000000;
-                               val |= (bh->hose_b->first_busno << 16) | 0xff;
-                               mv64x60_write(bh, MV64x60_PCI1_P2P_CONFIG, val);
-                               /* Flush FIFO */
-                               (void)mv64x60_read(bh, MV64x60_PCI1_P2P_CONFIG);
-                       }
-                       else {
-                               bh->hose_b->first_busno = 0;
-                       }
-
-                       bh->hose_b->last_busno  = 0xff;
-                       bh->hose_b->last_busno = pciauto_bus_scan(bh->hose_b,
-                                               bh->hose_b->first_busno);
-               }
-               else {
-                       /* Assume bridge set up correctly by someone else */
-                       val = mv64x60_read(bh, MV64x60_PCI1_P2P_CONFIG);
-                       bh->hose_b->first_busno = (val & 0x00ff0000) >> 16;
-                       bh->hose_b->last_busno = 0xff; /* No way to know */
-               }
-       }
-
-       if (si->pci_0.enable_bus && !si->pci_0.enumerate_bus) {
-               if (si->pci_1.enable_bus) {
-                       bh->hose_a->last_busno = bh->hose_b->first_busno - 1;
-               }
-               else {
-                       bh->hose_a->last_busno = 0xff; /* No way to know */
-               }
-       }
-
-       return;
-}
-
-/*
- * mv64x60_exclude_pci_device()
- *
- * This routine is used to make the bridge not appear when the
- * PCI subsystem is accessing PCI devices (in PCI config space).
- */
-static int
-mv64x60_pci_exclude_device(u8 bus, u8 devfn)
-{
-       struct pci_controller   *hose;
-
-       hose = pci_bus_to_hose(bus);
-
-       /* Skip slot 0 on both hoses */
-       if ((mv64x60_pci_exclude_bridge == TRUE) &&
-           (PCI_SLOT(devfn) == 0) &&
-           (hose->first_busno == bus)) {
-               return PCIBIOS_DEVICE_NOT_FOUND;
-       }
-       else {
-               return PCIBIOS_SUCCESSFUL;
-       }
-} /* mv64x60_pci_exclude_device() */
-
-/*
- *****************************************************************************
- *
- *     OCP Fixup Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_fixup_ocp()
- *
- * Adjust the 'paddr' field in the bridge's OCP entries to reflect where they
- * really are in the physical address space.
- */
-static void __init
-mv64x60_fixup_ocp(struct ocp_device *dev, void *arg)
-{
-       mv64x60_handle_t        *bh = (mv64x60_handle_t *)arg;
-
-       if (dev->def->vendor == OCP_VENDOR_MARVELL) {
-               dev->def->paddr += bh->p_base;
-       }
-
-       return;
-}
-
-/*
- *****************************************************************************
- *
- *     GT64260-Specific Routines
- *
- *****************************************************************************
- */
-/*
- * gt64260_translate_size()
- *
- * On the GT64260, the size register is really the "top" address of the window.
- */
-static u32 __init
-gt64260_translate_size(u32 base, u32 size, u32 num_bits)
-{
-       return base + mv64x60_mask(size - 1, num_bits);
-}
-
-/*
- * gt64260_untranslate_size()
- *
- * Translate the top address of a window into a window size.
- */
-static u32 __init
-gt64260_untranslate_size(u32 base, u32 size, u32 num_bits)
-{
-       if (size >= base) {
-               size = size - base + (1 << (32 - num_bits));
-       }
-       else {
-               size = 0;
-       }
-
-       return size;
-}
-
-/*
- * gt64260_set_pci2mem_window()
- *
- * The PCI->MEM window registers are actually in PCI config space so need
- * to set them by setting the correct config space BARs.
- */
-static void __init
-gt64260_set_pci2mem_window(struct pci_controller *hose, u32 window, u32 base)
-{
-       u32     reg_addrs[] = { 0x10, 0x14, 0x18, 0x1c };
-
-       DBG("set pci->mem window: %d, hose: %d, base: 0x%x\n", window,
-               hose->index, base);
-
-       early_write_config_dword(hose, hose->first_busno,
-                       PCI_DEVFN(0, 0), reg_addrs[window],
-                       mv64x60_mask(base, 20) | 0x8);
-       return;
-}
-
-/*
- * gt64260_is_enabled_32bit()
- *
- * On a GT64260, a window is enabled iff its top address is >= to its base
- * address.
- */
-static u32 __init
-gt64260_is_enabled_32bit(mv64x60_handle_t *bh, u32 window)
-{
-       u32     rc = 0;
-
-       if ((gt64260_32bit_windows[window].base_reg != 0) &&
-               (gt64260_32bit_windows[window].size_reg != 0) &&
-               ((mv64x60_read(bh, gt64260_32bit_windows[window].size_reg) &
-                       ((1 << gt64260_32bit_windows[window].size_bits) - 1)) >=
-                (mv64x60_read(bh, gt64260_32bit_windows[window].base_reg) &
-                       ((1 << gt64260_32bit_windows[window].base_bits) - 1)))){
-
-               rc = 1;
-       }
-
-       if (rc) {
-               DBG("32bit window %d is enabled\n", window);
-       }
-       else {
-               DBG("32bit window %d is disabled\n", window);
-       }
-
-       return rc;
-}
-
-/*
- * gt64260_enable_window_32bit()
- *
- * On the GT64260, a window is enabled iff the top address is >= to the base
- * address of the window.  Since the window has already been configured by
- * the time this routine is called, we have nothing to do here.
- */
-static void __init
-gt64260_enable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("enable 32bit window: %d\n", window);
-       return;
-}
-
-/*
- * gt64260_disable_window_32bit()
- *
- * On a GT64260, you disable a window by setting its top address to be less
- * than its base address.
- */
-static void __init
-gt64260_disable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("disable 32bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
-               window, gt64260_32bit_windows[window].base_reg,
-               gt64260_32bit_windows[window].size_reg);
-
-       if ((gt64260_32bit_windows[window].base_reg != 0) &&
-               (gt64260_32bit_windows[window].size_reg != 0)) {
-
-               /* To disable, make bottom reg higher than top reg */
-               mv64x60_write(bh, gt64260_32bit_windows[window].base_reg,0xfff);
-               mv64x60_write(bh, gt64260_32bit_windows[window].size_reg, 0);
-       }
-
-       return;
-}
-
-/*
- * gt64260_enable_window_64bit()
- *
- * On the GT64260, a window is enabled iff the top address is >= to the base
- * address of the window.  Since the window has already been configured by
- * the time this routine is called, we have nothing to do here.
- */
-static void __init
-gt64260_enable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("enable 64bit window: %d\n", window);
-       return; /* Enabled when window configured (i.e., when top >= base) */
-}
-
-/*
- * gt64260_disable_window_64bit()
- *
- * On a GT64260, you disable a window by setting its top address to be less
- * than its base address.
- */
-static void __init
-gt64260_disable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("disable 64bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
-               window, gt64260_64bit_windows[window].base_lo_reg,
-               gt64260_64bit_windows[window].size_reg);
-
-       if ((gt64260_64bit_windows[window].base_lo_reg != 0) &&
-               (gt64260_64bit_windows[window].size_reg != 0)) {
-
-               /* To disable, make bottom reg higher than top reg */
-               mv64x60_write(bh, gt64260_64bit_windows[window].base_lo_reg,
-                                                                       0xfff);
-               mv64x60_write(bh, gt64260_64bit_windows[window].base_hi_reg, 0);
-               mv64x60_write(bh, gt64260_64bit_windows[window].size_reg, 0);
-       }
-
-       return;
-}
-
-/*
- * gt64260_disable_all_windows()
- *
- * The GT64260 has several windows that aren't represented in the table of
- * windows at the top of this file.  This routine turns all of them off
- * except for the memory controller windows, of course.
- */
-static void __init
-gt64260_disable_all_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       u32     i;
-
-       /* Disable 32bit windows (don't disable cpu->mem windows) */
-       for (i=MV64x60_CPU2DEV_0_WIN; i<MV64x60_32BIT_WIN_COUNT; i++) {
-               if (!(si->window_preserve_mask_32 & (1<<i)))
-                       gt64260_disable_window_32bit(bh, i);
-       }
-
-       /* Disable 64bit windows */
-       for (i=0; i<MV64x60_64BIT_WIN_COUNT; i++) {
-               if (!(si->window_preserve_mask_64 & (1<<i)))
-                       gt64260_disable_window_64bit(bh, i);
-       }
-
-       /* Turn off cpu protection windows not in gt64260_32bit_windows[] */
-       mv64x60_write(bh, GT64260_CPU_PROT_BASE_4, 0xfff);
-       mv64x60_write(bh, GT64260_CPU_PROT_SIZE_4, 0);
-       mv64x60_write(bh, GT64260_CPU_PROT_BASE_5, 0xfff);
-       mv64x60_write(bh, GT64260_CPU_PROT_SIZE_5, 0);
-       mv64x60_write(bh, GT64260_CPU_PROT_BASE_6, 0xfff);
-       mv64x60_write(bh, GT64260_CPU_PROT_SIZE_6, 0);
-       mv64x60_write(bh, GT64260_CPU_PROT_BASE_7, 0xfff);
-       mv64x60_write(bh, GT64260_CPU_PROT_SIZE_7, 0);
-
-       /* Turn off PCI->MEM access cntl wins not in gt64260_64bit_windows[] */
-       mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_4_BASE_LO, 0xfff);
-       mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_4_BASE_HI, 0);
-       mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_4_SIZE, 0);
-       mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_5_BASE_LO, 0xfff);
-       mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_5_BASE_HI, 0);
-       mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_5_SIZE, 0);
-       mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_6_BASE_LO, 0xfff);
-       mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_6_BASE_HI, 0);
-       mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_6_SIZE, 0);
-       mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_7_BASE_LO, 0xfff);
-       mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_7_BASE_HI, 0);
-       mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_7_SIZE, 0);
-
-       mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_4_BASE_LO, 0xfff);
-       mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_4_BASE_HI, 0);
-       mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_4_SIZE, 0);
-       mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_5_BASE_LO, 0xfff);
-       mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_5_BASE_HI, 0);
-       mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_5_SIZE, 0);
-       mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_6_BASE_LO, 0xfff);
-       mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_6_BASE_HI, 0);
-       mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_6_SIZE, 0);
-       mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_7_BASE_LO, 0xfff);
-       mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_7_BASE_HI, 0);
-       mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_7_SIZE, 0);
-
-       /* Disable all PCI-><whatever> windows */
-       mv64x60_set_bits(bh, MV64x60_PCI0_BAR_ENABLE, 0x07ffffff);
-       mv64x60_set_bits(bh, MV64x60_PCI1_BAR_ENABLE, 0x07ffffff);
-
-       return;
-}
-
-/*
- * gt64260a_chip_specific_init()
- *
- * Implement errata work arounds for the GT64260A.
- */
-static void
-gt64260a_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       struct ocp_device       *dev;
-       mv64x60_ocp_mpsc_data_t *mpsc_dp;
-       u8                      save_exclude;
-       u32                     val;
-
-       /* R#18 */
-       /* cpu read buffer to buffer 1 (reg 0x0448) */
-       mv64x60_set_bits(bh, GT64260_SDRAM_CONFIG, (1<<26));
-
-       /* No longer errata so turn on */
-       /* Enable pci read/write combine, master write trigger,
-       * disable slave sync barrier
-       * readmultiple (reg 0x0c00 and 0x0c80)
-       */
-       if (si->pci_0.enable_bus) {
-               mv64x60_set_bits(bh, MV64x60_PCI0_CMD,
-                       ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
-       }
-
-       if (si->pci_1.enable_bus) {
-               mv64x60_set_bits(bh, MV64x60_PCI1_CMD,
-                       ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
-       }
-
-#if 1  /* XXXX */
-       /*
-        * Dave Wilhardt found that bit 4 in the PCI Command registers must
-        * be set if you are using cache coherency.
-        *
-        * Note: he also said that bit 4 must be on in all PCI devices but
-        *       that has not been implemented yet.
-        */
-       save_exclude = mv64x60_pci_exclude_bridge;
-       mv64x60_pci_exclude_bridge = FALSE;
-
-       early_read_config_dword(bh->hose_a,
-                       bh->hose_a->first_busno,
-                       PCI_DEVFN(0,0),
-                       PCI_COMMAND,
-                       &val);
-       val |= PCI_COMMAND_INVALIDATE;
-       early_write_config_dword(bh->hose_a,
-                       bh->hose_a->first_busno,
-                       PCI_DEVFN(0,0),
-                       PCI_COMMAND,
-                       val);
-
-       early_read_config_dword(bh->hose_b,
-                       bh->hose_b->first_busno,
-                       PCI_DEVFN(0,0),
-                       PCI_COMMAND,
-                       &val);
-       val |= PCI_COMMAND_INVALIDATE;
-       early_write_config_dword(bh->hose_b,
-                       bh->hose_b->first_busno,
-                       PCI_DEVFN(0,0),
-                       PCI_COMMAND,
-                       val);
-
-       mv64x60_pci_exclude_bridge = save_exclude;
-#endif
-
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
-                                                               != NULL) {
-               mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-               mpsc_dp->mirror_regs = 1;
-               mpsc_dp->cache_mgmt = 1;
-       }
-
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
-                                                               != NULL) {
-               mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-               mpsc_dp->mirror_regs = 1;
-               mpsc_dp->cache_mgmt = 1;
-       }
-
-       return;
-}
-
-/*
- * gt64260b_chip_specific_init()
- *
- * Implement errata work arounds for the GT64260B.
- */
-static void
-gt64260b_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       struct ocp_device       *dev;
-       mv64x60_ocp_mpsc_data_t *mpsc_dp;
-
-       /* R#18 */
-       /* cpu read buffer to buffer 1 (reg 0x0448) */
-       mv64x60_set_bits(bh, GT64260_SDRAM_CONFIG, (1<<26));
-
-       /* No longer errata so turn on */
-       /* Enable pci read/write combine, master write trigger,
-       * disable slave sync barrier
-       * readmultiple (reg 0x0c00 and 0x0c80)
-       */
-       if (si->pci_0.enable_bus) {
-               mv64x60_set_bits(bh, MV64x60_PCI0_CMD,
-                       ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
-       }
-
-       if (si->pci_1.enable_bus) {
-               mv64x60_set_bits(bh, MV64x60_PCI1_CMD,
-                       ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
-       }
-
-       mv64x60_set_bits(bh, GT64260_CPU_WB_PRIORITY_BUFFER_DEPTH, 0xf);
-
-       /*
-        * The 64260B is not supposed to have the bug where the MPSC & ENET
-        * can't access cache coherent regions.  However, testing has shown
-        * that the MPSC, at least, still has this bug.
-        */
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
-                                                               != NULL) {
-               mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-               mpsc_dp->cache_mgmt = 1;
-       }
-
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
-                                                               != NULL) {
-               mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-               mpsc_dp->cache_mgmt = 1;
-       }
-
-       return;
-}
-
-/*
- *****************************************************************************
- *
- *     MV64360-Specific Routines
- *
- *****************************************************************************
- */
-/*
- * mv64360_translate_size()
- *
- * On the MV64360, the size register is set similar to the size you get
- * from a pci config space BAR register.  That is, programmed from LSB to MSB
- * as a sequence of 1's followed by a sequence of 0's. IOW, "size -1" with the
- * assumption that the size is a power of 2.
- */
-static u32 __init
-mv64360_translate_size(u32 base_addr, u32 size, u32 num_bits)
-{
-       return mv64x60_mask(size - 1, num_bits);
-}
-
-/*
- * mv64360_untranslate_size()
- *
- * Translate the size register value of a window into a window size.
- */
-static u32 __init
-mv64360_untranslate_size(u32 base_addr, u32 size, u32 num_bits)
-{
-       if (size > 0) {
-               size >>= (32 - num_bits);
-               size++;
-               size <<= (32 - num_bits);
-       }
-
-       return size;
-}
-
-/*
- * mv64360_set_pci2mem_window()
- *
- * The PCI->MEM window registers are actually in PCI config space so need
- * to set them by setting the correct config space BARs.
- */
-static void __init
-mv64360_set_pci2mem_window(struct pci_controller *hose, u32 window, u32 base)
-{
-       struct {
-               u32     fcn;
-               u32     base_hi_bar;
-               u32     base_lo_bar;
-       } reg_addrs[] = {{ 0, 0x14, 0x10 }, { 0, 0x1c, 0x18 },
-               { 1, 0x14, 0x10 }, { 1, 0x1c, 0x18 }};
-
-       DBG("set pci->mem window: %d, hose: %d, base: 0x%x\n", window,
-               hose->index, base);
-
-       early_write_config_dword(hose, hose->first_busno,
-                       PCI_DEVFN(0, reg_addrs[window].fcn),
-                       reg_addrs[window].base_hi_bar, 0);
-       early_write_config_dword(hose, hose->first_busno,
-                       PCI_DEVFN(0, reg_addrs[window].fcn),
-                       reg_addrs[window].base_lo_bar,
-                       mv64x60_mask(base, 20) | 0xc);
-       return;
-}
-
-/*
- * mv64360_is_enabled_32bit()
- *
- * On a MV64360, a window is enabled by either clearing a bit in the
- * CPU BAR Enable reg or setting a bit in the window's base reg.
- * Note that this doesn't work for windows on the PCI slave side but we don't
- * check those so its okay.
- */
-static u32 __init
-mv64360_is_enabled_32bit(mv64x60_handle_t *bh, u32 window)
-{
-       u32     rc = 0;
-
-       if ((mv64360_32bit_windows[window].base_reg != 0) &&
-               (mv64360_32bit_windows[window].size_reg != 0)) {
-
-               if (mv64360_32bit_windows[window].extra & 0x80000000) {
-                       rc = (mv64x60_read(bh,
-                               mv64360_32bit_windows[window].base_reg) & 
-                               (1 << (mv64360_32bit_windows[window].extra &
-                                                               0xff))) != 0;
-               }
-               else {
-                       rc = (mv64x60_read(bh, MV64360_CPU_BAR_ENABLE) & 
-                               (1 << mv64360_32bit_windows[window].extra)) ==0;
-               }
-       }
-
-       if (rc) {
-               DBG("32bit window %d is enabled\n", window);
-       }
-       else {
-               DBG("32bit window %d is disabled\n", window);
-       }
-
-       return rc;
-}
-
-/*
- * mv64360_enable_window_32bit()
- *
- * On a MV64360, a window is enabled by either clearing a bit in the
- * CPU BAR Enable reg or setting a bit in the window's base reg.
- */
-static void __init
-mv64360_enable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("enable 32bit window: %d\n", window);
-
-       if ((mv64360_32bit_windows[window].base_reg != 0) &&
-               (mv64360_32bit_windows[window].size_reg != 0)) {
-
-               if (mv64360_32bit_windows[window].extra & 0x80000000) {
-                       mv64x60_set_bits(bh,
-                               mv64360_32bit_windows[window].base_reg,
-                               (1 << (mv64360_32bit_windows[window].extra &
-                                                                       0xff)));
-               }
-               else {
-                       mv64x60_clr_bits(bh, MV64360_CPU_BAR_ENABLE,
-                               (1 << mv64360_32bit_windows[window].extra));
-               }
-       }
-
-       return;
-}
-
-/*
- * mv64360_disable_window_32bit()
- *
- * On a MV64360, a window is disabled by either setting a bit in the
- * CPU BAR Enable reg or clearing a bit in the window's base reg.
- */
-static void __init
-mv64360_disable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("disable 32bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
-               window, mv64360_32bit_windows[window].base_reg,
-               mv64360_32bit_windows[window].size_reg);
-
-       if ((mv64360_32bit_windows[window].base_reg != 0) &&
-               (mv64360_32bit_windows[window].size_reg != 0)) {
-
-               if (mv64360_32bit_windows[window].extra & 0x80000000) {
-                       mv64x60_clr_bits(bh,
-                               mv64360_32bit_windows[window].base_reg,
-                               (1 << (mv64360_32bit_windows[window].extra &
-                                                                       0xff)));
-               }
-               else {
-                       mv64x60_set_bits(bh, MV64360_CPU_BAR_ENABLE,
-                               (1 << mv64360_32bit_windows[window].extra));
-               }
-       }
-
-       return;
-}
-
-/*
- * mv64360_enable_window_64bit()
- *
- * On the MV64360, a 64-bit window is enabled by setting a bit in the window's 
- * base reg.
- */
-static void __init
-mv64360_enable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("enable 64bit window: %d\n", window);
-
-       /* For 64360, 'extra' field holds bit that enables the window */
-       if ((mv64360_64bit_windows[window].base_lo_reg!= 0) &&
-               (mv64360_64bit_windows[window].size_reg != 0)) {
-
-               if (mv64360_64bit_windows[window].extra & 0x80000000) {
-                       mv64x60_set_bits(bh,
-                               mv64360_64bit_windows[window].base_lo_reg,
-                               (1 << (mv64360_64bit_windows[window].extra &
-                                                                       0xff)));
-               } /* Should be no 'else' ones */
-       }
-
-       return;
-}
-
-/*
- * mv64360_disable_window_64bit()
- *
- * On a MV64360, a 64-bit window is disabled by clearing a bit in the window's
- * base reg.
- */
-static void __init
-mv64360_disable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
-       DBG("disable 64bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
-               window, mv64360_64bit_windows[window].base_lo_reg,
-               mv64360_64bit_windows[window].size_reg);
-
-       if ((mv64360_64bit_windows[window].base_lo_reg != 0) &&
-               (mv64360_64bit_windows[window].size_reg != 0)) {
-
-               if (mv64360_64bit_windows[window].extra & 0x80000000) {
-                       mv64x60_clr_bits(bh,
-                               mv64360_64bit_windows[window].base_lo_reg,
-                               (1 << (mv64360_64bit_windows[window].extra &
-                                                                       0xff)));
-               } /* Should be no 'else' ones */
-       }
-
-       return;
-}
-
-/*
- * mv64360_disable_all_windows()
- *
- * The MV64360 has a few windows that aren't represented in the table of
- * windows at the top of this file.  This routine turns all of them off
- * except for the memory controller windows, of course.
- */
-static void __init
-mv64360_disable_all_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       u32     i;
-
-       /* Disable 32bit windows (don't disable cpu->mem windows) */
-       for (i=MV64x60_CPU2DEV_0_WIN; i<MV64x60_32BIT_WIN_COUNT; i++) {
-               if (!(si->window_preserve_mask_32 & (1<<i)))
-                       mv64360_disable_window_32bit(bh, i);
-       }
-
-       /* Disable 64bit windows */
-       for (i=0; i<MV64x60_64BIT_WIN_COUNT; i++) {
-               if (!(si->window_preserve_mask_64 & (1<<i)))
-                       mv64360_disable_window_64bit(bh, i);
-       }
-
-       /* Turn off PCI->MEM access cntl wins not in mv64360_64bit_windows[] */
-       mv64x60_clr_bits(bh, MV64x60_PCI0_ACC_CNTL_4_BASE_LO, 0);
-       mv64x60_clr_bits(bh, MV64x60_PCI0_ACC_CNTL_5_BASE_LO, 0);
-       mv64x60_clr_bits(bh, MV64x60_PCI1_ACC_CNTL_4_BASE_LO, 0);
-       mv64x60_clr_bits(bh, MV64x60_PCI1_ACC_CNTL_5_BASE_LO, 0);
-
-       /* Disable all PCI-><whatever> windows */
-       mv64x60_set_bits(bh, MV64x60_PCI0_BAR_ENABLE, 0x0000f9ff);
-       mv64x60_set_bits(bh, MV64x60_PCI1_BAR_ENABLE, 0x0000f9ff);
-
-       return;
-}
-
-/*
- * mv64360_chip_specific_init()
- *
- * No errata work arounds for the MV64360 implemented at this point.
- */
-static void
-mv64360_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       struct ocp_device       *dev;
-       mv64x60_ocp_mpsc_data_t *mpsc_dp;
-
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
-                                                               != NULL) {
-               mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-               mpsc_dp->brg_can_tune = 1;
-       }
-
-       if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
-                                                               != NULL) {
-               mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-               mpsc_dp->brg_can_tune = 1;
-       }
-
-       return;
-}
-
-/*
- * mv64460_chip_specific_init()
- *
- * No errata work arounds for the MV64460 implemented at this point.
- */
-static void
-mv64460_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
-       mv64360_chip_specific_init(bh, si); /* XXXX check errata */
-       return;
-}
diff --git a/arch/ppc/syslib/ppc4xx_sgdma.c b/arch/ppc/syslib/ppc4xx_sgdma.c
deleted file mode 100644 (file)
index 49c6e9c..0000000
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * arch/ppc/kernel/ppc4xx_sgdma.c
- *
- * IBM PPC4xx DMA engine scatter/gather library
- *
- * Copyright 2002-2003 MontaVista Software Inc.
- *
- * Cleaned up and converted to new DCR access
- * Matt Porter <mporter@kernel.crashing.org>
- *
- * Original code by Armin Kuster <akuster@mvista.com>
- * and Pete Popov <ppopov@mvista.com>
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- * You should have received a copy of the  GNU General Public License along
- * with this program; if not, write  to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/ppc4xx_dma.h>
-
-void
-ppc4xx_set_sg_addr(int dmanr, phys_addr_t sg_addr)
-{
-       if (dmanr >= MAX_PPC4xx_DMA_CHANNELS) {
-               printk("ppc4xx_set_sg_addr: bad channel: %d\n", dmanr);
-               return;
-       }
-
-#ifdef PPC4xx_DMA_64BIT
-       mtdcr(DCRN_ASGH0 + (dmanr * 0x8), (u32)(sg_addr >> 32));
-#endif
-       mtdcr(DCRN_ASG0 + (dmanr * 0x8), (u32)sg_addr);
-}
-
-/*
- *   Add a new sgl descriptor to the end of a scatter/gather list
- *   which was created by alloc_dma_handle().
- *
- *   For a memory to memory transfer, both dma addresses must be
- *   valid. For a peripheral to memory transfer, one of the addresses
- *   must be set to NULL, depending on the direction of the transfer:
- *   memory to peripheral: set dst_addr to NULL,
- *   peripheral to memory: set src_addr to NULL.
- */
-int
-ppc4xx_add_dma_sgl(sgl_handle_t handle, phys_addr_t src_addr, phys_addr_t dst_addr,
-                  unsigned int count)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *) handle;
-       ppc_dma_ch_t *p_dma_ch;
-
-       if (!handle) {
-               printk("ppc4xx_add_dma_sgl: null handle\n");
-               return DMA_STATUS_BAD_HANDLE;
-       }
-
-       if (psgl->dmanr >= MAX_PPC4xx_DMA_CHANNELS) {
-               printk("ppc4xx_add_dma_sgl: bad channel: %d\n", psgl->dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-
-       p_dma_ch = &dma_channels[psgl->dmanr];
-
-#ifdef DEBUG_4xxDMA
-       {
-               int error = 0;
-               unsigned int aligned =
-                   (unsigned) src_addr | (unsigned) dst_addr | count;
-               switch (p_dma_ch->pwidth) {
-               case PW_8:
-                       break;
-               case PW_16:
-                       if (aligned & 0x1)
-                               error = 1;
-                       break;
-               case PW_32:
-                       if (aligned & 0x3)
-                               error = 1;
-                       break;
-               case PW_64:
-                       if (aligned & 0x7)
-                               error = 1;
-                       break;
-               default:
-                       printk("ppc4xx_add_dma_sgl: invalid bus width: 0x%x\n",
-                              p_dma_ch->pwidth);
-                       return DMA_STATUS_GENERAL_ERROR;
-               }
-               if (error)
-                       printk
-                           ("Alignment warning: ppc4xx_add_dma_sgl src 0x%x dst 0x%x count 0x%x bus width var %d\n",
-                            src_addr, dst_addr, count, p_dma_ch->pwidth);
-
-       }
-#endif
-
-       if ((unsigned) (psgl->ptail + 1) >= ((unsigned) psgl + SGL_LIST_SIZE)) {
-               printk("sgl handle out of memory \n");
-               return DMA_STATUS_OUT_OF_MEMORY;
-       }
-
-       if (!psgl->ptail) {
-               psgl->phead = (ppc_sgl_t *)
-                   ((unsigned) psgl + sizeof (sgl_list_info_t));
-               psgl->phead_dma = psgl->dma_addr + sizeof(sgl_list_info_t);
-               psgl->ptail = psgl->phead;
-               psgl->ptail_dma = psgl->phead_dma;
-       } else {
-               psgl->ptail->next = psgl->ptail_dma + sizeof(ppc_sgl_t);
-               psgl->ptail++;
-               psgl->ptail_dma += sizeof(ppc_sgl_t);
-       }
-
-       psgl->ptail->control = psgl->control;
-       psgl->ptail->src_addr = src_addr;
-       psgl->ptail->dst_addr = dst_addr;
-       psgl->ptail->control_count = (count >> p_dma_ch->shift) |
-           psgl->sgl_control;
-       psgl->ptail->next = (uint32_t) NULL;
-
-       return DMA_STATUS_GOOD;
-}
-
-/*
- * Enable (start) the DMA described by the sgl handle.
- */
-void
-ppc4xx_enable_dma_sgl(sgl_handle_t handle)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *) handle;
-       ppc_dma_ch_t *p_dma_ch;
-       uint32_t sg_command;
-
-       if (!handle) {
-               printk("ppc4xx_enable_dma_sgl: null handle\n");
-               return;
-       } else if (psgl->dmanr > (MAX_PPC4xx_DMA_CHANNELS - 1)) {
-               printk("ppc4xx_enable_dma_sgl: bad channel in handle %d\n",
-                      psgl->dmanr);
-               return;
-       } else if (!psgl->phead) {
-               printk("ppc4xx_enable_dma_sgl: sg list empty\n");
-               return;
-       }
-
-       p_dma_ch = &dma_channels[psgl->dmanr];
-       psgl->ptail->control_count &= ~SG_LINK; /* make this the last dscrptr */
-       sg_command = mfdcr(DCRN_ASGC);
-
-       ppc4xx_set_sg_addr(psgl->dmanr, psgl->phead_dma);
-
-       sg_command |= SSG_ENABLE(psgl->dmanr);
-
-       mtdcr(DCRN_ASGC, sg_command);   /* start transfer */
-}
-
-/*
- * Halt an active scatter/gather DMA operation.
- */
-void
-ppc4xx_disable_dma_sgl(sgl_handle_t handle)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *) handle;
-       uint32_t sg_command;
-
-       if (!handle) {
-               printk("ppc4xx_enable_dma_sgl: null handle\n");
-               return;
-       } else if (psgl->dmanr > (MAX_PPC4xx_DMA_CHANNELS - 1)) {
-               printk("ppc4xx_enable_dma_sgl: bad channel in handle %d\n",
-                      psgl->dmanr);
-               return;
-       }
-
-       sg_command = mfdcr(DCRN_ASGC);
-       sg_command &= ~SSG_ENABLE(psgl->dmanr);
-       mtdcr(DCRN_ASGC, sg_command);   /* stop transfer */
-}
-
-/*
- *  Returns number of bytes left to be transferred from the entire sgl list.
- *  *src_addr and *dst_addr get set to the source/destination address of
- *  the sgl descriptor where the DMA stopped.
- *
- *  An sgl transfer must NOT be active when this function is called.
- */
-int
-ppc4xx_get_dma_sgl_residue(sgl_handle_t handle, phys_addr_t * src_addr,
-                          phys_addr_t * dst_addr)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *) handle;
-       ppc_dma_ch_t *p_dma_ch;
-       ppc_sgl_t *pnext, *sgl_addr;
-       uint32_t count_left;
-
-       if (!handle) {
-               printk("ppc4xx_get_dma_sgl_residue: null handle\n");
-               return DMA_STATUS_BAD_HANDLE;
-       } else if (psgl->dmanr > (MAX_PPC4xx_DMA_CHANNELS - 1)) {
-               printk("ppc4xx_get_dma_sgl_residue: bad channel in handle %d\n",
-                      psgl->dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-
-       sgl_addr = (ppc_sgl_t *) __va(mfdcr(DCRN_ASG0 + (psgl->dmanr * 0x8)));
-       count_left = mfdcr(DCRN_DMACT0 + (psgl->dmanr * 0x8));
-
-       if (!sgl_addr) {
-               printk("ppc4xx_get_dma_sgl_residue: sgl addr register is null\n");
-               goto error;
-       }
-
-       pnext = psgl->phead;
-       while (pnext &&
-              ((unsigned) pnext < ((unsigned) psgl + SGL_LIST_SIZE) &&
-               (pnext != sgl_addr))
-           ) {
-               pnext++;
-       }
-
-       if (pnext == sgl_addr) {        /* found the sgl descriptor */
-
-               *src_addr = pnext->src_addr;
-               *dst_addr = pnext->dst_addr;
-
-               /*
-                * Now search the remaining descriptors and add their count.
-                * We already have the remaining count from this descriptor in
-                * count_left.
-                */
-               pnext++;
-
-               while ((pnext != psgl->ptail) &&
-                      ((unsigned) pnext < ((unsigned) psgl + SGL_LIST_SIZE))
-                   ) {
-                       count_left += pnext->control_count & SG_COUNT_MASK;
-               }
-
-               if (pnext != psgl->ptail) {     /* should never happen */
-                       printk
-                           ("ppc4xx_get_dma_sgl_residue error (1) psgl->ptail 0x%x handle 0x%x\n",
-                            (unsigned int) psgl->ptail, (unsigned int) handle);
-                       goto error;
-               }
-
-               /* success */
-               p_dma_ch = &dma_channels[psgl->dmanr];
-               return (count_left << p_dma_ch->shift); /* count in bytes */
-
-       } else {
-               /* this shouldn't happen */
-               printk
-                   ("get_dma_sgl_residue, unable to match current address 0x%x, handle 0x%x\n",
-                    (unsigned int) sgl_addr, (unsigned int) handle);
-
-       }
-
-      error:
-       *src_addr = (phys_addr_t) NULL;
-       *dst_addr = (phys_addr_t) NULL;
-       return 0;
-}
-
-/*
- * Returns the address(es) of the buffer(s) contained in the head element of
- * the scatter/gather list.  The element is removed from the scatter/gather
- * list and the next element becomes the head.
- *
- * This function should only be called when the DMA is not active.
- */
-int
-ppc4xx_delete_dma_sgl_element(sgl_handle_t handle, phys_addr_t * src_dma_addr,
-                             phys_addr_t * dst_dma_addr)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *) handle;
-
-       if (!handle) {
-               printk("ppc4xx_delete_sgl_element: null handle\n");
-               return DMA_STATUS_BAD_HANDLE;
-       } else if (psgl->dmanr > (MAX_PPC4xx_DMA_CHANNELS - 1)) {
-               printk("ppc4xx_delete_sgl_element: bad channel in handle %d\n",
-                      psgl->dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-
-       if (!psgl->phead) {
-               printk("ppc4xx_delete_sgl_element: sgl list empty\n");
-               *src_dma_addr = (phys_addr_t) NULL;
-               *dst_dma_addr = (phys_addr_t) NULL;
-               return DMA_STATUS_SGL_LIST_EMPTY;
-       }
-
-       *src_dma_addr = (phys_addr_t) psgl->phead->src_addr;
-       *dst_dma_addr = (phys_addr_t) psgl->phead->dst_addr;
-
-       if (psgl->phead == psgl->ptail) {
-               /* last descriptor on the list */
-               psgl->phead = NULL;
-               psgl->ptail = NULL;
-       } else {
-               psgl->phead++;
-               psgl->phead_dma += sizeof(ppc_sgl_t);
-       }
-
-       return DMA_STATUS_GOOD;
-}
-
-
-/*
- *   Create a scatter/gather list handle.  This is simply a structure which
- *   describes a scatter/gather list.
- *
- *   A handle is returned in "handle" which the driver should save in order to
- *   be able to access this list later.  A chunk of memory will be allocated
- *   to be used by the API for internal management purposes, including managing
- *   the sg list and allocating memory for the sgl descriptors.  One page should
- *   be more than enough for that purpose.  Perhaps it's a bit wasteful to use
- *   a whole page for a single sg list, but most likely there will be only one
- *   sg list per channel.
- *
- *   Interrupt notes:
- *   Each sgl descriptor has a copy of the DMA control word which the DMA engine
- *   loads in the control register.  The control word has a "global" interrupt
- *   enable bit for that channel. Interrupts are further qualified by a few bits
- *   in the sgl descriptor count register.  In order to setup an sgl, we have to
- *   know ahead of time whether or not interrupts will be enabled at the completion
- *   of the transfers.  Thus, enable_dma_interrupt()/disable_dma_interrupt() MUST
- *   be called before calling alloc_dma_handle().  If the interrupt mode will never
- *   change after powerup, then enable_dma_interrupt()/disable_dma_interrupt()
- *   do not have to be called -- interrupts will be enabled or disabled based
- *   on how the channel was configured after powerup by the hw_init_dma_channel()
- *   function.  Each sgl descriptor will be setup to interrupt if an error occurs;
- *   however, only the last descriptor will be setup to interrupt. Thus, an
- *   interrupt will occur (if interrupts are enabled) only after the complete
- *   sgl transfer is done.
- */
-int
-ppc4xx_alloc_dma_handle(sgl_handle_t * phandle, unsigned int mode, unsigned int dmanr)
-{
-       sgl_list_info_t *psgl;
-       dma_addr_t dma_addr;
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-       uint32_t sg_command;
-       void *ret;
-
-       if (dmanr >= MAX_PPC4xx_DMA_CHANNELS) {
-               printk("ppc4xx_alloc_dma_handle: invalid channel 0x%x\n", dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-
-       if (!phandle) {
-               printk("ppc4xx_alloc_dma_handle: null handle pointer\n");
-               return DMA_STATUS_NULL_POINTER;
-       }
-
-       /* Get a page of memory, which is zeroed out by consistent_alloc() */
-       ret = dma_alloc_coherent(NULL, DMA_PPC4xx_SIZE, &dma_addr, GFP_KERNEL);
-       if (ret != NULL) {
-               memset(ret, 0, DMA_PPC4xx_SIZE);
-               psgl = (sgl_list_info_t *) ret;
-       }
-
-       if (psgl == NULL) {
-               *phandle = (sgl_handle_t) NULL;
-               return DMA_STATUS_OUT_OF_MEMORY;
-       }
-
-       psgl->dma_addr = dma_addr;
-       psgl->dmanr = dmanr;
-
-       /*
-        * Modify and save the control word. These words will be
-        * written to each sgl descriptor.  The DMA engine then
-        * loads this control word into the control register
-        * every time it reads a new descriptor.
-        */
-       psgl->control = p_dma_ch->control;
-       /* Clear all mode bits */
-       psgl->control &= ~(DMA_TM_MASK | DMA_TD);
-       /* Save control word and mode */
-       psgl->control |= (mode | DMA_CE_ENABLE);
-
-       /* In MM mode, we must set ETD/TCE */
-       if (mode == DMA_MODE_MM)
-               psgl->control |= DMA_ETD_OUTPUT | DMA_TCE_ENABLE;
-
-       if (p_dma_ch->int_enable) {
-               /* Enable channel interrupt */
-               psgl->control |= DMA_CIE_ENABLE;
-       } else {
-               psgl->control &= ~DMA_CIE_ENABLE;
-       }
-
-       sg_command = mfdcr(DCRN_ASGC);
-       sg_command |= SSG_MASK_ENABLE(dmanr);
-
-       /* Enable SGL control access */
-       mtdcr(DCRN_ASGC, sg_command);
-       psgl->sgl_control = SG_ERI_ENABLE | SG_LINK;
-
-       if (p_dma_ch->int_enable) {
-               if (p_dma_ch->tce_enable)
-                       psgl->sgl_control |= SG_TCI_ENABLE;
-               else
-                       psgl->sgl_control |= SG_ETI_ENABLE;
-       }
-
-       *phandle = (sgl_handle_t) psgl;
-       return DMA_STATUS_GOOD;
-}
-
-/*
- * Destroy a scatter/gather list handle that was created by alloc_dma_handle().
- * The list must be empty (contain no elements).
- */
-void
-ppc4xx_free_dma_handle(sgl_handle_t handle)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *) handle;
-
-       if (!handle) {
-               printk("ppc4xx_free_dma_handle: got NULL\n");
-               return;
-       } else if (psgl->phead) {
-               printk("ppc4xx_free_dma_handle: list not empty\n");
-               return;
-       } else if (!psgl->dma_addr) {   /* should never happen */
-               printk("ppc4xx_free_dma_handle: no dma address\n");
-               return;
-       }
-
-       dma_free_coherent(NULL, DMA_PPC4xx_SIZE, (void *) psgl, 0);
-}
-
-EXPORT_SYMBOL(ppc4xx_alloc_dma_handle);
-EXPORT_SYMBOL(ppc4xx_free_dma_handle);
-EXPORT_SYMBOL(ppc4xx_add_dma_sgl);
-EXPORT_SYMBOL(ppc4xx_delete_dma_sgl_element);
-EXPORT_SYMBOL(ppc4xx_enable_dma_sgl);
-EXPORT_SYMBOL(ppc4xx_disable_dma_sgl);
-EXPORT_SYMBOL(ppc4xx_get_dma_sgl_residue);
diff --git a/arch/ppc/syslib/ppc8260_pic.c b/arch/ppc/syslib/ppc8260_pic.c
deleted file mode 100644 (file)
index 7faeb90..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-#include <linux/stddef.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <asm/irq.h>
-#include <asm/immap_8260.h>
-#include <asm/mpc8260.h>
-#include "ppc8260_pic.h"
-
-/* The 8260 internal interrupt controller.  It is usually
- * the only interrupt controller.
- * There are two 32-bit registers (high/low) for up to 64
- * possible interrupts.
- *
- * Now, the fun starts.....Interrupt Numbers DO NOT MAP
- * in a simple arithmetic fashion to mask or pending registers.
- * That is, interrupt 4 does not map to bit position 4.
- * We create two tables, indexed by vector number, to indicate
- * which register to use and which bit in the register to use.
- */
-static u_char  irq_to_siureg[] = {
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0
-};
-
-static u_char  irq_to_siubit[] = {
-       31, 16, 17, 18, 19, 20, 21, 22,
-       23, 24, 25, 26, 27, 28, 29, 30,
-       29, 30, 16, 17, 18, 19, 20, 21,
-       22, 23, 24, 25, 26, 27, 28, 31,
-        0,  1,  2,  3,  4,  5,  6,  7,
-        8,  9, 10, 11, 12, 13, 14, 15,
-       15, 14, 13, 12, 11, 10,  9,  8,
-        7,  6,  5,  4,  3,  2,  1,  0
-};
-
-static void m8260_mask_irq(unsigned int irq_nr)
-{
-       int     bit, word;
-       volatile uint   *simr;
-
-       bit = irq_to_siubit[irq_nr];
-       word = irq_to_siureg[irq_nr];
-
-       simr = &(immr->im_intctl.ic_simrh);
-       ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
-       simr[word] = ppc_cached_irq_mask[word];
-}
-
-static void m8260_unmask_irq(unsigned int irq_nr)
-{
-       int     bit, word;
-       volatile uint   *simr;
-
-       bit = irq_to_siubit[irq_nr];
-       word = irq_to_siureg[irq_nr];
-
-       simr = &(immr->im_intctl.ic_simrh);
-       ppc_cached_irq_mask[word] |= (1 << (31 - bit));
-       simr[word] = ppc_cached_irq_mask[word];
-}
-
-static void m8260_mask_and_ack(unsigned int irq_nr)
-{
-       int     bit, word;
-       volatile uint   *simr, *sipnr;
-
-       bit = irq_to_siubit[irq_nr];
-       word = irq_to_siureg[irq_nr];
-
-       simr = &(immr->im_intctl.ic_simrh);
-       sipnr = &(immr->im_intctl.ic_sipnrh);
-       ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
-       simr[word] = ppc_cached_irq_mask[word];
-       sipnr[word] = 1 << (31 - bit);
-}
-
-static void m8260_end_irq(unsigned int irq_nr)
-{
-       int     bit, word;
-       volatile uint   *simr;
-
-       if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))
-                       && irq_desc[irq_nr].action) {
-
-               bit = irq_to_siubit[irq_nr];
-               word = irq_to_siureg[irq_nr];
-
-               simr = &(immr->im_intctl.ic_simrh);
-               ppc_cached_irq_mask[word] |= (1 << (31 - bit));
-               simr[word] = ppc_cached_irq_mask[word];
-       }
-}
-
-struct hw_interrupt_type ppc8260_pic = {
-       " 8260 SIU  ",
-       NULL,
-       NULL,
-       m8260_unmask_irq,
-       m8260_mask_irq,
-       m8260_mask_and_ack,
-       m8260_end_irq,
-       0
-};
-
-
-int
-m8260_get_irq(struct pt_regs *regs)
-{
-       int irq;
-        unsigned long bits;
-
-        /* For MPC8260, read the SIVEC register and shift the bits down
-         * to get the irq number.         */
-        bits = immr->im_intctl.ic_sivec;
-        irq = bits >> 26;
-
-       if (irq == 0)
-               return(-1);
-#if 0
-        irq += ppc8260_pic.irq_offset;
-#endif
-       return irq;
-}
-
diff --git a/arch/ppc/syslib/ppc8260_pic.h b/arch/ppc/syslib/ppc8260_pic.h
deleted file mode 100644 (file)
index 9f683b7..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _PPC_KERNEL_PPC8260_H
-#define _PPC_KERNEL_PPC8260_H
-
-#include <linux/irq.h>
-
-extern struct hw_interrupt_type ppc8260_pic;
-
-void m8260_pic_init(void);
-void m8260_do_IRQ(struct pt_regs *regs,
-                 int            cpu);
-int m8260_get_irq(struct pt_regs *regs);
-
-#endif /* _PPC_KERNEL_PPC8260_H */
diff --git a/arch/ppc/syslib/ppc85xx_setup.c b/arch/ppc/syslib/ppc85xx_setup.c
deleted file mode 100644 (file)
index 6ceea97..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * arch/ppc/syslib/ppc85xx_setup.c
- *
- * MPC85XX common board code
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/serial.h>
-#include <linux/tty.h> /* for linux/serial_core.h */
-#include <linux/serial_core.h>
-
-#include <asm/prom.h>
-#include <asm/time.h>
-#include <asm/mpc85xx.h>
-#include <asm/immap_85xx.h>
-#include <asm/mmu.h>
-#include <asm/ocp.h>
-#include <asm/kgdb.h>
-
-#include <syslib/ppc85xx_setup.h>
-
-/* Return the amount of memory */
-unsigned long __init
-mpc85xx_find_end_of_memory(void)
-{
-        bd_t *binfo;
-
-        binfo = (bd_t *) __res;
-
-        return binfo->bi_memsize;
-}
-
-/* The decrementer counts at the system (internal) clock freq divided by 8 */
-void __init
-mpc85xx_calibrate_decr(void)
-{
-        bd_t *binfo = (bd_t *) __res;
-        unsigned int freq, divisor;
-
-        /* get the core frequency */
-        freq = binfo->bi_busfreq;
-
-        /* The timebase is updated every 8 bus clocks, HID0[SEL_TBCLK] = 0 */
-        divisor = 8;
-        tb_ticks_per_jiffy = freq / divisor / HZ;
-        tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
-
-       /* Set the time base to zero */
-       mtspr(SPRN_TBWL, 0);
-       mtspr(SPRN_TBWU, 0);
-
-       /* Clear any pending timer interrupts */
-       mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
-
-       /* Enable decrementer interrupt */
-       mtspr(SPRN_TCR, TCR_DIE);
-}
-
-#ifdef CONFIG_SERIAL_8250
-void __init
-mpc85xx_early_serial_map(void)
-{
-       struct uart_port serial_req;
-       bd_t *binfo = (bd_t *) __res;
-       phys_addr_t duart_paddr = binfo->bi_immr_base + MPC85xx_UART0_OFFSET;
-
-       /* Setup serial port access */
-       memset(&serial_req, 0, sizeof (serial_req));
-       serial_req.uartclk = binfo->bi_busfreq;
-       serial_req.line = 0;
-       serial_req.irq = MPC85xx_IRQ_DUART;
-       serial_req.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
-       serial_req.iotype = SERIAL_IO_MEM;
-       serial_req.membase = ioremap(duart_paddr, MPC85xx_UART0_SIZE);
-       serial_req.mapbase = duart_paddr;
-       serial_req.regshift = 0;
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-       gen550_init(0, &serial_req);
-#endif
-
-       if (early_serial_setup(&serial_req) != 0)
-               printk("Early serial init of port 0 failed\n");
-
-       /* Assume early_serial_setup() doesn't modify serial_req */
-       duart_paddr = binfo->bi_immr_base + MPC85xx_UART1_OFFSET;
-       serial_req.line = 1;
-       serial_req.mapbase = duart_paddr;
-       serial_req.membase = ioremap(duart_paddr, MPC85xx_UART1_SIZE);
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-       gen550_init(1, &serial_req);
-#endif
-
-       if (early_serial_setup(&serial_req) != 0)
-               printk("Early serial init of port 1 failed\n");
-}
-#endif
-
-void
-mpc85xx_restart(char *cmd)
-{
-       local_irq_disable();
-       abort();
-}
-
-void
-mpc85xx_power_off(void)
-{
-       local_irq_disable();
-       for(;;);
-}
-
-void
-mpc85xx_halt(void)
-{
-       local_irq_disable();
-       for(;;);
-}
-
-#ifdef CONFIG_PCI
-static void __init
-mpc85xx_setup_pci1(struct pci_controller *hose)
-{
-       volatile struct ccsr_pci *pci;
-       volatile struct ccsr_guts *guts;
-       unsigned short temps;
-       bd_t *binfo = (bd_t *) __res;
-
-       pci = ioremap(binfo->bi_immr_base + MPC85xx_PCI1_OFFSET,
-                   MPC85xx_PCI1_SIZE);
-
-       guts = ioremap(binfo->bi_immr_base + MPC85xx_GUTS_OFFSET,
-                   MPC85xx_GUTS_SIZE);
-
-       early_read_config_word(hose, 0, 0, PCI_COMMAND, &temps);
-       temps |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       early_write_config_word(hose, 0, 0, PCI_COMMAND, temps);
-
-#define PORDEVSR_PCI   (0x00800000)    /* PCI Mode */
-       if (guts->pordevsr & PORDEVSR_PCI) {
-               early_write_config_byte(hose, 0, 0, PCI_LATENCY_TIMER, 0x80);
-       } else {
-               /* PCI-X init */
-               temps = PCI_X_CMD_MAX_SPLIT | PCI_X_CMD_MAX_READ
-                       | PCI_X_CMD_ERO | PCI_X_CMD_DPERR_E;
-               early_write_config_word(hose, 0, 0, PCIX_COMMAND, temps);
-       }
-
-       /* Disable all windows (except powar0 since its ignored) */
-       pci->powar1 = 0;
-       pci->powar2 = 0;
-       pci->powar3 = 0;
-       pci->powar4 = 0;
-       pci->piwar1 = 0;
-       pci->piwar2 = 0;
-       pci->piwar3 = 0;
-
-       /* Setup Phys:PCI 1:1 outbound mem window @ MPC85XX_PCI1_LOWER_MEM */
-       pci->potar1 = (MPC85XX_PCI1_LOWER_MEM >> 12) & 0x000fffff;
-       pci->potear1 = 0x00000000;
-       pci->powbar1 = (MPC85XX_PCI1_LOWER_MEM >> 12) & 0x000fffff;
-       /* Enable, Mem R/W */
-       pci->powar1 = 0x80044000 |
-          (__ilog2(MPC85XX_PCI1_UPPER_MEM - MPC85XX_PCI1_LOWER_MEM + 1) - 1);
-
-       /* Setup outboud IO windows @ MPC85XX_PCI1_IO_BASE */
-       pci->potar2 = 0x00000000;
-       pci->potear2 = 0x00000000;
-       pci->powbar2 = (MPC85XX_PCI1_IO_BASE >> 12) & 0x000fffff;
-       /* Enable, IO R/W */
-       pci->powar2 = 0x80088000 | (__ilog2(MPC85XX_PCI1_IO_SIZE) - 1);
-
-       /* Setup 2G inbound Memory Window @ 0 */
-       pci->pitar1 = 0x00000000;
-       pci->piwbar1 = 0x00000000;
-       pci->piwar1 = 0xa0f5501e;       /* Enable, Prefetch, Local
-                                          Mem, Snoop R/W, 2G */
-}
-
-
-extern int mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin);
-extern int mpc85xx_exclude_device(u_char bus, u_char devfn);
-
-#ifdef CONFIG_85xx_PCI2
-static void __init
-mpc85xx_setup_pci2(struct pci_controller *hose)
-{
-       volatile struct ccsr_pci *pci;
-       unsigned short temps;
-       bd_t *binfo = (bd_t *) __res;
-
-       pci = ioremap(binfo->bi_immr_base + MPC85xx_PCI2_OFFSET,
-                   MPC85xx_PCI2_SIZE);
-
-       early_read_config_word(hose, hose->bus_offset, 0, PCI_COMMAND, &temps);
-       temps |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       early_write_config_word(hose, hose->bus_offset, 0, PCI_COMMAND, temps);
-       early_write_config_byte(hose, hose->bus_offset, 0, PCI_LATENCY_TIMER, 0x80);
-
-       /* Disable all windows (except powar0 since its ignored) */
-       pci->powar1 = 0;
-       pci->powar2 = 0;
-       pci->powar3 = 0;
-       pci->powar4 = 0;
-       pci->piwar1 = 0;
-       pci->piwar2 = 0;
-       pci->piwar3 = 0;
-
-       /* Setup Phys:PCI 1:1 outbound mem window @ MPC85XX_PCI2_LOWER_MEM */
-       pci->potar1 = (MPC85XX_PCI2_LOWER_MEM >> 12) & 0x000fffff;
-       pci->potear1 = 0x00000000;
-       pci->powbar1 = (MPC85XX_PCI2_LOWER_MEM >> 12) & 0x000fffff;
-       /* Enable, Mem R/W */
-       pci->powar1 = 0x80044000 |
-          (__ilog2(MPC85XX_PCI1_UPPER_MEM - MPC85XX_PCI1_LOWER_MEM + 1) - 1);
-
-       /* Setup outboud IO windows @ MPC85XX_PCI2_IO_BASE */
-       pci->potar2 = 0x00000000;
-       pci->potear2 = 0x00000000;
-       pci->powbar2 = (MPC85XX_PCI2_IO_BASE >> 12) & 0x000fffff;
-       /* Enable, IO R/W */
-       pci->powar2 = 0x80088000 | (__ilog2(MPC85XX_PCI1_IO_SIZE) - 1);
-
-       /* Setup 2G inbound Memory Window @ 0 */
-       pci->pitar1 = 0x00000000;
-       pci->piwbar1 = 0x00000000;
-       pci->piwar1 = 0xa0f5501e;       /* Enable, Prefetch, Local
-                                          Mem, Snoop R/W, 2G */
-}
-#endif /* CONFIG_85xx_PCI2 */
-
-void __init
-mpc85xx_setup_hose(void)
-{
-       struct pci_controller *hose_a;
-#ifdef CONFIG_85xx_PCI2
-       struct pci_controller *hose_b;
-#endif
-       bd_t *binfo = (bd_t *) __res;
-
-       hose_a = pcibios_alloc_controller();
-
-       if (!hose_a)
-               return;
-
-       ppc_md.pci_swizzle = common_swizzle;
-       ppc_md.pci_map_irq = mpc85xx_map_irq;
-
-       hose_a->first_busno = 0;
-       hose_a->bus_offset = 0;
-       hose_a->last_busno = 0xff;
-
-       setup_indirect_pci(hose_a, binfo->bi_immr_base + PCI1_CFG_ADDR_OFFSET,
-                          binfo->bi_immr_base + PCI1_CFG_DATA_OFFSET);
-       hose_a->set_cfg_type = 1;
-
-       mpc85xx_setup_pci1(hose_a);
-
-       hose_a->pci_mem_offset = MPC85XX_PCI1_MEM_OFFSET;
-       hose_a->mem_space.start = MPC85XX_PCI1_LOWER_MEM;
-       hose_a->mem_space.end = MPC85XX_PCI1_UPPER_MEM;
-
-       hose_a->io_space.start = MPC85XX_PCI1_LOWER_IO;
-       hose_a->io_space.end = MPC85XX_PCI1_UPPER_IO;
-       hose_a->io_base_phys = MPC85XX_PCI1_IO_BASE;
-#if CONFIG_85xx_PCI2
-       isa_io_base =
-               (unsigned long) ioremap(MPC85XX_PCI1_IO_BASE,
-                                       MPC85XX_PCI1_IO_SIZE +
-                                       MPC85XX_PCI2_IO_SIZE);
-#else
-       isa_io_base =
-               (unsigned long) ioremap(MPC85XX_PCI1_IO_BASE,
-                                       MPC85XX_PCI1_IO_SIZE);
-#endif
-       hose_a->io_base_virt = (void *) isa_io_base;
-
-       /* setup resources */
-       pci_init_resource(&hose_a->mem_resources[0],
-                       MPC85XX_PCI1_LOWER_MEM,
-                       MPC85XX_PCI1_UPPER_MEM,
-                       IORESOURCE_MEM, "PCI1 host bridge");
-
-       pci_init_resource(&hose_a->io_resource,
-                       MPC85XX_PCI1_LOWER_IO,
-                       MPC85XX_PCI1_UPPER_IO,
-                       IORESOURCE_IO, "PCI1 host bridge");
-
-       ppc_md.pci_exclude_device = mpc85xx_exclude_device;
-
-       hose_a->last_busno = pciauto_bus_scan(hose_a, hose_a->first_busno);
-
-#if CONFIG_85xx_PCI2
-       hose_b = pcibios_alloc_controller();
-
-       if (!hose_b)
-               return;
-
-       hose_b->bus_offset = hose_a->last_busno + 1;
-       hose_b->first_busno = hose_a->last_busno + 1;
-       hose_b->last_busno = 0xff;
-
-       setup_indirect_pci(hose_b, binfo->bi_immr_base + PCI2_CFG_ADDR_OFFSET,
-                          binfo->bi_immr_base + PCI2_CFG_DATA_OFFSET);
-       hose_b->set_cfg_type = 1;
-
-       mpc85xx_setup_pci2(hose_b);
-
-       hose_b->pci_mem_offset = MPC85XX_PCI2_MEM_OFFSET;
-       hose_b->mem_space.start = MPC85XX_PCI2_LOWER_MEM;
-       hose_b->mem_space.end = MPC85XX_PCI2_UPPER_MEM;
-
-       hose_b->io_space.start = MPC85XX_PCI2_LOWER_IO;
-       hose_b->io_space.end = MPC85XX_PCI2_UPPER_IO;
-       hose_b->io_base_phys = MPC85XX_PCI2_IO_BASE;
-       hose_b->io_base_virt = (void *) isa_io_base + MPC85XX_PCI1_IO_SIZE;
-
-       /* setup resources */
-       pci_init_resource(&hose_b->mem_resources[0],
-                       MPC85XX_PCI2_LOWER_MEM,
-                       MPC85XX_PCI2_UPPER_MEM,
-                       IORESOURCE_MEM, "PCI2 host bridge");
-
-       pci_init_resource(&hose_b->io_resource,
-                       MPC85XX_PCI2_LOWER_IO,
-                       MPC85XX_PCI2_UPPER_IO,
-                       IORESOURCE_IO, "PCI2 host bridge");
-
-       hose_b->last_busno = pciauto_bus_scan(hose_b, hose_b->first_busno);
-#endif
-       return;
-}
-#endif /* CONFIG_PCI */
-
-
diff --git a/arch/ppc/syslib/ppc85xx_setup.h b/arch/ppc/syslib/ppc85xx_setup.h
deleted file mode 100644 (file)
index 6783259..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * arch/ppc/syslib/ppc85xx_setup.h
- *
- * MPC85XX common board definitions
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor Inc.
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#ifndef __PPC_SYSLIB_PPC85XX_SETUP_H
-#define __PPC_SYSLIB_PPC85XX_SETUP_H
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <asm/ppcboot.h>
-
-extern unsigned long mpc85xx_find_end_of_memory(void) __init;
-extern void mpc85xx_calibrate_decr(void) __init;
-extern void mpc85xx_early_serial_map(void) __init;
-extern void mpc85xx_restart(char *cmd);
-extern void mpc85xx_power_off(void);
-extern void mpc85xx_halt(void);
-extern void mpc85xx_setup_hose(void) __init;
-
-/* PCI config */
-#define PCI1_CFG_ADDR_OFFSET   (0x8000)
-#define PCI1_CFG_DATA_OFFSET   (0x8004)
-
-#define PCI2_CFG_ADDR_OFFSET   (0x9000)
-#define PCI2_CFG_DATA_OFFSET   (0x9004)
-
-/* Additional register for PCI-X configuration */
-#define PCIX_NEXT_CAP  0x60
-#define PCIX_CAP_ID    0x61
-#define PCIX_COMMAND   0x62
-#define PCIX_STATUS    0x64
-
-/* Serial Config */
-#define MPC85XX_0_SERIAL                (CCSRBAR + 0x4500)
-#define MPC85XX_1_SERIAL                (CCSRBAR + 0x4600)
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE  64
-#else
-#define RS_TABLE_SIZE  2
-#endif
-
-#ifndef BASE_BAUD
-#define BASE_BAUD 115200
-#endif
-
-#define STD_UART_OP(num)                                       \
-       { 0, BASE_BAUD, num, MPC85xx_IRQ_DUART,                 \
-               (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST),        \
-               iomem_base: (u8 *)MPC85XX_##num##_SERIAL,       \
-               io_type: SERIAL_IO_MEM},
-
-/* Offset of CPM register space */
-#define CPM_MAP_ADDR   (CCSRBAR + MPC85xx_CPM_OFFSET)
-
-#endif /* __PPC_SYSLIB_PPC85XX_SETUP_H */
index 5705ce6..e9431d8 100644 (file)
@@ -436,6 +436,8 @@ config SPINLINE
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 10c1d62..5381ba1 100644 (file)
@@ -48,6 +48,8 @@ core-$(CONFIG_XMON)           += arch/ppc64/xmon/
 drivers-$(CONFIG_OPROFILE)     += arch/ppc64/oprofile/
 
 boot := arch/ppc64/boot
+bzImage: vmlinux
+       cp vmlinux arch/ppc64/boot/bzImage
 
 boottarget-$(CONFIG_PPC_PSERIES) := zImage zImage.initrd
 boottarget-$(CONFIG_PPC_ISERIES) := vmlinux.sminitrd vmlinux.initrd vmlinux.sm
diff --git a/arch/ppc64/kernel/hvcserver.c b/arch/ppc64/kernel/hvcserver.c
deleted file mode 100644 (file)
index fbe445e..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * hvcserver.c
- * Copyright (C) 2004 Ryan S Arnold, IBM Corporation
- *
- * PPC64 virtual I/O console server support.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <asm/hvcall.h>
-#include <asm/hvcserver.h>
-#include <asm/io.h>
-
-#define HVCS_ARCH_VERSION "1.0.0"
-
-MODULE_AUTHOR("Ryan S. Arnold <rsa@us.ibm.com>");
-MODULE_DESCRIPTION("IBM hvcs ppc64 API");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(HVCS_ARCH_VERSION);
-
-/*
- * Convert arch specific return codes into relevant errnos.  The hvcs
- * functions aren't performance sensitive, so this conversion isn't an
- * issue.
- */
-int hvcs_convert(long to_convert)
-{
-       switch (to_convert) {
-               case H_Success:
-                       return 0;
-               case H_Parameter:
-                       return -EINVAL;
-               case H_Hardware:
-                       return -EIO;
-               case H_Busy:
-               case H_LongBusyOrder1msec:
-               case H_LongBusyOrder10msec:
-               case H_LongBusyOrder100msec:
-               case H_LongBusyOrder1sec:
-               case H_LongBusyOrder10sec:
-               case H_LongBusyOrder100sec:
-                       return -EBUSY;
-               case H_Function: /* fall through */
-               default:
-                       return -EPERM;
-       }
-}
-
-int hvcs_free_partner_info(struct list_head *head)
-{
-       struct hvcs_partner_info *pi;
-       struct list_head *element;
-
-       if (!head) {
-               return -EINVAL;
-       }
-
-       while (!list_empty(head)) {
-               element = head->next;
-               pi = list_entry(element, struct hvcs_partner_info, node);
-               list_del(element);
-               kfree(pi);
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL(hvcs_free_partner_info);
-
-/* Helper function for hvcs_get_partner_info */
-int hvcs_next_partner(unsigned int unit_address,
-               unsigned long last_p_partition_ID,
-               unsigned long last_p_unit_address, unsigned long *pi_buff)
-
-{
-       long retval;
-       retval = plpar_hcall_norets(H_VTERM_PARTNER_INFO, unit_address,
-                       last_p_partition_ID,
-                               last_p_unit_address, virt_to_phys(pi_buff));
-       return hvcs_convert(retval);
-}
-
-/*
- * The unit_address parameter is the unit address of the vty-server vdevice
- * in whose partner information the caller is interested.  This function
- * uses a pointer to a list_head instance in which to store the partner info.
- * This function returns non-zero on success, or if there is no partner info.
- *
- * Invocation of this function should always be followed by an invocation of
- * hvcs_free_partner_info() using a pointer to the SAME list head instance
- * that was used to store the partner_info list.
- */
-int hvcs_get_partner_info(unsigned int unit_address, struct list_head *head,
-               unsigned long *pi_buff)
-{
-       /*
-        * This is a page sized buffer to be passed to hvcall per invocation.
-        * NOTE: the first long returned is unit_address.  The second long
-        * returned is the partition ID and starting with pi_buff[2] are
-        * HVCS_CLC_LENGTH characters, which are diff size than the unsigned
-        * long, hence the casting mumbojumbo you see later.
-        */
-       unsigned long   last_p_partition_ID;
-       unsigned long   last_p_unit_address;
-       struct hvcs_partner_info *next_partner_info = NULL;
-       int more = 1;
-       int retval;
-
-       memset(pi_buff, 0x00, PAGE_SIZE);
-       /* invalid parameters */
-       if (!head)
-               return -EINVAL;
-
-       last_p_partition_ID = last_p_unit_address = ~0UL;
-       INIT_LIST_HEAD(head);
-
-       if (!pi_buff)
-               return -ENOMEM;
-
-       do {
-               retval = hvcs_next_partner(unit_address, last_p_partition_ID,
-                               last_p_unit_address, pi_buff);
-               if (retval) {
-                       /*
-                        * Don't indicate that we've failed if we have
-                        * any list elements.
-                        */
-                       if (!list_empty(head))
-                               return 0;
-                       return retval;
-               }
-
-               last_p_partition_ID = pi_buff[0];
-               last_p_unit_address = pi_buff[1];
-
-               /* This indicates that there are no further partners */
-               if (last_p_partition_ID == ~0UL
-                               && last_p_unit_address == ~0UL)
-                       break;
-
-               /* This is a very small struct and will be freed soon in
-                * hvcs_free_partner_info(). */
-               next_partner_info = kmalloc(sizeof(struct hvcs_partner_info),
-                               GFP_ATOMIC);
-
-               if (!next_partner_info) {
-                       printk(KERN_WARNING "HVCONSOLE: kmalloc() failed to"
-                               " allocate partner info struct.\n");
-                       hvcs_free_partner_info(head);
-                       return -ENOMEM;
-               }
-
-               next_partner_info->unit_address
-                       = (unsigned int)last_p_unit_address;
-               next_partner_info->partition_ID
-                       = (unsigned int)last_p_partition_ID;
-
-               /* copy the Null-term char too */
-               strncpy(&next_partner_info->location_code[0],
-                       (char *)&pi_buff[2],
-                       strlen((char *)&pi_buff[2]) + 1);
-
-               list_add_tail(&(next_partner_info->node), head);
-               next_partner_info = NULL;
-
-       } while (more);
-
-       return 0;
-}
-EXPORT_SYMBOL(hvcs_get_partner_info);
-
-/*
- * If this function is called once and -EINVAL is returned it may
- * indicate that the partner info needs to be refreshed for the
- * target unit address at which point the caller must invoke
- * hvcs_get_partner_info() and then call this function again.  If,
- * for a second time, -EINVAL is returned then it indicates that
- * there is probably already a partner connection registered to a
- * different vty-server@ vdevice.  It is also possible that a second
- * -EINVAL may indicate that one of the parms is not valid, for
- * instance if the link was removed between the vty-server@ vdevice
- * and the vty@ vdevice that you are trying to open.  Don't shoot the
- * messenger.  Firmware implemented it this way.
- */
-int hvcs_register_connection( unsigned int unit_address,
-               unsigned int p_partition_ID, unsigned int p_unit_address)
-{
-       long retval;
-       retval = plpar_hcall_norets(H_REGISTER_VTERM, unit_address,
-                               p_partition_ID, p_unit_address);
-       return hvcs_convert(retval);
-}
-EXPORT_SYMBOL(hvcs_register_connection);
-
-/*
- * If -EBUSY is returned continue to call this function
- * until 0 is returned.
- */
-int hvcs_free_connection(unsigned int unit_address)
-{
-       long retval;
-       retval = plpar_hcall_norets(H_FREE_VTERM, unit_address);
-       return hvcs_convert(retval);
-}
-EXPORT_SYMBOL(hvcs_free_connection);
index d0d509e..9111268 100644 (file)
@@ -832,7 +832,15 @@ _GLOBAL(sys_call_table32)
        .llong .compat_sys_sched_setaffinity
        .llong .compat_sys_sched_getaffinity
        .llong .sys_ni_syscall
-       .llong .sys_ni_syscall          /* 225 - reserved for tux */
+#ifdef CONFIG_TUX
+        .llong .__sys_tux
+#else
+# ifdef CONFIG_TUX_MODULE
+        .llong .sys_tux
+# else
+       .llong .sys_ni_syscall
+# endif
+#endif
        .llong .sys32_sendfile64
        .llong .compat_sys_io_setup
        .llong .sys_io_destroy
@@ -864,7 +872,7 @@ _GLOBAL(sys_call_table32)
        .llong .ppc32_fadvise64_64      /* 32bit only fadvise64_64 */
        .llong .ppc_rtas                /* 255 */
        .llong .sys_ni_syscall          /* 256 reserved for sys_debug_setcontext */
-       .llong .sys_ni_syscall          /* 257 reserved for vserver */
+       .llong .sys_vserver
        .llong .sys_ni_syscall          /* 258 reserved for new sys_remap_file_pages */
        .llong .sys_ni_syscall          /* 259 reserved for new sys_mbind */
        .llong .sys_ni_syscall          /* 260 reserved for new sys_get_mempolicy */
@@ -1104,7 +1112,15 @@ _GLOBAL(sys_call_table)
        .llong .sys_sched_setaffinity
        .llong .sys_sched_getaffinity
        .llong .sys_ni_syscall
-       .llong .sys_ni_syscall          /* 225 - reserved for tux */
+#ifdef CONFIG_TUX
+        .llong .__sys_tux
+#else
+# ifdef CONFIG_TUX_MODULE
+        .llong .sys_tux
+# else
+       .llong .sys_ni_syscall
+# endif
+#endif
        .llong .sys_ni_syscall          /* 32bit only sendfile64 */
        .llong .sys_io_setup
        .llong .sys_io_destroy
index aeead83..9c3d2f5 100644 (file)
@@ -76,6 +76,8 @@ int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 438d258..b199fec 100644 (file)
@@ -37,6 +37,8 @@ struct rtas_t rtas = {
        .lock = SPIN_LOCK_UNLOCKED
 };
 
+EXPORT_SYMBOL_GPL(rtas);
+
 char rtas_err_buf[RTAS_ERROR_LOG_MAX];
 
 spinlock_t rtas_data_buf_lock = SPIN_LOCK_UNLOCKED;
index 1f30034..5cf39f3 100644 (file)
@@ -751,6 +751,8 @@ out:
        return ret;
 }
 
+EXPORT_SYMBOL_GPL(smp_call_function);
+
 void smp_call_function_interrupt(void)
 {
        void (*func) (void *info);
index 26e5e8d..376dc4a 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/ptrace.h>
 #include <linux/aio_abi.h>
 #include <linux/elf.h>
+#include <linux/vs_cvirt.h>
 
 #include <net/scm.h>
 #include <net/sock.h>
@@ -1154,6 +1155,7 @@ asmlinkage long sys32_time(compat_time_t __user * tloc)
 asmlinkage int sys32_olduname(struct oldold_utsname __user * name)
 {
        int error;
+       struct new_utsname *ptr;
        
        if (!name)
                return -EFAULT;
@@ -1161,15 +1163,16 @@ asmlinkage int sys32_olduname(struct oldold_utsname __user * name)
                return -EFAULT;
   
        down_read(&uts_sem);
-       error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
+       ptr = vx_new_utsname();
+       error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
        error -= __put_user(0,name->sysname+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
        error -= __put_user(0,name->nodename+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
        error -= __put_user(0,name->release+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
        error -= __put_user(0,name->version+__OLD_UTS_LEN);
-       error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
+       error -= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
        error = __put_user(0,name->machine+__OLD_UTS_LEN);
        up_read(&uts_sem);
 
index 41b3493..33b64c2 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/percpu.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/module.h>
 #include <asm/current.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
@@ -172,6 +173,8 @@ void ppc64_enable_pmcs(void)
 }
 #endif
 
+EXPORT_SYMBOL_GPL(ppc64_enable_pmcs);
+
 /* XXX convert to rusty's on_one_cpu */
 static unsigned long run_on_cpu(unsigned long cpu,
                                unsigned long (*func)(unsigned long),
index 5f70f7b..b6770e3 100644 (file)
@@ -116,6 +116,8 @@ int die(const char *str, struct pt_regs *regs, long err)
        if (nl)
                printk("\n");
        show_regs(regs);
+       if (netdump_func)
+               netdump_func(regs);
        bust_spinlocks(0);
        spin_unlock_irq(&die_lock);
 
@@ -123,6 +125,8 @@ int die(const char *str, struct pt_regs *regs, long err)
                panic("Fatal exception in interrupt");
 
        if (panic_on_oops) {
+               if (netdump_func)
+                       netdump_func = NULL;
                printk(KERN_EMERG "Fatal exception: panic in 5 seconds\n");
                set_current_state(TASK_UNINTERRUPTIBLE);
                schedule_timeout(5 * HZ);
index 0306bab..691b25e 100644 (file)
@@ -4,6 +4,6 @@
 
 EXTRA_CFLAGS += -mno-minimal-toc
 
-obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o tlb.o slb_low.o slb.o
+obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o tlb.o slb_low.o slb.o mmap.o
 obj-$(CONFIG_DISCONTIGMEM) += numa.o
 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
index b704e00..403c79b 100644 (file)
@@ -125,7 +125,8 @@ static void setup_huge_pte(struct mm_struct *mm, struct page *page,
        hugepte_t entry;
        int i;
 
-       mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       vx_rsspages_sub(mm, HPAGE_SIZE / PAGE_SIZE);
        entry = mk_hugepte(page, write_access);
        for (i = 0; i < HUGEPTE_BATCH_SIZE; i++)
                set_hugepte(ptep+i, entry);
@@ -287,7 +288,8 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                        /* This is the first hugepte in a batch */
                        ptepage = hugepte_page(entry);
                        get_page(ptepage);
-                       dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+                       // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+                       vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
                }
                set_hugepte(dst_pte, entry);
 
@@ -410,7 +412,8 @@ void unmap_hugepage_range(struct vm_area_struct *vma,
        }
        put_cpu();
 
-       mm->rss -= (end - start) >> PAGE_SHIFT;
+       // mm->rss -= (end - start) >> PAGE_SHIFT;
+       vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
 }
 
 int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
diff --git a/arch/ppc64/mm/slb.c b/arch/ppc64/mm/slb.c
deleted file mode 100644 (file)
index bc61258..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * PowerPC64 SLB support.
- *
- * Copyright (C) 2004 David Gibson <dwg@au.ibm.com>, IBM
- * Based on earlier code writteh by:
- * Dave Engebretsen and Mike Corrigan {engebret|mikejc}@us.ibm.com
- *    Copyright (c) 2001 Dave Engebretsen
- * Copyright (C) 2002 Anton Blanchard <anton@au.ibm.com>, IBM
- *
- *
- *      This program is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU General Public License
- *      as published by the Free Software Foundation; either version
- *      2 of the License, or (at your option) any later version.
- */
-
-#include <linux/config.h>
-#include <asm/pgtable.h>
-#include <asm/mmu.h>
-#include <asm/mmu_context.h>
-#include <asm/paca.h>
-#include <asm/naca.h>
-#include <asm/cputable.h>
-
-extern void slb_allocate(unsigned long ea);
-
-static inline void create_slbe(unsigned long ea, unsigned long vsid,
-                              unsigned long flags, unsigned long entry)
-{
-       ea = (ea & ESID_MASK) | SLB_ESID_V | entry;
-       vsid = (vsid << SLB_VSID_SHIFT) | flags;
-       asm volatile("slbmte  %0,%1" :
-                    : "r" (vsid), "r" (ea)
-                    : "memory" );
-}
-
-static void slb_add_bolted(void)
-{
-#ifndef CONFIG_PPC_ISERIES
-       WARN_ON(!irqs_disabled());
-
-       /* If you change this make sure you change SLB_NUM_BOLTED
-        * appropriately too */
-
-       /* Slot 1 - first VMALLOC segment
-         *     Since modules end up there it gets hit very heavily.
-         */
-       create_slbe(VMALLOCBASE, get_kernel_vsid(VMALLOCBASE),
-                   SLB_VSID_KERNEL, 1);
-
-       asm volatile("isync":::"memory");
-#endif
-}
-
-/* Flush all user entries from the segment table of the current processor. */
-void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
-{
-       unsigned long offset = get_paca()->slb_cache_ptr;
-       unsigned long esid_data;
-       unsigned long pc = KSTK_EIP(tsk);
-       unsigned long stack = KSTK_ESP(tsk);
-       unsigned long unmapped_base;
-
-       if (offset <= SLB_CACHE_ENTRIES) {
-               int i;
-               asm volatile("isync" : : : "memory");
-               for (i = 0; i < offset; i++) {
-                       esid_data = (unsigned long)get_paca()->slb_cache[i]
-                               << SID_SHIFT;
-                       asm volatile("slbie %0" : : "r" (esid_data));
-               }
-               asm volatile("isync" : : : "memory");
-       } else {
-               asm volatile("isync; slbia; isync" : : : "memory");
-               slb_add_bolted();
-       }
-
-       /* Workaround POWER5 < DD2.1 issue */
-       if (offset == 1 || offset > SLB_CACHE_ENTRIES) {
-               /* flush segment in EEH region, we shouldn't ever
-                * access addresses in this region. */
-               asm volatile("slbie %0" : : "r"(EEHREGIONBASE));
-       }
-
-       get_paca()->slb_cache_ptr = 0;
-       get_paca()->context = mm->context;
-
-       /*
-        * preload some userspace segments into the SLB.
-        */
-       if (test_tsk_thread_flag(tsk, TIF_32BIT))
-               unmapped_base = TASK_UNMAPPED_BASE_USER32;
-       else
-               unmapped_base = TASK_UNMAPPED_BASE_USER64;
-
-       if (pc >= KERNELBASE)
-               return;
-       slb_allocate(pc);
-
-       if (GET_ESID(pc) == GET_ESID(stack))
-               return;
-
-       if (stack >= KERNELBASE)
-               return;
-       slb_allocate(stack);
-
-       if ((GET_ESID(pc) == GET_ESID(unmapped_base))
-           || (GET_ESID(stack) == GET_ESID(unmapped_base)))
-               return;
-
-       if (unmapped_base >= KERNELBASE)
-               return;
-       slb_allocate(unmapped_base);
-}
-
-void slb_initialize(void)
-{
-#ifdef CONFIG_PPC_ISERIES
-       asm volatile("isync; slbia; isync":::"memory");
-#else
-       unsigned long flags = SLB_VSID_KERNEL;
-
-       /* Invalidate the entire SLB (even slot 0) & all the ERATS */
-       if (cur_cpu_spec->cpu_features & CPU_FTR_16M_PAGE)
-               flags |= SLB_VSID_L;
-
-       asm volatile("isync":::"memory");
-       asm volatile("slbmte  %0,%0"::"r" (0) : "memory");
-       asm volatile("isync; slbia; isync":::"memory");
-       create_slbe(KERNELBASE, get_kernel_vsid(KERNELBASE),
-                   flags, 0);
-
-#endif
-       slb_add_bolted();
-       get_paca()->stab_rr = SLB_NUM_BOLTED;
-}
diff --git a/arch/ppc64/mm/slb_low.S b/arch/ppc64/mm/slb_low.S
deleted file mode 100644 (file)
index 4b3dfe0..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * arch/ppc64/mm/slb_low.S
- *
- * Low-level SLB routines
- *
- * Copyright (C) 2004 David Gibson <dwg@au.ibm.com>, IBM
- *
- * Based on earlier C version:
- * Dave Engebretsen and Mike Corrigan {engebret|mikejc}@us.ibm.com
- *    Copyright (c) 2001 Dave Engebretsen
- * Copyright (C) 2002 Anton Blanchard <anton@au.ibm.com>, IBM
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public License
- *  as published by the Free Software Foundation; either version
- *  2 of the License, or (at your option) any later version.
- */
-
-#include <linux/config.h>
-#include <asm/processor.h>
-#include <asm/page.h>
-#include <asm/mmu.h>
-#include <asm/ppc_asm.h>
-#include <asm/offsets.h>
-#include <asm/cputable.h>
-
-/* void slb_allocate(unsigned long ea);
- *
- * Create an SLB entry for the given EA (user or kernel).
- *     r3 = faulting address, r13 = PACA
- *     r9, r10, r11 are clobbered by this function
- * No other registers are examined or changed.
- */
-_GLOBAL(slb_allocate)
-       /*
-        * First find a slot, round robin. Previously we tried to find
-        * a free slot first but that took too long. Unfortunately we
-        * dont have any LRU information to help us choose a slot.
-        */
-       ld      r10,PACASTABRR(r13)
-3:
-       addi    r10,r10,1
-       /* use a cpu feature mask if we ever change our slb size */
-       cmpldi  r10,SLB_NUM_ENTRIES
-
-       blt+    4f
-       li      r10,SLB_NUM_BOLTED
-
-       /*
-        * Never cast out the segment for our kernel stack. Since we
-        * dont invalidate the ERAT we could have a valid translation
-        * for the kernel stack during the first part of exception exit
-        * which gets invalidated due to a tlbie from another cpu at a
-        * non recoverable point (after setting srr0/1) - Anton
-        */
-4:     slbmfee r11,r10
-       srdi    r11,r11,27
-       /*
-        * Use paca->ksave as the value of the kernel stack pointer,
-        * because this is valid at all times.
-        * The >> 27 (rather than >> 28) is so that the LSB is the
-        * valid bit - this way we check valid and ESID in one compare.
-        * In order to completely close the tiny race in the context
-        * switch (between updating r1 and updating paca->ksave),
-        * we check against both r1 and paca->ksave.
-        */
-       srdi    r9,r1,27
-       ori     r9,r9,1                 /* mangle SP for later compare */
-       cmpd    r11,r9
-       beq-    3b
-       ld      r9,PACAKSAVE(r13)
-       srdi    r9,r9,27
-       ori     r9,r9,1
-       cmpd    r11,r9
-       beq-    3b
-
-       std     r10,PACASTABRR(r13)
-
-       /* r3 = faulting address, r10 = entry */
-
-       srdi    r9,r3,60                /* get region */
-       srdi    r3,r3,28                /* get esid */
-       cmpldi  cr7,r9,0xc              /* cmp KERNELBASE for later use */
-
-       /* r9 = region, r3 = esid, cr7 = <>KERNELBASE */
-
-       rldicr. r11,r3,32,16
-       bne-    8f                      /* invalid ea bits set */
-       addi    r11,r9,-1
-       cmpldi  r11,0xb
-       blt-    8f                      /* invalid region */
-
-       /* r9 = region, r3 = esid, r10 = entry, cr7 = <>KERNELBASE */
-
-       blt     cr7,0f                  /* user or kernel? */
-
-       /* kernel address */
-       li      r11,SLB_VSID_KERNEL
-BEGIN_FTR_SECTION
-       bne     cr7,9f
-       li      r11,(SLB_VSID_KERNEL|SLB_VSID_L)
-END_FTR_SECTION_IFSET(CPU_FTR_16M_PAGE)
-       b       9f
-
-0:     /* user address */
-       li      r11,SLB_VSID_USER
-#ifdef CONFIG_HUGETLB_PAGE
-BEGIN_FTR_SECTION
-       /* check against the hugepage ranges */
-       cmpldi  r3,(TASK_HPAGE_END>>SID_SHIFT)
-       bge     6f                      /* >= TASK_HPAGE_END */
-       cmpldi  r3,(TASK_HPAGE_BASE>>SID_SHIFT)
-       bge     5f                      /* TASK_HPAGE_BASE..TASK_HPAGE_END */
-       cmpldi  r3,16
-       bge     6f                      /* 4GB..TASK_HPAGE_BASE */
-
-       lhz     r9,PACAHTLBSEGS(r13)
-       srd     r9,r9,r3
-       andi.   r9,r9,1
-       beq     6f
-
-5:     /* this is a hugepage user address */
-       li      r11,(SLB_VSID_USER|SLB_VSID_L)
-END_FTR_SECTION_IFSET(CPU_FTR_16M_PAGE)
-#endif /* CONFIG_HUGETLB_PAGE */
-
-6:     ld      r9,PACACONTEXTID(r13)
-
-9:     /* r9 = "context", r3 = esid, r11 = flags, r10 = entry */
-
-       rldimi  r9,r3,15,0              /* r9= VSID ordinal */
-
-7:     rldimi  r10,r3,28,0             /* r10= ESID<<28 | entry */
-       oris    r10,r10,SLB_ESID_V@h    /* r10 |= SLB_ESID_V */
-
-       /* r9 = ordinal, r3 = esid, r11 = flags, r10 = esid_data */
-
-       li      r3,VSID_RANDOMIZER@higher
-       sldi    r3,r3,32
-       oris    r3,r3,VSID_RANDOMIZER@h
-       ori     r3,r3,VSID_RANDOMIZER@l
-
-       mulld   r9,r3,r9                /* r9 = ordinal * VSID_RANDOMIZER */
-       clrldi  r9,r9,28                /* r9 &= VSID_MASK */
-       sldi    r9,r9,SLB_VSID_SHIFT    /* r9 <<= SLB_VSID_SHIFT */
-       or      r9,r9,r11               /* r9 |= flags */
-
-       /* r9 = vsid_data, r10 = esid_data, cr7 = <>KERNELBASE */
-
-       /*
-        * No need for an isync before or after this slbmte. The exception
-        * we enter with and the rfid we exit with are context synchronizing.
-        */
-       slbmte  r9,r10
-
-       bgelr   cr7                     /* we're done for kernel addresses */
-
-       /* Update the slb cache */
-       lhz     r3,PACASLBCACHEPTR(r13) /* offset = paca->slb_cache_ptr */
-       cmpldi  r3,SLB_CACHE_ENTRIES
-       bge     1f
-
-       /* still room in the slb cache */
-       sldi    r11,r3,1                /* r11 = offset * sizeof(u16) */
-       rldicl  r10,r10,36,28           /* get low 16 bits of the ESID */
-       add     r11,r11,r13             /* r11 = (u16 *)paca + offset */
-       sth     r10,PACASLBCACHE(r11)   /* paca->slb_cache[offset] = esid */
-       addi    r3,r3,1                 /* offset++ */
-       b       2f
-1:                                     /* offset >= SLB_CACHE_ENTRIES */
-       li      r3,SLB_CACHE_ENTRIES+1
-2:
-       sth     r3,PACASLBCACHEPTR(r13) /* paca->slb_cache_ptr = offset */
-       blr
-
-8:     /* invalid EA */
-       li      r9,0                    /* 0 VSID ordinal -> BAD_VSID */
-       li      r11,SLB_VSID_USER       /* flags don't much matter */
-       b       7b
index ce8cb18..d112120 100644 (file)
@@ -443,6 +443,8 @@ config DEBUG_SPINLOCK_SLEEP
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 68c1a72..df7c55f 100644 (file)
@@ -57,6 +57,11 @@ boot         := arch/$(ARCH)/boot
 
 all: image
 
+# This is a white lie which helps to keep our spec simpler.
+# No $(Q) or other trickery because nobody should use it outside of RPM builds.
+bzImage: image
+       ln -s image arch/$(ARCH)/boot/bzImage
+
 install: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $@
 
index a67fd8a..6ead7ff 100644 (file)
@@ -15,4 +15,4 @@ $(obj)/image: vmlinux FORCE
 
 install: $(CONFIGURE) $(obj)/image
        sh -x $(obj)/install.sh $(KERNELRELEASE) $(obj)/image \
-             System.map Kerntypes "$(INSTALL_PATH)"
+             System.map init/kerntypes.o "$(INSTALL_PATH)"
index 278a813..860bebc 100644 (file)
@@ -16,7 +16,8 @@
 #   $1 - kernel version
 #   $2 - kernel image file
 #   $3 - kernel map file
-#   $4 - default install path (blank if root directory)
+#   $4 - kernel type file
+#   $5 - default install path (blank if root directory)
 #
 
 # User may have a custom install script
@@ -26,13 +27,22 @@ if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi
 
 # Default install - same as make zlilo
 
-if [ -f $4/vmlinuz ]; then
-       mv $4/vmlinuz $4/vmlinuz.old
+if [ -f $5/vmlinuz ]; then
+       mv $5/vmlinuz $5/vmlinuz.old
 fi
 
-if [ -f $4/System.map ]; then
-       mv $4/System.map $4/System.old
+if [ -f $5/System.map ]; then
+       mv $5/System.map $5/System.old
 fi
 
-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
+if [ -f $5/Kerntypes ]; then
+       mv $5/Kerntypes $5/Kerntypes.old
+fi
+
+cat $2 > $5/vmlinuz
+cp $3 $5/System.map
+
+# copy the kernel type file if it exists
+if [ -f $4 ]; then
+       cp $4 $5/Kerntypes
+fi
index 595c43a..3e781bd 100644 (file)
@@ -36,7 +36,7 @@
 
 int setup_arg_pages32(struct linux_binprm *bprm, int executable_stack)
 {
-       unsigned long stack_base;
+       unsigned long stack_base, grow;
        struct vm_area_struct *mpnt;
        struct mm_struct *mm = current->mm;
        int i;
@@ -53,7 +53,10 @@ int setup_arg_pages32(struct linux_binprm *bprm, int executable_stack)
        if (!mpnt) 
                return -ENOMEM; 
        
-       if (security_vm_enough_memory((STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
+       grow = (STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
+               >> PAGE_SHIFT;
+       if (security_vm_enough_memory(grow) ||
+               !vx_vmpages_avail(mm, grow)) {
                kmem_cache_free(vm_area_cachep, mpnt);
                return -ENOMEM;
        }
@@ -69,7 +72,9 @@ int setup_arg_pages32(struct linux_binprm *bprm, int executable_stack)
                mpnt->vm_page_prot = PAGE_COPY;
                mpnt->vm_flags = VM_STACK_FLAGS;
                insert_vm_struct(mm, mpnt);
-               mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               // mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               vx_vmpages_sub(mm, mm->total_vm -
+                       ((mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT));
        } 
 
        for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
index 26b89e5..6e35d53 100644 (file)
@@ -695,9 +695,11 @@ sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = do_ptrace(child, request, addr, data);
-
+out_tsk:
        put_task_struct(child);
 out:
        unlock_kernel();
index 9186fe7..d17ba7b 100644 (file)
@@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_settime,sys32_clock_settime_wrapper)
 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper)       /* 260 */
 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
-NI_SYSCALL                                                     /* reserved for vserver */
+SYSCALL(sys_vserver,sys_vserver,sys_vserver)
 SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
index 6614d4b..cbe2ffb 100644 (file)
@@ -243,12 +243,17 @@ void die(const char * str, struct pt_regs * regs, long err)
        bust_spinlocks(1);
        printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
         show_regs(regs);
+       if (netdump_func)
+               netdump_func(regs);
        bust_spinlocks(0);
         spin_unlock_irq(&die_lock);
        if (in_interrupt())
                panic("Fatal exception in interrupt");
-       if (panic_on_oops)
+       if (panic_on_oops) {
+               if (netdump_func)
+                        netdump_func = NULL;
                panic("Fatal exception: panic_on_oops");
+       }
         do_exit(SIGSEGV);
 }
 
diff --git a/arch/s390/lib/memset.S b/arch/s390/lib/memset.S
deleted file mode 100644 (file)
index 447af53..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *  arch/s390/lib/memset.S
- *    S390 fast memset routine
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address to memory area
- * R3 = byte to fill memory with
- * R4 = number of bytes to fill
- */
-        .globl  memset
-memset:
-        LTR     4,4
-        JZ      memset_end
-        LR      0,2                    # save pointer to memory area
-        LR      1,3                    # move pad byte to R1
-        LR      3,4
-        SR      4,4                    # no source for MVCLE, only a pad byte
-        SR      5,5
-        MVCLE   2,4,0(1)               # thats it, MVCLE is your friend
-        JO      .-4
-        LR      2,0                    # return pointer to mem.
-memset_end:
-        BR      14
-        
-
diff --git a/arch/s390/lib/memset64.S b/arch/s390/lib/memset64.S
deleted file mode 100644 (file)
index 1e4b035..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *  arch/s390/lib/memset.S
- *    S390 fast memset routine
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address to memory area
- * R3 = byte to fill memory with
- * R4 = number of bytes to fill
- */
-        .globl  memset
-memset:
-        LTGR    4,4
-        JZ      memset_end
-        LGR     0,2                    # save pointer to memory area
-        LGR     1,3                    # move pad byte to R1
-        LGR     3,4
-        SGR     4,4                    # no source for MVCLE, only a pad byte
-        SGR     5,5
-        MVCLE   2,4,0(1)               # thats it, MVCLE is your friend
-        JO      .-4
-        LGR     2,0                    # return pointer to mem.
-memset_end:
-        BR      14
-        
-
diff --git a/arch/s390/lib/strcmp.S b/arch/s390/lib/strcmp.S
deleted file mode 100644 (file)
index 340edff..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *  arch/s390/lib/strcmp.S
- *    S390 strcmp routine
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of compare string
- * R3 = address of test string
- */
-        .globl   strcmp
-strcmp:
-        SR      0,0
-        SR      1,1
-        CLST    2,3
-        JO      .-4
-        JE      strcmp_equal
-        IC      0,0(3)
-        IC      1,0(2)
-        SR      1,0
-strcmp_equal:
-        LR      2,1
-        BR      14
-        
diff --git a/arch/s390/lib/strcmp64.S b/arch/s390/lib/strcmp64.S
deleted file mode 100644 (file)
index 124f3df..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *  arch/s390/lib/strcmp.S
- *    S390 strcmp routine
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of compare string
- * R3 = address of test string
- */
-        .globl   strcmp
-strcmp:
-        SGR     0,0
-        SGR     1,1
-        CLST    2,3
-        JO      .-4
-        JE      strcmp_equal
-        IC      0,0(3)
-        IC      1,0(2)
-        SGR     1,0
-strcmp_equal:
-        LGR     2,1
-        BR      14
-        
diff --git a/arch/s390/lib/strcpy.S b/arch/s390/lib/strcpy.S
deleted file mode 100644 (file)
index 1d36b9c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- *  arch/s390/kernel/strcpy.S
- *    S390 strcpy routine
- *
- *  S390 version
- *    Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- */
-        .globl   strcpy
-strcpy:
-       sr      %r0,%r0
-0:     mvst    %r2,%r3
-       jo      0b
-       br      %r14
-
diff --git a/arch/s390/lib/strcpy64.S b/arch/s390/lib/strcpy64.S
deleted file mode 100644 (file)
index 06815dc..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- *  arch/s390/kernel/strcpy.S
- *    S390 strcpy routine
- *
- *  S390 version
- *    Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- */
-        .globl   strcpy
-strcpy:
-       sgr     %r0,%r0
-0:     mvst    %r2,%r3
-       jo      0b
-       br      %r14
-
diff --git a/arch/s390/lib/strncpy.S b/arch/s390/lib/strncpy.S
deleted file mode 100644 (file)
index a3285bd..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *  arch/s390/kernel/strncpy.S
- *    S390 strncpy routine
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- * R4 = max number of bytes to copy
- */
-        .globl   strncpy
-strncpy:
-        LR      1,2            # don't touch address in R2
-       LTR     4,4
-        JZ      strncpy_exit   # 0 bytes -> nothing to do
-       SR      0,0
-strncpy_loop:
-        ICM     0,1,0(3)       # ICM sets the cc, IC does not
-       LA      3,1(3)
-        STC     0,0(1)
-       LA      1,1(1)
-        JZ      strncpy_pad    # ICM inserted a 0x00
-        BRCT    4,strncpy_loop # R4 -= 1, jump to strncpy_loop if >  0
-strncpy_exit:
-        BR      14
-strncpy_clear:
-       STC     0,0(1)
-       LA      1,1(1)
-strncpy_pad:
-       BRCT    4,strncpy_clear
-       BR      14
diff --git a/arch/s390/lib/strncpy64.S b/arch/s390/lib/strncpy64.S
deleted file mode 100644 (file)
index 1e455e5..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *  arch/s390/kernel/strncpy.S
- *    S390 strncpy routine
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- * R4 = max number of bytes to copy
- */
-        .globl   strncpy
-strncpy:
-        LGR     1,2            # don't touch address in R2
-       LTR     4,4
-        JZ      strncpy_exit   # 0 bytes -> nothing to do
-       SGR     0,0
-strncpy_loop:
-        ICM     0,1,0(3)       # ICM sets the cc, IC does not
-       LA      3,1(3)
-        STC     0,0(1)
-       LA      1,1(1)
-        JZ      strncpy_pad    # ICM inserted a 0x00
-        BRCTG   4,strncpy_loop # R4 -= 1, jump to strncpy_loop if > 0
-strncpy_exit:
-        BR      14
-strncpy_clear:
-       STC     0,0(1)
-       LA      1,1(1)
-strncpy_pad:
-       BRCTG   4,strncpy_clear
-       BR      14
index f8583ca..aa9a42b 100644 (file)
@@ -2,6 +2,6 @@
 # Makefile for the linux s390-specific parts of the memory manager.
 #
 
-obj-y   := init.o fault.o ioremap.o extmem.o
+obj-y   := init.o fault.o ioremap.o extmem.o mmap.o
 obj-$(CONFIG_CMM) += cmm.o
 
index 1541b86..d8d3c3f 100644 (file)
@@ -240,6 +240,11 @@ void __init paging_init(void)
 }
 #endif /* CONFIG_ARCH_S390X */
 
+int page_is_ram (unsigned long pagenr)
+{
+       return pagenr < max_mapnr;
+}
+
 void __init mem_init(void)
 {
        unsigned long codesize, reservedpages, datasize, initsize;
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
deleted file mode 100644 (file)
index 1039196..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *  linux/arch/s390/mm/mmap.c
- *
- *  flexible mmap layout support
- *
- * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *
- * Started by Ingo Molnar <mingo@elte.hu>
- */
-
-#include <linux/personality.h>
-#include <linux/mm.h>
-
-/*
- * Top of mmap area (just below the process stack).
- *
- * Leave an at least ~128 MB hole.
- */
-#define MIN_GAP (128*1024*1024)
-#define MAX_GAP (TASK_SIZE/6*5)
-
-static inline unsigned long mmap_base(void)
-{
-       unsigned long gap = current->rlim[RLIMIT_STACK].rlim_cur;
-
-       if (gap < MIN_GAP)
-               gap = MIN_GAP;
-       else if (gap > MAX_GAP)
-               gap = MAX_GAP;
-
-       return TASK_SIZE - (gap & PAGE_MASK);
-}
-
-static inline int mmap_is_legacy(void)
-{
-#ifdef CONFIG_ARCH_S390X
-       /*
-        * Force standard allocation for 64 bit programs.
-        */
-       if (!test_thread_flag(TIF_31BIT))
-               return 1;
-#endif
-       return sysctl_legacy_va_layout ||
-           (current->personality & ADDR_COMPAT_LAYOUT) ||
-           current->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY;
-}
-
-/*
- * This function, called very early during the creation of a new
- * process VM image, sets up which VM layout function to use:
- */
-void arch_pick_mmap_layout(struct mm_struct *mm)
-{
-       /*
-        * Fall back to the standard layout if the personality
-        * bit is set, or if the expected stack growth is unlimited:
-        */
-       if (mmap_is_legacy()) {
-               mm->mmap_base = TASK_UNMAPPED_BASE;
-               mm->get_unmapped_area = arch_get_unmapped_area;
-               mm->unmap_area = arch_unmap_area;
-       } else {
-               mm->mmap_base = mmap_base();
-               mm->get_unmapped_area = arch_get_unmapped_area_topdown;
-               mm->unmap_area = arch_unmap_area_topdown;
-       }
-}
index ce61d06..2140eb0 100644 (file)
@@ -894,6 +894,8 @@ config FRAME_POINTER
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
diff --git a/arch/sh/boards/systemh/Makefile b/arch/sh/boards/systemh/Makefile
deleted file mode 100644 (file)
index 858d4d9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Makefile for the SystemH specific parts of the kernel
-#
-
-obj-y   := setup.o irq.o io.o
-
-# XXX: This wants to be consolidated in arch/sh/drivers/pci, and more
-# importantly, with the generic sh7751_pcic_init() code. For now, we'll
-# just abuse the hell out of kbuild, because we can..
-
-obj-$(CONFIG_PCI) += pci.o
-pci-y := ../se/7751/pci.o
-
diff --git a/arch/sh/boards/systemh/io.c b/arch/sh/boards/systemh/io.c
deleted file mode 100644 (file)
index bb10cb6..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/* 
- * linux/arch/sh/boards/systemh/io.c
- *
- * Copyright (C) 2001  Ian da Silva, Jeremy Siegel
- * Based largely on io_se.c.
- *
- * I/O routine for Hitachi 7751 Systemh.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <asm/systemh/7751systemh.h>
-#include <asm/addrspace.h>
-#include <asm/io.h>
-
-#include <linux/pci.h>
-#include "../../drivers/pci/pci-sh7751.h"
-
-/*
- * The 7751 SystemH Engine uses the built-in PCI controller (PCIC)
- * of the 7751 processor, and has a SuperIO accessible on its memory 
- * bus.
- */ 
-
-#define PCIIOBR                (volatile long *)PCI_REG(SH7751_PCIIOBR)
-#define PCIMBR          (volatile long *)PCI_REG(SH7751_PCIMBR)
-#define PCI_IO_AREA    SH7751_PCI_IO_BASE
-#define PCI_MEM_AREA   SH7751_PCI_CONFIG_BASE
-
-#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
-#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area
-                                                of smc lan chip*/ 
-
-#define maybebadio(name,port) \
-  printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
-        #name, (port), (__u32) __builtin_return_address(0))
-
-static inline void delay(void)
-{
-       ctrl_inw(0xa0000000);
-}
-
-static inline volatile __u16 *
-port2adr(unsigned int port)
-{
-       if (port >= 0x2000)
-               return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
-#if 0
-       else
-               return (volatile __u16 *) (PA_SUPERIO + (port << 1));
-#endif
-       maybebadio(name,(unsigned long)port);
-       return (volatile __u16*)port;
-}
-
-/* In case someone configures the kernel w/o PCI support: in that */
-/* scenario, don't ever bother to check for PCI-window addresses */
-
-/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
-#if defined(CONFIG_PCI)
-#define CHECK_SH7751_PCIIO(port) \
-  ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
-#else
-#define CHECK_SH7751_PCIIO(port) (0)
-#endif
-
-/*
- * General outline: remap really low stuff [eventually] to SuperIO,
- * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
- * is mapped through the PCI IO window.  Stuff with high bits (PXSEG)
- * should be way beyond the window, and is used  w/o translation for
- * compatibility.
- */
-unsigned char sh7751systemh_inb(unsigned long port)
-{
-       if (PXSEG(port))
-               return *(volatile unsigned char *)port;
-       else if (CHECK_SH7751_PCIIO(port))
-               return *(volatile unsigned char *)PCI_IOMAP(port);
-       else if (port <= 0x3F1)
-               return *(volatile unsigned char *)ETHER_IOMAP(port);
-       else
-               return (*port2adr(port))&0xff; 
-}
-
-unsigned char sh7751systemh_inb_p(unsigned long port)
-{
-       unsigned char v;
-
-        if (PXSEG(port))
-                v = *(volatile unsigned char *)port;
-       else if (CHECK_SH7751_PCIIO(port))
-                v = *(volatile unsigned char *)PCI_IOMAP(port);
-       else if (port <= 0x3F1)
-               v = *(volatile unsigned char *)ETHER_IOMAP(port);
-       else
-               v = (*port2adr(port))&0xff; 
-       delay();
-       return v;
-}
-
-unsigned short sh7751systemh_inw(unsigned long port)
-{
-        if (PXSEG(port))
-                return *(volatile unsigned short *)port;
-       else if (CHECK_SH7751_PCIIO(port))
-                return *(volatile unsigned short *)PCI_IOMAP(port);
-       else if (port >= 0x2000)
-               return *port2adr(port);
-       else if (port <= 0x3F1)
-               return *(volatile unsigned int *)ETHER_IOMAP(port);
-       else
-               maybebadio(inw, port);
-       return 0;
-}
-
-unsigned int sh7751systemh_inl(unsigned long port)
-{
-        if (PXSEG(port))
-                return *(volatile unsigned long *)port;
-       else if (CHECK_SH7751_PCIIO(port))
-                return *(volatile unsigned int *)PCI_IOMAP(port);
-       else if (port >= 0x2000)
-               return *port2adr(port);
-       else if (port <= 0x3F1)
-               return *(volatile unsigned int *)ETHER_IOMAP(port);
-       else
-               maybebadio(inl, port);
-       return 0;
-}
-
-void sh7751systemh_outb(unsigned char value, unsigned long port)
-{
-
-        if (PXSEG(port))
-                *(volatile unsigned char *)port = value;
-       else if (CHECK_SH7751_PCIIO(port))
-               *((unsigned char*)PCI_IOMAP(port)) = value;
-       else if (port <= 0x3F1)
-               *(volatile unsigned char *)ETHER_IOMAP(port) = value;
-       else
-               *(port2adr(port)) = value;
-}
-
-void sh7751systemh_outb_p(unsigned char value, unsigned long port)
-{
-        if (PXSEG(port))
-                *(volatile unsigned char *)port = value;
-       else if (CHECK_SH7751_PCIIO(port))
-               *((unsigned char*)PCI_IOMAP(port)) = value;
-       else if (port <= 0x3F1)
-               *(volatile unsigned char *)ETHER_IOMAP(port) = value;
-       else
-               *(port2adr(port)) = value;
-       delay();
-}
-
-void sh7751systemh_outw(unsigned short value, unsigned long port)
-{
-        if (PXSEG(port))
-                *(volatile unsigned short *)port = value;
-       else if (CHECK_SH7751_PCIIO(port))
-               *((unsigned short *)PCI_IOMAP(port)) = value;
-       else if (port >= 0x2000)
-               *port2adr(port) = value;
-       else if (port <= 0x3F1)
-               *(volatile unsigned short *)ETHER_IOMAP(port) = value;
-       else
-               maybebadio(outw, port);
-}
-
-void sh7751systemh_outl(unsigned int value, unsigned long port)
-{
-        if (PXSEG(port))
-                *(volatile unsigned long *)port = value;
-       else if (CHECK_SH7751_PCIIO(port))
-               *((unsigned long*)PCI_IOMAP(port)) = value;
-       else
-               maybebadio(outl, port);
-}
-
-void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count)
-{
-       unsigned char *p = addr;
-       while (count--) *p++ = sh7751systemh_inb(port);
-}
-
-void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count)
-{
-       unsigned short *p = addr;
-       while (count--) *p++ = sh7751systemh_inw(port);
-}
-
-void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count)
-{
-       maybebadio(insl, port);
-}
-
-void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count)
-{
-       unsigned char *p = (unsigned char*)addr;
-       while (count--) sh7751systemh_outb(*p++, port);
-}
-
-void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long count)
-{
-       unsigned short *p = (unsigned short*)addr;
-       while (count--) sh7751systemh_outw(*p++, port);
-}
-
-void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count)
-{
-       maybebadio(outsw, port);
-}
-
-/* For read/write calls, just copy generic (pass-thru); PCIMBR is  */
-/* already set up.  For a larger memory space, these would need to */
-/* reset PCIMBR as needed on a per-call basis...                   */
-
-unsigned char sh7751systemh_readb(unsigned long addr)
-{
-       return *(volatile unsigned char*)addr;
-}
-
-unsigned short sh7751systemh_readw(unsigned long addr)
-{
-       return *(volatile unsigned short*)addr;
-}
-
-unsigned int sh7751systemh_readl(unsigned long addr)
-{
-       return *(volatile unsigned long*)addr;
-}
-
-void sh7751systemh_writeb(unsigned char b, unsigned long addr)
-{
-       *(volatile unsigned char*)addr = b;
-}
-
-void sh7751systemh_writew(unsigned short b, unsigned long addr)
-{
-       *(volatile unsigned short*)addr = b;
-}
-
-void sh7751systemh_writel(unsigned int b, unsigned long addr)
-{
-        *(volatile unsigned long*)addr = b;
-}
-
-\f
-
-/* Map ISA bus address to the real address. Only for PCMCIA.  */
-
-/* ISA page descriptor.  */
-static __u32 sh_isa_memmap[256];
-
-#if 0
-static int
-sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
-{
-       int idx;
-
-       if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
-               return -1;
-
-       idx = start >> 12;
-       sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
-       printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
-              start, length, offset, idx, sh_isa_memmap[idx]);
-       return 0;
-}
-#endif
-
-unsigned long
-sh7751systemh_isa_port2addr(unsigned long offset)
-{
-       int idx;
-
-       idx = (offset >> 12) & 0xff;
-       offset &= 0xfff;
-       return sh_isa_memmap[idx] + offset;
-}
diff --git a/arch/sh/boards/systemh/irq.c b/arch/sh/boards/systemh/irq.c
deleted file mode 100644 (file)
index cc9ea89..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* 
- * linux/arch/sh/boards/systemh/irq.c
- *
- * Copyright (C) 2000  Kazumoto Kojima
- *
- * Hitachi SystemH Support.
- *
- * Modified for 7751 SystemH by
- * Jonathan Short.
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-
-#include <linux/hdreg.h>
-#include <linux/ide.h>
-#include <asm/io.h>
-#include <asm/mach/7751systemh.h>
-#include <asm/smc37c93x.h>
-
-/* address of external interrupt mask register
- * address must be set prior to use these (maybe in init_XXX_irq())
- * XXX : is it better to use .config than specifying it in code? */
-static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
-static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
-
-/* forward declaration */
-static unsigned int startup_systemh_irq(unsigned int irq);
-static void shutdown_systemh_irq(unsigned int irq);
-static void enable_systemh_irq(unsigned int irq);
-static void disable_systemh_irq(unsigned int irq);
-static void mask_and_ack_systemh(unsigned int);
-static void end_systemh_irq(unsigned int irq);
-
-/* hw_interrupt_type */
-static struct hw_interrupt_type systemh_irq_type = {
-       " SystemH Register",
-       startup_systemh_irq,
-       shutdown_systemh_irq,
-       enable_systemh_irq,
-       disable_systemh_irq,
-       mask_and_ack_systemh,
-       end_systemh_irq
-};
-
-static unsigned int startup_systemh_irq(unsigned int irq)
-{ 
-       enable_systemh_irq(irq);
-       return 0; /* never anything pending */
-}
-
-static void shutdown_systemh_irq(unsigned int irq)
-{
-       disable_systemh_irq(irq);
-}
-
-static void disable_systemh_irq(unsigned int irq)
-{
-       if (systemh_irq_mask_register) {
-               unsigned long flags;
-               unsigned long val, mask = 0x01 << 1;
-
-               /* Clear the "irq"th bit in the mask and set it in the request */
-               local_irq_save(flags);
-
-               val = ctrl_inl((unsigned long)systemh_irq_mask_register);
-               val &= ~mask;
-               ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
-
-               val = ctrl_inl((unsigned long)systemh_irq_request_register);
-               val |= mask;
-               ctrl_outl(val, (unsigned long)systemh_irq_request_register);
-
-               local_irq_restore(flags);
-       }
-}
-
-static void enable_systemh_irq(unsigned int irq)
-{
-       if (systemh_irq_mask_register) {
-               unsigned long flags;
-               unsigned long val, mask = 0x01 << 1;
-
-               /* Set "irq"th bit in the mask register */
-               local_irq_save(flags);
-               val = ctrl_inl((unsigned long)systemh_irq_mask_register);
-               val |= mask;
-               ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
-               local_irq_restore(flags);
-       }
-}
-
-static void mask_and_ack_systemh(unsigned int irq)
-{
-       disable_systemh_irq(irq);
-}
-
-static void end_systemh_irq(unsigned int irq)
-{
-       if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
-               enable_systemh_irq(irq);
-}
-
-void make_systemh_irq(unsigned int irq)
-{
-       disable_irq_nosync(irq);
-       irq_desc[irq].handler = &systemh_irq_type;
-       disable_systemh_irq(irq);
-}
-
diff --git a/arch/sh/boards/systemh/setup.c b/arch/sh/boards/systemh/setup.c
deleted file mode 100644 (file)
index 7f26345..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* 
- * linux/arch/sh/boards/systemh/setup.c
- *
- * Copyright (C) 2000  Kazumoto Kojima
- * Copyright (C) 2003  Paul Mundt
- *
- * Hitachi SystemH Support.
- *
- * Modified for 7751 SystemH by Jonathan Short.
- *
- * Rewritten for 2.6 by Paul Mundt.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-#include <linux/init.h>
-#include <asm/mach/7751systemh.h>
-#include <asm/mach/io.h>
-#include <asm/machvec.h>
-
-extern void make_systemh_irq(unsigned int irq);
-
-const char *get_system_type(void)
-{
-       return "7751 SystemH";
-}
-
-/*
- * Initialize IRQ setting
- */
-void __init init_7751systemh_IRQ(void)
-{
-/*     make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); LAN */
-/*     make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-4); */
-       make_systemh_irq(0xb);  /* Ethernet interrupt */
-}
-
-struct sh_machine_vector mv_7751systemh __initmv = {
-       .mv_nr_irqs             = 72,
-
-       .mv_inb                 = sh7751systemh_inb,
-       .mv_inw                 = sh7751systemh_inw,
-       .mv_inl                 = sh7751systemh_inl,
-       .mv_outb                = sh7751systemh_outb,
-       .mv_outw                = sh7751systemh_outw,
-       .mv_outl                = sh7751systemh_outl,
-
-       .mv_inb_p               = sh7751systemh_inb_p,
-       .mv_inw_p               = sh7751systemh_inw,
-       .mv_inl_p               = sh7751systemh_inl,
-       .mv_outb_p              = sh7751systemh_outb_p,
-       .mv_outw_p              = sh7751systemh_outw,
-       .mv_outl_p              = sh7751systemh_outl,
-
-       .mv_insb                = sh7751systemh_insb,
-       .mv_insw                = sh7751systemh_insw,
-       .mv_insl                = sh7751systemh_insl,
-       .mv_outsb               = sh7751systemh_outsb,
-       .mv_outsw               = sh7751systemh_outsw,
-       .mv_outsl               = sh7751systemh_outsl,
-
-       .mv_readb               = sh7751systemh_readb,
-       .mv_readw               = sh7751systemh_readw,
-       .mv_readl               = sh7751systemh_readl,
-       .mv_writeb              = sh7751systemh_writeb,
-       .mv_writew              = sh7751systemh_writew,
-       .mv_writel              = sh7751systemh_writel,
-
-       .mv_isa_port2addr       = sh7751systemh_isa_port2addr,
-
-       .mv_init_irq            = init_7751systemh_IRQ,
-};
-ALIAS_MV(7751systemh)
-
-int __init platform_setup(void)
-{
-       return 0;
-}
-
diff --git a/arch/sh/configs/rts7751r2d_defconfig b/arch/sh/configs/rts7751r2d_defconfig
deleted file mode 100644 (file)
index b724a51..0000000
+++ /dev/null
@@ -1,808 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_SUPERH=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODULE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System type
-#
-# CONFIG_SH_SOLUTION_ENGINE is not set
-# CONFIG_SH_7751_SOLUTION_ENGINE is not set
-# CONFIG_SH_7751_SYSTEMH is not set
-# CONFIG_SH_STB1_HARP is not set
-# CONFIG_SH_STB1_OVERDRIVE is not set
-# CONFIG_SH_HP620 is not set
-# CONFIG_SH_HP680 is not set
-# CONFIG_SH_HP690 is not set
-# CONFIG_SH_CQREEK is not set
-# CONFIG_SH_DMIDA is not set
-# CONFIG_SH_EC3104 is not set
-# CONFIG_SH_SATURN is not set
-# CONFIG_SH_DREAMCAST is not set
-# CONFIG_SH_CAT68701 is not set
-# CONFIG_SH_BIGSUR is not set
-# CONFIG_SH_SH2000 is not set
-# CONFIG_SH_ADX is not set
-# CONFIG_SH_MPC1211 is not set
-# CONFIG_SH_SECUREEDGE5410 is not set
-CONFIG_SH_RTS7751R2D=y
-# CONFIG_SH_UNKNOWN is not set
-# CONFIG_CPU_SH2 is not set
-# CONFIG_CPU_SH3 is not set
-CONFIG_CPU_SH4=y
-# CONFIG_CPU_SUBTYPE_SH7604 is not set
-# CONFIG_CPU_SUBTYPE_SH7300 is not set
-# CONFIG_CPU_SUBTYPE_SH7707 is not set
-# CONFIG_CPU_SUBTYPE_SH7708 is not set
-# CONFIG_CPU_SUBTYPE_SH7709 is not set
-# CONFIG_CPU_SUBTYPE_SH7750 is not set
-CONFIG_CPU_SUBTYPE_SH7751=y
-# CONFIG_CPU_SUBTYPE_SH7760 is not set
-# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
-CONFIG_MMU=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="mem=64M console=ttySC0,115200 root=/dev/hda1"
-CONFIG_MEMORY_START=0x0c000000
-CONFIG_MEMORY_SIZE=0x04000000
-CONFIG_MEMORY_SET=y
-# CONFIG_MEMORY_OVERRIDE is not set
-CONFIG_SH_RTC=y
-CONFIG_ZERO_PAGE_OFFSET=0x00010000
-CONFIG_BOOT_LINK_OFFSET=0x00800000
-CONFIG_CPU_LITTLE_ENDIAN=y
-# CONFIG_PREEMPT is not set
-# CONFIG_UBC_WAKEUP is not set
-# CONFIG_SH_WRITETHROUGH is not set
-# CONFIG_SH_OCRAM is not set
-# CONFIG_SH_STORE_QUEUES is not set
-# CONFIG_SMP is not set
-CONFIG_VOYAGERGX=y
-CONFIG_RTS7751R2D_REV11=y
-CONFIG_SH_PCLK_FREQ=60000000
-# CONFIG_CPU_FREQ is not set
-CONFIG_SH_DMA=y
-CONFIG_NR_ONCHIP_DMA_CHANNELS=8
-# CONFIG_NR_DMA_CHANNELS_BOOL is not set
-# CONFIG_DMA_PAGE_OPS is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
-#
-CONFIG_ISA=y
-CONFIG_PCI=y
-CONFIG_SH_PCIDMA_NONCOHERENT=y
-CONFIG_PCI_AUTO=y
-CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
-CONFIG_PCI_DMA=y
-# CONFIG_PCI_LEGACY_PROC is not set
-CONFIG_PCI_NAMES=y
-CONFIG_HOTPLUG=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=m
-CONFIG_YENTA=m
-CONFIG_CARDBUS=y
-# CONFIG_I82092 is not set
-# CONFIG_I82365 is not set
-# CONFIG_TCIC is not set
-CONFIG_PCMCIA_PROBE=y
-
-#
-# PCI Hotplug Support
-#
-CONFIG_HOTPLUG_PCI=y
-# CONFIG_HOTPLUG_PCI_FAKE is not set
-# CONFIG_HOTPLUG_PCI_CPCI is not set
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_FLAT is not set
-# CONFIG_BINFMT_MISC is not set
-
-#
-# Generic Driver Options
-#
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
-CONFIG_BLK_DEV_IDECS=m
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_IDEPCI is not set
-# CONFIG_IDE_CHIPSETS is not set
-# CONFIG_BLK_DEV_IDEDMA is not set
-# CONFIG_IDEDMA_AUTO is not set
-# CONFIG_DMA_NONPCI is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-# CONFIG_IP_PNP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_STNIC is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_LANCE is not set
-# CONFIG_NET_VENDOR_SMC is not set
-# CONFIG_NET_VENDOR_RACAL is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_AT1700 is not set
-# CONFIG_DEPCA is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_ISA=y
-# CONFIG_E2100 is not set
-# CONFIG_EWRK3 is not set
-# CONFIG_EEXPRESS is not set
-# CONFIG_EEXPRESS_PRO is not set
-# CONFIG_HPLAN_PLUS is not set
-# CONFIG_HPLAN is not set
-# CONFIG_LP486E is not set
-# CONFIG_ETH16I is not set
-CONFIG_NE2000=m
-# CONFIG_ZNET is not set
-# CONFIG_SEEQ8005 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_AC3200 is not set
-# CONFIG_APRICOT is not set
-# CONFIG_B44 is not set
-# CONFIG_CS89x0 is not set
-# CONFIG_DGRS is not set
-# CONFIG_EEPRO100 is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-CONFIG_8139TOO=y
-# CONFIG_8139TOO_PIO is not set
-# CONFIG_8139TOO_TUNE_TWISTER is not set
-# CONFIG_8139TOO_8129 is not set
-# CONFIG_8139_OLD_RX_RESET is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-# CONFIG_NET_POCKET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-CONFIG_NET_RADIO=y
-
-#
-# Obsolete Wireless cards support (pre-802.11)
-#
-# CONFIG_STRIP is not set
-# CONFIG_ARLAN is not set
-# CONFIG_WAVELAN is not set
-# CONFIG_PCMCIA_WAVELAN is not set
-# CONFIG_PCMCIA_NETWAVE is not set
-
-#
-# Wireless 802.11 Frequency Hopping cards support
-#
-# CONFIG_PCMCIA_RAYCS is not set
-
-#
-# Wireless 802.11b ISA/PCI cards support
-#
-# CONFIG_AIRO is not set
-CONFIG_HERMES=m
-# CONFIG_PLX_HERMES is not set
-# CONFIG_TMD_HERMES is not set
-# CONFIG_PCI_HERMES is not set
-
-#
-# Wireless 802.11b Pcmcia/Cardbus cards support
-#
-CONFIG_PCMCIA_HERMES=m
-# CONFIG_AIRO_CS is not set
-# CONFIG_PCMCIA_ATMEL is not set
-# CONFIG_PCMCIA_WL3501 is not set
-CONFIG_NET_WIRELESS=y
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# PCMCIA network device support
-#
-# CONFIG_NET_PCMCIA is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-# CONFIG_SERIO_I8042 is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL is not set
-CONFIG_SH_SCI=y
-CONFIG_SERIAL_CONSOLE=y
-CONFIG_RTC_9701JE=y
-
-#
-# Unix 98 PTY support
-#
-# CONFIG_UNIX98_PTYS is not set
-CONFIG_HEARTBEAT=y
-# CONFIG_PSMOUSE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_RTC is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-# CONFIG_SERIAL_SH_SCI is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Algorithms
-#
-
-#
-# I2C Hardware Bus support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-CONFIG_MINIX_FS=y
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-CONFIG_VFAT_FS=y
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-# CONFIG_NFS_FS is not set
-# CONFIG_NFSD is not set
-# CONFIG_EXPORTFS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-CONFIG_NLS=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-CONFIG_NLS_CODEPAGE_932=y
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-
-#
-# Advanced Linux Sound Architecture
-#
-CONFIG_SND=m
-# CONFIG_SND_SEQUENCER is not set
-# CONFIG_SND_OSSEMUL is not set
-# CONFIG_SND_VERBOSE_PRINTK is not set
-# CONFIG_SND_DEBUG is not set
-
-#
-# Generic devices
-#
-# CONFIG_SND_DUMMY is not set
-# CONFIG_SND_MTPAV is not set
-# CONFIG_SND_SERIAL_U16550 is not set
-# CONFIG_SND_MPU401 is not set
-
-#
-# ISA devices
-#
-# CONFIG_SND_AD1848 is not set
-# CONFIG_SND_CS4231 is not set
-# CONFIG_SND_CS4232 is not set
-# CONFIG_SND_CS4236 is not set
-# CONFIG_SND_ES1688 is not set
-# CONFIG_SND_ES18XX is not set
-# CONFIG_SND_GUSCLASSIC is not set
-# CONFIG_SND_GUSEXTREME is not set
-# CONFIG_SND_GUSMAX is not set
-# CONFIG_SND_INTERWAVE is not set
-# CONFIG_SND_INTERWAVE_STB is not set
-# CONFIG_SND_OPTI92X_AD1848 is not set
-# CONFIG_SND_OPTI92X_CS4231 is not set
-# CONFIG_SND_OPTI93X is not set
-# CONFIG_SND_SB8 is not set
-# CONFIG_SND_SB16 is not set
-# CONFIG_SND_SBAWE is not set
-# CONFIG_SND_WAVEFRONT is not set
-# CONFIG_SND_CMI8330 is not set
-# CONFIG_SND_OPL3SA2 is not set
-# CONFIG_SND_SGALAXY is not set
-# CONFIG_SND_SSCAPE is not set
-
-#
-# PCI devices
-#
-# CONFIG_SND_ALI5451 is not set
-# CONFIG_SND_AZT3328 is not set
-# CONFIG_SND_CS46XX is not set
-# CONFIG_SND_CS4281 is not set
-# CONFIG_SND_EMU10K1 is not set
-# CONFIG_SND_KORG1212 is not set
-# CONFIG_SND_NM256 is not set
-# CONFIG_SND_RME32 is not set
-# CONFIG_SND_RME96 is not set
-# CONFIG_SND_RME9652 is not set
-# CONFIG_SND_HDSP is not set
-# CONFIG_SND_TRIDENT is not set
-CONFIG_SND_YMFPCI=m
-# CONFIG_SND_ALS4000 is not set
-# CONFIG_SND_CMIPCI is not set
-# CONFIG_SND_ENS1370 is not set
-# CONFIG_SND_ENS1371 is not set
-# CONFIG_SND_ES1938 is not set
-# CONFIG_SND_ES1968 is not set
-# CONFIG_SND_MAESTRO3 is not set
-# CONFIG_SND_FM801 is not set
-# CONFIG_SND_ICE1712 is not set
-# CONFIG_SND_ICE1724 is not set
-# CONFIG_SND_INTEL8X0 is not set
-# CONFIG_SND_SONICVIBES is not set
-# CONFIG_SND_VIA82XX is not set
-# CONFIG_SND_VX222 is not set
-
-#
-# PCMCIA devices
-#
-# CONFIG_SND_VXPOCKET is not set
-# CONFIG_SND_VXP440 is not set
-
-#
-# Open Sound System
-#
-CONFIG_SOUND_PRIME=m
-# CONFIG_SOUND_BT878 is not set
-CONFIG_SOUND_CMPCI=m
-# CONFIG_SOUND_CMPCI_FM is not set
-# CONFIG_SOUND_CMPCI_MIDI is not set
-# CONFIG_SOUND_CMPCI_JOYSTICK is not set
-# CONFIG_SOUND_CMPCI_CM8738 is not set
-# CONFIG_SOUND_EMU10K1 is not set
-# CONFIG_SOUND_FUSION is not set
-# CONFIG_SOUND_CS4281 is not set
-# CONFIG_SOUND_ES1370 is not set
-# CONFIG_SOUND_ES1371 is not set
-# CONFIG_SOUND_ESSSOLO1 is not set
-# CONFIG_SOUND_MAESTRO is not set
-# CONFIG_SOUND_MAESTRO3 is not set
-# CONFIG_SOUND_ICH is not set
-# CONFIG_SOUND_SONICVIBES is not set
-# CONFIG_SOUND_TRIDENT is not set
-# CONFIG_SOUND_MSNDCLAS is not set
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_VIA82CXXX is not set
-# CONFIG_SOUND_OSS is not set
-# CONFIG_SOUND_ALI5455 is not set
-# CONFIG_SOUND_FORTE is not set
-# CONFIG_SOUND_RME96XX is not set
-# CONFIG_SOUND_AD1980 is not set
-CONFIG_SOUND_VOYAGERGX=m
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-# CONFIG_USB_GADGET is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_SH_STANDARD_BIOS is not set
-# CONFIG_KGDB is not set
-# CONFIG_FRAME_POINTER is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
index 0178269..bfdfa74 100644 (file)
@@ -108,6 +108,8 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 4d5d687..4bc9703 100644 (file)
@@ -62,7 +62,8 @@ static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma,
        unsigned long i;
        pte_t entry;
 
-       mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
 
        if (write_access)
                entry = pte_mkwrite(pte_mkdirty(mk_pte(page,
@@ -115,7 +116,8 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                        pte_val(entry) += PAGE_SIZE;
                        dst_pte++;
                }
-               dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
                addr += HPAGE_SIZE;
        }
        return 0;
@@ -206,7 +208,8 @@ void unmap_hugepage_range(struct vm_area_struct *vma,
                        pte++;
                }
        }
-       mm->rss -= (end - start) >> PAGE_SHIFT;
+       // mm->rss -= (end - start) >> PAGE_SHIFT;
+       vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
        flush_tlb_range(vma, start, end);
 }
 
diff --git a/arch/sh64/configs/cayman_defconfig b/arch/sh64/configs/cayman_defconfig
deleted file mode 100644 (file)
index 2d1b415..0000000
+++ /dev/null
@@ -1,659 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_SUPERH=y
-CONFIG_SUPERH64=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_LOG_BUF_SHIFT=14
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-# CONFIG_SYSVIPC is not set
-CONFIG_POSIX_MQUEUE=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# System type
-#
-# CONFIG_SH_GENERIC is not set
-# CONFIG_SH_SIMULATOR is not set
-CONFIG_SH_CAYMAN=y
-# CONFIG_SH_ROMRAM is not set
-# CONFIG_SH_HARP is not set
-
-#
-# Processor type and features
-#
-CONFIG_CPU_SH5=y
-CONFIG_CPU_SUBTYPE_SH5_101=y
-# CONFIG_CPU_SUBTYPE_SH5_103 is not set
-CONFIG_LITTLE_ENDIAN=y
-# CONFIG_BIG_ENDIAN is not set
-# CONFIG_SH64_FPU_DENORM_FLUSH is not set
-CONFIG_SH64_PGTABLE_2_LEVEL=y
-# CONFIG_SH64_PGTABLE_3_LEVEL is not set
-CONFIG_HUGETLB_PAGE_SIZE_64K=y
-# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
-# CONFIG_HUGETLB_PAGE_SIZE_512MB is not set
-CONFIG_SH64_USER_MISALIGNED_FIXUP=y
-
-#
-# Memory options
-#
-CONFIG_CACHED_MEMORY_OFFSET=0x20000000
-CONFIG_MEMORY_START=0x80000000
-CONFIG_MEMORY_SIZE_IN_MB=128
-
-#
-# Cache options
-#
-# CONFIG_DCACHE_DISABLED is not set
-CONFIG_DCACHE_WRITE_BACK=y
-# CONFIG_DCACHE_WRITE_THROUGH is not set
-# CONFIG_ICACHE_DISABLED is not set
-CONFIG_PCIDEVICE_MEMORY_START=C0000000
-CONFIG_DEVICE_MEMORY_START=E0000000
-CONFIG_FLASH_MEMORY_START=0x00000000
-CONFIG_PCI_BLOCK_START=0x40000000
-
-#
-# CPU Subtype specific options
-#
-CONFIG_SH64_ID2815_WORKAROUND=y
-
-#
-# Misc options
-#
-CONFIG_HEARTBEAT=y
-CONFIG_HDSP253_LED=y
-CONFIG_SH_DMA=y
-CONFIG_PREEMPT=y
-
-#
-# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
-#
-CONFIG_PCI=y
-CONFIG_SH_PCIDMA_NONCOHERENT=y
-CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_FLAT is not set
-# CONFIG_BINFMT_MISC is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_STNIC is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-CONFIG_NET_TULIP=y
-# CONFIG_DE2104X is not set
-CONFIG_TULIP=y
-# CONFIG_TULIP_MWI is not set
-# CONFIG_TULIP_MMIO is not set
-# CONFIG_TULIP_NAPI is not set
-# CONFIG_DE4X5 is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_DM9102 is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-# CONFIG_EEPRO100 is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-CONFIG_INPUT_MOUSE=y
-CONFIG_MOUSE_PS2=y
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_MOUSE_VSXXXAA is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_SH_SCI=y
-CONFIG_SERIAL_SH_SCI_CONSOLE=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-# CONFIG_SH_WDT is not set
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-CONFIG_FB=y
-# CONFIG_FB_PM2 is not set
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_ASILIANT is not set
-# CONFIG_FB_IMSTT is not set
-# CONFIG_FB_E1355 is not set
-# CONFIG_FB_RIVA is not set
-# CONFIG_FB_MATROX is not set
-# CONFIG_FB_RADEON_OLD is not set
-# CONFIG_FB_RADEON is not set
-# CONFIG_FB_ATY128 is not set
-# CONFIG_FB_ATY is not set
-# CONFIG_FB_SIS is not set
-# CONFIG_FB_NEOMAGIC is not set
-CONFIG_FB_KYRO=y
-# CONFIG_FB_3DFX is not set
-# CONFIG_FB_VOODOO1 is not set
-# CONFIG_FB_TRIDENT is not set
-# CONFIG_FB_VIRTUAL is not set
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE=y
-CONFIG_PCI_CONSOLE=y
-CONFIG_FONTS=y
-# CONFIG_FONT_8x8 is not set
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_6x11 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-# CONFIG_FONT_MINI_4x6 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_SUN12x22 is not set
-
-#
-# Logo configuration
-#
-CONFIG_LOGO=y
-# CONFIG_LOGO_LINUX_MONO is not set
-# CONFIG_LOGO_LINUX_VGA16 is not set
-# CONFIG_LOGO_LINUX_CLUT224 is not set
-# CONFIG_LOGO_SUPERH_MONO is not set
-# CONFIG_LOGO_SUPERH_VGA16 is not set
-CONFIG_LOGO_SUPERH_CLUT224=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-CONFIG_MINIX_FS=y
-CONFIG_ROMFS_FS=y
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_HUGETLBFS=y
-CONFIG_HUGETLB_PAGE=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Kernel hacking
-#
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_EARLY_PRINTK is not set
-# CONFIG_DEBUG_KERNEL_WITH_GDB_STUB is not set
-# CONFIG_SH64_PROC_TLB is not set
-# CONFIG_SH64_PROC_ASIDS is not set
-CONFIG_SH64_SR_WATCH=y
-# CONFIG_SH_ALPHANUMERIC is not set
-# CONFIG_SH_NO_BSS_INIT is not set
-CONFIG_FRAME_POINTER=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
diff --git a/arch/sh64/defconfig b/arch/sh64/defconfig
deleted file mode 100644 (file)
index 8cfca49..0000000
+++ /dev/null
@@ -1,667 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_SUPERH=y
-CONFIG_SUPERH64=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_LOG_BUF_SHIFT=14
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-# CONFIG_SYSVIPC is not set
-CONFIG_POSIX_MQUEUE=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-# CONFIG_IKCONFIG is not set
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# System type
-#
-# CONFIG_SH_GENERIC is not set
-# CONFIG_SH_SIMULATOR is not set
-CONFIG_SH_CAYMAN=y
-# CONFIG_SH_ROMRAM is not set
-# CONFIG_SH_HARP is not set
-CONFIG_CPU_SH5=y
-CONFIG_CPU_SUBTYPE_SH5_101=y
-# CONFIG_CPU_SUBTYPE_SH5_103 is not set
-CONFIG_LITTLE_ENDIAN=y
-# CONFIG_BIG_ENDIAN is not set
-# CONFIG_SH64_FPU_DENORM_FLUSH is not set
-CONFIG_SH64_PGTABLE_2_LEVEL=y
-# CONFIG_SH64_PGTABLE_3_LEVEL is not set
-CONFIG_HUGETLB_PAGE_SIZE_64K=y
-# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
-# CONFIG_HUGETLB_PAGE_SIZE_512MB is not set
-CONFIG_SH64_USER_MISALIGNED_FIXUP=y
-
-#
-# Memory options
-#
-CONFIG_CACHED_MEMORY_OFFSET=0x20000000
-CONFIG_MEMORY_START=0x80000000
-CONFIG_MEMORY_SIZE_IN_MB=128
-
-#
-# Cache options
-#
-# CONFIG_DCACHE_DISABLED is not set
-CONFIG_DCACHE_WRITE_BACK=y
-# CONFIG_DCACHE_WRITE_THROUGH is not set
-# CONFIG_ICACHE_DISABLED is not set
-CONFIG_PCIDEVICE_MEMORY_START=C0000000
-CONFIG_DEVICE_MEMORY_START=E0000000
-CONFIG_FLASH_MEMORY_START=0x00000000
-CONFIG_PCI_BLOCK_START=0x40000000
-
-#
-# CPU Subtype specific options
-#
-CONFIG_SH64_ID2815_WORKAROUND=y
-
-#
-# Misc options
-#
-CONFIG_HEARTBEAT=y
-CONFIG_HDSP253_LED=y
-CONFIG_SH_DMA=y
-CONFIG_PREEMPT=y
-
-#
-# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
-#
-CONFIG_PCI=y
-CONFIG_SH_PCIDMA_NONCOHERENT=y
-CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_FLAT is not set
-# CONFIG_BINFMT_MISC is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_STNIC is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-CONFIG_NET_TULIP=y
-# CONFIG_DE2104X is not set
-CONFIG_TULIP=y
-# CONFIG_TULIP_MWI is not set
-# CONFIG_TULIP_MMIO is not set
-# CONFIG_TULIP_NAPI is not set
-# CONFIG_DE4X5 is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_DM9102 is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-# CONFIG_EEPRO100 is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_VELOCITY is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-CONFIG_INPUT_MOUSE=y
-CONFIG_MOUSE_PS2=y
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_MOUSE_VSXXXAA is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_SH_SCI=y
-CONFIG_SERIAL_SH_SCI_CONSOLE=y
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-# CONFIG_SH_WDT is not set
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-CONFIG_FB=y
-# CONFIG_FB_CIRRUS is not set
-# CONFIG_FB_PM2 is not set
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_ASILIANT is not set
-# CONFIG_FB_IMSTT is not set
-# CONFIG_FB_E1355 is not set
-# CONFIG_FB_RIVA is not set
-# CONFIG_FB_MATROX is not set
-# CONFIG_FB_RADEON_OLD is not set
-# CONFIG_FB_RADEON is not set
-# CONFIG_FB_ATY128 is not set
-# CONFIG_FB_ATY is not set
-# CONFIG_FB_SIS is not set
-# CONFIG_FB_NEOMAGIC is not set
-CONFIG_FB_KYRO=y
-# CONFIG_FB_3DFX is not set
-# CONFIG_FB_VOODOO1 is not set
-# CONFIG_FB_TRIDENT is not set
-# CONFIG_FB_VIRTUAL is not set
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE=y
-CONFIG_PCI_CONSOLE=y
-CONFIG_FONTS=y
-# CONFIG_FONT_8x8 is not set
-CONFIG_FONT_8x16=y
-# CONFIG_FONT_6x11 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
-# CONFIG_FONT_MINI_4x6 is not set
-# CONFIG_FONT_SUN8x16 is not set
-# CONFIG_FONT_SUN12x22 is not set
-
-#
-# Logo configuration
-#
-CONFIG_LOGO=y
-# CONFIG_LOGO_LINUX_MONO is not set
-# CONFIG_LOGO_LINUX_VGA16 is not set
-# CONFIG_LOGO_LINUX_CLUT224 is not set
-# CONFIG_LOGO_SUPERH_MONO is not set
-# CONFIG_LOGO_SUPERH_VGA16 is not set
-CONFIG_LOGO_SUPERH_CLUT224=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-CONFIG_MINIX_FS=y
-CONFIG_ROMFS_FS=y
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_HUGETLBFS=y
-CONFIG_HUGETLB_PAGE=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Profiling support
-#
-CONFIG_PROFILING=y
-# CONFIG_OPROFILE is not set
-
-#
-# Kernel hacking
-#
-CONFIG_MAGIC_SYSRQ=y
-# CONFIG_EARLY_PRINTK is not set
-# CONFIG_DEBUG_KERNEL_WITH_GDB_STUB is not set
-# CONFIG_SH64_PROC_TLB is not set
-# CONFIG_SH64_PROC_ASIDS is not set
-CONFIG_SH64_SR_WATCH=y
-# CONFIG_SH_ALPHANUMERIC is not set
-# CONFIG_SH_NO_BSS_INIT is not set
-CONFIG_FRAME_POINTER=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC16 is not set
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
index 7d0688a..02ce6cc 100644 (file)
@@ -452,6 +452,8 @@ config DEBUG_BUGVERBOSE
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 15fcf89..6a9edfe 100644 (file)
@@ -53,6 +53,9 @@ all: image
 
 boot := arch/sparc/boot
 
+bzImage: image
+       cp $(boot)/image $(boot)/bzImage
+
 image tftpboot.img: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
index d838bd8..949072b 100644 (file)
@@ -321,6 +321,10 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
                pt_error_return(regs, ESRCH);
                goto out;
        }
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
+               pt_error_return(regs, ESRCH);
+               goto out_tsk;
+       }
 
        if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
            || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
index a17dbc3..0787907 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/utsname.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
@@ -471,13 +472,13 @@ asmlinkage int sys_getdomainname(char __user *name, int len)
        
        down_read(&uts_sem);
        
-       nlen = strlen(system_utsname.domainname) + 1;
+       nlen = strlen(vx_new_uts(domainname)) + 1;
 
        if (nlen < len)
                len = nlen;
        if (len > __NEW_UTS_LEN)
                goto done;
-       if (copy_to_user(name, system_utsname.domainname, len))
+       if (copy_to_user(name, vx_new_uts(domainname), len))
                goto done;
        err = 0;
 done:
index fd452a6..56c8c87 100644 (file)
@@ -72,7 +72,7 @@ sys_call_table:
 /*250*/        .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
 /*255*/        .long sys_nis_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
 /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
-/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
+/*265*/        .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
 /*270*/        .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
 /*275*/        .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_ni_syscall
 /*280*/        .long sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
index 6044288..c85f8f2 100644 (file)
@@ -708,6 +708,8 @@ config FRAME_POINTER
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index fc57c40..d33535f 100644 (file)
@@ -69,6 +69,9 @@ drivers-$(CONFIG_OPROFILE)    += arch/sparc64/oprofile/
 
 boot := arch/sparc64/boot
 
+bzImage: image
+       cp $(boot)/image $(boot)/bzImage
+
 image tftpboot.img vmlinux.aout: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
index 3dbf266..ae92b77 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/binfmts.h>
 #include <linux/personality.h>
 #include <linux/init.h>
+#include <linux/vs_memory.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -239,7 +240,8 @@ static int load_aout32_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        current->mm->brk = ex.a_bss +
                (current->mm->start_brk = N_BSSADDR(ex));
 
-       current->mm->rss = 0;
+       // current->mm->rss = 0;
+       vx_rsspages_sub(current->mm, current->mm->rss);
        current->mm->mmap = NULL;
        compute_creds(bprm);
        current->flags &= ~PF_FORKNOEXEC;
index 3e9aa09..8e5e098 100644 (file)
@@ -172,6 +172,10 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
                pt_error_return(regs, ESRCH);
                goto out;
        }
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
+               pt_error_return(regs, ESRCH);
+               goto out_tsk;
+       }
 
        if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
            || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
index 76e62d4..3d6fd1e 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/syscalls.h>
 #include <linux/ipc.h>
 #include <linux/personality.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
@@ -465,13 +466,13 @@ asmlinkage long sys_getdomainname(char __user *name, int len)
 
        down_read(&uts_sem);
        
-       nlen = strlen(system_utsname.domainname) + 1;
+       nlen = strlen(vx_new_uts(domainname)) + 1;
 
         if (nlen < len)
                 len = nlen;
        if (len > __NEW_UTS_LEN)
                goto done;
-       if (copy_to_user(name, system_utsname.domainname, len))
+       if (copy_to_user(name, vx_new_uts(domainname), len))
                goto done;
        err = 0;
 done:
index a937ab7..4aee276 100644 (file)
@@ -73,7 +73,7 @@ sys_call_table32:
 /*250*/        .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
        .word sys_ni_syscall, sys32_clock_settime, compat_clock_gettime, compat_clock_getres, sys32_clock_nanosleep
 /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_timer_gettime, sys_timer_getoverrun
-       .word sys_timer_delete, sys32_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
+       .word sys_timer_delete, sys32_timer_create, sys_vserver, compat_sys_io_setup, sys_io_destroy
 /*270*/        .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
        .word sys_mq_timedsend, sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, sys_ni_syscall
 /*280*/        .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
@@ -139,7 +139,7 @@ sys_call_table:
 /*250*/        .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
        .word sys_ni_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
 /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
-       .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
+       .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
 /*270*/        .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
        .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_ni_syscall
 /*280*/        .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
diff --git a/arch/sparc64/lib/blockops.S b/arch/sparc64/lib/blockops.S
deleted file mode 100644 (file)
index 8413038..0000000
+++ /dev/null
@@ -1,451 +0,0 @@
-/* $Id: blockops.S,v 1.42 2002/02/09 19:49:30 davem Exp $
- * blockops.S: UltraSparc block zero optimized routines.
- *
- * Copyright (C) 1996, 1998, 1999, 2000 David S. Miller (davem@redhat.com)
- * Copyright (C) 1997 Jakub Jelinek (jakub@redhat.com)
- */
-
-#include "VIS.h"
-#include <asm/visasm.h>
-#include <asm/thread_info.h>
-#include <asm/page.h>
-#include <asm/dcu.h>
-#include <asm/spitfire.h>
-#include <asm/pgtable.h>
-
-#define TOUCH(reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7)  \
-       fmovd   %reg0, %f48;    fmovd   %reg1, %f50;            \
-       fmovd   %reg2, %f52;    fmovd   %reg3, %f54;            \
-       fmovd   %reg4, %f56;    fmovd   %reg5, %f58;            \
-       fmovd   %reg6, %f60;    fmovd   %reg7, %f62;
-
-#define        DCACHE_SIZE     (PAGE_SIZE * 2)
-#define TLBTEMP_ENT1   (60 << 3)
-#define TLBTEMP_ENT2   (61 << 3)
-#define TLBTEMP_ENTSZ  (1 << 3)
-
-#if (PAGE_SHIFT == 13) || (PAGE_SHIFT == 19)
-#define PAGE_SIZE_REM  0x80
-#elif (PAGE_SHIFT == 16) || (PAGE_SHIFT == 22)
-#define PAGE_SIZE_REM  0x100
-#else
-#error Wrong PAGE_SHIFT specified
-#endif
-
-       .text
-
-       .align          32
-       .globl          copy_user_page
-       .type           copy_user_page,@function
-copy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
-       VISEntry
-       sethi           %hi(PAGE_SIZE), %g3
-       sethi           %uhi(PAGE_OFFSET), %g2
-       sllx            %g2, 32, %g2
-       sub             %o0, %g2, %g1
-       and             %o2, %g3, %o0
-       sethi           %hi(TLBTEMP_BASE), %o3
-       sethi           %uhi(_PAGE_VALID | _PAGE_SZBITS), %g3
-       sub             %o1, %g2, %g2
-       sllx            %g3, 32, %g3
-       mov             TLB_TAG_ACCESS, %o2
-       or              %g3, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W), %g3
-       sethi           %hi(DCACHE_SIZE), %o1
-       or              %g1, %g3, %g1
-       or              %g2, %g3, %g2
-       add             %o0, %o3, %o0
-       add             %o0, %o1, %o1
-#define FIX_INSN_1     0x96102060 /* mov (12 << 3), %o3 */
-cheetah_patch_1:
-       mov             TLBTEMP_ENT1, %o3
-       rdpr            %pstate, %g3
-       wrpr            %g3, PSTATE_IE, %pstate
-
-       /* Do this now, before loading the fixed TLB entries for copying,
-        * so we do not risk a multiple TLB match condition later when
-        * restoring those entries.
-        */
-       ldx             [%g6 + TI_FLAGS], %g3
-
-       /* Spitfire Errata #32 workaround */
-       mov             PRIMARY_CONTEXT, %o4
-       stxa            %g0, [%o4] ASI_DMMU
-       membar          #Sync
-
-       ldxa            [%o3] ASI_DTLB_TAG_READ, %o4
-
-       /* Spitfire Errata #32 workaround */
-       mov             PRIMARY_CONTEXT, %o5
-       stxa            %g0, [%o5] ASI_DMMU
-       membar          #Sync
-
-       ldxa            [%o3] ASI_DTLB_DATA_ACCESS, %g0
-       ldxa            [%o3] ASI_DTLB_DATA_ACCESS, %o5
-       stxa            %o0, [%o2] ASI_DMMU
-       stxa            %g1, [%o3] ASI_DTLB_DATA_ACCESS
-       membar          #Sync
-       add             %o3, (TLBTEMP_ENTSZ), %o3
-
-       /* Spitfire Errata #32 workaround */
-       mov             PRIMARY_CONTEXT, %g5
-       stxa            %g0, [%g5] ASI_DMMU
-       membar          #Sync
-
-       ldxa            [%o3] ASI_DTLB_TAG_READ, %g5
-
-       /* Spitfire Errata #32 workaround */
-       mov             PRIMARY_CONTEXT, %g7
-       stxa            %g0, [%g7] ASI_DMMU
-       membar          #Sync
-
-       ldxa            [%o3] ASI_DTLB_DATA_ACCESS, %g0
-       ldxa            [%o3] ASI_DTLB_DATA_ACCESS, %g7
-       stxa            %o1, [%o2] ASI_DMMU
-       stxa            %g2, [%o3] ASI_DTLB_DATA_ACCESS
-       membar          #Sync
-
-       andcc           %g3, _TIF_BLKCOMMIT, %g0
-       bne,pn          %xcc, copy_page_using_blkcommit
-        nop
-
-       BRANCH_IF_ANY_CHEETAH(g3,o2,cheetah_copy_user_page)
-       ba,pt           %xcc, spitfire_copy_user_page
-        nop
-
-cheetah_copy_user_page:
-       .globl          cheetah_copy_user_page_nop_1_6
-cheetah_copy_user_page_nop_1_6:
-       ldxa            [%g0] ASI_DCU_CONTROL_REG, %g3
-       sethi           %uhi(DCU_PE), %o2
-       sllx            %o2, 32, %o2
-       or              %g3, %o2, %o2
-       stxa            %o2, [%g0] ASI_DCU_CONTROL_REG  ! Enable P-cache
-       membar          #Sync
-
-       sethi           %hi((PAGE_SIZE/64)-7), %o2      ! A0 Group
-       prefetch        [%o1 + 0x000], #one_read        ! MS
-       or              %o2, %lo((PAGE_SIZE/64)-7), %o2 ! A1 Group
-       prefetch        [%o1 + 0x040], #one_read        ! MS
-       prefetch        [%o1 + 0x080], #one_read        ! MS Group
-       prefetch        [%o1 + 0x0c0], #one_read        ! MS Group
-       ldd             [%o1 + 0x000], %f0              ! MS Group
-       prefetch        [%o1 + 0x100], #one_read        ! MS Group
-       ldd             [%o1 + 0x008], %f2              ! AX
-       prefetch        [%o1 + 0x140], #one_read        ! MS Group
-       ldd             [%o1 + 0x010], %f4              ! AX
-       prefetch        [%o1 + 0x180], #one_read        ! MS Group
-       fmovd           %f0, %f32                       ! FGA Group
-       ldd             [%o1 + 0x018], %f6              ! AX
-       fmovd           %f2, %f34                       ! FGA Group
-       ldd             [%o1 + 0x020], %f8              ! MS
-       fmovd           %f4, %f36                       ! FGA Group
-       ldd             [%o1 + 0x028], %f10             ! AX
-       membar          #StoreStore                     ! MS
-       fmovd           %f6, %f38                       ! FGA Group
-       ldd             [%o1 + 0x030], %f12             ! MS
-       fmovd           %f8, %f40                       ! FGA Group
-       ldd             [%o1 + 0x038], %f14             ! AX
-       fmovd           %f10, %f42                      ! FGA Group
-       ldd             [%o1 + 0x040], %f16             ! MS
-1:     ldd             [%o1 + 0x048], %f2              ! AX (Group)
-       fmovd           %f12, %f44                      ! FGA
-       ldd             [%o1 + 0x050], %f4              ! MS
-       fmovd           %f14, %f46                      ! FGA Group
-       stda            %f32, [%o0] ASI_BLK_P           ! MS
-       ldd             [%o1 + 0x058], %f6              ! AX
-       fmovd           %f16, %f32                      ! FGA Group (8-cycle stall)
-       ldd             [%o1 + 0x060], %f8              ! MS
-       fmovd           %f2, %f34                       ! FGA Group
-       ldd             [%o1 + 0x068], %f10             ! AX
-       fmovd           %f4, %f36                       ! FGA Group
-       ldd             [%o1 + 0x070], %f12             ! MS
-       fmovd           %f6, %f38                       ! FGA Group
-       ldd             [%o1 + 0x078], %f14             ! AX
-       fmovd           %f8, %f40                       ! FGA Group
-       ldd             [%o1 + 0x080], %f16             ! AX
-       prefetch        [%o1 + 0x180], #one_read        ! MS
-       fmovd           %f10, %f42                      ! FGA Group
-       subcc           %o2, 1, %o2                     ! A0
-       add             %o0, 0x40, %o0                  ! A1
-       bne,pt          %xcc, 1b                        ! BR
-        add            %o1, 0x40, %o1                  ! A0 Group
-
-       mov             5, %o2                          ! A0 Group
-1:     ldd             [%o1 + 0x048], %f2              ! AX
-       fmovd           %f12, %f44                      ! FGA
-       ldd             [%o1 + 0x050], %f4              ! MS
-       fmovd           %f14, %f46                      ! FGA Group
-       stda            %f32, [%o0] ASI_BLK_P           ! MS
-       ldd             [%o1 + 0x058], %f6              ! AX
-       fmovd           %f16, %f32                      ! FGA Group (8-cycle stall)
-       ldd             [%o1 + 0x060], %f8              ! MS
-       fmovd           %f2, %f34                       ! FGA Group
-       ldd             [%o1 + 0x068], %f10             ! AX
-       fmovd           %f4, %f36                       ! FGA Group
-       ldd             [%o1 + 0x070], %f12             ! MS
-       fmovd           %f6, %f38                       ! FGA Group
-       ldd             [%o1 + 0x078], %f14             ! AX
-       fmovd           %f8, %f40                       ! FGA Group
-       ldd             [%o1 + 0x080], %f16             ! MS
-       fmovd           %f10, %f42                      ! FGA Group
-       subcc           %o2, 1, %o2                     ! A0
-       add             %o0, 0x40, %o0                  ! A1
-       bne,pt          %xcc, 1b                        ! BR
-        add            %o1, 0x40, %o1                  ! A0 Group
-
-       ldd             [%o1 + 0x048], %f2              ! AX
-       fmovd           %f12, %f44                      ! FGA
-       ldd             [%o1 + 0x050], %f4              ! MS
-       fmovd           %f14, %f46                      ! FGA Group
-       stda            %f32, [%o0] ASI_BLK_P           ! MS
-       ldd             [%o1 + 0x058], %f6              ! AX
-       fmovd           %f16, %f32                      ! FGA Group (8-cycle stall)
-       ldd             [%o1 + 0x060], %f8              ! MS
-       fmovd           %f2, %f34                       ! FGA Group
-       ldd             [%o1 + 0x068], %f10             ! AX
-       fmovd           %f4, %f36                       ! FGA Group
-       ldd             [%o1 + 0x070], %f12             ! MS
-       fmovd           %f6, %f38                       ! FGA Group
-       add             %o0, 0x40, %o0                  ! A0
-       ldd             [%o1 + 0x078], %f14             ! AX
-       fmovd           %f8, %f40                       ! FGA Group
-       fmovd           %f10, %f42                      ! FGA Group
-       fmovd           %f12, %f44                      ! FGA Group
-       fmovd           %f14, %f46                      ! FGA Group
-       stda            %f32, [%o0] ASI_BLK_P           ! MS
-       .globl          cheetah_copy_user_page_nop_2_3
-cheetah_copy_user_page_nop_2_3:
-       mov             PRIMARY_CONTEXT, %o2
-       stxa            %g0, [%o2] ASI_DMMU             ! Flush P-cache
-       stxa            %g3, [%g0] ASI_DCU_CONTROL_REG  ! Disable P-cache
-       ba,a,pt         %xcc, copy_user_page_continue
-
-spitfire_copy_user_page:
-       ldda            [%o1] ASI_BLK_P, %f0
-       add             %o1, 0x40, %o1
-       ldda            [%o1] ASI_BLK_P, %f16
-       add             %o1, 0x40, %o1
-       sethi           %hi(PAGE_SIZE), %o2
-1:     TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
-       ldda            [%o1] ASI_BLK_P, %f32
-       stda            %f48, [%o0] ASI_BLK_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
-       ldda            [%o1] ASI_BLK_P, %f0
-       stda            %f48, [%o0] ASI_BLK_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       TOUCH(f32, f34, f36, f38, f40, f42, f44, f46)
-       ldda            [%o1] ASI_BLK_P, %f16
-       stda            %f48, [%o0] ASI_BLK_P
-       sub             %o2, 0x40, %o2
-       add             %o1, 0x40, %o1
-       cmp             %o2, PAGE_SIZE_REM
-       bne,pt          %xcc, 1b
-        add            %o0, 0x40, %o0
-#if (PAGE_SHIFT == 16) || (PAGE_SHIFT == 22)
-       TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
-       ldda            [%o1] ASI_BLK_P, %f32
-       stda            %f48, [%o0] ASI_BLK_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
-       ldda            [%o1] ASI_BLK_P, %f0
-       stda            %f48, [%o0] ASI_BLK_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       membar          #Sync
-       stda            %f32, [%o0] ASI_BLK_P
-       add             %o0, 0x40, %o0
-       stda            %f0, [%o0] ASI_BLK_P
-#else
-       membar          #Sync
-       stda            %f0, [%o0] ASI_BLK_P
-       add             %o0, 0x40, %o0
-       stda            %f16, [%o0] ASI_BLK_P
-#endif
-copy_user_page_continue:
-       membar          #Sync
-       VISExit
-
-       mov             TLB_TAG_ACCESS, %o2
-       stxa            %g5, [%o2] ASI_DMMU
-       stxa            %g7, [%o3] ASI_DTLB_DATA_ACCESS
-       membar          #Sync
-       sub             %o3, (TLBTEMP_ENTSZ), %o3
-       stxa            %o4, [%o2] ASI_DMMU
-       stxa            %o5, [%o3] ASI_DTLB_DATA_ACCESS
-       membar          #Sync
-       rdpr            %pstate, %g3
-       jmpl            %o7 + 0x8, %g0
-        wrpr           %g3, PSTATE_IE, %pstate
-
-copy_page_using_blkcommit:
-       membar          #LoadStore | #StoreStore | #StoreLoad
-       ldda            [%o1] ASI_BLK_P, %f0
-       add             %o1, 0x40, %o1
-       ldda            [%o1] ASI_BLK_P, %f16
-       add             %o1, 0x40, %o1
-       sethi           %hi(PAGE_SIZE), %o2
-1:     TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
-       ldda            [%o1] ASI_BLK_P, %f32
-       stda            %f48, [%o0] ASI_BLK_COMMIT_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
-       ldda            [%o1] ASI_BLK_P, %f0
-       stda            %f48, [%o0] ASI_BLK_COMMIT_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       TOUCH(f32, f34, f36, f38, f40, f42, f44, f46)
-       ldda            [%o1] ASI_BLK_P, %f16
-       stda            %f48, [%o0] ASI_BLK_COMMIT_P
-       sub             %o2, 0x40, %o2
-       add             %o1, 0x40, %o1
-       cmp             %o2, PAGE_SIZE_REM
-       bne,pt          %xcc, 1b
-        add            %o0, 0x40, %o0
-#if (PAGE_SHIFT == 16) || (PAGE_SHIFT == 22)
-       TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
-       ldda            [%o1] ASI_BLK_P, %f32
-       stda            %f48, [%o0] ASI_BLK_COMMIT_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
-       ldda            [%o1] ASI_BLK_P, %f0
-       stda            %f48, [%o0] ASI_BLK_COMMIT_P
-       add             %o1, 0x40, %o1
-       sub             %o2, 0x40, %o2
-       add             %o0, 0x40, %o0
-       membar          #Sync
-       stda            %f32, [%o0] ASI_BLK_COMMIT_P
-       add             %o0, 0x40, %o0
-       ba,pt           %xcc, copy_user_page_continue
-        stda           %f0, [%o0] ASI_BLK_COMMIT_P
-#else
-       membar          #Sync
-       stda            %f0, [%o0] ASI_BLK_COMMIT_P
-       add             %o0, 0x40, %o0
-       ba,pt           %xcc, copy_user_page_continue
-        stda           %f16, [%o0] ASI_BLK_COMMIT_P
-#endif
-
-       .align          32
-       .globl          _clear_page
-       .type           _clear_page,@function
-_clear_page:   /* %o0=dest */
-       VISEntryHalf
-       ba,pt           %xcc, clear_page_common
-        clr            %o4
-
-       .align          32
-       .globl          clear_user_page
-       .type           clear_user_page,@function
-clear_user_page:       /* %o0=dest, %o1=vaddr */
-       VISEntryHalf
-       sethi           %hi(PAGE_SIZE), %g3
-       sethi           %uhi(PAGE_OFFSET), %g2
-       sllx            %g2, 32, %g2
-       sub             %o0, %g2, %g1
-       and             %o1, %g3, %o0
-       mov             TLB_TAG_ACCESS, %o2
-       sethi           %uhi(_PAGE_VALID | _PAGE_SZBITS), %g3
-       sethi           %hi(TLBTEMP_BASE), %o3
-       sllx            %g3, 32, %g3
-       or              %g3, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W), %g3
-       or              %g1, %g3, %g1
-       add             %o0, %o3, %o0
-#define FIX_INSN_2     0x96102068 /* mov (13 << 3), %o3 */
-cheetah_patch_2:
-       mov             TLBTEMP_ENT2, %o3
-       rdpr            %pstate, %g3
-       wrpr            %g3, PSTATE_IE, %pstate
-
-       /* Spitfire Errata #32 workaround */
-       mov             PRIMARY_CONTEXT, %g5
-       stxa            %g0, [%g5] ASI_DMMU
-       membar          #Sync
-
-       ldxa            [%o3] ASI_DTLB_TAG_READ, %g5
-
-       /* Spitfire Errata #32 workaround */
-       mov             PRIMARY_CONTEXT, %g7
-       stxa            %g0, [%g7] ASI_DMMU
-       membar          #Sync
-
-       ldxa            [%o3] ASI_DTLB_DATA_ACCESS, %g0
-       ldxa            [%o3] ASI_DTLB_DATA_ACCESS, %g7
-       stxa            %o0, [%o2] ASI_DMMU
-       stxa            %g1, [%o3] ASI_DTLB_DATA_ACCESS
-       membar          #Sync
-
-       mov             1, %o4
-
-clear_page_common:
-       membar          #StoreLoad | #StoreStore | #LoadStore   ! LSU   Group
-       fzero           %f0                             ! FPA   Group
-       sethi           %hi(PAGE_SIZE/256), %o1         ! IEU0
-       fzero           %f2                             ! FPA   Group
-       or              %o1, %lo(PAGE_SIZE/256), %o1    ! IEU0
-       faddd           %f0, %f2, %f4                   ! FPA   Group
-       fmuld           %f0, %f2, %f6                   ! FPM
-       faddd           %f0, %f2, %f8                   ! FPA   Group
-       fmuld           %f0, %f2, %f10                  ! FPM
-
-       faddd           %f0, %f2, %f12                  ! FPA   Group
-       fmuld           %f0, %f2, %f14                  ! FPM
-1:     stda            %f0, [%o0 + %g0] ASI_BLK_P      ! Store Group
-       add             %o0, 0x40, %o0                  ! IEU0
-       stda            %f0, [%o0 + %g0] ASI_BLK_P      ! Store Group
-       add             %o0, 0x40, %o0                  ! IEU0
-       stda            %f0, [%o0 + %g0] ASI_BLK_P      ! Store Group
-
-       add             %o0, 0x40, %o0                  ! IEU0  Group
-       stda            %f0, [%o0 + %g0] ASI_BLK_P      ! Store Group
-       subcc           %o1, 1, %o1                     ! IEU1
-       bne,pt          %icc, 1b                        ! CTI
-        add            %o0, 0x40, %o0                  ! IEU0  Group
-       membar          #Sync                           ! LSU   Group
-       VISExitHalf
-
-       brnz,pt         %o4, 1f
-        nop
-
-       retl
-        nop
-
-1:
-       stxa            %g5, [%o2] ASI_DMMU
-       stxa            %g7, [%o3] ASI_DTLB_DATA_ACCESS
-       membar          #Sync
-       jmpl            %o7 + 0x8, %g0
-        wrpr           %g3, 0x0, %pstate
-
-       .globl          cheetah_patch_pgcopyops
-cheetah_patch_pgcopyops:
-       sethi           %hi(FIX_INSN_1), %g1
-       or              %g1, %lo(FIX_INSN_1), %g1
-       sethi           %hi(cheetah_patch_1), %g2
-       or              %g2, %lo(cheetah_patch_1), %g2
-       stw             %g1, [%g2]
-       flush           %g2
-       sethi           %hi(FIX_INSN_2), %g1
-       or              %g1, %lo(FIX_INSN_2), %g1
-       sethi           %hi(cheetah_patch_2), %g2
-       or              %g2, %lo(cheetah_patch_2), %g2
-       stw             %g1, [%g2]
-       flush           %g2
-       retl
-        nop
-
-#undef FIX_INSN1
-#undef FIX_INSN2
-#undef PAGE_SIZE_REM
diff --git a/arch/sparc64/lib/splock.S b/arch/sparc64/lib/splock.S
deleted file mode 100644 (file)
index e466ed2..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* splock.S: Spinlock primitives too large to inline.
- *
- * Copyright (C) 2004 David S. Miller (davem@redhat.com)
- */
-
-       .text
-       .align  64
-
-       .globl          _raw_spin_lock
-_raw_spin_lock:                /* %o0 = lock_ptr */
-1:     ldstub          [%o0], %g7
-       brnz,pn         %g7, 2f
-        membar         #StoreLoad | #StoreStore
-       retl
-        nop
-2:     ldub            [%o0], %g7
-       brnz,pt         %g7, 2b
-        membar         #LoadLoad
-       ba,a,pt         %xcc, 1b
-
-       .globl  _raw_spin_lock_flags
-_raw_spin_lock_flags:  /* %o0 = lock_ptr, %o1 = irq_flags */
-1:     ldstub          [%o0], %g7
-       brnz,pn         %g7, 2f
-        membar         #StoreLoad | #StoreStore
-       retl
-        nop
-
-2:     rdpr            %pil, %g2               ! Save PIL
-       wrpr            %o1, %pil               ! Set previous PIL
-3:     ldub            [%o0], %g7              ! Spin on lock set
-       brnz,pt         %g7, 3b
-        membar         #LoadLoad
-       ba,pt           %xcc, 1b                ! Retry lock acquire
-        wrpr           %g2, %pil               ! Restore PIL
index 6da2759..c9954c2 100644 (file)
@@ -59,7 +59,8 @@ static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma,
        unsigned long i;
        pte_t entry;
 
-       mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
+       vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
 
        if (write_access)
                entry = pte_mkwrite(pte_mkdirty(mk_pte(page,
@@ -112,7 +113,8 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                        pte_val(entry) += PAGE_SIZE;
                        dst_pte++;
                }
-               dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
+               vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
                addr += HPAGE_SIZE;
        }
        return 0;
@@ -203,7 +205,8 @@ void unmap_hugepage_range(struct vm_area_struct *vma,
                        pte++;
                }
        }
-       mm->rss -= (end - start) >> PAGE_SHIFT;
+       // mm->rss -= (end - start) >> PAGE_SHIFT;
+       vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
        flush_tlb_range(vma, start, end);
 }
 
index a237c68..6fe66f8 100644 (file)
@@ -362,7 +362,7 @@ static int report_statvfs(struct vfsmount *mnt, struct inode *inode, u32 buf)
                int j = strlen (p);
                
                if (j > 15) j = 15;
-               if (IS_RDONLY(inode)) i = 1;
+               if (IS_RDONLY(inode) || (mnt && MNT_IS_RDONLY(mnt))) i = 1;
                if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
                if (!sysv_valid_dev(inode->i_sb->s_dev))
                        return -EOVERFLOW;
@@ -398,7 +398,7 @@ static int report_statvfs64(struct vfsmount *mnt, struct inode *inode, u32 buf)
                int j = strlen (p);
                
                if (j > 15) j = 15;
-               if (IS_RDONLY(inode)) i = 1;
+               if (IS_RDONLY(inode) || (mnt && MNT_IS_RDONLY(mnt))) i = 1;
                if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
                if (!sysv_valid_dev(inode->i_sb->s_dev))
                        return -EOVERFLOW;
index 47fbaf3..e472073 100644 (file)
@@ -61,9 +61,26 @@ config MODE_SKAS
 
 config NET
        bool "Networking support"
+       help
+       Unless you really know what you are doing, you should say Y here.
+       The reason is that some programs need kernel networking support even
+       when running on a stand-alone machine that isn't connected to any
+       other computer. If you are upgrading from an older kernel, you
+       should consider updating your networking tools too because changes
+       in the kernel and the tools often go hand in hand. The tools are
+       contained in the package net-tools, the location and version number
+       of which are given in Documentation/Changes.
+
+       For a general introduction to Linux networking, it is highly
+       recommended to read the NET-HOWTO, available from
+       <http://www.tldp.org/docs.html#howto>.
+
 
 source "fs/Kconfig.binfmt"
 
+config EXTERNFS
+       tristate "Support for host-based filesystems"
+
 config HOSTFS
        tristate "Host filesystem"
        help
@@ -85,6 +102,23 @@ config HOSTFS
         If you'd like to be able to work with files stored on the host, 
         say Y or M here; otherwise say N.
 
+config HUMFS
+       tristate 'Usable host filesystem'
+       depends on EXTERNFS
+
+config HPPFS
+       tristate "HoneyPot ProcFS"
+       help
+       hppfs (HoneyPot ProcFS) is a filesystem which allows UML /proc 
+       entries to be overridden, removed, or fabricated from the host.
+       Its purpose is to allow a UML to appear to be a physical machine
+       by removing or changing anything in /proc which gives away the
+       identity of a UML.
+
+       See http://user-mode-linux.sf.net/hppfs.html for more information.
+
+       You only need this if you are setting up a UML honeypot.  Otherwise,
+       it is safe to say 'N' here.
 
 config MCONSOLE
        bool "Management console"
@@ -105,6 +139,16 @@ config MCONSOLE
 config MAGIC_SYSRQ
        bool "Magic SysRq key"
        depends on MCONSOLE
+       help
+       If you say Y here, you will have some control over the system even
+       if the system crashes for example during kernel debugging (e.g., you
+       will be able to flush the buffer cache to disk, reboot the system
+       immediately or dump some status information). This is accomplished
+       by pressing various keys while holding SysRq (Alt+PrintScreen). It
+       also works on a serial console (on PC hardware at least), if you
+       send a BREAK and then within 5 seconds a command keypress. The
+       keys are documented in Documentation/sysrq.txt. Don't say Y
+       unless you really know what this hack does.
 
 config HOST_2G_2G
        bool "2G/2G host address space split"
@@ -160,6 +204,9 @@ config KERNEL_HALF_GIGS
 config HIGHMEM
        bool "Highmem support"
 
+config PROC_MM
+       bool "/proc/mm support"
+
 config KERNEL_STACK_ORDER
        int "Kernel stack size order"
        default 2
@@ -168,6 +215,17 @@ config KERNEL_STACK_ORDER
        be 1 << order pages.  The default is OK unless you're running Valgrind
        on UML, in which case, set this to 3.
 
+config UML_REAL_TIME_CLOCK
+       bool "Real-time Clock"
+       default y
+       help
+       This option makes UML time deltas match wall clock deltas.  This should
+       normally be enabled.  The exception would be if you are debugging with
+       UML and spend long times with UML stopped at a breakpoint.  In this
+       case, when UML is restarted, it will call the timer enough times to make
+       up for the time spent at the breakpoint.  This could result in a 
+       noticable lag.  If this is a problem, then disable this option.
+
 endmenu
 
 source "init/Kconfig"
@@ -188,6 +246,8 @@ source "net/Kconfig"
 
 source "fs/Kconfig"
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
@@ -240,6 +300,10 @@ config FRAME_POINTER
 config PT_PROXY
        bool "Enable ptrace proxy"
        depends on XTERM_CHAN && DEBUG_INFO
+       help
+       This option enables a debugging interface which allows gdb to debug
+       the kernel without needing to actually attach to kernel threads.
+       If you want to do kernel debugging, say Y here; otherwise say N.
 
 config GPROF
        bool "Enable gprof support"
index fba53d9..46e97fc 100644 (file)
@@ -29,6 +29,20 @@ config BLK_DEV_UBD_SYNC
         wise choice too.  In all other cases (for example, if you're just
         playing around with User-Mode Linux) you can choose N.
 
+# Turn this back on when the driver actually works
+#
+#config BLK_DEV_COW
+#      tristate "COW block device"
+#      help
+#      This is a layered driver which sits above two other block devices.
+#      One is read-only, and the other is a read-write layer which stores
+#      all changes.  This provides the illusion that the read-only layer
+#      can be mounted read-write and changed.
+
+config BLK_DEV_COW_COMMON
+       bool
+       default BLK_DEV_COW || BLK_DEV_UBD
+
 config BLK_DEV_LOOP
        tristate "Loopback device support"
 
index a21cbbc..8a6afe6 100644 (file)
@@ -108,11 +108,55 @@ config SSL_CHAN
 
 config UNIX98_PTYS
        bool "Unix98 PTY support"
-
-config UNIX98_PTY_COUNT
-       int "Maximum number of Unix98 PTYs in use (0-2048)"
-       depends on UNIX98_PTYS
+       ---help---
+         A pseudo terminal (PTY) is a software device consisting of two
+         halves: a master and a slave. The slave device behaves identical to
+         a physical terminal; the master device is used by a process to
+         read data from and write data to the slave, thereby emulating a
+         terminal. Typical programs for the master side are telnet servers
+         and xterms.
+
+         Linux has traditionally used the BSD-like names /dev/ptyxx for
+         masters and /dev/ttyxx for slaves of pseudo terminals. This scheme
+         has a number of problems. The GNU C library glibc 2.1 and later,
+         however, supports the Unix98 naming standard: in order to acquire a
+         pseudo terminal, a process opens /dev/ptmx; the number of the pseudo
+         terminal is then made available to the process and the pseudo
+         terminal slave can be accessed as /dev/pts/<number>. What was
+         traditionally /dev/ttyp2 will then be /dev/pts/2, for example.
+
+         All modern Linux systems use the Unix98 ptys.  Say Y unless
+         you're on an embedded system and want to conserve memory.
+
+config LEGACY_PTYS
+       bool "Legacy (BSD) PTY support"
+       default y
+       ---help---
+         A pseudo terminal (PTY) is a software device consisting of two
+         halves: a master and a slave. The slave device behaves identical to
+         a physical terminal; the master device is used by a process to
+         read data from and write data to the slave, thereby emulating a
+         terminal. Typical programs for the master side are telnet servers
+         and xterms.
+
+         Linux has traditionally used the BSD-like names /dev/ptyxx
+         for masters and /dev/ttyxx for slaves of pseudo
+         terminals. This scheme has a number of problems, including
+         security.  This option enables these legacy devices; on most
+         systems, it is safe to say N.
+
+
+config LEGACY_PTY_COUNT
+       int "Maximum number of legacy PTY in use"
+       depends on LEGACY_PTYS
        default "256"
+       ---help---
+         The maximum number of legacy PTYs that can be used at any one time.
+         The default is 256, and should be more than enough.  Embedded
+         systems may want to reduce this to save memory.
+
+         When not in use, each legacy PTY occupies 12 bytes on 32-bit
+         architectures and 24 bytes on 64-bit architectures.
 
 config WATCHDOG
        bool "Watchdog Timer Support"
index 443a74b..94c6bf0 100644 (file)
@@ -1,5 +1,5 @@
 
-menu "Network Devices"
+menu "UML Network Devices"
        depends on NET
 
 # UML virtual driver
@@ -176,73 +176,5 @@ config UML_NET_SLIRP
        
         Startup example: "eth0=slirp,FE:FD:01:02:03:04,/usr/local/bin/slirp"
 
-
-# Below are hardware-independent drivers mirrored from
-# drivers/net/Config.in. It would be nice if Linux
-# had HW independent drivers separated from the other
-# but it does not. Until then each non-ISA/PCI arch
-# needs to provide it's own menu of network drivers
-config DUMMY
-       tristate "Dummy net driver support"
-
-config BONDING
-       tristate "Bonding driver support"
-
-config EQUALIZER
-       tristate "EQL (serial line load balancing) support"
-
-config TUN
-       tristate "Universal TUN/TAP device driver support"
-
-config ETHERTAP
-       tristate "Ethertap network tap (OBSOLETE)"
-       depends on EXPERIMENTAL && NETLINK
-
-config PPP
-       tristate "PPP (point-to-point protocol) support"
-
-config PPP_MULTILINK
-       bool "PPP multilink support (EXPERIMENTAL)"
-       depends on PPP && EXPERIMENTAL
-
-config PPP_FILTER
-       bool "PPP filtering"
-       depends on PPP && FILTER
-
-config PPP_ASYNC
-       tristate "PPP support for async serial ports"
-       depends on PPP
-
-config PPP_SYNC_TTY
-       tristate "PPP support for sync tty ports"
-       depends on PPP
-
-config PPP_DEFLATE
-       tristate "PPP Deflate compression"
-       depends on PPP
-
-config PPP_BSDCOMP
-       tristate "PPP BSD-Compress compression"
-       depends on PPP
-
-config PPPOE
-       tristate "PPP over Ethernet (EXPERIMENTAL)"
-       depends on PPP && EXPERIMENTAL
-
-config SLIP
-       tristate "SLIP (serial line) support"
-
-config SLIP_COMPRESSED
-       bool "CSLIP compressed headers"
-       depends on SLIP=y
-
-config SLIP_SMART
-       bool "Keepalive and linefill"
-       depends on SLIP=y
-
-config SLIP_MODE_SLIP6
-       bool "Six bit SLIP encapsulation"
-       depends on SLIP=y
-
 endmenu
 
index bb7d3f6..803d12e 100644 (file)
@@ -22,17 +22,21 @@ core-y                      += $(ARCH_DIR)/kernel/           \
                           $(ARCH_DIR)/sys-$(SUBARCH)/
 
 # Have to precede the include because the included Makefiles reference them.
-SYMLINK_HEADERS = include/asm-um/archparam.h include/asm-um/system.h \
-       include/asm-um/sigcontext.h include/asm-um/processor.h \
-       include/asm-um/ptrace.h include/asm-um/arch-signal.h
+SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \
+       arch-signal.h module.h
+SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
 
 ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
        $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
 
 GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
 
-include $(ARCH_DIR)/Makefile-$(SUBARCH)
-include $(ARCH_DIR)/Makefile-os-$(OS)
+# This target adds dependencies to "prepare". They are defined in the included
+# Makefiles (see Makefile-i386).
+
+.PHONY: sys_prepare
+sys_prepare:
+       @:
 
 MAKEFILE-$(CONFIG_MODE_TT) += Makefile-tt
 MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
@@ -41,6 +45,9 @@ ifneq ($(MAKEFILE-y),)
   include $(addprefix $(ARCH_DIR)/,$(MAKEFILE-y))
 endif
 
+include $(ARCH_DIR)/Makefile-$(SUBARCH)
+include $(ARCH_DIR)/Makefile-os-$(OS)
+
 EXTRAVERSION := $(EXTRAVERSION)-1um
 
 ARCH_INCLUDE = -I$(ARCH_DIR)/include
@@ -52,14 +59,24 @@ ARCH_INCLUDE = -I$(ARCH_DIR)/include
 
 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
        -D_LARGEFILE64_SOURCE $(ARCH_INCLUDE) -Derrno=kernel_errno \
-       $(MODE_INCLUDE)
+       -Dsigprocmask=kernel_sigprocmask $(MODE_INCLUDE)
+
+check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
+
+CFLAGS += $(call check_gcc,-fno-unit-at-a-time,)
 
 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
 
+# These are needed for clean and mrproper, since in that case .config is not
+# included; the values here are meaningless
+
+CONFIG_NEST_LEVEL ?= 0
+CONFIG_KERNEL_HALF_GIGS ?= 0
+
 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
 
 ifeq ($(CONFIG_MODE_SKAS), y)
-$(SYS_HEADERS) : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
+$(SYS_HEADERS) : $(TOPDIR)/$(ARCH_DIR)/include/skas_ptregs.h
 endif
 
 include/linux/version.h: arch/$(ARCH)/Makefile
@@ -98,17 +115,21 @@ CPP_MODE_TT := $(shell [ "$(CONFIG_MODE_TT)" = "y" ] && echo -DMODE_TT)
 CONFIG_KERNEL_STACK_ORDER ?= 2
 STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
 
-AFLAGS_vmlinux.lds.o = -U$(SUBARCH) \
-       -DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \
+ifndef START
+  START = $$(($(TOP_ADDR) - $(SIZE)))
+endif
+
+AFLAGS_vmlinux.lds.o = $(shell echo -U$(SUBARCH) \
+       -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
        -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \
-       -DKERNEL_STACK_SIZE=$(STACK_SIZE)
+       -DKERNEL_STACK_SIZE=$(STACK_SIZE))
 
-AFLAGS_$(LD_SCRIPT-y:.s=).o = $(AFLAGS_vmlinux.lds.o) -P -C -Uum
+export AFLAGS_$(LD_SCRIPT-y:.s=).o = $(AFLAGS_vmlinux.lds.o) -P -C -Uum
 
 LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y)
 
-$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
-       $(call if_changed_dep,as_s_S)
+#$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
+#      $(call if_changed_dep,as_s_S)
 
 linux: vmlinux $(LD_SCRIPT-y)
        $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
@@ -116,37 +137,47 @@ linux: vmlinux $(LD_SCRIPT-y)
 
 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
 USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
+USER_CFLAGS := $(patsubst -Dsigprocmask=kernel_sigprocmask,,$(USER_CFLAGS))
 USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
        $(MODE_INCLUDE)
 
 # To get a definition of F_SETSIG
 USER_CFLAGS += -D_GNU_SOURCE
 
+# From main Makefile, these options are set after including the ARCH makefile.
+# So copy them here.
+
+ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+USER_CFLAGS            += -Os
+else
+USER_CFLAGS            += -O2
+endif
+
+ifndef CONFIG_FRAME_POINTER
+USER_CFLAGS            += -fomit-frame-pointer
+endif
+
+ifdef CONFIG_DEBUG_INFO
+USER_CFLAGS            += -g
+endif
+
 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/uml.lds.s \
-       $(ARCH_DIR)/dyn_link.ld.s $(GEN_HEADERS)
+       $(ARCH_DIR)/dyn_link.ld.s $(ARCH_DIR)/include/uml-config.h \
+       $(GEN_HEADERS)
 
-$(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c
-       $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
+MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
+       $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS))
+
+$(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c sys_prepare
+       @ echo '  MAIN    $@'
+       @ $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
 
 archmrproper:
-       for d in $(ARCH_SUBDIRS) $(ARCH_DIR)/util; \
-       do \
-               $(MAKE) -C $$d archmrproper; \
-       done
-       rm -f $(CLEAN_FILES) $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) include/asm \
-               $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS))
-
-archclean: sysclean
-       for d in $(ARCH_SUBDIRS) $(ARCH_DIR)/util; \
-       do \
-               $(MAKE) -C $$d clean; \
-       done
-       find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
-               -o -name '*.gcov' \) -type f -print | xargs rm -f
-       rm -f linux x.i gmon.out $(ARCH_DIR)/link.ld $(GEN_HEADERS)
+       @:
 
-archdep: 
-       for d in $(ARCH_SUBDIRS); do $(MAKE) -C $$d fastdep; done
+archclean:
+       @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
+               -o -name '*.gcov' \) -type f -print | xargs rm -f
 
 $(SYMLINK_HEADERS):
        cd $(TOPDIR)/$(dir $@) ; \
@@ -161,19 +192,32 @@ $(ARCH_DIR)/include/sysdep:
 $(ARCH_DIR)/os:
        cd $(ARCH_DIR) && ln -sf os-$(OS) os
 
-$(ARCH_DIR)/include/uml-config.h :
-       sed 's/ CONFIG/ UML_CONFIG/' $(TOPDIR)/include/linux/autoconf.h > $@
+# Generated files
+define filechk_umlconfig
+       sed 's/ CONFIG/ UML_CONFIG/'
+endef
+
+$(ARCH_DIR)/include/uml-config.h : $(TOPDIR)/include/linux/autoconf.h
+       $(call filechk,umlconfig)
+
+filechk_gen_header = $<
 
 $(ARCH_DIR)/include/task.h : $(ARCH_DIR)/util/mk_task
-       $< > $@
+       $(call filechk,gen_header)
 
 $(ARCH_DIR)/include/kern_constants.h : $(ARCH_DIR)/util/mk_constants
-       $< > $@
+       $(call filechk,gen_header)
 
-$(ARCH_DIR)/util/mk_task : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h \
-       $(ARCH_DIR)/util FORCE ;
+$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants : $(ARCH_DIR)/util \
+       sys_prepare FORCE ;
 
 $(ARCH_DIR)/util: FORCE
-       @$(call descend,$@,)
+       $(Q)$(MAKE) $(build)=$@
+
+export SUBARCH USER_CFLAGS OS 
+
+all: linux
 
-export SUBARCH USER_CFLAGS OS
+define archhelp
+    echo  '* linux     - Binary kernel image (./linux)'
+endef
index 3bd90fb..1b7e163 100644 (file)
@@ -4,7 +4,18 @@ else
 TOP_ADDR = 0xc0000000
 endif
 
+ifeq ($(CONFIG_MODE_SKAS),y)
+  ifneq ($(CONFIG_MODE_TT),y)
+     START = 0x8048000
+  endif
+endif
+
 CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH)
+
+ifneq ($(CONFIG_GPROF),y)
+ARCH_CFLAGS += -DUM_FASTCALL
+endif
+
 ELF_ARCH = $(SUBARCH)
 ELF_FORMAT = elf32-$(SUBARCH)
 
@@ -16,22 +27,27 @@ SYS_UTIL_DIR        := $(ARCH_DIR)/sys-i386/util
 
 SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
 
+sys_prepare: $(SYS_DIR)/sc.h
+
 prepare: $(SYS_HEADERS)
 
+filechk_$(SYS_DIR)/sc.h := $(SYS_UTIL_DIR)/mk_sc
+
 $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
-       $< > $@
+       $(call filechk,$@)
+
+filechk_$(SYS_DIR)/thread.h := $(SYS_UTIL_DIR)/mk_thread 
 
 $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread 
-       $< > $@
+       $(call filechk,$@)
 
-$(SYS_UTIL_DIR)/mk_sc: FORCE ; 
-       @$(call descend,$(SYS_UTIL_DIR),$@)
+$(SYS_UTIL_DIR)/mk_sc: scripts/basic/fixdep include/config/MARKER FORCE ; 
+       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
 
-$(SYS_UTIL_DIR)/mk_thread: $(ARCH_SYMLINKS) $(GEN_HEADERS) FORCE ; 
-       @$(call descend,$(SYS_UTIL_DIR),$@)
+$(SYS_UTIL_DIR)/mk_thread: $(ARCH_SYMLINKS) $(GEN_HEADERS) sys_prepare FORCE ; 
+       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
 
 $(SYS_UTIL_DIR): include/asm FORCE
-       @$(call descend,$@,)
+       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR)
 
-sysclean :
-       rm -f $(SYS_HEADERS)
+CLEAN_FILES += $(SYS_HEADERS)
index b9dfec5..d114908 100644 (file)
@@ -14,7 +14,7 @@ MODE_INCLUDE += -I$(TOPDIR)/$(ARCH_DIR)/kernel/skas/include
 LINK_SKAS = -Wl,-rpath,/lib 
 LD_SCRIPT_SKAS = dyn.lds.s
 
-GEN_HEADERS += $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
+GEN_HEADERS += $(TOPDIR)/$(ARCH_DIR)/include/skas_ptregs.h
 
-$(ARCH_DIR)/kernel/skas/include/skas_ptregs.h :
-       $(MAKE) -C $(ARCH_DIR)/kernel/skas include/skas_ptregs.h
+$(TOPDIR)/$(ARCH_DIR)/include/skas_ptregs.h :
+       $(Q)$(MAKE) $(build)=$(ARCH_DIR)/kernel/skas $@
index 6d32bc2..fc68bcb 100644 (file)
@@ -227,7 +227,6 @@ CONFIG_ROMFS_FS=m
 CONFIG_EXT2_FS=y
 CONFIG_SYSV_FS=m
 CONFIG_UDF_FS=m
-# CONFIG_UDF_RW is not set
 CONFIG_UFS_FS=m
 # CONFIG_UFS_FS_WRITE is not set
 
index 412d006..544f3b0 100644 (file)
@@ -3,29 +3,21 @@
 #
 CONFIG_USERMODE=y
 CONFIG_MMU=y
-CONFIG_SWAP=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_CONFIG_LOG_BUF_SHIFT=14
 
 #
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General Setup
+# UML-specific options
 #
 CONFIG_MODE_TT=y
 CONFIG_MODE_SKAS=y
 CONFIG_NET=y
-CONFIG_SYSVIPC=y
-CONFIG_BSD_PROCESS_ACCT=y
-CONFIG_SYSCTL=y
-CONFIG_BINFMT_AOUT=y
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=y
+CONFIG_EXTERNFS=y
 CONFIG_HOSTFS=y
+CONFIG_HUMFS=y
+CONFIG_HPPFS=y
 CONFIG_MCONSOLE=y
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_HOST_2G_2G is not set
@@ -36,12 +28,55 @@ CONFIG_KERNEL_HALF_GIGS=1
 # CONFIG_HIGHMEM is not set
 CONFIG_PROC_MM=y
 CONFIG_KERNEL_STACK_ORDER=2
+CONFIG_UML_REAL_TIME_CLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_STANDALONE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+CONFIG_BSD_PROCESS_ACCT=y
+
+#
+# Class Based Kernel Resource Management
+#
+# CONFIG_CKRM is not set
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+# CONFIG_DELAY_ACCT is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 
 #
 # Loadable module support
 #
-CONFIG_MODULES=y
-# CONFIG_KMOD is not set
+# CONFIG_MODULES is not set
+
+#
+# Generic Driver Options
+#
+CONFIG_PREVENT_FIRMWARE_BUILD=y
 
 #
 # Character Devices
@@ -58,7 +93,8 @@ CONFIG_CON_ZERO_CHAN="fd:0,fd:1"
 CONFIG_CON_CHAN="xterm"
 CONFIG_SSL_CHAN="pty"
 CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
 # CONFIG_WATCHDOG is not set
 CONFIG_UML_SOUND=y
 CONFIG_SOUND=y
@@ -69,6 +105,7 @@ CONFIG_HOSTAUDIO=y
 #
 CONFIG_BLK_DEV_UBD=y
 # CONFIG_BLK_DEV_UBD_SYNC is not set
+CONFIG_BLK_DEV_COW_COMMON=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_NBD=y
 CONFIG_BLK_DEV_RAM=y
@@ -78,7 +115,7 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_NETDEVICES=y
 
 #
-# Network Devices
+# UML Network Devices
 #
 CONFIG_UML_NET=y
 CONFIG_UML_NET_ETHERTAP=y
@@ -88,22 +125,6 @@ CONFIG_UML_NET_DAEMON=y
 CONFIG_UML_NET_MCAST=y
 # CONFIG_UML_NET_PCAP is not set
 CONFIG_UML_NET_SLIRP=y
-CONFIG_DUMMY=y
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-CONFIG_TUN=y
-# CONFIG_ETHERTAP is not set
-CONFIG_PPP=y
-# CONFIG_PPP_MULTILINK is not set
-# CONFIG_PPP_ASYNC is not set
-# CONFIG_PPP_SYNC_TTY is not set
-# CONFIG_PPP_DEFLATE is not set
-# CONFIG_PPP_BSDCOMP is not set
-# CONFIG_PPPOE is not set
-CONFIG_SLIP=y
-# CONFIG_SLIP_COMPRESSED is not set
-# CONFIG_SLIP_SMART is not set
-# CONFIG_SLIP_MODE_SLIP6 is not set
 
 #
 # Networking support
@@ -115,8 +136,6 @@ CONFIG_SLIP=y
 CONFIG_PACKET=y
 CONFIG_PACKET_MMAP=y
 # CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
 CONFIG_UNIX=y
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
@@ -126,23 +145,24 @@ CONFIG_INET=y
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
 # CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
 # CONFIG_SYN_COOKIES is not set
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
-# CONFIG_XFRM_USER is not set
+# CONFIG_INET_IPCOMP is not set
 # CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
 
 #
 # SCTP Configuration (EXPERIMENTAL)
 #
-CONFIG_IPV6_SCTP__=y
 # CONFIG_IP_SCTP is not set
 # CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
 # CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
 # CONFIG_NET_DIVERT is not set
@@ -154,99 +174,151 @@ CONFIG_IPV6_SCTP__=y
 # QoS and/or fair queueing
 #
 # CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_DUMMY=y
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=y
 
 #
 # Ethernet (10 or 100Mbit)
 #
 # CONFIG_NET_ETHERNET is not set
+# CONFIG_NE2000 is not set
 
 #
 # Ethernet (1000 Mbit)
 #
 
 #
-# Wireless LAN (non-hamradio)
+# Ethernet (10000 Mbit)
 #
-# CONFIG_NET_RADIO is not set
 
 #
-# Token Ring devices (depends on LLC=y)
+# Token Ring devices
 #
-# CONFIG_SHAPER is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
 
 #
 # Wan interfaces
 #
 # CONFIG_WAN is not set
+CONFIG_PPP=y
+# CONFIG_PPP_MULTILINK is not set
+# CONFIG_PPP_FILTER is not set
+# CONFIG_PPP_ASYNC is not set
+# CONFIG_PPP_SYNC_TTY is not set
+# CONFIG_PPP_DEFLATE is not set
+# CONFIG_PPP_BSDCOMP is not set
+# CONFIG_PPPOE is not set
+CONFIG_SLIP=y
+# CONFIG_SLIP_COMPRESSED is not set
+# CONFIG_SLIP_SMART is not set
+# CONFIG_SLIP_MODE_SLIP6 is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
 
 #
 # File systems
 #
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+CONFIG_REISERFS_FS=y
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+CONFIG_MINIX_FS=y
+# CONFIG_ROMFS_FS is not set
 CONFIG_QUOTA=y
 # CONFIG_QFMT_V1 is not set
 # CONFIG_QFMT_V2 is not set
 CONFIG_QUOTACTL=y
-CONFIG_AUTOFS_FS=m
-CONFIG_AUTOFS4_FS=m
-CONFIG_REISERFS_FS=m
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_AUTOFS_FS=y
+CONFIG_AUTOFS4_FS=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+# CONFIG_JOLIET is not set
+# CONFIG_ZISOFS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_RELAYFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-CONFIG_FAT_FS=m
-CONFIG_MSDOS_FS=m
-CONFIG_VFAT_FS=m
 # CONFIG_EFS_FS is not set
 CONFIG_JFFS_FS=y
 CONFIG_JFFS_FS_VERBOSE=0
-CONFIG_JFFS_PROC_FS=y
+# CONFIG_JFFS_PROC_FS is not set
 # CONFIG_JFFS2_FS is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
 # CONFIG_CRAMFS is not set
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-CONFIG_ISO9660_FS=m
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_JFS_FS is not set
-CONFIG_MINIX_FS=m
 # CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
 # CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_SYSV_FS is not set
-# CONFIG_UDF_FS is not set
 # CONFIG_UFS_FS is not set
-# CONFIG_XFS_FS is not set
 
 #
 # Network File Systems
 #
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
 # CONFIG_NFS_FS is not set
 # CONFIG_NFSD is not set
 # CONFIG_EXPORTFS is not set
-# CONFIG_CIFS is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
 
 #
@@ -254,11 +326,11 @@ CONFIG_EXT2_FS=y
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-CONFIG_NLS=y
 
 #
 # Native Language Support
 #
+CONFIG_NLS=y
 CONFIG_NLS_DEFAULT="iso8859-1"
 # CONFIG_NLS_CODEPAGE_437 is not set
 # CONFIG_NLS_CODEPAGE_737 is not set
@@ -283,6 +355,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # CONFIG_NLS_ISO8859_8 is not set
 # CONFIG_NLS_CODEPAGE_1250 is not set
 # CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
 # CONFIG_NLS_ISO8859_1 is not set
 # CONFIG_NLS_ISO8859_2 is not set
 # CONFIG_NLS_ISO8859_3 is not set
@@ -298,6 +371,18 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # CONFIG_NLS_KOI8_U is not set
 # CONFIG_NLS_UTF8 is not set
 
+#
+# Linux VServer
+#
+CONFIG_VSERVER_LEGACY=y
+CONFIG_PROC_SECURE=y
+# CONFIG_VSERVER_HARDCPU is not set
+# CONFIG_INOXID_NONE is not set
+# CONFIG_INOXID_GID16 is not set
+CONFIG_INOXID_GID24=y
+# CONFIG_INOXID_GID32 is not set
+# CONFIG_INOXID_MAGIC is not set
+
 #
 # Security options
 #
@@ -311,33 +396,14 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 #
 # Library routines
 #
+# CONFIG_CRC_CCITT is not set
 # CONFIG_CRC32 is not set
+# CONFIG_LIBCRC32C is not set
 
 #
 # SCSI support
 #
-CONFIG_SCSI=y
-CONFIG_GENERIC_ISA_DMA=y
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-CONFIG_SD_EXTRA_DEVS=40
-CONFIG_CHR_DEV_ST=y
-CONFIG_BLK_DEV_SR=y
-CONFIG_BLK_DEV_SR_VENDOR=y
-CONFIG_SR_EXTRA_DEVS=2
-CONFIG_CHR_DEV_SG=y
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-CONFIG_SCSI_DEBUG_QUEUES=y
-CONFIG_SCSI_MULTI_LUN=y
-CONFIG_SCSI_CONSTANTS=y
-CONFIG_SCSI_LOGGING=y
-CONFIG_SCSI_DEBUG=y
+# CONFIG_SCSI is not set
 
 #
 # Multi-device support (RAID and LVM)
@@ -359,12 +425,23 @@ CONFIG_MTD_CHAR=y
 CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
 
 #
 # RAM/ROM/Flash chip drivers
 #
 # CONFIG_MTD_CFI is not set
 # CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
@@ -373,20 +450,22 @@ CONFIG_MTD_BLOCK=y
 #
 # Mapping drivers for chip access
 #
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
 
 #
 # Self-contained MTD device drivers
 #
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
-CONFIG_MTD_BLKMTD=m
+CONFIG_MTD_BLKMTD=y
 
 #
 # Disk-On-Chip Device Drivers
 #
-# CONFIG_MTD_DOC1000 is not set
 # CONFIG_MTD_DOC2000 is not set
 # CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
 
 #
 # NAND Flash Device Drivers
index 8ea9ada..ba1aabb 100644 (file)
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2000, 2002, 2003 Jeff Dike (jdike@karaya.com)
 # Licensed under the GPL
 #
 
@@ -15,7 +15,7 @@ mcast-objs := mcast_kern.o mcast_user.o
 #pcap-objs := pcap_kern.o pcap_user.o $(PCAP)
 net-objs := net_kern.o net_user.o
 mconsole-objs := mconsole_kern.o mconsole_user.o
-hostaudio-objs := hostaudio_kern.o hostaudio_user.o
+hostaudio-objs := hostaudio_kern.o
 ubd-objs := ubd_kern.o ubd_user.o
 port-objs := port_kern.o port_user.o
 harddog-objs := harddog_kern.o harddog_user.o
@@ -39,6 +39,8 @@ obj-$(CONFIG_PTY_CHAN) += pty.o
 obj-$(CONFIG_TTY_CHAN) += tty.o 
 obj-$(CONFIG_XTERM_CHAN) += xterm.o xterm_kern.o
 obj-$(CONFIG_UML_WATCHDOG) += harddog.o
+obj-$(CONFIG_BLK_DEV_COW) += cow_kern.o
+obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o
 
 obj-y += stdio_console.o $(CHAN_OBJS)
 
@@ -46,18 +48,7 @@ USER_SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs))
 
 USER_OBJS := $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) fd.o \
        null.o pty.o tty.o xterm.o
-USER_OBJS := $(foreach file,$(USER_OBJS),arch/um/drivers/$(file))
+USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
 $(USER_OBJS) : %.o: %.c
        $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
-
-clean:
-
-modules:
-
-fastdep:
-
-dep:
-
-archmrproper: clean
-
index 9e45a08..9ffd300 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/tty.h>
+#include <linux/string.h>
 #include <linux/tty_flip.h>
 #include <asm/irq.h>
 #include "chan_kern.h"
@@ -16,6 +17,7 @@
 #include "irq_user.h"
 #include "sigio.h"
 #include "line.h"
+#include "os.h"
 
 static void *not_configged_init(char *str, int device, struct chan_opts *opts)
 {
@@ -86,6 +88,54 @@ static struct chan_ops not_configged_ops = {
        .winch          = 0,
 };
 
+void generic_close(int fd, void *unused)
+{
+       os_close_file(fd);
+}
+
+int generic_read(int fd, char *c_out, void *unused)
+{
+       int n;
+
+       n = os_read_file(fd, c_out, sizeof(*c_out));
+
+       if(n == -EAGAIN)
+               return(0);
+       else if(n == 0)
+               return(-EIO);
+       return(n);
+}
+
+/* XXX Trivial wrapper around os_write_file */
+
+int generic_write(int fd, const char *buf, int n, void *unused)
+{
+       return(os_write_file(fd, buf, n));
+}
+
+int generic_window_size(int fd, void *unused, unsigned short *rows_out,
+                       unsigned short *cols_out)
+{
+       int rows, cols;
+       int ret;
+
+       ret = os_window_size(fd, &rows, &cols);
+       if(ret < 0)
+               return(ret);
+
+       ret = ((*rows_out != rows) || (*cols_out != cols));
+
+       *rows_out = rows;
+       *cols_out = cols;
+
+       return(ret);
+}
+
+void generic_free(void *data)
+{
+       kfree(data);
+}
+
 static void tty_receive_char(struct tty_struct *tty, char ch)
 {
        if(tty == NULL) return;
@@ -265,6 +315,11 @@ static int one_chan_config_string(struct chan *chan, char *str, int size,
 {
        int n = 0;
 
+       if(chan == NULL){
+               CONFIG_CHUNK(str, size, n, "none", 1);
+               return(n);
+       }
+
        CONFIG_CHUNK(str, size, n, chan->ops->type, 0);
 
        if(chan->dev == NULL){
@@ -420,7 +475,8 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device,
                INIT_LIST_HEAD(chans);
        }
 
-       if((out = strchr(str, ',')) != NULL){
+       out = strchr(str, ',');
+       if(out != NULL){
                in = str;
                *out = '\0';
                out++;
@@ -475,12 +531,15 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task,
                                goto out;
                        }
                        err = chan->ops->read(chan->fd, &c, chan->data);
-                       if(err > 0) tty_receive_char(tty, c);
+                       if(err > 0) 
+                               tty_receive_char(tty, c);
                } while(err > 0);
+
                if(err == 0) reactivate_fd(chan->fd, irq);
                if(err == -EIO){
                        if(chan->primary){
-                               if(tty != NULL) tty_hangup(tty);
+                               if(tty != NULL) 
+                                       tty_hangup(tty);
                                line_disable(dev, irq);
                                close_chan(chans);
                                free_chan(chans);
index 714bace..bbc5b4c 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -7,7 +7,6 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <termios.h>
-#include <fcntl.h>
 #include <string.h>
 #include <signal.h>
 #include <sys/stat.h>
 #include "choose-mode.h"
 #include "mode.h"
 
-void generic_close(int fd, void *unused)
-{
-       close(fd);
-}
-
-int generic_read(int fd, char *c_out, void *unused)
+static void winch_handler(int sig)
 {
-       int n;
-
-       n = read(fd, c_out, sizeof(*c_out));
-       if(n < 0){
-               if(errno == EAGAIN) return(0);
-               return(-errno);
-       }
-       else if(n == 0) return(-EIO);
-       return(1);
 }
 
-int generic_write(int fd, const char *buf, int n, void *unused)
-{
-       int count;
-
-       count = write(fd, buf, n);
-       if(count < 0) return(-errno);
-       return(count);
-}
+struct winch_data {
+       int pty_fd;
+       int pipe_fd;
+       int close_me;
+};
 
+/* XXX This breaks horribly (by hanging UML) when moved to chan_kern.c - 
+ * needs investigation
+ */
 int generic_console_write(int fd, const char *buf, int n, void *unused)
 {
        struct termios save, new;
@@ -65,49 +50,21 @@ int generic_console_write(int fd, const char *buf, int n, void *unused)
        return(err);
 }
 
-int generic_window_size(int fd, void *unused, unsigned short *rows_out,
-                       unsigned short *cols_out)
-{
-       struct winsize size;
-       int ret = 0;
-
-       if(ioctl(fd, TIOCGWINSZ, &size) == 0){
-               ret = ((*rows_out != size.ws_row) || 
-                      (*cols_out != size.ws_col));
-               *rows_out = size.ws_row;
-               *cols_out = size.ws_col;
-       }
-       return(ret);
-}
-
-void generic_free(void *data)
-{
-       kfree(data);
-}
-
-static void winch_handler(int sig)
-{
-}
-
-struct winch_data {
-       int pty_fd;
-       int pipe_fd;
-       int close_me;
-};
-
 static int winch_thread(void *arg)
 {
        struct winch_data *data = arg;
        sigset_t sigs;
        int pty_fd, pipe_fd;
+       int count, err;
        char c = 1;
 
-       close(data->close_me);
+       os_close_file(data->close_me);
        pty_fd = data->pty_fd;
        pipe_fd = data->pipe_fd;
-       if(write(pipe_fd, &c, sizeof(c)) != sizeof(c))
+       count = os_write_file(pipe_fd, &c, sizeof(c));
+       if(count != sizeof(c))
                printk("winch_thread : failed to write synchronization "
-                      "byte, errno = %d\n", errno);
+                      "byte, err = %d\n", -count);
 
        signal(SIGWINCH, winch_handler);
        sigfillset(&sigs);
@@ -123,26 +80,24 @@ static int winch_thread(void *arg)
                exit(1);
        }
 
-       if(ioctl(pty_fd, TIOCSCTTY, 0) < 0){
-               printk("winch_thread : TIOCSCTTY failed, errno = %d\n", errno);
-               exit(1);
-       }
-       if(tcsetpgrp(pty_fd, os_getpid()) < 0){
-               printk("winch_thread : tcsetpgrp failed, errno = %d\n", errno);
+       err = os_new_tty_pgrp(pty_fd, os_getpid());
+       if(err < 0){
+               printk("winch_thread : new_tty_pgrp failed, err = %d\n", -err);
                exit(1);
        }
 
-       if(read(pipe_fd, &c, sizeof(c)) != sizeof(c))
+       count = os_read_file(pipe_fd, &c, sizeof(c));
+       if(count != sizeof(c))
                printk("winch_thread : failed to read synchronization byte, "
-                      "errno = %d\n", errno);
+                      "err = %d\n", -count);
 
        while(1){
                pause();
 
-               if(write(pipe_fd, &c, sizeof(c)) != sizeof(c)){
-                       printk("winch_thread : write failed, errno = %d\n",
-                              errno);
-               }
+               count = os_write_file(pipe_fd, &c, sizeof(c));
+               if(count != sizeof(c))
+                       printk("winch_thread : write failed, err = %d\n",
+                              -count);
        }
 }
 
@@ -154,8 +109,8 @@ static int winch_tramp(int fd, void *device_data, int *fd_out)
        char c;
 
        err = os_pipe(fds, 1, 1);
-       if(err){
-               printk("winch_tramp : os_pipe failed, errno = %d\n", -err);
+       if(err < 0){
+               printk("winch_tramp : os_pipe failed, err = %d\n", -err);
                return(err);
        }
 
@@ -168,12 +123,12 @@ static int winch_tramp(int fd, void *device_data, int *fd_out)
                return(pid);
        }
 
-       close(fds[1]);
+       os_close_file(fds[1]);
        *fd_out = fds[0];
-       n = read(fds[0], &c, sizeof(c));
+       n = os_read_file(fds[0], &c, sizeof(c));
        if(n != sizeof(c)){
                printk("winch_tramp : failed to read synchronization byte\n");
-               printk("read returned %d, errno = %d\n", n, errno);
+               printk("read failed, err = %d\n", -n);
                printk("fd %d will not support SIGWINCH\n", fd);
                *fd_out = -1;
        }
@@ -183,20 +138,24 @@ static int winch_tramp(int fd, void *device_data, int *fd_out)
 void register_winch(int fd, void *device_data)
 {
        int pid, thread, thread_fd;
+       int count;
        char c = 1;
 
-       if(!isatty(fd)) return;
+       if(!isatty(fd)) 
+               return;
 
        pid = tcgetpgrp(fd);
-       if(!CHOOSE_MODE(is_tracer_winch(pid, fd, device_data), 0) && 
-          (pid == -1)){
+       if(!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd, 
+                            device_data) && (pid == -1)){
                thread = winch_tramp(fd, device_data, &thread_fd);
                if(fd != -1){
                        register_winch_irq(thread_fd, fd, thread, device_data);
 
-                       if(write(thread_fd, &c, sizeof(c)) != sizeof(c))
+                       count = os_write_file(thread_fd, &c, sizeof(c));
+                       if(count != sizeof(c))
                                printk("register_winch : failed to write "
-                                      "synchronization byte\n");
+                                      "synchronization byte, err = %d\n",
+                                       -count);
                }
        }
 }
diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h
deleted file mode 100644 (file)
index d875d04..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef __COW_H__
-#define __COW_H__
-
-#include <asm/types.h>
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define ntohll(x) (x)
-# define htonll(x) (x)
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
-# define ntohll(x)  bswap_64(x)
-# define htonll(x)  bswap_64(x)
-#else
-#error "__BYTE_ORDER not defined"
-#endif
-
-extern int init_cow_file(int fd, char *cow_file, char *backing_file, 
-                        int sectorsize, int alignment, int *bitmap_offset_out, 
-                        unsigned long *bitmap_len_out, int *data_offset_out);
-
-extern int file_reader(__u64 offset, char *buf, int len, void *arg);
-extern int read_cow_header(int (*reader)(__u64, char *, int, void *), 
-                          void *arg, __u32 *version_out, 
-                          char **backing_file_out, time_t *mtime_out, 
-                          __u64 *size_out, int *sectorsize_out, 
-                          __u32 *align_out, int *bitmap_offset_out);
-
-extern int write_cow_header(char *cow_file, int fd, char *backing_file, 
-                           int sectorsize, int alignment, long long *size);
-
-extern void cow_sizes(int version, __u64 size, int sectorsize, int align,
-                     int bitmap_offset, unsigned long *bitmap_len_out, 
-                     int *data_offset_out);
-
-#endif
-
-/*
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
deleted file mode 100644 (file)
index 014c2c8..0000000
+++ /dev/null
@@ -1,375 +0,0 @@
-#include <stddef.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <byteswap.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include <netinet/in.h>
-
-#include "os.h"
-
-#include "cow.h"
-#include "cow_sys.h"
-
-#define PATH_LEN_V1 256
-
-struct cow_header_v1 {
-       int magic;
-       int version;
-       char backing_file[PATH_LEN_V1];
-       time_t mtime;
-       __u64 size;
-       int sectorsize;
-};
-
-#define PATH_LEN_V2 MAXPATHLEN
-
-struct cow_header_v2 {
-       unsigned long magic;
-       unsigned long version;
-       char backing_file[PATH_LEN_V2];
-       time_t mtime;
-       __u64 size;
-       int sectorsize;
-};
-
-/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in 
- * case other systems have different values for MAXPATHLEN
- */
-#define PATH_LEN_V3 4096
-
-/* Changes from V2 - 
- *     PATH_LEN_V3 as described above
- *     Explicitly specify field bit lengths for systems with different
- *             lengths for the usual C types.  Not sure whether char or
- *             time_t should be changed, this can be changed later without
- *             breaking compatibility
- *     Add alignment field so that different alignments can be used for the
- *             bitmap and data
- *     Add cow_format field to allow for the possibility of different ways
- *             of specifying the COW blocks.  For now, the only value is 0,
- *             for the traditional COW bitmap.
- *     Move the backing_file field to the end of the header.  This allows
- *             for the possibility of expanding it into the padding required
- *             by the bitmap alignment.
- *     The bitmap and data portions of the file will be aligned as specified
- *             by the alignment field.  This is to allow COW files to be
- *             put on devices with restrictions on access alignments, such as
- *             /dev/raw, with a 512 byte alignment restriction.  This also
- *             allows the data to be more aligned more strictly than on
- *             sector boundaries.  This is needed for ubd-mmap, which needs
- *             the data to be page aligned.
- *     Fixed (finally!) the rounding bug
- */
-
-struct cow_header_v3 {
-       __u32 magic;
-       __u32 version;
-       time_t mtime;
-       __u64 size;
-       __u32 sectorsize;
-       __u32 alignment;
-       __u32 cow_format;
-       char backing_file[PATH_LEN_V3];
-};
-
-/* COW format definitions - for now, we have only the usual COW bitmap */
-#define COW_BITMAP 0
-
-union cow_header {
-       struct cow_header_v1 v1;
-       struct cow_header_v2 v2;
-       struct cow_header_v3 v3;
-};
-
-#define COW_MAGIC 0x4f4f4f4d  /* MOOO */
-#define COW_VERSION 3
-
-#define DIV_ROUND(x, len) (((x) + (len) - 1) / (len))
-#define ROUND_UP(x, align) DIV_ROUND(x, align) * (align)
-
-void cow_sizes(int version, __u64 size, int sectorsize, int align, 
-              int bitmap_offset, unsigned long *bitmap_len_out, 
-              int *data_offset_out)
-{
-       if(version < 3){
-               *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
-
-               *data_offset_out = bitmap_offset + *bitmap_len_out;
-               *data_offset_out = (*data_offset_out + sectorsize - 1) / 
-                       sectorsize;
-               *data_offset_out *= sectorsize;
-       }
-       else {
-               *bitmap_len_out = DIV_ROUND(size, sectorsize);
-               *bitmap_len_out = DIV_ROUND(*bitmap_len_out, 8);
-
-               *data_offset_out = bitmap_offset + *bitmap_len_out;
-               *data_offset_out = ROUND_UP(*data_offset_out, align);
-       }
-}
-
-static int absolutize(char *to, int size, char *from)
-{
-       char save_cwd[256], *slash;
-       int remaining;
-
-       if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
-               cow_printf("absolutize : unable to get cwd - errno = %d\n", 
-                          errno);
-               return(-1);
-       }
-       slash = strrchr(from, '/');
-       if(slash != NULL){
-               *slash = '\0';
-               if(chdir(from)){
-                       *slash = '/';
-                       cow_printf("absolutize : Can't cd to '%s' - " 
-                                  "errno = %d\n", from, errno);
-                       return(-1);
-               }
-               *slash = '/';
-               if(getcwd(to, size) == NULL){
-                       cow_printf("absolutize : unable to get cwd of '%s' - "
-                              "errno = %d\n", from, errno);
-                       return(-1);
-               }
-               remaining = size - strlen(to);
-               if(strlen(slash) + 1 > remaining){
-                       cow_printf("absolutize : unable to fit '%s' into %d "
-                              "chars\n", from, size);
-                       return(-1);
-               }
-               strcat(to, slash);
-       }
-       else {
-               if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
-                       cow_printf("absolutize : unable to fit '%s' into %d "
-                              "chars\n", from, size);
-                       return(-1);
-               }
-               strcpy(to, save_cwd);
-               strcat(to, "/");
-               strcat(to, from);
-       }
-       chdir(save_cwd);
-       return(0);
-}
-
-int write_cow_header(char *cow_file, int fd, char *backing_file, 
-                    int sectorsize, int alignment, long long *size)
-{
-       struct cow_header_v3 *header;
-       unsigned long modtime;
-       int err;
-
-       err = cow_seek_file(fd, 0);
-       if(err < 0){
-               cow_printf("write_cow_header - lseek failed, err = %d\n", -err);
-               goto out;
-       }
-
-       err = -ENOMEM;
-       header = cow_malloc(sizeof(*header));
-       if(header == NULL){
-               cow_printf("Failed to allocate COW V3 header\n");
-               goto out;
-       }
-       header->magic = htonl(COW_MAGIC);
-       header->version = htonl(COW_VERSION);
-
-       err = -EINVAL;
-       if(strlen(backing_file) > sizeof(header->backing_file) - 1){
-               cow_printf("Backing file name \"%s\" is too long - names are "
-                          "limited to %d characters\n", backing_file, 
-                          sizeof(header->backing_file) - 1);
-               goto out_free;
-       }
-
-       if(absolutize(header->backing_file, sizeof(header->backing_file), 
-                     backing_file))
-               goto out_free;
-
-       err = os_file_modtime(header->backing_file, &modtime);
-       if(err < 0){
-               cow_printf("Backing file '%s' mtime request failed, "
-                          "err = %d\n", header->backing_file, -err);
-               goto out_free;
-       }
-
-       err = cow_file_size(header->backing_file, size);
-       if(err < 0){
-               cow_printf("Couldn't get size of backing file '%s', "
-                          "err = %d\n", header->backing_file, -err);
-               goto out_free;
-       }
-
-       header->mtime = htonl(modtime);
-       header->size = htonll(*size);
-       header->sectorsize = htonl(sectorsize);
-       header->alignment = htonl(alignment);
-       header->cow_format = COW_BITMAP;
-
-       err = os_write_file(fd, header, sizeof(*header));
-       if(err != sizeof(*header)){
-               cow_printf("Write of header to new COW file '%s' failed, "
-                          "err = %d\n", cow_file, -err);
-               goto out_free;
-       }
-       err = 0;
- out_free:
-       cow_free(header);
- out:
-       return(err);
-}
-
-int file_reader(__u64 offset, char *buf, int len, void *arg)
-{
-       int fd = *((int *) arg);
-
-       return(pread(fd, buf, len, offset));
-}
-
-/* XXX Need to sanity-check the values read from the header */
-
-int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, 
-                   __u32 *version_out, char **backing_file_out, 
-                   time_t *mtime_out, __u64 *size_out, 
-                   int *sectorsize_out, __u32 *align_out, 
-                   int *bitmap_offset_out)
-{
-       union cow_header *header;
-       char *file;
-       int err, n;
-       unsigned long version, magic;
-
-       header = cow_malloc(sizeof(*header));
-       if(header == NULL){
-               cow_printf("read_cow_header - Failed to allocate header\n");
-               return(-ENOMEM);
-       }
-       err = -EINVAL;
-       n = (*reader)(0, (char *) header, sizeof(*header), arg);
-       if(n < offsetof(typeof(header->v1), backing_file)){
-               cow_printf("read_cow_header - short header\n");
-               goto out;
-       }
-
-       magic = header->v1.magic;
-       if(magic == COW_MAGIC) {
-               version = header->v1.version;
-       }
-       else if(magic == ntohl(COW_MAGIC)){
-               version = ntohl(header->v1.version);
-       }
-       /* No error printed because the non-COW case comes through here */
-       else goto out;
-
-       *version_out = version;
-
-       if(version == 1){
-               if(n < sizeof(header->v1)){
-                       cow_printf("read_cow_header - failed to read V1 "
-                                  "header\n");
-                       goto out;
-               }
-               *mtime_out = header->v1.mtime;
-               *size_out = header->v1.size;
-               *sectorsize_out = header->v1.sectorsize;
-               *bitmap_offset_out = sizeof(header->v1);
-               *align_out = *sectorsize_out;
-               file = header->v1.backing_file;
-       }
-       else if(version == 2){
-               if(n < sizeof(header->v2)){
-                       cow_printf("read_cow_header - failed to read V2 "
-                                  "header\n");
-                       goto out;
-               }
-               *mtime_out = ntohl(header->v2.mtime);
-               *size_out = ntohll(header->v2.size);
-               *sectorsize_out = ntohl(header->v2.sectorsize);
-               *bitmap_offset_out = sizeof(header->v2);
-               *align_out = *sectorsize_out;
-               file = header->v2.backing_file;
-       }
-       else if(version == 3){
-               if(n < sizeof(header->v3)){
-                       cow_printf("read_cow_header - failed to read V2 "
-                                  "header\n");
-                       goto out;
-               }
-               *mtime_out = ntohl(header->v3.mtime);
-               *size_out = ntohll(header->v3.size);
-               *sectorsize_out = ntohl(header->v3.sectorsize);
-               *align_out = ntohl(header->v3.alignment);
-               *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
-               file = header->v3.backing_file;
-       }
-       else {
-               cow_printf("read_cow_header - invalid COW version\n");
-               goto out;               
-       }
-       err = -ENOMEM;
-       *backing_file_out = cow_strdup(file);
-       if(*backing_file_out == NULL){
-               cow_printf("read_cow_header - failed to allocate backing "
-                          "file\n");
-               goto out;
-       }
-       err = 0;
- out:
-       cow_free(header);
-       return(err);
-}
-
-int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
-                 int alignment, int *bitmap_offset_out, 
-                 unsigned long *bitmap_len_out, int *data_offset_out)
-{
-       __u64 size, offset;
-       char zero = 0;
-       int err;
-
-       err = write_cow_header(cow_file, fd, backing_file, sectorsize, 
-                              alignment, &size);
-       if(err) 
-               goto out;
-       
-       *bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment);
-       cow_sizes(COW_VERSION, size, sectorsize, alignment, *bitmap_offset_out,
-                 bitmap_len_out, data_offset_out);
-
-       offset = *data_offset_out + size - sizeof(zero);
-       err = cow_seek_file(fd, offset);
-       if(err < 0){
-               cow_printf("cow bitmap lseek failed : err = %d\n", -err);
-               goto out;
-       }
-
-       /* does not really matter how much we write it is just to set EOF 
-        * this also sets the entire COW bitmap
-        * to zero without having to allocate it 
-        */
-       err = cow_write_file(fd, &zero, sizeof(zero));
-       if(err != sizeof(zero)){
-               cow_printf("Write of bitmap to new COW file '%s' failed, "
-                          "err = %d\n", cow_file, -err);
-               err = -EINVAL;
-               goto out;
-       }
-
-       return(0);
-
- out:
-       return(err);
-}
-
-/*
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index de71aec..024972f 100644 (file)
@@ -53,7 +53,8 @@ static int connect_to_switch(struct daemon_data *pri)
        struct request_v3 req;
        int fd, n, err;
 
-       if((pri->control = socket(AF_UNIX, SOCK_STREAM, 0)) < 0){
+       pri->control = socket(AF_UNIX, SOCK_STREAM, 0);
+       if(pri->control < 0){
                printk("daemon_open : control socket failed, errno = %d\n", 
                       errno);          
                return(-errno);
@@ -67,7 +68,8 @@ static int connect_to_switch(struct daemon_data *pri)
                goto out;
        }
 
-       if((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0){
+       fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+       if(fd < 0){
                printk("daemon_open : data socket failed, errno = %d\n", 
                       errno);
                err = -errno;
@@ -91,18 +93,18 @@ static int connect_to_switch(struct daemon_data *pri)
        req.version = SWITCH_VERSION;
        req.type = REQ_NEW_CONTROL;
        req.sock = *local_addr;
-       n = write(pri->control, &req, sizeof(req));
+       n = os_write_file(pri->control, &req, sizeof(req));
        if(n != sizeof(req)){
-               printk("daemon_open : control setup request returned %d, "
-                      "errno = %d\n", n, errno);
+               printk("daemon_open : control setup request failed, err = %d\n",
+                      -n);
                err = -ENOTCONN;
                goto out;               
        }
 
-       n = read(pri->control, sun, sizeof(*sun));
+       n = os_read_file(pri->control, sun, sizeof(*sun));
        if(n != sizeof(*sun)){
-               printk("daemon_open : read of data socket returned %d, "
-                      "errno = %d\n", n, errno);
+               printk("daemon_open : read of data socket failed, err = %d\n", 
+                      -n);
                err = -ENOTCONN;
                goto out_close;         
        }
@@ -111,9 +113,9 @@ static int connect_to_switch(struct daemon_data *pri)
        return(fd);
 
  out_close:
-       close(fd);
+       os_close_file(fd);
  out:
-       close(pri->control);
+       os_close_file(pri->control);
        return(err);
 }
 
@@ -153,8 +155,8 @@ static void daemon_remove(void *data)
 {
        struct daemon_data *pri = data;
 
-       close(pri->fd);
-       close(pri->control);
+       os_close_file(pri->fd);
+       os_close_file(pri->control);
        if(pri->data_addr != NULL) kfree(pri->data_addr);
        if(pri->ctl_addr != NULL) kfree(pri->ctl_addr);
        if(pri->local_addr != NULL) kfree(pri->local_addr);
index 4ac314c..42cba3f 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <termios.h>
+#include <errno.h>
 #include "user.h"
 #include "user_util.h"
 #include "chan_user.h"
@@ -35,7 +36,8 @@ void *fd_init(char *str, int device, struct chan_opts *opts)
                printk("fd_init : couldn't parse file descriptor '%s'\n", str);
                return(NULL);
        }
-       if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL);
+       data = um_kmalloc(sizeof(*data));
+       if(data == NULL) return(NULL);
        *data = ((struct fd_chan) { .fd         = n,
                                    .raw        = opts->raw });
        return(data);
@@ -44,10 +46,16 @@ void *fd_init(char *str, int device, struct chan_opts *opts)
 int fd_open(int input, int output, int primary, void *d, char **dev_out)
 {
        struct fd_chan *data = d;
+       int err;
 
        if(data->raw && isatty(data->fd)){
-               tcgetattr(data->fd, &data->tt);
-               raw(data->fd, 0);
+               CATCH_EINTR(err = tcgetattr(data->fd, &data->tt));
+               if(err)
+                       return(err);
+
+               err = raw(data->fd);
+               if(err)
+                       return(err);
        }
        sprintf(data->str, "%d", data->fd);
        *dev_out = data->str;
@@ -57,9 +65,13 @@ int fd_open(int input, int output, int primary, void *d, char **dev_out)
 void fd_close(int fd, void *d)
 {
        struct fd_chan *data = d;
+       int err;
 
        if(data->raw && isatty(fd)){
-               tcsetattr(fd, TCSAFLUSH, &data->tt);
+               CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &data->tt));
+               if(err)
+                       printk("Failed to restore terminal state - " 
+                              "errno = %d\n", -err);
                data->raw = 0;
        }
 }
index cbbf41b..3563d4a 100644 (file)
@@ -27,10 +27,10 @@ static void pre_exec(void *d)
        dup2(data->stdin, 0);
        dup2(data->stdout, 1);
        dup2(data->stdout, 2);
-       close(data->stdin);
-       close(data->stdout);
-       close(data->close_me[0]);
-       close(data->close_me[1]);
+       os_close_file(data->stdin);
+       os_close_file(data->stdout);
+       os_close_file(data->close_me[0]);
+       os_close_file(data->close_me[1]);
 }
 
 int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
@@ -44,15 +44,15 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
        char **args = NULL;
 
        err = os_pipe(in_fds, 1, 0);
-       if(err){
-               printk("harddog_open - os_pipe failed, errno = %d\n", -err);
-               return(err);
+       if(err < 0){
+               printk("harddog_open - os_pipe failed, err = %d\n", -err);
+               goto out;
        }
 
        err = os_pipe(out_fds, 1, 0);
-       if(err){
-               printk("harddog_open - os_pipe failed, errno = %d\n", -err);
-               return(err);
+       if(err < 0){
+               printk("harddog_open - os_pipe failed, err = %d\n", -err);
+               goto out_close_in;
        }
 
        data.stdin = out_fds[0];
@@ -72,42 +72,47 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
 
        pid = run_helper(pre_exec, &data, args, NULL);
 
-       close(out_fds[0]);
-       close(in_fds[1]);
+       os_close_file(out_fds[0]);
+       os_close_file(in_fds[1]);
 
        if(pid < 0){
                err = -pid;
-               printk("harddog_open - run_helper failed, errno = %d\n", err);
-               goto out;
+               printk("harddog_open - run_helper failed, errno = %d\n", -err);
+               goto out_close_out;
        }
 
-       n = read(in_fds[0], &c, sizeof(c));
+       n = os_read_file(in_fds[0], &c, sizeof(c));
        if(n == 0){
                printk("harddog_open - EOF on watchdog pipe\n");
                helper_wait(pid);
                err = -EIO;
-               goto out;
+               goto out_close_out;
        }
        else if(n < 0){
                printk("harddog_open - read of watchdog pipe failed, "
-                      "errno = %d\n", errno);
+                      "err = %d\n", -n);
                helper_wait(pid);
-               err = -errno;
-               goto out;
+               err = n;
+               goto out_close_out;
        }
        *in_fd_ret = in_fds[0];
        *out_fd_ret = out_fds[1];
        return(0);
+
+ out_close_in:
+       os_close_file(in_fds[0]);
+       os_close_file(in_fds[1]);
+ out_close_out:
+       os_close_file(out_fds[0]);
+       os_close_file(out_fds[1]);
  out:
-       close(out_fds[1]);
-       close(in_fds[0]);
        return(err);
 }
 
 void stop_watchdog(int in_fd, int out_fd)
 {
-       close(in_fd);
-       close(out_fd);
+       os_close_file(in_fd);
+       os_close_file(out_fd);
 }
 
 int ping_watchdog(int fd)
@@ -115,11 +120,12 @@ int ping_watchdog(int fd)
        int n;
        char c = '\n';
 
-       n = write(fd, &c, sizeof(c));
-       if(n < sizeof(c)){
-               printk("ping_watchdog - write failed, errno = %d\n",
-                      errno);
-               return(-errno);
+       n = os_write_file(fd, &c, sizeof(c));
+       if(n != sizeof(c)){
+               printk("ping_watchdog - write failed, err = %d\n", -n);
+               if(n < 0) 
+                       return(n);
+               return(-EIO);
        }
        return 1;
 
index b512783..7f965c8 100644 (file)
@@ -5,44 +5,64 @@
 
 #include "linux/config.h"
 #include "linux/module.h"
-#include "linux/version.h"
 #include "linux/init.h"
 #include "linux/slab.h"
 #include "linux/fs.h"
 #include "linux/sound.h"
 #include "linux/soundcard.h"
+#include "asm/uaccess.h"
 #include "kern_util.h"
 #include "init.h"
-#include "hostaudio.h"
+#include "os.h"
+
+struct hostaudio_state {
+       int fd;
+};
+
+struct hostmixer_state {
+       int fd;
+};
+
+#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
+#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
 
 /* Only changed from linux_main at boot time */
 char *dsp = HOSTAUDIO_DEV_DSP;
 char *mixer = HOSTAUDIO_DEV_MIXER;
 
+#define DSP_HELP \
+"    This is used to specify the host dsp device to the hostaudio driver.\n" \
+"    The default is \"" HOSTAUDIO_DEV_DSP "\".\n\n"
+
+#define MIXER_HELP \
+"    This is used to specify the host mixer device to the hostaudio driver.\n"\
+"    The default is \"" HOSTAUDIO_DEV_MIXER "\".\n\n"
+
 #ifndef MODULE
 static int set_dsp(char *name, int *add)
 {
-       dsp = uml_strdup(name);
+       dsp = name;
        return(0);
 }
 
-__uml_setup("dsp=", set_dsp,
-"dsp=<dsp device>\n"
-"    This is used to specify the host dsp device to the hostaudio driver.\n"
-"    The default is \"" HOSTAUDIO_DEV_DSP "\".\n\n"
-);
+__uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
 
 static int set_mixer(char *name, int *add)
 {
-       mixer = uml_strdup(name);
+       mixer = name;
        return(0);
 }
 
-__uml_setup("mixer=", set_mixer,
-"mixer=<mixer device>\n"
-"    This is used to specify the host mixer device to the hostaudio driver.\n"
-"    The default is \"" HOSTAUDIO_DEV_MIXER "\".\n\n"
-);
+__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
+
+#else /*MODULE*/
+
+MODULE_PARM(dsp, "s");
+MODULE_PARM_DESC(dsp, DSP_HELP);
+
+MODULE_PARM(mixer, "s");
+MODULE_PARM_DESC(mixer, MIXER_HELP);
+
 #endif
 
 /* /dev/dsp file operations */
@@ -51,23 +71,56 @@ static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count,
                              loff_t *ppos)
 {
         struct hostaudio_state *state = file->private_data;
+       void *kbuf;
+       int err;
 
 #ifdef DEBUG
         printk("hostaudio: read called, count = %d\n", count);
 #endif
 
-        return(hostaudio_read_user(state, buffer, count, ppos));
+       kbuf = kmalloc(count, GFP_KERNEL);
+       if(kbuf == NULL)
+               return(-ENOMEM);
+
+       err = os_read_file(state->fd, kbuf, count);
+       if(err < 0)
+               goto out;
+
+       if(copy_to_user(buffer, kbuf, err))
+               err = -EFAULT;
+
+ out:
+       kfree(kbuf);
+       return(err);
 }
 
 static ssize_t hostaudio_write(struct file *file, const char *buffer, 
                               size_t count, loff_t *ppos)
 {
         struct hostaudio_state *state = file->private_data;
+       void *kbuf;
+       int err;
 
 #ifdef DEBUG
         printk("hostaudio: write called, count = %d\n", count);
 #endif
-        return(hostaudio_write_user(state, buffer, count, ppos));
+
+       kbuf = kmalloc(count, GFP_KERNEL);
+       if(kbuf == NULL)
+               return(-ENOMEM);
+
+       err = -EFAULT;
+       if(copy_from_user(kbuf, buffer, count))
+               goto out;
+
+       err = os_write_file(state->fd, kbuf, count);
+       if(err < 0)
+               goto out;
+       *ppos += err;
+
+ out:
+       kfree(kbuf);
+       return(err);
 }
 
 static unsigned int hostaudio_poll(struct file *file, 
@@ -86,12 +139,43 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
                           unsigned int cmd, unsigned long arg)
 {
         struct hostaudio_state *state = file->private_data;
+       unsigned long data = 0;
+       int err;
 
 #ifdef DEBUG
         printk("hostaudio: ioctl called, cmd = %u\n", cmd);
 #endif
-
-        return(hostaudio_ioctl_user(state, cmd, arg));
+       switch(cmd){
+       case SNDCTL_DSP_SPEED:
+       case SNDCTL_DSP_STEREO:
+       case SNDCTL_DSP_GETBLKSIZE:
+       case SNDCTL_DSP_CHANNELS:
+       case SNDCTL_DSP_SUBDIVIDE:
+       case SNDCTL_DSP_SETFRAGMENT:
+               if(get_user(data, (int *) arg))
+                       return(-EFAULT);
+               break;
+       default:
+               break;
+       }
+
+       err = os_ioctl_generic(state->fd, cmd, (unsigned long) &data);
+
+       switch(cmd){
+       case SNDCTL_DSP_SPEED:
+       case SNDCTL_DSP_STEREO:
+       case SNDCTL_DSP_GETBLKSIZE:
+       case SNDCTL_DSP_CHANNELS:
+       case SNDCTL_DSP_SUBDIVIDE:
+       case SNDCTL_DSP_SETFRAGMENT:
+               if(put_user(data, (int *) arg))
+                       return(-EFAULT);
+               break;
+       default:
+               break;
+       }
+
+       return(err);
 }
 
 static int hostaudio_open(struct inode *inode, struct file *file)
@@ -105,17 +189,19 @@ static int hostaudio_open(struct inode *inode, struct file *file)
 #endif
 
         state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
-        if(state == NULL) return(-ENOMEM);
+        if(state == NULL) 
+               return(-ENOMEM);
 
         if(file->f_mode & FMODE_READ) r = 1;
         if(file->f_mode & FMODE_WRITE) w = 1;
 
-        ret = hostaudio_open_user(state, r, w, dsp);
+       ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
         if(ret < 0){
                kfree(state);
                return(ret);
         }
 
+       state->fd = ret;
         file->private_data = state;
         return(0);
 }
@@ -123,16 +209,15 @@ static int hostaudio_open(struct inode *inode, struct file *file)
 static int hostaudio_release(struct inode *inode, struct file *file)
 {
         struct hostaudio_state *state = file->private_data;
-        int ret;
 
 #ifdef DEBUG
         printk("hostaudio: release called\n");
 #endif
 
-        ret = hostaudio_release_user(state);
+       os_close_file(state->fd);
         kfree(state);
 
-        return(ret);
+        return(0);
 }
 
 /* /dev/mixer file operations */
@@ -146,7 +231,7 @@ static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
         printk("hostmixer: ioctl called\n");
 #endif
 
-        return(hostmixer_ioctl_mixdev_user(state, cmd, arg));
+       return(os_ioctl_generic(state->fd, cmd, arg));
 }
 
 static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
@@ -165,9 +250,11 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
         if(file->f_mode & FMODE_READ) r = 1;
         if(file->f_mode & FMODE_WRITE) w = 1;
 
-        ret = hostmixer_open_mixdev_user(state, r, w, mixer);
+       ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
         
         if(ret < 0){
+               printk("hostaudio_open_mixdev failed to open '%s', err = %d\n",
+                      dsp, -ret);
                kfree(state);
                return(ret);
         }
@@ -179,16 +266,15 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
 static int hostmixer_release(struct inode *inode, struct file *file)
 {
         struct hostmixer_state *state = file->private_data;
-       int ret;
 
 #ifdef DEBUG
         printk("hostmixer: release called\n");
 #endif
 
-        ret = hostmixer_release_mixdev_user(state);
+       os_close_file(state->fd);
         kfree(state);
 
-        return(ret);
+        return(0);
 }
 
 
@@ -225,7 +311,8 @@ MODULE_LICENSE("GPL");
 
 static int __init hostaudio_init_module(void)
 {
-        printk(KERN_INFO "UML Audio Relay\n");
+        printk(KERN_INFO "UML Audio Relay (host dsp = %s, host mixer = %s)\n",
+              dsp, mixer);
 
        module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
         if(module_data.dev_audio < 0){
index c32fa1b..b89fefb 100644 (file)
@@ -4,9 +4,6 @@
  */
 
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
 #include "hostaudio.h"
 ssize_t hostaudio_read_user(struct hostaudio_state *state, char *buffer, 
                            size_t count, loff_t *ppos)
 {
-       ssize_t ret;
-
 #ifdef DEBUG
         printk("hostaudio: read_user called, count = %d\n", count);
 #endif
 
-        ret = read(state->fd, buffer, count);
-
-        if(ret < 0) return(-errno);
-        return(ret);
+       return(os_read_file(state->fd, buffer, count));
 }
 
 ssize_t hostaudio_write_user(struct hostaudio_state *state, const char *buffer,
                             size_t count, loff_t *ppos)
 {
-       ssize_t ret;
-
 #ifdef DEBUG
         printk("hostaudio: write_user called, count = %d\n", count);
 #endif
 
-        ret = write(state->fd, buffer, count);
-
-        if(ret < 0) return(-errno);
-        return(ret);
+       return(os_write_file(state->fd, buffer, count));
 }
 
 int hostaudio_ioctl_user(struct hostaudio_state *state, unsigned int cmd, 
                         unsigned long arg)
 {
-       int ret;
 #ifdef DEBUG
         printk("hostaudio: ioctl_user called, cmd = %u\n", cmd);
 #endif
 
-        ret = ioctl(state->fd, cmd, arg);
-       
-        if(ret < 0) return(-errno);
-        return(ret);
+       return(os_ioctl_generic(state->fd, cmd, arg));
 }
 
 int hostaudio_open_user(struct hostaudio_state *state, int r, int w, char *dsp)
@@ -67,14 +50,15 @@ int hostaudio_open_user(struct hostaudio_state *state, int r, int w, char *dsp)
         printk("hostaudio: open_user called\n");
 #endif
 
-        state->fd = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
-
-        if(state->fd >= 0) return(0);
+       state->fd = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
 
-        printk("hostaudio_open_user failed to open '%s', errno = %d\n",
-              dsp, errno);
+       if(state->fd < 0) {
+               printk("hostaudio_open_user failed to open '%s', err = %d\n",
+                      dsp, -state->fd);
+               return(state->fd); 
+       }
         
-        return(-errno); 
+       return(0);
 }
 
 int hostaudio_release_user(struct hostaudio_state *state)
@@ -82,10 +66,10 @@ int hostaudio_release_user(struct hostaudio_state *state)
 #ifdef DEBUG
         printk("hostaudio: release called\n");
 #endif
-        if(state->fd >= 0){
-               close(state->fd);
-               state->fd=-1;
-        }
+       if(state->fd >= 0){
+               os_close_file(state->fd);
+               state->fd = -1;
+       }
 
         return(0);
 }
@@ -95,15 +79,11 @@ int hostaudio_release_user(struct hostaudio_state *state)
 int hostmixer_ioctl_mixdev_user(struct hostmixer_state *state, 
                                unsigned int cmd, unsigned long arg)
 {
-       int ret;
 #ifdef DEBUG
         printk("hostmixer: ioctl_user called cmd = %u\n",cmd);
 #endif
 
-        ret = ioctl(state->fd, cmd, arg);
-       if(ret < 0) 
-               return(-errno);
-       return(ret);
+       return(os_ioctl_generic(state->fd, cmd, arg));
 }
 
 int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r, int w,
@@ -115,12 +95,13 @@ int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r, int w,
 
         state->fd = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
 
-        if(state->fd >= 0) return(0);
-
-        printk("hostaudio_open_mixdev_user failed to open '%s', errno = %d\n",
-              mixer, errno);
+       if(state->fd < 0) {
+               printk("hostaudio_open_mixdev_user failed to open '%s', "
+                      "err = %d\n", mixer, state->fd);
+               return(state->fd); 
+       }
         
-        return(-errno); 
+       return(0);
 }
 
 int hostmixer_release_mixdev_user(struct hostmixer_state *state)
@@ -130,7 +111,7 @@ int hostmixer_release_mixdev_user(struct hostmixer_state *state)
 #endif
 
         if(state->fd >= 0){
-               close(state->fd);
+               os_close_file(state->fd);
                state->fd = -1;
         }
 
index 92efc73..80b3e0e 100644 (file)
@@ -6,8 +6,8 @@
 #include "linux/sched.h"
 #include "linux/slab.h"
 #include "linux/list.h"
+#include "linux/interrupt.h"
 #include "linux/devfs_fs_kernel.h"
-#include "asm/irq.h"
 #include "asm/uaccess.h"
 #include "chan_kern.h"
 #include "irq_user.h"
 #include "user_util.h"
 #include "kern_util.h"
 #include "os.h"
+#include "irq_kern.h"
 
 #define LINE_BUFSIZE 4096
 
-void line_interrupt(int irq, void *data, struct pt_regs *unused)
+static irqreturn_t line_interrupt(int irq, void *data, struct pt_regs *unused)
 {
        struct line *dev = data;
 
        if(dev->count > 0) 
                chan_interrupt(&dev->chan_list, &dev->task, dev->tty, irq, 
                               dev);
+       return IRQ_HANDLED;
 }
 
-void line_timer_cb(void *arg)
+static void line_timer_cb(void *arg)
 {
        struct line *dev = arg;
 
        line_interrupt(dev->driver->read_irq, dev, NULL);
 }
 
-static void buffer_data(struct line *line, const char *buf, int len)
+static int write_room(struct line *dev)
 {
-       int end;
+       int n;
+
+       if(dev->buffer == NULL) return(LINE_BUFSIZE - 1);
+
+       n = dev->head - dev->tail;
+       if(n <= 0) n = LINE_BUFSIZE + n;
+       return(n - 1);
+}
+
+static int buffer_data(struct line *line, const char *buf, int len)
+{
+       int end, room;
 
        if(line->buffer == NULL){
                line->buffer = kmalloc(LINE_BUFSIZE, GFP_ATOMIC);
                if(line->buffer == NULL){
                        printk("buffer_data - atomic allocation failed\n");
-                       return;
+                       return(0);
                }
                line->head = line->buffer;
                line->tail = line->buffer;
        }
+
+       room = write_room(line);
+       len = (len > room) ? room : len;
+
        end = line->buffer + LINE_BUFSIZE - line->tail;
        if(len < end){
                memcpy(line->tail, buf, len);
@@ -60,6 +77,8 @@ static void buffer_data(struct line *line, const char *buf, int len)
                memcpy(line->buffer, buf, len);
                line->tail = line->buffer + len;
        }
+
+       return(len);
 }
 
 static int flush_buffer(struct line *line)
@@ -95,7 +114,7 @@ int line_write(struct line *lines, struct tty_struct *tty, int from_user,
        struct line *line;
        char *new;
        unsigned long flags;
-       int n, err, i;
+       int n, err, i, ret = 0;
 
        if(tty->stopped) return 0;
 
@@ -104,9 +123,13 @@ int line_write(struct line *lines, struct tty_struct *tty, int from_user,
                if(new == NULL)
                        return(0);
                n = copy_from_user(new, buf, len);
-               if(n == len)
-                       return(-EFAULT);
                buf = new;
+               if(n == len){
+                       len = -EFAULT;
+                       goto out_free;
+               }
+
+               len -= n;
        }
 
        i = tty->index;
@@ -115,41 +138,50 @@ int line_write(struct line *lines, struct tty_struct *tty, int from_user,
        down(&line->sem);
        if(line->head != line->tail){
                local_irq_save(flags);
-               buffer_data(line, buf, len);
+               ret += buffer_data(line, buf, len);
                err = flush_buffer(line);
                local_irq_restore(flags);
                if(err <= 0)
-                       goto out;
+                       goto out_up;
        }
        else {
                n = write_chan(&line->chan_list, buf, len, 
                               line->driver->write_irq);
                if(n < 0){
-                       len = n;
-                       goto out;
+                       ret = n;
+                       goto out_up;
                }
-               if(n < len)
-                       buffer_data(line, buf + n, len - n);
+
+               len -= n;
+               ret += n;
+               if(len > 0)
+                       ret += buffer_data(line, buf + n, len);
        }
- out:
+ out_up:
        up(&line->sem);
-       return(len);
+ out_free:
+       if(from_user)
+               kfree(buf);
+       return(ret);
 }
 
-void line_write_interrupt(int irq, void *data, struct pt_regs *unused)
+static irqreturn_t line_write_interrupt(int irq, void *data, 
+                                       struct pt_regs *unused)
 {
        struct line *dev = data;
        struct tty_struct *tty = dev->tty;
        int err;
 
        err = flush_buffer(dev);
-       if(err == 0) return;
+       if(err == 0) 
+               return(IRQ_NONE);
        else if(err < 0){
                dev->head = dev->buffer;
                dev->tail = dev->buffer;
        }
 
-       if(tty == NULL) return;
+       if(tty == NULL) 
+               return(IRQ_NONE);
 
        if(test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
           (tty->ldisc.write_wakeup != NULL))
@@ -161,21 +193,9 @@ void line_write_interrupt(int irq, void *data, struct pt_regs *unused)
         * writes.
         */
 
-       if (waitqueue_active(&tty->write_wait))
+       if(waitqueue_active(&tty->write_wait))
                wake_up_interruptible(&tty->write_wait);
-
-}
-
-int line_write_room(struct tty_struct *tty)
-{
-       struct line *dev = tty->driver_data;
-       int n;
-
-       if(dev->buffer == NULL) return(LINE_BUFSIZE - 1);
-
-       n = dev->head - dev->tail;
-       if(n <= 0) n = LINE_BUFSIZE + n;
-       return(n - 1);
+       return(IRQ_HANDLED);
 }
 
 int line_setup_irq(int fd, int input, int output, void *data)
@@ -305,7 +325,7 @@ int line_setup(struct line *lines, int num, char *init, int all_allowed)
                if(*end != '='){
                        printk(KERN_ERR "line_setup failed to parse \"%s\"\n", 
                               init);
-                       return(1);
+                       return(0);
                }
                init = end;
        }
@@ -313,12 +333,12 @@ int line_setup(struct line *lines, int num, char *init, int all_allowed)
        if((n >= 0) && (n >= num)){
                printk("line_setup - %d out of range ((0 ... %d) allowed)\n",
                       n, num);
-               return(1);
+               return(0);
        }
        else if(n >= 0){
                if(lines[n].count > 0){
                        printk("line_setup - device %d is open\n", n);
-                       return(1);
+                       return(0);
                }
                if(lines[n].init_pri <= INIT_ONE){
                        lines[n].init_pri = INIT_ONE;
@@ -332,7 +352,7 @@ int line_setup(struct line *lines, int num, char *init, int all_allowed)
        else if(!all_allowed){
                printk("line_setup - can't configure all devices from "
                       "mconsole\n");
-               return(1);
+               return(0);
        }
        else {
                for(i = 0; i < num; i++){
@@ -346,7 +366,7 @@ int line_setup(struct line *lines, int num, char *init, int all_allowed)
                        }
                }
        }
-       return(0);
+       return(1);
 }
 
 int line_config(struct line *lines, int num, char *str)
@@ -357,7 +377,7 @@ int line_config(struct line *lines, int num, char *str)
                printk("line_config - uml_strdup failed\n");
                return(-ENOMEM);
        }
-       return(line_setup(lines, num, new, 0));
+       return(!line_setup(lines, num, new, 0));
 }
 
 int line_get_config(char *name, struct line *lines, int num, char *str, 
@@ -369,7 +389,7 @@ int line_get_config(char *name, struct line *lines, int num, char *str,
 
        dev = simple_strtoul(name, &end, 0);
        if((*end != '\0') || (end == name)){
-               *error_out = "line_setup failed to parse device number";
+               *error_out = "line_get_config failed to parse device number";
                return(0);
        }
 
@@ -379,15 +399,15 @@ int line_get_config(char *name, struct line *lines, int num, char *str,
        }
 
        line = &lines[dev];
+
        down(&line->sem);
-       
        if(!line->valid)
                CONFIG_CHUNK(str, size, n, "none", 1);
        else if(line->count == 0)
                CONFIG_CHUNK(str, size, n, line->init_str, 1);
        else n = chan_config_string(&line->chan_list, str, size, error_out);
-
        up(&line->sem);
+
        return(n);
 }
 
@@ -396,7 +416,14 @@ int line_remove(struct line *lines, int num, char *str)
        char config[sizeof("conxxxx=none\0")];
 
        sprintf(config, "%s=none", str);
-       return(line_setup(lines, num, config, 0));
+       return(!line_setup(lines, num, config, 0));
+}
+
+int line_write_room(struct tty_struct *tty)
+{
+       struct line *dev = tty->driver_data;
+
+       return(write_room(dev));
 }
 
 struct tty_driver *line_register_devfs(struct lines *set,
@@ -412,7 +439,8 @@ struct tty_driver *line_register_devfs(struct lines *set,
                return NULL;
 
        driver->driver_name = line_driver->name;
-       driver->name = line_driver->devfs_name;
+       driver->name = line_driver->device_name;
+       driver->devfs_name = line_driver->devfs_name;
        driver->major = line_driver->major;
        driver->minor_start = line_driver->minor_start;
        driver->type = line_driver->type;
@@ -432,7 +460,7 @@ struct tty_driver *line_register_devfs(struct lines *set,
 
        for(i = 0; i < nlines; i++){
                if(!lines[i].valid) 
-                       tty_unregister_devfs(driver, i);
+                       tty_unregister_device(driver, i);
        }
 
        mconsole_register_dev(&line_driver->mc);
@@ -465,24 +493,25 @@ struct winch {
        struct line *line;
 };
 
-void winch_interrupt(int irq, void *data, struct pt_regs *unused)
+irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
 {
        struct winch *winch = data;
        struct tty_struct *tty;
        int err;
        char c;
 
-       err = generic_read(winch->fd, &c, NULL);
-       if(err < 0){
-               if(err != -EAGAIN){
-                       printk("winch_interrupt : read failed, errno = %d\n", 
-                              -err);
-                       printk("fd %d is losing SIGWINCH support\n", 
-                              winch->tty_fd);
-                       free_irq(irq, data);
-                       return;
+       if(winch->fd != -1){
+               err = generic_read(winch->fd, &c, NULL);
+               if(err < 0){
+                       if(err != -EAGAIN){
+                               printk("winch_interrupt : read failed, "
+                                      "errno = %d\n", -err);
+                               printk("fd %d is losing SIGWINCH support\n", 
+                                      winch->tty_fd);
+                               return(IRQ_HANDLED);
+                       }
+                       goto out;
                }
-               goto out;
        }
        tty = winch->line->tty;
        if(tty != NULL){
@@ -492,7 +521,9 @@ void winch_interrupt(int irq, void *data, struct pt_regs *unused)
                kill_pg(tty->pgrp, SIGWINCH, 1);
        }
  out:
-       reactivate_fd(winch->fd, WINCH_IRQ);
+       if(winch->fd != -1)
+               reactivate_fd(winch->fd, WINCH_IRQ);
+       return(IRQ_HANDLED);
 }
 
 DECLARE_MUTEX(winch_handler_sem);
@@ -529,7 +560,10 @@ static void winch_cleanup(void)
 
        list_for_each(ele, &winch_handlers){
                winch = list_entry(ele, struct winch, list);
-               close(winch->fd);
+               if(winch->fd != -1){
+                       deactivate_fd(winch->fd, WINCH_IRQ);
+                       os_close_file(winch->fd);
+               }
                if(winch->pid != -1) 
                        os_kill_process(winch->pid, 1);
        }
index 58e5db6..0fe1d9f 100644 (file)
@@ -23,6 +23,7 @@
 #include "kern_util.h"
 #include "user_util.h"
 #include "user.h"
+#include "os.h"
 
 #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
 
@@ -62,7 +63,8 @@ static int mcast_open(void *data)
                goto out;
        }
 
-       if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
+       fd = socket(AF_INET, SOCK_DGRAM, 0);
+       if (fd < 0){
                printk("mcast_open : data socket failed, errno = %d\n", 
                       errno);
                fd = -ENOMEM;
@@ -72,7 +74,7 @@ static int mcast_open(void *data)
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
                printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",
                        errno);
-               close(fd);
+               os_close_file(fd);
                fd = -EINVAL;
                goto out;
        }
@@ -82,7 +84,7 @@ static int mcast_open(void *data)
                       sizeof(pri->ttl)) < 0) {
                printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",
                        errno);
-               close(fd);
+               os_close_file(fd);
                fd = -EINVAL;
                goto out;
        }
@@ -91,7 +93,7 @@ static int mcast_open(void *data)
        if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
                printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",
                        errno);
-               close(fd);
+               os_close_file(fd);
                fd = -EINVAL;
                goto out;
        }
@@ -99,7 +101,7 @@ static int mcast_open(void *data)
        /* bind socket to mcast address */
        if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
                printk("mcast_open : data bind failed, errno = %d\n", errno);
-               close(fd);
+               os_close_file(fd);
                fd = -EINVAL;
                goto out;
        }               
@@ -115,7 +117,7 @@ static int mcast_open(void *data)
                       "interface on the host.\n");
                printk("eth0 should be configured in order to use the "
                       "multicast transport.\n");
-               close(fd);
+               os_close_file(fd);
                fd = -EINVAL;
        }
 
@@ -137,7 +139,7 @@ static void mcast_close(int fd, void *data)
                        errno);
        }
 
-       close(fd);
+       os_close_file(fd);
 }
 
 int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri)
index b12cb18..3396ba4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -15,6 +15,9 @@
 #include "linux/sysrq.h"
 #include "linux/workqueue.h"
 #include "linux/module.h"
+#include "linux/file.h"
+#include "linux/fs.h"
+#include "linux/namei.h"
 #include "linux/proc_fs.h"
 #include "asm/irq.h"
 #include "asm/uaccess.h"
@@ -27,6 +30,7 @@
 #include "init.h"
 #include "os.h"
 #include "umid.h"
+#include "irq_kern.h"
 
 static int do_unlink_socket(struct notifier_block *notifier, 
                            unsigned long what, void *data)
@@ -47,27 +51,26 @@ static struct notifier_block reboot_notifier = {
 
 LIST_HEAD(mc_requests);
 
-void mc_work_proc(void *unused)
+static void mc_work_proc(void *unused)
 {
        struct mconsole_entry *req;
        unsigned long flags;
-       int done;
 
-       do {
+       while(!list_empty(&mc_requests)){
                local_save_flags(flags);
                req = list_entry(mc_requests.next, struct mconsole_entry, 
                                 list);
                list_del(&req->list);
-               done = list_empty(&mc_requests);
                local_irq_restore(flags);
                req->request.cmd->handler(&req->request);
                kfree(req);
-       } while(!done);
+       }
 }
 
 DECLARE_WORK(mconsole_work, mc_work_proc, NULL);
 
-void mconsole_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t mconsole_interrupt(int irq, void *dev_id, 
+                                     struct pt_regs *regs)
 {
        int fd;
        struct mconsole_entry *new;
@@ -75,9 +78,10 @@ void mconsole_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
        fd = (int) dev_id;
        while (mconsole_get_request(fd, &req)){
-               if(req.cmd->as_interrupt) (*req.cmd->handler)(&req);
+               if(req.cmd->context == MCONSOLE_INTR) 
+                       (*req.cmd->handler)(&req);
                else {
-                       new = kmalloc(sizeof(req), GFP_ATOMIC);
+                       new = kmalloc(sizeof(*new), GFP_ATOMIC);
                        if(new == NULL)
                                mconsole_reply(&req, "Out of memory", 1, 0);
                        else {
@@ -86,8 +90,10 @@ void mconsole_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                        }
                }
        }
-       if(!list_empty(&mc_requests)) schedule_work(&mconsole_work);
+       if(!list_empty(&mc_requests)) 
+               schedule_work(&mconsole_work);
        reactivate_fd(fd, MCONSOLE_IRQ);
+       return(IRQ_HANDLED);
 }
 
 void mconsole_version(struct mc_request *req)
@@ -100,20 +106,109 @@ void mconsole_version(struct mc_request *req)
        mconsole_reply(req, version, 0, 0);
 }
 
+void mconsole_log(struct mc_request *req)
+{
+       int len;
+       char *ptr = req->request.data;
+       
+       ptr += strlen("log ");
+
+       len = req->len - (ptr - req->request.data);
+       printk("%.*s", len, ptr);
+       mconsole_reply(req, "", 0, 0);
+}
+
+void mconsole_proc(struct mc_request *req)
+{
+       struct nameidata nd;
+       struct file_system_type *proc;
+       struct super_block *super;
+       struct file *file;
+       int n, err;
+       char *ptr = req->request.data, *buf;
+       
+       ptr += strlen("proc");
+       while(isspace(*ptr)) ptr++;
+
+       proc = get_fs_type("proc");
+       if(proc == NULL){
+               mconsole_reply(req, "procfs not registered", 1, 0);
+               goto out;
+       }
+
+       super = (*proc->get_sb)(proc, 0, NULL, NULL);
+       put_filesystem(proc);
+       if(super == NULL){
+               mconsole_reply(req, "Failed to get procfs superblock", 1, 0);
+               goto out;
+       }
+       up_write(&super->s_umount);
+
+       nd.dentry = super->s_root;
+       nd.mnt = NULL;
+       nd.flags = O_RDONLY + 1;
+       nd.last_type = LAST_ROOT;
+
+       err = link_path_walk(ptr, &nd);
+       if(err){
+               mconsole_reply(req, "Failed to look up file", 1, 0);
+               goto out_kill;
+       }
+
+       file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
+       if(IS_ERR(file)){
+               mconsole_reply(req, "Failed to open file", 1, 0);
+               goto out_kill;
+       }
+
+       buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       if(buf == NULL){
+               mconsole_reply(req, "Failed to allocate buffer", 1, 0);
+               goto out_fput;
+       }
+
+       if((file->f_op != NULL) && (file->f_op->read != NULL)){
+               do {
+                       n = (*file->f_op->read)(file, buf, PAGE_SIZE - 1, 
+                                               &file->f_pos);
+                       if(n >= 0){
+                               buf[n] = '\0';
+                               mconsole_reply(req, buf, 0, (n > 0));
+                       }
+                       else {
+                               mconsole_reply(req, "Read of file failed", 
+                                              1, 0);
+                               goto out_free;
+                       }
+               } while(n > 0);
+       }
+       else mconsole_reply(req, "", 0, 0);
+
+ out_free:
+       kfree(buf);
+ out_fput:
+       fput(file);
+ out_kill:
+       deactivate_super(super);
+ out: ;
+}
+
 #define UML_MCONSOLE_HELPTEXT \
-"Commands:
-    version - Get kernel version
-    help - Print this message
-    halt - Halt UML
-    reboot - Reboot UML
-    config <dev>=<config> - Add a new device to UML; 
-       same syntax as command line
-    config <dev> - Query the configuration of a device
-    remove <dev> - Remove a device from UML
-    sysrq <letter> - Performs the SysRq action controlled by the letter
-    cad - invoke the Ctl-Alt-Del handler
-    stop - pause the UML; it will do nothing until it receives a 'go'
-    go - continue the UML after a 'stop'
+"Commands: \n\
+    version - Get kernel version \n\
+    help - Print this message \n\
+    halt - Halt UML \n\
+    reboot - Reboot UML \n\
+    config <dev>=<config> - Add a new device to UML;  \n\
+       same syntax as command line \n\
+    config <dev> - Query the configuration of a device \n\
+    remove <dev> - Remove a device from UML \n\
+    sysrq <letter> - Performs the SysRq action controlled by the letter \n\
+    cad - invoke the Ctl-Alt-Del handler \n\
+    stop - pause the UML; it will do nothing until it receives a 'go' \n\
+    go - continue the UML after a 'stop' \n\
+    log <string> - make UML enter <string> into the kernel log\n\
+    proc <file> - returns the contents of the UML's /proc/<file>\n\
 "
 
 void mconsole_help(struct mc_request *req)
@@ -279,8 +374,8 @@ void mconsole_sysrq(struct mc_request *req)
        ptr += strlen("sysrq");
        while(isspace(*ptr)) ptr++;
 
-       handle_sysrq(*ptr, &current->thread.regs, NULL);
        mconsole_reply(req, "", 0, 0);
+       handle_sysrq(*ptr, &current->thread.regs, NULL);
 }
 #else
 void mconsole_sysrq(struct mc_request *req)
@@ -302,7 +397,7 @@ int mconsole_init(void)
        if(umid_file_name("mconsole", file, sizeof(file))) return(-1);
        snprintf(mconsole_socket_name, sizeof(file), "%s", file);
 
-       sock = create_unix_socket(file, sizeof(file));
+       sock = os_create_unix_socket(file, sizeof(file), 1);
        if (sock < 0){
                printk("Failed to initialize management console\n");
                return(1);
@@ -344,11 +439,16 @@ static int write_proc_mconsole(struct file *file, const char *buffer,
        if(buf == NULL) 
                return(-ENOMEM);
 
-       if(copy_from_user(buf, buffer, count))
-               return(-EFAULT);
+       if(copy_from_user(buf, buffer, count)){
+               count = -EFAULT;
+               goto out;
+       }
+
        buf[count] = '\0';
 
        mconsole_notify(notify_socket, MCONSOLE_USER_NOTIFY, buf, count);
+ out:
+       kfree(buf);
        return(count);
 }
 
index 11b09a9..fe5afb1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
 #include "umid.h"
 
 static struct mconsole_command commands[] = {
-       { "version", mconsole_version, 1 },
-       { "halt", mconsole_halt, 0 },
-       { "reboot", mconsole_reboot, 0 },
-       { "config", mconsole_config, 0 },
-       { "remove", mconsole_remove, 0 },
-       { "sysrq", mconsole_sysrq, 1 },
-       { "help", mconsole_help, 1 },
-       { "cad", mconsole_cad, 1 },
-       { "stop", mconsole_stop, 0 },
-       { "go", mconsole_go, 1 },
+       { "version", mconsole_version, MCONSOLE_INTR },
+       { "halt", mconsole_halt, MCONSOLE_PROC },
+       { "reboot", mconsole_reboot, MCONSOLE_PROC },
+       { "config", mconsole_config, MCONSOLE_PROC },
+       { "remove", mconsole_remove, MCONSOLE_PROC },
+       { "sysrq", mconsole_sysrq, MCONSOLE_INTR },
+       { "help", mconsole_help, MCONSOLE_INTR },
+       { "cad", mconsole_cad, MCONSOLE_INTR },
+       { "stop", mconsole_stop, MCONSOLE_PROC },
+       { "go", mconsole_go, MCONSOLE_INTR },
+       { "log", mconsole_log, MCONSOLE_INTR },
+       { "proc", mconsole_proc, MCONSOLE_PROC },
 };
 
 /* Initialized in mconsole_init, which is an initcall */
@@ -139,6 +141,7 @@ int mconsole_reply(struct mc_request *req, char *str, int err, int more)
                memcpy(reply.data, str, len);
                reply.data[len] = '\0';
                total -= len;
+               str += len;
                reply.len = len + 1;
 
                len = sizeof(reply) + reply.len - sizeof(reply.data);
index 628d8f8..1862691 100644 (file)
@@ -120,7 +120,10 @@ static int __init mmapper_init(void)
        printk(KERN_INFO "Mapper v0.1\n");
 
        v_buf = (char *) find_iomem("mmapper", &mmapper_size);
-       if(mmapper_size == 0) return(0);
+       if(mmapper_size == 0){
+               printk(KERN_ERR "mmapper_init - find_iomem failed\n");
+               return(0);
+       }
 
        p_buf = __pa(v_buf);
 
index a52b79d..20c4732 100644 (file)
@@ -19,6 +19,8 @@
 #include "linux/inetdevice.h"
 #include "linux/ctype.h"
 #include "linux/bootmem.h"
+#include "linux/ethtool.h"
+#include "asm/uaccess.h"
 #include "user_util.h"
 #include "kern_util.h"
 #include "net_kern.h"
@@ -26,6 +28,7 @@
 #include "mconsole_kern.h"
 #include "init.h"
 #include "irq_user.h"
+#include "irq_kern.h"
 
 static spinlock_t opened_lock = SPIN_LOCK_UNLOCKED;
 LIST_HEAD(opened);
@@ -37,7 +40,8 @@ static int uml_net_rx(struct net_device *dev)
        struct sk_buff *skb;
 
        /* If we can't allocate memory, try again next round. */
-       if ((skb = dev_alloc_skb(dev->mtu)) == NULL) {
+       skb = dev_alloc_skb(dev->mtu);
+       if (skb == NULL) {
                lp->stats.rx_dropped++;
                return 0;
        }
@@ -61,14 +65,14 @@ static int uml_net_rx(struct net_device *dev)
        return pkt_len;
 }
 
-void uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
        struct net_device *dev = dev_id;
        struct uml_net_private *lp = dev->priv;
        int err;
 
        if(!netif_running(dev))
-               return;
+               return(IRQ_NONE);
 
        spin_lock(&lp->lock);
        while((err = uml_net_rx(dev)) > 0) ;
@@ -83,6 +87,7 @@ void uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
  out:
        spin_unlock(&lp->lock);
+       return(IRQ_HANDLED);
 }
 
 static int uml_net_open(struct net_device *dev)
@@ -237,7 +242,30 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
 
 static int uml_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-       return(-EINVAL);
+       static const struct ethtool_drvinfo info = {
+               .cmd     = ETHTOOL_GDRVINFO,
+               .driver  = "uml virtual ethernet",
+               .version = "42",
+       };
+       void *useraddr;
+       u32 ethcmd;
+
+       switch (cmd) {
+       case SIOCETHTOOL:
+               useraddr = ifr->ifr_data;
+               if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
+                       return -EFAULT;
+               switch (ethcmd) {
+               case ETHTOOL_GDRVINFO:
+                       if (copy_to_user(useraddr, &info, sizeof(info)))
+                               return -EFAULT;
+                       return 0;
+               default:
+                       return -EOPNOTSUPP;
+               }
+       default:
+               return -EINVAL;
+       }
 }
 
 void uml_net_user_timer_expire(unsigned long _conn)
@@ -250,37 +278,6 @@ void uml_net_user_timer_expire(unsigned long _conn)
 #endif
 }
 
-/*
- * default do nothing hard header packet routines for struct net_device init.
- * real ethernet transports will overwrite with real routines.
- */
-static int uml_net_hard_header(struct sk_buff *skb, struct net_device *dev,
-                 unsigned short type, void *daddr, void *saddr, unsigned len)
-{
-       return(0); /* no change */
-}
-
-static int uml_net_rebuild_header(struct sk_buff *skb)
-{
-       return(0); /* ignore */ 
-}
-
-static int uml_net_header_cache(struct neighbour *neigh, struct hh_cache *hh)
-{
-       return(-1); /* fail */
-}
-
-static void uml_net_header_cache_update(struct hh_cache *hh,
-                 struct net_device *dev, unsigned char * haddr)
-{
-       /* ignore */
-}
-
-static int uml_net_header_parse(struct sk_buff *skb, unsigned char *haddr)
-{
-       return(0); /* nothing */
-}
-
 static spinlock_t devices_lock = SPIN_LOCK_UNLOCKED;
 static struct list_head devices = LIST_HEAD_INIT(devices);
 
@@ -290,7 +287,7 @@ static int eth_configure(int n, void *init, char *mac,
        struct uml_net *device;
        struct net_device *dev;
        struct uml_net_private *lp;
-       int err, size;
+       int save, err, size;
 
        size = transport->private_size + sizeof(struct uml_net_private) + 
                sizeof(((struct uml_net_private *) 0)->user);
@@ -332,12 +329,6 @@ static int eth_configure(int n, void *init, char *mac,
        snprintf(dev->name, sizeof(dev->name), "eth%d", n);
        device->dev = dev;
 
-        dev->hard_header = uml_net_hard_header;
-        dev->rebuild_header = uml_net_rebuild_header;
-        dev->hard_header_cache = uml_net_header_cache;
-        dev->header_cache_update= uml_net_header_cache_update;
-        dev->hard_header_parse = uml_net_header_parse;
-
        (*transport->kern->init)(dev, init);
 
        dev->mtu = transport->user->max_packet;
@@ -364,21 +355,29 @@ static int eth_configure(int n, void *init, char *mac,
        }
        lp = dev->priv;
 
-       INIT_LIST_HEAD(&lp->list);
-       spin_lock_init(&lp->lock);
-       lp->dev = dev;
-       lp->fd = -1;
-       lp->mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0 };
-       lp->have_mac = device->have_mac;
-       lp->protocol = transport->kern->protocol;
-       lp->open = transport->user->open;
-       lp->close = transport->user->close;
-       lp->remove = transport->user->remove;
-       lp->read = transport->kern->read;
-       lp->write = transport->kern->write;
-       lp->add_address = transport->user->add_address;
-       lp->delete_address = transport->user->delete_address;
-       lp->set_mtu = transport->user->set_mtu;
+       /* lp.user is the first four bytes of the transport data, which
+        * has already been initialized.  This structure assignment will
+        * overwrite that, so we make sure that .user gets overwritten with
+        * what it already has.
+        */
+       save = lp->user[0];
+       *lp = ((struct uml_net_private) 
+               { .list                 = LIST_HEAD_INIT(lp->list),
+                 .lock                 = SPIN_LOCK_UNLOCKED,
+                 .dev                  = dev,
+                 .fd                   = -1,
+                 .mac                  = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
+                 .have_mac             = device->have_mac,
+                 .protocol             = transport->kern->protocol,
+                 .open                 = transport->user->open,
+                 .close                = transport->user->close,
+                 .remove               = transport->user->remove,
+                 .read                 = transport->kern->read,
+                 .write                = transport->kern->write,
+                 .add_address          = transport->user->add_address,
+                 .delete_address       = transport->user->delete_address,
+                 .set_mtu              = transport->user->set_mtu,
+                 .user                 = { save } });
 
        init_timer(&lp->tl);
        lp->tl.function = uml_net_user_timer_expire;
@@ -611,7 +610,8 @@ static int net_remove(char *str)
        unregister_netdev(dev);
 
        list_del(&device->list);
-       free_netdev(device);
+       kfree(device);
+       free_netdev(dev);
        return(0);
 }
 
index 75a83e9..8753188 100644 (file)
@@ -26,8 +26,7 @@ int tap_open_common(void *dev, char *gate_addr)
        if(gate_addr == NULL) return(0);
        if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], 
                  &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){
-               printk("Invalid tap IP address - '%s'\n", 
-                      gate_addr);
+               printk("Invalid tap IP address - '%s'\n", gate_addr);
                return(-EINVAL);
        }
        return(0);
@@ -60,18 +59,18 @@ void read_output(int fd, char *output, int len)
        }
                
        *output = '\0';
-       if(read(fd, &remain, sizeof(remain)) != sizeof(remain)){
-               printk("read_output - read of length failed, errno = %d\n",
-                      errno);
+       n = os_read_file(fd, &remain, sizeof(remain));
+       if(n != sizeof(remain)){
+               printk("read_output - read of length failed, err = %d\n", -n);
                return;
        }
 
        while(remain != 0){
                n = (remain < len) ? remain : len;
-               actual = read(fd, output, n);
+               actual = os_read_file(fd, output, n);
                if(actual != n){
                        printk("read_output - read of data failed, "
-                              "errno = %d\n", errno);
+                              "err = %d\n", -actual);
                        return;
                }
                remain -= actual;
@@ -83,13 +82,12 @@ int net_read(int fd, void *buf, int len)
 {
        int n;
 
-       while(((n = read(fd,  buf,  len)) < 0) && (errno == EINTR)) ;
+       n = os_read_file(fd,  buf,  len);
 
-       if(n < 0){
-               if(errno == EAGAIN) return(0);
-               return(-errno);
-       }
-       else if(n == 0) return(-ENOTCONN);
+       if(n == -EAGAIN) 
+               return(0);
+       else if(n == 0) 
+               return(-ENOTCONN);
        return(n);
 }
 
@@ -112,13 +110,13 @@ int net_write(int fd, void *buf, int len)
 {
        int n;
 
-       while(((n = write(fd, buf, len)) < 0) && (errno == EINTR)) ;
-       if(n < 0){
-               if(errno == EAGAIN) return(0);
-               return(-errno);
-       }
-       else if(n == 0) return(-ENOTCONN);
-       return(n);      
+       n = os_write_file(fd, buf, len);
+
+       if(n == -EAGAIN) 
+               return(0);
+       else if(n == 0) 
+               return(-ENOTCONN);
+       return(n);
 }
 
 int net_send(int fd, void *buf, int len)
@@ -157,7 +155,7 @@ static void change_pre_exec(void *arg)
 {
        struct change_pre_exec_data *data = arg;
 
-       close(data->close_me);
+       os_close_file(data->close_me);
        dup2(data->stdout, 1);
 }
 
@@ -167,17 +165,18 @@ static int change_tramp(char **argv, char *output, int output_len)
        struct change_pre_exec_data pe_data;
 
        err = os_pipe(fds, 1, 0);
-       if(err){
-               printk("change_tramp - pipe failed, errno = %d\n", -err);
+       if(err < 0){
+               printk("change_tramp - pipe failed, err = %d\n", -err);
                return(err);
        }
        pe_data.close_me = fds[0];
        pe_data.stdout = fds[1];
        pid = run_helper(change_pre_exec, &pe_data, argv, NULL);
 
-       close(fds[1]);
        read_output(fds[0], output, output_len);
-       waitpid(pid, NULL, 0);  
+       os_close_file(fds[0]);
+       os_close_file(fds[1]);
+       CATCH_EINTR(waitpid(pid, NULL, 0));     
        return(pid);
 }
 
index d361554..66b2fbe 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <stdlib.h>
 #include <errno.h>
-#include <fcntl.h>
 #include "chan_user.h"
 #include "os.h"
 
index 3c44630..4044053 100644 (file)
@@ -6,6 +6,7 @@
 #include "linux/list.h"
 #include "linux/sched.h"
 #include "linux/slab.h"
+#include "linux/interrupt.h"
 #include "linux/irq.h"
 #include "linux/spinlock.h"
 #include "linux/errno.h"
@@ -14,6 +15,7 @@
 #include "kern_util.h"
 #include "kern.h"
 #include "irq_user.h"
+#include "irq_kern.h"
 #include "port.h"
 #include "init.h"
 #include "os.h"
@@ -38,21 +40,21 @@ struct port_dev {
 struct connection {
        struct list_head list;
        int fd;
-       int helper_pid;
+       int helper_pid;
        int socket[2];
        int telnetd_pid;
        struct port_list *port;
 };
 
-static void pipe_interrupt(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t pipe_interrupt(int irq, void *data, struct pt_regs *regs)
 {
        struct connection *conn = data;
        int fd;
 
-       fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
+       fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
        if(fd < 0){
                if(fd == -EAGAIN)
-                       return;
+                       return(IRQ_NONE);
 
                printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n", 
                       -fd);
@@ -65,6 +67,7 @@ static void pipe_interrupt(int irq, void *data, struct pt_regs *regs)
        list_add(&conn->list, &conn->port->connections);
 
        up(&conn->port->sem);
+       return(IRQ_HANDLED);
 }
 
 static int port_accept(struct port_list *port)
@@ -102,8 +105,7 @@ static int port_accept(struct port_list *port)
        }
 
        list_add(&conn->list, &port->pending);
-       ret = 1;
-       goto out;
+       return(1);
 
  out_free:
        kfree(conn);
@@ -138,12 +140,13 @@ void port_work_proc(void *unused)
 
 DECLARE_WORK(port_work, port_work_proc, NULL);
 
-static void port_interrupt(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t port_interrupt(int irq, void *data, struct pt_regs *regs)
 {
        struct port_list *port = data;
 
        port->has_connection = 1;
        schedule_work(&port_work);
+       return(IRQ_HANDLED);
 } 
 
 void *port_data(int port_num)
index 7a37cf6..92a6d4e 100644 (file)
@@ -47,10 +47,12 @@ void *port_init(char *str, int device, struct chan_opts *opts)
                return(NULL);
        }
 
-       if((kern_data = port_data(port)) == NULL) 
+       kern_data = port_data(port);
+       if(kern_data == NULL) 
                return(NULL);
 
-       if((data = um_kmalloc(sizeof(*data))) == NULL) 
+       data = um_kmalloc(sizeof(*data));
+       if(data == NULL) 
                goto err;
 
        *data = ((struct port_chan) { .raw              = opts->raw,
@@ -74,12 +76,17 @@ void port_free(void *d)
 int port_open(int input, int output, int primary, void *d, char **dev_out)
 {
        struct port_chan *data = d;
-       int fd;
+       int fd, err;
 
        fd = port_wait(data->kernel_data);
        if((fd >= 0) && data->raw){
-               tcgetattr(fd, &data->tt);
-               raw(fd, 0);
+               CATCH_EINTR(err = tcgetattr(fd, &data->tt));
+               if(err)
+                       return(err);
+
+               err = raw(fd);
+               if(err)
+                       return(err);
        }
        *dev_out = data->dev;
        return(fd);
@@ -90,7 +97,7 @@ void port_close(int fd, void *d)
        struct port_chan *data = d;
 
        port_remove_dev(data->kernel_data);
-       close(fd);
+       os_close_file(fd);
 }
 
 int port_console_write(int fd, const char *buf, int n, void *d)
@@ -116,12 +123,18 @@ struct chan_ops port_ops = {
 int port_listen_fd(int port)
 {
        struct sockaddr_in addr;
-       int fd, err;
+       int fd, err, arg;
 
        fd = socket(PF_INET, SOCK_STREAM, 0);
        if(fd == -1) 
                return(-errno);
 
+       arg = 1;
+       if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
+               err = -errno;
+               goto out;
+       }
+
        addr.sin_family = AF_INET;
        addr.sin_port = htons(port);
        addr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -130,11 +143,15 @@ int port_listen_fd(int port)
                goto out;
        }
   
-       if((listen(fd, 1) < 0) || (os_set_fd_block(fd, 0))){
+       if(listen(fd, 1) < 0){
                err = -errno;
                goto out;
        }
 
+       err = os_set_fd_block(fd, 0);
+       if(err < 0)
+               goto out;
+
        return(fd);
  out:
        os_close_file(fd);
@@ -153,10 +170,10 @@ void port_pre_exec(void *arg)
        dup2(data->sock_fd, 0);
        dup2(data->sock_fd, 1);
        dup2(data->sock_fd, 2);
-       close(data->sock_fd);
+       os_close_file(data->sock_fd);
        dup2(data->pipe_fd, 3);
        os_shutdown_socket(3, 1, 0);
-       close(data->pipe_fd);
+       os_close_file(data->pipe_fd);
 }
 
 int port_connection(int fd, int *socket, int *pid_out)
@@ -166,11 +183,12 @@ int port_connection(int fd, int *socket, int *pid_out)
                         "/usr/lib/uml/port-helper", NULL };
        struct port_pre_exec_data data;
 
-       if((new = os_accept_connection(fd)) < 0)
-               return(-errno);
+       new = os_accept_connection(fd);
+       if(new < 0)
+               return(new);
 
        err = os_pipe(socket, 0, 0);
-       if(err) 
+       if(err < 0
                goto out_close;
 
        data = ((struct port_pre_exec_data)
@@ -186,11 +204,11 @@ int port_connection(int fd, int *socket, int *pid_out)
 
  out_shutdown:
        os_shutdown_socket(socket[0], 1, 1);
-       close(socket[0]);
+       os_close_file(socket[0]);
        os_shutdown_socket(socket[1], 1, 1);    
-       close(socket[1]);
+       os_close_file(socket[1]);
  out_close:
-       close(new);
+       os_close_file(new);
        return(err);
 }
 
index 0274053..d674171 100644 (file)
@@ -7,12 +7,12 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <termios.h>
 #include "chan_user.h"
 #include "user.h"
 #include "user_util.h"
 #include "kern_util.h"
+#include "os.h"
 
 struct pty_chan {
        void (*announce)(char *dev_name, int dev);
@@ -26,7 +26,8 @@ void *pty_chan_init(char *str, int device, struct chan_opts *opts)
 {
        struct pty_chan *data;
 
-       if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL);
+       data = um_kmalloc(sizeof(*data));
+       if(data == NULL) return(NULL);
        *data = ((struct pty_chan) { .announce          = opts->announce, 
                                     .dev               = device,
                                     .raw               = opts->raw });
@@ -37,15 +38,21 @@ int pts_open(int input, int output, int primary, void *d, char **dev_out)
 {
        struct pty_chan *data = d;
        char *dev;
-       int fd;
+       int fd, err;
 
-       if((fd = get_pty()) < 0){
+       fd = get_pty();
+       if(fd < 0){
                printk("open_pts : Failed to open pts\n");
                return(-errno);
        }
        if(data->raw){
-               tcgetattr(fd, &data->tt);
-               raw(fd, 0);
+               CATCH_EINTR(err = tcgetattr(fd, &data->tt));
+               if(err)
+                       return(err);
+
+               err = raw(fd);
+               if(err)
+                       return(err);
        }
 
        dev = ptsname(fd);
@@ -57,29 +64,27 @@ int pts_open(int input, int output, int primary, void *d, char **dev_out)
 
 int getmaster(char *line)
 {
-       struct stat stb;
        char *pty, *bank, *cp;
-       int master;
+       int master, err;
 
        pty = &line[strlen("/dev/ptyp")];
        for (bank = "pqrs"; *bank; bank++) {
                line[strlen("/dev/pty")] = *bank;
                *pty = '0';
-               if (stat(line, &stb) < 0)
+               if (os_stat_file(line, NULL) < 0)
                        break;
                for (cp = "0123456789abcdef"; *cp; cp++) {
                        *pty = *cp;
-                       master = open(line, O_RDWR);
+                       master = os_open_file(line, of_rdwr(OPENFLAGS()), 0);
                        if (master >= 0) {
                                char *tp = &line[strlen("/dev/")];
-                               int ok;
 
                                /* verify slave side is usable */
                                *tp = 't';
-                               ok = access(line, R_OK|W_OK) == 0;
+                               err = os_access(line, OS_ACC_RW_OK);
                                *tp = 'p';
-                               if (ok) return(master);
-                               (void) close(master);
+                               if(err == 0) return(master);
+                               (void) os_close_file(master);
                        }
                }
        }
@@ -89,13 +94,19 @@ int getmaster(char *line)
 int pty_open(int input, int output, int primary, void *d, char **dev_out)
 {
        struct pty_chan *data = d;
-       int fd;
+       int fd, err;
        char dev[sizeof("/dev/ptyxx\0")] = "/dev/ptyxx";
 
        fd = getmaster(dev);
-       if(fd < 0) return(-errno);
+       if(fd < 0) 
+               return(-errno);
+       
+       if(data->raw){
+               err = raw(fd);
+               if(err)
+                       return(err);
+       }
        
-       if(data->raw) raw(fd, 0);
        if(data->announce) (*data->announce)(dev, data->dev);
 
        sprintf(data->dev_name, "%s", dev);
index 782cf52..3d8d4ca 100644 (file)
@@ -4,11 +4,9 @@
 #include <stddef.h>
 #include <sched.h>
 #include <string.h>
-#include <sys/fcntl.h>
-#include <sys/errno.h>
+#include <errno.h>
 #include <sys/termios.h>
 #include <sys/wait.h>
-#include <sys/ioctl.h>
 #include <sys/signal.h>
 #include "user_util.h"
 #include "kern_util.h"
@@ -65,9 +63,9 @@ static void slip_pre_exec(void *arg)
 {
        struct slip_pre_exec_data *data = arg;
 
-       if(data->stdin != -1) dup2(data->stdin, 0);
+       if(data->stdin >= 0) dup2(data->stdin, 0);
        dup2(data->stdout, 1);
-       if(data->close_me != -1) close(data->close_me);
+       if(data->close_me >= 0) os_close_file(data->close_me);
 }
 
 static int slip_tramp(char **argv, int fd)
@@ -77,8 +75,8 @@ static int slip_tramp(char **argv, int fd)
        int status, pid, fds[2], err, output_len;
 
        err = os_pipe(fds, 1, 0);
-       if(err){
-               printk("slip_tramp : pipe failed, errno = %d\n", -err);
+       if(err < 0){
+               printk("slip_tramp : pipe failed, err = %d\n", -err);
                return(err);
        }
 
@@ -96,16 +94,18 @@ static int slip_tramp(char **argv, int fd)
                        printk("slip_tramp : failed to allocate output "
                               "buffer\n");
 
-               close(fds[1]);
+               os_close_file(fds[1]);
                read_output(fds[0], output, output_len);
                if(output != NULL){
                        printk("%s", output);
                        kfree(output);
                }
-               if(waitpid(pid, &status, 0) < 0) err = errno;
+               CATCH_EINTR(err = waitpid(pid, &status, 0));
+               if(err < 0)
+                       err = errno;
                else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){
                        printk("'%s' didn't exit with status 0\n", argv[0]);
-                       err = EINVAL;
+                       err = -EINVAL;
                }
        }
        return(err);
@@ -118,15 +118,17 @@ static int slip_open(void *data)
        char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
        char *argv[] = { "uml_net", version_buf, "slip", "up", gate_buf, 
                         NULL };
-       int sfd, mfd, disc, sencap, err;
+       int sfd, mfd, err;
 
-       if((mfd = get_pty()) < 0){
-               printk("umn : Failed to open pty\n");
-               return(-1);
+       mfd = get_pty();
+       if(mfd < 0){
+               printk("umn : Failed to open pty, err = %d\n", -mfd);
+               return(mfd);
        }
-       if((sfd = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0)) < 0){
-               printk("Couldn't open tty for slip line\n");
-               return(-1);
+       sfd = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0);
+       if(sfd < 0){
+               printk("Couldn't open tty for slip line, err = %d\n", -sfd);
+               return(sfd);
        }
        if(set_up_tty(sfd)) return(-1);
        pri->slave = sfd;
@@ -138,28 +140,23 @@ static int slip_open(void *data)
 
                err = slip_tramp(argv, sfd);
 
-               if(err != 0){
-                       printk("slip_tramp failed - errno = %d\n", err);
-                       return(-err);
+               if(err < 0){
+                       printk("slip_tramp failed - err = %d\n", -err);
+                       return(err);
                }
-               if(ioctl(pri->slave, SIOCGIFNAME, pri->name) < 0){
-                       printk("SIOCGIFNAME failed, errno = %d\n", errno);
-                       return(-errno);
+               err = os_get_ifname(pri->slave, pri->name);
+               if(err < 0){
+                       printk("get_ifname failed, err = %d\n", -err);
+                       return(err);
                }
                iter_addresses(pri->dev, open_addr, pri->name);
        }
        else {
-               disc = N_SLIP;
-               if(ioctl(sfd, TIOCSETD, &disc) < 0){
-                       printk("Failed to set slip line discipline - "
-                              "errno = %d\n", errno);
-                       return(-errno);
-               }
-               sencap = 0;
-               if(ioctl(sfd, SIOCSIFENCAP, &sencap) < 0){
-                       printk("Failed to set slip encapsulation - "
-                              "errno = %d\n", errno);
-                       return(-errno);
+               err = os_set_slip(sfd);
+               if(err < 0){
+                       printk("Failed to set slip discipline encapsulation - "
+                              "err = %d\n", -err);
+                       return(err);
                }
        }
        return(mfd);
@@ -181,9 +178,9 @@ static void slip_close(int fd, void *data)
        err = slip_tramp(argv, -1);
 
        if(err != 0)
-               printk("slip_tramp failed - errno = %d\n", err);
-       close(fd);
-       close(pri->slave);
+               printk("slip_tramp failed - errno = %d\n", -err);
+       os_close_file(fd);
+       os_close_file(pri->slave);
        pri->slave = -1;
 }
 
@@ -243,7 +240,7 @@ static void slip_add_addr(unsigned char *addr, unsigned char *netmask,
 {
        struct slip_data *pri = data;
 
-       if(pri->slave == -1) return;
+       if(pri->slave < 0) return;
        open_addr(addr, netmask, pri->name);
 }
 
@@ -252,7 +249,7 @@ static void slip_del_addr(unsigned char *addr, unsigned char *netmask,
 {
        struct slip_data *pri = data;
 
-       if(pri->slave == -1) return;
+       if(pri->slave < 0) return;
        close_addr(addr, netmask, pri->name);
 }
 
index cbdbb65..e95fcab 100644 (file)
@@ -4,8 +4,7 @@
 #include <stddef.h>
 #include <sched.h>
 #include <string.h>
-#include <sys/fcntl.h>
-#include <sys/errno.h>
+#include <errno.h>
 #include <sys/wait.h>
 #include <sys/signal.h>
 #include "user_util.h"
@@ -48,15 +47,15 @@ static int slirp_tramp(char **argv, int fd)
 
        return(pid);
 }
+
+/* XXX This is just a trivial wrapper around os_pipe */ 
 static int slirp_datachan(int *mfd, int *sfd)
 {
        int fds[2], err;
 
        err = os_pipe(fds, 1, 1);
-       if(err){
-               printk("slirp_datachan: Failed to open pipe, errno = %d\n",
-                      -err);
+       if(err < 0){
+               printk("slirp_datachan: Failed to open pipe, err = %d\n", -err);
                return(err);
        }
 
@@ -77,7 +76,7 @@ static int slirp_open(void *data)
        pid = slirp_tramp(pri->argw.argv, sfd);
 
        if(pid < 0){
-               printk("slirp_tramp failed - errno = %d\n", pid);
+               printk("slirp_tramp failed - errno = %d\n", -pid);
                os_close_file(sfd);     
                os_close_file(mfd);     
                return(pid);
@@ -97,8 +96,8 @@ static void slirp_close(int fd, void *data)
        struct slirp_data *pri = data;
        int status,err;
 
-       close(fd);
-       close(pri->slave);
+       os_close_file(fd);
+       os_close_file(pri->slave);
 
        pri->slave = -1;
 
@@ -114,13 +113,13 @@ static void slirp_close(int fd, void *data)
        }
 #endif
 
-       err = waitpid(pri->pid, &status, WNOHANG);
-       if(err<0) {
+       CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG));
+       if(err < 0) {
                printk("slirp_close: waitpid returned %d\n", errno);
                return;
        }
 
-       if(err==0) {
+       if(err == 0) {
                printk("slirp_close: process %d has not exited\n");
                return;
        }
index 826a77c..4649c4c 100644 (file)
@@ -10,6 +10,7 @@
 #include "linux/major.h"
 #include "linux/mm.h"
 #include "linux/init.h"
+#include "linux/console.h"
 #include "asm/termbits.h"
 #include "asm/irq.h"
 #include "line.h"
@@ -53,8 +54,9 @@ static int ssl_remove(char *str);
 
 static struct line_driver driver = {
        .name                   = "UML serial line",
-       .devfs_name             = "tts/%d",
-       .major                  = TTYAUX_MAJOR,
+       .device_name            = "ttS",
+       .devfs_name             = "tts/",
+       .major                  = TTY_MAJOR,
        .minor_start            = 64,
        .type                   = TTY_DRIVER_TYPE_SERIAL,
        .subtype                = 0,
@@ -149,6 +151,9 @@ static int ssl_ioctl(struct tty_struct *tty, struct file * file,
        case TCSETSW:
        case TCGETA:
        case TIOCMGET:
+       case TCSBRK:
+       case TCSBRKP:
+       case TIOCMSET:
                ret = -ENOIOCTLCMD;
                break;
        default:
@@ -212,6 +217,37 @@ static struct tty_operations ssl_ops = {
  */
 static int ssl_init_done = 0;
 
+static void ssl_console_write(struct console *c, const char *string, 
+                             unsigned len)
+{
+       struct line *line = &serial_lines[c->index];
+       if(ssl_init_done)
+               down(&line->sem);
+       console_write_chan(&line->chan_list, string, len);
+       if(ssl_init_done)
+               up(&line->sem);
+}
+
+static struct tty_driver *ssl_console_device(struct console *c, int *index)
+{
+       *index = c->index;
+       return ssl_driver;
+}
+
+static int ssl_console_setup(struct console *co, char *options)
+{
+       return(0);
+}
+
+static struct console ssl_cons = {
+       name:           "ttyS",
+       write:          ssl_console_write,
+       device:         ssl_console_device,
+       setup:          ssl_console_setup,
+       flags:          CON_PRINTBUFFER,
+       index:          -1,
+};
+
 int ssl_init(void)
 {
        char *new_title;
@@ -227,17 +263,18 @@ int ssl_init(void)
        new_title = add_xterm_umid(opts.xterm_title);
        if(new_title != NULL) opts.xterm_title = new_title;
 
+       register_console(&ssl_cons);
        ssl_init_done = 1;
        return(0);
 }
 
-__initcall(ssl_init);
+late_initcall(ssl_init);
 
 static int ssl_chan_setup(char *str)
 {
-       line_setup(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]),
-                  str, 1);
-       return(1);
+       return(line_setup(serial_lines, 
+                         sizeof(serial_lines)/sizeof(serial_lines[0]), 
+                         str, 1));
 }
 
 __setup("ssl", ssl_chan_setup);
index 3ae795e..90fb3a7 100644 (file)
@@ -83,7 +83,8 @@ static int con_remove(char *str);
 
 static struct line_driver driver = {
        .name                   = "UML console",
-       .devfs_name             = "vc/%d",
+       .device_name            = "tty",
+       .devfs_name             = "vc/",
        .major                  = TTY_MAJOR,
        .minor_start            = 0,
        .type                   = TTY_DRIVER_TYPE_CONSOLE,
@@ -159,6 +160,15 @@ static int chars_in_buffer(struct tty_struct *tty)
 
 static int con_init_done = 0;
 
+static struct tty_operations console_ops = {
+       .open                   = con_open,
+       .close                  = con_close,
+       .write                  = con_write,
+       .chars_in_buffer        = chars_in_buffer,
+       .set_termios            = set_termios,
+       .write_room             = line_write_room,
+};
+
 int stdio_init(void)
 {
        char *new_title;
@@ -166,7 +176,8 @@ int stdio_init(void)
        printk(KERN_INFO "Initializing stdio console driver\n");
 
        console_driver = line_register_devfs(&console_lines, &driver,
-                               &console_ops, vts, sizeof(vts)/sizeof(vts[0]));
+                                            &console_ops, vts,
+                                            sizeof(vts)/sizeof(vts[0]));
 
        lines_init(vts, sizeof(vts)/sizeof(vts[0]));
 
@@ -178,52 +189,53 @@ int stdio_init(void)
        return(0);
 }
 
-__initcall(stdio_init);
+late_initcall(stdio_init);
 
-static void console_write(struct console *console, const char *string, 
-                         unsigned len)
+static void uml_console_write(struct console *console, const char *string, 
+                             unsigned len)
 {
-       if(con_init_done) down(&vts[console->index].sem);
-       console_write_chan(&vts[console->index].chan_list, string, len);
-       if(con_init_done) up(&vts[console->index].sem);
-}
+       struct line *line = &vts[console->index];
 
-static struct tty_operations console_ops = {
-       .open                   = con_open,
-       .close                  = con_close,
-       .write                  = con_write,
-       .chars_in_buffer        = chars_in_buffer,
-       .set_termios            = set_termios,
-       .write_room             = line_write_room,
-};
+       if(con_init_done)
+               down(&line->sem);
+       console_write_chan(&line->chan_list, string, len);
+       if(con_init_done)
+               up(&line->sem);
+}
 
-static struct tty_driver *console_device(struct console *c, int *index)
+static struct tty_driver *uml_console_device(struct console *c, int *index)
 {
        *index = c->index;
        return console_driver;
 }
 
-static int console_setup(struct console *co, char *options)
+static int uml_console_setup(struct console *co, char *options)
 {
        return(0);
 }
 
-static struct console stdiocons = INIT_CONSOLE("tty", console_write, 
-                                              console_device, console_setup,
-                                              CON_PRINTBUFFER);
+static struct console stdiocons = {
+       name:           "tty",
+       write:          uml_console_write,
+       device:         uml_console_device,
+       setup:          uml_console_setup,
+       flags:          CON_PRINTBUFFER,
+       index:          -1,
+};
 
-static void __init stdio_console_init(void)
+static int __init stdio_console_init(void)
 {
        INIT_LIST_HEAD(&vts[0].chan_list);
        list_add(&init_console_chan.list, &vts[0].chan_list);
        register_console(&stdiocons);
+       return(0);
 }
+
 console_initcall(stdio_console_init);
 
 static int console_chan_setup(char *str)
 {
-       line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1);
-       return(1);
+       return(line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1));
 }
 
 __setup("con", console_chan_setup);
index e9eb9e3..54aadef 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <stdio.h>
 #include <termios.h>
-#include <fcntl.h>
 #include <errno.h>
 #include <unistd.h>
 #include "chan_user.h"
@@ -30,7 +29,8 @@ void *tty_chan_init(char *str, int device, struct chan_opts *opts)
        }
        str++;
 
-       if((data = um_kmalloc(sizeof(*data))) == NULL) 
+       data = um_kmalloc(sizeof(*data)); 
+       if(data == NULL) 
                return(NULL);
        *data = ((struct tty_chan) { .dev       = str,
                                     .raw       = opts->raw });
@@ -41,13 +41,18 @@ void *tty_chan_init(char *str, int device, struct chan_opts *opts)
 int tty_open(int input, int output, int primary, void *d, char **dev_out)
 {
        struct tty_chan *data = d;
-       int fd;
+       int fd, err;
 
        fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0);
        if(fd < 0) return(fd);
        if(data->raw){
-               tcgetattr(fd, &data->tt);
-               raw(fd, 0);
+               CATCH_EINTR(err = tcgetattr(fd, &data->tt));
+               if(err)
+                       return(err);
+
+               err = raw(fd);
+               if(err)
+                       return(err);
        }
 
        *dev_out = data->dev;
index 0c3890b..bad209b 100644 (file)
@@ -8,6 +8,13 @@
  * old style ubd by setting UBD_SHIFT to 0
  * 2002-09-27...2002-10-18 massive tinkering for 2.5
  * partitions have changed in 2.5
+ * 2003-01-29 more tinkering for 2.5.59-1
+ * This should now address the sysfs problems and has
+ * the symlink for devfs to allow for booting with
+ * the common /dev/ubd/discX/... names rather than
+ * only /dev/ubdN/discN this version also has lots of
+ * clean ups preparing for ubd-many.
+ * James McMechan
  */
 
 #define MAJOR_NR UBD_MAJOR
 #include "mconsole_kern.h"
 #include "init.h"
 #include "irq_user.h"
+#include "irq_kern.h"
 #include "ubd_user.h"
 #include "2_5compat.h"
 #include "os.h"
+#include "mem.h"
+#include "mem_kern.h"
 
 static spinlock_t ubd_io_lock = SPIN_LOCK_UNLOCKED;
 static spinlock_t ubd_lock = SPIN_LOCK_UNLOCKED;
@@ -56,6 +66,10 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
 
 #define MAX_DEV (8)
 
+/* Changed in early boot */
+static int ubd_do_mmap = 0;
+#define UBD_MMAP_BLOCK_SIZE PAGE_SIZE
+
 static struct block_device_operations ubd_blops = {
         .owner         = THIS_MODULE,
         .open          = ubd_open,
@@ -67,7 +81,7 @@ static struct block_device_operations ubd_blops = {
 static request_queue_t *ubd_queue;
 
 /* Protected by ubd_lock */
-static int fake_major = 0;
+static int fake_major = MAJOR_NR;
 
 static struct gendisk *ubd_gendisk[MAX_DEV];
 static struct gendisk *fake_gendisk[MAX_DEV];
@@ -96,13 +110,19 @@ struct cow {
 
 struct ubd {
        char *file;
-       int is_dir;
        int count;
        int fd;
        __u64 size;
        struct openflags boot_openflags;
        struct openflags openflags;
+       int no_cow;
        struct cow cow;
+
+       int map_writes;
+       int map_reads;
+       int nomap_writes;
+       int nomap_reads;
+       int write_maps;
 };
 
 #define DEFAULT_COW { \
@@ -115,21 +135,28 @@ struct ubd {
 
 #define DEFAULT_UBD { \
        .file =                 NULL, \
-       .is_dir =               0, \
        .count =                0, \
        .fd =                   -1, \
        .size =                 -1, \
        .boot_openflags =       OPEN_FLAGS, \
        .openflags =            OPEN_FLAGS, \
+        .no_cow =               0, \
         .cow =                 DEFAULT_COW, \
+       .map_writes             = 0, \
+       .map_reads              = 0, \
+       .nomap_writes           = 0, \
+       .nomap_reads            = 0, \
+       .write_maps             = 0, \
 }
 
 struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
 
 static int ubd0_init(void)
 {
-       if(ubd_dev[0].file == NULL)
-               ubd_dev[0].file = "root_fs";
+       struct ubd *dev = &ubd_dev[0];
+
+       if(dev->file == NULL)
+               dev->file = "root_fs";
        return(0);
 }
 
@@ -196,19 +223,46 @@ __uml_help(fake_ide_setup,
 "    Create ide0 entries that map onto ubd devices.\n\n"
 );
 
+static int parse_unit(char **ptr)
+{
+       char *str = *ptr, *end;
+       int n = -1;
+
+       if(isdigit(*str)) {
+               n = simple_strtoul(str, &end, 0);
+               if(end == str)
+                       return(-1);
+               *ptr = end;
+       }
+       else if (('a' <= *str) && (*str <= 'h')) {
+               n = *str - 'a';
+               str++;
+               *ptr = str;
+       }
+       return(n);
+}
+
 static int ubd_setup_common(char *str, int *index_out)
 {
+       struct ubd *dev;
        struct openflags flags = global_openflags;
        char *backing_file;
        int n, err;
 
        if(index_out) *index_out = -1;
-       n = *str++;
+       n = *str;
        if(n == '='){
-               static int fake_major_allowed = 1;
                char *end;
                int major;
 
+               str++;
+               if(!strcmp(str, "mmap")){
+                       CHOOSE_MODE(printk("mmap not supported by the ubd "
+                                          "driver in tt mode\n"),
+                                   ubd_do_mmap = 1);
+                       return(0);
+               }
+
                if(!strcmp(str, "sync")){
                        global_openflags.s = 1;
                        return(0);
@@ -220,20 +274,14 @@ static int ubd_setup_common(char *str, int *index_out)
                        return(1);
                }
 
-               if(!fake_major_allowed){
-                       printk(KERN_ERR "Can't assign a fake major twice\n");
-                       return(1);
-               }
-
                err = 1;
                spin_lock(&ubd_lock);
-               if(!fake_major_allowed){
+               if(fake_major != MAJOR_NR){
                        printk(KERN_ERR "Can't assign a fake major twice\n");
                        goto out1;
                }
  
                fake_major = major;
-               fake_major_allowed = 0;
 
                printk(KERN_INFO "Setting extra ubd major number to %d\n",
                       major);
@@ -243,25 +291,23 @@ static int ubd_setup_common(char *str, int *index_out)
                return(err);
        }
 
-       if(n < '0'){
-               printk(KERN_ERR "ubd_setup : index out of range\n"); }
-
-       if((n >= '0') && (n <= '9')) n -= '0';
-       else if((n >= 'a') && (n <= 'z')) n -= 'a';
-       else {
-               printk(KERN_ERR "ubd_setup : device syntax invalid\n");
+       n = parse_unit(&str);
+       if(n < 0){
+               printk(KERN_ERR "ubd_setup : couldn't parse unit number "
+                      "'%s'\n", str);
                return(1);
        }
        if(n >= MAX_DEV){
-               printk(KERN_ERR "ubd_setup : index out of range "
-                      "(%d devices)\n", MAX_DEV);      
+               printk(KERN_ERR "ubd_setup : index %d out of range "
+                      "(%d devices)\n", n, MAX_DEV);
                return(1);
        }
 
        err = 1;
        spin_lock(&ubd_lock);
 
-       if(ubd_dev[n].file != NULL){
+       dev = &ubd_dev[n];
+       if(dev->file != NULL){
                printk(KERN_ERR "ubd_setup : device already configured\n");
                goto out2;
        }
@@ -276,6 +322,11 @@ static int ubd_setup_common(char *str, int *index_out)
                flags.s = 1;
                str++;
        }
+       if (*str == 'd'){
+               dev->no_cow = 1;
+               str++;
+       }
+
        if(*str++ != '='){
                printk(KERN_ERR "ubd_setup : Expected '='\n");
                goto out2;
@@ -284,14 +335,17 @@ static int ubd_setup_common(char *str, int *index_out)
        err = 0;
        backing_file = strchr(str, ',');
        if(backing_file){
-               *backing_file = '\0';
-               backing_file++;
-       }
-       ubd_dev[n].file = str;
-       if(ubd_is_dir(ubd_dev[n].file))
-               ubd_dev[n].is_dir = 1;
-       ubd_dev[n].cow.file = backing_file;
-       ubd_dev[n].boot_openflags = flags;
+               if(dev->no_cow)
+                       printk(KERN_ERR "Can't specify both 'd' and a "
+                              "cow file\n");
+               else {
+                       *backing_file = '\0';
+                       backing_file++;
+               }
+       }
+       dev->file = str;
+       dev->cow.file = backing_file;
+       dev->boot_openflags = flags;
  out2:
        spin_unlock(&ubd_lock);
        return(err);
@@ -321,8 +375,7 @@ __uml_help(ubd_setup,
 static int fakehd_set = 0;
 static int fakehd(char *str)
 {
-       printk(KERN_INFO 
-              "fakehd : Changing ubd name to \"hd\".\n");
+       printk(KERN_INFO "fakehd : Changing ubd name to \"hd\".\n");
        fakehd_set = 1;
        return 1;
 }
@@ -368,32 +421,42 @@ static void ubd_handler(void)
 {
        struct io_thread_req req;
        struct request *rq = elv_next_request(ubd_queue);
-       int n;
+       int n, err;
 
        do_ubd = NULL;
        intr_count++;
        n = read_ubd_fs(thread_fd, &req, sizeof(req));
        if(n != sizeof(req)){
                printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
-                      "errno = %d\n", os_getpid(), -n);
+                      "err = %d\n", os_getpid(), -n);
                spin_lock(&ubd_io_lock);
                end_request(rq, 0);
                spin_unlock(&ubd_io_lock);
                return;
        }
         
-        if((req.offset != ((__u64) (rq->sector)) << 9) ||
-          (req.length != (rq->current_nr_sectors) << 9))
+       if((req.op != UBD_MMAP) && 
+          ((req.offset != ((__u64) (rq->sector)) << 9) ||
+           (req.length != (rq->current_nr_sectors) << 9)))
                panic("I/O op mismatch");
        
+       if(req.map_fd != -1){
+               err = physmem_subst_mapping(req.buffer, req.map_fd, 
+                                           req.map_offset, 1);
+               if(err)
+                       printk("ubd_handler - physmem_subst_mapping failed, "
+                              "err = %d\n", -err);
+       }
+
        ubd_finish(rq, req.error);
        reactivate_fd(thread_fd, UBD_IRQ);      
        do_ubd_request(ubd_queue);
 }
 
-static void ubd_intr(int irq, void *dev, struct pt_regs *unused)
+static irqreturn_t ubd_intr(int irq, void *dev, struct pt_regs *unused)
 {
        ubd_handler();
+       return(IRQ_HANDLED);
 }
 
 /* Only changed by ubd_init, which is an initcall. */
@@ -417,10 +480,14 @@ static int ubd_file_size(struct ubd *dev, __u64 *size_out)
 
 static void ubd_close(struct ubd *dev)
 {
+       if(ubd_do_mmap)
+               physmem_forget_descriptor(dev->fd);
        os_close_file(dev->fd);
        if(dev->cow.file == NULL)
                return;
 
+       if(ubd_do_mmap)
+               physmem_forget_descriptor(dev->cow.fd);
        os_close_file(dev->cow.fd);
        vfree(dev->cow.bitmap);
        dev->cow.bitmap = NULL;
@@ -429,18 +496,20 @@ static void ubd_close(struct ubd *dev)
 static int ubd_open_dev(struct ubd *dev)
 {
        struct openflags flags;
-       int err, n, create_cow, *create_ptr;
+       char **back_ptr;
+       int err, create_cow, *create_ptr;
 
+       dev->openflags = dev->boot_openflags;
        create_cow = 0;
        create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL;
-       dev->fd = open_ubd_file(dev->file, &dev->openflags, &dev->cow.file,
+       back_ptr = dev->no_cow ? NULL : &dev->cow.file;
+       dev->fd = open_ubd_file(dev->file, &dev->openflags, back_ptr,
                                &dev->cow.bitmap_offset, &dev->cow.bitmap_len, 
                                &dev->cow.data_offset, create_ptr);
 
        if((dev->fd == -ENOENT) && create_cow){
-               n = dev - ubd_dev;
                dev->fd = create_cow_file(dev->file, dev->cow.file, 
-                                         dev->openflags, 1 << 9,
+                                         dev->openflags, 1 << 9, PAGE_SIZE,
                                          &dev->cow.bitmap_offset, 
                                          &dev->cow.bitmap_len,
                                          &dev->cow.data_offset);
@@ -455,13 +524,17 @@ static int ubd_open_dev(struct ubd *dev)
        if(dev->cow.file != NULL){
                err = -ENOMEM;
                dev->cow.bitmap = (void *) vmalloc(dev->cow.bitmap_len);
-               if(dev->cow.bitmap == NULL) goto error;
+               if(dev->cow.bitmap == NULL){
+                       printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
+                       goto error;
+               }
                flush_tlb_kernel_vm();
 
                err = read_cow_bitmap(dev->fd, dev->cow.bitmap, 
                                      dev->cow.bitmap_offset, 
                                      dev->cow.bitmap_len);
-               if(err) goto error;
+               if(err < 0)
+                       goto error;
 
                flags = dev->openflags;
                flags.w = 0;
@@ -481,17 +554,31 @@ static int ubd_new_disk(int major, u64 size, int unit,
                        
 {
        struct gendisk *disk;
+       char from[sizeof("ubd/nnnnn\0")], to[sizeof("discnnnnn/disc\0")];
+       int err;
 
        disk = alloc_disk(1 << UBD_SHIFT);
-       if (!disk)
-               return -ENOMEM;
+       if(disk == NULL)
+               return(-ENOMEM);
 
        disk->major = major;
        disk->first_minor = unit << UBD_SHIFT;
        disk->fops = &ubd_blops;
        set_capacity(disk, size / 512);
-       sprintf(disk->disk_name, "ubd");
-       sprintf(disk->devfs_name, "ubd/disc%d", unit);
+       if(major == MAJOR_NR){
+               sprintf(disk->disk_name, "ubd%c", 'a' + unit);
+               sprintf(disk->devfs_name, "ubd/disc%d", unit);
+               sprintf(from, "ubd/%d", unit);
+               sprintf(to, "disc%d/disc", unit);
+               err = devfs_mk_symlink(from, to);
+               if(err)
+                       printk("ubd_new_disk failed to make link from %s to "
+                              "%s, error = %d\n", from, to, err);
+       }
+       else {
+               sprintf(disk->disk_name, "ubd_fake%d", unit);
+               sprintf(disk->devfs_name, "ubd_fake/disc%d", unit);
+       }
 
        disk->private_data = &ubd_dev[unit];
        disk->queue = ubd_queue;
@@ -506,24 +593,21 @@ static int ubd_add(int n)
        struct ubd *dev = &ubd_dev[n];
        int err;
 
-       if(dev->is_dir)
-               return(-EISDIR);
-
-       if (!dev->file)
+       if(dev->file == NULL)
                return(-ENODEV);
 
        if (ubd_open_dev(dev))
                return(-ENODEV);
 
        err = ubd_file_size(dev, &dev->size);
-       if(err)
+       if(err < 0)
                return(err);
 
        err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]);
        if(err) 
                return(err);
  
-       if(fake_major)
+       if(fake_major != MAJOR_NR)
                ubd_new_disk(fake_major, dev->size, n, 
                             &fake_gendisk[n]);
 
@@ -561,42 +645,42 @@ static int ubd_config(char *str)
        return(err);
 }
 
-static int ubd_get_config(char *dev, char *str, int size, char **error_out)
+static int ubd_get_config(char *name, char *str, int size, char **error_out)
 {
-       struct ubd *ubd;
+       struct ubd *dev;
        char *end;
-       int major, n = 0;
+       int n, len = 0;
 
-       major = simple_strtoul(dev, &end, 0);
-       if((*end != '\0') || (end == dev)){
-               *error_out = "ubd_get_config : didn't parse major number";
+       n = simple_strtoul(name, &end, 0);
+       if((*end != '\0') || (end == name)){
+               *error_out = "ubd_get_config : didn't parse device number";
                return(-1);
        }
 
-       if((major >= MAX_DEV) || (major < 0)){
-               *error_out = "ubd_get_config : major number out of range";
+       if((n >= MAX_DEV) || (n < 0)){
+               *error_out = "ubd_get_config : device number out of range";
                return(-1);
        }
 
-       ubd = &ubd_dev[major];
+       dev = &ubd_dev[n];
        spin_lock(&ubd_lock);
 
-       if(ubd->file == NULL){
-               CONFIG_CHUNK(str, size, n, "", 1);
+       if(dev->file == NULL){
+               CONFIG_CHUNK(str, size, len, "", 1);
                goto out;
        }
 
-       CONFIG_CHUNK(str, size, n, ubd->file, 0);
+       CONFIG_CHUNK(str, size, len, dev->file, 0);
 
-       if(ubd->cow.file != NULL){
-               CONFIG_CHUNK(str, size, n, ",", 0);
-               CONFIG_CHUNK(str, size, n, ubd->cow.file, 1);
+       if(dev->cow.file != NULL){
+               CONFIG_CHUNK(str, size, len, ",", 0);
+               CONFIG_CHUNK(str, size, len, dev->cow.file, 1);
        }
-       else CONFIG_CHUNK(str, size, n, "", 1);
+       else CONFIG_CHUNK(str, size, len, "", 1);
 
  out:
        spin_unlock(&ubd_lock);
-       return(n);
+       return(len);
 }
 
 static int ubd_remove(char *str)
@@ -604,11 +688,9 @@ static int ubd_remove(char *str)
        struct ubd *dev;
        int n, err = -ENODEV;
 
-       if(!isdigit(*str))
-               return(err);    /* it should be a number 0-7/a-h */
+       n = parse_unit(&str);
 
-       n = *str - '0';
-       if(n >= MAX_DEV) 
+       if((n < 0) || (n >= MAX_DEV))
                return(err);
 
        dev = &ubd_dev[n];
@@ -669,7 +751,7 @@ int ubd_init(void)
                
        elevator_init(ubd_queue, &elevator_noop);
 
-       if (fake_major != 0) {
+       if (fake_major != MAJOR_NR) {
                char name[sizeof("ubd_nnn\0")];
 
                snprintf(name, sizeof(name), "ubd_%d", fake_major);
@@ -696,6 +778,7 @@ int ubd_driver_init(void){
        io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *), 
                                 &thread_fd);
        if(io_pid < 0){
+               io_pid = -1;
                printk(KERN_ERR 
                       "ubd : Failed to start I/O thread (errno = %d) - "
                       "falling back to synchronous I/O\n", -io_pid);
@@ -703,8 +786,8 @@ int ubd_driver_init(void){
        }
        err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, 
                             SA_INTERRUPT, "ubd", ubd_dev);
-       if(err != 0) printk(KERN_ERR 
-                           "um_request_irq failed - errno = %d\n", -err);
+       if(err != 0) 
+               printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
        return(err);
 }
 
@@ -714,15 +797,9 @@ static int ubd_open(struct inode *inode, struct file *filp)
 {
        struct gendisk *disk = inode->i_bdev->bd_disk;
        struct ubd *dev = disk->private_data;
-       int err = -EISDIR;
+       int err = 0;
 
-       if(dev->is_dir == 1)
-               goto out;
-
-       err = 0;
        if(dev->count == 0){
-               dev->openflags = dev->boot_openflags;
-
                err = ubd_open_dev(dev);
                if(err){
                        printk(KERN_ERR "%s: Can't open \"%s\": errno = %d\n",
@@ -749,62 +826,156 @@ static int ubd_release(struct inode * inode, struct file * file)
        return(0);
 }
 
-void cowify_req(struct io_thread_req *req, struct ubd *dev)
+static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask, 
+                         __u64 *cow_offset, unsigned long *bitmap, 
+                         __u64 bitmap_offset, unsigned long *bitmap_words,
+                         __u64 bitmap_len)
+{
+       __u64 sector = io_offset >> 9;
+       int i, update_bitmap = 0;
+
+       for(i = 0; i < length >> 9; i++){
+               if(cow_mask != NULL)
+                       ubd_set_bit(i, (unsigned char *) cow_mask);
+               if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
+                       continue;
+
+               update_bitmap = 1;
+               ubd_set_bit(sector + i, (unsigned char *) bitmap);
+       }
+
+       if(!update_bitmap)
+               return;
+
+       *cow_offset = sector / (sizeof(unsigned long) * 8);
+
+       /* This takes care of the case where we're exactly at the end of the
+        * device, and *cow_offset + 1 is off the end.  So, just back it up
+        * by one word.  Thanks to Lynn Kerby for the fix and James McMechan
+        * for the original diagnosis.
+        */
+       if(*cow_offset == ((bitmap_len + sizeof(unsigned long) - 1) / 
+                          sizeof(unsigned long) - 1))
+               (*cow_offset)--;
+
+       bitmap_words[0] = bitmap[*cow_offset];
+       bitmap_words[1] = bitmap[*cow_offset + 1];
+
+       *cow_offset *= sizeof(unsigned long);
+       *cow_offset += bitmap_offset;
+}
+
+static void cowify_req(struct io_thread_req *req, unsigned long *bitmap, 
+                      __u64 bitmap_offset, __u64 bitmap_len)
 {
-        int i, update_bitmap, sector = req->offset >> 9;
+       __u64 sector = req->offset >> 9;
+       int i;
 
        if(req->length > (sizeof(req->sector_mask) * 8) << 9)
                panic("Operation too long");
+
        if(req->op == UBD_READ) {
                for(i = 0; i < req->length >> 9; i++){
-                       if(ubd_test_bit(sector + i, (unsigned char *) 
-                                       dev->cow.bitmap)){
+                       if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
                                ubd_set_bit(i, (unsigned char *) 
                                            &req->sector_mask);
-                       }
                 }
-        } 
-        else {
-               update_bitmap = 0;
-               for(i = 0; i < req->length >> 9; i++){
-                       ubd_set_bit(i, (unsigned char *) 
-                                   &req->sector_mask);
-                       if(!ubd_test_bit(sector + i, (unsigned char *) 
-                                        dev->cow.bitmap))
-                               update_bitmap = 1;
-                       ubd_set_bit(sector + i, (unsigned char *) 
-                                   dev->cow.bitmap);
-               }
-               if(update_bitmap){
-                       req->cow_offset = sector / (sizeof(unsigned long) * 8);
-                       req->bitmap_words[0] = 
-                               dev->cow.bitmap[req->cow_offset];
-                       req->bitmap_words[1] = 
-                               dev->cow.bitmap[req->cow_offset + 1];
-                       req->cow_offset *= sizeof(unsigned long);
-                       req->cow_offset += dev->cow.bitmap_offset;
+       }
+       else cowify_bitmap(req->offset, req->length, &req->sector_mask,
+                          &req->cow_offset, bitmap, bitmap_offset, 
+                          req->bitmap_words, bitmap_len);
+}
+
+static int mmap_fd(struct request *req, struct ubd *dev, __u64 offset)
+{
+       __u64 sector;
+       unsigned char *bitmap;
+       int bit, i;
+
+       /* mmap must have been requested on the command line */
+       if(!ubd_do_mmap)
+               return(-1);
+
+       /* The buffer must be page aligned */
+       if(((unsigned long) req->buffer % UBD_MMAP_BLOCK_SIZE) != 0)
+               return(-1);
+
+       /* The request must be a page long */
+       if((req->current_nr_sectors << 9) != PAGE_SIZE)
+               return(-1);
+
+       if(dev->cow.file == NULL)
+               return(dev->fd);
+
+       sector = offset >> 9;
+       bitmap = (unsigned char *) dev->cow.bitmap;
+       bit = ubd_test_bit(sector, bitmap);
+
+       for(i = 1; i < req->current_nr_sectors; i++){
+               if(ubd_test_bit(sector + i, bitmap) != bit)
+                       return(-1);
+       }
+
+       if(bit || (rq_data_dir(req) == WRITE))
+               offset += dev->cow.data_offset;
+
+       /* The data on disk must be page aligned */
+       if((offset % UBD_MMAP_BLOCK_SIZE) != 0)
+               return(-1);
+
+       return(bit ? dev->fd : dev->cow.fd);
+}
+
+static int prepare_mmap_request(struct ubd *dev, int fd, __u64 offset, 
+                               struct request *req, 
+                               struct io_thread_req *io_req)
+{
+       int err;
+
+       if(rq_data_dir(req) == WRITE){
+               /* Writes are almost no-ops since the new data is already in the
+                * host page cache
+                */
+               dev->map_writes++;
+               if(dev->cow.file != NULL)
+                       cowify_bitmap(io_req->offset, io_req->length, 
+                                     &io_req->sector_mask, &io_req->cow_offset,
+                                     dev->cow.bitmap, dev->cow.bitmap_offset,
+                                     io_req->bitmap_words, 
+                                     dev->cow.bitmap_len);
+       }
+       else {
+               int w;
+
+               if((dev->cow.file != NULL) && (fd == dev->cow.fd))
+                       w = 0;
+               else w = dev->openflags.w;
+
+               if((dev->cow.file != NULL) && (fd == dev->fd))
+                       offset += dev->cow.data_offset;
+
+               err = physmem_subst_mapping(req->buffer, fd, offset, w);
+               if(err){
+                       printk("physmem_subst_mapping failed, err = %d\n", 
+                              -err);
+                       return(1);
                }
+               dev->map_reads++;
        }
+       io_req->op = UBD_MMAP;
+       io_req->buffer = req->buffer;
+       return(0);
 }
 
 static int prepare_request(struct request *req, struct io_thread_req *io_req)
 {
        struct gendisk *disk = req->rq_disk;
        struct ubd *dev = disk->private_data;
-       __u64 block;
-       int nsect;
+       __u64 offset;
+       int len, fd;
 
        if(req->rq_status == RQ_INACTIVE) return(1);
 
-       if(dev->is_dir){
-               strcpy(req->buffer, "HOSTFS:");
-               strcat(req->buffer, dev->file);
-               spin_lock(&ubd_io_lock);
-               end_request(req, 1);
-               spin_unlock(&ubd_io_lock);
-               return(1);
-       }
-
        if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
                printk("Write attempted on readonly ubd device %s\n", 
                       disk->disk_name);
@@ -814,23 +985,49 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
                return(1);
        }
 
-        block = req->sector;
-        nsect = req->current_nr_sectors;
+       offset = ((__u64) req->sector) << 9;
+       len = req->current_nr_sectors << 9;
 
-       io_req->op = rq_data_dir(req) == READ ? UBD_READ : UBD_WRITE;
        io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd;
        io_req->fds[1] = dev->fd;
+       io_req->map_fd = -1;
+       io_req->cow_offset = -1;
+       io_req->offset = offset;
+       io_req->length = len;
+       io_req->error = 0;
+       io_req->sector_mask = 0;
+
+       fd = mmap_fd(req, dev, io_req->offset);
+       if(fd > 0){
+               /* If mmapping is otherwise OK, but the first access to the 
+                * page is a write, then it's not mapped in yet.  So we have 
+                * to write the data to disk first, then we can map the disk
+                * page in and continue normally from there.
+                */
+               if((rq_data_dir(req) == WRITE) && !is_remapped(req->buffer, dev->fd, io_req->offset + dev->cow.data_offset)){
+                       io_req->map_fd = dev->fd;
+                       io_req->map_offset = io_req->offset + 
+                               dev->cow.data_offset;
+                       dev->write_maps++;
+               }
+               else return(prepare_mmap_request(dev, fd, io_req->offset, req, 
+                                                io_req));
+       }
+
+       if(rq_data_dir(req) == READ)
+               dev->nomap_reads++;
+       else dev->nomap_writes++;
+
+       io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE;
        io_req->offsets[0] = 0;
        io_req->offsets[1] = dev->cow.data_offset;
-       io_req->offset = ((__u64) block) << 9;
-       io_req->length = nsect << 9;
        io_req->buffer = req->buffer;
        io_req->sectorsize = 1 << 9;
-       io_req->sector_mask = 0;
-       io_req->cow_offset = -1;
-       io_req->error = 0;
 
-        if(dev->cow.file != NULL) cowify_req(io_req, dev);
+       if(dev->cow.file != NULL) 
+               cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset,
+                          dev->cow.bitmap_len);
+
        return(0);
 }
 
@@ -841,7 +1038,7 @@ static void do_ubd_request(request_queue_t *q)
        int err, n;
 
        if(thread_fd == -1){
-               while(!list_empty(&q->queue_head)){
+               while(!elv_queue_empty(q)){
                        req = elv_next_request(q);
                        err = prepare_request(req, &io_req);
                        if(!err){
@@ -851,7 +1048,8 @@ static void do_ubd_request(request_queue_t *q)
                }
        }
        else {
-               if(do_ubd || list_empty(&q->queue_head)) return;
+               if(do_ubd || elv_queue_empty(q))
+                       return;
                req = elv_next_request(q);
                err = prepare_request(req, &io_req);
                if(!err){
@@ -885,7 +1083,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
                g.heads = 128;
                g.sectors = 32;
                g.cylinders = dev->size / (128 * 32 * 512);
-               g.start = 2;
+               g.start = get_start_sect(inode->i_bdev);
                return(copy_to_user(loc, &g, sizeof(g)) ? -EFAULT : 0);
 
        case HDIO_SET_UNMASKINTR:
@@ -935,6 +1133,150 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
        return(-EINVAL);
 }
 
+static int ubd_check_remapped(int fd, unsigned long address, int is_write,
+                             __u64 offset, int is_user)
+{
+       __u64 bitmap_offset;
+       unsigned long new_bitmap[2];
+       int i, err, n;
+
+       /* This can only fix kernelspace faults */
+       if(is_user)
+               return(0);
+
+       /* ubd-mmap is only enabled in skas mode */
+       if(CHOOSE_MODE(1, 0))
+               return(0);
+
+       /* If it's not a write access, we can't do anything about it */
+       if(!is_write)
+               return(0);
+
+       /* We have a write */
+       for(i = 0; i < sizeof(ubd_dev) / sizeof(ubd_dev[0]); i++){
+               struct ubd *dev = &ubd_dev[i];
+
+               if((dev->fd != fd) && (dev->cow.fd != fd))
+                       continue;
+
+               /* It's a write to a ubd device */
+
+               if(!dev->openflags.w){
+                       /* It's a write access on a read-only device - probably
+                        * shouldn't happen.  If the kernel is trying to change
+                        * something with no intention of writing it back out,
+                        * then this message will clue us in that this needs
+                        * fixing
+                        */
+                       printk("Write access to mapped page from readonly ubd "
+                              "device %d\n", i);
+                       return(0);
+               }
+
+               /* It's a write to a writeable ubd device - it must be COWed
+                * because, otherwise, the page would have been mapped in 
+                * writeable
+                */
+
+               if(!dev->cow.file)
+                       panic("Write fault on writeable non-COW ubd device %d",
+                             i);
+
+               /* It should also be an access to the backing file since the 
+                * COW pages should be mapped in read-write
+                */
+
+               if(fd == dev->fd)
+                       panic("Write fault on a backing page of ubd "
+                             "device %d\n", i);
+
+               /* So, we do the write, copying the backing data to the COW 
+                * file... 
+                */
+
+               err = os_seek_file(dev->fd, offset + dev->cow.data_offset);
+               if(err < 0)
+                       panic("Couldn't seek to %lld in COW file of ubd "
+                             "device %d, err = %d", 
+                             offset + dev->cow.data_offset, i, -err);
+
+               n = os_write_file(dev->fd, (void *) address, PAGE_SIZE);
+               if(n != PAGE_SIZE)
+                       panic("Couldn't copy data to COW file of ubd "
+                             "device %d, err = %d", i, -n);
+
+               /* ... updating the COW bitmap... */
+
+               cowify_bitmap(offset, PAGE_SIZE, NULL, &bitmap_offset, 
+                             dev->cow.bitmap, dev->cow.bitmap_offset, 
+                             new_bitmap, dev->cow.bitmap_len);
+
+               err = os_seek_file(dev->fd, bitmap_offset);
+               if(err < 0)
+                       panic("Couldn't seek to %lld in COW file of ubd "
+                             "device %d, err = %d", bitmap_offset, i, -err);
+
+               n = os_write_file(dev->fd, new_bitmap, sizeof(new_bitmap));
+               if(n != sizeof(new_bitmap))
+                       panic("Couldn't update bitmap  of ubd device %d, "
+                             "err = %d", i, -n);
+               
+               /* Maybe we can map the COW page in, and maybe we can't.  If
+                * it is a pre-V3 COW file, we can't, since the alignment will 
+                * be wrong.  If it is a V3 or later COW file which has been 
+                * moved to a system with a larger page size, then maybe we 
+                * can't, depending on the exact location of the page.
+                */
+
+               offset += dev->cow.data_offset;
+
+               /* Remove the remapping, putting the original anonymous page
+                * back.  If the COW file can be mapped in, that is done.
+                * Otherwise, the COW page is read in.
+                */
+
+               if(!physmem_remove_mapping((void *) address))
+                       panic("Address 0x%lx not remapped by ubd device %d", 
+                             address, i);
+               if((offset % UBD_MMAP_BLOCK_SIZE) == 0)
+                       physmem_subst_mapping((void *) address, dev->fd, 
+                                             offset, 1);
+               else {
+                       err = os_seek_file(dev->fd, offset);
+                       if(err < 0)
+                               panic("Couldn't seek to %lld in COW file of "
+                                     "ubd device %d, err = %d", offset, i, 
+                                     -err);
+
+                       n = os_read_file(dev->fd, (void *) address, PAGE_SIZE);
+                       if(n != PAGE_SIZE)
+                               panic("Failed to read page from offset %llx of "
+                                     "COW file of ubd device %d, err = %d",
+                                     offset, i, -n);
+               }
+
+               return(1);
+       }
+
+       /* It's not a write on a ubd device */
+       return(0);
+}
+
+static struct remapper ubd_remapper = {
+       .list   = LIST_HEAD_INIT(ubd_remapper.list),
+       .proc   = ubd_check_remapped,
+};
+
+static int ubd_remapper_setup(void)
+{
+       if(ubd_do_mmap)
+               register_remapper(&ubd_remapper);
+
+       return(0);
+}
+
+__initcall(ubd_remapper_setup);
+
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
index 93b6f3e..400c2a0 100644 (file)
 #include <signal.h>
 #include <string.h>
 #include <netinet/in.h>
-#include <sys/stat.h>
 #include <sys/time.h>
-#include <sys/fcntl.h>
 #include <sys/socket.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include "asm/types.h"
 #include "user.h"
 #include "ubd_user.h"
 #include "os.h"
+#include "cow.h"
 
 #include <endian.h>
 #include <byteswap.h>
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define ntohll(x) (x)
-# define htonll(x) (x)
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
-# define ntohll(x)  bswap_64(x)
-# define htonll(x)  bswap_64(x)
-#else
-#error "__BYTE_ORDER not defined"
-#endif
-
-#define PATH_LEN_V1 256
-
-struct cow_header_v1 {
-       int magic;
-       int version;
-       char backing_file[PATH_LEN_V1];
-       time_t mtime;
-       __u64 size;
-       int sectorsize;
-};
-
-#define PATH_LEN_V2 MAXPATHLEN
-
-struct cow_header_v2 {
-       unsigned long magic;
-       unsigned long version;
-       char backing_file[PATH_LEN_V2];
-       time_t mtime;
-       __u64 size;
-       int sectorsize;
-};
-
-union cow_header {
-       struct cow_header_v1 v1;
-       struct cow_header_v2 v2;
-};
-
-#define COW_MAGIC 0x4f4f4f4d  /* MOOO */
-#define COW_VERSION 2
-
-static void sizes(__u64 size, int sectorsize, int bitmap_offset, 
-                 unsigned long *bitmap_len_out, int *data_offset_out)
-{
-       *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
-
-       *data_offset_out = bitmap_offset + *bitmap_len_out;
-       *data_offset_out = (*data_offset_out + sectorsize - 1) / sectorsize;
-       *data_offset_out *= sectorsize;
-}
-
-static int read_cow_header(int fd, int *magic_out, char **backing_file_out, 
-                          time_t *mtime_out, __u64 *size_out, 
-                          int *sectorsize_out, int *bitmap_offset_out)
-{
-       union cow_header *header;
-       char *file;
-       int err, n;
-       unsigned long version, magic;
-
-       header = um_kmalloc(sizeof(*header));
-       if(header == NULL){
-               printk("read_cow_header - Failed to allocate header\n");
-               return(-ENOMEM);
-       }
-       err = -EINVAL;
-       n = read(fd, header, sizeof(*header));
-       if(n < offsetof(typeof(header->v1), backing_file)){
-               printk("read_cow_header - short header\n");
-               goto out;
-       }
-
-       magic = header->v1.magic;
-       if(magic == COW_MAGIC) {
-               version = header->v1.version;
-       }
-       else if(magic == ntohl(COW_MAGIC)){
-               version = ntohl(header->v1.version);
-       }
-       else goto out;
-
-       *magic_out = COW_MAGIC;
-
-       if(version == 1){
-               if(n < sizeof(header->v1)){
-                       printk("read_cow_header - failed to read V1 header\n");
-                       goto out;
-               }
-               *mtime_out = header->v1.mtime;
-               *size_out = header->v1.size;
-               *sectorsize_out = header->v1.sectorsize;
-               *bitmap_offset_out = sizeof(header->v1);
-               file = header->v1.backing_file;
-       }
-       else if(version == 2){
-               if(n < sizeof(header->v2)){
-                       printk("read_cow_header - failed to read V2 header\n");
-                       goto out;
-               }
-               *mtime_out = ntohl(header->v2.mtime);
-               *size_out = ntohll(header->v2.size);
-               *sectorsize_out = ntohl(header->v2.sectorsize);
-               *bitmap_offset_out = sizeof(header->v2);
-               file = header->v2.backing_file;
-       }
-       else {
-               printk("read_cow_header - invalid COW version\n");
-               goto out;
-       }
-       err = -ENOMEM;
-       *backing_file_out = uml_strdup(file);
-       if(*backing_file_out == NULL){
-               printk("read_cow_header - failed to allocate backing file\n");
-               goto out;
-       }
-       err = 0;
- out:
-       kfree(header);
-       return(err);
-}
 
 static int same_backing_files(char *from_cmdline, char *from_cow, char *cow)
 {
-       struct stat buf1, buf2;
+       struct uml_stat buf1, buf2;
+       int err;
 
        if(from_cmdline == NULL) return(1);
        if(!strcmp(from_cmdline, from_cow)) return(1);
 
-       if(stat(from_cmdline, &buf1) < 0){
-               printk("Couldn't stat '%s', errno = %d\n", from_cmdline, 
-                      errno);
+       err = os_stat_file(from_cmdline, &buf1);
+       if(err < 0){
+               printk("Couldn't stat '%s', err = %d\n", from_cmdline, -err);
                return(1);
        }
-       if(stat(from_cow, &buf2) < 0){
-               printk("Couldn't stat '%s', errno = %d\n", from_cow, errno);
+       err = os_stat_file(from_cow, &buf2);
+       if(err < 0){
+               printk("Couldn't stat '%s', err = %d\n", from_cow, -err);
                return(1);
        }
-       if((buf1.st_dev == buf2.st_dev) && (buf1.st_ino == buf2.st_ino))
+       if((buf1.ust_major == buf2.ust_major) && 
+          (buf1.ust_minor == buf2.ust_minor) && 
+          (buf1.ust_ino == buf2.ust_ino))
                return(1);
 
        printk("Backing file mismatch - \"%s\" requested,\n"
@@ -174,20 +57,21 @@ static int same_backing_files(char *from_cmdline, char *from_cow, char *cow)
 
 static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
 {
-       struct stat64 buf;
+       unsigned long modtime;
        long long actual;
        int err;
 
-       if(stat64(file, &buf) < 0){
-               printk("Failed to stat backing file \"%s\", errno = %d\n",
-                      file, errno);
-               return(-errno);
+       err = os_file_modtime(file, &modtime);
+       if(err < 0){
+               printk("Failed to get modification time of backing file "
+                      "\"%s\", err = %d\n", file, -err);
+               return(err);
        }
 
        err = os_file_size(file, &actual);
-       if(err){
+       if(err < 0){
                printk("Failed to get size of backing file \"%s\", "
-                      "errno = %d\n", file, -err);
+                      "err = %d\n", file, -err);
                return(err);
        }
 
@@ -196,9 +80,9 @@ static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
                       "file\n", size, actual);
                return(-EINVAL);
        }
-       if(buf.st_mtime != mtime){
+       if(modtime != mtime){
                printk("mtime mismatch (%ld vs %ld) of COW header vs backing "
-                      "file\n", mtime, buf.st_mtime);
+                      "file\n", mtime, modtime);
                return(-EINVAL);
        }
        return(0);
@@ -209,124 +93,16 @@ int read_cow_bitmap(int fd, void *buf, int offset, int len)
        int err;
 
        err = os_seek_file(fd, offset);
-       if(err != 0) return(-errno);
-       err = read(fd, buf, len);
-       if(err < 0) return(-errno);
-       return(0);
-}
+       if(err < 0) 
+               return(err);
 
-static int absolutize(char *to, int size, char *from)
-{
-       char save_cwd[256], *slash;
-       int remaining;
+       err = os_read_file(fd, buf, len);
+       if(err < 0) 
+               return(err);
 
-       if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
-               printk("absolutize : unable to get cwd - errno = %d\n", errno);
-               return(-1);
-       }
-       slash = strrchr(from, '/');
-       if(slash != NULL){
-               *slash = '\0';
-               if(chdir(from)){
-                       *slash = '/';
-                       printk("absolutize : Can't cd to '%s' - errno = %d\n",
-                              from, errno);
-                       return(-1);
-               }
-               *slash = '/';
-               if(getcwd(to, size) == NULL){
-                       printk("absolutize : unable to get cwd of '%s' - "
-                              "errno = %d\n", from, errno);
-                       return(-1);
-               }
-               remaining = size - strlen(to);
-               if(strlen(slash) + 1 > remaining){
-                       printk("absolutize : unable to fit '%s' into %d "
-                              "chars\n", from, size);
-                       return(-1);
-               }
-               strcat(to, slash);
-       }
-       else {
-               if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
-                       printk("absolutize : unable to fit '%s' into %d "
-                              "chars\n", from, size);
-                       return(-1);
-               }
-               strcpy(to, save_cwd);
-               strcat(to, "/");
-               strcat(to, from);
-       }
-       chdir(save_cwd);
        return(0);
 }
 
-static int write_cow_header(char *cow_file, int fd, char *backing_file, 
-                           int sectorsize, long long *size)
-{
-        struct cow_header_v2 *header;
-       struct stat64 buf;
-       int err;
-
-       err = os_seek_file(fd, 0);
-       if(err != 0){
-               printk("write_cow_header - lseek failed, errno = %d\n", errno);
-               return(-errno);
-       }
-
-       err = -ENOMEM;
-       header = um_kmalloc(sizeof(*header));
-       if(header == NULL){
-               printk("Failed to allocate COW V2 header\n");
-               goto out;
-       }
-       header->magic = htonl(COW_MAGIC);
-       header->version = htonl(COW_VERSION);
-
-       err = -EINVAL;
-       if(strlen(backing_file) > sizeof(header->backing_file) - 1){
-               printk("Backing file name \"%s\" is too long - names are "
-                      "limited to %d characters\n", backing_file, 
-                      sizeof(header->backing_file) - 1);
-               goto out_free;
-       }
-
-       if(absolutize(header->backing_file, sizeof(header->backing_file), 
-                     backing_file))
-               goto out_free;
-
-       err = stat64(header->backing_file, &buf);
-       if(err < 0){
-               printk("Stat of backing file '%s' failed, errno = %d\n",
-                      header->backing_file, errno);
-               err = -errno;
-               goto out_free;
-       }
-
-       err = os_file_size(header->backing_file, size);
-       if(err){
-               printk("Couldn't get size of backing file '%s', errno = %d\n",
-                      header->backing_file, -*size);
-               goto out_free;
-       }
-
-       header->mtime = htonl(buf.st_mtime);
-       header->size = htonll(*size);
-       header->sectorsize = htonl(sectorsize);
-
-       err = write(fd, header, sizeof(*header));
-       if(err != sizeof(*header)){
-               printk("Write of header to new COW file '%s' failed, "
-                      "errno = %d\n", cow_file, errno);
-               goto out_free;
-       }
-       err = 0;
- out_free:
-       kfree(header);
- out:
-       return(err);
-}
-
 int open_ubd_file(char *file, struct openflags *openflags, 
                  char **backing_file_out, int *bitmap_offset_out, 
                  unsigned long *bitmap_len_out, int *data_offset_out, 
@@ -334,26 +110,36 @@ int open_ubd_file(char *file, struct openflags *openflags,
 {
        time_t mtime;
        __u64 size;
+       __u32 version, align;
        char *backing_file;
-        int fd, err, sectorsize, magic, same, mode = 0644;
+       int fd, err, sectorsize, same, mode = 0644;
 
-        if((fd = os_open_file(file, *openflags, mode)) < 0){
+       fd = os_open_file(file, *openflags, mode);
+       if(fd < 0){
                if((fd == -ENOENT) && (create_cow_out != NULL))
                        *create_cow_out = 1;
                 if(!openflags->w ||
                    ((errno != EROFS) && (errno != EACCES))) return(-errno);
                openflags->w = 0;
-                if((fd = os_open_file(file, *openflags, mode)) < 0) 
+               fd = os_open_file(file, *openflags, mode); 
+               if(fd < 0) 
                        return(fd);
         }
+
+       err = os_lock_file(fd, openflags->w);
+       if(err < 0){
+               printk("Failed to lock '%s', err = %d\n", file, -err);
+               goto out_close;
+       }
+       
        if(backing_file_out == NULL) return(fd);
 
-       err = read_cow_header(fd, &magic, &backing_file, &mtime, &size, 
-                             &sectorsize, bitmap_offset_out);
+       err = read_cow_header(file_reader, &fd, &version, &backing_file, &mtime,
+                             &size, &sectorsize, &align, bitmap_offset_out);
        if(err && (*backing_file_out != NULL)){
                printk("Failed to read COW header from COW file \"%s\", "
-                      "errno = %d\n", file, err);
-               goto error;
+                      "errno = %d\n", file, -err);
+               goto out_close;
        }
        if(err) return(fd);
 
@@ -363,36 +149,33 @@ int open_ubd_file(char *file, struct openflags *openflags,
 
        if(!same && !backing_file_mismatch(*backing_file_out, size, mtime)){
                printk("Switching backing file to '%s'\n", *backing_file_out);
-               err = write_cow_header(file, fd, *backing_file_out, 
-                                      sectorsize, &size);
+               err = write_cow_header(file, fd, *backing_file_out,
+                                      sectorsize, align, &size);
                if(err){
-                       printk("Switch failed, errno = %d\n", err);
+                       printk("Switch failed, errno = %d\n", -err);
                        return(err);
                }
        }
        else {
                *backing_file_out = backing_file;
                err = backing_file_mismatch(*backing_file_out, size, mtime);
-               if(err) goto error;
+               if(err) goto out_close;
        }
 
-       sizes(size, sectorsize, *bitmap_offset_out, bitmap_len_out, 
-             data_offset_out);
+       cow_sizes(version, size, sectorsize, align, *bitmap_offset_out, 
+                 bitmap_len_out, data_offset_out);
 
         return(fd);
error:
-       close(fd);
out_close:
+       os_close_file(fd);
        return(err);
 }
 
 int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
-                   int sectorsize, int *bitmap_offset_out, 
+                   int sectorsize, int alignment, int *bitmap_offset_out, 
                    unsigned long *bitmap_len_out, int *data_offset_out)
 {
-       __u64 blocks;
-       long zero;
-       int err, fd, i;
-       long long size;
+       int err, fd;
 
        flags.c = 1;
        fd = open_ubd_file(cow_file, &flags, NULL, NULL, NULL, NULL, NULL);
@@ -403,57 +186,50 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
                goto out;
        }
 
-       err = write_cow_header(cow_file, fd, backing_file, sectorsize, &size);
-       if(err) goto out_close;
-
-       blocks = (size + sectorsize - 1) / sectorsize;
-       blocks = (blocks + sizeof(long) * 8 - 1) / (sizeof(long) * 8);
-       zero = 0;
-       for(i = 0; i < blocks; i++){
-               err = write(fd, &zero, sizeof(zero));
-               if(err != sizeof(zero)){
-                       printk("Write of bitmap to new COW file '%s' failed, "
-                              "errno = %d\n", cow_file, errno);
-                       goto out_close;
-               }
-       }
-
-       sizes(size, sectorsize, sizeof(struct cow_header_v2), 
-             bitmap_len_out, data_offset_out);
-       *bitmap_offset_out = sizeof(struct cow_header_v2);
-
-       return(fd);
+       err = init_cow_file(fd, cow_file, backing_file, sectorsize, alignment,
+                           bitmap_offset_out, bitmap_len_out, 
+                           data_offset_out);
+       if(!err)
+               return(fd);
 
- out_close:
-       close(fd);
+       os_close_file(fd);
  out:
        return(err);
 }
 
+/* XXX Just trivial wrappers around os_read_file and os_write_file */
 int read_ubd_fs(int fd, void *buffer, int len)
 {
-       int n;
-
-       n = read(fd, buffer, len);
-       if(n < 0) return(-errno);
-       else return(n);
+       return(os_read_file(fd, buffer, len));
 }
 
 int write_ubd_fs(int fd, char *buffer, int len)
 {
-       int n;
-
-       n = write(fd, buffer, len);
-       if(n < 0) return(-errno);
-       else return(n);
+       return(os_write_file(fd, buffer, len));
 }
 
-int ubd_is_dir(char *file)
+static int update_bitmap(struct io_thread_req *req)
 {
-       struct stat64 buf;
+       int n;
+
+       if(req->cow_offset == -1)
+               return(0);
+
+       n = os_seek_file(req->fds[1], req->cow_offset);
+       if(n < 0){
+               printk("do_io - bitmap lseek failed : err = %d\n", -n);
+               return(1);
+       }
 
-       if(stat64(file, &buf) < 0) return(0);
-       return(S_ISDIR(buf.st_mode));
+       n = os_write_file(req->fds[1], &req->bitmap_words,
+                         sizeof(req->bitmap_words));
+       if(n != sizeof(req->bitmap_words)){
+               printk("do_io - bitmap update failed, err = %d fd = %d\n", -n,
+                      req->fds[1]);
+               return(1);
+       }
+
+       return(0);
 }
 
 void do_io(struct io_thread_req *req)
@@ -461,8 +237,18 @@ void do_io(struct io_thread_req *req)
        char *buf;
        unsigned long len;
        int n, nsectors, start, end, bit;
+       int err;
        __u64 off;
 
+       if(req->op == UBD_MMAP){
+               /* Touch the page to force the host to do any necessary IO to 
+                * get it into memory 
+                */
+               n = *((volatile int *) req->buffer);
+               req->error = update_bitmap(req);
+               return;
+       }
+
        nsectors = req->length / req->sectorsize;
        start = 0;
        do {
@@ -473,15 +259,14 @@ void do_io(struct io_thread_req *req)
                                    &req->sector_mask) == bit))
                        end++;
 
-               if(end != nsectors)
-                       printk("end != nsectors\n");
                off = req->offset + req->offsets[bit] + 
                        start * req->sectorsize;
                len = (end - start) * req->sectorsize;
                buf = &req->buffer[start * req->sectorsize];
 
-               if(os_seek_file(req->fds[bit], off) != 0){
-                       printk("do_io - lseek failed : errno = %d\n", errno);
+               err = os_seek_file(req->fds[bit], off);
+               if(err < 0){
+                       printk("do_io - lseek failed : err = %d\n", -err);
                        req->error = 1;
                        return;
                }
@@ -490,11 +275,10 @@ void do_io(struct io_thread_req *req)
                        do {
                                buf = &buf[n];
                                len -= n;
-                               n = read(req->fds[bit], buf, len);
+                               n = os_read_file(req->fds[bit], buf, len);
                                if (n < 0) {
-                                       printk("do_io - read returned %d : "
-                                              "errno = %d fd = %d\n", n,
-                                              errno, req->fds[bit]);
+                                       printk("do_io - read failed, err = %d "
+                                              "fd = %d\n", -n, req->fds[bit]);
                                        req->error = 1;
                                        return;
                                }
@@ -502,11 +286,10 @@ void do_io(struct io_thread_req *req)
                        if (n < len) memset(&buf[n], 0, len - n);
                }
                else {
-                       n = write(req->fds[bit], buf, len);
+                       n = os_write_file(req->fds[bit], buf, len);
                        if(n != len){
-                               printk("do_io - write returned %d : "
-                                      "errno = %d fd = %d\n", n, 
-                                      errno, req->fds[bit]);
+                               printk("do_io - write failed err = %d "
+                                      "fd = %d\n", -n, req->fds[bit]);
                                req->error = 1;
                                return;
                        }
@@ -515,24 +298,7 @@ void do_io(struct io_thread_req *req)
                start = end;
        } while(start < nsectors);
 
-       if(req->cow_offset != -1){
-               if(os_seek_file(req->fds[1], req->cow_offset) != 0){
-                       printk("do_io - bitmap lseek failed : errno = %d\n",
-                              errno);
-                       req->error = 1;
-                       return;
-               }
-               n = write(req->fds[1], &req->bitmap_words, 
-                         sizeof(req->bitmap_words));
-               if(n != sizeof(req->bitmap_words)){
-                       printk("do_io - bitmap update returned %d : "
-                              "errno = %d fd = %d\n", n, errno, req->fds[1]);
-                       req->error = 1;
-                       return;
-               }
-       }
-       req->error = 0;
-       return;
+       req->error = update_bitmap(req);
 }
 
 /* Changed in start_io_thread, which is serialized by being called only
@@ -550,19 +316,23 @@ int io_thread(void *arg)
 
        signal(SIGWINCH, SIG_IGN);
        while(1){
-               n = read(kernel_fd, &req, sizeof(req));
-               if(n < 0) printk("io_thread - read returned %d, errno = %d\n",
-                                n, errno);
-               else if(n < sizeof(req)){
-                       printk("io_thread - short read : length = %d\n", n);
+               n = os_read_file(kernel_fd, &req, sizeof(req));
+               if(n != sizeof(req)){
+                       if(n < 0)
+                               printk("io_thread - read failed, fd = %d, "
+                                      "err = %d\n", kernel_fd, -n);
+                       else {
+                               printk("io_thread - short read, fd = %d, "
+                                      "length = %d\n", kernel_fd, n);
+                       }
                        continue;
                }
                io_count++;
                do_io(&req);
-               n = write(kernel_fd, &req, sizeof(req));
+               n = os_write_file(kernel_fd, &req, sizeof(req));
                if(n != sizeof(req))
-                       printk("io_thread - write failed, errno = %d\n",
-                              errno);
+                       printk("io_thread - write failed, fd = %d, err = %d\n",
+                              kernel_fd, -n);
        }
 }
 
@@ -571,10 +341,11 @@ int start_io_thread(unsigned long sp, int *fd_out)
        int pid, fds[2], err;
 
        err = os_pipe(fds, 1, 1);
-       if(err){
-               printk("start_io_thread - os_pipe failed, errno = %d\n", -err);
-               return(-1);
+       if(err < 0){
+               printk("start_io_thread - os_pipe failed, err = %d\n", -err);
+               goto out;
        }
+
        kernel_fd = fds[0];
        *fd_out = fds[1];
 
@@ -582,32 +353,19 @@ int start_io_thread(unsigned long sp, int *fd_out)
                    NULL);
        if(pid < 0){
                printk("start_io_thread - clone failed : errno = %d\n", errno);
-               return(-errno);
-       }
-       return(pid);
-}
-
-#ifdef notdef
-int start_io_thread(unsigned long sp, int *fd_out)
-{
-       int pid;
-
-       if((kernel_fd = get_pty()) < 0) return(-1);
-       raw(kernel_fd, 0);
-       if((*fd_out = open(ptsname(kernel_fd), O_RDWR)) < 0){
-               printk("Couldn't open tty for IO\n");
-               return(-1);
+               goto out_close;
        }
 
-       pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
-                   NULL);
-       if(pid < 0){
-               printk("start_io_thread - clone failed : errno = %d\n", errno);
-               return(-errno);
-       }
        return(pid);
+
+ out_close:
+       os_close_file(fds[0]);
+       os_close_file(fds[1]);
+       kernel_fd = -1;
+       *fd_out = -1;
+ out:
+       return(err);
 }
-#endif
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
index 59c4ba8..f417b3b 100644 (file)
@@ -8,7 +8,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <termios.h>
 #include <signal.h>
 #include <sched.h>
@@ -36,7 +35,8 @@ void *xterm_init(char *str, int device, struct chan_opts *opts)
 {
        struct xterm_chan *data;
 
-       if((data = malloc(sizeof(*data))) == NULL) return(NULL);
+       data = malloc(sizeof(*data));
+       if(data == NULL) return(NULL);
        *data = ((struct xterm_chan) { .pid             = -1, 
                                       .helper_pid      = -1,
                                       .device          = device, 
@@ -83,6 +83,7 @@ __uml_setup("xterm=", xterm_setup,
 "    are 'xterm=gnome-terminal,-t,-x'.\n\n"
 );
 
+/* XXX This badly needs some cleaning up in the error paths */
 int xterm_open(int input, int output, int primary, void *d, char **dev_out)
 {
        struct xterm_chan *data = d;
@@ -93,7 +94,7 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out)
                         "/usr/lib/uml/port-helper", "-uml-socket",
                         file, NULL };
 
-       if(access(argv[4], X_OK))
+       if(os_access(argv[4], OS_ACC_X_OK) < 0)
                argv[4] = "port-helper";
 
        fd = mkstemp(file);
@@ -106,13 +107,13 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out)
                printk("xterm_open : unlink failed, errno = %d\n", errno);
                return(-errno);
        }
-       close(fd);
+       os_close_file(fd);
 
-       fd = create_unix_socket(file, sizeof(file));
+       fd = os_create_unix_socket(file, sizeof(file), 1);
        if(fd < 0){
                printk("xterm_open : create_unix_socket failed, errno = %d\n", 
                       -fd);
-               return(-fd);
+               return(fd);
        }
 
        sprintf(title, data->title, data->device);
@@ -128,20 +129,32 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out)
        if(data->direct_rcv)
                new = os_rcv_fd(fd, &data->helper_pid);
        else {
-               if((err = os_set_fd_block(fd, 0)) != 0){
+               err = os_set_fd_block(fd, 0);
+               if(err < 0){
                        printk("xterm_open : failed to set descriptor "
-                              "non-blocking, errno = %d\n", err);
+                              "non-blocking, err = %d\n", -err);
                        return(err);
                }
                new = xterm_fd(fd, &data->helper_pid);
        }
        if(new < 0){
-               printk("xterm_open : os_rcv_fd failed, errno = %d\n", -new);
+               printk("xterm_open : os_rcv_fd failed, err = %d\n", -new);
                goto out;
        }
 
-       tcgetattr(new, &data->tt);
-       if(data->raw) raw(new, 0);
+       CATCH_EINTR(err = tcgetattr(new, &data->tt));
+       if(err){
+               new = err;
+               goto out;
+       }
+
+       if(data->raw){
+               err = raw(new);
+               if(err){
+                       new = err;
+                       goto out;
+               }
+       }
 
        data->pid = pid;
        *dev_out = NULL;
@@ -160,7 +173,7 @@ void xterm_close(int fd, void *d)
        if(data->helper_pid != -1) 
                os_kill_process(data->helper_pid, 0);
        data->helper_pid = -1;
-       close(fd);
+       os_close_file(fd);
 }
 
 void xterm_free(void *d)
index 1b4683f..a94813f 100644 (file)
@@ -5,9 +5,12 @@
 
 #include "linux/errno.h"
 #include "linux/slab.h"
+#include "linux/signal.h"
+#include "linux/interrupt.h"
 #include "asm/semaphore.h"
 #include "asm/irq.h"
 #include "irq_user.h"
+#include "irq_kern.h"
 #include "kern_util.h"
 #include "os.h"
 #include "xterm.h"
@@ -19,17 +22,18 @@ struct xterm_wait {
        int new_fd;
 };
 
-static void xterm_interrupt(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t xterm_interrupt(int irq, void *data, struct pt_regs *regs)
 {
        struct xterm_wait *xterm = data;
        int fd;
 
        fd = os_rcv_fd(xterm->fd, &xterm->pid);
        if(fd == -EAGAIN)
-               return;
+               return(IRQ_NONE);
 
        xterm->new_fd = fd;
        up(&xterm->sem);
+       return(IRQ_HANDLED);
 }
 
 int xterm_fd(int socket, int *pid_out)
@@ -54,7 +58,8 @@ int xterm_fd(int socket, int *pid_out)
        if(err){
                printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
                       "err = %d\n",  err);
-               return(err);
+               ret = err;
+               goto out;
        }
        down(&data->sem);
 
@@ -62,6 +67,7 @@ int xterm_fd(int socket, int *pid_out)
 
        ret = data->new_fd;
        *pid_out = data->pid;
+ out:
        kfree(data);
 
        return(ret);
index 361d930..a331e2b 100644 (file)
@@ -1,21 +1,23 @@
+#include <asm-generic/vmlinux.lds.h>
+
 OUTPUT_FORMAT(ELF_FORMAT)
 OUTPUT_ARCH(ELF_ARCH)
 ENTRY(_start)
 jiffies = jiffies_64;
 
-SEARCH_DIR("/usr/local/i686-pc-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
-/* Do we need any of these for elf?
-   __DYNAMIC = 0;    */
 SECTIONS
 {
   . = START + SIZEOF_HEADERS;
   .interp         : { *(.interp) }
-  . = ALIGN(4096);
   __binary_start = .;
   . = ALIGN(4096);             /* Init code and data */
   _stext = .;
   __init_begin = .;
-  .text.init : { *(.text.init) }
+  .init.text : { 
+       _sinittext = .;
+       *(.init.text)
+       _einittext = .;
+  }
 
   . = ALIGN(4096);
 
@@ -55,7 +57,9 @@ SECTIONS
   } =0x90909090
   .plt            : { *(.plt) }
   .text           : {
-    *(.text .stub .text.* .gnu.linkonce.t.*)
+    *(.text)
+    SCHED_TEXT
+    *(.stub .text.* .gnu.linkonce.t.*)
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
   } =0x90909090
@@ -67,7 +71,7 @@ SECTIONS
 
   #include "asm/common.lds.S"
 
-  .data.init : { *(.data.init) }
+  init.data : { *(.init.data) }
 
   /* Ensure the __preinit_array_start label is properly aligned.  We
      could instead move the label definition inside the section, but
index 6d36d9c..abdb015 100644 (file)
@@ -6,20 +6,6 @@
 #ifndef __2_5_COMPAT_H__
 #define __2_5_COMPAT_H__
 
-#include "linux/version.h"
-
-#define INIT_CONSOLE(dev_name, write_proc, device_proc, setup_proc, f) { \
-       name :          dev_name, \
-       write :         write_proc, \
-       read :          NULL, \
-       device :        device_proc, \
-       setup :         setup_proc, \
-       flags :         f, \
-       index :         -1, \
-       cflag :         0, \
-       next :          NULL \
-}
-
 #define INIT_HARDSECT(arr, maj, sizes)
 
 #define SET_PRI(task) do ; while(0)
index f1d82e0..52c393f 100644 (file)
@@ -100,6 +100,16 @@ extern struct uml_param __uml_setup_start, __uml_setup_end;
 #define __uml_postsetup_call   __attribute__ ((unused,__section__ (".uml.postsetup.init")))
 #define __uml_exit_call                __attribute__ ((unused,__section__ (".uml.exitcall.exit")))
 
+#ifndef __KERNEL__
+
+#define __initcall(fn) static initcall_t __initcall_##fn __init_call = fn
+#define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn
+
+#define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
+#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit")))
+
+#endif
+
 #endif /* _LINUX_UML_INIT_H */
 
 /*
diff --git a/arch/um/include/irq_kern.h b/arch/um/include/irq_kern.h
deleted file mode 100644 (file)
index 4bcb829..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* 
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __IRQ_KERN_H__
-#define __IRQ_KERN_H__
-
-#include "linux/interrupt.h"
-
-extern int um_request_irq(unsigned int irq, int fd, int type,
-                         irqreturn_t (*handler)(int, void *, 
-                                                struct pt_regs *),
-                         unsigned long irqflags,  const char * devname,
-                         void *dev_id);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 087bd39..0df4076 100644 (file)
@@ -14,6 +14,7 @@ extern void free_irq_by_irq_and_dev(int irq, void *dev_id);
 extern void free_irq_by_fd(int fd);
 extern void reactivate_fd(int fd, int irqnum);
 extern void deactivate_fd(int fd, int irqnum);
+extern int deactivate_all_fds(void);
 extern void forward_interrupts(int pid);
 extern void init_irq_signals(int on_sigstack);
 extern void forward_ipi(int fd, int pid);
index 09e76a3..eace6b2 100644 (file)
@@ -60,12 +60,11 @@ extern void finish_fork(void);
 extern void paging_init(void);
 extern void init_flush_vm(void);
 extern void *syscall_sp(void *t);
-extern void syscall_trace(void);
+extern void syscall_trace(union uml_pt_regs *regs, int entryexit);
 extern int hz(void);
-extern void idle_timer(void);
+extern void uml_idle_timer(void);
 extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
 extern int external_pid(void *t);
-extern int pid_to_processor_id(int pid);
 extern void boot_timer_handler(int sig);
 extern void interrupt_end(void);
 extern void initial_thread_cb(void (*proc)(void *), void *arg);
@@ -89,9 +88,7 @@ extern int remove_gdb(void);
 extern char *uml_strdup(char *string);
 extern void unprotect_kernel_mem(void);
 extern void protect_kernel_mem(void);
-extern void set_kmem_end(unsigned long);
 extern void uml_cleanup(void);
-extern int pid_to_processor_id(int pid);
 extern void set_current(void *t);
 extern void lock_signalled_task(void *t);
 extern void IPI_handler(int cpu);
@@ -100,7 +97,9 @@ extern void *get_init_task(void);
 extern int clear_user_proc(void *buf, int size);
 extern int copy_to_user_proc(void *to, void *from, int size);
 extern int copy_from_user_proc(void *to, void *from, int size);
+extern int strlen_user_proc(char *str);
 extern void bus_handler(int sig, union uml_pt_regs *regs);
+extern void winch(int sig, union uml_pt_regs *regs);
 extern long execute_syscall(void *r);
 extern int smp_sigio_handler(void);
 extern void *get_current(void);
@@ -111,6 +110,8 @@ extern void arch_switch(void);
 extern void free_irq(unsigned int, void *);
 extern int um_in_interrupt(void);
 extern int cpu(void);
+extern unsigned long long time_stamp(void);
+
 #endif
 
 /*
index e9783dc..3191132 100644 (file)
@@ -9,12 +9,14 @@
 #include "linux/list.h"
 #include "linux/workqueue.h"
 #include "linux/tty.h"
+#include "linux/interrupt.h"
 #include "asm/semaphore.h"
 #include "chan_user.h"
 #include "mconsole_kern.h"
 
 struct line_driver {
        char *name;
+       char *device_name;
        char *devfs_name;
        short major;
        short minor_start;
@@ -67,8 +69,6 @@ struct lines {
 
 #define LINES_INIT(n) {  num :         n }
 
-extern void line_interrupt(int irq, void *data, struct pt_regs *unused);
-extern void line_write_interrupt(int irq, void *data, struct pt_regs *unused);
 extern void line_close(struct line *lines, struct tty_struct *tty);
 extern int line_open(struct line *lines, struct tty_struct *tty, 
                     struct chan_opts *opts);
index 7eea2fa..9fbe308 100644 (file)
@@ -41,11 +41,13 @@ struct mconsole_notify {
 
 struct mc_request;
 
+enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC };
+
 struct mconsole_command
 {
        char *command;
        void (*handler)(struct mc_request *req);
-       int as_interrupt;
+       enum mc_context context;
 };
 
 struct mc_request
@@ -77,6 +79,8 @@ extern void mconsole_sysrq(struct mc_request *req);
 extern void mconsole_cad(struct mc_request *req);
 extern void mconsole_stop(struct mc_request *req);
 extern void mconsole_go(struct mc_request *req);
+extern void mconsole_log(struct mc_request *req);
+extern void mconsole_proc(struct mc_request *req);
 
 extern int mconsole_get_request(int fd, struct mc_request *req);
 extern int mconsole_notify(char *sock_name, int type, const void *data, 
index bad6b30..7d3bc63 100644 (file)
@@ -1,19 +1,18 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002, 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
 #ifndef __MEM_H__
 #define __MEM_H__
 
-struct vm_reserved {
-       struct list_head list;
-       unsigned long start;
-       unsigned long end;
-};
+#include "linux/types.h"
 
-extern void set_usable_vm(unsigned long start, unsigned long end);
-extern void set_kmem_end(unsigned long new);
+extern int phys_mapping(unsigned long phys, __u64 *offset_out);
+extern int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w);
+extern int is_remapped(const void *virt, int fd, __u64 offset);
+extern int physmem_remove_mapping(void *virt);
+extern void physmem_forget_descriptor(int fd);
 
 #endif
 
diff --git a/arch/um/include/mem_kern.h b/arch/um/include/mem_kern.h
deleted file mode 100644 (file)
index b39f03d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* 
- * Copyright (C) 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#ifndef __MEM_KERN_H__
-#define __MEM_KERN_H__
-
-#include "linux/list.h"
-#include "linux/types.h"
-
-struct remapper {
-       struct list_head list;
-       int (*proc)(int, unsigned long, int, __u64);
-};
-
-extern void register_remapper(struct remapper *info);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index d80ac35..fe0c298 100644 (file)
 #ifndef _MEM_USER_H
 #define _MEM_USER_H
 
-struct mem_region {
+struct iomem_region {
+       struct iomem_region *next;
        char *driver;
-       unsigned long start_pfn;
-       unsigned long start;
-       unsigned long len;
-       void *mem_map;
        int fd;
+       int size;
+       unsigned long phys;
+       unsigned long virt;
 };
 
-extern struct mem_region *regions[];
-extern struct mem_region physmem_region;
+extern struct iomem_region *iomem_regions;
+extern int iomem_size;
 
 #define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1))
 
 extern unsigned long host_task_size;
 extern unsigned long task_size;
 
+extern void check_devanon(void);
 extern int init_mem_user(void);
 extern int create_mem_file(unsigned long len);
-extern void setup_range(int fd, char *driver, unsigned long start,
-                       unsigned long pfn, unsigned long total, int need_vm, 
-                       struct mem_region *region, void *reserved);
 extern void setup_memory(void *entry);
 extern unsigned long find_iomem(char *driver, unsigned long *len_out);
-extern int init_maps(struct mem_region *region);
-extern int nregions(void);
-extern int reserve_vm(unsigned long start, unsigned long end, void *e);
+extern int init_maps(unsigned long physmem, unsigned long iomem, 
+                    unsigned long highmem);
 extern unsigned long get_vm(unsigned long len);
 extern void setup_physmem(unsigned long start, unsigned long usable,
-                         unsigned long len);
-extern int setup_region(struct mem_region *region, void *entry);
+                         unsigned long len, unsigned long highmem);
 extern void add_iomem(char *name, int fd, unsigned long size);
-extern struct mem_region *phys_region(unsigned long phys);
 extern unsigned long phys_offset(unsigned long phys);
 extern void unmap_physmem(void);
-extern int map_memory(unsigned long virt, unsigned long phys, 
-                     unsigned long len, int r, int w, int x);
+extern void map_memory(unsigned long virt, unsigned long phys, 
+                      unsigned long len, int r, int w, int x);
 extern int protect_memory(unsigned long addr, unsigned long len, 
                          int r, int w, int x, int must_succeed);
 extern unsigned long get_kmem_end(void);
index b9b1f0c..08a174e 100644 (file)
 #define OS_TYPE_FIFO 6
 #define OS_TYPE_SOCK 7
 
+/* os_access() flags */
+#define OS_ACC_F_OK    0       /* Test for existence.  */
+#define OS_ACC_X_OK    1       /* Test for execute permission.  */
+#define OS_ACC_W_OK    2       /* Test for write permission.  */
+#define OS_ACC_R_OK    4       /* Test for read permission.  */
+#define OS_ACC_RW_OK   (OS_ACC_W_OK | OS_ACC_R_OK) /* Test for RW permission */
+
+/*
+ * types taken from stat_file() in hostfs_user.c
+ * (if they are wrong here, they are wrong there...).
+ */
+struct uml_stat {
+       int                ust_major;      /* device */
+       int                ust_minor;
+       unsigned long long ust_ino;        /* inode */
+       int                ust_mode;       /* protection */
+       int                ust_nlink;      /* number of hard links */
+       int                ust_uid;        /* user ID of owner */
+       int                ust_gid;        /* group ID of owner */
+       unsigned long long ust_size;       /* total size, in bytes */
+       int                ust_blksize;    /* blocksize for filesystem I/O */
+       unsigned long long ust_blocks;     /* number of blocks allocated */
+       unsigned long      ust_atime;      /* time of last access */
+       unsigned long      ust_mtime;      /* time of last modification */
+       unsigned long      ust_ctime;      /* time of last change */
+       int                ust_rmajor;
+       int                ust_rminor;
+};
+
 struct openflags {
        unsigned int r : 1;
        unsigned int w : 1;
@@ -26,10 +55,12 @@ struct openflags {
        unsigned int a : 1;     /* O_APPEND */
        unsigned int e : 1;     /* O_EXCL */
        unsigned int cl : 1;    /* FD_CLOEXEC */
+       unsigned int d : 1;     /* O_DIRECT */
 };
 
 #define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \
-                                         .t = 0, .a = 0, .e = 0, .cl = 0 })
+                                         .t = 0, .a = 0, .e = 0, .cl = 0, \
+                                         .d = 0 })
 
 static inline struct openflags of_read(struct openflags flags)
 {
@@ -84,29 +115,76 @@ static inline struct openflags of_excl(struct openflags flags)
        flags.e = 1; 
        return(flags); 
 }
+
 static inline struct openflags of_cloexec(struct openflags flags)
 { 
        flags.cl = 1; 
        return(flags); 
 }
   
+static inline struct openflags of_direct(struct openflags flags)
+{ 
+       flags.d = 1; 
+       return(flags); 
+}
+
+extern int os_stat_file(const char *file_name, struct uml_stat *buf);
+extern int os_lstat_file(const char *file_name, struct uml_stat *ubuf);
+extern int os_stat_fd(const int fd, struct uml_stat *buf);
+extern int os_access(const char *file, int mode);
+extern int os_set_file_time(const char *file, unsigned long access, 
+                           unsigned long mod);
+extern int os_set_file_perms(const char *file, int mode);
+extern int os_set_file_owner(const char *file, int owner, int group);
+extern void os_print_error(int error, const char* str);
+extern int os_get_exec_close(int fd, int *close_on_exec);
+extern int os_set_exec_close(int fd, int close_on_exec);
+extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
+extern int os_window_size(int fd, int *rows, int *cols);
+extern int os_new_tty_pgrp(int fd, int pid);
+extern int os_get_ifname(int fd, char *namebuf);
+extern int os_set_slip(int fd);
+extern int os_set_owner(int fd, int pid);
+extern int os_sigio_async(int master, int slave);
+extern int os_mode_fd(int fd, int mode);
+
 extern int os_seek_file(int fd, __u64 offset);
 extern int os_open_file(char *file, struct openflags flags, int mode);
+extern void *os_open_dir(char *dir, int *err_out);
+extern int os_seek_dir(void *stream, unsigned long long pos);
+extern int os_read_dir(void *stream, unsigned long long *ino_out, 
+                      char **name_out);
+extern int os_tell_dir(void *stream);
+extern int os_close_dir(void *stream);
+extern int os_remove_file(const char *file);
+extern int os_move_file(const char *from, const char *to);
+extern int os_truncate_file(const char *file, unsigned long long len);
+extern int os_truncate_fd(int fd, unsigned long long len);
 extern int os_read_file(int fd, void *buf, int len);
-extern int os_write_file(int fd, void *buf, int count);
+extern int os_write_file(int fd, const void *buf, int count);
 extern int os_file_size(char *file, long long *size_out);
+extern int os_fd_size(int fd, long long *size_out);
+extern int os_file_modtime(char *file, unsigned long *modtime);
 extern int os_pipe(int *fd, int stream, int close_on_exec);
 extern int os_set_fd_async(int fd, int owner);
+extern int os_clear_fd_async(int fd);
 extern int os_set_fd_block(int fd, int blocking);
 extern int os_accept_connection(int fd);
+extern int os_create_unix_socket(char *file, int len, int close_on_exec);
+extern int os_make_symlink(const char *to, const char *from);
+extern int os_read_symlink(const char *file, char *buf, int size);
+extern int os_link_file(const char *to, const char *from);
+extern int os_make_dir(const char *dir, int mode);
+extern int os_remove_dir(const char *dir);
+extern int os_make_dev(const char *name, int mode, int major, int minor);
 extern int os_shutdown_socket(int fd, int r, int w);
 extern void os_close_file(int fd);
 extern int os_rcv_fd(int fd, int *helper_pid_out);
-extern int create_unix_socket(char *file, int len);
+extern int create_unix_socket(char *file, int len, int close_on_exec);
 extern int os_connect_socket(char *name);
 extern int os_file_type(char *file);
 extern int os_file_mode(char *file, struct openflags *mode_out);
+extern int os_lock_file(int fd, int excl);
 
 extern unsigned long os_process_pc(int pid);
 extern int os_process_parent(int pid);
@@ -115,11 +193,19 @@ extern void os_kill_process(int pid, int reap_child);
 extern void os_usr1_process(int pid);
 extern int os_getpid(void);
 
-extern int os_map_memory(void *virt, int fd, unsigned long off, 
+extern int os_map_memory(void *virt, int fd, unsigned long long off, 
                         unsigned long len, int r, int w, int x);
 extern int os_protect_memory(void *addr, unsigned long len, 
                             int r, int w, int x);
 extern int os_unmap_memory(void *addr, int len);
+extern void os_flush_stdout(void);
+extern int os_stat_filesystem(char *path, long *bsize_out, 
+                             long long *blocks_out, long long *bfree_out,
+                             long long *bavail_out, long long *files_out,
+                             long long *ffree_out, void *fsid_out, 
+                             int fsid_size, long *namelen_out, 
+                             long *spare_out);
+extern unsigned long long os_usecs(void);
 
 #endif
 
index adaea4d..b075e54 100644 (file)
@@ -11,6 +11,8 @@ extern int signal_stack_size;
 extern int change_sig(int signal, int on);
 extern void set_sigstack(void *stack, int size);
 extern void set_handler(int sig, void (*handler)(int), int flags, ...);
+extern int set_signals(int enable);
+extern int get_signals(void);
 
 #endif
 
index 7cd983d..cfb5fb4 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
 
index d1ca652..bac91c1 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef __UM_SYSDEP_CHECKSUM_H
 #define __UM_SYSDEP_CHECKSUM_H
 
+#include "linux/in6.h"
 #include "linux/string.h"
 
 /*
index b4065b2..13faf07 100644 (file)
@@ -56,26 +56,26 @@ static inline void setup_arch_frame(struct arch_frame_data_raw *in,
  * it would have to be __builtin_frame_address(1).
  */
 
-static inline unsigned long frame_restorer(void)
-{
-       unsigned long *fp;
-
-       fp = __builtin_frame_address(0);
-       return((unsigned long) (fp + 1));
-}
+#define frame_restorer() \
+({ \
+       unsigned long *fp; \
+\
+       fp = __builtin_frame_address(0); \
+       ((unsigned long) (fp + 1)); \
+})
 
 /* Similarly, this returns the value of sp when the handler was first
  * entered.  This is used to calculate the proper sp when delivering
  * signals.
  */
 
-static inline unsigned long frame_sp(void)
-{
-       unsigned long *fp;
-
-       fp = __builtin_frame_address(0);
-       return((unsigned long) (fp + 1));
-}
+#define frame_sp() \
+({ \
+       unsigned long *fp; \
+\
+       fp = __builtin_frame_address(0); \
+       ((unsigned long) (fp + 1)); \
+})
 
 #endif
 
index 26c70cf..887fdb6 100644 (file)
@@ -28,8 +28,8 @@
  */
 #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
 
-/* These are General Protection and Page Fault */
-#define SEGV_IS_FIXABLE(trap) ((trap == 13) || (trap == 14))
+/* This is Page Fault */
+#define SEGV_IS_FIXABLE(trap) (trap == 14)
 
 #define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc)))
 
index 08d7c13..4ab66ae 100644 (file)
@@ -11,39 +11,34 @@ typedef long syscall_handler_t(struct pt_regs);
 #define EXECUTE_SYSCALL(syscall, regs) \
        ((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(&regs->regs))
 
-extern syscall_handler_t sys_modify_ldt;
-extern syscall_handler_t old_mmap_i386;
-extern syscall_handler_t old_select;
-extern syscall_handler_t sys_ni_syscall;
-
 #define ARCH_SYSCALLS \
-       [ __NR_mmap ] = old_mmap_i386, \
-       [ __NR_select ] = old_select, \
-       [ __NR_vm86old ] = sys_ni_syscall, \
-        [ __NR_modify_ldt ] = sys_modify_ldt, \
-       [ __NR_lchown32 ] = sys_lchown, \
-       [ __NR_getuid32 ] = sys_getuid, \
-       [ __NR_getgid32 ] = sys_getgid, \
-       [ __NR_geteuid32 ] = sys_geteuid, \
-       [ __NR_getegid32 ] = sys_getegid, \
-       [ __NR_setreuid32 ] = sys_setreuid, \
-       [ __NR_setregid32 ] = sys_setregid, \
-       [ __NR_getgroups32 ] = sys_getgroups, \
-       [ __NR_setgroups32 ] = sys_setgroups, \
-       [ __NR_fchown32 ] = sys_fchown, \
-       [ __NR_setresuid32 ] = sys_setresuid, \
-       [ __NR_getresuid32 ] = sys_getresuid, \
-       [ __NR_setresgid32 ] = sys_setresgid, \
-       [ __NR_getresgid32 ] = sys_getresgid, \
-       [ __NR_chown32 ] = sys_chown, \
-       [ __NR_setuid32 ] = sys_setuid, \
-       [ __NR_setgid32 ] = sys_setgid, \
-       [ __NR_setfsuid32 ] = sys_setfsuid, \
-       [ __NR_setfsgid32 ] = sys_setfsgid, \
-       [ __NR_pivot_root ] = sys_pivot_root, \
-       [ __NR_mincore ] = sys_mincore, \
-       [ __NR_madvise ] = sys_madvise, \
-        [ 222 ] = sys_ni_syscall, 
+       [ __NR_mmap ] = (syscall_handler_t *) old_mmap_i386, \
+       [ __NR_select ] = (syscall_handler_t *) old_select, \
+       [ __NR_vm86old ] = (syscall_handler_t *) sys_ni_syscall, \
+        [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \
+       [ __NR_lchown32 ] = (syscall_handler_t *) sys_lchown, \
+       [ __NR_getuid32 ] = (syscall_handler_t *) sys_getuid, \
+       [ __NR_getgid32 ] = (syscall_handler_t *) sys_getgid, \
+       [ __NR_geteuid32 ] = (syscall_handler_t *) sys_geteuid, \
+       [ __NR_getegid32 ] = (syscall_handler_t *) sys_getegid, \
+       [ __NR_setreuid32 ] = (syscall_handler_t *) sys_setreuid, \
+       [ __NR_setregid32 ] = (syscall_handler_t *) sys_setregid, \
+       [ __NR_getgroups32 ] = (syscall_handler_t *) sys_getgroups, \
+       [ __NR_setgroups32 ] = (syscall_handler_t *) sys_setgroups, \
+       [ __NR_fchown32 ] = (syscall_handler_t *) sys_fchown, \
+       [ __NR_setresuid32 ] = (syscall_handler_t *) sys_setresuid, \
+       [ __NR_getresuid32 ] = (syscall_handler_t *) sys_getresuid, \
+       [ __NR_setresgid32 ] = (syscall_handler_t *) sys_setresgid, \
+       [ __NR_getresgid32 ] = (syscall_handler_t *) sys_getresgid, \
+       [ __NR_chown32 ] = (syscall_handler_t *) sys_chown, \
+       [ __NR_setuid32 ] = (syscall_handler_t *) sys_setuid, \
+       [ __NR_setgid32 ] = (syscall_handler_t *) sys_setgid, \
+       [ __NR_setfsuid32 ] = (syscall_handler_t *) sys_setfsuid, \
+       [ __NR_setfsgid32 ] = (syscall_handler_t *) sys_setfsgid, \
+       [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \
+       [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
+       [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
+        [ 222 ] = (syscall_handler_t *) sys_ni_syscall, 
         
 /* 222 doesn't yet have a name in include/asm-i386/unistd.h */
 
index 9ddb749..6793a2f 100644 (file)
@@ -11,6 +11,7 @@ extern void switch_timers(int to_real);
 extern void set_interval(int timer_type);
 extern void idle_sleep(int secs);
 extern void enable_timer(void);
+extern void disable_timer(void);
 extern unsigned long time_lock(void);
 extern void time_unlock(unsigned long);
 
index b28beaf..bddccc0 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "os.h"
 
-enum ubd_req { UBD_READ, UBD_WRITE };
+enum ubd_req { UBD_READ, UBD_WRITE, UBD_MMAP };
 
 struct io_thread_req {
        enum ubd_req op;
@@ -20,8 +20,10 @@ struct io_thread_req {
        char *buffer;
        int sectorsize;
        unsigned long sector_mask;
-       unsigned long cow_offset;
+       unsigned long long cow_offset;
        unsigned long bitmap_words[2];
+       int map_fd;
+       unsigned long long map_offset;
        int error;
 };
 
@@ -31,7 +33,7 @@ extern int open_ubd_file(char *file, struct openflags *openflags,
                         int *create_cow_out);
 extern int create_cow_file(char *cow_file, char *backing_file, 
                           struct openflags flags, int sectorsize, 
-                          int *bitmap_offset_out, 
+                          int alignment, int *bitmap_offset_out, 
                           unsigned long *bitmap_len_out,
                           int *data_offset_out);
 extern int read_cow_bitmap(int fd, void *buf, int offset, int len);
@@ -39,7 +41,6 @@ extern int read_ubd_fs(int fd, void *buffer, int len);
 extern int write_ubd_fs(int fd, char *buffer, int len);
 extern int start_io_thread(unsigned long sp, int *fds_out);
 extern void do_io(struct io_thread_req *req);
-extern int ubd_is_dir(char *file);
 
 static inline int ubd_test_bit(__u64 bit, unsigned char *data)
 {
index 41afa3a..8b36a54 100644 (file)
@@ -38,22 +38,73 @@ static inline int copy_to_user(void *to, const void *from, int n)
                                from, n));
 }
 
+/*
+ * strncpy_from_user: - Copy a NUL terminated string from userspace.
+ * @dst:   Destination address, in kernel space.  This buffer must be at
+ *         least @count bytes long.
+ * @src:   Source address, in user space.
+ * @count: Maximum number of bytes to copy, including the trailing NUL.
+ * 
+ * Copies a NUL-terminated string from userspace to kernel space.
+ *
+ * On success, returns the length of the string (not including the trailing
+ * NUL).
+ *
+ * If access to userspace fails, returns -EFAULT (some data may have been
+ * copied).
+ *
+ * If @count is smaller than the length of the string, copies @count bytes
+ * and returns @count.
+ */
+
 static inline int strncpy_from_user(char *dst, const char *src, int count)
 {
        return(CHOOSE_MODE_PROC(strncpy_from_user_tt, strncpy_from_user_skas,
                                dst, src, count));
 }
 
+/*
+ * __clear_user: - Zero a block of memory in user space, with less checking.
+ * @to:   Destination address, in user space.
+ * @n:    Number of bytes to zero.
+ *
+ * Zero a block of memory in user space.  Caller must check
+ * the specified block with access_ok() before calling this function.
+ *
+ * Returns number of bytes that could not be cleared.
+ * On success, this will be zero.
+ */
 static inline int __clear_user(void *mem, int len)
 {
        return(CHOOSE_MODE_PROC(__clear_user_tt, __clear_user_skas, mem, len));
 }
 
+/*
+ * clear_user: - Zero a block of memory in user space.
+ * @to:   Destination address, in user space.
+ * @n:    Number of bytes to zero.
+ *
+ * Zero a block of memory in user space.
+ *
+ * Returns number of bytes that could not be cleared.
+ * On success, this will be zero.
+ */
 static inline int clear_user(void *mem, int len)
 {
        return(CHOOSE_MODE_PROC(clear_user_tt, clear_user_skas, mem, len));
 }
 
+/*
+ * strlen_user: - Get the size of a string in user space.
+ * @str: The string to measure.
+ * @n:   The maximum valid length
+ *
+ * Get the size of a NUL-terminated string in user space.
+ *
+ * Returns the size of the string INCLUDING the terminating NUL.
+ * On exception, returns 0.
+ * If the string is too long, returns a value greater than @n.
+ */
 static inline int strnlen_user(const void *str, int len)
 {
        return(CHOOSE_MODE_PROC(strnlen_user_tt, strnlen_user_skas, str, len));
index 6f009be..57ee9e2 100644 (file)
@@ -14,6 +14,9 @@ extern void *um_kmalloc_atomic(int size);
 extern void kfree(void *ptr);
 extern int in_aton(char *str);
 extern int open_gdb_chan(void);
+extern int strlcpy(char *, const char *, int);
+extern void *um_vmalloc(int size);
+extern void vfree(void *ptr);
 
 #endif
 
index e87b8fc..ab089d7 100644 (file)
@@ -8,14 +8,14 @@
 
 #include "sysdep/ptrace.h"
 
+#define CATCH_EINTR(expr) while (((expr) < 0) && (errno == EINTR))
+
 extern int mode_tt;
 
 extern int grantpt(int __fd);
 extern int unlockpt(int __fd);
 extern char *ptsname(int __fd);
 
-enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
-
 struct cpu_task {
        int pid;
        void *task;
@@ -59,13 +59,11 @@ extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
 extern void *add_signal_handler(int sig, void (*handler)(int));
 extern int start_fork_tramp(void *arg, unsigned long temp_stack, 
                            int clone_flags, int (*tramp)(void *));
-extern int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags);
 extern int linux_main(int argc, char **argv);
 extern void set_cmdline(char *cmd);
 extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
 extern int get_pty(void);
 extern void *um_kmalloc(int size);
-extern int raw(int fd, int complain);
 extern int switcheroo(int fd, int prot, void *from, void *to, int size);
 extern void setup_machinename(char *machine_out);
 extern void setup_hostinfo(void);
@@ -76,7 +74,6 @@ extern void do_exec(int old_pid, int new_pid);
 extern void tracer_panic(char *msg, ...);
 extern char *get_umid(int only_if_set);
 extern void do_longjmp(void *p, int val);
-extern void suspend_new_thread(int fd);
 extern int detach(int pid, int sig);
 extern int attach(int pid);
 extern void kill_child_dead(int pid);
@@ -86,11 +83,15 @@ extern void check_sigio(void);
 extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
 extern void write_sigio_workaround(void);
 extern void arch_check_bugs(void);
+extern int cpu_feature(char *what, char *buf, int len);
 extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
 extern int arch_fixup(unsigned long address, void *sc_ptr);
 extern void forward_pending_sigio(int target);
 extern int can_do_skas(void);
+extern void arch_init_thread(void);
+extern int setjmp_wrapper(void (*proc)(void *, void *), ...);
+extern int raw(int fd);
+
 #endif
 
 /*
index 0f13dd4..6cce266 100644 (file)
@@ -5,13 +5,18 @@
 
 extra-y := vmlinux.lds.s
 
-obj-y = checksum.o config.o exec_kern.o exitcode.o frame_kern.o frame.o \
-       helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
-       process.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \
-       sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o \
-       syscall_user.o sysrq.o sys_call_table.o tempfile.o time.o \
-       time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \
-       umid.o user_syms.o user_util.o
+# Descend into ../util for make clean.  This is here because it doesn't work
+# in arch/um/Makefile.
+
+subdir- = ../util
+
+obj-y = checksum.o config.o exec_kern.o exitcode.o filehandle.o frame_kern.o \
+       frame.o helper.o init_task.o irq.o irq_user.o ksyms.o mem.o \
+       mem_user.o physmem.o process.o process_kern.o ptrace.o reboot.o \
+       resource.o sigio_user.o sigio_kern.o signal_kern.o signal_user.o \
+       smp.o syscall_kern.o syscall_user.o sysrq.o sys_call_table.o \
+       tempfile.o time.o time_kern.o tlb.o trap_kern.o trap_user.o \
+       uaccess_user.o um_arch.o umid.o user_util.o
 
 obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o
 obj-$(CONFIG_GPROF)    += gprof_syms.o
@@ -24,43 +29,27 @@ obj-$(CONFIG_MODE_SKAS) += skas/
 user-objs-$(CONFIG_TTY_LOG) += tty_log.o
 
 USER_OBJS := $(filter %_user.o,$(obj-y))  $(user-objs-y) config.o helper.o \
-       process.o tempfile.o time.o tty_log.o umid.o user_util.o user_syms.o
+       process.o tempfile.o time.o tty_log.o umid.o user_util.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
-DMODULES-$(CONFIG_MODULES) = -D__CONFIG_MODULES__
-DMODVERSIONS-$(CONFIG_MODVERSIONS) = -D__CONFIG_MODVERSIONS__
-
-
-CFLAGS_user_syms.o = -D__AUTOCONF_INCLUDED__ $(DMODULES-y) $(DMODVERSIONS-y) \
-       -I/usr/include -I../include
-
 CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS))
 
-$(USER_OBJS) : %.o: %.c
-       $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
-
 # This has to be separate because it needs be compiled with frame pointers
 # regardless of how the rest of the kernel is built.
 
 $(obj)/frame.o: $(src)/frame.c
        $(CC) $(CFLAGS_$(notdir $@)) -c -o $@ $<
 
-QUOTE = 'my $$config=`cat $(TOPDIR)/.config`; $$config =~ s/"/\\"/g ; while(<STDIN>) { $$_ =~ s/CONFIG/$$config/; print $$_ }'
+$(USER_OBJS) : %.o: %.c
+       $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
 
-$(obj)/config.c : $(src)/config.c.in $(TOPDIR)/.config
-       $(PERL) -e $(QUOTE) < $(src)/config.c.in > $@
+QUOTE = 'my $$config=`cat $(TOPDIR)/.config`; $$config =~ s/"/\\"/g ; $$config =~ s/\n/\\n"\n"/g ; while(<STDIN>) { $$_ =~ s/CONFIG/$$config/; print $$_ }'
 
 $(obj)/config.o : $(obj)/config.c
 
-clean:
-       rm -f config.c
-       for dir in $(subdir-y) ; do $(MAKE) -C $$dir clean; done
-
-modules:
-
-fastdep:
-
-dep:
-
-archmrproper: clean
+quiet_cmd_quote = QUOTE $@
+cmd_quote = $(PERL) -e $(QUOTE) < $< > $@
 
+targets += config.c
+$(obj)/config.c : $(src)/config.c.in $(TOPDIR)/.config FORCE
+       $(call if_changed,quote)
index f6c96b9..c062cbf 100644 (file)
@@ -7,9 +7,7 @@
 #include <stdlib.h>
 #include "init.h"
 
-static __initdata char *config = "
-CONFIG
-";
+static __initdata char *config = "CONFIG";
 
 static int __init print_config(char *line, int *add)
 {
index a6be6b5..a5f2128 100644 (file)
@@ -32,10 +32,15 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
        CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
 }
 
+extern void log_exec(char **argv, void *tty);
+
 static int execve1(char *file, char **argv, char **env)
 {
         int error;
 
+#ifdef CONFIG_TTY_LOG
+       log_exec(argv, current->tty);
+#endif
         error = do_execve(file, argv, env, &current->thread.regs);
         if (error == 0){
                 current->ptrace &= ~PT_DTRACE;
index d8993f2..4b349f2 100644 (file)
@@ -21,6 +21,7 @@
 #include "sysdep/sigcontext.h"
 #include "frame_user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "ptrace_user.h"
 #include "os.h"
 
@@ -40,7 +41,7 @@ static int capture_stack(int (*child)(void *arg), void *arg, void *sp,
        /* Wait for it to stop itself and continue it with a SIGUSR1 to force 
         * it into the signal handler.
         */
-       n = waitpid(pid, &status, WUNTRACED);
+       CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if(n < 0){
                printf("capture_stack : waitpid failed - errno = %d\n", errno);
                exit(1);
@@ -60,7 +61,7 @@ static int capture_stack(int (*child)(void *arg), void *arg, void *sp,
         * At this point, the handler has stuffed the addresses of
         * sig, sc, and SA_RESTORER in raw.
         */
-       n = waitpid(pid, &status, WUNTRACED);
+       CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if(n < 0){
                printf("capture_stack : waitpid failed - errno = %d\n", errno);
                exit(1);
@@ -82,7 +83,8 @@ static int capture_stack(int (*child)(void *arg), void *arg, void *sp,
                       errno);
                exit(1);
        }
-       if(waitpid(pid, &status, 0) < 0){
+       CATCH_EINTR(n = waitpid(pid, &status, 0));
+       if(n < 0){
                printf("capture_stack : waitpid failed - errno = %d\n", errno);
                exit(1);
        }
@@ -279,7 +281,7 @@ void capture_signal_stack(void)
        struct sc_frame_raw raw_sc;
        struct si_frame_raw raw_si;
        void *stack, *sigstack;
-       unsigned long top, sig_top, base;
+       unsigned long top, base;
 
        stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
@@ -292,7 +294,6 @@ void capture_signal_stack(void)
        }
 
        top = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
-       sig_top = (unsigned long) sigstack + PAGE_SIZE;
 
        /* Get the sigcontext, no sigrestorer layout */
        raw_sc.restorer = 0;
index 9ff4374..24fa893 100644 (file)
@@ -6,7 +6,6 @@
 #include "asm/ptrace.h"
 #include "asm/uaccess.h"
 #include "asm/signal.h"
-#include "asm/uaccess.h"
 #include "asm/ucontext.h"
 #include "frame_kern.h"
 #include "sigcontext.h"
@@ -29,12 +28,15 @@ static int copy_restorer(void (*restorer)(void), unsigned long start,
                            sizeof(restorer)));
 }
 
+extern int userspace_pid[];
+
 static int copy_sc_to_user(void *to, void *fp, struct pt_regs *from, 
                           struct arch_frame_data *arch)
 {
        return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), 
                                              arch),
-                          copy_sc_to_user_skas(to, fp, &from->regs,
+                          copy_sc_to_user_skas(userspace_pid[0], to, fp, 
+                                               &from->regs,
                                                current->thread.cr2,
                                                current->thread.err)));
 }
index 5c4b279..29cceb0 100644 (file)
@@ -7,12 +7,12 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <sched.h>
 #include <sys/signal.h>
 #include <sys/wait.h>
 #include "user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "os.h"
 
 struct helper_data {
@@ -33,6 +33,7 @@ static int helper_child(void *arg)
 {
        struct helper_data *data = arg;
        char **argv = data->argv;
+       int errval;
 
        if(helper_pause){
                signal(SIGHUP, helper_hup);
@@ -41,8 +42,9 @@ static int helper_child(void *arg)
        if(data->pre_exec != NULL)
                (*data->pre_exec)(data->pre_data);
        execvp(argv[0], argv);
+       errval = errno;
        printk("execvp of '%s' failed - errno = %d\n", argv[0], errno);
-       write(data->fd, &errno, sizeof(errno));
+       os_write_file(data->fd, &errval, sizeof(errval));
        os_kill_process(os_getpid(), 0);
        return(0);
 }
@@ -59,17 +61,20 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
        if((stack_out != NULL) && (*stack_out != 0))
                stack = *stack_out;
        else stack = alloc_stack(0, um_in_interrupt());
-       if(stack == 0) return(-ENOMEM);
+       if(stack == 0) 
+               return(-ENOMEM);
 
        err = os_pipe(fds, 1, 0);
-       if(err){
-               printk("run_helper : pipe failed, errno = %d\n", -err);
-               return(err);
+       if(err < 0){
+               printk("run_helper : pipe failed, err = %d\n", -err);
+               goto out_free;
        }
-       if(fcntl(fds[1], F_SETFD, 1) != 0){
-               printk("run_helper : setting FD_CLOEXEC failed, errno = %d\n",
-                      errno);
-               return(-errno);
+
+       err = os_set_exec_close(fds[1], 1);
+       if(err < 0){
+               printk("run_helper : setting FD_CLOEXEC failed, err = %d\n",
+                      -err);
+               goto out_close;
        }
 
        sp = stack + page_size() - sizeof(void *);
@@ -80,23 +85,30 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
        pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
        if(pid < 0){
                printk("run_helper : clone failed, errno = %d\n", errno);
-               return(-errno);
+               err = -errno;
+               goto out_close;
        }
-       close(fds[1]);
-       n = read(fds[0], &err, sizeof(err));
+
+       os_close_file(fds[1]);
+       n = os_read_file(fds[0], &err, sizeof(err));
        if(n < 0){
-               printk("run_helper : read on pipe failed, errno = %d\n", 
-                      errno);
-               return(-errno);
+               printk("run_helper : read on pipe failed, err = %d\n", -n);
+               err = n;
+               os_kill_process(pid, 1);
        }
        else if(n != 0){
-               waitpid(pid, NULL, 0);
-               pid = -err;
+               CATCH_EINTR(n = waitpid(pid, NULL, 0));
+               pid = -errno;
        }
+       err = pid;
 
-       if(stack_out == NULL) free_stack(stack, 0);
+ out_close:
+       os_close_file(fds[0]);
+ out_free:
+       if(stack_out == NULL) 
+               free_stack(stack, 0);
         else *stack_out = stack;
-       return(pid);
+       return(err);
 }
 
 int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, 
@@ -117,9 +129,11 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
        }
        if(stack_out == NULL){
                pid = waitpid(pid, &status, 0);
-               if(pid < 0)
+               if(pid < 0){
                        printk("run_helper_thread - wait failed, errno = %d\n",
-                              pid);
+                              errno);
+                       pid = -errno;
+               }
                if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
                        printk("run_helper_thread - thread returned status "
                               "0x%x\n", status);
index be82caf..cd7c85b 100644 (file)
@@ -8,7 +8,6 @@
 #include "linux/module.h"
 #include "linux/sched.h"
 #include "linux/init_task.h"
-#include "linux/version.h"
 #include "linux/mqueue.h"
 #include "asm/uaccess.h"
 #include "asm/pgtable.h"
@@ -19,7 +18,7 @@ static struct fs_struct init_fs = INIT_FS;
 struct mm_struct init_mm = INIT_MM(init_mm);
 static struct files_struct init_files = INIT_FILES;
 static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
-
+static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
 EXPORT_SYMBOL(init_mm);
 
 /*
@@ -44,26 +43,12 @@ union thread_union init_thread_union
 __attribute__((__section__(".data.init_task"))) = 
 { INIT_THREAD_INFO(init_task) };
 
-struct task_struct *alloc_task_struct(void)
-{
-       return((struct task_struct *) 
-              __get_free_pages(GFP_KERNEL, CONFIG_KERNEL_STACK_ORDER));
-}
-
 void unprotect_stack(unsigned long stack)
 {
        protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, 
                       1, 1, 0, 1);
 }
 
-void free_task_struct(struct task_struct *task)
-{
-       /* free_pages decrements the page counter and only actually frees
-        * the pages if they are now not accessed by anything.
-        */
-       free_pages((unsigned long) task, CONFIG_KERNEL_STACK_ORDER);
-}
-
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
index 944c734..265cbab 100644 (file)
@@ -6,7 +6,6 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 #include <errno.h>
 
 #include "user_util.h"
@@ -19,13 +18,15 @@ int load_initrd(char *filename, void *buf, int size)
 {
        int fd, n;
 
-       if((fd = os_open_file(filename, of_read(OPENFLAGS()), 0)) < 0){
-               printk("Opening '%s' failed - errno = %d\n", filename, errno);
+       fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
+       if(fd < 0){
+               printk("Opening '%s' failed - err = %d\n", filename, -fd);
                return(-1);
        }
-       if((n = read(fd, buf, size)) != size){
-               printk("Read of %d bytes from '%s' returned %d, errno = %d\n",
-                      size, filename, n, errno);
+       n = os_read_file(fd, buf, size);
+       if(n != size){
+               printk("Read of %d bytes from '%s' failed, err = %d\n", size, 
+                      filename, -n);
                return(-1);
        }
        return(0);
index 0e968bb..9b2a68f 100644 (file)
@@ -29,6 +29,7 @@
 #include "user_util.h"
 #include "kern_util.h"
 #include "irq_user.h"
+#include "irq_kern.h"
 
 static void register_irq_proc (unsigned int irq);
 
@@ -83,65 +84,55 @@ struct hw_interrupt_type no_irq_type = {
        end_none
 };
 
-/* Not changed */
-volatile unsigned long irq_err_count;
-
 /*
  * Generic, controller-independent functions:
  */
 
-int get_irq_list(char *buf)
+int show_interrupts(struct seq_file *p, void *v)
 {
-       int i, j;
-       unsigned long flags;
+       int i = *(loff_t *) v, j;
        struct irqaction * action;
-       char *p = buf;
+       unsigned long flags;
 
-       p += sprintf(p, "           ");
-       for (j=0; j<num_online_cpus(); j++)
-               p += sprintf(p, "CPU%d       ",j);
-       *p++ = '\n';
+       if (i == 0) {
+               seq_printf(p, "           ");
+               for (j=0; j<NR_CPUS; j++)
+                       if (cpu_online(j))
+                               seq_printf(p, "CPU%d       ",j);
+               seq_putc(p, '\n');
+       }
 
-       for (i = 0 ; i < NR_IRQS ; i++) {
+       if (i < NR_IRQS) {
                spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action) 
-                       goto end;
-               p += sprintf(p, "%3d: ",i);
+                       goto skip;
+               seq_printf(p, "%3d: ",i);
 #ifndef CONFIG_SMP
-               p += sprintf(p, "%10u ", kstat_irqs(i));
+               seq_printf(p, "%10u ", kstat_irqs(i));
 #else
-               for (j = 0; j < num_online_cpus(); j++)
-                       p += sprintf(p, "%10u ",
-                               kstat_cpu(cpu_logical_map(j)).irqs[i]);
+               for (j = 0; j < NR_CPUS; j++)
+                       if (cpu_online(j))
+                               seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
 #endif
-               p += sprintf(p, " %14s", irq_desc[i].handler->typename);
-               p += sprintf(p, "  %s", action->name);
+               seq_printf(p, " %14s", irq_desc[i].handler->typename);
+               seq_printf(p, "  %s", action->name);
 
                for (action=action->next; action; action = action->next)
-                       p += sprintf(p, ", %s", action->name);
-               *p++ = '\n';
-       end:
+                       seq_printf(p, ", %s", action->name);
+
+               seq_putc(p, '\n');
+skip:
                spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+       } else if (i == NR_IRQS) {
+               seq_printf(p, "NMI: ");
+               for (j = 0; j < NR_CPUS; j++)
+                       if (cpu_online(j))
+                               seq_printf(p, "%10u ", nmi_count(j));
+               seq_putc(p, '\n');
        }
-       p += sprintf(p, "\n");
-#ifdef notdef
-#ifdef CONFIG_SMP
-       p += sprintf(p, "LOC: ");
-       for (j = 0; j < num_online_cpus(); j++)
-               p += sprintf(p, "%10u ",
-                       apic_timer_irqs[cpu_logical_map(j)]);
-       p += sprintf(p, "\n");
-#endif
-#endif
-       p += sprintf(p, "ERR: %10lu\n", irq_err_count);
-       return p - buf;
-}
 
-
-int show_interrupts(struct seq_file *p, void *v)
-{
-       return(0);
+       return 0;
 }
 
 /*
@@ -282,13 +273,12 @@ unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
         * 0 return value means that this irq is already being
         * handled by some other CPU. (or is disabled)
         */
-       int cpu = smp_processor_id();
        irq_desc_t *desc = irq_desc + irq;
        struct irqaction * action;
        unsigned int status;
 
        irq_enter();
-       kstat_cpu(cpu).irqs[irq]++;
+       kstat_this_cpu.irqs[irq]++;
        spin_lock(&desc->lock);
        desc->handler->ack(irq);
        /*
@@ -385,7 +375,7 @@ out:
  */
  
 int request_irq(unsigned int irq,
-               void (*handler)(int, void *, struct pt_regs *),
+               irqreturn_t (*handler)(int, void *, struct pt_regs *),
                unsigned long irqflags, 
                const char * devname,
                void *dev_id)
@@ -433,15 +423,19 @@ int request_irq(unsigned int irq,
 EXPORT_SYMBOL(request_irq);
 
 int um_request_irq(unsigned int irq, int fd, int type,
-                  void (*handler)(int, void *, struct pt_regs *),
+                  irqreturn_t (*handler)(int, void *, struct pt_regs *),
                   unsigned long irqflags, const char * devname,
                   void *dev_id)
 {
-       int retval;
+       int err;
+
+       err = request_irq(irq, handler, irqflags, devname, dev_id);
+       if(err) 
+               return(err);
 
-       retval = request_irq(irq, handler, irqflags, devname, dev_id);
-       if(retval) return(retval);
-       return(activate_fd(irq, fd, type, dev_id));
+       if(fd != -1)
+               err = activate_fd(irq, fd, type, dev_id);
+       return(err);
 }
 
 /* this was setup_x86_irq but it seems pretty generic */
@@ -474,7 +468,8 @@ int setup_irq(unsigned int irq, struct irqaction * new)
         */
        spin_lock_irqsave(&desc->lock,flags);
        p = &desc->action;
-       if ((old = *p) != NULL) {
+       old = *p;
+       if (old != NULL) {
                /* Can't share interrupts unless both agree to */
                if (!(old->flags & new->flags & SA_SHIRQ)) {
                        spin_unlock_irqrestore(&desc->lock,flags);
@@ -586,12 +581,14 @@ static int irq_affinity_write_proc (struct file *file, const char *buffer,
                                        unsigned long count, void *data)
 {
        int irq = (long) data, full_count = count, err;
-       cpumask_t new_value, tmp;
+       cpumask_t new_value;
 
        if (!irq_desc[irq].handler->set_affinity)
                return -EIO;
 
        err = cpumask_parse(buffer, count, new_value);
+       if(err)
+               return(err);
 
 #ifdef CONFIG_SMP
        /*
@@ -599,9 +596,11 @@ static int irq_affinity_write_proc (struct file *file, const char *buffer,
         * way to make the system unusable accidentally :-) At least
         * one online CPU still has to be targeted.
         */
-       cpus_and(tmp, new_value, cpu_online_map);
-       if (cpus_empty(tmp))
-               return -EINVAL;
+       { cpumask_t tmp;
+         cpus_and(tmp, new_value, cpu_online_map);
+         if (cpus_empty(tmp))
+                 return -EINVAL;
+       }
 #endif
 
        irq_affinity[irq] = new_value;
index 57fe9bb..38e66ac 100644 (file)
@@ -6,7 +6,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <signal.h>
 #include <string.h>
 #include <sys/poll.h>
@@ -49,7 +48,8 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
 
        if(smp_sigio_handler()) return;
        while(1){
-               if((n = poll(pollfds, pollfds_num, 0)) < 0){
+               n = poll(pollfds, pollfds_num, 0);
+               if(n < 0){
                        if(errno == EINTR) continue;
                        printk("sigio_handler : poll returned %d, "
                               "errno = %d\n", n, errno);
@@ -364,36 +364,47 @@ void deactivate_fd(int fd, int irqnum)
        irq_unlock(flags);
 }
 
-void forward_ipi(int fd, int pid)
+int deactivate_all_fds(void)
 {
-       if(fcntl(fd, F_SETOWN, pid) < 0){
-               int save_errno = errno;
-               if(fcntl(fd, F_GETOWN, 0) != pid){
-                       printk("forward_ipi: F_SETOWN failed, fd = %d, "
-                              "me = %d, target = %d, errno = %d\n", fd, 
-                              os_getpid(), pid, save_errno);
-               }
+       struct irq_fd *irq;
+       int err;
+
+       for(irq=active_fds;irq != NULL;irq = irq->next){
+               err = os_clear_fd_async(irq->fd);
+               if(err)
+                       return(err);
        }
+
+       return(0);
+}
+
+void forward_ipi(int fd, int pid)
+{
+       int err;
+
+       err = os_set_owner(fd, pid);
+       if(err < 0)
+               printk("forward_ipi: set_owner failed, fd = %d, me = %d, "
+                      "target = %d, err = %d\n", fd, os_getpid(), pid, -err);
 }
 
 void forward_interrupts(int pid)
 {
        struct irq_fd *irq;
        unsigned long flags;
+       int err;
 
        flags = irq_lock();
        for(irq=active_fds;irq != NULL;irq = irq->next){
-               if(fcntl(irq->fd, F_SETOWN, pid) < 0){
-                       int save_errno = errno;
-                       if(fcntl(irq->fd, F_GETOWN, 0) != pid){
-                               /* XXX Just remove the irq rather than
-                                * print out an infinite stream of these
-                                */
-                               printk("Failed to forward %d to pid %d, "
-                                      "errno = %d\n", irq->fd, pid, 
-                                      save_errno);
-                       }
+               err = os_set_owner(irq->fd, pid);
+               if(err < 0){
+                       /* XXX Just remove the irq rather than
+                        * print out an infinite stream of these
+                        */
+                       printk("Failed to forward %d to pid %d, err = %d\n",
+                              irq->fd, pid, -err);
                }
+
                irq->pid = pid;
        }
        irq_unlock(flags);
index 1f82ad7..cb12aa8 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2004 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -8,7 +8,7 @@
 #include "linux/string.h"
 #include "linux/smp_lock.h"
 #include "linux/spinlock.h"
-#include <linux/highmem.h>
+#include "linux/highmem.h"
 #include "asm/current.h"
 #include "asm/delay.h"
 #include "asm/processor.h"
@@ -19,6 +19,7 @@
 #include "asm/tlbflush.h"
 #include "kern_util.h"
 #include "user_util.h"
+#include "mem_user.h"
 #include "os.h"
 #include "helper.h"
 
@@ -34,34 +35,66 @@ EXPORT_SYMBOL(task_size);
 EXPORT_SYMBOL(flush_tlb_range);
 EXPORT_SYMBOL(host_task_size);
 EXPORT_SYMBOL(arch_validate);
+EXPORT_SYMBOL(get_kmem_end);
 
-EXPORT_SYMBOL(region_pa);
-EXPORT_SYMBOL(region_va);
-EXPORT_SYMBOL(phys_mem_map);
-EXPORT_SYMBOL(page_mem_map);
 EXPORT_SYMBOL(page_to_phys);
 EXPORT_SYMBOL(phys_to_page);
 EXPORT_SYMBOL(high_physmem);
 EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(um_virt_to_phys);
+EXPORT_SYMBOL(__virt_to_page);
+EXPORT_SYMBOL(to_phys);
+EXPORT_SYMBOL(to_virt);
 EXPORT_SYMBOL(mode_tt);
 EXPORT_SYMBOL(handle_page_fault);
+EXPORT_SYMBOL(find_iomem);
 
+#ifdef CONFIG_MODE_TT
+EXPORT_SYMBOL(strncpy_from_user_tt);
+EXPORT_SYMBOL(copy_from_user_tt);
+EXPORT_SYMBOL(copy_to_user_tt);
+#endif
+
+#ifdef CONFIG_MODE_SKAS
+EXPORT_SYMBOL(strncpy_from_user_skas);
+EXPORT_SYMBOL(copy_to_user_skas);
+EXPORT_SYMBOL(copy_from_user_skas);
+#endif
+
+EXPORT_SYMBOL(os_stat_fd);
+EXPORT_SYMBOL(os_stat_file);
+EXPORT_SYMBOL(os_access);
+EXPORT_SYMBOL(os_print_error);
+EXPORT_SYMBOL(os_get_exec_close);
+EXPORT_SYMBOL(os_set_exec_close);
 EXPORT_SYMBOL(os_getpid);
 EXPORT_SYMBOL(os_open_file);
 EXPORT_SYMBOL(os_read_file);
 EXPORT_SYMBOL(os_write_file);
 EXPORT_SYMBOL(os_seek_file);
+EXPORT_SYMBOL(os_lock_file);
+EXPORT_SYMBOL(os_ioctl_generic);
 EXPORT_SYMBOL(os_pipe);
 EXPORT_SYMBOL(os_file_type);
+EXPORT_SYMBOL(os_file_mode);
+EXPORT_SYMBOL(os_file_size);
+EXPORT_SYMBOL(os_flush_stdout);
 EXPORT_SYMBOL(os_close_file);
+EXPORT_SYMBOL(os_set_fd_async);
+EXPORT_SYMBOL(os_set_fd_block);
 EXPORT_SYMBOL(helper_wait);
 EXPORT_SYMBOL(os_shutdown_socket);
+EXPORT_SYMBOL(os_create_unix_socket);
 EXPORT_SYMBOL(os_connect_socket);
+EXPORT_SYMBOL(os_accept_connection);
+EXPORT_SYMBOL(os_rcv_fd);
 EXPORT_SYMBOL(run_helper);
 EXPORT_SYMBOL(start_thread);
 EXPORT_SYMBOL(dump_thread);
 
+EXPORT_SYMBOL(do_gettimeofday);
+EXPORT_SYMBOL(do_settimeofday);
+
 /* This is here because UML expands open to sys_open, not to a system
  * call instruction.
  */
@@ -90,3 +123,13 @@ EXPORT_SYMBOL(kunmap_atomic);
 EXPORT_SYMBOL(kmap_atomic_to_page);
 #endif
 
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
index 84a895c..d520947 100644 (file)
@@ -1,74 +1,66 @@
 /* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
-#include "linux/config.h"
-#include "linux/module.h"
-#include "linux/types.h"
+#include "linux/stddef.h"
+#include "linux/kernel.h"
 #include "linux/mm.h"
-#include "linux/fs.h"
-#include "linux/init.h"
 #include "linux/bootmem.h"
 #include "linux/swap.h"
-#include "linux/slab.h"
-#include "linux/vmalloc.h"
 #include "linux/highmem.h"
+#include "linux/gfp.h"
 #include "asm/page.h"
-#include "asm/pgtable.h"
+#include "asm/fixmap.h"
 #include "asm/pgalloc.h"
-#include "asm/bitops.h"
-#include "asm/uaccess.h"
-#include "asm/tlb.h"
 #include "user_util.h"
 #include "kern_util.h"
-#include "mem_user.h"
-#include "mem.h"
 #include "kern.h"
-#include "init.h"
-#include "os.h"
-#include "mode_kern.h"
+#include "mem_user.h"
 #include "uml_uaccess.h"
+#include "os.h"
+
+extern char __binary_start;
 
 /* Changed during early boot */
-pgd_t swapper_pg_dir[1024];
-unsigned long high_physmem;
-unsigned long vm_start;
-unsigned long vm_end;
-unsigned long highmem;
 unsigned long *empty_zero_page = NULL;
 unsigned long *empty_bad_page = NULL;
-
-/* Not modified */
-const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";
-
-extern char __init_begin, __init_end;
-extern long physmem_size;
-
-/* Not changed by UML */
-DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
-
-/* Changed during early boot */
+pgd_t swapper_pg_dir[1024];
+unsigned long highmem;
 int kmalloc_ok = 0;
 
-#define NREGIONS (phys_region_index(0xffffffff) - phys_region_index(0x0) + 1)
-struct mem_region *regions[NREGIONS] = { [ 0 ... NREGIONS - 1 ] = NULL };
-#define REGION_SIZE ((0xffffffff & ~REGION_MASK) + 1)
-
-/* Changed during early boot */
 static unsigned long brk_end;
 
+void unmap_physmem(void)
+{
+       os_unmap_memory((void *) brk_end, uml_reserved - brk_end);
+}
+
 static void map_cb(void *unused)
 {
        map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
 }
 
-void unmap_physmem(void)
+#ifdef CONFIG_HIGHMEM
+static void setup_highmem(unsigned long highmem_start, 
+                         unsigned long highmem_len)
 {
-       os_unmap_memory((void *) brk_end, uml_reserved - brk_end);
-}
+       struct page *page;
+       unsigned long highmem_pfn;
+       int i;
 
-extern char __binary_start;
+       highmem_start_page = virt_to_page(highmem_start);
+
+       highmem_pfn = __pa(highmem_start) >> PAGE_SHIFT;
+       for(i = 0; i < highmem_len >> PAGE_SHIFT; i++){
+               page = &mem_map[highmem_pfn + i];
+               ClearPageReserved(page);
+               set_bit(PG_highmem, &page->flags);
+               set_page_count(page, 1);
+               __free_page(page);
+       }
+}
+#endif
 
 void mem_init(void)
 {
@@ -103,50 +95,15 @@ void mem_init(void)
        totalhigh_pages = highmem >> PAGE_SHIFT;
        totalram_pages += totalhigh_pages;
        num_physpages = totalram_pages;
-       max_mapnr = totalram_pages;
        max_pfn = totalram_pages;
        printk(KERN_INFO "Memory: %luk available\n", 
               (unsigned long) nr_free_pages() << (PAGE_SHIFT-10));
        kmalloc_ok = 1;
-}
-
-/* Changed during early boot */
-static unsigned long kmem_top = 0;
-
-unsigned long get_kmem_end(void)
-{
-       if(kmem_top == 0)
-               kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
-       return(kmem_top);
-}
-
-void set_kmem_end(unsigned long new)
-{
-       kmem_top = new;
-}
 
 #ifdef CONFIG_HIGHMEM
-/* Changed during early boot */
-pte_t *kmap_pte;
-pgprot_t kmap_prot;
-
-EXPORT_SYMBOL(kmap_prot);
-EXPORT_SYMBOL(kmap_pte);
-
-#define kmap_get_fixmap_pte(vaddr)                                     \
-       pte_offset_kernel(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))
-
-void __init kmap_init(void)
-{
-       unsigned long kmap_vstart;
-
-       /* cache the first kmap pte */
-       kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
-       kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
-
-       kmap_prot = PAGE_KERNEL;
+       setup_highmem(end_iomem, highmem);
+#endif
 }
-#endif /* CONFIG_HIGHMEM */
 
 static void __init fixrange_init(unsigned long start, unsigned long end, 
                                 pgd_t *pgd_base)
@@ -178,76 +135,24 @@ static void __init fixrange_init(unsigned long start, unsigned long end,
        }
 }
 
-int init_maps(struct mem_region *region)
-{
-       struct page *p, *map;
-       int i, n, len;
-
-       if(region == &physmem_region){
-               region->mem_map = mem_map;
-               return(0);
-       }
-       else if(region->mem_map != NULL) return(0);
-
-       n = region->len >> PAGE_SHIFT;
-       len = n * sizeof(struct page);
-       if(kmalloc_ok){
-               map = kmalloc(len, GFP_KERNEL);
-               if(map == NULL) map = vmalloc(len);
-       }
-       else map = alloc_bootmem_low_pages(len);
-
-       if(map == NULL)
-               return(-ENOMEM);
-       for(i = 0; i < n; i++){
-               p = &map[i];
-               set_page_count(p, 0);
-               SetPageReserved(p);
-               INIT_LIST_HEAD(&p->list);
-       }
-       region->mem_map = map;
-       return(0);
-}
+#if CONFIG_HIGHMEM
+pte_t *kmap_pte;
+pgprot_t kmap_prot;
 
-DECLARE_MUTEX(regions_sem);
+#define kmap_get_fixmap_pte(vaddr)                                     \
+       pte_offset(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))
 
-static int setup_one_range(int fd, char *driver, unsigned long start, 
-                          unsigned long pfn, int len, 
-                          struct mem_region *region)
+void __init kmap_init(void)
 {
-       int i;
-
-       down(&regions_sem);
-       for(i = 0; i < NREGIONS; i++){
-               if(regions[i] == NULL) break;           
-       }
-       if(i == NREGIONS){
-               printk("setup_range : no free regions\n");
-               i = -1;
-               goto out;
-       }
-
-       if(fd == -1)
-               fd = create_mem_file(len);
+       unsigned long kmap_vstart;
 
-       if(region == NULL){
-               region = alloc_bootmem_low_pages(sizeof(*region));
-               if(region == NULL)
-                       panic("Failed to allocating mem_region");
-       }
+       /* cache the first kmap pte */
+       kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
+       kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
 
-       *region = ((struct mem_region) { .driver        = driver,
-                                        .start_pfn     = pfn,
-                                        .start         = start, 
-                                        .len           = len, 
-                                        .fd            = fd } );
-       regions[i] = region;
- out:
-       up(&regions_sem);
-       return(i);
+       kmap_prot = PAGE_KERNEL;
 }
 
-#ifdef CONFIG_HIGHMEM
 static void init_highmem(void)
 {
        pgd_t *pgd;
@@ -268,63 +173,20 @@ static void init_highmem(void)
 
        kmap_init();
 }
-
-void setup_highmem(unsigned long len)
-{
-       struct mem_region *region;
-       struct page *page, *map;
-       unsigned long phys;
-       int i, cur, index;
-
-       phys = physmem_size;
-       do {
-               cur = min(len, (unsigned long) REGION_SIZE);
-               i = setup_one_range(-1, NULL, -1, phys >> PAGE_SHIFT, cur, 
-                                   NULL);
-               if(i == -1){
-                       printk("setup_highmem - setup_one_range failed\n");
-                       return;
-               }
-               region = regions[i];
-               index = phys / PAGE_SIZE;
-               region->mem_map = &mem_map[index];
-
-               map = region->mem_map;
-               for(i = 0; i < (cur >> PAGE_SHIFT); i++){
-                       page = &map[i];
-                       ClearPageReserved(page);
-                       set_bit(PG_highmem, &page->flags);
-                       set_page_count(page, 1);
-                       __free_page(page);
-               }
-               phys += cur;
-               len -= cur;
-       } while(len > 0);
-}
-#endif
+#endif /* CONFIG_HIGHMEM */
 
 void paging_init(void)
 {
-       struct mem_region *region;
-       unsigned long zones_size[MAX_NR_ZONES], start, end, vaddr;
-       int i, index;
+       unsigned long zones_size[MAX_NR_ZONES], vaddr;
+       int i;
 
        empty_zero_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
        empty_bad_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
        for(i=0;i<sizeof(zones_size)/sizeof(zones_size[0]);i++) 
                zones_size[i] = 0;
-       zones_size[0] = (high_physmem >> PAGE_SHIFT) - 
-               (uml_physmem >> PAGE_SHIFT);
+       zones_size[0] = (end_iomem >> PAGE_SHIFT) - (uml_physmem >> PAGE_SHIFT);
        zones_size[2] = highmem >> PAGE_SHIFT;
        free_area_init(zones_size);
-       start = phys_region_index(__pa(uml_physmem));
-       end = phys_region_index(__pa(high_physmem - 1));
-       for(i = start; i <= end; i++){
-               region = regions[i];
-               index = (region->start - uml_physmem) / PAGE_SIZE;
-               region->mem_map = &mem_map[index];
-               if(i > start) free_bootmem(__pa(region->start), region->len);
-       }
 
        /*
         * Fixed mappings, only the page table structure has to be
@@ -335,15 +197,33 @@ void paging_init(void)
 
 #ifdef CONFIG_HIGHMEM
        init_highmem();
-       setup_highmem(highmem);
 #endif
 }
 
-pte_t __bad_page(void)
+struct page *arch_validate(struct page *page, int mask, int order)
 {
-       clear_page(empty_bad_page);
-        return pte_mkdirty(mk_pte((struct page *) empty_bad_page, 
-                                 PAGE_SHARED));
+       unsigned long addr, zero = 0;
+       int i;
+
+ again:
+       if(page == NULL) return(page);
+       if(PageHighMem(page)) return(page);
+
+       addr = (unsigned long) page_address(page);
+       for(i = 0; i < (1 << order); i++){
+               current->thread.fault_addr = (void *) addr;
+               if(__do_copy_to_user((void *) addr, &zero, 
+                                    sizeof(zero),
+                                    &current->thread.fault_addr,
+                                    &current->thread.fault_catcher)){
+                       if(!(mask & __GFP_WAIT)) return(NULL);
+                       else break;
+               }
+               addr += PAGE_SIZE;
+       }
+       if(i == (1 << order)) return(page);
+       page = alloc_pages(mask, order);
+       goto again;
 }
 
 /* This can't do anything because nothing in the kernel image can be freed
@@ -401,395 +281,6 @@ void show_mem(void)
         printk("%d pages swap cached\n", cached);
 }
 
-static int __init uml_mem_setup(char *line, int *add)
-{
-       char *retptr;
-       physmem_size = memparse(line,&retptr);
-       return 0;
-}
-__uml_setup("mem=", uml_mem_setup,
-"mem=<Amount of desired ram>\n"
-"    This controls how much \"physical\" memory the kernel allocates\n"
-"    for the system. The size is specified as a number followed by\n"
-"    one of 'k', 'K', 'm', 'M', which have the obvious meanings.\n"
-"    This is not related to the amount of memory in the physical\n"
-"    machine. It can be more, and the excess, if it's ever used, will\n"
-"    just be swapped out.\n        Example: mem=64M\n\n"
-);
-
-struct page *arch_validate(struct page *page, int mask, int order)
-{
-       unsigned long addr, zero = 0;
-       int i;
-
- again:
-       if(page == NULL) return(page);
-       if(PageHighMem(page)) return(page);
-
-       addr = (unsigned long) page_address(page);
-       for(i = 0; i < (1 << order); i++){
-               current->thread.fault_addr = (void *) addr;
-               if(__do_copy_to_user((void *) addr, &zero, 
-                                    sizeof(zero),
-                                    &current->thread.fault_addr,
-                                    &current->thread.fault_catcher)){
-                       if(!(mask & __GFP_WAIT)) return(NULL);
-                       else break;
-               }
-               addr += PAGE_SIZE;
-       }
-       if(i == (1 << order)) return(page);
-       page = alloc_pages(mask, order);
-       goto again;
-}
-
-DECLARE_MUTEX(vm_reserved_sem);
-static struct list_head vm_reserved = LIST_HEAD_INIT(vm_reserved);
-
-/* Static structures, linked in to the list in early boot */
-static struct vm_reserved head = {
-       .list           = LIST_HEAD_INIT(head.list),
-       .start          = 0,
-       .end            = 0xffffffff
-};
-
-static struct vm_reserved tail = {
-       .list           = LIST_HEAD_INIT(tail.list),
-       .start          = 0,
-       .end            = 0xffffffff
-};
-
-void set_usable_vm(unsigned long start, unsigned long end)
-{
-       list_add(&head.list, &vm_reserved);
-       list_add(&tail.list, &head.list);
-       head.end = start;
-       tail.start = end;
-}
-
-int reserve_vm(unsigned long start, unsigned long end, void *e)
-              
-{
-       struct vm_reserved *entry = e, *reserved, *prev;
-       struct list_head *ele;
-       int err;
-
-       down(&vm_reserved_sem);
-       list_for_each(ele, &vm_reserved){
-               reserved = list_entry(ele, struct vm_reserved, list);
-               if(reserved->start >= end) goto found;
-       }
-       panic("Reserved vm out of range");
- found:
-       prev = list_entry(ele->prev, struct vm_reserved, list);
-       if(prev->end > start)
-               panic("Can't reserve vm");
-       if(entry == NULL)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
-       if(entry == NULL){
-               printk("reserve_vm : Failed to allocate entry\n");
-               err = -ENOMEM;
-               goto out;
-       }
-       *entry = ((struct vm_reserved) 
-               { .list         = LIST_HEAD_INIT(entry->list),
-                 .start        = start,
-                 .end          = end });
-       list_add(&entry->list, &prev->list);
-       err = 0;
- out:
-       up(&vm_reserved_sem);
-       return(0);
-}
-
-unsigned long get_vm(unsigned long len)
-{
-       struct vm_reserved *this, *next;
-       struct list_head *ele;
-       unsigned long start;
-       int err;
-       
-       down(&vm_reserved_sem);
-       list_for_each(ele, &vm_reserved){
-               this = list_entry(ele, struct vm_reserved, list);
-               next = list_entry(ele->next, struct vm_reserved, list);
-               if((this->start < next->start) && 
-                  (this->end + len + PAGE_SIZE <= next->start))
-                       goto found;
-       }
-       up(&vm_reserved_sem);
-       return(0);
- found:
-       up(&vm_reserved_sem);
-       start = (unsigned long) UML_ROUND_UP(this->end) + PAGE_SIZE;
-       err = reserve_vm(start, start + len, NULL);
-       if(err) return(0);
-       return(start);
-}
-
-int nregions(void)
-{
-       return(NREGIONS);
-}
-
-void setup_range(int fd, char *driver, unsigned long start, unsigned long pfn,
-                unsigned long len, int need_vm, struct mem_region *region, 
-                void *reserved)
-{
-       int i, cur;
-
-       do {
-               cur = min(len, (unsigned long) REGION_SIZE);
-               i = setup_one_range(fd, driver, start, pfn, cur, region);
-               region = regions[i];
-               if(need_vm && setup_region(region, reserved)){
-                       kfree(region);
-                       regions[i] = NULL;
-                       return;
-               }
-               start += cur;
-               if(pfn != -1) pfn += cur;
-               len -= cur;
-       } while(len > 0);
-}
-
-struct iomem {
-       char *name;
-       int fd;
-       unsigned long size;
-};
-
-/* iomem regions can only be added on the command line at the moment.  
- * Locking will be needed when they can be added via mconsole.
- */
-
-struct iomem iomem_regions[NREGIONS] = { [ 0 ... NREGIONS - 1 ] =
-                                        { .name        = NULL,
-                                          .fd          = -1,
-                                          .size        = 0 } };
-
-int num_iomem_regions = 0;
-
-void add_iomem(char *name, int fd, unsigned long size)
-{
-       if(num_iomem_regions == sizeof(iomem_regions)/sizeof(iomem_regions[0]))
-               return;
-       size = (size + PAGE_SIZE - 1) & PAGE_MASK;
-       iomem_regions[num_iomem_regions++] = 
-               ((struct iomem) { .name         = name,
-                                 .fd           = fd,
-                                 .size         = size } );
-}
-
-int setup_iomem(void)
-{
-       struct iomem *iomem;
-       int i;
-
-       for(i = 0; i < num_iomem_regions; i++){
-               iomem = &iomem_regions[i];
-               setup_range(iomem->fd, iomem->name, -1, -1, iomem->size, 1, 
-                           NULL, NULL);
-       }
-       return(0);
-}
-
-__initcall(setup_iomem);
-
-#define PFN_UP(x)      (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-#define PFN_DOWN(x)    ((x) >> PAGE_SHIFT)
-
-/* Changed during early boot */
-static struct mem_region physmem_region;
-static struct vm_reserved physmem_reserved;
-
-void setup_physmem(unsigned long start, unsigned long reserve_end,
-                  unsigned long len)
-{
-       struct mem_region *region = &physmem_region;
-       struct vm_reserved *reserved = &physmem_reserved;
-       unsigned long cur, pfn = 0;
-       int do_free = 1, bootmap_size;
-
-       do {
-               cur = min(len, (unsigned long) REGION_SIZE);
-               if(region == NULL) 
-                       region = alloc_bootmem_low_pages(sizeof(*region));
-               if(reserved == NULL) 
-                       reserved = alloc_bootmem_low_pages(sizeof(*reserved));
-               if((region == NULL) || (reserved == NULL))
-                       panic("Couldn't allocate physmem region or vm "
-                             "reservation\n");
-               setup_range(-1, NULL, start, pfn, cur, 1, region, reserved);
-
-               if(do_free){
-                       unsigned long reserve = reserve_end - start;
-                       int pfn = PFN_UP(__pa(reserve_end));
-                       int delta = (len - reserve) >> PAGE_SHIFT;
-
-                       bootmap_size = init_bootmem(pfn, pfn + delta);
-                       free_bootmem(__pa(reserve_end) + bootmap_size,
-                                    cur - bootmap_size - reserve);
-                       do_free = 0;
-               }
-               start += cur;
-               pfn += cur >> PAGE_SHIFT;
-               len -= cur;
-               region = NULL;
-               reserved = NULL;
-       } while(len > 0);
-}
-
-struct mem_region *phys_region(unsigned long phys)
-{
-       unsigned int n = phys_region_index(phys);
-
-       if(regions[n] == NULL) 
-               panic("Physical address in uninitialized region");
-       return(regions[n]);
-}
-
-unsigned long phys_offset(unsigned long phys)
-{
-       return(phys_addr(phys));
-}
-
-struct page *phys_mem_map(unsigned long phys)
-{
-       return((struct page *) phys_region(phys)->mem_map);
-}
-
-struct page *pte_mem_map(pte_t pte)
-{
-       return(phys_mem_map(pte_val(pte)));
-}
-
-struct mem_region *page_region(struct page *page, int *index_out)
-{
-       int i;
-       struct mem_region *region;
-       struct page *map;
-
-       for(i = 0; i < NREGIONS; i++){
-               region = regions[i];
-               if(region == NULL) continue;
-               map = region->mem_map;
-               if((page >= map) && (page < &map[region->len >> PAGE_SHIFT])){
-                       if(index_out != NULL) *index_out = i;
-                       return(region);
-               }
-       }
-       panic("No region found for page");
-       return(NULL);
-}
-
-unsigned long page_to_pfn(struct page *page)
-{
-       struct mem_region *region = page_region(page, NULL);
-
-       return(region->start_pfn + (page - (struct page *) region->mem_map));
-}
-
-struct mem_region *pfn_to_region(unsigned long pfn, int *index_out)
-{
-       struct mem_region *region;
-       int i;
-
-       for(i = 0; i < NREGIONS; i++){
-               region = regions[i];
-               if(region == NULL)
-                       continue;
-
-               if((region->start_pfn <= pfn) &&
-                  (region->start_pfn + (region->len >> PAGE_SHIFT) > pfn)){
-                       if(index_out != NULL) 
-                               *index_out = i;
-                       return(region);
-               }
-       }
-       return(NULL);
-}
-
-struct page *pfn_to_page(unsigned long pfn)
-{
-       struct mem_region *region = pfn_to_region(pfn, NULL);
-       struct page *mem_map = (struct page *) region->mem_map;
-
-       return(&mem_map[pfn - region->start_pfn]);
-}
-
-unsigned long phys_to_pfn(unsigned long p)
-{
-       struct mem_region *region = regions[phys_region_index(p)];
-
-       return(region->start_pfn + (phys_addr(p) >> PAGE_SHIFT));
-}
-
-unsigned long pfn_to_phys(unsigned long pfn)
-{
-       int n;
-       struct mem_region *region = pfn_to_region(pfn, &n);
-
-       return(mk_phys((pfn - region->start_pfn) << PAGE_SHIFT, n));
-}
-
-struct page *page_mem_map(struct page *page)
-{
-       return((struct page *) page_region(page, NULL)->mem_map);
-}
-
-extern unsigned long region_pa(void *virt)
-{
-       struct mem_region *region;
-       unsigned long addr = (unsigned long) virt;
-       int i;
-
-       for(i = 0; i < NREGIONS; i++){
-               region = regions[i];
-               if(region == NULL) continue;
-               if((region->start <= addr) && 
-                  (addr <= region->start + region->len))
-                       return(mk_phys(addr - region->start, i));
-       }
-       panic("region_pa : no region for virtual address");
-       return(0);
-}
-
-extern void *region_va(unsigned long phys)
-{
-       return((void *) (phys_region(phys)->start + phys_addr(phys)));
-}
-
-unsigned long page_to_phys(struct page *page)
-{
-       int n;
-       struct mem_region *region = page_region(page, &n);
-       struct page *map = region->mem_map;
-       return(mk_phys((page - map) << PAGE_SHIFT, n));
-}
-
-struct page *phys_to_page(unsigned long phys)
-{
-       struct page *mem_map;
-
-       mem_map = phys_mem_map(phys);
-       return(mem_map + (phys_offset(phys) >> PAGE_SHIFT));
-}
-
-static int setup_mem_maps(void)
-{
-       struct mem_region *region;
-       int i;
-
-       for(i = 0; i < NREGIONS; i++){
-               region = regions[i];
-               if((region != NULL) && (region->fd > 0)) init_maps(region);
-       }
-       return(0);
-}
-
-__initcall(setup_mem_maps);
-
 /*
  * Allocate and free page tables.
  */
index d90345b..b6d6a61 100644 (file)
 #include <stddef.h>
 #include <stdarg.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
-#include <sys/stat.h>
+#include <fcntl.h>
 #include <sys/types.h>
 #include <sys/mman.h>
 #include "kern_util.h"
 #include "init.h"
 #include "os.h"
 #include "tempfile.h"
+#include "kern_constants.h"
 
 extern struct mem_region physmem_region;
 
 #define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
 
-int create_mem_file(unsigned long len)
+static int create_tmp_file(unsigned long len)
 {
-       int fd;
+       int fd, err;
        char zero;
 
        fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1);
-       if (fchmod(fd, 0777) < 0){
-               perror("fchmod");
+       if(fd < 0) {
+               os_print_error(fd, "make_tempfile");
                exit(1);
        }
-       if(os_seek_file(fd, len) < 0){
-               perror("lseek");
+
+       err = os_mode_fd(fd, 0777);
+       if(err < 0){
+               os_print_error(err, "os_mode_fd");
+               exit(1);
+       }
+       err = os_seek_file(fd, len);
+       if(err < 0){
+               os_print_error(err, "os_seek_file");
                exit(1);
        }
        zero = 0;
-       if(write(fd, &zero, 1) != 1){
-               perror("write");
+       err = os_write_file(fd, &zero, 1);
+       if(err != 1){
+               os_print_error(err, "os_write_file");
                exit(1);
        }
-       if(fcntl(fd, F_SETFD, 1) != 0)
-               perror("Setting FD_CLOEXEC failed");
+
        return(fd);
 }
 
-int setup_region(struct mem_region *region, void *entry)
+static int have_devanon = 0;
+
+void check_devanon(void)
 {
-       void *loc, *start;
-       char *driver;
-       int err, offset;
-
-       if(region->start != -1){
-               err = reserve_vm(region->start, 
-                                region->start + region->len, entry);
-               if(err){
-                       printk("setup_region : failed to reserve "
-                              "0x%x - 0x%x for driver '%s'\n",
-                              region->start, 
-                              region->start + region->len,
-                              region->driver);
-                       return(-1);
-               }
-       }
-       else region->start = get_vm(region->len);
-       if(region->start == 0){
-               if(region->driver == NULL) driver = "physmem";
-               else driver = region->driver;
-               printk("setup_region : failed to find vm for "
-                      "driver '%s' (length %d)\n", driver, region->len);
-               return(-1);
-       }
-       if(region->start == uml_physmem){
-               start = (void *) uml_reserved;
-               offset = uml_reserved - uml_physmem;
+       int fd;
+
+       printk("Checking for /dev/anon on the host...");
+       fd = open("/dev/anon", O_RDWR);
+       if(fd < 0){
+               printk("Not available (open failed with errno %d)\n", errno);
+               return;
        }
-       else {
-               start = (void *) region->start;
-               offset = 0;
+
+       printk("OK\n");
+       have_devanon = 1;
+}
+
+static int create_anon_file(unsigned long len)
+{
+       void *addr;
+       int fd;
+
+       fd = open("/dev/anon", O_RDWR);
+       if(fd < 0) {
+               os_print_error(fd, "opening /dev/anon");
+               exit(1);
        }
 
-       loc = mmap(start, region->len - offset, PROT_READ | PROT_WRITE, 
-                  MAP_SHARED | MAP_FIXED, region->fd, offset);
-       if(loc != start){
-               perror("Mapping memory");
+       addr = mmap(NULL, len, PROT_READ | PROT_WRITE , MAP_PRIVATE, fd, 0);
+       if(addr == MAP_FAILED){
+               os_print_error((int) addr, "mapping physmem file");
                exit(1);
        }
-       return(0);
+       munmap(addr, len);
+
+       return(fd);
 }
 
+int create_mem_file(unsigned long len)
+{
+       int err, fd;
+
+       if(have_devanon)
+               fd = create_anon_file(len);
+       else fd = create_tmp_file(len);
+
+       err = os_set_exec_close(fd, 1);
+       if(err < 0)
+               os_print_error(err, "exec_close");
+       return(fd);
+}
+
+struct iomem_region *iomem_regions = NULL;
+int iomem_size = 0;
+
 static int __init parse_iomem(char *str, int *add)
 {
-       struct stat buf;
+       struct iomem_region *new;
+       struct uml_stat buf;
        char *file, *driver;
-       int fd;
+       int fd, err, size;
 
        driver = str;
        file = strchr(str,',');
        if(file == NULL){
-               printk("parse_iomem : failed to parse iomem\n");
-               return(1);
+               printf("parse_iomem : failed to parse iomem\n");
+               goto out;
        }
        *file = '\0';
        file++;
        fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0);
        if(fd < 0){
-               printk("parse_iomem - Couldn't open io file, errno = %d\n", 
-                      errno);
-               return(1);
+               os_print_error(fd, "parse_iomem - Couldn't open io file");
+               goto out;
+       }
+
+       err = os_stat_fd(fd, &buf);
+       if(err < 0){
+               os_print_error(err, "parse_iomem - cannot stat_fd file");
+               goto out_close;
        }
-       if(fstat(fd, &buf) < 0) {
-               printk("parse_iomem - cannot fstat file, errno = %d\n", errno);
-               return(1);
+
+       new = malloc(sizeof(*new));
+       if(new == NULL){
+               perror("Couldn't allocate iomem_region struct");
+               goto out_close;
        }
-       add_iomem(driver, fd, buf.st_size);
+
+       size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1);
+
+       *new = ((struct iomem_region) { .next           = iomem_regions,
+                                       .driver         = driver,
+                                       .fd             = fd,
+                                       .size           = size,
+                                       .phys           = 0,
+                                       .virt           = 0 });
+       iomem_regions = new;
+       iomem_size += new->size + UM_KERN_PAGE_SIZE;
+
        return(0);
+ out_close:
+       os_close_file(fd);
+ out:
+       return(1);
 }
 
 __uml_setup("iomem=", parse_iomem,
@@ -153,72 +194,52 @@ __uml_setup("iomem=", parse_iomem,
 "    Configure <file> as an IO memory region named <name>.\n\n"
 );
 
-#ifdef notdef
-int logging = 0;
-int logging_fd = -1;
-
-int logging_line = 0;
-char logging_buf[256];
-
-void log(char *fmt, ...)
-{
-       va_list ap;
-       struct timeval tv;
-       struct openflags flags;
-
-       if(logging == 0) return;
-       if(logging_fd < 0){
-               flags = of_create(of_trunc(of_rdrw(OPENFLAGS())));
-               logging_fd = os_open_file("log", flags, 0644);
-       }
-       gettimeofday(&tv, NULL);
-       sprintf(logging_buf, "%d\t %u.%u  ", logging_line++, tv.tv_sec, 
-               tv.tv_usec);
-       va_start(ap, fmt);
-       vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap);
-       va_end(ap);
-       write(logging_fd, logging_buf, strlen(logging_buf));
-}
-#endif
-
-int map_memory(unsigned long virt, unsigned long phys, unsigned long len, 
-              int r, int w, int x)
-{
-       struct mem_region *region = phys_region(phys);
-
-       return(os_map_memory((void *) virt, region->fd, phys_offset(phys), len,
-                            r, w, x));
-}
-
 int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
                   int must_succeed)
 {
-       if(os_protect_memory((void *) addr, len, r, w, x) < 0){
+       int err;
+
+       err = os_protect_memory((void *) addr, len, r, w, x);
+       if(err < 0){
                 if(must_succeed)
-                        panic("protect failed, errno = %d", errno);
-                else return(-errno);
+                       panic("protect failed, err = %d", -err);
+               else return(err);
        }
        return(0);
 }
 
-unsigned long find_iomem(char *driver, unsigned long *len_out)
+#if 0
+/* Debugging facility for dumping stuff out to the host, avoiding the timing
+ * problems that come with printf and breakpoints.
+ * Enable in case of emergency.
+ */
+
+int logging = 1;
+int logging_fd = -1;
+
+int logging_line = 0;
+char logging_buf[512];
+
+void log(char *fmt, ...)
 {
-       struct mem_region *region;
-       int i, n;
-
-       n = nregions();
-       for(i = 0; i < n; i++){
-               region = regions[i];
-               if(region == NULL) continue;
-               if((region->driver != NULL) &&
-                  !strcmp(region->driver, driver)){
-                       *len_out = region->len;
-                       return(region->start);
-               }
-       }
-       *len_out = 0;
-       return 0;
+        va_list ap;
+        struct timeval tv;
+        struct openflags flags;
+
+        if(logging == 0) return;
+        if(logging_fd < 0){
+                flags = of_create(of_trunc(of_rdwr(OPENFLAGS())));
+                logging_fd = os_open_file("log", flags, 0644);
+        }
+        gettimeofday(&tv, NULL);
+        sprintf(logging_buf, "%d\t %u.%u  ", logging_line++, tv.tv_sec, 
+                tv.tv_usec);
+        va_start(ap, fmt);
+        vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap);
+        va_end(ap);
+        write(logging_fd, logging_buf, strlen(logging_buf));
 }
+#endif
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
deleted file mode 100644 (file)
index d0e0f50..0000000
+++ /dev/null
@@ -1,468 +0,0 @@
-/* 
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/mm.h"
-#include "linux/ghash.h"
-#include "linux/slab.h"
-#include "linux/vmalloc.h"
-#include "linux/bootmem.h"
-#include "asm/types.h"
-#include "asm/pgtable.h"
-#include "kern_util.h"
-#include "user_util.h"
-#include "mode_kern.h"
-#include "mem.h"
-#include "mem_user.h"
-#include "os.h"
-#include "kern.h"
-#include "init.h"
-
-#if 0
-static pgd_t physmem_pgd[PTRS_PER_PGD];
-
-static struct phys_desc *lookup_mapping(void *addr)
-{
-       pgd = &physmem_pgd[pgd_index(addr)];
-       if(pgd_none(pgd))
-               return(NULL);
-
-       pmd = pmd_offset(pgd, addr);
-       if(pmd_none(pmd))
-               return(NULL);
-
-       pte = pte_offset_kernel(pmd, addr);
-       return((struct phys_desc *) pte_val(pte));
-}
-
-static struct add_mapping(void *addr, struct phys_desc *new)
-{
-}
-#endif
-
-#define PHYS_HASHSIZE (8192)
-
-struct phys_desc;
-
-DEF_HASH_STRUCTS(virtmem, PHYS_HASHSIZE, struct phys_desc);
-
-struct phys_desc {
-       struct virtmem_ptrs virt_ptrs;
-       int fd;
-       __u64 offset;
-       void *virt;
-       unsigned long phys;
-       struct list_head list;
-};
-
-struct virtmem_table virtmem_hash;
-
-static int virt_cmp(void *virt1, void *virt2)
-{
-       return(virt1 != virt2);
-}
-
-static int virt_hash(void *virt)
-{
-       unsigned long addr = ((unsigned long) virt) >> PAGE_SHIFT;
-       return(addr % PHYS_HASHSIZE);
-}
-
-DEF_HASH(static, virtmem, struct phys_desc, virt_ptrs, void *, virt, virt_cmp, 
-        virt_hash);
-
-LIST_HEAD(descriptor_mappings);
-
-struct desc_mapping {
-       int fd;
-       struct list_head list;
-       struct list_head pages;
-};
-
-static struct desc_mapping *find_mapping(int fd)
-{
-       struct desc_mapping *desc;
-       struct list_head *ele;
-
-       list_for_each(ele, &descriptor_mappings){
-               desc = list_entry(ele, struct desc_mapping, list);
-               if(desc->fd == fd)
-                       return(desc);
-       }
-
-       return(NULL);
-}
-
-static struct desc_mapping *descriptor_mapping(int fd)
-{
-       struct desc_mapping *desc;
-
-       desc = find_mapping(fd);
-       if(desc != NULL)
-               return(desc);
-
-       desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
-       if(desc == NULL)
-               return(NULL);
-
-       *desc = ((struct desc_mapping) 
-               { .fd =         fd,
-                 .list =       LIST_HEAD_INIT(desc->list),
-                 .pages =      LIST_HEAD_INIT(desc->pages) });
-       list_add(&desc->list, &descriptor_mappings);
-
-       return(desc);
-}
-
-int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w)
-{
-       struct desc_mapping *fd_maps;
-       struct phys_desc *desc;
-       unsigned long phys;
-       int err;
-
-       fd_maps = descriptor_mapping(fd);
-       if(fd_maps == NULL)
-               return(-ENOMEM);
-
-       phys = __pa(virt);
-       if(find_virtmem_hash(&virtmem_hash, virt) != NULL)
-               panic("Address 0x%p is already substituted\n", virt);
-
-       err = -ENOMEM;
-       desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
-       if(desc == NULL)
-               goto out;
-
-       *desc = ((struct phys_desc) 
-               { .virt_ptrs =  { NULL, NULL },
-                 .fd =         fd,
-                 .offset =             offset,
-                 .virt =               virt,
-                 .phys =               __pa(virt),
-                 .list =               LIST_HEAD_INIT(desc->list) });
-       insert_virtmem_hash(&virtmem_hash, desc);
-
-       list_add(&desc->list, &fd_maps->pages);
-
-       virt = (void *) ((unsigned long) virt & PAGE_MASK);
-       err = os_map_memory(virt, fd, offset, PAGE_SIZE, 1, w, 0);
-       if(!err)
-               goto out;
-
-       remove_virtmem_hash(&virtmem_hash, desc);
-       kfree(desc);
- out:
-       return(err);
-}
-
-static int physmem_fd = -1;
-
-static void remove_mapping(struct phys_desc *desc)
-{
-       void *virt = desc->virt;
-       int err;
-
-       remove_virtmem_hash(&virtmem_hash, desc);
-       list_del(&desc->list);
-       kfree(desc);
-
-       err = os_map_memory(virt, physmem_fd, __pa(virt), PAGE_SIZE, 1, 1, 0);
-       if(err)
-               panic("Failed to unmap block device page from physical memory, "
-                     "errno = %d", -err);
-}
-
-int physmem_remove_mapping(void *virt)
-{
-       struct phys_desc *desc;
-
-       virt = (void *) ((unsigned long) virt & PAGE_MASK);
-       desc = find_virtmem_hash(&virtmem_hash, virt);
-       if(desc == NULL)
-               return(0);
-
-       remove_mapping(desc);
-       return(1);
-}
-
-void physmem_forget_descriptor(int fd)
-{
-       struct desc_mapping *desc;
-       struct phys_desc *page;
-       struct list_head *ele, *next;
-       __u64 offset;
-       void *addr;
-       int err;
-
-       desc = find_mapping(fd);
-       if(desc == NULL)
-               return;
-
-       list_for_each_safe(ele, next, &desc->pages){
-               page = list_entry(ele, struct phys_desc, list);
-               offset = page->offset;
-               addr = page->virt;
-               remove_mapping(page);
-               err = os_seek_file(fd, offset);
-               if(err)
-                       panic("physmem_forget_descriptor - failed to seek "
-                             "to %lld in fd %d, error = %d\n",
-                             offset, fd, -err);
-               err = os_read_file(fd, addr, PAGE_SIZE);
-               if(err < 0)
-                       panic("physmem_forget_descriptor - failed to read "
-                             "from fd %d to 0x%p, error = %d\n",
-                             fd, addr, -err);
-       }
-
-       list_del(&desc->list);
-       kfree(desc);
-}
-
-void arch_free_page(struct page *page, int order)
-{
-       void *virt;
-       int i;
-
-       for(i = 0; i < (1 << order); i++){
-               virt = __va(page_to_phys(page + i));
-               physmem_remove_mapping(virt);
-       }
-}
-
-int is_remapped(void *virt)
-{
-       return(find_virtmem_hash(&virtmem_hash, virt) != NULL);
-}
-
-/* Changed during early boot */
-unsigned long high_physmem;
-
-extern unsigned long physmem_size;
-
-void *to_virt(unsigned long phys)
-{
-       return((void *) uml_physmem + phys);
-}
-
-unsigned long to_phys(void *virt)
-{
-       return(((unsigned long) virt) - uml_physmem);
-}
-
-int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
-{
-       struct page *p, *map;
-       unsigned long phys_len, phys_pages, highmem_len, highmem_pages;
-       unsigned long iomem_len, iomem_pages, total_len, total_pages;
-       int i;
-
-       phys_pages = physmem >> PAGE_SHIFT;
-       phys_len = phys_pages * sizeof(struct page);
-
-       iomem_pages = iomem >> PAGE_SHIFT;
-       iomem_len = iomem_pages * sizeof(struct page);
-
-       highmem_pages = highmem >> PAGE_SHIFT;
-       highmem_len = highmem_pages * sizeof(struct page);
-
-       total_pages = phys_pages + iomem_pages + highmem_pages;
-       total_len = phys_len + iomem_pages + highmem_len;
-
-       if(kmalloc_ok){
-               map = kmalloc(total_len, GFP_KERNEL);
-               if(map == NULL) 
-                       map = vmalloc(total_len);
-       }
-       else map = alloc_bootmem_low_pages(total_len);
-
-       if(map == NULL)
-               return(-ENOMEM);
-
-       for(i = 0; i < total_pages; i++){
-               p = &map[i];
-               set_page_count(p, 0);
-               SetPageReserved(p);
-               INIT_LIST_HEAD(&p->lru);
-       }
-
-       mem_map = map;
-       max_mapnr = total_pages;
-       return(0);
-}
-
-struct page *phys_to_page(const unsigned long phys)
-{
-       return(&mem_map[phys >> PAGE_SHIFT]);
-}
-
-struct page *__virt_to_page(const unsigned long virt)
-{
-       return(&mem_map[__pa(virt) >> PAGE_SHIFT]);
-}
-
-unsigned long page_to_phys(struct page *page)
-{
-       return((page - mem_map) << PAGE_SHIFT);
-}
-
-pte_t mk_pte(struct page *page, pgprot_t pgprot)
-{
-       pte_t pte;
-
-       pte_val(pte) = page_to_phys(page) + pgprot_val(pgprot);
-       if(pte_present(pte)) pte_mknewprot(pte_mknewpage(pte));
-       return(pte);
-}
-
-/* Changed during early boot */
-static unsigned long kmem_top = 0;
-
-unsigned long get_kmem_end(void)
-{
-       if(kmem_top == 0) 
-               kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
-       return(kmem_top);
-}
-
-void map_memory(unsigned long virt, unsigned long phys, unsigned long len, 
-               int r, int w, int x)
-{
-       __u64 offset;
-       int fd, err;
-
-       fd = phys_mapping(phys, &offset);
-       err = os_map_memory((void *) virt, fd, offset, len, r, w, x);
-       if(err)
-               panic("map_memory(0x%lx, %d, 0x%llx, %ld, %d, %d, %d) failed, "
-                     "err = %d\n", virt, fd, offset, len, r, w, x, err);
-}
-
-#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-
-void setup_physmem(unsigned long start, unsigned long reserve_end,
-                  unsigned long len, unsigned long highmem)
-{
-       unsigned long reserve = reserve_end - start;
-       int pfn = PFN_UP(__pa(reserve_end));
-       int delta = (len - reserve) >> PAGE_SHIFT;
-       int err, offset, bootmap_size;
-
-       physmem_fd = create_mem_file(len + highmem);
-
-       offset = uml_reserved - uml_physmem;
-       err = os_map_memory((void *) uml_reserved, physmem_fd, offset, 
-                           len - offset, 1, 1, 0);
-       if(err < 0){
-               os_print_error(err, "Mapping memory");
-               exit(1);
-       }
-
-       bootmap_size = init_bootmem(pfn, pfn + delta);
-       free_bootmem(__pa(reserve_end) + bootmap_size,
-                    len - bootmap_size - reserve);
-}
-
-int phys_mapping(unsigned long phys, __u64 *offset_out)
-{
-       struct phys_desc *desc = find_virtmem_hash(&virtmem_hash, 
-                                                  __va(phys & PAGE_MASK));
-       int fd = -1;
-
-       if(desc != NULL){
-               fd = desc->fd;
-               *offset_out = desc->offset;
-       }
-       else if(phys < physmem_size){
-               fd = physmem_fd;
-               *offset_out = phys;
-       }
-       else if(phys < __pa(end_iomem)){
-               struct iomem_region *region = iomem_regions;
-       
-               while(region != NULL){
-                       if((phys >= region->phys) && 
-                          (phys < region->phys + region->size)){
-                               fd = region->fd;
-                               *offset_out = phys - region->phys;
-                               break;
-                       }
-                       region = region->next;
-               }
-       }
-       else if(phys < __pa(end_iomem) + highmem){
-               fd = physmem_fd;
-               *offset_out = phys - iomem_size;
-       }
-
-       return(fd);
-}
-
-static int __init uml_mem_setup(char *line, int *add)
-{
-       char *retptr;
-       physmem_size = memparse(line,&retptr);
-       return 0;
-}
-__uml_setup("mem=", uml_mem_setup,
-"mem=<Amount of desired ram>\n"
-"    This controls how much \"physical\" memory the kernel allocates\n"
-"    for the system. The size is specified as a number followed by\n"
-"    one of 'k', 'K', 'm', 'M', which have the obvious meanings.\n"
-"    This is not related to the amount of memory in the host.  It can\n"
-"    be more, and the excess, if it's ever used, will just be swapped out.\n"
-"      Example: mem=64M\n\n"
-);
-
-unsigned long find_iomem(char *driver, unsigned long *len_out)
-{
-       struct iomem_region *region = iomem_regions;
-       
-       while(region != NULL){
-               if(!strcmp(region->driver, driver)){
-                       *len_out = region->size;
-                       return(region->virt);
-               }
-       }
-
-       return(0);
-}
-
-int setup_iomem(void)
-{
-       struct iomem_region *region = iomem_regions;
-       unsigned long iomem_start = high_physmem + PAGE_SIZE;
-       int err;
-
-       while(region != NULL){
-               err = os_map_memory((void *) iomem_start, region->fd, 0, 
-                                   region->size, 1, 1, 0);
-               if(err)
-                       printk("Mapping iomem region for driver '%s' failed, "
-                              "errno = %d\n", region->driver, -err);
-               else {
-                       region->virt = iomem_start;
-                       region->phys = __pa(region->virt);
-               }
-
-               iomem_start += region->size + PAGE_SIZE;
-               region = region->next;
-       }
-
-       return(0);
-}
-
-__initcall(setup_iomem);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 4c3aa45..694a9c9 100644 (file)
@@ -9,12 +9,10 @@
 #include <sched.h>
 #include <errno.h>
 #include <stdarg.h>
-#include <fcntl.h>
 #include <stdlib.h>
 #include <setjmp.h>
 #include <sys/time.h>
 #include <sys/ptrace.h>
-#include <sys/ioctl.h>
 #include <sys/wait.h>
 #include <sys/mman.h>
 #include <asm/ptrace.h>
@@ -47,7 +45,7 @@ void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
        int flags = 0, pages;
 
        if(sig_stack != NULL){
-               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
+               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
                set_sigstack(sig_stack, pages * page_size());
                flags = SA_ONSTACK;
        }
@@ -58,7 +56,7 @@ void init_new_thread_signals(int altstack)
 {
        int flags = altstack ? SA_ONSTACK : 0;
 
-       set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
+       set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags, 
                    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
        set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, 
                    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
@@ -71,8 +69,7 @@ void init_new_thread_signals(int altstack)
        set_handler(SIGWINCH, (__sighandler_t) sig_handler, flags, 
                    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
        set_handler(SIGUSR2, (__sighandler_t) sig_handler, 
-                   SA_NOMASK | flags, -1);
-       (void) CHOOSE_MODE(signal(SIGCHLD, SIG_IGN), (void *) 0);
+                   flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
        signal(SIGHUP, SIG_IGN);
 
        init_irq_signals(altstack);
@@ -122,24 +119,19 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
 
        /* Start the process and wait for it to kill itself */
        new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
-       if(new_pid < 0) return(-errno);
-       while((err = waitpid(new_pid, &status, 0) < 0) && (errno == EINTR)) ;
-       if(err < 0) panic("Waiting for outer trampoline failed - errno = %d", 
-                         errno);
-       if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
-               panic("outer trampoline didn't exit with SIGKILL");
+       if(new_pid < 0) 
+               return(new_pid);
 
-       return(arg.pid);
-}
+       CATCH_EINTR(err = waitpid(new_pid, &status, 0));
+       if(err < 0) 
+               panic("Waiting for outer trampoline failed - errno = %d", 
+                     errno);
 
-void suspend_new_thread(int fd)
-{
-       char c;
-
-       os_stop_process(os_getpid());
+       if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
+               panic("outer trampoline didn't exit with SIGKILL, "
+                     "status = %d", status);
 
-       if(read(fd, &c, sizeof(c)) != sizeof(c))
-               panic("read failed in suspend_new_thread");
+       return(arg.pid);
 }
 
 static int ptrace_child(void *arg)
@@ -168,7 +160,7 @@ static int start_ptraced_child(void **stack_out)
        pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
        if(pid < 0)
                panic("check_ptrace : clone failed, errno = %d", errno);
-       n = waitpid(pid, &status, WUNTRACED);
+       CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if(n < 0)
                panic("check_ptrace : wait failed, errno = %d", errno);
        if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
@@ -185,7 +177,7 @@ static void stop_ptraced_child(int pid, void *stack, int exitcode)
 
        if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
                panic("check_ptrace : ptrace failed, errno = %d", errno);
-       n = waitpid(pid, &status, 0);
+       CATCH_EINTR(n = waitpid(pid, &status, 0));
        if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode))
                panic("check_ptrace : child exited with status 0x%x", status);
 
@@ -205,7 +197,7 @@ void __init check_ptrace(void)
                if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
                        panic("check_ptrace : ptrace failed, errno = %d", 
                              errno);
-               n = waitpid(pid, &status, WUNTRACED);
+               CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
                if(n < 0)
                        panic("check_ptrace : wait failed, errno = %d", errno);
                if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
@@ -229,11 +221,11 @@ void __init check_ptrace(void)
 
 int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
 {
-       jmp_buf buf;
+       sigjmp_buf buf;
        int n;
 
        *jmp_ptr = &buf;
-       n = setjmp(buf);
+       n = sigsetjmp(buf, 1);
        if(n != 0)
                return(n);
        (*fn)(arg);
@@ -273,7 +265,7 @@ int can_do_skas(void)
        stop_ptraced_child(pid, stack, 1);
 
        printf("Checking for /proc/mm...");
-       if(access("/proc/mm", W_OK)){
+       if(os_access("/proc/mm", OS_ACC_W_OK) < 0){
                printf("not found\n");
                ret = 0;
        }
index e17600a..8eb2d3b 100644 (file)
@@ -16,6 +16,8 @@
 #include "linux/module.h"
 #include "linux/init.h"
 #include "linux/capability.h"
+#include "linux/vmalloc.h"
+#include "linux/spinlock.h"
 #include "asm/unistd.h"
 #include "asm/mman.h"
 #include "asm/segment.h"
@@ -23,7 +25,6 @@
 #include "asm/pgtable.h"
 #include "asm/processor.h"
 #include "asm/tlbflush.h"
-#include "asm/spinlock.h"
 #include "asm/uaccess.h"
 #include "asm/user.h"
 #include "user_util.h"
@@ -52,17 +53,12 @@ struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
 
 struct task_struct *get_task(int pid, int require)
 {
-        struct task_struct *task, *ret;
+        struct task_struct *ret;
 
-        ret = NULL;
         read_lock(&tasklist_lock);
-        for_each_process(task){
-                if(task->pid == pid){
-                        ret = task;
-                        break;
-                }
-        }
+       ret = find_task_by_pid(pid);
         read_unlock(&tasklist_lock);
+
         if(require && (ret == NULL)) panic("get_task couldn't find a task\n");
         return(ret);
 }
@@ -95,7 +91,8 @@ unsigned long alloc_stack(int order, int atomic)
        int flags = GFP_KERNEL;
 
        if(atomic) flags |= GFP_ATOMIC;
-       if((page = __get_free_pages(flags, order)) == 0)
+       page = __get_free_pages(flags, order);
+       if(page == 0)
                return(0);
        stack_protections(page);
        return(page);
@@ -103,13 +100,15 @@ unsigned long alloc_stack(int order, int atomic)
 
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
 {
-       struct task_struct *p;
+       int pid;
 
        current->thread.request.u.thread.proc = fn;
        current->thread.request.u.thread.arg = arg;
-       p = do_fork(CLONE_VM | flags, 0, NULL, 0, NULL, NULL);
-       if(IS_ERR(p)) panic("do_fork failed in kernel_thread");
-       return(p->pid);
+       pid = do_fork(CLONE_VM | CLONE_UNTRACED | flags, 0, NULL, 0, NULL, 
+                     NULL);
+       if(pid < 0)
+               panic("do_fork failed in kernel_thread, errno = %d", pid);
+       return(pid);
 }
 
 void switch_mm(struct mm_struct *prev, struct mm_struct *next, 
@@ -129,7 +128,7 @@ void set_current(void *t)
                { external_pid(task), task });
 }
 
-void *switch_to(void *prev, void *next, void *last)
+void *_switch_to(void *prev, void *next, void *last)
 {
        return(CHOOSE_MODE(switch_to_tt(prev, next), 
                           switch_to_skas(prev, next)));
@@ -149,7 +148,7 @@ void release_thread(struct task_struct *task)
 void exit_thread(void)
 {
        CHOOSE_MODE(exit_thread_tt(), exit_thread_skas());
-       unprotect_stack((unsigned long) current->thread_info);
+       unprotect_stack((unsigned long) current_thread);
 }
  
 void *get_current(void)
@@ -157,13 +156,15 @@ void *get_current(void)
        return(current);
 }
 
+void prepare_to_copy(struct task_struct *tsk)
+{
+}
+
 int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
                unsigned long stack_top, struct task_struct * p, 
                struct pt_regs *regs)
 {
        p->thread = (struct thread_struct) INIT_THREAD;
-       p->thread.kernel_stack = 
-               (unsigned long) p->thread_info + 2 * PAGE_SIZE;
        return(CHOOSE_MODE_PROC(copy_thread_tt, copy_thread_skas, nr, 
                                clone_flags, sp, stack_top, p, regs));
 }
@@ -190,7 +191,7 @@ int current_pid(void)
 
 void default_idle(void)
 {
-       idle_timer();
+       uml_idle_timer();
 
        atomic_inc(&init_mm.mm_count);
        current->mm = &init_mm;
@@ -299,6 +300,11 @@ void *um_kmalloc_atomic(int size)
        return(kmalloc(size, GFP_ATOMIC));
 }
 
+void *um_vmalloc(int size)
+{
+       return(vmalloc(size));
+}
+
 unsigned long get_fault_addr(void)
 {
        return((unsigned long) current->thread.fault_addr);
@@ -318,8 +324,7 @@ int user_context(unsigned long sp)
        unsigned long stack;
 
        stack = sp & (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER);
-       stack += 2 * PAGE_SIZE;
-       return(stack != current->thread.kernel_stack);
+       return(stack != (unsigned long) current_thread);
 }
 
 extern void remove_umid_dir(void);
@@ -367,10 +372,15 @@ int clear_user_proc(void *buf, int size)
        return(clear_user(buf, size));
 }
 
+int strlen_user_proc(char *str)
+{
+       return(strlen_user(str));
+}
+
 int smp_sigio_handler(void)
 {
 #ifdef CONFIG_SMP
-       int cpu = current->thread_info->cpu;
+       int cpu = current_thread->cpu;
        IPI_handler(cpu);
        if(cpu != 0)
                return(1);
@@ -385,7 +395,7 @@ int um_in_interrupt(void)
 
 int cpu(void)
 {
-       return(current->thread_info->cpu);
+       return(current_thread->cpu);
 }
 
 /*
index c68c937..5ca4ef0 100644 (file)
@@ -58,6 +58,8 @@ int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
@@ -302,8 +304,17 @@ int sys_ptrace(long request, long pid, long addr, long data)
        return ret;
 }
 
-void syscall_trace(void)
+void syscall_trace(union uml_pt_regs *regs, int entryexit)
 {
+       if (unlikely(current->audit_context)) {
+               if (!entryexit)
+                       audit_syscall_entry(current, regs->orig_eax,
+                                           regs->ebx, regs->ecx,
+                                           regs->edx, regs->esi);
+               else
+                       audit_syscall_exit(current, regs->eax);
+       }
+
        if (!test_thread_flag(TIF_SYSCALL_TRACE))
                return;
        if (!(current->ptrace & PT_PTRACED))
@@ -311,11 +322,8 @@ void syscall_trace(void)
 
        /* the 0x80 provides a way for the tracing parent to distinguish
           between a syscall stop and SIGTRAP delivery */
-       current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
-                                       ? 0x80 : 0);
-       current->state = TASK_STOPPED;
-       notify_parent(current, SIGCHLD);
-       schedule();
+       ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
+                                ? 0x80 : 0));
 
        /*
         * this isn't the same as continuing with a signal, but it will do
index 3e4ab29..207f89d 100644 (file)
@@ -15,6 +15,7 @@
 #ifdef CONFIG_SMP
 static void kill_idlers(int me)
 {
+#ifdef CONFIG_MODE_TT
        struct task_struct *p;
        int i;
 
@@ -23,6 +24,7 @@ static void kill_idlers(int me)
                if((p != NULL) && (p->thread.mode.tt.extern_pid != me))
                        os_kill_process(p->thread.mode.tt.extern_pid, 0);
        }
+#endif
 }
 #endif
 
index 02272e6..2cb3911 100644 (file)
@@ -6,26 +6,33 @@
 #include "linux/kernel.h"
 #include "linux/list.h"
 #include "linux/slab.h"
-#include "asm/irq.h"
+#include "linux/signal.h"
+#include "linux/interrupt.h"
 #include "init.h"
 #include "sigio.h"
 #include "irq_user.h"
+#include "irq_kern.h"
 
 /* Protected by sigio_lock() called from write_sigio_workaround */
 static int sigio_irq_fd = -1;
 
-void sigio_interrupt(int irq, void *data, struct pt_regs *unused)
+static irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
 {
        read_sigio_fd(sigio_irq_fd);
        reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
+       return(IRQ_HANDLED);
 }
 
 int write_sigio_irq(int fd)
 {
-       if(um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
-                         SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", 
-                         NULL)){
-               printk("write_sigio_irq : um_request_irq failed\n");
+       int err;
+
+       err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
+                            SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", 
+                            NULL);
+       if(err){
+               printk("write_sigio_irq : um_request_irq failed, err = %d\n",
+                      err);
                return(-1);
        }
        sigio_irq_fd = fd;
index b5ce13d..80fe2cd 100644 (file)
@@ -7,7 +7,6 @@
 #include <stdlib.h>
 #include <termios.h>
 #include <pty.h>
-#include <fcntl.h>
 #include <signal.h>
 #include <errno.h>
 #include <string.h>
@@ -17,6 +16,7 @@
 #include "init.h"
 #include "user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "sigio.h"
 #include "helper.h"
 #include "os.h"
@@ -26,7 +26,7 @@ int pty_output_sigio = 0;
 int pty_close_sigio = 0;
 
 /* Used as a flag during SIGIO testing early in boot */
-static int got_sigio = 0;
+static volatile int got_sigio = 0;
 
 void __init handler(int sig)
 {
@@ -45,19 +45,18 @@ static void openpty_cb(void *arg)
 
        info->err = 0;
        if(openpty(&info->master, &info->slave, NULL, NULL, NULL))
-               info->err = errno;
+               info->err = -errno;
 }
 
 void __init check_one_sigio(void (*proc)(int, int))
 {
        struct sigaction old, new;
-       struct termios tt;
        struct openpty_arg pty = { .master = -1, .slave = -1 };
-       int master, slave, flags;
+       int master, slave, err;
 
        initial_thread_cb(openpty_cb, &pty);
        if(pty.err){
-               printk("openpty failed, errno = %d\n", pty.err);
+               printk("openpty failed, errno = %d\n", -pty.err);
                return;
        }
 
@@ -69,23 +68,14 @@ void __init check_one_sigio(void (*proc)(int, int))
                return;
        }
 
-       if(tcgetattr(master, &tt) < 0)
-               panic("check_sigio : tcgetattr failed, errno = %d\n", errno);
-       cfmakeraw(&tt);
-       if(tcsetattr(master, TCSADRAIN, &tt) < 0)
-               panic("check_sigio : tcsetattr failed, errno = %d\n", errno);
+       /* Not now, but complain so we now where we failed. */
+       err = raw(master);
+       if (err < 0)
+               panic("check_sigio : __raw failed, errno = %d\n", -err);
 
-       if((flags = fcntl(master, F_GETFL)) < 0)
-               panic("tty_fds : fcntl F_GETFL failed, errno = %d\n", errno);
-
-       if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
-          (fcntl(master, F_SETOWN, os_getpid()) < 0))
-               panic("check_sigio : fcntl F_SETFL or F_SETOWN failed, "
-                     "errno = %d\n", errno);
-
-       if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
-               panic("check_sigio : fcntl F_SETFL failed, errno = %d\n", 
-                     errno);
+       err = os_sigio_async(master, slave);
+       if(err < 0)
+               panic("tty_fds : sigio_async failed, err = %d\n", -err);
 
        if(sigaction(SIGIO, NULL, &old) < 0)
                panic("check_sigio : sigaction 1 failed, errno = %d\n", errno);
@@ -97,8 +87,8 @@ void __init check_one_sigio(void (*proc)(int, int))
        got_sigio = 0;
        (*proc)(master, slave);
                
-       close(master);
-       close(slave);
+       os_close_file(master);
+       os_close_file(slave);
 
        if(sigaction(SIGIO, &old, NULL) < 0)
                panic("check_sigio : sigaction 3 failed, errno = %d\n", errno);
@@ -112,25 +102,25 @@ static void tty_output(int master, int slave)
        printk("Checking that host ptys support output SIGIO...");
 
        memset(buf, 0, sizeof(buf));
-       while(write(master, buf, sizeof(buf)) > 0) ;
+
+       while(os_write_file(master, buf, sizeof(buf)) > 0) ;
        if(errno != EAGAIN)
                panic("check_sigio : write failed, errno = %d\n", errno);
-
-       while(((n = read(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
+       while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
 
        if(got_sigio){
                printk("Yes\n");
                pty_output_sigio = 1;
        }
-       else if(errno == EAGAIN) printk("No, enabling workaround\n");
-       else panic("check_sigio : read failed, errno = %d\n", errno);
+       else if(n == -EAGAIN) printk("No, enabling workaround\n");
+       else panic("check_sigio : read failed, err = %d\n", n);
 }
 
 static void tty_close(int master, int slave)
 {
        printk("Checking that host ptys support SIGIO on close...");
 
-       close(slave);
+       os_close_file(slave);
        if(got_sigio){
                printk("Yes\n");
                pty_close_sigio = 1;
@@ -140,7 +130,8 @@ static void tty_close(int master, int slave)
 
 void __init check_sigio(void)
 {
-       if(access("/dev/ptmx", R_OK) && access("/dev/ptyp0", R_OK)){
+       if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) &&
+          (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){
                printk("No pseudo-terminals available - skipping pty SIGIO "
                       "check\n");
                return;
@@ -201,11 +192,10 @@ static int write_sigio_thread(void *unused)
                        p = &fds->poll[i];
                        if(p->revents == 0) continue;
                        if(p->fd == sigio_private[1]){
-                               n = read(sigio_private[1], &c, sizeof(c));
+                               n = os_read_file(sigio_private[1], &c, sizeof(c));
                                if(n != sizeof(c))
                                        printk("write_sigio_thread : "
-                                              "read failed, errno = %d\n",
-                                              errno);
+                                              "read failed, err = %d\n", -n);
                                tmp = current_poll;
                                current_poll = next_poll;
                                next_poll = tmp;
@@ -218,10 +208,10 @@ static int write_sigio_thread(void *unused)
                                        (fds->used - i) * sizeof(*fds->poll));
                        }
 
-                       n = write(respond_fd, &c, sizeof(c));
+                       n = os_write_file(respond_fd, &c, sizeof(c));
                        if(n != sizeof(c))
                                printk("write_sigio_thread : write failed, "
-                                      "errno = %d\n", errno);
+                                      "err = %d\n", -n);
                }
        }
 }
@@ -252,15 +242,15 @@ static void update_thread(void)
        char c;
 
        flags = set_signals(0);
-       n = write(sigio_private[0], &c, sizeof(c));
+       n = os_write_file(sigio_private[0], &c, sizeof(c));
        if(n != sizeof(c)){
-               printk("update_thread : write failed, errno = %d\n", errno);
+               printk("update_thread : write failed, err = %d\n", -n);
                goto fail;
        }
 
-       n = read(sigio_private[0], &c, sizeof(c));
+       n = os_read_file(sigio_private[0], &c, sizeof(c));
        if(n != sizeof(c)){
-               printk("update_thread : read failed, errno = %d\n", errno);
+               printk("update_thread : read failed, err = %d\n", -n);
                goto fail;
        }
 
@@ -271,10 +261,10 @@ static void update_thread(void)
        if(write_sigio_pid != -1) 
                os_kill_process(write_sigio_pid, 1);
        write_sigio_pid = -1;
-       close(sigio_private[0]);
-       close(sigio_private[1]);        
-       close(write_sigio_fds[0]);
-       close(write_sigio_fds[1]);
+       os_close_file(sigio_private[0]);
+       os_close_file(sigio_private[1]);        
+       os_close_file(write_sigio_fds[0]);
+       os_close_file(write_sigio_fds[1]);
        sigio_unlock();
        set_signals(flags);
 }
@@ -369,15 +359,15 @@ void write_sigio_workaround(void)
                goto out;
 
        err = os_pipe(write_sigio_fds, 1, 1);
-       if(err){
+       if(err < 0){
                printk("write_sigio_workaround - os_pipe 1 failed, "
-                      "errno = %d\n", -err);
+                      "err = %d\n", -err);
                goto out;
        }
        err = os_pipe(sigio_private, 1, 1);
-       if(err){
+       if(err < 0){
                printk("write_sigio_workaround - os_pipe 2 failed, "
-                      "errno = %d\n", -err);
+                      "err = %d\n", -err);
                goto out_close1;
        }
        if(setup_initial_poll(sigio_private[1]))
@@ -399,11 +389,11 @@ void write_sigio_workaround(void)
        os_kill_process(write_sigio_pid, 1);
        write_sigio_pid = -1;
  out_close2:
-       close(sigio_private[0]);
-       close(sigio_private[1]);        
+       os_close_file(sigio_private[0]);
+       os_close_file(sigio_private[1]);        
  out_close1:
-       close(write_sigio_fds[0]);
-       close(write_sigio_fds[1]);
+       os_close_file(write_sigio_fds[0]);
+       os_close_file(write_sigio_fds[1]);
        sigio_unlock();
 }
 
@@ -412,10 +402,16 @@ int read_sigio_fd(int fd)
        int n;
        char c;
 
-       n = read(fd, &c, sizeof(c));
+       n = os_read_file(fd, &c, sizeof(c));
        if(n != sizeof(c)){
-               printk("read_sigio_fd - read failed, errno = %d\n", errno);
-               return(-errno);
+               if(n < 0) {
+                       printk("read_sigio_fd - read failed, err = %d\n", -n);
+                       return(n);
+               } 
+               else { 
+                       printk("read_sigio_fd - short read, bytes = %d\n", n);
+                       return(-EIO);
+               }
        }
        return(n);
 }
index 6e13847..5edb071 100644 (file)
@@ -36,7 +36,7 @@ static void force_segv(int sig)
        if(sig == SIGSEGV){
                struct k_sigaction *ka;
 
-               ka = &current->sig->action[SIGSEGV - 1];
+               ka = &current->sighand->action[SIGSEGV - 1];
                ka->sa.sa_handler = SIG_DFL;
        }
        force_sig(SIGSEGV, current);
@@ -60,10 +60,10 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
        int err, ret;
 
        ret = 0;
+       /* Always make any pending restarted system calls return -EINTR */
+       current_thread_info()->restart_block.fn = do_no_restart_syscall;
        switch(error){
        case -ERESTART_RESTARTBLOCK:
-               current_thread_info()->restart_block.fn = 
-                       do_no_restart_syscall;
        case -ERESTARTNOHAND:
                ret = -EINTR;
                break;
@@ -142,7 +142,7 @@ static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset, int error)
                return(0);
 
        /* Whee!  Actually deliver the signal.  */
-       ka = &current->sig->action[sig -1 ];
+       ka = &current->sighand->action[sig -1 ];
        err = handle_signal(regs, sig, ka, &info, oldset, error);
        if(!err) return(1);
 
@@ -201,7 +201,7 @@ int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
        }
 }
 
-int sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize)
+int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
 {
        sigset_t saveset, newset;
 
@@ -227,20 +227,59 @@ int sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize)
        }
 }
 
+int sys_sigaction(int sig, const struct old_sigaction __user *act,
+                        struct old_sigaction __user *oact)
+{
+       struct k_sigaction new_ka, old_ka;
+       int ret;
+
+       if (act) {
+               old_sigset_t mask;
+               if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
+                   __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
+                   __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
+                       return -EFAULT;
+               __get_user(new_ka.sa.sa_flags, &act->sa_flags);
+               __get_user(mask, &act->sa_mask);
+               siginitset(&new_ka.sa.sa_mask, mask);
+       }
+
+       ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
+
+       if (!ret && oact) {
+               if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
+                   __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
+                   __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
+                       return -EFAULT;
+               __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
+               __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
+       }
+
+       return ret;
+}
+
+int sys_sigaltstack(const stack_t *uss, stack_t *uoss)
+{
+       return(do_sigaltstack(uss, uoss, PT_REGS_SP(&current->thread.regs)));
+}
+
+extern int userspace_pid[];
+
 static int copy_sc_from_user(struct pt_regs *to, void *from, 
                             struct arch_frame_data *arch)
 {
        int ret;
 
        ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from, arch),
-                         copy_sc_from_user_skas(&to->regs, from));
+                         copy_sc_from_user_skas(userspace_pid[0], 
+                                                &to->regs, from));
        return(ret);
 }
 
 int sys_sigreturn(struct pt_regs regs)
 {
-       void *sc = sp_to_sc(PT_REGS_SP(&current->thread.regs));
-       void *mask = sp_to_mask(PT_REGS_SP(&current->thread.regs));
+       void __user *sc = sp_to_sc(PT_REGS_SP(&current->thread.regs));
+       void __user *mask = sp_to_mask(PT_REGS_SP(&current->thread.regs));
        int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
 
        spin_lock_irq(&current->sighand->siglock);
@@ -257,8 +296,8 @@ int sys_sigreturn(struct pt_regs regs)
 
 int sys_rt_sigreturn(struct pt_regs regs)
 {
-       struct ucontext *uc = sp_to_uc(PT_REGS_SP(&current->thread.regs));
-       void *fp;
+       unsigned long sp = PT_REGS_SP(&current->thread.regs);
+       struct ucontext __user *uc = sp_to_uc(sp);
        int sig_size = _NSIG_WORDS * sizeof(unsigned long);
 
        spin_lock_irq(&current->sighand->siglock);
@@ -266,7 +305,6 @@ int sys_rt_sigreturn(struct pt_regs regs)
        sigdelsetmask(&current->blocked, ~_BLOCKABLE);
        recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
-       fp = (void *) (((unsigned long) uc) + sizeof(struct ucontext));
        copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext,
                          &signal_frame_si.common.arch);
        return(PT_REGS_SYSCALL_RET(&current->thread.regs));
index 72c7995..85f9469 100644 (file)
@@ -5,20 +5,24 @@
 
 obj-y = exec_kern.o exec_user.o mem.o mem_user.o mmu.o process.o \
        process_kern.o syscall_kern.o syscall_user.o time.o tlb.o trap_user.o \
-       sys-$(SUBARCH)/
+       uaccess.o sys-$(SUBARCH)/
+
+host-progs     := util/mk_ptregs
+clean-files    := include/skas_ptregs.h
 
 USER_OBJS = $(filter %_user.o,$(obj-y)) process.o time.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
-include/skas_ptregs.h : util/mk_ptregs
-       util/mk_ptregs > $@
-
-util/mk_ptregs :
-       $(MAKE) -C util
+$(TOPDIR)/arch/um/include/skas_ptregs.h : $(src)/util/mk_ptregs
+       @echo -n '  Generating $@'
+       @$< > $@.tmp
+       @if [ -r $@ ] && cmp -s $@ $@.tmp; then \
+               echo ' (unchanged)'; \
+               rm -f $@.tmp; \
+       else \
+               echo ' (updated)'; \
+               mv -f $@.tmp $@; \
+       fi
 
 $(USER_OBJS) : %.o: %.c
        $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
-
-clean :
-       $(MAKE) -C util clean
-       $(RM) -f include/skas_ptregs.h
index c9942b6..d50633a 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/ptrace.h>
 #include "user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "os.h"
 #include "time_user.h"
 
@@ -26,7 +27,7 @@ static int user_thread_tramp(void *arg)
 
 int user_thread(unsigned long stack, int flags)
 {
-       int pid, status;
+       int pid, status, err;
 
        pid = clone(user_thread_tramp, (void *) stack_sp(stack), 
                    flags | CLONE_FILES | SIGCHLD, NULL);
@@ -35,7 +36,8 @@ int user_thread(unsigned long stack, int flags)
                return(pid);
        }
 
-       if(waitpid(pid, &status, WUNTRACED) < 0){
+       CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
+       if(err < 0){
                printk("user_thread - waitpid failed, errno = %d\n", errno);
                return(-errno);
        }
index 7516206..ca5b840 100644 (file)
@@ -6,20 +6,24 @@
 #ifndef __MODE_SKAS_H__
 #define __MODE_SKAS_H__
 
+#include <sysdep/ptrace.h>
+
 extern unsigned long exec_regs[];
 extern unsigned long exec_fp_regs[];
 extern unsigned long exec_fpx_regs[];
 extern int have_fpx_regs;
 
 extern void user_time_init_skas(void);
-extern int copy_sc_from_user_skas(union uml_pt_regs *regs, void *from_ptr);
-extern int copy_sc_to_user_skas(void *to_ptr, void *fp, 
+extern int copy_sc_from_user_skas(int pid, union uml_pt_regs *regs, 
+                                 void *from_ptr);
+extern int copy_sc_to_user_skas(int pid, void *to_ptr, void *fp, 
                                union uml_pt_regs *regs, 
                                unsigned long fault_addr, int fault_type);
 extern void sig_handler_common_skas(int sig, void *sc_ptr);
 extern void halt_skas(void);
 extern void reboot_skas(void);
 extern void kill_off_processes_skas(void);
+extern int is_skas_winch(int pid, int fd, void *data);
 
 #endif
 
index d9614f6..0bbc975 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "sysdep/ptrace.h"
 
-extern int userspace_pid;
+extern int userspace_pid[];
 
 extern void switch_threads(void *me, void *next);
 extern void thread_wait(void *sw, void *fb);
@@ -32,7 +32,7 @@ extern int singlestepping_skas(void);
 extern int new_mm(int from);
 extern void save_registers(union uml_pt_regs *regs);
 extern void restore_registers(union uml_pt_regs *regs);
-extern void start_userspace(void);
+extern void start_userspace(int cpu);
 extern void init_registers(int pid);
 
 #endif
index d28c4b1..0d6f30b 100644 (file)
@@ -6,20 +6,12 @@
 #ifndef __SKAS_UACCESS_H
 #define __SKAS_UACCESS_H
 
-#include "linux/string.h"
-#include "linux/sched.h"
-#include "linux/err.h"
-#include "asm/processor.h"
-#include "asm/pgtable.h"
 #include "asm/errno.h"
-#include "asm/current.h"
-#include "asm/a.out.h"
-#include "kern_util.h"
 
 #define access_ok_skas(type, addr, size) \
        ((segment_eq(get_fs(), KERNEL_DS)) || \
         (((unsigned long) (addr) < TASK_SIZE) && \
-         ((unsigned long) (addr) + (size) < TASK_SIZE)))
+         ((unsigned long) (addr) + (size) <= TASK_SIZE)))
 
 static inline int verify_area_skas(int type, const void * addr, 
                                   unsigned long size)
@@ -27,197 +19,12 @@ static inline int verify_area_skas(int type, const void * addr,
        return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
 }
 
-static inline unsigned long maybe_map(unsigned long virt, int is_write)
-{
-       pte_t pte;
-
-       void *phys = um_virt_to_phys(current, virt, &pte);
-       int dummy_code;
-
-       if(IS_ERR(phys) || (is_write && !pte_write(pte))){
-               if(handle_page_fault(virt, 0, is_write, 0, &dummy_code))
-                       return(0);
-               phys = um_virt_to_phys(current, virt, NULL);
-       }
-       return((unsigned long) __va((unsigned long) phys));
-}
-
-static inline int buffer_op(unsigned long addr, int len, 
-                           int (*op)(unsigned long addr, int len, void *arg),
-                           void *arg)
-{
-       int size = min(PAGE_ALIGN(addr) - addr, (unsigned long) len);
-       int remain = len, n;
-
-       n = (*op)(addr, size, arg);
-       if(n != 0)
-               return(n < 0 ? remain : 0);
-
-       addr += size;
-       remain -= size;
-       if(remain == 0) 
-               return(0);
-
-       while(addr < ((addr + remain) & PAGE_MASK)){
-               n = (*op)(addr, PAGE_SIZE, arg);
-               if(n != 0)
-                       return(n < 0 ? remain : 0);
-
-               addr += PAGE_SIZE;
-               remain -= PAGE_SIZE;
-       }
-       if(remain == 0)
-               return(0);
-
-       n = (*op)(addr, remain, arg);
-       if(n != 0)
-               return(n < 0 ? remain : 0);
-       return(0);
-}
-
-static inline int copy_chunk_from_user(unsigned long from, int len, void *arg)
-{
-       unsigned long *to_ptr = arg, to = *to_ptr;
-
-       from = maybe_map(from, 0);
-       if(from == 0)
-               return(-1);
-
-       memcpy((void *) to, (void *) from, len);
-       *to_ptr += len;
-       return(0);
-}
-
-static inline int copy_from_user_skas(void *to, const void *from, int n)
-{
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               memcpy(to, from, n);
-               return(0);
-       }
-
-       return(access_ok_skas(VERIFY_READ, from, n) ?
-              buffer_op((unsigned long) from, n, copy_chunk_from_user, &to) :
-              n);
-}
-
-static inline int copy_chunk_to_user(unsigned long to, int len, void *arg)
-{
-       unsigned long *from_ptr = arg, from = *from_ptr;
-
-       to = maybe_map(to, 1);
-       if(to == 0)
-               return(-1);
-
-       memcpy((void *) to, (void *) from, len);
-       *from_ptr += len;
-       return(0);
-}
-
-static inline int copy_to_user_skas(void *to, const void *from, int n)
-{
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               memcpy(to, from, n);
-               return(0);
-       }
-
-       return(access_ok_skas(VERIFY_WRITE, to, n) ?
-              buffer_op((unsigned long) to, n, copy_chunk_to_user, &from) :
-              n);
-}
-
-static inline int strncpy_chunk_from_user(unsigned long from, int len, 
-                                         void *arg)
-{
-        char **to_ptr = arg, *to = *to_ptr;
-       int n;
-
-       from = maybe_map(from, 0);
-       if(from == 0)
-               return(-1);
-
-       strncpy(to, (void *) from, len);
-       n = strnlen(to, len);
-       *to_ptr += n;
-
-       if(n < len) 
-               return(1);
-       return(0);
-}
-
-static inline int strncpy_from_user_skas(char *dst, const char *src, int count)
-{
-       int n;
-       char *ptr = dst;
-
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               strncpy(dst, src, count);
-               return(strnlen(dst, count));
-       }
-
-       if(!access_ok_skas(VERIFY_READ, src, 1))
-               return(-EFAULT);
-
-       n = buffer_op((unsigned long) src, count, strncpy_chunk_from_user, 
-                     &ptr);
-       if(n != 0)
-               return(-EFAULT);
-       return(strnlen(dst, count));
-}
-
-static inline int clear_chunk(unsigned long addr, int len, void *unused)
-{
-       addr = maybe_map(addr, 1);
-       if(addr == 0) 
-               return(-1);
-
-       memset((void *) addr, 0, len);
-       return(0);
-}
-
-static inline int __clear_user_skas(void *mem, int len)
-{
-       return(buffer_op((unsigned long) mem, len, clear_chunk, NULL));
-}
-
-static inline int clear_user_skas(void *mem, int len)
-{
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               memset(mem, 0, len);
-               return(0);
-       }
-
-       return(access_ok_skas(VERIFY_WRITE, mem, len) ? 
-              buffer_op((unsigned long) mem, len, clear_chunk, NULL) : len);
-}
-
-static inline int strnlen_chunk(unsigned long str, int len, void *arg)
-{
-       int *len_ptr = arg, n;
-
-       str = maybe_map(str, 0);
-       if(str == 0) 
-               return(-1);
-
-       n = strnlen((void *) str, len);
-       *len_ptr += n;
-
-       if(n < len)
-               return(1);
-       return(0);
-}
-
-static inline int strnlen_user_skas(const void *str, int len)
-{
-       int count = 0, n;
-
-       if(segment_eq(get_fs(), KERNEL_DS))
-               return(strnlen(str, len) + 1);
-
-       n = buffer_op((unsigned long) str, len, strnlen_chunk, &count);
-       if(n == 0)
-               return(count + 1);
-       return(-EFAULT);
-}
+extern int copy_from_user_skas(void *to, const void *from, int n);
+extern int copy_to_user_skas(void *to, const void *from, int n);
+extern int strncpy_from_user_skas(char *dst, const char *src, int count);
+extern int __clear_user_skas(void *mem, int len);
+extern int clear_user_skas(void *mem, int len);
+extern int strnlen_user_skas(const void *str, int len);
 
 #endif
 
index d163090..1909125 100644 (file)
@@ -7,6 +7,7 @@
 #include <sys/mman.h>
 #include <sys/ptrace.h>
 #include "mem_user.h"
+#include "mem.h"
 #include "user.h"
 #include "os.h"
 #include "proc_mm.h"
@@ -15,12 +16,12 @@ void map(int fd, unsigned long virt, unsigned long phys, unsigned long len,
         int r, int w, int x)
 {
        struct proc_mm_op map;
-       struct mem_region *region;
-       int prot, n;
+       __u64 offset;
+       int prot, n, phys_fd;
 
        prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | 
                (x ? PROT_EXEC : 0);
-       region = phys_region(phys);
+       phys_fd = phys_mapping(phys, &offset);
 
        map = ((struct proc_mm_op) { .op        = MM_MMAP,
                                     .u         = 
@@ -30,12 +31,12 @@ void map(int fd, unsigned long virt, unsigned long phys, unsigned long len,
                                         .prot          = prot,
                                         .flags         = MAP_SHARED | 
                                                          MAP_FIXED,
-                                        .fd            = region->fd,
-                                        .offset        = phys_offset(phys)
+                                        .fd            = phys_fd,
+                                        .offset        = offset
                                       } } } );
        n = os_write_file(fd, &map, sizeof(map));
        if(n != sizeof(map)) 
-               printk("map : /proc/mm map failed, errno = %d\n", errno);
+               printk("map : /proc/mm map failed, err = %d\n", -n);
 }
 
 int unmap(int fd, void *addr, int len)
@@ -49,8 +50,13 @@ int unmap(int fd, void *addr, int len)
                                         { .addr        = (unsigned long) addr,
                                           .len         = len } } } );
        n = os_write_file(fd, &unmap, sizeof(unmap));
-       if((n != 0) && (n != sizeof(unmap)))
-               return(-errno);
+       if(n != sizeof(unmap)) {
+               if(n < 0) 
+                       return(n);
+               else if(n > 0) 
+                       return(-EIO);
+       }
+
        return(0);
 }
 
@@ -71,11 +77,15 @@ int protect(int fd, unsigned long addr, unsigned long len, int r, int w,
                                           .prot        = prot } } } );
 
        n = os_write_file(fd, &protect, sizeof(protect));
-       if((n != 0) && (n != sizeof(protect))){
+       if(n != sizeof(protect)) {
+               if(n == 0) return(0);
+
                if(must_succeed)
-                       panic("protect failed, errno = %d", errno);
-               return(-errno);
+                       panic("protect failed, err = %d", -n);
+
+               return(-EIO);
        }
+
        return(0);
 }
 
index 5911cdd..6cb9a6d 100644 (file)
@@ -22,9 +22,11 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
        else from = -1;
 
        mm->context.skas.mm_fd = new_mm(from);
-       if(mm->context.skas.mm_fd < 0)
-               panic("init_new_context_skas - new_mm failed, errno = %d\n",
-                     mm->context.skas.mm_fd);
+       if(mm->context.skas.mm_fd < 0){
+               printk("init_new_context_skas - new_mm failed, errno = %d\n",
+                      mm->context.skas.mm_fd);
+               return(mm->context.skas.mm_fd);
+       }
 
        return(0);
 }
index cb91f8c..a1a6b8d 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <stdlib.h>
+#include <unistd.h>
 #include <errno.h>
 #include <signal.h>
 #include <setjmp.h>
 #include "os.h"
 #include "proc_mm.h"
 #include "skas_ptrace.h"
+#include "chan_user.h"
+#include "signal_user.h"
+
+int is_skas_winch(int pid, int fd, void *data)
+{
+       if(pid != getpid())
+               return(0);
+
+       register_winch_irq(-1, fd, -1, data);
+       return(1);
+}
+
+/* These are set once at boot time and not changed thereafter */
 
 unsigned long exec_regs[FRAME_SIZE];
 unsigned long exec_fp_regs[HOST_FP_SIZE];
@@ -48,11 +62,11 @@ static void handle_trap(int pid, union uml_pt_regs *regs)
        int err, syscall_nr, status;
 
        syscall_nr = PT_SYSCALL_NR(regs->skas.regs);
+       UPT_SYSCALL_NR(regs) = syscall_nr;
        if(syscall_nr < 1){
                relay_signal(SIGTRAP, regs);
                return;
        }
-       UPT_SYSCALL_NR(regs) = syscall_nr;
 
        err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_getpid);
        if(err < 0)
@@ -64,7 +78,7 @@ static void handle_trap(int pid, union uml_pt_regs *regs)
                panic("handle_trap - continuing to end of syscall failed, "
                      "errno = %d\n", errno);
 
-       err = waitpid(pid, &status, WUNTRACED);
+       CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
        if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
                panic("handle_trap - failed to wait at end of syscall, "
                      "errno = %d, status = %d\n", errno, status);
@@ -72,8 +86,6 @@ static void handle_trap(int pid, union uml_pt_regs *regs)
        handle_syscall(regs);
 }
 
-int userspace_pid;
-
 static int userspace_tramp(void *arg)
 {
        init_new_thread_signals(0);
@@ -83,7 +95,11 @@ static int userspace_tramp(void *arg)
        return(0);
 }
 
-void start_userspace(void)
+/* Each element set once, and only accessed by a single processor anyway */
+#define NR_CPUS 1
+int userspace_pid[NR_CPUS];
+
+void start_userspace(int cpu)
 {
        void *stack;
        unsigned long sp;
@@ -101,7 +117,7 @@ void start_userspace(void)
                panic("start_userspace : clone failed, errno = %d", errno);
 
        do {
-               n = waitpid(pid, &status, WUNTRACED);
+               CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
                if(n < 0)
                        panic("start_userspace : wait failed, errno = %d", 
                              errno);
@@ -114,21 +130,21 @@ void start_userspace(void)
        if(munmap(stack, PAGE_SIZE) < 0)
                panic("start_userspace : munmap failed, errno = %d\n", errno);
 
-       userspace_pid = pid;
+       userspace_pid[cpu] = pid;
 }
 
 void userspace(union uml_pt_regs *regs)
 {
-       int err, status, op;
+       int err, status, op, pid = userspace_pid[0];
 
        restore_registers(regs);
                
-       err = ptrace(PTRACE_SYSCALL, userspace_pid, 0, 0);
+       err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
        if(err)
                panic("userspace - PTRACE_SYSCALL failed, errno = %d\n", 
                       errno);
        while(1){
-               err = waitpid(userspace_pid, &status, WUNTRACED);
+               CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
                if(err < 0)
                        panic("userspace - waitpid failed, errno = %d\n", 
                              errno);
@@ -139,16 +155,17 @@ void userspace(union uml_pt_regs *regs)
                if(WIFSTOPPED(status)){
                        switch(WSTOPSIG(status)){
                        case SIGSEGV:
-                               handle_segv(userspace_pid);
+                               handle_segv(pid);
                                break;
                        case SIGTRAP:
-                               handle_trap(userspace_pid, regs);
+                               handle_trap(pid, regs);
                                break;
                        case SIGIO:
                        case SIGVTALRM:
                        case SIGILL:
                        case SIGBUS:
                        case SIGFPE:
+                       case SIGWINCH:
                                user_signal(WSTOPSIG(status), regs);
                                break;
                        default:
@@ -162,7 +179,7 @@ void userspace(union uml_pt_regs *regs)
 
                op = singlestepping_skas() ? PTRACE_SINGLESTEP : 
                        PTRACE_SYSCALL;
-               err = ptrace(op, userspace_pid, 0, 0);
+               err = ptrace(op, pid, 0, 0);
                if(err)
                        panic("userspace - PTRACE_SYSCALL failed, "
                              "errno = %d\n", errno);
@@ -172,33 +189,45 @@ void userspace(union uml_pt_regs *regs)
 void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
                void (*handler)(int))
 {
-       jmp_buf switch_buf, fork_buf;
+       unsigned long flags;
+       sigjmp_buf switch_buf, fork_buf;
 
        *switch_buf_ptr = &switch_buf;
        *fork_buf_ptr = &fork_buf;
 
-       if(setjmp(fork_buf) == 0)
+       /* Somewhat subtle - siglongjmp restores the signal mask before doing
+        * the longjmp.  This means that when jumping from one stack to another
+        * when the target stack has interrupts enabled, an interrupt may occur
+        * on the source stack.  This is bad when starting up a process because
+        * it's not supposed to get timer ticks until it has been scheduled.
+        * So, we disable interrupts around the sigsetjmp to ensure that 
+        * they can't happen until we get back here where they are safe.
+        */
+       flags = get_signals();
+       block_signals();
+       if(sigsetjmp(fork_buf, 1) == 0)
                new_thread_proc(stack, handler);
+       set_signals(flags);
 
        remove_sigstack();
 }
 
 void thread_wait(void *sw, void *fb)
 {
-       jmp_buf buf, **switch_buf = sw, *fork_buf;
+       sigjmp_buf buf, **switch_buf = sw, *fork_buf;
 
        *switch_buf = &buf;
        fork_buf = fb;
-       if(setjmp(buf) == 0)
-               longjmp(*fork_buf, 1);
+       if(sigsetjmp(buf, 1) == 0)
+               siglongjmp(*fork_buf, 1);
 }
 
-static int move_registers(int int_op, int fp_op, union uml_pt_regs *regs,
-                         unsigned long *fp_regs)
+static int move_registers(int pid, int int_op, int fp_op, 
+                         union uml_pt_regs *regs, unsigned long *fp_regs)
 {
-       if(ptrace(int_op, userspace_pid, 0, regs->skas.regs) < 0)
+       if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
                return(-errno);
-       if(ptrace(fp_op, userspace_pid, 0, fp_regs) < 0)
+       if(ptrace(fp_op, pid, 0, fp_regs) < 0)
                return(-errno);
        return(0);
 }
@@ -217,10 +246,11 @@ void save_registers(union uml_pt_regs *regs)
                fp_regs = regs->skas.fp;
        }
 
-       err = move_registers(PTRACE_GETREGS, fp_op, regs, fp_regs);
+       err = move_registers(userspace_pid[0], PTRACE_GETREGS, fp_op, regs, 
+                            fp_regs);
        if(err)
                panic("save_registers - saving registers failed, errno = %d\n",
-                     err);
+                     -err);
 }
 
 void restore_registers(union uml_pt_regs *regs)
@@ -237,42 +267,43 @@ void restore_registers(union uml_pt_regs *regs)
                fp_regs = regs->skas.fp;
        }
 
-       err = move_registers(PTRACE_SETREGS, fp_op, regs, fp_regs);
+       err = move_registers(userspace_pid[0], PTRACE_SETREGS, fp_op, regs, 
+                            fp_regs);
        if(err)
                panic("restore_registers - saving registers failed, "
-                     "errno = %d\n", err);
+                     "errno = %d\n", -err);
 }
 
 void switch_threads(void *me, void *next)
 {
-       jmp_buf my_buf, **me_ptr = me, *next_buf = next;
+       sigjmp_buf my_buf, **me_ptr = me, *next_buf = next;
        
        *me_ptr = &my_buf;
-       if(setjmp(my_buf) == 0)
-               longjmp(*next_buf, 1);
+       if(sigsetjmp(my_buf, 1) == 0)
+               siglongjmp(*next_buf, 1);
 }
 
-static jmp_buf initial_jmpbuf;
+static sigjmp_buf initial_jmpbuf;
 
 /* XXX Make these percpu */
 static void (*cb_proc)(void *arg);
 static void *cb_arg;
-static jmp_buf *cb_back;
+static sigjmp_buf *cb_back;
 
 int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
 {
-       jmp_buf **switch_buf = switch_buf_ptr;
+       sigjmp_buf **switch_buf = switch_buf_ptr;
        int n;
 
        *fork_buf_ptr = &initial_jmpbuf;
-       n = setjmp(initial_jmpbuf);
+       n = sigsetjmp(initial_jmpbuf, 1);
        if(n == 0)
                new_thread_proc((void *) stack, new_thread_handler);
        else if(n == 1)
                remove_sigstack();
        else if(n == 2){
                (*cb_proc)(cb_arg);
-               longjmp(*cb_back, 1);
+               siglongjmp(*cb_back, 1);
        }
        else if(n == 3){
                kmalloc_ok = 0;
@@ -282,7 +313,7 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
                kmalloc_ok = 0;
                return(1);
        }
-       longjmp(**switch_buf, 1);
+       siglongjmp(**switch_buf, 1);
 }
 
 void remove_sigstack(void)
@@ -297,15 +328,15 @@ void remove_sigstack(void)
 
 void initial_thread_cb_skas(void (*proc)(void *), void *arg)
 {
-       jmp_buf here;
+       sigjmp_buf here;
 
        cb_proc = proc;
        cb_arg = arg;
        cb_back = &here;
 
        block_signals();
-       if(setjmp(here) == 0)
-               longjmp(initial_jmpbuf, 2);
+       if(sigsetjmp(here, 1) == 0)
+               siglongjmp(initial_jmpbuf, 2);
        unblock_signals();
 
        cb_proc = NULL;
@@ -316,40 +347,21 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
 void halt_skas(void)
 {
        block_signals();
-       longjmp(initial_jmpbuf, 3);
+       siglongjmp(initial_jmpbuf, 3);
 }
 
 void reboot_skas(void)
 {
        block_signals();
-       longjmp(initial_jmpbuf, 4);
-}
-
-int new_mm(int from)
-{
-       struct proc_mm_op copy;
-       int n, fd = os_open_file("/proc/mm", of_write(OPENFLAGS()), 0);
-
-       if(fd < 0)
-               return(-errno);
-
-       if(from != -1){
-               copy = ((struct proc_mm_op) { .op       = MM_COPY_SEGMENTS,
-                                             .u        = 
-                                             { .copy_segments  = from } } );
-               n = os_write_file(fd, &copy, sizeof(copy));
-               if(n != sizeof(copy)) 
-                       printk("new_mm : /proc/mm copy_segments failed, "
-                              "errno = %d\n", errno);
-       }
-       return(fd);
+       siglongjmp(initial_jmpbuf, 4);
 }
 
 void switch_mm_skas(int mm_fd)
 {
        int err;
 
-       err = ptrace(PTRACE_SWITCH_MM, userspace_pid, 0, mm_fd);
+#warning need cpu pid in switch_mm_skas
+       err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0, mm_fd);
        if(err)
                panic("switch_mm_skas - PTRACE_SWITCH_MM failed, errno = %d\n",
                      errno);
@@ -357,7 +369,8 @@ void switch_mm_skas(int mm_fd)
 
 void kill_off_processes_skas(void)
 {
-       os_kill_process(userspace_pid, 1);
+#warning need to loop over userspace_pids in kill_off_processes_skas
+       os_kill_process(userspace_pid[0], 1);
 }
 
 void init_registers(int pid)
index 128146c..e16309d 100644 (file)
@@ -16,6 +16,8 @@
 #include "frame.h"
 #include "kern.h"
 #include "mode.h"
+#include "filehandle.h"
+#include "proc_mm.h"
 
 int singlestepping_skas(void)
 {
@@ -61,11 +63,13 @@ void new_thread_handler(int sig)
        thread_wait(&current->thread.mode.skas.switch_buf, 
                    current->thread.mode.skas.fork_buf);
 
-#ifdef CONFIG_SMP
-       schedule_tail(NULL);
-#endif
+       if(current->thread.prev_sched != NULL)
+               schedule_tail(current->thread.prev_sched);
        current->thread.prev_sched = NULL;
 
+       /* The return value is 1 if the kernel thread execs a process,
+        * 0 if it just exits
+        */
        n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
        if(n == 1)
                userspace(&current->thread.regs.regs);
@@ -93,11 +97,11 @@ void fork_handler(int sig)
                    current->thread.mode.skas.fork_buf);
        
        force_flush_all();
-#ifdef CONFIG_SMP
+       if(current->thread.prev_sched == NULL)
+               panic("blech");
+       
        schedule_tail(current->thread.prev_sched);
-#endif
        current->thread.prev_sched = NULL;
-       unblock_signals();
 
        userspace(&current->thread.regs.regs);
 }
@@ -128,15 +132,36 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
                handler = new_thread_handler;
        }
 
-       new_thread((void *) p->thread.kernel_stack, 
-                  &p->thread.mode.skas.switch_buf, 
+       new_thread(p->thread_info, &p->thread.mode.skas.switch_buf, 
                   &p->thread.mode.skas.fork_buf, handler);
        return(0);
 }
 
+int new_mm(int from)
+{
+       struct proc_mm_op copy;
+       int n, fd;
+
+       fd = open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
+       if(fd < 0)
+               return(fd);
+
+       if(from != -1){
+               copy = ((struct proc_mm_op) { .op       = MM_COPY_SEGMENTS,
+                                             .u        = 
+                                             { .copy_segments  = from } } );
+               n = os_write_file(fd, &copy, sizeof(copy));
+               if(n != sizeof(copy)) 
+                       printk("new_mm : /proc/mm copy_segments failed, "
+                              "err = %d\n", -n);
+       }
+
+       return(fd);
+}
+
 void init_idle_skas(void)
 {
-       cpu_tasks[current->thread_info->cpu].pid = os_getpid();
+       cpu_tasks[current_thread->cpu].pid = os_getpid();
        default_idle();
 }
 
@@ -160,27 +185,29 @@ static int start_kernel_proc(void *unused)
 
 int start_uml_skas(void)
 {
-       start_userspace();
+       start_userspace(0);
        capture_signal_stack();
 
        init_new_thread_signals(1);
-       idle_timer();
+       uml_idle_timer();
 
        init_task.thread.request.u.thread.proc = start_kernel_proc;
        init_task.thread.request.u.thread.arg = NULL;
-       return(start_idle_thread((void *) init_task.thread.kernel_stack,
+       return(start_idle_thread(init_task.thread_info,
                                 &init_task.thread.mode.skas.switch_buf,
                                 &init_task.thread.mode.skas.fork_buf));
 }
 
 int external_pid_skas(struct task_struct *task)
 {
-       return(userspace_pid);
+#warning Need to look up userspace_pid by cpu  
+       return(userspace_pid[0]);
 }
 
 int thread_pid_skas(struct task_struct *task)
 {
-       return(userspace_pid);
+#warning Need to look up userspace_pid by cpu  
+       return(userspace_pid[0]);
 }
 
 /*
index 2ad8271..3eeea05 100644 (file)
@@ -10,5 +10,3 @@ USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
 $(USER_OBJS) : %.o: %.c
        $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
-
-clean :
index 5f340e1..895d34c 100644 (file)
 #include "kern_util.h"
 #include "user.h"
 #include "sigcontext.h"
+#include "mode.h"
 
-extern int userspace_pid;
-
-int copy_sc_from_user_skas(union uml_pt_regs *regs, void *from_ptr)
+int copy_sc_from_user_skas(int pid, union uml_pt_regs *regs, void *from_ptr)
 {
        struct sigcontext sc, *from = from_ptr;
        unsigned long fpregs[FP_FRAME_SIZE];
@@ -41,13 +40,12 @@ int copy_sc_from_user_skas(union uml_pt_regs *regs, void *from_ptr)
        regs->skas.regs[EIP] = sc.eip;
        regs->skas.regs[CS] = sc.cs;
        regs->skas.regs[EFL] = sc.eflags;
-       regs->skas.regs[UESP] = sc.esp_at_signal;
        regs->skas.regs[SS] = sc.ss;
        regs->skas.fault_addr = sc.cr2;
        regs->skas.fault_type = FAULT_WRITE(sc.err);
        regs->skas.trap_type = sc.trapno;
 
-       err = ptrace(PTRACE_SETFPREGS, userspace_pid, 0, fpregs);
+       err = ptrace(PTRACE_SETFPREGS, pid, 0, fpregs);
        if(err < 0){
                printk("copy_sc_to_user - PTRACE_SETFPREGS failed, "
                       "errno = %d\n", errno);
@@ -57,8 +55,9 @@ int copy_sc_from_user_skas(union uml_pt_regs *regs, void *from_ptr)
        return(0);
 }
 
-int copy_sc_to_user_skas(void *to_ptr, void *fp, union uml_pt_regs *regs, 
-                        unsigned long fault_addr, int fault_type)
+int copy_sc_to_user_skas(int pid, void *to_ptr, void *fp, 
+                        union uml_pt_regs *regs, unsigned long fault_addr, 
+                        int fault_type)
 {
        struct sigcontext sc, *to = to_ptr;
        struct _fpstate *to_fp;
@@ -86,7 +85,7 @@ int copy_sc_to_user_skas(void *to_ptr, void *fp, union uml_pt_regs *regs,
        sc.err = TO_SC_ERR(fault_type);
        sc.trapno = regs->skas.trap_type;
 
-       err = ptrace(PTRACE_GETFPREGS, userspace_pid, 0, fpregs);
+       err = ptrace(PTRACE_GETFPREGS, pid, 0, fpregs);
        if(err < 0){
                printk("copy_sc_to_user - PTRACE_GETFPREGS failed, "
                       "errno = %d\n", errno);
index bc837a7..1d7eca5 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
index caccb77..34fd5f9 100644 (file)
@@ -22,7 +22,7 @@ void handle_syscall(union uml_pt_regs *regs)
 
        index = record_syscall_start(UPT_SYSCALL_NR(regs));
 
-       syscall_trace();
+       syscall_trace(regs, 1);
        result = execute_syscall(regs);
 
        REGS_SET_SYSCALL_RETURN(regs->skas.regs, result);
@@ -30,7 +30,7 @@ void handle_syscall(union uml_pt_regs *regs)
           (result == -ERESTARTNOINTR))
                do_signal(result);
 
-       syscall_trace();
+       syscall_trace(regs, 0);
        record_syscall_end(index, result);
 }
 
index 0906f65..9659370 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -19,8 +19,10 @@ void sig_handler_common_skas(int sig, void *sc_ptr)
        struct skas_regs *r;
        struct signal_info *info;
        int save_errno = errno;
+       int save_user;
 
        r = &TASK_REGS(get_current())->skas;
+       save_user = r->is_user;
        r->is_user = 0;
        r->fault_addr = SC_FAULT_ADDR(sc);
        r->fault_type = SC_FAULT_TYPE(sc);
@@ -33,16 +35,13 @@ void sig_handler_common_skas(int sig, void *sc_ptr)
        (*info->handler)(sig, (union uml_pt_regs *) r);
 
        errno = save_errno;
+       r->is_user = save_user;
 }
 
-extern int missed_ticks[];
-
 void user_signal(int sig, union uml_pt_regs *regs)
 {
        struct signal_info *info;
 
-       if(sig == SIGVTALRM)
-               missed_ticks[cpu()]++;
        regs->skas.is_user = 1;
        regs->skas.fault_addr = 0;
        regs->skas.fault_type = 0;
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
deleted file mode 100644 (file)
index ea82f19..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/* 
- * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/stddef.h"
-#include "linux/kernel.h"
-#include "linux/string.h"
-#include "linux/fs.h"
-#include "linux/highmem.h"
-#include "asm/page.h"
-#include "asm/pgtable.h"
-#include "asm/uaccess.h"
-#include "kern_util.h"
-
-extern void *um_virt_to_phys(struct task_struct *task, unsigned long addr, 
-                            pte_t *pte_out);
-
-static unsigned long maybe_map(unsigned long virt, int is_write)
-{
-       pte_t pte;
-       int err;
-
-       void *phys = um_virt_to_phys(current, virt, &pte);
-       int dummy_code;
-
-       if(IS_ERR(phys) || (is_write && !pte_write(pte))){
-               err = handle_page_fault(virt, 0, is_write, 0, &dummy_code);
-               if(err)
-                       return(0);
-               phys = um_virt_to_phys(current, virt, NULL);
-       }
-       return((unsigned long) phys);
-}
-
-static int do_op(unsigned long addr, int len, int is_write, 
-                int (*op)(unsigned long addr, int len, void *arg), void *arg)
-{
-       struct page *page;
-       int n;
-
-       addr = maybe_map(addr, is_write);
-       if(addr == -1)
-               return(-1);
-
-       page = phys_to_page(addr);
-       addr = (unsigned long) kmap(page) + (addr & ~PAGE_MASK);
-       n = (*op)(addr, len, arg);
-       kunmap(page);
-
-       return(n);
-}
-
-static int buffer_op(unsigned long addr, int len, int is_write,
-                    int (*op)(unsigned long addr, int len, void *arg),
-                    void *arg)
-{
-       int size = min(PAGE_ALIGN(addr) - addr, (unsigned long) len);
-       int remain = len, n;
-
-       n = do_op(addr, size, is_write, op, arg);
-       if(n != 0)
-               return(n < 0 ? remain : 0);
-
-       addr += size;
-       remain -= size;
-       if(remain == 0) 
-               return(0);
-
-       while(addr < ((addr + remain) & PAGE_MASK)){
-               n = do_op(addr, PAGE_SIZE, is_write, op, arg);
-               if(n != 0)
-                       return(n < 0 ? remain : 0);
-
-               addr += PAGE_SIZE;
-               remain -= PAGE_SIZE;
-       }
-       if(remain == 0)
-               return(0);
-
-       n = do_op(addr, remain, is_write, op, arg);
-       if(n != 0)
-               return(n < 0 ? remain : 0);
-       return(0);
-}
-
-static int copy_chunk_from_user(unsigned long from, int len, void *arg)
-{
-       unsigned long *to_ptr = arg, to = *to_ptr;
-
-       memcpy((void *) to, (void *) from, len);
-       *to_ptr += len;
-       return(0);
-}
-
-int copy_from_user_skas(void *to, const void *from, int n)
-{
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               memcpy(to, from, n);
-               return(0);
-       }
-
-       return(access_ok_skas(VERIFY_READ, from, n) ?
-              buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to):
-              n);
-}
-
-static int copy_chunk_to_user(unsigned long to, int len, void *arg)
-{
-       unsigned long *from_ptr = arg, from = *from_ptr;
-
-       memcpy((void *) to, (void *) from, len);
-       *from_ptr += len;
-       return(0);
-}
-
-int copy_to_user_skas(void *to, const void *from, int n)
-{
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               memcpy(to, from, n);
-               return(0);
-       }
-
-       return(access_ok_skas(VERIFY_WRITE, to, n) ?
-              buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) :
-              n);
-}
-
-static int strncpy_chunk_from_user(unsigned long from, int len, void *arg)
-{
-       char **to_ptr = arg, *to = *to_ptr;
-       int n;
-
-       strncpy(to, (void *) from, len);
-       n = strnlen(to, len);
-       *to_ptr += n;
-
-       if(n < len) 
-               return(1);
-       return(0);
-}
-
-int strncpy_from_user_skas(char *dst, const char *src, int count)
-{
-       int n;
-       char *ptr = dst;
-
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               strncpy(dst, src, count);
-               return(strnlen(dst, count));
-       }
-
-       if(!access_ok_skas(VERIFY_READ, src, 1))
-               return(-EFAULT);
-
-       n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user, 
-                     &ptr);
-       if(n != 0)
-               return(-EFAULT);
-       return(strnlen(dst, count));
-}
-
-static int clear_chunk(unsigned long addr, int len, void *unused)
-{
-       memset((void *) addr, 0, len);
-       return(0);
-}
-
-int __clear_user_skas(void *mem, int len)
-{
-       return(buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL));
-}
-
-int clear_user_skas(void *mem, int len)
-{
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               memset(mem, 0, len);
-               return(0);
-       }
-
-       return(access_ok_skas(VERIFY_WRITE, mem, len) ? 
-              buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len);
-}
-
-static int strnlen_chunk(unsigned long str, int len, void *arg)
-{
-       int *len_ptr = arg, n;
-
-       n = strnlen((void *) str, len);
-       *len_ptr += n;
-
-       if(n < len)
-               return(1);
-       return(0);
-}
-
-int strnlen_user_skas(const void *str, int len)
-{
-       int count = 0, n;
-
-       if(segment_eq(get_fs(), KERNEL_DS))
-               return(strnlen(str, len) + 1);
-
-       n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
-       if(n == 0)
-               return(count + 1);
-       return(-EFAULT);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index e62dc25..5ba1d68 100644 (file)
@@ -1,10 +1,9 @@
 all: mk_ptregs
 
 mk_ptregs : mk_ptregs.o
-       $(CC) -o mk_ptregs mk_ptregs.o
+       $(HOSTCC) -o mk_ptregs mk_ptregs.o
 
 mk_ptregs.o : mk_ptregs.c
-       $(CC) -c $< 
+       $(HOSTCC) -c $< 
 
-clean : 
-       $(RM) -f mk_ptregs *.o *~
+clean-files := mk_ptregs *.o *~
index 6587910..116f74d 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include <asm/ptrace.h>
 #include <asm/user.h>
 
index b815855..6ffb4d0 100644 (file)
@@ -1,9 +1,15 @@
 /* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
 #include "linux/config.h"
+#include "linux/percpu.h"
+#include "asm/pgalloc.h"
+#include "asm/tlb.h"
+
+/* For some reason, mmu_gathers are referenced when CONFIG_SMP is off. */
+DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 
 #ifdef CONFIG_SMP
 
@@ -23,7 +29,7 @@
 #include "os.h"
 
 /* CPU online map, set by smp_boot_cpus */
-unsigned long cpu_online_map = cpumask_of_cpu(0);
+unsigned long cpu_online_map = CPU_MASK_NONE;
 
 EXPORT_SYMBOL(cpu_online_map);
 
@@ -33,14 +39,6 @@ EXPORT_SYMBOL(cpu_online_map);
  */
 struct cpuinfo_um cpu_data[NR_CPUS];
 
-spinlock_t um_bh_lock = SPIN_LOCK_UNLOCKED;
-
-atomic_t global_bh_count;
-
-/* Not used by UML */
-unsigned char global_irq_holder = NO_PROC_ID;
-unsigned volatile long global_irq_lock;
-
 /* Set when the idlers are all forked */
 int smp_threads_ready = 0;
 
@@ -55,80 +53,44 @@ struct task_struct *idle_threads[NR_CPUS];
 
 void smp_send_reschedule(int cpu)
 {
-       write(cpu_data[cpu].ipi_pipe[1], "R", 1);
+       os_write_file(cpu_data[cpu].ipi_pipe[1], "R", 1);
        num_reschedules_sent++;
 }
 
-static void show(char * str)
-{
-       int cpu = smp_processor_id();
-
-       printk(KERN_INFO "\n%s, CPU %d:\n", str, cpu);
-}
-       
-#define MAXCOUNT 100000000
-
-static inline void wait_on_bh(void)
-{
-       int count = MAXCOUNT;
-       do {
-               if (!--count) {
-                       show("wait_on_bh");
-                       count = ~0;
-               }
-               /* nothing .. wait for the other bh's to go away */
-       } while (atomic_read(&global_bh_count) != 0);
-}
-
-/*
- * This is called when we want to synchronize with
- * bottom half handlers. We need to wait until
- * no other CPU is executing any bottom half handler.
- *
- * Don't wait if we're already running in an interrupt
- * context or are inside a bh handler. 
- */
-void synchronize_bh(void)
-{
-       if (atomic_read(&global_bh_count) && !in_interrupt())
-               wait_on_bh();
-}
-
 void smp_send_stop(void)
 {
        int i;
 
        printk(KERN_INFO "Stopping all CPUs...");
        for(i = 0; i < num_online_cpus(); i++){
-               if(i == current->thread_info->cpu)
+               if(i == current_thread->cpu)
                        continue;
-               write(cpu_data[i].ipi_pipe[1], "S", 1);
+               os_write_file(cpu_data[i].ipi_pipe[1], "S", 1);
        }
        printk("done\n");
 }
 
-static cpumask_t smp_commenced_mask;
-static cpumask_t smp_callin_map = CPU_MASK_NONE;
+static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
+static cpumask_t cpu_callin_map = CPU_MASK_NONE;
 
 static int idle_proc(void *cpup)
 {
        int cpu = (int) cpup, err;
 
        err = os_pipe(cpu_data[cpu].ipi_pipe, 1, 1);
-       if(err)
-               panic("CPU#%d failed to create IPI pipe, errno = %d", cpu, 
-                     -err);
+       if(err < 0)
+               panic("CPU#%d failed to create IPI pipe, err = %d", cpu, -err);
 
        activate_ipi(cpu_data[cpu].ipi_pipe[0], 
                     current->thread.mode.tt.extern_pid);
  
        wmb();
-       if (cpu_test_and_set(cpu, &smp_callin_map)) {
+       if (cpu_test_and_set(cpu, cpu_callin_map)) {
                printk("huh, CPU#%d already present??\n", cpu);
                BUG();
        }
 
-       while (!cpu_isset(cpu, &smp_commenced_mask))
+       while (!cpu_isset(cpu, smp_commenced_mask))
                cpu_relax();
 
        cpu_set(cpu, cpu_online_map);
@@ -143,16 +105,19 @@ static struct task_struct *idle_thread(int cpu)
 
         current->thread.request.u.thread.proc = idle_proc;
         current->thread.request.u.thread.arg = (void *) cpu;
-       new_task = do_fork(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, NULL);
-       if(IS_ERR(new_task)) panic("do_fork failed in idle_thread");
+       new_task = copy_process(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, 
+                               NULL);
+       if(IS_ERR(new_task)) 
+               panic("copy_process failed in idle_thread, error = %ld",
+                     PTR_ERR(new_task));
 
        cpu_tasks[cpu] = ((struct cpu_task) 
                          { .pid =      new_task->thread.mode.tt.extern_pid,
                            .task =     new_task } );
        idle_threads[cpu] = new_task;
-       CHOOSE_MODE(write(new_task->thread.mode.tt.switch_pipe[1], &c, 
-                         sizeof(c)),
-                   ({ panic("skas mode doesn't support SMP"); }));
+       CHOOSE_MODE(os_write_file(new_task->thread.mode.tt.switch_pipe[1], &c, 
+                                 sizeof(c)),
+       wake_up_forked_process(new_task);
        return(new_task);
 }
 
@@ -160,15 +125,17 @@ void smp_prepare_cpus(unsigned int maxcpus)
 {
        struct task_struct *idle;
        unsigned long waittime;
-       int err, cpu;
+       int err, cpu, me = smp_processor_id();
 
-       cpu_set(0, cpu_online_map);
-       cpu_set(0, smp_callin_map);
+       cpu_clear(me, cpu_online_map);
+       cpu_set(me, cpu_online_map);
+       cpu_set(me, cpu_callin_map);
 
-       err = os_pipe(cpu_data[0].ipi_pipe, 1, 1);
-       if(err) panic("CPU#0 failed to create IPI pipe, errno = %d", -err);
+       err = os_pipe(cpu_data[me].ipi_pipe, 1, 1);
+       if(err < 0)
+               panic("CPU#0 failed to create IPI pipe, errno = %d", -err);
 
-       activate_ipi(cpu_data[0].ipi_pipe[0], 
+       activate_ipi(cpu_data[me].ipi_pipe[0], 
                     current->thread.mode.tt.extern_pid);
 
        for(cpu = 1; cpu < ncpus; cpu++){
@@ -180,10 +147,10 @@ void smp_prepare_cpus(unsigned int maxcpus)
                unhash_process(idle);
 
                waittime = 200000000;
-               while (waittime-- && !cpu_isset(cpu, smp_callin_map))
+               while (waittime-- && !cpu_isset(cpu, cpu_callin_map))
                        cpu_relax();
 
-               if (cpu_isset(cpu, smp_callin_map))
+               if (cpu_isset(cpu, cpu_callin_map))
                        printk("done\n");
                else printk("failed\n");
        }
@@ -216,7 +183,7 @@ void IPI_handler(int cpu)
        int fd;
 
        fd = cpu_data[cpu].ipi_pipe[0];
-       while (read(fd, &c, 1) == 1) {
+       while (os_read_file(fd, &c, 1) == 1) {
                switch (c) {
                case 'C':
                        smp_call_function_slave(cpu);
@@ -276,9 +243,9 @@ int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic,
        info = _info;
 
        for (i=0;i<NR_CPUS;i++)
-               if((i != current->thread_info->cpu) && 
+               if((i != current_thread->cpu) && 
                   cpu_isset(i, cpu_online_map))
-                       write(cpu_data[i].ipi_pipe[1], "C", 1);
+                       os_write_file(cpu_data[i].ipi_pipe[1], "C", 1);
 
        while (atomic_read(&scf_started) != cpus)
                barrier();
index 77a7d92..fa0542c 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "linux/config.h"
 #include "linux/unistd.h"
-#include "linux/version.h"
 #include "linux/sys.h"
 #include "linux/swap.h"
 #include "linux/syscalls.h"
 #include "sysdep/syscalls.h"
 #include "kern_util.h"
 
-extern syscall_handler_t sys_restart_syscall;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_exit;
+#ifdef CONFIG_NFSD
+#define NFSSERVCTL sys_nfsservctl
+#else
+#define NFSSERVCTL sys_ni_syscall
+#endif
+
+#define LAST_GENERIC_SYSCALL __NR_vserver
+
+#if LAST_GENERIC_SYSCALL > LAST_ARCH_SYSCALL
+#define LAST_SYSCALL LAST_GENERIC_SYSCALL
+#else
+#define LAST_SYSCALL LAST_ARCH_SYSCALL
+#endif
+
 extern syscall_handler_t sys_fork;
-extern syscall_handler_t sys_creat;
-extern syscall_handler_t sys_link;
-extern syscall_handler_t sys_unlink;
-extern syscall_handler_t sys_chdir;
-extern syscall_handler_t sys_mknod;
-extern syscall_handler_t sys_chmod;
-extern syscall_handler_t sys_lchown16;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_stat;
-extern syscall_handler_t sys_getpid;
-extern syscall_handler_t sys_oldumount;
-extern syscall_handler_t sys_setuid16;
-extern syscall_handler_t sys_getuid16;
+extern syscall_handler_t sys_execve;
+extern syscall_handler_t um_time;
+extern syscall_handler_t um_mount;
+extern syscall_handler_t um_stime;
 extern syscall_handler_t sys_ptrace;
-extern syscall_handler_t sys_alarm;
-extern syscall_handler_t sys_fstat;
-extern syscall_handler_t sys_pause;
-extern syscall_handler_t sys_utime;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_access;
-extern syscall_handler_t sys_nice;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_sync;
-extern syscall_handler_t sys_kill;
-extern syscall_handler_t sys_rename;
-extern syscall_handler_t sys_mkdir;
-extern syscall_handler_t sys_rmdir;
 extern syscall_handler_t sys_pipe;
-extern syscall_handler_t sys_times;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_brk;
-extern syscall_handler_t sys_setgid16;
-extern syscall_handler_t sys_getgid16;
-extern syscall_handler_t sys_signal;
-extern syscall_handler_t sys_geteuid16;
-extern syscall_handler_t sys_getegid16;
-extern syscall_handler_t sys_acct;
-extern syscall_handler_t sys_umount;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_ioctl;
-extern syscall_handler_t sys_fcntl;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_setpgid;
-extern syscall_handler_t sys_ni_syscall;
 extern syscall_handler_t sys_olduname;
-extern syscall_handler_t sys_umask;
-extern syscall_handler_t sys_chroot;
-extern syscall_handler_t sys_ustat;
-extern syscall_handler_t sys_dup2;
-extern syscall_handler_t sys_getppid;
-extern syscall_handler_t sys_getpgrp;
 extern syscall_handler_t sys_sigaction;
-extern syscall_handler_t sys_sgetmask;
-extern syscall_handler_t sys_ssetmask;
-extern syscall_handler_t sys_setreuid16;
-extern syscall_handler_t sys_setregid16;
 extern syscall_handler_t sys_sigsuspend;
-extern syscall_handler_t sys_sigpending;
-extern syscall_handler_t sys_sethostname;
-extern syscall_handler_t sys_setrlimit;
-extern syscall_handler_t sys_old_getrlimit;
-extern syscall_handler_t sys_getrusage;
-extern syscall_handler_t sys_gettimeofday;
-extern syscall_handler_t sys_settimeofday;
-extern syscall_handler_t sys_getgroups16;
-extern syscall_handler_t sys_setgroups16;
-extern syscall_handler_t sys_symlink;
-extern syscall_handler_t sys_lstat;
-extern syscall_handler_t sys_readlink;
-extern syscall_handler_t sys_swapon;
-extern syscall_handler_t sys_uselib;
-extern syscall_handler_t sys_reboot;
 extern syscall_handler_t old_readdir;
-extern syscall_handler_t sys_munmap;
-extern syscall_handler_t sys_truncate;
-extern syscall_handler_t sys_ftruncate;
-extern syscall_handler_t sys_fchmod;
-extern syscall_handler_t sys_fchown16;
-extern syscall_handler_t sys_getpriority;
-extern syscall_handler_t sys_setpriority;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_statfs;
-extern syscall_handler_t sys_fstatfs;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_socketcall;
-extern syscall_handler_t sys_syslog;
-extern syscall_handler_t sys_setitimer;
-extern syscall_handler_t sys_getitimer;
-extern syscall_handler_t sys_newstat;
-extern syscall_handler_t sys_newlstat;
-extern syscall_handler_t sys_newfstat;
 extern syscall_handler_t sys_uname;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_vhangup;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_swapoff;
-extern syscall_handler_t sys_sysinfo;
 extern syscall_handler_t sys_ipc;
-extern syscall_handler_t sys_fsync;
 extern syscall_handler_t sys_sigreturn;
-extern syscall_handler_t sys_rt_sigreturn;
 extern syscall_handler_t sys_clone;
-extern syscall_handler_t sys_setdomainname;
-extern syscall_handler_t sys_newuname;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_adjtimex;
-extern syscall_handler_t sys_mprotect;
-extern syscall_handler_t sys_sigprocmask;
-extern syscall_handler_t sys_init_module;
-extern syscall_handler_t sys_delete_module;
-extern syscall_handler_t sys_quotactl;
-extern syscall_handler_t sys_getpgid;
-extern syscall_handler_t sys_fchdir;
-extern syscall_handler_t sys_bdflush;
-extern syscall_handler_t sys_sysfs;
-extern syscall_handler_t sys_personality;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_setfsuid16;
-extern syscall_handler_t sys_setfsgid16;
-extern syscall_handler_t sys_llseek;
-extern syscall_handler_t sys_getdents;
-extern syscall_handler_t sys_flock;
-extern syscall_handler_t sys_msync;
-extern syscall_handler_t sys_readv;
-extern syscall_handler_t sys_writev;
-extern syscall_handler_t sys_getsid;
-extern syscall_handler_t sys_fdatasync;
-extern syscall_handler_t sys_mlock;
-extern syscall_handler_t sys_munlock;
-extern syscall_handler_t sys_mlockall;
-extern syscall_handler_t sys_munlockall;
-extern syscall_handler_t sys_sched_setparam;
-extern syscall_handler_t sys_sched_getparam;
-extern syscall_handler_t sys_sched_setscheduler;
-extern syscall_handler_t sys_sched_getscheduler;
-extern syscall_handler_t sys_sched_get_priority_max;
-extern syscall_handler_t sys_sched_get_priority_min;
-extern syscall_handler_t sys_sched_rr_get_interval;
-extern syscall_handler_t sys_nanosleep;
-extern syscall_handler_t sys_mremap;
-extern syscall_handler_t sys_setresuid16;
-extern syscall_handler_t sys_getresuid16;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_poll;
-extern syscall_handler_t sys_nfsservctl;
-extern syscall_handler_t sys_setresgid16;
-extern syscall_handler_t sys_getresgid16;
-extern syscall_handler_t sys_prctl;
-extern syscall_handler_t sys_ni_syscall;
+extern syscall_handler_t sys_rt_sigreturn;
 extern syscall_handler_t sys_rt_sigaction;
-extern syscall_handler_t sys_rt_sigprocmask;
-extern syscall_handler_t sys_rt_sigpending;
-extern syscall_handler_t sys_rt_sigtimedwait;
-extern syscall_handler_t sys_rt_sigqueueinfo;
-extern syscall_handler_t sys_rt_sigsuspend;
-extern syscall_handler_t sys_pread64;
-extern syscall_handler_t sys_pwrite64;
-extern syscall_handler_t sys_chown16;
-extern syscall_handler_t sys_getcwd;
-extern syscall_handler_t sys_capget;
-extern syscall_handler_t sys_capset;
 extern syscall_handler_t sys_sigaltstack;
-extern syscall_handler_t sys_sendfile;
-extern syscall_handler_t sys_ni_syscall;
-extern syscall_handler_t sys_ni_syscall;
 extern syscall_handler_t sys_vfork;
-extern syscall_handler_t sys_getrlimit;
 extern syscall_handler_t sys_mmap2;
-extern syscall_handler_t sys_truncate64;
-extern syscall_handler_t sys_ftruncate64;
-extern syscall_handler_t sys_stat64;
-extern syscall_handler_t sys_lstat64;
-extern syscall_handler_t sys_fstat64;
-extern syscall_handler_t sys_lchown;
-extern syscall_handler_t sys_getuid;
-extern syscall_handler_t sys_getgid;
-extern syscall_handler_t sys_geteuid;
-extern syscall_handler_t sys_getegid;
-extern syscall_handler_t sys_setreuid;
-extern syscall_handler_t sys_setregid;
-extern syscall_handler_t sys_getgroups;
-extern syscall_handler_t sys_setgroups;
-extern syscall_handler_t sys_fchown;
-extern syscall_handler_t sys_setresuid;
-extern syscall_handler_t sys_getresuid;
-extern syscall_handler_t sys_setresgid;
-extern syscall_handler_t sys_getresgid;
-extern syscall_handler_t sys_chown;
-extern syscall_handler_t sys_setuid;
-extern syscall_handler_t sys_setgid;
-extern syscall_handler_t sys_setfsuid;
-extern syscall_handler_t sys_setfsgid;
-extern syscall_handler_t sys_pivot_root;
-extern syscall_handler_t sys_mincore;
-extern syscall_handler_t sys_madvise;
-extern syscall_handler_t sys_fcntl64;
-extern syscall_handler_t sys_getdents64;
-extern syscall_handler_t sys_gettid;
-extern syscall_handler_t sys_readahead;
-extern syscall_handler_t sys_tkill;
-extern syscall_handler_t sys_sendfile64;
-extern syscall_handler_t sys_futex;
-extern syscall_handler_t sys_sched_setaffinity;
-extern syscall_handler_t sys_sched_getaffinity;
-extern syscall_handler_t sys_io_setup;
-extern syscall_handler_t sys_io_destroy;
-extern syscall_handler_t sys_io_getevents;
-extern syscall_handler_t sys_io_submit;
-extern syscall_handler_t sys_io_cancel;
-extern syscall_handler_t sys_exit_group;
-extern syscall_handler_t sys_lookup_dcookie;
-extern syscall_handler_t sys_epoll_create;
-extern syscall_handler_t sys_epoll_ctl;
-extern syscall_handler_t sys_epoll_wait;
-extern syscall_handler_t sys_remap_file_pages;
-extern syscall_handler_t sys_set_tid_address;
-
-#ifdef CONFIG_NFSD
-#define NFSSERVCTL sys_nfsservctl
-#else
-#define NFSSERVCTL sys_ni_syscall
-#endif
-
-extern syscall_handler_t um_mount;
-extern syscall_handler_t um_time;
-extern syscall_handler_t um_stime;
-
-#define LAST_GENERIC_SYSCALL __NR_set_tid_address
+extern syscall_handler_t sys_timer_create;
+extern syscall_handler_t old_mmap_i386;
+extern syscall_handler_t old_select;
+extern syscall_handler_t sys_modify_ldt;
+extern syscall_handler_t sys_rt_sigsuspend;
 
-#if LAST_GENERIC_SYSCALL > LAST_ARCH_SYSCALL
-#define LAST_SYSCALL LAST_GENERIC_SYSCALL
-#else
-#define LAST_SYSCALL LAST_ARCH_SYSCALL
-#endif
+extern syscall_handler_t sys_vserver;
 
 syscall_handler_t *sys_call_table[] = {
-       [ __NR_restart_syscall ] = sys_restart_syscall,
-       [ __NR_exit ] = sys_exit,
-       [ __NR_fork ] = sys_fork,
+       [ __NR_restart_syscall ] = (syscall_handler_t *) sys_restart_syscall,
+       [ __NR_exit ] (syscall_handler_t *) sys_exit,
+       [ __NR_fork ] (syscall_handler_t *) sys_fork,
        [ __NR_read ] = (syscall_handler_t *) sys_read,
        [ __NR_write ] = (syscall_handler_t *) sys_write,
 
@@ -266,229 +66,249 @@ syscall_handler_t *sys_call_table[] = {
        [ __NR_open ] = (syscall_handler_t *) sys_open,
        [ __NR_close ] = (syscall_handler_t *) sys_close,
        [ __NR_waitpid ] = (syscall_handler_t *) sys_waitpid,
-       [ __NR_creat ] = sys_creat,
-       [ __NR_link ] = sys_link,
-       [ __NR_unlink ] = sys_unlink,
+       [ __NR_creat ] (syscall_handler_t *) sys_creat,
+       [ __NR_link ] (syscall_handler_t *) sys_link,
+       [ __NR_unlink ] (syscall_handler_t *) sys_unlink,
        [ __NR_execve ] = (syscall_handler_t *) sys_execve,
 
        /* declared differently in kern_util.h */
-       [ __NR_chdir ] = sys_chdir,
+       [ __NR_chdir ] (syscall_handler_t *) sys_chdir,
        [ __NR_time ] = um_time,
-       [ __NR_mknod ] = sys_mknod,
-       [ __NR_chmod ] = sys_chmod,
-       [ __NR_lchown ] = sys_lchown16,
-       [ __NR_break ] = sys_ni_syscall,
-       [ __NR_oldstat ] = sys_stat,
+       [ __NR_mknod ] (syscall_handler_t *) sys_mknod,
+       [ __NR_chmod ] (syscall_handler_t *) sys_chmod,
+       [ __NR_lchown ] (syscall_handler_t *) sys_lchown16,
+       [ __NR_break ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_oldstat ] (syscall_handler_t *) sys_stat,
        [ __NR_lseek ] = (syscall_handler_t *) sys_lseek,
-       [ __NR_getpid ] = sys_getpid,
+       [ __NR_getpid ] (syscall_handler_t *) sys_getpid,
        [ __NR_mount ] = um_mount,
-       [ __NR_umount ] = sys_oldumount,
-       [ __NR_setuid ] = sys_setuid16,
-       [ __NR_getuid ] = sys_getuid16,
+       [ __NR_umount ] (syscall_handler_t *) sys_oldumount,
+       [ __NR_setuid ] (syscall_handler_t *) sys_setuid16,
+       [ __NR_getuid ] (syscall_handler_t *) sys_getuid16,
        [ __NR_stime ] = um_stime,
-       [ __NR_ptrace ] = sys_ptrace,
-       [ __NR_alarm ] = sys_alarm,
-       [ __NR_oldfstat ] = sys_fstat,
-       [ __NR_pause ] = sys_pause,
-       [ __NR_utime ] = sys_utime,
-       [ __NR_stty ] = sys_ni_syscall,
-       [ __NR_gtty ] = sys_ni_syscall,
-       [ __NR_access ] = sys_access,
-       [ __NR_nice ] = sys_nice,
-       [ __NR_ftime ] = sys_ni_syscall,
-       [ __NR_sync ] = sys_sync,
-       [ __NR_kill ] = sys_kill,
-       [ __NR_rename ] = sys_rename,
-       [ __NR_mkdir ] = sys_mkdir,
-       [ __NR_rmdir ] = sys_rmdir,
+       [ __NR_ptrace ] (syscall_handler_t *) sys_ptrace,
+       [ __NR_alarm ] (syscall_handler_t *) sys_alarm,
+       [ __NR_oldfstat ] (syscall_handler_t *) sys_fstat,
+       [ __NR_pause ] (syscall_handler_t *) sys_pause,
+       [ __NR_utime ] (syscall_handler_t *) sys_utime,
+       [ __NR_stty ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_gtty ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_access ] (syscall_handler_t *) sys_access,
+       [ __NR_nice ] (syscall_handler_t *) sys_nice,
+       [ __NR_ftime ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_sync ] (syscall_handler_t *) sys_sync,
+       [ __NR_kill ] (syscall_handler_t *) sys_kill,
+       [ __NR_rename ] (syscall_handler_t *) sys_rename,
+       [ __NR_mkdir ] (syscall_handler_t *) sys_mkdir,
+       [ __NR_rmdir ] (syscall_handler_t *) sys_rmdir,
 
        /* Declared differently in asm/unistd.h */
        [ __NR_dup ] = (syscall_handler_t *) sys_dup,
-       [ __NR_pipe ] = sys_pipe,
-       [ __NR_times ] = sys_times,
-       [ __NR_prof ] = sys_ni_syscall,
-       [ __NR_brk ] = sys_brk,
-       [ __NR_setgid ] = sys_setgid16,
-       [ __NR_getgid ] = sys_getgid16,
-       [ __NR_signal ] = sys_signal,
-       [ __NR_geteuid ] = sys_geteuid16,
-       [ __NR_getegid ] = sys_getegid16,
-       [ __NR_acct ] = sys_acct,
-       [ __NR_umount2 ] = sys_umount,
-       [ __NR_lock ] = sys_ni_syscall,
-       [ __NR_ioctl ] = sys_ioctl,
-       [ __NR_fcntl ] = sys_fcntl,
-       [ __NR_mpx ] = sys_ni_syscall,
-       [ __NR_setpgid ] = sys_setpgid,
-       [ __NR_ulimit ] = sys_ni_syscall,
-       [ __NR_oldolduname ] = sys_olduname,
-       [ __NR_umask ] = sys_umask,
-       [ __NR_chroot ] = sys_chroot,
-       [ __NR_ustat ] = sys_ustat,
-       [ __NR_dup2 ] = sys_dup2,
-       [ __NR_getppid ] = sys_getppid,
-       [ __NR_getpgrp ] = sys_getpgrp,
+       [ __NR_pipe ] (syscall_handler_t *) sys_pipe,
+       [ __NR_times ] (syscall_handler_t *) sys_times,
+       [ __NR_prof ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_brk ] (syscall_handler_t *) sys_brk,
+       [ __NR_setgid ] (syscall_handler_t *) sys_setgid16,
+       [ __NR_getgid ] (syscall_handler_t *) sys_getgid16,
+       [ __NR_signal ] (syscall_handler_t *) sys_signal,
+       [ __NR_geteuid ] (syscall_handler_t *) sys_geteuid16,
+       [ __NR_getegid ] (syscall_handler_t *) sys_getegid16,
+       [ __NR_acct ] (syscall_handler_t *) sys_acct,
+       [ __NR_umount2 ] (syscall_handler_t *) sys_umount,
+       [ __NR_lock ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_ioctl ] (syscall_handler_t *) sys_ioctl,
+       [ __NR_fcntl ] (syscall_handler_t *) sys_fcntl,
+       [ __NR_mpx ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_setpgid ] (syscall_handler_t *) sys_setpgid,
+       [ __NR_ulimit ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_oldolduname ] (syscall_handler_t *) sys_olduname,
+       [ __NR_umask ] (syscall_handler_t *) sys_umask,
+       [ __NR_chroot ] (syscall_handler_t *) sys_chroot,
+       [ __NR_ustat ] (syscall_handler_t *) sys_ustat,
+       [ __NR_dup2 ] (syscall_handler_t *) sys_dup2,
+       [ __NR_getppid ] (syscall_handler_t *) sys_getppid,
+       [ __NR_getpgrp ] (syscall_handler_t *) sys_getpgrp,
        [ __NR_setsid ] = (syscall_handler_t *) sys_setsid,
-       [ __NR_sigaction ] = sys_sigaction,
-       [ __NR_sgetmask ] = sys_sgetmask,
-       [ __NR_ssetmask ] = sys_ssetmask,
-       [ __NR_setreuid ] = sys_setreuid16,
-       [ __NR_setregid ] = sys_setregid16,
-       [ __NR_sigsuspend ] = sys_sigsuspend,
-       [ __NR_sigpending ] = sys_sigpending,
-       [ __NR_sethostname ] = sys_sethostname,
-       [ __NR_setrlimit ] = sys_setrlimit,
-       [ __NR_getrlimit ] = sys_old_getrlimit,
-       [ __NR_getrusage ] = sys_getrusage,
-       [ __NR_gettimeofday ] = sys_gettimeofday,
-       [ __NR_settimeofday ] = sys_settimeofday,
-       [ __NR_getgroups ] = sys_getgroups16,
-       [ __NR_setgroups ] = sys_setgroups16,
-       [ __NR_symlink ] = sys_symlink,
-       [ __NR_oldlstat ] = sys_lstat,
-       [ __NR_readlink ] = sys_readlink,
-       [ __NR_uselib ] = sys_uselib,
+       [ __NR_sigaction ] (syscall_handler_t *) sys_sigaction,
+       [ __NR_sgetmask ] (syscall_handler_t *) sys_sgetmask,
+       [ __NR_ssetmask ] (syscall_handler_t *) sys_ssetmask,
+       [ __NR_setreuid ] (syscall_handler_t *) sys_setreuid16,
+       [ __NR_setregid ] (syscall_handler_t *) sys_setregid16,
+       [ __NR_sigsuspend ] (syscall_handler_t *) sys_sigsuspend,
+       [ __NR_sigpending ] (syscall_handler_t *) sys_sigpending,
+       [ __NR_sethostname ] (syscall_handler_t *) sys_sethostname,
+       [ __NR_setrlimit ] (syscall_handler_t *) sys_setrlimit,
+       [ __NR_getrlimit ] (syscall_handler_t *) sys_old_getrlimit,
+       [ __NR_getrusage ] (syscall_handler_t *) sys_getrusage,
+       [ __NR_gettimeofday ] (syscall_handler_t *) sys_gettimeofday,
+       [ __NR_settimeofday ] (syscall_handler_t *) sys_settimeofday,
+       [ __NR_getgroups ] (syscall_handler_t *) sys_getgroups16,
+       [ __NR_setgroups ] (syscall_handler_t *) sys_setgroups16,
+       [ __NR_symlink ] (syscall_handler_t *) sys_symlink,
+       [ __NR_oldlstat ] (syscall_handler_t *) sys_lstat,
+       [ __NR_readlink ] (syscall_handler_t *) sys_readlink,
+       [ __NR_uselib ] (syscall_handler_t *) sys_uselib,
        [ __NR_swapon ] = (syscall_handler_t *) sys_swapon,
-       [ __NR_reboot ] = sys_reboot,
+       [ __NR_reboot ] (syscall_handler_t *) sys_reboot,
        [ __NR_readdir ] = old_readdir,
-       [ __NR_munmap ] = sys_munmap,
-       [ __NR_truncate ] = sys_truncate,
-       [ __NR_ftruncate ] = sys_ftruncate,
-       [ __NR_fchmod ] = sys_fchmod,
-       [ __NR_fchown ] = sys_fchown16,
-       [ __NR_getpriority ] = sys_getpriority,
-       [ __NR_setpriority ] = sys_setpriority,
-       [ __NR_profil ] = sys_ni_syscall,
-       [ __NR_statfs ] = sys_statfs,
-       [ __NR_fstatfs ] = sys_fstatfs,
-       [ __NR_ioperm ] = sys_ni_syscall,
-       [ __NR_socketcall ] = sys_socketcall,
-       [ __NR_syslog ] = sys_syslog,
-       [ __NR_setitimer ] = sys_setitimer,
-       [ __NR_getitimer ] = sys_getitimer,
-       [ __NR_stat ] = sys_newstat,
-       [ __NR_lstat ] = sys_newlstat,
-       [ __NR_fstat ] = sys_newfstat,
-       [ __NR_olduname ] = sys_uname,
-       [ __NR_iopl ] = sys_ni_syscall,
-       [ __NR_vhangup ] = sys_vhangup,
-       [ __NR_idle ] = sys_ni_syscall,
+       [ __NR_munmap ] (syscall_handler_t *) sys_munmap,
+       [ __NR_truncate ] (syscall_handler_t *) sys_truncate,
+       [ __NR_ftruncate ] (syscall_handler_t *) sys_ftruncate,
+       [ __NR_fchmod ] (syscall_handler_t *) sys_fchmod,
+       [ __NR_fchown ] (syscall_handler_t *) sys_fchown16,
+       [ __NR_getpriority ] (syscall_handler_t *) sys_getpriority,
+       [ __NR_setpriority ] (syscall_handler_t *) sys_setpriority,
+       [ __NR_profil ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_statfs ] (syscall_handler_t *) sys_statfs,
+       [ __NR_fstatfs ] (syscall_handler_t *) sys_fstatfs,
+       [ __NR_ioperm ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_socketcall ] (syscall_handler_t *) sys_socketcall,
+       [ __NR_syslog ] (syscall_handler_t *) sys_syslog,
+       [ __NR_setitimer ] (syscall_handler_t *) sys_setitimer,
+       [ __NR_getitimer ] (syscall_handler_t *) sys_getitimer,
+       [ __NR_stat ] (syscall_handler_t *) sys_newstat,
+       [ __NR_lstat ] (syscall_handler_t *) sys_newlstat,
+       [ __NR_fstat ] (syscall_handler_t *) sys_newfstat,
+       [ __NR_olduname ] (syscall_handler_t *) sys_uname,
+       [ __NR_iopl ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_vhangup ] (syscall_handler_t *) sys_vhangup,
+       [ __NR_idle ] (syscall_handler_t *) sys_ni_syscall,
        [ __NR_wait4 ] = (syscall_handler_t *) sys_wait4,
        [ __NR_swapoff ] = (syscall_handler_t *) sys_swapoff,
-       [ __NR_sysinfo ] = sys_sysinfo,
-       [ __NR_ipc ] = sys_ipc,
-       [ __NR_fsync ] = sys_fsync,
-       [ __NR_sigreturn ] = sys_sigreturn,
-       [ __NR_clone ] = sys_clone,
-       [ __NR_setdomainname ] = sys_setdomainname,
-       [ __NR_uname ] = sys_newuname,
-       [ __NR_adjtimex ] = sys_adjtimex,
-       [ __NR_mprotect ] = sys_mprotect,
-       [ __NR_sigprocmask ] = sys_sigprocmask,
-       [ __NR_create_module ] = sys_ni_syscall,
-       [ __NR_init_module ] = sys_init_module,
-       [ __NR_delete_module ] = sys_delete_module,
-       [ __NR_get_kernel_syms ] = sys_ni_syscall,
-       [ __NR_quotactl ] = sys_quotactl,
-       [ __NR_getpgid ] = sys_getpgid,
-       [ __NR_fchdir ] = sys_fchdir,
-       [ __NR_bdflush ] = sys_bdflush,
-       [ __NR_sysfs ] = sys_sysfs,
-       [ __NR_personality ] = sys_personality,
-       [ __NR_afs_syscall ] = sys_ni_syscall,
-       [ __NR_setfsuid ] = sys_setfsuid16,
-       [ __NR_setfsgid ] = sys_setfsgid16,
-       [ __NR__llseek ] = sys_llseek,
-       [ __NR_getdents ] = sys_getdents,
+       [ __NR_sysinfo ] (syscall_handler_t *) sys_sysinfo,
+       [ __NR_ipc ] (syscall_handler_t *) sys_ipc,
+       [ __NR_fsync ] (syscall_handler_t *) sys_fsync,
+       [ __NR_sigreturn ] (syscall_handler_t *) sys_sigreturn,
+       [ __NR_clone ] (syscall_handler_t *) sys_clone,
+       [ __NR_setdomainname ] (syscall_handler_t *) sys_setdomainname,
+       [ __NR_uname ] (syscall_handler_t *) sys_newuname,
+       [ __NR_adjtimex ] (syscall_handler_t *) sys_adjtimex,
+       [ __NR_mprotect ] (syscall_handler_t *) sys_mprotect,
+       [ __NR_sigprocmask ] (syscall_handler_t *) sys_sigprocmask,
+       [ __NR_create_module ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_init_module ] (syscall_handler_t *) sys_init_module,
+       [ __NR_delete_module ] (syscall_handler_t *) sys_delete_module,
+       [ __NR_get_kernel_syms ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_quotactl ] (syscall_handler_t *) sys_quotactl,
+       [ __NR_getpgid ] (syscall_handler_t *) sys_getpgid,
+       [ __NR_fchdir ] (syscall_handler_t *) sys_fchdir,
+       [ __NR_bdflush ] (syscall_handler_t *) sys_bdflush,
+       [ __NR_sysfs ] (syscall_handler_t *) sys_sysfs,
+       [ __NR_personality ] (syscall_handler_t *) sys_personality,
+       [ __NR_afs_syscall ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_setfsuid ] (syscall_handler_t *) sys_setfsuid16,
+       [ __NR_setfsgid ] (syscall_handler_t *) sys_setfsgid16,
+       [ __NR__llseek ] (syscall_handler_t *) sys_llseek,
+       [ __NR_getdents ] (syscall_handler_t *) sys_getdents,
        [ __NR__newselect ] = (syscall_handler_t *) sys_select,
-       [ __NR_flock ] = sys_flock,
-       [ __NR_msync ] = sys_msync,
-       [ __NR_readv ] = sys_readv,
-       [ __NR_writev ] = sys_writev,
-       [ __NR_getsid ] = sys_getsid,
-       [ __NR_fdatasync ] = sys_fdatasync,
+       [ __NR_flock ] (syscall_handler_t *) sys_flock,
+       [ __NR_msync ] (syscall_handler_t *) sys_msync,
+       [ __NR_readv ] (syscall_handler_t *) sys_readv,
+       [ __NR_writev ] (syscall_handler_t *) sys_writev,
+       [ __NR_getsid ] (syscall_handler_t *) sys_getsid,
+       [ __NR_fdatasync ] (syscall_handler_t *) sys_fdatasync,
        [ __NR__sysctl ] = (syscall_handler_t *) sys_sysctl,
-       [ __NR_mlock ] = sys_mlock,
-       [ __NR_munlock ] = sys_munlock,
-       [ __NR_mlockall ] = sys_mlockall,
-       [ __NR_munlockall ] = sys_munlockall,
-       [ __NR_sched_setparam ] = sys_sched_setparam,
-       [ __NR_sched_getparam ] = sys_sched_getparam,
-       [ __NR_sched_setscheduler ] = sys_sched_setscheduler,
-       [ __NR_sched_getscheduler ] = sys_sched_getscheduler,
+       [ __NR_mlock ] (syscall_handler_t *) sys_mlock,
+       [ __NR_munlock ] (syscall_handler_t *) sys_munlock,
+       [ __NR_mlockall ] (syscall_handler_t *) sys_mlockall,
+       [ __NR_munlockall ] (syscall_handler_t *) sys_munlockall,
+       [ __NR_sched_setparam ] (syscall_handler_t *) sys_sched_setparam,
+       [ __NR_sched_getparam ] (syscall_handler_t *) sys_sched_getparam,
+       [ __NR_sched_setscheduler ] (syscall_handler_t *) sys_sched_setscheduler,
+       [ __NR_sched_getscheduler ] (syscall_handler_t *) sys_sched_getscheduler,
        [ __NR_sched_yield ] = (syscall_handler_t *) yield,
-       [ __NR_sched_get_priority_max ] = sys_sched_get_priority_max,
-       [ __NR_sched_get_priority_min ] = sys_sched_get_priority_min,
-       [ __NR_sched_rr_get_interval ] = sys_sched_rr_get_interval,
-       [ __NR_nanosleep ] = sys_nanosleep,
-       [ __NR_mremap ] = sys_mremap,
-       [ __NR_setresuid ] = sys_setresuid16,
-       [ __NR_getresuid ] = sys_getresuid16,
-       [ __NR_vm86 ] = sys_ni_syscall,
-       [ __NR_query_module ] = sys_ni_syscall,
-       [ __NR_poll ] = sys_poll,
-       [ __NR_nfsservctl ] = NFSSERVCTL,
-       [ __NR_setresgid ] = sys_setresgid16,
-       [ __NR_getresgid ] = sys_getresgid16,
-       [ __NR_prctl ] = sys_prctl,
-       [ __NR_rt_sigreturn ] = sys_rt_sigreturn,
-       [ __NR_rt_sigaction ] = sys_rt_sigaction,
-       [ __NR_rt_sigprocmask ] = sys_rt_sigprocmask,
-       [ __NR_rt_sigpending ] = sys_rt_sigpending,
-       [ __NR_rt_sigtimedwait ] = sys_rt_sigtimedwait,
-       [ __NR_rt_sigqueueinfo ] = sys_rt_sigqueueinfo,
-       [ __NR_rt_sigsuspend ] = sys_rt_sigsuspend,
-       [ __NR_pread64 ] = sys_pread64,
-       [ __NR_pwrite64 ] = sys_pwrite64,
-       [ __NR_chown ] = sys_chown16,
-       [ __NR_getcwd ] = sys_getcwd,
-       [ __NR_capget ] = sys_capget,
-       [ __NR_capset ] = sys_capset,
-       [ __NR_sigaltstack ] = sys_sigaltstack,
-       [ __NR_sendfile ] = sys_sendfile,
-       [ __NR_getpmsg ] = sys_ni_syscall,
-       [ __NR_putpmsg ] = sys_ni_syscall,
-       [ __NR_vfork ] = sys_vfork,
-       [ __NR_ugetrlimit ] = sys_getrlimit,
-       [ __NR_mmap2 ] = sys_mmap2,
-       [ __NR_truncate64 ] = sys_truncate64,
-       [ __NR_ftruncate64 ] = sys_ftruncate64,
-       [ __NR_stat64 ] = sys_stat64,
-       [ __NR_lstat64 ] = sys_lstat64,
-       [ __NR_fstat64 ] = sys_fstat64,
-       [ __NR_fcntl64 ] = sys_fcntl64,
-       [ __NR_getdents64 ] = sys_getdents64,
-       [ __NR_gettid ] = sys_gettid,
-       [ __NR_readahead ] = sys_readahead,
-       [ __NR_setxattr ] = sys_ni_syscall,
-       [ __NR_lsetxattr ] = sys_ni_syscall,
-       [ __NR_fsetxattr ] = sys_ni_syscall,
-       [ __NR_getxattr ] = sys_ni_syscall,
-       [ __NR_lgetxattr ] = sys_ni_syscall,
-       [ __NR_fgetxattr ] = sys_ni_syscall,
-       [ __NR_listxattr ] = sys_ni_syscall,
-       [ __NR_llistxattr ] = sys_ni_syscall,
-       [ __NR_flistxattr ] = sys_ni_syscall,
-       [ __NR_removexattr ] = sys_ni_syscall,
-       [ __NR_lremovexattr ] = sys_ni_syscall,
-       [ __NR_fremovexattr ] = sys_ni_syscall,
-       [ __NR_tkill ] = sys_tkill,
-       [ __NR_sendfile64 ] = sys_sendfile64,
-       [ __NR_futex ] = sys_futex,
-       [ __NR_sched_setaffinity ] = sys_sched_setaffinity,
-       [ __NR_sched_getaffinity ] = sys_sched_getaffinity,
-       [ __NR_io_setup ] = sys_io_setup,
-       [ __NR_io_destroy ] = sys_io_destroy,
-       [ __NR_io_getevents ] = sys_io_getevents,
-       [ __NR_io_submit ] = sys_io_submit,
-       [ __NR_io_cancel ] = sys_io_cancel,
-       [ __NR_exit_group ] = sys_exit_group,
-       [ __NR_lookup_dcookie ] = sys_lookup_dcookie,
-       [ __NR_epoll_create ] = sys_epoll_create,
-       [ __NR_epoll_ctl ] = sys_epoll_ctl,
-       [ __NR_epoll_wait ] = sys_epoll_wait,
-        [ __NR_remap_file_pages ] = sys_remap_file_pages,
-        [ __NR_set_tid_address ] = sys_set_tid_address,
+       [ __NR_sched_get_priority_max ] (syscall_handler_t *) sys_sched_get_priority_max,
+       [ __NR_sched_get_priority_min ] (syscall_handler_t *) sys_sched_get_priority_min,
+       [ __NR_sched_rr_get_interval ] (syscall_handler_t *) sys_sched_rr_get_interval,
+       [ __NR_nanosleep ] (syscall_handler_t *) sys_nanosleep,
+       [ __NR_mremap ] (syscall_handler_t *) sys_mremap,
+       [ __NR_setresuid ] (syscall_handler_t *) sys_setresuid16,
+       [ __NR_getresuid ] (syscall_handler_t *) sys_getresuid16,
+       [ __NR_vm86 ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_query_module ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_poll ] (syscall_handler_t *) sys_poll,
+       [ __NR_nfsservctl ] = (syscall_handler_t *) NFSSERVCTL,
+       [ __NR_setresgid ] (syscall_handler_t *) sys_setresgid16,
+       [ __NR_getresgid ] (syscall_handler_t *) sys_getresgid16,
+       [ __NR_prctl ] (syscall_handler_t *) sys_prctl,
+       [ __NR_rt_sigreturn ] (syscall_handler_t *) sys_rt_sigreturn,
+       [ __NR_rt_sigaction ] (syscall_handler_t *) sys_rt_sigaction,
+       [ __NR_rt_sigprocmask ] (syscall_handler_t *) sys_rt_sigprocmask,
+       [ __NR_rt_sigpending ] (syscall_handler_t *) sys_rt_sigpending,
+       [ __NR_rt_sigtimedwait ] (syscall_handler_t *) sys_rt_sigtimedwait,
+       [ __NR_rt_sigqueueinfo ] (syscall_handler_t *) sys_rt_sigqueueinfo,
+       [ __NR_rt_sigsuspend ] (syscall_handler_t *) sys_rt_sigsuspend,
+       [ __NR_pread64 ] (syscall_handler_t *) sys_pread64,
+       [ __NR_pwrite64 ] (syscall_handler_t *) sys_pwrite64,
+       [ __NR_chown ] (syscall_handler_t *) sys_chown16,
+       [ __NR_getcwd ] (syscall_handler_t *) sys_getcwd,
+       [ __NR_capget ] (syscall_handler_t *) sys_capget,
+       [ __NR_capset ] (syscall_handler_t *) sys_capset,
+       [ __NR_sigaltstack ] (syscall_handler_t *) sys_sigaltstack,
+       [ __NR_sendfile ] (syscall_handler_t *) sys_sendfile,
+       [ __NR_getpmsg ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_putpmsg ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_vfork ] (syscall_handler_t *) sys_vfork,
+       [ __NR_ugetrlimit ] (syscall_handler_t *) sys_getrlimit,
+       [ __NR_mmap2 ] (syscall_handler_t *) sys_mmap2,
+       [ __NR_truncate64 ] (syscall_handler_t *) sys_truncate64,
+       [ __NR_ftruncate64 ] (syscall_handler_t *) sys_ftruncate64,
+       [ __NR_stat64 ] (syscall_handler_t *) sys_stat64,
+       [ __NR_lstat64 ] (syscall_handler_t *) sys_lstat64,
+       [ __NR_fstat64 ] (syscall_handler_t *) sys_fstat64,
+       [ __NR_getdents64 ] (syscall_handler_t *) sys_getdents64,
+       [ __NR_fcntl64 ] (syscall_handler_t *) sys_fcntl64,
+       [ 223 ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_gettid ] (syscall_handler_t *) sys_gettid,
+       [ __NR_readahead ] (syscall_handler_t *) sys_readahead,
+       [ __NR_setxattr ] (syscall_handler_t *) sys_setxattr,
+       [ __NR_lsetxattr ] (syscall_handler_t *) sys_lsetxattr,
+       [ __NR_fsetxattr ] (syscall_handler_t *) sys_fsetxattr,
+       [ __NR_getxattr ] (syscall_handler_t *) sys_getxattr,
+       [ __NR_lgetxattr ] (syscall_handler_t *) sys_lgetxattr,
+       [ __NR_fgetxattr ] (syscall_handler_t *) sys_fgetxattr,
+       [ __NR_listxattr ] (syscall_handler_t *) sys_listxattr,
+       [ __NR_llistxattr ] (syscall_handler_t *) sys_llistxattr,
+       [ __NR_flistxattr ] (syscall_handler_t *) sys_flistxattr,
+       [ __NR_removexattr ] (syscall_handler_t *) sys_removexattr,
+       [ __NR_lremovexattr ] (syscall_handler_t *) sys_lremovexattr,
+       [ __NR_fremovexattr ] (syscall_handler_t *) sys_fremovexattr,
+       [ __NR_tkill ] (syscall_handler_t *) sys_tkill,
+       [ __NR_sendfile64 ] (syscall_handler_t *) sys_sendfile64,
+       [ __NR_futex ] (syscall_handler_t *) sys_futex,
+       [ __NR_sched_setaffinity ] (syscall_handler_t *) sys_sched_setaffinity,
+       [ __NR_sched_getaffinity ] (syscall_handler_t *) sys_sched_getaffinity,
+       [ __NR_set_thread_area ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_get_thread_area ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_io_setup ] (syscall_handler_t *) sys_io_setup,
+       [ __NR_io_destroy ] (syscall_handler_t *) sys_io_destroy,
+       [ __NR_io_getevents ] (syscall_handler_t *) sys_io_getevents,
+       [ __NR_io_submit ] (syscall_handler_t *) sys_io_submit,
+       [ __NR_io_cancel ] (syscall_handler_t *) sys_io_cancel,
+       [ __NR_fadvise64 ] (syscall_handler_t *) sys_fadvise64,
+       [ 251 ] (syscall_handler_t *) sys_ni_syscall,
+       [ __NR_exit_group ] (syscall_handler_t *) sys_exit_group,
+       [ __NR_lookup_dcookie ] (syscall_handler_t *) sys_lookup_dcookie,
+       [ __NR_epoll_create ] (syscall_handler_t *) sys_epoll_create,
+       [ __NR_epoll_ctl ] (syscall_handler_t *) sys_epoll_ctl,
+       [ __NR_epoll_wait ] (syscall_handler_t *) sys_epoll_wait,
+        [ __NR_remap_file_pages ] (syscall_handler_t *) sys_remap_file_pages,
+        [ __NR_set_tid_address ] (syscall_handler_t *) sys_set_tid_address,
+       [ __NR_timer_create ] (syscall_handler_t *) sys_timer_create,
+       [ __NR_timer_settime ] (syscall_handler_t *) sys_timer_settime,
+       [ __NR_timer_gettime ] (syscall_handler_t *) sys_timer_gettime,
+       [ __NR_timer_getoverrun ] (syscall_handler_t *) sys_timer_getoverrun,
+       [ __NR_timer_delete ] (syscall_handler_t *) sys_timer_delete,
+       [ __NR_clock_settime ] (syscall_handler_t *) sys_clock_settime,
+       [ __NR_clock_gettime ] (syscall_handler_t *) sys_clock_gettime,
+       [ __NR_clock_getres ] (syscall_handler_t *) sys_clock_getres,
+       [ __NR_clock_nanosleep ] (syscall_handler_t *) sys_clock_nanosleep,
+       [ __NR_statfs64 ] (syscall_handler_t *) sys_statfs64,
+       [ __NR_fstatfs64 ] (syscall_handler_t *) sys_fstatfs64,
+       [ __NR_tgkill ] (syscall_handler_t *) sys_tgkill,
+       [ __NR_utimes ] (syscall_handler_t *) sys_utimes,
+       [ __NR_fadvise64_64 ] (syscall_handler_t *) sys_fadvise64_64,
+       [ __NR_vserver ] (syscall_handler_t *) sys_vserver,
 
        ARCH_SYSCALLS
        [ LAST_SYSCALL + 1 ... NR_syscalls ] = 
index 2af5fc2..cec6e63 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -15,6 +15,8 @@
 #include "linux/unistd.h"
 #include "linux/slab.h"
 #include "linux/utime.h"
+#include <linux/vs_cvirt.h>
+
 #include "asm/mman.h"
 #include "asm/uaccess.h"
 #include "asm/ipc.h"
@@ -36,39 +38,40 @@ long um_mount(char * dev_name, char * dir_name, char * type,
 
 long sys_fork(void)
 {
-       struct task_struct *p;
+       long ret;
 
        current->thread.forking = 1;
-        p = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
+        ret = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
        current->thread.forking = 0;
-       return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
+       return(ret);
 }
 
-long sys_clone(unsigned long clone_flags, unsigned long newsp)
+long sys_clone(unsigned long clone_flags, unsigned long newsp, 
+              int *parent_tid, int *child_tid)
 {
-       struct task_struct *p;
+       long ret;
 
        current->thread.forking = 1;
-       p = do_fork(clone_flags, newsp, NULL, 0, NULL, NULL);
+       ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid);
        current->thread.forking = 0;
-       return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
+       return(ret);
 }
 
 long sys_vfork(void)
 {
-       struct task_struct *p;
+       long ret;
 
        current->thread.forking = 1;
-       p = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL, NULL);
+       ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL, 
+                     NULL);
        current->thread.forking = 0;
-       return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
+       return(ret);
 }
 
 /* common code for old and new mmaps */
-static inline long do_mmap2(
-       unsigned long addr, unsigned long len,
-       unsigned long prot, unsigned long flags,
-       unsigned long fd, unsigned long pgoff)
+long do_mmap2(struct mm_struct *mm, unsigned long addr, unsigned long len,
+             unsigned long prot, unsigned long flags, unsigned long fd,
+             unsigned long pgoff)
 {
        int error = -EBADF;
        struct file * file = NULL;
@@ -80,9 +83,9 @@ static inline long do_mmap2(
                        goto out;
        }
 
-       down_write(&current->mm->mmap_sem);
-       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
-       up_write(&current->mm->mmap_sem);
+       down_write(&mm->mmap_sem);
+       error = do_mmap_pgoff(mm, file, addr, len, prot, flags, pgoff);
+       up_write(&mm->mmap_sem);
 
        if (file)
                fput(file);
@@ -94,7 +97,7 @@ long sys_mmap2(unsigned long addr, unsigned long len,
               unsigned long prot, unsigned long flags,
               unsigned long fd, unsigned long pgoff)
 {
-       return do_mmap2(addr, len, prot, flags, fd, pgoff);
+       return do_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
 }
 
 /*
@@ -121,7 +124,8 @@ int old_mmap(unsigned long addr, unsigned long len,
        if (offset & ~PAGE_MASK)
                goto out;
 
-       err = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
+       err = do_mmap2(current->mm, addr, len, prot, flags, fd, 
+                      offset >> PAGE_SHIFT);
  out:
        return err;
 }
@@ -136,43 +140,12 @@ int sys_pipe(unsigned long * fildes)
 
         error = do_pipe(fd);
         if (!error) {
-                if (copy_to_user(fildes, fd, 2*sizeof(int)))
+               if (copy_to_user(fildes, fd, sizeof(fd)))
                         error = -EFAULT;
         }
         return error;
 }
 
-int sys_sigaction(int sig, const struct old_sigaction *act,
-                        struct old_sigaction *oact)
-{
-       struct k_sigaction new_ka, old_ka;
-       int ret;
-
-       if (act) {
-               old_sigset_t mask;
-               if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
-                   __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
-                   __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
-                       return -EFAULT;
-               __get_user(new_ka.sa.sa_flags, &act->sa_flags);
-               __get_user(mask, &act->sa_mask);
-               siginitset(&new_ka.sa.sa_mask, mask);
-       }
-
-       ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
-
-       if (!ret && oact) {
-               if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
-                   __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
-                   __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
-                       return -EFAULT;
-               __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
-               __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
-       }
-
-       return ret;
-}
-
 /*
  * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  *
@@ -254,7 +227,7 @@ int sys_ipc (uint call, int first, int second,
                return sys_shmctl (first, second,
                                   (struct shmid_ds *) ptr);
        default:
-               return -EINVAL;
+               return -ENOSYS;
        }
 }
 
@@ -264,7 +237,7 @@ int sys_uname(struct old_utsname * name)
        if (!name)
                return -EFAULT;
        down_read(&uts_sem);
-       err=copy_to_user(name, &system_utsname, sizeof (*name));
+       err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
        up_read(&uts_sem);
        return err?-EFAULT:0;
 }
@@ -272,6 +245,7 @@ int sys_uname(struct old_utsname * name)
 int sys_olduname(struct oldold_utsname * name)
 {
        int error;
+       struct new_utsname *ptr;
 
        if (!name)
                return -EFAULT;
@@ -280,19 +254,20 @@ int sys_olduname(struct oldold_utsname * name)
   
        down_read(&uts_sem);
        
-       error = __copy_to_user(&name->sysname,&system_utsname.sysname,
+       ptr = vx_new_utsname();
+       error = __copy_to_user(&name->sysname,ptr->sysname,
                               __OLD_UTS_LEN);
        error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->nodename,&system_utsname.nodename,
+       error |= __copy_to_user(&name->nodename,ptr->nodename,
                                __OLD_UTS_LEN);
        error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->release,&system_utsname.release,
+       error |= __copy_to_user(&name->release,ptr->release,
                                __OLD_UTS_LEN);
        error |= __put_user(0,name->release+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->version,&system_utsname.version,
+       error |= __copy_to_user(&name->version,ptr->version,
                                __OLD_UTS_LEN);
        error |= __put_user(0,name->version+__OLD_UTS_LEN);
-       error |= __copy_to_user(&name->machine,&system_utsname.machine,
+       error |= __copy_to_user(&name->machine,ptr->machine,
                                __OLD_UTS_LEN);
        error |= __put_user(0,name->machine+__OLD_UTS_LEN);
        
@@ -303,11 +278,6 @@ int sys_olduname(struct oldold_utsname * name)
        return error;
 }
 
-int sys_sigaltstack(const stack_t *uss, stack_t *uoss)
-{
-       return(do_sigaltstack(uss, uoss, PT_REGS_SP(&current->thread.regs)));
-}
-
 long execute_syscall(void *r)
 {
        return(CHOOSE_MODE_PROC(execute_syscall_tt, execute_syscall_skas, r));
index b43c214..80b8470 100644 (file)
@@ -44,6 +44,11 @@ void dump_stack(void)
 }
 EXPORT_SYMBOL(dump_stack);
 
+void show_stack(struct task_struct *task, unsigned long *sp)
+{
+       show_trace(sp);
+}
+
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
index 3fd4208..b1674bc 100644 (file)
@@ -28,6 +28,7 @@ static void __init find_tempdir(void)
        }
        if((dir == NULL) || (*dir == '\0')) 
                dir = "/tmp";
+
        tempdir = malloc(strlen(dir) + 2);
        if(tempdir == NULL){
                fprintf(stderr, "Failed to malloc tempdir, "
@@ -49,7 +50,8 @@ int make_tempfile(const char *template, char **out_tempname, int do_unlink)
        else
                *tempname = 0;
        strcat(tempname, template);
-       if((fd = mkstemp(tempname)) < 0){
+       fd = mkstemp(tempname);
+       if(fd < 0){
                fprintf(stderr, "open - cannot create %s: %s\n", tempname, 
                        strerror(errno));
                return -1;
@@ -59,7 +61,8 @@ int make_tempfile(const char *template, char **out_tempname, int do_unlink)
                return -1;
        }
        if(out_tempname){
-               if((*out_tempname = strdup(tempname)) == NULL){
+               *out_tempname = strdup(tempname);
+               if(*out_tempname == NULL){
                        perror("strdup");
                        return -1;
                }
index 6f0d757..a6e7ff3 100644 (file)
@@ -4,24 +4,33 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <time.h>
 #include <sys/time.h>
 #include <signal.h>
 #include <errno.h>
-#include "linux/module.h"
 #include "user_util.h"
 #include "kern_util.h"
 #include "user.h"
 #include "process.h"
 #include "signal_user.h"
 #include "time_user.h"
+#include "kern_constants.h"
+
+/* XXX This really needs to be declared and initialized in a kernel file since 
+ * it's in <linux/time.h>
+ */
+extern struct timespec wall_to_monotonic;
 
 extern struct timeval xtime;
 
+struct timeval local_offset = { 0, 0 };
+
 void timer(void)
 {
        gettimeofday(&xtime, NULL);
+       timeradd(&xtime, &local_offset, &xtime);
 }
 
 void set_interval(int timer_type)
@@ -44,6 +53,15 @@ void enable_timer(void)
                       errno);
 }
 
+void disable_timer(void)
+{
+       struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
+       if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
+          (setitimer(ITIMER_REAL, &disable, NULL) < 0))
+               printk("disnable_timer - setitimer failed, errno = %d\n",
+                      errno);
+}
+
 void switch_timers(int to_real)
 {
        struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
@@ -66,7 +84,7 @@ void switch_timers(int to_real)
                       errno);
 }
 
-void idle_timer(void)
+void uml_idle_timer(void)
 {
        if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR)
                panic("Couldn't unset SIGVTALRM handler");
@@ -76,14 +94,23 @@ void idle_timer(void)
        set_interval(ITIMER_REAL);
 }
 
+extern int do_posix_clock_monotonic_gettime(struct timespec *tp);
+
 void time_init(void)
 {
+       struct timespec now;
        if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR)
                panic("Couldn't set SIGVTALRM handler");
        set_interval(ITIMER_VIRTUAL);
+
+       do_posix_clock_monotonic_gettime(&now);
+       wall_to_monotonic.tv_sec = -now.tv_sec;
+       wall_to_monotonic.tv_nsec = -now.tv_nsec;
 }
 
-struct timeval local_offset = { 0, 0 };
+/* Declared in linux/time.h, which can't be included here */
+extern void clock_was_set(void);
 
 void do_gettimeofday(struct timeval *tv)
 {
@@ -96,15 +123,13 @@ void do_gettimeofday(struct timeval *tv)
        clock_was_set();
 }
 
-EXPORT_SYMBOL(do_gettimeofday);
-
 int do_settimeofday(struct timespec *tv)
 {
        struct timeval now;
        unsigned long flags;
        struct timeval tv_in;
 
-       if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
+       if ((unsigned long) tv->tv_nsec >= UM_NSEC_PER_SEC)
                return -EINVAL;
 
        tv_in.tv_sec = tv->tv_sec;
@@ -114,9 +139,9 @@ int do_settimeofday(struct timespec *tv)
        gettimeofday(&now, NULL);
        timersub(&tv_in, &now, &local_offset);
        time_unlock(flags);
-}
 
-EXPORT_SYMBOL(do_settimeofday);
+       return(0);
+}
 
 void idle_sleep(int secs)
 {
index 752fd03..c36bff0 100644 (file)
@@ -20,6 +20,7 @@
 #include "user_util.h"
 #include "time_user.h"
 #include "mode.h"
+#include "os.h"
 
 u64 jiffies_64;
 
@@ -30,22 +31,61 @@ int hz(void)
        return(HZ);
 }
 
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ */
+unsigned long long sched_clock(void)
+{
+       return (unsigned long long)jiffies_64 * (1000000000 / HZ);
+}
+
 /* Changed at early boot */
 int timer_irq_inited = 0;
 
-/* missed_ticks will be modified after kernel memory has been 
- * write-protected, so this puts it in a section which will be left 
- * write-enabled.
- */
-int __attribute__ ((__section__ (".unprotected"))) missed_ticks[NR_CPUS];
+static int first_tick;
+static unsigned long long prev_usecs;
+static long long delta;                /* Deviation per interval */
+
+#define MILLION 1000000
 
 void timer_irq(union uml_pt_regs *regs)
 {
-       int cpu = current->thread_info->cpu, ticks = missed_ticks[cpu];
+       unsigned long long ticks = 0;
+
+       if(!timer_irq_inited){
+               /* This is to ensure that ticks don't pile up when
+                * the timer handler is suspended */
+               first_tick = 0;
+               return;
+       }
+
+       if(first_tick){
+#if defined(CONFIG_UML_REAL_TIME_CLOCK)
+               /* We've had 1 tick */
+               unsigned long long usecs = os_usecs();
+
+               delta += usecs - prev_usecs;
+               prev_usecs = usecs;
 
-        if(!timer_irq_inited) return;
-       missed_ticks[cpu] = 0;
-       while(ticks--) do_IRQ(TIMER_IRQ, regs);
+               /* Protect against the host clock being set backwards */
+               if(delta < 0)
+                       delta = 0;
+
+               ticks += (delta * HZ) / MILLION;
+               delta -= (ticks * MILLION) / HZ;
+#else
+               ticks = 1;
+#endif
+       }
+       else {
+               prev_usecs = os_usecs();
+               first_tick = 1;
+       }
+
+       while(ticks > 0){
+               do_IRQ(TIMER_IRQ, regs);
+               ticks--;
+       }
 }
 
 void boot_timer_handler(int sig)
@@ -58,12 +98,15 @@ void boot_timer_handler(int sig)
        do_timer(&regs);
 }
 
-void um_timer(int irq, void *dev, struct pt_regs *regs)
+irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
 {
+       unsigned long flags;
+
        do_timer(regs);
-       write_seqlock(&xtime_lock);
+       write_seqlock_irqsave(&xtime_lock, flags);
        timer();
-       write_sequnlock(&xtime_lock);
+       write_sequnlock_irqrestore(&xtime_lock, flags);
+       return(IRQ_HANDLED);
 }
 
 long um_time(int * tloc)
@@ -81,12 +124,12 @@ long um_time(int * tloc)
 long um_stime(int * tptr)
 {
        int value;
-       struct timeval new;
+       struct timespec new;
 
        if (get_user(value, tptr))
                 return -EFAULT;
        new.tv_sec = value;
-       new.tv_usec = 0;
+       new.tv_nsec = 0;
        do_settimeofday(&new);
        return 0;
 }
@@ -110,7 +153,7 @@ void __udelay(um_udelay_t usecs)
 {
        int i, n;
 
-       n = (loops_per_jiffy * HZ * usecs) / 1000000;
+       n = (loops_per_jiffy * HZ * usecs) / MILLION;
        for(i=0;i<n;i++) ;
 }
 
@@ -118,16 +161,18 @@ void __const_udelay(um_udelay_t usecs)
 {
        int i, n;
 
-       n = (loops_per_jiffy * HZ * usecs) / 1000000;
+       n = (loops_per_jiffy * HZ * usecs) / MILLION;
        for(i=0;i<n;i++) ;
 }
 
 void timer_handler(int sig, union uml_pt_regs *regs)
 {
 #ifdef CONFIG_SMP
+       local_irq_disable();
        update_process_times(user_context(UPT_SP(regs)));
+       local_irq_enable();
 #endif
-       if(current->thread_info->cpu == 0)
+       if(current_thread->cpu == 0)
                timer_irq(regs);
 }
 
@@ -136,6 +181,7 @@ static spinlock_t timer_spinlock = SPIN_LOCK_UNLOCKED;
 unsigned long time_lock(void)
 {
        unsigned long flags;
+
        spin_lock_irqsave(&timer_spinlock, flags);
        return(flags);
 }
@@ -150,8 +196,8 @@ int __init timer_init(void)
        int err;
 
        CHOOSE_MODE(user_time_init_tt(), user_time_init_skas());
-       if((err = request_irq(TIMER_IRQ, um_timer, SA_INTERRUPT, "timer", 
-                             NULL)) != 0)
+       err = request_irq(TIMER_IRQ, um_timer, SA_INTERRUPT, "timer", NULL);
+       if(err != 0)
                printk(KERN_ERR "timer_init : request_irq failed - "
                       "errno = %d\n", -err);
        timer_irq_inited = 1;
@@ -160,7 +206,6 @@ int __init timer_init(void)
 
 __initcall(timer_init);
 
-
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
index 7925dc4..443b828 100644 (file)
 #include "asm/tlbflush.h"
 #include "asm/a.out.h"
 #include "asm/current.h"
+#include "asm/irq.h"
 #include "user_util.h"
 #include "kern_util.h"
 #include "kern.h"
 #include "chan_kern.h"
 #include "mconsole_kern.h"
 #include "2_5compat.h"
+#include "mem.h"
+#include "mem_kern.h"
 
 int handle_page_fault(unsigned long address, unsigned long ip, 
                      int is_write, int is_user, int *code_out)
@@ -51,12 +54,12 @@ int handle_page_fault(unsigned long address, unsigned long ip,
        if(is_write && !(vma->vm_flags & VM_WRITE)) 
                goto out;
        page = address & PAGE_MASK;
-       if(page == (unsigned long) current->thread_info + PAGE_SIZE)
+       if(page == (unsigned long) current_thread + PAGE_SIZE)
                panic("Kernel stack overflow");
        pgd = pgd_offset(mm, page);
        pmd = pmd_offset(pgd, page);
- survive:
        do {
+ survive:
                switch (handle_mm_fault(mm, vma, address, is_write)){
                case VM_FAULT_MINOR:
                        current->min_flt++;
@@ -75,10 +78,10 @@ int handle_page_fault(unsigned long address, unsigned long ip,
                }
                pte = pte_offset_kernel(pmd, page);
        } while(!pte_present(*pte));
+       err = 0;
        *pte = pte_mkyoung(*pte);
        if(pte_write(*pte)) *pte = pte_mkdirty(*pte);
        flush_tlb_page(vma, page);
-       err = 0;
  out:
        up_read(&mm->mmap_sem);
        return(err);
@@ -94,10 +97,36 @@ out_of_memory:
                down_read(&mm->mmap_sem);
                goto survive;
        }
-       err = -ENOMEM;
        goto out;
 }
 
+LIST_HEAD(physmem_remappers);
+
+void register_remapper(struct remapper *info)
+{
+       list_add(&info->list, &physmem_remappers);
+}
+
+static int check_remapped_addr(unsigned long address, int is_write, int is_user)
+{
+       struct remapper *remapper;
+       struct list_head *ele;
+       __u64 offset;
+       int fd;
+
+       fd = phys_mapping(__pa(address), &offset);
+       if(fd == -1)
+               return(0);
+
+       list_for_each(ele, &physmem_remappers){
+               remapper = list_entry(ele, struct remapper, list);
+               if((*remapper->proc)(fd, address, is_write, offset, is_user))
+                       return(1);
+       }
+
+       return(0);
+}
+
 unsigned long segv(unsigned long address, unsigned long ip, int is_write, 
                   int is_user, void *sc)
 {
@@ -109,7 +138,9 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write,
                 flush_tlb_kernel_vm();
                 return(0);
         }
-        if(current->mm == NULL)
+       else if(check_remapped_addr(address & PAGE_MASK, is_write, is_user))
+               return(0);
+       else if(current->mm == NULL)
                panic("Segfault with no mm");
        err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
 
@@ -120,9 +151,8 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write,
                current->thread.fault_addr = (void *) address;
                do_longjmp(catcher, 1);
        } 
-       else if(current->thread.fault_addr != NULL){
+       else if(current->thread.fault_addr != NULL)
                panic("fault_addr set but no fault catcher");
-       }
        else if(arch_fixup(ip, sc))
                return(0);
 
@@ -155,8 +185,6 @@ void bad_segv(unsigned long address, unsigned long ip, int is_write)
 {
        struct siginfo si;
 
-       printk(KERN_ERR "Unfixable SEGV in '%s' (pid %d) at 0x%lx "
-              "(ip 0x%lx)\n", current->comm, current->pid, address, ip);
        si.si_signo = SIGSEGV;
        si.si_code = SEGV_ACCERR;
        si.si_addr = (void *) address;
@@ -180,6 +208,11 @@ void bus_handler(int sig, union uml_pt_regs *regs)
        else relay_signal(sig, regs);
 }
 
+void winch(int sig, union uml_pt_regs *regs)
+{
+       do_IRQ(WINCH_IRQ, regs);
+}
+
 void trap_init(void)
 {
 }
index 63812e5..d12eac6 100644 (file)
@@ -5,11 +5,9 @@
 
 #include <stdlib.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <setjmp.h>
 #include <signal.h>
 #include <sys/time.h>
-#include <sys/ioctl.h>
 #include <sys/ptrace.h>
 #include <sys/wait.h>
 #include <asm/page.h>
@@ -34,7 +32,14 @@ void kill_child_dead(int pid)
 {
        kill(pid, SIGKILL);
        kill(pid, SIGCONT);
-       while(waitpid(pid, NULL, 0) > 0) kill(pid, SIGCONT);
+       do {
+               int n;
+               CATCH_EINTR(n = waitpid(pid, NULL, 0));
+               if (n > 0)
+                       kill(pid, SIGCONT);
+               else
+                       break;
+       } while(1);
 }
 
 /* Unlocked - don't care if this is a bit off */
@@ -82,6 +87,8 @@ struct signal_info sig_info[] = {
                     .is_irq            = 0 },
        [ SIGILL ] { .handler           = relay_signal,
                     .is_irq            = 0 },
+       [ SIGWINCH ] { .handler         = winch,
+                      .is_irq          = 1 },
        [ SIGBUS ] { .handler           = bus_handler,
                     .is_irq            = 0 },
        [ SIGSEGV] { .handler           = segv_handler,
@@ -102,12 +109,11 @@ void sig_handler(int sig, struct sigcontext sc)
                         sig, &sc);
 }
 
-extern int timer_irq_inited, missed_ticks[];
+extern int timer_irq_inited;
 
 void alarm_handler(int sig, struct sigcontext sc)
 {
        if(!timer_irq_inited) return;
-       missed_ticks[cpu()]++;
 
        if(sig == SIGALRM)
                switch_timers(0);
@@ -121,9 +127,9 @@ void alarm_handler(int sig, struct sigcontext sc)
 
 void do_longjmp(void *b, int val)
 {
-       jmp_buf *buf = b;
+       sigjmp_buf *buf = b;
 
-       longjmp(*buf, val);
+       siglongjmp(*buf, val);
 }
 
 /*
index 439688b..33416e8 100644 (file)
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
 # Licensed under the GPL
 #
 
@@ -7,7 +7,7 @@ extra-y := unmap_fin.o
 
 obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
        syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \
-       uaccess_user.o sys-$(SUBARCH)/
+       uaccess.o uaccess_user.o sys-$(SUBARCH)/
 
 obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptproxy/
 
@@ -27,5 +27,3 @@ $(obj)/unmap.o: $(src)/unmap.c
 
 $(obj)/unmap_fin.o : $(src)/unmap.o
        ld -r -o $@ $< -lc -L/usr/lib
-
-clean :
index afd9471..065b504 100644 (file)
 #include "kern_util.h"
 #include "irq_user.h"
 #include "time_user.h"
+#include "signal_user.h"
 #include "mem_user.h"
 #include "os.h"
 #include "tlb.h"
+#include "mode.h"
 
 static int exec_tramp(void *sig_stack)
 {
@@ -38,8 +40,7 @@ void flush_thread_tt(void)
                do_exit(SIGKILL);
        }
                
-       new_pid = start_fork_tramp((void *) current->thread.kernel_stack,
-                                  stack, 0, exec_tramp);
+       new_pid = start_fork_tramp(current->thread_info, stack, 0, exec_tramp);
        if(new_pid < 0){
                printk(KERN_ERR 
                       "flush_thread : new thread failed, errno = %d\n",
@@ -47,17 +48,19 @@ void flush_thread_tt(void)
                do_exit(SIGKILL);
        }
 
-       if(current->thread_info->cpu == 0)
+       if(current_thread->cpu == 0)
                forward_interrupts(new_pid);
        current->thread.request.op = OP_EXEC;
        current->thread.request.u.exec.pid = new_pid;
-       unprotect_stack((unsigned long) current->thread_info);
+       unprotect_stack((unsigned long) current_thread);
        os_usr1_process(os_getpid());
+       change_sig(SIGUSR1, 1);
 
+       change_sig(SIGUSR1, 0);
        enable_timer();
        free_page(stack);
        protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
-       task_protections((unsigned long) current->thread_info);
+       task_protections((unsigned long) current_thread);
        force_flush_all();
        unblock_signals();
 }
index 35d1082..6d5fa82 100644 (file)
 void do_exec(int old_pid, int new_pid)
 {
        unsigned long regs[FRAME_SIZE];
+       int err;
 
        if((ptrace(PTRACE_ATTACH, new_pid, 0, 0) < 0) ||
-          (ptrace(PTRACE_CONT, new_pid, 0, 0) < 0) ||
-          (waitpid(new_pid, 0, WUNTRACED) < 0))
+          (ptrace(PTRACE_CONT, new_pid, 0, 0) < 0))
                tracer_panic("do_exec failed to attach proc - errno = %d",
                             errno);
 
+       CATCH_EINTR(err = waitpid(new_pid, 0, WUNTRACED));
+       if (err < 0)
+               tracer_panic("do_exec failed to attach proc in waitpid - errno = %d",
+                            errno);
+
        if(ptrace_getregs(old_pid, regs) < 0)
                tracer_panic("do_exec failed to get registers - errno = %d",
                             errno);
index 83d94ab..1a64e75 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "sysdep/ptrace.h"
 
+enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
+
 extern int tracing_pid;
 
 extern int tracer(int (*init_proc)(void *), void *sp);
index 42425a2..7399836 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -43,65 +43,19 @@ extern unsigned long get_fault_addr(void);
 
 extern int __do_copy_from_user(void *to, const void *from, int n,
                               void **fault_addr, void **fault_catcher);
-
-static inline int copy_from_user_tt(void *to, const void *from, int n)
-{
-       return(access_ok_tt(VERIFY_READ, from, n) ?
-              __do_copy_from_user(to, from, n, 
-                                  &current->thread.fault_addr,
-                                  &current->thread.fault_catcher) : n);
-}
-
-static inline int copy_to_user_tt(void *to, const void *from, int n)
-{
-       return(access_ok_tt(VERIFY_WRITE, to, n) ?
-              __do_copy_to_user(to, from, n, 
-                                  &current->thread.fault_addr,
-                                  &current->thread.fault_catcher) : n);
-}
-
 extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
                                  void **fault_addr, void **fault_catcher);
-
-static inline int strncpy_from_user_tt(char *dst, const char *src, int count)
-{
-       int n;
-
-       if(!access_ok_tt(VERIFY_READ, src, 1)) return(-EFAULT);
-       n = __do_strncpy_from_user(dst, src, count, 
-                                  &current->thread.fault_addr,
-                                  &current->thread.fault_catcher);
-       if(n < 0) return(-EFAULT);
-       return(n);
-}
-
 extern int __do_clear_user(void *mem, size_t len, void **fault_addr,
                           void **fault_catcher);
-
-static inline int __clear_user_tt(void *mem, int len)
-{
-       return(__do_clear_user(mem, len,
-                              &current->thread.fault_addr,
-                              &current->thread.fault_catcher));
-}
-
-static inline int clear_user_tt(void *mem, int len)
-{
-       return(access_ok_tt(VERIFY_WRITE, mem, len) ? 
-              __do_clear_user(mem, len, 
-                              &current->thread.fault_addr,
-                              &current->thread.fault_catcher) : len);
-}
-
 extern int __do_strnlen_user(const char *str, unsigned long n,
                             void **fault_addr, void **fault_catcher);
 
-static inline int strnlen_user_tt(const void *str, int len)
-{
-       return(__do_strnlen_user(str, len,
-                                &current->thread.fault_addr,
-                                &current->thread.fault_catcher));
-}
+extern int copy_from_user_tt(void *to, const void *from, int n);
+extern int copy_to_user_tt(void *to, const void *from, int n);
+extern int strncpy_from_user_tt(char *dst, const char *src, int count);
+extern int __clear_user_tt(void *mem, int len);
+extern int clear_user_tt(void *mem, int len);
+extern int strnlen_user_tt(const void *str, int len);
 
 #endif
 
index 0c39b26..34090b8 100644 (file)
@@ -18,7 +18,7 @@ void before_mem_tt(unsigned long brk_start)
        if(!jail || debug)
                remap_data(UML_ROUND_DOWN(&_stext), UML_ROUND_UP(&_etext), 1);
        remap_data(UML_ROUND_DOWN(&_sdata), UML_ROUND_UP(&_edata), 1);
-       remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(brk_start), 1);
+       remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1);
 }
 
 #ifdef CONFIG_HOST_2G_2G
index e10db3f..3085267 100644 (file)
@@ -25,14 +25,13 @@ void remap_data(void *segment_start, void *segment_end, int w)
        size = (unsigned long) segment_end - 
                (unsigned long) segment_start;
        data = create_mem_file(size);
-       if((addr = mmap(NULL, size, PROT_WRITE | PROT_READ, 
-                       MAP_SHARED, data, 0)) == MAP_FAILED){
+       addr = mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_SHARED, data, 0);
+       if(addr == MAP_FAILED){
                perror("mapping new data segment");
                exit(1);
        }
        memcpy(addr, segment_start, size);
-       if(switcheroo(data, prot, addr, segment_start, 
-                     size) < 0){
+       if(switcheroo(data, prot, addr, segment_start, size) < 0){
                printf("switcheroo failed\n");
                exit(1);
        }
index 7a2f330..177cb24 100644 (file)
@@ -62,7 +62,7 @@ void *switch_to_tt(void *prev, void *next, void *last)
        reading = 0;
        err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c));
        if(err != sizeof(c))
-               panic("write of switch_pipe failed, errno = %d", -err);
+               panic("write of switch_pipe failed, err = %d", -err);
 
        reading = 1;
        if((from->state == TASK_ZOMBIE) || (from->state == TASK_DEAD))
@@ -104,50 +104,92 @@ void *switch_to_tt(void *prev, void *next, void *last)
 
 void release_thread_tt(struct task_struct *task)
 {
-       os_kill_process(task->thread.mode.tt.extern_pid, 0);
+       int pid = task->thread.mode.tt.extern_pid;
+
+       if(os_getpid() != pid)
+               os_kill_process(pid, 0);
 }
 
 void exit_thread_tt(void)
 {
-       close(current->thread.mode.tt.switch_pipe[0]);
-       close(current->thread.mode.tt.switch_pipe[1]);
+       os_close_file(current->thread.mode.tt.switch_pipe[0]);
+       os_close_file(current->thread.mode.tt.switch_pipe[1]);
+}
+
+void suspend_new_thread(int fd)
+{
+       int err;
+       char c;
+
+       os_stop_process(os_getpid());
+       err = os_read_file(fd, &c, sizeof(c));
+       if(err != sizeof(c))
+               panic("read failed in suspend_new_thread, err = %d", -err);
 }
 
 void schedule_tail(task_t *prev);
 
 static void new_thread_handler(int sig)
 {
+       unsigned long disable;
        int (*fn)(void *);
        void *arg;
 
        fn = current->thread.request.u.thread.proc;
        arg = current->thread.request.u.thread.arg;
+
        UPT_SC(&current->thread.regs.regs) = (void *) (&sig + 1);
+       disable = (1 << (SIGVTALRM - 1)) | (1 << (SIGALRM - 1)) |
+               (1 << (SIGIO - 1)) | (1 << (SIGPROF - 1));
+       SC_SIGMASK(UPT_SC(&current->thread.regs.regs)) &= ~disable;
+
        suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
 
-       block_signals();
+       force_flush_all();
+       if(current->thread.prev_sched != NULL)
+               schedule_tail(current->thread.prev_sched);
+       current->thread.prev_sched = NULL;
+
        init_new_thread_signals(1);
-#ifdef CONFIG_SMP
-       schedule_tail(current->thread.prev_sched);
-#endif
        enable_timer();
        free_page(current->thread.temp_stack);
        set_cmdline("(kernel thread)");
-       force_flush_all();
 
-       current->thread.prev_sched = NULL;
        change_sig(SIGUSR1, 1);
        change_sig(SIGVTALRM, 1);
        change_sig(SIGPROF, 1);
-       unblock_signals();
+       local_irq_enable();
        if(!run_kernel_thread(fn, arg, &current->thread.exec_buf))
                do_exit(0);
+       
+       /* XXX No set_user_mode here because a newly execed process will
+        * immediately segfault on its non-existent IP, coming straight back
+        * to the signal handler, which will call set_user_mode on its way
+        * out.  This should probably change since it's confusing.
+        */
 }
 
 static int new_thread_proc(void *stack)
 {
+       /* local_irq_disable is needed to block out signals until this thread is
+        * properly scheduled.  Otherwise, the tracing thread will get mighty 
+        * upset about any signals that arrive before that.  
+        * This has the complication that it sets the saved signal mask in
+        * the sigcontext to block signals.  This gets restored when this
+        * thread (or a descendant, since they get a copy of this sigcontext)
+        * returns to userspace.
+        * So, this is compensated for elsewhere.
+        * XXX There is still a small window until local_irq_disable() actually 
+        * finishes where signals are possible - shouldn't be a problem in 
+        * practice since SIGIO hasn't been forwarded here yet, and the 
+        * local_irq_disable should finish before a SIGVTALRM has time to be 
+        * delivered.
+        */
+
+       local_irq_disable();
        init_new_thread_stack(stack, new_thread_handler);
        os_usr1_process(os_getpid());
+       change_sig(SIGUSR1, 1);
        return(0);
 }
 
@@ -156,7 +198,7 @@ static int new_thread_proc(void *stack)
  * itself with a SIGUSR1.  set_user_mode has to be run with SIGUSR1 off,
  * so it is blocked before it's called.  They are re-enabled on sigreturn
  * despite the fact that they were blocked when the SIGUSR1 was issued because
- * copy_thread copies the parent's signcontext, including the signal mask
+ * copy_thread copies the parent's sigcontext, including the signal mask
  * onto the signal frame.
  */
 
@@ -165,35 +207,33 @@ void finish_fork_handler(int sig)
        UPT_SC(&current->thread.regs.regs) = (void *) (&sig + 1);
        suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
 
-#ifdef CONFIG_SMP      
-       schedule_tail(NULL);
-#endif
+       force_flush_all();
+       if(current->thread.prev_sched != NULL)
+               schedule_tail(current->thread.prev_sched);
+       current->thread.prev_sched = NULL;
+
        enable_timer();
        change_sig(SIGVTALRM, 1);
        local_irq_enable();
-       force_flush_all();
        if(current->mm != current->parent->mm)
                protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 
                               1, 0, 1);
-       task_protections((unsigned long) current->thread_info);
-
-       current->thread.prev_sched = NULL;
+       task_protections((unsigned long) current_thread);
 
        free_page(current->thread.temp_stack);
+       local_irq_disable();
        change_sig(SIGUSR1, 0);
        set_user_mode(current);
 }
 
-static int sigusr1 = SIGUSR1;
-
 int fork_tramp(void *stack)
 {
-       int sig = sigusr1;
-
        local_irq_disable();
+       arch_init_thread();
        init_new_thread_stack(stack, finish_fork_handler);
 
-       kill(os_getpid(), sig);
+       os_usr1_process(os_getpid());
+       change_sig(SIGUSR1, 1);
        return(0);
 }
 
@@ -213,9 +253,9 @@ int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
        }
 
        err = os_pipe(p->thread.mode.tt.switch_pipe, 1, 1);
-       if(err){
-               printk("copy_thread : pipe failed, errno = %d\n", -err);
-               return(err);
+       if(err < 0){
+               printk("copy_thread : pipe failed, err = %d\n", -err);
+               goto out;
        }
 
        stack = alloc_stack(0, 0);
@@ -227,8 +267,7 @@ int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
 
        clone_flags &= CLONE_VM;
        p->thread.temp_stack = stack;
-       new_pid = start_fork_tramp((void *) p->thread.kernel_stack, stack,
-                                  clone_flags, tramp);
+       new_pid = start_fork_tramp(p->thread_info, stack, clone_flags, tramp);
        if(new_pid < 0){
                printk(KERN_ERR "copy_thread : clone failed - errno = %d\n", 
                       -new_pid);
@@ -246,19 +285,30 @@ int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
        current->thread.request.op = OP_FORK;
        current->thread.request.u.fork.pid = new_pid;
        os_usr1_process(os_getpid());
-       return(0);
+
+       /* Enable the signal and then disable it to ensure that it is handled
+        * here, and nowhere else.
+        */
+       change_sig(SIGUSR1, 1);
+
+       change_sig(SIGUSR1, 0);
+       err = 0;
+ out:
+       return(err);
 }
 
 void reboot_tt(void)
 {
        current->thread.request.op = OP_REBOOT;
        os_usr1_process(os_getpid());
+       change_sig(SIGUSR1, 1);
 }
 
 void halt_tt(void)
 {
        current->thread.request.op = OP_HALT;
        os_usr1_process(os_getpid());
+       change_sig(SIGUSR1, 1);
 }
 
 void kill_off_processes_tt(void)
@@ -285,6 +335,9 @@ void initial_thread_cb_tt(void (*proc)(void *), void *arg)
                current->thread.request.u.cb.proc = proc;
                current->thread.request.u.cb.arg = arg;
                os_usr1_process(os_getpid());
+               change_sig(SIGUSR1, 1);
+
+               change_sig(SIGUSR1, 0);
        }
 }
 
@@ -377,8 +430,8 @@ static void mprotect_kernel_mem(int w)
 
        pages = (1 << CONFIG_KERNEL_STACK_ORDER);
 
-       start = (unsigned long) current->thread_info + PAGE_SIZE;
-       end = (unsigned long) current + PAGE_SIZE * pages;
+       start = (unsigned long) current_thread + PAGE_SIZE;
+       end = (unsigned long) current_thread + PAGE_SIZE * pages;
        protect_memory(uml_reserved, start - uml_reserved, 1, w, 1, 1);
        protect_memory(end, high_physmem - end, 1, w, 1, 1);
 
@@ -454,8 +507,9 @@ void set_init_pid(int pid)
 
        init_task.thread.mode.tt.extern_pid = pid;
        err = os_pipe(init_task.thread.mode.tt.switch_pipe, 1, 1);
-       if(err) panic("Can't create switch pipe for init_task, errno = %d", 
-                     err);
+       if(err)
+               panic("Can't create switch pipe for init_task, errno = %d", 
+                     -err);
 }
 
 int singlestepping_tt(void *t)
@@ -479,9 +533,9 @@ int start_uml_tt(void)
        void *sp;
        int pages;
 
-       pages = (1 << CONFIG_KERNEL_STACK_ORDER) - 2;
-       sp = (void *) init_task.thread.kernel_stack + pages * PAGE_SIZE - 
-               sizeof(unsigned long);
+       pages = (1 << CONFIG_KERNEL_STACK_ORDER);
+       sp = (void *) ((unsigned long) init_task.thread_info) + 
+               pages * PAGE_SIZE - sizeof(unsigned long);
        return(tracer(start_kernel_proc, sp));
 }
 
index 97d4f0b..9f9daf5 100644 (file)
@@ -9,5 +9,3 @@ USER_OBJS := $(foreach file,$(obj-y),$(src)/$(file))
 
 $(USER_OBJS) : %.o: %.c
        $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
-
-clean:
index 65504f8..458ecf9 100644 (file)
@@ -15,7 +15,6 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
-#include <fcntl.h>
 #include <termios.h>
 #include <sys/wait.h>
 #include <sys/types.h>
@@ -273,7 +272,7 @@ void fake_child_exit(void)
 
        child_proxy(1, W_EXITCODE(0, 0));
        while(debugger.waiting == 1){
-               pid = waitpid(debugger.pid, &status, WUNTRACED);
+               CATCH_EINTR(pid = waitpid(debugger.pid, &status, WUNTRACED));
                if(pid != debugger.pid){
                        printk("fake_child_exit - waitpid failed, "
                               "errno = %d\n", errno);
@@ -281,7 +280,7 @@ void fake_child_exit(void)
                }
                debugger_proxy(status, debugger.pid);
        }
-       pid = waitpid(debugger.pid, &status, WUNTRACED);
+       CATCH_EINTR(pid = waitpid(debugger.pid, &status, WUNTRACED));
        if(pid != debugger.pid){
                printk("fake_child_exit - waitpid failed, "
                       "errno = %d\n", errno);
@@ -293,10 +292,10 @@ void fake_child_exit(void)
 }
 
 char gdb_init_string[] = 
-"att 1
-b panic
-b stop
-handle SIGWINCH nostop noprint pass
+"att 1 \n\
+b panic \n\
+b stop \n\
+handle SIGWINCH nostop noprint pass \n\
 ";
 
 int start_debugger(char *prog, int startup, int stop, int *fd_out)
@@ -304,7 +303,8 @@ int start_debugger(char *prog, int startup, int stop, int *fd_out)
        int slave, child;
 
        slave = open_gdb_chan();
-       if((child = fork()) == 0){
+       child = fork();
+       if(child == 0){
                char *tempname = NULL;
                int fd;
 
@@ -327,18 +327,19 @@ int start_debugger(char *prog, int startup, int stop, int *fd_out)
                        exit(1);
 #endif
                }
-               if((fd = make_tempfile("/tmp/gdb_init-XXXXXX", &tempname, 0)) < 0){
-                       printk("start_debugger : make_tempfile failed, errno = %d\n",
-                              errno);
+               fd = make_tempfile("/tmp/gdb_init-XXXXXX", &tempname, 0);
+               if(fd < 0){
+                       printk("start_debugger : make_tempfile failed,"
+                              "err = %d\n", -fd);
                        exit(1);
                }
-               write(fd, gdb_init_string, sizeof(gdb_init_string) - 1);
+               os_write_file(fd, gdb_init_string, sizeof(gdb_init_string) - 1);
                if(startup){
                        if(stop){
-                               write(fd, "b start_kernel\n",
+                               os_write_file(fd, "b start_kernel\n",
                                      strlen("b start_kernel\n"));
                        }
-                       write(fd, "c\n", strlen("c\n"));
+                       os_write_file(fd, "c\n", strlen("c\n"));
                }
                if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
                        printk("start_debugger :  PTRACE_TRACEME failed, "
index 50a120d..c42855a 100644 (file)
@@ -9,6 +9,7 @@ terms and conditions.
 #include <string.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/ptrace.h>
 #include <asm/ptrace.h>
index aad7e4b..86ef676 100644 (file)
@@ -56,21 +56,23 @@ int parent_wait_return(struct debugger *debugger, pid_t unused)
 int real_wait_return(struct debugger *debugger)
 {
        unsigned long ip;
-       int err, pid;
+       int pid;
 
        pid = debugger->pid;
+
        ip = ptrace(PTRACE_PEEKUSER, pid, PT_IP_OFFSET, 0);
-       ip = IP_RESTART_SYSCALL(ip);
-       err = ptrace(PTRACE_POKEUSER, pid, PT_IP_OFFSET, ip);
+       IP_RESTART_SYSCALL(ip);
+
        if(ptrace(PTRACE_POKEUSER, pid, PT_IP_OFFSET, ip) < 0)
                tracer_panic("real_wait_return : Failed to restart system "
-                            "call, errno = %d\n");
+                            "call, errno = %d\n", errno);
+
        if((ptrace(PTRACE_SYSCALL, debugger->pid, 0, SIGCHLD) < 0) ||
           (ptrace(PTRACE_SYSCALL, debugger->pid, 0, 0) < 0) ||
           (ptrace(PTRACE_SYSCALL, debugger->pid, 0, 0) < 0) ||
           debugger_normal_return(debugger, -1))
                tracer_panic("real_wait_return : gdb failed to wait, "
-                            "errno = %d\n");
+                            "errno = %d\n", errno);
        return(0);
 }
 
index 2ad8271..3eeea05 100644 (file)
@@ -10,5 +10,3 @@ USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
 $(USER_OBJS) : %.o: %.c
        $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
-
-clean :
index 1b71f9c..555ffd0 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
index f7c845d..1cabbd8 100644 (file)
@@ -33,7 +33,7 @@ void syscall_handler_tt(int sig, union uml_pt_regs *regs)
        SC_START_SYSCALL(sc);
 
        index = record_syscall_start(syscall);
-       syscall_trace();
+       syscall_trace(regs, 1);
        result = execute_syscall(regs);
 
        /* regs->sc may have changed while the system call ran (there may
@@ -46,7 +46,7 @@ void syscall_handler_tt(int sig, union uml_pt_regs *regs)
           (result == -ERESTARTNOINTR))
                do_signal(result);
 
-       syscall_trace();
+       syscall_trace(regs, 0);
        record_syscall_end(index, result);
 }
 
index 32ac316..d8ad334 100644 (file)
@@ -10,6 +10,7 @@
 #include "asm/page.h"
 #include "asm/pgtable.h"
 #include "asm/uaccess.h"
+#include "asm/tlbflush.h"
 #include "user_util.h"
 #include "mem_user.h"
 #include "os.h"
index 6a6322a..1b54774 100644 (file)
@@ -39,16 +39,17 @@ int is_tracer_winch(int pid, int fd, void *data)
                return(0);
 
        register_winch_irq(tracer_winch[0], fd, -1, data);
-       return(0);
+       return(1);
 }
 
 static void tracer_winch_handler(int sig)
 {
+       int n;
        char c = 1;
 
-       if(write(tracer_winch[1], &c, sizeof(c)) != sizeof(c))
-               printk("tracer_winch_handler - write failed, errno = %d\n",
-                      errno);
+       n = os_write_file(tracer_winch[1], &c, sizeof(c));
+       if(n != sizeof(c))
+               printk("tracer_winch_handler - write failed, err = %d\n", -n);
 }
 
 /* Called only by the tracing thread during initialization */
@@ -58,9 +59,8 @@ static void setup_tracer_winch(void)
        int err;
 
        err = os_pipe(tracer_winch, 1, 1);
-       if(err){
-               printk("setup_tracer_winch : os_pipe failed, errno = %d\n", 
-                      -err);
+       if(err < 0){
+               printk("setup_tracer_winch : os_pipe failed, err = %d\n", -err);
                return;
        }
        signal(SIGWINCH, tracer_winch_handler);
@@ -130,8 +130,8 @@ static void sleeping_process_signal(int pid, int sig)
        case SIGTSTP:
                if(ptrace(PTRACE_CONT, pid, 0, sig) < 0)
                        tracer_panic("sleeping_process_signal : Failed to "
-                                    "continue pid %d, errno = %d\n", pid,
-                                    sig);
+                                    "continue pid %d, signal = %d, "
+                                    "errno = %d\n", pid, sig, errno);
                break;
 
        /* This happens when the debugger (e.g. strace) is doing system call 
@@ -145,7 +145,7 @@ static void sleeping_process_signal(int pid, int sig)
                if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
                        tracer_panic("sleeping_process_signal : Failed to "
                                     "PTRACE_SYSCALL pid %d, errno = %d\n",
-                                    pid, sig);
+                                    pid, errno);
                break;
        case SIGSTOP:
                break;
@@ -192,7 +192,7 @@ int tracer(int (*init_proc)(void *), void *sp)
        printf("tracing thread pid = %d\n", tracing_pid);
 
        pid = clone(signal_tramp, sp, CLONE_FILES | SIGCHLD, init_proc);
-       n = waitpid(pid, &status, WUNTRACED);
+       CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if(n < 0){
                printf("waitpid on idle thread failed, errno = %d\n", errno);
                exit(1);
@@ -218,7 +218,7 @@ int tracer(int (*init_proc)(void *), void *sp)
                        err = attach(debugger_parent);
                        if(err){
                                printf("Failed to attach debugger parent %d, "
-                                      "errno = %d\n", debugger_parent, err);
+                                      "errno = %d\n", debugger_parent, -err);
                                debugger_parent = -1;
                        }
                        else {
@@ -233,7 +233,8 @@ int tracer(int (*init_proc)(void *), void *sp)
        }
        set_cmdline("(tracing thread)");
        while(1){
-               if((pid = waitpid(-1, &status, WUNTRACED)) <= 0){
+               CATCH_EINTR(pid = waitpid(-1, &status, WUNTRACED));
+               if(pid <= 0){
                        if(errno != ECHILD){
                                printf("wait failed - errno = %d\n", errno);
                        }
@@ -401,7 +402,7 @@ static int __init uml_debug_setup(char *line, int *add)
                
                if(!strcmp(line, "go")) debug_stop = 0;
                else if(!strcmp(line, "parent")) debug_parent = 1;
-               else printk("Unknown debug option : '%s'\n", line);
+               else printf("Unknown debug option : '%s'\n", line);
 
                line = next;
        }
index 7a6dbf5..00bacac 100644 (file)
@@ -23,6 +23,13 @@ void sig_handler_common_tt(int sig, void *sc_ptr)
 
        unprotect_kernel_mem();
 
+       /* This is done because to allow SIGSEGV to be delivered inside a SEGV
+        * handler.  This can happen in copy_user, and if SEGV is disabled,
+        * the process will die.
+        */
+       if(sig == SIGSEGV)
+               change_sig(SIGSEGV, 1);
+
        r = &TASK_REGS(get_current())->tt;
        save_regs = *r;
        is_user = user_context(SC_SP(sc));
@@ -30,7 +37,6 @@ void sig_handler_common_tt(int sig, void *sc_ptr)
        if(sig != SIGUSR2) 
                r->syscall = -1;
 
-       change_sig(SIGUSR1, 1);
        info = &sig_info[sig];
        if(!info->is_irq) unblock_signals();
 
@@ -39,7 +45,6 @@ void sig_handler_common_tt(int sig, void *sc_ptr)
        if(is_user){
                interrupt_end();
                block_signals();
-               change_sig(SIGUSR1, 0);
                set_user_mode(NULL);
        }
        *r = save_regs;
diff --git a/arch/um/kernel/tt/uaccess.c b/arch/um/kernel/tt/uaccess.c
deleted file mode 100644 (file)
index 9c84011..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* 
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/sched.h"
-#include "asm/uaccess.h"
-
-int copy_from_user_tt(void *to, const void *from, int n)
-{
-       if(!access_ok_tt(VERIFY_READ, from, n)) 
-               return(n);
-
-       return(__do_copy_from_user(to, from, n, &current->thread.fault_addr,
-                                  &current->thread.fault_catcher));
-}
-
-int copy_to_user_tt(void *to, const void *from, int n)
-{
-       if(!access_ok_tt(VERIFY_WRITE, to, n))
-               return(n);
-               
-       return(__do_copy_to_user(to, from, n, &current->thread.fault_addr,
-                                &current->thread.fault_catcher));
-}
-
-int strncpy_from_user_tt(char *dst, const char *src, int count)
-{
-       int n;
-
-       if(!access_ok_tt(VERIFY_READ, src, 1)) 
-               return(-EFAULT);
-
-       n = __do_strncpy_from_user(dst, src, count, 
-                                  &current->thread.fault_addr,
-                                  &current->thread.fault_catcher);
-       if(n < 0) return(-EFAULT);
-       return(n);
-}
-
-int __clear_user_tt(void *mem, int len)
-{
-       return(__do_clear_user(mem, len,
-                              &current->thread.fault_addr,
-                              &current->thread.fault_catcher));
-}
-
-int clear_user_tt(void *mem, int len)
-{
-       if(!access_ok_tt(VERIFY_WRITE, mem, len))
-               return(len);
-
-       return(__do_clear_user(mem, len, &current->thread.fault_addr,
-                              &current->thread.fault_catcher));
-}
-
-int strnlen_user_tt(const void *str, int len)
-{
-       return(__do_strnlen_user(str, len,
-                                &current->thread.fault_addr,
-                                &current->thread.fault_catcher));
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 537ee9f..f014755 100644 (file)
@@ -8,15 +8,20 @@
 #include <string.h>
 #include "user_util.h"
 #include "uml_uaccess.h"
+#include "task.h"
+#include "kern_util.h"
 
 int __do_copy_from_user(void *to, const void *from, int n,
                        void **fault_addr, void **fault_catcher)
 {
+       struct tt_regs save = TASK_REGS(get_current())->tt;
        unsigned long fault;
        int faulted;
 
        fault = __do_user_copy(to, from, n, fault_addr, fault_catcher,
                               __do_copy, &faulted);
+       TASK_REGS(get_current())->tt = save;
+
        if(!faulted) return(0);
        else return(n - (fault - (unsigned long) from));
 }
@@ -29,11 +34,14 @@ static void __do_strncpy(void *dst, const void *src, int count)
 int __do_strncpy_from_user(char *dst, const char *src, unsigned long count,
                           void **fault_addr, void **fault_catcher)
 {
+       struct tt_regs save = TASK_REGS(get_current())->tt;
        unsigned long fault;
        int faulted;
 
        fault = __do_user_copy(dst, src, count, fault_addr, fault_catcher,
                               __do_strncpy, &faulted);
+       TASK_REGS(get_current())->tt = save;
+
        if(!faulted) return(strlen(dst));
        else return(-1);
 }
@@ -46,11 +54,14 @@ static void __do_clear(void *to, const void *from, int n)
 int __do_clear_user(void *mem, unsigned long len,
                    void **fault_addr, void **fault_catcher)
 {
+       struct tt_regs save = TASK_REGS(get_current())->tt;
        unsigned long fault;
        int faulted;
 
        fault = __do_user_copy(mem, NULL, len, fault_addr, fault_catcher,
                               __do_clear, &faulted);
+       TASK_REGS(get_current())->tt = save;
+
        if(!faulted) return(0);
        else return(len - (fault - (unsigned long) mem));
 }
@@ -58,19 +69,20 @@ int __do_clear_user(void *mem, unsigned long len,
 int __do_strnlen_user(const char *str, unsigned long n,
                      void **fault_addr, void **fault_catcher)
 {
+       struct tt_regs save = TASK_REGS(get_current())->tt;
        int ret;
        unsigned long *faddrp = (unsigned long *)fault_addr;
-       jmp_buf jbuf;
+       sigjmp_buf jbuf;
 
        *fault_catcher = &jbuf;
-       if(setjmp(jbuf) == 0){
+       if(sigsetjmp(jbuf, 1) == 0)
                ret = strlen(str) + 1;
-       } 
-       else {
-               ret = *faddrp - (unsigned long) str;
-       }
+       else ret = *faddrp - (unsigned long) str;
+
        *fault_addr = NULL;
        *fault_catcher = NULL;
+
+       TASK_REGS(get_current())->tt = save;
        return ret;
 }
 
index 36d3e69..3f7aecd 100644 (file)
@@ -3,10 +3,7 @@
  * Licensed under the GPL
  */
 
-#include <stdio.h>
-#include <errno.h>
 #include <sys/mman.h>
-#include "user.h"
 
 int switcheroo(int fd, int prot, void *from, void *to, int size)
 {
index 61c4cc3..148b86a 100644 (file)
@@ -9,10 +9,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <sys/time.h>
 #include "init.h"
 #include "user.h"
+#include "kern_util.h"
 #include "os.h"
 
 #define TTY_LOG_DIR "./"
@@ -24,29 +24,40 @@ static int tty_log_fd = -1;
 #define TTY_LOG_OPEN 1
 #define TTY_LOG_CLOSE 2
 #define TTY_LOG_WRITE 3
+#define TTY_LOG_EXEC 4
+
+#define TTY_READ 1
+#define TTY_WRITE 2
 
 struct tty_log_buf {
        int what;
        unsigned long tty;
        int len;
+       int direction;
+       unsigned long sec;
+       unsigned long usec;
 };
 
-int open_tty_log(void *tty)
+int open_tty_log(void *tty, void *current_tty)
 {
        struct timeval tv;
        struct tty_log_buf data;
        char buf[strlen(tty_log_dir) + sizeof("01234567890-01234567\0")];
        int fd;
 
+       gettimeofday(&tv, NULL);
        if(tty_log_fd != -1){
-               data = ((struct tty_log_buf) { what :   TTY_LOG_OPEN,
-                                              tty : (unsigned long) tty,
-                                              len : 0 });
-               write(tty_log_fd, &data, sizeof(data));
+               data = ((struct tty_log_buf) { .what    = TTY_LOG_OPEN,
+                                              .tty  = (unsigned long) tty,
+                                              .len  = sizeof(current_tty),
+                                              .direction = 0,
+                                              .sec = tv.tv_sec,
+                                              .usec = tv.tv_usec } );
+               os_write_file(tty_log_fd, &data, sizeof(data));
+               os_write_file(tty_log_fd, &current_tty, data.len);
                return(tty_log_fd);
        }
 
-       gettimeofday(&tv, NULL);
        sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec, 
                (unsigned int) tv.tv_usec);
 
@@ -62,30 +73,117 @@ int open_tty_log(void *tty)
 void close_tty_log(int fd, void *tty)
 {
        struct tty_log_buf data;
+       struct timeval tv;
 
        if(tty_log_fd != -1){
-               data = ((struct tty_log_buf) { what :   TTY_LOG_CLOSE,
-                                              tty : (unsigned long) tty,
-                                              len : 0 });
-               write(tty_log_fd, &data, sizeof(data));
+               gettimeofday(&tv, NULL);
+               data = ((struct tty_log_buf) { .what    = TTY_LOG_CLOSE,
+                                              .tty  = (unsigned long) tty,
+                                              .len  = 0,
+                                              .direction = 0,
+                                              .sec = tv.tv_sec,
+                                              .usec = tv.tv_usec } );
+               os_write_file(tty_log_fd, &data, sizeof(data));
                return;
        }
-       close(fd);
+       os_close_file(fd);
 }
 
-int write_tty_log(int fd, char *buf, int len, void *tty)
+static int log_chunk(int fd, const char *buf, int len)
 {
+       int total = 0, try, missed, n;
+       char chunk[64];
+
+       while(len > 0){
+               try = (len > sizeof(chunk)) ? sizeof(chunk) : len;
+               missed = copy_from_user_proc(chunk, (char *) buf, try);
+               try -= missed;
+               n = os_write_file(fd, chunk, try);
+               if(n != try) {
+                       if(n < 0) 
+                               return(n);
+                       return(-EIO);
+               }
+               if(missed != 0)
+                       return(-EFAULT);
+
+               len -= try;
+               total += try;
+               buf += try;
+       }
+
+       return(total);
+}
+
+int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read)
+{
+       struct timeval tv;
        struct tty_log_buf data;
+       int direction;
 
        if(fd == tty_log_fd){
-               data = ((struct tty_log_buf) { what :   TTY_LOG_WRITE,
-                                              tty : (unsigned long) tty,
-                                              len : len });
-               write(tty_log_fd, &data, sizeof(data));
+               gettimeofday(&tv, NULL);
+               direction = is_read ? TTY_READ : TTY_WRITE;
+               data = ((struct tty_log_buf) { .what    = TTY_LOG_WRITE,
+                                              .tty  = (unsigned long) tty,
+                                              .len  = len,
+                                              .direction = direction,
+                                              .sec = tv.tv_sec,
+                                              .usec = tv.tv_usec } );
+               os_write_file(tty_log_fd, &data, sizeof(data));
        }
-       return(write(fd, buf, len));
+
+       return(log_chunk(fd, buf, len));
 }
 
+void log_exec(char **argv, void *tty)
+{
+       struct timeval tv;
+       struct tty_log_buf data;
+       char **ptr,*arg;
+       int len;
+       
+       if(tty_log_fd == -1) return;
+
+       gettimeofday(&tv, NULL);
+
+       len = 0;
+       for(ptr = argv; ; ptr++){
+               if(copy_from_user_proc(&arg, ptr, sizeof(arg)))
+                       return;
+               if(arg == NULL) break;
+               len += strlen_user_proc(arg);
+       }
+
+       data = ((struct tty_log_buf) { .what    = TTY_LOG_EXEC,
+                                      .tty  = (unsigned long) tty,
+                                      .len  = len,
+                                      .direction = 0,
+                                      .sec = tv.tv_sec,
+                                      .usec = tv.tv_usec } );
+       os_write_file(tty_log_fd, &data, sizeof(data));
+
+       for(ptr = argv; ; ptr++){
+               if(copy_from_user_proc(&arg, ptr, sizeof(arg)))
+                       return;
+               if(arg == NULL) break;
+               log_chunk(tty_log_fd, arg, strlen_user_proc(arg));
+       }
+}
+
+extern void register_tty_logger(int (*opener)(void *, void *),
+                               int (*writer)(int, const char *, int, 
+                                             void *, int),
+                               void (*closer)(int, void *));
+
+static int register_logger(void)
+{
+       register_tty_logger(open_tty_log, write_tty_log, close_tty_log);
+       return(0);
+}
+
+__uml_initcall(register_logger);
+
 static int __init set_tty_log_dir(char *name, int *add)
 {
        tty_log_dir = name;
@@ -104,9 +202,11 @@ static int __init set_tty_log_fd(char *name, int *add)
 
        tty_log_fd = strtoul(name, &end, 0);
        if((*end != '\0') || (end == name)){
-               printk("set_tty_log_fd - strtoul failed on '%s'\n", name);
+               printf("set_tty_log_fd - strtoul failed on '%s'\n", name);
                tty_log_fd = -1;
        }
+
+       *add = 0;
        return 0;
 }
 
index eb9be24..d035257 100644 (file)
@@ -18,9 +18,9 @@ unsigned long __do_user_copy(void *to, const void *from, int n,
 {
        unsigned long *faddrp = (unsigned long *) fault_addr, ret;
 
-       jmp_buf jbuf;
+       sigjmp_buf jbuf;
        *fault_catcher = &jbuf;
-       if(setjmp(jbuf) == 0){
+       if(sigsetjmp(jbuf, 1) == 0){
                (*op)(to, from, n);
                ret = 0;
                *faulted_out = 0;
index e8f0cac..802b7fb 100644 (file)
@@ -27,7 +27,6 @@
 #include "user_util.h"
 #include "kern_util.h"
 #include "kern.h"
-#include "mprot.h"
 #include "mem_user.h"
 #include "mem.h"
 #include "umid.h"
 #include "mode_kern.h"
 #include "mode.h"
 
-#define DEFAULT_COMMAND_LINE "root=6200"
+#define DEFAULT_COMMAND_LINE "root=98:0"
 
 struct cpuinfo_um boot_cpu_data = { 
        .loops_per_jiffy        = 0,
        .ipi_pipe               = { -1, -1 }
 };
 
+/* Placeholder to make UML link until the vsyscall stuff is actually 
+ * implemented
+ */
+void *__kernel_vsyscall;
+
 unsigned long thread_saved_pc(struct task_struct *task)
 {
        return(os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
@@ -53,18 +57,22 @@ unsigned long thread_saved_pc(struct task_struct *task)
 
 static int show_cpuinfo(struct seq_file *m, void *v)
 {
-       int index;
+       int index = 0;
 
-       index = (struct cpuinfo_um *)v - cpu_data;
 #ifdef CONFIG_SMP
+       index = (struct cpuinfo_um *) v - cpu_data;
        if (!cpu_online(index))
                return 0;
 #endif
 
-       seq_printf(m, "bogomips\t: %lu.%02lu\n",
+       seq_printf(m, "processor\t: %d\n", index);
+       seq_printf(m, "vendor_id\t: User Mode Linux\n");
+       seq_printf(m, "model name\t: UML\n");
+       seq_printf(m, "mode\t\t: %s\n", CHOOSE_MODE("tt", "skas"));
+       seq_printf(m, "host\t\t: %s\n", host_info);
+       seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
                   loops_per_jiffy/(500000/HZ),
                   (loops_per_jiffy/(5000/HZ)) % 100);
-       seq_printf(m, "host\t\t: %s\n", host_info);
 
        return(0);
 }
@@ -134,12 +142,12 @@ void set_cmdline(char *cmd)
        if(umid != NULL){
                snprintf(argv1_begin, 
                         (argv1_end - argv1_begin) * sizeof(*ptr), 
-                        "(%s)", umid);
+                        "(%s) ", umid);
                ptr = &argv1_begin[strlen(argv1_begin)];
        }
        else ptr = argv1_begin;
 
-       snprintf(ptr, (argv1_end - ptr) * sizeof(*ptr), " [%s]", cmd);
+       snprintf(ptr, (argv1_end - ptr) * sizeof(*ptr), "[%s]", cmd);
        memset(argv1_begin + strlen(argv1_begin), '\0', 
               argv1_end - argv1_begin - strlen(argv1_begin));
 #endif
@@ -179,7 +187,7 @@ __uml_setup("root=", uml_root_setup,
 static int __init uml_ncpus_setup(char *line, int *add)
 {
        if (!sscanf(line, "%d", &ncpus)) {
-               printk("Couldn't parse [%s]\n", line);
+               printf("Couldn't parse [%s]\n", line);
                return -1;
        }
 
@@ -210,7 +218,7 @@ static int __init mode_tt_setup(char *line, int *add)
 
 static int __init mode_tt_setup(char *line, int *add)
 {
-       printk("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
+       printf("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
        return(0);
 }
 
@@ -221,7 +229,7 @@ static int __init mode_tt_setup(char *line, int *add)
 
 static int __init mode_tt_setup(char *line, int *add)
 {
-       printk("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
+       printf("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
        return(0);
 }
 
@@ -291,15 +299,15 @@ static void __init uml_postsetup(void)
 
 /* Set during early boot */
 unsigned long brk_start;
-static struct vm_reserved kernel_vm_reserved;
+unsigned long end_iomem;
 
 #define MIN_VMALLOC (32 * 1024 * 1024)
 
 int linux_main(int argc, char **argv)
 {
-       unsigned long avail;
+       unsigned long avail, diff;
        unsigned long virtmem_size, max_physmem;
-       unsigned int i, add, err;
+       unsigned int i, add;
 
        for (i = 1; i < argc; i++){
                if((i == 1) && (argv[i][0] == ' ')) continue;
@@ -315,6 +323,16 @@ int linux_main(int argc, char **argv)
 
        brk_start = (unsigned long) sbrk(0);
        CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start);
+       /* Increase physical memory size for exec-shield users
+       so they actually get what they asked for. This should
+       add zero for non-exec shield users */
+       
+       diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
+       if(diff > 1024 * 1024){
+               printf("Adding %ld bytes to physical memory to account for "
+                      "exec-shield gap\n", diff);
+               physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
+       }
 
        uml_physmem = uml_start;
 
@@ -328,12 +346,16 @@ int linux_main(int argc, char **argv)
        argv1_end = &argv[1][strlen(argv[1])];
 #endif
   
-       set_usable_vm(uml_physmem, get_kmem_end());
-
        highmem = 0;
-       max_physmem = get_kmem_end() - uml_physmem - MIN_VMALLOC;
-       if(physmem_size > max_physmem){
-               highmem = physmem_size - max_physmem;
+       iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
+       max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC;
+
+       /* Zones have to begin on a 1 << MAX_ORDER page boundary,
+        * so this makes sure that's true for highmem
+        */
+       max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER)) - 1);
+       if(physmem_size + iomem_size > max_physmem){
+               highmem = physmem_size + iomem_size - max_physmem;
                physmem_size -= highmem;
 #ifndef CONFIG_HIGHMEM
                highmem = 0;
@@ -343,11 +365,19 @@ int linux_main(int argc, char **argv)
        }
 
        high_physmem = uml_physmem + physmem_size;
-       high_memory = (void *) high_physmem;
+       end_iomem = high_physmem + iomem_size;
+       high_memory = (void *) end_iomem;
 
        start_vm = VMALLOC_START;
 
-       setup_physmem(uml_physmem, uml_reserved, physmem_size);
+       setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
+       if(init_maps(physmem_size, iomem_size, highmem)){
+               printf("Failed to allocate mem_map for %ld bytes of physical "
+                      "memory and %ld bytes of highmem\n", physmem_size,
+                      highmem);
+               exit(1);
+       }
+
        virtmem_size = physmem_size;
        avail = get_kmem_end() - start_vm;
        if(physmem_size > avail) virtmem_size = avail;
@@ -357,28 +387,23 @@ int linux_main(int argc, char **argv)
                printf("Kernel virtual memory size shrunk to %ld bytes\n",
                       virtmem_size);
 
-       err = reserve_vm(high_physmem, end_vm, &kernel_vm_reserved);
-       if(err){
-               printf("Failed to reserve VM area for kernel VM\n");
-               exit(1);
-       }
-
        uml_postsetup();
 
-       init_task.thread.kernel_stack = (unsigned long) &init_thread_info + 
-               2 * PAGE_SIZE;
-
        task_protections((unsigned long) &init_thread_info);
+       os_flush_stdout();
 
        return(CHOOSE_MODE(start_uml_tt(), start_uml_skas()));
 }
 
+extern int uml_exitcode;
+
 static int panic_exit(struct notifier_block *self, unsigned long unused1,
                      void *unused2)
 {
 #ifdef CONFIG_MAGIC_SYSRQ
-       handle_sysrq('p', &current->thread.regs, NULL, NULL);
+       handle_sysrq('p', &current->thread.regs, NULL);
 #endif
+       uml_exitcode = 1;
        machine_halt();
        return(0);
 }
@@ -403,6 +428,11 @@ void __init check_bugs(void)
        arch_check_bugs();
        check_ptrace();
        check_sigio();
+       check_devanon();
+}
+
+void apply_alternatives(void *start, void *end)
+{
 }
 
 /*
index 1da1a0d..f609e11 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <stdio.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
@@ -33,18 +32,19 @@ static char *uml_dir = UML_DIR;
 static int umid_is_random = 1;
 static int umid_inited = 0;
 
-static int make_umid(void);
+static int make_umid(int (*printer)(const char *fmt, ...));
 
-static int __init set_umid(char *name, int is_random)
+static int __init set_umid(char *name, int is_random, 
+                          int (*printer)(const char *fmt, ...))
 {
        if(umid_inited){
-               printk("Unique machine name can't be set twice\n");
+               (*printer)("Unique machine name can't be set twice\n");
                return(-1);
        }
 
        if(strlen(name) > UMID_LEN - 1)
-               printk("Unique machine name is being truncated to %s "
-                      "characters\n", UMID_LEN);
+               (*printer)("Unique machine name is being truncated to %d "
+                          "characters\n", UMID_LEN);
        strlcpy(umid, name, sizeof(umid));
 
        umid_is_random = is_random;
@@ -54,7 +54,8 @@ static int __init set_umid(char *name, int is_random)
 
 static int __init set_umid_arg(char *name, int *add)
 {
-       return(set_umid(name, 0));
+       *add = 0;
+       return(set_umid(name, 0, printf));
 }
 
 __uml_setup("umid=", set_umid_arg,
@@ -67,7 +68,7 @@ int __init umid_file_name(char *name, char *buf, int len)
 {
        int n;
 
-       if(!umid_inited && make_umid()) return(-1);
+       if(!umid_inited && make_umid(printk)) return(-1);
 
        n = strlen(uml_dir) + strlen(umid) + strlen(name) + 1;
        if(n > len){
@@ -85,22 +86,23 @@ static int __init create_pid_file(void)
 {
        char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")];
        char pid[sizeof("nnnnn\0")];
-       int fd;
+       int fd, n;
 
        if(umid_file_name("pid", file, sizeof(file))) return 0;
 
        fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), 
                          0644);
        if(fd < 0){
-               printk("Open of machine pid file \"%s\" failed - "
-                      "errno = %d\n", file, -fd);
+               printf("Open of machine pid file \"%s\" failed - "
+                      "err = %d\n", file, -fd);
                return 0;
        }
 
        sprintf(pid, "%d\n", os_getpid());
-       if(write(fd, pid, strlen(pid)) != strlen(pid))
-               printk("Write of pid file failed - errno = %d\n", errno);
-       close(fd);
+       n = os_write_file(fd, pid, strlen(pid));
+       if(n != strlen(pid))
+               printf("Write of pid file failed - err = %d\n", -n);
+       os_close_file(fd);
        return 0;
 }
 
@@ -111,7 +113,8 @@ static int actually_do_remove(char *dir)
        int len;
        char file[256];
 
-       if((directory = opendir(dir)) == NULL){
+       directory = opendir(dir);
+       if(directory == NULL){
                printk("actually_do_remove : couldn't open directory '%s', "
                       "errno = %d\n", dir, errno);
                return(1);
@@ -160,22 +163,24 @@ int not_dead_yet(char *dir)
 {
        char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")];
        char pid[sizeof("nnnnn\0")], *end;
-       int dead, fd, p;
+       int dead, fd, p, n;
 
        sprintf(file, "%s/pid", dir);
        dead = 0;
-       if((fd = os_open_file(file, of_read(OPENFLAGS()), 0)) < 0){
+       fd = os_open_file(file, of_read(OPENFLAGS()), 0);
+       if(fd < 0){
                if(fd != -ENOENT){
                        printk("not_dead_yet : couldn't open pid file '%s', "
-                              "errno = %d\n", file, -fd);
+                              "err = %d\n", file, -fd);
                        return(1);
                }
                dead = 1;
        }
        if(fd > 0){
-               if(read(fd, pid, sizeof(pid)) < 0){
+               n = os_read_file(fd, pid, sizeof(pid));
+               if(n < 0){
                        printk("not_dead_yet : couldn't read pid file '%s', "
-                              "errno = %d\n", file, errno);
+                              "err = %d\n", file, -n);
                        return(1);
                }
                p = strtoul(pid, &end, 0);
@@ -195,17 +200,20 @@ int not_dead_yet(char *dir)
 static int __init set_uml_dir(char *name, int *add)
 {
        if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){
-               uml_dir = malloc(strlen(name) + 1);
+               uml_dir = malloc(strlen(name) + 2);
                if(uml_dir == NULL){
-                       printk("Failed to malloc uml_dir - error = %d\n",
+                       printf("Failed to malloc uml_dir - error = %d\n",
                               errno);
                        uml_dir = name;
+                       /* Return 0 here because do_initcalls doesn't look at
+                        * the return value.
+                        */
                        return(0);
                }
                sprintf(uml_dir, "%s/", name);
        }
        else uml_dir = name;
-       return 0;
+       return(0);
 }
 
 static int __init make_uml_dir(void)
@@ -217,7 +225,7 @@ static int __init make_uml_dir(void)
                char *home = getenv("HOME");
 
                if(home == NULL){
-                       printk("make_uml_dir : no value in environment for "
+                       printf("make_uml_dir : no value in environment for "
                               "$HOME\n");
                        exit(1);
                }
@@ -232,57 +240,59 @@ static int __init make_uml_dir(void)
                dir[len + 1] = '\0';
        }
 
-       if((uml_dir = malloc(strlen(dir) + 1)) == NULL){
+       uml_dir = malloc(strlen(dir) + 1);
+       if(uml_dir == NULL){
                printf("make_uml_dir : malloc failed, errno = %d\n", errno);
                exit(1);
        }
        strcpy(uml_dir, dir);
        
        if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){
-               printk("Failed to mkdir %s - errno = %i\n", uml_dir, errno);
+               printf("Failed to mkdir %s - errno = %i\n", uml_dir, errno);
                return(-1);
        }
        return 0;
 }
 
-static int __init make_umid(void)
+static int __init make_umid(int (*printer)(const char *fmt, ...))
 {
        int fd, err;
        char tmp[strlen(uml_dir) + UMID_LEN + 1];
 
        strlcpy(tmp, uml_dir, sizeof(tmp));
 
-       if(*umid == 0){
+       if(!umid_inited){
                strcat(tmp, "XXXXXX");
                fd = mkstemp(tmp);
                if(fd < 0){
-                       printk("make_umid - mkstemp failed, errno = %d\n",
-                              errno);
+                       (*printer)("make_umid - mkstemp failed, errno = %d\n",
+                                  errno);
                        return(1);
                }
 
-               close(fd);
+               os_close_file(fd);
                /* There's a nice tiny little race between this unlink and
                 * the mkdir below.  It'd be nice if there were a mkstemp
                 * for directories.
                 */
                unlink(tmp);
-               set_umid(&tmp[strlen(uml_dir)], 1);
+               set_umid(&tmp[strlen(uml_dir)], 1, printer);
        }
        
        sprintf(tmp, "%s%s", uml_dir, umid);
 
-       if((err = mkdir(tmp, 0777)) < 0){
+       err = mkdir(tmp, 0777);
+       if(err < 0){
                if(errno == EEXIST){
                        if(not_dead_yet(tmp)){
-                               printk("umid '%s' is in use\n", umid);
+                               (*printer)("umid '%s' is in use\n", umid);
                                return(-1);
                        }
                        err = mkdir(tmp, 0777);
                }
        }
        if(err < 0){
-               printk("Failed to create %s - errno = %d\n", umid, errno);
+               (*printer)("Failed to create %s - errno = %d\n", umid, errno);
                return(-1);
        }
 
@@ -295,7 +305,13 @@ __uml_setup("uml_dir=", set_uml_dir,
 );
 
 __uml_postsetup(make_uml_dir);
-__uml_postsetup(make_umid);
+
+static int __init make_umid_setup(void)
+{
+       return(make_umid(printf));
+}
+
+__uml_postsetup(make_umid_setup);
 __uml_postsetup(create_pid_file);
 
 /*
diff --git a/arch/um/kernel/user_syms.c b/arch/um/kernel/user_syms.c
deleted file mode 100644 (file)
index 2d32ea3..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/vfs.h>
-#include <sys/ioctl.h>
-#include "user_util.h"
-#include "mem_user.h"
-#include "uml-config.h"
-
-/* Had to steal this from linux/module.h because that file can't be included
- * since this includes various user-level headers.
- */
-
-struct module_symbol
-{
-       unsigned long value;
-       const char *name;
-};
-
-/* Indirect stringification.  */
-
-#define __MODULE_STRING_1(x)   #x
-#define __MODULE_STRING(x)     __MODULE_STRING_1(x)
-
-#if !defined(__AUTOCONF_INCLUDED__)
-
-#define __EXPORT_SYMBOL(sym,str)   error config_must_be_included_before_module
-#define EXPORT_SYMBOL(var)        error config_must_be_included_before_module
-#define EXPORT_SYMBOL_NOVERS(var)  error config_must_be_included_before_module
-
-#elif !defined(UML_CONFIG_MODULES)
-
-#define __EXPORT_SYMBOL(sym,str)
-#define EXPORT_SYMBOL(var)
-#define EXPORT_SYMBOL_NOVERS(var)
-
-#else
-
-#define __EXPORT_SYMBOL(sym, str)                      \
-const char __kstrtab_##sym[]                           \
-__attribute__((section(".kstrtab"))) = str;            \
-const struct module_symbol __ksymtab_##sym             \
-__attribute__((section("__ksymtab"))) =                        \
-{ (unsigned long)&sym, __kstrtab_##sym }
-
-#if defined(__MODVERSIONS__) || !defined(UML_CONFIG_MODVERSIONS)
-#define EXPORT_SYMBOL(var)  __EXPORT_SYMBOL(var, __MODULE_STRING(var))
-#else
-#define EXPORT_SYMBOL(var)  __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var)))
-#endif
-
-#define EXPORT_SYMBOL_NOVERS(var)  __EXPORT_SYMBOL(var, __MODULE_STRING(var))
-
-#endif
-
-EXPORT_SYMBOL(__errno_location);
-
-EXPORT_SYMBOL(access);
-EXPORT_SYMBOL(open);
-EXPORT_SYMBOL(open64);
-EXPORT_SYMBOL(close);
-EXPORT_SYMBOL(read);
-EXPORT_SYMBOL(write);
-EXPORT_SYMBOL(dup2);
-EXPORT_SYMBOL(__xstat);
-EXPORT_SYMBOL(__lxstat);
-EXPORT_SYMBOL(__lxstat64);
-EXPORT_SYMBOL(lseek);
-EXPORT_SYMBOL(lseek64);
-EXPORT_SYMBOL(chown);
-EXPORT_SYMBOL(truncate);
-EXPORT_SYMBOL(utime);
-EXPORT_SYMBOL(chmod);
-EXPORT_SYMBOL(rename);
-EXPORT_SYMBOL(__xmknod);
-
-EXPORT_SYMBOL(symlink);
-EXPORT_SYMBOL(link);
-EXPORT_SYMBOL(unlink);
-EXPORT_SYMBOL(readlink);
-
-EXPORT_SYMBOL(mkdir);
-EXPORT_SYMBOL(rmdir);
-EXPORT_SYMBOL(opendir);
-EXPORT_SYMBOL(readdir);
-EXPORT_SYMBOL(closedir);
-EXPORT_SYMBOL(seekdir);
-EXPORT_SYMBOL(telldir);
-
-EXPORT_SYMBOL(ioctl);
-
-extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
-                       __off64_t __offset);
-extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
-                        __off64_t __offset);
-EXPORT_SYMBOL(pread64);
-EXPORT_SYMBOL(pwrite64);
-
-EXPORT_SYMBOL(statfs);
-EXPORT_SYMBOL(statfs64);
-
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(getuid);
-
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(strstr);
-
-EXPORT_SYMBOL(find_iomem);
index 9e4fbae..1e7c1f1 100644 (file)
@@ -5,9 +5,9 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <fcntl.h>
 #include <unistd.h>
 #include <limits.h>
+#include <setjmp.h>
 #include <sys/mman.h> 
 #include <sys/stat.h>
 #include <sys/ptrace.h>
@@ -81,19 +81,19 @@ int wait_for_stop(int pid, int sig, int cont_type, void *relay)
        int status, ret;
 
        while(1){
-               if(((ret = waitpid(pid, &status, WUNTRACED)) < 0) ||
+               CATCH_EINTR(ret = waitpid(pid, &status, WUNTRACED));
+               if((ret < 0) ||
                   !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){
                        if(ret < 0){
-                               if(errno == EINTR) continue;
                                printk("wait failed, errno = %d\n",
                                       errno);
                        }
                        else if(WIFEXITED(status)) 
-                               printk("process exited with status %d\n", 
-                                      WEXITSTATUS(status));
+                               printk("process %d exited with status %d\n", 
+                                      pid, WEXITSTATUS(status));
                        else if(WIFSIGNALED(status))
-                               printk("process exited with signal %d\n", 
-                                      WTERMSIG(status));
+                               printk("process %d exited with signal %d\n", 
+                                      pid, WTERMSIG(status));
                        else if((WSTOPSIG(status) == SIGVTALRM) ||
                                (WSTOPSIG(status) == SIGALRM) ||
                                (WSTOPSIG(status) == SIGIO) ||
@@ -109,8 +109,8 @@ int wait_for_stop(int pid, int sig, int cont_type, void *relay)
                                ptrace(cont_type, pid, 0, WSTOPSIG(status));
                                continue;
                        }
-                       else printk("process stopped with signal %d\n", 
-                                   WSTOPSIG(status));
+                       else printk("process %d stopped with signal %d\n", 
+                                   pid, WSTOPSIG(status));
                        panic("wait_for_stop failed to wait for %d to stop "
                              "with %d\n", pid, sig);
                }
@@ -118,29 +118,27 @@ int wait_for_stop(int pid, int sig, int cont_type, void *relay)
        }
 }
 
-int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags)
-{
-       int pid;
-
-       pid = clone(fn, sp, flags, arg);
-       if(pid < 0) return(-1);
-       wait_for_stop(pid, SIGSTOP, PTRACE_CONT, NULL);
-       ptrace(PTRACE_CONT, pid, 0, 0);
-       return(pid);
-}
-
-int raw(int fd, int complain)
+int raw(int fd)
 {
        struct termios tt;
        int err;
 
-       tcgetattr(fd, &tt);
+       CATCH_EINTR(err = tcgetattr(fd, &tt));
+       if (err < 0) {
+               printk("tcgetattr failed, errno = %d\n", errno);
+               return(-errno);
+       }
+
        cfmakeraw(&tt);
-       err = tcsetattr(fd, TCSANOW, &tt);
-       if((err < 0) && complain){
+
+       CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt));
+       if (err < 0) {
                printk("tcsetattr failed, errno = %d\n", errno);
                return(-errno);
        }
+
+       /* XXX tcsetattr could have applied only some changes
+        * (and cfmakeraw() is a set of changes) */
        return(0);
 }
 
@@ -163,6 +161,21 @@ void setup_hostinfo(void)
                host.release, host.version, host.machine);
 }
 
+int setjmp_wrapper(void (*proc)(void *, void *), ...)
+{
+        va_list args;
+       sigjmp_buf buf;
+       int n;
+
+       n = sigsetjmp(buf, 1);
+       if(n == 0){
+               va_start(args, proc);
+               (*proc)(&buf, &args);
+       }
+       va_end(args);
+       return(n);
+}
+
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
index 3866884..9d06171 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
+#include <errno.h>
 #include <sys/resource.h>
 #include <sys/mman.h>
 #include <sys/user.h>
@@ -16,6 +17,8 @@
 #include "kern_util.h"
 #include "mem_user.h"
 #include "signal_user.h"
+#include "time_user.h"
+#include "irq_user.h"
 #include "user.h"
 #include "init.h"
 #include "mode.h"
@@ -123,12 +126,14 @@ int main(int argc, char **argv, char **envp)
 
        set_stklim();
 
-       if((new_argv = malloc((argc + 1) * sizeof(char *))) == NULL){
+       new_argv = malloc((argc + 1) * sizeof(char *));
+       if(new_argv == NULL){
                perror("Mallocing argv");
                exit(1);
        }
        for(i=0;i<argc;i++){
-               if((new_argv[i] = strdup(argv[i])) == NULL){
+               new_argv[i] = strdup(argv[i]);
+               if(new_argv[i] == NULL){
                        perror("Mallocing an arg");
                        exit(1);
                }
@@ -144,7 +149,20 @@ int main(int argc, char **argv, char **envp)
        
        /* Reboot */
        if(ret){
+               int err;
+
                printf("\n");
+
+               /* Let any pending signals fire, then disable them.  This 
+                * ensures that they won't be delivered after the exec, when 
+                * they are definitely not expected.
+                */
+               unblock_signals();
+               disable_timer();
+               err = deactivate_all_fds();
+               if(err)
+                       printf("deactivate_all_fds failed, errno = %d\n", -err);
+
                execvp(new_argv[0], new_argv);
                perror("Failed to exec kernel");
                ret = 1;
@@ -160,10 +178,21 @@ extern void *__real_malloc(int);
 
 void *__wrap_malloc(int size)
 {
-       if(CAN_KMALLOC())
-               return(um_kmalloc(size));
-       else
+       void *ret;
+
+       if(!CAN_KMALLOC())
                return(__real_malloc(size));
+       else if(size <= PAGE_SIZE) /* finding contiguos pages is hard */
+               ret = um_kmalloc(size);
+       else ret = um_vmalloc(size);
+
+       /* glibc people insist that if malloc fails, errno should be
+        * set by malloc as well. So we do.
+        */
+       if(ret == NULL)
+               errno = ENOMEM;
+
+       return(ret);
 }
 
 void *__wrap_calloc(int n, int size)
@@ -177,9 +206,35 @@ void *__wrap_calloc(int n, int size)
 
 extern void __real_free(void *);
 
+extern unsigned long high_physmem;
+
 void __wrap_free(void *ptr)
 {
-       if(CAN_KMALLOC()) kfree(ptr);
+       unsigned long addr = (unsigned long) ptr;
+
+       /* We need to know how the allocation happened, so it can be correctly
+        * freed.  This is done by seeing what region of memory the pointer is
+        * in -
+        *      physical memory - kmalloc/kfree
+        *      kernel virtual memory - vmalloc/vfree
+        *      anywhere else - malloc/free
+        * If kmalloc is not yet possible, then the kernel memory regions
+        * may not be set up yet, and the variables not set up.  So,
+        * free is called.
+        *
+        * CAN_KMALLOC is checked because it would be bad to free a buffer
+        * with kmalloc/vmalloc after they have been turned off during 
+        * shutdown.
+        */
+
+       if((addr >= uml_physmem) && (addr < high_physmem)){
+               if(CAN_KMALLOC())
+                       kfree(ptr);
+       }
+       else if((addr >= start_vm) && (addr < end_vm)){
+               if(CAN_KMALLOC())
+                       vfree(ptr);
+       }
        else __real_free(ptr);
 }
 
index 37eea4a..a6665dd 100644 (file)
@@ -3,13 +3,15 @@
 # Licensed under the GPL
 #
 
-obj-y = file.o process.o tty.o drivers/
+obj-y = aio.o file.o process.o time.o tty.o user_syms.o drivers/
 
-USER_OBJS := $(foreach file,file.o process.o tty.o,$(obj)/$(file))
+USER_OBJS := $(foreach file,aio.o file.o process.o time.o tty.o,$(obj)/$(file))
 
 $(USER_OBJS) : %.o: %.c
        $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
 
-clean :
-
-archmrproper:
+HAVE_AIO_ABI = $(shell [ -e /usr/include/linux/aio_abi.h ] && \
+       echo -DHAVE_AIO_ABI)
+HAVE_AIO_LIBC = $(shell objdump -T /lib/libc-*.so | grep io_submit && \
+       echo -DHAVE_AIO_LIBC)
+CFLAGS_aio.o = $(HAVE_AIO_ABI) $(HAVE_AIO_LIBC)
index 17f1561..6ae4b19 100644 (file)
@@ -8,7 +8,6 @@
 #include "linux/init.h"
 #include "linux/netdevice.h"
 #include "linux/etherdevice.h"
-#include "linux/init.h"
 #include "net_kern.h"
 #include "net_user.h"
 #include "etap.h"
index e275929..cd4d654 100644 (file)
@@ -8,7 +8,6 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <stddef.h>
-#include <fcntl.h>
 #include <stdlib.h>
 #include <sys/errno.h>
 #include <sys/socket.h>
@@ -17,6 +16,7 @@
 #include <net/if.h>
 #include "user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "net_user.h"
 #include "etap.h"
 #include "helper.h"
@@ -42,13 +42,14 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask,
 {
        struct addr_change change;
        void *output;
+       int n;
 
        change.what = op;
        memcpy(change.addr, addr, sizeof(change.addr));
        memcpy(change.netmask, netmask, sizeof(change.netmask));
-       if(write(fd, &change, sizeof(change)) != sizeof(change))
-               printk("etap_change - request failed, errno = %d\n",
-                      errno);
+       n = os_write_file(fd, &change, sizeof(change));
+       if(n != sizeof(change))
+               printk("etap_change - request failed, err = %d\n", -n);
        output = um_kmalloc(page_size());
        if(output == NULL)
                printk("etap_change : Failed to allocate output buffer\n");
@@ -82,15 +83,15 @@ static void etap_pre_exec(void *arg)
        struct etap_pre_exec_data *data = arg;
 
        dup2(data->control_remote, 1);
-       close(data->data_me);
-       close(data->control_me);
+       os_close_file(data->data_me);
+       os_close_file(data->control_me);
 }
 
 static int etap_tramp(char *dev, char *gate, int control_me, 
                      int control_remote, int data_me, int data_remote)
 {
        struct etap_pre_exec_data pe_data;
-       int pid, status, err;
+       int pid, status, err, n;
        char version_buf[sizeof("nnnnn\0")];
        char data_fd_buf[sizeof("nnnnnn\0")];
        char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
@@ -114,21 +115,22 @@ static int etap_tramp(char *dev, char *gate, int control_me,
        pe_data.data_me = data_me;
        pid = run_helper(etap_pre_exec, &pe_data, args, NULL);
 
-       if(pid < 0) err = errno;
-       close(data_remote);
-       close(control_remote);
-       if(read(control_me, &c, sizeof(c)) != sizeof(c)){
-               printk("etap_tramp : read of status failed, errno = %d\n",
-                      errno);
-               return(EINVAL);
+       if(pid < 0) err = pid;
+       os_close_file(data_remote);
+       os_close_file(control_remote);
+       n = os_read_file(control_me, &c, sizeof(c));
+       if(n != sizeof(c)){
+               printk("etap_tramp : read of status failed, err = %d\n", -n);
+               return(-EINVAL);
        }
        if(c != 1){
                printk("etap_tramp : uml_net failed\n");
-               err = EINVAL;
-               if(waitpid(pid, &status, 0) < 0) err = errno;
-               else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1)){
+               err = -EINVAL;
+               CATCH_EINTR(n = waitpid(pid, &status, 0));
+               if(n < 0)
+                       err = -errno;
+               else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
                        printk("uml_net didn't exit with status 1\n");
-               }
        }
        return(err);
 }
@@ -143,14 +145,14 @@ static int etap_open(void *data)
        if(err) return(err);
 
        err = os_pipe(data_fds, 0, 0);
-       if(err){
-               printk("data os_pipe failed - errno = %d\n", -err);
+       if(err < 0){
+               printk("data os_pipe failed - err = %d\n", -err);
                return(err);
        }
 
        err = os_pipe(control_fds, 1, 0);
-       if(err){
-               printk("control os_pipe failed - errno = %d\n", -err);
+       if(err < 0){
+               printk("control os_pipe failed - err = %d\n", -err);
                return(err);
        }
        
@@ -167,9 +169,9 @@ static int etap_open(void *data)
                kfree(output);
        }
 
-       if(err != 0){
-               printk("etap_tramp failed - errno = %d\n", err);
-               return(-err);
+       if(err < 0){
+               printk("etap_tramp failed - err = %d\n", -err);
+               return(err);
        }
 
        pri->data_fd = data_fds[0];
@@ -183,11 +185,11 @@ static void etap_close(int fd, void *data)
        struct ethertap_data *pri = data;
 
        iter_addresses(pri->dev, etap_close_addr, &pri->control_fd);
-       close(fd);
+       os_close_file(fd);
        os_shutdown_socket(pri->data_fd, 1, 1);
-       close(pri->data_fd);
+       os_close_file(pri->data_fd);
        pri->data_fd = -1;
-       close(pri->control_fd);
+       os_close_file(pri->control_fd);
        pri->control_fd = -1;
 }
 
index c858f11..f40c627 100644 (file)
@@ -8,7 +8,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -19,6 +18,7 @@
 #include "net_user.h"
 #include "tuntap.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "user.h"
 #include "helper.h"
 #include "os.h"
@@ -61,7 +61,7 @@ static void tuntap_pre_exec(void *arg)
        struct tuntap_pre_exec_data *data = arg;
        
        dup2(data->stdout, 1);
-       close(data->close_me);
+       os_close_file(data->close_me);
 }
 
 static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
@@ -86,7 +86,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
 
        if(pid < 0) return(-pid);
 
-       close(remote);
+       os_close_file(remote);
 
        msg.msg_name = NULL;
        msg.msg_namelen = 0;
@@ -107,19 +107,19 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
        if(n < 0){
                printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", 
                       errno);
-               return(errno);
+               return(-errno);
        }
-       waitpid(pid, NULL, 0);
+       CATCH_EINTR(waitpid(pid, NULL, 0));
 
        cmsg = CMSG_FIRSTHDR(&msg);
        if(cmsg == NULL){
                printk("tuntap_open_tramp : didn't receive a message\n");
-               return(EINVAL);
+               return(-EINVAL);
        }
        if((cmsg->cmsg_level != SOL_SOCKET) || 
           (cmsg->cmsg_type != SCM_RIGHTS)){
                printk("tuntap_open_tramp : didn't receive a descriptor\n");
-               return(EINVAL);
+               return(-EINVAL);
        }
        *fd_out = ((int *) CMSG_DATA(cmsg))[0];
        return(0);
@@ -133,27 +133,29 @@ static int tuntap_open(void *data)
        int err, fds[2], len, used;
 
        err = tap_open_common(pri->dev, pri->gate_addr);
-       if(err) return(err);
+       if(err < 0) 
+               return(err);
 
        if(pri->fixed_config){
-               if((pri->fd = open("/dev/net/tun", O_RDWR)) < 0){
-                       printk("Failed to open /dev/net/tun, errno = %d\n",
-                              errno);
-                       return(-errno);
+               pri->fd = os_open_file("/dev/net/tun", of_rdwr(OPENFLAGS()), 0);
+               if(pri->fd < 0){
+                       printk("Failed to open /dev/net/tun, err = %d\n",
+                              -pri->fd);
+                       return(pri->fd);
                }
                memset(&ifr, 0, sizeof(ifr));
-               ifr.ifr_flags = IFF_TAP;
+               ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
                strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name));
                if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){
-                       printk("TUNSETIFF failed, errno = %d", errno);
-                       close(pri->fd);
+                       printk("TUNSETIFF failed, errno = %d\n", errno);
+                       os_close_file(pri->fd);
                        return(-errno);
                }
        }
        else {
                err = os_pipe(fds, 0, 0);
-               if(err){
-                       printk("tuntap_open : os_pipe failed - errno = %d\n",
+               if(err < 0){
+                       printk("tuntap_open : os_pipe failed - err = %d\n",
                               -err);
                        return(err);
                }
@@ -166,19 +168,19 @@ static int tuntap_open(void *data)
                                        fds[1], buffer, len, &used);
 
                output = buffer;
-               if(err == 0){
-                       pri->dev_name = uml_strdup(buffer);
-                       output += IFNAMSIZ;
-                       printk(output);
-                       free_output_buffer(buffer);
-               }
-               else {
-                       printk(output);
+               if(err < 0) {
+                       printk("%s", output);
                        free_output_buffer(buffer);
-                       printk("tuntap_open_tramp failed - errno = %d\n", err);
-                       return(-err);
+                       printk("tuntap_open_tramp failed - err = %d\n", -err);
+                       return(err);
                }
-               close(fds[0]);
+
+               pri->dev_name = uml_strdup(buffer);
+               output += IFNAMSIZ;
+               printk("%s", output);
+               free_output_buffer(buffer);
+
+               os_close_file(fds[0]);
                iter_addresses(pri->dev, open_addr, pri->dev_name);
        }
 
@@ -191,7 +193,7 @@ static void tuntap_close(int fd, void *data)
 
        if(!pri->fixed_config) 
                iter_addresses(pri->dev, close_addr, pri->dev_name);
-       close(fd);
+       os_close_file(fd);
        pri->fd = -1;
 }
 
index e622db0..bda79c1 100644 (file)
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <utime.h>
+#include <dirent.h>
+#include <linux/kdev_t.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/uio.h>
+#include <sys/utsname.h>
+#include <sys/vfs.h>
 #include "os.h"
 #include "user.h"
 #include "kern_util.h"
 
-int os_file_type(char *file)
+static void copy_stat(struct uml_stat *dst, struct stat64 *src)
+{
+       *dst = ((struct uml_stat) {
+               .ust_major   = MAJOR(src->st_dev),     /* device */
+               .ust_minor   = MINOR(src->st_dev),
+               .ust_ino     = src->st_ino,     /* inode */
+               .ust_mode    = src->st_mode,    /* protection */
+               .ust_nlink   = src->st_nlink,   /* number of hard links */
+               .ust_uid     = src->st_uid,     /* user ID of owner */
+               .ust_gid     = src->st_gid,     /* group ID of owner */
+               .ust_size    = src->st_size,    /* total size, in bytes */
+               .ust_blksize = src->st_blksize, /* blocksize for filesys I/O */
+               .ust_blocks  = src->st_blocks,  /* number of blocks allocated */
+               .ust_atime   = src->st_atime,   /* time of last access */
+               .ust_mtime   = src->st_mtime,   /* time of last modification */
+               .ust_ctime   = src->st_ctime,   /* time of last change */
+               .ust_rmajor  = MAJOR(src->st_rdev),
+               .ust_rminor  = MINOR(src->st_rdev),
+       });
+}
+
+int os_stat_fd(const int fd, struct uml_stat *ubuf)
+{
+       struct stat64 sbuf;
+       int err;
+
+       do {
+               err = fstat64(fd, &sbuf);
+       } while((err < 0) && (errno == EINTR)) ;
+
+       if(err < 0) 
+               return(-errno);
+
+       if(ubuf != NULL)
+               copy_stat(ubuf, &sbuf);
+       return(err);
+}
+
+int os_stat_file(const char *file_name, struct uml_stat *ubuf)
+{
+       struct stat64 sbuf;
+       int err;
+
+       do {
+               err = stat64(file_name, &sbuf);
+       } while((err < 0) && (errno == EINTR)) ;
+
+       if(err < 0) 
+               return(-errno);
+
+       if(ubuf != NULL)
+               copy_stat(ubuf, &sbuf);
+       return(err);
+}
+
+int os_lstat_file(const char *file_name, struct uml_stat *ubuf)
+{
+       struct stat64 sbuf;
+       int err;
+
+       do {
+               err = lstat64(file_name, &sbuf);
+       } while((err < 0) && (errno == EINTR)) ;
+
+       if(err < 0) 
+               return(-errno);
+
+       if(ubuf != NULL)
+               copy_stat(ubuf, &sbuf);
+       return(err);
+}
+
+int os_access(const char *file, int mode)
+{
+       int amode, err;
+
+       amode=(mode& OS_ACC_R_OK ? R_OK : 0) | (mode& OS_ACC_W_OK ? W_OK : 0) |
+             (mode& OS_ACC_X_OK ? X_OK : 0) | (mode& OS_ACC_F_OK ? F_OK : 0) ;
+
+       err = access(file, amode);
+       if(err < 0)
+               return(-errno);
+
+       return(0);
+}
+
+int os_set_file_time(const char *file, unsigned long access, unsigned long mod)
+{
+       struct utimbuf buf = ((struct utimbuf){ .actime = access, 
+                                               .modtime = mod });
+       int err;
+
+       err = utime(file, &buf);
+       if(err < 0)
+               return(-errno);
+
+       return(0);
+}
+
+int os_set_file_perms(const char *file, int mode)
+{
+       int err;
+
+       err = chmod(file, mode);
+       if(err < 0)
+               return(-errno);
+
+       return(0);
+}
+
+int os_set_file_owner(const char *file, int owner, int group)
+{
+       int err;
+
+       err = chown(file, owner, group);
+       if(err < 0)
+               return(-errno);
+
+       return(0);
+}
+
+void os_print_error(int error, const char* str)
+{
+       errno = error < 0 ? -error : error;
+
+       perror(str);
+}
+
+/* FIXME? required only by hostaudio (because it passes ioctls verbatim) */
+int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
+{
+       int err;
+
+       err = ioctl(fd, cmd, arg);
+       if(err < 0)
+               return(-errno);
+
+       return(err);
+}
+
+int os_window_size(int fd, int *rows, int *cols)
+{
+       struct winsize size;
+
+       if(ioctl(fd, TIOCGWINSZ, &size) < 0)
+               return(-errno);
+
+       *rows = size.ws_row;
+       *cols = size.ws_col;
+
+       return(0);
+}
+
+int os_new_tty_pgrp(int fd, int pid)
+{
+       if(ioctl(fd, TIOCSCTTY, 0) < 0){
+               printk("TIOCSCTTY failed, errno = %d\n", errno);
+               return(-errno);
+       }
+
+       if(tcsetpgrp(fd, pid) < 0){
+               printk("tcsetpgrp failed, errno = %d\n", errno);
+               return(-errno);
+       }
+
+       return(0);
+}
+
+/* FIXME: ensure namebuf in os_get_if_name is big enough */
+int os_get_ifname(int fd, char* namebuf)
+{
+       if(ioctl(fd, SIOCGIFNAME, namebuf) < 0)
+               return(-errno);
+
+       return(0);
+}
+
+int os_set_slip(int fd)
+{
+       int disc, sencap;
+
+       disc = N_SLIP;
+       if(ioctl(fd, TIOCSETD, &disc) < 0){
+               printk("Failed to set slip line discipline - "
+                      "errno = %d\n", errno);
+               return(-errno);
+       }
+
+       sencap = 0;
+       if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0){
+               printk("Failed to set slip encapsulation - "
+                      "errno = %d\n", errno);
+               return(-errno);
+       }
+
+       return(0);
+}
+
+int os_set_owner(int fd, int pid)
+{
+       if(fcntl(fd, F_SETOWN, pid) < 0){
+               int save_errno = errno;
+
+               if(fcntl(fd, F_GETOWN, 0) != pid)
+                       return(-save_errno);
+       }
+
+       return(0);
+}
+
+/* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */ 
+int os_sigio_async(int master, int slave)
 {
-       struct stat64 buf;
+       int flags;
+
+       flags = fcntl(master, F_GETFL);
+       if(flags < 0) {
+               printk("fcntl F_GETFL failed, errno = %d\n", errno);
+               return(-errno);
+       }
+
+       if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
+          (fcntl(master, F_SETOWN, os_getpid()) < 0)){
+               printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n", 
+                      errno);
+               return(-errno);
+       }
+
+       if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)){
+               printk("fcntl F_SETFL failed, errno = %d\n", errno);
+               return(-errno);
+       }
+
+       return(0);
+}
+
+int os_mode_fd(int fd, int mode)
+{
+       int err;
+
+       do {
+               err = fchmod(fd, mode);
+       } while((err < 0) && (errno==EINTR)) ;
 
-       if(stat64(file, &buf) == -1)
+       if(err < 0)
                return(-errno);
 
-       if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR);
-       else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK);
-       else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV);
-       else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV);
-       else if(S_ISFIFO(buf.st_mode)) return(OS_TYPE_FIFO);
-       else if(S_ISSOCK(buf.st_mode)) return(OS_TYPE_SOCK);
+       return(0);
+}
+
+int os_file_type(char *file)
+{
+       struct uml_stat buf;
+       int err;
+
+       err = os_lstat_file(file, &buf);
+       if(err < 0)
+               return(err);
+
+       if(S_ISDIR(buf.ust_mode)) return(OS_TYPE_DIR);
+       else if(S_ISLNK(buf.ust_mode)) return(OS_TYPE_SYMLINK);
+       else if(S_ISCHR(buf.ust_mode)) return(OS_TYPE_CHARDEV);
+       else if(S_ISBLK(buf.ust_mode)) return(OS_TYPE_BLOCKDEV);
+       else if(S_ISFIFO(buf.ust_mode)) return(OS_TYPE_FIFO);
+       else if(S_ISSOCK(buf.ust_mode)) return(OS_TYPE_SOCK);
        else return(OS_TYPE_FILE);
 }
 
 int os_file_mode(char *file, struct openflags *mode_out)
 {
+       int err;
+
        *mode_out = OPENFLAGS();
 
-       if(!access(file, W_OK)) *mode_out = of_write(*mode_out);
-       else if(errno != EACCES) 
-               return(-errno);
+       err = os_access(file, OS_ACC_W_OK);
+       if((err < 0) && (err != -EACCES))
+               return(err);
 
-       if(!access(file, R_OK)) *mode_out = of_read(*mode_out);
-       else if(errno != EACCES) 
-               return(-errno);
+       *mode_out = of_write(*mode_out);
+
+       err = os_access(file, OS_ACC_R_OK);
+       if((err < 0) && (err != -EACCES))
+               return(err);
+
+       *mode_out = of_read(*mode_out);
 
        return(0);
 }
@@ -61,21 +326,110 @@ int os_open_file(char *file, struct openflags flags, int mode)
        if(flags.c) f |= O_CREAT;
        if(flags.t) f |= O_TRUNC;
        if(flags.e) f |= O_EXCL;
+       if(flags.d) f |= O_DIRECT;
 
        fd = open64(file, f, mode);
-       if(fd < 0) return(-errno);
-       
-       if(flags.cl){
-               if(fcntl(fd, F_SETFD, 1)){
-                       close(fd);
-                       return(-errno);
-               }
+       if(fd < 0)
+               return(-errno);
+
+       if(flags.cl && fcntl(fd, F_SETFD, 1)){
+               os_close_file(fd);
+               return(-errno);
        }
 
-       return(fd);
        return(fd);
 }
 
+void *os_open_dir(char *path, int *err_out)
+{
+       void *dir;
+
+       dir = opendir(path);
+       *err_out = -errno;
+       return(dir);
+}
+
+int os_seek_dir(void *stream, unsigned long long pos)
+{
+       seekdir(stream, pos);
+       return(0);
+}
+
+int os_read_dir(void *stream, unsigned long long *ino_out, char **name_out)
+{
+       struct dirent *ent;
+
+       errno = 0;
+       ent = readdir(stream);
+       if(ent == NULL){
+               if(errno != 0)
+                       return(-errno);
+               *name_out = NULL;
+               return(0);
+       }
+
+       *ino_out = ent->d_ino;
+       *name_out = ent->d_name;
+       return(0);
+}
+
+int os_tell_dir(void *stream)
+{
+       return(telldir(stream));
+}
+
+int os_close_dir(void *stream)
+{
+       int err;
+
+       err = closedir(stream);
+       if(err < 0)
+               return(-errno);
+       return(0);
+}
+
+int os_remove_file(const char *file)
+{
+       int err;
+
+       err = unlink(file);
+       if(err)
+               return(-errno);
+
+       return(0);
+}
+
+int os_move_file(const char *from, const char *to)
+{
+       int err;
+
+       err = rename(from, to);
+       if(err)
+               return(-errno);
+
+       return(0);
+}
+
+int os_truncate_fd(int fd, unsigned long long len)
+{
+       int err;
+
+       err = ftruncate(fd, len);
+       if(err)
+               return(-errno);
+       return(0);
+}
+
+int os_truncate_file(const char *file, unsigned long long len)
+{
+       int err;
+
+       err = truncate(file, len);
+       if(err)
+               return(-errno);
+       return(0);
+}
+
 int os_connect_socket(char *name)
 {
        struct sockaddr_un sock;
@@ -90,7 +444,7 @@ int os_connect_socket(char *name)
 
        err = connect(fd, (struct sockaddr *) &sock, sizeof(sock));
        if(err)
-               return(err);
+               return(-errno);
 
        return(fd);
 }
@@ -105,92 +459,180 @@ int os_seek_file(int fd, __u64 offset)
        __u64 actual;
 
        actual = lseek64(fd, offset, SEEK_SET);
-       if(actual != offset) return(-errno);
+       if(actual != offset) 
+               return(-errno);
        return(0);
 }
 
-int os_read_file(int fd, void *buf, int len)
+static int fault_buffer(void *start, int len, 
+                       int (*copy_proc)(void *addr, void *buf, int len))
 {
-       int n;
+       int page = getpagesize(), i;
+       char c;
 
-       /* Force buf into memory if it's not already. */
+       for(i = 0; i < len; i += page){
+               if((*copy_proc)(start + i, &c, sizeof(c)))
+                       return(-EFAULT);
+       }
+       if((len % page) != 0){
+               if((*copy_proc)(start + len - 1, &c, sizeof(c)))
+                       return(-EFAULT);
+       }
+       return(0);
+}
 
-       /* XXX This fails if buf is kernel memory */
-#ifdef notdef
-       if(copy_to_user_proc(buf, &c, sizeof(c)))
-               return(-EFAULT);
-#endif
+static int file_io(int fd, void *buf, int len,
+                  int (*io_proc)(int fd, void *buf, int len),
+                  int (*copy_user_proc)(void *addr, void *buf, int len))
+{
+       int n, err;
+
+       do {
+               n = (*io_proc)(fd, buf, len);
+               if((n < 0) && (errno == EFAULT)){
+                       err = fault_buffer(buf, len, copy_user_proc);
+                       if(err)
+                               return(err);
+                       n = (*io_proc)(fd, buf, len);
+               }
+       } while((n < 0) && (errno == EINTR));
 
-       n = read(fd, buf, len);
        if(n < 0)
                return(-errno);
        return(n);
 }
 
-int os_write_file(int fd, void *buf, int count)
+int os_read_file(int fd, void *buf, int len)
 {
-       int n;
-
-       /* Force buf into memory if it's not already. */
-       
-       /* XXX This fails if buf is kernel memory */
-#ifdef notdef
-       if(copy_to_user_proc(buf, buf, buf[0]))
-               return(-EFAULT);
-#endif
+       return(file_io(fd, buf, len, (int (*)(int, void *, int)) read, 
+                      copy_from_user_proc));
+}
 
-       n = write(fd, buf, count);
-       if(n < 0)
-               return(-errno);
-       return(n);
+int os_write_file(int fd, const void *buf, int len)
+{
+       return(file_io(fd, (void *) buf, len, 
+                      (int (*)(int, void *, int)) write, copy_to_user_proc));
 }
 
 int os_file_size(char *file, long long *size_out)
 {
-       struct stat64 buf;
+       struct uml_stat buf;
+       int err;
 
-       if(stat64(file, &buf) == -1){
-               printk("Couldn't stat \"%s\" : errno = %d\n", file, errno);
-               return(-errno);
+       err = os_stat_file(file, &buf);
+       if(err < 0){
+               printk("Couldn't stat \"%s\" : err = %d\n", file, -err);
+               return(err);
        }
-       if(S_ISBLK(buf.st_mode)){
+
+       if(S_ISBLK(buf.ust_mode)){
                int fd, blocks;
 
-               if((fd = open64(file, O_RDONLY)) < 0){
-                       printk("Couldn't open \"%s\", errno = %d\n", file,
-                              errno);
-                       return(-errno);
+               fd = os_open_file(file, of_read(OPENFLAGS()), 0);
+               if(fd < 0){
+                       printk("Couldn't open \"%s\", errno = %d\n", file, -fd);
+                       return(fd);
                }
                if(ioctl(fd, BLKGETSIZE, &blocks) < 0){
                        printk("Couldn't get the block size of \"%s\", "
                               "errno = %d\n", file, errno);
-                       close(fd);
-                       return(-errno);
+                       err = -errno;
+                       os_close_file(fd);
+                       return(err);
                }
                *size_out = ((long long) blocks) * 512;
-               close(fd);
+               os_close_file(fd);
                return(0);
        }
+       *size_out = buf.ust_size;
+       return(0);
+}
+
+int os_fd_size(int fd, long long *size_out)
+{
+       struct stat buf;
+       int err;
+
+       err = fstat(fd, &buf);
+       if(err)
+               return(-errno);
+
        *size_out = buf.st_size;
        return(0);
 }
 
+int os_file_modtime(char *file, unsigned long *modtime)
+{
+       struct uml_stat buf;
+       int err;
+
+       err = os_stat_file(file, &buf);
+       if(err < 0){
+               printk("Couldn't stat \"%s\" : err = %d\n", file, -err);
+               return(err);
+       }
+
+       *modtime = buf.ust_mtime;
+       return(0);
+}
+
+int os_get_exec_close(int fd, int* close_on_exec)
+{
+       int ret;
+
+       do {
+               ret = fcntl(fd, F_GETFD);
+       } while((ret < 0) && (errno == EINTR)) ;
+
+       if(ret < 0)
+               return(-errno);
+
+       *close_on_exec = (ret&FD_CLOEXEC) ? 1 : 0;
+       return(ret);
+}
+
+int os_set_exec_close(int fd, int close_on_exec)
+{
+       int flag, err;
+
+       if(close_on_exec) flag = FD_CLOEXEC;
+       else flag = 0;
+
+       do {
+               err = fcntl(fd, F_SETFD, flag);
+       } while((err < 0) && (errno == EINTR)) ;
+
+       if(err < 0)
+               return(-errno);
+       return(err);
+}
+
 int os_pipe(int *fds, int stream, int close_on_exec)
 {
        int err, type = stream ? SOCK_STREAM : SOCK_DGRAM;
 
        err = socketpair(AF_UNIX, type, 0, fds);
-       if(err) 
+       if(err < 0
                return(-errno);
 
        if(!close_on_exec)
                return(0);
 
-       if((fcntl(fds[0], F_SETFD, 1) < 0) || (fcntl(fds[1], F_SETFD, 1) < 0))
-               printk("os_pipe : Setting FD_CLOEXEC failed, errno = %d", 
-                      errno);
+       err = os_set_exec_close(fds[0], 1);
+       if(err < 0)
+               goto error;
+
+       err = os_set_exec_close(fds[1], 1);
+       if(err < 0)
+               goto error;
 
        return(0);
+
+ error:
+       printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err);
+       os_close_file(fds[1]);
+       os_close_file(fds[0]);
+       return(err);
 }
 
 int os_set_fd_async(int fd, int owner)
@@ -219,6 +661,16 @@ int os_set_fd_async(int fd, int owner)
        return(0);
 }
 
+int os_clear_fd_async(int fd)
+{
+       int flags = fcntl(fd, F_GETFL);
+
+       flags &= ~(O_ASYNC | O_NONBLOCK);
+       if(fcntl(fd, F_SETFL, flags) < 0)
+               return(-errno);
+       return(0);
+}
+
 int os_set_fd_block(int fd, int blocking)
 {
        int flags;
@@ -270,7 +722,7 @@ int os_shutdown_socket(int fd, int r, int w)
                return(-EINVAL);
        }
        err = shutdown(fd, what);
-       if(err)
+       if(err < 0)
                return(-errno);
        return(0);
 }
@@ -315,7 +767,7 @@ int os_rcv_fd(int fd, int *helper_pid_out)
        return(new);
 }
 
-int create_unix_socket(char *file, int len)
+int os_create_unix_socket(char *file, int len, int close_on_exec)
 {
        struct sockaddr_un addr;
        int sock, err;
@@ -327,6 +779,13 @@ int create_unix_socket(char *file, int len)
                return(-errno);
        }
 
+       if(close_on_exec) {
+               err = os_set_exec_close(sock, 1);
+               if(err < 0)
+                       printk("create_unix_socket : close_on_exec failed, "
+                      "err = %d", -err);
+       }
+
        addr.sun_family = AF_UNIX;
 
        /* XXX Be more careful about overflow */
@@ -334,14 +793,143 @@ int create_unix_socket(char *file, int len)
 
        err = bind(sock, (struct sockaddr *) &addr, sizeof(addr));
        if (err < 0){
-               printk("create_listening_socket - bind failed, errno = %d\n",
-                      errno);
+               printk("create_listening_socket at '%s' - bind failed, "
+                      "errno = %d\n", file, errno);
                return(-errno);
        }
 
        return(sock);
 }
 
+int os_make_symlink(const char *to, const char *from)
+{
+       int err;
+
+       err = symlink(to, from);
+       if(err)
+               return(-errno);
+
+       return(0);
+}
+
+int os_read_symlink(const char *file, char *buf, int size)
+{
+       int err;
+
+       err = readlink(file, buf, size);
+       if(err < 0)
+               return(-errno);
+
+       return(err);
+}
+
+int os_link_file(const char *to, const char *from)
+{
+       int err;
+
+       err = link(to, from);
+       if(err)
+               return(-errno);
+
+       return(0);
+}
+
+int os_make_dir(const char *dir, int mode)
+{
+       int err;
+
+       err = mkdir(dir, mode);
+       if(err)
+               return(-errno);
+
+       return(0);
+}
+
+int os_make_dev(const char *name, int mode, int major, int minor)
+{
+       int err;
+
+       err = mknod(name, mode, MKDEV(major, minor));
+       if(err)
+               return(-errno);
+
+       return(0);
+}
+
+int os_remove_dir(const char *dir)
+{
+       int err;
+
+       err = rmdir(dir);
+       if(err)
+               return(-errno);
+
+       return(0);
+}
+
+void os_flush_stdout(void)
+{
+       fflush(stdout);
+}
+
+int os_lock_file(int fd, int excl)
+{
+       int type = excl ? F_WRLCK : F_RDLCK;
+       struct flock lock = ((struct flock) { .l_type   = type,
+                                             .l_whence = SEEK_SET,
+                                             .l_start  = 0,
+                                             .l_len    = 0 } );
+       int err, save;
+
+       err = fcntl(fd, F_SETLK, &lock);
+       if(!err)
+               goto out;
+
+       save = -errno;
+       err = fcntl(fd, F_GETLK, &lock);
+       if(err){
+               err = -errno;
+               goto out;
+       }
+
+       printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid);
+       err = save;
+ out:
+       return(err);
+}
+
+int os_stat_filesystem(char *path, long *bsize_out, long long *blocks_out, 
+                      long long *bfree_out, long long *bavail_out, 
+                      long long *files_out, long long *ffree_out, 
+                      void *fsid_out, int fsid_size, long *namelen_out, 
+                      long *spare_out)
+{
+       struct statfs64 buf;
+       int err;
+
+       err = statfs64(path, &buf);
+       if(err < 0)
+               return(-errno);
+
+       *bsize_out = buf.f_bsize;
+       *blocks_out = buf.f_blocks;
+       *bfree_out = buf.f_bfree;
+       *bavail_out = buf.f_bavail;
+       *files_out = buf.f_files;
+       *ffree_out = buf.f_ffree;
+       memcpy(fsid_out, &buf.f_fsid, 
+              sizeof(buf.f_fsid) > fsid_size ? fsid_size : 
+              sizeof(buf.f_fsid));
+       *namelen_out = buf.f_namelen;
+       spare_out[0] = buf.f_spare[0];
+       spare_out[1] = buf.f_spare[1];
+       spare_out[2] = buf.f_spare[2];
+       spare_out[3] = buf.f_spare[3];
+       spare_out[4] = buf.f_spare[4];
+       spare_out[5] = buf.f_spare[5];
+       return(0);
+}
+
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
index a97778f..ce1b5f1 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -7,35 +7,44 @@
 #include <stdio.h>
 #include <errno.h>
 #include <signal.h>
+#include <linux/unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include "os.h"
 #include "user.h"
+#include "user_util.h"
+
+#define ARBITRARY_ADDR -1
+#define FAILURE_PID    -1
+
+#define STAT_PATH_LEN sizeof("/proc/#######/stat\0")
+#define COMM_SCANF "%*[^)])"
 
 unsigned long os_process_pc(int pid)
 {
-       char proc_stat[sizeof("/proc/#####/stat\0")], buf[256];
+       char proc_stat[STAT_PATH_LEN], buf[256];
        unsigned long pc;
-       int fd;
+       int fd, err;
 
        sprintf(proc_stat, "/proc/%d/stat", pid);
        fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0);
        if(fd < 0){
-               printk("os_process_pc - couldn't open '%s', errno = %d\n", 
-                      proc_stat, errno);
-               return(-1);
+               printk("os_process_pc - couldn't open '%s', err = %d\n", 
+                      proc_stat, -fd);
+               return(ARBITRARY_ADDR);
        }
-       if(read(fd, buf, sizeof(buf)) < 0){
-               printk("os_process_pc - couldn't read '%s', errno = %d\n", 
-                      proc_stat, errno);
-               close(fd);
-               return(-1);
+       err = os_read_file(fd, buf, sizeof(buf));
+       if(err < 0){
+               printk("os_process_pc - couldn't read '%s', err = %d\n", 
+                      proc_stat, -err);
+               os_close_file(fd);
+               return(ARBITRARY_ADDR);
        }
-       close(fd);
-       pc = -1;
-       if(sscanf(buf, "%*d %*s %*c %*d %*d %*d %*d %*d %*d %*d %*d "
+       os_close_file(fd);
+       pc = ARBITRARY_ADDR;
+       if(sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
                  "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
-                 "%*d %*d %*d %*d %ld", &pc) != 1){
+                 "%*d %*d %*d %*d %*d %lu", &pc) != 1){
                printk("os_process_pc - couldn't find pc in '%s'\n", buf);
        }
        return(pc);
@@ -43,7 +52,7 @@ unsigned long os_process_pc(int pid)
 
 int os_process_parent(int pid)
 {
-       char stat[sizeof("/proc/nnnnn/stat\0")];
+       char stat[STAT_PATH_LEN];
        char data[256];
        int parent, n, fd;
 
@@ -52,22 +61,22 @@ int os_process_parent(int pid)
        snprintf(stat, sizeof(stat), "/proc/%d/stat", pid);
        fd = os_open_file(stat, of_read(OPENFLAGS()), 0);
        if(fd < 0){
-               printk("Couldn't open '%s', errno = %d\n", stat, -fd);
-               return(-1);
+               printk("Couldn't open '%s', err = %d\n", stat, -fd);
+               return(FAILURE_PID);
        }
 
-       n = read(fd, data, sizeof(data));
-       close(fd);
+       n = os_read_file(fd, data, sizeof(data));
+       os_close_file(fd);
 
        if(n < 0){
-               printk("Couldn't read '%s', errno = %d\n", stat);
-               return(-1);
+               printk("Couldn't read '%s', err = %d\n", stat, -n);
+               return(FAILURE_PID);
        }
 
-       parent = -1;
-       /* XXX This will break if there is a space in the command */
-       n = sscanf(data, "%*d %*s %*c %d", &parent);
-       if(n != 1) printk("Failed to scan '%s'\n", data);
+       parent = FAILURE_PID;
+       n = sscanf(data, "%*d " COMM_SCANF " %*c %d", &parent);
+       if(n != 1) 
+               printk("Failed to scan '%s'\n", data);
 
        return(parent);
 }
@@ -81,7 +90,7 @@ void os_kill_process(int pid, int reap_child)
 {
        kill(pid, SIGKILL);
        if(reap_child)
-               waitpid(pid, NULL, 0);
+               CATCH_EINTR(waitpid(pid, NULL, 0));
                
 }
 
@@ -95,7 +104,7 @@ int os_getpid(void)
        return(getpid());
 }
 
-int os_map_memory(void *virt, int fd, unsigned long off, unsigned long len, 
+int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len,
                  int r, int w, int x)
 {
        void *loc;
@@ -104,8 +113,8 @@ int os_map_memory(void *virt, int fd, unsigned long off, unsigned long len,
        prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | 
                (x ? PROT_EXEC : 0);
 
-       loc = mmap((void *) virt, len, prot, MAP_SHARED | MAP_FIXED, 
-                  fd, off);
+       loc = mmap64((void *) virt, len, prot, MAP_SHARED | MAP_FIXED, 
+                    fd, off);
        if(loc == MAP_FAILED)
                return(-errno);
        return(0);
@@ -126,7 +135,8 @@ int os_unmap_memory(void *addr, int len)
         int err;
 
         err = munmap(addr, len);
-        if(err < 0) return(-errno);
+       if(err < 0)
+               return(-errno);
         return(0);
 }
 
index 2866ddb..4cfdd18 100644 (file)
@@ -28,10 +28,10 @@ int get_pty(void)
        struct grantpt_info info;
        int fd;
 
-       if((fd = os_open_file("/dev/ptmx", of_rdwr(OPENFLAGS()), 0)) < 0){
-               printk("get_pty : Couldn't open /dev/ptmx - errno = %d\n",
-                      errno);
-               return(-1);
+       fd = os_open_file("/dev/ptmx", of_rdwr(OPENFLAGS()), 0);
+       if(fd < 0){
+               printk("get_pty : Couldn't open /dev/ptmx - err = %d\n", -fd);
+               return(fd);
        }
 
        info.fd = fd;
@@ -39,7 +39,7 @@ int get_pty(void)
 
        if(info.res < 0){
                printk("get_pty : Couldn't grant pty - errno = %d\n", 
-                      info.err);
+                      -info.err);
                return(-1);
        }
        if(unlockpt(fd) < 0){
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
deleted file mode 100644 (file)
index ef0fb71..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "linux/types.h"
-#include "linux/module.h"
-
-/* Some of this are builtin function (some are not but could in the future),
- * so I *must* declare good prototypes for them and then EXPORT them.
- * The kernel code uses the macro defined by include/linux/string.h,
- * so I undef macros; the userspace code does not include that and I
- * add an EXPORT for the glibc one.*/
-
-#undef strlen
-#undef strstr
-#undef memcpy
-#undef memset
-
-extern size_t strlen(const char *);
-extern void *memcpy(void *, const void *, size_t);
-extern void *memset(void *, int, size_t);
-extern int printf(const char *, ...);
-
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(printf);
-
-EXPORT_SYMBOL(strstr);
-
-/* Here, instead, I can provide a fake prototype. Yes, someone cares: genksyms.
- * However, the modules will use the CRC defined *here*, no matter if it is 
- * good; so the versions of these symbols will always match
- */
-#define EXPORT_SYMBOL_PROTO(sym)       \
-       int sym(void);                  \
-       EXPORT_SYMBOL(sym);
-
-EXPORT_SYMBOL_PROTO(__errno_location);
-
-EXPORT_SYMBOL_PROTO(access);
-EXPORT_SYMBOL_PROTO(open);
-EXPORT_SYMBOL_PROTO(open64);
-EXPORT_SYMBOL_PROTO(close);
-EXPORT_SYMBOL_PROTO(read);
-EXPORT_SYMBOL_PROTO(write);
-EXPORT_SYMBOL_PROTO(dup2);
-EXPORT_SYMBOL_PROTO(__xstat);
-EXPORT_SYMBOL_PROTO(__lxstat);
-EXPORT_SYMBOL_PROTO(__lxstat64);
-EXPORT_SYMBOL_PROTO(lseek);
-EXPORT_SYMBOL_PROTO(lseek64);
-EXPORT_SYMBOL_PROTO(chown);
-EXPORT_SYMBOL_PROTO(truncate);
-EXPORT_SYMBOL_PROTO(utime);
-EXPORT_SYMBOL_PROTO(chmod);
-EXPORT_SYMBOL_PROTO(rename);
-EXPORT_SYMBOL_PROTO(__xmknod);
-
-EXPORT_SYMBOL_PROTO(symlink);
-EXPORT_SYMBOL_PROTO(link);
-EXPORT_SYMBOL_PROTO(unlink);
-EXPORT_SYMBOL_PROTO(readlink);
-
-EXPORT_SYMBOL_PROTO(mkdir);
-EXPORT_SYMBOL_PROTO(rmdir);
-EXPORT_SYMBOL_PROTO(opendir);
-EXPORT_SYMBOL_PROTO(readdir);
-EXPORT_SYMBOL_PROTO(closedir);
-EXPORT_SYMBOL_PROTO(seekdir);
-EXPORT_SYMBOL_PROTO(telldir);
-
-EXPORT_SYMBOL_PROTO(ioctl);
-
-EXPORT_SYMBOL_PROTO(pread64);
-EXPORT_SYMBOL_PROTO(pwrite64);
-
-EXPORT_SYMBOL_PROTO(statfs);
-EXPORT_SYMBOL_PROTO(statfs64);
-
-EXPORT_SYMBOL_PROTO(getuid);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 7525859..d489f4b 100644 (file)
@@ -1,14 +1,18 @@
-obj-y = bugs.o checksum.o extable.o fault.o ksyms.o ldt.o module.o \
-       ptrace.o ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o
+obj-y = bitops.o bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o \
+       ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o
 
 obj-$(CONFIG_HIGHMEM) += highmem.o
+obj-$(CONFIG_MODULES) += module.o
 
 USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
-SYMLINKS = semaphore.c highmem.c module.c
+SYMLINKS = bitops.c semaphore.c highmem.c module.c
 SYMLINKS := $(foreach f,$(SYMLINKS),$(src)/$f)
 
+clean-files := $(SYMLINKS)
+
+bitops.c-dir = lib
 semaphore.c-dir = kernel
 highmem.c-dir = mm
 module.c-dir = kernel
@@ -24,19 +28,4 @@ $(USER_OBJS) : %.o: %.c
 $(SYMLINKS): 
        $(call make_link,$@)
 
-clean:
-       $(MAKE) -C util clean
-
-fastdep:
-
-dep:
-
-archmrproper:
-       rm -f $(SYMLINKS)
-
-archclean:
-
-archdep:
-
-modules:
-
+subdir- := util
index 3905bab..d5e0ba9 100644 (file)
@@ -4,20 +4,21 @@
  */
 
 #include <unistd.h>
-#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/signal.h>
+#include <asm/ldt.h>
 #include "kern_util.h"
 #include "user.h"
 #include "sysdep/ptrace.h"
 #include "task.h"
+#include "os.h"
 
 #define MAXTOKEN 64
 
 /* Set during early boot */
-int cpu_has_cmov = 1;
-int cpu_has_xmm = 0;
+int host_has_cmov = 1;
+int host_has_xmm = 0;
 
 static char token(int fd, char *buf, int len, char stop)
 {
@@ -27,13 +28,15 @@ static char token(int fd, char *buf, int len, char stop)
        ptr = buf;
        end = &buf[len];
        do {
-               n = read(fd, ptr, sizeof(*ptr));
+               n = os_read_file(fd, ptr, sizeof(*ptr));
                c = *ptr++;
-               if(n == 0) return(0);
-               else if(n != sizeof(*ptr)){
-                       printk("Reading /proc/cpuinfo failed, "
-                              "errno = %d\n", errno);
-                       return(-errno);
+               if(n != sizeof(*ptr)){
+                       if(n == 0) return(0);
+                       printk("Reading /proc/cpuinfo failed, err = %d\n", -n);
+                       if(n < 0) 
+                               return(n);
+                       else 
+                               return(-EIO);
                }
        } while((c != '\n') && (c != stop) && (ptr < end));
 
@@ -45,45 +48,79 @@ static char token(int fd, char *buf, int len, char stop)
        return(c);
 }
 
-static int check_cpu_feature(char *feature, int *have_it)
+static int find_cpuinfo_line(int fd, char *key, char *scratch, int len)
 {
-       char buf[MAXTOKEN], c;
-       int fd, len = sizeof(buf)/sizeof(buf[0]), n;
-
-       printk("Checking for host processor %s support...", feature);
-       fd = open("/proc/cpuinfo", O_RDONLY);
-       if(fd < 0){
-               printk("Couldn't open /proc/cpuinfo, errno = %d\n", errno);
-               return(0);
-       }
+       int n;
+       char c;
 
-       *have_it = 0;
-       buf[len - 1] = '\0';
+       scratch[len - 1] = '\0';
        while(1){
-               c = token(fd, buf, len - 1, ':');
-               if(c <= 0) goto out;
+               c = token(fd, scratch, len - 1, ':');
+               if(c <= 0)
+                       return(0);
                else if(c != ':'){
                        printk("Failed to find ':' in /proc/cpuinfo\n");
-                       goto out;
+                       return(0);
                }
 
-               if(!strncmp(buf, "flags", strlen("flags"))) break;
+               if(!strncmp(scratch, key, strlen(key))) 
+                       return(1);
 
                do {
-                       n = read(fd, &c, sizeof(c));
+                       n = os_read_file(fd, &c, sizeof(c));
                        if(n != sizeof(c)){
                                printk("Failed to find newline in "
-                                      "/proc/cpuinfo, n = %d, errno = %d\n",
-                                      n, errno);
-                               goto out;
+                                      "/proc/cpuinfo, err = %d\n", -n);
+                               return(0);
                        }
                } while(c != '\n');
        }
+       return(0);
+}
+
+int cpu_feature(char *what, char *buf, int len)
+{
+       int fd, ret = 0;
+
+       fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0);
+       if(fd < 0){
+               printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd);
+               return(0);
+       }
+
+       if(!find_cpuinfo_line(fd, what, buf, len)){
+               printk("Couldn't find '%s' line in /proc/cpuinfo\n", what);
+               goto out_close;
+       }
+
+       token(fd, buf, len, '\n');
+       ret = 1;
+
+ out_close:
+       os_close_file(fd);
+       return(ret);
+}
+
+static int check_cpu_flag(char *feature, int *have_it)
+{
+       char buf[MAXTOKEN], c;
+       int fd, len = sizeof(buf)/sizeof(buf[0]);
+
+       printk("Checking for host processor %s support...", feature);
+       fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0);
+       if(fd < 0){
+               printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd);
+               return(0);
+       }
+
+       *have_it = 0;
+       if(!find_cpuinfo_line(fd, "flags", buf, sizeof(buf) / sizeof(buf[0])))
+               goto out;
 
        c = token(fd, buf, len - 1, ' ');
        if(c < 0) goto out;
        else if(c != ' '){
-               printk("Failed to find ':' in /proc/cpuinfo\n");
+               printk("Failed to find ' ' in /proc/cpuinfo\n");
                goto out;
        }
 
@@ -100,48 +137,76 @@ static int check_cpu_feature(char *feature, int *have_it)
  out:
        if(*have_it == 0) printk("No\n");
        else if(*have_it == 1) printk("Yes\n");
-       close(fd);
+       os_close_file(fd);
        return(1);
 }
 
+#if 0 /* This doesn't work in tt mode, plus it's causing compilation problems
+       * for some people.
+       */
+static void disable_lcall(void)
+{
+       struct modify_ldt_ldt_s ldt;
+       int err;
+
+       bzero(&ldt, sizeof(ldt));
+       ldt.entry_number = 7;
+       ldt.base_addr = 0;
+       ldt.limit = 0;
+       err = modify_ldt(1, &ldt, sizeof(ldt));
+       if(err)
+               printk("Failed to disable lcall7 - errno = %d\n", errno);
+}
+#endif
+
+void arch_init_thread(void)
+{
+#if 0
+       disable_lcall();
+#endif
+}
+
 void arch_check_bugs(void)
 {
        int have_it;
 
-       if(access("/proc/cpuinfo", R_OK)){
+       if(os_access("/proc/cpuinfo", OS_ACC_R_OK) < 0){
                printk("/proc/cpuinfo not available - skipping CPU capability "
                       "checks\n");
                return;
        }
-       if(check_cpu_feature("cmov", &have_it)) cpu_has_cmov = have_it;
-       if(check_cpu_feature("xmm", &have_it)) cpu_has_xmm = have_it;
+       if(check_cpu_flag("cmov", &have_it)) 
+               host_has_cmov = have_it;
+       if(check_cpu_flag("xmm", &have_it)) 
+               host_has_xmm = have_it;
 }
 
 int arch_handle_signal(int sig, union uml_pt_regs *regs)
 {
-       unsigned long ip;
+       unsigned char tmp[2];
 
        /* This is testing for a cmov (0x0f 0x4x) instruction causing a
         * SIGILL in init.
         */
        if((sig != SIGILL) || (TASK_PID(get_current()) != 1)) return(0);
 
-       ip = UPT_IP(regs);
-       if((*((char *) ip) != 0x0f) || ((*((char *) (ip + 1)) & 0xf0) != 0x40))
+       if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2))
+               panic("SIGILL in init, could not read instructions!\n");
+       if((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
                return(0);
 
-       if(cpu_has_cmov == 0)
+       if(host_has_cmov == 0)
                panic("SIGILL caused by cmov, which this processor doesn't "
                      "implement, boot a filesystem compiled for older "
                      "processors");
-       else if(cpu_has_cmov == 1)
+       else if(host_has_cmov == 1)
                panic("SIGILL caused by cmov, which this processor claims to "
                      "implement");
-       else if(cpu_has_cmov == -1)
+       else if(host_has_cmov == -1)
                panic("SIGILL caused by cmov, couldn't tell if this processor "
                      "implements it, boot a filesystem compiled for older "
                      "processors");
-       else panic("Bad value for cpu_has_cmov (%d)", cpu_has_cmov);
+       else panic("Bad value for host_has_cmov (%d)", host_has_cmov);
        return(0);
 }
 
diff --git a/arch/um/sys-i386/extable.c b/arch/um/sys-i386/extable.c
deleted file mode 100644 (file)
index 946e7ad..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * linux/arch/i386/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-              const struct exception_table_entry *last,
-              unsigned long value)
-{
-        while (first <= last) {
-               const struct exception_table_entry *mid;
-               long diff;
-
-               mid = (last - first) / 2 + first;
-               diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
index 6a0ec33..a8ddb38 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2004 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -7,16 +7,24 @@
 #include "sysdep/ptrace.h"
 #include "sysdep/sigcontext.h"
 
-extern unsigned long search_exception_table(unsigned long addr);
+/* These two are from asm-um/uaccess.h and linux/module.h, check them. */
+struct exception_table_entry
+{
+       unsigned long insn;
+       unsigned long fixup;
+};
 
+const struct exception_table_entry *search_exception_tables(unsigned long add);
+/* Compare this to arch/i386/mm/extable.c:fixup_exception() */
 int arch_fixup(unsigned long address, void *sc_ptr)
 {
        struct sigcontext *sc = sc_ptr;
-       unsigned long fixup;
+       const struct exception_table_entry *fixup;
 
        fixup = search_exception_tables(address);
        if(fixup != 0){
-               sc->eip = fixup;
+               sc->eip = fixup->fixup;
                return(1);
        }
        return(0);
index 33e3021..ba77cca 100644 (file)
@@ -13,6 +13,8 @@
 #ifdef CONFIG_MODE_TT
 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
 
+/* XXX this needs copy_to_user and copy_from_user */
+
 int sys_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
 {
        if(verify_area(VERIFY_READ, ptr, bytecount)) return(-EFAULT);
index 70da623..4c7d375 100644 (file)
@@ -39,10 +39,11 @@ static void write_debugregs(int pid, unsigned long *regs)
        nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]);
        for(i = 0; i < nregs; i++){
                if((i == 4) || (i == 5)) continue;
-               if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i],
+               if(ptrace(PTRACE_POKEUSER, pid, &dummy->u_debugreg[i],
                          regs[i]) < 0)
-                       printk("write_debugregs - ptrace failed, "
-                              "errno = %d\n", errno);
+                       printk("write_debugregs - ptrace failed on "
+                              "register %d, value = 0x%x, errno = %d\n", i, 
+                              regs[i], errno);
        }
 }
 
@@ -54,7 +55,7 @@ static void read_debugregs(int pid, unsigned long *regs)
        dummy = NULL;
        nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]);
        for(i = 0; i < nregs; i++){
-               regs[i] = ptrace(PTRACE_PEEKUSR, pid, 
+               regs[i] = ptrace(PTRACE_PEEKUSER, pid, 
                                 &dummy->u_debugreg[i], 0);
        }
 }
index a3eca5f..d10c36a 100644 (file)
@@ -1,15 +1,10 @@
+host-progs     := mk_sc mk_thread
+always         := $(host-progs)
 
-host-progs     := mk_sc
-always         := $(host-progs) mk_thread
-targets                := mk_thread_kern.o mk_thread_user.o
+mk_thread-objs := mk_thread_kern.o mk_thread_user.o
 
-mk_sc-objs     := mk_sc.o
-
-$(obj)/mk_thread : $(obj)/mk_thread_kern.o $(obj)/mk_thread_user.o
-       $(CC) $(CFLAGS) -o $@ $^
-
-$(obj)/mk_thread_user.o : $(src)/mk_thread_user.c
-       $(CC) $(USER_CFLAGS) -c -o $@ $<
+HOSTCFLAGS_mk_thread_kern.o    := $(CFLAGS) $(CPPFLAGS)
+HOSTCFLAGS_mk_thread_user.o    := $(USER_CFLAGS)
 
 clean :
        $(RM) -f $(build-targets)
index 224b6ad..85cbd30 100644 (file)
@@ -38,6 +38,7 @@ int main(int argc, char **argv)
   SC_OFFSET("SC_ERR", err);
   SC_OFFSET("SC_CR2", cr2);
   SC_OFFSET("SC_FPSTATE", fpstate);
+  SC_OFFSET("SC_SIGMASK", oldmask);
   SC_FP_OFFSET("SC_FP_CW", cw);
   SC_FP_OFFSET("SC_FP_SW", sw);
   SC_FP_OFFSET("SC_FP_TAG", tag);
index 4dd7353..d02f4c2 100644 (file)
@@ -7,18 +7,5 @@ all: $(OBJ)
 $(OBJ): $(OBJS)
        rm -f $@
        $(LD) $(LINKFLAGS) --start-group $^ --end-group -o $@
-clean:
-       rm -f $(OBJS)
 
-fastdep:
-
-archmrproper:
-
-archclean:
-       rm -f link.ld
-       @$(MAKEBOOT) clean
-
-archdep:
-       @$(MAKEBOOT) dep
-
-modules:
+clean-files := $(OBJS) link.ld
index 3767c25..af20026 100644 (file)
@@ -66,13 +66,4 @@ misc.o: misc.S ppc_defs.h
        $(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
        rm -f asm
 
-clean:
-       rm -f $(OBJS)
-       rm -f ppc_defs.h
-       rm -f checksum.S semaphore.c mk_defs.c
-
-fastdep:
-
-dep:
-
-modules:
+clean-files := $(OBJS) ppc_defs.h checksum.S semaphore.c mk_defs.c
index d182fb5..3c2fdec 100644 (file)
@@ -9,7 +9,6 @@ SECTIONS
 {
   . = START + SIZEOF_HEADERS;
 
-  . = ALIGN(4096);
   __binary_start = .;
 #ifdef MODE_TT
   .thread_private : {
@@ -26,11 +25,16 @@ SECTIONS
   . = ALIGN(4096);             /* Init code and data */
   _stext = .;
   __init_begin = .;
-  .text.init : { *(.text.init) }
+  .init.text : { 
+       _sinittext = .;
+       *(.init.text)
+       _einittext = .;
+  }
   . = ALIGN(4096);
   .text      :
   {
     *(.text)
+    SCHED_TEXT
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
     *(.gnu.linkonce.t*)
@@ -38,7 +42,7 @@ SECTIONS
 
   #include "asm/common.lds.S"
 
-  .data.init : { *(.data.init) }
+  init.data : { *(init.data) }
   .data    :
   {
     . = ALIGN(KERNEL_STACK_SIZE);              /* init_task */
index defd038..2fa9136 100644 (file)
@@ -1,23 +1,11 @@
-always         := mk_task mk_constants
-targets                := mk_task_user.o mk_task_kern.o \
-                  mk_constants_user.o mk_constants_kern.o
+host-progs             := mk_task mk_constants
+always                 := $(host-progs)
 
-$(obj)/mk_task: $(obj)/mk_task_user.o $(obj)/mk_task_kern.o
-       $(CC) -o $@ $^
+mk_task-objs           := mk_task_user.o mk_task_kern.o
+mk_constants-objs      := mk_constants_user.o mk_constants_kern.o
 
-$(obj)/mk_task_user.o: $(src)/mk_task_user.c
-       $(CC) -o $@ -c $< 
-
-$(obj)/mk_constants : $(obj)/mk_constants_user.o $(obj)/mk_constants_kern.o
-       $(CC) -o $@ $^
-
-$(obj)/mk_constants_user.o : $(src)/mk_constants_user.c
-       $(CC) -c $< -o $@
-
-$(obj)/mk_constants_kern.o : $(src)/mk_constants_kern.c
-       $(CC) $(CFLAGS) -c $< -o $@
+HOSTCFLAGS_mk_task_kern.o      := $(CFLAGS) $(CPPFLAGS)
+HOSTCFLAGS_mk_constants_kern.o := $(CFLAGS) $(CPPFLAGS)
 
 clean:
-       $(RM) $(build-targets)
-
-archmrproper:
+       $(RM) -f $(host-progs)
index 7e74934..cdcb123 100644 (file)
@@ -1,5 +1,6 @@
 #include "linux/kernel.h"
 #include "linux/stringify.h"
+#include "linux/time.h"
 #include "asm/page.h"
 
 extern void print_head(void);
@@ -11,6 +12,7 @@ int main(int argc, char **argv)
 {
   print_head();
   print_constant_int("UM_KERN_PAGE_SIZE", PAGE_SIZE);
+
   print_constant_str("UM_KERN_EMERG", KERN_EMERG);
   print_constant_str("UM_KERN_ALERT", KERN_ALERT);
   print_constant_str("UM_KERN_CRIT", KERN_CRIT);
@@ -19,6 +21,8 @@ int main(int argc, char **argv)
   print_constant_str("UM_KERN_NOTICE", KERN_NOTICE);
   print_constant_str("UM_KERN_INFO", KERN_INFO);
   print_constant_str("UM_KERN_DEBUG", KERN_DEBUG);
+
+  print_constant_int("UM_NSEC_PER_SEC", NSEC_PER_SEC);
   print_tail();
   return(0);
 }
index 8665652..994e4f8 100644 (file)
@@ -334,6 +334,8 @@ config NO_KERNEL_MSG
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index fc06058..7d25547 100644 (file)
@@ -138,6 +138,8 @@ int sys_ptrace(long request, long pid, long addr, long data)
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        rval = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 2122afc..1c07776 100644 (file)
@@ -499,6 +499,8 @@ config IOMMU_LEAK
 
 endmenu
 
+source "kernel/vserver/Kconfig"
+
 source "security/Kconfig"
 
 source "crypto/Kconfig"
index 040e56f..fe6bae2 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/binfmts.h>
 #include <linux/personality.h>
 #include <linux/init.h>
+#include <linux/vs_memory.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -309,7 +310,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                (current->mm->start_brk = N_BSSADDR(ex));
        current->mm->free_area_cache = TASK_UNMAPPED_BASE;
 
-       current->mm->rss = 0;
+       // current->mm->rss = 0;
+       vx_rsspages_sub(current->mm, current->mm->rss);
        current->mm->mmap = NULL;
        compute_creds(bprm);
        current->flags &= ~PF_FORKNOEXEC;
index 8e6b845..fc1a9b0 100644 (file)
@@ -327,7 +327,7 @@ static void elf32_init(struct pt_regs *regs)
 
 int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
 {
-       unsigned long stack_base;
+       unsigned long stack_base, grow;
        struct vm_area_struct *mpnt;
        struct mm_struct *mm = current->mm;
        int i;
@@ -344,7 +344,10 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
        if (!mpnt) 
                return -ENOMEM; 
        
-       if (security_vm_enough_memory((IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
+       grow = (IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
+               >> PAGE_SHIFT;
+       if (security_vm_enough_memory(grow) ||
+               !vx_vmpages_avail(mm, grow)) {
                kmem_cache_free(vm_area_cachep, mpnt);
                return -ENOMEM;
        }
@@ -365,7 +368,9 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
                mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC) ? 
                        PAGE_COPY_EXEC : PAGE_COPY;
                insert_vm_struct(mm, mpnt);
-               mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               // mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               vx_vmpages_sub(mm, mm->total_vm -
+                       ((mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT));
        } 
 
        for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
@@ -382,7 +387,7 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
 }
 
 static unsigned long
-elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type)
+elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type, unsigned long unused)
 {
        unsigned long map_addr;
        struct task_struct *me = current; 
index 0a2fb66..805e980 100644 (file)
@@ -578,7 +578,7 @@ ia32_sys_call_table:
        .quad sys_tgkill                /* 270 */
        .quad compat_sys_utimes
        .quad sys32_fadvise64_64
-       .quad quiet_ni_syscall  /* sys_vserver */
+       .quad sys_vserver
        .quad sys_mbind
        .quad compat_get_mempolicy      /* 275 */
        .quad sys_set_mempolicy
index ab80034..2f2e29d 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/ptrace.h>
 #include <linux/highuid.h>
 #include <linux/vmalloc.h>
+#include <linux/vs_cvirt.h>
 #include <asm/mman.h>
 #include <asm/types.h>
 #include <asm/uaccess.h>
@@ -1059,6 +1060,7 @@ asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
 asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
 {
        int error;
+       struct new_utsname *ptr;
 
        if (!name)
                return -EFAULT;
@@ -1067,13 +1069,14 @@ asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
   
        down_read(&uts_sem);
        
-       error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
+       ptr = vx_new_utsname();
+       error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
         __put_user(0,name->sysname+__OLD_UTS_LEN);
-        __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
+        __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
         __put_user(0,name->nodename+__OLD_UTS_LEN);
-        __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
+        __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
         __put_user(0,name->release+__OLD_UTS_LEN);
-        __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
+        __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
         __put_user(0,name->version+__OLD_UTS_LEN);
         { 
                 char *arch = "x86_64";
@@ -1096,7 +1099,7 @@ long sys32_uname(struct old_utsname __user * name)
        if (!name)
                return -EFAULT;
        down_read(&uts_sem);
-       err=copy_to_user(name, &system_utsname, sizeof (*name));
+       err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
        up_read(&uts_sem);
        if (personality(current->personality) == PER_LINUX32) 
                err |= copy_to_user(&name->machine, "i686", 5);
@@ -1348,4 +1351,3 @@ static int __init ia32_init (void)
 __initcall(ia32_init);
 
 extern unsigned long ia32_sys_call_table[];
-EXPORT_SYMBOL(ia32_sys_call_table);
index 5dd7752..d07a45b 100644 (file)
@@ -208,6 +208,8 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;
+       if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+               goto out_tsk;
 
        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
index 38a286c..3feb337 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/file.h>
 #include <linux/utsname.h>
 #include <linux/personality.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/ipc.h>
@@ -146,7 +147,7 @@ asmlinkage long sys_uname(struct new_utsname __user * name)
 {
        int err;
        down_read(&uts_sem);
-       err = copy_to_user(name, &system_utsname, sizeof (*name));
+       err = copy_to_user(name, vx_new_utsname(), sizeof (*name));
        up_read(&uts_sem);
        if (personality(current->personality) == PER_LINUX32) 
                err |= copy_to_user(&name->machine, "i686", 5);                 
index 99d0ec2..5aeee7c 100644 (file)
@@ -335,8 +335,11 @@ void oops_end(void)
        bust_spinlocks(0); 
        spin_unlock(&die_lock); 
        local_irq_enable();     /* make sure back scroll still works */
-       if (panic_on_oops)
+       if (panic_on_oops) {
+               if (netdump_func)
+                       netdump_func = NULL;
                panic("Oops"); 
+       }
 } 
 
 void __die(const char * str, struct pt_regs * regs, long err)
@@ -366,6 +369,8 @@ void die(const char * str, struct pt_regs * regs, long err)
        oops_begin();
        handle_BUG(regs);
        __die(str, regs, err);
+       if (netdump_func)
+               netdump_func(regs);
        oops_end();
        do_exit(SIGSEGV); 
 }
index 1fb1384..1bfb6ae 100644 (file)
@@ -182,11 +182,6 @@ EXPORT_SYMBOL_NOVERS(memcpy);
 EXPORT_SYMBOL_NOVERS(__memcpy);
 EXPORT_SYMBOL_NOVERS(memcmp);
 
-/* syscall export needed for misdesigned sound drivers. */
-EXPORT_SYMBOL(sys_read);
-EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(sys_open);
-
 EXPORT_SYMBOL(empty_zero_page);
 
 #ifdef CONFIG_HAVE_DEC_LOCK
index 14bbe9e..b8cf5d9 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the linux x86_64-specific parts of the memory manager.
 #
 
-obj-y   := init.o fault.o ioremap.o extable.o pageattr.o
+obj-y   := init.o fault.o ioremap.o extable.o pageattr.o mmap.o
 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
 obj-$(CONFIG_DISCONTIGMEM) += numa.o
 obj-$(CONFIG_K8_NUMA) += k8topology.o
index f393e33..a51772d 100644 (file)
@@ -396,6 +396,26 @@ static inline int page_is_ram (unsigned long pagenr)
        return 0;
 }
 
+/*
+ * devmem_is_allowed() checks to see if /dev/mem access to a certain address is
+ * valid. The argument is a physical page number.
+ *
+ *
+ * On x86-64, access has to be given to the first megabyte of ram because that area
+ * contains bios code and data regions used by X and dosemu and similar apps.
+ * Access has to be given to non-kernel-ram areas as well, these contain the PCI
+ * mmio resources as well as potential bios/acpi data regions.
+ */
+int devmem_is_allowed(unsigned long pagenr)
+{
+       if (pagenr <= 256)
+               return 1;
+       if (!page_is_ram(pagenr))
+               return 1;
+       return 0;
+}
+
+
 static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
                         kcore_vsyscall;
 
diff --git a/configs/kernel-2.6.8-i686-planetlab-desktop.config b/configs/kernel-2.6.8-i686-planetlab-desktop.config
new file mode 100644 (file)
index 0000000..9426fb0
--- /dev/null
@@ -0,0 +1,1750 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_X86=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_GENERIC_ISA_DMA=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+
+#
+# Class Based Kernel Resource Management
+#
+CONFIG_CKRM=y
+CONFIG_RCFS_FS=y
+CONFIG_CKRM_TYPE_TASKCLASS=y
+CONFIG_CKRM_RES_NUMTASKS=y
+CONFIG_CKRM_CPU_SCHEDULE=y
+CONFIG_CKRM_RES_BLKIO=y
+CONFIG_CKRM_RES_MEM=y
+# CONFIG_CKRM_MEM_LRUORDER_CHANGE is not set
+# CONFIG_CKRM_TYPE_SOCKETCLASS is not set
+CONFIG_CKRM_RBCE=y
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=17
+# CONFIG_HOTPLUG is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_OOM_PANIC=y
+# CONFIG_EMBEDDED is not set
+# CONFIG_DELAY_ACCT is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SIG is not set
+CONFIG_KMOD=y
+
+#
+# Processor type and features
+#
+CONFIG_X86_PC=y
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_NUMAQ is not set
+# CONFIG_X86_SUMMIT is not set
+# CONFIG_X86_BIGSMP is not set
+# CONFIG_X86_VISWS is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_ES7000 is not set
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+# CONFIG_M686 is not set
+# CONFIG_MPENTIUMII is not set
+CONFIG_MPENTIUMIII=y
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_XADD=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_GOOD_APIC=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_USE_PPRO_CHECKSUM=y
+CONFIG_X86_4G=y
+CONFIG_X86_SWITCH_PAGETABLES=y
+CONFIG_X86_4G_VM_LAYOUT=y
+CONFIG_X86_UACCESS_INDIRECT=y
+CONFIG_X86_HIGH_ENTRY=y
+CONFIG_HPET_TIMER=y
+CONFIG_HPET_EMULATE_RTC=y
+# CONFIG_SMP is not set
+# CONFIG_PREEMPT is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_X86_UP_APIC is not set
+CONFIG_X86_TSC=y
+CONFIG_X86_MCE=y
+# CONFIG_X86_MCE_NONFATAL is not set
+CONFIG_TOSHIBA=m
+CONFIG_I8K=m
+CONFIG_MICROCODE=m
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+# CONFIG_NOHIGHMEM is not set
+CONFIG_HIGHMEM4G=y
+# CONFIG_HIGHMEM64G is not set
+CONFIG_HIGHMEM=y
+CONFIG_HIGHPTE=y
+# CONFIG_MATH_EMULATION is not set
+CONFIG_MTRR=y
+# CONFIG_EFI is not set
+CONFIG_REGPARM=y
+
+#
+# Power management options (ACPI, APM)
+#
+CONFIG_PM=y
+# CONFIG_SOFTWARE_SUSPEND is not set
+# CONFIG_PM_DISK is not set
+
+#
+# ACPI (Advanced Configuration and Power Interface) Support
+#
+CONFIG_ACPI=y
+CONFIG_ACPI_BOOT=y
+CONFIG_ACPI_INTERPRETER=y
+CONFIG_ACPI_SLEEP=y
+CONFIG_ACPI_SLEEP_PROC_FS=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_FAN=y
+CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_ASUS=m
+CONFIG_ACPI_TOSHIBA=m
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_BUS=y
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_PCI=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_X86_PM_TIMER=y
+
+#
+# APM (Advanced Power Management) BIOS Support
+#
+CONFIG_APM=m
+# CONFIG_APM_IGNORE_USER_SUSPEND is not set
+# CONFIG_APM_DO_ENABLE is not set
+CONFIG_APM_CPU_IDLE=y
+# CONFIG_APM_DISPLAY_BLANK is not set
+CONFIG_APM_RTC_IS_GMT=y
+# CONFIG_APM_ALLOW_INTS is not set
+# CONFIG_APM_REAL_MODE_POWER_OFF is not set
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+# CONFIG_CPU_FREQ_PROC_INTF is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+# CONFIG_CPU_FREQ_24_API is not set
+CONFIG_CPU_FREQ_TABLE=y
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+CONFIG_X86_POWERNOW_K6=m
+CONFIG_X86_POWERNOW_K7=m
+CONFIG_X86_POWERNOW_K8=m
+# CONFIG_X86_GX_SUSPMOD is not set
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
+CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
+CONFIG_X86_SPEEDSTEP_ICH=m
+CONFIG_X86_SPEEDSTEP_SMI=m
+CONFIG_X86_P4_CLOCKMOD=m
+CONFIG_X86_SPEEDSTEP_LIB=m
+# CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK is not set
+CONFIG_X86_LONGRUN=m
+CONFIG_X86_LONGHAUL=m
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_PCI=y
+# CONFIG_PCI_GOBIOS is not set
+# CONFIG_PCI_GOMMCONFIG is not set
+# CONFIG_PCI_GODIRECT is not set
+CONFIG_PCI_GOANY=y
+CONFIG_PCI_BIOS=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_LEGACY_PROC=y
+# CONFIG_PCI_NAMES is not set
+CONFIG_ISA=y
+# CONFIG_EISA is not set
+# CONFIG_MCA is not set
+# CONFIG_SCx200 is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_MISC=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_REDBOOT_PARTS=m
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLOCK=m
+CONFIG_MTD_BLOCK_RO=m
+CONFIG_FTL=m
+CONFIG_NFTL=m
+CONFIG_NFTL_RW=y
+CONFIG_INFTL=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_AMDSTD_RETRY=3
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+CONFIG_MTD_RAM=m
+CONFIG_MTD_ROM=m
+CONFIG_MTD_ABSENT=m
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PNC2000 is not set
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_SBC_GXX=m
+CONFIG_MTD_ELAN_104NC=m
+CONFIG_MTD_SCx200_DOCFLASH=m
+# CONFIG_MTD_AMD76XROM is not set
+# CONFIG_MTD_ICHXROM is not set
+CONFIG_MTD_SCB2_FLASH=m
+# CONFIG_MTD_NETtel is not set
+# CONFIG_MTD_DILNETPC is not set
+# CONFIG_MTD_L440GX is not set
+CONFIG_MTD_PCI=m
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_PMC551=m
+# CONFIG_MTD_PMC551_BUGFIX is not set
+# CONFIG_MTD_PMC551_DEBUG is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+# CONFIG_MTD_BLKMTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+CONFIG_MTD_DOC2000=m
+# CONFIG_MTD_DOC2001 is not set
+CONFIG_MTD_DOC2001PLUS=m
+CONFIG_MTD_DOCPROBE=m
+CONFIG_MTD_DOCECC=m
+# CONFIG_MTD_DOCPROBE_ADVANCED is not set
+CONFIG_MTD_DOCPROBE_ADDRESS=0
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_IDS=m
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_ISAPNP=y
+# CONFIG_PNPBIOS is not set
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_FD=m
+# CONFIG_BLK_DEV_XD is not set
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+CONFIG_BLK_DEV_LOOP=m
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=16384
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_LBD=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECD=y
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_BLK_DEV_IDEFLOPPY=y
+CONFIG_BLK_DEV_IDESCSI=m
+# CONFIG_IDE_TASK_IOCTL is not set
+# CONFIG_IDE_TASKFILE_IO is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_BLK_DEV_CMD640 is not set
+CONFIG_BLK_DEV_IDEPNP=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_RZ1000=y
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+CONFIG_BLK_DEV_ADMA=y
+CONFIG_BLK_DEV_AEC62XX=y
+CONFIG_BLK_DEV_ALI15X3=y
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+CONFIG_BLK_DEV_ATIIXP=y
+CONFIG_BLK_DEV_CMD64X=y
+CONFIG_BLK_DEV_TRIFLEX=y
+CONFIG_BLK_DEV_CY82C693=y
+CONFIG_BLK_DEV_CS5520=y
+CONFIG_BLK_DEV_CS5530=y
+CONFIG_BLK_DEV_HPT34X=y
+# CONFIG_HPT34X_AUTODMA is not set
+CONFIG_BLK_DEV_HPT366=y
+# CONFIG_BLK_DEV_SC1200 is not set
+CONFIG_BLK_DEV_PIIX=y
+# CONFIG_BLK_DEV_NS87415 is not set
+CONFIG_BLK_DEV_PDC202XX_OLD=y
+# CONFIG_PDC202XX_BURST is not set
+CONFIG_BLK_DEV_PDC202XX_NEW=y
+CONFIG_PDC202XX_FORCE=y
+CONFIG_BLK_DEV_SVWKS=y
+CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_BLK_DEV_SIS5513=y
+CONFIG_BLK_DEV_SLC90E66=y
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=y
+# CONFIG_IDE_ARM is not set
+# CONFIG_IDE_CHIPSETS is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=m
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+
+#
+# SCSI Transport Attributes
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+
+#
+# SCSI low-level drivers
+#
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+# CONFIG_SCSI_7000FASST is not set
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AHA152X=m
+CONFIG_SCSI_AHA1542=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=4
+CONFIG_AIC7XXX_RESET_DELAY_MS=15000
+# CONFIG_AIC7XXX_BUILD_FIRMWARE is not set
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=4
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_BUILD_FIRMWARE is not set
+# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
+# CONFIG_SCSI_DPT_I2O is not set
+CONFIG_SCSI_IN2000=m
+CONFIG_SCSI_MEGARAID=m
+CONFIG_SCSI_SATA=y
+CONFIG_SCSI_SATA_SVW=m
+CONFIG_SCSI_ATA_PIIX=m
+CONFIG_SCSI_SATA_NV=m
+CONFIG_SCSI_SATA_PROMISE=m
+CONFIG_SCSI_SATA_SX4=m
+CONFIG_SCSI_SATA_SIL=m
+CONFIG_SCSI_SATA_SIS=m
+CONFIG_SCSI_SATA_VIA=m
+CONFIG_SCSI_SATA_VITESSE=m
+CONFIG_SCSI_BUSLOGIC=m
+# CONFIG_SCSI_OMIT_FLASHPOINT is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_EATA_PIO is not set
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+# CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INIA100=m
+# CONFIG_SCSI_NCR53C406A is not set
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
+# CONFIG_SCSI_IPR is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PSI240I is not set
+CONFIG_SCSI_QLOGIC_FAS=m
+CONFIG_SCSI_QLOGIC_ISP=m
+# CONFIG_SCSI_QLOGIC_FC is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA2XXX=m
+CONFIG_SCSI_QLA21XX=m
+CONFIG_SCSI_QLA22XX=m
+CONFIG_SCSI_QLA2300=m
+CONFIG_SCSI_QLA2322=m
+CONFIG_SCSI_QLA6312=m
+CONFIG_SCSI_QLA6322=m
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_DC395x is not set
+CONFIG_SCSI_DC390T=m
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_ULTRASTOR is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID5=m
+CONFIG_MD_RAID6=m
+CONFIG_MD_MULTIPATH=m
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_CRYPT is not set
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+
+#
+# Fusion MPT device support
+#
+CONFIG_FUSION=m
+CONFIG_FUSION_MAX_SGE=40
+# CONFIG_FUSION_ISENSE is not set
+CONFIG_FUSION_CTL=m
+
+#
+# IEEE 1394 (FireWire) support
+#
+CONFIG_IEEE1394=m
+
+#
+# Subsystem Options
+#
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+CONFIG_IEEE1394_OUI_DB=y
+# CONFIG_IEEE1394_EXTRA_CONFIG_ROMS is not set
+
+#
+# Device Drivers
+#
+# CONFIG_IEEE1394_PCILYNX is not set
+CONFIG_IEEE1394_OHCI1394=m
+
+#
+# Protocol Drivers
+#
+# CONFIG_IEEE1394_VIDEO1394 is not set
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+# CONFIG_IEEE1394_ETH1394 is not set
+CONFIG_IEEE1394_DV1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_IEEE1394_CMP=m
+CONFIG_IEEE1394_AMDTP=m
+
+#
+# I2O device support
+#
+CONFIG_I2O=m
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_ACCEPT_QUEUES is not set
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_ICMP_IPOD=y
+# CONFIG_IPV6 is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_CLK_JIFFIES=y
+# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
+# CONFIG_NET_SCH_CLK_CPU is not set
+# CONFIG_NET_SCH_CBQ is not set
+CONFIG_NET_SCH_HTB=m
+# CONFIG_NET_SCH_HFSC is not set
+# CONFIG_NET_SCH_PRIO is not set
+# CONFIG_NET_SCH_RED is not set
+# CONFIG_NET_SCH_SFQ is not set
+# CONFIG_NET_SCH_TEQL is not set
+# CONFIG_NET_SCH_TBF is not set
+# CONFIG_NET_SCH_GRED is not set
+# CONFIG_NET_SCH_DSMARK is not set
+# CONFIG_NET_SCH_NETEM is not set
+# CONFIG_NET_SCH_INGRESS is not set
+# CONFIG_NET_QOS is not set
+CONFIG_NET_CLS=y
+# CONFIG_NET_CLS_TCINDEX is not set
+# CONFIG_NET_CLS_ROUTE4 is not set
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+# CONFIG_NET_CLS_U32 is not set
+# CONFIG_NET_CLS_IND is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_TUX is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+# CONFIG_NET_SB1000 is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_EL1=m
+CONFIG_EL2=m
+CONFIG_ELPLUS=m
+CONFIG_EL16=m
+CONFIG_EL3=m
+CONFIG_3C515=m
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_LANCE=m
+CONFIG_NET_VENDOR_SMC=y
+CONFIG_WD80x3=m
+CONFIG_ULTRA=m
+CONFIG_SMC9194=m
+CONFIG_NET_VENDOR_RACAL=y
+# CONFIG_NI5010 is not set
+CONFIG_NI52=m
+CONFIG_NI65=m
+
+#
+# Tulip family network device support
+#
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+CONFIG_TULIP_MMIO=y
+# CONFIG_TULIP_NAPI is not set
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+# CONFIG_AT1700 is not set
+CONFIG_DEPCA=m
+CONFIG_HP100=m
+# CONFIG_NET_ISA is not set
+CONFIG_NE2000=m
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_AMD8111E_NAPI=y
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_AC3200=m
+CONFIG_APRICOT=m
+CONFIG_B44=m
+CONFIG_FORCEDETH=m
+CONFIG_CS89x0=m
+CONFIG_DGRS=m
+CONFIG_EEPRO100=m
+# CONFIG_EEPRO100_PIO is not set
+CONFIG_E100=m
+CONFIG_E100_NAPI=y
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+CONFIG_8139TOO_PIO=y
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+CONFIG_VIA_RHINE_MMIO=y
+CONFIG_VIA_VELOCITY=m
+CONFIG_NET_POCKET=y
+CONFIG_ATP=m
+CONFIG_DE600=m
+CONFIG_DE620=m
+
+#
+# Ethernet (1000 Mbit)
+#
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+CONFIG_SK98LIN=m
+CONFIG_TIGON3=m
+
+#
+# Ethernet (10000 Mbit)
+#
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+# CONFIG_SERIAL_8250_ACPI is not set
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+# CONFIG_SERIAL_8250_MANY_PORTS is not set
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_SERIAL_8250_MULTIPORT=y
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+# CONFIG_CRASH is not set
+CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_QIC02_TAPE is not set
+
+#
+# IPMI
+#
+CONFIG_IPMI_HANDLER=m
+# CONFIG_IPMI_PANIC_EVENT is not set
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_HW_RANDOM=m
+CONFIG_NVRAM=m
+CONFIG_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+CONFIG_AGP=m
+CONFIG_AGP_ALI=m
+CONFIG_AGP_ATI=m
+CONFIG_AGP_AMD=m
+CONFIG_AGP_AMD64=m
+CONFIG_AGP_INTEL=m
+CONFIG_AGP_INTEL_MCH=m
+CONFIG_AGP_NVIDIA=m
+CONFIG_AGP_SIS=m
+CONFIG_AGP_SWORKS=m
+CONFIG_AGP_VIA=m
+CONFIG_AGP_EFFICEON=m
+CONFIG_DRM=y
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_GAMMA=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_MWAVE=m
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_HPET is not set
+CONFIG_HANGCHECK_TIMER=m
+
+#
+# I2C support
+#
+CONFIG_I2C=m
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD8111=m
+# CONFIG_I2C_ELEKTOR is not set
+# CONFIG_I2C_I801 is not set
+CONFIG_I2C_I810=m
+CONFIG_I2C_ISA=m
+CONFIG_I2C_NFORCE2=m
+# CONFIG_I2C_PARPORT_LIGHT is not set
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_PROSAVAGE=m
+CONFIG_I2C_SAVAGE4=m
+# CONFIG_SCx200_ACB is not set
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+CONFIG_I2C_VOODOO3=m
+
+#
+# Hardware Sensors Chip support
+#
+CONFIG_I2C_SENSOR=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83627HF=m
+
+#
+# Other I2C Chip support
+#
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_SENSORS_PCF8591=m
+CONFIG_SENSORS_RTC8564=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+CONFIG_IBM_ASM=m
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=m
+
+#
+# Video For Linux
+#
+
+#
+# Video Adapters
+#
+# CONFIG_VIDEO_BT848 is not set
+CONFIG_VIDEO_PMS=m
+CONFIG_VIDEO_CPIA=m
+# CONFIG_VIDEO_CPIA_USB is not set
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+CONFIG_TUNER_3036=m
+CONFIG_VIDEO_STRADIS=m
+CONFIG_VIDEO_ZORAN=m
+CONFIG_VIDEO_ZORAN_BUZ=m
+CONFIG_VIDEO_ZORAN_DC10=m
+CONFIG_VIDEO_ZORAN_DC30=m
+CONFIG_VIDEO_ZORAN_LML33=m
+CONFIG_VIDEO_ZORAN_LML33R10=m
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_MXB=m
+CONFIG_VIDEO_DPC=m
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_OVCAMCHIP=m
+
+#
+# Radio Adapters
+#
+CONFIG_RADIO_CADET=m
+CONFIG_RADIO_RTRACK=m
+CONFIG_RADIO_RTRACK2=m
+CONFIG_RADIO_AZTECH=m
+CONFIG_RADIO_GEMTEK=m
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+CONFIG_RADIO_SF16FMI=m
+CONFIG_RADIO_SF16FMR2=m
+CONFIG_RADIO_TERRATEC=m
+CONFIG_RADIO_TRUST=m
+CONFIG_RADIO_TYPHOON=m
+CONFIG_RADIO_TYPHOON_PROC_FS=y
+CONFIG_RADIO_ZOLTRIX=m
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_VIDEO_VIDEOBUF=m
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_BUF=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+
+#
+# Graphics support
+#
+CONFIG_FB=y
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+CONFIG_FB_VGA16=m
+CONFIG_FB_VESA=y
+CONFIG_VIDEO_SELECT=y
+CONFIG_FB_HGA=m
+CONFIG_FB_HGA_ACCEL=y
+CONFIG_FB_RIVA=m
+# CONFIG_FB_RIVA_I2C is not set
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_I810=m
+CONFIG_FB_I810_GTF=y
+CONFIG_FB_MATROX=m
+CONFIG_FB_MATROX_MILLENIUM=y
+CONFIG_FB_MATROX_MYSTIQUE=y
+CONFIG_FB_MATROX_G450=y
+CONFIG_FB_MATROX_G100=y
+CONFIG_FB_MATROX_I2C=m
+CONFIG_FB_MATROX_MAVEN=m
+CONFIG_FB_MATROX_MULTIHEAD=y
+# CONFIG_FB_RADEON_OLD is not set
+CONFIG_FB_RADEON=m
+CONFIG_FB_RADEON_I2C=y
+# CONFIG_FB_RADEON_DEBUG is not set
+CONFIG_FB_ATY128=m
+CONFIG_FB_ATY=m
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GX=y
+# CONFIG_FB_ATY_XL_INIT is not set
+# CONFIG_FB_SIS is not set
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_MDA_CONSOLE=m
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+# CONFIG_LOGO is not set
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_RTCTIMER=m
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+
+#
+# Generic devices
+#
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_OPL4_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+# CONFIG_SND_SERIAL_U16550 is not set
+CONFIG_SND_MPU401=m
+
+#
+# ISA devices
+#
+CONFIG_SND_AD1816A=m
+CONFIG_SND_AD1848=m
+CONFIG_SND_CS4231=m
+CONFIG_SND_CS4232=m
+CONFIG_SND_CS4236=m
+CONFIG_SND_ES968=m
+CONFIG_SND_ES1688=m
+CONFIG_SND_ES18XX=m
+CONFIG_SND_GUSCLASSIC=m
+CONFIG_SND_GUSEXTREME=m
+CONFIG_SND_GUSMAX=m
+CONFIG_SND_INTERWAVE=m
+CONFIG_SND_INTERWAVE_STB=m
+CONFIG_SND_OPTI92X_AD1848=m
+CONFIG_SND_OPTI92X_CS4231=m
+CONFIG_SND_OPTI93X=m
+CONFIG_SND_SB8=m
+CONFIG_SND_SB16=m
+CONFIG_SND_SBAWE=m
+CONFIG_SND_SB16_CSP=y
+# CONFIG_SND_WAVEFRONT is not set
+CONFIG_SND_ALS100=m
+CONFIG_SND_AZT2320=m
+CONFIG_SND_CMI8330=m
+CONFIG_SND_DT019X=m
+CONFIG_SND_OPL3SA2=m
+CONFIG_SND_SGALAXY=m
+CONFIG_SND_SSCAPE=m
+
+#
+# PCI devices
+#
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS4281=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_HDSP=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_YMFPCI=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VX222=m
+
+#
+# ALSA USB devices
+#
+# CONFIG_SND_USB_AUDIO is not set
+
+#
+# Open Sound System
+#
+# CONFIG_SOUND_PRIME is not set
+
+#
+# USB support
+#
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_SPLIT_ISO=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_OHCI_HCD=m
+CONFIG_USB_UHCI_HCD=m
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH_TTY is not set
+# CONFIG_USB_MIDI is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_RW_DETECT=y
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_HP8200e=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+
+#
+# USB Human Interface Devices (HID)
+#
+# CONFIG_USB_HID is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_MTOUCH is not set
+# CONFIG_USB_EGALAX is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+# CONFIG_USB_DABUSB is not set
+# CONFIG_USB_VICAM is not set
+# CONFIG_USB_DSBR is not set
+# CONFIG_USB_IBMCAM is not set
+# CONFIG_USB_KONICAWC is not set
+# CONFIG_USB_OV511 is not set
+# CONFIG_USB_PWC is not set
+# CONFIG_USB_SE401 is not set
+# CONFIG_USB_SN9C102 is not set
+# CONFIG_USB_STV680 is not set
+# CONFIG_USB_W9968CF is not set
+
+#
+# USB Network adaptors
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+
+#
+# USB Host-to-Host Cables
+#
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_GENESYS=y
+CONFIG_USB_NET1080=y
+CONFIG_USB_PL2301=y
+
+#
+# Intelligent USB Devices/Gadgets
+#
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_ZAURUS=y
+CONFIG_USB_CDCETHER=y
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_AX8817X=y
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_TIGL is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETSERVO is not set
+# CONFIG_USB_TEST is not set
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+CONFIG_DEVPTS_FS_XATTR=y
+CONFIG_DEVPTS_FS_SECURITY=y
+CONFIG_TMPFS=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_RAMFS=y
+# CONFIG_RELAYFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_EXPORTFS is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=m
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=m
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CRASH_DUMP=y
+CONFIG_CRASH_DUMP_BLOCKDEV=y
+# CONFIG_CRASH_DUMP_NETDEV is not set
+# CONFIG_CRASH_DUMP_MEMDEV is not set
+# CONFIG_CRASH_DUMP_COMPRESS_RLE is not set
+# CONFIG_CRASH_DUMP_COMPRESS_GZIP is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+CONFIG_DEBUG_SLAB=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_SPINLOCK=y
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_DEBUG_HIGHMEM=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_SPINLOCK_SLEEP=y
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Linux VServer
+#
+CONFIG_VSERVER_LEGACY=y
+# CONFIG_VSERVER_PROC_SECURE is not set
+# CONFIG_VSERVER_HARDCPU is not set
+# CONFIG_INOXID_NONE is not set
+# CONFIG_INOXID_UID16 is not set
+# CONFIG_INOXID_GID16 is not set
+CONFIG_INOXID_UGID24=y
+# CONFIG_INOXID_INTERN is not set
+# CONFIG_INOXID_RUNTIME is not set
+CONFIG_VSERVER_DEBUG=y
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_PC=y
diff --git a/configs/kernel-2.6.8-i686-planetlab.config b/configs/kernel-2.6.8-i686-planetlab.config
new file mode 100644 (file)
index 0000000..5749723
--- /dev/null
@@ -0,0 +1,1103 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_X86=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_GENERIC_ISA_DMA=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+
+#
+# Class Based Kernel Resource Management
+#
+CONFIG_CKRM=y
+CONFIG_RCFS_FS=y
+CONFIG_CKRM_TYPE_TASKCLASS=y
+CONFIG_CKRM_RES_NUMTASKS=y
+CONFIG_CKRM_CPU_SCHEDULE=y
+CONFIG_CKRM_RES_BLKIO=y
+CONFIG_CKRM_RES_MEM=y
+# CONFIG_CKRM_MEM_LRUORDER_CHANGE is not set
+# CONFIG_CKRM_TYPE_SOCKETCLASS is not set
+CONFIG_CKRM_RBCE=y
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=17
+# CONFIG_HOTPLUG is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_OOM_PANIC=y
+# CONFIG_EMBEDDED is not set
+# CONFIG_DELAY_ACCT is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SIG is not set
+CONFIG_KMOD=y
+
+#
+# Processor type and features
+#
+CONFIG_X86_PC=y
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_NUMAQ is not set
+# CONFIG_X86_SUMMIT is not set
+# CONFIG_X86_BIGSMP is not set
+# CONFIG_X86_VISWS is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_ES7000 is not set
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+CONFIG_M686=y
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_XADD=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_X86_PPRO_FENCE=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_GOOD_APIC=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_USE_PPRO_CHECKSUM=y
+CONFIG_X86_4G=y
+CONFIG_X86_SWITCH_PAGETABLES=y
+CONFIG_X86_4G_VM_LAYOUT=y
+CONFIG_X86_UACCESS_INDIRECT=y
+CONFIG_X86_HIGH_ENTRY=y
+CONFIG_HPET_TIMER=y
+# CONFIG_SMP is not set
+# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_X86_UP_APIC is not set
+CONFIG_X86_TSC=y
+CONFIG_X86_MCE=y
+# CONFIG_X86_MCE_NONFATAL is not set
+# CONFIG_TOSHIBA is not set
+# CONFIG_I8K is not set
+CONFIG_MICROCODE=m
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+# CONFIG_NOHIGHMEM is not set
+CONFIG_HIGHMEM4G=y
+# CONFIG_HIGHMEM64G is not set
+CONFIG_HIGHMEM=y
+CONFIG_HIGHPTE=y
+# CONFIG_MATH_EMULATION is not set
+CONFIG_MTRR=y
+CONFIG_REGPARM=y
+
+#
+# Power management options (ACPI, APM)
+#
+# CONFIG_PM is not set
+
+#
+# ACPI (Advanced Configuration and Power Interface) Support
+#
+# CONFIG_ACPI is not set
+CONFIG_ACPI_BOOT=y
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_PCI=y
+# CONFIG_PCI_GOBIOS is not set
+# CONFIG_PCI_GOMMCONFIG is not set
+# CONFIG_PCI_GODIRECT is not set
+CONFIG_PCI_GOANY=y
+CONFIG_PCI_BIOS=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_LEGACY_PROC=y
+# CONFIG_PCI_NAMES is not set
+CONFIG_ISA=y
+# CONFIG_EISA is not set
+# CONFIG_MCA is not set
+# CONFIG_SCx200 is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_MISC=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+CONFIG_BLK_DEV_LOOP=m
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=16384
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_LBD=y
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECD=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=y
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+# CONFIG_IDE_TASKFILE_IO is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_BLK_DEV_CMD640 is not set
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_RZ1000=y
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+CONFIG_BLK_DEV_ADMA=y
+CONFIG_BLK_DEV_AEC62XX=y
+CONFIG_BLK_DEV_ALI15X3=y
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+CONFIG_BLK_DEV_ATIIXP=y
+CONFIG_BLK_DEV_CMD64X=y
+CONFIG_BLK_DEV_TRIFLEX=y
+CONFIG_BLK_DEV_CY82C693=y
+CONFIG_BLK_DEV_CS5520=y
+CONFIG_BLK_DEV_CS5530=y
+CONFIG_BLK_DEV_HPT34X=y
+# CONFIG_HPT34X_AUTODMA is not set
+CONFIG_BLK_DEV_HPT366=y
+# CONFIG_BLK_DEV_SC1200 is not set
+CONFIG_BLK_DEV_PIIX=y
+# CONFIG_BLK_DEV_NS87415 is not set
+CONFIG_BLK_DEV_PDC202XX_OLD=y
+# CONFIG_PDC202XX_BURST is not set
+CONFIG_BLK_DEV_PDC202XX_NEW=y
+CONFIG_PDC202XX_FORCE=y
+CONFIG_BLK_DEV_SVWKS=y
+CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_BLK_DEV_SIS5513=y
+CONFIG_BLK_DEV_SLC90E66=y
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=y
+# CONFIG_IDE_ARM is not set
+# CONFIG_IDE_CHIPSETS is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=m
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+
+#
+# SCSI Transport Attributes
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+
+#
+# SCSI low-level drivers
+#
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+# CONFIG_SCSI_7000FASST is not set
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AHA152X=m
+CONFIG_SCSI_AHA1542=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=4
+CONFIG_AIC7XXX_RESET_DELAY_MS=15000
+# CONFIG_AIC7XXX_BUILD_FIRMWARE is not set
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=4
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_BUILD_FIRMWARE is not set
+# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
+# CONFIG_SCSI_DPT_I2O is not set
+CONFIG_SCSI_IN2000=m
+CONFIG_SCSI_MEGARAID=m
+CONFIG_SCSI_SATA=y
+CONFIG_SCSI_SATA_SVW=m
+CONFIG_SCSI_ATA_PIIX=m
+CONFIG_SCSI_SATA_NV=m
+CONFIG_SCSI_SATA_PROMISE=m
+CONFIG_SCSI_SATA_SX4=m
+CONFIG_SCSI_SATA_SIL=m
+CONFIG_SCSI_SATA_SIS=m
+CONFIG_SCSI_SATA_VIA=m
+CONFIG_SCSI_SATA_VITESSE=m
+CONFIG_SCSI_BUSLOGIC=m
+# CONFIG_SCSI_OMIT_FLASHPOINT is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_EATA_PIO is not set
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+# CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INIA100=m
+# CONFIG_SCSI_NCR53C406A is not set
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
+# CONFIG_SCSI_IPR is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PSI240I is not set
+CONFIG_SCSI_QLOGIC_FAS=m
+CONFIG_SCSI_QLOGIC_ISP=m
+# CONFIG_SCSI_QLOGIC_FC is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA2XXX=m
+CONFIG_SCSI_QLA21XX=m
+CONFIG_SCSI_QLA22XX=m
+CONFIG_SCSI_QLA2300=m
+CONFIG_SCSI_QLA2322=m
+CONFIG_SCSI_QLA6312=m
+CONFIG_SCSI_QLA6322=m
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_DC395x is not set
+CONFIG_SCSI_DC390T=m
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_ULTRASTOR is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=y
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_MD_RAID6 is not set
+# CONFIG_MD_MULTIPATH is not set
+CONFIG_BLK_DEV_DM=y
+# CONFIG_DM_CRYPT is not set
+# CONFIG_DM_SNAPSHOT is not set
+# CONFIG_DM_MIRROR is not set
+# CONFIG_DM_ZERO is not set
+
+#
+# Fusion MPT device support
+#
+CONFIG_FUSION=m
+CONFIG_FUSION_MAX_SGE=40
+# CONFIG_FUSION_ISENSE is not set
+CONFIG_FUSION_CTL=m
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_ACCEPT_QUEUES is not set
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_ICMP_IPOD=y
+# CONFIG_IPV6 is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_CLK_JIFFIES=y
+# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
+# CONFIG_NET_SCH_CLK_CPU is not set
+# CONFIG_NET_SCH_CBQ is not set
+CONFIG_NET_SCH_HTB=m
+# CONFIG_NET_SCH_HFSC is not set
+# CONFIG_NET_SCH_PRIO is not set
+# CONFIG_NET_SCH_RED is not set
+# CONFIG_NET_SCH_SFQ is not set
+# CONFIG_NET_SCH_TEQL is not set
+# CONFIG_NET_SCH_TBF is not set
+# CONFIG_NET_SCH_GRED is not set
+# CONFIG_NET_SCH_DSMARK is not set
+# CONFIG_NET_SCH_NETEM is not set
+# CONFIG_NET_SCH_INGRESS is not set
+# CONFIG_NET_QOS is not set
+CONFIG_NET_CLS=y
+# CONFIG_NET_CLS_TCINDEX is not set
+# CONFIG_NET_CLS_ROUTE4 is not set
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+# CONFIG_NET_CLS_U32 is not set
+# CONFIG_NET_CLS_IND is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_TUX is not set
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_EL1=m
+CONFIG_EL2=m
+CONFIG_ELPLUS=m
+CONFIG_EL16=m
+CONFIG_EL3=m
+CONFIG_3C515=m
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_LANCE=m
+CONFIG_NET_VENDOR_SMC=y
+CONFIG_WD80x3=m
+CONFIG_ULTRA=m
+CONFIG_SMC9194=m
+CONFIG_NET_VENDOR_RACAL=y
+# CONFIG_NI5010 is not set
+CONFIG_NI52=m
+CONFIG_NI65=m
+
+#
+# Tulip family network device support
+#
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+CONFIG_TULIP_MMIO=y
+# CONFIG_TULIP_NAPI is not set
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+# CONFIG_AT1700 is not set
+CONFIG_DEPCA=m
+CONFIG_HP100=m
+# CONFIG_NET_ISA is not set
+CONFIG_NE2000=m
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_AMD8111E_NAPI=y
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_AC3200=m
+CONFIG_APRICOT=m
+CONFIG_B44=m
+CONFIG_FORCEDETH=m
+CONFIG_CS89x0=m
+CONFIG_DGRS=m
+CONFIG_EEPRO100=m
+# CONFIG_EEPRO100_PIO is not set
+CONFIG_E100=m
+CONFIG_E100_NAPI=y
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+CONFIG_8139TOO_PIO=y
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+CONFIG_VIA_RHINE_MMIO=y
+CONFIG_VIA_VELOCITY=m
+CONFIG_NET_POCKET=y
+CONFIG_ATP=m
+CONFIG_DE600=m
+CONFIG_DE620=m
+
+#
+# Ethernet (1000 Mbit)
+#
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+CONFIG_SK98LIN=m
+CONFIG_TIGON3=m
+
+#
+# Ethernet (10000 Mbit)
+#
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+# CONFIG_SERIAL_8250_MANY_PORTS is not set
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_SERIAL_8250_MULTIPORT=y
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_CRASH is not set
+# CONFIG_QIC02_TAPE is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+# CONFIG_MWAVE is not set
+# CONFIG_RAW_DRIVER is not set
+CONFIG_HANGCHECK_TIMER=y
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+# CONFIG_IBM_ASM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+CONFIG_VIDEO_SELECT=y
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+# CONFIG_MDA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+CONFIG_DEVPTS_FS_XATTR=y
+CONFIG_DEVPTS_FS_SECURITY=y
+CONFIG_TMPFS=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_RAMFS=y
+# CONFIG_RELAYFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_EXPORTFS is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=m
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=m
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_CRASH_DUMP is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+CONFIG_DEBUG_SLAB=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_SPINLOCK=y
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_DEBUG_HIGHMEM=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_SPINLOCK_SLEEP=y
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Linux VServer
+#
+CONFIG_VSERVER_LEGACY=y
+# CONFIG_VSERVER_PROC_SECURE is not set
+# CONFIG_VSERVER_HARDCPU is not set
+# CONFIG_INOXID_NONE is not set
+# CONFIG_INOXID_UID16 is not set
+# CONFIG_INOXID_GID16 is not set
+CONFIG_INOXID_UGID24=y
+# CONFIG_INOXID_INTERN is not set
+# CONFIG_INOXID_RUNTIME is not set
+# CONFIG_VSERVER_DEBUG is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_PC=y
diff --git a/configs/kernel-2.6.8-i686-uml-planetlab.config b/configs/kernel-2.6.8-i686-uml-planetlab.config
new file mode 100644 (file)
index 0000000..bd7f133
--- /dev/null
@@ -0,0 +1,519 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_USERMODE=y
+CONFIG_MMU=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# UML-specific options
+#
+CONFIG_MODE_TT=y
+CONFIG_MODE_SKAS=y
+CONFIG_NET=y
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=m
+CONFIG_EXTERNFS=y
+CONFIG_HOSTFS=y
+# CONFIG_HUMFS is not set
+# CONFIG_HPPFS is not set
+CONFIG_MCONSOLE=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_HOST_2G_2G is not set
+# CONFIG_UML_SMP is not set
+# CONFIG_SMP is not set
+CONFIG_NEST_LEVEL=0
+CONFIG_KERNEL_HALF_GIGS=1
+# CONFIG_HIGHMEM is not set
+CONFIG_PROC_MM=y
+CONFIG_KERNEL_STACK_ORDER=2
+CONFIG_UML_REAL_TIME_CLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+
+#
+# Class Based Kernel Resource Management
+#
+# CONFIG_CKRM is not set
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_HOTPLUG is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_EMBEDDED is not set
+# CONFIG_DELAY_ACCT is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SIG is not set
+CONFIG_KMOD=y
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+
+#
+# Character Devices
+#
+CONFIG_STDIO_CONSOLE=y
+CONFIG_SSL=y
+CONFIG_FD_CHAN=y
+CONFIG_NULL_CHAN=y
+CONFIG_PORT_CHAN=y
+CONFIG_PTY_CHAN=y
+CONFIG_TTY_CHAN=y
+CONFIG_XTERM_CHAN=y
+CONFIG_CON_ZERO_CHAN="fd:0,fd:1"
+CONFIG_CON_CHAN="xterm"
+CONFIG_SSL_CHAN="pty"
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+CONFIG_SOFT_WATCHDOG=y
+CONFIG_UML_WATCHDOG=y
+CONFIG_UML_SOUND=y
+CONFIG_SOUND=y
+CONFIG_HOSTAUDIO=y
+
+#
+# Block Devices
+#
+CONFIG_BLK_DEV_UBD=y
+# CONFIG_BLK_DEV_UBD_SYNC is not set
+CONFIG_BLK_DEV_COW_COMMON=y
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=16384
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_MMAPPER is not set
+CONFIG_NETDEVICES=y
+
+#
+# UML Network Devices
+#
+CONFIG_UML_NET=y
+CONFIG_UML_NET_ETHERTAP=y
+CONFIG_UML_NET_TUNTAP=y
+CONFIG_UML_NET_SLIP=y
+CONFIG_UML_NET_DAEMON=y
+CONFIG_UML_NET_MCAST=y
+# CONFIG_UML_NET_PCAP is not set
+CONFIG_UML_NET_SLIRP=y
+
+#
+# Networking support
+#
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+# CONFIG_NETLINK_DEV is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_ACCEPT_QUEUES is not set
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+CONFIG_ICMP_IPOD=y
+# CONFIG_IPV6 is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_LIMIT=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_MAC=m
+CONFIG_IP_NF_MATCH_PKTTYPE=m
+CONFIG_IP_NF_MATCH_MARK=m
+CONFIG_IP_NF_MATCH_MULTIPORT=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH_ESP=m
+CONFIG_IP_NF_MATCH_LENGTH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_TCPMSS=m
+CONFIG_IP_NF_MATCH_HELPER=m
+CONFIG_IP_NF_MATCH_STATE=m
+CONFIG_IP_NF_MATCH_CONNTRACK=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_LOCAL=y
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_MARK=m
+CONFIG_IP_NF_TARGET_CLASSIFY=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
+CONFIG_IP_NF_TARGET_NOTRACK=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_REALM=m
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_CLK_JIFFIES=y
+# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
+# CONFIG_NET_SCH_CLK_CPU is not set
+# CONFIG_NET_SCH_CBQ is not set
+CONFIG_NET_SCH_HTB=m
+# CONFIG_NET_SCH_HFSC is not set
+# CONFIG_NET_SCH_PRIO is not set
+# CONFIG_NET_SCH_RED is not set
+# CONFIG_NET_SCH_SFQ is not set
+# CONFIG_NET_SCH_TEQL is not set
+# CONFIG_NET_SCH_TBF is not set
+# CONFIG_NET_SCH_GRED is not set
+# CONFIG_NET_SCH_DSMARK is not set
+# CONFIG_NET_SCH_NETEM is not set
+# CONFIG_NET_SCH_INGRESS is not set
+# CONFIG_NET_QOS is not set
+# CONFIG_NET_CLS is not set
+CONFIG_NET_CLS_ROUTE=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_TUX is not set
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS_XATTR=y
+CONFIG_DEVPTS_FS_SECURITY=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_RELAYFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_EXPORTFS is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Linux VServer
+#
+CONFIG_VSERVER_LEGACY=y
+# CONFIG_VSERVER_PROC_SECURE is not set
+CONFIG_VSERVER_HARDCPU=y
+# CONFIG_INOXID_NONE is not set
+# CONFIG_INOXID_UID16 is not set
+# CONFIG_INOXID_GID16 is not set
+CONFIG_INOXID_UGID24=y
+# CONFIG_INOXID_INTERN is not set
+# CONFIG_INOXID_RUNTIME is not set
+CONFIG_VSERVER_DEBUG=y
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+
+#
+# SCSI support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_FRAME_POINTER=y
+# CONFIG_PT_PROXY is not set
+# CONFIG_GPROF is not set
+# CONFIG_GCOV is not set
index 12429ef..2e2c339 100644 (file)
@@ -246,5 +246,25 @@ config CRYPTO_TEST
        help
          Quick & dirty crypto test module.
 
+config CRYPTO_SIGNATURE
+       bool "In-kernel signature checker (EXPERIMENTAL)"
+       depends on CRYPTO
+       help
+         Signature checker (used for module sig checking).
+
+config CRYPTO_SIGNATURE_DSA
+       bool "Handle DSA signatures (EXPERIMENTAL)"
+       depends on CRYPTO_SIGNATURE
+       select CRYPTO_MPILIB
+       help
+         DSA Signature checker.
+
+config CRYPTO_MPILIB
+       bool "Multiprecision maths library (EXPERIMENTAL)"
+       depends on CRYPTO
+       help
+         Multiprecision maths library from GnuPG
+       
+
 endmenu
 
index 04428a6..bf7ca60 100644 (file)
@@ -29,3 +29,6 @@ obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
 
 obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
+
+obj-$(CONFIG_CRYPTO_SIGNATURE) += signature/
+obj-$(CONFIG_CRYPTO_MPILIB) += mpi/
index 6f0e625..24fd60e 100644 (file)
@@ -117,12 +117,19 @@ static void crypto_exit_ops(struct crypto_tfm *tfm)
        }
 }
 
-struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+struct crypto_tfm *crypto_alloc_tfm2(const char *name, u32 flags,
+                                    int nomodload)
 {
        struct crypto_tfm *tfm = NULL;
        struct crypto_alg *alg;
 
-       alg = crypto_alg_mod_lookup(name);
+       if (!nomodload) {
+               alg = crypto_alg_mod_lookup(name);
+       }
+       else {
+               alg = crypto_alg_lookup(name);
+       }
+
        if (alg == NULL)
                goto out;
        
@@ -153,6 +160,11 @@ out:
        return tfm;
 }
 
+struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+{
+       return crypto_alloc_tfm2(name, flags, 0);
+}
+
 void crypto_free_tfm(struct crypto_tfm *tfm)
 {
        crypto_exit_ops(tfm);
index d9b6ac9..61a7676 100644 (file)
@@ -52,6 +52,13 @@ static void update(struct crypto_tfm *tfm,
        }
 }
 
+static void update_kernel(struct crypto_tfm *tfm,
+                         const void *data, size_t count)
+{
+       tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm), data, count);
+       crypto_yield(tfm);
+}
+
 static void final(struct crypto_tfm *tfm, u8 *out)
 {
        tfm->__crt_alg->cra_digest.dia_final(crypto_tfm_ctx(tfm), out);
@@ -94,6 +101,7 @@ int crypto_init_digest_ops(struct crypto_tfm *tfm)
        
        ops->dit_init   = init;
        ops->dit_update = update;
+       ops->dit_update_kernel = update_kernel;
        ops->dit_final  = final;
        ops->dit_digest = digest;
        ops->dit_setkey = setkey;
diff --git a/crypto/mpi/Makefile b/crypto/mpi/Makefile
new file mode 100644 (file)
index 0000000..e96597d
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# MPI multiprecision maths library (from gpg) 
+#
+
+obj-$(CONFIG_CRYPTO_MPILIB) = \
+       generic_mpih-lshift.o           \
+       generic_mpih-mul1.o             \
+       generic_mpih-mul2.o             \
+       generic_mpih-mul3.o             \
+       generic_mpih-rshift.o           \
+       generic_mpih-sub1.o             \
+       generic_mpih-add1.o             \
+       generic_udiv-w-sdiv.o           \
+       mpicoder.o                      \
+       mpi-add.o                       \
+       mpi-bit.o                       \
+       mpi-div.o                       \
+       mpi-cmp.o                       \
+       mpi-gcd.o                       \
+       mpih-cmp.o                      \
+       mpih-div.o                      \
+       mpih-mul.o                      \
+       mpi-inline.o                    \
+       mpi-inv.o                       \
+       mpi-mpow.o                      \
+       mpi-mul.o                       \
+       mpi-pow.o                       \
+       mpi-scan.o                      \
+       mpiutil.o
+
diff --git a/crypto/mpi/generic_mpi-asm-defs.h b/crypto/mpi/generic_mpi-asm-defs.h
new file mode 100644 (file)
index 0000000..13424e2
--- /dev/null
@@ -0,0 +1,10 @@
+/* This file defines some basic constants for the MPI machinery.  We
+ * need to define the types on a per-CPU basis, so it is done with
+ * this file here.  */
+#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG)
+
+
+
+
+
+
diff --git a/crypto/mpi/generic_mpih-add1.c b/crypto/mpi/generic_mpih-add1.c
new file mode 100644 (file)
index 0000000..891fef0
--- /dev/null
@@ -0,0 +1,62 @@
+/* mpihelp-add_1.c  -  MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 
+ *               2000 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+mpihelp_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+              mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+    mpi_limb_t x, y, cy;
+    mpi_size_t j;
+
+    /* The loop counter and index J goes from -SIZE to -1.  This way
+       the loop becomes faster.  */
+    j = -size;
+
+    /* Offset the base pointers to compensate for the negative indices. */
+    s1_ptr -= j;
+    s2_ptr -= j;
+    res_ptr -= j;
+
+    cy = 0;
+    do {
+       y = s2_ptr[j];
+       x = s1_ptr[j];
+       y += cy;                  /* add previous carry to one addend */
+       cy = y < cy;              /* get out carry from that addition */
+       y += x;                   /* add other addend */
+       cy += y < x;              /* get out carry from that add, combine */
+       res_ptr[j] = y;
+    } while( ++j );
+
+    return cy;
+}
+
diff --git a/crypto/mpi/generic_mpih-lshift.c b/crypto/mpi/generic_mpih-lshift.c
new file mode 100644 (file)
index 0000000..9e159b5
--- /dev/null
@@ -0,0 +1,66 @@
+/* mpihelp-lshift.c  - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+
+/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
+ * and store the USIZE least significant digits of the result at WP.
+ * Return the bits shifted out from the most significant digit.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be >= UP.
+ */
+
+mpi_limb_t
+mpihelp_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+                                           unsigned int cnt)
+{
+    mpi_limb_t high_limb, low_limb;
+    unsigned sh_1, sh_2;
+    mpi_size_t i;
+    mpi_limb_t retval;
+
+    sh_1 = cnt;
+    wp += 1;
+    sh_2 = BITS_PER_MPI_LIMB - sh_1;
+    i = usize - 1;
+    low_limb = up[i];
+    retval = low_limb >> sh_2;
+    high_limb = low_limb;
+    while( --i >= 0 ) {
+       low_limb = up[i];
+       wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
+       high_limb = low_limb;
+    }
+    wp[i] = high_limb << sh_1;
+
+    return retval;
+}
+
+
diff --git a/crypto/mpi/generic_mpih-mul1.c b/crypto/mpi/generic_mpih-mul1.c
new file mode 100644 (file)
index 0000000..4e34d46
--- /dev/null
@@ -0,0 +1,58 @@
+/* mpihelp-mul_1.c  -  MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+                                                   mpi_limb_t s2_limb)
+{
+    mpi_limb_t cy_limb;
+    mpi_size_t j;
+    mpi_limb_t prod_high, prod_low;
+
+    /* The loop counter and index J goes from -S1_SIZE to -1.  This way
+     * the loop becomes faster.  */
+    j = -s1_size;
+
+    /* Offset the base pointers to compensate for the negative indices.  */
+    s1_ptr -= j;
+    res_ptr -= j;
+
+    cy_limb = 0;
+    do {
+       umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+       prod_low += cy_limb;
+       cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+       res_ptr[j] = prod_low;
+    } while( ++j );
+
+    return cy_limb;
+}
+
diff --git a/crypto/mpi/generic_mpih-mul2.c b/crypto/mpi/generic_mpih-mul2.c
new file mode 100644 (file)
index 0000000..c1f41f3
--- /dev/null
@@ -0,0 +1,63 @@
+/* mpihelp-mul_2.c  -  MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                 mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+    mpi_limb_t cy_limb;
+    mpi_size_t j;
+    mpi_limb_t prod_high, prod_low;
+    mpi_limb_t x;
+
+    /* The loop counter and index J goes from -SIZE to -1.  This way
+     * the loop becomes faster.  */
+    j = -s1_size;
+    res_ptr -= j;
+    s1_ptr -= j;
+
+    cy_limb = 0;
+    do {
+       umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+
+       prod_low += cy_limb;
+       cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+       x = res_ptr[j];
+       prod_low = x + prod_low;
+       cy_limb += prod_low < x?1:0;
+       res_ptr[j] = prod_low;
+    } while ( ++j );
+    return cy_limb;
+}
+
+
diff --git a/crypto/mpi/generic_mpih-mul3.c b/crypto/mpi/generic_mpih-mul3.c
new file mode 100644 (file)
index 0000000..6b1d04b
--- /dev/null
@@ -0,0 +1,64 @@
+/* mpihelp-mul_3.c  -  MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+mpihelp_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                 mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+    mpi_limb_t cy_limb;
+    mpi_size_t j;
+    mpi_limb_t prod_high, prod_low;
+    mpi_limb_t x;
+
+    /* The loop counter and index J goes from -SIZE to -1.  This way
+     * the loop becomes faster.  */
+    j = -s1_size;
+    res_ptr -= j;
+    s1_ptr -= j;
+
+    cy_limb = 0;
+    do {
+       umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb);
+
+       prod_low += cy_limb;
+       cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+       x = res_ptr[j];
+       prod_low = x - prod_low;
+       cy_limb += prod_low > x?1:0;
+       res_ptr[j] = prod_low;
+    } while( ++j );
+
+    return cy_limb;
+}
+
+
diff --git a/crypto/mpi/generic_mpih-rshift.c b/crypto/mpi/generic_mpih-rshift.c
new file mode 100644 (file)
index 0000000..0fc3bc8
--- /dev/null
@@ -0,0 +1,65 @@
+/* mpih-rshift.c  -  MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 1999,
+ *               2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GNUPG
+ *
+ * GNUPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNUPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+
+
+/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right
+ * and store the USIZE least significant limbs of the result at WP.
+ * The bits shifted out to the right are returned.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be <= UP.
+ */
+
+mpi_limb_t
+mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
+{
+    mpi_limb_t high_limb, low_limb;
+    unsigned sh_1, sh_2;
+    mpi_size_t i;
+    mpi_limb_t retval;
+
+    sh_1 = cnt;
+    wp -= 1;
+    sh_2 = BITS_PER_MPI_LIMB - sh_1;
+    high_limb = up[0];
+    retval = high_limb << sh_2;
+    low_limb = high_limb;
+    for( i=1; i < usize; i++) {
+       high_limb = up[i];
+       wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
+       low_limb = high_limb;
+    }
+    wp[i] = low_limb >> sh_1;
+
+    return retval;
+}
+
diff --git a/crypto/mpi/generic_mpih-sub1.c b/crypto/mpi/generic_mpih-sub1.c
new file mode 100644 (file)
index 0000000..9c78f15
--- /dev/null
@@ -0,0 +1,62 @@
+/* mpihelp-add_2.c  -  MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+mpihelp_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                                 mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+    mpi_limb_t x, y, cy;
+    mpi_size_t j;
+
+    /* The loop counter and index J goes from -SIZE to -1.  This way
+       the loop becomes faster.  */
+    j = -size;
+
+    /* Offset the base pointers to compensate for the negative indices.  */
+    s1_ptr -= j;
+    s2_ptr -= j;
+    res_ptr -= j;
+
+    cy = 0;
+    do {
+       y = s2_ptr[j];
+       x = s1_ptr[j];
+       y += cy;                  /* add previous carry to subtrahend */
+       cy = y < cy;              /* get out carry from that addition */
+       y = x - y;                /* main subtract */
+       cy += y > x;              /* get out carry from the subtract, combine */
+       res_ptr[j] = y;
+    } while( ++j );
+
+    return cy;
+}
+
+
diff --git a/crypto/mpi/generic_udiv-w-sdiv.c b/crypto/mpi/generic_udiv-w-sdiv.c
new file mode 100644 (file)
index 0000000..8cfc6d3
--- /dev/null
@@ -0,0 +1,130 @@
+/* mpihelp_udiv_w_sdiv -- implement udiv_qrnnd on machines with only signed
+ *                       division.
+ * Copyright (C) 1992, 1994, 1996, 1998 Free Software Foundation, Inc.
+ * Contributed by Peter L. Montgomery.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+#if 0  /* not yet ported to MPI */
+
+mpi_limb_t
+mpihelp_udiv_w_sdiv( mpi_limp_t *rp,
+                    mpi_limp_t *a1,
+                    mpi_limp_t *a0,
+                    mpi_limp_t *d   )
+{
+  mp_limb_t q, r;
+  mp_limb_t c0, c1, b1;
+
+  if ((mpi_limb_signed_t) d >= 0)
+    {
+      if (a1 < d - a1 - (a0 >> (BITS_PER_MP_LIMB - 1)))
+       {
+         /* dividend, divisor, and quotient are nonnegative */
+         sdiv_qrnnd (q, r, a1, a0, d);
+       }
+      else
+       {
+         /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */
+         sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (BITS_PER_MP_LIMB - 1));
+         /* Divide (c1*2^32 + c0) by d */
+         sdiv_qrnnd (q, r, c1, c0, d);
+         /* Add 2^31 to quotient */
+         q += (mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1);
+       }
+    }
+  else
+    {
+      b1 = d >> 1;                     /* d/2, between 2^30 and 2^31 - 1 */
+      c1 = a1 >> 1;                    /* A/2 */
+      c0 = (a1 << (BITS_PER_MP_LIMB - 1)) + (a0 >> 1);
+
+      if (a1 < b1)                     /* A < 2^32*b1, so A/2 < 2^31*b1 */
+       {
+         sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
+
+         r = 2*r + (a0 & 1);           /* Remainder from A/(2*b1) */
+         if ((d & 1) != 0)
+           {
+             if (r >= q)
+               r = r - q;
+             else if (q - r <= d)
+               {
+                 r = r - q + d;
+                 q--;
+               }
+             else
+               {
+                 r = r - q + 2*d;
+                 q -= 2;
+               }
+           }
+       }
+      else if (c1 < b1)                /* So 2^31 <= (A/2)/b1 < 2^32 */
+       {
+         c1 = (b1 - 1) - c1;
+         c0 = ~c0;                     /* logical NOT */
+
+         sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
+
+         q = ~q;                       /* (A/2)/b1 */
+         r = (b1 - 1) - r;
+
+         r = 2*r + (a0 & 1);           /* A/(2*b1) */
+
+         if ((d & 1) != 0)
+           {
+             if (r >= q)
+               r = r - q;
+             else if (q - r <= d)
+               {
+                 r = r - q + d;
+                 q--;
+               }
+             else
+               {
+                 r = r - q + 2*d;
+                 q -= 2;
+               }
+           }
+       }
+      else                             /* Implies c1 = b1 */
+       {                               /* Hence a1 = d - 1 = 2*b1 - 1 */
+         if (a0 >= -d)
+           {
+             q = -1;
+             r = a0 + d;
+           }
+         else
+           {
+             q = -2;
+             r = a0 + 2*d;
+           }
+       }
+    }
+
+  *rp = r;
+  return q;
+}
+
+#endif
+
diff --git a/crypto/mpi/longlong.h b/crypto/mpi/longlong.h
new file mode 100644 (file)
index 0000000..bf084fc
--- /dev/null
@@ -0,0 +1,1502 @@
+/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
+   Note: I added some stuff for use with gnupg
+
+Copyright (C) 1991, 1992, 1993, 1994, 1996, 1998,
+              2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+This file is free software; you can redistribute it and/or modify
+it under the terms of the GNU Library General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with this file; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/* You have to define the following before including this file:
+
+   UWtype -- An unsigned type, default type for operations (typically a "word")
+   UHWtype -- An unsigned type, at least half the size of UWtype.
+   UDWtype -- An unsigned type, at least twice as large a UWtype
+   W_TYPE_SIZE -- size in bits of UWtype
+
+   SItype, USItype -- Signed and unsigned 32 bit types.
+   DItype, UDItype -- Signed and unsigned 64 bit types.
+
+   On a 32 bit machine UWtype should typically be USItype;
+   on a 64 bit machine, UWtype should typically be UDItype.
+*/
+
+#define __BITS4 (W_TYPE_SIZE / 4)
+#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
+#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
+#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
+
+/* This is used to make sure no undesirable sharing between different libraries
+   that use this file takes place.  */
+#ifndef __MPN
+#define __MPN(x) __##x
+#endif
+
+/* Define auxiliary asm macros.
+
+   1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two
+   UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype
+   word product in HIGH_PROD and LOW_PROD.
+
+   2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
+   UDWtype product.  This is just a variant of umul_ppmm.
+
+   3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+   denominator) divides a UDWtype, composed by the UWtype integers
+   HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
+   in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
+   than DENOMINATOR for correct operation.  If, in addition, the most
+   significant bit of DENOMINATOR must be 1, then the pre-processor symbol
+   UDIV_NEEDS_NORMALIZATION is defined to 1.
+
+   4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+   denominator).  Like udiv_qrnnd but the numbers are signed.  The quotient
+   is rounded towards 0.
+
+   5) count_leading_zeros(count, x) counts the number of zero-bits from the
+   msb to the first non-zero bit in the UWtype X.  This is the number of
+   steps X needs to be shifted left to set the msb.  Undefined for X == 0,
+   unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
+
+   6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
+   from the least significant end.
+
+   7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
+   high_addend_2, low_addend_2) adds two UWtype integers, composed by
+   HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
+   respectively.  The result is placed in HIGH_SUM and LOW_SUM.  Overflow
+   (i.e. carry out) is not stored anywhere, and is lost.
+
+   8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
+   high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
+   composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
+   LOW_SUBTRAHEND_2 respectively.  The result is placed in HIGH_DIFFERENCE
+   and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
+   and is lost.
+
+   If any of these macros are left undefined for a particular CPU,
+   C macros are used.  */
+
+/* The CPUs come in alphabetical order below.
+
+   Please add support for more CPUs here, or improve the current support
+   for the CPUs below! */
+
+#if defined (__GNUC__) && !defined (NO_ASM)
+
+/* We sometimes need to clobber "cc" with gcc2, but that would not be
+   understood by gcc1. Use cpp to avoid major code duplication.  */
+#if __GNUC__ < 2
+#define __CLOBBER_CC
+#define __AND_CLOBBER_CC
+#else /* __GNUC__ >= 2 */
+#define __CLOBBER_CC : "cc"
+#define __AND_CLOBBER_CC , "cc"
+#endif /* __GNUC__ < 2 */
+
+
+/***************************************
+ **************  A29K  *****************
+ ***************************************/
+#if (defined (__a29k__) || defined (_AM29K)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("add %1,%4,%5\n"   \
+           "addc %0,%2,%3"                                              \
+          : "=r" ((USItype)(sh)),                                      \
+           "=&r" ((USItype)(sl))                                       \
+          : "%r" ((USItype)(ah)),                                      \
+            "rI" ((USItype)(bh)),                                      \
+            "%r" ((USItype)(al)),                                      \
+            "rI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("sub %1,%4,%5\n"                                             \
+          "subc %0,%2,%3"                                              \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "r" ((USItype)(ah)),                                       \
+            "rI" ((USItype)(bh)),                                      \
+            "r" ((USItype)(al)),                                       \
+            "rI" ((USItype)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+  do {                                                                 \
+    USItype __m0 = (m0), __m1 = (m1);                                  \
+    __asm__ ("multiplu %0,%1,%2"                                        \
+            : "=r" ((USItype)(xl))                                     \
+            : "r" (__m0),                                              \
+              "r" (__m1));                                             \
+    __asm__ ("multmu %0,%1,%2"                                          \
+            : "=r" ((USItype)(xh))                                     \
+            : "r" (__m0),                                              \
+              "r" (__m1));                                             \
+  } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  __asm__ ("dividu %0,%3,%4"                                            \
+          : "=r" ((USItype)(q)),                                       \
+            "=q" ((USItype)(r))                                        \
+          : "1" ((USItype)(n1)),                                       \
+            "r" ((USItype)(n0)),                                       \
+            "r" ((USItype)(d)))
+
+#define count_leading_zeros(count, x) \
+    __asm__ ("clz %0,%1"                                                \
+            : "=r" ((USItype)(count))                                  \
+            : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
+#endif /* __a29k__ */
+
+
+#if defined (__alpha) && W_TYPE_SIZE == 64
+#define umul_ppmm(ph, pl, m0, m1) \
+  do {                                                                 \
+    UDItype __m0 = (m0), __m1 = (m1);                                  \
+    __asm__ ("umulh %r1,%2,%0"                                          \
+            : "=r" ((UDItype) ph)                                      \
+            : "%rJ" (__m0),                                            \
+              "rI" (__m1));                                            \
+    (pl) = __m0 * __m1;                                                \
+  } while (0)
+#define UMUL_TIME 46
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  do { UDItype __r;                                                    \
+    (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                        \
+    (r) = __r;                                                         \
+  } while (0)
+extern UDItype __udiv_qrnnd ();
+#define UDIV_TIME 220
+#endif /* LONGLONG_STANDALONE */
+#endif /* __alpha */
+
+/***************************************
+ **************  ARM  ******************
+ ***************************************/
+#if defined (__arm__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("adds %1, %4, %5\n"                                          \
+          "adc  %0, %2, %3"                                            \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%r" ((USItype)(ah)),                                      \
+            "rI" ((USItype)(bh)),                                      \
+            "%r" ((USItype)(al)),                                      \
+            "rI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("subs %1, %4, %5\n"                                          \
+          "sbc  %0, %2, %3"                                            \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "r" ((USItype)(ah)),                                       \
+            "rI" ((USItype)(bh)),                                      \
+            "r" ((USItype)(al)),                                       \
+            "rI" ((USItype)(bl)))
+#if defined __ARM_ARCH_2__ || defined __ARM_ARCH_3__
+#define umul_ppmm(xh, xl, a, b) \
+  __asm__ ("%@ Inlined umul_ppmm\n"                                     \
+       "mov    %|r0, %2, lsr #16               @ AAAA\n"               \
+       "mov    %|r2, %3, lsr #16               @ BBBB\n"               \
+       "bic    %|r1, %2, %|r0, lsl #16         @ aaaa\n"               \
+       "bic    %0, %3, %|r2, lsl #16           @ bbbb\n"               \
+       "mul    %1, %|r1, %|r2                  @ aaaa * BBBB\n"        \
+       "mul    %|r2, %|r0, %|r2                @ AAAA * BBBB\n"        \
+       "mul    %|r1, %0, %|r1                  @ aaaa * bbbb\n"        \
+       "mul    %0, %|r0, %0                    @ AAAA * bbbb\n"        \
+       "adds   %|r0, %1, %0                    @ central sum\n"        \
+       "addcs  %|r2, %|r2, #65536\n"                                   \
+       "adds   %1, %|r1, %|r0, lsl #16\n"                              \
+       "adc    %0, %|r2, %|r0, lsr #16"                                \
+          : "=&r" ((USItype)(xh)),                                     \
+            "=r" ((USItype)(xl))                                       \
+          : "r" ((USItype)(a)),                                        \
+            "r" ((USItype)(b))                                         \
+          : "r0", "r1", "r2")
+#else
+#define umul_ppmm(xh, xl, a, b)                                         \
+  __asm__ ("%@ Inlined umul_ppmm\n"                                     \
+          "umull %r1, %r0, %r2, %r3"                                   \
+                  : "=&r" ((USItype)(xh)),                             \
+                    "=r" ((USItype)(xl))                               \
+                  : "r" ((USItype)(a)),                                \
+                    "r" ((USItype)(b))                                 \
+                  : "r0", "r1")
+#endif
+#define UMUL_TIME 20
+#define UDIV_TIME 100
+#endif /* __arm__ */
+
+/***************************************
+ **************  CLIPPER  **************
+ ***************************************/
+#if defined (__clipper__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+  ({union {UDItype __ll;                                               \
+          struct {USItype __l, __h;} __i;                              \
+         } __xx;                                                       \
+  __asm__ ("mulwux %2,%0"                                               \
+          : "=r" (__xx.__ll)                                           \
+          : "%0" ((USItype)(u)),                                       \
+            "r" ((USItype)(v)));                                       \
+  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define smul_ppmm(w1, w0, u, v) \
+  ({union {DItype __ll;                                                \
+          struct {SItype __l, __h;} __i;                               \
+         } __xx;                                                       \
+  __asm__ ("mulwx %2,%0"                                                \
+          : "=r" (__xx.__ll)                                           \
+          : "%0" ((SItype)(u)),                                        \
+            "r" ((SItype)(v)));                                        \
+  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+  ({UDItype __w;                                                       \
+    __asm__ ("mulwux %2,%0"                                             \
+            : "=r" (__w)                                               \
+            : "%0" ((USItype)(u)),                                     \
+              "r" ((USItype)(v)));                                     \
+    __w; })
+#endif /* __clipper__ */
+
+
+/***************************************
+ **************  GMICRO  ***************
+ ***************************************/
+#if defined (__gmicro__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("add.w %5,%1\n"                                              \
+          "addx %3,%0"                                                 \
+          : "=g" ((USItype)(sh)),                                      \
+            "=&g" ((USItype)(sl))                                      \
+          : "%0" ((USItype)(ah)),                                      \
+            "g" ((USItype)(bh)),                                       \
+            "%1" ((USItype)(al)),                                      \
+            "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("sub.w %5,%1\n"                                              \
+          "subx %3,%0"                                                 \
+          : "=g" ((USItype)(sh)),                                      \
+            "=&g" ((USItype)(sl))                                      \
+          : "0" ((USItype)(ah)),                                       \
+            "g" ((USItype)(bh)),                                       \
+            "1" ((USItype)(al)),                                       \
+            "g" ((USItype)(bl)))
+#define umul_ppmm(ph, pl, m0, m1) \
+  __asm__ ("mulx %3,%0,%1"                                              \
+          : "=g" ((USItype)(ph)),                                      \
+            "=r" ((USItype)(pl))                                       \
+          : "%0" ((USItype)(m0)),                                      \
+            "g" ((USItype)(m1)))
+#define udiv_qrnnd(q, r, nh, nl, d) \
+  __asm__ ("divx %4,%0,%1"                                              \
+          : "=g" ((USItype)(q)),                                       \
+            "=r" ((USItype)(r))                                        \
+          : "1" ((USItype)(nh)),                                       \
+            "0" ((USItype)(nl)),                                       \
+            "g" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+  __asm__ ("bsch/1 %1,%0"                                               \
+          : "=g" (count)                                               \
+          : "g" ((USItype)(x)),                                        \
+            "0" ((USItype)0))
+#endif
+
+
+/***************************************
+ **************  HPPA  *****************
+ ***************************************/
+#if defined (__hppa) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("   add %4,%5,%1\n"                                             \
+          "    addc %2,%3,%0"                                              \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%rM" ((USItype)(ah)),                                     \
+            "rM" ((USItype)(bh)),                                      \
+            "%rM" ((USItype)(al)),                                     \
+            "rM" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("   sub %4,%5,%1\n"                                             \
+          "    subb %2,%3,%0"                                              \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "rM" ((USItype)(ah)),                                      \
+            "rM" ((USItype)(bh)),                                      \
+            "rM" ((USItype)(al)),                                      \
+            "rM" ((USItype)(bl)))
+#if defined (_PA_RISC1_1)
+#define umul_ppmm(wh, wl, u, v) \
+  do {                                                                 \
+    union {UDItype __ll;                                               \
+          struct {USItype __h, __l;} __i;                              \
+         } __xx;                                                       \
+    __asm__ (" xmpyu %1,%2,%0"                                           \
+            : "=*f" (__xx.__ll)                                        \
+            : "*f" ((USItype)(u)),                                     \
+              "*f" ((USItype)(v)));                                    \
+    (wh) = __xx.__i.__h;                                               \
+    (wl) = __xx.__i.__l;                                               \
+  } while (0)
+#define UMUL_TIME 8
+#define UDIV_TIME 60
+#else
+#define UMUL_TIME 40
+#define UDIV_TIME 80
+#endif
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  do { USItype __r;                                                    \
+    (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                        \
+    (r) = __r;                                                         \
+  } while (0)
+extern USItype __udiv_qrnnd ();
+#endif /* LONGLONG_STANDALONE */
+#define count_leading_zeros(count, x) \
+  do {                                                                \
+    USItype __tmp;                                                    \
+    __asm__ (                                                         \
+       "       ldi             1,%0                                       \n" \
+       "       extru,=         %1,15,16,%%r0  ; Bits 31..16 zero?         \n" \
+       "       extru,tr        %1,15,16,%1    ; No.  Shift down, skip add.\n" \
+       "       ldo             16(%0),%0      ; Yes.   Perform add.       \n" \
+       "       extru,=         %1,23,8,%%r0   ; Bits 15..8 zero?          \n" \
+       "       extru,tr        %1,23,8,%1     ; No.  Shift down, skip add.\n" \
+       "       ldo             8(%0),%0       ; Yes.   Perform add.       \n" \
+       "       extru,=         %1,27,4,%%r0   ; Bits 7..4 zero?           \n" \
+       "       extru,tr        %1,27,4,%1     ; No.  Shift down, skip add.\n" \
+       "       ldo             4(%0),%0       ; Yes.   Perform add.       \n" \
+       "       extru,=         %1,29,2,%%r0   ; Bits 3..2 zero?           \n" \
+       "       extru,tr        %1,29,2,%1     ; No.  Shift down, skip add.\n" \
+       "       ldo             2(%0),%0       ; Yes.   Perform add.       \n" \
+       "       extru           %1,30,1,%1     ; Extract bit 1.            \n" \
+       "       sub             %0,%1,%0       ; Subtract it.              "   \
+       : "=r" (count), "=r" (__tmp) : "1" (x));                        \
+  } while (0)
+#endif /* hppa */
+
+
+/***************************************
+ **************  I370  *****************
+ ***************************************/
+#if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32
+#define umul_ppmm(xh, xl, m0, m1) \
+  do {                                                                 \
+    union {UDItype __ll;                                               \
+          struct {USItype __h, __l;} __i;                              \
+         } __xx;                                                       \
+    USItype __m0 = (m0), __m1 = (m1);                                  \
+    __asm__ ("mr %0,%3"                                                 \
+            : "=r" (__xx.__i.__h),                                     \
+              "=r" (__xx.__i.__l)                                      \
+            : "%1" (__m0),                                             \
+              "r" (__m1));                                             \
+    (xh) = __xx.__i.__h; (xl) = __xx.__i.__l;                          \
+    (xh) += ((((SItype) __m0 >> 31) & __m1)                            \
+            + (((SItype) __m1 >> 31) & __m0));                         \
+  } while (0)
+#define smul_ppmm(xh, xl, m0, m1) \
+  do {                                                                 \
+    union {DItype __ll;                                                \
+          struct {USItype __h, __l;} __i;                              \
+         } __xx;                                                       \
+    __asm__ ("mr %0,%3"                                                 \
+            : "=r" (__xx.__i.__h),                                     \
+              "=r" (__xx.__i.__l)                                      \
+            : "%1" (m0),                                               \
+              "r" (m1));                                               \
+    (xh) = __xx.__i.__h; (xl) = __xx.__i.__l;                          \
+  } while (0)
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+  do {                                                                 \
+    union {DItype __ll;                                                \
+          struct {USItype __h, __l;} __i;                              \
+         } __xx;                                                       \
+    __xx.__i.__h = n1; __xx.__i.__l = n0;                              \
+    __asm__ ("dr %0,%2"                                                 \
+            : "=r" (__xx.__ll)                                         \
+            : "0" (__xx.__ll), "r" (d));                               \
+    (q) = __xx.__i.__l; (r) = __xx.__i.__h;                            \
+  } while (0)
+#endif
+
+
+/***************************************
+ **************  I386  *****************
+ ***************************************/
+#undef __i386__
+#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("addl %5,%1\n"                                               \
+          "adcl %3,%0"                                                 \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%0" ((USItype)(ah)),                                      \
+            "g" ((USItype)(bh)),                                       \
+            "%1" ((USItype)(al)),                                      \
+            "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("subl %5,%1\n"                                               \
+          "sbbl %3,%0"                                                 \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "0" ((USItype)(ah)),                                       \
+            "g" ((USItype)(bh)),                                       \
+            "1" ((USItype)(al)),                                       \
+            "g" ((USItype)(bl)))
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("mull %3"                                                    \
+          : "=a" ((USItype)(w0)),                                      \
+            "=d" ((USItype)(w1))                                       \
+          : "%0" ((USItype)(u)),                                       \
+            "rm" ((USItype)(v)))
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  __asm__ ("divl %4"                                                    \
+          : "=a" ((USItype)(q)),                                       \
+            "=d" ((USItype)(r))                                        \
+          : "0" ((USItype)(n0)),                                       \
+            "1" ((USItype)(n1)),                                       \
+            "rm" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+  do {                                                                 \
+    USItype __cbtmp;                                                   \
+    __asm__ ("bsrl %1,%0"                                               \
+            : "=r" (__cbtmp) : "rm" ((USItype)(x)));                   \
+    (count) = __cbtmp ^ 31;                                            \
+  } while (0)
+#define count_trailing_zeros(count, x) \
+  __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)))
+#ifndef UMUL_TIME
+#define UMUL_TIME 40
+#endif
+#ifndef UDIV_TIME
+#define UDIV_TIME 40
+#endif
+#endif /* 80x86 */
+
+
+/***************************************
+ **************  I860  *****************
+ ***************************************/
+#if defined (__i860__) && W_TYPE_SIZE == 32
+#define rshift_rhlc(r,h,l,c) \
+  __asm__ ("shr %3,r0,r0\n"  \
+           "shrd %1,%2,%0"   \
+          "=r" (r) : "r" (h), "r" (l), "rn" (c))
+#endif /* i860 */
+
+/***************************************
+ **************  I960  *****************
+ ***************************************/
+#if defined (__i960__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("cmpo 1,0\n"      \
+           "addc %5,%4,%1\n" \
+           "addc %3,%2,%0"   \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%dI" ((USItype)(ah)),                                     \
+            "dI" ((USItype)(bh)),                                      \
+            "%dI" ((USItype)(al)),                                     \
+            "dI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("cmpo 0,0\n"      \
+           "subc %5,%4,%1\n" \
+           "subc %3,%2,%0"   \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "dI" ((USItype)(ah)),                                      \
+            "dI" ((USItype)(bh)),                                      \
+            "dI" ((USItype)(al)),                                      \
+            "dI" ((USItype)(bl)))
+#define umul_ppmm(w1, w0, u, v) \
+  ({union {UDItype __ll;                                               \
+          struct {USItype __l, __h;} __i;                              \
+         } __xx;                                                       \
+  __asm__ ("emul        %2,%1,%0"                                       \
+          : "=d" (__xx.__ll)                                           \
+          : "%dI" ((USItype)(u)),                                      \
+            "dI" ((USItype)(v)));                                      \
+  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+  ({UDItype __w;                                                       \
+    __asm__ ("emul      %2,%1,%0"                                       \
+            : "=d" (__w)                                               \
+            : "%dI" ((USItype)(u)),                                    \
+              "dI" ((USItype)(v)));                                    \
+    __w; })
+#define udiv_qrnnd(q, r, nh, nl, d) \
+  do {                                                                 \
+    union {UDItype __ll;                                               \
+          struct {USItype __l, __h;} __i;                              \
+         } __nn;                                                       \
+    __nn.__i.__h = (nh); __nn.__i.__l = (nl);                          \
+    __asm__ ("ediv %d,%n,%0"                                            \
+          : "=d" (__rq.__ll)                                           \
+          : "dI" (__nn.__ll),                                          \
+            "dI" ((USItype)(d)));                                      \
+    (r) = __rq.__i.__l; (q) = __rq.__i.__h;                            \
+  } while (0)
+#define count_leading_zeros(count, x) \
+  do {                                                                 \
+    USItype __cbtmp;                                                   \
+    __asm__ ("scanbit %1,%0"                                            \
+            : "=r" (__cbtmp)                                           \
+            : "r" ((USItype)(x)));                                     \
+    (count) = __cbtmp ^ 31;                                            \
+  } while (0)
+#define COUNT_LEADING_ZEROS_0 (-32) /* sic */
+#if defined (__i960mx)         /* what is the proper symbol to test??? */
+#define rshift_rhlc(r,h,l,c) \
+  do {                                                                 \
+    union {UDItype __ll;                                               \
+          struct {USItype __l, __h;} __i;                              \
+         } __nn;                                                       \
+    __nn.__i.__h = (h); __nn.__i.__l = (l);                            \
+    __asm__ ("shre %2,%1,%0"                                            \
+            : "=d" (r) : "dI" (__nn.__ll), "dI" (c));                  \
+  }
+#endif /* i960mx */
+#endif /* i960 */
+
+
+/***************************************
+ **************  68000 ****************
+ ***************************************/
+#if (defined (__mc68000__) || defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("add%.l %5,%1\n"                                             \
+          "addx%.l %3,%0"                                              \
+          : "=d" ((USItype)(sh)),                                      \
+            "=&d" ((USItype)(sl))                                      \
+          : "%0" ((USItype)(ah)),                                      \
+            "d" ((USItype)(bh)),                                       \
+            "%1" ((USItype)(al)),                                      \
+            "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("sub%.l %5,%1\n"                                             \
+          "subx%.l %3,%0"                                              \
+          : "=d" ((USItype)(sh)),                                      \
+            "=&d" ((USItype)(sl))                                      \
+          : "0" ((USItype)(ah)),                                       \
+            "d" ((USItype)(bh)),                                       \
+            "1" ((USItype)(al)),                                       \
+            "g" ((USItype)(bl)))
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("mulu%.l %3,%1:%0"                                           \
+          : "=d" ((USItype)(w0)),                                      \
+            "=d" ((USItype)(w1))                                       \
+          : "%0" ((USItype)(u)),                                       \
+            "dmi" ((USItype)(v)))
+#define UMUL_TIME 45
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  __asm__ ("divu%.l %4,%1:%0"                                           \
+          : "=d" ((USItype)(q)),                                       \
+            "=d" ((USItype)(r))                                        \
+          : "0" ((USItype)(n0)),                                       \
+            "1" ((USItype)(n1)),                                       \
+            "dmi" ((USItype)(d)))
+#define UDIV_TIME 90
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+  __asm__ ("divs%.l %4,%1:%0"                                           \
+          : "=d" ((USItype)(q)),                                       \
+            "=d" ((USItype)(r))                                        \
+          : "0" ((USItype)(n0)),                                       \
+            "1" ((USItype)(n1)),                                       \
+            "dmi" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+  __asm__ ("bfffo %1{%b2:%b2},%0"                                       \
+          : "=d" ((USItype)(count))                                    \
+          : "od" ((USItype)(x)), "n" (0))
+#define COUNT_LEADING_ZEROS_0 32
+#else /* not mc68020 */
+#define umul_ppmm(xh, xl, a, b) \
+  do { USItype __umul_tmp1, __umul_tmp2;                         \
+       __asm__ ("| Inlined umul_ppmm                         \n" \
+ "        move%.l %5,%3                                       \n" \
+ "        move%.l %2,%0                                       \n" \
+ "        move%.w %3,%1                                       \n" \
+ "        swap %3                                            \n" \
+ "        swap %0                                            \n" \
+ "        mulu %2,%1                                         \n" \
+ "        mulu %3,%0                                         \n" \
+ "        mulu %2,%3                                         \n" \
+ "        swap %2                                            \n" \
+ "        mulu %5,%2                                         \n" \
+ "        add%.l       %3,%2                                 \n" \
+ "        jcc  1f                                            \n" \
+ "        add%.l       %#0x10000,%0                          \n" \
+ "1:   move%.l %2,%3                                         \n" \
+ "        clr%.w       %2                                    \n" \
+ "        swap %2                                            \n" \
+ "        swap %3                                            \n" \
+ "        clr%.w       %3                                    \n" \
+ "        add%.l       %3,%1                                 \n" \
+ "        addx%.l %2,%0                                       \n" \
+ "        | End inlined umul_ppmm"                                \
+             : "=&d" ((USItype)(xh)), "=&d" ((USItype)(xl)),     \
+               "=d" (__umul_tmp1), "=&d" (__umul_tmp2)           \
+             : "%2" ((USItype)(a)), "d" ((USItype)(b)));         \
+  } while (0)
+#define UMUL_TIME 100
+#define UDIV_TIME 400
+#endif /* not mc68020 */
+#endif /* mc68000 */
+
+
+/***************************************
+ **************  88000 ****************
+ ***************************************/
+#if defined (__m88000__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("addu.co %1,%r4,%r5\n"                                       \
+          "addu.ci %0,%r2,%r3"                                         \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%rJ" ((USItype)(ah)),                                     \
+            "rJ" ((USItype)(bh)),                                      \
+            "%rJ" ((USItype)(al)),                                     \
+            "rJ" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("subu.co %1,%r4,%r5\n"                                       \
+          "subu.ci %0,%r2,%r3"                                         \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "rJ" ((USItype)(ah)),                                      \
+            "rJ" ((USItype)(bh)),                                      \
+            "rJ" ((USItype)(al)),                                      \
+            "rJ" ((USItype)(bl)))
+#define count_leading_zeros(count, x) \
+  do {                                                                 \
+    USItype __cbtmp;                                                   \
+    __asm__ ("ff1 %0,%1"                                                \
+            : "=r" (__cbtmp)                                           \
+            : "r" ((USItype)(x)));                                     \
+    (count) = __cbtmp ^ 31;                                            \
+  } while (0)
+#define COUNT_LEADING_ZEROS_0 63 /* sic */
+#if defined (__m88110__)
+#define umul_ppmm(wh, wl, u, v) \
+  do {                                                                 \
+    union {UDItype __ll;                                               \
+          struct {USItype __h, __l;} __i;                              \
+         } __x;                                                        \
+    __asm__ ("mulu.d %0,%1,%2" : "=r" (__x.__ll) : "r" (u), "r" (v));   \
+    (wh) = __x.__i.__h;                                                \
+    (wl) = __x.__i.__l;                                                \
+  } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  ({union {UDItype __ll;                                               \
+          struct {USItype __h, __l;} __i;                              \
+         } __x, __q;                                                   \
+  __x.__i.__h = (n1); __x.__i.__l = (n0);                              \
+  __asm__ ("divu.d %0,%1,%2"                                            \
+          : "=r" (__q.__ll) : "r" (__x.__ll), "r" (d));                \
+  (r) = (n0) - __q.__l * (d); (q) = __q.__l; })
+#define UMUL_TIME 5
+#define UDIV_TIME 25
+#else
+#define UMUL_TIME 17
+#define UDIV_TIME 150
+#endif /* __m88110__ */
+#endif /* __m88000__ */
+
+/***************************************
+ **************  MIPS  *****************
+ ***************************************/
+#if defined (__mips__) && W_TYPE_SIZE == 32
+#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("multu %2,%3"                                                \
+          : "=l" ((USItype)(w0)),                                      \
+            "=h" ((USItype)(w1))                                       \
+          : "d" ((USItype)(u)),                                        \
+            "d" ((USItype)(v)))
+#else
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("multu %2,%3 \n" \
+          "mflo %0 \n"     \
+          "mfhi %1"                                                        \
+          : "=d" ((USItype)(w0)),                                      \
+            "=d" ((USItype)(w1))                                       \
+          : "d" ((USItype)(u)),                                        \
+            "d" ((USItype)(v)))
+#endif
+#define UMUL_TIME 10
+#define UDIV_TIME 100
+#endif /* __mips__ */
+
+/***************************************
+ **************  MIPS/64  **************
+ ***************************************/
+#if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
+#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("dmultu %2,%3"                                               \
+          : "=l" ((UDItype)(w0)),                                      \
+            "=h" ((UDItype)(w1))                                       \
+          : "d" ((UDItype)(u)),                                        \
+            "d" ((UDItype)(v)))
+#else
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("dmultu %2,%3 \n"    \
+          "mflo %0 \n"         \
+          "mfhi %1"                                                        \
+          : "=d" ((UDItype)(w0)),                                      \
+            "=d" ((UDItype)(w1))                                       \
+          : "d" ((UDItype)(u)),                                        \
+            "d" ((UDItype)(v)))
+#endif
+#define UMUL_TIME 20
+#define UDIV_TIME 140
+#endif /* __mips__ */
+
+
+/***************************************
+ **************  32000 ****************
+ ***************************************/
+#if defined (__ns32000__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+  ({union {UDItype __ll;                                               \
+          struct {USItype __l, __h;} __i;                              \
+         } __xx;                                                       \
+  __asm__ ("meid %2,%0"                                                 \
+          : "=g" (__xx.__ll)                                           \
+          : "%0" ((USItype)(u)),                                       \
+            "g" ((USItype)(v)));                                       \
+  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+  ({UDItype __w;                                                       \
+    __asm__ ("meid %2,%0"                                               \
+            : "=g" (__w)                                               \
+            : "%0" ((USItype)(u)),                                     \
+              "g" ((USItype)(v)));                                     \
+    __w; })
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  ({union {UDItype __ll;                                               \
+          struct {USItype __l, __h;} __i;                              \
+         } __xx;                                                       \
+  __xx.__i.__h = (n1); __xx.__i.__l = (n0);                            \
+  __asm__ ("deid %2,%0"                                                 \
+          : "=g" (__xx.__ll)                                           \
+          : "0" (__xx.__ll),                                           \
+            "g" ((USItype)(d)));                                       \
+  (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
+#define count_trailing_zeros(count,x) \
+  do {
+    __asm__ ("ffsd      %2,%0"                                          \
+            : "=r" ((USItype) (count))                                 \
+            : "0" ((USItype) 0),                                       \
+              "r" ((USItype) (x)));                                    \
+  } while (0)
+#endif /* __ns32000__ */
+
+
+/***************************************
+ **************  PPC  ******************
+ ***************************************/
+#if (defined (_ARCH_PPC) || defined (_IBMR2)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  do {                                                                 \
+    if (__builtin_constant_p (bh) && (bh) == 0)                        \
+      __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2"           \
+            : "=r" ((USItype)(sh)),                                    \
+              "=&r" ((USItype)(sl))                                    \
+            : "%r" ((USItype)(ah)),                                    \
+              "%r" ((USItype)(al)),                                    \
+              "rI" ((USItype)(bl)));                                   \
+    else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0)         \
+      __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2"           \
+            : "=r" ((USItype)(sh)),                                    \
+              "=&r" ((USItype)(sl))                                    \
+            : "%r" ((USItype)(ah)),                                    \
+              "%r" ((USItype)(al)),                                    \
+              "rI" ((USItype)(bl)));                                   \
+    else                                                               \
+      __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3"          \
+            : "=r" ((USItype)(sh)),                                    \
+              "=&r" ((USItype)(sl))                                    \
+            : "%r" ((USItype)(ah)),                                    \
+              "r" ((USItype)(bh)),                                     \
+              "%r" ((USItype)(al)),                                    \
+              "rI" ((USItype)(bl)));                                   \
+  } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  do {                                                                 \
+    if (__builtin_constant_p (ah) && (ah) == 0)                        \
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2"       \
+              : "=r" ((USItype)(sh)),                                  \
+                "=&r" ((USItype)(sl))                                  \
+              : "r" ((USItype)(bh)),                                   \
+                "rI" ((USItype)(al)),                                  \
+                "r" ((USItype)(bl)));                                  \
+    else if (__builtin_constant_p (ah) && (ah) ==~(USItype) 0)         \
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2"       \
+              : "=r" ((USItype)(sh)),                                  \
+                "=&r" ((USItype)(sl))                                  \
+              : "r" ((USItype)(bh)),                                   \
+                "rI" ((USItype)(al)),                                  \
+                "r" ((USItype)(bl)));                                  \
+    else if (__builtin_constant_p (bh) && (bh) == 0)                   \
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2"         \
+              : "=r" ((USItype)(sh)),                                  \
+                "=&r" ((USItype)(sl))                                  \
+              : "r" ((USItype)(ah)),                                   \
+                "rI" ((USItype)(al)),                                  \
+                "r" ((USItype)(bl)));                                  \
+    else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0)         \
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2"         \
+              : "=r" ((USItype)(sh)),                                  \
+                "=&r" ((USItype)(sl))                                  \
+              : "r" ((USItype)(ah)),                                   \
+                "rI" ((USItype)(al)),                                  \
+                "r" ((USItype)(bl)));                                  \
+    else                                                               \
+      __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2"      \
+              : "=r" ((USItype)(sh)),                                  \
+                "=&r" ((USItype)(sl))                                  \
+              : "r" ((USItype)(ah)),                                   \
+                "r" ((USItype)(bh)),                                   \
+                "rI" ((USItype)(al)),                                  \
+                "r" ((USItype)(bl)));                                  \
+  } while (0)
+#define count_leading_zeros(count, x) \
+  __asm__ ("{cntlz|cntlzw} %0,%1"                                       \
+          : "=r" ((USItype)(count))                                    \
+          : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
+#if defined (_ARCH_PPC)
+#define umul_ppmm(ph, pl, m0, m1) \
+  do {                                                                 \
+    USItype __m0 = (m0), __m1 = (m1);                                  \
+    __asm__ ("mulhwu %0,%1,%2"                                          \
+            : "=r" ((USItype) ph)                                      \
+            : "%r" (__m0),                                             \
+              "r" (__m1));                                             \
+    (pl) = __m0 * __m1;                                                \
+  } while (0)
+#define UMUL_TIME 15
+#define smul_ppmm(ph, pl, m0, m1) \
+  do {                                                                 \
+    SItype __m0 = (m0), __m1 = (m1);                                   \
+    __asm__ ("mulhw %0,%1,%2"                                           \
+            : "=r" ((SItype) ph)                                       \
+            : "%r" (__m0),                                             \
+              "r" (__m1));                                             \
+    (pl) = __m0 * __m1;                                                \
+  } while (0)
+#define SMUL_TIME 14
+#define UDIV_TIME 120
+#else
+#define umul_ppmm(xh, xl, m0, m1) \
+  do {                                                                 \
+    USItype __m0 = (m0), __m1 = (m1);                                  \
+    __asm__ ("mul %0,%2,%3"                                             \
+            : "=r" ((USItype)(xh)),                                    \
+              "=q" ((USItype)(xl))                                     \
+            : "r" (__m0),                                              \
+              "r" (__m1));                                             \
+    (xh) += ((((SItype) __m0 >> 31) & __m1)                            \
+            + (((SItype) __m1 >> 31) & __m0));                         \
+  } while (0)
+#define UMUL_TIME 8
+#define smul_ppmm(xh, xl, m0, m1) \
+  __asm__ ("mul %0,%2,%3"                                               \
+          : "=r" ((SItype)(xh)),                                       \
+            "=q" ((SItype)(xl))                                        \
+          : "r" (m0),                                                  \
+            "r" (m1))
+#define SMUL_TIME 4
+#define sdiv_qrnnd(q, r, nh, nl, d) \
+  __asm__ ("div %0,%2,%4"                                               \
+          : "=r" ((SItype)(q)), "=q" ((SItype)(r))                     \
+          : "r" ((SItype)(nh)), "1" ((SItype)(nl)), "r" ((SItype)(d)))
+#define UDIV_TIME 100
+#endif
+#endif /* Power architecture variants. */
+
+
+/***************************************
+ **************  PYR  ******************
+ ***************************************/
+#if defined (__pyr__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("addw        %5,%1 \n" \
+          "addwc       %3,%0"                                          \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%0" ((USItype)(ah)),                                      \
+            "g" ((USItype)(bh)),                                       \
+            "%1" ((USItype)(al)),                                      \
+            "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("subw        %5,%1 \n" \
+          "subwb       %3,%0"                                          \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "0" ((USItype)(ah)),                                       \
+            "g" ((USItype)(bh)),                                       \
+            "1" ((USItype)(al)),                                       \
+            "g" ((USItype)(bl)))
+/* This insn works on Pyramids with AP, XP, or MI CPUs, but not with SP.  */
+#define umul_ppmm(w1, w0, u, v) \
+  ({union {UDItype __ll;                                               \
+          struct {USItype __h, __l;} __i;                              \
+         } __xx;                                                       \
+  __asm__ ("movw %1,%R0 \n" \
+          "uemul %2,%0"                                                \
+          : "=&r" (__xx.__ll)                                          \
+          : "g" ((USItype) (u)),                                       \
+            "g" ((USItype)(v)));                                       \
+  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#endif /* __pyr__ */
+
+
+/***************************************
+ **************  RT/ROMP  **************
+ ***************************************/
+#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("a %1,%5 \n" \
+          "ae %0,%3"                                                   \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%0" ((USItype)(ah)),                                      \
+            "r" ((USItype)(bh)),                                       \
+            "%1" ((USItype)(al)),                                      \
+            "r" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("s %1,%5\n" \
+          "se %0,%3"                                                   \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "0" ((USItype)(ah)),                                       \
+            "r" ((USItype)(bh)),                                       \
+            "1" ((USItype)(al)),                                       \
+            "r" ((USItype)(bl)))
+#define umul_ppmm(ph, pl, m0, m1) \
+  do {                                                                 \
+    USItype __m0 = (m0), __m1 = (m1);                                  \
+    __asm__ (                                                          \
+       "s       r2,r2    \n" \
+       "mts    r10,%2   \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "m      r2,%3    \n" \
+       "cas    %0,r2,r0 \n" \
+       "mfs    r10,%1"                                                 \
+            : "=r" ((USItype)(ph)),                                    \
+              "=r" ((USItype)(pl))                                     \
+            : "%r" (__m0),                                             \
+               "r" (__m1)                                              \
+            : "r2");                                                   \
+    (ph) += ((((SItype) __m0 >> 31) & __m1)                            \
+            + (((SItype) __m1 >> 31) & __m0));                         \
+  } while (0)
+#define UMUL_TIME 20
+#define UDIV_TIME 200
+#define count_leading_zeros(count, x) \
+  do {                                                                 \
+    if ((x) >= 0x10000)                                                \
+      __asm__ ("clz     %0,%1"                                          \
+              : "=r" ((USItype)(count))                                \
+              : "r" ((USItype)(x) >> 16));                             \
+    else                                                               \
+      {                                                                \
+       __asm__ ("clz   %0,%1"                                          \
+                : "=r" ((USItype)(count))                              \
+                : "r" ((USItype)(x)));                                 \
+       (count) += 16;                                                  \
+      }                                                                \
+  } while (0)
+#endif /* RT/ROMP */
+
+
+/***************************************
+ **************  SH2  ******************
+ ***************************************/
+#if (defined (__sh2__) || defined(__sh3__) || defined(__SH4__) ) \
+    && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ (                                                            \
+        "dmulu.l %2,%3\n"  \
+       "sts    macl,%1\n" \
+       "sts    mach,%0"                                                \
+          : "=r" ((USItype)(w1)),                                      \
+            "=r" ((USItype)(w0))                                       \
+          : "r" ((USItype)(u)),                                        \
+            "r" ((USItype)(v))                                         \
+          : "macl", "mach")
+#define UMUL_TIME 5
+#endif
+
+/***************************************
+ **************  SPARC ****************
+ ***************************************/
+#if defined (__sparc__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("addcc %r4,%5,%1\n" \
+          "addx %r2,%3,%0"                                             \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "%rJ" ((USItype)(ah)),                                     \
+            "rI" ((USItype)(bh)),                                      \
+            "%rJ" ((USItype)(al)),                                     \
+            "rI" ((USItype)(bl))                                       \
+          __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("subcc %r4,%5,%1\n" \
+          "subx %r2,%3,%0"                                             \
+          : "=r" ((USItype)(sh)),                                      \
+            "=&r" ((USItype)(sl))                                      \
+          : "rJ" ((USItype)(ah)),                                      \
+            "rI" ((USItype)(bh)),                                      \
+            "rJ" ((USItype)(al)),                                      \
+            "rI" ((USItype)(bl))                                       \
+          __CLOBBER_CC)
+#if defined (__sparc_v8__)
+/* Don't match immediate range because, 1) it is not often useful,
+   2) the 'I' flag thinks of the range as a 13 bit signed interval,
+   while we want to match a 13 bit interval, sign extended to 32 bits,
+   but INTERPRETED AS UNSIGNED.  */
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("umul %2,%3,%1;rd %%y,%0"                                    \
+          : "=r" ((USItype)(w1)),                                      \
+            "=r" ((USItype)(w0))                                       \
+          : "r" ((USItype)(u)),                                        \
+            "r" ((USItype)(v)))
+#define UMUL_TIME 5
+#ifndef SUPERSPARC     /* SuperSPARC's udiv only handles 53 bit dividends */
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  do {                                                                 \
+    USItype __q;                                                       \
+    __asm__ ("mov %1,%%y;nop;nop;nop;udiv %2,%3,%0"                     \
+            : "=r" ((USItype)(__q))                                    \
+            : "r" ((USItype)(n1)),                                     \
+              "r" ((USItype)(n0)),                                     \
+              "r" ((USItype)(d)));                                     \
+    (r) = (n0) - __q * (d);                                            \
+    (q) = __q;                                                         \
+  } while (0)
+#define UDIV_TIME 25
+#endif /* SUPERSPARC */
+#else /* ! __sparc_v8__ */
+#if defined (__sparclite__)
+/* This has hardware multiply but not divide.  It also has two additional
+   instructions scan (ffs from high bit) and divscc.  */
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("umul %2,%3,%1;rd %%y,%0"                                    \
+          : "=r" ((USItype)(w1)),                                      \
+            "=r" ((USItype)(w0))                                       \
+          : "r" ((USItype)(u)),                                        \
+            "r" ((USItype)(v)))
+#define UMUL_TIME 5
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  __asm__ ("! Inlined udiv_qrnnd                                     \n" \
+ "        wr   %%g0,%2,%%y     ! Not a delayed write for sparclite  \n" \
+ "        tst  %%g0                                                 \n" \
+ "        divscc       %3,%4,%%g1                                   \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%%g1                                 \n" \
+ "        divscc       %%g1,%4,%0                                   \n" \
+ "        rd   %%y,%1                                               \n" \
+ "        bl,a 1f                                                    \n" \
+ "        add  %1,%4,%1                                             \n" \
+ "1:   ! End of inline udiv_qrnnd"                                     \
+          : "=r" ((USItype)(q)),                                       \
+            "=r" ((USItype)(r))                                        \
+          : "r" ((USItype)(n1)),                                       \
+            "r" ((USItype)(n0)),                                       \
+            "rI" ((USItype)(d))                                        \
+          : "%g1" __AND_CLOBBER_CC)
+#define UDIV_TIME 37
+#define count_leading_zeros(count, x) \
+  __asm__ ("scan %1,0,%0"                                               \
+          : "=r" ((USItype)(x))                                        \
+          : "r" ((USItype)(count)))
+/* Early sparclites return 63 for an argument of 0, but they warn that future
+   implementations might change this.  Therefore, leave COUNT_LEADING_ZEROS_0
+   undefined.  */
+#endif /* __sparclite__ */
+#endif /* __sparc_v8__ */
+/* Default to sparc v7 versions of umul_ppmm and udiv_qrnnd.  */
+#ifndef umul_ppmm
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("! Inlined umul_ppmm                                        \n" \
+ "        wr   %%g0,%2,%%y     ! SPARC has 0-3 delay insn after a wr  \n" \
+ "        sra  %3,31,%%g2      ! Don't move this insn                 \n" \
+ "        and  %2,%%g2,%%g2    ! Don't move this insn                 \n" \
+ "        andcc        %%g0,0,%%g1     ! Don't move this insn                 \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,%3,%%g1                                   \n" \
+ "        mulscc       %%g1,0,%%g1                                    \n" \
+ "        add  %%g1,%%g2,%0                                           \n" \
+ "        rd   %%y,%1"                                                 \
+          : "=r" ((USItype)(w1)),                                      \
+            "=r" ((USItype)(w0))                                       \
+          : "%rI" ((USItype)(u)),                                      \
+            "r" ((USItype)(v))                                         \
+          : "%g1", "%g2" __AND_CLOBBER_CC)
+#define UMUL_TIME 39           /* 39 instructions */
+#endif
+#ifndef udiv_qrnnd
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+  do { USItype __r;                                                    \
+    (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                        \
+    (r) = __r;                                                         \
+  } while (0)
+extern USItype __udiv_qrnnd ();
+#define UDIV_TIME 140
+#endif /* LONGLONG_STANDALONE */
+#endif /* udiv_qrnnd */
+#endif /* __sparc__ */
+
+
+/***************************************
+ **************  VAX  ******************
+ ***************************************/
+#if defined (__vax__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("addl2 %5,%1\n" \
+          "adwc %3,%0"                                                 \
+          : "=g" ((USItype)(sh)),                                      \
+            "=&g" ((USItype)(sl))                                      \
+          : "%0" ((USItype)(ah)),                                      \
+            "g" ((USItype)(bh)),                                       \
+            "%1" ((USItype)(al)),                                      \
+            "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("subl2 %5,%1\n" \
+          "sbwc %3,%0"                                                 \
+          : "=g" ((USItype)(sh)),                                      \
+            "=&g" ((USItype)(sl))                                      \
+          : "0" ((USItype)(ah)),                                       \
+            "g" ((USItype)(bh)),                                       \
+            "1" ((USItype)(al)),                                       \
+            "g" ((USItype)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+  do {                                                                 \
+    union {UDItype __ll;                                               \
+          struct {USItype __l, __h;} __i;                              \
+         } __xx;                                                       \
+    USItype __m0 = (m0), __m1 = (m1);                                  \
+    __asm__ ("emul %1,%2,$0,%0"                                         \
+            : "=g" (__xx.__ll)                                         \
+            : "g" (__m0),                                              \
+              "g" (__m1));                                             \
+    (xh) = __xx.__i.__h; (xl) = __xx.__i.__l;                          \
+    (xh) += ((((SItype) __m0 >> 31) & __m1)                            \
+            + (((SItype) __m1 >> 31) & __m0));                         \
+  } while (0)
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+  do {                                                                 \
+    union {DItype __ll;                                                \
+          struct {SItype __l, __h;} __i;                               \
+         } __xx;                                                       \
+    __xx.__i.__h = n1; __xx.__i.__l = n0;                              \
+    __asm__ ("ediv %3,%2,%0,%1"                                         \
+            : "=g" (q), "=g" (r)                                       \
+            : "g" (__xx.__ll), "g" (d));                               \
+  } while (0)
+#endif /* __vax__ */
+
+
+/***************************************
+ **************  Z8000 ****************
+ ***************************************/
+#if defined (__z8000__) && W_TYPE_SIZE == 16
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("add %H1,%H5\n\tadc  %H0,%H3"                                \
+          : "=r" ((unsigned int)(sh)),                                 \
+            "=&r" ((unsigned int)(sl))                                 \
+          : "%0" ((unsigned int)(ah)),                                 \
+            "r" ((unsigned int)(bh)),                                  \
+            "%1" ((unsigned int)(al)),                                 \
+            "rQR" ((unsigned int)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("sub %H1,%H5\n\tsbc  %H0,%H3"                                \
+          : "=r" ((unsigned int)(sh)),                                 \
+            "=&r" ((unsigned int)(sl))                                 \
+          : "0" ((unsigned int)(ah)),                                  \
+            "r" ((unsigned int)(bh)),                                  \
+            "1" ((unsigned int)(al)),                                  \
+            "rQR" ((unsigned int)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+  do {                                                                 \
+    union {long int __ll;                                              \
+          struct {unsigned int __h, __l;} __i;                         \
+         } __xx;                                                       \
+    unsigned int __m0 = (m0), __m1 = (m1);                             \
+    __asm__ ("mult      %S0,%H3"                                        \
+            : "=r" (__xx.__i.__h),                                     \
+              "=r" (__xx.__i.__l)                                      \
+            : "%1" (__m0),                                             \
+              "rQR" (__m1));                                           \
+    (xh) = __xx.__i.__h; (xl) = __xx.__i.__l;                          \
+    (xh) += ((((signed int) __m0 >> 15) & __m1)                        \
+            + (((signed int) __m1 >> 15) & __m0));                     \
+  } while (0)
+#endif /* __z8000__ */
+
+#endif /* __GNUC__ */
+
+
+/***************************************
+ ***********  Generic Versions ********
+ ***************************************/
+#if !defined (umul_ppmm) && defined (__umulsidi3)
+#define umul_ppmm(ph, pl, m0, m1) \
+  {                                                                    \
+    UDWtype __ll = __umulsidi3 (m0, m1);                               \
+    ph = (UWtype) (__ll >> W_TYPE_SIZE);                               \
+    pl = (UWtype) __ll;                                                \
+  }
+#endif
+
+#if !defined (__umulsidi3)
+#define __umulsidi3(u, v) \
+  ({UWtype __hi, __lo;                                                 \
+    umul_ppmm (__hi, __lo, u, v);                                      \
+    ((UDWtype) __hi << W_TYPE_SIZE) | __lo; })
+#endif
+
+/* If this machine has no inline assembler, use C macros.  */
+
+#if !defined (add_ssaaaa)
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  do {                                                                 \
+    UWtype __x;                                                        \
+    __x = (al) + (bl);                                                 \
+    (sh) = (ah) + (bh) + (__x < (al));                                 \
+    (sl) = __x;                                                        \
+  } while (0)
+#endif
+
+#if !defined (sub_ddmmss)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  do {                                                                 \
+    UWtype __x;                                                        \
+    __x = (al) - (bl);                                                 \
+    (sh) = (ah) - (bh) - (__x > (al));                                 \
+    (sl) = __x;                                                        \
+  } while (0)
+#endif
+
+#if !defined (umul_ppmm)
+#define umul_ppmm(w1, w0, u, v)                                        \
+  do {                                                                 \
+    UWtype __x0, __x1, __x2, __x3;                                     \
+    UHWtype __ul, __vl, __uh, __vh;                                    \
+    UWtype __u = (u), __v = (v);                                       \
+                                                                       \
+    __ul = __ll_lowpart (__u);                                         \
+    __uh = __ll_highpart (__u);                                        \
+    __vl = __ll_lowpart (__v);                                         \
+    __vh = __ll_highpart (__v);                                        \
+                                                                       \
+    __x0 = (UWtype) __ul * __vl;                                       \
+    __x1 = (UWtype) __ul * __vh;                                       \
+    __x2 = (UWtype) __uh * __vl;                                       \
+    __x3 = (UWtype) __uh * __vh;                                       \
+                                                                       \
+    __x1 += __ll_highpart (__x0);/* this can't give carry */            \
+    __x1 += __x2;              /* but this indeed can */               \
+    if (__x1 < __x2)           /* did we get it? */                    \
+      __x3 += __ll_B;          /* yes, add it in the proper pos. */    \
+                                                                       \
+    (w1) = __x3 + __ll_highpart (__x1);                                \
+    (w0) = (__ll_lowpart (__x1) << W_TYPE_SIZE/2) + __ll_lowpart (__x0);\
+  } while (0)
+#endif
+
+#if !defined (umul_ppmm)
+#define smul_ppmm(w1, w0, u, v)                                        \
+  do {                                                                 \
+    UWtype __w1;                                                       \
+    UWtype __m0 = (u), __m1 = (v);                                     \
+    umul_ppmm (__w1, w0, __m0, __m1);                                  \
+    (w1) = __w1 - (-(__m0 >> (W_TYPE_SIZE - 1)) & __m1)                \
+               - (-(__m1 >> (W_TYPE_SIZE - 1)) & __m0);                \
+  } while (0)
+#endif
+
+/* Define this unconditionally, so it can be used for debugging.  */
+#define __udiv_qrnnd_c(q, r, n1, n0, d) \
+  do {                                                                 \
+    UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m;                    \
+    __d1 = __ll_highpart (d);                                          \
+    __d0 = __ll_lowpart (d);                                           \
+                                                                       \
+    __r1 = (n1) % __d1;                                                \
+    __q1 = (n1) / __d1;                                                \
+    __m = (UWtype) __q1 * __d0;                                        \
+    __r1 = __r1 * __ll_B | __ll_highpart (n0);                         \
+    if (__r1 < __m)                                                    \
+      {                                                                \
+       __q1--, __r1 += (d);                                            \
+       if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
+         if (__r1 < __m)                                               \
+           __q1--, __r1 += (d);                                        \
+      }                                                                \
+    __r1 -= __m;                                                       \
+                                                                       \
+    __r0 = __r1 % __d1;                                                \
+    __q0 = __r1 / __d1;                                                \
+    __m = (UWtype) __q0 * __d0;                                        \
+    __r0 = __r0 * __ll_B | __ll_lowpart (n0);                          \
+    if (__r0 < __m)                                                    \
+      {                                                                \
+       __q0--, __r0 += (d);                                            \
+       if (__r0 >= (d))                                                \
+         if (__r0 < __m)                                               \
+           __q0--, __r0 += (d);                                        \
+      }                                                                \
+    __r0 -= __m;                                                       \
+                                                                       \
+    (q) = (UWtype) __q1 * __ll_B | __q0;                               \
+    (r) = __r0;                                                        \
+  } while (0)
+
+/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
+   __udiv_w_sdiv (defined in libgcc or elsewhere).  */
+#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
+#define udiv_qrnnd(q, r, nh, nl, d) \
+  do {                                                                 \
+    UWtype __r;                                                        \
+    (q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d);                        \
+    (r) = __r;                                                         \
+  } while (0)
+#endif
+
+/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c.  */
+#if !defined (udiv_qrnnd)
+#define UDIV_NEEDS_NORMALIZATION 1
+#define udiv_qrnnd __udiv_qrnnd_c
+#endif
+
+#undef count_leading_zeros
+#if !defined (count_leading_zeros)
+extern
+#ifdef __STDC__
+const
+#endif
+unsigned char __clz_tab[];
+#define count_leading_zeros(count, x) \
+  do {                                                                 \
+    UWtype __xr = (x);                                                 \
+    UWtype __a;                                                        \
+                                                                       \
+    if (W_TYPE_SIZE <= 32)                                             \
+      {                                                                \
+       __a = __xr < ((UWtype) 1 << 2*__BITS4)                          \
+         ? (__xr < ((UWtype) 1 << __BITS4) ? 0 : __BITS4)              \
+         : (__xr < ((UWtype) 1 << 3*__BITS4) ?  2*__BITS4 : 3*__BITS4);\
+      }                                                                \
+    else                                                               \
+      {                                                                \
+       for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8)                  \
+         if (((__xr >> __a) & 0xff) != 0)                              \
+           break;                                                      \
+      }                                                                \
+                                                                       \
+    (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a);            \
+  } while (0)
+/* This version gives a well-defined value for zero. */
+#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
+#endif
+
+#if !defined (count_trailing_zeros)
+/* Define count_trailing_zeros using count_leading_zeros.  The latter might be
+   defined in asm, but if it is not, the C version above is good enough.  */
+#define count_trailing_zeros(count, x) \
+  do {                                                                 \
+    UWtype __ctz_x = (x);                                              \
+    UWtype __ctz_c;                                                    \
+    count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x);                 \
+    (count) = W_TYPE_SIZE - 1 - __ctz_c;                               \
+  } while (0)
+#endif
+
+#ifndef UDIV_NEEDS_NORMALIZATION
+#define UDIV_NEEDS_NORMALIZATION 0
+#endif
diff --git a/crypto/mpi/mpi-add.c b/crypto/mpi/mpi-add.c
new file mode 100644 (file)
index 0000000..2004206
--- /dev/null
@@ -0,0 +1,258 @@
+/* mpi-add.c  -  MPI functions
+ *     Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *     Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+
+/****************
+ * Add the unsigned integer V to the mpi-integer U and store the
+ * result in W. U and V may be the same.
+ */
+int
+mpi_add_ui(MPI w, const MPI u, unsigned long v )
+{
+    mpi_ptr_t wp, up;
+    mpi_size_t usize, wsize;
+    int usign, wsign;
+
+    usize = u->nlimbs;
+    usign = u->sign;
+    wsign = 0;
+
+    /* If not space for W (and possible carry), increase space.  */
+    wsize = usize + 1;
+    if( w->alloced < wsize )
+           if (mpi_resize(w, wsize) < 0)
+                   return -ENOMEM;
+
+    /* These must be after realloc (U may be the same as W).  */
+    up = u->d;
+    wp = w->d;
+
+    if( !usize ) {  /* simple */
+       wp[0] = v;
+       wsize = v? 1:0;
+    }
+    else if( !usign ) {  /* mpi is not negative */
+       mpi_limb_t cy;
+       cy = mpihelp_add_1(wp, up, usize, v);
+       wp[usize] = cy;
+       wsize = usize + cy;
+    }
+    else {  /* The signs are different.  Need exact comparison to determine
+            * which operand to subtract from which.  */
+       if( usize == 1 && up[0] < v ) {
+           wp[0] = v - up[0];
+           wsize = 1;
+       }
+       else {
+           mpihelp_sub_1(wp, up, usize, v);
+           /* Size can decrease with at most one limb. */
+           wsize = usize - (wp[usize-1]==0);
+           wsign = 1;
+       }
+    }
+
+    w->nlimbs = wsize;
+    w->sign   = wsign;
+    return 0;
+}
+
+
+int
+mpi_add(MPI w, MPI u, MPI v)
+{
+    mpi_ptr_t wp, up, vp;
+    mpi_size_t usize, vsize, wsize;
+    int usign, vsign, wsign;
+
+    if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
+       usize = v->nlimbs;
+       usign = v->sign;
+       vsize = u->nlimbs;
+       vsign = u->sign;
+       wsize = usize + 1;
+       if (RESIZE_IF_NEEDED(w, wsize) < 0)
+               return -ENOMEM;
+       /* These must be after realloc (u or v may be the same as w).  */
+       up    = v->d;
+       vp    = u->d;
+    }
+    else {
+       usize = u->nlimbs;
+       usign = u->sign;
+       vsize = v->nlimbs;
+       vsign = v->sign;
+       wsize = usize + 1;
+       if (RESIZE_IF_NEEDED(w, wsize) < 0)
+               return -ENOMEM;
+       /* These must be after realloc (u or v may be the same as w).  */
+       up    = u->d;
+       vp    = v->d;
+    }
+    wp = w->d;
+    wsign = 0;
+
+    if( !vsize ) {  /* simple */
+        MPN_COPY(wp, up, usize );
+       wsize = usize;
+       wsign = usign;
+    }
+    else if( usign != vsign ) { /* different sign */
+       /* This test is right since USIZE >= VSIZE */
+       if( usize != vsize ) {
+           mpihelp_sub(wp, up, usize, vp, vsize);
+           wsize = usize;
+           MPN_NORMALIZE(wp, wsize);
+           wsign = usign;
+       }
+       else if( mpihelp_cmp(up, vp, usize) < 0 ) {
+           mpihelp_sub_n(wp, vp, up, usize);
+           wsize = usize;
+           MPN_NORMALIZE(wp, wsize);
+           if( !usign )
+               wsign = 1;
+       }
+       else {
+           mpihelp_sub_n(wp, up, vp, usize);
+           wsize = usize;
+           MPN_NORMALIZE(wp, wsize);
+           if( usign )
+               wsign = 1;
+       }
+    }
+    else { /* U and V have same sign. Add them. */
+       mpi_limb_t cy = mpihelp_add(wp, up, usize, vp, vsize);
+       wp[usize] = cy;
+       wsize = usize + cy;
+       if( usign )
+           wsign = 1;
+    }
+
+    w->nlimbs = wsize;
+    w->sign = wsign;
+    return 0;
+}
+
+
+/****************
+ * Subtract the unsigned integer V from the mpi-integer U and store the
+ * result in W.
+ */
+int
+mpi_sub_ui(MPI w, MPI u, unsigned long v )
+{
+    mpi_ptr_t wp, up;
+    mpi_size_t usize, wsize;
+    int usign, wsign;
+
+    usize = u->nlimbs;
+    usign = u->sign;
+    wsign = 0;
+
+    /* If not space for W (and possible carry), increase space.  */
+    wsize = usize + 1;
+    if( w->alloced < wsize )
+           if (mpi_resize(w, wsize) < 0)
+                   return -ENOMEM;
+
+    /* These must be after realloc (U may be the same as W).  */
+    up = u->d;
+    wp = w->d;
+
+    if( !usize ) {  /* simple */
+       wp[0] = v;
+       wsize = v? 1:0;
+       wsign = 1;
+    }
+    else if( usign ) { /* mpi and v are negative */
+       mpi_limb_t cy;
+       cy = mpihelp_add_1(wp, up, usize, v);
+       wp[usize] = cy;
+       wsize = usize + cy;
+    }
+    else {  /* The signs are different.  Need exact comparison to determine
+            * which operand to subtract from which.  */
+       if( usize == 1 && up[0] < v ) {
+           wp[0] = v - up[0];
+           wsize = 1;
+           wsign = 1;
+       }
+       else {
+           mpihelp_sub_1(wp, up, usize, v);
+           /* Size can decrease with at most one limb. */
+           wsize = usize - (wp[usize-1]==0);
+       }
+    }
+
+    w->nlimbs = wsize;
+    w->sign   = wsign;
+    return 0;
+}
+
+int
+mpi_sub(MPI w, MPI u, MPI v)
+{
+       int rc;
+
+    if( w == v ) {
+           MPI vv;
+       if (mpi_copy(&vv, v) < 0)
+               return -ENOMEM;
+       vv->sign = !vv->sign;
+       rc = mpi_add( w, u, vv );
+       mpi_free(vv);
+    }
+    else {
+       /* fixme: this is not thread-save (we temp. modify v) */
+       v->sign = !v->sign;
+       rc = mpi_add( w, u, v );
+       v->sign = !v->sign;
+    }
+    return rc;
+}
+
+
+int
+mpi_addm( MPI w, MPI u, MPI v, MPI m)
+{
+       if (mpi_add(w, u, v) < 0 ||
+           mpi_fdiv_r( w, w, m ) < 0)
+               return -ENOMEM;
+       return 0;
+}
+
+int
+mpi_subm( MPI w, MPI u, MPI v, MPI m)
+{
+       if (mpi_sub(w, u, v) < 0 ||
+           mpi_fdiv_r( w, w, m ) < 0)
+               return -ENOMEM;
+       return 0;
+}
+
diff --git a/crypto/mpi/mpi-bit.c b/crypto/mpi/mpi-bit.c
new file mode 100644 (file)
index 0000000..f155cc2
--- /dev/null
@@ -0,0 +1,245 @@
+/* mpi-bit.c  -  MPI bit level fucntions
+ * Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+const unsigned char __clz_tab[] = {
+       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,
+       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,
+       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,
+       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,
+       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,
+       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,
+       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,
+       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,
+};
+
+#define A_LIMB_1 ((mpi_limb_t) 1)
+
+
+/****************
+ * Sometimes we have MSL (most significant limbs) which are 0;
+ * this is for some reasons not good, so this function removes them.
+ */
+void
+mpi_normalize( MPI a )
+{
+    for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- )
+       ;
+}
+
+
+
+/****************
+ * Return the number of bits in A.
+ */
+unsigned
+mpi_get_nbits( MPI a )
+{
+    unsigned n;
+
+    mpi_normalize( a );
+
+    if( a->nlimbs ) {
+       mpi_limb_t alimb = a->d[a->nlimbs-1];
+       if( alimb ) {
+         count_leading_zeros( n, alimb );
+       }
+       else
+           n = BITS_PER_MPI_LIMB;
+       n = BITS_PER_MPI_LIMB - n + (a->nlimbs-1) * BITS_PER_MPI_LIMB;
+    }
+    else
+       n = 0;
+    return n;
+}
+
+
+/****************
+ * Test whether bit N is set.
+ */
+int
+mpi_test_bit( MPI a, unsigned n )
+{
+    unsigned limbno, bitno;
+    mpi_limb_t limb;
+
+    limbno = n / BITS_PER_MPI_LIMB;
+    bitno  = n % BITS_PER_MPI_LIMB;
+
+    if( limbno >= a->nlimbs )
+       return 0; /* too far left: this is a 0 */
+    limb = a->d[limbno];
+    return (limb & (A_LIMB_1 << bitno))? 1: 0;
+}
+
+
+/****************
+ * Set bit N of A.
+ */
+int
+mpi_set_bit( MPI a, unsigned n )
+{
+    unsigned limbno, bitno;
+
+    limbno = n / BITS_PER_MPI_LIMB;
+    bitno  = n % BITS_PER_MPI_LIMB;
+
+    if( limbno >= a->nlimbs ) { /* resize */
+       if( a->alloced >= limbno )
+           if (mpi_resize(a, limbno+1 ) < 0) return -ENOMEM;
+       a->nlimbs = limbno+1;
+    }
+    a->d[limbno] |= (A_LIMB_1<<bitno);
+    return 0;
+}
+
+/****************
+ * Set bit N of A. and clear all bits above
+ */
+int
+mpi_set_highbit( MPI a, unsigned n )
+{
+    unsigned limbno, bitno;
+
+    limbno = n / BITS_PER_MPI_LIMB;
+    bitno  = n % BITS_PER_MPI_LIMB;
+
+    if( limbno >= a->nlimbs ) { /* resize */
+       if( a->alloced >= limbno )
+           if (mpi_resize(a, limbno+1 ) < 0) return -ENOMEM;
+       a->nlimbs = limbno+1;
+    }
+    a->d[limbno] |= (A_LIMB_1<<bitno);
+    for( bitno++; bitno < BITS_PER_MPI_LIMB; bitno++ )
+       a->d[limbno] &= ~(A_LIMB_1 << bitno);
+    a->nlimbs = limbno+1;
+    return 0;
+}
+
+/****************
+ * clear bit N of A and all bits above
+ */
+void
+mpi_clear_highbit( MPI a, unsigned n )
+{
+    unsigned limbno, bitno;
+
+    limbno = n / BITS_PER_MPI_LIMB;
+    bitno  = n % BITS_PER_MPI_LIMB;
+
+    if( limbno >= a->nlimbs )
+       return; /* not allocated, so need to clear bits :-) */
+
+    for( ; bitno < BITS_PER_MPI_LIMB; bitno++ )
+       a->d[limbno] &= ~(A_LIMB_1 << bitno);
+    a->nlimbs = limbno+1;
+}
+
+/****************
+ * Clear bit N of A.
+ */
+void
+mpi_clear_bit( MPI a, unsigned n )
+{
+    unsigned limbno, bitno;
+
+    limbno = n / BITS_PER_MPI_LIMB;
+    bitno  = n % BITS_PER_MPI_LIMB;
+
+    if( limbno >= a->nlimbs )
+       return; /* don't need to clear this bit, it's to far to left */
+    a->d[limbno] &= ~(A_LIMB_1 << bitno);
+}
+
+
+/****************
+ * Shift A by N bits to the right
+ * FIXME: should use alloc_limb if X and A are same.
+ */
+int
+mpi_rshift( MPI x, MPI a, unsigned n )
+{
+    mpi_ptr_t xp;
+    mpi_size_t xsize;
+
+    xsize = a->nlimbs;
+    x->sign = a->sign;
+    if (RESIZE_IF_NEEDED(x, (size_t)xsize) < 0) return -ENOMEM;
+    xp = x->d;
+
+    if( xsize ) {
+       mpihelp_rshift( xp, a->d, xsize, n);
+       MPN_NORMALIZE( xp, xsize);
+    }
+    x->nlimbs = xsize;
+    return 0;
+}
+
+
+/****************
+ * Shift A by COUNT limbs to the left
+ * This is used only within the MPI library
+ */
+int
+mpi_lshift_limbs( MPI a, unsigned int count )
+{
+    mpi_ptr_t ap = a->d;
+    int n = a->nlimbs;
+    int i;
+
+    if( !count || !n )
+       return 0;
+
+    if (RESIZE_IF_NEEDED( a, n+count ) < 0) return -ENOMEM;
+
+    for( i = n-1; i >= 0; i-- )
+       ap[i+count] = ap[i];
+    for(i=0; i < count; i++ )
+       ap[i] = 0;
+    a->nlimbs += count;
+    return 0;
+}
+
+
+/****************
+ * Shift A by COUNT limbs to the right
+ * This is used only within the MPI library
+ */
+void
+mpi_rshift_limbs( MPI a, unsigned int count )
+{
+    mpi_ptr_t ap = a->d;
+    mpi_size_t n = a->nlimbs;
+    unsigned int i;
+
+    if( count >= n ) {
+       a->nlimbs = 0;
+       return;
+    }
+
+    for( i = 0; i < n - count; i++ )
+       ap[i] = ap[i+count];
+    ap[i] = 0;
+    a->nlimbs -= count;
+}
+
+
diff --git a/crypto/mpi/mpi-cmp.c b/crypto/mpi/mpi-cmp.c
new file mode 100644 (file)
index 0000000..c183cd5
--- /dev/null
@@ -0,0 +1,71 @@
+/* mpi-cmp.c  -  MPI functions
+ * Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+
+int
+mpi_cmp_ui( MPI u, unsigned long v )
+{
+    mpi_limb_t limb = v;
+
+    mpi_normalize( u );
+    if( !u->nlimbs && !limb )
+       return 0;
+    if( u->sign )
+       return -1;
+    if( u->nlimbs > 1 )
+       return 1;
+
+    if( u->d[0] == limb )
+       return 0;
+    else if( u->d[0] > limb )
+       return 1;
+    else
+       return -1;
+}
+
+int
+mpi_cmp( MPI u, MPI v )
+{
+    mpi_size_t usize, vsize;
+    int cmp;
+
+    mpi_normalize( u );
+    mpi_normalize( v );
+    usize = u->nlimbs;
+    vsize = v->nlimbs;
+    if( !u->sign && v->sign )
+       return 1;
+    if( u->sign && !v->sign )
+       return -1;
+    if( usize != vsize && !u->sign && !v->sign )
+       return usize - vsize;
+    if( usize != vsize && u->sign && v->sign )
+       return vsize + usize;
+    if( !usize )
+       return 0;
+    if( !(cmp=mpihelp_cmp( u->d, v->d, usize )) )
+       return 0;
+    if( (cmp < 0?1:0) == (u->sign?1:0))
+       return 1;
+    return -1;
+}
+
+
diff --git a/crypto/mpi/mpi-div.c b/crypto/mpi/mpi-div.c
new file mode 100644 (file)
index 0000000..dee9146
--- /dev/null
@@ -0,0 +1,345 @@
+/* mpi-div.c  -  MPI functions
+ *     Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ *     Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include <linux/string.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+int
+mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor )
+{
+       int rc = -ENOMEM;
+       int divisor_sign = divisor->sign;
+       MPI temp_divisor = NULL;
+
+       /* We need the original value of the divisor after the remainder has been
+        * preliminary calculated.      We have to copy it to temporary space if it's
+        * the same variable as REM.  */
+       if( rem == divisor ) {
+               if (mpi_copy( &temp_divisor, divisor ) < 0) goto nomem;
+               divisor = temp_divisor;
+       }
+
+       if (mpi_tdiv_qr(NULL, rem, dividend, divisor ) < 0) goto nomem;
+       if( ((divisor_sign?1:0) ^ (dividend->sign?1:0)) && rem->nlimbs )
+               if (mpi_add( rem, rem, divisor) < 0) goto nomem;
+
+       rc = 0;
+
+ nomem:
+       if( temp_divisor )
+               mpi_free(temp_divisor);
+       return rc;
+}
+
+
+/****************
+ * Division rounding the quotient towards -infinity.
+ * The remainder gets the same sign as the denominator.
+ * rem is optional
+ */
+
+ulong
+mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor )
+{
+    mpi_limb_t rlimb;
+
+    rlimb = mpihelp_mod_1( dividend->d, dividend->nlimbs, divisor );
+    if( rlimb && dividend->sign )
+       rlimb = divisor - rlimb;
+
+    if( rem ) {
+       rem->d[0] = rlimb;
+       rem->nlimbs = rlimb? 1:0;
+    }
+    return rlimb;
+}
+
+
+int
+mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor )
+{
+    MPI tmp = mpi_alloc( mpi_get_nlimbs(quot) );
+    if (!tmp)
+           return -ENOMEM;
+    mpi_fdiv_qr( quot, tmp, dividend, divisor);
+    mpi_free(tmp);
+    return 0;
+}
+
+int
+mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor )
+{
+    int divisor_sign = divisor->sign;
+    MPI temp_divisor = NULL;
+
+    if( quot == divisor || rem == divisor ) {
+       if (mpi_copy( &temp_divisor, divisor ) < 0);
+       return -ENOMEM;
+       divisor = temp_divisor;
+    }
+
+    if (mpi_tdiv_qr( quot, rem, dividend, divisor ) < 0)
+           goto nomem;
+
+    if( (divisor_sign ^ dividend->sign) && rem->nlimbs ) {
+           if (mpi_sub_ui( quot, quot, 1 ) < 0)
+                   goto nomem;
+           if (mpi_add( rem, rem, divisor) < 0)
+                   goto nomem;
+    }
+
+    if( temp_divisor )
+       mpi_free(temp_divisor);
+
+    return 0;
+
+ nomem:
+    mpi_free(temp_divisor);
+    return -ENOMEM;
+}
+
+
+/* If den == quot, den needs temporary storage.
+ * If den == rem, den needs temporary storage.
+ * If num == quot, num needs temporary storage.
+ * If den has temporary storage, it can be normalized while being copied,
+ *   i.e no extra storage should be allocated.
+ */
+
+int
+mpi_tdiv_r( MPI rem, MPI num, MPI den)
+{
+    return mpi_tdiv_qr(NULL, rem, num, den );
+}
+
+int
+mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den)
+{
+       int rc = -ENOMEM;
+       mpi_ptr_t np, dp;
+       mpi_ptr_t qp, rp;
+       mpi_size_t nsize = num->nlimbs;
+       mpi_size_t dsize = den->nlimbs;
+       mpi_size_t qsize, rsize;
+       mpi_size_t sign_remainder = num->sign;
+       mpi_size_t sign_quotient = num->sign ^ den->sign;
+       unsigned normalization_steps;
+       mpi_limb_t q_limb;
+       mpi_ptr_t marker[5];
+       int markidx=0;
+
+       memset(marker,0,sizeof(marker));
+
+       /* Ensure space is enough for quotient and remainder.
+        * We need space for an extra limb in the remainder, because it's
+        * up-shifted (normalized) below.  */
+       rsize = nsize + 1;
+       if (mpi_resize( rem, rsize) < 0) goto nomem;
+
+       qsize = rsize - dsize;    /* qsize cannot be bigger than this.  */
+       if( qsize <= 0 ) {
+               if( num != rem ) {
+                       rem->nlimbs = num->nlimbs;
+                       rem->sign = num->sign;
+                       MPN_COPY(rem->d, num->d, nsize);
+               }
+               if( quot ) {
+                       /* This needs to follow the assignment to rem, in case the
+                        * numerator and quotient are the same.  */
+                       quot->nlimbs = 0;
+                       quot->sign = 0;
+               }
+               return 0;
+       }
+
+       if( quot )
+               if (mpi_resize( quot, qsize) < 0) goto nomem;
+
+       /* Read pointers here, when reallocation is finished.  */
+       np = num->d;
+       dp = den->d;
+       rp = rem->d;
+
+       /* Optimize division by a single-limb divisor.  */
+       if( dsize == 1 ) {
+               mpi_limb_t rlimb;
+               if( quot ) {
+                       qp = quot->d;
+                       rlimb = mpihelp_divmod_1( qp, np, nsize, dp[0] );
+                       qsize -= qp[qsize - 1] == 0;
+                       quot->nlimbs = qsize;
+                       quot->sign = sign_quotient;
+               }
+               else
+                       rlimb = mpihelp_mod_1( np, nsize, dp[0] );
+               rp[0] = rlimb;
+               rsize = rlimb != 0?1:0;
+               rem->nlimbs = rsize;
+               rem->sign = sign_remainder;
+               return 0;
+       }
+
+
+       if( quot ) {
+               qp = quot->d;
+               /* Make sure QP and NP point to different objects.  Otherwise the
+                * numerator would be gradually overwritten by the quotient limbs.  */
+               if(qp == np) { /* Copy NP object to temporary space.  */
+                       np = marker[markidx++] = mpi_alloc_limb_space(nsize);
+                       MPN_COPY(np, qp, nsize);
+               }
+       }
+       else /* Put quotient at top of remainder. */
+               qp = rp + dsize;
+
+       count_leading_zeros( normalization_steps, dp[dsize - 1] );
+
+       /* Normalize the denominator, i.e. make its most significant bit set by
+        * shifting it NORMALIZATION_STEPS bits to the left.  Also shift the
+        * numerator the same number of steps (to keep the quotient the same!).
+        */
+       if( normalization_steps ) {
+               mpi_ptr_t tp;
+               mpi_limb_t nlimb;
+
+               /* Shift up the denominator setting the most significant bit of
+                * the most significant word.  Use temporary storage not to clobber
+                * the original contents of the denominator.  */
+               tp = marker[markidx++] = mpi_alloc_limb_space(dsize);
+               if (!tp) goto nomem;
+               mpihelp_lshift( tp, dp, dsize, normalization_steps );
+               dp = tp;
+
+               /* Shift up the numerator, possibly introducing a new most
+                * significant word.  Move the shifted numerator in the remainder
+                * meanwhile.  */
+               nlimb = mpihelp_lshift(rp, np, nsize, normalization_steps);
+               if( nlimb ) {
+                       rp[nsize] = nlimb;
+                       rsize = nsize + 1;
+               }
+               else
+                       rsize = nsize;
+       }
+       else {
+               /* The denominator is already normalized, as required.  Copy it to
+                * temporary space if it overlaps with the quotient or remainder.  */
+               if( dp == rp || (quot && (dp == qp))) {
+                       mpi_ptr_t tp;
+
+                       tp = marker[markidx++] = mpi_alloc_limb_space(dsize);
+                       if (!tp) goto nomem;
+                       MPN_COPY( tp, dp, dsize );
+                       dp = tp;
+               }
+
+               /* Move the numerator to the remainder.  */
+               if( rp != np )
+                       MPN_COPY(rp, np, nsize);
+
+               rsize = nsize;
+       }
+
+       q_limb = mpihelp_divrem( qp, 0, rp, rsize, dp, dsize );
+
+       if( quot ) {
+               qsize = rsize - dsize;
+               if(q_limb) {
+                       qp[qsize] = q_limb;
+                       qsize += 1;
+               }
+
+               quot->nlimbs = qsize;
+               quot->sign = sign_quotient;
+       }
+
+       rsize = dsize;
+       MPN_NORMALIZE (rp, rsize);
+
+       if( normalization_steps && rsize ) {
+               mpihelp_rshift(rp, rp, rsize, normalization_steps);
+               rsize -= rp[rsize - 1] == 0?1:0;
+       }
+
+       rem->nlimbs = rsize;
+       rem->sign       = sign_remainder;
+
+       rc = 0;
+ nomem:
+       while( markidx )
+               mpi_free_limb_space(marker[--markidx]);
+       return rc;
+}
+
+int
+mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count )
+{
+    mpi_size_t usize, wsize;
+    mpi_size_t limb_cnt;
+
+    usize = u->nlimbs;
+    limb_cnt = count / BITS_PER_MPI_LIMB;
+    wsize = usize - limb_cnt;
+    if( limb_cnt >= usize )
+       w->nlimbs = 0;
+    else {
+       mpi_ptr_t wp;
+       mpi_ptr_t up;
+
+       if (RESIZE_IF_NEEDED( w, wsize ) < 0)
+               return -ENOMEM;
+       wp = w->d;
+       up = u->d;
+
+       count %= BITS_PER_MPI_LIMB;
+       if( count ) {
+           mpihelp_rshift( wp, up + limb_cnt, wsize, count );
+           wsize -= !wp[wsize - 1];
+       }
+       else {
+           MPN_COPY_INCR( wp, up + limb_cnt, wsize);
+       }
+
+       w->nlimbs = wsize;
+    }
+    return 0;
+}
+
+/****************
+ * Check whether dividend is divisible by divisor
+ * (note: divisor must fit into a limb)
+ */
+int
+mpi_divisible_ui(MPI dividend, ulong divisor )
+{
+    return !mpihelp_mod_1( dividend->d, dividend->nlimbs, divisor );
+}
+
diff --git a/crypto/mpi/mpi-gcd.c b/crypto/mpi/mpi-gcd.c
new file mode 100644 (file)
index 0000000..2841b9f
--- /dev/null
@@ -0,0 +1,60 @@
+/* mpi-gcd.c  -  MPI functions
+ * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+
+/****************
+ * Find the greatest common divisor G of A and B.
+ * Return: true if this 1, false in all other cases
+ */
+int
+mpi_gcd( MPI g, const MPI xa, const MPI xb )
+{
+    MPI a = NULL, b = NULL;
+
+    if (mpi_copy(&a, xa) < 0)
+           goto nomem;
+
+    if (mpi_copy(&b, xb) < 0)
+           goto nomem;
+
+    /* TAOCP Vol II, 4.5.2, Algorithm A */
+    a->sign = 0;
+    b->sign = 0;
+    while( mpi_cmp_ui( b, 0 ) ) {
+           if (mpi_fdiv_r( g, a, b ) < 0) /* g used as temorary variable */
+                   goto nomem;
+           if (mpi_set(a,b) < 0)
+                   goto nomem;
+           if (mpi_set(b,g) < 0)
+                   goto nomem;
+    }
+    if (mpi_set(g, a) < 0)
+           goto nomem;
+
+    mpi_free(a);
+    mpi_free(b);
+    return !mpi_cmp_ui( g, 1);
+
+ nomem:
+    mpi_free(a);
+    mpi_free(b);
+    return -ENOMEM;
+}
diff --git a/crypto/mpi/mpi-inline.c b/crypto/mpi/mpi-inline.c
new file mode 100644 (file)
index 0000000..da53e2d
--- /dev/null
@@ -0,0 +1,33 @@
+/* mpi-inline.c
+ * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/* put the inline functions as real functions into the lib */
+#define G10_MPI_INLINE_DECL
+
+#include "mpi-internal.h"
+
+/* always include the header becuase it is only
+ * included by mpi-internal if __GCC__ is defined but we
+ * need it here in all cases and the above definition of
+ * of the macro allows us to do so
+ */
+#include "mpi-inline.h"
+
diff --git a/crypto/mpi/mpi-inline.h b/crypto/mpi/mpi-inline.h
new file mode 100644 (file)
index 0000000..02481b6
--- /dev/null
@@ -0,0 +1,128 @@
+/* mpi-inline.h  -  Internal to the Multi Precision Integers
+ *     Copyright (C) 1994, 1996, 1998, 1999 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#ifndef G10_MPI_INLINE_H
+#define G10_MPI_INLINE_H
+
+#ifndef G10_MPI_INLINE_DECL
+  #define G10_MPI_INLINE_DECL  extern __inline__
+#endif
+
+G10_MPI_INLINE_DECL  mpi_limb_t
+mpihelp_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+              mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+    mpi_limb_t x;
+
+    x = *s1_ptr++;
+    s2_limb += x;
+    *res_ptr++ = s2_limb;
+    if( s2_limb < x ) { /* sum is less than the left operand: handle carry */
+       while( --s1_size ) {
+           x = *s1_ptr++ + 1;  /* add carry */
+           *res_ptr++ = x;     /* and store */
+           if( x )             /* not 0 (no overflow): we can stop */
+               goto leave;
+       }
+       return 1; /* return carry (size of s1 to small) */
+    }
+
+  leave:
+    if( res_ptr != s1_ptr ) { /* not the same variable */
+       mpi_size_t i;          /* copy the rest */
+       for( i=0; i < s1_size-1; i++ )
+           res_ptr[i] = s1_ptr[i];
+    }
+    return 0; /* no carry */
+}
+
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+mpihelp_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+                              mpi_ptr_t s2_ptr, mpi_size_t s2_size)
+{
+    mpi_limb_t cy = 0;
+
+    if( s2_size )
+       cy = mpihelp_add_n( res_ptr, s1_ptr, s2_ptr, s2_size );
+
+    if( s1_size - s2_size )
+       cy = mpihelp_add_1( res_ptr + s2_size, s1_ptr + s2_size,
+                           s1_size - s2_size, cy);
+    return cy;
+}
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+mpihelp_sub_1(mpi_ptr_t res_ptr,  mpi_ptr_t s1_ptr,
+             mpi_size_t s1_size, mpi_limb_t s2_limb )
+{
+    mpi_limb_t x;
+
+    x = *s1_ptr++;
+    s2_limb = x - s2_limb;
+    *res_ptr++ = s2_limb;
+    if( s2_limb > x ) {
+       while( --s1_size ) {
+           x = *s1_ptr++;
+           *res_ptr++ = x - 1;
+           if( x )
+               goto leave;
+       }
+       return 1;
+    }
+
+  leave:
+    if( res_ptr != s1_ptr ) {
+       mpi_size_t i;
+       for( i=0; i < s1_size-1; i++ )
+           res_ptr[i] = s1_ptr[i];
+    }
+    return 0;
+}
+
+
+
+G10_MPI_INLINE_DECL   mpi_limb_t
+mpihelp_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+                               mpi_ptr_t s2_ptr, mpi_size_t s2_size)
+{
+    mpi_limb_t cy = 0;
+
+    if( s2_size )
+       cy = mpihelp_sub_n(res_ptr, s1_ptr, s2_ptr, s2_size);
+
+    if( s1_size - s2_size )
+       cy = mpihelp_sub_1(res_ptr + s2_size, s1_ptr + s2_size,
+                                     s1_size - s2_size, cy);
+    return cy;
+}
+
+
+#endif /*G10_MPI_INLINE_H*/
diff --git a/crypto/mpi/mpi-internal.h b/crypto/mpi/mpi-internal.h
new file mode 100644 (file)
index 0000000..9ed7166
--- /dev/null
@@ -0,0 +1,265 @@
+/* mpi-internal.h  -  Internal to the Multi Precision Integers
+ *     Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ *     Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#ifndef G10_MPI_INTERNAL_H
+#define G10_MPI_INTERNAL_H
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/crypto/mpi.h>
+#include <asm/errno.h>
+
+#define log_debug printk
+#define log_bug printk
+
+#define assert(x) do { \
+               if (!x) log_bug("failed assertion\n"); \
+              } while(0);
+
+/* If KARATSUBA_THRESHOLD is not already defined, define it to a
+ * value which is good on most machines.  */
+
+/* tested 4, 16, 32 and 64, where 16 gave the best performance when
+ * checking a 768 and a 1024 bit ElGamal signature.
+ * (wk 22.12.97) */
+#ifndef KARATSUBA_THRESHOLD
+    #define KARATSUBA_THRESHOLD 16
+#endif
+
+/* The code can't handle KARATSUBA_THRESHOLD smaller than 2.  */
+#if KARATSUBA_THRESHOLD < 2
+    #undef KARATSUBA_THRESHOLD
+    #define KARATSUBA_THRESHOLD 2
+#endif
+
+
+typedef mpi_limb_t *mpi_ptr_t; /* pointer to a limb */
+typedef int mpi_size_t;        /* (must be a signed type) */
+
+#define ABS(x) (x >= 0 ? x : -x)
+#define MIN(l,o) ((l) < (o) ? (l) : (o))
+#define MAX(h,i) ((h) > (i) ? (h) : (i))
+
+static inline int RESIZE_IF_NEEDED(MPI a, unsigned b)
+{
+       if (a->alloced < b)
+               return mpi_resize(a,b);
+       return 0;
+}
+
+/* Copy N limbs from S to D.  */
+#define MPN_COPY( d, s, n) \
+    do {                               \
+       mpi_size_t _i;                  \
+       for( _i = 0; _i < (n); _i++ )   \
+           (d)[_i] = (s)[_i];          \
+    } while(0)
+
+#define MPN_COPY_INCR( d, s, n)        \
+    do {                               \
+       mpi_size_t _i;                  \
+       for( _i = 0; _i < (n); _i++ )   \
+           (d)[_i] = (d)[_i];          \
+    } while (0)
+
+#define MPN_COPY_DECR( d, s, n ) \
+    do {                               \
+       mpi_size_t _i;                  \
+       for( _i = (n)-1; _i >= 0; _i--) \
+          (d)[_i] = (s)[_i];           \
+    } while(0)
+
+/* Zero N limbs at D */
+#define MPN_ZERO(d, n) \
+    do {                                 \
+       int  _i;                          \
+       for( _i = 0; _i < (n); _i++ )  \
+           (d)[_i] = 0;                    \
+    } while (0)
+
+#define MPN_NORMALIZE(d, n)  \
+    do {                      \
+       while( (n) > 0 ) {     \
+           if( (d)[(n)-1] ) \
+               break;         \
+           (n)--;             \
+       }                      \
+    } while(0)
+
+#define MPN_NORMALIZE_NOT_ZERO(d, n) \
+    do {                                   \
+       for(;;) {                           \
+           if( (d)[(n)-1] )                \
+               break;                      \
+           (n)--;                          \
+       }                                   \
+    } while(0)
+
+#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
+    do {                                               \
+       if( (size) < KARATSUBA_THRESHOLD )              \
+           mul_n_basecase (prodp, up, vp, size);       \
+       else                                            \
+           mul_n (prodp, up, vp, size, tspace);        \
+    } while (0);
+
+
+/* Divide the two-limb number in (NH,,NL) by D, with DI being the largest
+ * limb not larger than (2**(2*BITS_PER_MP_LIMB))/D - (2**BITS_PER_MP_LIMB).
+ * If this would yield overflow, DI should be the largest possible number
+ * (i.e., only ones).  For correct operation, the most significant bit of D
+ * has to be set.  Put the quotient in Q and the remainder in R.
+ */
+#define UDIV_QRNND_PREINV(q, r, nh, nl, d, di) \
+    do {                                                           \
+       mpi_limb_t _q, _ql, _r;                                     \
+       mpi_limb_t _xh, _xl;                                        \
+       umul_ppmm (_q, _ql, (nh), (di));                            \
+       _q += (nh);     /* DI is 2**BITS_PER_MPI_LIMB too small */  \
+       umul_ppmm (_xh, _xl, _q, (d));                              \
+       sub_ddmmss (_xh, _r, (nh), (nl), _xh, _xl);                 \
+       if( _xh ) {                                                 \
+           sub_ddmmss (_xh, _r, _xh, _r, 0, (d));                  \
+           _q++;                                                   \
+           if( _xh) {                                              \
+               sub_ddmmss (_xh, _r, _xh, _r, 0, (d));              \
+               _q++;                                               \
+           }                                                       \
+       }                                                           \
+       if( _r >= (d) ) {                                           \
+           _r -= (d);                                              \
+           _q++;                                                   \
+       }                                                           \
+       (r) = _r;                                                   \
+       (q) = _q;                                                   \
+    } while (0)
+
+
+/*-- mpiutil.c --*/
+mpi_ptr_t mpi_alloc_limb_space( unsigned nlimbs );
+void mpi_free_limb_space( mpi_ptr_t a );
+void mpi_assign_limb_space( MPI a, mpi_ptr_t ap, unsigned nlimbs );
+
+/*-- mpi-bit.c --*/
+void mpi_rshift_limbs( MPI a, unsigned int count );
+int mpi_lshift_limbs( MPI a, unsigned int count );
+
+
+/*-- mpihelp-add.c --*/
+mpi_limb_t mpihelp_add_1(mpi_ptr_t res_ptr,  mpi_ptr_t s1_ptr,
+                        mpi_size_t s1_size, mpi_limb_t s2_limb );
+mpi_limb_t mpihelp_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                         mpi_ptr_t s2_ptr,  mpi_size_t size);
+mpi_limb_t mpihelp_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+                      mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+
+/*-- mpihelp-sub.c --*/
+mpi_limb_t mpihelp_sub_1( mpi_ptr_t res_ptr,  mpi_ptr_t s1_ptr,
+                         mpi_size_t s1_size, mpi_limb_t s2_limb );
+mpi_limb_t mpihelp_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                         mpi_ptr_t s2_ptr, mpi_size_t size);
+mpi_limb_t mpihelp_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+                      mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+
+/*-- mpihelp-cmp.c --*/
+int mpihelp_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size );
+
+/*-- mpihelp-mul.c --*/
+
+struct karatsuba_ctx {
+    struct karatsuba_ctx *next;
+    mpi_ptr_t tspace;
+    mpi_size_t tspace_size;
+    mpi_ptr_t tp;
+    mpi_size_t tp_size;
+};
+
+void mpihelp_release_karatsuba_ctx( struct karatsuba_ctx *ctx );
+
+mpi_limb_t mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                            mpi_size_t s1_size, mpi_limb_t s2_limb);
+mpi_limb_t mpihelp_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                            mpi_size_t s1_size, mpi_limb_t s2_limb);
+int mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
+                                                  mpi_size_t size);
+int mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
+                mpi_ptr_t vp, mpi_size_t vsize, mpi_limb_t *_result);
+void mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size );
+void mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size,
+                                               mpi_ptr_t tspace);
+
+int mpihelp_mul_karatsuba_case( mpi_ptr_t prodp,
+                                mpi_ptr_t up, mpi_size_t usize,
+                                mpi_ptr_t vp, mpi_size_t vsize,
+                                struct karatsuba_ctx *ctx );
+
+
+/*-- mpihelp-mul_1.c (or xxx/cpu/ *.S) --*/
+mpi_limb_t mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+                         mpi_size_t s1_size, mpi_limb_t s2_limb);
+
+/*-- mpihelp-div.c --*/
+mpi_limb_t mpihelp_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+                                                mpi_limb_t divisor_limb);
+mpi_limb_t mpihelp_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
+                          mpi_ptr_t np, mpi_size_t nsize,
+                          mpi_ptr_t dp, mpi_size_t dsize);
+mpi_limb_t mpihelp_divmod_1( mpi_ptr_t quot_ptr,
+                            mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+                            mpi_limb_t divisor_limb);
+
+/*-- mpihelp-shift.c --*/
+mpi_limb_t mpihelp_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+                                                          unsigned cnt);
+mpi_limb_t mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+                                                          unsigned cnt);
+
+
+/* Define stuff for longlong.h.  */
+#define W_TYPE_SIZE BITS_PER_MPI_LIMB
+  typedef mpi_limb_t   UWtype;
+  typedef unsigned int UHWtype;
+#if defined (__GNUC__)
+  typedef unsigned int UQItype   __attribute__ ((mode (QI)));
+  typedef         int SItype     __attribute__ ((mode (SI)));
+  typedef unsigned int USItype   __attribute__ ((mode (SI)));
+  typedef         int DItype     __attribute__ ((mode (DI)));
+  typedef unsigned int UDItype   __attribute__ ((mode (DI)));
+#else
+  typedef unsigned char UQItype;
+  typedef         long SItype;
+  typedef unsigned long USItype;
+#endif
+
+#ifdef __GNUC__
+  #include "mpi-inline.h"
+#endif
+
+#endif /*G10_MPI_INTERNAL_H*/
diff --git a/crypto/mpi/mpi-inv.c b/crypto/mpi/mpi-inv.c
new file mode 100644 (file)
index 0000000..0e0f282
--- /dev/null
@@ -0,0 +1,148 @@
+/* mpi-inv.c  -  MPI functions
+ * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+
+
+/****************
+ * Calculate the multiplicative inverse X of A mod N
+ * That is: Find the solution x for
+ *             1 = (a*x) mod n
+ */
+int
+mpi_invm( MPI x, const MPI a, const MPI n )
+{
+       /* Extended Euclid's algorithm (See TAOPC Vol II, 4.5.2, Alg X)
+        * modified according to Michael Penk's solution for Exercice 35
+        * with further enhancement */
+       MPI u = NULL, v = NULL;
+       MPI u1 = NULL, u2 = NULL, u3 = NULL;
+       MPI v1 = NULL, v2 = NULL, v3 = NULL;
+       MPI t1 = NULL, t2 = NULL, t3 = NULL;
+       unsigned k;
+       int sign;
+       int odd = 0;
+       int rc = -ENOMEM;
+
+       if (mpi_copy(&u, a) < 0) goto cleanup;
+       if (mpi_copy(&v, n) < 0) goto cleanup;
+
+       for(k=0; !mpi_test_bit(u,0) && !mpi_test_bit(v,0); k++ ) {
+               if (mpi_rshift(u, u, 1) < 0) goto cleanup;
+               if (mpi_rshift(v, v, 1) < 0) goto cleanup;
+       }
+       odd = mpi_test_bit(v,0);
+
+       u1 = mpi_alloc_set_ui(1); if (!u1) goto cleanup;
+       if( !odd ) {
+               u2 = mpi_alloc_set_ui(0);
+               if (!u2) goto cleanup;
+       }
+       if (mpi_copy(&u3, u) < 0) goto cleanup;
+       if (mpi_copy(&v1, v) < 0) goto cleanup;
+       if( !odd ) {
+               v2 = mpi_alloc( mpi_get_nlimbs(u) );  if (!v2) goto cleanup;
+               if (mpi_sub( v2, u1, u ) < 0) goto cleanup; /* U is used as const 1 */
+       }
+       if (mpi_copy(&v3, v) < 0) goto cleanup;
+       if( mpi_test_bit(u, 0) ) { /* u is odd */
+               t1 = mpi_alloc_set_ui(0); if (!t1) goto cleanup;
+               if( !odd ) {
+                       t2 = mpi_alloc_set_ui(1); if (!t2) goto cleanup;
+                       t2->sign = 1; 
+               }
+               if (mpi_copy(&t3, v) < 0) goto cleanup;
+               t3->sign = !t3->sign;
+               goto Y4;
+       }
+       else {
+               t1 = mpi_alloc_set_ui(1); if (!t1) goto cleanup;
+               if( !odd ) {
+                       t2 = mpi_alloc_set_ui(0); if (!t2) goto cleanup;
+               }
+               if (mpi_copy(&t3, u) < 0) goto cleanup;
+       }
+       do {
+               do {
+                       if( !odd ) {
+                               if( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */
+                                       if (mpi_add(t1, t1, v) < 0) goto cleanup;
+                                       if (mpi_sub(t2, t2, u) < 0) goto cleanup;
+                               }
+                               if (mpi_rshift(t1, t1, 1) < 0) goto cleanup;
+                               if (mpi_rshift(t2, t2, 1) < 0) goto cleanup;
+                               if (mpi_rshift(t3, t3, 1) < 0) goto cleanup;
+                       }
+                       else {
+                               if( mpi_test_bit(t1, 0) )
+                                       if (mpi_add(t1, t1, v) < 0) goto cleanup;
+                               if (mpi_rshift(t1, t1, 1) < 0) goto cleanup;
+                               if (mpi_rshift(t3, t3, 1) < 0) goto cleanup;
+                       }
+               Y4:
+                       ;
+               } while( !mpi_test_bit( t3, 0 ) ); /* while t3 is even */
+
+               if( !t3->sign ) {
+                       if (mpi_set(u1, t1) < 0) goto cleanup;
+                       if( !odd )
+                               if (mpi_set(u2, t2) < 0) goto cleanup;
+                       if (mpi_set(u3, t3) < 0) goto cleanup;
+               }
+               else {
+                       if (mpi_sub(v1, v, t1) < 0) goto cleanup;
+                       sign = u->sign; u->sign = !u->sign;
+                       if( !odd )
+                               if (mpi_sub(v2, u, t2) < 0) goto cleanup;
+                       u->sign = sign;
+                       sign = t3->sign; t3->sign = !t3->sign;
+                       if (mpi_set(v3, t3) < 0) goto cleanup;
+                       t3->sign = sign;
+               }
+               if (mpi_sub(t1, u1, v1) < 0) goto cleanup;
+               if( !odd )
+                       if (mpi_sub(t2, u2, v2) < 0) goto cleanup;
+               if (mpi_sub(t3, u3, v3) < 0) goto cleanup;
+               if( t1->sign ) {
+                       if (mpi_add(t1, t1, v) < 0) goto cleanup;
+                       if( !odd )
+                               if (mpi_sub(t2, t2, u) < 0) goto cleanup;
+               }
+       } while( mpi_cmp_ui( t3, 0 ) ); /* while t3 != 0 */
+       /* mpi_lshift( u3, k ); */
+       rc = mpi_set(x, u1);
+
+ cleanup:
+       mpi_free(u1);
+       mpi_free(v1);
+       mpi_free(t1);
+       if( !odd ) {
+               mpi_free(u2);
+               mpi_free(v2);
+               mpi_free(t2);
+       }
+       mpi_free(u3);
+       mpi_free(v3);
+       mpi_free(t3);
+
+       mpi_free(u);
+       mpi_free(v);
+       return rc;
+}
diff --git a/crypto/mpi/mpi-mpow.c b/crypto/mpi/mpi-mpow.c
new file mode 100644 (file)
index 0000000..eb6d3c7
--- /dev/null
@@ -0,0 +1,113 @@
+/* mpi-mpow.c  -  MPI functions
+ * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+static int
+build_index(const MPI *exparray, int k, int i, int t )
+{
+    int j, bitno;
+    int index = 0;
+
+    bitno = t-i;
+    for(j=k-1; j >= 0; j-- ) {
+       index <<= 1;
+       if( mpi_test_bit( exparray[j], bitno ) )
+           index |= 1;
+    }
+    return index;
+}
+
+/****************
+ * RES = (BASE[0] ^ EXP[0]) *  (BASE[1] ^ EXP[1]) * ... * mod M
+ */
+int
+mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI m)
+{
+       int rc = -ENOMEM;
+       int k;  /* number of elements */
+       int t;  /* bit size of largest exponent */
+       int i, j, idx;
+       MPI *G = NULL;  /* table with precomputed values of size 2^k */
+       MPI tmp = NULL;
+
+       for(k=0; basearray[k]; k++ )
+               ;
+       if (!k) { printk("mpi_mulpowm: assert(k) failed\n"); BUG(); }
+       for(t=0, i=0; (tmp=exparray[i]); i++ ) {
+               j = mpi_get_nbits(tmp);
+               if( j > t )
+                       t = j;
+       }
+       if (i!=k) { printk("mpi_mulpowm: assert(i==k) failed\n"); BUG(); }
+       if (!t)   { printk("mpi_mulpowm: assert(t) failed\n"); BUG(); }
+       if (k>=10) { printk("mpi_mulpowm: assert(k<10) failed\n"); BUG(); }
+
+       G = kmalloc( (1<<k) * sizeof *G, GFP_KERNEL );
+       if (!G) goto nomem;
+       memset(G,0,(1<<k) * sizeof *G);
+       /* and calculate */
+       tmp =  mpi_alloc( mpi_get_nlimbs(m)+1 ); if (!tmp) goto nomem;
+       if (mpi_set_ui( res, 1 ) < 0) goto nomem;
+       for(i = 1; i <= t; i++ ) {
+               if (mpi_mulm(tmp, res, res, m ) < 0) goto nomem;
+               idx = build_index( exparray, k, i, t );
+               if (!(idx >= 0 && idx < (1<<k))) {
+                       printk("mpi_mulpowm: assert(idx >= 0 && idx < (1<<k)) failed\n");
+                       BUG();
+               }
+               if( !G[idx] ) {
+                       if( !idx ) {
+                               G[0] = mpi_alloc_set_ui( 1 );
+                               if (!G[0]) goto nomem;
+                       }
+                       else {
+                               for(j=0; j < k; j++ ) {
+                                       if( (idx & (1<<j) ) ) {
+                                               if( !G[idx] ) {
+                                                       if (mpi_copy( &G[idx], basearray[j] ) < 0)
+                                                               goto nomem;
+                                               }
+                                               else {
+                                                       if (mpi_mulm(G[idx],G[idx],basearray[j],m) < 0)
+                                                               goto nomem;
+                                               }
+                                       }
+                               }
+                               if( !G[idx] ) {
+                                       G[idx] = mpi_alloc(0);
+                                       if (!G[idx]) goto nomem;
+                               }
+                       }
+               }
+               if (mpi_mulm(res, tmp, G[idx], m ) < 0) goto nomem;
+       }
+
+       rc = 0;
+ nomem:
+       /* cleanup */
+       mpi_free(tmp);
+       for(i=0; i < (1<<k); i++ )
+               mpi_free(G[i]);
+       kfree(G);
+       return rc;
+}
diff --git a/crypto/mpi/mpi-mul.c b/crypto/mpi/mpi-mul.c
new file mode 100644 (file)
index 0000000..14fd2a4
--- /dev/null
@@ -0,0 +1,202 @@
+/* mpi-mul.c  -  MPI functions
+ *     Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ *     Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+
+
+int
+mpi_mul_ui( MPI prod, MPI mult, unsigned long small_mult )
+{
+    mpi_size_t size, prod_size;
+    mpi_ptr_t  prod_ptr;
+    mpi_limb_t cy;
+    int sign;
+
+    size = mult->nlimbs;
+    sign = mult->sign;
+
+    if( !size || !small_mult ) {
+       prod->nlimbs = 0;
+       prod->sign = 0;
+       return 0;
+    }
+
+    prod_size = size + 1;
+    if( prod->alloced < prod_size )
+           if (mpi_resize( prod, prod_size ) < 0)
+                   return -ENOMEM;
+    prod_ptr = prod->d;
+
+    cy = mpihelp_mul_1( prod_ptr, mult->d, size, (mpi_limb_t)small_mult );
+    if( cy )
+       prod_ptr[size++] = cy;
+    prod->nlimbs = size;
+    prod->sign = sign;
+    return 0;
+}
+
+
+int
+mpi_mul_2exp( MPI w, MPI u, unsigned long cnt)
+{
+    mpi_size_t usize, wsize, limb_cnt;
+    mpi_ptr_t wp;
+    mpi_limb_t wlimb;
+    int usign, wsign;
+
+    usize = u->nlimbs;
+    usign = u->sign;
+
+    if( !usize ) {
+       w->nlimbs = 0;
+       w->sign = 0;
+       return 0;
+    }
+
+    limb_cnt = cnt / BITS_PER_MPI_LIMB;
+    wsize = usize + limb_cnt + 1;
+    if( w->alloced < wsize )
+           if (mpi_resize(w, wsize ) < 0)
+                   return -ENOMEM;
+    wp = w->d;
+    wsize = usize + limb_cnt;
+    wsign = usign;
+
+    cnt %= BITS_PER_MPI_LIMB;
+    if( cnt ) {
+       wlimb = mpihelp_lshift( wp + limb_cnt, u->d, usize, cnt );
+       if( wlimb ) {
+           wp[wsize] = wlimb;
+           wsize++;
+       }
+    }
+    else {
+       MPN_COPY_DECR( wp + limb_cnt, u->d, usize );
+    }
+
+    /* Zero all whole limbs at low end.  Do it here and not before calling
+     * mpn_lshift, not to lose for U == W.  */
+    MPN_ZERO( wp, limb_cnt );
+
+    w->nlimbs = wsize;
+    w->sign = wsign;
+    return 0;
+}
+
+int
+mpi_mul( MPI w, MPI u, MPI v)
+{
+       int rc = -ENOMEM;
+       mpi_size_t usize, vsize, wsize;
+       mpi_ptr_t up, vp, wp;
+       mpi_limb_t cy;
+       int usign, vsign, sign_product;
+       int assign_wp=0;
+       mpi_ptr_t tmp_limb=NULL;
+
+
+       if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
+               usize = v->nlimbs;
+               usign = v->sign;
+               up    = v->d;
+               vsize = u->nlimbs;
+               vsign = u->sign;
+               vp    = u->d;
+       }
+       else {
+               usize = u->nlimbs;
+               usign = u->sign;
+               up    = u->d;
+               vsize = v->nlimbs;
+               vsign = v->sign;
+               vp    = v->d;
+       }
+       sign_product = usign ^ vsign;
+       wp = w->d;
+
+       /* Ensure W has space enough to store the result.  */
+       wsize = usize + vsize;
+       if( w->alloced < (size_t)wsize ) {
+               if( wp == up || wp == vp ) {
+                       wp = mpi_alloc_limb_space(wsize);
+                       if (!wp) goto nomem;
+                       assign_wp = 1;
+               }
+               else {
+                       if (mpi_resize(w, wsize ) < 0) goto nomem;
+                       wp = w->d;
+               }
+       }
+       else { /* Make U and V not overlap with W.      */
+               if( wp == up ) {
+                       /* W and U are identical.  Allocate temporary space for U.      */
+                       up = tmp_limb = mpi_alloc_limb_space( usize);
+                       if (!up) goto nomem;
+                       /* Is V identical too?  Keep it identical with U.  */
+                       if( wp == vp )
+                               vp = up;
+                       /* Copy to the temporary space.  */
+                       MPN_COPY( up, wp, usize );
+               }
+               else if( wp == vp ) {
+                       /* W and V are identical.  Allocate temporary space for V.      */
+                       vp = tmp_limb = mpi_alloc_limb_space( vsize);
+                       if (!vp) goto nomem;
+                       /* Copy to the temporary space.  */
+                       MPN_COPY( vp, wp, vsize );
+               }
+       }
+
+       if( !vsize )
+               wsize = 0;
+       else {
+               if (mpihelp_mul( wp, up, usize, vp, vsize, &cy) < 0)
+                       goto nomem;
+               wsize -= cy? 0:1;
+       }
+
+       if( assign_wp )
+               mpi_assign_limb_space( w, wp, wsize );
+
+       w->nlimbs = wsize;
+       w->sign = sign_product;
+       rc = 0;
+ nomem:
+       if( tmp_limb )
+               mpi_free_limb_space( tmp_limb );
+       return rc;
+}
+
+int
+mpi_mulm( MPI w, MPI u, MPI v, MPI m)
+{
+       if (mpi_mul(w, u, v) < 0)
+               return -ENOMEM;
+       return mpi_fdiv_r( w, w, m );
+}
diff --git a/crypto/mpi/mpi-pow.c b/crypto/mpi/mpi-pow.c
new file mode 100644 (file)
index 0000000..fa0efa5
--- /dev/null
@@ -0,0 +1,312 @@
+/* mpi-pow.c  -  MPI functions
+ *     Copyright (C) 1994, 1996, 1998, 2000 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include <linux/string.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+/****************
+ * RES = BASE ^ EXP mod MOD
+ */
+int
+mpi_powm( MPI res, MPI base, MPI exp, MPI mod)
+{
+    mpi_ptr_t mp_marker=NULL, bp_marker=NULL, ep_marker=NULL;
+    mpi_ptr_t xp_marker=NULL;
+    mpi_ptr_t tspace = NULL;
+    mpi_ptr_t  rp, ep, mp, bp;
+    mpi_size_t esize, msize, bsize, rsize;
+    int        esign, msign, bsign, rsign;
+    mpi_size_t size;
+    int mod_shift_cnt;
+    int negative_result;
+    int assign_rp=0;
+    mpi_size_t tsize=0;   /* to avoid compiler warning */
+                         /* fixme: we should check that the warning is void*/
+    int rc = -ENOMEM;
+
+    esize = exp->nlimbs;
+    msize = mod->nlimbs;
+    size = 2 * msize;
+    esign = exp->sign;
+    msign = mod->sign;
+
+    rp = res->d;
+    ep = exp->d;
+
+    if( !msize )
+       msize = 1 / msize;          /* provoke a signal */
+
+    if( !esize ) {
+       /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0
+        * depending on if MOD equals 1.  */
+       rp[0] = 1;
+       res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
+       res->sign = 0;
+       goto leave;
+    }
+
+    /* Normalize MOD (i.e. make its most significant bit set) as required by
+     * mpn_divrem.  This will make the intermediate values in the calculation
+     * slightly larger, but the correct result is obtained after a final
+     * reduction using the original MOD value. */
+    mp = mp_marker = mpi_alloc_limb_space(msize);
+    if (!mp)
+           goto enomem;
+    count_leading_zeros( mod_shift_cnt, mod->d[msize-1] );
+    if( mod_shift_cnt )
+       mpihelp_lshift( mp, mod->d, msize, mod_shift_cnt );
+    else
+       MPN_COPY( mp, mod->d, msize );
+
+    bsize = base->nlimbs;
+    bsign = base->sign;
+    if( bsize > msize ) { /* The base is larger than the module. Reduce it. */
+       /* Allocate (BSIZE + 1) with space for remainder and quotient.
+        * (The quotient is (bsize - msize + 1) limbs.)  */
+       bp = bp_marker = mpi_alloc_limb_space( bsize + 1);
+       if (!bp)
+               goto enomem;
+       MPN_COPY( bp, base->d, bsize );
+       /* We don't care about the quotient, store it above the remainder,
+        * at BP + MSIZE.  */
+       mpihelp_divrem( bp + msize, 0, bp, bsize, mp, msize );
+       bsize = msize;
+       /* Canonicalize the base, since we are going to multiply with it
+        * quite a few times.  */
+       MPN_NORMALIZE( bp, bsize );
+    }
+    else
+       bp = base->d;
+
+    if( !bsize ) {
+       res->nlimbs = 0;
+       res->sign = 0;
+       goto leave;
+    }
+
+    if( res->alloced < size ) {
+       /* We have to allocate more space for RES.  If any of the input
+        * parameters are identical to RES, defer deallocation of the old
+        * space.  */
+       if( rp == ep || rp == mp || rp == bp ) {
+           rp = mpi_alloc_limb_space(size);
+           if (!rp)
+                   goto enomem;
+           assign_rp = 1;
+       }
+       else {
+               if (mpi_resize( res, size ) < 0)
+                       goto enomem;
+           rp = res->d;
+       }
+    }
+    else { /* Make BASE, EXP and MOD not overlap with RES.  */
+       if( rp == bp ) {
+           /* RES and BASE are identical.  Allocate temp. space for BASE.  */
+               BUG_ON(bp_marker);
+           bp = bp_marker = mpi_alloc_limb_space(bsize);
+           if (!bp)
+                   goto enomem;
+           MPN_COPY(bp, rp, bsize);
+       }
+       if( rp == ep ) {
+           /* RES and EXP are identical.  Allocate temp. space for EXP.  */
+           ep = ep_marker = mpi_alloc_limb_space(esize);
+           if (!ep)
+                   goto enomem;  
+           MPN_COPY(ep, rp, esize);
+       }
+       if( rp == mp ) {
+           /* RES and MOD are identical.  Allocate temporary space for MOD.*/
+           BUG_ON(mp_marker);
+           mp = mp_marker = mpi_alloc_limb_space(msize);
+           if (!mp)
+                   goto enomem;
+           MPN_COPY(mp, rp, msize);
+       }
+    }
+
+    MPN_COPY( rp, bp, bsize );
+    rsize = bsize;
+    rsign = bsign;
+
+    {
+       mpi_size_t i;
+       mpi_ptr_t xp;
+       int c;
+       mpi_limb_t e;
+       mpi_limb_t carry_limb;
+       struct karatsuba_ctx karactx;
+
+       xp = xp_marker = mpi_alloc_limb_space(2 * (msize + 1));
+       if (xp)
+               goto enomem;
+
+       memset( &karactx, 0, sizeof karactx );
+       negative_result = (ep[0] & 1) && base->sign;
+
+       i = esize - 1;
+       e = ep[i];
+       count_leading_zeros (c, e);
+       e = (e << c) << 1;     /* shift the exp bits to the left, lose msb */
+       c = BITS_PER_MPI_LIMB - 1 - c;
+
+       /* Main loop.
+        *
+        * Make the result be pointed to alternately by XP and RP.  This
+        * helps us avoid block copying, which would otherwise be necessary
+        * with the overlap restrictions of mpihelp_divmod. With 50% probability
+        * the result after this loop will be in the area originally pointed
+        * by RP (==RES->d), and with 50% probability in the area originally
+        * pointed to by XP.
+        */
+
+       for(;;) {
+           while( c ) {
+               mpi_ptr_t tp;
+               mpi_size_t xsize;
+
+               /*if (mpihelp_mul_n(xp, rp, rp, rsize) < 0) goto enomem */
+               if( rsize < KARATSUBA_THRESHOLD )
+                   mpih_sqr_n_basecase( xp, rp, rsize );
+               else {
+                   if( !tspace ) {
+                       tsize = 2 * rsize;
+                       tspace = mpi_alloc_limb_space(tsize);
+                       if (!tspace)
+                               goto enomem;
+                   }
+                   else if( tsize < (2*rsize) ) {
+                       mpi_free_limb_space( tspace );
+                       tsize = 2 * rsize;
+                       tspace = mpi_alloc_limb_space(tsize);
+                       if (!tspace)
+                               goto enomem;
+                   }
+                   mpih_sqr_n( xp, rp, rsize, tspace );
+               }
+
+               xsize = 2 * rsize;
+               if( xsize > msize ) {
+                   mpihelp_divrem(xp + msize, 0, xp, xsize, mp, msize);
+                   xsize = msize;
+               }
+
+               tp = rp; rp = xp; xp = tp;
+               rsize = xsize;
+
+               if( (mpi_limb_signed_t)e < 0 ) {
+                   /*mpihelp_mul( xp, rp, rsize, bp, bsize );*/
+                   if( bsize < KARATSUBA_THRESHOLD ) {
+                           mpi_limb_t tmp;
+                           if (mpihelp_mul( xp, rp, rsize, bp, bsize, &tmp ) < 0)
+                                   goto enomem;
+                   }
+                   else {
+                           if (mpihelp_mul_karatsuba_case(
+                                       xp, rp, rsize, bp, bsize, &karactx ) < 0)
+                                   goto enomem;
+                   }
+
+                   xsize = rsize + bsize;
+                   if( xsize > msize ) {
+                       mpihelp_divrem(xp + msize, 0, xp, xsize, mp, msize);
+                       xsize = msize;
+                   }
+
+                   tp = rp; rp = xp; xp = tp;
+                   rsize = xsize;
+               }
+               e <<= 1;
+               c--;
+           }
+
+           i--;
+           if( i < 0 )
+               break;
+           e = ep[i];
+           c = BITS_PER_MPI_LIMB;
+       }
+
+       /* We shifted MOD, the modulo reduction argument, left MOD_SHIFT_CNT
+        * steps.  Adjust the result by reducing it with the original MOD.
+        *
+        * Also make sure the result is put in RES->d (where it already
+        * might be, see above).
+        */
+       if( mod_shift_cnt ) {
+           carry_limb = mpihelp_lshift( res->d, rp, rsize, mod_shift_cnt);
+           rp = res->d;
+           if( carry_limb ) {
+               rp[rsize] = carry_limb;
+               rsize++;
+           }
+       }
+       else {
+           MPN_COPY( res->d, rp, rsize);
+           rp = res->d;
+       }
+
+       if( rsize >= msize ) {
+           mpihelp_divrem(rp + msize, 0, rp, rsize, mp, msize);
+           rsize = msize;
+       }
+
+       /* Remove any leading zero words from the result.  */
+       if( mod_shift_cnt )
+           mpihelp_rshift( rp, rp, rsize, mod_shift_cnt);
+       MPN_NORMALIZE (rp, rsize);
+
+       mpihelp_release_karatsuba_ctx( &karactx );
+    }
+
+    if( negative_result && rsize ) {
+       if( mod_shift_cnt )
+           mpihelp_rshift( mp, mp, msize, mod_shift_cnt);
+       mpihelp_sub( rp, mp, msize, rp, rsize);
+       rsize = msize;
+       rsign = msign;
+       MPN_NORMALIZE(rp, rsize);
+    }
+    res->nlimbs = rsize;
+    res->sign = rsign;
+
+ leave:
+    rc = 0;
+ enomem:
+    if( assign_rp ) mpi_assign_limb_space( res, rp, size );
+    if( mp_marker ) mpi_free_limb_space( mp_marker );
+    if( bp_marker ) mpi_free_limb_space( bp_marker );
+    if( ep_marker ) mpi_free_limb_space( ep_marker );
+    if( xp_marker ) mpi_free_limb_space( xp_marker );
+    if( tspace )    mpi_free_limb_space( tspace );
+    return rc;
+}
+
diff --git a/crypto/mpi/mpi-scan.c b/crypto/mpi/mpi-scan.c
new file mode 100644 (file)
index 0000000..0f080fb
--- /dev/null
@@ -0,0 +1,129 @@
+/* mpi-scan.c  -  MPI functions
+ * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+/****************
+ * Scan through an mpi and return byte for byte. a -1 is returned to indicate
+ * the end of the mpi. Scanning is done from the lsb to the msb, returned
+ * values are in the range of 0 .. 255.
+ *
+ * FIXME: This code is VERY ugly!
+ */
+int
+mpi_getbyte( const MPI a, unsigned idx )
+{
+    int i, j;
+    unsigned n;
+    mpi_ptr_t ap;
+    mpi_limb_t limb;
+
+    ap = a->d;
+    for(n=0,i=0; i < a->nlimbs; i++ ) {
+       limb = ap[i];
+       for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
+           if( n == idx )
+               return (limb >> j*8) & 0xff;
+    }
+    return -1;
+}
+
+
+/****************
+ * Put a value at position IDX into A. idx counts from lsb to msb
+ */
+void
+mpi_putbyte( MPI a, unsigned idx, int xc )
+{
+    int i, j;
+    unsigned n;
+    mpi_ptr_t ap;
+    mpi_limb_t limb, c;
+
+    c = xc & 0xff;
+    ap = a->d;
+    for(n=0,i=0; i < a->alloced; i++ ) {
+       limb = ap[i];
+       for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
+           if( n == idx ) {
+             #if BYTES_PER_MPI_LIMB == 4
+               if( j == 0 )
+                   limb = (limb & 0xffffff00) | c;
+               else if( j == 1 )
+                   limb = (limb & 0xffff00ff) | (c<<8);
+               else if( j == 2 )
+                   limb = (limb & 0xff00ffff) | (c<<16);
+               else
+                   limb = (limb & 0x00ffffff) | (c<<24);
+             #elif BYTES_PER_MPI_LIMB == 8
+               if( j == 0 )
+                   limb = (limb & 0xffffffffffffff00) | c;
+               else if( j == 1 )
+                   limb = (limb & 0xffffffffffff00ff) | (c<<8);
+               else if( j == 2 )
+                   limb = (limb & 0xffffffffff00ffff) | (c<<16);
+               else if( j == 3 )
+                   limb = (limb & 0xffffffff00ffffff) | (c<<24);
+               else if( j == 4 )
+                   limb = (limb & 0xffffff00ffffffff) | (c<<32);
+               else if( j == 5 )
+                   limb = (limb & 0xffff00ffffffffff) | (c<<40);
+               else if( j == 6 )
+                   limb = (limb & 0xff00ffffffffffff) | (c<<48);
+               else
+                   limb = (limb & 0x00ffffffffffffff) | (c<<56);
+             #else
+                #error please enhance this function, its ugly - i know.
+             #endif
+               if( a->nlimbs <= i )
+                   a->nlimbs = i+1;
+               ap[i] = limb;
+               return;
+           }
+    }
+    log_bug("index out of range\n");
+}
+
+
+/****************
+ * Count the number of zerobits at the low end of A
+ */
+unsigned
+mpi_trailing_zeros( const MPI a )
+{
+    unsigned n, count = 0;
+
+    for(n=0; n < a->nlimbs; n++ ) {
+       if( a->d[n] ) {
+           unsigned nn;
+           mpi_limb_t alimb = a->d[n];
+
+           count_trailing_zeros( nn, alimb );
+           count += nn;
+           break;
+       }
+       count += BITS_PER_MPI_LIMB;
+    }
+    return count;
+
+}
+
+
diff --git a/crypto/mpi/mpicoder.c b/crypto/mpi/mpicoder.c
new file mode 100644 (file)
index 0000000..14bfcc6
--- /dev/null
@@ -0,0 +1,359 @@
+/* mpicoder.c  -  Coder for the external representation of MPIs
+ * Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+
+#define DIM(v) (sizeof(v)/sizeof((v)[0]))
+#define MAX_EXTERN_MPI_BITS 16384
+
+
+static uint8_t asn[15] = /* Object ID is 1.3.14.3.2.26 */
+  { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
+    0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 };
+
+
+MPI
+do_encode_md(const void *sha_buffer, unsigned nbits)
+{
+  int nframe = (nbits+7) / 8;
+  uint8_t *frame, *fr_pt;
+  int i = 0, n;
+  size_t asnlen = DIM(asn);
+  MPI a = MPI_NULL;
+
+  if(SHA1_DIGEST_LENGTH + asnlen + 4  > nframe )
+    printk("MPI: can't encode a %d bit MD into a %d bits frame\n",
+         (int)(SHA1_DIGEST_LENGTH*8), (int)nbits);
+
+  /* We encode the MD in this way:
+   *
+   *      0  A PAD(n bytes)   0  ASN(asnlen bytes)  MD(len bytes)
+   *
+   * PAD consists of FF bytes.
+   */
+  frame = kmalloc(nframe, GFP_KERNEL);
+  if (!frame)
+         return MPI_NULL;
+  n = 0;
+  frame[n++] = 0;
+  frame[n++] = 1; /* block type */
+  i = nframe - SHA1_DIGEST_LENGTH - asnlen -3 ;
+  
+  if(i <= 1) {
+    printk("MPI: message digest encoding failed\n");
+    kfree(frame);
+    return a;
+  }
+
+  memset( frame+n, 0xff, i ); n += i;
+  frame[n++] = 0;
+  memcpy( frame+n, &asn, asnlen ); n += asnlen;
+  memcpy( frame+n, sha_buffer, SHA1_DIGEST_LENGTH ); n += SHA1_DIGEST_LENGTH;
+  
+  i = nframe;
+  fr_pt = frame;
+
+  if (n != nframe) {
+    printk("MPI: message digest encoding failed, frame length is wrong\n");
+    kfree(frame);
+    return a;
+  }
+  
+  a = mpi_alloc( (nframe+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB );
+  mpi_set_buffer( a, frame, nframe, 0 );
+  kfree(frame);
+
+  return a;
+}
+
+
+MPI
+mpi_read_from_buffer(const void *xbuffer, unsigned *ret_nread)
+{
+  const uint8_t *buffer = xbuffer;
+  int i, j;
+  unsigned nbits, nbytes, nlimbs, nread=0;
+  mpi_limb_t a;
+  MPI val = MPI_NULL;
+
+  if( *ret_nread < 2 )
+    goto leave;
+  nbits = buffer[0] << 8 | buffer[1];
+
+  if( nbits > MAX_EXTERN_MPI_BITS ) {
+    printk("MPI: mpi too large (%u bits)\n", nbits);
+    goto leave;
+  }
+  buffer += 2;
+  nread = 2;
+
+  nbytes = (nbits+7) / 8;
+  nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
+  val = mpi_alloc( nlimbs );
+  if (!val)
+         return MPI_NULL;
+  i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
+  i %= BYTES_PER_MPI_LIMB;
+  val->nbits = nbits;
+  j= val->nlimbs = nlimbs;
+  val->sign = 0;
+  for( ; j > 0; j-- ) {
+    a = 0;
+    for(; i < BYTES_PER_MPI_LIMB; i++ ) {
+      if( ++nread > *ret_nread ) {
+       printk("MPI: mpi larger than buffer nread=%d ret_nread=%d\n", nread, *ret_nread);
+       goto leave;
+      }
+      a <<= 8;
+      a |= *buffer++;
+    }
+    i = 0;
+    val->d[j-1] = a;
+  }
+
+ leave:
+  *ret_nread = nread;
+  return val;
+}
+
+
+/****************
+ * Make an mpi from a character string.
+ */
+int
+mpi_fromstr(MPI val, const char *str)
+{
+    int hexmode=0, sign=0, prepend_zero=0, i, j, c, c1, c2;
+    unsigned nbits, nbytes, nlimbs;
+    mpi_limb_t a;
+
+    if( *str == '-' ) {
+       sign = 1;
+       str++;
+    }
+    if( *str == '0' && str[1] == 'x' )
+       hexmode = 1;
+    else
+       return -EINVAL; /* other bases are not yet supported */
+    str += 2;
+
+    nbits = strlen(str)*4;
+    if( nbits % 8 )
+       prepend_zero = 1;
+    nbytes = (nbits+7) / 8;
+    nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
+    if( val->alloced < nlimbs )
+           if (!mpi_resize(val, nlimbs ))
+                   return -ENOMEM;
+    i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
+    i %= BYTES_PER_MPI_LIMB;
+    j= val->nlimbs = nlimbs;
+    val->sign = sign;
+    for( ; j > 0; j-- ) {
+       a = 0;
+       for(; i < BYTES_PER_MPI_LIMB; i++ ) {
+           if( prepend_zero ) {
+               c1 = '0';
+               prepend_zero = 0;
+           }
+           else
+               c1 = *str++;
+           assert(c1);
+           c2 = *str++;
+           assert(c2);
+           if( c1 >= '0' && c1 <= '9' )
+               c = c1 - '0';
+           else if( c1 >= 'a' && c1 <= 'f' )
+               c = c1 - 'a' + 10;
+           else if( c1 >= 'A' && c1 <= 'F' )
+               c = c1 - 'A' + 10;
+           else {
+               mpi_clear(val);
+               return 1;
+           }
+           c <<= 4;
+           if( c2 >= '0' && c2 <= '9' )
+               c |= c2 - '0';
+           else if( c2 >= 'a' && c2 <= 'f' )
+               c |= c2 - 'a' + 10;
+           else if( c2 >= 'A' && c2 <= 'F' )
+               c |= c2 - 'A' + 10;
+           else {
+               mpi_clear(val);
+               return 1;
+           }
+           a <<= 8;
+           a |= c;
+       }
+       i = 0;
+
+       val->d[j-1] = a;
+    }
+
+    return 0;
+}
+
+
+/****************
+ * Special function to get the low 8 bytes from an mpi.
+ * This can be used as a keyid; KEYID is an 2 element array.
+ * Return the low 4 bytes.
+ */
+u32
+mpi_get_keyid( const MPI a, u32 *keyid )
+{
+#if BYTES_PER_MPI_LIMB == 4
+    if( keyid ) {
+       keyid[0] = a->nlimbs >= 2? a->d[1] : 0;
+       keyid[1] = a->nlimbs >= 1? a->d[0] : 0;
+    }
+    return a->nlimbs >= 1? a->d[0] : 0;
+#elif BYTES_PER_MPI_LIMB == 8
+    if( keyid ) {
+       keyid[0] = a->nlimbs? (u32)(a->d[0] >> 32) : 0;
+       keyid[1] = a->nlimbs? (u32)(a->d[0] & 0xffffffff) : 0;
+    }
+    return a->nlimbs? (u32)(a->d[0] & 0xffffffff) : 0;
+#else
+  #error Make this function work with other LIMB sizes
+#endif
+}
+
+
+/****************
+ * Return an allocated buffer with the MPI (msb first).
+ * NBYTES receives the length of this buffer. Caller must free the
+ * return string (This function does return a 0 byte buffer with NBYTES
+ * set to zero if the value of A is zero. If sign is not NULL, it will
+ * be set to the sign of the A.
+ */
+void *
+mpi_get_buffer( MPI a, unsigned *nbytes, int *sign )
+{
+    uint8_t *p, *buffer;
+    mpi_limb_t alimb;
+    int i;
+    unsigned int n;
+
+    if( sign )
+       *sign = a->sign;
+    *nbytes = n = a->nlimbs * BYTES_PER_MPI_LIMB;
+    if (!n)
+      n++; /* avoid zero length allocation */
+    p = buffer = kmalloc(n, GFP_KERNEL);
+
+    for(i=a->nlimbs-1; i >= 0; i-- ) {
+       alimb = a->d[i];
+#if BYTES_PER_MPI_LIMB == 4
+       *p++ = alimb >> 24;
+       *p++ = alimb >> 16;
+       *p++ = alimb >>  8;
+       *p++ = alimb      ;
+#elif BYTES_PER_MPI_LIMB == 8
+       *p++ = alimb >> 56;
+       *p++ = alimb >> 48;
+       *p++ = alimb >> 40;
+       *p++ = alimb >> 32;
+       *p++ = alimb >> 24;
+       *p++ = alimb >> 16;
+       *p++ = alimb >>  8;
+       *p++ = alimb      ;
+#else
+#error please implement for this limb size.
+#endif
+    }
+
+    /* this is sub-optimal but we need to do the shift operation
+     * because the caller has to free the returned buffer */
+    for(p=buffer; !*p && *nbytes; p++, --*nbytes )
+      ;
+    if( p != buffer )
+      memmove(buffer,p, *nbytes);
+
+    return buffer;
+}
+
+
+/****************
+ * Use BUFFER to update MPI.
+ */
+int
+mpi_set_buffer( MPI a, const void *xbuffer, unsigned nbytes, int sign )
+{
+    const uint8_t *buffer = xbuffer, *p;
+    mpi_limb_t alimb;
+    int nlimbs;
+    int i;
+
+    nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
+    if (RESIZE_IF_NEEDED(a, nlimbs) < 0)
+           return -ENOMEM;
+    a->sign = sign;
+
+    for(i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; ) {
+      #if BYTES_PER_MPI_LIMB == 4
+       alimb  = (mpi_limb_t)*p-- ;
+       alimb |= (mpi_limb_t)*p-- <<  8 ;
+       alimb |= (mpi_limb_t)*p-- << 16 ;
+       alimb |= (mpi_limb_t)*p-- << 24 ;
+      #elif BYTES_PER_MPI_LIMB == 8
+       alimb  = (mpi_limb_t)*p--       ;
+       alimb |= (mpi_limb_t)*p-- <<  8 ;
+       alimb |= (mpi_limb_t)*p-- << 16 ;
+       alimb |= (mpi_limb_t)*p-- << 24 ;
+       alimb |= (mpi_limb_t)*p-- << 32 ;
+       alimb |= (mpi_limb_t)*p-- << 40 ;
+       alimb |= (mpi_limb_t)*p-- << 48 ;
+       alimb |= (mpi_limb_t)*p-- << 56 ;
+      #else
+       #error please implement for this limb size.
+      #endif
+       a->d[i++] = alimb;
+    }
+    if( p >= buffer ) {
+      #if BYTES_PER_MPI_LIMB == 4
+       alimb  = *p--       ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- <<  8 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ;
+      #elif BYTES_PER_MPI_LIMB == 8
+       alimb  = (mpi_limb_t)*p-- ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- <<  8 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 32 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 40 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 48 ;
+       if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 56 ;
+      #else
+       #error please implement for this limb size.
+      #endif
+       a->d[i++] = alimb;
+    }
+    a->nlimbs = i;
+
+    if (i != nlimbs) {
+           printk("MPI: mpi_set_buffer: Assertion failed (%d != %d)", i, nlimbs);
+           BUG();
+    }
+    return 0;
+}
+
diff --git a/crypto/mpi/mpih-cmp.c b/crypto/mpi/mpih-cmp.c
new file mode 100644 (file)
index 0000000..0ffd64e
--- /dev/null
@@ -0,0 +1,58 @@
+/* mpihelp-sub.c  -  MPI helper functions
+ *     Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ *     Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+
+/****************
+ * Compare OP1_PTR/OP1_SIZE with OP2_PTR/OP2_SIZE.
+ * There are no restrictions on the relative sizes of
+ * the two arguments.
+ * Return 1 if OP1 > OP2, 0 if they are equal, and -1 if OP1 < OP2.
+ */
+int
+mpihelp_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size )
+{
+    mpi_size_t i;
+    mpi_limb_t op1_word, op2_word;
+
+    for( i = size - 1; i >= 0 ; i--) {
+       op1_word = op1_ptr[i];
+       op2_word = op2_ptr[i];
+       if( op1_word != op2_word )
+           goto diff;
+    }
+    return 0;
+
+  diff:
+    /* This can *not* be simplified to
+     *  op2_word - op2_word
+     * since that expression might give signed overflow.  */
+    return (op1_word > op2_word) ? 1 : -1;
+}
+
diff --git a/crypto/mpi/mpih-div.c b/crypto/mpi/mpih-div.c
new file mode 100644 (file)
index 0000000..e4e80fe
--- /dev/null
@@ -0,0 +1,534 @@
+/* mpihelp-div.c  -  MPI helper functions
+ *     Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ *     Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+#ifndef UMUL_TIME
+  #define UMUL_TIME 1
+#endif
+#ifndef UDIV_TIME
+  #define UDIV_TIME UMUL_TIME
+#endif
+
+/* FIXME: We should be using invert_limb (or invert_normalized_limb)
+ * here (not udiv_qrnnd).
+ */
+
+mpi_limb_t
+mpihelp_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+                                     mpi_limb_t divisor_limb)
+{
+    mpi_size_t i;
+    mpi_limb_t n1, n0, r;
+    int dummy;
+
+    /* Botch: Should this be handled at all?  Rely on callers? */
+    if( !dividend_size )
+       return 0;
+
+    /* If multiplication is much faster than division, and the
+     * dividend is large, pre-invert the divisor, and use
+     * only multiplications in the inner loop.
+     *
+     * This test should be read:
+     *  Does it ever help to use udiv_qrnnd_preinv?
+     *    && Does what we save compensate for the inversion overhead?
+     */
+    if( UDIV_TIME > (2 * UMUL_TIME + 6)
+       && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) {
+       int normalization_steps;
+
+       count_leading_zeros( normalization_steps, divisor_limb );
+       if( normalization_steps ) {
+           mpi_limb_t divisor_limb_inverted;
+
+           divisor_limb <<= normalization_steps;
+
+           /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB.  The
+            * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+            * most significant bit (with weight 2**N) implicit.
+            *
+            * Special case for DIVISOR_LIMB == 100...000.
+            */
+           if( !(divisor_limb << 1) )
+               divisor_limb_inverted = ~(mpi_limb_t)0;
+           else
+               udiv_qrnnd(divisor_limb_inverted, dummy,
+                          -divisor_limb, 0, divisor_limb);
+
+           n1 = dividend_ptr[dividend_size - 1];
+           r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+           /* Possible optimization:
+            * if (r == 0
+            * && divisor_limb > ((n1 << normalization_steps)
+            *                 | (dividend_ptr[dividend_size - 2] >> ...)))
+            * ...one division less...
+            */
+           for( i = dividend_size - 2; i >= 0; i--) {
+               n0 = dividend_ptr[i];
+               UDIV_QRNND_PREINV(dummy, r, r,
+                                  ((n1 << normalization_steps)
+                         | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+                         divisor_limb, divisor_limb_inverted);
+               n1 = n0;
+           }
+           UDIV_QRNND_PREINV(dummy, r, r,
+                             n1 << normalization_steps,
+                             divisor_limb, divisor_limb_inverted);
+           return r >> normalization_steps;
+       }
+       else {
+           mpi_limb_t divisor_limb_inverted;
+
+           /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB.  The
+            * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+            * most significant bit (with weight 2**N) implicit.
+            *
+            * Special case for DIVISOR_LIMB == 100...000.
+            */
+           if( !(divisor_limb << 1) )
+               divisor_limb_inverted = ~(mpi_limb_t)0;
+           else
+               udiv_qrnnd(divisor_limb_inverted, dummy,
+                           -divisor_limb, 0, divisor_limb);
+
+           i = dividend_size - 1;
+           r = dividend_ptr[i];
+
+           if( r >= divisor_limb )
+               r = 0;
+           else
+               i--;
+
+           for( ; i >= 0; i--) {
+               n0 = dividend_ptr[i];
+               UDIV_QRNND_PREINV(dummy, r, r,
+                                 n0, divisor_limb, divisor_limb_inverted);
+           }
+           return r;
+       }
+    }
+    else {
+       if( UDIV_NEEDS_NORMALIZATION ) {
+           int normalization_steps;
+
+           count_leading_zeros(normalization_steps, divisor_limb);
+           if( normalization_steps ) {
+               divisor_limb <<= normalization_steps;
+
+               n1 = dividend_ptr[dividend_size - 1];
+               r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+               /* Possible optimization:
+                * if (r == 0
+                * && divisor_limb > ((n1 << normalization_steps)
+                *                 | (dividend_ptr[dividend_size - 2] >> ...)))
+                * ...one division less...
+                */
+               for(i = dividend_size - 2; i >= 0; i--) {
+                   n0 = dividend_ptr[i];
+                   udiv_qrnnd (dummy, r, r,
+                               ((n1 << normalization_steps)
+                        | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+                        divisor_limb);
+                   n1 = n0;
+               }
+               udiv_qrnnd (dummy, r, r,
+                           n1 << normalization_steps,
+                           divisor_limb);
+               return r >> normalization_steps;
+           }
+       }
+       /* No normalization needed, either because udiv_qrnnd doesn't require
+        * it, or because DIVISOR_LIMB is already normalized.  */
+       i = dividend_size - 1;
+       r = dividend_ptr[i];
+
+       if(r >= divisor_limb)
+           r = 0;
+       else
+           i--;
+
+       for(; i >= 0; i--) {
+           n0 = dividend_ptr[i];
+           udiv_qrnnd (dummy, r, r, n0, divisor_limb);
+       }
+       return r;
+    }
+}
+
+/* Divide num (NP/NSIZE) by den (DP/DSIZE) and write
+ * the NSIZE-DSIZE least significant quotient limbs at QP
+ * and the DSIZE long remainder at NP. If QEXTRA_LIMBS is
+ * non-zero, generate that many fraction bits and append them after the
+ * other quotient limbs.
+ * Return the most significant limb of the quotient, this is always 0 or 1.
+ *
+ * Preconditions:
+ * 0. NSIZE >= DSIZE.
+ * 1. The most significant bit of the divisor must be set.
+ * 2. QP must either not overlap with the input operands at all, or
+ *    QP + DSIZE >= NP must hold true. (This means that it's
+ *    possible to put the quotient in the high part of NUM, right after the
+ *    remainder in NUM.
+ * 3. NSIZE >= DSIZE, even if QEXTRA_LIMBS is non-zero.
+ */
+
+mpi_limb_t
+mpihelp_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
+               mpi_ptr_t np, mpi_size_t nsize,
+               mpi_ptr_t dp, mpi_size_t dsize)
+{
+    mpi_limb_t most_significant_q_limb = 0;
+
+    switch(dsize) {
+      case 0:
+       /* We are asked to divide by zero, so go ahead and do it!  (To make
+          the compiler not remove this statement, return the value.)  */
+       return 1 / dsize;
+
+      case 1:
+       {
+           mpi_size_t i;
+           mpi_limb_t n1;
+           mpi_limb_t d;
+
+           d = dp[0];
+           n1 = np[nsize - 1];
+
+           if( n1 >= d ) {
+               n1 -= d;
+               most_significant_q_limb = 1;
+           }
+
+           qp += qextra_limbs;
+           for( i = nsize - 2; i >= 0; i--)
+               udiv_qrnnd( qp[i], n1, n1, np[i], d );
+           qp -= qextra_limbs;
+
+           for( i = qextra_limbs - 1; i >= 0; i-- )
+               udiv_qrnnd (qp[i], n1, n1, 0, d);
+
+           np[0] = n1;
+       }
+       break;
+
+      case 2:
+       {
+           mpi_size_t i;
+           mpi_limb_t n1, n0, n2;
+           mpi_limb_t d1, d0;
+
+           np += nsize - 2;
+           d1 = dp[1];
+           d0 = dp[0];
+           n1 = np[1];
+           n0 = np[0];
+
+           if( n1 >= d1 && (n1 > d1 || n0 >= d0) ) {
+               sub_ddmmss (n1, n0, n1, n0, d1, d0);
+               most_significant_q_limb = 1;
+           }
+
+           for( i = qextra_limbs + nsize - 2 - 1; i >= 0; i-- ) {
+               mpi_limb_t q;
+               mpi_limb_t r;
+
+               if( i >= qextra_limbs )
+                   np--;
+               else
+                   np[0] = 0;
+
+               if( n1 == d1 ) {
+                   /* Q should be either 111..111 or 111..110.  Need special
+                    * treatment of this rare case as normal division would
+                    * give overflow.  */
+                   q = ~(mpi_limb_t)0;
+
+                   r = n0 + d1;
+                   if( r < d1 ) {   /* Carry in the addition? */
+                       add_ssaaaa( n1, n0, r - d0, np[0], 0, d0 );
+                       qp[i] = q;
+                       continue;
+                   }
+                   n1 = d0 - (d0 != 0?1:0);
+                   n0 = -d0;
+               }
+               else {
+                   udiv_qrnnd (q, r, n1, n0, d1);
+                   umul_ppmm (n1, n0, d0, q);
+               }
+
+               n2 = np[0];
+             q_test:
+               if( n1 > r || (n1 == r && n0 > n2) ) {
+                   /* The estimated Q was too large.  */
+                   q--;
+                   sub_ddmmss (n1, n0, n1, n0, 0, d0);
+                   r += d1;
+                   if( r >= d1 )    /* If not carry, test Q again.  */
+                       goto q_test;
+               }
+
+               qp[i] = q;
+               sub_ddmmss (n1, n0, r, n2, n1, n0);
+           }
+           np[1] = n1;
+           np[0] = n0;
+       }
+       break;
+
+      default:
+       {
+           mpi_size_t i;
+           mpi_limb_t dX, d1, n0;
+
+           np += nsize - dsize;
+           dX = dp[dsize - 1];
+           d1 = dp[dsize - 2];
+           n0 = np[dsize - 1];
+
+           if( n0 >= dX ) {
+               if(n0 > dX || mpihelp_cmp(np, dp, dsize - 1) >= 0 ) {
+                   mpihelp_sub_n(np, np, dp, dsize);
+                   n0 = np[dsize - 1];
+                   most_significant_q_limb = 1;
+               }
+           }
+
+           for( i = qextra_limbs + nsize - dsize - 1; i >= 0; i--) {
+               mpi_limb_t q;
+               mpi_limb_t n1, n2;
+               mpi_limb_t cy_limb;
+
+               if( i >= qextra_limbs ) {
+                   np--;
+                   n2 = np[dsize];
+               }
+               else {
+                   n2 = np[dsize - 1];
+                   MPN_COPY_DECR (np + 1, np, dsize - 1);
+                   np[0] = 0;
+               }
+
+               if( n0 == dX ) {
+                   /* This might over-estimate q, but it's probably not worth
+                    * the extra code here to find out.  */
+                   q = ~(mpi_limb_t)0;
+               }
+               else {
+                   mpi_limb_t r;
+
+                   udiv_qrnnd(q, r, n0, np[dsize - 1], dX);
+                   umul_ppmm(n1, n0, d1, q);
+
+                   while( n1 > r || (n1 == r && n0 > np[dsize - 2])) {
+                       q--;
+                       r += dX;
+                       if( r < dX ) /* I.e. "carry in previous addition?" */
+                           break;
+                       n1 -= n0 < d1;
+                       n0 -= d1;
+                   }
+               }
+
+               /* Possible optimization: We already have (q * n0) and (1 * n1)
+                * after the calculation of q.  Taking advantage of that, we
+                * could make this loop make two iterations less.  */
+               cy_limb = mpihelp_submul_1(np, dp, dsize, q);
+
+               if( n2 != cy_limb ) {
+                   mpihelp_add_n(np, np, dp, dsize);
+                   q--;
+               }
+
+               qp[i] = q;
+               n0 = np[dsize - 1];
+           }
+       }
+    }
+
+    return most_significant_q_limb;
+}
+
+
+/****************
+ * Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB.
+ * Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR.
+ * Return the single-limb remainder.
+ * There are no constraints on the value of the divisor.
+ *
+ * QUOT_PTR and DIVIDEND_PTR might point to the same limb.
+ */
+
+mpi_limb_t
+mpihelp_divmod_1( mpi_ptr_t quot_ptr,
+                 mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+                 mpi_limb_t divisor_limb)
+{
+    mpi_size_t i;
+    mpi_limb_t n1, n0, r;
+    int dummy;
+
+    if( !dividend_size )
+       return 0;
+
+    /* If multiplication is much faster than division, and the
+     * dividend is large, pre-invert the divisor, and use
+     * only multiplications in the inner loop.
+     *
+     * This test should be read:
+     * Does it ever help to use udiv_qrnnd_preinv?
+     * && Does what we save compensate for the inversion overhead?
+     */
+    if( UDIV_TIME > (2 * UMUL_TIME + 6)
+       && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) {
+       int normalization_steps;
+
+       count_leading_zeros( normalization_steps, divisor_limb );
+       if( normalization_steps ) {
+           mpi_limb_t divisor_limb_inverted;
+
+           divisor_limb <<= normalization_steps;
+
+           /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB.  The
+            * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+            * most significant bit (with weight 2**N) implicit.
+            */
+           /* Special case for DIVISOR_LIMB == 100...000.  */
+           if( !(divisor_limb << 1) )
+               divisor_limb_inverted = ~(mpi_limb_t)0;
+           else
+               udiv_qrnnd(divisor_limb_inverted, dummy,
+                          -divisor_limb, 0, divisor_limb);
+
+           n1 = dividend_ptr[dividend_size - 1];
+           r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+           /* Possible optimization:
+            * if (r == 0
+            * && divisor_limb > ((n1 << normalization_steps)
+            *                 | (dividend_ptr[dividend_size - 2] >> ...)))
+            * ...one division less...
+            */
+           for( i = dividend_size - 2; i >= 0; i--) {
+               n0 = dividend_ptr[i];
+               UDIV_QRNND_PREINV( quot_ptr[i + 1], r, r,
+                                  ((n1 << normalization_steps)
+                        | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+                             divisor_limb, divisor_limb_inverted);
+               n1 = n0;
+           }
+           UDIV_QRNND_PREINV( quot_ptr[0], r, r,
+                              n1 << normalization_steps,
+                              divisor_limb, divisor_limb_inverted);
+           return r >> normalization_steps;
+       }
+       else {
+           mpi_limb_t divisor_limb_inverted;
+
+           /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB.  The
+            * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+            * most significant bit (with weight 2**N) implicit.
+            */
+           /* Special case for DIVISOR_LIMB == 100...000.  */
+           if( !(divisor_limb << 1) )
+               divisor_limb_inverted = ~(mpi_limb_t) 0;
+           else
+               udiv_qrnnd(divisor_limb_inverted, dummy,
+                          -divisor_limb, 0, divisor_limb);
+
+           i = dividend_size - 1;
+           r = dividend_ptr[i];
+
+           if( r >= divisor_limb )
+               r = 0;
+           else
+               quot_ptr[i--] = 0;
+
+           for( ; i >= 0; i-- ) {
+               n0 = dividend_ptr[i];
+               UDIV_QRNND_PREINV( quot_ptr[i], r, r,
+                                  n0, divisor_limb, divisor_limb_inverted);
+           }
+           return r;
+       }
+    }
+    else {
+       if(UDIV_NEEDS_NORMALIZATION) {
+           int normalization_steps;
+
+           count_leading_zeros (normalization_steps, divisor_limb);
+           if( normalization_steps ) {
+               divisor_limb <<= normalization_steps;
+
+               n1 = dividend_ptr[dividend_size - 1];
+               r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+               /* Possible optimization:
+                * if (r == 0
+                * && divisor_limb > ((n1 << normalization_steps)
+                *                 | (dividend_ptr[dividend_size - 2] >> ...)))
+                * ...one division less...
+                */
+               for( i = dividend_size - 2; i >= 0; i--) {
+                   n0 = dividend_ptr[i];
+                   udiv_qrnnd (quot_ptr[i + 1], r, r,
+                            ((n1 << normalization_steps)
+                        | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+                               divisor_limb);
+                   n1 = n0;
+               }
+               udiv_qrnnd (quot_ptr[0], r, r,
+                           n1 << normalization_steps,
+                           divisor_limb);
+               return r >> normalization_steps;
+           }
+       }
+       /* No normalization needed, either because udiv_qrnnd doesn't require
+        * it, or because DIVISOR_LIMB is already normalized.  */
+       i = dividend_size - 1;
+       r = dividend_ptr[i];
+
+       if(r >= divisor_limb)
+           r = 0;
+       else
+           quot_ptr[i--] = 0;
+
+       for(; i >= 0; i--) {
+           n0 = dividend_ptr[i];
+           udiv_qrnnd( quot_ptr[i], r, r, n0, divisor_limb );
+       }
+       return r;
+    }
+}
+
+
diff --git a/crypto/mpi/mpih-mul.c b/crypto/mpi/mpih-mul.c
new file mode 100644 (file)
index 0000000..c4eaca7
--- /dev/null
@@ -0,0 +1,547 @@
+/* mpihelp-mul.c  -  MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 1999,
+ *               2000 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#include <linux/string.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+
+#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
+    do {                                               \
+       if( (size) < KARATSUBA_THRESHOLD )              \
+           mul_n_basecase (prodp, up, vp, size);       \
+       else                                            \
+           mul_n (prodp, up, vp, size, tspace);        \
+    } while (0);
+
+#define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \
+    do {                                           \
+       if ((size) < KARATSUBA_THRESHOLD)           \
+           mpih_sqr_n_basecase (prodp, up, size);       \
+       else                                        \
+           mpih_sqr_n (prodp, up, size, tspace);        \
+    } while (0);
+
+
+
+
+/* Multiply the natural numbers u (pointed to by UP) and v (pointed to by VP),
+ * both with SIZE limbs, and store the result at PRODP.  2 * SIZE limbs are
+ * always stored.  Return the most significant limb.
+ *
+ * Argument constraints:
+ * 1. PRODP != UP and PRODP != VP, i.e. the destination
+ *    must be distinct from the multiplier and the multiplicand.
+ *
+ *
+ * Handle simple cases with traditional multiplication.
+ *
+ * This is the most critical code of multiplication.  All multiplies rely
+ * on this, both small and huge.  Small ones arrive here immediately.  Huge
+ * ones arrive here as this is the base case for Karatsuba's recursive
+ * algorithm below.
+ */
+
+static mpi_limb_t
+mul_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up,
+                                mpi_ptr_t vp, mpi_size_t size)
+{
+    mpi_size_t i;
+    mpi_limb_t cy;
+    mpi_limb_t v_limb;
+
+    /* Multiply by the first limb in V separately, as the result can be
+     * stored (not added) to PROD.  We also avoid a loop for zeroing.  */
+    v_limb = vp[0];
+    if( v_limb <= 1 ) {
+       if( v_limb == 1 )
+           MPN_COPY( prodp, up, size );
+       else
+           MPN_ZERO( prodp, size );
+       cy = 0;
+    }
+    else
+       cy = mpihelp_mul_1( prodp, up, size, v_limb );
+
+    prodp[size] = cy;
+    prodp++;
+
+    /* For each iteration in the outer loop, multiply one limb from
+     * U with one limb from V, and add it to PROD.  */
+    for( i = 1; i < size; i++ ) {
+       v_limb = vp[i];
+       if( v_limb <= 1 ) {
+           cy = 0;
+           if( v_limb == 1 )
+              cy = mpihelp_add_n(prodp, prodp, up, size);
+       }
+       else
+           cy = mpihelp_addmul_1(prodp, up, size, v_limb);
+
+       prodp[size] = cy;
+       prodp++;
+    }
+
+    return cy;
+}
+
+
+static void
+mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
+                       mpi_size_t size, mpi_ptr_t tspace )
+{
+    if( size & 1 ) {
+      /* The size is odd, and the code below doesn't handle that.
+       * Multiply the least significant (size - 1) limbs with a recursive
+       * call, and handle the most significant limb of S1 and S2
+       * separately.
+       * A slightly faster way to do this would be to make the Karatsuba
+       * code below behave as if the size were even, and let it check for
+       * odd size in the end.  I.e., in essence move this code to the end.
+       * Doing so would save us a recursive call, and potentially make the
+       * stack grow a lot less.
+       */
+      mpi_size_t esize = size - 1;      /* even size */
+      mpi_limb_t cy_limb;
+
+      MPN_MUL_N_RECURSE( prodp, up, vp, esize, tspace );
+      cy_limb = mpihelp_addmul_1( prodp + esize, up, esize, vp[esize] );
+      prodp[esize + esize] = cy_limb;
+      cy_limb = mpihelp_addmul_1( prodp + esize, vp, size, up[esize] );
+      prodp[esize + size] = cy_limb;
+    }
+    else {
+       /* Anatolij Alekseevich Karatsuba's divide-and-conquer algorithm.
+        *
+        * Split U in two pieces, U1 and U0, such that
+        * U = U0 + U1*(B**n),
+        * and V in V1 and V0, such that
+        * V = V0 + V1*(B**n).
+        *
+        * UV is then computed recursively using the identity
+        *
+        *        2n   n          n                     n
+        * UV = (B  + B )U V  +  B (U -U )(V -V )  +  (B + 1)U V
+        *                1 1        1  0   0  1              0 0
+        *
+        * Where B = 2**BITS_PER_MP_LIMB.
+        */
+       mpi_size_t hsize = size >> 1;
+       mpi_limb_t cy;
+       int negflg;
+
+       /* Product H.      ________________  ________________
+        *                |_____U1 x V1____||____U0 x V0_____|
+        * Put result in upper part of PROD and pass low part of TSPACE
+        * as new TSPACE.
+        */
+       MPN_MUL_N_RECURSE(prodp + size, up + hsize, vp + hsize, hsize, tspace);
+
+       /* Product M.      ________________
+        *                |_(U1-U0)(V0-V1)_|
+        */
+       if( mpihelp_cmp(up + hsize, up, hsize) >= 0 ) {
+           mpihelp_sub_n(prodp, up + hsize, up, hsize);
+           negflg = 0;
+       }
+       else {
+           mpihelp_sub_n(prodp, up, up + hsize, hsize);
+           negflg = 1;
+       }
+       if( mpihelp_cmp(vp + hsize, vp, hsize) >= 0 ) {
+           mpihelp_sub_n(prodp + hsize, vp + hsize, vp, hsize);
+           negflg ^= 1;
+       }
+       else {
+           mpihelp_sub_n(prodp + hsize, vp, vp + hsize, hsize);
+           /* No change of NEGFLG.  */
+       }
+       /* Read temporary operands from low part of PROD.
+        * Put result in low part of TSPACE using upper part of TSPACE
+        * as new TSPACE.
+        */
+       MPN_MUL_N_RECURSE(tspace, prodp, prodp + hsize, hsize, tspace + size);
+
+       /* Add/copy product H. */
+       MPN_COPY (prodp + hsize, prodp + size, hsize);
+       cy = mpihelp_add_n( prodp + size, prodp + size,
+                           prodp + size + hsize, hsize);
+
+       /* Add product M (if NEGFLG M is a negative number) */
+       if(negflg)
+           cy -= mpihelp_sub_n(prodp + hsize, prodp + hsize, tspace, size);
+       else
+           cy += mpihelp_add_n(prodp + hsize, prodp + hsize, tspace, size);
+
+       /* Product L.      ________________  ________________
+        *                |________________||____U0 x V0_____|
+        * Read temporary operands from low part of PROD.
+        * Put result in low part of TSPACE using upper part of TSPACE
+        * as new TSPACE.
+        */
+       MPN_MUL_N_RECURSE(tspace, up, vp, hsize, tspace + size);
+
+       /* Add/copy Product L (twice) */
+
+       cy += mpihelp_add_n(prodp + hsize, prodp + hsize, tspace, size);
+       if( cy )
+         mpihelp_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy);
+
+       MPN_COPY(prodp, tspace, hsize);
+       cy = mpihelp_add_n(prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+       if( cy )
+           mpihelp_add_1(prodp + size, prodp + size, size, 1);
+    }
+}
+
+
+void
+mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size )
+{
+    mpi_size_t i;
+    mpi_limb_t cy_limb;
+    mpi_limb_t v_limb;
+
+    /* Multiply by the first limb in V separately, as the result can be
+     * stored (not added) to PROD.  We also avoid a loop for zeroing.  */
+    v_limb = up[0];
+    if( v_limb <= 1 ) {
+       if( v_limb == 1 )
+           MPN_COPY( prodp, up, size );
+       else
+           MPN_ZERO(prodp, size);
+       cy_limb = 0;
+    }
+    else
+       cy_limb = mpihelp_mul_1( prodp, up, size, v_limb );
+
+    prodp[size] = cy_limb;
+    prodp++;
+
+    /* For each iteration in the outer loop, multiply one limb from
+     * U with one limb from V, and add it to PROD.  */
+    for( i=1; i < size; i++) {
+       v_limb = up[i];
+       if( v_limb <= 1 ) {
+           cy_limb = 0;
+           if( v_limb == 1 )
+               cy_limb = mpihelp_add_n(prodp, prodp, up, size);
+       }
+       else
+           cy_limb = mpihelp_addmul_1(prodp, up, size, v_limb);
+
+       prodp[size] = cy_limb;
+       prodp++;
+    }
+}
+
+
+void
+mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace)
+{
+    if( size & 1 ) {
+       /* The size is odd, and the code below doesn't handle that.
+        * Multiply the least significant (size - 1) limbs with a recursive
+        * call, and handle the most significant limb of S1 and S2
+        * separately.
+        * A slightly faster way to do this would be to make the Karatsuba
+        * code below behave as if the size were even, and let it check for
+        * odd size in the end.  I.e., in essence move this code to the end.
+        * Doing so would save us a recursive call, and potentially make the
+        * stack grow a lot less.
+        */
+       mpi_size_t esize = size - 1;       /* even size */
+       mpi_limb_t cy_limb;
+
+       MPN_SQR_N_RECURSE( prodp, up, esize, tspace );
+       cy_limb = mpihelp_addmul_1( prodp + esize, up, esize, up[esize] );
+       prodp[esize + esize] = cy_limb;
+       cy_limb = mpihelp_addmul_1( prodp + esize, up, size, up[esize] );
+
+       prodp[esize + size] = cy_limb;
+    }
+    else {
+       mpi_size_t hsize = size >> 1;
+       mpi_limb_t cy;
+
+       /* Product H.      ________________  ________________
+        *                |_____U1 x U1____||____U0 x U0_____|
+        * Put result in upper part of PROD and pass low part of TSPACE
+        * as new TSPACE.
+        */
+       MPN_SQR_N_RECURSE(prodp + size, up + hsize, hsize, tspace);
+
+       /* Product M.      ________________
+        *                |_(U1-U0)(U0-U1)_|
+        */
+       if( mpihelp_cmp( up + hsize, up, hsize) >= 0 )
+           mpihelp_sub_n( prodp, up + hsize, up, hsize);
+       else
+           mpihelp_sub_n (prodp, up, up + hsize, hsize);
+
+       /* Read temporary operands from low part of PROD.
+        * Put result in low part of TSPACE using upper part of TSPACE
+        * as new TSPACE.  */
+       MPN_SQR_N_RECURSE(tspace, prodp, hsize, tspace + size);
+
+       /* Add/copy product H  */
+       MPN_COPY(prodp + hsize, prodp + size, hsize);
+       cy = mpihelp_add_n(prodp + size, prodp + size,
+                          prodp + size + hsize, hsize);
+
+       /* Add product M (if NEGFLG M is a negative number).  */
+       cy -= mpihelp_sub_n (prodp + hsize, prodp + hsize, tspace, size);
+
+       /* Product L.      ________________  ________________
+        *                |________________||____U0 x U0_____|
+        * Read temporary operands from low part of PROD.
+        * Put result in low part of TSPACE using upper part of TSPACE
+        * as new TSPACE.  */
+       MPN_SQR_N_RECURSE (tspace, up, hsize, tspace + size);
+
+       /* Add/copy Product L (twice).  */
+       cy += mpihelp_add_n (prodp + hsize, prodp + hsize, tspace, size);
+       if( cy )
+           mpihelp_add_1(prodp + hsize + size, prodp + hsize + size,
+                                                           hsize, cy);
+
+       MPN_COPY(prodp, tspace, hsize);
+       cy = mpihelp_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+       if( cy )
+           mpihelp_add_1 (prodp + size, prodp + size, size, 1);
+    }
+}
+
+
+/* This should be made into an inline function in gmp.h.  */
+int
+mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size)
+{
+    if( up == vp ) {
+       if( size < KARATSUBA_THRESHOLD )
+           mpih_sqr_n_basecase( prodp, up, size );
+       else {
+           mpi_ptr_t tspace;
+           tspace = mpi_alloc_limb_space( 2 * size );
+           if (!tspace)
+                   return -ENOMEM;
+           mpih_sqr_n( prodp, up, size, tspace );
+           mpi_free_limb_space( tspace );
+       }
+    }
+    else {
+       if( size < KARATSUBA_THRESHOLD )
+           mul_n_basecase( prodp, up, vp, size );
+       else {
+           mpi_ptr_t tspace;
+           tspace = mpi_alloc_limb_space( 2 * size );
+           if (!tspace)
+                   return -ENOMEM;
+           mul_n (prodp, up, vp, size, tspace);
+           mpi_free_limb_space( tspace );
+       }
+    }
+
+    return 0;
+}
+
+
+
+int
+mpihelp_mul_karatsuba_case( mpi_ptr_t prodp,
+                           mpi_ptr_t up, mpi_size_t usize,
+                           mpi_ptr_t vp, mpi_size_t vsize,
+                           struct karatsuba_ctx *ctx )
+{
+    mpi_limb_t cy;
+
+    if( !ctx->tspace || ctx->tspace_size < vsize ) {
+       if( ctx->tspace )
+           mpi_free_limb_space( ctx->tspace );
+       ctx->tspace = mpi_alloc_limb_space( 2 * vsize);
+       if (!ctx->tspace)
+               return -ENOMEM;
+       ctx->tspace_size = vsize;
+    }
+
+    MPN_MUL_N_RECURSE( prodp, up, vp, vsize, ctx->tspace );
+
+    prodp += vsize;
+    up += vsize;
+    usize -= vsize;
+    if( usize >= vsize ) {
+       if( !ctx->tp || ctx->tp_size < vsize ) {
+           if( ctx->tp )
+               mpi_free_limb_space( ctx->tp );
+           ctx->tp = mpi_alloc_limb_space( 2 * vsize );
+           if (!ctx->tp) {
+                   if( ctx->tspace )
+                           mpi_free_limb_space( ctx->tspace );
+                   ctx->tspace = NULL;
+                   return -ENOMEM;
+           }
+           ctx->tp_size = vsize;
+       }
+
+       do {
+           MPN_MUL_N_RECURSE( ctx->tp, up, vp, vsize, ctx->tspace );
+           cy = mpihelp_add_n( prodp, prodp, ctx->tp, vsize );
+           mpihelp_add_1( prodp + vsize, ctx->tp + vsize, vsize, cy );
+           prodp += vsize;
+           up += vsize;
+           usize -= vsize;
+       } while( usize >= vsize );
+    }
+
+    if( usize ) {
+       if( usize < KARATSUBA_THRESHOLD ) {
+               mpi_limb_t tmp;
+               if (mpihelp_mul( ctx->tspace, vp, vsize, up, usize, &tmp) < 0)
+                       return -ENOMEM;
+       }
+       else {
+           if( !ctx->next ) {
+               ctx->next = kmalloc( sizeof *ctx, GFP_KERNEL );
+               if (!ctx->next)
+                       return -ENOMEM;
+               memset(ctx->next, 0, sizeof(ctx));
+           }
+           if (mpihelp_mul_karatsuba_case( ctx->tspace,
+                                           vp, vsize,
+                                           up, usize,
+                                           ctx->next ) < 0)
+                   return -ENOMEM;
+       }
+
+       cy = mpihelp_add_n( prodp, prodp, ctx->tspace, vsize);
+       mpihelp_add_1( prodp + vsize, ctx->tspace + vsize, usize, cy );
+    }
+
+    return 0;
+}
+
+
+void
+mpihelp_release_karatsuba_ctx( struct karatsuba_ctx *ctx )
+{
+    struct karatsuba_ctx *ctx2;
+
+    if( ctx->tp )
+       mpi_free_limb_space( ctx->tp );
+    if( ctx->tspace )
+       mpi_free_limb_space( ctx->tspace );
+    for( ctx=ctx->next; ctx; ctx = ctx2 ) {
+       ctx2 = ctx->next;
+       if( ctx->tp )
+           mpi_free_limb_space( ctx->tp );
+       if( ctx->tspace )
+           mpi_free_limb_space( ctx->tspace );
+       kfree( ctx );
+    }
+}
+
+/* Multiply the natural numbers u (pointed to by UP, with USIZE limbs)
+ * and v (pointed to by VP, with VSIZE limbs), and store the result at
+ * PRODP.  USIZE + VSIZE limbs are always stored, but if the input
+ * operands are normalized.  Return the most significant limb of the
+ * result.
+ *
+ * NOTE: The space pointed to by PRODP is overwritten before finished
+ * with U and V, so overlap is an error.
+ *
+ * Argument constraints:
+ * 1. USIZE >= VSIZE.
+ * 2. PRODP != UP and PRODP != VP, i.e. the destination
+ *    must be distinct from the multiplier and the multiplicand.
+ */
+
+int
+mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
+            mpi_ptr_t vp, mpi_size_t vsize,
+            mpi_limb_t *_result)
+{
+    mpi_ptr_t prod_endp = prodp + usize + vsize - 1;
+    mpi_limb_t cy;
+    struct karatsuba_ctx ctx;
+
+    if( vsize < KARATSUBA_THRESHOLD ) {
+       mpi_size_t i;
+       mpi_limb_t v_limb;
+
+       if( !vsize ) {
+               *_result = 0;
+               return 0;
+       }
+
+       /* Multiply by the first limb in V separately, as the result can be
+        * stored (not added) to PROD.  We also avoid a loop for zeroing.  */
+       v_limb = vp[0];
+       if( v_limb <= 1 ) {
+           if( v_limb == 1 )
+               MPN_COPY( prodp, up, usize );
+           else
+               MPN_ZERO( prodp, usize );
+           cy = 0;
+       }
+       else
+           cy = mpihelp_mul_1( prodp, up, usize, v_limb );
+
+       prodp[usize] = cy;
+       prodp++;
+
+       /* For each iteration in the outer loop, multiply one limb from
+        * U with one limb from V, and add it to PROD.  */
+       for( i = 1; i < vsize; i++ ) {
+           v_limb = vp[i];
+           if( v_limb <= 1 ) {
+               cy = 0;
+               if( v_limb == 1 )
+                  cy = mpihelp_add_n(prodp, prodp, up, usize);
+           }
+           else
+               cy = mpihelp_addmul_1(prodp, up, usize, v_limb);
+
+           prodp[usize] = cy;
+           prodp++;
+       }
+
+       *_result = cy;
+       return 0;
+    }
+
+    memset( &ctx, 0, sizeof ctx );
+    if (mpihelp_mul_karatsuba_case( prodp, up, usize, vp, vsize, &ctx ) < 0)
+           return -ENOMEM;
+    mpihelp_release_karatsuba_ctx( &ctx );
+    *_result = *prod_endp;
+    return 0;
+}
+
+
diff --git a/crypto/mpi/mpiutil.c b/crypto/mpi/mpiutil.c
new file mode 100644 (file)
index 0000000..5bec431
--- /dev/null
@@ -0,0 +1,214 @@
+/* mpiutil.ac  -  Utility functions for MPI
+ * Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "mpi-internal.h"
+
+
+/****************
+ * Note:  It was a bad idea to use the number of limbs to allocate
+ *       because on a alpha the limbs are large but we normally need
+ *       integers of n bits - So we should chnage this to bits (or bytes).
+ *
+ *       But mpi_alloc is used in a lot of places :-)
+ */
+MPI mpi_alloc(unsigned nlimbs)
+{
+       MPI a;
+
+       a = (MPI) kmalloc(sizeof *a,GFP_KERNEL);
+       if (!a)
+               return a;
+
+       if (nlimbs) {
+               a->d = mpi_alloc_limb_space(nlimbs);
+               if (!a->d) {
+                       kfree(a);
+                       return NULL;
+               }
+       }
+       else {
+               a->d = NULL;
+       }
+
+       a->alloced = nlimbs;
+       a->nlimbs = 0;
+       a->sign = 0;
+       a->flags = 0;
+       a->nbits = 0;
+       return a;
+}
+
+mpi_ptr_t mpi_alloc_limb_space( unsigned nlimbs )
+{
+    size_t len = nlimbs * sizeof(mpi_limb_t);
+
+    return kmalloc(len,GFP_KERNEL);
+}
+
+void mpi_free_limb_space( mpi_ptr_t a )
+{
+    if( !a )
+       return;
+
+    kfree(a);
+}
+
+
+void mpi_assign_limb_space(MPI a, mpi_ptr_t ap, unsigned nlimbs)
+{
+    mpi_free_limb_space(a->d);
+    a->d = ap;
+    a->alloced = nlimbs;
+}
+
+/****************
+ * Resize the array of A to NLIMBS. the additional space is cleared
+ * (set to 0) [done by m_realloc()]
+ */
+int mpi_resize(MPI a, unsigned nlimbs)
+{
+       void *p;
+
+       if (nlimbs <= a->alloced)
+               return 0; /* no need to do it */
+
+       if (a->d) {
+               p = kmalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL);
+               if (!p)
+                       return -ENOMEM;
+               memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t));
+               kfree(a->d);
+               a->d = p;
+       } else {
+               a->d = kmalloc( nlimbs * sizeof(mpi_limb_t), GFP_KERNEL);
+               if (!a->d)
+                       return -ENOMEM;
+               memset(a->d, 0, nlimbs * sizeof(mpi_limb_t) );
+       }
+       a->alloced = nlimbs;
+       return 0;
+}
+
+void mpi_clear(MPI a)
+{
+       a->nlimbs = 0;
+       a->nbits = 0;
+       a->flags = 0;
+}
+
+void mpi_free(MPI a)
+{
+       if (!a)
+               return;
+
+       if (a->flags & 4)
+               kfree(a->d);
+       else {
+               mpi_free_limb_space(a->d);
+       }
+
+       if (a->flags & ~7 )
+               printk("invalid flag value in mpi\n");
+       kfree(a);
+}
+
+
+/****************
+ * Note: This copy function should not interpret the MPI
+ *      but copy it transparently.
+ */
+int mpi_copy(MPI *copied, const MPI a )
+{
+       size_t i;
+       MPI b;
+
+       *copied = MPI_NULL;
+
+       if ( a ) {
+               b = mpi_alloc( a->nlimbs );
+               if (!b)
+                       return -ENOMEM;
+
+               b->nlimbs = a->nlimbs;
+               b->sign = a->sign;
+               b->flags  = a->flags;
+               b->nbits = a->nbits;
+
+               for (i = 0; i < b->nlimbs; i++ )
+                       b->d[i] = a->d[i];
+
+               *copied = b;
+       }
+
+       return 0;
+}
+
+
+int mpi_set(MPI w, const MPI u)
+{
+       mpi_ptr_t wp, up;
+       mpi_size_t usize = u->nlimbs;
+       int usign = u->sign;
+
+       if (RESIZE_IF_NEEDED(w, (size_t) usize) < 0)
+               return -ENOMEM;
+
+       wp = w->d;
+       up = u->d;
+       MPN_COPY(wp, up, usize);
+       w->nlimbs = usize;
+       w->nbits = u->nbits;
+       w->flags = u->flags;
+       w->sign = usign;
+       return 0;
+}
+
+
+int mpi_set_ui(MPI w, unsigned long u)
+{
+       if (RESIZE_IF_NEEDED(w, 1) < 0)
+               return -ENOMEM;
+       w->d[0] = u;
+       w->nlimbs = u? 1:0;
+       w->sign = 0;
+       w->nbits = 0;
+       w->flags = 0;
+       return 0;
+}
+
+MPI mpi_alloc_set_ui(unsigned long u)
+{
+       MPI w = mpi_alloc(1);
+       if (!w)
+               return w;
+       w->d[0] = u;
+       w->nlimbs = u? 1:0;
+       w->sign = 0;
+       return w;
+}
+
+
+void mpi_swap(MPI a, MPI b)
+{
+       struct gcry_mpi tmp;
+
+       tmp = *a; *a = *b; *b = tmp;
+}
+
diff --git a/crypto/signature/Makefile b/crypto/signature/Makefile
new file mode 100644 (file)
index 0000000..4d1042e
--- /dev/null
@@ -0,0 +1,10 @@
+#
+# Makefile for the signature checker
+#
+
+obj-y := \
+       ksign.o \
+       ksign-parse.o \
+       ksign-keyring.o \
+       ksign-publickey.o \
+       dsa.o
diff --git a/crypto/signature/dsa.c b/crypto/signature/dsa.c
new file mode 100644 (file)
index 0000000..5b5c736
--- /dev/null
@@ -0,0 +1,98 @@
+/* dsa.c  -  DSA signature algorithm
+ *     Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/crypto/mpi.h>
+#include <asm/errno.h>
+#include "local.h"
+
+/*****************************************************************************/
+/*
+ * perform DSA algorithm signature verification
+ */
+int DSA_verify(const MPI datahash, const MPI sig[], const MPI pkey[])
+{
+       MPI p, q, g, y, r, s;
+       MPI w = NULL, u1 = NULL, u2 = NULL, v = NULL;
+       MPI base[3];
+       MPI exp[3];
+       int rc;
+
+       if (!datahash ||
+           !sig[0] || !sig[1] ||
+           !pkey[0] || !pkey[1] || !pkey[2] || !pkey[3]
+           )
+               return -EINVAL;
+
+       p = pkey[0];    /* prime */
+       q = pkey[1];    /* group order */
+       g = pkey[2];    /* group generator */
+       y = pkey[3];    /* g^x mod p */
+       r = sig[0];
+       s = sig[1];
+
+       if (!(mpi_cmp_ui(r, 0) > 0 && mpi_cmp(r, q) < 0)) {
+               printk("DSA_verify assertion failed [0 < r < q]\n");
+               return -EPERM;
+       }
+
+       if (!(mpi_cmp_ui(s, 0) > 0 && mpi_cmp(s, q) < 0)) {
+               printk("DSA_verify assertion failed [0 < s < q]\n");
+               return -EPERM;
+       }
+
+       rc = -ENOMEM;
+       w  = mpi_alloc(mpi_get_nlimbs(q)); if (!w ) goto cleanup;
+       u1 = mpi_alloc(mpi_get_nlimbs(q)); if (!u1) goto cleanup;
+       u2 = mpi_alloc(mpi_get_nlimbs(q)); if (!u2) goto cleanup;
+       v  = mpi_alloc(mpi_get_nlimbs(p)); if (!v ) goto cleanup;
+
+       /* w = s^(-1) mod q */
+       if (mpi_invm(w, s, q) < 0)
+               goto cleanup;
+
+       /* u1 = (datahash * w) mod q */
+       if (mpi_mulm(u1, datahash, w, q) < 0)
+               goto cleanup;
+
+       /* u2 = r * w mod q  */
+       if (mpi_mulm(u2, r, w, q) < 0)
+               goto cleanup;
+
+       /* v =  g^u1 * y^u2 mod p mod q */
+       base[0] = g;    exp[0] = u1;
+       base[1] = y;    exp[1] = u2;
+       base[2] = NULL; exp[2] = NULL;
+
+       if (mpi_mulpowm(v, base, exp, p) < 0)
+               goto cleanup;
+
+       if (mpi_fdiv_r(v, v, q) < 0)
+               goto cleanup;
+
+       rc = mpi_cmp(v, r) == 0 ? 0 : -EPERM;
+
+ cleanup:
+       mpi_free(w);
+       mpi_free(u1);
+       mpi_free(u2);
+       mpi_free(v);
+       return rc;
+} /* end DSA_verify() */
diff --git a/crypto/signature/key.h b/crypto/signature/key.h
new file mode 100644 (file)
index 0000000..a1ecccb
--- /dev/null
@@ -0,0 +1,7 @@
+
+/* automatically generated by bin2hex */
+static unsigned char ksign_def_public_key[] __initdata =
+{
+       0x00, 0x09, 0x00, 0x00, 0x00, 0x00
+};
+
diff --git a/crypto/signature/ksign-parse.c b/crypto/signature/ksign-parse.c
new file mode 100644 (file)
index 0000000..acc2d1f
--- /dev/null
@@ -0,0 +1,609 @@
+/* parse-packet.c  - read packets
+ * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <asm/errno.h>
+#include "local.h"
+
+static inline uint32_t buffer_to_u32(const uint8_t *buffer)
+{
+       uint32_t a;
+       a =  *buffer << 24;
+       a |= buffer[1] << 16;
+       a |= buffer[2] << 8;
+       a |= buffer[3];
+       return a;
+}
+
+static inline uint16_t read_16(const uint8_t **datap)
+{
+       uint16_t a;
+       a = *(*datap)++ << 8;
+       a |= *(*datap)++;
+       return a;
+}
+
+static inline uint32_t read_32(const uint8_t **datap)
+{
+       uint32_t a;
+       a =  *(*datap)++ << 24;
+       a |= *(*datap)++ << 16;
+       a |= *(*datap)++ << 8;
+       a |= *(*datap)++;
+       return a;
+}
+
+void ksign_free_signature(struct ksign_signature *sig)
+{
+       int i;
+
+       if (!sig)
+               return;
+
+       for (i = 0; i < DSA_NSIG; i++)
+               mpi_free(sig->data[i]);
+       kfree(sig->hashed_data);
+       kfree(sig->unhashed_data);
+       kfree(sig);
+}
+
+void ksign_free_public_key(struct ksign_public_key *pk)
+{
+       int i;
+
+       if (pk) {
+               for (i = 0; i < DSA_NPKEY; i++)
+                       mpi_free(pk->pkey[i]);
+               kfree(pk);
+       }
+}
+
+void ksign_free_user_id(struct ksign_user_id *uid)
+{
+       if (uid)
+               kfree(uid);
+}
+
+/*****************************************************************************/
+/*
+ *
+ */
+static void ksign_calc_pk_keyid(struct crypto_tfm *sha1,
+                               struct ksign_public_key *pk)
+{
+       unsigned n;
+       unsigned nb[DSA_NPKEY];
+       unsigned nn[DSA_NPKEY];
+       uint8_t *pp[DSA_NPKEY];
+       uint32_t a32;
+       int i;
+       int npkey = DSA_NPKEY;
+
+       crypto_digest_init(sha1);
+
+       n = pk->version < 4 ? 8 : 6;
+       for (i = 0; i < npkey; i++) {
+               nb[i] = mpi_get_nbits(pk->pkey[i]);
+               pp[i] = mpi_get_buffer( pk->pkey[i], nn + i, NULL);
+               n += 2 + nn[i];
+       }
+
+       SHA1_putc(sha1, 0x99);     /* ctb */
+       SHA1_putc(sha1, n >> 8);   /* 2 uint8_t length header */
+       SHA1_putc(sha1, n);
+
+       if( pk->version < 4)
+               SHA1_putc(sha1, 3);
+       else
+               SHA1_putc(sha1, 4);
+
+       a32 = pk->timestamp;
+       SHA1_putc(sha1, a32 >> 24 );
+       SHA1_putc(sha1, a32 >> 16 );
+       SHA1_putc(sha1, a32 >>  8 );
+       SHA1_putc(sha1, a32 >>  0 );
+
+       if (pk->version < 4) {
+               uint16_t a16;
+
+               if( pk->expiredate )
+                       a16 = (uint16_t) ((pk->expiredate - pk->timestamp) / 86400L);
+               else
+                       a16 = 0;
+               SHA1_putc(sha1, a16 >> 8);
+               SHA1_putc(sha1, a16 >> 0);
+       }
+
+       SHA1_putc(sha1, PUBKEY_ALGO_DSA);
+
+       for (i = 0; i < npkey; i++) {
+               SHA1_putc(sha1, nb[i] >> 8);
+               SHA1_putc(sha1, nb[i]);
+               SHA1_write(sha1, pp[i], nn[i]);
+               kfree(pp[i]);
+       }
+
+} /* end ksign_calc_pk_keyid() */
+
+/*****************************************************************************/
+/*
+ * parse a user ID embedded in a signature
+ */
+static int ksign_parse_user_id(const uint8_t *datap, const uint8_t *endp,
+                              ksign_user_id_actor_t uidfnx, void *fnxdata)
+{
+       struct ksign_user_id *uid;
+       int rc = 0;
+       int n;
+
+       if (!uidfnx)
+               return 0;
+
+       n = endp - datap;
+       uid = kmalloc(sizeof(*uid) + n + 1, GFP_KERNEL);
+       if (!uid)
+               return -ENOMEM;
+       uid->len = n;
+
+       memcpy(uid->name, datap, n);
+       uid->name[n] = 0;
+
+       rc = uidfnx(uid, fnxdata);
+       if (rc == 0)
+               return rc; /* uidfnx keeps the record */
+       if (rc == 1)
+               rc = 0;
+
+       ksign_free_user_id(uid);
+       return rc;
+} /* end ksign_parse_user_id() */
+
+/*****************************************************************************/
+/*
+ * extract a public key embedded in a signature
+ */
+static int ksign_parse_key(const uint8_t *datap, const uint8_t *endp,
+                          uint8_t *hdr, int hdrlen,
+                          ksign_public_key_actor_t pkfnx, void *fnxdata)
+{
+       struct ksign_public_key *pk;
+       struct crypto_tfm *sha1_tfm;
+       unsigned long timestamp, expiredate;
+       uint8_t sha1[SHA1_DIGEST_SIZE];
+       int i, version;
+       int is_v4 = 0;
+       int rc = 0;
+
+       if (endp - datap < 12) {
+               printk("ksign: public key packet too short\n");
+               return -EBADMSG;
+       }
+
+       version = *datap++;
+       switch (version) {
+       case 4:
+               is_v4 = 1;
+       case 2:
+       case 3:
+               break;
+       default:
+               printk("ksign: public key packet with unknown version %d\n",
+                      version);
+               return -EBADMSG;
+       }
+
+       timestamp = read_32(&datap);
+       if (is_v4)
+               expiredate = 0; /* have to get it from the selfsignature */
+       else {
+               unsigned short ndays;
+               ndays = read_16(&datap);
+               if (ndays)
+                       expiredate = timestamp + ndays * 86400L;
+               else
+                       expiredate = 0;
+       }
+
+       if (*datap++ != PUBKEY_ALGO_DSA) {
+               printk("ksign: public key packet with unknown version %d\n",
+                      version);
+               return 0;
+       }
+
+       /* extract the stuff from the DSA public key */
+       pk = kmalloc(sizeof(struct ksign_public_key), GFP_KERNEL);
+       if (!pk)
+               return -ENOMEM;
+
+       memset(pk, 0, sizeof(struct ksign_public_key));
+       atomic_set(&pk->count, 1);
+       pk->timestamp   = timestamp;
+       pk->expiredate  = expiredate;
+       pk->hdrbytes    = hdrlen;
+       pk->version     = version;
+
+       for (i = 0; i < DSA_NPKEY; i++) {
+               unsigned int remaining = endp - datap;
+               pk->pkey[i] = mpi_read_from_buffer(datap, &remaining);
+               datap += remaining;
+       }
+
+       rc = -ENOMEM;
+
+       sha1_tfm = crypto_alloc_tfm2("sha1", 0, 1);
+       if (!sha1_tfm)
+               goto cleanup;
+
+       ksign_calc_pk_keyid(sha1_tfm, pk);
+       crypto_digest_final(sha1_tfm, sha1);
+       crypto_free_tfm(sha1_tfm);
+
+       pk->keyid[0] = sha1[12] << 24 | sha1[13] << 16 | sha1[14] << 8 | sha1[15];
+       pk->keyid[1] = sha1[16] << 24 | sha1[17] << 16 | sha1[18] << 8 | sha1[19];
+
+       rc = 0;
+       if (pkfnx)
+               rc = pkfnx(pk, fnxdata);
+
+ cleanup:
+       ksign_put_public_key(pk);
+       return rc;
+} /* end ksign_parse_key() */
+
+/*****************************************************************************/
+/*
+ *
+ */
+static const uint8_t *ksign_find_sig_issuer(const uint8_t *buffer)
+{
+       size_t buflen;
+       size_t n;
+       int type;
+       int seq = 0;
+
+       if (!buffer)
+               return NULL;
+
+       buflen = read_16(&buffer);
+       while (buflen) {
+               n = *buffer++; buflen--;
+               if (n == 255) {
+                       if (buflen < 4)
+                               goto too_short;
+                       n = read_32(&buffer);
+                       buflen -= 4;
+               }
+               else if (n >= 192) {
+                       if(buflen < 2)
+                               goto too_short;
+                       n = ((n - 192) << 8) + *buffer + 192;
+                       buffer++;
+                       buflen--;
+               }
+
+               if (buflen < n)
+                       goto too_short;
+
+               type = *buffer & 0x7f;
+               if (!(++seq > 0))
+                       ;
+               else if (type == SIGSUBPKT_ISSUER) { /* found */
+                       buffer++;
+                       n--;
+                       if (n > buflen || n < 8)
+                               goto too_short;
+                       return buffer;
+               }
+
+               buffer += n;
+               buflen -= n;
+       }
+
+ too_short:
+       return NULL; /* end of subpackets; not found */
+} /* end ksign_find_sig_issuer() */
+
+/*****************************************************************************/
+/*
+ * extract signature data embedded in a signature
+ */
+static int ksign_parse_signature(const uint8_t *datap, const uint8_t *endp,
+                                ksign_signature_actor_t sigfnx, void *fnxdata)
+{
+       struct ksign_signature *sig;
+       size_t n;
+       int version, is_v4 = 0;
+       int rc;
+       int i;
+
+       if (endp - datap < 16) {
+               printk("ksign: signature packet too short\n");
+               return -EBADMSG;
+       }
+
+       version = *datap++;
+       switch (version) {
+       case 4:
+               is_v4 = 1;
+       case 3:
+       case 2:
+               break;
+       default:
+               printk("ksign: signature packet with unknown version %d\n", version);
+               return 0;
+       }
+
+       /* store information */
+       sig = kmalloc(sizeof(*sig), GFP_KERNEL);
+       if (!sig)
+               return -ENOMEM;
+
+       memset(sig, 0, sizeof(*sig));
+       sig->version = version;
+
+       if (!is_v4)
+               datap++; /* ignore md5 length */
+
+       sig->sig_class = *datap++;
+       if (!is_v4) {
+               sig->timestamp = read_32(&datap);
+               sig->keyid[0] = read_32(&datap);
+               sig->keyid[1] = read_32(&datap);
+       }
+
+       rc = 0;
+       if (*datap++ != PUBKEY_ALGO_DSA) {
+               printk("ksign: ignoring non-DSA signature\n");
+               goto leave;
+       }
+       if (*datap++ != DIGEST_ALGO_SHA1) {
+               printk("ksign: ignoring non-SHA1 signature\n");
+               goto leave;
+       }
+
+       rc = -EBADMSG;
+       if (is_v4) { /* read subpackets */
+               n = read_16(&datap); /* length of hashed data */
+               if (n > 10000) {
+                       printk("ksign: signature packet: hashed data too long\n");
+                       goto leave;
+               }
+               if (n) {
+                       if ((size_t)(endp - datap) < n) {
+                               printk("ksign: signature packet: available data too short\n");
+                               goto leave;
+                       }
+                       sig->hashed_data = kmalloc(n + 2, GFP_KERNEL);
+                       if (!sig->hashed_data) {
+                               rc = -ENOMEM;
+                               goto leave;
+                       }
+                       sig->hashed_data[0] = n >> 8;
+                       sig->hashed_data[1] = n;
+                       memcpy(sig->hashed_data + 2, datap, n);
+                       datap += n;
+               }
+
+               n = read_16(&datap); /* length of unhashed data */
+               if (n > 10000) {
+                       printk("ksign: signature packet: unhashed data too long\n");
+                       goto leave;
+               }
+               if (n) {
+                       if ((size_t) (endp - datap) < n) {
+                               printk("ksign: signature packet: available data too short\n");
+                               goto leave;
+                       }
+                       sig->unhashed_data = kmalloc(n + 2, GFP_KERNEL);
+                       if (!sig->unhashed_data) {
+                               rc = -ENOMEM;
+                               goto leave;
+                       }
+                       sig->unhashed_data[0] = n >> 8;
+                       sig->unhashed_data[1] = n;
+                       memcpy(sig->unhashed_data + 2, datap, n);
+                       datap += n;
+               }
+       }
+
+       if (endp - datap < 5) { /* sanity check */
+               printk("ksign: signature packet too short\n");
+               goto leave;
+       }
+
+       sig->digest_start[0] = *datap++;
+       sig->digest_start[1] = *datap++;
+
+       if (is_v4) {
+               const uint8_t *p;
+
+               p = ksign_find_sig_issuer(sig->hashed_data);
+               if (!p)
+                       p = ksign_find_sig_issuer(sig->unhashed_data);
+               if (!p)
+                       printk("ksign: signature packet without issuer\n");
+               else {
+                       sig->keyid[0] = buffer_to_u32(p);
+                       sig->keyid[1] = buffer_to_u32(p + 4);
+               }
+       }
+
+       for (i = 0; i < DSA_NSIG; i++) {
+               size_t remaining = endp - datap;
+               sig->data[i] = mpi_read_from_buffer(datap, &remaining);
+               datap += remaining;
+       }
+
+       rc = 0;
+       if (sigfnx) {
+               rc = sigfnx(sig, fnxdata);
+               if (rc == 0)
+                       return rc; /* sigfnx keeps the signature */
+               if (rc == 1)
+                       rc = 0;
+       }
+
+ leave:
+       ksign_free_signature(sig);
+       return rc;
+} /* end ksign_parse_signature() */
+
+/*****************************************************************************/
+/*
+ * parse the next packet and call appropriate handler function for known types
+ * - returns:
+ *     0 on EOF
+ *     1 if there might be more packets
+ *     -EBADMSG if the packet is in an invalid format
+ *     -ve on other error
+ */
+static int ksign_parse_one_packet(const uint8_t **datap,
+                                 const uint8_t *endp,
+                                 ksign_signature_actor_t sigfnx,
+                                 ksign_public_key_actor_t pkfnx,
+                                 ksign_user_id_actor_t uidfnx,
+                                 void *data)
+{
+       int rc, c, ctb, pkttype, lenuint8_ts;
+       unsigned long pktlen;
+       uint8_t hdr[8];
+       int hdrlen;
+
+       /* extract the next packet and dispatch it */
+       rc = 0;
+       if (*datap >= endp)
+               goto leave;
+       ctb = *(*datap)++;
+
+       rc = -EBADMSG;
+
+       hdrlen = 0;
+       hdr[hdrlen++] = ctb;
+       if (!(ctb & 0x80)) {
+               printk("ksign: invalid packet (ctb=%02x)\n", ctb);
+               goto leave;
+       }
+
+       pktlen = 0;
+       if (ctb & 0x40) {
+               pkttype = ctb & 0x3f;
+               if (*datap >= endp) {
+                       printk("ksign: 1st length byte missing\n");
+                       goto leave;
+               }
+               c = *(*datap)++;
+               hdr[hdrlen++] = c;
+
+               if (c < 192) {
+                       pktlen = c;
+               }
+               else if (c < 224) {
+                       pktlen = (c - 192) * 256;
+                       if (*datap >= endp) {
+                               printk("ksign: 2nd length uint8_t missing\n");
+                               goto leave;
+                       }
+                       c = *(*datap)++;
+                       hdr[hdrlen++] = c;
+                       pktlen += c + 192;
+               }
+               else if (c == 255) {
+                       if (*datap + 3 >= endp) {
+                               printk("ksign: 4 uint8_t length invalid\n");
+                               goto leave;
+                       }
+                       pktlen  = (hdr[hdrlen++] = *(*datap)++ << 24    );
+                       pktlen |= (hdr[hdrlen++] = *(*datap)++ << 16    );
+                       pktlen |= (hdr[hdrlen++] = *(*datap)++ <<  8    );
+                       pktlen |= (hdr[hdrlen++] = *(*datap)++ <<  0    );
+               }
+               else {
+                       pktlen = 0;/* to indicate partial length */
+               }
+       }
+       else {
+               pkttype = (ctb >> 2) & 0xf;
+               lenuint8_ts = ((ctb & 3) == 3) ? 0 : (1 << (ctb & 3));
+               if( !lenuint8_ts ) {
+                       pktlen = 0; /* don't know the value */
+               }
+               else {
+                       if (*datap + lenuint8_ts > endp) {
+                               printk("ksign: length uint8_ts missing\n");
+                               goto leave;
+                       }
+                       for( ; lenuint8_ts; lenuint8_ts-- ) {
+                               pktlen <<= 8;
+                               pktlen |= hdr[hdrlen++] = *(*datap)++;
+                       }
+               }
+       }
+
+       if (*datap + pktlen > endp) {
+               printk("ksign: packet length longer than available data\n");
+               goto leave;
+       }
+
+       /* deal with the next packet appropriately */
+       switch (pkttype) {
+       case PKT_PUBLIC_KEY:
+               rc = ksign_parse_key(*datap, *datap + pktlen, hdr, hdrlen, pkfnx, data);
+               break;
+       case PKT_SIGNATURE:
+               rc = ksign_parse_signature(*datap, *datap + pktlen, sigfnx, data);
+               break;
+       case PKT_USER_ID:
+               rc = ksign_parse_user_id(*datap, *datap + pktlen, uidfnx, data);
+               break;
+       default:
+               rc = 0; /* unknown packet */
+               break;
+       }
+
+       *datap += pktlen;
+ leave:
+       return rc;
+} /* end ksign_parse_one_packet() */
+
+/*****************************************************************************/
+/*
+ * parse the contents of a packet buffer, passing the signature, public key and
+ * user ID to the caller's callback functions
+ */
+int ksign_parse_packets(const uint8_t *buf,
+                       size_t size,
+                       ksign_signature_actor_t sigfnx,
+                       ksign_public_key_actor_t pkfnx,
+                       ksign_user_id_actor_t uidfnx,
+                       void *data)
+{
+       const uint8_t *datap, *endp;
+       int rc;
+
+       datap = buf;
+       endp = buf + size;
+       do {
+               rc = ksign_parse_one_packet(&datap, endp,
+                                           sigfnx, pkfnx, uidfnx, data);
+       } while (rc == 0 && datap < endp);
+
+       return rc;
+} /* end ksign_parse_packets() */
diff --git a/crypto/signature/ksign-publickey.c b/crypto/signature/ksign-publickey.c
new file mode 100644 (file)
index 0000000..762e2a8
--- /dev/null
@@ -0,0 +1,19 @@
+#include "local.h"
+
+#include "key.h"
+
+static int __init ksign_init(void)
+{
+       int rc;
+
+       printk("ksign: Installing public key data\n");
+
+       rc = ksign_load_keyring_from_buffer(ksign_def_public_key,
+                                           sizeof(ksign_def_public_key));
+       if (rc < 0)
+               printk("Unable to load default keyring: error=%d\n", -rc);
+
+       return rc;
+}
+
+module_init(ksign_init)
diff --git a/crypto/signature/local.h b/crypto/signature/local.h
new file mode 100644 (file)
index 0000000..5d2fa52
--- /dev/null
@@ -0,0 +1,163 @@
+/* local.h: kernel signature checker internal defs
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ * - Derived from GnuPG packet.h - packet definitions
+ *   - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <linux/list.h>
+#include <linux/crypto.h>
+#include <linux/crypto/ksign.h>
+#include <linux/crypto/mpi.h>
+#include <asm/atomic.h>
+
+#define SHA1_DIGEST_SIZE       20
+
+#define PUBKEY_USAGE_SIG       1           /* key is good for signatures */
+#define PUBKEY_USAGE_ENC       2           /* key is good for encryption */
+
+#define PUBKEY_ALGO_DSA                17
+#define DSA_NPKEY              4       /* number of MPI's in DSA public key */
+#define DSA_NSIG               2       /* number of MPI's in DSA signature */
+
+#define DIGEST_ALGO_SHA1       2
+
+typedef enum {
+       PKT_NONE                        = 0,
+       PKT_SIGNATURE                   = 2,    /* secret key encrypted packet */
+       PKT_PUBLIC_KEY                  = 6,    /* public key */
+       PKT_USER_ID                     = 13,   /* user id packet */
+} pkttype_t;
+
+typedef enum {
+       SIGSUBPKT_TEST_CRITICAL         = -3,
+       SIGSUBPKT_NONE                  = 0,
+       SIGSUBPKT_SIG_CREATED           = 2,    /* signature creation time */
+       SIGSUBPKT_SIG_EXPIRE            = 3,    /* signature expiration time */
+       SIGSUBPKT_EXPORTABLE            = 4,    /* exportable */
+       SIGSUBPKT_TRUST                 = 5,    /* trust signature */
+       SIGSUBPKT_REGEXP                = 6,    /* regular expression */
+       SIGSUBPKT_REVOCABLE             = 7,    /* revocable */
+       SIGSUBPKT_KEY_EXPIRE            = 9,    /* key expiration time */
+       SIGSUBPKT_ARR                   = 10,   /* additional recipient request */
+       SIGSUBPKT_PREF_SYM              = 11,   /* preferred symmetric algorithms */
+       SIGSUBPKT_REV_KEY               = 12,   /* revocation key */
+       SIGSUBPKT_ISSUER                = 16,   /* issuer key ID */
+       SIGSUBPKT_NOTATION              = 20,   /* notation data */
+       SIGSUBPKT_PREF_HASH             = 21,   /* preferred hash algorithms */
+       SIGSUBPKT_PREF_COMPR            = 22,   /* preferred compression algorithms */
+       SIGSUBPKT_KS_FLAGS              = 23,   /* key server preferences */
+       SIGSUBPKT_PREF_KS               = 24,   /* preferred key server */
+       SIGSUBPKT_PRIMARY_UID           = 25,   /* primary user id */
+       SIGSUBPKT_POLICY                = 26,   /* policy URL */
+       SIGSUBPKT_KEY_FLAGS             = 27,   /* key flags */
+       SIGSUBPKT_SIGNERS_UID           = 28,   /* signer's user id */
+       SIGSUBPKT_REVOC_REASON          = 29,   /* reason for revocation */
+       SIGSUBPKT_PRIV_VERIFY_CACHE     = 101,  /* cache verification result */
+
+       SIGSUBPKT_FLAG_CRITICAL         = 128
+} sigsubpkttype_t;
+
+/*
+ * signature record
+ */
+struct ksign_signature
+{
+       uint32_t        keyid[2];               /* 64 bit keyid */
+       time_t          timestamp;              /* signature made */
+       uint8_t         version;
+       uint8_t         sig_class;              /* sig classification, append for MD calculation*/
+       uint8_t         *hashed_data;           /* all subpackets with hashed  data (v4 only) */
+       uint8_t         *unhashed_data;         /* ditto for unhashed data */
+       uint8_t         digest_start[2];        /* first 2 uint8_ts of the digest */
+       MPI             data[DSA_NSIG];
+};
+
+extern void ksign_free_signature(struct ksign_signature *sig);
+
+/*
+ * public key record
+ */
+struct ksign_public_key
+{
+       struct list_head link;
+       atomic_t        count;                  /* ref count */
+       time_t          timestamp;              /* key made */
+       time_t          expiredate;             /* expires at this date or 0 if not at all */
+       uint8_t         hdrbytes;               /* number of header bytes */
+       uint8_t         version;
+       int             is_valid;               /* key (especially subkey) is valid */
+       unsigned long   local_id;               /* internal use, valid if > 0 */
+       uint32_t        main_keyid[2];          /* keyid of the primary key */
+       uint32_t        keyid[2];               /* calculated by keyid_from_pk() */
+       MPI             pkey[DSA_NPKEY];
+};
+
+extern void ksign_free_public_key(struct ksign_public_key *pk);
+
+static inline void ksign_put_public_key(struct ksign_public_key *pk)
+{
+       if (atomic_dec_and_test(&pk->count))
+               ksign_free_public_key(pk);
+}
+
+extern int ksign_load_keyring_from_buffer(const void *buffer, size_t size);
+
+extern struct ksign_public_key *ksign_get_public_key(const uint32_t *keyid);
+
+/*
+ * user ID record
+ */
+struct ksign_user_id
+{
+       int             len;                    /* length of the name */
+       char            name[0];
+};
+
+extern void ksign_free_user_id(struct ksign_user_id *uid);
+
+/*
+ *
+ */
+typedef int (*ksign_signature_actor_t)(struct ksign_signature *, void *fnxdata);
+typedef int (*ksign_public_key_actor_t)(struct ksign_public_key *, void *fnxdata);
+typedef int (*ksign_user_id_actor_t)(struct ksign_user_id *, void *fnxdata);
+
+extern int ksign_parse_packets(const uint8_t *buf,
+                              size_t size,
+                              ksign_signature_actor_t sigfnx,
+                              ksign_public_key_actor_t pkfnx,
+                              ksign_user_id_actor_t uidfnx,
+                              void *data);
+
+extern int DSA_verify(const MPI datahash, const MPI sig[], const MPI pkey[]);
+
+/*
+ * fast access to the digest
+ * - we _know_ the data is locked into kernel memory, so we don't want to have
+ *   to kmap() it
+ */
+static inline void SHA1_putc(struct crypto_tfm *sha1, uint8_t ch)
+{
+       crypto_digest_update_kernel(sha1, &ch, 1);
+}
+
+static inline void SHA1_write(struct crypto_tfm *sha1, const void *s, size_t n)
+{
+       crypto_digest_update_kernel(sha1, s, n);
+}
index 847d2c1..d5406c3 100644 (file)
@@ -50,4 +50,5 @@ obj-$(CONFIG_ISDN)            += isdn/
 obj-$(CONFIG_MCA)              += mca/
 obj-$(CONFIG_EISA)             += eisa/
 obj-$(CONFIG_CPU_FREQ)         += cpufreq/
+obj-$(CONFIG_CRASH_DUMP)       += dump/
 obj-y                          += firmware/
index e0a313f..028da15 100644 (file)
@@ -79,7 +79,6 @@ acpi_ds_execute_arguments (
        acpi_status                     status;
        union acpi_parse_object         *op;
        struct acpi_walk_state          *walk_state;
-       union acpi_parse_object         *arg;
 
 
        ACPI_FUNCTION_TRACE ("ds_execute_arguments");
@@ -126,9 +125,7 @@ acpi_ds_execute_arguments (
 
        /* Get and init the Op created above */
 
-       arg = op->common.value.arg;
        op->common.node = node;
-       arg->common.node = node;
        acpi_ps_delete_parse_tree (op);
 
        /* Evaluate the deferred arguments */
index 56bb801..bc9e249 100644 (file)
@@ -600,7 +600,7 @@ acpi_ec_add (
        
                acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler);
 
-               kfree(ec_ecdt);
+//             kfree(ec_ecdt);
        }
 
        /* Get GPE bit assignment (EC events). */
index 56b9ce9..040acbb 100644 (file)
@@ -6126,6 +6126,9 @@ static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
   unsigned long flags;
   unsigned char Channel, TargetID, LogicalDriveNumber;
   unsigned short LogicalDeviceNumber;
+  wait_queue_t __wait;
+  
+  init_waitqueue_entry(&__wait, current);
 
   spin_lock_irqsave(&Controller->queue_lock, flags);
   while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
@@ -6308,11 +6311,18 @@ static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
                                        .SegmentByteCount =
            CommandMailbox->ControllerInfo.DataTransferSize;
          DAC960_ExecuteCommand(Command);
+         add_wait_queue(&Controller->CommandWaitQueue, &__wait);
+         set_current_state(TASK_UNINTERRUPTIBLE);
+         
          while (Controller->V2.NewControllerInformation->PhysicalScanActive)
            {
              DAC960_ExecuteCommand(Command);
-             sleep_on_timeout(&Controller->CommandWaitQueue, HZ);
+             schedule_timeout(HZ);
+             set_current_state(TASK_UNINTERRUPTIBLE);
            }
+         current->state = TASK_RUNNING;
+         remove_wait_queue(&Controller->CommandWaitQueue, &__wait);
+          
          DAC960_UserCritical("Discovery Completed\n", Controller);
        }
     }
index 2654b5b..c66498b 100644 (file)
 # kblockd threads
 #
 
-obj-y  := elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o
+obj-y  := elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o ckrm-iostub.o
 
 obj-$(CONFIG_IOSCHED_NOOP)     += noop-iosched.o
 obj-$(CONFIG_IOSCHED_AS)       += as-iosched.o
 obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o
 obj-$(CONFIG_IOSCHED_CFQ)      += cfq-iosched.o
+obj-$(CONFIG_CKRM_RES_BLKIO)   += ckrm-io.o
 obj-$(CONFIG_MAC_FLOPPY)       += swim3.o
 obj-$(CONFIG_BLK_DEV_FD)       += floppy.o
 obj-$(CONFIG_BLK_DEV_FD98)     += floppy98.o
diff --git a/drivers/block/carmel.c b/drivers/block/carmel.c
deleted file mode 100644 (file)
index 38fd6fe..0000000
+++ /dev/null
@@ -1,1763 +0,0 @@
-/*
- *  carmel.c: Driver for Promise SATA SX8 looks-like-I2O hardware
- *
- *  Copyright 2004 Red Hat, Inc.
- *
- *  Author/maintainer:  Jeff Garzik <jgarzik@pobox.com>
- *
- *  This file is subject to the terms and conditions of the GNU General Public
- *  License.  See the file "COPYING" in the main directory of this archive
- *  for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/blkdev.h>
-#include <linux/sched.h>
-#include <linux/devfs_fs_kernel.h>
-#include <linux/interrupt.h>
-#include <linux/compiler.h>
-#include <linux/workqueue.h>
-#include <linux/bitops.h>
-#include <linux/delay.h>
-#include <linux/time.h>
-#include <linux/hdreg.h>
-#include <asm/io.h>
-#include <asm/semaphore.h>
-#include <asm/uaccess.h>
-
-MODULE_AUTHOR("Jeff Garzik");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Promise SATA SX8 (carmel) block driver");
-
-#if 0
-#define CARM_DEBUG
-#define CARM_VERBOSE_DEBUG
-#else
-#undef CARM_DEBUG
-#undef CARM_VERBOSE_DEBUG
-#endif
-#undef CARM_NDEBUG
-
-#define DRV_NAME "carmel"
-#define DRV_VERSION "0.8"
-#define PFX DRV_NAME ": "
-
-#define NEXT_RESP(idx) ((idx + 1) % RMSG_Q_LEN)
-
-/* 0xf is just arbitrary, non-zero noise; this is sorta like poisoning */
-#define TAG_ENCODE(tag)        (((tag) << 16) | 0xf)
-#define TAG_DECODE(tag)        (((tag) >> 16) & 0x1f)
-#define TAG_VALID(tag) ((((tag) & 0xf) == 0xf) && (TAG_DECODE(tag) < 32))
-
-/* note: prints function name for you */
-#ifdef CARM_DEBUG
-#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
-#ifdef CARM_VERBOSE_DEBUG
-#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
-#else
-#define VPRINTK(fmt, args...)
-#endif /* CARM_VERBOSE_DEBUG */
-#else
-#define DPRINTK(fmt, args...)
-#define VPRINTK(fmt, args...)
-#endif /* CARM_DEBUG */
-
-#ifdef CARM_NDEBUG
-#define assert(expr)
-#else
-#define assert(expr) \
-        if(unlikely(!(expr))) {                                   \
-        printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
-        #expr,__FILE__,__FUNCTION__,__LINE__);          \
-        }
-#endif
-
-/* defines only for the constants which don't work well as enums */
-struct carm_host;
-
-enum {
-       /* adapter-wide limits */
-       CARM_MAX_PORTS          = 8,
-       CARM_SHM_SIZE           = (4096 << 7),
-       CARM_MINORS_PER_MAJOR   = 256 / CARM_MAX_PORTS,
-       CARM_MAX_WAIT_Q         = CARM_MAX_PORTS + 1,
-
-       /* command message queue limits */
-       CARM_MAX_REQ            = 64,          /* max command msgs per host */
-       CARM_MAX_Q              = 1,               /* one command at a time */
-       CARM_MSG_LOW_WATER      = (CARM_MAX_REQ / 4),        /* refill mark */
-
-       /* S/G limits, host-wide and per-request */
-       CARM_MAX_REQ_SG         = 32,        /* max s/g entries per request */
-       CARM_SG_BOUNDARY        = 0xffffUL,         /* s/g segment boundary */
-       CARM_MAX_HOST_SG        = 600,          /* max s/g entries per host */
-       CARM_SG_LOW_WATER       = (CARM_MAX_HOST_SG / 4),   /* re-fill mark */
-
-       /* hardware registers */
-       CARM_IHQP               = 0x1c,
-       CARM_INT_STAT           = 0x10, /* interrupt status */
-       CARM_INT_MASK           = 0x14, /* interrupt mask */
-       CARM_HMUC               = 0x18, /* host message unit control */
-       RBUF_ADDR_LO            = 0x20, /* response msg DMA buf low 32 bits */
-       RBUF_ADDR_HI            = 0x24, /* response msg DMA buf high 32 bits */
-       RBUF_BYTE_SZ            = 0x28,
-       CARM_RESP_IDX           = 0x2c,
-       CARM_CMS0               = 0x30, /* command message size reg 0 */
-       CARM_LMUC               = 0x48,
-       CARM_HMPHA              = 0x6c,
-       CARM_INITC              = 0xb5,
-
-       /* bits in CARM_INT_{STAT,MASK} */
-       INT_RESERVED            = 0xfffffff0,
-       INT_WATCHDOG            = (1 << 3),     /* watchdog timer */
-       INT_Q_OVERFLOW          = (1 << 2),     /* cmd msg q overflow */
-       INT_Q_AVAILABLE         = (1 << 1),     /* cmd msg q has free space */
-       INT_RESPONSE            = (1 << 0),     /* response msg available */
-       INT_ACK_MASK            = INT_WATCHDOG | INT_Q_OVERFLOW,
-       INT_DEF_MASK            = INT_RESERVED | INT_Q_OVERFLOW |
-                                 INT_RESPONSE,
-
-       /* command messages, and related register bits */
-       CARM_HAVE_RESP          = 0x01,
-       CARM_MSG_READ           = 1,
-       CARM_MSG_WRITE          = 2,
-       CARM_MSG_VERIFY         = 3,
-       CARM_MSG_GET_CAPACITY   = 4,
-       CARM_MSG_FLUSH          = 5,
-       CARM_MSG_IOCTL          = 6,
-       CARM_MSG_ARRAY          = 8,
-       CARM_MSG_MISC           = 9,
-       CARM_CME                = (1 << 2),
-       CARM_RME                = (1 << 1),
-       CARM_WZBC               = (1 << 0),
-       CARM_RMI                = (1 << 0),
-       CARM_Q_FULL             = (1 << 3),
-       CARM_MSG_SIZE           = 288,
-       CARM_Q_LEN              = 48,
-
-       /* CARM_MSG_IOCTL messages */
-       CARM_IOC_SCAN_CHAN      = 5,    /* scan channels for devices */
-       CARM_IOC_GET_TCQ        = 13,   /* get tcq/ncq depth */
-       CARM_IOC_SET_TCQ        = 14,   /* set tcq/ncq depth */
-
-       IOC_SCAN_CHAN_NODEV     = 0x1f,
-       IOC_SCAN_CHAN_OFFSET    = 0x40,
-
-       /* CARM_MSG_ARRAY messages */
-       CARM_ARRAY_INFO         = 0,
-
-       ARRAY_NO_EXIST          = (1 << 31),
-
-       /* response messages */
-       RMSG_SZ                 = 8,    /* sizeof(struct carm_response) */
-       RMSG_Q_LEN              = 48,   /* resp. msg list length */
-       RMSG_OK                 = 1,    /* bit indicating msg was successful */
-                                       /* length of entire resp. msg buffer */
-       RBUF_LEN                = RMSG_SZ * RMSG_Q_LEN,
-
-       PDC_SHM_SIZE            = (4096 << 7), /* length of entire h/w buffer */
-
-       /* CARM_MSG_MISC messages */
-       MISC_GET_FW_VER         = 2,
-       MISC_ALLOC_MEM          = 3,
-       MISC_SET_TIME           = 5,
-
-       /* MISC_GET_FW_VER feature bits */
-       FW_VER_4PORT            = (1 << 2), /* 1=4 ports, 0=8 ports */
-       FW_VER_NON_RAID         = (1 << 1), /* 1=non-RAID firmware, 0=RAID */
-       FW_VER_ZCR              = (1 << 0), /* zero channel RAID (whatever that is) */
-
-       /* carm_host flags */
-       FL_NON_RAID             = FW_VER_NON_RAID,
-       FL_4PORT                = FW_VER_4PORT,
-       FL_FW_VER_MASK          = (FW_VER_NON_RAID | FW_VER_4PORT),
-       FL_DAC                  = (1 << 16),
-       FL_DYN_MAJOR            = (1 << 17),
-};
-
-enum scatter_gather_types {
-       SGT_32BIT               = 0,
-       SGT_64BIT               = 1,
-};
-
-enum host_states {
-       HST_INVALID,            /* invalid state; never used */
-       HST_ALLOC_BUF,          /* setting up master SHM area */
-       HST_ERROR,              /* we never leave here */
-       HST_PORT_SCAN,          /* start dev scan */
-       HST_DEV_SCAN_START,     /* start per-device probe */
-       HST_DEV_SCAN,           /* continue per-device probe */
-       HST_DEV_ACTIVATE,       /* activate devices we found */
-       HST_PROBE_FINISHED,     /* probe is complete */
-       HST_PROBE_START,        /* initiate probe */
-       HST_SYNC_TIME,          /* tell firmware what time it is */
-       HST_GET_FW_VER,         /* get firmware version, adapter port cnt */
-};
-
-#ifdef CARM_DEBUG
-static const char *state_name[] = {
-       "HST_INVALID",
-       "HST_ALLOC_BUF",
-       "HST_ERROR",
-       "HST_PORT_SCAN",
-       "HST_DEV_SCAN_START",
-       "HST_DEV_SCAN",
-       "HST_DEV_ACTIVATE",
-       "HST_PROBE_FINISHED",
-       "HST_PROBE_START",
-       "HST_SYNC_TIME",
-       "HST_GET_FW_VER",
-};
-#endif
-
-struct carm_port {
-       unsigned int                    port_no;
-       unsigned int                    n_queued;
-       struct gendisk                  *disk;
-       struct carm_host                *host;
-
-       /* attached device characteristics */
-       u64                             capacity;
-       char                            name[41];
-       u16                             dev_geom_head;
-       u16                             dev_geom_sect;
-       u16                             dev_geom_cyl;
-};
-
-struct carm_request {
-       unsigned int                    tag;
-       int                             n_elem;
-       unsigned int                    msg_type;
-       unsigned int                    msg_subtype;
-       unsigned int                    msg_bucket;
-       struct request                  *rq;
-       struct carm_port                *port;
-       struct scatterlist              sg[CARM_MAX_REQ_SG];
-};
-
-struct carm_host {
-       unsigned long                   flags;
-       void                            *mmio;
-       void                            *shm;
-       dma_addr_t                      shm_dma;
-
-       int                             major;
-       int                             id;
-       char                            name[32];
-
-       spinlock_t                      lock;
-       struct pci_dev                  *pdev;
-       unsigned int                    state;
-       u32                             fw_ver;
-
-       request_queue_t                 *oob_q;
-       unsigned int                    n_oob;
-
-       unsigned int                    hw_sg_used;
-
-       unsigned int                    resp_idx;
-
-       unsigned int                    wait_q_prod;
-       unsigned int                    wait_q_cons;
-       request_queue_t                 *wait_q[CARM_MAX_WAIT_Q];
-
-       unsigned int                    n_msgs;
-       u64                             msg_alloc;
-       struct carm_request             req[CARM_MAX_REQ];
-       void                            *msg_base;
-       dma_addr_t                      msg_dma;
-
-       int                             cur_scan_dev;
-       unsigned long                   dev_active;
-       unsigned long                   dev_present;
-       struct carm_port                port[CARM_MAX_PORTS];
-
-       struct work_struct              fsm_task;
-
-       struct semaphore                probe_sem;
-};
-
-struct carm_response {
-       u32 ret_handle;
-       u32 status;
-}  __attribute__((packed));
-
-struct carm_msg_sg {
-       u32 start;
-       u32 len;
-}  __attribute__((packed));
-
-struct carm_msg_rw {
-       u8 type;
-       u8 id;
-       u8 sg_count;
-       u8 sg_type;
-       u32 handle;
-       u32 lba;
-       u16 lba_count;
-       u16 lba_high;
-       struct carm_msg_sg sg[32];
-}  __attribute__((packed));
-
-struct carm_msg_allocbuf {
-       u8 type;
-       u8 subtype;
-       u8 n_sg;
-       u8 sg_type;
-       u32 handle;
-       u32 addr;
-       u32 len;
-       u32 evt_pool;
-       u32 n_evt;
-       u32 rbuf_pool;
-       u32 n_rbuf;
-       u32 msg_pool;
-       u32 n_msg;
-       struct carm_msg_sg sg[8];
-}  __attribute__((packed));
-
-struct carm_msg_ioctl {
-       u8 type;
-       u8 subtype;
-       u8 array_id;
-       u8 reserved1;
-       u32 handle;
-       u32 data_addr;
-       u32 reserved2;
-}  __attribute__((packed));
-
-struct carm_msg_sync_time {
-       u8 type;
-       u8 subtype;
-       u16 reserved1;
-       u32 handle;
-       u32 reserved2;
-       u32 timestamp;
-}  __attribute__((packed));
-
-struct carm_msg_get_fw_ver {
-       u8 type;
-       u8 subtype;
-       u16 reserved1;
-       u32 handle;
-       u32 data_addr;
-       u32 reserved2;
-}  __attribute__((packed));
-
-struct carm_fw_ver {
-       u32 version;
-       u8 features;
-       u8 reserved1;
-       u16 reserved2;
-}  __attribute__((packed));
-
-struct carm_array_info {
-       u32 size;
-
-       u16 size_hi;
-       u16 stripe_size;
-
-       u32 mode;
-
-       u16 stripe_blk_sz;
-       u16 reserved1;
-
-       u16 cyl;
-       u16 head;
-
-       u16 sect;
-       u8 array_id;
-       u8 reserved2;
-
-       char name[40];
-
-       u32 array_status;
-
-       /* device list continues beyond this point? */
-}  __attribute__((packed));
-
-static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
-static void carm_remove_one (struct pci_dev *pdev);
-static int carm_bdev_ioctl(struct inode *ino, struct file *fil,
-                          unsigned int cmd, unsigned long arg);
-
-static struct pci_device_id carm_pci_tbl[] = {
-       { PCI_VENDOR_ID_PROMISE, 0x8000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_PROMISE, 0x8002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { }     /* terminate list */
-};
-MODULE_DEVICE_TABLE(pci, carm_pci_tbl);
-
-static struct pci_driver carm_driver = {
-       .name           = DRV_NAME,
-       .id_table       = carm_pci_tbl,
-       .probe          = carm_init_one,
-       .remove         = carm_remove_one,
-};
-
-static struct block_device_operations carm_bd_ops = {
-       .owner          = THIS_MODULE,
-       .ioctl          = carm_bdev_ioctl,
-};
-
-static unsigned int carm_host_id;
-static unsigned long carm_major_alloc;
-
-
-
-static int carm_bdev_ioctl(struct inode *ino, struct file *fil,
-                          unsigned int cmd, unsigned long arg)
-{
-       void __user *usermem = (void __user *) arg;
-       struct carm_port *port = ino->i_bdev->bd_disk->private_data;
-       struct hd_geometry geom;
-
-       switch (cmd) {
-       case HDIO_GETGEO:
-               if (!usermem)
-                       return -EINVAL;
-
-               geom.heads = (u8) port->dev_geom_head;
-               geom.sectors = (u8) port->dev_geom_sect;
-               geom.cylinders = port->dev_geom_cyl;
-               geom.start = get_start_sect(ino->i_bdev);
-
-               if (copy_to_user(usermem, &geom, sizeof(geom)))
-                       return -EFAULT;
-               return 0;
-
-       default:
-               break;
-       }
-
-       return -EOPNOTSUPP;
-}
-
-static const u32 msg_sizes[] = { 32, 64, 128, CARM_MSG_SIZE };
-
-static inline int carm_lookup_bucket(u32 msg_size)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(msg_sizes); i++)
-               if (msg_size <= msg_sizes[i])
-                       return i;
-       
-       return -ENOENT;
-}
-
-static void carm_init_buckets(void *mmio)
-{
-       unsigned int i;
-
-       for (i = 0; i < ARRAY_SIZE(msg_sizes); i++)
-               writel(msg_sizes[i], mmio + CARM_CMS0 + (4 * i));
-}
-
-static inline void *carm_ref_msg(struct carm_host *host,
-                                unsigned int msg_idx)
-{
-       return host->msg_base + (msg_idx * CARM_MSG_SIZE);
-}
-
-static inline dma_addr_t carm_ref_msg_dma(struct carm_host *host,
-                                         unsigned int msg_idx)
-{
-       return host->msg_dma + (msg_idx * CARM_MSG_SIZE);
-}
-
-static int carm_send_msg(struct carm_host *host,
-                        struct carm_request *crq)
-{
-       void *mmio = host->mmio;
-       u32 msg = (u32) carm_ref_msg_dma(host, crq->tag);
-       u32 cm_bucket = crq->msg_bucket;
-       u32 tmp;
-       int rc = 0;
-
-       VPRINTK("ENTER\n");
-
-       tmp = readl(mmio + CARM_HMUC);
-       if (tmp & CARM_Q_FULL) {
-#if 0
-               tmp = readl(mmio + CARM_INT_MASK);
-               tmp |= INT_Q_AVAILABLE;
-               writel(tmp, mmio + CARM_INT_MASK);
-               readl(mmio + CARM_INT_MASK);    /* flush */
-#endif
-               DPRINTK("host msg queue full\n");
-               rc = -EBUSY;
-       } else {
-               writel(msg | (cm_bucket << 1), mmio + CARM_IHQP);
-               readl(mmio + CARM_IHQP);        /* flush */
-       }
-
-       return rc;
-}
-
-static struct carm_request *carm_get_request(struct carm_host *host)
-{
-       unsigned int i;
-
-       /* obey global hardware limit on S/G entries */
-       if (host->hw_sg_used >= (CARM_MAX_HOST_SG - CARM_MAX_REQ_SG))
-               return NULL;
-
-       for (i = 0; i < CARM_MAX_Q; i++)
-               if ((host->msg_alloc & (1ULL << i)) == 0) {
-                       struct carm_request *crq = &host->req[i];
-                       crq->port = NULL;
-                       crq->n_elem = 0;
-
-                       host->msg_alloc |= (1ULL << i);
-                       host->n_msgs++;
-
-                       assert(host->n_msgs <= CARM_MAX_REQ);
-                       return crq;
-               }
-       
-       DPRINTK("no request available, returning NULL\n");
-       return NULL;
-}
-
-static int carm_put_request(struct carm_host *host, struct carm_request *crq)
-{
-       assert(crq->tag < CARM_MAX_Q);
-
-       if (unlikely((host->msg_alloc & (1ULL << crq->tag)) == 0))
-               return -EINVAL; /* tried to clear a tag that was not active */
-
-       assert(host->hw_sg_used >= crq->n_elem);
-
-       host->msg_alloc &= ~(1ULL << crq->tag);
-       host->hw_sg_used -= crq->n_elem;
-       host->n_msgs--;
-
-       return 0;
-}
-
-static struct carm_request *carm_get_special(struct carm_host *host)
-{
-       unsigned long flags;
-       struct carm_request *crq = NULL;
-       struct request *rq;
-       int tries = 5000;
-
-       while (tries-- > 0) {
-               spin_lock_irqsave(&host->lock, flags);
-               crq = carm_get_request(host);
-               spin_unlock_irqrestore(&host->lock, flags);
-
-               if (crq)
-                       break;
-               msleep(10);
-       }
-
-       if (!crq)
-               return NULL;
-
-       rq = blk_get_request(host->oob_q, WRITE /* bogus */, GFP_KERNEL);
-       if (!rq) {
-               spin_lock_irqsave(&host->lock, flags);
-               carm_put_request(host, crq);
-               spin_unlock_irqrestore(&host->lock, flags);
-               return NULL;
-       }
-
-       crq->rq = rq;
-       return crq;
-}
-
-static int carm_array_info (struct carm_host *host, unsigned int array_idx)
-{
-       struct carm_msg_ioctl *ioc;
-       unsigned int idx;
-       u32 msg_data;
-       dma_addr_t msg_dma;
-       struct carm_request *crq;
-       int rc;
-
-       crq = carm_get_special(host);
-       if (!crq) {
-               rc = -ENOMEM;
-               goto err_out;
-       }
-
-       idx = crq->tag;
-
-       ioc = carm_ref_msg(host, idx);
-       msg_dma = carm_ref_msg_dma(host, idx);
-       msg_data = (u32) (msg_dma + sizeof(struct carm_array_info));
-
-       crq->msg_type = CARM_MSG_ARRAY;
-       crq->msg_subtype = CARM_ARRAY_INFO;
-       rc = carm_lookup_bucket(sizeof(struct carm_msg_ioctl) +
-                               sizeof(struct carm_array_info));
-       BUG_ON(rc < 0);
-       crq->msg_bucket = (u32) rc;
-
-       memset(ioc, 0, sizeof(*ioc));
-       ioc->type       = CARM_MSG_ARRAY;
-       ioc->subtype    = CARM_ARRAY_INFO;
-       ioc->array_id   = (u8) array_idx;
-       ioc->handle     = cpu_to_le32(TAG_ENCODE(idx));
-       ioc->data_addr  = cpu_to_le32(msg_data);
-
-       spin_lock_irq(&host->lock);
-       assert(host->state == HST_DEV_SCAN_START ||
-              host->state == HST_DEV_SCAN);
-       spin_unlock_irq(&host->lock);
-
-       DPRINTK("blk_insert_request, tag == %u\n", idx);
-       blk_insert_request(host->oob_q, crq->rq, 1, crq, 0);
-
-       return 0;
-
-err_out:
-       spin_lock_irq(&host->lock);
-       host->state = HST_ERROR;
-       spin_unlock_irq(&host->lock);
-       return rc;
-}
-
-typedef unsigned int (*carm_sspc_t)(struct carm_host *, unsigned int, void *);
-
-static int carm_send_special (struct carm_host *host, carm_sspc_t func)
-{
-       struct carm_request *crq;
-       struct carm_msg_ioctl *ioc;
-       void *mem;
-       unsigned int idx, msg_size;
-       int rc;
-
-       crq = carm_get_special(host);
-       if (!crq)
-               return -ENOMEM;
-
-       idx = crq->tag;
-
-       mem = carm_ref_msg(host, idx);
-
-       msg_size = func(host, idx, mem);
-
-       ioc = mem;
-       crq->msg_type = ioc->type;
-       crq->msg_subtype = ioc->subtype;
-       rc = carm_lookup_bucket(msg_size);
-       BUG_ON(rc < 0);
-       crq->msg_bucket = (u32) rc;
-
-       DPRINTK("blk_insert_request, tag == %u\n", idx);
-       blk_insert_request(host->oob_q, crq->rq, 1, crq, 0);
-
-       return 0;
-}
-
-static unsigned int carm_fill_sync_time(struct carm_host *host,
-                                       unsigned int idx, void *mem)
-{
-       struct timeval tv;
-       struct carm_msg_sync_time *st = mem;
-
-       do_gettimeofday(&tv);
-
-       memset(st, 0, sizeof(*st));
-       st->type        = CARM_MSG_MISC;
-       st->subtype     = MISC_SET_TIME;
-       st->handle      = cpu_to_le32(TAG_ENCODE(idx));
-       st->timestamp   = cpu_to_le32(tv.tv_sec);
-
-       return sizeof(struct carm_msg_sync_time);
-}
-
-static unsigned int carm_fill_alloc_buf(struct carm_host *host,
-                                       unsigned int idx, void *mem)
-{
-       struct carm_msg_allocbuf *ab = mem;
-
-       memset(ab, 0, sizeof(*ab));
-       ab->type        = CARM_MSG_MISC;
-       ab->subtype     = MISC_ALLOC_MEM;
-       ab->handle      = cpu_to_le32(TAG_ENCODE(idx));
-       ab->n_sg        = 1;
-       ab->sg_type     = SGT_32BIT;
-       ab->addr        = cpu_to_le32(host->shm_dma + (PDC_SHM_SIZE >> 1));
-       ab->len         = cpu_to_le32(PDC_SHM_SIZE >> 1);
-       ab->evt_pool    = cpu_to_le32(host->shm_dma + (16 * 1024));
-       ab->n_evt       = cpu_to_le32(1024);
-       ab->rbuf_pool   = cpu_to_le32(host->shm_dma);
-       ab->n_rbuf      = cpu_to_le32(RMSG_Q_LEN);
-       ab->msg_pool    = cpu_to_le32(host->shm_dma + RBUF_LEN);
-       ab->n_msg       = cpu_to_le32(CARM_Q_LEN);
-       ab->sg[0].start = cpu_to_le32(host->shm_dma + (PDC_SHM_SIZE >> 1));
-       ab->sg[0].len   = cpu_to_le32(65536);
-
-       return sizeof(struct carm_msg_allocbuf);
-}
-
-static unsigned int carm_fill_scan_channels(struct carm_host *host,
-                                           unsigned int idx, void *mem)
-{
-       struct carm_msg_ioctl *ioc = mem;
-       u32 msg_data = (u32) (carm_ref_msg_dma(host, idx) +
-                             IOC_SCAN_CHAN_OFFSET);
-
-       memset(ioc, 0, sizeof(*ioc));
-       ioc->type       = CARM_MSG_IOCTL;
-       ioc->subtype    = CARM_IOC_SCAN_CHAN;
-       ioc->handle     = cpu_to_le32(TAG_ENCODE(idx));
-       ioc->data_addr  = cpu_to_le32(msg_data);
-
-       /* fill output data area with "no device" default values */
-       mem += IOC_SCAN_CHAN_OFFSET;
-       memset(mem, IOC_SCAN_CHAN_NODEV, CARM_MAX_PORTS);
-
-       return IOC_SCAN_CHAN_OFFSET + CARM_MAX_PORTS;
-}
-
-static unsigned int carm_fill_get_fw_ver(struct carm_host *host,
-                                        unsigned int idx, void *mem)
-{
-       struct carm_msg_get_fw_ver *ioc = mem;
-       u32 msg_data = (u32) (carm_ref_msg_dma(host, idx) + sizeof(*ioc));
-
-       memset(ioc, 0, sizeof(*ioc));
-       ioc->type       = CARM_MSG_MISC;
-       ioc->subtype    = MISC_GET_FW_VER;
-       ioc->handle     = cpu_to_le32(TAG_ENCODE(idx));
-       ioc->data_addr  = cpu_to_le32(msg_data);
-
-       return sizeof(struct carm_msg_get_fw_ver) +
-              sizeof(struct carm_fw_ver);
-}
-
-static inline void carm_end_request_queued(struct carm_host *host,
-                                          struct carm_request *crq,
-                                          int uptodate)
-{
-       struct request *req = crq->rq;
-       int rc;
-
-       rc = end_that_request_first(req, uptodate, req->hard_nr_sectors);
-       assert(rc == 0);
-
-       end_that_request_last(req);
-
-       rc = carm_put_request(host, crq);
-       assert(rc == 0);
-}
-
-static inline void carm_push_q (struct carm_host *host, request_queue_t *q)
-{
-       unsigned int idx = host->wait_q_prod % CARM_MAX_WAIT_Q;
-
-       blk_stop_queue(q);
-       VPRINTK("STOPPED QUEUE %p\n", q);
-
-       host->wait_q[idx] = q;
-       host->wait_q_prod++;
-       BUG_ON(host->wait_q_prod == host->wait_q_cons); /* overrun */
-}
-
-static inline request_queue_t *carm_pop_q(struct carm_host *host)
-{
-       unsigned int idx;
-
-       if (host->wait_q_prod == host->wait_q_cons)
-               return NULL;
-
-       idx = host->wait_q_cons % CARM_MAX_WAIT_Q;
-       host->wait_q_cons++;
-
-       return host->wait_q[idx];
-}
-
-static inline void carm_round_robin(struct carm_host *host)
-{
-       request_queue_t *q = carm_pop_q(host);
-       if (q) {
-               blk_start_queue(q);
-               VPRINTK("STARTED QUEUE %p\n", q);
-       }
-}
-
-static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq,
-                       int is_ok)
-{
-       carm_end_request_queued(host, crq, is_ok);
-       if (CARM_MAX_Q == 1)
-               carm_round_robin(host);
-       else if ((host->n_msgs <= CARM_MSG_LOW_WATER) &&
-                (host->hw_sg_used <= CARM_SG_LOW_WATER)) {
-               carm_round_robin(host);
-       }
-}
-
-static void carm_oob_rq_fn(request_queue_t *q)
-{
-       struct carm_host *host = q->queuedata;
-       struct carm_request *crq;
-       struct request *rq;
-       int rc;
-
-       while (1) {
-               DPRINTK("get req\n");
-               rq = elv_next_request(q);
-               if (!rq)
-                       break;
-
-               blkdev_dequeue_request(rq);
-
-               crq = rq->special;
-               assert(crq != NULL);
-               assert(crq->rq == rq);
-
-               crq->n_elem = 0;
-
-               DPRINTK("send req\n");
-               rc = carm_send_msg(host, crq);
-               if (rc) {
-                       blk_requeue_request(q, rq);
-                       carm_push_q(host, q);
-                       return;         /* call us again later, eventually */
-               }
-       }
-}
-
-static void carm_rq_fn(request_queue_t *q)
-{
-       struct carm_port *port = q->queuedata;
-       struct carm_host *host = port->host;
-       struct carm_msg_rw *msg;
-       struct carm_request *crq;
-       struct request *rq;
-       struct scatterlist *sg;
-       int writing = 0, pci_dir, i, n_elem, rc;
-       u32 tmp;
-       unsigned int msg_size;
-
-queue_one_request:
-       VPRINTK("get req\n");
-       rq = elv_next_request(q);
-       if (!rq)
-               return;
-
-       crq = carm_get_request(host);
-       if (!crq) {
-               carm_push_q(host, q);
-               return;         /* call us again later, eventually */
-       }
-       crq->rq = rq;
-
-       blkdev_dequeue_request(rq);
-
-       if (rq_data_dir(rq) == WRITE) {
-               writing = 1;
-               pci_dir = PCI_DMA_TODEVICE;
-       } else {
-               pci_dir = PCI_DMA_FROMDEVICE;
-       }
-
-       /* get scatterlist from block layer */
-       sg = &crq->sg[0];
-       n_elem = blk_rq_map_sg(q, rq, sg);
-       if (n_elem <= 0) {
-               carm_end_rq(host, crq, 0);
-               return;         /* request with no s/g entries? */
-       }
-
-       /* map scatterlist to PCI bus addresses */
-       n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir);
-       if (n_elem <= 0) {
-               carm_end_rq(host, crq, 0);
-               return;         /* request with no s/g entries? */
-       }
-       crq->n_elem = n_elem;
-       crq->port = port;
-       host->hw_sg_used += n_elem;
-
-       /*
-        * build read/write message
-        */
-
-       VPRINTK("build msg\n");
-       msg = (struct carm_msg_rw *) carm_ref_msg(host, crq->tag);
-
-       if (writing) {
-               msg->type = CARM_MSG_WRITE;
-               crq->msg_type = CARM_MSG_WRITE;
-       } else {
-               msg->type = CARM_MSG_READ;
-               crq->msg_type = CARM_MSG_READ;
-       }
-
-       msg->id         = port->port_no;
-       msg->sg_count   = n_elem;
-       msg->sg_type    = SGT_32BIT;
-       msg->handle     = cpu_to_le32(TAG_ENCODE(crq->tag));
-       msg->lba        = cpu_to_le32(rq->sector & 0xffffffff);
-       tmp             = (rq->sector >> 16) >> 16;
-       msg->lba_high   = cpu_to_le16( (u16) tmp );
-       msg->lba_count  = cpu_to_le16(rq->nr_sectors);
-
-       msg_size = sizeof(struct carm_msg_rw) - sizeof(msg->sg);
-       for (i = 0; i < n_elem; i++) {
-               struct carm_msg_sg *carm_sg = &msg->sg[i];
-               carm_sg->start = cpu_to_le32(sg_dma_address(&crq->sg[i]));
-               carm_sg->len = cpu_to_le32(sg_dma_len(&crq->sg[i]));
-               msg_size += sizeof(struct carm_msg_sg);
-       }
-
-       rc = carm_lookup_bucket(msg_size);
-       BUG_ON(rc < 0);
-       crq->msg_bucket = (u32) rc;
-
-       /*
-        * queue read/write message to hardware
-        */
-
-       VPRINTK("send msg, tag == %u\n", crq->tag);
-       rc = carm_send_msg(host, crq);
-       if (rc) {
-               carm_put_request(host, crq);
-               blk_requeue_request(q, rq);
-               carm_push_q(host, q);
-               return;         /* call us again later, eventually */
-       }
-
-       goto queue_one_request;
-}
-
-static void carm_handle_array_info(struct carm_host *host,
-                                  struct carm_request *crq, u8 *mem,
-                                  int is_ok)
-{
-       struct carm_port *port;
-       u8 *msg_data = mem + sizeof(struct carm_array_info);
-       struct carm_array_info *desc = (struct carm_array_info *) msg_data;
-       u64 lo, hi;
-       int cur_port;
-       size_t slen;
-
-       DPRINTK("ENTER\n");
-
-       carm_end_rq(host, crq, is_ok);
-
-       if (!is_ok)
-               goto out;
-       if (le32_to_cpu(desc->array_status) & ARRAY_NO_EXIST)
-               goto out;
-
-       cur_port = host->cur_scan_dev;
-
-       /* should never occur */
-       if ((cur_port < 0) || (cur_port >= CARM_MAX_PORTS)) {
-               printk(KERN_ERR PFX "BUG: cur_scan_dev==%d, array_id==%d\n",
-                      cur_port, (int) desc->array_id);
-               goto out;
-       }
-
-       port = &host->port[cur_port];
-
-       lo = (u64) le32_to_cpu(desc->size);
-       hi = (u64) le32_to_cpu(desc->size_hi);
-
-       port->capacity = lo | (hi << 32);
-       port->dev_geom_head = le16_to_cpu(desc->head);
-       port->dev_geom_sect = le16_to_cpu(desc->sect);
-       port->dev_geom_cyl = le16_to_cpu(desc->cyl);
-
-       host->dev_active |= (1 << cur_port);
-
-       strncpy(port->name, desc->name, sizeof(port->name));
-       port->name[sizeof(port->name) - 1] = 0;
-       slen = strlen(port->name);
-       while (slen && (port->name[slen - 1] == ' ')) {
-               port->name[slen - 1] = 0;
-               slen--;
-       }
-
-       printk(KERN_INFO DRV_NAME "(%s): port %u device %Lu sectors\n",
-              pci_name(host->pdev), port->port_no,
-              (unsigned long long) port->capacity);
-       printk(KERN_INFO DRV_NAME "(%s): port %u device \"%s\"\n",
-              pci_name(host->pdev), port->port_no, port->name);
-
-out:
-       assert(host->state == HST_DEV_SCAN);
-       schedule_work(&host->fsm_task);
-}
-
-static void carm_handle_scan_chan(struct carm_host *host,
-                                 struct carm_request *crq, u8 *mem,
-                                 int is_ok)
-{
-       u8 *msg_data = mem + IOC_SCAN_CHAN_OFFSET;
-       unsigned int i, dev_count = 0;
-       int new_state = HST_DEV_SCAN_START;
-
-       DPRINTK("ENTER\n");
-
-       carm_end_rq(host, crq, is_ok);
-
-       if (!is_ok) {
-               new_state = HST_ERROR;
-               goto out;
-       }
-
-       /* TODO: scan and support non-disk devices */
-       for (i = 0; i < 8; i++)
-               if (msg_data[i] == 0) { /* direct-access device (disk) */
-                       host->dev_present |= (1 << i);
-                       dev_count++;
-               }
-
-       printk(KERN_INFO DRV_NAME "(%s): found %u interesting devices\n",
-              pci_name(host->pdev), dev_count);
-
-out:
-       assert(host->state == HST_PORT_SCAN);
-       host->state = new_state;
-       schedule_work(&host->fsm_task);
-}
-
-static void carm_handle_generic(struct carm_host *host,
-                               struct carm_request *crq, int is_ok,
-                               int cur_state, int next_state)
-{
-       DPRINTK("ENTER\n");
-
-       carm_end_rq(host, crq, is_ok);
-
-       assert(host->state == cur_state);
-       if (is_ok)
-               host->state = next_state;
-       else
-               host->state = HST_ERROR;
-       schedule_work(&host->fsm_task);
-}
-
-static inline void carm_handle_rw(struct carm_host *host,
-                                 struct carm_request *crq, int is_ok)
-{
-       int pci_dir;
-
-       VPRINTK("ENTER\n");
-
-       if (rq_data_dir(crq->rq) == WRITE)
-               pci_dir = PCI_DMA_TODEVICE;
-       else
-               pci_dir = PCI_DMA_FROMDEVICE;
-
-       pci_unmap_sg(host->pdev, &crq->sg[0], crq->n_elem, pci_dir);
-
-       carm_end_rq(host, crq, is_ok);
-}
-
-static inline void carm_handle_resp(struct carm_host *host,
-                                   u32 ret_handle_le, u32 status)
-{
-       u32 handle = le32_to_cpu(ret_handle_le);
-       unsigned int msg_idx;
-       struct carm_request *crq;
-       int is_ok = (status == RMSG_OK);
-       u8 *mem;
-
-       VPRINTK("ENTER, handle == 0x%x\n", handle);
-
-       if (unlikely(!TAG_VALID(handle))) {
-               printk(KERN_ERR DRV_NAME "(%s): BUG: invalid tag 0x%x\n",
-                      pci_name(host->pdev), handle);
-               return;
-       }
-
-       msg_idx = TAG_DECODE(handle);
-       VPRINTK("tag == %u\n", msg_idx);
-
-       crq = &host->req[msg_idx];
-
-       /* fast path */
-       if (likely(crq->msg_type == CARM_MSG_READ ||
-                  crq->msg_type == CARM_MSG_WRITE)) {
-               carm_handle_rw(host, crq, is_ok);
-               return;
-       }
-
-       mem = carm_ref_msg(host, msg_idx);
-
-       switch (crq->msg_type) {
-       case CARM_MSG_IOCTL: {
-               switch (crq->msg_subtype) {
-               case CARM_IOC_SCAN_CHAN:
-                       carm_handle_scan_chan(host, crq, mem, is_ok);
-                       break;
-               default:
-                       /* unknown / invalid response */
-                       goto err_out;
-               }
-               break;
-       }
-
-       case CARM_MSG_MISC: {
-               switch (crq->msg_subtype) {
-               case MISC_ALLOC_MEM:
-                       carm_handle_generic(host, crq, is_ok,
-                                           HST_ALLOC_BUF, HST_SYNC_TIME);
-                       break;
-               case MISC_SET_TIME:
-                       carm_handle_generic(host, crq, is_ok,
-                                           HST_SYNC_TIME, HST_GET_FW_VER);
-                       break;
-               case MISC_GET_FW_VER: {
-                       struct carm_fw_ver *ver = (struct carm_fw_ver *)
-                               mem + sizeof(struct carm_msg_get_fw_ver);
-                       if (is_ok) {
-                               host->fw_ver = le32_to_cpu(ver->version);
-                               host->flags |= (ver->features & FL_FW_VER_MASK);
-                       }
-                       carm_handle_generic(host, crq, is_ok,
-                                           HST_GET_FW_VER, HST_PORT_SCAN);
-                       break;
-               }
-               default:
-                       /* unknown / invalid response */
-                       goto err_out;
-               }
-               break;
-       }
-
-       case CARM_MSG_ARRAY: {
-               switch (crq->msg_subtype) {
-               case CARM_ARRAY_INFO:
-                       carm_handle_array_info(host, crq, mem, is_ok);
-                       break;
-               default:
-                       /* unknown / invalid response */
-                       goto err_out;
-               }
-               break;
-       }
-
-       default:
-               /* unknown / invalid response */
-               goto err_out;
-       }
-
-       return;
-
-err_out:
-       printk(KERN_WARNING DRV_NAME "(%s): BUG: unhandled message type %d/%d\n",
-              pci_name(host->pdev), crq->msg_type, crq->msg_subtype);
-       carm_end_rq(host, crq, 0);
-}
-
-static inline void carm_handle_responses(struct carm_host *host)
-{
-       void *mmio = host->mmio;
-       struct carm_response *resp = (struct carm_response *) host->shm;
-       unsigned int work = 0;
-       unsigned int idx = host->resp_idx % RMSG_Q_LEN;
-
-       while (1) {
-               u32 status = le32_to_cpu(resp[idx].status);
-
-               if (status == 0xffffffff) {
-                       VPRINTK("ending response on index %u\n", idx);
-                       writel(idx << 3, mmio + CARM_RESP_IDX);
-                       break;
-               }
-
-               /* response to a message we sent */
-               else if ((status & (1 << 31)) == 0) {
-                       VPRINTK("handling msg response on index %u\n", idx);
-                       carm_handle_resp(host, resp[idx].ret_handle, status);
-                       resp[idx].status = 0xffffffff;
-               }
-
-               /* asynchronous events the hardware throws our way */
-               else if ((status & 0xff000000) == (1 << 31)) {
-                       u8 *evt_type_ptr = (u8 *) &resp[idx];
-                       u8 evt_type = *evt_type_ptr;
-                       printk(KERN_WARNING DRV_NAME "(%s): unhandled event type %d\n",
-                              pci_name(host->pdev), (int) evt_type);
-                       resp[idx].status = 0xffffffff;
-               }
-
-               idx = NEXT_RESP(idx);
-               work++;
-       }
-
-       VPRINTK("EXIT, work==%u\n", work);
-       host->resp_idx += work;
-}
-
-static irqreturn_t carm_interrupt(int irq, void *__host, struct pt_regs *regs)
-{
-       struct carm_host *host = __host;
-       void *mmio;
-       u32 mask;
-       int handled = 0;
-       unsigned long flags;
-
-       if (!host) {
-               VPRINTK("no host\n");
-               return IRQ_NONE;
-       }
-
-       spin_lock_irqsave(&host->lock, flags);
-
-       mmio = host->mmio;
-
-       /* reading should also clear interrupts */
-       mask = readl(mmio + CARM_INT_STAT);
-
-       if (mask == 0 || mask == 0xffffffff) {
-               VPRINTK("no work, mask == 0x%x\n", mask);
-               goto out;
-       }
-
-       if (mask & INT_ACK_MASK)
-               writel(mask, mmio + CARM_INT_STAT);
-
-       if (unlikely(host->state == HST_INVALID)) {
-               VPRINTK("not initialized yet, mask = 0x%x\n", mask);
-               goto out;
-       }
-
-       if (mask & CARM_HAVE_RESP) {
-               handled = 1;
-               carm_handle_responses(host);
-       }
-
-out:
-       spin_unlock_irqrestore(&host->lock, flags);
-       VPRINTK("EXIT\n");
-       return IRQ_RETVAL(handled);
-}
-
-static void carm_fsm_task (void *_data)
-{
-       struct carm_host *host = _data;
-       unsigned long flags;
-       unsigned int state;
-       int rc, i, next_dev;
-       int reschedule = 0;
-       int new_state = HST_INVALID;
-
-       spin_lock_irqsave(&host->lock, flags);
-       state = host->state;
-       spin_unlock_irqrestore(&host->lock, flags);
-
-       DPRINTK("ENTER, state == %s\n", state_name[state]);
-
-       switch (state) {
-       case HST_PROBE_START:
-               new_state = HST_ALLOC_BUF;
-               reschedule = 1;
-               break;
-
-       case HST_ALLOC_BUF:
-               rc = carm_send_special(host, carm_fill_alloc_buf);
-               if (rc) {
-                       new_state = HST_ERROR;
-                       reschedule = 1;
-               }
-               break;
-
-       case HST_SYNC_TIME:
-               rc = carm_send_special(host, carm_fill_sync_time);
-               if (rc) {
-                       new_state = HST_ERROR;
-                       reschedule = 1;
-               }
-               break;
-
-       case HST_GET_FW_VER:
-               rc = carm_send_special(host, carm_fill_get_fw_ver);
-               if (rc) {
-                       new_state = HST_ERROR;
-                       reschedule = 1;
-               }
-               break;
-
-       case HST_PORT_SCAN:
-               rc = carm_send_special(host, carm_fill_scan_channels);
-               if (rc) {
-                       new_state = HST_ERROR;
-                       reschedule = 1;
-               }
-               break;
-
-       case HST_DEV_SCAN_START:
-               host->cur_scan_dev = -1;
-               new_state = HST_DEV_SCAN;
-               reschedule = 1;
-               break;
-
-       case HST_DEV_SCAN:
-               next_dev = -1;
-               for (i = host->cur_scan_dev + 1; i < CARM_MAX_PORTS; i++)
-                       if (host->dev_present & (1 << i)) {
-                               next_dev = i;
-                               break;
-                       }
-
-               if (next_dev >= 0) {
-                       host->cur_scan_dev = next_dev;
-                       rc = carm_array_info(host, next_dev);
-                       if (rc) {
-                               new_state = HST_ERROR;
-                               reschedule = 1;
-                       }
-               } else {
-                       new_state = HST_DEV_ACTIVATE;
-                       reschedule = 1;
-               }
-               break;
-
-       case HST_DEV_ACTIVATE: {
-               int activated = 0;
-               for (i = 0; i < CARM_MAX_PORTS; i++)
-                       if (host->dev_active & (1 << i)) {
-                               struct carm_port *port = &host->port[i];
-                               struct gendisk *disk = port->disk;
-
-                               set_capacity(disk, port->capacity);
-                               add_disk(disk);
-                               activated++;
-                       }
-
-               printk(KERN_INFO DRV_NAME "(%s): %d ports activated\n",
-                      pci_name(host->pdev), activated);
-
-               new_state = HST_PROBE_FINISHED;
-               reschedule = 1;
-               break;
-       }
-
-       case HST_PROBE_FINISHED:
-               up(&host->probe_sem);
-               break;
-
-       case HST_ERROR:
-               /* FIXME: TODO */
-               break;
-
-       default:
-               /* should never occur */
-               printk(KERN_ERR PFX "BUG: unknown state %d\n", state);
-               assert(0);
-               break;
-       }
-
-       if (new_state != HST_INVALID) {
-               spin_lock_irqsave(&host->lock, flags);
-               host->state = new_state;
-               spin_unlock_irqrestore(&host->lock, flags);
-       }
-       if (reschedule)
-               schedule_work(&host->fsm_task);
-}
-
-static int carm_init_wait(void *mmio, u32 bits, unsigned int test_bit)
-{
-       unsigned int i;
-
-       for (i = 0; i < 50000; i++) {
-               u32 tmp = readl(mmio + CARM_LMUC);
-               udelay(100);
-
-               if (test_bit) {
-                       if ((tmp & bits) == bits)
-                               return 0;
-               } else {
-                       if ((tmp & bits) == 0)
-                               return 0;
-               }
-
-               cond_resched();
-       }
-
-       printk(KERN_ERR PFX "carm_init_wait timeout, bits == 0x%x, test_bit == %s\n",
-              bits, test_bit ? "yes" : "no");
-       return -EBUSY;
-}
-
-static void carm_init_responses(struct carm_host *host)
-{
-       void *mmio = host->mmio;
-       unsigned int i;
-       struct carm_response *resp = (struct carm_response *) host->shm;
-
-       for (i = 0; i < RMSG_Q_LEN; i++)
-               resp[i].status = 0xffffffff;
-
-       writel(0, mmio + CARM_RESP_IDX);
-}
-
-static int carm_init_host(struct carm_host *host)
-{
-       void *mmio = host->mmio;
-       u32 tmp;
-       u8 tmp8;
-       int rc;
-
-       DPRINTK("ENTER\n");
-
-       writel(0, mmio + CARM_INT_MASK);
-
-       tmp8 = readb(mmio + CARM_INITC);
-       if (tmp8 & 0x01) {
-               tmp8 &= ~0x01;
-               writeb(tmp8, CARM_INITC);
-               readb(mmio + CARM_INITC);       /* flush */
-
-               DPRINTK("snooze...\n");
-               msleep(5000);
-       }
-
-       tmp = readl(mmio + CARM_HMUC);
-       if (tmp & CARM_CME) {
-               DPRINTK("CME bit present, waiting\n");
-               rc = carm_init_wait(mmio, CARM_CME, 1);
-               if (rc) {
-                       DPRINTK("EXIT, carm_init_wait 1 failed\n");
-                       return rc;
-               }
-       }
-       if (tmp & CARM_RME) {
-               DPRINTK("RME bit present, waiting\n");
-               rc = carm_init_wait(mmio, CARM_RME, 1);
-               if (rc) {
-                       DPRINTK("EXIT, carm_init_wait 2 failed\n");
-                       return rc;
-               }
-       }
-
-       tmp &= ~(CARM_RME | CARM_CME);
-       writel(tmp, mmio + CARM_HMUC);
-       readl(mmio + CARM_HMUC);        /* flush */
-
-       rc = carm_init_wait(mmio, CARM_RME | CARM_CME, 0);
-       if (rc) {
-               DPRINTK("EXIT, carm_init_wait 3 failed\n");
-               return rc;
-       }
-
-       carm_init_buckets(mmio);
-
-       writel(host->shm_dma & 0xffffffff, mmio + RBUF_ADDR_LO);
-       writel((host->shm_dma >> 16) >> 16, mmio + RBUF_ADDR_HI);
-       writel(RBUF_LEN, mmio + RBUF_BYTE_SZ);
-
-       tmp = readl(mmio + CARM_HMUC);
-       tmp |= (CARM_RME | CARM_CME | CARM_WZBC);
-       writel(tmp, mmio + CARM_HMUC);
-       readl(mmio + CARM_HMUC);        /* flush */
-
-       rc = carm_init_wait(mmio, CARM_RME | CARM_CME, 1);
-       if (rc) {
-               DPRINTK("EXIT, carm_init_wait 4 failed\n");
-               return rc;
-       }
-
-       writel(0, mmio + CARM_HMPHA);
-       writel(INT_DEF_MASK, mmio + CARM_INT_MASK);
-
-       carm_init_responses(host);
-
-       /* start initialization, probing state machine */
-       spin_lock_irq(&host->lock);
-       assert(host->state == HST_INVALID);
-       host->state = HST_PROBE_START;
-       spin_unlock_irq(&host->lock);
-       schedule_work(&host->fsm_task);
-
-       DPRINTK("EXIT\n");
-       return 0;
-}
-
-static int carm_init_disks(struct carm_host *host)
-{
-       unsigned int i;
-       int rc = 0;
-
-       for (i = 0; i < CARM_MAX_PORTS; i++) {
-               struct gendisk *disk;
-               request_queue_t *q;
-               struct carm_port *port;
-
-               port = &host->port[i];
-               port->host = host;
-               port->port_no = i;
-
-               disk = alloc_disk(CARM_MINORS_PER_MAJOR);
-               if (!disk) {
-                       rc = -ENOMEM;
-                       break;
-               }
-
-               port->disk = disk;
-               sprintf(disk->disk_name, DRV_NAME "%u_%u", host->id, i);
-               sprintf(disk->devfs_name, DRV_NAME "/%u_%u", host->id, i);
-               disk->major = host->major;
-               disk->first_minor = i * CARM_MINORS_PER_MAJOR;
-               disk->fops = &carm_bd_ops;
-               disk->private_data = port;
-
-               q = blk_init_queue(carm_rq_fn, &host->lock);
-               if (!q) {
-                       rc = -ENOMEM;
-                       break;
-               }
-               disk->queue = q;
-               blk_queue_max_hw_segments(q, CARM_MAX_REQ_SG);
-               blk_queue_max_phys_segments(q, CARM_MAX_REQ_SG);
-               blk_queue_segment_boundary(q, CARM_SG_BOUNDARY);
-
-               q->queuedata = port;
-       }
-
-       return rc;
-}
-
-static void carm_free_disks(struct carm_host *host)
-{
-       unsigned int i;
-
-       for (i = 0; i < CARM_MAX_PORTS; i++) {
-               struct gendisk *disk = host->port[i].disk;
-               if (disk) {
-                       request_queue_t *q = disk->queue;
-
-                       if (disk->flags & GENHD_FL_UP)
-                               del_gendisk(disk);
-                       if (q)
-                               blk_cleanup_queue(q);
-                       put_disk(disk);
-               }
-       }
-}
-
-static int carm_init_shm(struct carm_host *host)
-{
-       host->shm = pci_alloc_consistent(host->pdev, CARM_SHM_SIZE,
-                                        &host->shm_dma);
-       if (!host->shm)
-               return -ENOMEM;
-
-       host->msg_base = host->shm + RBUF_LEN;
-       host->msg_dma = host->shm_dma + RBUF_LEN;
-
-       memset(host->shm, 0xff, RBUF_LEN);
-       memset(host->msg_base, 0, PDC_SHM_SIZE - RBUF_LEN);
-
-       return 0;
-}
-
-static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-       static unsigned int printed_version;
-       struct carm_host *host;
-       unsigned int pci_dac;
-       int rc;
-       request_queue_t *q;
-       unsigned int i;
-
-       if (!printed_version++)
-               printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
-
-       rc = pci_enable_device(pdev);
-       if (rc)
-               return rc;
-
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc)
-               goto err_out;
-
-#if IF_64BIT_DMA_IS_POSSIBLE /* grrrr... */
-       rc = pci_set_dma_mask(pdev, 0xffffffffffffffffULL);
-       if (!rc) {
-               rc = pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL);
-               if (rc) {
-                       printk(KERN_ERR DRV_NAME "(%s): consistent DMA mask failure\n",
-                               pci_name(pdev));
-                       goto err_out_regions;
-               }
-               pci_dac = 1;
-       } else {
-#endif
-               rc = pci_set_dma_mask(pdev, 0xffffffffULL);
-               if (rc) {
-                       printk(KERN_ERR DRV_NAME "(%s): DMA mask failure\n",
-                               pci_name(pdev));
-                       goto err_out_regions;
-               }
-               pci_dac = 0;
-#if IF_64BIT_DMA_IS_POSSIBLE /* grrrr... */
-       }
-#endif
-
-       host = kmalloc(sizeof(*host), GFP_KERNEL);
-       if (!host) {
-               printk(KERN_ERR DRV_NAME "(%s): memory alloc failure\n",
-                      pci_name(pdev));
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
-
-       memset(host, 0, sizeof(*host));
-       host->pdev = pdev;
-       host->flags = pci_dac ? FL_DAC : 0;
-       spin_lock_init(&host->lock);
-       INIT_WORK(&host->fsm_task, carm_fsm_task, host);
-       init_MUTEX_LOCKED(&host->probe_sem);
-
-       for (i = 0; i < ARRAY_SIZE(host->req); i++)
-               host->req[i].tag = i;
-
-       host->mmio = ioremap(pci_resource_start(pdev, 0),
-                            pci_resource_len(pdev, 0));
-       if (!host->mmio) {
-               printk(KERN_ERR DRV_NAME "(%s): MMIO alloc failure\n",
-                      pci_name(pdev));
-               rc = -ENOMEM;
-               goto err_out_kfree;
-       }
-
-       rc = carm_init_shm(host);
-       if (rc) {
-               printk(KERN_ERR DRV_NAME "(%s): DMA SHM alloc failure\n",
-                      pci_name(pdev));
-               goto err_out_iounmap;
-       }
-
-       q = blk_init_queue(carm_oob_rq_fn, &host->lock);
-       if (!q) {
-               printk(KERN_ERR DRV_NAME "(%s): OOB queue alloc failure\n",
-                      pci_name(pdev));
-               rc = -ENOMEM;
-               goto err_out_pci_free;
-       }
-       host->oob_q = q;
-       q->queuedata = host;
-
-       /*
-        * Figure out which major to use: 160, 161, or dynamic
-        */
-       if (!test_and_set_bit(0, &carm_major_alloc))
-               host->major = 160;
-       else if (!test_and_set_bit(1, &carm_major_alloc))
-               host->major = 161;
-       else
-               host->flags |= FL_DYN_MAJOR;
-
-       host->id = carm_host_id;
-       sprintf(host->name, DRV_NAME "%d", carm_host_id);
-
-       rc = register_blkdev(host->major, host->name);
-       if (rc < 0)
-               goto err_out_free_majors;
-       if (host->flags & FL_DYN_MAJOR)
-               host->major = rc;
-
-       devfs_mk_dir(DRV_NAME);
-
-       rc = carm_init_disks(host);
-       if (rc)
-               goto err_out_blkdev_disks;
-
-       pci_set_master(pdev);
-
-       rc = request_irq(pdev->irq, carm_interrupt, SA_SHIRQ, DRV_NAME, host);
-       if (rc) {
-               printk(KERN_ERR DRV_NAME "(%s): irq alloc failure\n",
-                      pci_name(pdev));
-               goto err_out_blkdev_disks;
-       }
-
-       rc = carm_init_host(host);
-       if (rc)
-               goto err_out_free_irq;
-
-       DPRINTK("waiting for probe_sem\n");
-       down(&host->probe_sem);
-
-       printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n",
-              host->name, pci_name(pdev), (int) CARM_MAX_PORTS,
-              pci_resource_start(pdev, 0), pdev->irq, host->major);
-
-       carm_host_id++;
-       pci_set_drvdata(pdev, host);
-       return 0;
-
-err_out_free_irq:
-       free_irq(pdev->irq, host);
-err_out_blkdev_disks:
-       carm_free_disks(host);
-       unregister_blkdev(host->major, host->name);
-err_out_free_majors:
-       if (host->major == 160)
-               clear_bit(0, &carm_major_alloc);
-       else if (host->major == 161)
-               clear_bit(1, &carm_major_alloc);
-       blk_cleanup_queue(host->oob_q);
-err_out_pci_free:
-       pci_free_consistent(pdev, CARM_SHM_SIZE, host->shm, host->shm_dma);
-err_out_iounmap:
-       iounmap(host->mmio);
-err_out_kfree:
-       kfree(host);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       pci_disable_device(pdev);
-       return rc;
-}
-
-static void carm_remove_one (struct pci_dev *pdev)
-{
-       struct carm_host *host = pci_get_drvdata(pdev);
-
-       if (!host) {
-               printk(KERN_ERR PFX "BUG: no host data for PCI(%s)\n",
-                      pci_name(pdev));
-               return;
-       }
-
-       free_irq(pdev->irq, host);
-       carm_free_disks(host);
-       devfs_remove(DRV_NAME);
-       unregister_blkdev(host->major, host->name);
-       if (host->major == 160)
-               clear_bit(0, &carm_major_alloc);
-       else if (host->major == 161)
-               clear_bit(1, &carm_major_alloc);
-       blk_cleanup_queue(host->oob_q);
-       pci_free_consistent(pdev, CARM_SHM_SIZE, host->shm, host->shm_dma);
-       iounmap(host->mmio);
-       kfree(host);
-       pci_release_regions(pdev);
-       pci_disable_device(pdev);
-       pci_set_drvdata(pdev, NULL);
-}
-
-static int __init carm_init(void)
-{
-       return pci_module_init(&carm_driver);
-}
-
-static void __exit carm_exit(void)
-{
-       pci_unregister_driver(&carm_driver);
-}
-
-module_init(carm_init);
-module_exit(carm_exit);
-
-
index 5509e56..c9fd23a 100644 (file)
@@ -209,7 +209,7 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
         ctlr_info_t *h = (ctlr_info_t*)data;
         drive_info_struct *drv;
        unsigned long flags;
-       unsigned int vol_sz, vol_sz_frac;
+       sector_t vol_sz, vol_sz_frac;
 
         ctlr = h->ctlr;
 
diff --git a/drivers/block/cfq-iosched-orig.c b/drivers/block/cfq-iosched-orig.c
new file mode 100644 (file)
index 0000000..977d32d
--- /dev/null
@@ -0,0 +1,706 @@
+/*
+ *  linux/drivers/block/cfq-iosched.c
+ *
+ *  CFQ, or complete fairness queueing, disk scheduler.
+ *
+ *  Based on ideas from a previously unfinished io
+ *  scheduler (round robin per-process disk scheduling) and Andrea Arcangeli.
+ *
+ *  Copyright (C) 2003 Jens Axboe <axboe@suse.de>
+ */
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/blkdev.h>
+#include <linux/elevator.h>
+#include <linux/bio.h>
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/compiler.h>
+#include <linux/hash.h>
+#include <linux/rbtree.h>
+#include <linux/mempool.h>
+
+/*
+ * tunables
+ */
+static int cfq_quantum = 4;
+static int cfq_queued = 8;
+
+#define CFQ_QHASH_SHIFT                6
+#define CFQ_QHASH_ENTRIES      (1 << CFQ_QHASH_SHIFT)
+#define list_entry_qhash(entry)        list_entry((entry), struct cfq_queue, cfq_hash)
+
+#define CFQ_MHASH_SHIFT                8
+#define CFQ_MHASH_BLOCK(sec)   ((sec) >> 3)
+#define CFQ_MHASH_ENTRIES      (1 << CFQ_MHASH_SHIFT)
+#define CFQ_MHASH_FN(sec)      (hash_long(CFQ_MHASH_BLOCK((sec)),CFQ_MHASH_SHIFT))
+#define ON_MHASH(crq)          !list_empty(&(crq)->hash)
+#define rq_hash_key(rq)                ((rq)->sector + (rq)->nr_sectors)
+#define list_entry_hash(ptr)   list_entry((ptr), struct cfq_rq, hash)
+
+#define list_entry_cfqq(ptr)   list_entry((ptr), struct cfq_queue, cfq_list)
+
+#define RQ_DATA(rq)            ((struct cfq_rq *) (rq)->elevator_private)
+
+static kmem_cache_t *crq_pool;
+static kmem_cache_t *cfq_pool;
+static mempool_t *cfq_mpool;
+
+struct cfq_data {
+       struct list_head rr_list;
+       struct list_head *dispatch;
+       struct list_head *cfq_hash;
+
+       struct list_head *crq_hash;
+
+       unsigned int busy_queues;
+       unsigned int max_queued;
+
+       mempool_t *crq_pool;
+};
+
+struct cfq_queue {
+       struct list_head cfq_hash;
+       struct list_head cfq_list;
+       struct rb_root sort_list;
+       int pid;
+       int queued[2];
+#if 0
+       /*
+        * with a simple addition like this, we can do io priorities. almost.
+        * does need a split request free list, too.
+        */
+       int io_prio
+#endif
+};
+
+struct cfq_rq {
+       struct rb_node rb_node;
+       sector_t rb_key;
+
+       struct request *request;
+
+       struct cfq_queue *cfq_queue;
+
+       struct list_head hash;
+};
+
+static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq);
+static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int pid);
+static void cfq_dispatch_sort(struct list_head *head, struct cfq_rq *crq);
+
+/*
+ * lots of deadline iosched dupes, can be abstracted later...
+ */
+static inline void __cfq_del_crq_hash(struct cfq_rq *crq)
+{
+       list_del_init(&crq->hash);
+}
+
+static inline void cfq_del_crq_hash(struct cfq_rq *crq)
+{
+       if (ON_MHASH(crq))
+               __cfq_del_crq_hash(crq);
+}
+
+static void cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq)
+{
+       cfq_del_crq_hash(crq);
+
+       if (q->last_merge == crq->request)
+               q->last_merge = NULL;
+}
+
+static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq)
+{
+       struct request *rq = crq->request;
+
+       BUG_ON(ON_MHASH(crq));
+
+       list_add(&crq->hash, &cfqd->crq_hash[CFQ_MHASH_FN(rq_hash_key(rq))]);
+}
+
+static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
+{
+       struct list_head *hash_list = &cfqd->crq_hash[CFQ_MHASH_FN(offset)];
+       struct list_head *entry, *next = hash_list->next;
+
+       while ((entry = next) != hash_list) {
+               struct cfq_rq *crq = list_entry_hash(entry);
+               struct request *__rq = crq->request;
+
+               next = entry->next;
+
+               BUG_ON(!ON_MHASH(crq));
+
+               if (!rq_mergeable(__rq)) {
+                       __cfq_del_crq_hash(crq);
+                       continue;
+               }
+
+               if (rq_hash_key(__rq) == offset)
+                       return __rq;
+       }
+
+       return NULL;
+}
+
+/*
+ * rb tree support functions
+ */
+#define RB_NONE                (2)
+#define RB_EMPTY(node) ((node)->rb_node == NULL)
+#define RB_CLEAR(node) ((node)->rb_color = RB_NONE)
+#define RB_CLEAR_ROOT(root)    ((root)->rb_node = NULL)
+#define ON_RB(node)    ((node)->rb_color != RB_NONE)
+#define rb_entry_crq(node)     rb_entry((node), struct cfq_rq, rb_node)
+#define rq_rb_key(rq)          (rq)->sector
+
+static inline void cfq_del_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
+{
+       if (ON_RB(&crq->rb_node)) {
+               cfqq->queued[rq_data_dir(crq->request)]--;
+               rb_erase(&crq->rb_node, &cfqq->sort_list);
+               crq->cfq_queue = NULL;
+       }
+}
+
+static struct cfq_rq *
+__cfq_add_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
+{
+       struct rb_node **p = &cfqq->sort_list.rb_node;
+       struct rb_node *parent = NULL;
+       struct cfq_rq *__crq;
+
+       while (*p) {
+               parent = *p;
+               __crq = rb_entry_crq(parent);
+
+               if (crq->rb_key < __crq->rb_key)
+                       p = &(*p)->rb_left;
+               else if (crq->rb_key > __crq->rb_key)
+                       p = &(*p)->rb_right;
+               else
+                       return __crq;
+       }
+
+       rb_link_node(&crq->rb_node, parent, p);
+       return 0;
+}
+
+static void
+cfq_add_crq_rb(struct cfq_data *cfqd, struct cfq_queue *cfqq,struct cfq_rq *crq)
+{
+       struct request *rq = crq->request;
+       struct cfq_rq *__alias;
+
+       crq->rb_key = rq_rb_key(rq);
+       cfqq->queued[rq_data_dir(rq)]++;
+retry:
+       __alias = __cfq_add_crq_rb(cfqq, crq);
+       if (!__alias) {
+               rb_insert_color(&crq->rb_node, &cfqq->sort_list);
+               crq->cfq_queue = cfqq;
+               return;
+       }
+
+       cfq_del_crq_rb(cfqq, __alias);
+       cfq_dispatch_sort(cfqd->dispatch, __alias);
+       goto retry;
+}
+
+static struct request *
+cfq_find_rq_rb(struct cfq_data *cfqd, sector_t sector)
+{
+       struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
+       struct rb_node *n;
+
+       if (!cfqq)
+               goto out;
+
+       n = cfqq->sort_list.rb_node;
+       while (n) {
+               struct cfq_rq *crq = rb_entry_crq(n);
+
+               if (sector < crq->rb_key)
+                       n = n->rb_left;
+               else if (sector > crq->rb_key)
+                       n = n->rb_right;
+               else
+                       return crq->request;
+       }
+
+out:
+       return NULL;
+}
+
+static void cfq_remove_request(request_queue_t *q, struct request *rq)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct cfq_rq *crq = RQ_DATA(rq);
+
+       if (crq) {
+               struct cfq_queue *cfqq = crq->cfq_queue;
+
+               cfq_remove_merge_hints(q, crq);
+               list_del_init(&rq->queuelist);
+
+               if (cfqq) {
+                       cfq_del_crq_rb(cfqq, crq);
+
+                       if (RB_EMPTY(&cfqq->sort_list))
+                               cfq_put_queue(cfqd, cfqq);
+               }
+       }
+}
+
+static int
+cfq_merge(request_queue_t *q, struct request **req, struct bio *bio)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct request *__rq;
+       int ret;
+
+       ret = elv_try_last_merge(q, bio);
+       if (ret != ELEVATOR_NO_MERGE) {
+               __rq = q->last_merge;
+               goto out_insert;
+       }
+
+       __rq = cfq_find_rq_hash(cfqd, bio->bi_sector);
+       if (__rq) {
+               BUG_ON(__rq->sector + __rq->nr_sectors != bio->bi_sector);
+
+               if (elv_rq_merge_ok(__rq, bio)) {
+                       ret = ELEVATOR_BACK_MERGE;
+                       goto out;
+               }
+       }
+
+       __rq = cfq_find_rq_rb(cfqd, bio->bi_sector + bio_sectors(bio));
+       if (__rq) {
+               if (elv_rq_merge_ok(__rq, bio)) {
+                       ret = ELEVATOR_FRONT_MERGE;
+                       goto out;
+               }
+       }
+
+       return ELEVATOR_NO_MERGE;
+out:
+       q->last_merge = __rq;
+out_insert:
+       *req = __rq;
+       return ret;
+}
+
+static void cfq_merged_request(request_queue_t *q, struct request *req)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct cfq_rq *crq = RQ_DATA(req);
+
+       cfq_del_crq_hash(crq);
+       cfq_add_crq_hash(cfqd, crq);
+
+       if (ON_RB(&crq->rb_node) && (rq_rb_key(req) != crq->rb_key)) {
+               struct cfq_queue *cfqq = crq->cfq_queue;
+
+               cfq_del_crq_rb(cfqq, crq);
+               cfq_add_crq_rb(cfqd, cfqq, crq);
+       }
+
+       q->last_merge = req;
+}
+
+static void
+cfq_merged_requests(request_queue_t *q, struct request *req,
+                   struct request *next)
+{
+       cfq_merged_request(q, req);
+       cfq_remove_request(q, next);
+}
+
+static void cfq_dispatch_sort(struct list_head *head, struct cfq_rq *crq)
+{
+       struct list_head *entry = head;
+       struct request *__rq;
+
+       if (!list_empty(head)) {
+               __rq = list_entry_rq(head->next);
+
+               if (crq->request->sector < __rq->sector) {
+                       entry = head->prev;
+                       goto link;
+               }
+       }
+
+       while ((entry = entry->prev) != head) {
+               __rq = list_entry_rq(entry);
+
+               if (crq->request->sector <= __rq->sector)
+                       break;
+       }
+
+link:
+       list_add_tail(&crq->request->queuelist, entry);
+}
+
+static inline void
+__cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd,
+                       struct cfq_queue *cfqq)
+{
+       struct cfq_rq *crq = rb_entry_crq(rb_first(&cfqq->sort_list));
+
+       cfq_del_crq_rb(cfqq, crq);
+       cfq_remove_merge_hints(q, crq);
+       cfq_dispatch_sort(cfqd->dispatch, crq);
+}
+
+static int cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd)
+{
+       struct cfq_queue *cfqq;
+       struct list_head *entry, *tmp;
+       int ret, queued, good_queues;
+
+       if (list_empty(&cfqd->rr_list))
+               return 0;
+
+       queued = ret = 0;
+restart:
+       good_queues = 0;
+       list_for_each_safe(entry, tmp, &cfqd->rr_list) {
+               cfqq = list_entry_cfqq(cfqd->rr_list.next);
+
+               BUG_ON(RB_EMPTY(&cfqq->sort_list));
+
+               __cfq_dispatch_requests(q, cfqd, cfqq);
+
+               if (RB_EMPTY(&cfqq->sort_list))
+                       cfq_put_queue(cfqd, cfqq);
+               else
+                       good_queues++;
+
+               queued++;
+               ret = 1;
+       }
+
+       if ((queued < cfq_quantum) && good_queues)
+               goto restart;
+
+       return ret;
+}
+
+static struct request *cfq_next_request(request_queue_t *q)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct request *rq;
+
+       if (!list_empty(cfqd->dispatch)) {
+               struct cfq_rq *crq;
+dispatch:
+               rq = list_entry_rq(cfqd->dispatch->next);
+
+               crq = RQ_DATA(rq);
+               if (crq)
+                       cfq_remove_merge_hints(q, crq);
+
+               return rq;
+       }
+
+       if (cfq_dispatch_requests(q, cfqd))
+               goto dispatch;
+
+       return NULL;
+}
+
+static inline struct cfq_queue *
+__cfq_find_cfq_hash(struct cfq_data *cfqd, int pid, const int hashval)
+{
+       struct list_head *hash_list = &cfqd->cfq_hash[hashval];
+       struct list_head *entry;
+
+       list_for_each(entry, hash_list) {
+               struct cfq_queue *__cfqq = list_entry_qhash(entry);
+
+               if (__cfqq->pid == pid)
+                       return __cfqq;
+       }
+
+       return NULL;
+}
+
+static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int pid)
+{
+       const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
+
+       return __cfq_find_cfq_hash(cfqd, pid, hashval);
+}
+
+static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+{
+       cfqd->busy_queues--;
+       list_del(&cfqq->cfq_list);
+       list_del(&cfqq->cfq_hash);
+       mempool_free(cfqq, cfq_mpool);
+}
+
+static struct cfq_queue *cfq_get_queue(struct cfq_data *cfqd, int pid)
+{
+       const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
+       struct cfq_queue *cfqq = __cfq_find_cfq_hash(cfqd, pid, hashval);
+
+       if (!cfqq) {
+               cfqq = mempool_alloc(cfq_mpool, GFP_NOIO);
+
+               INIT_LIST_HEAD(&cfqq->cfq_hash);
+               INIT_LIST_HEAD(&cfqq->cfq_list);
+               RB_CLEAR_ROOT(&cfqq->sort_list);
+
+               cfqq->pid = pid;
+               cfqq->queued[0] = cfqq->queued[1] = 0;
+               list_add(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
+       }
+
+       return cfqq;
+}
+
+static void cfq_enqueue(struct cfq_data *cfqd, struct cfq_rq *crq)
+{
+       struct cfq_queue *cfqq;
+
+       cfqq = cfq_get_queue(cfqd, current->tgid);
+
+       cfq_add_crq_rb(cfqd, cfqq, crq);
+
+       if (list_empty(&cfqq->cfq_list)) {
+               list_add(&cfqq->cfq_list, &cfqd->rr_list);
+               cfqd->busy_queues++;
+       }
+}
+
+static void
+cfq_insert_request(request_queue_t *q, struct request *rq, int where)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct cfq_rq *crq = RQ_DATA(rq);
+
+       switch (where) {
+               case ELEVATOR_INSERT_BACK:
+                       while (cfq_dispatch_requests(q, cfqd))
+                               ;
+                       list_add_tail(&rq->queuelist, cfqd->dispatch);
+                       break;
+               case ELEVATOR_INSERT_FRONT:
+                       list_add(&rq->queuelist, cfqd->dispatch);
+                       break;
+               case ELEVATOR_INSERT_SORT:
+                       BUG_ON(!blk_fs_request(rq));
+                       cfq_enqueue(cfqd, crq);
+                       break;
+               default:
+                       printk("%s: bad insert point %d\n", __FUNCTION__,where);
+                       return;
+       }
+
+       if (rq_mergeable(rq)) {
+               cfq_add_crq_hash(cfqd, crq);
+
+               if (!q->last_merge)
+                       q->last_merge = rq;
+       }
+}
+
+static int cfq_queue_empty(request_queue_t *q)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+
+       if (list_empty(cfqd->dispatch) && list_empty(&cfqd->rr_list))
+               return 1;
+
+       return 0;
+}
+
+static struct request *
+cfq_former_request(request_queue_t *q, struct request *rq)
+{
+       struct cfq_rq *crq = RQ_DATA(rq);
+       struct rb_node *rbprev = rb_prev(&crq->rb_node);
+
+       if (rbprev)
+               return rb_entry_crq(rbprev)->request;
+
+       return NULL;
+}
+
+static struct request *
+cfq_latter_request(request_queue_t *q, struct request *rq)
+{
+       struct cfq_rq *crq = RQ_DATA(rq);
+       struct rb_node *rbnext = rb_next(&crq->rb_node);
+
+       if (rbnext)
+               return rb_entry_crq(rbnext)->request;
+
+       return NULL;
+}
+
+static int cfq_may_queue(request_queue_t *q, int rw)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct cfq_queue *cfqq;
+       int ret = 1;
+
+       if (!cfqd->busy_queues)
+               goto out;
+
+       cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
+       if (cfqq) {
+               int limit = (q->nr_requests - cfq_queued) / cfqd->busy_queues;
+
+               if (limit < 3)
+                       limit = 3;
+               else if (limit > cfqd->max_queued)
+                       limit = cfqd->max_queued;
+
+               if (cfqq->queued[rw] > limit)
+                       ret = 0;
+       }
+out:
+       return ret;
+}
+
+static void cfq_put_request(request_queue_t *q, struct request *rq)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct cfq_rq *crq = RQ_DATA(rq);
+
+       if (crq) {
+               BUG_ON(q->last_merge == rq);
+               BUG_ON(ON_MHASH(crq));
+
+               mempool_free(crq, cfqd->crq_pool);
+               rq->elevator_private = NULL;
+       }
+}
+
+static int cfq_set_request(request_queue_t *q, struct request *rq, int gfp_mask)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct cfq_rq *crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
+
+       if (crq) {
+               RB_CLEAR(&crq->rb_node);
+               crq->request = rq;
+               crq->cfq_queue = NULL;
+               INIT_LIST_HEAD(&crq->hash);
+               rq->elevator_private = crq;
+               return 0;
+       }
+
+       return 1;
+}
+
+static void cfq_exit(request_queue_t *q, elevator_t *e)
+{
+       struct cfq_data *cfqd = e->elevator_data;
+
+       e->elevator_data = NULL;
+       mempool_destroy(cfqd->crq_pool);
+       kfree(cfqd->crq_hash);
+       kfree(cfqd->cfq_hash);
+       kfree(cfqd);
+}
+
+static int cfq_init(request_queue_t *q, elevator_t *e)
+{
+       struct cfq_data *cfqd;
+       int i;
+
+       cfqd = kmalloc(sizeof(*cfqd), GFP_KERNEL);
+       if (!cfqd)
+               return -ENOMEM;
+
+       memset(cfqd, 0, sizeof(*cfqd));
+       INIT_LIST_HEAD(&cfqd->rr_list);
+
+       cfqd->crq_hash = kmalloc(sizeof(struct list_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL);
+       if (!cfqd->crq_hash)
+               goto out_crqhash;
+
+       cfqd->cfq_hash = kmalloc(sizeof(struct list_head) * CFQ_QHASH_ENTRIES, GFP_KERNEL);
+       if (!cfqd->cfq_hash)
+               goto out_cfqhash;
+
+       cfqd->crq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, crq_pool);
+       if (!cfqd->crq_pool)
+               goto out_crqpool;
+
+       for (i = 0; i < CFQ_MHASH_ENTRIES; i++)
+               INIT_LIST_HEAD(&cfqd->crq_hash[i]);
+       for (i = 0; i < CFQ_QHASH_ENTRIES; i++)
+               INIT_LIST_HEAD(&cfqd->cfq_hash[i]);
+
+       cfqd->dispatch = &q->queue_head;
+       e->elevator_data = cfqd;
+
+       /*
+        * just set it to some high value, we want anyone to be able to queue
+        * some requests. fairness is handled differently
+        */
+       cfqd->max_queued = q->nr_requests;
+       q->nr_requests = 8192;
+
+       return 0;
+out_crqpool:
+       kfree(cfqd->cfq_hash);
+out_cfqhash:
+       kfree(cfqd->crq_hash);
+out_crqhash:
+       kfree(cfqd);
+       return -ENOMEM;
+}
+
+static int __init cfq_slab_setup(void)
+{
+       crq_pool = kmem_cache_create("crq_pool", sizeof(struct cfq_rq), 0, 0,
+                                       NULL, NULL);
+
+       if (!crq_pool)
+               panic("cfq_iosched: can't init crq pool\n");
+
+       cfq_pool = kmem_cache_create("cfq_pool", sizeof(struct cfq_queue), 0, 0,
+                                       NULL, NULL);
+
+       if (!cfq_pool)
+               panic("cfq_iosched: can't init cfq pool\n");
+
+       cfq_mpool = mempool_create(64, mempool_alloc_slab, mempool_free_slab, cfq_pool);
+
+       if (!cfq_mpool)
+               panic("cfq_iosched: can't init cfq mpool\n");
+
+       return 0;
+}
+
+subsys_initcall(cfq_slab_setup);
+
+elevator_t iosched_cfq = {
+       .elevator_name =                "cfq",
+       .elevator_merge_fn =            cfq_merge,
+       .elevator_merged_fn =           cfq_merged_request,
+       .elevator_merge_req_fn =        cfq_merged_requests,
+       .elevator_next_req_fn =         cfq_next_request,
+       .elevator_add_req_fn =          cfq_insert_request,
+       .elevator_remove_req_fn =       cfq_remove_request,
+       .elevator_queue_empty_fn =      cfq_queue_empty,
+       .elevator_former_req_fn =       cfq_former_request,
+       .elevator_latter_req_fn =       cfq_latter_request,
+       .elevator_set_req_fn =          cfq_set_request,
+       .elevator_put_req_fn =          cfq_put_request,
+       .elevator_may_queue_fn =        cfq_may_queue,
+       .elevator_init_fn =             cfq_init,
+       .elevator_exit_fn =             cfq_exit,
+};
+
+EXPORT_SYMBOL(iosched_cfq);
index 068f4ea..7b45a80 100644 (file)
@@ -6,6 +6,18 @@
  *  Based on ideas from a previously unfinished io
  *  scheduler (round robin per-process disk scheduling) and Andrea Arcangeli.
  *
+ *  IO priorities are supported, from 0% to 100% in 5% increments. Both of
+ *  those values have special meaning - 0% class is allowed to do io if
+ *  noone else wants to use the disk. 100% is considered real-time io, and
+ *  always get priority. Default process io rate is 95%. In absence of other
+ *  io, a class may consume 100% disk bandwidth regardless. Withing a class,
+ *  bandwidth is distributed equally among the citizens.
+ *
+ * TODO:
+ *     - cfq_select_requests() needs some work for 5-95% io
+ *     - barriers not supported
+ *     - export grace periods in ms, not jiffies
+ *
  *  Copyright (C) 2003 Jens Axboe <axboe@suse.de>
  */
 #include <linux/kernel.h>
 #include <linux/hash.h>
 #include <linux/rbtree.h>
 #include <linux/mempool.h>
+#include <asm/div64.h>
+
+#if IOPRIO_NR > BITS_PER_LONG
+#error Cannot support this many io priority levels
+#endif
+
+#define LIMIT_DEBUG   1
 
 /*
  * tunables
  */
-static int cfq_quantum = 4;
-static int cfq_queued = 8;
+static int cfq_quantum = 6;
+static int cfq_quantum_io = 256;
+static int cfq_idle_quantum = 1;
+static int cfq_idle_quantum_io = 64;
+static int cfq_queued = 4;
+static int cfq_grace_rt = HZ / 100 ?: 1;
+static int cfq_grace_idle = HZ / 10;
 
 #define CFQ_QHASH_SHIFT                6
 #define CFQ_QHASH_ENTRIES      (1 << CFQ_QHASH_SHIFT)
-#define list_entry_qhash(entry)        list_entry((entry), struct cfq_queue, cfq_hash)
+#define list_entry_qhash(entry)        hlist_entry((entry), struct cfq_queue, cfq_hash)
 
 #define CFQ_MHASH_SHIFT                8
 #define CFQ_MHASH_BLOCK(sec)   ((sec) >> 3)
 #define CFQ_MHASH_ENTRIES      (1 << CFQ_MHASH_SHIFT)
 #define CFQ_MHASH_FN(sec)      (hash_long(CFQ_MHASH_BLOCK((sec)),CFQ_MHASH_SHIFT))
-#define ON_MHASH(crq)          !list_empty(&(crq)->hash)
 #define rq_hash_key(rq)                ((rq)->sector + (rq)->nr_sectors)
-#define list_entry_hash(ptr)   list_entry((ptr), struct cfq_rq, hash)
+#define list_entry_hash(ptr)   hlist_entry((ptr), struct cfq_rq, hash)
 
 #define list_entry_cfqq(ptr)   list_entry((ptr), struct cfq_queue, cfq_list)
+#define list_entry_prio(ptr)   list_entry((ptr), struct cfq_rq, prio_list)
+
+#define cfq_account_io(crq)    \
+       ((crq)->ioprio != IOPRIO_IDLE && (crq)->ioprio != IOPRIO_RT)
+
+/* define to be 50 ms for now; make tunable later */
+#define CFQ_EPOCH              50000
+/* Needs to be made tunable right away, in MiB/s */
+#define CFQ_DISKBW             10       
+/* Temporary global limit, as percent of available b/w, for each "class" */
+#define CFQ_TEMPLIM            10
+
+/*
+ * defines how we distribute bandwidth (can be tgid, uid, etc)
+ */
+
+/* FIXME: change hash_key to be sizeof(void *) rather than sizeof(int) 
+ * otherwise the cast of cki_tsk_icls will not work reliably on 64-bit arches.
+ * OR, change cki_tsk_icls to return ints (will need another id space to be 
+ * managed)
+ */
+
+#if defined(CONFIG_CKRM_RES_BLKIO) || defined(CONFIG_CKRM_RES_BLKIO_MODULE)
+extern inline void *cki_hash_key(struct task_struct *tsk);
+extern inline int cki_ioprio(struct task_struct *tsk);
+#define cfq_hash_key(current)   ((int)cki_hash_key((current)))
+#define cfq_ioprio(current)    (cki_ioprio((current)))
+
+#else
+#define cfq_hash_key(current)  ((current)->tgid)
+
+/*
+ * move to io_context
+ */
+#define cfq_ioprio(current)    ((current)->ioprio)
+#endif
 
-#define RQ_DATA(rq)            ((struct cfq_rq *) (rq)->elevator_private)
+#define CFQ_WAIT_RT    0
+#define CFQ_WAIT_NORM  1
 
 static kmem_cache_t *crq_pool;
 static kmem_cache_t *cfq_pool;
 static mempool_t *cfq_mpool;
 
+/*
+ * defines an io priority level
+ */
+struct io_prio_data {
+       struct list_head rr_list;
+       int busy_queues;
+       int busy_rq;
+       unsigned long busy_sectors;
+       
+       /* requests, sectors and queues 
+         * added(in),dispatched/deleted(out) 
+        * at this priority level. 
+        */
+       atomic_t cum_rq_in,cum_rq_out;              
+       atomic_t cum_sectors_in,cum_sectors_out;    
+       atomic_t cum_queues_in,cum_queues_out;
+
+#ifdef LIMIT_DEBUG
+       int nskip;
+       unsigned long navsec;
+       unsigned long csectorate;
+       unsigned long lsectorate;
+#endif
+
+       struct list_head prio_list;
+       int last_rq;
+       int last_sectors;
+};
+
+/*
+ * per-request queue structure
+ */
 struct cfq_data {
        struct list_head rr_list;
        struct list_head *dispatch;
-       struct list_head *cfq_hash;
+       struct hlist_head *cfq_hash;
+       struct hlist_head *crq_hash;
+       mempool_t *crq_pool;
 
-       struct list_head *crq_hash;
+       struct io_prio_data cid[IOPRIO_NR];
 
-       unsigned int busy_queues;
-       unsigned int max_queued;
+       /*
+        * total number of busy queues and requests
+        */
+       int busy_rq;
+       int busy_queues;
+       unsigned long busy_sectors;
 
-       mempool_t *crq_pool;
 
        request_queue_t *queue;
+       unsigned long rq_starved_mask;
+
+       /*
+        * grace period handling
+        */
+       struct timer_list timer;
+       unsigned long wait_end;
+       unsigned long flags;
+       struct work_struct work;
 
        /*
         * tunables
         */
        unsigned int cfq_quantum;
+       unsigned int cfq_quantum_io;
+       unsigned int cfq_idle_quantum;
+       unsigned int cfq_idle_quantum_io;
        unsigned int cfq_queued;
+       unsigned int cfq_grace_rt;
+       unsigned int cfq_grace_idle;
+
+       unsigned long cfq_epoch;        /* duration for limit enforcement */
+       unsigned long cfq_epochsectors; /* max sectors dispatchable/epoch */
 };
 
+/*
+ * per-class structure
+ */
 struct cfq_queue {
-       struct list_head cfq_hash;
        struct list_head cfq_list;
+       struct hlist_node cfq_hash;
+       int hash_key;
        struct rb_root sort_list;
-       int pid;
        int queued[2];
-#if 0
-       /*
-        * with a simple addition like this, we can do io priorities. almost.
-        * does need a split request free list, too.
-        */
-       int io_prio
-#endif
+       int ioprio;
+
+       unsigned long avsec;            /* avg sectors dispatched/epoch */
+       unsigned long long lastime;     /* timestamp of last request served */
+       unsigned long sectorate;        /* limit for sectors served/epoch */
+       int skipped;                    /* queue skipped at last dispatch ? */
 };
 
+/*
+ * per-request structure
+ */
 struct cfq_rq {
+       struct cfq_queue *cfq_queue;
        struct rb_node rb_node;
+       struct hlist_node hash;
        sector_t rb_key;
 
        struct request *request;
-
-       struct cfq_queue *cfq_queue;
-
-       struct list_head hash;
+       struct list_head prio_list;
+       unsigned long nr_sectors;
+       int ioprio;
 };
 
 static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq);
@@ -103,18 +223,13 @@ static void cfq_dispatch_sort(struct cfq_data *cfqd, struct cfq_queue *cfqq,
 /*
  * lots of deadline iosched dupes, can be abstracted later...
  */
-static inline void __cfq_del_crq_hash(struct cfq_rq *crq)
-{
-       list_del_init(&crq->hash);
-}
-
 static inline void cfq_del_crq_hash(struct cfq_rq *crq)
 {
-       if (ON_MHASH(crq))
-               __cfq_del_crq_hash(crq);
+       hlist_del_init(&crq->hash);
 }
 
-static void cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq)
+static inline void
+cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq)
 {
        cfq_del_crq_hash(crq);
 
@@ -125,27 +240,26 @@ static void cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq)
 static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq)
 {
        struct request *rq = crq->request;
+       const int hash_idx = CFQ_MHASH_FN(rq_hash_key(rq));
 
-       BUG_ON(ON_MHASH(crq));
-
-       list_add(&crq->hash, &cfqd->crq_hash[CFQ_MHASH_FN(rq_hash_key(rq))]);
+       BUG_ON(!hlist_unhashed(&crq->hash));
+       hlist_add_head(&crq->hash, &cfqd->crq_hash[hash_idx]);
 }
 
 static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
 {
-       struct list_head *hash_list = &cfqd->crq_hash[CFQ_MHASH_FN(offset)];
-       struct list_head *entry, *next = hash_list->next;
+       struct hlist_head *hash_list = &cfqd->crq_hash[CFQ_MHASH_FN(offset)];
+       struct hlist_node *entry, *next;
 
-       while ((entry = next) != hash_list) {
+       hlist_for_each_safe(entry, next, hash_list) {
                struct cfq_rq *crq = list_entry_hash(entry);
                struct request *__rq = crq->request;
 
-               next = entry->next;
-
-               BUG_ON(!ON_MHASH(crq));
+               BUG_ON(hlist_unhashed(&crq->hash));
 
                if (!rq_mergeable(__rq)) {
-                       __cfq_del_crq_hash(crq);
+                       cfq_del_crq_hash(crq);
                        continue;
                }
 
@@ -159,20 +273,27 @@ static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
 /*
  * rb tree support functions
  */
-#define RB_NONE                (2)
-#define RB_EMPTY(node) ((node)->rb_node == NULL)
-#define RB_CLEAR(node) ((node)->rb_color = RB_NONE)
-#define RB_CLEAR_ROOT(root)    ((root)->rb_node = NULL)
-#define ON_RB(node)    ((node)->rb_color != RB_NONE)
+#define RB_EMPTY(node)         ((node)->rb_node == NULL)
 #define rb_entry_crq(node)     rb_entry((node), struct cfq_rq, rb_node)
 #define rq_rb_key(rq)          (rq)->sector
 
-static inline void cfq_del_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
+static void
+cfq_del_crq_rb(struct cfq_data *cfqd, struct cfq_queue *cfqq,struct cfq_rq *crq)
 {
-       if (ON_RB(&crq->rb_node)) {
+       if (crq->cfq_queue) {
+               crq->cfq_queue = NULL;
+
+               if (cfq_account_io(crq)) {
+                       cfqd->busy_rq--;
+                       cfqd->busy_sectors -= crq->nr_sectors;
+                       cfqd->cid[crq->ioprio].busy_rq--;
+                       cfqd->cid[crq->ioprio].busy_sectors -= crq->nr_sectors;
+               }
+               atomic_inc(&(cfqd->cid[crq->ioprio].cum_rq_out));
+               atomic_add(crq->nr_sectors,
+                          &(cfqd->cid[crq->ioprio].cum_sectors_out));
                cfqq->queued[rq_data_dir(crq->request)]--;
                rb_erase(&crq->rb_node, &cfqq->sort_list);
-               crq->cfq_queue = NULL;
        }
 }
 
@@ -205,12 +326,22 @@ cfq_add_crq_rb(struct cfq_data *cfqd, struct cfq_queue *cfqq,struct cfq_rq *crq)
        struct request *rq = crq->request;
        struct cfq_rq *__alias;
 
-       crq->rb_key = rq_rb_key(rq);
+
        cfqq->queued[rq_data_dir(rq)]++;
+       if (cfq_account_io(crq)) {
+               cfqd->busy_rq++;
+               cfqd->busy_sectors += crq->nr_sectors;
+               cfqd->cid[crq->ioprio].busy_rq++;
+               cfqd->cid[crq->ioprio].busy_sectors += crq->nr_sectors;
+       }
+       atomic_inc(&(cfqd->cid[crq->ioprio].cum_rq_in));
+       atomic_add(crq->nr_sectors,
+                  &(cfqd->cid[crq->ioprio].cum_sectors_in));
 retry:
        __alias = __cfq_add_crq_rb(cfqq, crq);
        if (!__alias) {
                rb_insert_color(&crq->rb_node, &cfqq->sort_list);
+               crq->rb_key = rq_rb_key(rq);
                crq->cfq_queue = cfqq;
                return;
        }
@@ -222,7 +353,7 @@ retry:
 static struct request *
 cfq_find_rq_rb(struct cfq_data *cfqd, sector_t sector)
 {
-       struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
+       struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, cfq_hash_key(current));
        struct rb_node *n;
 
        if (!cfqq)
@@ -247,16 +378,31 @@ out:
 static void cfq_remove_request(request_queue_t *q, struct request *rq)
 {
        struct cfq_data *cfqd = q->elevator.elevator_data;
-       struct cfq_rq *crq = RQ_DATA(rq);
+       struct cfq_rq *crq = RQ_ELV_DATA(rq);
 
        if (crq) {
-               struct cfq_queue *cfqq = crq->cfq_queue;
 
                cfq_remove_merge_hints(q, crq);
+               list_del_init(&crq->prio_list);
                list_del_init(&rq->queuelist);
 
-               if (cfqq) {
-                       cfq_del_crq_rb(cfqq, crq);
+               /*
+                * set a grace period timer to allow realtime io to make real
+                * progress, if we release an rt request. for normal request,
+                * set timer so idle io doesn't interfere with other io
+                */
+               if (crq->ioprio == IOPRIO_RT) {
+                       set_bit(CFQ_WAIT_RT, &cfqd->flags);
+                       cfqd->wait_end = jiffies + cfqd->cfq_grace_rt;
+               } else if (crq->ioprio != IOPRIO_IDLE) {
+                       set_bit(CFQ_WAIT_NORM, &cfqd->flags);
+                       cfqd->wait_end = jiffies + cfqd->cfq_grace_idle;
+               }
+
+               if (crq->cfq_queue) {
+                       struct cfq_queue *cfqq = crq->cfq_queue;
+
+                       cfq_del_crq_rb(cfqd, cfqq, crq);
 
                        if (RB_EMPTY(&cfqq->sort_list))
                                cfq_put_queue(cfqd, cfqq);
@@ -306,18 +452,26 @@ out_insert:
 static void cfq_merged_request(request_queue_t *q, struct request *req)
 {
        struct cfq_data *cfqd = q->elevator.elevator_data;
-       struct cfq_rq *crq = RQ_DATA(req);
+       struct cfq_rq *crq = RQ_ELV_DATA(req);
+       int tmp;
 
        cfq_del_crq_hash(crq);
        cfq_add_crq_hash(cfqd, crq);
 
-       if (ON_RB(&crq->rb_node) && (rq_rb_key(req) != crq->rb_key)) {
+       if (crq->cfq_queue && (rq_rb_key(req) != crq->rb_key)) {
                struct cfq_queue *cfqq = crq->cfq_queue;
 
-               cfq_del_crq_rb(cfqq, crq);
+               cfq_del_crq_rb(cfqd, cfqq, crq);
                cfq_add_crq_rb(cfqd, cfqq, crq);
        }
 
+       tmp = req->hard_nr_sectors - crq->nr_sectors;
+       cfqd->busy_sectors += tmp;
+       cfqd->cid[crq->ioprio].busy_sectors += tmp;
+       atomic_add(tmp,&(cfqd->cid[crq->ioprio].cum_sectors_in));
+
+       crq->nr_sectors = req->hard_nr_sectors;
+
        q->last_merge = req;
 }
 
@@ -329,6 +483,9 @@ cfq_merged_requests(request_queue_t *q, struct request *req,
        cfq_remove_request(q, next);
 }
 
+/*
+ * sort into dispatch list, in optimal ascending order
+ */
 static void
 cfq_dispatch_sort(struct cfq_data *cfqd, struct cfq_queue *cfqq,
                  struct cfq_rq *crq)
@@ -336,7 +493,7 @@ cfq_dispatch_sort(struct cfq_data *cfqd, struct cfq_queue *cfqq,
        struct list_head *head = cfqd->dispatch, *entry = head;
        struct request *__rq;
 
-       cfq_del_crq_rb(cfqq, crq);
+       cfq_del_crq_rb(cfqd, cfqq, crq);
        cfq_remove_merge_hints(cfqd->queue, crq);
 
        if (!list_empty(head)) {
@@ -359,47 +516,219 @@ link:
        list_add_tail(&crq->request->queuelist, entry);
 }
 
-static inline void
+/*
+ * remove from io scheduler core and put on dispatch list for service
+ */
+static inline int
 __cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd,
                        struct cfq_queue *cfqq)
 {
-       struct cfq_rq *crq = rb_entry_crq(rb_first(&cfqq->sort_list));
+       struct cfq_rq *crq;
+       unsigned long long ts, gap;
+       unsigned long newavsec;
+
+       crq = rb_entry_crq(rb_first(&cfqq->sort_list));
+
+#if 1
+       /* Determine if queue should be skipped for being overshare */
+       ts = sched_clock();
+       gap = ts - cfqq->lastime;
+#ifdef LIMIT_DEBUG
+       cfqq->sectorate = (cfqd->cfq_epochsectors 
+                          * CFQ_TEMPLIM)/100;
+       
+#endif
+       if ((gap >= cfqd->cfq_epoch) || (gap < 0)) {
+               cfqq->avsec = crq->nr_sectors ; 
+               cfqq->lastime = ts;
+       } else {
+               u64 tmp;
+               /* Age old average and accumalate request to be served */
+
+//             tmp = (u64) (cfqq->avsec * gap) ;
+//             do_div(tmp, cfqd->cfq_epoch);
+               newavsec = (unsigned long)(cfqq->avsec >> 1) + crq->nr_sectors;
+//             if (crq->ioprio >= 0 && crq->ioprio <= 20)
+//                     cfqd->cid[crq->ioprio].lsectorate = newavsec; 
+//             atomic_set(&(cfqd->cid[crq->ioprio].lsectorate),
+//                        newavsec);
+
+               if ((newavsec < cfqq->sectorate) || cfqq->skipped) {
+                       cfqq->avsec = newavsec ;
+                       cfqq->lastime = ts;
+                       cfqq->skipped = 0;
+               } else {
+                       /* queue over share ; skip once */
+                       cfqq->skipped = 1;
+#ifdef LIMIT_DEBUG     
+//                     atomic_inc(&(cfqd->cid[crq->ioprio].nskip));
+//                     if (crq->ioprio >= 0 && crq->ioprio <= 20)
+//                             cfqd->cid[crq->ioprio].nskip++;
+#endif
+                       return 0;
+               }
+       }
+#endif
+
+#ifdef LIMIT_DEBUG
+//     if (crq->ioprio >= 0 && crq->ioprio <= 20) {
+//             cfqd->cid[crq->ioprio].navsec = cfqq->avsec;
+//             cfqd->cid[crq->ioprio].csectorate = cfqq->sectorate;
+//     }
 
+//     atomic_set(&(cfqd->cid[crq->ioprio].navsec),cfqq->avsec);
+//     atomic_set(&(cfqd->cid[crq->ioprio].csectorate),cfqq->sectorate);
+#endif
        cfq_dispatch_sort(cfqd, cfqq, crq);
+
+       /*
+        * technically, for IOPRIO_RT we don't need to add it to the list.
+        */
+       list_add_tail(&crq->prio_list, &cfqd->cid[cfqq->ioprio].prio_list);
+       return crq->nr_sectors;
 }
 
-static int cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd)
+static int
+cfq_dispatch_requests(request_queue_t *q, int prio, int max_rq, int max_sectors)
 {
-       struct cfq_queue *cfqq;
-       struct list_head *entry, *tmp;
-       int ret, queued, good_queues;
-
-       if (list_empty(&cfqd->rr_list))
-               return 0;
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+       struct list_head *plist = &cfqd->cid[prio].rr_list;
+       struct list_head *entry, *nxt;
+       int q_rq, q_io;
+       int ret ;
 
-       queued = ret = 0;
-restart:
-       good_queues = 0;
-       list_for_each_safe(entry, tmp, &cfqd->rr_list) {
-               cfqq = list_entry_cfqq(cfqd->rr_list.next);
+       /*
+        * for each queue at this prio level, dispatch a request
+        */
+       q_rq = q_io = 0;
+       list_for_each_safe(entry, nxt, plist) {
+               struct cfq_queue *cfqq = list_entry_cfqq(entry);
 
                BUG_ON(RB_EMPTY(&cfqq->sort_list));
 
-               __cfq_dispatch_requests(q, cfqd, cfqq);
+               ret = __cfq_dispatch_requests(q, cfqd, cfqq);
+               if (ret <= 0) {
+                       continue; /* skip queue */
+                       /* can optimize more by moving q to end of plist ? */
+               }
+               q_io += ret ;
+               q_rq++ ;
 
                if (RB_EMPTY(&cfqq->sort_list))
                        cfq_put_queue(cfqd, cfqq);
-               else
-                       good_queues++;
+               /*
+                * if we hit the queue limit, put the string of serviced
+                * queues at the back of the pending list
+                */
+               if (q_io >= max_sectors || q_rq >= max_rq) {
+                       struct list_head *prv = nxt->prev;
 
-               queued++;
-               ret = 1;
+                       if (prv != plist) {
+                               list_del(plist);
+                               list_add(plist, prv);
+                       }
+                       break;
+               }
        }
 
-       if ((queued < cfqd->cfq_quantum) && good_queues)
-               goto restart;
+       cfqd->cid[prio].last_rq = q_rq;
+       cfqd->cid[prio].last_sectors = q_io;
+       return q_rq;
+}
 
-       return ret;
+/*
+ * try to move some requests to the dispatch list. return 0 on success
+ */
+static int cfq_select_requests(request_queue_t *q, struct cfq_data *cfqd)
+{
+       int queued, busy_rq, busy_sectors, i;
+
+       /*
+        * if there's any realtime io, only schedule that
+        */
+       if (cfq_dispatch_requests(q, IOPRIO_RT, cfqd->cfq_quantum, cfqd->cfq_quantum_io))
+               return 1;
+
+       /*
+        * if RT io was last serviced and grace time hasn't expired,
+        * arm the timer to restart queueing if no other RT io has been
+        * submitted in the mean time
+        */
+       if (test_bit(CFQ_WAIT_RT, &cfqd->flags)) {
+               if (time_before(jiffies, cfqd->wait_end)) {
+                       mod_timer(&cfqd->timer, cfqd->wait_end);
+                       return 0;
+               }
+               clear_bit(CFQ_WAIT_RT, &cfqd->flags);
+       }
+
+       /*
+        * for each priority level, calculate number of requests we
+        * are allowed to put into service.
+        */
+       queued = 0;
+       busy_rq = cfqd->busy_rq;
+       busy_sectors = cfqd->busy_sectors;
+       for (i = IOPRIO_RT - 1; i > IOPRIO_IDLE; i--) {
+               const int o_rq = busy_rq - cfqd->cid[i].busy_rq;
+               const int o_sectors = busy_sectors - cfqd->cid[i].busy_sectors;
+               int q_rq = cfqd->cfq_quantum * (i + 1) / IOPRIO_NR;
+               int q_io = cfqd->cfq_quantum_io * (i + 1) / IOPRIO_NR;
+
+               /*
+                * no need to keep iterating the list, if there are no
+                * requests pending anymore
+                */
+               if (!cfqd->busy_rq)
+                       break;
+
+               /*
+                * find out how many requests and sectors we are allowed to
+                * service
+                */
+               if (o_rq)
+                       q_rq = o_sectors * (i + 1) / IOPRIO_NR;
+               if (q_rq > cfqd->cfq_quantum)
+                       q_rq = cfqd->cfq_quantum;
+
+               if (o_sectors)
+                       q_io = o_sectors * (i + 1) / IOPRIO_NR;
+               if (q_io > cfqd->cfq_quantum_io)
+                       q_io = cfqd->cfq_quantum_io;
+
+               /*
+                * average with last dispatched for fairness
+                */
+               if (cfqd->cid[i].last_rq != -1)
+                       q_rq = (cfqd->cid[i].last_rq + q_rq) / 2;
+               if (cfqd->cid[i].last_sectors != -1)
+                       q_io = (cfqd->cid[i].last_sectors + q_io) / 2;
+
+               queued += cfq_dispatch_requests(q, i, q_rq, q_io);
+       }
+
+       if (queued)
+               return 1;
+
+       /*
+        * only allow dispatch of idle io, if the queue has been idle from
+        * servicing RT or normal io for the grace period
+        */
+       if (test_bit(CFQ_WAIT_NORM, &cfqd->flags)) {
+               if (time_before(jiffies, cfqd->wait_end)) {
+                       mod_timer(&cfqd->timer, cfqd->wait_end);
+                       return 0;
+               }
+               clear_bit(CFQ_WAIT_NORM, &cfqd->flags);
+       }
+
+       /*
+        * if we found nothing to do, allow idle io to be serviced
+        */
+       if (cfq_dispatch_requests(q, IOPRIO_IDLE, cfqd->cfq_idle_quantum, cfqd->cfq_idle_quantum_io))
+               return 1;
+
+       return 0;
 }
 
 static struct request *cfq_next_request(request_queue_t *q)
@@ -410,61 +739,82 @@ static struct request *cfq_next_request(request_queue_t *q)
        if (!list_empty(cfqd->dispatch)) {
                struct cfq_rq *crq;
 dispatch:
+               /*
+                * end grace period, we are servicing a request
+                */
+               del_timer(&cfqd->timer);
+               clear_bit(CFQ_WAIT_RT, &cfqd->flags);
+               clear_bit(CFQ_WAIT_NORM, &cfqd->flags);
+
+               BUG_ON(list_empty(cfqd->dispatch));
                rq = list_entry_rq(cfqd->dispatch->next);
 
-               crq = RQ_DATA(rq);
-               if (crq)
-                       cfq_remove_merge_hints(q, crq);
+               BUG_ON(q->last_merge == rq);
+               crq = RQ_ELV_DATA(rq);
+               if (crq) {
+                       BUG_ON(!hlist_unhashed(&crq->hash));
+                       list_del_init(&crq->prio_list);
+               }
 
                return rq;
        }
 
-       if (cfq_dispatch_requests(q, cfqd))
+       /*
+        * we moved requests to dispatch list, go back end serve one
+        */
+       if (cfq_select_requests(q, cfqd))
                goto dispatch;
 
        return NULL;
 }
 
 static inline struct cfq_queue *
-__cfq_find_cfq_hash(struct cfq_data *cfqd, int pid, const int hashval)
+__cfq_find_cfq_hash(struct cfq_data *cfqd, int hashkey, const int hashval)
 {
-       struct list_head *hash_list = &cfqd->cfq_hash[hashval];
-       struct list_head *entry;
+       struct hlist_head *hash_list = &cfqd->cfq_hash[hashval];
+       struct hlist_node *entry;
 
-       list_for_each(entry, hash_list) {
+       hlist_for_each(entry, hash_list) {
                struct cfq_queue *__cfqq = list_entry_qhash(entry);
 
-               if (__cfqq->pid == pid)
+               if (__cfqq->hash_key == hashkey)
                        return __cfqq;
        }
 
        return NULL;
 }
 
-static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int pid)
+
+static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int hashkey)
 {
-       const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
+       const int hashval = hash_long(hashkey, CFQ_QHASH_SHIFT);
 
-       return __cfq_find_cfq_hash(cfqd, pid, hashval);
+       return __cfq_find_cfq_hash(cfqd, hashkey, hashval);
 }
 
 static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 {
        cfqd->busy_queues--;
+       WARN_ON(cfqd->busy_queues < 0);
+
+       cfqd->cid[cfqq->ioprio].busy_queues--;
+       WARN_ON(cfqd->cid[cfqq->ioprio].busy_queues < 0);
+       atomic_inc(&(cfqd->cid[cfqq->ioprio].cum_queues_out));
+
        list_del(&cfqq->cfq_list);
-       list_del(&cfqq->cfq_hash);
+       hlist_del(&cfqq->cfq_hash);
        mempool_free(cfqq, cfq_mpool);
 }
 
-static struct cfq_queue *__cfq_get_queue(struct cfq_data *cfqd, int pid,
+static struct cfq_queue *__cfq_get_queue(struct cfq_data *cfqd, int hashkey,
                                         int gfp_mask)
 {
-       const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
+       const int hashval = hash_long(hashkey, CFQ_QHASH_SHIFT);
        struct cfq_queue *cfqq, *new_cfqq = NULL;
        request_queue_t *q = cfqd->queue;
 
 retry:
-       cfqq = __cfq_find_cfq_hash(cfqd, pid, hashval);
+       cfqq = __cfq_find_cfq_hash(cfqd, hashkey, hashval);
 
        if (!cfqq) {
                if (new_cfqq) {
@@ -478,13 +828,15 @@ retry:
                } else
                        return NULL;
 
-               INIT_LIST_HEAD(&cfqq->cfq_hash);
+               memset(cfqq, 0, sizeof(*cfqq));
+               INIT_HLIST_NODE(&cfqq->cfq_hash);
                INIT_LIST_HEAD(&cfqq->cfq_list);
-               RB_CLEAR_ROOT(&cfqq->sort_list);
-
-               cfqq->pid = pid;
-               cfqq->queued[0] = cfqq->queued[1] = 0;
-               list_add(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
+               cfqq->hash_key = cfq_hash_key(current);
+               cfqq->ioprio = cfq_ioprio(current);
+               cfqq->avsec = 0 ;
+               cfqq->lastime = sched_clock();
+               cfqq->sectorate = (cfqd->cfq_epochsectors * CFQ_TEMPLIM)/100;
+               hlist_add_head(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
        }
 
        if (new_cfqq)
@@ -493,31 +845,63 @@ retry:
        return cfqq;
 }
 
-static struct cfq_queue *cfq_get_queue(struct cfq_data *cfqd, int pid,
+static struct cfq_queue *cfq_get_queue(struct cfq_data *cfqd, int hashkey,
                                       int gfp_mask)
 {
        request_queue_t *q = cfqd->queue;
        struct cfq_queue *cfqq;
 
        spin_lock_irq(q->queue_lock);
-       cfqq = __cfq_get_queue(cfqd, pid, gfp_mask);
+       cfqq = __cfq_get_queue(cfqd, hashkey, gfp_mask);
        spin_unlock_irq(q->queue_lock);
 
        return cfqq;
 }
 
-static void cfq_enqueue(struct cfq_data *cfqd, struct cfq_rq *crq)
+static void
+__cfq_enqueue(request_queue_t *q, struct cfq_data *cfqd, struct cfq_rq *crq)
 {
+       const int prio = crq->ioprio;
        struct cfq_queue *cfqq;
 
-       cfqq = __cfq_get_queue(cfqd, current->tgid, GFP_ATOMIC);
+       cfqq = __cfq_get_queue(cfqd, cfq_hash_key(current), GFP_ATOMIC);
        if (cfqq) {
+
+               /*
+                * not too good...
+                */
+               if (prio > cfqq->ioprio) {
+                       printk("prio hash collision %d %d\n", 
+                              prio, cfqq->ioprio);
+                       if (!list_empty(&cfqq->cfq_list)) {
+                               cfqd->cid[cfqq->ioprio].busy_queues--;
+                               WARN_ON(cfqd->cid[cfqq->ioprio].busy_queues<0);
+                               atomic_inc(&(cfqd->cid[cfqq->ioprio].cum_queues_out));
+                               cfqd->cid[prio].busy_queues++;
+                               atomic_inc(&(cfqd->cid[prio].cum_queues_in));
+                               list_move_tail(&cfqq->cfq_list, 
+                                              &cfqd->cid[prio].rr_list);
+                       }
+                       cfqq->ioprio = prio;
+               }
+
                cfq_add_crq_rb(cfqd, cfqq, crq);
 
                if (list_empty(&cfqq->cfq_list)) {
-                       list_add(&cfqq->cfq_list, &cfqd->rr_list);
+                       list_add_tail(&cfqq->cfq_list, 
+                                     &cfqd->cid[prio].rr_list);
+                       cfqd->cid[prio].busy_queues++;
+                       atomic_inc(&(cfqd->cid[prio].cum_queues_in));
                        cfqd->busy_queues++;
                }
+
+               if (rq_mergeable(crq->request)) {
+                       cfq_add_crq_hash(cfqd, crq);
+                       
+                       if (!q->last_merge)
+                               q->last_merge = crq->request;
+               }
+
        } else {
                /*
                 * should can only happen if the request wasn't allocated
@@ -528,16 +912,57 @@ static void cfq_enqueue(struct cfq_data *cfqd, struct cfq_rq *crq)
        }
 }
 
+static void cfq_reenqueue(request_queue_t *q, struct cfq_data *cfqd, int prio)
+{
+       struct list_head *prio_list = &cfqd->cid[prio].prio_list;
+       struct list_head *entry, *tmp;
+
+       list_for_each_safe(entry, tmp, prio_list) {
+               struct cfq_rq *crq = list_entry_prio(entry);
+
+               list_del_init(entry);
+               list_del_init(&crq->request->queuelist);
+               __cfq_enqueue(q, cfqd, crq);
+       }
+}
+
+static void
+cfq_enqueue(request_queue_t *q, struct cfq_data *cfqd, struct cfq_rq *crq)
+{
+       const int prio = cfq_ioprio(current);
+
+       crq->ioprio = prio;
+       crq->nr_sectors = crq->request->hard_nr_sectors;
+       __cfq_enqueue(q, cfqd, crq);
+
+       if (prio == IOPRIO_RT) {
+               int i;
+
+               /*
+                * realtime io gets priority, move all other io back
+                */
+               for (i = IOPRIO_IDLE; i < IOPRIO_RT; i++)
+                       cfq_reenqueue(q, cfqd, i);
+       } else if (prio != IOPRIO_IDLE) {
+               /*
+                * check if we need to move idle io back into queue
+                */
+               cfq_reenqueue(q, cfqd, IOPRIO_IDLE);
+       }
+}
+
 static void
 cfq_insert_request(request_queue_t *q, struct request *rq, int where)
 {
        struct cfq_data *cfqd = q->elevator.elevator_data;
-       struct cfq_rq *crq = RQ_DATA(rq);
+       struct cfq_rq *crq = RQ_ELV_DATA(rq);
 
        switch (where) {
                case ELEVATOR_INSERT_BACK:
+#if 0
                        while (cfq_dispatch_requests(q, cfqd))
                                ;
+#endif
                        list_add_tail(&rq->queuelist, cfqd->dispatch);
                        break;
                case ELEVATOR_INSERT_FRONT:
@@ -545,26 +970,20 @@ cfq_insert_request(request_queue_t *q, struct request *rq, int where)
                        break;
                case ELEVATOR_INSERT_SORT:
                        BUG_ON(!blk_fs_request(rq));
-                       cfq_enqueue(cfqd, crq);
+                       cfq_enqueue(q, cfqd, crq);
                        break;
                default:
-                       printk("%s: bad insert point %d\n", __FUNCTION__,where);
+                       printk("%s: bad insert point %d\n", 
+                              __FUNCTION__,where);
                        return;
        }
-
-       if (rq_mergeable(rq)) {
-               cfq_add_crq_hash(cfqd, crq);
-
-               if (!q->last_merge)
-                       q->last_merge = rq;
-       }
 }
 
 static int cfq_queue_empty(request_queue_t *q)
 {
        struct cfq_data *cfqd = q->elevator.elevator_data;
 
-       if (list_empty(cfqd->dispatch) && list_empty(&cfqd->rr_list))
+       if (list_empty(cfqd->dispatch) && !cfqd->busy_queues)
                return 1;
 
        return 0;
@@ -573,7 +992,7 @@ static int cfq_queue_empty(request_queue_t *q)
 static struct request *
 cfq_former_request(request_queue_t *q, struct request *rq)
 {
-       struct cfq_rq *crq = RQ_DATA(rq);
+       struct cfq_rq *crq = RQ_ELV_DATA(rq);
        struct rb_node *rbprev = rb_prev(&crq->rb_node);
 
        if (rbprev)
@@ -585,7 +1004,7 @@ cfq_former_request(request_queue_t *q, struct request *rq)
 static struct request *
 cfq_latter_request(request_queue_t *q, struct request *rq)
 {
-       struct cfq_rq *crq = RQ_DATA(rq);
+       struct cfq_rq *crq = RQ_ELV_DATA(rq);
        struct rb_node *rbnext = rb_next(&crq->rb_node);
 
        if (rbnext)
@@ -594,27 +1013,46 @@ cfq_latter_request(request_queue_t *q, struct request *rq)
        return NULL;
 }
 
+static void cfq_queue_congested(request_queue_t *q)
+{
+       struct cfq_data *cfqd = q->elevator.elevator_data;
+
+       set_bit(cfq_ioprio(current), &cfqd->rq_starved_mask);
+}
+
 static int cfq_may_queue(request_queue_t *q, int rw)
 {
        struct cfq_data *cfqd = q->elevator.elevator_data;
        struct cfq_queue *cfqq;
-       int ret = 1;
+       const int prio = cfq_ioprio(current);
+       int limit, ret = 1;
 
        if (!cfqd->busy_queues)
                goto out;
 
-       cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
-       if (cfqq) {
-               int limit = (q->nr_requests - cfqd->cfq_queued) / cfqd->busy_queues;
+       cfqq = cfq_find_cfq_hash(cfqd, cfq_hash_key(current));
+       if (!cfqq)
+               goto out;
 
-               if (limit < 3)
-                       limit = 3;
-               else if (limit > cfqd->max_queued)
-                       limit = cfqd->max_queued;
+       cfqq = cfq_find_cfq_hash(cfqd, cfq_hash_key(current));
+       if (!cfqq)
+               goto out;
 
-               if (cfqq->queued[rw] > limit)
-                       ret = 0;
-       }
+       /*
+        * if higher or equal prio io is sleeping waiting for a request, don't
+        * allow this one to allocate one. as long as ll_rw_blk does fifo
+        * waitqueue wakeups this should work...
+        */
+       if (cfqd->rq_starved_mask & ~((1 << prio) - 1))
+               goto out;
+
+       if (cfqq->queued[rw] < cfqd->cfq_queued || !cfqd->cid[prio].busy_queues)
+               goto out;
+
+       limit = q->nr_requests * (prio + 1) / IOPRIO_NR;
+       limit /= cfqd->cid[prio].busy_queues;
+       if (cfqq->queued[rw] > limit)
+               ret = 0;
 out:
        return ret;
 }
@@ -622,13 +1060,13 @@ out:
 static void cfq_put_request(request_queue_t *q, struct request *rq)
 {
        struct cfq_data *cfqd = q->elevator.elevator_data;
-       struct cfq_rq *crq = RQ_DATA(rq);
+       struct cfq_rq *crq = RQ_ELV_DATA(rq);
        struct request_list *rl;
        int other_rw;
 
        if (crq) {
                BUG_ON(q->last_merge == rq);
-               BUG_ON(ON_MHASH(crq));
+               BUG_ON(!hlist_unhashed(&crq->hash));
 
                mempool_free(crq, cfqd->crq_pool);
                rq->elevator_private = NULL;
@@ -661,17 +1099,21 @@ static int cfq_set_request(request_queue_t *q, struct request *rq, int gfp_mask)
        /*
         * prepare a queue up front, so cfq_enqueue() doesn't have to
         */
-       cfqq = cfq_get_queue(cfqd, current->tgid, gfp_mask);
+       cfqq = cfq_get_queue(cfqd, cfq_hash_key(current), gfp_mask);
        if (!cfqq)
                return 1;
 
        crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
        if (crq) {
+               /*
+                * process now has one request
+                */
+               clear_bit(cfq_ioprio(current), &cfqd->rq_starved_mask);
+
                memset(crq, 0, sizeof(*crq));
-               RB_CLEAR(&crq->rb_node);
                crq->request = rq;
-               crq->cfq_queue = NULL;
-               INIT_LIST_HEAD(&crq->hash);
+               INIT_HLIST_NODE(&crq->hash);
+               INIT_LIST_HEAD(&crq->prio_list);
                rq->elevator_private = crq;
                return 0;
        }
@@ -690,6 +1132,26 @@ static void cfq_exit(request_queue_t *q, elevator_t *e)
        kfree(cfqd);
 }
 
+static void cfq_timer(unsigned long data)
+{
+       struct cfq_data *cfqd = (struct cfq_data *) data;
+
+       clear_bit(CFQ_WAIT_RT, &cfqd->flags);
+       clear_bit(CFQ_WAIT_NORM, &cfqd->flags);
+       kblockd_schedule_work(&cfqd->work);
+}
+
+static void cfq_work(void *data)
+{
+       request_queue_t *q = data;
+       unsigned long flags;
+
+       spin_lock_irqsave(q->queue_lock, flags);
+       if (cfq_next_request(q))
+               q->request_fn(q);
+       spin_unlock_irqrestore(q->queue_lock, flags);
+}
+
 static int cfq_init(request_queue_t *q, elevator_t *e)
 {
        struct cfq_data *cfqd;
@@ -700,38 +1162,75 @@ static int cfq_init(request_queue_t *q, elevator_t *e)
                return -ENOMEM;
 
        memset(cfqd, 0, sizeof(*cfqd));
-       INIT_LIST_HEAD(&cfqd->rr_list);
+       init_timer(&cfqd->timer);
+       cfqd->timer.function = cfq_timer;
+       cfqd->timer.data = (unsigned long) cfqd;
+
+       INIT_WORK(&cfqd->work, cfq_work, q);
+
+       for (i = 0; i < IOPRIO_NR; i++) {
+               struct io_prio_data *cid = &cfqd->cid[i];
+
+               INIT_LIST_HEAD(&cid->rr_list);
+               INIT_LIST_HEAD(&cid->prio_list);
+               cid->last_rq = -1;
+               cid->last_sectors = -1;
+
+               atomic_set(&cid->cum_rq_in,0);          
+               atomic_set(&cid->cum_rq_out,0);
+               atomic_set(&cid->cum_sectors_in,0);
+               atomic_set(&cid->cum_sectors_out,0);            
+               atomic_set(&cid->cum_queues_in,0);
+               atomic_set(&cid->cum_queues_out,0);
+#if 0
+               atomic_set(&cid->nskip,0);
+               atomic_set(&cid->navsec,0);
+               atomic_set(&cid->csectorate,0);
+               atomic_set(&cid->lsectorate,0);
+#endif
+       }
 
-       cfqd->crq_hash = kmalloc(sizeof(struct list_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL);
+       cfqd->crq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_MHASH_ENTRIES,
+                                GFP_KERNEL);
        if (!cfqd->crq_hash)
                goto out_crqhash;
 
-       cfqd->cfq_hash = kmalloc(sizeof(struct list_head) * CFQ_QHASH_ENTRIES, GFP_KERNEL);
+       cfqd->cfq_hash = kmalloc(sizeof(struct hlist_head) * CFQ_QHASH_ENTRIES,
+                                GFP_KERNEL);
        if (!cfqd->cfq_hash)
                goto out_cfqhash;
 
-       cfqd->crq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, crq_pool);
+       cfqd->crq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, 
+                                       mempool_free_slab, crq_pool);
        if (!cfqd->crq_pool)
                goto out_crqpool;
 
        for (i = 0; i < CFQ_MHASH_ENTRIES; i++)
-               INIT_LIST_HEAD(&cfqd->crq_hash[i]);
+               INIT_HLIST_HEAD(&cfqd->crq_hash[i]);
        for (i = 0; i < CFQ_QHASH_ENTRIES; i++)
-               INIT_LIST_HEAD(&cfqd->cfq_hash[i]);
+               INIT_HLIST_HEAD(&cfqd->cfq_hash[i]);
+
+       cfqd->cfq_queued = cfq_queued;
+       cfqd->cfq_quantum = cfq_quantum;
+       cfqd->cfq_quantum_io = cfq_quantum_io;
+       cfqd->cfq_idle_quantum = cfq_idle_quantum;
+       cfqd->cfq_idle_quantum_io = cfq_idle_quantum_io;
+       cfqd->cfq_grace_rt = cfq_grace_rt;
+       cfqd->cfq_grace_idle = cfq_grace_idle;
+
+       q->nr_requests <<= 2;
 
        cfqd->dispatch = &q->queue_head;
        e->elevator_data = cfqd;
        cfqd->queue = q;
 
-       /*
-        * just set it to some high value, we want anyone to be able to queue
-        * some requests. fairness is handled differently
-        */
-       cfqd->max_queued = q->nr_requests;
-       q->nr_requests = 8192;
-
-       cfqd->cfq_queued = cfq_queued;
-       cfqd->cfq_quantum = cfq_quantum;
+       cfqd->cfq_epoch = CFQ_EPOCH;
+       if (q->hardsect_size)
+               cfqd->cfq_epochsectors = ((CFQ_DISKBW * 1000000)/
+                                     q->hardsect_size)* (1000000 / CFQ_EPOCH);
+       else
+               cfqd->cfq_epochsectors = ((CFQ_DISKBW * 1000000)/512)
+                       * (1000000 / CFQ_EPOCH) ;
 
        return 0;
 out_crqpool:
@@ -797,7 +1296,12 @@ static ssize_t __FUNC(struct cfq_data *cfqd, char *page)          \
        return cfq_var_show(__VAR, (page));                             \
 }
 SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum);
+SHOW_FUNCTION(cfq_quantum_io_show, cfqd->cfq_quantum_io);
+SHOW_FUNCTION(cfq_idle_quantum_show, cfqd->cfq_idle_quantum);
+SHOW_FUNCTION(cfq_idle_quantum_io_show, cfqd->cfq_idle_quantum_io);
 SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued);
+SHOW_FUNCTION(cfq_grace_rt_show, cfqd->cfq_grace_rt);
+SHOW_FUNCTION(cfq_grace_idle_show, cfqd->cfq_grace_idle);
 #undef SHOW_FUNCTION
 
 #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX)                                \
@@ -811,23 +1315,271 @@ static ssize_t __FUNC(struct cfq_data *cfqd, const char *page, size_t count)    \
        return ret;                                                     \
 }
 STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, INT_MAX);
+STORE_FUNCTION(cfq_quantum_io_store, &cfqd->cfq_quantum_io, 4, INT_MAX);
+STORE_FUNCTION(cfq_idle_quantum_store, &cfqd->cfq_idle_quantum, 1, INT_MAX);
+STORE_FUNCTION(cfq_idle_quantum_io_store, &cfqd->cfq_idle_quantum_io, 4, INT_MAX);
 STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, INT_MAX);
+STORE_FUNCTION(cfq_grace_rt_store, &cfqd->cfq_grace_rt, 0, INT_MAX);
+STORE_FUNCTION(cfq_grace_idle_store, &cfqd->cfq_grace_idle, 0, INT_MAX);
 #undef STORE_FUNCTION
 
+
+static ssize_t cfq_epoch_show(struct cfq_data *cfqd, char *page)
+{
+       return sprintf(page, "%lu\n", cfqd->cfq_epoch);
+}
+
+static ssize_t cfq_epoch_store(struct cfq_data *cfqd, const char *page, size_t count)
+{
+       char *p = (char *) page;
+       cfqd->cfq_epoch = simple_strtoul(p, &p, 10);
+       return count;
+}
+
+static ssize_t cfq_epochsectors_show(struct cfq_data *cfqd, char *page)
+{
+       return sprintf(page, "%lu\n", cfqd->cfq_epochsectors);
+}
+
+static ssize_t 
+cfq_epochsectors_store(struct cfq_data *cfqd, const char *page, size_t count)
+{
+       char *p = (char *) page;
+       cfqd->cfq_epochsectors = simple_strtoul(p, &p, 10);
+       return count;
+}
+
+/* Additional entries to get priority level data */
+static ssize_t
+cfq_prio_show(struct cfq_data *cfqd, char *page, unsigned int priolvl)
+{
+       int r1,r2,s1,s2,q1,q2;
+
+       if (!(priolvl >= IOPRIO_IDLE && priolvl <= IOPRIO_RT)) 
+               return 0;
+       
+       r1 = (int)atomic_read(&(cfqd->cid[priolvl].cum_rq_in));
+       r2 = (int)atomic_read(&(cfqd->cid[priolvl].cum_rq_out));
+       s1 = (int)atomic_read(&(cfqd->cid[priolvl].cum_sectors_in));
+       s2 = (int)atomic_read(&(cfqd->cid[priolvl].cum_sectors_out));
+       q1 = (int)atomic_read(&(cfqd->cid[priolvl].cum_queues_in)); 
+       q2 = (int)atomic_read(&(cfqd->cid[priolvl].cum_queues_out));
+       
+       return sprintf(page,"skip %d avsec %lu rate %lu new %lu"
+                      "rq (%d,%d) sec (%d,%d) q (%d,%d)\n",
+                      cfqd->cid[priolvl].nskip,
+                      cfqd->cid[priolvl].navsec,
+                      cfqd->cid[priolvl].csectorate,
+                      cfqd->cid[priolvl].lsectorate,
+//                    atomic_read(&cfqd->cid[priolvl].nskip),
+//                    atomic_read(&cfqd->cid[priolvl].navsec),
+//                    atomic_read(&cfqd->cid[priolvl].csectorate),
+//                    atomic_read(&cfqd->cid[priolvl].lsectorate),
+                      r1,r2,
+                      s1,s2,
+                      q1,q2);
+}
+
+#define SHOW_PRIO_DATA(__PRIOLVL)                                               \
+static ssize_t cfq_prio_##__PRIOLVL##_show(struct cfq_data *cfqd, char *page)  \
+{                                                                              \
+       return cfq_prio_show(cfqd,page,__PRIOLVL);                              \
+}
+SHOW_PRIO_DATA(0);
+SHOW_PRIO_DATA(1);
+SHOW_PRIO_DATA(2);
+SHOW_PRIO_DATA(3);
+SHOW_PRIO_DATA(4);
+SHOW_PRIO_DATA(5);
+SHOW_PRIO_DATA(6);
+SHOW_PRIO_DATA(7);
+SHOW_PRIO_DATA(8);
+SHOW_PRIO_DATA(9);
+SHOW_PRIO_DATA(10);
+SHOW_PRIO_DATA(11);
+SHOW_PRIO_DATA(12);
+SHOW_PRIO_DATA(13);
+SHOW_PRIO_DATA(14);
+SHOW_PRIO_DATA(15);
+SHOW_PRIO_DATA(16);
+SHOW_PRIO_DATA(17);
+SHOW_PRIO_DATA(18);
+SHOW_PRIO_DATA(19);
+SHOW_PRIO_DATA(20);
+#undef SHOW_PRIO_DATA
+
+
+static ssize_t cfq_prio_store(struct cfq_data *cfqd, const char *page, size_t count, int priolvl)
+{      
+       atomic_set(&(cfqd->cid[priolvl].cum_rq_in),0);
+       atomic_set(&(cfqd->cid[priolvl].cum_rq_out),0);
+       atomic_set(&(cfqd->cid[priolvl].cum_sectors_in),0);
+       atomic_set(&(cfqd->cid[priolvl].cum_sectors_out),0);
+       atomic_set(&(cfqd->cid[priolvl].cum_queues_in),0);
+       atomic_set(&(cfqd->cid[priolvl].cum_queues_out),0);
+
+       return count;
+}
+
+
+#define STORE_PRIO_DATA(__PRIOLVL)                                                                \
+static ssize_t cfq_prio_##__PRIOLVL##_store(struct cfq_data *cfqd, const char *page, size_t count) \
+{                                                                                                 \
+        return cfq_prio_store(cfqd,page,count,__PRIOLVL);                                          \
+}                  
+STORE_PRIO_DATA(0);     
+STORE_PRIO_DATA(1);
+STORE_PRIO_DATA(2);
+STORE_PRIO_DATA(3);
+STORE_PRIO_DATA(4);
+STORE_PRIO_DATA(5);
+STORE_PRIO_DATA(6);
+STORE_PRIO_DATA(7);
+STORE_PRIO_DATA(8);
+STORE_PRIO_DATA(9);
+STORE_PRIO_DATA(10);
+STORE_PRIO_DATA(11);
+STORE_PRIO_DATA(12);
+STORE_PRIO_DATA(13);
+STORE_PRIO_DATA(14);
+STORE_PRIO_DATA(15);
+STORE_PRIO_DATA(16);
+STORE_PRIO_DATA(17);
+STORE_PRIO_DATA(18);
+STORE_PRIO_DATA(19);
+STORE_PRIO_DATA(20);
+#undef STORE_PRIO_DATA
+
+
 static struct cfq_fs_entry cfq_quantum_entry = {
        .attr = {.name = "quantum", .mode = S_IRUGO | S_IWUSR },
        .show = cfq_quantum_show,
        .store = cfq_quantum_store,
 };
+static struct cfq_fs_entry cfq_quantum_io_entry = {
+       .attr = {.name = "quantum_io", .mode = S_IRUGO | S_IWUSR },
+       .show = cfq_quantum_io_show,
+       .store = cfq_quantum_io_store,
+};
+static struct cfq_fs_entry cfq_idle_quantum_entry = {
+       .attr = {.name = "idle_quantum", .mode = S_IRUGO | S_IWUSR },
+       .show = cfq_idle_quantum_show,
+       .store = cfq_idle_quantum_store,
+};
+static struct cfq_fs_entry cfq_idle_quantum_io_entry = {
+       .attr = {.name = "idle_quantum_io", .mode = S_IRUGO | S_IWUSR },
+       .show = cfq_idle_quantum_io_show,
+       .store = cfq_idle_quantum_io_store,
+};
 static struct cfq_fs_entry cfq_queued_entry = {
        .attr = {.name = "queued", .mode = S_IRUGO | S_IWUSR },
        .show = cfq_queued_show,
        .store = cfq_queued_store,
 };
+static struct cfq_fs_entry cfq_grace_rt_entry = {
+       .attr = {.name = "grace_rt", .mode = S_IRUGO | S_IWUSR },
+       .show = cfq_grace_rt_show,
+       .store = cfq_grace_rt_store,
+};
+static struct cfq_fs_entry cfq_grace_idle_entry = {
+       .attr = {.name = "grace_idle", .mode = S_IRUGO | S_IWUSR },
+       .show = cfq_grace_idle_show,
+       .store = cfq_grace_idle_store,
+};
+static struct cfq_fs_entry cfq_epoch_entry = {
+       .attr = {.name = "epoch", .mode = S_IRUGO | S_IWUSR },
+       .show = cfq_epoch_show,
+       .store = cfq_epoch_store,
+};
+static struct cfq_fs_entry cfq_epochsectors_entry = {
+       .attr = {.name = "epochsectors", .mode = S_IRUGO | S_IWUSR },
+       .show = cfq_epochsectors_show,
+       .store = cfq_epochsectors_store,
+};
+
+#define P_0_STR   "p0"
+#define P_1_STR   "p1"
+#define P_2_STR   "p2"
+#define P_3_STR   "p3"
+#define P_4_STR   "p4"
+#define P_5_STR   "p5"
+#define P_6_STR   "p6"
+#define P_7_STR   "p7"
+#define P_8_STR   "p8"
+#define P_9_STR   "p9"
+#define P_10_STR  "p10"
+#define P_11_STR  "p11"
+#define P_12_STR  "p12"
+#define P_13_STR  "p13"
+#define P_14_STR  "p14"
+#define P_15_STR  "p15"
+#define P_16_STR  "p16"
+#define P_17_STR  "p17"
+#define P_18_STR  "p18"
+#define P_19_STR  "p19"
+#define P_20_STR  "p20"
+
+
+#define CFQ_PRIO_SYSFS_ENTRY(__PRIOLVL)                                           \
+static struct cfq_fs_entry cfq_prio_##__PRIOLVL##_entry = {                \
+       .attr = {.name = P_##__PRIOLVL##_STR, .mode = S_IRUGO | S_IWUSR }, \
+       .show = cfq_prio_##__PRIOLVL##_show,                               \
+       .store = cfq_prio_##__PRIOLVL##_store,                             \
+};
+CFQ_PRIO_SYSFS_ENTRY(0);
+CFQ_PRIO_SYSFS_ENTRY(1);
+CFQ_PRIO_SYSFS_ENTRY(2);
+CFQ_PRIO_SYSFS_ENTRY(3);
+CFQ_PRIO_SYSFS_ENTRY(4);
+CFQ_PRIO_SYSFS_ENTRY(5);
+CFQ_PRIO_SYSFS_ENTRY(6);
+CFQ_PRIO_SYSFS_ENTRY(7);
+CFQ_PRIO_SYSFS_ENTRY(8);
+CFQ_PRIO_SYSFS_ENTRY(9);
+CFQ_PRIO_SYSFS_ENTRY(10);
+CFQ_PRIO_SYSFS_ENTRY(11);
+CFQ_PRIO_SYSFS_ENTRY(12);
+CFQ_PRIO_SYSFS_ENTRY(13);
+CFQ_PRIO_SYSFS_ENTRY(14);
+CFQ_PRIO_SYSFS_ENTRY(15);
+CFQ_PRIO_SYSFS_ENTRY(16);
+CFQ_PRIO_SYSFS_ENTRY(17);
+CFQ_PRIO_SYSFS_ENTRY(18);
+CFQ_PRIO_SYSFS_ENTRY(19);
+CFQ_PRIO_SYSFS_ENTRY(20);
+#undef CFQ_PRIO_SYSFS_ENTRY
 
 static struct attribute *default_attrs[] = {
        &cfq_quantum_entry.attr,
+       &cfq_quantum_io_entry.attr,
+       &cfq_idle_quantum_entry.attr,
+       &cfq_idle_quantum_io_entry.attr,
        &cfq_queued_entry.attr,
+       &cfq_grace_rt_entry.attr,
+       &cfq_grace_idle_entry.attr,
+       &cfq_epoch_entry.attr,
+       &cfq_epochsectors_entry.attr,
+       &cfq_prio_0_entry.attr,
+       &cfq_prio_1_entry.attr,
+       &cfq_prio_2_entry.attr,
+       &cfq_prio_3_entry.attr,
+       &cfq_prio_4_entry.attr,
+       &cfq_prio_5_entry.attr,
+       &cfq_prio_6_entry.attr,
+       &cfq_prio_7_entry.attr,
+       &cfq_prio_8_entry.attr,
+       &cfq_prio_9_entry.attr,
+       &cfq_prio_10_entry.attr,
+       &cfq_prio_11_entry.attr,
+       &cfq_prio_12_entry.attr,
+       &cfq_prio_13_entry.attr,
+       &cfq_prio_14_entry.attr,
+       &cfq_prio_15_entry.attr,
+       &cfq_prio_16_entry.attr,
+       &cfq_prio_17_entry.attr,
+       &cfq_prio_18_entry.attr,
+       &cfq_prio_19_entry.attr,
+       &cfq_prio_20_entry.attr,
        NULL,
 };
 
@@ -883,6 +1635,7 @@ elevator_t iosched_cfq = {
        .elevator_set_req_fn =          cfq_set_request,
        .elevator_put_req_fn =          cfq_put_request,
        .elevator_may_queue_fn =        cfq_may_queue,
+       .elevator_set_congested_fn =    cfq_queue_congested,
        .elevator_init_fn =             cfq_init,
        .elevator_exit_fn =             cfq_exit,
 };
diff --git a/drivers/block/ckrm-io.c b/drivers/block/ckrm-io.c
new file mode 100644 (file)
index 0000000..7edfce7
--- /dev/null
@@ -0,0 +1,578 @@
+/* linux/drivers/block/ckrm_io.c : Block I/O Resource Controller for CKRM
+ *
+ * Copyright (C) Shailabh Nagar, IBM Corp. 2004
+ * 
+ * 
+ * Provides best-effort block I/O bandwidth control for CKRM 
+ * This file provides the CKRM API. The underlying scheduler is a 
+ * modified Complete-Fair Queueing (CFQ) iosched.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 29 July 2004
+ *          Third complete rewrite for CKRM's current API
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <asm/errno.h>
+#include <asm/div64.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/fs.h>
+
+#include <linux/ckrm_tc.h>
+#include <linux/ckrm-io.h>
+
+/* Tie to cfq priorities */
+#define CKI_IOPRIO_NORM                IOPRIO_NORM
+
+/* Divisor to get fraction of bandwidth represented by an IOPRIO value */
+/* FIXME: Will not work if IOPRIO_NR > 100 */
+#define CKI_IOPRIO_DIV         (IOPRIO_NR-1)
+/* Minimum ioprio value to be assigned to a class */
+#define CKI_IOPRIO_MIN         1
+
+#define CKI_IOUSAGE_UNIT       512
+
+typedef struct ckrm_io_stats{
+       struct timeval       epochstart ; /* all measurements relative to this 
+                                            start time */
+       unsigned long        blksz;  /* size of bandwidth unit */
+       atomic_t             blkrd;  /* read units submitted to DD */
+       atomic_t             blkwr; /* write units submitted to DD */
+       
+} cki_stats_t;          /* per class I/O statistics */
+
+/* Note
+ * Currently local unit == CFQ I/O priority directly.
+ * CFQ ionice values have an implied bandwidth share so they
+ * can be added, subdivided etc. as long as the initial allocation
+ * of the systemwide default's total is set to the highest CFQ ionice
+ * value (== 100% of disk bandwidth)
+ */
+
+typedef struct ckrm_io_class {
+
+       struct ckrm_core_class *core;
+       struct ckrm_core_class *parent;
+       
+       struct ckrm_shares shares;
+       spinlock_t      shares_lock; /* protect share changes */
+       
+       /* Absolute shares of this class
+        * in local units. 
+        */
+
+       int cnt_guarantee; /* Allocation as parent */
+       int cnt_unused;    /* Allocation to default subclass */
+
+       /* Statistics, for class and default subclass */
+       cki_stats_t stats; 
+       cki_stats_t mystats;
+
+} cki_icls_t;
+
+
+
+/* Internal functions */
+static inline void cki_reset_stats(cki_stats_t *usg);
+static inline void init_icls_one(cki_icls_t *icls);
+static inline int cki_div(int *a, int b, int c);
+//static inline int cki_recalc(cki_icls_t *icls, int rel2abs);
+static void cki_recalc_propagate(cki_icls_t *res, cki_icls_t *parres);
+
+/* External functions e.g. interface to ioscheduler */
+void *cki_tsk_icls (struct task_struct *tsk);
+int cki_tsk_ioprio (struct task_struct *tsk);
+
+extern void cki_cfq_set(icls_tsk_t tskicls, icls_ioprio_t tskioprio);
+
+/* CKRM Resource Controller API functions */
+static void * cki_alloc(struct ckrm_core_class *this,
+                       struct ckrm_core_class * parent);
+static void cki_free(void *res);
+static int cki_setshare(void *res, struct ckrm_shares * shares);
+static int cki_getshare(void *res, struct ckrm_shares * shares);
+static int cki_getstats(void *res, struct seq_file *);
+static int cki_resetstats(void *res);
+static int cki_showconfig(void *res, struct seq_file *sfile);
+static int cki_setconfig(void *res, const char *cfgstr);
+static void cki_chgcls(void *tsk, void *oldres, void *newres);
+
+
+struct ckrm_res_ctlr cki_rcbs;
+
+static inline void cki_reset_stats(cki_stats_t *stats)
+{
+       if (stats) {
+               atomic_set(&stats->blkrd,0);
+               atomic_set(&stats->blkwr,0);
+       }
+}
+
+static inline void init_icls_stats(cki_icls_t *icls)
+{
+       struct timeval tv;
+
+       do_gettimeofday(&tv);
+       icls->stats.epochstart = icls->mystats.epochstart = tv;
+       icls->stats.blksz = icls->mystats.blksz = CKI_IOUSAGE_UNIT;
+       cki_reset_stats(&icls->stats);
+       cki_reset_stats(&icls->mystats);
+}      
+
+/* Initialize icls to default values 
+ * No other classes touched, locks not reinitialized.
+ */
+
+static inline void init_icls_one(cki_icls_t *icls)
+{
+       // Assign zero as initial guarantee otherwise creations
+       // could fail due to inadequate share
+
+       //icls->shares.my_guarantee = 
+       //      (CKI_IOPRIO_MIN * CKRM_SHARE_DFLT_TOTAL_GUARANTEE) / 
+       //      CKI_IOPRIO_DIV ;
+       icls->shares.my_guarantee = 0;
+       icls->shares.my_limit = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       icls->shares.total_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       icls->shares.max_limit = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+
+       icls->shares.unused_guarantee = icls->shares.total_guarantee - 
+               icls->shares.my_guarantee;
+       icls->shares.cur_max_limit = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+
+
+       icls->cnt_guarantee = icls->cnt_unused = IOPRIO_IDLE;
+
+       //Same rationale icls->ioprio = CKI_IOPRIO_MIN;
+       //IOPRIO_IDLE equivalence to zero my_guarantee (set above) relies
+       //on former being zero.
+       
+       init_icls_stats(icls);
+}
+
+
+static inline int cki_div(int *a, int b, int c)
+{
+       u64 temp = (u64) b * c ;
+       do_div(temp,CKI_IOPRIO_DIV);
+       *a = (int) temp;
+
+       return 0;
+}
+       
+
+/* Recalculate absolute shares from relative (rel2abs=1)
+ * or vice versa (rel2abs=0) 
+ * Caller should have a lock on icls
+ */
+
+static void cki_recalc_propagate(cki_icls_t *res, cki_icls_t *parres)
+{
+
+       ckrm_core_class_t *child = NULL;
+       cki_icls_t *childres;
+       int resid = cki_rcbs.resid;
+
+       if (parres) {
+               struct ckrm_shares *par = &parres->shares;
+               struct ckrm_shares *self = &res->shares;
+
+
+
+               if (parres->cnt_guarantee == CKRM_SHARE_DONTCARE) {
+                       res->cnt_guarantee = CKRM_SHARE_DONTCARE;
+               } else if (par->total_guarantee) {
+                       u64 temp = (u64) self->my_guarantee * 
+                               parres->cnt_guarantee;
+                       do_div(temp, par->total_guarantee);
+                       res->cnt_guarantee = (int) temp;
+               } else {
+                       res->cnt_guarantee = 0;
+               }
+
+               if (res->cnt_guarantee == CKRM_SHARE_DONTCARE) {
+                       res->cnt_unused = CKRM_SHARE_DONTCARE;
+               } else if (self->total_guarantee) {
+                       u64 temp = (u64) self->unused_guarantee * 
+                               res->cnt_guarantee;
+                       do_div(temp, self->total_guarantee);
+                       res->cnt_unused = (int) temp;
+               } else {
+                       res->cnt_unused = 0;
+               }
+       }
+       // propagate to children
+       ckrm_lock_hier(res->core);
+       while ((child = ckrm_get_next_child(res->core,child)) != NULL){
+               childres = ckrm_get_res_class(child, resid, 
+                                             cki_icls_t);
+               
+               spin_lock(&childres->shares_lock);
+               cki_recalc_propagate(childres, res);
+               spin_unlock(&childres->shares_lock);
+       }
+       ckrm_unlock_hier(res->core);
+}
+
+#if 0
+static inline int cki_recalc(cki_icls_t *icls, int rel2abs)
+{
+       u64 temp;
+
+       if (icls->parent == NULL) {
+               /* Root, as parent, always gets all */
+
+               temp = icls->shares.my_guarantee * (IOPRIO_NR-1);
+               do_div(temp, icls->shares.total_guarantee);
+
+               icls->total = IOPRIO_NR-1;
+               icls->ioprio = temp ;
+               icls->unused = icls->total - icls->ioprio;
+//             icls->unused = (IOPRIO_NR-1)-icls->ioprio;
+
+       } else {
+               cki_icls_t *parres;
+               int partot ;
+               
+               parres = ckrm_get_res_class(icls->parent,
+                                           cki_rcbs.resid,
+                                           cki_icls_t);
+               if (!parres) {
+                       printk(KERN_ERR "cki_recalc: error getting "
+                              "resclass from core \n");
+                       return -EINVAL;
+               }
+
+
+               temp = (icls->shares.my_guarantee * 
+                       parres->total);
+               do_div(temp, parres->shares.total_guarantee);
+
+               icls->ioprio = temp;
+               icls->unused = 0;
+
+       }
+       
+       return 0;
+
+}
+#endif
+
+void *cki_tsk_icls(struct task_struct *tsk)
+{
+       return (void *) ckrm_get_res_class(class_core(tsk->taskclass),
+                                          cki_rcbs.resid, cki_icls_t);
+}
+
+int cki_tsk_ioprio(struct task_struct *tsk)
+{
+       cki_icls_t *icls = ckrm_get_res_class(class_core(tsk->taskclass),
+                                          cki_rcbs.resid, cki_icls_t);
+       return icls->cnt_unused;
+}
+
+static void *cki_alloc(struct ckrm_core_class *core,
+                        struct ckrm_core_class *parent)
+{
+       cki_icls_t *icls;
+       
+       icls = kmalloc(sizeof(cki_icls_t), GFP_ATOMIC);
+       if (!icls) {
+               printk(KERN_ERR "cki_res_alloc failed GFP_ATOMIC\n");
+               return NULL;
+       }
+
+       memset(icls, 0, sizeof(cki_icls_t));
+       icls->core = core;
+       icls->parent = parent;
+       icls->shares_lock = SPIN_LOCK_UNLOCKED;
+
+       if (parent == NULL) {
+
+               /* Root class gets same as "normal" CFQ priorities to
+                * retain compatibility of behaviour in the absence of 
+                * other classes
+                */
+
+               icls->cnt_guarantee = icls->cnt_unused = IOPRIO_NR-1; 
+
+               /* Default gets normal, not minimum */
+               //icls->unused = IOPRIO_NORM;
+               //icls->unused = icls->guarantee-icls->myguarantee;
+               //icls->limit = icls->mylimit = IOPRIO_NR;
+
+               /* Compute shares in abstract units */
+               icls->shares.total_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+
+               // my_guarantee for root is meaningless. Set to default
+               icls->shares.my_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+
+               icls->shares.unused_guarantee = 
+                       CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+
+               //temp = (u64) icls->cnt_unused * icls->shares.total_guarantee;
+               //do_div(temp, CKI_IOPRIO_DIV); 
+               // temp now has root's default's share
+               //icls->shares.unused_guarantee = 
+               // icls->shares.total_guarantee - temp; 
+
+               icls->shares.my_limit = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+               icls->shares.max_limit = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+               icls->shares.cur_max_limit = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+
+       } else {
+               init_icls_one(icls);
+               /* No propagation to parent needed if icls'
+                  initial share is zero */
+       }
+       try_module_get(THIS_MODULE);
+       return icls;
+}
+
+static void cki_free(void *res)
+{
+       cki_icls_t *icls = res, *parres;
+       
+       if (!res)
+               return;
+
+       /* Deallocate CFQ queues */
+
+       /* Currently CFQ queues are deallocated when empty. Since no task 
+        * should belong to this icls, no new requests will get added to the
+        * CFQ queue. 
+        * 
+        * When CFQ switches to persistent queues, call its "put" function
+        * so it gets deallocated after the last pending request is serviced.
+        *
+        */
+
+       parres = ckrm_get_res_class(icls->parent,
+                                   cki_rcbs.resid,
+                                   cki_icls_t);
+       if (!parres) {
+               printk(KERN_ERR "cki_free: error getting "
+                      "resclass from core \n");
+               return;
+       }
+
+       /* Update parent's shares */
+       spin_lock(&parres->shares_lock);
+       child_guarantee_changed(&parres->shares, icls->shares.my_guarantee, 0);
+       parres->cnt_unused += icls->cnt_guarantee;
+       spin_unlock(&parres->shares_lock);
+
+       kfree(res);
+       module_put(THIS_MODULE);
+       return;
+}
+
+
+static int cki_setshare(void *res, struct ckrm_shares *new)
+{
+       cki_icls_t *icls = res, *parres;
+       struct ckrm_shares *cur, *par;
+       int rc = -EINVAL, resid = cki_rcbs.resid;
+
+       if (!icls) {
+               printk(KERN_ERR "No class\n");
+               return rc;
+       }
+
+       cur = &icls->shares; 
+
+       /* limits not supported */
+       if ((new->max_limit != CKRM_SHARE_UNCHANGED)
+           || (new->my_limit != CKRM_SHARE_UNCHANGED)) {
+               printk(KERN_ERR "limits not supported\n");
+               return -EINVAL;
+       }
+
+       if (icls->parent) {
+               parres =
+                   ckrm_get_res_class(icls->parent, resid, cki_icls_t);
+               if (!parres) {
+                       printk(KERN_ERR "cki_setshare: error getting "
+                              "resclass from core \n");
+                       return -EINVAL;
+               }
+               spin_lock(&parres->shares_lock);
+               spin_lock(&icls->shares_lock);
+               par = &parres->shares;
+       } else {
+               spin_lock(&icls->shares_lock);
+               parres = NULL;
+               par = NULL;
+       }
+
+       rc = set_shares(new, cur, par);
+       printk(KERN_ERR "rc from set_shares %d\n", rc);
+
+       if ((!rc) && parres) {
+               
+               if (parres->cnt_guarantee == CKRM_SHARE_DONTCARE) {
+                       parres->cnt_unused = CKRM_SHARE_DONTCARE;
+               } else if (par->total_guarantee) {
+                       u64 temp = (u64) par->unused_guarantee * 
+                               parres->cnt_guarantee;
+                       do_div(temp, par->total_guarantee);
+                       parres->cnt_unused = (int) temp;
+               } else {
+                       parres->cnt_unused = 0;
+               }
+               cki_recalc_propagate(res, parres);
+       
+#if 0
+               int old = icls->ioprio;
+               
+               rc = cki_recalc(icls,0);
+
+               if (!rc && parres) {
+                       int raise_tot = icls->ioprio - old ;
+                       parres->unused -= raise_tot ;
+               }
+#endif
+       }
+       spin_unlock(&icls->shares_lock);
+       if (icls->parent) {
+               spin_unlock(&parres->shares_lock);
+       }
+       return rc;
+}
+
+static int cki_getshare(void *res, struct ckrm_shares * shares)
+{
+       cki_icls_t *icls = res;
+
+       if (!icls)
+               return -EINVAL;
+       *shares = icls->shares;
+       return 0;
+}
+
+static int cki_getstats(void *res, struct seq_file *sfile)
+{
+       cki_icls_t *icls = res;
+
+       if (!icls)
+               return -EINVAL;
+
+/*     
+       seq_printf(sfile, "%d my_read\n",atomic_read(&icls->mystats.blkrd));
+       seq_printf(sfile, "%d my_write\n",atomic_read(&icls->mystats.blkwr));
+       seq_printf(sfile, "%d total_read\n",atomic_read(&icls->stats.blkrd));
+       seq_printf(sfile, "%d total_write\n",atomic_read(&icls->stats.blkwr));
+*/
+       
+       seq_printf(sfile, "%d total ioprio\n",icls->cnt_guarantee);
+       seq_printf(sfile, "%d unused/default ioprio\n",icls->cnt_unused);
+
+       return 0;
+}
+
+static int cki_resetstats(void *res)
+{
+       cki_icls_t *icls = res;
+
+       if (!res)
+               return -EINVAL;
+       
+       init_icls_stats(icls);
+       return 0;
+}
+
+static int cki_showconfig(void *res, struct seq_file *sfile)
+{
+       return -ENOSYS;
+}
+       
+static int cki_setconfig(void *res, const char *cfgstr)
+{
+       return -ENOSYS;
+}
+
+static void cki_chgcls(void *tsk, void *oldres, void *newres)
+{
+       /* cki_icls_t *oldicls = oldres, *newicls = newres; */
+       
+       /* Nothing needs to be done 
+        * Future requests from task will go to the new class's CFQ q
+        * Old ones will continue to get satisfied from the original q
+        * 
+        * Once CFQ moves to a persistent queue model and if refcounts on 
+        * icls's CFQ queues are used, a decrement op would be needed here
+        */
+       
+       return;
+}
+
+
+
+struct ckrm_res_ctlr cki_rcbs = {
+       .res_name = "io",
+       .res_hdepth = 1,
+       .resid = -1,
+       .res_alloc = cki_alloc,
+       .res_free = cki_free,
+       .set_share_values = cki_setshare,
+       .get_share_values = cki_getshare,
+       .get_stats = cki_getstats,
+       .reset_stats = cki_resetstats,
+       .show_config = cki_showconfig,
+       .set_config = cki_setconfig,
+       .change_resclass = cki_chgcls,
+};
+
+
+
+int __init cki_init(void)
+{
+       struct ckrm_classtype *clstype;
+       int resid = cki_rcbs.resid;
+
+       clstype = ckrm_find_classtype_by_name("taskclass");
+       if (clstype == NULL) {
+               printk(KERN_INFO "init_cki: classtype<taskclass> not found\n");
+               return -ENOENT;
+       }
+
+       if (resid == -1) {
+               resid = ckrm_register_res_ctlr(clstype, &cki_rcbs);
+               if (resid != -1) {
+                       cki_rcbs.classtype = clstype;
+                       cki_cfq_set(cki_tsk_icls,cki_tsk_ioprio);
+               }
+       }
+       
+       return 0;
+}
+       
+void __exit cki_exit(void)
+{
+       ckrm_unregister_res_ctlr(&cki_rcbs);
+       cki_rcbs.resid = -1;
+       cki_rcbs.classtype = NULL; 
+       cki_cfq_set(NULL,NULL);
+}
+
+module_init(cki_init)
+module_exit(cki_exit)
+
+MODULE_AUTHOR("Shailabh Nagar <nagar@watson.ibm.com>");
+MODULE_DESCRIPTION("CKRM Disk I/O Resource Controller");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/block/ckrm-iostub.c b/drivers/block/ckrm-iostub.c
new file mode 100644 (file)
index 0000000..c325d8e
--- /dev/null
@@ -0,0 +1,64 @@
+/* ckrm-iostub.c - Stub file for ckrm_io module
+ *
+ * Copyright (C) Shailabh Nagar,  IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * 
+ * 07 Aug 2004: Created
+ * 
+ */
+
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/ckrm-io.h>
+
+static spinlock_t stub_lock = SPIN_LOCK_UNLOCKED;
+
+static icls_tsk_t tskiclstub;
+static icls_ioprio_t tskiopriostub;
+
+
+void cki_cfq_set(icls_tsk_t tskicls, icls_ioprio_t tskioprio)
+{
+       spin_lock(&stub_lock);
+       tskiclstub = tskicls;
+       tskiopriostub = tskioprio;
+       spin_unlock(&stub_lock);
+}
+
+void *cki_hash_key(struct task_struct *tsk)
+{
+       void *ret;
+       spin_lock(&stub_lock);
+       if (tskiclstub)
+               ret = (*tskiclstub)(tsk);
+       else 
+               ret = (void *) tsk->tgid;
+       spin_unlock(&stub_lock);
+       return ret;
+}
+
+int cki_ioprio(struct task_struct *tsk)
+{
+       int ret;
+       spin_lock(&stub_lock);
+       if (tskiopriostub) 
+               ret = (*tskiopriostub)(tsk);
+       else 
+               ret = tsk->ioprio;
+       spin_unlock(&stub_lock);
+       return ret;
+}
+
+EXPORT_SYMBOL(cki_cfq_set);
+EXPORT_SYMBOL(cki_hash_key);
+EXPORT_SYMBOL(cki_ioprio);
index 35c9385..950eb99 100644 (file)
@@ -339,6 +339,14 @@ void elv_put_request(request_queue_t *q, struct request *rq)
                e->elevator_put_req_fn(q, rq);
 }
 
+void elv_set_congested(request_queue_t *q)
+{
+       elevator_t *e = &q->elevator;
+
+       if (e->elevator_set_congested_fn)
+               e->elevator_set_congested_fn(q);
+}
+
 int elv_may_queue(request_queue_t *q, int rw)
 {
        elevator_t *e = &q->elevator;
@@ -346,7 +354,7 @@ int elv_may_queue(request_queue_t *q, int rw)
        if (e->elevator_may_queue_fn)
                return e->elevator_may_queue_fn(q, rw);
 
-       return 0;
+       return 1;
 }
 
 void elv_completed_request(request_queue_t *q, struct request *rq)
diff --git a/drivers/block/floppy98.c b/drivers/block/floppy98.c
deleted file mode 100644 (file)
index 95031f1..0000000
+++ /dev/null
@@ -1,4682 +0,0 @@
-/*
- *  linux/drivers/block/floppy.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *  Copyright (C) 1993, 1994  Alain Knaff
- *  Copyright (C) 1998 Alan Cox
- */
-/*
- * 02.12.91 - Changed to static variables to indicate need for reset
- * and recalibrate. This makes some things easier (output_byte reset
- * checking etc), and means less interrupt jumping in case of errors,
- * so the code is hopefully easier to understand.
- */
-
-/*
- * This file is certainly a mess. I've tried my best to get it working,
- * but I don't like programming floppies, and I have only one anyway.
- * Urgel. I should check for more errors, and do more graceful error
- * recovery. Seems there are problems with several drives. I've tried to
- * correct them. No promises.
- */
-
-/*
- * As with hd.c, all routines within this file can (and will) be called
- * by interrupts, so extreme caution is needed. A hardware interrupt
- * handler may not sleep, or a kernel panic will happen. Thus I cannot
- * call "floppy-on" directly, but have to set a special timer interrupt
- * etc.
- */
-
-/*
- * 28.02.92 - made track-buffering routines, based on the routines written
- * by entropy@wintermute.wpi.edu (Lawrence Foard). Linus.
- */
-
-/*
- * Automatic floppy-detection and formatting written by Werner Almesberger
- * (almesber@nessie.cs.id.ethz.ch), who also corrected some problems with
- * the floppy-change signal detection.
- */
-
-/*
- * 1992/7/22 -- Hennus Bergman: Added better error reporting, fixed
- * FDC data overrun bug, added some preliminary stuff for vertical
- * recording support.
- *
- * 1992/9/17: Added DMA allocation & DMA functions. -- hhb.
- *
- * TODO: Errors are still not counted properly.
- */
-
-/* 1992/9/20
- * Modifications for ``Sector Shifting'' by Rob Hooft (hooft@chem.ruu.nl)
- * modeled after the freeware MS-DOS program fdformat/88 V1.8 by
- * Christoph H. Hochst\"atter.
- * I have fixed the shift values to the ones I always use. Maybe a new
- * ioctl() should be created to be able to modify them.
- * There is a bug in the driver that makes it impossible to format a
- * floppy as the first thing after bootup.
- */
-
-/*
- * 1993/4/29 -- Linus -- cleaned up the timer handling in the kernel, and
- * this helped the floppy driver as well. Much cleaner, and still seems to
- * work.
- */
-
-/* 1994/6/24 --bbroad-- added the floppy table entries and made
- * minor modifications to allow 2.88 floppies to be run.
- */
-
-/* 1994/7/13 -- Paul Vojta -- modified the probing code to allow three or more
- * disk types.
- */
-
-/*
- * 1994/8/8 -- Alain Knaff -- Switched to fdpatch driver: Support for bigger
- * format bug fixes, but unfortunately some new bugs too...
- */
-
-/* 1994/9/17 -- Koen Holtman -- added logging of physical floppy write
- * errors to allow safe writing by specialized programs.
- */
-
-/* 1995/4/24 -- Dan Fandrich -- added support for Commodore 1581 3.5" disks
- * by defining bit 1 of the "stretch" parameter to mean put sectors on the
- * opposite side of the disk, leaving the sector IDs alone (i.e. Commodore's
- * drives are "upside-down").
- */
-
-/*
- * 1995/8/26 -- Andreas Busse -- added Mips support.
- */
-
-/*
- * 1995/10/18 -- Ralf Baechle -- Portability cleanup; move machine dependent
- * features to asm/floppy.h.
- */
-
-/*
- * 1998/05/07 -- Russell King -- More portability cleanups; moved definition of
- * interrupt and dma channel to asm/floppy.h. Cleaned up some formatting &
- * use of '0' for NULL.
- */
-/*
- * 1998/06/07 -- Alan Cox -- Merged the 2.0.34 fixes for resource allocation
- * failures.
- */
-
-/*
- * 1998/09/20 -- David Weinehall -- Added slow-down code for buggy PS/2-drives.
- */
-
-/*
- * 1999/01/19 -- N.Fujita & Linux/98 Project -- Added code for NEC PC-9800
- * series.
- */
-
-/*
- * 1999/08/13 -- Paul Slootman -- floppy stopped working on Alpha after 24
- * days, 6 hours, 32 minutes and 32 seconds (i.e. MAXINT jiffies; ints were
- * being used to store jiffies, which are unsigned longs).
- */
-
-/*
- * 2000/08/28 -- Arnaldo Carvalho de Melo <acme@conectiva.com.br>
- * - get rid of check_region
- * - s/suser/capable/
- */
-
-/*
- * 2001/08/26 -- Paul Gortmaker - fix insmod oops on machines with no
- * floppy controller (lingering task on list after module is gone... boom.)
- */
-
-/*
- * 2002/02/07 -- Anton Altaparmakov - Fix io ports reservation to correct range
- * (0x3f2-0x3f5, 0x3f7). This fix is a bit of a hack but the proper fix
- * requires many non-obvious changes in arch dependent code.
- */
-
-/*
- * 2002/10/12 -- Osamu Tomita <tomita@cinet.co.jp>
- * split code from floppy.c
- * support NEC PC-9800 only
- */
-
-#define FLOPPY_SANITY_CHECK
-#undef  FLOPPY_SILENT_DCL_CLEAR
-
-/*
-#define PC9800_DEBUG_FLOPPY
-#define PC9800_DEBUG_FLOPPY2
-*/
-
-#define REALLY_SLOW_IO
-
-#define DEBUGT 2
-#define DCL_DEBUG /* debug disk change line */
-
-/* do print messages for unexpected interrupts */
-static int print_unex=1;
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-#include <linux/version.h>
-#include <linux/fdreg.h>
-#include <linux/blkdev.h>
-#include <linux/blkpg.h>
-#include <linux/cdrom.h>       /* for the compatibility eject ioctl */
-#include <linux/completion.h>
-
-/*
- * 1998/1/21 -- Richard Gooch <rgooch@atnf.csiro.au> -- devfs support
- */
-
-
-#include <linux/fd.h>
-#define FLOPPY98_MOTOR_MASK 0x08
-
-#include <linux/hdreg.h>
-#define FD98_STATUS    (0 + FD_IOPORT )
-#define FD98_DATA      (2 + FD_IOPORT )
-#define FD_MODE                (4 + FD_IOPORT )
-#define FD_MODE_CHANGE 0xbe
-#define FD_EMODE_CHANGE        0x4be
-
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/bio.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/mc146818rtc.h> /* CMOS defines */
-#include <linux/ioport.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
-#include <linux/device.h>
-#include <linux/buffer_head.h>         /* for invalidate_buffers() */
-
-/*
- * PS/2 floppies have much slower step rates than regular floppies.
- * It's been recommended that take about 1/4 of the default speed
- * in some more extreme cases.
- */
-static int slow_floppy;
-
-#include <asm/dma.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-#ifndef DEFAULT_FLOPPY_IRQ
-# define DEFAULT_FLOPPY_IRQ    11
-#endif
-#ifndef DEFAULT_FLOPPY_DMA
-# define DEFAULT_FLOPPY_DMA    2
-#endif
-
-static int FLOPPY_IRQ=DEFAULT_FLOPPY_IRQ;
-static int FLOPPY_DMA=DEFAULT_FLOPPY_DMA;
-static int can_use_virtual_dma=2;
-static int auto_detect_mode = 0;
-static int retry_auto_detect = 0;
-#define FD_AFTER_RESET_DELAY 1000
-
-/* =======
- * can use virtual DMA:
- * 0 = use of virtual DMA disallowed by config
- * 1 = use of virtual DMA prescribed by config
- * 2 = no virtual DMA preference configured.  By default try hard DMA,
- * but fall back on virtual DMA when not enough memory available
- */
-
-static int use_virtual_dma;
-/* =======
- * use virtual DMA
- * 0 using hard DMA
- * 1 using virtual DMA
- * This variable is set to virtual when a DMA mem problem arises, and
- * reset back in floppy_grab_irq_and_dma.
- * It is not safe to reset it in other circumstances, because the floppy
- * driver may have several buffers in use at once, and we do currently not
- * record each buffers capabilities
- */
-
-static spinlock_t floppy_lock = SPIN_LOCK_UNLOCKED;
-static struct completion device_release;
-
-static unsigned short virtual_dma_port=0x3f0;
-irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs);
-static int set_mode(char mask, char data);
-static void register_devfs_entries (int drive) __init;
-
-#define K_64   0x10000         /* 64KB */
-
-/* the following is the mask of allowed drives. By default units 2 and
- * 3 of both floppy controllers are disabled, because switching on the
- * motor of these drives causes system hangs on some PCI computers. drive
- * 0 is the low bit (0x1), and drive 7 is the high bit (0x80). Bits are on if
- * a drive is allowed.
- *
- * NOTE: This must come before we include the arch floppy header because
- *       some ports reference this variable from there. -DaveM
- */
-
-static int allowed_drive_mask = 0x0f;
-
-#include <asm/floppy.h>
-
-static int irqdma_allocated;
-
-#define LOCAL_END_REQUEST
-#define DEVICE_NAME "floppy"
-
-#include <linux/blkpg.h>
-#include <linux/cdrom.h> /* for the compatibility eject ioctl */
-#include <linux/completion.h>
-
-static struct request *current_req;
-static struct request_queue *floppy_queue;
-
-#ifndef fd_get_dma_residue
-#define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA)
-#endif
-
-/* Dma Memory related stuff */
-
-#ifndef fd_dma_mem_free
-#define fd_dma_mem_free(addr, size) free_pages(addr, get_order(size))
-#endif
-
-#ifndef fd_dma_mem_alloc
-#define fd_dma_mem_alloc(size) __get_dma_pages(GFP_KERNEL,get_order(size))
-#endif
-
-static inline void fallback_on_nodma_alloc(char **addr, size_t l)
-{
-#ifdef FLOPPY_CAN_FALLBACK_ON_NODMA
-       if (*addr)
-               return; /* we have the memory */
-       if (can_use_virtual_dma != 2)
-               return; /* no fallback allowed */
-       printk("DMA memory shortage. Temporarily falling back on virtual DMA\n");
-       *addr = (char *) nodma_mem_alloc(l);
-#else
-       return;
-#endif
-}
-
-/* End dma memory related stuff */
-
-static unsigned long fake_change;
-static int initialising=1;
-
-#define ITYPE(x) (((x)>>2) & 0x1f)
-#define TOMINOR(x) ((x & 3) | ((x & 4) << 5))
-#define UNIT(x) ((x) & 0x03)           /* drive on fdc */
-#define FDC(x) (((x) & 0x04) >> 2)  /* fdc of drive */
-#define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2))
-                               /* reverse mapping from unit and fdc to drive */
-#define DP (&drive_params[current_drive])
-#define DRS (&drive_state[current_drive])
-#define DRWE (&write_errors[current_drive])
-#define FDCS (&fdc_state[fdc])
-#define CLEARF(x) (clear_bit(x##_BIT, &DRS->flags))
-#define SETF(x) (set_bit(x##_BIT, &DRS->flags))
-#define TESTF(x) (test_bit(x##_BIT, &DRS->flags))
-
-#define UDP (&drive_params[drive])
-#define UDRS (&drive_state[drive])
-#define UDRWE (&write_errors[drive])
-#define UFDCS (&fdc_state[FDC(drive)])
-#define UCLEARF(x) (clear_bit(x##_BIT, &UDRS->flags))
-#define USETF(x) (set_bit(x##_BIT, &UDRS->flags))
-#define UTESTF(x) (test_bit(x##_BIT, &UDRS->flags))
-
-#define DPRINT(format, args...) printk(DEVICE_NAME "%d: " format, current_drive , ## args)
-
-#define PH_HEAD(floppy,head) (((((floppy)->stretch & 2) >>1) ^ head) << 2)
-#define STRETCH(floppy) ((floppy)->stretch & FD_STRETCH)
-
-#define CLEARSTRUCT(x) memset((x), 0, sizeof(*(x)))
-
-/* read/write */
-#define COMMAND raw_cmd->cmd[0]
-#define DR_SELECT raw_cmd->cmd[1]
-#define TRACK raw_cmd->cmd[2]
-#define HEAD raw_cmd->cmd[3]
-#define SECTOR raw_cmd->cmd[4]
-#define SIZECODE raw_cmd->cmd[5]
-#define SECT_PER_TRACK raw_cmd->cmd[6]
-#define GAP raw_cmd->cmd[7]
-#define SIZECODE2 raw_cmd->cmd[8]
-#define NR_RW 9
-
-/* format */
-#define F_SIZECODE raw_cmd->cmd[2]
-#define F_SECT_PER_TRACK raw_cmd->cmd[3]
-#define F_GAP raw_cmd->cmd[4]
-#define F_FILL raw_cmd->cmd[5]
-#define NR_F 6
-
-/*
- * Maximum disk size (in kilobytes). This default is used whenever the
- * current disk size is unknown.
- * [Now it is rather a minimum]
- */
-#define MAX_DISK_SIZE 4 /* 3984*/
-
-
-/*
- * globals used by 'result()'
- */
-#define MAX_REPLIES 16
-static unsigned char reply_buffer[MAX_REPLIES];
-static int inr; /* size of reply buffer, when called from interrupt */
-#define ST0 (reply_buffer[0])
-#define ST1 (reply_buffer[1])
-#define ST2 (reply_buffer[2])
-#define ST3 (reply_buffer[0]) /* result of GETSTATUS */
-#define R_TRACK (reply_buffer[3])
-#define R_HEAD (reply_buffer[4])
-#define R_SECTOR (reply_buffer[5])
-#define R_SIZECODE (reply_buffer[6])
-
-#define SEL_DLY (2*HZ/100)
-
-/*
- * this struct defines the different floppy drive types.
- */
-static struct {
-       struct floppy_drive_params params;
-       const char *name; /* name printed while booting */
-} default_drive_params[]= {
-/* NOTE: the time values in jiffies should be in msec!
- CMOS drive type
-  |     Maximum data rate supported by drive type
-  |     |   Head load time, msec
-  |     |   |   Head unload time, msec (not used)
-  |     |   |   |     Step rate interval, usec
-  |     |   |   |     |       Time needed for spinup time (jiffies)
-  |     |   |   |     |       |      Timeout for spinning down (jiffies)
-  |     |   |   |     |       |      |   Spindown offset (where disk stops)
-  |     |   |   |     |       |      |   |     Select delay
-  |     |   |   |     |       |      |   |     |     RPS
-  |     |   |   |     |       |      |   |     |     |    Max number of tracks
-  |     |   |   |     |       |      |   |     |     |    |     Interrupt timeout
-  |     |   |   |     |       |      |   |     |     |    |     |   Max nonintlv. sectors
-  |     |   |   |     |       |      |   |     |     |    |     |   | -Max Errors- flags */
-{{0,  500, 16, 16, 8000,    1*HZ, 3*HZ,  0, SEL_DLY, 5,  80, 3*HZ, 20, {3,1,2,0,2}, 0,
-      0, { 7, 4, 8, 2, 1, 5, 3,10}, 3*HZ/2, 0 }, "unknown" },
-
-{{1,  300, 16, 16, 8000,    1*HZ, 3*HZ,  0, SEL_DLY, 5,  40, 3*HZ, 17, {3,1,2,0,2}, 0,
-      0, { 1, 0, 0, 0, 0, 0, 0, 0}, 3*HZ/2, 1 }, "360K PC" }, /*5 1/4 360 KB PC*/
-
-{{2,  500, 16, 16, 6000, 4*HZ/10, 3*HZ, 14, SEL_DLY, 6,  83, 3*HZ, 17, {3,1,2,0,2}, 0,
-      0, { 2, 6, 4, 0, 0, 0, 0, 0}, 3*HZ/2, 2 }, "1.2M" }, /*5 1/4 HD AT*/
-
-{{3,  250, 16, 16, 3000,    1*HZ, 3*HZ,  0, SEL_DLY, 5,  83, 3*HZ, 20, {3,1,2,0,2}, 0,
-      0, { 4, 6, 0, 0, 0, 0, 0, 0}, 3*HZ/2, 4 }, "720k" }, /*3 1/2 DD*/
-
-{{4,  500, 16, 16, 4000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5,  83, 3*HZ, 20, {3,1,2,0,2}, 0,
-      0, { 7,10, 2, 4, 6, 0, 0, 0}, 3*HZ/2, 7 }, "1.44M" }, /*3 1/2 HD*/
-
-{{5, 1000, 15,  8, 3000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5,  83, 3*HZ, 40, {3,1,2,0,2}, 0,
-      0, { 7, 8, 4,25,28,22,31,21}, 3*HZ/2, 8 }, "2.88M AMI BIOS" }, /*3 1/2 ED*/
-
-{{6, 1000, 15,  8, 3000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5,  83, 3*HZ, 40, {3,1,2,0,2}, 0,
-      0, { 7, 8, 4,25,28,22,31,21}, 3*HZ/2, 8 }, "2.88M" } /*3 1/2 ED*/
-/*    |  --autodetected formats---    |      |      |
- *    read_track                      |      |    Name printed when booting
- *                                   |     Native format
- *                 Frequency of disk change checks */
-};
-
-static struct floppy_drive_params drive_params[N_DRIVE];
-static struct floppy_drive_struct drive_state[N_DRIVE];
-static struct floppy_write_errors write_errors[N_DRIVE];
-static struct timer_list motor_off_timer[N_DRIVE];
-static struct gendisk *disks[N_DRIVE];
-static struct block_device *opened_bdev[N_DRIVE];
-static DECLARE_MUTEX(open_lock);
-static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
-
-/*
- * This struct defines the different floppy types.
- *
- * Bit 0 of 'stretch' tells if the tracks need to be doubled for some
- * types (e.g. 360kB diskette in 1.2MB drive, etc.).  Bit 1 of 'stretch'
- * tells if the disk is in Commodore 1581 format, which means side 0 sectors
- * are located on side 1 of the disk but with a side 0 ID, and vice-versa.
- * This is the same as the Sharp MZ-80 5.25" CP/M disk format, except that the
- * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical
- * side 0 is on physical side 0 (but with the misnamed sector IDs).
- * 'stretch' should probably be renamed to something more general, like
- * 'options'.  Other parameters should be self-explanatory (see also
- * setfdprm(8)).
- */
-/*
-           Size
-            |  Sectors per track
-            |  | Head
-            |  | |  Tracks
-            |  | |  | Stretch
-            |  | |  | |  Gap 1 size
-            |  | |  | |    |  Data rate, | 0x40 for perp
-            |  | |  | |    |    |  Spec1 (stepping rate, head unload
-            |  | |  | |    |    |    |    /fmt gap (gap2) */
-static struct floppy_struct floppy_type[32] = {
-       {    0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL    }, /*  0 no testing    */
-#if 0
-       {  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"d360"  }, /*  1 360KB PC      */
-#else
-       { 2464,16,2,77,0,0x35,0x48,0xDF,0x74,"d360"  }, /*  1 1.25MB 98     */
-#endif
-       { 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,"h1200" }, /*  2 1.2MB AT      */
-       {  720, 9,1,80,0,0x2A,0x02,0xDF,0x50,"D360"  }, /*  3 360KB SS 3.5" */
-       { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"D720"  }, /*  4 720KB 3.5"    */
-       {  720, 9,2,40,1,0x23,0x01,0xDF,0x50,"h360"  }, /*  5 360KB AT      */
-       { 1440, 9,2,80,0,0x23,0x01,0xDF,0x50,"h720"  }, /*  6 720KB AT      */
-       { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,"H1440" }, /*  7 1.44MB 3.5"   */
-       { 5760,36,2,80,0,0x1B,0x43,0xAF,0x54,"E2880" }, /*  8 2.88MB 3.5"   */
-       { 6240,39,2,80,0,0x1B,0x43,0xAF,0x28,"E3120" }, /*  9 3.12MB 3.5"   */
-
-       { 2880,18,2,80,0,0x25,0x00,0xDF,0x02,"h1440" }, /* 10 1.44MB 5.25"  */
-       { 3360,21,2,80,0,0x1C,0x00,0xCF,0x0C,"H1680" }, /* 11 1.68MB 3.5"   */
-       {  820,10,2,41,1,0x25,0x01,0xDF,0x2E,"h410"  }, /* 12 410KB 5.25"   */
-       { 1640,10,2,82,0,0x25,0x02,0xDF,0x2E,"H820"  }, /* 13 820KB 3.5"    */
-       { 2952,18,2,82,0,0x25,0x00,0xDF,0x02,"h1476" }, /* 14 1.48MB 5.25"  */
-       { 3444,21,2,82,0,0x25,0x00,0xDF,0x0C,"H1722" }, /* 15 1.72MB 3.5"   */
-       {  840,10,2,42,1,0x25,0x01,0xDF,0x2E,"h420"  }, /* 16 420KB 5.25"   */
-       { 1660,10,2,83,0,0x25,0x02,0xDF,0x2E,"H830"  }, /* 17 830KB 3.5"    */
-       { 2988,18,2,83,0,0x25,0x00,0xDF,0x02,"h1494" }, /* 18 1.49MB 5.25"  */
-       { 3486,21,2,83,0,0x25,0x00,0xDF,0x0C,"H1743" }, /* 19 1.74 MB 3.5"  */
-
-       { 1760,11,2,80,0,0x1C,0x09,0xCF,0x00,"h880"  }, /* 20 880KB 5.25"   */
-       { 2080,13,2,80,0,0x1C,0x01,0xCF,0x00,"D1040" }, /* 21 1.04MB 3.5"   */
-       { 2240,14,2,80,0,0x1C,0x19,0xCF,0x00,"D1120" }, /* 22 1.12MB 3.5"   */
-       { 3200,20,2,80,0,0x1C,0x20,0xCF,0x2C,"h1600" }, /* 23 1.6MB 5.25"   */
-       { 3520,22,2,80,0,0x1C,0x08,0xCF,0x2e,"H1760" }, /* 24 1.76MB 3.5"   */
-       { 3840,24,2,80,0,0x1C,0x20,0xCF,0x00,"H1920" }, /* 25 1.92MB 3.5"   */
-       { 6400,40,2,80,0,0x25,0x5B,0xCF,0x00,"E3200" }, /* 26 3.20MB 3.5"   */
-       { 7040,44,2,80,0,0x25,0x5B,0xCF,0x00,"E3520" }, /* 27 3.52MB 3.5"   */
-       { 7680,48,2,80,0,0x25,0x63,0xCF,0x00,"E3840" }, /* 28 3.84MB 3.5"   */
-
-       { 3680,23,2,80,0,0x1C,0x10,0xCF,0x00,"H1840" }, /* 29 1.84MB 3.5"   */
-       { 1600,10,2,80,0,0x25,0x02,0xDF,0x2E,"D800"  }, /* 30 800KB 3.5"    */
-       { 3200,20,2,80,0,0x1C,0x00,0xCF,0x2C,"H1600" }, /* 31 1.6MB 3.5"    */
-};
-
-#define        NUMBER(x)       (sizeof(x) / sizeof(*(x)))
-#define SECTSIZE (_FD_SECTSIZE(*floppy))
-
-/* Auto-detection: Disk type used until the next media change occurs. */
-static struct floppy_struct *current_type[N_DRIVE];
-
-/*
- * User-provided type information. current_type points to
- * the respective entry of this array.
- */
-static struct floppy_struct user_params[N_DRIVE];
-
-static sector_t floppy_sizes[256];
-
-/*
- * The driver is trying to determine the correct media format
- * while probing is set. rw_interrupt() clears it after a
- * successful access.
- */
-static int probing;
-
-/* Synchronization of FDC access. */
-#define FD_COMMAND_NONE -1
-#define FD_COMMAND_ERROR 2
-#define FD_COMMAND_OKAY 3
-
-static volatile int command_status = FD_COMMAND_NONE;
-static unsigned long fdc_busy;
-static DECLARE_WAIT_QUEUE_HEAD(fdc_wait);
-static DECLARE_WAIT_QUEUE_HEAD(command_done);
-
-#define NO_SIGNAL (!interruptible || !signal_pending(current))
-#define CALL(x) if ((x) == -EINTR) return -EINTR
-#define ECALL(x) if ((ret = (x))) return ret;
-#define _WAIT(x,i) CALL(ret=wait_til_done((x),i))
-#define WAIT(x) _WAIT((x),interruptible)
-#define IWAIT(x) _WAIT((x),1)
-
-/* Errors during formatting are counted here. */
-static int format_errors;
-
-/* Format request descriptor. */
-static struct format_descr format_req;
-
-/*
- * Rate is 0 for 500kb/s, 1 for 300kbps, 2 for 250kbps
- * Spec1 is 0xSH, where S is stepping rate (F=1ms, E=2ms, D=3ms etc),
- * H is head unload time (1=16ms, 2=32ms, etc)
- */
-
-/*
- * Track buffer
- * Because these are written to by the DMA controller, they must
- * not contain a 64k byte boundary crossing, or data will be
- * corrupted/lost.
- */
-static char *floppy_track_buffer;
-static int max_buffer_sectors;
-
-static int *errors;
-typedef void (*done_f)(int);
-static struct cont_t {
-       void (*interrupt)(void); /* this is called after the interrupt of the
-                                 * main command */
-       void (*redo)(void); /* this is called to retry the operation */
-       void (*error)(void); /* this is called to tally an error */
-       done_f done; /* this is called to say if the operation has 
-                     * succeeded/failed */
-} *cont;
-
-static void floppy_ready(void);
-static void floppy_start(void);
-static void process_fd_request(void);
-static void recalibrate_floppy(void);
-static void floppy_shutdown(unsigned long);
-
-static int floppy_grab_irq_and_dma(void);
-static void floppy_release_irq_and_dma(void);
-
-/*
- * The "reset" variable should be tested whenever an interrupt is scheduled,
- * after the commands have been sent. This is to ensure that the driver doesn't
- * get wedged when the interrupt doesn't come because of a failed command.
- * reset doesn't need to be tested before sending commands, because
- * output_byte is automatically disabled when reset is set.
- */
-#define CHECK_RESET { if (FDCS->reset){ reset_fdc(); return; } }
-static void reset_fdc(void);
-
-/*
- * These are global variables, as that's the easiest way to give
- * information to interrupts. They are the data used for the current
- * request.
- */
-#define NO_TRACK -1
-#define NEED_1_RECAL -2
-#define NEED_2_RECAL -3
-
-static int usage_count;
-
-/* buffer related variables */
-static int buffer_track = -1;
-static int buffer_drive = -1;
-static int buffer_min = -1;
-static int buffer_max = -1;
-
-/* fdc related variables, should end up in a struct */
-static struct floppy_fdc_state fdc_state[N_FDC];
-static int fdc; /* current fdc */
-
-static struct floppy_struct *_floppy = floppy_type;
-static unsigned char current_drive;
-static long current_count_sectors;
-static unsigned char fsector_t; /* sector in track */
-static unsigned char in_sector_offset; /* offset within physical sector,
-                                        * expressed in units of 512 bytes */
-
-#ifndef fd_eject
-static inline int fd_eject(int drive)
-{
-       return -EINVAL;
-}
-#endif
-
-#ifdef DEBUGT
-static long unsigned debugtimer;
-#endif
-
-/*
- * Debugging
- * =========
- */
-static inline void set_debugt(void)
-{
-#ifdef DEBUGT
-       debugtimer = jiffies;
-#endif
-}
-
-static inline void debugt(const char *message)
-{
-#ifdef DEBUGT
-       if (DP->flags & DEBUGT)
-               printk("%s dtime=%lu\n", message, jiffies-debugtimer);
-#endif
-}
-
-typedef void (*timeout_fn)(unsigned long);
-static struct timer_list fd_timeout = TIMER_INITIALIZER(floppy_shutdown, 0, 0);
-
-static const char *timeout_message;
-
-#ifdef FLOPPY_SANITY_CHECK
-static void is_alive(const char *message)
-{
-       /* this routine checks whether the floppy driver is "alive" */
-       if (fdc_busy && command_status < 2 && !timer_pending(&fd_timeout)){
-               DPRINT("timeout handler died: %s\n",message);
-       }
-}
-#endif
-
-static void (*do_floppy)(void) = NULL;
-
-#ifdef FLOPPY_SANITY_CHECK
-
-#define OLOGSIZE 20
-
-static void (*lasthandler)(void);
-static unsigned long interruptjiffies;
-static unsigned long resultjiffies;
-static int resultsize;
-static unsigned long lastredo;
-
-static struct output_log {
-       unsigned char data;
-       unsigned char status;
-       unsigned long jiffies;
-} output_log[OLOGSIZE];
-
-static int output_log_pos;
-#endif
-
-#define current_reqD -1
-#define MAXTIMEOUT -2
-
-static void reschedule_timeout(int drive, const char *message, int marg)
-{
-       unsigned long delay;
-
-       if (drive == current_reqD)
-               drive = current_drive;
-       if (drive < 0 || drive > N_DRIVE) {
-               delay = 20UL*HZ;
-               drive=0;
-       } else
-               delay = UDP->timeout;
-       mod_timer(&fd_timeout, delay + jiffies);
-       if (UDP->flags & FD_DEBUG){
-               DPRINT("reschedule timeout ");
-               printk(message, marg);
-               printk("\n");
-       }
-       timeout_message = message;
-}
-
-static int maximum(int a, int b)
-{
-       if (a > b)
-               return a;
-       else
-               return b;
-}
-#define INFBOUND(a,b) (a)=maximum((a),(b));
-
-static int minimum(int a, int b)
-{
-       if (a < b)
-               return a;
-       else
-               return b;
-}
-#define SUPBOUND(a,b) (a)=minimum((a),(b));
-
-
-/*
- * Bottom half floppy driver.
- * ==========================
- *
- * This part of the file contains the code talking directly to the hardware,
- * and also the main service loop (seek-configure-spinup-command)
- */
-
-/*
- * disk change.
- * This routine is responsible for maintaining the FD_DISK_CHANGE flag,
- * and the last_checked date.
- *
- * last_checked is the date of the last check which showed 'no disk change'
- * FD_DISK_CHANGE is set under two conditions:
- * 1. The floppy has been changed after some i/o to that floppy already
- *    took place.
- * 2. No floppy disk is in the drive. This is done in order to ensure that
- *    requests are quickly flushed in case there is no disk in the drive. It
- *    follows that FD_DISK_CHANGE can only be cleared if there is a disk in
- *    the drive.
- *
- * For 1., maxblock is observed. Maxblock is 0 if no i/o has taken place yet.
- * For 2., FD_DISK_NEWCHANGE is watched. FD_DISK_NEWCHANGE is cleared on
- *  each seek. If a disk is present, the disk change line should also be
- *  cleared on each seek. Thus, if FD_DISK_NEWCHANGE is clear, but the disk
- *  change line is set, this means either that no disk is in the drive, or
- *  that it has been removed since the last seek.
- *
- * This means that we really have a third possibility too:
- *  The floppy has been changed after the last seek.
- */
-
-static int disk_change(int drive)
-{
-       return UTESTF(FD_DISK_CHANGED);
-}
-
-static int set_mode(char mask, char data)
-{
-       register unsigned char newdor, olddor;
-
-       olddor = FDCS->dor;
-       newdor = (olddor & mask) | data;
-       if (newdor != olddor) {
-               FDCS->dor = newdor;
-               fd_outb(newdor, FD_MODE);
-       }
-
-       if (newdor & FLOPPY98_MOTOR_MASK)
-               floppy_grab_irq_and_dma();
-
-       if (olddor & FLOPPY98_MOTOR_MASK)
-               floppy_release_irq_and_dma();
-
-       return olddor;
-}
-
-static void twaddle(void)
-{
-       if (DP->select_delay)
-               return;
-
-       fd_outb(FDCS->dor & 0xf7, FD_MODE);
-       fd_outb(FDCS->dor, FD_MODE);
-       DRS->select_date = jiffies;
-}
-
-/* reset all driver information about the current fdc. This is needed after
- * a reset, and after a raw command. */
-static void reset_fdc_info(int mode)
-{
-       int drive;
-
-       FDCS->spec1 = FDCS->spec2 = -1;
-       FDCS->need_configure = 1;
-       FDCS->perp_mode = 1;
-       FDCS->rawcmd = 0;
-       for (drive = 0; drive < N_DRIVE; drive++)
-               if (FDC(drive) == fdc &&
-                   (mode || UDRS->track != NEED_1_RECAL))
-                       UDRS->track = NEED_2_RECAL;
-}
-
-/* selects the fdc and drive, and enables the fdc's input/dma. */
-static void set_fdc(int drive)
-{
-       fdc = 0;
-       current_drive = drive;
-       set_mode(~0, 0x10);
-       if (FDCS->rawcmd == 2)
-               reset_fdc_info(1);
-
-       if (fd_inb(FD98_STATUS) != STATUS_READY)
-               FDCS->reset = 1;
-}
-
-/* locks the driver */
-static int _lock_fdc(int drive, int interruptible, int line)
-{
-       if (!usage_count){
-               printk(KERN_ERR "Trying to lock fdc while usage count=0 at line %d\n", line);
-               return -1;
-       }
-       if(floppy_grab_irq_and_dma()==-1)
-               return -EBUSY;
-
-       if (test_and_set_bit(0, &fdc_busy)) {
-               DECLARE_WAITQUEUE(wait, current);
-               add_wait_queue(&fdc_wait, &wait);
-
-               for (;;) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-
-                       if (!test_and_set_bit(0, &fdc_busy))
-                               break;
-
-                       schedule();
-
-                       if (!NO_SIGNAL) {
-                               remove_wait_queue(&fdc_wait, &wait);
-                               return -EINTR;
-                       }
-               }
-
-               set_current_state(TASK_RUNNING);
-               remove_wait_queue(&fdc_wait, &wait);
-       }
-       command_status = FD_COMMAND_NONE;
-
-       reschedule_timeout(drive, "lock fdc", 0);
-       set_fdc(drive);
-       return 0;
-}
-
-#define lock_fdc(drive,interruptible) _lock_fdc(drive,interruptible, __LINE__)
-
-#define LOCK_FDC(drive,interruptible) \
-if (lock_fdc(drive,interruptible)) return -EINTR;
-
-
-/* unlocks the driver */
-static inline void unlock_fdc(void)
-{
-       raw_cmd = 0;
-       if (!fdc_busy)
-               DPRINT("FDC access conflict!\n");
-
-       if (do_floppy)
-               DPRINT("device interrupt still active at FDC release: %p!\n",
-                       do_floppy);
-       command_status = FD_COMMAND_NONE;
-       del_timer(&fd_timeout);
-       cont = NULL;
-       clear_bit(0, &fdc_busy);
-       floppy_release_irq_and_dma();
-       wake_up(&fdc_wait);
-}
-
-#ifndef CONFIG_PC9800_MOTOR_OFF /* tomita */
-
-/* switches the motor off after a given timeout */
-static void motor_off_callback(unsigned long nr)
-{
-       printk(KERN_DEBUG "fdc%lu: turn off motor\n", nr);
-}
-
-/* schedules motor off */
-static void floppy_off(unsigned int drive)
-{
-}
-
-#else /* CONFIG_PC9800_MOTOR_OFF */
-
-/* switches the motor off after a given timeout */
-static void motor_off_callback(unsigned long fdc)
-{
-       printk(KERN_DEBUG "fdc%u: turn off motor\n", (unsigned int) fdc);
-
-       fd_outb(0, FD_MODE);    /* MTON = 0 */
-}
-
-static struct timer_list motor_off_timer[N_FDC] = {
-       { data: 0, function: motor_off_callback },
-#if N_FDC > 1
-       { data: 1, function: motor_off_callback },
-#endif
-#if N_FDC > 2
-# error "N_FDC > 2; please fix initializer for motor_off_timer[]"
-#endif
-};
-
-/* schedules motor off */
-static void floppy_off(unsigned int drive)
-{
-       unsigned long volatile delta;
-       register int fdc = FDC(drive);
-
-       if (!(FDCS->dor & (0x10 << UNIT(drive))))
-               return;
-
-       del_timer(motor_off_timer + fdc);
-
-#if 0
-       /* make spindle stop in a position which minimizes spinup time
-        * next time */
-       if (UDP->rps){
-               delta = jiffies - UDRS->first_read_date + HZ -
-                       UDP->spindown_offset;
-               delta = ((delta * UDP->rps) % HZ) / UDP->rps;
-               motor_off_timer[drive].expires = jiffies + UDP->spindown - delta;
-       }
-#else
-       if (UDP->rps)
-               motor_off_timer[drive].expires = jiffies + UDP->spindown;
-#endif
-
-       add_timer(motor_off_timer + fdc);
-}
-
-#endif /* CONFIG_PC9800_MOTOR_OFF */
-
-/*
- * cycle through all N_DRIVE floppy drives, for disk change testing.
- * stopping at current drive. This is done before any long operation, to
- * be sure to have up to date disk change information.
- */
-static void scandrives(void)
-{
-       int i, drive, saved_drive;
-
-       if (DP->select_delay)
-               return;
-
-       saved_drive = current_drive;
-       for (i=0; i < N_DRIVE; i++){
-               drive = (saved_drive + i + 1) % N_DRIVE;
-               if (UDRS->fd_ref == 0 || UDP->select_delay != 0)
-                       continue; /* skip closed drives */
-               set_fdc(drive);
-       }
-       set_fdc(saved_drive);
-}
-
-static void empty(void)
-{
-}
-
-static DECLARE_WORK(floppy_work, NULL, NULL);
-
-static void schedule_bh(void (*handler) (void))
-{
-       PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
-       schedule_work(&floppy_work);
-}
-
-static struct timer_list fd_timer = TIMER_INITIALIZER(NULL, 0, 0);
-
-static void cancel_activity(void)
-{
-       do_floppy = NULL;
-       PREPARE_WORK(&floppy_work, (void*)(void*)empty, NULL);
-       del_timer(&fd_timer);
-}
-
-/* this function makes sure that the disk stays in the drive during the
- * transfer */
-static void fd_watchdog(void)
-{
-#ifdef DCL_DEBUG
-       if (DP->flags & FD_DEBUG){
-               DPRINT("calling disk change from watchdog\n");
-       }
-#endif
-
-       if (disk_change(current_drive)){
-               DPRINT("disk removed during i/o\n");
-               cancel_activity();
-               cont->done(0);
-               reset_fdc();
-       } else {
-               del_timer(&fd_timer);
-               fd_timer.function = (timeout_fn) fd_watchdog;
-               fd_timer.expires = jiffies + HZ / 10;
-               add_timer(&fd_timer);
-       }
-}
-
-static void main_command_interrupt(void)
-{
-       del_timer(&fd_timer);
-       cont->interrupt();
-}
-
-/* waits for a delay (spinup or select) to pass */
-static int fd_wait_for_completion(unsigned long delay, timeout_fn function)
-{
-       if (FDCS->reset){
-               reset_fdc(); /* do the reset during sleep to win time
-                             * if we don't need to sleep, it's a good
-                             * occasion anyways */
-               return 1;
-       }
-
-       if ((signed) (jiffies - delay) < 0){
-               del_timer(&fd_timer);
-               fd_timer.function = function;
-               fd_timer.expires = delay;
-               add_timer(&fd_timer);
-               return 1;
-       }
-       return 0;
-}
-
-static spinlock_t floppy_hlt_lock = SPIN_LOCK_UNLOCKED;
-static int hlt_disabled;
-static void floppy_disable_hlt(void)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&floppy_hlt_lock, flags);
-       if (!hlt_disabled) {
-               hlt_disabled=1;
-#ifdef HAVE_DISABLE_HLT
-               disable_hlt();
-#endif
-       }
-       spin_unlock_irqrestore(&floppy_hlt_lock, flags);
-}
-
-static void floppy_enable_hlt(void)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&floppy_hlt_lock, flags);
-       if (hlt_disabled){
-               hlt_disabled=0;
-#ifdef HAVE_DISABLE_HLT
-               enable_hlt();
-#endif
-       }
-       spin_unlock_irqrestore(&floppy_hlt_lock, flags);
-}
-
-
-static void setup_DMA(void)
-{
-       unsigned long f;
-
-#ifdef FLOPPY_SANITY_CHECK
-       if (raw_cmd->length == 0){
-               int i;
-
-               printk("zero dma transfer size:");
-               for (i=0; i < raw_cmd->cmd_count; i++)
-                       printk("%x,", raw_cmd->cmd[i]);
-               printk("\n");
-               cont->done(0);
-               FDCS->reset = 1;
-               return;
-       }
-       if (((unsigned long) raw_cmd->kernel_data) % 512){
-               printk("non aligned address: %p\n", raw_cmd->kernel_data);
-               cont->done(0);
-               FDCS->reset=1;
-               return;
-       }
-#endif
-       f=claim_dma_lock();
-       fd_disable_dma();
-#ifdef fd_dma_setup
-       if (fd_dma_setup(raw_cmd->kernel_data, raw_cmd->length, 
-                       (raw_cmd->flags & FD_RAW_READ)?
-                       DMA_MODE_READ : DMA_MODE_WRITE,
-                       FDCS->address) < 0) {
-               release_dma_lock(f);
-               cont->done(0);
-               FDCS->reset=1;
-               return;
-       }
-       release_dma_lock(f);
-#else  
-       fd_clear_dma_ff();
-       fd_cacheflush(raw_cmd->kernel_data, raw_cmd->length);
-       fd_set_dma_mode((raw_cmd->flags & FD_RAW_READ)?
-                       DMA_MODE_READ : DMA_MODE_WRITE);
-       fd_set_dma_addr(raw_cmd->kernel_data);
-       fd_set_dma_count(raw_cmd->length);
-       virtual_dma_port = FDCS->address;
-       fd_enable_dma();
-       release_dma_lock(f);
-#endif
-       floppy_disable_hlt();
-}
-
-static void show_floppy(void);
-
-/* waits until the fdc becomes ready */
-
-#ifdef PC9800_DEBUG_FLOPPY
-#define READY_DELAY 10000000
-#else
-#define READY_DELAY 100000
-#endif
-
-static int wait_til_ready(void)
-{
-       int counter, status;
-       if (FDCS->reset)
-               return -1;
-       for (counter = 0; counter < READY_DELAY; counter++) {
-               status = fd_inb(FD98_STATUS);           
-               if (status & STATUS_READY)
-                       return status;
-       }
-       if (!initialising) {
-               DPRINT("Getstatus times out (%x) on fdc %d\n",
-                       status, fdc);
-               show_floppy();
-       }
-       FDCS->reset = 1;
-       return -1;
-}
-
-/* sends a command byte to the fdc */
-static int output_byte(char byte)
-{
-       int status;
-
-       if ((status = wait_til_ready()) < 0)
-               return -1;
-       if ((status & (STATUS_READY|STATUS_DIR|STATUS_DMA)) == STATUS_READY){
-               fd_outb(byte,FD98_DATA);
-#ifdef FLOPPY_SANITY_CHECK
-               output_log[output_log_pos].data = byte;
-               output_log[output_log_pos].status = status;
-               output_log[output_log_pos].jiffies = jiffies;
-               output_log_pos = (output_log_pos + 1) % OLOGSIZE;
-#endif
-               return 0;
-       }
-       FDCS->reset = 1;
-       if (!initialising) {
-               DPRINT("Unable to send byte %x to FDC. Fdc=%x Status=%x\n",
-                      byte, fdc, status);
-               show_floppy();
-       }
-       return -1;
-}
-#define LAST_OUT(x) if (output_byte(x)<0){ reset_fdc();return;}
-
-/* gets the response from the fdc */
-static int result(void)
-{
-       int i, status=0;
-
-       for(i=0; i < MAX_REPLIES; i++) {
-               if ((status = wait_til_ready()) < 0)
-                       break;
-               status &= STATUS_DIR|STATUS_READY|STATUS_BUSY|STATUS_DMA;
-               if ((status & ~STATUS_BUSY) == STATUS_READY){
-#ifdef FLOPPY_SANITY_CHECK
-                       resultjiffies = jiffies;
-                       resultsize = i;
-#endif
-                       return i;
-               }
-               if (status == (STATUS_DIR|STATUS_READY|STATUS_BUSY))
-                       reply_buffer[i] = fd_inb(FD98_DATA);
-               else
-                       break;
-       }
-       if (!initialising) {
-               DPRINT("get result error. Fdc=%d Last status=%x Read bytes=%d\n",
-                      fdc, status, i);
-               show_floppy();
-       }
-       FDCS->reset = 1;
-       return -1;
-}
-
-static int fifo_depth = 0xa;
-static int no_fifo;
-
-#define NOMINAL_DTR 500
-
-/* Issue a "SPECIFY" command to set the step rate time, head unload time,
- * head load time, and DMA disable flag to values needed by floppy.
- *
- * The value "dtr" is the data transfer rate in Kbps.  It is needed
- * to account for the data rate-based scaling done by the 82072 and 82077
- * FDC types.  This parameter is ignored for other types of FDCs (i.e.
- * 8272a).
- *
- * Note that changing the data transfer rate has a (probably deleterious)
- * effect on the parameters subject to scaling for 82072/82077 FDCs, so
- * fdc_specify is called again after each data transfer rate
- * change.
- *
- * srt: 1000 to 16000 in microseconds
- * hut: 16 to 240 milliseconds
- * hlt: 2 to 254 milliseconds
- *
- * These values are rounded up to the next highest available delay time.
- */
-static void fdc_specify(void)
-{
-       output_byte(FD_SPECIFY);
-       output_byte(FDCS->spec1 = 0xdf);
-       output_byte(FDCS->spec2 = 0x24);
-}
-
-static void tell_sector(void)
-{
-       printk(": track %d, head %d, sector %d, size %d",
-              R_TRACK, R_HEAD, R_SECTOR, R_SIZECODE);
-} /* tell_sector */
-
-static int auto_detect_mode_pc9800(void)
-{
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("auto_detect_mode_pc9800: retry_auto_detect=%d\n",
-               retry_auto_detect);
-#endif
-       if (retry_auto_detect > 4) {
-               retry_auto_detect = 0;     
-               return 1;
-       }
-
-       switch ((int)(_floppy - floppy_type)) {
-               case 2:
-                       _floppy = floppy_type + 4;
-                       break;
-
-               case 4:
-               case 6:
-                       _floppy = floppy_type + 7;
-                       break;
-
-               case 7:
-               case 10:
-                       _floppy = floppy_type + 2;
-                       break;
-
-               default:
-                       _floppy = floppy_type + 7;
-       }
-
-       retry_auto_detect++;
-       return 0;
-}
-
-static void access_mode_change_pc9800(void);
-
-/*
- * OK, this error interpreting routine is called after a
- * DMA read/write has succeeded
- * or failed, so we check the results, and copy any buffers.
- * hhb: Added better error reporting.
- * ak: Made this into a separate routine.
- */
-static int interpret_errors(void)
-{
-       char bad;
-
-       if (inr!=7) {
-               DPRINT("-- FDC reply error");
-               FDCS->reset = 1;
-               return 1;
-       }
-
-       /* check IC to find cause of interrupt */
-       switch (ST0 & ST0_INTR) {
-               case 0x40:      /* error occurred during command execution */
-                       if (ST1 & ST1_EOC)
-                               return 0; /* occurs with pseudo-DMA */
-                       bad = 1;
-                       if (ST1 & ST1_WP) {
-                               DPRINT("Drive is write protected\n");
-                               CLEARF(FD_DISK_WRITABLE);
-                               cont->done(0);
-                               bad = 2;
-                       } else if (ST1 & ST1_ND) {
-                               SETF(FD_NEED_TWADDLE);
-                       } else if (ST1 & ST1_OR) {
-                               if (DP->flags & FTD_MSG)
-                                       DPRINT("Over/Underrun - retrying\n");
-                               bad = 0;
-                       }else if (*errors >= DP->max_errors.reporting){
-                               if (ST0 & ST0_ECE) {
-                                       printk("Recalibrate failed!");
-                               } else if (ST2 & ST2_CRC) {
-                                       printk("data CRC error");
-                                       tell_sector();
-                               } else if (ST1 & ST1_CRC) {
-                                       printk("CRC error");
-                                       tell_sector();
-                               } else if ((ST1 & (ST1_MAM|ST1_ND)) || (ST2 & ST2_MAM)) {
-                                       if (auto_detect_mode) {
-                                               bad = (char)auto_detect_mode_pc9800();
-                                               access_mode_change_pc9800();
-                                       }
-
-                                       if (bad) {
-                                               printk("floppy error: MA: _floppy - floppy_type=%d\n", (int)(_floppy - floppy_type));
-                                               printk("bad=%d\n", (int)bad);
-                                               if (!probing) {
-                                                       printk("sector not found");
-                                                       tell_sector();
-                                               } else
-                                                       printk("probe failed...");
-                                       }
-                               } else if (ST2 & ST2_WC) {      /* seek error */
-                                       printk("wrong cylinder");
-                               } else if (ST2 & ST2_BC) {      /* cylinder marked as bad */
-                                       printk("bad cylinder");
-                               } else {
-                                       printk("unknown error. ST[0..2] are: 0x%x 0x%x 0x%x", ST0, ST1, ST2);
-                                       tell_sector();
-                               }
-                               printk("\n");
-
-                       }
-                       if (ST2 & ST2_WC || ST2 & ST2_BC)
-                               /* wrong cylinder => recal */
-                               DRS->track = NEED_2_RECAL;
-                       return bad;
-               case 0x80: /* invalid command given */
-                       DPRINT("Invalid FDC command given!\n");
-                       cont->done(0);
-                       return 2;
-               case 0xc0:
-                       SETF(FD_DISK_CHANGED);
-                       SETF(FD_DISK_WRITABLE);
-                       DPRINT("Abnormal termination caused by polling\n");
-                       cont->error();
-                       return 2;
-               default: /* (0) Normal command termination */
-                       auto_detect_mode = 0;
-                       return 0;
-       }
-}
-
-/*
- * This routine is called when everything should be correctly set up
- * for the transfer (i.e. floppy motor is on, the correct floppy is
- * selected, and the head is sitting on the right track).
- */
-static void setup_rw_floppy(void)
-{
-       int i,r, flags,dflags;
-       unsigned long ready_date;
-       timeout_fn function;
-
-       access_mode_change_pc9800();
-       flags = raw_cmd->flags;
-       if (flags & (FD_RAW_READ | FD_RAW_WRITE))
-               flags |= FD_RAW_INTR;
-
-       if ((flags & FD_RAW_SPIN) && !(flags & FD_RAW_NO_MOTOR)){
-               ready_date = DRS->spinup_date + DP->spinup;
-               /* If spinup will take a long time, rerun scandrives
-                * again just before spinup completion. Beware that
-                * after scandrives, we must again wait for selection.
-                */
-               if ((signed) (ready_date - jiffies) > DP->select_delay){
-                       ready_date -= DP->select_delay;
-                       function = (timeout_fn) floppy_start;
-               } else
-                       function = (timeout_fn) setup_rw_floppy;
-
-               /* wait until the floppy is spinning fast enough */
-               if (fd_wait_for_completion(ready_date,function))
-                       return;
-       }
-       dflags = DRS->flags;
-
-       if ((flags & FD_RAW_READ) || (flags & FD_RAW_WRITE))
-               setup_DMA();
-
-       if (flags & FD_RAW_INTR)
-               do_floppy = main_command_interrupt;
-
-       r=0;
-       for (i=0; i< raw_cmd->cmd_count; i++)
-               r|=output_byte(raw_cmd->cmd[i]);
-
-#ifdef DEBUGT
-       debugt("rw_command: ");
-#endif
-       if (r){
-               cont->error();
-               reset_fdc();
-               return;
-       }
-
-       if (!(flags & FD_RAW_INTR)){
-               inr = result();
-               cont->interrupt();
-       } else if (flags & FD_RAW_NEED_DISK)
-               fd_watchdog();
-}
-
-static int blind_seek;
-
-/*
- * This is the routine called after every seek (or recalibrate) interrupt
- * from the floppy controller.
- */
-static void seek_interrupt(void)
-{
-#ifdef DEBUGT
-       debugt("seek interrupt:");
-#endif
-       if (inr != 2 || (ST0 & 0xF8) != 0x20) {
-               DRS->track = NEED_2_RECAL;
-               cont->error();
-               cont->redo();
-               return;
-       }
-       if (DRS->track >= 0 && DRS->track != ST1 && !blind_seek){
-#ifdef DCL_DEBUG
-               if (DP->flags & FD_DEBUG){
-                       DPRINT("clearing NEWCHANGE flag because of effective seek\n");
-                       DPRINT("jiffies=%lu\n", jiffies);
-               }
-#endif
-               CLEARF(FD_DISK_NEWCHANGE); /* effective seek */
-               CLEARF(FD_DISK_CHANGED); /* effective seek */
-               DRS->select_date = jiffies;
-       }
-       DRS->track = ST1;
-       floppy_ready();
-}
-
-static void check_wp(void)
-{
-       if (TESTF(FD_VERIFY)) {
-               /* check write protection */
-               output_byte(FD_GETSTATUS);
-               output_byte(UNIT(current_drive));
-               if (result() != 1){
-                       FDCS->reset = 1;
-                       return;
-               }
-               CLEARF(FD_VERIFY);
-               CLEARF(FD_NEED_TWADDLE);
-#ifdef DCL_DEBUG
-               if (DP->flags & FD_DEBUG){
-                       DPRINT("checking whether disk is write protected\n");
-                       DPRINT("wp=%x\n",ST3 & 0x40);
-               }
-#endif
-               if (!(ST3  & 0x40))
-                       SETF(FD_DISK_WRITABLE);
-               else
-                       CLEARF(FD_DISK_WRITABLE);
-       }
-}
-
-static void seek_floppy(void)
-{
-       int track;
-
-       blind_seek=0;
-
-#ifdef DCL_DEBUG
-       if (DP->flags & FD_DEBUG){
-               DPRINT("calling disk change from seek\n");
-       }
-#endif
-
-       if (!TESTF(FD_DISK_NEWCHANGE) &&
-           disk_change(current_drive) &&
-           (raw_cmd->flags & FD_RAW_NEED_DISK)){
-               /* the media changed flag should be cleared after the seek.
-                * If it isn't, this means that there is really no disk in
-                * the drive.
-                */
-               SETF(FD_DISK_CHANGED);
-               cont->done(0);
-               cont->redo();
-               return;
-       }
-       if (DRS->track <= NEED_1_RECAL){
-               recalibrate_floppy();
-               return;
-       } else if (TESTF(FD_DISK_NEWCHANGE) &&
-                  (raw_cmd->flags & FD_RAW_NEED_DISK) &&
-                  (DRS->track <= NO_TRACK || DRS->track == raw_cmd->track)) {
-               /* we seek to clear the media-changed condition. Does anybody
-                * know a more elegant way, which works on all drives? */
-               if (raw_cmd->track)
-                       track = raw_cmd->track - 1;
-               else {
-                       if (DP->flags & FD_SILENT_DCL_CLEAR){
-                               blind_seek = 1;
-                               raw_cmd->flags |= FD_RAW_NEED_SEEK;
-                       }
-                       track = 1;
-               }
-       } else {
-               check_wp();
-               if (raw_cmd->track != DRS->track &&
-                   (raw_cmd->flags & FD_RAW_NEED_SEEK))
-                       track = raw_cmd->track;
-               else {
-                       setup_rw_floppy();
-                       return;
-               }
-       }
-
-       do_floppy = seek_interrupt;
-       output_byte(FD_SEEK);
-       output_byte(UNIT(current_drive));
-       LAST_OUT(track);
-#ifdef DEBUGT
-       debugt("seek command:");
-#endif
-}
-
-static void recal_interrupt(void)
-{
-#ifdef DEBUGT
-       debugt("recal interrupt:");
-#endif
-       if (inr !=2)
-               FDCS->reset = 1;
-       else if (ST0 & ST0_ECE) {
-               switch(DRS->track){
-                       case NEED_1_RECAL:
-#ifdef DEBUGT
-                               debugt("recal interrupt need 1 recal:");
-#endif
-                               /* after a second recalibrate, we still haven't
-                                * reached track 0. Probably no drive. Raise an
-                                * error, as failing immediately might upset
-                                * computers possessed by the Devil :-) */
-                               cont->error();
-                               cont->redo();
-                               return;
-                       case NEED_2_RECAL:
-#ifdef DEBUGT
-                               debugt("recal interrupt need 2 recal:");
-#endif
-                               /* If we already did a recalibrate,
-                                * and we are not at track 0, this
-                                * means we have moved. (The only way
-                                * not to move at recalibration is to
-                                * be already at track 0.) Clear the
-                                * new change flag */
-#ifdef DCL_DEBUG
-                               if (DP->flags & FD_DEBUG){
-                                       DPRINT("clearing NEWCHANGE flag because of second recalibrate\n");
-                               }
-#endif
-
-                               CLEARF(FD_DISK_NEWCHANGE);
-                               DRS->select_date = jiffies;
-                               /* fall through */
-                       default:
-#ifdef DEBUGT
-                               debugt("recal interrupt default:");
-#endif
-                               /* Recalibrate moves the head by at
-                                * most 80 steps. If after one
-                                * recalibrate we don't have reached
-                                * track 0, this might mean that we
-                                * started beyond track 80.  Try
-                                * again.  */
-                               DRS->track = NEED_1_RECAL;
-                               break;
-               }
-       } else
-               DRS->track = ST1;
-       floppy_ready();
-}
-
-static void print_result(char *message, int inr)
-{
-       int i;
-
-       DPRINT("%s ", message);
-       if (inr >= 0)
-               for (i=0; i<inr; i++)
-                       printk("repl[%d]=%x ", i, reply_buffer[i]);
-       printk("\n");
-}
-
-/* interrupt handler. Note that this can be called externally on the Sparc */
-irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
-       void (*handler)(void) = do_floppy;
-       int do_print;
-       unsigned long f;
-
-       lasthandler = handler;
-       interruptjiffies = jiffies;
-
-       f=claim_dma_lock();
-       fd_disable_dma();
-       release_dma_lock(f);
-
-       floppy_enable_hlt();
-       do_floppy = NULL;
-       if (fdc >= N_FDC || FDCS->address == -1){
-               /* we don't even know which FDC is the culprit */
-               printk("DOR0=%x\n", fdc_state[0].dor);
-               printk("floppy interrupt on bizarre fdc %d\n",fdc);
-               printk("handler=%p\n", handler);
-               is_alive("bizarre fdc");
-               return IRQ_NONE;
-       }
-
-       FDCS->reset = 0;
-       /* We have to clear the reset flag here, because apparently on boxes
-        * with level triggered interrupts (PS/2, Sparc, ...), it is needed to
-        * emit SENSEI's to clear the interrupt line. And FDCS->reset blocks the
-        * emission of the SENSEI's.
-        * It is OK to emit floppy commands because we are in an interrupt
-        * handler here, and thus we have to fear no interference of other
-        * activity.
-        */
-
-       do_print = !handler && print_unex && !initialising;
-
-       inr = result();
-       if (inr && do_print)
-               print_result("unexpected interrupt", inr);
-       if (inr == 0){
-               do {
-                       output_byte(FD_SENSEI);
-                       inr = result();
-                       if ((ST0 & ST0_INTR) == 0xC0) {
-                               int drive = ST0 & ST0_DS;
-
-                               /* Attention Interrupt. */
-                               if (ST0 & ST0_NR) {
-#ifdef PC9800_DEBUG_FLOPPY
-                                       if (do_print)
-                                               printk(KERN_DEBUG
-                                                       "floppy debug: floppy ejected (drive %d)\n",
-                                                       drive);
-#endif
-                                       USETF(FD_DISK_CHANGED);
-                                       USETF(FD_VERIFY);
-                               } else {
-#ifdef PC9800_DEBUG_FLOPPY
-                                       if (do_print)
-                                               printk(KERN_DEBUG
-                                                       "floppy debug: floppy inserted (drive %d)\n",
-                                                       drive);
-#endif
-                               }
-                       } /* Attention Interrupt */
-#ifdef PC9800_DEBUG_FLOPPY
-                       else {
-                               printk(KERN_DEBUG
-                                       "floppy debug : unknown interrupt\n");
-                       }
-#endif
-               } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2);
-       }
-       if (handler) {
-               schedule_bh(handler);
-       } else {
-#if 0
-               FDCS->reset = 1;
-#endif
-       }
-       is_alive("normal interrupt end");
-
-       /* FIXME! Was it really for us? */
-       return IRQ_HANDLED;
-}
-
-static void recalibrate_floppy(void)
-{
-#ifdef DEBUGT
-       debugt("recalibrate floppy:");
-#endif
-       do_floppy = recal_interrupt;
-       output_byte(FD_RECALIBRATE);
-       LAST_OUT(UNIT(current_drive));
-}
-
-/*
- * Must do 4 FD_SENSEIs after reset because of ``drive polling''.
- */
-static void reset_interrupt(void)
-{
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("floppy debug: reset interrupt\n");
-#endif
-#ifdef DEBUGT
-       debugt("reset interrupt:");
-#endif
-       result();               /* get the status ready for set_fdc */
-       if (FDCS->reset) {
-               printk("reset set in interrupt, calling %p\n", cont->error);
-               cont->error(); /* a reset just after a reset. BAD! */
-       }
-       cont->redo();
-}
-
-/*
- * reset is done by pulling bit 2 of DOR low for a while (old FDCs),
- * or by setting the self clearing bit 7 of STATUS (newer FDCs)
- */
-static void reset_fdc(void)
-{
-       unsigned long flags;
-
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("floppy debug: reset_fdc\n");
-#endif
-
-       do_floppy = reset_interrupt;
-       FDCS->reset = 0;
-       reset_fdc_info(0);
-
-       /* Pseudo-DMA may intercept 'reset finished' interrupt.  */
-       /* Irrelevant for systems with true DMA (i386).          */
-
-       flags=claim_dma_lock();
-       fd_disable_dma();
-       release_dma_lock(flags);
-
-       fd_outb(FDCS->dor | 0x80, FD_MODE);
-       udelay(FD_RESET_DELAY);
-       fd_outb(FDCS->dor, FD_MODE);
-       udelay(FD_AFTER_RESET_DELAY);
-}
-
-static void show_floppy(void)
-{
-       int i;
-
-       printk("\n");
-       printk("floppy driver state\n");
-       printk("-------------------\n");
-       printk("now=%lu last interrupt=%lu diff=%lu last called handler=%p\n",
-              jiffies, interruptjiffies, jiffies-interruptjiffies, lasthandler);
-
-
-#ifdef FLOPPY_SANITY_CHECK
-       printk("timeout_message=%s\n", timeout_message);
-       printk("last output bytes:\n");
-       for (i=0; i < OLOGSIZE; i++)
-               printk("%2x %2x %lu\n",
-                      output_log[(i+output_log_pos) % OLOGSIZE].data,
-                      output_log[(i+output_log_pos) % OLOGSIZE].status,
-                      output_log[(i+output_log_pos) % OLOGSIZE].jiffies);
-       printk("last result at %lu\n", resultjiffies);
-       printk("last redo_fd_request at %lu\n", lastredo);
-       for (i=0; i<resultsize; i++){
-               printk("%2x ", reply_buffer[i]);
-       }
-       printk("\n");
-#endif
-
-       printk("status=%x\n", fd_inb(FD98_STATUS));
-       printk("fdc_busy=%lu\n", fdc_busy);
-       if (do_floppy)
-               printk("do_floppy=%p\n", do_floppy);
-       if (floppy_work.pending)
-               printk("floppy_work.func=%p\n", floppy_work.func);
-       if (timer_pending(&fd_timer))
-               printk("fd_timer.function=%p\n", fd_timer.function);
-       if (timer_pending(&fd_timeout)){
-               printk("timer_function=%p\n",fd_timeout.function);
-               printk("expires=%lu\n",fd_timeout.expires-jiffies);
-               printk("now=%lu\n",jiffies);
-       }
-       printk("cont=%p\n", cont);
-       printk("current_req=%p\n", current_req);
-       printk("command_status=%d\n", command_status);
-       printk("\n");
-}
-
-static void floppy_shutdown(unsigned long data)
-{
-       unsigned long flags;
-       
-       if (!initialising)
-               show_floppy();
-       cancel_activity();
-
-       floppy_enable_hlt();
-       
-       flags=claim_dma_lock();
-       fd_disable_dma();
-       release_dma_lock(flags);
-       
-       /* avoid dma going to a random drive after shutdown */
-
-       if (!initialising)
-               DPRINT("floppy timeout called\n");
-       FDCS->reset = 1;
-       if (cont){
-               cont->done(0);
-               cont->redo(); /* this will recall reset when needed */
-       } else {
-               printk("no cont in shutdown!\n");
-               process_fd_request();
-       }
-       is_alive("floppy shutdown");
-}
-/*typedef void (*timeout_fn)(unsigned long);*/
-
-static void access_mode_change_pc9800(void)
-{
-       static int access_mode, mode_change_now, old_mode, new_set = 1;
-#ifdef PC9800_DEBUG_FLOPPY2
-       printk("enter access_mode_change\n");
-#endif
-       access_mode = mode_change_now = 0;
-       if (DP->cmos==4) {
-               switch ((int)(_floppy - &floppy_type[0])) {
-               case 1:
-               case 2:
-                       new_set = 1;
-                       access_mode = 2;
-                       break;
-
-               case 4:
-               case 6:
-                       new_set = 1;
-                       access_mode = 3;
-                       break;
-
-               case 7:
-               case 10:
-                       new_set = 1;
-                       access_mode = 1;
-                       break;
-
-               default:
-                       access_mode = 1;
-                       break;
-               }
-
-               old_mode = fd_inb(FD_MODE_CHANGE) & 3;
-
-               switch (access_mode) {
-               case 1:
-                       if ((old_mode & 2) == 0) {
-                               fd_outb(old_mode | 2, FD_MODE_CHANGE);
-                               mode_change_now = 1;
-                       } else {
-                               fd_outb(current_drive << 5, FD_EMODE_CHANGE);
-                               if (fd_inb(FD_EMODE_CHANGE) == 0xff)
-                                       return;
-                       }
-
-                       fd_outb((current_drive << 5) | 0x11, FD_EMODE_CHANGE);
-                       mode_change_now = 1;
-                       break;
-
-               case 2:
-                       if ((old_mode & 2) == 0) {
-                               fd_outb(old_mode | 2, FD_MODE_CHANGE);
-                               mode_change_now = 1;
-                       } else {
-                               fd_outb(current_drive << 5, FD_EMODE_CHANGE);
-                               if ((fd_inb(FD_EMODE_CHANGE) & 1) == 0)
-                                       return;
-                               fd_outb((current_drive << 5) | 0x10, FD_EMODE_CHANGE);
-                               mode_change_now = 1;
-                       }
-
-                       break;
-
-               case 3:
-                       if ((old_mode & 2) == 0)
-                               return;
-                       fd_outb(current_drive << 5, FD_EMODE_CHANGE);
-                       if (fd_inb(FD_EMODE_CHANGE) & 1)
-                               fd_outb((current_drive << 5) | 0x10, FD_EMODE_CHANGE);
-                       fd_outb(old_mode & 0xfd, FD_MODE_CHANGE);
-                       mode_change_now = 1;
-                       break;
-
-               default:
-                       break;
-               }
-       } else {
-               switch ((int)(_floppy - &floppy_type[0])) {
-               case 1:
-               case 2:
-                       new_set = 1;
-                       access_mode = 2;
-                       break;
-
-               case 4:
-               case 6:
-                       new_set = 1;
-                       access_mode = 3;
-                       break;
-
-               default:
-                       switch (DP->cmos) {
-                       case 2:
-                               access_mode = 2;
-                               break;
-
-                       case 3:
-                               access_mode = 3;
-                               break;
-
-                       default:
-                               break;
-                       }
-
-                       break;
-               }
-
-               old_mode = fd_inb(FD_MODE_CHANGE) & 3;
-
-               switch (access_mode) {
-               case 2:
-                       if ((old_mode & 2) == 0) {
-                               fd_outb(old_mode | 2, FD_MODE_CHANGE);
-                               mode_change_now = 1;
-                       }
-
-                       break;
-
-               case 3:
-                       if (old_mode & 2) {
-                               fd_outb(old_mode & 0xfd, FD_MODE_CHANGE);
-                               mode_change_now = 1;
-                       }
-
-                       break;
-
-               default:
-                       break;
-               }
-       }
-#ifdef PC9800_DEBUG_FLOPPY2
-       printk("floppy debug: DP->cmos=%d\n", DP->cmos);
-       printk("floppy debug: mode_change_now=%d\n", mode_change_now);
-       printk("floppy debug: access_mode=%d\n", access_mode);
-       printk("floppy debug: old_mode=%d\n", old_mode);
-       printk("floppy debug: _floppy - &floppy_type[0]=%d\n", (int)(_floppy - &floppy_type[0]));
-#endif /* PC9800_DEBUG_FLOPPY2 */
-       if(mode_change_now)
-               reset_fdc();
-}
-
-/* start motor, check media-changed condition and write protection */
-static int start_motor(void (*function)(void) )
-{
-       access_mode_change_pc9800();
-       set_mode(~0, 0x8);
-
-       /* wait_for_completion also schedules reset if needed. */
-       return(fd_wait_for_completion(DRS->select_date+DP->select_delay,
-                                  (timeout_fn) function));
-}
-
-static void floppy_ready(void)
-{
-       CHECK_RESET;
-       if (start_motor(floppy_ready)) return;
-
-#ifdef DCL_DEBUG
-       if (DP->flags & FD_DEBUG){
-               DPRINT("calling disk change from floppy_ready\n");
-       }
-#endif
-       if (!(raw_cmd->flags & FD_RAW_NO_MOTOR) &&
-          disk_change(current_drive) &&
-          !DP->select_delay)
-               twaddle(); /* this clears the dcl on certain drive/controller
-                           * combinations */
-
-#ifdef fd_chose_dma_mode
-       if ((raw_cmd->flags & FD_RAW_READ) || 
-           (raw_cmd->flags & FD_RAW_WRITE))
-       {
-               unsigned long flags = claim_dma_lock();
-               fd_chose_dma_mode(raw_cmd->kernel_data,
-                                 raw_cmd->length);
-               release_dma_lock(flags);
-       }
-#endif
-
-#if 0
-       access_mode_change_pc9800();
-#endif
-       if (raw_cmd->flags & (FD_RAW_NEED_SEEK | FD_RAW_NEED_DISK)){
-               fdc_specify(); /* must be done here because of hut, hlt ... */
-               seek_floppy();
-       } else {
-               if ((raw_cmd->flags & FD_RAW_READ) || 
-                   (raw_cmd->flags & FD_RAW_WRITE))
-                       fdc_specify();
-               setup_rw_floppy();
-       }
-}
-
-static void floppy_start(void)
-{
-       reschedule_timeout(current_reqD, "floppy start", 0);
-
-       scandrives();
-#ifdef DCL_DEBUG
-       if (DP->flags & FD_DEBUG){
-               DPRINT("setting NEWCHANGE in floppy_start\n");
-       }
-#endif
-       SETF(FD_DISK_NEWCHANGE);
-       floppy_ready();
-}
-
-/*
- * ========================================================================
- * here ends the bottom half. Exported routines are:
- * floppy_start, floppy_off, floppy_ready, lock_fdc, unlock_fdc, set_fdc,
- * start_motor, reset_fdc, reset_fdc_info, interpret_errors.
- * Initialization also uses output_byte, result, set_dor, floppy_interrupt
- * and set_dor.
- * ========================================================================
- */
-/*
- * General purpose continuations.
- * ==============================
- */
-
-static void do_wakeup(void)
-{
-       reschedule_timeout(MAXTIMEOUT, "do wakeup", 0);
-       cont = 0;
-       command_status += 2;
-       wake_up(&command_done);
-}
-
-static struct cont_t wakeup_cont={
-       empty,
-       do_wakeup,
-       empty,
-       (done_f)empty
-};
-
-
-static struct cont_t intr_cont={
-       empty,
-       process_fd_request,
-       empty,
-       (done_f) empty
-};
-
-static int wait_til_done(void (*handler)(void), int interruptible)
-{
-       int ret;
-
-       schedule_bh((void *)(void *)handler);
-
-       if (command_status < 2 && NO_SIGNAL) {
-               DECLARE_WAITQUEUE(wait, current);
-
-               add_wait_queue(&command_done, &wait);
-               for (;;) {
-                       set_current_state(interruptible?
-                                         TASK_INTERRUPTIBLE:
-                                         TASK_UNINTERRUPTIBLE);
-
-                       if (command_status >= 2 || !NO_SIGNAL)
-                               break;
-
-                       is_alive("wait_til_done");
-
-                       schedule();
-               }
-
-               set_current_state(TASK_RUNNING);
-               remove_wait_queue(&command_done, &wait);
-       }
-
-       if (command_status < 2){
-               cancel_activity();
-               cont = &intr_cont;
-               reset_fdc();
-               return -EINTR;
-       }
-
-#ifdef PC9800_DEBUG_FLOPPY
-       if (command_status != FD_COMMAND_OKAY)
-               printk("floppy check: wait_til_done out:%d\n", command_status);
-#endif
-       if (FDCS->reset)
-               command_status = FD_COMMAND_ERROR;
-       if (command_status == FD_COMMAND_OKAY)
-               ret=0;
-       else
-               ret=-EIO;
-       command_status = FD_COMMAND_NONE;
-       return ret;
-}
-
-static void generic_done(int result)
-{
-       command_status = result;
-       cont = &wakeup_cont;
-}
-
-static void generic_success(void)
-{
-       cont->done(1);
-}
-
-static void generic_failure(void)
-{
-       cont->done(0);
-}
-
-static void success_and_wakeup(void)
-{
-       generic_success();
-       cont->redo();
-}
-
-
-/*
- * formatting and rw support.
- * ==========================
- */
-
-static int next_valid_format(void)
-{
-       int probed_format;
-
-       probed_format = DRS->probed_format;
-       while(1){
-               if (probed_format >= 8 ||
-                    !DP->autodetect[probed_format]){
-                       DRS->probed_format = 0;
-                       return 1;
-               }
-               if (floppy_type[DP->autodetect[probed_format]].sect){
-                       DRS->probed_format = probed_format;
-                       return 0;
-               }
-               probed_format++;
-       }
-}
-
-static void bad_flp_intr(void)
-{
-       if (probing){
-               DRS->probed_format++;
-               if (!next_valid_format())
-                       return;
-       }
-       (*errors)++;
-       INFBOUND(DRWE->badness, *errors);
-       if (*errors > DP->max_errors.abort)
-               cont->done(0);
-       if (*errors > DP->max_errors.reset)
-               FDCS->reset = 1;
-       else if (*errors > DP->max_errors.recal)
-               DRS->track = NEED_2_RECAL;
-}
-
-static void set_floppy(int drive)
-{
-       int type = ITYPE(UDRS->fd_device);
-       if (type) {
-               auto_detect_mode = 0;
-               _floppy = floppy_type + type;
-       } else if (auto_detect_mode == 0) {
-               auto_detect_mode = 1;
-               retry_auto_detect = 0;
-               _floppy = current_type[drive];
-       }
-#ifdef PC9800_DEBUG_FLOPPY2
-       printk("set_floppy: set floppy type=%d\n", (int)(_floppy - floppy_type));
-#endif
-}
-
-/*
- * formatting support.
- * ===================
- */
-static void format_interrupt(void)
-{
-       switch (interpret_errors()){
-               case 1:
-                       cont->error();
-               case 2:
-                       break;
-               case 0:
-                       cont->done(1);
-       }
-       cont->redo();
-}
-
-#define CODE2SIZE (ssize = ((1 << SIZECODE) + 3) >> 2)
-#define FM_MODE(x,y) ((y) & ~(((x)->rate & 0x80) >>1))
-#define CT(x) ((x) | 0xc0)
-static void setup_format_params(int track)
-{
-       struct fparm {
-               unsigned char track,head,sect,size;
-       } *here = (struct fparm *)floppy_track_buffer;
-       int il,n;
-       int count,head_shift,track_shift;
-
-       raw_cmd = &default_raw_cmd;
-       raw_cmd->track = track;
-
-       raw_cmd->flags = FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN |
-               FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK;
-       raw_cmd->rate = _floppy->rate & 0x43;
-       raw_cmd->cmd_count = NR_F;
-       COMMAND = FM_MODE(_floppy,FD_FORMAT);
-       DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy,format_req.head);
-       F_SIZECODE = FD_SIZECODE(_floppy);
-       F_SECT_PER_TRACK = _floppy->sect << 2 >> F_SIZECODE;
-       F_GAP = _floppy->fmt_gap;
-       F_FILL = FD_FILL_BYTE;
-
-       raw_cmd->kernel_data = floppy_track_buffer;
-       raw_cmd->length = 4 * F_SECT_PER_TRACK;
-
-       /* allow for about 30ms for data transport per track */
-       head_shift  = (F_SECT_PER_TRACK + 5) / 6;
-
-       /* a ``cylinder'' is two tracks plus a little stepping time */
-       track_shift = 2 * head_shift + 3;
-
-       /* position of logical sector 1 on this track */
-       n = (track_shift * format_req.track + head_shift * format_req.head)
-               % F_SECT_PER_TRACK;
-
-       /* determine interleave */
-       il = 1;
-       if (_floppy->fmt_gap < 0x22)
-               il++;
-
-       /* initialize field */
-       for (count = 0; count < F_SECT_PER_TRACK; ++count) {
-               here[count].track = format_req.track;
-               here[count].head = format_req.head;
-               here[count].sect = 0;
-               here[count].size = F_SIZECODE;
-       }
-       /* place logical sectors */
-       for (count = 1; count <= F_SECT_PER_TRACK; ++count) {
-               here[n].sect = count;
-               n = (n+il) % F_SECT_PER_TRACK;
-               if (here[n].sect) { /* sector busy, find next free sector */
-                       ++n;
-                       if (n>= F_SECT_PER_TRACK) {
-                               n-=F_SECT_PER_TRACK;
-                               while (here[n].sect) ++n;
-                       }
-               }
-       }
-}
-
-static void redo_format(void)
-{
-       buffer_track = -1;
-       setup_format_params(format_req.track << STRETCH(_floppy));
-       floppy_start();
-#ifdef DEBUGT
-       debugt("queue format request");
-#endif
-}
-
-static struct cont_t format_cont={
-       format_interrupt,
-       redo_format,
-       bad_flp_intr,
-       generic_done };
-
-static int do_format(int drive, struct format_descr *tmp_format_req)
-{
-       int ret;
-
-       LOCK_FDC(drive,1);
-       set_floppy(drive);
-       if (!_floppy ||
-           _floppy->track > DP->tracks ||
-           tmp_format_req->track >= _floppy->track ||
-           tmp_format_req->head >= _floppy->head ||
-           (_floppy->sect << 2) % (1 <<  FD_SIZECODE(_floppy)) ||
-           !_floppy->fmt_gap) {
-               process_fd_request();
-               return -EINVAL;
-       }
-       format_req = *tmp_format_req;
-       format_errors = 0;
-       cont = &format_cont;
-       errors = &format_errors;
-       IWAIT(redo_format);
-       process_fd_request();
-       return ret;
-}
-
-/*
- * Buffer read/write and support
- * =============================
- */
-
-static void floppy_end_request(struct request *req, int uptodate)
-{
-       if (end_that_request_first(req, uptodate, current_count_sectors))
-               return;
-       add_disk_randomness(req->rq_disk);
-       floppy_off((long)req->rq_disk->private_data);
-       blkdev_dequeue_request(req);
-       end_that_request_last(req);
-
-       /* We're done with the request */
-       current_req = NULL;
-}
-
-
-/* new request_done. Can handle physical sectors which are smaller than a
- * logical buffer */
-static void request_done(int uptodate)
-{
-       struct request_queue *q = floppy_queue;
-       struct request *req = current_req;
-       unsigned long flags;
-       int block;
-
-       probing = 0;
-       reschedule_timeout(MAXTIMEOUT, "request done %d", uptodate);
-
-       if (!req) {
-               printk("floppy.c: no request in request_done\n");
-               return;
-       }
-
-       if (uptodate){
-               /* maintain values for invalidation on geometry
-                * change */
-               block = current_count_sectors + req->sector;
-               INFBOUND(DRS->maxblock, block);
-               if (block > _floppy->sect)
-                       DRS->maxtrack = 1;
-
-               /* unlock chained buffers */
-               spin_lock_irqsave(q->queue_lock, flags);
-               floppy_end_request(req, 1);
-               spin_unlock_irqrestore(q->queue_lock, flags);
-       } else {
-               if (rq_data_dir(req) == WRITE) {
-                       /* record write error information */
-                       DRWE->write_errors++;
-                       if (DRWE->write_errors == 1) {
-                               DRWE->first_error_sector = req->sector;
-                               DRWE->first_error_generation = DRS->generation;
-                       }
-                       DRWE->last_error_sector = req->sector;
-                       DRWE->last_error_generation = DRS->generation;
-               }
-               spin_lock_irqsave(q->queue_lock, flags);
-               floppy_end_request(req, 0);
-               spin_unlock_irqrestore(q->queue_lock, flags);
-       }
-}
-
-/* Interrupt handler evaluating the result of the r/w operation */
-static void rw_interrupt(void)
-{
-       int nr_sectors, ssize, eoc, heads;
-
-       if (R_HEAD >= 2) {
-           /* some Toshiba floppy controllers occasionnally seem to
-            * return bogus interrupts after read/write operations, which
-            * can be recognized by a bad head number (>= 2) */
-            return;
-       }  
-
-       if (!DRS->first_read_date)
-               DRS->first_read_date = jiffies;
-
-       nr_sectors = 0;
-       CODE2SIZE;
-
-       if (ST1 & ST1_EOC)
-               eoc = 1;
-       else
-               eoc = 0;
-
-       if (COMMAND & 0x80)
-               heads = 2;
-       else
-               heads = 1;
-
-       nr_sectors = (((R_TRACK-TRACK) * heads +
-                                  R_HEAD-HEAD) * SECT_PER_TRACK +
-                                  R_SECTOR-SECTOR + eoc) << SIZECODE >> 2;
-
-#ifdef FLOPPY_SANITY_CHECK
-       if (nr_sectors / ssize > 
-               (in_sector_offset + current_count_sectors + ssize - 1) / ssize) {
-               DPRINT("long rw: %x instead of %lx\n",
-                       nr_sectors, current_count_sectors);
-               printk("rs=%d s=%d\n", R_SECTOR, SECTOR);
-               printk("rh=%d h=%d\n", R_HEAD, HEAD);
-               printk("rt=%d t=%d\n", R_TRACK, TRACK);
-               printk("heads=%d eoc=%d\n", heads, eoc);
-               printk("spt=%d st=%d ss=%d\n", SECT_PER_TRACK,
-                      fsector_t, ssize);
-               printk("in_sector_offset=%d\n", in_sector_offset);
-       }
-#endif
-
-       nr_sectors -= in_sector_offset;
-       INFBOUND(nr_sectors,0);
-       SUPBOUND(current_count_sectors, nr_sectors);
-
-       switch (interpret_errors()){
-               case 2:
-                       cont->redo();
-                       return;
-               case 1:
-                       if (!current_count_sectors){
-                               cont->error();
-                               cont->redo();
-                               return;
-                       }
-                       break;
-               case 0:
-                       if (!current_count_sectors){
-                               cont->redo();
-                               return;
-                       }
-                       current_type[current_drive] = _floppy;
-                       floppy_sizes[TOMINOR(current_drive) ]= _floppy->size;
-                       break;
-       }
-
-       if (probing) {
-               if (DP->flags & FTD_MSG)
-                       DPRINT("Auto-detected floppy type %s in fd%d\n",
-                               _floppy->name,current_drive);
-               current_type[current_drive] = _floppy;
-               floppy_sizes[TOMINOR(current_drive)] = _floppy->size;
-               probing = 0;
-       }
-
-       if (CT(COMMAND) != FD_READ || 
-            raw_cmd->kernel_data == current_req->buffer){
-               /* transfer directly from buffer */
-               cont->done(1);
-       } else if (CT(COMMAND) == FD_READ){
-               buffer_track = raw_cmd->track;
-               buffer_drive = current_drive;
-               INFBOUND(buffer_max, nr_sectors + fsector_t);
-       }
-       cont->redo();
-}
-
-/* Compute maximal contiguous buffer size. */
-static int buffer_chain_size(void)
-{
-       struct bio *bio;
-       struct bio_vec *bv;
-       int size, i;
-       char *base;
-
-       base = bio_data(current_req->bio);
-       size = 0;
-
-       rq_for_each_bio(bio, current_req) {
-               bio_for_each_segment(bv, bio, i) {
-                       if (page_address(bv->bv_page) + bv->bv_offset != base + size)
-                               break;
-
-                       size += bv->bv_len;
-               }
-       }
-
-       return size >> 9;
-}
-
-/* Compute the maximal transfer size */
-static int transfer_size(int ssize, int max_sector, int max_size)
-{
-       SUPBOUND(max_sector, fsector_t + max_size);
-
-       /* alignment */
-       max_sector -= (max_sector % _floppy->sect) % ssize;
-
-       /* transfer size, beginning not aligned */
-       current_count_sectors = max_sector - fsector_t ;
-
-       return max_sector;
-}
-
-/*
- * Move data from/to the track buffer to/from the buffer cache.
- */
-static void copy_buffer(int ssize, int max_sector, int max_sector_2)
-{
-       int remaining; /* number of transferred 512-byte sectors */
-       struct bio_vec *bv;
-       struct bio *bio;
-       char *buffer, *dma_buffer;
-       int size, i;
-
-       max_sector = transfer_size(ssize,
-                                  minimum(max_sector, max_sector_2),
-                                  current_req->nr_sectors);
-
-       if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
-           buffer_max > fsector_t + current_req->nr_sectors)
-               current_count_sectors = minimum(buffer_max - fsector_t,
-                                               current_req->nr_sectors);
-
-       remaining = current_count_sectors << 9;
-#ifdef FLOPPY_SANITY_CHECK
-       if ((remaining >> 9) > current_req->nr_sectors  &&
-           CT(COMMAND) == FD_WRITE){
-               DPRINT("in copy buffer\n");
-               printk("current_count_sectors=%ld\n", current_count_sectors);
-               printk("remaining=%d\n", remaining >> 9);
-               printk("current_req->nr_sectors=%ld\n",current_req->nr_sectors);
-               printk("current_req->current_nr_sectors=%u\n",
-                      current_req->current_nr_sectors);
-               printk("max_sector=%d\n", max_sector);
-               printk("ssize=%d\n", ssize);
-       }
-#endif
-
-       buffer_max = maximum(max_sector, buffer_max);
-
-       dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
-
-       size = current_req->current_nr_sectors << 9;
-
-       rq_for_each_bio(bio, current_req) {
-               bio_for_each_segment(bv, bio, i) {
-                       if (!remaining)
-                               break;
-
-                       size = bv->bv_len;
-                       SUPBOUND(size, remaining);
-
-                       buffer = page_address(bv->bv_page) + bv->bv_offset;
-#ifdef FLOPPY_SANITY_CHECK
-               if (dma_buffer + size >
-                   floppy_track_buffer + (max_buffer_sectors << 10) ||
-                   dma_buffer < floppy_track_buffer){
-                       DPRINT("buffer overrun in copy buffer %d\n",
-                               (int) ((floppy_track_buffer - dma_buffer) >>9));
-                       printk("fsector_t=%d buffer_min=%d\n",
-                              fsector_t, buffer_min);
-                       printk("current_count_sectors=%ld\n",
-                              current_count_sectors);
-                       if (CT(COMMAND) == FD_READ)
-                               printk("read\n");
-                       if (CT(COMMAND) == FD_WRITE)
-                               printk("write\n");
-                       break;
-               }
-               if (((unsigned long)buffer) % 512)
-                       DPRINT("%p buffer not aligned\n", buffer);
-#endif
-                       if (CT(COMMAND) == FD_READ)
-                               memcpy(buffer, dma_buffer, size);
-                       else
-                               memcpy(dma_buffer, buffer, size);
-
-                       remaining -= size;
-                       dma_buffer += size;
-               }
-       }
-#ifdef FLOPPY_SANITY_CHECK
-       if (remaining){
-               if (remaining > 0)
-                       max_sector -= remaining >> 9;
-               DPRINT("weirdness: remaining %d\n", remaining>>9);
-       }
-#endif
-}
-
-#if 0
-static inline int check_dma_crossing(char *start, 
-                                    unsigned long length, char *message)
-{
-       if (CROSS_64KB(start, length)) {
-               printk("DMA xfer crosses 64KB boundary in %s %p-%p\n", 
-                      message, start, start+length);
-               return 1;
-       } else
-               return 0;
-}
-#endif
-
-/* work around a bug in pseudo DMA
- * (on some FDCs) pseudo DMA does not stop when the CPU stops
- * sending data.  Hence we need a different way to signal the
- * transfer length:  We use SECT_PER_TRACK.  Unfortunately, this
- * does not work with MT, hence we can only transfer one head at
- * a time
- */
-static void virtualdmabug_workaround(void)
-{
-       int hard_sectors, end_sector;
-
-       if(CT(COMMAND) == FD_WRITE) {
-               COMMAND &= ~0x80; /* switch off multiple track mode */
-
-               hard_sectors = raw_cmd->length >> (7 + SIZECODE);
-               end_sector = SECTOR + hard_sectors - 1;
-#ifdef FLOPPY_SANITY_CHECK
-               if(end_sector > SECT_PER_TRACK) {
-                       printk("too many sectors %d > %d\n",
-                              end_sector, SECT_PER_TRACK);
-                       return;
-               }
-#endif
-               SECT_PER_TRACK = end_sector; /* make sure SECT_PER_TRACK points
-                                             * to end of transfer */
-       }
-}
-
-/*
- * Formulate a read/write request.
- * this routine decides where to load the data (directly to buffer, or to
- * tmp floppy area), how much data to load (the size of the buffer, the whole
- * track, or a single sector)
- * All floppy_track_buffer handling goes in here. If we ever add track buffer
- * allocation on the fly, it should be done here. No other part should need
- * modification.
- */
-
-static int make_raw_rw_request(void)
-{
-       int aligned_sector_t;
-       int max_sector, max_size, tracksize, ssize;
-
-       if(max_buffer_sectors == 0) {
-               printk("VFS: Block I/O scheduled on unopened device\n");
-               return 0;
-       }
-
-       set_fdc((long)current_req->rq_disk->private_data);
-
-       raw_cmd = &default_raw_cmd;
-       raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_DISK | FD_RAW_NEED_DISK |
-               FD_RAW_NEED_SEEK;
-       raw_cmd->cmd_count = NR_RW;
-       if (rq_data_dir(current_req) == READ) {
-               raw_cmd->flags |= FD_RAW_READ;
-               COMMAND = FM_MODE(_floppy,FD_READ);
-       } else if (rq_data_dir(current_req) == WRITE){
-               raw_cmd->flags |= FD_RAW_WRITE;
-               COMMAND = FM_MODE(_floppy,FD_WRITE);
-       } else {
-               DPRINT("make_raw_rw_request: unknown command\n");
-               return 0;
-       }
-
-       max_sector = _floppy->sect * _floppy->head;
-
-       TRACK = (int)current_req->sector / max_sector;
-       fsector_t = (int)current_req->sector % max_sector;
-       if (_floppy->track && TRACK >= _floppy->track) {
-               if (current_req->current_nr_sectors & 1) {
-                       current_count_sectors = 1;
-                       return 1;
-               } else
-                       return 0;
-       }
-       HEAD = fsector_t / _floppy->sect;
-
-       if (((_floppy->stretch & FD_SWAPSIDES) || TESTF(FD_NEED_TWADDLE)) &&
-           fsector_t < _floppy->sect)
-               max_sector = _floppy->sect;
-
-       /* 2M disks have phantom sectors on the first track */
-       if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)){
-               max_sector = 2 * _floppy->sect / 3;
-               if (fsector_t >= max_sector){
-                       current_count_sectors = minimum(_floppy->sect - fsector_t,
-                                                       current_req->nr_sectors);
-                       return 1;
-               }
-               SIZECODE = 2;
-       } else
-               SIZECODE = FD_SIZECODE(_floppy);
-       raw_cmd->rate = _floppy->rate & 0x43;
-       if ((_floppy->rate & FD_2M) &&
-           (TRACK || HEAD) &&
-           raw_cmd->rate == 2)
-               raw_cmd->rate = 1;
-
-       if (SIZECODE)
-               SIZECODE2 = 0xff;
-       else
-               SIZECODE2 = 0x80;
-       raw_cmd->track = TRACK << STRETCH(_floppy);
-       DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy,HEAD);
-       GAP = _floppy->gap;
-       CODE2SIZE;
-       SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE;
-       SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + 1;
-
-       /* tracksize describes the size which can be filled up with sectors
-        * of size ssize.
-        */
-       tracksize = _floppy->sect - _floppy->sect % ssize;
-       if (tracksize < _floppy->sect){
-               SECT_PER_TRACK ++;
-               if (tracksize <= fsector_t % _floppy->sect)
-                       SECTOR--;
-
-               /* if we are beyond tracksize, fill up using smaller sectors */
-               while (tracksize <= fsector_t % _floppy->sect){
-                       while(tracksize + ssize > _floppy->sect){
-                               SIZECODE--;
-                               ssize >>= 1;
-                       }
-                       SECTOR++; SECT_PER_TRACK ++;
-                       tracksize += ssize;
-               }
-               max_sector = HEAD * _floppy->sect + tracksize;
-       } else if (!TRACK && !HEAD && !(_floppy->rate & FD_2M) && probing) {
-               max_sector = _floppy->sect;
-       } else if (!HEAD && CT(COMMAND) == FD_WRITE) {
-               /* for virtual DMA bug workaround */
-               max_sector = _floppy->sect;
-       }
-
-       in_sector_offset = (fsector_t % _floppy->sect) % ssize;
-       aligned_sector_t = fsector_t - in_sector_offset;
-       max_size = current_req->nr_sectors;
-       if ((raw_cmd->track == buffer_track) && 
-           (current_drive == buffer_drive) &&
-           (fsector_t >= buffer_min) && (fsector_t < buffer_max)) {
-               /* data already in track buffer */
-               if (CT(COMMAND) == FD_READ) {
-                       copy_buffer(1, max_sector, buffer_max);
-                       return 1;
-               }
-       } else if (in_sector_offset || current_req->nr_sectors < ssize){
-               if (CT(COMMAND) == FD_WRITE){
-                       if (fsector_t + current_req->nr_sectors > ssize &&
-                           fsector_t + current_req->nr_sectors < ssize + ssize)
-                               max_size = ssize + ssize;
-                       else
-                               max_size = ssize;
-               }
-               raw_cmd->flags &= ~FD_RAW_WRITE;
-               raw_cmd->flags |= FD_RAW_READ;
-               COMMAND = FM_MODE(_floppy,FD_READ);
-       } else if ((unsigned long)current_req->buffer < MAX_DMA_ADDRESS) {
-               unsigned long dma_limit;
-               int direct, indirect;
-
-               indirect= transfer_size(ssize,max_sector,max_buffer_sectors*2) -
-                       fsector_t;
-
-               /*
-                * Do NOT use minimum() here---MAX_DMA_ADDRESS is 64 bits wide
-                * on a 64 bit machine!
-                */
-               max_size = buffer_chain_size();
-               dma_limit = (MAX_DMA_ADDRESS - ((unsigned long) current_req->buffer)) >> 9;
-               if ((unsigned long) max_size > dma_limit) {
-                       max_size = dma_limit;
-               }
-               /* 64 kb boundaries */
-               if (CROSS_64KB(current_req->buffer, max_size << 9))
-                       max_size = (K_64 - 
-                                   ((unsigned long)current_req->buffer) % K_64)>>9;
-               direct = transfer_size(ssize,max_sector,max_size) - fsector_t;
-               /*
-                * We try to read tracks, but if we get too many errors, we
-                * go back to reading just one sector at a time.
-                *
-                * This means we should be able to read a sector even if there
-                * are other bad sectors on this track.
-                */
-               if (!direct ||
-                   (indirect * 2 > direct * 3 &&
-                    *errors < DP->max_errors.read_track &&
-                    /*!TESTF(FD_NEED_TWADDLE) &&*/
-                    ((!probing || (DP->read_track&(1<<DRS->probed_format)))))){
-                       max_size = current_req->nr_sectors;
-               } else {
-                       raw_cmd->kernel_data = current_req->buffer;
-                       raw_cmd->length = current_count_sectors << 9;
-                       if (raw_cmd->length == 0){
-                               DPRINT("zero dma transfer attempted from make_raw_request\n");
-                               DPRINT("indirect=%d direct=%d fsector_t=%d",
-                                       indirect, direct, fsector_t);
-                               return 0;
-                       }
-/*                     check_dma_crossing(raw_cmd->kernel_data, 
-                                          raw_cmd->length, 
-                                          "end of make_raw_request [1]");*/
-
-                       virtualdmabug_workaround();
-                       return 2;
-               }
-       }
-
-       if (CT(COMMAND) == FD_READ)
-               max_size = max_sector; /* unbounded */
-
-       /* claim buffer track if needed */
-       if (buffer_track != raw_cmd->track ||  /* bad track */
-           buffer_drive !=current_drive || /* bad drive */
-           fsector_t > buffer_max ||
-           fsector_t < buffer_min ||
-           ((CT(COMMAND) == FD_READ ||
-             (!in_sector_offset && current_req->nr_sectors >= ssize))&&
-            max_sector > 2 * max_buffer_sectors + buffer_min &&
-            max_size + fsector_t > 2 * max_buffer_sectors + buffer_min)
-           /* not enough space */){
-               buffer_track = -1;
-               buffer_drive = current_drive;
-               buffer_max = buffer_min = aligned_sector_t;
-       }
-       raw_cmd->kernel_data = floppy_track_buffer + 
-               ((aligned_sector_t-buffer_min)<<9);
-
-       if (CT(COMMAND) == FD_WRITE){
-               /* copy write buffer to track buffer.
-                * if we get here, we know that the write
-                * is either aligned or the data already in the buffer
-                * (buffer will be overwritten) */
-#ifdef FLOPPY_SANITY_CHECK
-               if (in_sector_offset && buffer_track == -1)
-                       DPRINT("internal error offset !=0 on write\n");
-#endif
-               buffer_track = raw_cmd->track;
-               buffer_drive = current_drive;
-               copy_buffer(ssize, max_sector, 2*max_buffer_sectors+buffer_min);
-       } else
-               transfer_size(ssize, max_sector,
-                             2*max_buffer_sectors+buffer_min-aligned_sector_t);
-
-       /* round up current_count_sectors to get dma xfer size */
-       raw_cmd->length = in_sector_offset+current_count_sectors;
-       raw_cmd->length = ((raw_cmd->length -1)|(ssize-1))+1;
-       raw_cmd->length <<= 9;
-#ifdef FLOPPY_SANITY_CHECK
-       /*check_dma_crossing(raw_cmd->kernel_data, raw_cmd->length, 
-         "end of make_raw_request");*/
-       if ((raw_cmd->length < current_count_sectors << 9) ||
-           (raw_cmd->kernel_data != current_req->buffer &&
-            CT(COMMAND) == FD_WRITE &&
-            (aligned_sector_t + (raw_cmd->length >> 9) > buffer_max ||
-             aligned_sector_t < buffer_min)) ||
-           raw_cmd->length % (128 << SIZECODE) ||
-           raw_cmd->length <= 0 || current_count_sectors <= 0){
-               DPRINT("fractionary current count b=%lx s=%lx\n",
-                       raw_cmd->length, current_count_sectors);
-               if (raw_cmd->kernel_data != current_req->buffer)
-                       printk("addr=%d, length=%ld\n",
-                              (int) ((raw_cmd->kernel_data - 
-                                      floppy_track_buffer) >> 9),
-                              current_count_sectors);
-               printk("st=%d ast=%d mse=%d msi=%d\n",
-                      fsector_t, aligned_sector_t, max_sector, max_size);
-               printk("ssize=%x SIZECODE=%d\n", ssize, SIZECODE);
-               printk("command=%x SECTOR=%d HEAD=%d, TRACK=%d\n",
-                      COMMAND, SECTOR, HEAD, TRACK);
-               printk("buffer drive=%d\n", buffer_drive);
-               printk("buffer track=%d\n", buffer_track);
-               printk("buffer_min=%d\n", buffer_min);
-               printk("buffer_max=%d\n", buffer_max);
-               return 0;
-       }
-
-       if (raw_cmd->kernel_data != current_req->buffer){
-               if (raw_cmd->kernel_data < floppy_track_buffer ||
-                   current_count_sectors < 0 ||
-                   raw_cmd->length < 0 ||
-                   raw_cmd->kernel_data + raw_cmd->length >
-                   floppy_track_buffer + (max_buffer_sectors  << 10)){
-                       DPRINT("buffer overrun in schedule dma\n");
-                       printk("fsector_t=%d buffer_min=%d current_count=%ld\n",
-                              fsector_t, buffer_min,
-                              raw_cmd->length >> 9);
-                       printk("current_count_sectors=%ld\n",
-                              current_count_sectors);
-                       if (CT(COMMAND) == FD_READ)
-                               printk("read\n");
-                       if (CT(COMMAND) == FD_WRITE)
-                               printk("write\n");
-                       return 0;
-               }
-       } else if (raw_cmd->length > current_req->nr_sectors << 9 ||
-                  current_count_sectors > current_req->nr_sectors){
-               DPRINT("buffer overrun in direct transfer\n");
-               return 0;
-       } else if (raw_cmd->length < current_count_sectors << 9){
-               DPRINT("more sectors than bytes\n");
-               printk("bytes=%ld\n", raw_cmd->length >> 9);
-               printk("sectors=%ld\n", current_count_sectors);
-       }
-       if (raw_cmd->length == 0){
-               DPRINT("zero dma transfer attempted from make_raw_request\n");
-               return 0;
-       }
-#endif
-
-       virtualdmabug_workaround();
-       return 2;
-}
-
-static void redo_fd_request(void)
-{
-#define REPEAT {request_done(0); continue; }
-       int drive;
-       int tmp;
-
-       lastredo = jiffies;
-       if (current_drive < N_DRIVE)
-               floppy_off(current_drive);
-
-       for (;;) {
-               if (!current_req) {
-                       struct request *req;
-
-                       spin_lock_irq(floppy_queue->queue_lock);
-                       req = elv_next_request(floppy_queue);
-                       spin_unlock_irq(floppy_queue->queue_lock);
-                       if (!req) {
-                               do_floppy = NULL;
-                               unlock_fdc();
-                               return;
-                       }
-                       current_req = req;
-               }
-               drive = (long)current_req->rq_disk->private_data;
-               set_fdc(drive);
-               reschedule_timeout(current_reqD, "redo fd request", 0);
-
-               set_floppy(drive);
-               raw_cmd = & default_raw_cmd;
-               raw_cmd->flags = 0;
-               if (start_motor(redo_fd_request)) return;
-               disk_change(current_drive);
-               if (test_bit(current_drive, &fake_change) ||
-                  TESTF(FD_DISK_CHANGED)){
-                       DPRINT("disk absent or changed during operation\n");
-                       REPEAT;
-               }
-               if (!_floppy) { /* Autodetection */
-                       if (!probing){
-                               DRS->probed_format = 0;
-                               if (next_valid_format()){
-                                       DPRINT("no autodetectable formats\n");
-                                       _floppy = NULL;
-                                       REPEAT;
-                               }
-                       }
-                       probing = 1;
-                       _floppy = floppy_type+DP->autodetect[DRS->probed_format];
-               } else
-                       probing = 0;
-               errors = & (current_req->errors);
-               tmp = make_raw_rw_request();
-               if (tmp < 2){
-                       request_done(tmp);
-                       continue;
-               }
-
-               if (TESTF(FD_NEED_TWADDLE))
-                       twaddle();
-               schedule_bh( (void *)(void *) floppy_start);
-#ifdef DEBUGT
-               debugt("queue fd request");
-#endif
-               return;
-       }
-#undef REPEAT
-}
-
-static struct cont_t rw_cont={
-       rw_interrupt,
-       redo_fd_request,
-       bad_flp_intr,
-       request_done };
-
-static void process_fd_request(void)
-{
-       cont = &rw_cont;
-       schedule_bh( (void *)(void *) redo_fd_request);
-}
-
-static void do_fd_request(request_queue_t * q)
-{
-       if(max_buffer_sectors == 0) {
-               printk("VFS: do_fd_request called on non-open device\n");
-               return;
-       }
-
-       if (usage_count == 0) {
-               printk("warning: usage count=0, current_req=%p exiting\n", current_req);
-               printk("sect=%ld flags=%lx\n", (long)current_req->sector, current_req->flags);
-               return;
-       }
-       if (fdc_busy){
-               /* fdc busy, this new request will be treated when the
-                  current one is done */
-               is_alive("do fd request, old request running");
-               return;
-       }
-       lock_fdc(MAXTIMEOUT,0);
-       process_fd_request();
-       is_alive("do fd request");
-}
-
-static struct cont_t poll_cont={
-       success_and_wakeup,
-       floppy_ready,
-       generic_failure,
-       generic_done };
-
-static int poll_drive(int interruptible, int flag)
-{
-       int ret;
-       /* no auto-sense, just clear dcl */
-       raw_cmd = &default_raw_cmd;
-       raw_cmd->flags= flag;
-       raw_cmd->track=0;
-       raw_cmd->cmd_count=0;
-       cont = &poll_cont;
-#ifdef DCL_DEBUG
-       if (DP->flags & FD_DEBUG){
-               DPRINT("setting NEWCHANGE in poll_drive\n");
-       }
-#endif
-       SETF(FD_DISK_NEWCHANGE);
-       WAIT(floppy_ready);
-       return ret;
-}
-
-/*
- * User triggered reset
- * ====================
- */
-
-static void reset_intr(void)
-{
-       printk("weird, reset interrupt called\n");
-}
-
-static struct cont_t reset_cont={
-       reset_intr,
-       success_and_wakeup,
-       generic_failure,
-       generic_done };
-
-static int user_reset_fdc(int drive, int arg, int interruptible)
-{
-       int ret;
-
-       ret=0;
-       LOCK_FDC(drive,interruptible);
-       if (arg == FD_RESET_ALWAYS)
-               FDCS->reset=1;
-       if (FDCS->reset){
-               cont = &reset_cont;
-               WAIT(reset_fdc);
-       }
-       process_fd_request();
-       return ret;
-}
-
-/*
- * Misc Ioctl's and support
- * ========================
- */
-static inline int fd_copyout(void *param, const void *address, unsigned long size)
-{
-       return copy_to_user(param,address, size) ? -EFAULT : 0;
-}
-
-static inline int fd_copyin(void *param, void *address, unsigned long size)
-{
-       return copy_from_user(address, param, size) ? -EFAULT : 0;
-}
-
-#define _COPYOUT(x) (copy_to_user((void *)param, &(x), sizeof(x)) ? -EFAULT : 0)
-#define _COPYIN(x) (copy_from_user(&(x), (void *)param, sizeof(x)) ? -EFAULT : 0)
-
-#define COPYOUT(x) ECALL(_COPYOUT(x))
-#define COPYIN(x) ECALL(_COPYIN(x))
-
-static inline const char *drive_name(int type, int drive)
-{
-       struct floppy_struct *floppy;
-
-       if (type)
-               floppy = floppy_type + type;
-       else {
-               if (UDP->native_format)
-                       floppy = floppy_type + UDP->native_format;
-               else
-                       return "(null)";
-       }
-       if (floppy->name)
-               return floppy->name;
-       else
-               return "(null)";
-}
-
-
-/* raw commands */
-static void raw_cmd_done(int flag)
-{
-       int i;
-
-       if (!flag) {
-               raw_cmd->flags |= FD_RAW_FAILURE;
-               raw_cmd->flags |= FD_RAW_HARDFAILURE;
-       } else {
-               raw_cmd->reply_count = inr;
-               if (raw_cmd->reply_count > MAX_REPLIES)
-                       raw_cmd->reply_count=0;
-               for (i=0; i< raw_cmd->reply_count; i++)
-                       raw_cmd->reply[i] = reply_buffer[i];
-
-               if (raw_cmd->flags & (FD_RAW_READ | FD_RAW_WRITE))
-               {
-                       unsigned long flags;
-                       flags=claim_dma_lock();
-                       raw_cmd->length = fd_get_dma_residue();
-                       release_dma_lock(flags);
-               }
-               
-               if ((raw_cmd->flags & FD_RAW_SOFTFAILURE) &&
-                   (!raw_cmd->reply_count || (raw_cmd->reply[0] & 0xc0)))
-                       raw_cmd->flags |= FD_RAW_FAILURE;
-
-               if (disk_change(current_drive))
-                       raw_cmd->flags |= FD_RAW_DISK_CHANGE;
-               else
-                       raw_cmd->flags &= ~FD_RAW_DISK_CHANGE;
-               if (raw_cmd->flags & FD_RAW_NO_MOTOR_AFTER)
-                       motor_off_callback(current_drive);
-
-               if (raw_cmd->next &&
-                  (!(raw_cmd->flags & FD_RAW_FAILURE) ||
-                   !(raw_cmd->flags & FD_RAW_STOP_IF_FAILURE)) &&
-                  ((raw_cmd->flags & FD_RAW_FAILURE) ||
-                   !(raw_cmd->flags &FD_RAW_STOP_IF_SUCCESS))) {
-                       raw_cmd = raw_cmd->next;
-                       return;
-               }
-       }
-       generic_done(flag);
-}
-
-
-static struct cont_t raw_cmd_cont={
-       success_and_wakeup,
-       floppy_start,
-       generic_failure,
-       raw_cmd_done
-};
-
-static inline int raw_cmd_copyout(int cmd, char *param,
-                                 struct floppy_raw_cmd *ptr)
-{
-       int ret;
-
-       while(ptr) {
-               COPYOUT(*ptr);
-               param += sizeof(struct floppy_raw_cmd);
-               if ((ptr->flags & FD_RAW_READ) && ptr->buffer_length){
-                       if (ptr->length>=0 && ptr->length<=ptr->buffer_length)
-                               ECALL(fd_copyout(ptr->data, 
-                                                ptr->kernel_data, 
-                                                ptr->buffer_length - 
-                                                ptr->length));
-               }
-               ptr = ptr->next;
-       }
-       return 0;
-}
-
-
-static void raw_cmd_free(struct floppy_raw_cmd **ptr)
-{
-       struct floppy_raw_cmd *next,*this;
-
-       this = *ptr;
-       *ptr = 0;
-       while(this) {
-               if (this->buffer_length) {
-                       fd_dma_mem_free((unsigned long)this->kernel_data,
-                                       this->buffer_length);
-                       this->buffer_length = 0;
-               }
-               next = this->next;
-               kfree(this);
-               this = next;
-       }
-}
-
-
-static inline int raw_cmd_copyin(int cmd, char *param,
-                                struct floppy_raw_cmd **rcmd)
-{
-       struct floppy_raw_cmd *ptr;
-       int ret;
-       int i;
-       
-       *rcmd = 0;
-       while(1) {
-               ptr = (struct floppy_raw_cmd *) 
-                       kmalloc(sizeof(struct floppy_raw_cmd), GFP_USER);
-               if (!ptr)
-                       return -ENOMEM;
-               *rcmd = ptr;
-               COPYIN(*ptr);
-               ptr->next = 0;
-               ptr->buffer_length = 0;
-               param += sizeof(struct floppy_raw_cmd);
-               if (ptr->cmd_count > 33)
-                       /* the command may now also take up the space
-                        * initially intended for the reply & the
-                        * reply count. Needed for long 82078 commands
-                        * such as RESTORE, which takes ... 17 command
-                        * bytes. Murphy's law #137: When you reserve
-                        * 16 bytes for a structure, you'll one day
-                        * discover that you really need 17...
-                        */
-                       return -EINVAL;
-
-               for (i=0; i< 16; i++)
-                       ptr->reply[i] = 0;
-               ptr->resultcode = 0;
-               ptr->kernel_data = 0;
-
-               if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
-                       if (ptr->length <= 0)
-                               return -EINVAL;
-                       ptr->kernel_data =(char*)fd_dma_mem_alloc(ptr->length);
-                       fallback_on_nodma_alloc(&ptr->kernel_data,
-                                               ptr->length);
-                       if (!ptr->kernel_data)
-                               return -ENOMEM;
-                       ptr->buffer_length = ptr->length;
-               }
-               if (ptr->flags & FD_RAW_WRITE)
-                       ECALL(fd_copyin(ptr->data, ptr->kernel_data, 
-                                       ptr->length));
-               rcmd = & (ptr->next);
-               if (!(ptr->flags & FD_RAW_MORE))
-                       return 0;
-               ptr->rate &= 0x43;
-       }
-}
-
-
-static int raw_cmd_ioctl(int cmd, void *param)
-{
-       int drive, ret, ret2;
-       struct floppy_raw_cmd *my_raw_cmd;
-
-       if (FDCS->rawcmd <= 1)
-               FDCS->rawcmd = 1;
-       for (drive= 0; drive < N_DRIVE; drive++){
-               if (FDC(drive) != fdc)
-                       continue;
-               if (drive == current_drive){
-                       if (UDRS->fd_ref > 1){
-                               FDCS->rawcmd = 2;
-                               break;
-                       }
-               } else if (UDRS->fd_ref){
-                       FDCS->rawcmd = 2;
-                       break;
-               }
-       }
-
-       if (FDCS->reset)
-               return -EIO;
-
-       ret = raw_cmd_copyin(cmd, param, &my_raw_cmd);
-       if (ret) {
-               raw_cmd_free(&my_raw_cmd);
-               return ret;
-       }
-
-       raw_cmd = my_raw_cmd;
-       cont = &raw_cmd_cont;
-       ret=wait_til_done(floppy_start,1);
-#ifdef DCL_DEBUG
-       if (DP->flags & FD_DEBUG){
-               DPRINT("calling disk change from raw_cmd ioctl\n");
-       }
-#endif
-
-       if (ret != -EINTR && FDCS->reset)
-               ret = -EIO;
-
-       DRS->track = NO_TRACK;
-
-       ret2 = raw_cmd_copyout(cmd, param, my_raw_cmd);
-       if (!ret)
-               ret = ret2;
-       raw_cmd_free(&my_raw_cmd);
-       return ret;
-}
-
-static int invalidate_drive(struct block_device *bdev)
-{
-       /* invalidate the buffer track to force a reread */
-       set_bit((long)bdev->bd_disk->private_data, &fake_change);
-       process_fd_request();
-       check_disk_change(bdev);
-       return 0;
-}
-
-
-static inline void clear_write_error(int drive)
-{
-       CLEARSTRUCT(UDRWE);
-}
-
-static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
-                              int drive, int type, struct block_device *bdev)
-{
-       int cnt;
-
-       /* sanity checking for parameters.*/
-       if (g->sect <= 0 ||
-           g->head <= 0 ||
-           g->track <= 0 ||
-           g->track > UDP->tracks>>STRETCH(g) ||
-           /* check if reserved bits are set */
-           (g->stretch&~(FD_STRETCH|FD_SWAPSIDES)) != 0)
-               return -EINVAL;
-       if (type){
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-               down(&open_lock);
-               LOCK_FDC(drive,1);
-               floppy_type[type] = *g;
-               floppy_type[type].name="user format";
-               for (cnt = type << 2; cnt < (type << 2) + 4; cnt++)
-                       floppy_sizes[cnt]= floppy_sizes[cnt+0x80]=
-                               floppy_type[type].size+1;
-               process_fd_request();
-               for (cnt = 0; cnt < N_DRIVE; cnt++) {
-                       struct block_device *bdev = opened_bdev[cnt];
-                       if (!bdev || ITYPE(drive_state[cnt].fd_device) != type)
-                               continue;
-                       __invalidate_device(bdev, 0);
-               }
-               up(&open_lock);
-       } else {
-               LOCK_FDC(drive,1);
-               if (cmd != FDDEFPRM)
-                       /* notice a disk change immediately, else
-                        * we lose our settings immediately*/
-                       CALL(poll_drive(1, FD_RAW_NEED_DISK));
-               user_params[drive] = *g;
-               if (buffer_drive == drive)
-                       SUPBOUND(buffer_max, user_params[drive].sect);
-               current_type[drive] = &user_params[drive];
-               floppy_sizes[drive] = user_params[drive].size;
-               if (cmd == FDDEFPRM)
-                       DRS->keep_data = -1;
-               else
-                       DRS->keep_data = 1;
-               /* invalidation. Invalidate only when needed, i.e.
-                * when there are already sectors in the buffer cache
-                * whose number will change. This is useful, because
-                * mtools often changes the geometry of the disk after
-                * looking at the boot block */
-               if (DRS->maxblock > user_params[drive].sect || DRS->maxtrack)
-                       invalidate_drive(bdev);
-               else
-                       process_fd_request();
-       }
-       return 0;
-}
-
-/* handle obsolete ioctl's */
-static int ioctl_table[]= {
-       FDCLRPRM,
-       FDSETPRM,
-       FDDEFPRM,
-       FDGETPRM,
-       FDMSGON,
-       FDMSGOFF,
-       FDFMTBEG,
-       FDFMTTRK,
-       FDFMTEND,
-       FDSETEMSGTRESH,
-       FDFLUSH,
-       FDSETMAXERRS,
-       FDGETMAXERRS,
-       FDGETDRVTYP,
-       FDSETDRVPRM,
-       FDGETDRVPRM,
-       FDGETDRVSTAT,
-       FDPOLLDRVSTAT,
-       FDRESET,
-       FDGETFDCSTAT,
-       FDWERRORCLR,
-       FDWERRORGET,
-       FDRAWCMD,
-       FDEJECT,
-       FDTWADDLE
-};
-
-static inline int normalize_ioctl(int *cmd, int *size)
-{
-       int i;
-
-       for (i=0; i < ARRAY_SIZE(ioctl_table); i++) {
-               if ((*cmd & 0xffff) == (ioctl_table[i] & 0xffff)){
-                       *size = _IOC_SIZE(*cmd);
-                       *cmd = ioctl_table[i];
-                       if (*size > _IOC_SIZE(*cmd)) {
-                               printk("ioctl not yet supported\n");
-                               return -EFAULT;
-                       }
-                       return 0;
-               }
-       }
-       return -EINVAL;
-}
-
-static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
-{
-       if (type)
-               *g = &floppy_type[type];
-       else {
-               LOCK_FDC(drive,0);
-               CALL(poll_drive(0,0));
-               process_fd_request();           
-               *g = current_type[drive];
-       }
-       if (!*g)
-               return -ENODEV;
-       return 0;
-}
-
-static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-                   unsigned long param)
-{
-#define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data)
-#define OUT(c,x) case c: outparam = (const char *) (x); break
-#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
-
-       int drive = (long)inode->i_bdev->bd_disk->private_data;
-       int i, type = ITYPE(UDRS->fd_device);
-       int ret;
-       int size;
-       union inparam {
-               struct floppy_struct g; /* geometry */
-               struct format_descr f;
-               struct floppy_max_errors max_errors;
-               struct floppy_drive_params dp;
-       } inparam; /* parameters coming from user space */
-       const char *outparam; /* parameters passed back to user space */
-
-       /* convert compatibility eject ioctls into floppy eject ioctl.
-        * We do this in order to provide a means to eject floppy disks before
-        * installing the new fdutils package */
-       if (cmd == CDROMEJECT || /* CD-ROM eject */
-           cmd == 0x6470 /* SunOS floppy eject */) {
-               DPRINT("obsolete eject ioctl\n");
-               DPRINT("please use floppycontrol --eject\n");
-               cmd = FDEJECT;
-       }
-
-       /* generic block device ioctls */
-       switch(cmd) {
-               /* the following have been inspired by the corresponding
-                * code for other block devices. */
-               struct floppy_struct *g;
-               case HDIO_GETGEO:
-               {
-                       struct hd_geometry loc;
-                       ECALL(get_floppy_geometry(drive, type, &g));
-                       loc.heads = g->head;
-                       loc.sectors = g->sect;
-                       loc.cylinders = g->track;
-                       loc.start = 0;
-                       return _COPYOUT(loc);
-               }
-       }
-
-       /* convert the old style command into a new style command */
-       if ((cmd & 0xff00) == 0x0200) {
-               ECALL(normalize_ioctl(&cmd, &size));
-       } else
-               return -EINVAL;
-
-       /* permission checks */
-       if (((cmd & 0x40) && !FD_IOCTL_ALLOWED) ||
-           ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
-               return -EPERM;
-
-       /* copyin */
-       CLEARSTRUCT(&inparam);
-       if (_IOC_DIR(cmd) & _IOC_WRITE)
-               ECALL(fd_copyin((void *)param, &inparam, size))
-
-       switch (cmd) {
-               case FDEJECT:
-                       if (UDRS->fd_ref != 1)
-                               /* somebody else has this drive open */
-                               return -EBUSY;
-                       LOCK_FDC(drive,1);
-
-                       /* do the actual eject. Fails on
-                        * non-Sparc architectures */
-                       ret=fd_eject(UNIT(drive));
-
-                       USETF(FD_DISK_CHANGED);
-                       USETF(FD_VERIFY);
-                       process_fd_request();
-                       return ret;                     
-               case FDCLRPRM:
-                       LOCK_FDC(drive,1);
-                       current_type[drive] = NULL;
-                       floppy_sizes[drive] = MAX_DISK_SIZE << 1;
-                       UDRS->keep_data = 0;
-                       return invalidate_drive(inode->i_bdev);
-               case FDSETPRM:
-               case FDDEFPRM:
-                       return set_geometry(cmd, & inparam.g,
-                                           drive, type, inode->i_bdev);
-               case FDGETPRM:
-                       ECALL(get_floppy_geometry(drive, type, 
-                                                 (struct floppy_struct**)
-                                                 &outparam));
-                       break;
-
-               case FDMSGON:
-                       UDP->flags |= FTD_MSG;
-                       return 0;
-               case FDMSGOFF:
-                       UDP->flags &= ~FTD_MSG;
-                       return 0;
-
-               case FDFMTBEG:
-                       LOCK_FDC(drive,1);
-                       CALL(poll_drive(1, FD_RAW_NEED_DISK));
-                       ret = UDRS->flags;
-                       if (ret & FD_VERIFY) {
-                               CALL(poll_drive(1, FD_RAW_NEED_DISK));
-                               ret = UDRS->flags;
-                       }
-
-                       if (ret & FD_VERIFY) {
-                               CALL(poll_drive(1, FD_RAW_NEED_DISK));
-                               ret = UDRS->flags;
-                       }
-
-                       if (ret & FD_VERIFY) {
-                               CALL(poll_drive(1, FD_RAW_NEED_DISK));
-                               ret = UDRS->flags;
-                       }
-
-                       if (ret & FD_VERIFY) {
-                               CALL(poll_drive(1, FD_RAW_NEED_DISK));
-                               ret = UDRS->flags;
-                       }
-
-                       if(ret & FD_VERIFY){
-                               CALL(poll_drive(1, FD_RAW_NEED_DISK));
-                               ret = UDRS->flags;
-                       }
-                       process_fd_request();
-                       if (ret & FD_VERIFY)
-                               return -ENODEV;
-                       if (!(ret & FD_DISK_WRITABLE))
-                               return -EROFS;
-                       return 0;
-               case FDFMTTRK:
-                       if (UDRS->fd_ref != 1)
-                               return -EBUSY;
-                       return do_format(drive, &inparam.f);
-               case FDFMTEND:
-               case FDFLUSH:
-                       LOCK_FDC(drive,1);
-                       return invalidate_drive(inode->i_bdev);
-
-               case FDSETEMSGTRESH:
-                       UDP->max_errors.reporting =
-                               (unsigned short) (param & 0x0f);
-                       return 0;
-               OUT(FDGETMAXERRS, &UDP->max_errors);
-               IN(FDSETMAXERRS, &UDP->max_errors, max_errors);
-
-               case FDGETDRVTYP:
-                       outparam = drive_name(type,drive);
-                       SUPBOUND(size,strlen(outparam)+1);
-                       break;
-
-               IN(FDSETDRVPRM, UDP, dp);
-               OUT(FDGETDRVPRM, UDP);
-
-               case FDPOLLDRVSTAT:
-                       LOCK_FDC(drive,1);
-                       CALL(poll_drive(1, FD_RAW_NEED_DISK));
-                       process_fd_request();
-                       /* fall through */
-               OUT(FDGETDRVSTAT, UDRS);
-
-               case FDRESET:
-                       return user_reset_fdc(drive, (int)param, 1);
-
-               OUT(FDGETFDCSTAT,UFDCS);
-
-               case FDWERRORCLR:
-                       CLEARSTRUCT(UDRWE);
-                       return 0;
-               OUT(FDWERRORGET,UDRWE);
-
-               case FDRAWCMD:
-                       if (type)
-                               return -EINVAL;
-                       LOCK_FDC(drive,1);
-                       set_floppy(drive);
-                       CALL(i = raw_cmd_ioctl(cmd,(void *) param));
-                       process_fd_request();
-                       return i;
-
-               case FDTWADDLE:
-                       LOCK_FDC(drive,1);
-                       twaddle();
-                       process_fd_request();
-                       return 0;
-
-               default:
-                       return -EINVAL;
-       }
-
-       if (_IOC_DIR(cmd) & _IOC_READ)
-               return fd_copyout((void *)param, outparam, size);
-       else
-               return 0;
-#undef OUT
-#undef IN
-}
-
-static void __init config_types(void)
-{
-       int first=1;
-       int drive;
-       extern struct fd_info {
-               unsigned char dummy[4 * 6];
-               unsigned char fd_types[8];
-       } drive_info;
-
-       for (drive = 0; drive < 4; drive++)
-               UDP->cmos = drive_info.fd_types[drive];
-
-       /* XXX */
-       /* additional physical CMOS drive detection should go here */
-
-       for (drive=0; drive < N_DRIVE; drive++){
-               unsigned int type = UDP->cmos;
-               struct floppy_drive_params *params;
-               const char *name = NULL;
-               static char temparea[32];
-
-               if (type < NUMBER(default_drive_params)) {
-                       params = &default_drive_params[type].params;
-                       if (type) {
-                               name = default_drive_params[type].name;
-                               allowed_drive_mask |= 1 << drive;
-                       }
-                       else
-                               allowed_drive_mask &= ~(1 << drive);
-               } else {
-                       params = &default_drive_params[0].params;
-                       sprintf(temparea, "unknown type %d (usb?)", type);
-                       name = temparea;
-               }
-               if (name) {
-                       const char * prepend = ",";
-                       if (first) {
-                               prepend = KERN_INFO "Floppy drive(s):";
-                               first = 0;
-                       }
-                       printk("%s fd%d is %s", prepend, drive, name);
-                       register_devfs_entries (drive);
-               }
-               *UDP = *params;
-       }
-       if (!first)
-               printk("\n");
-}
-
-static int floppy_release(struct inode * inode, struct file * filp)
-{
-       int drive = (long)inode->i_bdev->bd_disk->private_data;
-
-       down(&open_lock);
-       if (UDRS->fd_ref < 0)
-               UDRS->fd_ref=0;
-       else if (!UDRS->fd_ref--) {
-               DPRINT("floppy_release with fd_ref == 0");
-               UDRS->fd_ref = 0;
-       }
-       if (!UDRS->fd_ref)
-               opened_bdev[drive] = NULL;
-       floppy_release_irq_and_dma();
-       up(&open_lock);
-       return 0;
-}
-
-/*
- * floppy_open check for aliasing (/dev/fd0 can be the same as
- * /dev/PS0 etc), and disallows simultaneous access to the same
- * drive with different device numbers.
- */
-#define RETERR(x) do{floppy_release(inode,filp); return -(x);}while(0)
-
-static int floppy_open(struct inode * inode, struct file * filp)
-{
-       int drive = (long)inode->i_bdev->bd_disk->private_data;
-       int old_dev;
-       int try;
-       int res = -EBUSY;
-       char *tmp;
-
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("floppy open: start\n");
-#endif
-       filp->private_data = (void*) 0;
-
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("floppy open: drive=%d, current_drive=%d, UDP->cmos=%d\n"
-                  "floppy open: FDCS={spec1=%d, spec2=%d, dtr=%d, version=%d, dor=%d, address=%lu}\n",
-                  drive, current_drive, UDP->cmos, FDCS->spec1, FDCS->spec2,
-                  FDCS->dtr, FDCS->version, FDCS->dor, FDCS->address);
-       if (_floppy) {
-               printk("floppy open: _floppy={size=%d, sect=%d, head=%d, track=%d, spec1=%d}\n",
-                          _floppy->size, _floppy->sect, _floppy->head,
-                          _floppy->track, _floppy->spec1);
-       } else {
-               printk("floppy open: _floppy=NULL\n");
-       }
-#endif /* PC9800_DEBUG_FLOPPY */
-
-       down(&open_lock);
-       old_dev = UDRS->fd_device;
-       if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
-               goto out2;
-
-       if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){
-               USETF(FD_DISK_CHANGED);
-               USETF(FD_VERIFY);
-       }
-
-       if (UDRS->fd_ref == -1 ||
-          (UDRS->fd_ref && (filp->f_flags & O_EXCL)))
-               goto out2;
-
-       if (floppy_grab_irq_and_dma())
-               goto out2;
-
-       if (filp->f_flags & O_EXCL)
-               UDRS->fd_ref = -1;
-       else
-               UDRS->fd_ref++;
-
-       opened_bdev[drive] = inode->i_bdev;
-
-       res = -ENXIO;
-
-       if (!floppy_track_buffer){
-               /* if opening an ED drive, reserve a big buffer,
-                * else reserve a small one */
-               if ((UDP->cmos == 6) || (UDP->cmos == 5))
-                       try = 64; /* Only 48 actually useful */
-               else
-                       try = 32; /* Only 24 actually useful */
-
-               tmp=(char *)fd_dma_mem_alloc(1024 * try);
-               if (!tmp && !floppy_track_buffer) {
-                       try >>= 1; /* buffer only one side */
-                       INFBOUND(try, 16);
-                       tmp= (char *)fd_dma_mem_alloc(1024*try);
-               }
-               if (!tmp && !floppy_track_buffer) {
-                       fallback_on_nodma_alloc(&tmp, 2048 * try);
-               }
-               if (!tmp && !floppy_track_buffer) {
-                       DPRINT("Unable to allocate DMA memory\n");
-                       goto out;
-               }
-               if (floppy_track_buffer) {
-                       if (tmp)
-                               fd_dma_mem_free((unsigned long)tmp,try*1024);
-               } else {
-                       buffer_min = buffer_max = -1;
-                       floppy_track_buffer = tmp;
-                       max_buffer_sectors = try;
-               }
-       }
-
-       UDRS->fd_device = iminor(inode);
-       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
-       if (old_dev != -1 && old_dev != iminor(inode)) {
-               if (buffer_drive == drive)
-                       buffer_track = -1;
-       }
-
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("floppy open: floppy.c:%d passed\n", __LINE__);
-#endif
-
-
-       /* Allow ioctls if we have write-permissions even if read-only open.
-        * Needed so that programs such as fdrawcmd still can work on write
-        * protected disks */
-       if (filp->f_mode & 2 || permission(filp->f_dentry->d_inode,2,NULL) == 0)
-           filp->private_data = (void*) 8;
-
-       if (UFDCS->rawcmd == 1)
-               UFDCS->rawcmd = 2;
-
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("floppy open: floppy.c:%d passed\n", __LINE__);
-#endif
-
-       if (!(filp->f_flags & O_NDELAY)) {
-               if (filp->f_mode & 3) {
-                       UDRS->last_checked = 0;
-                       check_disk_change(inode->i_bdev);
-                       if (UTESTF(FD_DISK_CHANGED))
-                               goto out;
-               }
-               res = -EROFS;
-               if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
-                       goto out;
-#ifdef PC9800_DEBUG_FLOPPY
-               printk("floppy open: end normally\n");
-#endif
-       }
-       up(&open_lock);
-       return 0;
-out:
-       if (UDRS->fd_ref < 0)
-               UDRS->fd_ref=0;
-       else
-               UDRS->fd_ref--;
-       if (!UDRS->fd_ref)
-               opened_bdev[drive] = NULL;
-       floppy_release_irq_and_dma();
-out2:
-       up(&open_lock);
-       return res;
-}
-
-/*
- * Check if the disk has been changed or if a change has been faked.
- */
-static int check_floppy_change(struct gendisk *disk)
-{
-       int drive = (long)disk->private_data;
-
-#ifdef PC9800_DEBUG_FLOPPY
-       printk("check_floppy_change: MINOR=%d\n", minor(dev));
-#endif
-
-       if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY))
-               return 1;
-
-       if (UDP->checkfreq < (int)(jiffies - UDRS->last_checked)) {
-               if(floppy_grab_irq_and_dma()) {
-                       return 1;
-               }
-
-               lock_fdc(drive,0);
-               poll_drive(0,0);
-               process_fd_request();
-               floppy_release_irq_and_dma();
-       }
-
-       if (UTESTF(FD_DISK_CHANGED) ||
-          UTESTF(FD_VERIFY) ||
-          test_bit(drive, &fake_change) ||
-          (!ITYPE(UDRS->fd_device) && !current_type[drive]))
-               return 1;
-       return 0;
-}
-
-/*
- * This implements "read block 0" for floppy_revalidate().
- * Needed for format autodetection, checking whether there is
- * a disk in the drive, and whether that disk is writable.
- */
-
-static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done, int err)
-{
-       if (bio->bi_size)
-               return 1;
-
-       complete((struct completion*)bio->bi_private);
-       return 0;
-}
-
-static int __floppy_read_block_0(struct block_device *bdev)
-{
-       struct bio bio;
-       struct bio_vec bio_vec;
-       struct completion complete;
-       struct page *page;
-       size_t size;
-
-       page = alloc_page(GFP_NOIO);
-       if (!page) {
-               process_fd_request();
-               return -ENOMEM;
-       }
-
-       size = bdev->bd_block_size;
-       if (!size)
-               size = 1024;
-
-       bio_init(&bio);
-       bio.bi_io_vec = &bio_vec;
-       bio_vec.bv_page = page;
-       bio_vec.bv_len = size;
-       bio_vec.bv_offset = 0;
-       bio.bi_vcnt = 1;
-       bio.bi_idx = 0;
-       bio.bi_size = size;
-       bio.bi_bdev = bdev;
-       bio.bi_sector = 0;
-       init_completion(&complete);
-       bio.bi_private = &complete;
-       bio.bi_end_io = floppy_rb0_complete;
-
-       submit_bio(READ, &bio);
-       generic_unplug_device(bdev_get_queue(bdev));
-       process_fd_request();
-       wait_for_completion(&complete);
-
-       __free_page(page);
-
-       return 0;
-}
-
-/* revalidate the floppy disk, i.e. trigger format autodetection by reading
- * the bootblock (block 0). "Autodetection" is also needed to check whether
- * there is a disk in the drive at all... Thus we also do it for fixed
- * geometry formats */
-static int floppy_revalidate(struct gendisk *disk)
-{
-       int drive=(long)disk->private_data;
-#define NO_GEOM (!current_type[drive] && !ITYPE(UDRS->fd_device))
-       int cf;
-       int res = 0;
-
-       if (UTESTF(FD_DISK_CHANGED) ||
-           UTESTF(FD_VERIFY) ||
-           test_bit(drive, &fake_change) ||
-           NO_GEOM){
-               if(usage_count == 0) {
-                       printk("VFS: revalidate called on non-open device.\n");
-                       return -EFAULT;
-               }
-               lock_fdc(drive,0);
-               cf = UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY);
-               if (!(cf || test_bit(drive, &fake_change) || NO_GEOM)){
-                       process_fd_request(); /*already done by another thread*/
-                       return 0;
-               }
-               UDRS->maxblock = 0;
-               UDRS->maxtrack = 0;
-               if (buffer_drive == drive)
-                       buffer_track = -1;
-               clear_bit(drive, &fake_change);
-               UCLEARF(FD_DISK_CHANGED);
-               if (cf)
-                       UDRS->generation++;
-               if (NO_GEOM){
-                       /* auto-sensing */
-                       res = __floppy_read_block_0(opened_bdev[drive]);
-               } else {
-                       if (cf)
-                               poll_drive(0, FD_RAW_NEED_DISK);
-                       process_fd_request();
-               }
-       }
-       set_capacity(disk, floppy_sizes[UDRS->fd_device]);
-       return res;
-}
-
-static struct block_device_operations floppy_fops = {
-       .owner          = THIS_MODULE,
-       .open           = floppy_open,
-       .release        = floppy_release,
-       .ioctl          = fd_ioctl,
-       .media_changed  = check_floppy_change,
-       .revalidate_disk= floppy_revalidate,
-};
-
-static char *table[] =
-{"",
-#if 0
-       "d360", 
-#else
-       "h1232",
-#endif
-       "h1200", "u360", "u720", "h360", "h720",
-       "u1440", "u2880", "CompaQ", "h1440", "u1680", "h410",
-       "u820", "h1476", "u1722", "h420", "u830", "h1494", "u1743",
-       "h880", "u1040", "u1120", "h1600", "u1760", "u1920",
-       "u3200", "u3520", "u3840", "u1840", "u800", "u1600",
-NULL
-};
-
-static int t360[] = {
-       1,0
-};
-static int t1200[] = {
-       2,5,6,10,12,14,16,18,20,23,0
-};
-static int t3in[] = {
-        8, 9,26,27,28, 7,11,15,19,24,25,
-       29,31, 3, 4,13,17,21,22,30, 0
-};
-
-static int *table_sup[] = {
-       NULL, t360, t1200, t3in+5+8, t3in+5, t3in, t3in
-};
-
-static void __init register_devfs_entries (int drive)
-{
-       int base_minor = (drive < 4) ? drive : (124 + drive);
-
-       if (UDP->cmos < NUMBER(default_drive_params)) {
-               int i = 0;
-               do {
-                       int minor = base_minor + (table_sup[UDP->cmos][i] << 2);
-
-                       devfs_mk_bdev(MKDEV(FLOPPY_MAJOR, minor), 
-                                       S_IFBLK|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP,
-                                       "floppy/%d%s",
-                                       drive, table[table_sup[UDP->cmos][i]]);
-               } while (table_sup[UDP->cmos][i++]);
-       }
-}
-
-/*
- * Floppy Driver initialization
- * =============================
- */
-
-static inline char __init get_fdc_version(void)
-{
-       return FDC_8272A;
-}
-
-/* lilo configuration */
-
-static void __init floppy_set_flags(int *ints,int param, int param2)
-{
-       int i;
-
-       for (i=0; i < ARRAY_SIZE(default_drive_params); i++){
-               if (param)
-                       default_drive_params[i].params.flags |= param2;
-               else
-                       default_drive_params[i].params.flags &= ~param2;
-       }
-       DPRINT("%s flag 0x%x\n", param2 ? "Setting" : "Clearing", param);
-}
-
-static void __init daring(int *ints,int param, int param2)
-{
-       int i;
-
-       for (i=0; i < ARRAY_SIZE(default_drive_params); i++){
-               if (param){
-                       default_drive_params[i].params.select_delay = 0;
-                       default_drive_params[i].params.flags |= FD_SILENT_DCL_CLEAR;
-               } else {
-                       default_drive_params[i].params.select_delay = 2*HZ/100;
-                       default_drive_params[i].params.flags &= ~FD_SILENT_DCL_CLEAR;
-               }
-       }
-       DPRINT("Assuming %s floppy hardware\n", param ? "standard" : "broken");
-}
-
-static void __init set_cmos(int *ints, int dummy, int dummy2)
-{
-       int current_drive=0;
-
-       if (ints[0] != 2){
-               DPRINT("wrong number of parameters for CMOS\n");
-               return;
-       }
-       current_drive = ints[1];
-       if (current_drive < 0 || current_drive >= 8){
-               DPRINT("bad drive for set_cmos\n");
-               return;
-       }
-#if N_FDC > 1
-       if (current_drive >= 4 && !FDC2)
-               FDC2 = 0x370;
-#endif
-       DP->cmos = ints[2];
-       DPRINT("setting CMOS code to %d\n", ints[2]);
-}
-
-static struct param_table {
-       const char *name;
-       void (*fn)(int *ints, int param, int param2);
-       int *var;
-       int def_param;
-       int param2;
-} config_params[]={
-       { "allowed_drive_mask", 0, &allowed_drive_mask, 0xff, 0}, /* obsolete */
-       { "all_drives", 0, &allowed_drive_mask, 0xff, 0 }, /* obsolete */
-       { "irq", 0, &FLOPPY_IRQ, DEFAULT_FLOPPY_IRQ, 0 },
-       { "dma", 0, &FLOPPY_DMA, DEFAULT_FLOPPY_DMA, 0 },
-
-       { "daring", daring, 0, 1, 0},
-#if N_FDC > 1
-       { "two_fdc",  0, &FDC2, 0x370, 0 },
-       { "one_fdc", 0, &FDC2, 0, 0 },
-#endif
-       { "broken_dcl", floppy_set_flags, 0, 1, FD_BROKEN_DCL },
-       { "messages", floppy_set_flags, 0, 1, FTD_MSG },
-       { "silent_dcl_clear", floppy_set_flags, 0, 1, FD_SILENT_DCL_CLEAR },
-       { "debug", floppy_set_flags, 0, 1, FD_DEBUG },
-
-       { "nodma", 0, &can_use_virtual_dma, 1, 0 },
-       { "yesdma", 0, &can_use_virtual_dma, 0, 0 },
-
-       { "fifo_depth", 0, &fifo_depth, 0xa, 0 },
-       { "nofifo", 0, &no_fifo, 0x20, 0 },
-       { "usefifo", 0, &no_fifo, 0, 0 },
-
-       { "cmos", set_cmos, 0, 0, 0 },
-       { "slow", 0, &slow_floppy, 1, 0 },
-
-       { "unexpected_interrupts", 0, &print_unex, 1, 0 },
-       { "no_unexpected_interrupts", 0, &print_unex, 0, 0 },
-
-       EXTRA_FLOPPY_PARAMS
-};
-
-static int __init floppy_setup(char *str)
-{
-       int i;
-       int param;
-       int ints[11];
-
-       str = get_options(str,ARRAY_SIZE(ints),ints);
-       if (str) {
-               for (i=0; i< ARRAY_SIZE(config_params); i++){
-                       if (strcmp(str,config_params[i].name) == 0){
-                               if (ints[0])
-                                       param = ints[1];
-                               else
-                                       param = config_params[i].def_param;
-                               if (config_params[i].fn)
-                                       config_params[i].
-                                               fn(ints,param,
-                                                  config_params[i].param2);
-                               if (config_params[i].var) {
-                                       DPRINT("%s=%d\n", str, param);
-                                       *config_params[i].var = param;
-                               }
-                               return 1;
-                       }
-               }
-       }
-       if (str) {
-               DPRINT("unknown floppy option [%s]\n", str);
-               
-               DPRINT("allowed options are:");
-               for (i=0; i< ARRAY_SIZE(config_params); i++)
-                       printk(" %s",config_params[i].name);
-               printk("\n");
-       } else
-               DPRINT("botched floppy option\n");
-       DPRINT("Read linux/Documentation/floppy.txt\n");
-       return 0;
-}
-
-static int have_no_fdc= -ENODEV;
-
-static void floppy_device_release(struct device *dev)
-{
-       complete(&device_release);
-}
-
-static struct platform_device floppy_device = {
-       .name           = "floppy",
-       .id             = 0,
-       .dev            = {
-                       .release = floppy_device_release,
-       },
-};
-
-static struct kobject *floppy_find(dev_t dev, int *part, void *data)
-{
-       int drive = (*part&3) | ((*part&0x80) >> 5);
-       if (drive >= N_DRIVE ||
-           !(allowed_drive_mask & (1 << drive)) ||
-           fdc_state[FDC(drive)].version == FDC_NONE)
-               return NULL;
-       if (((*part>>2) & 0x1f) >= NUMBER(floppy_type))
-               return NULL;
-       *part = 0;
-       return get_disk(disks[drive]);
-}
-
-int __init floppy_init(void)
-{
-       int i,unit,drive;
-       int err;
-
-       raw_cmd = NULL;
-       FDC1 = 0x90;
-
-       for (i=0; i<N_DRIVE; i++) {
-               disks[i] = alloc_disk(1);
-               if (!disks[i])
-                       goto Enomem;
-       }
-
-       devfs_mk_dir (NULL, "floppy", NULL);
-       if ((err = register_blkdev(FLOPPY_MAJOR,"fd")))
-               goto out;
-
-       for (i=0; i<N_DRIVE; i++) {
-               disks[i]->major = FLOPPY_MAJOR;
-               disks[i]->first_minor = TOMINOR(i);
-               disks[i]->fops = &floppy_fops;
-               sprintf(disks[i]->disk_name, "fd%d", i);
-       }
-
-       blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
-                               floppy_find, NULL, NULL);
-
-       for (i=0; i<256; i++)
-               if (ITYPE(i))
-                       floppy_sizes[i] = floppy_type[ITYPE(i)].size;
-               else
-                       floppy_sizes[i] = MAX_DISK_SIZE << 1;
-
-       floppy_queue = blk_init_queue(do_fd_request, &floppy_lock);
-       if (!floppy_queue)
-               goto out_queue;
-
-       reschedule_timeout(MAXTIMEOUT, "floppy init", MAXTIMEOUT);
-       config_types();
-
-       for (i = 0; i < N_FDC; i++) {
-               fdc = i;
-               CLEARSTRUCT(FDCS);
-               FDCS->dtr = -1;
-               FDCS->dor = 0;
-       }
-
-       if ((fd_inb(FD_MODE_CHANGE) & 1) == 0)
-               FDC1 = 0xc8;
-
-       use_virtual_dma = can_use_virtual_dma & 1;
-       fdc_state[0].address = FDC1;
-       if (fdc_state[0].address == -1) {
-               err = -ENODEV;
-               goto out1;
-       }
-#if N_FDC > 1
-       fdc_state[1].address = FDC2;
-#endif
-
-       fdc = 0; /* reset fdc in case of unexpected interrupt */
-       if (floppy_grab_irq_and_dma()){
-               err = -EBUSY;
-               goto out1;
-       }
-
-       /* initialise drive state */
-       for (drive = 0; drive < N_DRIVE; drive++) {
-               CLEARSTRUCT(UDRS);
-               CLEARSTRUCT(UDRWE);
-               USETF(FD_DISK_NEWCHANGE);
-               USETF(FD_DISK_CHANGED);
-               USETF(FD_VERIFY);
-               UDRS->fd_device = -1;
-               floppy_track_buffer = NULL;
-               max_buffer_sectors = 0;
-       }
-
-       for (i = 0; i < N_FDC; i++) {
-               fdc = i;
-               FDCS->driver_version = FD_DRIVER_VERSION;
-               for (unit=0; unit<4; unit++)
-                       FDCS->track[unit] = 0;
-               if (FDCS->address == -1)
-                       continue;
-               FDCS->rawcmd = 2;
-               user_reset_fdc(-1, FD_RESET_ALWAYS, 0);
-
-               /* Try to determine the floppy controller type */
-               FDCS->version = get_fdc_version();
-               if (FDCS->version == FDC_NONE){
-                       /* free ioports reserved by floppy_grab_irq_and_dma() */
-                       release_region(FDCS->address, 1);
-                       release_region(FDCS->address + 2, 1);
-                       release_region(FDCS->address + 4, 1);
-                       release_region(0xbe, 1);
-                       release_region(0x4be, 1);
-                       FDCS->address = -1;
-                       continue;
-               }
-               if (can_use_virtual_dma == 2 && FDCS->version < FDC_82072A)
-                       can_use_virtual_dma = 0;
-
-               have_no_fdc = 0;
-               /* Not all FDCs seem to be able to handle the version command
-                * properly, so force a reset for the standard FDC clones,
-                * to avoid interrupt garbage.
-                */
-               user_reset_fdc(-1,FD_RESET_ALWAYS,0);
-       }
-       fdc=0;
-       del_timer(&fd_timeout);
-       current_drive = 0;
-       floppy_release_irq_and_dma();
-#if 0  /* no message */
-       initialising=0;
-#endif
-       if (have_no_fdc) {
-               DPRINT("no floppy controllers found\n");
-               flush_scheduled_work();
-               if (usage_count)
-                       floppy_release_irq_and_dma();
-               err = have_no_fdc;
-               goto out2;
-       }
-       
-       for (drive = 0; drive < N_DRIVE; drive++) {
-               init_timer(&motor_off_timer[drive]);
-               motor_off_timer[drive].data = drive;
-               motor_off_timer[drive].function = motor_off_callback;
-               if (!(allowed_drive_mask & (1 << drive)))
-                       continue;
-               if (fdc_state[FDC(drive)].version == FDC_NONE)
-                       continue;
-               /* to be cleaned up... */
-               disks[drive]->private_data = (void*)(long)drive;
-               disks[drive]->queue = floppy_queue;
-               add_disk(disks[drive]);
-       }
-
-       platform_device_register(&floppy_device);
-       return 0;
-
-out1:
-       del_timer_sync(&fd_timeout);
-out2:
-       blk_cleanup_queue(floppy_queue);
-out_queue:
-       blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
-       unregister_blkdev(FLOPPY_MAJOR,"fd");
-out:
-       for (i=0; i<N_DRIVE; i++)
-               put_disk(disks[i]);
-       return err;
-
-Enomem:
-       while (i--)
-               put_disk(disks[i]);
-       return -ENOMEM;
-}
-
-static spinlock_t floppy_usage_lock = SPIN_LOCK_UNLOCKED;
-
-static int floppy_grab_irq_and_dma(void)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&floppy_usage_lock, flags);
-       if (usage_count++){
-               spin_unlock_irqrestore(&floppy_usage_lock, flags);
-               return 0;
-       }
-       spin_unlock_irqrestore(&floppy_usage_lock, flags);
-       if (fd_request_irq()) {
-               DPRINT("Unable to grab IRQ%d for the floppy driver\n",
-                       FLOPPY_IRQ);
-               spin_lock_irqsave(&floppy_usage_lock, flags);
-               usage_count--;
-               spin_unlock_irqrestore(&floppy_usage_lock, flags);
-               return -1;
-       }
-       if (fd_request_dma()) {
-               DPRINT("Unable to grab DMA%d for the floppy driver\n",
-                       FLOPPY_DMA);
-               fd_free_irq();
-               spin_lock_irqsave(&floppy_usage_lock, flags);
-               usage_count--;
-               spin_unlock_irqrestore(&floppy_usage_lock, flags);
-               return -1;
-       }
-
-       for (fdc=0; fdc< N_FDC; fdc++){
-               if (FDCS->address != -1){
-                       static char floppy[] = "floppy";
-                       if (!request_region(FDCS->address, 1, floppy))
-                               goto cleanup0;
-
-                       if (!request_region(FDCS->address + 2, 1, floppy)) {
-                               release_region(FDCS->address, 1);
-                               goto cleanup0;
-                       }
-
-                       if (!request_region(FDCS->address + 4, 1, floppy)) {
-                               release_region(FDCS->address, 1);
-                               release_region(FDCS->address + 2, 1);
-                               goto cleanup0;
-                       }
-
-                       if (fdc == 0) {  /* internal FDC */
-                               if (request_region(0xbe, 1, "floppy mode change")) {
-                                       if (request_region(0x4be, 1, "floppy ex. mode change"))
-                                               continue;
-                                       else
-                                               DPRINT("Floppy io-port 0x4be in use\n");
-
-                                       release_region(0xbe, 1);
-                               } else
-                                       DPRINT("Floppy io-port 0xbe in use\n");
-
-                               release_region(FDCS->address, 1);
-                               release_region(FDCS->address + 2, 1);
-                               release_region(FDCS->address + 4, 1);
-                       }
-
-                       goto cleanup1;
-               }
-       }
-       for (fdc=0; fdc< N_FDC; fdc++){
-               if (FDCS->address != -1){
-                       reset_fdc_info(1);
-                       fd_outb(FDCS->dor, FD_MODE);
-               }
-       }
-       fdc = 0;
-       fd_outb((FDCS->dor & 8), FD_MODE);
-
-       for (fdc = 0; fdc < N_FDC; fdc++)
-               if (FDCS->address != -1)
-                       fd_outb(FDCS->dor, FD_MODE);
-       /*
-        *      The driver will try and free resources and relies on us
-        *      to know if they were allocated or not.
-        */
-       fdc = 0;
-       irqdma_allocated = 1;
-       return 0;
-
-cleanup0:
-       DPRINT("Floppy io-port 0x%04lx in use\n", FDCS->address);
-cleanup1:
-       fd_free_irq();
-       fd_free_dma();
-       while(--fdc >= 0) {
-               release_region(FDCS->address, 1);
-               release_region(FDCS->address + 2, 1);
-               release_region(FDCS->address + 4, 1);
-               if (fdc == 0) {
-                       release_region(0x00be, 1);
-                       release_region(0x04be, 1);
-               }
-       }
-       spin_lock_irqsave(&floppy_usage_lock, flags);
-       usage_count--;
-       spin_unlock_irqrestore(&floppy_usage_lock, flags);
-       return -1;
-}
-
-static void floppy_release_irq_and_dma(void)
-{
-       int old_fdc;
-#ifdef FLOPPY_SANITY_CHECK
-       int drive;
-#endif
-       long tmpsize;
-       unsigned long tmpaddr;
-       unsigned long flags;
-
-       spin_lock_irqsave(&floppy_usage_lock, flags);
-       if (--usage_count){
-               spin_unlock_irqrestore(&floppy_usage_lock, flags);
-               return;
-       }
-       spin_unlock_irqrestore(&floppy_usage_lock, flags);
-       if(irqdma_allocated)
-       {
-               fd_disable_dma();
-               fd_free_dma();
-               fd_free_irq();
-               irqdma_allocated=0;
-       }
-       fd_outb(0, FD_MODE);
-       floppy_enable_hlt();
-
-       if (floppy_track_buffer && max_buffer_sectors) {
-               tmpsize = max_buffer_sectors*1024;
-               tmpaddr = (unsigned long)floppy_track_buffer;
-               floppy_track_buffer = NULL;
-               max_buffer_sectors = 0;
-               buffer_min = buffer_max = -1;
-               fd_dma_mem_free(tmpaddr, tmpsize);
-       }
-
-#ifdef FLOPPY_SANITY_CHECK
-       for (drive=0; drive < N_FDC * 4; drive++)
-               if (timer_pending(motor_off_timer + drive))
-                       printk("motor off timer %d still active\n", drive);
-
-       if (timer_pending(&fd_timeout))
-               printk("floppy timer still active:%s\n", timeout_message);
-       if (timer_pending(&fd_timer))
-               printk("auxiliary floppy timer still active\n");
-       if (floppy_work.pending)
-               printk("work still pending\n");
-#endif
-       old_fdc = fdc;
-       for (fdc = 0; fdc < N_FDC; fdc++)
-               if (FDCS->address != -1) {
-                       release_region(FDCS->address, 1);
-                       release_region(FDCS->address + 2, 1);
-                       release_region(FDCS->address + 4, 1);
-                       if (fdc == 0) {
-                               release_region(0xbe, 1);
-                               release_region(0x4be, 1);
-                       }
-               }
-       fdc = old_fdc;
-}
-
-
-#ifdef MODULE
-
-char *floppy;
-
-static void unregister_devfs_entries (int drive)
-{
-    int i;
-
-    if (UDP->cmos < NUMBER(default_drive_params)) {
-       i = 0;
-       do {
-           devfs_remove("floppy/%d%s", drive, table[table_sup[UDP->cmos][i]]);
-       } while (table_sup[UDP->cmos][i++]);
-    }
-}
-
-static void __init parse_floppy_cfg_string(char *cfg)
-{
-       char *ptr;
-
-       while(*cfg) {
-               for(ptr = cfg;*cfg && *cfg != ' ' && *cfg != '\t'; cfg++);
-               if (*cfg) {
-                       *cfg = '\0';
-                       cfg++;
-               }
-               if (*ptr)
-                       floppy_setup(ptr);
-       }
-}
-
-int init_module(void)
-{
-       printk(KERN_INFO "inserting floppy driver for " UTS_RELEASE "\n");
-               
-       if (floppy)
-               parse_floppy_cfg_string(floppy);
-       return floppy_init();
-}
-
-void cleanup_module(void)
-{
-       int drive;
-               
-       init_completion(&device_release);
-       platform_device_unregister(&floppy_device);
-       blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
-       unregister_blkdev(FLOPPY_MAJOR, "fd");
-
-       for (drive = 0; drive < N_DRIVE; drive++) {
-               del_timer_sync(&motor_off_timer[drive]);
-
-               if ((allowed_drive_mask & (1 << drive)) &&
-                   fdc_state[FDC(drive)].version != FDC_NONE) {
-                       del_gendisk(disks[drive]);
-                       unregister_devfs_entries(drive);
-               }
-               put_disk(disks[drive]);
-       }
-       devfs_remove("floppy");
-
-       del_timer_sync(&fd_timeout);
-       del_timer_sync(&fd_timer);
-       blk_cleanup_queue(floppy_queue);
-
-       if (usage_count)
-               floppy_release_irq_and_dma();
-
-       /* eject disk, if any */
-       fd_eject(0);
-
-       wait_for_completion(&device_release);
-}
-
-MODULE_PARM(floppy,"s");
-MODULE_PARM(FLOPPY_IRQ,"i");
-MODULE_PARM(FLOPPY_DMA,"i");
-MODULE_AUTHOR("Osamu Tomita");
-MODULE_SUPPORTED_DEVICE("fd");
-MODULE_LICENSE("GPL");
-
-#else
-
-__setup ("floppy=", floppy_setup);
-module_init(floppy_init)
-#endif
index 17c403e..49ff5e0 100644 (file)
@@ -1362,12 +1362,12 @@ static int blk_init_free_list(request_queue_t *q)
 static int __make_request(request_queue_t *, struct bio *);
 
 static elevator_t *chosen_elevator =
-#if defined(CONFIG_IOSCHED_AS)
+#if defined(CONFIG_IOSCHED_CFQ)
+       &iosched_cfq;
+#elif defined(CONFIG_IOSCHED_AS)
        &iosched_as;
 #elif defined(CONFIG_IOSCHED_DEADLINE)
        &iosched_deadline;
-#elif defined(CONFIG_IOSCHED_CFQ)
-       &iosched_cfq;
 #elif defined(CONFIG_IOSCHED_NOOP)
        &elevator_noop;
 #else
@@ -1594,6 +1594,10 @@ static struct request *get_request(request_queue_t *q, int rw, int gfp_mask)
        struct io_context *ioc = get_io_context(gfp_mask);
 
        spin_lock_irq(q->queue_lock);
+
+       if (!elv_may_queue(q, rw))
+               goto out_lock;
+
        if (rl->count[rw]+1 >= q->nr_requests) {
                /*
                 * The queue will fill after this allocation, so set it as
@@ -1607,15 +1611,12 @@ static struct request *get_request(request_queue_t *q, int rw, int gfp_mask)
                }
        }
 
-       if (blk_queue_full(q, rw)
-                       && !ioc_batching(ioc) && !elv_may_queue(q, rw)) {
-               /*
-                * The queue is full and the allocating process is not a
-                * "batcher", and not exempted by the IO scheduler
-                */
-               spin_unlock_irq(q->queue_lock);
-               goto out;
-       }
+       /*
+        * The queue is full and the allocating process is not a
+        * "batcher", and not exempted by the IO scheduler
+        */
+       if (blk_queue_full(q, rw) && !ioc_batching(ioc))
+               goto out_lock;
 
        rl->count[rw]++;
        if (rl->count[rw] >= queue_congestion_on_threshold(q))
@@ -1633,8 +1634,7 @@ static struct request *get_request(request_queue_t *q, int rw, int gfp_mask)
                 */
                spin_lock_irq(q->queue_lock);
                freed_request(q, rw);
-               spin_unlock_irq(q->queue_lock);
-               goto out;
+               goto out_lock;
        }
 
        if (ioc_batching(ioc))
@@ -1664,6 +1664,11 @@ static struct request *get_request(request_queue_t *q, int rw, int gfp_mask)
 out:
        put_io_context(ioc);
        return rq;
+out_lock:
+       if (!rq)
+               elv_set_congested(q);
+       spin_unlock_irq(q->queue_lock);
+       goto out;
 }
 
 /*
@@ -2399,6 +2404,7 @@ void generic_make_request(struct bio *bio)
        sector_t maxsector;
        int ret, nr_sectors = bio_sectors(bio);
 
+       might_sleep();
        /* Test device or partition size, when known. */
        maxsector = bio->bi_bdev->bd_inode->i_size >> 9;
        if (maxsector) {
@@ -3167,3 +3173,21 @@ void blk_unregister_queue(struct gendisk *disk)
                kobject_put(&disk->kobj);
        }
 }
+
+asmlinkage int sys_ioprio_set(int ioprio)
+{
+       if (ioprio < IOPRIO_IDLE || ioprio > IOPRIO_RT)
+               return -EINVAL;
+       if (ioprio == IOPRIO_RT && !capable(CAP_SYS_ADMIN))
+               return -EACCES;
+
+       printk("%s: set ioprio %d\n", current->comm, ioprio);
+       current->ioprio = ioprio;
+       return 0;
+}
+
+asmlinkage int sys_ioprio_get(void)
+{
+       return current->ioprio;
+}
+
index 41d0239..f94fd8a 100644 (file)
@@ -154,7 +154,6 @@ static int verify_command(struct file *file, unsigned char *cmd)
                safe_for_write(WRITE_12),
                safe_for_write(WRITE_VERIFY_12),
                safe_for_write(WRITE_16),
-               safe_for_write(WRITE_BUFFER),
                safe_for_write(WRITE_LONG),
        };
        unsigned char type = cmd_type[cmd[0]];
@@ -316,12 +315,12 @@ static int sg_scsi_ioctl(struct file *file, request_queue_t *q,
                return -EFAULT;
        if (in_len > PAGE_SIZE || out_len > PAGE_SIZE)
                return -EINVAL;
-       if (get_user(opcode, sic->data))
+       if (get_user(opcode, (int *)sic->data))
                return -EFAULT;
 
        bytes = max(in_len, out_len);
        if (bytes) {
-               buffer = kmalloc(bytes, q->bounce_gfp | GFP_USER);
+               buffer = kmalloc(bytes, q->bounce_gfp | GFP_USER | __GFP_NOWARN);
                if (!buffer)
                        return -ENOMEM;
 
index 37e0673..d86e52e 100644 (file)
@@ -466,6 +466,8 @@ config LEGACY_PTYS
          security.  This option enables these legacy devices; on most
          systems, it is safe to say N.
 
+config CRASH
+        tristate "Crash Utility memory driver"
 
 config LEGACY_PTY_COUNT
        int "Maximum number of legacy PTY in use"
index b927c16..14e233e 100644 (file)
@@ -84,6 +84,8 @@ obj-$(CONFIG_IPMI_HANDLER) += ipmi/
 
 obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
 
+obj-$(CONFIG_CRASH) += crash.o
+
 # Files generated that shall be removed upon make clean
 clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c
 
diff --git a/drivers/char/crash.c b/drivers/char/crash.c
new file mode 100644 (file)
index 0000000..43cc96f
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ *  linux/drivers/char/crash.c
+ *
+ *  Copyright (C) 2004  Dave Anderson <anderson@redhat.com>
+ *  Copyright (C) 2004  Red Hat, Inc.
+ */
+
+/******************************************************************************
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2, or (at your option)
+ *   any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *****************************************************************************/
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/miscdevice.h>
+#include <linux/init.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/types.h>
+#include <asm/crash.h>
+
+#define CRASH_VERSION   "1.0"
+
+/*
+ *  These are the file operation functions that allow crash utility
+ *  access to physical memory.
+ */
+
+static loff_t 
+crash_llseek(struct file * file, loff_t offset, int orig)
+{
+        switch (orig) {
+                case 0:
+                        file->f_pos = offset;
+                        return file->f_pos;
+                case 1:
+                        file->f_pos += offset;
+                        return file->f_pos;
+                default:
+                        return -EINVAL;
+        }
+}
+
+/*
+ *  Determine the page address for an address offset value, 
+ *  get a virtual address for it, and copy it out.
+ *  Accesses must fit within a page.
+ */
+static ssize_t
+crash_read(struct file *file, char *buf, size_t count, loff_t *poff)
+{
+       void *vaddr;
+       struct page *page;
+       u64 offset;
+       ssize_t read;
+
+       offset = *poff;
+       if (offset >> PAGE_SHIFT != (offset+count-1) >> PAGE_SHIFT) 
+               return -EINVAL;
+
+       vaddr = map_virtual(offset, &page);
+       if (!vaddr)
+                return -EFAULT;
+
+        if (copy_to_user(buf, vaddr, count)) {
+               unmap_virtual(page);
+               return -EFAULT;
+       }
+       unmap_virtual(page);
+
+       read = count;
+        *poff += read;
+        return read;
+}
+
+static struct file_operations crash_fops = {
+       owner:          THIS_MODULE,
+       llseek:         crash_llseek,
+       read:           crash_read,
+};
+
+static struct miscdevice crash_dev = {
+       MISC_DYNAMIC_MINOR,
+       "crash",
+       &crash_fops
+};
+
+static int __init
+crash_init(void)
+{
+       int ret;
+
+       ret = misc_register(&crash_dev);
+       if (ret) {
+               printk(KERN_ERR 
+                   "crash memory driver: cannot misc_register (MISC_DYNAMIC_MINOR)\n");
+               goto out;
+       }
+       
+       ret = 0;
+       printk(KERN_INFO "crash memory driver: version %s\n", CRASH_VERSION);
+out:
+       return ret;
+}
+
+static void __exit
+crash_cleanup_module(void)
+{
+       misc_deregister(&crash_dev);
+}
+
+module_init(crash_init);
+module_exit(crash_cleanup_module);
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/char/drm/drm_irq.h b/drivers/char/drm/drm_irq.h
deleted file mode 100644 (file)
index 04bb0ac..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-/**
- * \file drm_irq.h 
- * IRQ support
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "drmP.h"
-
-#include <linux/interrupt.h>   /* For task queue support */
-
-#ifndef __HAVE_SHARED_IRQ
-#define __HAVE_SHARED_IRQ      0
-#endif
-
-#if __HAVE_SHARED_IRQ
-#define DRM_IRQ_TYPE           SA_SHIRQ
-#else
-#define DRM_IRQ_TYPE           0
-#endif
-
-/**
- * Get interrupt from bus id.
- * 
- * \param inode device inode.
- * \param filp file pointer.
- * \param cmd command.
- * \param arg user argument, pointing to a drm_irq_busid structure.
- * \return zero on success or a negative number on failure.
- * 
- * Finds the PCI device with the specified bus id and gets its IRQ number.
- * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
- * to that of the device that this DRM instance attached to.
- */
-int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
-                  unsigned int cmd, unsigned long arg)
-{
-       drm_file_t *priv = filp->private_data;
-       drm_device_t *dev = priv->dev;
-       drm_irq_busid_t __user *argp = (void __user *)arg;
-       drm_irq_busid_t p;
-
-       if (copy_from_user(&p, argp, sizeof(p)))
-               return -EFAULT;
-
-       if ((p.busnum >> 8) != dev->pci_domain ||
-           (p.busnum & 0xff) != dev->pci_bus ||
-           p.devnum != dev->pci_slot ||
-           p.funcnum != dev->pci_func)
-               return -EINVAL;
-
-       p.irq = dev->irq;
-
-       DRM_DEBUG("%d:%d:%d => IRQ %d\n",
-                 p.busnum, p.devnum, p.funcnum, p.irq);
-       if (copy_to_user(argp, &p, sizeof(p)))
-               return -EFAULT;
-       return 0;
-}
-
-#if __HAVE_IRQ
-
-/**
- * Install IRQ handler.
- *
- * \param dev DRM device.
- * \param irq IRQ number.
- *
- * Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver
- * \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions
- * before and after the installation.
- */
-int DRM(irq_install)( drm_device_t *dev )
-{
-       int ret;
-       if ( dev->irq == 0 )
-               return -EINVAL;
-
-       down( &dev->struct_sem );
-
-       /* Driver must have been initialized */
-       if ( !dev->dev_private ) {
-               up( &dev->struct_sem );
-               return -EINVAL;
-       }
-
-       if ( dev->irq_enabled ) {
-               up( &dev->struct_sem );
-               return -EBUSY;
-       }
-       dev->irq_enabled = 1;
-       up( &dev->struct_sem );
-
-       DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
-
-#if __HAVE_DMA
-       dev->dma->next_buffer = NULL;
-       dev->dma->next_queue = NULL;
-       dev->dma->this_buffer = NULL;
-#endif
-
-#ifdef __HAVE_IRQ_BH
-       INIT_WORK(&dev->work, DRM(irq_immediate_bh), dev);
-#endif
-
-#ifdef __HAVE_VBL_IRQ
-       init_waitqueue_head(&dev->vbl_queue);
-
-       spin_lock_init( &dev->vbl_lock );
-
-       INIT_LIST_HEAD( &dev->vbl_sigs.head );
-
-       dev->vbl_pending = 0;
-#endif
-
-                               /* Before installing handler */
-       DRM(driver_irq_preinstall)(dev);
-
-                               /* Install handler */
-       ret = request_irq( dev->irq, DRM(irq_handler),
-                          DRM_IRQ_TYPE, dev->devname, dev );
-       if ( ret < 0 ) {
-               down( &dev->struct_sem );
-               dev->irq_enabled = 0;
-               up( &dev->struct_sem );
-               return ret;
-       }
-
-                               /* After installing handler */
-       DRM(driver_irq_postinstall)(dev);
-
-       return 0;
-}
-
-/**
- * Uninstall the IRQ handler.
- *
- * \param dev DRM device.
- *
- * Calls the driver's \c DRM(driver_irq_uninstall)() function, and stops the irq.
- */
-int DRM(irq_uninstall)( drm_device_t *dev )
-{
-       int irq_enabled;
-
-       down( &dev->struct_sem );
-       irq_enabled = dev->irq_enabled;
-       dev->irq_enabled = 0;
-       up( &dev->struct_sem );
-
-       if ( !irq_enabled )
-               return -EINVAL;
-
-       DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
-
-       DRM(driver_irq_uninstall)( dev );
-
-       free_irq( dev->irq, dev );
-
-       return 0;
-}
-
-/**
- * IRQ control ioctl.
- *
- * \param inode device inode.
- * \param filp file pointer.
- * \param cmd command.
- * \param arg user argument, pointing to a drm_control structure.
- * \return zero on success or a negative number on failure.
- *
- * Calls irq_install() or irq_uninstall() according to \p arg.
- */
-int DRM(control)( struct inode *inode, struct file *filp,
-                 unsigned int cmd, unsigned long arg )
-{
-       drm_file_t *priv = filp->private_data;
-       drm_device_t *dev = priv->dev;
-       drm_control_t ctl;
-
-       if ( copy_from_user( &ctl, (drm_control_t __user *)arg, sizeof(ctl) ) )
-               return -EFAULT;
-
-       switch ( ctl.func ) {
-       case DRM_INST_HANDLER:
-               if (dev->if_version < DRM_IF_VERSION(1, 2) &&
-                   ctl.irq != dev->irq)
-                       return -EINVAL;
-               return DRM(irq_install)( dev );
-       case DRM_UNINST_HANDLER:
-               return DRM(irq_uninstall)( dev );
-       default:
-               return -EINVAL;
-       }
-}
-
-#ifdef __HAVE_VBL_IRQ
-
-/**
- * Wait for VBLANK.
- *
- * \param inode device inode.
- * \param filp file pointer.
- * \param cmd command.
- * \param data user argument, pointing to a drm_wait_vblank structure.
- * \return zero on success or a negative number on failure.
- *
- * Verifies the IRQ is installed. 
- *
- * If a signal is requested checks if this task has already scheduled the same signal
- * for the same vblank sequence number - nothing to be done in
- * that case. If the number of tasks waiting for the interrupt exceeds 100 the
- * function fails. Otherwise adds a new entry to drm_device::vbl_sigs for this
- * task.
- *
- * If a signal is not requested, then calls vblank_wait().
- */
-int DRM(wait_vblank)( DRM_IOCTL_ARGS )
-{
-       drm_file_t *priv = filp->private_data;
-       drm_device_t *dev = priv->dev;
-       drm_wait_vblank_t __user *argp = (void __user *)data;
-       drm_wait_vblank_t vblwait;
-       struct timeval now;
-       int ret = 0;
-       unsigned int flags;
-
-       if (!dev->irq)
-               return -EINVAL;
-
-       DRM_COPY_FROM_USER_IOCTL( vblwait, argp, sizeof(vblwait) );
-
-       switch ( vblwait.request.type & ~_DRM_VBLANK_FLAGS_MASK ) {
-       case _DRM_VBLANK_RELATIVE:
-               vblwait.request.sequence += atomic_read( &dev->vbl_received );
-               vblwait.request.type &= ~_DRM_VBLANK_RELATIVE;
-       case _DRM_VBLANK_ABSOLUTE:
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
-       
-       if ( flags & _DRM_VBLANK_SIGNAL ) {
-               unsigned long irqflags;
-               drm_vbl_sig_t *vbl_sig;
-               
-               vblwait.reply.sequence = atomic_read( &dev->vbl_received );
-
-               spin_lock_irqsave( &dev->vbl_lock, irqflags );
-
-               /* Check if this task has already scheduled the same signal
-                * for the same vblank sequence number; nothing to be done in
-                * that case
-                */
-               list_for_each_entry( vbl_sig, &dev->vbl_sigs.head, head ) {
-                       if (vbl_sig->sequence == vblwait.request.sequence
-                           && vbl_sig->info.si_signo == vblwait.request.signal
-                           && vbl_sig->task == current)
-                       {
-                               spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
-                               goto done;
-                       }
-               }
-
-               if ( dev->vbl_pending >= 100 ) {
-                       spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
-                       return -EBUSY;
-               }
-
-               dev->vbl_pending++;
-
-               spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
-
-               if ( !( vbl_sig = DRM_MALLOC( sizeof( drm_vbl_sig_t ) ) ) ) {
-                       return -ENOMEM;
-               }
-
-               memset( (void *)vbl_sig, 0, sizeof(*vbl_sig) );
-
-               vbl_sig->sequence = vblwait.request.sequence;
-               vbl_sig->info.si_signo = vblwait.request.signal;
-               vbl_sig->task = current;
-
-               spin_lock_irqsave( &dev->vbl_lock, irqflags );
-
-               list_add_tail( (struct list_head *) vbl_sig, &dev->vbl_sigs.head );
-
-               spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
-       } else {
-               ret = DRM(vblank_wait)( dev, &vblwait.request.sequence );
-
-               do_gettimeofday( &now );
-               vblwait.reply.tval_sec = now.tv_sec;
-               vblwait.reply.tval_usec = now.tv_usec;
-       }
-
-done:
-       DRM_COPY_TO_USER_IOCTL( argp, vblwait, sizeof(vblwait) );
-
-       return ret;
-}
-
-/**
- * Send the VBLANK signals.
- *
- * \param dev DRM device.
- *
- * Sends a signal for each task in drm_device::vbl_sigs and empties the list.
- *
- * If a signal is not requested, then calls vblank_wait().
- */
-void DRM(vbl_send_signals)( drm_device_t *dev )
-{
-       struct list_head *list, *tmp;
-       drm_vbl_sig_t *vbl_sig;
-       unsigned int vbl_seq = atomic_read( &dev->vbl_received );
-       unsigned long flags;
-
-       spin_lock_irqsave( &dev->vbl_lock, flags );
-
-       list_for_each_safe( list, tmp, &dev->vbl_sigs.head ) {
-               vbl_sig = list_entry( list, drm_vbl_sig_t, head );
-               if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) {
-                       vbl_sig->info.si_code = vbl_seq;
-                       send_sig_info( vbl_sig->info.si_signo, &vbl_sig->info, vbl_sig->task );
-
-                       list_del( list );
-
-                       DRM_FREE( vbl_sig, sizeof(*vbl_sig) );
-
-                       dev->vbl_pending--;
-               }
-       }
-
-       spin_unlock_irqrestore( &dev->vbl_lock, flags );
-}
-
-#endif /* __HAVE_VBL_IRQ */
-
-#endif /* __HAVE_IRQ */
index 42220ef..800a69f 100644 (file)
@@ -843,14 +843,11 @@ static void i810_dma_dispatch_vertex(drm_device_t *dev,
 
        if (buf_priv->currently_mapped == I810_BUF_MAPPED) {
                unsigned int prim = (sarea_priv->vertex_prim & PR_MASK);
-
-               put_user((GFX_OP_PRIMITIVE | prim |
-                                            ((used/4)-2)),
-               (u32 __user *)buf_priv->virtual);
+               
+               *(u32 *)buf_priv->kernel_virtual = ((GFX_OP_PRIMITIVE | prim | ((used/4)-2)));
 
                if (used & 4) {
-                       put_user(0,
-                       (u32 __user *)((u32)buf_priv->virtual + used));
+                       *(u32 *)((u32)buf_priv->kernel_virtual + used) = 0;
                        used += 4;
                }
 
index 856dc81..5f8b8fd 100644 (file)
@@ -1166,19 +1166,19 @@ static void i830_dma_dispatch_vertex(drm_device_t *dev,
        DRM_DEBUG(  "start + used - 4 : %ld\n", start + used - 4);
 
        if (buf_priv->currently_mapped == I830_BUF_MAPPED) {
-               u32  __user *vp = buf_priv->virtual;
+               u32  *vp = buf_priv->kernel_virtual;
 
-               put_user( (GFX_OP_PRIMITIVE |
+               vp[0] =  (GFX_OP_PRIMITIVE |
                         sarea_priv->vertex_prim |
-                         ((used/4)-2)), &vp[0]);
+                         ((used/4)-2));
 
                if (dev_priv->use_mi_batchbuffer_start) {
-                       put_user(MI_BATCH_BUFFER_END, &vp[used/4]);
+                       vp[used/4] = MI_BATCH_BUFFER_END;
                        used += 4; 
                }
                
                if (used & 4) {
-                       put_user(0, &vp[used/4]);
+                       vp[used/4] = 0;
                        used += 4;
                }
 
diff --git a/drivers/char/dz.c b/drivers/char/dz.c
deleted file mode 100644 (file)
index 2363003..0000000
+++ /dev/null
@@ -1,1540 +0,0 @@
-/*
- * dz.c: Serial port driver for DECStations equiped 
- *       with the DZ chipset.
- *
- * Copyright (C) 1998 Olivier A. D. Lebaillif 
- *             
- * Email: olivier.lebaillif@ifrsys.com
- *
- * [31-AUG-98] triemer
- * Changed IRQ to use Harald's dec internals interrupts.h
- * removed base_addr code - moving address assignment to setup.c
- * Changed name of dz_init to rs_init to be consistent with tc code
- * [13-NOV-98] triemer fixed code to receive characters
- *    after patches by harald to irq code.  
- * [09-JAN-99] triemer minor fix for schedule - due to removal of timeout
- *            field from "current" - somewhere between 2.1.121 and 2.1.131
-Qua Jun 27 15:02:26 BRT 2001
- * [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups
- *  
- * Parts (C) 1999 David Airlie, airlied@linux.ie 
- * [07-SEP-99] Bugfixes 
- */
-
-/* #define DEBUG_DZ 1 */
-
-#include <linux/module.h>
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h> 
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/major.h>
-#include <linux/param.h>
-#include <linux/interrupt.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
-#include <asm-mips/wbflush.h>
-#include <asm/dec/interrupts.h>                        /* for definition of SERIAL */
-
-/* for definition of struct console */
-#ifdef CONFIG_SERIAL_CONSOLE
-#define CONSOLE_LINE (3)
-#endif /* ifdef CONFIG_SERIAL_CONSOLE */
-#if defined(CONFIG_SERIAL_CONSOLE) || defined(DEBUG_DZ)
-#include <linux/console.h>
-#endif /* if defined(CONFIG_SERIAL_CONSOLE) || defined(DEBUG_DZ) */
-
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-
-#include <asm/uaccess.h>
-#include <asm/irq.h>
-#include <asm/dec/machtype.h>
-#include <asm/dec/kn01.h>
-#include <asm/dec/kn02.h>
-
-#ifdef DEBUG_DZ
-#include <linux/ptrace.h>
-#include <linux/fs.h>
-#include <asm/bootinfo.h>
-
-extern int (*prom_printf) (char *,...);
-#endif
-
-
-
-#include "dz.h"
-
-#define DZ_INTR_DEBUG 1
-
-DECLARE_TASK_QUEUE(tq_serial);
-
-static struct dz_serial *lines[4];
-static unsigned char tmp_buffer[256];
-
-
-
-#ifdef DEBUG_DZ
-/*
- * debugging code to send out chars via prom 
- */
-static void debug_console( const char *s,int count)
-{
-       unsigned i;
-
-       for (i = 0; i < count; i++) {
-               if (*s == 10)
-                       prom_printf("%c", 13);
-               prom_printf("%c", *s++);
-       }
-}
-#endif
-
-/*
- * ------------------------------------------------------------
- * dz_in () and dz_out ()
- *
- * These routines are used to access the registers of the DZ 
- * chip, hiding relocation differences between implementation.
- * ------------------------------------------------------------
- */
-
-static inline unsigned short dz_in (struct dz_serial *info, unsigned offset)
-{
-       volatile u16 *addr = (volatile u16 *)(info->port + offset);
-
-       return *addr;
-}
-
-static inline void dz_out (struct dz_serial *info, unsigned offset,
-                           unsigned short value)
-{
-       volatile u16 *addr = (volatile u16 *)(info->port + offset);
-       *addr = value;
-}
-
-/*
- * ------------------------------------------------------------
- * rs_stop () and rs_start ()
- *
- * These routines are called before setting or resetting 
- * tty->stopped. They enable or disable transmitter interrupts, 
- * as necessary.
- * ------------------------------------------------------------
- */
-
-static void dz_stop (struct tty_struct *tty)
-{
-       struct dz_serial *info; 
-       unsigned short mask, tmp;
-
-       if (!tty) 
-               return; 
-       info = (struct dz_serial *)tty->driver_data; 
-
-       mask = 1 << info->line;
-       tmp = dz_in (info, DZ_TCR);       /* read the TX flag */
-
-       tmp &= ~mask;                   /* clear the TX flag */
-       dz_out (info, DZ_TCR, tmp);
-}
-
-static void dz_start (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-       unsigned short mask, tmp;
-
-       mask = 1 << info->line;
-       tmp = dz_in (info, DZ_TCR);      /* read the TX flag */
-
-       tmp |= mask;                   /* set the TX flag */
-       dz_out (info, DZ_TCR, tmp);
-}
-
-/*
- * ------------------------------------------------------------
- * Here starts the interrupt handling routines.  All of the 
- * following subroutines are declared as inline and are folded 
- * into dz_interrupt.  They were separated out for readability's 
- * sake. 
- *
- * Note: rs_interrupt() is a "fast" interrupt, which means that it
- * runs with interrupts turned off.  People who may want to modify
- * rs_interrupt() should try to keep the interrupt handler as fast as
- * possible.  After you are done making modifications, it is not a bad
- * idea to do:
- * 
- * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer dz.c
- *
- * and look at the resulting assemble code in serial.s.
- *
- * ------------------------------------------------------------
- */
-
-/*
- * ------------------------------------------------------------
- * dz_sched_event ()
- *
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- * ------------------------------------------------------------
- */
-static inline void dz_sched_event (struct dz_serial *info, int event)
-{
-       info->event |= 1 << event;
-       queue_task(&info->tqueue, &tq_serial);
-       mark_bh(SERIAL_BH);
-}
-
-/*
- * ------------------------------------------------------------
- * receive_char ()
- *
- * This routine deals with inputs from any lines.
- * ------------------------------------------------------------
- */
-static inline void receive_chars (struct dz_serial *info_in)
-{
-       struct dz_serial *info;
-       struct tty_struct *tty = 0;
-       struct async_icount *icount;
-       int ignore = 0;
-       unsigned short status, tmp;
-       unsigned char ch;
-
-       /*
-        * This code is going to be a problem...  the call to tty_flip_buffer
-        * is going to need to be rethought...
-        */
-       do {
-               status = dz_in (info_in, DZ_RBUF);
-               info = lines[LINE(status)];
-
-               /* punt so we don't get duplicate characters */
-               if (!(status & DZ_DVAL))
-                       goto ignore_char;
-
-               ch = UCHAR(status);                     /* grab the char */
-
-#if 0
-               if (info->is_console) {
-                       if (ch == 0)
-                               return;                 /* it's a break ... */
-               }
-#endif
-
-               tty = info->tty;        /* now tty points to the proper dev */
-               icount = &info->icount;
-
-               if (!tty)
-                       break;
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE) break;
-
-               *tty->flip.char_buf_ptr = ch;
-               *tty->flip.flag_buf_ptr = 0;
-               icount->rx++;
-
-               /* keep track of the statistics */
-               if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) {
-                       if (status & DZ_PERR)           /* parity error */
-                               icount->parity++;
-                       else if (status & DZ_FERR)      /* frame error */
-                               icount->frame++;
-                       if (status & DZ_OERR)           /* overrun error */
-                               icount->overrun++;
-
-                       /*
-                        * Check to see if we should ignore the character and
-                        * mask off conditions that should be ignored
-                        */
-
-                       if (status & info->ignore_status_mask) {
-                               if (++ignore > 100)
-                                       break;
-                               goto ignore_char;
-                       }
-
-                       /* mask off the error conditions we want to ignore */
-                       tmp = status & info->read_status_mask;
-
-                       if (tmp & DZ_PERR) {
-                               *tty->flip.flag_buf_ptr = TTY_PARITY;
-#ifdef DEBUG_DZ
-                               debug_console("PERR\n",5);
-#endif /* DEBUG_DZ */
-                       } else if (tmp & DZ_FERR) {
-                               *tty->flip.flag_buf_ptr = TTY_FRAME;
-#ifdef DEBUG_DZ
-                               debug_console("FERR\n",5);
-#endif /* DEBUG_DZ */
-                       } if (tmp & DZ_OERR) { 
-#ifdef DEBUG_DZ
-                               debug_console("OERR\n",5);
-#endif /* DEBUG_DZ */
-                               if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-                                       tty->flip.count++;
-                                       tty->flip.flag_buf_ptr++;
-                                       tty->flip.char_buf_ptr++;
-                                       *tty->flip.flag_buf_ptr = TTY_OVERRUN;
-                               }
-                       }
-               }
-       tty->flip.flag_buf_ptr++;
-       tty->flip.char_buf_ptr++;
-       tty->flip.count++;
-ignore_char:
-       ;
-       } while (status & DZ_DVAL);
-
-       if (tty)
-               tty_flip_buffer_push(tty);
-}
-
-/*
- * ------------------------------------------------------------
- * transmit_char ()
- *
- * This routine deals with outputs to any lines.
- * ------------------------------------------------------------
- */
-static inline void transmit_chars (struct dz_serial *info)
-{
-       unsigned char tmp;
-
-       if (info->x_char) {           /* XON/XOFF chars */
-               dz_out(info, DZ_TDR, info->x_char);
-               info->icount.tx++;
-               info->x_char = 0;
-               return;
-       }
-
-       /* if nothing to do or stopped or hardware stopped */
-       if ((info->xmit_cnt <= 0) || info->tty->stopped ||
-           info->tty->hw_stopped) {
-               dz_stop(info->tty);
-               return;
-       }
-
-       /*
-        * If something to do ... (rember the dz has no output fifo so we go
-        * one char at a time :-<
-        */
-       tmp = (unsigned short) info->xmit_buf[info->xmit_tail++];
-       dz_out(info, DZ_TDR, tmp);
-       info->xmit_tail = info->xmit_tail & (DZ_XMIT_SIZE - 1);
-       info->icount.tx++;
-
-       if (--info->xmit_cnt < WAKEUP_CHARS)
-       dz_sched_event(info, DZ_EVENT_WRITE_WAKEUP);
-
-       /* Are we done */
-       if (info->xmit_cnt <= 0)
-               dz_stop(info->tty);
-}
-
-/*
- * ------------------------------------------------------------
- * check_modem_status ()
- *
- * Only valid for the MODEM line duh !
- * ------------------------------------------------------------
- */
-static inline void check_modem_status (struct dz_serial *info)
-{
-       unsigned short status;
-
-       /* if not ne modem line just return */
-       if (info->line != DZ_MODEM)
-               return;
-
-       status = dz_in(info, DZ_MSR);
-  
-       /* it's easy, since DSR2 is the only bit in the register */
-       if (status)
-               info->icount.dsr++;
-}
-
-/*
- * ------------------------------------------------------------
- * dz_interrupt ()
- *
- * this is the main interrupt routine for the DZ chip.
- * It deals with the multiple ports.
- * ------------------------------------------------------------
- */
-static void dz_interrupt (int irq, void *dev, struct pt_regs *regs)
-{
-       struct dz_serial *info;
-       unsigned short status;
-
-        /* get the reason why we just got an irq */
-       status = dz_in((struct dz_serial *)dev, DZ_CSR);
-       info = lines[LINE(status)];     /* re-arrange info the proper port */
-
-       if (status & DZ_RDONE) 
-               receive_chars(info);    /* the receive function */
-
-       if (status & DZ_TRDY) 
-               transmit_chars (info);
-}
-
-/*
- * -------------------------------------------------------------------
- * Here ends the DZ interrupt routines.
- * -------------------------------------------------------------------
- */
-
-/*
- * This routine is used to handle the "bottom half" processing for the
- * serial driver, known also the "software interrupt" processing.
- * This processing is done at the kernel interrupt level, after the
- * rs_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON.  This
- * is where time-consuming activities which can not be done in the
- * interrupt driver proper are done; the interrupt driver schedules
- * them using rs_sched_event(), and they get done here.
- */
-static void do_serial_bh (void)
-{
-       run_task_queue (&tq_serial);
-}
-
-static void do_softint (void *private_data)
-{
-       struct dz_serial *info = (struct dz_serial *) private_data;
-       struct tty_struct *tty = info->tty;
-
-       if (!tty)
-               return;
-
-       if (test_and_clear_bit(DZ_EVENT_WRITE_WAKEUP, &info->event)) {
-               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                   tty->ldisc.write_wakeup)
-                       (tty->ldisc.write_wakeup) (tty);
-               wake_up_interruptible (&tty->write_wait);
-       }
-}
-
-/*
- * -------------------------------------------------------------------
- * This routine is called from the scheduler tqueue when the interrupt
- * routine has signalled that a hangup has occurred.  The path of
- * hangup processing is:
- *
- *      serial interrupt routine -> (scheduler tqueue) ->
- *      do_serial_hangup() -> tty->hangup() -> rs_hangup()
- * ------------------------------------------------------------------- 
- */
-static void do_serial_hangup (void *private_data)
-{
-       struct dz_serial *info = (struct dz_serial *) private_data;
-       struct tty_struct *tty = info->tty;
-        
-       if (!tty)
-               return;
-
-       tty_hangup(tty);
-}
-
-/*
- * -------------------------------------------------------------------
- * startup ()
- *
- * various initialization tasks
- * ------------------------------------------------------------------- 
- */
-static int startup (struct dz_serial *info)
-{
-       unsigned long page, flags;
-       unsigned short tmp;
-
-       if (info->is_initialized)
-               return 0;
-  
-       save_and_cli(flags);
-
-       if (!info->port) {
-               if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
-               restore_flags(flags);
-               return -ENODEV;
-       }
-
-       if (!info->xmit_buf) {
-               page = get_zeroed_page(GFP_KERNEL);
-               if (!page) {
-                       restore_flags (flags);
-               return -ENOMEM;
-               }
-               info->xmit_buf = (unsigned char *)page;
-       }
-
-       if (info->tty)
-               clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
-       /* enable the interrupt and the scanning */
-       tmp = dz_in(info, DZ_CSR);
-       tmp |= (DZ_RIE | DZ_TIE | DZ_MSE);
-       dz_out(info, DZ_CSR, tmp);
-
-       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-
-       change_speed(info);                     /* set up the speed */
-
-       /*
-        * Clear the line transmitter buffer I can't figure out why I need to
-        * do this - but its necessary - in order for the console portion and
-        * the interrupt portion to live happily side by side.
-        */
-
-       info->is_initialized = 1;
-
-       restore_flags(flags);
-
-       return 0;
-}
-
-/* 
- * -------------------------------------------------------------------
- * shutdown ()
- *
- * This routine will shutdown a serial port; interrupts are disabled, and
- * DTR is dropped if the hangup on close termio flag is on.
- * ------------------------------------------------------------------- 
- */
-static void shutdown (struct dz_serial *info)
-{
-       unsigned long flags;
-       unsigned short tmp;
-
-       if (!info->is_initialized)
-               return;
-
-       save_and_cli(flags);
-
-       dz_stop (info->tty);
-
-       info->cflags &= ~DZ_CREAD;      /* turn off receive enable flag */
-       dz_out(info, DZ_LPR, info->cflags);
-
-       if (info->xmit_buf) {               /* free Tx buffer */
-               free_page((unsigned long)info->xmit_buf);
-               info->xmit_buf = 0;
-       }
-
-       if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
-               tmp = dz_in(info, DZ_TCR);
-               if (tmp & DZ_MODEM_DTR) {
-                       tmp &= ~DZ_MODEM_DTR;
-                       dz_out(info, DZ_TCR, tmp);
-               }
-       }
-
-       if (info->tty)
-               set_bit (TTY_IO_ERROR, &info->tty->flags);
-
-       info->is_initialized = 0;
-
-       restore_flags (flags);
-}
-
-/* 
- * -------------------------------------------------------------------
- * change_speed ()
- *
- * set the baud rate.
- * ------------------------------------------------------------------- 
- */
-static void change_speed (struct dz_serial *info)
-{
-       unsigned long flags;
-       unsigned cflag;
-       int baud;
-
-       if (!info->tty || !info->tty->termios)
-               return;
-  
-       save_and_cli(flags);
-  
-       info->cflags = info->line;
-
-       cflag = info->tty->termios->c_cflag;
-
-       switch (cflag & CSIZE) {
-               case CS5:
-                       info->cflags |= DZ_CS5;
-                       break;
-               case CS6:
-                       info->cflags |= DZ_CS6;
-                       break;
-               case CS7:
-                       info->cflags |= DZ_CS7;
-                       break;
-               case CS8: 
-               default:
-                       info->cflags |= DZ_CS8;
-       }
-
-       if (cflag & CSTOPB)
-               info->cflags |= DZ_CSTOPB;
-       if (cflag & PARENB)
-               info->cflags |= DZ_PARENB;
-       if (cflag & PARODD)
-               info->cflags |= DZ_PARODD;
-  
-       baud = tty_get_baud_rate(info->tty);
-       switch (baud) {
-       case 50:
-               info->cflags |= DZ_B50;
-               break;
-       case 75:
-               info->cflags |= DZ_B75;
-               break;
-       case 110:
-               info->cflags |= DZ_B110;
-               break;
-       case 134:
-               info->cflags |= DZ_B134;
-               break; 
-       case 150:
-               info->cflags |= DZ_B150;
-               break;
-       case 300:
-               info->cflags |= DZ_B300;
-               break; 
-       case 600:
-               info->cflags |= DZ_B600;
-               break;
-       case 1200:
-               info->cflags |= DZ_B1200;
-               break; 
-       case 1800:
-               info->cflags |= DZ_B1800;
-               break;
-       case 2000:
-               info->cflags |= DZ_B2000;
-               break;
-       case 2400:
-               info->cflags |= DZ_B2400;
-               break;
-       case 3600:
-               info->cflags |= DZ_B3600;
-               break; 
-       case 4800:
-               info->cflags |= DZ_B4800;
-               break;
-       case 7200:
-               info->cflags |= DZ_B7200;
-               break; 
-       case 9600: 
-       default:
-               info->cflags |= DZ_B9600; 
-       }
-
-       info->cflags |= DZ_RXENAB;
-       dz_out(info, DZ_LPR, info->cflags);
-
-       /* setup accept flag */
-       info->read_status_mask = DZ_OERR;
-       if (I_INPCK(info->tty))
-               info->read_status_mask |= (DZ_FERR | DZ_PERR); 
-  
-       /* characters to ignore */
-       info->ignore_status_mask = 0;
-       if (I_IGNPAR(info->tty))
-               info->ignore_status_mask |= (DZ_FERR | DZ_PERR);
-
-       restore_flags(flags);
-}
-
-/* 
- * -------------------------------------------------------------------
- * dz_flush_char ()
- *
- * Flush the buffer.
- * ------------------------------------------------------------------- 
- */
-static void dz_flush_chars (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-       unsigned long flags;
-
-       if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
-           !info->xmit_buf)
-               return;
-
-       save_and_cli(flags);
-       dz_start (info->tty);
-       restore_flags(flags);
-}
-
-
-/* 
- * -------------------------------------------------------------------
- * dz_write ()
- *
- * main output routine.
- * ------------------------------------------------------------------- 
- */
-static int dz_write (struct tty_struct *tty, int from_user,
-                     const unsigned char *buf, int count)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-       unsigned long flags;
-       int c, ret = 0;
-
-       if (!tty )
-               return ret;
-       if (!info->xmit_buf)
-               return ret;
-       if (!tmp_buf)
-               tmp_buf = tmp_buffer;
-
-       if (from_user) {
-               down (&tmp_buf_sem);
-               while (1) {
-                       c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
-                                          DZ_XMIT_SIZE - info->xmit_head));
-                       if (c <= 0)
-                               break;
-
-                       c -= copy_from_user (tmp_buf, buf, c);
-                       if (!c) {
-                               if (!ret)
-                                       ret = -EFAULT;
-                               break;
-                       }
-
-                       save_and_cli(flags);
-
-                       c = MIN(c, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
-                                      DZ_XMIT_SIZE - info->xmit_head));
-                       memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-                       info->xmit_head = ((info->xmit_head + c) &
-                                          (DZ_XMIT_SIZE - 1));
-                       info->xmit_cnt += c;
-                       restore_flags(flags);
-
-                       buf += c;
-                       count -= c;
-                       ret += c;
-               }
-               up(&tmp_buf_sem);
-       } else {
-               while (1) {
-                       save_and_cli(flags);
-
-                       c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
-                                          DZ_XMIT_SIZE - info->xmit_head));
-                       if (c <= 0) {
-                               restore_flags (flags);
-                               break;
-                       }
-                       memcpy(info->xmit_buf + info->xmit_head, buf, c);
-                       info->xmit_head = ((info->xmit_head + c) &
-                                          (DZ_XMIT_SIZE-1));
-                       info->xmit_cnt += c;
-                       restore_flags(flags);
-
-                       buf += c;
-                       count -= c;
-                       ret += c;
-               }
-       }
-
-       if (info->xmit_cnt) {
-               if (!tty->stopped) {
-                       if (!tty->hw_stopped) {
-                               dz_start (info->tty);
-                       }
-               }
-       }
-
-       return ret;
-}
-
-/* 
- * -------------------------------------------------------------------
- * dz_write_room ()
- *
- * compute the amount of space available for writing.
- * ------------------------------------------------------------------- 
- */
-static int dz_write_room (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-       int ret;
-
-       ret = DZ_XMIT_SIZE - info->xmit_cnt - 1;
-       if (ret < 0)
-               ret = 0;
-
-       return ret;
-}
-
-/* 
- * -------------------------------------------------------------------
- * dz_chars_in_buffer ()
- *
- * compute the amount of char left to be transmitted
- * ------------------------------------------------------------------- 
- */
-static int dz_chars_in_buffer (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-  
-       return info->xmit_cnt;
-}
-
-/* 
- * -------------------------------------------------------------------
- * dz_flush_buffer ()
- *
- * Empty the output buffer
- * ------------------------------------------------------------------- 
- */
-static void dz_flush_buffer (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-                                
-       cli();
-       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-       sti();
-
-       wake_up_interruptible (&tty->write_wait);
-
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-            tty->ldisc.write_wakeup)
-               tty->ldisc.write_wakeup(tty);
-}
-
-/*
- * ------------------------------------------------------------
- * dz_throttle () and dz_unthrottle ()
- * 
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled (or not).
- * ------------------------------------------------------------
- */
-static void dz_throttle (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;  
-
-       if (I_IXOFF(tty))
-               info->x_char = STOP_CHAR(tty);
-}
-
-static void dz_unthrottle (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;  
-
-       if (I_IXOFF(tty)) {
-               if (info->x_char)
-                       info->x_char = 0;
-               else
-                       info->x_char = START_CHAR(tty);
-       }
-}
-
-static void dz_send_xchar (struct tty_struct *tty, char ch)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
-       info->x_char = ch;
-
-       if (ch)
-               dz_start(info->tty);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl () and friends
- * ------------------------------------------------------------
- */
-static int get_serial_info(struct dz_serial *info,
-                           struct serial_struct *retinfo)
-{
-       struct serial_struct tmp;
-  
-       if (!retinfo)
-               return -EFAULT;
-
-       memset (&tmp, 0, sizeof(tmp));
-
-       tmp.type = info->type;
-       tmp.line = info->line;
-       tmp.port = info->port;
-       tmp.irq = SERIAL;
-       tmp.flags = info->flags;
-       tmp.baud_base = info->baud_base;
-       tmp.close_delay = info->close_delay;
-       tmp.closing_wait = info->closing_wait;
-
-       return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
-}
-
-static int set_serial_info (struct dz_serial *info,
-                            struct serial_struct *new_info)
-{
-       struct serial_struct new_serial;
-       struct dz_serial old_info;
-       int retval = 0;
-
-       if (!new_info)
-               return -EFAULT;
-
-       if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
-               return -EFAULT;
-
-       old_info = *info;
-
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
-
-       if (info->count > 1)
-               return -EBUSY;
-
-       /*
-        * OK, past this point, all the error checking has been done.
-        * At this point, we start making changes.....
-        */
-
-       info->baud_base = new_serial.baud_base;
-       info->type = new_serial.type;
-       info->close_delay = new_serial.close_delay;
-       info->closing_wait = new_serial.closing_wait;
-
-       retval = startup(info);
-
-       return retval;
-}
-
-/*
- * get_lsr_info - get line status register info
- *
- * Purpose: Let user call ioctl() to get info when the UART physically
- *          is emptied.  On bus types like RS485, the transmitter must
- *          release the bus after transmitting. This must be done when
- *          the transmit shift register is empty, not be done when the
- *          transmit holding register is empty.  This functionality
- *          allows an RS485 driver to be written in user space. 
- */
-static int get_lsr_info (struct dz_serial *info, unsigned int *value)
-{
-       unsigned short status = dz_in (info, DZ_LPR);
-
-       return put_user (status, value);
-}
-
-/*
- * This routine sends a break character out the serial port.
- */
-static void send_break (struct dz_serial *info, int duration)
-{
-       unsigned long flags;
-       unsigned short tmp, mask;
-
-       if (!info->port)
-               return;
-
-       mask = 1 << info->line;
-       tmp = dz_in (info, DZ_TCR);
-       tmp |= mask;
-
-       current->state = TASK_INTERRUPTIBLE;
-
-       save_and_cli(flags);
-       dz_out(info, DZ_TCR, tmp);
-       schedule_timeout(duration);
-       tmp &= ~mask;
-       dz_out(info, DZ_TCR, tmp);
-       restore_flags(flags);
-}
-
-static int dz_ioctl(struct tty_struct *tty, struct file *file,
-                    unsigned int cmd, unsigned long arg)
-{
-       int error;
-       struct dz_serial * info = (struct dz_serial *)tty->driver_data;
-       int retval;
-
-       if (cmd != TIOCGSERIAL && cmd != TIOCSSERIAL &&
-           cmd != TIOCSERCONFIG && cmd != TIOCSERGWILD  &&
-           cmd != TIOCSERSWILD && cmd != TIOCSERGSTRUCT) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
-                       return -EIO;
-       }
-
-       switch (cmd) {
-       case TCSBRK:            /* SVID version: non-zero arg --> no break */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               if (!arg)
-                       send_break(info, HZ/4); /* 1/4 second */
-               return 0;
-
-       case TCSBRKP:           /* support for POSIX tcsendbreak() */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               send_break(info, arg ? arg*(HZ/10) : HZ/4);
-               return 0;
-
-       case TIOCGSOFTCAR:
-               return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
-
-       case TIOCSSOFTCAR:
-               if (get_user (arg, (unsigned long *)arg))
-                       return -EFAULT;
-
-               tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) |
-                                       (arg ? CLOCAL : 0);
-               return 0;
-
-       case TIOCGSERIAL:
-               return get_serial_info(info, (struct serial_struct *)arg);
-
-       case TIOCSSERIAL:
-               return set_serial_info(info, (struct serial_struct *) arg);
-
-       case TIOCSERGETLSR:             /* Get line status register */
-               return get_lsr_info (info, (unsigned int *)arg);
-
-       case TIOCSERGSTRUCT:
-               return copy_to_user((struct dz_serial *)arg, info,
-                                   sizeof(struct dz_serial)) ? -EFAULT : 0;
-       default:
-               return -ENOIOCTLCMD;
-       }
-
-       return 0;
-}
-
-static void dz_set_termios (struct tty_struct *tty,
-                           struct termios *old_termios)
-{
-       struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
-       if (tty->termios->c_cflag == old_termios->c_cflag)
-               return;
-
-       change_speed (info);
-
-       if ((old_termios->c_cflag & CRTSCTS) &&
-           !(tty->termios->c_cflag & CRTSCTS)) {
-               tty->hw_stopped = 0;
-               dz_start(tty);
-       }
-}
-
-/*
- * ------------------------------------------------------------
- * dz_close()
- * 
- * This routine is called when the serial port gets closed.  First, we
- * wait for the last remaining data to be sent.  Then, we turn off
- * the transmit enable and receive enable flags.
- * ------------------------------------------------------------
- */
-static void dz_close(struct tty_struct *tty, struct file *filp)
-{
-       struct dz_serial * info = (struct dz_serial *)tty->driver_data;
-       unsigned long flags;
-
-       if (!info)
-               return;
-       save_and_cli(flags); 
-
-       if (tty_hung_up_p(filp)) {
-               restore_flags(flags);
-               return;
-       }
-
-       if ((tty->count == 1) && (info->count != 1)) {
-               /*
-                * Uh, oh.  tty->count is 1, which means that the tty structure
-                * will be freed.  Info->count should always be one in these
-                * conditions.  If it's greater than one, we've got real
-                * problems, since it means the serial port won't be shutdown.
-                */
-               printk("dz_close: bad serial port count; tty->count is 1, "
-                      "info->count is %d\n", info->count);
-               info->count = 1;
-       }
-
-       if (--info->count < 0) {
-               printk("ds_close: bad serial port count for ttyS%02d: %d\n",
-                      info->line, info->count);
-               info->count = 0;
-       }
-
-       if (info->count) {
-               restore_flags(flags);
-               return;
-       }
-       info->flags |= DZ_CLOSING;
-       /*
-        * Now we wait for the transmit buffer to clear; and we notify the line
-        * discipline to only process XON/XOFF characters.
-        */
-       tty->closing = 1;
-
-       if (info->closing_wait != DZ_CLOSING_WAIT_NONE)
-               tty_wait_until_sent(tty, info->closing_wait);
-
-       /*
-        * At this point we stop accepting input.  To do this, we disable the
-        * receive line status interrupts.
-        */
-       shutdown(info);
-
-       if (tty->driver->flush_buffer)
-               tty->driver->flush_buffer (tty);
-       if (tty->ldisc.flush_buffer)
-               tty->ldisc.flush_buffer (tty);
-       tty->closing = 0;
-       info->event = 0;
-       info->tty = 0;
-
-       if (tty->ldisc.num != ldiscs[N_TTY].num) {
-               if (tty->ldisc.close)
-                       tty->ldisc.close(tty);
-               tty->ldisc = ldiscs[N_TTY];
-               tty->termios->c_line = N_TTY;
-               if (tty->ldisc.open)
-                       tty->ldisc.open(tty);
-       }
-       if (info->blocked_open) {
-               if (info->close_delay) {
-                       current->state = TASK_INTERRUPTIBLE;
-                       schedule_timeout(info->close_delay);
-               }
-               wake_up_interruptible(&info->open_wait);
-       }
-
-       info->flags &= ~(DZ_NORMAL_ACTIVE | DZ_CLOSING);
-       wake_up_interruptible(&info->close_wait);
-
-       restore_flags(flags);
-}
-
-/*
- * dz_hangup () --- called by tty_hangup() when a hangup is signaled.
- */
-static void dz_hangup (struct tty_struct *tty)
-{
-       struct dz_serial *info = (struct dz_serial *) tty->driver_data;
-  
-       dz_flush_buffer(tty);
-       shutdown(info);
-       info->event = 0;
-       info->count = 0;
-       info->flags &= ~DZ_NORMAL_ACTIVE;
-       info->tty = 0;
-       wake_up_interruptible(&info->open_wait);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_open() and friends
- * ------------------------------------------------------------
- */
-static int block_til_ready(struct tty_struct *tty, struct file *filp,
-                           struct dz_serial *info)
-{
-       DECLARE_WAITQUEUE(wait, current); 
-       int retval;
-       int do_clocal = 0;
-
-       /*
-        * If the device is in the middle of being closed, then block
-        * until it's done, and then try again.
-        */
-       if (info->flags & DZ_CLOSING) {
-               interruptible_sleep_on(&info->close_wait);
-               return -EAGAIN;
-       }
-
-       /*
-        * If non-blocking mode is set, or the port is not enabled, then make
-        * the check up front and then exit.
-        */
-       if ((filp->f_flags & O_NONBLOCK) ||
-           (tty->flags & (1 << TTY_IO_ERROR))) {
-               info->flags |= DZ_NORMAL_ACTIVE;
-
-               return 0;
-       }
-
-       if (tty->termios->c_cflag & CLOCAL)
-               do_clocal = 1;
-
-       /*
-        * Block waiting for the carrier detect and the line to become free
-        * (i.e., not in use by the callout).  While we are in this loop,
-        * info->count is dropped by one, so that dz_close() knows when to free
-        * things.  We restore it upon exit, either normal or abnormal.
-        */
-       retval = 0;
-       add_wait_queue(&info->open_wait, &wait);
-
-       info->count--;
-       info->blocked_open++;
-       while (1) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               if (tty_hung_up_p (filp) || !(info->is_initialized)) {
-                       retval = -EAGAIN;
-                       break;
-               }
-               if (!(info->flags & DZ_CLOSING) && do_clocal)
-                       break;
-               if (signal_pending(current)) {
-                       retval = -ERESTARTSYS;
-                       break;
-               }
-               schedule();
-       }
-               
-       current->state = TASK_RUNNING;
-       remove_wait_queue (&info->open_wait, &wait);
-       if (!tty_hung_up_p(filp))
-               info->count++;
-       info->blocked_open--;
-
-       if (retval)
-               return retval;
-       info->flags |= DZ_NORMAL_ACTIVE;
-       return 0;
-}
-
-/*
- * This routine is called whenever a serial port is opened.  It
- * enables interrupts for a serial port. It also performs the 
- * serial-specific initialization for the tty structure.
- */
-static int dz_open (struct tty_struct *tty, struct file *filp)
-{
-       struct dz_serial *info;
-       int retval, line;
-
-       line = tty->index;
-
-       /*
-        * The dz lines for the mouse/keyboard must be opened using their
-        * respective drivers.
-        */
-       if ((line < 0) || (line >= DZ_NB_PORT))
-               return -ENODEV;
-
-       if ((line == DZ_KEYBOARD) || (line == DZ_MOUSE))
-               return -ENODEV;
-
-       info = lines[line];
-       info->count++;
-
-       tty->driver_data = info;
-       info->tty = tty;
-
-       /*
-        * Start up serial port
-        */
-       retval = startup (info);
-       if (retval)
-               return retval;
-
-       retval = block_til_ready (tty, filp, info);
-       if (retval)
-               return retval;
-
-       return 0;
-}
-
-static void show_serial_version (void)
-{
-       printk("%s%s\n", dz_name, dz_version);
-}
-
-static struct tty_driver *serial_driver;
-
-static struct tty_operations serial_ops = {
-       .open = dz_open,
-       .close = dz_close,
-       .write = dz_write,
-       .flush_chars = dz_flush_chars,
-       .write_room = dz_write_room,
-       .chars_in_buffer = dz_chars_in_buffer,
-       .flush_buffer = dz_flush_buffer,
-       .ioctl = dz_ioctl,
-       .throttle = dz_throttle,
-       .unthrottle = dz_unthrottle,
-       .send_xchar = dz_send_xchar,
-       .set_termios = dz_set_termios,
-       .stop = dz_stop,
-       .start = dz_start,
-       .hangup = dz_hangup,
-};
-
-int __init dz_init(void)
-{
-       int i, flags;
-       struct dz_serial *info;
-
-       serial_driver = alloc_tty_driver(DZ_NB_PORT);
-       if (!serial_driver)
-               return -ENOMEM;
-
-       /* Setup base handler, and timer table. */
-       init_bh(SERIAL_BH, do_serial_bh);
-
-       show_serial_version();
-
-       serial_driver->owner = THIS_MODULE;
-       serial_driver->devfs_name = "tts/";
-       serial_driver->name = "ttyS";
-       serial_driver->major = TTY_MAJOR;
-       serial_driver->minor_start = 64;
-       serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
-       serial_driver->subtype = SERIAL_TYPE_NORMAL;
-       serial_driver->init_termios = tty_std_termios;
-       serial_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL |
-                                            CLOCAL;
-       serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
-       tty_set_operations(serial_driver, &serial_ops);
-
-       if (tty_register_driver(serial_driver))
-               panic("Couldn't register serial driver\n");
-
-       save_flags(flags); cli();
-       for (i=0; i < DZ_NB_PORT;  i++) {
-               info = &multi[i]; 
-               lines[i] = info;
-               info->magic = SERIAL_MAGIC;
-
-               if ((mips_machtype == MACH_DS23100) ||
-                   (mips_machtype == MACH_DS5100)) 
-                       info->port = (unsigned long) KN01_DZ11_BASE;
-               else 
-                       info->port = (unsigned long) KN02_DZ11_BASE;
-
-               info->line = i;
-               info->tty = 0;
-               info->close_delay = 50;
-               info->closing_wait = 3000;
-               info->x_char = 0;
-               info->event = 0;
-               info->count = 0;
-               info->blocked_open = 0;
-               info->tqueue.routine = do_softint;
-               info->tqueue.data = info;
-               info->tqueue_hangup.routine = do_serial_hangup;
-               info->tqueue_hangup.data = info;
-               init_waitqueue_head(&info->open_wait); 
-               init_waitqueue_head(&info->close_wait); 
-
-               /*
-                * If we are pointing to address zero then punt - not correctly
-                * set up in setup.c to handle this.
-                */
-               if (! info->port)
-                       return 0;
-
-               printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line,
-                      info->port, SERIAL);
-
-               tty_register_device(serial_driver, info->line, NULL);
-       }
-
-       /* Reset the chip */
-#ifndef CONFIG_SERIAL_CONSOLE
-       {
-               int tmp;
-               dz_out(info, DZ_CSR, DZ_CLR);
-               while ((tmp = dz_in(info,DZ_CSR)) & DZ_CLR);
-               wbflush();
-  
-               /* Enable scanning */
-               dz_out(info, DZ_CSR, DZ_MSE); 
-       }
-#endif
-  
-       /*
-        * Order matters here... the trick is that flags is updated... in
-        * request_irq - to immediatedly obliterate it is unwise.
-        */
-       restore_flags(flags);
-
-       if (request_irq(SERIAL, dz_interrupt, SA_INTERRUPT, "DZ", lines[0]))
-               panic("Unable to register DZ interrupt\n");
-       return 0;
-}
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static void dz_console_put_char (unsigned char ch)
-{
-       unsigned long flags;
-       int  loops = 2500;
-       unsigned short tmp = ch;
-       /*
-        * this code sends stuff out to serial device - spinning its wheels and
-        * waiting.
-        */
-
-       /* force the issue - point it at lines[3]*/
-       dz_console = &multi[CONSOLE_LINE];
-
-       save_and_cli(flags);
-
-       /* spin our wheels */
-       while (((dz_in(dz_console, DZ_CSR) & DZ_TRDY) != DZ_TRDY) &&  loops--)
-               ;
-  
-       /* Actually transmit the character. */
-       dz_out(dz_console, DZ_TDR, tmp);
-
-       restore_flags(flags); 
-}
-
-/* 
- * -------------------------------------------------------------------
- * dz_console_print ()
- *
- * dz_console_print is registered for printk.
- * The console must be locked when we get here.
- * ------------------------------------------------------------------- 
- */
-static void dz_console_print (struct console *cons, 
-                             const char *str, 
-                             unsigned int count)
-{
-#ifdef DEBUG_DZ
-       prom_printf((char *)str);
-#endif
-       while (count--) {
-               if (*str == '\n')
-                       dz_console_put_char('\r');
-               dz_console_put_char(*str++);
-       }
-}
-
-static struct tty_driver *dz_console_device(struct console *c, int *index)
-{
-       *index = c->index;
-       return serial_driver;
-}
-
-static int __init dz_console_setup(struct console *co, char *options)
-{
-       int baud = 9600;
-       int bits = 8;
-       int parity = 'n';
-       int cflag = CREAD | HUPCL | CLOCAL;
-       char *s;
-       unsigned short mask,tmp;
-
-       if (options) {
-               baud = simple_strtoul(options, NULL, 10);
-               s = options;
-               while (*s >= '0' && *s <= '9')
-                       s++;
-               if (*s)
-                       parity = *s++;
-               if (*s)
-                       bits   = *s - '0';
-       }
-
-       /*
-        * Now construct a cflag setting.
-        */
-       switch (baud) {
-       case 1200:
-               cflag |= DZ_B1200;
-               break;
-       case 2400:
-               cflag |= DZ_B2400;
-               break;
-       case 4800:
-               cflag |= DZ_B4800;
-               break;
-       case 9600:
-       default:
-               cflag |= DZ_B9600;
-               break;
-       }
-       switch (bits) {
-       case 7:
-               cflag |= DZ_CS7;
-               break;
-       default:
-       case 8:
-               cflag |= DZ_CS8;
-               break;
-       }
-       switch (parity) {
-       case 'o':
-       case 'O':
-               cflag |= DZ_PARODD;
-               break;
-       case 'e':
-       case 'E':
-               cflag |= DZ_PARENB;
-               break;
-       }
-       co->cflag = cflag;
-
-       /* TOFIX: force to console line */
-       dz_console = &multi[CONSOLE_LINE];
-       if ((mips_machtype == MACH_DS23100) || (mips_machtype == MACH_DS5100)) 
-               dz_console->port = KN01_DZ11_BASE;
-       else 
-               dz_console->port = KN02_DZ11_BASE; 
-       dz_console->line = CONSOLE_LINE;
-
-       dz_out(dz_console, DZ_CSR, DZ_CLR);
-       while ((tmp = dz_in(dz_console,DZ_CSR)) & DZ_CLR)
-               ;
-
-       /* enable scanning */
-       dz_out(dz_console, DZ_CSR, DZ_MSE); 
-
-       /*  Set up flags... */
-       dz_console->cflags = 0;
-       dz_console->cflags |= DZ_B9600;
-       dz_console->cflags |= DZ_CS8;
-       dz_console->cflags |= DZ_PARENB;
-       dz_out(dz_console, DZ_LPR, dz_console->cflags);
-
-       mask = 1 << dz_console->line;
-       tmp = dz_in (dz_console, DZ_TCR);               /* read the TX flag */
-       if (!(tmp & mask)) {
-               tmp |= mask;                            /* set the TX flag */
-               dz_out (dz_console, DZ_TCR, tmp); 
-       }
-
-       return 0;
-}
-
-static struct console dz_sercons = {
-    .name      = "ttyS",
-    .write     = dz_console_print,
-    .device    = dz_console_device,
-    .setup     = dz_console_setup,
-    .flags     = CON_CONSDEV | CON_PRINTBUFFER,
-    .index     = CONSOLE_LINE,
-};
-
-void __init dz_serial_console_init(void)
-{
-       register_console(&dz_sercons);
-}
-
-#endif /* ifdef CONFIG_SERIAL_CONSOLE */
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/char/dz.h b/drivers/char/dz.h
deleted file mode 100644 (file)
index 989f927..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * dz.h: Serial port driver for DECStations equiped 
- *       with the DZ chipset.
- *
- * Copyright (C) 1998 Olivier A. D. Lebaillif 
- *             
- * Email: olivier.lebaillif@ifrsys.com
- *
- */
-#ifndef DZ_SERIAL_H
-#define DZ_SERIAL_H
-
-/*
- * Definitions for the Control and Status Received.
- */
-#define DZ_TRDY        0x8000                 /* Transmitter empty */
-#define DZ_TIE         0x4000                 /* Transmitter Interrupt Enable */
-#define DZ_RDONE       0x0080                 /* Receiver data ready */
-#define DZ_RIE         0x0040                 /* Receive Interrupt Enable */
-#define DZ_MSE         0x0020                 /* Master Scan Enable */
-#define DZ_CLR         0x0010                 /* Master reset */
-#define DZ_MAINT       0x0008                 /* Loop Back Mode */
-
-/*
- * Definitions for the Received buffer. 
- */
-#define DZ_RBUF_MASK   0x00FF                 /* Data Mask in the Receive Buffer */
-#define DZ_LINE_MASK   0x0300                 /* Line Mask in the Receive Buffer */
-#define DZ_DVAL        0x8000                 /* Valid Data indicator */
-#define DZ_OERR        0x4000                 /* Overrun error indicator */
-#define DZ_FERR        0x2000                 /* Frame error indicator */
-#define DZ_PERR        0x1000                 /* Parity error indicator */
-
-#define LINE(x) (x & DZ_LINE_MASK) >> 8       /* Get the line number from the input buffer */
-#define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK)
-
-/*
- * Definitions for the Transmit Register.
- */
-#define DZ_LINE_KEYBOARD 0x0001
-#define DZ_LINE_MOUSE    0x0002
-#define DZ_LINE_MODEM    0x0004
-#define DZ_LINE_PRINTER  0x0008
-
-#define DZ_MODEM_DTR     0x0400               /* DTR for the modem line (2) */
-
-/*
- * Definitions for the Modem Status Register.
- */
-#define DZ_MODEM_DSR     0x0200               /* DSR for the modem line (2) */
-
-/*
- * Definitions for the Transmit Data Register.
- */
-#define DZ_BRK0          0x0100               /* Break assertion for line 0 */
-#define DZ_BRK1          0x0200               /* Break assertion for line 1 */
-#define DZ_BRK2          0x0400               /* Break assertion for line 2 */
-#define DZ_BRK3          0x0800               /* Break assertion for line 3 */
-
-/*
- * Definitions for the Line Parameter Register.
- */
-#define DZ_KEYBOARD      0x0000               /* line 0 = keyboard */
-#define DZ_MOUSE         0x0001               /* line 1 = mouse */
-#define DZ_MODEM         0x0002               /* line 2 = modem */
-#define DZ_PRINTER       0x0003               /* line 3 = printer */
-
-#define DZ_CSIZE         0x0018               /* Number of bits per byte (mask) */
-#define DZ_CS5           0x0000               /* 5 bits per byte */
-#define DZ_CS6           0x0008               /* 6 bits per byte */
-#define DZ_CS7           0x0010               /* 7 bits per byte */
-#define DZ_CS8           0x0018               /* 8 bits per byte */
-
-#define DZ_CSTOPB        0x0020               /* 2 stop bits instead of one */ 
-
-#define DZ_PARENB        0x0040               /* Parity enable */
-#define DZ_PARODD        0x0080               /* Odd parity instead of even */
-
-#define DZ_CBAUD         0x0E00               /* Baud Rate (mask) */
-#define DZ_B50           0x0000
-#define DZ_B75           0x0100
-#define DZ_B110          0x0200
-#define DZ_B134          0x0300
-#define DZ_B150          0x0400
-#define DZ_B300          0x0500
-#define DZ_B600          0x0600
-#define DZ_B1200         0x0700 
-#define DZ_B1800         0x0800
-#define DZ_B2000         0x0900
-#define DZ_B2400         0x0A00
-#define DZ_B3600         0x0B00
-#define DZ_B4800         0x0C00
-#define DZ_B7200         0x0D00
-#define DZ_B9600         0x0E00
-
-#define DZ_CREAD         0x1000               /* Enable receiver */
-#define DZ_RXENAB        0x1000               /* enable receive char */
-/*
- * Addresses for the DZ registers
- */
-#define DZ_CSR       0x00            /* Control and Status Register */
-#define DZ_RBUF      0x08            /* Receive Buffer */
-#define DZ_LPR       0x08            /* Line Parameters Register */
-#define DZ_TCR       0x10            /* Transmitter Control Register */
-#define DZ_MSR       0x18            /* Modem Status Register */
-#define DZ_TDR       0x18            /* Transmit Data Register */
-
-
-#define DZ_NB_PORT 4
-
-#define DZ_XMIT_SIZE   4096                 /* buffer size */
-#define WAKEUP_CHARS   DZ_XMIT_SIZE/4
-
-#define DZ_EVENT_WRITE_WAKEUP   0
-
-#ifndef MIN
-#define MIN(a,b)        ((a) < (b) ? (a) : (b))
-
-#define DZ_INITIALIZED       0x80000000 /* Serial port was initialized */
-#define DZ_CALLOUT_ACTIVE    0x40000000 /* Call out device is active */
-#define DZ_NORMAL_ACTIVE     0x20000000 /* Normal device is active */
-#define DZ_BOOT_AUTOCONF     0x10000000 /* Autoconfigure port on bootup */
-#define DZ_CLOSING           0x08000000 /* Serial port is closing */
-#define DZ_CTS_FLOW          0x04000000 /* Do CTS flow control */
-#define DZ_CHECK_CD          0x02000000 /* i.e., CLOCAL */
-
-#define DZ_CLOSING_WAIT_INF  0
-#define DZ_CLOSING_WAIT_NONE 65535
-
-#define DZ_SPLIT_TERMIOS   0x0008 /* Separate termios for dialin/callout */
-#define DZ_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */
-#define DZ_PGRP_LOCKOUT    0x0200 /* Lock out cua opens based on pgrp */
-
-struct dz_serial {
-  unsigned                port;                /* base address for the port */
-  int                     type;
-  int                     flags; 
-  int                     baud_base;
-  int                     blocked_open;
-  unsigned short          close_delay;
-  unsigned short          closing_wait;
-  unsigned short          line;                /* port/line number */
-  unsigned short          cflags;              /* line configuration flag */
-  unsigned short          x_char;              /* xon/xoff character */
-  unsigned short          read_status_mask;    /* mask for read condition */
-  unsigned short          ignore_status_mask;  /* mask for ignore condition */
-  unsigned long           event;               /* mask used in BH */
-  unsigned char           *xmit_buf;           /* Transmit buffer */
-  int                     xmit_head;           /* Position of the head */
-  int                     xmit_tail;           /* Position of the tail */
-  int                     xmit_cnt;            /* Count of the chars in the buffer */
-  int                     count;               /* indicates how many times it has been opened */
-  int                     magic;
-
-  struct async_icount     icount;              /* keep track of things ... */
-  struct tty_struct       *tty;                /* tty associated */
-  struct tq_struct        tqueue;              /* Queue for BH */
-  struct tq_struct        tqueue_hangup;
-  wait_queue_head_t       open_wait;
-  wait_queue_head_t       close_wait;
-
-  unsigned char           is_console;          /* flag indicating a serial console */
-  unsigned char           is_initialized;
-};
-
-static struct dz_serial multi[DZ_NB_PORT];    /* Four serial lines in the DZ chip */
-static struct dz_serial *dz_console;
-
-/*
- * tmp_buf is used as a temporary buffer by serial_write.  We need to
- * lock it in case the copy_from_user blocks while swapping in a page,
- * and some other program tries to do a serial write at the same time.
- * Since the lock will only come under contention when the system is
- * swapping and available memory is low, it makes sense to share one
- * buffer across all the serial ports, since it significantly saves
- * memory if large numbers of serial ports are open.
- */
-static unsigned char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
-
-static char *dz_name = "DECstation DZ serial driver version ";
-static char *dz_version = "1.02";
-
-static inline unsigned short dz_in (struct dz_serial *, unsigned);
-static inline void dz_out (struct dz_serial *, unsigned, unsigned short);
-
-static inline void dz_sched_event (struct dz_serial *, int);
-static inline void receive_chars (struct dz_serial *);
-static inline void transmit_chars (struct dz_serial *);
-static inline void check_modem_status (struct dz_serial *);
-
-static void dz_stop (struct tty_struct *);
-static void dz_start (struct tty_struct *);
-static void dz_interrupt (int, void *, struct pt_regs *);
-static void do_serial_bh (void);
-static void do_softint (void *);
-static void do_serial_hangup (void *);
-static void change_speed (struct dz_serial *);
-static void dz_flush_chars (struct tty_struct *);
-static void dz_console_print (struct console *, const char *, unsigned int);
-static void dz_flush_buffer (struct tty_struct *);
-static void dz_throttle (struct tty_struct *);
-static void dz_unthrottle (struct tty_struct *);
-static void dz_send_xchar (struct tty_struct *, char);
-static void shutdown (struct dz_serial *);
-static void send_break (struct dz_serial *, int);
-static void dz_set_termios (struct tty_struct *, struct termios *);
-static void dz_close (struct tty_struct *, struct file *);
-static void dz_hangup (struct tty_struct *);
-static void show_serial_version (void);
-
-static int dz_write (struct tty_struct *, int, const unsigned char *, int);
-static int dz_write_room (struct tty_struct *);
-static int dz_chars_in_buffer (struct tty_struct *);
-static int startup (struct dz_serial *);
-static int get_serial_info (struct dz_serial *, struct serial_struct *);
-static int set_serial_info (struct dz_serial *, struct serial_struct *);
-static int get_lsr_info (struct dz_serial *, unsigned int *);
-static int dz_ioctl (struct tty_struct *, struct file *, unsigned int, unsigned long);
-static int block_til_ready (struct tty_struct *, struct file *, struct dz_serial *);
-static int dz_open (struct tty_struct *, struct file *);
-
-#ifdef MODULE
-int init_module (void)
-void cleanup_module (void)
-#endif
-
-#endif
-
-#endif /* DZ_SERIAL_H */
diff --git a/drivers/char/h8.c b/drivers/char/h8.c
deleted file mode 100644 (file)
index 19843a0..0000000
+++ /dev/null
@@ -1,1180 +0,0 @@
-/*
- * Hitachi H8/337 Microcontroller driver
- *
- * The H8 is used to deal with the power and thermal environment
- * of a system.
- *
- * Fixes:
- *     June 1999, AV   added releasing /proc/driver/h8
- *     Feb  2000, Borislav Deianov
- *                     changed queues to use list.h instead of lists.h
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/timer.h>
-#include <linux/fcntl.h>
-#include <linux/linkage.h>
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-#include <linux/miscdevice.h>
-#include <linux/list.h>
-#include <linux/ioport.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-
-#include "h8.h"
-
-#define DEBUG_H8
-
-#ifdef DEBUG_H8
-#define Dprintk                printk
-#else
-#define Dprintk
-#endif
-
-#define XDprintk if(h8_debug==-1)printk
-
-/*
- * The h8 device is one of the misc char devices.
- */
-#define H8_MINOR_DEV   140
-
-/*
- * Forward declarations.
- */
-static int  h8_init(void);
-static int  h8_display_blank(void);
-static int  h8_display_unblank(void);
-
-static void  h8_intr(int irq, void *dev_id, struct pt_regs *regs);
-
-static int   h8_get_info(char *, char **, off_t, int);
-
-/*
- * Support Routines.
- */
-static void h8_hw_init(void);
-static void h8_start_new_cmd(void);
-static void h8_send_next_cmd_byte(void);
-static void h8_read_event_status(void);
-static void h8_sync(void);
-static void h8_q_cmd(u_char *, int, int);
-static void h8_cmd_done(h8_cmd_q_t *qp);
-static int  h8_alloc_queues(void);
-
-static u_long h8_get_cpu_speed(void);
-static int h8_get_curr_temp(u_char curr_temp[]);
-static void h8_get_max_temp(void);
-static void h8_get_upper_therm_thold(void);
-static void h8_set_upper_therm_thold(int);
-static int h8_get_ext_status(u_char stat_word[]);
-
-static int h8_monitor_thread(void *);
-
-static int h8_manage_therm(void);
-static void h8_set_cpu_speed(int speed_divisor);
-
-static void h8_start_monitor_timer(unsigned long secs);
-static void h8_activate_monitor(unsigned long unused);
-
-/* in arch/alpha/kernel/lca.c */
-extern void lca_clock_print(void);
-extern int  lca_get_clock(void);
-extern void lca_clock_fiddle(int);
-
-static void h8_set_event_mask(int);
-static void h8_clear_event_mask(int);
-
-/*
- * Driver structures
- */
-
-static struct timer_list h8_monitor_timer;
-static int h8_monitor_timer_active = 0;
-
-static char  driver_version[] = "X0.0";/* no spaces */
-
-static union   intr_buf intrbuf;
-static int     intr_buf_ptr;
-static union   intr_buf xx;    
-static u_char  last_temp;
-
-/*
- * I/O Macros for register reads and writes.
- */
-#define H8_READ(a)     inb((a))
-#define H8_WRITE(d,a)  outb((d),(a))
-
-#define        H8_GET_STATUS   H8_READ((h8_base) + H8_STATUS_REG_OFF)
-#define H8_READ_DATA   H8_READ((h8_base) + H8_DATA_REG_OFF)
-#define WRITE_DATA(d)  H8_WRITE((d), h8_base + H8_DATA_REG_OFF)
-#define WRITE_CMD(d)   H8_WRITE((d), h8_base + H8_CMD_REG_OFF)
-
-static unsigned int h8_base = H8_BASE_ADDR;
-static unsigned int h8_irq = H8_IRQ;
-static unsigned int h8_state = H8_IDLE;
-static unsigned int h8_index = -1;
-static unsigned int h8_enabled = 0;
-
-static LIST_HEAD(h8_actq);
-static LIST_HEAD(h8_cmdq);
-static LIST_HEAD(h8_freeq);
-
-/* 
- * Globals used in thermal control of Alphabook1.
- */
-static int cpu_speed_divisor = -1;                     
-static int h8_event_mask = 0;                  
-static DECLARE_WAIT_QUEUE_HEAD(h8_monitor_wait);
-static unsigned int h8_command_mask = 0;
-static int h8_uthermal_threshold = DEFAULT_UTHERMAL_THRESHOLD;
-static int h8_uthermal_window = UTH_HYSTERESIS;                      
-static int h8_debug = 0xfffffdfc;
-static int h8_ldamp = MHZ_115;
-static int h8_udamp = MHZ_57;
-static u_char h8_current_temp = 0;
-static u_char h8_system_temp = 0;
-static int h8_sync_channel = 0;
-static DECLARE_WAIT_QUEUE_HEAD(h8_sync_wait);
-static int h8_init_performed;
-
-/* CPU speeds and clock divisor values */
-static int speed_tab[6] = {230, 153, 115, 57, 28, 14};
-  
-/*
- * H8 interrupt handler
-  */
-static void h8_intr(int irq, void *dev_id, struct pt_regs *regs)
-{
-       u_char  stat_reg, data_reg;
-       h8_cmd_q_t *qp = list_entry(h8_actq.next, h8_cmd_q_t, link);
-
-       stat_reg = H8_GET_STATUS;
-       data_reg = H8_READ_DATA;
-
-       XDprintk("h8_intr: state %d status 0x%x data 0x%x\n", h8_state, stat_reg, data_reg);
-
-       switch (h8_state) {
-         /* Response to an asynchronous event. */
-       case H8_IDLE: { /* H8_IDLE */
-           if (stat_reg & H8_OFULL) {
-               if (data_reg == H8_INTR) {
-                   h8_state = H8_INTR_MODE;
-                   /* Executing a command to determine what happened. */
-                   WRITE_CMD(H8_RD_EVENT_STATUS);
-                   intr_buf_ptr = 1;
-                   WRITE_CMD(H8_RD_EVENT_STATUS);
-               } else {
-                   Dprintk("h8_intr: idle stat 0x%x data 0x%x\n",
-                           stat_reg, data_reg);
-               }
-           } else {
-               Dprintk("h8_intr: bogus interrupt\n");
-           }
-           break;
-       }
-       case H8_INTR_MODE: { /* H8_INTR_MODE */
-           XDprintk("H8 intr/intr_mode\n");
-           if (data_reg == H8_BYTE_LEVEL_ACK) {
-               return;
-           } else if (data_reg == H8_CMD_ACK) {
-               return;
-           } else {
-               intrbuf.byte[intr_buf_ptr] = data_reg;
-               if(!intr_buf_ptr) {
-                   h8_state = H8_IDLE;
-                   h8_read_event_status();
-               }
-               intr_buf_ptr--;
-           }
-           break;
-       }
-       /* Placed in this state by h8_start_new_cmd(). */
-       case H8_XMIT: { /* H8_XMIT */
-           XDprintk("H8 intr/xmit\n");
-           /* If a byte level acknowledgement has been received */
-           if (data_reg == H8_BYTE_LEVEL_ACK) {
-               XDprintk("H8 intr/xmit BYTE ACK\n");
-               qp->nacks++;
-               if (qp->nacks > qp->ncmd)
-                   if(h8_debug & 0x1)
-                       Dprintk("h8intr: bogus # of acks!\n");
-               /* 
-                * If the number of bytes sent is less than the total 
-                * number of bytes in the command.
-                */ 
-               if (qp->cnt < qp->ncmd) {
-                   h8_send_next_cmd_byte();
-               }
-               return;
-               /* If the complete command has produced an acknowledgement. */
-           } else if (data_reg == H8_CMD_ACK) {
-               XDprintk("H8 intr/xmit CMD ACK\n");
-               /* If there are response bytes */
-               if (qp->nrsp)
-                   h8_state = H8_RCV;
-               else
-                   h8_state = H8_IDLE;
-               qp->cnt = 0;
-               return;
-               /* Error, need to start over with a clean slate. */
-           } else if (data_reg == H8_NACK) {
-               XDprintk("h8_intr: NACK received restarting command\n");
-               qp->nacks = 0;
-               qp->cnt = 0;
-               h8_state = H8_IDLE;
-               WRITE_CMD(H8_SYNC);
-               return;
-           } else {
-               Dprintk ("h8intr: xmit unknown data 0x%x \n", data_reg);
-               return;
-           }
-           break;
-       }
-       case H8_RESYNC: { /* H8_RESYNC */
-           XDprintk("H8 intr/resync\n");
-           if (data_reg == H8_BYTE_LEVEL_ACK) {
-               return;
-           } else if (data_reg == H8_SYNC_BYTE) {
-               h8_state = H8_IDLE;
-               if (!list_empty(&h8_actq))
-                   h8_send_next_cmd_byte();
-           } else {
-               Dprintk ("h8_intr: resync unknown data 0x%x \n", data_reg);
-               return;
-           }
-           break;
-       } 
-       case H8_RCV: { /* H8_RCV */
-           XDprintk("H8 intr/rcv\n");
-           if (qp->cnt < qp->nrsp) {
-               qp->rcvbuf[qp->cnt] = data_reg;
-               qp->cnt++;
-               /* If command reception finished. */
-               if (qp->cnt == qp->nrsp) {
-                   h8_state = H8_IDLE;
-                   list_del(&qp->link);
-                   h8_cmd_done (qp);
-                   /* More commands to send over? */
-                   if (!list_empty(&h8_cmdq))
-                       h8_start_new_cmd();
-               }
-               return;
-           } else {
-               Dprintk ("h8intr: rcv overflow cmd 0x%x\n", qp->cmdbuf[0]);
-           }
-           break;
-       }
-       default: /* default */
-           Dprintk("H8 intr/unknown\n");
-           break;
-       }
-       return;
-}
-
-static void __exit h8_cleanup (void)
-{
-       remove_proc_entry("driver/h8", NULL);
-        release_region(h8_base, 8);
-        free_irq(h8_irq, NULL);
-}
-
-static int __init h8_init(void)
-{
-        if(request_irq(h8_irq, h8_intr, SA_INTERRUPT, "h8", NULL))
-        {
-                printk(KERN_ERR "H8: error: IRQ %d is not free\n", h8_irq);
-                return -EIO;
-        }
-        printk(KERN_INFO "H8 at 0x%x IRQ %d\n", h8_base, h8_irq);
-
-        if (!request_region(h8_base, 8, "h8"))
-        {
-               free_irq(h8_irq, NULL);
-               return -EIO;
-        }
-
-        create_proc_info_entry("driver/h8", 0, NULL, h8_get_info);
-
-       h8_alloc_queues();
-
-       h8_hw_init();
-
-       kernel_thread(h8_monitor_thread, NULL, 0);
-
-        return 0;
-}
-
-module_init(h8_init);
-module_exit(h8_cleanup);
-
-static void __init h8_hw_init(void)
-{
-       u_char  buf[H8_MAX_CMD_SIZE];
-
-       /* set CPU speed to max for booting */
-       h8_set_cpu_speed(MHZ_230);
-
-       /*
-        * Initialize the H8
-        */
-       h8_sync();  /* activate interrupts */
-
-       /* To clear conditions left by console */
-       h8_read_event_status(); 
-
-       /* Perform a conditioning read */
-       buf[0] = H8_DEVICE_CONTROL;
-       buf[1] = 0xff;
-       buf[2] = 0x0;
-       h8_q_cmd(buf, 3, 1);
-
-       /* Turn on built-in and external mice, capture power switch */
-       buf[0] = H8_DEVICE_CONTROL;
-       buf[1] = 0x0;
-       buf[2] = H8_ENAB_INT_PTR | H8_ENAB_EXT_PTR |
-              /*H8_DISAB_PWR_OFF_SW |*/ H8_ENAB_LOW_SPD_IND;
-       h8_q_cmd(buf, 3, 1);
-
-        h8_enabled = 1;
-       return;
-}
-
-static int h8_get_info(char *buf, char **start, off_t fpos, int length)
-{
-#ifdef CONFIG_PROC_FS
-        char *p;
-
-        if (!h8_enabled)
-                return 0;
-        p = buf;
-
-
-        /*
-           0) Linux driver version (this will change if format changes)
-           1) 
-           2) 
-           3)
-           4)
-       */
-            
-        p += sprintf(p, "%s \n",
-                     driver_version
-                    );
-
-        return p - buf;
-#else
-       return 0;
-#endif
-}
-
-/* Called from console driver -- must make sure h8_enabled. */
-static int h8_display_blank(void)
-{
-#ifdef CONFIG_H8_DISPLAY_BLANK
-        int     error;
-
-        if (!h8_enabled)
-                return 0;
-        error = h8_set_display_power_state(H8_STATE_STANDBY);
-        if (error == H8_SUCCESS)
-                return 1;
-        h8_error("set display standby", error);
-#endif
-        return 0;
-}
-
-/* Called from console driver -- must make sure h8_enabled. */
-static int h8_display_unblank(void)
-{
-#ifdef CONFIG_H8_DISPLAY_BLANK
-        int error;
-
-        if (!h8_enabled)
-                return 0;
-        error = h8_set_display_power_state(H8_STATE_READY);
-        if (error == H8_SUCCESS)
-                return 1;
-        h8_error("set display ready", error);
-#endif
-        return 0;
-}
-
-static int h8_alloc_queues(void)
-{
-        h8_cmd_q_t *qp;
-       unsigned long flags;
-        int i;
-
-        qp = (h8_cmd_q_t *)kmalloc((sizeof (h8_cmd_q_t) * H8_Q_ALLOC_AMOUNT),
-                                  GFP_KERNEL);
-
-        if (!qp) {
-                printk(KERN_ERR "H8: could not allocate memory for command queue\n");
-                return(0);
-        }
-        /* add to the free queue */
-        save_flags(flags); cli();
-        for (i = 0; i < H8_Q_ALLOC_AMOUNT; i++) {
-                /* place each at front of freeq */
-                list_add(&qp[i].link, &h8_freeq);
-        }
-        restore_flags(flags);
-        return (1);
-}
-
-/* 
- * Basic means by which commands are sent to the H8.
- */
-void
-h8_q_cmd(u_char *cmd, int cmd_size, int resp_size)
-{
-        h8_cmd_q_t      *qp;
-       unsigned long flags;
-        int             i;
-
-        /* get cmd buf */
-       save_flags(flags); cli();
-        while (list_empty(&h8_freeq)) {
-                Dprintk("H8: need to allocate more cmd buffers\n");
-                restore_flags(flags);
-                h8_alloc_queues();
-                save_flags(flags); cli();
-        }
-        /* get first element from queue */
-        qp = list_entry(h8_freeq.next, h8_cmd_q_t, link);
-        list_del(&qp->link);
-
-        restore_flags(flags);
-
-        /* fill it in */
-        for (i = 0; i < cmd_size; i++)
-            qp->cmdbuf[i] = cmd[i];
-        qp->ncmd = cmd_size;
-        qp->nrsp = resp_size;
-
-        /* queue it at the end of the cmd queue */
-        save_flags(flags); cli();
-
-        /* XXX this actually puts it at the start of cmd queue, bug? */
-        list_add(&qp->link, &h8_cmdq);
-
-        restore_flags(flags);
-
-        h8_start_new_cmd();
-}
-
-void
-h8_start_new_cmd(void)
-{
-        unsigned long flags;
-        h8_cmd_q_t *qp;
-
-       save_flags(flags); cli();
-        if (h8_state != H8_IDLE) {
-                if (h8_debug & 0x1)
-                        Dprintk("h8_start_new_cmd: not idle\n");
-                restore_flags(flags);
-                return;
-        }
-
-        if (!list_empty(&h8_actq)) {
-                Dprintk("h8_start_new_cmd: inconsistency: IDLE with non-empty active queue!\n");
-                restore_flags(flags);
-                return;
-        }
-
-        if (list_empty(&h8_cmdq)) {
-                Dprintk("h8_start_new_cmd: no command to dequeue\n");
-                restore_flags(flags);
-                return;
-        }
-        /*
-         * Take first command off of the command queue and put
-         * it on the active queue.
-         */
-        qp = list_entry(h8_cmdq.next, h8_cmd_q_t, link);
-        list_del(&qp->link);
-        /* XXX should this go to the end of the active queue? */
-        list_add(&qp->link, &h8_actq);
-        h8_state = H8_XMIT;
-        if (h8_debug & 0x1)
-                Dprintk("h8_start_new_cmd: Starting a command\n");
-
-        qp->cnt = 1;
-        WRITE_CMD(qp->cmdbuf[0]);               /* Kick it off */
-
-        restore_flags(flags);
-        return;
-}
-
-void
-h8_send_next_cmd_byte(void)
-{
-        h8_cmd_q_t      *qp = list_entry(h8_actq.next, h8_cmd_q_t, link);
-        int cnt;
-
-        cnt = qp->cnt;
-        qp->cnt++;
-
-        if (h8_debug & 0x1)
-                Dprintk("h8 sending next cmd byte 0x%x (0x%x)\n",
-                       cnt, qp->cmdbuf[cnt]);
-
-        if (cnt) {
-                WRITE_DATA(qp->cmdbuf[cnt]);
-        } else {
-                WRITE_CMD(qp->cmdbuf[cnt]);
-        }
-        return;
-}
-
-/*
- * Synchronize H8 communications channel for command transmission.
- */
-void
-h8_sync(void)
-{
-        u_char  buf[H8_MAX_CMD_SIZE];
-
-        buf[0] = H8_SYNC;
-        buf[1] = H8_SYNC_BYTE;
-        h8_q_cmd(buf, 2, 1);
-}
-
-/*
- * Responds to external interrupt. Reads event status word and 
- * decodes type of interrupt. 
- */
-void
-h8_read_event_status(void)
-{
-
-        if(h8_debug & 0x200)
-                printk(KERN_DEBUG "h8_read_event_status: value 0x%x\n", intrbuf.word);
-
-        /*
-         * Power related items
-         */
-        if (intrbuf.word & H8_DC_CHANGE) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: DC_CHANGE\n");
-                /* see if dc added or removed, set batt/dc flag, send event */
-
-                h8_set_event_mask(H8_MANAGE_BATTERY);
-                wake_up(&h8_monitor_wait);
-        }
-
-        if (intrbuf.word & H8_POWER_BUTTON) {
-                printk(KERN_CRIT "Power switch pressed - please wait - preparing to power 
-off\n");
-                h8_set_event_mask(H8_POWER_BUTTON);
-                wake_up(&h8_monitor_wait);
-        }
-
-        /*
-         * Thermal related items
-         */
-        if (intrbuf.word & H8_THERMAL_THRESHOLD) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: THERMAL_THRESHOLD\n");
-                h8_set_event_mask(H8_MANAGE_UTHERM);
-                wake_up(&h8_monitor_wait);
-        }
-
-        /*
-         * nops -for now
-         */
-        if (intrbuf.word & H8_DOCKING_STATION_STATUS) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: DOCKING_STATION_STATUS\n");
-                /* read_ext_status */
-        }
-        if (intrbuf.word & H8_EXT_BATT_STATUS) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: EXT_BATT_STATUS\n");
-
-        }
-        if (intrbuf.word & H8_EXT_BATT_CHARGE_STATE) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: EXT_BATT_CHARGE_STATE\n");
-
-        }
-        if (intrbuf.word & H8_BATT_CHANGE_OVER) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: BATT_CHANGE_OVER\n");
-
-        }
-        if (intrbuf.word & H8_WATCHDOG) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: WATCHDOG\n");
-                /* nop */
-        }
-        if (intrbuf.word & H8_SHUTDOWN) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: SHUTDOWN\n");
-                /* nop */
-        }
-        if (intrbuf.word & H8_KEYBOARD) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: KEYBOARD\n");
-                /* nop */
-        }
-        if (intrbuf.word & H8_EXT_MOUSE_OR_CASE_SWITCH) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: EXT_MOUSE_OR_CASE_SWITCH\n");
-                /* read_ext_status*/
-        }
-        if (intrbuf.word & H8_INT_BATT_LOW) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: INT_BATT_LOW\n"); post
-                /* event, warn user */
-        }
-        if (intrbuf.word & H8_INT_BATT_CHARGE_STATE) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: INT_BATT_CHARGE_STATE\n");
-                /* nop - happens often */
-        }
-        if (intrbuf.word & H8_INT_BATT_STATUS) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: INT_BATT_STATUS\n");
-
-        }
-        if (intrbuf.word & H8_INT_BATT_CHARGE_THRESHOLD) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: INT_BATT_CHARGE_THRESHOLD\n");
-                /* nop - happens often */
-        }
-        if (intrbuf.word & H8_EXT_BATT_LOW) {
-               if(h8_debug & 0x4)
-                   printk(KERN_DEBUG "h8_read_event_status: EXT_BATT_LOW\n");
-                /*if no internal, post event, warn user */
-                /* else nop */
-        }
-
-        return;
-}
-
-/*
- * Function called when H8 has performed requested command.
- */
-static void
-h8_cmd_done(h8_cmd_q_t *qp)
-{
-
-        /* what to do */
-        switch (qp->cmdbuf[0]) {
-       case H8_SYNC:
-           if (h8_debug & 0x40000) 
-               printk(KERN_DEBUG "H8: Sync command done - byte returned was 0x%x\n", 
-                      qp->rcvbuf[0]);
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_RD_SN:
-       case H8_RD_ENET_ADDR:
-           printk(KERN_DEBUG "H8: read Ethernet address: command done - address: %x - %x - %x - %x - %x - %x \n", 
-                  qp->rcvbuf[0], qp->rcvbuf[1], qp->rcvbuf[2],
-                  qp->rcvbuf[3], qp->rcvbuf[4], qp->rcvbuf[5]);
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_RD_HW_VER:
-       case H8_RD_MIC_VER:
-       case H8_RD_MAX_TEMP:
-           printk(KERN_DEBUG "H8: Max recorded CPU temp %d, Sys temp %d\n",
-                  qp->rcvbuf[0], qp->rcvbuf[1]);
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_RD_MIN_TEMP:
-           printk(KERN_DEBUG "H8: Min recorded CPU temp %d, Sys temp %d\n",
-                  qp->rcvbuf[0], qp->rcvbuf[1]);
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_RD_CURR_TEMP:
-           h8_sync_channel |= H8_RD_CURR_TEMP;
-           xx.byte[0] = qp->rcvbuf[0];
-           xx.byte[1] = qp->rcvbuf[1];
-           wake_up(&h8_sync_wait); 
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_RD_SYS_VARIENT:
-       case H8_RD_PWR_ON_CYCLES:
-           printk(KERN_DEBUG " H8: RD_PWR_ON_CYCLES command done\n");
-           break;
-
-       case H8_RD_PWR_ON_SECS:
-           printk(KERN_DEBUG "H8: RD_PWR_ON_SECS command done\n");
-           break;
-
-       case H8_RD_RESET_STATUS:
-       case H8_RD_PWR_DN_STATUS:
-       case H8_RD_EVENT_STATUS:
-       case H8_RD_ROM_CKSM:
-       case H8_RD_EXT_STATUS:
-           xx.byte[1] = qp->rcvbuf[0];
-           xx.byte[0] = qp->rcvbuf[1];
-           h8_sync_channel |= H8_GET_EXT_STATUS;
-           wake_up(&h8_sync_wait); 
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_RD_USER_CFG:
-       case H8_RD_INT_BATT_VOLT:
-       case H8_RD_DC_INPUT_VOLT:
-       case H8_RD_HORIZ_PTR_VOLT:
-       case H8_RD_VERT_PTR_VOLT:
-       case H8_RD_EEPROM_STATUS:
-       case H8_RD_ERR_STATUS:
-       case H8_RD_NEW_BUSY_SPEED:
-       case H8_RD_CONFIG_INTERFACE:
-       case H8_RD_INT_BATT_STATUS:
-           printk(KERN_DEBUG "H8: Read int batt status cmd done - returned was %x %x %x\n",
-                  qp->rcvbuf[0], qp->rcvbuf[1], qp->rcvbuf[2]);
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_RD_EXT_BATT_STATUS:
-       case H8_RD_PWR_UP_STATUS:
-       case H8_RD_EVENT_STATUS_MASK:
-       case H8_CTL_EMU_BITPORT:
-       case H8_DEVICE_CONTROL:
-           if(h8_debug & 0x20000) {
-               printk(KERN_DEBUG "H8: Device control cmd done - byte returned was 0x%x\n",
-                      qp->rcvbuf[0]);
-           }
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_CTL_TFT_BRT_DC:
-       case H8_CTL_WATCHDOG:
-       case H8_CTL_MIC_PROT:
-       case H8_CTL_INT_BATT_CHG:
-       case H8_CTL_EXT_BATT_CHG:
-       case H8_CTL_MARK_SPACE:
-       case H8_CTL_MOUSE_SENSITIVITY:
-       case H8_CTL_DIAG_MODE:
-       case H8_CTL_IDLE_AND_BUSY_SPDS:
-           printk(KERN_DEBUG "H8: Idle and busy speed command done\n");
-           break;
-
-       case H8_CTL_TFT_BRT_BATT:
-       case H8_CTL_UPPER_TEMP:
-           if(h8_debug & 0x10) {
-               XDprintk("H8: ctl upper thermal thresh cmd done - returned was %d\n",
-                      qp->rcvbuf[0]);
-           }
-           list_add(&qp->link, &h8_freeq);
-           break;
-
-       case H8_CTL_LOWER_TEMP:
-       case H8_CTL_TEMP_CUTOUT:
-       case H8_CTL_WAKEUP:
-       case H8_CTL_CHG_THRESHOLD:
-       case H8_CTL_TURBO_MODE:
-       case H8_SET_DIAG_STATUS:
-       case H8_SOFTWARE_RESET:
-       case H8_RECAL_PTR:
-       case H8_SET_INT_BATT_PERCENT:
-       case H8_WRT_CFG_INTERFACE_REG:
-       case H8_WRT_EVENT_STATUS_MASK:
-       case H8_ENTER_POST_MODE:
-       case H8_EXIT_POST_MODE:
-       case H8_RD_EEPROM:
-       case H8_WRT_EEPROM:
-       case H8_WRT_TO_STATUS_DISP:
-           printk("H8: Write IO status display command done\n");
-           break;
-
-       case H8_DEFINE_SPC_CHAR:
-       case H8_DEFINE_TABLE_STRING_ENTRY:
-       case H8_PERFORM_EMU_CMD:
-       case H8_EMU_RD_REG:
-       case H8_EMU_WRT_REG:
-       case H8_EMU_RD_RAM:
-       case H8_EMU_WRT_RAM:
-       case H8_BQ_RD_REG:
-       case H8_BQ_WRT_REG:
-       case H8_PWR_OFF:
-           printk (KERN_DEBUG "H8: misc command completed\n");
-           break;
-        }
-        return;
-}
-
-/*
- * Retrieve the current CPU temperature and case temperature.  Provides
- * the feedback for the thermal control algorithm.  Synchcronized via 
- * sleep() for priority so that no other actions in the process will take
- * place before the data becomes available.
- */
-int
-h8_get_curr_temp(u_char curr_temp[])
-{
-        u_char  buf[H8_MAX_CMD_SIZE];
-        unsigned long flags;
-
-        memset(buf, 0, H8_MAX_CMD_SIZE); 
-        buf[0] = H8_RD_CURR_TEMP;
-
-        h8_q_cmd(buf, 1, 2);
-
-       save_flags(flags); cli();
-
-        while((h8_sync_channel & H8_RD_CURR_TEMP) == 0)
-                sleep_on(&h8_sync_wait); 
-
-        restore_flags(flags);
-
-        h8_sync_channel &= ~H8_RD_CURR_TEMP;
-        curr_temp[0] = xx.byte[0];
-        curr_temp[1] = xx.byte[1];
-        xx.word = 0;
-
-        if(h8_debug & 0x8) 
-                printk("H8: curr CPU temp %d, Sys temp %d\n",
-                      curr_temp[0], curr_temp[1]);
-        return 0;
-}
-
-static void
-h8_get_max_temp(void)
-{
-        u_char  buf[H8_MAX_CMD_SIZE];
-
-        buf[0] = H8_RD_MAX_TEMP;
-        h8_q_cmd(buf, 1, 2);
-}
-
-/*
- * Assigns an upper limit to the value of the H8 thermal interrupt.
- * As an example setting a value of 115 F here will cause the 
- * interrupt to trigger when the CPU temperature reaches 115 F.
- */
-static void
-h8_set_upper_therm_thold(int thold)
-{
-        u_char  buf[H8_MAX_CMD_SIZE];
-
-        /* write 0 to reinitialize interrupt */
-        buf[0] = H8_CTL_UPPER_TEMP;
-        buf[1] = 0x0;
-        buf[2] = 0x0;
-        h8_q_cmd(buf, 3, 1); 
-
-        /* Do it for real */
-        buf[0] = H8_CTL_UPPER_TEMP;
-        buf[1] = 0x0;
-        buf[2] = thold;
-        h8_q_cmd(buf, 3, 1); 
-}
-
-static void
-h8_get_upper_therm_thold(void)
-{
-        u_char  buf[H8_MAX_CMD_SIZE];
-
-        buf[0] = H8_CTL_UPPER_TEMP;
-        buf[1] = 0xff;
-        buf[2] = 0;
-        h8_q_cmd(buf, 3, 1); 
-}
-
-/*
- * The external status word contains information on keyboard controller,
- * power button, changes in external batt status, change in DC state,
- * docking station, etc. General purpose querying use.
- */
-int
-h8_get_ext_status(u_char stat_word[])
-{
-        u_char  buf[H8_MAX_CMD_SIZE];
-       unsigned long flags;
-
-        memset(buf, 0, H8_MAX_CMD_SIZE); 
-        buf[0] = H8_RD_EXT_STATUS;
-
-        h8_q_cmd(buf, 1, 2);
-
-       save_flags(flags); cli();
-
-        while((h8_sync_channel & H8_GET_EXT_STATUS) == 0)
-                sleep_on(&h8_sync_wait); 
-
-        restore_flags(flags);
-
-        h8_sync_channel &= ~H8_GET_EXT_STATUS;
-        stat_word[0] = xx.byte[0];
-        stat_word[1] = xx.byte[1];
-        xx.word = 0;
-
-        if(h8_debug & 0x8) 
-                printk("H8: curr ext status %x,  %x\n",
-                      stat_word[0], stat_word[1]);
-
-        return 0;
-}
-
-/*
- * Thread attached to task 0 manages thermal/physcial state of Alphabook. 
- * When a condition is detected by the interrupt service routine, the
- * isr does a wakeup() on h8_monitor_wait.  The mask value is then
- * screened for the appropriate action.
- */
-
-int
-h8_monitor_thread(void * unused)
-{
-        u_char curr_temp[2];
-
-        /*
-         * Need a logic based safety valve here. During boot when this thread is
-         * started and the thermal interrupt is not yet initialized this logic 
-         * checks the temperature and acts accordingly.  When this path is acted
-         * upon system boot is painfully slow, however, the priority associated 
-         * with overheating is high enough to warrant this action.
-         */
-        h8_get_curr_temp(curr_temp);
-
-        printk(KERN_INFO "H8: Initial CPU temp: %d\n", curr_temp[0]);
-
-        if(curr_temp[0] >= h8_uthermal_threshold) {
-                h8_set_event_mask(H8_MANAGE_UTHERM);
-                h8_manage_therm();
-        } else {
-                /*
-                 * Arm the upper thermal limit of the H8 so that any temp in
-                 * excess will trigger the thermal control mechanism.
-                 */
-                h8_set_upper_therm_thold(h8_uthermal_threshold);
-        }
-
-        for(;;) {
-               sleep_on(&h8_monitor_wait);
-
-                if(h8_debug & 0x2)
-                        printk(KERN_DEBUG "h8_monitor_thread awakened, mask:%x\n",
-                                h8_event_mask);
-
-                if (h8_event_mask & (H8_MANAGE_UTHERM|H8_MANAGE_LTHERM)) {
-                        h8_manage_therm();
-                }
-
-#if 0
-                if (h8_event_mask & H8_POWER_BUTTON) {
-                        h8_system_down();
-                }
-
-               /*
-                * If an external DC supply is removed or added make 
-                * appropriate CPU speed adjustments.
-                */
-                if (h8_event_mask & H8_MANAGE_BATTERY) {
-                          h8_run_level_3_manage(H8_RUN); 
-                          h8_clear_event_mask(H8_MANAGE_BATTERY);
-                }
-#endif
-        }
-}
-
-/* 
- * Function implements the following policy. When the machine is booted
- * the system is set to run at full clock speed. When the upper thermal
- * threshold is reached as a result of full clock a damping factor is 
- * applied to cool off the cpu.  The default value is one quarter clock
- * (57 Mhz).  When as a result of this cooling a temperature lower by
- * hmc_uthermal_window is reached, the machine is reset to a higher 
- * speed, one half clock (115 Mhz).  One half clock is maintained until
- * the upper thermal threshold is again reached restarting the cycle.
- */
-
-int
-h8_manage_therm(void)
-{
-        u_char curr_temp[2];
-
-        if(h8_event_mask & H8_MANAGE_UTHERM) {
-               /* Upper thermal interrupt received, need to cool down. */
-               if(h8_debug & 0x10)
-                        printk(KERN_WARNING "H8: Thermal threshold %d F reached\n",
-                              h8_uthermal_threshold);
-               h8_set_cpu_speed(h8_udamp); 
-                h8_clear_event_mask(H8_MANAGE_UTHERM);
-                h8_set_event_mask(H8_MANAGE_LTHERM);
-                /* Check again in 30 seconds for CPU temperature */
-                h8_start_monitor_timer(H8_TIMEOUT_INTERVAL); 
-        } else if (h8_event_mask & H8_MANAGE_LTHERM) {
-               /* See how cool the system has become as a result
-                  of the reduction in speed. */
-                h8_get_curr_temp(curr_temp);
-                last_temp = curr_temp[0];
-                if (curr_temp[0] < (h8_uthermal_threshold - h8_uthermal_window))
-               {
-                       /* System cooling has progressed to a point
-                          that the CPU may be sped up. */
-                        h8_set_upper_therm_thold(h8_uthermal_threshold);
-                        h8_set_cpu_speed(h8_ldamp); /* adjustable */ 
-                        if(h8_debug & 0x10)
-                            printk(KERN_WARNING "H8: CPU cool, applying cpu_divisor: %d \n",
-                                  h8_ldamp);
-                        h8_clear_event_mask(H8_MANAGE_LTHERM);
-                }
-               else /* Not cool enough yet, check again in 30 seconds. */
-                        h8_start_monitor_timer(H8_TIMEOUT_INTERVAL);
-        } else {
-                
-        }
-       return 0;
-}
-
-/* 
- * Function conditions the value of global_rpb_counter before
- * calling the primitive which causes the actual speed change.
- */
-void
-h8_set_cpu_speed(int speed_divisor)
-{
-
-#ifdef NOT_YET
-/*
- * global_rpb_counter is consumed by alpha_delay() in determining just
- * how much time to delay.  It is necessary that the number of microseconds
- * in DELAY(n) be kept consistent over a variety of CPU clock speeds.
- * To that end global_rpb_counter is here adjusted.
- */ 
-        
-        switch (speed_divisor) {
-                case 0:
-                        global_rpb_counter = rpb->rpb_counter * 2L;
-                        break;
-                case 1:
-                        global_rpb_counter = rpb->rpb_counter * 4L / 3L ;
-                        break;
-                case 3:
-                        global_rpb_counter = rpb->rpb_counter / 2L;
-                        break;
-                case 4:
-                        global_rpb_counter = rpb->rpb_counter / 4L;
-                        break;
-                case 5:
-                        global_rpb_counter = rpb->rpb_counter / 8L;
-                        break;
-                /* 
-                 * This case most commonly needed for cpu_speed_divisor 
-                 * of 2 which is the value assigned by the firmware. 
-                 */
-                default:
-                        global_rpb_counter = rpb->rpb_counter;
-                break;
-        }
-#endif /* NOT_YET */
-
-        if(h8_debug & 0x8)
-                printk(KERN_DEBUG "H8: Setting CPU speed to %d MHz\n",
-                      speed_tab[speed_divisor]); 
-
-         /* Make the actual speed change */
-        lca_clock_fiddle(speed_divisor);
-}
-
-/*
- * Gets value stored in rpb representing CPU clock speed and adjusts this
- * value based on the current clock speed divisor.
- */
-u_long
-h8_get_cpu_speed(void)
-{
-        u_long speed = 0;
-        u_long counter;
-
-#ifdef NOT_YET
-        counter = rpb->rpb_counter / 1000000L;
-
-        switch (alphabook_get_clock()) {
-                case 0:
-                        speed = counter * 2L;
-                        break;
-                case 1:
-                        speed = counter * 4L / 3L ;
-                        break;
-                case 2:
-                        speed = counter;
-                        break;
-                case 3:
-                        speed = counter / 2L;
-                        break;
-                case 4:
-                        speed = counter / 4L;
-                        break;
-                case 5:
-                        speed = counter / 8L;
-                        break;
-                default:
-                break;
-        }
-        if(h8_debug & 0x8)
-                printk(KERN_DEBUG "H8: CPU speed current setting: %d MHz\n", speed); 
-#endif  /* NOT_YET */
-       return speed;
-}
-
-static void
-h8_activate_monitor(unsigned long unused)
-{
-       unsigned long flags;
-
-       save_flags(flags); cli();
-       h8_monitor_timer_active = 0;
-       restore_flags(flags);
-
-       wake_up(&h8_monitor_wait);
-}
-
-static void
-h8_start_monitor_timer(unsigned long secs)
-{
-       unsigned long flags;
-
-       if (h8_monitor_timer_active)
-           return;
-
-       save_flags(flags); cli();
-       h8_monitor_timer_active = 1;
-       restore_flags(flags);
-
-        init_timer(&h8_monitor_timer);
-        h8_monitor_timer.function = h8_activate_monitor;
-        h8_monitor_timer.expires = secs * HZ + jiffies;
-        add_timer(&h8_monitor_timer);
-}
-
-static void h8_set_event_mask(int mask)
-{
-       unsigned long flags;
-
-       save_flags(flags); cli();
-       h8_event_mask |= mask;
-       restore_flags(flags);
-}
-
-static void h8_clear_event_mask(int mask)
-{
-       unsigned long flags;
-
-       save_flags(flags); cli();
-       h8_event_mask &= (~mask);
-       restore_flags(flags);
-}
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/char/h8.h b/drivers/char/h8.h
deleted file mode 100644 (file)
index 986eef5..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- */
-
-#ifndef __H8_H__
-#define __H8_H__
-
-/*
- * Register address and offsets
- */
-#define H8_BASE_ADDR                   0x170            /* default */
-#define H8_IRQ                        9                /* default */
-#define H8_STATUS_REG_OFF              0x4              
-#define H8_CMD_REG_OFF                 0x4
-#define H8_DATA_REG_OFF                0x0
-
-
-/* H8 register bit definitions */
-/* status register */
-#define H8_OFULL                       0x1              /* output data register full */
-#define H8_IFULL                       0x2              /* input data register full */
-#define H8_CMD                         0x8              /* command / not data */
-
-#define H8_INTR                        0xfa
-#define H8_NACK                        0xfc
-#define H8_BYTE_LEVEL_ACK              0xfd
-#define H8_CMD_ACK                     0xfe
-#define H8_SYNC_BYTE                   0x99
-
-/*
- * H8 command definitions
- */
-/* System info commands */
-#define H8_SYNC                         0x0
-#define H8_RD_SN                        0x1
-#define H8_RD_ENET_ADDR                 0x2
-#define H8_RD_HW_VER                    0x3
-#define H8_RD_MIC_VER                   0x4
-#define H8_RD_MAX_TEMP                  0x5
-#define H8_RD_MIN_TEMP                  0x6
-#define H8_RD_CURR_TEMP                 0x7
-#define H8_RD_SYS_VARIENT               0x8
-#define H8_RD_PWR_ON_CYCLES             0x9
-#define H8_RD_PWR_ON_SECS               0xa
-#define H8_RD_RESET_STATUS              0xb
-#define H8_RD_PWR_DN_STATUS             0xc
-#define H8_RD_EVENT_STATUS              0xd
-#define H8_RD_ROM_CKSM                  0xe
-#define H8_RD_EXT_STATUS                0xf
-#define H8_RD_USER_CFG                  0x10
-#define H8_RD_INT_BATT_VOLT             0x11
-#define H8_RD_DC_INPUT_VOLT             0x12
-#define H8_RD_HORIZ_PTR_VOLT            0x13
-#define H8_RD_VERT_PTR_VOLT             0x14
-#define H8_RD_EEPROM_STATUS             0x15
-#define H8_RD_ERR_STATUS                0x16
-#define H8_RD_NEW_BUSY_SPEED            0x17
-#define H8_RD_CONFIG_INTERFACE          0x18
-#define H8_RD_INT_BATT_STATUS           0x19
-#define H8_RD_EXT_BATT_STATUS           0x1a
-#define H8_RD_PWR_UP_STATUS             0x1b
-#define H8_RD_EVENT_STATUS_MASK         0x56
-
-/* Read/write/modify commands */
-#define H8_CTL_EMU_BITPORT              0x32
-#define H8_DEVICE_CONTROL               0x21
-#define H8_CTL_TFT_BRT_DC               0x22
-#define H8_CTL_WATCHDOG                 0x23
-#define H8_CTL_MIC_PROT                 0x24
-#define H8_CTL_INT_BATT_CHG             0x25
-#define H8_CTL_EXT_BATT_CHG             0x26
-#define H8_CTL_MARK_SPACE               0x27
-#define H8_CTL_MOUSE_SENSITIVITY        0x28
-#define H8_CTL_DIAG_MODE                0x29
-#define H8_CTL_IDLE_AND_BUSY_SPDS       0x2a
-#define H8_CTL_TFT_BRT_BATT             0x2b
-#define H8_CTL_UPPER_TEMP               0x2c
-#define H8_CTL_LOWER_TEMP               0x2d
-#define H8_CTL_TEMP_CUTOUT              0x2e
-#define H8_CTL_WAKEUP                   0x2f
-#define H8_CTL_CHG_THRESHOLD            0x30
-#define H8_CTL_TURBO_MODE               0x31
-#define H8_SET_DIAG_STATUS              0x40
-#define H8_SOFTWARE_RESET               0x41
-#define H8_RECAL_PTR                    0x42
-#define H8_SET_INT_BATT_PERCENT         0x43
-#define H8_WRT_CFG_INTERFACE_REG        0x45
-#define H8_WRT_EVENT_STATUS_MASK        0x57
-#define H8_ENTER_POST_MODE              0x46
-#define H8_EXIT_POST_MODE               0x47
-
-/* Block transfer commands */
-#define H8_RD_EEPROM                    0x50
-#define H8_WRT_EEPROM                   0x51
-#define H8_WRT_TO_STATUS_DISP           0x52
-#define H8_DEFINE_SPC_CHAR              0x53
-/* Generic commands */
-#define H8_DEFINE_TABLE_STRING_ENTRY    0x60
-
-/* Battery control commands */
-#define H8_PERFORM_EMU_CMD              0x70
-#define H8_EMU_RD_REG                   0x71
-#define H8_EMU_WRT_REG                  0x72
-#define H8_EMU_RD_RAM                   0x73
-#define H8_EMU_WRT_RAM                  0x74
-#define H8_BQ_RD_REG                    0x75
-#define H8_BQ_WRT_REG                   0x76
-
-/* System admin commands */
-#define H8_PWR_OFF                      0x80
-
-/*
- * H8 command related definitions
- */
-
-/* device control argument bits */
-#define H8_ENAB_EXTSMI                  0x1
-#define H8_DISAB_IRQ                    0x2
-#define H8_ENAB_FLASH_WRT               0x4
-#define H8_ENAB_THERM                   0x8
-#define H8_ENAB_INT_PTR                 0x10
-#define H8_ENAB_LOW_SPD_IND             0x20
-#define H8_ENAB_EXT_PTR                 0x40
-#define H8_DISAB_PWR_OFF_SW             0x80
-#define H8_POWER_OFF                   0x80
-
-/* H8 read event status bits */
-#define H8_DC_CHANGE                    0x1
-#define H8_INT_BATT_LOW                 0x2
-#define H8_INT_BATT_CHARGE_THRESHOLD    0x4
-#define H8_INT_BATT_CHARGE_STATE        0x8
-#define H8_INT_BATT_STATUS              0x10
-#define H8_EXT_BATT_CHARGE_STATE        0x20
-#define H8_EXT_BATT_LOW                 0x40
-#define H8_EXT_BATT_STATUS              0x80
-#define H8_THERMAL_THRESHOLD            0x100
-#define H8_WATCHDOG                     0x200
-#define H8_DOCKING_STATION_STATUS       0x400
-#define H8_EXT_MOUSE_OR_CASE_SWITCH     0x800
-#define H8_KEYBOARD                     0x1000
-#define H8_BATT_CHANGE_OVER             0x2000
-#define H8_POWER_BUTTON                 0x4000
-#define H8_SHUTDOWN                     0x8000
-
-/* H8 control idle and busy speeds */
-#define H8_SPEED_LOW                    0x1
-#define H8_SPEED_MED                    0x2
-#define H8_SPEED_HI                     0x3
-#define H8_SPEED_LOCKED                 0x80
-
-#define H8_MAX_CMD_SIZE                 18      
-#define H8_Q_ALLOC_AMOUNT               10      
-
-/* H8 state field values */
-#define H8_IDLE                         1
-#define H8_XMIT                         2
-#define H8_RCV                          3
-#define H8_RESYNC                       4
-#define H8_INTR_MODE                    5
-
-/* Mask values for control functions */
-#define UTH_HYSTERESIS                  5
-#define DEFAULT_UTHERMAL_THRESHOLD      115
-#define H8_TIMEOUT_INTERVAL            30
-#define H8_RUN                          4
-
-#define H8_GET_MAX_TEMP                 0x1
-#define H8_GET_CURR_TEMP                0x2
-#define H8_GET_UPPR_THRMAL_THOLD        0x4
-#define H8_GET_ETHERNET_ADDR            0x8
-#define H8_SYNC_OP                      0x10 
-#define H8_SET_UPPR_THRMAL_THOLD        0x20
-#define H8_GET_INT_BATT_STAT            0x40
-#define H8_GET_CPU_SPD                  0x80
-#define H8_MANAGE_UTHERM                0x100 
-#define H8_MANAGE_LTHERM                0x200 
-#define H8_HALT                         0x400 
-#define H8_CRASH                        0x800 
-#define H8_GET_EXT_STATUS               0x10000
-#define H8_MANAGE_QUIET                 0x20000
-#define H8_MANAGE_SPEEDUP               0x40000
-#define H8_MANAGE_BATTERY               0x80000
-#define H8_SYSTEM_DELAY_TEST            0x100000
-#define H8_POWER_SWITCH_TEST            0x200000
-
-/* CPU speeds and clock divisor values */
-#define MHZ_14                           5
-#define MHZ_28                           4
-#define MHZ_57                           3
-#define MHZ_115                          2
-#define MHZ_230                          0 
-
-/*
- * H8 data
- */
-struct h8_data {
-        u_int           ser_num;
-        u_char          ether_add[6];
-        u_short         hw_ver;
-        u_short         mic_ver;
-        u_short         max_tmp;
-        u_short         min_tmp;
-        u_short         cur_tmp;
-        u_int           sys_var;
-        u_int           pow_on;
-        u_int           pow_on_secs;
-        u_char          reset_status;
-        u_char          pwr_dn_status;
-        u_short         event_status;
-        u_short         rom_cksm;
-        u_short         ext_status;
-        u_short         u_cfg;
-        u_char          ibatt_volt;
-        u_char          dc_volt;
-        u_char          ptr_horiz;
-        u_char          ptr_vert;
-        u_char          eeprom_status;
-        u_char          error_status;
-        u_char          new_busy_speed;
-        u_char          cfg_interface;
-        u_short         int_batt_status;
-        u_short         ext_batt_status;
-        u_char          pow_up_status;
-        u_char          event_status_mask;
-};
-
-
-/*
- * H8 command buffers
- */
-typedef struct h8_cmd_q {
-        struct list_head link;          /* double linked list */
-        int             ncmd;           /* number of bytes in command */
-        int             nrsp;           /* number of bytes in response */
-        int             cnt;            /* number of bytes sent/received */
-        int             nacks;          /* number of byte level acks */
-        u_char          cmdbuf[H8_MAX_CMD_SIZE]; /* buffer to store command */
-        u_char          rcvbuf[H8_MAX_CMD_SIZE]; /* buffer to store response */
-} h8_cmd_q_t;
-
-union   intr_buf {
-        u_char  byte[2];
-        u_int   word;
-};
-
-#endif /* __H8_H_ */
index 83d6b37..764c653 100644 (file)
@@ -55,7 +55,7 @@
 
 static int hangcheck_tick = DEFAULT_IOFENCE_TICK;
 static int hangcheck_margin = DEFAULT_IOFENCE_MARGIN;
-static int hangcheck_reboot;  /* Defaults to not reboot */
+static int hangcheck_reboot = 1;  /* Defaults to reboot */
 
 /* Driver options */
 module_param(hangcheck_tick, int, 0);
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
deleted file mode 100644 (file)
index 5e8c472..0000000
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*
- * Intel & MS High Precision Event Timer Implementation.
- *
- * Copyright (C) 2003 Intel Corporation
- *     Venki Pallipadi
- * (c) Copyright 2004 Hewlett-Packard Development Company, L.P.
- *     Bob Picco <robert.picco@hp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/miscdevice.h>
-#include <linux/major.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/init.h>
-#include <linux/poll.h>
-#include <linux/proc_fs.h>
-#include <linux/spinlock.h>
-#include <linux/sysctl.h>
-#include <linux/wait.h>
-#include <linux/bcd.h>
-#include <linux/seq_file.h>
-
-#include <asm/current.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/bitops.h>
-#include <asm/div64.h>
-
-#include <linux/acpi.h>
-#include <acpi/acpi_bus.h>
-#include <linux/hpet.h>
-
-/*
- * The High Precision Event Timer driver.
- * This driver is closely modelled after the rtc.c driver.
- * http://www.intel.com/labs/platcomp/hpet/hpetspec.htm
- */
-#define        HPET_USER_FREQ  (64)
-#define        HPET_DRIFT      (500)
-
-static u32 hpet_ntimer, hpet_nhpet, hpet_max_freq = HPET_USER_FREQ;
-
-/* A lock for concurrent access by app and isr hpet activity. */
-static spinlock_t hpet_lock = SPIN_LOCK_UNLOCKED;
-/* A lock for concurrent intermodule access to hpet and isr hpet activity. */
-static spinlock_t hpet_task_lock = SPIN_LOCK_UNLOCKED;
-
-#define        HPET_DEV_NAME   (7)
-
-struct hpet_dev {
-       struct hpets *hd_hpets;
-       struct hpet *hd_hpet;
-       struct hpet_timer *hd_timer;
-       unsigned long hd_ireqfreq;
-       unsigned long hd_irqdata;
-       wait_queue_head_t hd_waitqueue;
-       struct fasync_struct *hd_async_queue;
-       struct hpet_task *hd_task;
-       unsigned int hd_flags;
-       unsigned int hd_irq;
-       unsigned int hd_hdwirq;
-       char hd_name[HPET_DEV_NAME];
-};
-
-struct hpets {
-       struct hpets *hp_next;
-       struct hpet *hp_hpet;
-       unsigned long hp_period;
-       unsigned long hp_delta;
-       unsigned int hp_ntimer;
-       unsigned int hp_which;
-       struct hpet_dev hp_dev[1];
-};
-
-static struct hpets *hpets;
-
-#define        HPET_OPEN               0x0001
-#define        HPET_IE                 0x0002  /* interrupt enabled */
-#define        HPET_PERIODIC           0x0004
-
-#if BITS_PER_LONG == 64
-#define        write_counter(V, MC)    writeq(V, MC)
-#define        read_counter(MC)        readq(MC)
-#else
-#define        write_counter(V, MC)    writel(V, MC)
-#define        read_counter(MC)        readl(MC)
-#endif
-
-#ifndef readq
-static unsigned long long __inline readq(void *addr)
-{
-       return readl(addr) | (((unsigned long long)readl(addr + 4)) << 32LL);
-}
-#endif
-
-#ifndef writeq
-static void __inline writeq(unsigned long long v, void *addr)
-{
-       writel(v & 0xffffffff, addr);
-       writel(v >> 32, addr + 4);
-}
-#endif
-
-static irqreturn_t hpet_interrupt(int irq, void *data, struct pt_regs *regs)
-{
-       struct hpet_dev *devp;
-       unsigned long isr;
-
-       devp = data;
-
-       spin_lock(&hpet_lock);
-       devp->hd_irqdata++;
-
-       /*
-        * For non-periodic timers, increment the accumulator.
-        * This has the effect of treating non-periodic like periodic.
-        */
-       if ((devp->hd_flags & (HPET_IE | HPET_PERIODIC)) == HPET_IE) {
-               unsigned long m, t;
-
-               t = devp->hd_ireqfreq;
-               m = read_counter(&devp->hd_hpet->hpet_mc);
-               write_counter(t + m + devp->hd_hpets->hp_delta,
-                             &devp->hd_timer->hpet_compare);
-       }
-
-       isr = (1 << (devp - devp->hd_hpets->hp_dev));
-       writeq(isr, &devp->hd_hpet->hpet_isr);
-       spin_unlock(&hpet_lock);
-
-       spin_lock(&hpet_task_lock);
-       if (devp->hd_task)
-               devp->hd_task->ht_func(devp->hd_task->ht_data);
-       spin_unlock(&hpet_task_lock);
-
-       wake_up_interruptible(&devp->hd_waitqueue);
-
-       kill_fasync(&devp->hd_async_queue, SIGIO, POLL_IN);
-
-       return IRQ_HANDLED;
-}
-
-static int hpet_open(struct inode *inode, struct file *file)
-{
-       struct hpet_dev *devp;
-       struct hpets *hpetp;
-       int i;
-
-       if (file->f_mode & FMODE_WRITE)
-               return -EINVAL;
-
-       spin_lock_irq(&hpet_lock);
-
-       for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next)
-               for (i = 0; i < hpetp->hp_ntimer; i++)
-                       if (hpetp->hp_dev[i].hd_flags & HPET_OPEN
-                           || hpetp->hp_dev[i].hd_task)
-                               continue;
-                       else {
-                               devp = &hpetp->hp_dev[i];
-                               break;
-                       }
-
-       if (!devp) {
-               spin_unlock_irq(&hpet_lock);
-               return -EBUSY;
-       }
-
-       file->private_data = devp;
-       devp->hd_irqdata = 0;
-       devp->hd_flags |= HPET_OPEN;
-       spin_unlock_irq(&hpet_lock);
-
-       return 0;
-}
-
-static ssize_t
-hpet_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
-{
-       DECLARE_WAITQUEUE(wait, current);
-       unsigned long data;
-       ssize_t retval;
-       struct hpet_dev *devp;
-
-       devp = file->private_data;
-       if (!devp->hd_ireqfreq)
-               return -EIO;
-
-       if (count < sizeof(unsigned long))
-               return -EINVAL;
-
-       add_wait_queue(&devp->hd_waitqueue, &wait);
-
-       for ( ; ; ) {
-               set_current_state(TASK_INTERRUPTIBLE);
-
-               spin_lock_irq(&hpet_lock);
-               data = devp->hd_irqdata;
-               devp->hd_irqdata = 0;
-               spin_unlock_irq(&hpet_lock);
-
-               if (data)
-                       break;
-               else if (file->f_flags & O_NONBLOCK) {
-                       retval = -EAGAIN;
-                       goto out;
-               } else if (signal_pending(current)) {
-                       retval = -ERESTARTSYS;
-                       goto out;
-               }
-               schedule();
-       }
-
-       retval = put_user(data, (unsigned long __user *)buf);
-       if (!retval)
-               retval = sizeof(unsigned long);
-out:
-       __set_current_state(TASK_RUNNING);
-       remove_wait_queue(&devp->hd_waitqueue, &wait);
-
-       return retval;
-}
-
-static unsigned int hpet_poll(struct file *file, poll_table * wait)
-{
-       unsigned long v;
-       struct hpet_dev *devp;
-
-       devp = file->private_data;
-
-       if (!devp->hd_ireqfreq)
-               return 0;
-
-       poll_wait(file, &devp->hd_waitqueue, wait);
-
-       spin_lock_irq(&hpet_lock);
-       v = devp->hd_irqdata;
-       spin_unlock_irq(&hpet_lock);
-
-       if (v != 0)
-               return POLLIN | POLLRDNORM;
-
-       return 0;
-}
-
-static int hpet_mmap(struct file *file, struct vm_area_struct *vma)
-{
-#ifdef CONFIG_HPET_MMAP
-       struct hpet_dev *devp;
-       unsigned long addr;
-
-       if (((vma->vm_end - vma->vm_start) != PAGE_SIZE) || vma->vm_pgoff)
-               return -EINVAL;
-
-       devp = file->private_data;
-       addr = (unsigned long)devp->hd_hpet;
-
-       if (addr & (PAGE_SIZE - 1))
-               return -ENOSYS;
-
-       vma->vm_flags |= VM_IO;
-       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-       addr = __pa(addr);
-
-       if (remap_page_range
-           (vma, vma->vm_start, addr, PAGE_SIZE, vma->vm_page_prot)) {
-               printk(KERN_ERR "remap_page_range failed in hpet.c\n");
-               return -EAGAIN;
-       }
-
-       return 0;
-#else
-       return -ENOSYS;
-#endif
-}
-
-static int hpet_fasync(int fd, struct file *file, int on)
-{
-       struct hpet_dev *devp;
-
-       devp = file->private_data;
-
-       if (fasync_helper(fd, file, on, &devp->hd_async_queue) >= 0)
-               return 0;
-       else
-               return -EIO;
-}
-
-static int hpet_release(struct inode *inode, struct file *file)
-{
-       struct hpet_dev *devp;
-       struct hpet_timer *timer;
-       int irq = 0;
-
-       devp = file->private_data;
-       timer = devp->hd_timer;
-
-       spin_lock_irq(&hpet_lock);
-
-       writeq((readq(&timer->hpet_config) & ~Tn_INT_ENB_CNF_MASK),
-              &timer->hpet_config);
-
-       irq = devp->hd_irq;
-       devp->hd_irq = 0;
-
-       devp->hd_ireqfreq = 0;
-
-       if (devp->hd_flags & HPET_PERIODIC
-           && readq(&timer->hpet_config) & Tn_TYPE_CNF_MASK) {
-               unsigned long v;
-
-               v = readq(&timer->hpet_config);
-               v ^= Tn_TYPE_CNF_MASK;
-               writeq(v, &timer->hpet_config);
-       }
-
-       devp->hd_flags &= ~(HPET_OPEN | HPET_IE | HPET_PERIODIC);
-       spin_unlock_irq(&hpet_lock);
-
-       if (irq)
-               free_irq(irq, devp);
-
-       if (file->f_flags & FASYNC)
-               hpet_fasync(-1, file, 0);
-
-       file->private_data = NULL;
-       return 0;
-}
-
-static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int);
-
-static int
-hpet_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-          unsigned long arg)
-{
-       struct hpet_dev *devp;
-
-       devp = file->private_data;
-       return hpet_ioctl_common(devp, cmd, arg, 0);
-}
-
-static int hpet_ioctl_ieon(struct hpet_dev *devp)
-{
-       struct hpet_timer *timer;
-       struct hpet *hpet;
-       struct hpets *hpetp;
-       int irq;
-       unsigned long g, v, t, m;
-       unsigned long flags, isr;
-
-       timer = devp->hd_timer;
-       hpet = devp->hd_hpet;
-       hpetp = devp->hd_hpets;
-
-       v = readq(&timer->hpet_config);
-       spin_lock_irq(&hpet_lock);
-
-       if (devp->hd_flags & HPET_IE) {
-               spin_unlock_irq(&hpet_lock);
-               return -EBUSY;
-       }
-
-       devp->hd_flags |= HPET_IE;
-       spin_unlock_irq(&hpet_lock);
-
-       t = readq(&timer->hpet_config);
-       irq = devp->hd_hdwirq;
-
-       if (irq) {
-               sprintf(devp->hd_name, "hpet%d", (int)(devp - hpetp->hp_dev));
-
-               if (request_irq
-                   (irq, hpet_interrupt, SA_INTERRUPT, devp->hd_name, (void *)devp)) {
-                       printk(KERN_ERR "hpet: IRQ %d is not free\n", irq);
-                       irq = 0;
-               }
-       }
-
-       if (irq == 0) {
-               spin_lock_irq(&hpet_lock);
-               devp->hd_flags ^= HPET_IE;
-               spin_unlock_irq(&hpet_lock);
-               return -EIO;
-       }
-
-       devp->hd_irq = irq;
-       t = devp->hd_ireqfreq;
-       v = readq(&timer->hpet_config);
-       g = v | Tn_INT_ENB_CNF_MASK;
-
-       if (devp->hd_flags & HPET_PERIODIC) {
-               write_counter(t, &timer->hpet_compare);
-               g |= Tn_TYPE_CNF_MASK;
-               v |= Tn_TYPE_CNF_MASK;
-               writeq(v, &timer->hpet_config);
-               v |= Tn_VAL_SET_CNF_MASK;
-               writeq(v, &timer->hpet_config);
-               local_irq_save(flags);
-               m = read_counter(&hpet->hpet_mc);
-               write_counter(t + m + hpetp->hp_delta, &timer->hpet_compare);
-       } else {
-               local_irq_save(flags);
-               m = read_counter(&hpet->hpet_mc);
-               write_counter(t + m + hpetp->hp_delta, &timer->hpet_compare);
-       }
-
-       isr = (1 << (devp - hpets->hp_dev));
-       writeq(isr, &hpet->hpet_isr);
-       writeq(g, &timer->hpet_config);
-       local_irq_restore(flags);
-
-       return 0;
-}
-
-static inline unsigned long hpet_time_div(unsigned long dis)
-{
-       unsigned long long m = 1000000000000000ULL;
-
-       do_div(m, dis);
-
-       return (unsigned long)m;
-}
-
-static int
-hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
-{
-       struct hpet_timer *timer;
-       struct hpet *hpet;
-       struct hpets *hpetp;
-       int err;
-       unsigned long v;
-
-       switch (cmd) {
-       case HPET_IE_OFF:
-       case HPET_INFO:
-       case HPET_EPI:
-       case HPET_DPI:
-       case HPET_IRQFREQ:
-               timer = devp->hd_timer;
-               hpet = devp->hd_hpet;
-               hpetp = devp->hd_hpets;
-               break;
-       case HPET_IE_ON:
-               return hpet_ioctl_ieon(devp);
-       default:
-               return -EINVAL;
-       }
-
-       err = 0;
-
-       switch (cmd) {
-       case HPET_IE_OFF:
-               if ((devp->hd_flags & HPET_IE) == 0)
-                       break;
-               v = readq(&timer->hpet_config);
-               v &= ~Tn_INT_ENB_CNF_MASK;
-               writeq(v, &timer->hpet_config);
-               if (devp->hd_irq) {
-                       free_irq(devp->hd_irq, devp);
-                       devp->hd_irq = 0;
-               }
-               devp->hd_flags ^= HPET_IE;
-               break;
-       case HPET_INFO:
-               {
-                       struct hpet_info info;
-
-                       info.hi_ireqfreq = hpet_time_div(hpetp->hp_period *
-                                                        devp->hd_ireqfreq);
-                       info.hi_flags =
-                           readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK;
-                       info.hi_hpet = devp->hd_hpets->hp_which;
-                       info.hi_timer = devp - devp->hd_hpets->hp_dev;
-                       if (copy_to_user((void __user *)arg, &info, sizeof(info)))
-                               err = -EFAULT;
-                       break;
-               }
-       case HPET_EPI:
-               v = readq(&timer->hpet_config);
-               if ((v & Tn_PER_INT_CAP_MASK) == 0) {
-                       err = -ENXIO;
-                       break;
-               }
-               devp->hd_flags |= HPET_PERIODIC;
-               break;
-       case HPET_DPI:
-               v = readq(&timer->hpet_config);
-               if ((v & Tn_PER_INT_CAP_MASK) == 0) {
-                       err = -ENXIO;
-                       break;
-               }
-               if (devp->hd_flags & HPET_PERIODIC &&
-                   readq(&timer->hpet_config) & Tn_TYPE_CNF_MASK) {
-                       v = readq(&timer->hpet_config);
-                       v ^= Tn_TYPE_CNF_MASK;
-                       writeq(v, &timer->hpet_config);
-               }
-               devp->hd_flags &= ~HPET_PERIODIC;
-               break;
-       case HPET_IRQFREQ:
-               if (!kernel && (arg > hpet_max_freq) &&
-                   !capable(CAP_SYS_RESOURCE)) {
-                       err = -EACCES;
-                       break;
-               }
-
-               if (arg & (arg - 1)) {
-                       err = -EINVAL;
-                       break;
-               }
-
-               devp->hd_ireqfreq = hpet_time_div(hpetp->hp_period * arg);
-       }
-
-       return err;
-}
-
-static struct file_operations hpet_fops = {
-       .owner = THIS_MODULE,
-       .llseek = no_llseek,
-       .read = hpet_read,
-       .poll = hpet_poll,
-       .ioctl = hpet_ioctl,
-       .open = hpet_open,
-       .release = hpet_release,
-       .fasync = hpet_fasync,
-       .mmap = hpet_mmap,
-};
-
-EXPORT_SYMBOL(hpet_alloc);
-EXPORT_SYMBOL(hpet_register);
-EXPORT_SYMBOL(hpet_unregister);
-EXPORT_SYMBOL(hpet_control);
-
-int hpet_register(struct hpet_task *tp, int periodic)
-{
-       unsigned int i;
-       u64 mask;
-       struct hpet_timer *timer;
-       struct hpet_dev *devp;
-       struct hpets *hpetp;
-
-       switch (periodic) {
-       case 1:
-               mask = Tn_PER_INT_CAP_MASK;
-               break;
-       case 0:
-               mask = 0;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       spin_lock_irq(&hpet_task_lock);
-       spin_lock(&hpet_lock);
-
-       for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next)
-               for (timer = hpetp->hp_hpet->hpet_timers, i = 0;
-                    i < hpetp->hp_ntimer; i++, timer++) {
-                       if ((readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK)
-                           != mask)
-                               continue;
-
-                       devp = &hpetp->hp_dev[i];
-
-                       if (devp->hd_flags & HPET_OPEN || devp->hd_task) {
-                               devp = NULL;
-                               continue;
-                       }
-
-                       tp->ht_opaque = devp;
-                       devp->hd_task = tp;
-                       break;
-               }
-
-       spin_unlock(&hpet_lock);
-       spin_unlock_irq(&hpet_task_lock);
-
-       if (tp->ht_opaque)
-               return 0;
-       else
-               return -EBUSY;
-}
-
-static inline int hpet_tpcheck(struct hpet_task *tp)
-{
-       struct hpet_dev *devp;
-       struct hpets *hpetp;
-
-       devp = tp->ht_opaque;
-
-       if (!devp)
-               return -ENXIO;
-
-       for (hpetp = hpets; hpetp; hpetp = hpetp->hp_next)
-               if (devp >= hpetp->hp_dev
-                   && devp < (hpetp->hp_dev + hpetp->hp_ntimer)
-                   && devp->hd_hpet == hpetp->hp_hpet)
-                       return 0;
-
-       return -ENXIO;
-}
-
-int hpet_unregister(struct hpet_task *tp)
-{
-       struct hpet_dev *devp;
-       struct hpet_timer *timer;
-       int err;
-
-       if ((err = hpet_tpcheck(tp)))
-               return err;
-
-       spin_lock_irq(&hpet_task_lock);
-       spin_lock(&hpet_lock);
-
-       devp = tp->ht_opaque;
-       if (devp->hd_task != tp) {
-               spin_unlock(&hpet_lock);
-               spin_unlock_irq(&hpet_task_lock);
-               return -ENXIO;
-       }
-
-       timer = devp->hd_timer;
-       writeq((readq(&timer->hpet_config) & ~Tn_INT_ENB_CNF_MASK),
-              &timer->hpet_config);
-       devp->hd_flags &= ~(HPET_IE | HPET_PERIODIC);
-       devp->hd_task = NULL;
-       spin_unlock(&hpet_lock);
-       spin_unlock_irq(&hpet_task_lock);
-
-       return 0;
-}
-
-int hpet_control(struct hpet_task *tp, unsigned int cmd, unsigned long arg)
-{
-       struct hpet_dev *devp;
-       int err;
-
-       if ((err = hpet_tpcheck(tp)))
-               return err;
-
-       spin_lock_irq(&hpet_lock);
-       devp = tp->ht_opaque;
-       if (devp->hd_task != tp) {
-               spin_unlock_irq(&hpet_lock);
-               return -ENXIO;
-       }
-       spin_unlock_irq(&hpet_lock);
-       return hpet_ioctl_common(devp, cmd, arg, 1);
-}
-
-#ifdef CONFIG_TIME_INTERPOLATION
-
-static unsigned long hpet_offset, last_wall_hpet;
-static long hpet_nsecs_per_cycle, hpet_cycles_per_sec;
-
-static unsigned long hpet_getoffset(void)
-{
-       return hpet_offset + (read_counter(&hpets->hp_hpet->hpet_mc) -
-                             last_wall_hpet) * hpet_nsecs_per_cycle;
-}
-
-static void hpet_update(long delta)
-{
-       unsigned long mc;
-       unsigned long offset;
-
-       mc = read_counter(&hpets->hp_hpet->hpet_mc);
-       offset = hpet_offset + (mc - last_wall_hpet) * hpet_nsecs_per_cycle;
-
-       if (delta < 0 || (unsigned long)delta < offset)
-               hpet_offset = offset - delta;
-       else
-               hpet_offset = 0;
-       last_wall_hpet = mc;
-}
-
-static void hpet_reset(void)
-{
-       hpet_offset = 0;
-       last_wall_hpet = read_counter(&hpets->hp_hpet->hpet_mc);
-}
-
-static struct time_interpolator hpet_interpolator = {
-       .get_offset = hpet_getoffset,
-       .update = hpet_update,
-       .reset = hpet_reset
-};
-
-#endif
-
-static ctl_table hpet_table[] = {
-       {
-        .ctl_name = 1,
-        .procname = "max-user-freq",
-        .data = &hpet_max_freq,
-        .maxlen = sizeof(int),
-        .mode = 0644,
-        .proc_handler = &proc_dointvec,
-        },
-       {.ctl_name = 0}
-};
-
-static ctl_table hpet_root[] = {
-       {
-        .ctl_name = 1,
-        .procname = "hpet",
-        .maxlen = 0,
-        .mode = 0555,
-        .child = hpet_table,
-        },
-       {.ctl_name = 0}
-};
-
-static ctl_table dev_root[] = {
-       {
-        .ctl_name = CTL_DEV,
-        .procname = "dev",
-        .maxlen = 0,
-        .mode = 0555,
-        .child = hpet_root,
-        },
-       {.ctl_name = 0}
-};
-
-static struct ctl_table_header *sysctl_header;
-
-/*
- * Adjustment for when arming the timer with
- * initial conditions.  That is, main counter
- * ticks expired before interrupts are enabled.
- */
-#define        TICK_CALIBRATE  (1000UL)
-
-static unsigned long __init hpet_calibrate(struct hpets *hpetp)
-{
-       struct hpet_timer *timer = NULL;
-       unsigned long t, m, count, i, flags, start;
-       struct hpet_dev *devp;
-       int j;
-       struct hpet *hpet;
-
-       for (j = 0, devp = hpetp->hp_dev; j < hpetp->hp_ntimer; j++, devp++)
-               if ((devp->hd_flags & HPET_OPEN) == 0) {
-                       timer = devp->hd_timer;
-                       break;
-               }
-
-       if (!timer)
-               return 0;
-
-       hpet = hpets->hp_hpet;
-       t = read_counter(&timer->hpet_compare);
-
-       i = 0;
-       count = hpet_time_div(hpetp->hp_period * TICK_CALIBRATE);
-
-       local_irq_save(flags);
-
-       start = read_counter(&hpet->hpet_mc);
-
-       do {
-               m = read_counter(&hpet->hpet_mc);
-               write_counter(t + m + hpetp->hp_delta, &timer->hpet_compare);
-       } while (i++, (m - start) < count);
-
-       local_irq_restore(flags);
-
-       return (m - start) / i;
-}
-
-int __init hpet_alloc(struct hpet_data *hdp)
-{
-       u64 cap, mcfg;
-       struct hpet_dev *devp;
-       u32 i, ntimer;
-       struct hpets *hpetp;
-       size_t siz;
-       struct hpet *hpet;
-       static struct hpets *last __initdata = (struct hpets *)0;
-
-       /*
-        * hpet_alloc can be called by platform dependent code.
-        * if platform dependent code has allocated the hpet
-        * ACPI also reports hpet, then we catch it here.
-        */
-       for (hpetp = hpets; hpetp; hpetp = hpetp->hp_next)
-               if (hpetp->hp_hpet == (struct hpet *)(hdp->hd_address))
-                       return 0;
-
-       siz = sizeof(struct hpets) + ((hdp->hd_nirqs - 1) *
-                                     sizeof(struct hpet_dev));
-
-       hpetp = kmalloc(siz, GFP_KERNEL);
-
-       if (!hpetp)
-               return -ENOMEM;
-
-       memset(hpetp, 0, siz);
-
-       hpetp->hp_which = hpet_nhpet++;
-       hpetp->hp_hpet = (struct hpet *)hdp->hd_address;
-
-       hpetp->hp_ntimer = hdp->hd_nirqs;
-
-       for (i = 0; i < hdp->hd_nirqs; i++)
-               hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i];
-
-       hpet = hpetp->hp_hpet;
-
-       cap = readq(&hpet->hpet_cap);
-
-       ntimer = ((cap & HPET_NUM_TIM_CAP_MASK) >> HPET_NUM_TIM_CAP_SHIFT) + 1;
-
-       if (hpetp->hp_ntimer != ntimer) {
-               printk(KERN_WARNING "hpet: number irqs doesn't agree"
-                      " with number of timers\n");
-               kfree(hpetp);
-               return -ENODEV;
-       }
-
-       if (last)
-               last->hp_next = hpetp;
-       else
-               hpets = hpetp;
-
-       last = hpetp;
-
-       hpetp->hp_period = (cap & HPET_COUNTER_CLK_PERIOD_MASK) >>
-           HPET_COUNTER_CLK_PERIOD_SHIFT;
-
-       mcfg = readq(&hpet->hpet_config);
-       if ((mcfg & HPET_ENABLE_CNF_MASK) == 0) {
-               write_counter(0L, &hpet->hpet_mc);
-               mcfg |= HPET_ENABLE_CNF_MASK;
-               writeq(mcfg, &hpet->hpet_config);
-       }
-
-       for (i = 0, devp = hpetp->hp_dev; i < hpetp->hp_ntimer;
-            i++, hpet_ntimer++, devp++) {
-               unsigned long v;
-               struct hpet_timer *timer;
-
-               timer = &hpet->hpet_timers[devp - hpetp->hp_dev];
-               v = readq(&timer->hpet_config);
-
-               devp->hd_hpets = hpetp;
-               devp->hd_hpet = hpet;
-               devp->hd_timer = timer;
-
-               /*
-                * If the timer was reserved by platform code,
-                * then make timer unavailable for opens.
-                */
-               if (hdp->hd_state & (1 << i)) {
-                       devp->hd_flags = HPET_OPEN;
-                       continue;
-               }
-
-               init_waitqueue_head(&devp->hd_waitqueue);
-       }
-
-       hpetp->hp_delta = hpet_calibrate(hpetp);
-
-       return 0;
-}
-
-static acpi_status __init hpet_resources(struct acpi_resource *res, void *data)
-{
-       struct hpet_data *hdp;
-       acpi_status status;
-       struct acpi_resource_address64 addr;
-       struct hpets *hpetp;
-
-       hdp = data;
-
-       status = acpi_resource_to_address64(res, &addr);
-
-       if (ACPI_SUCCESS(status)) {
-               unsigned long size;
-
-               size = addr.max_address_range - addr.min_address_range + 1;
-               hdp->hd_address =
-                   (unsigned long)ioremap(addr.min_address_range, size);
-
-               for (hpetp = hpets; hpetp; hpetp = hpetp->hp_next)
-                       if (hpetp->hp_hpet == (struct hpet *)(hdp->hd_address))
-                               return -EBUSY;
-       } else if (res->id == ACPI_RSTYPE_EXT_IRQ) {
-               struct acpi_resource_ext_irq *irqp;
-               int i;
-
-               irqp = &res->data.extended_irq;
-
-               if (irqp->number_of_interrupts > 0) {
-                       hdp->hd_nirqs = irqp->number_of_interrupts;
-
-                       for (i = 0; i < hdp->hd_nirqs; i++)
-                               hdp->hd_irq[i] =
-                                   acpi_register_gsi(irqp->interrupts[i],
-                                                     irqp->edge_level,
-                                                     irqp->active_high_low);
-               }
-       }
-
-       return AE_OK;
-}
-
-static int __init hpet_acpi_add(struct acpi_device *device)
-{
-       acpi_status result;
-       struct hpet_data data;
-
-       memset(&data, 0, sizeof(data));
-
-       result =
-           acpi_walk_resources(device->handle, METHOD_NAME__CRS,
-                               hpet_resources, &data);
-
-       if (ACPI_FAILURE(result))
-               return -ENODEV;
-
-       if (!data.hd_address || !data.hd_nirqs) {
-               printk("%s: no address or irqs in _CRS\n", __FUNCTION__);
-               return -ENODEV;
-       }
-
-       return hpet_alloc(&data);
-}
-
-static int __init hpet_acpi_remove(struct acpi_device *device, int type)
-{
-       return 0;
-}
-
-static struct acpi_driver hpet_acpi_driver __initdata = {
-       .name = "hpet",
-       .class = "",
-       .ids = "PNP0103",
-       .ops = {
-               .add = hpet_acpi_add,
-               .remove = hpet_acpi_remove,
-               },
-};
-
-static struct miscdevice hpet_misc = { HPET_MINOR, "hpet", &hpet_fops };
-
-static int __init hpet_init(void)
-{
-       (void)acpi_bus_register_driver(&hpet_acpi_driver);
-
-       if (hpets) {
-               if (misc_register(&hpet_misc))
-                       return -ENODEV;
-
-               sysctl_header = register_sysctl_table(dev_root, 0);
-
-#ifdef CONFIG_TIME_INTERPOLATION
-               {
-                       struct hpet *hpet;
-
-                       hpet = hpets->hp_hpet;
-                       hpet_cycles_per_sec = hpet_time_div(hpets->hp_period);
-                       hpet_interpolator.frequency = hpet_cycles_per_sec;
-                       hpet_interpolator.drift = hpet_cycles_per_sec *
-                           HPET_DRIFT / 1000000;
-                       hpet_nsecs_per_cycle = 1000000000 / hpet_cycles_per_sec;
-                       register_time_interpolator(&hpet_interpolator);
-               }
-#endif
-               return 0;
-       } else
-               return -ENODEV;
-}
-
-static void __exit hpet_exit(void)
-{
-       acpi_bus_unregister_driver(&hpet_acpi_driver);
-
-       if (hpets)
-               unregister_sysctl_table(sysctl_header);
-
-       return;
-}
-
-module_init(hpet_init);
-module_exit(hpet_exit);
-MODULE_AUTHOR("Bob Picco <Robert.Picco@hp.com>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
deleted file mode 100644 (file)
index 96ca634..0000000
+++ /dev/null
@@ -1,1579 +0,0 @@
-/*
- * IBM eServer Hypervisor Virtual Console Server Device Driver
- * Copyright (C) 2003, 2004 IBM Corp.
- *  Ryan S. Arnold (rsa@us.ibm.com)
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- * Author(s) :  Ryan S. Arnold <rsa@us.ibm.com>
- *
- * This is the device driver for the IBM Hypervisor Virtual Console Server,
- * "hvcs".  The IBM hvcs provides a tty driver interface to allow Linux
- * user space applications access to the system consoles of logically
- * partitioned operating systems, e.g. Linux, running on the same partitioned
- * Power5 ppc64 system.  Physical hardware consoles per partition are not
- * practical on this hardware so system consoles are accessed by this driver
- * using inter-partition firmware interfaces to virtual terminal devices.
- *
- * A vty is known to the HMC as a "virtual serial server adapter".  It is a
- * virtual terminal device that is created by firmware upon partition creation
- * to act as a partitioned OS's console device.
- *
- * Firmware dynamically (via hotplug) exposes vty-servers to a running ppc64
- * Linux system upon their creation by the HMC or their exposure during boot.
- * The non-user interactive backend of this driver is implemented as a vio
- * device driver so that it can receive notification of vty-server lifetimes
- * after it registers with the vio bus to handle vty-server probe and remove
- * callbacks.
- *
- * Many vty-servers can be configured to connect to one vty, but a vty can
- * only be actively connected to by a single vty-server, in any manner, at one
- * time.  If the HMC is currently hosting the console for a target Linux
- * partition; attempts to open the tty device to the partition's console using
- * the hvcs on any partition will return -EBUSY with every open attempt until
- * the HMC frees the connection between its vty-server and the desired
- * partition's vty device.  Conversely, a vty-server may only be connected to
- * a single vty at one time even though it may have several configured vty
- * partner possibilities.
- *
- * Firmware does not provide notification of vty partner changes to this
- * driver.  This means that an HMC Super Admin may add or remove partner vtys
- * from a vty-server's partner list but the changes will not be signaled to
- * the vty-server.  Firmware only notifies the driver when a vty-server is
- * added or removed from the system.  To compensate for this deficiency, this
- * driver implements a sysfs update attribute which provides a method for
- * rescanning partner information upon a user's request.
- *
- * Each vty-server, prior to being exposed to this driver is reference counted
- * using the 2.6 Linux kernel kobject construct.  This kobject is also used by
- * the vio bus to provide a vio device sysfs entry that this driver attaches
- * device specific attributes to, including partner information.  The vio bus
- * framework also provides a sysfs entry for each vio driver.  The hvcs driver
- * provides driver attributes in this entry.
- *
- * For direction on installation and usage of this driver please reference
- * Documentation/powerpc/hvcs.txt.
- */
-
-#include <linux/device.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/kobject.h>
-#include <linux/kthread.h>
-#include <linux/list.h>
-#include <linux/major.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/stat.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <asm/hvconsole.h>
-#include <asm/hvcserver.h>
-#include <asm/uaccess.h>
-#include <asm/vio.h>
-
-/*
- * 1.0.0 -> 1.1.0 Added kernel_thread scheduling methodology to driver to
- * replace wait_task constructs.
- *
- * 1.1.0 -> 1.2.0 Moved pi_buff initialization out of arch code into driver code
- * and added locking to share this buffer between hvcs_struct instances.  This
- * is because the page_size kmalloc can't be done with a spin_lock held.
- *
- * Also added sysfs attribute to manually disconnect the vty-server from the vty
- * due to stupid firmware behavior when opening the connection then sending data
- * then then quickly closing the connection would cause data loss on the
- * receiving side.  This required some reordering of the termination code.
- *
- * Fixed the hangup scenario and fixed memory leaks on module_exit.
- *
- * 1.2.0 -> 1.3.0 Moved from manual kernel thread creation & execution to
- * kthread construct which replaced in-kernel IPC for thread termination with
- * kthread_stop and kthread_should_stop.  Explicit wait_queue handling was
- * removed because kthread handles this.  Minor bug fix to postpone partner_info
- * clearing on hvcs_close until adapter removal to preserve context data for
- * printk on partner connection free.  Added lock to protect hvcs_structs so
- * that hvcs_struct instances aren't added or removed during list traversal.
- * Cleaned up comment style, added spaces after commas, and broke function
- * declaration lines to be under 80 columns.
- */
-#define HVCS_DRIVER_VERSION "1.3.0"
-
-MODULE_AUTHOR("Ryan S. Arnold <rsa@us.ibm.com>");
-MODULE_DESCRIPTION("IBM hvcs (Hypervisor Virtual Console Server) Driver");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(HVCS_DRIVER_VERSION);
-
-/*
- * Since the Linux TTY code does not currently (2-04-2004) support dynamic
- * addition of tty derived devices and we shouldn't allocate thousands of
- * tty_device pointers when the number of vty-server & vty partner connections
- * will most often be much lower than this, we'll arbitrarily allocate
- * HVCS_DEFAULT_SERVER_ADAPTERS tty_structs and cdev's by default when we
- * register the tty_driver. This can be overridden using an insmod parameter.
- */
-#define HVCS_DEFAULT_SERVER_ADAPTERS   64
-
-/*
- * The user can't insmod with more than HVCS_MAX_SERVER_ADAPTERS hvcs device
- * nodes as a sanity check.  Theoretically there can be over 1 Billion
- * vty-server & vty partner connections.
- */
-#define HVCS_MAX_SERVER_ADAPTERS       1024
-
-/*
- * We let Linux assign us a major number and we start the minors at zero.  There
- * is no intuitive mapping between minor number and the target partition.  The
- * mapping of minor number is related to the order the vty-servers are exposed
- * to this driver via the hvcs_probe function.
- */
-#define HVCS_MINOR_START       0
-
-/*
- * The hcall interface involves putting 8 chars into each of two registers.
- * We load up those 2 registers (in arch/ppc64/hvconsole.c) by casting char[16]
- * to long[2].  It would work without __ALIGNED__, but a little (tiny) bit
- * slower because an unaligned load is slower than aligned load.
- */
-#define __ALIGNED__    __attribute__((__aligned__(8)))
-
-/* Converged location code string length + 1 null terminator */
-#define CLC_LENGTH             80
-
-/*
- * How much data can firmware send with each hvc_put_chars()?  Maybe this
- * should be moved into an architecture specific area.
- */
-#define HVCS_BUFF_LEN  16
-
-/*
- * This is the maximum amount of data we'll let the user send us (hvcs_write) at
- * once in a chunk as a sanity check.
- */
-#define HVCS_MAX_FROM_USER     4096
-
-/*
- * Be careful when adding flags to this line discipline.  Don't add anything
- * that will cause echoing or we'll go into recursive loop echoing chars back
- * and forth with the console drivers.
- */
-static struct termios hvcs_tty_termios = {
-       .c_iflag = IGNBRK | IGNPAR,
-       .c_oflag = OPOST,
-       .c_cflag = B38400 | CS8 | CREAD | HUPCL,
-       .c_cc = INIT_C_CC
-};
-
-/*
- * This value is used to take the place of a command line parameter when the
- * module is inserted.  It starts as -1 and stays as such if the user doesn't
- * specify a module insmod parameter.  If they DO specify one then it is set to
- * the value of the integer passed in.
- */
-static int hvcs_parm_num_devs = -1;
-module_param(hvcs_parm_num_devs, int, 0);
-
-char hvcs_driver_name[] = "hvcs";
-char hvcs_device_node[] = "hvcs";
-char hvcs_driver_string[]
-       = "IBM hvcs (Hypervisor Virtual Console Server) Driver";
-
-/* Status of partner info rescan triggered via sysfs. */
-static int hvcs_rescan_status = 0;
-
-static struct tty_driver *hvcs_tty_driver;
-
-/*
- * This is used to associate a vty-server, as it is exposed to this driver, with
- * a preallocated tty_struct.index.  The dev node and hvcs index numbers are not
- * re-used after device removal otherwise removing and adding a new one would
- * link a /dev/hvcs* entry to a different vty-server than it did before the
- * removal.  Incidentally, a newly exposed vty-server will always map to an
- * incrementally higher /dev/hvcs* entry than the last exposed vty-server.
- */
-static int hvcs_struct_count = -1;
-
-/*
- * Used by the khvcsd to pick up I/O operations when the kernel_thread is
- * already awake but potentially shifted to TASK_INTERRUPTIBLE state.
- */
-static int hvcs_kicked = 0;
-
-/* Used the the kthread construct for task operations */
-static struct task_struct *hvcs_task;
-
-/*
- * We allocate this for the use of all of the hvcs_structs when they fetch
- * partner info.
- */
-static unsigned long *hvcs_pi_buff;
-
-static spinlock_t hvcs_pi_lock;
-
-/* One vty-server per hvcs_struct */
-struct hvcs_struct {
-       spinlock_t lock;
-
-       /*
-        * This index identifies this hvcs device as the complement to a
-        * specific tty index.
-        */
-       unsigned int index;
-
-       struct tty_struct *tty;
-       unsigned int open_count;
-
-       /*
-        * Used to tell the driver kernel_thread what operations need to take
-        * place upon this hvcs_struct instance.
-        */
-       int todo_mask;
-
-       /*
-        * This buffer is required so that when hvcs_write_room() reports that
-        * it can send HVCS_BUFF_LEN characters that it will buffer the full
-        * HVCS_BUFF_LEN characters if need be.  This is essential for opost
-        * writes since they do not do high level buffering and expect to be
-        * able to send what the driver commits to sending buffering
-        * [e.g. tab to space conversions in n_tty.c opost()].
-        */
-       char buffer[HVCS_BUFF_LEN];
-       int chars_in_buffer;
-
-       /*
-        * Any variable below the kobject is valid before a tty is connected and
-        * stays valid after the tty is disconnected.  These shouldn't be
-        * whacked until the koject refcount reaches zero though some entries
-        * may be changed via sysfs initiatives.
-        */
-       struct kobject kobj; /* ref count & hvcs_struct lifetime */
-       int connected; /* is the vty-server currently connected to a vty? */
-       unsigned int p_unit_address; /* partner unit address */
-       unsigned int p_partition_ID; /* partner partition ID */
-       char p_location_code[CLC_LENGTH];
-       struct list_head next; /* list management */
-       struct vio_dev *vdev;
-};
-
-/* Required to back map a kobject to its containing object */
-#define from_kobj(kobj) container_of(kobj, struct hvcs_struct, kobj)
-
-static struct list_head hvcs_structs = LIST_HEAD_INIT(hvcs_structs);
-static spinlock_t hvcs_structs_lock;
-
-static void hvcs_unthrottle(struct tty_struct *tty);
-static void hvcs_throttle(struct tty_struct *tty);
-static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance,
-               struct pt_regs *regs);
-
-static int hvcs_write(struct tty_struct *tty, int from_user,
-               const unsigned char *buf, int count);
-static int hvcs_write_room(struct tty_struct *tty);
-static int hvcs_chars_in_buffer(struct tty_struct *tty);
-
-static int hvcs_has_pi(struct hvcs_struct *hvcsd);
-static void hvcs_set_pi(struct hvcs_partner_info *pi,
-               struct hvcs_struct *hvcsd);
-static int hvcs_get_pi(struct hvcs_struct *hvcsd);
-static int hvcs_rescan_devices_list(void);
-
-static int hvcs_partner_connect(struct hvcs_struct *hvcsd);
-static void hvcs_partner_free(struct hvcs_struct *hvcsd);
-
-static int hvcs_enable_device(struct hvcs_struct *hvcsd,
-               uint32_t unit_address, unsigned int irq, struct vio_dev *dev);
-static void hvcs_final_close(struct hvcs_struct *hvcsd);
-
-static void destroy_hvcs_struct(struct kobject *kobj);
-static int hvcs_open(struct tty_struct *tty, struct file *filp);
-static void hvcs_close(struct tty_struct *tty, struct file *filp);
-static void hvcs_hangup(struct tty_struct * tty);
-
-static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd);
-static void hvcs_remove_device_attrs(struct vio_dev *vdev);
-static void hvcs_create_driver_attrs(void);
-static void hvcs_remove_driver_attrs(void);
-
-static int __devinit hvcs_probe(struct vio_dev *dev,
-               const struct vio_device_id *id);
-static int __devexit hvcs_remove(struct vio_dev *dev);
-static int __init hvcs_module_init(void);
-static void __exit hvcs_module_exit(void);
-
-#define HVCS_SCHED_READ        0x00000001
-#define HVCS_QUICK_READ        0x00000002
-#define HVCS_TRY_WRITE 0x00000004
-#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ)
-
-static void hvcs_kick(void)
-{
-       hvcs_kicked = 1;
-       wmb();
-       wake_up_process(hvcs_task);
-}
-
-static void hvcs_unthrottle(struct tty_struct *tty)
-{
-       struct hvcs_struct *hvcsd = tty->driver_data;
-       unsigned long flags;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       hvcsd->todo_mask |= HVCS_SCHED_READ;
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       hvcs_kick();
-}
-
-static void hvcs_throttle(struct tty_struct *tty)
-{
-       struct hvcs_struct *hvcsd = tty->driver_data;
-       unsigned long flags;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       vio_disable_interrupts(hvcsd->vdev);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-}
-
-/*
- * If the device is being removed we don't have to worry about this interrupt
- * handler taking any further interrupts because they are disabled which means
- * the hvcs_struct will always be valid in this handler.
- */
-static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance,
-               struct pt_regs *regs)
-{
-       struct hvcs_struct *hvcsd = dev_instance;
-       unsigned long flags;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       vio_disable_interrupts(hvcsd->vdev);
-       hvcsd->todo_mask |= HVCS_SCHED_READ;
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       hvcs_kick();
-
-       return IRQ_HANDLED;
-}
-
-/* This function must be called with the hvcsd->lock held */
-static void hvcs_try_write(struct hvcs_struct *hvcsd)
-{
-       unsigned int unit_address = hvcsd->vdev->unit_address;
-       struct tty_struct *tty = hvcsd->tty;
-       int sent;
-
-       if (hvcsd->todo_mask & HVCS_TRY_WRITE) {
-               /* won't send partial writes */
-               sent = hvc_put_chars(unit_address,
-                               &hvcsd->buffer[0],
-                               hvcsd->chars_in_buffer );
-               if (sent > 0) {
-                       hvcsd->chars_in_buffer = 0;
-                       wmb();
-                       hvcsd->todo_mask &= ~(HVCS_TRY_WRITE);
-                       wmb();
-
-                       /*
-                        * We are still obligated to deliver the data to the
-                        * hypervisor even if the tty has been closed because
-                        * we commited to delivering it.  But don't try to wake
-                        * a non-existent tty.
-                        */
-                       if (tty) {
-                               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP))
-                                               && tty->ldisc.write_wakeup)
-                                       (tty->ldisc.write_wakeup) (tty);
-                               wake_up_interruptible(&tty->write_wait);
-                       }
-               }
-       }
-}
-
-static int hvcs_io(struct hvcs_struct *hvcsd)
-{
-       unsigned int unit_address;
-       struct tty_struct *tty;
-       char buf[HVCS_BUFF_LEN] __ALIGNED__;
-       unsigned long flags;
-       int got;
-       int i;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-
-       unit_address = hvcsd->vdev->unit_address;
-       tty = hvcsd->tty;
-
-       hvcs_try_write(hvcsd);
-
-       if (!tty || test_bit(TTY_THROTTLED, &tty->flags)) {
-               hvcsd->todo_mask &= ~(HVCS_READ_MASK);
-               goto bail;
-       } else if (!(hvcsd->todo_mask & (HVCS_READ_MASK)))
-               goto bail;
-
-       /* remove the read masks */
-       hvcsd->todo_mask &= ~(HVCS_READ_MASK);
-
-       if ((tty->flip.count + HVCS_BUFF_LEN) < TTY_FLIPBUF_SIZE) {
-               got = hvc_get_chars(unit_address,
-                               &buf[0],
-                               HVCS_BUFF_LEN);
-               for (i=0;got && i<got;i++)
-                       tty_insert_flip_char(tty, buf[i], TTY_NORMAL);
-       }
-
-       /* Give the TTY time to process the data we just sent. */
-       if (got)
-               hvcsd->todo_mask |= HVCS_QUICK_READ;
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       if (tty->flip.count) {
-               /* This is synch because tty->low_latency == 1 */
-               tty_flip_buffer_push(tty);
-       }
-
-       if (!got) {
-               /* Do this _after_ the flip_buffer_push */
-               spin_lock_irqsave(&hvcsd->lock, flags);
-               vio_enable_interrupts(hvcsd->vdev);
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-       }
-
-       return hvcsd->todo_mask;
-
- bail:
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return hvcsd->todo_mask;
-}
-
-static int khvcsd(void *unused)
-{
-       struct hvcs_struct *hvcsd = NULL;
-       struct list_head *element;
-       struct list_head *safe_temp;
-       int hvcs_todo_mask;
-       unsigned long structs_flags;
-
-       __set_current_state(TASK_RUNNING);
-
-       do {
-               hvcs_todo_mask = 0;
-               hvcs_kicked = 0;
-               wmb();
-
-               spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
-               list_for_each_safe(element, safe_temp, &hvcs_structs) {
-                       hvcsd = list_entry(element, struct hvcs_struct, next);
-                               hvcs_todo_mask |= hvcs_io(hvcsd);
-               }
-               spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
-
-               /*
-                * If any of the hvcs adapters want to try a write or quick read
-                * don't schedule(), yield a smidgen then execute the hvcs_io
-                * thread again for those that want the write.
-                */
-                if (hvcs_todo_mask & (HVCS_TRY_WRITE | HVCS_QUICK_READ)) {
-                       yield();
-                       continue;
-               }
-
-               set_current_state(TASK_INTERRUPTIBLE);
-               if (!hvcs_kicked)
-                       schedule();
-               __set_current_state(TASK_RUNNING);
-       } while (!kthread_should_stop());
-
-       return 0;
-}
-
-static struct vio_device_id hvcs_driver_table[] __devinitdata= {
-       {"serial-server", "hvterm2"},
-       { 0, }
-};
-MODULE_DEVICE_TABLE(vio, hvcs_driver_table);
-
-/* callback when the kboject ref count reaches zero */
-static void destroy_hvcs_struct(struct kobject *kobj)
-{
-       struct hvcs_struct *hvcsd = from_kobj(kobj);
-       struct vio_dev *vdev;
-       unsigned long flags;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-
-       /* the list_del poisons the pointers */
-       list_del(&(hvcsd->next));
-
-       if (hvcsd->connected == 1) {
-               hvcs_partner_free(hvcsd);
-               printk(KERN_INFO "HVCS: Closed vty-server@%X and"
-                               " partner vty@%X:%d connection.\n",
-                               hvcsd->vdev->unit_address,
-                               hvcsd->p_unit_address,
-                               (unsigned int)hvcsd->p_partition_ID);
-       }
-       printk(KERN_INFO "HVCS: Destroyed hvcs_struct for vty-server@%X.\n",
-                       hvcsd->vdev->unit_address);
-
-       vdev = hvcsd->vdev;
-       hvcsd->vdev = NULL;
-
-       hvcsd->p_unit_address = 0;
-       hvcsd->p_partition_ID = 0;
-       memset(&hvcsd->p_location_code[0], 0x00, CLC_LENGTH);
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-
-       hvcs_remove_device_attrs(vdev);
-
-       kfree(hvcsd);
-}
-
-/* This function must be called with hvcsd->lock held. */
-static void hvcs_final_close(struct hvcs_struct *hvcsd)
-{
-       vio_disable_interrupts(hvcsd->vdev);
-       free_irq(hvcsd->vdev->irq, hvcsd);
-
-       hvcsd->todo_mask = 0;
-
-       /* These two may be redundant if the operation was a close. */
-       if (hvcsd->tty) {
-               hvcsd->tty->driver_data = NULL;
-               hvcsd->tty = NULL;
-       }
-
-       hvcsd->open_count = 0;
-
-       memset(&hvcsd->buffer[0], 0x00, HVCS_BUFF_LEN);
-       hvcsd->chars_in_buffer = 0;
-}
-
-static struct kobj_type hvcs_kobj_type = {
-       .release = destroy_hvcs_struct,
-};
-
-static int __devinit hvcs_probe(
-       struct vio_dev *dev,
-       const struct vio_device_id *id)
-{
-       struct hvcs_struct *hvcsd;
-       unsigned long structs_flags;
-
-       if (!dev || !id) {
-               printk(KERN_ERR "HVCS: probed with invalid parameter.\n");
-               return -EPERM;
-       }
-
-       hvcsd = kmalloc(sizeof(*hvcsd), GFP_KERNEL);
-       if (!hvcsd) {
-               return -ENODEV;
-       }
-
-       /* hvcsd->tty is zeroed out with the memset */
-       memset(hvcsd, 0x00, sizeof(*hvcsd));
-
-       hvcsd->lock = SPIN_LOCK_UNLOCKED;
-       /* Automatically incs the refcount the first time */
-       kobject_init(&hvcsd->kobj);
-       /* Set up the callback for terminating the hvcs_struct's life */
-       hvcsd->kobj.ktype = &hvcs_kobj_type;
-
-       hvcsd->vdev = dev;
-       dev->dev.driver_data = hvcsd;
-
-       hvcsd->index = ++hvcs_struct_count;
-       hvcsd->chars_in_buffer = 0;
-       hvcsd->todo_mask = 0;
-       hvcsd->connected = 0;
-
-       /*
-        * This will populate the hvcs_struct's partner info fields for the
-        * first time.
-        */
-       if (hvcs_get_pi(hvcsd)) {
-               printk(KERN_ERR "HVCS: Failed to fetch partner"
-                       " info for vty-server@%X on device probe.\n",
-                       hvcsd->vdev->unit_address);
-       }
-
-       /*
-        * If a user app opens a tty that corresponds to this vty-server before
-        * the hvcs_struct has been added to the devices list then the user app
-        * will get -ENODEV.
-        */
-
-       spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
-
-       list_add_tail(&(hvcsd->next), &hvcs_structs);
-
-       spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
-
-       hvcs_create_device_attrs(hvcsd);
-
-       printk(KERN_INFO "HVCS: Added vty-server@%X.\n", dev->unit_address);
-
-       /*
-        * DON'T enable interrupts here because there is no user to receive the
-        * data.
-        */
-       return 0;
-}
-
-static int __devexit hvcs_remove(struct vio_dev *dev)
-{
-       struct hvcs_struct *hvcsd = dev->dev.driver_data;
-       unsigned long flags;
-       struct kobject *kobjp;
-       struct tty_struct *tty;
-
-       if (!hvcsd)
-               return -ENODEV;
-
-       /* By this time the vty-server won't be getting any more interrups */
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-
-       tty = hvcsd->tty;
-
-       kobjp = &hvcsd->kobj;
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-
-       /*
-        * Let the last holder of this object cause it to be removed, which
-        * would probably be tty_hangup below.
-        */
-       kobject_put (kobjp);
-
-       /*
-        * The hangup is a scheduled function which will auto chain call
-        * hvcs_hangup.  The tty should always be valid at this time unless a
-        * simultaneous tty close already cleaned up the hvcs_struct.
-        */
-       if (tty)
-               tty_hangup(tty);
-
-       printk(KERN_INFO "HVCS: vty-server@%X removed from the"
-                       " vio bus.\n", dev->unit_address);
-       return 0;
-};
-
-static struct vio_driver hvcs_vio_driver = {
-       .name           = hvcs_driver_name,
-       .id_table       = hvcs_driver_table,
-       .probe          = hvcs_probe,
-       .remove         = hvcs_remove,
-};
-
-/* Only called from hvcs_get_pi please */
-static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd)
-{
-       int clclength;
-
-       hvcsd->p_unit_address = pi->unit_address;
-       hvcsd->p_partition_ID  = pi->partition_ID;
-       clclength = strlen(&pi->location_code[0]);
-       if (clclength > CLC_LENGTH - 1)
-               clclength = CLC_LENGTH - 1;
-
-       /* copy the null-term char too */
-       strncpy(&hvcsd->p_location_code[0],
-                       &pi->location_code[0], clclength + 1);
-}
-
-/*
- * Traverse the list and add the partner info that is found to the hvcs_struct
- * struct entry. NOTE: At this time I know that partner info will return a
- * single entry but in the future there may be multiple partner info entries per
- * vty-server and you'll want to zero out that list and reset it.  If for some
- * reason you have an old version of this driver but there IS more than one
- * partner info then hvcsd->p_* will hold the last partner info data from the
- * firmware query.  A good way to update this code would be to replace the three
- * partner info fields in hvcs_struct with a list of hvcs_partner_info
- * instances.
- *
- * This function must be called with the hvcsd->lock held.
- */
-static int hvcs_get_pi(struct hvcs_struct *hvcsd)
-{
-       /* struct hvcs_partner_info *head_pi = NULL; */
-       struct hvcs_partner_info *pi = NULL;
-       unsigned int unit_address = hvcsd->vdev->unit_address;
-       struct list_head head;
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcs_pi_lock, flags);
-       if (!hvcs_pi_buff) {
-               spin_unlock_irqrestore(&hvcs_pi_lock, flags);
-               return -EFAULT;
-       }
-       retval = hvcs_get_partner_info(unit_address, &head, hvcs_pi_buff);
-       spin_unlock_irqrestore(&hvcs_pi_lock, flags);
-       if (retval) {
-               printk(KERN_ERR "HVCS: Failed to fetch partner"
-                       " info for vty-server@%x.\n", unit_address);
-               return retval;
-       }
-
-       /* nixes the values if the partner vty went away */
-       hvcsd->p_unit_address = 0;
-       hvcsd->p_partition_ID = 0;
-
-       list_for_each_entry(pi, &head, node)
-               hvcs_set_pi(pi, hvcsd);
-
-       hvcs_free_partner_info(&head);
-       return 0;
-}
-
-/*
- * This function is executed by the driver "rescan" sysfs entry.  It shouldn't
- * be executed elsewhere, in order to prevent deadlock issues.
- */
-static int hvcs_rescan_devices_list(void)
-{
-       struct hvcs_struct *hvcsd = NULL;
-       unsigned long flags;
-       unsigned long structs_flags;
-
-       spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
-
-       list_for_each_entry(hvcsd, &hvcs_structs, next) {
-               spin_lock_irqsave(&hvcsd->lock, flags);
-               hvcs_get_pi(hvcsd);
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-       }
-
-       spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
-
-       return 0;
-}
-
-/*
- * Farm this off into its own function because it could be more complex once
- * multiple partners support is added. This function should be called with
- * the hvcsd->lock held.
- */
-static int hvcs_has_pi(struct hvcs_struct *hvcsd)
-{
-       if ((!hvcsd->p_unit_address) || (!hvcsd->p_partition_ID))
-               return 0;
-       return 1;
-}
-
-/*
- * NOTE: It is possible that the super admin removed a partner vty and then
- * added a different vty as the new partner.
- *
- * This function must be called with the hvcsd->lock held.
- */
-static int hvcs_partner_connect(struct hvcs_struct *hvcsd)
-{
-       int retval;
-       unsigned int unit_address = hvcsd->vdev->unit_address;
-
-       /*
-        * If there wasn't any pi when the device was added it doesn't meant
-        * there isn't any now.  This driver isn't notified when a new partner
-        * vty is added to a vty-server so we discover changes on our own.
-        * Please see comments in hvcs_register_connection() for justification
-        * of this bizarre code.
-        */
-       retval = hvcs_register_connection(unit_address,
-                       hvcsd->p_partition_ID,
-                       hvcsd->p_unit_address);
-       if (!retval) {
-               hvcsd->connected = 1;
-               return 0;
-       } else if (retval != -EINVAL)
-               return retval;
-
-       /*
-        * As per the spec re-get the pi and try again if -EINVAL after the
-        * first connection attempt.
-        */
-       if (hvcs_get_pi(hvcsd))
-               return -ENOMEM;
-
-       if (!hvcs_has_pi(hvcsd))
-               return -ENODEV;
-
-       retval = hvcs_register_connection(unit_address,
-                       hvcsd->p_partition_ID,
-                       hvcsd->p_unit_address);
-       if (retval != -EINVAL) {
-               hvcsd->connected = 1;
-               return retval;
-       }
-
-       /*
-        * EBUSY is the most likely scenario though the vty could have been
-        * removed or there really could be an hcall error due to the parameter
-        * data but thanks to ambiguous firmware return codes we can't really
-        * tell.
-        */
-       printk(KERN_INFO "HVCS: vty-server or partner"
-                       " vty is busy.  Try again later.\n");
-       return -EBUSY;
-}
-
-/* This function must be called with the hvcsd->lock held */
-static void hvcs_partner_free(struct hvcs_struct *hvcsd)
-{
-       int retval;
-       do {
-               retval = hvcs_free_connection(hvcsd->vdev->unit_address);
-       } while (retval == -EBUSY);
-       hvcsd->connected = 0;
-}
-
-/* This helper function must be called WITHOUT the hvcsd->lock held */
-static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
-               unsigned int irq, struct vio_dev *vdev)
-{
-       unsigned long flags;
-
-       /*
-        * It is possible that the vty-server was removed between the time that
-        * the conn was registered and now.
-        */
-       if (!request_irq(irq, &hvcs_handle_interrupt,
-                               SA_INTERRUPT, "ibmhvcs", hvcsd)) {
-               /*
-                * It is possible the vty-server was removed after the irq was
-                * requested but before we have time to enable interrupts.
-                */
-               if (vio_enable_interrupts(vdev) == H_Success)
-                       return 0;
-               else {
-                       printk(KERN_ERR "HVCS: int enable failed for"
-                                       " vty-server@%X.\n", unit_address);
-                       free_irq(irq, hvcsd);
-               }
-       } else
-               printk(KERN_ERR "HVCS: irq req failed for"
-                               " vty-server@%X.\n", unit_address);
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       hvcs_partner_free(hvcsd);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-
-       return -ENODEV;
-
-}
-
-/*
- * This always increments the kobject ref count if the call is successful.
- * Please remember to dec when you are done with the instance.
- *
- * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when
- * calling this function or you will get deadlock.
- */
-struct hvcs_struct *hvcs_get_by_index(int index)
-{
-       struct hvcs_struct *hvcsd = NULL;
-       struct list_head *element;
-       struct list_head *safe_temp;
-       unsigned long flags;
-       unsigned long structs_flags;
-
-       spin_lock_irqsave(&hvcs_structs_lock, structs_flags);
-       /* We can immediately discard OOB requests */
-       if (index >= 0 && index < HVCS_MAX_SERVER_ADAPTERS) {
-               list_for_each_safe(element, safe_temp, &hvcs_structs) {
-                       hvcsd = list_entry(element, struct hvcs_struct, next);
-                       spin_lock_irqsave(&hvcsd->lock, flags);
-                       if (hvcsd->index == index) {
-                               kobject_get(&hvcsd->kobj);
-                               spin_unlock_irqrestore(&hvcsd->lock, flags);
-                               spin_unlock_irqrestore(&hvcs_structs_lock,
-                                               structs_flags);
-                               return hvcsd;
-                       }
-                       spin_unlock_irqrestore(&hvcsd->lock, flags);
-               }
-               hvcsd = NULL;
-       }
-
-       spin_unlock_irqrestore(&hvcs_structs_lock, structs_flags);
-       return hvcsd;
-}
-
-/*
- * This is invoked via the tty_open interface when a user app connects to the
- * /dev node.
- */
-static int hvcs_open(struct tty_struct *tty, struct file *filp)
-{
-       struct hvcs_struct *hvcsd = NULL;
-       int retval = 0;
-       unsigned long flags;
-       unsigned int irq;
-       struct vio_dev *vdev;
-       unsigned long unit_address;
-
-       if (tty->driver_data)
-               goto fast_open;
-
-       /*
-        * Is there a vty-server that shares the same index?
-        * This function increments the kobject index.
-        */
-       if (!(hvcsd = hvcs_get_by_index(tty->index))) {
-               printk(KERN_WARNING "HVCS: open failed, no index.\n");
-               return -ENODEV;
-       }
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-
-       if (hvcsd->connected == 0)
-               if ((retval = hvcs_partner_connect(hvcsd)))
-                       goto error_release;
-
-       hvcsd->open_count = 1;
-       hvcsd->tty = tty;
-       tty->driver_data = hvcsd;
-
-       /*
-        * Set this driver to low latency so that we actually have a chance at
-        * catching a throttled TTY after we flip_buffer_push.  Otherwise the
-        * flush_to_async may not execute until after the kernel_thread has
-        * yielded and resumed the next flip_buffer_push resulting in data
-        * loss.
-        */
-       tty->low_latency = 1;
-
-       memset(&hvcsd->buffer[0], 0x3F, HVCS_BUFF_LEN);
-
-       /*
-        * Save these in the spinlock for the enable operations that need them
-        * outside of the spinlock.
-        */
-       irq = hvcsd->vdev->irq;
-       vdev = hvcsd->vdev;
-       unit_address = hvcsd->vdev->unit_address;
-
-       hvcsd->todo_mask |= HVCS_SCHED_READ;
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-
-       /*
-        * This must be done outside of the spinlock because it requests irqs
-        * and will grab the spinlcok and free the connection if it fails.
-        */
-       if ((hvcs_enable_device(hvcsd, unit_address, irq, vdev))) {
-               kobject_put(&hvcsd->kobj);
-               printk(KERN_WARNING "HVCS: enable device failed.\n");
-               return -ENODEV;
-       }
-
-       goto open_success;
-
-fast_open:
-       hvcsd = tty->driver_data;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       if (!kobject_get(&hvcsd->kobj)) {
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-               printk(KERN_ERR "HVCS: Kobject of open"
-                       " hvcs doesn't exist.\n");
-               return -EFAULT; /* Is this the right return value? */
-       }
-
-       hvcsd->open_count++;
-
-       hvcsd->todo_mask |= HVCS_SCHED_READ;
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-open_success:
-       hvcs_kick();
-
-       printk(KERN_INFO "HVCS: vty-server@%X opened.\n",
-               hvcsd->vdev->unit_address );
-
-       return 0;
-
-error_release:
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       kobject_put(&hvcsd->kobj);
-
-       printk(KERN_WARNING "HVCS: HVCS partner connect failed.\n");
-       return retval;
-}
-
-static void hvcs_close(struct tty_struct *tty, struct file *filp)
-{
-       struct hvcs_struct *hvcsd;
-       unsigned long flags;
-       struct kobject *kobjp;
-
-       /*
-        * Is someone trying to close the file associated with this device after
-        * we have hung up?  If so tty->driver_data wouldn't be valid.
-        */
-       if (tty_hung_up_p(filp))
-               return;
-
-       /*
-        * No driver_data means that this close was probably issued after a
-        * failed hvcs_open by the tty layer's release_dev() api and we can just
-        * exit cleanly.
-        */
-       if (!tty->driver_data)
-               return;
-
-       hvcsd = tty->driver_data;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       if (--hvcsd->open_count == 0) {
-
-               /*
-                * This line is important because it tells hvcs_open that this
-                * device needs to be re-configured the next time hvcs_open is
-                * called.
-                */
-               hvcsd->tty->driver_data = NULL;
-
-               /*
-                * NULL this early so that the kernel_thread doesn't try to
-                * execute any operations on the TTY even though it is obligated
-                * to deliver any pending I/O to the hypervisor.
-                */
-               hvcsd->tty = NULL;
-
-               /*
-                * Block the close until all the buffered data has been
-                * delivered.
-                */
-               while(hvcsd->chars_in_buffer) {
-                       spin_unlock_irqrestore(&hvcsd->lock, flags);
-
-                       /*
-                        * Give the kernel thread the hvcs_struct so that it can
-                        * try to deliver the remaining data but block the close
-                        * operation by spinning in this function so that other
-                        * tty operations have to wait.
-                        */
-                       yield();
-                       spin_lock_irqsave(&hvcsd->lock, flags);
-               }
-
-               hvcs_final_close(hvcsd);
-
-       } else if (hvcsd->open_count < 0) {
-               printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
-                               " is missmanaged.\n",
-                       hvcsd->vdev->unit_address, hvcsd->open_count);
-       }
-       kobjp = &hvcsd->kobj;
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-
-       kobject_put(kobjp);
-}
-
-static void hvcs_hangup(struct tty_struct * tty)
-{
-       struct hvcs_struct *hvcsd = tty->driver_data;
-       unsigned long flags;
-       int temp_open_count;
-       struct kobject *kobjp;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       /* Preserve this so that we know how many kobject refs to put */
-       temp_open_count = hvcsd->open_count;
-
-       /*
-        * Don't kobject put inside the spinlock because the destruction
-        * callback may use the spinlock and it may get called before the
-        * spinlock has been released.  Get a pointer to the kobject and
-        * kobject_put on that instead.
-        */
-       kobjp = &hvcsd->kobj;
-
-       /* Calling this will drop any buffered data on the floor. */
-       hvcs_final_close(hvcsd);
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-
-       /*
-        * We need to kobject_put() for every open_count we have since the
-        * tty_hangup() function doesn't invoke a close per open connection on a
-        * non-console device.
-        */
-       while(temp_open_count) {
-               --temp_open_count;
-               /*
-                * The final put will trigger destruction of the hvcs_struct.
-                * NOTE:  If this hangup was signaled from user space then the
-                * final put will never happen.
-                */
-               kobject_put(kobjp);
-       }
-}
-
-/*
- * NOTE: This is almost always from_user since user level apps interact with the
- * /dev nodes. I'm trusting that if hvcs_write gets called and interrupted by
- * hvcs_remove (which removes the target device and executes tty_hangup()) that
- * tty_hangup will allow hvcs_write time to complete execution before it
- * terminates our device.
- */
-static int hvcs_write(struct tty_struct *tty, int from_user,
-               const unsigned char *buf, int count)
-{
-       struct hvcs_struct *hvcsd = tty->driver_data;
-       unsigned int unit_address;
-       unsigned char *charbuf;
-       unsigned long flags;
-       int total_sent = 0;
-       int tosend = 0;
-       int result = 0;
-
-       /*
-        * If they don't check the return code off of their open they may
-        * attempt this even if there is no connected device.
-        */
-       if (!hvcsd)
-               return -ENODEV;
-
-       /* Reasonable size to prevent user level flooding */
-       if (count > HVCS_MAX_FROM_USER) {
-               printk(KERN_WARNING "HVCS write: count being truncated to"
-                               " HVCS_MAX_FROM_USER.\n");
-               count = HVCS_MAX_FROM_USER;
-       }
-
-       if (!from_user)
-               charbuf = (unsigned char *)buf;
-       else {
-               charbuf = kmalloc(count, GFP_KERNEL);
-               if (!charbuf) {
-                       printk(KERN_WARNING "HVCS: write -ENOMEM.\n");
-                       return -ENOMEM;
-               }
-
-               if (copy_from_user(charbuf, buf, count)) {
-                       kfree(charbuf);
-                       printk(KERN_WARNING "HVCS: write -EFAULT.\n");
-                       return -EFAULT;
-               }
-       }
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-
-       /*
-        * Somehow an open succedded but the device was removed or the
-        * connection terminated between the vty-server and partner vty during
-        * the middle of a write operation?  This is a crummy place to do this
-        * but we want to keep it all in the spinlock.
-        */
-       if (hvcsd->open_count <= 0) {
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-               if (from_user)
-                       kfree(charbuf);
-               return -ENODEV;
-       }
-
-       unit_address = hvcsd->vdev->unit_address;
-
-       while (count > 0) {
-               tosend = min(count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer));
-               /*
-                * No more space, this probably means that the last call to
-                * hvcs_write() didn't succeed and the buffer was filled up.
-                */
-               if (!tosend)
-                       break;
-
-               memcpy(&hvcsd->buffer[hvcsd->chars_in_buffer],
-                               &charbuf[total_sent],
-                               tosend);
-
-               hvcsd->chars_in_buffer += tosend;
-
-               result = 0;
-
-               /*
-                * If this is true then we don't want to try writing to the
-                * hypervisor because that is the kernel_threads job now.  We'll
-                * just add to the buffer.
-                */
-               if (!(hvcsd->todo_mask & HVCS_TRY_WRITE))
-                       /* won't send partial writes */
-                       result = hvc_put_chars(unit_address,
-                                       &hvcsd->buffer[0],
-                                       hvcsd->chars_in_buffer);
-
-               /*
-                * Since we know we have enough room in hvcsd->buffer for
-                * tosend we record that it was sent regardless of whether the
-                * hypervisor actually took it because we have it buffered.
-                */
-               total_sent+=tosend;
-               count-=tosend;
-               if (result == 0) {
-                       hvcsd->todo_mask |= HVCS_TRY_WRITE;
-                       hvcs_kick();
-                       break;
-               }
-
-               hvcsd->chars_in_buffer = 0;
-               /*
-                * Test after the chars_in_buffer reset otherwise this could
-                * deadlock our writes if hvc_put_chars fails.
-                */
-               if (result < 0)
-                       break;
-       }
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       if (from_user)
-               kfree(charbuf);
-
-       if (result == -1)
-               return -EIO;
-       else
-               return total_sent;
-}
-
-/*
- * This is really asking how much can we guarentee that we can send or that we
- * absolutely WILL BUFFER if we can't send it.  This driver MUST honor the
- * return value, hence the reason for hvcs_struct buffering.
- */
-static int hvcs_write_room(struct tty_struct *tty)
-{
-       struct hvcs_struct *hvcsd = tty->driver_data;
-       unsigned long flags;
-       int retval;
-
-       if (!hvcsd || hvcsd->open_count <= 0)
-               return 0;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-
-static int hvcs_chars_in_buffer(struct tty_struct *tty)
-{
-       struct hvcs_struct *hvcsd = tty->driver_data;
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = hvcsd->chars_in_buffer;
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-
-static struct tty_operations hvcs_ops = {
-       .open = hvcs_open,
-       .close = hvcs_close,
-       .hangup = hvcs_hangup,
-       .write = hvcs_write,
-       .write_room = hvcs_write_room,
-       .chars_in_buffer = hvcs_chars_in_buffer,
-       .unthrottle = hvcs_unthrottle,
-       .throttle = hvcs_throttle,
-};
-
-static int __init hvcs_module_init(void)
-{
-       int rc;
-       int num_ttys_to_alloc;
-
-       printk(KERN_INFO "Initializing %s\n", hvcs_driver_string);
-
-       /* Has the user specified an overload with an insmod param? */
-       if (hvcs_parm_num_devs <= 0 ||
-               (hvcs_parm_num_devs > HVCS_MAX_SERVER_ADAPTERS)) {
-               num_ttys_to_alloc = HVCS_DEFAULT_SERVER_ADAPTERS;
-       } else
-               num_ttys_to_alloc = hvcs_parm_num_devs;
-
-       hvcs_tty_driver = alloc_tty_driver(num_ttys_to_alloc);
-       if (!hvcs_tty_driver)
-               return -ENOMEM;
-
-       hvcs_tty_driver->owner = THIS_MODULE;
-
-       hvcs_tty_driver->driver_name = hvcs_driver_name;
-       hvcs_tty_driver->name = hvcs_device_node;
-
-       /*
-        * We'll let the system assign us a major number, indicated by leaving
-        * it blank.
-        */
-
-       hvcs_tty_driver->minor_start = HVCS_MINOR_START;
-       hvcs_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
-
-       /*
-        * We role our own so that we DONT ECHO.  We can't echo because the
-        * device we are connecting to already echoes by default and this would
-        * throw us into a horrible recursive echo-echo-echo loop.
-        */
-       hvcs_tty_driver->init_termios = hvcs_tty_termios;
-       hvcs_tty_driver->flags = TTY_DRIVER_REAL_RAW;
-
-       tty_set_operations(hvcs_tty_driver, &hvcs_ops);
-
-       /*
-        * The following call will result in sysfs entries that denote the
-        * dynamically assigned major and minor numbers for our devices.
-        */
-       if (tty_register_driver(hvcs_tty_driver)) {
-               printk(KERN_ERR "HVCS: registration "
-                       " as a tty driver failed.\n");
-               put_tty_driver(hvcs_tty_driver);
-               return rc;
-       }
-
-       hvcs_structs_lock = SPIN_LOCK_UNLOCKED;
-
-       hvcs_pi_lock = SPIN_LOCK_UNLOCKED;
-       hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL);
-
-       hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
-       if (IS_ERR(hvcs_task)) {
-               printk("khvcsd creation failed.  Driver not loaded.\n");
-               kfree(hvcs_pi_buff);
-               put_tty_driver(hvcs_tty_driver);
-               return -EIO;
-       }
-
-       rc = vio_register_driver(&hvcs_vio_driver);
-
-       /*
-        * This needs to be done AFTER the vio_register_driver() call or else
-        * the kobjects won't be initialized properly.
-        */
-       hvcs_create_driver_attrs();
-
-       printk(KERN_INFO "HVCS: driver module inserted.\n");
-
-       return rc;
-}
-
-static void __exit hvcs_module_exit(void)
-{
-       unsigned long flags;
-
-       /*
-        * This driver receives hvcs_remove callbacks for each device upon
-        * module removal.
-        */
-
-       /*
-        * This synchronous operation  will wake the khvcsd kthread if it is
-        * asleep and will return when khvcsd has terminated.
-        */
-       kthread_stop(hvcs_task);
-
-       spin_lock_irqsave(&hvcs_pi_lock, flags);
-       kfree(hvcs_pi_buff);
-       hvcs_pi_buff = NULL;
-       spin_unlock_irqrestore(&hvcs_pi_lock, flags);
-
-       hvcs_remove_driver_attrs();
-
-       vio_unregister_driver(&hvcs_vio_driver);
-
-       tty_unregister_driver(hvcs_tty_driver);
-
-       put_tty_driver(hvcs_tty_driver);
-
-       printk(KERN_INFO "HVCS: driver module removed.\n");
-}
-
-module_init(hvcs_module_init);
-module_exit(hvcs_module_exit);
-
-static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
-{
-       return viod->dev.driver_data;
-}
-/* The sysfs interface for the driver and devices */
-
-static ssize_t hvcs_partner_vtys_show(struct device *dev, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
-
-static ssize_t hvcs_partner_clcs_show(struct device *dev, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
-
-static ssize_t hvcs_current_vty_store(struct device *dev, const char * buf,
-               size_t count)
-{
-       /*
-        * Don't need this feature at the present time because firmware doesn't
-        * yet support multiple partners.
-        */
-       printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
-       return -EPERM;
-}
-
-static ssize_t hvcs_current_vty_show(struct device *dev, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-
-static DEVICE_ATTR(current_vty,
-       S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
-
-static ssize_t hvcs_vterm_state_store(struct device *dev, const char *buf,
-               size_t count)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-
-       /* writing a '0' to this sysfs entry will result in the disconnect. */
-       if (simple_strtol(buf, NULL, 0) != 0)
-               return -EINVAL;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-
-       if (hvcsd->open_count > 0) {
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-               printk(KERN_INFO "HVCS: vterm state unchanged.  "
-                               "The hvcs device node is still in use.\n");
-               return -EPERM;
-       }
-
-       if (hvcsd->connected == 0) {
-               spin_unlock_irqrestore(&hvcsd->lock, flags);
-               printk(KERN_INFO "HVCS: vterm state unchanged. The"
-                               " vty-server is not connected to a vty.\n");
-               return -EPERM;
-       }
-
-       hvcs_partner_free(hvcsd);
-       printk(KERN_INFO "HVCS: Closed vty-server@%X and"
-                       " partner vty@%X:%d connection.\n",
-                       hvcsd->vdev->unit_address,
-                       hvcsd->p_unit_address,
-                       (unsigned int)hvcsd->p_partition_ID);
-
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return count;
-}
-
-static ssize_t hvcs_vterm_state_show(struct device *dev, char *buf)
-{
-       struct vio_dev *viod = to_vio_dev(dev);
-       struct hvcs_struct *hvcsd = from_vio_dev(viod);
-       unsigned long flags;
-       int retval;
-
-       spin_lock_irqsave(&hvcsd->lock, flags);
-       retval = sprintf(buf, "%d\n", hvcsd->connected);
-       spin_unlock_irqrestore(&hvcsd->lock, flags);
-       return retval;
-}
-static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
-               hvcs_vterm_state_show, hvcs_vterm_state_store);
-
-static struct attribute *hvcs_attrs[] = {
-       &dev_attr_partner_vtys.attr,
-       &dev_attr_partner_clcs.attr,
-       &dev_attr_current_vty.attr,
-       &dev_attr_vterm_state.attr,
-       NULL,
-};
-
-static struct attribute_group hvcs_attr_group = {
-       .attrs = hvcs_attrs,
-};
-
-static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd)
-{
-       struct vio_dev *vdev = hvcsd->vdev;
-       sysfs_create_group(&vdev->dev.kobj, &hvcs_attr_group);
-}
-
-static void hvcs_remove_device_attrs(struct vio_dev *vdev)
-{
-       sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
-}
-
-static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
-{
-       /* A 1 means it is updating, a 0 means it is done updating */
-       return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
-}
-
-static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
-               size_t count)
-{
-       if ((simple_strtol(buf, NULL, 0) != 1)
-               && (hvcs_rescan_status != 0))
-               return -EINVAL;
-
-       hvcs_rescan_status = 1;
-       printk(KERN_INFO "HVCS: rescanning partner info for all"
-               " vty-servers.\n");
-       hvcs_rescan_devices_list();
-       hvcs_rescan_status = 0;
-       return count;
-}
-static DRIVER_ATTR(rescan,
-       S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
-
-static void hvcs_create_driver_attrs(void)
-{
-       struct device_driver *driverfs = &(hvcs_vio_driver.driver);
-       driver_create_file(driverfs, &driver_attr_rescan);
-}
-
-static void hvcs_remove_driver_attrs(void)
-{
-       struct device_driver *driverfs = &(hvcs_vio_driver.driver);
-       driver_remove_file(driverfs, &driver_attr_rescan);
-}
index 6110dbf..945a258 100644 (file)
@@ -225,8 +225,8 @@ static void lp_error (int minor)
 
        polling = lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE;
        if (polling) lp_release_parport (&lp_table[minor]);
-       interruptible_sleep_on_timeout (&lp_table[minor].waitq,
-                                       LP_TIMEOUT_POLLED);
+       set_current_state(TASK_INTERRUPTIBLE);
+       schedule_timeout(LP_TIMEOUT_POLLED);
        if (polling) lp_claim_parport_or_block (&lp_table[minor]);
        else parport_yield_blocking (lp_table[minor].dev);
 }
diff --git a/drivers/char/lp_old98.c b/drivers/char/lp_old98.c
deleted file mode 100644 (file)
index 895ca1d..0000000
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- *     linux/drivers/char/lp_old98.c
- *
- * printer port driver for ancient PC-9800s with no bidirectional port support
- *
- * Copyright (C)  1998,99  Kousuke Takai <tak@kmc.kyoto-u.ac.jp>,
- *                        Kyoto University Microcomputer Club
- *
- * This driver is based on and has compatibility with `lp.c',
- * generic PC printer port driver.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/config.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/console.h>
-#include <linux/fs.h>
-
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/lp.h>
-
-/*
- *  I/O port numbers
- */
-#define        LP_PORT_DATA    0x40
-#define        LP_PORT_STATUS  (LP_PORT_DATA + 2)
-#define        LP_PORT_STROBE  (LP_PORT_DATA + 4)
-#define LP_PORT_CONTROL        (LP_PORT_DATA + 6)
-
-#define        LP_PORT_H98MODE 0x0448
-#define        LP_PORT_EXTMODE 0x0149
-
-/*
- *  bit mask for I/O
- */
-#define        LP_MASK_nBUSY   (1 << 2)
-#define        LP_MASK_nSTROBE (1 << 7)
-
-#define LP_CONTROL_ASSERT_STROBE       (0x0e)
-#define LP_CONTROL_NEGATE_STROBE       (0x0f)
-
-/*
- *  Acceptable maximum value for non-privileged user for LPCHARS ioctl.
- */
-#define LP_CHARS_NOPRIV_MAX    65535
-
-#define        DC1     '\x11'
-#define        DC3     '\x13'
-
-/* PC-9800s have at least and at most one old-style printer port. */
-static struct lp_struct lp = {
-       .flags  = LP_EXIST | LP_ABORTOPEN,
-       .chars  = LP_INIT_CHAR,
-       .time   = LP_INIT_TIME,
-       .wait   = LP_INIT_WAIT,
-};
-
-static int     dc1_check;
-static spinlock_t lp_old98_lock = SPIN_LOCK_UNLOCKED;
-
-
-#undef LP_OLD98_DEBUG
-
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-static struct console lp_old98_console;                /* defined later */
-static short saved_console_flags;
-#endif
-
-static DECLARE_WAIT_QUEUE_HEAD (lp_old98_waitq);
-
-static void lp_old98_timer_function(unsigned long data)
-{
-       if (inb(LP_PORT_STATUS) & LP_MASK_nBUSY)
-               wake_up_interruptible(&lp_old98_waitq);
-       else {
-               struct timer_list *t = (struct timer_list *) data;
-
-               t->expires = jiffies + 1;
-               add_timer(t);
-       }
-}
-
-static inline int lp_old98_wait_ready(void)
-{
-       struct timer_list timer;
-
-       init_timer(&timer);
-       timer.function = lp_old98_timer_function;
-       timer.expires = jiffies + 1;
-       timer.data = (unsigned long)&timer;
-       add_timer(&timer);
-       interruptible_sleep_on(&lp_old98_waitq);
-       del_timer(&timer);
-       return signal_pending(current);
-}
-
-static inline int lp_old98_char(char lpchar)
-{
-       unsigned long count = 0;
-#ifdef LP_STATS
-       int tmp;
-#endif
-
-       while (!(inb(LP_PORT_STATUS) & LP_MASK_nBUSY)) {
-               count++;
-               if (count >= lp.chars)
-                       return 0;
-       }
-
-       outb(lpchar, LP_PORT_DATA);
-
-#ifdef LP_STATS
-       /*
-        *  Update lp statsistics here (and between next two outb()'s).
-        *  Time to compute it is part of storobe delay.
-        */
-       if (count > lp.stats.maxwait) {
-#ifdef LP_OLD98_DEBUG
-               printk(KERN_DEBUG "lp_old98: success after %d counts.\n",
-                      count);
-#endif
-               lp.stats.maxwait = count;
-       }
-       count *= 256;
-       tmp = count - lp.stats.meanwait;
-       if (tmp < 0)
-               tmp = -tmp;
-#endif
-       ndelay(lp.wait);
-    
-       /* negate PSTB# (activate strobe)       */
-       outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL);
-
-#ifdef LP_STATS
-       lp.stats.meanwait = (255 * lp.stats.meanwait + count + 128) / 256;
-       lp.stats.mdev = (127 * lp.stats.mdev + tmp + 64) / 128;
-       lp.stats.chars ++;
-#endif
-
-       ndelay(lp.wait);
-
-       /* assert PSTB# (deactivate strobe)     */
-       outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL);
-
-       return 1;
-}
-
-static ssize_t lp_old98_write(struct file * file,
-                             const char * buf, size_t count,
-                             loff_t *dummy)
-{
-       unsigned long total_bytes_written = 0;
-
-       if (!access_ok(VERIFY_READ, buf, count))
-               return -EFAULT;
-
-#ifdef LP_STATS
-       if (jiffies - lp.lastcall > lp.time)
-               lp.runchars = 0;
-       lp.lastcall = jiffies;
-#endif
-
-       do {
-               unsigned long bytes_written = 0;
-               unsigned long copy_size
-                       = (count < LP_BUFFER_SIZE ? count : LP_BUFFER_SIZE);
-
-               if (__copy_from_user(lp.lp_buffer, buf, copy_size))
-                       return -EFAULT;
-
-               while (bytes_written < copy_size) {
-                       if (lp_old98_char(lp.lp_buffer[bytes_written]))
-                               bytes_written ++;
-                       else {
-#ifdef LP_STATS
-                               int rc = lp.runchars + bytes_written;
-
-                               if (rc > lp.stats.maxrun)
-                                       lp.stats.maxrun = rc;
-
-                               lp.stats.sleeps ++;
-#endif
-#ifdef LP_OLD98_DEBUG
-                               printk(KERN_DEBUG
-                                      "lp_old98: sleeping at %d characters"
-                                      " for %d jiffies\n",
-                                      lp.runchars, lp.time);
-                               lp.runchars = 0;
-#endif
-                               if (lp_old98_wait_ready())
-                                       return ((total_bytes_written
-                                                + bytes_written)
-                                               ? : -EINTR);
-                       }
-               }
-               total_bytes_written += bytes_written;
-               buf += bytes_written;
-#ifdef LP_STATS
-               lp.runchars += bytes_written;
-#endif
-               count -= bytes_written;
-       } while (count > 0);
-
-       return total_bytes_written;
-}
-
-static int lp_old98_open(struct inode * inode, struct file * file)
-{
-       if (iminor(inode) != 0)
-               return -ENXIO;
-
-       if (lp.flags & LP_BUSY)
-               return -EBUSY;
-
-       if (dc1_check && (lp.flags & LP_ABORTOPEN)
-           && !(file->f_flags & O_NONBLOCK)) {
-               /*
-                *  Check whether printer is on-line.
-                *  PC-9800's old style port have only BUSY# as status input,
-                *  so that it is impossible to distinguish that the printer is
-                *  ready and that the printer is off-line or not connected
-                *  (in both case BUSY# is in the same state). So:
-                *
-                *    (1) output DC1 (0x11) to printer port and do strobe.
-                *    (2) watch BUSY# line for a while. If BUSY# is pulled
-                *        down, the printer will be ready. Otherwise,
-                *        it will be off-line (or not connected, or power-off,
-                *         ...).
-                *
-                *  The source of this procedure:
-                *      Terumasa KODAKA, Kazufumi SHIMIZU, Yu HAYAMI:
-                *              `PC-9801 Super Technique', Ascii, 1992.
-                */
-               int count;
-               unsigned long flags;
-
-               /* interrupts while check is fairly bad */
-               spin_lock_irqsave(&lp_old98_lock, flags);
-
-               if (!lp_old98_char(DC1)) {
-                       spin_unlock_irqrestore(&lp_old98_lock, flags);
-                       return -EBUSY;
-               }
-               count = (unsigned int)dc1_check > 10000 ? 10000 : dc1_check;
-               while (inb(LP_PORT_STATUS) & LP_MASK_nBUSY) {
-                       if (--count == 0) {
-                               spin_unlock_irqrestore(&lp_old98_lock, flags);
-                               return -ENODEV;
-                       }
-               }
-               spin_unlock_irqrestore(&lp_old98_lock, flags);
-       }
-
-       if ((lp.lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL)) == NULL)
-               return -ENOMEM;
-
-       lp.flags |= LP_BUSY;
-
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-       saved_console_flags = lp_old98_console.flags;
-       lp_old98_console.flags &= ~CON_ENABLED;
-#endif
-       return 0;
-}
-
-static int lp_old98_release(struct inode * inode, struct file * file)
-{
-       kfree(lp.lp_buffer);
-       lp.lp_buffer = NULL;
-       lp.flags &= ~LP_BUSY;
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-       lp_old98_console.flags = saved_console_flags;
-#endif
-       return 0;
-}
-
-static int lp_old98_init_device(void)
-{
-       unsigned char data;
-
-       if ((data = inb(LP_PORT_EXTMODE)) != 0xFF && (data & 0x10)) {
-               printk(KERN_INFO
-                      "lp_old98: shutting down extended parallel port mode...\n");
-               outb(data & ~0x10, LP_PORT_EXTMODE);
-       }
-#ifdef PC98_HW_H98
-       if ((pc98_hw_flags & PC98_HW_H98)
-           && ((data = inb(LP_PORT_H98MODE)) & 0x01)) {
-               printk(KERN_INFO
-                      "lp_old98: shutting down H98 full centronics mode...\n");
-               outb(data & ~0x01, LP_PORT_H98MODE);
-       }
-#endif
-       return 0;
-}
-
-static int lp_old98_ioctl(struct inode *inode, struct file *file,
-                         unsigned int command, unsigned long arg)
-{
-       int retval = 0;
-
-       switch (command) {
-       case LPTIME:
-               lp.time = arg * HZ/100;
-               break;
-       case LPCHAR:
-               lp.chars = arg;
-               break;
-       case LPABORT:
-               if (arg)
-                       lp.flags |= LP_ABORT;
-               else
-                       lp.flags &= ~LP_ABORT;
-               break;
-       case LPABORTOPEN:
-               if (arg)
-                       lp.flags |= LP_ABORTOPEN;
-               else
-                       lp.flags &= ~LP_ABORTOPEN;
-               break;
-       case LPCAREFUL:
-               /* do nothing */
-               break;
-       case LPWAIT:
-               lp.wait = arg;
-               break;
-       case LPGETIRQ:
-               retval = put_user(0, (int *)arg);
-               break;
-       case LPGETSTATUS:
-               /*
-                * convert PC-9800's status to IBM PC's one, so that tunelp(8)
-                * works in the same way on this driver.
-                */
-               retval = put_user((inb(LP_PORT_STATUS) & LP_MASK_nBUSY)
-                                       ? (LP_PBUSY | LP_PERRORP) : LP_PERRORP,
-                                       (int *)arg);
-               break;
-       case LPRESET:
-               retval = lp_old98_init_device();
-               break;
-#ifdef LP_STATS
-       case LPGETSTATS:
-               if (copy_to_user((struct lp_stats *)arg, &lp.stats,
-                                sizeof(struct lp_stats)))
-                       retval = -EFAULT;
-               else if (suser())
-                       memset(&lp.stats, 0, sizeof(struct lp_stats));
-               break;
-#endif
-       case LPGETFLAGS:
-               retval = put_user(lp.flags, (int *)arg);
-               break;
-       case LPSETIRQ: 
-       default:
-               retval = -EINVAL;
-       }
-       return retval;
-}
-
-static struct file_operations lp_old98_fops = {
-       .owner          = THIS_MODULE,
-       .write          = lp_old98_write,
-       .ioctl          = lp_old98_ioctl,
-       .open           = lp_old98_open,
-       .release        = lp_old98_release,
-};
-
-/*
- *  Support for console on lp_old98
- */
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-
-static inline void io_delay(void)
-{
-       unsigned char dummy;    /* actually not output */
-
-       asm volatile ("out%B0 %0,%1" : "=a"(dummy) : "N"(0x5f));
-}
-
-static void lp_old98_console_write(struct console *console,
-                                   const char *s, unsigned int count)
-{
-       int i;
-       static unsigned int timeout_run = 0;
-
-       while (count) {
-               /* wait approx 1.2 seconds */
-               for (i = 2000000; !(inb(LP_PORT_STATUS) & LP_MASK_nBUSY);
-                                                               io_delay())
-                       if (!--i) {
-                               if (++timeout_run >= 10)
-                                       /* disable forever... */
-                                       console->flags &= ~CON_ENABLED;
-                               return;
-                       }
-
-               timeout_run = 0;
-
-               if (*s == '\n') {
-                       outb('\r', LP_PORT_DATA);
-                       io_delay();
-                       io_delay();
-                       outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL);
-                       io_delay();
-                       io_delay();
-                       outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL);
-                       io_delay();
-                       io_delay();
-                       for (i = 1000000;
-                                       !(inb(LP_PORT_STATUS) & LP_MASK_nBUSY);
-                                       io_delay())
-                               if (!--i)
-                                       return;
-               }
-
-               outb(*s++, LP_PORT_DATA);
-               io_delay();
-               io_delay();
-               outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL);
-               io_delay();
-               io_delay();
-               outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL);
-               io_delay();
-               io_delay();
-
-               --count;
-       }
-}
-
-static struct console lp_old98_console = {
-       .name   = "lp_old98",
-       .write  = lp_old98_console_write,
-       .flags  = CON_PRINTBUFFER,
-       .index  = -1,
-};
-
-#endif /* console on lp_old98 */
-
-static int __init lp_old98_init(void)
-{
-       char *errmsg = "I/O ports already occupied, giving up.";
-
-#ifdef PC98_HW_H98
-       if (pc98_hw_flags & PC98_HW_H98)
-           if (!request_region(LP_PORT_H98MODE, 1, "lp_old98")
-               goto err1;
-#endif
-       if (!request_region(LP_PORT_DATA,   1, "lp_old98"))
-               goto err2;
-       if (!request_region(LP_PORT_STATUS, 1, "lp_old98"))
-               goto err3;
-       if (!request_region(LP_PORT_STROBE, 1, "lp_old98"))
-               goto err4;
-       if (!request_region(LP_PORT_EXTMODE, 1, "lp_old98"))
-               goto err5;
-       if (!register_chrdev(LP_MAJOR, "lp", &lp_old98_fops)) {
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-               register_console(&lp_old98_console);
-               printk(KERN_INFO "lp_old98: console ready\n");
-#endif
-               /*
-                * rest are not needed by this driver,
-                * but for locking out other printer drivers...
-                */
-               lp_old98_init_device();
-               return 0;
-       } else
-               errmsg = "unable to register device";
-
-       release_region(LP_PORT_EXTMODE, 1);
-err5:
-       release_region(LP_PORT_STROBE, 1);
-err4:
-       release_region(LP_PORT_STATUS, 1);
-err3:
-       release_region(LP_PORT_DATA, 1);
-err2:
-#ifdef PC98_HW_H98
-       if (pc98_hw_flags & PC98_HW_H98)
-           release_region(LP_PORT_H98MODE, 1);
-
-err1:
-#endif
-       printk(KERN_ERR "lp_old98: %s\n", errmsg);
-       return -EBUSY;
-}
-
-static void __exit lp_old98_exit(void)
-{
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-       unregister_console(&lp_old98_console);
-#endif
-       unregister_chrdev(LP_MAJOR, "lp");
-
-       release_region(LP_PORT_DATA,   1);
-       release_region(LP_PORT_STATUS, 1);
-       release_region(LP_PORT_STROBE, 1);
-#ifdef PC98_HW_H98
-       if (pc98_hw_flags & PC98_HW_H98)
-               release_region(LP_PORT_H98MODE, 1);
-#endif
-       release_region(LP_PORT_EXTMODE, 1);
-}
-
-#ifndef MODULE
-static int __init lp_old98_setup(char *str)
-{
-        int ints[4];
-
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0)
-               dc1_check = ints[1];
-        return 1;
-}
-__setup("lp_old98_dc1_check=", lp_old98_setup);
-#endif
-
-MODULE_PARM(dc1_check, "i");
-MODULE_AUTHOR("Kousuke Takai <tak@kmc.kyoto-u.ac.jp>");
-MODULE_DESCRIPTION("PC-9800 old printer port driver");
-MODULE_LICENSE("GPL");
-
-module_init(lp_old98_init);
-module_exit(lp_old98_exit);
index 3274c3a..8b86d01 100644 (file)
@@ -114,6 +114,18 @@ static inline int valid_phys_addr_range(unsigned long addr, size_t *count)
 }
 #endif
 
+static inline int range_is_allowed(unsigned long from, unsigned long to)
+{
+       unsigned long cursor;
+       
+       cursor = from >> PAGE_SHIFT;
+       while ((cursor << PAGE_SHIFT) < to) {
+               if (!devmem_is_allowed(cursor))
+                       return 0;
+               cursor++;
+       }
+       return 1;
+}
 static ssize_t do_write_mem(void *p, unsigned long realp,
                            const char __user * buf, size_t count, loff_t *ppos)
 {
@@ -133,6 +145,8 @@ static ssize_t do_write_mem(void *p, unsigned long realp,
                written+=sz;
        }
 #endif
+       if (!range_is_allowed(realp, realp+count))
+               return -EPERM;
        copied = copy_from_user(p, buf, count);
        if (copied) {
                ssize_t ret = written + (count - copied);
@@ -176,6 +190,8 @@ static ssize_t read_mem(struct file * file, char __user * buf,
                }
        }
 #endif
+       if (!range_is_allowed(p, p+count))
+               return -EPERM;
        if (copy_to_user(buf, __va(p), count))
                return -EFAULT;
        read += count;
@@ -197,6 +213,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
 {
        unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
        int uncached;
+       unsigned long cursor;
 
        uncached = uncached_access(file, offset);
 #ifdef pgprot_noncached
@@ -212,6 +229,13 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
         */
        if (uncached)
                vma->vm_flags |= VM_IO;
+               
+       cursor = vma->vm_pgoff;
+       while ((cursor << PAGE_SHIFT) < offset + vma->vm_end-vma->vm_start) {
+               if (!devmem_is_allowed(cursor))
+                       return -EPERM;
+               cursor++;
+       }
 
        if (remap_page_range(vma, vma->vm_start, offset, vma->vm_end-vma->vm_start,
                             vma->vm_page_prot))
@@ -232,6 +256,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
        ssize_t read = 0;
        ssize_t virtr = 0;
        char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
+       
+       return -EPERM;
                
        if (p < (unsigned long) high_memory) {
                read = count;
@@ -285,65 +311,6 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
        return virtr + read;
 }
 
-/*
- * This function writes to the *virtual* memory as seen by the kernel.
- */
-static ssize_t write_kmem(struct file * file, const char __user * buf, 
-                         size_t count, loff_t *ppos)
-{
-       unsigned long p = *ppos;
-       ssize_t wrote = 0;
-       ssize_t virtr = 0;
-       ssize_t written;
-       char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
-
-       if (p < (unsigned long) high_memory) {
-
-               wrote = count;
-               if (count > (unsigned long) high_memory - p)
-                       wrote = (unsigned long) high_memory - p;
-
-               written = do_write_mem((void*)p, p, buf, wrote, ppos);
-               if (written != wrote)
-                       return written;
-               wrote = written;
-               p += wrote;
-               buf += wrote;
-               count -= wrote;
-       }
-
-       if (count > 0) {
-               kbuf = (char *)__get_free_page(GFP_KERNEL);
-               if (!kbuf)
-                       return wrote ? wrote : -ENOMEM;
-               while (count > 0) {
-                       int len = count;
-
-                       if (len > PAGE_SIZE)
-                               len = PAGE_SIZE;
-                       if (len) {
-                               written = copy_from_user(kbuf, buf, len);
-                               if (written) {
-                                       ssize_t ret;
-
-                                       free_page((unsigned long)kbuf);
-                                       ret = wrote + virtr + (len - written);
-                                       return ret ? ret : -EFAULT;
-                               }
-                       }
-                       len = vwrite(kbuf, (char *)p, len);
-                       count -= len;
-                       buf += len;
-                       virtr += len;
-                       p += len;
-               }
-               free_page((unsigned long)kbuf);
-       }
-
-       *ppos = p;
-       return virtr + wrote;
-}
-
 #if defined(CONFIG_ISA) || !defined(__mc68000__)
 static ssize_t read_port(struct file * file, char __user * buf,
                         size_t count, loff_t *ppos)
@@ -594,7 +561,6 @@ static struct file_operations mem_fops = {
 static struct file_operations kmem_fops = {
        .llseek         = memory_lseek,
        .read           = read_kmem,
-       .write          = write_kmem,
        .mmap           = mmap_kmem,
        .open           = open_kmem,
 };
index e39179f..a261179 100644 (file)
@@ -2483,3 +2483,36 @@ __u32 check_tcp_syn_cookie(__u32 cookie, __u32 saddr, __u32 daddr, __u16 sport,
        return (cookie - tmp[17]) & COOKIEMASK; /* Leaving the data behind */
 }
 #endif
+
+/*
+ * Get a random word:
+ */
+unsigned int get_random_int(void)
+{
+       unsigned int val = 0;
+
+       if (!exec_shield_randomize)
+               return 0;
+
+#ifdef CONFIG_X86_HAS_TSC
+       rdtscl(val);
+#endif
+       val += current->pid + jiffies + (int)&val;
+
+       /*
+        * Use IP's RNG. It suits our purpose perfectly: it re-keys itself
+        * every second, from the entropy pool (and thus creates a limited
+        * drain on it), and uses halfMD4Transform within the second. We
+        * also spice it with the TSC (if available), jiffies, PID and the
+        * stack address:
+        */
+       return secure_ip_id(val);
+}
+
+unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len)
+{
+       unsigned long range = end - len - start;
+       if (end <= start + len)
+               return 0;
+       return PAGE_ALIGN(get_random_int() % range + start);
+}
diff --git a/drivers/char/sh-sci.c b/drivers/char/sh-sci.c
deleted file mode 100644 (file)
index d3894a6..0000000
+++ /dev/null
@@ -1,1646 +0,0 @@
-/* $Id: sh-sci.c,v 1.16 2004/02/10 17:04:17 lethal Exp $
- *
- *  linux/drivers/char/sh-sci.c
- *
- *  SuperH on-chip serial module support.  (SCI with no FIFO / with FIFO)
- *  Copyright (C) 1999, 2000  Niibe Yutaka
- *  Copyright (C) 2000  Sugioka Toshinobu
- *  Modified to support multiple serial ports. Stuart Menefy (May 2000).
- *  Modified to support SH7760 SCIF. Paul Mundt (Oct 2003).
- *  Modified to support H8/300 Series. Yoshinori Sato (Feb 2004).
- *
- * TTY code is based on sx.c (Specialix SX driver) by:
- *
- *   (C) 1998 R.E.Wolff@BitWizard.nl
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/serial.h>
-#include <linux/major.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_SH_KGDB_CONSOLE)
-#include <linux/console.h>
-#endif
-#ifdef CONFIG_CPU_FREQ
-#include <linux/notifier.h>
-#include <linux/cpufreq.h>
-#endif
-
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/bitops.h>
-
-#include <linux/generic_serial.h>
-
-#ifdef CONFIG_SH_STANDARD_BIOS
-#include <asm/sh_bios.h>
-#endif
-
-#include "sh-sci.h"
-
-#ifdef CONFIG_SH_KGDB
-#include <asm/kgdb.h>
-
-int kgdb_sci_setup(void);
-static int kgdb_get_char(struct sci_port *port);
-static void kgdb_put_char(struct sci_port *port, char c);
-static void kgdb_handle_error(struct sci_port *port);
-static struct sci_port *kgdb_sci_port;
-
-#ifdef CONFIG_SH_KGDB_CONSOLE
-static struct console kgdbcons;
-void __init kgdb_console_init(void);
-#endif /* CONFIG_SH_KGDB_CONSOLE */
-
-#endif /* CONFIG_SH_KGDB */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static struct console sercons;
-static struct sci_port* sercons_port=0;
-static int sercons_baud;
-#ifdef CONFIG_MAGIC_SYSRQ
-#include <linux/sysrq.h>
-static int break_pressed;
-#endif /* CONFIG_MAGIC_SYSRQ */
-#endif /* CONFIG_SERIAL_CONSOLE */
-
-/* Function prototypes */
-static void sci_init_pins_sci(struct sci_port* port, unsigned int cflag);
-#ifndef SCI_ONLY
-static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag);
-#if defined(CONFIG_CPU_SH3)
-static void sci_init_pins_irda(struct sci_port* port, unsigned int cflag);
-#endif
-#endif
-static void sci_disable_tx_interrupts(void *ptr);
-static void sci_enable_tx_interrupts(void *ptr);
-static void sci_disable_rx_interrupts(void *ptr);
-static void sci_enable_rx_interrupts(void *ptr);
-static int  sci_get_CD(void *ptr);
-static void sci_shutdown_port(void *ptr);
-static int sci_set_real_termios(void *ptr);
-static void sci_hungup(void *ptr);
-static void sci_close(void *ptr);
-static int sci_chars_in_buffer(void *ptr);
-static int sci_request_irq(struct sci_port *port);
-static void sci_free_irq(struct sci_port *port);
-static int sci_init_drivers(void);
-
-static struct tty_driver *sci_driver;
-
-static struct sci_port sci_ports[SCI_NPORTS] = SCI_INIT;
-
-static int sci_debug = 0;
-
-#ifdef MODULE
-MODULE_PARM(sci_debug, "i");
-#endif
-
-#define dprintk(x...) do { if (sci_debug) printk(x); } while(0)
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static void put_char(struct sci_port *port, char c)
-{
-       unsigned long flags;
-       unsigned short status;
-
-       local_irq_save(flags);
-
-       do
-               status = sci_in(port, SCxSR);
-       while (!(status & SCxSR_TDxE(port)));
-       
-       sci_out(port, SCxTDR, c);
-       sci_in(port, SCxSR);            /* Dummy read */
-       sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-
-       local_irq_restore(flags);
-}
-#endif
-
-#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
-
-static void handle_error(struct sci_port *port)
-{                              /* Clear error flags */
-       sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
-}
-
-static int get_char(struct sci_port *port)
-{
-       unsigned long flags;
-       unsigned short status;
-       int c;
-
-       local_irq_save(flags);
-        do {
-               status = sci_in(port, SCxSR);
-               if (status & SCxSR_ERRORS(port)) {
-                       handle_error(port);
-                       continue;
-               }
-       } while (!(status & SCxSR_RDxF(port)));
-       c = sci_in(port, SCxRDR);
-       sci_in(port, SCxSR);            /* Dummy read */
-       sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
-       local_irq_restore(flags);
-
-       return c;
-}
-
-/* Taken from sh-stub.c of GDB 4.18 */
-static const char hexchars[] = "0123456789abcdef";
-
-static __inline__ char highhex(int  x)
-{
-       return hexchars[(x >> 4) & 0xf];
-}
-
-static __inline__ char lowhex(int  x)
-{
-       return hexchars[x & 0xf];
-}
-
-#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
-
-/*
- * Send the packet in buffer.  The host gets one chance to read it.
- * This routine does not wait for a positive acknowledge.
- */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static void put_string(struct sci_port *port, const char *buffer, int count)
-{
-       int i;
-       const unsigned char *p = buffer;
-
-#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
-       int checksum;
-       int usegdb=0;
-
-#ifdef CONFIG_SH_STANDARD_BIOS
-       /* This call only does a trap the first time it is
-        * called, and so is safe to do here unconditionally
-        */
-       usegdb |= sh_bios_in_gdb_mode();
-#endif
-#ifdef CONFIG_SH_KGDB
-       usegdb |= (kgdb_in_gdb_mode && (port == kgdb_sci_port));
-#endif
-
-       if (usegdb) {
-           /*  $<packet info>#<checksum>. */
-           do {
-               unsigned char c;
-               put_char(port, '$');
-               put_char(port, 'O'); /* 'O'utput to console */
-               checksum = 'O';
-
-               for (i=0; i<count; i++) { /* Don't use run length encoding */
-                       int h, l;
-
-                       c = *p++;
-                       h = highhex(c);
-                       l = lowhex(c);
-                       put_char(port, h);
-                       put_char(port, l);
-                       checksum += h + l;
-               }
-               put_char(port, '#');
-               put_char(port, highhex(checksum));
-               put_char(port, lowhex(checksum));
-           } while  (get_char(port) != '+');
-       } else
-#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
-       for (i=0; i<count; i++) {
-               if (*p == 10)
-                       put_char(port, '\r');
-               put_char(port, *p++);
-       }
-}
-#endif /* CONFIG_SERIAL_CONSOLE */
-
-
-#ifdef CONFIG_SH_KGDB
-
-/* Is the SCI ready, ie is there a char waiting? */
-static int kgdb_is_char_ready(struct sci_port *port)
-{
-        unsigned short status = sci_in(port, SCxSR);
-
-        if (status & (SCxSR_ERRORS(port) | SCxSR_BRK(port)))
-                kgdb_handle_error(port);
-
-        return (status & SCxSR_RDxF(port));
-}
-
-/* Write a char */
-static void kgdb_put_char(struct sci_port *port, char c)
-{
-        unsigned short status;
-
-        do
-                status = sci_in(port, SCxSR);
-        while (!(status & SCxSR_TDxE(port)));
-
-        sci_out(port, SCxTDR, c);
-        sci_in(port, SCxSR);    /* Dummy read */
-        sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-}
-
-/* Get a char if there is one, else ret -1 */
-static int kgdb_get_char(struct sci_port *port)
-{
-        int c;
-
-        if (kgdb_is_char_ready(port) == 0)
-                c = -1;
-        else {
-                c = sci_in(port, SCxRDR);
-                sci_in(port, SCxSR);    /* Dummy read */
-                sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
-        }
-
-        return c;
-}
-
-/* Called from kgdbstub.c to get a character, i.e. is blocking */
-static int kgdb_sci_getchar(void)
-{
-        volatile int c;
-
-        /* Keep trying to read a character, this could be neater */
-        while ((c = kgdb_get_char(kgdb_sci_port)) < 0);
-
-        return c;
-}
-
-/* Called from kgdbstub.c to put a character, just a wrapper */
-static void kgdb_sci_putchar(int c)
-{
-
-        kgdb_put_char(kgdb_sci_port, c);
-}
-
-/* Clear any errors on the SCI */
-static void kgdb_handle_error(struct sci_port *port)
-{
-        sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));  /* Clear error flags */
-}
-
-/* Breakpoint if there's a break sent on the serial port */
-static void kgdb_break_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
-        struct sci_port *port = ptr;
-        unsigned short status = sci_in(port, SCxSR);
-
-        if (status & SCxSR_BRK(port)) {
-
-                /* Break into the debugger if a break is detected */
-                BREAKPOINT();
-
-                /* Clear */
-                sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
-                return;
-        }
-}
-
-#endif /* CONFIG_SH_KGDB */
-
-static struct real_driver sci_real_driver = {
-       sci_disable_tx_interrupts,
-       sci_enable_tx_interrupts,
-       sci_disable_rx_interrupts,
-       sci_enable_rx_interrupts,
-       sci_get_CD,
-       sci_shutdown_port,
-       sci_set_real_termios,
-       sci_chars_in_buffer,
-        sci_close,
-        sci_hungup,
-       NULL
-};
-
-#if !defined(__H8300H__) && !defined(__H8300S__)
-#if defined(SCI_ONLY) || defined(SCI_AND_SCIF)
-static void sci_init_pins_sci(struct sci_port* port, unsigned int cflag)
-{
-}
-#endif
-
-#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
-#if defined(CONFIG_CPU_SH3)
-/* For SH7707, SH7709, SH7709A, SH7729 */
-static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag)
-{
-       unsigned int fcr_val = 0;
-
-       {
-               unsigned short data;
-
-               /* We need to set SCPCR to enable RTS/CTS */
-               data = ctrl_inw(SCPCR);
-               /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
-               ctrl_outw(data&0x0cff, SCPCR);
-       }
-       if (cflag & CRTSCTS)
-               fcr_val |= SCFCR_MCE;
-       else {
-               unsigned short data;
-
-               /* We need to set SCPCR to enable RTS/CTS */
-               data = ctrl_inw(SCPCR);
-               /* Clear out SCP7MD1,0, SCP4MD1,0,
-                  Set SCP6MD1,0 = {01} (output)  */
-               ctrl_outw((data&0x0cff)|0x1000, SCPCR);
-
-               data = ctrl_inb(SCPDR);
-               /* Set /RTS2 (bit6) = 0 */
-               ctrl_outb(data&0xbf, SCPDR);
-       }
-       sci_out(port, SCFCR, fcr_val);
-}
-
-static void sci_init_pins_irda(struct sci_port* port, unsigned int cflag)
-{
-       unsigned int fcr_val = 0;
-
-       if (cflag & CRTSCTS)
-               fcr_val |= SCFCR_MCE;
-
-       sci_out(port, SCFCR, fcr_val);
-}
-
-#else
-
-/* For SH7750 */
-static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag)
-{
-       unsigned int fcr_val = 0;
-
-       if (cflag & CRTSCTS) {
-               fcr_val |= SCFCR_MCE;
-       } else {
-               ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */
-       }
-       sci_out(port, SCFCR, fcr_val);
-}
-
-#endif
-#endif /* SCIF_ONLY || SCI_AND_SCIF */
-#else /* !defined(__H8300H__) && !defined(__H8300S__) */
-static void sci_init_pins_sci(struct sci_port* port, unsigned int cflag)
-{
-       int ch = (port->base - SMR0) >> 3;
-       /* set DDR regs */
-       H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].rx,H8300_GPIO_INPUT);
-       H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].tx,H8300_GPIO_OUTPUT);
-       /* tx mark output*/
-       H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx;
-}
-
-#if defined(__H8300S__)
-enum {sci_disable,sci_enable};
-
-static void h8300_sci_enable(struct sci_port* port, unsigned int ctrl)
-{
-       volatile unsigned char *mstpcrl=(volatile unsigned char *)MSTPCRL;
-       int ch = (port->base  - SMR0) >> 3;
-       unsigned char mask = 1 << (ch+1);
-       if (ctrl == sci_disable)
-               *mstpcrl |= mask;
-       else
-               *mstpcrl &= ~mask;
-}
-#endif
-#endif
-
-static void sci_setsignals(struct sci_port *port, int dtr, int rts)
-{
-       /* This routine is used for seting signals of: DTR, DCD, CTS/RTS */
-       /* We use SCIF's hardware for CTS/RTS, so don't need any for that. */
-       /* If you have signals for DTR and DCD, please implement here. */
-       ;
-}
-
-static int sci_getsignals(struct sci_port *port)
-{
-       /* This routine is used for geting signals of: DTR, DCD, DSR, RI,
-          and CTS/RTS */
-
-       return TIOCM_DTR|TIOCM_RTS|TIOCM_DSR;
-/*
-       (((o_stat & OP_DTR)?TIOCM_DTR:0) |
-        ((o_stat & OP_RTS)?TIOCM_RTS:0) |
-        ((i_stat & IP_CTS)?TIOCM_CTS:0) |
-        ((i_stat & IP_DCD)?TIOCM_CAR:0) |
-        ((i_stat & IP_DSR)?TIOCM_DSR:0) |
-        ((i_stat & IP_RI) ?TIOCM_RNG:0)
-*/
-}
-
-static void sci_set_baud(struct sci_port *port, int baud)
-{
-       int t;
-
-       switch (baud) {
-       case 0:
-               t = -1;
-               break;
-       case 2400:
-               t = BPS_2400;
-               break;
-       case 4800:
-               t = BPS_4800;
-               break;
-       case 9600:
-               t = BPS_9600;
-               break;
-       case 19200:
-               t = BPS_19200;
-               break;
-       case 38400:
-               t = BPS_38400;
-               break;
-       case 57600:
-               t = BPS_57600;
-               break;
-       default:
-               printk(KERN_INFO "sci: unsupported baud rate: %d, using 115200 instead.\n", baud);
-       case 115200:
-               t = BPS_115200;
-               break;
-       }
-
-       if (t > 0) {
-               sci_setsignals (port, 1, -1);
-               if(t >= 256) {
-                       sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1);
-                       t >>= 2;
-               } else {
-                       sci_out(port, SCSMR, sci_in(port, SCSMR) & ~3);
-               }
-               sci_out(port, SCBRR, t);
-               udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
-       } else {
-               sci_setsignals (port, 0, -1);
-       }
-}
-
-static void sci_set_termios_cflag(struct sci_port *port, int cflag, int baud)
-{
-       unsigned int status;
-       unsigned int smr_val;
-
-       do
-               status = sci_in(port, SCxSR);
-       while (!(status & SCxSR_TEND(port)));
-
-       sci_out(port, SCSCR, 0x00);     /* TE=0, RE=0, CKE1=0 */
-
-#if !defined(SCI_ONLY)
-       if (port->type == PORT_SCIF) {
-               sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
-       }
-#endif
-
-       smr_val = sci_in(port, SCSMR) & 3;
-       if ((cflag & CSIZE) == CS7)
-               smr_val |= 0x40;
-       if (cflag & PARENB)
-               smr_val |= 0x20;
-       if (cflag & PARODD)
-               smr_val |= 0x30;
-       if (cflag & CSTOPB)
-               smr_val |= 0x08;
-       sci_out(port, SCSMR, smr_val);
-       sci_set_baud(port, baud);
-
-       port->init_pins(port, cflag);
-       sci_out(port, SCSCR, SCSCR_INIT(port));
-}
-
-static int sci_set_real_termios(void *ptr)
-{
-       struct sci_port *port = ptr;
-
-       if (port->old_cflag != port->gs.tty->termios->c_cflag) {
-               port->old_cflag = port->gs.tty->termios->c_cflag;
-               sci_set_termios_cflag(port, port->old_cflag, port->gs.baud);
-               sci_enable_rx_interrupts(port);
-       }
-
-       return 0;
-}
-
-/* ********************************************************************** *
- *                   the interrupt related routines                       *
- * ********************************************************************** */
-
-/*
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- */
-static inline void sci_sched_event(struct sci_port *port, int event)
-{
-       port->event |= 1 << event;
-       schedule_work(&port->tqueue);
-}
-
-static void sci_transmit_chars(struct sci_port *port)
-{
-       int count, i;
-       int txroom;
-       unsigned long flags;
-       unsigned short status;
-       unsigned short ctrl;
-       unsigned char c;
-
-       status = sci_in(port, SCxSR);
-       if (!(status & SCxSR_TDxE(port))) {
-               local_irq_save(flags);
-               ctrl = sci_in(port, SCSCR);
-               if (port->gs.xmit_cnt == 0) {
-                       ctrl &= ~SCI_CTRL_FLAGS_TIE;
-                       port->gs.flags &= ~GS_TX_INTEN;
-               } else
-                       ctrl |= SCI_CTRL_FLAGS_TIE;
-               sci_out(port, SCSCR, ctrl);
-               local_irq_restore(flags);
-               return;
-       }
-
-       while (1) {
-               count = port->gs.xmit_cnt;
-#if !defined(SCI_ONLY)
-               if (port->type == PORT_SCIF) {
-                       txroom = 16 - (sci_in(port, SCFDR)>>8);
-               } else {
-                       txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
-               }
-#else
-               txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
-#endif
-               if (count > txroom)
-                       count = txroom;
-
-               /* Don't copy past the end of the source buffer */
-               if (count > SERIAL_XMIT_SIZE - port->gs.xmit_tail)
-                       count = SERIAL_XMIT_SIZE - port->gs.xmit_tail;
-
-               /* If for one reason or another, we can't copy more data, we're done! */
-               if (count == 0)
-                       break;
-
-               for (i=0; i<count; i++) {
-                       c = port->gs.xmit_buf[port->gs.xmit_tail + i];
-                       sci_out(port, SCxTDR, c);
-               }
-               sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-
-               port->icount.tx += count;
-
-               /* Update the kernel buffer end */
-               port->gs.xmit_tail = (port->gs.xmit_tail + count) & (SERIAL_XMIT_SIZE-1);
-
-               /* This one last. (this is essential)
-                  It would allow others to start putting more data into the buffer! */
-               port->gs.xmit_cnt -= count;
-       }
-
-       if (port->gs.xmit_cnt <= port->gs.wakeup_chars)
-               sci_sched_event(port, SCI_EVENT_WRITE_WAKEUP);
-
-       local_irq_save(flags);
-       ctrl = sci_in(port, SCSCR);
-       if (port->gs.xmit_cnt == 0) {
-               ctrl &= ~SCI_CTRL_FLAGS_TIE;
-               port->gs.flags &= ~GS_TX_INTEN;
-       } else {
-#if !defined(SCI_ONLY)
-               if (port->type == PORT_SCIF) {
-                       sci_in(port, SCxSR); /* Dummy read */
-                       sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-               }
-#endif
-               ctrl |= SCI_CTRL_FLAGS_TIE;
-       }
-       sci_out(port, SCSCR, ctrl);
-       local_irq_restore(flags);
-}
-
-/* On SH3, SCIF may read end-of-break as a space->mark char */
-#define STEPFN(c)  ({int __c=(c); (((__c-1)|(__c)) == -1); })
-
-static inline void sci_receive_chars(struct sci_port *port,
-                                    struct pt_regs *regs)
-{
-       int i, count;
-       struct tty_struct *tty;
-       int copied=0;
-       unsigned short status;
-
-       status = sci_in(port, SCxSR);
-       if (!(status & SCxSR_RDxF(port)))
-               return;
-
-       tty = port->gs.tty;
-       while (1) {
-#if !defined(SCI_ONLY)
-               if (port->type == PORT_SCIF) {
-                       count = sci_in(port, SCFDR)&0x001f;
-               } else {
-                       count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
-               }
-#else
-               count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
-#endif
-
-               /* Don't copy more bytes than there is room for in the buffer */
-               if (tty->flip.count + count > TTY_FLIPBUF_SIZE)
-                       count = TTY_FLIPBUF_SIZE - tty->flip.count;
-
-               /* If for any reason we can't copy more data, we're done! */
-               if (count == 0)
-                       break;
-
-               if (port->type == PORT_SCI) {
-                       tty->flip.char_buf_ptr[0] = sci_in(port, SCxRDR);
-                       tty->flip.flag_buf_ptr[0] = TTY_NORMAL;
-               } else {
-                       for (i=0; i<count; i++) {
-                               char c = sci_in(port, SCxRDR);
-                               status = sci_in(port, SCxSR);
-#if defined(__SH3__)
-                               /* Skip "chars" during break */
-                               if (port->break_flag) {
-                                       if ((c == 0) &&
-                                           (status & SCxSR_FER(port))) {
-                                               count--; i--;
-                                               continue;
-                                       }
-                                       /* Nonzero => end-of-break */
-                                       dprintk("scif: debounce<%02x>\n", c);
-                                       port->break_flag = 0;
-                                       if (STEPFN(c)) {
-                                               count--; i--;
-                                               continue;
-                                       }
-                               }
-#endif /* __SH3__ */
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-                               if (break_pressed && (port == sercons_port)) {
-                                       if (c != 0 &&
-                                           time_before(jiffies,
-                                                       break_pressed + HZ*5)) {
-                                               handle_sysrq(c, regs, NULL);
-                                               break_pressed = 0;
-                                               count--; i--;
-                                               continue;
-                                       } else if (c != 0) {
-                                               break_pressed = 0;
-                                       }
-                               }
-#endif /* CONFIG_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ */
-
-                               /* Store data and status */
-                               tty->flip.char_buf_ptr[i] = c;
-                               if (status&SCxSR_FER(port)) {
-                                       tty->flip.flag_buf_ptr[i] = TTY_FRAME;
-                                       dprintk("sci: frame error\n");
-                               } else if (status&SCxSR_PER(port)) {
-                                       tty->flip.flag_buf_ptr[i] = TTY_PARITY;
-                                       dprintk("sci: parity error\n");
-                               } else {
-                                       tty->flip.flag_buf_ptr[i] = TTY_NORMAL;
-                               }
-                       }
-               }
-
-               sci_in(port, SCxSR); /* dummy read */
-               sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
-
-               /* Update the kernel buffer end */
-               tty->flip.count += count;
-               tty->flip.char_buf_ptr += count;
-               tty->flip.flag_buf_ptr += count;
-
-               copied += count;
-               port->icount.rx += count;
-       }
-
-       if (copied)
-               /* Tell the rest of the system the news. New characters! */
-               tty_flip_buffer_push(tty);
-       else {
-               sci_in(port, SCxSR); /* dummy read */
-               sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
-       }
-}
-
-static inline int sci_handle_errors(struct sci_port *port)
-{
-       int copied = 0;
-       unsigned short status = sci_in(port, SCxSR);
-       struct tty_struct *tty = port->gs.tty;
-
-       if (status&SCxSR_ORER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
-               /* overrun error */
-               copied++;
-               *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-               dprintk("sci: overrun error\n");
-       }
-
-       if (status&SCxSR_FER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
-               if (sci_rxd_in(port) == 0) {
-                       /* Notify of BREAK */
-                       copied++;
-                       *tty->flip.flag_buf_ptr++ = TTY_BREAK;
-                       dprintk("sci: BREAK detected\n");
-               }
-               else {
-                       /* frame error */
-                       copied++;
-                       *tty->flip.flag_buf_ptr++ = TTY_FRAME;
-                       dprintk("sci: frame error\n");
-               }
-       }
-
-       if (status&SCxSR_PER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
-               /* parity error */
-               copied++;
-               *tty->flip.flag_buf_ptr++ = TTY_PARITY;
-               dprintk("sci: parity error\n");
-       }
-
-       if (copied) {
-               tty->flip.count += copied;
-               tty_flip_buffer_push(tty);
-       }
-
-       return copied;
-}
-
-static inline int sci_handle_breaks(struct sci_port *port)
-{
-       int copied = 0;
-       unsigned short status = sci_in(port, SCxSR);
-       struct tty_struct *tty = port->gs.tty;
-
-       if (status&SCxSR_BRK(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
-#if defined(__SH3__)
-               /* Debounce break */
-               if (port->break_flag)
-                       goto break_continue;
-               port->break_flag = 1;
-#endif
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-               if (port == sercons_port) {
-                       if (break_pressed == 0) {
-                               break_pressed = jiffies;
-                               dprintk("sci: implied sysrq\n");
-                               goto break_continue;
-                       }
-                       /* Double break implies a real break */
-                       break_pressed = 0;
-               }
-#endif
-               /* Notify of BREAK */
-               copied++;
-               *tty->flip.flag_buf_ptr++ = TTY_BREAK;
-               dprintk("sci: BREAK detected\n");
-       }
- break_continue:
-
-#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_ST40STB1) || \
-    defined(CONFIG_CPU_SUBTYPE_SH7760)
-       /* XXX: Handle SCIF overrun error */
-       if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) {
-               sci_out(port, SCLSR, 0);
-               if(tty->flip.count<TTY_FLIPBUF_SIZE) {
-                       copied++;
-                       *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-                       dprintk("sci: overrun error\n");
-               }
-       }
-#endif
-
-       if (copied) {
-               tty->flip.count += copied;
-               tty_flip_buffer_push(tty);
-       }
-
-       return copied;
-}
-
-static irqreturn_t sci_rx_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
-       struct sci_port *port = ptr;
-
-       if (port->gs.flags & GS_ACTIVE)
-               if (!(port->gs.flags & SCI_RX_THROTTLE)) {
-                       sci_receive_chars(port, regs);
-                       return IRQ_HANDLED;
-
-               }
-       sci_disable_rx_interrupts(port);
-
-       return IRQ_HANDLED;
-}
-
-static irqreturn_t sci_tx_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
-       struct sci_port *port = ptr;
-
-       if (port->gs.flags & GS_ACTIVE)
-               sci_transmit_chars(port);
-       else {
-               sci_disable_tx_interrupts(port);
-       }
-
-       return IRQ_HANDLED;
-}
-
-static irqreturn_t sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
-       struct sci_port *port = ptr;
-
-       /* Handle errors */
-       if (port->type == PORT_SCI) {
-               if(sci_handle_errors(port)) {
-                       /* discard character in rx buffer */
-                       sci_in(port, SCxSR);
-                       sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
-               }
-       }
-       else
-               sci_rx_interrupt(irq, ptr, regs);
-               
-       sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
-
-       /* Kick the transmission */
-       sci_tx_interrupt(irq, ptr, regs);
-
-       return IRQ_HANDLED;
-}
-
-#if !defined(SCI_ONLY)
-static irqreturn_t sci_br_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
-       struct sci_port *port = ptr;
-
-       /* Handle BREAKs */
-       sci_handle_breaks(port);
-       sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
-
-       return IRQ_HANDLED;
-}
-#endif
-
-static void do_softint(void *private_)
-{
-       struct sci_port *port = (struct sci_port *) private_;
-       struct tty_struct       *tty;
-       
-       tty = port->gs.tty;
-       if (!tty)
-               return;
-
-       if (test_and_clear_bit(SCI_EVENT_WRITE_WAKEUP, &port->event)) {
-               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                   tty->ldisc.write_wakeup)
-                       (tty->ldisc.write_wakeup)(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
-}
-
-/* ********************************************************************** *
- *                Here are the routines that actually                     *
- *              interface with the generic_serial driver                  *
- * ********************************************************************** */
-
-static void sci_disable_tx_interrupts(void *ptr)
-{
-       struct sci_port *port = ptr;
-       unsigned long flags;
-       unsigned short ctrl;
-
-       /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */
-       local_irq_save(flags);
-       ctrl = sci_in(port, SCSCR);
-       ctrl &= ~SCI_CTRL_FLAGS_TIE;
-       sci_out(port, SCSCR, ctrl);
-       local_irq_restore(flags);
-}
-
-static void sci_enable_tx_interrupts(void *ptr)
-{
-       struct sci_port *port = ptr; 
-
-       disable_irq(port->irqs[SCIx_TXI_IRQ]);
-       sci_transmit_chars(port);
-       enable_irq(port->irqs[SCIx_TXI_IRQ]);
-}
-
-static void sci_disable_rx_interrupts(void * ptr)
-{
-       struct sci_port *port = ptr;
-       unsigned long flags;
-       unsigned short ctrl;
-
-       /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */
-       local_irq_save(flags);
-       ctrl = sci_in(port, SCSCR);
-       ctrl &= ~SCI_CTRL_FLAGS_RIE;
-       sci_out(port, SCSCR, ctrl);
-       local_irq_restore(flags);
-}
-
-static void sci_enable_rx_interrupts(void * ptr)
-{
-       struct sci_port *port = ptr;
-       unsigned long flags;
-       unsigned short ctrl;
-
-       /* Set RIE (Receive Interrupt Enable) bit in SCSCR */
-       local_irq_save(flags);
-       ctrl = sci_in(port, SCSCR);
-       ctrl |= SCI_CTRL_FLAGS_RIE;
-       sci_out(port, SCSCR, ctrl);
-       local_irq_restore(flags);
-}
-
-static int sci_get_CD(void * ptr)
-{
-       /* If you have signal for CD (Carrier Detect), please change here. */
-       return 1;
-}
-
-static int sci_chars_in_buffer(void * ptr)
-{
-       struct sci_port *port = ptr;
-
-#if !defined(SCI_ONLY)
-       if (port->type == PORT_SCIF) {
-               return (sci_in(port, SCFDR) >> 8) + ((sci_in(port, SCxSR) & SCxSR_TEND(port))? 0: 1);
-       } else {
-               return (sci_in(port, SCxSR) & SCxSR_TEND(port))? 0: 1;
-       }
-#else
-       return (sci_in(port, SCxSR) & SCxSR_TEND(port))? 0: 1;
-#endif
-}
-
-static void sci_shutdown_port(void * ptr)
-{
-       struct sci_port *port = ptr; 
-
-       port->gs.flags &= ~ GS_ACTIVE;
-       if (port->gs.tty && port->gs.tty->termios->c_cflag & HUPCL)
-               sci_setsignals(port, 0, 0);
-       sci_free_irq(port);
-#if defined(__H8300S__)
-       h8300_sci_enable(port,sci_disable);
-#endif
-}
-
-/* ********************************************************************** *
- *                Here are the routines that actually                     *
- *               interface with the rest of the system                    *
- * ********************************************************************** */
-
-static int sci_open(struct tty_struct * tty, struct file * filp)
-{
-       struct sci_port *port;
-       int retval, line;
-
-       line = tty->index;
-
-       if ((line < 0) || (line >= SCI_NPORTS))
-               return -ENODEV;
-
-       port = &sci_ports[line];
-
-       tty->driver_data = port;
-       port->gs.tty = tty;
-       port->gs.count++;
-
-       port->event = 0;
-       INIT_WORK(&port->tqueue, do_softint, port);
-
-#if defined(__H8300S__)
-               h8300_sci_enable(port,sci_enable);
-#endif
-
-       /*
-        * Start up serial port
-        */
-       retval = gs_init_port(&port->gs);
-       if (retval) {
-               goto failed_1;
-       }
-
-       port->gs.flags |= GS_ACTIVE;
-       sci_setsignals(port, 1,1);
-
-       if (port->gs.count == 1) {
-               retval = sci_request_irq(port);
-       }
-
-       retval = gs_block_til_ready(port, filp);
-
-       if (retval) {
-               goto failed_3;
-       }
-
-#ifdef CONFIG_SERIAL_CONSOLE
-       if (sercons.cflag && sercons.index == line) {
-               tty->termios->c_cflag = sercons.cflag;
-               port->gs.baud = sercons_baud;
-               sercons.cflag = 0;
-               sci_set_real_termios(port);
-       }
-#endif
-
-#ifdef CONFIG_SH_KGDB_CONSOLE
-        if (kgdbcons.cflag && kgdbcons.index == line) {
-                tty->termios->c_cflag = kgdbcons.cflag;
-                port->gs.baud = kgdb_baud;
-                sercons.cflag = 0;
-                sci_set_real_termios(port);
-        }
-#endif
-
-       sci_enable_rx_interrupts(port);
-
-       return 0;
-
-failed_3:
-       sci_free_irq(port);
-failed_1:
-       port->gs.count--;
-       return retval;
-}
-
-static void sci_hungup(void *ptr)
-{
-        return;
-}
-
-static void sci_close(void *ptr)
-{
-        return;
-}
-
-static int sci_tiocmget(struct tty_struct *tty, struct file *file)
-{
-       struct sci_port *port = tty->driver_data;
-       return sci_getsignals(port);
-}
-
-static int sci_tiocmset(struct tty_struct *tty, struct file *file,
-                       unsigned int set, unsigned int clear)
-{
-       struct sci_port *port = tty->driver_data;
-       int rts = -1, dtr = -1;
-
-       if (set & TIOCM_RTS)
-               rts = 1;
-       if (set & TIOCM_DTR)
-               dtr = 1;
-       if (clear & TIOCM_RTS)
-               rts = 0;
-       if (clear & TIOCM_DTR)
-               dtr = 0;
-
-       sci_setsignals(port, dtr, rts);
-       return 0;
-}
-
-static int sci_ioctl(struct tty_struct * tty, struct file * filp, 
-                     unsigned int cmd, unsigned long arg)
-{
-       int rc;
-       struct sci_port *port = tty->driver_data;
-       int ival;
-
-       rc = 0;
-       switch (cmd) {
-       case TIOCGSOFTCAR:
-               rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
-                             (unsigned int __user *) arg);
-               break;
-       case TIOCSSOFTCAR:
-               if ((rc = get_user(ival, (unsigned int __user *) arg)) == 0)
-                       tty->termios->c_cflag =
-                               (tty->termios->c_cflag & ~CLOCAL) |
-                               (ival ? CLOCAL : 0);
-               break;
-       case TIOCGSERIAL:
-               if ((rc = verify_area(VERIFY_WRITE, (void __user *) arg,
-                                     sizeof(struct serial_struct))) == 0)
-                       rc = gs_getserial(&port->gs, (struct serial_struct *) arg);
-               break;
-       case TIOCSSERIAL:
-               if ((rc = verify_area(VERIFY_READ, (void __user *) arg,
-                                     sizeof(struct serial_struct))) == 0)
-                       rc = gs_setserial(&port->gs,
-                                         (struct serial_struct *) arg);
-               break;
-       default:
-               rc = -ENOIOCTLCMD;
-               break;
-       }
-
-       return rc;
-}
-
-static void sci_throttle(struct tty_struct * tty)
-{
-       struct sci_port *port = (struct sci_port *)tty->driver_data;
-
-       /* If the port is using any type of input flow
-        * control then throttle the port.
-        */
-       if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty)) )
-               port->gs.flags |= SCI_RX_THROTTLE;
-}
-
-static void sci_unthrottle(struct tty_struct * tty)
-{
-       struct sci_port *port = (struct sci_port *)tty->driver_data;
-
-       /* Always unthrottle even if flow control is not enabled on
-        * this port in case we disabled flow control while the port
-        * was throttled
-        */
-       port->gs.flags &= ~SCI_RX_THROTTLE;
-       sci_enable_rx_interrupts(port);
-       return;
-}
-
-#ifdef CONFIG_PROC_FS
-static int sci_read_proc(char *page, char **start, off_t off, int count,
-                        int *eof, void *data)
-{
-       int i;
-       struct sci_port *port;
-       int len = 0;
-       
-        len += sprintf(page, "sciinfo:0.1\n");
-       for (i = 0; i < SCI_NPORTS && len < 4000; i++) {
-               port = &sci_ports[i];
-               len += sprintf(page+len, "%d: uart:%s address: %08x", i,
-                              (port->type == PORT_SCI) ? "SCI" : "SCIF",
-                              port->base);
-               len += sprintf(page+len, " baud:%d", port->gs.baud);
-               len += sprintf(page+len, " tx:%d rx:%d",
-                              port->icount.tx, port->icount.rx);
-
-               if (port->icount.frame)
-                       len += sprintf(page+len, " fe:%d", port->icount.frame);
-               if (port->icount.parity)
-                       len += sprintf(page+len, " pe:%d", port->icount.parity);
-               if (port->icount.brk)
-                       len += sprintf(page+len, " brk:%d", port->icount.brk);
-               if (port->icount.overrun)
-                       len += sprintf(page+len, " oe:%d", port->icount.overrun);
-               len += sprintf(page+len, "\n");
-       }
-       return len;
-}
-#endif
-
-#ifdef CONFIG_CPU_FREQ
-/*
- * Here we define a transistion notifier so that we can update all of our
- * ports' baud rate when the peripheral clock changes.
- */
-
-static int sci_notifier(struct notifier_block *self, unsigned long phase, void *p)
-{
-       struct cpufreq_freqs *freqs = p;
-       int i;
-
-       if (phase == CPUFREQ_POSTCHANGE) {
-               for (i = 0; i < SCI_NPORTS; i++) {
-                       /*
-                        * This will force a baud rate change in hardware.
-                        */
-                       if (sci_ports[i].gs.tty != NULL) {
-                               sci_set_baud(&sci_ports[i], sci_ports[i].gs.baud);
-                       }
-               }
-               printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n",
-                               __FUNCTION__, freqs->cpu, freqs->old, freqs->new);
-       }
-
-       return NOTIFY_OK;
-}
-
-static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 };
-#endif /* CONFIG_CPU_FREQ */
-
-static struct tty_operations sci_ops = {
-       .open   = sci_open,
-       .close = gs_close,
-       .write = gs_write,
-       .put_char = gs_put_char,
-       .flush_chars = gs_flush_chars,
-       .write_room = gs_write_room,
-       .chars_in_buffer = gs_chars_in_buffer,
-       .flush_buffer = gs_flush_buffer,
-       .ioctl = sci_ioctl,
-       .throttle = sci_throttle,
-       .unthrottle = sci_unthrottle,
-       .set_termios = gs_set_termios,
-       .stop = gs_stop,
-       .start = gs_start,
-       .hangup = gs_hangup,
-#ifdef CONFIG_PROC_FS
-       .read_proc = sci_read_proc,
-#endif
-       .tiocmget = sci_tiocmget,
-       .tiocmset = sci_tiocmset,
-};
-
-/* ********************************************************************** *
- *                    Here are the initialization routines.               *
- * ********************************************************************** */
-
-static int sci_init_drivers(void)
-{
-       int error;
-       struct sci_port *port;
-       sci_driver = alloc_tty_driver(SCI_NPORTS);
-       if (!sci_driver)
-               return -ENOMEM;
-
-       sci_driver->owner = THIS_MODULE;
-       sci_driver->driver_name = "sci";
-       sci_driver->name = "ttySC";
-       sci_driver->devfs_name = "ttsc/";
-       sci_driver->major = SCI_MAJOR;
-       sci_driver->minor_start = SCI_MINOR_START;
-       sci_driver->type = TTY_DRIVER_TYPE_SERIAL;
-       sci_driver->subtype = SERIAL_TYPE_NORMAL;
-       sci_driver->init_termios = tty_std_termios;
-       sci_driver->init_termios.c_cflag =
-               B9600 | CS8 | CREAD | HUPCL | CLOCAL | CRTSCTS;
-       sci_driver->flags = TTY_DRIVER_REAL_RAW;
-       tty_set_operations(sci_driver, &sci_ops);
-       if ((error = tty_register_driver(sci_driver))) {
-               printk(KERN_ERR "sci: Couldn't register SCI driver, error = %d\n",
-                      error);
-               put_tty_driver(sci_driver);
-               return 1;
-       }
-
-       for (port = &sci_ports[0]; port < &sci_ports[SCI_NPORTS]; port++) {
-               port->gs.magic = SCI_MAGIC;
-               port->gs.close_delay = HZ/2;
-               port->gs.closing_wait = 30 * HZ;
-               port->gs.rd = &sci_real_driver;
-               init_waitqueue_head(&port->gs.open_wait);
-               init_waitqueue_head(&port->gs.close_wait);
-               port->old_cflag = 0;
-               port->icount.cts = port->icount.dsr = 
-                       port->icount.rng = port->icount.dcd = 0;
-               port->icount.rx = port->icount.tx = 0;
-               port->icount.frame = port->icount.parity = 0;
-               port->icount.overrun = port->icount.brk = 0;
-       }
-
-#ifdef CONFIG_CPU_FREQ
-       /* Setup transition notifier */
-       if (cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER) < 0) {
-               printk(KERN_ERR "sci: Unable to register CPU frequency notifier\n");
-               return 1;
-       }
-       printk("sci: CPU frequency notifier registered\n");
-#endif
-       return 0;
-}
-
-static int sci_request_irq(struct sci_port *port)
-{
-       int i;
-#if !defined(SCI_ONLY)
-       irqreturn_t (*handlers[4])(int irq, void *p, struct pt_regs *regs) = {
-               sci_er_interrupt, sci_rx_interrupt, sci_tx_interrupt,
-               sci_br_interrupt,
-       };
-#else
-       void (*handlers[3])(int irq, void *ptr, struct pt_regs *regs) = {
-               sci_er_interrupt, sci_rx_interrupt, sci_tx_interrupt,
-       };
-#endif
-       for (i=0; i<(sizeof(handlers)/sizeof(handlers[0])); i++) {
-               if (!port->irqs[i]) continue;
-               if (request_irq(port->irqs[i], handlers[i], SA_INTERRUPT,
-                               "sci", port)) {
-                       printk(KERN_ERR "sci: Cannot allocate irq.\n");
-                       return -ENODEV;
-               }
-       }
-       return 0;
-}
-
-static void sci_free_irq(struct sci_port *port)
-{
-       int i;
-
-       for (i=0; i<4; i++) {
-               if (!port->irqs[i]) continue;
-               free_irq(port->irqs[i], port);
-       }
-}
-
-static char banner[] __initdata =
-       KERN_INFO "SuperH SCI(F) driver initialized\n";
-
-int __init sci_init(void)
-{
-       struct sci_port *port;
-       int j;
-
-       printk("%s", banner);
-
-       for (j=0; j<SCI_NPORTS; j++) {
-               port = &sci_ports[j];
-               printk(KERN_INFO "ttySC%d at 0x%08x is a %s\n", j, port->base,
-                      (port->type == PORT_SCI) ? "SCI" : "SCIF");
-       }
-
-       sci_init_drivers();
-
-#ifdef CONFIG_SH_STANDARD_BIOS
-       sh_bios_gdb_detach();
-#endif
-       return 0;               /* Return -EIO when not detected */
-}
-
-module_init(sci_init);
-
-#ifdef MODULE
-#undef func_enter
-#undef func_exit
-
-void cleanup_module(void)
-{
-       tty_unregister_driver(sci_driver);
-       put_tty_driver(sci_driver);
-}
-
-#include "generic_serial.c"
-#endif
-
-#ifdef CONFIG_SERIAL_CONSOLE
-/*
- *     Print a string to the serial port trying not to disturb
- *     any possible real use of the port...
- */
-static void serial_console_write(struct console *co, const char *s,
-                                unsigned count)
-{
-       put_string(sercons_port, s, count);
-}
-
-static struct tty_driver *serial_console_device(struct console *c, int *index)
-{
-       *index = c->index;
-       return sci_driver;
-}
-
-/*
- *     Setup initial baud/bits/parity. We do two things here:
- *     - construct a cflag setting for the first rs_open()
- *     - initialize the serial port
- *     Return non-zero if we didn't find a serial port.
- */
-static int __init serial_console_setup(struct console *co, char *options)
-{
-       int     baud = 9600;
-       int     bits = 8;
-       int     parity = 'n';
-       int     cflag = CREAD | HUPCL | CLOCAL;
-       char    *s;
-
-       sercons_port = &sci_ports[co->index];
-
-       if (options) {
-               baud = simple_strtoul(options, NULL, 10);
-               s = options;
-               while(*s >= '0' && *s <= '9')
-                       s++;
-               if (*s) parity = *s++;
-               if (*s) bits   = *s - '0';
-       }
-
-       /*
-        *      Now construct a cflag setting.
-        */
-       switch (baud) {
-               case 19200:
-                       cflag |= B19200;
-                       break;
-               case 38400:
-                       cflag |= B38400;
-                       break;
-               case 57600:
-                       cflag |= B57600;
-                       break;
-               case 115200:
-                       cflag |= B115200;
-                       break;
-               case 9600:
-               default:
-                       cflag |= B9600;
-                       baud = 9600;
-                       break;
-       }
-       switch (bits) {
-               case 7:
-                       cflag |= CS7;
-                       break;
-               default:
-               case 8:
-                       cflag |= CS8;
-                       break;
-       }
-       switch (parity) {
-               case 'o': case 'O':
-                       cflag |= PARODD;
-                       break;
-               case 'e': case 'E':
-                       cflag |= PARENB;
-                       break;
-       }
-
-       co->cflag = cflag;
-       sercons_baud = baud;
-
-#if defined(__H8300S__)
-       h8300_sci_enable(sercons_port,sci_enable);
-#endif
-       sci_set_termios_cflag(sercons_port, cflag, baud);
-       sercons_port->old_cflag = cflag;
-
-       return 0;
-}
-
-static struct console sercons = {
-       .name           = "ttySC",
-       .write          = serial_console_write,
-       .device         = serial_console_device,
-       .setup          = serial_console_setup,
-       .flags          = CON_PRINTBUFFER,
-       .index          = -1,
-};
-
-/*
- *     Register console.
- */
-
-#ifdef CONFIG_SH_EARLY_PRINTK
-extern void sh_console_unregister (void);
-#endif
-
-static int __init sci_console_init(void)
-{
-       register_console(&sercons);
-#ifdef CONFIG_SH_EARLY_PRINTK
-       /* Now that the real console is available, unregister the one we
-        * used while first booting.
-        */
-       sh_console_unregister();
-#endif
-       return 0;
-}
-console_initcall(sci_console_init);
-
-#endif /* CONFIG_SERIAL_CONSOLE */
-
-
-#ifdef CONFIG_SH_KGDB
-
-/* Initialise the KGDB serial port */
-int kgdb_sci_setup(void)
-{
-       int cflag = CREAD | HUPCL | CLOCAL;
-
-       if ((kgdb_portnum < 0) || (kgdb_portnum >= SCI_NPORTS))
-               return -1;
-
-        kgdb_sci_port = &sci_ports[kgdb_portnum];
-
-       switch (kgdb_baud) {
-        case 115200:
-                cflag |= B115200;
-                break;
-       case 57600:
-                cflag |= B57600;
-                break;
-        case 38400:
-                cflag |= B38400;
-                break;
-        case 19200:
-                cflag |= B19200;
-                break;
-        case 9600:
-        default:
-                cflag |= B9600;
-                kgdb_baud = 9600;
-                break;
-        }
-
-       switch (kgdb_bits) {
-        case '7':
-                cflag |= CS7;
-                break;
-        default:
-        case '8':
-                cflag |= CS8;
-                break;
-        }
-
-        switch (kgdb_parity) {
-        case 'O':
-                cflag |= PARODD;
-                break;
-        case 'E':
-                cflag |= PARENB;
-                break;
-        }
-
-        kgdb_cflag = cflag;
-        sci_set_termios_cflag(kgdb_sci_port, kgdb_cflag, kgdb_baud);
-
-        /* Set up the interrupt for BREAK from GDB */
-       /* Commented out for now since it may not be possible yet...
-          request_irq(kgdb_sci_port->irqs[0], kgdb_break_interrupt,
-                      SA_INTERRUPT, "sci", kgdb_sci_port);
-          sci_enable_rx_interrupts(kgdb_sci_port);
-       */
-
-       /* Setup complete: initialize function pointers */
-       kgdb_getchar = kgdb_sci_getchar;
-       kgdb_putchar = kgdb_sci_putchar;
-
-        return 0;
-}
-
-#ifdef CONFIG_SH_KGDB_CONSOLE
-
-/* Create a console device */
-static kdev_t kgdb_console_device(struct console *c)
-{
-        return MKDEV(SCI_MAJOR, SCI_MINOR_START + c->index);
-}
-
-/* Set up the KGDB console */
-static int __init kgdb_console_setup(struct console *co, char *options)
-{
-        /* NB we ignore 'options' because we've already done the setup */
-        co->cflag = kgdb_cflag;
-
-        return 0;
-}
-
-/* Register the KGDB console so we get messages (d'oh!) */
-void __init kgdb_console_init(void)
-{
-        register_console(&kgdbcons);
-}
-
-/* The console structure for KGDB */
-static struct console kgdbcons = {
-        name:"ttySC",
-        write:kgdb_console_write,
-        device:kgdb_console_device,
-        wait_key:serial_console_wait_key,
-        setup:kgdb_console_setup,
-        flags:CON_PRINTBUFFER | CON_ENABLED,
-        index:-1,
-};
-
-#endif /* CONFIG_SH_KGDB_CONSOLE */
-
-#endif /* CONFIG_SH_KGDB */
diff --git a/drivers/char/sh-sci.h b/drivers/char/sh-sci.h
deleted file mode 100644 (file)
index 5d07cd1..0000000
+++ /dev/null
@@ -1,478 +0,0 @@
-/* $Id: sh-sci.h,v 1.7 2004/02/10 17:04:17 lethal Exp $
- *
- *  linux/drivers/char/sh-sci.h
- *
- *  SuperH on-chip serial module support.  (SCI with no FIFO / with FIFO)
- *  Copyright (C) 1999, 2000  Niibe Yutaka
- *  Copyright (C) 2000  Greg Banks
- *  Modified to support multiple serial ports. Stuart Menefy (May 2000).
- *  Modified to support SH7760 SCIF. Paul Mundt (Oct 2003).
- *  Modified to support H8/300 Serise Yoshinori Sato (Feb 2004). 
- *
- */
-#include <linux/config.h>
-
-#if defined(__H8300H__) || defined(__H8300S__)
-#include <asm/gpio.h>
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
-#include <asm/regs306x.h>
-#endif
-#if defined(CONFIG_H8S2678)
-#include <asm/regs267x.h>
-#endif
-#endif
-
-/* Values for sci_port->type */
-#define PORT_SCI  0
-#define PORT_SCIF 1
-#define PORT_IRDA 1            /* XXX: temporary assignment */
-
-/* Offsets into the sci_port->irqs array */
-#define SCIx_ERI_IRQ 0
-#define SCIx_RXI_IRQ 1
-#define SCIx_TXI_IRQ 2
-
-/*                     ERI, RXI, TXI, BRI */
-#define SCI_IRQS      { 23,  24,  25,   0 }
-#define SH3_SCIF_IRQS { 56,  57,  59,  58 }
-#define SH3_IRDA_IRQS { 52,  53,  55,  54 }
-#define SH4_SCIF_IRQS { 40,  41,  43,  42 }
-#define STB1_SCIF1_IRQS {23, 24,  26,  25 }
-#define SH7760_SCIF0_IRQS { 52, 53, 55, 54 }
-#define SH7760_SCIF1_IRQS { 72, 73, 75, 74 }
-#define SH7760_SCIF2_IRQS { 76, 77, 79, 78 }
-#define H8300H_SCI_IRQS0 {52, 53, 54,   0 }
-#define H8300H_SCI_IRQS1 {56, 57, 58,   0 }
-#define H8300H_SCI_IRQS2 {60, 61, 62,   0 }
-#define H8S_SCI_IRQS0 {88, 89, 90,   0 }
-#define H8S_SCI_IRQS1 {92, 93, 94,   0 }
-#define H8S_SCI_IRQS2 {96, 97, 98,   0 }
-
-#if defined(CONFIG_CPU_SUBTYPE_SH7708)
-# define SCI_NPORTS 1
-# define SCI_INIT { \
-  { {}, PORT_SCI,  0xfffffe80, SCI_IRQS,      sci_init_pins_sci  } \
-}
-# define SCSPTR 0xffffff7c /* 8 bit */
-# define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_ONLY
-#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
-  { {}, PORT_SCI,  0xfffffe80, SCI_IRQS,      sci_init_pins_sci  }, \
-  { {}, PORT_SCIF, 0xA4000150, SH3_SCIF_IRQS, sci_init_pins_scif }, \
-  { {}, PORT_SCIF, 0xA4000140, SH3_IRDA_IRQS, sci_init_pins_irda }  \
-}
-# define SCPCR  0xA4000116 /* 16 bit SCI and SCIF */
-# define SCPDR  0xA4000136 /* 8  bit SCI and SCIF */
-# define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_AND_SCIF
-#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
-# define SCI_NPORTS 2
-# define SCI_INIT { \
-  { {}, PORT_SCI,  0xffe00000, SCI_IRQS,      sci_init_pins_sci  }, \
-  { {}, PORT_SCIF, 0xFFE80000, SH4_SCIF_IRQS, sci_init_pins_scif }  \
-}
-# define SCSPTR1 0xffe0001c /* 8  bit SCI */
-# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
-# define SCIF_ORER 0x0001   /* overrun error bit */
-# define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \
-       0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
-       0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
-# define SCI_AND_SCIF
-#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
-  { {}, PORT_SCIF, 0xfe600000, SH7760_SCIF0_IRQS, sci_init_pins_scif }, \
-  { {}, PORT_SCIF, 0xfe610000, SH7760_SCIF1_IRQS, sci_init_pins_scif }, \
-  { {}, PORT_SCIF, 0xfe620000, SH7760_SCIF2_IRQS, sci_init_pins_scif }  \
-}
-# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
-# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
-# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
-# define SCIF_ORDER 0x0001  /* overrun error bit */
-# define SCSCR_INIT(port)          0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
-# define SCIF_ONLY
-#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
-# define SCI_NPORTS 2
-# define SCI_INIT { \
-  { {}, PORT_SCIF, 0xffe00000, STB1_SCIF1_IRQS, sci_init_pins_scif }, \
-  { {}, PORT_SCIF, 0xffe80000, SH4_SCIF_IRQS,   sci_init_pins_scif }  \
-}
-# define SCSPTR1 0xffe00020 /* 16 bit SCIF */
-# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
-# define SCIF_ORER 0x0001   /* overrun error bit */
-# define SCSCR_INIT(port)          0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
-# define SCIF_ONLY
-#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
-  { {}, PORT_SCI,  0x00ffffb0, H8300H_SCI_IRQS0, sci_init_pins_sci }, \
-  { {}, PORT_SCI,  0x00ffffb8, H8300H_SCI_IRQS1, sci_init_pins_sci }, \
-  { {}, PORT_SCI,  0x00ffffc0, H8300H_SCI_IRQS2, sci_init_pins_sci }  \
-}
-# define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_ONLY
-# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
-#elif defined(CONFIG_H8S2678)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
-  { {}, PORT_SCI,  0x00ffff78, H8S_SCI_IRQS0, sci_init_pins_sci }, \
-  { {}, PORT_SCI,  0x00ffff80, H8S_SCI_IRQS1, sci_init_pins_sci }, \
-  { {}, PORT_SCI,  0x00ffff88, H8S_SCI_IRQS2, sci_init_pins_sci }  \
-}
-# define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_ONLY
-# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
-#else
-# error CPU subtype not defined
-#endif
-
-/* SCSCR */
-#define SCI_CTRL_FLAGS_TIE  0x80 /* all */
-#define SCI_CTRL_FLAGS_RIE  0x40 /* all */
-#define SCI_CTRL_FLAGS_TE   0x20 /* all */
-#define SCI_CTRL_FLAGS_RE   0x10 /* all */
-/*      SCI_CTRL_FLAGS_REIE 0x08  * 7750 SCIF */
-/*      SCI_CTRL_FLAGS_MPIE 0x08  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/*      SCI_CTRL_FLAGS_TEIE 0x04  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/*      SCI_CTRL_FLAGS_CKE1 0x02  * all */
-/*      SCI_CTRL_FLAGS_CKE0 0x01  * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */
-
-/* SCxSR SCI */
-#define SCI_TDRE  0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_RDRF  0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_ORER  0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_FER   0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_PER   0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_TEND  0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/*      SCI_MPB   0x02  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/*      SCI_MPBT  0x01  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-
-#define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
-
-/* SCxSR SCIF */
-#define SCIF_ER    0x0080 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_TEND  0x0040 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_TDFE  0x0020 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_BRK   0x0010 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_FER   0x0008 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_PER   0x0004 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_RDF   0x0002 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_DR    0x0001 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-
-#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
-
-#if defined(SCI_ONLY)
-# define SCxSR_TEND(port)              SCI_TEND
-# define SCxSR_ERRORS(port)            SCI_ERRORS
-# define SCxSR_RDxF(port)               SCI_RDRF
-# define SCxSR_TDxE(port)               SCI_TDRE
-# define SCxSR_ORER(port)              SCI_ORER
-# define SCxSR_FER(port)               SCI_FER
-# define SCxSR_PER(port)               SCI_PER
-# define SCxSR_BRK(port)               0x00
-# define SCxSR_RDxF_CLEAR(port)                0xbc
-# define SCxSR_ERROR_CLEAR(port)       0xc4
-# define SCxSR_TDxE_CLEAR(port)                0x78
-# define SCxSR_BREAK_CLEAR(port)       0xc4
-#elif defined(SCIF_ONLY) 
-# define SCxSR_TEND(port)              SCIF_TEND
-# define SCxSR_ERRORS(port)            SCIF_ERRORS
-# define SCxSR_RDxF(port)               SCIF_RDF
-# define SCxSR_TDxE(port)               SCIF_TDFE
-# define SCxSR_ORER(port)              0x0000
-# define SCxSR_FER(port)               SCIF_FER
-# define SCxSR_PER(port)               SCIF_PER
-# define SCxSR_BRK(port)               SCIF_BRK
-# define SCxSR_RDxF_CLEAR(port)                0x00fc
-# define SCxSR_ERROR_CLEAR(port)       0x0073
-# define SCxSR_TDxE_CLEAR(port)                0x00df
-# define SCxSR_BREAK_CLEAR(port)       0x00e3
-#else
-# define SCxSR_TEND(port)       (((port)->type == PORT_SCI) ? SCI_TEND   : SCIF_TEND)
-# define SCxSR_ERRORS(port)     (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
-# define SCxSR_RDxF(port)        (((port)->type == PORT_SCI) ? SCI_RDRF   : SCIF_RDF)
-# define SCxSR_TDxE(port)        (((port)->type == PORT_SCI) ? SCI_TDRE   : SCIF_TDFE)
-# define SCxSR_ORER(port)        (((port)->type == PORT_SCI) ? SCI_ORER   : 0x0000)
-# define SCxSR_FER(port)         (((port)->type == PORT_SCI) ? SCI_FER    : SCIF_FER)
-# define SCxSR_PER(port)         (((port)->type == PORT_SCI) ? SCI_PER    : SCIF_PER)
-# define SCxSR_BRK(port)         (((port)->type == PORT_SCI) ? 0x00       : SCIF_BRK)
-# define SCxSR_RDxF_CLEAR(port)         (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
-# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
-# define SCxSR_TDxE_CLEAR(port)  (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
-# define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
-#endif
-
-/* SCFCR */
-#define SCFCR_RFRST 0x0002
-#define SCFCR_TFRST 0x0004
-#define SCFCR_MCE   0x0008
-
-#define SCI_MAJOR              204
-#define SCI_MINOR_START                8
-
-/* Generic serial flags */
-#define SCI_RX_THROTTLE                0x0000001
-
-#define SCI_MAGIC 0xbabeface
-
-/*
- * Events are used to schedule things to happen at timer-interrupt
- * time, instead of at rs interrupt time.
- */
-#define SCI_EVENT_WRITE_WAKEUP 0
-
-struct sci_port {
-       struct gs_port gs;
-       int type;
-       unsigned int base;
-       unsigned char irqs[4]; /* ERI, RXI, TXI, BRI */
-       void (*init_pins)(struct sci_port* port, unsigned int cflag);
-       unsigned int old_cflag;
-       struct async_icount icount;
-       struct work_struct tqueue;
-       unsigned long event;
-       int break_flag;
-};
-
-#define SCI_IN(size, offset)                                   \
-  unsigned int addr = port->base + (offset);                   \
-  if ((size) == 8) {                                           \
-    return ctrl_inb(addr);                                     \
-  } else {                                                     \
-    return ctrl_inw(addr);                                     \
-  }
-#define SCI_OUT(size, offset, value)                           \
-  unsigned int addr = port->base + (offset);                   \
-  if ((size) == 8) {                                           \
-    ctrl_outb(value, addr);                                    \
-  } else {                                                     \
-    ctrl_outw(value, addr);                                    \
-  }
-
-#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
-  static inline unsigned int sci_##name##_in(struct sci_port* port)    \
-  {                                                                    \
-    if (port->type == PORT_SCI) {                                      \
-      SCI_IN(sci_size, sci_offset)                                     \
-    } else {                                                           \
-      SCI_IN(scif_size, scif_offset);                                  \
-    }                                                                  \
-  }                                                                    \
-  static inline void sci_##name##_out(struct sci_port* port, unsigned int value) \
-  {                                                                    \
-    if (port->type == PORT_SCI) {                                      \
-      SCI_OUT(sci_size, sci_offset, value)                             \
-    } else {                                                           \
-      SCI_OUT(scif_size, scif_offset, value);                          \
-    }                                                                  \
-  }
-
-#define CPU_SCIF_FNS(name, scif_offset, scif_size)                             \
-  static inline unsigned int sci_##name##_in(struct sci_port* port)    \
-  {                                                                    \
-    SCI_IN(scif_size, scif_offset);                                    \
-  }                                                                    \
-  static inline void sci_##name##_out(struct sci_port* port, unsigned int value) \
-  {                                                                    \
-    SCI_OUT(scif_size, scif_offset, value);                            \
-  }
-
-#define CPU_SCI_FNS(name, sci_offset, sci_size)                                \
-  static inline unsigned int sci_##name##_in(struct sci_port* port)    \
-  {                                                                    \
-    SCI_IN(sci_size, sci_offset);                                      \
-  }                                                                    \
-  static inline void sci_##name##_out(struct sci_port* port, unsigned int value) \
-  {                                                                    \
-    SCI_OUT(sci_size, sci_offset, value);                              \
-  }
-
-#ifdef CONFIG_CPU_SH3
-#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
-                sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
-                 h8_sci_offset, h8_sci_size) \
-  CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size)
-#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
-  CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
-#elif defined(__H8300H__) || defined(__H8300S__)
-#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
-                sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
-                 h8_sci_offset, h8_sci_size) \
-  CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
-#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size)
-#else
-#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
-                sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
-                h8_sci_offset, h8_sci_size) \
-  CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
-#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
-  CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
-#endif
-
-/*      reg      SCI/SH3   SCI/SH4  SCIF/SH3   SCIF/SH4  SCI/H8*/
-/*      name     off  sz   off  sz   off  sz   off  sz   off  sz*/
-SCIx_FNS(SCSMR,  0x00,  8, 0x00,  8, 0x00,  8, 0x00, 16, 0x00,  8)
-SCIx_FNS(SCBRR,  0x02,  8, 0x04,  8, 0x02,  8, 0x04,  8, 0x01,  8)
-SCIx_FNS(SCSCR,  0x04,  8, 0x08,  8, 0x04,  8, 0x08, 16, 0x02,  8)
-SCIx_FNS(SCxTDR, 0x06,  8, 0x0c,  8, 0x06,  8, 0x0C,  8, 0x03,  8)
-SCIx_FNS(SCxSR,  0x08,  8, 0x10,  8, 0x08, 16, 0x10, 16, 0x04,  8)
-SCIx_FNS(SCxRDR, 0x0a,  8, 0x14,  8, 0x0A,  8, 0x14,  8, 0x05,  8)
-SCIF_FNS(SCFCR,                      0x0c,  8, 0x18, 16)
-SCIF_FNS(SCFDR,                      0x0e, 16, 0x1C, 16)
-SCIF_FNS(SCLSR,                         0,  0, 0x24, 16)
-
-#define sci_in(port, reg) sci_##reg##_in(port)
-#define sci_out(port, reg, value) sci_##reg##_out(port, value)
-
-/* H8/300 series SCI pins assignment */
-#if defined(__H8300H__) || defined(__H8300S__)
-static const struct __attribute__((packed))
-{
-       int port;             /* GPIO port no */
-       unsigned short rx,tx; /* GPIO bit no */
-} h8300_sci_pins[] =
-{
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
-       {    /* SCI0 */
-               .port = H8300_GPIO_P9,
-               .rx   = H8300_GPIO_B2,
-               .tx   = H8300_GPIO_B0,
-       },
-       {    /* SCI1 */
-               .port = H8300_GPIO_P9,
-               .rx   = H8300_GPIO_B3,
-               .tx   = H8300_GPIO_B1,
-       },
-       {    /* SCI2 */
-               .port = H8300_GPIO_PB,
-               .rx   = H8300_GPIO_B7,
-               .tx   = H8300_GPIO_B6,
-       }
-#elif defined(CONFIG_H8S2678)
-       {    /* SCI0 */
-               .port = H8300_GPIO_P3,
-               .rx   = H8300_GPIO_B2,
-               .tx   = H8300_GPIO_B0,
-       },
-       {    /* SCI1 */
-               .port = H8300_GPIO_P3,
-               .rx   = H8300_GPIO_B3,
-               .tx   = H8300_GPIO_B1,
-       },
-       {    /* SCI2 */
-               .port = H8300_GPIO_P5,
-               .rx   = H8300_GPIO_B1,
-               .tx   = H8300_GPIO_B0,
-       }
-#endif
-};
-#endif
-
-#if defined(CONFIG_CPU_SUBTYPE_SH7708)
-static inline int sci_rxd_in(struct sci_port *port)
-{
-       if (port->base == 0xfffffe80)
-               return ctrl_inb(SCSPTR)&0x01 ? 1 : 0; /* SCI */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
-static inline int sci_rxd_in(struct sci_port *port)
-{
-       if (port->base == 0xfffffe80)
-               return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */
-       if (port->base == 0xa4000150)
-               return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
-       if (port->base == 0xa4000140)
-               return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
-static inline int sci_rxd_in(struct sci_port *port)
-{
-#ifndef SCIF_ONLY
-       if (port->base == 0xffe00000)
-               return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
-#endif
-#ifndef SCI_ONLY
-       if (port->base == 0xffe80000)
-               return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
-#endif
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
-static inline int sci_rxd_in(struct sci_port *port)
-{
-       if (port->base == 0xfe600000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->base == 0xfe610000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->base == 0xfe620000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-}
-#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
-static inline int sci_rxd_in(struct sci_port *port)
-{
-       if (port->base == 0xffe00000)
-               return ctrl_inw(SCSPTR1)&0x0001 ? 1 : 0; /* SCIF */
-       else
-               return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
-
-}
-#elif defined(__H8300H__) || defined(__H8300S__)
-static inline int sci_rxd_in(struct sci_port *port)
-{
-       int ch = (port->base - SMR0) >> 3;
-       return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
-}
-#endif
-
-/*
- * Values for the BitRate Register (SCBRR)
- *
- * The values are actually divisors for a frequency which can
- * be internal to the SH3 (14.7456MHz) or derived from an external
- * clock source.  This driver assumes the internal clock is used;
- * to support using an external clock source, config options or
- * possibly command-line options would need to be added.
- *
- * Also, to support speeds below 2400 (why?) the lower 2 bits of
- * the SCSMR register would also need to be set to non-zero values.
- *
- * -- Greg Banks 27Feb2000
- *
- * Answer: The SCBRR register is only eight bits, and the value in
- * it gets larger with lower baud rates. At around 2400 (depending on
- * the peripherial module clock) you run out of bits. However the
- * lower two bits of SCSMR allow the module clock to be divided down,
- * scaling the value which is needed in SCBRR.
- *
- * -- Stuart Menefy - 23 May 2000
- *
- * I meant, why would anyone bother with bitrates below 2400.
- *
- * -- Greg Banks - 7Jul2000
- *
- * You "speedist"!  How will I use my 110bps ASR-33 teletype with paper
- * tape reader as a console!
- *
- * -- Mitch Davis - 15 Jul 2000
- */
-
-#define PCLK           (current_cpu_data.module_clock)
-
-#if !defined(__H8300H__) && !defined(__H8300S__)
-#define SCBRR_VALUE(bps) ((PCLK+16*bps)/(32*bps)-1)
-#else
-#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
-#endif
-#define BPS_2400       SCBRR_VALUE(2400)
-#define BPS_4800       SCBRR_VALUE(4800)
-#define BPS_9600       SCBRR_VALUE(9600)
-#define BPS_19200      SCBRR_VALUE(19200)
-#define BPS_38400      SCBRR_VALUE(38400)
-#define BPS_57600      SCBRR_VALUE(57600)
-#define BPS_115200     SCBRR_VALUE(115200)
-#define BPS_230400     SCBRR_VALUE(230400)
-
diff --git a/drivers/char/sn_serial.c b/drivers/char/sn_serial.c
deleted file mode 100644 (file)
index c3ba299..0000000
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*
- * C-Brick Serial Port (and console) driver for SGI Altix machines.
- *
- * This driver is NOT suitable for talking to the l1-controller for
- * anything other than 'console activities' --- please use the l1
- * driver for that.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/config.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/module.h>
-#include <linux/sysrq.h>
-#include <linux/circ_buf.h>
-#include <linux/serial_reg.h>
-#include <asm/uaccess.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/simulator.h>
-#include <asm/sn/sn2/sn_private.h>
-
-#if defined(CONFIG_SGI_L1_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-static char sysrq_serial_str[] = "\eSYS";
-static char *sysrq_serial_ptr = sysrq_serial_str;
-static unsigned long sysrq_requested;
-#endif /* CONFIG_SGI_L1_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ */
-
-/* minor device number */
-#define SN_SAL_MINOR 64
-
-/* number of characters left in xmit buffer before we ask for more */
-#define WAKEUP_CHARS 128
-
-/* number of characters we can transmit to the SAL console at a time */
-#define SN_SAL_MAX_CHARS 120
-
-#define SN_SAL_EVENT_WRITE_WAKEUP 0
-
-/* 64K, when we're asynch, it must be at least printk's LOG_BUF_LEN to
- * avoid losing chars, (always has to be a power of 2) */
-#define SN_SAL_BUFFER_SIZE (64 * (1 << 10))
-
-#define SN_SAL_UART_FIFO_DEPTH 16
-#define SN_SAL_UART_FIFO_SPEED_CPS 9600/10
-
-/* we don't kmalloc/get_free_page these as we want them available
- * before either of those are initialized */
-static char sn_xmit_buff_mem[SN_SAL_BUFFER_SIZE];
-
-struct volatile_circ_buf {
-       char *cb_buf;
-       int cb_head;
-       int cb_tail;
-};
-
-static struct volatile_circ_buf xmit = { .cb_buf = sn_xmit_buff_mem };
-static char sn_tmp_buffer[SN_SAL_BUFFER_SIZE];
-
-static struct tty_struct *sn_sal_tty;
-
-static struct timer_list sn_sal_timer;
-static int sn_sal_event; /* event type for task queue */
-
-static int sn_sal_is_asynch;
-static int sn_sal_irq;
-static spinlock_t sn_sal_lock = SPIN_LOCK_UNLOCKED;
-static int sn_total_tx_count;
-static int sn_total_rx_count;
-
-static void sn_sal_tasklet_action(unsigned long data);
-static DECLARE_TASKLET(sn_sal_tasklet, sn_sal_tasklet_action, 0);
-
-static unsigned long sn_interrupt_timeout;
-
-extern u64 master_node_bedrock_address;
-
-#undef DEBUG
-#ifdef DEBUG
-static int sn_debug_printf(const char *fmt, ...);
-#define DPRINTF(x...) sn_debug_printf(x)
-#else
-#define DPRINTF(x...) do { } while (0)
-#endif
-
-struct sn_sal_ops {
-       int (*sal_puts)(const char *s, int len);
-       int (*sal_getc)(void);
-       int (*sal_input_pending)(void);
-       void (*sal_wakeup_transmit)(void);
-};
-
-/* This is the pointer used. It is assigned to point to one of
- * the tables below.
- */
-static struct sn_sal_ops *sn_func;
-
-/* Prototypes */
-static int snt_hw_puts(const char *, int);
-static int snt_poll_getc(void);
-static int snt_poll_input_pending(void);
-static int snt_sim_puts(const char *, int);
-static int snt_sim_getc(void);
-static int snt_sim_input_pending(void);
-static int snt_intr_getc(void);
-static int snt_intr_input_pending(void);
-static void sn_intr_transmit_chars(void);
-
-/* A table for polling */
-static struct sn_sal_ops poll_ops = {
-       .sal_puts               = snt_hw_puts,
-       .sal_getc               = snt_poll_getc,
-       .sal_input_pending      = snt_poll_input_pending
-};
-
-/* A table for the simulator */
-static struct sn_sal_ops sim_ops = {
-       .sal_puts               = snt_sim_puts,
-       .sal_getc               = snt_sim_getc,
-       .sal_input_pending      = snt_sim_input_pending
-};
-
-/* A table for interrupts enabled */
-static struct sn_sal_ops intr_ops = {
-       .sal_puts               = snt_hw_puts,
-       .sal_getc               = snt_intr_getc,
-       .sal_input_pending      = snt_intr_input_pending,
-       .sal_wakeup_transmit    = sn_intr_transmit_chars
-};
-
-
-/* the console does output in two distinctly different ways:
- * synchronous and asynchronous (buffered).  initally, early_printk
- * does synchronous output.  any data written goes directly to the SAL
- * to be output (incidentally, it is internally buffered by the SAL)
- * after interrupts and timers are initialized and available for use,
- * the console init code switches to asynchronous output.  this is
- * also the earliest opportunity to begin polling for console input.
- * after console initialization, console output and tty (serial port)
- * output is buffered and sent to the SAL asynchronously (either by
- * timer callback or by UART interrupt) */
-
-
-/* routines for running the console in polling mode */
-
-static int
-snt_hw_puts(const char *s, int len)
-{
-       /* looking at the PROM source code, putb calls the flush
-        * routine, so if we send characters in FIFO sized chunks, it
-        * should go out by the next time the timer gets called */
-       return ia64_sn_console_putb(s, len);
-}
-
-static int
-snt_poll_getc(void)
-{
-       int ch;
-       ia64_sn_console_getc(&ch);
-       return ch;
-}
-
-static int
-snt_poll_input_pending(void)
-{
-       int status, input;
-
-       status = ia64_sn_console_check(&input);
-       return !status && input;
-}
-
-
-/* routines for running the console on the simulator */
-
-static int
-snt_sim_puts(const char *str, int count)
-{
-       int counter = count;
-
-#ifdef FLAG_DIRECT_CONSOLE_WRITES
-       /* This is an easy way to pre-pend the output to know whether the output
-        * was done via sal or directly */
-       writeb('[', master_node_bedrock_address + (UART_TX << 3));
-       writeb('+', master_node_bedrock_address + (UART_TX << 3));
-       writeb(']', master_node_bedrock_address + (UART_TX << 3));
-       writeb(' ', master_node_bedrock_address + (UART_TX << 3));
-#endif /* FLAG_DIRECT_CONSOLE_WRITES */
-       while (counter > 0) {
-               writeb(*str, master_node_bedrock_address + (UART_TX << 3));
-               counter--;
-               str++;
-       }
-
-       return count;
-}
-
-static int
-snt_sim_getc(void)
-{
-       return readb(master_node_bedrock_address + (UART_RX << 3));
-}
-
-static int
-snt_sim_input_pending(void)
-{
-       return readb(master_node_bedrock_address + (UART_LSR << 3)) & UART_LSR_DR;
-}
-
-
-/* routines for an interrupt driven console (normal) */
-
-static int
-snt_intr_getc(void)
-{
-       return ia64_sn_console_readc();
-}
-
-static int
-snt_intr_input_pending(void)
-{
-       return ia64_sn_console_intr_status() & SAL_CONSOLE_INTR_RECV;
-}
-
-/* The early printk (possible setup) and function call */
-
-void
-early_printk_sn_sal(const char *s, unsigned count)
-{
-       extern void early_sn_setup(void);
-
-       if (!sn_func) {
-               if (IS_RUNNING_ON_SIMULATOR())
-                       sn_func = &sim_ops;
-               else
-                       sn_func = &poll_ops;
-
-               early_sn_setup();
-       }
-       sn_func->sal_puts(s, count);
-}
-
-#ifdef DEBUG
-/* this is as "close to the metal" as we can get, used when the driver
- * itself may be broken */
-static int
-sn_debug_printf(const char *fmt, ...)
-{
-       static char printk_buf[1024];
-       int printed_len;
-       va_list args;
-
-       va_start(args, fmt);
-       printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
-       early_printk_sn_sal(printk_buf, printed_len);
-       va_end(args);
-       return printed_len;
-}
-#endif /* DEBUG */
-
-/*
- * Interrupt handling routines.
- */
-
-static void
-sn_sal_sched_event(int event)
-{
-       sn_sal_event |= (1 << event);
-       tasklet_schedule(&sn_sal_tasklet);
-}
-
-/* sn_receive_chars can be called before sn_sal_tty is initialized.  in
- * that case, its only use is to trigger sysrq and kdb */
-static void
-sn_receive_chars(struct pt_regs *regs, unsigned long *flags)
-{
-       int ch;
-
-       while (sn_func->sal_input_pending()) {
-               ch = sn_func->sal_getc();
-               if (ch < 0) {
-                       printk(KERN_ERR "sn_serial: An error occured while "
-                              "obtaining data from the console (0x%0x)\n", ch);
-                       break;
-               }
-#if defined(CONFIG_SGI_L1_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-               if (sysrq_requested) {
-                       unsigned long sysrq_timeout = sysrq_requested + HZ*5;
-
-                       sysrq_requested = 0;
-                       if (ch && time_before(jiffies, sysrq_timeout)) {
-                               spin_unlock_irqrestore(&sn_sal_lock, *flags);
-                               handle_sysrq(ch, regs, NULL);
-                               spin_lock_irqsave(&sn_sal_lock, *flags);
-                               /* don't record this char */
-                               continue;
-                       }
-               }
-               if (ch == *sysrq_serial_ptr) {
-                       if (!(*++sysrq_serial_ptr)) {
-                               sysrq_requested = jiffies;
-                               sysrq_serial_ptr = sysrq_serial_str;
-                       }
-               }
-               else
-                       sysrq_serial_ptr = sysrq_serial_str;
-#endif /* CONFIG_SGI_L1_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ */
-
-               /* record the character to pass up to the tty layer */
-               if (sn_sal_tty) {
-                       *sn_sal_tty->flip.char_buf_ptr = ch;
-                       sn_sal_tty->flip.char_buf_ptr++;
-                       sn_sal_tty->flip.count++;
-                       if (sn_sal_tty->flip.count == TTY_FLIPBUF_SIZE)
-                               break;
-               }
-               sn_total_rx_count++;
-       }
-
-       if (sn_sal_tty)
-               tty_flip_buffer_push((struct tty_struct *)sn_sal_tty);
-}
-
-
-/* synch_flush_xmit must be called with sn_sal_lock */
-static void
-synch_flush_xmit(void)
-{
-       int xmit_count, tail, head, loops, ii;
-       int result;
-       char *start;
-
-       if (xmit.cb_head == xmit.cb_tail)
-               return; /* Nothing to do. */
-
-       head = xmit.cb_head;
-       tail = xmit.cb_tail;
-       start = &xmit.cb_buf[tail];
-
-       /* twice around gets the tail to the end of the buffer and
-        * then to the head, if needed */
-       loops = (head < tail) ? 2 : 1;
-
-       for (ii = 0; ii < loops; ii++) {
-               xmit_count = (head < tail) ?  (SN_SAL_BUFFER_SIZE - tail) : (head - tail);
-
-               if (xmit_count > 0) {
-                       result = sn_func->sal_puts((char *)start, xmit_count);
-                       if (!result)
-                               DPRINTF("\n*** synch_flush_xmit failed to flush\n");
-                       if (result > 0) {
-                               xmit_count -= result;
-                               sn_total_tx_count += result;
-                               tail += result;
-                               tail &= SN_SAL_BUFFER_SIZE - 1;
-                               xmit.cb_tail = tail;
-                               start = (char *)&xmit.cb_buf[tail];
-                       }
-               }
-       }
-}
-
-/* must be called with a lock protecting the circular buffer and
- * sn_sal_tty */
-static void
-sn_poll_transmit_chars(void)
-{
-       int xmit_count, tail, head;
-       int result;
-       char *start;
-
-       BUG_ON(!sn_sal_is_asynch);
-
-       if (xmit.cb_head == xmit.cb_tail ||
-           (sn_sal_tty && (sn_sal_tty->stopped || sn_sal_tty->hw_stopped))) {
-               /* Nothing to do. */
-               return;
-       }
-
-       head = xmit.cb_head;
-       tail = xmit.cb_tail;
-       start = &xmit.cb_buf[tail];
-
-       xmit_count = (head < tail) ?  (SN_SAL_BUFFER_SIZE - tail) : (head - tail);
-
-       if (xmit_count == 0)
-               DPRINTF("\n*** empty xmit_count\n");
-
-       /* use the ops, as we could be on the simulator */
-       result = sn_func->sal_puts((char *)start, xmit_count);
-       if (!result)
-               DPRINTF("\n*** error in synchronous sal_puts\n");
-       /* XXX chadt clean this up */
-       if (result > 0) {
-               xmit_count -= result;
-               sn_total_tx_count += result;
-               tail += result;
-               tail &= SN_SAL_BUFFER_SIZE - 1;
-               xmit.cb_tail = tail;
-               start = &xmit.cb_buf[tail];
-       }
-
-       /* if there's few enough characters left in the xmit buffer
-        * that we could stand for the upper layer to send us some
-        * more, ask for it. */
-       if (sn_sal_tty)
-               if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < WAKEUP_CHARS)
-                       sn_sal_sched_event(SN_SAL_EVENT_WRITE_WAKEUP);
-}
-
-
-/* must be called with a lock protecting the circular buffer and
- * sn_sal_tty */
-static void
-sn_intr_transmit_chars(void)
-{
-       int xmit_count, tail, head, loops, ii;
-       int result;
-       char *start;
-
-       BUG_ON(!sn_sal_is_asynch);
-
-       if (xmit.cb_head == xmit.cb_tail ||
-           (sn_sal_tty && (sn_sal_tty->stopped || sn_sal_tty->hw_stopped))) {
-               /* Nothing to do. */
-               return;
-       }
-
-       head = xmit.cb_head;
-       tail = xmit.cb_tail;
-       start = &xmit.cb_buf[tail];
-
-       /* twice around gets the tail to the end of the buffer and
-        * then to the head, if needed */
-       loops = (head < tail) ? 2 : 1;
-
-       for (ii = 0; ii < loops; ii++) {
-               xmit_count = (head < tail) ?
-                       (SN_SAL_BUFFER_SIZE - tail) : (head - tail);
-
-               if (xmit_count > 0) {
-                       result = ia64_sn_console_xmit_chars((char *)start, xmit_count);
-#ifdef DEBUG
-                       if (!result)
-                               DPRINTF("`");
-#endif
-                       if (result > 0) {
-                               xmit_count -= result;
-                               sn_total_tx_count += result;
-                               tail += result;
-                               tail &= SN_SAL_BUFFER_SIZE - 1;
-                               xmit.cb_tail = tail;
-                               start = &xmit.cb_buf[tail];
-                       }
-               }
-       }
-
-       /* if there's few enough characters left in the xmit buffer
-        * that we could stand for the upper layer to send us some
-        * more, ask for it. */
-       if (sn_sal_tty)
-               if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < WAKEUP_CHARS)
-                       sn_sal_sched_event(SN_SAL_EVENT_WRITE_WAKEUP);
-}
-
-
-static irqreturn_t
-sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       /* this call is necessary to pass the interrupt back to the
-        * SAL, since it doesn't intercept the UART interrupts
-        * itself */
-       int status = ia64_sn_console_intr_status();
-       unsigned long flags;
-
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       if (status & SAL_CONSOLE_INTR_RECV)
-               sn_receive_chars(regs, &flags);
-       if (status & SAL_CONSOLE_INTR_XMIT)
-               sn_intr_transmit_chars();
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-       return IRQ_HANDLED;
-}
-
-
-/* returns the console irq if interrupt is successfully registered,
- * else 0 */
-static int
-sn_sal_connect_interrupt(void)
-{
-       cpuid_t intr_cpuid;
-       unsigned int intr_cpuloc;
-       nasid_t console_nasid;
-       unsigned int console_irq;
-       int result;
-
-       console_nasid = ia64_sn_get_console_nasid();
-       intr_cpuid = first_cpu(node_to_cpumask(nasid_to_cnodeid(console_nasid)));
-       intr_cpuloc = cpu_physical_id(intr_cpuid);
-       console_irq = CPU_VECTOR_TO_IRQ(intr_cpuloc, SGI_UART_VECTOR);
-
-       result = intr_connect_level(intr_cpuid, SGI_UART_VECTOR);
-       BUG_ON(result != SGI_UART_VECTOR);
-
-       result = request_irq(console_irq, sn_sal_interrupt, SA_INTERRUPT,  "SAL console driver", &sn_sal_tty);
-       if (result >= 0)
-               return console_irq;
-
-       printk(KERN_WARNING "sn_serial: console proceeding in polled mode\n");
-       return 0;
-}
-
-static void
-sn_sal_tasklet_action(unsigned long data)
-{
-       unsigned long flags;
-
-       if (sn_sal_tty) {
-               spin_lock_irqsave(&sn_sal_lock, flags);
-               if (sn_sal_tty) {
-                       if (test_and_clear_bit(SN_SAL_EVENT_WRITE_WAKEUP, &sn_sal_event)) {
-                               if ((sn_sal_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && sn_sal_tty->ldisc.write_wakeup)
-                                       (sn_sal_tty->ldisc.write_wakeup)((struct tty_struct *)sn_sal_tty);
-                               wake_up_interruptible((wait_queue_head_t *)&sn_sal_tty->write_wait);
-                       }
-               }
-               spin_unlock_irqrestore(&sn_sal_lock, flags);
-       }
-}
-
-
-/*
- * This function handles polled mode.
- */
-static void
-sn_sal_timer_poll(unsigned long dummy)
-{
-       unsigned long flags;
-
-       if (!sn_sal_irq) {
-               spin_lock_irqsave(&sn_sal_lock, flags);
-               sn_receive_chars(NULL, &flags);
-               sn_poll_transmit_chars();
-               spin_unlock_irqrestore(&sn_sal_lock, flags);
-               mod_timer(&sn_sal_timer, jiffies + sn_interrupt_timeout);
-       }
-}
-
-
-/*
- * User-level console routines
- */
-
-static int
-sn_sal_open(struct tty_struct *tty, struct file *filp)
-{
-       unsigned long flags;
-
-       DPRINTF("sn_sal_open: sn_sal_tty = %p, tty = %p, filp = %p\n",
-               sn_sal_tty, tty, filp);
-
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       if (!sn_sal_tty)
-               sn_sal_tty = tty;
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-
-       return 0;
-}
-
-
-/* We're keeping all our resources.  We're keeping interrupts turned
- * on.  Maybe just let the tty layer finish its stuff...? GMSH
- */
-static void
-sn_sal_close(struct tty_struct *tty, struct file * filp)
-{
-       if (tty->count == 1) {
-               unsigned long flags;
-               tty->closing = 1;
-               if (tty->driver->flush_buffer)
-                       tty->driver->flush_buffer(tty);
-               if (tty->ldisc.flush_buffer)
-                       tty->ldisc.flush_buffer(tty);
-               tty->closing = 0;
-               spin_lock_irqsave(&sn_sal_lock, flags);
-               sn_sal_tty = NULL;
-               spin_unlock_irqrestore(&sn_sal_lock, flags);
-       }
-}
-
-
-static int
-sn_sal_write(struct tty_struct *tty, int from_user,
-            const unsigned char *buf, int count)
-{
-       int c, ret = 0;
-       unsigned long flags;
-
-       if (from_user) {
-               while (1) {
-                       int c1;
-                       c = CIRC_SPACE_TO_END(xmit.cb_head, xmit.cb_tail,
-                                             SN_SAL_BUFFER_SIZE);
-
-                       if (count < c)
-                               c = count;
-                       if (c <= 0)
-                               break;
-
-                       c -= copy_from_user(sn_tmp_buffer, buf, c);
-                       if (!c) {
-                               if (!ret)
-                                       ret = -EFAULT;
-                               break;
-                       }
-
-                       /* Turn off interrupts and see if the xmit buffer has
-                        * moved since the last time we looked.
-                        */
-                       spin_lock_irqsave(&sn_sal_lock, flags);
-                       c1 = CIRC_SPACE_TO_END(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
-
-                       if (c1 < c)
-                               c = c1;
-
-                       memcpy(xmit.cb_buf + xmit.cb_head, sn_tmp_buffer, c);
-                       xmit.cb_head = ((xmit.cb_head + c) & (SN_SAL_BUFFER_SIZE - 1));
-                       spin_unlock_irqrestore(&sn_sal_lock, flags);
-
-                       buf += c;
-                       count -= c;
-                       ret += c;
-               }
-       }
-       else {
-               /* The buffer passed in isn't coming from userland,
-                * so cut out the middleman (sn_tmp_buffer).
-                */
-               spin_lock_irqsave(&sn_sal_lock, flags);
-               while (1) {
-                       c = CIRC_SPACE_TO_END(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
-
-                       if (count < c)
-                               c = count;
-                       if (c <= 0) {
-                               break;
-                       }
-                       memcpy(xmit.cb_buf + xmit.cb_head, buf, c);
-                       xmit.cb_head = ((xmit.cb_head + c) & (SN_SAL_BUFFER_SIZE - 1));
-                       buf += c;
-                       count -= c;
-                       ret += c;
-               }
-               spin_unlock_irqrestore(&sn_sal_lock, flags);
-       }
-
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       if (xmit.cb_head != xmit.cb_tail && !(tty && (tty->stopped || tty->hw_stopped)))
-               if (sn_func->sal_wakeup_transmit)
-                       sn_func->sal_wakeup_transmit();
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-
-       return ret;
-}
-
-
-static void
-sn_sal_put_char(struct tty_struct *tty, unsigned char ch)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       if (CIRC_SPACE(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) != 0) {
-               xmit.cb_buf[xmit.cb_head] = ch;
-               xmit.cb_head = (xmit.cb_head + 1) & (SN_SAL_BUFFER_SIZE-1);
-               if ( sn_func->sal_wakeup_transmit )
-                       sn_func->sal_wakeup_transmit();
-       }
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-}
-
-
-static void
-sn_sal_flush_chars(struct tty_struct *tty)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE))
-               if (sn_func->sal_wakeup_transmit)
-                       sn_func->sal_wakeup_transmit();
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-}
-
-
-static int
-sn_sal_write_room(struct tty_struct *tty)
-{
-       unsigned long flags;
-       int space;
-
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       space = CIRC_SPACE(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-       return space;
-}
-
-
-static int
-sn_sal_chars_in_buffer(struct tty_struct *tty)
-{
-       unsigned long flags;
-       int space;
-
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       space = CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
-       DPRINTF("<%d>", space);
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-       return space;
-}
-
-
-static void
-sn_sal_flush_buffer(struct tty_struct *tty)
-{
-       unsigned long flags;
-
-       /* drop everything */
-       spin_lock_irqsave(&sn_sal_lock, flags);
-       xmit.cb_head = xmit.cb_tail = 0;
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-
-       /* wake up tty level */
-       wake_up_interruptible(&tty->write_wait);
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup)(tty);
-}
-
-
-static void
-sn_sal_hangup(struct tty_struct *tty)
-{
-       sn_sal_flush_buffer(tty);
-}
-
-
-static void
-sn_sal_wait_until_sent(struct tty_struct *tty, int timeout)
-{
-       /* this is SAL's problem */
-       DPRINTF("<sn_serial: should wait until sent>");
-}
-
-
-/*
- * sn_sal_read_proc
- *
- * Console /proc interface
- */
-
-static int
-sn_sal_read_proc(char *page, char **start, off_t off, int count,
-                  int *eof, void *data)
-{
-       int len = 0;
-       off_t   begin = 0;
-
-       len += sprintf(page, "sn_serial: nasid:%ld irq:%d tx:%d rx:%d\n",
-                      ia64_sn_get_console_nasid(), sn_sal_irq,
-                      sn_total_tx_count, sn_total_rx_count);
-       *eof = 1;
-
-       if (off >= len+begin)
-               return 0;
-       *start = page + (off-begin);
-
-       return count < begin+len-off ? count : begin+len-off;
-}
-
-
-static struct tty_operations sn_sal_driver_ops = {
-       .open            = sn_sal_open,
-       .close           = sn_sal_close,
-       .write           = sn_sal_write,
-       .put_char        = sn_sal_put_char,
-       .flush_chars     = sn_sal_flush_chars,
-       .write_room      = sn_sal_write_room,
-       .chars_in_buffer = sn_sal_chars_in_buffer,
-       .hangup          = sn_sal_hangup,
-       .wait_until_sent = sn_sal_wait_until_sent,
-       .read_proc       = sn_sal_read_proc,
-};
-static struct tty_driver *sn_sal_driver;
-
-/* sn_sal_init wishlist:
- * - allocate sn_tmp_buffer
- * - fix up the tty_driver struct
- * - turn on receive interrupts
- * - do any termios twiddling once and for all
- */
-
-/*
- * Boot-time initialization code
- */
-
-static void __init
-sn_sal_switch_to_asynch(void)
-{
-       unsigned long flags;
-
-       /* without early_printk, we may be invoked late enough to race
-        * with other cpus doing console IO at this point, however
-        * console interrupts will never be enabled */
-       spin_lock_irqsave(&sn_sal_lock, flags);
-
-       if (sn_sal_is_asynch) {
-               spin_unlock_irqrestore(&sn_sal_lock, flags);
-               return;
-       }
-
-       DPRINTF("sn_serial: switch to asynchronous console\n");
-
-       /* early_printk invocation may have done this for us */
-       if (!sn_func) {
-               if (IS_RUNNING_ON_SIMULATOR())
-                       sn_func = &sim_ops;
-               else
-                       sn_func = &poll_ops;
-       }
-
-       /* we can't turn on the console interrupt (as request_irq
-        * calls kmalloc, which isn't set up yet), so we rely on a
-        * timer to poll for input and push data from the console
-        * buffer.
-        */
-       init_timer(&sn_sal_timer);
-       sn_sal_timer.function = sn_sal_timer_poll;
-
-       if (IS_RUNNING_ON_SIMULATOR())
-               sn_interrupt_timeout = 6;
-       else {
-               /* 960cps / 16 char FIFO = 60HZ
-                * HZ / (SN_SAL_FIFO_SPEED_CPS / SN_SAL_FIFO_DEPTH) */
-               sn_interrupt_timeout = HZ * SN_SAL_UART_FIFO_DEPTH / SN_SAL_UART_FIFO_SPEED_CPS;
-       }
-       mod_timer(&sn_sal_timer, jiffies + sn_interrupt_timeout);
-
-       sn_sal_is_asynch = 1;
-       spin_unlock_irqrestore(&sn_sal_lock, flags);
-}
-
-static void __init
-sn_sal_switch_to_interrupts(void)
-{
-       int irq;
-
-       DPRINTF("sn_serial: switching to interrupt driven console\n");
-
-       irq = sn_sal_connect_interrupt();
-       if (irq) {
-               unsigned long flags;
-               spin_lock_irqsave(&sn_sal_lock, flags);
-
-               /* sn_sal_irq is a global variable.  When it's set to
-                * a non-zero value, we stop polling for input (since
-                * interrupts should now be enabled). */
-               sn_sal_irq = irq;
-               sn_func = &intr_ops;
-
-               /* turn on receive interrupts */
-               ia64_sn_console_intr_enable(SAL_CONSOLE_INTR_RECV);
-               spin_unlock_irqrestore(&sn_sal_lock, flags);
-       }
-}
-
-static int __init
-sn_sal_module_init(void)
-{
-       int retval;
-
-       DPRINTF("sn_serial: sn_sal_module_init\n");
-
-       if (!ia64_platform_is("sn2"))
-               return -ENODEV;
-
-       sn_sal_driver = alloc_tty_driver(1);
-       if ( !sn_sal_driver )
-               return -ENOMEM;
-
-       sn_sal_driver->owner = THIS_MODULE;
-       sn_sal_driver->driver_name = "sn_serial";
-       sn_sal_driver->name = "ttyS";
-       sn_sal_driver->major = TTY_MAJOR;
-       sn_sal_driver->minor_start = SN_SAL_MINOR;
-       sn_sal_driver->type = TTY_DRIVER_TYPE_SERIAL;
-       sn_sal_driver->subtype = SERIAL_TYPE_NORMAL;
-       sn_sal_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
-
-       tty_set_operations(sn_sal_driver, &sn_sal_driver_ops);
-
-       /* when this driver is compiled in, the console initialization
-        * will have already switched us into asynchronous operation
-        * before we get here through the module initcalls */
-       sn_sal_switch_to_asynch();
-
-       /* at this point (module_init) we can try to turn on interrupts */
-       if (!IS_RUNNING_ON_SIMULATOR())
-           sn_sal_switch_to_interrupts();
-
-       sn_sal_driver->init_termios = tty_std_termios;
-       sn_sal_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-
-       if ((retval = tty_register_driver(sn_sal_driver))) {
-               printk(KERN_ERR "sn_serial: Unable to register tty driver\n");
-               return retval;
-       }
-       return 0;
-}
-
-
-static void __exit
-sn_sal_module_exit(void)
-{
-       del_timer_sync(&sn_sal_timer);
-       tty_unregister_driver(sn_sal_driver);
-       put_tty_driver(sn_sal_driver);
-}
-
-module_init(sn_sal_module_init);
-module_exit(sn_sal_module_exit);
-
-/*
- * Kernel console definitions
- */
-
-#ifdef CONFIG_SGI_L1_SERIAL_CONSOLE
-/*
- * Print a string to the SAL console.  The console_lock must be held
- * when we get here.
- */
-static void
-sn_sal_console_write(struct console *co, const char *s, unsigned count)
-{
-       unsigned long flags;
-       const char *s1;
-
-       BUG_ON(!sn_sal_is_asynch);
-
-       /* somebody really wants this output, might be an
-        * oops, kdb, panic, etc.  make sure they get it. */
-       if (spin_is_locked(&sn_sal_lock)) {
-               synch_flush_xmit();
-               /* Output '\r' before each '\n' */
-               while ((s1 = memchr(s, '\n', count)) != NULL) {
-                       sn_func->sal_puts(s, s1 - s);
-                       sn_func->sal_puts("\r\n", 2);
-                       count -= s1 + 1 - s;
-                       s = s1 + 1;
-               }
-               sn_func->sal_puts(s, count);
-       }
-       else if (in_interrupt()) {
-               spin_lock_irqsave(&sn_sal_lock, flags);
-               synch_flush_xmit();
-               spin_unlock_irqrestore(&sn_sal_lock, flags);
-               /* Output '\r' before each '\n' */
-               while ((s1 = memchr(s, '\n', count)) != NULL) {
-                       sn_func->sal_puts(s, s1 - s);
-                       sn_func->sal_puts("\r\n", 2);
-                       count -= s1 + 1 - s;
-                       s = s1 + 1;
-               }
-               sn_func->sal_puts(s, count);
-       }
-       else {
-               /* Output '\r' before each '\n' */
-               while ((s1 = memchr(s, '\n', count)) != NULL) {
-                       sn_sal_write(NULL, 0, s, s1 - s);
-                       sn_sal_write(NULL, 0, "\r\n", 2);
-                       count -= s1 + 1 - s;
-                       s = s1 + 1;
-               }
-               sn_sal_write(NULL, 0, s, count);
-       }
-}
-
-static struct tty_driver *
-sn_sal_console_device(struct console *c, int *index)
-{
-       *index = c->index;
-       return sn_sal_driver;
-}
-
-static int __init
-sn_sal_console_setup(struct console *co, char *options)
-{
-       return 0;
-}
-
-
-static struct console sal_console = {
-       .name = "ttyS",
-       .write = sn_sal_console_write,
-       .device = sn_sal_console_device,
-       .setup = sn_sal_console_setup,
-       .index = -1
-};
-
-static int __init
-sn_sal_serial_console_init(void)
-{
-       if (ia64_platform_is("sn2")) {
-               sn_sal_switch_to_asynch();
-               DPRINTF("sn_sal_serial_console_init : register console\n");
-               register_console(&sal_console);
-       }
-       return 0;
-}
-console_initcall(sn_sal_serial_console_init);
-
-#endif /* CONFIG_SGI_L1_SERIAL_CONSOLE */
index da52bff..c9688f1 100644 (file)
@@ -107,6 +107,17 @@ static struct sysrq_key_op sysrq_reboot_op = {
        .action_msg     = "Resetting",
 };
 
+/* crash sysrq handler */
+static void sysrq_handle_crash(int key, struct pt_regs *pt_regs,
+                              struct tty_struct *tty) {
+       *( (char *) 0) = 0;
+}
+static struct sysrq_key_op sysrq_crash_op = {
+       handler:        sysrq_handle_crash,
+       help_msg:       "Crash",
+       action_msg:     "Crashing the kernel by request",
+};
+
 static void sysrq_handle_sync(int key, struct pt_regs *pt_regs,
                              struct tty_struct *tty) 
 {
@@ -235,7 +246,7 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
                 it is handled specially on the sparc
                 and will never arrive */
 /* b */        &sysrq_reboot_op,
-/* c */ NULL,
+/* c */ &sysrq_crash_op,
 /* d */        NULL,
 /* e */        &sysrq_term_op,
 /* f */        NULL,
index 91f530c..4f6ff61 100644 (file)
@@ -142,6 +142,7 @@ static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *);
 ssize_t redirected_tty_write(struct file *, const char __user *, size_t, loff_t *);
 static unsigned int tty_poll(struct file *, poll_table *);
 static int tty_open(struct inode *, struct file *);
+static int ptmx_open(struct inode *, struct file *);
 static int tty_release(struct inode *, struct file *);
 int tty_ioctl(struct inode * inode, struct file * file,
              unsigned int cmd, unsigned long arg);
@@ -377,6 +378,19 @@ static struct file_operations tty_fops = {
        .fasync         = tty_fasync,
 };
 
+#ifdef CONFIG_UNIX98_PTYS
+static struct file_operations ptmx_fops = {
+       .llseek         = no_llseek,
+       .read           = tty_read,
+       .write          = tty_write,
+       .poll           = tty_poll,
+       .ioctl          = tty_ioctl,
+       .open           = ptmx_open,
+       .release        = tty_release,
+       .fasync         = tty_fasync,
+};
+#endif
+
 static struct file_operations console_fops = {
        .llseek         = no_llseek,
        .read           = tty_read,
@@ -1358,53 +1372,13 @@ retry_open:
                return -ENODEV;
        }
 
-#ifdef CONFIG_UNIX98_PTYS
-       if (device == MKDEV(TTYAUX_MAJOR,2)) {
-               int idr_ret;
-
-               /* find a device that is not in use. */
-               down(&allocated_ptys_lock);
-               if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) {
-                       up(&allocated_ptys_lock);
-                       return -ENOMEM;
-               }
-               idr_ret = idr_get_new(&allocated_ptys, NULL, &index);
-               if (idr_ret < 0) {
-                       up(&allocated_ptys_lock);
-                       if (idr_ret == -EAGAIN)
-                               return -ENOMEM;
-                       return -EIO;
-               }
-               if (index >= pty_limit) {
-                       idr_remove(&allocated_ptys, index);
-                       up(&allocated_ptys_lock);
-                       return -EIO;
-               }
-               up(&allocated_ptys_lock);
-
-               driver = ptm_driver;
-               retval = init_dev(driver, index, &tty);
-               if (retval) {
-                       down(&allocated_ptys_lock);
-                       idr_remove(&allocated_ptys, index);
-                       up(&allocated_ptys_lock);
-                       return retval;
-               }
-
-               set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
-               if (devpts_pty_new(tty->link))
-                       retval = -ENOMEM;
-       } else
-#endif
-       {
-               driver = get_tty_driver(device, &index);
-               if (!driver)
-                       return -ENODEV;
+       driver = get_tty_driver(device, &index);
+       if (!driver)
+               return -ENODEV;
 got_driver:
-               retval = init_dev(driver, index, &tty);
-               if (retval)
-                       return retval;
-       }
+       retval = init_dev(driver, index, &tty);
+       if (retval)
+               return retval;
 
        filp->private_data = tty;
        file_move(filp, &tty->tty_files);
@@ -1431,15 +1405,6 @@ got_driver:
                printk(KERN_DEBUG "error %d in opening %s...", retval,
                       tty->name);
 #endif
-
-#ifdef CONFIG_UNIX98_PTYS
-               if (index != -1) {
-                       down(&allocated_ptys_lock);
-                       idr_remove(&allocated_ptys, index);
-                       up(&allocated_ptys_lock);
-               }
-#endif
-
                release_dev(filp);
                if (retval != -ERESTARTSYS)
                        return retval;
@@ -1467,6 +1432,62 @@ got_driver:
        return 0;
 }
 
+#ifdef CONFIG_UNIX98_PTYS
+static int ptmx_open(struct inode * inode, struct file * filp)
+{
+       struct tty_struct *tty;
+       int retval;
+       int index;
+       int idr_ret;
+
+       nonseekable_open(inode, filp);
+
+       /* find a device that is not in use. */
+       down(&allocated_ptys_lock);
+       if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) {
+               up(&allocated_ptys_lock);
+               return -ENOMEM;
+       }
+       idr_ret = idr_get_new(&allocated_ptys, NULL, &index);
+       if (idr_ret < 0) {
+               up(&allocated_ptys_lock);
+               if (idr_ret == -EAGAIN)
+                       return -ENOMEM;
+               return -EIO;
+       }
+       if (index >= pty_limit) {
+               idr_remove(&allocated_ptys, index);
+               up(&allocated_ptys_lock);
+               return -EIO;
+       }
+       up(&allocated_ptys_lock);
+
+       retval = init_dev(ptm_driver, index, &tty);
+       if (retval)
+               goto out;
+
+       set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
+       filp->private_data = tty;
+       file_move(filp, &tty->tty_files);
+
+       retval = -ENOMEM;
+       if (devpts_pty_new(tty->link))
+               goto out1;
+
+       check_tty_count(tty, "tty_open");
+       retval = ptm_driver->open(tty, filp);
+       if (!retval)
+               return 0;
+out1:
+       release_dev(filp);
+out:
+       down(&allocated_ptys_lock);
+       idr_remove(&allocated_ptys, index);
+       up(&allocated_ptys_lock);
+       return retval;
+}
+#endif
+
 static int tty_release(struct inode * inode, struct file * filp)
 {
        lock_kernel();
@@ -2441,7 +2462,7 @@ static int __init tty_init(void)
        class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
 
 #ifdef CONFIG_UNIX98_PTYS
-       cdev_init(&ptmx_cdev, &tty_fops);
+       cdev_init(&ptmx_cdev, &ptmx_fops);
        if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
                panic("Couldn't register /dev/ptmx driver\n");
diff --git a/drivers/char/upd4990a.c b/drivers/char/upd4990a.c
deleted file mode 100644 (file)
index f06f509..0000000
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * NEC PC-9800 Real Time Clock interface for Linux     
- *
- * Copyright (C) 1997-2001  Linux/98 project,
- *                         Kyoto University Microcomputer Club.
- *
- * Based on:
- *     drivers/char/rtc.c by Paul Gortmaker
- *
- * Changes:
- *  2001-02-09 Call check_region on rtc_init and do not request I/O 0033h.
- *             Call del_timer and release_region on rtc_exit. -- tak
- *  2001-07-14 Rewrite <linux/upd4990a.h> and split to <linux/upd4990a.h>
- *             and <asm-i386/upd4990a.h>.
- *             Introduce a lot of spin_lock/unlock (&rtc_lock).
- */
-
-#define RTC98_VERSION  "1.2"
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/miscdevice.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/rtc.h>
-#include <linux/bcd.h>
-#include <linux/upd4990a.h>
-#include <linux/init.h>
-#include <linux/poll.h>
-#include <linux/proc_fs.h>
-#include <linux/spinlock.h>
-
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-/*
- *     We sponge a minor off of the misc major. No need slurping
- *     up another valuable major dev number for this. If you add
- *     an ioctl, make sure you don't conflict with SPARC's RTC
- *     ioctls.
- */
-
-static struct fasync_struct *rtc_async_queue;
-
-static DECLARE_WAIT_QUEUE_HEAD(rtc_wait);
-
-static struct timer_list rtc_uie_timer;
-static u8 old_refclk;
-
-static int rtc_ioctl(struct inode *inode, struct file *file,
-                       unsigned int cmd, unsigned long arg);
-
-static int rtc_read_proc(char *page, char **start, off_t off,
-                         int count, int *eof, void *data);
-
-/*
- *     Bits in rtc_status. (5 bits of room for future expansion)
- */
-
-#define RTC_IS_OPEN            0x01    /* means /dev/rtc is in use     */
-#define RTC_TIMER_ON            0x02    /* not used */
-#define RTC_UIE_TIMER_ON        0x04   /* UIE emulation timer is active */
-
-/*
- * rtc_status is never changed by rtc_interrupt, and ioctl/open/close is
- * protected by the big kernel lock. However, ioctl can still disable the timer
- * in rtc_status and then with del_timer after the interrupt has read
- * rtc_status but before mod_timer is called, which would then reenable the
- * timer (but you would need to have an awful timing before you'd trip on it)
- */
-static unsigned char rtc_status;       /* bitmapped status byte.       */
-static unsigned long rtc_irq_data;     /* our output to the world      */
-
-static const unsigned char days_in_mo[] = 
-{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-
-extern spinlock_t rtc_lock;    /* defined in arch/i386/kernel/time.c */
-
-static void rtc_uie_intr(unsigned long data)
-{
-       u8 refclk, tmp;
-
-       /* Kernel timer does del_timer internally before calling
-          each timer entry, so this is unnecessary.
-          del_timer(&rtc_uie_timer);  */
-       spin_lock(&rtc_lock);
-
-       /* Detect rising edge of 1Hz reference clock.  */
-       refclk = UPD4990A_READ_DATA();
-       tmp = old_refclk & refclk;
-       old_refclk = ~refclk;
-       if (!(tmp & 1))
-               rtc_irq_data += 0x100;
-
-       spin_unlock(&rtc_lock);
-
-       if (!(tmp & 1)) {
-               /* Now do the rest of the actions */
-               wake_up_interruptible(&rtc_wait);
-               kill_fasync(&rtc_async_queue, SIGIO, POLL_IN);
-       }
-
-       rtc_uie_timer.expires = jiffies + 1;
-       add_timer(&rtc_uie_timer);
-}
-
-/*
- *     Now all the various file operations that we export.
- */
-
-static ssize_t rtc_read(struct file *file, char *buf,
-                       size_t count, loff_t *ppos)
-{
-       DECLARE_WAITQUEUE(wait, current);
-       unsigned long data;
-       ssize_t retval = 0;
-       
-       if (count < sizeof(unsigned long))
-               return -EINVAL;
-
-       add_wait_queue(&rtc_wait, &wait);
-
-       set_current_state(TASK_INTERRUPTIBLE);
-
-       do {
-               /* First make it right. Then make it fast. Putting this whole
-                * block within the parentheses of a while would be too
-                * confusing. And no, xchg() is not the answer. */
-               spin_lock_irq(&rtc_lock);
-               data = rtc_irq_data;
-               rtc_irq_data = 0;
-               spin_unlock_irq(&rtc_lock);
-
-               if (data != 0)
-                       break;
-               if (file->f_flags & O_NONBLOCK) {
-                       retval = -EAGAIN;
-                       goto out;
-               }
-               if (signal_pending(current)) {
-                       retval = -ERESTARTSYS;
-                       goto out;
-               }
-               schedule();
-       } while (1);
-
-       retval = put_user(data, (unsigned long *)buf);
-       if (!retval)
-               retval = sizeof(unsigned long); 
- out:
-       set_current_state(TASK_RUNNING);
-       remove_wait_queue(&rtc_wait, &wait);
-
-       return retval;
-}
-
-static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-                    unsigned long arg)
-{
-       struct rtc_time wtime; 
-       struct upd4990a_raw_data raw;
-
-       switch (cmd) {
-       case RTC_UIE_OFF:       /* Mask ints from RTC updates.  */
-               spin_lock_irq(&rtc_lock);
-               if (rtc_status & RTC_UIE_TIMER_ON) {
-                       rtc_status &= ~RTC_UIE_TIMER_ON;
-                       del_timer(&rtc_uie_timer);
-               }
-               spin_unlock_irq(&rtc_lock);
-               return 0;
-
-       case RTC_UIE_ON:        /* Allow ints for RTC updates.  */
-               spin_lock_irq(&rtc_lock);
-               rtc_irq_data = 0;
-               if (!(rtc_status & RTC_UIE_TIMER_ON)) {
-                       rtc_status |= RTC_UIE_TIMER_ON;
-                       rtc_uie_timer.expires = jiffies + 1;
-                       add_timer(&rtc_uie_timer);
-               }
-               /* Just in case... */
-               upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-               old_refclk = ~UPD4990A_READ_DATA();
-               spin_unlock_irq(&rtc_lock);
-               return 0;
-
-       case RTC_RD_TIME:       /* Read the time/date from RTC  */
-               spin_lock_irq(&rtc_lock);
-               upd4990a_get_time(&raw, 0);
-               spin_unlock_irq(&rtc_lock);
-
-               wtime.tm_sec    = BCD2BIN(raw.sec);
-               wtime.tm_min    = BCD2BIN(raw.min);
-               wtime.tm_hour   = BCD2BIN(raw.hour);
-               wtime.tm_mday   = BCD2BIN(raw.mday);
-               wtime.tm_mon    = raw.mon - 1; /* convert to 0-base */
-               wtime.tm_wday   = raw.wday;
-
-               /*
-                * Account for differences between how the RTC uses the values
-                * and how they are defined in a struct rtc_time;
-                */
-               if ((wtime.tm_year = BCD2BIN(raw.year)) < 95)
-                       wtime.tm_year += 100;
-
-               wtime.tm_isdst = 0;
-               break;
-
-       case RTC_SET_TIME:      /* Set the RTC */
-       {
-               int leap_yr;
-
-               if (!capable(CAP_SYS_TIME))
-                       return -EACCES;
-
-               if (copy_from_user(&wtime, (struct rtc_time *) arg,
-                                   sizeof (struct rtc_time)))
-                       return -EFAULT;
-
-               /* Valid year is 1995 - 2094, inclusive.  */
-               if (wtime.tm_year < 95 || wtime.tm_year > 194)
-                       return -EINVAL;
-
-               if (wtime.tm_mon > 11 || wtime.tm_mday == 0)
-                       return -EINVAL;
-
-               /* For acceptable year domain (1995 - 2094),
-                  this IS sufficient.  */
-               leap_yr = !(wtime.tm_year % 4);
-
-               if (wtime.tm_mday > (days_in_mo[wtime.tm_mon]
-                                    + (wtime.tm_mon == 2 && leap_yr)))
-                       return -EINVAL;
-                       
-               if (wtime.tm_hour >= 24
-                   || wtime.tm_min >= 60 || wtime.tm_sec >= 60)
-                       return -EINVAL;
-
-               if (wtime.tm_wday > 6)
-                       return -EINVAL;
-
-               raw.sec  = BIN2BCD(wtime.tm_sec);
-               raw.min  = BIN2BCD(wtime.tm_min);
-               raw.hour = BIN2BCD(wtime.tm_hour);
-               raw.mday = BIN2BCD(wtime.tm_mday);
-               raw.mon  = wtime.tm_mon + 1;
-               raw.wday = wtime.tm_wday;
-               raw.year = BIN2BCD(wtime.tm_year % 100);
-
-               spin_lock_irq(&rtc_lock);
-               upd4990a_set_time(&raw, 0);
-               spin_unlock_irq(&rtc_lock);
-
-               return 0;
-       }
-       default:
-               return -EINVAL;
-       }
-       return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0;
-}
-
-/*
- *     We enforce only one user at a time here with the open/close.
- *     Also clear the previous interrupt data on an open, and clean
- *     up things on a close.
- */
-
-static int rtc_open(struct inode *inode, struct file *file)
-{
-       spin_lock_irq(&rtc_lock);
-
-       if(rtc_status & RTC_IS_OPEN)
-               goto out_busy;
-
-       rtc_status |= RTC_IS_OPEN;
-
-       rtc_irq_data = 0;
-       spin_unlock_irq(&rtc_lock);
-       return 0;
-
- out_busy:
-       spin_unlock_irq(&rtc_lock);
-       return -EBUSY;
-}
-
-static int rtc_fasync(int fd, struct file *filp, int on)
-{
-       return fasync_helper(fd, filp, on, &rtc_async_queue);
-}
-
-static int rtc_release(struct inode *inode, struct file *file)
-{
-       del_timer(&rtc_uie_timer);
-
-       if (file->f_flags & FASYNC)
-               rtc_fasync(-1, file, 0);
-
-       rtc_irq_data = 0;
-
-       /* No need for locking -- nobody else can do anything until this rmw is
-        * committed, and no timer is running. */
-       rtc_status &= ~(RTC_IS_OPEN | RTC_UIE_TIMER_ON);
-       return 0;
-}
-
-static unsigned int rtc_poll(struct file *file, poll_table *wait)
-{
-       unsigned long l;
-
-       poll_wait(file, &rtc_wait, wait);
-
-       spin_lock_irq(&rtc_lock);
-       l = rtc_irq_data;
-       spin_unlock_irq(&rtc_lock);
-
-       if (l != 0)
-               return POLLIN | POLLRDNORM;
-       return 0;
-}
-
-/*
- *     The various file operations we support.
- */
-
-static struct file_operations rtc_fops = {
-       .owner          = THIS_MODULE,
-       .read           = rtc_read,
-       .poll           = rtc_poll,
-       .ioctl          = rtc_ioctl,
-       .open           = rtc_open,
-       .release        = rtc_release,
-       .fasync         = rtc_fasync,
-};
-
-static struct miscdevice rtc_dev=
-{
-       .minor  = RTC_MINOR,
-       .name   = "rtc",
-       .fops   = &rtc_fops,
-};
-
-static int __init rtc_init(void)
-{
-       int err = 0;
-
-       if (!request_region(UPD4990A_IO, 1, "rtc")) {
-               printk(KERN_ERR "upd4990a: could not acquire I/O port %#x\n",
-                       UPD4990A_IO);
-               return -EBUSY;
-       }
-
-       err = misc_register(&rtc_dev);
-       if (err) {
-               printk(KERN_ERR "upd4990a: can't misc_register() on minor=%d\n",
-                       RTC_MINOR);
-               release_region(UPD4990A_IO, 1);
-               return err;
-       }
-               
-#if 0
-       printk(KERN_INFO "\xB6\xDA\xDD\xC0\xDE \xC4\xDE\xB9\xB2 Driver\n");  /* Calender Clock Driver */
-#else
-       printk(KERN_INFO
-              "Real Time Clock driver for NEC PC-9800 v" RTC98_VERSION "\n");
-#endif
-       create_proc_read_entry("driver/rtc", 0, NULL, rtc_read_proc, NULL);
-
-       init_timer(&rtc_uie_timer);
-       rtc_uie_timer.function = rtc_uie_intr;
-
-       return 0;
-}
-
-module_init (rtc_init);
-
-static void __exit rtc_exit(void)
-{
-       del_timer(&rtc_uie_timer);
-       release_region(UPD4990A_IO, 1);
-       remove_proc_entry("driver/rtc", NULL);
-       misc_deregister(&rtc_dev);
-}
-
-module_exit (rtc_exit);
-
-/*
- *     Info exported via "/proc/driver/rtc".
- */
-
-static inline int rtc_get_status(char *buf)
-{
-       char *p;
-       unsigned int year;
-       struct upd4990a_raw_data data;
-
-       p = buf;
-
-       upd4990a_get_time(&data, 0);
-
-       /*
-        * There is no way to tell if the luser has the RTC set for local
-        * time or for Universal Standard Time (GMT). Probably local though.
-        */
-       if ((year = BCD2BIN(data.year) + 1900) < 1995)
-               year += 100;
-       p += sprintf(p,
-                    "rtc_time\t: %02d:%02d:%02d\n"
-                    "rtc_date\t: %04d-%02d-%02d\n",
-                    BCD2BIN(data.hour), BCD2BIN(data.min),
-                    BCD2BIN(data.sec),
-                    year, data.mon, BCD2BIN(data.mday));
-
-       return  p - buf;
-}
-
-static int rtc_read_proc(char *page, char **start, off_t off,
-                        int count, int *eof, void *data)
-{
-       int len = rtc_get_status(page);
-
-       if (len <= off + count)
-               *eof = 1;
-       *start = page + off;
-       len -= off;
-       if (len > count)
-               len = count;
-       if (len < 0)
-               len = 0;
-       return len;
-}
diff --git a/drivers/char/watchdog/ixp2000_wdt.c b/drivers/char/watchdog/ixp2000_wdt.c
deleted file mode 100644 (file)
index ebcaf79..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * drivers/watchdog/ixp2000_wdt.c
- *
- * Watchdog driver for Intel IXP2000 network processors
- *
- * Adapted from the IXP4xx watchdog driver by Lennert Buytenhek.
- * The original version carries these notices:
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright 2004 (c) MontaVista, Software, Inc.
- * Based on sa1100 driver, Copyright (C) 2000 Oleg Drokin <green@crimea.edu>
- *
- * This file is licensed under  the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/watchdog.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-
-#ifdef CONFIG_WATCHDOG_NOWAYOUT
-static int nowayout = 1;
-#else
-static int nowayout = 0;
-#endif
-static unsigned int heartbeat = 60;    /* (secs) Default is 1 minute */
-static unsigned long wdt_status;
-
-#define        WDT_IN_USE              0
-#define        WDT_OK_TO_CLOSE         1
-
-static unsigned long wdt_tick_rate;
-
-static void
-wdt_enable(void)
-{
-       ixp2000_reg_write(IXP2000_RESET0, *(IXP2000_RESET0) | WDT_RESET_ENABLE);
-       ixp2000_reg_write(IXP2000_TWDE, WDT_ENABLE);
-       ixp2000_reg_write(IXP2000_T4_CLD, heartbeat * wdt_tick_rate);
-       ixp2000_reg_write(IXP2000_T4_CTL, TIMER_DIVIDER_256 | TIMER_ENABLE);
-}
-
-static void
-wdt_disable(void)
-{
-       ixp2000_reg_write(IXP2000_T4_CTL, 0);
-}
-
-static void
-wdt_keepalive(void)
-{
-       ixp2000_reg_write(IXP2000_T4_CLD, heartbeat * wdt_tick_rate);
-}
-
-static int
-ixp2000_wdt_open(struct inode *inode, struct file *file)
-{
-       if (test_and_set_bit(WDT_IN_USE, &wdt_status))
-               return -EBUSY;
-
-       clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-       wdt_enable();
-
-       return nonseekable_open(inode, file);
-}
-
-static ssize_t
-ixp2000_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
-{
-       if (len) {
-               if (!nowayout) {
-                       size_t i;
-
-                       clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-                       for (i = 0; i != len; i++) {
-                               char c;
-
-                               if (get_user(c, data + i))
-                                       return -EFAULT;
-                               if (c == 'V')
-                                       set_bit(WDT_OK_TO_CLOSE, &wdt_status);
-                       }
-               }
-               wdt_keepalive();
-       }
-
-       return len;
-}
-
-
-static struct watchdog_info ident = {
-       .options        = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT |
-                               WDIOF_KEEPALIVEPING,
-       .identity       = "IXP2000 Watchdog",
-};
-
-static int
-ixp2000_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-                       unsigned long arg)
-{
-       int ret = -ENOIOCTLCMD;
-       int time;
-
-       switch (cmd) {
-       case WDIOC_GETSUPPORT:
-               ret = copy_to_user((struct watchdog_info *)arg, &ident,
-                                  sizeof(ident)) ? -EFAULT : 0;
-               break;
-
-       case WDIOC_GETSTATUS:
-               ret = put_user(0, (int *)arg);
-               break;
-
-       case WDIOC_GETBOOTSTATUS:
-               ret = put_user(0, (int *)arg);
-               break;
-
-       case WDIOC_SETTIMEOUT:
-               ret = get_user(time, (int *)arg);
-               if (ret)
-                       break;
-
-               if (time <= 0 || time > 60) {
-                       ret = -EINVAL;
-                       break;
-               }
-
-               heartbeat = time;
-               wdt_keepalive();
-               /* Fall through */
-
-       case WDIOC_GETTIMEOUT:
-               ret = put_user(heartbeat, (int *)arg);
-               break;
-
-       case WDIOC_KEEPALIVE:
-               wdt_enable();
-               ret = 0;
-               break;
-       }
-
-       return ret;
-}
-
-static int
-ixp2000_wdt_release(struct inode *inode, struct file *file)
-{
-       if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) {
-               wdt_disable();
-       } else {
-               printk(KERN_CRIT "WATCHDOG: Device closed unexpectdly - "
-                                       "timer will not stop\n");
-       }
-
-       clear_bit(WDT_IN_USE, &wdt_status);
-       clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-       return 0;
-}
-
-
-static struct file_operations ixp2000_wdt_fops =
-{
-       .owner          = THIS_MODULE,
-       .llseek         = no_llseek,
-       .write          = ixp2000_wdt_write,
-       .ioctl          = ixp2000_wdt_ioctl,
-       .open           = ixp2000_wdt_open,
-       .release        = ixp2000_wdt_release,
-};
-
-static struct miscdevice ixp2000_wdt_miscdev =
-{
-       .minor          = WATCHDOG_MINOR,
-       .name           = "IXP2000 Watchdog",
-       .fops           = &ixp2000_wdt_fops,
-};
-
-static int __init ixp2000_wdt_init(void)
-{
-       wdt_tick_rate = (*IXP2000_T1_CLD * HZ)/ 256;;
-
-       return misc_register(&ixp2000_wdt_miscdev);
-}
-
-static void __exit ixp2000_wdt_exit(void)
-{
-       misc_deregister(&ixp2000_wdt_miscdev);
-}
-
-module_init(ixp2000_wdt_init);
-module_exit(ixp2000_wdt_exit);
-
-MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net">);
-MODULE_DESCRIPTION("IXP2000 Network Processor Watchdog");
-
-module_param(heartbeat, int, 0);
-MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 60s)");
-
-module_param(nowayout, int, 0);
-MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
-
diff --git a/drivers/char/watchdog/ixp4xx_wdt.c b/drivers/char/watchdog/ixp4xx_wdt.c
deleted file mode 100644 (file)
index b8e3d91..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * drivers/watchdog/ixp4xx_wdt.c
- *
- * Watchdog driver for Intel IXP4xx network processors
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright 2004 (c) MontaVista, Software, Inc.
- * Based on sa1100 driver, Copyright (C) 2000 Oleg Drokin <green@crimea.edu>
- *
- * This file is licensed under  the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/watchdog.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-
-#ifdef CONFIG_WATCHDOG_NOWAYOUT
-static int nowayout = 1;
-#else
-static int nowayout = 0;
-#endif
-static int heartbeat = 60;     /* (secs) Default is 1 minute */
-static unsigned long wdt_status;
-static unsigned long boot_status;
-
-#define WDT_TICK_RATE (IXP4XX_PERIPHERAL_BUS_CLOCK * 1000000UL)
-
-#define        WDT_IN_USE              0
-#define        WDT_OK_TO_CLOSE         1
-
-static void
-wdt_enable(void)
-{
-       *IXP4XX_OSWK = IXP4XX_WDT_KEY;
-       *IXP4XX_OSWE = 0;
-       *IXP4XX_OSWT = WDT_TICK_RATE * heartbeat;
-       *IXP4XX_OSWE = IXP4XX_WDT_COUNT_ENABLE | IXP4XX_WDT_RESET_ENABLE;
-       *IXP4XX_OSWK = 0;
-}
-
-static void
-wdt_disable(void)
-{
-       *IXP4XX_OSWK = IXP4XX_WDT_KEY;
-       *IXP4XX_OSWE = 0;
-       *IXP4XX_OSWK = 0;
-}
-
-static int
-ixp4xx_wdt_open(struct inode *inode, struct file *file)
-{
-       if (test_and_set_bit(WDT_IN_USE, &wdt_status))
-               return -EBUSY;
-
-       clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-       wdt_enable();
-
-       return nonseekable_open(inode, file);
-}
-
-static ssize_t
-ixp4xx_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
-{
-       if (len) {
-               if (!nowayout) {
-                       size_t i;
-
-                       clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-                       for (i = 0; i != len; i++) {
-                               char c;
-
-                               if (get_user(c, data + i))
-                                       return -EFAULT;
-                               if (c == 'V')
-                                       set_bit(WDT_OK_TO_CLOSE, &wdt_status);
-                       }
-               }
-               wdt_enable();
-       }
-
-       return len;
-}
-
-static struct watchdog_info ident = {
-       .options        = WDIOF_CARDRESET | WDIOF_MAGICCLOSE |
-                         WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
-       .identity       = "IXP4xx Watchdog",
-};
-
-
-static int
-ixp4xx_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-                       unsigned long arg)
-{
-       int ret = -ENOIOCTLCMD;
-       int time;
-
-       switch (cmd) {
-       case WDIOC_GETSUPPORT:
-               ret = copy_to_user((struct watchdog_info *)arg, &ident,
-                                  sizeof(ident)) ? -EFAULT : 0;
-               break;
-
-       case WDIOC_GETSTATUS:
-               ret = put_user(0, (int *)arg);
-               break;
-
-       case WDIOC_GETBOOTSTATUS:
-               ret = put_user(boot_status, (int *)arg);
-               break;
-
-       case WDIOC_SETTIMEOUT:
-               ret = get_user(time, (int *)arg);
-               if (ret)
-                       break;
-
-               if (time <= 0 || time > 60) {
-                       ret = -EINVAL;
-                       break;
-               }
-
-               heartbeat = time;
-               wdt_enable();
-               /* Fall through */
-
-       case WDIOC_GETTIMEOUT:
-               ret = put_user(heartbeat, (int *)arg);
-               break;
-
-       case WDIOC_KEEPALIVE:
-               wdt_enable();
-               ret = 0;
-               break;
-       }
-       return ret;
-}
-
-static int
-ixp4xx_wdt_release(struct inode *inode, struct file *file)
-{
-       if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) {
-               wdt_disable();
-       } else {
-               printk(KERN_CRIT "WATCHDOG: Device closed unexpectdly - "
-                                       "timer will not stop\n");
-       }
-
-       clear_bit(WDT_IN_USE, &wdt_status);
-       clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-       return 0;
-}
-
-
-static struct file_operations ixp4xx_wdt_fops =
-{
-       .owner          = THIS_MODULE,
-       .write          = ixp4xx_wdt_write,
-       .ioctl          = ixp4xx_wdt_ioctl,
-       .open           = ixp4xx_wdt_open,
-       .release        = ixp4xx_wdt_release,
-};
-
-static struct miscdevice ixp4xx_wdt_miscdev =
-{
-       .minor          = WATCHDOG_MINOR,
-       .name           = "IXP4xx Watchdog",
-       .fops           = &ixp4xx_wdt_fops,
-};
-
-static int __init ixp4xx_wdt_init(void)
-{
-       int ret;
-       unsigned long processor_id;
-
-       asm("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(processor_id) :);
-       if (!(processor_id & 0xf)) {
-               printk("IXP4XXX Watchdog: Rev. A0 CPU detected - "
-                       "watchdog disabled\n");
-
-               return -ENODEV;
-       }
-
-       ret = misc_register(&ixp4xx_wdt_miscdev);
-       if (ret == 0)
-               printk("IXP4xx Watchdog Timer: heartbeat %d sec\n", heartbeat);
-
-       boot_status = (*IXP4XX_OSST & IXP4XX_OSST_TIMER_WARM_RESET) ?
-                       WDIOF_CARDRESET : 0;
-
-       return ret;
-}
-
-static void __exit ixp4xx_wdt_exit(void)
-{
-       misc_deregister(&ixp4xx_wdt_miscdev);
-}
-
-
-module_init(ixp4xx_wdt_init);
-module_exit(ixp4xx_wdt_exit);
-
-MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net">);
-MODULE_DESCRIPTION("IXP4xx Network Processor Watchdog");
-
-module_param(heartbeat, int, 0);
-MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 60s)");
-
-module_param(nowayout, int, 0);
-MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
-
diff --git a/drivers/dump/Makefile b/drivers/dump/Makefile
new file mode 100644 (file)
index 0000000..deb671f
--- /dev/null
@@ -0,0 +1,16 @@
+#
+# Makefile for the dump device drivers.
+#
+
+dump-y                                 := dump_setup.o dump_fmt.o dump_filters.o dump_scheme.o dump_execute.o
+dump-$(CONFIG_X86)                     += dump_i386.o
+dump-$(CONFIG_ARM)                     += dump_arm.o
+dump-$(CONFIG_PPC64)                    += dump_ppc64.o
+dump-$(CONFIG_CRASH_DUMP_MEMDEV)       += dump_memdev.o dump_overlay.o
+dump-objs                              += $(dump-y)
+
+obj-$(CONFIG_CRASH_DUMP)               += dump.o
+obj-$(CONFIG_CRASH_DUMP_BLOCKDEV)      += dump_blockdev.o
+obj-$(CONFIG_CRASH_DUMP_NETDEV)        += dump_netdev.o
+obj-$(CONFIG_CRASH_DUMP_COMPRESS_RLE)  += dump_rle.o
+obj-$(CONFIG_CRASH_DUMP_COMPRESS_GZIP) += dump_gzip.o
diff --git a/drivers/dump/dump_arm.c b/drivers/dump/dump_arm.c
new file mode 100644 (file)
index 0000000..b1849fa
--- /dev/null
@@ -0,0 +1,250 @@
+/*
+ * Architecture specific (ARM/XScale) functions for Linux crash dumps.
+ *
+ * Created by: Fleming Feng (fleming.feng@intel.com)
+ *
+ * Copyright(C) 2003 Intel Corp. All rights reserved.
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/*
+ * The hooks for dumping the kernel virtual memory to disk are in this
+ * file.  Any time a modification is made to the virtual memory mechanism,
+ * these routines must be changed to use the new mechanisms.
+ */
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/smp.h>
+#include <linux/fs.h>
+#include <linux/vmalloc.h>
+#include <linux/dump.h>
+#include <linux/mm.h>
+#include <asm/processor.h>
+#include <asm/hardirq.h>
+#include <asm/kdebug.h>
+
+static __s32   saved_irq_count;        /* saved preempt_count() flags */
+
+static int alloc_dha_stack(void)
+{
+       int i;
+       void *ptr;
+       
+       if (dump_header_asm.dha_stack[0])
+               return 0;
+
+               ptr = vmalloc(THREAD_SIZE * num_online_cpus());
+       if (!ptr) {
+               printk("vmalloc for dha_stacks failed\n");
+               return -ENOMEM;
+       }
+
+       for( i = 0; i < num_online_cpus(); i++){
+               dump_header_asm.dha_stack[i] = (u32)((unsigned long)ptr +
+                                                    (i * THREAD_SIZE));
+       }
+
+       return 0;
+}
+
+static int free_dha_stack(void) 
+{
+       if (dump_header_asm.dha_stack[0]){
+               vfree((void*)dump_header_asm.dha_stack[0]);
+               dump_header_asm.dha_stack[0] = 0;
+       }
+       return 0;
+}
+
+void __dump_save_regs(struct pt_regs* dest_regs, const struct pt_regs* regs)
+{
+
+       /* Here, because the arm version uses _dump_regs_t,
+        * instead of pt_regs in dump_header_asm, while the
+        * the function is defined inside architecture independent
+        * header file include/linux/dump.h, the size of block of
+        * memory copied is not equal to pt_regs.
+        */
+
+       memcpy(dest_regs, regs, sizeof(_dump_regs_t));
+
+}
+
+#ifdef CONFIG_SMP
+/* FIXME: This is reserved for possible future usage for SMP system 
+ * based on ARM/XScale. Currently, there is no information for an 
+ * SMP system based on ARM/XScale, they are not used!
+ */
+/* save registers on other processor */
+void
+__dump_save_other_cpus(void)
+{
+
+       /* Dummy now! */
+
+       return;
+       
+}
+#else  /* !CONFIG_SMP */
+#define save_other_cpu_state() do { } while (0)
+#endif /* !CONFIG_SMP */
+
+/* 
+ * Kludge - dump from interrupt context is unreliable (Fixme)
+ *
+ * We do this so that softirqs initiated for dump i/o 
+ * get processed and we don't hang while waiting for i/o
+ * to complete or in any irq synchronization attempt.
+ *
+ * This is not quite legal of course, as it has the side 
+ * effect of making all interrupts & softirqs triggered 
+ * while dump is in progress complete before currently 
+ * pending softirqs and the currently executing interrupt 
+ * code. 
+ */
+static inline void
+irq_bh_save(void)
+{
+       saved_irq_count = irq_count();
+       preempt_count() &= ~(HARDIRQ_MASK|SOFTIRQ_MASK);
+}
+
+static inline void
+irq_bh_restore(void)
+{
+       preempt_count() |= saved_irq_count;
+}
+
+/*
+ * Name: __dump_irq_enable
+ * Func: Reset system so interrupts are enabled.
+ *      This is used for dump methods that requires interrupts
+ *      Eventually, all methods will have interrupts disabled
+ *      and this code can be removed.
+ *      
+ *      Re-enable interrupts
+ */
+int
+__dump_irq_enable(void)
+{
+       irq_bh_save();
+       local_irq_enable();
+       return 0;
+}
+
+/* Name: __dump_irq_restore
+ * Func: Resume the system state in an architecture-specific way.
+ */
+void 
+__dump_irq_restore(void)
+{
+       local_irq_disable();
+       irq_bh_restore();
+}
+       
+
+/*
+ * Name: __dump_configure_header()
+ * Func: Meant to fill in arch specific header fields except per-cpu state
+ *      already captured in dump_lcrash_configure_header.
+ */
+int
+__dump_configure_header(const struct pt_regs *regs)
+{
+       return (0);
+}
+
+/*
+ * Name: dump_die_event
+ * Func: Called from notify_die
+ */
+static int dump_die_event(struct notifier_block* this,
+                         unsigned long event,
+                         void* arg)
+{
+       const struct die_args* args = (const struct die_args*)arg;
+
+       switch(event){
+               case DIE_PANIC: 
+               case DIE_OOPS:
+               case DIE_WATCHDOG:
+                       dump_execute(args->str, args->regs);
+                       break;          
+       }
+       return NOTIFY_DONE;
+
+}
+
+static struct notifier_block dump_die_block = {
+       .notifier_call = dump_die_event,
+};
+
+/* Name: __dump_init()
+ * Func: Initialize the dumping routine process.
+ */
+void
+__dump_init(uint64_t local_memory_start)
+{
+       /* hook into PANIC and OOPS */
+       register_die_notifier(&dump_die_block);
+}
+
+/*
+ * Name: __dump_open()
+ * Func: Open the dump device (architecture specific).  This is in
+ *       case it's necessary in the future.
+ */
+void
+__dump_open(void)
+{
+
+       alloc_dha_stack();
+
+       return;
+}
+
+/*
+ * Name: __dump_cleanup()
+ * Func: Free any architecture specific data structures. This is called
+ *       when the dump module is being removed.
+ */
+void
+__dump_cleanup(void)
+{
+       free_dha_stack();
+       unregister_die_notifier(&dump_die_block);
+
+       /* return */
+       return;
+}
+
+/* 
+ * Name: __dump_page_valid()
+ * Func: Check if page is valid to dump.
+ */
+int
+__dump_page_valid(unsigned long index)
+{
+       if(!pfn_valid(index))
+               return 0;
+       else
+               return 1;
+}
+
+/* 
+ * Name: manual_handle_crashdump 
+ * Func: Interface for the lkcd dump command. Calls dump_execute()
+ */
+int
+manual_handle_crashdump(void) {
+       
+       _dump_regs_t regs;      
+
+       get_current_general_regs(&regs);
+       get_current_cp14_regs(&regs);
+       get_current_cp15_regs(&regs);
+       dump_execute("manual", &regs);
+       return 0;
+}
diff --git a/drivers/dump/dump_blockdev.c b/drivers/dump/dump_blockdev.c
new file mode 100644 (file)
index 0000000..cee31a4
--- /dev/null
@@ -0,0 +1,468 @@
+/*
+ * Implements the dump driver interface for saving a dump to 
+ * a block device through the kernel's generic low level block i/o
+ * routines.
+ *
+ * Started: June 2002 - Mohamed Abbas <mohamed.abbas@intel.com>
+ *     Moved original lkcd kiobuf dump i/o code from dump_base.c
+ *     to use generic dump device interfaces
+ *
+ * Sept 2002 - Bharata B. Rao <bharata@in.ibm.com>
+ *     Convert dump i/o to directly use bio instead of kiobuf for 2.5
+ *
+ * Oct 2002  - Suparna Bhattacharya <suparna@in.ibm.com>
+ *     Rework to new dumpdev.h structures, implement open/close/
+ *     silence, misc fixes (blocknr removal, bio_add_page usage)  
+ *
+ * Copyright (C) 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/blkdev.h>
+#include <linux/bio.h>
+#include <asm/hardirq.h>
+#include <linux/dump.h>
+#include "dump_methods.h"
+
+extern void *dump_page_buf;
+
+/* The end_io callback for dump i/o completion */
+static int
+dump_bio_end_io(struct bio *bio, unsigned int bytes_done, int error)
+{
+       struct dump_blockdev *dump_bdev;
+
+       if (bio->bi_size) {
+               /* some bytes still left to transfer */
+               return 1; /* not complete */
+       }
+
+       dump_bdev = (struct dump_blockdev *)bio->bi_private;
+       if (error) {
+               printk("IO error while writing the dump, aborting\n");
+       }
+
+       dump_bdev->err = error;
+
+       /* no wakeup needed, since caller polls for completion */
+       return 0;
+}
+
+/* Check if the dump bio is already mapped to the specified buffer */
+static int
+dump_block_map_valid(struct dump_blockdev *dev, struct page *page, 
+       int len) 
+{
+       struct bio *bio = dev->bio;
+       unsigned long bsize = 0;
+
+       if (!bio->bi_vcnt)
+               return 0; /* first time, not mapped */
+
+
+       if ((bio_page(bio) != page) || (len > bio->bi_vcnt << PAGE_SHIFT))
+               return 0; /* buffer not mapped */
+
+       bsize = bdev_hardsect_size(bio->bi_bdev);
+       if ((len & (PAGE_SIZE - 1)) || (len & bsize))
+               return 0; /* alignment checks needed */
+
+       /* quick check to decide if we need to redo bio_add_page */
+       if (bdev_get_queue(bio->bi_bdev)->merge_bvec_fn)
+               return 0; /* device may have other restrictions */
+
+       return 1; /* already mapped */
+}
+
+/* 
+ * Set up the dump bio for i/o from the specified buffer 
+ * Return value indicates whether the full buffer could be mapped or not
+ */
+static int
+dump_block_map(struct dump_blockdev *dev, void *buf, int len)
+{
+       struct page *page = virt_to_page(buf);
+       struct bio *bio = dev->bio;
+       unsigned long bsize = 0;
+
+       bio->bi_bdev = dev->bdev;
+       bio->bi_sector = (dev->start_offset + dev->ddev.curr_offset) >> 9;
+       bio->bi_idx = 0; /* reset index to the beginning */
+
+       if (dump_block_map_valid(dev, page, len)) {
+               /* already mapped and usable rightaway */
+               bio->bi_size = len; /* reset size to the whole bio */
+       } else {
+               /* need to map the bio */
+               bio->bi_size = 0;
+               bio->bi_vcnt = 0;
+               bsize = bdev_hardsect_size(bio->bi_bdev);
+
+               /* first a few sanity checks */
+               if (len < bsize) {
+                       printk("map: len less than hardsect size \n");
+                       return -EINVAL;
+               }
+
+               if ((unsigned long)buf & bsize) {
+                       printk("map: not aligned \n");
+                       return -EINVAL;
+               }
+
+               /* assume contig. page aligned low mem buffer( no vmalloc) */
+               if ((page_address(page) != buf) || (len & (PAGE_SIZE - 1))) {
+                       printk("map: invalid buffer alignment!\n");
+                       return -EINVAL; 
+               }
+               /* finally we can go ahead and map it */
+               while (bio->bi_size < len)
+                       if (bio_add_page(bio, page++, PAGE_SIZE, 0) == 0) {
+                               break;
+                       }
+
+               bio->bi_end_io = dump_bio_end_io;
+               bio->bi_private = dev;
+       }
+
+       if (bio->bi_size != len) {
+               printk("map: bio size = %d not enough for len = %d!\n",
+                       bio->bi_size, len);
+               return -E2BIG;
+       }
+       return 0;
+}
+
+static void
+dump_free_bio(struct bio *bio)
+{
+       if (bio)
+               kfree(bio->bi_io_vec);
+       kfree(bio);
+}
+
+/*
+ * Prepares the dump device so we can take a dump later. 
+ * The caller is expected to have filled up the dev_id field in the 
+ * block dump dev structure.
+ *
+ * At dump time when dump_block_write() is invoked it will be too 
+ * late to recover, so as far as possible make sure obvious errors 
+ * get caught right here and reported back to the caller.
+ */
+static int
+dump_block_open(struct dump_dev *dev, unsigned long arg)
+{
+       struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+       struct block_device *bdev;
+       int retval = 0;
+       struct bio_vec *bvec;
+
+       /* make sure this is a valid block device */
+       if (!arg) {
+               retval = -EINVAL;
+               goto err;
+       }
+
+       /* Convert it to the new dev_t format */
+       arg = MKDEV((arg >> OLDMINORBITS), (arg & OLDMINORMASK));
+       
+       /* get a corresponding block_dev struct for this */
+       bdev = bdget((dev_t)arg);
+       if (!bdev) {
+               retval = -ENODEV;
+               goto err;
+       }
+
+       /* get the block device opened */
+       if ((retval = blkdev_get(bdev, O_RDWR | O_LARGEFILE, 0))) {
+               goto err1;
+       }
+
+       if ((dump_bdev->bio = kmalloc(sizeof(struct bio), GFP_KERNEL)) 
+               == NULL) {
+               printk("Cannot allocate bio\n");
+               retval = -ENOMEM;
+               goto err2;
+       }
+
+       bio_init(dump_bdev->bio);
+
+       if ((bvec = kmalloc(sizeof(struct bio_vec) * 
+               (DUMP_BUFFER_SIZE >> PAGE_SHIFT), GFP_KERNEL)) == NULL) {
+               retval = -ENOMEM;
+               goto err3;
+       }
+
+       /* assign the new dump dev structure */
+       dump_bdev->dev_id = (dev_t)arg;
+       dump_bdev->bdev = bdev;
+
+       /* make a note of the limit */
+       dump_bdev->limit = bdev->bd_inode->i_size;
+       
+       /* now make sure we can map the dump buffer */
+       dump_bdev->bio->bi_io_vec = bvec;
+       dump_bdev->bio->bi_max_vecs = DUMP_BUFFER_SIZE >> PAGE_SHIFT;
+
+       retval = dump_block_map(dump_bdev, dump_config.dumper->dump_buf, 
+               DUMP_BUFFER_SIZE);
+               
+       if (retval) {
+               printk("open: dump_block_map failed, ret %d\n", retval);
+               goto err3;
+       }
+
+       printk("Block device (%d,%d) successfully configured for dumping\n",
+              MAJOR(dump_bdev->dev_id),
+              MINOR(dump_bdev->dev_id));
+
+
+       /* after opening the block device, return */
+       return retval;
+
+err3:  dump_free_bio(dump_bdev->bio);
+       dump_bdev->bio = NULL;
+err2:  if (bdev) blkdev_put(bdev);
+               goto err;
+err1:  if (bdev) bdput(bdev);
+       dump_bdev->bdev = NULL;
+err:   return retval;
+}
+
+/*
+ * Close the dump device and release associated resources
+ * Invoked when unconfiguring the dump device.
+ */
+static int
+dump_block_release(struct dump_dev *dev)
+{
+       struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+
+       /* release earlier bdev if present */
+       if (dump_bdev->bdev) {
+               blkdev_put(dump_bdev->bdev);
+               dump_bdev->bdev = NULL;
+       }
+
+       dump_free_bio(dump_bdev->bio);
+       dump_bdev->bio = NULL;
+
+       return 0;
+}
+
+
+/*
+ * Prepare the dump device for use (silence any ongoing activity
+ * and quiesce state) when the system crashes.
+ */
+static int
+dump_block_silence(struct dump_dev *dev)
+{
+       struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+       struct request_queue *q = bdev_get_queue(dump_bdev->bdev);
+       int ret;
+
+       /* If we can't get request queue lock, refuse to take the dump */
+       if (!spin_trylock(q->queue_lock))
+               return -EBUSY;
+
+       ret = elv_queue_empty(q);
+       spin_unlock(q->queue_lock);
+
+       /* For now we assume we have the device to ourselves */
+       /* Just a quick sanity check */
+       if (!ret) {
+               /* Warn the user and move on */
+               printk(KERN_ALERT "Warning: Non-empty request queue\n");
+               printk(KERN_ALERT "I/O requests in flight at dump time\n");
+       }
+
+       /* 
+        * Move to a softer level of silencing where no spin_lock_irqs 
+        * are held on other cpus
+        */
+       dump_silence_level = DUMP_SOFT_SPIN_CPUS;       
+
+       ret = __dump_irq_enable();
+       if (ret) {
+               return ret;
+       }
+
+       printk("Dumping to block device (%d,%d) on CPU %d ...\n",
+              MAJOR(dump_bdev->dev_id), MINOR(dump_bdev->dev_id),
+              smp_processor_id());
+       
+       return 0;
+}
+
+/*
+ * Invoked when dumping is done. This is the time to put things back 
+ * (i.e. undo the effects of dump_block_silence) so the device is 
+ * available for normal use.
+ */
+static int
+dump_block_resume(struct dump_dev *dev)
+{
+       __dump_irq_restore();
+       return 0;
+}
+
+
+/*
+ * Seek to the specified offset in the dump device.
+ * Makes sure this is a valid offset, otherwise returns an error.
+ */
+static int
+dump_block_seek(struct dump_dev *dev, loff_t off)
+{
+       struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+       loff_t offset = off + dump_bdev->start_offset;
+       
+       if (offset & ( PAGE_SIZE - 1)) {
+               printk("seek: non-page aligned\n");
+               return -EINVAL;
+       }
+
+       if (offset & (bdev_hardsect_size(dump_bdev->bdev) - 1)) {
+               printk("seek: not sector aligned \n");
+               return -EINVAL;
+       }
+
+       if (offset > dump_bdev->limit) {
+               printk("seek: not enough space left on device!\n");
+               return -ENOSPC; 
+       }
+       dev->curr_offset = off;
+       return 0;
+}
+
+/*
+ * Write out a buffer after checking the device limitations, 
+ * sector sizes, etc. Assumes the buffer is in directly mapped 
+ * kernel address space (not vmalloc'ed).
+ *
+ * Returns: number of bytes written or -ERRNO. 
+ */
+static int
+dump_block_write(struct dump_dev *dev, void *buf, 
+       unsigned long len)
+{
+       struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+       loff_t offset = dev->curr_offset + dump_bdev->start_offset;
+       int retval = -ENOSPC;
+
+       if (offset >= dump_bdev->limit) {
+               printk("write: not enough space left on device!\n");
+               goto out;
+       }
+
+       /* don't write more blocks than our max limit */
+       if (offset + len > dump_bdev->limit) 
+               len = dump_bdev->limit - offset;
+
+
+       retval = dump_block_map(dump_bdev, buf, len);
+       if (retval){
+               printk("write: dump_block_map failed! err %d\n", retval);
+               goto out;
+       }
+
+       /*
+        * Write out the data to disk.
+        * Assumes the entire buffer mapped to a single bio, which we can
+        * submit and wait for io completion. In the future, may consider
+        * increasing the dump buffer size and submitting multiple bio s 
+        * for better throughput.
+        */
+       dump_bdev->err = -EAGAIN;
+       submit_bio(WRITE, dump_bdev->bio);
+
+       dump_bdev->ddev.curr_offset += len;
+       retval = len;
+ out:
+       return retval;
+}
+
+/*
+ * Name: dump_block_ready()
+ * Func: check if the last dump i/o is over and ready for next request
+ */
+static int
+dump_block_ready(struct dump_dev *dev, void *buf)
+{
+       struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+       request_queue_t *q = bdev_get_queue(dump_bdev->bio->bi_bdev);
+
+       /* check for io completion */
+       if (dump_bdev->err == -EAGAIN) {
+               q->unplug_fn(q);
+               return -EAGAIN;
+       }
+
+       if (dump_bdev->err) {
+               printk("dump i/o err\n");
+               return dump_bdev->err;
+       }
+
+       return 0;
+}
+
+
+struct dump_dev_ops dump_blockdev_ops = {
+       .open           = dump_block_open,
+       .release        = dump_block_release,
+       .silence        = dump_block_silence,
+       .resume         = dump_block_resume,
+       .seek           = dump_block_seek,
+       .write          = dump_block_write,
+       /* .read not implemented */
+       .ready          = dump_block_ready
+};
+
+static struct dump_blockdev default_dump_blockdev = {
+       .ddev = {.type_name = "blockdev", .ops = &dump_blockdev_ops, 
+                       .curr_offset = 0},
+       /* 
+        * leave enough room for the longest swap header possibly written 
+        * written by mkswap (likely the largest page size supported by
+        * the arch
+        */
+       .start_offset   = DUMP_HEADER_OFFSET,
+       .err            = 0
+       /* assume the rest of the fields are zeroed by default */
+};     
+       
+struct dump_blockdev *dump_blockdev = &default_dump_blockdev;
+
+static int __init
+dump_blockdev_init(void)
+{
+       if (dump_register_device(&dump_blockdev->ddev) < 0) {
+               printk("block device driver registration failed\n");
+               return -1;
+       }
+               
+       printk("block device driver for LKCD registered\n");
+       return 0;
+}
+
+static void __exit
+dump_blockdev_cleanup(void)
+{
+       dump_unregister_device(&dump_blockdev->ddev);
+       printk("block device driver for LKCD unregistered\n");
+}
+
+MODULE_AUTHOR("LKCD Development Team <lkcd-devel@lists.sourceforge.net>");
+MODULE_DESCRIPTION("Block Dump Driver for Linux Kernel Crash Dump (LKCD)");
+MODULE_LICENSE("GPL");
+
+module_init(dump_blockdev_init);
+module_exit(dump_blockdev_cleanup);
diff --git a/drivers/dump/dump_execute.c b/drivers/dump/dump_execute.c
new file mode 100644 (file)
index 0000000..d0dc251
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * The file has the common/generic dump execution code 
+ *
+ * Started: Oct 2002 -  Suparna Bhattacharya <suparna@in.ibm.com>
+ *     Split and rewrote high level dump execute code to make use 
+ *     of dump method interfaces.
+ *
+ * Derived from original code in dump_base.c created by 
+ *     Matt Robinson <yakker@sourceforge.net>)
+ *     
+ * Copyright (C) 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * Assumes dumper and dump config settings are in place
+ * (invokes corresponding dumper specific routines as applicable)
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+#include <linux/kernel.h>
+#include <linux/notifier.h>
+#include <linux/dump.h>
+#include <linux/delay.h>
+#include <linux/reboot.h>
+#include "dump_methods.h"
+
+struct notifier_block *dump_notifier_list; /* dump started/ended callback */
+
+extern int panic_timeout;
+
+/* Dump progress indicator */
+void 
+dump_speedo(int i)
+{
+       static const char twiddle[4] =  { '|', '\\', '-', '/' };
+       printk("%c\b", twiddle[i&3]);
+}
+
+/* Make the device ready and write out the header */
+int dump_begin(void)
+{
+       int err = 0;
+
+       /* dump_dev = dump_config.dumper->dev; */
+       dumper_reset();
+       if ((err = dump_dev_silence())) {
+               /* quiesce failed, can't risk continuing */
+               /* Todo/Future: switch to alternate dump scheme if possible */
+               printk("dump silence dev failed ! error %d\n", err);
+               return err;
+       }
+
+       pr_debug("Writing dump header\n");
+       if ((err = dump_update_header())) {
+               printk("dump update header failed ! error %d\n", err);
+               dump_dev_resume();
+               return err;
+       }
+
+       dump_config.dumper->curr_offset = DUMP_BUFFER_SIZE;
+
+       return 0;
+}
+
+/* 
+ * Write the dump terminator, a final header update and let go of 
+ * exclusive use of the device for dump.
+ */
+int dump_complete(void)
+{
+       int ret = 0;
+
+       if (dump_config.level != DUMP_LEVEL_HEADER) {
+               if ((ret = dump_update_end_marker())) {
+                       printk("dump update end marker error %d\n", ret);
+               }
+               if ((ret = dump_update_header())) {
+                       printk("dump update header error %d\n", ret);
+               }
+       }
+       ret = dump_dev_resume();
+
+       if ((panic_timeout > 0) && (!(dump_config.flags & (DUMP_FLAGS_SOFTBOOT | DUMP_FLAGS_NONDISRUPT)))) {
+               printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
+#ifdef CONFIG_SMP
+               smp_send_stop();
+#endif
+               mdelay(panic_timeout * 1000);
+               machine_restart(NULL);
+       }
+
+       return ret;
+}
+
+/* Saves all dump data */
+int dump_execute_savedump(void)
+{
+       int ret = 0, err = 0;
+
+       if ((ret = dump_begin()))  {
+               return ret;
+       }
+
+       if (dump_config.level != DUMP_LEVEL_HEADER) { 
+               ret = dump_sequencer();
+       }
+       if ((err = dump_complete())) {
+               printk("Dump complete failed. Error %d\n", err);
+       }
+
+       return ret;
+}
+
+extern void dump_calc_bootmap_pages(void);
+
+/* Does all the real work:  Capture and save state */
+int dump_generic_execute(const char *panic_str, const struct pt_regs *regs)
+{
+       int ret = 0;
+
+       if ((ret = dump_configure_header(panic_str, regs))) {
+               printk("dump config header failed ! error %d\n", ret);
+               return ret;     
+       }
+
+       dump_calc_bootmap_pages();
+       /* tell interested parties that a dump is about to start */
+       notifier_call_chain(&dump_notifier_list, DUMP_BEGIN, 
+               &dump_config.dump_device);
+
+       if (dump_config.level != DUMP_LEVEL_NONE)
+               ret = dump_execute_savedump();
+
+       pr_debug("dumped %ld blocks of %d bytes each\n", 
+               dump_config.dumper->count, DUMP_BUFFER_SIZE);
+       
+       /* tell interested parties that a dump has completed */
+       notifier_call_chain(&dump_notifier_list, DUMP_END, 
+               &dump_config.dump_device);
+
+       return ret;
+}
diff --git a/drivers/dump/dump_filters.c b/drivers/dump/dump_filters.c
new file mode 100644 (file)
index 0000000..735cd0b
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Default filters to select data to dump for various passes.
+ *
+ * Started: Oct 2002 -  Suparna Bhattacharya <suparna@in.ibm.com>
+ *     Split and rewrote default dump selection logic to generic dump 
+ *     method interfaces 
+ * Derived from a portion of dump_base.c created by 
+ *     Matt Robinson <yakker@sourceforge.net>)
+ *
+ * Copyright (C) 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * Used during single-stage dumping and during stage 1 of the 2-stage scheme
+ * (Stage 2 of the 2-stage scheme uses the fully transparent filters
+ * i.e. passthru filters in dump_overlay.c)
+ *
+ * Future: Custom selective dump may involve a different set of filters.
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+#include <linux/kernel.h>
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/dump.h>
+#include "dump_methods.h"
+
+#define DUMP_PFN_SAFETY_MARGIN  1024  /* 4 MB */
+static unsigned long bootmap_pages;
+
+/* Copied from mm/bootmem.c - FIXME */
+/* return the number of _pages_ that will be allocated for the boot bitmap */
+void dump_calc_bootmap_pages (void)
+{
+       unsigned long mapsize;
+       unsigned long pages = num_physpages;
+
+       mapsize = (pages+7)/8;
+       mapsize = (mapsize + ~PAGE_MASK) & PAGE_MASK;
+       mapsize >>= PAGE_SHIFT;
+       bootmap_pages = mapsize + DUMP_PFN_SAFETY_MARGIN + 1;
+}
+
+
+/* temporary */
+extern unsigned long min_low_pfn;
+
+
+int dump_low_page(struct page *p)
+{
+       return ((page_to_pfn(p) >= min_low_pfn) &&
+               (page_to_pfn(p) < (min_low_pfn + bootmap_pages)));
+}
+
+static inline int kernel_page(struct page *p)
+{
+       /* FIXME: Need to exclude hugetlb pages. Clue: reserved but inuse */
+       return (PageReserved(p) && !PageInuse(p)) || (!PageLRU(p) && PageInuse(p));
+}
+
+static inline int user_page(struct page *p)
+{
+       return PageInuse(p) && (!PageReserved(p) && PageLRU(p));
+}
+
+static inline int unreferenced_page(struct page *p)
+{
+       return !PageInuse(p) && !PageReserved(p);
+}
+
+
+/* loc marks the beginning of a range of pages */
+int dump_filter_kernpages(int pass, unsigned long loc, unsigned long sz)
+{
+       struct page *page = (struct page *)loc;
+       /* if any of the pages is a kernel page, select this set */     
+       while (sz) {
+               if (dump_low_page(page) || kernel_page(page))
+                       return 1;
+               sz -= PAGE_SIZE;
+               page++;
+       }       
+       return 0;
+}
+
+
+/* loc marks the beginning of a range of pages */
+int dump_filter_userpages(int pass, unsigned long loc, unsigned long sz)
+{
+       struct page *page = (struct page *)loc;
+       int ret = 0;
+       /* select if the set has any user page, and no kernel pages  */ 
+       while (sz) {
+               if (user_page(page) && !dump_low_page(page)) {
+                       ret = 1;
+               } else if (kernel_page(page) || dump_low_page(page)) {
+                       return 0;
+               }
+               page++;
+               sz -= PAGE_SIZE;
+       }       
+       return ret;
+}
+
+
+
+/* loc marks the beginning of a range of pages */
+int dump_filter_unusedpages(int pass, unsigned long loc, unsigned long sz)
+{
+       struct page *page = (struct page *)loc;
+
+       /* select if the set does not have any used pages  */   
+       while (sz) {
+               if (!unreferenced_page(page) || dump_low_page(page)) {
+                       return 0;
+               }
+               page++;
+               sz -= PAGE_SIZE;
+       }       
+       return 1;
+}
+
+/* dummy: last (non-existent) pass */
+int dump_filter_none(int pass, unsigned long loc, unsigned long sz)
+{
+       return 0;
+}
+
+/* TBD: resolve level bitmask ? */
+struct dump_data_filter dump_filter_table[] = {
+       { .name = "kern", .selector = dump_filter_kernpages, 
+               .level_mask = DUMP_MASK_KERN},
+       { .name = "user", .selector = dump_filter_userpages, 
+               .level_mask = DUMP_MASK_USED},
+       { .name = "unused", .selector = dump_filter_unusedpages, 
+               .level_mask = DUMP_MASK_UNUSED},
+       { .name = "none", .selector = dump_filter_none, 
+               .level_mask = DUMP_MASK_REST},
+       { .name = "", .selector = NULL, .level_mask = 0}
+};
+
diff --git a/drivers/dump/dump_fmt.c b/drivers/dump/dump_fmt.c
new file mode 100644 (file)
index 0000000..afa0aed
--- /dev/null
@@ -0,0 +1,406 @@
+/*
+ * Implements the routines which handle the format specific
+ * aspects of dump for the default dump format.
+ *
+ * Used in single stage dumping and stage 1 of soft-boot based dumping 
+ * Saves data in LKCD (lcrash) format 
+ *
+ * Previously a part of dump_base.c
+ *
+ * Started: Oct 2002 -  Suparna Bhattacharya <suparna@in.ibm.com>
+ *     Split off and reshuffled LKCD dump format code around generic
+ *     dump method interfaces.
+ *
+ * Derived from original code created by 
+ *     Matt Robinson <yakker@sourceforge.net>)
+ *
+ * Contributions from SGI, IBM, HP, MCL, and others.
+ *
+ * Copyright (C) 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000 - 2002 TurboLinux, Inc.  All rights reserved.
+ * Copyright (C) 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/time.h>
+#include <linux/sched.h>
+#include <linux/ptrace.h>
+#include <linux/utsname.h>
+#include <asm/dump.h>
+#include <linux/dump.h>
+#include "dump_methods.h"
+
+/*
+ * SYSTEM DUMP LAYOUT
+ * 
+ * System dumps are currently the combination of a dump header and a set
+ * of data pages which contain the system memory.  The layout of the dump
+ * (for full dumps) is as follows:
+ *
+ *             +-----------------------------+
+ *             |     generic dump header     |
+ *             +-----------------------------+
+ *             |   architecture dump header  |
+ *             +-----------------------------+
+ *             |         page header         |
+ *             +-----------------------------+
+ *             |          page data          |
+ *             +-----------------------------+
+ *             |         page header         |
+ *             +-----------------------------+
+ *             |          page data          |
+ *             +-----------------------------+
+ *             |              |              |
+ *             |              |              |
+ *             |              |              |
+ *             |              |              |
+ *             |              V              |
+ *             +-----------------------------+
+ *             |        PAGE_END header      |
+ *             +-----------------------------+
+ *
+ * There are two dump headers, the first which is architecture
+ * independent, and the other which is architecture dependent.  This
+ * allows different architectures to dump different data structures
+ * which are specific to their chipset, CPU, etc.
+ *
+ * After the dump headers come a succession of dump page headers along
+ * with dump pages.  The page header contains information about the page
+ * size, any flags associated with the page (whether it's compressed or
+ * not), and the address of the page.  After the page header is the page
+ * data, which is either compressed (or not).  Each page of data is
+ * dumped in succession, until the final dump header (PAGE_END) is
+ * placed at the end of the dump, assuming the dump device isn't out
+ * of space.
+ *
+ * This mechanism allows for multiple compression types, different
+ * types of data structures, different page ordering, etc., etc., etc.
+ * It's a very straightforward mechanism for dumping system memory.
+ */
+
+struct __dump_header dump_header;  /* the primary dump header              */
+struct __dump_header_asm dump_header_asm; /* the arch-specific dump header */
+
+/*
+ *  Set up common header fields (mainly the arch indep section) 
+ *  Per-cpu state is handled by lcrash_save_context
+ *  Returns the size of the header in bytes.
+ */
+static int lcrash_init_dump_header(const char *panic_str)
+{
+       struct timeval dh_time;
+       unsigned long temp_dha_stack[DUMP_MAX_NUM_CPUS];
+       u64 temp_memsz = dump_header.dh_memory_size;
+
+       /* make sure the dump header isn't TOO big */
+       if ((sizeof(struct __dump_header) +
+               sizeof(struct __dump_header_asm)) > DUMP_BUFFER_SIZE) {
+                       printk("lcrash_init_header(): combined "
+                               "headers larger than DUMP_BUFFER_SIZE!\n");
+                       return -E2BIG;
+       }
+
+       /* initialize the dump headers to zero */
+       /* save dha_stack pointer because it may contains pointer for stack! */
+       memcpy(&(temp_dha_stack[0]), &(dump_header_asm.dha_stack[0]),
+               DUMP_MAX_NUM_CPUS * sizeof(unsigned long));
+       memset(&dump_header, 0, sizeof(dump_header));
+       memset(&dump_header_asm, 0, sizeof(dump_header_asm));
+       dump_header.dh_memory_size = temp_memsz;
+       memcpy(&(dump_header_asm.dha_stack[0]), &(temp_dha_stack[0]),
+               DUMP_MAX_NUM_CPUS * sizeof(unsigned long));
+
+       /* configure dump header values */
+       dump_header.dh_magic_number = DUMP_MAGIC_NUMBER;
+       dump_header.dh_version = DUMP_VERSION_NUMBER;
+       dump_header.dh_memory_start = PAGE_OFFSET;
+       dump_header.dh_memory_end = DUMP_MAGIC_NUMBER;
+       dump_header.dh_header_size = sizeof(struct __dump_header);
+       dump_header.dh_page_size = PAGE_SIZE;
+       dump_header.dh_dump_level = dump_config.level;
+       dump_header.dh_current_task = (unsigned long) current;
+       dump_header.dh_dump_compress = dump_config.dumper->compress->
+               compress_type;
+       dump_header.dh_dump_flags = dump_config.flags;
+       dump_header.dh_dump_device = dump_config.dumper->dev->device_id; 
+
+#if DUMP_DEBUG >= 6
+       dump_header.dh_num_bytes = 0;
+#endif
+       dump_header.dh_num_dump_pages = 0;
+       do_gettimeofday(&dh_time);
+       dump_header.dh_time.tv_sec = dh_time.tv_sec;
+       dump_header.dh_time.tv_usec = dh_time.tv_usec;
+
+       memcpy((void *)&(dump_header.dh_utsname_sysname), 
+               (const void *)&(system_utsname.sysname), __NEW_UTS_LEN + 1);
+       memcpy((void *)&(dump_header.dh_utsname_nodename), 
+               (const void *)&(system_utsname.nodename), __NEW_UTS_LEN + 1);
+       memcpy((void *)&(dump_header.dh_utsname_release), 
+               (const void *)&(system_utsname.release), __NEW_UTS_LEN + 1);
+       memcpy((void *)&(dump_header.dh_utsname_version), 
+               (const void *)&(system_utsname.version), __NEW_UTS_LEN + 1);
+       memcpy((void *)&(dump_header.dh_utsname_machine), 
+               (const void *)&(system_utsname.machine), __NEW_UTS_LEN + 1);
+       memcpy((void *)&(dump_header.dh_utsname_domainname), 
+               (const void *)&(system_utsname.domainname), __NEW_UTS_LEN + 1);
+
+       if (panic_str) {
+               memcpy((void *)&(dump_header.dh_panic_string),
+                       (const void *)panic_str, DUMP_PANIC_LEN);
+       }
+
+        dump_header_asm.dha_magic_number = DUMP_ASM_MAGIC_NUMBER;
+        dump_header_asm.dha_version = DUMP_ASM_VERSION_NUMBER;
+        dump_header_asm.dha_header_size = sizeof(dump_header_asm);
+#ifdef CONFIG_ARM
+       dump_header_asm.dha_physaddr_start = PHYS_OFFSET;
+#endif
+
+       dump_header_asm.dha_smp_num_cpus = num_online_cpus();
+       pr_debug("smp_num_cpus in header %d\n", 
+               dump_header_asm.dha_smp_num_cpus);
+
+       dump_header_asm.dha_dumping_cpu = smp_processor_id();
+       
+       return sizeof(dump_header) + sizeof(dump_header_asm);
+}
+
+
+int dump_lcrash_configure_header(const char *panic_str, 
+       const struct pt_regs *regs)
+{
+       int retval = 0;
+
+       dump_config.dumper->header_len = lcrash_init_dump_header(panic_str);
+
+       /* capture register states for all processors */
+       dump_save_this_cpu(regs);
+       __dump_save_other_cpus(); /* side effect:silence cpus */
+
+       /* configure architecture-specific dump header values */
+       if ((retval = __dump_configure_header(regs))) 
+               return retval;
+
+       dump_config.dumper->header_dirty++;
+       return 0;
+}
+
+/* save register and task context */
+void dump_lcrash_save_context(int cpu, const struct pt_regs *regs, 
+       struct task_struct *tsk)
+{
+       dump_header_asm.dha_smp_current_task[cpu] = (unsigned long)tsk;
+
+       __dump_save_regs(&dump_header_asm.dha_smp_regs[cpu], regs);
+
+       /* take a snapshot of the stack */
+       /* doing this enables us to tolerate slight drifts on this cpu */
+       if (dump_header_asm.dha_stack[cpu]) {
+               memcpy((void *)dump_header_asm.dha_stack[cpu],
+                               tsk->thread_info, THREAD_SIZE);
+       }
+       dump_header_asm.dha_stack_ptr[cpu] = (unsigned long)(tsk->thread_info);
+}
+
+/* write out the header */
+int dump_write_header(void)
+{
+       int retval = 0, size;
+       void *buf = dump_config.dumper->dump_buf;
+
+       /* accounts for DUMP_HEADER_OFFSET if applicable */
+       if ((retval = dump_dev_seek(0))) {
+               printk("Unable to seek to dump header offset: %d\n", 
+                       retval);
+               return retval;
+       }
+
+       memcpy(buf, (void *)&dump_header, sizeof(dump_header));
+       size = sizeof(dump_header);
+       memcpy(buf + size, (void *)&dump_header_asm, sizeof(dump_header_asm));
+       size += sizeof(dump_header_asm);
+       size = PAGE_ALIGN(size);
+       retval = dump_ll_write(buf , size);
+
+       if (retval < size) 
+               return (retval >= 0) ? ENOSPC : retval;
+       return 0;
+}
+
+int dump_generic_update_header(void)
+{
+       int err = 0;
+
+       if (dump_config.dumper->header_dirty) {
+               if ((err = dump_write_header())) {
+                       printk("dump write header failed !err %d\n", err);
+               } else {
+                       dump_config.dumper->header_dirty = 0;
+               }
+       }
+
+       return err;
+}
+
+static inline int is_curr_stack_page(struct page *page, unsigned long size)
+{
+       unsigned long thread_addr = (unsigned long)current_thread_info();
+       unsigned long addr = (unsigned long)page_address(page);
+
+       return !PageHighMem(page) && (addr < thread_addr + THREAD_SIZE)
+               && (addr + size > thread_addr);
+}
+
+static inline int is_dump_page(struct page *page, unsigned long size)
+{
+       unsigned long addr = (unsigned long)page_address(page);
+       unsigned long dump_buf = (unsigned long)dump_config.dumper->dump_buf;
+
+       return !PageHighMem(page) && (addr < dump_buf + DUMP_BUFFER_SIZE)
+               && (addr + size > dump_buf);
+}
+
+int dump_allow_compress(struct page *page, unsigned long size)
+{
+       /*
+        * Don't compress the page if any part of it overlaps
+        * with the current stack or dump buffer (since the contents
+        * in these could be changing while compression is going on)
+        */
+       return !is_curr_stack_page(page, size) && !is_dump_page(page, size);
+}
+
+void lcrash_init_pageheader(struct __dump_page *dp, struct page *page, 
+       unsigned long sz)
+{
+       memset(dp, sizeof(struct __dump_page), 0);
+       dp->dp_flags = 0; 
+       dp->dp_size = 0;
+       if (sz > 0)
+               dp->dp_address = (loff_t)page_to_pfn(page) << PAGE_SHIFT;
+
+#if DUMP_DEBUG > 6
+       dp->dp_page_index = dump_header.dh_num_dump_pages;
+       dp->dp_byte_offset = dump_header.dh_num_bytes + DUMP_BUFFER_SIZE
+               + DUMP_HEADER_OFFSET; /* ?? */
+#endif /* DUMP_DEBUG */
+}
+
+int dump_lcrash_add_data(unsigned long loc, unsigned long len)
+{
+       struct page *page = (struct page *)loc;
+       void *addr, *buf = dump_config.dumper->curr_buf;
+       struct __dump_page *dp = (struct __dump_page *)buf; 
+       int bytes, size;
+
+       if (buf > dump_config.dumper->dump_buf + DUMP_BUFFER_SIZE)
+               return -ENOMEM;
+
+       lcrash_init_pageheader(dp, page, len);
+       buf += sizeof(struct __dump_page);
+
+       while (len) {
+               addr = kmap_atomic(page, KM_DUMP);
+               size = bytes = (len > PAGE_SIZE) ? PAGE_SIZE : len;     
+               /* check for compression */
+               if (dump_allow_compress(page, bytes)) {
+                       size = dump_compress_data((char *)addr, bytes, (char *)buf);
+               }
+               /* set the compressed flag if the page did compress */
+               if (size && (size < bytes)) {
+                       dp->dp_flags |= DUMP_DH_COMPRESSED;
+               } else {
+                       /* compression failed -- default to raw mode */
+                       dp->dp_flags |= DUMP_DH_RAW;
+                       memcpy(buf, addr, bytes);
+                       size = bytes;
+               }
+               /* memset(buf, 'A', size); temporary: testing only !! */
+               kunmap_atomic(addr, KM_DUMP);
+               dp->dp_size += size;
+               buf += size;
+               len -= bytes;
+               page++;
+       }
+
+       /* now update the header */
+#if DUMP_DEBUG > 6
+       dump_header.dh_num_bytes += dp->dp_size + sizeof(*dp);
+#endif
+       dump_header.dh_num_dump_pages++;
+       dump_config.dumper->header_dirty++;
+
+       dump_config.dumper->curr_buf = buf;     
+
+       return len;
+}
+
+int dump_lcrash_update_end_marker(void)
+{
+       struct __dump_page *dp = 
+               (struct __dump_page *)dump_config.dumper->curr_buf;
+       unsigned long left;
+       int ret = 0;
+               
+       lcrash_init_pageheader(dp, NULL, 0);
+       dp->dp_flags |= DUMP_DH_END; /* tbd: truncation test ? */
+       
+       /* now update the header */
+#if DUMP_DEBUG > 6
+       dump_header.dh_num_bytes += sizeof(*dp);
+#endif
+       dump_config.dumper->curr_buf += sizeof(*dp);
+       left = dump_config.dumper->curr_buf - dump_config.dumper->dump_buf;
+
+       printk("\n");
+
+       while (left) {
+               if ((ret = dump_dev_seek(dump_config.dumper->curr_offset))) {
+                       printk("Seek failed at offset 0x%llx\n", 
+                       dump_config.dumper->curr_offset);
+                       return ret;
+               }
+
+               if (DUMP_BUFFER_SIZE > left) 
+                       memset(dump_config.dumper->curr_buf, 'm', 
+                               DUMP_BUFFER_SIZE - left);
+
+               if ((ret = dump_ll_write(dump_config.dumper->dump_buf, 
+                       DUMP_BUFFER_SIZE)) < DUMP_BUFFER_SIZE) {
+                       return (ret < 0) ? ret : -ENOSPC;
+               }
+
+               dump_config.dumper->curr_offset += DUMP_BUFFER_SIZE;
+       
+               if (left > DUMP_BUFFER_SIZE) {
+                       left -= DUMP_BUFFER_SIZE;
+                       memcpy(dump_config.dumper->dump_buf, 
+                       dump_config.dumper->dump_buf + DUMP_BUFFER_SIZE, left);
+                       dump_config.dumper->curr_buf -= DUMP_BUFFER_SIZE;
+               } else {
+                       left = 0;
+               }
+       }
+       return 0;
+}
+
+
+/* Default Formatter (lcrash) */
+struct dump_fmt_ops dump_fmt_lcrash_ops = {
+       .configure_header       = dump_lcrash_configure_header,
+       .update_header          = dump_generic_update_header,
+       .save_context           = dump_lcrash_save_context,
+       .add_data               = dump_lcrash_add_data,
+       .update_end_marker      = dump_lcrash_update_end_marker
+};
+
+struct dump_fmt dump_fmt_lcrash = {
+       .name   = "lcrash",
+       .ops    = &dump_fmt_lcrash_ops
+};
+
diff --git a/drivers/dump/dump_gzip.c b/drivers/dump/dump_gzip.c
new file mode 100644 (file)
index 0000000..8809f52
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * GZIP Compression functions for kernel crash dumps.
+ *
+ * Created by: Matt Robinson (yakker@sourceforge.net)
+ * Copyright 2001 Matt D. Robinson.  All rights reserved.
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/* header files */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/fs.h>
+#include <linux/file.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/dump.h>
+#include <linux/zlib.h>
+#include <linux/vmalloc.h>
+
+static void *deflate_workspace;
+
+/*
+ * Name: dump_compress_gzip()
+ * Func: Compress a DUMP_PAGE_SIZE page using gzip-style algorithms (the.
+ *       deflate functions similar to what's used in PPP).
+ */
+static u16
+dump_compress_gzip(const u8 *old, u16 oldsize, u8 *new, u16 newsize)
+{
+       /* error code and dump stream */
+       int err;
+       z_stream dump_stream;
+       
+       dump_stream.workspace = deflate_workspace;
+       
+       if ((err = zlib_deflateInit(&dump_stream, Z_BEST_COMPRESSION)) != Z_OK) {
+               /* fall back to RLE compression */
+               printk("dump_compress_gzip(): zlib_deflateInit() "
+                       "failed (%d)!\n", err);
+               return 0;
+       }
+
+       /* use old (page of memory) and size (DUMP_PAGE_SIZE) as in-streams */
+       dump_stream.next_in = (u8 *) old;
+       dump_stream.avail_in = oldsize;
+
+       /* out streams are new (dpcpage) and new size (DUMP_DPC_PAGE_SIZE) */
+       dump_stream.next_out = new;
+       dump_stream.avail_out = newsize;
+
+       /* deflate the page -- check for error */
+       err = zlib_deflate(&dump_stream, Z_FINISH);
+       if (err != Z_STREAM_END) {
+               /* zero is return code here */
+               (void)zlib_deflateEnd(&dump_stream);
+               printk("dump_compress_gzip(): zlib_deflate() failed (%d)!\n",
+                       err);
+               return 0;
+       }
+
+       /* let's end the deflated compression stream */
+       if ((err = zlib_deflateEnd(&dump_stream)) != Z_OK) {
+               printk("dump_compress_gzip(): zlib_deflateEnd() "
+                       "failed (%d)!\n", err);
+       }
+
+       /* return the compressed byte total (if it's smaller) */
+       if (dump_stream.total_out >= oldsize) {
+               return oldsize;
+       }
+       return dump_stream.total_out;
+}
+
+/* setup the gzip compression functionality */
+static struct __dump_compress dump_gzip_compression = {
+       .compress_type = DUMP_COMPRESS_GZIP,
+       .compress_func = dump_compress_gzip,
+       .compress_name = "GZIP",
+};
+
+/*
+ * Name: dump_compress_gzip_init()
+ * Func: Initialize gzip as a compression mechanism.
+ */
+static int __init
+dump_compress_gzip_init(void)
+{
+       deflate_workspace = vmalloc(zlib_deflate_workspacesize());
+       if (!deflate_workspace) {
+               printk("dump_compress_gzip_init(): Failed to "
+                       "alloc %d bytes for deflate workspace\n",
+                       zlib_deflate_workspacesize());
+               return -ENOMEM;
+       }
+       dump_register_compression(&dump_gzip_compression);
+       return 0;
+}
+
+/*
+ * Name: dump_compress_gzip_cleanup()
+ * Func: Remove gzip as a compression mechanism.
+ */
+static void __exit
+dump_compress_gzip_cleanup(void)
+{
+       vfree(deflate_workspace);
+       dump_unregister_compression(DUMP_COMPRESS_GZIP);
+}
+
+/* module initialization */
+module_init(dump_compress_gzip_init);
+module_exit(dump_compress_gzip_cleanup);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("LKCD Development Team <lkcd-devel@lists.sourceforge.net>");
+MODULE_DESCRIPTION("Gzip compression module for crash dump driver");
diff --git a/drivers/dump/dump_i386.c b/drivers/dump/dump_i386.c
new file mode 100644 (file)
index 0000000..5a01e0f
--- /dev/null
@@ -0,0 +1,344 @@
+/*
+ * Architecture specific (i386) functions for Linux crash dumps.
+ *
+ * Created by: Matt Robinson (yakker@sgi.com)
+ *
+ * Copyright 1999 Silicon Graphics, Inc. All rights reserved.
+ *
+ * 2.3 kernel modifications by: Matt D. Robinson (yakker@turbolinux.com)
+ * Copyright 2000 TurboLinux, Inc.  All rights reserved.
+ * 
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/*
+ * The hooks for dumping the kernel virtual memory to disk are in this
+ * file.  Any time a modification is made to the virtual memory mechanism,
+ * these routines must be changed to use the new mechanisms.
+ */
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/smp.h>
+#include <linux/fs.h>
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+#include <linux/dump.h>
+#include "dump_methods.h"
+#include <linux/irq.h>
+
+#include <asm/processor.h>
+#include <asm/e820.h>
+#include <asm/hardirq.h>
+#include <asm/nmi.h>
+
+static __s32        saved_irq_count;   /* saved preempt_count() flags */
+
+static int
+alloc_dha_stack(void)
+{
+       int i;
+       void *ptr;
+       
+       if (dump_header_asm.dha_stack[0])
+               return 0;
+
+       ptr = vmalloc(THREAD_SIZE * num_online_cpus());
+       if (!ptr) {
+               printk("vmalloc for dha_stacks failed\n");
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < num_online_cpus(); i++) {
+               dump_header_asm.dha_stack[i] = (u32)((unsigned long)ptr +
+                               (i * THREAD_SIZE));
+       }
+       return 0;
+}
+
+static int
+free_dha_stack(void) 
+{
+       if (dump_header_asm.dha_stack[0]) {
+               vfree((void *)dump_header_asm.dha_stack[0]);    
+               dump_header_asm.dha_stack[0] = 0;
+       }
+       return 0;
+}
+
+
+void 
+__dump_save_regs(struct pt_regs *dest_regs, const struct pt_regs *regs)
+{
+       *dest_regs = *regs;
+
+       /* In case of panic dumps, we collects regs on entry to panic.
+        * so, we shouldn't 'fix' ssesp here again. But it is hard to
+        * tell just looking at regs whether ssesp need fixing. We make
+        * this decision by looking at xss in regs. If we have better
+        * means to determine that ssesp are valid (by some flag which
+        * tells that we are here due to panic dump), then we can use
+        * that instead of this kludge.
+        */
+       if (!user_mode(regs)) {
+               if ((0xffff & regs->xss) == __KERNEL_DS) 
+                       /* already fixed up */
+                       return;
+               dest_regs->esp = (unsigned long)&(regs->esp);
+               __asm__ __volatile__ ("movw %%ss, %%ax;"
+                       :"=a"(dest_regs->xss));
+       }
+}
+
+
+#ifdef CONFIG_SMP
+extern cpumask_t irq_affinity[];
+extern irq_desc_t irq_desc[];
+extern void dump_send_ipi(void);
+
+static int dump_expect_ipi[NR_CPUS];
+static atomic_t waiting_for_dump_ipi;
+static cpumask_t saved_affinity[NR_IRQS];
+
+extern void stop_this_cpu(void *); /* exported by i386 kernel */
+
+static int
+dump_nmi_callback(struct pt_regs *regs, int cpu) 
+{
+       if (!dump_expect_ipi[cpu])
+               return 0;
+
+       dump_expect_ipi[cpu] = 0;
+       
+       dump_save_this_cpu(regs);
+       atomic_dec(&waiting_for_dump_ipi);
+
+ level_changed:
+       switch (dump_silence_level) {
+       case DUMP_HARD_SPIN_CPUS:       /* Spin until dump is complete */
+               while (dump_oncpu) {
+                       barrier();      /* paranoia */
+                       if (dump_silence_level != DUMP_HARD_SPIN_CPUS)
+                               goto level_changed;
+
+                       cpu_relax();    /* kill time nicely */
+               }
+               break;
+
+       case DUMP_HALT_CPUS:            /* Execute halt */
+               stop_this_cpu(NULL);
+               break;
+               
+       case DUMP_SOFT_SPIN_CPUS:
+               /* Mark the task so it spins in schedule */
+               set_tsk_thread_flag(current, TIF_NEED_RESCHED);
+               break;
+       }
+
+       return 1;
+}
+
+/* save registers on other processors */
+void 
+__dump_save_other_cpus(void)
+{
+       int i, cpu = smp_processor_id();
+       int other_cpus = num_online_cpus()-1;
+       
+       if (other_cpus > 0) {
+               atomic_set(&waiting_for_dump_ipi, other_cpus);
+
+               for (i = 0; i < NR_CPUS; i++) {
+                       dump_expect_ipi[i] = (i != cpu && cpu_online(i));
+               }
+
+               /* short circuit normal NMI handling temporarily */
+               set_nmi_callback(dump_nmi_callback);
+               wmb();
+
+               dump_send_ipi();
+               /* may be we dont need to wait for NMI to be processed. 
+                  just write out the header at the end of dumping, if
+                  this IPI is not processed until then, there probably
+                  is a problem and we just fail to capture state of 
+                  other cpus. */
+               while(atomic_read(&waiting_for_dump_ipi) > 0) {
+                       cpu_relax();
+               }
+
+               unset_nmi_callback();
+       }
+}
+
+/*
+ * Routine to save the old irq affinities and change affinities of all irqs to
+ * the dumping cpu.
+ */
+static void 
+set_irq_affinity(void)
+{
+       int i;
+       cpumask_t cpu = CPU_MASK_NONE;
+
+       cpu_set(smp_processor_id(), cpu);
+       memcpy(saved_affinity, irq_affinity, NR_IRQS * sizeof(unsigned long));
+       for (i = 0; i < NR_IRQS; i++) {
+               if (irq_desc[i].handler == NULL)
+                       continue;
+               irq_affinity[i] = cpu;
+               if (irq_desc[i].handler->set_affinity != NULL)
+                       irq_desc[i].handler->set_affinity(i, irq_affinity[i]);
+       }
+}
+
+/*
+ * Restore old irq affinities.
+ */
+static void 
+reset_irq_affinity(void)
+{
+       int i;
+
+       memcpy(irq_affinity, saved_affinity, NR_IRQS * sizeof(unsigned long));
+       for (i = 0; i < NR_IRQS; i++) {
+               if (irq_desc[i].handler == NULL)
+                       continue;
+               if (irq_desc[i].handler->set_affinity != NULL)
+                       irq_desc[i].handler->set_affinity(i, saved_affinity[i]);
+       }
+}
+
+#else /* !CONFIG_SMP */
+#define set_irq_affinity()     do { } while (0)
+#define reset_irq_affinity()   do { } while (0)
+#define save_other_cpu_states() do { } while (0)
+#endif /* !CONFIG_SMP */
+
+/* 
+ * Kludge - dump from interrupt context is unreliable (Fixme)
+ *
+ * We do this so that softirqs initiated for dump i/o 
+ * get processed and we don't hang while waiting for i/o
+ * to complete or in any irq synchronization attempt.
+ *
+ * This is not quite legal of course, as it has the side 
+ * effect of making all interrupts & softirqs triggered 
+ * while dump is in progress complete before currently 
+ * pending softirqs and the currently executing interrupt 
+ * code. 
+ */
+static inline void
+irq_bh_save(void)
+{
+       saved_irq_count = irq_count();
+       preempt_count() &= ~(HARDIRQ_MASK|SOFTIRQ_MASK);
+}
+
+static inline void
+irq_bh_restore(void)
+{
+       preempt_count() |= saved_irq_count;
+}
+
+/*
+ * Name: __dump_irq_enable
+ * Func: Reset system so interrupts are enabled.
+ *      This is used for dump methods that require interrupts
+ *      Eventually, all methods will have interrupts disabled
+ *      and this code can be removed.
+ *
+ *     Change irq affinities
+ *     Re-enable interrupts
+ */
+int
+__dump_irq_enable(void)
+{
+       set_irq_affinity();
+       irq_bh_save();
+       local_irq_enable();
+       return 0;
+}
+
+/*
+ * Name: __dump_irq_restore
+ * Func: Resume the system state in an architecture-specific way.
+
+ */
+void 
+__dump_irq_restore(void)
+{
+       local_irq_disable();
+       reset_irq_affinity();
+       irq_bh_restore();
+}
+
+/*
+ * Name: __dump_configure_header()
+ * Func: Meant to fill in arch specific header fields except per-cpu state
+ * already captured via __dump_save_context for all CPUs.
+ */
+int
+__dump_configure_header(const struct pt_regs *regs)
+{
+       return (0);
+}
+
+/*
+ * Name: __dump_init()
+ * Func: Initialize the dumping routine process.
+ */
+void
+__dump_init(uint64_t local_memory_start)
+{
+       return;
+}
+
+/*
+ * Name: __dump_open()
+ * Func: Open the dump device (architecture specific).
+ */
+void
+__dump_open(void)
+{
+       alloc_dha_stack();
+}
+
+/*
+ * Name: __dump_cleanup()
+ * Func: Free any architecture specific data structures. This is called
+ *       when the dump module is being removed.
+ */
+void
+__dump_cleanup(void)
+{
+       free_dha_stack();
+}
+
+extern int pfn_is_ram(unsigned long);
+
+/*
+ * Name: __dump_page_valid()
+ * Func: Check if page is valid to dump.
+ */ 
+int 
+__dump_page_valid(unsigned long index)
+{
+       if (!pfn_valid(index))
+               return 0;
+
+       return pfn_is_ram(index);
+}
+
+/* 
+ * Name: manual_handle_crashdump()
+ * Func: Interface for the lkcd dump command. Calls dump_execute()
+ */
+int
+manual_handle_crashdump(void) {
+
+       struct pt_regs regs;
+       
+       get_current_regs(&regs);
+       dump_execute("manual", &regs);
+       return 0;
+}
diff --git a/drivers/dump/dump_memdev.c b/drivers/dump/dump_memdev.c
new file mode 100644 (file)
index 0000000..1cd700d
--- /dev/null
@@ -0,0 +1,640 @@
+/*
+ * Implements the dump driver interface for saving a dump in available
+ * memory areas. The saved pages may be written out to persistent storage  
+ * after a soft reboot.
+ *
+ * Started: Oct 2002 -  Suparna Bhattacharya <suparna@in.ibm.com>
+ *
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * This code is released under version 2 of the GNU GPL.
+ *
+ * The approach of tracking pages containing saved dump using map pages 
+ * allocated as needed has been derived from the Mission Critical Linux 
+ * mcore dump implementation. 
+ *
+ * Credits and a big thanks for letting the lkcd project make use of 
+ * the excellent piece of work and also helping with clarifications 
+ * and tips along the way are due to:
+ *     Dave Winchell <winchell@mclx.com> (primary author of mcore)
+ *     Jeff Moyer <moyer@mclx.com>
+ *     Josh Huber <huber@mclx.com>
+ *
+ * For those familiar with the mcore code, the main differences worth
+ * noting here (besides the dump device abstraction) result from enabling 
+ * "high" memory pages (pages not permanently mapped in the kernel 
+ * address space) to be used for saving dump data (because of which a 
+ * simple virtual address based linked list cannot be used anymore for 
+ * managing free pages), an added level of indirection for faster 
+ * lookups during the post-boot stage, and the idea of pages being 
+ * made available as they get freed up while dump to memory progresses 
+ * rather than one time before starting the dump. The last point enables 
+ * a full memory snapshot to be saved starting with an initial set of 
+ * bootstrap pages given a good compression ratio. (See dump_overlay.c)
+ *
+ */
+
+/*
+ * -----------------MEMORY LAYOUT ------------------
+ * The memory space consists of a set of discontiguous pages, and
+ * discontiguous map pages as well, rooted in a chain of indirect
+ * map pages (also discontiguous). Except for the indirect maps 
+ * (which must be preallocated in advance), the rest of the pages 
+ * could be in high memory.
+ *
+ * root
+ *  |    ---------    --------        --------
+ *  -->  | .  . +|--->|  .  +|------->| . .  |       indirect 
+ *       --|--|---    ---|----        --|-|---      maps
+ *         |  |          |                     | |     
+ *    ------  ------   -------     ------ -------
+ *    | .  |  | .  |   | .  . |    | .  | |  . . |   maps 
+ *    --|---  --|---   --|--|--    --|--- ---|-|--
+ *     page    page    page page   page   page page  data
+ *                                                   pages
+ *
+ * Writes to the dump device happen sequentially in append mode.
+ * The main reason for the existence of the indirect map is
+ * to enable a quick way to lookup a specific logical offset in
+ * the saved data post-soft-boot, e.g. to writeout pages
+ * with more critical data first, even though such pages
+ * would have been compressed and copied last, being the lowest
+ * ranked candidates for reuse due to their criticality.
+ * (See dump_overlay.c)
+ */
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <linux/bootmem.h>
+#include <linux/dump.h>
+#include "dump_methods.h"
+
+#define DUMP_MAP_SZ (PAGE_SIZE / sizeof(unsigned long)) /* direct map size */
+#define DUMP_IND_MAP_SZ        DUMP_MAP_SZ - 1  /* indirect map size */
+#define DUMP_NR_BOOTSTRAP      64  /* no of bootstrap pages */
+
+extern int dump_low_page(struct page *);
+
+/* check if the next entry crosses a page boundary */
+static inline int is_last_map_entry(unsigned long *map)
+{
+       unsigned long addr = (unsigned long)(map + 1);
+
+       return (!(addr & (PAGE_SIZE - 1)));
+}
+
+/* Todo: should have some validation checks */
+/* The last entry in the indirect map points to the next indirect map */
+/* Indirect maps are referred to directly by virtual address */
+static inline unsigned long *next_indirect_map(unsigned long *map)
+{
+       return (unsigned long *)map[DUMP_IND_MAP_SZ];
+}
+
+#ifdef CONFIG_CRASH_DUMP_SOFTBOOT
+/* Called during early bootup - fixme: make this __init */
+void dump_early_reserve_map(struct dump_memdev *dev)
+{
+       unsigned long *map1, *map2;
+       loff_t off = 0, last = dev->last_used_offset >> PAGE_SHIFT;
+       int i, j;
+       
+       printk("Reserve bootmap space holding previous dump of %lld pages\n",
+                       last);
+       map1= (unsigned long *)dev->indirect_map_root;
+
+       while (map1 && (off < last)) {
+               reserve_bootmem(virt_to_phys((void *)map1), PAGE_SIZE);
+               for (i=0;  (i < DUMP_MAP_SZ - 1) && map1[i] && (off < last); 
+                       i++, off += DUMP_MAP_SZ) {
+                       pr_debug("indirect map[%d] = 0x%lx\n", i, map1[i]);
+                       if (map1[i] >= max_low_pfn)
+                               continue;
+                       reserve_bootmem(map1[i] << PAGE_SHIFT, PAGE_SIZE);
+                       map2 = pfn_to_kaddr(map1[i]);
+                       for (j = 0 ; (j < DUMP_MAP_SZ) && map2[j] && 
+                               (off + j < last); j++) {
+                               pr_debug("\t map[%d][%d] = 0x%lx\n", i, j, 
+                                       map2[j]);
+                               if (map2[j] < max_low_pfn) {
+                                       reserve_bootmem(map2[j] << PAGE_SHIFT,
+                                               PAGE_SIZE);
+                               }
+                       }
+               }
+               map1 = next_indirect_map(map1);
+       }
+       dev->nr_free = 0; /* these pages don't belong to this boot */
+}
+#endif
+
+/* mark dump pages so that they aren't used by this kernel */
+void dump_mark_map(struct dump_memdev *dev)
+{
+       unsigned long *map1, *map2;
+       loff_t off = 0, last = dev->last_used_offset >> PAGE_SHIFT;
+       struct page *page;
+       int i, j;
+       
+       printk("Dump: marking pages in use by previous dump\n");
+       map1= (unsigned long *)dev->indirect_map_root;
+
+       while (map1 && (off < last)) {
+               page = virt_to_page(map1);      
+               set_page_count(page, 1);
+               for (i=0;  (i < DUMP_MAP_SZ - 1) && map1[i] && (off < last); 
+                       i++, off += DUMP_MAP_SZ) {
+                       pr_debug("indirect map[%d] = 0x%lx\n", i, map1[i]);
+                       page = pfn_to_page(map1[i]);
+                       set_page_count(page, 1);
+                       map2 = kmap_atomic(page, KM_DUMP);
+                       for (j = 0 ; (j < DUMP_MAP_SZ) && map2[j] && 
+                               (off + j < last); j++) {
+                               pr_debug("\t map[%d][%d] = 0x%lx\n", i, j, 
+                                       map2[j]);
+                               page = pfn_to_page(map2[j]);
+                               set_page_count(page, 1);
+                       }
+               }
+               map1 = next_indirect_map(map1);
+       }
+}
+       
+
+/* 
+ * Given a logical offset into the mem device lookup the 
+ * corresponding page 
+ *     loc is specified in units of pages 
+ * Note: affects curr_map (even in the case where lookup fails)
+ */
+struct page *dump_mem_lookup(struct dump_memdev *dump_mdev, unsigned long loc)
+{
+       unsigned long *map;
+       unsigned long i, index = loc / DUMP_MAP_SZ;
+       struct page *page = NULL;
+       unsigned long curr_pfn, curr_map, *curr_map_ptr = NULL;
+
+       map = (unsigned long *)dump_mdev->indirect_map_root;
+       if (!map)
+               return NULL;
+
+       if (loc > dump_mdev->last_offset >> PAGE_SHIFT)
+               return NULL;
+
+       /* 
+        * first locate the right indirect map 
+        * in the chain of indirect maps 
+        */
+       for (i = 0; i + DUMP_IND_MAP_SZ < index ; i += DUMP_IND_MAP_SZ) {
+               if (!(map = next_indirect_map(map)))
+                       return NULL;
+       }
+       /* then the right direct map */
+       /* map entries are referred to by page index */
+       if ((curr_map = map[index - i])) {
+               page = pfn_to_page(curr_map);
+               /* update the current traversal index */
+               /* dump_mdev->curr_map = &map[index - i];*/
+               curr_map_ptr = &map[index - i];
+       }
+
+       if (page)
+               map = kmap_atomic(page, KM_DUMP);
+       else 
+               return NULL;
+
+       /* and finally the right entry therein */
+       /* data pages are referred to by page index */
+       i = index * DUMP_MAP_SZ;
+       if ((curr_pfn = map[loc - i])) {
+               page = pfn_to_page(curr_pfn);
+               dump_mdev->curr_map = curr_map_ptr;
+               dump_mdev->curr_map_offset = loc - i;
+               dump_mdev->ddev.curr_offset = loc << PAGE_SHIFT;
+       } else {
+               page = NULL;
+       }
+       kunmap_atomic(map, KM_DUMP);
+
+       return page;
+}
+                       
+/* 
+ * Retrieves a pointer to the next page in the dump device 
+ * Used during the lookup pass post-soft-reboot 
+ */
+struct page *dump_mem_next_page(struct dump_memdev *dev)
+{
+       unsigned long i; 
+       unsigned long *map;     
+       struct page *page = NULL;
+
+       if (dev->ddev.curr_offset + PAGE_SIZE >= dev->last_offset) {
+               return NULL;
+       }
+
+       if ((i = (unsigned long)(++dev->curr_map_offset)) >= DUMP_MAP_SZ) {
+               /* move to next map */  
+               if (is_last_map_entry(++dev->curr_map)) {
+                       /* move to the next indirect map page */
+                       printk("dump_mem_next_page: go to next indirect map\n");
+                       dev->curr_map = (unsigned long *)*dev->curr_map;
+                       if (!dev->curr_map)
+                               return NULL;
+               }
+               i = dev->curr_map_offset = 0;
+               pr_debug("dump_mem_next_page: next map 0x%lx, entry 0x%lx\n",
+                               dev->curr_map, *dev->curr_map);
+
+       };
+       
+       if (*dev->curr_map) {
+               map = kmap_atomic(pfn_to_page(*dev->curr_map), KM_DUMP);
+               if (map[i])
+                       page = pfn_to_page(map[i]);
+               kunmap_atomic(map, KM_DUMP);
+               dev->ddev.curr_offset += PAGE_SIZE;
+       };
+
+       return page;
+}
+
+/* Copied from dump_filters.c */
+static inline int kernel_page(struct page *p)
+{
+       /* FIXME: Need to exclude hugetlb pages. Clue: reserved but inuse */
+       return (PageReserved(p) && !PageInuse(p)) || (!PageLRU(p) && PageInuse(p));
+}
+
+static inline int user_page(struct page *p)
+{
+       return PageInuse(p) && (!PageReserved(p) && PageLRU(p));
+}
+
+int dump_reused_by_boot(struct page *page)
+{
+       /* Todo
+        * Checks:
+        * if PageReserved 
+        * if < __end + bootmem_bootmap_pages for this boot + allowance 
+        * if overwritten by initrd (how to check ?)
+        * Also, add more checks in early boot code
+        * e.g. bootmem bootmap alloc verify not overwriting dump, and if
+        * so then realloc or move the dump pages out accordingly.
+        */
+
+       /* Temporary proof of concept hack, avoid overwriting kern pages */
+
+       return (kernel_page(page) || dump_low_page(page) || user_page(page));
+}
+
+
+/* Uses the free page passed in to expand available space */
+int dump_mem_add_space(struct dump_memdev *dev, struct page *page)
+{
+       struct page *map_page;
+       unsigned long *map;     
+       unsigned long i; 
+
+       if (!dev->curr_map)
+               return -ENOMEM; /* must've exhausted indirect map */
+
+       if (!*dev->curr_map || dev->curr_map_offset >= DUMP_MAP_SZ) {
+               /* add map space */
+               *dev->curr_map = page_to_pfn(page);
+               dev->curr_map_offset = 0;
+               return 0;
+       }
+
+       /* add data space */
+       i = dev->curr_map_offset;
+       map_page = pfn_to_page(*dev->curr_map);
+       map = (unsigned long *)kmap_atomic(map_page, KM_DUMP);
+       map[i] = page_to_pfn(page);
+       kunmap_atomic(map, KM_DUMP);
+       dev->curr_map_offset = ++i;
+       dev->last_offset += PAGE_SIZE;
+       if (i >= DUMP_MAP_SZ) {
+               /* move to next map */
+               if (is_last_map_entry(++dev->curr_map)) {
+                       /* move to the next indirect map page */
+                       pr_debug("dump_mem_add_space: using next"
+                       "indirect map\n");
+                       dev->curr_map = (unsigned long *)*dev->curr_map;
+               }
+       }               
+       return 0;
+}
+
+
+/* Caution: making a dest page invalidates existing contents of the page */
+int dump_check_and_free_page(struct dump_memdev *dev, struct page *page)
+{
+       int err = 0;
+
+       /* 
+        * the page can be used as a destination only if we are sure
+        * it won't get overwritten by the soft-boot, and is not
+        * critical for us right now.
+        */
+       if (dump_reused_by_boot(page))
+               return 0;
+
+       if ((err = dump_mem_add_space(dev, page))) {
+               printk("Warning: Unable to extend memdev space. Err %d\n",
+               err);
+               return 0;
+       }
+
+       dev->nr_free++;
+       return 1;
+}
+
+
+/* Set up the initial maps and bootstrap space  */
+/* Must be called only after any previous dump is written out */
+int dump_mem_open(struct dump_dev *dev, unsigned long devid)
+{
+       struct dump_memdev *dump_mdev = DUMP_MDEV(dev);
+       unsigned long nr_maps, *map, *prev_map = &dump_mdev->indirect_map_root;
+       void *addr;
+       struct page *page;
+       unsigned long i = 0;
+       int err = 0;
+
+       /* Todo: sanity check for unwritten previous dump */
+
+       /* allocate pages for indirect map (non highmem area) */
+       nr_maps = num_physpages / DUMP_MAP_SZ; /* maps to cover entire mem */
+       for (i = 0; i < nr_maps; i += DUMP_IND_MAP_SZ) {
+               if (!(map = (unsigned long *)dump_alloc_mem(PAGE_SIZE))) {
+                       printk("Unable to alloc indirect map %ld\n", 
+                               i / DUMP_IND_MAP_SZ);
+                       return -ENOMEM;
+               }
+               clear_page(map);
+               *prev_map = (unsigned long)map;
+               prev_map = &map[DUMP_IND_MAP_SZ];
+       };
+               
+       dump_mdev->curr_map = (unsigned long *)dump_mdev->indirect_map_root;
+       dump_mdev->curr_map_offset = 0; 
+
+       /* 
+        * allocate a few bootstrap pages: at least 1 map and 1 data page
+        * plus enough to save the dump header
+        */
+       i = 0;
+       do {
+               if (!(addr = dump_alloc_mem(PAGE_SIZE))) {
+                       printk("Unable to alloc bootstrap page %ld\n", i);
+                       return -ENOMEM;
+               }
+
+               page = virt_to_page(addr);
+               if (dump_low_page(page)) {
+                       dump_free_mem(addr);
+                       continue;
+               }
+
+               if (dump_mem_add_space(dump_mdev, page)) {
+                       printk("Warning: Unable to extend memdev "
+                                       "space. Err %d\n", err);
+                       dump_free_mem(addr);
+                       continue;
+               }
+               i++;
+       } while (i < DUMP_NR_BOOTSTRAP);
+
+       printk("dump memdev init: %ld maps, %ld bootstrap pgs, %ld free pgs\n",
+               nr_maps, i, dump_mdev->last_offset >> PAGE_SHIFT);
+       
+       dump_mdev->last_bs_offset = dump_mdev->last_offset;
+
+       return 0;
+}
+
+/* Releases all pre-alloc'd pages */
+int dump_mem_release(struct dump_dev *dev)
+{
+       struct dump_memdev *dump_mdev = DUMP_MDEV(dev);
+       struct page *page, *map_page;
+       unsigned long *map, *prev_map;
+       void *addr;
+       int i;
+
+       if (!dump_mdev->nr_free)
+               return 0;
+
+       pr_debug("dump_mem_release\n");
+       page = dump_mem_lookup(dump_mdev, 0);
+       for (i = 0; page && (i < DUMP_NR_BOOTSTRAP - 1); i++) {
+               if (PageHighMem(page))
+                       break;
+               addr = page_address(page);
+               if (!addr) {
+                       printk("page_address(%p) = NULL\n", page);
+                       break;
+               }
+               pr_debug("Freeing page at 0x%lx\n", addr); 
+               dump_free_mem(addr);
+               if (dump_mdev->curr_map_offset >= DUMP_MAP_SZ - 1) {
+                       map_page = pfn_to_page(*dump_mdev->curr_map);
+                       if (PageHighMem(map_page))
+                               break;
+                       page = dump_mem_next_page(dump_mdev);
+                       addr = page_address(map_page);
+                       if (!addr) {
+                               printk("page_address(%p) = NULL\n", 
+                                       map_page);
+                               break;
+                       }
+                       pr_debug("Freeing map page at 0x%lx\n", addr);
+                       dump_free_mem(addr);
+                       i++;
+               } else {
+                       page = dump_mem_next_page(dump_mdev);
+               }
+       }
+
+       /* now for the last used bootstrap page used as a map page */
+       if ((i < DUMP_NR_BOOTSTRAP) && (*dump_mdev->curr_map)) {
+               map_page = pfn_to_page(*dump_mdev->curr_map);
+               if ((map_page) && !PageHighMem(map_page)) {
+                       addr = page_address(map_page);
+                       if (!addr) {
+                               printk("page_address(%p) = NULL\n", map_page);
+                       } else {
+                               pr_debug("Freeing map page at 0x%lx\n", addr);
+                               dump_free_mem(addr);
+                               i++;
+                       }
+               }
+       }
+
+       printk("Freed %d bootstrap pages\n", i);
+
+       /* free the indirect maps */
+       map = (unsigned long *)dump_mdev->indirect_map_root;
+
+       i = 0;
+       while (map) {
+               prev_map = map;
+               map = next_indirect_map(map);
+               dump_free_mem(prev_map);
+               i++;
+       }
+
+       printk("Freed %d indirect map(s)\n", i);
+
+       /* Reset the indirect map */
+       dump_mdev->indirect_map_root = 0;
+       dump_mdev->curr_map = 0;
+
+       /* Reset the free list */
+       dump_mdev->nr_free = 0;
+
+       dump_mdev->last_offset = dump_mdev->ddev.curr_offset = 0;
+       dump_mdev->last_used_offset = 0;
+       dump_mdev->curr_map = NULL;
+       dump_mdev->curr_map_offset = 0;
+       return 0;
+}
+
+/*
+ * Long term:
+ * It is critical for this to be very strict. Cannot afford
+ * to have anything running and accessing memory while we overwrite 
+ * memory (potential risk of data corruption).
+ * If in doubt (e.g if a cpu is hung and not responding) just give
+ * up and refuse to proceed with this scheme.
+ *
+ * Note: I/O will only happen after soft-boot/switchover, so we can 
+ * safely disable interrupts and force stop other CPUs if this is
+ * going to be a disruptive dump, no matter what they
+ * are in the middle of.
+ */
+/* 
+ * ATM Most of this is already taken care of in the nmi handler 
+ * We may halt the cpus rightaway if we know this is going to be disruptive 
+ * For now, since we've limited ourselves to overwriting free pages we
+ * aren't doing much here. Eventually, we'd have to wait to make sure other
+ * cpus aren't using memory we could be overwriting
+ */
+int dump_mem_silence(struct dump_dev *dev)
+{
+       struct dump_memdev *dump_mdev = DUMP_MDEV(dev);
+
+       if (dump_mdev->last_offset > dump_mdev->last_bs_offset) {
+               /* prefer to run lkcd config & start with a clean slate */
+               return -EEXIST;
+       }
+       return 0;
+}
+
+extern int dump_overlay_resume(void);
+
+/* Trigger the next stage of dumping */
+int dump_mem_resume(struct dump_dev *dev)
+{
+       dump_overlay_resume(); 
+       return 0;
+}
+
+/* 
+ * Allocate mem dev pages as required and copy buffer contents into it.
+ * Fails if the no free pages are available
+ * Keeping it simple and limited for starters (can modify this over time)
+ *  Does not handle holes or a sparse layout
+ *  Data must be in multiples of PAGE_SIZE
+ */
+int dump_mem_write(struct dump_dev *dev, void *buf, unsigned long len)
+{
+       struct dump_memdev *dump_mdev = DUMP_MDEV(dev);
+       struct page *page;
+       unsigned long n = 0;
+       void *addr;
+       unsigned long *saved_curr_map, saved_map_offset;
+       int ret = 0;
+
+       pr_debug("dump_mem_write: offset 0x%llx, size %ld\n", 
+               dev->curr_offset, len);
+
+       if (dev->curr_offset + len > dump_mdev->last_offset)  {
+               printk("Out of space to write\n");
+               return -ENOSPC;
+       }
+       
+       if ((len & (PAGE_SIZE - 1)) || (dev->curr_offset & (PAGE_SIZE - 1)))
+               return -EINVAL; /* not aligned in units of page size */
+
+       saved_curr_map = dump_mdev->curr_map;
+       saved_map_offset = dump_mdev->curr_map_offset;
+       page = dump_mem_lookup(dump_mdev, dev->curr_offset >> PAGE_SHIFT);
+
+       for (n = len; (n > 0) && page; n -= PAGE_SIZE, buf += PAGE_SIZE ) {
+               addr = kmap_atomic(page, KM_DUMP);
+               /* memset(addr, 'x', PAGE_SIZE); */
+               memcpy(addr, buf, PAGE_SIZE);
+               kunmap_atomic(addr, KM_DUMP);
+               /* dev->curr_offset += PAGE_SIZE; */
+               page = dump_mem_next_page(dump_mdev);
+       }
+
+       dump_mdev->curr_map = saved_curr_map;
+       dump_mdev->curr_map_offset = saved_map_offset;
+
+       if (dump_mdev->last_used_offset < dev->curr_offset)
+               dump_mdev->last_used_offset = dev->curr_offset;
+
+       return (len - n) ? (len - n) : ret ;
+}
+
+/* dummy - always ready */
+int dump_mem_ready(struct dump_dev *dev, void *buf)
+{
+       return 0;
+}
+
+/* 
+ * Should check for availability of space to write upto the offset 
+ * affects only the curr_offset; last_offset untouched 
+ * Keep it simple: Only allow multiples of PAGE_SIZE for now 
+ */
+int dump_mem_seek(struct dump_dev *dev, loff_t offset)
+{
+       struct dump_memdev *dump_mdev = DUMP_MDEV(dev);
+
+       if (offset & (PAGE_SIZE - 1))
+               return -EINVAL; /* allow page size units only for now */
+       
+       /* Are we exceeding available space ? */
+       if (offset > dump_mdev->last_offset) {
+               printk("dump_mem_seek failed for offset 0x%llx\n",
+                       offset);
+               return -ENOSPC; 
+       }
+
+       dump_mdev->ddev.curr_offset = offset;
+       return 0;
+}
+
+struct dump_dev_ops dump_memdev_ops = {
+       .open           = dump_mem_open,
+       .release        = dump_mem_release,
+       .silence        = dump_mem_silence,
+       .resume         = dump_mem_resume,
+       .seek           = dump_mem_seek,
+       .write          = dump_mem_write,
+       .read           = NULL, /* not implemented at the moment */
+       .ready          = dump_mem_ready
+};
+
+static struct dump_memdev default_dump_memdev = {
+       .ddev = {.type_name = "memdev", .ops = &dump_memdev_ops,
+                .device_id = 0x14}
+       /* assume the rest of the fields are zeroed by default */
+};     
+       
+/* may be overwritten if a previous dump exists */
+struct dump_memdev *dump_memdev = &default_dump_memdev;
+
diff --git a/drivers/dump/dump_methods.h b/drivers/dump/dump_methods.h
new file mode 100644 (file)
index 0000000..d2e1f7c
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * Generic interfaces for flexible system dump 
+ *
+ * Started: Oct 2002 -  Suparna Bhattacharya (suparna@in.ibm.com)
+ *
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+#ifndef _LINUX_DUMP_METHODS_H
+#define _LINUX_DUMP_METHODS_H
+
+/*
+ * Inspired by Matt Robinson's suggestion of introducing dump 
+ * methods as a way to enable different crash dump facilities to 
+ * coexist where each employs its own scheme or dumping policy.
+ *
+ * The code here creates a framework for flexible dump by defining 
+ * a set of methods and providing associated helpers that differentiate
+ * between the underlying mechanism (how to dump), overall scheme 
+ * (sequencing of stages and data dumped and associated quiescing), 
+ * output format (what the dump output looks like), target type 
+ * (where to save the dump; see dumpdev.h), and selection policy 
+ * (state/data to dump).
+ * 
+ * These sets of interfaces can be mixed and matched to build a 
+ * dumper suitable for a given situation, allowing for 
+ * flexibility as well appropriate degree of code reuse.
+ * For example all features and options of lkcd (including
+ * granular selective dumping in the near future) should be
+ * available even when say, the 2 stage soft-boot based mechanism 
+ * is used for taking disruptive dumps.
+ *
+ * Todo: Additionally modules or drivers may supply their own
+ * custom dumpers which extend dump with module specific
+ * information or hardware state, and can even tweak the
+ * mechanism when it comes to saving state relevant to
+ * them.
+ */
+
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/highmem.h>
+#include <linux/dumpdev.h>
+
+#define MAX_PASSES     6
+#define MAX_DEVS       4
+
+
+/* To customise selection of pages to be dumped in a given pass/group */
+struct dump_data_filter{
+       char name[32];
+       int (*selector)(int, unsigned long, unsigned long);
+       ulong level_mask; /* dump level(s) for which this filter applies */
+       loff_t start[MAX_NUMNODES], end[MAX_NUMNODES]; /* location range applicable */
+       ulong num_mbanks;  /* Number of memory banks. Greater than one for discontig memory (NUMA) */
+};
+
+
+/* 
+ * Determined by the kind of dump mechanism and appropriate 
+ * overall scheme 
+ */ 
+struct dump_scheme_ops {
+       /* sets aside memory, inits data structures etc */
+       int (*configure)(unsigned long devid); 
+       /* releases  resources */
+       int (*unconfigure)(void); 
+
+       /* ordering of passes, invoking iterator */
+       int (*sequencer)(void); 
+        /* iterates over system data, selects and acts on data to dump */
+       int (*iterator)(int, int (*)(unsigned long, unsigned long), 
+               struct dump_data_filter *); 
+        /* action when data is selected for dump */
+       int (*save_data)(unsigned long, unsigned long); 
+        /* action when data is to be excluded from dump */
+       int (*skip_data)(unsigned long, unsigned long); 
+       /* policies for space, multiple dump devices etc */
+       int (*write_buffer)(void *, unsigned long); 
+};
+
+struct dump_scheme {
+       /* the name serves as an anchor to locate the scheme after reboot */
+       char name[32]; 
+       struct dump_scheme_ops *ops;
+       struct list_head list;
+};
+
+/* Quiescing/Silence levels (controls IPI callback behaviour) */
+extern enum dump_silence_levels {
+       DUMP_SOFT_SPIN_CPUS     = 1,
+       DUMP_HARD_SPIN_CPUS     = 2,
+       DUMP_HALT_CPUS          = 3,
+} dump_silence_level;
+
+/* determined by the dump (file) format */
+struct dump_fmt_ops {
+       /* build header */
+       int (*configure_header)(const char *, const struct pt_regs *); 
+       int (*update_header)(void); /* update header and write it out */
+       /* save curr context  */
+       void (*save_context)(int, const struct pt_regs *, 
+               struct task_struct *); 
+       /* typically called by the save_data action */
+       /* add formatted data to the dump buffer */
+       int (*add_data)(unsigned long, unsigned long); 
+       int (*update_end_marker)(void);
+};
+
+struct dump_fmt {
+       unsigned long magic; 
+       char name[32];  /* lcrash, crash, elf-core etc */
+       struct dump_fmt_ops *ops;
+       struct list_head list;
+};
+
+/* 
+ * Modules will be able add their own data capture schemes by 
+ * registering their own dumpers. Typically they would use the 
+ * primary dumper as a template and tune it with their routines.
+ * Still Todo.
+ */
+
+/* The combined dumper profile (mechanism, scheme, dev, fmt) */
+struct dumper {
+       char name[32]; /* singlestage, overlay (stg1), passthru(stg2), pull */
+       struct dump_scheme *scheme;
+       struct dump_fmt *fmt;
+       struct __dump_compress *compress;
+       struct dump_data_filter *filter;
+       struct dump_dev *dev; 
+       /* state valid only for active dumper(s) - per instance */
+       /* run time state/context */
+       int curr_pass;
+       unsigned long count;
+       loff_t curr_offset; /* current logical offset into dump device */
+       loff_t curr_loc; /* current memory location */
+       void *curr_buf; /* current position in the dump buffer */
+       void *dump_buf; /* starting addr of dump buffer */
+       int header_dirty; /* whether the header needs to be written out */
+       int header_len; 
+       struct list_head dumper_list; /* links to other dumpers */
+};     
+
+/* Starting point to get to the current configured state */
+struct dump_config {
+       ulong level;
+       ulong flags;
+       struct dumper *dumper;
+       unsigned long dump_device;
+       unsigned long dump_addr; /* relevant only for in-memory dumps */
+       struct list_head dump_dev_list;
+};     
+
+extern struct dump_config dump_config;
+
+/* Used to save the dump config across a reboot for 2-stage dumps: 
+ * 
+ * Note: The scheme, format, compression and device type should be 
+ * registered at bootup, for this config to be sharable across soft-boot. 
+ * The function addresses could have changed and become invalid, and
+ * need to be set up again.
+ */
+struct dump_config_block {
+       u64 magic; /* for a quick sanity check after reboot */
+       struct dump_memdev memdev; /* handle to dump stored in memory */
+       struct dump_config config;
+       struct dumper dumper;
+       struct dump_scheme scheme;
+       struct dump_fmt fmt;
+       struct __dump_compress compress;
+       struct dump_data_filter filter_table[MAX_PASSES];
+       struct dump_anydev dev[MAX_DEVS]; /* target dump device */
+};
+
+
+/* Wrappers that invoke the methods for the current (active) dumper */
+
+/* Scheme operations */
+
+static inline int dump_sequencer(void)
+{
+       return dump_config.dumper->scheme->ops->sequencer();
+}
+
+static inline int dump_iterator(int pass, int (*action)(unsigned long, 
+       unsigned long), struct dump_data_filter *filter)
+{
+       return dump_config.dumper->scheme->ops->iterator(pass, action, filter);
+}
+
+#define dump_save_data dump_config.dumper->scheme->ops->save_data
+#define dump_skip_data dump_config.dumper->scheme->ops->skip_data
+
+static inline int dump_write_buffer(void *buf, unsigned long len)
+{
+       return dump_config.dumper->scheme->ops->write_buffer(buf, len);
+}
+
+static inline int dump_configure(unsigned long devid)
+{
+       return dump_config.dumper->scheme->ops->configure(devid);
+}
+
+static inline int dump_unconfigure(void)
+{
+       return dump_config.dumper->scheme->ops->unconfigure();
+}
+
+/* Format operations */
+
+static inline int dump_configure_header(const char *panic_str, 
+       const struct pt_regs *regs)
+{
+       return dump_config.dumper->fmt->ops->configure_header(panic_str, regs);
+}
+
+static inline void dump_save_context(int cpu, const struct pt_regs *regs, 
+               struct task_struct *tsk)
+{
+       dump_config.dumper->fmt->ops->save_context(cpu, regs, tsk);
+}
+
+static inline int dump_save_this_cpu(const struct pt_regs *regs)
+{
+       int cpu = smp_processor_id();
+
+       dump_save_context(cpu, regs, current);
+       return 1;
+}
+
+static inline int dump_update_header(void)
+{
+       return dump_config.dumper->fmt->ops->update_header();
+}
+
+static inline int dump_update_end_marker(void)
+{
+       return dump_config.dumper->fmt->ops->update_end_marker();
+}
+
+static inline int dump_add_data(unsigned long loc, unsigned long sz)
+{
+       return dump_config.dumper->fmt->ops->add_data(loc, sz);
+}
+
+/* Compression operation */
+static inline int dump_compress_data(char *src, int slen, char *dst)
+{
+       return dump_config.dumper->compress->compress_func(src, slen, 
+               dst, DUMP_DPC_PAGE_SIZE);
+}
+
+
+/* Prototypes of some default implementations of dump methods */
+
+extern struct __dump_compress dump_none_compression;
+
+/* Default scheme methods (dump_scheme.c) */
+
+extern int dump_generic_sequencer(void);
+extern int dump_page_iterator(int pass, int (*action)(unsigned long, unsigned
+       long), struct dump_data_filter *filter);
+extern int dump_generic_save_data(unsigned long loc, unsigned long sz);
+extern int dump_generic_skip_data(unsigned long loc, unsigned long sz);
+extern int dump_generic_write_buffer(void *buf, unsigned long len);
+extern int dump_generic_configure(unsigned long);
+extern int dump_generic_unconfigure(void);
+
+/* Default scheme template */
+extern struct dump_scheme dump_scheme_singlestage;
+
+/* Default dump format methods */
+
+extern int dump_lcrash_configure_header(const char *panic_str, 
+       const struct pt_regs *regs);
+extern void dump_lcrash_save_context(int  cpu, const struct pt_regs *regs, 
+       struct task_struct *tsk);
+extern int dump_generic_update_header(void);
+extern int dump_lcrash_add_data(unsigned long loc, unsigned long sz);
+extern int dump_lcrash_update_end_marker(void);
+
+/* Default format (lcrash) template */
+extern struct dump_fmt dump_fmt_lcrash;
+
+/* Default dump selection filter table */
+
+/* 
+ * Entries listed in order of importance and correspond to passes
+ * The last entry (with a level_mask of zero) typically reflects data that 
+ * won't be dumped  -- this may for example be used to identify data 
+ * that will be skipped for certain so the corresponding memory areas can be 
+ * utilized as scratch space.
+ */   
+extern struct dump_data_filter dump_filter_table[];
+
+/* Some pre-defined dumpers */
+extern struct dumper dumper_singlestage;
+extern struct dumper dumper_stage1;
+extern struct dumper dumper_stage2;
+
+/* These are temporary */
+#define DUMP_MASK_HEADER       DUMP_LEVEL_HEADER
+#define DUMP_MASK_KERN         DUMP_LEVEL_KERN
+#define DUMP_MASK_USED         DUMP_LEVEL_USED
+#define DUMP_MASK_UNUSED       DUMP_LEVEL_ALL_RAM
+#define DUMP_MASK_REST         0 /* dummy for now */
+
+/* Helpers - move these to dump.h later ? */
+
+int dump_generic_execute(const char *panic_str, const struct pt_regs *regs);
+extern int dump_ll_write(void *buf, unsigned long len); 
+int dump_check_and_free_page(struct dump_memdev *dev, struct page *page);
+
+static inline void dumper_reset(void)
+{
+       dump_config.dumper->curr_buf = dump_config.dumper->dump_buf;
+       dump_config.dumper->curr_loc = 0;
+       dump_config.dumper->curr_offset = 0;
+       dump_config.dumper->count = 0;
+       dump_config.dumper->curr_pass = 0;
+}
+
+/* 
+ * May later be moulded to perform boot-time allocations so we can dump 
+ * earlier during bootup 
+ */
+static inline void *dump_alloc_mem(unsigned long size)
+{
+       return kmalloc(size, GFP_KERNEL);
+}
+
+static inline void dump_free_mem(void *buf)
+{
+       struct page *page;
+
+       /* ignore reserved pages (e.g. post soft boot stage) */
+       if (buf && (page = virt_to_page(buf))) {
+               if (PageReserved(page))
+                       return;
+       }
+
+       kfree(buf);
+}
+
+
+#endif /*  _LINUX_DUMP_METHODS_H */
diff --git a/drivers/dump/dump_netdev.c b/drivers/dump/dump_netdev.c
new file mode 100644 (file)
index 0000000..1feb6da
--- /dev/null
@@ -0,0 +1,867 @@
+/*
+ * Implements the dump driver interface for saving a dump via network
+ * interface. 
+ *
+ * Some of this code has been taken/adapted from Ingo Molnar's netconsole
+ * code. LKCD team expresses its thanks to Ingo.
+ *
+ * Started: June 2002 - Mohamed Abbas <mohamed.abbas@intel.com>
+ *     Adapted netconsole code to implement LKCD dump over the network.
+ *
+ * Nov 2002 - Bharata B. Rao <bharata@in.ibm.com>
+ *     Innumerable code cleanups, simplification and some fixes.
+ *     Netdump configuration done by ioctl instead of using module parameters.
+ *
+ * Copyright (C) 2001  Ingo Molnar <mingo@redhat.com>
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ *  This code is released under version 2 of the GNU GPL.
+ */
+
+#include <net/tcp.h>
+#include <net/udp.h>
+#include <linux/delay.h>
+#include <linux/random.h>
+#include <linux/reboot.h>
+#include <linux/module.h>
+#include <linux/dump.h>
+#include <linux/dump_netdev.h>
+#include <linux/percpu.h>
+
+#include <asm/unaligned.h>
+
+static int startup_handshake;
+static int page_counter;
+static struct net_device *dump_ndev;
+static struct in_device *dump_in_dev;
+static u16 source_port, target_port;
+static u32 source_ip, target_ip;
+static unsigned char daddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} ;
+static spinlock_t dump_skb_lock = SPIN_LOCK_UNLOCKED;
+static int dump_nr_skbs;
+static struct sk_buff *dump_skb;
+static unsigned long flags_global;
+static int netdump_in_progress;
+static char device_name[IFNAMSIZ];
+
+/*
+ * security depends on the trusted path between the netconsole
+ * server and netconsole client, since none of the packets are
+ * encrypted. The random magic number protects the protocol
+ * against spoofing.
+ */
+static u64 dump_magic;
+
+#define MAX_UDP_CHUNK 1460
+#define MAX_PRINT_CHUNK (MAX_UDP_CHUNK-HEADER_LEN)
+
+/*
+ * We maintain a small pool of fully-sized skbs,
+ * to make sure the message gets out even in
+ * extreme OOM situations.
+ */
+#define DUMP_MAX_SKBS 32
+
+#define MAX_SKB_SIZE \
+               (MAX_UDP_CHUNK + sizeof(struct udphdr) + \
+                               sizeof(struct iphdr) + sizeof(struct ethhdr))
+
+static void
+dump_refill_skbs(void)
+{
+       struct sk_buff *skb;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dump_skb_lock, flags);
+       while (dump_nr_skbs < DUMP_MAX_SKBS) {
+               skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC);
+               if (!skb)
+                       break;
+               if (dump_skb)
+                       skb->next = dump_skb;
+               else
+                       skb->next = NULL;
+               dump_skb = skb;
+               dump_nr_skbs++;
+       }
+       spin_unlock_irqrestore(&dump_skb_lock, flags);
+}
+
+static struct
+sk_buff * dump_get_skb(void)
+{
+       struct sk_buff *skb;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dump_skb_lock, flags);
+       skb = dump_skb;
+       if (skb) {
+               dump_skb = skb->next;
+               skb->next = NULL;
+               dump_nr_skbs--;
+       }
+       spin_unlock_irqrestore(&dump_skb_lock, flags);
+        
+       return skb;
+}
+
+/*
+ * Zap completed output skbs.
+ */
+static void
+zap_completion_queue(void)
+{
+       int count;
+       unsigned long flags;
+       struct softnet_data *sd;
+
+        count=0;
+       sd = &__get_cpu_var(softnet_data);
+       if (sd->completion_queue) {
+               struct sk_buff *clist;
+       
+               local_irq_save(flags);
+               clist = sd->completion_queue;
+               sd->completion_queue = NULL;
+               local_irq_restore(flags);
+
+               while (clist != NULL) {
+                       struct sk_buff *skb = clist;
+                       clist = clist->next;
+                       __kfree_skb(skb);
+                       count++;
+                       if (count > 10000)
+                               printk("Error in sk list\n");
+               }
+       }
+}
+
+static void
+dump_send_skb(struct net_device *dev, const char *msg, unsigned int msg_len,
+               reply_t *reply)
+{
+       int once = 1;
+       int total_len, eth_len, ip_len, udp_len, count = 0;
+       struct sk_buff *skb;
+       struct udphdr *udph;
+       struct iphdr *iph;
+       struct ethhdr *eth; 
+
+       udp_len = msg_len + HEADER_LEN + sizeof(*udph);
+       ip_len = eth_len = udp_len + sizeof(*iph);
+       total_len = eth_len + ETH_HLEN;
+
+repeat_loop:
+       zap_completion_queue();
+       if (dump_nr_skbs < DUMP_MAX_SKBS)
+               dump_refill_skbs();
+
+       skb = alloc_skb(total_len, GFP_ATOMIC);
+       if (!skb) {
+               skb = dump_get_skb();
+               if (!skb) {
+                       count++;
+                       if (once && (count == 1000000)) {
+                               printk("possibly FATAL: out of netconsole "
+                                       "skbs!!! will keep retrying.\n");
+                               once = 0;
+                       }
+                       dev->poll_controller(dev);
+                       goto repeat_loop;
+               }
+       }
+
+       atomic_set(&skb->users, 1);
+       skb_reserve(skb, total_len - msg_len - HEADER_LEN);
+       skb->data[0] = NETCONSOLE_VERSION;
+
+       put_unaligned(htonl(reply->nr), (u32 *) (skb->data + 1));
+       put_unaligned(htonl(reply->code), (u32 *) (skb->data + 5));
+       put_unaligned(htonl(reply->info), (u32 *) (skb->data + 9));
+
+       memcpy(skb->data + HEADER_LEN, msg, msg_len);
+       skb->len += msg_len + HEADER_LEN;
+
+       udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
+       udph->source = source_port;
+       udph->dest = target_port;
+       udph->len = htons(udp_len);
+       udph->check = 0;
+
+       iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
+
+       iph->version  = 4;
+       iph->ihl      = 5;
+       iph->tos      = 0;
+       iph->tot_len  = htons(ip_len);
+       iph->id       = 0;
+       iph->frag_off = 0;
+       iph->ttl      = 64;
+       iph->protocol = IPPROTO_UDP;
+       iph->check    = 0;
+       iph->saddr    = source_ip;
+       iph->daddr    = target_ip;
+       iph->check    = ip_fast_csum((unsigned char *)iph, iph->ihl);
+
+       eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
+
+       eth->h_proto = htons(ETH_P_IP);
+       memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
+       memcpy(eth->h_dest, daddr, dev->addr_len);
+
+       count=0;
+repeat_poll:
+       spin_lock(&dev->xmit_lock);
+       dev->xmit_lock_owner = smp_processor_id();
+
+       count++;
+
+
+       if (netif_queue_stopped(dev)) {
+               dev->xmit_lock_owner = -1;
+               spin_unlock(&dev->xmit_lock);
+
+               dev->poll_controller(dev);
+               zap_completion_queue();
+
+
+               goto repeat_poll;
+       }
+
+       dev->hard_start_xmit(skb, dev);
+
+       dev->xmit_lock_owner = -1;
+       spin_unlock(&dev->xmit_lock);
+}
+
+static unsigned short
+udp_check(struct udphdr *uh, int len, unsigned long saddr, unsigned long daddr,
+               unsigned long base)
+{
+       return csum_tcpudp_magic(saddr, daddr, len, IPPROTO_UDP, base);
+}
+
+static int
+udp_checksum_init(struct sk_buff *skb, struct udphdr *uh,
+                            unsigned short ulen, u32 saddr, u32 daddr)
+{
+       if (uh->check == 0) {
+               skb->ip_summed = CHECKSUM_UNNECESSARY;
+       } else if (skb->ip_summed == CHECKSUM_HW) {
+               skb->ip_summed = CHECKSUM_UNNECESSARY;
+               if (!udp_check(uh, ulen, saddr, daddr, skb->csum))
+                       return 0;
+               skb->ip_summed = CHECKSUM_NONE;
+       }
+       if (skb->ip_summed != CHECKSUM_UNNECESSARY)
+               skb->csum = csum_tcpudp_nofold(saddr, daddr, ulen,
+                               IPPROTO_UDP, 0);
+       /* Probably, we should checksum udp header (it should be in cache
+        * in any case) and data in tiny packets (< rx copybreak).
+        */
+       return 0;
+}
+
+static __inline__ int
+__udp_checksum_complete(struct sk_buff *skb)
+{
+       return (unsigned short)csum_fold(skb_checksum(skb, 0, skb->len,
+                               skb->csum));
+}
+
+static __inline__
+int udp_checksum_complete(struct sk_buff *skb)
+{
+       return skb->ip_summed != CHECKSUM_UNNECESSARY &&
+               __udp_checksum_complete(skb);
+}
+
+int new_req = 0;
+static req_t req;
+
+static int
+dump_rx_hook(struct sk_buff *skb)
+{
+       int proto;
+       struct iphdr *iph;
+       struct udphdr *uh;
+       __u32 len, saddr, daddr, ulen;
+       req_t *__req;
+
+       /* 
+        * First check if were are dumping or doing startup handshake, if
+        * not quickly return.
+        */
+       if (!netdump_in_progress)
+               return NET_RX_SUCCESS;
+
+       if (skb->dev->type != ARPHRD_ETHER)
+               goto out;
+
+       proto = ntohs(skb->mac.ethernet->h_proto);
+       if (proto != ETH_P_IP)
+               goto out;
+
+       if (skb->pkt_type == PACKET_OTHERHOST)
+               goto out;
+
+       if (skb_shared(skb))
+               goto out;
+
+        /* IP header correctness testing: */
+       iph = (struct iphdr *)skb->data;
+       if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+               goto out;
+
+       if (iph->ihl < 5 || iph->version != 4)
+               goto out;
+
+       if (!pskb_may_pull(skb, iph->ihl*4))
+               goto out;
+
+       if (ip_fast_csum((u8 *)iph, iph->ihl) != 0)
+               goto out;
+
+       len = ntohs(iph->tot_len);
+       if (skb->len < len || len < iph->ihl*4)
+               goto out;
+
+       saddr = iph->saddr;
+       daddr = iph->daddr;
+       if (iph->protocol != IPPROTO_UDP)
+               goto out;
+
+       if (source_ip != daddr)
+               goto out;
+
+       if (target_ip != saddr)
+               goto out;
+
+       len -= iph->ihl*4;
+       uh = (struct udphdr *)(((char *)iph) + iph->ihl*4);
+       ulen = ntohs(uh->len);
+
+       if (ulen != len || ulen < (sizeof(*uh) + sizeof(*__req)))
+               goto out;
+
+       if (udp_checksum_init(skb, uh, ulen, saddr, daddr) < 0)
+               goto out;
+
+       if (udp_checksum_complete(skb))
+               goto out;
+
+       if (source_port != uh->dest)
+               goto out;
+
+       if (target_port != uh->source)
+               goto out;
+
+       __req = (req_t *)(uh + 1);
+       if ((ntohl(__req->command) != COMM_GET_MAGIC) &&
+           (ntohl(__req->command) != COMM_HELLO) &&
+           (ntohl(__req->command) != COMM_START_WRITE_NETDUMP_ACK) &&
+           (ntohl(__req->command) != COMM_START_NETDUMP_ACK) &&
+           (memcmp(&__req->magic, &dump_magic, sizeof(dump_magic)) != 0))
+               goto out;
+
+       req.magic = ntohl(__req->magic);
+       req.command = ntohl(__req->command);
+       req.from = ntohl(__req->from);
+       req.to = ntohl(__req->to);
+       req.nr = ntohl(__req->nr);
+       new_req = 1;
+out:
+       return NET_RX_DROP;
+}
+
+static void
+dump_send_mem(struct net_device *dev, req_t *req, const char* buff, size_t len)
+{
+       int i;
+
+       int nr_chunks = len/1024;
+       reply_t reply;
+       
+       reply.nr = req->nr;
+       reply.info = 0;
+
+        if ( nr_chunks <= 0)
+                nr_chunks = 1;
+       for (i = 0; i < nr_chunks; i++) {
+               unsigned int offset = i*1024;
+               reply.code = REPLY_MEM;
+               reply.info = offset;
+                dump_send_skb(dev, buff + offset, 1024, &reply);
+       }
+}
+
+/*
+ * This function waits for the client to acknowledge the receipt
+ * of the netdump startup reply, with the possibility of packets
+ * getting lost. We resend the startup packet if no ACK is received,
+ * after a 1 second delay.
+ *
+ * (The client can test the success of the handshake via the HELLO
+ * command, and send ACKs until we enter netdump mode.)
+ */
+static int
+dump_handshake(struct dump_dev *net_dev)
+{
+       char tmp[200];
+       reply_t reply;
+       int i, j;
+
+       if (startup_handshake) {
+               sprintf(tmp, "NETDUMP start, waiting for start-ACK.\n");
+               reply.code = REPLY_START_NETDUMP;
+               reply.nr = 0;
+               reply.info = 0;
+       } else {
+               sprintf(tmp, "NETDUMP start, waiting for start-ACK.\n");
+               reply.code = REPLY_START_WRITE_NETDUMP;
+               reply.nr = net_dev->curr_offset;
+               reply.info = net_dev->curr_offset;
+       }
+       
+       /* send 300 handshake packets before declaring failure */
+       for (i = 0; i < 300; i++) {
+               dump_send_skb(dump_ndev, tmp, strlen(tmp), &reply);
+
+               /* wait 1 sec */
+               for (j = 0; j < 10000; j++) {
+                       udelay(100);
+                       dump_ndev->poll_controller(dump_ndev);
+                       zap_completion_queue();
+                       if (new_req)
+                               break;
+               }
+
+               /* 
+                * if there is no new request, try sending the handshaking
+                * packet again
+                */
+               if (!new_req)
+                       continue;
+
+               /* 
+                * check if the new request is of the expected type,
+                * if so, return, else try sending the handshaking
+                * packet again
+                */
+               if (startup_handshake) {
+                       if (req.command == COMM_HELLO || req.command ==
+                               COMM_START_NETDUMP_ACK) {
+                               return 0;
+                       } else {
+                               new_req = 0;
+                               continue;
+                       }
+               } else {
+                       if (req.command == COMM_SEND_MEM) {
+                               return 0;
+                       } else {
+                               new_req = 0;
+                               continue;
+                       }
+               }
+       }
+       return -1;
+}
+
+static ssize_t
+do_netdump(struct dump_dev *net_dev, const char* buff, size_t len)
+{
+       reply_t reply;
+       char tmp[200];
+       ssize_t  ret = 0;
+       int repeatCounter, counter, total_loop;
+       
+       netdump_in_progress = 1;
+
+       if (dump_handshake(net_dev) < 0) {
+               printk("network dump failed due to handshake failure\n");
+               goto out;
+       }
+
+       /*
+        * Ideally startup handshake should be done during dump configuration,
+        * i.e., in dump_net_open(). This will be done when I figure out
+        * the dependency between startup handshake, subsequent write and
+        * various commands wrt to net-server.
+        */
+       if (startup_handshake)
+               startup_handshake = 0;
+
+        counter = 0;
+       repeatCounter = 0;
+       total_loop = 0;
+       while (1) {
+                if (!new_req) {
+                       dump_ndev->poll_controller(dump_ndev);
+                       zap_completion_queue();
+               }
+               if (!new_req) {
+                       repeatCounter++;
+
+                       if (repeatCounter > 5) {
+                               counter++;
+                               if (counter > 10000) {
+                                       if (total_loop >= 100000) {
+                                               printk("Time OUT LEAVE NOW\n");
+                                               goto out;
+                                       } else {
+                                               total_loop++;
+                                               printk("Try number %d out of "
+                                                       "10 before Time Out\n",
+                                                       total_loop);
+                                       }
+                               }
+                               mdelay(1);
+                               repeatCounter = 0;
+                       }       
+                       continue;
+               }
+               repeatCounter = 0;
+               counter = 0;
+               total_loop = 0;
+               new_req = 0;
+               switch (req.command) {
+               case COMM_NONE:
+                       break;
+
+               case COMM_SEND_MEM:
+                       dump_send_mem(dump_ndev, &req, buff, len);
+                       break;
+
+               case COMM_EXIT:
+                case COMM_START_WRITE_NETDUMP_ACK:
+                       ret = len;
+                       goto out;
+
+               case COMM_HELLO:
+                       sprintf(tmp, "Hello, this is netdump version "
+                                       "0.%02d\n", NETCONSOLE_VERSION);
+                       reply.code = REPLY_HELLO;
+                       reply.nr = req.nr;
+                        reply.info = net_dev->curr_offset;
+                       dump_send_skb(dump_ndev, tmp, strlen(tmp), &reply);
+                       break;
+
+               case COMM_GET_PAGE_SIZE:
+                       sprintf(tmp, "PAGE_SIZE: %ld\n", PAGE_SIZE);
+                       reply.code = REPLY_PAGE_SIZE;
+                       reply.nr = req.nr;
+                       reply.info = PAGE_SIZE;
+                       dump_send_skb(dump_ndev, tmp, strlen(tmp), &reply);
+                       break;
+
+               case COMM_GET_NR_PAGES:
+                       reply.code = REPLY_NR_PAGES;
+                       reply.nr = req.nr;
+                       reply.info = num_physpages;
+                        reply.info = page_counter;
+                       sprintf(tmp, "Number of pages: %ld\n", num_physpages);
+                       dump_send_skb(dump_ndev, tmp, strlen(tmp), &reply);
+                       break;
+
+               case COMM_GET_MAGIC:
+                       reply.code = REPLY_MAGIC;
+                       reply.nr = req.nr;
+                       reply.info = NETCONSOLE_VERSION;
+                       dump_send_skb(dump_ndev, (char *)&dump_magic,
+                                       sizeof(dump_magic), &reply);
+                       break;
+
+               default:
+                       reply.code = REPLY_ERROR;
+                       reply.nr = req.nr;
+                       reply.info = req.command;
+                       sprintf(tmp, "Got unknown command code %d!\n",
+                                       req.command);
+                       dump_send_skb(dump_ndev, tmp, strlen(tmp), &reply);
+                       break;
+               }
+       }
+out:
+       netdump_in_progress = 0;
+       return ret;
+}
+
+static int
+dump_validate_config(void)
+{
+       source_ip = dump_in_dev->ifa_list->ifa_local;
+       if (!source_ip) {
+               printk("network device %s has no local address, "
+                               "aborting.\n", device_name);
+               return -1;
+       }
+
+#define IP(x) ((unsigned char *)&source_ip)[x]
+       printk("Source %d.%d.%d.%d", IP(0), IP(1), IP(2), IP(3));
+#undef IP
+
+       if (!source_port) {
+               printk("source_port parameter not specified, aborting.\n");
+               return -1;
+       }
+       printk(":%i\n", source_port);
+       source_port = htons(source_port);
+
+       if (!target_ip) {
+               printk("target_ip parameter not specified, aborting.\n");
+               return -1;
+       }
+
+#define IP(x) ((unsigned char *)&target_ip)[x]
+       printk("Target %d.%d.%d.%d", IP(0), IP(1), IP(2), IP(3));
+#undef IP
+
+       if (!target_port) {
+               printk("target_port parameter not specified, aborting.\n");
+               return -1;
+       }
+       printk(":%i\n", target_port);
+       target_port = htons(target_port);
+
+       printk("Target Ethernet Address %02x:%02x:%02x:%02x:%02x:%02x",
+               daddr[0], daddr[1], daddr[2], daddr[3], daddr[4], daddr[5]);
+
+       if ((daddr[0] & daddr[1] & daddr[2] & daddr[3] & daddr[4] & 
+                               daddr[5]) == 255)
+               printk("(Broadcast)");
+       printk("\n");
+       return 0;
+}
+
+/*
+ * Prepares the dump device so we can take a dump later. 
+ * Validates the netdump configuration parameters.
+ *
+ * TODO: Network connectivity check should be done here.
+ */
+static int
+dump_net_open(struct dump_dev *net_dev, unsigned long arg)
+{
+       int retval = 0;
+
+       /* get the interface name */
+       if (copy_from_user(device_name, (void *)arg, IFNAMSIZ))
+               return -EFAULT;
+
+       if (!(dump_ndev = dev_get_by_name(device_name))) {
+               printk("network device %s does not exist, aborting.\n",
+                               device_name);
+               return -ENODEV;
+       }
+
+       if (!dump_ndev->poll_controller) {
+               printk("network device %s does not implement polling yet, "
+                               "aborting.\n", device_name);
+               retval = -1; /* return proper error */
+               goto err1;
+       }
+
+       if (!(dump_in_dev = in_dev_get(dump_ndev))) {
+               printk("network device %s is not an IP protocol device, "
+                               "aborting.\n", device_name);
+               retval = -EINVAL;
+               goto err1;
+       }
+
+       if ((retval = dump_validate_config()) < 0)
+               goto err2;
+
+       net_dev->curr_offset = 0;
+       printk("Network device %s successfully configured for dumping\n",
+                       device_name);
+       return retval;
+err2:
+       in_dev_put(dump_in_dev);
+err1:
+       dev_put(dump_ndev);     
+       return retval;
+}
+
+/*
+ * Close the dump device and release associated resources
+ * Invoked when unconfiguring the dump device.
+ */
+static int
+dump_net_release(struct dump_dev *net_dev)
+{
+       if (dump_in_dev)
+               in_dev_put(dump_in_dev);
+       if (dump_ndev)
+               dev_put(dump_ndev);
+       return 0;
+}
+
+/*
+ * Prepare the dump device for use (silence any ongoing activity
+ * and quiesce state) when the system crashes.
+ */
+static int
+dump_net_silence(struct dump_dev *net_dev)
+{
+       netpoll_set_trap(1);
+       local_irq_save(flags_global);
+       dump_ndev->rx_hook = dump_rx_hook;
+        startup_handshake = 1;
+       net_dev->curr_offset = 0;
+       printk("Dumping to network device %s on CPU %d ...\n", device_name,
+                       smp_processor_id());
+       return 0;
+}
+
+/*
+ * Invoked when dumping is done. This is the time to put things back 
+ * (i.e. undo the effects of dump_block_silence) so the device is 
+ * available for normal use.
+ */
+static int
+dump_net_resume(struct dump_dev *net_dev)
+{
+       int indx;
+       reply_t reply;
+       char tmp[200];
+
+        if (!dump_ndev)
+               return (0);
+
+       sprintf(tmp, "NETDUMP end.\n");
+       for( indx = 0; indx < 6; indx++) {
+               reply.code = REPLY_END_NETDUMP;
+               reply.nr = 0;
+               reply.info = 0;
+               dump_send_skb(dump_ndev, tmp, strlen(tmp), &reply);
+       }
+       printk("NETDUMP END!\n");
+       local_irq_restore(flags_global);
+       netpoll_set_trap(0);
+       dump_ndev->rx_hook = NULL;
+       startup_handshake = 0;
+       return 0;
+}
+
+/*
+ * Seek to the specified offset in the dump device.
+ * Makes sure this is a valid offset, otherwise returns an error.
+ */
+static  int
+dump_net_seek(struct dump_dev *net_dev, loff_t off)
+{
+       /*
+        * For now using DUMP_HEADER_OFFSET as hard coded value,
+        * See dump_block_seekin dump_blockdev.c to know how to
+        * do this properly.
+        */
+       net_dev->curr_offset = off;
+       return 0;
+}
+
+/*
+ *
+ */
+static int
+dump_net_write(struct dump_dev *net_dev, void *buf, unsigned long len)
+{
+       int cnt, i, off;
+       ssize_t ret;
+
+       cnt = len/ PAGE_SIZE;
+
+       for (i = 0; i < cnt; i++) {
+               off = i* PAGE_SIZE;
+               ret = do_netdump(net_dev, buf+off, PAGE_SIZE);
+               if (ret <= 0)
+                       return -1;
+               net_dev->curr_offset = net_dev->curr_offset + PAGE_SIZE;
+       }
+       return len;
+}
+
+/*
+ * check if the last dump i/o is over and ready for next request
+ */
+static int
+dump_net_ready(struct dump_dev *net_dev, void *buf)
+{
+       return 0;
+}
+
+/*
+ * ioctl function used for configuring network dump
+ */
+static int
+dump_net_ioctl(struct dump_dev *net_dev, unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case DIOSTARGETIP:
+               target_ip = arg;
+               break;
+       case DIOSTARGETPORT:
+               target_port = (u16)arg;
+               break;
+       case DIOSSOURCEPORT:
+               source_port = (u16)arg;
+               break;
+       case DIOSETHADDR:
+               return copy_from_user(daddr, (void *)arg, 6);
+               break;
+       case DIOGTARGETIP:
+       case DIOGTARGETPORT:
+       case DIOGSOURCEPORT:
+       case DIOGETHADDR:
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
+struct dump_dev_ops dump_netdev_ops = {
+       .open           = dump_net_open,
+       .release        = dump_net_release,
+       .silence        = dump_net_silence,
+       .resume         = dump_net_resume,
+       .seek           = dump_net_seek,
+       .write          = dump_net_write,
+       /* .read not implemented */
+       .ready          = dump_net_ready,
+       .ioctl          = dump_net_ioctl
+};
+
+static struct dump_dev default_dump_netdev = {
+       .type_name = "networkdev", 
+       .ops = &dump_netdev_ops, 
+       .curr_offset = 0
+};
+
+static int __init
+dump_netdev_init(void)
+{
+        default_dump_netdev.curr_offset = 0;
+
+       if (dump_register_device(&default_dump_netdev) < 0) {
+               printk("network dump device driver registration failed\n");
+               return -1;
+       }
+       printk("network device driver for LKCD registered\n");
+       get_random_bytes(&dump_magic, sizeof(dump_magic));
+       return 0;
+}
+
+static void __exit
+dump_netdev_cleanup(void)
+{
+       dump_unregister_device(&default_dump_netdev);
+}
+
+MODULE_AUTHOR("LKCD Development Team <lkcd-devel@lists.sourceforge.net>");
+MODULE_DESCRIPTION("Network Dump Driver for Linux Kernel Crash Dump (LKCD)");
+MODULE_LICENSE("GPL");
+
+module_init(dump_netdev_init);
+module_exit(dump_netdev_cleanup);
diff --git a/drivers/dump/dump_overlay.c b/drivers/dump/dump_overlay.c
new file mode 100644 (file)
index 0000000..8e10b78
--- /dev/null
@@ -0,0 +1,884 @@
+/*
+ * Two-stage soft-boot based dump scheme methods (memory overlay
+ * with post soft-boot writeout)
+ *
+ * Started: Oct 2002 -  Suparna Bhattacharya <suparna@in.ibm.com>
+ *
+ * This approach of saving the dump in memory and writing it 
+ * out after a softboot without clearing memory is derived from the 
+ * Mission Critical Linux dump implementation. Credits and a big
+ * thanks for letting the lkcd project make use of the excellent 
+ * piece of work and also for helping with clarifications and 
+ * tips along the way are due to:
+ *     Dave Winchell <winchell@mclx.com> (primary author of mcore)
+ *     and also to
+ *     Jeff Moyer <moyer@mclx.com>
+ *     Josh Huber <huber@mclx.com>
+ * 
+ * For those familiar with the mcore implementation, the key 
+ * differences/extensions here are in allowing entire memory to be 
+ * saved (in compressed form) through a careful ordering scheme 
+ * on both the way down as well on the way up after boot, the latter
+ * for supporting the LKCD notion of passes in which most critical 
+ * data is the first to be saved to the dump device. Also the post 
+ * boot writeout happens from within the kernel rather than driven 
+ * from userspace.
+ *
+ * The sequence is orchestrated through the abstraction of "dumpers",
+ * one for the first stage which then sets up the dumper for the next 
+ * stage, providing for a smooth and flexible reuse of the singlestage 
+ * dump scheme methods and a handle to pass dump device configuration 
+ * information across the soft boot. 
+ *
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/*
+ * Disruptive dumping using the second kernel soft-boot option
+ * for issuing dump i/o operates in 2 stages:
+ * 
+ * (1) - Saves the (compressed & formatted) dump in memory using a 
+ *       carefully ordered overlay scheme designed to capture the 
+ *       entire physical memory or selective portions depending on 
+ *       dump config settings, 
+ *     - Registers the stage 2 dumper and 
+ *     - Issues a soft reboot w/o clearing memory. 
+ *
+ *     The overlay scheme starts with a small bootstrap free area
+ *     and follows a reverse ordering of passes wherein it 
+ *     compresses and saves data starting with the least critical 
+ *     areas first, thus freeing up the corresponding pages to 
+ *     serve as destination for subsequent data to be saved, and
+ *     so on. With a good compression ratio, this makes it feasible
+ *     to capture an entire physical memory dump without significantly
+ *     reducing memory available during regular operation.
+ *
+ * (2) Post soft-reboot, runs through the saved memory dump and
+ *     writes it out to disk, this time around, taking care to
+ *     save the more critical data first (i.e. pages which figure 
+ *     in early passes for a regular dump). Finally issues a 
+ *     clean reboot.
+ *     
+ *     Since the data was saved in memory after selection/filtering
+ *     and formatted as per the chosen output dump format, at this 
+ *     stage the filter and format actions are just dummy (or
+ *     passthrough) actions, except for influence on ordering of
+ *     passes.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/highmem.h>
+#include <linux/bootmem.h>
+#include <linux/dump.h>
+#ifdef CONFIG_KEXEC
+#include <linux/delay.h>
+#include <linux/reboot.h>
+#include <linux/kexec.h>
+#endif
+#include "dump_methods.h"
+
+extern struct list_head dumper_list_head;
+extern struct dump_memdev *dump_memdev;
+extern struct dumper dumper_stage2;
+struct dump_config_block *dump_saved_config = NULL;
+extern struct dump_blockdev *dump_blockdev;
+static struct dump_memdev *saved_dump_memdev = NULL;
+static struct dumper *saved_dumper = NULL;
+
+#ifdef CONFIG_KEXEC
+extern int panic_timeout;
+#endif
+
+/* For testing 
+extern void dump_display_map(struct dump_memdev *);
+*/
+
+struct dumper *dumper_by_name(char *name)
+{
+#ifdef LATER
+       struct dumper *dumper;
+       list_for_each_entry(dumper, &dumper_list_head, dumper_list)
+               if (!strncmp(dumper->name, name, 32))
+                       return dumper;
+
+       /* not found */
+       return NULL; 
+#endif
+       /* Temporary proof of concept */
+       if (!strncmp(dumper_stage2.name, name, 32))
+               return &dumper_stage2;
+       else
+               return NULL;
+}
+
+#ifdef CONFIG_CRASH_DUMP_SOFTBOOT
+extern void dump_early_reserve_map(struct dump_memdev *);
+
+void crashdump_reserve(void)
+{
+       extern unsigned long crashdump_addr;
+
+       if (crashdump_addr == 0xdeadbeef) 
+               return;
+
+       /* reserve dump config and saved dump pages */
+       dump_saved_config = (struct dump_config_block *)crashdump_addr;
+       /* magic verification */
+       if (dump_saved_config->magic != DUMP_MAGIC_LIVE) {
+               printk("Invalid dump magic. Ignoring dump\n");
+               dump_saved_config = NULL;
+               return;
+       }
+                       
+       printk("Dump may be available from previous boot\n");
+
+       reserve_bootmem(virt_to_phys((void *)crashdump_addr), 
+               PAGE_ALIGN(sizeof(struct dump_config_block)));
+       dump_early_reserve_map(&dump_saved_config->memdev);
+
+}
+#endif
+
+/* 
+ * Loads the dump configuration from a memory block saved across soft-boot
+ * The ops vectors need fixing up as the corresp. routines may have 
+ * relocated in the new soft-booted kernel.
+ */
+int dump_load_config(struct dump_config_block *config)
+{
+       struct dumper *dumper;
+       struct dump_data_filter *filter_table, *filter;
+       struct dump_dev *dev;
+       int i;
+
+       if (config->magic != DUMP_MAGIC_LIVE)
+               return -ENOENT; /* not a valid config */
+
+       /* initialize generic config data */
+       memcpy(&dump_config, &config->config, sizeof(dump_config));
+
+       /* initialize dumper state */
+       if (!(dumper = dumper_by_name(config->dumper.name)))  {
+               printk("dumper name mismatch\n");
+               return -ENOENT; /* dumper mismatch */
+       }
+       
+       /* verify and fixup schema */
+       if (strncmp(dumper->scheme->name, config->scheme.name, 32)) {
+               printk("dumper scheme mismatch\n");
+               return -ENOENT; /* mismatch */
+       }
+       config->scheme.ops = dumper->scheme->ops;
+       config->dumper.scheme = &config->scheme;
+       
+       /* verify and fixup filter operations */
+       filter_table = dumper->filter;
+       for (i = 0, filter = config->filter_table; 
+               ((i < MAX_PASSES) && filter_table[i].selector); 
+               i++, filter++) {
+               if (strncmp(filter_table[i].name, filter->name, 32)) {
+                       printk("dump filter mismatch\n");
+                       return -ENOENT; /* filter name mismatch */
+               }
+               filter->selector = filter_table[i].selector;
+       }
+       config->dumper.filter = config->filter_table;
+
+       /* fixup format */
+       if (strncmp(dumper->fmt->name, config->fmt.name, 32)) {
+               printk("dump format mismatch\n");
+               return -ENOENT; /* mismatch */
+       }
+       config->fmt.ops = dumper->fmt->ops;
+       config->dumper.fmt = &config->fmt;
+
+       /* fixup target device */
+       dev = (struct dump_dev *)(&config->dev[0]);
+       if (dumper->dev == NULL) {
+               pr_debug("Vanilla dumper - assume default\n");
+               if (dump_dev == NULL)
+                       return -ENODEV;
+               dumper->dev = dump_dev;
+       }
+
+       if (strncmp(dumper->dev->type_name, dev->type_name, 32)) { 
+               printk("dump dev type mismatch %s instead of %s\n",
+                               dev->type_name, dumper->dev->type_name);
+               return -ENOENT; /* mismatch */
+       }
+       dev->ops = dumper->dev->ops; 
+       config->dumper.dev = dev;
+       
+       /* fixup memory device containing saved dump pages */
+       /* assume statically init'ed dump_memdev */
+       config->memdev.ddev.ops = dump_memdev->ddev.ops; 
+       /* switch to memdev from prev boot */
+       saved_dump_memdev = dump_memdev; /* remember current */
+       dump_memdev = &config->memdev;
+
+       /* Make this the current primary dumper */
+       dump_config.dumper = &config->dumper;
+
+       return 0;
+}
+
+/* Saves the dump configuration in a memory block for use across a soft-boot */
+int dump_save_config(struct dump_config_block *config)
+{
+       printk("saving dump config settings\n");
+
+       /* dump config settings */
+       memcpy(&config->config, &dump_config, sizeof(dump_config));
+
+       /* dumper state */
+       memcpy(&config->dumper, dump_config.dumper, sizeof(struct dumper));
+       memcpy(&config->scheme, dump_config.dumper->scheme, 
+               sizeof(struct dump_scheme));
+       memcpy(&config->fmt, dump_config.dumper->fmt, sizeof(struct dump_fmt));
+       memcpy(&config->dev[0], dump_config.dumper->dev, 
+               sizeof(struct dump_anydev));
+       memcpy(&config->filter_table, dump_config.dumper->filter, 
+               sizeof(struct dump_data_filter)*MAX_PASSES);
+
+       /* handle to saved mem pages */
+       memcpy(&config->memdev, dump_memdev, sizeof(struct dump_memdev));
+
+       config->magic = DUMP_MAGIC_LIVE;
+       
+       return 0;
+}
+
+int dump_init_stage2(struct dump_config_block *saved_config)
+{
+       int err = 0;
+
+       pr_debug("dump_init_stage2\n");
+       /* Check if dump from previous boot exists */
+       if (saved_config) {
+               printk("loading dumper from previous boot \n");
+               /* load and configure dumper from previous boot */
+               if ((err = dump_load_config(saved_config)))
+                       return err;
+
+               if (!dump_oncpu) {
+                       if ((err = dump_configure(dump_config.dump_device))) {
+                               printk("Stage 2 dump configure failed\n");
+                               return err;
+                       }
+               }
+
+               dumper_reset();
+               dump_dev = dump_config.dumper->dev;
+               /* write out the dump */
+               err = dump_generic_execute(NULL, NULL);
+               
+               dump_saved_config = NULL;
+
+               if (!dump_oncpu) {
+                       dump_unconfigure(); 
+               }
+               
+               return err;
+
+       } else {
+               /* no dump to write out */
+               printk("no dumper from previous boot \n");
+               return 0;
+       }
+}
+
+extern void dump_mem_markpages(struct dump_memdev *);
+
+int dump_switchover_stage(void)
+{
+       int ret = 0;
+
+       /* trigger stage 2 rightaway - in real life would be after soft-boot */
+       /* dump_saved_config would be a boot param */
+       saved_dump_memdev = dump_memdev;
+       saved_dumper = dump_config.dumper;
+       ret = dump_init_stage2(dump_saved_config);
+       dump_memdev = saved_dump_memdev;
+       dump_config.dumper = saved_dumper;
+       return ret;
+}
+
+int dump_activate_softboot(void) 
+{
+        int err = 0;
+#ifdef CONFIG_KEXEC
+        int num_cpus_online = 0;
+        struct kimage *image;
+#endif
+
+        /* temporary - switchover to writeout previously saved dump */
+#ifndef CONFIG_KEXEC
+        err = dump_switchover_stage(); /* non-disruptive case */
+        if (dump_oncpu)
+                       dump_config.dumper = &dumper_stage1; /* set things back */
+
+        return err;
+#else
+
+        dump_silence_level = DUMP_HALT_CPUS;
+        /* wait till we become the only cpu */
+        /* maybe by checking for online cpus ? */
+
+        while((num_cpus_online = num_online_cpus()) > 1);
+
+        /* now call into kexec */
+
+        image = xchg(&kexec_image, 0);
+        if (image) {
+                       mdelay(panic_timeout*1000);
+                               machine_kexec(image);
+                               }
+
+
+        /* TBD/Fixme:
+        *          * should we call reboot notifiers ? inappropriate for panic ?
+        *                   * what about device_shutdown() ?
+        *                            * is explicit bus master disabling needed or can we do that
+        *                                     * through driverfs ?
+        *                                              */
+        return 0;
+#endif
+}
+
+/* --- DUMP SCHEME ROUTINES  --- */
+
+static inline int dump_buf_pending(struct dumper *dumper)
+{
+       return (dumper->curr_buf - dumper->dump_buf);
+}
+
+/* Invoked during stage 1 of soft-reboot based dumping */
+int dump_overlay_sequencer(void)
+{
+       struct dump_data_filter *filter = dump_config.dumper->filter;
+       struct dump_data_filter *filter2 = dumper_stage2.filter;
+       int pass = 0, err = 0, save = 0;
+       int (*action)(unsigned long, unsigned long);
+
+       /* Make sure gzip compression is being used */
+       if (dump_config.dumper->compress->compress_type != DUMP_COMPRESS_GZIP) {
+               printk(" Please set GZIP compression \n");
+               return -EINVAL;
+       }
+
+       /* start filling in dump data right after the header */
+       dump_config.dumper->curr_offset = 
+               PAGE_ALIGN(dump_config.dumper->header_len);
+
+       /* Locate the last pass */
+       for (;filter->selector; filter++, pass++);
+       
+       /* 
+        * Start from the end backwards: overlay involves a reverse 
+        * ordering of passes, since less critical pages are more
+        * likely to be reusable as scratch space once we are through
+        * with them. 
+        */
+       for (--pass, --filter; pass >= 0; pass--, filter--)
+       {
+               /* Assumes passes are exclusive (even across dumpers) */
+               /* Requires care when coding the selection functions */
+               if ((save = filter->level_mask & dump_config.level))
+                       action = dump_save_data;
+               else
+                       action = dump_skip_data;
+
+               /* Remember the offset where this pass started */
+               /* The second stage dumper would use this */
+               if (dump_buf_pending(dump_config.dumper) & (PAGE_SIZE - 1)) {
+                       pr_debug("Starting pass %d with pending data\n", pass);
+                       pr_debug("filling dummy data to page-align it\n");
+                       dump_config.dumper->curr_buf = (void *)PAGE_ALIGN(
+                               (unsigned long)dump_config.dumper->curr_buf);
+               }
+               
+               filter2[pass].start[0] = dump_config.dumper->curr_offset
+                       + dump_buf_pending(dump_config.dumper);
+
+               err = dump_iterator(pass, action, filter);
+
+               filter2[pass].end[0] = dump_config.dumper->curr_offset
+                       + dump_buf_pending(dump_config.dumper);
+               filter2[pass].num_mbanks = 1;
+
+               if (err < 0) {
+                       printk("dump_overlay_seq: failure %d in pass %d\n", 
+                               err, pass);
+                       break;
+               }       
+               printk("\n %d overlay pages %s of %d each in pass %d\n", 
+               err, save ? "saved" : "skipped", DUMP_PAGE_SIZE, pass);
+       }
+
+       return err;
+}
+
+/* from dump_memdev.c */
+extern struct page *dump_mem_lookup(struct dump_memdev *dev, unsigned long loc);
+extern struct page *dump_mem_next_page(struct dump_memdev *dev);
+
+static inline struct page *dump_get_saved_page(loff_t loc)
+{
+       return (dump_mem_lookup(dump_memdev, loc >> PAGE_SHIFT));
+}
+
+static inline struct page *dump_next_saved_page(void)
+{
+       return (dump_mem_next_page(dump_memdev));
+}
+
+/* 
+ * Iterates over list of saved dump pages. Invoked during second stage of 
+ * soft boot dumping
+ *
+ * Observation: If additional selection is desired at this stage then
+ * a different iterator could be written which would advance 
+ * to the next page header everytime instead of blindly picking up
+ * the data. In such a case loc would be interpreted differently. 
+ * At this moment however a blind pass seems sufficient, cleaner and
+ * faster.
+ */
+int dump_saved_data_iterator(int pass, int (*action)(unsigned long, 
+       unsigned long), struct dump_data_filter *filter)
+{
+       loff_t loc, end;
+       struct page *page;
+       unsigned long count = 0;
+       int i, err = 0;
+       unsigned long sz;
+
+       for (i = 0; i < filter->num_mbanks; i++) {
+               loc  = filter->start[i];
+               end = filter->end[i];
+               printk("pass %d, start off 0x%llx end offset 0x%llx\n", pass,
+                       loc, end);
+
+               /* loc will get treated as logical offset into stage 1 */
+               page = dump_get_saved_page(loc);
+                       
+               for (; loc < end; loc += PAGE_SIZE) {
+                       dump_config.dumper->curr_loc = loc;
+                       if (!page) {
+                               printk("no more saved data for pass %d\n", 
+                                       pass);
+                               break;
+                       }
+                       sz = (loc + PAGE_SIZE > end) ? end - loc : PAGE_SIZE;
+
+                       if (page && filter->selector(pass, (unsigned long)page, 
+                               PAGE_SIZE))  {
+                               pr_debug("mem offset 0x%llx\n", loc);
+                               if ((err = action((unsigned long)page, sz))) 
+                                       break;
+                               else
+                                       count++;
+                               /* clear the contents of page */
+                               /* fixme: consider using KM_DUMP instead */
+                               clear_highpage(page);
+                       
+                       }
+                       page = dump_next_saved_page();
+               }
+       }
+
+       return err ? err : count;
+}
+
+static inline int dump_overlay_pages_done(struct page *page, int nr)
+{
+       int ret=0;
+
+       for (; nr ; page++, nr--) {
+               if (dump_check_and_free_page(dump_memdev, page))
+                       ret++;
+       }
+       return ret;
+}
+
+int dump_overlay_save_data(unsigned long loc, unsigned long len)
+{
+       int err = 0;
+       struct page *page = (struct page *)loc;
+       static unsigned long cnt = 0;
+
+       if ((err = dump_generic_save_data(loc, len)))
+               return err;
+
+       if (dump_overlay_pages_done(page, len >> PAGE_SHIFT)) {
+               cnt++;
+               if (!(cnt & 0x7f))
+                       pr_debug("released page 0x%lx\n", page_to_pfn(page));
+       }
+       
+       return err;
+}
+
+
+int dump_overlay_skip_data(unsigned long loc, unsigned long len)
+{
+       struct page *page = (struct page *)loc;
+
+       dump_overlay_pages_done(page, len >> PAGE_SHIFT);
+       return 0;
+}
+
+int dump_overlay_resume(void)
+{
+       int err = 0;
+
+       /* 
+        * switch to stage 2 dumper, save dump_config_block
+        * and then trigger a soft-boot
+        */
+       dumper_stage2.header_len = dump_config.dumper->header_len;
+       dump_config.dumper = &dumper_stage2;
+       if ((err = dump_save_config(dump_saved_config)))
+               return err;
+
+       dump_dev = dump_config.dumper->dev;
+
+#ifdef CONFIG_KEXEC
+        /* If we are doing a disruptive dump, activate softboot now */
+        if((panic_timeout > 0) && (!(dump_config.flags & DUMP_FLAGS_NONDISRUPT)))
+        err = dump_activate_softboot();
+#endif
+               
+       return err;
+       err = dump_switchover_stage();  /* plugs into soft boot mechanism */
+       dump_config.dumper = &dumper_stage1; /* set things back */
+       return err;
+}
+
+int dump_overlay_configure(unsigned long devid)
+{
+       struct dump_dev *dev;
+       struct dump_config_block *saved_config = dump_saved_config;
+       int err = 0;
+
+       /* If there is a previously saved dump, write it out first */
+       if (saved_config) {
+               printk("Processing old dump pending writeout\n");
+               err = dump_switchover_stage();
+               if (err) {
+                       printk("failed to writeout saved dump\n");
+                       return err;
+               }
+               dump_free_mem(saved_config); /* testing only: not after boot */
+       }
+
+       dev = dumper_stage2.dev = dump_config.dumper->dev;
+       /* From here on the intermediate dump target is memory-only */
+       dump_dev = dump_config.dumper->dev = &dump_memdev->ddev;
+       if ((err = dump_generic_configure(0))) {
+               printk("dump generic configure failed: err %d\n", err);
+               return err;
+       }
+       /* temporary */
+       dumper_stage2.dump_buf = dump_config.dumper->dump_buf;
+
+       /* Sanity check on the actual target dump device */
+       if (!dev || (err = dev->ops->open(dev, devid))) {
+               return err;
+       }
+       /* TBD: should we release the target if this is soft-boot only ? */
+
+       /* alloc a dump config block area to save across reboot */
+       if (!(dump_saved_config = dump_alloc_mem(sizeof(struct 
+               dump_config_block)))) {
+               printk("dump config block alloc failed\n");
+               /* undo configure */
+               dump_generic_unconfigure();
+               return -ENOMEM;
+       }
+       dump_config.dump_addr = (unsigned long)dump_saved_config;
+       printk("Dump config block of size %d set up at 0x%lx\n", 
+               sizeof(*dump_saved_config), (unsigned long)dump_saved_config);
+       return 0;
+}
+
+int dump_overlay_unconfigure(void)
+{
+       struct dump_dev *dev = dumper_stage2.dev;
+       int err = 0;
+
+       pr_debug("dump_overlay_unconfigure\n");
+       /* Close the secondary device */
+       dev->ops->release(dev); 
+       pr_debug("released secondary device\n");
+
+       err = dump_generic_unconfigure();
+       pr_debug("Unconfigured generic portions\n");
+       dump_free_mem(dump_saved_config);
+       dump_saved_config = NULL;
+       pr_debug("Freed saved config block\n");
+       dump_dev = dump_config.dumper->dev = dumper_stage2.dev;
+
+       printk("Unconfigured overlay dumper\n");
+       return err;
+}
+
+int dump_staged_unconfigure(void)
+{
+       int err = 0;
+       struct dump_config_block *saved_config = dump_saved_config;
+       struct dump_dev *dev;
+
+       pr_debug("dump_staged_unconfigure\n");
+       err = dump_generic_unconfigure();
+
+       /* now check if there is a saved dump waiting to be written out */
+       if (saved_config) {
+               printk("Processing saved dump pending writeout\n");
+               if ((err = dump_switchover_stage())) {
+                       printk("Error in commiting saved dump at 0x%lx\n", 
+                               (unsigned long)saved_config);
+                       printk("Old dump may hog memory\n");
+               } else {
+                       dump_free_mem(saved_config);
+                       pr_debug("Freed saved config block\n");
+               }
+               dump_saved_config = NULL;
+       } else {
+               dev = &dump_memdev->ddev;
+               dev->ops->release(dev);
+       }
+       printk("Unconfigured second stage dumper\n");
+
+       return 0;
+}
+
+/* ----- PASSTHRU FILTER ROUTINE --------- */
+
+/* transparent - passes everything through */
+int dump_passthru_filter(int pass, unsigned long loc, unsigned long sz)
+{
+       return 1;
+}
+
+/* ----- PASSTRU FORMAT ROUTINES ---- */
+
+
+int dump_passthru_configure_header(const char *panic_str, const struct pt_regs *regs)
+{
+       dump_config.dumper->header_dirty++;
+       return 0;
+}
+
+/* Copies bytes of data from page(s) to the specified buffer */
+int dump_copy_pages(void *buf, struct page *page, unsigned long sz)
+{
+       unsigned long len = 0, bytes;
+       void *addr;
+
+       while (len < sz) {
+               addr = kmap_atomic(page, KM_DUMP);
+               bytes = (sz > len + PAGE_SIZE) ? PAGE_SIZE : sz - len;  
+               memcpy(buf, addr, bytes); 
+               kunmap_atomic(addr, KM_DUMP);
+               buf += bytes;
+               len += bytes;
+               page++;
+       }
+       /* memset(dump_config.dumper->curr_buf, 0x57, len); temporary */
+
+       return sz - len;
+}
+
+int dump_passthru_update_header(void)
+{
+       long len = dump_config.dumper->header_len;
+       struct page *page;
+       void *buf = dump_config.dumper->dump_buf;
+       int err = 0;
+
+       if (!dump_config.dumper->header_dirty)
+               return 0;
+
+       pr_debug("Copying header of size %ld bytes from memory\n", len);
+       if (len > DUMP_BUFFER_SIZE) 
+               return -E2BIG;
+
+       page = dump_mem_lookup(dump_memdev, 0);
+       for (; (len > 0) && page; buf += PAGE_SIZE, len -= PAGE_SIZE) {
+               if ((err = dump_copy_pages(buf, page, PAGE_SIZE)))
+                       return err;
+               page = dump_mem_next_page(dump_memdev);
+       }
+       if (len > 0) {
+               printk("Incomplete header saved in mem\n");
+               return -ENOENT;
+       }
+
+       if ((err = dump_dev_seek(0))) {
+               printk("Unable to seek to dump header offset\n");
+               return err;
+       }
+       err = dump_ll_write(dump_config.dumper->dump_buf, 
+               buf - dump_config.dumper->dump_buf);
+       if (err < dump_config.dumper->header_len)
+               return (err < 0) ? err : -ENOSPC;
+
+       dump_config.dumper->header_dirty = 0;
+       return 0;
+}
+
+static loff_t next_dph_offset = 0;
+
+static int dph_valid(struct __dump_page *dph)
+{
+       if ((dph->dp_address & (PAGE_SIZE - 1)) || (dph->dp_flags 
+             > DUMP_DH_COMPRESSED) || (!dph->dp_flags) ||
+               (dph->dp_size > PAGE_SIZE)) {
+       printk("dp->address = 0x%llx, dp->size = 0x%x, dp->flag = 0x%x\n",
+               dph->dp_address, dph->dp_size, dph->dp_flags);
+               return 0;
+       }
+       return 1;
+}
+
+int dump_verify_lcrash_data(void *buf, unsigned long sz)
+{
+       struct __dump_page *dph;
+
+       /* sanity check for page headers */
+       while (next_dph_offset + sizeof(*dph) < sz) {
+               dph = (struct __dump_page *)(buf + next_dph_offset);
+               if (!dph_valid(dph)) {
+                       printk("Invalid page hdr at offset 0x%llx\n",
+                               next_dph_offset);
+                       return -EINVAL;
+               }
+               next_dph_offset += dph->dp_size + sizeof(*dph);
+       }
+
+       next_dph_offset -= sz;  
+       return 0;
+}
+
+/* 
+ * TBD/Later: Consider avoiding the copy by using a scatter/gather 
+ * vector representation for the dump buffer
+ */
+int dump_passthru_add_data(unsigned long loc, unsigned long sz)
+{
+       struct page *page = (struct page *)loc;
+       void *buf = dump_config.dumper->curr_buf;
+       int err = 0;
+
+       if ((err = dump_copy_pages(buf, page, sz))) {
+               printk("dump_copy_pages failed");
+               return err;
+       }
+
+       if ((err = dump_verify_lcrash_data(buf, sz))) {
+               printk("dump_verify_lcrash_data failed\n");
+               printk("Invalid data for pfn 0x%lx\n", page_to_pfn(page));
+               printk("Page flags 0x%lx\n", page->flags);
+               printk("Page count 0x%x\n", atomic_read(&page->count));
+               return err;
+       }
+
+       dump_config.dumper->curr_buf = buf + sz;
+
+       return 0;
+}
+
+
+/* Stage 1 dumper: Saves compressed dump in memory and soft-boots system */
+
+/* Scheme to overlay saved data in memory for writeout after a soft-boot */
+struct dump_scheme_ops dump_scheme_overlay_ops = {
+       .configure      = dump_overlay_configure,
+       .unconfigure    = dump_overlay_unconfigure,
+       .sequencer      = dump_overlay_sequencer,
+       .iterator       = dump_page_iterator,
+       .save_data      = dump_overlay_save_data,
+       .skip_data      = dump_overlay_skip_data,
+       .write_buffer   = dump_generic_write_buffer
+};
+
+struct dump_scheme dump_scheme_overlay = {
+       .name           = "overlay",
+       .ops            = &dump_scheme_overlay_ops
+};
+
+
+/* Stage 1 must use a good compression scheme - default to gzip */
+extern struct __dump_compress dump_gzip_compression;
+
+struct dumper dumper_stage1 = {
+       .name           = "stage1",
+       .scheme         = &dump_scheme_overlay,
+       .fmt            = &dump_fmt_lcrash,
+       .compress       = &dump_none_compression, /* needs to be gzip */
+       .filter         = dump_filter_table,
+       .dev            = NULL,
+};             
+
+/* Stage 2 dumper: Activated after softboot to write out saved dump to device */
+
+/* Formatter that transfers data as is (transparent) w/o further conversion */
+struct dump_fmt_ops dump_fmt_passthru_ops = {
+       .configure_header       = dump_passthru_configure_header,
+       .update_header          = dump_passthru_update_header,
+       .save_context           = NULL, /* unused */
+       .add_data               = dump_passthru_add_data,
+       .update_end_marker      = dump_lcrash_update_end_marker
+};
+
+struct dump_fmt dump_fmt_passthru = {
+       .name   = "passthru",
+       .ops    = &dump_fmt_passthru_ops
+};
+
+/* Filter that simply passes along any data within the range (transparent)*/
+/* Note: The start and end ranges in the table are filled in at run-time */
+
+extern int dump_filter_none(int pass, unsigned long loc, unsigned long sz);
+
+struct dump_data_filter dump_passthru_filtertable[MAX_PASSES] = {
+{.name = "passkern", .selector = dump_passthru_filter, 
+       .level_mask = DUMP_MASK_KERN },
+{.name = "passuser", .selector = dump_passthru_filter, 
+       .level_mask = DUMP_MASK_USED },
+{.name = "passunused", .selector = dump_passthru_filter, 
+       .level_mask = DUMP_MASK_UNUSED },
+{.name = "none", .selector = dump_filter_none, 
+       .level_mask = DUMP_MASK_REST }
+};
+
+
+/* Scheme to handle data staged / preserved across a soft-boot */
+struct dump_scheme_ops dump_scheme_staged_ops = {
+       .configure      = dump_generic_configure,
+       .unconfigure    = dump_staged_unconfigure,
+       .sequencer      = dump_generic_sequencer,
+       .iterator       = dump_saved_data_iterator,
+       .save_data      = dump_generic_save_data,
+       .skip_data      = dump_generic_skip_data,
+       .write_buffer   = dump_generic_write_buffer
+};
+
+struct dump_scheme dump_scheme_staged = {
+       .name           = "staged",
+       .ops            = &dump_scheme_staged_ops
+};
+
+/* The stage 2 dumper comprising all these */
+struct dumper dumper_stage2 = {
+       .name           = "stage2",
+       .scheme         = &dump_scheme_staged,
+       .fmt            = &dump_fmt_passthru,
+       .compress       = &dump_none_compression,
+       .filter         = dump_passthru_filtertable,
+       .dev            = NULL,
+};             
+
diff --git a/drivers/dump/dump_ppc64.c b/drivers/dump/dump_ppc64.c
new file mode 100644 (file)
index 0000000..7fa6d85
--- /dev/null
@@ -0,0 +1,436 @@
+/*
+ * Architecture specific (ppc64) functions for Linux crash dumps.
+ *
+ * Created by: Matt Robinson (yakker@sgi.com)
+ *
+ * Copyright 1999 Silicon Graphics, Inc. All rights reserved.
+ * 
+ * 2.3 kernel modifications by: Matt D. Robinson (yakker@turbolinux.com)
+ * Copyright 2000 TurboLinux, Inc.  All rights reserved.
+ * Copyright 2003, 2004 IBM Corporation
+ * 
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/*
+ * The hooks for dumping the kernel virtual memory to disk are in this
+ * file.  Any time a modification is made to the virtual memory mechanism,
+ * these routines must be changed to use the new mechanisms.
+ */
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/dump.h>
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+#include <linux/delay.h>
+#include <linux/syscalls.h> 
+#include <linux/ioctl32.h>
+#include <asm/hardirq.h>
+#include "dump_methods.h"
+#include <linux/irq.h>
+#include <asm/machdep.h>
+#include <asm/uaccess.h>
+#include <asm/irq.h>
+#include <asm/page.h>
+#if defined(CONFIG_KDB) && !defined(CONFIG_DUMP_MODULE)
+#include <linux/kdb.h>
+#endif
+
+extern cpumask_t irq_affinity[];
+
+static cpumask_t saved_affinity[NR_IRQS];
+
+static __s32         saved_irq_count;   /* saved preempt_count() flags */
+
+static int alloc_dha_stack(void)
+{
+        int i;
+        void *ptr;
+
+        if (dump_header_asm.dha_stack[0])
+                return 0;
+
+        ptr = (void *)vmalloc(THREAD_SIZE * num_online_cpus());
+        if (!ptr) {
+                return -ENOMEM;
+        }
+
+        for (i = 0; i < num_online_cpus(); i++) {
+                dump_header_asm.dha_stack[i] = 
+                       (uint64_t)((unsigned long)ptr + (i * THREAD_SIZE));
+       }
+       return 0;
+}
+
+static int free_dha_stack(void)
+{
+        if (dump_header_asm.dha_stack[0]) {
+                vfree((void*)dump_header_asm.dha_stack[0]);
+               dump_header_asm.dha_stack[0] = 0;
+       }
+        return 0;
+}
+#ifdef CONFIG_SMP
+static int dump_expect_ipi[NR_CPUS];
+static atomic_t waiting_for_dump_ipi;
+
+extern void stop_this_cpu(void *);
+static int
+dump_ipi_handler(struct pt_regs *regs) 
+{
+       int cpu = smp_processor_id();
+
+       if (!dump_expect_ipi[cpu])
+               return 0;
+       dump_save_this_cpu(regs);
+       atomic_dec(&waiting_for_dump_ipi);
+
+ level_changed:
+       switch (dump_silence_level) {
+       case DUMP_HARD_SPIN_CPUS:       /* Spin until dump is complete */
+               while (dump_oncpu) {
+                       barrier();      /* paranoia */
+                       if (dump_silence_level != DUMP_HARD_SPIN_CPUS)
+                               goto level_changed;
+                       cpu_relax();    /* kill time nicely */
+               }
+               break;
+
+       case DUMP_HALT_CPUS:            /* Execute halt */
+               stop_this_cpu(NULL);
+               break;
+       
+       case DUMP_SOFT_SPIN_CPUS:
+               /* Mark the task so it spins in schedule */
+               set_tsk_thread_flag(current, TIF_NEED_RESCHED);
+               break;
+       }
+
+       return 1;
+}
+
+/* save registers on other processors
+ * If the other cpus don't respond we simply do not get their states.
+ */
+void 
+__dump_save_other_cpus(void)
+{
+       int i, cpu = smp_processor_id();
+       int other_cpus = num_online_cpus()-1;
+       
+       if (other_cpus > 0) {
+               atomic_set(&waiting_for_dump_ipi, other_cpus);
+               for (i = 0; i < NR_CPUS; i++)
+                       dump_expect_ipi[i] = (i != cpu && cpu_online(i));
+
+               dump_send_ipi(dump_ipi_handler);
+               /*
+                * may be we dont need to wait for NMI to be processed.
+                * just write out the header at the end of dumping, if
+                * this IPI is not processed until then, there probably
+                * is a problem and we just fail to capture state of
+                * other cpus.
+                */
+               while (atomic_read(&waiting_for_dump_ipi) > 0) {
+                       cpu_relax();
+               }
+               dump_send_ipi(NULL);    /* clear handler */
+       }
+}
+
+/*
+ * Restore old irq affinities.
+ */
+static void
+__dump_reset_irq_affinity(void)
+{
+       int i;
+       irq_desc_t *irq_d;
+
+       memcpy(irq_affinity, saved_affinity, NR_IRQS * sizeof(unsigned long));
+
+       for_each_irq(i) {
+               irq_d = get_irq_desc(i);
+               if (irq_d->handler == NULL) {
+                       continue;
+               }
+               if (irq_d->handler->set_affinity != NULL) {
+                       irq_d->handler->set_affinity(i, saved_affinity[i]);
+               }
+       }
+}
+
+/*
+ * Routine to save the old irq affinities and change affinities of all irqs to
+ * the dumping cpu.
+ *
+ * NB: Need to be expanded to multiple nodes.
+ */
+static void
+__dump_set_irq_affinity(void)
+{
+       int i;
+       cpumask_t cpu = CPU_MASK_NONE;
+       irq_desc_t *irq_d;
+
+       cpu_set(smp_processor_id(), cpu);
+
+       memcpy(saved_affinity, irq_affinity, NR_IRQS * sizeof(unsigned long));
+
+       for_each_irq(i) {
+               irq_d = get_irq_desc(i);
+               if (irq_d->handler == NULL) {
+                       continue;
+               }
+               irq_affinity[i] = cpu;
+               if (irq_d->handler->set_affinity != NULL) {
+                       irq_d->handler->set_affinity(i, irq_affinity[i]);
+               }
+       }
+}
+#else /* !CONFIG_SMP */
+#define __dump_save_other_cpus() do { } while (0)
+#define __dump_set_irq_affinity()      do { } while (0)
+#define __dump_reset_irq_affinity()    do { } while (0)
+#endif /* !CONFIG_SMP */
+
+void
+__dump_save_regs(struct pt_regs *dest_regs, const struct pt_regs *regs)
+{
+       if (regs) {
+               memcpy(dest_regs, regs, sizeof(struct pt_regs));
+       } 
+}
+
+/*
+ * Name: __dump_configure_header()
+ * Func: Configure the dump header with all proper values.
+ */
+int
+__dump_configure_header(const struct pt_regs *regs)
+{
+       return (0);
+}
+
+#if defined(CONFIG_KDB) && !defined(CONFIG_DUMP_MODULE)
+int
+kdb_sysdump(int argc, const char **argv, const char **envp, struct pt_regs *regs)
+{
+       kdb_printf("Dumping to disk...\n");
+       dump("dump from kdb", regs);
+       kdb_printf("Dump Complete\n");
+       return 0;
+}
+#endif
+
+static int dw_long(unsigned int fd, unsigned int cmd, unsigned long arg,
+                  struct file *f)
+{
+       mm_segment_t old_fs = get_fs();
+       int err;
+       unsigned long val;
+
+       set_fs (KERNEL_DS);
+       err = sys_ioctl(fd, cmd, (unsigned long)&val);
+       set_fs (old_fs);
+       if (!err && put_user((unsigned int) val, (u32 *)arg))
+               return -EFAULT;
+       return err;
+}
+
+/*
+ * Name: __dump_init()
+ * Func: Initialize the dumping routine process.  This is in case
+ *       it's necessary in the future.
+ */
+void
+__dump_init(uint64_t local_memory_start)
+{
+       int ret;
+
+       ret = register_ioctl32_conversion(DIOSDUMPDEV, NULL);
+       ret |= register_ioctl32_conversion(DIOGDUMPDEV, NULL);
+       ret |= register_ioctl32_conversion(DIOSDUMPLEVEL, NULL);
+       ret |= register_ioctl32_conversion(DIOGDUMPLEVEL, dw_long);
+       ret |= register_ioctl32_conversion(DIOSDUMPFLAGS, NULL);
+       ret |= register_ioctl32_conversion(DIOGDUMPFLAGS, dw_long);
+       ret |= register_ioctl32_conversion(DIOSDUMPCOMPRESS, NULL);
+       ret |= register_ioctl32_conversion(DIOGDUMPCOMPRESS, dw_long);
+       ret |= register_ioctl32_conversion(DIOSTARGETIP, NULL);
+       ret |= register_ioctl32_conversion(DIOGTARGETIP, NULL);
+       ret |= register_ioctl32_conversion(DIOSTARGETPORT, NULL);
+       ret |= register_ioctl32_conversion(DIOGTARGETPORT, NULL);
+       ret |= register_ioctl32_conversion(DIOSSOURCEPORT, NULL);
+       ret |= register_ioctl32_conversion(DIOGSOURCEPORT, NULL);
+       ret |= register_ioctl32_conversion(DIOSETHADDR, NULL);
+       ret |= register_ioctl32_conversion(DIOGETHADDR, NULL);
+       ret |= register_ioctl32_conversion(DIOGDUMPOKAY, dw_long);
+       ret |= register_ioctl32_conversion(DIOSDUMPTAKE, NULL);
+       if (ret) {
+               printk(KERN_ERR "LKCD: registering ioctl32 translations failed\n");
+       }
+
+#if defined(FIXME) && defined(CONFIG_KDB) && !defined(CONFIG_DUMP_MODULE)
+       /* This won't currently work because interrupts are off in kdb
+        * and the dump process doesn't understand how to recover.
+        */
+       /* ToDo: add a command to query/set dump configuration */
+       kdb_register_repeat("sysdump", kdb_sysdump, "", "use lkcd to dump the system to disk (if configured)", 0, KDB_REPEAT_NONE);
+#endif
+
+       /* return */
+       return;
+}
+
+/*
+ * Name: __dump_open()
+ * Func: Open the dump device (architecture specific).  This is in
+ *       case it's necessary in the future.
+ */
+void
+__dump_open(void)
+{
+       alloc_dha_stack();
+}
+
+
+/*
+ * Name: __dump_cleanup()
+ * Func: Free any architecture specific data structures. This is called
+ *       when the dump module is being removed.
+ */
+void
+__dump_cleanup(void)
+{
+       int ret;
+
+       ret = unregister_ioctl32_conversion(DIOSDUMPDEV);
+       ret |= unregister_ioctl32_conversion(DIOGDUMPDEV);
+       ret |= unregister_ioctl32_conversion(DIOSDUMPLEVEL);
+       ret |= unregister_ioctl32_conversion(DIOGDUMPLEVEL);
+       ret |= unregister_ioctl32_conversion(DIOSDUMPFLAGS);
+       ret |= unregister_ioctl32_conversion(DIOGDUMPFLAGS);
+       ret |= unregister_ioctl32_conversion(DIOSDUMPCOMPRESS);
+       ret |= unregister_ioctl32_conversion(DIOGDUMPCOMPRESS);
+       ret |= unregister_ioctl32_conversion(DIOSTARGETIP);
+       ret |= unregister_ioctl32_conversion(DIOGTARGETIP);
+       ret |= unregister_ioctl32_conversion(DIOSTARGETPORT);
+       ret |= unregister_ioctl32_conversion(DIOGTARGETPORT);
+       ret |= unregister_ioctl32_conversion(DIOSSOURCEPORT);
+       ret |= unregister_ioctl32_conversion(DIOGSOURCEPORT);
+       ret |= unregister_ioctl32_conversion(DIOSETHADDR);
+       ret |= unregister_ioctl32_conversion(DIOGETHADDR);
+       ret |= unregister_ioctl32_conversion(DIOGDUMPOKAY);
+       ret |= unregister_ioctl32_conversion(DIOSDUMPTAKE);
+       if (ret) {
+               printk(KERN_ERR "LKCD: Unregistering ioctl32 translations failed\n");
+       }
+       free_dha_stack();
+}
+
+/*
+ * Kludge - dump from interrupt context is unreliable (Fixme)
+ *
+ * We do this so that softirqs initiated for dump i/o
+ * get processed and we don't hang while waiting for i/o
+ * to complete or in any irq synchronization attempt.
+ *
+ * This is not quite legal of course, as it has the side
+ * effect of making all interrupts & softirqs triggered
+ * while dump is in progress complete before currently
+ * pending softirqs and the currently executing interrupt
+ * code.
+ */
+static inline void
+irq_bh_save(void)
+{
+       saved_irq_count = irq_count();
+       preempt_count() &= ~(HARDIRQ_MASK|SOFTIRQ_MASK);
+}
+
+static inline void
+irq_bh_restore(void)
+{
+       preempt_count() |= saved_irq_count;
+}
+
+/*
+ * Name: __dump_irq_enable
+ * Func: Reset system so interrupts are enabled.
+ * This is used for dump methods that require interrupts
+ * Eventually, all methods will have interrupts disabled
+ * and this code can be removed.
+ *
+ * Change irq affinities
+ * Re-enable interrupts
+ */
+int
+__dump_irq_enable(void)
+{
+       __dump_set_irq_affinity();
+       irq_bh_save();
+       local_irq_enable();
+       return 0;
+}
+
+/*
+ * Name: __dump_irq_restore
+ * Func: Resume the system state in an architecture-specific way.
+ */
+void
+__dump_irq_restore(void)
+{
+       local_irq_disable();
+       __dump_reset_irq_affinity();
+       irq_bh_restore(); 
+}
+
+#if 0
+/* Cheap progress hack.  It estimates pages to write and
+ * assumes all pages will go -- so it may get way off.
+ * As the progress is not displayed for other architectures, not used at this 
+ * moment.
+ */
+void
+__dump_progress_add_page(void)
+{
+       unsigned long total_pages = nr_free_pages() + nr_inactive_pages + nr_active_pages;
+       unsigned int percent = (dump_header.dh_num_dump_pages * 100) / total_pages;
+       char buf[30];
+
+       if (percent > last_percent && percent <= 100) {
+               sprintf(buf, "Dump %3d%%     ", percent);
+               ppc64_dump_msg(0x2, buf);
+               last_percent = percent;
+       }
+
+}
+#endif
+
+extern int dump_page_is_ram(unsigned long);
+/*
+ * Name: __dump_page_valid()
+ * Func: Check if page is valid to dump.
+ */
+int
+__dump_page_valid(unsigned long index)
+{
+       if (!pfn_valid(index))
+               return 0;
+
+       return dump_page_is_ram(index);
+}
+
+/*
+ * Name: manual_handle_crashdump()
+ * Func: Interface for the lkcd dump command. Calls dump_execute()
+ */
+int
+manual_handle_crashdump(void)
+{
+       struct pt_regs regs;
+
+       get_current_regs(&regs);
+       dump_execute("manual", &regs);
+       return 0;
+}
diff --git a/drivers/dump/dump_rle.c b/drivers/dump/dump_rle.c
new file mode 100644 (file)
index 0000000..9d8c1bd
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * RLE Compression functions for kernel crash dumps.
+ *
+ * Created by: Matt Robinson (yakker@sourceforge.net)
+ * Copyright 2001 Matt D. Robinson.  All rights reserved.
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/* header files */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/fs.h>
+#include <linux/file.h>
+#include <linux/init.h>
+#include <linux/dump.h>
+
+/*
+ * Name: dump_compress_rle()
+ * Func: Compress a DUMP_PAGE_SIZE (hardware) page down to something more
+ *       reasonable, if possible.  This is the same routine we use in IRIX.
+ */
+static u16
+dump_compress_rle(const u8 *old, u16 oldsize, u8 *new, u16 newsize)
+{
+       u16 ri, wi, count = 0;
+       u_char value = 0, cur_byte;
+
+       /*
+        * If the block should happen to "compress" to larger than the
+        * buffer size, allocate a larger one and change cur_buf_size.
+        */
+
+       wi = ri = 0;
+
+       while (ri < oldsize) {
+               if (!ri) {
+                       cur_byte = value = old[ri];
+                       count = 0;
+               } else {
+                       if (count == 255) {
+                               if (wi + 3 > oldsize) {
+                                       return oldsize;
+                               }
+                               new[wi++] = 0;
+                               new[wi++] = count;
+                               new[wi++] = value;
+                               value = cur_byte = old[ri];
+                               count = 0;
+                       } else { 
+                               if ((cur_byte = old[ri]) == value) {
+                                       count++;
+                               } else {
+                                       if (count > 1) {
+                                               if (wi + 3 > oldsize) {
+                                                       return oldsize;
+                                               }
+                                               new[wi++] = 0;
+                                               new[wi++] = count;
+                                               new[wi++] = value;
+                                       } else if (count == 1) {
+                                               if (value == 0) {
+                                                       if (wi + 3 > oldsize) {
+                                                               return oldsize;
+                                                       }
+                                                       new[wi++] = 0;
+                                                       new[wi++] = 1;
+                                                       new[wi++] = 0;
+                                               } else {
+                                                       if (wi + 2 > oldsize) {
+                                                               return oldsize;
+                                                       }
+                                                       new[wi++] = value;
+                                                       new[wi++] = value;
+                                               }
+                                       } else { /* count == 0 */
+                                               if (value == 0) {
+                                                       if (wi + 2 > oldsize) {
+                                                               return oldsize;
+                                                       }
+                                                       new[wi++] = value;
+                                                       new[wi++] = value;
+                                               } else {
+                                                       if (wi + 1 > oldsize) {
+                                                               return oldsize;
+                                                       }
+                                                       new[wi++] = value;
+                                               }
+                                       } /* if count > 1 */
+
+                                       value = cur_byte;
+                                       count = 0;
+
+                               } /* if byte == value */
+
+                       } /* if count == 255 */
+
+               } /* if ri == 0 */
+               ri++;
+
+       }
+       if (count > 1) {
+               if (wi + 3 > oldsize) {
+                       return oldsize;
+               }
+               new[wi++] = 0;
+               new[wi++] = count;
+               new[wi++] = value;
+       } else if (count == 1) {
+               if (value == 0) {
+                       if (wi + 3 > oldsize)
+                               return oldsize;
+                       new[wi++] = 0;
+                       new[wi++] = 1;
+                       new[wi++] = 0;
+               } else {
+                       if (wi + 2 > oldsize)
+                               return oldsize;
+                       new[wi++] = value;
+                       new[wi++] = value;
+               }
+       } else { /* count == 0 */
+               if (value == 0) {
+                       if (wi + 2 > oldsize)
+                               return oldsize;
+                       new[wi++] = value;
+                       new[wi++] = value;
+               } else {
+                       if (wi + 1 > oldsize)
+                               return oldsize;
+                       new[wi++] = value;
+               }
+       } /* if count > 1 */
+
+       value = cur_byte;
+       count = 0;
+       return wi;
+}
+
+/* setup the rle compression functionality */
+static struct __dump_compress dump_rle_compression = {
+       .compress_type = DUMP_COMPRESS_RLE,
+       .compress_func = dump_compress_rle,
+       .compress_name = "RLE",
+};
+
+/*
+ * Name: dump_compress_rle_init()
+ * Func: Initialize rle compression for dumping.
+ */
+static int __init
+dump_compress_rle_init(void)
+{
+       dump_register_compression(&dump_rle_compression);
+       return 0;
+}
+
+/*
+ * Name: dump_compress_rle_cleanup()
+ * Func: Remove rle compression for dumping.
+ */
+static void __exit
+dump_compress_rle_cleanup(void)
+{
+       dump_unregister_compression(DUMP_COMPRESS_RLE);
+}
+
+/* module initialization */
+module_init(dump_compress_rle_init);
+module_exit(dump_compress_rle_cleanup);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("LKCD Development Team <lkcd-devel@lists.sourceforge.net>");
+MODULE_DESCRIPTION("RLE compression module for crash dump driver");
diff --git a/drivers/dump/dump_scheme.c b/drivers/dump/dump_scheme.c
new file mode 100644 (file)
index 0000000..de0ce78
--- /dev/null
@@ -0,0 +1,383 @@
+/* 
+ * Default single stage dump scheme methods
+ *
+ * Previously a part of dump_base.c
+ *
+ * Started: Oct 2002 -  Suparna Bhattacharya <suparna@in.ibm.com>
+ *     Split and rewrote LKCD dump scheme to generic dump method 
+ *     interfaces 
+ * Derived from original code created by
+ *     Matt Robinson <yakker@sourceforge.net>)
+ *
+ * Contributions from SGI, IBM, HP, MCL, and others.
+ *
+ * Copyright (C) 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/*
+ * Implements the default dump scheme, i.e. single-stage gathering and 
+ * saving of dump data directly to the target device, which operates in
+ * a push mode, where the dumping system decides what data it saves
+ * taking into account pre-specified dump config options.
+ *
+ * Aside: The 2-stage dump scheme, where there is a soft-reset between
+ * the gathering and saving phases, also reuses some of these
+ * default routines (see dump_overlay.c) 
+ */ 
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/reboot.h>
+#include <linux/nmi.h>
+#include <linux/dump.h>
+#include "dump_methods.h"
+
+extern int panic_timeout;  /* time before reboot */
+
+extern void dump_speedo(int);
+
+/* Default sequencer used during single stage dumping */
+/* Also invoked during stage 2 of soft-boot based dumping */
+int dump_generic_sequencer(void)
+{
+       struct dump_data_filter *filter = dump_config.dumper->filter;
+       int pass = 0, err = 0, save = 0;
+       int (*action)(unsigned long, unsigned long);
+
+       /* 
+        * We want to save the more critical data areas first in 
+        * case we run out of space, encounter i/o failures, or get
+        * interrupted otherwise and have to give up midway
+        * So, run through the passes in increasing order 
+        */
+       for (;filter->selector; filter++, pass++)
+       {
+               /* Assumes passes are exclusive (even across dumpers) */
+               /* Requires care when coding the selection functions */
+               if ((save = filter->level_mask & dump_config.level))
+                       action = dump_save_data;
+               else
+                       action = dump_skip_data;
+
+               if ((err = dump_iterator(pass, action, filter)) < 0)
+                       break;
+
+               printk("\n %d dump pages %s of %d each in pass %d\n", 
+               err, save ? "saved" : "skipped", DUMP_PAGE_SIZE, pass);
+
+       }
+
+       return (err < 0) ? err : 0;
+}
+
+static inline struct page *dump_get_page(loff_t loc)
+{
+
+       unsigned long page_index = loc >> PAGE_SHIFT;
+
+       /* todo: complete this  to account for ia64/discontig mem */
+       /* todo: and to check for validity, ram page, no i/o mem etc */
+       /* need to use pfn/physaddr equiv of kern_addr_valid */
+
+       /* Important:
+        *   On ARM/XScale system, the physical address starts from 
+        *   PHYS_OFFSET, and it maybe the situation that PHYS_OFFSET != 0. 
+        *   For example on Intel's PXA250, PHYS_OFFSET = 0xa0000000. And the 
+        *   page index starts from PHYS_PFN_OFFSET. When configuring
+        *   filter, filter->start is assigned to 0 in dump_generic_configure.
+        *   Here we want to adjust it by adding PHYS_PFN_OFFSET to it!
+        */
+#ifdef CONFIG_ARM
+       page_index += PHYS_PFN_OFFSET;
+#endif
+       if (__dump_page_valid(page_index))
+               return pfn_to_page(page_index);
+       else
+               return NULL;
+
+}
+
+/* Default iterator: for singlestage and stage 1 of soft-boot dumping */
+/* Iterates over range of physical memory pages in DUMP_PAGE_SIZE increments */
+int dump_page_iterator(int pass, int (*action)(unsigned long, unsigned long), 
+       struct dump_data_filter *filter)
+{
+       /* Todo : fix unit, type */
+       loff_t loc, start, end;
+       int i, count = 0, err = 0;
+       struct page *page;
+
+       /* Todo: Add membanks code */
+       /* TBD: Check if we need to address DUMP_PAGE_SIZE < PAGE_SIZE */       
+
+       for (i = 0; i < filter->num_mbanks; i++) {
+               start = filter->start[i];
+               end = filter->end[i];
+               for (loc = start; loc < end; loc += DUMP_PAGE_SIZE) {
+                       dump_config.dumper->curr_loc = loc;
+                       page = dump_get_page(loc);
+                       if (page && filter->selector(pass, 
+                               (unsigned long) page, DUMP_PAGE_SIZE)) { 
+                               if ((err = action((unsigned long)page, 
+                                       DUMP_PAGE_SIZE))) {
+                                       printk("dump_page_iterator: err %d for "
+                                               "loc 0x%llx, in pass %d\n", 
+                                               err, loc, pass);
+                                       return err ? err : count;
+                               } else
+                                       count++;
+                       }
+               }
+       }
+
+       return err ? err : count;
+}
+
+/* 
+ * Base function that saves the selected block of data in the dump 
+ * Action taken when iterator decides that data needs to be saved 
+ */
+int dump_generic_save_data(unsigned long loc, unsigned long sz)
+{
+       void *buf;
+       void *dump_buf = dump_config.dumper->dump_buf;
+       int left, bytes, ret;
+
+       if ((ret = dump_add_data(loc, sz))) {
+               return ret;
+       }
+       buf = dump_config.dumper->curr_buf;
+
+       /* If we've filled up the buffer write it out */
+       if ((left = buf - dump_buf) >= DUMP_BUFFER_SIZE) {
+               bytes = dump_write_buffer(dump_buf, DUMP_BUFFER_SIZE);
+               if (bytes < DUMP_BUFFER_SIZE) {
+                       printk("dump_write_buffer failed %d\n", bytes);
+                       return bytes ? -ENOSPC : bytes;
+               }
+
+               left -= bytes;
+               
+               /* -- A few chores to do from time to time -- */
+               dump_config.dumper->count++;
+
+               if (!(dump_config.dumper->count & 0x3f)) {
+                       /* Update the header every one in a while */
+                       memset((void *)dump_buf, 'b', DUMP_BUFFER_SIZE);
+                       if ((ret = dump_update_header()) < 0) {
+                               /* issue warning */
+                               return ret;
+                       }
+                       printk(".");
+
+                       touch_nmi_watchdog();
+               } else if (!(dump_config.dumper->count & 0x7)) {
+                       /* Show progress so the user knows we aren't hung */
+                       dump_speedo(dump_config.dumper->count >> 3); 
+               }
+               /* Todo: Touch/Refresh watchdog */
+
+               /* --- Done with periodic chores -- */
+
+               /* 
+                * extra bit of copying to simplify verification  
+                * in the second kernel boot based scheme
+                */
+               memcpy(dump_buf - DUMP_PAGE_SIZE, dump_buf + 
+                       DUMP_BUFFER_SIZE - DUMP_PAGE_SIZE, DUMP_PAGE_SIZE);
+
+               /* now adjust the leftover bits back to the top of the page */
+               /* this case would not arise during stage 2 (passthru) */
+               memset(dump_buf, 'z', DUMP_BUFFER_SIZE);
+               if (left) {
+                       memcpy(dump_buf, dump_buf + DUMP_BUFFER_SIZE, left);
+               }
+               buf -= DUMP_BUFFER_SIZE;
+               dump_config.dumper->curr_buf = buf;
+       }
+                               
+       return 0;
+}
+
+int dump_generic_skip_data(unsigned long loc, unsigned long sz)
+{
+       /* dummy by default */
+       return 0;
+}
+
+/* 
+ * Common low level routine to write a buffer to current dump device 
+ * Expects checks for space etc to have been taken care of by the caller 
+ * Operates serially at the moment for simplicity. 
+ * TBD/Todo: Consider batching for improved throughput
+ */
+int dump_ll_write(void *buf, unsigned long len)
+{
+       long transferred = 0, last_transfer = 0;
+       int ret = 0;
+
+       /* make sure device is ready */
+       while ((ret = dump_dev_ready(NULL)) == -EAGAIN);
+       if  (ret < 0) {
+               printk("dump_dev_ready failed !err %d\n", ret);
+               return ret;
+       }
+
+       while (len) {
+               if ((last_transfer = dump_dev_write(buf, len)) <= 0)  {
+                       ret = last_transfer;
+                       printk("dump_dev_write failed !err %d\n", 
+                       ret);
+                       break;
+               }
+               /* wait till complete */
+               while ((ret = dump_dev_ready(buf)) == -EAGAIN)
+                       cpu_relax();
+
+               if  (ret < 0) {
+                       printk("i/o failed !err %d\n", ret);
+                       break;
+               }
+
+               len -= last_transfer;
+               buf += last_transfer;
+               transferred += last_transfer;
+       }
+       return (ret < 0) ? ret : transferred;
+}
+
+/* default writeout routine for single dump device */
+/* writes out the dump data ensuring enough space is left for the end marker */
+int dump_generic_write_buffer(void *buf, unsigned long len)
+{
+       long written = 0;
+       int err = 0;
+
+       /* check for space */
+       if ((err = dump_dev_seek(dump_config.dumper->curr_offset + len + 
+                       2*DUMP_BUFFER_SIZE)) < 0) {
+               printk("dump_write_buffer: insuff space after offset 0x%llx\n",
+                       dump_config.dumper->curr_offset);
+               return err;
+       }
+       /* alignment check would happen as a side effect of this */
+       if ((err = dump_dev_seek(dump_config.dumper->curr_offset)) < 0)
+               return err; 
+
+       written = dump_ll_write(buf, len);
+
+       /* all or none */
+
+       if (written < len)
+               written = written ? -ENOSPC : written;
+       else
+               dump_config.dumper->curr_offset += len;
+
+       return written;
+}
+
+int dump_generic_configure(unsigned long devid)
+{
+       struct dump_dev *dev = dump_config.dumper->dev;
+       struct dump_data_filter *filter;
+       void *buf;
+       int ret = 0;
+
+       /* Allocate the dump buffer and initialize dumper state */
+       /* Assume that we get aligned addresses */
+       if (!(buf = dump_alloc_mem(DUMP_BUFFER_SIZE + 3 * DUMP_PAGE_SIZE)))
+               return -ENOMEM;
+
+       if ((unsigned long)buf & (PAGE_SIZE - 1)) {
+               /* sanity check for page aligned address */
+               dump_free_mem(buf);
+               return -ENOMEM; /* fixme: better error code */
+       }
+
+       /* Initialize the rest of the fields */
+       dump_config.dumper->dump_buf = buf + DUMP_PAGE_SIZE;
+       dumper_reset();
+
+       /* Open the dump device */
+       if (!dev)
+               return -ENODEV;
+
+       if ((ret = dev->ops->open(dev, devid))) {
+              return ret;
+       }
+
+       /* Initialise the memory ranges in the dump filter */
+       for (filter = dump_config.dumper->filter ;filter->selector; filter++) {
+               if (!filter->start[0] && !filter->end[0]) {
+                       pg_data_t *pgdat;
+                       int i = 0;
+                       for_each_pgdat(pgdat) {
+                               filter->start[i] = 
+                                       (loff_t)pgdat->node_start_pfn << PAGE_SHIFT;
+                               filter->end[i] =
+                                       (loff_t)(pgdat->node_start_pfn + pgdat->node_spanned_pages) << PAGE_SHIFT;
+                               i++;
+                       }
+                       filter->num_mbanks = i;
+               }
+       }
+
+       return 0;
+}
+
+int dump_generic_unconfigure(void)
+{
+       struct dump_dev *dev = dump_config.dumper->dev;
+       void *buf = dump_config.dumper->dump_buf;
+       int ret = 0;
+
+       pr_debug("Generic unconfigure\n");
+       /* Close the dump device */
+       if (dev && (ret = dev->ops->release(dev)))
+               return ret;
+
+       printk("Closed dump device\n");
+       
+       if (buf)
+               dump_free_mem((buf - DUMP_PAGE_SIZE));
+
+       dump_config.dumper->curr_buf = dump_config.dumper->dump_buf = NULL;
+       pr_debug("Released dump buffer\n");
+
+       return 0;
+}
+
+
+/* Set up the default dump scheme */
+
+struct dump_scheme_ops dump_scheme_singlestage_ops = {
+       .configure      = dump_generic_configure,
+       .unconfigure    = dump_generic_unconfigure,
+       .sequencer      = dump_generic_sequencer,
+       .iterator       = dump_page_iterator,
+       .save_data      = dump_generic_save_data,
+       .skip_data      = dump_generic_skip_data,
+       .write_buffer   = dump_generic_write_buffer,
+};
+
+struct dump_scheme dump_scheme_singlestage = {
+       .name           = "single-stage",
+       .ops            = &dump_scheme_singlestage_ops
+};
+
+/* The single stage dumper comprising all these */
+struct dumper dumper_singlestage = {
+       .name           = "single-stage",
+       .scheme         = &dump_scheme_singlestage,
+       .fmt            = &dump_fmt_lcrash,
+       .compress       = &dump_none_compression,
+       .filter         = dump_filter_table,
+       .dev            = NULL,
+};             
+
diff --git a/drivers/dump/dump_setup.c b/drivers/dump/dump_setup.c
new file mode 100644 (file)
index 0000000..668b2d0
--- /dev/null
@@ -0,0 +1,835 @@
+/*
+ * Standard kernel function entry points for Linux crash dumps.
+ *
+ * Created by: Matt Robinson (yakker@sourceforge.net)
+ * Contributions from SGI, IBM, HP, MCL, and others.
+ *
+ * Copyright (C) 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2000 - 2002 TurboLinux, Inc.  All rights reserved.
+ * Copyright (C) 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 Free Software Foundation, Inc. All rights reserved.
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/*
+ * -----------------------------------------------------------------------
+ *
+ * DUMP HISTORY
+ *
+ * This dump code goes back to SGI's first attempts at dumping system
+ * memory on SGI systems running IRIX.  A few developers at SGI needed
+ * a way to take this system dump and analyze it, and created 'icrash',
+ * or IRIX Crash.  The mechanism (the dumps and 'icrash') were used
+ * by support people to generate crash reports when a system failure
+ * occurred.  This was vital for large system configurations that
+ * couldn't apply patch after patch after fix just to hope that the
+ * problems would go away.  So the system memory, along with the crash
+ * dump analyzer, allowed support people to quickly figure out what the
+ * problem was on the system with the crash dump.
+ *
+ * In comes Linux.  SGI started moving towards the open source community,
+ * and upon doing so, SGI wanted to take its support utilities into Linux
+ * with the hopes that they would end up the in kernel and user space to
+ * be used by SGI's customers buying SGI Linux systems.  One of the first
+ * few products to be open sourced by SGI was LKCD, or Linux Kernel Crash
+ * Dumps.  LKCD comprises of a patch to the kernel to enable system
+ * dumping, along with 'lcrash', or Linux Crash, to analyze the system
+ * memory dump.  A few additional system scripts and kernel modifications
+ * are also included to make the dump mechanism and dump data easier to
+ * process and use.
+ *
+ * As soon as LKCD was released into the open source community, a number
+ * of larger companies started to take advantage of it.  Today, there are
+ * many community members that contribute to LKCD, and it continues to
+ * flourish and grow as an open source project.
+ */
+
+/*
+ * DUMP TUNABLES
+ *
+ * This is the list of system tunables (via /proc) that are available
+ * for Linux systems.  All the read, write, etc., functions are listed
+ * here.  Currently, there are a few different tunables for dumps:
+ *
+ * dump_device (used to be dumpdev):
+ *     The device for dumping the memory pages out to.  This 
+ *     may be set to the primary swap partition for disruptive dumps,
+ *     and must be an unused partition for non-disruptive dumps.
+ *     Todo: In the case of network dumps, this may be interpreted 
+ *     as the IP address of the netdump server to connect to.
+ *
+ * dump_compress (used to be dump_compress_pages):
+ *     This is the flag which indicates which compression mechanism
+ *     to use.  This is a BITMASK, not an index (0,1,2,4,8,16,etc.).
+ *     This is the current set of values:
+ *
+ *     0: DUMP_COMPRESS_NONE -- Don't compress any pages.
+ *     1: DUMP_COMPRESS_RLE  -- This uses RLE compression.
+ *     2: DUMP_COMPRESS_GZIP -- This uses GZIP compression.
+ *
+ * dump_level:
+ *     The amount of effort the dump module should make to save
+ *     information for post crash analysis.  This value is now
+ *     a BITMASK value, not an index:
+ *
+ *     0:   Do nothing, no dumping. (DUMP_LEVEL_NONE)
+ *
+ *     1:   Print out the dump information to the dump header, and
+ *          write it out to the dump_device. (DUMP_LEVEL_HEADER)
+ *
+ *     2:   Write out the dump header and all kernel memory pages.
+ *          (DUMP_LEVEL_KERN)
+ *
+ *     4:   Write out the dump header and all kernel and user
+ *          memory pages.  (DUMP_LEVEL_USED)
+ *
+ *     8:   Write out the dump header and all conventional/cached 
+ *         memory (RAM) pages in the system (kernel, user, free).  
+ *         (DUMP_LEVEL_ALL_RAM)
+ *
+ *    16:   Write out everything, including non-conventional memory
+ *         like firmware, proms, I/O registers, uncached memory.
+ *         (DUMP_LEVEL_ALL)
+ *
+ *     The dump_level will default to 1.
+ *
+ * dump_flags:
+ *     These are the flags to use when talking about dumps.  There
+ *     are lots of possibilities.  This is a BITMASK value, not an index.
+ * 
+ * -----------------------------------------------------------------------
+ */
+
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/reboot.h>
+#include <linux/fs.h>
+#include <linux/dump.h>
+#include "dump_methods.h"
+#include <linux/proc_fs.h>
+#include <linux/module.h>
+#include <linux/utsname.h>
+#include <linux/highmem.h>
+#include <linux/miscdevice.h>
+#include <linux/sysrq.h>
+#include <linux/sysctl.h>
+#include <linux/nmi.h>
+#include <linux/init.h>
+
+#include <asm/hardirq.h>
+#include <asm/uaccess.h>
+
+/*
+ * -----------------------------------------------------------------------
+ *                         V A R I A B L E S
+ * -----------------------------------------------------------------------
+ */
+
+/* Dump tunables */
+struct dump_config dump_config = {
+       .level          = 0,
+       .flags          = 0,
+       .dump_device    = 0,
+       .dump_addr      = 0,
+       .dumper         = NULL
+};
+#ifdef CONFIG_ARM 
+static _dump_regs_t all_regs;
+#endif
+
+/* Global variables used in dump.h */
+/* degree of system freeze when dumping */
+enum dump_silence_levels dump_silence_level = DUMP_HARD_SPIN_CPUS;      
+
+/* Other global fields */
+extern struct __dump_header dump_header; 
+struct dump_dev *dump_dev = NULL;  /* Active dump device                   */
+static int dump_compress = 0;
+
+static u16 dump_compress_none(const u8 *old, u16 oldsize, u8 *new, u16 newsize);
+struct __dump_compress dump_none_compression = {
+       .compress_type  = DUMP_COMPRESS_NONE,
+       .compress_func  = dump_compress_none,
+       .compress_name  = "none",
+};
+
+/* our device operations and functions */
+static int dump_ioctl(struct inode *i, struct file *f,
+       unsigned int cmd, unsigned long arg);
+
+static struct file_operations dump_fops = {
+       .owner  = THIS_MODULE,
+       .ioctl  = dump_ioctl,
+};
+
+static struct miscdevice dump_miscdev = {
+       .minor  = CRASH_DUMP_MINOR,
+       .name   = "dump",
+       .fops   = &dump_fops,
+};
+MODULE_ALIAS_MISCDEV(CRASH_DUMP_MINOR);
+
+/* static variables                                                    */
+static int dump_okay = 0;              /* can we dump out to disk?     */
+static spinlock_t dump_lock = SPIN_LOCK_UNLOCKED;
+
+/* used for dump compressors */
+static struct list_head dump_compress_list = LIST_HEAD_INIT(dump_compress_list);
+
+/* list of registered dump targets */
+static struct list_head dump_target_list = LIST_HEAD_INIT(dump_target_list);
+
+/* lkcd info structure -- this is used by lcrash for basic system data     */
+struct __lkcdinfo lkcdinfo = {
+       .ptrsz          = (sizeof(void *) * 8),
+#if defined(__LITTLE_ENDIAN) 
+       .byte_order     = __LITTLE_ENDIAN,
+#else
+       .byte_order     = __BIG_ENDIAN,
+#endif
+       .page_shift     = PAGE_SHIFT,
+       .page_size      = PAGE_SIZE,
+       .page_mask      = PAGE_MASK,
+       .page_offset    = PAGE_OFFSET,
+};
+
+/*
+ * -----------------------------------------------------------------------
+ *            / P R O C   T U N A B L E   F U N C T I O N S
+ * -----------------------------------------------------------------------
+ */
+
+static int proc_dump_device(ctl_table *ctl, int write, struct file *f,
+                           void *buffer, size_t *lenp);
+
+static int proc_doulonghex(ctl_table *ctl, int write, struct file *f,
+                           void *buffer, size_t *lenp);
+/*
+ * sysctl-tuning infrastructure.
+ */
+static ctl_table dump_table[] = {
+       { .ctl_name = CTL_DUMP_LEVEL,
+         .procname = DUMP_LEVEL_NAME, 
+         .data = &dump_config.level,    
+         .maxlen = sizeof(int),
+         .mode = 0644,
+         .proc_handler = proc_doulonghex, },
+
+       { .ctl_name = CTL_DUMP_FLAGS,
+         .procname = DUMP_FLAGS_NAME,
+         .data = &dump_config.flags,   
+         .maxlen = sizeof(int),
+         .mode = 0644,
+         .proc_handler = proc_doulonghex, },
+
+       { .ctl_name = CTL_DUMP_COMPRESS,
+         .procname = DUMP_COMPRESS_NAME,
+         .data = &dump_compress, /* FIXME */
+         .maxlen = sizeof(int),
+         .mode = 0644,
+         .proc_handler = proc_dointvec, },
+         
+       { .ctl_name = CTL_DUMP_DEVICE,
+         .procname = DUMP_DEVICE_NAME,
+         .mode = 0644,
+         .data = &dump_config.dump_device, /* FIXME */
+         .maxlen = sizeof(int),
+         .proc_handler = proc_dump_device },
+
+#ifdef CONFIG_CRASH_DUMP_MEMDEV
+       { .ctl_name = CTL_DUMP_ADDR,
+         .procname = DUMP_ADDR_NAME,
+         .mode = 0444,
+         .data = &dump_config.dump_addr,
+         .maxlen = sizeof(unsigned long),
+         .proc_handler = proc_doulonghex },
+#endif
+
+       { 0, }
+};
+
+static ctl_table dump_root[] = {
+       { .ctl_name = KERN_DUMP,
+         .procname = "dump",
+         .mode = 0555, 
+         .child = dump_table },
+       { 0, }
+};
+
+static ctl_table kernel_root[] = {
+       { .ctl_name = CTL_KERN,
+         .procname = "kernel",
+         .mode = 0555,
+         .child = dump_root, },
+       { 0, }
+};
+
+static struct ctl_table_header *sysctl_header;
+
+/*
+ * -----------------------------------------------------------------------
+ *              C O M P R E S S I O N   F U N C T I O N S
+ * -----------------------------------------------------------------------
+ */
+
+/*
+ * Name: dump_compress_none()
+ * Func: Don't do any compression, period.
+ */
+static u16
+dump_compress_none(const u8 *old, u16 oldsize, u8 *new, u16 newsize)
+{
+       /* just return the old size */
+       return oldsize;
+}
+
+
+/*
+ * Name: dump_execute()
+ * Func: Execute the dumping process.  This makes sure all the appropriate
+ *       fields are updated correctly, and calls dump_execute_memdump(),
+ *       which does the real work.
+ */
+void
+dump_execute(const char *panic_str, const struct pt_regs *regs)
+{
+       int state = -1;
+       unsigned long flags;
+
+       /* make sure we can dump */
+       if (!dump_okay) {
+               pr_info("LKCD not yet configured, can't take dump now\n");
+               return;
+       }
+
+       /* Exclude multiple dumps at the same time,
+        * and disable interrupts,  some drivers may re-enable
+        * interrupts in with silence()
+        *
+        * Try and acquire spin lock. If successful, leave preempt
+        * and interrupts disabled.  See spin_lock_irqsave in spinlock.h
+        */
+       local_irq_save(flags);
+       if (!spin_trylock(&dump_lock)) {
+               local_irq_restore(flags);
+               pr_info("LKCD dump already in progress\n");
+               return;
+       }
+
+       /* Bring system into the strictest level of quiescing for min drift 
+        * dump drivers can soften this as required in dev->ops->silence() 
+        */
+       dump_oncpu = smp_processor_id() + 1;
+       dump_silence_level = DUMP_HARD_SPIN_CPUS; 
+
+       state = dump_generic_execute(panic_str, regs);
+       
+       dump_oncpu = 0;
+       spin_unlock_irqrestore(&dump_lock, flags);
+
+       if (state < 0) {
+               printk("Dump Incomplete or failed!\n");
+       } else {
+               printk("Dump Complete; %d dump pages saved.\n", 
+                      dump_header.dh_num_dump_pages);
+       }
+}
+
+/*
+ * Name: dump_register_compression()
+ * Func: Register a dump compression mechanism.
+ */
+void
+dump_register_compression(struct __dump_compress *item)
+{
+       if (item)
+               list_add(&(item->list), &dump_compress_list);
+}
+
+/*
+ * Name: dump_unregister_compression()
+ * Func: Remove a dump compression mechanism, and re-assign the dump
+ *       compression pointer if necessary.
+ */
+void
+dump_unregister_compression(int compression_type)
+{
+       struct list_head *tmp;
+       struct __dump_compress *dc;
+
+       /* let's make sure our list is valid */
+       if (compression_type != DUMP_COMPRESS_NONE) {
+               list_for_each(tmp, &dump_compress_list) {
+                       dc = list_entry(tmp, struct __dump_compress, list);
+                       if (dc->compress_type == compression_type) {
+                               list_del(&(dc->list));
+                               break;
+                       }
+               }
+       }
+}
+
+/*
+ * Name: dump_compress_init()
+ * Func: Initialize (or re-initialize) compression scheme.
+ */
+static int
+dump_compress_init(int compression_type)
+{
+       struct list_head *tmp;
+       struct __dump_compress *dc;
+
+       /* try to remove the compression item */
+       list_for_each(tmp, &dump_compress_list) {
+               dc = list_entry(tmp, struct __dump_compress, list);
+               if (dc->compress_type == compression_type) {
+                       dump_config.dumper->compress = dc;
+                       dump_compress = compression_type;
+                       pr_debug("Dump Compress %s\n", dc->compress_name);
+                       return 0;
+               }
+       }
+
+       /* 
+        * nothing on the list -- return ENODATA to indicate an error 
+        *
+        * NB: 
+        *      EAGAIN: reports "Resource temporarily unavailable" which
+        *              isn't very enlightening.
+        */
+       printk("compression_type:%d not found\n", compression_type);
+
+       return -ENODATA;
+}
+
+static int
+dumper_setup(unsigned long flags, unsigned long devid)
+{
+       int ret = 0;
+
+       /* unconfigure old dumper if it exists */
+       dump_okay = 0;
+       if (dump_config.dumper) {
+               pr_debug("Unconfiguring current dumper\n");
+               dump_unconfigure();
+       }
+       /* set up new dumper */
+       if (dump_config.flags & DUMP_FLAGS_SOFTBOOT) {
+               printk("Configuring softboot based dump \n");
+#ifdef CONFIG_CRASH_DUMP_MEMDEV
+               dump_config.dumper = &dumper_stage1; 
+#else
+               printk("Requires CONFIG_CRASHDUMP_MEMDEV. Can't proceed.\n");
+               return -1;
+#endif
+       } else {
+               dump_config.dumper = &dumper_singlestage;
+       }       
+       dump_config.dumper->dev = dump_dev;
+
+       ret = dump_configure(devid);
+       if (!ret) {
+               dump_okay = 1;
+               pr_debug("%s dumper set up for dev 0x%lx\n", 
+                       dump_config.dumper->name, devid);
+               dump_config.dump_device = devid;
+       } else {
+               printk("%s dumper set up failed for dev 0x%lx\n", 
+                      dump_config.dumper->name, devid);
+               dump_config.dumper = NULL;
+       }
+       return ret;
+}
+
+static int
+dump_target_init(int target)
+{
+       char type[20];
+       struct list_head *tmp;
+       struct dump_dev *dev;
+       
+       switch (target) {
+               case DUMP_FLAGS_DISKDUMP:
+                       strcpy(type, "blockdev"); break;
+               case DUMP_FLAGS_NETDUMP:
+                       strcpy(type, "networkdev"); break;
+               default:
+                       return -1;
+       }
+
+       /*
+        * This is a bit stupid, generating strings from flag
+        * and doing strcmp. This is done because 'struct dump_dev'
+        * has string 'type_name' and not interger 'type'.
+        */
+       list_for_each(tmp, &dump_target_list) {
+               dev = list_entry(tmp, struct dump_dev, list);
+               if (strcmp(type, dev->type_name) == 0) {
+                       dump_dev = dev;
+                       return 0;
+               }
+       }
+       return -1;
+}
+
+/*
+ * Name: dump_ioctl()
+ * Func: Allow all dump tunables through a standard ioctl() mechanism.
+ *       This is far better than before, where we'd go through /proc,
+ *       because now this will work for multiple OS and architectures.
+ */
+static int
+dump_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg)
+{
+       /* check capabilities */
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       if (!dump_config.dumper && cmd == DIOSDUMPCOMPRESS)
+               /* dump device must be configured first */
+               return -ENODEV;
+
+       /*
+        * This is the main mechanism for controlling get/set data
+        * for various dump device parameters.  The real trick here
+        * is setting the dump device (DIOSDUMPDEV).  That's what
+        * triggers everything else.
+        */
+       switch (cmd) {
+       case DIOSDUMPDEV:       /* set dump_device */
+               pr_debug("Configuring dump device\n"); 
+               if (!(f->f_flags & O_RDWR))
+                       return -EPERM;
+
+               __dump_open();
+               return dumper_setup(dump_config.flags, arg);
+
+               
+       case DIOGDUMPDEV:       /* get dump_device */
+               return put_user((long)dump_config.dump_device, (long *)arg);
+
+       case DIOSDUMPLEVEL:     /* set dump_level */
+               if (!(f->f_flags & O_RDWR))
+                       return -EPERM;
+
+               /* make sure we have a positive value */
+               if (arg < 0)
+                       return -EINVAL;
+
+               /* Fixme: clean this up */
+               dump_config.level = 0;
+               switch ((int)arg) {
+                       case DUMP_LEVEL_ALL:
+                       case DUMP_LEVEL_ALL_RAM:
+                               dump_config.level |= DUMP_MASK_UNUSED;
+                       case DUMP_LEVEL_USED:
+                               dump_config.level |= DUMP_MASK_USED;
+                       case DUMP_LEVEL_KERN:
+                               dump_config.level |= DUMP_MASK_KERN;
+                       case DUMP_LEVEL_HEADER:
+                               dump_config.level |= DUMP_MASK_HEADER;
+                       case DUMP_LEVEL_NONE:
+                               break;
+                       default:
+                               return (-EINVAL);
+                       }
+               pr_debug("Dump Level 0x%lx\n", dump_config.level);
+               break;
+
+       case DIOGDUMPLEVEL:     /* get dump_level */
+               /* fixme: handle conversion */
+               return put_user((long)dump_config.level, (long *)arg);
+
+               
+       case DIOSDUMPFLAGS:     /* set dump_flags */
+               /* check flags */
+               if (!(f->f_flags & O_RDWR))
+                       return -EPERM;
+
+               /* make sure we have a positive value */
+               if (arg < 0)
+                       return -EINVAL;
+                       
+               if (dump_target_init(arg & DUMP_FLAGS_TARGETMASK) < 0)
+                       return -EINVAL; /* return proper error */
+
+               dump_config.flags = arg;
+               
+               pr_debug("Dump Flags 0x%lx\n", dump_config.flags);
+               break;
+               
+       case DIOGDUMPFLAGS:     /* get dump_flags */
+               return put_user((long)dump_config.flags, (long *)arg);
+
+       case DIOSDUMPCOMPRESS:  /* set the dump_compress status */
+               if (!(f->f_flags & O_RDWR))
+                       return -EPERM;
+
+               return dump_compress_init((int)arg);
+
+       case DIOGDUMPCOMPRESS:  /* get the dump_compress status */
+               return put_user((long)(dump_config.dumper ? 
+                       dump_config.dumper->compress->compress_type : 0), 
+                       (long *)arg);
+       case DIOGDUMPOKAY: /* check if dump is configured */
+               return put_user((long)dump_okay, (long *)arg);
+       
+       case DIOSDUMPTAKE: /* Trigger a manual dump */
+               /* Do not proceed if lkcd not yet configured */
+               if(!dump_okay) {
+                       printk("LKCD not yet configured. Cannot take manual dump\n");
+                       return -ENODEV;
+               }
+
+               /* Take the dump */
+               return  manual_handle_crashdump();
+                       
+       default:
+               /* 
+                * these are network dump specific ioctls, let the
+                * module handle them.
+                */
+               return dump_dev_ioctl(cmd, arg);
+       }
+       return 0;
+}
+
+/*
+ * Handle special cases for dump_device 
+ * changing dump device requires doing an opening the device
+ */
+static int 
+proc_dump_device(ctl_table *ctl, int write, struct file *f,
+                void *buffer, size_t *lenp)
+{
+       int *valp = ctl->data;
+       int oval = *valp;
+       int ret = -EPERM;
+
+       /* same permission checks as ioctl */
+       if (capable(CAP_SYS_ADMIN)) {
+               ret = proc_doulonghex(ctl, write, f, buffer, lenp);
+               if (ret == 0 && write && *valp != oval) {
+                       /* need to restore old value to close properly */
+                       dump_config.dump_device = (dev_t) oval;
+                       __dump_open();
+                       ret = dumper_setup(dump_config.flags, (dev_t) *valp);
+               }
+       }
+
+       return ret;
+}
+
+/* All for the want of a proc_do_xxx routine which prints values in hex */
+static int 
+proc_doulonghex(ctl_table *ctl, int write, struct file *f,
+                void *buffer, size_t *lenp)
+{
+#define TMPBUFLEN 20
+       unsigned long *i;
+       size_t len, left;
+       char buf[TMPBUFLEN];
+
+       if (!ctl->data || !ctl->maxlen || !*lenp || (f->f_pos)) {
+               *lenp = 0;
+               return 0;
+       }
+       
+       i = (unsigned long *) ctl->data;
+       left = *lenp;
+       
+       sprintf(buf, "0x%lx\n", (*i));
+       len = strlen(buf);
+       if (len > left)
+               len = left;
+       if(copy_to_user(buffer, buf, len))
+               return -EFAULT;
+       
+       left -= len;
+       *lenp -= left;
+       f->f_pos += *lenp;
+       return 0;
+}
+
+/*
+ * -----------------------------------------------------------------------
+ *                     I N I T   F U N C T I O N S
+ * -----------------------------------------------------------------------
+ */
+
+/*
+ * These register and unregister routines are exported for modules
+ * to register their dump drivers (like block, net etc)
+ */
+int
+dump_register_device(struct dump_dev *ddev)
+{
+       struct list_head *tmp;
+       struct dump_dev *dev;
+
+       list_for_each(tmp, &dump_target_list) {
+               dev = list_entry(tmp, struct dump_dev, list);
+               if (strcmp(ddev->type_name, dev->type_name) == 0) {
+                       printk("Target type %s already registered\n",
+                                       dev->type_name);
+                       return -1; /* return proper error */
+               }
+       }
+       list_add(&(ddev->list), &dump_target_list);
+       
+       return 0;
+}
+
+void
+dump_unregister_device(struct dump_dev *ddev)
+{
+       list_del(&(ddev->list));
+       if (ddev != dump_dev)
+               return;
+
+       dump_okay = 0;
+
+       if (dump_config.dumper)
+               dump_unconfigure();
+
+       dump_config.flags &= ~DUMP_FLAGS_TARGETMASK;
+       dump_okay = 0;
+       dump_dev = NULL;
+       dump_config.dumper = NULL;
+}
+
+static int panic_event(struct notifier_block *this, unsigned long event,
+                      void *ptr)
+{
+#ifdef CONFIG_ARM
+       get_current_general_regs(&all_regs);
+       get_current_cp14_regs(&all_regs);
+       get_current_cp15_regs(&all_regs);
+       dump_execute((const char *)ptr, &all_regs);
+#else
+       struct pt_regs regs;
+       
+       get_current_regs(&regs);
+       dump_execute((const char *)ptr, &regs);
+#endif
+       return 0;
+}
+
+extern struct notifier_block *panic_notifier_list;
+static int panic_event(struct notifier_block *, unsigned long, void *);
+static struct notifier_block panic_block = {
+       .notifier_call = panic_event,
+};
+
+#ifdef CONFIG_MAGIC_SYSRQ
+/* Sysrq handler */
+static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs,
+               struct tty_struct *tty) {
+       dump_execute("sysrq", pt_regs);
+}
+
+static struct sysrq_key_op sysrq_crashdump_op = {
+       .handler        =       sysrq_handle_crashdump,
+       .help_msg       =       "Dump",
+       .action_msg     =       "Starting crash dump",
+};
+#endif
+
+static inline void
+dump_sysrq_register(void) 
+{
+#ifdef CONFIG_MAGIC_SYSRQ
+       __sysrq_lock_table();
+       __sysrq_put_key_op(DUMP_SYSRQ_KEY, &sysrq_crashdump_op);
+       __sysrq_unlock_table();
+#endif
+}
+
+static inline void
+dump_sysrq_unregister(void)
+{
+#ifdef CONFIG_MAGIC_SYSRQ
+       __sysrq_lock_table();
+       if (__sysrq_get_key_op(DUMP_SYSRQ_KEY) == &sysrq_crashdump_op)
+               __sysrq_put_key_op(DUMP_SYSRQ_KEY, NULL);
+       __sysrq_unlock_table();
+#endif
+}
+
+/*
+ * Name: dump_init()
+ * Func: Initialize the dump process.  This will set up any architecture
+ *       dependent code.  The big key is we need the memory offsets before
+ *       the page table is initialized, because the base memory offset
+ *       is changed after paging_init() is called.
+ */
+static int __init
+dump_init(void)
+{
+       struct sysinfo info;
+       int err;
+
+       /* try to create our dump device */
+       err = misc_register(&dump_miscdev);
+       if (err) {
+               printk("cannot register dump character device!\n");
+               return err;
+       }
+
+       __dump_init((u64)PAGE_OFFSET);
+
+       /* set the dump_compression_list structure up */
+       dump_register_compression(&dump_none_compression);
+
+       /* grab the total memory size now (not if/when we crash) */
+       si_meminfo(&info);
+
+       /* set the memory size */
+       dump_header.dh_memory_size = (u64)info.totalram;
+
+       sysctl_header = register_sysctl_table(kernel_root, 0);
+       dump_sysrq_register();
+
+       notifier_chain_register(&panic_notifier_list, &panic_block);
+       dump_function_ptr = dump_execute;
+
+       pr_info("Crash dump driver initialized.\n");
+       return 0;
+}
+
+static void __exit
+dump_cleanup(void)
+{
+       dump_okay = 0;
+
+       if (dump_config.dumper)
+               dump_unconfigure();
+
+       /* arch-specific cleanup routine */
+       __dump_cleanup();
+
+       /* ignore errors while unregistering -- since can't do anything */
+       unregister_sysctl_table(sysctl_header);
+       misc_deregister(&dump_miscdev);
+       dump_sysrq_unregister();
+       notifier_chain_unregister(&panic_notifier_list, &panic_block);
+       dump_function_ptr = NULL;
+}
+
+EXPORT_SYMBOL(dump_register_compression);
+EXPORT_SYMBOL(dump_unregister_compression);
+EXPORT_SYMBOL(dump_register_device);
+EXPORT_SYMBOL(dump_unregister_device);
+EXPORT_SYMBOL(dump_config);
+EXPORT_SYMBOL(dump_silence_level);
+
+EXPORT_SYMBOL(__dump_irq_enable);
+EXPORT_SYMBOL(__dump_irq_restore);
+
+MODULE_AUTHOR("Matt D. Robinson <yakker@sourceforge.net>");
+MODULE_DESCRIPTION("Linux Kernel Crash Dump (LKCD) driver");
+MODULE_LICENSE("GPL");
+
+module_init(dump_init);
+module_exit(dump_cleanup);
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c
deleted file mode 100644 (file)
index 09e4f68..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Parse the EFI PCDP table to locate the console device.
- *
- * (c) Copyright 2002, 2003, 2004 Hewlett-Packard Development Company, L.P.
- *     Khalid Aziz <khalid.aziz@hp.com>
- *     Alex Williamson <alex.williamson@hp.com>
- *     Bjorn Helgaas <bjorn.helgaas@hp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/acpi.h>
-#include <linux/console.h>
-#include <linux/efi.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/serial_core.h>
-#include <asm/io.h>
-#include <asm/serial.h>
-#include "pcdp.h"
-
-static inline int
-uart_irq_supported(int rev, struct pcdp_uart *uart)
-{
-       if (rev < 3)
-               return uart->pci_func & PCDP_UART_IRQ;
-       return uart->flags & PCDP_UART_IRQ;
-}
-
-static inline int
-uart_pci(int rev, struct pcdp_uart *uart)
-{
-       if (rev < 3)
-               return uart->pci_func & PCDP_UART_PCI;
-       return uart->flags & PCDP_UART_PCI;
-}
-
-static inline int
-uart_active_high_low(int rev, struct pcdp_uart *uart)
-{
-       if (uart_pci(rev, uart) || uart->flags & PCDP_UART_ACTIVE_LOW)
-               return ACPI_ACTIVE_LOW;
-       return ACPI_ACTIVE_HIGH;
-}
-
-static inline int
-uart_edge_level(int rev, struct pcdp_uart *uart)
-{
-       if (uart_pci(rev, uart))
-               return ACPI_LEVEL_SENSITIVE;
-       if (rev < 3 || uart->flags & PCDP_UART_EDGE_SENSITIVE)
-               return ACPI_EDGE_SENSITIVE;
-       return ACPI_LEVEL_SENSITIVE;
-}
-
-static void __init
-setup_serial_console(int rev, struct pcdp_uart *uart)
-{
-#ifdef CONFIG_SERIAL_8250_CONSOLE
-       struct uart_port port;
-       static char options[16];
-       int mapsize = 64;
-
-       memset(&port, 0, sizeof(port));
-       port.uartclk = uart->clock_rate;
-       if (!port.uartclk)      /* some FW doesn't supply this */
-               port.uartclk = BASE_BAUD * 16;
-
-       if (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
-               port.mapbase = uart->addr.address;
-               port.membase = ioremap(port.mapbase, mapsize);
-               if (!port.membase) {
-                       printk(KERN_ERR "%s: couldn't ioremap 0x%lx-0x%lx\n",
-                               __FUNCTION__, port.mapbase, port.mapbase + mapsize);
-                       return;
-               }
-               port.iotype = UPIO_MEM;
-       } else if (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
-               port.iobase = uart->addr.address;
-               port.iotype = UPIO_PORT;
-       } else
-               return;
-
-       switch (uart->pci_prog_intfc) {
-               case 0x0: port.type = PORT_8250;    break;
-               case 0x1: port.type = PORT_16450;   break;
-               case 0x2: port.type = PORT_16550;   break;
-               case 0x3: port.type = PORT_16650;   break;
-               case 0x4: port.type = PORT_16750;   break;
-               case 0x5: port.type = PORT_16850;   break;
-               case 0x6: port.type = PORT_16C950;  break;
-               default:  port.type = PORT_UNKNOWN; break;
-       }
-
-       port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
-
-       if (uart_irq_supported(rev, uart)) {
-               port.irq = acpi_register_gsi(uart->gsi,
-                       uart_active_high_low(rev, uart),
-                       uart_edge_level(rev, uart));
-               port.flags |= UPF_AUTO_IRQ;  /* some FW reported wrong GSI */
-               if (uart_pci(rev, uart))
-                       port.flags |= UPF_SHARE_IRQ;
-       }
-
-       if (early_serial_setup(&port) < 0)
-               return;
-
-       snprintf(options, sizeof(options), "%lun%d", uart->baud,
-               uart->bits ? uart->bits : 8);
-       add_preferred_console("ttyS", port.line, options);
-
-       printk(KERN_INFO "PCDP: serial console at %s 0x%lx (ttyS%d, options %s)\n",
-               port.iotype == UPIO_MEM ? "MMIO" : "I/O",
-               uart->addr.address, port.line, options);
-#endif
-}
-
-static void __init
-setup_vga_console(struct pcdp_vga *vga)
-{
-#ifdef CONFIG_VT
-#ifdef CONFIG_VGA_CONSOLE
-       if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) {
-               printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n");
-               return;
-       }
-
-       conswitchp = &vga_con;
-       printk(KERN_INFO "PCDP: VGA console\n");
-#endif
-#endif
-}
-
-void __init
-efi_setup_pcdp_console(char *cmdline)
-{
-       struct pcdp *pcdp;
-       struct pcdp_uart *uart;
-       struct pcdp_device *dev, *end;
-       int i, serial = 0;
-
-       pcdp = efi.hcdp;
-       if (!pcdp)
-               return;
-
-       printk(KERN_INFO "PCDP: v%d at 0x%p\n", pcdp->rev, pcdp);
-
-       if (pcdp->rev < 3) {
-               if (strstr(cmdline, "console=ttyS0") || efi_uart_console_only())
-                       serial = 1;
-       }
-
-       for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
-               if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
-                       if (uart->type == PCDP_CONSOLE_UART) {
-                               setup_serial_console(pcdp->rev, uart);
-                               return;
-                       }
-               }
-       }
-
-       end = (struct pcdp_device *) ((u8 *) pcdp + pcdp->length);
-       for (dev = (struct pcdp_device *) (pcdp->uart + pcdp->num_uarts);
-            dev < end;
-            dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
-               if (dev->flags & PCDP_PRIMARY_CONSOLE) {
-                       if (dev->type == PCDP_CONSOLE_VGA) {
-                               setup_vga_console((struct pcdp_vga *) dev);
-                               return;
-                       }
-               }
-       }
-}
-
-#ifdef CONFIG_IA64_EARLY_PRINTK_UART
-unsigned long
-hcdp_early_uart (void)
-{
-       efi_system_table_t *systab;
-       efi_config_table_t *config_tables;
-       unsigned long addr = 0;
-       struct pcdp *pcdp = 0;
-       struct pcdp_uart *uart;
-       int i;
-
-       systab = (efi_system_table_t *) ia64_boot_param->efi_systab;
-       if (!systab)
-               return 0;
-       systab = __va(systab);
-
-       config_tables = (efi_config_table_t *) systab->tables;
-       if (!config_tables)
-               return 0;
-       config_tables = __va(config_tables);
-
-       for (i = 0; i < systab->nr_tables; i++) {
-               if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
-                       pcdp = (struct pcdp *) config_tables[i].table;
-                       break;
-               }
-       }
-       if (!pcdp)
-               return 0;
-       pcdp = __va(pcdp);
-
-       for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
-               if (uart->type == PCDP_CONSOLE_UART) {
-                       addr = uart->addr.address;
-                       break;
-               }
-       }
-       return addr;
-}
-#endif /* CONFIG_IA64_EARLY_PRINTK_UART */
diff --git a/drivers/firmware/pcdp.h b/drivers/firmware/pcdp.h
deleted file mode 100644 (file)
index 863bb6f..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Definitions for PCDP-defined console devices
- *
- * v1.0a: http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf
- * v2.0:  http://www.dig64.org/specifications/DIG64_HCDPv20_042804.pdf
- *
- * (c) Copyright 2002, 2004 Hewlett-Packard Development Company, L.P.
- *     Khalid Aziz <khalid.aziz@hp.com>
- *     Bjorn Helgaas <bjorn.helgaas@hp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#define PCDP_CONSOLE                   0
-#define PCDP_DEBUG                     1
-#define PCDP_CONSOLE_OUTPUT            2
-#define PCDP_CONSOLE_INPUT             3
-
-#define PCDP_UART                      (0 << 3)
-#define PCDP_VGA                       (1 << 3)
-#define PCDP_USB                       (2 << 3)
-
-/* pcdp_uart.type and pcdp_device.type */
-#define PCDP_CONSOLE_UART              (PCDP_UART | PCDP_CONSOLE)
-#define PCDP_DEBUG_UART                        (PCDP_UART | PCDP_DEBUG)
-#define PCDP_CONSOLE_VGA               (PCDP_VGA  | PCDP_CONSOLE_OUTPUT)
-#define PCDP_CONSOLE_USB               (PCDP_USB  | PCDP_CONSOLE_INPUT)
-
-/* pcdp_uart.flags */
-#define PCDP_UART_EDGE_SENSITIVE       (1 << 0)
-#define PCDP_UART_ACTIVE_LOW           (1 << 1)
-#define PCDP_UART_PRIMARY_CONSOLE      (1 << 2)
-#define PCDP_UART_IRQ                  (1 << 6) /* in pci_func for rev < 3 */
-#define PCDP_UART_PCI                  (1 << 7) /* in pci_func for rev < 3 */
-
-struct pcdp_uart {
-       u8                              type;
-       u8                              bits;
-       u8                              parity;
-       u8                              stop_bits;
-       u8                              pci_seg;
-       u8                              pci_bus;
-       u8                              pci_dev;
-       u8                              pci_func;
-       u64                             baud;
-       struct acpi_generic_address     addr;
-       u16                             pci_dev_id;
-       u16                             pci_vendor_id;
-       u32                             gsi;
-       u32                             clock_rate;
-       u8                              pci_prog_intfc;
-       u8                              flags;
-};
-
-struct pcdp_vga {
-       u8                      count;          /* address space descriptors */
-};
-
-/* pcdp_device.flags */
-#define PCDP_PRIMARY_CONSOLE   1
-
-struct pcdp_device {
-       u8                      type;
-       u8                      flags;
-       u16                     length;
-       u16                     efi_index;
-};
-
-struct pcdp {
-       u8                      signature[4];
-       u32                     length;
-       u8                      rev;            /* PCDP v2.0 is rev 3 */
-       u8                      chksum;
-       u8                      oemid[6];
-       u8                      oem_tabid[8];
-       u32                     oem_rev;
-       u8                      creator_id[4];
-       u32                     creator_rev;
-       u32                     num_uarts;
-       struct pcdp_uart        uart[0];        /* actual size is num_uarts */
-       /* remainder of table is pcdp_device structures */
-};
diff --git a/drivers/i2c/busses/i2c-ixp42x.c b/drivers/i2c/busses/i2c-ixp42x.c
deleted file mode 100644 (file)
index 59fcb70..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * drivers/i2c/i2c-adap-ixp42x.c
- *
- * Intel's IXP42x XScale NPU chipsets (IXP420, 421, 422, 425) do not have
- * an on board I2C controller but provide 16 GPIO pins that are often
- * used to create an I2C bus. This driver provides an i2c_adapter 
- * interface that plugs in under algo_bit and drives the GPIO pins
- * as instructed by the alogorithm driver.
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright (c) 2003-2004 MontaVista Software Inc.
- *
- * This file is licensed under the terms of the GNU General Public 
- * License version 2. This program is licensed "as is" without any 
- * warranty of any kind, whether express or implied.
- *
- * NOTE: Since different platforms will use different GPIO pins for
- *       I2C, this driver uses an IXP42x-specific platform_data
- *       pointer to pass the GPIO numbers to the driver. This 
- *       allows us to support all the different IXP42x platforms
- *       w/o having to put #ifdefs in this driver.
- *
- *       See arch/arm/mach-ixp42x/ixdp425.c for an example of building a 
- *       device list and filling in the ixp42x_i2c_pins data structure 
- *       that is passed as the platform_data to this driver.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/i2c.h>
-
-#include <asm/hardware.h>      /* Pick up IXP42x-specific bits */
-
-static inline int ixp42x_scl_pin(void *data)
-{
-       return ((struct ixp42x_i2c_pins*)data)->scl_pin;
-}
-
-static inline int ixp42x_sda_pin(void *data)
-{
-       return ((struct ixp42x_i2c_pins*)data)->sda_pin;
-}
-
-static void ixp42x_bit_setscl(void *data, int val)
-{
-       gpio_line_set(ixp42x_scl_pin(data), 0);
-       gpio_line_config(ixp42x_scl_pin(data),
-               val ? IXP425_GPIO_IN : IXP425_GPIO_OUT );
-}
-
-static void ixp42x_bit_setsda(void *data, int val)
-{
-       gpio_line_set(ixp42x_sda_pin(data), 0);
-       gpio_line_config(ixp42x_sda_pin(data),
-               val ? IXP425_GPIO_IN : IXP425_GPIO_OUT );
-}
-
-static int ixp42x_bit_getscl(void *data)
-{
-       int scl;
-
-       gpio_line_config(ixp42x_scl_pin(data), IXP425_GPIO_IN );
-       gpio_line_get(ixp42x_scl_pin(data), &scl);
-
-       return scl;
-}      
-
-static int ixp42x_bit_getsda(void *data)
-{
-       int sda;
-
-       gpio_line_config(ixp42x_sda_pin(data), IXP425_GPIO_IN );
-       gpio_line_get(ixp42x_sda_pin(data), &sda);
-
-       return sda;
-}      
-
-struct ixp42x_i2c_data {
-       struct ixp42x_i2c_pins *gpio_pins;
-       struct i2c_adapter adapter;
-       struct i2c_algo_bit_data algo_data;
-};
-
-static int ixp42x_i2c_remove(struct device *dev)
-{
-       struct platform_device *plat_dev = to_platform_device(dev);
-       struct ixp42x_i2c_data *drv_data = dev_get_drvdata(&plat_dev->dev);
-
-       dev_set_drvdata(&plat_dev->dev, NULL);
-
-       i2c_bit_del_bus(&drv_data->adapter);
-
-       kfree(drv_data);
-
-       return 0;
-}
-
-static int ixp42x_i2c_probe(struct device *dev)
-{
-       int err;
-       struct platform_device *plat_dev = to_platform_device(dev);
-       struct ixp42x_i2c_pins *gpio = plat_dev->dev.platform_data;
-       struct ixp42x_i2c_data *drv_data = 
-               kmalloc(sizeof(struct ixp42x_i2c_data), GFP_KERNEL);
-
-       if(!drv_data)
-               return -ENOMEM;
-
-       memzero(drv_data, sizeof(struct ixp42x_i2c_data));
-       drv_data->gpio_pins = gpio;
-
-       /*
-        * We could make a lot of these structures static, but
-        * certain platforms may have multiple GPIO-based I2C
-        * buses for various device domains, so we need per-device
-        * algo_data->data. 
-        */
-       drv_data->algo_data.data = gpio;
-       drv_data->algo_data.setsda = ixp42x_bit_setsda;
-       drv_data->algo_data.setscl = ixp42x_bit_setscl;
-       drv_data->algo_data.getsda = ixp42x_bit_getsda;
-       drv_data->algo_data.getscl = ixp42x_bit_getscl;
-       drv_data->algo_data.udelay = 10;
-       drv_data->algo_data.mdelay = 10;
-       drv_data->algo_data.timeout = 100;
-
-       drv_data->adapter.id = I2C_HW_B_IXP425,
-       drv_data->adapter.algo_data = &drv_data->algo_data,
-
-       drv_data->adapter.dev.parent = &plat_dev->dev;
-
-       gpio_line_config(gpio->scl_pin, IXP425_GPIO_IN);
-       gpio_line_config(gpio->sda_pin, IXP425_GPIO_IN);
-       gpio_line_set(gpio->scl_pin, 0);
-       gpio_line_set(gpio->sda_pin, 0);
-
-       if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) {
-               printk(KERN_ERR "ERROR: Could not install %s\n", dev->bus_id);
-
-               kfree(drv_data);
-               return err;
-       }
-
-       dev_set_drvdata(&plat_dev->dev, drv_data);
-
-       return 0;
-}
-
-static struct device_driver ixp42x_i2c_driver = {
-       .name           = "IXP42X-I2C",
-       .bus            = &platform_bus_type,
-       .probe          = ixp42x_i2c_probe,
-       .remove         = ixp42x_i2c_remove,
-};
-
-static int __init ixp42x_i2c_init(void)
-{
-       return driver_register(&ixp42x_i2c_driver);
-}
-
-static void __exit ixp42x_i2c_exit(void)
-{
-       driver_unregister(&ixp42x_i2c_driver);
-}
-
-module_init(ixp42x_i2c_init);
-module_exit(ixp42x_i2c_exit);
-
-MODULE_DESCRIPTION("GPIO-based I2C driver for IXP42x systems");
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
-
diff --git a/drivers/ide/ide-tcq.c b/drivers/ide/ide-tcq.c
deleted file mode 100644 (file)
index 4284fba..0000000
+++ /dev/null
@@ -1,808 +0,0 @@
-/*
- * Copyright (C) 2001, 2002 Jens Axboe <axboe@suse.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- * Support for the DMA queued protocol, which enables ATA disk drives to
- * use tagged command queueing.
- */
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/ide.h>
-
-#include <asm/io.h>
-#include <asm/delay.h>
-
-/*
- * warning: it will be _very_ verbose if defined
- */
-#undef IDE_TCQ_DEBUG
-
-#ifdef IDE_TCQ_DEBUG
-#define TCQ_PRINTK printk
-#else
-#define TCQ_PRINTK(x...)
-#endif
-
-/*
- * use nIEN or not
- */
-#undef IDE_TCQ_NIEN
-
-/*
- * we are leaving the SERVICE interrupt alone, IBM drives have it
- * on per default and it can't be turned off. Doesn't matter, this
- * is the sane config.
- */
-#undef IDE_TCQ_FIDDLE_SI
-
-/*
- * bad drive blacklist, for drives that raport tcq capability but don't
- * work reliably with the default config. initially from freebsd table.
- */
-struct ide_tcq_blacklist {
-       char *model;
-       char works;
-       unsigned int max_sectors;
-};
-
-static struct ide_tcq_blacklist ide_tcq_blacklist[] = {
-       {
-               .model =        "IBM-DTTA",
-               .works =        1,
-               .max_sectors =  128,
-       },
-       {
-               .model =        "IBM-DJNA",
-               .works =        0,
-       },
-       {
-               .model =        "WDC AC",
-               .works =        0,
-       },
-       {
-               .model =        NULL,
-       },
-};
-
-ide_startstop_t ide_dmaq_intr(ide_drive_t *drive);
-ide_startstop_t ide_service(ide_drive_t *drive);
-
-static struct ide_tcq_blacklist *ide_find_drive_blacklist(ide_drive_t *drive)
-{
-       struct ide_tcq_blacklist *itb;
-       int i = 0;
-
-       do {
-               itb = &ide_tcq_blacklist[i];
-
-               if (!itb->model)
-                       break;
-
-               if (!strncmp(drive->id->model, itb->model, strlen(itb->model)))
-                       return itb;
-
-               i++;
-       } while (1);
-
-       return NULL;
-}
-
-static inline void drive_ctl_nien(ide_drive_t *drive, int set)
-{
-#ifdef IDE_TCQ_NIEN
-       if (IDE_CONTROL_REG) {
-               int mask = set ? 0x02 : 0x00;
-
-               hwif->OUTB(drive->ctl | mask, IDE_CONTROL_REG);
-       }
-#endif
-}
-
-static ide_startstop_t ide_tcq_nop_handler(ide_drive_t *drive)
-{
-       ide_task_t *args = HWGROUP(drive)->rq->special;
-       ide_hwif_t *hwif = HWIF(drive);
-       int auto_poll_check = 0;
-       u8 stat, err;
-
-       if (args->tfRegister[IDE_FEATURE_OFFSET] & 0x01)
-               auto_poll_check = 1;
-
-       local_irq_enable();
-
-       stat = hwif->INB(IDE_STATUS_REG);
-       err = hwif->INB(IDE_ERROR_REG);
-       ide_end_drive_cmd(drive, stat, err);
-
-       /*
-        * do taskfile and check ABRT bit -- intelligent adapters will not
-        * pass NOP with sub-code 0x01 to device, so the command will not
-        * fail there
-        */
-       if (auto_poll_check) {
-               if (!(args->tfRegister[IDE_FEATURE_OFFSET] & ABRT_ERR)) {
-                       HWIF(drive)->auto_poll = 1;
-                       printk("%s: NOP Auto-poll enabled\n",HWIF(drive)->name);
-               }
-       }
-
-       kfree(args);
-       return ide_stopped;
-}
-
-/*
- * if we encounter _any_ error doing I/O to one of the tags, we must
- * invalidate the pending queue. clear the software busy queue and requeue
- * on the request queue for restart. issue a WIN_NOP to clear hardware queue
- */
-static void ide_tcq_invalidate_queue(ide_drive_t *drive)
-{
-       ide_hwgroup_t *hwgroup = HWGROUP(drive);
-       request_queue_t *q = drive->queue;
-       struct request *rq;
-       unsigned long flags;
-
-       printk("%s: invalidating tag queue (%d commands)\n", drive->name, ata_pending_commands(drive));
-
-       /*
-        * first kill timer and block queue
-        */
-       spin_lock_irqsave(&ide_lock, flags);
-
-       del_timer(&hwgroup->timer);
-
-       if (HWIF(drive)->dma)
-               HWIF(drive)->ide_dma_end(drive);
-
-       blk_queue_invalidate_tags(q);
-
-       drive->using_tcq = 0;
-       drive->queue_depth = 1;
-       hwgroup->busy = 0;
-       hwgroup->handler = NULL;
-
-       spin_unlock_irqrestore(&ide_lock, flags);
-
-       /*
-        * now kill hardware queue with a NOP
-        */
-       rq = &hwgroup->wrq;
-       ide_init_drive_cmd(rq);
-       rq->buffer = hwgroup->cmd_buf;
-       memset(rq->buffer, 0, sizeof(hwgroup->cmd_buf));
-       rq->buffer[0] = WIN_NOP;
-       ide_do_drive_cmd(drive, rq, ide_preempt);
-}
-
-void ide_tcq_intr_timeout(unsigned long data)
-{
-       ide_drive_t *drive = (ide_drive_t *) data;
-       ide_hwgroup_t *hwgroup = HWGROUP(drive);
-       ide_hwif_t *hwif = HWIF(drive);
-       unsigned long flags;
-
-       printk(KERN_ERR "ide_tcq_intr_timeout: timeout waiting for %s interrupt\n", hwgroup->rq ? "completion" : "service");
-
-       spin_lock_irqsave(&ide_lock, flags);
-
-       if (!hwgroup->busy)
-               printk(KERN_ERR "ide_tcq_intr_timeout: hwgroup not busy\n");
-       if (hwgroup->handler == NULL)
-               printk(KERN_ERR "ide_tcq_intr_timeout: missing isr!\n");
-
-       hwgroup->busy = 1;
-       spin_unlock_irqrestore(&ide_lock, flags);
-
-       /*
-        * if pending commands, try service before giving up
-        */
-       if (ata_pending_commands(drive)) {
-               u8 stat = hwif->INB(IDE_STATUS_REG);
-
-               if ((stat & SRV_STAT) && (ide_service(drive) == ide_started))
-                       return;
-       }
-
-       if (drive)
-               ide_tcq_invalidate_queue(drive);
-}
-
-void __ide_tcq_set_intr(ide_hwgroup_t *hwgroup, ide_handler_t *handler)
-{
-       /*
-        * always just bump the timer for now, the timeout handling will
-        * have to be changed to be per-command
-        */
-       hwgroup->timer.function = ide_tcq_intr_timeout;
-       hwgroup->timer.data = (unsigned long) hwgroup->drive;
-       mod_timer(&hwgroup->timer, jiffies + 5 * HZ);
-
-       hwgroup->handler = handler;
-}
-
-void ide_tcq_set_intr(ide_hwgroup_t *hwgroup, ide_handler_t *handler)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&ide_lock, flags);
-       __ide_tcq_set_intr(hwgroup, handler);
-       spin_unlock_irqrestore(&ide_lock, flags);
-}
-
-/*
- * wait 400ns, then poll for busy_mask to clear from alt status
- */
-#define IDE_TCQ_WAIT   (10000)
-int ide_tcq_wait_altstat(ide_drive_t *drive, byte *stat, byte busy_mask)
-{
-       ide_hwif_t *hwif = HWIF(drive);
-       int i = 0;
-
-       udelay(1);
-
-       do {
-               *stat = hwif->INB(IDE_ALTSTATUS_REG);
-
-               if (!(*stat & busy_mask))
-                       break;
-
-               if (unlikely(i++ > IDE_TCQ_WAIT))
-                       return 1;
-
-               udelay(10);
-       } while (1);
-
-       return 0;
-}
-
-/*
- * issue SERVICE command to drive -- drive must have been selected first,
- * and it must have reported a need for service (status has SRV_STAT set)
- *
- * Also, nIEN must be set as not to need protection against ide_dmaq_intr
- */
-ide_startstop_t ide_service(ide_drive_t *drive)
-{
-       ide_hwif_t *hwif = HWIF(drive);
-       unsigned long flags;
-       struct request *rq;
-       byte feat, stat;
-       int tag;
-
-       TCQ_PRINTK("%s: started service\n", drive->name);
-
-       /*
-        * could be called with IDE_DMA in-progress from invalidate
-        * handler, refuse to do anything
-        */
-       if (hwif->dma)
-               return ide_stopped;
-
-       /*
-        * need to select the right drive first...
-        */
-       if (drive != HWGROUP(drive)->drive) {
-               SELECT_DRIVE(drive);
-               udelay(10);
-       }
-
-       drive_ctl_nien(drive, 1);
-
-       /*
-        * send SERVICE, wait 400ns, wait for BUSY_STAT to clear
-        */
-       hwif->OUTB(WIN_QUEUED_SERVICE, IDE_COMMAND_REG);
-
-       if (ide_tcq_wait_altstat(drive, &stat, BUSY_STAT)) {
-               printk(KERN_ERR "ide_service: BUSY clear took too long\n");
-               ide_dump_status(drive, "ide_service", stat);
-               ide_tcq_invalidate_queue(drive);
-               return ide_stopped;
-       }
-
-       drive_ctl_nien(drive, 0);
-
-       /*
-        * FIXME, invalidate queue
-        */
-       if (stat & ERR_STAT) {
-               ide_dump_status(drive, "ide_service", stat);
-               ide_tcq_invalidate_queue(drive);
-               return ide_stopped;
-       }
-
-       /*
-        * should not happen, a buggy device could introduce loop
-        */
-       feat = hwif->INB(IDE_NSECTOR_REG);
-       if (feat & REL) {
-               HWGROUP(drive)->rq = NULL;
-               printk(KERN_ERR "%s: release in service\n", drive->name);
-               return ide_stopped;
-       }
-
-       tag = feat >> 3;
-
-       TCQ_PRINTK("ide_service: stat %x, feat %x\n", stat, feat);
-
-       spin_lock_irqsave(&ide_lock, flags);
-
-       if ((rq = blk_queue_find_tag(drive->queue, tag))) {
-               HWGROUP(drive)->rq = rq;
-
-               /*
-                * we'll start a dma read or write, device will trigger
-                * interrupt to indicate end of transfer, release is not
-                * allowed
-                */
-               TCQ_PRINTK("ide_service: starting command, stat=%x\n", stat);
-               spin_unlock_irqrestore(&ide_lock, flags);
-               return __ide_dma_queued_start(drive);
-       }
-
-       printk(KERN_ERR "ide_service: missing request for tag %d\n", tag);
-       spin_unlock_irqrestore(&ide_lock, flags);
-       return ide_stopped;
-}
-
-ide_startstop_t ide_check_service(ide_drive_t *drive)
-{
-       ide_hwif_t *hwif = HWIF(drive);
-       byte stat;
-
-       TCQ_PRINTK("%s: ide_check_service\n", drive->name);
-
-       if (!ata_pending_commands(drive))
-               return ide_stopped;
-
-       stat = hwif->INB(IDE_STATUS_REG);
-       if (stat & SRV_STAT)
-               return ide_service(drive);
-
-       /*
-        * we have pending commands, wait for interrupt
-        */
-       TCQ_PRINTK("%s: wait for service interrupt\n", drive->name);
-       ide_tcq_set_intr(HWGROUP(drive), ide_dmaq_intr);
-       return ide_started;
-}
-
-ide_startstop_t ide_dmaq_complete(ide_drive_t *drive, struct request *rq, byte stat)
-{
-       byte dma_stat;
-
-       /*
-        * transfer was in progress, stop DMA engine
-        */
-       dma_stat = HWIF(drive)->ide_dma_end(drive);
-
-       /*
-        * must be end of I/O, check status and complete as necessary
-        */
-       if (unlikely(!OK_STAT(stat, READY_STAT, drive->bad_wstat | DRQ_STAT))) {
-               printk(KERN_ERR "ide_dmaq_intr: %s: error status %x\n",drive->name,stat);
-               ide_dump_status(drive, "ide_dmaq_complete", stat);
-               ide_tcq_invalidate_queue(drive);
-               return ide_stopped;
-       }
-
-       if (dma_stat)
-               printk(KERN_WARNING "%s: bad DMA status (dma_stat=%x)\n", drive->name, dma_stat);
-
-       TCQ_PRINTK("ide_dmaq_complete: ending %p, tag %d\n", rq, rq->tag);
-       ide_end_request(drive, 1, rq->nr_sectors);
-
-       /*
-        * we completed this command, check if we can service a new command
-        */
-       return ide_check_service(drive);
-}
-
-/*
- * intr handler for queued dma operations. this can be entered for two
- * reasons:
- *
- * 1) device has completed dma transfer
- * 2) service request to start a command
- *
- * if the drive has an active tag, we first complete that request before
- * processing any pending SERVICE.
- */
-ide_startstop_t ide_dmaq_intr(ide_drive_t *drive)
-{
-       struct request *rq = HWGROUP(drive)->rq;
-       ide_hwif_t *hwif = HWIF(drive);
-       byte stat = hwif->INB(IDE_STATUS_REG);
-
-       TCQ_PRINTK("ide_dmaq_intr: stat=%x\n", stat);
-
-       /*
-        * if a command completion interrupt is pending, do that first and
-        * check service afterwards
-        */
-       if (rq) {
-               TCQ_PRINTK("ide_dmaq_intr: completion\n");
-               return ide_dmaq_complete(drive, rq, stat);
-       }
-
-       /*
-        * service interrupt
-        */
-       if (stat & SRV_STAT) {
-               TCQ_PRINTK("ide_dmaq_intr: SERV (stat=%x)\n", stat);
-               return ide_service(drive);
-       }
-
-       printk("ide_dmaq_intr: stat=%x, not expected\n", stat);
-       return ide_check_service(drive);
-}
-
-/*
- * check if the ata adapter this drive is attached to supports the
- * NOP auto-poll for multiple tcq enabled drives on one channel
- */
-static int ide_tcq_check_autopoll(ide_drive_t *drive)
-{
-       ide_task_t *args;
-       int i, drives;
-
-       /*
-        * only need to probe if both drives on a channel support tcq
-        */
-       for (i = 0, drives = 0; i < MAX_DRIVES; i++)
-               if (HWIF(drive)->drives[i].present && drive->media == ide_disk)
-                       drives++;
-
-       if (drives <= 1)
-               return 0;
-
-       /*
-        * what a mess...
-        */
-       args = kmalloc(sizeof(*args), GFP_ATOMIC);
-       if (!args)
-               return 1;
-
-       memset(args, 0, sizeof(*args));
-
-       args->tfRegister[IDE_FEATURE_OFFSET] = 0x01;
-       args->tfRegister[IDE_COMMAND_OFFSET] = WIN_NOP;
-       args->command_type = IDE_DRIVE_TASK_NO_DATA;
-       args->handler = ide_tcq_nop_handler;
-       return ide_raw_taskfile(drive, args, NULL);
-}
-
-/*
- * configure the drive for tcq
- */
-static int ide_tcq_configure(ide_drive_t *drive)
-{
-       int tcq_mask = 1 << 1 | 1 << 14;
-       int tcq_bits = tcq_mask | 1 << 15;
-       ide_task_t *args;
-
-       /*
-        * bit 14 and 1 must be set in word 83 of the device id to indicate
-        * support for dma queued protocol, and bit 15 must be cleared
-        */
-       if ((drive->id->command_set_2 & tcq_bits) ^ tcq_mask) {
-               printk(KERN_INFO "%s: TCQ not supported\n", drive->name);
-               return -EIO;
-       }
-
-       args = kmalloc(sizeof(*args), GFP_ATOMIC);
-       if (!args)
-               return -ENOMEM;
-
-       memset(args, 0, sizeof(ide_task_t));
-       args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
-       args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_EN_WCACHE;
-       args->command_type = IDE_DRIVE_TASK_NO_DATA;
-       args->handler      = &task_no_data_intr;
-
-       if (ide_raw_taskfile(drive, args, NULL)) {
-               printk(KERN_WARNING "%s: failed to enable write cache\n", drive->name);
-               goto err;
-       }
-
-       /*
-        * disable RELease interrupt, it's quicker to poll this after
-        * having sent the command opcode
-        */
-       memset(args, 0, sizeof(ide_task_t));
-       args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
-       args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_DIS_RI;
-       args->command_type = IDE_DRIVE_TASK_NO_DATA;
-       args->handler      = &task_no_data_intr;
-
-       if (ide_raw_taskfile(drive, args, NULL)) {
-               printk(KERN_ERR "%s: disabling release interrupt fail\n", drive->name);
-               goto err;
-       }
-
-#ifdef IDE_TCQ_FIDDLE_SI
-       /*
-        * enable SERVICE interrupt
-        */
-       memset(args, 0, sizeof(ide_task_t));
-       args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
-       args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_EN_SI;
-       args->command_type = IDE_DRIVE_TASK_NO_DATA;
-       args->handler      = &task_no_data_intr;
-
-       if (ide_raw_taskfile(drive, args, NULL)) {
-               printk(KERN_ERR "%s: enabling service interrupt fail\n", drive->name);
-               goto err;
-       }
-#endif
-
-       kfree(args);
-       return 0;
-err:
-       kfree(args);
-       return -EIO;
-}
-
-/*
- * for now assume that command list is always as big as we need and don't
- * attempt to shrink it on tcq disable
- */
-static int ide_enable_queued(ide_drive_t *drive, int on)
-{
-       struct ide_tcq_blacklist *itb;
-       int depth = drive->using_tcq ? drive->queue_depth : 0;
-
-       /*
-        * disable or adjust queue depth
-        */
-       if (!on) {
-               if (drive->using_tcq)
-                       printk(KERN_INFO "%s: TCQ disabled\n", drive->name);
-
-               drive->using_tcq = 0;
-               return 0;
-       }
-
-       if (ide_tcq_configure(drive)) {
-               drive->using_tcq = 0;
-               return 1;
-       }
-
-       /*
-        * some drives need limited transfer size in tcq
-        */
-       itb = ide_find_drive_blacklist(drive);
-       if (itb && itb->max_sectors) {
-               if (itb->max_sectors > HWIF(drive)->rqsize)
-                       itb->max_sectors = HWIF(drive)->rqsize;
-
-               blk_queue_max_sectors(drive->queue, itb->max_sectors);
-       }
-
-       /*
-        * enable block tagging
-        */
-       if (!blk_queue_tagged(drive->queue))
-               blk_queue_init_tags(drive->queue, IDE_MAX_TAG, NULL);
-
-       /*
-        * check auto-poll support
-        */
-       ide_tcq_check_autopoll(drive);
-
-       if (depth != drive->queue_depth)
-               printk(KERN_INFO "%s: tagged command queueing enabled, command queue depth %d\n", drive->name, drive->queue_depth);
-
-       drive->using_tcq = 1;
-       return 0;
-}
-
-int ide_tcq_wait_dataphase(ide_drive_t *drive)
-{
-       ide_hwif_t *hwif = HWIF(drive);
-       byte stat;
-       int i;
-
-       do {
-               stat = hwif->INB(IDE_STATUS_REG);
-               if (!(stat & BUSY_STAT))
-                       break;
-
-               udelay(10);
-       } while (1);
-
-       if (OK_STAT(stat, READY_STAT | DRQ_STAT, drive->bad_wstat))
-               return 0;
-
-       i = 0;
-       udelay(1);
-       do {
-               stat = hwif->INB(IDE_STATUS_REG);
-
-               if (OK_STAT(stat, READY_STAT | DRQ_STAT, drive->bad_wstat))
-                       break;
-
-               ++i;
-               if (unlikely(i >= IDE_TCQ_WAIT))
-                       return 1;
-
-               udelay(10);
-       } while (1);
-
-       return 0;
-}
-
-static int ide_tcq_check_blacklist(ide_drive_t *drive)
-{
-       struct ide_tcq_blacklist *itb = ide_find_drive_blacklist(drive);
-
-       if (!itb)
-               return 0;
-
-       return !itb->works;
-}
-
-int __ide_dma_queued_on(ide_drive_t *drive)
-{
-       ide_hwif_t *hwif = HWIF(drive);
-
-       if (drive->media != ide_disk)
-               return 1;
-       if (!drive->using_dma)
-               return 1;
-       if (hwif->chipset == ide_pdc4030)
-               return 1;
-       if (ide_tcq_check_blacklist(drive)) {
-               printk(KERN_WARNING "%s: tcq forbidden by blacklist\n",
-                                       drive->name);
-               return 1;
-       }
-       if (hwif->drives[0].present && hwif->drives[1].present) {
-               printk(KERN_WARNING "%s: only one drive on a channel supported"
-                                       " for tcq\n", drive->name);
-               return 1;
-       }
-       if (ata_pending_commands(drive)) {
-               printk(KERN_WARNING "ide-tcq; can't toggle tcq feature on "
-                                       "busy drive\n");
-               return 1;
-       }
-
-       return ide_enable_queued(drive, 1);
-}
-
-int __ide_dma_queued_off(ide_drive_t *drive)
-{
-       if (drive->media != ide_disk)
-               return 1;
-       if (ata_pending_commands(drive)) {
-               printk("ide-tcq; can't toggle tcq feature on busy drive\n");
-               return 1;
-       }
-
-       return ide_enable_queued(drive, 0);
-}
-
-static ide_startstop_t ide_dma_queued_rw(ide_drive_t *drive, u8 command)
-{
-       ide_hwif_t *hwif = HWIF(drive);
-       unsigned long flags;
-       byte stat, feat;
-
-       TCQ_PRINTK("%s: starting tag\n", drive->name);
-
-       /*
-        * set nIEN, tag start operation will enable again when
-        * it is safe
-        */
-       drive_ctl_nien(drive, 1);
-
-       TCQ_PRINTK("%s: sending cmd=%x\n", drive->name, command);
-       hwif->OUTB(command, IDE_COMMAND_REG);
-
-       if (ide_tcq_wait_altstat(drive, &stat, BUSY_STAT)) {
-               printk("%s: alt stat timeout\n", drive->name);
-               goto err;
-       }
-
-       drive_ctl_nien(drive, 0);
-
-       if (stat & ERR_STAT)
-               goto err;
-
-       /*
-        * bus not released, start dma
-        */
-       feat = hwif->INB(IDE_NSECTOR_REG);
-       if (!(feat & REL)) {
-               TCQ_PRINTK("IMMED in queued_start, feat=%x\n", feat);
-               return __ide_dma_queued_start(drive);
-       }
-
-       /*
-        * drive released the bus, clear active request and check for service
-        */
-       spin_lock_irqsave(&ide_lock, flags);
-       HWGROUP(drive)->rq = NULL;
-       __ide_tcq_set_intr(HWGROUP(drive), ide_dmaq_intr);
-       spin_unlock_irqrestore(&ide_lock, flags);
-
-       TCQ_PRINTK("REL in queued_start\n");
-
-       stat = hwif->INB(IDE_STATUS_REG);
-       if (stat & SRV_STAT)
-               return ide_service(drive);
-
-       return ide_released;
-err:
-       ide_dump_status(drive, "rw_queued", stat);
-       ide_tcq_invalidate_queue(drive);
-       return ide_stopped;
-}
-
-ide_startstop_t __ide_dma_queued_read(ide_drive_t *drive)
-{
-       u8 command = WIN_READDMA_QUEUED;
-
-       if (drive->addressing == 1)
-                command = WIN_READDMA_QUEUED_EXT;
-
-       return ide_dma_queued_rw(drive, command);
-}
-
-ide_startstop_t __ide_dma_queued_write(ide_drive_t *drive)
-{
-       u8 command = WIN_WRITEDMA_QUEUED;
-
-       if (drive->addressing == 1)
-                command = WIN_WRITEDMA_QUEUED_EXT;
-
-       return ide_dma_queued_rw(drive, command);
-}
-
-ide_startstop_t __ide_dma_queued_start(ide_drive_t *drive)
-{
-       ide_hwgroup_t *hwgroup = HWGROUP(drive);
-       struct request *rq = hwgroup->rq;
-       ide_hwif_t *hwif = HWIF(drive);
-       unsigned int reading = 0;
-
-       TCQ_PRINTK("ide_dma: setting up queued tag=%d\n", rq->tag);
-
-       if (!hwgroup->busy)
-               printk(KERN_ERR "queued_rw: hwgroup not busy\n");
-
-       if (ide_tcq_wait_dataphase(drive)) {
-               printk(KERN_WARNING "timeout waiting for data phase\n");
-               return ide_stopped;
-       }
-
-       if (rq_data_dir(rq) == READ)
-               reading = 1 << 3;
-
-       if (ide_start_dma(hwif, drive, reading))
-               return ide_stopped;
-
-       ide_tcq_set_intr(hwgroup, ide_dmaq_intr);
-
-       if (!hwif->ide_dma_begin(drive))
-               return ide_started;
-
-       return ide_stopped;
-}
diff --git a/drivers/ide/legacy/hd98.c b/drivers/ide/legacy/hd98.c
deleted file mode 100644 (file)
index 8028b57..0000000
+++ /dev/null
@@ -1,883 +0,0 @@
-/*
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *
- * This is the low-level hd interrupt support. It traverses the
- * request-list, using interrupts to jump between functions. As
- * all the functions are called within interrupts, we may not
- * sleep. Special care is recommended.
- *
- *  modified by Drew Eckhardt to check nr of hd's from the CMOS.
- *
- *  Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug
- *  in the early extended-partition checks and added DM partitions
- *
- *  IRQ-unmask, drive-id, multiple-mode, support for ">16 heads",
- *  and general streamlining by Mark Lord.
- *
- *  Removed 99% of above. Use Mark's ide driver for those options.
- *  This is now a lightweight ST-506 driver. (Paul Gortmaker)
- *
- *  Modified 1995 Russell King for ARM processor.
- *
- *  Bugfix: max_sectors must be <= 255 or the wheels tend to come
- *  off in a hurry once you queue things up - Paul G. 02/2001
- */
-
-/* Uncomment the following if you want verbose error reports. */
-/* #define VERBOSE_ERRORS */
-
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/genhd.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/ioport.h>
-#include <linux/mc146818rtc.h> /* CMOS defines */
-#include <linux/init.h>
-#include <linux/blkpg.h>
-#include <linux/hdreg.h>
-
-#define REALLY_SLOW_IO
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-#include "io_ports.h"
-
-#ifdef __arm__
-#undef  HD_IRQ
-#endif
-#include <asm/irq.h>
-#ifdef __arm__
-#define HD_IRQ IRQ_HARDDISK
-#endif
-
-/* Hd controller regster ports */
-
-#define HD_DATA                0x640   /* _CTL when writing */
-#define HD_ERROR       0x642   /* see err-bits */
-#define HD_NSECTOR     0x644   /* nr of sectors to read/write */
-#define HD_SECTOR      0x646   /* starting sector */
-#define HD_LCYL                0x648   /* starting cylinder */
-#define HD_HCYL                0x64a   /* high byte of starting cyl */
-#define HD_CURRENT     0x64c   /* 101dhhhh , d=drive, hhhh=head */
-#define HD_STATUS      0x64e   /* see status-bits */
-#define HD_FEATURE     HD_ERROR        /* same io address, read=error, write=feature */
-#define HD_PRECOMP     HD_FEATURE      /* obsolete use of this port - predates IDE */
-#define HD_COMMAND     HD_STATUS       /* same io address, read=status, write=cmd */
-
-#define HD_CMD         0x74c   /* used for resets */
-#define HD_ALTSTATUS   0x74c   /* same as HD_STATUS but doesn't clear irq */
-
-/* Bits of HD_STATUS */
-#define ERR_STAT               0x01
-#define INDEX_STAT             0x02
-#define ECC_STAT               0x04    /* Corrected error */
-#define DRQ_STAT               0x08
-#define SEEK_STAT              0x10
-#define SERVICE_STAT           SEEK_STAT
-#define WRERR_STAT             0x20
-#define READY_STAT             0x40
-#define BUSY_STAT              0x80
-
-/* Bits for HD_ERROR */
-#define MARK_ERR               0x01    /* Bad address mark */
-#define TRK0_ERR               0x02    /* couldn't find track 0 */
-#define ABRT_ERR               0x04    /* Command aborted */
-#define MCR_ERR                        0x08    /* media change request */
-#define ID_ERR                 0x10    /* ID field not found */
-#define MC_ERR                 0x20    /* media changed */
-#define ECC_ERR                        0x40    /* Uncorrectable ECC error */
-#define BBD_ERR                        0x80    /* pre-EIDE meaning:  block marked bad */
-#define ICRC_ERR               0x80    /* new meaning:  CRC error during transfer */
-
-static spinlock_t hd_lock = SPIN_LOCK_UNLOCKED;
-static struct request_queue *hd_queue;
-
-#define CURRENT elv_next_request(hd_queue)
-
-#define TIMEOUT_VALUE  (6*HZ)
-#define        HD_DELAY        0
-
-#define MAX_ERRORS     16      /* Max read/write errors/sector */
-#define RESET_FREQ      8      /* Reset controller every 8th retry */
-#define RECAL_FREQ      4      /* Recalibrate every 4th retry */
-#define MAX_HD         2
-
-#define STAT_OK                (READY_STAT|SEEK_STAT)
-#define OK_STATUS(s)   (((s)&(STAT_OK|(BUSY_STAT|WRERR_STAT|ERR_STAT)))==STAT_OK)
-
-static void recal_intr(void);
-static void bad_rw_intr(void);
-
-static int reset;
-static int hd_error;
-
-/*
- *  This struct defines the HD's and their types.
- */
-struct hd_i_struct {
-       unsigned int head,sect,cyl,wpcom,lzone,ctl;
-       int unit;
-       int recalibrate;
-       int special_op;
-};
-       
-#ifdef HD_TYPE
-static struct hd_i_struct hd_info[] = { HD_TYPE };
-static int NR_HD = ((sizeof (hd_info))/(sizeof (struct hd_i_struct)));
-#else
-static struct hd_i_struct hd_info[MAX_HD];
-static int NR_HD;
-#endif
-
-static struct gendisk *hd_gendisk[MAX_HD];
-
-static struct timer_list device_timer;
-
-#define TIMEOUT_VALUE (6*HZ)
-
-#define SET_TIMER                                                      \
-       do {                                                            \
-               mod_timer(&device_timer, jiffies + TIMEOUT_VALUE);      \
-       } while (0)
-
-static void (*do_hd)(void) = NULL;
-#define SET_HANDLER(x) \
-if ((do_hd = (x)) != NULL) \
-       SET_TIMER; \
-else \
-       del_timer(&device_timer);
-
-
-#if (HD_DELAY > 0)
-unsigned long last_req;
-
-unsigned long read_timer(void)
-{
-        extern spinlock_t i8253_lock;
-       unsigned long t, flags;
-       int i;
-
-       spin_lock_irqsave(&i8253_lock, flags);
-       t = jiffies * 11932;
-       outb_p(0, PIT_MODE);
-       i = inb_p(PIT_CH0);
-       i |= inb(PIT_CH0) << 8;
-       spin_unlock_irqrestore(&i8253_lock, flags);
-       return(t - i);
-}
-#endif
-
-void __init hd_setup(char *str, int *ints)
-{
-       int hdind = 0;
-
-       if (ints[0] != 3)
-               return;
-       if (hd_info[0].head != 0)
-               hdind=1;
-       hd_info[hdind].head = ints[2];
-       hd_info[hdind].sect = ints[3];
-       hd_info[hdind].cyl = ints[1];
-       hd_info[hdind].wpcom = 0;
-       hd_info[hdind].lzone = ints[1];
-       hd_info[hdind].ctl = (ints[2] > 8 ? 8 : 0);
-       NR_HD = hdind+1;
-}
-
-static void dump_status (const char *msg, unsigned int stat)
-{
-       char *name = CURRENT ?
-                       CURRENT->rq_dev->bd_disk->disk_name :
-                       "hd?";
-#ifdef VERBOSE_ERRORS
-       printk("%s: %s: status=0x%02x { ", name, msg, stat & 0xff);
-       if (stat & BUSY_STAT)   printk("Busy ");
-       if (stat & READY_STAT)  printk("DriveReady ");
-       if (stat & WRERR_STAT)  printk("WriteFault ");
-       if (stat & SEEK_STAT)   printk("SeekComplete ");
-       if (stat & DRQ_STAT)    printk("DataRequest ");
-       if (stat & ECC_STAT)    printk("CorrectedError ");
-       if (stat & INDEX_STAT)  printk("Index ");
-       if (stat & ERR_STAT)    printk("Error ");
-       printk("}\n");
-       if ((stat & ERR_STAT) == 0) {
-               hd_error = 0;
-       } else {
-               hd_error = inb(HD_ERROR);
-               printk("%s: %s: error=0x%02x { ", name, msg, hd_error & 0xff);
-               if (hd_error & BBD_ERR)         printk("BadSector ");
-               if (hd_error & ECC_ERR)         printk("UncorrectableError ");
-               if (hd_error & ID_ERR)          printk("SectorIdNotFound ");
-               if (hd_error & ABRT_ERR)        printk("DriveStatusError ");
-               if (hd_error & TRK0_ERR)        printk("TrackZeroNotFound ");
-               if (hd_error & MARK_ERR)        printk("AddrMarkNotFound ");
-               printk("}");
-               if (hd_error & (BBD_ERR|ECC_ERR|ID_ERR|MARK_ERR)) {
-                       printk(", CHS=%d/%d/%d", (inb(HD_HCYL)<<8) + inb(HD_LCYL),
-                               inb(HD_CURRENT) & 0xf, inb(HD_SECTOR));
-                       if (CURRENT)
-                               printk(", sector=%ld", CURRENT->sector);
-               }
-               printk("\n");
-       }
-#else
-       printk("%s: %s: status=0x%02x.\n", name, msg, stat & 0xff);
-       if ((stat & ERR_STAT) == 0) {
-               hd_error = 0;
-       } else {
-               hd_error = inb(HD_ERROR);
-               printk("%s: %s: error=0x%02x.\n", name, msg, hd_error & 0xff);
-       }
-#endif
-}
-
-void check_status(void)
-{
-       int i = inb(HD_STATUS);
-
-       if (!OK_STATUS(i)) {
-               dump_status("check_status", i);
-               bad_rw_intr();
-       }
-}
-
-static int controller_busy(void)
-{
-       int retries = 100000;
-       unsigned char status;
-
-       do {
-               status = inb(HD_STATUS);
-       } while ((status & BUSY_STAT) && --retries);
-       return status;
-}
-
-static int status_ok(void)
-{
-       unsigned char status = inb(HD_STATUS);
-
-       if (status & BUSY_STAT)
-               return 1;       /* Ancient, but does it make sense??? */
-       if (status & WRERR_STAT)
-               return 0;
-       if (!(status & READY_STAT))
-               return 0;
-       if (!(status & SEEK_STAT))
-               return 0;
-       return 1;
-}
-
-static int controller_ready(unsigned int drive, unsigned int head)
-{
-       int retry = 100;
-
-       do {
-               if (controller_busy() & BUSY_STAT)
-                       return 0;
-               outb(0xA0 | (drive<<4) | head, HD_CURRENT);
-               if (status_ok())
-                       return 1;
-       } while (--retry);
-       return 0;
-}
-
-static void hd_out(struct hd_i_struct *disk,
-                  unsigned int nsect,
-                  unsigned int sect,
-                  unsigned int head,
-                  unsigned int cyl,
-                  unsigned int cmd,
-                  void (*intr_addr)(void))
-{
-       unsigned short port;
-
-#if (HD_DELAY > 0)
-       while (read_timer() - last_req < HD_DELAY)
-               /* nothing */;
-#endif
-       if (reset)
-               return;
-       if (!controller_ready(disk->unit, head)) {
-               reset = 1;
-               return;
-       }
-       SET_HANDLER(intr_addr);
-       outb(disk->ctl,HD_CMD);
-       port=HD_DATA + 2;
-       outb(disk->wpcom>>2, port); port += 2;
-       outb(nsect, port); port += 2;
-       outb(sect, port); port += 2;
-       outb(cyl, port); port += 2;
-       outb(cyl>>8, port); port += 2;
-       outb(0xA0|(disk->unit<<4)|head, port); port += 2;
-       outb(cmd, port);
-}
-
-static void hd_request (void);
-
-static int drive_busy(void)
-{
-       unsigned int i;
-       unsigned char c;
-
-       for (i = 0; i < 500000 ; i++) {
-               c = inb(HD_STATUS);
-               if ((c & (BUSY_STAT | READY_STAT | SEEK_STAT)) == STAT_OK)
-                       return 0;
-       }
-       dump_status("reset timed out", c);
-       return 1;
-}
-
-static void reset_controller(void)
-{
-       int     i;
-
-       outb(4,HD_CMD);
-       for(i = 0; i < 1000; i++) barrier();
-       outb(hd_info[0].ctl & 0x0f,HD_CMD);
-       for(i = 0; i < 1000; i++) barrier();
-       if (drive_busy())
-               printk("hd: controller still busy\n");
-       else if ((hd_error = inb(HD_ERROR)) != 1)
-               printk("hd: controller reset failed: %02x\n",hd_error);
-}
-
-static void reset_hd(void)
-{
-       static int i;
-
-repeat:
-       if (reset) {
-               reset = 0;
-               i = -1;
-               reset_controller();
-       } else {
-               check_status();
-               if (reset)
-                       goto repeat;
-       }
-       if (++i < NR_HD) {
-               struct hd_i_struct *disk = &hd_info[i];
-               disk->special_op = disk->recalibrate = 1;
-               hd_out(disk, disk->sect, disk->sect, disk->head-1,
-                       disk->cyl, WIN_SPECIFY, &reset_hd);
-               if (reset)
-                       goto repeat;
-       } else
-               hd_request();
-}
-
-/*
- * Ok, don't know what to do with the unexpected interrupts: on some machines
- * doing a reset and a retry seems to result in an eternal loop. Right now I
- * ignore it, and just set the timeout.
- *
- * On laptops (and "green" PCs), an unexpected interrupt occurs whenever the
- * drive enters "idle", "standby", or "sleep" mode, so if the status looks
- * "good", we just ignore the interrupt completely.
- */
-void unexpected_hd_interrupt(void)
-{
-       unsigned int stat = inb(HD_STATUS);
-
-       if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) {
-               dump_status ("unexpected interrupt", stat);
-               SET_TIMER;
-       }
-}
-
-/*
- * bad_rw_intr() now tries to be a bit smarter and does things
- * according to the error returned by the controller.
- * -Mika Liljeberg (liljeber@cs.Helsinki.FI)
- */
-static void bad_rw_intr(void)
-{
-       struct request *req = CURRENT;
-       struct hd_i_struct *disk;
-
-       if (!req)
-               return;
-       disk = req->rq_disk->private_data;
-       if (++req->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) {
-               end_request(req, 0);
-               disk->special_op = disk->recalibrate = 1;
-       } else if (req->errors % RESET_FREQ == 0)
-               reset = 1;
-       else if ((hd_error & TRK0_ERR) || req->errors % RECAL_FREQ == 0)
-               disk->special_op = disk->recalibrate = 1;
-       /* Otherwise just retry */
-}
-
-static inline int wait_DRQ(void)
-{
-       int retries = 100000, stat;
-
-       while (--retries > 0)
-               if ((stat = inb(HD_STATUS)) & DRQ_STAT)
-                       return 0;
-       dump_status("wait_DRQ", stat);
-       return -1;
-}
-
-static void read_intr(void)
-{
-       int i, retries = 100000;
-       struct request *req;
-
-       do {
-               i = (unsigned) inb(HD_STATUS);
-               if (i & BUSY_STAT)
-                       continue;
-               if (!OK_STATUS(i))
-                       break;
-               if (i & DRQ_STAT)
-                       goto ok_to_read;
-       } while (--retries > 0);
-       dump_status("read_intr", i);
-       bad_rw_intr();
-       hd_request();
-       return;
-ok_to_read:
-       req = CURRENT;
-       insw(HD_DATA,req->buffer,256);
-       req->sector++;
-       req->buffer += 512;
-       req->errors = 0;
-       i = --req->nr_sectors;
-       --req->current_nr_sectors;
-#ifdef DEBUG
-       printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
-               req->rq_disk->disk_name, req->sector, req->nr_sectors,
-               req->buffer+512);
-#endif
-       if (req->current_nr_sectors <= 0)
-               end_request(req, 1);
-       if (i > 0) {
-               SET_HANDLER(&read_intr);
-               return;
-       }
-       (void) inb(HD_STATUS);
-#if (HD_DELAY > 0)
-       last_req = read_timer();
-#endif
-       if (CURRENT)
-               hd_request();
-       return;
-}
-
-static void write_intr(void)
-{
-       int i;
-       int retries = 100000;
-       struct request *req = CURRENT;
-
-       do {
-               i = (unsigned) inb(HD_STATUS);
-               if (i & BUSY_STAT)
-                       continue;
-               if (!OK_STATUS(i))
-                       break;
-               if ((req->nr_sectors <= 1) || (i & DRQ_STAT))
-                       goto ok_to_write;
-       } while (--retries > 0);
-       dump_status("write_intr", i);
-       bad_rw_intr();
-       hd_request();
-       return;
-ok_to_write:
-       req->sector++;
-       i = --req->nr_sectors;
-       --req->current_nr_sectors;
-       req->buffer += 512;
-       if (!i || (req->bio && req->current_nr_sectors < 1))
-               end_request(req, 1);
-       if (i > 0) {
-               SET_HANDLER(&write_intr);
-               outsw(HD_DATA,req->buffer,256);
-               local_irq_enable();
-       } else {
-#if (HD_DELAY > 0)
-               last_req = read_timer();
-#endif
-               hd_request();
-       }
-       return;
-}
-
-static void recal_intr(void)
-{
-       check_status();
-#if (HD_DELAY > 0)
-       last_req = read_timer();
-#endif
-       hd_request();
-}
-
-/*
- * This is another of the error-routines I don't know what to do with. The
- * best idea seems to just set reset, and start all over again.
- */
-static void hd_times_out(unsigned long dummy)
-{
-       do_hd = NULL;
-
-       if (!CURRENT)
-               return;
-
-       disable_irq(HD_IRQ);
-       local_irq_enable();
-       reset = 1;
-       printk("%s: timeout\n", CURRENT->rq_disk->disk_name);
-       if (++CURRENT->errors >= MAX_ERRORS) {
-#ifdef DEBUG
-               printk("%s: too many errors\n", CURRENT->rq_disk->disk_name);
-#endif
-               end_request(CURRENT, 0);
-       }
-       local_irq_disable();
-       hd_request();
-       enable_irq(HD_IRQ);
-}
-
-int do_special_op(struct hd_i_struct *disk, struct request *req)
-{
-       if (disk->recalibrate) {
-               disk->recalibrate = 0;
-               hd_out(disk, disk->sect,0,0,0,WIN_RESTORE,&recal_intr);
-               return reset;
-       }
-       if (disk->head > 16) {
-               printk ("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name);
-               end_request(req, 0);
-       }
-       disk->special_op = 0;
-       return 1;
-}
-
-/*
- * The driver enables interrupts as much as possible.  In order to do this,
- * (a) the device-interrupt is disabled before entering hd_request(),
- * and (b) the timeout-interrupt is disabled before the sti().
- *
- * Interrupts are still masked (by default) whenever we are exchanging
- * data/cmds with a drive, because some drives seem to have very poor
- * tolerance for latency during I/O. The IDE driver has support to unmask
- * interrupts for non-broken hardware, so use that driver if required.
- */
-static void hd_request(void)
-{
-       unsigned int block, nsect, sec, track, head, cyl;
-       struct hd_i_struct *disk;
-       struct request *req;
-
-       if (do_hd)
-               return;
-repeat:
-       del_timer(&device_timer);
-       local_irq_enable();
-
-       if (!CURRENT) {
-               do_hd = NULL;
-               return;
-       }
-       req = CURRENT;
-
-       if (reset) {
-               local_irq_disable();
-               reset_hd();
-               return;
-       }
-       disk = req->rq_disk->private_data;
-       block = req->sector;
-       nsect = req->nr_sectors;
-       if (block >= get_capacity(req->rq_disk) ||
-           ((block+nsect) > get_capacity(req->rq_disk))) {
-               printk("%s: bad access: block=%d, count=%d\n",
-                       req->rq_disk->disk_name, block, nsect);
-               end_request(req, 0);
-               goto repeat;
-       }
-
-       if (disk->special_op) {
-               if (do_special_op(disk, req))
-                       goto repeat;
-               return;
-       }
-       sec   = block % disk->sect + 1;
-       track = block / disk->sect;
-       head  = track % disk->head;
-       cyl   = track / disk->head;
-#ifdef DEBUG
-       printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n",
-               req->rq_disk->disk_name, (req->cmd == READ)?"read":"writ",
-               cyl, head, sec, nsect, req->buffer);
-#endif
-       if (req->flags & REQ_CMD) {
-               switch (rq_data_dir(req)) {
-               case READ:
-                       hd_out(disk,nsect,sec,head,cyl,WIN_READ,&read_intr);
-                       if (reset)
-                               goto repeat;
-                       break;
-               case WRITE:
-                       hd_out(disk,nsect,sec,head,cyl,WIN_WRITE,&write_intr);
-                       if (reset)
-                               goto repeat;
-                       if (wait_DRQ()) {
-                               bad_rw_intr();
-                               goto repeat;
-                       }
-                       outsw(HD_DATA,req->buffer,256);
-                       break;
-               default:
-                       printk("unknown hd-command\n");
-                       end_request(req, 0);
-                       break;
-               }
-       }
-}
-
-static void do_hd_request (request_queue_t * q)
-{
-       disable_irq(HD_IRQ);
-       hd_request();
-       enable_irq(HD_IRQ);
-}
-
-static int hd_ioctl(struct inode * inode, struct file * file,
-       unsigned int cmd, unsigned long arg)
-{
-       struct hd_i_struct *disk = inode->i_bdev->bd_disk->private_data;
-       struct hd_geometry *loc = (struct hd_geometry *) arg;
-       struct hd_geometry g; 
-
-       if (cmd != HDIO_GETGEO)
-               return -EINVAL;
-       if (!loc)
-               return -EINVAL;
-       g.heads = disk->head;
-       g.sectors = disk->sect;
-       g.cylinders = disk->cyl;
-       g.start = get_start_sect(inode->i_bdev);
-       return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; 
-}
-
-/*
- * Releasing a block device means we sync() it, so that it can safely
- * be forgotten about...
- */
-
-static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       void (*handler)(void) = do_hd;
-
-       do_hd = NULL;
-       del_timer(&device_timer);
-       if (!handler)
-               handler = unexpected_hd_interrupt;
-       handler();
-       local_irq_enable();
-}
-
-static struct block_device_operations hd_fops = {
-       .ioctl =        hd_ioctl,
-};
-
-/*
- * This is the hard disk IRQ description. The SA_INTERRUPT in sa_flags
- * means we run the IRQ-handler with interrupts disabled:  this is bad for
- * interrupt latency, but anything else has led to problems on some
- * machines.
- *
- * We enable interrupts in some of the routines after making sure it's
- * safe.
- */
-
-static int __init hd_init(void)
-{
-       int drive;
-       if (register_blkdev(HD_MAJOR,"hd")) {
-               printk("hd: unable to get major %d for hard disk\n",HD_MAJOR);
-               return -1;
-       }
-       hd_queue = blk_init_queue(do_hd_request, &hd_lock);
-       if (!hd_queue) {
-               unregister_blkdev(HD_MAJOR,"hd");
-               return -1;
-       }
-       blk_queue_max_sectors(hd_queue, 255);
-       init_timer(&device_timer);
-       device_timer.function = hd_times_out;
-       blk_queue_hardsect_size(hd_queue, 512);
-
-#ifdef __i386__
-       if (!NR_HD) {
-               extern struct drive_info drive_info;
-               unsigned char *BIOS = (unsigned char *) &drive_info;
-               unsigned long flags;
-#ifndef CONFIG_X86_PC9800
-               int cmos_disks;
-#endif
-
-               for (drive=0 ; drive<2 ; drive++) {
-                       hd_info[drive].cyl = *(unsigned short *) BIOS;
-                       hd_info[drive].head = *(3+BIOS);
-                       hd_info[drive].sect = *(2+BIOS);
-                       hd_info[drive].wpcom = 0;
-                       hd_info[drive].ctl = *(3+BIOS) > 8 ? 8 : 0;
-                       hd_info[drive].lzone = *(unsigned short *) BIOS;
-                       if (hd_info[drive].cyl && NR_HD == drive)
-                               NR_HD++;
-                       BIOS += 6;
-               }
-
-       }
-#endif /* __i386__ */
-#ifdef __arm__
-       if (!NR_HD) {
-               /* We don't know anything about the drive.  This means
-                * that you *MUST* specify the drive parameters to the
-                * kernel yourself.
-                */
-               printk("hd: no drives specified - use hd=cyl,head,sectors"
-                       " on kernel command line\n");
-       }
-#endif
-       if (!NR_HD)
-               goto out;
-
-       for (drive=0 ; drive < NR_HD ; drive++) {
-               struct gendisk *disk = alloc_disk(64);
-               struct hd_i_struct *p = &hd_info[drive];
-               if (!disk)
-                       goto Enomem;
-               disk->major = HD_MAJOR;
-               disk->first_minor = drive << 6;
-               disk->fops = &hd_fops;
-               sprintf(disk->disk_name, "hd%c", 'a'+drive);
-               disk->private_data = p;
-               set_capacity(disk, p->head * p->sect * p->cyl);
-               disk->queue = hd_queue;
-               p->unit = drive;
-               hd_gendisk[drive] = disk;
-               printk ("%s: %luMB, CHS=%d/%d/%d\n",
-                       disk->disk_name, (unsigned long)get_capacity(disk)/2048,
-                       p->cyl, p->head, p->sect);
-       }
-
-       if (request_irq(HD_IRQ, hd_interrupt, SA_INTERRUPT, "hd", NULL)) {
-               printk("hd: unable to get IRQ%d for the hard disk driver\n",
-                       HD_IRQ);
-               goto out1;
-       }
-
-       if (!request_region(HD_DATA, 2, "hd(data)")) {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
-               NR_HD = 0;
-               free_irq(HD_IRQ, NULL);
-               return;
-       }
-
-       if (!request_region(HD_DATA + 2, 1, "hd"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
-               goto out2;
-       }
-
-       if (!request_region(HD_DATA + 4, 1, "hd"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
-               goto out3;
-       }
-
-       if (!request_region(HD_DATA + 6, 1, "hd"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
-               goto out4;
-       }
-
-       if (!request_region(HD_DATA + 8, 1, "hd"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
-               goto out5;
-       }
-
-       if (!request_region(HD_DATA + 10, 1, "hd"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
-               goto out6;
-       }
-
-       if (!request_region(HD_DATA + 12, 1, "hd"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
-               goto out7;
-       }
-
-       if (!request_region(HD_CMD, 1, "hd(cmd)"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_CMD);
-               goto out8;
-       }
-
-       if (!request_region(HD_CMD + 2, 1, "hd(cmd)"))
-       {
-               printk(KERN_WARNING "hd: port 0x%x busy\n", HD_CMD);
-               goto out9;
-       }
-
-       for(drive=0; drive < NR_HD; drive++)
-               add_disk(hd_gendisk[drive]);
-       return 0;
-
-out9:
-       release_region(HD_CMD, 1);
-out8:
-       release_region(HD_DATA + 12, 1);
-out7:
-       release_region(HD_DATA + 10, 1);
-out6:
-       release_region(HD_DATA + 8, 1);
-out5:
-       release_region(HD_DATA + 6, 1);
-out4:
-       release_region(HD_DATA + 4, 1);
-out3:
-       release_region(HD_DATA + 2, 1);
-out2:
-       release_region(HD_DATA, 2);
-       free_irq(HD_IRQ, NULL);
-out1:
-       for (drive = 0; drive < NR_HD; drive++)
-               put_disk(hd_gendisk[drive]);
-       NR_HD = 0;
-out:
-       del_timer(&device_timer);
-       unregister_blkdev(HD_MAJOR,"hd");
-       blk_cleanup_queue(hd_queue);
-       return -1;
-Enomem:
-       while (drive--)
-               put_disk(hd_gendisk[drive]);
-       goto out;
-}
-
-static int parse_hd_setup (char *line) {
-       int ints[6];
-
-       (void) get_options(line, ARRAY_SIZE(ints), ints);
-       hd_setup(NULL, ints);
-
-       return 1;
-}
-__setup("hd=", parse_hd_setup);
-
-module_init(hd_init);
diff --git a/drivers/ide/legacy/pc9800.c b/drivers/ide/legacy/pc9800.c
deleted file mode 100644 (file)
index 6b91a18..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *  ide_pc9800.c
- *
- *  Copyright (C) 1997-2000  Linux/98 project,
- *                          Kyoto University Microcomputer Club.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/ioport.h>
-#include <linux/ide.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/pc9800.h>
-
-#define PC9800_IDE_BANKSELECT  0x432
-
-#undef PC9800_IDE_DEBUG
-
-static void pc9800_select(ide_drive_t *drive)
-{
-#ifdef PC9800_IDE_DEBUG
-       byte old;
-
-       /* Too noisy: */
-       /* printk(KERN_DEBUG "pc9800_select(%s)\n", drive->name); */
-
-       outb(0x80, PC9800_IDE_BANKSELECT);
-       old = inb(PC9800_IDE_BANKSELECT);
-       if (old != HWIF(drive)->index)
-               printk(KERN_DEBUG "ide-pc9800: switching bank #%d -> #%d\n",
-                       old, HWIF(drive)->index);
-#endif
-       outb(HWIF(drive)->index, PC9800_IDE_BANKSELECT);
-}
-
-void __init ide_probe_for_pc9800(void)
-{
-       u8 saved_bank;
-
-       if (!PC9800_9821_P() /* || !PC9821_IDEIF_DOUBLE_P() */)
-               return;
-
-       if (!request_region(PC9800_IDE_BANKSELECT, 1, "ide0/1 bank")) {
-               printk(KERN_ERR
-                       "ide: bank select port (%#x) is already occupied!\n",
-                       PC9800_IDE_BANKSELECT);
-               return;
-       }
-
-       /* Do actual probing. */
-       if ((saved_bank = inb(PC9800_IDE_BANKSELECT)) == (u8) ~0
-           || (outb(saved_bank ^ 1, PC9800_IDE_BANKSELECT),
-               /* Next outb is dummy for reading status. */
-               outb(0x80, PC9800_IDE_BANKSELECT),
-               inb(PC9800_IDE_BANKSELECT) != (saved_bank ^ 1))) {
-               printk(KERN_INFO
-                       "ide: pc9800 type bank selecting port not found\n");
-               release_region(PC9800_IDE_BANKSELECT, 1);
-               return;
-       }
-
-       /* Restore original value, just in case. */
-       outb(saved_bank, PC9800_IDE_BANKSELECT);
-
-       /* These ports are reseved by IDE I/F.  */
-       if (!request_region(0x430, 1, "ide") ||
-           !request_region(0x435, 1, "ide")) {
-               printk(KERN_WARNING
-                       "ide: IO port 0x430 and 0x435 are reserved for IDE"
-                       " the card using these ports may not work\n");
-       }
-
-       if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET] == HD_DATA &&
-           ide_hwifs[1].io_ports[IDE_DATA_OFFSET] == HD_DATA) {
-               ide_hwifs[0].chipset = ide_pc9800;
-               ide_hwifs[0].mate = &ide_hwifs[1];
-               ide_hwifs[0].selectproc = pc9800_select;
-               ide_hwifs[1].chipset = ide_pc9800;
-               ide_hwifs[1].mate = &ide_hwifs[0];
-               ide_hwifs[1].selectproc = pc9800_select;
-       }
-}
diff --git a/drivers/ide/pci/alim15x3.h b/drivers/ide/pci/alim15x3.h
deleted file mode 100644 (file)
index 439bd50..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef ALI15X3_H
-#define ALI15X3_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_ALI_TIMINGS
-
-static unsigned int init_chipset_ali15x3(struct pci_dev *, const char *);
-static void init_hwif_common_ali15x3(ide_hwif_t *);
-static void init_hwif_ali15x3(ide_hwif_t *);
-static void init_dma_ali15x3(ide_hwif_t *, unsigned long);
-
-static ide_pci_device_t ali15x3_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_AL,
-               .device         = PCI_DEVICE_ID_AL_M5229,
-               .name           = "ALI15X3",
-               .init_chipset   = init_chipset_ali15x3,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_ali15x3,
-               .init_dma       = init_dma_ali15x3,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* ALI15X3 */
diff --git a/drivers/ide/pci/amd74xx.h b/drivers/ide/pci/amd74xx.h
deleted file mode 100644 (file)
index cb265c8..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-#ifndef AMD74XX_H
-#define AMD74XX_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_AMD_TIMINGS
-
-static unsigned int init_chipset_amd74xx(struct pci_dev *, const char *);
-static void init_hwif_amd74xx(ide_hwif_t *);
-
-static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_AMD,
-               .device         = PCI_DEVICE_ID_AMD_COBRA_7401,
-               .name           = "AMD7401",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },{     /* 1 */
-               .vendor         = PCI_VENDOR_ID_AMD,
-               .device         = PCI_DEVICE_ID_AMD_VIPER_7409,
-               .name           = "AMD7409",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },{     /* 2 */
-               .vendor         = PCI_VENDOR_ID_AMD,
-               .device         = PCI_DEVICE_ID_AMD_VIPER_7411,
-               .name           = "AMD7411",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },{     /* 3 */
-               .vendor         = PCI_VENDOR_ID_AMD,
-               .device         = PCI_DEVICE_ID_AMD_OPUS_7441,
-               .name           = "AMD7441",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },{     /* 4 */
-               .vendor         = PCI_VENDOR_ID_AMD,
-               .device         = PCI_DEVICE_ID_AMD_8111_IDE,
-               .name           = "AMD8111",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .autodma        = AUTODMA,
-               .channels       = 2,
-               .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },
-       {       /* 5 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE_IDE,
-               .name           = "NFORCE",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },
-       {       /* 6 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE,
-               .name           = "NFORCE2",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },
-       {       /* 7 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE,
-               .name           = "NFORCE2S",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-       },
-       {       /* 8 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
-               .name           = "NFORCE2S-SATA",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-       },
-       {       /* 9 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE,
-               .name           = "NFORCE3",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-       },
-       {       /* 10 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE,
-               .name           = "NFORCE3S",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-       },
-       {       /* 11 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
-               .name           = "NFORCE3S-SATA",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-       },
-       {       /* 12 */
-               .vendor         = PCI_VENDOR_ID_NVIDIA,
-               .device         = PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2,
-               .name           = "NFORCE3S-SATA2",
-               .init_chipset   = init_chipset_amd74xx,
-               .init_hwif      = init_hwif_amd74xx,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
-               .bootable       = ON_BOARD,
-       },
-       {
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* AMD74XX_H */
diff --git a/drivers/ide/pci/cmd640.h b/drivers/ide/pci/cmd640.h
deleted file mode 100644 (file)
index 28b6e04..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef CMD640_H
-#define CMD640_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define IDE_IGNORE      ((void *)-1)
-
-static ide_pci_device_t cmd640_chipsets[] __initdata = {
-       {
-               .vendor         = PCI_VENDOR_ID_CMD,
-               .device         = PCI_DEVICE_ID_CMD_640,
-               .name           = "CMD640",
-               .init_setup     = NULL,
-               .init_chipset   = NULL,
-               .init_iops      = NULL,
-               .init_hwif      = IDE_IGNORE,
-               .init_dma       = NULL,
-               .channels       = 2,
-               .autodma        = NODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .bootable       = EOL,
-       }
-}
-
-#endif /* CMD640_H */
index 5882693..8ddd2ce 100644 (file)
@@ -290,7 +290,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
                return 1;
        }
        pci_set_master(dev);
-       pci_set_dma_mask(dev, 0xFFFFFFFF);
+       if (pci_set_dma_mask(dev, 0xFFFFFFFF)) {
+               printk(KERN_WARNING "cs5520: No suitable DMA available.\n");
+               return -ENODEV;
+       }
        init_chipset_cs5520(dev, d->name);
 
        index.all = 0xf0f0;
diff --git a/drivers/ide/pci/cs5520.h b/drivers/ide/pci/cs5520.h
deleted file mode 100644 (file)
index 21e8cb3..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef CS5520_H
-#define CS5520_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_CS5520_TIMINGS
-
-static unsigned int init_chipset_cs5520(struct pci_dev *, const char *);
-static void init_hwif_cs5520(ide_hwif_t *);
-static void cs5520_init_setup_dma(struct pci_dev *dev, struct ide_pci_device_s *d, ide_hwif_t *hwif);
-
-static ide_pci_device_t cyrix_chipsets[] __devinitdata = {
-       {
-               .vendor         = PCI_VENDOR_ID_CYRIX,
-               .device         = PCI_DEVICE_ID_CYRIX_5510,
-               .name           = "Cyrix 5510",
-               .init_chipset   = init_chipset_cs5520,
-               .init_setup_dma = cs5520_init_setup_dma,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_cs5520,
-               .isa_ports      = 1,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },
-       {
-               .vendor         = PCI_VENDOR_ID_CYRIX,
-               .device         = PCI_DEVICE_ID_CYRIX_5520,
-               .name           = "Cyrix 5520",
-               .init_chipset   = init_chipset_cs5520,
-               .init_setup_dma = cs5520_init_setup_dma,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_cs5520,
-               .isa_ports      = 1,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       }
-};
-
-
-#endif /* CS5520_H */
-
-
diff --git a/drivers/ide/pci/cs5530.h b/drivers/ide/pci/cs5530.h
deleted file mode 100644 (file)
index 89f448e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef CS5530_H
-#define CS5530_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_CS5530_TIMINGS
-
-static unsigned int init_chipset_cs5530(struct pci_dev *, const char *);
-static void init_hwif_cs5530(ide_hwif_t *);
-
-static ide_pci_device_t cs5530_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_CYRIX,
-               .device         = PCI_DEVICE_ID_CYRIX_5530_IDE,
-               .name           = "CS5530",
-               .init_chipset   = init_chipset_cs5530,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_cs5530,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* CS5530_H */
diff --git a/drivers/ide/pci/ns87415.h b/drivers/ide/pci/ns87415.h
deleted file mode 100644 (file)
index 597803e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef NS87415_H
-#define NS87415_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static void init_hwif_ns87415(ide_hwif_t *);
-
-static ide_pci_device_t ns87415_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_NS,
-               .device         = PCI_DEVICE_ID_NS_87415,
-               .name           = "NS87415",
-               .init_chipset   = NULL,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_ns87415,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* NS87415_H */
diff --git a/drivers/ide/pci/rz1000.h b/drivers/ide/pci/rz1000.h
deleted file mode 100644 (file)
index 30823af..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef RZ100X_H
-#define RZ100X_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static void init_hwif_rz1000(ide_hwif_t *);
-
-static ide_pci_device_t rz1000_chipsets[] __devinitdata = {
-{
-               .vendor         = PCI_VENDOR_ID_PCTECH,
-               .device         = PCI_DEVICE_ID_PCTECH_RZ1000,
-               .name           = "RZ1000",
-               .init_chipset   = NULL,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_rz1000,
-               .init_dma       = NULL,
-               .channels       = 2,
-               .autodma        = NODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = PCI_VENDOR_ID_PCTECH,
-               .device         = PCI_DEVICE_ID_PCTECH_RZ1001,
-               .name           = "RZ1001",
-               .init_chipset   = NULL,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_rz1000,
-               .init_dma       = NULL,
-               .channels       = 2,
-               .autodma        = NODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* RZ100X_H */
diff --git a/drivers/ide/pci/sc1200.h b/drivers/ide/pci/sc1200.h
deleted file mode 100644 (file)
index dc422a8..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef SC1200_H
-#define SC1200_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_SC1200_TIMINGS
-
-static unsigned int init_chipset_sc1200(struct pci_dev *, const char *);
-static void init_hwif_sc1200(ide_hwif_t *);
-
-static ide_pci_device_t sc1200_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_NS,
-               .device         = PCI_DEVICE_ID_NS_SCx200_IDE,
-               .name           = "SC1200",
-               .init_chipset   = init_chipset_sc1200,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_sc1200,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* SC1200_H */
diff --git a/drivers/ide/pci/siimage.h b/drivers/ide/pci/siimage.h
deleted file mode 100644 (file)
index a47aae5..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef SIIMAGE_H
-#define SIIMAGE_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#include <asm/io.h>
-
-#define DISPLAY_SIIMAGE_TIMINGS
-
-#undef SIIMAGE_VIRTUAL_DMAPIO
-#undef SIIMAGE_BUFFERED_TASKFILE
-#undef SIIMAGE_LARGE_DMA
-
-#define SII_DEBUG 0
-
-#if SII_DEBUG
-#define siiprintk(x...)        printk(x)
-#else
-#define siiprintk(x...)
-#endif
-
-static unsigned int init_chipset_siimage(struct pci_dev *, const char *);
-static void init_iops_siimage(ide_hwif_t *);
-static void init_hwif_siimage(ide_hwif_t *);
-
-static ide_pci_device_t siimage_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_CMD,
-               .device         = PCI_DEVICE_ID_SII_680,
-               .name           = "SiI680",
-               .init_chipset   = init_chipset_siimage,
-               .init_iops      = init_iops_siimage,
-               .init_hwif      = init_hwif_siimage,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{     /* 1 */
-               .vendor         = PCI_VENDOR_ID_CMD,
-               .device         = PCI_DEVICE_ID_SII_3112,
-               .name           = "SiI3112 Serial ATA",
-               .init_chipset   = init_chipset_siimage,
-               .init_iops      = init_iops_siimage,
-               .init_hwif      = init_hwif_siimage,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{     /* 2 */
-               .vendor         = PCI_VENDOR_ID_CMD,
-               .device         = PCI_DEVICE_ID_SII_1210SA,
-               .name           = "Adaptec AAR-1210SA",
-               .init_chipset   = init_chipset_siimage,
-               .init_iops      = init_iops_siimage,
-               .init_hwif      = init_hwif_siimage,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* SIIMAGE_H */
diff --git a/drivers/ide/pci/sis5513.h b/drivers/ide/pci/sis5513.h
deleted file mode 100644 (file)
index 79f3aa8..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef SIS5513_H
-#define SIS5513_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_SIS_TIMINGS
-
-static unsigned int init_chipset_sis5513(struct pci_dev *, const char *);
-static void init_hwif_sis5513(ide_hwif_t *);
-
-static ide_pci_device_t sis5513_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_SI,
-               .device         = PCI_DEVICE_ID_SI_5513,
-               .name           = "SIS5513",
-               .init_chipset   = init_chipset_sis5513,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_sis5513,
-               .channels       = 2,
-               .autodma        = NOAUTODMA,
-               .enablebits     = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
-               .bootable       = ON_BOARD,
-               .extra          = 0
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* SIS5513_H */
diff --git a/drivers/ide/pci/sl82c105.h b/drivers/ide/pci/sl82c105.h
deleted file mode 100644 (file)
index f71ee70..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef W82C105_H
-#define W82C105_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static unsigned int init_chipset_sl82c105(struct pci_dev *, const char *);
-static void init_hwif_sl82c105(ide_hwif_t *);
-static void init_dma_sl82c105(ide_hwif_t *, unsigned long);
-
-static ide_pci_device_t sl82c105_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_WINBOND,
-               .device         = PCI_DEVICE_ID_WINBOND_82C105,
-               .name           = "W82C105",
-               .init_chipset   = init_chipset_sl82c105,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_sl82c105,
-               .init_dma       = init_dma_sl82c105,
-               .channels       = 2,
-               .autodma        = NOAUTODMA,
-               .enablebits     = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* W82C105_H */
diff --git a/drivers/ide/pci/slc90e66.h b/drivers/ide/pci/slc90e66.h
deleted file mode 100644 (file)
index 2f15858..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef SLC90E66_H
-#define SLC90E66_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_SLC90E66_TIMINGS
-
-#define SLC90E66_DEBUG_DRIVE_INFO      0
-
-static unsigned int init_chipset_slc90e66(struct pci_dev *, const char *);
-static void init_hwif_slc90e66(ide_hwif_t *);
-
-static ide_pci_device_t slc90e66_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_EFAR,
-               .device         = PCI_DEVICE_ID_EFAR_SLC90E66_1,
-               .name           = "SLC90E66",
-               .init_chipset   = init_chipset_slc90e66,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_slc90e66,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* SLC90E66_H */
diff --git a/drivers/ide/pci/triflex.h b/drivers/ide/pci/triflex.h
deleted file mode 100644 (file)
index 7f6f737..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* 
- * triflex.h
- *
- * Copyright (C) 2002 Hewlett-Packard Development Group, L.P.
- * Author: Torben Mathiasen <torben.mathiasen@hp.com>
- *
- */
-#ifndef TRIFLEX_H
-#define TRIFLEX_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static unsigned int __devinit init_chipset_triflex(struct pci_dev *, const char *);
-static void init_hwif_triflex(ide_hwif_t *);
-
-static ide_pci_device_t triflex_devices[] __devinitdata = {
-       {
-               .vendor         = PCI_VENDOR_ID_COMPAQ,
-               .device         = PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE,
-               .name           = "TRIFLEX",
-               .init_chipset   = init_chipset_triflex,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_triflex,
-               .channels       = 2,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
-               .bootable       = ON_BOARD,
-       },{     
-               .bootable       = EOL,
-       }
-};
-
-static struct pci_device_id triflex_pci_tbl[] = {
-       { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE, PCI_ANY_ID, 
-               PCI_ANY_ID, 0, 0, 0 },
-       { 0, },
-};
-MODULE_DEVICE_TABLE(pci, triflex_pci_tbl);
-
-#endif /* TRIFLEX_H */
diff --git a/drivers/ide/pci/trm290.h b/drivers/ide/pci/trm290.h
deleted file mode 100644 (file)
index e18b29e..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef TRM290_H
-#define TRM290_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-extern void init_hwif_trm290(ide_hwif_t *);
-
-static ide_pci_device_t trm290_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_TEKRAM,
-               .device         = PCI_DEVICE_ID_TEKRAM_DC290,
-               .name           = "TRM290",
-               .init_chipset   = NULL,
-               .init_iops      = NULL,
-               .init_hwif      = init_hwif_trm290,
-               .init_dma       = NULL,
-               .channels       = 2,
-               .autodma        = NOAUTODMA,
-               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* TRM290_H */
diff --git a/drivers/ide/pci/via82cxxx.h b/drivers/ide/pci/via82cxxx.h
deleted file mode 100644 (file)
index a47f040..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef VIA82CXXX_H
-#define VIA82CXXX_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_VIA_TIMINGS
-
-static unsigned int init_chipset_via82cxxx(struct pci_dev *, const char *);
-static void init_hwif_via82cxxx(ide_hwif_t *);
-
-static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
-       {       /* 0 */
-               .vendor         = PCI_VENDOR_ID_VIA,
-               .device         = PCI_DEVICE_ID_VIA_82C576_1,
-               .name           = "VP_IDE",
-               .init_chipset   = init_chipset_via82cxxx,
-               .init_hwif      = init_hwif_via82cxxx,
-               .channels       = 2,
-               .autodma        = NOAUTODMA,
-               .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{     /* 1 */
-               .vendor         = PCI_VENDOR_ID_VIA,
-               .device         = PCI_DEVICE_ID_VIA_82C586_1,
-               .name           = "VP_IDE",
-               .init_chipset   = init_chipset_via82cxxx,
-               .init_hwif      = init_hwif_via82cxxx,
-               .channels       = 2,
-               .autodma        = NOAUTODMA,
-               .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD,
-               .extra          = 0,
-       },{
-               .vendor         = 0,
-               .device         = 0,
-               .channels       = 0,
-               .bootable       = EOL,
-       }
-};
-
-#endif /* VIA82CXXX_H */
diff --git a/drivers/ide/ppc/swarm.c b/drivers/ide/ppc/swarm.c
deleted file mode 100644 (file)
index d54a555..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2001 Broadcom Corporation
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-/*  Derived loosely from ide-pmac.c, so:
- *  
- *  Copyright (C) 1998 Paul Mackerras.
- *  Copyright (C) 1995-1998 Mark Lord
- */
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/ide.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/sibyte/sb1250_int.h>
-
-#define __IDE_SWARM_C
-
-#include <asm/sibyte/swarm_ide.h>
-
-void __init swarm_ide_probe(void)
-{
-       int i;
-       ide_hwif_t *hwif;
-       /* 
-        * Find the first untaken slot in hwifs 
-        */
-       for (i = 0; i < MAX_HWIFS; i++) {
-               if (!ide_hwifs[i].io_ports[IDE_DATA_OFFSET]) {
-                       break;
-               }
-       }
-       if (i == MAX_HWIFS) {
-               printk("No space for SWARM onboard IDE driver in ide_hwifs[].  Not enabled.\n");
-               return;
-       }
-
-       /* Set up our stuff */
-       hwif = &ide_hwifs[i];
-       hwif->hw.io_ports[IDE_DATA_OFFSET]    = SWARM_IDE_REG(0x1f0);
-       hwif->hw.io_ports[IDE_ERROR_OFFSET]   = SWARM_IDE_REG(0x1f1);
-       hwif->hw.io_ports[IDE_NSECTOR_OFFSET] = SWARM_IDE_REG(0x1f2);
-       hwif->hw.io_ports[IDE_SECTOR_OFFSET]  = SWARM_IDE_REG(0x1f3);
-       hwif->hw.io_ports[IDE_LCYL_OFFSET]    = SWARM_IDE_REG(0x1f4);
-       hwif->hw.io_ports[IDE_HCYL_OFFSET]    = SWARM_IDE_REG(0x1f5);
-       hwif->hw.io_ports[IDE_SELECT_OFFSET]  = SWARM_IDE_REG(0x1f6);
-       hwif->hw.io_ports[IDE_STATUS_OFFSET]  = SWARM_IDE_REG(0x1f7);
-       hwif->hw.io_ports[IDE_CONTROL_OFFSET] = SWARM_IDE_REG(0x3f6);
-       hwif->hw.io_ports[IDE_IRQ_OFFSET]     = SWARM_IDE_REG(0x3f7);
-//     hwif->hw->ack_intr                    = swarm_ide_ack_intr;
-       hwif->hw.irq                          = SWARM_IDE_INT;
-#if 0
-       hwif->iops                            = swarm_iops;
-#else
-       hwif->OUTB      = hwif->OUTBP         = swarm_outb;
-       hwif->OUTW      = hwif->OUTWP         = swarm_outw;
-       hwif->OUTL      = hwif->OUTLP         = swarm_outl;
-       hwif->OUTSW     = hwif->OUTSWP        = swarm_outsw;
-       hwif->OUTSL     = hwif->OUTSLP        = swarm_outsl;
-       hwif->INB       = hwif->INBP          = swarm_inb;
-       hwif->INW       = hwif->INWP          = swarm_inw;
-       hwif->INL       = hwif->INLP          = swarm_inl;
-       hwif->INSW      = hwif->INSWP         = swarm_insw;
-       hwif->INSL      = hwif->INSLP         = swarm_insl;
-#endif
-#if 0
-       hwif->pioops                          = swarm_pio_ops;
-#else
-       hwif->ata_input_data                  = swarm_ata_input_data;
-       hwif->ata_output_data                 = swarm_ata_output_data;
-       hwif->atapi_input_bytes               = swarm_atapi_input_bytes;
-       hwif->atapi_output_bytes              = swarm_atapi_output_bytes;
-#endif
-       memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
-       hwif->irq                             = hwif->hw.irq;
-       printk("SWARM onboard IDE configured as device %i\n", i);
-
-#ifndef HWIF_PROBE_CLASSIC_METHOD
-       probe_hwif_init(hwif->index);
-#endif /* HWIF_PROBE_CLASSIC_METHOD */
-
-}
-
diff --git a/drivers/input/keyboard/98kbd.c b/drivers/input/keyboard/98kbd.c
deleted file mode 100644 (file)
index 970a5ae..0000000
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- *  drivers/input/keyboard/98kbd.c
- *
- *  PC-9801 keyboard driver for Linux
- *
- *    Based on atkbd.c and xtkbd.c written by Vojtech Pavlik
- *
- *  Copyright (c) 2002 Osamu Tomita
- *  Copyright (c) 1999-2001 Vojtech Pavlik
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/input.h>
-#include <linux/init.h>
-#include <linux/serio.h>
-
-#include <asm/io.h>
-#include <asm/pc9800.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9801 keyboard driver");
-MODULE_LICENSE("GPL");
-
-#define KBD98_KEY      0x7f
-#define KBD98_RELEASE  0x80
-
-static unsigned char kbd98_keycode[256] = {
-         1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 43, 14, 15,
-        16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 41, 26, 28, 30, 31, 32,
-        33, 34, 35, 36, 37, 38, 39, 40, 27, 44, 45, 46, 47, 48, 49, 50,
-        51, 52, 53, 12, 57, 92,109,104,110,111,103,105,106,108,102,107,
-        74, 98, 71, 72, 73, 55, 75, 76, 77, 78, 79, 80, 81,117, 82,121,
-        83, 94, 87, 88,183,184,185,  0,  0,  0,  0,  0,  0,  0,102,  0,
-        99,133, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,  0,  0,  0,  0,
-        54, 58, 42, 56, 29
-};
-
-struct jis_kbd_conv {
-       unsigned char scancode;
-       struct {
-               unsigned char shift;
-               unsigned char keycode;
-       } emul[2];
-};
-
-static struct jis_kbd_conv kbd98_jis[] = {
-       {0x02, {{0,   3}, {1,  40}}},
-       {0x06, {{0,   7}, {1,   8}}},
-       {0x07, {{0,   8}, {0,  40}}},
-       {0x08, {{0,   9}, {1,  10}}},
-       {0x09, {{0,  10}, {1,  11}}},
-       {0x0a, {{0,  11}, {1, 255}}},
-       {0x0b, {{0,  12}, {0,  13}}},
-       {0x0c, {{1,   7}, {0,  41}}},
-       {0x1a, {{1,   3}, {1,  41}}},
-       {0x26, {{0,  39}, {1,  13}}},
-       {0x27, {{1,  39}, {1,   9}}},
-       {0x33, {{0, 255}, {1,  12}}},
-       {0xff, {{0, 255}, {1, 255}}}    /* terminater */
-};
-
-#define KBD98_CMD_SETEXKEY     0x1095  /* Enable/Disable Windows, Appli key */
-#define KBD98_CMD_SETRATE      0x109c  /* Set typematic rate */
-#define KBD98_CMD_SETLEDS      0x109d  /* Set keyboard leds */
-#define KBD98_CMD_GETLEDS      0x119d  /* Get keyboard leds */
-#define KBD98_CMD_GETID                0x019f
-
-#define KBD98_RET_ACK          0xfa
-#define KBD98_RET_NAK          0xfc    /* Command NACK, send the cmd again */
-
-#define KBD98_KEY_JIS_EMUL     253
-#define KBD98_KEY_UNKNOWN      254
-#define KBD98_KEY_NULL         255
-
-static char *kbd98_name = "PC-9801 Keyboard";
-
-struct kbd98 {
-       unsigned char keycode[256];
-       struct input_dev dev;
-       struct serio *serio;
-       char phys[32];
-       unsigned char cmdbuf[4];
-       unsigned char cmdcnt;
-       signed char ack;
-       unsigned char shift;
-       struct {
-               unsigned char scancode;
-               unsigned char keycode;
-       } emul;
-       struct jis_kbd_conv jis[16];
-};
-
-irqreturn_t kbd98_interrupt(struct serio *serio, unsigned char data,
-                           unsigned int flags, struct pt_regs *regs)
-{
-       struct kbd98 *kbd98 = serio->private;
-       unsigned char scancode, keycode;
-       int press, i;
-
-       switch (data) {
-               case KBD98_RET_ACK:
-                       kbd98->ack = 1;
-                       goto out;
-               case KBD98_RET_NAK:
-                       kbd98->ack = -1;
-                       goto out;
-       }
-
-       if (kbd98->cmdcnt) {
-               kbd98->cmdbuf[--kbd98->cmdcnt] = data;
-               goto out;
-       }
-
-       scancode = data & KBD98_KEY;
-       keycode = kbd98->keycode[scancode];
-       press = !(data & KBD98_RELEASE);
-       if (kbd98->emul.scancode != KBD98_KEY_UNKNOWN
-           && scancode != kbd98->emul.scancode) {
-               input_report_key(&kbd98->dev, kbd98->emul.keycode, 0);
-               kbd98->emul.scancode = KBD98_KEY_UNKNOWN;
-       }
-
-       if (keycode == KEY_RIGHTSHIFT)
-               kbd98->shift = press;
-
-       switch (keycode) {
-               case KEY_2:
-               case KEY_6:
-               case KEY_7:
-               case KEY_8:
-               case KEY_9:
-               case KEY_0:
-               case KEY_MINUS:
-               case KEY_EQUAL:
-               case KEY_GRAVE:
-               case KEY_SEMICOLON:
-               case KEY_APOSTROPHE:
-                       /* emulation: JIS keyboard to US101 keyboard */
-                       i = 0;
-                       while (kbd98->jis[i].scancode != 0xff) {
-                               if (scancode == kbd98->jis[i].scancode)
-                                       break;
-                               i ++;
-                       }
-
-                       keycode = kbd98->jis[i].emul[kbd98->shift].keycode;
-                       if (keycode == KBD98_KEY_NULL)
-                               break;
-
-                       if (press) {
-                               kbd98->emul.scancode = scancode;
-                               kbd98->emul.keycode = keycode;
-                               if (kbd98->jis[i].emul[kbd98->shift].shift
-                                                               != kbd98->shift)
-                                       input_report_key(&kbd98->dev,
-                                                       KEY_RIGHTSHIFT,
-                                                       !(kbd98->shift));
-                       }
-
-                       input_report_key(&kbd98->dev, keycode, press);
-                       if (!press) {
-                               if (kbd98->jis[i].emul[kbd98->shift].shift
-                                                               != kbd98->shift)
-                                       input_report_key(&kbd98->dev,
-                                                       KEY_RIGHTSHIFT,
-                                                       kbd98->shift);
-                               kbd98->emul.scancode = KBD98_KEY_UNKNOWN;
-                       }
-
-                       input_sync(&kbd98->dev);
-                       break;
-
-               case KEY_CAPSLOCK:
-                       input_report_key(&kbd98->dev, keycode, 1);
-                       input_sync(&kbd98->dev);
-                       input_report_key(&kbd98->dev, keycode, 0);
-                       input_sync(&kbd98->dev);
-                       break;
-
-               case KBD98_KEY_NULL:
-                       break;
-
-               case 0:
-                       printk(KERN_WARNING "kbd98.c: Unknown key (scancode %#x) %s.\n",
-                               data & KBD98_KEY, data & KBD98_RELEASE ? "released" : "pressed");
-                       break;
-
-               default:
-                       input_report_key(&kbd98->dev, keycode, press);
-                       input_sync(&kbd98->dev);
-                       break;
-       }
-
-out:
-       return IRQ_HANDLED;
-}
-
-/*
- * kbd98_sendbyte() sends a byte to the keyboard, and waits for
- * acknowledge. It doesn't handle resends according to the keyboard
- * protocol specs, because if these are needed, the keyboard needs
- * replacement anyway, and they only make a mess in the protocol.
- */
-
-static int kbd98_sendbyte(struct kbd98 *kbd98, unsigned char byte)
-{
-       int timeout = 10000; /* 100 msec */
-       kbd98->ack = 0;
-
-       if (serio_write(kbd98->serio, byte))
-               return -1;
-
-       while (!kbd98->ack && timeout--) udelay(10);
-
-       return -(kbd98->ack <= 0);
-}
-
-/*
- * kbd98_command() sends a command, and its parameters to the keyboard,
- * then waits for the response and puts it in the param array.
- */
-
-static int kbd98_command(struct kbd98 *kbd98, unsigned char *param, int command)
-{
-       int timeout = 50000; /* 500 msec */
-       int send = (command >> 12) & 0xf;
-       int receive = (command >> 8) & 0xf;
-       int i;
-
-       kbd98->cmdcnt = receive;
-
-       if (command & 0xff)
-               if (kbd98_sendbyte(kbd98, command & 0xff))
-                       return (kbd98->cmdcnt = 0) - 1;
-
-       for (i = 0; i < send; i++)
-               if (kbd98_sendbyte(kbd98, param[i]))
-                       return (kbd98->cmdcnt = 0) - 1;
-
-       while (kbd98->cmdcnt && timeout--) udelay(10);
-
-       if (param)
-               for (i = 0; i < receive; i++)
-                       param[i] = kbd98->cmdbuf[(receive - 1) - i];
-
-       if (kbd98->cmdcnt)
-               return (kbd98->cmdcnt = 0) - 1;
-
-       return 0;
-}
-
-/*
- * Event callback from the input module. Events that change the state of
- * the hardware are processed here.
- */
-
-static int kbd98_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
-{
-       struct kbd98 *kbd98 = dev->private;
-       char param[2];
-
-       switch (type) {
-
-               case EV_LED:
-
-                       if (__PC9800SCA_TEST_BIT(0x481, 3)) {
-                               /* 98note with Num Lock key */
-                               /* keep Num Lock status     */
-                               *param = 0x60;
-                               if (kbd98_command(kbd98, param,
-                                                       KBD98_CMD_GETLEDS))
-                                       printk(KERN_DEBUG
-                                               "kbd98: Get keyboard LED"
-                                               " status Error\n");
-
-                               *param &= 1;
-                       } else {
-                               /* desktop PC-9801 */
-                               *param = 1;     /* Always set Num Lock */
-                       }
-
-                       *param |= 0x70
-                              | (test_bit(LED_CAPSL,   dev->led) ? 4 : 0)
-                              | (test_bit(LED_KANA,    dev->led) ? 8 : 0);
-                       kbd98_command(kbd98, param, KBD98_CMD_SETLEDS);
-
-                       return 0;
-       }
-
-       return -1;
-}
-
-void kbd98_connect(struct serio *serio, struct serio_dev *dev)
-{
-       struct kbd98 *kbd98;
-       int i;
-
-       if ((serio->type & SERIO_TYPE) != SERIO_PC9800)
-               return;
-
-       if (!(kbd98 = kmalloc(sizeof(struct kbd98), GFP_KERNEL)))
-               return;
-
-       memset(kbd98, 0, sizeof(struct kbd98));
-       kbd98->emul.scancode = KBD98_KEY_UNKNOWN;
-
-       kbd98->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
-       kbd98->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_KANA);
-
-       kbd98->serio = serio;
-
-       init_input_dev(&kbd98->dev);
-       kbd98->dev.keycode = kbd98->keycode;
-       kbd98->dev.keycodesize = sizeof(unsigned char);
-       kbd98->dev.keycodemax = ARRAY_SIZE(kbd98_keycode);
-       kbd98->dev.event = kbd98_event;
-       kbd98->dev.private = kbd98;
-
-       serio->private = kbd98;
-
-       if (serio_open(serio, dev)) {
-               kfree(kbd98);
-               return;
-       }
-
-       memcpy(kbd98->jis, kbd98_jis, sizeof(kbd98_jis));
-       memcpy(kbd98->keycode, kbd98_keycode, sizeof(kbd98->keycode));
-       for (i = 0; i < 255; i++)
-               set_bit(kbd98->keycode[i], kbd98->dev.keybit);
-       clear_bit(0, kbd98->dev.keybit);
-
-       sprintf(kbd98->phys, "%s/input0", serio->phys);
-
-       kbd98->dev.name = kbd98_name;
-       kbd98->dev.phys = kbd98->phys;
-       kbd98->dev.id.bustype = BUS_XTKBD;
-       kbd98->dev.id.vendor = 0x0002;
-       kbd98->dev.id.product = 0x0001;
-       kbd98->dev.id.version = 0x0100;
-
-       input_register_device(&kbd98->dev);
-
-       printk(KERN_INFO "input: %s on %s\n", kbd98_name, serio->phys);
-}
-
-void kbd98_disconnect(struct serio *serio)
-{
-       struct kbd98 *kbd98 = serio->private;
-       input_unregister_device(&kbd98->dev);
-       serio_close(serio);
-       kfree(kbd98);
-}
-
-struct serio_dev kbd98_dev = {
-       .interrupt =    kbd98_interrupt,
-       .connect =      kbd98_connect,
-       .disconnect =   kbd98_disconnect
-};
-
-int __init kbd98_init(void)
-{
-       serio_register_device(&kbd98_dev);
-       return 0;
-}
-
-void __exit kbd98_exit(void)
-{
-       serio_unregister_device(&kbd98_dev);
-}
-
-module_init(kbd98_init);
-module_exit(kbd98_exit);
diff --git a/drivers/input/misc/98spkr.c b/drivers/input/misc/98spkr.c
deleted file mode 100644 (file)
index cdb6c0d..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *  PC-9800 Speaker beeper driver for Linux
- *
- *  Copyright (c) 2002 Osamu Tomita
- *  Copyright (c) 2002 Vojtech Pavlik
- *  Copyright (c) 1992 Orest Zborowski
- *
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <asm/8253pit.h>
-#include <asm/io.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9800 Speaker beeper driver");
-MODULE_LICENSE("GPL");
-
-static char spkr98_name[] = "PC-9801 Speaker";
-static char spkr98_phys[] = "isa3fdb/input0";
-static struct input_dev spkr98_dev;
-
-spinlock_t i8253_beep_lock = SPIN_LOCK_UNLOCKED;
-
-static int spkr98_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
-{
-       unsigned int count = 0;
-       unsigned long flags;
-
-       if (type != EV_SND)
-               return -1;
-
-       switch (code) {
-               case SND_BELL: if (value) value = 1000;
-               case SND_TONE: break;
-               default: return -1;
-       }
-
-       if (value > 20 && value < 32767)
-               count = PIT_TICK_RATE / value;
-
-       spin_lock_irqsave(&i8253_beep_lock, flags);
-
-       if (count) {
-               outb(0x76, 0x3fdf);
-               outb(0, 0x5f);
-               outb(count & 0xff, 0x3fdb);
-               outb(0, 0x5f);
-               outb((count >> 8) & 0xff, 0x3fdb);
-               /* beep on */
-               outb(6, 0x37);
-       } else {
-               /* beep off */
-               outb(7, 0x37);
-       }
-
-       spin_unlock_irqrestore(&i8253_beep_lock, flags);
-
-       return 0;
-}
-
-static int __init spkr98_init(void)
-{
-       spkr98_dev.evbit[0] = BIT(EV_SND);
-       spkr98_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
-       spkr98_dev.event = spkr98_event;
-
-       spkr98_dev.name = spkr98_name;
-       spkr98_dev.phys = spkr98_phys;
-       spkr98_dev.id.bustype = BUS_ISA;
-       spkr98_dev.id.vendor = 0x001f;
-       spkr98_dev.id.product = 0x0001;
-       spkr98_dev.id.version = 0x0100;
-
-       input_register_device(&spkr98_dev);
-
-        printk(KERN_INFO "input: %s\n", spkr98_name);
-
-       return 0;
-}
-
-static void __exit spkr98_exit(void)
-{
-        input_unregister_device(&spkr98_dev);
-}
-
-module_init(spkr98_init);
-module_exit(spkr98_exit);
diff --git a/drivers/input/mouse/98busmouse.c b/drivers/input/mouse/98busmouse.c
deleted file mode 100644 (file)
index fed160f..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- *
- *  Copyright (c) 2002 Osamu Tomita
- *
- *  Based on the work of:
- *     James Banks             Matthew Dillon
- *     David Giller            Nathan Laredo
- *     Linus Torvalds          Johan Myreen
- *     Cliff Matthews          Philip Blundell
- *     Russell King            Vojtech Pavlik
- */
-
-/*
- * NEC PC-9801 Bus Mouse Driver for Linux
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or 
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * 
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/delay.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <linux/interrupt.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9801 busmouse driver");
-MODULE_LICENSE("GPL");
-
-#define        PC98BM_BASE             0x7fd9
-#define        PC98BM_DATA_PORT        PC98BM_BASE + 0
-/*     PC98BM_SIGNATURE_PORT   does not exist */
-#define        PC98BM_CONTROL_PORT     PC98BM_BASE + 4
-/*     PC98BM_INTERRUPT_PORT   does not exist */
-#define        PC98BM_CONFIG_PORT      PC98BM_BASE + 6
-
-#define        PC98BM_ENABLE_IRQ       0x00
-#define        PC98BM_DISABLE_IRQ      0x10
-#define        PC98BM_READ_X_LOW       0x80
-#define        PC98BM_READ_X_HIGH      0xa0
-#define        PC98BM_READ_Y_LOW       0xc0
-#define        PC98BM_READ_Y_HIGH      0xe0
-
-#define PC98BM_DEFAULT_MODE    0x93
-/*     PC98BM_CONFIG_BYTE      is not used */
-/*     PC98BM_SIGNATURE_BYTE   is not used */
-
-#define PC98BM_TIMER_PORT      0xbfdb
-#define PC98BM_DEFAULT_TIMER_VAL       0x00
-
-#define PC98BM_IRQ             13
-
-static int pc98bm_irq = PC98BM_IRQ;
-module_param_named(irq, pc98bm_irq, uint, 0);
-MODULE_PARM_DESC(irq, "IRQ number (13=default)");
-
-__obsolete_setup("pc98bm_irq=");
-
-static int pc98bm_used = 0;
-
-static irqreturn_t pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-static int pc98bm_open(struct input_dev *dev)
-{
-       if (pc98bm_used++)
-               return 0;
-       if (request_irq(pc98bm_irq, pc98bm_interrupt, 0, "98busmouse", NULL)) {
-               pc98bm_used--;
-               printk(KERN_ERR "98busmouse.c: Can't allocate irq %d\n", pc98bm_irq);
-               return -EBUSY;
-       }
-       outb(PC98BM_ENABLE_IRQ, PC98BM_CONTROL_PORT);
-       return 0;
-}
-
-static void pc98bm_close(struct input_dev *dev)
-{
-       if (--pc98bm_used)
-               return;
-       outb(PC98BM_DISABLE_IRQ, PC98BM_CONTROL_PORT);
-       free_irq(pc98bm_irq, NULL);
-}
-
-static struct input_dev pc98bm_dev = {
-       .evbit  = { BIT(EV_KEY) | BIT(EV_REL) },
-       .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
-       .relbit = { BIT(REL_X) | BIT(REL_Y) },
-       .open   = pc98bm_open,
-       .close  = pc98bm_close,
-       .name   = "PC-9801 bus mouse",
-       .phys   = "isa7fd9/input0",
-       .id     = {
-               .bustype = BUS_ISA,
-               .vendor  = 0x0004,
-               .product = 0x0001,
-               .version = 0x0100,
-       },
-};
-
-static irqreturn_t pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       char dx, dy;
-       unsigned char buttons;
-
-       outb(PC98BM_READ_X_LOW, PC98BM_CONTROL_PORT);
-       dx = (inb(PC98BM_DATA_PORT) & 0xf);
-       outb(PC98BM_READ_X_HIGH, PC98BM_CONTROL_PORT);
-       dx |= (inb(PC98BM_DATA_PORT) & 0xf) << 4;
-       outb(PC98BM_READ_Y_LOW, PC98BM_CONTROL_PORT);
-       dy = (inb(PC98BM_DATA_PORT) & 0xf);
-       outb(PC98BM_READ_Y_HIGH, PC98BM_CONTROL_PORT);
-       buttons = inb(PC98BM_DATA_PORT);
-       dy |= (buttons & 0xf) << 4;
-       buttons = ~buttons >> 5;
-
-       input_report_rel(&pc98bm_dev, REL_X, dx);
-       input_report_rel(&pc98bm_dev, REL_Y, dy);
-       input_report_key(&pc98bm_dev, BTN_RIGHT,  buttons & 1);
-       input_report_key(&pc98bm_dev, BTN_MIDDLE, buttons & 2);
-       input_report_key(&pc98bm_dev, BTN_LEFT,   buttons & 4);
-       input_sync(&pc98bm_dev);
-
-       outb(PC98BM_ENABLE_IRQ, PC98BM_CONTROL_PORT);
-
-       return IRQ_HANDLED;
-}
-
-static int __init pc98bm_init(void)
-{
-       int i;
-
-       for (i = 0; i <= 6; i += 2) {
-               if (!request_region(PC98BM_BASE + i, 1, "98busmouse")) {
-                       printk(KERN_ERR "98busmouse.c: Can't allocate ports at %#x\n", PC98BM_BASE + i);
-                       while (i > 0) {
-                               i -= 2;
-                               release_region(PC98BM_BASE + i, 1);
-                       }
-
-                       return -EBUSY;
-               }
-
-       }
-
-       if (!request_region(PC98BM_TIMER_PORT, 1, "98busmouse")) {
-               printk(KERN_ERR "98busmouse.c: Can't allocate ports at %#x\n", PC98BM_TIMER_PORT);
-               for (i = 0; i <= 6; i += 2)
-                       release_region(PC98BM_BASE + i, 1);
-
-               return -EBUSY;
-       }
-
-       outb(PC98BM_DEFAULT_MODE, PC98BM_CONFIG_PORT);
-       outb(PC98BM_DISABLE_IRQ, PC98BM_CONTROL_PORT);
-
-       outb(PC98BM_DEFAULT_TIMER_VAL, PC98BM_TIMER_PORT);
-
-       input_register_device(&pc98bm_dev);
-       
-       printk(KERN_INFO "input: PC-9801 bus mouse at %#x irq %d\n", PC98BM_BASE, pc98bm_irq);
-
-       return 0;
-}
-
-static void __exit pc98bm_exit(void)
-{
-       int i;
-
-       input_unregister_device(&pc98bm_dev);
-       for (i = 0; i <= 6; i += 2)
-               release_region(PC98BM_BASE + i, 1);
-
-       release_region(PC98BM_TIMER_PORT, 1);
-}
-
-module_init(pc98bm_init);
-module_exit(pc98bm_exit);
diff --git a/drivers/input/serio/98kbd-io.c b/drivers/input/serio/98kbd-io.c
deleted file mode 100644 (file)
index 32bd067..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *  NEC PC-9801 keyboard controller driver for Linux
- *
- *  Copyright (c) 1999-2002 Osamu Tomita <tomita@cinet.co.jp>
- *    Based on i8042.c written by Vojtech Pavlik
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/serio.h>
-#include <linux/sched.h>
-
-#include <asm/io.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("NEC PC-9801 keyboard controller driver");
-MODULE_LICENSE("GPL");
-
-/*
- * Names.
- */
-
-#define KBD98_PHYS_DESC "isa0041/serio0"
-
-/*
- * IRQs.
- */
-
-#define KBD98_IRQ      1
-
-/*
- * Register numbers.
- */
-
-#define KBD98_COMMAND_REG      0x43
-#define KBD98_STATUS_REG       0x43
-#define KBD98_DATA_REG         0x41
-
-spinlock_t kbd98io_lock = SPIN_LOCK_UNLOCKED;
-
-static struct serio kbd98_port;
-extern struct pt_regs *kbd_pt_regs;
-
-static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-/*
- * kbd98_flush() flushes all data that may be in the keyboard buffers
- */
-
-static int kbd98_flush(void)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&kbd98io_lock, flags);
-
-       while (inb(KBD98_STATUS_REG) & 0x02) /* RxRDY */
-               inb(KBD98_DATA_REG);
-
-       if (inb(KBD98_STATUS_REG) & 0x38)
-               printk("98kbd-io: Keyboard error!\n");
-
-       spin_unlock_irqrestore(&kbd98io_lock, flags);
-
-       return 0;
-}
-
-/*
- * kbd98_write() sends a byte out through the keyboard interface.
- */
-
-static int kbd98_write(struct serio *port, unsigned char c)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&kbd98io_lock, flags);
-
-       outb(0, 0x5f);                  /* wait */
-       outb(0x17, KBD98_COMMAND_REG);  /* enable send command */
-       outb(0, 0x5f);                  /* wait */
-       outb(c, KBD98_DATA_REG);
-       outb(0, 0x5f);                  /* wait */
-       outb(0x16, KBD98_COMMAND_REG);  /* disable send command */
-       outb(0, 0x5f);                  /* wait */
-
-       spin_unlock_irqrestore(&kbd98io_lock, flags);
-
-       return 0;
-}
-
-/*
- * kbd98_open() is called when a port is open by the higher layer.
- * It allocates the interrupt and enables in in the chip.
- */
-
-static int kbd98_open(struct serio *port)
-{
-       kbd98_flush();
-
-       if (request_irq(KBD98_IRQ, kbd98io_interrupt, 0, "kbd98", NULL)) {
-               printk(KERN_ERR "98kbd-io.c: Can't get irq %d for %s, unregistering the port.\n", KBD98_IRQ, "KBD");
-               serio_unregister_port(port);
-               return -1;
-       }
-
-       return 0;
-}
-
-static void kbd98_close(struct serio *port)
-{
-       free_irq(KBD98_IRQ, NULL);
-
-       kbd98_flush();
-}
-
-/*
- * Structures for registering the devices in the serio.c module.
- */
-
-static struct serio kbd98_port =
-{
-       .type =         SERIO_PC9800,
-       .write =        kbd98_write,
-       .open =         kbd98_open,
-       .close =        kbd98_close,
-       .driver =       NULL,
-       .name =         "PC-9801 Kbd Port",
-       .phys =         KBD98_PHYS_DESC,
-};
-
-/*
- * kbd98io_interrupt() is the most important function in this driver -
- * it handles the interrupts from keyboard, and sends incoming bytes
- * to the upper layers.
- */
-
-static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       unsigned long flags;
-       unsigned char data;
-
-       spin_lock_irqsave(&kbd98io_lock, flags);
-
-       data = inb(KBD98_DATA_REG);
-       spin_unlock_irqrestore(&kbd98io_lock, flags);
-       serio_interrupt(&kbd98_port, data, 0, regs);
-
-       return IRQ_HANDLED;
-}
-
-int __init kbd98io_init(void)
-{
-       serio_register_port(&kbd98_port);
-
-       printk(KERN_INFO "serio: PC-9801 %s port at %#lx,%#lx irq %d\n",
-              "KBD",
-              (unsigned long) KBD98_DATA_REG,
-              (unsigned long) KBD98_COMMAND_REG,
-              KBD98_IRQ);
-
-       return 0;
-}
-
-void __exit kbd98io_exit(void)
-{
-       serio_unregister_port(&kbd98_port);
-}
-
-module_init(kbd98io_init);
-module_exit(kbd98io_exit);
index e9d8dab..1314f00 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/sysdev.h>
 #include <linux/pm.h>
 #include <linux/serio.h>
+#include <linux/pci.h>
 
 #include <asm/io.h>
 
@@ -131,6 +132,7 @@ static int i8042_flush(void)
        spin_lock_irqsave(&i8042_lock, flags);
 
        while ((i8042_read_status() & I8042_STR_OBF) && (i++ < I8042_BUFFER_SIZE)) {
+               udelay(50);
                data = i8042_read_data();
                dbg("%02x <- i8042 (flush, %s)", data,
                        i8042_read_status() & I8042_STR_AUXDATA ? "aux" : "kbd");
@@ -669,6 +671,69 @@ static void i8042_timer_func(unsigned long data)
 }
 
 
+static int i8042_spank_usb(void)
+{
+       struct pci_dev *usb = NULL;
+       int found = 0;
+       u16 word;
+       unsigned long addr;
+       unsigned long len;
+       int i;
+       
+       while((usb = pci_find_class((PCI_CLASS_SERIAL_USB << 8), usb)) != NULL)
+       {
+               /* UHCI controller not in legacy ? */
+               
+               pci_read_config_word(usb, 0xC0, &word);
+               if(word & 0x2000)
+                       continue;
+                       
+               /* Check it is enabled. If the port is active in legacy mode
+                  then this will be mapped already */
+                  
+               for(i = 0; i < PCI_ROM_RESOURCE; i++)
+               {
+                       if (!(pci_resource_flags (usb, i) & IORESOURCE_IO))
+                               continue;
+               }
+               if(i == PCI_ROM_RESOURCE)
+                       continue;
+               
+               /*
+                *      Retrieve the bits
+                */
+                   
+               addr = pci_resource_start(usb, i);
+               len = pci_resource_len (usb, i);
+               
+               /*
+                *      Check its configured and not in use
+                */
+               if(addr == 0)
+                       continue;
+               if (request_region(addr, len, "usb whackamole"))
+                       continue;
+                               
+               /*
+                *      Kick the problem controller out of legacy mode
+                *      so things like the E750x don't break
+                */
+               
+               outw(0, addr + 4);              /* IRQ Mask */
+               outw(4, addr);                  /* Reset */
+               msleep(20);
+               outw(0, addr);
+               
+               msleep(20);
+               /* Now take if off the BIOS */
+               pci_write_config_word(usb, 0xC0, 0x2000);
+               release_region(addr, len);
+
+               found = 1;
+       }
+       return found;
+}
+
 /*
  * i8042_controller init initializes the i8042 controller, and,
  * most importantly, sets it into non-xlated mode if that's
@@ -677,6 +742,7 @@ static void i8042_timer_func(unsigned long data)
 
 static int i8042_controller_init(void)
 {
+       int tries = 0;
 
 /*
  * Test the i8042. We need to know if it thinks it's working correctly
@@ -705,9 +771,15 @@ static int i8042_controller_init(void)
  * Save the CTR for restoral on unload / reboot.
  */
 
-       if (i8042_command(&i8042_ctr, I8042_CMD_CTL_RCTR)) {
-               printk(KERN_ERR "i8042.c: Can't read CTR while initializing i8042.\n");
-               return -1;
+       while(i8042_command(&i8042_ctr, I8042_CMD_CTL_RCTR)) {
+               if(tries > 3 || !i8042_spank_usb())
+               {
+                       printk(KERN_ERR "i8042.c: Can't read CTR while initializing i8042.\n");
+                       return -1;
+               }
+               printk(KERN_WARNING "i8042.c: Can't read CTR, disabling USB legacy and retrying.\n");
+               i8042_flush();
+               tries++;
        }
 
        i8042_initial_ctr = i8042_ctr;
index c8feb83..0a87c9e 100644 (file)
@@ -12,6 +12,8 @@ raid6-objs    := raid6main.o raid6algos.o raid6recov.o raid6tables.o \
                   raid6mmx.o raid6sse1.o raid6sse2.o
 host-progs     := mktables
 
+CFLAGS_raid6int8.o += -O2
+
 # Note: link order is important.  All raid personalities
 # and xor.o must come before md.o, as they each initialise 
 # themselves, and md.o may use the personalities when it 
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
deleted file mode 100644 (file)
index 03a955c..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-/**
- *
- * $Id: phram.c,v 1.2 2004/08/09 13:19:44 dwmw2 Exp $
- *
- * Copyright (c) Jochen Schaeuble <psionic@psionic.de>
- * 07/2003     rewritten by Joern Engel <joern@wh.fh-wedel.de>
- *
- * DISCLAIMER:  This driver makes use of Rusty's excellent module code,
- * so it will not work for 2.4 without changes and it wont work for 2.4
- * as a module without major changes.  Oh well!
- *
- * Usage:
- *
- * one commend line parameter per device, each in the form:
- *   phram=<name>,<start>,<len>
- * <name> may be up to 63 characters.
- * <start> and <len> can be octal, decimal or hexadecimal.  If followed
- * by "k", "M" or "G", the numbers will be interpreted as kilo, mega or
- * gigabytes.
- *
- */
-
-#include <asm/io.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/mtd/mtd.h>
-
-#define ERROR(fmt, args...) printk(KERN_ERR "phram: " fmt , ## args)
-
-struct phram_mtd_list {
-       struct list_head list;
-       struct mtd_info *mtdinfo;
-};
-
-static LIST_HEAD(phram_list);
-
-
-
-int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
-{
-       u_char *start = (u_char *)mtd->priv;
-
-       if (instr->addr + instr->len > mtd->size)
-               return -EINVAL;
-       
-       memset(start + instr->addr, 0xff, instr->len);
-
-       /* This'll catch a few races. Free the thing before returning :) 
-        * I don't feel at all ashamed. This kind of thing is possible anyway
-        * with flash, but unlikely.
-        */
-
-       instr->state = MTD_ERASE_DONE;
-
-       mtd_erase_callback(instr);
-
-       return 0;
-}
-
-int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
-               size_t *retlen, u_char **mtdbuf)
-{
-       u_char *start = (u_char *)mtd->priv;
-
-       if (from + len > mtd->size)
-               return -EINVAL;
-       
-       *mtdbuf = start + from;
-       *retlen = len;
-       return 0;
-}
-
-void phram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len)
-{
-}
-
-int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
-               size_t *retlen, u_char *buf)
-{
-       u_char *start = (u_char *)mtd->priv;
-
-       if (from + len > mtd->size)
-               return -EINVAL;
-       
-       memcpy(buf, start + from, len);
-
-       *retlen = len;
-       return 0;
-}
-
-int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
-               size_t *retlen, const u_char *buf)
-{
-       u_char *start = (u_char *)mtd->priv;
-
-       if (to + len > mtd->size)
-               return -EINVAL;
-       
-       memcpy(start + to, buf, len);
-
-       *retlen = len;
-       return 0;
-}
-
-
-
-static void unregister_devices(void)
-{
-       struct phram_mtd_list *this;
-
-       list_for_each_entry(this, &phram_list, list) {
-               del_mtd_device(this->mtdinfo);
-               iounmap(this->mtdinfo->priv);
-               kfree(this->mtdinfo);
-               kfree(this);
-       }
-}
-
-static int register_device(char *name, unsigned long start, unsigned long len)
-{
-       struct phram_mtd_list *new;
-       int ret = -ENOMEM;
-
-       new = kmalloc(sizeof(*new), GFP_KERNEL);
-       if (!new)
-               goto out0;
-
-       new->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
-       if (!new->mtdinfo)
-               goto out1;
-       
-       memset(new->mtdinfo, 0, sizeof(struct mtd_info));
-
-       ret = -EIO;
-       new->mtdinfo->priv = ioremap(start, len);
-       if (!new->mtdinfo->priv) {
-               ERROR("ioremap failed\n");
-               goto out2;
-       }
-
-
-       new->mtdinfo->name = name;
-       new->mtdinfo->size = len;
-       new->mtdinfo->flags = MTD_CAP_RAM | MTD_ERASEABLE | MTD_VOLATILE;
-        new->mtdinfo->erase = phram_erase;
-       new->mtdinfo->point = phram_point;
-       new->mtdinfo->unpoint = phram_unpoint;
-       new->mtdinfo->read = phram_read;
-       new->mtdinfo->write = phram_write;
-       new->mtdinfo->owner = THIS_MODULE;
-       new->mtdinfo->type = MTD_RAM;
-       new->mtdinfo->erasesize = 0x0;
-
-       ret = -EAGAIN;
-       if (add_mtd_device(new->mtdinfo)) {
-               ERROR("Failed to register new device\n");
-               goto out3;
-       }
-
-       list_add_tail(&new->list, &phram_list);
-       return 0;       
-
-out3:
-       iounmap(new->mtdinfo->priv);
-out2:
-       kfree(new->mtdinfo);
-out1:
-       kfree(new);
-out0:
-       return ret;
-}
-
-static int ustrtoul(const char *cp, char **endp, unsigned int base)
-{
-       unsigned long result = simple_strtoul(cp, endp, base);
-
-       switch (**endp) {
-       case 'G':
-               result *= 1024;
-       case 'M':
-               result *= 1024;
-       case 'k':
-               result *= 1024;
-               endp++;
-       }
-       return result;
-}
-
-static int parse_num32(uint32_t *num32, const char *token)
-{
-       char *endp;
-       unsigned long n;
-
-       n = ustrtoul(token, &endp, 0);
-       if (*endp)
-               return -EINVAL;
-
-       *num32 = n;
-       return 0;
-}
-
-static int parse_name(char **pname, const char *token)
-{
-       size_t len;
-       char *name;
-
-       len = strlen(token) + 1;
-       if (len > 64)
-               return -ENOSPC;
-
-       name = kmalloc(len, GFP_KERNEL);
-       if (!name)
-               return -ENOMEM;
-
-       strcpy(name, token);
-
-       *pname = name;
-       return 0;
-}
-
-#define parse_err(fmt, args...) do {   \
-       ERROR(fmt , ## args);   \
-       return 0;               \
-} while (0)
-
-static int phram_setup(const char *val, struct kernel_param *kp)
-{
-       char buf[64+12+12], *str = buf;
-       char *token[3];
-       char *name;
-       uint32_t start;
-       uint32_t len;
-       int i, ret;
-
-       if (strnlen(val, sizeof(str)) >= sizeof(str))
-               parse_err("parameter too long\n");
-
-       strcpy(str, val);
-
-       for (i=0; i<3; i++)
-               token[i] = strsep(&str, ",");
-
-       if (str)
-               parse_err("too many arguments\n");
-
-       if (!token[2])
-               parse_err("not enough arguments\n");
-
-       ret = parse_name(&name, token[0]);
-       if (ret == -ENOMEM)
-               parse_err("out of memory\n");
-       if (ret == -ENOSPC)
-               parse_err("name too long\n");
-       if (ret)
-               return 0;
-
-       ret = parse_num32(&start, token[1]);
-       if (ret)
-               parse_err("illegal start address\n");
-
-       ret = parse_num32(&len, token[2]);
-       if (ret)
-               parse_err("illegal device length\n");
-
-       register_device(name, start, len);
-
-       return 0;
-}
-
-module_param_call(phram, phram_setup, NULL, NULL, 000);
-MODULE_PARM_DESC(phram, "Memory region to map. \"map=<name>,<start><length>\"");
-
-/*
- * Just for compatibility with slram, this is horrible and should go someday.
- */
-static int __init slram_setup(const char *val, struct kernel_param *kp)
-{
-       char buf[256], *str = buf;
-
-       if (!val || !val[0])
-               parse_err("no arguments to \"slram=\"\n");
-
-       if (strnlen(val, sizeof(str)) >= sizeof(str))
-               parse_err("parameter too long\n");
-
-       strcpy(str, val);
-
-       while (str) {
-               char *token[3];
-               char *name;
-               uint32_t start;
-               uint32_t len;
-               int i, ret;
-
-               for (i=0; i<3; i++) {
-                       token[i] = strsep(&str, ",");
-                       if (token[i])
-                               continue;
-                       parse_err("wrong number of arguments to \"slram=\"\n");
-               }
-
-               /* name */
-               ret = parse_name(&name, token[0]);
-               if (ret == -ENOMEM)
-                       parse_err("of memory\n");
-               if (ret == -ENOSPC)
-                       parse_err("too long\n");
-               if (ret)
-                       return 1;
-
-               /* start */
-               ret = parse_num32(&start, token[1]);
-               if (ret)
-                       parse_err("illegal start address\n");
-
-               /* len */
-               if (token[2][0] == '+')
-                       ret = parse_num32(&len, token[2] + 1);
-               else
-                       ret = parse_num32(&len, token[2]);
-
-               if (ret)
-                       parse_err("illegal device length\n");
-
-               if (token[2][0] != '+') {
-                       if (len < start)
-                               parse_err("end < start\n");
-                       len -= start;
-               }
-
-               register_device(name, start, len);
-       }
-       return 1;
-}
-
-module_param_call(slram, slram_setup, NULL, NULL, 000);
-MODULE_PARM_DESC(slram, "List of memory regions to map. \"map=<name>,<start><length/end>\"");
-
-
-int __init init_phram(void)
-{
-       printk(KERN_ERR "phram loaded\n");
-       return 0;
-}
-
-static void __exit cleanup_phram(void)
-{
-       unregister_devices();
-}
-
-module_init(init_phram);
-module_exit(cleanup_phram);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Jörn Engel <joern@wh.fh-wedel.de>");
-MODULE_DESCRIPTION("MTD driver for physical RAM");
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
deleted file mode 100644 (file)
index a26cc3a..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * ichxrom.c
- *
- * Normal mappings of chips in physical memory
- * $Id: ichxrom.c,v 1.8 2004/07/16 17:43:11 dwmw2 Exp $
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/io.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/pci_ids.h>
-#include <linux/mtd/cfi.h>
-
-#define xstr(s) str(s)
-#define str(s) #s
-#define MOD_NAME xstr(KBUILD_BASENAME)
-
-#define MTD_DEV_NAME_LENGTH 16
-
-#define RESERVE_MEM_REGION 0
-
-
-#define MANUFACTURER_INTEL     0x0089
-#define I82802AB       0x00ad
-#define I82802AC       0x00ac
-
-#define ICHX_FWH_REGION_START  0xFF000000UL
-#define ICHX_FWH_REGION_SIZE   0x01000000UL
-#define BIOS_CNTL      0x4e
-#define FWH_DEC_EN1    0xE3
-#define FWH_DEC_EN2    0xF0
-#define FWH_SEL1       0xE8
-#define FWH_SEL2       0xEE
-
-struct ichxrom_map_info {
-       struct map_info map;
-       struct mtd_info *mtd;
-       unsigned long window_addr;
-       struct pci_dev *pdev;
-       struct resource window_rsrc;
-       struct resource rom_rsrc;
-       char mtd_name[MTD_DEV_NAME_LENGTH];
-};
-
-static inline unsigned long addr(struct map_info *map, unsigned long ofs)
-{
-       unsigned long offset;
-       offset = ((8*1024*1024) - map->size) + ofs;
-       if (offset >= (4*1024*1024)) {
-               offset += 0x400000;
-       }
-       return map->map_priv_1 + 0x400000 + offset;
-}
-
-static inline unsigned long dbg_addr(struct map_info *map, unsigned long addr)
-{
-       return addr - map->map_priv_1 + ICHX_FWH_REGION_START;
-}
-       
-static map_word ichxrom_read(struct map_info *map, unsigned long ofs)
-{
-       map_word val;
-       int i;
-       switch(map->bankwidth) {
-       case 1:  val.x[0] = __raw_readb(addr(map, ofs)); break;
-       case 2:  val.x[0] = __raw_readw(addr(map, ofs)); break;
-       case 4:  val.x[0] = __raw_readl(addr(map, ofs)); break;
-#if BITS_PER_LONG >= 64
-       case 8:  val.x[0] = __raw_readq(addr(map, ofs)); break;
-#endif
-       default: val.x[0] = 0; break;
-       }
-       for(i = 1; i < map_words(map); i++) {
-               val.x[i] = 0;
-       }
-       return val;
-}
-
-static void ichxrom_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
-{
-       memcpy_fromio(to, addr(map, from), len);
-}
-
-static void ichxrom_write(struct map_info *map, map_word d, unsigned long ofs)
-{
-       switch(map->bankwidth) {
-       case 1: __raw_writeb(d.x[0], addr(map,ofs)); break;
-       case 2: __raw_writew(d.x[0], addr(map,ofs)); break;
-       case 4: __raw_writel(d.x[0], addr(map,ofs)); break;
-#if BITS_PER_LONG >= 64
-       case 8: __raw_writeq(d.x[0], addr(map,ofs)); break;
-#endif
-       }
-       mb();
-}
-
-static void ichxrom_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
-{
-       memcpy_toio(addr(map, to), from, len);
-}
-
-static struct ichxrom_map_info ichxrom_map = {
-       .map = {
-               .name = MOD_NAME,
-               .phys = NO_XIP,
-               .size = 0,
-               .bankwidth = 1,
-               .read = ichxrom_read,
-               .copy_from = ichxrom_copy_from,
-               .write = ichxrom_write,
-               .copy_to = ichxrom_copy_to,
-               /* Firmware hubs only use vpp when being programmed
-                * in a factory setting.  So in-place programming
-                * needs to use a different method.
-                */
-       },
-       /* remaining fields of structure are initialized to 0 */
-};
-
-enum fwh_lock_state {
-       FWH_DENY_WRITE = 1,
-       FWH_IMMUTABLE  = 2,
-       FWH_DENY_READ  = 4,
-};
-
-static void ichxrom_cleanup(struct ichxrom_map_info *info)
-{
-       u16 word;
-
-       /* Disable writes through the rom window */
-       pci_read_config_word(info->pdev, BIOS_CNTL, &word);
-       pci_write_config_word(info->pdev, BIOS_CNTL, word & ~1);
-
-       if (info->mtd) {
-               del_mtd_device(info->mtd);
-               map_destroy(info->mtd);
-               info->mtd = NULL;
-               info->map.virt = 0;
-       }
-       if (info->rom_rsrc.parent)
-               release_resource(&info->rom_rsrc);
-       if (info->window_rsrc.parent)
-               release_resource(&info->window_rsrc);
-
-       if (info->window_addr) {
-               iounmap((void *)(info->window_addr));
-               info->window_addr = 0;
-       }
-}
-
-
-static int ichxrom_set_lock_state(struct mtd_info *mtd, loff_t ofs, size_t len,
-       enum fwh_lock_state state)
-{
-       struct map_info *map = mtd->priv;
-       unsigned long start = ofs;
-       unsigned long end = start + len -1;
-
-       /* FIXME do I need to guard against concurrency here? */
-       /* round down to 64K boundaries */
-       start = start & ~0xFFFF;
-       end = end & ~0xFFFF;
-       while (start <= end) {
-               unsigned long ctrl_addr;
-               ctrl_addr = addr(map, start) - 0x400000 + 2;
-               writeb(state, ctrl_addr);
-               start = start + 0x10000;
-       }
-       return 0;
-}
-
-static int ichxrom_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
-{
-       return ichxrom_set_lock_state(mtd, ofs, len, FWH_DENY_WRITE);
-}
-
-static int ichxrom_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
-{
-       return ichxrom_set_lock_state(mtd, ofs, len, 0);
-}
-
-static int __devinit ichxrom_init_one (struct pci_dev *pdev,
-       const struct pci_device_id *ent)
-{
-       u16 word;
-       struct ichxrom_map_info *info = &ichxrom_map;
-       unsigned long map_size;
-       static char *probes[] = { "cfi_probe", "jedec_probe" };
-       struct cfi_private *cfi;
-
-       /* For now I just handle the ichx and I assume there
-        * are not a lot of resources up at the top of the address
-        * space.  It is possible to handle other devices in the
-        * top 16MB but it is very painful.  Also since
-        * you can only really attach a FWH to an ICHX there
-        * a number of simplifications you can make.
-        *
-        * Also you can page firmware hubs if an 8MB window isn't enough 
-        * but don't currently handle that case either.
-        */
-
-       info->pdev = pdev;
-
-       /*
-        * Try to reserve the window mem region.  If this fails then
-        * it is likely due to the window being "reseved" by the BIOS.
-        */
-       info->window_rsrc.name = MOD_NAME;
-       info->window_rsrc.start = ICHX_FWH_REGION_START;
-       info->window_rsrc.end = ICHX_FWH_REGION_START + ICHX_FWH_REGION_SIZE - 1;
-       info->window_rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-       if (request_resource(&iomem_resource, &info->window_rsrc)) {
-               info->window_rsrc.parent = NULL;
-               printk(KERN_ERR MOD_NAME
-                      " %s(): Unable to register resource"
-                      " 0x%.08lx-0x%.08lx - kernel bug?\n",
-                      __func__,
-                      info->window_rsrc.start, info->window_rsrc.end);
-       }
-       
-       /* Enable writes through the rom window */
-       pci_read_config_word(pdev, BIOS_CNTL, &word);
-       if (!(word & 1)  && (word & (1<<1))) {
-               /* The BIOS will generate an error if I enable
-                * this device, so don't even try.
-                */
-               printk(KERN_ERR MOD_NAME ": firmware access control, I can't enable writes\n");
-               goto failed;
-       }
-       pci_write_config_word(pdev, BIOS_CNTL, word | 1);
-
-
-       /* Map the firmware hub into my address space. */
-       /* Does this use too much virtual address space? */
-       info->window_addr = (unsigned long)ioremap(
-               ICHX_FWH_REGION_START, ICHX_FWH_REGION_SIZE);
-       if (!info->window_addr) {
-               printk(KERN_ERR "Failed to ioremap\n");
-               goto failed;
-       }
-
-       /* For now assume the firmware has setup all relevant firmware
-        * windows.  We don't have enough information to handle this case
-        * intelligently.
-        */
-
-       /* FIXME select the firmware hub and enable a window to it. */
-
-       info->mtd = NULL;
-       info->map.map_priv_1 = info->window_addr;
-
-       /* Loop through the possible bankwidths */
-       for(ichxrom_map.map.bankwidth = 4; ichxrom_map.map.bankwidth; ichxrom_map.map.bankwidth >>= 1) {
-               map_size = ICHX_FWH_REGION_SIZE;
-               while(!info->mtd && (map_size > 0)) {
-                       int i;
-                       info->map.size = map_size;
-                       for(i = 0; i < sizeof(probes)/sizeof(char *); i++) {
-                               info->mtd = do_map_probe(probes[i], &ichxrom_map.map);
-                               if (info->mtd)
-                                       break;
-                       }
-                       map_size -= 512*1024;
-               }
-               if (info->mtd)
-                       break;
-       }
-       if (!info->mtd) {
-               goto failed;
-       }
-       cfi = ichxrom_map.map.fldrv_priv;
-       if ((cfi->mfr == MANUFACTURER_INTEL) && (
-                   (cfi->id == I82802AB) ||
-                   (cfi->id == I82802AC))) 
-       {
-               /* If it is a firmware hub put in the special lock
-                * and unlock routines.
-                */
-               info->mtd->lock = ichxrom_lock;
-               info->mtd->unlock = ichxrom_unlock;
-       }
-       if (info->mtd->size > info->map.size) {
-               printk(KERN_WARNING MOD_NAME " rom(%u) larger than window(%lu). fixing...\n",
-                      info->mtd->size, info->map.size);
-               info->mtd->size = info->map.size;
-       }
-               
-       info->mtd->owner = THIS_MODULE;
-       add_mtd_device(info->mtd);
-
-       if (info->window_rsrc.parent) {
-               /*
-                * Registering the MTD device in iomem may not be possible
-                * if there is a BIOS "reserved" and BUSY range.  If this
-                * fails then continue anyway.
-                */
-               snprintf(info->mtd_name, MTD_DEV_NAME_LENGTH,
-                        "mtd%d", info->mtd->index);
-
-               info->rom_rsrc.name = info->mtd_name;
-               info->rom_rsrc.start = ICHX_FWH_REGION_START
-                       + ICHX_FWH_REGION_SIZE - map_size;
-               info->rom_rsrc.end = ICHX_FWH_REGION_START
-                       + ICHX_FWH_REGION_SIZE;
-               info->rom_rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-               if (request_resource(&info->window_rsrc, &info->rom_rsrc)) {
-                       printk(KERN_ERR MOD_NAME
-                              ": cannot reserve MTD resource\n");
-                       info->rom_rsrc.parent = NULL;
-               }
-       }
-
-       return 0;
-
- failed:
-       ichxrom_cleanup(info);
-       return -ENODEV;
-}
-
-
-static void __devexit ichxrom_remove_one (struct pci_dev *pdev)
-{
-       struct ichxrom_map_info *info = &ichxrom_map;
-       u16 word;
-
-       del_mtd_device(info->mtd);
-       map_destroy(info->mtd);
-       info->mtd = NULL;
-       info->map.map_priv_1 = 0;
-
-       iounmap((void *)(info->window_addr));
-       info->window_addr = 0;
-
-       /* Disable writes through the rom window */
-       pci_read_config_word(pdev, BIOS_CNTL, &word);
-       pci_write_config_word(pdev, BIOS_CNTL, word & ~1);
-
-#if RESERVE_MEM_REGION 
-       release_mem_region(ICHX_FWH_REGION_START, ICHX_FWH_REGION_SIZE);
-#endif
-}
-
-static struct pci_device_id ichxrom_pci_tbl[] __devinitdata = {
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, 
-         PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, 
-         PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, 
-         PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,
-         PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1,
-         PCI_ANY_ID, PCI_ANY_ID, },
-       { 0, },
-};
-
-MODULE_DEVICE_TABLE(pci, ichxrom_pci_tbl);
-
-#if 0
-static struct pci_driver ichxrom_driver = {
-       .name =         MOD_NAME,
-       .id_table =     ichxrom_pci_tbl,
-       .probe =        ichxrom_init_one,
-       .remove =       ichxrom_remove_one,
-};
-#endif
-
-static struct pci_dev *mydev;
-int __init init_ichxrom(void)
-{
-       struct pci_dev *pdev;
-       struct pci_device_id *id;
-
-       pdev = NULL;
-       for (id = ichxrom_pci_tbl; id->vendor; id++) {
-               pdev = pci_find_device(id->vendor, id->device, NULL);
-               if (pdev) {
-                       break;
-               }
-       }
-       if (pdev) {
-               mydev = pdev;
-               return ichxrom_init_one(pdev, &ichxrom_pci_tbl[0]);
-       }
-       return -ENXIO;
-#if 0
-       return pci_module_init(&ichxrom_driver);
-#endif
-}
-
-static void __exit cleanup_ichxrom(void)
-{
-       ichxrom_remove_one(mydev);
-}
-
-module_init(init_ichxrom);
-module_exit(cleanup_ichxrom);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Eric Biederman <ebiederman@lnxi.com>");
-MODULE_DESCRIPTION("MTD map driver for BIOS chips on the ICHX southbridge");
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
deleted file mode 100644 (file)
index 0f7dedd..0000000
+++ /dev/null
@@ -1,1635 +0,0 @@
-/* 
- * drivers/mtd/nand/diskonchip.c
- *
- * (C) 2003 Red Hat, Inc.
- * (C) 2004 Dan Brown <dan_brown@ieee.org>
- * (C) 2004 Kalev Lember <kalev@smartlink.ee>
- *
- * Author: David Woodhouse <dwmw2@infradead.org>
- * Additional Diskonchip 2000 and Millennium support by Dan Brown <dan_brown@ieee.org>
- * Diskonchip Millennium Plus support by Kalev Lember <kalev@smartlink.ee>
- *
- * Interface to generic NAND code for M-Systems DiskOnChip devices
- *
- * $Id: diskonchip.c,v 1.34 2004/08/09 19:41:12 dbrown Exp $
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <asm/io.h>
-
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/doc2000.h>
-#include <linux/mtd/compatmac.h>
-#include <linux/mtd/partitions.h>
-#include <linux/mtd/inftl.h>
-
-/* Where to look for the devices? */
-#ifndef CONFIG_MTD_DISKONCHIP_PROBE_ADDRESS
-#define CONFIG_MTD_DISKONCHIP_PROBE_ADDRESS 0
-#endif
-
-static unsigned long __initdata doc_locations[] = {
-#if defined (__alpha__) || defined(__i386__) || defined(__x86_64__)
-#ifdef CONFIG_MTD_DISKONCHIP_PROBE_HIGH
-       0xfffc8000, 0xfffca000, 0xfffcc000, 0xfffce000, 
-       0xfffd0000, 0xfffd2000, 0xfffd4000, 0xfffd6000,
-       0xfffd8000, 0xfffda000, 0xfffdc000, 0xfffde000, 
-       0xfffe0000, 0xfffe2000, 0xfffe4000, 0xfffe6000, 
-       0xfffe8000, 0xfffea000, 0xfffec000, 0xfffee000,
-#else /*  CONFIG_MTD_DOCPROBE_HIGH */
-       0xc8000, 0xca000, 0xcc000, 0xce000, 
-       0xd0000, 0xd2000, 0xd4000, 0xd6000,
-       0xd8000, 0xda000, 0xdc000, 0xde000, 
-       0xe0000, 0xe2000, 0xe4000, 0xe6000, 
-       0xe8000, 0xea000, 0xec000, 0xee000,
-#endif /*  CONFIG_MTD_DOCPROBE_HIGH */
-#elif defined(__PPC__)
-       0xe4000000,
-#elif defined(CONFIG_MOMENCO_OCELOT)
-       0x2f000000,
-        0xff000000,
-#elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C)
-        0xff000000,
-##else
-#warning Unknown architecture for DiskOnChip. No default probe locations defined
-#endif
-       0xffffffff };
-
-static struct mtd_info *doclist = NULL;
-
-struct doc_priv {
-       unsigned long virtadr;
-       unsigned long physadr;
-       u_char ChipID;
-       u_char CDSNControl;
-       int chips_per_floor; /* The number of chips detected on each floor */
-       int curfloor;
-       int curchip;
-       int mh0_page;
-       int mh1_page;
-       struct mtd_info *nextdoc;
-};
-
-/* Max number of eraseblocks to scan (from start of device) for the (I)NFTL
-   MediaHeader.  The spec says to just keep going, I think, but that's just
-   silly. */
-#define MAX_MEDIAHEADER_SCAN 8
-
-/* This is the syndrome computed by the HW ecc generator upon reading an empty
-   page, one with all 0xff for data and stored ecc code. */
-static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a };
-/* This is the ecc value computed by the HW ecc generator upon writing an empty
-   page, one with all 0xff for data. */
-static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 };
-
-#define INFTL_BBT_RESERVED_BLOCKS 4
-
-#define DoC_is_MillenniumPlus(doc) ((doc)->ChipID == DOC_ChipID_DocMilPlus16 || (doc)->ChipID == DOC_ChipID_DocMilPlus32)
-#define DoC_is_Millennium(doc) ((doc)->ChipID == DOC_ChipID_DocMil)
-#define DoC_is_2000(doc) ((doc)->ChipID == DOC_ChipID_Doc2k)
-
-static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd);
-static void doc200x_select_chip(struct mtd_info *mtd, int chip);
-
-static int debug=0;
-MODULE_PARM(debug, "i");
-
-static int try_dword=1;
-MODULE_PARM(try_dword, "i");
-
-static int no_ecc_failures=0;
-MODULE_PARM(no_ecc_failures, "i");
-
-static int no_autopart=0;
-MODULE_PARM(no_autopart, "i");
-
-#ifdef MTD_NAND_DISKONCHIP_BBTWRITE
-static int inftl_bbt_write=1;
-#else
-static int inftl_bbt_write=0;
-#endif
-MODULE_PARM(inftl_bbt_write, "i");
-
-static unsigned long doc_config_location = CONFIG_MTD_DISKONCHIP_PROBE_ADDRESS;
-MODULE_PARM(doc_config_location, "l");
-MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
-
-static void DoC_Delay(struct doc_priv *doc, unsigned short cycles)
-{
-       volatile char dummy;
-       int i;
-       
-       for (i = 0; i < cycles; i++) {
-               if (DoC_is_Millennium(doc))
-                       dummy = ReadDOC(doc->virtadr, NOP);
-               else if (DoC_is_MillenniumPlus(doc))
-                       dummy = ReadDOC(doc->virtadr, Mplus_NOP);
-               else
-                       dummy = ReadDOC(doc->virtadr, DOCStatus);
-       }
-       
-}
-
-#define CDSN_CTRL_FR_B_MASK    (CDSN_CTRL_FR_B0 | CDSN_CTRL_FR_B1)
-
-/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
-static int _DoC_WaitReady(struct doc_priv *doc)
-{
-       unsigned long docptr = doc->virtadr;
-       unsigned long timeo = jiffies + (HZ * 10);
-
-       if(debug) printk("_DoC_WaitReady...\n");
-       /* Out-of-line routine to wait for chip response */
-       if (DoC_is_MillenniumPlus(doc)) {
-               while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) {
-                       if (time_after(jiffies, timeo)) {
-                               printk("_DoC_WaitReady timed out.\n");
-                               return -EIO;
-                       }
-                       udelay(1);
-                       cond_resched();
-               }
-       } else {
-               while (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) {
-                       if (time_after(jiffies, timeo)) {
-                               printk("_DoC_WaitReady timed out.\n");
-                               return -EIO;
-                       }
-                       udelay(1);
-                       cond_resched();
-               }
-       }
-
-       return 0;
-}
-
-static inline int DoC_WaitReady(struct doc_priv *doc)
-{
-       unsigned long docptr = doc->virtadr;
-       int ret = 0;
-
-       if (DoC_is_MillenniumPlus(doc)) {
-               DoC_Delay(doc, 4);
-
-               if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK)
-                       /* Call the out-of-line routine to wait */
-                       ret = _DoC_WaitReady(doc);
-       } else {
-               DoC_Delay(doc, 4);
-
-               if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B))
-                       /* Call the out-of-line routine to wait */
-                       ret = _DoC_WaitReady(doc);
-               DoC_Delay(doc, 2);
-       }
-
-       if(debug) printk("DoC_WaitReady OK\n");
-       return ret;
-}
-
-static void doc2000_write_byte(struct mtd_info *mtd, u_char datum)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       if(debug)printk("write_byte %02x\n", datum);
-       WriteDOC(datum, docptr, CDSNSlowIO);
-       WriteDOC(datum, docptr, 2k_CDSN_IO);
-}
-
-static u_char doc2000_read_byte(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       u_char ret;
-
-       ReadDOC(docptr, CDSNSlowIO);
-       DoC_Delay(doc, 2);
-       ret = ReadDOC(docptr, 2k_CDSN_IO);
-       if (debug) printk("read_byte returns %02x\n", ret);
-       return ret;
-}
-
-static void doc2000_writebuf(struct mtd_info *mtd, 
-                            const u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-       if (debug)printk("writebuf of %d bytes: ", len);
-       for (i=0; i < len; i++) {
-               WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i);
-               if (debug && i < 16)
-                       printk("%02x ", buf[i]);
-       }
-       if (debug) printk("\n");
-}
-
-static void doc2000_readbuf(struct mtd_info *mtd, 
-                           u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       if (debug)printk("readbuf of %d bytes: ", len);
-
-       for (i=0; i < len; i++) {
-               buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i);
-       }
-}
-
-static void doc2000_readbuf_dword(struct mtd_info *mtd, 
-                           u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       if (debug) printk("readbuf_dword of %d bytes: ", len);
-
-       if (unlikely((((unsigned long)buf)|len) & 3)) {
-               for (i=0; i < len; i++) {
-                       *(uint8_t *)(&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i);
-               }
-       } else {
-               for (i=0; i < len; i+=4) {
-                       *(uint32_t*)(&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i);
-               }
-       }
-}
-
-static int doc2000_verifybuf(struct mtd_info *mtd, 
-                             const u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       for (i=0; i < len; i++)
-               if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO))
-                       return -EFAULT;
-       return 0;
-}
-
-static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       uint16_t ret;
-
-       doc200x_select_chip(mtd, nr);
-       doc200x_hwcontrol(mtd, NAND_CTL_SETCLE);
-       this->write_byte(mtd, NAND_CMD_READID);
-       doc200x_hwcontrol(mtd, NAND_CTL_CLRCLE);
-       doc200x_hwcontrol(mtd, NAND_CTL_SETALE);
-       this->write_byte(mtd, 0);
-       doc200x_hwcontrol(mtd, NAND_CTL_CLRALE);
-
-       ret = this->read_byte(mtd) << 8;
-       ret |= this->read_byte(mtd);
-
-       if (doc->ChipID == DOC_ChipID_Doc2k && try_dword && !nr) {
-               /* First chip probe. See if we get same results by 32-bit access */
-               union {
-                       uint32_t dword;
-                       uint8_t byte[4];
-               } ident;
-               unsigned long docptr = doc->virtadr;
-
-               doc200x_hwcontrol(mtd, NAND_CTL_SETCLE);
-               doc2000_write_byte(mtd, NAND_CMD_READID);
-               doc200x_hwcontrol(mtd, NAND_CTL_CLRCLE);
-               doc200x_hwcontrol(mtd, NAND_CTL_SETALE);
-               doc2000_write_byte(mtd, 0);
-               doc200x_hwcontrol(mtd, NAND_CTL_CLRALE);
-
-               ident.dword = readl(docptr + DoC_2k_CDSN_IO);
-               if (((ident.byte[0] << 8) | ident.byte[1]) == ret) {
-                       printk(KERN_INFO "DiskOnChip 2000 responds to DWORD access\n");
-                       this->read_buf = &doc2000_readbuf_dword;
-               }
-       }
-               
-       return ret;
-}
-
-static void __init doc2000_count_chips(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       uint16_t mfrid;
-       int i;
-
-       /* Max 4 chips per floor on DiskOnChip 2000 */
-       doc->chips_per_floor = 4;
-
-       /* Find out what the first chip is */
-       mfrid = doc200x_ident_chip(mtd, 0);
-
-       /* Find how many chips in each floor. */
-       for (i = 1; i < 4; i++) {
-               if (doc200x_ident_chip(mtd, i) != mfrid)
-                       break;
-       }
-       doc->chips_per_floor = i;
-       printk(KERN_DEBUG "Detected %d chips per floor.\n", i);
-}
-
-static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
-{
-       struct doc_priv *doc = (void *)this->priv;
-
-       int status;
-       
-       DoC_WaitReady(doc);
-       this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
-       DoC_WaitReady(doc);
-       status = (int)this->read_byte(mtd);
-
-       return status;
-}
-
-static void doc2001_write_byte(struct mtd_info *mtd, u_char datum)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       WriteDOC(datum, docptr, CDSNSlowIO);
-       WriteDOC(datum, docptr, Mil_CDSN_IO);
-       WriteDOC(datum, docptr, WritePipeTerm);
-}
-
-static u_char doc2001_read_byte(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       //ReadDOC(docptr, CDSNSlowIO);
-       /* 11.4.5 -- delay twice to allow extended length cycle */
-       DoC_Delay(doc, 2);
-       ReadDOC(docptr, ReadPipeInit);
-       //return ReadDOC(docptr, Mil_CDSN_IO);
-       return ReadDOC(docptr, LastDataRead);
-}
-
-static void doc2001_writebuf(struct mtd_info *mtd, 
-                            const u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       for (i=0; i < len; i++)
-               WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i);
-       /* Terminate write pipeline */
-       WriteDOC(0x00, docptr, WritePipeTerm);
-}
-
-static void doc2001_readbuf(struct mtd_info *mtd, 
-                           u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       /* Start read pipeline */
-       ReadDOC(docptr, ReadPipeInit);
-
-       for (i=0; i < len-1; i++)
-               buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff));
-
-       /* Terminate read pipeline */
-       buf[i] = ReadDOC(docptr, LastDataRead);
-}
-
-static int doc2001_verifybuf(struct mtd_info *mtd, 
-                            const u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       /* Start read pipeline */
-       ReadDOC(docptr, ReadPipeInit);
-
-       for (i=0; i < len-1; i++)
-               if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) {
-                       ReadDOC(docptr, LastDataRead);
-                       return i;
-               }
-       if (buf[i] != ReadDOC(docptr, LastDataRead))
-               return i;
-       return 0;
-}
-
-static u_char doc2001plus_read_byte(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       u_char ret;
-
-        ReadDOC(docptr, Mplus_ReadPipeInit);
-        ReadDOC(docptr, Mplus_ReadPipeInit);
-        ret = ReadDOC(docptr, Mplus_LastDataRead);
-       if (debug) printk("read_byte returns %02x\n", ret);
-       return ret;
-}
-
-static void doc2001plus_writebuf(struct mtd_info *mtd, 
-                            const u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       if (debug)printk("writebuf of %d bytes: ", len);
-       for (i=0; i < len; i++) {
-               WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i);
-               if (debug && i < 16)
-                       printk("%02x ", buf[i]);
-       }
-       if (debug) printk("\n");
-}
-
-static void doc2001plus_readbuf(struct mtd_info *mtd, 
-                           u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       if (debug)printk("readbuf of %d bytes: ", len);
-
-       /* Start read pipeline */
-       ReadDOC(docptr, Mplus_ReadPipeInit);
-       ReadDOC(docptr, Mplus_ReadPipeInit);
-
-       for (i=0; i < len-2; i++) {
-               buf[i] = ReadDOC(docptr, Mil_CDSN_IO);
-               if (debug && i < 16)
-                       printk("%02x ", buf[i]);
-       }
-
-       /* Terminate read pipeline */
-       buf[len-2] = ReadDOC(docptr, Mplus_LastDataRead);
-       if (debug && i < 16)
-               printk("%02x ", buf[len-2]);
-       buf[len-1] = ReadDOC(docptr, Mplus_LastDataRead);
-       if (debug && i < 16)
-               printk("%02x ", buf[len-1]);
-       if (debug) printk("\n");
-}
-
-static int doc2001plus_verifybuf(struct mtd_info *mtd, 
-                            const u_char *buf, int len)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-
-       if (debug)printk("verifybuf of %d bytes: ", len);
-
-       /* Start read pipeline */
-       ReadDOC(docptr, Mplus_ReadPipeInit);
-       ReadDOC(docptr, Mplus_ReadPipeInit);
-
-       for (i=0; i < len-2; i++)
-               if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) {
-                       ReadDOC(docptr, Mplus_LastDataRead);
-                       ReadDOC(docptr, Mplus_LastDataRead);
-                       return i;
-               }
-       if (buf[len-2] != ReadDOC(docptr, Mplus_LastDataRead))
-               return len-2;
-       if (buf[len-1] != ReadDOC(docptr, Mplus_LastDataRead))
-               return len-1;
-       return 0;
-}
-
-static void doc2001plus_select_chip(struct mtd_info *mtd, int chip)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int floor = 0;
-
-       if(debug)printk("select chip (%d)\n", chip);
-
-       if (chip == -1) {
-               /* Disable flash internally */
-               WriteDOC(0, docptr, Mplus_FlashSelect);
-               return;
-       }
-
-       floor = chip / doc->chips_per_floor;
-       chip -= (floor *  doc->chips_per_floor);
-
-       /* Assert ChipEnable and deassert WriteProtect */
-       WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect);
-       this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
-
-       doc->curchip = chip;
-       doc->curfloor = floor;
-}
-
-static void doc200x_select_chip(struct mtd_info *mtd, int chip)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int floor = 0;
-
-       if(debug)printk("select chip (%d)\n", chip);
-
-       if (chip == -1)
-               return;
-
-       floor = chip / doc->chips_per_floor;
-       chip -= (floor *  doc->chips_per_floor);
-
-       /* 11.4.4 -- deassert CE before changing chip */
-       doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE);
-
-       WriteDOC(floor, docptr, FloorSelect);
-       WriteDOC(chip, docptr, CDSNDeviceSelect);
-
-       doc200x_hwcontrol(mtd, NAND_CTL_SETNCE);
-
-       doc->curchip = chip;
-       doc->curfloor = floor;
-}
-
-static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       switch(cmd) {
-       case NAND_CTL_SETNCE:
-               doc->CDSNControl |= CDSN_CTRL_CE;
-               break;
-       case NAND_CTL_CLRNCE:
-               doc->CDSNControl &= ~CDSN_CTRL_CE;
-               break;
-       case NAND_CTL_SETCLE:
-               doc->CDSNControl |= CDSN_CTRL_CLE;
-               break;
-       case NAND_CTL_CLRCLE:
-               doc->CDSNControl &= ~CDSN_CTRL_CLE;
-               break;
-       case NAND_CTL_SETALE:
-               doc->CDSNControl |= CDSN_CTRL_ALE;
-               break;
-       case NAND_CTL_CLRALE:
-               doc->CDSNControl &= ~CDSN_CTRL_ALE;
-               break;
-       case NAND_CTL_SETWP:
-               doc->CDSNControl |= CDSN_CTRL_WP;
-               break;
-       case NAND_CTL_CLRWP:
-               doc->CDSNControl &= ~CDSN_CTRL_WP;
-               break;
-       }
-       if (debug)printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl);
-       WriteDOC(doc->CDSNControl, docptr, CDSNControl);
-       /* 11.4.3 -- 4 NOPs after CSDNControl write */
-       DoC_Delay(doc, 4);
-}
-
-static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       /*
-        * Must terminate write pipeline before sending any commands
-        * to the device.
-        */
-       if (command == NAND_CMD_PAGEPROG) {
-               WriteDOC(0x00, docptr, Mplus_WritePipeTerm);
-               WriteDOC(0x00, docptr, Mplus_WritePipeTerm);
-       }
-
-       /*
-        * Write out the command to the device.
-        */
-       if (command == NAND_CMD_SEQIN) {
-               int readcmd;
-
-               if (column >= mtd->oobblock) {
-                       /* OOB area */
-                       column -= mtd->oobblock;
-                       readcmd = NAND_CMD_READOOB;
-               } else if (column < 256) {
-                       /* First 256 bytes --> READ0 */
-                       readcmd = NAND_CMD_READ0;
-               } else {
-                       column -= 256;
-                       readcmd = NAND_CMD_READ1;
-               }
-               WriteDOC(readcmd, docptr, Mplus_FlashCmd);
-       }
-       WriteDOC(command, docptr, Mplus_FlashCmd);
-       WriteDOC(0, docptr, Mplus_WritePipeTerm);
-       WriteDOC(0, docptr, Mplus_WritePipeTerm);
-
-       if (column != -1 || page_addr != -1) {
-               /* Serially input address */
-               if (column != -1) {
-                       /* Adjust columns for 16 bit buswidth */
-                       if (this->options & NAND_BUSWIDTH_16)
-                               column >>= 1;
-                       WriteDOC(column, docptr, Mplus_FlashAddress);
-               }
-               if (page_addr != -1) {
-                       WriteDOC((unsigned char) (page_addr & 0xff), docptr, Mplus_FlashAddress);
-                       WriteDOC((unsigned char) ((page_addr >> 8) & 0xff), docptr, Mplus_FlashAddress);
-                       /* One more address cycle for higher density devices */
-                       if (this->chipsize & 0x0c000000) {
-                               WriteDOC((unsigned char) ((page_addr >> 16) & 0x0f), docptr, Mplus_FlashAddress);
-                               printk("high density\n");
-                       }
-               }
-               WriteDOC(0, docptr, Mplus_WritePipeTerm);
-               WriteDOC(0, docptr, Mplus_WritePipeTerm);
-               /* deassert ALE */
-               if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || command == NAND_CMD_READOOB || command == NAND_CMD_READID)
-                       WriteDOC(0, docptr, Mplus_FlashControl);
-       }
-
-       /* 
-        * program and erase have their own busy handlers
-        * status and sequential in needs no delay
-       */
-       switch (command) {
-
-       case NAND_CMD_PAGEPROG:
-       case NAND_CMD_ERASE1:
-       case NAND_CMD_ERASE2:
-       case NAND_CMD_SEQIN:
-       case NAND_CMD_STATUS:
-               return;
-
-       case NAND_CMD_RESET:
-               if (this->dev_ready)
-                       break;
-               udelay(this->chip_delay);
-               WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd);
-               WriteDOC(0, docptr, Mplus_WritePipeTerm);
-               WriteDOC(0, docptr, Mplus_WritePipeTerm);
-               while ( !(this->read_byte(mtd) & 0x40));
-               return;
-
-       /* This applies to read commands */
-       default:
-               /* 
-                * If we don't have access to the busy pin, we apply the given
-                * command delay
-               */
-               if (!this->dev_ready) {
-                       udelay (this->chip_delay);
-                       return;
-               }
-       }
-
-       /* Apply this short delay always to ensure that we do wait tWB in
-        * any case on any machine. */
-       ndelay (100);
-       /* wait until command is processed */
-       while (!this->dev_ready(mtd));
-}
-
-static int doc200x_dev_ready(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       if (DoC_is_MillenniumPlus(doc)) {
-               /* 11.4.2 -- must NOP four times before checking FR/B# */
-               DoC_Delay(doc, 4);
-               if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) {
-                       if(debug)
-                               printk("not ready\n");
-                       return 0;
-               }
-               if (debug)printk("was ready\n");
-               return 1;
-       } else {
-               /* 11.4.2 -- must NOP four times before checking FR/B# */
-               DoC_Delay(doc, 4);
-               if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) {
-                       if(debug)
-                               printk("not ready\n");
-                       return 0;
-               }
-               /* 11.4.2 -- Must NOP twice if it's ready */
-               DoC_Delay(doc, 2);
-               if (debug)printk("was ready\n");
-               return 1;
-       }
-}
-
-static int doc200x_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
-{
-       /* This is our last resort if we couldn't find or create a BBT.  Just
-          pretend all blocks are good. */
-       return 0;
-}
-
-static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       /* Prime the ECC engine */
-       switch(mode) {
-       case NAND_ECC_READ:
-               WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
-               WriteDOC(DOC_ECC_EN, docptr, ECCConf);
-               break;
-       case NAND_ECC_WRITE:
-               WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
-               WriteDOC(DOC_ECC_EN | DOC_ECC_RW, docptr, ECCConf);
-               break;
-       }
-}
-
-static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-
-       /* Prime the ECC engine */
-       switch(mode) {
-       case NAND_ECC_READ:
-               WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf);
-               WriteDOC(DOC_ECC_EN, docptr, Mplus_ECCConf);
-               break;
-       case NAND_ECC_WRITE:
-               WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf);
-               WriteDOC(DOC_ECC_EN | DOC_ECC_RW, docptr, Mplus_ECCConf);
-               break;
-       }
-}
-
-/* This code is only called on write */
-static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
-                                unsigned char *ecc_code)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       int i;
-       int emptymatch = 1;
-
-       /* flush the pipeline */
-       if (DoC_is_2000(doc)) {
-               WriteDOC(doc->CDSNControl & ~CDSN_CTRL_FLASH_IO, docptr, CDSNControl);
-               WriteDOC(0, docptr, 2k_CDSN_IO);
-               WriteDOC(0, docptr, 2k_CDSN_IO);
-               WriteDOC(0, docptr, 2k_CDSN_IO);
-               WriteDOC(doc->CDSNControl, docptr, CDSNControl);
-       } else if (DoC_is_MillenniumPlus(doc)) {
-               WriteDOC(0, docptr, Mplus_NOP);
-               WriteDOC(0, docptr, Mplus_NOP);
-               WriteDOC(0, docptr, Mplus_NOP);
-       } else {
-               WriteDOC(0, docptr, NOP);
-               WriteDOC(0, docptr, NOP);
-               WriteDOC(0, docptr, NOP);
-       }
-
-       for (i = 0; i < 6; i++) {
-               if (DoC_is_MillenniumPlus(doc))
-                       ecc_code[i] = ReadDOC_(docptr, DoC_Mplus_ECCSyndrome0 + i);
-               else 
-                       ecc_code[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
-               if (ecc_code[i] != empty_write_ecc[i])
-                       emptymatch = 0;
-       }
-       if (DoC_is_MillenniumPlus(doc))
-               WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf);
-       else
-               WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
-#if 0
-       /* If emptymatch=1, we might have an all-0xff data buffer.  Check. */
-       if (emptymatch) {
-               /* Note: this somewhat expensive test should not be triggered
-                  often.  It could be optimized away by examining the data in
-                  the writebuf routine, and remembering the result. */
-               for (i = 0; i < 512; i++) {
-                       if (dat[i] == 0xff) continue;
-                       emptymatch = 0;
-                       break;
-               }
-       }
-       /* If emptymatch still =1, we do have an all-0xff data buffer.
-          Return all-0xff ecc value instead of the computed one, so
-          it'll look just like a freshly-erased page. */
-       if (emptymatch) memset(ecc_code, 0xff, 6);
-#endif
-       return 0;
-}
-
-static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)
-{
-       int i, ret = 0;
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned long docptr = doc->virtadr;
-       volatile u_char dummy;
-       int emptymatch = 1;
-       
-       /* flush the pipeline */
-       if (DoC_is_2000(doc)) {
-               dummy = ReadDOC(docptr, 2k_ECCStatus);
-               dummy = ReadDOC(docptr, 2k_ECCStatus);
-               dummy = ReadDOC(docptr, 2k_ECCStatus);
-       } else if (DoC_is_MillenniumPlus(doc)) {
-               dummy = ReadDOC(docptr, Mplus_ECCConf);
-               dummy = ReadDOC(docptr, Mplus_ECCConf);
-               dummy = ReadDOC(docptr, Mplus_ECCConf);
-       } else {
-               dummy = ReadDOC(docptr, ECCConf);
-               dummy = ReadDOC(docptr, ECCConf);
-               dummy = ReadDOC(docptr, ECCConf);
-       }
-       
-       /* Error occured ? */
-       if (dummy & 0x80) {
-               for (i = 0; i < 6; i++) {
-                       if (DoC_is_MillenniumPlus(doc))
-                               calc_ecc[i] = ReadDOC_(docptr, DoC_Mplus_ECCSyndrome0 + i);
-                       else
-                               calc_ecc[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
-                       if (calc_ecc[i] != empty_read_syndrome[i])
-                               emptymatch = 0;
-               }
-               /* If emptymatch=1, the read syndrome is consistent with an
-                  all-0xff data and stored ecc block.  Check the stored ecc. */
-               if (emptymatch) {
-                       for (i = 0; i < 6; i++) {
-                               if (read_ecc[i] == 0xff) continue;
-                               emptymatch = 0;
-                               break;
-                       }
-               }
-               /* If emptymatch still =1, check the data block. */
-               if (emptymatch) {
-               /* Note: this somewhat expensive test should not be triggered
-                  often.  It could be optimized away by examining the data in
-                  the readbuf routine, and remembering the result. */
-                       for (i = 0; i < 512; i++) {
-                               if (dat[i] == 0xff) continue;
-                               emptymatch = 0;
-                               break;
-                       }
-               }
-               /* If emptymatch still =1, this is almost certainly a freshly-
-                  erased block, in which case the ECC will not come out right.
-                  We'll suppress the error and tell the caller everything's
-                  OK.  Because it is. */
-               if (!emptymatch) ret = doc_decode_ecc (dat, calc_ecc);
-               if (ret > 0)
-                       printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
-       }       
-       if (DoC_is_MillenniumPlus(doc))
-               WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf);
-       else
-               WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
-       if (no_ecc_failures && (ret == -1)) {
-               printk(KERN_ERR "suppressing ECC failure\n");
-               ret = 0;
-       }
-       return ret;
-}
-               
-//u_char mydatabuf[528];
-
-static struct nand_oobinfo doc200x_oobinfo = {
-        .useecc = MTD_NANDECC_AUTOPLACE,
-        .eccbytes = 6,
-        .eccpos = {0, 1, 2, 3, 4, 5},
-        .oobfree = { {8, 8} }
-};
-/* Find the (I)NFTL Media Header, and optionally also the mirror media header.
-   On sucessful return, buf will contain a copy of the media header for
-   further processing.  id is the string to scan for, and will presumably be
-   either "ANAND" or "BNAND".  If findmirror=1, also look for the mirror media
-   header.  The page #s of the found media headers are placed in mh0_page and
-   mh1_page in the DOC private structure. */
-static int __init find_media_headers(struct mtd_info *mtd, u_char *buf,
-                                    const char *id, int findmirror)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       unsigned offs, end = (MAX_MEDIAHEADER_SCAN << this->phys_erase_shift);
-       int ret;
-       size_t retlen;
-
-       end = min(end, mtd->size); // paranoia
-       for (offs = 0; offs < end; offs += mtd->erasesize) {
-               ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf);
-               if (retlen != mtd->oobblock) continue;
-               if (ret) {
-                       printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n",
-                               offs);
-               }
-               if (memcmp(buf, id, 6)) continue;
-               printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs);
-               if (doc->mh0_page == -1) {
-                       doc->mh0_page = offs >> this->page_shift;
-                       if (!findmirror) return 1;
-                       continue;
-               }
-               doc->mh1_page = offs >> this->page_shift;
-               return 2;
-       }
-       if (doc->mh0_page == -1) {
-               printk(KERN_WARNING "DiskOnChip %s Media Header not found.\n", id);
-               return 0;
-       }
-       /* Only one mediaheader was found.  We want buf to contain a
-          mediaheader on return, so we'll have to re-read the one we found. */
-       offs = doc->mh0_page << this->page_shift;
-       ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf);
-       if (retlen != mtd->oobblock) {
-               /* Insanity.  Give up. */
-               printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n");
-               return 0;
-       }
-       return 1;
-}
-
-static inline int __init nftl_partscan(struct mtd_info *mtd,
-                               struct mtd_partition *parts)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       int ret = 0;
-       u_char *buf;
-       struct NFTLMediaHeader *mh;
-       const unsigned psize = 1 << this->page_shift;
-       unsigned blocks, maxblocks;
-       int offs, numheaders;
-
-       buf = kmalloc(mtd->oobblock, GFP_KERNEL);
-       if (!buf) {
-               printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n");
-               return 0;
-       }
-       if (!(numheaders=find_media_headers(mtd, buf, "ANAND", 1))) goto out;
-       mh = (struct NFTLMediaHeader *) buf;
-
-//#ifdef CONFIG_MTD_DEBUG_VERBOSE
-//     if (CONFIG_MTD_DEBUG_VERBOSE >= 2)
-       printk(KERN_INFO "    DataOrgID        = %s\n"
-                        "    NumEraseUnits    = %d\n"
-                        "    FirstPhysicalEUN = %d\n"
-                        "    FormattedSize    = %d\n"
-                        "    UnitSizeFactor   = %d\n",
-               mh->DataOrgID, mh->NumEraseUnits,
-               mh->FirstPhysicalEUN, mh->FormattedSize,
-               mh->UnitSizeFactor);
-//#endif
-
-       blocks = mtd->size >> this->phys_erase_shift;
-       maxblocks = min(32768U, mtd->erasesize - psize);
-
-       if (mh->UnitSizeFactor == 0x00) {
-               /* Auto-determine UnitSizeFactor.  The constraints are:
-                  - There can be at most 32768 virtual blocks.
-                  - There can be at most (virtual block size - page size)
-                    virtual blocks (because MediaHeader+BBT must fit in 1).
-               */
-               mh->UnitSizeFactor = 0xff;
-               while (blocks > maxblocks) {
-                       blocks >>= 1;
-                       maxblocks = min(32768U, (maxblocks << 1) + psize);
-                       mh->UnitSizeFactor--;
-               }
-               printk(KERN_WARNING "UnitSizeFactor=0x00 detected.  Correct value is assumed to be 0x%02x.\n", mh->UnitSizeFactor);
-       }
-
-       /* NOTE: The lines below modify internal variables of the NAND and MTD
-          layers; variables with have already been configured by nand_scan.
-          Unfortunately, we didn't know before this point what these values
-          should be.  Thus, this code is somewhat dependant on the exact
-          implementation of the NAND layer.  */
-       if (mh->UnitSizeFactor != 0xff) {
-               this->bbt_erase_shift += (0xff - mh->UnitSizeFactor);
-               mtd->erasesize <<= (0xff - mh->UnitSizeFactor);
-               printk(KERN_INFO "Setting virtual erase size to %d\n", mtd->erasesize);
-               blocks = mtd->size >> this->bbt_erase_shift;
-               maxblocks = min(32768U, mtd->erasesize - psize);
-       }
-
-       if (blocks > maxblocks) {
-               printk(KERN_ERR "UnitSizeFactor of 0x%02x is inconsistent with device size.  Aborting.\n", mh->UnitSizeFactor);
-               goto out;
-       }
-
-       /* Skip past the media headers. */
-       offs = max(doc->mh0_page, doc->mh1_page);
-       offs <<= this->page_shift;
-       offs += mtd->erasesize;
-
-       //parts[0].name = " DiskOnChip Boot / Media Header partition";
-       //parts[0].offset = 0;
-       //parts[0].size = offs;
-
-       parts[0].name = " DiskOnChip BDTL partition";
-       parts[0].offset = offs;
-       parts[0].size = (mh->NumEraseUnits - numheaders) << this->bbt_erase_shift;
-
-       offs += parts[0].size;
-       if (offs < mtd->size) {
-               parts[1].name = " DiskOnChip Remainder partition";
-               parts[1].offset = offs;
-               parts[1].size = mtd->size - offs;
-               ret = 2;
-               goto out;
-       }
-       ret = 1;
-out:
-       kfree(buf);
-       return ret;
-}
-
-/* This is a stripped-down copy of the code in inftlmount.c */
-static inline int __init inftl_partscan(struct mtd_info *mtd,
-                                struct mtd_partition *parts)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       int ret = 0;
-       u_char *buf;
-       struct INFTLMediaHeader *mh;
-       struct INFTLPartition *ip;
-       int numparts = 0;
-       int blocks;
-       int vshift, lastvunit = 0;
-       int i;
-       int end = mtd->size;
-
-       if (inftl_bbt_write)
-               end -= (INFTL_BBT_RESERVED_BLOCKS << this->phys_erase_shift);
-
-       buf = kmalloc(mtd->oobblock, GFP_KERNEL);
-       if (!buf) {
-               printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n");
-               return 0;
-       }
-
-       if (!find_media_headers(mtd, buf, "BNAND", 0)) goto out;
-       doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift);
-       mh = (struct INFTLMediaHeader *) buf;
-
-       mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks);
-       mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions);
-       mh->NoOfBDTLPartitions = le32_to_cpu(mh->NoOfBDTLPartitions);
-       mh->BlockMultiplierBits = le32_to_cpu(mh->BlockMultiplierBits);
-       mh->FormatFlags = le32_to_cpu(mh->FormatFlags);
-       mh->PercentUsed = le32_to_cpu(mh->PercentUsed);
-//#ifdef CONFIG_MTD_DEBUG_VERBOSE
-//     if (CONFIG_MTD_DEBUG_VERBOSE >= 2)
-       printk(KERN_INFO "    bootRecordID          = %s\n"
-                        "    NoOfBootImageBlocks   = %d\n"
-                        "    NoOfBinaryPartitions  = %d\n"
-                        "    NoOfBDTLPartitions    = %d\n"
-                        "    BlockMultiplerBits    = %d\n"
-                        "    FormatFlgs            = %d\n"
-                        "    OsakVersion           = %d.%d.%d.%d\n"
-                        "    PercentUsed           = %d\n",
-               mh->bootRecordID, mh->NoOfBootImageBlocks,
-               mh->NoOfBinaryPartitions,
-               mh->NoOfBDTLPartitions,
-               mh->BlockMultiplierBits, mh->FormatFlags,
-               ((unsigned char *) &mh->OsakVersion)[0] & 0xf,
-               ((unsigned char *) &mh->OsakVersion)[1] & 0xf,
-               ((unsigned char *) &mh->OsakVersion)[2] & 0xf,
-               ((unsigned char *) &mh->OsakVersion)[3] & 0xf,
-               mh->PercentUsed);
-//#endif
-
-       vshift = this->phys_erase_shift + mh->BlockMultiplierBits;
-
-       blocks = mtd->size >> vshift;
-       if (blocks > 32768) {
-               printk(KERN_ERR "BlockMultiplierBits=%d is inconsistent with device size.  Aborting.\n", mh->BlockMultiplierBits);
-               goto out;
-       }
-
-       blocks = doc->chips_per_floor << (this->chip_shift - this->phys_erase_shift);
-       if (inftl_bbt_write && (blocks > mtd->erasesize)) {
-               printk(KERN_ERR "Writeable BBTs spanning more than one erase block are not yet supported.  FIX ME!\n");
-               goto out;
-       }
-
-       /* Scan the partitions */
-       for (i = 0; (i < 4); i++) {
-               ip = &(mh->Partitions[i]);
-               ip->virtualUnits = le32_to_cpu(ip->virtualUnits);
-               ip->firstUnit = le32_to_cpu(ip->firstUnit);
-               ip->lastUnit = le32_to_cpu(ip->lastUnit);
-               ip->flags = le32_to_cpu(ip->flags);
-               ip->spareUnits = le32_to_cpu(ip->spareUnits);
-               ip->Reserved0 = le32_to_cpu(ip->Reserved0);
-
-//#ifdef CONFIG_MTD_DEBUG_VERBOSE
-//             if (CONFIG_MTD_DEBUG_VERBOSE >= 2)
-               printk(KERN_INFO        "    PARTITION[%d] ->\n"
-                       "        virtualUnits    = %d\n"
-                       "        firstUnit       = %d\n"
-                       "        lastUnit        = %d\n"
-                       "        flags           = 0x%x\n"
-                       "        spareUnits      = %d\n",
-                       i, ip->virtualUnits, ip->firstUnit,
-                       ip->lastUnit, ip->flags,
-                       ip->spareUnits);
-//#endif
-
-/*
-               if ((i == 0) && (ip->firstUnit > 0)) {
-                       parts[0].name = " DiskOnChip IPL / Media Header partition";
-                       parts[0].offset = 0;
-                       parts[0].size = mtd->erasesize * ip->firstUnit;
-                       numparts = 1;
-               }
-*/
-
-               if (ip->flags & INFTL_BINARY)
-                       parts[numparts].name = " DiskOnChip BDK partition";
-               else
-                       parts[numparts].name = " DiskOnChip BDTL partition";
-               parts[numparts].offset = ip->firstUnit << vshift;
-               parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift;
-               numparts++;
-               if (ip->lastUnit > lastvunit) lastvunit = ip->lastUnit;
-               if (ip->flags & INFTL_LAST) break;
-       }
-       lastvunit++;
-       if ((lastvunit << vshift) < end) {
-               parts[numparts].name = " DiskOnChip Remainder partition";
-               parts[numparts].offset = lastvunit << vshift;
-               parts[numparts].size = end - parts[numparts].offset;
-               numparts++;
-       }
-       ret = numparts;
-out:
-       kfree(buf);
-       return ret;
-}
-
-static int __init nftl_scan_bbt(struct mtd_info *mtd)
-{
-       int ret, numparts;
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       struct mtd_partition parts[2];
-
-       memset((char *) parts, 0, sizeof(parts));
-       /* On NFTL, we have to find the media headers before we can read the
-          BBTs, since they're stored in the media header eraseblocks. */
-       numparts = nftl_partscan(mtd, parts);
-       if (!numparts) return -EIO;
-       this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT |
-                               NAND_BBT_SAVECONTENT | NAND_BBT_WRITE |
-                               NAND_BBT_VERSION;
-       this->bbt_td->veroffs = 7;
-       this->bbt_td->pages[0] = doc->mh0_page + 1;
-       if (doc->mh1_page != -1) {
-               this->bbt_md->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT |
-                                       NAND_BBT_SAVECONTENT | NAND_BBT_WRITE |
-                                       NAND_BBT_VERSION;
-               this->bbt_md->veroffs = 7;
-               this->bbt_md->pages[0] = doc->mh1_page + 1;
-       } else {
-               this->bbt_md = NULL;
-       }
-
-       /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set.
-          At least as nand_bbt.c is currently written. */
-       if ((ret = nand_scan_bbt(mtd, NULL)))
-               return ret;
-       add_mtd_device(mtd);
-#ifdef CONFIG_MTD_PARTITIONS
-       if (!no_autopart)
-               add_mtd_partitions(mtd, parts, numparts);
-#endif
-       return 0;
-}
-
-static int __init inftl_scan_bbt(struct mtd_info *mtd)
-{
-       int ret, numparts;
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-       struct mtd_partition parts[5];
-
-       if (this->numchips > doc->chips_per_floor) {
-               printk(KERN_ERR "Multi-floor INFTL devices not yet supported.\n");
-               return -EIO;
-       }
-
-       if (DoC_is_MillenniumPlus(doc)) {
-               this->bbt_td->options = NAND_BBT_2BIT | NAND_BBT_ABSPAGE;
-               if (inftl_bbt_write)
-                       this->bbt_td->options |= NAND_BBT_WRITE;
-               this->bbt_td->pages[0] = 2;
-               this->bbt_md = NULL;
-       } else {
-               this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT |
-                                       NAND_BBT_VERSION;
-               if (inftl_bbt_write)
-                       this->bbt_td->options |= NAND_BBT_WRITE;
-               this->bbt_td->offs = 8;
-               this->bbt_td->len = 8;
-               this->bbt_td->veroffs = 7;
-               this->bbt_td->maxblocks = INFTL_BBT_RESERVED_BLOCKS;
-               this->bbt_td->reserved_block_code = 0x01;
-               this->bbt_td->pattern = "MSYS_BBT";
-
-               this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT |
-                                       NAND_BBT_VERSION;
-               if (inftl_bbt_write)
-                       this->bbt_md->options |= NAND_BBT_WRITE;
-               this->bbt_md->offs = 8;
-               this->bbt_md->len = 8;
-               this->bbt_md->veroffs = 7;
-               this->bbt_md->maxblocks = INFTL_BBT_RESERVED_BLOCKS;
-               this->bbt_md->reserved_block_code = 0x01;
-               this->bbt_md->pattern = "TBB_SYSM";
-       }
-
-       /* It's safe to set bd=NULL below because NAND_BBT_CREATE is not set.
-          At least as nand_bbt.c is currently written. */
-       if ((ret = nand_scan_bbt(mtd, NULL)))
-               return ret;
-       memset((char *) parts, 0, sizeof(parts));
-       numparts = inftl_partscan(mtd, parts);
-       /* At least for now, require the INFTL Media Header.  We could probably
-          do without it for non-INFTL use, since all it gives us is
-          autopartitioning, but I want to give it more thought. */
-       if (!numparts) return -EIO;
-       add_mtd_device(mtd);
-#ifdef CONFIG_MTD_PARTITIONS
-       if (!no_autopart)
-               add_mtd_partitions(mtd, parts, numparts);
-#endif
-       return 0;
-}
-
-static inline int __init doc2000_init(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-
-       this->write_byte = doc2000_write_byte;
-       this->read_byte = doc2000_read_byte;
-       this->write_buf = doc2000_writebuf;
-       this->read_buf = doc2000_readbuf;
-       this->verify_buf = doc2000_verifybuf;
-       this->scan_bbt = nftl_scan_bbt;
-
-       doc->CDSNControl = CDSN_CTRL_FLASH_IO | CDSN_CTRL_ECC_IO;
-       doc2000_count_chips(mtd);
-       mtd->name = "DiskOnChip 2000 (NFTL Model)";
-       return (4 * doc->chips_per_floor);
-}
-
-static inline int __init doc2001_init(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-
-       this->write_byte = doc2001_write_byte;
-       this->read_byte = doc2001_read_byte;
-       this->write_buf = doc2001_writebuf;
-       this->read_buf = doc2001_readbuf;
-       this->verify_buf = doc2001_verifybuf;
-
-       ReadDOC(doc->virtadr, ChipID);
-       ReadDOC(doc->virtadr, ChipID);
-       ReadDOC(doc->virtadr, ChipID);
-       if (ReadDOC(doc->virtadr, ChipID) != DOC_ChipID_DocMil) {
-               /* It's not a Millennium; it's one of the newer
-                  DiskOnChip 2000 units with a similar ASIC. 
-                  Treat it like a Millennium, except that it
-                  can have multiple chips. */
-               doc2000_count_chips(mtd);
-               mtd->name = "DiskOnChip 2000 (INFTL Model)";
-               this->scan_bbt = inftl_scan_bbt;
-               return (4 * doc->chips_per_floor);
-       } else {
-               /* Bog-standard Millennium */
-               doc->chips_per_floor = 1;
-               mtd->name = "DiskOnChip Millennium";
-               this->scan_bbt = nftl_scan_bbt;
-               return 1;
-       }
-}
-
-static inline int __init doc2001plus_init(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       struct doc_priv *doc = (void *)this->priv;
-
-       this->write_byte = NULL;
-       this->read_byte = doc2001plus_read_byte;
-       this->write_buf = doc2001plus_writebuf;
-       this->read_buf = doc2001plus_readbuf;
-       this->verify_buf = doc2001plus_verifybuf;
-       this->scan_bbt = inftl_scan_bbt;
-       this->hwcontrol = NULL;
-       this->select_chip = doc2001plus_select_chip;
-       this->cmdfunc = doc2001plus_command;
-       this->enable_hwecc = doc2001plus_enable_hwecc;
-
-       doc->chips_per_floor = 1;
-       mtd->name = "DiskOnChip Millennium Plus";
-
-       return 1;
-}
-
-static inline int __init doc_probe(unsigned long physadr)
-{
-       unsigned char ChipID;
-       struct mtd_info *mtd;
-       struct nand_chip *nand;
-       struct doc_priv *doc;
-       unsigned long virtadr;
-       unsigned char save_control;
-       unsigned char tmp, tmpb, tmpc;
-       int reg, len, numchips;
-       int ret = 0;
-
-       virtadr = (unsigned long)ioremap(physadr, DOC_IOREMAP_LEN);
-       if (!virtadr) {
-               printk(KERN_ERR "Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n", DOC_IOREMAP_LEN, physadr);
-               return -EIO;
-       }
-
-       /* It's not possible to cleanly detect the DiskOnChip - the
-        * bootup procedure will put the device into reset mode, and
-        * it's not possible to talk to it without actually writing
-        * to the DOCControl register. So we store the current contents
-        * of the DOCControl register's location, in case we later decide
-        * that it's not a DiskOnChip, and want to put it back how we
-        * found it. 
-        */
-       save_control = ReadDOC(virtadr, DOCControl);
-
-       /* Reset the DiskOnChip ASIC */
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, 
-                virtadr, DOCControl);
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, 
-                virtadr, DOCControl);
-
-       /* Enable the DiskOnChip ASIC */
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, 
-                virtadr, DOCControl);
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, 
-                virtadr, DOCControl);
-
-       ChipID = ReadDOC(virtadr, ChipID);
-
-       switch(ChipID) {
-       case DOC_ChipID_Doc2k:
-               reg = DoC_2k_ECCStatus;
-               break;
-       case DOC_ChipID_DocMil:
-               reg = DoC_ECCConf;
-               break;
-       case DOC_ChipID_DocMilPlus16:
-       case DOC_ChipID_DocMilPlus32:
-       case 0:
-               /* Possible Millennium Plus, need to do more checks */
-               /* Possibly release from power down mode */
-               for (tmp = 0; (tmp < 4); tmp++)
-                       ReadDOC(virtadr, Mplus_Power);
-
-               /* Reset the Millennium Plus ASIC */
-               tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT |
-                       DOC_MODE_BDECT;
-               WriteDOC(tmp, virtadr, Mplus_DOCControl);
-               WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm);
-
-               mdelay(1);
-               /* Enable the Millennium Plus ASIC */
-               tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT |
-                       DOC_MODE_BDECT;
-               WriteDOC(tmp, virtadr, Mplus_DOCControl);
-               WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm);
-               mdelay(1);
-
-               ChipID = ReadDOC(virtadr, ChipID);
-
-               switch (ChipID) {
-               case DOC_ChipID_DocMilPlus16:
-                       reg = DoC_Mplus_Toggle;
-                       break;
-               case DOC_ChipID_DocMilPlus32:
-                       printk(KERN_ERR "DiskOnChip Millennium Plus 32MB is not supported, ignoring.\n");
-               default:
-                       ret = -ENODEV;
-                       goto notfound;
-               }
-               break;
-
-       default:
-               ret = -ENODEV;
-               goto notfound;
-       }
-       /* Check the TOGGLE bit in the ECC register */
-       tmp  = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
-       tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
-       tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
-       if ((tmp == tmpb) || (tmp != tmpc)) {
-               printk(KERN_WARNING "Possible DiskOnChip at 0x%lx failed TOGGLE test, dropping.\n", physadr);
-               ret = -ENODEV;
-               goto notfound;
-       }
-
-       for (mtd = doclist; mtd; mtd = doc->nextdoc) {
-               unsigned char oldval;
-               unsigned char newval;
-               nand = mtd->priv;
-               doc = (void *)nand->priv;
-               /* Use the alias resolution register to determine if this is
-                  in fact the same DOC aliased to a new address.  If writes
-                  to one chip's alias resolution register change the value on
-                  the other chip, they're the same chip. */
-               if (ChipID == DOC_ChipID_DocMilPlus16) {
-                       oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution);
-                       newval = ReadDOC(virtadr, Mplus_AliasResolution);
-               } else {
-                       oldval = ReadDOC(doc->virtadr, AliasResolution);
-                       newval = ReadDOC(virtadr, AliasResolution);
-               }
-               if (oldval != newval)
-                       continue;
-               if (ChipID == DOC_ChipID_DocMilPlus16) {
-                       WriteDOC(~newval, virtadr, Mplus_AliasResolution);
-                       oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution);
-                       WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it
-               } else {
-                       WriteDOC(~newval, virtadr, AliasResolution);
-                       oldval = ReadDOC(doc->virtadr, AliasResolution);
-                       WriteDOC(newval, virtadr, AliasResolution); // restore it
-               }
-               newval = ~newval;
-               if (oldval == newval) {
-                       printk(KERN_DEBUG "Found alias of DOC at 0x%lx to 0x%lx\n", doc->physadr, physadr);
-                       goto notfound;
-               }
-       }
-
-       printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr);
-
-       len = sizeof(struct mtd_info) +
-             sizeof(struct nand_chip) +
-             sizeof(struct doc_priv) +
-             (2 * sizeof(struct nand_bbt_descr));
-       mtd = kmalloc(len, GFP_KERNEL);
-       if (!mtd) {
-               printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len);
-               ret = -ENOMEM;
-               goto fail;
-       }
-       memset(mtd, 0, len);
-
-       nand                    = (struct nand_chip *) (mtd + 1);
-       doc                     = (struct doc_priv *) (nand + 1);
-       nand->bbt_td            = (struct nand_bbt_descr *) (doc + 1);
-       nand->bbt_md            = nand->bbt_td + 1;
-
-       mtd->priv               = (void *) nand;
-       mtd->owner              = THIS_MODULE;
-
-       nand->priv              = (void *) doc;
-       nand->select_chip       = doc200x_select_chip;
-       nand->hwcontrol         = doc200x_hwcontrol;
-       nand->dev_ready         = doc200x_dev_ready;
-       nand->waitfunc          = doc200x_wait;
-       nand->block_bad         = doc200x_block_bad;
-       nand->enable_hwecc      = doc200x_enable_hwecc;
-       nand->calculate_ecc     = doc200x_calculate_ecc;
-       nand->correct_data      = doc200x_correct_data;
-       //nand->data_buf
-       nand->autooob           = &doc200x_oobinfo;
-       nand->eccmode           = NAND_ECC_HW6_512;
-       nand->options           = NAND_USE_FLASH_BBT | NAND_HWECC_SYNDROME;
-
-       doc->physadr            = physadr;
-       doc->virtadr            = virtadr;
-       doc->ChipID             = ChipID;
-       doc->curfloor           = -1;
-       doc->curchip            = -1;
-       doc->mh0_page           = -1;
-       doc->mh1_page           = -1;
-       doc->nextdoc            = doclist;
-
-       if (ChipID == DOC_ChipID_Doc2k)
-               numchips = doc2000_init(mtd);
-       else if (ChipID == DOC_ChipID_DocMilPlus16)
-               numchips = doc2001plus_init(mtd);
-       else
-               numchips = doc2001_init(mtd);
-
-       if ((ret = nand_scan(mtd, numchips))) {
-               /* DBB note: i believe nand_release is necessary here, as
-                  buffers may have been allocated in nand_base.  Check with
-                  Thomas. FIX ME! */
-               /* nand_release will call del_mtd_device, but we haven't yet
-                  added it.  This is handled without incident by
-                  del_mtd_device, as far as I can tell. */
-               nand_release(mtd);
-               kfree(mtd);
-               goto fail;
-       }
-
-       /* Success! */
-       doclist = mtd;
-       return 0;
-
-notfound:
-       /* Put back the contents of the DOCControl register, in case it's not
-          actually a DiskOnChip.  */
-       WriteDOC(save_control, virtadr, DOCControl);
-fail:
-       iounmap((void *)virtadr);
-       return ret;
-}
-
-int __init init_nanddoc(void)
-{
-       int i;
-
-       if (doc_config_location) {
-               printk(KERN_INFO "Using configured DiskOnChip probe address 0x%lx\n", doc_config_location);
-               return doc_probe(doc_config_location);
-       } else {
-               for (i=0; (doc_locations[i] != 0xffffffff); i++) {
-                       doc_probe(doc_locations[i]);
-               }
-       }
-       /* No banner message any more. Print a message if no DiskOnChip
-          found, so the user knows we at least tried. */
-       if (!doclist) {
-               printk(KERN_INFO "No valid DiskOnChip devices found\n");
-               return -ENODEV;
-       }
-       return 0;
-}
-
-void __exit cleanup_nanddoc(void)
-{
-       struct mtd_info *mtd, *nextmtd;
-       struct nand_chip *nand;
-       struct doc_priv *doc;
-
-       for (mtd = doclist; mtd; mtd = nextmtd) {
-               nand = mtd->priv;
-               doc = (void *)nand->priv;
-
-               nextmtd = doc->nextdoc;
-               nand_release(mtd);
-               iounmap((void *)doc->virtadr);
-               kfree(mtd);
-       }
-}
-
-module_init(init_nanddoc);
-module_exit(cleanup_nanddoc);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
-MODULE_DESCRIPTION("M-Systems DiskOnChip 2000, Millennium and Millennium Plus device driver\n");
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
deleted file mode 100644 (file)
index e991942..0000000
+++ /dev/null
@@ -1,1397 +0,0 @@
-/*
- *  drivers/mtd/nand.c
- *
- *  Overview:
- *   This is the generic MTD driver for NAND flash devices. It should be
- *   capable of working with almost all NAND chips currently available.
- *   
- *     Additional technical information is available on
- *     http://www.linux-mtd.infradead.org/tech/nand.html
- *     
- *  Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
- *               2002 Thomas Gleixner (tglx@linutronix.de)
- *
- *  10-29-2001  Thomas Gleixner (tglx@linutronix.de)
- *             - Changed nand_chip structure for controlline function to
- *             support different hardware structures (Access to
- *             controllines ALE,CLE,NCE via hardware specific function. 
- *             - exit out of "failed erase block" changed, to avoid
- *             driver hangup
- *             - init_waitqueue_head added in function nand_scan !!
- *
- *  01-30-2002  Thomas Gleixner (tglx@linutronix.de)
- *             change in nand_writev to block invalid vecs entries
- *
- *  02-11-2002  Thomas Gleixner (tglx@linutronix.de)
- *             - major rewrite to avoid duplicated code
- *               common nand_write_page function  
- *               common get_chip function 
- *             - added oob_config structure for out of band layouts
- *             - write_oob changed for partial programming
- *             - read cache for faster access for subsequent reads
- *             from the same page.
- *             - support for different read/write address
- *             - support for device ready/busy line
- *             - read oob for more than one page enabled
- *
- *  02-27-2002 Thomas Gleixner (tglx@linutronix.de)
- *             - command-delay can be programmed
- *             - fixed exit from erase with callback-function enabled
- *
- *  03-21-2002  Thomas Gleixner (tglx@linutronix.de)
- *             - DEBUG improvements provided by Elizabeth Clarke 
- *             (eclarke@aminocom.com)
- *             - added zero check for this->chip_delay
- *
- *  04-03-2002  Thomas Gleixner (tglx@linutronix.de)
- *             - added added hw-driver supplied command and wait functions
- *             - changed blocking for erase (erase suspend enabled)
- *             - check pointers before accessing flash provided by
- *             John Hall (john.hall@optionexist.co.uk)
- *
- *  04-09-2002  Thomas Gleixner (tglx@linutronix.de)
- *             - nand_wait repaired
- *
- *  04-28-2002  Thomas Gleixner (tglx@linutronix.de)   
- *             - OOB config defines moved to nand.h 
- *
- *  08-01-2002  Thomas Gleixner (tglx@linutronix.de)   
- *             - changed my mailaddress, added pointer to tech/nand.html
- *
- *  08-07-2002         Thomas Gleixner (tglx@linutronix.de)
- *             forced bad block location to byte 5 of OOB, even if
- *             CONFIG_MTD_NAND_ECC_JFFS2 is not set, to prevent
- *             erase /dev/mtdX from erasing bad blocks and destroying
- *             bad block info
- *
- *  08-10-2002         Thomas Gleixner (tglx@linutronix.de)
- *             Fixed writing tail of data. Thanks to Alice Hennessy
- *             <ahennessy@mvista.com>.
- *
- *  08-10-2002         Thomas Gleixner (tglx@linutronix.de)
- *             nand_read_ecc and nand_write_page restructured to support
- *             hardware ECC. Thanks to Steven Hein (ssh@sgi.com)
- *             for basic implementation and suggestions.
- *             3 new pointers in nand_chip structure:
- *             calculate_ecc, correct_data, enabled_hwecc                                       
- *             forcing all hw-drivers to support page cache
- *             eccvalid_pos is now mandatory
- *
- *  08-17-2002 tglx: fixed signed/unsigned missmatch in write.c
- *             Thanks to Ken Offer <koffer@arlut.utexas.edu>   
- *
- *  08-29-2002  tglx: use buffered read/write only for non pagealigned 
- *             access, speed up the aligned path by using the fs-buffer
- *             reset chip removed from nand_select(), implicit done
- *             only, when erase is interrupted
- *             waitfuntion use yield, instead of schedule_timeout
- *             support for 6byte/512byte hardware ECC
- *             read_ecc, write_ecc extended for different oob-layout
- *             selections: Implemented NAND_NONE_OOB, NAND_JFFS2_OOB,
- *             NAND_YAFFS_OOB. fs-driver gives one of these constants
- *             to select the oob-layout fitting the filesystem.
- *             oobdata can be read together with the raw data, when
- *             the fs-driver supplies a big enough buffer.
- *             size = 12 * number of pages to read (256B pagesize)
- *                    24 * number of pages to read (512B pagesize)
- *             the buffer contains 8/16 byte oobdata and 4/8 byte
- *             returncode from calculate_ecc
- *             oobdata can be given from filesystem to program them
- *             in one go together with the raw data. ECC codes are
- *             filled in at the place selected by oobsel.
- *
- *  09-04-2002  tglx: fixed write_verify (John Hall (john.hall@optionexist.co.uk))
- *
- *  11-11-2002  tglx: fixed debug output in nand_write_page 
- *             (John Hall (john.hall@optionexist.co.uk))
- *
- *  11-25-2002  tglx: Moved device ID/ manufacturer ID from nand_ids.h
- *             Splitted device ID and manufacturer ID table. 
- *             Removed CONFIG_MTD_NAND_ECC, as it defaults to ECC_NONE for
- *             mtd->read / mtd->write and is controllable by the fs driver
- *             for mtd->read_ecc / mtd->write_ecc
- *             some minor cleanups
- *
- *  12-05-2002  tglx: Dave Ellis (DGE@sixnetio) provided the fix for
- *             WRITE_VERIFY long time ago. Thanks for remembering me.  
- *
- *  02-14-2003  tglx: Reject non page aligned writes   
- *             Fixed ecc select in nand_write_page to match semantics. 
- *
- *  02-18-2003 tglx: Changed oobsel to pointer. Added a default oob-selector
- *                     
- *  02-18-2003 tglx: Implemented oobsel again. Now it uses a pointer to
- +             a structure, which will be supplied by a filesystem driver
- *             If NULL is given, then the defaults (none or defaults
- *             supplied by ioctl (MEMSETOOBSEL) are used.
- *             For partitions the partition defaults are used (mtdpart.c)
- *
- *  06-04-2003  tglx: fix compile errors and fix write verify problem for
- *             some chips, which need either a delay between the readback
- *             and the next write command or have the CE removed. The
- *             CE disable/enable is much faster than a 20us delay and
- *             it should work on all available chips.
- *     
- * $Id: nand.c,v 1.46 2003/06/04 17:10:36 gleixner Exp $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/nand_ecc.h>
-#include <linux/mtd/compatmac.h>
-#include <linux/interrupt.h>
-#include <asm/io.h>
-
-/*
- * Macros for low-level register control
- */
-#define nand_select()  this->hwcontrol(NAND_CTL_SETNCE);
-#define nand_deselect() this->hwcontrol(NAND_CTL_CLRNCE);
-
-/*
- * NAND low-level MTD interface functions
- */
-static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
-static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-                         size_t * retlen, u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
-static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
-static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf);
-static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
-                          size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
-static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf);
-static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs,
-                       unsigned long count, loff_t to, size_t * retlen);
-static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs,
-                       unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
-static int nand_erase (struct mtd_info *mtd, struct erase_info *instr);
-static void nand_sync (struct mtd_info *mtd);
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf,  struct nand_oobinfo *oobsel);
-
-
-/*
- * Send command to NAND device
- */
-static void nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
-{
-       register struct nand_chip *this = mtd->priv;
-       register unsigned long NAND_IO_ADDR = this->IO_ADDR_W;
-
-       /* Begin command latch cycle */
-       this->hwcontrol (NAND_CTL_SETCLE);
-       /*
-        * Write out the command to the device.
-        */
-       if (command != NAND_CMD_SEQIN)
-               writeb (command, NAND_IO_ADDR);
-       else {
-               if (mtd->oobblock == 256 && column >= 256) {
-                       column -= 256;
-                       writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
-                       writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
-               } else if (mtd->oobblock == 512 && column >= 256) {
-                       if (column < 512) {
-                               column -= 256;
-                               writeb (NAND_CMD_READ1, NAND_IO_ADDR);
-                               writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
-                       } else {
-                               column -= 512;
-                               writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
-                               writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
-                       }
-               } else {
-                       writeb (NAND_CMD_READ0, NAND_IO_ADDR);
-                       writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
-               }
-       }
-
-       /* Set ALE and clear CLE to start address cycle */
-       this->hwcontrol (NAND_CTL_CLRCLE);
-
-       if (column != -1 || page_addr != -1) {
-               this->hwcontrol (NAND_CTL_SETALE);
-
-               /* Serially input address */
-               if (column != -1)
-                       writeb (column, NAND_IO_ADDR);
-               if (page_addr != -1) {
-                       writeb ((unsigned char) (page_addr & 0xff), NAND_IO_ADDR);
-                       writeb ((unsigned char) ((page_addr >> 8) & 0xff), NAND_IO_ADDR);
-                       /* One more address cycle for higher density devices */
-                       if (mtd->size & 0x0c000000) 
-                               writeb ((unsigned char) ((page_addr >> 16) & 0x0f), NAND_IO_ADDR);
-               }
-               /* Latch in address */
-               this->hwcontrol (NAND_CTL_CLRALE);
-       }
-       
-       /* 
-        * program and erase have their own busy handlers 
-        * status and sequential in needs no delay
-       */
-       switch (command) {
-                       
-       case NAND_CMD_PAGEPROG:
-       case NAND_CMD_ERASE1:
-       case NAND_CMD_ERASE2:
-       case NAND_CMD_SEQIN:
-       case NAND_CMD_STATUS:
-               return;
-
-       case NAND_CMD_RESET:
-               if (this->dev_ready)    
-                       break;
-               this->hwcontrol (NAND_CTL_SETCLE);
-               writeb (NAND_CMD_STATUS, NAND_IO_ADDR);
-               this->hwcontrol (NAND_CTL_CLRCLE);
-               while ( !(readb (this->IO_ADDR_R) & 0x40));
-               return;
-
-       /* This applies to read commands */     
-       default:
-               /* 
-                * If we don't have access to the busy pin, we apply the given
-                * command delay
-               */
-               if (!this->dev_ready) {
-                       udelay (this->chip_delay);
-                       return;
-               }       
-       }
-       
-       /* wait until command is processed */
-       while (!this->dev_ready());
-}
-
-/*
- *     Get chip for selected access
- */
-static inline void nand_get_chip (struct nand_chip *this, struct mtd_info *mtd, int new_state, int *erase_state)
-{
-
-       DECLARE_WAITQUEUE (wait, current);
-
-       /* 
-        * Grab the lock and see if the device is available 
-        * For erasing, we keep the spinlock until the
-        * erase command is written. 
-       */
-retry:
-       spin_lock_bh (&this->chip_lock);
-
-       if (this->state == FL_READY) {
-               this->state = new_state;
-               if (new_state != FL_ERASING)
-                       spin_unlock_bh (&this->chip_lock);
-               return;
-       }
-
-       if (this->state == FL_ERASING) {
-               if (new_state != FL_ERASING) {
-                       this->state = new_state;
-                       spin_unlock_bh (&this->chip_lock);
-                       nand_select (); /* select in any case */
-                       this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
-                       return;
-               }
-       }
-
-       set_current_state (TASK_UNINTERRUPTIBLE);
-       add_wait_queue (&this->wq, &wait);
-       spin_unlock_bh (&this->chip_lock);
-       schedule ();
-       remove_wait_queue (&this->wq, &wait);
-       goto retry;
-}
-
-/*
- * Wait for command done. This applies to erase and program only
- * Erase can take up to 400ms and program up to 20ms according to 
- * general NAND and SmartMedia specs
- *
-*/
-static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
-{
-
-       unsigned long   timeo = jiffies;
-       int     status;
-       
-       if (state == FL_ERASING)
-                timeo += (HZ * 400) / 1000;
-       else
-                timeo += (HZ * 20) / 1000;
-
-       spin_lock_bh (&this->chip_lock);
-       this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-
-       while (time_before(jiffies, timeo)) {           
-               /* Check, if we were interrupted */
-               if (this->state != state) {
-                       spin_unlock_bh (&this->chip_lock);
-                       return 0;
-               }
-               if (this->dev_ready) {
-                       if (this->dev_ready ())
-                               break;
-               }
-               if (readb (this->IO_ADDR_R) & 0x40)
-                       break;
-                                               
-               spin_unlock_bh (&this->chip_lock);
-               yield ();
-               spin_lock_bh (&this->chip_lock);
-       }
-       status = (int) readb (this->IO_ADDR_R);
-       spin_unlock_bh (&this->chip_lock);
-
-       return status;
-}
-
-/*
- *     Nand_page_program function is used for write and writev !
- *     This function will always program a full page of data
- *     If you call it with a non page aligned buffer, you're lost :)
- */
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf,  struct nand_oobinfo *oobsel)
-{
-       int     i, status;
-       u_char  ecc_code[6], *oob_data;
-       int     eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
-       int     *oob_config = oobsel->eccpos;
-       
-       /* pad oob area, if we have no oob buffer from fs-driver */
-       if (!oob_buf) {
-               oob_data = &this->data_buf[mtd->oobblock];
-               for (i = 0; i < mtd->oobsize; i++)
-                       oob_data[i] = 0xff;
-       } else 
-               oob_data = oob_buf;
-       
-       /* Send command to begin auto page programming */
-       this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page);
-
-       /* Write out complete page of data, take care of eccmode */
-       switch (eccmode) {
-       /* No ecc and software ecc 3/256, write all */
-       case NAND_ECC_NONE:
-               printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");
-               for (i = 0; i < mtd->oobblock; i++) 
-                       writeb ( this->data_poi[i] , this->IO_ADDR_W);
-               break;
-       case NAND_ECC_SOFT:
-               this->calculate_ecc (&this->data_poi[0], &(ecc_code[0]));
-               for (i = 0; i < 3; i++)
-                       oob_data[oob_config[i]] = ecc_code[i];
-               /* Calculate and write the second ECC for 512 Byte page size */
-               if (mtd->oobblock == 512) {
-                       this->calculate_ecc (&this->data_poi[256], &(ecc_code[3]));
-                       for (i = 3; i < 6; i++)
-                               oob_data[oob_config[i]] = ecc_code[i];
-               } 
-               for (i = 0; i < mtd->oobblock; i++) 
-                       writeb ( this->data_poi[i] , this->IO_ADDR_W);
-               break;
-               
-       /* Hardware ecc 3 byte / 256 data, write first half, get ecc, then second, if 512 byte pagesize */      
-       case NAND_ECC_HW3_256:          
-               this->enable_hwecc (NAND_ECC_WRITE);    /* enable hardware ecc logic for write */
-               for (i = 0; i < mtd->eccsize; i++) 
-                       writeb ( this->data_poi[i] , this->IO_ADDR_W);
-               
-               this->calculate_ecc (NULL, &(ecc_code[0]));
-               for (i = 0; i < 3; i++)
-                       oob_data[oob_config[i]] = ecc_code[i];
-                       
-               if (mtd->oobblock == 512) {
-                       this->enable_hwecc (NAND_ECC_WRITE);    /* enable hardware ecc logic for write*/
-                       for (i = mtd->eccsize; i < mtd->oobblock; i++) 
-                               writeb ( this->data_poi[i] , this->IO_ADDR_W);
-                       this->calculate_ecc (NULL, &(ecc_code[3]));
-                       for (i = 3; i < 6; i++)
-                               oob_data[oob_config[i]] = ecc_code[i];
-               }
-               break;
-                               
-       /* Hardware ecc 3 byte / 512 byte data, write full page */      
-       case NAND_ECC_HW3_512:  
-               this->enable_hwecc (NAND_ECC_WRITE);    /* enable hardware ecc logic */
-               for (i = 0; i < mtd->oobblock; i++) 
-                       writeb ( this->data_poi[i] , this->IO_ADDR_W);
-               this->calculate_ecc (NULL, &(ecc_code[0]));
-               for (i = 0; i < 3; i++)
-                       oob_data[oob_config[i]] = ecc_code[i];
-               break;
-
-       /* Hardware ecc 6 byte / 512 byte data, write full page */      
-       case NAND_ECC_HW6_512:  
-               this->enable_hwecc (NAND_ECC_WRITE);    /* enable hardware ecc logic */
-               for (i = 0; i < mtd->oobblock; i++) 
-                       writeb ( this->data_poi[i] , this->IO_ADDR_W);
-               this->calculate_ecc (NULL, &(ecc_code[0]));
-               for (i = 0; i < 6; i++)
-                       oob_data[oob_config[i]] = ecc_code[i];
-               break;
-               
-       default:
-               printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
-               BUG();  
-       }       
-       
-       /* Write out OOB data */
-       for (i = 0; i <  mtd->oobsize; i++)
-               writeb ( oob_data[i] , this->IO_ADDR_W);
-
-       /* Send command to actually program the data */
-       this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1);
-
-       /* call wait ready function */
-       status = this->waitfunc (mtd, this, FL_WRITING);
-
-       /* See if device thinks it succeeded */
-       if (status & 0x01) {
-               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page);
-               return -EIO;
-       }
-
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
-       /*
-        * The NAND device assumes that it is always writing to
-        * a cleanly erased page. Hence, it performs its internal
-        * write verification only on bits that transitioned from
-        * 1 to 0. The device does NOT verify the whole page on a
-        * byte by byte basis. It is possible that the page was
-        * not completely erased or the page is becoming unusable
-        * due to wear. The read with ECC would catch the error
-        * later when the ECC page check fails, but we would rather
-        * catch it early in the page write stage. Better to write
-        * no data than invalid data.
-        */
-
-       /* Send command to read back the page */
-       this->cmdfunc (mtd, NAND_CMD_READ0, 0, page);
-       /* Loop through and verify the data */
-       for (i = 0; i < mtd->oobblock; i++) {
-               if (this->data_poi[i] != readb (this->IO_ADDR_R)) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
-                       return -EIO;
-               }
-       }
-
-       /* check, if we have a fs-supplied oob-buffer */
-       if (oob_buf) {
-               for (i = 0; i < mtd->oobsize; i++) {
-                       if (oob_data[i] != readb (this->IO_ADDR_R)) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
-                               return -EIO;
-                       }
-               }
-       } else {
-               if (eccmode != NAND_ECC_NONE) {
-                       int ecc_bytes = 0;
-
-                       switch (this->eccmode) {
-                       case NAND_ECC_SOFT:
-                       case NAND_ECC_HW3_256: ecc_bytes = (mtd->oobblock == 512) ? 6 : 3; break;
-                       case NAND_ECC_HW3_512: ecc_bytes = 3; break;
-                       case NAND_ECC_HW6_512: ecc_bytes = 6; break;
-                       }
-
-                       for (i = 0; i < mtd->oobsize; i++)
-                               oob_data[i] = readb (this->IO_ADDR_R);
-
-                       for (i = 0; i < ecc_bytes; i++) {
-                               if (oob_data[oob_config[i]] != ecc_code[i]) {
-                                       DEBUG (MTD_DEBUG_LEVEL0,
-                                              "%s: Failed ECC write "
-                                      "verify, page 0x%08x, " "%6i bytes were succesful\n", __FUNCTION__, page, i);
-                               return -EIO;
-                               }
-                       }
-               }
-       }
-       /* 
-        * Terminate the read command. This is faster than sending a reset command or 
-        * applying a 20us delay before issuing the next programm sequence.
-        * This is not a problem for all chips, but I have found a bunch of them.
-        */
-       nand_deselect();
-       nand_select();
-#endif
-       return 0;
-}
-
-/*
-*      Use NAND read ECC
-*/
-static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
-{
-       return (nand_read_ecc (mtd, from, len, retlen, buf, NULL, NULL));
-}                         
-
-
-/*
- * NAND read with ECC
- */
-static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-                         size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel)
-{
-       int j, col, page, end, ecc;
-       int erase_state = 0;
-       int read = 0, oob = 0, ecc_status = 0, ecc_failed = 0;
-       struct nand_chip *this = mtd->priv;
-       u_char *data_poi, *oob_data = oob_buf;
-       u_char ecc_calc[6];
-       u_char ecc_code[6];
-       int     eccmode;
-       int     *oob_config;
-
-       // use chip default if zero
-       if (oobsel == NULL)
-               oobsel = &mtd->oobinfo;
-               
-       eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
-       oob_config = oobsel->eccpos;
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
-
-       /* Do not allow reads past end of device */
-       if ((from + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: Attempt read beyond end of device\n");
-               *retlen = 0;
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd ,FL_READING, &erase_state);
-
-       /* Select the NAND device */
-       nand_select ();
-
-       /* First we calculate the starting page */
-       page = from >> this->page_shift;
-
-       /* Get raw starting column */
-       col = from & (mtd->oobblock - 1);
-
-       end = mtd->oobblock;
-       ecc = mtd->eccsize;
-
-       /* Send the read command */
-       this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page);
-       
-       /* Loop until all data read */
-       while (read < len) {
-               
-               /* If we have consequent page reads, apply delay or wait for ready/busy pin */
-               if (read) {
-                       if (!this->dev_ready) 
-                               udelay (this->chip_delay);
-                       else
-                               while (!this->dev_ready());     
-               }
-
-               /* 
-                * If the read is not page aligned, we have to read into data buffer
-                * due to ecc, else we read into return buffer direct
-                */
-               if (!col && (len - read) >= end)  
-                       data_poi = &buf[read];
-               else 
-                       data_poi = this->data_buf;
-
-               /* get oob area, if we have no oob buffer from fs-driver */
-               if (!oob_buf) {
-                       oob_data = &this->data_buf[end];
-                       oob = 0;
-               }       
-                       
-               j = 0;
-               switch (eccmode) {
-               case NAND_ECC_NONE:     /* No ECC, Read in a page */            
-                       printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n");
-                       while (j < end)
-                               data_poi[j++] = readb (this->IO_ADDR_R);
-                       break;
-                       
-               case NAND_ECC_SOFT:     /* Software ECC 3/256: Read in a page + oob data */
-                       while (j < end)
-                               data_poi[j++] = readb (this->IO_ADDR_R);
-                       this->calculate_ecc (&data_poi[0], &ecc_calc[0]);
-                       if (mtd->oobblock == 512)
-                               this->calculate_ecc (&data_poi[256], &ecc_calc[3]);
-                       break;  
-                       
-               case NAND_ECC_HW3_256: /* Hardware ECC 3 byte /256 byte data: Read in first 256 byte, get ecc, */
-                       this->enable_hwecc (NAND_ECC_READ);     
-                       while (j < ecc)
-                               data_poi[j++] = readb (this->IO_ADDR_R);
-                       this->calculate_ecc (&data_poi[0], &ecc_calc[0]);       /* read from hardware */
-                       
-                       if (mtd->oobblock == 512) { /* read second, if pagesize = 512 */
-                               this->enable_hwecc (NAND_ECC_READ);     
-                               while (j < end)
-                                       data_poi[j++] = readb (this->IO_ADDR_R);
-                               this->calculate_ecc (&data_poi[256], &ecc_calc[3]); /* read from hardware */
-                       }                                       
-                       break;                                          
-                               
-               case NAND_ECC_HW3_512:  
-               case NAND_ECC_HW6_512: /* Hardware ECC 3/6 byte / 512 byte data : Read in a page  */
-                       this->enable_hwecc (NAND_ECC_READ);     
-                       while (j < end)
-                               data_poi[j++] = readb (this->IO_ADDR_R);
-                       this->calculate_ecc (&data_poi[0], &ecc_calc[0]);       /* read from hardware */
-                       break;
-
-               default:
-                       printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
-                       BUG();  
-               }
-
-               /* read oobdata */
-               for (j = 0; j <  mtd->oobsize; j++) 
-                       oob_data[oob + j] = readb (this->IO_ADDR_R);
-               
-               /* Skip ECC, if not active */
-               if (eccmode == NAND_ECC_NONE)
-                       goto readdata;  
-               
-               /* Pick the ECC bytes out of the oob data */
-               for (j = 0; j < 6; j++)
-                       ecc_code[j] = oob_data[oob + oob_config[j]];
-
-               /* correct data, if neccecary */
-               ecc_status = this->correct_data (&data_poi[0], &ecc_code[0], &ecc_calc[0]);
-               /* check, if we have a fs supplied oob-buffer */
-               if (oob_buf) { 
-                       oob += mtd->oobsize;
-                       *((int *)&oob_data[oob]) = ecc_status;
-                       oob += sizeof(int);
-               }
-               if (ecc_status == -1) { 
-                       DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
-                       ecc_failed++;
-               }
-               
-               if (mtd->oobblock == 512 && eccmode != NAND_ECC_HW3_512) {
-                       ecc_status = this->correct_data (&data_poi[256], &ecc_code[3], &ecc_calc[3]);
-                       if (oob_buf) {
-                               *((int *)&oob_data[oob]) = ecc_status;
-                               oob += sizeof(int);
-                       }
-                       if (ecc_status == -1) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
-                               ecc_failed++;
-                       }
-               }
-readdata:
-               if (col || (len - read) < end) { 
-                       for (j = col; j < end && read < len; j++)
-                               buf[read++] = data_poi[j];
-               } else          
-                       read += mtd->oobblock;
-               /* For subsequent reads align to page boundary. */
-               col = 0;
-               /* Increment page address */
-               page++;
-       }
-
-       /* De-select the NAND device */
-       nand_deselect ();
-
-       /* Wake up anyone waiting on the device */
-       spin_lock_bh (&this->chip_lock);
-       this->state = FL_READY;
-       wake_up (&this->wq);
-       spin_unlock_bh (&this->chip_lock);
-
-       /*
-        * Return success, if no ECC failures, else -EIO
-        * fs driver will take care of that, because
-        * retlen == desired len and result == -EIO
-        */
-       *retlen = read;
-       return ecc_failed ? -EIO : 0;
-}
-
-/*
- * NAND read out-of-band
- */
-static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
-{
-       int i, col, page;
-       int erase_state = 0;
-       struct nand_chip *this = mtd->priv;
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
-
-       /* Shift to get page */
-       page = ((int) from) >> this->page_shift;
-
-       /* Mask to get column */
-       col = from & 0x0f;
-
-       /* Initialize return length value */
-       *retlen = 0;
-
-       /* Do not allow reads past end of device */
-       if ((from + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n");
-               *retlen = 0;
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd , FL_READING, &erase_state);
-
-       /* Select the NAND device */
-       nand_select ();
-
-       /* Send the read command */
-       this->cmdfunc (mtd, NAND_CMD_READOOB, col, page);
-       /* 
-        * Read the data, if we read more than one page
-        * oob data, let the device transfer the data !
-        */
-       for (i = 0; i < len; i++) {
-               buf[i] = readb (this->IO_ADDR_R);
-               if ((col++ & (mtd->oobsize - 1)) == (mtd->oobsize - 1))
-                       udelay (this->chip_delay);
-       }
-       /* De-select the NAND device */
-       nand_deselect ();
-
-       /* Wake up anyone waiting on the device */
-       spin_lock_bh (&this->chip_lock);
-       this->state = FL_READY;
-       wake_up (&this->wq);
-       spin_unlock_bh (&this->chip_lock);
-
-       /* Return happy */
-       *retlen = len;
-       return 0;
-}
-
-#define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0
-
-/*
-*      Use NAND write ECC
-*/
-static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf)
-{
-       return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL));
-}                         
-/*
- * NAND write with ECC
- */
-static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
-                          size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel)
-{
-       int page, ret = 0, oob = 0, written = 0;
-       struct nand_chip *this = mtd->priv;
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
-
-       /* Do not allow write past end of device */
-       if ((to + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n");
-               return -EINVAL;
-       }
-
-       /* reject writes, which are not page aligned */ 
-       if (NOTALIGNED (to) || NOTALIGNED(len)) {
-               printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
-               return -EINVAL;
-       }
-
-       // if oobsel is NULL, use chip defaults
-       if (oobsel == NULL) 
-               oobsel = &mtd->oobinfo;         
-
-       /* Shift to get page */
-       page = ((int) to) >> this->page_shift;
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_WRITING, NULL);
-
-       /* Select the NAND device */
-       nand_select ();
-
-       /* Check the WP bit */
-       this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-       if (!(readb (this->IO_ADDR_R) & 0x80)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Device is write protected!!!\n");
-               ret = -EIO;
-               goto out;
-       }
-
-       /* Loop until all data is written */
-       while (written < len) {
-               int cnt = mtd->oobblock;
-               this->data_poi = (u_char*) &buf[written];
-               /* We use the same function for write and writev */
-               if (eccbuf) {
-                       ret = nand_write_page (mtd, this, page, &eccbuf[oob], oobsel);
-                       oob += mtd->oobsize;
-               } else 
-                       ret = nand_write_page (mtd, this, page, NULL, oobsel);  
-               
-               if (ret)
-                       goto out;
-
-               /* Update written bytes count */
-               written += cnt;
-               /* Increment page address */
-               page++;
-       }
-
-out:
-       /* De-select the NAND device */
-       nand_deselect ();
-
-       /* Wake up anyone waiting on the device */
-       spin_lock_bh (&this->chip_lock);
-       this->state = FL_READY;
-       wake_up (&this->wq);
-       spin_unlock_bh (&this->chip_lock);
-
-       *retlen = written;
-       return ret;
-}
-
-/*
- * NAND write out-of-band
- */
-static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf)
-{
-       int i, column, page, status, ret = 0;
-       struct nand_chip *this = mtd->priv;
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
-
-       /* Shift to get page */
-       page = ((int) to) >> this->page_shift;
-
-       /* Mask to get column */
-       column = to & 0x1f;
-
-       /* Initialize return length value */
-       *retlen = 0;
-
-       /* Do not allow write past end of page */
-       if ((column + len) > mtd->oobsize) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n");
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_WRITING, NULL);
-
-       /* Select the NAND device */
-       nand_select ();
-
-       /* Check the WP bit */
-       this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-       if (!(readb (this->IO_ADDR_R) & 0x80)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Device is write protected!!!\n");
-               ret = -EIO;
-               goto out;
-       }
-
-       /* Write out desired data */
-       this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page);
-       /* prepad 0xff for partial programming */
-       for (i = 0; i < column; i++)
-               writeb (0xff, this->IO_ADDR_W);
-       /* write data */
-       for (i = 0; i < len; i++)
-               writeb (buf[i], this->IO_ADDR_W);       
-       /* postpad 0xff for partial programming */
-       for (i = len + column; i < mtd->oobsize; i++)
-               writeb (0xff, this->IO_ADDR_W);
-
-       /* Send command to program the OOB data */
-       this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1);
-
-       status = this->waitfunc (mtd, this, FL_WRITING);
-
-       /* See if device thinks it succeeded */
-       if (status & 0x01) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page);
-               ret = -EIO;
-               goto out;
-       }
-       /* Return happy */
-       *retlen = len;
-
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
-       /* Send command to read back the data */
-       this->cmdfunc (mtd, NAND_CMD_READOOB, column, page);
-
-       /* Loop through and verify the data */
-       for (i = 0; i < len; i++) {
-               if (buf[i] != readb (this->IO_ADDR_R)) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page);
-                       ret = -EIO;
-                       goto out;
-               }
-       }
-#endif
-
-out:
-       /* De-select the NAND device */
-       nand_deselect ();
-
-       /* Wake up anyone waiting on the device */
-       spin_lock_bh (&this->chip_lock);
-       this->state = FL_READY;
-       wake_up (&this->wq);
-       spin_unlock_bh (&this->chip_lock);
-
-       return ret;
-}
-
-
-/*
- * NAND write with iovec
- */
-static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, 
-               loff_t to, size_t * retlen)
-{
-       return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, 0));       
-}
-
-static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, 
-               loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel)
-{
-       int i, page, len, total_len, ret = 0, written = 0;
-       struct nand_chip *this = mtd->priv;
-
-       /* Calculate total length of data */
-       total_len = 0;
-       for (i = 0; i < count; i++)
-               total_len += (int) vecs[i].iov_len;
-
-       DEBUG (MTD_DEBUG_LEVEL3,
-              "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
-
-       /* Do not allow write past end of page */
-       if ((to + total_len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n");
-               return -EINVAL;
-       }
-
-       /* reject writes, which are not page aligned */ 
-       if (NOTALIGNED (to) || NOTALIGNED(total_len)) {
-               printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
-               return -EINVAL;
-       }
-
-       // if oobsel is NULL, use chip defaults
-       if (oobsel == NULL) 
-               oobsel = &mtd->oobinfo;         
-
-       /* Shift to get page */
-       page = ((int) to) >> this->page_shift;
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_WRITING, NULL);
-
-       /* Select the NAND device */
-       nand_select ();
-
-       /* Check the WP bit */
-       this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-       if (!(readb (this->IO_ADDR_R) & 0x80)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Device is write protected!!!\n");
-               ret = -EIO;
-               goto out;
-       }
-
-       /* Loop until all iovecs' data has been written */
-       len = 0;
-       while (count) {
-               /* 
-                *  Check, if the tuple gives us not enough data for a 
-                *  full page write. Then we can use the iov direct, 
-                *  else we have to copy into data_buf.         
-                */
-               if ((vecs->iov_len - len) >= mtd->oobblock) {
-                       this->data_poi = (u_char *) vecs->iov_base;
-                       this->data_poi += len;
-                       len += mtd->oobblock; 
-                       /* Check, if we have to switch to the next tuple */
-                       if (len >= (int) vecs->iov_len) {
-                               vecs++;
-                               len = 0;
-                               count--;
-                       }
-               } else {
-                       /*
-                        * Read data out of each tuple until we have a full page
-                        * to write or we've read all the tuples.
-                       */
-                       int cnt = 0;
-                       while ((cnt < mtd->oobblock) && count) {
-                               if (vecs->iov_base != NULL && vecs->iov_len) {
-                                       this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++];
-                               }
-                               /* Check, if we have to switch to the next tuple */
-                               if (len >= (int) vecs->iov_len) {
-                                       vecs++;
-                                       len = 0;
-                                       count--;
-                               }
-                       }       
-                       this->data_poi = this->data_buf;        
-               }
-               
-               /* We use the same function for write and writev !) */
-               ret = nand_write_page (mtd, this, page, NULL, oobsel);
-               if (ret)
-                       goto out;
-
-               /* Update written bytes count */
-               written += mtd->oobblock;
-
-               /* Increment page address */
-               page++;
-       }
-
-out:
-       /* De-select the NAND device */
-       nand_deselect ();
-
-       /* Wake up anyone waiting on the device */
-       spin_lock_bh (&this->chip_lock);
-       this->state = FL_READY;
-       wake_up (&this->wq);
-       spin_unlock_bh (&this->chip_lock);
-
-       *retlen = written;
-       return ret;
-}
-
-/*
- * NAND erase a block
- */
-static int nand_erase (struct mtd_info *mtd, struct erase_info *instr)
-{
-       int page, len, status, pages_per_block, ret;
-       struct nand_chip *this = mtd->priv;
-       DECLARE_WAITQUEUE (wait, current);
-
-       DEBUG (MTD_DEBUG_LEVEL3,
-              "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
-
-       /* Start address must align on block boundary */
-       if (instr->addr & (mtd->erasesize - 1)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n");
-               return -EINVAL;
-       }
-
-       /* Length must align on block boundary */
-       if (instr->len & (mtd->erasesize - 1)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n");
-               return -EINVAL;
-       }
-
-       /* Do not allow erase past end of device */
-       if ((instr->len + instr->addr) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n");
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_ERASING, NULL);
-
-       /* Shift to get first page */
-       page = (int) (instr->addr >> this->page_shift);
-
-       /* Calculate pages in each block */
-       pages_per_block = mtd->erasesize / mtd->oobblock;
-
-       /* Select the NAND device */
-       nand_select ();
-
-       /* Check the WP bit */
-       this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-       if (!(readb (this->IO_ADDR_R) & 0x80)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n");
-               instr->state = MTD_ERASE_FAILED;
-               goto erase_exit;
-       }
-
-       /* Loop through the pages */
-       len = instr->len;
-
-       instr->state = MTD_ERASING;
-
-       while (len) {
-               /* Check if we have a bad block, we do not erase bad blocks ! */
-               this->cmdfunc (mtd, NAND_CMD_READOOB, NAND_BADBLOCK_POS, page);
-               if (readb (this->IO_ADDR_R) != 0xff) {
-                       printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page);
-                       instr->state = MTD_ERASE_FAILED;
-                       goto erase_exit;
-               }
-
-               /* Send commands to erase a page */
-               this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page);
-               this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);
-
-               spin_unlock_bh (&this->chip_lock);
-               status = this->waitfunc (mtd, this, FL_ERASING);
-
-               /* Get spinlock, in case we exit */
-               spin_lock_bh (&this->chip_lock);
-               /* See if block erase succeeded */
-               if (status & 0x01) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page);
-                       instr->state = MTD_ERASE_FAILED;
-                       goto erase_exit;
-               }
-               
-               /* Check, if we were interupted */
-               if (this->state == FL_ERASING) {
-                       /* Increment page address and decrement length */
-                       len -= mtd->erasesize;
-                       page += pages_per_block;
-               }
-               /* Release the spin lock */
-               spin_unlock_bh (&this->chip_lock);
-erase_retry:
-               spin_lock_bh (&this->chip_lock);
-               /* Check the state and sleep if it changed */
-               if (this->state == FL_ERASING || this->state == FL_READY) {
-                       /* Select the NAND device again, if we were interrupted */
-                       this->state = FL_ERASING;
-                       nand_select ();
-                       continue;
-               } else {
-                       set_current_state (TASK_UNINTERRUPTIBLE);
-                       add_wait_queue (&this->wq, &wait);
-                       spin_unlock_bh (&this->chip_lock);
-                       schedule ();
-                       remove_wait_queue (&this->wq, &wait);
-                       goto erase_retry;
-               }
-       }
-       instr->state = MTD_ERASE_DONE;
-
-erase_exit:
-       /* De-select the NAND device */
-       nand_deselect ();
-       spin_unlock_bh (&this->chip_lock);
-
-       ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
-       /* Do call back function */
-       if (!ret && instr->callback)
-               instr->callback (instr);
-
-       /* The device is ready */
-       spin_lock_bh (&this->chip_lock);
-       this->state = FL_READY;
-       spin_unlock_bh (&this->chip_lock);
-
-       /* Return more or less happy */
-       return ret;
-}
-
-/*
- * NAND sync
- */
-static void nand_sync (struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       DECLARE_WAITQUEUE (wait, current);
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n");
-
-retry:
-       /* Grab the spinlock */
-       spin_lock_bh (&this->chip_lock);
-
-       /* See what's going on */
-       switch (this->state) {
-       case FL_READY:
-       case FL_SYNCING:
-               this->state = FL_SYNCING;
-               spin_unlock_bh (&this->chip_lock);
-               break;
-
-       default:
-               /* Not an idle state */
-               add_wait_queue (&this->wq, &wait);
-               spin_unlock_bh (&this->chip_lock);
-               schedule ();
-
-               remove_wait_queue (&this->wq, &wait);
-               goto retry;
-       }
-
-       /* Lock the device */
-       spin_lock_bh (&this->chip_lock);
-
-       /* Set the device to be ready again */
-       if (this->state == FL_SYNCING) {
-               this->state = FL_READY;
-               wake_up (&this->wq);
-       }
-
-       /* Unlock the device */
-       spin_unlock_bh (&this->chip_lock);
-}
-
-/*
- * Scan for the NAND device
- */
-int nand_scan (struct mtd_info *mtd)
-{
-       int i, nand_maf_id, nand_dev_id;
-       struct nand_chip *this = mtd->priv;
-
-       /* check for proper chip_delay setup, set 20us if not */
-       if (!this->chip_delay)
-               this->chip_delay = 20;
-
-       /* check, if a user supplied command function given */
-       if (this->cmdfunc == NULL)
-               this->cmdfunc = nand_command;
-
-       /* check, if a user supplied wait function given */
-       if (this->waitfunc == NULL)
-               this->waitfunc = nand_wait;
-
-       /* Select the device */
-       nand_select ();
-
-       /* Send the command for reading device ID */
-       this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
-
-       /* Read manufacturer and device IDs */
-       nand_maf_id = readb (this->IO_ADDR_R);
-       nand_dev_id = readb (this->IO_ADDR_R);
-
-       /* Print and store flash device information */
-       for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-               if (nand_dev_id == nand_flash_ids[i].id && !mtd->size) {
-                       mtd->name = nand_flash_ids[i].name;
-                       mtd->erasesize = nand_flash_ids[i].erasesize;
-                       mtd->size = (1 << nand_flash_ids[i].chipshift);
-                       mtd->eccsize = 256;
-                       if (nand_flash_ids[i].page256) {
-                               mtd->oobblock = 256;
-                               mtd->oobsize = 8;
-                               this->page_shift = 8;
-                       } else {
-                               mtd->oobblock = 512;
-                               mtd->oobsize = 16;
-                               this->page_shift = 9;
-                       }
-                       /* Try to identify manufacturer */
-                       for (i = 0; nand_manuf_ids[i].id != 0x0; i++) {
-                               if (nand_manuf_ids[i].id == nand_maf_id)
-                                       break;
-                       }       
-                       printk (KERN_INFO "NAND device: Manufacture ID:"
-                               " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 
-                               nand_manuf_ids[i].name , mtd->name);
-                       break;
-               }
-       }
-
-       /* 
-        * check ECC mode, default to software
-        * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize
-        * fallback to software ECC 
-       */
-       this->eccsize = 256;    /* set default eccsize */       
-
-       switch (this->eccmode) {
-
-       case NAND_ECC_HW3_512: 
-               if (mtd->oobblock == 256) {
-                       printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n");
-                       this->eccmode = NAND_ECC_SOFT;
-                       this->calculate_ecc = nand_calculate_ecc;
-                       this->correct_data = nand_correct_data;
-                       break;          
-               } else 
-                       this->eccsize = 512; /* set eccsize to 512 and fall through for function check */
-
-       case NAND_ECC_HW3_256:
-               if (this->calculate_ecc && this->correct_data && this->enable_hwecc)
-                       break;
-               printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n");
-               BUG();  
-
-       case NAND_ECC_NONE: 
-               printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n");
-               this->eccmode = NAND_ECC_NONE;
-               break;
-
-       case NAND_ECC_SOFT:     
-               this->calculate_ecc = nand_calculate_ecc;
-               this->correct_data = nand_correct_data;
-               break;
-
-       default:
-               printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
-               BUG();  
-       }       
-       
-       /* Initialize state, waitqueue and spinlock */
-       this->state = FL_READY;
-       init_waitqueue_head (&this->wq);
-       spin_lock_init (&this->chip_lock);
-
-       /* De-select the device */
-       nand_deselect ();
-
-       /* Print warning message for no device */
-       if (!mtd->size) {
-               printk (KERN_WARNING "No NAND device found!!!\n");
-               return 1;
-       }
-
-       /* Fill in remaining MTD driver data */
-       mtd->type = MTD_NANDFLASH;
-       mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
-       mtd->ecctype = MTD_ECC_SW;
-       mtd->erase = nand_erase;
-       mtd->point = NULL;
-       mtd->unpoint = NULL;
-       mtd->read = nand_read;
-       mtd->write = nand_write;
-       mtd->read_ecc = nand_read_ecc;
-       mtd->write_ecc = nand_write_ecc;
-       mtd->read_oob = nand_read_oob;
-       mtd->write_oob = nand_write_oob;
-       mtd->readv = NULL;
-       mtd->writev = nand_writev;
-       mtd->writev_ecc = nand_writev_ecc;
-       mtd->sync = nand_sync;
-       mtd->lock = NULL;
-       mtd->unlock = NULL;
-       mtd->suspend = NULL;
-       mtd->resume = NULL;
-       mtd->owner = THIS_MODULE;
-
-       /* Return happy */
-       return 0;
-}
-
-EXPORT_SYMBOL (nand_scan);
-
-MODULE_LICENSE ("GPL");
-MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>");
-MODULE_DESCRIPTION ("Generic NAND flash driver code");
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
deleted file mode 100644 (file)
index ff6adf4..0000000
+++ /dev/null
@@ -1,2581 +0,0 @@
-/*
- *  drivers/mtd/nand.c
- *
- *  Overview:
- *   This is the generic MTD driver for NAND flash devices. It should be
- *   capable of working with almost all NAND chips currently available.
- *   Basic support for AG-AND chips is provided.
- *   
- *     Additional technical information is available on
- *     http://www.linux-mtd.infradead.org/tech/nand.html
- *     
- *  Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
- *               2002 Thomas Gleixner (tglx@linutronix.de)
- *
- *  02-08-2004  tglx: support for strange chips, which cannot auto increment 
- *             pages on read / read_oob
- *
- *  03-17-2004  tglx: Check ready before auto increment check. Simon Bayes
- *             pointed this out, as he marked an auto increment capable chip
- *             as NOAUTOINCR in the board driver.
- *             Make reads over block boundaries work too
- *
- *  04-14-2004 tglx: first working version for 2k page size chips
- *  
- *  05-19-2004  tglx: Basic support for Renesas AG-AND chips
- *
- * Credits:
- *     David Woodhouse for adding multichip support  
- *     
- *     Aleph One Ltd. and Toby Churchill Ltd. for supporting the
- *     rework for 2K page size chips
- *
- * TODO:
- *     Enable cached programming for 2k page size chips
- *     Check, if mtd->ecctype should be set to MTD_ECC_HW
- *     if we have HW ecc support.
- *     The AG-AND chips have nice features for speed improvement,
- *     which are not supported yet. Read / program 4 pages in one go.
- *
- * $Id: nand_base.c,v 1.115 2004/08/09 13:19:45 dwmw2 Exp $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/nand_ecc.h>
-#include <linux/mtd/compatmac.h>
-#include <linux/interrupt.h>
-#include <linux/bitops.h>
-#include <asm/io.h>
-
-#ifdef CONFIG_MTD_PARTITIONS
-#include <linux/mtd/partitions.h>
-#endif
-
-/* Define default oob placement schemes for large and small page devices */
-static struct nand_oobinfo nand_oob_8 = {
-       .useecc = MTD_NANDECC_AUTOPLACE,
-       .eccbytes = 3,
-       .eccpos = {0, 1, 2},
-       .oobfree = { {3, 2}, {6, 2} }
-};
-
-static struct nand_oobinfo nand_oob_16 = {
-       .useecc = MTD_NANDECC_AUTOPLACE,
-       .eccbytes = 6,
-       .eccpos = {0, 1, 2, 3, 6, 7},
-       .oobfree = { {8, 8} }
-};
-
-static struct nand_oobinfo nand_oob_64 = {
-       .useecc = MTD_NANDECC_AUTOPLACE,
-       .eccbytes = 24,
-       .eccpos = {
-               40, 41, 42, 43, 44, 45, 46, 47, 
-               48, 49, 50, 51, 52, 53, 54, 55, 
-               56, 57, 58, 59, 60, 61, 62, 63},
-       .oobfree = { {2, 38} }
-};
-
-/* This is used for padding purposes in nand_write_oob */
-static u_char ffchars[] = {
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-};
-
-/*
- * NAND low-level MTD interface functions
- */
-static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len);
-static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len);
-static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len);
-
-static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
-static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-                         size_t * retlen, u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
-static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
-static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf);
-static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
-                          size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
-static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf);
-static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs,
-                       unsigned long count, loff_t to, size_t * retlen);
-static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs,
-                       unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
-static int nand_erase (struct mtd_info *mtd, struct erase_info *instr);
-static void nand_sync (struct mtd_info *mtd);
-
-/* Some internal functions */
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf,
-               struct nand_oobinfo *oobsel, int mode);
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
-static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, 
-       u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode);
-#else
-#define nand_verify_pages(...) (0)
-#endif
-               
-static void nand_get_chip (struct nand_chip *this, struct mtd_info *mtd, int new_state);
-
-/**
- * nand_release_chip - [GENERIC] release chip
- * @mtd:       MTD device structure
- * 
- * Deselect, release chip lock and wake up anyone waiting on the device 
- */
-static void nand_release_chip (struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-
-       /* De-select the NAND device */
-       this->select_chip(mtd, -1);
-       /* Release the chip */
-       spin_lock_bh (&this->chip_lock);
-       this->state = FL_READY;
-       wake_up (&this->wq);
-       spin_unlock_bh (&this->chip_lock);
-}
-
-/**
- * nand_read_byte - [DEFAULT] read one byte from the chip
- * @mtd:       MTD device structure
- *
- * Default read function for 8bit buswith
- */
-static u_char nand_read_byte(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       return readb(this->IO_ADDR_R);
-}
-
-/**
- * nand_write_byte - [DEFAULT] write one byte to the chip
- * @mtd:       MTD device structure
- * @byte:      pointer to data byte to write
- *
- * Default write function for 8it buswith
- */
-static void nand_write_byte(struct mtd_info *mtd, u_char byte)
-{
-       struct nand_chip *this = mtd->priv;
-       writeb(byte, this->IO_ADDR_W);
-}
-
-/**
- * nand_read_byte16 - [DEFAULT] read one byte endianess aware from the chip
- * @mtd:       MTD device structure
- *
- * Default read function for 16bit buswith with 
- * endianess conversion
- */
-static u_char nand_read_byte16(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       return (u_char) cpu_to_le16(readw(this->IO_ADDR_R));
-}
-
-/**
- * nand_write_byte16 - [DEFAULT] write one byte endianess aware to the chip
- * @mtd:       MTD device structure
- * @byte:      pointer to data byte to write
- *
- * Default write function for 16bit buswith with
- * endianess conversion
- */
-static void nand_write_byte16(struct mtd_info *mtd, u_char byte)
-{
-       struct nand_chip *this = mtd->priv;
-       writew(le16_to_cpu((u16) byte), this->IO_ADDR_W);
-}
-
-/**
- * nand_read_word - [DEFAULT] read one word from the chip
- * @mtd:       MTD device structure
- *
- * Default read function for 16bit buswith without 
- * endianess conversion
- */
-static u16 nand_read_word(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       return readw(this->IO_ADDR_R);
-}
-
-/**
- * nand_write_word - [DEFAULT] write one word to the chip
- * @mtd:       MTD device structure
- * @word:      data word to write
- *
- * Default write function for 16bit buswith without 
- * endianess conversion
- */
-static void nand_write_word(struct mtd_info *mtd, u16 word)
-{
-       struct nand_chip *this = mtd->priv;
-       writew(word, this->IO_ADDR_W);
-}
-
-/**
- * nand_select_chip - [DEFAULT] control CE line
- * @mtd:       MTD device structure
- * @chip:      chipnumber to select, -1 for deselect
- *
- * Default select function for 1 chip devices.
- */
-static void nand_select_chip(struct mtd_info *mtd, int chip)
-{
-       struct nand_chip *this = mtd->priv;
-       switch(chip) {
-       case -1:
-               this->hwcontrol(mtd, NAND_CTL_CLRNCE);  
-               break;
-       case 0:
-               this->hwcontrol(mtd, NAND_CTL_SETNCE);
-               break;
-
-       default:
-               BUG();
-       }
-}
-
-/**
- * nand_write_buf - [DEFAULT] write buffer to chip
- * @mtd:       MTD device structure
- * @buf:       data buffer
- * @len:       number of bytes to write
- *
- * Default write function for 8bit buswith
- */
-static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i=0; i<len; i++)
-               writeb(buf[i], this->IO_ADDR_W);
-}
-
-/**
- * nand_read_buf - [DEFAULT] read chip data into buffer 
- * @mtd:       MTD device structure
- * @buf:       buffer to store date
- * @len:       number of bytes to read
- *
- * Default read function for 8bit buswith
- */
-static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i=0; i<len; i++)
-               buf[i] = readb(this->IO_ADDR_R);
-}
-
-/**
- * nand_verify_buf - [DEFAULT] Verify chip data against buffer 
- * @mtd:       MTD device structure
- * @buf:       buffer containing the data to compare
- * @len:       number of bytes to compare
- *
- * Default verify function for 8bit buswith
- */
-static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i=0; i<len; i++)
-               if (buf[i] != readb(this->IO_ADDR_R))
-                       return -EFAULT;
-
-       return 0;
-}
-
-/**
- * nand_write_buf16 - [DEFAULT] write buffer to chip
- * @mtd:       MTD device structure
- * @buf:       data buffer
- * @len:       number of bytes to write
- *
- * Default write function for 16bit buswith
- */
-static void nand_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-       u16 *p = (u16 *) buf;
-       len >>= 1;
-       
-       for (i=0; i<len; i++)
-               writew(p[i], this->IO_ADDR_W);
-               
-}
-
-/**
- * nand_read_buf16 - [DEFAULT] read chip data into buffer 
- * @mtd:       MTD device structure
- * @buf:       buffer to store date
- * @len:       number of bytes to read
- *
- * Default read function for 16bit buswith
- */
-static void nand_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-       u16 *p = (u16 *) buf;
-       len >>= 1;
-
-       for (i=0; i<len; i++)
-               p[i] = readw(this->IO_ADDR_R);
-}
-
-/**
- * nand_verify_buf16 - [DEFAULT] Verify chip data against buffer 
- * @mtd:       MTD device structure
- * @buf:       buffer containing the data to compare
- * @len:       number of bytes to compare
- *
- * Default verify function for 16bit buswith
- */
-static int nand_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-       u16 *p = (u16 *) buf;
-       len >>= 1;
-
-       for (i=0; i<len; i++)
-               if (p[i] != readw(this->IO_ADDR_R))
-                       return -EFAULT;
-
-       return 0;
-}
-
-/**
- * nand_block_bad - [DEFAULT] Read bad block marker from the chip
- * @mtd:       MTD device structure
- * @ofs:       offset from device start
- * @getchip:   0, if the chip is already selected
- *
- * Check, if the block is bad. 
- */
-static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
-{
-       int page, chipnr, res = 0;
-       struct nand_chip *this = mtd->priv;
-       u16 bad;
-
-       if (getchip) {
-               page = (int)(ofs >> this->page_shift);
-               chipnr = (int)(ofs >> this->chip_shift);
-
-               /* Grab the lock and see if the device is available */
-               nand_get_chip (this, mtd, FL_READING);
-
-               /* Select the NAND device */
-               this->select_chip(mtd, chipnr);
-       } else 
-               page = (int) ofs;       
-
-       if (this->options & NAND_BUSWIDTH_16) {
-               this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask);
-               bad = cpu_to_le16(this->read_word(mtd));
-               if (this->badblockpos & 0x1)
-                       bad >>= 1;
-               if ((bad & 0xFF) != 0xff)
-                       res = 1;
-       } else {
-               this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask);
-               if (this->read_byte(mtd) != 0xff)
-                       res = 1;
-       }
-               
-       if (getchip) {
-               /* Deselect and wake up anyone waiting on the device */
-               nand_release_chip(mtd);
-       }       
-       
-       return res;
-}
-
-/**
- * nand_default_block_markbad - [DEFAULT] mark a block bad
- * @mtd:       MTD device structure
- * @ofs:       offset from device start
- *
- * This is the default implementation, which can be overridden by
- * a hardware specific driver.
-*/
-static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
-{
-       struct nand_chip *this = mtd->priv;
-       u_char buf[2] = {0, 0};
-       size_t  retlen;
-       int block;
-       
-       /* Get block number */
-       block = ((int) ofs) >> this->bbt_erase_shift;
-       this->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);
-
-       /* Do we have a flash based bad block table ? */
-       if (this->options & NAND_USE_FLASH_BBT)
-               return nand_update_bbt (mtd, ofs);
-               
-       /* We write two bytes, so we dont have to mess with 16 bit access */
-       ofs += mtd->oobsize + (this->badblockpos & ~0x01);
-       return nand_write_oob (mtd, ofs , 2, &retlen, buf);
-}
-
-/** 
- * nand_check_wp - [GENERIC] check if the chip is write protected
- * @mtd:       MTD device structure
- * Check, if the device is write protected 
- *
- * The function expects, that the device is already selected 
- */
-static int nand_check_wp (struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       /* Check the WP bit */
-       this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-       return (this->read_byte(mtd) & 0x80) ? 0 : 1; 
-}
-
-/**
- * nand_block_checkbad - [GENERIC] Check if a block is marked bad
- * @mtd:       MTD device structure
- * @ofs:       offset from device start
- * @getchip:   0, if the chip is already selected
- * @allowbbt:  1, if its allowed to access the bbt area
- *
- * Check, if the block is bad. Either by reading the bad block table or
- * calling of the scan function.
- */
-static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt)
-{
-       struct nand_chip *this = mtd->priv;
-       
-       if (!this->bbt)
-               return this->block_bad(mtd, ofs, getchip);
-       
-       /* Return info from the table */
-       return nand_isbad_bbt (mtd, ofs, allowbbt);
-}
-
-/**
- * nand_command - [DEFAULT] Send command to NAND device
- * @mtd:       MTD device structure
- * @command:   the command to be sent
- * @column:    the column address for this command, -1 if none
- * @page_addr: the page address for this command, -1 if none
- *
- * Send command to NAND device. This function is used for small page
- * devices (256/512 Bytes per page)
- */
-static void nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
-{
-       register struct nand_chip *this = mtd->priv;
-
-       /* Begin command latch cycle */
-       this->hwcontrol(mtd, NAND_CTL_SETCLE);
-       /*
-        * Write out the command to the device.
-        */
-       if (command == NAND_CMD_SEQIN) {
-               int readcmd;
-
-               if (column >= mtd->oobblock) {
-                       /* OOB area */
-                       column -= mtd->oobblock;
-                       readcmd = NAND_CMD_READOOB;
-               } else if (column < 256) {
-                       /* First 256 bytes --> READ0 */
-                       readcmd = NAND_CMD_READ0;
-               } else {
-                       column -= 256;
-                       readcmd = NAND_CMD_READ1;
-               }
-               this->write_byte(mtd, readcmd);
-       }
-       this->write_byte(mtd, command);
-
-       /* Set ALE and clear CLE to start address cycle */
-       this->hwcontrol(mtd, NAND_CTL_CLRCLE);
-
-       if (column != -1 || page_addr != -1) {
-               this->hwcontrol(mtd, NAND_CTL_SETALE);
-
-               /* Serially input address */
-               if (column != -1) {
-                       /* Adjust columns for 16 bit buswidth */
-                       if (this->options & NAND_BUSWIDTH_16)
-                               column >>= 1;
-                       this->write_byte(mtd, column);
-               }
-               if (page_addr != -1) {
-                       this->write_byte(mtd, (unsigned char) (page_addr & 0xff));
-                       this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff));
-                       /* One more address cycle for higher density devices */
-                       if (this->chipsize & 0x0c000000) 
-                               this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0x0f));
-               }
-               /* Latch in address */
-               this->hwcontrol(mtd, NAND_CTL_CLRALE);
-       }
-       
-       /* 
-        * program and erase have their own busy handlers 
-        * status and sequential in needs no delay
-       */
-       switch (command) {
-                       
-       case NAND_CMD_PAGEPROG:
-       case NAND_CMD_ERASE1:
-       case NAND_CMD_ERASE2:
-       case NAND_CMD_SEQIN:
-       case NAND_CMD_STATUS:
-               return;
-
-       case NAND_CMD_RESET:
-               if (this->dev_ready)    
-                       break;
-               udelay(this->chip_delay);
-               this->hwcontrol(mtd, NAND_CTL_SETCLE);
-               this->write_byte(mtd, NAND_CMD_STATUS);
-               this->hwcontrol(mtd, NAND_CTL_CLRCLE);
-               while ( !(this->read_byte(mtd) & 0x40));
-               return;
-
-       /* This applies to read commands */     
-       default:
-               /* 
-                * If we don't have access to the busy pin, we apply the given
-                * command delay
-               */
-               if (!this->dev_ready) {
-                       udelay (this->chip_delay);
-                       return;
-               }       
-       }
-       
-       /* Apply this short delay always to ensure that we do wait tWB in
-        * any case on any machine. */
-       ndelay (100);
-       /* wait until command is processed */
-       while (!this->dev_ready(mtd));
-}
-
-/**
- * nand_command_lp - [DEFAULT] Send command to NAND large page device
- * @mtd:       MTD device structure
- * @command:   the command to be sent
- * @column:    the column address for this command, -1 if none
- * @page_addr: the page address for this command, -1 if none
- *
- * Send command to NAND device. This is the version for the new large page devices
- * We dont have the seperate regions as we have in the small page devices.
- * We must emulate NAND_CMD_READOOB to keep the code compatible.
- *
- */
-static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, int page_addr)
-{
-       register struct nand_chip *this = mtd->priv;
-
-       /* Emulate NAND_CMD_READOOB */
-       if (command == NAND_CMD_READOOB) {
-               column += mtd->oobblock;
-               command = NAND_CMD_READ0;
-       }
-       
-               
-       /* Begin command latch cycle */
-       this->hwcontrol(mtd, NAND_CTL_SETCLE);
-       /* Write out the command to the device. */
-       this->write_byte(mtd, command);
-       /* End command latch cycle */
-       this->hwcontrol(mtd, NAND_CTL_CLRCLE);
-
-       if (column != -1 || page_addr != -1) {
-               this->hwcontrol(mtd, NAND_CTL_SETALE);
-
-               /* Serially input address */
-               if (column != -1) {
-                       /* Adjust columns for 16 bit buswidth */
-                       if (this->options & NAND_BUSWIDTH_16)
-                               column >>= 1;
-                       this->write_byte(mtd, column & 0xff);
-                       this->write_byte(mtd, column >> 8);
-               }       
-               if (page_addr != -1) {
-                       this->write_byte(mtd, (unsigned char) (page_addr & 0xff));
-                       this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff));
-                       /* One more address cycle for devices > 128MiB */
-                       if (this->chipsize > (128 << 20))
-                               this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0xff));
-               }
-               /* Latch in address */
-               this->hwcontrol(mtd, NAND_CTL_CLRALE);
-       }
-       
-       /* 
-        * program and erase have their own busy handlers 
-        * status and sequential in needs no delay
-       */
-       switch (command) {
-                       
-       case NAND_CMD_CACHEDPROG:
-       case NAND_CMD_PAGEPROG:
-       case NAND_CMD_ERASE1:
-       case NAND_CMD_ERASE2:
-       case NAND_CMD_SEQIN:
-       case NAND_CMD_STATUS:
-               return;
-
-
-       case NAND_CMD_RESET:
-               if (this->dev_ready)    
-                       break;
-               udelay(this->chip_delay);
-               this->hwcontrol(mtd, NAND_CTL_SETCLE);
-               this->write_byte(mtd, NAND_CMD_STATUS);
-               this->hwcontrol(mtd, NAND_CTL_CLRCLE);
-               while ( !(this->read_byte(mtd) & 0x40));
-               return;
-
-       case NAND_CMD_READ0:
-               /* Begin command latch cycle */
-               this->hwcontrol(mtd, NAND_CTL_SETCLE);
-               /* Write out the start read command */
-               this->write_byte(mtd, NAND_CMD_READSTART);
-               /* End command latch cycle */
-               this->hwcontrol(mtd, NAND_CTL_CLRCLE);
-               /* Fall through into ready check */
-               
-       /* This applies to read commands */     
-       default:
-               /* 
-                * If we don't have access to the busy pin, we apply the given
-                * command delay
-               */
-               if (!this->dev_ready) {
-                       udelay (this->chip_delay);
-                       return;
-               }       
-       }
-       
-       /* Apply this short delay always to ensure that we do wait tWB in
-        * any case on any machine. */
-       ndelay (100);
-       /* wait until command is processed */
-       while (!this->dev_ready(mtd));
-}
-
-/**
- * nand_get_chip - [GENERIC] Get chip for selected access
- * @this:      the nand chip descriptor
- * @mtd:       MTD device structure
- * @new_state: the state which is requested 
- *
- * Get the device and lock it for exclusive access
- */
-static void nand_get_chip (struct nand_chip *this, struct mtd_info *mtd, int new_state)
-{
-
-       DECLARE_WAITQUEUE (wait, current);
-
-       /* 
-        * Grab the lock and see if the device is available 
-       */
-retry:
-       spin_lock_bh (&this->chip_lock);
-
-       if (this->state == FL_READY) {
-               this->state = new_state;
-               spin_unlock_bh (&this->chip_lock);
-               return;
-       }
-
-       set_current_state (TASK_UNINTERRUPTIBLE);
-       add_wait_queue (&this->wq, &wait);
-       spin_unlock_bh (&this->chip_lock);
-       schedule ();
-       remove_wait_queue (&this->wq, &wait);
-       goto retry;
-}
-
-/**
- * nand_wait - [DEFAULT]  wait until the command is done
- * @mtd:       MTD device structure
- * @this:      NAND chip structure
- * @state:     state to select the max. timeout value
- *
- * Wait for command done. This applies to erase and program only
- * Erase can take up to 400ms and program up to 20ms according to 
- * general NAND and SmartMedia specs
- *
-*/
-static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
-{
-
-       unsigned long   timeo = jiffies;
-       int     status;
-       
-       if (state == FL_ERASING)
-                timeo += (HZ * 400) / 1000;
-       else
-                timeo += (HZ * 20) / 1000;
-
-       /* Apply this short delay always to ensure that we do wait tWB in
-        * any case on any machine. */
-       ndelay (100);
-
-       spin_lock_bh (&this->chip_lock);
-       if ((state == FL_ERASING) && (this->options & NAND_IS_AND))
-               this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1);
-       else    
-               this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-
-       while (time_before(jiffies, timeo)) {           
-               /* Check, if we were interrupted */
-               if (this->state != state) {
-                       spin_unlock_bh (&this->chip_lock);
-                       return 0;
-               }
-               if (this->dev_ready) {
-                       if (this->dev_ready(mtd))
-                               break;
-               }
-               if (this->read_byte(mtd) & NAND_STATUS_READY)
-                       break;
-                                               
-               spin_unlock_bh (&this->chip_lock);
-               yield ();
-               spin_lock_bh (&this->chip_lock);
-       }
-       status = (int) this->read_byte(mtd);
-       spin_unlock_bh (&this->chip_lock);
-
-       return status;
-}
-
-/**
- * nand_write_page - [GENERIC] write one page
- * @mtd:       MTD device structure
- * @this:      NAND chip structure
- * @page:      startpage inside the chip, must be called with (page & this->pagemask)
- * @oob_buf:   out of band data buffer
- * @oobsel:    out of band selecttion structre
- * @cached:    1 = enable cached programming if supported by chip
- *
- * Nand_page_program function is used for write and writev !
- * This function will always program a full page of data
- * If you call it with a non page aligned buffer, you're lost :)
- *
- * Cached programming is not supported yet.
- */
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, 
-       u_char *oob_buf,  struct nand_oobinfo *oobsel, int cached)
-{
-       int     i, status;
-       u_char  ecc_code[8];
-       int     eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
-       int     *oob_config = oobsel->eccpos;
-       int     datidx = 0, eccidx = 0, eccsteps = this->eccsteps;
-       int     eccbytes = 0;
-       
-       /* FIXME: Enable cached programming */
-       cached = 0;
-       
-       /* Send command to begin auto page programming */
-       this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page);
-
-       /* Write out complete page of data, take care of eccmode */
-       switch (eccmode) {
-       /* No ecc, write all */
-       case NAND_ECC_NONE:
-               printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");
-               this->write_buf(mtd, this->data_poi, mtd->oobblock);
-               break;
-               
-       /* Software ecc 3/256, write all */
-       case NAND_ECC_SOFT:
-               for (; eccsteps; eccsteps--) {
-                       this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code);
-                       for (i = 0; i < 3; i++, eccidx++)
-                               oob_buf[oob_config[eccidx]] = ecc_code[i];
-                       datidx += this->eccsize;
-               }
-               this->write_buf(mtd, this->data_poi, mtd->oobblock);
-               break;
-               
-       /* Hardware ecc 8 byte / 512 byte data */       
-       case NAND_ECC_HW8_512:  
-               eccbytes += 2;
-       /* Hardware ecc 6 byte / 512 byte data */       
-       case NAND_ECC_HW6_512:  
-               eccbytes += 3;
-       /* Hardware ecc 3 byte / 256 data */    
-       /* Hardware ecc 3 byte / 512 byte data */       
-       case NAND_ECC_HW3_256:          
-       case NAND_ECC_HW3_512:
-               eccbytes += 3;
-               for (; eccsteps; eccsteps--) {
-                       /* enable hardware ecc logic for write */
-                       this->enable_hwecc(mtd, NAND_ECC_WRITE);
-                       this->write_buf(mtd, &this->data_poi[datidx], this->eccsize);
-                       this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code);
-                       for (i = 0; i < eccbytes; i++, eccidx++)
-                               oob_buf[oob_config[eccidx]] = ecc_code[i];
-                       /* If the hardware ecc provides syndromes then
-                        * the ecc code must be written immidiately after
-                        * the data bytes (words) */
-                       if (this->options & NAND_HWECC_SYNDROME)
-                               this->write_buf(mtd, ecc_code, eccbytes);
-
-                       datidx += this->eccsize;
-               }
-               break;
-
-       default:
-               printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
-               BUG();  
-       }
-                                                                               
-       /* Write out OOB data */
-       if (this->options & NAND_HWECC_SYNDROME)
-               this->write_buf(mtd, &oob_buf[oobsel->eccbytes], mtd->oobsize - oobsel->eccbytes);
-       else 
-               this->write_buf(mtd, oob_buf, mtd->oobsize);
-
-       /* Send command to actually program the data */
-       this->cmdfunc (mtd, cached ? NAND_CMD_CACHEDPROG : NAND_CMD_PAGEPROG, -1, -1);
-
-       if (!cached) {
-               /* call wait ready function */
-               status = this->waitfunc (mtd, this, FL_WRITING);
-               /* See if device thinks it succeeded */
-               if (status & 0x01) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page);
-                       return -EIO;
-               }
-       } else {
-               /* FIXME: Implement cached programming ! */
-               /* wait until cache is ready*/
-               // status = this->waitfunc (mtd, this, FL_CACHEDRPG);
-       }
-       return 0;       
-}
-
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
-/**
- * nand_verify_pages - [GENERIC] verify the chip contents after a write
- * @mtd:       MTD device structure
- * @this:      NAND chip structure
- * @page:      startpage inside the chip, must be called with (page & this->pagemask)
- * @numpages:  number of pages to verify
- * @oob_buf:   out of band data buffer
- * @oobsel:    out of band selecttion structre
- * @chipnr:    number of the current chip
- * @oobmode:   1 = full buffer verify, 0 = ecc only
- *
- * The NAND device assumes that it is always writing to a cleanly erased page.
- * Hence, it performs its internal write verification only on bits that 
- * transitioned from 1 to 0. The device does NOT verify the whole page on a
- * byte by byte basis. It is possible that the page was not completely erased 
- * or the page is becoming unusable due to wear. The read with ECC would catch 
- * the error later when the ECC page check fails, but we would rather catch 
- * it early in the page write stage. Better to write no data than invalid data.
- */
-static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, 
-       u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode)
-{
-       int     i, j, datidx = 0, oobofs = 0, res = -EIO;
-       int     eccsteps = this->eccsteps;
-       int     hweccbytes; 
-       u_char  oobdata[64];
-
-       hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0;
-
-       /* Send command to read back the first page */
-       this->cmdfunc (mtd, NAND_CMD_READ0, 0, page);
-
-       for(;;) {
-               for (j = 0; j < eccsteps; j++) {
-                       /* Loop through and verify the data */
-                       if (this->verify_buf(mtd, &this->data_poi[datidx], mtd->eccsize)) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
-                               goto out;
-                       }
-                       datidx += mtd->eccsize;
-                       /* Have we a hw generator layout ? */
-                       if (!hweccbytes)
-                               continue;
-                       if (this->verify_buf(mtd, &this->oob_buf[oobofs], hweccbytes)) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
-                               goto out;
-                       }
-                       oobofs += hweccbytes;
-               }
-
-               /* check, if we must compare all data or if we just have to
-                * compare the ecc bytes
-                */
-               if (oobmode) {
-                       if (this->verify_buf(mtd, &oob_buf[oobofs], mtd->oobsize - hweccbytes * eccsteps)) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
-                               goto out;
-                       }
-               } else {
-                       /* Read always, else autoincrement fails */
-                       this->read_buf(mtd, oobdata, mtd->oobsize - hweccbytes * eccsteps);
-
-                       if (oobsel->useecc != MTD_NANDECC_OFF && !hweccbytes) {
-                               int ecccnt = oobsel->eccbytes;
-               
-                               for (i = 0; i < ecccnt; i++) {
-                                       int idx = oobsel->eccpos[i];
-                                       if (oobdata[idx] != oob_buf[oobofs + idx] ) {
-                                               DEBUG (MTD_DEBUG_LEVEL0,
-                                               "%s: Failed ECC write "
-                                               "verify, page 0x%08x, " "%6i bytes were succesful\n", __FUNCTION__, page, i);
-                                               goto out;
-                                       }
-                               }
-                       }       
-               }
-               oobofs += mtd->oobsize - hweccbytes * eccsteps;
-               page++;
-               numpages--;
-
-               /* Apply delay or wait for ready/busy pin 
-                * Do this before the AUTOINCR check, so no problems
-                * arise if a chip which does auto increment
-                * is marked as NOAUTOINCR by the board driver.
-                * Do this also before returning, so the chip is
-                * ready for the next command.
-               */
-               if (!this->dev_ready) 
-                       udelay (this->chip_delay);
-               else
-                       while (!this->dev_ready(mtd));  
-
-               /* All done, return happy */
-               if (!numpages)
-                       return 0;
-               
-                       
-               /* Check, if the chip supports auto page increment */ 
-               if (!NAND_CANAUTOINCR(this))
-                       this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page);
-       }
-       /* 
-        * Terminate the read command. We come here in case of an error
-        * So we must issue a reset command.
-        */
-out:    
-       this->cmdfunc (mtd, NAND_CMD_RESET, -1, -1);
-       return res;
-}
-#endif
-
-/**
- * nand_read - [MTD Interface] MTD compability function for nand_read_ecc
- * @mtd:       MTD device structure
- * @from:      offset to read from
- * @len:       number of bytes to read
- * @retlen:    pointer to variable to store the number of read bytes
- * @buf:       the databuffer to put data
- *
- * This function simply calls nand_read_ecc with oob buffer and oobsel = NULL
-*/
-static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
-{
-       return nand_read_ecc (mtd, from, len, retlen, buf, NULL, NULL);
-}                         
-
-
-/**
- * nand_read_ecc - [MTD Interface] Read data with ECC
- * @mtd:       MTD device structure
- * @from:      offset to read from
- * @len:       number of bytes to read
- * @retlen:    pointer to variable to store the number of read bytes
- * @buf:       the databuffer to put data
- * @oob_buf:   filesystem supplied oob data buffer
- * @oobsel:    oob selection structure
- *
- * NAND read with ECC
- */
-static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-                         size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel)
-{
-       int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1;
-       int read = 0, oob = 0, ecc_status = 0, ecc_failed = 0;
-       struct nand_chip *this = mtd->priv;
-       u_char *data_poi, *oob_data = oob_buf;
-       u_char ecc_calc[32];
-       u_char ecc_code[32];
-        int eccmode, eccsteps;
-       int     *oob_config, datidx;
-       int     blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
-       int     eccbytes = 3;
-       int     compareecc = 1;
-       int     oobreadlen;
-
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
-
-       /* Do not allow reads past end of device */
-       if ((from + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: Attempt read beyond end of device\n");
-               *retlen = 0;
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd ,FL_READING);
-
-       /* use userspace supplied oobinfo, if zero */
-       if (oobsel == NULL)
-               oobsel = &mtd->oobinfo;
-       
-       /* Autoplace of oob data ? Use the default placement scheme */
-       if (oobsel->useecc == MTD_NANDECC_AUTOPLACE)
-               oobsel = this->autooob;
-               
-       eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
-       oob_config = oobsel->eccpos;
-
-       /* Select the NAND device */
-       chipnr = (int)(from >> this->chip_shift);
-       this->select_chip(mtd, chipnr);
-
-       /* First we calculate the starting page */
-       realpage = (int) (from >> this->page_shift);
-       page = realpage & this->pagemask;
-
-       /* Get raw starting column */
-       col = from & (mtd->oobblock - 1);
-
-       end = mtd->oobblock;
-       ecc = this->eccsize;
-       switch (eccmode) {
-       case NAND_ECC_HW6_512: /* Hardware ECC 6 byte / 512 byte data  */
-               eccbytes = 6;
-               break;                                          
-       case NAND_ECC_HW8_512: /* Hardware ECC 8 byte / 512 byte data  */
-               eccbytes = 8;
-               break;
-       case NAND_ECC_NONE:
-               compareecc = 0;
-               break;                                          
-       }        
-
-       if (this->options & NAND_HWECC_SYNDROME)
-               compareecc = 0;
-
-       oobreadlen = mtd->oobsize;
-       if (this->options & NAND_HWECC_SYNDROME) 
-               oobreadlen -= oobsel->eccbytes;
-
-       /* Loop until all data read */
-       while (read < len) {
-               
-               int aligned = (!col && (len - read) >= end);
-               /* 
-                * If the read is not page aligned, we have to read into data buffer
-                * due to ecc, else we read into return buffer direct
-                */
-               if (aligned)
-                       data_poi = &buf[read];
-               else 
-                       data_poi = this->data_buf;
-               
-               /* Check, if we have this page in the buffer 
-                *
-                * FIXME: Make it work when we must provide oob data too,
-                * check the usage of data_buf oob field
-                */
-               if (realpage == this->pagebuf && !oob_buf) {
-                       /* aligned read ? */
-                       if (aligned)
-                               memcpy (data_poi, this->data_buf, end);
-                       goto readdata;
-               }
-
-               /* Check, if we must send the read command */
-               if (sndcmd) {
-                       this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page);
-                       sndcmd = 0;
-               }       
-
-               /* get oob area, if we have no oob buffer from fs-driver */
-               if (!oob_buf || oobsel->useecc == MTD_NANDECC_AUTOPLACE)
-                       oob_data = &this->data_buf[end];
-
-               eccsteps = this->eccsteps;
-               
-               switch (eccmode) {
-               case NAND_ECC_NONE: {   /* No ECC, Read in a page */
-                       static unsigned long lastwhinge = 0;
-                       if ((lastwhinge / HZ) != (jiffies / HZ)) {
-                               printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n");
-                               lastwhinge = jiffies;
-                       }
-                       this->read_buf(mtd, data_poi, end);
-                       break;
-               }
-                       
-               case NAND_ECC_SOFT:     /* Software ECC 3/256: Read in a page + oob data */
-                       this->read_buf(mtd, data_poi, end);
-                       for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc) 
-                               this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]);
-                       break;  
-                       
-               case NAND_ECC_HW3_256: /* Hardware ECC 3 byte /256 byte data */
-               case NAND_ECC_HW3_512: /* Hardware ECC 3 byte /512 byte data */ 
-               case NAND_ECC_HW6_512: /* Hardware ECC 6 byte / 512 byte data  */
-               case NAND_ECC_HW8_512: /* Hardware ECC 8 byte / 512 byte data  */
-                       for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) {
-                               this->enable_hwecc(mtd, NAND_ECC_READ); 
-                               this->read_buf(mtd, &data_poi[datidx], ecc);
-
-                               /* HW ecc with syndrome calculation must read the
-                                * syndrome from flash immidiately after the data */
-                               if (!compareecc) {
-                                       /* Some hw ecc generators need to know when the
-                                        * syndrome is read from flash */
-                                       this->enable_hwecc(mtd, NAND_ECC_READSYN);
-                                       this->read_buf(mtd, &oob_data[i], eccbytes);
-                                       /* We calc error correction directly, it checks the hw
-                                        * generator for an error, reads back the syndrome and
-                                        * does the error correction on the fly */
-                                       if (this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]) == -1) {
-                                               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " 
-                                                       "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr);
-                                               ecc_failed++;
-                                       }
-                               } else {
-                                       this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]);
-                               }       
-                       }
-                       break;                                          
-
-               default:
-                       printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
-                       BUG();  
-               }
-
-               /* read oobdata */
-               this->read_buf(mtd, &oob_data[mtd->oobsize - oobreadlen], oobreadlen);
-
-               /* Skip ECC check, if not requested (ECC_NONE or HW_ECC with syndromes) */
-               if (!compareecc)
-                       goto readoob;   
-               
-               /* Pick the ECC bytes out of the oob data */
-               for (j = 0; j < oobsel->eccbytes; j++)
-                       ecc_code[j] = oob_data[oob_config[j]];
-
-               /* correct data, if neccecary */
-               for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) {
-                       ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]);
-                       
-                       /* Get next chunk of ecc bytes */
-                       j += eccbytes;
-                       
-                       /* Check, if we have a fs supplied oob-buffer, 
-                        * This is the legacy mode. Used by YAFFS1
-                        * Should go away some day
-                        */
-                       if (oob_buf && oobsel->useecc == MTD_NANDECC_PLACE) { 
-                               int *p = (int *)(&oob_data[mtd->oobsize]);
-                               p[i] = ecc_status;
-                       }
-                       
-                       if (ecc_status == -1) { 
-                               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
-                               ecc_failed++;
-                       }
-               }               
-
-       readoob:
-               /* check, if we have a fs supplied oob-buffer */
-               if (oob_buf) {
-                       /* without autoplace. Legacy mode used by YAFFS1 */
-                       switch(oobsel->useecc) {
-                       case MTD_NANDECC_AUTOPLACE:
-                               /* Walk through the autoplace chunks */
-                               for (i = 0, j = 0; j < mtd->oobavail; i++) {
-                                       int from = oobsel->oobfree[i][0];
-                                       int num = oobsel->oobfree[i][1];
-                                       memcpy(&oob_buf[oob], &oob_data[from], num);
-                                       j+= num;
-                               }
-                               oob += mtd->oobavail;
-                               break;
-                       case MTD_NANDECC_PLACE:
-                               /* YAFFS1 legacy mode */
-                               oob_data += this->eccsteps * sizeof (int);
-                       default:
-                               oob_data += mtd->oobsize;
-                       }
-               }
-       readdata:
-               /* Partial page read, transfer data into fs buffer */
-               if (!aligned) { 
-                       for (j = col; j < end && read < len; j++)
-                               buf[read++] = data_poi[j];
-                       this->pagebuf = realpage;       
-               } else          
-                       read += mtd->oobblock;
-
-               /* Apply delay or wait for ready/busy pin 
-                * Do this before the AUTOINCR check, so no problems
-                * arise if a chip which does auto increment
-                * is marked as NOAUTOINCR by the board driver.
-               */
-               if (!this->dev_ready) 
-                       udelay (this->chip_delay);
-               else
-                       while (!this->dev_ready(mtd));  
-                       
-               if (read == len)
-                       break;  
-
-               /* For subsequent reads align to page boundary. */
-               col = 0;
-               /* Increment page address */
-               realpage++;
-
-               page = realpage & this->pagemask;
-               /* Check, if we cross a chip boundary */
-               if (!page) {
-                       chipnr++;
-                       this->select_chip(mtd, -1);
-                       this->select_chip(mtd, chipnr);
-               }
-               /* Check, if the chip supports auto page increment 
-                * or if we have hit a block boundary. 
-               */ 
-               if (!NAND_CANAUTOINCR(this) || !(page & blockcheck))
-                       sndcmd = 1;                             
-       }
-
-       /* Deselect and wake up anyone waiting on the device */
-       nand_release_chip(mtd);
-
-       /*
-        * Return success, if no ECC failures, else -EBADMSG
-        * fs driver will take care of that, because
-        * retlen == desired len and result == -EBADMSG
-        */
-       *retlen = read;
-       return ecc_failed ? -EBADMSG : 0;
-}
-
-/**
- * nand_read_oob - [MTD Interface] NAND read out-of-band
- * @mtd:       MTD device structure
- * @from:      offset to read from
- * @len:       number of bytes to read
- * @retlen:    pointer to variable to store the number of read bytes
- * @buf:       the databuffer to put data
- *
- * NAND read out-of-band data from the spare area
- */
-static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
-{
-       int i, col, page, chipnr;
-       struct nand_chip *this = mtd->priv;
-       int     blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
-
-       /* Shift to get page */
-       page = (int)(from >> this->page_shift);
-       chipnr = (int)(from >> this->chip_shift);
-       
-       /* Mask to get column */
-       col = from & (mtd->oobsize - 1);
-
-       /* Initialize return length value */
-       *retlen = 0;
-
-       /* Do not allow reads past end of device */
-       if ((from + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n");
-               *retlen = 0;
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd , FL_READING);
-
-       /* Select the NAND device */
-       this->select_chip(mtd, chipnr);
-
-       /* Send the read command */
-       this->cmdfunc (mtd, NAND_CMD_READOOB, col, page & this->pagemask);
-       /* 
-        * Read the data, if we read more than one page
-        * oob data, let the device transfer the data !
-        */
-       i = 0;
-       while (i < len) {
-               int thislen = mtd->oobsize - col;
-               thislen = min_t(int, thislen, len);
-               this->read_buf(mtd, &buf[i], thislen);
-               i += thislen;
-               
-               /* Apply delay or wait for ready/busy pin 
-                * Do this before the AUTOINCR check, so no problems
-                * arise if a chip which does auto increment
-                * is marked as NOAUTOINCR by the board driver.
-               */
-               if (!this->dev_ready) 
-                       udelay (this->chip_delay);
-               else
-                       while (!this->dev_ready(mtd));  
-
-               /* Read more ? */
-               if (i < len) {
-                       page++;
-                       col = 0;
-
-                       /* Check, if we cross a chip boundary */
-                       if (!(page & this->pagemask)) {
-                               chipnr++;
-                               this->select_chip(mtd, -1);
-                               this->select_chip(mtd, chipnr);
-                       }
-                               
-                       /* Check, if the chip supports auto page increment 
-                        * or if we have hit a block boundary. 
-                       */ 
-                       if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) {
-                               /* For subsequent page reads set offset to 0 */
-                               this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask);
-                       }
-               }
-       }
-
-       /* Deselect and wake up anyone waiting on the device */
-       nand_release_chip(mtd);
-
-       /* Return happy */
-       *retlen = len;
-       return 0;
-}
-
-/**
- * nand_read_raw - [GENERIC] Read raw data including oob into buffer
- * @mtd:       MTD device structure
- * @buf:       temporary buffer
- * @from:      offset to read from
- * @len:       number of bytes to read
- * @ooblen:    number of oob data bytes to read
- *
- * Read raw data including oob into buffer
- */
-int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen)
-{
-       struct nand_chip *this = mtd->priv;
-       int page = (int) (from >> this->page_shift);
-       int chip = (int) (from >> this->chip_shift);
-       int sndcmd = 1;
-       int cnt = 0;
-       int pagesize = mtd->oobblock + mtd->oobsize;
-       int     blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
-
-       /* Do not allow reads past end of device */
-       if ((from + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt read beyond end of device\n");
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd , FL_READING);
-
-       this->select_chip (mtd, chip);
-       
-       /* Add requested oob length */
-       len += ooblen;
-       
-       while (len) {
-               if (sndcmd)
-                       this->cmdfunc (mtd, NAND_CMD_READ0, 0, page & this->pagemask);
-               sndcmd = 0;     
-
-               this->read_buf (mtd, &buf[cnt], pagesize);
-
-               len -= pagesize;
-               cnt += pagesize;
-               page++;
-               
-               if (!this->dev_ready) 
-                       udelay (this->chip_delay);
-               else
-                       while (!this->dev_ready(mtd));  
-                       
-               /* Check, if the chip supports auto page increment */ 
-               if (!NAND_CANAUTOINCR(this) || !(page & blockcheck))
-                       sndcmd = 1;
-       }
-
-       /* Deselect and wake up anyone waiting on the device */
-       nand_release_chip(mtd);
-       return 0;
-}
-
-
-/** 
- * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer 
- * @mtd:       MTD device structure
- * @fsbuf:     buffer given by fs driver
- * @oobsel:    out of band selection structre
- * @autoplace: 1 = place given buffer into the oob bytes
- * @numpages:  number of pages to prepare
- *
- * Return:
- * 1. Filesystem buffer available and autoplacement is off,
- *    return filesystem buffer
- * 2. No filesystem buffer or autoplace is off, return internal
- *    buffer
- * 3. Filesystem buffer is given and autoplace selected
- *    put data from fs buffer into internal buffer and
- *    retrun internal buffer
- *
- * Note: The internal buffer is filled with 0xff. This must
- * be done only once, when no autoplacement happens
- * Autoplacement sets the buffer dirty flag, which
- * forces the 0xff fill before using the buffer again.
- *
-*/
-static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct nand_oobinfo *oobsel,
-               int autoplace, int numpages)
-{
-       struct nand_chip *this = mtd->priv;
-       int i, len, ofs;
-
-       /* Zero copy fs supplied buffer */
-       if (fsbuf && !autoplace) 
-               return fsbuf;
-
-       /* Check, if the buffer must be filled with ff again */
-       if (this->oobdirty) {   
-               memset (this->oob_buf, 0xff, 
-                       mtd->oobsize << (this->phys_erase_shift - this->page_shift));
-               this->oobdirty = 0;
-       }       
-       
-       /* If we have no autoplacement or no fs buffer use the internal one */
-       if (!autoplace || !fsbuf)
-               return this->oob_buf;
-       
-       /* Walk through the pages and place the data */
-       this->oobdirty = 1;
-       ofs = 0;
-       while (numpages--) {
-               for (i = 0, len = 0; len < mtd->oobavail; i++) {
-                       int to = ofs + oobsel->oobfree[i][0];
-                       int num = oobsel->oobfree[i][1];
-                       memcpy (&this->oob_buf[to], fsbuf, num);
-                       len += num;
-                       fsbuf += num;
-               }
-               ofs += mtd->oobavail;
-       }
-       return this->oob_buf;
-}
-
-#define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0
-
-/**
- * nand_write - [MTD Interface] compability function for nand_write_ecc
- * @mtd:       MTD device structure
- * @to:                offset to write to
- * @len:       number of bytes to write
- * @retlen:    pointer to variable to store the number of written bytes
- * @buf:       the data to write
- *
- * This function simply calls nand_write_ecc with oob buffer and oobsel = NULL
- *
-*/
-static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf)
-{
-       return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL));
-}
-                          
-/**
- * nand_write_ecc - [MTD Interface] NAND write with ECC
- * @mtd:       MTD device structure
- * @to:                offset to write to
- * @len:       number of bytes to write
- * @retlen:    pointer to variable to store the number of written bytes
- * @buf:       the data to write
- * @eccbuf:    filesystem supplied oob data buffer
- * @oobsel:    oob selection structure
- *
- * NAND write with ECC
- */
-static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
-                          size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel)
-{
-       int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr;
-       int autoplace = 0, numpages, totalpages;
-       struct nand_chip *this = mtd->priv;
-       u_char *oobbuf, *bufstart;
-       int     ppblock = (1 << (this->phys_erase_shift - this->page_shift));
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
-
-       /* Initialize retlen, in case of early exit */
-       *retlen = 0;
-
-       /* Do not allow write past end of device */
-       if ((to + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n");
-               return -EINVAL;
-       }
-
-       /* reject writes, which are not page aligned */ 
-       if (NOTALIGNED (to) || NOTALIGNED(len)) {
-               printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_WRITING);
-
-       /* Calculate chipnr */
-       chipnr = (int)(to >> this->chip_shift);
-       /* Select the NAND device */
-       this->select_chip(mtd, chipnr);
-
-       /* Check, if it is write protected */
-       if (nand_check_wp(mtd))
-               goto out;
-
-       /* if oobsel is NULL, use chip defaults */
-       if (oobsel == NULL) 
-               oobsel = &mtd->oobinfo;         
-               
-       /* Autoplace of oob data ? Use the default placement scheme */
-       if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) {
-               oobsel = this->autooob;
-               autoplace = 1;
-       }       
-
-       /* Setup variables and oob buffer */
-       totalpages = len >> this->page_shift;
-       page = (int) (to >> this->page_shift);
-       /* Invalidate the page cache, if we write to the cached page */
-       if (page <= this->pagebuf && this->pagebuf < (page + totalpages))  
-               this->pagebuf = -1;
-       
-       /* Set it relative to chip */
-       page &= this->pagemask;
-       startpage = page;
-       /* Calc number of pages we can write in one go */
-       numpages = min (ppblock - (startpage  & (ppblock - 1)), totalpages);
-       oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, autoplace, numpages);
-       bufstart = (u_char *)buf;
-
-       /* Loop until all data is written */
-       while (written < len) {
-
-               this->data_poi = (u_char*) &buf[written];
-               /* Write one page. If this is the last page to write
-                * or the last page in this block, then use the
-                * real pageprogram command, else select cached programming
-                * if supported by the chip.
-                */
-               ret = nand_write_page (mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0));
-               if (ret) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret);
-                       goto out;
-               }       
-               /* Next oob page */
-               oob += mtd->oobsize;
-               /* Update written bytes count */
-               written += mtd->oobblock;
-               if (written == len) 
-                       goto cmp;
-               
-               /* Increment page address */
-               page++;
-
-               /* Have we hit a block boundary ? Then we have to verify and
-                * if verify is ok, we have to setup the oob buffer for
-                * the next pages.
-               */
-               if (!(page & (ppblock - 1))){
-                       int ofs;
-                       this->data_poi = bufstart;
-                       ret = nand_verify_pages (mtd, this, startpage, 
-                               page - startpage,
-                               oobbuf, oobsel, chipnr, (eccbuf != NULL));
-                       if (ret) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret);
-                               goto out;
-                       }       
-                       *retlen = written;
-
-                       ofs = autoplace ? mtd->oobavail : mtd->oobsize;
-                       if (eccbuf)
-                               eccbuf += (page - startpage) * ofs;
-                       totalpages -= page - startpage;
-                       numpages = min (totalpages, ppblock);
-                       page &= this->pagemask;
-                       startpage = page;
-                       oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, 
-                                       autoplace, numpages);
-                       /* Check, if we cross a chip boundary */
-                       if (!page) {
-                               chipnr++;
-                               this->select_chip(mtd, -1);
-                               this->select_chip(mtd, chipnr);
-                       }
-               }
-       }
-       /* Verify the remaining pages */
-cmp:
-       this->data_poi = bufstart;
-       ret = nand_verify_pages (mtd, this, startpage, totalpages,
-               oobbuf, oobsel, chipnr, (eccbuf != NULL));
-       if (!ret)
-               *retlen = written;
-       else    
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret);
-
-out:
-       /* Deselect and wake up anyone waiting on the device */
-       nand_release_chip(mtd);
-
-       return ret;
-}
-
-
-/**
- * nand_write_oob - [MTD Interface] NAND write out-of-band
- * @mtd:       MTD device structure
- * @to:                offset to write to
- * @len:       number of bytes to write
- * @retlen:    pointer to variable to store the number of written bytes
- * @buf:       the data to write
- *
- * NAND write out-of-band
- */
-static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf)
-{
-       int column, page, status, ret = -EIO, chipnr;
-       struct nand_chip *this = mtd->priv;
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
-
-       /* Shift to get page */
-       page = (int) (to >> this->page_shift);
-       chipnr = (int) (to >> this->chip_shift);
-
-       /* Mask to get column */
-       column = to & (mtd->oobsize - 1);
-
-       /* Initialize return length value */
-       *retlen = 0;
-
-       /* Do not allow write past end of page */
-       if ((column + len) > mtd->oobsize) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n");
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_WRITING);
-
-       /* Select the NAND device */
-       this->select_chip(mtd, chipnr);
-
-       /* Reset the chip. Some chips (like the Toshiba TC5832DC found
-          in one of my DiskOnChip 2000 test units) will clear the whole
-          data page too if we don't do this. I have no clue why, but
-          I seem to have 'fixed' it in the doc2000 driver in
-          August 1999.  dwmw2. */
-       this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
-
-       /* Check, if it is write protected */
-       if (nand_check_wp(mtd))
-               goto out;
-       
-       /* Invalidate the page cache, if we write to the cached page */
-       if (page == this->pagebuf)
-               this->pagebuf = -1;
-
-       if (NAND_MUST_PAD(this)) {
-               /* Write out desired data */
-               this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask);
-               /* prepad 0xff for partial programming */
-               this->write_buf(mtd, ffchars, column);
-               /* write data */
-               this->write_buf(mtd, buf, len);
-               /* postpad 0xff for partial programming */
-               this->write_buf(mtd, ffchars, mtd->oobsize - (len+column));
-       } else {
-               /* Write out desired data */
-               this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask);
-               /* write data */
-               this->write_buf(mtd, buf, len);
-       }
-       /* Send command to program the OOB data */
-       this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1);
-
-       status = this->waitfunc (mtd, this, FL_WRITING);
-
-       /* See if device thinks it succeeded */
-       if (status & 0x01) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page);
-               ret = -EIO;
-               goto out;
-       }
-       /* Return happy */
-       *retlen = len;
-
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
-       /* Send command to read back the data */
-       this->cmdfunc (mtd, NAND_CMD_READOOB, column, page & this->pagemask);
-
-       if (this->verify_buf(mtd, buf, len)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page);
-               ret = -EIO;
-               goto out;
-       }
-#endif
-       ret = 0;
-out:
-       /* Deselect and wake up anyone waiting on the device */
-       nand_release_chip(mtd);
-
-       return ret;
-}
-
-
-/**
- * nand_writev - [MTD Interface] compabilty function for nand_writev_ecc
- * @mtd:       MTD device structure
- * @vecs:      the iovectors to write
- * @count:     number of vectors
- * @to:                offset to write to
- * @retlen:    pointer to variable to store the number of written bytes
- *
- * NAND write with kvec. This just calls the ecc function
- */
-static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, 
-               loff_t to, size_t * retlen)
-{
-       return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, NULL));    
-}
-
-/**
- * nand_writev_ecc - [MTD Interface] write with iovec with ecc
- * @mtd:       MTD device structure
- * @vecs:      the iovectors to write
- * @count:     number of vectors
- * @to:                offset to write to
- * @retlen:    pointer to variable to store the number of written bytes
- * @eccbuf:    filesystem supplied oob data buffer
- * @oobsel:    oob selection structure
- *
- * NAND write with iovec with ecc
- */
-static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, 
-               loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel)
-{
-       int i, page, len, total_len, ret = -EIO, written = 0, chipnr;
-       int oob, numpages, autoplace = 0, startpage;
-       struct nand_chip *this = mtd->priv;
-       int     ppblock = (1 << (this->phys_erase_shift - this->page_shift));
-       u_char *oobbuf, *bufstart;
-
-       /* Preset written len for early exit */
-       *retlen = 0;
-
-       /* Calculate total length of data */
-       total_len = 0;
-       for (i = 0; i < count; i++)
-               total_len += (int) vecs[i].iov_len;
-
-       DEBUG (MTD_DEBUG_LEVEL3,
-              "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
-
-       /* Do not allow write past end of page */
-       if ((to + total_len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n");
-               return -EINVAL;
-       }
-
-       /* reject writes, which are not page aligned */ 
-       if (NOTALIGNED (to) || NOTALIGNED(total_len)) {
-               printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
-               return -EINVAL;
-       }
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_WRITING);
-
-       /* Get the current chip-nr */
-       chipnr = (int) (to >> this->chip_shift);
-       /* Select the NAND device */
-       this->select_chip(mtd, chipnr);
-
-       /* Check, if it is write protected */
-       if (nand_check_wp(mtd))
-               goto out;
-
-       /* if oobsel is NULL, use chip defaults */
-       if (oobsel == NULL) 
-               oobsel = &mtd->oobinfo;         
-
-       /* Autoplace of oob data ? Use the default placement scheme */
-       if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) {
-               oobsel = this->autooob;
-               autoplace = 1;
-       }       
-
-       /* Setup start page */
-       page = (int) (to >> this->page_shift);
-       /* Invalidate the page cache, if we write to the cached page */
-       if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift))  
-               this->pagebuf = -1;
-
-       startpage = page & this->pagemask;
-
-       /* Loop until all kvec' data has been written */
-       len = 0;
-       while (count) {
-               /* If the given tuple is >= pagesize then
-                * write it out from the iov
-                */
-               if ((vecs->iov_len - len) >= mtd->oobblock) {
-                       /* Calc number of pages we can write
-                        * out of this iov in one go */
-                       numpages = (vecs->iov_len - len) >> this->page_shift;
-                       /* Do not cross block boundaries */
-                       numpages = min (ppblock - (startpage & (ppblock - 1)), numpages);
-                       oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages);
-                       bufstart = (u_char *)vecs->iov_base;
-                       bufstart += len;
-                       this->data_poi = bufstart;
-                       oob = 0;
-                       for (i = 1; i <= numpages; i++) {
-                               /* Write one page. If this is the last page to write
-                                * then use the real pageprogram command, else select 
-                                * cached programming if supported by the chip.
-                                */
-                               ret = nand_write_page (mtd, this, page & this->pagemask, 
-                                       &oobbuf[oob], oobsel, i != numpages);
-                               if (ret)
-                                       goto out;
-                               this->data_poi += mtd->oobblock;
-                               len += mtd->oobblock;
-                               oob += mtd->oobsize;
-                               page++;
-                       }
-                       /* Check, if we have to switch to the next tuple */
-                       if (len >= (int) vecs->iov_len) {
-                               vecs++;
-                               len = 0;
-                               count--;
-                       }
-               } else {
-                       /* We must use the internal buffer, read data out of each 
-                        * tuple until we have a full page to write
-                        */
-                       int cnt = 0;
-                       while (cnt < mtd->oobblock) {
-                               if (vecs->iov_base != NULL && vecs->iov_len) 
-                                       this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++];
-                               /* Check, if we have to switch to the next tuple */
-                               if (len >= (int) vecs->iov_len) {
-                                       vecs++;
-                                       len = 0;
-                                       count--;
-                               }
-                       }
-                       this->pagebuf = page;   
-                       this->data_poi = this->data_buf;        
-                       bufstart = this->data_poi;
-                       numpages = 1;           
-                       oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages);
-                       ret = nand_write_page (mtd, this, page & this->pagemask,
-                               oobbuf, oobsel, 0);
-                       if (ret)
-                               goto out;
-                       page++;
-               }
-
-               this->data_poi = bufstart;
-               ret = nand_verify_pages (mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0);
-               if (ret)
-                       goto out;
-                       
-               written += mtd->oobblock * numpages;
-               /* All done ? */
-               if (!count)
-                       break;
-
-               startpage = page & this->pagemask;
-               /* Check, if we cross a chip boundary */
-               if (!startpage) {
-                       chipnr++;
-                       this->select_chip(mtd, -1);
-                       this->select_chip(mtd, chipnr);
-               }
-       }
-       ret = 0;
-out:
-       /* Deselect and wake up anyone waiting on the device */
-       nand_release_chip(mtd);
-
-       *retlen = written;
-       return ret;
-}
-
-/**
- * single_erease_cmd - [GENERIC] NAND standard block erase command function
- * @mtd:       MTD device structure
- * @page:      the page address of the block which will be erased
- *
- * Standard erase command for NAND chips
- */
-static void single_erase_cmd (struct mtd_info *mtd, int page)
-{
-       struct nand_chip *this = mtd->priv;
-       /* Send commands to erase a block */
-       this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page);
-       this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);
-}
-
-/**
- * multi_erease_cmd - [GENERIC] AND specific block erase command function
- * @mtd:       MTD device structure
- * @page:      the page address of the block which will be erased
- *
- * AND multi block erase command function
- * Erase 4 consecutive blocks
- */
-static void multi_erase_cmd (struct mtd_info *mtd, int page)
-{
-       struct nand_chip *this = mtd->priv;
-       /* Send commands to erase a block */
-       this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++);
-       this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++);
-       this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++);
-       this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page);
-       this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);
-}
-
-/**
- * nand_erase - [MTD Interface] erase block(s)
- * @mtd:       MTD device structure
- * @instr:     erase instruction
- *
- * Erase one ore more blocks
- */
-static int nand_erase (struct mtd_info *mtd, struct erase_info *instr)
-{
-       return nand_erase_nand (mtd, instr, 0);
-}
-/**
- * nand_erase_intern - [NAND Interface] erase block(s)
- * @mtd:       MTD device structure
- * @instr:     erase instruction
- * @allowbbt:  allow erasing the bbt area
- *
- * Erase one ore more blocks
- */
-int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt)
-{
-       int page, len, status, pages_per_block, ret, chipnr;
-       struct nand_chip *this = mtd->priv;
-
-       DEBUG (MTD_DEBUG_LEVEL3,
-              "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
-
-       /* Start address must align on block boundary */
-       if (instr->addr & ((1 << this->phys_erase_shift) - 1)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n");
-               return -EINVAL;
-       }
-
-       /* Length must align on block boundary */
-       if (instr->len & ((1 << this->phys_erase_shift) - 1)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n");
-               return -EINVAL;
-       }
-
-       /* Do not allow erase past end of device */
-       if ((instr->len + instr->addr) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n");
-               return -EINVAL;
-       }
-
-       instr->fail_addr = 0xffffffff;
-
-       /* Grab the lock and see if the device is available */
-       nand_get_chip (this, mtd, FL_ERASING);
-
-       /* Shift to get first page */
-       page = (int) (instr->addr >> this->page_shift);
-       chipnr = (int) (instr->addr >> this->chip_shift);
-
-       /* Calculate pages in each block */
-       pages_per_block = 1 << (this->phys_erase_shift - this->page_shift);
-
-       /* Select the NAND device */
-       this->select_chip(mtd, chipnr);
-
-       /* Check the WP bit */
-       /* Check, if it is write protected */
-       if (nand_check_wp(mtd)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n");
-               instr->state = MTD_ERASE_FAILED;
-               goto erase_exit;
-       }
-
-       /* Loop through the pages */
-       len = instr->len;
-
-       instr->state = MTD_ERASING;
-
-       while (len) {
-               /* Check if we have a bad block, we do not erase bad blocks ! */
-               if (nand_block_checkbad(mtd, ((loff_t) page) << this->page_shift, 0, allowbbt)) {
-                       printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page);
-                       instr->state = MTD_ERASE_FAILED;
-                       goto erase_exit;
-               }
-               
-               /* Invalidate the page cache, if we erase the block which contains 
-                  the current cached page */
-               if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block))
-                       this->pagebuf = -1;
-
-               this->erase_cmd (mtd, page & this->pagemask);
-               
-               status = this->waitfunc (mtd, this, FL_ERASING);
-
-               /* See if block erase succeeded */
-               if (status & 0x01) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page);
-                       instr->state = MTD_ERASE_FAILED;
-                       instr->fail_addr = (page << this->page_shift);
-                       goto erase_exit;
-               }
-               
-               /* Increment page address and decrement length */
-               len -= (1 << this->phys_erase_shift);
-               page += pages_per_block;
-
-               /* Check, if we cross a chip boundary */
-               if (len && !(page & this->pagemask)) {
-                       chipnr++;
-                       this->select_chip(mtd, -1);
-                       this->select_chip(mtd, chipnr);
-               }
-       }
-       instr->state = MTD_ERASE_DONE;
-
-erase_exit:
-
-       ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
-       /* Do call back function */
-       if (!ret)
-               mtd_erase_callback(instr);
-
-       /* Deselect and wake up anyone waiting on the device */
-       nand_release_chip(mtd);
-
-       /* Return more or less happy */
-       return ret;
-}
-
-/**
- * nand_sync - [MTD Interface] sync
- * @mtd:       MTD device structure
- *
- * Sync is actually a wait for chip ready function
- */
-static void nand_sync (struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       DECLARE_WAITQUEUE (wait, current);
-
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n");
-
-retry:
-       /* Grab the spinlock */
-       spin_lock_bh (&this->chip_lock);
-
-       /* See what's going on */
-       switch (this->state) {
-       case FL_READY:
-       case FL_SYNCING:
-               this->state = FL_SYNCING;
-               spin_unlock_bh (&this->chip_lock);
-               break;
-
-       default:
-               /* Not an idle state */
-               add_wait_queue (&this->wq, &wait);
-               spin_unlock_bh (&this->chip_lock);
-               schedule ();
-
-               remove_wait_queue (&this->wq, &wait);
-               goto retry;
-       }
-
-       /* Lock the device */
-       spin_lock_bh (&this->chip_lock);
-
-       /* Set the device to be ready again */
-       if (this->state == FL_SYNCING) {
-               this->state = FL_READY;
-               wake_up (&this->wq);
-       }
-
-       /* Unlock the device */
-       spin_unlock_bh (&this->chip_lock);
-}
-
-
-/**
- * nand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad
- * @mtd:       MTD device structure
- * @ofs:       offset relative to mtd start
- */
-static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs)
-{
-       /* Check for invalid offset */
-       if (ofs > mtd->size) 
-               return -EINVAL;
-       
-       return nand_block_checkbad (mtd, ofs, 1, 0);
-}
-
-/**
- * nand_block_markbad - [MTD Interface] Mark the block at the given offset as bad
- * @mtd:       MTD device structure
- * @ofs:       offset relative to mtd start
- */
-static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs)
-{
-       struct nand_chip *this = mtd->priv;
-       int ret;
-
-        if ((ret = nand_block_isbad(mtd, ofs))) {
-               /* If it was bad already, return success and do nothing. */
-               if (ret > 0)
-                       return 0;
-               return ret;
-        }
-
-       return this->block_markbad(mtd, ofs);
-}
-
-/**
- * nand_scan - [NAND Interface] Scan for the NAND device
- * @mtd:       MTD device structure
- * @maxchips:  Number of chips to scan for
- *
- * This fills out all the not initialized function pointers
- * with the defaults.
- * The flash ID is read and the mtd/chip structures are
- * filled with the appropriate values. Buffers are allocated if
- * they are not provided by the board driver
- *
- */
-int nand_scan (struct mtd_info *mtd, int maxchips)
-{
-       int i, j, nand_maf_id, nand_dev_id, busw;
-       struct nand_chip *this = mtd->priv;
-
-       /* Get buswidth to select the correct functions*/
-       busw = this->options & NAND_BUSWIDTH_16;
-
-       /* check for proper chip_delay setup, set 20us if not */
-       if (!this->chip_delay)
-               this->chip_delay = 20;
-
-       /* check, if a user supplied command function given */
-       if (this->cmdfunc == NULL)
-               this->cmdfunc = nand_command;
-
-       /* check, if a user supplied wait function given */
-       if (this->waitfunc == NULL)
-               this->waitfunc = nand_wait;
-
-       if (!this->select_chip)
-               this->select_chip = nand_select_chip;
-       if (!this->write_byte)
-               this->write_byte = busw ? nand_write_byte16 : nand_write_byte;
-       if (!this->read_byte)
-               this->read_byte = busw ? nand_read_byte16 : nand_read_byte;
-       if (!this->write_word)
-               this->write_word = nand_write_word;
-       if (!this->read_word)
-               this->read_word = nand_read_word;
-       if (!this->block_bad)
-               this->block_bad = nand_block_bad;
-       if (!this->block_markbad)
-               this->block_markbad = nand_default_block_markbad;
-       if (!this->write_buf)
-               this->write_buf = busw ? nand_write_buf16 : nand_write_buf;
-       if (!this->read_buf)
-               this->read_buf = busw ? nand_read_buf16 : nand_read_buf;
-       if (!this->verify_buf)
-               this->verify_buf = busw ? nand_verify_buf16 : nand_verify_buf;
-       if (!this->scan_bbt)
-               this->scan_bbt = nand_default_bbt;
-
-       /* Select the device */
-       this->select_chip(mtd, 0);
-
-       /* Send the command for reading device ID */
-       this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
-
-       /* Read manufacturer and device IDs */
-       nand_maf_id = this->read_byte(mtd);
-       nand_dev_id = this->read_byte(mtd);
-
-       /* Print and store flash device information */
-       for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-                               
-               if (nand_dev_id != nand_flash_ids[i].id) 
-                       continue;
-
-               if (!mtd->name) mtd->name = nand_flash_ids[i].name;
-               this->chipsize = nand_flash_ids[i].chipsize << 20;
-               
-               /* New devices have all the information in additional id bytes */
-               if (!nand_flash_ids[i].pagesize) {
-                       int extid;
-                       /* The 3rd id byte contains non relevant data ATM */
-                       extid = this->read_byte(mtd);
-                       /* The 4th id byte is the important one */
-                       extid = this->read_byte(mtd);
-                       /* Calc pagesize */
-                       mtd->oobblock = 1024 << (extid & 0x3);
-                       extid >>= 2;
-                       /* Calc oobsize */
-                       mtd->oobsize = (8 << (extid & 0x03)) * (mtd->oobblock / 512);
-                       extid >>= 2;
-                       /* Calc blocksize. Blocksize is multiples of 64KiB */
-                       mtd->erasesize = (64 * 1024)  << (extid & 0x03);
-                       extid >>= 2;
-                       /* Get buswidth information */
-                       busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0;
-               
-               } else {
-                       /* Old devices have this data hardcoded in the
-                        * device id table */
-                       mtd->erasesize = nand_flash_ids[i].erasesize;
-                       mtd->oobblock = nand_flash_ids[i].pagesize;
-                       mtd->oobsize = mtd->oobblock / 32;
-                       busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16;
-               }
-
-               /* Check, if buswidth is correct. Hardware drivers should set
-                * this correct ! */
-               if (busw != (this->options & NAND_BUSWIDTH_16)) {
-                       printk (KERN_INFO "NAND device: Manufacturer ID:"
-                               " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 
-                               nand_manuf_ids[i].name , mtd->name);
-                       printk (KERN_WARNING 
-                               "NAND bus width %d instead %d bit\n", 
-                                       (this->options & NAND_BUSWIDTH_16) ? 16 : 8,
-                                       busw ? 16 : 8);
-                       this->select_chip(mtd, -1);
-                       return 1;       
-               }
-               
-               /* Calculate the address shift from the page size */    
-               this->page_shift = ffs(mtd->oobblock) - 1;
-               this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1;
-               this->chip_shift = ffs(this->chipsize) - 1;
-
-               /* Set the bad block position */
-               this->badblockpos = mtd->oobblock > 512 ? 
-                       NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
-
-               /* Get chip options, preserve non chip based options */
-               this->options &= ~NAND_CHIPOPTIONS_MSK;
-               this->options |= nand_flash_ids[i].options & NAND_CHIPOPTIONS_MSK;
-               /* Set this as a default. Board drivers can override it, if neccecary */
-               this->options |= NAND_NO_AUTOINCR;
-               /* Check if this is a not a samsung device. Do not clear the options
-                * for chips which are not having an extended id.
-                */     
-               if (nand_maf_id != NAND_MFR_SAMSUNG && !nand_flash_ids[i].pagesize)
-                       this->options &= ~NAND_SAMSUNG_LP_OPTIONS;
-               
-               /* Check for AND chips with 4 page planes */
-               if (this->options & NAND_4PAGE_ARRAY)
-                       this->erase_cmd = multi_erase_cmd;
-               else
-                       this->erase_cmd = single_erase_cmd;
-
-               /* Do not replace user supplied command function ! */
-               if (mtd->oobblock > 512 && this->cmdfunc == nand_command)
-                       this->cmdfunc = nand_command_lp;
-                               
-               /* Try to identify manufacturer */
-               for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
-                       if (nand_manuf_ids[j].id == nand_maf_id)
-                               break;
-               }
-               printk (KERN_INFO "NAND device: Manufacturer ID:"
-                       " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 
-                       nand_manuf_ids[j].name , nand_flash_ids[i].name);
-               break;
-       }
-
-       if (!nand_flash_ids[i].name) {
-               printk (KERN_WARNING "No NAND device found!!!\n");
-               this->select_chip(mtd, -1);
-               return 1;
-       }
-
-       for (i=1; i < maxchips; i++) {
-               this->select_chip(mtd, i);
-
-               /* Send the command for reading device ID */
-               this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
-
-               /* Read manufacturer and device IDs */
-               if (nand_maf_id != this->read_byte(mtd) ||
-                   nand_dev_id != this->read_byte(mtd))
-                       break;
-       }
-       if (i > 1)
-               printk(KERN_INFO "%d NAND chips detected\n", i);
-       
-       /* Allocate buffers, if neccecary */
-       if (!this->oob_buf) {
-               size_t len;
-               len = mtd->oobsize << (this->phys_erase_shift - this->page_shift);
-               this->oob_buf = kmalloc (len, GFP_KERNEL);
-               if (!this->oob_buf) {
-                       printk (KERN_ERR "nand_scan(): Cannot allocate oob_buf\n");
-                       return -ENOMEM;
-               }
-               this->options |= NAND_OOBBUF_ALLOC;
-       }
-       
-       if (!this->data_buf) {
-               size_t len;
-               len = mtd->oobblock + mtd->oobsize;
-               this->data_buf = kmalloc (len, GFP_KERNEL);
-               if (!this->data_buf) {
-                       if (this->options & NAND_OOBBUF_ALLOC)
-                               kfree (this->oob_buf);
-                       printk (KERN_ERR "nand_scan(): Cannot allocate data_buf\n");
-                       return -ENOMEM;
-               }
-               this->options |= NAND_DATABUF_ALLOC;
-       }
-
-       /* Store the number of chips and calc total size for mtd */
-       this->numchips = i;
-       mtd->size = i * this->chipsize;
-       /* Convert chipsize to number of pages per chip -1. */
-       this->pagemask = (this->chipsize >> this->page_shift) - 1;
-       /* Preset the internal oob buffer */
-       memset(this->oob_buf, 0xff, mtd->oobsize << (this->phys_erase_shift - this->page_shift));
-
-       /* If no default placement scheme is given, select an
-        * appropriate one */
-       if (!this->autooob) {
-               /* Select the appropriate default oob placement scheme for
-                * placement agnostic filesystems */
-               switch (mtd->oobsize) { 
-               case 8:
-                       this->autooob = &nand_oob_8;
-                       break;
-               case 16:
-                       this->autooob = &nand_oob_16;
-                       break;
-               case 64:
-                       this->autooob = &nand_oob_64;
-                       break;
-               default:
-                       printk (KERN_WARNING "No oob scheme defined for oobsize %d\n",
-                               mtd->oobsize);
-                       BUG();
-               }
-       }
-       
-       /* The number of bytes available for the filesystem to place fs dependend
-        * oob data */
-       if (this->options & NAND_BUSWIDTH_16) {
-               mtd->oobavail = mtd->oobsize - (this->autooob->eccbytes + 2);
-               if (this->autooob->eccbytes & 0x01)
-                       mtd->oobavail--;
-       } else
-               mtd->oobavail = mtd->oobsize - (this->autooob->eccbytes + 1);
-
-       /* 
-        * check ECC mode, default to software
-        * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize
-        * fallback to software ECC 
-       */
-       this->eccsize = 256;    /* set default eccsize */       
-
-       switch (this->eccmode) {
-
-       case NAND_ECC_HW3_512: 
-       case NAND_ECC_HW6_512: 
-       case NAND_ECC_HW8_512: 
-               if (mtd->oobblock == 256) {
-                       printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n");
-                       this->eccmode = NAND_ECC_SOFT;
-                       this->calculate_ecc = nand_calculate_ecc;
-                       this->correct_data = nand_correct_data;
-                       break;          
-               } else 
-                       this->eccsize = 512; /* set eccsize to 512 and fall through for function check */
-
-       case NAND_ECC_HW3_256:
-               if (this->calculate_ecc && this->correct_data && this->enable_hwecc)
-                       break;
-               printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n");
-               BUG();  
-
-       case NAND_ECC_NONE: 
-               printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n");
-               this->eccmode = NAND_ECC_NONE;
-               break;
-
-       case NAND_ECC_SOFT:     
-               this->calculate_ecc = nand_calculate_ecc;
-               this->correct_data = nand_correct_data;
-               break;
-
-       default:
-               printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
-               BUG();  
-       }       
-       
-       mtd->eccsize = this->eccsize;
-       
-       /* Set the number of read / write steps for one page to ensure ECC generation */
-       switch (this->eccmode) {
-       case NAND_ECC_HW3_512:
-       case NAND_ECC_HW6_512:
-       case NAND_ECC_HW8_512:
-               this->eccsteps = mtd->oobblock / 512;
-               break;
-       case NAND_ECC_HW3_256:
-       case NAND_ECC_SOFT:     
-               this->eccsteps = mtd->oobblock / 256;
-               break;
-               
-       case NAND_ECC_NONE: 
-               this->eccsteps = 1;
-               break;
-       }
-       
-       /* Initialize state, waitqueue and spinlock */
-       this->state = FL_READY;
-       init_waitqueue_head (&this->wq);
-       spin_lock_init (&this->chip_lock);
-
-       /* De-select the device */
-       this->select_chip(mtd, -1);
-
-       /* Invalidate the pagebuffer reference */
-       this->pagebuf = -1;
-
-       /* Fill in remaining MTD driver data */
-       mtd->type = MTD_NANDFLASH;
-       mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
-       mtd->ecctype = MTD_ECC_SW;
-       mtd->erase = nand_erase;
-       mtd->point = NULL;
-       mtd->unpoint = NULL;
-       mtd->read = nand_read;
-       mtd->write = nand_write;
-       mtd->read_ecc = nand_read_ecc;
-       mtd->write_ecc = nand_write_ecc;
-       mtd->read_oob = nand_read_oob;
-       mtd->write_oob = nand_write_oob;
-       mtd->readv = NULL;
-       mtd->writev = nand_writev;
-       mtd->writev_ecc = nand_writev_ecc;
-       mtd->sync = nand_sync;
-       mtd->lock = NULL;
-       mtd->unlock = NULL;
-       mtd->suspend = NULL;
-       mtd->resume = NULL;
-       mtd->block_isbad = nand_block_isbad;
-       mtd->block_markbad = nand_block_markbad;
-
-       /* and make the autooob the default one */
-       memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo));
-
-       mtd->owner = THIS_MODULE;
-
-       /* Build bad block table */
-       return this->scan_bbt (mtd);
-}
-
-/**
- * nand_release - [NAND Interface] Free resources held by the NAND device 
- * @mtd:       MTD device structure
-*/
-void nand_release (struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-
-#ifdef CONFIG_MTD_PARTITIONS
-       /* Deregister partitions */
-       del_mtd_partitions (mtd);
-#endif
-       /* Deregister the device */
-       del_mtd_device (mtd);
-
-       /* Free bad block table memory, if allocated */
-       if (this->bbt)
-               kfree (this->bbt);
-       /* Buffer allocated by nand_scan ? */
-       if (this->options & NAND_OOBBUF_ALLOC)
-               kfree (this->oob_buf);
-       /* Buffer allocated by nand_scan ? */
-       if (this->options & NAND_DATABUF_ALLOC)
-               kfree (this->data_buf);
-}
-
-EXPORT_SYMBOL (nand_scan);
-EXPORT_SYMBOL (nand_release);
-
-MODULE_LICENSE ("GPL");
-MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>");
-MODULE_DESCRIPTION ("Generic NAND flash driver code");
diff --git a/drivers/mtd/nand/tx4925ndfmc.c b/drivers/mtd/nand/tx4925ndfmc.c
deleted file mode 100644 (file)
index 5f6a2f5..0000000
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- *  drivers/mtd/tx4925ndfmc.c
- *
- *  Overview:
- *   This is a device driver for the NAND flash device found on the
- *   Toshiba RBTX4925 reference board, which is a SmartMediaCard. It supports 
- *   16MiB, 32MiB and 64MiB cards.
- *
- * Author: MontaVista Software, Inc.  source@mvista.com
- *
- * Derived from drivers/mtd/autcpu12.c
- *       Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
- *
- * $Id: tx4925ndfmc.c,v 1.3 2004/07/20 02:44:26 dwmw2 Exp $
- *
- * Copyright (C) 2001 Toshiba Corporation 
- * 
- * 2003 (c) MontaVista Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/partitions.h>
-#include <linux/delay.h>
-#include <asm/io.h>
-#include <asm/tx4925/tx4925_nand.h>
-
-extern struct nand_oobinfo jffs2_oobinfo;
-
-/*
- * MTD structure for RBTX4925 board
- */
-static struct mtd_info *tx4925ndfmc_mtd = NULL;
-
-/*
- * Define partitions for flash devices
- */
-
-static struct mtd_partition partition_info16k[] = {
-       { .name = "RBTX4925 flash partition 1",
-         .offset =  0,
-         .size =    8 * 0x00100000 },
-       { .name = "RBTX4925 flash partition 2",
-         .offset =  8 * 0x00100000,
-         .size =    8 * 0x00100000 },
-};
-
-static struct mtd_partition partition_info32k[] = {
-       { .name = "RBTX4925 flash partition 1",
-         .offset =  0,
-         .size =    8 * 0x00100000 },
-       { .name = "RBTX4925 flash partition 2",
-         .offset = 8 * 0x00100000,
-         .size =  24 * 0x00100000 },
-};
-
-static struct mtd_partition partition_info64k[] = {
-       { .name = "User FS",
-         .offset =  0,
-         .size =   16 * 0x00100000 },
-       { .name = "RBTX4925 flash partition 2",
-         .offset = 16 * 0x00100000,
-         .size =   48 * 0x00100000},
-};
-
-static struct mtd_partition partition_info128k[] = {
-       { .name = "Skip bad section",
-         .offset =  0,
-         .size =   16 * 0x00100000 },
-       { .name = "User FS",
-         .offset = 16 * 0x00100000,
-         .size =   112 * 0x00100000 },
-};
-#define NUM_PARTITIONS16K  2
-#define NUM_PARTITIONS32K  2
-#define NUM_PARTITIONS64K  2
-#define NUM_PARTITIONS128K 2
-
-/* 
- *     hardware specific access to control-lines
-*/
-static void tx4925ndfmc_hwcontrol(struct mtd_info *mtd, int cmd)
-{
-
-       switch(cmd){
-
-               case NAND_CTL_SETCLE: 
-                       tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_CLE;
-                       break;
-               case NAND_CTL_CLRCLE:
-                       tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_CLE;
-                       break;
-               case NAND_CTL_SETALE:
-                       tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ALE;
-                       break;
-               case NAND_CTL_CLRALE: 
-                       tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ALE;
-                       break;
-               case NAND_CTL_SETNCE:
-                       tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_CE;
-                       break;
-               case NAND_CTL_CLRNCE:
-                       tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_CE;
-                       break;
-               case NAND_CTL_SETWP:
-                       tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_WE;
-                       break;
-               case NAND_CTL_CLRWP:
-                       tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_WE;
-                       break;
-       }
-}
-
-/*
-*      read device ready pin
-*/
-static int tx4925ndfmc_device_ready(struct mtd_info *mtd)
-{
-       int ready;
-       ready = (tx4925_ndfmcptr->sr & TX4925_NDSFR_BUSY) ? 0 : 1;
-       return ready;
-}
-void tx4925ndfmc_enable_hwecc(struct mtd_info *mtd, int mode)
-{
-       /* reset first */
-       tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ECC_CNTL_MASK;
-       tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ECC_CNTL_MASK;
-       tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ECC_CNTL_ENAB;
-}
-static void tx4925ndfmc_disable_ecc(void)
-{
-       tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ECC_CNTL_MASK;
-}
-static void tx4925ndfmc_enable_read_ecc(void)
-{
-       tx4925_ndfmcptr->mcr &= ~TX4925_NDFMCR_ECC_CNTL_MASK;
-       tx4925_ndfmcptr->mcr |= TX4925_NDFMCR_ECC_CNTL_READ;
-}
-void tx4925ndfmc_readecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code){
-       int i;
-       u_char *ecc = ecc_code;
-        tx4925ndfmc_enable_read_ecc();
-       for (i = 0;i < 6;i++,ecc++)
-               *ecc = tx4925_read_nfmc(&(tx4925_ndfmcptr->dtr));
-        tx4925ndfmc_disable_ecc();
-}
-void tx4925ndfmc_device_setup(void)
-{
-
-       *(unsigned char *)0xbb005000 &= ~0x08;
-
-        /* reset NDFMC */
-        tx4925_ndfmcptr->rstr |= TX4925_NDFRSTR_RST;
-       while (tx4925_ndfmcptr->rstr & TX4925_NDFRSTR_RST);       
-
-       /* setup BusSeparete, Hold Time, Strobe Pulse Width */
-       tx4925_ndfmcptr->mcr = TX4925_BSPRT ? TX4925_NDFMCR_BSPRT : 0;
-       tx4925_ndfmcptr->spr = TX4925_HOLD << 4 | TX4925_SPW;             
-}
-static u_char tx4925ndfmc_nand_read_byte(struct mtd_info *mtd)
-{
-        struct nand_chip *this = mtd->priv;
-        return tx4925_read_nfmc(this->IO_ADDR_R);
-}
-
-static void tx4925ndfmc_nand_write_byte(struct mtd_info *mtd, u_char byte)
-{
-        struct nand_chip *this = mtd->priv;
-        tx4925_write_nfmc(byte, this->IO_ADDR_W);
-}
-
-static void tx4925ndfmc_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i=0; i<len; i++)
-               tx4925_write_nfmc(buf[i], this->IO_ADDR_W);
-}
-
-static void tx4925ndfmc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i=0; i<len; i++)
-               buf[i] = tx4925_read_nfmc(this->IO_ADDR_R);
-}
-
-static int tx4925ndfmc_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i=0; i<len; i++)
-               if (buf[i] != tx4925_read_nfmc(this->IO_ADDR_R))
-                       return -EFAULT;
-
-       return 0;
-}
-
-/*
- * Send command to NAND device
- */
-static void tx4925ndfmc_nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
-{
-       register struct nand_chip *this = mtd->priv;
-
-       /* Begin command latch cycle */
-       this->hwcontrol(mtd, NAND_CTL_SETCLE);
-       /*
-        * Write out the command to the device.
-        */
-       if (command == NAND_CMD_SEQIN) {
-               int readcmd;
-
-               if (column >= mtd->oobblock) {
-                       /* OOB area */
-                       column -= mtd->oobblock;
-                       readcmd = NAND_CMD_READOOB;
-               } else if (column < 256) {
-                       /* First 256 bytes --> READ0 */
-                       readcmd = NAND_CMD_READ0;
-               } else {
-                       column -= 256;
-                       readcmd = NAND_CMD_READ1;
-               }
-               this->write_byte(mtd, readcmd);
-       }
-       this->write_byte(mtd, command);
-
-       /* Set ALE and clear CLE to start address cycle */
-       this->hwcontrol(mtd, NAND_CTL_CLRCLE);
-
-       if (column != -1 || page_addr != -1) {
-               this->hwcontrol(mtd, NAND_CTL_SETALE);
-
-               /* Serially input address */
-               if (column != -1)
-                       this->write_byte(mtd, column);
-               if (page_addr != -1) {
-                       this->write_byte(mtd, (unsigned char) (page_addr & 0xff));
-                       this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff));
-                       /* One more address cycle for higher density devices */
-                       if (mtd->size & 0x0c000000) 
-                               this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0x0f));
-               }
-               /* Latch in address */
-               this->hwcontrol(mtd, NAND_CTL_CLRALE);
-       }
-       
-       /* 
-        * program and erase have their own busy handlers 
-        * status and sequential in needs no delay
-       */
-       switch (command) {
-                       
-       case NAND_CMD_PAGEPROG:
-               /* Turn off WE */
-               this->hwcontrol (mtd, NAND_CTL_CLRWP);
-                return;
-
-       case NAND_CMD_SEQIN:
-               /* Turn on WE */
-               this->hwcontrol (mtd, NAND_CTL_SETWP);
-                return;
-
-       case NAND_CMD_ERASE1:
-       case NAND_CMD_ERASE2:
-       case NAND_CMD_STATUS:
-               return;
-
-       case NAND_CMD_RESET:
-               if (this->dev_ready)    
-                       break;
-               this->hwcontrol(mtd, NAND_CTL_SETCLE);
-               this->write_byte(mtd, NAND_CMD_STATUS);
-               this->hwcontrol(mtd, NAND_CTL_CLRCLE);
-               while ( !(this->read_byte(mtd) & 0x40));
-               return;
-
-       /* This applies to read commands */     
-       default:
-               /* 
-                * If we don't have access to the busy pin, we apply the given
-                * command delay
-               */
-               if (!this->dev_ready) {
-                       udelay (this->chip_delay);
-                       return;
-               }       
-       }
-       
-       /* wait until command is processed */
-       while (!this->dev_ready(mtd));
-}
-
-#ifdef CONFIG_MTD_CMDLINE_PARTS
-extern int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partitio
-n **pparts, char *);
-#endif
-
-/*
- * Main initialization routine
- */
-extern int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
-int __init tx4925ndfmc_init (void)
-{
-       struct nand_chip *this;
-       int err = 0;
-
-       /* Allocate memory for MTD device structure and private data */
-       tx4925ndfmc_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
-                               GFP_KERNEL);
-       if (!tx4925ndfmc_mtd) {
-               printk ("Unable to allocate RBTX4925 NAND MTD device structure.\n");
-               err = -ENOMEM;
-               goto out;
-       }
-
-        tx4925ndfmc_device_setup();
-
-       /* io is indirect via a register so don't need to ioremap address */
-
-       /* Get pointer to private data */
-       this = (struct nand_chip *) (&tx4925ndfmc_mtd[1]);
-
-       /* Initialize structures */
-       memset((char *) tx4925ndfmc_mtd, 0, sizeof(struct mtd_info));
-       memset((char *) this, 0, sizeof(struct nand_chip));
-
-       /* Link the private data with the MTD structure */
-       tx4925ndfmc_mtd->priv = this;
-
-       /* Set address of NAND IO lines */
-       this->IO_ADDR_R = (unsigned long)&(tx4925_ndfmcptr->dtr);
-       this->IO_ADDR_W = (unsigned long)&(tx4925_ndfmcptr->dtr);
-       this->hwcontrol = tx4925ndfmc_hwcontrol;
-       this->enable_hwecc = tx4925ndfmc_enable_hwecc;
-       this->calculate_ecc = tx4925ndfmc_readecc;
-       this->correct_data = nand_correct_data;
-       this->eccmode = NAND_ECC_HW6_512;       
-       this->dev_ready = tx4925ndfmc_device_ready;
-       /* 20 us command delay time */
-       this->chip_delay = 20;          
-        this->read_byte = tx4925ndfmc_nand_read_byte;
-        this->write_byte = tx4925ndfmc_nand_write_byte;
-       this->cmdfunc = tx4925ndfmc_nand_command;
-       this->write_buf = tx4925ndfmc_nand_write_buf;
-       this->read_buf = tx4925ndfmc_nand_read_buf;
-       this->verify_buf = tx4925ndfmc_nand_verify_buf;
-
-       /* Scan to find existance of the device */
-       if (nand_scan (tx4925ndfmc_mtd, 1)) {
-               err = -ENXIO;
-               goto out_ior;
-       }
-
-       /* Allocate memory for internal data buffer */
-       this->data_buf = kmalloc (sizeof(u_char) * (tx4925ndfmc_mtd->oobblock + tx4925ndfmc_mtd->oobsize), GFP_KERNEL);
-       if (!this->data_buf) {
-               printk ("Unable to allocate NAND data buffer for RBTX4925.\n");
-               err = -ENOMEM;
-               goto out_ior;
-       }
-
-       /* Register the partitions */
-#ifdef CONFIG_MTD_CMDLINE_PARTS
-        {
-                int mtd_parts_nb = 0;
-                struct mtd_partition *mtd_parts = 0;
-                mtd_parts_nb = parse_cmdline_partitions(tx4925ndfmc_mtd, &mtd_parts, "tx4925ndfmc");
-                if (mtd_parts_nb > 0)
-                        add_mtd_partitions(tx4925ndfmc_mtd, mtd_parts, mtd_parts_nb);
-                else
-                        add_mtd_device(tx4925ndfmc_mtd);
-        }
-#else /* ifdef CONFIG_MTD_CMDLINE_PARTS */
-       switch(tx4925ndfmc_mtd->size){
-               case 0x01000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info16k, NUM_PARTITIONS16K); break;
-               case 0x02000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info32k, NUM_PARTITIONS32K); break;
-               case 0x04000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info64k, NUM_PARTITIONS64K); break; 
-               case 0x08000000: add_mtd_partitions(tx4925ndfmc_mtd, partition_info128k, NUM_PARTITIONS128K); break; 
-               default: {
-                       printk ("Unsupported SmartMedia device\n"); 
-                       err = -ENXIO;
-                       goto out_buf;
-               }
-       }
-#endif /* ifdef CONFIG_MTD_CMDLINE_PARTS */
-       goto out;
-
-out_buf:
-       kfree (this->data_buf);    
-out_ior:
-out:
-       return err;
-}
-
-module_init(tx4925ndfmc_init);
-
-/*
- * Clean up routine
- */
-#ifdef MODULE
-static void __exit tx4925ndfmc_cleanup (void)
-{
-       struct nand_chip *this = (struct nand_chip *) &tx4925ndfmc_mtd[1];
-
-       /* Unregister partitions */
-       del_mtd_partitions(tx4925ndfmc_mtd);
-       
-       /* Unregister the device */
-       del_mtd_device (tx4925ndfmc_mtd);
-
-       /* Free internal data buffers */
-       kfree (this->data_buf);
-
-       /* Free the MTD device structure */
-       kfree (tx4925ndfmc_mtd);
-}
-module_exit(tx4925ndfmc_cleanup);
-#endif
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Alice Hennessy <ahennessy@mvista.com>");
-MODULE_DESCRIPTION("Glue layer for SmartMediaCard on Toshiba RBTX4925");
index ab2e61a..197a3cd 100644 (file)
@@ -1787,7 +1787,7 @@ vortex_timer(unsigned long data)
        struct net_device *dev = (struct net_device *)data;
        struct vortex_private *vp = netdev_priv(dev);
        long ioaddr = dev->base_addr;
-       int next_tick = 60*HZ;
+       int next_tick = 10*HZ;
        int ok = 0;
        int media_status, mii_status, old_window;
 
index 8828377..b124144 100644 (file)
@@ -1075,7 +1075,7 @@ config ETH16I
 
 config NE2000
        tristate "NE2000/NE1000 support"
-       depends on NET_ISA || (Q40 && m)
+       depends on ISA || (Q40 && m)
        select CRC32
        ---help---
          If you have a network (Ethernet) card of this type, say Y and read
@@ -2598,3 +2598,10 @@ config NETCONSOLE
        If you want to log kernel messages over the network, enable this.
        See Documentation/networking/netconsole.txt for details.
 
+config NETDUMP
+       tristate "Network kernel crash dump support"
+       depends on NETPOLL && NETPOLL_TRAP && X86
+       ---help---
+       Enable this option if you have a netdump server and you would like
+       to collect kernel crash dumps.
+
index 2ae71cf..3a7b01d 100644 (file)
@@ -191,3 +191,4 @@ obj-$(CONFIG_HAMRADIO) += hamradio/
 obj-$(CONFIG_IRDA) += irda/
 
 obj-$(CONFIG_NETCONSOLE) += netconsole.o
+obj-$(CONFIG_NETDUMP) += netdump.o
index 90ed332..a4977d2 100644 (file)
@@ -441,7 +441,7 @@ MODULE_PARM_DESC(max_rx_desc, "AceNIC/3C985/GA620 max number of receive descript
 MODULE_PARM_DESC(tx_ratio, "AceNIC/3C985/GA620 ratio of NIC memory used for TX/RX descriptors (range 0-63)");
 
 
-static char version[] __initdata = 
+static char version[]  = 
   "acenic.c: v0.92 08/05/2002  Jes Sorensen, linux-acenic@SunSITE.dk\n"
   "                            http://home.cern.ch/~jes/gige/acenic.html\n";
 
diff --git a/drivers/net/auto_irq.c b/drivers/net/auto_irq.c
deleted file mode 100644 (file)
index 96ddc77..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* auto_irq.c: Auto-configure IRQ lines for linux. */
-/*
-    Written 1994 by Donald Becker.
-
-    The author may be reached as becker@scyld.com
-
-    This code is a general-purpose IRQ line detector for devices with
-    jumpered IRQ lines.  If you can make the device raise an IRQ (and
-    that IRQ line isn't already being used), these routines will tell
-    you what IRQ line it's using -- perfect for those oh-so-cool boot-time
-    device probes!
-
-    To use this, first call autoirq_setup(timeout). TIMEOUT is how many
-    'jiffies' (1/100 sec.) to detect other devices that have active IRQ lines,
-    and can usually be zero at boot.  'autoirq_setup()' returns the bit
-    vector of nominally-available IRQ lines (lines may be physically in-use,
-    but not yet registered to a device).
-    Next, set up your device to trigger an interrupt.
-    Finally call autoirq_report(TIMEOUT) to find out which IRQ line was
-    most recently active.  The TIMEOUT should usually be zero, but may
-    be set to the number of jiffies to wait for a slow device to raise an IRQ.
-
-    The idea of using the setup timeout to filter out bogus IRQs came from
-    the serial driver.
-*/
-
-
-#ifdef version
-static const char *version=
-"auto_irq.c:v1.11 Donald Becker (becker@scyld.com)";
-#endif
-
-#include <linux/module.h>
-#include <linux/jiffies.h>
-#include <linux/delay.h>
-#include <asm/bitops.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <linux/netdevice.h>
-
-static unsigned long irqs;
-
-void autoirq_setup(int waittime)
-{
-       irqs = probe_irq_on();
-}
-
-#define BUSY_LOOP_UNTIL(j) while ((long)(jiffies-(j)) < 0) ;
-int autoirq_report(int waittime)
-{
-       unsigned long delay = jiffies + waittime;
-       BUSY_LOOP_UNTIL(delay)
-       return probe_irq_off(irqs);
-}
-
-EXPORT_SYMBOL(autoirq_setup);
-EXPORT_SYMBOL(autoirq_report);
-
-\f
-/*
- * Local variables:
- *  compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c auto_irq.c"
- *  version-control: t
- *  kept-new-versions: 5
- *  c-indent-level: 4
- *  tab-width: 4
- * End:
- */
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
deleted file mode 100644 (file)
index 5005c1c..0000000
+++ /dev/null
@@ -1,1926 +0,0 @@
-/* 
- * drivers/net/gianfar.c
- *
- * Gianfar Ethernet Driver
- * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
- * Based on 8260_io/fcc_enet.c
- *
- * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- *  Gianfar:  AKA Lambda Draconis, "Dragon"
- *  RA 11 31 24.2
- *  Dec +69 19 52
- *  V 3.84
- *  B-V +1.62
- *
- *  Theory of operation
- *  This driver is designed for the Triple-speed Ethernet
- *  controllers on the Freescale 8540/8560 integrated processors,
- *  as well as the Fast Ethernet Controller on the 8540.  
- *  
- *  The driver is initialized through OCP.  Structures which
- *  define the configuration needed by the board are defined in a
- *  board structure in arch/ppc/platforms (though I do not
- *  discount the possibility that other architectures could one
- *  day be supported.  One assumption the driver currently makes
- *  is that the PHY is configured in such a way to advertise all
- *  capabilities.  This is a sensible default, and on certain
- *  PHYs, changing this default encounters substantial errata
- *  issues.  Future versions may remove this requirement, but for
- *  now, it is best for the firmware to ensure this is the case.
- *
- *  The Gianfar Ethernet Controller uses a ring of buffer
- *  descriptors.  The beginning is indicated by a register
- *  pointing to the physical address of the start of the ring. 
- *  The end is determined by a "wrap" bit being set in the 
- *  last descriptor of the ring.
- *
- *  When a packet is received, the RXF bit in the
- *  IEVENT register is set, triggering an interrupt when the 
- *  corresponding bit in the IMASK register is also set (if
- *  interrupt coalescing is active, then the interrupt may not
- *  happen immediately, but will wait until either a set number
- *  of frames or amount of time have passed.).  In NAPI, the
- *  interrupt handler will signal there is work to be done, and
- *  exit.  Without NAPI, the packet(s) will be handled
- *  immediately.  Both methods will start at the last known empty
- *  descriptor, and process every subsequent descriptor until there 
- *  are none left with data (NAPI will stop after a set number of
- *  packets to give time to other tasks, but will eventually
- *  process all the packets).  The data arrives inside a
- *  pre-allocated skb, and so after the skb is passed up to the
- *  stack, a new skb must be allocated, and the address field in
- *  the buffer descriptor must be updated to indicate this new
- *  skb.
- *
- *  When the kernel requests that a packet be transmitted, the
- *  driver starts where it left off last time, and points the
- *  descriptor at the buffer which was passed in.  The driver
- *  then informs the DMA engine that there are packets ready to
- *  be transmitted.  Once the controller is finished transmitting
- *  the packet, an interrupt may be triggered (under the same
- *  conditions as for reception, but depending on the TXF bit).
- *  The driver then cleans up the buffer.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/spinlock.h>
-#include <linux/mm.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/dma-mapping.h>
-#include <linux/crc32.h>
-
-#include "gianfar.h"
-#include "gianfar_phy.h"
-#ifdef CONFIG_NET_FASTROUTE
-#include <linux/if_arp.h>
-#include <net/ip.h>
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,41)
-#define irqreturn_t void
-#define IRQ_HANDLED 
-#endif
-
-#define TX_TIMEOUT      (1*HZ)
-#define SKB_ALLOC_TIMEOUT 1000000
-#undef BRIEF_GFAR_ERRORS
-#define VERBOSE_GFAR_ERRORS
-
-#ifdef CONFIG_GFAR_NAPI
-#define RECEIVE(x) netif_receive_skb(x)
-#else
-#define RECEIVE(x) netif_rx(x)
-#endif
-
-#define DEVICE_NAME "%s: Gianfar Ethernet Controller Version 1.0, "
-char gfar_driver_name[] = "Gianfar Ethernet";
-char gfar_driver_version[] = "1.0";
-
-int startup_gfar(struct net_device *dev);
-static int gfar_enet_open(struct net_device *dev);
-static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void gfar_timeout(struct net_device *dev);
-static int gfar_close(struct net_device *dev);
-struct sk_buff *gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp);
-static struct net_device_stats *gfar_get_stats(struct net_device *dev);
-static int gfar_set_mac_address(struct net_device *dev);
-static int gfar_change_mtu(struct net_device *dev, int new_mtu);
-static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs);
-static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs);
-irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs);
-static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-static irqreturn_t phy_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-static void gfar_phy_change(void *data);
-static void gfar_phy_timer(unsigned long data);
-static void adjust_link(struct net_device *dev);
-static void init_registers(struct net_device *dev);
-static int init_phy(struct net_device *dev);
-static int gfar_probe(struct ocp_device *ocpdev);
-static void gfar_remove(struct ocp_device *ocpdev);
-void free_skb_resources(struct gfar_private *priv);
-static void gfar_set_multi(struct net_device *dev);
-static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
-#ifdef CONFIG_GFAR_NAPI
-static int gfar_poll(struct net_device *dev, int *budget);
-#endif
-#ifdef CONFIG_NET_FASTROUTE
-static int gfar_accept_fastpath(struct net_device *dev, struct dst_entry *dst);
-#endif
-static inline int try_fastroute(struct sk_buff *skb, struct net_device *dev, int length);
-#ifdef CONFIG_GFAR_NAPI
-static int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
-#else
-static int gfar_clean_rx_ring(struct net_device *dev);
-#endif
-static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length);
-
-extern struct ethtool_ops gfar_ethtool_ops;
-extern void gfar_gstrings_normon(struct net_device *dev, u32 stringset, 
-               u8 * buf);
-extern void gfar_fill_stats_normon(struct net_device *dev, 
-               struct ethtool_stats *dummy, u64 * buf);
-extern int gfar_stats_count_normon(struct net_device *dev);
-
-
-MODULE_AUTHOR("Freescale Semiconductor, Inc");
-MODULE_DESCRIPTION("Gianfar Ethernet Driver");
-MODULE_LICENSE("GPL");
-
-/* Called by the ocp code to initialize device data structures
- * required for bringing up the device
- * returns 0 on success */
-static int gfar_probe(struct ocp_device *ocpdev)
-{
-       u32 tempval;
-       struct ocp_device *mdiodev;
-       struct net_device *dev = NULL;
-       struct gfar_private *priv = NULL;
-       struct ocp_gfar_data *einfo;
-       int idx;
-       int err = 0;
-       struct ethtool_ops *dev_ethtool_ops;
-
-       einfo = (struct ocp_gfar_data *) ocpdev->def->additions;
-
-       if (einfo == NULL) {
-               printk(KERN_ERR "gfar %d: Missing additional data!\n",
-                      ocpdev->def->index);
-
-               return -ENODEV;
-       }
-
-       /* get a pointer to the register memory which can
-        * configure the PHYs.  If it's different from this set,
-        * get the device which has those regs */
-       if ((einfo->phyregidx >= 0) && (einfo->phyregidx != ocpdev->def->index)) {
-               mdiodev = ocp_find_device(OCP_ANY_ID,
-                                         OCP_FUNC_GFAR, einfo->phyregidx);
-
-               /* If the device which holds the MDIO regs isn't
-                * up, wait for it to come up */
-               if (mdiodev == NULL)
-                       return -EAGAIN;
-       } else {
-               mdiodev = ocpdev;
-       }
-
-       /* Create an ethernet device instance */
-       dev = alloc_etherdev(sizeof (*priv));
-
-       if (dev == NULL)
-               return -ENOMEM;
-
-       priv = netdev_priv(dev);
-
-       /* Set the info in the priv to the current info */
-       priv->einfo = einfo;
-
-       /* get a pointer to the register memory */
-       priv->regs = (struct gfar *)
-           ioremap(ocpdev->def->paddr, sizeof (struct gfar));
-
-       if (priv->regs == NULL) {
-               err = -ENOMEM;
-               goto regs_fail;
-       }
-
-       /* Set the PHY base address */
-       priv->phyregs = (struct gfar *)
-           ioremap(mdiodev->def->paddr, sizeof (struct gfar));
-
-       if (priv->phyregs == NULL) {
-               err = -ENOMEM;
-               goto phy_regs_fail;
-       }
-
-       ocp_set_drvdata(ocpdev, dev);
-
-       /* Stop the DMA engine now, in case it was running before */
-       /* (The firmware could have used it, and left it running). */
-       /* To do this, we write Graceful Receive Stop and Graceful */
-       /* Transmit Stop, and then wait until the corresponding bits */
-       /* in IEVENT indicate the stops have completed. */
-       tempval = gfar_read(&priv->regs->dmactrl);
-       tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);
-       gfar_write(&priv->regs->dmactrl, tempval);
-
-       tempval = gfar_read(&priv->regs->dmactrl);
-       tempval |= (DMACTRL_GRS | DMACTRL_GTS);
-       gfar_write(&priv->regs->dmactrl, tempval);
-
-       while (!(gfar_read(&priv->regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC)))
-               cpu_relax();
-
-       /* Reset MAC layer */
-       gfar_write(&priv->regs->maccfg1, MACCFG1_SOFT_RESET);
-
-       tempval = (MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
-       gfar_write(&priv->regs->maccfg1, tempval);
-
-       /* Initialize MACCFG2. */
-       gfar_write(&priv->regs->maccfg2, MACCFG2_INIT_SETTINGS);
-
-       /* Initialize ECNTRL */
-       gfar_write(&priv->regs->ecntrl, ECNTRL_INIT_SETTINGS);
-
-       /* Copy the station address into the dev structure, */
-       /* and into the address registers MAC_STNADDR1,2. */
-       /* Backwards, because little endian MACs are dumb. */
-       /* Don't set the regs if the firmware already did */
-       memcpy(dev->dev_addr, einfo->mac_addr, MAC_ADDR_LEN);
-
-       /* Set the dev->base_addr to the gfar reg region */
-       dev->base_addr = (unsigned long) (priv->regs);
-
-       SET_MODULE_OWNER(dev);
-
-       /* Fill in the dev structure */
-       dev->open = gfar_enet_open;
-       dev->hard_start_xmit = gfar_start_xmit;
-       dev->tx_timeout = gfar_timeout;
-       dev->watchdog_timeo = TX_TIMEOUT;
-#ifdef CONFIG_GFAR_NAPI
-       dev->poll = gfar_poll;
-       dev->weight = GFAR_DEV_WEIGHT;
-#endif
-       dev->stop = gfar_close;
-       dev->get_stats = gfar_get_stats;
-       dev->change_mtu = gfar_change_mtu;
-       dev->mtu = 1500;
-       dev->set_multicast_list = gfar_set_multi;
-       dev->flags |= IFF_MULTICAST;
-
-       dev_ethtool_ops = 
-               (struct ethtool_ops *)kmalloc(sizeof(struct ethtool_ops), 
-                                             GFP_KERNEL);
-
-       if(dev_ethtool_ops == NULL) {
-               err = -ENOMEM;
-               goto ethtool_fail;
-       }
-
-       memcpy(dev_ethtool_ops, &gfar_ethtool_ops, sizeof(gfar_ethtool_ops));
-
-       /* If there is no RMON support in this device, we don't
-        * want to expose non-existant statistics */
-       if((priv->einfo->flags & GFAR_HAS_RMON) == 0) {
-               dev_ethtool_ops->get_strings = gfar_gstrings_normon;
-               dev_ethtool_ops->get_stats_count = gfar_stats_count_normon;
-               dev_ethtool_ops->get_ethtool_stats = gfar_fill_stats_normon;
-       }
-
-       if((priv->einfo->flags & GFAR_HAS_COALESCE) == 0) {
-               dev_ethtool_ops->set_coalesce = NULL;
-               dev_ethtool_ops->get_coalesce = NULL;
-       }
-
-       dev->ethtool_ops = dev_ethtool_ops;
-
-#ifdef CONFIG_NET_FASTROUTE
-       dev->accept_fastpath = gfar_accept_fastpath;
-#endif
-
-       priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE;
-#ifdef CONFIG_GFAR_BUFSTASH
-       priv->rx_stash_size = STASH_LENGTH;
-#endif
-       priv->tx_ring_size = DEFAULT_TX_RING_SIZE;
-       priv->rx_ring_size = DEFAULT_RX_RING_SIZE;
-
-       /* Initially, coalescing is disabled */
-       priv->txcoalescing = 0;
-       priv->txcount = 0;
-       priv->txtime = 0;
-       priv->rxcoalescing = 0;
-       priv->rxcount = 0;
-       priv->rxtime = 0;
-
-       err = register_netdev(dev);
-
-       if (err) {
-               printk(KERN_ERR "%s: Cannot register net device, aborting.\n",
-                      dev->name);
-               goto register_fail;
-       }
-
-       /* Print out the device info */
-       printk(DEVICE_NAME, dev->name);
-       for (idx = 0; idx < 6; idx++)
-               printk("%2.2x%c", dev->dev_addr[idx], idx == 5 ? ' ' : ':');
-       printk("\n");
-
-       /* Even more device info helps when determining which kernel */
-       /* provided which set of benchmarks.  Since this is global for all */
-       /* devices, we only print it once */
-#ifdef CONFIG_GFAR_NAPI
-       printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name);
-#else
-       printk(KERN_INFO "%s: Running with NAPI disabled\n", dev->name);
-#endif
-       printk(KERN_INFO "%s: %d/%d RX/TX BD ring size\n",
-              dev->name, priv->rx_ring_size, priv->tx_ring_size);
-
-       return 0;
-
-
-register_fail:
-       kfree(dev_ethtool_ops);
-ethtool_fail:
-       iounmap((void *) priv->phyregs);
-phy_regs_fail:
-       iounmap((void *) priv->regs);
-regs_fail:
-       free_netdev(dev);
-       return -ENOMEM;
-}
-
-static void gfar_remove(struct ocp_device *ocpdev)
-{
-       struct net_device *dev = ocp_get_drvdata(ocpdev);
-       struct gfar_private *priv = netdev_priv(dev);
-
-       ocp_set_drvdata(ocpdev, NULL);
-
-       kfree(dev->ethtool_ops);
-       iounmap((void *) priv->regs);
-       iounmap((void *) priv->phyregs);
-       free_netdev(dev);
-}
-
-/* Configure the PHY for dev.
- * returns 0 if success.  -1 if failure
- */
-static int init_phy(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-       struct phy_info *curphy;
-
-       priv->link = 1;
-       priv->oldlink = 0;
-       priv->oldspeed = 0;
-       priv->olddplx = -1;
-
-       /* get info for this PHY */
-       curphy = get_phy_info(dev);
-
-       if (curphy == NULL) {
-               printk(KERN_ERR "%s: No PHY found\n", dev->name);
-               return -1;
-       }
-
-       priv->phyinfo = curphy;
-
-       /* Run the commands which configure the PHY */
-       phy_run_commands(dev, curphy->config);
-
-       return 0;
-}
-
-static void init_registers(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-
-       /* Clear IEVENT */
-       gfar_write(&priv->regs->ievent, IEVENT_INIT_CLEAR);
-
-       /* Initialize IMASK */
-       gfar_write(&priv->regs->imask, IMASK_INIT_CLEAR);
-
-       /* Init hash registers to zero */
-       gfar_write(&priv->regs->iaddr0, 0);
-       gfar_write(&priv->regs->iaddr1, 0);
-       gfar_write(&priv->regs->iaddr2, 0);
-       gfar_write(&priv->regs->iaddr3, 0);
-       gfar_write(&priv->regs->iaddr4, 0);
-       gfar_write(&priv->regs->iaddr5, 0);
-       gfar_write(&priv->regs->iaddr6, 0);
-       gfar_write(&priv->regs->iaddr7, 0);
-
-       gfar_write(&priv->regs->gaddr0, 0);
-       gfar_write(&priv->regs->gaddr1, 0);
-       gfar_write(&priv->regs->gaddr2, 0);
-       gfar_write(&priv->regs->gaddr3, 0);
-       gfar_write(&priv->regs->gaddr4, 0);
-       gfar_write(&priv->regs->gaddr5, 0);
-       gfar_write(&priv->regs->gaddr6, 0);
-       gfar_write(&priv->regs->gaddr7, 0);
-
-       /* Zero out rctrl */
-       gfar_write(&priv->regs->rctrl, 0x00000000);
-
-       /* Zero out the rmon mib registers if it has them */
-       if (priv->einfo->flags & GFAR_HAS_RMON) {
-               memset((void *) &(priv->regs->rmon), 0,
-                      sizeof (struct rmon_mib));
-
-               /* Mask off the CAM interrupts */
-               gfar_write(&priv->regs->rmon.cam1, 0xffffffff);
-               gfar_write(&priv->regs->rmon.cam2, 0xffffffff);
-       }
-
-       /* Initialize the max receive buffer length */
-       gfar_write(&priv->regs->mrblr, priv->rx_buffer_size);
-
-#ifdef CONFIG_GFAR_BUFSTASH
-       /* If we are stashing buffers, we need to set the
-        * extraction length to the size of the buffer */
-       gfar_write(&priv->regs->attreli, priv->rx_stash_size << 16);
-#endif
-
-       /* Initialize the Minimum Frame Length Register */
-       gfar_write(&priv->regs->minflr, MINFLR_INIT_SETTINGS);
-
-       /* Setup Attributes so that snooping is on for rx */
-       gfar_write(&priv->regs->attr, ATTR_INIT_SETTINGS);
-       gfar_write(&priv->regs->attreli, ATTRELI_INIT_SETTINGS);
-
-       /* Assign the TBI an address which won't conflict with the PHYs */
-       gfar_write(&priv->regs->tbipa, TBIPA_VALUE);
-}
-
-void stop_gfar(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
-       unsigned long flags;
-       u32 tempval;
-
-       /* Lock it down */
-       spin_lock_irqsave(&priv->lock, flags);
-
-       /* Tell the kernel the link is down */
-       priv->link = 0;
-       adjust_link(dev);
-
-       /* Mask all interrupts */
-       gfar_write(&regs->imask, IMASK_INIT_CLEAR);
-
-       /* Clear all interrupts */
-       gfar_write(&regs->ievent, IEVENT_INIT_CLEAR);
-
-       /* Stop the DMA, and wait for it to stop */
-       tempval = gfar_read(&priv->regs->dmactrl);
-       if ((tempval & (DMACTRL_GRS | DMACTRL_GTS))
-           != (DMACTRL_GRS | DMACTRL_GTS)) {
-               tempval |= (DMACTRL_GRS | DMACTRL_GTS);
-               gfar_write(&priv->regs->dmactrl, tempval);
-
-               while (!(gfar_read(&priv->regs->ievent) &
-                        (IEVENT_GRSC | IEVENT_GTSC)))
-                       cpu_relax();
-       }
-
-       /* Disable Rx and Tx */
-       tempval = gfar_read(&regs->maccfg1);
-       tempval &= ~(MACCFG1_RX_EN | MACCFG1_TX_EN);
-       gfar_write(&regs->maccfg1, tempval);
-
-       if (priv->einfo->flags & GFAR_HAS_PHY_INTR) {
-               phy_run_commands(dev, priv->phyinfo->shutdown);
-       }
-
-       spin_unlock_irqrestore(&priv->lock, flags);
-
-       /* Free the IRQs */
-       if (priv->einfo->flags & GFAR_HAS_MULTI_INTR) {
-               free_irq(priv->einfo->interruptError, dev);
-               free_irq(priv->einfo->interruptTransmit, dev);
-               free_irq(priv->einfo->interruptReceive, dev);
-       } else {
-               free_irq(priv->einfo->interruptTransmit, dev);
-       }
-
-       if (priv->einfo->flags & GFAR_HAS_PHY_INTR) {
-               free_irq(priv->einfo->interruptPHY, dev);
-       } else {
-               del_timer_sync(&priv->phy_info_timer);
-       }
-
-       free_skb_resources(priv);
-
-       dma_unmap_single(NULL, gfar_read(&regs->tbase),
-                       sizeof(struct txbd)*priv->tx_ring_size,
-                       DMA_BIDIRECTIONAL);
-       dma_unmap_single(NULL, gfar_read(&regs->rbase),
-                       sizeof(struct rxbd)*priv->rx_ring_size,
-                       DMA_BIDIRECTIONAL);
-
-       /* Free the buffer descriptors */
-       kfree(priv->tx_bd_base);
-}
-
-/* If there are any tx skbs or rx skbs still around, free them.
- * Then free tx_skbuff and rx_skbuff */
-void free_skb_resources(struct gfar_private *priv)
-{
-       struct rxbd8 *rxbdp;
-       struct txbd8 *txbdp;
-       int i;
-
-       /* Go through all the buffer descriptors and free their data buffers */
-       txbdp = priv->tx_bd_base;
-
-       for (i = 0; i < priv->tx_ring_size; i++) {
-
-               if (priv->tx_skbuff[i]) {
-                       dma_unmap_single(NULL, txbdp->bufPtr,
-                                       txbdp->length,
-                                       DMA_TO_DEVICE);
-                       dev_kfree_skb_any(priv->tx_skbuff[i]);
-                       priv->tx_skbuff[i] = NULL;
-               }
-       }
-
-       kfree(priv->tx_skbuff);
-
-       rxbdp = priv->rx_bd_base;
-
-       /* rx_skbuff is not guaranteed to be allocated, so only
-        * free it and its contents if it is allocated */
-       if(priv->rx_skbuff != NULL) {
-               for (i = 0; i < priv->rx_ring_size; i++) {
-                       if (priv->rx_skbuff[i]) {
-                               dma_unmap_single(NULL, rxbdp->bufPtr,
-                                               priv->rx_buffer_size
-                                               + RXBUF_ALIGNMENT,
-                                               DMA_FROM_DEVICE);
-
-                               dev_kfree_skb_any(priv->rx_skbuff[i]);
-                               priv->rx_skbuff[i] = NULL;
-                       }
-
-                       rxbdp->status = 0;
-                       rxbdp->length = 0;
-                       rxbdp->bufPtr = 0;
-
-                       rxbdp++;
-               }
-
-               kfree(priv->rx_skbuff);
-       }
-}
-
-/* Bring the controller up and running */
-int startup_gfar(struct net_device *dev)
-{
-       struct txbd8 *txbdp;
-       struct rxbd8 *rxbdp;
-       unsigned long addr;
-       int i;
-       struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
-       u32 tempval;
-       int err = 0;
-
-       gfar_write(&regs->imask, IMASK_INIT_CLEAR);
-
-       /* Allocate memory for the buffer descriptors */
-       addr =
-           (unsigned int) kmalloc(sizeof (struct txbd8) * priv->tx_ring_size +
-                                  sizeof (struct rxbd8) * priv->rx_ring_size,
-                                  GFP_KERNEL);
-
-       if (addr == 0) {
-               printk(KERN_ERR "%s: Could not allocate buffer descriptors!\n",
-                      dev->name);
-               return -ENOMEM;
-       }
-
-       priv->tx_bd_base = (struct txbd8 *) addr;
-
-       /* enet DMA only understands physical addresses */
-       gfar_write(&regs->tbase, 
-                       dma_map_single(NULL, (void *)addr, 
-                               sizeof(struct txbd8) * priv->tx_ring_size,
-                               DMA_BIDIRECTIONAL));
-
-       /* Start the rx descriptor ring where the tx ring leaves off */
-       addr = addr + sizeof (struct txbd8) * priv->tx_ring_size;
-       priv->rx_bd_base = (struct rxbd8 *) addr;
-       gfar_write(&regs->rbase, 
-                       dma_map_single(NULL, (void *)addr, 
-                               sizeof(struct rxbd8) * priv->rx_ring_size,
-                               DMA_BIDIRECTIONAL));
-
-       /* Setup the skbuff rings */
-       priv->tx_skbuff =
-           (struct sk_buff **) kmalloc(sizeof (struct sk_buff *) *
-                                       priv->tx_ring_size, GFP_KERNEL);
-
-       if (priv->tx_skbuff == NULL) {
-               printk(KERN_ERR "%s: Could not allocate tx_skbuff\n",
-                      dev->name);
-               err = -ENOMEM;
-               goto tx_skb_fail;
-       }
-
-       for (i = 0; i < priv->tx_ring_size; i++)
-               priv->tx_skbuff[i] = NULL;
-
-       priv->rx_skbuff =
-           (struct sk_buff **) kmalloc(sizeof (struct sk_buff *) *
-                                       priv->rx_ring_size, GFP_KERNEL);
-
-       if (priv->rx_skbuff == NULL) {
-               printk(KERN_ERR "%s: Could not allocate rx_skbuff\n",
-                      dev->name);
-               err = -ENOMEM;
-               goto rx_skb_fail;
-       }
-
-       for (i = 0; i < priv->rx_ring_size; i++)
-               priv->rx_skbuff[i] = NULL;
-
-       /* Initialize some variables in our dev structure */
-       priv->dirty_tx = priv->cur_tx = priv->tx_bd_base;
-       priv->cur_rx = priv->rx_bd_base;
-       priv->skb_curtx = priv->skb_dirtytx = 0;
-       priv->skb_currx = 0;
-
-       /* Initialize Transmit Descriptor Ring */
-       txbdp = priv->tx_bd_base;
-       for (i = 0; i < priv->tx_ring_size; i++) {
-               txbdp->status = 0;
-               txbdp->length = 0;
-               txbdp->bufPtr = 0;
-               txbdp++;
-       }
-
-       /* Set the last descriptor in the ring to indicate wrap */
-       txbdp--;
-       txbdp->status |= TXBD_WRAP;
-
-       rxbdp = priv->rx_bd_base;
-       for (i = 0; i < priv->rx_ring_size; i++) {
-               struct sk_buff *skb = NULL;
-
-               rxbdp->status = 0;
-
-               skb = gfar_new_skb(dev, rxbdp);
-
-               priv->rx_skbuff[i] = skb;
-
-               rxbdp++;
-       }
-
-       /* Set the last descriptor in the ring to wrap */
-       rxbdp--;
-       rxbdp->status |= RXBD_WRAP;
-
-       /* If the device has multiple interrupts, register for
-        * them.  Otherwise, only register for the one */
-       if (priv->einfo->flags & GFAR_HAS_MULTI_INTR) {
-               /* Install our interrupt handlers for Error, 
-                * Transmit, and Receive */
-               if (request_irq(priv->einfo->interruptError, gfar_error,
-                               SA_SHIRQ, "enet_error", dev) < 0) {
-                       printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                              dev->name, priv->einfo->interruptError);
-
-                       err = -1;
-                       goto err_irq_fail;
-               }
-
-               if (request_irq(priv->einfo->interruptTransmit, gfar_transmit,
-                               SA_SHIRQ, "enet_tx", dev) < 0) {
-                       printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                              dev->name, priv->einfo->interruptTransmit);
-
-                       err = -1;
-
-                       goto tx_irq_fail;
-               }
-
-               if (request_irq(priv->einfo->interruptReceive, gfar_receive,
-                               SA_SHIRQ, "enet_rx", dev) < 0) {
-                       printk(KERN_ERR "%s: Can't get IRQ %d (receive0)\n",
-                              dev->name, priv->einfo->interruptReceive);
-
-                       err = -1;
-                       goto rx_irq_fail;
-               }
-       } else {
-               if (request_irq(priv->einfo->interruptTransmit, gfar_interrupt,
-                               SA_SHIRQ, "gfar_interrupt", dev) < 0) {
-                       printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                              dev->name, priv->einfo->interruptError);
-
-                       err = -1;
-                       goto err_irq_fail;
-               }
-       }
-
-       /* Grab the PHY interrupt */
-       if (priv->einfo->flags & GFAR_HAS_PHY_INTR) {
-               if (request_irq(priv->einfo->interruptPHY, phy_interrupt,
-                               SA_SHIRQ, "phy_interrupt", dev) < 0) {
-                       printk(KERN_ERR "%s: Can't get IRQ %d (PHY)\n",
-                              dev->name, priv->einfo->interruptPHY);
-
-                       err = -1;
-
-                       if (priv->einfo->flags & GFAR_HAS_MULTI_INTR)
-                               goto phy_irq_fail;
-                       else
-                               goto tx_irq_fail;
-               }
-       } else {
-               init_timer(&priv->phy_info_timer);
-               priv->phy_info_timer.function = &gfar_phy_timer;
-               priv->phy_info_timer.data = (unsigned long) dev;
-               mod_timer(&priv->phy_info_timer, jiffies + 2 * HZ);
-       }
-
-       /* Set up the bottom half queue */
-       INIT_WORK(&priv->tq, (void (*)(void *))gfar_phy_change, dev);
-
-       /* Configure the PHY interrupt */
-       phy_run_commands(dev, priv->phyinfo->startup);
-
-       /* Tell the kernel the link is up, and determine the
-        * negotiated features (speed, duplex) */
-       adjust_link(dev);
-
-       if (priv->link == 0)
-               printk(KERN_INFO "%s: No link detected\n", dev->name);
-
-       /* Configure the coalescing support */
-       if (priv->txcoalescing)
-               gfar_write(&regs->txic,
-                          mk_ic_value(priv->txcount, priv->txtime));
-       else
-               gfar_write(&regs->txic, 0);
-
-       if (priv->rxcoalescing)
-               gfar_write(&regs->rxic,
-                          mk_ic_value(priv->rxcount, priv->rxtime));
-       else
-               gfar_write(&regs->rxic, 0);
-
-       init_waitqueue_head(&priv->rxcleanupq);
-
-       /* Enable Rx and Tx in MACCFG1 */
-       tempval = gfar_read(&regs->maccfg1);
-       tempval |= (MACCFG1_RX_EN | MACCFG1_TX_EN);
-       gfar_write(&regs->maccfg1, tempval);
-
-       /* Initialize DMACTRL to have WWR and WOP */
-       tempval = gfar_read(&priv->regs->dmactrl);
-       tempval |= DMACTRL_INIT_SETTINGS;
-       gfar_write(&priv->regs->dmactrl, tempval);
-
-       /* Clear THLT, so that the DMA starts polling now */
-       gfar_write(&regs->tstat, TSTAT_CLEAR_THALT);
-
-       /* Make sure we aren't stopped */
-       tempval = gfar_read(&priv->regs->dmactrl);
-       tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);
-       gfar_write(&priv->regs->dmactrl, tempval);
-
-       /* Unmask the interrupts we look for */
-       gfar_write(&regs->imask, IMASK_DEFAULT);
-
-       return 0;
-
-phy_irq_fail:
-       free_irq(priv->einfo->interruptReceive, dev);
-rx_irq_fail:
-       free_irq(priv->einfo->interruptTransmit, dev);
-tx_irq_fail:
-       free_irq(priv->einfo->interruptError, dev);
-err_irq_fail:
-rx_skb_fail:
-       free_skb_resources(priv);
-tx_skb_fail:
-       kfree(priv->tx_bd_base);
-       return err;
-}
-
-/* Called when something needs to use the ethernet device */
-/* Returns 0 for success. */
-static int gfar_enet_open(struct net_device *dev)
-{
-       int err;
-
-       /* Initialize a bunch of registers */
-       init_registers(dev);
-
-       gfar_set_mac_address(dev);
-
-       err = init_phy(dev);
-
-       if (err)
-               return err;
-
-       err = startup_gfar(dev);
-
-       netif_start_queue(dev);
-
-       return err;
-}
-
-/* This is called by the kernel when a frame is ready for transmission. */
-/* It is pointed to by the dev->hard_start_xmit function pointer */
-static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-       struct txbd8 *txbdp;
-
-       /* Update transmit stats */
-       priv->stats.tx_bytes += skb->len;
-
-       /* Lock priv now */
-       spin_lock_irq(&priv->lock);
-
-       /* Point at the first free tx descriptor */
-       txbdp = priv->cur_tx;
-
-       /* Clear all but the WRAP status flags */
-       txbdp->status &= TXBD_WRAP;
-
-       /* Set buffer length and pointer */
-       txbdp->length = skb->len;
-       txbdp->bufPtr = dma_map_single(NULL, skb->data, 
-                       skb->len, DMA_TO_DEVICE);
-
-       /* Save the skb pointer so we can free it later */
-       priv->tx_skbuff[priv->skb_curtx] = skb;
-
-       /* Update the current skb pointer (wrapping if this was the last) */
-       priv->skb_curtx =
-           (priv->skb_curtx + 1) & TX_RING_MOD_MASK(priv->tx_ring_size);
-
-       /* Flag the BD as interrupt-causing */
-       txbdp->status |= TXBD_INTERRUPT;
-
-       /* Flag the BD as ready to go, last in frame, and  */
-       /* in need of CRC */
-       txbdp->status |= (TXBD_READY | TXBD_LAST | TXBD_CRC);
-
-       dev->trans_start = jiffies;
-
-       /* If this was the last BD in the ring, the next one */
-       /* is at the beginning of the ring */
-       if (txbdp->status & TXBD_WRAP)
-               txbdp = priv->tx_bd_base;
-       else
-               txbdp++;
-
-       /* If the next BD still needs to be cleaned up, then the bds
-          are full.  We need to tell the kernel to stop sending us stuff. */
-       if (txbdp == priv->dirty_tx) {
-               netif_stop_queue(dev);
-
-               priv->stats.tx_fifo_errors++;
-       }
-
-       /* Update the current txbd to the next one */
-       priv->cur_tx = txbdp;
-
-       /* Tell the DMA to go go go */
-       gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT);
-
-       /* Unlock priv */
-       spin_unlock_irq(&priv->lock);
-
-       return 0;
-}
-
-/* Stops the kernel queue, and halts the controller */
-static int gfar_close(struct net_device *dev)
-{
-       stop_gfar(dev);
-
-       netif_stop_queue(dev);
-
-       return 0;
-}
-
-/* returns a net_device_stats structure pointer */
-static struct net_device_stats * gfar_get_stats(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-
-       return &(priv->stats);
-}
-
-/* Changes the mac address if the controller is not running. */
-int gfar_set_mac_address(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-       int i;
-       char tmpbuf[MAC_ADDR_LEN];
-       u32 tempval;
-
-       /* Now copy it into the mac registers backwards, cuz */
-       /* little endian is silly */
-       for (i = 0; i < MAC_ADDR_LEN; i++)
-               tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->dev_addr[i];
-
-       gfar_write(&priv->regs->macstnaddr1, *((u32 *) (tmpbuf)));
-
-       tempval = *((u32 *) (tmpbuf + 4));
-
-       gfar_write(&priv->regs->macstnaddr2, tempval);
-
-       return 0;
-}
-
-/**********************************************************************
- * gfar_accept_fastpath
- *
- * Used to authenticate to the kernel that a fast path entry can be
- * added to device's routing table cache
- *
- * Input : pointer to ethernet interface network device structure and
- *         a pointer to the designated entry to be added to the cache.
- * Output : zero upon success, negative upon failure
- **********************************************************************/
-#ifdef CONFIG_NET_FASTROUTE
-static int gfar_accept_fastpath(struct net_device *dev, struct dst_entry *dst)
-{
-       struct net_device *odev = dst->dev;
-
-       if ((dst->ops->protocol != __constant_htons(ETH_P_IP))
-                       || (odev->type != ARPHRD_ETHER) 
-                       || (odev->accept_fastpath == NULL)) {
-               return -1;
-       }
-
-       return 0;
-}
-#endif
-
-/* try_fastroute() -- Checks the fastroute cache to see if a given packet
- *   can be routed immediately to another device.  If it can, we send it.
- *   If we used a fastroute, we return 1.  Otherwise, we return 0.
- *   Returns 0 if CONFIG_NET_FASTROUTE is not on
- */
-static inline int try_fastroute(struct sk_buff *skb, struct net_device *dev, int length)
-{
-#ifdef CONFIG_NET_FASTROUTE
-       struct ethhdr *eth;
-       struct iphdr *iph;
-       unsigned int hash;
-       struct rtable *rt;
-       struct net_device *odev;
-       struct gfar_private *priv = netdev_priv(dev);
-       unsigned int CPU_ID = smp_processor_id();
-
-       eth = (struct ethhdr *) (skb->data);
-
-       /* Only route ethernet IP packets */
-       if (eth->h_proto == __constant_htons(ETH_P_IP)) {
-               iph = (struct iphdr *) (skb->data + ETH_HLEN);
-
-               /* Generate the hash value */
-               hash = ((*(u8 *) &iph->daddr) ^ (*(u8 *) & iph->saddr)) & NETDEV_FASTROUTE_HMASK;
-
-               rt = (struct rtable *) (dev->fastpath[hash]);
-               if (rt != NULL 
-                               && ((*(u32 *) &iph->daddr) == (*(u32 *) &rt->key.dst))
-                               && ((*(u32 *) &iph->saddr) == (*(u32 *) &rt->key.src))
-                               && !(rt->u.dst.obsolete)) {
-                       odev = rt->u.dst.dev;
-                       netdev_rx_stat[CPU_ID].fastroute_hit++;
-
-                       /* Make sure the packet is:
-                        * 1) IPv4
-                        * 2) without any options (header length of 5)
-                        * 3) Not a multicast packet
-                        * 4) going to a valid destination
-                        * 5) Not out of time-to-live
-                        */
-                       if (iph->version == 4 
-                                       && iph->ihl == 5 
-                                       && (!(eth->h_dest[0] & 0x01)) 
-                                       && neigh_is_valid(rt->u.dst.neighbour) 
-                                       && iph->ttl > 1) {
-
-                               /* Fast Route Path: Taken if the outgoing device is ready to transmit the packet now */
-                               if ((!netif_queue_stopped(odev)) 
-                                               && (!spin_is_locked(odev->xmit_lock)) 
-                                               && (skb->len <= (odev->mtu + ETH_HLEN + 2 + 4))) {
-
-                                       skb->pkt_type = PACKET_FASTROUTE;
-                                       skb->protocol = __constant_htons(ETH_P_IP);
-                                       ip_decrease_ttl(iph);
-                                       memcpy(eth->h_source, odev->dev_addr, MAC_ADDR_LEN);
-                                       memcpy(eth->h_dest, rt->u.dst.neighbour->ha, MAC_ADDR_LEN);
-                                       skb->dev = odev;
-
-                                       /* Prep the skb for the packet */
-                                       skb_put(skb, length);
-
-                                       if (odev->hard_start_xmit(skb, odev) != 0) {
-                                               panic("%s: FastRoute path corrupted", dev->name);
-                                       }
-                                       netdev_rx_stat[CPU_ID].fastroute_success++;
-                               }
-
-                               /* Semi Fast Route Path: Mark the packet as needing fast routing, but let the
-                                * stack handle getting it to the device */
-                               else {
-                                       skb->pkt_type = PACKET_FASTROUTE;
-                                       skb->nh.raw = skb->data + ETH_HLEN;
-                                       skb->protocol = __constant_htons(ETH_P_IP);
-                                       netdev_rx_stat[CPU_ID].fastroute_defer++;
-
-                                       /* Prep the skb for the packet */
-                                       skb_put(skb, length);
-
-                                       if(RECEIVE(skb) == NET_RX_DROP) {
-                                               priv->extra_stats.kernel_dropped++;
-                                       }
-                               }
-
-                               return 1;
-                       }
-               }
-       }
-#endif /* CONFIG_NET_FASTROUTE */
-       return 0;
-}
-
-static int gfar_change_mtu(struct net_device *dev, int new_mtu)
-{
-       int tempsize, tempval;
-       struct gfar_private *priv = netdev_priv(dev);
-       int oldsize = priv->rx_buffer_size;
-       int frame_size = new_mtu + 18;
-
-       if ((frame_size < 64) || (frame_size > JUMBO_FRAME_SIZE)) {
-               printk(KERN_ERR "%s: Invalid MTU setting\n", dev->name);
-               return -EINVAL;
-       }
-
-       tempsize =
-           (frame_size & ~(INCREMENTAL_BUFFER_SIZE - 1)) +
-           INCREMENTAL_BUFFER_SIZE;
-
-       /* Only stop and start the controller if it isn't already
-        * stopped */
-       if ((oldsize != tempsize) && (dev->flags & IFF_UP))
-               stop_gfar(dev);
-
-       priv->rx_buffer_size = tempsize;
-
-       dev->mtu = new_mtu;
-
-       gfar_write(&priv->regs->mrblr, priv->rx_buffer_size);
-       gfar_write(&priv->regs->maxfrm, priv->rx_buffer_size);
-
-       /* If the mtu is larger than the max size for standard
-        * ethernet frames (ie, a jumbo frame), then set maccfg2
-        * to allow huge frames, and to check the length */
-       tempval = gfar_read(&priv->regs->maccfg2);
-
-       if (priv->rx_buffer_size > DEFAULT_RX_BUFFER_SIZE)
-               tempval |= (MACCFG2_HUGEFRAME | MACCFG2_LENGTHCHECK);
-       else
-               tempval &= ~(MACCFG2_HUGEFRAME | MACCFG2_LENGTHCHECK);
-
-       gfar_write(&priv->regs->maccfg2, tempval);
-
-       if ((oldsize != tempsize) && (dev->flags & IFF_UP))
-               startup_gfar(dev);
-
-       return 0;
-}
-
-/* gfar_timeout gets called when a packet has not been
- * transmitted after a set amount of time.
- * For now, assume that clearing out all the structures, and
- * starting over will fix the problem. */
-static void gfar_timeout(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-
-       priv->stats.tx_errors++;
-
-       if (dev->flags & IFF_UP) {
-               stop_gfar(dev);
-               startup_gfar(dev);
-       }
-
-       if (!netif_queue_stopped(dev))
-               netif_schedule(dev);
-}
-
-/* Interrupt Handler for Transmit complete */
-static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct net_device *dev = (struct net_device *) dev_id;
-       struct gfar_private *priv = netdev_priv(dev);
-       struct txbd8 *bdp;
-
-       /* Clear IEVENT */
-       gfar_write(&priv->regs->ievent, IEVENT_TX_MASK);
-
-       /* Lock priv */
-       spin_lock(&priv->lock);
-       bdp = priv->dirty_tx;
-       while ((bdp->status & TXBD_READY) == 0) {
-               /* If dirty_tx and cur_tx are the same, then either the */
-               /* ring is empty or full now (it could only be full in the beginning, */
-               /* obviously).  If it is empty, we are done. */
-               if ((bdp == priv->cur_tx) && (netif_queue_stopped(dev) == 0))
-                       break;
-
-               priv->stats.tx_packets++;
-
-               /* Deferred means some collisions occurred during transmit, */
-               /* but we eventually sent the packet. */
-               if (bdp->status & TXBD_DEF)
-                       priv->stats.collisions++;
-
-               /* Free the sk buffer associated with this TxBD */
-               dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]);
-               priv->tx_skbuff[priv->skb_dirtytx] = NULL;
-               priv->skb_dirtytx =
-                   (priv->skb_dirtytx +
-                    1) & TX_RING_MOD_MASK(priv->tx_ring_size);
-
-               /* update bdp to point at next bd in the ring (wrapping if necessary) */
-               if (bdp->status & TXBD_WRAP)
-                       bdp = priv->tx_bd_base;
-               else
-                       bdp++;
-
-               /* Move dirty_tx to be the next bd */
-               priv->dirty_tx = bdp;
-
-               /* We freed a buffer, so now we can restart transmission */
-               if (netif_queue_stopped(dev))
-                       netif_wake_queue(dev);
-       } /* while ((bdp->status & TXBD_READY) == 0) */
-
-       /* If we are coalescing the interrupts, reset the timer */
-       /* Otherwise, clear it */
-       if (priv->txcoalescing)
-               gfar_write(&priv->regs->txic,
-                          mk_ic_value(priv->txcount, priv->txtime));
-       else
-               gfar_write(&priv->regs->txic, 0);
-
-       spin_unlock(&priv->lock);
-
-       return IRQ_HANDLED;
-}
-
-struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-       struct sk_buff *skb = NULL;
-       unsigned int timeout = SKB_ALLOC_TIMEOUT;
-
-       /* We have to allocate the skb, so keep trying till we succeed */
-       while ((!skb) && timeout--)
-               skb = dev_alloc_skb(priv->rx_buffer_size + RXBUF_ALIGNMENT);
-
-       if (skb == NULL)
-               return NULL;
-
-       /* We need the data buffer to be aligned properly.  We will reserve
-        * as many bytes as needed to align the data properly
-        */
-       skb_reserve(skb,
-                   RXBUF_ALIGNMENT -
-                   (((unsigned) skb->data) & (RXBUF_ALIGNMENT - 1)));
-
-       skb->dev = dev;
-
-       bdp->bufPtr = dma_map_single(NULL, skb->data,
-                       priv->rx_buffer_size + RXBUF_ALIGNMENT, 
-                       DMA_FROM_DEVICE);
-
-       bdp->length = 0;
-
-       /* Mark the buffer empty */
-       bdp->status |= (RXBD_EMPTY | RXBD_INTERRUPT);
-
-       return skb;
-}
-
-static inline void count_errors(unsigned short status, struct gfar_private *priv)
-{
-       struct net_device_stats *stats = &priv->stats;
-       struct gfar_extra_stats *estats = &priv->extra_stats;
-
-       /* If the packet was truncated, none of the other errors
-        * matter */
-       if (status & RXBD_TRUNCATED) {
-               stats->rx_length_errors++;
-
-               estats->rx_trunc++;
-
-               return;
-       }
-       /* Count the errors, if there were any */
-       if (status & (RXBD_LARGE | RXBD_SHORT)) {
-               stats->rx_length_errors++;
-
-               if (status & RXBD_LARGE)
-                       estats->rx_large++;
-               else
-                       estats->rx_short++;
-       }
-       if (status & RXBD_NONOCTET) {
-               stats->rx_frame_errors++;
-               estats->rx_nonoctet++;
-       }
-       if (status & RXBD_CRCERR) {
-               estats->rx_crcerr++;
-               stats->rx_crc_errors++;
-       }
-       if (status & RXBD_OVERRUN) {
-               estats->rx_overrun++;
-               stats->rx_crc_errors++;
-       }
-}
-
-irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct net_device *dev = (struct net_device *) dev_id;
-       struct gfar_private *priv = netdev_priv(dev);
-
-#ifdef CONFIG_GFAR_NAPI
-       u32 tempval;
-#endif
-
-       /* Clear IEVENT, so rx interrupt isn't called again
-        * because of this interrupt */
-       gfar_write(&priv->regs->ievent, IEVENT_RX_MASK);
-
-       /* support NAPI */
-#ifdef CONFIG_GFAR_NAPI
-       if (netif_rx_schedule_prep(dev)) {
-               tempval = gfar_read(&priv->regs->imask);
-               tempval &= IMASK_RX_DISABLED;
-               gfar_write(&priv->regs->imask, tempval);
-
-               __netif_rx_schedule(dev);
-       } else {
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: receive called twice (%x)[%x]\n",
-                      dev->name, gfar_read(priv->regs->ievent),
-                      gfar_read(priv->regs->imask));
-#endif
-       }
-#else
-
-       spin_lock(&priv->lock);
-       gfar_clean_rx_ring(dev);
-
-       /* If we are coalescing interrupts, update the timer */
-       /* Otherwise, clear it */
-       if (priv->rxcoalescing)
-               gfar_write(&priv->regs->rxic,
-                          mk_ic_value(priv->rxcount, priv->rxtime));
-       else
-               gfar_write(&priv->regs->rxic, 0);
-
-       /* Just in case we need to wake the ring param changer */
-       priv->rxclean = 1;
-
-       spin_unlock(&priv->lock);
-#endif
-
-       return IRQ_HANDLED;
-}
-
-
-/* gfar_process_frame() -- handle one incoming packet if skb
- * isn't NULL.  Try the fastroute before using the stack */
-static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
-               int length)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-
-       if (skb == NULL) {
-#ifdef BRIEF_GFAR_ERRORS
-               printk(KERN_WARNING "%s: Missing skb!!.\n",
-                               dev->name);
-#endif
-               priv->stats.rx_dropped++;
-               priv->extra_stats.rx_skbmissing++;
-       } else {
-               if(try_fastroute(skb, dev, length) == 0) {
-                       /* Prep the skb for the packet */
-                       skb_put(skb, length);
-
-                       /* Tell the skb what kind of packet this is */
-                       skb->protocol = eth_type_trans(skb, dev);
-
-                       /* Send the packet up the stack */
-                       if (RECEIVE(skb) == NET_RX_DROP) {
-                               priv->extra_stats.kernel_dropped++;
-                       }
-               }
-       }
-
-       return 0;
-}
-
-/* gfar_clean_rx_ring() -- Processes each frame in the rx ring
- *   until all are gone (or, in the case of NAPI, the budget/quota
- *   has been reached). Returns the number of frames handled
- */
-#ifdef CONFIG_GFAR_NAPI
-static int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
-#else
-static int gfar_clean_rx_ring(struct net_device *dev)
-#endif
-{
-       struct rxbd8 *bdp;
-       struct sk_buff *skb;
-       u16 pkt_len;
-       int howmany = 0;
-       struct gfar_private *priv = netdev_priv(dev);
-
-       /* Get the first full descriptor */
-       bdp = priv->cur_rx;
-
-#ifdef CONFIG_GFAR_NAPI
-#define GFAR_RXDONE() ((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))
-#else
-#define GFAR_RXDONE() (bdp->status & RXBD_EMPTY)
-#endif
-       while (!GFAR_RXDONE()) {
-               skb = priv->rx_skbuff[priv->skb_currx];
-
-               if (!(bdp->status &
-                     (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET
-                      | RXBD_CRCERR | RXBD_OVERRUN | RXBD_TRUNCATED))) {
-                       /* Increment the number of packets */
-                       priv->stats.rx_packets++;
-                       howmany++;
-
-                       /* Remove the FCS from the packet length */
-                       pkt_len = bdp->length - 4;
-
-                       gfar_process_frame(dev, skb, pkt_len);
-
-                       priv->stats.rx_bytes += pkt_len;
-
-               } else {
-                       count_errors(bdp->status, priv);
-
-                       if (skb)
-                               dev_kfree_skb_any(skb);
-
-                       priv->rx_skbuff[priv->skb_currx] = NULL;
-               }
-
-               dev->last_rx = jiffies;
-
-               /* Clear the status flags for this buffer */
-               bdp->status &= ~RXBD_STATS;
-
-               /* Add another skb for the future */
-               skb = gfar_new_skb(dev, bdp);
-               priv->rx_skbuff[priv->skb_currx] = skb;
-
-               /* Update to the next pointer */
-               if (bdp->status & RXBD_WRAP)
-                       bdp = priv->rx_bd_base;
-               else
-                       bdp++;
-
-               /* update to point at the next skb */
-               priv->skb_currx =
-                   (priv->skb_currx +
-                    1) & RX_RING_MOD_MASK(priv->rx_ring_size);
-
-       }
-
-       /* Update the current rxbd pointer to be the next one */
-       priv->cur_rx = bdp;
-
-       /* If no packets have arrived since the
-        * last one we processed, clear the IEVENT RX and
-        * BSY bits so that another interrupt won't be
-        * generated when we set IMASK */
-       if (bdp->status & RXBD_EMPTY)
-               gfar_write(&priv->regs->ievent, IEVENT_RX_MASK);
-
-       return howmany;
-}
-
-#ifdef CONFIG_GFAR_NAPI
-static int gfar_poll(struct net_device *dev, int *budget)
-{
-       int howmany;
-       struct gfar_private *priv = netdev_priv(dev);
-       int rx_work_limit = *budget;
-
-       if (rx_work_limit > dev->quota)
-               rx_work_limit = dev->quota;
-
-       spin_lock(&priv->lock);
-       howmany = gfar_clean_rx_ring(dev, rx_work_limit);
-
-       dev->quota -= howmany;
-       rx_work_limit -= howmany;
-       *budget -= howmany;
-
-       if (rx_work_limit >= 0) {
-               netif_rx_complete(dev);
-
-               /* Clear the halt bit in RSTAT */
-               gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT);
-
-               gfar_write(&priv->regs->imask, IMASK_DEFAULT);
-
-               /* If we are coalescing interrupts, update the timer */
-               /* Otherwise, clear it */
-               if (priv->rxcoalescing)
-                       gfar_write(&priv->regs->rxic,
-                                  mk_ic_value(priv->rxcount, priv->rxtime));
-               else
-                       gfar_write(&priv->regs->rxic, 0);
-
-               /* Signal to the ring size changer that it's safe to go */
-               priv->rxclean = 1;
-       }
-
-       spin_unlock(priv->lock);
-
-       return (rx_work_limit < 0) ? 1 : 0;
-}
-#endif
-
-/* The interrupt handler for devices with one interrupt */
-static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct net_device *dev = dev_id;
-       struct gfar_private *priv = netdev_priv(dev);
-
-       /* Save ievent for future reference */
-       u32 events = gfar_read(&priv->regs->ievent);
-
-       /* Clear IEVENT */
-       gfar_write(&priv->regs->ievent, events);
-
-       /* Check for reception */
-       if ((events & IEVENT_RXF0) || (events & IEVENT_RXB0))
-               gfar_receive(irq, dev_id, regs);
-
-       /* Check for transmit completion */
-       if ((events & IEVENT_TXF) || (events & IEVENT_TXB))
-               gfar_transmit(irq, dev_id, regs);
-
-       /* Update error statistics */
-       if (events & IEVENT_TXE) {
-               priv->stats.tx_errors++;
-
-               if (events & IEVENT_LC)
-                       priv->stats.tx_window_errors++;
-               if (events & IEVENT_CRL)
-                       priv->stats.tx_aborted_errors++;
-               if (events & IEVENT_XFUN) {
-#ifdef VERBOSE_GFAR_ERRORS
-                       printk(KERN_WARNING "%s: tx underrun. dropped packet\n",
-                              dev->name);
-#endif
-                       priv->stats.tx_dropped++;
-                       priv->extra_stats.tx_underrun++;
-
-                       /* Reactivate the Tx Queues */
-                       gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT);
-               }
-       }
-       if (events & IEVENT_BSY) {
-               priv->stats.rx_errors++;
-               priv->extra_stats.rx_bsy++;
-
-               gfar_receive(irq, dev_id, regs);
-
-#ifndef CONFIG_GFAR_NAPI
-               /* Clear the halt bit in RSTAT */
-               gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT);
-#endif
-
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: busy error (rhalt: %x)\n", dev->name,
-                      gfar_read(priv->regs->rstat));
-#endif
-       }
-       if (events & IEVENT_BABR) {
-               priv->stats.rx_errors++;
-               priv->extra_stats.rx_babr++;
-
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: babbling error\n", dev->name);
-#endif
-       }
-       if (events & IEVENT_EBERR) {
-               priv->extra_stats.eberr++;
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: EBERR\n", dev->name);
-#endif
-       }
-       if (events & IEVENT_RXC) {
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: control frame\n", dev->name);
-#endif
-       }
-
-       if (events & IEVENT_BABT) {
-               priv->extra_stats.tx_babt++;
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: babt error\n", dev->name);
-#endif
-       }
-
-       return IRQ_HANDLED;
-}
-
-static irqreturn_t phy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct net_device *dev = (struct net_device *) dev_id;
-       struct gfar_private *priv = netdev_priv(dev);
-
-       /* Run the commands which acknowledge the interrupt */
-       phy_run_commands(dev, priv->phyinfo->ack_int);
-
-       /* Schedule the bottom half */
-       schedule_work(&priv->tq);
-
-       return IRQ_HANDLED;
-}
-
-/* Scheduled by the phy_interrupt/timer to handle PHY changes */
-static void gfar_phy_change(void *data)
-{
-       struct net_device *dev = (struct net_device *) data;
-       struct gfar_private *priv = netdev_priv(dev);
-       int timeout = HZ / 1000 + 1;
-
-       /* Delay to give the PHY a chance to change the
-        * register state */
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(timeout);
-
-       /* Run the commands which check the link state */
-       phy_run_commands(dev, priv->phyinfo->handle_int);
-
-       /* React to the change in state */
-       adjust_link(dev);
-}
-
-/* Called every so often on systems that don't interrupt
- * the core for PHY changes */
-static void gfar_phy_timer(unsigned long data)
-{
-       struct net_device *dev = (struct net_device *) data;
-       struct gfar_private *priv = netdev_priv(dev);
-
-       schedule_work(&priv->tq);
-
-       mod_timer(&priv->phy_info_timer, jiffies + 2 * HZ);
-}
-
-/* Called every time the controller might need to be made
- * aware of new link state.  The PHY code conveys this
- * information through variables in the priv structure, and this
- * function converts those variables into the appropriate
- * register values, and can bring down the device if needed.
- */
-static void adjust_link(struct net_device *dev)
-{
-       struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
-       u32 tempval;
-
-       if (priv->link) {
-               /* Now we make sure that we can be in full duplex mode.
-                * If not, we operate in half-duplex mode. */
-               if (priv->duplexity != priv->olddplx) {
-                       if (!(priv->duplexity)) {
-                               tempval = gfar_read(&regs->maccfg2);
-                               tempval &= ~(MACCFG2_FULL_DUPLEX);
-                               gfar_write(&regs->maccfg2, tempval);
-
-                               printk(KERN_INFO "%s: Half Duplex\n",
-                                      dev->name);
-                       } else {
-                               tempval = gfar_read(&regs->maccfg2);
-                               tempval |= MACCFG2_FULL_DUPLEX;
-                               gfar_write(&regs->maccfg2, tempval);
-
-                               printk(KERN_INFO "%s: Full Duplex\n",
-                                      dev->name);
-                       }
-
-                       priv->olddplx = priv->duplexity;
-               }
-
-               if (priv->speed != priv->oldspeed) {
-                       switch (priv->speed) {
-                       case 1000:
-                               tempval = gfar_read(&regs->maccfg2);
-                               tempval =
-                                   ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII);
-                               gfar_write(&regs->maccfg2, tempval);
-                               break;
-                       case 100:
-                       case 10:
-                               tempval = gfar_read(&regs->maccfg2);
-                               tempval =
-                                   ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII);
-                               gfar_write(&regs->maccfg2, tempval);
-                               break;
-                       default:
-                               printk(KERN_WARNING
-                                      "%s: Ack!  Speed (%d) is not 10/100/1000!\n",
-                                      dev->name, priv->speed);
-                               break;
-                       }
-
-                       printk(KERN_INFO "%s: Speed %dBT\n", dev->name,
-                              priv->speed);
-
-                       priv->oldspeed = priv->speed;
-               }
-
-               if (!priv->oldlink) {
-                       printk(KERN_INFO "%s: Link is up\n", dev->name);
-                       priv->oldlink = 1;
-                       netif_carrier_on(dev);
-                       netif_schedule(dev);
-               }
-       } else {
-               if (priv->oldlink) {
-                       printk(KERN_INFO "%s: Link is down\n", dev->name);
-                       priv->oldlink = 0;
-                       priv->oldspeed = 0;
-                       priv->olddplx = -1;
-                       netif_carrier_off(dev);
-               }
-       }
-
-#ifdef VERBOSE_GFAR_ERRORS
-       printk(KERN_INFO "%s: Link now %s; %dBT %s-duplex\n",
-              dev->name, priv->link ? "up" : "down", priv->speed, priv->duplexity ? "full" : "half");
-#endif
-}
-
-
-/* Update the hash table based on the current list of multicast
- * addresses we subscribe to.  Also, change the promiscuity of
- * the device based on the flags (this function is called
- * whenever dev->flags is changed */
-static void gfar_set_multi(struct net_device *dev)
-{
-       struct dev_mc_list *mc_ptr;
-       struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
-       u32 tempval;
-
-       if(dev->flags & IFF_PROMISC) {
-               printk(KERN_INFO "%s: Entering promiscuous mode.\n",
-                               dev->name);
-               /* Set RCTRL to PROM */
-               tempval = gfar_read(&regs->rctrl);
-               tempval |= RCTRL_PROM;
-               gfar_write(&regs->rctrl, tempval);
-       } else {
-               /* Set RCTRL to not PROM */
-               tempval = gfar_read(&regs->rctrl);
-               tempval &= ~(RCTRL_PROM);
-               gfar_write(&regs->rctrl, tempval);
-       }
-       
-       if(dev->flags & IFF_ALLMULTI) {
-               /* Set the hash to rx all multicast frames */
-               gfar_write(&regs->gaddr0, 0xffffffff);
-               gfar_write(&regs->gaddr1, 0xffffffff);
-               gfar_write(&regs->gaddr2, 0xffffffff);
-               gfar_write(&regs->gaddr3, 0xffffffff);
-               gfar_write(&regs->gaddr4, 0xffffffff);
-               gfar_write(&regs->gaddr5, 0xffffffff);
-               gfar_write(&regs->gaddr6, 0xffffffff);
-               gfar_write(&regs->gaddr7, 0xffffffff);
-       } else {
-               /* zero out the hash */
-               gfar_write(&regs->gaddr0, 0x0);
-               gfar_write(&regs->gaddr1, 0x0);
-               gfar_write(&regs->gaddr2, 0x0);
-               gfar_write(&regs->gaddr3, 0x0);
-               gfar_write(&regs->gaddr4, 0x0);
-               gfar_write(&regs->gaddr5, 0x0);
-               gfar_write(&regs->gaddr6, 0x0);
-               gfar_write(&regs->gaddr7, 0x0);
-
-               if(dev->mc_count == 0)
-                       return;
-
-               /* Parse the list, and set the appropriate bits */
-               for(mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) {
-                       gfar_set_hash_for_addr(dev, mc_ptr->dmi_addr);
-               }
-       }
-
-       return;
-}
-
-/* Set the appropriate hash bit for the given addr */
-/* The algorithm works like so:
- * 1) Take the Destination Address (ie the multicast address), and
- * do a CRC on it (little endian), and reverse the bits of the
- * result.
- * 2) Use the 8 most significant bits as a hash into a 256-entry
- * table.  The table is controlled through 8 32-bit registers:
- * gaddr0-7.  gaddr0's MSB is entry 0, and gaddr7's LSB is
- * gaddr7.  This means that the 3 most significant bits in the
- * hash index which gaddr register to use, and the 5 other bits
- * indicate which bit (assuming an IBM numbering scheme, which
- * for PowerPC (tm) is usually the case) in the register holds
- * the entry. */
-static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr)
-{
-       u32 tempval;
-       struct gfar_private *priv = netdev_priv(dev);
-       struct gfar *regs = priv->regs;
-       u32 *hash = &regs->gaddr0;
-       u32 result = ether_crc(MAC_ADDR_LEN, addr);
-       u8 whichreg = ((result >> 29) & 0x7);
-       u8 whichbit = ((result >> 24) & 0x1f);
-       u32 value = (1 << (31-whichbit));
-
-       tempval = gfar_read(&hash[whichreg]);
-       tempval |= value;
-       gfar_write(&hash[whichreg], tempval);
-
-       return;
-}
-
-/* GFAR error interrupt handler */
-static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct net_device *dev = dev_id;
-       struct gfar_private *priv = netdev_priv(dev);
-
-       /* Save ievent for future reference */
-       u32 events = gfar_read(&priv->regs->ievent);
-
-       /* Clear IEVENT */
-       gfar_write(&priv->regs->ievent, IEVENT_ERR_MASK);
-
-       /* Hmm... */
-#if defined (BRIEF_GFAR_ERRORS) || defined (VERBOSE_GFAR_ERRORS)
-       printk(KERN_DEBUG "%s: error interrupt (ievent=0x%08x imask=0x%08x)\n",
-              dev->name, events, gfar_read(priv->regs->imask));
-#endif
-
-       /* Update the error counters */
-       if (events & IEVENT_TXE) {
-               priv->stats.tx_errors++;
-
-               if (events & IEVENT_LC)
-                       priv->stats.tx_window_errors++;
-               if (events & IEVENT_CRL)
-                       priv->stats.tx_aborted_errors++;
-               if (events & IEVENT_XFUN) {
-#ifdef VERBOSE_GFAR_ERRORS
-                       printk(KERN_DEBUG "%s: underrun.  packet dropped.\n",
-                              dev->name);
-#endif
-                       priv->stats.tx_dropped++;
-                       priv->extra_stats.tx_underrun++;
-
-                       /* Reactivate the Tx Queues */
-                       gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT);
-               }
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: Transmit Error\n", dev->name);
-#endif
-       }
-       if (events & IEVENT_BSY) {
-               priv->stats.rx_errors++;
-               priv->extra_stats.rx_bsy++;
-
-               gfar_receive(irq, dev_id, regs);
-
-#ifndef CONFIG_GFAR_NAPI
-               /* Clear the halt bit in RSTAT */
-               gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT);
-#endif
-
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: busy error (rhalt: %x)\n", dev->name,
-                      gfar_read(priv->regs->rstat));
-#endif
-       }
-       if (events & IEVENT_BABR) {
-               priv->stats.rx_errors++;
-               priv->extra_stats.rx_babr++;
-
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: babbling error\n", dev->name);
-#endif
-       }
-       if (events & IEVENT_EBERR) {
-               priv->extra_stats.eberr++;
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: EBERR\n", dev->name);
-#endif
-       }
-       if (events & IEVENT_RXC)
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: control frame\n", dev->name);
-#endif
-
-       if (events & IEVENT_BABT) {
-               priv->extra_stats.tx_babt++;
-#ifdef VERBOSE_GFAR_ERRORS
-               printk(KERN_DEBUG "%s: babt error\n", dev->name);
-#endif
-       }
-       return IRQ_HANDLED;
-}
-
-/* Structure for a device driver */
-static struct ocp_device_id gfar_ids[] = {
-       {.vendor = OCP_ANY_ID,.function = OCP_FUNC_GFAR},
-       {.vendor = OCP_VENDOR_INVALID}
-};
-
-static struct ocp_driver gfar_driver = {
-       .name = "gianfar",
-       .id_table = gfar_ids,
-
-       .probe = gfar_probe,
-       .remove = gfar_remove,
-};
-
-static int __init gfar_init(void)
-{
-       int rc;
-
-       rc = ocp_register_driver(&gfar_driver);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)
-       if (rc != 0) {
-#else
-       if (rc == 0) {
-#endif
-               ocp_unregister_driver(&gfar_driver);
-               return -ENODEV;
-       }
-
-       return 0;
-}
-
-static void __exit gfar_exit(void)
-{
-       ocp_unregister_driver(&gfar_driver);
-}
-
-module_init(gfar_init);
-module_exit(gfar_exit);
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
deleted file mode 100644 (file)
index f7af346..0000000
+++ /dev/null
@@ -1,537 +0,0 @@
-/* 
- * drivers/net/gianfar.h
- *
- * Gianfar Ethernet Driver
- * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
- * Based on 8260_io/fcc_enet.c
- *
- * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- *  Still left to do:
- *      -Add support for module parameters
- */
-#ifndef __GIANFAR_H
-#define __GIANFAR_H
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/spinlock.h>
-#include <linux/mm.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/crc32.h>
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)
-#include <linux/workqueue.h>
-#else
-#include <linux/tqueue.h>
-#define work_struct tq_struct
-#define schedule_work schedule_task
-#endif
-
-#include <linux/ethtool.h>
-#include <linux/netdevice.h>
-#include <asm/ocp.h>
-#include "gianfar_phy.h"
-
-/* The maximum number of packets to be handled in one call of gfar_poll */
-#define GFAR_DEV_WEIGHT 64
-
-/* Number of bytes to align the rx bufs to */
-#define RXBUF_ALIGNMENT 64
-
-/* The number of bytes which composes a unit for the purpose of
- * allocating data buffers.  ie-for any given MTU, the data buffer
- * will be the next highest multiple of 512 bytes. */
-#define INCREMENTAL_BUFFER_SIZE 512
-
-
-#define MAC_ADDR_LEN 6
-
-extern char gfar_driver_name[];
-extern char gfar_driver_version[];
-
-/* These need to be powers of 2 for this driver */
-#ifdef CONFIG_GFAR_NAPI
-#define DEFAULT_TX_RING_SIZE   256
-#define DEFAULT_RX_RING_SIZE   256
-#else
-#define DEFAULT_TX_RING_SIZE    64
-#define DEFAULT_RX_RING_SIZE    64
-#endif
-
-#define GFAR_RX_MAX_RING_SIZE   256
-#define GFAR_TX_MAX_RING_SIZE   256
-
-#define DEFAULT_RX_BUFFER_SIZE  1536
-#define TX_RING_MOD_MASK(size) (size-1)
-#define RX_RING_MOD_MASK(size) (size-1)
-#define JUMBO_BUFFER_SIZE 9728
-#define JUMBO_FRAME_SIZE 9600
-
-/* Latency of interface clock in nanoseconds */
-/* Interface clock latency , in this case, means the 
- * time described by a value of 1 in the interrupt
- * coalescing registers' time fields.  Since those fields
- * refer to the time it takes for 64 clocks to pass, the
- * latencies are as such:
- * GBIT = 125MHz => 8ns/clock => 8*64 ns / tick
- * 100 = 25 MHz => 40ns/clock => 40*64 ns / tick
- * 10 = 2.5 MHz => 400ns/clock => 400*64 ns / tick
- */
-#define GFAR_GBIT_TIME  512
-#define GFAR_100_TIME   2560
-#define GFAR_10_TIME    25600
-
-#define DEFAULT_TXCOUNT        16
-#define DEFAULT_TXTIME 32768
-
-#define DEFAULT_RXCOUNT        16
-#define DEFAULT_RXTIME 32768
-
-#define TBIPA_VALUE            0x1f
-#define MIIMCFG_INIT_VALUE     0x00000007
-#define MIIMCFG_RESET           0x80000000
-#define MIIMIND_BUSY            0x00000001
-
-/* MAC register bits */
-#define MACCFG1_SOFT_RESET     0x80000000
-#define MACCFG1_RESET_RX_MC    0x00080000
-#define MACCFG1_RESET_TX_MC    0x00040000
-#define MACCFG1_RESET_RX_FUN   0x00020000
-#define        MACCFG1_RESET_TX_FUN    0x00010000
-#define MACCFG1_LOOPBACK       0x00000100
-#define MACCFG1_RX_FLOW                0x00000020
-#define MACCFG1_TX_FLOW                0x00000010
-#define MACCFG1_SYNCD_RX_EN    0x00000008
-#define MACCFG1_RX_EN          0x00000004
-#define MACCFG1_SYNCD_TX_EN    0x00000002
-#define MACCFG1_TX_EN          0x00000001
-
-#define MACCFG2_INIT_SETTINGS  0x00007205
-#define MACCFG2_FULL_DUPLEX    0x00000001
-#define MACCFG2_IF              0x00000300
-#define MACCFG2_MII             0x00000100
-#define MACCFG2_GMII            0x00000200
-#define MACCFG2_HUGEFRAME      0x00000020
-#define MACCFG2_LENGTHCHECK    0x00000010
-
-#define ECNTRL_INIT_SETTINGS   0x00001000
-#define ECNTRL_TBI_MODE         0x00000020
-
-#define MRBLR_INIT_SETTINGS    DEFAULT_RX_BUFFER_SIZE
-
-#define MINFLR_INIT_SETTINGS   0x00000040
-
-/* Init to do tx snooping for buffers and descriptors */
-#define DMACTRL_INIT_SETTINGS   0x000000c3
-#define DMACTRL_GRS             0x00000010
-#define DMACTRL_GTS             0x00000008
-
-#define TSTAT_CLEAR_THALT       0x80000000
-
-/* Interrupt coalescing macros */
-#define IC_ICEN                        0x80000000
-#define IC_ICFT_MASK           0x1fe00000
-#define IC_ICFT_SHIFT          21
-#define mk_ic_icft(x)          \
-       (((unsigned int)x << IC_ICFT_SHIFT)&IC_ICFT_MASK)
-#define IC_ICTT_MASK           0x0000ffff
-#define mk_ic_ictt(x)          (x&IC_ICTT_MASK)
-
-#define mk_ic_value(count, time) (IC_ICEN | \
-                               mk_ic_icft(count) | \
-                               mk_ic_ictt(time))
-
-#define RCTRL_PROM             0x00000008
-#define RSTAT_CLEAR_RHALT       0x00800000
-
-#define IEVENT_INIT_CLEAR      0xffffffff
-#define IEVENT_BABR            0x80000000
-#define IEVENT_RXC             0x40000000
-#define IEVENT_BSY             0x20000000
-#define IEVENT_EBERR           0x10000000
-#define IEVENT_MSRO            0x04000000
-#define IEVENT_GTSC            0x02000000
-#define IEVENT_BABT            0x01000000
-#define IEVENT_TXC             0x00800000
-#define IEVENT_TXE             0x00400000
-#define IEVENT_TXB             0x00200000
-#define IEVENT_TXF             0x00100000
-#define IEVENT_LC              0x00040000
-#define IEVENT_CRL             0x00020000
-#define IEVENT_XFUN            0x00010000
-#define IEVENT_RXB0            0x00008000
-#define IEVENT_GRSC            0x00000100
-#define IEVENT_RXF0            0x00000080
-#define IEVENT_RX_MASK          (IEVENT_RXB0 | IEVENT_RXF0)
-#define IEVENT_TX_MASK          (IEVENT_TXB | IEVENT_TXF)
-#define IEVENT_ERR_MASK         \
-(IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \
- IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \
- | IEVENT_CRL | IEVENT_XFUN)
-
-#define IMASK_INIT_CLEAR       0x00000000
-#define IMASK_BABR              0x80000000
-#define IMASK_RXC               0x40000000
-#define IMASK_BSY               0x20000000
-#define IMASK_EBERR             0x10000000
-#define IMASK_MSRO             0x04000000
-#define IMASK_GRSC              0x02000000
-#define IMASK_BABT             0x01000000
-#define IMASK_TXC               0x00800000
-#define IMASK_TXEEN            0x00400000
-#define IMASK_TXBEN            0x00200000
-#define IMASK_TXFEN             0x00100000
-#define IMASK_LC               0x00040000
-#define IMASK_CRL              0x00020000
-#define IMASK_XFUN             0x00010000
-#define IMASK_RXB0              0x00008000
-#define IMASK_GTSC              0x00000100
-#define IMASK_RXFEN0           0x00000080
-#define IMASK_RX_DISABLED ~(IMASK_RXFEN0 | IMASK_BSY)
-#define IMASK_DEFAULT  (IMASK_TXEEN | IMASK_TXFEN | IMASK_TXBEN | \
-               IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \
-               IMASK_XFUN | IMASK_RXC | IMASK_BABT)
-
-
-/* Attribute fields */
-
-/* This enables rx snooping for buffers and descriptors */
-#ifdef CONFIG_GFAR_BDSTASH
-#define ATTR_BDSTASH           0x00000800
-#else
-#define ATTR_BDSTASH           0x00000000
-#endif
-
-#ifdef CONFIG_GFAR_BUFSTASH
-#define ATTR_BUFSTASH          0x00004000
-#define STASH_LENGTH           64
-#else
-#define ATTR_BUFSTASH          0x00000000
-#endif
-
-#define ATTR_SNOOPING          0x000000c0
-#define ATTR_INIT_SETTINGS      (ATTR_SNOOPING \
-               | ATTR_BDSTASH | ATTR_BUFSTASH)
-
-#define ATTRELI_INIT_SETTINGS   0x0
-
-
-/* TxBD status field bits */
-#define TXBD_READY             0x8000
-#define TXBD_PADCRC            0x4000
-#define TXBD_WRAP              0x2000
-#define TXBD_INTERRUPT         0x1000
-#define TXBD_LAST              0x0800
-#define TXBD_CRC               0x0400
-#define TXBD_DEF               0x0200
-#define TXBD_HUGEFRAME         0x0080
-#define TXBD_LATECOLLISION     0x0080
-#define TXBD_RETRYLIMIT                0x0040
-#define        TXBD_RETRYCOUNTMASK     0x003c
-#define TXBD_UNDERRUN          0x0002
-
-/* RxBD status field bits */
-#define RXBD_EMPTY             0x8000
-#define RXBD_RO1               0x4000
-#define RXBD_WRAP              0x2000
-#define RXBD_INTERRUPT         0x1000
-#define RXBD_LAST              0x0800
-#define RXBD_FIRST             0x0400
-#define RXBD_MISS              0x0100
-#define RXBD_BROADCAST         0x0080
-#define RXBD_MULTICAST         0x0040
-#define RXBD_LARGE             0x0020
-#define RXBD_NONOCTET          0x0010
-#define RXBD_SHORT             0x0008
-#define RXBD_CRCERR            0x0004
-#define RXBD_OVERRUN           0x0002
-#define RXBD_TRUNCATED         0x0001
-#define RXBD_STATS             0x01ff
-
-struct txbd8
-{
-       u16     status; /* Status Fields */
-       u16     length; /* Buffer length */
-       u32     bufPtr; /* Buffer Pointer */
-};
-
-struct rxbd8
-{
-       u16     status; /* Status Fields */
-       u16     length; /* Buffer Length */
-       u32     bufPtr; /* Buffer Pointer */
-};
-
-struct rmon_mib
-{
-       u32     tr64;   /* 0x.680 - Transmit and Receive 64-byte Frame Counter */
-       u32     tr127;  /* 0x.684 - Transmit and Receive 65-127 byte Frame Counter */
-       u32     tr255;  /* 0x.688 - Transmit and Receive 128-255 byte Frame Counter */
-       u32     tr511;  /* 0x.68c - Transmit and Receive 256-511 byte Frame Counter */
-       u32     tr1k;   /* 0x.690 - Transmit and Receive 512-1023 byte Frame Counter */
-       u32     trmax;  /* 0x.694 - Transmit and Receive 1024-1518 byte Frame Counter */
-       u32     trmgv;  /* 0x.698 - Transmit and Receive 1519-1522 byte Good VLAN Frame */
-       u32     rbyt;   /* 0x.69c - Receive Byte Counter */
-       u32     rpkt;   /* 0x.6a0 - Receive Packet Counter */
-       u32     rfcs;   /* 0x.6a4 - Receive FCS Error Counter */
-       u32     rmca;   /* 0x.6a8 - Receive Multicast Packet Counter */
-       u32     rbca;   /* 0x.6ac - Receive Broadcast Packet Counter */
-       u32     rxcf;   /* 0x.6b0 - Receive Control Frame Packet Counter */
-       u32     rxpf;   /* 0x.6b4 - Receive Pause Frame Packet Counter */
-       u32     rxuo;   /* 0x.6b8 - Receive Unknown OP Code Counter */
-       u32     raln;   /* 0x.6bc - Receive Alignment Error Counter */
-       u32     rflr;   /* 0x.6c0 - Receive Frame Length Error Counter */
-       u32     rcde;   /* 0x.6c4 - Receive Code Error Counter */
-       u32     rcse;   /* 0x.6c8 - Receive Carrier Sense Error Counter */
-       u32     rund;   /* 0x.6cc - Receive Undersize Packet Counter */
-       u32     rovr;   /* 0x.6d0 - Receive Oversize Packet Counter */
-       u32     rfrg;   /* 0x.6d4 - Receive Fragments Counter */
-       u32     rjbr;   /* 0x.6d8 - Receive Jabber Counter */
-       u32     rdrp;   /* 0x.6dc - Receive Drop Counter */
-       u32     tbyt;   /* 0x.6e0 - Transmit Byte Counter Counter */
-       u32     tpkt;   /* 0x.6e4 - Transmit Packet Counter */
-       u32     tmca;   /* 0x.6e8 - Transmit Multicast Packet Counter */
-       u32     tbca;   /* 0x.6ec - Transmit Broadcast Packet Counter */
-       u32     txpf;   /* 0x.6f0 - Transmit Pause Control Frame Counter */
-       u32     tdfr;   /* 0x.6f4 - Transmit Deferral Packet Counter */
-       u32     tedf;   /* 0x.6f8 - Transmit Excessive Deferral Packet Counter */
-       u32     tscl;   /* 0x.6fc - Transmit Single Collision Packet Counter */
-       u32     tmcl;   /* 0x.700 - Transmit Multiple Collision Packet Counter */
-       u32     tlcl;   /* 0x.704 - Transmit Late Collision Packet Counter */
-       u32     txcl;   /* 0x.708 - Transmit Excessive Collision Packet Counter */
-       u32     tncl;   /* 0x.70c - Transmit Total Collision Counter */
-       u8      res1[4];
-       u32     tdrp;   /* 0x.714 - Transmit Drop Frame Counter */
-       u32     tjbr;   /* 0x.718 - Transmit Jabber Frame Counter */
-       u32     tfcs;   /* 0x.71c - Transmit FCS Error Counter */
-       u32     txcf;   /* 0x.720 - Transmit Control Frame Counter */
-       u32     tovr;   /* 0x.724 - Transmit Oversize Frame Counter */
-       u32     tund;   /* 0x.728 - Transmit Undersize Frame Counter */
-       u32     tfrg;   /* 0x.72c - Transmit Fragments Frame Counter */
-       u32     car1;   /* 0x.730 - Carry Register One */
-       u32     car2;   /* 0x.734 - Carry Register Two */
-       u32     cam1;   /* 0x.738 - Carry Mask Register One */
-       u32     cam2;   /* 0x.73c - Carry Mask Register Two */
-};
-
-struct gfar_extra_stats {
-       u64 kernel_dropped;
-       u64 rx_large;
-       u64 rx_short;
-       u64 rx_nonoctet;
-       u64 rx_crcerr;
-       u64 rx_overrun;
-       u64 rx_bsy;
-       u64 rx_babr;
-       u64 rx_trunc;
-       u64 eberr;
-       u64 tx_babt;
-       u64 tx_underrun;
-       u64 rx_skbmissing;
-       u64 tx_timeout;
-};
-
-#define GFAR_RMON_LEN ((sizeof(struct rmon_mib) - 16)/sizeof(u32))
-#define GFAR_EXTRA_STATS_LEN (sizeof(struct gfar_extra_stats)/sizeof(u64))
-
-/* Number of stats in the stats structure (ignore car and cam regs)*/
-#define GFAR_STATS_LEN (GFAR_RMON_LEN + GFAR_EXTRA_STATS_LEN)
-
-#define GFAR_INFOSTR_LEN 32
-
-struct gfar_stats {
-       u64 extra[GFAR_EXTRA_STATS_LEN];
-       u64 rmon[GFAR_RMON_LEN];
-};
-
-
-struct gfar {
-       u8      res1[16];
-       u32     ievent;                 /* 0x.010 - Interrupt Event Register */
-       u32     imask;                  /* 0x.014 - Interrupt Mask Register */
-       u32     edis;                   /* 0x.018 - Error Disabled Register */
-       u8      res2[4];
-       u32     ecntrl;                 /* 0x.020 - Ethernet Control Register */
-       u32     minflr;                 /* 0x.024 - Minimum Frame Length Register */
-       u32     ptv;                    /* 0x.028 - Pause Time Value Register */
-       u32     dmactrl;                /* 0x.02c - DMA Control Register */
-       u32     tbipa;                  /* 0x.030 - TBI PHY Address Register */
-       u8      res3[88];
-       u32     fifo_tx_thr;            /* 0x.08c - FIFO transmit threshold register */
-       u8      res4[8];
-       u32     fifo_tx_starve;         /* 0x.098 - FIFO transmit starve register */
-       u32     fifo_tx_starve_shutoff; /* 0x.09c - FIFO transmit starve shutoff register */
-       u8      res5[96];
-       u32     tctrl;                  /* 0x.100 - Transmit Control Register */
-       u32     tstat;                  /* 0x.104 - Transmit Status Register */
-       u8      res6[4];
-       u32     tbdlen;                 /* 0x.10c - Transmit Buffer Descriptor Data Length Register */
-       u32     txic;                   /* 0x.110 - Transmit Interrupt Coalescing Configuration Register */
-       u8      res7[16];
-       u32     ctbptr;                 /* 0x.124 - Current Transmit Buffer Descriptor Pointer Register */
-       u8      res8[92];
-       u32     tbptr;                  /* 0x.184 - Transmit Buffer Descriptor Pointer Low Register */
-       u8      res9[124];
-       u32     tbase;                  /* 0x.204 - Transmit Descriptor Base Address Register */
-       u8      res10[168];
-       u32     ostbd;                  /* 0x.2b0 - Out-of-Sequence Transmit Buffer Descriptor Register */
-       u32     ostbdp;                 /* 0x.2b4 - Out-of-Sequence Transmit Data Buffer Pointer Register */
-       u8      res11[72];
-       u32     rctrl;                  /* 0x.300 - Receive Control Register */
-       u32     rstat;                  /* 0x.304 - Receive Status Register */
-       u8      res12[4];
-       u32     rbdlen;                 /* 0x.30c - RxBD Data Length Register */
-       u32     rxic;                   /* 0x.310 - Receive Interrupt Coalescing Configuration Register */
-       u8      res13[16];
-       u32     crbptr;                 /* 0x.324 - Current Receive Buffer Descriptor Pointer */
-       u8      res14[24];
-       u32     mrblr;                  /* 0x.340 - Maximum Receive Buffer Length Register */
-       u8      res15[64];
-       u32     rbptr;                  /* 0x.384 - Receive Buffer Descriptor Pointer */
-       u8      res16[124];
-       u32     rbase;                  /* 0x.404 - Receive Descriptor Base Address */
-       u8      res17[248];
-       u32     maccfg1;                /* 0x.500 - MAC Configuration 1 Register */
-       u32     maccfg2;                /* 0x.504 - MAC Configuration 2 Register */
-       u32     ipgifg;                 /* 0x.508 - Inter Packet Gap/Inter Frame Gap Register */
-       u32     hafdup;                 /* 0x.50c - Half Duplex Register */
-       u32     maxfrm;                 /* 0x.510 - Maximum Frame Length Register */
-       u8      res18[12];
-       u32     miimcfg;                /* 0x.520 - MII Management Configuration Register */
-       u32     miimcom;                /* 0x.524 - MII Management Command Register */
-       u32     miimadd;                /* 0x.528 - MII Management Address Register */
-       u32     miimcon;                /* 0x.52c - MII Management Control Register */
-       u32     miimstat;               /* 0x.530 - MII Management Status Register */
-       u32     miimind;                /* 0x.534 - MII Management Indicator Register */
-       u8      res19[4];
-       u32     ifstat;                 /* 0x.53c - Interface Status Register */
-       u32     macstnaddr1;            /* 0x.540 - Station Address Part 1 Register */
-       u32     macstnaddr2;            /* 0x.544 - Station Address Part 2 Register */
-       u8      res20[312];
-       struct rmon_mib rmon;
-       u8      res21[192];
-       u32     iaddr0;                 /* 0x.800 - Indivdual address register 0 */
-       u32     iaddr1;                 /* 0x.804 - Indivdual address register 1 */
-       u32     iaddr2;                 /* 0x.808 - Indivdual address register 2 */
-       u32     iaddr3;                 /* 0x.80c - Indivdual address register 3 */
-       u32     iaddr4;                 /* 0x.810 - Indivdual address register 4 */
-       u32     iaddr5;                 /* 0x.814 - Indivdual address register 5 */
-       u32     iaddr6;                 /* 0x.818 - Indivdual address register 6 */
-       u32     iaddr7;                 /* 0x.81c - Indivdual address register 7 */
-       u8      res22[96];
-       u32     gaddr0;                 /* 0x.880 - Global address register 0 */
-       u32     gaddr1;                 /* 0x.884 - Global address register 1 */
-       u32     gaddr2;                 /* 0x.888 - Global address register 2 */
-       u32     gaddr3;                 /* 0x.88c - Global address register 3 */
-       u32     gaddr4;                 /* 0x.890 - Global address register 4 */
-       u32     gaddr5;                 /* 0x.894 - Global address register 5 */
-       u32     gaddr6;                 /* 0x.898 - Global address register 6 */
-       u32     gaddr7;                 /* 0x.89c - Global address register 7 */
-       u8      res23[856];
-       u32     attr;                   /* 0x.bf8 - Attributes Register */
-       u32     attreli;                /* 0x.bfc - Attributes Extract Length and Extract Index Register */
-       u8      res24[1024];
-
-};
-
-/* Struct stolen almost completely (and shamelessly) from the FCC enet source
- * (Ok, that's not so true anymore, but there is a family resemblence)
- * The GFAR buffer descriptors track the ring buffers.  The rx_bd_base
- * and tx_bd_base always point to the currently available buffer.
- * The dirty_tx tracks the current buffer that is being sent by the
- * controller.  The cur_tx and dirty_tx are equal under both completely
- * empty and completely full conditions.  The empty/ready indicator in
- * the buffer descriptor determines the actual condition.
- */
-struct gfar_private
-{
-       /* pointers to arrays of skbuffs for tx and rx */
-       struct sk_buff ** tx_skbuff;
-       struct sk_buff ** rx_skbuff;
-
-       /* indices pointing to the next free sbk in skb arrays */
-       u16 skb_curtx;
-       u16 skb_currx;
-
-       /* index of the first skb which hasn't been transmitted
-        * yet. */
-       u16 skb_dirtytx;
-
-       /* Configuration info for the coalescing features */
-       unsigned char txcoalescing;
-       unsigned short txcount;
-       unsigned short txtime;
-       unsigned char rxcoalescing;
-       unsigned short rxcount;
-       unsigned short rxtime;
-
-       /* GFAR addresses */
-       struct rxbd8 *rx_bd_base;       /* Base addresses of Rx and Tx Buffers */
-       struct txbd8 *tx_bd_base;
-       struct rxbd8 *cur_rx;           /* Next free rx ring entry */
-       struct txbd8 *cur_tx;           /* Next free ring entry */
-       struct txbd8 *dirty_tx;         /* The Ring entry to be freed. */
-       struct gfar *regs;      /* Pointer to the GFAR memory mapped Registers */
-       struct phy_info *phyinfo;
-       struct gfar *phyregs;
-       struct work_struct tq;
-       struct timer_list phy_info_timer;
-       struct net_device_stats stats; /* linux network statistics */
-       struct gfar_extra_stats extra_stats;
-       spinlock_t lock;
-       unsigned int rx_buffer_size;
-       unsigned int rx_stash_size;
-       unsigned int tx_ring_size;
-       unsigned int rx_ring_size;
-       wait_queue_head_t rxcleanupq;
-       unsigned int rxclean;
-       int link;       /* current link state */
-       int oldlink;
-       int duplexity; /* Indicates negotiated duplex state */
-       int olddplx;
-       int speed;      /* Indicates negotiated speed */
-       int oldspeed;
-       
-       /* Info structure initialized by board setup code */
-       struct ocp_gfar_data *einfo;
-};
-
-extern inline u32 gfar_read(volatile unsigned *addr)
-{
-       u32 val;
-       val = in_be32(addr);
-       return val;
-}
-
-extern inline void gfar_write(volatile unsigned *addr, u32 val)
-{
-       out_be32(addr, val);
-}
-
-
-
-#endif /* __GIANFAR_H */
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
deleted file mode 100644 (file)
index 4ccb5af..0000000
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * drivers/net/gianfar_ethtool.c
- *
- * Gianfar Ethernet Driver
- * Ethtool support for Gianfar Enet
- * Based on e1000 ethtool support
- *
- * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This software may be used and distributed according to 
- * the terms of the GNU Public License, Version 2, incorporated herein 
- * by reference.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/spinlock.h>
-#include <linux/mm.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/crc32.h>
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <linux/ethtool.h>
-
-#include "gianfar.h"
-
-#define is_power_of_2(x)        ((x) != 0 && (((x) & ((x) - 1)) == 0))
-
-extern int startup_gfar(struct net_device *dev);
-extern void stop_gfar(struct net_device *dev);
-extern void gfar_receive(int irq, void *dev_id, struct pt_regs *regs);
-
-void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
-                    u64 * buf);
-void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf);
-int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals);
-int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals);
-void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals);
-int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals);
-void gfar_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo);
-
-static char stat_gstrings[][ETH_GSTRING_LEN] = {
-       "RX Dropped by Kernel",
-       "RX Large Frame Errors",
-       "RX Short Frame Errors",
-       "RX Non-Octet Errors",
-       "RX CRC Errors",
-       "RX Overrun Errors",
-       "RX Busy Errors",
-       "RX Babbling Errors",
-       "RX Truncated Frames",
-       "Ethernet Bus Error",
-       "TX Babbling Errors",
-       "TX Underrun Errors",
-       "RX SKB Missing Errors",
-       "TX Timeout Errors",
-       "tx&rx 64B frames",
-       "tx&rx 65-127B frames",
-       "tx&rx 128-255B frames",
-       "tx&rx 256-511B frames",
-       "tx&rx 512-1023B frames",
-       "tx&rx 1024-1518B frames",
-       "tx&rx 1519-1522B Good VLAN",
-       "RX bytes",
-       "RX Packets",
-       "RX FCS Errors",
-       "Receive Multicast Packet",
-       "Receive Broadcast Packet",
-       "RX Control Frame Packets",
-       "RX Pause Frame Packets",
-       "RX Unknown OP Code",
-       "RX Alignment Error",
-       "RX Frame Length Error",
-       "RX Code Error",
-       "RX Carrier Sense Error",
-       "RX Undersize Packets",
-       "RX Oversize Packets",
-       "RX Fragmented Frames",
-       "RX Jabber Frames",
-       "RX Dropped Frames",
-       "TX Byte Counter",
-       "TX Packets",
-       "TX Multicast Packets",
-       "TX Broadcast Packets",
-       "TX Pause Control Frames",
-       "TX Deferral Packets",
-       "TX Excessive Deferral Packets",
-       "TX Single Collision Packets",
-       "TX Multiple Collision Packets",
-       "TX Late Collision Packets",
-       "TX Excessive Collision Packets",
-       "TX Total Collision",
-       "RESERVED",
-       "TX Dropped Frames",
-       "TX Jabber Frames",
-       "TX FCS Errors",
-       "TX Control Frames",
-       "TX Oversize Frames",
-       "TX Undersize Frames",
-       "TX Fragmented Frames",
-};
-
-/* Fill in an array of 64-bit statistics from various sources.
- * This array will be appended to the end of the ethtool_stats
- * structure, and returned to user space
- */
-void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy, u64 * buf)
-{
-       int i;
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       u32 *rmon = (u32 *) & priv->regs->rmon;
-       u64 *extra = (u64 *) & priv->extra_stats;
-       struct gfar_stats *stats = (struct gfar_stats *) buf;
-
-       for (i = 0; i < GFAR_RMON_LEN; i++) {
-               stats->rmon[i] = (u64) (rmon[i]);
-       }
-
-       for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++) {
-               stats->extra[i] = extra[i];
-       }
-}
-
-/* Returns the number of stats (and their corresponding strings) */
-int gfar_stats_count(struct net_device *dev)
-{
-       return GFAR_STATS_LEN;
-}
-
-void gfar_gstrings_normon(struct net_device *dev, u32 stringset, u8 * buf)
-{
-       memcpy(buf, stat_gstrings, GFAR_EXTRA_STATS_LEN * ETH_GSTRING_LEN);
-}
-
-void gfar_fill_stats_normon(struct net_device *dev, 
-               struct ethtool_stats *dummy, u64 * buf)
-{
-       int i;
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       u64 *extra = (u64 *) & priv->extra_stats;
-
-       for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++) {
-               buf[i] = extra[i];
-       }
-}
-
-
-int gfar_stats_count_normon(struct net_device *dev)
-{
-       return GFAR_EXTRA_STATS_LEN;
-}
-/* Fills in the drvinfo structure with some basic info */
-void gfar_gdrvinfo(struct net_device *dev, struct
-             ethtool_drvinfo *drvinfo)
-{
-       strncpy(drvinfo->driver, gfar_driver_name, GFAR_INFOSTR_LEN);
-       strncpy(drvinfo->version, gfar_driver_version, GFAR_INFOSTR_LEN);
-       strncpy(drvinfo->fw_version, "N/A", GFAR_INFOSTR_LEN);
-       strncpy(drvinfo->bus_info, "N/A", GFAR_INFOSTR_LEN);
-       drvinfo->n_stats = GFAR_STATS_LEN;
-       drvinfo->testinfo_len = 0;
-       drvinfo->regdump_len = 0;
-       drvinfo->eedump_len = 0;
-}
-
-/* Return the current settings in the ethtool_cmd structure */
-int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       uint gigabit_support = 
-               priv->einfo->flags & GFAR_HAS_GIGABIT ? SUPPORTED_1000baseT_Full : 0;
-       uint gigabit_advert = 
-               priv->einfo->flags & GFAR_HAS_GIGABIT ? ADVERTISED_1000baseT_Full: 0;
-
-       cmd->supported = (SUPPORTED_10baseT_Half
-                         | SUPPORTED_100baseT_Half
-                         | SUPPORTED_100baseT_Full
-                         | gigabit_support | SUPPORTED_Autoneg);
-
-       /* For now, we always advertise everything */
-       cmd->advertising = (ADVERTISED_10baseT_Half
-                           | ADVERTISED_100baseT_Half
-                           | ADVERTISED_100baseT_Full
-                           | gigabit_advert | ADVERTISED_Autoneg);
-
-       cmd->speed = priv->speed;
-       cmd->duplex = priv->duplexity;
-       cmd->port = PORT_MII;
-       cmd->phy_address = priv->einfo->phyid;
-       cmd->transceiver = XCVR_EXTERNAL;
-       cmd->autoneg = AUTONEG_ENABLE;
-       cmd->maxtxpkt = priv->txcount;
-       cmd->maxrxpkt = priv->rxcount;
-
-       return 0;
-}
-
-/* Return the length of the register structure */
-int gfar_reglen(struct net_device *dev)
-{
-       return sizeof (struct gfar);
-}
-
-/* Return a dump of the GFAR register space */
-void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
-{
-       int i;
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       u32 *theregs = (u32 *) priv->regs;
-       u32 *buf = (u32 *) regbuf;
-
-       for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++)
-               buf[i] = theregs[i];
-}
-
-/* Return the link state 1 is up, 0 is down */
-u32 gfar_get_link(struct net_device *dev)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       return (u32) priv->link;
-}
-
-/* Fill in a buffer with the strings which correspond to the
- * stats */
-void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf)
-{
-       memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN);
-}
-
-/* Convert microseconds to ethernet clock ticks, which changes
- * depending on what speed the controller is running at */
-static unsigned int gfar_usecs2ticks(struct gfar_private *priv, unsigned int usecs)
-{
-       unsigned int count;
-
-       /* The timer is different, depending on the interface speed */
-       switch (priv->speed) {
-       case 1000:
-               count = GFAR_GBIT_TIME;
-               break;
-       case 100:
-               count = GFAR_100_TIME;
-               break;
-       case 10:
-       default:
-               count = GFAR_10_TIME;
-               break;
-       }
-
-       /* Make sure we return a number greater than 0
-        * if usecs > 0 */
-       return ((usecs * 1000 + count - 1) / count);
-}
-
-/* Convert ethernet clock ticks to microseconds */
-static unsigned int gfar_ticks2usecs(struct gfar_private *priv, unsigned int ticks)
-{
-       unsigned int count;
-
-       /* The timer is different, depending on the interface speed */
-       switch (priv->speed) {
-       case 1000:
-               count = GFAR_GBIT_TIME;
-               break;
-       case 100:
-               count = GFAR_100_TIME;
-               break;
-       case 10:
-       default:
-               count = GFAR_10_TIME;
-               break;
-       }
-
-       /* Make sure we return a number greater than 0 */
-       /* if ticks is > 0 */
-       return ((ticks * count) / 1000);
-}
-
-/* Get the coalescing parameters, and put them in the cvals
- * structure.  */
-int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-
-       cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, priv->rxtime);
-       cvals->rx_max_coalesced_frames = priv->rxcount;
-
-       cvals->tx_coalesce_usecs = gfar_ticks2usecs(priv, priv->txtime);
-       cvals->tx_max_coalesced_frames = priv->txcount;
-
-       cvals->use_adaptive_rx_coalesce = 0;
-       cvals->use_adaptive_tx_coalesce = 0;
-
-       cvals->pkt_rate_low = 0;
-       cvals->rx_coalesce_usecs_low = 0;
-       cvals->rx_max_coalesced_frames_low = 0;
-       cvals->tx_coalesce_usecs_low = 0;
-       cvals->tx_max_coalesced_frames_low = 0;
-
-       /* When the packet rate is below pkt_rate_high but above
-        * pkt_rate_low (both measured in packets per second) the
-        * normal {rx,tx}_* coalescing parameters are used.
-        */
-
-       /* When the packet rate is (measured in packets per second)
-        * is above pkt_rate_high, the {rx,tx}_*_high parameters are
-        * used.
-        */
-       cvals->pkt_rate_high = 0;
-       cvals->rx_coalesce_usecs_high = 0;
-       cvals->rx_max_coalesced_frames_high = 0;
-       cvals->tx_coalesce_usecs_high = 0;
-       cvals->tx_max_coalesced_frames_high = 0;
-
-       /* How often to do adaptive coalescing packet rate sampling,
-        * measured in seconds.  Must not be zero.
-        */
-       cvals->rate_sample_interval = 0;
-
-       return 0;
-}
-
-/* Change the coalescing values.
- * Both cvals->*_usecs and cvals->*_frames have to be > 0
- * in order for coalescing to be active
- */
-int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-
-       /* Set up rx coalescing */
-       if ((cvals->rx_coalesce_usecs == 0) ||
-           (cvals->rx_max_coalesced_frames == 0))
-               priv->rxcoalescing = 0;
-       else
-               priv->rxcoalescing = 1;
-
-       priv->rxtime = gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs);
-       priv->rxcount = cvals->rx_max_coalesced_frames;
-
-       /* Set up tx coalescing */
-       if ((cvals->tx_coalesce_usecs == 0) ||
-           (cvals->tx_max_coalesced_frames == 0))
-               priv->txcoalescing = 0;
-       else
-               priv->txcoalescing = 1;
-
-       priv->txtime = gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs);
-       priv->txcount = cvals->tx_max_coalesced_frames;
-
-       if (priv->rxcoalescing)
-               gfar_write(&priv->regs->rxic,
-                          mk_ic_value(priv->rxcount, priv->rxtime));
-       else
-               gfar_write(&priv->regs->rxic, 0);
-
-       if (priv->txcoalescing)
-               gfar_write(&priv->regs->txic,
-                          mk_ic_value(priv->txcount, priv->txtime));
-       else
-               gfar_write(&priv->regs->txic, 0);
-
-       return 0;
-}
-
-/* Fills in rvals with the current ring parameters.  Currently,
- * rx, rx_mini, and rx_jumbo rings are the same size, as mini and
- * jumbo are ignored by the driver */
-void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-
-       rvals->rx_max_pending = GFAR_RX_MAX_RING_SIZE;
-       rvals->rx_mini_max_pending = GFAR_RX_MAX_RING_SIZE;
-       rvals->rx_jumbo_max_pending = GFAR_RX_MAX_RING_SIZE;
-       rvals->tx_max_pending = GFAR_TX_MAX_RING_SIZE;
-
-       /* Values changeable by the user.  The valid values are
-        * in the range 1 to the "*_max_pending" counterpart above.
-        */
-       rvals->rx_pending = priv->rx_ring_size;
-       rvals->rx_mini_pending = priv->rx_ring_size;
-       rvals->rx_jumbo_pending = priv->rx_ring_size;
-       rvals->tx_pending = priv->tx_ring_size;
-}
-
-/* Change the current ring parameters, stopping the controller if
- * necessary so that we don't mess things up while we're in
- * motion.  We wait for the ring to be clean before reallocating
- * the rings. */
-int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
-{
-       u32 tempval;
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       int err = 0;
-
-       if (rvals->rx_pending > GFAR_RX_MAX_RING_SIZE)
-               return -EINVAL;
-
-       if (!is_power_of_2(rvals->rx_pending)) {
-               printk("%s: Ring sizes must be a power of 2\n",
-                               dev->name);
-               return -EINVAL;
-       }
-
-       if (rvals->tx_pending > GFAR_TX_MAX_RING_SIZE)
-               return -EINVAL;
-
-       if (!is_power_of_2(rvals->tx_pending)) {
-               printk("%s: Ring sizes must be a power of 2\n",
-                               dev->name);
-               return -EINVAL;
-       }
-
-       /* Stop the controller so we don't rx any more frames */
-       /* But first, make sure we clear the bits */
-       tempval = gfar_read(&priv->regs->dmactrl);
-       tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);
-       gfar_write(&priv->regs->dmactrl, tempval);
-
-       tempval = gfar_read(&priv->regs->dmactrl);
-       tempval |= (DMACTRL_GRS | DMACTRL_GTS);
-       gfar_write(&priv->regs->dmactrl, tempval);
-
-       while (!(gfar_read(&priv->regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC)))
-               cpu_relax();
-
-       /* Note that rx is not clean right now */
-       priv->rxclean = 0;
-
-       if (dev->flags & IFF_UP) {
-               /* Tell the driver to process the rest of the frames */
-               gfar_receive(0, (void *) dev, NULL);
-
-               /* Now wait for it to be done */
-               wait_event_interruptible(priv->rxcleanupq, priv->rxclean);
-
-               /* Ok, all packets have been handled.  Now we bring it down,
-                * change the ring size, and bring it up */
-
-               stop_gfar(dev);
-       }
-
-       priv->rx_ring_size = rvals->rx_pending;
-       priv->tx_ring_size = rvals->tx_pending;
-
-       if (dev->flags & IFF_UP)
-               err = startup_gfar(dev);
-
-       return err;
-}
-
-struct ethtool_ops gfar_ethtool_ops = {
-       .get_settings = gfar_gsettings,
-       .get_drvinfo = gfar_gdrvinfo,
-       .get_regs_len = gfar_reglen,
-       .get_regs = gfar_get_regs,
-       .get_link = gfar_get_link,
-       .get_coalesce = gfar_gcoalesce,
-       .set_coalesce = gfar_scoalesce,
-       .get_ringparam = gfar_gringparam,
-       .set_ringparam = gfar_sringparam,
-       .get_strings = gfar_gstrings,
-       .get_stats_count = gfar_stats_count,
-       .get_ethtool_stats = gfar_fill_stats,
-};
diff --git a/drivers/net/gianfar_phy.c b/drivers/net/gianfar_phy.c
deleted file mode 100644 (file)
index ea02e5d..0000000
+++ /dev/null
@@ -1,622 +0,0 @@
-/* 
- * drivers/net/gianfar_phy.c
- *
- * Gianfar Ethernet Driver -- PHY handling
- * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
- * Based on 8260_io/fcc_enet.c
- *
- * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/spinlock.h>
-#include <linux/mm.h>
-#include <linux/mii.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/crc32.h>
-
-#include "gianfar.h"
-#include "gianfar_phy.h"
-
-/* Write value to the PHY for this device to the register at regnum, */
-/* waiting until the write is done before it returns.  All PHY */
-/* configuration has to be done through the TSEC1 MIIM regs */
-void write_phy_reg(struct net_device *dev, u16 regnum, u16 value)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       struct gfar *regbase = priv->phyregs;
-       struct ocp_gfar_data *einfo = priv->einfo;
-
-       /* Set the PHY address and the register address we want to write */
-       gfar_write(&regbase->miimadd, ((einfo->phyid) << 8) | regnum);
-
-       /* Write out the value we want */
-       gfar_write(&regbase->miimcon, value);
-
-       /* Wait for the transaction to finish */
-       while (gfar_read(&regbase->miimind) & MIIMIND_BUSY)
-               cpu_relax();
-}
-
-/* Reads from register regnum in the PHY for device dev, */
-/* returning the value.  Clears miimcom first.  All PHY */
-/* configuration has to be done through the TSEC1 MIIM regs */
-u16 read_phy_reg(struct net_device *dev, u16 regnum)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       struct gfar *regbase = priv->phyregs;
-       struct ocp_gfar_data *einfo = priv->einfo;
-       u16 value;
-
-       /* Set the PHY address and the register address we want to read */
-       gfar_write(&regbase->miimadd, ((einfo->phyid) << 8) | regnum);
-
-       /* Clear miimcom, and then initiate a read */
-       gfar_write(&regbase->miimcom, 0);
-       gfar_write(&regbase->miimcom, MIIM_READ_COMMAND);
-
-       /* Wait for the transaction to finish */
-       while (gfar_read(&regbase->miimind) & (MIIMIND_NOTVALID | MIIMIND_BUSY))
-               cpu_relax();
-
-       /* Grab the value of the register from miimstat */
-       value = gfar_read(&regbase->miimstat);
-
-       return value;
-}
-
-/* returns which value to write to the control register. */
-/* For 10/100 the value is slightly different. */
-u16 mii_cr_init(u16 mii_reg, struct net_device * dev)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       struct ocp_gfar_data *einfo = priv->einfo;
-
-       if (einfo->flags & GFAR_HAS_GIGABIT)
-               return MIIM_CONTROL_INIT;
-       else
-               return MIIM_CR_INIT;
-}
-
-#define BRIEF_GFAR_ERRORS
-/* Wait for auto-negotiation to complete */
-u16 mii_parse_sr(u16 mii_reg, struct net_device * dev)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-
-       unsigned int timeout = GFAR_AN_TIMEOUT;
-
-       if (mii_reg & MIIM_STATUS_LINK)
-               priv->link = 1;
-       else
-               priv->link = 0;
-
-       /* Only auto-negotiate if the link has just gone up */
-       if (priv->link && !priv->oldlink) {
-               while ((!(mii_reg & MIIM_STATUS_AN_DONE)) && timeout--)
-                       mii_reg = read_phy_reg(dev, MIIM_STATUS);
-
-#if defined(BRIEF_GFAR_ERRORS)
-               if (mii_reg & MIIM_STATUS_AN_DONE)
-                       printk(KERN_INFO "%s: Auto-negotiation done\n",
-                              dev->name);
-               else
-                       printk(KERN_INFO "%s: Auto-negotiation timed out\n",
-                              dev->name);
-#endif
-       }
-
-       return 0;
-}
-
-/* Determine the speed and duplex which was negotiated */
-u16 mii_parse_88E1011_psr(u16 mii_reg, struct net_device * dev)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       unsigned int speed;
-
-       if (priv->link) {
-               if (mii_reg & MIIM_88E1011_PHYSTAT_DUPLEX)
-                       priv->duplexity = 1;
-               else
-                       priv->duplexity = 0;
-
-               speed = (mii_reg & MIIM_88E1011_PHYSTAT_SPEED);
-
-               switch (speed) {
-               case MIIM_88E1011_PHYSTAT_GBIT:
-                       priv->speed = 1000;
-                       break;
-               case MIIM_88E1011_PHYSTAT_100:
-                       priv->speed = 100;
-                       break;
-               default:
-                       priv->speed = 10;
-                       break;
-               }
-       } else {
-               priv->speed = 0;
-               priv->duplexity = 0;
-       }
-
-       return 0;
-}
-
-u16 mii_parse_cis8201(u16 mii_reg, struct net_device * dev)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       unsigned int speed;
-
-       if (priv->link) {
-               if (mii_reg & MIIM_CIS8201_AUXCONSTAT_DUPLEX)
-                       priv->duplexity = 1;
-               else
-                       priv->duplexity = 0;
-
-               speed = mii_reg & MIIM_CIS8201_AUXCONSTAT_SPEED;
-
-               switch (speed) {
-               case MIIM_CIS8201_AUXCONSTAT_GBIT:
-                       priv->speed = 1000;
-                       break;
-               case MIIM_CIS8201_AUXCONSTAT_100:
-                       priv->speed = 100;
-                       break;
-               default:
-                       priv->speed = 10;
-                       break;
-               }
-       } else {
-               priv->speed = 0;
-               priv->duplexity = 0;
-       }
-
-       return 0;
-}
-
-u16 mii_parse_dm9161_scsr(u16 mii_reg, struct net_device * dev)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-
-       if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_100H))
-               priv->speed = 100;
-       else
-               priv->speed = 10;
-
-       if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_10F))
-               priv->duplexity = 1;
-       else
-               priv->duplexity = 0;
-
-       return 0;
-}
-
-u16 dm9161_wait(u16 mii_reg, struct net_device *dev)
-{
-       int timeout = HZ;
-       int secondary = 10;
-       u16 temp;
-
-       do {
-
-               /* Davicom takes a bit to come up after a reset,
-                * so wait here for a bit */
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(timeout);
-
-               temp = read_phy_reg(dev, MIIM_STATUS);
-
-               secondary--;
-       } while ((!(temp & MIIM_STATUS_AN_DONE)) && secondary);
-
-       return 0;
-}
-
-/*
- * consult the BCM54xx auxilliary status register to find the link settings
- */
-u16 mii_parse_bcm54xx_sr(u16 mii_reg, struct net_device * dev)
-{
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-
-       /* Link modes of the BCM5400 PHY */
-       static const uint16_t link_table[8][3] = {
-               { 0, 0          },      /* No link */
-               { 0, 10         },      /* 10BT Half Duplex */
-               { 1, 10         },      /* 10BT Full Duplex */
-               { 0, 100        },      /* 100BT Half Duplex */
-               { 0, 100        },      /* 100BT Half Duplex */
-               { 1, 100        },      /* 100BT Full Duplex*/
-               { 1, 1000       },      /* 1000BT */
-               { 1, 1000       },      /* 1000BT */
-       };
-
-       uint16_t link_mode;
-
-       link_mode = mii_reg & MIIM_BCM54xx_AUXSTATUS_LINKMODE_MASK;
-       link_mode >>= MIIM_BCM54xx_AUXSTATUS_LINKMODE_SHIFT;
-
-       priv->duplexity = link_table[link_mode][0];
-       priv->speed = link_table[link_mode][1];
-
-       return 0;
-}
-
-static struct phy_info phy_info_M88E1011S = {
-       0x01410c6,
-       "Marvell 88E1011S",
-       4,
-       (const struct phy_cmd[]) {      /* config */
-               /* Reset and configure the PHY */
-               {MIIM_CONTROL, MIIM_CONTROL_INIT, mii_cr_init},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* startup */
-               /* Status is read once to clear old link state */
-               {MIIM_STATUS, miim_read, NULL},
-               /* Auto-negotiate */
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               /* Read the status */
-               {MIIM_88E1011_PHY_STATUS, miim_read, mii_parse_88E1011_psr},
-               /* Clear the IEVENT register */
-               {MIIM_88E1011_IEVENT, miim_read, NULL},
-               /* Set up the mask */
-               {MIIM_88E1011_IMASK, MIIM_88E1011_IMASK_INIT, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* ack_int */
-               /* Clear the interrupt */
-               {MIIM_88E1011_IEVENT, miim_read, NULL},
-               /* Disable interrupts */
-               {MIIM_88E1011_IMASK, MIIM_88E1011_IMASK_CLEAR, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* handle_int */
-               /* Read the Status (2x to make sure link is right) */
-               {MIIM_STATUS, miim_read, NULL},
-               /* Check the status */
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               {MIIM_88E1011_PHY_STATUS, miim_read, mii_parse_88E1011_psr},
-                       /* Enable Interrupts */
-               {MIIM_88E1011_IMASK, MIIM_88E1011_IMASK_INIT, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* shutdown */
-               {MIIM_88E1011_IEVENT, miim_read, NULL},
-               {MIIM_88E1011_IMASK, MIIM_88E1011_IMASK_CLEAR, NULL},
-               {miim_end,}
-       },
-};
-
-/* Cicada 8204 */
-static struct phy_info phy_info_cis8204 = {
-       0x3f11,
-       "Cicada Cis8204",
-       6,
-       (const struct phy_cmd[]) {      /* config */
-               /* Override PHY config settings */
-               {MIIM_CIS8201_AUX_CONSTAT, MIIM_CIS8201_AUXCONSTAT_INIT, NULL},
-               /* Set up the interface mode */
-               {MIIM_CIS8201_EXT_CON1, MIIM_CIS8201_EXTCON1_INIT, NULL},
-               /* Configure some basic stuff */
-               {MIIM_CONTROL, MIIM_CONTROL_INIT, mii_cr_init},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* startup */
-               /* Read the Status (2x to make sure link is right) */
-               {MIIM_STATUS, miim_read, NULL},
-               /* Auto-negotiate */
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               /* Read the status */
-               {MIIM_CIS8201_AUX_CONSTAT, miim_read, mii_parse_cis8201},
-               /* Clear the status register */
-               {MIIM_CIS8204_ISTAT, miim_read, NULL},
-               /* Enable interrupts */
-               {MIIM_CIS8204_IMASK, MIIM_CIS8204_IMASK_MASK, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* ack_int */
-               /* Clear the status register */
-               {MIIM_CIS8204_ISTAT, miim_read, NULL},
-               /* Disable interrupts */
-               {MIIM_CIS8204_IMASK, 0x0, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* handle_int */
-               /* Read the Status (2x to make sure link is right) */
-               {MIIM_STATUS, miim_read, NULL},
-               /* Auto-negotiate */
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               /* Read the status */
-               {MIIM_CIS8201_AUX_CONSTAT, miim_read, mii_parse_cis8201},
-               /* Enable interrupts */
-               {MIIM_CIS8204_IMASK, MIIM_CIS8204_IMASK_MASK, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* shutdown */
-               /* Clear the status register */
-               {MIIM_CIS8204_ISTAT, miim_read, NULL},
-               /* Disable interrupts */
-               {MIIM_CIS8204_IMASK, 0x0, NULL},
-               {miim_end,}
-       },
-};
-
-/* Cicada 8201 */
-static struct phy_info phy_info_cis8201 = {
-       0xfc41,
-       "CIS8201",
-       4,
-       (const struct phy_cmd[]) {      /* config */
-               /* Override PHY config settings */
-               {MIIM_CIS8201_AUX_CONSTAT, MIIM_CIS8201_AUXCONSTAT_INIT, NULL},
-               /* Set up the interface mode */
-               {MIIM_CIS8201_EXT_CON1, MIIM_CIS8201_EXTCON1_INIT, NULL},
-               /* Configure some basic stuff */
-               {MIIM_CONTROL, MIIM_CONTROL_INIT, mii_cr_init},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* startup */
-               /* Read the Status (2x to make sure link is right) */
-               {MIIM_STATUS, miim_read, NULL},
-               /* Auto-negotiate */
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               /* Read the status */
-               {MIIM_CIS8201_AUX_CONSTAT, miim_read, mii_parse_cis8201},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* ack_int */
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* handle_int */
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* shutdown */
-               {miim_end,}
-       },
-};
-
-static struct phy_info phy_info_dm9161 = {
-       0x0181b88,
-       "Davicom DM9161E",
-       4,
-       (const struct phy_cmd[]) {      /* config */
-               {MIIM_CONTROL, MIIM_DM9161_CR_STOP, NULL},
-               /* Do not bypass the scrambler/descrambler */
-               {MIIM_DM9161_SCR, MIIM_DM9161_SCR_INIT, NULL},
-               /* Clear 10BTCSR to default */
-               {MIIM_DM9161_10BTCSR, MIIM_DM9161_10BTCSR_INIT, NULL},
-               /* Configure some basic stuff */
-               {MIIM_CONTROL, MIIM_CR_INIT, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* startup */
-               /* Restart Auto Negotiation */
-               {MIIM_CONTROL, MIIM_DM9161_CR_RSTAN, NULL},
-               /* Status is read once to clear old link state */
-               {MIIM_STATUS, miim_read, dm9161_wait},
-               /* Auto-negotiate */
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               /* Read the status */
-               {MIIM_DM9161_SCSR, miim_read, mii_parse_dm9161_scsr},
-               /* Clear any pending interrupts */
-               {MIIM_DM9161_INTR, miim_read, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* ack_int */
-               {MIIM_DM9161_INTR, miim_read, NULL},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* handle_int */
-               {MIIM_STATUS, miim_read, NULL},
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               {MIIM_DM9161_SCSR, miim_read, mii_parse_dm9161_scsr},
-               {miim_end,}
-       },
-       (const struct phy_cmd[]) {      /* shutdown */
-               {MIIM_DM9161_INTR, miim_read, NULL},
-               {miim_end,}
-       },
-};
-
-/* Broadcom BCM5421S PHY */
-static struct phy_info phy_info_bcm5421s = {
-       .id = 0x2060E1,
-       .name = "Broadcom BCM5421S",
-       .shift = 0,
-       .config = (const struct phy_cmd[]) {
-               /* Configure some basic stuff */
-               {MIIM_CONTROL, MIIM_CR_INIT, NULL},
-#if 0 /* 5421 only */
-               miim_write(MII_BCM5400_AUXCONTROL, 0x1007),
-               miim_set_bits(MII_BCM5400_AUXCONTROL, 0x0400),
-               miim_write(MII_BCM5400_AUXCONTROL, 0x0007),
-               miim_set_bits(MII_BCM5400_AUXCONTROL, 0x0800),
-               miim_write(0x17, 0x000a),
-               miim_set_bits(MII_RERRCOUNTER, 0x0200),
-#endif
-#if 0 /* enable automatic low power */
-               miim_write(MII_NCONFIG, 0x9002),
-               miim_write(MII_NCONFIG, 0xa821),
-               miim_write(MII_NCONFIG, 0x941d),
-#endif
-               {miim_end,}
-       },
-       .startup = (const struct phy_cmd[]) {
-               /* Restart Auto Negotiation */
-               miim_set_bits(MIIM_CONTROL, BMCR_ANENABLE | BMCR_ANRESTART),
-#if 0
-               /* Status is read once to clear old link state */
-               {MIIM_STATUS, miim_read, dm9161_wait},
-#endif
-               /* Auto-negotiate */
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-
-               /* Read the link status */
-               {MIIM_BCM54xx_AUXSTATUS, miim_read, mii_parse_bcm54xx_sr},
-
-               {miim_end,}
-       },
-       .ack_int = (const struct phy_cmd[]) {
-               {miim_end,}
-       },
-       .handle_int = (const struct phy_cmd[]) {
-               {MIIM_STATUS, miim_read, NULL},
-               {MIIM_STATUS, miim_read, mii_parse_sr},
-               {miim_end,}
-       },
-       .shutdown = (const struct phy_cmd[]) {
-               {miim_end,}
-       },
-};
-
-static struct phy_info *phy_info[] = {
-       &phy_info_cis8201,
-       &phy_info_cis8204,
-       &phy_info_M88E1011S,
-       &phy_info_dm9161,
-       &phy_info_bcm5421s,
-       NULL
-};
-
-/* Use the PHY ID registers to determine what type of PHY is attached
- * to device dev.  return a struct phy_info structure describing that PHY
- */
-struct phy_info * get_phy_info(struct net_device *dev)
-{
-       u16 phy_reg;
-       u32 phy_ID;
-       int i;
-       struct phy_info *theInfo = NULL;
-
-       /* Grab the bits from PHYIR1, and put them in the upper half */
-       phy_reg = read_phy_reg(dev, MIIM_PHYIR1);
-       phy_ID = (phy_reg & 0xffff) << 16;
-
-       /* Grab the bits from PHYIR2, and put them in the lower half */
-       phy_reg = read_phy_reg(dev, MIIM_PHYIR2);
-       phy_ID |= (phy_reg & 0xffff);
-
-       /* loop through all the known PHY types, and find one that */
-       /* matches the ID we read from the PHY. */
-       for (i = 0; phy_info[i]; i++)
-               if (phy_info[i]->id == (phy_ID >> phy_info[i]->shift))
-                       theInfo = phy_info[i];
-
-       if (theInfo == NULL) {
-               printk("%s: PHY id %x is not supported!\n", dev->name, phy_ID);
-               return NULL;
-       } else {
-               printk("%s: PHY is %s (%x)\n", dev->name, theInfo->name,
-                      phy_ID);
-       }
-
-       return theInfo;
-}
-
-/* Take a list of struct phy_cmd, and, depending on the values, either */
-/* read or write, using a helper function if provided */
-/* It is assumed that all lists of struct phy_cmd will be terminated by */
-/* mii_end. */
-void phy_run_commands(struct net_device *dev, const struct phy_cmd *cmd)
-{
-       int i;
-       u16 result;
-       struct gfar_private *priv = (struct gfar_private *) dev->priv;
-       struct gfar *phyregs = priv->phyregs;
-
-       /* Reset the management interface */
-       gfar_write(&phyregs->miimcfg, MIIMCFG_RESET);
-
-       /* Setup the MII Mgmt clock speed */
-       gfar_write(&phyregs->miimcfg, MIIMCFG_INIT_VALUE);
-
-       /* Wait until the bus is free */
-       while (gfar_read(&phyregs->miimind) & MIIMIND_BUSY)
-               cpu_relax();
-
-       for (i = 0; cmd->mii_reg != miim_end; i++) {
-               switch (cmd->mii_data >> 16) {
-               case 0x0000:
-                       /* Otherwise, it's a write */
-                       /* If a function was supplied, it will provide 
-                        * the value to write */
-                       /* Otherwise, the value was supplied in cmd->mii_data */
-                       if (cmd->funct != NULL)
-                               result = (*(cmd->funct)) (0, dev);
-                       else
-                               result = cmd->mii_data;
-
-                       write_phy_reg(dev, cmd->mii_reg, result);
-                       break;
-
-               case 0x0001:
-                       /* Read the value of the PHY reg */
-                       result = read_phy_reg(dev, cmd->mii_reg);
-
-                       /* If a function was supplied, we need to let it process */
-                       /* the result. */
-                       if (cmd->funct != NULL)
-                               (*(cmd->funct)) (result, dev);
-                       break;
-
-               case 0x0002:
-                       /* read the value, clear some bits and write it back */
-                       BUG_ON(cmd->funct);
-
-                       result = read_phy_reg(dev, cmd->mii_reg);
-                       result &= cmd->mii_data;
-                       write_phy_reg(dev, cmd->mii_reg, result);
-                       break;
-
-               case 0x0003:
-                       /* read the value, set some bits and write it back */
-                       BUG_ON(cmd->funct);
-
-                       result = read_phy_reg(dev, cmd->mii_reg);
-                       result &= cmd->mii_data;
-                       write_phy_reg(dev, cmd->mii_reg, result);
-                       break;
-
-               case 0x0004:
-                       /* read the value, flip some bits and write it back */
-                       BUG_ON(cmd->funct);
-
-                       result = read_phy_reg(dev, cmd->mii_reg);
-                       result &= cmd->mii_data;
-                       write_phy_reg(dev, cmd->mii_reg, result);
-                       break;
-
-               default:
-                       printk("GIANFAR: Unknown MII command %08x\n",
-                              cmd->mii_data);
-                       BUG();
-               }
-               cmd++;
-       }
-}
diff --git a/drivers/net/gianfar_phy.h b/drivers/net/gianfar_phy.h
deleted file mode 100644 (file)
index df4c0ec..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/* 
- * drivers/net/gianfar_phy.h
- *
- * Gianfar Ethernet Driver -- PHY handling
- * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
- * Based on 8260_io/fcc_enet.c
- *
- * Author: Andy Fleming
- * Maintainer: Kumar Gala (kumar.gala@freescale.com)
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-#ifndef __GIANFAR_PHY_H
-#define __GIANFAR_PHY_H
-
-/* simple datum processing commands */
-#define miim_end               (0xffff0000U)
-#define miim_read              (0x00010000U)
-#define miim_clear_bits(reg,x) { reg, (0x00020000U | ~(u32)(x)), NULL }
-#define miim_set_bits(reg,x)   { reg, (0x00030000U | (u32)(x)),  NULL }
-#define miim_flip_bits(reg,x)  { reg, (0x00040000U | (u32)(x)),  NULL }
-#define miim_write(reg, x)     { reg, (0x0000ffffU & (u32)(x)),  NULL }
-
-#define MIIMIND_BUSY            0x00000001
-#define MIIMIND_NOTVALID        0x00000004
-
-#define MIIM_CONTROL           0x00
-#define MIIM_CONTROL_RESET     0x00008000
-#define MIIM_CONTROL_INIT      0x00001140
-#define MIIM_ANEN              0x00001000
-
-#define MIIM_CR                 0x00
-#define MIIM_CR_RST            0x00008000
-#define MIIM_CR_INIT           0x00001000
-
-#define MIIM_STATUS            0x1
-#define MIIM_STATUS_AN_DONE    0x00000020
-#define MIIM_STATUS_LINK       0x0004
-
-#define MIIM_PHYIR1            0x2
-#define MIIM_PHYIR2            0x3
-
-#define GFAR_AN_TIMEOUT         0x000fffff
-
-#define MIIM_ANLPBPA   0x5
-#define MIIM_ANLPBPA_HALF      0x00000040
-#define MIIM_ANLPBPA_FULL      0x00000020
-
-#define MIIM_ANEX              0x6
-#define MIIM_ANEX_NP           0x00000004
-#define MIIM_ANEX_PRX          0x00000002
-
-
-/* Cicada Extended Control Register 1 */
-#define MIIM_CIS8201_EXT_CON1           0x17
-#define MIIM_CIS8201_EXTCON1_INIT       0x0000
-
-/* Cicada Interrupt Mask Register */
-#define MIIM_CIS8204_IMASK             0x19
-#define MIIM_CIS8204_IMASK_IEN         0x8000
-#define MIIM_CIS8204_IMASK_SPEED       0x4000
-#define MIIM_CIS8204_IMASK_LINK                0x2000
-#define MIIM_CIS8204_IMASK_DUPLEX      0x1000
-#define MIIM_CIS8204_IMASK_MASK                0xf000
-
-/* Cicada Interrupt Status Register */
-#define MIIM_CIS8204_ISTAT             0x1a
-#define MIIM_CIS8204_ISTAT_STATUS      0x8000
-#define MIIM_CIS8204_ISTAT_SPEED       0x4000
-#define MIIM_CIS8204_ISTAT_LINK                0x2000
-#define MIIM_CIS8204_ISTAT_DUPLEX      0x1000
-
-/* Cicada Auxiliary Control/Status Register */
-#define MIIM_CIS8201_AUX_CONSTAT        0x1c
-#define MIIM_CIS8201_AUXCONSTAT_INIT    0x0004
-#define MIIM_CIS8201_AUXCONSTAT_DUPLEX  0x0020
-#define MIIM_CIS8201_AUXCONSTAT_SPEED   0x0018
-#define MIIM_CIS8201_AUXCONSTAT_GBIT    0x0010
-#define MIIM_CIS8201_AUXCONSTAT_100     0x0008
-                                                                                
-/* 88E1011 PHY Status Register */
-#define MIIM_88E1011_PHY_STATUS         0x11
-#define MIIM_88E1011_PHYSTAT_SPEED      0xc000
-#define MIIM_88E1011_PHYSTAT_GBIT       0x8000
-#define MIIM_88E1011_PHYSTAT_100        0x4000
-#define MIIM_88E1011_PHYSTAT_DUPLEX     0x2000
-#define MIIM_88E1011_PHYSTAT_LINK      0x0400
-
-#define MIIM_88E1011_IEVENT            0x13
-#define MIIM_88E1011_IEVENT_CLEAR      0x0000
-
-#define MIIM_88E1011_IMASK             0x12
-#define MIIM_88E1011_IMASK_INIT                0x6400
-#define MIIM_88E1011_IMASK_CLEAR       0x0000
-
-/* DM9161 Control register values */
-#define MIIM_DM9161_CR_STOP    0x0400
-#define MIIM_DM9161_CR_RSTAN   0x1200
-
-#define MIIM_DM9161_SCR                0x10
-#define MIIM_DM9161_SCR_INIT   0x0610
-
-/* DM9161 Specified Configuration and Status Register */
-#define MIIM_DM9161_SCSR       0x11
-#define MIIM_DM9161_SCSR_100F  0x8000
-#define MIIM_DM9161_SCSR_100H  0x4000
-#define MIIM_DM9161_SCSR_10F   0x2000
-#define MIIM_DM9161_SCSR_10H   0x1000
-
-/* DM9161 Interrupt Register */
-#define MIIM_DM9161_INTR       0x15
-#define MIIM_DM9161_INTR_PEND          0x8000
-#define MIIM_DM9161_INTR_DPLX_MASK     0x0800
-#define MIIM_DM9161_INTR_SPD_MASK      0x0400
-#define MIIM_DM9161_INTR_LINK_MASK     0x0200
-#define MIIM_DM9161_INTR_MASK          0x0100
-#define MIIM_DM9161_INTR_DPLX_CHANGE   0x0010
-#define MIIM_DM9161_INTR_SPD_CHANGE    0x0008
-#define MIIM_DM9161_INTR_LINK_CHANGE   0x0004
-#define MIIM_DM9161_INTR_INIT          0x0000
-#define MIIM_DM9161_INTR_STOP  \
-(MIIM_DM9161_INTR_DPLX_MASK | MIIM_DM9161_INTR_SPD_MASK \
- | MIIM_DM9161_INTR_LINK_MASK | MIIM_DM9161_INTR_MASK)
-
-/* DM9161 10BT Configuration/Status */
-#define MIIM_DM9161_10BTCSR    0x12
-#define MIIM_DM9161_10BTCSR_INIT       0x7800
-
-/* BCM54xx regs */
-#define MIIM_BCM54xx_AUXCONTROL        0x18
-#define MIIM_BCM54xx_AUXSTATUS 0x19
-#define MIIM_BCM54xx_AUXSTATUS_LINKMODE_MASK     0x0700
-#define MIIM_BCM54xx_AUXSTATUS_LINKMODE_SHIFT    8  
-
-#define MIIM_READ_COMMAND       0x00000001
-
-/*
- * struct phy_cmd:  A command for reading or writing a PHY register
- *
- * mii_reg:  The register to read or write
- *
- * mii_data:  For writes, the value to put in the register.
- *     A value of -1 indicates this is a read.
- *
- * funct: A function pointer which is invoked for each command.
- *     For reads, this function will be passed the value read
- *     from the PHY, and process it.
- *     For writes, the result of this function will be written
- *     to the PHY register
- */
-struct phy_cmd {
-    u32 mii_reg;
-    u32 mii_data;
-    u16 (*funct) (u16 mii_reg, struct net_device * dev);
-};
-
-/* struct phy_info: a structure which defines attributes for a PHY
- *
- * id will contain a number which represents the PHY.  During
- * startup, the driver will poll the PHY to find out what its
- * UID--as defined by registers 2 and 3--is.  The 32-bit result
- * gotten from the PHY will be shifted right by "shift" bits to
- * discard any bits which may change based on revision numbers
- * unimportant to functionality
- *
- * The struct phy_cmd entries represent pointers to an arrays of
- * commands which tell the driver what to do to the PHY.
- */
-struct phy_info {
-    u32 id;
-    char *name;
-    unsigned int shift;
-    /* Called to configure the PHY, and modify the controller
-     * based on the results */
-    const struct phy_cmd *config;
-
-    /* Called when starting up the controller.  Usually sets
-     * up the interrupt for state changes */
-    const struct phy_cmd *startup;
-
-    /* Called inside the interrupt handler to acknowledge
-     * the interrupt */
-    const struct phy_cmd *ack_int;
-
-    /* Called in the bottom half to handle the interrupt */
-    const struct phy_cmd *handle_int;
-
-    /* Called when bringing down the controller.  Usually stops
-     * the interrupts from being generated */
-    const struct phy_cmd *shutdown;
-};
-
-struct phy_info *get_phy_info(struct net_device *dev);
-void phy_run_commands(struct net_device *dev, const struct phy_cmd *cmd);
-
-#endif /* GIANFAR_PHY_H */
diff --git a/drivers/net/ne2k_cbus.c b/drivers/net/ne2k_cbus.c
deleted file mode 100644 (file)
index 4fc68d9..0000000
+++ /dev/null
@@ -1,887 +0,0 @@
-/*
-
-  ne2k_cbus.c: A driver for the NE2000 like ethernet on NEC PC-9800.
-
-       This is a copy of the 2.5.66 Linux ISA NE2000 driver "ne.c" 
-       (Donald Becker/Paul Gortmaker) with the NEC PC-9800 specific
-       changes added by Osamu Tomita. 
-
-From ne.c:
------------
-    Copyright 1993 United States Government as represented by the
-    Director, National Security Agency.
-
-    This software may be used and distributed according to the terms
-    of the GNU General Public License, incorporated herein by reference.
------------
-
-*/
-
-/* Routines for the NatSemi-based designs (NE[12]000). */
-
-static const char version[] =
-"ne2k_cbus.c:v1.0 3/24/03 Osamu Tomita\n";
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/isapnp.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-
-#include "8390.h"
-
-/* Some defines that people can play with if so inclined. */
-
-/* Do we support clones that don't adhere to 14,15 of the SAprom ? */
-#define SUPPORT_NE_BAD_CLONES
-
-/* Do we perform extra sanity checks on stuff ? */
-/* #define NE_SANITY_CHECK */
-
-/* Do we implement the read before write bugfix ? */
-/* #define NE_RW_BUGFIX */
-
-/* Do we have a non std. amount of memory? (in units of 256 byte pages) */
-/* #define PACKETBUF_MEMSIZE   0x40 */
-
-#ifdef SUPPORT_NE_BAD_CLONES
-/* A list of bad clones that we none-the-less recognize. */
-static struct { const char *name8, *name16; unsigned char SAprefix[4];}
-bad_clone_list[] __initdata = {
-    {"LA/T-98?", "LA/T-98", {0x00, 0xa0, 0xb0}},       /* I/O Data */
-    {"EGY-98?", "EGY-98", {0x00, 0x40, 0x26}},         /* Melco EGY98 */
-    {"ICM?", "ICM-27xx-ET", {0x00, 0x80, 0xc8}},       /* ICM IF-27xx-ET */
-    {"CNET-98/EL?", "CNET(98)E/L", {0x00, 0x80, 0x4C}},        /* Contec CNET-98/EL */
-    {0,}
-};
-#endif
-
-/* ---- No user-serviceable parts below ---- */
-
-#define NE_BASE         (dev->base_addr)
-#define NE_CMD         EI_SHIFT(0x00)
-#define NE_DATAPORT    EI_SHIFT(0x10)  /* NatSemi-defined port window offset. */
-#define NE_RESET       EI_SHIFT(0x1f) /* Issue a read to reset, a write to clear. */
-#define NE_IO_EXTENT   0x20
-
-#define NE1SM_START_PG 0x20    /* First page of TX buffer */
-#define NE1SM_STOP_PG  0x40    /* Last page +1 of RX ring */
-#define NESM_START_PG  0x40    /* First page of TX buffer */
-#define NESM_STOP_PG   0x80    /* Last page +1 of RX ring */
-
-#include "ne2k_cbus.h"
-
-static int ne_probe1(struct net_device *dev, int ioaddr);
-static int ne_open(struct net_device *dev);
-static int ne_close(struct net_device *dev);
-
-static void ne_reset_8390(struct net_device *dev);
-static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
-                         int ring_page);
-static void ne_block_input(struct net_device *dev, int count,
-                         struct sk_buff *skb, int ring_offset);
-static void ne_block_output(struct net_device *dev, const int count,
-               const unsigned char *buf, const int start_page);
-
-\f
-/*  Probe for various non-shared-memory ethercards.
-
-   NEx000-clone boards have a Station Address PROM (SAPROM) in the packet
-   buffer memory space.  NE2000 clones have 0x57,0x57 in bytes 0x0e,0x0f of
-   the SAPROM, while other supposed NE2000 clones must be detected by their
-   SA prefix.
-
-   Reading the SAPROM from a word-wide card with the 8390 set in byte-wide
-   mode results in doubled values, which can be detected and compensated for.
-
-   The probe is also responsible for initializing the card and filling
-   in the 'dev' and 'ei_status' structures.
-
-   We use the minimum memory size for some ethercard product lines, iff we can't
-   distinguish models.  You can increase the packet buffer size by setting
-   PACKETBUF_MEMSIZE.  Reported Cabletron packet buffer locations are:
-       E1010   starts at 0x100 and ends at 0x2000.
-       E1010-x starts at 0x100 and ends at 0x8000. ("-x" means "more memory")
-       E2010    starts at 0x100 and ends at 0x4000.
-       E2010-x starts at 0x100 and ends at 0xffff.  */
-
-static int __init do_ne_probe(struct net_device *dev)
-{
-       unsigned int base_addr = dev->base_addr;
-       int irq = dev->irq;
-
-       SET_MODULE_OWNER(dev);
-
-       if (ei_debug > 2)
-               printk(KERN_DEBUG "ne_probe(): entered.\n");
-
-       /* If CONFIG_NET_CBUS,
-          we need dev->priv->reg_offset BEFORE to probe */
-       if (ne2k_cbus_init(dev) != 0)
-               return -ENOMEM;
-
-       /* First check any supplied i/o locations. User knows best. <cough> */
-       if (base_addr > 0) {
-               int result;
-               const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-
-               if (ei_debug > 2)
-                       printk(KERN_DEBUG "ne_probe(): call ne_probe_cbus(base_addr=0x%x)\n", base_addr);
-
-               result = ne_probe_cbus(dev, hw, base_addr, irq);
-               if (result != 0)
-                       ne2k_cbus_destroy(dev);
-
-               return result;
-       }
-
-       if (ei_debug > 2)
-               printk(KERN_DEBUG "ne_probe(): base_addr is not specified.\n");
-
-#ifndef MODULE
-       /* Last resort. The semi-risky C-Bus auto-probe. */
-       if (ei_debug > 2)
-               printk(KERN_DEBUG "ne_probe(): auto-probe start.\n");
-
-       {
-               const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-
-               if (hw && hw->hwtype) {
-                       const unsigned short *plist;
-                       for (plist = hw->portlist; *plist; plist++)
-                               if (ne_probe_cbus(dev, hw, *plist, irq) == 0)
-                                       return 0;
-               } else {
-                       for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) {
-                               const unsigned short *plist;
-                               for (plist = hw->portlist; *plist; plist++)
-                                       if (ne_probe_cbus(dev, hw, *plist, irq) == 0)
-                                               return 0;
-                       }
-               }
-       }
-#endif
-
-       ne2k_cbus_destroy(dev);
-
-       return -ENODEV;
-}
-
-static void cleanup_card(struct net_device *dev)
-{
-       const struct ne2k_cbus_region *rlist;
-       const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-
-       free_irq(dev->irq, dev);
-       for (rlist = hw->regionlist; rlist->range; rlist++) {
-               release_region(dev->base_addr + rlist->start,
-                               rlist->range);
-       }
-       ne2k_cbus_destroy(dev);
-}
-
-struct net_device * __init ne_probe(int unit)
-{
-       struct net_device *dev = alloc_ei_netdev();
-       int err;
-
-       if (!dev)
-               return ERR_PTR(-ENOMEM);
-
-       sprintf(dev->name, "eth%d", unit);
-       netdev_boot_setup_check(dev);
-
-       err = do_ne_probe(dev);
-       if (err)
-               goto out;
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
-       return dev;
-out1:
-       cleanup_card(dev);
-out:
-       free_netdev(dev);
-       return ERR_PTR(err);
-}
-
-static int __init ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr, int irq)
-{
-       if (ei_debug > 2)
-               printk(KERN_DEBUG "ne_probe_cbus(): entered. (called from %p)\n",
-                      __builtin_return_address(0));
-
-       if (hw && hw->hwtype) {
-               ne2k_cbus_set_hwtype(dev, hw, ioaddr);
-               dev->irq = irq;
-               return ne_probe1(dev, ioaddr);
-       } else {
-               /* auto detect */
-
-               printk(KERN_DEBUG "ne_probe_cbus(): try to determine hardware types.\n");
-               for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) {
-                       ne2k_cbus_set_hwtype(dev, hw, ioaddr);
-                       dev->irq = irq;
-                       if (ne_probe1(dev, ioaddr) == 0)
-                               return 0;
-               }
-       }
-       return -ENODEV;
-}
-
-static int __init ne_probe1(struct net_device *dev, int ioaddr)
-{
-       int i;
-       unsigned char SA_prom[32];
-       int wordlength = 2;
-       const char *name = NULL;
-       int start_page, stop_page;
-       int neX000, bad_card;
-       int reg0, ret;
-       static unsigned version_printed;
-       const struct ne2k_cbus_region *rlist;
-       const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-       if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) {
-               outb_p(0, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE);
-               /* udelay(5000);        */
-               outb_p(1, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE);
-               /* udelay(5000);        */
-               outb_p((ioaddr & 0xf000) >> 8 | 0x08 | 0x01, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE + 2);
-               /* udelay(5000); */
-       }
-#endif
-
-       for (rlist = hw->regionlist; rlist->range; rlist++)
-               if (!request_region(ioaddr + rlist->start,
-                                       rlist->range, dev->name)) {
-                       ret = -EBUSY;
-                       goto err_out;
-               }
-
-       reg0 = inb_p(ioaddr + EI_SHIFT(0));
-       if (reg0 == 0xFF) {
-               ret = -ENODEV;
-               goto err_out;
-       }
-
-       /* Do a preliminary verification that we have a 8390. */
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-       if (hw->hwtype != NE2K_CBUS_HARDWARE_TYPE_CNET98EL)
-#endif
-       {
-               int regd;
-               outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);
-               regd = inb_p(ioaddr + EI_SHIFT(0x0d));
-               outb_p(0xff, ioaddr + EI_SHIFT(0x0d));
-               outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD);
-               inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */
-               if (inb_p(ioaddr + EN0_COUNTER0) != 0) {
-                       outb_p(reg0, ioaddr);
-                       outb_p(regd, ioaddr + EI_SHIFT(0x0d));  /* Restore the old values. */
-                       ret = -ENODEV;
-                       goto err_out;
-               }
-       }
-
-       if (ei_debug  &&  version_printed++ == 0)
-               printk(KERN_INFO "%s", version);
-
-       printk(KERN_INFO "NE*000 ethercard probe at %#3x:", ioaddr);
-
-       /* A user with a poor card that fails to ack the reset, or that
-          does not have a valid 0x57,0x57 signature can still use this
-          without having to recompile. Specifying an i/o address along
-          with an otherwise unused dev->mem_end value of "0xBAD" will
-          cause the driver to skip these parts of the probe. */
-
-       bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad));
-
-       /* Reset card. Who knows what dain-bramaged state it was left in. */
-
-       {
-               unsigned long reset_start_time = jiffies;
-
-               /* derived from CNET98EL-patch for bad clones */
-               outb_p(E8390_NODMA | E8390_STOP, ioaddr + E8390_CMD);
-
-               /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
-               outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
-
-               while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
-               if (jiffies - reset_start_time > 2*HZ/100) {
-                       if (bad_card) {
-                               printk(" (warning: no reset ack)");
-                               break;
-                       } else {
-                               printk(" not found (no reset ack).\n");
-                               ret = -ENODEV;
-                               goto err_out;
-                       }
-               }
-
-               outb_p(0xff, ioaddr + EN0_ISR);         /* Ack all intr. */
-       }
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-       if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) {
-               static const char pat[32] ="AbcdeFghijKlmnoPqrstUvwxyZ789012";
-               char buf[32];
-               int maxwait = 200;
-
-               if (ei_debug > 2)
-                       printk(" [CNET98EL-specific initialize...");
-               outb_p(E8390_NODMA | E8390_STOP, ioaddr + E8390_CMD); /* 0x20|0x1 */
-               ret = -ENODEV;
-               i = inb(ioaddr);
-               if ((i & ~0x2) != (0x20 | 0x01))
-                       goto err_out;
-               if ((inb(ioaddr + 0x7) & 0x80) != 0x80)
-                       goto err_out;
-               outb_p(E8390_RXOFF, ioaddr + EN0_RXCR); /* out(ioaddr+0xc, 0x20) */
-               /* outb_p(ENDCFG_WTS|ENDCFG_FT1|ENDCFG_LS, ioaddr+EN0_DCFG); */
-               outb_p(ENDCFG_WTS | 0x48, ioaddr + EN0_DCFG); /* 0x49 */
-               outb_p(CNET98EL_START_PG, ioaddr + EN0_STARTPG);
-               outb_p(CNET98EL_STOP_PG, ioaddr + EN0_STOPPG);
-               if (ei_debug > 2)
-                       printk("memory check");
-               for (i = 0; i < 65536; i += 1024) {
-                       if (ei_debug > 2)
-                               printk(" %04x", i);
-                       ne2k_cbus_writemem(dev, ioaddr, i, pat, 32);
-                       while (((inb(ioaddr + EN0_ISR) & ENISR_RDC) != ENISR_RDC) && --maxwait)
-                               ;
-                       ne2k_cbus_readmem(dev, ioaddr, i, buf, 32);
-                       if (memcmp(pat, buf, 32)) {
-                               if (ei_debug > 2)
-                                       printk(" failed.");
-                               break;
-                       }
-               }
-               if (i != 16384) {
-                       if (ei_debug > 2)
-                               printk("] ");
-                       printk("memory failure at %x\n", i);
-                       goto err_out;
-               }
-               if (ei_debug > 2)
-                       printk(" good...");
-               if (!dev->irq) {
-                       if (ei_debug > 2)
-                               printk("] ");
-                       printk("IRQ must be specified for C-NET(98)E/L. probe failed.\n");
-                       goto err_out;
-               }
-               outb((dev->irq > 5) ? (dev->irq & 4):(dev->irq >> 1), ioaddr + (0x2 | 0x400));
-               outb(0x7e, ioaddr + (0x4 | 0x400));
-               ne2k_cbus_readmem(dev, ioaddr, 16384, SA_prom, 32);
-               outb(0xff, ioaddr + EN0_ISR);
-               if (ei_debug > 2)
-                       printk("done]");
-       } else
-#endif /* CONFIG_NE2K_CBUS_CNET98EL */
-       /* Read the 16 bytes of station address PROM.
-          We must first initialize registers, similar to NS8390_init(eifdev, 0).
-          We can't reliably read the SAPROM address without this.
-          (I learned the hard way!). */
-       {
-               struct {unsigned char value; unsigned short offset;} program_seq[] = 
-               {
-                       {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/
-                       /* NEC PC-9800: some board can only handle word-wide access? */
-                       {0x48 | ENDCFG_WTS,     EN0_DCFG},      /* Set word-wide (0x48) access. */
-                       {16384 / 256, EN0_STARTPG},
-                       {32768 / 256, EN0_STOPPG},
-                       {0x00,  EN0_RCNTLO},    /* Clear the count regs. */
-                       {0x00,  EN0_RCNTHI},
-                       {0x00,  EN0_IMR},       /* Mask completion irq. */
-                       {0xFF,  EN0_ISR},
-                       {E8390_RXOFF, EN0_RXCR},        /* 0x20  Set to monitor */
-                       {E8390_TXOFF, EN0_TXCR},        /* 0x02  and loopback mode. */
-                       {32,    EN0_RCNTLO},
-                       {0x00,  EN0_RCNTHI},
-                       {0x00,  EN0_RSARLO},    /* DMA starting at 0x0000. */
-                       {0x00,  EN0_RSARHI},
-                       {E8390_RREAD+E8390_START, E8390_CMD},
-               };
-
-               for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
-                       outb_p(program_seq[i].value, ioaddr + program_seq[i].offset);
-               insw(ioaddr + NE_DATAPORT, SA_prom, 32 >> 1);
-
-       }
-
-       if (wordlength == 2)
-       {
-               for (i = 0; i < 16; i++)
-                       SA_prom[i] = SA_prom[i+i];
-               start_page = NESM_START_PG;
-               stop_page = NESM_STOP_PG;
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-               if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) {
-                       start_page = CNET98EL_START_PG;
-                       stop_page = CNET98EL_STOP_PG;
-               }
-#endif
-       } else {
-               start_page = NE1SM_START_PG;
-               stop_page = NE1SM_STOP_PG;
-       }
-
-       neX000 = (SA_prom[14] == 0x57  &&  SA_prom[15] == 0x57);
-       if (neX000) {
-               name = "C-Bus-NE2K-compat";
-       }
-       else
-       {
-#ifdef SUPPORT_NE_BAD_CLONES
-               /* Ack!  Well, there might be a *bad* NE*000 clone there.
-                  Check for total bogus addresses. */
-               for (i = 0; bad_clone_list[i].name8; i++)
-               {
-                       if (SA_prom[0] == bad_clone_list[i].SAprefix[0] &&
-                               SA_prom[1] == bad_clone_list[i].SAprefix[1] &&
-                               SA_prom[2] == bad_clone_list[i].SAprefix[2])
-                       {
-                               if (wordlength == 2)
-                               {
-                                       name = bad_clone_list[i].name16;
-                               } else {
-                                       name = bad_clone_list[i].name8;
-                               }
-                               break;
-                       }
-               }
-               if (bad_clone_list[i].name8 == NULL)
-               {
-                       printk(" not found (invalid signature %2.2x %2.2x).\n",
-                               SA_prom[14], SA_prom[15]);
-                       ret = -ENXIO;
-                       goto err_out;
-               }
-#else
-               printk(" not found.\n");
-               ret = -ENXIO;
-               goto err_out;
-#endif
-       }
-
-       if (dev->irq < 2)
-       {
-               unsigned long cookie = probe_irq_on();
-               outb_p(0x50, ioaddr + EN0_IMR); /* Enable one interrupt. */
-               outb_p(0x00, ioaddr + EN0_RCNTLO);
-               outb_p(0x00, ioaddr + EN0_RCNTHI);
-               outb_p(E8390_RREAD+E8390_START, ioaddr); /* Trigger it... */
-               mdelay(10);             /* wait 10ms for interrupt to propagate */
-               outb_p(0x00, ioaddr + EN0_IMR);                 /* Mask it again. */
-               dev->irq = probe_irq_off(cookie);
-               if (ei_debug > 2)
-                       printk(" autoirq is %d\n", dev->irq);
-       } else if (dev->irq == 7)
-               /* Fixup for users that don't know that IRQ 7 is really IRQ 11,
-                  or don't know which one to set. */
-               dev->irq = 11;
-
-       if (! dev->irq) {
-               printk(" failed to detect IRQ line.\n");
-               ret = -EAGAIN;
-               goto err_out;
-       }
-
-       /* Snarf the interrupt now.  There's no point in waiting since we cannot
-          share and the board will usually be enabled. */
-       ret = request_irq(dev->irq, ei_interrupt, 0, name, dev);
-       if (ret) {
-               printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret);
-               goto err_out_kfree;
-       }
-
-       dev->base_addr = ioaddr;
-
-       for(i = 0; i < ETHER_ADDR_LEN; i++) {
-               printk(" %2.2x", SA_prom[i]);
-               dev->dev_addr[i] = SA_prom[i];
-       }
-
-       printk("\n%s: %s found at %#x, hardware type %d(%s), using IRQ %d.\n",
-                  dev->name, name, ioaddr, hw->hwtype, hw->hwident, dev->irq);
-
-       ei_status.name = name;
-       ei_status.tx_start_page = start_page;
-       ei_status.stop_page = stop_page;
-       ei_status.word16 = (wordlength == 2);
-
-       ei_status.rx_start_page = start_page + TX_PAGES;
-#ifdef PACKETBUF_MEMSIZE
-        /* Allow the packet buffer size to be overridden by know-it-alls. */
-       ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
-#endif
-
-       ei_status.reset_8390 = &ne_reset_8390;
-       ei_status.block_input = &ne_block_input;
-       ei_status.block_output = &ne_block_output;
-       ei_status.get_8390_hdr = &ne_get_8390_hdr;
-       ei_status.priv = 0;
-       dev->open = &ne_open;
-       dev->stop = &ne_close;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       dev->poll_controller = ei_poll;
-#endif
-       NS8390_init(dev, 0);
-       return 0;
-
-err_out_kfree:
-       ne2k_cbus_destroy(dev);
-err_out:
-       while (rlist > hw->regionlist) {
-               rlist --;
-               release_region(ioaddr + rlist->start, rlist->range);
-       }
-       return ret;
-}
-
-static int ne_open(struct net_device *dev)
-{
-       ei_open(dev);
-       return 0;
-}
-
-static int ne_close(struct net_device *dev)
-{
-       if (ei_debug > 1)
-               printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
-       ei_close(dev);
-       return 0;
-}
-
-/* Hard reset the card.  This used to pause for the same period that a
-   8390 reset command required, but that shouldn't be necessary. */
-
-static void ne_reset_8390(struct net_device *dev)
-{
-       unsigned long reset_start_time = jiffies;
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
-       if (ei_debug > 1)
-               printk(KERN_DEBUG "resetting the 8390 t=%ld...", jiffies);
-
-       /* derived from CNET98EL-patch for bad clones... */
-       outb_p(E8390_NODMA | E8390_STOP, NE_BASE + E8390_CMD);  /* 0x20 | 0x1 */
-
-       /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
-       outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
-
-       ei_status.txing = 0;
-       ei_status.dmaing = 0;
-
-       /* This check _should_not_ be necessary, omit eventually. */
-       while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
-               if (jiffies - reset_start_time > 2*HZ/100) {
-                       printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name);
-                       break;
-               }
-       outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */
-}
-
-/* Grab the 8390 specific header. Similar to the block_input routine, but
-   we don't need to be concerned with ring wrap as the header will be at
-   the start of a page, so we optimize accordingly. */
-
-static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
-{
-       int nic_base = dev->base_addr;
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
-       /* This *shouldn't* happen. If it does, it's the last thing you'll see */
-
-       if (ei_status.dmaing)
-       {
-               printk(KERN_EMERG "%s: DMAing conflict in ne_get_8390_hdr "
-                       "[DMAstat:%d][irqlock:%d].\n",
-                       dev->name, ei_status.dmaing, ei_status.irqlock);
-               return;
-       }
-
-       ei_status.dmaing |= 0x01;
-       outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
-       outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
-       outb_p(0, nic_base + EN0_RCNTHI);
-       outb_p(0, nic_base + EN0_RSARLO);               /* On page boundary */
-       outb_p(ring_page, nic_base + EN0_RSARHI);
-       outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
-
-       if (ei_status.word16)
-               insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
-       else
-               insb(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr));
-
-       outb_p(ENISR_RDC, nic_base + EN0_ISR);  /* Ack intr. */
-       ei_status.dmaing &= ~0x01;
-
-       le16_to_cpus(&hdr->count);
-}
-
-/* Block input and output, similar to the Crynwr packet driver.  If you
-   are porting to a new ethercard, look at the packet driver source for hints.
-   The NEx000 doesn't share the on-board packet memory -- you have to put
-   the packet out through the "remote DMA" dataport using outb. */
-
-static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
-{
-#ifdef NE_SANITY_CHECK
-       int xfer_count = count;
-#endif
-       int nic_base = dev->base_addr;
-       char *buf = skb->data;
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
-       /* This *shouldn't* happen. If it does, it's the last thing you'll see */
-       if (ei_status.dmaing)
-       {
-               printk(KERN_EMERG "%s: DMAing conflict in ne_block_input "
-                       "[DMAstat:%d][irqlock:%d].\n",
-                       dev->name, ei_status.dmaing, ei_status.irqlock);
-               return;
-       }
-       ei_status.dmaing |= 0x01;
-
-       /* round up count to a word (derived from ICM-patch) */
-       count = (count + 1) & ~1;
-
-       outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
-       outb_p(count & 0xff, nic_base + EN0_RCNTLO);
-       outb_p(count >> 8, nic_base + EN0_RCNTHI);
-       outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO);
-       outb_p(ring_offset >> 8, nic_base + EN0_RSARHI);
-       outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
-       if (ei_status.word16)
-       {
-               insw(NE_BASE + NE_DATAPORT,buf,count>>1);
-               if (count & 0x01)
-               {
-                       buf[count-1] = inb(NE_BASE + NE_DATAPORT);
-#ifdef NE_SANITY_CHECK
-                       xfer_count++;
-#endif
-               }
-       } else {
-               insb(NE_BASE + NE_DATAPORT, buf, count);
-       }
-
-#ifdef NE_SANITY_CHECK
-       /* This was for the ALPHA version only, but enough people have
-          been encountering problems so it is still here.  If you see
-          this message you either 1) have a slightly incompatible clone
-          or 2) have noise/speed problems with your bus. */
-
-       if (ei_debug > 1)
-       {
-               /* DMA termination address check... */
-               int addr, tries = 20;
-               do {
-                       /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
-                          -- it's broken for Rx on some cards! */
-                       int high = inb_p(nic_base + EN0_RSARHI);
-                       int low = inb_p(nic_base + EN0_RSARLO);
-                       addr = (high << 8) + low;
-                       if (((ring_offset + xfer_count) & 0xff) == low)
-                               break;
-               } while (--tries > 0);
-               if (tries <= 0)
-                       printk(KERN_WARNING "%s: RX transfer address mismatch,"
-                               "%#4.4x (expected) vs. %#4.4x (actual).\n",
-                               dev->name, ring_offset + xfer_count, addr);
-       }
-#endif
-       outb_p(ENISR_RDC, nic_base + EN0_ISR);  /* Ack intr. */
-       ei_status.dmaing &= ~0x01;
-}
-
-static void ne_block_output(struct net_device *dev, int count,
-               const unsigned char *buf, const int start_page)
-{
-       int nic_base = NE_BASE;
-       unsigned long dma_start;
-#ifdef NE_SANITY_CHECK
-       int retries = 0;
-#endif
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
-       /* Round the count up for word writes.  Do we need to do this?
-          What effect will an odd byte count have on the 8390?
-          I should check someday. */
-
-       if (ei_status.word16 && (count & 0x01))
-               count++;
-
-       /* This *shouldn't* happen. If it does, it's the last thing you'll see */
-       if (ei_status.dmaing)
-       {
-               printk(KERN_EMERG "%s: DMAing conflict in ne_block_output."
-                       "[DMAstat:%d][irqlock:%d]\n",
-                       dev->name, ei_status.dmaing, ei_status.irqlock);
-               return;
-       }
-       ei_status.dmaing |= 0x01;
-       /* We should already be in page 0, but to be safe... */
-       outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD);
-
-#ifdef NE_SANITY_CHECK
-retry:
-#endif
-
-#ifdef NE8390_RW_BUGFIX
-       /* Handle the read-before-write bug the same way as the
-          Crynwr packet driver -- the NatSemi method doesn't work.
-          Actually this doesn't always work either, but if you have
-          problems with your NEx000 this is better than nothing! */
-
-       outb_p(0x42, nic_base + EN0_RCNTLO);
-       outb_p(0x00,   nic_base + EN0_RCNTHI);
-       outb_p(0x42, nic_base + EN0_RSARLO);
-       outb_p(0x00, nic_base + EN0_RSARHI);
-       outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
-       /* Make certain that the dummy read has occurred. */
-       udelay(6);
-#endif
-
-       outb_p(ENISR_RDC, nic_base + EN0_ISR);
-
-       /* Now the normal output. */
-       outb_p(count & 0xff, nic_base + EN0_RCNTLO);
-       outb_p(count >> 8,   nic_base + EN0_RCNTHI);
-       outb_p(0x00, nic_base + EN0_RSARLO);
-       outb_p(start_page, nic_base + EN0_RSARHI);
-
-       outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD);
-       if (ei_status.word16) {
-               outsw(NE_BASE + NE_DATAPORT, buf, count>>1);
-       } else {
-               outsb(NE_BASE + NE_DATAPORT, buf, count);
-       }
-
-       dma_start = jiffies;
-
-#ifdef NE_SANITY_CHECK
-       /* This was for the ALPHA version only, but enough people have
-          been encountering problems so it is still here. */
-
-       if (ei_debug > 1)
-       {
-               /* DMA termination address check... */
-               int addr, tries = 20;
-               do {
-                       int high = inb_p(nic_base + EN0_RSARHI);
-                       int low = inb_p(nic_base + EN0_RSARLO);
-                       addr = (high << 8) + low;
-                       if ((start_page << 8) + count == addr)
-                               break;
-               } while (--tries > 0);
-
-               if (tries <= 0)
-               {
-                       printk(KERN_WARNING "%s: Tx packet transfer address mismatch,"
-                               "%#4.4x (expected) vs. %#4.4x (actual).\n",
-                               dev->name, (start_page << 8) + count, addr);
-                       if (retries++ == 0)
-                               goto retry;
-               }
-       }
-#endif
-
-       while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
-               if (jiffies - dma_start > 2*HZ/100) {           /* 20ms */
-                       printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
-                       ne_reset_8390(dev);
-                       NS8390_init(dev,1);
-                       break;
-               }
-
-       outb_p(ENISR_RDC, nic_base + EN0_ISR);  /* Ack intr. */
-       ei_status.dmaing &= ~0x01;
-       return;
-}
-
-\f
-#ifdef MODULE
-#define MAX_NE_CARDS   4       /* Max number of NE cards per module */
-static struct net_device *dev_ne[MAX_NE_CARDS];
-static int io[MAX_NE_CARDS];
-static int irq[MAX_NE_CARDS];
-static int bad[MAX_NE_CARDS];  /* 0xbad = bad sig or no reset ack */
-static int hwtype[MAX_NE_CARDS] = { 0, }; /* board type */
-
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(hwtype, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM_DESC(io, "I/O base address(es),required");
-MODULE_PARM_DESC(irq, "IRQ number(s)");
-MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures");
-MODULE_PARM_DESC(hwtype, "Board type of PC-9800 C-Bus NIC");
-MODULE_DESCRIPTION("NE1000/NE2000 PC-9800 C-bus Ethernet driver");
-MODULE_LICENSE("GPL");
-
-/* This is set up so that no ISA autoprobe takes place. We can't guarantee
-that the ne2k probe is the last 8390 based probe to take place (as it
-is at boot) and so the probe will get confused by any other 8390 cards.
-ISA device autoprobes on a running machine are not recommended anyway. */
-
-int init_module(void)
-{
-       int this_dev, found = 0;
-
-       for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
-               struct net_device *dev = alloc_ei_netdev();
-               if (!dev)
-                       break;
-               dev->irq = irq[this_dev];
-               dev->mem_end = bad[this_dev];
-               dev->base_addr = io[this_dev];
-               dev->mem_start = hwtype[this_dev];
-               if (do_ne_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_ne[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
-               }
-               free_netdev(dev);
-               if (found)
-                       break;
-               if (io[this_dev] != 0)
-                       printk(KERN_WARNING "ne2k_cbus: No NE*000 card found at i/o = %#x\n", io[this_dev]);
-               else
-                       printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n");
-               return -ENXIO;
-       }
-       if (found)
-               return 0;
-       return -ENODEV;
-}
-
-void cleanup_module(void)
-{
-       int this_dev;
-
-       for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
-               struct net_device *dev = dev_ne[this_dev];
-               if (dev) {
-                       unregister_netdev(dev);
-                       cleanup_card(dev);
-                       free_netdev(dev);
-               }
-       }
-}
-#endif /* MODULE */
-
diff --git a/drivers/net/ne2k_cbus.h b/drivers/net/ne2k_cbus.h
deleted file mode 100644 (file)
index adf2cbc..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-/* ne2k_cbus.h: 
-   vender-specific information definition for NEC PC-9800
-   C-bus Ethernet Cards
-   Used in ne.c 
-
-   (C)1998,1999 KITAGWA Takurou & Linux/98 project
-*/
-
-#include <linux/config.h>
-
-#undef NE_RESET
-#define NE_RESET EI_SHIFT(0x11) /* Issue a read to reset, a write to clear. */
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-#ifndef CONFIG_NE2K_CBUS_CNET98EL_IO_BASE
-#warning CONFIG_NE2K_CBUS_CNET98EL_IO_BASE is not defined(config error?)
-#warning use 0xaaed as default
-#define CONFIG_NE2K_CBUS_CNET98EL_IO_BASE 0xaaed /* or 0x55ed */
-#endif
-#define CNET98EL_START_PG 0x00
-#define CNET98EL_STOP_PG 0x40
-#endif
-
-/* Hardware type definition (derived from *BSD) */
-#define NE2K_CBUS_HARDWARE_TYPE_MASK 0xff
-
-/* 0: reserved for auto-detect */
-/* 1: (not tested)
-   Allied Telesis CentreCom LA-98-T */
-#define NE2K_CBUS_HARDWARE_TYPE_ATLA98 1
-/* 2: (not tested)
-   ELECOM Laneed
-   LD-BDN[123]A
-   PLANET SMART COM 98 EN-2298-C
-   MACNICA ME98 */
-#define NE2K_CBUS_HARDWARE_TYPE_BDN 2
-/* 3:
-   Melco EGY-98
-   Contec C-NET(98)E*A/L*A,C-NET(98)P */
-#define NE2K_CBUS_HARDWARE_TYPE_EGY98 3
-/* 4:
-   Melco LGY-98,IND-SP,IND-SS
-   MACNICA NE2098 */
-#define NE2K_CBUS_HARDWARE_TYPE_LGY98 4
-/* 5:
-   ICM DT-ET-25,DT-ET-T5,IF-2766ET,IF-2771ET
-   PLANET SMART COM 98 EN-2298-T,EN-2298P-T
-   D-Link DE-298PT,DE-298PCAT
-   ELECOM Laneed LD-98P */
-#define NE2K_CBUS_HARDWARE_TYPE_ICM 5
-/* 6: (reserved for SIC-98, which is not supported in this driver.) */
-/* 7: (unused in *BSD?)
-   <Original NE2000 compatible>
-   <for PCI/PCMCIA cards>
-*/
-#define NE2K_CBUS_HARDWARE_TYPE_NE2K 7
-/* 8:
-   NEC PC-9801-108 */
-#define NE2K_CBUS_HARDWARE_TYPE_NEC108 8
-/* 9:
-   I-O DATA LA-98,LA/T-98 */
-#define NE2K_CBUS_HARDWARE_TYPE_IOLA98 9
-/* 10: (reserved for C-NET(98), which is not supported in this driver.) */
-/* 11:
-   Contec C-NET(98)E,L */
-#define NE2K_CBUS_HARDWARE_TYPE_CNET98EL 11
-
-#define NE2K_CBUS_HARDWARE_TYPE_MAX 11
-
-/* HARDWARE TYPE ID 12-31: reserved */
-
-struct ne2k_cbus_offsetinfo {
-       unsigned short skip;
-       unsigned short offset8; /* +0x8 - +0xf */
-       unsigned short offset10; /* +0x10 */
-       unsigned short offset1f; /* +0x1f */
-};
-
-struct ne2k_cbus_region {
-       unsigned short start;
-       short range;
-};
-
-struct ne2k_cbus_hwinfo {
-       const unsigned short hwtype;
-       const unsigned char *hwident;
-#ifndef MODULE
-       const unsigned short *portlist;
-#endif
-       const struct ne2k_cbus_offsetinfo *offsetinfo;
-       const struct ne2k_cbus_region *regionlist;
-};
-
-#ifdef CONFIG_NE2K_CBUS_ATLA98
-#ifndef MODULE
-static unsigned short atla98_portlist[] __initdata = {
-       0xd0,
-       0
-};
-#endif
-#define atla98_offsetinfo ne2k_offsetinfo
-#define atla98_regionlist ne2k_regionlist
-#endif /* CONFIG_NE2K_CBUS_ATLA98 */
-
-#ifdef CONFIG_NE2K_CBUS_BDN
-#ifndef MODULE
-static unsigned short bdn_portlist[] __initdata = {
-       0xd0,
-       0
-};
-#endif
-static struct ne2k_cbus_offsetinfo bdn_offsetinfo __initdata = {
-#if 0
-       /* comes from FreeBSD(98) ed98.h */
-       0x1000, 0x8000, 0x100, 0xc200 /* ??? */
-#else
-       /* comes from NetBSD/pc98 if_ne_isa.c */
-       0x1000, 0x8000, 0x100, 0x7f00 /* ??? */
-#endif
-};
-static struct ne2k_cbus_region bdn_regionlist[] __initdata = {
-       {0x0, 1}, {0x1000, 1}, {0x2000, 1}, {0x3000,1},
-       {0x4000, 1}, {0x5000, 1}, {0x6000, 1}, {0x7000, 1},
-       {0x8000, 1}, {0x9000, 1}, {0xa000, 1}, {0xb000, 1},
-       {0xc000, 1}, {0xd000, 1}, {0xe000, 1}, {0xf000, 1},
-       {0x100, 1}, {0x7f00, 1},
-       {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_BDN */
-
-#ifdef CONFIG_NE2K_CBUS_EGY98
-#ifndef MODULE
-static unsigned short egy98_portlist[] __initdata = {
-       0xd0,
-       0
-};
-#endif
-static struct ne2k_cbus_offsetinfo egy98_offsetinfo __initdata = {
-       0x02, 0x100, 0x200, 0x300
-};
-static struct ne2k_cbus_region egy98_regionlist[] __initdata = {
-       {0x0, 1}, {0x2, 1}, {0x4, 1}, {0x6, 1},
-       {0x8, 1}, {0xa, 1}, {0xc, 1}, {0xe, 1},
-       {0x100, 1}, {0x102, 1}, {0x104, 1}, {0x106, 1},
-       {0x108, 1}, {0x10a, 1}, {0x10c, 1}, {0x10e, 1},
-       {0x200, 1}, {0x300, 1},
-       {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_EGY98 */
-
-#ifdef CONFIG_NE2K_CBUS_LGY98
-#ifndef MODULE
-static unsigned short lgy98_portlist[] __initdata = {
-       0xd0, 0x10d0, 0x20d0, 0x30d0, 0x40d0, 0x50d0, 0x60d0, 0x70d0,
-       0
-};
-#endif
-static struct ne2k_cbus_offsetinfo lgy98_offsetinfo __initdata = {
-       0x01, 0x08, 0x200, 0x300
-};
-static struct ne2k_cbus_region lgy98_regionlist[] __initdata = {
-       {0x0, 16}, {0x200, 1}, {0x300, 1},
-       {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_LGY98 */
-
-#ifdef CONFIG_NE2K_CBUS_ICM
-#ifndef MODULE
-static unsigned short icm_portlist[] __initdata = {
-       /* ICM */
-       0x56d0,
-       /* LD-98PT */
-       0x46d0, 0x66d0, 0x76d0, 0x86d0, 0x96d0, 0xa6d0, 0xb6d0, 0xc6d0,
-       0
-};
-#endif
-static struct ne2k_cbus_offsetinfo icm_offsetinfo __initdata = {
-       0x01, 0x08, 0x100, 0x10f
-};
-static struct ne2k_cbus_region icm_regionlist[] __initdata = {
-       {0x0, 16}, {0x100, 16},
-       {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_ICM */
-
-#if defined(CONFIG_NE2K_CBUS_NE2K) && !defined(MODULE)
-static unsigned short ne2k_portlist[] __initdata = {
-       0xd0, 0x300, 0x280, 0x320, 0x340, 0x360, 0x380,
-       0
-};
-#endif
-#if defined(CONFIG_NE2K_CBUS_NE2K) || defined(CONFIG_NE2K_CBUS_ATLA98)
-static struct ne2k_cbus_offsetinfo ne2k_offsetinfo __initdata = {
-       0x01, 0x08, 0x10, 0x1f
-};
-static struct ne2k_cbus_region ne2k_regionlist[] __initdata = {
-       {0x0, 32},
-       {0x0, 0}
-};
-#endif
-
-#ifdef CONFIG_NE2K_CBUS_NEC108
-#ifndef MODULE
-static unsigned short nec108_portlist[] __initdata = {
-       0x770, 0x2770, 0x4770, 0x6770,
-       0
-};
-#endif
-static struct ne2k_cbus_offsetinfo nec108_offsetinfo __initdata = {
-       0x02, 0x1000, 0x888, 0x88a
-};
-static struct ne2k_cbus_region nec108_regionlist[] __initdata = {
-       {0x0, 1}, {0x2, 1}, {0x4, 1}, {0x6, 1},
-       {0x8, 1}, {0xa, 1}, {0xc, 1}, {0xe, 1},
-       {0x1000, 1}, {0x1002, 1}, {0x1004, 1}, {0x1006, 1},
-       {0x1008, 1}, {0x100a, 1}, {0x100c, 1}, {0x100e, 1},
-       {0x888, 1}, {0x88a, 1}, {0x88c, 1}, {0x88e, 1},
-       {0x0, 0}
-};
-#endif
-
-#ifdef CONFIG_NE2K_CBUS_IOLA98
-#ifndef MODULE
-static unsigned short iola98_portlist[] __initdata = {
-       0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
-       0
-};
-#endif
-static struct ne2k_cbus_offsetinfo iola98_offsetinfo __initdata = {
-       0x1000, 0x8000, 0x100, 0xf100
-};
-static struct ne2k_cbus_region iola98_regionlist[] __initdata = {
-       {0x0, 1}, {0x1000, 1}, {0x2000, 1}, {0x3000, 1},
-       {0x4000, 1}, {0x5000, 1}, {0x6000, 1}, {0x7000, 1},
-       {0x8000, 1}, {0x9000, 1}, {0xa000, 1}, {0xb000, 1},
-       {0xc000, 1}, {0xd000, 1}, {0xe000, 1}, {0xf000, 1},
-       {0x100, 1}, {0xf100, 1},
-       {0x0,0}
-};
-#endif /* CONFIG_NE2K_CBUS_IOLA98 */
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-#ifndef MODULE
-static unsigned short cnet98el_portlist[] __initdata = {
-       0x3d0, 0x13d0, 0x23d0, 0x33d0, 0x43d0, 0x53d0, 0x60d0, 0x70d0,
-       0
-};
-#endif
-static struct ne2k_cbus_offsetinfo cnet98el_offsetinfo __initdata = {
-       0x01, 0x08, 0x40e, 0x400
-};
-static struct ne2k_cbus_region cnet98el_regionlist[] __initdata = {
-       {0x0, 16}, {0x400, 16},
-       {0x0, 0}
-};
-#endif
-
-
-/* port information table (for ne.c initialize/probe process) */
-
-static struct ne2k_cbus_hwinfo ne2k_cbus_hwinfo_list[] __initdata = {
-#ifdef CONFIG_NE2K_CBUS_ATLA98
-/* NOT TESTED */
-       {
-               NE2K_CBUS_HARDWARE_TYPE_ATLA98,
-               "LA-98-T",
-#ifndef MODULE
-               atla98_portlist,
-#endif
-               &atla98_offsetinfo, atla98_regionlist
-       },
-#endif
-#ifdef CONFIG_NE2K_CBUS_BDN
-/* NOT TESTED */
-       {
-               NE2K_CBUS_HARDWARE_TYPE_BDN,
-               "LD-BDN[123]A",
-#ifndef MODULE
-               bdn_portlist,
-#endif
-               &bdn_offsetinfo, bdn_regionlist
-       },
-#endif
-#ifdef CONFIG_NE2K_CBUS_ICM
-       {
-               NE2K_CBUS_HARDWARE_TYPE_ICM,
-               "IF-27xxET",
-#ifndef MODULE
-               icm_portlist,
-#endif
-               &icm_offsetinfo, icm_regionlist
-       },
-#endif
-#ifdef CONFIG_NE2K_CBUS_NE2K
-       {
-               NE2K_CBUS_HARDWARE_TYPE_NE2K,
-               "NE2000 compat.",
-#ifndef MODULE
-               ne2k_portlist,
-#endif
-               &ne2k_offsetinfo, ne2k_regionlist
-       },
-#endif
-#ifdef CONFIG_NE2K_CBUS_NEC108
-       {
-               NE2K_CBUS_HARDWARE_TYPE_NEC108,
-               "PC-9801-108",
-#ifndef MODULE
-               nec108_portlist,
-#endif
-               &nec108_offsetinfo, nec108_regionlist
-       },
-#endif
-#ifdef CONFIG_NE2K_CBUS_IOLA98
-       {
-               NE2K_CBUS_HARDWARE_TYPE_IOLA98,
-               "LA-98",
-#ifndef MODULE
-               iola98_portlist,
-#endif
-               &iola98_offsetinfo, iola98_regionlist
-       },
-#endif
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-       {
-               NE2K_CBUS_HARDWARE_TYPE_CNET98EL,
-               "C-NET(98)E/L",
-#ifndef MODULE
-               cnet98el_portlist,
-#endif
-               &cnet98el_offsetinfo, cnet98el_regionlist
-       },
-#endif
-/* NOTE: LGY98 must be probed before EGY98, or system stalled!? */
-#ifdef CONFIG_NE2K_CBUS_LGY98
-       {
-               NE2K_CBUS_HARDWARE_TYPE_LGY98,
-               "LGY-98",
-#ifndef MODULE
-               lgy98_portlist,
-#endif
-               &lgy98_offsetinfo, lgy98_regionlist
-       },
-#endif
-#ifdef CONFIG_NE2K_CBUS_EGY98
-       {
-               NE2K_CBUS_HARDWARE_TYPE_EGY98,
-               "EGY-98",
-#ifndef MODULE
-               egy98_portlist,
-#endif
-               &egy98_offsetinfo, egy98_regionlist
-       },
-#endif
-       {
-               0,
-               "unsupported hardware",
-#ifndef MODULE
-               NULL,
-#endif
-               NULL, NULL
-       }
-};
-
-static int __init ne2k_cbus_init(struct net_device *dev)
-{
-       struct ei_device *ei_local;
-       if (dev->priv == NULL) {
-               ei_local = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
-               if (ei_local == NULL)
-                       return -ENOMEM;
-               memset(ei_local, 0, sizeof(struct ei_device));
-               ei_local->reg_offset = kmalloc(sizeof(typeof(*ei_local->reg_offset))*18, GFP_KERNEL);
-               if (ei_local->reg_offset == NULL) {
-                       kfree(ei_local);
-                       return -ENOMEM;
-               }
-               spin_lock_init(&ei_local->page_lock);
-               dev->priv = ei_local;
-       }
-       return 0;
-}
-
-static void ne2k_cbus_destroy(struct net_device *dev)
-{
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-       if (ei_local != NULL) {
-               if (ei_local->reg_offset)
-                       kfree(ei_local->reg_offset);
-               kfree(dev->priv);
-               dev->priv = NULL;
-       }
-}
-
-static const struct ne2k_cbus_hwinfo * __init ne2k_cbus_get_hwinfo(int hwtype)
-{
-       const struct ne2k_cbus_hwinfo *hw;
-
-       for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) {
-               if (hw->hwtype == hwtype) break;
-       }
-       return hw;
-}
-
-static void __init ne2k_cbus_set_hwtype(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr)
-{
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-       int i;
-       int hwtype_old = dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK;
-
-       if (!ei_local)
-               panic("Gieee! ei_local == NULL!! (from %p)",
-                      __builtin_return_address(0));
-
-       dev->mem_start &= ~NE2K_CBUS_HARDWARE_TYPE_MASK;
-       dev->mem_start |= hw->hwtype & NE2K_CBUS_HARDWARE_TYPE_MASK;
-
-       if (ei_debug > 2) {
-               printk(KERN_DEBUG "hwtype changed: %d -> %d\n",hwtype_old,(int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-       }
-
-       if (hw->offsetinfo) {
-               for (i = 0; i < 8; i++) {
-                       ei_local->reg_offset[i] = hw->offsetinfo->skip * i;
-               }
-               for (i = 8; i < 16; i++) {
-                       ei_local->reg_offset[i] =
-                               hw->offsetinfo->skip*(i-8) + hw->offsetinfo->offset8;
-               }
-#ifdef CONFIG_NE2K_CBUS_NEC108
-               if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_NEC108) {
-                       int adj = (ioaddr & 0xf000) /2;
-                       ei_local->reg_offset[16] = 
-                               (hw->offsetinfo->offset10 | adj) - ioaddr;
-                       ei_local->reg_offset[17] = 
-                               (hw->offsetinfo->offset1f | adj) - ioaddr;
-               } else {
-#endif /* CONFIG_NE2K_CBUS_NEC108 */
-                       ei_local->reg_offset[16] = hw->offsetinfo->offset10;
-                       ei_local->reg_offset[17] = hw->offsetinfo->offset1f;
-#ifdef CONFIG_NE2K_CBUS_NEC108
-               }
-#endif
-       } else {
-               /* make dummmy offset list */
-               for (i = 0; i < 16; i++) {
-                       ei_local->reg_offset[i] = i;
-               }
-               ei_local->reg_offset[16] = 0x10;
-               ei_local->reg_offset[17] = 0x1f;
-       }
-}
-
-#if defined(CONFIG_NE2K_CBUS_ICM) || defined(CONFIG_NE2K_CBUS_CNET98EL)
-static void __init ne2k_cbus_readmem(struct net_device *dev, int ioaddr, unsigned short memaddr, char *buf, unsigned short len)
-{
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-       outb_p(E8390_NODMA | E8390_START, ioaddr+E8390_CMD);
-       outb_p(len & 0xff, ioaddr+EN0_RCNTLO);
-       outb_p(len >> 8, ioaddr+EN0_RCNTHI);
-       outb_p(memaddr & 0xff, ioaddr+EN0_RSARLO);
-       outb_p(memaddr >> 8, ioaddr+EN0_RSARHI);
-       outb_p(E8390_RREAD | E8390_START, ioaddr+E8390_CMD);
-       insw(ioaddr+NE_DATAPORT, buf, len >> 1);
-}
-static void __init ne2k_cbus_writemem(struct net_device *dev, int ioaddr, unsigned short memaddr, const char *buf, unsigned short len)
-{
-       struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-       outb_p(E8390_NODMA | E8390_START, ioaddr+E8390_CMD);
-       outb_p(ENISR_RDC, ioaddr+EN0_ISR);
-       outb_p(len & 0xff, ioaddr+EN0_RCNTLO);
-       outb_p(len >> 8, ioaddr+EN0_RCNTHI);
-       outb_p(memaddr & 0xff, ioaddr+EN0_RSARLO);
-       outb_p(memaddr >> 8, ioaddr+EN0_RSARHI);
-       outb_p(E8390_RWRITE | E8390_START, ioaddr+E8390_CMD);
-       outsw(ioaddr+NE_DATAPORT, buf, len >> 1);
-}
-#endif
-
-static int ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr, int irq);
-/* End of ne2k_cbus.h */
index 29c98d6..d26eef5 100644 (file)
@@ -45,6 +45,9 @@
 #include <linux/sysrq.h>
 #include <linux/smp.h>
 #include <linux/netpoll.h>
+#include <asm/unaligned.h>
+
+#include "netdump.h"
 
 MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>");
 MODULE_DESCRIPTION("Console driver for network interfaces");
@@ -58,28 +61,100 @@ static struct netpoll np = {
        .name = "netconsole",
        .dev_name = "eth0",
        .local_port = 6665,
-       .remote_port = 6666,
+       .remote_port = 514,
        .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
 };
 static int configured = 0;
 
+static char netlog_config[256];
+module_param_string(netlog, netlog_config, 256, 0);
+MODULE_PARM_DESC(netlog, " netlog=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n");
+static struct netpoll netlog_np = {
+       .name = "netlog",
+       .dev_name = "eth0",
+       .local_port = 6664,
+       .remote_port = 6666,
+       .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+};
+static int netlog_configured = 0;
+
 #define MAX_PRINT_CHUNK 1000
+#define SYSLOG_HEADER_LEN 4
+
+static int syslog_chars = SYSLOG_HEADER_LEN;
+static unsigned char syslog_line [MAX_PRINT_CHUNK + 10] = {
+       '<',
+       '5',
+       '>',
+       ' ',
+       [4 ... MAX_PRINT_CHUNK+5] = '\0',
+};
+static unsigned char netlog_line[MAX_PRINT_CHUNK + HEADER_LEN];
+static unsigned int log_offset;
+
+/*
+ * We feed kernel messages char by char, and send the UDP packet
+ * one linefeed. We buffer all characters received.
+ */
+static inline void feed_syslog_char(const unsigned char c)
+{
+       if (syslog_chars == MAX_PRINT_CHUNK)
+               syslog_chars--;
+       syslog_line[syslog_chars] = c;
+       syslog_chars++;
+       if (c == '\n') {
+               netpoll_send_udp(&np, syslog_line, syslog_chars);
+               syslog_chars = SYSLOG_HEADER_LEN;
+       }
+}
 
 static void write_msg(struct console *con, const char *msg, unsigned int len)
 {
-       int frag, left;
+       int left, i;
        unsigned long flags;
+       reply_t reply;
+       char *netlog_buf = &netlog_line[HEADER_LEN];
 
-       if (!np.dev)
+       if (!np.dev && !netlog_np.dev)
+               return;
+
+       if (unlikely(netdump_mode))
                return;
 
        local_irq_save(flags);
 
-       for(left = len; left; ) {
-               frag = min(left, MAX_PRINT_CHUNK);
-               netpoll_send_udp(&np, msg, frag);
-               msg += frag;
-               left -= frag;
+       if (np.dev)
+               for (i = 0; i < len; i++)
+                       feed_syslog_char(msg[i]);
+
+       if (netlog_np.dev) {
+               left = len;
+               while (left) {
+                       if (left > MAX_PRINT_CHUNK)
+                               len = MAX_PRINT_CHUNK;
+                       else
+                               len = left;
+                       netlog_line[0] = NETDUMP_VERSION;
+
+                       reply.nr = 0;
+                       reply.code = REPLY_LOG;
+                       reply.info = log_offset;
+
+                       put_unaligned(htonl(reply.nr), 
+                                     (u32 *)(netlog_line + 1));
+                       put_unaligned(htonl(reply.code),
+                                     (u32 *)(netlog_line + 5));
+                       put_unaligned(htonl(reply.info),
+                                     (u32 *)(netlog_line + 9));
+
+                       log_offset += len;
+                       memcpy(netlog_buf, msg, len);
+
+                       netpoll_send_udp(&netlog_np, 
+                                        netlog_line, len + HEADER_LEN);
+                       msg += len;
+                       left -= len;
+               }
        }
 
        local_irq_restore(flags);
@@ -98,17 +173,29 @@ static int option_setup(char *opt)
 
 __setup("netconsole=", option_setup);
 
+static int netlog_option_setup(char *opt)
+{
+       netlog_configured = !netpoll_parse_options(&netlog_np, opt);
+       return 0;
+}
+
+__setup("netlog=", netlog_option_setup);
+
 static int init_netconsole(void)
 {
        if(strlen(config))
                option_setup(config);
 
-       if(!configured) {
-               printk("netconsole: not configured, aborting\n");
-               return -EINVAL;
-       }
+       if (strlen(netlog_config))
+               netlog_option_setup(netlog_config);
+
+       if (configured && netpoll_setup(&np))
+               printk("netconsole: failed to configure syslog service\n");
 
-       if(netpoll_setup(&np))
+       if (netlog_configured && netpoll_setup(&netlog_np))
+               printk("netconsole: failed to configured netlog service.\n");
+
+       if (!configured && !netlog_configured)
                return -EINVAL;
 
        register_console(&netconsole);
@@ -119,7 +206,12 @@ static int init_netconsole(void)
 static void cleanup_netconsole(void)
 {
        unregister_console(&netconsole);
-       netpoll_cleanup(&np);
+
+       if (configured)
+               netpoll_cleanup(&np);
+
+       if (netlog_configured)
+               netpoll_cleanup(&netlog_np);
 }
 
 module_init(init_netconsole);
diff --git a/drivers/net/netdump.c b/drivers/net/netdump.c
new file mode 100644 (file)
index 0000000..3ebea07
--- /dev/null
@@ -0,0 +1,534 @@
+/*
+ *  linux/drivers/net/netdump.c
+ *
+ *  Copyright (C) 2001  Ingo Molnar <mingo@redhat.com>
+ *  Copyright (C) 2002  Red Hat, Inc.
+ *  Copyright (C) 2004  Red Hat, Inc.
+ *
+ *  This file contains the implementation of an IRQ-safe, crash-safe
+ *  kernel console implementation that outputs kernel messages to the
+ *  network.
+ *
+ * Modification history:
+ *
+ * 2001-09-17    started by Ingo Molnar.
+ * 2002-03-14    simultaneous syslog packet option by Michael K. Johnson
+ * 2004-04-07    port to 2.6 netpoll facility by Dave Anderson and Jeff Moyer.
+ */
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/random.h>
+#include <linux/reboot.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <asm/unaligned.h>
+#include <asm/pgtable.h>
+#include <linux/console.h>
+#include <linux/smp_lock.h>
+#include <linux/elf.h>
+#include <linux/preempt.h>
+
+#include "netdump.h"
+#include <linux/netpoll.h>
+
+/*
+ *  prototypes.
+ */
+void netdump_rx(struct netpoll *np, short source, char *data, int dlen);
+static void send_netdump_msg(struct netpoll *np, const char *msg, unsigned int msg_len, reply_t *reply);
+static void send_netdump_mem(struct netpoll *np, req_t *req);
+static void netdump_startup_handshake(struct netpoll *np);
+static void netpoll_netdump(struct pt_regs *regs);
+static void netpoll_start_netdump(struct pt_regs *regs);
+
+
+#include <asm/netdump.h>
+
+
+#undef Dprintk
+#define DEBUG 0
+#if DEBUG
+# define Dprintk(x...) printk(KERN_INFO x)
+#else
+# define Dprintk(x...)
+#endif
+
+MODULE_AUTHOR("Maintainer: Dave Anderson <anderson@redhat.com>");
+MODULE_DESCRIPTION("Network kernel crash dump module");
+MODULE_LICENSE("GPL");
+
+static char config[256];
+module_param_string(netdump, config, 256, 0);
+MODULE_PARM_DESC(netdump, 
+     " netdump=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n");
+
+static u32 magic1, magic2;
+module_param(magic1, uint, 000);
+module_param(magic2, uint, 000);
+
+static struct netpoll np = {
+       .name = "netdump",
+       .dev_name = "eth0",
+       .local_port = 6666,
+       .remote_port = 6666,
+       .remote_mac = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       .rx_hook = netdump_rx,
+       .dump_func = netpoll_start_netdump,
+};
+
+
+/*
+ * NOTE: security depends on the trusted path between the netconsole
+ *       server and netconsole client, since none of the packets are
+ *       encrypted. The random magic number protects the protocol
+ *       against spoofing.
+ */
+static u64 netdump_magic;
+
+static spinlock_t req_lock = SPIN_LOCK_UNLOCKED;
+static int nr_req = 0;
+static LIST_HEAD(request_list);
+
+static unsigned long long t0, jiffy_cycles;
+void *netdump_stack;
+
+
+static void update_jiffies(void)
+{
+       static unsigned long long prev_tick;
+       platform_timestamp(t0);
+
+       /* maintain jiffies in a polling fashion, based on rdtsc. */
+       if (t0 - prev_tick >= jiffy_cycles) {
+               prev_tick += jiffy_cycles;
+               jiffies++;
+       }
+}
+
+static void add_new_req(req_t *req)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&req_lock, flags);
+       list_add_tail(&req->list, &request_list);
+       nr_req++;
+       Dprintk("pending requests: %d.\n", nr_req);
+       spin_unlock_irqrestore(&req_lock, flags);
+}
+
+static req_t *get_new_req(void)
+{
+       req_t *req = NULL;
+       unsigned long flags;
+
+       update_jiffies();
+
+       spin_lock_irqsave(&req_lock, flags);
+       if (nr_req) {
+               req = list_entry(request_list.next, req_t, list);
+               list_del(&req->list);
+               nr_req--;
+       }
+       spin_unlock_irqrestore(&req_lock, flags);
+
+       return req;
+}
+
+static req_t *alloc_req(void)
+{
+       req_t *req;
+
+       req = (req_t *) kmalloc(sizeof(*req), GFP_ATOMIC);
+       return req;
+}
+
+static inline void print_status (req_t *req)
+{
+       static int count = 0;
+       static int prev_jiffies = 0;
+
+       if (jiffies/HZ != prev_jiffies/HZ) {
+               prev_jiffies = jiffies;
+               count++;
+               switch (count & 3) {
+                       case 0: printk("%d(%ld)/\r", nr_req, jiffies); break;
+                       case 1: printk("%d(%ld)|\r", nr_req, jiffies); break;
+                       case 2: printk("%d(%ld)\\\r", nr_req, jiffies); break;
+                       case 3: printk("%d(%ld)-\r", nr_req, jiffies); break;
+               }
+       }
+}
+
+void netdump_rx(struct netpoll *np, short source, char *data, int dlen)
+{
+       req_t *req, *__req = (req_t *)data;
+
+       if (!netdump_mode)
+               return;
+#if DEBUG
+       {
+               static int packet_count;
+               Dprintk("        %d\r", ++packet_count);
+       }
+#endif
+
+       if (dlen < NETDUMP_REQ_SIZE) {
+               Dprintk("... netdump_rx: len not ok.\n");
+               return;
+       }
+
+       req = alloc_req();
+       if (!req) {
+               printk("no more RAM to allocate request - dropping it.\n");
+               return;
+       }
+
+       req->magic = ntohl(__req->magic);
+       req->command = ntohl(__req->command);
+       req->from = ntohl(__req->from);
+       req->to = ntohl(__req->to);
+       req->nr = ntohl(__req->nr);
+
+       Dprintk("... netdump magic:   %08Lx.\n", req->magic);
+       Dprintk("... netdump command: %08x.\n", req->command);
+       Dprintk("... netdump from:    %08x.\n", req->from);
+       Dprintk("... netdump to:      %08x.\n", req->to);
+
+       add_new_req(req);
+       return;
+}
+
+#define MAX_MSG_LEN HEADER_LEN + 1024
+
+static void send_netdump_msg(struct netpoll *np, const char *msg, unsigned int msg_len, reply_t *reply)
+{
+       /* max len should be 1024 + HEADER_LEN */
+       static unsigned char netpoll_msg[MAX_MSG_LEN + 1];
+
+       if (msg_len + HEADER_LEN > MAX_MSG_LEN + 1) {
+               printk("CODER ERROR!!! msg_len %ud too big for send msg\n",
+                      msg_len);
+               for (;;) local_irq_disable();
+               /* NOTREACHED */
+       }
+
+       netpoll_msg[0] = NETDUMP_VERSION;
+       put_unaligned(htonl(reply->nr), (u32 *) (&netpoll_msg[1]));
+       put_unaligned(htonl(reply->code), (u32 *) (&netpoll_msg[5]));
+       put_unaligned(htonl(reply->info), (u32 *) (&netpoll_msg[9]));
+       memcpy(&netpoll_msg[HEADER_LEN], msg, msg_len);
+
+       netpoll_send_udp(np, netpoll_msg, HEADER_LEN + msg_len);
+}
+
+static void send_netdump_mem(struct netpoll *np, req_t *req)
+{
+       int i;
+       char *kaddr;
+       char str[1024];
+       struct page *page;
+       unsigned long nr = req->from;
+       int nr_chunks = PAGE_SIZE/1024;
+       reply_t reply;
+       
+       Dprintk(" ... send_netdump_mem\n");
+       reply.nr = req->nr;
+       reply.info = 0;
+       if (req->from >= platform_max_pfn()) {
+               sprintf(str, "page %08lx is bigger than max page # %08lx!\n", 
+                       nr, platform_max_pfn());
+               reply.code = REPLY_ERROR;
+               send_netdump_msg(np, str, strlen(str), &reply);
+               return;
+       }
+       if (page_is_ram(nr))
+               page = pfn_to_page(nr);
+       else
+               page = ZERO_PAGE(0);
+
+       kaddr = (char *)kmap_atomic(page, KM_NETDUMP);
+
+       for (i = 0; i < nr_chunks; i++) {
+               unsigned int offset = i*1024;
+               reply.code = REPLY_MEM;
+               reply.info = offset;
+               Dprintk(" ... send_netdump_mem: sending message\n");
+               send_netdump_msg(np, kaddr + offset, 1024, &reply);
+               Dprintk(" ... send_netdump_mem: sent message\n");
+       }
+
+       kunmap_atomic(kaddr, KM_NETDUMP);
+       Dprintk(" ... send_netdump_mem: returning\n");
+}
+
+/*
+ * This function waits for the client to acknowledge the receipt
+ * of the netdump startup reply, with the possibility of packets
+ * getting lost. We resend the startup packet if no ACK is received,
+ * after a 1 second delay.
+ *
+ * (The client can test the success of the handshake via the HELLO
+ * command, and send ACKs until we enter netdump mode.)
+ */
+static void netdump_startup_handshake(struct netpoll *np)
+{
+       char tmp[200];
+       reply_t reply;
+       req_t *req = NULL;
+       int i;
+
+repeat:
+       sprintf(tmp, "NETDUMP start, waiting for start-ACK.\n");
+       reply.code = REPLY_START_NETDUMP;
+       reply.nr = 0;
+       reply.info = 0;
+
+       send_netdump_msg(np, tmp, strlen(tmp), &reply);
+
+       for (i = 0; i < 10000; i++) {
+               // wait 1 sec.
+               udelay(100);
+               Dprintk("handshake: polling controller ...\n");
+               netpoll_poll(np);
+               req = get_new_req();
+               if (req)
+                       break;
+       }
+       if (!req)
+               goto repeat;
+       if (req->command != COMM_START_NETDUMP_ACK) {
+               kfree(req);
+               goto repeat;
+       }
+       kfree(req);
+
+       printk("NETDUMP START!\n");
+}
+
+static char cpus_frozen[NR_CPUS] = { 0 }; 
+
+static void freeze_cpu (void * dummy)
+{
+       cpus_frozen[smp_processor_id()] = 1;
+       for (;;) local_irq_disable();
+}
+
+static void netpoll_start_netdump(struct pt_regs *regs)
+{
+       int i;
+       unsigned long flags;
+
+       /*
+        *  The netdump code is not re-entrant for several reasons.  Most
+        *  immediately, we will switch to the base of our stack and 
+        *  overwrite all of our call history.
+        */
+       if (netdump_mode) {
+               printk(KERN_ERR
+               "netpoll_start_netdump: called recursively.  rebooting.\n");
+               mdelay(3000);
+               machine_restart(NULL);
+       }
+       netdump_mode = 1;
+
+       local_irq_save(flags);
+       preempt_disable();
+
+       smp_call_function(freeze_cpu, NULL, 1, -1);
+       mdelay(3000);
+       for (i = 0; i < NR_CPUS; i++) {
+               if (cpus_frozen[i])
+                       printk("CPU#%d is frozen.\n", i);
+               else if (i == smp_processor_id())
+                       printk("CPU#%d is executing netdump.\n", i);
+       }
+
+       /*
+        *  Some platforms may want to execute netdump on its own stack.
+        */
+       platform_start_netdump(netdump_stack, regs);
+
+       preempt_enable_no_resched();
+       local_irq_restore(flags);
+       return;
+}
+
+static void netpoll_netdump(struct pt_regs *regs)
+{
+       reply_t reply;
+       char tmp[200];
+       struct pt_regs myregs;
+       req_t *req;
+
+       /*
+        * Just in case we are crashing within the networking code
+        * ... attempt to fix up.
+        */
+       netpoll_reset_locks(&np);
+       platform_fix_regs();
+       platform_timestamp(t0);
+       netpoll_set_trap(1); /* bypass networking stack */
+
+       printk("< netdump activated - performing handshake with the server. >\n");
+       netdump_startup_handshake(&np);
+
+       printk("< handshake completed - listening for dump requests. >\n");
+
+       while (netdump_mode) {
+               local_irq_disable();
+               Dprintk("main netdump loop: polling controller ...\n");
+               netpoll_poll(&np);
+
+               req = get_new_req();
+               if (!req)
+                       continue;
+
+               Dprintk("got new req, command %d.\n", req->command);
+               print_status(req);
+               switch (req->command) {
+               case COMM_NONE:
+                       Dprintk("got NO command.\n");
+                       break;
+
+               case COMM_SEND_MEM:
+                       Dprintk("got MEM command.\n");
+                       send_netdump_mem(&np, req);
+                       break;
+
+               case COMM_EXIT:
+                       Dprintk("got EXIT command.\n");
+                       netdump_mode = 0;
+                       netpoll_set_trap(0);
+                       break;
+
+               case COMM_REBOOT:
+                       Dprintk("got REBOOT command.\n");
+                       printk("netdump: rebooting in 3 seconds.\n");
+                       mdelay(3000);
+                       machine_restart(NULL);
+                       break;
+
+               case COMM_HELLO:
+                       sprintf(tmp, "Hello, this is netdump version 0.%02d\n",
+                               NETDUMP_VERSION);
+                       reply.code = REPLY_HELLO;
+                       reply.nr = req->nr;
+                       reply.info = NETDUMP_VERSION;
+                       send_netdump_msg(&np, tmp, strlen(tmp), &reply);
+                       break;
+
+               case COMM_GET_PAGE_SIZE:
+                       sprintf(tmp, "PAGE_SIZE: %ld\n", PAGE_SIZE);
+                       reply.code = REPLY_PAGE_SIZE;
+                       reply.nr = req->nr;
+                       reply.info = PAGE_SIZE;
+                       send_netdump_msg(&np, tmp, strlen(tmp), &reply);
+                       break;
+
+               case COMM_GET_REGS:
+               {
+                       char *tmp2 = tmp;
+                       elf_gregset_t elf_regs;
+
+                       reply.code = REPLY_REGS;
+                       reply.nr = req->nr;
+                       reply.info = platform_max_pfn();
+                       tmp2 = tmp + sprintf(tmp, "Sending register info.\n");
+                       ELF_CORE_COPY_REGS(elf_regs, (&myregs));
+                       memcpy(tmp2, &elf_regs, sizeof(elf_regs));
+                       Dprintk("netdump: sending regs\n");
+                       send_netdump_msg(&np, tmp, 
+                               strlen(tmp) + sizeof(elf_regs), &reply);
+                       Dprintk("netdump: sent regs\n");
+                       break;
+               }
+
+               case COMM_GET_NR_PAGES:
+                       reply.code = REPLY_NR_PAGES;
+                       reply.nr = req->nr;
+                       reply.info = platform_max_pfn();
+                       sprintf(tmp, 
+                               "Number of pages: %ld\n", platform_max_pfn());
+                       send_netdump_msg(&np, tmp, strlen(tmp), &reply);
+                       break;
+
+               case COMM_SHOW_STATE:
+                       /* send response first */
+                       reply.code = REPLY_SHOW_STATE;
+                       reply.nr = req->nr;
+                       reply.info = 0;
+
+                       send_netdump_msg(&np, tmp, strlen(tmp), &reply);
+
+                       netdump_mode = 0;
+                       if (regs)
+                               show_regs(regs);
+                       show_state();
+                       show_mem();
+                       netdump_mode = 1;
+                       break;
+
+               default:
+                       reply.code = REPLY_ERROR;
+                       reply.nr = req->nr;
+                       reply.info = req->command;
+                       Dprintk("got UNKNOWN command!\n");
+                       sprintf(tmp, "Got unknown command code %d!\n", 
+                               req->command);
+                       send_netdump_msg(&np, tmp, strlen(tmp), &reply);
+                       break;
+               }
+               kfree(req);
+               req = NULL;
+       }
+       sprintf(tmp, "NETDUMP end.\n");
+       reply.code = REPLY_END_NETDUMP;
+       reply.nr = 0;
+       reply.info = 0;
+       send_netdump_msg(&np, tmp, strlen(tmp), &reply);
+       printk("NETDUMP END!\n");
+}
+
+static int option_setup(char *opt)
+{
+       return !netpoll_parse_options(&np, opt);
+}
+
+__setup("netdump=", option_setup);
+
+static int init_netdump(void)
+{
+       int configured = 0;
+
+       if (strlen(config))
+               configured = option_setup(config);
+
+       if (!configured) {
+               printk(KERN_ERR "netdump: not configured, aborting\n");
+               return -EINVAL;
+       }
+
+       if (netpoll_setup(&np))
+               return -EINVAL;
+
+       if (magic1 || magic2)
+               netdump_magic = magic1 + (((u64)magic2)<<32);
+
+       /*
+        *  Allocate a separate stack for netdump.
+        */
+       platform_init_stack(&netdump_stack);
+
+       printk(KERN_INFO "netdump: network crash dump enabled\n");
+       return 0;
+}
+
+static void cleanup_netdump(void)
+{
+       netpoll_cleanup(&np);
+       platform_cleanup_stack(netdump_stack);
+}
+
+module_init(init_netdump);
+module_exit(cleanup_netdump);
diff --git a/drivers/net/netdump.h b/drivers/net/netdump.h
new file mode 100644 (file)
index 0000000..cc3100e
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ *  linux/drivers/net/netdump.h
+ *
+ *  Copyright (C) 2001  Ingo Molnar <mingo@redhat.com>
+ *
+ *  This file contains the implementation of an IRQ-safe, crash-safe
+ *  kernel console implementation that outputs kernel messages to the
+ *  network.
+ *
+ * Modification history:
+ *
+ * 2001-09-17    started by Ingo Molnar.
+ */
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+#define NETDUMP_VERSION 0x04
+
+enum netdump_commands {
+       COMM_NONE = 0,
+       COMM_SEND_MEM = 1,
+       COMM_EXIT = 2,
+       COMM_REBOOT = 3,
+       COMM_HELLO = 4,
+       COMM_GET_NR_PAGES = 5,
+       COMM_GET_PAGE_SIZE = 6,
+       COMM_START_NETDUMP_ACK = 7,
+       COMM_GET_REGS = 8,
+       COMM_SHOW_STATE = 9,
+};
+
+#define NETDUMP_REQ_SIZE (8+4*4)
+
+typedef struct netdump_req_s {
+       u64 magic;
+       u32 nr;
+       u32 command;
+       u32 from;
+       u32 to;
+       struct list_head list; 
+} req_t;
+
+enum netdump_replies {
+       REPLY_NONE = 0,
+       REPLY_ERROR = 1,
+       REPLY_LOG = 2,
+       REPLY_MEM = 3,
+       REPLY_RESERVED = 4,
+       REPLY_HELLO = 5,
+       REPLY_NR_PAGES = 6,
+       REPLY_PAGE_SIZE = 7,
+       REPLY_START_NETDUMP = 8,
+       REPLY_END_NETDUMP = 9,
+       REPLY_REGS = 10,
+       REPLY_MAGIC = 11,
+       REPLY_SHOW_STATE = 12,
+};
+
+typedef struct netdump_reply_s {
+       u32 nr;
+       u32 code;
+       u32 info;
+} reply_t;
+
+#define HEADER_LEN (1 + sizeof(reply_t))
+
diff --git a/drivers/net/rcif.h b/drivers/net/rcif.h
deleted file mode 100644 (file)
index 85ff861..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-** *************************************************************************
-**
-**
-**     R C I F . H
-**
-**
-**  RedCreek InterFace include file.
-**
-**  ---------------------------------------------------------------------
-**  ---     Copyright (c) 1998-1999, RedCreek Communications Inc.     ---
-**  ---                   All rights reserved.                        ---
-**  ---------------------------------------------------------------------
-**
-** File Description:
-**
-** Header file private ioctl commands.
-**
-**
-**  This program is free software; you can redistribute it and/or modify
-**  it under the terms of the GNU General Public License as published by
-**  the Free Software Foundation; either version 2 of the License, or
-**  (at your option) any later version.
-
-**  This program is distributed in the hope that it will be useful,
-**  but WITHOUT ANY WARRANTY; without even the implied warranty of
-**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-**  GNU General Public License for more details.
-
-**  You should have received a copy of the GNU General Public License
-**  along with this program; if not, write to the Free Software
-**  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-** *************************************************************************
-*/
-
-#ifndef RCIF_H
-#define RCIF_H
-
-/* The following protocol revision # should be incremented every time
-   a new protocol or new structures are used in this file. */
-int USER_PROTOCOL_REV = 2;     /* used to track different protocol revisions */
-
-/* define a single TCB & buffer */
-typedef struct {               /* a single buffer */
-       U32 context;            /* context */
-       U32 scount;             /* segment count */
-       U32 size;               /* segment size */
-       U32 addr;               /* segment physical address */
-} __attribute__ ((packed))
-    singleB, *psingleB;
-typedef struct {               /* a single TCB */
-       /*
-          **  +-----------------------+
-          **  |         1             |  one buffer in the TCB
-          **  +-----------------------+
-          **  |  <user's Context>     |  user's buffer reference
-          **  +-----------------------+
-          **  |         1             |  one segment buffer
-          **  +-----------------------+                            _
-          **  |    <buffer size>      |  size                       \ 
-          **  +-----------------------+                              \ segment descriptor
-          **  |  <physical address>   |  physical address of buffer  /
-          **  +-----------------------+                            _/
-        */
-       U32 bcount;             /* buffer count */
-       singleB b;              /* buffer */
-
-} __attribute__ ((packed))
-    singleTCB, *psingleTCB;
-
-/*
-   When adding new entries, please add all 5 related changes, since 
-   it helps keep everything consistent:
-      1) User structure entry
-      2) User data entry
-      3) Structure short-cut entry
-      4) Data short-cut entry
-      5) Command identifier entry
-
-   For Example ("GETSPEED"):
-      1) struct  RCgetspeed_tag { U32 LinkSpeedCode; } RCgetspeed;
-      2) struct  RCgetspeed_tag *getspeed;
-      3) #define RCUS_GETSPEED  data.RCgetspeed;
-      4) #define RCUD_GETSPEED  _RC_user_data.getspeed
-      5) #define RCUC_GETSPEED  0x02
-  
-   Notes for the "GETSPEED" entry, above:
-      1) RCgetspeed      - RC{name}
-         RCgetspeed_tag  - RC{name}_tag
-         LinkSpeedCode   - create any structure format desired (not too large,
-                           since memory will be unioned with all other entries)
-      2) RCgetspeed_tag  - RC{name}_tag chosen in #1
-         getspeed        - arbitrary name (ptr to structure in #1)
-      3) RCUS_GETSPEED   - RCUS_{NAME}   ("NAME" & "name" do not have to the same)
-         data.RCgetspeed - data.RC{name}  ("RC{name}" from #1)
-      4) RCUD_GETSPEED   - _RC_user_data.getspeed  ("getspeed" from #2)
-      5) RCUC_GETSPEED   - unique hex identifier entry.
-*/
-
-typedef struct RC_user_tag RCuser_struct;
-
-/* 1) User structure entry */
-struct RC_user_tag {
-       int cmd;
-       union {
-               /* GETINFO structure */
-               struct RCgetinfo_tag {
-                       unsigned long int mem_start;
-                       unsigned long int mem_end;
-                       unsigned long int base_addr;
-                       unsigned char irq;
-                       unsigned char dma;
-                       unsigned char port;
-               } RCgetinfo;    /* <---- RCgetinfo */
-
-               /* GETSPEED structure */
-               struct RCgetspeed_tag {
-                       U32 LinkSpeedCode;
-               } RCgetspeed;   /* <---- RCgetspeed */
-
-               /* SETSPEED structure */
-               struct RCsetspeed_tag {
-                       U16 LinkSpeedCode;
-               } RCsetspeed;   /* <---- RCsetspeed */
-
-               /* GETPROM structure */
-               struct RCgetprom_tag {
-                       U32 PromMode;
-               } RCgetprom;    /* <---- RCgetprom */
-
-               /* SETPROM structure */
-               struct RCsetprom_tag {
-                       U16 PromMode;
-               } RCsetprom;    /* <---- RCsetprom */
-
-               /* GETBROADCAST structure */
-               struct RCgetbroadcast_tag {
-                       U32 BroadcastMode;
-               } RCgetbroadcast;       /* <---- RCgetbroadcast */
-
-               /* SETBROADCAST structure */
-               struct RCsetbroadcast_tag {
-                       U16 BroadcastMode;
-               } RCsetbroadcast;       /* <---- RCsetbroadcast */
-
-               /* GETFIRMWAREVER structure */
-#define FirmStringLen 80
-               struct RCgetfwver_tag {
-                       U8 FirmString[FirmStringLen];
-               } RCgetfwver;   /* <---- RCgetfwver */
-
-               /* GETIPANDMASK structure */
-               struct RCgetipnmask_tag {
-                       U32 IpAddr;
-                       U32 NetMask;
-               } RCgetipandmask;       /* <---- RCgetipandmask */
-
-               /* SETIPANDMASK structure */
-               struct RCsetipnmask_tag {
-                       U32 IpAddr;
-                       U32 NetMask;
-               } RCsetipandmask;       /* <---- RCsetipandmask */
-
-               /* GETMAC structure */
-#define MAC_SIZE 10
-               struct RCgetmac_tag {
-                       U8 mac[MAC_SIZE];
-               } RCgetmac;     /* <---- RCgetmac */
-
-               /* SETMAC structure */
-               struct RCsetmac_tag {
-                       U8 mac[MAC_SIZE];
-               } RCsetmac;     /* <---- RCsetmac */
-
-               /* GETLINKSTATUS structure */
-               struct RCgetlnkstatus_tag {
-                       U32 ReturnStatus;
-               } RCgetlnkstatus;       /* <---- RCgetlnkstatus */
-
-               /* GETLINKSTATISTICS structure */
-               struct RCgetlinkstats_tag {
-                       RCLINKSTATS StatsReturn;
-               } RCgetlinkstats;       /* <---- RCgetlinkstats */
-
-               /* DEFAULT structure (when no command was recognized) */
-               struct RCdefault_tag {
-                       int rc;
-               } RCdefault;    /* <---- RCdefault */
-
-       } data;
-
-};                             /* struct RC_user_tag { ... } */
-
-/* 2) User data entry */
-/* RCUD = RedCreek User Data */
-union RC_user_data_tag {       /* structure tags used are taken from RC_user_tag structure above */
-       struct RCgetinfo_tag *getinfo;
-       struct RCgetspeed_tag *getspeed;
-       struct RCgetprom_tag *getprom;
-       struct RCgetbroadcast_tag *getbroadcast;
-       struct RCgetfwver_tag *getfwver;
-       struct RCgetipnmask_tag *getipandmask;
-       struct RCgetmac_tag *getmac;
-       struct RCgetlnkstatus_tag *getlinkstatus;
-       struct RCgetlinkstats_tag *getlinkstatistics;
-       struct RCdefault_tag *rcdefault;
-       struct RCsetspeed_tag *setspeed;
-       struct RCsetprom_tag *setprom;
-       struct RCsetbroadcast_tag *setbroadcast;
-       struct RCsetipnmask_tag *setipandmask;
-       struct RCsetmac_tag *setmac;
-} _RC_user_data;               /* declare as a global, so the defines below will work */
-
-/* 3) Structure short-cut entry */
-/* define structure short-cuts *//* structure names are taken from RC_user_tag structure above */
-#define RCUS_GETINFO           data.RCgetinfo;
-#define RCUS_GETSPEED          data.RCgetspeed;
-#define RCUS_GETPROM           data.RCgetprom;
-#define RCUS_GETBROADCAST      data.RCgetbroadcast;
-#define RCUS_GETFWVER          data.RCgetfwver;
-#define RCUS_GETIPANDMASK      data.RCgetipandmask;
-#define RCUS_GETMAC            data.RCgetmac;
-#define RCUS_GETLINKSTATUS     data.RCgetlnkstatus;
-#define RCUS_GETLINKSTATISTICS data.RCgetlinkstats;
-#define RCUS_DEFAULT           data.RCdefault;
-#define RCUS_SETSPEED          data.RCsetspeed;
-#define RCUS_SETPROM           data.RCsetprom;
-#define RCUS_SETBROADCAST      data.RCsetbroadcast;
-#define RCUS_SETIPANDMASK      data.RCsetipandmask;
-#define RCUS_SETMAC            data.RCsetmac;
-
-/* 4) Data short-cut entry */
-/* define data short-cuts *//* pointer names are from RC_user_data_tag union (just below RC_user_tag) */
-#define RCUD_GETINFO           _RC_user_data.getinfo
-#define RCUD_GETSPEED          _RC_user_data.getspeed
-#define RCUD_GETPROM           _RC_user_data.getprom
-#define RCUD_GETBROADCAST      _RC_user_data.getbroadcast
-#define RCUD_GETFWVER          _RC_user_data.getfwver
-#define RCUD_GETIPANDMASK      _RC_user_data.getipandmask
-#define RCUD_GETMAC            _RC_user_data.getmac
-#define RCUD_GETLINKSTATUS     _RC_user_data.getlinkstatus
-#define RCUD_GETLINKSTATISTICS _RC_user_data.getlinkstatistics
-#define RCUD_DEFAULT           _RC_user_data.rcdefault
-#define RCUD_SETSPEED          _RC_user_data.setspeed
-#define RCUD_SETPROM           _RC_user_data.setprom
-#define RCUD_SETBROADCAST      _RC_user_data.setbroadcast
-#define RCUD_SETIPANDMASK      _RC_user_data.setipandmask
-#define RCUD_SETMAC            _RC_user_data.setmac
-
-/* 5) Command identifier entry */
-/* define command identifiers */
-#define RCUC_GETINFO            0x01
-#define RCUC_GETSPEED           0x02
-#define RCUC_GETFWVER           0x03
-#define RCUC_GETIPANDMASK       0x04
-#define RCUC_GETMAC             0x05
-#define RCUC_GETLINKSTATUS      0x06
-#define RCUC_GETLINKSTATISTICS  0x07
-#define RCUC_GETPROM            0x14
-#define RCUC_GETBROADCAST       0x15
-#define RCUC_DEFAULT            0xff
-#define RCUC_SETSPEED           0x08
-#define RCUC_SETIPANDMASK       0x09
-#define RCUC_SETMAC             0x0a
-#define RCUC_SETPROM            0x16
-#define RCUC_SETBROADCAST       0x17
-
-/* define ioctl commands to use, when talking to RC 45/PCI driver */
-#define RCU_PROTOCOL_REV         SIOCDEVPRIVATE
-#define RCU_COMMAND              SIOCDEVPRIVATE+1
-
-/*
-   Intended use for the above defines is shown below (GETINFO, as this example):
-
-      RCuser_struct RCuser;           // declare RCuser structure
-      struct ifreq ifr;               // declare an interface request structure
-
-      RCuser.cmd = RCUC_GETINFO;           // set user command to GETINFO
-      ifr->ifr_data = (caddr_t) &RCuser;   // set point to user structure
-
-      sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);   // get a socket
-      ioctl(sock, RCU_COMMAND, &ifr);                  // do ioctl on socket
-
-      RCUD_GETINFO = &RCuser.RCUS_GETINFO;   // set data pointer for GETINFO
-
-      // print results
-      printf("memory 0x%lx-0x%lx, base address 0x%x, irq 0x%x\n",
-              RCUD_GETINFO->mem_start, RCUD_GETINFO->mem_end,
-              RCUD_GETINFO->base_addr, RCUD_GETINFO->irq);
-*/
-
-#endif                         /* RCIF_H */
diff --git a/drivers/net/rclanmtl.c b/drivers/net/rclanmtl.c
deleted file mode 100644 (file)
index 14bd88a..0000000
+++ /dev/null
@@ -1,2029 +0,0 @@
-/*
-** *************************************************************************
-**
-**
-**     R C L A N M T L . C             $Revision: 6 $
-**
-**
-**  RedCreek I2O LAN Message Transport Layer program module.
-**
-**  ---------------------------------------------------------------------
-**  ---     Copyright (c) 1997-1999, RedCreek Communications Inc.     ---
-**  ---                   All rights reserved.                        ---
-**  ---------------------------------------------------------------------
-**
-**  File Description:
-**
-**  Host side I2O (Intelligent I/O) LAN message transport layer.
-**
-**  This program is free software; you can redistribute it and/or modify
-**  it under the terms of the GNU General Public License as published by
-**  the Free Software Foundation; either version 2 of the License, or
-**  (at your option) any later version.
-
-**  This program is distributed in the hope that it will be useful,
-**  but WITHOUT ANY WARRANTY; without even the implied warranty of
-**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-**  GNU General Public License for more details.
-
-**  You should have received a copy of the GNU General Public License
-**  along with this program; if not, write to the Free Software
-**  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** 1998-1999, LAN API was modified and enhanced by Alice Hennessy.
-**
-** Sometime in 1997, LAN API was written from scratch by Wendell Nichols.
-** *************************************************************************
-*/
-
-#define DEBUG 1
-
-#define RC_LINUX_MODULE
-#include "rclanmtl.h"
-
- /* RedCreek LAN device Target ID */
-#define RC_LAN_TARGET_ID  0x10
- /* RedCreek's OSM default LAN receive Initiator */
-#define DEFAULT_RECV_INIT_CONTEXT  0xA17
-
-/*
-** I2O message structures
-*/
-
-#define    I2O_TID_SZ                                  12
-#define    I2O_FUNCTION_SZ                             8
-
-/* Transaction Reply Lists (TRL) Control Word structure */
-
-#define    I2O_TRL_FLAGS_SINGLE_FIXED_LENGTH           0x00
-#define    I2O_TRL_FLAGS_SINGLE_VARIABLE_LENGTH        0x40
-#define    I2O_TRL_FLAGS_MULTIPLE_FIXED_LENGTH         0x80
-
-/* LAN Class specific functions */
-
-#define    I2O_LAN_PACKET_SEND                         0x3B
-#define    I2O_LAN_SDU_SEND                            0x3D
-#define    I2O_LAN_RECEIVE_POST                        0x3E
-#define    I2O_LAN_RESET                               0x35
-#define    I2O_LAN_SHUTDOWN                            0x37
-
-/* Private Class specfic function */
-#define    I2O_PRIVATE                                 0xFF
-
-/*  I2O Executive Function Codes.  */
-
-#define    I2O_EXEC_ADAPTER_ASSIGN                     0xB3
-#define    I2O_EXEC_ADAPTER_READ                       0xB2
-#define    I2O_EXEC_ADAPTER_RELEASE                    0xB5
-#define    I2O_EXEC_BIOS_INFO_SET                      0xA5
-#define    I2O_EXEC_BOOT_DEVICE_SET                    0xA7
-#define    I2O_EXEC_CONFIG_VALIDATE                    0xBB
-#define    I2O_EXEC_CONN_SETUP                         0xCA
-#define    I2O_EXEC_DEVICE_ASSIGN                      0xB7
-#define    I2O_EXEC_DEVICE_RELEASE                     0xB9
-#define    I2O_EXEC_HRT_GET                            0xA8
-#define    I2O_EXEC_IOP_CLEAR                          0xBE
-#define    I2O_EXEC_IOP_CONNECT                        0xC9
-#define    I2O_EXEC_IOP_RESET                          0xBD
-#define    I2O_EXEC_LCT_NOTIFY                         0xA2
-#define    I2O_EXEC_OUTBOUND_INIT                      0xA1
-#define    I2O_EXEC_PATH_ENABLE                        0xD3
-#define    I2O_EXEC_PATH_QUIESCE                       0xC5
-#define    I2O_EXEC_PATH_RESET                         0xD7
-#define    I2O_EXEC_STATIC_MF_CREATE                   0xDD
-#define    I2O_EXEC_STATIC_MF_RELEASE                  0xDF
-#define    I2O_EXEC_STATUS_GET                         0xA0
-#define    I2O_EXEC_SW_DOWNLOAD                        0xA9
-#define    I2O_EXEC_SW_UPLOAD                          0xAB
-#define    I2O_EXEC_SW_REMOVE                          0xAD
-#define    I2O_EXEC_SYS_ENABLE                         0xD1
-#define    I2O_EXEC_SYS_MODIFY                         0xC1
-#define    I2O_EXEC_SYS_QUIESCE                        0xC3
-#define    I2O_EXEC_SYS_TAB_SET                        0xA3
-
- /* Init Outbound Q status */
-#define    I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS          0x01
-#define    I2O_EXEC_OUTBOUND_INIT_REJECTED             0x02
-#define    I2O_EXEC_OUTBOUND_INIT_FAILED               0x03
-#define    I2O_EXEC_OUTBOUND_INIT_COMPLETE             0x04
-
-#define    I2O_UTIL_NOP                                0x00
-
-/* I2O Get Status State values */
-
-#define    I2O_IOP_STATE_INITIALIZING                  0x01
-#define    I2O_IOP_STATE_RESET                         0x02
-#define    I2O_IOP_STATE_HOLD                          0x04
-#define    I2O_IOP_STATE_READY                         0x05
-#define    I2O_IOP_STATE_OPERATIONAL                   0x08
-#define    I2O_IOP_STATE_FAILED                        0x10
-#define    I2O_IOP_STATE_FAULTED                       0x11
-
-/* Defines for Request Status Codes:  Table 3-1 Reply Status Codes.  */
-
-#define    I2O_REPLY_STATUS_SUCCESS                    0x00
-#define    I2O_REPLY_STATUS_ABORT_DIRTY                0x01
-#define    I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER     0x02
-#define    I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER     0x03
-#define    I2O_REPLY_STATUS_ERROR_DIRTY                0x04
-#define    I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER     0x05
-#define    I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER     0x06
-#define    I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY        0x07
-#define    I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER   0x08
-#define    I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER   0x09
-#define    I2O_REPLY_STATUS_TRANSACTION_ERROR          0x0A
-#define    I2O_REPLY_STATUS_PROGRESS_REPORT            0x80
-
-/* DetailedStatusCode defines for ALL messages: Table 3-2 Detailed Status Codes.*/
-
-#define    I2O_DETAIL_STATUS_SUCCESS                        0x0000
-#define    I2O_DETAIL_STATUS_BAD_KEY                        0x0001
-#define    I2O_DETAIL_STATUS_CHAIN_BUFFER_TOO_LARGE         0x0002
-#define    I2O_DETAIL_STATUS_DEVICE_BUSY                    0x0003
-#define    I2O_DETAIL_STATUS_DEVICE_LOCKED                  0x0004
-#define    I2O_DETAIL_STATUS_DEVICE_NOT_AVAILABLE           0x0005
-#define    I2O_DETAIL_STATUS_DEVICE_RESET                   0x0006
-#define    I2O_DETAIL_STATUS_INAPPROPRIATE_FUNCTION         0x0007
-#define    I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_HARD     0x0008
-#define    I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_SOFT     0x0009
-#define    I2O_DETAIL_STATUS_INVALID_INITIATOR_ADDRESS      0x000A
-#define    I2O_DETAIL_STATUS_INVALID_MESSAGE_FLAGS          0x000B
-#define    I2O_DETAIL_STATUS_INVALID_OFFSET                 0x000C
-#define    I2O_DETAIL_STATUS_INVALID_PARAMETER              0x000D
-#define    I2O_DETAIL_STATUS_INVALID_REQUEST                0x000E
-#define    I2O_DETAIL_STATUS_INVALID_TARGET_ADDRESS         0x000F
-#define    I2O_DETAIL_STATUS_MESSAGE_TOO_LARGE              0x0010
-#define    I2O_DETAIL_STATUS_MESSAGE_TOO_SMALL              0x0011
-#define    I2O_DETAIL_STATUS_MISSING_PARAMETER              0x0012
-#define    I2O_DETAIL_STATUS_NO_SUCH_PAGE                   0x0013
-#define    I2O_DETAIL_STATUS_REPLY_BUFFER_FULL              0x0014
-#define    I2O_DETAIL_STATUS_TCL_ERROR                      0x0015
-#define    I2O_DETAIL_STATUS_TIMEOUT                        0x0016
-#define    I2O_DETAIL_STATUS_UNKNOWN_ERROR                  0x0017
-#define    I2O_DETAIL_STATUS_UNKNOWN_FUNCTION               0x0018
-#define    I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION           0x0019
-#define    I2O_DETAIL_STATUS_UNSUPPORTED_VERSION            0x001A
-
- /* I2O msg header defines for VersionOffset */
-#define I2OMSGVER_1_5   0x0001
-#define SGL_OFFSET_0    I2OMSGVER_1_5
-#define SGL_OFFSET_4    (0x0040 | I2OMSGVER_1_5)
-#define TRL_OFFSET_5    (0x0050 | I2OMSGVER_1_5)
-#define TRL_OFFSET_6    (0x0060 | I2OMSGVER_1_5)
-
- /* I2O msg header defines for MsgFlags */
-#define MSG_STATIC      0x0100
-#define MSG_64BIT_CNTXT 0x0200
-#define MSG_MULTI_TRANS 0x1000
-#define MSG_FAIL        0x2000
-#define MSG_LAST        0x4000
-#define MSG_REPLY       0x8000
-
-  /* normal LAN request message MsgFlags and VersionOffset (0x1041) */
-#define LAN_MSG_REQST  (MSG_MULTI_TRANS | SGL_OFFSET_4)
-
- /* minimum size msg */
-#define THREE_WORD_MSG_SIZE 0x00030000
-#define FOUR_WORD_MSG_SIZE  0x00040000
-#define FIVE_WORD_MSG_SIZE  0x00050000
-#define SIX_WORD_MSG_SIZE   0x00060000
-#define SEVEN_WORD_MSG_SIZE 0x00070000
-#define EIGHT_WORD_MSG_SIZE 0x00080000
-#define NINE_WORD_MSG_SIZE  0x00090000
-
-/* Special TID Assignments */
-
-#define I2O_IOP_TID   0
-#define I2O_HOST_TID  0xB91
-
- /* RedCreek I2O private message codes */
-#define RC_PRIVATE_GET_MAC_ADDR     0x0001/**/ /* OBSOLETE */
-#define RC_PRIVATE_SET_MAC_ADDR     0x0002
-#define RC_PRIVATE_GET_NIC_STATS    0x0003
-#define RC_PRIVATE_GET_LINK_STATUS  0x0004
-#define RC_PRIVATE_SET_LINK_SPEED   0x0005
-#define RC_PRIVATE_SET_IP_AND_MASK  0x0006
-/* #define RC_PRIVATE_GET_IP_AND_MASK  0x0007 *//* OBSOLETE */
-#define RC_PRIVATE_GET_LINK_SPEED   0x0008
-#define RC_PRIVATE_GET_FIRMWARE_REV 0x0009
-/* #define RC_PRIVATE_GET_MAC_ADDR     0x000A */
-#define RC_PRIVATE_GET_IP_AND_MASK  0x000B
-#define RC_PRIVATE_DEBUG_MSG        0x000C
-#define RC_PRIVATE_REPORT_DRIVER_CAPABILITY  0x000D
-#define RC_PRIVATE_SET_PROMISCUOUS_MODE  0x000e
-#define RC_PRIVATE_GET_PROMISCUOUS_MODE  0x000f
-#define RC_PRIVATE_SET_BROADCAST_MODE    0x0010
-#define RC_PRIVATE_GET_BROADCAST_MODE    0x0011
-
-#define RC_PRIVATE_REBOOT           0x00FF
-
-/* I2O message header */
-typedef struct _I2O_MESSAGE_FRAME {
-       U8 VersionOffset;
-       U8 MsgFlags;
-       U16 MessageSize;
-       BF TargetAddress:I2O_TID_SZ;
-       BF InitiatorAddress:I2O_TID_SZ;
-       BF Function:I2O_FUNCTION_SZ;
-       U32 InitiatorContext;
-       /* SGL[] */
-} I2O_MESSAGE_FRAME, *PI2O_MESSAGE_FRAME;
-
- /* assumed a 16K minus 256 byte space for outbound queue message frames */
-#define MSG_FRAME_SIZE  512
-#define NMBR_MSG_FRAMES 30
-
- /* 
-    ** in reserved space right after PAB in host memory is area for returning
-    ** values from card 
-  */
-
-/*
-** typedef NICSTAT
-**
-** Data structure for NIC statistics retruned from PCI card.  Data copied from
-** here to user allocated RCLINKSTATS (see rclanmtl.h) structure.
-*/
-typedef struct tag_NicStat {
-       unsigned long TX_good;
-       unsigned long TX_maxcol;
-       unsigned long TX_latecol;
-       unsigned long TX_urun;
-       unsigned long TX_crs;   /* lost carrier sense */
-       unsigned long TX_def;   /* transmit deferred */
-       unsigned long TX_singlecol;     /* single collisions */
-       unsigned long TX_multcol;
-       unsigned long TX_totcol;
-       unsigned long Rcv_good;
-       unsigned long Rcv_CRCerr;
-       unsigned long Rcv_alignerr;
-       unsigned long Rcv_reserr;       /* rnr'd pkts */
-       unsigned long Rcv_orun;
-       unsigned long Rcv_cdt;
-       unsigned long Rcv_runt;
-       unsigned long dump_status;      /* last field directly from the chip */
-} NICSTAT, *P_NICSTAT;
-
-#define DUMP_DONE   0x0000A005 /* completed statistical dump */
-#define DUMP_CLEAR  0x0000A007 /* completed stat dump and clear counters */
-
-static volatile int msgFlag;
-
-/* local function prototypes */
-static void ProcessOutboundI2OMsg (PPAB pPab, U32 phyMsgAddr);
-static int FillI2OMsgSGLFromTCB (PU32 pMsg, PRCTCB pXmitCntrlBlock);
-static int GetI2OStatus (PPAB pPab);
-static int SendI2OOutboundQInitMsg (PPAB pPab);
-static int SendEnableSysMsg (PPAB pPab);
-
-/*
-** =========================================================================
-** RCInitI2OMsgLayer()
-**
-** Initialize the RedCreek I2O Module and adapter.
-**
-** Inputs:  dev - the devices net_device struct
-**          TransmitCallbackFunction - address of transmit callback function
-**          ReceiveCallbackFunction  - address of receive  callback function
-**
-** private message block is allocated by user.  It must be in locked pages.
-** p_msgbuf and p_phymsgbuf point to the same location.  Must be contigous
-** memory block of a minimum of 16K byte and long word aligned.
-** =========================================================================
-*/
-RC_RETURN
-RCInitI2OMsgLayer (struct net_device *dev,
-                  PFNTXCALLBACK TransmitCallbackFunction,
-                  PFNRXCALLBACK ReceiveCallbackFunction,
-                  PFNCALLBACK RebootCallbackFunction)
-{
-       int result;
-       PPAB pPab;
-       U32 pciBaseAddr = dev->base_addr;
-       PDPA pDpa = dev->priv;
-       PU8 p_msgbuf = pDpa->msgbuf;
-       PU8 p_phymsgbuf = (PU8) pDpa->msgbuf_dma;
-
-       dprintk
-           ("InitI2O: Adapter:0x%04ux ATU:0x%08ulx msgbuf:%p phymsgbuf:0x%08ulx\n"
-            "TransmitCallbackFunction:0x%08ulx  ReceiveCallbackFunction:0x%08ulx\n",
-            pDpa->id, pciBaseAddr, p_msgbuf, (u32) p_phymsgbuf,
-            (u32) TransmitCallbackFunction, (u32) ReceiveCallbackFunction);
-
-       /* Check if this interface already initialized - if so, shut it down */
-       if (pDpa->pPab != NULL) {
-               printk (KERN_WARNING
-                       "(rcpci45 driver:) pDpa->pPab [%d] != NULL\n",
-                       pDpa->id);
-/*          RCResetLANCard(pDpa->id, 0, (PU32)NULL, (PFNCALLBACK)NULL); */
-               pDpa->pPab = NULL;
-       }
-
-       /* store adapter instance values in adapter block.
-        * Adapter block is at beginning of message buffer */
-
-       pPab = kmalloc (sizeof (*pPab), GFP_KERNEL);
-       if (!pPab) {
-               printk (KERN_ERR
-                       "(rcpci45 driver:) RCInitI2OMsgLayer: Could not allocate memory for PAB struct!\n");
-               result = RC_RTN_MALLOC_ERROR;
-               goto err_out;
-       }
-
-       memset (pPab, 0, sizeof (*pPab));
-       pDpa->pPab = pPab;
-       pPab->p_atu = (PATU) pciBaseAddr;
-       pPab->pPci45LinBaseAddr = (PU8) pciBaseAddr;
-
-       /* Set outbound message frame addr */
-       pPab->outMsgBlockPhyAddr = (U32) p_phymsgbuf;
-       pPab->pLinOutMsgBlock = (PU8) p_msgbuf;
-
-       /* store callback function addresses */
-       pPab->pTransCallbackFunc = TransmitCallbackFunction;
-       pPab->pRecvCallbackFunc = ReceiveCallbackFunction;
-       pPab->pRebootCallbackFunc = RebootCallbackFunction;
-       pPab->pCallbackFunc = (PFNCALLBACK) NULL;
-
-       /*
-          ** Initialize I2O IOP
-        */
-       result = GetI2OStatus (pPab);
-
-       if (result != RC_RTN_NO_ERROR)
-               goto err_out_dealloc;
-
-       if (pPab->IOPState == I2O_IOP_STATE_OPERATIONAL) {
-               printk (KERN_INFO
-                       "(rcpci45 driver:) pPab->IOPState == op: resetting adapter\n");
-               RCResetLANCard (dev, 0, (PU32) NULL, (PFNCALLBACK) NULL);
-       }
-
-       result = SendI2OOutboundQInitMsg (pPab);
-
-       if (result != RC_RTN_NO_ERROR)
-               goto err_out_dealloc;
-
-       result = SendEnableSysMsg (pPab);
-
-       if (result != RC_RTN_NO_ERROR)
-               goto err_out_dealloc;
-
-       return RC_RTN_NO_ERROR;
-
-      err_out_dealloc:
-       kfree (pPab);
-      err_out:
-       return result;
-}
-
-/*
-** =========================================================================
-** Disable and Enable I2O interrupts.  I2O interrupts are enabled at Init time
-** but can be disabled and re-enabled through these two function calls.
-** Packets will still be put into any posted received buffers and packets will
-** be sent through RCI2OSendPacket() functions.  Disabling I2O interrupts
-** will prevent hardware interrupt to host even though the outbound I2O msg
-** queue is not emtpy.
-** =========================================================================
-*/
-#define i960_OUT_POST_Q_INT_BIT        0x0008  /* bit set masks interrupts */
-
-RC_RETURN
-RCDisableI2OInterrupts (struct net_device * dev)
-{
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       pPab->p_atu->OutIntMask |= i960_OUT_POST_Q_INT_BIT;
-
-       return RC_RTN_NO_ERROR;
-}
-
-RC_RETURN
-RCEnableI2OInterrupts (struct net_device * dev)
-{
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       pPab->p_atu->OutIntMask &= ~i960_OUT_POST_Q_INT_BIT;
-
-       return RC_RTN_NO_ERROR;
-
-}
-
-/*
-** =========================================================================
-** RCI2OSendPacket()
-** =========================================================================
-*/
-RC_RETURN
-RCI2OSendPacket (struct net_device * dev, U32 InitiatorContext,
-                PRCTCB pTransCtrlBlock)
-{
-       U32 msgOffset;
-       PU32 pMsg;
-       int size;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       dprintk ("RCI2OSendPacket()...\n");
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       /* get Inbound free Q entry - reading from In Q gets free Q entry */
-       /* offset to Msg Frame in PCI msg block */
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("RCI2OSendPacket(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       size = FillI2OMsgSGLFromTCB (pMsg + 4, pTransCtrlBlock);
-
-       if (size == -1) {       /* error processing TCB - send NOP msg */
-               dprintk ("RCI2OSendPacket(): Error Rrocess TCB!\n");
-               pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
-               pMsg[1] =
-                   I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-               return RC_RTN_TCB_ERROR;
-       } else {                /* send over msg header */
-
-               pMsg[0] = (size + 4) << 16 | LAN_MSG_REQST;     /* send over message size and flags */
-               pMsg[1] =
-                   I2O_LAN_PACKET_SEND << 24 | I2O_HOST_TID << 12 |
-                   RC_LAN_TARGET_ID;
-               pMsg[2] = InitiatorContext;
-               pMsg[3] = 0;    /* batch reply */
-               /* post to Inbound Post Q */
-               pPab->p_atu->InQueue = msgOffset;
-               return RC_RTN_NO_ERROR;
-       }
-}
-
-/*
-** =========================================================================
-** RCI2OPostRecvBuffer()
-**
-** inputs:  pBufrCntrlBlock - pointer to buffer control block
-**
-** returns TRUE if successful in sending message, else FALSE.
-** =========================================================================
-*/
-RC_RETURN
-RCPostRecvBuffers (struct net_device * dev, PRCTCB pTransCtrlBlock)
-{
-       U32 msgOffset;
-       PU32 pMsg;
-       int size;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       dprintk ("RCPostRecvBuffers()...\n");
-
-       /* search for DeviceHandle */
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       /* get Inbound free Q entry - reading from In Q gets free Q entry */
-       /* offset to Msg Frame in PCI msg block */
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("RCPostRecvBuffers(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       size = FillI2OMsgSGLFromTCB (pMsg + 4, pTransCtrlBlock);
-
-       if (size == -1) {       /* error prcessing TCB - send 3 DWORD private msg == NOP */
-               dprintk
-                   ("RCPostRecvBuffers(): Error Processing TCB! size = %d\n",
-                    size);
-               pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
-               pMsg[1] =
-                   I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-               /* post to Post Q */
-               pPab->p_atu->InQueue = msgOffset;
-               return RC_RTN_TCB_ERROR;
-       } else {                /* send over size msg header */
-
-               pMsg[0] = (size + 4) << 16 | LAN_MSG_REQST;     /* send over message size and flags */
-               pMsg[1] =
-                   I2O_LAN_RECEIVE_POST << 24 | I2O_HOST_TID << 12 |
-                   RC_LAN_TARGET_ID;
-               pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
-               pMsg[3] = *(PU32) pTransCtrlBlock;      /* number of packet buffers */
-               /* post to Post Q */
-               pPab->p_atu->InQueue = msgOffset;
-               return RC_RTN_NO_ERROR;
-       }
-}
-
-/*
-** =========================================================================
-** RCProcI2OMsgQ()
-**
-** Process I2O outbound message queue until empty.
-** =========================================================================
-*/
-irqreturn_t
-RCProcI2OMsgQ (struct net_device *dev)
-{
-       U32 phyAddrMsg;
-       PU8 p8Msg;
-       PU32 p32;
-       U16 count;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-       unsigned char debug_msg[20];
-
-       if (pPab == NULL)
-               return IRQ_NONE;
-
-       phyAddrMsg = pPab->p_atu->OutQueue;
-
-       while (phyAddrMsg != 0xFFFFFFFF) {
-               p8Msg =
-                   pPab->pLinOutMsgBlock + (phyAddrMsg -
-                                            pPab->outMsgBlockPhyAddr);
-               p32 = (PU32) p8Msg;
-
-               dprintk ("msg: 0x%x  0x%x \n", p8Msg[7], p32[5]);
-
-               /* Send Packet Reply Msg */
-               if (I2O_LAN_PACKET_SEND == p8Msg[7]) {  /* function code byte */
-                       count = *(PU16) (p8Msg + 2);
-                       count -= p8Msg[0] >> 4;
-                       /* status, count, context[], adapter */
-                       (*pPab->pTransCallbackFunc) (p8Msg[19], count, p32 + 5,
-                                                    dev);
-               } else if (I2O_LAN_RECEIVE_POST == p8Msg[7]) {  /* Receive Packet Reply Msg */
-                       dprintk
-                           ("I2O_RECV_REPLY pPab:0x%08ulx p8Msg:0x%08ulx p32:0x%08ulx\n",
-                            (u32) pPab, (u32) p8Msg, (u32) p32);
-                       dprintk ("msg: 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
-                                p32[0], p32[1], p32[2], p32[3]);
-                       dprintk ("     0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
-                                p32[4], p32[5], p32[6], p32[7]);
-                       dprintk ("     0x%08ulx:0X%08ulx:0x%08ulx:0x%08ulx\n",
-                                p32[8], p32[9], p32[10], p32[11]);
-                       /*  status, count, buckets remaining, packetParmBlock, adapter */
-                       (*pPab->pRecvCallbackFunc) (p8Msg[19], p8Msg[12],
-                                                   p32[5], p32 + 6, dev);
-               } else if (I2O_LAN_RESET == p8Msg[7]
-                          || I2O_LAN_SHUTDOWN == p8Msg[7])
-                       if (pPab->pCallbackFunc)
-                               (*pPab->pCallbackFunc) (p8Msg[19], 0, 0, dev);
-                       else
-                               pPab->pCallbackFunc = (PFNCALLBACK) 1;
-               else if (I2O_PRIVATE == p8Msg[7]) {
-                       dprintk ("i2o private 0x%x, 0x%x \n", p8Msg[7], p32[5]);
-                       switch (p32[5]) {
-                       case RC_PRIVATE_DEBUG_MSG:
-                               msgFlag = 1;
-                               dprintk ("Received I2O_PRIVATE msg\n");
-                               debug_msg[15] = (p32[6] & 0xff000000) >> 24;
-                               debug_msg[14] = (p32[6] & 0x00ff0000) >> 16;
-                               debug_msg[13] = (p32[6] & 0x0000ff00) >> 8;
-                               debug_msg[12] = (p32[6] & 0x000000ff);
-
-                               debug_msg[11] = (p32[7] & 0xff000000) >> 24;
-                               debug_msg[10] = (p32[7] & 0x00ff0000) >> 16;
-                               debug_msg[9] = (p32[7] & 0x0000ff00) >> 8;
-                               debug_msg[8] = (p32[7] & 0x000000ff);
-
-                               debug_msg[7] = (p32[8] & 0xff000000) >> 24;
-                               debug_msg[6] = (p32[8] & 0x00ff0000) >> 16;
-                               debug_msg[5] = (p32[8] & 0x0000ff00) >> 8;
-                               debug_msg[4] = (p32[8] & 0x000000ff);
-
-                               debug_msg[3] = (p32[9] & 0xff000000) >> 24;
-                               debug_msg[2] = (p32[9] & 0x00ff0000) >> 16;
-                               debug_msg[1] = (p32[9] & 0x0000ff00) >> 8;
-                               debug_msg[0] = (p32[9] & 0x000000ff);
-
-                               debug_msg[16] = '\0';
-                               dprintk ("%s", debug_msg);
-                               break;
-                       case RC_PRIVATE_REBOOT:
-                               dprintk ("Adapter reboot initiated...\n");
-                               if (pPab->pRebootCallbackFunc)
-                                       (*pPab->pRebootCallbackFunc) (0, 0, 0,
-                                                                     dev);
-                               break;
-                       default:
-                               printk (KERN_WARNING
-                                       "(rcpci45 driver:) Unknown private I2O msg received: 0x%x\n",
-                                       p32[5]);
-                               break;
-                       }
-               }
-
-               /* 
-                  ** Process other Msg's
-                */
-               else
-                       ProcessOutboundI2OMsg (pPab, phyAddrMsg);
-
-               /* return MFA to outbound free Q */
-               pPab->p_atu->OutQueue = phyAddrMsg;
-
-               /* any more msgs? */
-               phyAddrMsg = pPab->p_atu->OutQueue;
-       }
-
-       return IRQ_HANDLED;
-}
-
-/*
-** =========================================================================
-**  Returns LAN interface statistical counters to space provided by caller at
-**  StatsReturnAddr.  Returns 0 if success, else RC_RETURN code.
-**  This function will call the WaitCallback function provided by
-**  user while waiting for card to respond.
-** =========================================================================
-*/
-RC_RETURN
-RCGetLinkStatistics (struct net_device *dev,
-                    P_RCLINKSTATS StatsReturnAddr,
-                    PFNWAITCALLBACK WaitCallback)
-{
-       U32 msgOffset;
-       volatile U32 timeout;
-       volatile PU32 pMsg;
-       volatile PU32 p32, pReturnAddr;
-       P_NICSTAT pStats;
-       int i;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-/*dprintk("Get82558Stats() StatsReturnAddr:0x%08ulx\n", StatsReturnAddr); */
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("Get8255XStats(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-/*dprintk("Get82558Stats - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
-/*dprintk("Get82558Stats - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
-
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
-       pMsg[3] = 0x112;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_NIC_STATS;
-       pMsg[5] = pPab->outMsgBlockPhyAddr;
-
-       p32 = (PU32) pPab->outMsgBlockPhyAddr;
-       pStats = (P_NICSTAT) pPab->pLinOutMsgBlock;
-       pStats->dump_status = 0xFFFFFFFF;
-
-       /* post to Inbound Post Q */
-       pPab->p_atu->InQueue = msgOffset;
-
-       timeout = 100000;
-       while (1) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);
-
-               if (pStats->dump_status != 0xFFFFFFFF)
-                       break;
-
-               if (!timeout--) {
-                       dprintk
-                           ("RCGet82558Stats() Timeout waiting for NIC statistics\n");
-                       return RC_RTN_MSG_REPLY_TIMEOUT;
-               }
-       }
-
-       pReturnAddr = (PU32) StatsReturnAddr;
-
-       /* copy Nic stats to user's structure */
-       for (i = 0; i < (int) sizeof (RCLINKSTATS) / 4; i++)
-               pReturnAddr[i] = p32[i];
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** Get82558LinkStatus()
-** =========================================================================
-*/
-RC_RETURN
-RCGetLinkStatus (struct net_device * dev, PU32 ReturnAddr,
-                PFNWAITCALLBACK WaitCallback)
-{
-       U32 msgOffset;
-       volatile U32 timeout;
-       volatile PU32 pMsg;
-       volatile PU32 p32;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       dprintk ("Get82558LinkStatus() ReturnPhysAddr:0x%08ulx\n",
-                (u32) ReturnAddr);
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("Get82558LinkStatus(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-/*dprintk("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
-/*dprintk("Get82558LinkStatus - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
-
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
-       pMsg[3] = 0x112;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_STATUS;
-       pMsg[5] = pPab->outMsgBlockPhyAddr;
-
-       p32 = (PU32) pPab->pLinOutMsgBlock;
-       *p32 = 0xFFFFFFFF;
-
-       /* post to Inbound Post Q */
-       pPab->p_atu->InQueue = msgOffset;
-
-       timeout = 100000;
-       while (1) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);
-
-               if (*p32 != 0xFFFFFFFF)
-                       break;
-
-               if (!timeout--) {
-                       dprintk ("Timeout waiting for link status\n");
-                       return RC_RTN_MSG_REPLY_TIMEOUT;
-               }
-       }
-
-       *ReturnAddr = *p32;     /* 1 = up 0 = down */
-
-       return RC_RTN_NO_ERROR;
-
-}
-
-/*
-** =========================================================================
-** RCGetMAC()
-**
-** get the MAC address the adapter is listening for in non-promiscous mode.
-** MAC address is in media format.
-** =========================================================================
-*/
-RC_RETURN
-RCGetMAC (struct net_device * dev, PFNWAITCALLBACK WaitCallback)
-{
-       unsigned timeout;
-       U32 off;
-       PU8 mac = dev->dev_addr;
-       PU32 p;
-       U32 temp[2];
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-       PATU p_atu;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       p_atu = pPab->p_atu;
-
-       p_atu->EtherMacLow = 0; /* first zero return data */
-       p_atu->EtherMacHi = 0;
-
-       off = p_atu->InQueue;   /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       p = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       dprintk ("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n",
-                (uint) p_atu, (uint) off, (uint) p);
-       /* setup private message */
-       p[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
-       p[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       p[2] = 0;               /* initiator context */
-       p[3] = 0x218;           /* transaction context */
-       p[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_MAC_ADDR;
-
-       p_atu->InQueue = off;   /* send it to the I2O device */
-       dprintk ("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n",
-                (uint) p_atu, (uint) off, (uint) p);
-
-       /* wait for the rcpci45 board to update the info */
-       timeout = 1000000;
-       while (0 == p_atu->EtherMacLow) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);
-
-               if (!timeout--) {
-                       printk ("rc_getmac: Timeout\n");
-                       return RC_RTN_MSG_REPLY_TIMEOUT;
-               }
-       }
-
-       /* read the mac address  */
-       temp[0] = p_atu->EtherMacLow;
-       temp[1] = p_atu->EtherMacHi;
-       memcpy ((char *) mac, (char *) temp, 6);
-
-       dprintk ("rc_getmac: 0x%x\n", (u32) mac);
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetMAC()
-**
-** set MAC address the adapter is listening for in non-promiscous mode.
-** MAC address is in media format.
-** =========================================================================
-*/
-RC_RETURN
-RCSetMAC (struct net_device * dev, PU8 mac)
-{
-       U32 off;
-       PU32 pMsg;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup private message */
-       pMsg[0] = SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_MAC_ADDR;
-       pMsg[5] = *(unsigned *) mac;    /* first four bytes */
-       pMsg[6] = *(unsigned *) (mac + 4);      /* last two bytes */
-
-       pPab->p_atu->InQueue = off;     /* send it to the I2O device */
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetLinkSpeed()
-**
-** set ethernet link speed. 
-** input: speedControl - determines action to take as follows
-**          0 = reset and auto-negotiate (NWay)
-**          1 = Full Duplex 100BaseT
-**          2 = Half duplex 100BaseT
-**          3 = Full Duplex  10BaseT
-**          4 = Half duplex  10BaseT
-**          all other values are ignore (do nothing)
-** =========================================================================
-*/
-RC_RETURN
-RCSetLinkSpeed (struct net_device * dev, U16 LinkSpeedCode)
-{
-       U32 off;
-       PU32 pMsg;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_LINK_SPEED;
-       pMsg[5] = LinkSpeedCode;        /* link speed code */
-
-       pPab->p_atu->InQueue = off;     /* send it to the I2O device */
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetPromiscuousMode()
-**
-** Defined values for Mode:
-**  0 - turn off promiscuous mode
-**  1 - turn on  promiscuous mode
-**
-** =========================================================================
-*/
-RC_RETURN
-RCSetPromiscuousMode (struct net_device * dev, U16 Mode)
-{
-       U32 off;
-       PU32 pMsg;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_PROMISCUOUS_MODE;
-       pMsg[5] = Mode;         /* promiscuous mode setting */
-
-       pPab->p_atu->InQueue = off;     /* send it to the device */
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetPromiscuousMode()
-**
-** get promiscuous mode setting
-**
-** Possible return values placed in pMode:
-**  0 = promisuous mode not set
-**  1 = promisuous mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetPromiscuousMode (struct net_device * dev, PU32 pMode,
-                     PFNWAITCALLBACK WaitCallback)
-{
-       U32 msgOffset, timeout;
-       PU32 pMsg;
-       volatile PU32 p32;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               printk (KERN_WARNING
-                       "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       /* virtual pointer to return buffer - clear first two dwords */
-       p32 = (volatile PU32) pPab->pLinOutMsgBlock;
-       p32[0] = 0xff;
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_PROMISCUOUS_MODE;
-       /* phys address to return status - area right after PAB */
-       pMsg[5] = pPab->outMsgBlockPhyAddr;
-
-       /* post to Inbound Post Q */
-
-       pPab->p_atu->InQueue = msgOffset;
-
-       /* wait for response */
-       timeout = 1000000;
-       while (1) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0] != 0xff)
-                       break;
-
-               if (!timeout--) {
-                       dprintk
-                           ("Timeout waiting for promiscuous mode from adapter\n");
-                       dprintk ("0x%8x\n", p32[0]);
-                       return RC_RTN_NO_LINK_SPEED;
-               }
-       }
-
-       /* get mode */
-       *pMode = (U8) ((volatile PU8) p32)[0] & 0x0f;
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetBroadcastMode()
-**
-** Defined values for Mode:
-**  0 - turn off promiscuous mode
-**  1 - turn on  promiscuous mode
-**
-** =========================================================================
-*/
-RC_RETURN
-RCSetBroadcastMode (struct net_device * dev, U16 Mode)
-{
-       U32 off;
-       PU32 pMsg;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_BROADCAST_MODE;
-       pMsg[5] = Mode;         /* promiscuous mode setting */
-
-       pPab->p_atu->InQueue = off;     /* send it to the device */
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetBroadcastMode()
-**
-** get promiscuous mode setting
-**
-** Possible return values placed in pMode:
-**  0 = promisuous mode not set
-**  1 = promisuous mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetBroadcastMode (struct net_device * dev, PU32 pMode,
-                   PFNWAITCALLBACK WaitCallback)
-{
-       U32 msgOffset, timeout;
-       PU32 pMsg;
-       volatile PU32 p32;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               printk (KERN_WARNING
-                       "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       /* virtual pointer to return buffer - clear first two dwords */
-       p32 = (volatile PU32) pPab->pLinOutMsgBlock;
-       p32[0] = 0xff;
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_BROADCAST_MODE;
-       /* phys address to return status - area right after PAB */
-       pMsg[5] = pPab->outMsgBlockPhyAddr;
-
-       /* post to Inbound Post Q */
-
-       pPab->p_atu->InQueue = msgOffset;
-
-       /* wait for response */
-       timeout = 1000000;
-       while (1) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0] != 0xff)
-                       break;
-
-               if (!timeout--) {
-                       printk (KERN_WARNING
-                               "(rcpci45 driver:) Timeout waiting for promiscuous mode from adapter\n");
-                       printk (KERN_WARNING "(rcpci45 driver:) 0x%8x\n",
-                               p32[0]);
-                       return RC_RTN_NO_LINK_SPEED;
-               }
-       }
-
-       /* get mode */
-       *pMode = (U8) ((volatile PU8) p32)[0] & 0x0f;
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetLinkSpeed()
-**
-** get ethernet link speed. 
-**
-** 0 = Unknown
-** 1 = Full Duplex 100BaseT
-** 2 = Half duplex 100BaseT
-** 3 = Full Duplex  10BaseT
-** 4 = Half duplex  10BaseT
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetLinkSpeed (struct net_device * dev, PU32 pLinkSpeedCode,
-               PFNWAITCALLBACK WaitCallback)
-{
-       U32 msgOffset, timeout;
-       PU32 pMsg;
-       volatile PU32 p32;
-       U8 IOPLinkSpeed;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               printk (KERN_WARNING
-                       "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       /* virtual pointer to return buffer - clear first two dwords */
-       p32 = (volatile PU32) pPab->pLinOutMsgBlock;
-       p32[0] = 0xff;
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_SPEED;
-       /* phys address to return status - area right after PAB */
-       pMsg[5] = pPab->outMsgBlockPhyAddr;
-
-       /* post to Inbound Post Q */
-
-       pPab->p_atu->InQueue = msgOffset;
-
-       /* wait for response */
-       timeout = 1000000;
-       while (1) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0] != 0xff)
-                       break;
-
-               if (!timeout--) {
-                       dprintk ("Timeout waiting for link speed from IOP\n");
-                       dprintk ("0x%8x\n", p32[0]);
-                       return RC_RTN_NO_LINK_SPEED;
-               }
-       }
-
-       /* get Link speed */
-       IOPLinkSpeed = (U8) ((volatile PU8) p32)[0] & 0x0f;
-
-       *pLinkSpeedCode = IOPLinkSpeed;
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCReportDriverCapability(struct net_device *dev, U32 capability)
-**
-** Currently defined bits:
-** WARM_REBOOT_CAPABLE   0x01
-**
-** =========================================================================
-*/
-RC_RETURN
-RCReportDriverCapability (struct net_device * dev, U32 capability)
-{
-       U32 off;
-       PU32 pMsg;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] =
-           RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_REPORT_DRIVER_CAPABILITY;
-       pMsg[5] = capability;
-
-       pPab->p_atu->InQueue = off;     /* send it to the I2O device */
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetFirmwareVer()
-**
-** Return firmware version in the form "SoftwareVersion : Bt BootVersion"
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetFirmwareVer (struct net_device * dev, PU8 pFirmString,
-                 PFNWAITCALLBACK WaitCallback)
-{
-       U32 msgOffset, timeout;
-       PU32 pMsg;
-       volatile PU32 p32;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       msgOffset = pPab->p_atu->InQueue;
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("RCGetFirmwareVer(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       /* virtual pointer to return buffer - clear first two dwords */
-       p32 = (volatile PU32) pPab->pLinOutMsgBlock;
-       p32[0] = 0xff;
-
-       /* setup private message */
-       pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_FIRMWARE_REV;
-       /* phys address to return status - area right after PAB */
-       pMsg[5] = pPab->outMsgBlockPhyAddr;
-
-       /* post to Inbound Post Q */
-
-       pPab->p_atu->InQueue = msgOffset;
-
-       /* wait for response */
-       timeout = 1000000;
-       while (1) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0] != 0xff)
-                       break;
-
-               if (!timeout--) {
-                       dprintk ("Timeout waiting for link speed from IOP\n");
-                       return RC_RTN_NO_FIRM_VER;
-               }
-       }
-
-       strcpy (pFirmString, (PU8) p32);
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCResetLANCard()
-**
-** ResourceFlags indicates whether to return buffer resource explicitly
-** to host or keep and reuse.
-** CallbackFunction (if not NULL) is the function to be called when 
-** reset is complete.
-** If CallbackFunction is NULL, ReturnAddr will have a 1 placed in it when
-** reset is done (if not NULL).
-**
-** =========================================================================
-*/
-RC_RETURN
-RCResetLANCard (struct net_device * dev, U16 ResourceFlags, PU32 ReturnAddr,
-               PFNCALLBACK CallbackFunction)
-{
-       unsigned long off;
-       PU32 pMsg;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-       long timeout = 0;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pPab->pCallbackFunc = CallbackFunction;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup message */
-       pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_LAN_RESET << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
-       pMsg[3] = ResourceFlags << 16;  /* resource flags */
-
-       pPab->p_atu->InQueue = off;     /* send it to the I2O device */
-
-       if (CallbackFunction == (PFNCALLBACK) NULL) {
-               /* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc
-                  or until timer goes off */
-               while (pPab->pCallbackFunc == (PFNCALLBACK) NULL) {
-                       RCProcI2OMsgQ (dev);
-                       udelay (1000);  /* please don't hog the bus!!! */
-                       timeout++;
-                       if (timeout > 10000) {
-                               break;
-                       }
-               }
-               if (ReturnAddr != (PU32) NULL)
-                       *ReturnAddr = (U32) pPab->pCallbackFunc;
-       }
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCResetIOP()
-**
-** Send StatusGet Msg, wait for results return directly to buffer.
-**
-** =========================================================================
-*/
-RC_RETURN
-RCResetIOP (struct net_device * dev)
-{
-       U32 msgOffset, timeout;
-       PU32 pMsg;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-       volatile PU32 p32;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_EXEC_IOP_RESET << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
-       pMsg[2] = 0;            /* universal context */
-       pMsg[3] = 0;            /* universal context */
-       pMsg[4] = 0;            /* universal context */
-       pMsg[5] = 0;            /* universal context */
-       /* phys address to return status - area right after PAB */
-       pMsg[6] = pPab->outMsgBlockPhyAddr;
-       pMsg[7] = 0;
-       pMsg[8] = 1;            /*  return 1 byte */
-
-       /* virtual pointer to return buffer - clear first two dwords */
-       p32 = (volatile PU32) pPab->pLinOutMsgBlock;
-       p32[0] = 0;
-       p32[1] = 0;
-
-       /* post to Inbound Post Q */
-
-       pPab->p_atu->InQueue = msgOffset;
-
-       /* wait for response */
-       timeout = 1000000;
-       while (1) {
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0] || p32[1])
-                       break;
-
-               if (!timeout--) {
-                       dprintk ("RCResetIOP timeout\n");
-                       return RC_RTN_MSG_REPLY_TIMEOUT;
-               }
-       }
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCShutdownLANCard()
-**
-** ResourceFlags indicates whether to return buffer resource explicitly
-** to host or keep and reuse.
-** CallbackFunction (if not NULL) is the function to be called when 
-** shutdown is complete.
-** If CallbackFunction is NULL, ReturnAddr will have a 1 placed in it when
-** shutdown is done (if not NULL).
-**
-** =========================================================================
-*/
-RC_RETURN
-RCShutdownLANCard (struct net_device * dev, U16 ResourceFlags,
-                  PU32 ReturnAddr, PFNCALLBACK CallbackFunction)
-{
-       volatile PU32 pMsg;
-       U32 off;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-       long timeout = 0;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pPab->pCallbackFunc = CallbackFunction;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup message */
-       pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] =
-           I2O_LAN_SHUTDOWN << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
-       pMsg[3] = ResourceFlags << 16;  /* resource flags */
-
-       pPab->p_atu->InQueue = off;     /* send it to the I2O device */
-
-       if (CallbackFunction == (PFNCALLBACK) NULL) {
-               /* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc
-                  or until timer goes off */
-               while (pPab->pCallbackFunc == (PFNCALLBACK) NULL) {
-                       RCProcI2OMsgQ (dev);
-                       udelay (1000);  /* please don't hog the bus!!! */
-                       timeout++;
-                       if (timeout > 10000) {
-                               printk (KERN_WARNING
-                                       "(rcpci45 driver:) RCShutdownLANCard(): timeout\n");
-                               break;
-                       }
-               }
-               if (ReturnAddr != (PU32) NULL)
-                       *ReturnAddr = (U32) pPab->pCallbackFunc;
-       }
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetRavlinIPandMask()
-**
-** Set the Ravlin 45/PCI cards IP address and network mask.
-**
-** IP address and mask must be in network byte order.
-** For example, IP address 1.2.3.4 and mask 255.255.255.0 would be
-** 0x04030201 and 0x00FFFFFF on a little endian machine.
-**
-** =========================================================================
-*/
-RC_RETURN
-RCSetRavlinIPandMask (struct net_device * dev, U32 ipAddr, U32 netMask)
-{
-       volatile PU32 pMsg;
-       U32 off;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       off = pPab->p_atu->InQueue;     /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       /* setup private message */
-       pMsg[0] = SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x219;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_IP_AND_MASK;
-       pMsg[5] = ipAddr;
-       pMsg[6] = netMask;
-
-       pPab->p_atu->InQueue = off;     /* send it to the I2O device */
-       return RC_RTN_NO_ERROR;
-
-}
-
-/*
-** =========================================================================
-** RCGetRavlinIPandMask()
-**
-** get the IP address and MASK from the card
-** 
-** =========================================================================
-*/
-RC_RETURN
-RCGetRavlinIPandMask (struct net_device * dev, PU32 pIpAddr, PU32 pNetMask,
-                     PFNWAITCALLBACK WaitCallback)
-{
-       unsigned timeout;
-       U32 off;
-       PU32 pMsg, p32;
-       PPAB pPab = ((PDPA) dev->priv)->pPab;
-       PATU p_atu;
-
-       dprintk
-           ("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n",
-            (u32) pIpAddr, *pIpAddr);
-
-       if (pPab == NULL)
-               return RC_RTN_ADPTR_NOT_REGISTERED;
-
-       p_atu = pPab->p_atu;
-       off = p_atu->InQueue;   /* get addresss of message */
-
-       if (0xFFFFFFFF == off)
-               return RC_RTN_FREE_Q_EMPTY;
-
-       p32 = (volatile PU32) pPab->pLinOutMsgBlock;
-       *p32 = 0xFFFFFFFF;
-
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
-       dprintk
-           ("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n",
-            (u32) p_atu, off, (u32) p32);
-       /* setup private message */
-       pMsg[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
-       pMsg[2] = 0;            /* initiator context */
-       pMsg[3] = 0x218;        /* transaction context */
-       pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_IP_AND_MASK;
-       pMsg[5] = pPab->outMsgBlockPhyAddr;
-
-       p_atu->InQueue = off;   /* send it to the I2O device */
-       dprintk
-           ("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n",
-            (u32) p_atu, off, (u32) p32);
-
-       /* wait for the rcpci45 board to update the info */
-       timeout = 100000;
-       while (0xffffffff == *p32) {
-               if (WaitCallback)
-                       (*WaitCallback) ();
-
-               udelay (10);
-
-               if (!timeout--) {
-                       dprintk ("RCGetRavlinIPandMask: Timeout\n");
-                       return RC_RTN_MSG_REPLY_TIMEOUT;
-               }
-       }
-
-       dprintk
-           ("RCGetRavlinIPandMask: after time out\np32[0] (IpAddr) 0x%08ulx, p32[1] (IPmask) 0x%08ulx\n",
-            p32[0], p32[1]);
-
-       /* send IP and mask to user's space  */
-       *pIpAddr = p32[0];
-       *pNetMask = p32[1];
-
-       dprintk
-           ("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n",
-            (u32) pIpAddr, *pIpAddr);
-
-       return RC_RTN_NO_ERROR;
-}
-
-/* 
-** /////////////////////////////////////////////////////////////////////////
-** /////////////////////////////////////////////////////////////////////////
-**
-**                        local functions
-**
-** /////////////////////////////////////////////////////////////////////////
-** /////////////////////////////////////////////////////////////////////////
-*/
-
-/*
-** =========================================================================
-** SendI2OOutboundQInitMsg()
-**
-** =========================================================================
-*/
-static int
-SendI2OOutboundQInitMsg (PPAB pPab)
-{
-       U32 msgOffset, timeout, phyOutQFrames, i;
-       volatile PU32 pMsg;
-       volatile PU32 p32;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("SendI2OOutboundQInitMsg(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       dprintk
-           ("SendI2OOutboundQInitMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n",
-            (u32) pMsg, msgOffset);
-
-       pMsg[0] = EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6;
-       pMsg[1] =
-           I2O_EXEC_OUTBOUND_INIT << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
-       pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
-       pMsg[3] = 0x106;        /* transaction context */
-       pMsg[4] = 4096;         /* Host page frame size */
-       pMsg[5] = MSG_FRAME_SIZE << 16 | 0x80;  /* outbound msg frame size and Initcode */
-       pMsg[6] = 0xD0000004;   /* simple sgl element LE, EOB */
-       /* phys address to return status - area right after PAB */
-       pMsg[7] = pPab->outMsgBlockPhyAddr;
-
-       /* virtual pointer to return buffer - clear first two dwords */
-       p32 = (PU32) pPab->pLinOutMsgBlock;
-       p32[0] = 0;
-
-       /* post to Inbound Post Q */
-       pPab->p_atu->InQueue = msgOffset;
-
-       /* wait for response */
-       timeout = 100000;
-       while (1) {
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0])
-                       break;
-
-               if (!timeout--) {
-                       dprintk
-                           ("Timeout wait for InitOutQ InPrgress status from IOP\n");
-                       return RC_RTN_NO_I2O_STATUS;
-               }
-       }
-
-       timeout = 100000;
-       while (1) {
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0] == I2O_EXEC_OUTBOUND_INIT_COMPLETE)
-                       break;
-
-               if (!timeout--) {
-                       dprintk
-                           ("Timeout wait for InitOutQ Complete status from IOP\n");
-                       return RC_RTN_NO_I2O_STATUS;
-               }
-       }
-
-       /* load PCI outbound free Q with MF physical addresses */
-       phyOutQFrames = pPab->outMsgBlockPhyAddr;
-
-       for (i = 0; i < NMBR_MSG_FRAMES; i++) {
-               pPab->p_atu->OutQueue = phyOutQFrames;
-               phyOutQFrames += MSG_FRAME_SIZE;
-       }
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** GetI2OStatus()
-**
-** Send StatusGet Msg, wait for results return directly to buffer.
-**
-** =========================================================================
-*/
-static int
-GetI2OStatus (PPAB pPab)
-{
-       U32 msgOffset, timeout;
-       PU32 pMsg;
-       volatile PU32 p32;
-
-       msgOffset = pPab->p_atu->InQueue;
-       dprintk ("GetI2OStatus: msg offset = 0x%x\n", msgOffset);
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("GetI2OStatus(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_EXEC_STATUS_GET << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
-       pMsg[2] = 0;            /* universal context */
-       pMsg[3] = 0;            /* universal context */
-       pMsg[4] = 0;            /* universal context */
-       pMsg[5] = 0;            /* universal context */
-       /* phys address to return status - area right after PAB */
-       pMsg[6] = pPab->outMsgBlockPhyAddr;
-       pMsg[7] = 0;
-       pMsg[8] = 88;           /*  return 88 bytes */
-
-       /* virtual pointer to return buffer - clear first two dwords */
-       p32 = (volatile PU32) pPab->pLinOutMsgBlock;
-       p32[0] = 0;
-       p32[1] = 0;
-
-       dprintk
-           ("GetI2OStatus - pMsg:0x%08ulx, msgOffset:0x%08ulx, [1]:0x%08ulx, [6]:0x%08ulx\n",
-            (u32) pMsg, msgOffset, pMsg[1], pMsg[6]);
-
-       /* post to Inbound Post Q */
-       pPab->p_atu->InQueue = msgOffset;
-
-       dprintk ("Return status to p32 = 0x%08ulx\n", (u32) p32);
-
-       /* wait for response */
-       timeout = 1000000;
-       while (1) {
-               udelay (10);    /* please don't hog the bus!!! */
-
-               if (p32[0] && p32[1])
-                       break;
-
-               if (!timeout--) {
-                       dprintk ("Timeout waiting for status from IOP\n");
-                       dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
-                                p32[0], p32[1], p32[2], p32[3]);
-                       dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
-                                p32[4], p32[5], p32[6], p32[7]);
-                       dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
-                                p32[8], p32[9], p32[10], p32[11]);
-                       return RC_RTN_NO_I2O_STATUS;
-               }
-       }
-
-       dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1],
-                p32[2], p32[3]);
-       dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5],
-                p32[6], p32[7]);
-       dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[8], p32[9],
-                p32[10], p32[11]);
-       /* get IOP state */
-       pPab->IOPState = ((volatile PU8) p32)[10];
-       pPab->InboundMFrameSize = ((volatile PU16) p32)[6];
-
-       dprintk ("IOP state 0x%02x InFrameSize = 0x%04x\n",
-                pPab->IOPState, pPab->InboundMFrameSize);
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** SendEnableSysMsg()
-**
-**
-** =========================================================================
-*/
-static int
-SendEnableSysMsg (PPAB pPab)
-{
-       U32 msgOffset;
-       volatile PU32 pMsg;
-
-       msgOffset = pPab->p_atu->InQueue;
-
-       if (msgOffset == 0xFFFFFFFF) {
-               dprintk ("SendEnableSysMsg(): Inbound Free Q empty!\n");
-               return RC_RTN_FREE_Q_EMPTY;
-       }
-
-       /* calc virtual address of msg - virtual already mapped to physical */
-       pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-       dprintk
-           ("SendEnableSysMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n",
-            (u32) pMsg, msgOffset);
-
-       pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
-       pMsg[1] = I2O_EXEC_SYS_ENABLE << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
-       pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
-       pMsg[3] = 0x110;        /* transaction context */
-       pMsg[4] = 0x50657465;   /*  RedCreek Private */
-
-       /* post to Inbound Post Q */
-       pPab->p_atu->InQueue = msgOffset;
-
-       return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** FillI2OMsgFromTCB()
-**
-** inputs   pMsgU32 - virtual pointer (mapped to physical) of message frame
-**          pXmitCntrlBlock - pointer to caller buffer control block.
-**
-** fills in LAN SGL after Transaction Control Word or Bucket Count.
-** =========================================================================
-*/
-static int
-FillI2OMsgSGLFromTCB (PU32 pMsgFrame, PRCTCB pTransCtrlBlock)
-{
-       unsigned int nmbrBuffers, nmbrSeg, nmbrDwords, context, flags;
-       PU32 pTCB, pMsg;
-
-       /* SGL element flags */
-#define EOB        0x40000000
-#define LE         0x80000000
-#define SIMPLE_SGL 0x10000000
-#define BC_PRESENT 0x01000000
-
-       pTCB = (PU32) pTransCtrlBlock;
-       pMsg = pMsgFrame;
-       nmbrDwords = 0;
-
-       dprintk ("FillI2OMsgSGLFromTCBX\n");
-       dprintk ("TCB  0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
-                pTCB[0], pTCB[1], pTCB[2], pTCB[3], pTCB[4]);
-       dprintk ("pTCB 0x%08ulx, pMsg 0x%08ulx\n", (u32) pTCB, (u32) pMsg);
-
-       nmbrBuffers = *pTCB++;
-
-       if (!nmbrBuffers) {
-               return -1;
-       }
-
-       do {
-               context = *pTCB++;      /* buffer tag (context) */
-               nmbrSeg = *pTCB++;      /* number of segments */
-
-               if (!nmbrSeg) {
-                       return -1;
-               }
-
-               flags = SIMPLE_SGL | BC_PRESENT;
-
-               if (1 == nmbrSeg) {
-                       flags |= EOB;
-
-                       if (1 == nmbrBuffers)
-                               flags |= LE;
-               }
-
-               /* 1st SGL buffer element has context */
-               pMsg[0] = pTCB[0] | flags;      /* send over count (segment size) */
-               pMsg[1] = context;
-               pMsg[2] = pTCB[1];      /* send buffer segment physical address */
-               nmbrDwords += 3;
-               pMsg += 3;
-               pTCB += 2;
-
-               if (--nmbrSeg) {
-                       do {
-                               flags = SIMPLE_SGL;
-
-                               if (1 == nmbrSeg) {
-                                       flags |= EOB;
-
-                                       if (1 == nmbrBuffers)
-                                               flags |= LE;
-                               }
-
-                               pMsg[0] = pTCB[0] | flags;      /* send over count */
-                               pMsg[1] = pTCB[1];      /* send buffer segment physical address */
-                               nmbrDwords += 2;
-                               pTCB += 2;
-                               pMsg += 2;
-
-                       } while (--nmbrSeg);
-               }
-
-       } while (--nmbrBuffers);
-
-       return nmbrDwords;
-}
-
-/*
-** =========================================================================
-** ProcessOutboundI2OMsg()
-**
-** process I2O reply message
-** * change to msg structure *
-** =========================================================================
-*/
-static void
-ProcessOutboundI2OMsg (PPAB pPab, U32 phyAddrMsg)
-{
-       PU8 p8Msg;
-       PU32 p32;
-/*      U16 count; */
-
-       p8Msg = pPab->pLinOutMsgBlock + (phyAddrMsg - pPab->outMsgBlockPhyAddr);
-       p32 = (PU32) p8Msg;
-
-       dprintk
-           ("VXD: ProcessOutboundI2OMsg - pPab 0x%08ulx, phyAdr 0x%08ulx, linAdr 0x%08ulx\n",
-            (u32) pPab, phyAddrMsg, (u32) p8Msg);
-       dprintk ("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1],
-                p32[2], p32[3]);
-       dprintk ("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5],
-                p32[6], p32[7]);
-
-       if (p32[4] >> 24 != I2O_REPLY_STATUS_SUCCESS) {
-               dprintk ("Message reply status not success\n");
-               return;
-       }
-
-       switch (p8Msg[7]) {     /* function code byte */
-       case I2O_EXEC_SYS_TAB_SET:
-               msgFlag = 1;
-               dprintk ("Received I2O_EXEC_SYS_TAB_SET reply\n");
-               break;
-
-       case I2O_EXEC_HRT_GET:
-               msgFlag = 1;
-               dprintk ("Received I2O_EXEC_HRT_GET reply\n");
-               break;
-
-       case I2O_EXEC_LCT_NOTIFY:
-               msgFlag = 1;
-               dprintk ("Received I2O_EXEC_LCT_NOTIFY reply\n");
-               break;
-
-       case I2O_EXEC_SYS_ENABLE:
-               msgFlag = 1;
-               dprintk ("Received I2O_EXEC_SYS_ENABLE reply\n");
-               break;
-
-       default:
-               dprintk ("Received UNKNOWN reply\n");
-               break;
-       }
-}
diff --git a/drivers/net/rclanmtl.h b/drivers/net/rclanmtl.h
deleted file mode 100644 (file)
index 9488c0f..0000000
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
-** *************************************************************************
-**
-**
-**     R C L A N M T L . H             $Revision: 6 $
-**
-**
-**  RedCreek I2O LAN Message Transport Layer header file.
-**
-**  ---------------------------------------------------------------------
-**  ---     Copyright (c) 1997-1999, RedCreek Communications Inc.     ---
-**  ---                   All rights reserved.                        ---
-**  ---------------------------------------------------------------------
-**
-**  File Description:
-**
-**  Header file for host I2O (Intelligent I/O) LAN message transport layer 
-**  API and data types.
-**
-**  This program is free software; you can redistribute it and/or modify
-**  it under the terms of the GNU General Public License as published by
-**  the Free Software Foundation; either version 2 of the License, or
-**  (at your option) any later version.
-
-**  This program is distributed in the hope that it will be useful,
-**  but WITHOUT ANY WARRANTY; without even the implied warranty of
-**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-**  GNU General Public License for more details.
-
-**  You should have received a copy of the GNU General Public License
-**  along with this program; if not, write to the Free Software
-**  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** *************************************************************************
-*/
-
-#ifndef RCLANMTL_H
-#define RCLANMTL_H
-
-/* Linux specific includes */
-#include <asm/types.h>
-#ifdef RC_LINUX_MODULE         /* linux modules need non-library version of string functions */
-#include <linux/string.h>
-#else
-#include <string.h>
-#endif
-#include <linux/delay.h>       /* for udelay() */
-
-#include <linux/netdevice.h>
-#include <linux/if_ether.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-
-#include <asm/io.h>
-
-/* Debug stuff. Define for debug output */
-#undef RCDEBUG
-
-#ifdef RCDEBUG
-#define dprintk(args...) printk(KERN_DEBUG "rc: " args)
-#else
-#define dprintk(args...) { }
-#endif
-
-/* Typedefs */
-
- /* scalar data types */
-typedef __u8 U8;
-typedef __u16 U16;
-typedef __u32 U32;
-typedef __u8 *PU8;
-typedef __u16 *PU16;
-typedef __u32 *PU32;
-typedef unsigned long BF;
-typedef int RC_RETURN;
-
- /* 
-    ** type PFNWAITCALLBACK
-    **
-    ** pointer to void function - type used for WaitCallback in some functions 
-  */
-typedef void (*PFNWAITCALLBACK) (void);        /* void argument avoids compiler complaint */
-
- /*
-    ** type PFNTXCALLBACK 
-    **
-    ** Pointer to user's transmit callback function.  This user function is
-    ** called from RCProcI2OMsgQ() when packet have been transmitted from buffers
-    ** given in the RCI2OSendPacket() function.  BufferContext is a pointer to
-    ** an array of 32 bit context values.  These are the values the user assigned
-    ** and passed in the TCB to the RCI2OSendPacket() function.  PcktCount
-    ** indicates the number of buffer context values in the BufferContext[] array.
-    ** The User's TransmitCallbackFunction should recover (put back in free queue)
-    ** the packet buffers associated with the buffer context values.
-  */
-typedef void (*PFNTXCALLBACK) (U32 Status,
-                              U16 PcktCount,
-                              PU32 BufferContext, struct net_device *);
-
- /* 
-    ** type PFNRXCALLBACK 
-    **
-    ** Pointer to user's receive callback function.  This user function
-    ** is called from RCProcI2OMsgQ() when packets have been received into
-    ** previously posted packet buffers throught the RCPostRecvBuffers() function.
-    ** The received callback function should process the Packet Descriptor Block
-    ** pointed to by PacketDescBlock. See Packet Decription Block below.
-  */
-typedef void (*PFNRXCALLBACK) (U32 Status,
-                              U8 PktCount,
-                              U32 BucketsRemain,
-                              PU32 PacketDescBlock, struct net_device *);
-
- /* 
-    ** type PFNCALLBACK 
-    **
-    ** Pointer to user's generic callback function.  This user function
-    ** can be passed to LANReset or LANShutdown and is called when the 
-    ** the reset or shutdown is complete.
-    ** Param1 and Param2 are invalid for LANReset and LANShutdown.
-  */
-typedef void (*PFNCALLBACK) (U32 Status,
-                            U32 Param1, U32 Param2, struct net_device * dev);
-
-/*
-**  Message Unit CSR definitions for RedCreek PCI45 board
-*/
-typedef struct tag_rcatu {
-       volatile unsigned long APICRegSel;      /* APIC Register Select */
-       volatile unsigned long reserved0;
-       volatile unsigned long APICWinReg;      /* APIC Window Register */
-       volatile unsigned long reserved1;
-       volatile unsigned long InMsgReg0;       /* inbound message register 0 */
-       volatile unsigned long InMsgReg1;       /* inbound message register 1 */
-       volatile unsigned long OutMsgReg0;      /* outbound message register 0 */
-       volatile unsigned long OutMsgReg1;      /* outbound message register 1 */
-       volatile unsigned long InDoorReg;       /* inbound doorbell register */
-       volatile unsigned long InIntStat;       /* inbound interrupt status register */
-       volatile unsigned long InIntMask;       /* inbound interrupt mask register */
-       volatile unsigned long OutDoorReg;      /* outbound doorbell register */
-       volatile unsigned long OutIntStat;      /* outbound interrupt status register */
-       volatile unsigned long OutIntMask;      /* outbound interrupt mask register */
-       volatile unsigned long reserved2;
-       volatile unsigned long reserved3;
-       volatile unsigned long InQueue; /* inbound queue port */
-       volatile unsigned long OutQueue;        /* outbound queue port */
-       volatile unsigned long reserved4;
-       volatile unsigned long reserver5;
-       /* RedCreek extension */
-       volatile unsigned long EtherMacLow;
-       volatile unsigned long EtherMacHi;
-       volatile unsigned long IPaddr;
-       volatile unsigned long IPmask;
-} *PATU;
-
- /* 
-    ** typedef PAB
-    **
-    ** PCI Adapter Block - holds instance specific information.
-  */
-typedef struct {
-       PATU p_atu;             /* ptr to  ATU register block */
-       PU8 pPci45LinBaseAddr;
-       PU8 pLinOutMsgBlock;
-       U32 outMsgBlockPhyAddr;
-       PFNTXCALLBACK pTransCallbackFunc;
-       PFNRXCALLBACK pRecvCallbackFunc;
-       PFNCALLBACK pRebootCallbackFunc;
-       PFNCALLBACK pCallbackFunc;
-       U16 IOPState;
-       U16 InboundMFrameSize;
-} *PPAB;
-
-/*
- * Driver Private Area, DPA.
- */
-typedef struct {
-       U8 id;                  /* the AdapterID */
-
-       /* These two field are basically for the RCioctl function.
-        * I could not determine if they could be avoided. (RAA)*/
-       U32 pci_addr;           /* the pci address of the adapter */
-       U32 pci_addr_len;
-
-       struct pci_dev *pci_dev;
-       struct timer_list timer;        /*  timer */
-       struct net_device_stats stats;  /* the statistics structure */
-       unsigned long numOutRcvBuffers; /* number of outstanding receive buffers */
-       unsigned char shutdown;
-       unsigned char reboot;
-       unsigned char nexus;
-       PU8 msgbuf;             /* Pointer to Lan Api Private Area */
-       dma_addr_t msgbuf_dma;
-       PPAB pPab;              /* Pointer to the PCI Adapter Block */
-} *PDPA;
-
-/* PCI/45 Configuration space values */
-#define RC_PCI45_VENDOR_ID  0x4916
-#define RC_PCI45_DEVICE_ID  0x1960
-
- /* RedCreek API function return values */
-#define RC_RTN_NO_ERROR             0
-#define RC_RTN_I2O_NOT_INIT         1
-#define RC_RTN_FREE_Q_EMPTY         2
-#define RC_RTN_TCB_ERROR            3
-#define RC_RTN_TRANSACTION_ERROR    4
-#define RC_RTN_ADAPTER_ALREADY_INIT 5
-#define RC_RTN_MALLOC_ERROR         6
-#define RC_RTN_ADPTR_NOT_REGISTERED 7
-#define RC_RTN_MSG_REPLY_TIMEOUT    8
-#define RC_RTN_NO_I2O_STATUS        9
-#define RC_RTN_NO_FIRM_VER         10
-#define RC_RTN_NO_LINK_SPEED       11
-
-/* Driver capability flags */
-#define WARM_REBOOT_CAPABLE      0x01
-
-/*
-** Status - Transmit and Receive callback status word 
-**
-** A 32 bit Status is returned to the TX and RX callback functions.  This value
-** contains both the reply status and the detailed status as follows:
-**
-**  32    24     16            0
-**  +------+------+------------+
-**  | Reply|      |  Detailed  |
-**  |Status|   0  |   Status   |
-**  +------+------+------------+
-**
-** Reply Status and Detailed Status of zero indicates No Errors.
-*/
- /* reply message status defines */
-#define    I2O_REPLY_STATUS_SUCCESS                    0x00
-#define    I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER     0x02
-#define    I2O_REPLY_STATUS_TRANSACTION_ERROR          0x0A
-
-/* DetailedStatusCode defines */
-#define    I2O_LAN_DSC_SUCCESS                         0x0000
-#define    I2O_LAN_DSC_DEVICE_FAILURE                  0x0001
-#define    I2O_LAN_DSC_DESTINATION_NOT_FOUND           0x0002
-#define    I2O_LAN_DSC_TRANSMIT_ERROR                  0x0003
-#define    I2O_LAN_DSC_TRANSMIT_ABORTED                0x0004
-#define    I2O_LAN_DSC_RECEIVE_ERROR                   0x0005
-#define    I2O_LAN_DSC_RECEIVE_ABORTED                 0x0006
-#define    I2O_LAN_DSC_DMA_ERROR                       0x0007
-#define    I2O_LAN_DSC_BAD_PACKET_DETECTED             0x0008
-#define    I2O_LAN_DSC_OUT_OF_MEMORY                   0x0009
-#define    I2O_LAN_DSC_BUCKET_OVERRUN                  0x000A
-#define    I2O_LAN_DSC_IOP_INTERNAL_ERROR              0x000B
-#define    I2O_LAN_DSC_CANCELED                        0x000C
-#define    I2O_LAN_DSC_INVALID_TRANSACTION_CONTEXT     0x000D
-#define    I2O_LAN_DSC_DESTINATION_ADDRESS_DETECTED    0x000E
-#define    I2O_LAN_DSC_DESTINATION_ADDRESS_OMITTED     0x000F
-#define    I2O_LAN_DSC_PARTIAL_PACKET_RETURNED         0x0010
-
-/*
-** Packet Description Block   (Received packets)
-**
-** A pointer to this block structure is returned to the ReceiveCallback 
-** function.  It contains the list of packet buffers which have either been
-** filled with a packet or returned to host due to a LANReset function. 
-** Currently there will only be one packet per receive bucket (buffer) posted. 
-**
-**   32   24               0     
-**  +-----------------------+  -\
-**  |   Buffer 1 Context    |    \
-**  +-----------------------+     \
-**  |      0xC0000000       |     / First Bucket Descriptor
-**  +-----+-----------------+    /
-**  |  0  | packet 1 length |   / 
-**  +-----------------------+  -\
-**  |   Buffer 2 Context    |    \
-**  +-----------------------+     \
-**  |      0xC0000000       |     / Second Bucket Descriptor
-**  +-----+-----------------+    /
-**  |  0  | packet 2 length |   / 
-**  +-----+-----------------+  -
-**  |         ...           |  ----- more bucket descriptors
-**  +-----------------------+  -\
-**  |   Buffer n Context    |    \
-**  +-----------------------+     \
-**  |      0xC0000000       |     / Last Bucket Descriptor
-**  +-----+-----------------+    /
-**  |  0  | packet n length |   / 
-**  +-----+-----------------+  -
-**
-** Buffer Context values are those given to adapter in the TCB on calls to
-** RCPostRecvBuffers().
-**  
-*/
-
-/*
-** Transaction Control Block (TCB) structure
-**
-** A structure like this is filled in by the user and passed by reference to 
-** RCI2OSendPacket() and RCPostRecvBuffers() functions.  Minimum size is five
-** 32-bit words for one buffer with one segment descriptor.  
-** MAX_NMBR_POST_BUFFERS_PER_MSG defines the maximum single segment buffers
-** that can be described in a given TCB.
-**
-**   32                    0
-**  +-----------------------+
-**  |   Buffer Count        |  Number of buffers in the TCB
-**  +-----------------------+
-**  |   Buffer 1 Context    |  first buffer reference
-**  +-----------------------+
-**  |   Buffer 1 Seg Count  |  number of segments in buffer
-**  +-----------------------+
-**  |   Buffer 1 Seg Desc 1 |  first segment descriptor (size, physical address)
-**  +-----------------------+
-**  |         ...           |  more segment descriptors (size, physical address)
-**  +-----------------------+
-**  |   Buffer 1 Seg Desc n |  last segment descriptor (size, physical address)
-**  +-----------------------+
-**  |   Buffer 2 Context    |  second buffer reference
-**  +-----------------------+
-**  |   Buffer 2 Seg Count  |  number of segments in buffer
-**  +-----------------------+
-**  |   Buffer 2 Seg Desc 1 |  segment descriptor (size, physical address)
-**  +-----------------------+
-**  |         ...           |  more segment descriptors (size, physical address)
-**  +-----------------------+
-**  |   Buffer 2 Seg Desc n |
-**  +-----------------------+
-**  |         ...           |  more buffer descriptor blocks ...
-**  +-----------------------+
-**  |   Buffer n Context    |
-**  +-----------------------+
-**  |   Buffer n Seg Count  |
-**  +-----------------------+
-**  |   Buffer n Seg Desc 1 |
-**  +-----------------------+
-**  |         ...           |
-**  +-----------------------+
-**  |   Buffer n Seg Desc n |
-**  +-----------------------+
-**
-**
-** A TCB for one contigous packet buffer would look like the following:
-**
-**   32                    0
-**  +-----------------------+
-**  |         1             |  one buffer in the TCB
-**  +-----------------------+
-**  |  <user's Context>     |  user's buffer reference
-**  +-----------------------+
-**  |         1             |  one segment buffer
-**  +-----------------------+                            _
-**  |    <buffer size>      |  size                       \ 
-**  +-----------------------+                              \ segment descriptor
-**  |  <physical address>   |  physical address of buffer  /
-**  +-----------------------+                            _/
-**
-*/
-
- /* Buffer Segment Descriptor */
-typedef struct {
-       U32 size;
-       U32 phyAddress;
-} BSD, *PBSD;
-
-typedef PU32 PRCTCB;
-/*
-** -------------------------------------------------------------------------
-** Exported functions comprising the API to the LAN I2O message transport layer
-** -------------------------------------------------------------------------
-*/
-
- /*
-    ** InitRCI2OMsgLayer()
-    ** 
-    ** Called once prior to using the I2O LAN message transport layer.  User 
-    ** provides both the physical and virual address of a locked page buffer 
-    ** that is used as a private buffer for the RedCreek I2O message
-    ** transport layer.  This buffer must be a contigous memory block of a 
-    ** minimum of 16K bytes and long word aligned.  The user also must provide
-    ** the base address of the RedCreek PCI adapter assigned by BIOS or operating
-    ** system.  
-    **
-    ** Inputs:  dev - the net_device struct for the device.
-    **          TransmitCallbackFunction - address of user's TX callback function
-    **          ReceiveCallbackFunction  - address of user's RX callback function
-    **          RebootCallbackFunction  - address of user's reboot callback function
-    **
-  */
-RC_RETURN RCInitI2OMsgLayer (struct net_device *dev,
-                            PFNTXCALLBACK TransmitCallbackFunction,
-                            PFNRXCALLBACK ReceiveCallbackFunction,
-                            PFNCALLBACK RebootCallbackFunction);
-
- /*
-    ** RCSetRavlinIPandMask()
-    **
-    ** Set the Ravlin 45/PCI cards IP address and network mask.
-    **
-    ** IP address and mask must be in network byte order.
-    ** For example, IP address 1.2.3.4 and mask 255.255.255.0 would be
-    ** 0x04030201 and 0x00FFFFFF on a little endian machine.
-    **
-  */
-RC_RETURN RCSetRavlinIPandMask (struct net_device *dev, U32 ipAddr,
-                               U32 netMask);
-
-/*
-** =========================================================================
-** RCGetRavlinIPandMask()
-**
-** get the IP address and MASK from the card
-** 
-** =========================================================================
-*/
-RC_RETURN
-RCGetRavlinIPandMask (struct net_device *dev, PU32 pIpAddr, PU32 pNetMask,
-                     PFNWAITCALLBACK WaitCallback);
-
- /* 
-    ** RCProcI2OMsgQ()
-    ** 
-    ** Called from user's polling loop or Interrupt Service Routine for a PCI 
-    ** interrupt from the RedCreek PCI adapter.  User responsible for determining
-    ** and hooking the PCI interrupt. This function will call the registered
-    ** callback functions, TransmitCallbackFunction or ReceiveCallbackFunction,
-    ** if a TX or RX transaction has completed.
-  */
-irqreturn_t RCProcI2OMsgQ (struct net_device *dev);
-
- /*
-    ** Disable and Enable I2O interrupts.  I2O interrupts are enabled at Init time
-    ** but can be disabled and re-enabled through these two function calls.
-    ** Packets will still be put into any posted received buffers and packets will
-    ** be sent through RCI2OSendPacket() functions.  Disabling I2O interrupts
-    ** will prevent hardware interrupt to host even though the outbound I2O msg
-    ** queue is not emtpy.
-  */
-RC_RETURN RCEnableI2OInterrupts (struct net_device *dev);
-RC_RETURN RCDisableI2OInterrupts (struct net_device *dev);
-
- /* 
-    ** RCPostRecvBuffers()
-    ** 
-    ** Post user's page locked buffers for use by the PCI adapter to
-    ** return ethernet packets received from the LAN.  Transaction Control Block,
-    ** provided by user, contains buffer descriptor(s) which includes a buffer
-    ** context number along with buffer size and physical address.  See TCB above.
-    ** The buffer context and actual packet length are returned to the 
-    ** ReceiveCallbackFunction when packets have been received.  Buffers posted
-    ** to the RedCreek adapter are considered owned by the adapter until the
-    ** context is return to user through the ReceiveCallbackFunction.
-  */
-RC_RETURN RCPostRecvBuffers (struct net_device *dev,
-                            PRCTCB pTransactionCtrlBlock);
-#define MAX_NMBR_POST_BUFFERS_PER_MSG 32
-
- /*
-    ** RCI2OSendPacket()
-    ** 
-    ** Send user's ethernet packet from a locked page buffer.  
-    ** Packet must have full MAC header, however without a CRC.  
-    ** Initiator context is a user provided value that is returned 
-    ** to the TransmitCallbackFunction when packet buffer is free.
-    ** Transmit buffer are considered owned by the adapter until context's
-    ** returned to user through the TransmitCallbackFunction.
-  */
-RC_RETURN RCI2OSendPacket (struct net_device *dev,
-                          U32 context, PRCTCB pTransactionCtrlBlock);
-
- /* Ethernet Link Statistics structure */
-typedef struct tag_RC_link_stats {
-       U32 TX_good;            /* good transmit frames */
-       U32 TX_maxcol;          /* frames not TX due to MAX collisions */
-       U32 TX_latecol;         /* frames not TX due to late collisions */
-       U32 TX_urun;            /* frames not TX due to DMA underrun */
-       U32 TX_crs;             /* frames TX with lost carrier sense */
-       U32 TX_def;             /* frames deferred due to activity on link */
-       U32 TX_singlecol;       /* frames TX with one and only on collision */
-       U32 TX_multcol;         /* frames TX with more than one collision */
-       U32 TX_totcol;          /* total collisions detected during TX */
-       U32 Rcv_good;           /* good frames received */
-       U32 Rcv_CRCerr;         /* frames RX and discarded with CRC errors */
-       U32 Rcv_alignerr;       /* frames RX with alignment and CRC errors */
-       U32 Rcv_reserr;         /* good frames discarded due to no RX buffer */
-       U32 Rcv_orun;           /* RX frames lost due to FIFO overrun */
-       U32 Rcv_cdt;            /* RX frames with collision during RX */
-       U32 Rcv_runt;           /* RX frames shorter than 64 bytes */
-} RCLINKSTATS, *P_RCLINKSTATS;
-
- /*
-    ** RCGetLinkStatistics()
-    **
-    ** Returns link statistics in user's structure at address StatsReturnAddr
-    ** If given, not NULL, the function WaitCallback is called during the wait
-    ** loop while waiting for the adapter to respond.
-  */
-RC_RETURN RCGetLinkStatistics (struct net_device *dev,
-                              P_RCLINKSTATS StatsReturnAddr,
-                              PFNWAITCALLBACK WaitCallback);
-
- /*
-    ** RCGetLinkStatus()
-    **
-    ** Return link status, up or down, to user's location addressed by ReturnAddr.
-    ** If given, not NULL, the function WaitCallback is called during the wait
-    ** loop while waiting for the adapter to respond.
-  */
-RC_RETURN RCGetLinkStatus (struct net_device *dev,
-                          PU32 pReturnStatus, PFNWAITCALLBACK WaitCallback);
-
- /* Link Status defines - value returned in pReturnStatus */
-#define RC_LAN_LINK_STATUS_DOWN     0
-#define RC_LAN_LINK_STATUS_UP       1
-
- /*
-    ** RCGetMAC()
-    **
-    ** Get the current MAC address assigned to user.  RedCreek Ravlin 45/PCI 
-    ** has two MAC addresses.  One which is private to the PCI Card, and 
-    ** another MAC which is given to the user as its link layer MAC address. The
-    ** adapter runs in promiscous mode because of the dual address requirement.
-    ** The MAC address is returned to the unsigned char array pointer to by mac.
-  */
-RC_RETURN RCGetMAC (struct net_device *dev, PFNWAITCALLBACK WaitCallback);
-
- /*
-    ** RCSetMAC()
-    **
-    ** Set a new user port MAC address.  This address will be returned on
-    ** subsequent RCGetMAC() calls.
-  */
-RC_RETURN RCSetMAC (struct net_device *dev, PU8 mac);
-
- /*
-    ** RCSetLinkSpeed()
-    **
-    ** set adapter's link speed based on given input code.
-  */
-RC_RETURN RCSetLinkSpeed (struct net_device *dev, U16 LinkSpeedCode);
- /* Set link speed codes */
-#define LNK_SPD_AUTO_NEG_NWAY   0
-#define LNK_SPD_100MB_FULL      1
-#define LNK_SPD_100MB_HALF      2
-#define LNK_SPD_10MB_FULL       3
-#define LNK_SPD_10MB_HALF       4
-
- /*
-    ** RCGetLinkSpeed()
-    **
-    ** Return link speed code.
-  */
- /* Return link speed codes */
-#define LNK_SPD_UNKNOWN         0
-#define LNK_SPD_100MB_FULL      1
-#define LNK_SPD_100MB_HALF      2
-#define LNK_SPD_10MB_FULL       3
-#define LNK_SPD_10MB_HALF       4
-
-RC_RETURN
-RCGetLinkSpeed (struct net_device *dev, PU32 pLinkSpeedCode,
-               PFNWAITCALLBACK WaitCallback);
-/*
-** =========================================================================
-** RCSetPromiscuousMode(struct net_device *dev, U16 Mode)
-**
-** Defined values for Mode:
-**  0 - turn off promiscuous mode
-**  1 - turn on  promiscuous mode
-**
-** =========================================================================
-*/
-#define PROMISCUOUS_MODE_OFF 0
-#define PROMISCUOUS_MODE_ON  1
-RC_RETURN RCSetPromiscuousMode (struct net_device *dev, U16 Mode);
-/*
-** =========================================================================
-** RCGetPromiscuousMode(struct net_device *dev, PU32 pMode, PFNWAITCALLBACK WaitCallback)
-**
-** get promiscuous mode setting
-**
-** Possible return values placed in pMode:
-**  0 = promisuous mode not set
-**  1 = promisuous mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetPromiscuousMode (struct net_device *dev, PU32 pMode,
-                     PFNWAITCALLBACK WaitCallback);
-
-/*
-** =========================================================================
-** RCSetBroadcastMode(struct net_device *dev, U16 Mode)
-**
-** Defined values for Mode:
-**  0 - turn off promiscuous mode
-**  1 - turn on  promiscuous mode
-**
-** =========================================================================
-*/
-#define BROADCAST_MODE_OFF 0
-#define BROADCAST_MODE_ON  1
-RC_RETURN RCSetBroadcastMode (struct net_device *dev, U16 Mode);
-/*
-** =========================================================================
-** RCGetBroadcastMode(struct net_device *dev, PU32 pMode, PFNWAITCALLBACK WaitCallback)
-**
-** get broadcast mode setting
-**
-** Possible return values placed in pMode:
-**  0 = broadcast mode not set
-**  1 = broadcast mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetBroadcastMode (struct net_device *dev, PU32 pMode,
-                   PFNWAITCALLBACK WaitCallback);
-/*
-** =========================================================================
-** RCReportDriverCapability(struct net_device *dev, U32 capability)
-**
-** Currently defined bits:
-** WARM_REBOOT_CAPABLE   0x01
-**
-** =========================================================================
-*/
-RC_RETURN RCReportDriverCapability (struct net_device *dev, U32 capability);
-
-/*
-** RCGetFirmwareVer()
-**
-** Return firmware version in the form "SoftwareVersion : Bt BootVersion"
-**
-** WARNING: user's space pointed to by pFirmString should be at least 60 bytes.
-*/
-RC_RETURN
-RCGetFirmwareVer (struct net_device *dev, PU8 pFirmString,
-                 PFNWAITCALLBACK WaitCallback);
-
-/*
-** ----------------------------------------------
-** LAN adapter Reset and Shutdown functions
-** ----------------------------------------------
-*/
- /* resource flag bit assignments for RCResetLANCard() & RCShutdownLANCard() */
-#define RC_RESOURCE_RETURN_POSTED_RX_BUCKETS  0x0001
-#define RC_RESOURCE_RETURN_PEND_TX_BUFFERS    0x0002
-
- /*
-    ** RCResetLANCard()
-    **
-    ** Reset LAN card operation.  Causes a software reset of the ethernet
-    ** controller and restarts the command and receive units. Depending on 
-    ** the ResourceFlags given, the buffers are either returned to the
-    ** host with reply status of I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER and
-    ** detailed status of I2O_LAN_DSC_CANCELED (new receive buffers must be
-    ** posted after issuing this) OR the buffers are kept and reused by
-    ** the ethernet controller. If CallbackFunction is not NULL, the function
-    ** will be called when the reset is complete.  If the CallbackFunction is
-    ** NULL,a 1 will be put into the ReturnAddr after waiting for the reset 
-    ** to complete (please disable I2O interrupts during this method).
-    ** Any outstanding transmit or receive buffers that are complete will be
-    ** returned via the normal reply messages before the requested resource
-    ** buffers are returned.
-    ** A call to RCPostRecvBuffers() is needed to return the ethernet to full
-    ** operation if the receive buffers were returned during LANReset.
-    ** Note: The IOP status is not affected by a LAN reset.
-  */
-RC_RETURN RCResetLANCard (struct net_device *dev, U16 ResourceFlags,
-                         PU32 ReturnAddr, PFNCALLBACK CallbackFunction);
-
- /*
-    ** RCShutdownLANCard()
-    **
-    ** Shutdown LAN card operation and put into an idle (suspended) state.
-    ** The LAN card is restarted with RCResetLANCard() function.
-    ** Depending on the ResourceFlags given, the buffers are either returned 
-    ** to the host with reply status of I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 
-    ** and detailed status of I2O_LAN_DSC_CANCELED (new receive buffers must be
-    ** posted after issuing this) OR the buffers are kept and reused by
-    ** the ethernet controller. If CallbackFunction is not NULL, the function
-    ** will be called when the reset is complete.  If the CallbackFunction is
-    ** NULL,a 1 will be put into the ReturnAddr after waiting for the reset 
-    ** to complete (please disable I2O interrupts during this method).
-    ** Any outstanding transmit or receive buffers that are complete will be
-    ** returned via the normal reply messages before the requested resource
-    ** buffers are returned.
-    ** Note: The IOP status is not affected by a LAN shutdown.
-  */
-RC_RETURN
-RCShutdownLANCard (struct net_device *dev, U16 ResourceFlags, PU32 ReturnAddr,
-                  PFNCALLBACK CallbackFunction);
-
- /*
-    ** RCResetIOP();
-    **     Initializes IOPState to I2O_IOP_STATE_RESET.
-    **     Stops access to outbound message Q.
-    **     Discards any outstanding transmit or posted receive buffers.
-    **     Clears outbound message Q. 
-  */
-RC_RETURN RCResetIOP (struct net_device *dev);
-
-#endif                         /* RCLANMTL_H */
diff --git a/drivers/net/rcpci45.c b/drivers/net/rcpci45.c
deleted file mode 100644 (file)
index 76b63f3..0000000
+++ /dev/null
@@ -1,1049 +0,0 @@
-/* 
-**
-**  RCpci45.c  
-**
-**
-**
-**  ---------------------------------------------------------------------
-**  ---     Copyright (c) 1998, 1999, RedCreek Communications Inc.    ---
-**  ---                   All rights reserved.                        ---
-**  ---------------------------------------------------------------------
-**
-** Written by Pete Popov and Brian Moyle.
-**
-** Known Problems
-** 
-** None known at this time.
-**
-**  This program is free software; you can redistribute it and/or modify
-**  it under the terms of the GNU General Public License as published by
-**  the Free Software Foundation; either version 2 of the License, or
-**  (at your option) any later version.
-
-**  This program is distributed in the hope that it will be useful,
-**  but WITHOUT ANY WARRANTY; without even the implied warranty of
-**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-**  GNU General Public License for more details.
-
-**  You should have received a copy of the GNU General Public License
-**  along with this program; if not, write to the Free Software
-**  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-**  Francois Romieu, Apr 2003: Converted to pci DMA mapping API.
-**
-**  Pete Popov, Oct 2001: Fixed a few bugs to make the driver functional
-**  again. Note that this card is not supported or manufactured by 
-**  RedCreek anymore.
-**   
-**  Rasmus Andersen, December 2000: Converted to new PCI API and general
-**  cleanup.
-**
-**  Pete Popov, January 11,99: Fixed a couple of 2.1.x problems 
-**  (virt_to_bus() not called), tested it under 2.2pre5 (as a module), and 
-**  added a #define(s) to enable the use of the same file for both, the 2.0.x 
-**  kernels as well as the 2.1.x.
-**
-**  Ported to 2.1.x by Alan Cox 1998/12/9. 
-**
-**  Sometime in mid 1998, written by Pete Popov and Brian Moyle.
-**
-***************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/in.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/timer.h>
-
-#include <asm/irq.h>           /* For NR_IRQS only. */
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-
-static char version[] __initdata =
-    "RedCreek Communications PCI linux driver version 2.21\n";
-
-#define RC_LINUX_MODULE
-#include "rclanmtl.h"
-#include "rcif.h"
-
-#define RUN_AT(x) (jiffies + (x))
-
-#define NEW_MULTICAST
-
-#define MAX_ETHER_SIZE        1520
-#define MAX_NMBR_RCV_BUFFERS    96
-#define RC_POSTED_BUFFERS_LOW_MARK MAX_NMBR_RCV_BUFFERS-16
-#define BD_SIZE 3              /* Bucket Descriptor size */
-#define BD_LEN_OFFSET 2                /* Bucket Descriptor offset to length field */
-
-/* RedCreek LAN device Target ID */
-#define RC_LAN_TARGET_ID  0x10
-/* RedCreek's OSM default LAN receive Initiator */
-#define DEFAULT_RECV_INIT_CONTEXT  0xA17
-
-/* minimum msg buffer size needed by the card 
- * Note that the size of this buffer is hard code in the
- * ipsec card's firmware. Thus, the size MUST be a minimum
- * of 16K. Otherwise the card will end up using memory
- * that does not belong to it.
- */
-#define MSG_BUF_SIZE  16384
-
-/* 2003/04/20: I don't know about the hardware ability but the driver won't
- * play safe with 64 bit addressing and DAC without NETIF_F_HIGHDMA doesn't
- * really make sense anyway. Let's play safe - romieu.
- */
-#define RCPCI45_DMA_MASK       ((u64) 0xffffffff)
-
-static U32 DriverControlWord;
-
-static void rc_timer (unsigned long);
-
-static int RCopen (struct net_device *);
-static int RC_xmit_packet (struct sk_buff *, struct net_device *);
-static irqreturn_t RCinterrupt (int, void *, struct pt_regs *);
-static int RCclose (struct net_device *dev);
-static struct net_device_stats *RCget_stats (struct net_device *);
-static int RCioctl (struct net_device *, struct ifreq *, int);
-static int RCconfig (struct net_device *, struct ifmap *);
-static void RCxmit_callback (U32, U16, PU32, struct net_device *);
-static void RCrecv_callback (U32, U8, U32, PU32, struct net_device *);
-static void RCreset_callback (U32, U32, U32, struct net_device *);
-static void RCreboot_callback (U32, U32, U32, struct net_device *);
-static int RC_allocate_and_post_buffers (struct net_device *, int);
-
-static struct pci_device_id rcpci45_pci_table[] = {
-       { PCI_VENDOR_ID_REDCREEK, PCI_DEVICE_ID_RC45, PCI_ANY_ID, PCI_ANY_ID,},
-       {}
-};
-MODULE_DEVICE_TABLE (pci, rcpci45_pci_table);
-MODULE_LICENSE("GPL");
-
-static void __devexit
-rcpci45_remove_one (struct pci_dev *pdev)
-{
-       struct net_device *dev = pci_get_drvdata (pdev);
-       PDPA pDpa = dev->priv;
-
-       RCResetIOP (dev);
-       unregister_netdev (dev);
-       free_irq (dev->irq, dev);
-       iounmap ((void *) dev->base_addr);
-       pci_release_regions (pdev);
-       pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
-                            pDpa->msgbuf_dma);
-       if (pDpa->pPab)
-               kfree (pDpa->pPab);
-       free_netdev (dev);
-       pci_set_drvdata (pdev, NULL);
-}
-
-static int
-rcpci45_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-       unsigned long *vaddr;
-       PDPA pDpa;
-       int error;
-       static int card_idx = -1;
-       struct net_device *dev;
-       unsigned long pci_start, pci_len;
-
-       card_idx++;
-
-       /* 
-        * Allocate and fill new device structure. 
-        * We need enough for struct net_device plus DPA plus the LAN 
-        * API private area, which requires a minimum of 16KB.  The top 
-        * of the allocated area will be assigned to struct net_device; 
-        * the next chunk will be assigned to DPA; and finally, the rest 
-        * will be assigned to the LAN API layer.
-        */
-
-       dev = alloc_etherdev(sizeof(*pDpa));
-       if (!dev) {
-               printk (KERN_ERR
-                       "(rcpci45 driver:) alloc_etherdev alloc failed\n");
-               error = -ENOMEM;
-               goto err_out;
-       }
-
-       SET_MODULE_OWNER(dev);
-       SET_NETDEV_DEV(dev, &pdev->dev);
-
-       error = pci_enable_device (pdev);
-       if (error) {
-               printk (KERN_ERR
-                       "(rcpci45 driver:) %d: pci enable device error\n",
-                       card_idx);
-               goto err_out;
-       }
-       pci_start = pci_resource_start (pdev, 0);
-       pci_len = pci_resource_len (pdev, 0);
-       printk("pci_start %lx pci_len %lx\n", pci_start, pci_len);
-
-       pci_set_drvdata (pdev, dev);
-
-       pDpa = dev->priv;
-       pDpa->id = card_idx;
-       pDpa->pci_dev = pdev;
-       pDpa->pci_addr = pci_start;
-
-       if (!pci_start || !(pci_resource_flags (pdev, 0) & IORESOURCE_MEM)) {
-               printk (KERN_ERR
-                       "(rcpci45 driver:) No PCI mem resources! Aborting\n");
-               error = -EBUSY;
-               goto err_out_free_dev;
-       }
-
-       /*
-        * pDpa->msgbuf is where the card will dma the I2O 
-        * messages. Thus, we need contiguous physical pages of memory.
-        * 2003/04/20:  pci_alloc_consistent() provides well over the needed
-        * alignment on a 256 bytes boundary for the LAN API private area.
-        * Thus it isn't needed anymore to align it by hand.
-         */
-       pDpa->msgbuf = pci_alloc_consistent (pdev, MSG_BUF_SIZE,
-                                            &pDpa->msgbuf_dma);
-       if (!pDpa->msgbuf) {
-               printk (KERN_ERR "(rcpci45 driver:) \
-                       Could not allocate %d byte memory for the \
-                               private msgbuf!\n", MSG_BUF_SIZE);
-               error = -ENOMEM;
-               goto err_out_free_dev;
-       }
-
-       /* The adapter is accessible through memory-access read/write, not
-        * I/O read/write.  Thus, we need to map it to some virtual address
-        * area in order to access the registers as normal memory.
-        */
-       error = pci_request_regions (pdev, dev->name);
-       if (error)
-               goto err_out_free_msgbuf;
-
-       error = pci_set_dma_mask (pdev, RCPCI45_DMA_MASK);
-       if (error) {
-               printk (KERN_ERR
-                       "(rcpci45 driver:) pci_set_dma_mask failed!\n");
-               goto err_out_free_region;
-       }
-
-       vaddr = (ulong *) ioremap (pci_start, pci_len);
-       if (!vaddr) {
-               printk (KERN_ERR
-                       "(rcpci45 driver:) \
-                       Unable to remap address range from %lu to %lu\n",
-                       pci_start, pci_start + pci_len);
-               error = -EIO;
-               goto err_out_free_region;
-       }
-
-       dev->base_addr = (unsigned long) vaddr;
-       dev->irq = pdev->irq;
-       dev->open = &RCopen;
-       dev->hard_start_xmit = &RC_xmit_packet;
-       dev->stop = &RCclose;
-       dev->get_stats = &RCget_stats;
-       dev->do_ioctl = &RCioctl;
-       dev->set_config = &RCconfig;
-
-       if ((error = register_netdev(dev)))
-               goto err_out_iounmap;
-
-       return 0;               /* success */
-
-err_out_iounmap:
-       iounmap((void *) dev->base_addr);
-err_out_free_region:
-       pci_release_regions (pdev);
-err_out_free_msgbuf:
-       pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
-                            pDpa->msgbuf_dma);
-err_out_free_dev:
-       free_netdev (dev);
-err_out:
-       card_idx--;
-       return error;
-}
-
-static struct pci_driver rcpci45_driver = {
-       .name           = "rcpci45",
-       .id_table       = rcpci45_pci_table,
-       .probe          = rcpci45_init_one,
-       .remove         = __devexit_p(rcpci45_remove_one),
-};
-
-static int __init
-rcpci_init_module (void)
-{
-       int rc = pci_module_init (&rcpci45_driver);
-       if (!rc)
-               printk (KERN_ERR "%s", version);
-       return rc;
-}
-
-static int
-RCopen (struct net_device *dev)
-{
-       int post_buffers = MAX_NMBR_RCV_BUFFERS;
-       PDPA pDpa = dev->priv;
-       int count = 0;
-       int requested = 0;
-       int error;
-
-       if (pDpa->nexus) {
-               /* This is not the first time RCopen is called.  Thus,
-                * the interface was previously opened and later closed
-                * by RCclose().  RCclose() does a Shutdown; to wake up
-                * the adapter, a reset is mandatory before we can post
-                * receive buffers.  However, if the adapter initiated 
-                * a reboot while the interface was closed -- and interrupts
-                * were turned off -- we need will need to reinitialize
-                * the adapter, rather than simply waking it up.  
-                */
-               printk (KERN_INFO "Waking up adapter...\n");
-               RCResetLANCard (dev, 0, 0, 0);
-       } else {
-               pDpa->nexus = 1;
-               /* 
-                * RCInitI2OMsgLayer is done only once, unless the
-                * adapter was sent a warm reboot
-                */
-               error = RCInitI2OMsgLayer (dev, (PFNTXCALLBACK) RCxmit_callback,
-                                          (PFNRXCALLBACK) RCrecv_callback,
-                                          (PFNCALLBACK) RCreboot_callback);
-               if (error) {
-                       printk (KERN_ERR "%s: Unable to init msg layer (%x)\n",
-                                       dev->name, error);
-                       goto err_out;
-               }
-               if ((error = RCGetMAC (dev, NULL))) {
-                       printk (KERN_ERR "%s: Unable to get adapter MAC\n",
-                                       dev->name);
-                       goto err_out;
-               }
-       }
-
-       /* Request a shared interrupt line. */
-       error = request_irq (dev->irq, RCinterrupt, SA_SHIRQ, dev->name, dev);
-       if (error) {
-               printk (KERN_ERR "%s: unable to get IRQ %d\n", 
-                               dev->name, dev->irq);
-               goto err_out;
-       }
-
-       DriverControlWord |= WARM_REBOOT_CAPABLE;
-       RCReportDriverCapability (dev, DriverControlWord);
-
-       printk (KERN_INFO "%s: RedCreek Communications IPSEC VPN adapter\n",
-               dev->name);
-
-       RCEnableI2OInterrupts (dev);
-
-       while (post_buffers) {
-               if (post_buffers > MAX_NMBR_POST_BUFFERS_PER_MSG)
-                       requested = MAX_NMBR_POST_BUFFERS_PER_MSG;
-               else
-                       requested = post_buffers;
-               count = RC_allocate_and_post_buffers (dev, requested);
-
-               if (count < requested) {
-                       /*
-                        * Check to see if we were able to post 
-                        * any buffers at all.
-                        */
-                       if (post_buffers == MAX_NMBR_RCV_BUFFERS) {
-                               printk (KERN_ERR "%s: \
-                                       unable to allocate any buffers\n", 
-                                               dev->name);
-                               goto err_out_free_irq;
-                       }
-                       printk (KERN_WARNING "%s: \
-                       unable to allocate all requested buffers\n", dev->name);
-                       break;  /* we'll try to post more buffers later */
-               } else
-                       post_buffers -= count;
-       }
-       pDpa->numOutRcvBuffers = MAX_NMBR_RCV_BUFFERS - post_buffers;
-       pDpa->shutdown = 0;     /* just in case */
-       netif_start_queue (dev);
-       return 0;
-
-err_out_free_irq:
-       free_irq (dev->irq, dev);
-err_out:
-       return error;
-}
-
-static int
-RC_xmit_packet (struct sk_buff *skb, struct net_device *dev)
-{
-
-       PDPA pDpa = dev->priv;
-       singleTCB tcb;
-       psingleTCB ptcb = &tcb;
-       RC_RETURN status = 0;
-
-       netif_stop_queue (dev);
-
-       if (pDpa->shutdown || pDpa->reboot) {
-               printk ("RC_xmit_packet: tbusy!\n");
-               return 1;
-       }
-
-       /*
-        * The user is free to reuse the TCB after RCI2OSendPacket() 
-        * returns, since the function copies the necessary info into its 
-        * own private space.  Thus, our TCB can be a local structure.  
-        * The skb, on the other hand, will be freed up in our interrupt 
-        * handler.
-        */
-
-       ptcb->bcount = 1;
-
-       /* 
-        * we'll get the context when the adapter interrupts us to tell us that
-        * the transmission is done. At that time, we can free skb.
-        */
-       ptcb->b.context = (U32) skb;
-       ptcb->b.scount = 1;
-       ptcb->b.size = skb->len;
-       ptcb->b.addr = pci_map_single(pDpa->pci_dev, skb->data, skb->len,
-                                     PCI_DMA_TODEVICE);
-
-       if ((status = RCI2OSendPacket (dev, (U32) NULL, (PRCTCB) ptcb))
-           != RC_RTN_NO_ERROR) {
-               printk ("%s: send error 0x%x\n", dev->name, (uint) status);
-               return 1;
-       } else {
-               dev->trans_start = jiffies;
-               netif_wake_queue (dev);
-       }
-       /*
-        * That's it!
-        */
-       return 0;
-}
-
-/*
- * RCxmit_callback()
- *
- * The transmit callback routine. It's called by RCProcI2OMsgQ()
- * because the adapter is done with one or more transmit buffers and
- * it's returning them to us, or we asked the adapter to return the
- * outstanding transmit buffers by calling RCResetLANCard() with 
- * RC_RESOURCE_RETURN_PEND_TX_BUFFERS flag. 
- * All we need to do is free the buffers.
- */
-static void
-RCxmit_callback (U32 Status,
-                U16 PcktCount, PU32 BufferContext, struct net_device *dev)
-{
-       struct sk_buff *skb;
-       PDPA pDpa = dev->priv;
-
-       if (!pDpa) {
-               printk (KERN_ERR "%s: Fatal Error in xmit callback, !pDpa\n",
-                               dev->name);
-               return;
-       }
-
-       if (Status != I2O_REPLY_STATUS_SUCCESS)
-               printk (KERN_INFO "%s: xmit_callback: Status = 0x%x\n", 
-                               dev->name, (uint) Status);
-       if (pDpa->shutdown || pDpa->reboot)
-               printk (KERN_INFO "%s: xmit callback: shutdown||reboot\n",
-                               dev->name);
-
-       while (PcktCount--) {
-               skb = (struct sk_buff *) (BufferContext[0]);
-               BufferContext++;
-               pci_unmap_single(pDpa->pci_dev, BufferContext[1], skb->len,
-                                PCI_DMA_TODEVICE);
-               dev_kfree_skb_irq (skb);
-       }
-       netif_wake_queue (dev);
-}
-
-static void
-RCreset_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
-{
-       PDPA pDpa = dev->priv;
-
-       printk ("RCreset_callback Status 0x%x\n", (uint) Status);
-       /*
-        * Check to see why we were called.
-        */
-       if (pDpa->shutdown) {
-               printk (KERN_INFO "%s: shutting down interface\n",
-                               dev->name);
-               pDpa->shutdown = 0;
-               pDpa->reboot = 0;
-       } else if (pDpa->reboot) {
-               printk (KERN_INFO "%s: reboot, shutdown adapter\n",
-                               dev->name);
-               /*
-                * We don't set any of the flags in RCShutdownLANCard()
-                * and we don't pass a callback routine to it.
-                * The adapter will have already initiated the reboot by
-                * the time the function returns.
-                */
-               RCDisableI2OInterrupts (dev);
-               RCShutdownLANCard (dev, 0, 0, 0);
-               printk (KERN_INFO "%s: scheduling timer...\n", dev->name);
-               init_timer (&pDpa->timer);
-               pDpa->timer.expires = RUN_AT ((40 * HZ) / 10);  /* 4 sec. */
-               pDpa->timer.data = (unsigned long) dev;
-               pDpa->timer.function = &rc_timer;       /* timer handler */
-               add_timer (&pDpa->timer);
-       }
-}
-
-static void
-RCreboot_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
-{
-       PDPA pDpa = dev->priv;
-
-       printk (KERN_INFO "%s: reboot: rcv buffers outstanding = %d\n",
-                dev->name, (uint) pDpa->numOutRcvBuffers);
-
-       if (pDpa->shutdown) {
-               printk (KERN_INFO "%s: skip reboot, shutdown initiated\n",
-                               dev->name);
-               return;
-       }
-       pDpa->reboot = 1;
-       /*
-        * OK, we reset the adapter and ask it to return all
-        * outstanding transmit buffers as well as the posted
-        * receive buffers.  When the adapter is done returning
-        * those buffers, it will call our RCreset_callback() 
-        * routine.  In that routine, we'll call RCShutdownLANCard()
-        * to tell the adapter that it's OK to start the reboot and
-        * schedule a timer callback routine to execute 3 seconds 
-        * later; this routine will reinitialize the adapter at that time.
-        */
-       RCResetLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
-                       RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
-                       (PFNCALLBACK) RCreset_callback);
-}
-
-/*
- * RCrecv_callback()
- * 
- * The receive packet callback routine.  This is called by
- * RCProcI2OMsgQ() after the adapter posts buffers which have been
- * filled (one ethernet packet per buffer).
- */
-static void
-RCrecv_callback (U32 Status,
-                U8 PktCount,
-                U32 BucketsRemain,
-                PU32 PacketDescBlock, struct net_device *dev)
-{
-
-       U32 len, count;
-       PDPA pDpa = dev->priv;
-       struct sk_buff *skb;
-       singleTCB tcb;
-       psingleTCB ptcb = &tcb;
-
-       ptcb->bcount = 1;
-
-       if ((pDpa->shutdown || pDpa->reboot) && !Status)
-               printk (KERN_INFO "%s: shutdown||reboot && !Status (%d)\n",
-                               dev->name, PktCount);
-
-       if ((Status != I2O_REPLY_STATUS_SUCCESS) || pDpa->shutdown) {
-               /*
-                * Free whatever buffers the adapter returned, but don't
-                * pass them to the kernel.
-                */
-
-               if (!pDpa->shutdown && !pDpa->reboot)
-                       printk (KERN_INFO "%s: recv error status = 0x%x\n",
-                                       dev->name, (uint) Status);
-               else
-                       printk (KERN_DEBUG "%s: Returning %d buffs stat 0x%x\n",
-                                       dev->name, PktCount, (uint) Status);
-               /*
-                * TO DO: check the nature of the failure and put the 
-                * adapter in failed mode if it's a hard failure.  
-                * Send a reset to the adapter and free all outstanding memory.
-                */
-               if (PacketDescBlock) {
-                       while (PktCount--) {
-                               skb = (struct sk_buff *) PacketDescBlock[0];
-                               dev_kfree_skb (skb);
-                               pDpa->numOutRcvBuffers--;
-                               /* point to next context field */
-                               PacketDescBlock += BD_SIZE;
-                       }
-               }
-               return;
-       } else {
-               while (PktCount--) {
-                       skb = (struct sk_buff *) PacketDescBlock[0];
-                       len = PacketDescBlock[2];
-                       skb->dev = dev;
-                       skb_put (skb, len);     /* adjust length and tail */
-                       skb->protocol = eth_type_trans (skb, dev);
-                       netif_rx (skb); /* send the packet to the kernel */
-                       dev->last_rx = jiffies;
-                       pDpa->numOutRcvBuffers--;       
-                       /* point to next context field */
-                       PacketDescBlock += BD_SIZE;
-               }
-       }
-
-       /*
-        * Replenish the posted receive buffers. 
-        * DO NOT replenish buffers if the driver has already
-        * initiated a reboot or shutdown!
-        */
-
-       if (!pDpa->shutdown && !pDpa->reboot) {
-               count = RC_allocate_and_post_buffers (dev,
-                                                     MAX_NMBR_RCV_BUFFERS -
-                                                     pDpa->numOutRcvBuffers);
-               pDpa->numOutRcvBuffers += count;
-       }
-
-}
-
-/*
- * RCinterrupt()
- * 
- * Interrupt handler. 
- * This routine sets up a couple of pointers and calls
- * RCProcI2OMsgQ(), which in turn process the message and
- * calls one of our callback functions.
- */
-static irqreturn_t
-RCinterrupt (int irq, void *dev_id, struct pt_regs *regs)
-{
-
-       PDPA pDpa;
-       struct net_device *dev = dev_id;
-
-       pDpa = dev->priv;
-
-       if (pDpa->shutdown)
-               printk (KERN_DEBUG "%s: shutdown, service irq\n",
-                               dev->name);
-
-       return RCProcI2OMsgQ (dev);
-}
-
-#define REBOOT_REINIT_RETRY_LIMIT 4
-static void
-rc_timer (unsigned long data)
-{
-       struct net_device *dev = (struct net_device *) data;
-       PDPA pDpa = dev->priv;
-       int init_status;
-       static int retry;
-       int post_buffers = MAX_NMBR_RCV_BUFFERS;
-       int count = 0;
-       int requested = 0;
-
-       if (pDpa->reboot) {
-               init_status =
-                   RCInitI2OMsgLayer (dev, (PFNTXCALLBACK) RCxmit_callback,
-                                      (PFNRXCALLBACK) RCrecv_callback,
-                                      (PFNCALLBACK) RCreboot_callback);
-
-               switch (init_status) {
-               case RC_RTN_NO_ERROR:
-
-                       pDpa->reboot = 0;
-                       pDpa->shutdown = 0;     /* just in case */
-                       RCReportDriverCapability (dev, DriverControlWord);
-                       RCEnableI2OInterrupts (dev);
-
-
-                       if (!(dev->flags & IFF_UP)) {
-                               retry = 0;
-                               return;
-                       }
-                       while (post_buffers) {
-                               if (post_buffers > 
-                                               MAX_NMBR_POST_BUFFERS_PER_MSG)
-                                       requested = 
-                                               MAX_NMBR_POST_BUFFERS_PER_MSG;
-                               else
-                                       requested = post_buffers;
-                               count =
-                                   RC_allocate_and_post_buffers (dev,
-                                                                 requested);
-                               post_buffers -= count;
-                               if (count < requested)
-                                       break;
-                       }
-                       pDpa->numOutRcvBuffers =
-                           MAX_NMBR_RCV_BUFFERS - post_buffers;
-                       printk ("Initialization done.\n");
-                       netif_wake_queue (dev);
-                       retry = 0;
-                       return;
-               case RC_RTN_FREE_Q_EMPTY:
-                       retry++;
-                       printk (KERN_WARNING "%s inbound free q empty\n",
-                                       dev->name);
-                       break;
-               default:
-                       retry++;
-                       printk (KERN_WARNING "%s bad stat after reboot: %d\n",
-                                       dev->name, init_status);
-                       break;
-               }
-
-               if (retry > REBOOT_REINIT_RETRY_LIMIT) {
-                       printk (KERN_WARNING "%s unable to reinitialize adapter after reboot\n", dev->name);
-                       printk (KERN_WARNING "%s shutting down interface\n", dev->name);
-                       RCDisableI2OInterrupts (dev);
-                       dev->flags &= ~IFF_UP;
-               } else {
-                       printk (KERN_INFO "%s: rescheduling timer...\n",
-                                       dev->name);
-                       init_timer (&pDpa->timer);
-                       pDpa->timer.expires = RUN_AT ((40 * HZ) / 10);
-                       pDpa->timer.data = (unsigned long) dev;
-                       pDpa->timer.function = &rc_timer;
-                       add_timer (&pDpa->timer);
-               }
-       } else
-               printk (KERN_WARNING "%s: unexpected timer irq\n", dev->name);
-}
-
-static int
-RCclose (struct net_device *dev)
-{
-       PDPA pDpa = dev->priv;
-
-       printk("RCclose\n");
-       netif_stop_queue (dev);
-
-       if (pDpa->reboot) {
-               printk (KERN_INFO "%s skipping reset -- adapter already in reboot mode\n", dev->name);
-               dev->flags &= ~IFF_UP;
-               pDpa->shutdown = 1;
-               return 0;
-       }
-
-       pDpa->shutdown = 1;
-
-       /*
-        * We can't allow the driver to be unloaded until the adapter returns
-        * all posted receive buffers.  It doesn't hurt to tell the adapter
-        * to return all posted receive buffers and outstanding xmit buffers,
-        * even if there are none.
-        */
-
-       RCShutdownLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
-                          RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
-                          (PFNCALLBACK) RCreset_callback);
-
-       dev->flags &= ~IFF_UP;
-       return 0;
-}
-
-static struct net_device_stats *
-RCget_stats (struct net_device *dev)
-{
-       RCLINKSTATS RCstats;
-
-       PDPA pDpa = dev->priv;
-
-       if (!pDpa) {
-               return 0;
-       } else if (!(dev->flags & IFF_UP)) {
-               return 0;
-       }
-
-       memset (&RCstats, 0, sizeof (RCLINKSTATS));
-       if ((RCGetLinkStatistics (dev, &RCstats, (void *) 0)) ==
-           RC_RTN_NO_ERROR) {
-
-               /* total packets received    */
-               pDpa->stats.rx_packets = RCstats.Rcv_good
-               /* total packets transmitted    */;
-               pDpa->stats.tx_packets = RCstats.TX_good;
-
-               pDpa->stats.rx_errors = RCstats.Rcv_CRCerr + 
-                       RCstats.Rcv_alignerr + RCstats.Rcv_reserr + 
-                       RCstats.Rcv_orun + RCstats.Rcv_cdt + RCstats.Rcv_runt;
-
-               pDpa->stats.tx_errors = RCstats.TX_urun + RCstats.TX_crs + 
-                       RCstats.TX_def + RCstats.TX_totcol;
-
-               /*
-                * This needs improvement.
-                */
-               pDpa->stats.rx_dropped = 0; /* no space in linux buffers   */
-               pDpa->stats.tx_dropped = 0; /* no space available in linux */
-               pDpa->stats.multicast = 0;  /* multicast packets received  */
-               pDpa->stats.collisions = RCstats.TX_totcol;
-
-               /* detailed rx_errors: */
-               pDpa->stats.rx_length_errors = 0;
-               pDpa->stats.rx_over_errors = RCstats.Rcv_orun;
-               pDpa->stats.rx_crc_errors = RCstats.Rcv_CRCerr;
-               pDpa->stats.rx_frame_errors = 0;
-               pDpa->stats.rx_fifo_errors = 0; 
-               pDpa->stats.rx_missed_errors = 0;
-
-               /* detailed tx_errors */
-               pDpa->stats.tx_aborted_errors = 0;
-               pDpa->stats.tx_carrier_errors = 0;
-               pDpa->stats.tx_fifo_errors = 0;
-               pDpa->stats.tx_heartbeat_errors = 0;
-               pDpa->stats.tx_window_errors = 0;
-
-               return ((struct net_device_stats *) &(pDpa->stats));
-       }
-       return 0;
-}
-
-static int
-RCioctl (struct net_device *dev, struct ifreq *rq, int cmd)
-{
-       RCuser_struct RCuser;
-       PDPA pDpa = dev->priv;
-
-       if (!capable (CAP_NET_ADMIN))
-               return -EPERM;
-
-       switch (cmd) {
-
-       case RCU_PROTOCOL_REV:
-               /*
-                * Assign user protocol revision, to tell user-level
-                * controller program whether or not it's in sync.
-                */
-               rq->ifr_ifru.ifru_data = (caddr_t) USER_PROTOCOL_REV;
-               break;
-
-       case RCU_COMMAND:
-               {
-                       if (copy_from_user
-                           (&RCuser, rq->ifr_data, sizeof (RCuser)))
-                               return -EFAULT;
-
-                       dprintk ("RCioctl: RCuser_cmd = 0x%x\n", RCuser.cmd);
-
-                       switch (RCuser.cmd) {
-                       case RCUC_GETFWVER:
-                               RCUD_GETFWVER = &RCuser.RCUS_GETFWVER;
-                               RCGetFirmwareVer (dev,
-                                                 (PU8) & RCUD_GETFWVER->
-                                                 FirmString, NULL);
-                               break;
-                       case RCUC_GETINFO:
-                               RCUD_GETINFO = &RCuser.RCUS_GETINFO;
-                               RCUD_GETINFO->mem_start = dev->base_addr;
-                               RCUD_GETINFO->mem_end =
-                                   dev->base_addr + pDpa->pci_addr_len;
-                               RCUD_GETINFO->base_addr = pDpa->pci_addr;
-                               RCUD_GETINFO->irq = dev->irq;
-                               break;
-                       case RCUC_GETIPANDMASK:
-                               RCUD_GETIPANDMASK = &RCuser.RCUS_GETIPANDMASK;
-                               RCGetRavlinIPandMask (dev,
-                                                     (PU32) &
-                                                     RCUD_GETIPANDMASK->IpAddr,
-                                                     (PU32) &
-                                                     RCUD_GETIPANDMASK->
-                                                     NetMask, NULL);
-                               break;
-                       case RCUC_GETLINKSTATISTICS:
-                               RCUD_GETLINKSTATISTICS =
-                                   &RCuser.RCUS_GETLINKSTATISTICS;
-                               RCGetLinkStatistics (dev,
-                                                    (P_RCLINKSTATS) &
-                                                    RCUD_GETLINKSTATISTICS->
-                                                    StatsReturn, NULL);
-                               break;
-                       case RCUC_GETLINKSTATUS:
-                               RCUD_GETLINKSTATUS = &RCuser.RCUS_GETLINKSTATUS;
-                               RCGetLinkStatus (dev,
-                                                (PU32) & RCUD_GETLINKSTATUS->
-                                                ReturnStatus, NULL);
-                               break;
-                       case RCUC_GETMAC:
-                               RCUD_GETMAC = &RCuser.RCUS_GETMAC;
-                               RCGetMAC (dev, NULL);
-                               memcpy(RCUD_GETMAC, dev->dev_addr, 8);
-                               break;
-                       case RCUC_GETPROM:
-                               RCUD_GETPROM = &RCuser.RCUS_GETPROM;
-                               RCGetPromiscuousMode (dev,
-                                                     (PU32) & RCUD_GETPROM->
-                                                     PromMode, NULL);
-                               break;
-                       case RCUC_GETBROADCAST:
-                               RCUD_GETBROADCAST = &RCuser.RCUS_GETBROADCAST;
-                               RCGetBroadcastMode (dev,
-                                                   (PU32) & RCUD_GETBROADCAST->
-                                                   BroadcastMode, NULL);
-                               break;
-                       case RCUC_GETSPEED:
-                               if (!(dev->flags & IFF_UP)) {
-                                       return -ENODATA;
-                               }
-                               RCUD_GETSPEED = &RCuser.RCUS_GETSPEED;
-                               RCGetLinkSpeed (dev,
-                                               (PU32) & RCUD_GETSPEED->
-                                               LinkSpeedCode, NULL);
-                               break;
-                       case RCUC_SETIPANDMASK:
-                               RCUD_SETIPANDMASK = &RCuser.RCUS_SETIPANDMASK;
-                               RCSetRavlinIPandMask (dev,
-                                                     (U32) RCUD_SETIPANDMASK->
-                                                     IpAddr,
-                                                     (U32) RCUD_SETIPANDMASK->
-                                                     NetMask);
-                               break;
-                       case RCUC_SETMAC:
-                               RCSetMAC (dev, (PU8) & RCUD_SETMAC->mac);
-                               break;
-                       case RCUC_SETSPEED:
-                               RCUD_SETSPEED = &RCuser.RCUS_SETSPEED;
-                               RCSetLinkSpeed (dev,
-                                               (U16) RCUD_SETSPEED->
-                                               LinkSpeedCode);
-                               break;
-                       case RCUC_SETPROM:
-                               RCUD_SETPROM = &RCuser.RCUS_SETPROM;
-                               RCSetPromiscuousMode (dev,
-                                                     (U16) RCUD_SETPROM->
-                                                     PromMode);
-                               break;
-                       case RCUC_SETBROADCAST:
-                               RCUD_SETBROADCAST = &RCuser.RCUS_SETBROADCAST;
-                               RCSetBroadcastMode (dev,
-                                                   (U16) RCUD_SETBROADCAST->
-                                                   BroadcastMode);
-                               break;
-                       default:
-                               RCUD_DEFAULT = &RCuser.RCUS_DEFAULT;
-                               RCUD_DEFAULT->rc = 0x11223344;
-                               break;
-                       }
-                       if (copy_to_user (rq->ifr_data, &RCuser, 
-                                               sizeof (RCuser)))
-                               return -EFAULT;
-                       break;
-               }               /* RCU_COMMAND */
-
-       default:
-               rq->ifr_ifru.ifru_data = (caddr_t) 0x12345678;
-               return -EINVAL;
-       }
-       return 0;
-}
-
-static int
-RCconfig (struct net_device *dev, struct ifmap *map)
-{
-       /*
-        * To be completed ...
-        */
-       return 0;
-       if (dev->flags & IFF_UP)        /* can't act on a running interface */
-               return -EBUSY;
-
-       /* Don't allow changing the I/O address */
-       if (map->base_addr != dev->base_addr) {
-               printk (KERN_WARNING "%s Change I/O address not implemented\n",
-                               dev->name);
-               return -EOPNOTSUPP;
-       }
-       return 0;
-}
-
-static void __exit
-rcpci_cleanup_module (void)
-{
-       pci_unregister_driver (&rcpci45_driver);
-}
-
-module_init (rcpci_init_module);
-module_exit (rcpci_cleanup_module);
-
-static int
-RC_allocate_and_post_buffers (struct net_device *dev, int numBuffers)
-{
-
-       int i;
-       PU32 p;
-       psingleB pB;
-       struct sk_buff *skb;
-       PDPA pDpa = dev->priv;
-       RC_RETURN status;
-       U32 res = 0;
-
-       if (!numBuffers)
-               return 0;
-       else if (numBuffers > MAX_NMBR_POST_BUFFERS_PER_MSG) {
-               printk (KERN_ERR "%s: Too many buffers requested!\n",
-                               dev->name);
-               numBuffers = 32;
-       }
-
-       p = (PU32) kmalloc (sizeof (U32) + numBuffers * sizeof (singleB),
-                           GFP_DMA | GFP_ATOMIC);
-
-       if (!p) {
-               printk (KERN_WARNING "%s unable to allocate TCB\n",
-                               dev->name);
-               goto out;
-       }
-
-       p[0] = 0;               /* Buffer Count */
-       pB = (psingleB) ((U32) p + sizeof (U32));/* point to the first buffer */
-
-       for (i = 0; i < numBuffers; i++) {
-               skb = dev_alloc_skb (MAX_ETHER_SIZE + 2);
-               if (!skb) {
-                       printk (KERN_WARNING 
-                                       "%s: unable to allocate enough skbs!\n",
-                                       dev->name);
-                       goto err_out_unmap;
-               }
-               skb_reserve (skb, 2);   /* Align IP on 16 byte boundaries */
-               pB->context = (U32) skb;
-               pB->scount = 1; /* segment count */
-               pB->size = MAX_ETHER_SIZE;
-               pB->addr = pci_map_single(pDpa->pci_dev, skb->data, 
-                                         MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE);
-               p[0]++;
-               pB++;
-       }
-
-       if ((status = RCPostRecvBuffers (dev, (PRCTCB) p)) != RC_RTN_NO_ERROR) {
-               printk (KERN_WARNING "%s: Post buffer failed, error 0x%x\n",
-                               dev->name, status);
-               goto err_out_unmap;
-       }
-out_free:
-       res = p[0];
-       kfree (p);
-out:
-       return (res);           /* return the number of posted buffers */
-
-err_out_unmap:
-       for (; p[0] > 0; p[0]--) {
-               --pB;
-               skb = (struct sk_buff *) pB->context;
-               pci_unmap_single(pDpa->pci_dev, pB->addr, MAX_ETHER_SIZE,
-                                PCI_DMA_FROMDEVICE);
-               dev_kfree_skb (skb);
-       }
-       goto out_free;
-}
index 503fdff..aec6a60 100644 (file)
@@ -788,7 +788,8 @@ static int __init skge_init_module(void)
        cards = skge_probe();
        if (cards == 0) {
                printk("sk98lin: No adapter found.\n");
-       }
+       } else
+       __unsafe(THIS_MODULE);
        return cards ? 0 : -ENODEV;
 } /* skge_init_module */
 
index 69e9246..c7a4b6b 100644 (file)
@@ -849,6 +849,8 @@ static int tok_init_card(struct net_device *dev)
        struct tok_info *ti;
        short PIOaddr;
        unsigned long i;
+       wait_queue_t __wait;
+       init_waitqueue_entry(&__wait, current);
 
        PIOaddr = dev->base_addr;
        ti = (struct tok_info *) dev->priv;
@@ -861,13 +863,18 @@ static int tok_init_card(struct net_device *dev)
        current->state=TASK_UNINTERRUPTIBLE;
        schedule_timeout(TR_RST_TIME); /* wait 50ms */
 
+       add_wait_queue(&ti->wait_for_reset, &__wait);
+       set_current_state(TASK_UNINTERRUPTIBLE);
        outb(0, PIOaddr + ADAPTRESETREL);
 #ifdef ENABLE_PAGING
        if (ti->page_mask)
                writeb(SRPR_ENABLE_PAGING,ti->mmio+ACA_OFFSET+ACA_RW+SRPR_EVEN);
 #endif
        writeb(INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_SET + ISRP_EVEN);
-       i = sleep_on_timeout(&ti->wait_for_reset, 4 * HZ);
+       #warning pci posting bug
+       i = schedule_timeout(4 * HZ);
+       current->state = TASK_RUNNING;
+       remove_wait_queue(&ti->wait_for_reset, &__wait);
        return i? 0 : -EAGAIN;
 }
 
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
deleted file mode 100644 (file)
index f053d2a..0000000
+++ /dev/null
@@ -1,3277 +0,0 @@
-/*
- * This code is derived from the VIA reference driver (copyright message
- * below) provided to Red Hat by VIA Networking Technologies, Inc. for
- * addition to the Linux kernel.
- *
- * The code has been merged into one source file, cleaned up to follow
- * Linux coding style,  ported to the Linux 2.6 kernel tree and cleaned
- * for 64bit hardware platforms.
- *
- * TODO
- *     Big-endian support
- *     rx_copybreak/alignment
- *     Scatter gather
- *     More testing
- *
- * The changes are (c) Copyright 2004, Red Hat Inc. <alan@redhat.com>
- * Additional fixes and clean up: Francois Romieu
- *
- * This source has not been verified for use in safety critical systems.
- *
- * Please direct queries about the revamped driver to the linux-kernel
- * list not VIA.
- *
- * Original code:
- *
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * This software may be redistributed and/or modified under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * Author: Chuang Liang-Shing, AJ Jiang
- *
- * Date: Jan 24, 2003
- *
- * MODULE_LICENSE("GPL");
- *
- */
-
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/mm.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/version.h>
-#include <linux/string.h>
-#include <linux/wait.h>
-#include <asm/io.h>
-#include <linux/if.h>
-#include <linux/config.h>
-#include <asm/uaccess.h>
-#include <linux/proc_fs.h>
-#include <linux/inetdevice.h>
-#include <linux/reboot.h>
-#include <linux/ethtool.h>
-#include <linux/mii.h>
-#include <linux/in.h>
-#include <linux/if_arp.h>
-#include <linux/ip.h>
-#include <linux/tcp.h>
-#include <linux/udp.h>
-
-#include "via-velocity.h"
-
-
-static int velocity_nics = 0;
-static int msglevel = MSG_LEVEL_INFO;
-
-
-static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
-static struct ethtool_ops velocity_ethtool_ops;
-
-/*
-    Define module options
-*/
-
-MODULE_AUTHOR("VIA Networking Technologies, Inc.");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver");
-
-#define VELOCITY_PARAM(N,D) \
-        static const int N[MAX_UNITS]=OPTION_DEFAULT;\
-        MODULE_PARM(N, "1-" __MODULE_STRING(MAX_UNITS) "i");\
-        MODULE_PARM_DESC(N, D);
-
-#define RX_DESC_MIN     64
-#define RX_DESC_MAX     255
-#define RX_DESC_DEF     64
-VELOCITY_PARAM(RxDescriptors, "Number of receive descriptors");
-
-#define TX_DESC_MIN     16
-#define TX_DESC_MAX     256
-#define TX_DESC_DEF     64
-VELOCITY_PARAM(TxDescriptors, "Number of transmit descriptors");
-
-#define VLAN_ID_MIN     0
-#define VLAN_ID_MAX     4095
-#define VLAN_ID_DEF     0
-/* VID_setting[] is used for setting the VID of NIC.
-   0: default VID.
-   1-4094: other VIDs.
-*/
-VELOCITY_PARAM(VID_setting, "802.1Q VLAN ID");
-
-#define RX_THRESH_MIN   0
-#define RX_THRESH_MAX   3
-#define RX_THRESH_DEF   0
-/* rx_thresh[] is used for controlling the receive fifo threshold.
-   0: indicate the rxfifo threshold is 128 bytes.
-   1: indicate the rxfifo threshold is 512 bytes.
-   2: indicate the rxfifo threshold is 1024 bytes.
-   3: indicate the rxfifo threshold is store & forward.
-*/
-VELOCITY_PARAM(rx_thresh, "Receive fifo threshold");
-
-#define DMA_LENGTH_MIN  0
-#define DMA_LENGTH_MAX  7
-#define DMA_LENGTH_DEF  0
-
-/* DMA_length[] is used for controlling the DMA length
-   0: 8 DWORDs
-   1: 16 DWORDs
-   2: 32 DWORDs
-   3: 64 DWORDs
-   4: 128 DWORDs
-   5: 256 DWORDs
-   6: SF(flush till emply)
-   7: SF(flush till emply)
-*/
-VELOCITY_PARAM(DMA_length, "DMA length");
-
-#define TAGGING_DEF     0
-/* enable_tagging[] is used for enabling 802.1Q VID tagging.
-   0: disable VID seeting(default).
-   1: enable VID setting.
-*/
-VELOCITY_PARAM(enable_tagging, "Enable 802.1Q tagging");
-
-#define IP_ALIG_DEF     0
-/* IP_byte_align[] is used for IP header DWORD byte aligned
-   0: indicate the IP header won't be DWORD byte aligned.(Default) .
-   1: indicate the IP header will be DWORD byte aligned.
-      In some enviroment, the IP header should be DWORD byte aligned,
-      or the packet will be droped when we receive it. (eg: IPVS)
-*/
-VELOCITY_PARAM(IP_byte_align, "Enable IP header dword aligned");
-
-#define TX_CSUM_DEF     1
-/* txcsum_offload[] is used for setting the checksum offload ability of NIC.
-   (We only support RX checksum offload now)
-   0: disable csum_offload[checksum offload
-   1: enable checksum offload. (Default)
-*/
-VELOCITY_PARAM(txcsum_offload, "Enable transmit packet checksum offload");
-
-#define FLOW_CNTL_DEF   1
-#define FLOW_CNTL_MIN   1
-#define FLOW_CNTL_MAX   5
-
-/* flow_control[] is used for setting the flow control ability of NIC.
-   1: hardware deafult - AUTO (default). Use Hardware default value in ANAR.
-   2: enable TX flow control.
-   3: enable RX flow control.
-   4: enable RX/TX flow control.
-   5: disable
-*/
-VELOCITY_PARAM(flow_control, "Enable flow control ability");
-
-#define MED_LNK_DEF 0
-#define MED_LNK_MIN 0
-#define MED_LNK_MAX 4
-/* speed_duplex[] is used for setting the speed and duplex mode of NIC.
-   0: indicate autonegotiation for both speed and duplex mode
-   1: indicate 100Mbps half duplex mode
-   2: indicate 100Mbps full duplex mode
-   3: indicate 10Mbps half duplex mode
-   4: indicate 10Mbps full duplex mode
-
-   Note:
-        if EEPROM have been set to the force mode, this option is ignored
-            by driver.
-*/
-VELOCITY_PARAM(speed_duplex, "Setting the speed and duplex mode");
-
-#define VAL_PKT_LEN_DEF     0
-/* ValPktLen[] is used for setting the checksum offload ability of NIC.
-   0: Receive frame with invalid layer 2 length (Default)
-   1: Drop frame with invalid layer 2 length
-*/
-VELOCITY_PARAM(ValPktLen, "Receiving or Drop invalid 802.3 frame");
-
-#define WOL_OPT_DEF     0
-#define WOL_OPT_MIN     0
-#define WOL_OPT_MAX     7
-/* wol_opts[] is used for controlling wake on lan behavior.
-   0: Wake up if recevied a magic packet. (Default)
-   1: Wake up if link status is on/off.
-   2: Wake up if recevied an arp packet.
-   4: Wake up if recevied any unicast packet.
-   Those value can be sumed up to support more than one option.
-*/
-VELOCITY_PARAM(wol_opts, "Wake On Lan options");
-
-#define INT_WORKS_DEF   20
-#define INT_WORKS_MIN   10
-#define INT_WORKS_MAX   64
-
-VELOCITY_PARAM(int_works, "Number of packets per interrupt services");
-
-static int velocity_found1(struct pci_dev *pdev, const struct pci_device_id *ent);
-static void velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, struct velocity_info_tbl *info);
-static int velocity_get_pci_info(struct velocity_info *, struct pci_dev *pdev);
-static void velocity_print_info(struct velocity_info *vptr);
-static int velocity_open(struct net_device *dev);
-static int velocity_change_mtu(struct net_device *dev, int mtu);
-static int velocity_xmit(struct sk_buff *skb, struct net_device *dev);
-static int velocity_intr(int irq, void *dev_instance, struct pt_regs *regs);
-static void velocity_set_multi(struct net_device *dev);
-static struct net_device_stats *velocity_get_stats(struct net_device *dev);
-static int velocity_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static int velocity_close(struct net_device *dev);
-static int velocity_rx_srv(struct velocity_info *vptr, int status);
-static int velocity_receive_frame(struct velocity_info *, int idx);
-static int velocity_alloc_rx_buf(struct velocity_info *, int idx);
-static void velocity_init_registers(struct velocity_info *vptr, enum velocity_init_type type);
-static void velocity_free_rd_ring(struct velocity_info *vptr);
-static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_info *);
-static int velocity_soft_reset(struct velocity_info *vptr);
-static void mii_init(struct velocity_info *vptr, u32 mii_status);
-static u32 velocity_get_opt_media_mode(struct velocity_info *vptr);
-static void velocity_print_link_status(struct velocity_info *vptr);
-static void safe_disable_mii_autopoll(struct mac_regs * regs);
-static void velocity_shutdown(struct velocity_info *vptr);
-static void enable_flow_control_ability(struct velocity_info *vptr);
-static void enable_mii_autopoll(struct mac_regs * regs);
-static int velocity_mii_read(struct mac_regs *, u8 byIdx, u16 * pdata);
-static int velocity_mii_write(struct mac_regs *, u8 byMiiAddr, u16 data);
-static int velocity_set_wol(struct velocity_info *vptr);
-static void velocity_save_context(struct velocity_info *vptr, struct velocity_context *context);
-static void velocity_restore_context(struct velocity_info *vptr, struct velocity_context *context);
-static u32 mii_check_media_mode(struct mac_regs * regs);
-static u32 check_connection_type(struct mac_regs * regs);
-static void velocity_init_cam_filter(struct velocity_info *vptr);
-static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status);
-
-#ifdef CONFIG_PM
-static int velocity_suspend(struct pci_dev *pdev, u32 state);
-static int velocity_resume(struct pci_dev *pdev);
-
-static int velocity_netdev_event(struct notifier_block *nb, unsigned long notification, void *ptr);
-
-static struct notifier_block velocity_inetaddr_notifier = {
-      notifier_call:velocity_netdev_event,
-};
-
-#endif                         /* CONFIG_PM */
-
-/*
- *     Internal board variants. At the moment we have only one
- */
-
-static struct velocity_info_tbl chip_info_table[] = {
-       {CHIP_TYPE_VT6110, "VIA Networking Velocity Family Gigabit Ethernet Adapter", 256, 1, 0x00FFFFFFUL},
-       {0, NULL}
-};
-
-/*
- *     Describe the PCI device identifiers that we support in this
- *     device driver. Used for hotplug autoloading.
- */
-
-static struct pci_device_id velocity_id_table[] __devinitdata = {
-       {0x1106, 0x3119, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &chip_info_table[0]},
-       {0,}
-};
-
-MODULE_DEVICE_TABLE(pci, velocity_id_table);
-
-/**
- *     get_chip_name   -       identifier to name
- *     @id: chip identifier
- *
- *     Given a chip identifier return a suitable description. Returns
- *     a pointer a static string valid while the driver is loaded.
- */
-
-static char __devinit *get_chip_name(enum chip_type chip_id)
-{
-       int i;
-       for (i = 0; chip_info_table[i].name != NULL; i++)
-               if (chip_info_table[i].chip_id == chip_id)
-                       break;
-       return chip_info_table[i].name;
-}
-
-/**
- *     velocity_remove1        -       device unplug
- *     @pdev: PCI device being removed
- *
- *     Device unload callback. Called on an unplug or on module
- *     unload for each active device that is present. Disconnects
- *     the device from the network layer and frees all the resources
- */
-
-static void __devexit velocity_remove1(struct pci_dev *pdev)
-{
-       struct net_device *dev = pci_get_drvdata(pdev);
-       struct velocity_info *vptr = dev->priv;
-
-       unregister_netdev(dev);
-       iounmap(vptr->mac_regs);
-       pci_release_regions(pdev);
-       pci_disable_device(pdev);
-       pci_set_drvdata(pdev, NULL);
-       free_netdev(dev);
-}
-
-/**
- *     velocity_set_int_opt    -       parser for integer options
- *     @opt: pointer to option value
- *     @val: value the user requested (or -1 for default)
- *     @min: lowest value allowed
- *     @max: highest value allowed
- *     @def: default value
- *     @name: property name
- *     @dev: device name
- *
- *     Set an integer property in the module options. This function does
- *     all the verification and checking as well as reporting so that
- *     we don't duplicate code for each option.
- */
-
-static void __devinit velocity_set_int_opt(int *opt, int val, int min, int max, int def, char *name, char *devname)
-{
-       if (val == -1)
-               *opt = def;
-       else if (val < min || val > max) {
-               VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n",
-                                       devname, name, min, max);
-               *opt = def;
-       } else {
-               VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: set value of parameter %s to %d\n",
-                                       devname, name, val);
-               *opt = val;
-       }
-}
-
-/**
- *     velocity_set_bool_opt   -       parser for boolean options
- *     @opt: pointer to option value
- *     @val: value the user requested (or -1 for default)
- *     @def: default value (yes/no)
- *     @flag: numeric value to set for true.
- *     @name: property name
- *     @dev: device name
- *
- *     Set a boolean property in the module options. This function does
- *     all the verification and checking as well as reporting so that
- *     we don't duplicate code for each option.
- */
-
-static void __devinit velocity_set_bool_opt(u32 * opt, int val, int def, u32 flag, char *name, char *devname)
-{
-       (*opt) &= (~flag);
-       if (val == -1)
-               *opt |= (def ? flag : 0);
-       else if (val < 0 || val > 1) {
-               printk(KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1)\n", 
-                       devname, name);
-               *opt |= (def ? flag : 0);
-       } else {
-               printk(KERN_INFO "%s: set parameter %s to %s\n", 
-                       devname, name, val ? "TRUE" : "FALSE");
-               *opt |= (val ? flag : 0);
-       }
-}
-
-/**
- *     velocity_get_options    -       set options on device
- *     @opts: option structure for the device
- *     @index: index of option to use in module options array
- *     @devname: device name
- *
- *     Turn the module and command options into a single structure
- *     for the current device
- */
-
-static void __devinit velocity_get_options(struct velocity_opt *opts, int index, char *devname)
-{
-
-       velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, "rx_thresh", devname);
-       velocity_set_int_opt(&opts->DMA_length, DMA_length[index], DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, "DMA_length", devname);
-       velocity_set_int_opt(&opts->numrx, RxDescriptors[index], RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, "RxDescriptors", devname);
-       velocity_set_int_opt(&opts->numtx, TxDescriptors[index], TX_DESC_MIN, TX_DESC_MAX, TX_DESC_DEF, "TxDescriptors", devname);
-       velocity_set_int_opt(&opts->vid, VID_setting[index], VLAN_ID_MIN, VLAN_ID_MAX, VLAN_ID_DEF, "VID_setting", devname);
-       velocity_set_bool_opt(&opts->flags, enable_tagging[index], TAGGING_DEF, VELOCITY_FLAGS_TAGGING, "enable_tagging", devname);
-       velocity_set_bool_opt(&opts->flags, txcsum_offload[index], TX_CSUM_DEF, VELOCITY_FLAGS_TX_CSUM, "txcsum_offload", devname);
-       velocity_set_int_opt(&opts->flow_cntl, flow_control[index], FLOW_CNTL_MIN, FLOW_CNTL_MAX, FLOW_CNTL_DEF, "flow_control", devname);
-       velocity_set_bool_opt(&opts->flags, IP_byte_align[index], IP_ALIG_DEF, VELOCITY_FLAGS_IP_ALIGN, "IP_byte_align", devname);
-       velocity_set_bool_opt(&opts->flags, ValPktLen[index], VAL_PKT_LEN_DEF, VELOCITY_FLAGS_VAL_PKT_LEN, "ValPktLen", devname);
-       velocity_set_int_opt((int *) &opts->spd_dpx, speed_duplex[index], MED_LNK_MIN, MED_LNK_MAX, MED_LNK_DEF, "Media link mode", devname);
-       velocity_set_int_opt((int *) &opts->wol_opts, wol_opts[index], WOL_OPT_MIN, WOL_OPT_MAX, WOL_OPT_DEF, "Wake On Lan options", devname);
-       velocity_set_int_opt((int *) &opts->int_works, int_works[index], INT_WORKS_MIN, INT_WORKS_MAX, INT_WORKS_DEF, "Interrupt service works", devname);
-       opts->numrx = (opts->numrx & ~3);
-}
-
-/**
- *     velocity_init_cam_filter        -       initialise CAM
- *     @vptr: velocity to program
- *
- *     Initialize the content addressable memory used for filters. Load
- *     appropriately according to the presence of VLAN
- */
-
-static void velocity_init_cam_filter(struct velocity_info *vptr)
-{
-       struct mac_regs * regs = vptr->mac_regs;
-
-       /* T urn on MCFG_PQEN, turn off MCFG_RTGOPT */
-       WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG);
-       WORD_REG_BITS_ON(MCFG_VIDFR, &regs->MCFG);
-
-       /* Disable all CAMs */
-       memset(vptr->vCAMmask, 0, sizeof(u8) * 8);
-       memset(vptr->mCAMmask, 0, sizeof(u8) * 8);
-       mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM);
-       mac_set_cam_mask(regs, vptr->mCAMmask, VELOCITY_MULTICAST_CAM);
-
-       /* Enable first VCAM */
-       if (vptr->flags & VELOCITY_FLAGS_TAGGING) {
-               /* If Tagging option is enabled and VLAN ID is not zero, then
-                  turn on MCFG_RTGOPT also */
-               if (vptr->options.vid != 0)
-                       WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG);
-
-               mac_set_cam(regs, 0, (u8 *) & (vptr->options.vid), VELOCITY_VLAN_ID_CAM);
-               vptr->vCAMmask[0] |= 1;
-               mac_set_cam_mask(regs, vptr->vCAMmask, VELOCITY_VLAN_ID_CAM);
-       } else {
-               u16 temp = 0;
-               mac_set_cam(regs, 0, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
-               temp = 1;
-               mac_set_cam_mask(regs, (u8 *) &temp, VELOCITY_VLAN_ID_CAM);
-       }
-}
-
-/**
- *     velocity_rx_reset       -       handle a receive reset
- *     @vptr: velocity we are resetting
- *
- *     Reset the ownership and status for the receive ring side.
- *     Hand all the receive queue to the NIC.
- */
-
-static void velocity_rx_reset(struct velocity_info *vptr)
-{
-
-       struct mac_regs * regs = vptr->mac_regs;
-       int i;
-
-       vptr->rd_used = vptr->rd_curr = 0;
-
-       /*
-        *      Init state, all RD entries belong to the NIC
-        */
-       for (i = 0; i < vptr->options.numrx; ++i)
-               vptr->rd_ring[i].rdesc0.owner = cpu_to_le32(OWNED_BY_NIC);
-
-       writew(vptr->options.numrx, &regs->RBRDU);
-       writel(vptr->rd_pool_dma, &regs->RDBaseLo);
-       writew(0, &regs->RDIdx);
-       writew(vptr->options.numrx - 1, &regs->RDCSize);
-}
-
-/**
- *     velocity_init_registers -       initialise MAC registers
- *     @vptr: velocity to init
- *     @type: type of initialisation (hot or cold)
- *
- *     Initialise the MAC on a reset or on first set up on the
- *     hardware.
- */
-
-static void velocity_init_registers(struct velocity_info *vptr, 
-                                   enum velocity_init_type type)
-{
-       struct mac_regs * regs = vptr->mac_regs;
-       int i, mii_status;
-
-       mac_wol_reset(regs);
-
-       switch (type) {
-       case VELOCITY_INIT_RESET:
-       case VELOCITY_INIT_WOL:
-
-               netif_stop_queue(vptr->dev);
-
-               /*
-                *      Reset RX to prevent RX pointer not on the 4X location
-                */
-               velocity_rx_reset(vptr);
-               mac_rx_queue_run(regs);
-               mac_rx_queue_wake(regs);
-
-               mii_status = velocity_get_opt_media_mode(vptr);
-               if (velocity_set_media_mode(vptr, mii_status) != VELOCITY_LINK_CHANGE) {
-                       velocity_print_link_status(vptr);
-                       if (!(vptr->mii_status & VELOCITY_LINK_FAIL))
-                               netif_wake_queue(vptr->dev);
-               }
-
-               enable_flow_control_ability(vptr);
-
-               mac_clear_isr(regs);
-               writel(CR0_STOP, &regs->CR0Clr);
-               writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), 
-                                                       &regs->CR0Set);
-
-               break;
-
-       case VELOCITY_INIT_COLD:
-       default:
-               /*
-                *      Do reset
-                */
-               velocity_soft_reset(vptr);
-               mdelay(5);
-
-               mac_eeprom_reload(regs);
-               for (i = 0; i < 6; i++) {
-                       writeb(vptr->dev->dev_addr[i], &(regs->PAR[i]));
-               }
-               /*
-                *      clear Pre_ACPI bit.
-                */
-               BYTE_REG_BITS_OFF(CFGA_PACPI, &(regs->CFGA));
-               mac_set_rx_thresh(regs, vptr->options.rx_thresh);
-               mac_set_dma_length(regs, vptr->options.DMA_length);
-
-               writeb(WOLCFG_SAM | WOLCFG_SAB, &regs->WOLCFGSet);
-               /*
-                *      Bback off algorithm use original IEEE standard
-                */
-               BYTE_REG_BITS_SET(CFGB_OFSET, (CFGB_CRANDOM | CFGB_CAP | CFGB_MBA | CFGB_BAKOPT), &regs->CFGB);
-
-               /*
-                *      Set packet filter: Receive directed and broadcast address
-                */
-               velocity_set_multi(vptr->dev);
-
-               /*
-                *      Enable MII auto-polling
-                */
-               enable_mii_autopoll(regs);
-
-               vptr->int_mask = INT_MASK_DEF;
-
-               writel(cpu_to_le32(vptr->rd_pool_dma), &regs->RDBaseLo);
-               writew(vptr->options.numrx - 1, &regs->RDCSize);
-               mac_rx_queue_run(regs);
-               mac_rx_queue_wake(regs);
-
-               writew(vptr->options.numtx - 1, &regs->TDCSize);
-
-               for (i = 0; i < vptr->num_txq; i++) {
-                       writel(cpu_to_le32(vptr->td_pool_dma[i]), &(regs->TDBaseLo[i]));
-                       mac_tx_queue_run(regs, i);
-               }
-
-               velocity_init_cam_filter(vptr);
-
-               init_flow_control_register(vptr);
-
-               writel(CR0_STOP, &regs->CR0Clr);
-               writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), &regs->CR0Set);
-
-               mii_status = velocity_get_opt_media_mode(vptr);
-               netif_stop_queue(vptr->dev);
-               mac_clear_isr(regs);
-
-               mii_init(vptr, mii_status);
-
-               if (velocity_set_media_mode(vptr, mii_status) != VELOCITY_LINK_CHANGE) {
-                       velocity_print_link_status(vptr);
-                       if (!(vptr->mii_status & VELOCITY_LINK_FAIL))
-                               netif_wake_queue(vptr->dev);
-               }
-
-               enable_flow_control_ability(vptr);
-               mac_hw_mibs_init(regs);
-               mac_write_int_mask(vptr->int_mask, regs);
-               mac_clear_isr(regs);
-
-       }
-}
-
-/**
- *     velocity_soft_reset     -       soft reset
- *     @vptr: velocity to reset
- *
- *     Kick off a soft reset of the velocity adapter and then poll
- *     until the reset sequence has completed before returning.
- */
-
-static int velocity_soft_reset(struct velocity_info *vptr)
-{
-       struct mac_regs * regs = vptr->mac_regs;
-       int i = 0;
-
-       writel(CR0_SFRST, &regs->CR0Set);
-
-       for (i = 0; i < W_MAX_TIMEOUT; i++) {
-               udelay(5);
-               if (!DWORD_REG_BITS_IS_ON(CR0_SFRST, &regs->CR0Set))
-                       break;
-       }
-
-       if (i == W_MAX_TIMEOUT) {
-               writel(CR0_FORSRST, &regs->CR0Set);
-               /* FIXME: PCI POSTING */
-               /* delay 2ms */
-               mdelay(2);
-       }
-       return 0;
-}
-
-/**
- *     velocity_found1         -       set up discovered velocity card
- *     @pdev: PCI device
- *     @ent: PCI device table entry that matched
- *
- *     Configure a discovered adapter from scratch. Return a negative
- *     errno error code on failure paths.
- */
-
-static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-       static int first = 1;
-       struct net_device *dev;
-       int i;
-       struct velocity_info_tbl *info = (struct velocity_info_tbl *) ent->driver_data;
-       struct velocity_info *vptr;
-       struct mac_regs * regs;
-       int ret = -ENOMEM;
-
-       if (velocity_nics++ >= MAX_UNITS) {
-               printk(KERN_NOTICE VELOCITY_NAME ": already found %d NICs.\n", 
-                               velocity_nics);
-               return -ENODEV;
-       }
-
-       dev = alloc_etherdev(sizeof(struct velocity_info));
-
-       if (dev == NULL) {
-               printk(KERN_ERR VELOCITY_NAME ": allocate net device failed.\n");
-               goto out;
-       }
-       
-       /* Chain it all together */
-       
-       SET_MODULE_OWNER(dev);
-       SET_NETDEV_DEV(dev, &pdev->dev);
-       vptr = dev->priv;
-
-
-       if (first) {
-               printk(KERN_INFO "%s Ver. %s\n", 
-                       VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION);
-               printk(KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n");
-               printk(KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n");
-               first = 0;
-       }
-
-       velocity_init_info(pdev, vptr, info);
-
-       vptr->dev = dev;
-
-       dev->priv = vptr;
-       dev->irq = pdev->irq;
-
-       ret = pci_enable_device(pdev);
-       if (ret < 0) 
-               goto err_free_dev;
-
-       ret = velocity_get_pci_info(vptr, pdev);
-       if (ret < 0) {
-               printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n");
-               goto err_disable;
-       }
-
-       ret = pci_request_regions(pdev, VELOCITY_NAME);
-       if (ret < 0) {
-               printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n");
-               goto err_disable;
-       }
-
-       regs = ioremap(vptr->memaddr, vptr->io_size);
-       if (regs == NULL) {
-               ret = -EIO;
-               goto err_release_res;
-       }
-
-       vptr->mac_regs = regs;
-
-       mac_wol_reset(regs);
-
-       dev->base_addr = vptr->ioaddr;
-
-       for (i = 0; i < 6; i++)
-               dev->dev_addr[i] = readb(&regs->PAR[i]);
-
-
-       velocity_get_options(&vptr->options, velocity_nics - 1, dev->name);
-
-       /* 
-        *      Mask out the options cannot be set to the chip
-        */
-        
-       vptr->options.flags &= info->flags;
-
-       /*
-        *      Enable the chip specified capbilities
-        */
-        
-       vptr->flags = vptr->options.flags | (info->flags & 0xFF000000UL);
-
-       vptr->wol_opts = vptr->options.wol_opts;
-       vptr->flags |= VELOCITY_FLAGS_WOL_ENABLED;
-
-       vptr->phy_id = MII_GET_PHY_ID(vptr->mac_regs);
-
-       dev->irq = pdev->irq;
-       dev->open = velocity_open;
-       dev->hard_start_xmit = velocity_xmit;
-       dev->stop = velocity_close;
-       dev->get_stats = velocity_get_stats;
-       dev->set_multicast_list = velocity_set_multi;
-       dev->do_ioctl = velocity_ioctl;
-       dev->ethtool_ops = &velocity_ethtool_ops;
-       dev->change_mtu = velocity_change_mtu;
-#ifdef  VELOCITY_ZERO_COPY_SUPPORT
-       dev->features |= NETIF_F_SG;
-#endif
-
-       if (vptr->flags & VELOCITY_FLAGS_TX_CSUM) {
-               dev->features |= NETIF_F_HW_CSUM;
-       }
-
-       ret = register_netdev(dev);
-       if (ret < 0)
-               goto err_iounmap;
-
-       velocity_print_info(vptr);
-       pci_set_drvdata(pdev, dev);
-       
-       /* and leave the chip powered down */
-       
-       pci_set_power_state(pdev, 3);
-out:
-       return ret;
-
-err_iounmap:
-       iounmap(regs);
-err_release_res:
-       pci_release_regions(pdev);
-err_disable:
-       pci_disable_device(pdev);
-err_free_dev:
-       free_netdev(dev);
-       goto out;
-}
-
-/**
- *     velocity_print_info     -       per driver data
- *     @vptr: velocity
- *
- *     Print per driver data as the kernel driver finds Velocity
- *     hardware
- */
-
-static void __devinit velocity_print_info(struct velocity_info *vptr)
-{
-       struct net_device *dev = vptr->dev;
-
-       printk(KERN_INFO "%s: %s\n", dev->name, get_chip_name(vptr->chip_id));
-       printk(KERN_INFO "%s: Ethernet Address: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", 
-               dev->name, 
-               dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], 
-               dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
-}
-
-/**
- *     velocity_init_info      -       init private data
- *     @pdev: PCI device
- *     @vptr: Velocity info
- *     @info: Board type
- *
- *     Set up the initial velocity_info struct for the device that has been
- *     discovered.
- */
-
-static void __devinit velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, struct velocity_info_tbl *info)
-{
-       memset(vptr, 0, sizeof(struct velocity_info));
-
-       vptr->pdev = pdev;
-       vptr->chip_id = info->chip_id;
-       vptr->io_size = info->io_size;
-       vptr->num_txq = info->txqueue;
-       vptr->multicast_limit = MCAM_SIZE;
-
-       spin_lock_init(&vptr->lock);
-       spin_lock_init(&vptr->xmit_lock);
-}
-
-/**
- *     velocity_get_pci_info   -       retrieve PCI info for device
- *     @vptr: velocity device
- *     @pdev: PCI device it matches
- *
- *     Retrieve the PCI configuration space data that interests us from
- *     the kernel PCI layer
- */
-
-static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev)
-{
-
-       if(pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0)
-               return -EIO;
-               
-       pci_set_master(pdev);
-
-       vptr->ioaddr = pci_resource_start(pdev, 0);
-       vptr->memaddr = pci_resource_start(pdev, 1);
-       
-       if(!(pci_resource_flags(pdev, 0) & IORESOURCE_IO))
-       {
-               printk(KERN_ERR "%s: region #0 is not an I/O resource, aborting.\n",
-                               pci_name(pdev));
-               return -EINVAL;
-       }
-
-       if((pci_resource_flags(pdev, 1) & IORESOURCE_IO))
-       {
-               printk(KERN_ERR "%s: region #1 is an I/O resource, aborting.\n",
-                               pci_name(pdev));
-               return -EINVAL;
-       }
-
-       if(pci_resource_len(pdev, 1) < 256)
-       {
-               printk(KERN_ERR "%s: region #1 is too small.\n", 
-                               pci_name(pdev));
-               return -EINVAL;
-       }
-       vptr->pdev = pdev;
-
-       return 0;
-}
-
-/**
- *     velocity_init_rings     -       set up DMA rings
- *     @vptr: Velocity to set up
- *
- *     Allocate PCI mapped DMA rings for the receive and transmit layer
- *     to use.
- */
-
-static int velocity_init_rings(struct velocity_info *vptr)
-{
-       int i;
-       unsigned int psize;
-       unsigned int tsize;
-       dma_addr_t pool_dma;
-       u8 *pool;
-
-       /*
-        *      Allocate all RD/TD rings a single pool 
-        */
-        
-       psize = vptr->options.numrx * sizeof(struct rx_desc) + 
-               vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq;
-
-       /*
-        * pci_alloc_consistent() fulfills the requirement for 64 bytes
-        * alignment
-        */
-       pool = pci_alloc_consistent(vptr->pdev, psize, &pool_dma);
-
-       if (pool == NULL) {
-               printk(KERN_ERR "%s : DMA memory allocation failed.\n", 
-                                       vptr->dev->name);
-               return -ENOMEM;
-       }
-
-       memset(pool, 0, psize);
-
-       vptr->rd_ring = (struct rx_desc *) pool;
-
-       vptr->rd_pool_dma = pool_dma;
-
-       tsize = vptr->options.numtx * PKT_BUF_SZ * vptr->num_txq;
-       vptr->tx_bufs = pci_alloc_consistent(vptr->pdev, tsize, 
-                                               &vptr->tx_bufs_dma);
-
-       if (vptr->tx_bufs == NULL) {
-               printk(KERN_ERR "%s: DMA memory allocation failed.\n", 
-                                       vptr->dev->name);
-               pci_free_consistent(vptr->pdev, psize, pool, pool_dma);
-               return -ENOMEM;
-       }
-
-       memset(vptr->tx_bufs, 0, vptr->options.numtx * PKT_BUF_SZ * vptr->num_txq);
-
-       i = vptr->options.numrx * sizeof(struct rx_desc);
-       pool += i;
-       pool_dma += i;
-       for (i = 0; i < vptr->num_txq; i++) {
-               int offset = vptr->options.numtx * sizeof(struct tx_desc);
-
-               vptr->td_pool_dma[i] = pool_dma;
-               vptr->td_rings[i] = (struct tx_desc *) pool;
-               pool += offset;
-               pool_dma += offset;
-       }
-       return 0;
-}
-
-/**
- *     velocity_free_rings     -       free PCI ring pointers
- *     @vptr: Velocity to free from
- *
- *     Clean up the PCI ring buffers allocated to this velocity.
- */
-
-static void velocity_free_rings(struct velocity_info *vptr)
-{
-       int size;
-
-       size = vptr->options.numrx * sizeof(struct rx_desc) + 
-              vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq;
-
-       pci_free_consistent(vptr->pdev, size, vptr->rd_ring, vptr->rd_pool_dma);
-
-       size = vptr->options.numtx * PKT_BUF_SZ * vptr->num_txq;
-
-       pci_free_consistent(vptr->pdev, size, vptr->tx_bufs, vptr->tx_bufs_dma);
-}
-
-/**
- *     velocity_init_rd_ring   -       set up receive ring
- *     @vptr: velocity to configure
- *
- *     Allocate and set up the receive buffers for each ring slot and
- *     assign them to the network adapter.
- */
-
-static int velocity_init_rd_ring(struct velocity_info *vptr)
-{
-       int i, ret = -ENOMEM;
-       struct rx_desc *rd;
-       struct velocity_rd_info *rd_info;
-       unsigned int rsize = sizeof(struct velocity_rd_info) * 
-                                       vptr->options.numrx;
-
-       vptr->rd_info = kmalloc(rsize, GFP_KERNEL);
-       if(vptr->rd_info == NULL)
-               goto out;
-       memset(vptr->rd_info, 0, rsize);
-
-       /* Init the RD ring entries */
-       for (i = 0; i < vptr->options.numrx; i++) {
-               rd = &(vptr->rd_ring[i]);
-               rd_info = &(vptr->rd_info[i]);
-
-               ret = velocity_alloc_rx_buf(vptr, i);
-               if (ret < 0) {
-                       VELOCITY_PRT(MSG_LEVEL_ERR, KERN_ERR
-                               "%s: failed to allocate RX buffer.\n", 
-                               vptr->dev->name);
-                       velocity_free_rd_ring(vptr);
-                       goto out;
-               }
-               rd->rdesc0.owner = OWNED_BY_NIC;
-       }
-       vptr->rd_used = vptr->rd_curr = 0;
-out:
-       return ret;
-}
-
-/**
- *     velocity_free_rd_ring   -       set up receive ring
- *     @vptr: velocity to clean up
- *
- *     Free the receive buffers for each ring slot and any
- *     attached socket buffers that need to go away.
- */
-
-static void velocity_free_rd_ring(struct velocity_info *vptr)
-{
-       int i;
-
-       if (vptr->rd_info == NULL)
-               return;
-
-       for (i = 0; i < vptr->options.numrx; i++) {
-               struct velocity_rd_info *rd_info = &(vptr->rd_info[i]);
-
-               if (!rd_info->skb_dma)
-                       continue;
-               pci_unmap_single(vptr->pdev, rd_info->skb_dma, vptr->rx_buf_sz,
-                                PCI_DMA_FROMDEVICE);
-               rd_info->skb_dma = (dma_addr_t) NULL;
-
-               dev_kfree_skb(rd_info->skb);
-               rd_info->skb = NULL;
-       }
-
-       kfree(vptr->rd_info);
-       vptr->rd_info = NULL;
-}
-
-/**
- *     velocity_init_td_ring   -       set up transmit ring
- *     @vptr:  velocity
- *
- *     Set up the transmit ring and chain the ring pointers together.
- *     Returns zero on success or a negative posix errno code for
- *     failure.
- */
-static int velocity_init_td_ring(struct velocity_info *vptr)
-{
-       int i, j;
-       dma_addr_t curr;
-       struct tx_desc *td;
-       struct velocity_td_info *td_info;
-       unsigned int tsize = sizeof(struct velocity_td_info) * 
-                                       vptr->options.numtx;
-
-       /* Init the TD ring entries */
-       for (j = 0; j < vptr->num_txq; j++) {
-               curr = vptr->td_pool_dma[j];
-
-               vptr->td_infos[j] = kmalloc(tsize, GFP_KERNEL);
-               if(vptr->td_infos[j] == NULL)
-               {
-                       while(--j >= 0)
-                               kfree(vptr->td_infos[j]);
-                       return -ENOMEM;
-               }
-               memset(vptr->td_infos[j], 0, tsize);
-
-               for (i = 0; i < vptr->options.numtx; i++, curr += sizeof(struct tx_desc)) {
-                       td = &(vptr->td_rings[j][i]);
-                       td_info = &(vptr->td_infos[j][i]);
-                       td_info->buf = vptr->tx_bufs + (i + j) * PKT_BUF_SZ;
-                       td_info->buf_dma = vptr->tx_bufs_dma + (i + j) * PKT_BUF_SZ;
-               }
-               vptr->td_tail[j] = vptr->td_curr[j] = vptr->td_used[j] = 0;
-       }
-       return 0;
-}
-
-/*
- *     FIXME: could we merge this with velocity_free_tx_buf ?
- */
-
-static void velocity_free_td_ring_entry(struct velocity_info *vptr,
-                                                        int q, int n)
-{
-       struct velocity_td_info * td_info = &(vptr->td_infos[q][n]);
-       int i;
-       
-       if (td_info == NULL)
-               return;
-               
-       if (td_info->skb) {
-               for (i = 0; i < td_info->nskb_dma; i++)
-               {
-                       if (td_info->skb_dma[i]) {
-                               pci_unmap_single(vptr->pdev, td_info->skb_dma[i], 
-                                       td_info->skb->len, PCI_DMA_TODEVICE);
-                               td_info->skb_dma[i] = (dma_addr_t) NULL;
-                       }
-               }
-               dev_kfree_skb(td_info->skb);
-               td_info->skb = NULL;
-       }
-}
-
-/**
- *     velocity_free_td_ring   -       free td ring
- *     @vptr: velocity
- *
- *     Free up the transmit ring for this particular velocity adapter.
- *     We free the ring contents but not the ring itself.
- */
-static void velocity_free_td_ring(struct velocity_info *vptr)
-{
-       int i, j;
-
-       for (j = 0; j < vptr->num_txq; j++) {
-               if (vptr->td_infos[j] == NULL)
-                       continue;
-               for (i = 0; i < vptr->options.numtx; i++) {
-                       velocity_free_td_ring_entry(vptr, j, i);
-
-               }
-               if (vptr->td_infos[j]) {
-                       kfree(vptr->td_infos[j]);
-                       vptr->td_infos[j] = NULL;
-               }
-       }
-}
-
-/**
- *     velocity_rx_srv         -       service RX interrupt
- *     @vptr: velocity
- *     @status: adapter status (unused)
- *
- *     Walk the receive ring of the velocity adapter and remove
- *     any received packets from the receive queue. Hand the ring
- *     slots back to the adapter for reuse.
- */
-static int velocity_rx_srv(struct velocity_info *vptr, int status)
-{
-       struct rx_desc *rd;
-       struct net_device_stats *stats = &vptr->stats;
-       struct mac_regs * regs = vptr->mac_regs;
-       int rd_curr = vptr->rd_curr;
-       int works = 0;
-
-       while (1) {
-
-               rd = &(vptr->rd_ring[rd_curr]);
-
-               if ((vptr->rd_info[rd_curr]).skb == NULL) {
-                       if (velocity_alloc_rx_buf(vptr, rd_curr) < 0)
-                               break;
-               }
-
-               if (works++ > 15)
-                       break;
-
-               if (rd->rdesc0.owner == OWNED_BY_NIC)
-                       break;
-
-               /*
-                *      Don't drop CE or RL error frame although RXOK is off
-                *      FIXME: need to handle copybreak
-                */
-               if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) {
-                       if (velocity_receive_frame(vptr, rd_curr) == 0) {
-                               if (velocity_alloc_rx_buf(vptr, rd_curr) < 0) {
-                                       VELOCITY_PRT(MSG_LEVEL_ERR, KERN_ERR "%s: can not allocate rx buf\n", vptr->dev->name);
-                                       break;
-                               }
-                       } else {
-                               stats->rx_dropped++;
-                       }
-               } else {
-                       if (rd->rdesc0.RSR & RSR_CRC)
-                               stats->rx_crc_errors++;
-                       if (rd->rdesc0.RSR & RSR_FAE)
-                               stats->rx_frame_errors++;
-
-                       stats->rx_dropped++;
-               }
-
-               rd->inten = 1;
-
-               if (++vptr->rd_used >= 4) {
-                       int i, rd_prev = rd_curr;
-                       for (i = 0; i < 4; i++) {
-                               if (--rd_prev < 0)
-                                       rd_prev = vptr->options.numrx - 1;
-
-                               rd = &(vptr->rd_ring[rd_prev]);
-                               rd->rdesc0.owner = OWNED_BY_NIC;
-                       }
-                       writew(4, &(regs->RBRDU));
-                       vptr->rd_used -= 4;
-               }
-
-               vptr->dev->last_rx = jiffies;
-
-               rd_curr++;
-               if (rd_curr >= vptr->options.numrx)
-                       rd_curr = 0;
-       }
-       vptr->rd_curr = rd_curr;
-       VAR_USED(stats);
-       return works;
-}
-
-/**
- *     velocity_rx_csum        -       checksum process
- *     @rd: receive packet descriptor
- *     @skb: network layer packet buffer
- *
- *     Process the status bits for the received packet and determine
- *     if the checksum was computed and verified by the hardware
- */
-static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
-{
-       skb->ip_summed = CHECKSUM_NONE;
-
-       if (rd->rdesc1.CSM & CSM_IPKT) {
-               if (rd->rdesc1.CSM & CSM_IPOK) {
-                       if ((rd->rdesc1.CSM & CSM_TCPKT) || 
-                                       (rd->rdesc1.CSM & CSM_UDPKT)) {
-                               if (!(rd->rdesc1.CSM & CSM_TUPOK)) {
-                                       return;
-                               }
-                       }
-                       skb->ip_summed = CHECKSUM_UNNECESSARY;
-               }
-       }
-}
-
-/**
- *     velocity_receive_frame  -       received packet processor
- *     @vptr: velocity we are handling
- *     @idx: ring index
- *     
- *     A packet has arrived. We process the packet and if appropriate
- *     pass the frame up the network stack
- */
-static int velocity_receive_frame(struct velocity_info *vptr, int idx)
-{
-       struct net_device_stats *stats = &vptr->stats;
-       struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
-       struct rx_desc *rd = &(vptr->rd_ring[idx]);
-       struct sk_buff *skb;
-
-       if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) {
-               VELOCITY_PRT(MSG_LEVEL_VERBOSE, KERN_ERR " %s : the received frame span multple RDs.\n", vptr->dev->name);
-               stats->rx_length_errors++;
-               return -EINVAL;
-       }
-
-       if (rd->rdesc0.RSR & RSR_MAR)
-               vptr->stats.multicast++;
-
-       skb = rd_info->skb;
-       skb->dev = vptr->dev;
-
-       pci_unmap_single(vptr->pdev, rd_info->skb_dma, vptr->rx_buf_sz, 
-                                                       PCI_DMA_FROMDEVICE);
-       rd_info->skb_dma = (dma_addr_t) NULL;
-       rd_info->skb = NULL;
-
-       /* FIXME - memmove ? */
-       if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
-               int i;
-               for (i = rd->rdesc0.len + 4; i >= 0; i--)
-                       *(skb->data + i + 2) = *(skb->data + i);
-               skb->data += 2;
-               skb->tail += 2;
-       }
-
-       skb_put(skb, (rd->rdesc0.len - 4));
-       skb->protocol = eth_type_trans(skb, skb->dev);
-
-       /*
-        *      Drop frame not meeting IEEE 802.3
-        */
-        
-       if (vptr->flags & VELOCITY_FLAGS_VAL_PKT_LEN) {
-               if (rd->rdesc0.RSR & RSR_RL) {
-                       stats->rx_length_errors++;
-                       return -EINVAL;
-               }
-       }
-
-       velocity_rx_csum(rd, skb);
-       
-       /*
-        *      FIXME: need rx_copybreak handling
-        */
-
-       stats->rx_bytes += skb->len;
-       netif_rx(skb);
-
-       return 0;
-}
-
-/**
- *     velocity_alloc_rx_buf   -       allocate aligned receive buffer
- *     @vptr: velocity
- *     @idx: ring index
- *
- *     Allocate a new full sized buffer for the reception of a frame and
- *     map it into PCI space for the hardware to use. The hardware
- *     requires *64* byte alignment of the buffer which makes life
- *     less fun than would be ideal.
- */
-static int velocity_alloc_rx_buf(struct velocity_info *vptr, int idx)
-{
-       struct rx_desc *rd = &(vptr->rd_ring[idx]);
-       struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
-
-       rd_info->skb = dev_alloc_skb(vptr->rx_buf_sz + 64);
-       if (rd_info->skb == NULL)
-               return -ENOMEM;
-
-       /*
-        *      Do the gymnastics to get the buffer head for data at
-        *      64byte alignment.
-        */
-       skb_reserve(rd_info->skb, (unsigned long) rd_info->skb->tail & 63);
-       rd_info->skb->dev = vptr->dev;
-       rd_info->skb_dma = pci_map_single(vptr->pdev, rd_info->skb->tail, vptr->rx_buf_sz, PCI_DMA_FROMDEVICE);
-       
-       /*
-        *      Fill in the descriptor to match
-        */     
-        
-       *((u32 *) & (rd->rdesc0)) = 0;
-       rd->len = cpu_to_le32(vptr->rx_buf_sz);
-       rd->inten = 1;
-       rd->pa_low = cpu_to_le32(rd_info->skb_dma);
-       rd->pa_high = 0;
-       return 0;
-}
-
-/**
- *     tx_srv          -       transmit interrupt service
- *     @vptr; Velocity
- *     @status:
- *
- *     Scan the queues looking for transmitted packets that
- *     we can complete and clean up. Update any statistics as
- *     neccessary/
- */
-static int velocity_tx_srv(struct velocity_info *vptr, u32 status)
-{
-       struct tx_desc *td;
-       int qnum;
-       int full = 0;
-       int idx;
-       int works = 0;
-       struct velocity_td_info *tdinfo;
-       struct net_device_stats *stats = &vptr->stats;
-
-       for (qnum = 0; qnum < vptr->num_txq; qnum++) {
-               for (idx = vptr->td_tail[qnum]; vptr->td_used[qnum] > 0; 
-                       idx = (idx + 1) % vptr->options.numtx) {
-
-                       /*
-                        *      Get Tx Descriptor
-                        */
-                       td = &(vptr->td_rings[qnum][idx]);
-                       tdinfo = &(vptr->td_infos[qnum][idx]);
-
-                       if (td->tdesc0.owner == OWNED_BY_NIC)
-                               break;
-
-                       if ((works++ > 15))
-                               break;
-
-                       if (td->tdesc0.TSR & TSR0_TERR) {
-                               stats->tx_errors++;
-                               stats->tx_dropped++;
-                               if (td->tdesc0.TSR & TSR0_CDH)
-                                       stats->tx_heartbeat_errors++;
-                               if (td->tdesc0.TSR & TSR0_CRS)
-                                       stats->tx_carrier_errors++;
-                               if (td->tdesc0.TSR & TSR0_ABT)
-                                       stats->tx_aborted_errors++;
-                               if (td->tdesc0.TSR & TSR0_OWC)
-                                       stats->tx_window_errors++;
-                       } else {
-                               stats->tx_packets++;
-                               stats->tx_bytes += tdinfo->skb->len;
-                       }
-                       velocity_free_tx_buf(vptr, tdinfo);
-                       vptr->td_used[qnum]--;
-               }
-               vptr->td_tail[qnum] = idx;
-
-               if (AVAIL_TD(vptr, qnum) < 1) {
-                       full = 1;
-               }
-       }
-       /*
-        *      Look to see if we should kick the transmit network
-        *      layer for more work.
-        */
-       if (netif_queue_stopped(vptr->dev) && (full == 0)
-           && (!(vptr->mii_status & VELOCITY_LINK_FAIL))) {
-               netif_wake_queue(vptr->dev);
-       }
-       return works;
-}
-
-/**
- *     velocity_print_link_status      -       link status reporting
- *     @vptr: velocity to report on
- *
- *     Turn the link status of the velocity card into a kernel log
- *     description of the new link state, detailing speed and duplex
- *     status
- */
-
-static void velocity_print_link_status(struct velocity_info *vptr)
-{
-
-       if (vptr->mii_status & VELOCITY_LINK_FAIL) {
-               VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: failed to detect cable link\n", vptr->dev->name);
-       } else if (vptr->options.spd_dpx == SPD_DPX_AUTO) {
-               VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link autonegation", vptr->dev->name);
-
-               if (vptr->mii_status & VELOCITY_SPEED_1000)
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps");
-               else if (vptr->mii_status & VELOCITY_SPEED_100)
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps");
-               else
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps");
-
-               if (vptr->mii_status & VELOCITY_DUPLEX_FULL)
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " full duplex\n");
-               else
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " half duplex\n");
-       } else {
-               VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link forced", vptr->dev->name);
-               switch (vptr->options.spd_dpx) {
-               case SPD_DPX_100_HALF:
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps half duplex\n");
-                       break;
-               case SPD_DPX_100_FULL:
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps full duplex\n");
-                       break;
-               case SPD_DPX_10_HALF:
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps half duplex\n");
-                       break;
-               case SPD_DPX_10_FULL:
-                       VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps full duplex\n");
-                       break;
-               default:
-                       break;
-               }
-       }
-}
-
-/**
- *     velocity_error  -       handle error from controller
- *     @vptr: velocity
- *     @status: card status
- *
- *     Process an error report from the hardware and attempt to recover
- *     the card itself. At the moment we cannot recover from some 
- *     theoretically impossible errors but this could be fixed using
- *     the pci_device_failed logic to bounce the hardware
- *
- */
-static void velocity_error(struct velocity_info *vptr, int status)
-{
-
-       if (status & ISR_TXSTLI) {
-               struct mac_regs * regs = vptr->mac_regs;
-
-               printk(KERN_ERR "TD structure errror TDindex=%hx\n", readw(&regs->TDIdx[0]));
-               BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR);
-               writew(TRDCSR_RUN, &regs->TDCSRClr);
-               netif_stop_queue(vptr->dev);
-               
-               /* FIXME: port over the pci_device_failed code and use it
-                  here */
-       }
-
-       if (status & ISR_SRCI) {
-               struct mac_regs * regs = vptr->mac_regs;
-               int linked;
-
-               if (vptr->options.spd_dpx == SPD_DPX_AUTO) {
-                       vptr->mii_status = check_connection_type(regs);
-
-                       /*
-                        *      If it is a 3119, disable frame bursting in 
-                        *      halfduplex mode and enable it in fullduplex
-                        *       mode
-                        */
-                       if (vptr->rev_id < REV_ID_VT3216_A0) {
-                               if (vptr->mii_status | VELOCITY_DUPLEX_FULL)
-                                       BYTE_REG_BITS_ON(TCR_TB2BDIS, &regs->TCR);
-                               else
-                                       BYTE_REG_BITS_OFF(TCR_TB2BDIS, &regs->TCR);
-                       }
-                       /*
-                        *      Only enable CD heart beat counter in 10HD mode
-                        */
-                       if (!(vptr->mii_status & VELOCITY_DUPLEX_FULL) && (vptr->mii_status & VELOCITY_SPEED_10)) {
-                               BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG);
-                       } else {
-                               BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG);
-                       }
-               }
-               /*
-                *      Get link status from PHYSR0
-                */
-               linked = readb(&regs->PHYSR0) & PHYSR0_LINKGD;
-
-               if (linked) {
-                       vptr->mii_status &= ~VELOCITY_LINK_FAIL;
-               } else {
-                       vptr->mii_status |= VELOCITY_LINK_FAIL;
-               }
-
-               velocity_print_link_status(vptr);
-               enable_flow_control_ability(vptr);
-
-               /*
-                *      Re-enable auto-polling because SRCI will disable 
-                *      auto-polling
-                */
-                
-               enable_mii_autopoll(regs);
-
-               if (vptr->mii_status & VELOCITY_LINK_FAIL)
-                       netif_stop_queue(vptr->dev);
-               else
-                       netif_wake_queue(vptr->dev);
-
-       };
-       if (status & ISR_MIBFI)
-               velocity_update_hw_mibs(vptr);
-       if (status & ISR_LSTEI)
-               mac_rx_queue_wake(vptr->mac_regs);
-}
-
-/**
- *     velocity_free_tx_buf    -       free transmit buffer
- *     @vptr: velocity
- *     @tdinfo: buffer
- *
- *     Release an transmit buffer. If the buffer was preallocated then
- *     recycle it, if not then unmap the buffer.
- */
-static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_info *tdinfo)
-{
-       struct sk_buff *skb = tdinfo->skb;
-       int i;
-
-       /*
-        *      Don't unmap the pre-allocated tx_bufs
-        */
-       if (tdinfo->skb_dma && (tdinfo->skb_dma[0] != tdinfo->buf_dma)) {
-
-               for (i = 0; i < tdinfo->nskb_dma; i++) {
-#ifdef VELOCITY_ZERO_COPY_SUPPORT
-                       pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], td->tdesc1.len, PCI_DMA_TODEVICE);
-#else
-                       pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], skb->len, PCI_DMA_TODEVICE);
-#endif
-                       tdinfo->skb_dma[i] = 0;
-               }
-       }
-       dev_kfree_skb_irq(skb);
-       tdinfo->skb = NULL;
-}
-
-/**
- *     velocity_open           -       interface activation callback
- *     @dev: network layer device to open
- *
- *     Called when the network layer brings the interface up. Returns
- *     a negative posix error code on failure, or zero on success.
- *
- *     All the ring allocation and set up is done on open for this
- *     adapter to minimise memory usage when inactive
- */
-static int velocity_open(struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-       int ret;
-
-       vptr->rx_buf_sz = (dev->mtu <= 1504 ? PKT_BUF_SZ : dev->mtu + 32);
-
-       ret = velocity_init_rings(vptr);
-       if (ret < 0)
-               goto out;
-
-       ret = velocity_init_rd_ring(vptr);
-       if (ret < 0)
-               goto err_free_desc_rings;
-
-       ret = velocity_init_td_ring(vptr);
-       if (ret < 0)
-               goto err_free_rd_ring;
-       
-       /* Ensure chip is running */    
-       pci_set_power_state(vptr->pdev, 0);
-       
-       velocity_init_registers(vptr, VELOCITY_INIT_COLD);
-
-       ret = request_irq(vptr->pdev->irq, &velocity_intr, SA_SHIRQ,
-                         dev->name, dev);
-       if (ret < 0) {
-               /* Power down the chip */
-               pci_set_power_state(vptr->pdev, 3);
-               goto err_free_td_ring;
-       }
-
-       mac_enable_int(vptr->mac_regs);
-       netif_start_queue(dev);
-       vptr->flags |= VELOCITY_FLAGS_OPENED;
-out:
-       return ret;
-
-err_free_td_ring:
-       velocity_free_td_ring(vptr);
-err_free_rd_ring:
-       velocity_free_rd_ring(vptr);
-err_free_desc_rings:
-       velocity_free_rings(vptr);
-       goto out;
-}
-
-/** 
- *     velocity_change_mtu     -       MTU change callback
- *     @dev: network device
- *     @new_mtu: desired MTU
- *
- *     Handle requests from the networking layer for MTU change on
- *     this interface. It gets called on a change by the network layer.
- *     Return zero for success or negative posix error code.
- */
-static int velocity_change_mtu(struct net_device *dev, int new_mtu)
-{
-       struct velocity_info *vptr = dev->priv;
-       unsigned long flags;
-       int oldmtu = dev->mtu;
-       int ret = 0;
-
-       if ((new_mtu < VELOCITY_MIN_MTU) || new_mtu > (VELOCITY_MAX_MTU)) {
-               VELOCITY_PRT(MSG_LEVEL_ERR, KERN_NOTICE "%s: Invalid MTU.\n", 
-                               vptr->dev->name);
-               return -EINVAL;
-       }
-
-       if (new_mtu != oldmtu) {
-               spin_lock_irqsave(&vptr->lock, flags);
-
-               netif_stop_queue(dev);
-               velocity_shutdown(vptr);
-
-               velocity_free_td_ring(vptr);
-               velocity_free_rd_ring(vptr);
-
-               dev->mtu = new_mtu;
-               if (new_mtu > 8192)
-                       vptr->rx_buf_sz = 9 * 1024;
-               else if (new_mtu > 4096)
-                       vptr->rx_buf_sz = 8192;
-               else
-                       vptr->rx_buf_sz = 4 * 1024;
-
-               ret = velocity_init_rd_ring(vptr);
-               if (ret < 0)
-                       goto out_unlock;
-
-               ret = velocity_init_td_ring(vptr);
-               if (ret < 0)
-                       goto out_unlock;
-
-               velocity_init_registers(vptr, VELOCITY_INIT_COLD);
-
-               mac_enable_int(vptr->mac_regs);
-               netif_start_queue(dev);
-out_unlock:
-               spin_unlock_irqrestore(&vptr->lock, flags);
-       }
-
-       return ret;
-}
-
-/**
- *     velocity_shutdown       -       shut down the chip
- *     @vptr: velocity to deactivate
- *
- *     Shuts down the internal operations of the velocity and
- *     disables interrupts, autopolling, transmit and receive
- */
-static void velocity_shutdown(struct velocity_info *vptr)
-{
-       struct mac_regs * regs = vptr->mac_regs;
-       mac_disable_int(regs);
-       writel(CR0_STOP, &regs->CR0Set);
-       writew(0xFFFF, &regs->TDCSRClr);
-       writeb(0xFF, &regs->RDCSRClr);
-       safe_disable_mii_autopoll(regs);
-       mac_clear_isr(regs);
-}
-
-/**
- *     velocity_close          -       close adapter callback
- *     @dev: network device
- *
- *     Callback from the network layer when the velocity is being
- *     deactivated by the network layer
- */
-
-static int velocity_close(struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-
-       netif_stop_queue(dev);
-       velocity_shutdown(vptr);
-
-       if (vptr->flags & VELOCITY_FLAGS_WOL_ENABLED)
-               velocity_get_ip(vptr);
-       if (dev->irq != 0)
-               free_irq(dev->irq, dev);
-               
-       /* Power down the chip */
-       pci_set_power_state(vptr->pdev, 3);
-       
-       /* Free the resources */
-       velocity_free_td_ring(vptr);
-       velocity_free_rd_ring(vptr);
-       velocity_free_rings(vptr);
-
-       vptr->flags &= (~VELOCITY_FLAGS_OPENED);
-       return 0;
-}
-
-/**
- *     velocity_xmit           -       transmit packet callback
- *     @skb: buffer to transmit
- *     @dev: network device
- *
- *     Called by the networ layer to request a packet is queued to
- *     the velocity. Returns zero on success.
- */
-static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-       int qnum = 0;
-       struct tx_desc *td_ptr;
-       struct velocity_td_info *tdinfo;
-       unsigned long flags;
-       int index;
-
-       int pktlen = skb->len;
-
-       spin_lock_irqsave(&vptr->lock, flags);
-
-       index = vptr->td_curr[qnum];
-       td_ptr = &(vptr->td_rings[qnum][index]);
-       tdinfo = &(vptr->td_infos[qnum][index]);
-
-       td_ptr->tdesc1.TCPLS = TCPLS_NORMAL;
-       td_ptr->tdesc1.TCR = TCR0_TIC;
-       td_ptr->td_buf[0].queue = 0;
-
-       /*
-        *      Pad short frames. 
-        */
-       if (pktlen < ETH_ZLEN) {
-               /* Cannot occur until ZC support */
-               if(skb_linearize(skb, GFP_ATOMIC))
-                       return 0; 
-               pktlen = ETH_ZLEN;
-               memcpy(tdinfo->buf, skb->data, skb->len);
-               memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
-               tdinfo->skb = skb;
-               tdinfo->skb_dma[0] = tdinfo->buf_dma;
-               td_ptr->tdesc0.pktsize = pktlen;
-               td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
-               td_ptr->td_buf[0].pa_high = 0;
-               td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
-               tdinfo->nskb_dma = 1;
-               td_ptr->tdesc1.CMDZ = 2;
-       } else
-#ifdef VELOCITY_ZERO_COPY_SUPPORT
-       if (skb_shinfo(skb)->nr_frags > 0) {
-               int nfrags = skb_shinfo(skb)->nr_frags;
-               tdinfo->skb = skb;
-               if (nfrags > 6) {
-                       skb_linearize(skb, GFP_ATOMIC);
-                       memcpy(tdinfo->buf, skb->data, skb->len);
-                       tdinfo->skb_dma[0] = tdinfo->buf_dma;
-                       td_ptr->tdesc0.pktsize = 
-                       td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
-                       td_ptr->td_buf[0].pa_high = 0;
-                       td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
-                       tdinfo->nskb_dma = 1;
-                       td_ptr->tdesc1.CMDZ = 2;
-               } else {
-                       int i = 0;
-                       tdinfo->nskb_dma = 0;
-                       tdinfo->skb_dma[i] = pci_map_single(vptr->pdev, skb->data, skb->len - skb->data_len, PCI_DMA_TODEVICE);
-
-                       td_ptr->tdesc0.pktsize = pktlen;
-
-                       /* FIXME: support 48bit DMA later */
-                       td_ptr->td_buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma);
-                       td_ptr->td_buf[i].pa_high = 0;
-                       td_ptr->td_buf[i].bufsize = skb->len->skb->data_len;
-
-                       for (i = 0; i < nfrags; i++) {
-                               skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
-                               void *addr = ((void *) page_address(frag->page + frag->page_offset));
-
-                               tdinfo->skb_dma[i + 1] = pci_map_single(vptr->pdev, addr, frag->size, PCI_DMA_TODEVICE);
-
-                               td_ptr->td_buf[i + 1].pa_low = cpu_to_le32(tdinfo->skb_dma[i + 1]);
-                               td_ptr->td_buf[i + 1].pa_high = 0;
-                               td_ptr->td_buf[i + 1].bufsize = frag->size;
-                       }
-                       tdinfo->nskb_dma = i - 1;
-                       td_ptr->tdesc1.CMDZ = i;
-               }
-
-       } else
-#endif
-       {
-               /*
-                *      Map the linear network buffer into PCI space and
-                *      add it to the transmit ring.
-                */
-               tdinfo->skb = skb;
-               tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE);
-               td_ptr->tdesc0.pktsize = pktlen;
-               td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
-               td_ptr->td_buf[0].pa_high = 0;
-               td_ptr->td_buf[0].bufsize = td_ptr->tdesc0.pktsize;
-               tdinfo->nskb_dma = 1;
-               td_ptr->tdesc1.CMDZ = 2;
-       }
-
-       if (vptr->flags & VELOCITY_FLAGS_TAGGING) {
-               td_ptr->tdesc1.pqinf.VID = (vptr->options.vid & 0xfff);
-               td_ptr->tdesc1.pqinf.priority = 0;
-               td_ptr->tdesc1.pqinf.CFI = 0;
-               td_ptr->tdesc1.TCR |= TCR0_VETAG;
-       }
-
-       /*
-        *      Handle hardware checksum
-        */
-       if ((vptr->flags & VELOCITY_FLAGS_TX_CSUM)
-                                && (skb->ip_summed == CHECKSUM_HW)) {
-               struct iphdr *ip = skb->nh.iph;
-               if (ip->protocol == IPPROTO_TCP)
-                       td_ptr->tdesc1.TCR |= TCR0_TCPCK;
-               else if (ip->protocol == IPPROTO_UDP)
-                       td_ptr->tdesc1.TCR |= (TCR0_UDPCK);
-               td_ptr->tdesc1.TCR |= TCR0_IPCK;
-       }
-       {
-
-               int prev = index - 1;
-
-               if (prev < 0)
-                       prev = vptr->options.numtx - 1;
-               td_ptr->tdesc0.owner = OWNED_BY_NIC;
-               vptr->td_used[qnum]++;
-               vptr->td_curr[qnum] = (index + 1) % vptr->options.numtx;
-
-               if (AVAIL_TD(vptr, qnum) < 1)
-                       netif_stop_queue(dev);
-
-               td_ptr = &(vptr->td_rings[qnum][prev]);
-               td_ptr->td_buf[0].queue = 1;
-               mac_tx_queue_wake(vptr->mac_regs, qnum);
-       }
-       dev->trans_start = jiffies;
-       spin_unlock_irqrestore(&vptr->lock, flags);
-       return 0;
-}
-
-/**
- *     velocity_intr           -       interrupt callback
- *     @irq: interrupt number
- *     @dev_instance: interrupting device
- *     @pt_regs: CPU register state at interrupt
- *
- *     Called whenever an interrupt is generated by the velocity
- *     adapter IRQ line. We may not be the source of the interrupt
- *     and need to identify initially if we are, and if not exit as
- *     efficiently as possible.
- */
-static int velocity_intr(int irq, void *dev_instance, struct pt_regs *regs)
-{
-       struct net_device *dev = dev_instance;
-       struct velocity_info *vptr = dev->priv;
-       u32 isr_status;
-       int max_count = 0;
-
-
-       spin_lock(&vptr->lock);
-       isr_status = mac_read_isr(vptr->mac_regs);
-
-       /* Not us ? */
-       if (isr_status == 0) {
-               spin_unlock(&vptr->lock);
-               return IRQ_NONE;
-       }
-
-       mac_disable_int(vptr->mac_regs);
-
-       /*
-        *      Keep processing the ISR until we have completed
-        *      processing and the isr_status becomes zero
-        */
-        
-       while (isr_status != 0) {
-               mac_write_isr(vptr->mac_regs, isr_status);
-               if (isr_status & (~(ISR_PRXI | ISR_PPRXI | ISR_PTXI | ISR_PPTXI)))
-                       velocity_error(vptr, isr_status);
-               if (isr_status & (ISR_PRXI | ISR_PPRXI))
-                       max_count += velocity_rx_srv(vptr, isr_status);
-               if (isr_status & (ISR_PTXI | ISR_PPTXI))
-                       max_count += velocity_tx_srv(vptr, isr_status);
-               isr_status = mac_read_isr(vptr->mac_regs);
-               if (max_count > vptr->options.int_works)
-               {
-                       printk(KERN_WARNING "%s: excessive work at interrupt.\n", 
-                               dev->name);
-                       max_count = 0;
-               }
-       }
-       spin_unlock(&vptr->lock);
-       mac_enable_int(vptr->mac_regs);
-       return IRQ_HANDLED;
-
-}
-
-
-/**
- *     ether_crc       -       ethernet CRC function
- *
- *     Compute an ethernet CRC hash of the data block provided. This
- *     is not performance optimised but is not needed in performance
- *     critical code paths.
- *
- *     FIXME: could we use shared code here ?
- */
-static inline u32 ether_crc(int length, unsigned char *data)
-{
-       static unsigned const ethernet_polynomial = 0x04c11db7U;
-       
-       int crc = -1;
-
-       while (--length >= 0) {
-               unsigned char current_octet = *data++;
-               int bit;
-               for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
-                       crc = (crc << 1) ^ ((crc < 0) ^ (current_octet & 1) ? ethernet_polynomial : 0);
-               }
-       }
-       return crc;
-}
-
-/**
- *     velocity_set_multi      -       filter list change callback
- *     @dev: network device
- *
- *     Called by the network layer when the filter lists need to change
- *     for a velocity adapter. Reload the CAMs with the new address
- *     filter ruleset.
- */
-static void velocity_set_multi(struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-       struct mac_regs * regs = vptr->mac_regs;
-       u8 rx_mode;
-       int i;
-       struct dev_mc_list *mclist;
-
-       if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
-               /* Unconditionally log net taps. */
-               printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
-               writel(0xffffffff, &regs->MARCAM[0]);
-               writel(0xffffffff, &regs->MARCAM[4]);
-               rx_mode = (RCR_AM | RCR_AB | RCR_PROM);
-       } else if ((dev->mc_count > vptr->multicast_limit)
-                  || (dev->flags & IFF_ALLMULTI)) {
-               writel(0xffffffff, &regs->MARCAM[0]);
-               writel(0xffffffff, &regs->MARCAM[4]);
-               rx_mode = (RCR_AM | RCR_AB);
-       } else {
-               int offset = MCAM_SIZE - vptr->multicast_limit;
-               mac_get_cam_mask(regs, vptr->mCAMmask, VELOCITY_MULTICAST_CAM);
-
-               for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; i++, mclist = mclist->next) {
-                       mac_set_cam(regs, i + offset, mclist->dmi_addr, VELOCITY_MULTICAST_CAM);
-                       vptr->mCAMmask[(offset + i) / 8] |= 1 << ((offset + i) & 7);
-               }
-
-               mac_set_cam_mask(regs, vptr->mCAMmask, VELOCITY_MULTICAST_CAM);
-               rx_mode = (RCR_AM | RCR_AB);
-       }
-       if (dev->mtu > 1500)
-               rx_mode |= RCR_AL;
-
-       BYTE_REG_BITS_ON(rx_mode, &regs->RCR);
-
-}
-
-/**
- *     velocity_get_status     -       statistics callback
- *     @dev: network device
- *
- *     Callback from the network layer to allow driver statistics
- *     to be resynchronized with hardware collected state. In the
- *     case of the velocity we need to pull the MIB counters from
- *     the hardware into the counters before letting the network
- *     layer display them.
- */
-static struct net_device_stats *velocity_get_stats(struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-       
-       /* If the hardware is down, don't touch MII */
-       if(!netif_running(dev))
-               return &vptr->stats;
-
-       spin_lock_irq(&vptr->lock);
-       velocity_update_hw_mibs(vptr);
-       spin_unlock_irq(&vptr->lock);
-
-       vptr->stats.rx_packets = vptr->mib_counter[HW_MIB_ifRxAllPkts];
-       vptr->stats.rx_errors = vptr->mib_counter[HW_MIB_ifRxErrorPkts];
-       vptr->stats.rx_length_errors = vptr->mib_counter[HW_MIB_ifInRangeLengthErrors];
-
-//  unsigned long   rx_dropped;     /* no space in linux buffers    */
-       vptr->stats.collisions = vptr->mib_counter[HW_MIB_ifTxEtherCollisions];
-       /* detailed rx_errors: */
-//  unsigned long   rx_length_errors;
-//  unsigned long   rx_over_errors;     /* receiver ring buff overflow  */
-       vptr->stats.rx_crc_errors = vptr->mib_counter[HW_MIB_ifRxPktCRCE];
-//  unsigned long   rx_frame_errors;    /* recv'd frame alignment error */
-//  unsigned long   rx_fifo_errors;     /* recv'r fifo overrun      */
-//  unsigned long   rx_missed_errors;   /* receiver missed packet   */
-
-       /* detailed tx_errors */
-//  unsigned long   tx_fifo_errors;
-
-       return &vptr->stats;
-}
-
-
-/**
- *     velocity_ioctl          -       ioctl entry point
- *     @dev: network device
- *     @rq: interface request ioctl
- *     @cmd: command code
- *
- *     Called when the user issues an ioctl request to the network
- *     device in question. The velocity interface supports MII.
- */
-static int velocity_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
-       struct velocity_info *vptr = dev->priv;
-       int ret;
-
-       /* If we are asked for information and the device is power
-          saving then we need to bring the device back up to talk to it */
-               
-       if(!netif_running(dev))
-               pci_set_power_state(vptr->pdev, 0);
-               
-       switch (cmd) {
-       case SIOCGMIIPHY:       /* Get address of MII PHY in use. */
-       case SIOCGMIIREG:       /* Read MII PHY register. */
-       case SIOCSMIIREG:       /* Write to MII PHY register. */
-               ret = velocity_mii_ioctl(dev, rq, cmd);
-               break;
-
-       default:
-               ret = -EOPNOTSUPP;
-       }
-       if(!netif_running(dev))
-               pci_set_power_state(vptr->pdev, 3);
-               
-               
-       return ret;
-}
-
-/*
- *     Definition for our device driver. The PCI layer interface
- *     uses this to handle all our card discover and plugging
- */
-static struct pci_driver velocity_driver = {
-      name:VELOCITY_NAME,
-      id_table:velocity_id_table,
-      probe:velocity_found1,
-      remove:velocity_remove1,
-#ifdef CONFIG_PM
-      suspend:velocity_suspend,
-      resume:velocity_resume,
-#endif
-};
-
-/**
- *     velocity_init_module    -       load time function
- *
- *     Called when the velocity module is loaded. The PCI driver
- *     is registered with the PCI layer, and in turn will call
- *     the probe functions for each velocity adapter installed
- *     in the system.
- */
-static int __init velocity_init_module(void)
-{
-       int ret;
-       ret = pci_module_init(&velocity_driver);
-
-#ifdef CONFIG_PM
-       register_inetaddr_notifier(&velocity_inetaddr_notifier);
-#endif
-       return ret;
-}
-
-/**
- *     velocity_cleanup        -       module unload
- *
- *     When the velocity hardware is unloaded this function is called.
- *     It will clean up the notifiers and the unregister the PCI 
- *     driver interface for this hardware. This in turn cleans up
- *     all discovered interfaces before returning from the function
- */
-static void __exit velocity_cleanup_module(void)
-{
-#ifdef CONFIG_PM
-       unregister_inetaddr_notifier(&velocity_inetaddr_notifier);
-#endif
-       pci_unregister_driver(&velocity_driver);
-}
-
-module_init(velocity_init_module);
-module_exit(velocity_cleanup_module);
-
-
-/*
- * MII access , media link mode setting functions
- */
-/**
- *     mii_init        -       set up MII
- *     @vptr: velocity adapter
- *     @mii_status:  links tatus
- *
- *     Set up the PHY for the current link state.
- */
-static void mii_init(struct velocity_info *vptr, u32 mii_status)
-{
-       u16 BMCR;
-
-       switch (PHYID_GET_PHY_ID(vptr->phy_id)) {
-       case PHYID_CICADA_CS8201:
-               /*
-                *      Reset to hardware default
-                */
-               MII_REG_BITS_OFF((ANAR_ASMDIR | ANAR_PAUSE), MII_REG_ANAR, vptr->mac_regs);
-               /*
-                *      Turn on ECHODIS bit in NWay-forced full mode and turn it
-                *      off it in NWay-forced half mode for NWay-forced v.s. 
-                *      legacy-forced issue.
-                */
-               if (vptr->mii_status & VELOCITY_DUPLEX_FULL)
-                       MII_REG_BITS_ON(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs);
-               else
-                       MII_REG_BITS_OFF(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs);
-               /*
-                *      Turn on Link/Activity LED enable bit for CIS8201
-                */
-               MII_REG_BITS_ON(PLED_LALBE, MII_REG_PLED, vptr->mac_regs);
-               break;
-       case PHYID_VT3216_32BIT:
-       case PHYID_VT3216_64BIT:
-               /*
-                *      Reset to hardware default
-                */
-               MII_REG_BITS_ON((ANAR_ASMDIR | ANAR_PAUSE), MII_REG_ANAR, vptr->mac_regs);
-               /*
-                *      Turn on ECHODIS bit in NWay-forced full mode and turn it
-                *      off it in NWay-forced half mode for NWay-forced v.s. 
-                *      legacy-forced issue
-                */
-               if (vptr->mii_status & VELOCITY_DUPLEX_FULL)
-                       MII_REG_BITS_ON(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs);
-               else
-                       MII_REG_BITS_OFF(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs);
-               break;
-
-       case PHYID_MARVELL_1000:
-       case PHYID_MARVELL_1000S:
-               /*
-                *      Assert CRS on Transmit 
-                */
-               MII_REG_BITS_ON(PSCR_ACRSTX, MII_REG_PSCR, vptr->mac_regs);
-               /*
-                *      Reset to hardware default 
-                */
-               MII_REG_BITS_ON((ANAR_ASMDIR | ANAR_PAUSE), MII_REG_ANAR, vptr->mac_regs);
-               break;
-       default:
-               ;
-       }
-       velocity_mii_read(vptr->mac_regs, MII_REG_BMCR, &BMCR);
-       if (BMCR & BMCR_ISO) {
-               BMCR &= ~BMCR_ISO;
-               velocity_mii_write(vptr->mac_regs, MII_REG_BMCR, BMCR);
-       }
-}
-
-/**
- *     safe_disable_mii_autopoll       -       autopoll off
- *     @regs: velocity registers
- *
- *     Turn off the autopoll and wait for it to disable on the chip
- */
-static void safe_disable_mii_autopoll(struct mac_regs * regs)
-{
-       u16 ww;
-
-       /*  turn off MAUTO */
-       writeb(0, &regs->MIICR);
-       for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
-               udelay(1);
-               if (BYTE_REG_BITS_IS_ON(MIISR_MIDLE, &regs->MIISR))
-                       break;
-       }
-}
-
-/**
- *     enable_mii_autopoll     -       turn on autopolling
- *     @regs: velocity registers
- *
- *     Enable the MII link status autopoll feature on the Velocity
- *     hardware. Wait for it to enable.
- */
-
-static void enable_mii_autopoll(struct mac_regs * regs)
-{
-       int ii;
-
-       writeb(0, &(regs->MIICR));
-       writeb(MIIADR_SWMPL, &regs->MIIADR);
-
-       for (ii = 0; ii < W_MAX_TIMEOUT; ii++) {
-               udelay(1);
-               if (BYTE_REG_BITS_IS_ON(MIISR_MIDLE, &regs->MIISR))
-                       break;
-       }
-
-       writeb(MIICR_MAUTO, &regs->MIICR);
-
-       for (ii = 0; ii < W_MAX_TIMEOUT; ii++) {
-               udelay(1);
-               if (!BYTE_REG_BITS_IS_ON(MIISR_MIDLE, &regs->MIISR))
-                       break;
-       }
-
-}
-
-/**
- *     velocity_mii_read       -       read MII data
- *     @regs: velocity registers
- *     @index: MII register index
- *     @data: buffer for received data
- *
- *     Perform a single read of an MII 16bit register. Returns zero
- *     on success or -ETIMEDOUT if the PHY did not respond.
- */
-static int velocity_mii_read(struct mac_regs * regs, u8 index, u16 *data)
-{
-       u16 ww;
-
-       /*
-        *      Disable MIICR_MAUTO, so that mii addr can be set normally
-        */
-       safe_disable_mii_autopoll(regs);
-
-       writeb(index, &regs->MIIADR);
-
-       BYTE_REG_BITS_ON(MIICR_RCMD, &regs->MIICR);
-
-       for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
-               if (!(readb(&regs->MIICR) & MIICR_RCMD))
-                       break;
-       }
-
-       *data = readw(&regs->MIIDATA);
-
-       enable_mii_autopoll(regs);
-       if (ww == W_MAX_TIMEOUT)
-               return -ETIMEDOUT;
-       return 0;
-}
-
-/**
- *     velocity_mii_write      -       write MII data
- *     @regs: velocity registers
- *     @index: MII register index
- *     @data: 16bit data for the MII register
- *
- *     Perform a single write to an MII 16bit register. Returns zero
- *     on success or -ETIMEDOUT if the PHY did not respond.
- */
-static int velocity_mii_write(struct mac_regs * regs, u8 mii_addr, u16 data)
-{
-       u16 ww;
-
-       /*
-        *      Disable MIICR_MAUTO, so that mii addr can be set normally
-        */
-       safe_disable_mii_autopoll(regs);
-
-       /* MII reg offset */
-       writeb(mii_addr, &regs->MIIADR);
-       /* set MII data */
-       writew(data, &regs->MIIDATA);
-
-       /* turn on MIICR_WCMD */
-       BYTE_REG_BITS_ON(MIICR_WCMD, &regs->MIICR);
-
-       /* W_MAX_TIMEOUT is the timeout period */
-       for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
-               udelay(5);
-               if (!(readb(&regs->MIICR) & MIICR_WCMD))
-                       break;
-       }
-       enable_mii_autopoll(regs);
-
-       if (ww == W_MAX_TIMEOUT)
-               return -ETIMEDOUT;
-       return 0;
-}
-
-/**
- *     velocity_get_opt_media_mode     -       get media selection
- *     @vptr: velocity adapter
- *
- *     Get the media mode stored in EEPROM or module options and load
- *     mii_status accordingly. The requested link state information
- *     is also returned.
- */
-static u32 velocity_get_opt_media_mode(struct velocity_info *vptr)
-{
-       u32 status = 0;
-
-       switch (vptr->options.spd_dpx) {
-       case SPD_DPX_AUTO:
-               status = VELOCITY_AUTONEG_ENABLE;
-               break;
-       case SPD_DPX_100_FULL:
-               status = VELOCITY_SPEED_100 | VELOCITY_DUPLEX_FULL;
-               break;
-       case SPD_DPX_10_FULL:
-               status = VELOCITY_SPEED_10 | VELOCITY_DUPLEX_FULL;
-               break;
-       case SPD_DPX_100_HALF:
-               status = VELOCITY_SPEED_100;
-               break;
-       case SPD_DPX_10_HALF:
-               status = VELOCITY_SPEED_10;
-               break;
-       }
-       vptr->mii_status = status;
-       return status;
-}
-
-/**
- *     mii_set_auto_on         -       autonegotiate on
- *     @vptr: velocity
- *
- *     Enable autonegotation on this interface
- */
-static void mii_set_auto_on(struct velocity_info *vptr)
-{
-       if (MII_REG_BITS_IS_ON(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs))
-               MII_REG_BITS_ON(BMCR_REAUTO, MII_REG_BMCR, vptr->mac_regs);
-       else
-               MII_REG_BITS_ON(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs);
-}
-
-
-/*
-static void mii_set_auto_off(struct velocity_info * vptr)
-{
-    MII_REG_BITS_OFF(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs);
-}
-*/
-
-/**
- *     set_mii_flow_control    -       flow control setup
- *     @vptr: velocity interface
- *
- *     Set up the flow control on this interface according to
- *     the supplied user/eeprom options.
- */
-static void set_mii_flow_control(struct velocity_info *vptr)
-{
-       /*Enable or Disable PAUSE in ANAR */
-       switch (vptr->options.flow_cntl) {
-       case FLOW_CNTL_TX:
-               MII_REG_BITS_OFF(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs);
-               MII_REG_BITS_ON(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs);
-               break;
-
-       case FLOW_CNTL_RX:
-               MII_REG_BITS_ON(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs);
-               MII_REG_BITS_ON(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs);
-               break;
-
-       case FLOW_CNTL_TX_RX:
-               MII_REG_BITS_ON(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs);
-               MII_REG_BITS_ON(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs);
-               break;
-
-       case FLOW_CNTL_DISABLE:
-               MII_REG_BITS_OFF(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs);
-               MII_REG_BITS_OFF(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs);
-               break;
-       default:
-               break;
-       }
-}
-
-/**
- *     velocity_set_media_mode         -       set media mode
- *     @mii_status: old MII link state
- *
- *     Check the media link state and configure the flow control
- *     PHY and also velocity hardware setup accordingly. In particular
- *     we need to set up CD polling and frame bursting.
- */
-static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
-{
-       u32 curr_status;
-       struct mac_regs * regs = vptr->mac_regs;
-
-       vptr->mii_status = mii_check_media_mode(vptr->mac_regs);
-       curr_status = vptr->mii_status & (~VELOCITY_LINK_FAIL);
-
-       /* Set mii link status */
-       set_mii_flow_control(vptr);
-
-       /*
-          Check if new status is consisent with current status
-          if (((mii_status & curr_status) & VELOCITY_AUTONEG_ENABLE)
-          || (mii_status==curr_status)) {
-          vptr->mii_status=mii_check_media_mode(vptr->mac_regs);
-          vptr->mii_status=check_connection_type(vptr->mac_regs);
-          VELOCITY_PRT(MSG_LEVEL_INFO, "Velocity link no change\n");
-          return 0;
-          }
-        */
-
-       if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201) {
-               MII_REG_BITS_ON(AUXCR_MDPPS, MII_REG_AUXCR, vptr->mac_regs);
-       }
-
-       /*
-        *      If connection type is AUTO
-        */
-       if (mii_status & VELOCITY_AUTONEG_ENABLE) {
-               VELOCITY_PRT(MSG_LEVEL_INFO, "Velocity is AUTO mode\n");
-               /* clear force MAC mode bit */
-               BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, &regs->CHIPGCR);
-               /* set duplex mode of MAC according to duplex mode of MII */
-               MII_REG_BITS_ON(ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10, MII_REG_ANAR, vptr->mac_regs);
-               MII_REG_BITS_ON(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs);
-               MII_REG_BITS_ON(BMCR_SPEED1G, MII_REG_BMCR, vptr->mac_regs);
-
-               /* enable AUTO-NEGO mode */
-               mii_set_auto_on(vptr);
-       } else {
-               u16 ANAR;
-               u8 CHIPGCR;
-
-               /*
-                * 1. if it's 3119, disable frame bursting in halfduplex mode
-                *    and enable it in fullduplex mode
-                * 2. set correct MII/GMII and half/full duplex mode in CHIPGCR
-                * 3. only enable CD heart beat counter in 10HD mode
-                */
-
-               /* set force MAC mode bit */
-               BYTE_REG_BITS_ON(CHIPGCR_FCMODE, &regs->CHIPGCR);
-
-               CHIPGCR = readb(&regs->CHIPGCR);
-               CHIPGCR &= ~CHIPGCR_FCGMII;
-
-               if (mii_status & VELOCITY_DUPLEX_FULL) {
-                       CHIPGCR |= CHIPGCR_FCFDX;
-                       writeb(CHIPGCR, &regs->CHIPGCR);
-                       VELOCITY_PRT(MSG_LEVEL_INFO, "set Velocity to forced full mode\n");
-                       if (vptr->rev_id < REV_ID_VT3216_A0)
-                               BYTE_REG_BITS_OFF(TCR_TB2BDIS, &regs->TCR);
-               } else {
-                       CHIPGCR &= ~CHIPGCR_FCFDX;
-                       VELOCITY_PRT(MSG_LEVEL_INFO, "set Velocity to forced half mode\n");
-                       writeb(CHIPGCR, &regs->CHIPGCR);
-                       if (vptr->rev_id < REV_ID_VT3216_A0)
-                               BYTE_REG_BITS_ON(TCR_TB2BDIS, &regs->TCR);
-               }
-
-               MII_REG_BITS_OFF(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs);
-
-               if (!(mii_status & VELOCITY_DUPLEX_FULL) && (mii_status & VELOCITY_SPEED_10)) {
-                       BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG);
-               } else {
-                       BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG);
-               }
-               /* MII_REG_BITS_OFF(BMCR_SPEED1G, MII_REG_BMCR, vptr->mac_regs); */
-               velocity_mii_read(vptr->mac_regs, MII_REG_ANAR, &ANAR);
-               ANAR &= (~(ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10));
-               if (mii_status & VELOCITY_SPEED_100) {
-                       if (mii_status & VELOCITY_DUPLEX_FULL)
-                               ANAR |= ANAR_TXFD;
-                       else
-                               ANAR |= ANAR_TX;
-               } else {
-                       if (mii_status & VELOCITY_DUPLEX_FULL)
-                               ANAR |= ANAR_10FD;
-                       else
-                               ANAR |= ANAR_10;
-               }
-               velocity_mii_write(vptr->mac_regs, MII_REG_ANAR, ANAR);
-               /* enable AUTO-NEGO mode */
-               mii_set_auto_on(vptr);
-               /* MII_REG_BITS_ON(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs); */
-       }
-       /* vptr->mii_status=mii_check_media_mode(vptr->mac_regs); */
-       /* vptr->mii_status=check_connection_type(vptr->mac_regs); */
-       return VELOCITY_LINK_CHANGE;
-}
-
-/**
- *     mii_check_media_mode    -       check media state
- *     @regs: velocity registers
- *
- *     Check the current MII status and determine the link status
- *     accordingly
- */
-static u32 mii_check_media_mode(struct mac_regs * regs)
-{
-       u32 status = 0;
-       u16 ANAR;
-
-       if (!MII_REG_BITS_IS_ON(BMSR_LNK, MII_REG_BMSR, regs))
-               status |= VELOCITY_LINK_FAIL;
-
-       if (MII_REG_BITS_IS_ON(G1000CR_1000FD, MII_REG_G1000CR, regs))
-               status |= VELOCITY_SPEED_1000 | VELOCITY_DUPLEX_FULL;
-       else if (MII_REG_BITS_IS_ON(G1000CR_1000, MII_REG_G1000CR, regs))
-               status |= (VELOCITY_SPEED_1000);
-       else {
-               velocity_mii_read(regs, MII_REG_ANAR, &ANAR);
-               if (ANAR & ANAR_TXFD)
-                       status |= (VELOCITY_SPEED_100 | VELOCITY_DUPLEX_FULL);
-               else if (ANAR & ANAR_TX)
-                       status |= VELOCITY_SPEED_100;
-               else if (ANAR & ANAR_10FD)
-                       status |= (VELOCITY_SPEED_10 | VELOCITY_DUPLEX_FULL);
-               else
-                       status |= (VELOCITY_SPEED_10);
-       }
-
-       if (MII_REG_BITS_IS_ON(BMCR_AUTO, MII_REG_BMCR, regs)) {
-               velocity_mii_read(regs, MII_REG_ANAR, &ANAR);
-               if ((ANAR & (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10))
-                   == (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)) {
-                       if (MII_REG_BITS_IS_ON(G1000CR_1000 | G1000CR_1000FD, MII_REG_G1000CR, regs))
-                               status |= VELOCITY_AUTONEG_ENABLE;
-               }
-       }
-
-       return status;
-}
-
-static u32 check_connection_type(struct mac_regs * regs)
-{
-       u32 status = 0;
-       u8 PHYSR0;
-       u16 ANAR;
-       PHYSR0 = readb(&regs->PHYSR0);
-
-       /*
-          if (!(PHYSR0 & PHYSR0_LINKGD))
-          status|=VELOCITY_LINK_FAIL;
-        */
-
-       if (PHYSR0 & PHYSR0_FDPX)
-               status |= VELOCITY_DUPLEX_FULL;
-
-       if (PHYSR0 & PHYSR0_SPDG)
-               status |= VELOCITY_SPEED_1000;
-       if (PHYSR0 & PHYSR0_SPD10)
-               status |= VELOCITY_SPEED_10;
-       else
-               status |= VELOCITY_SPEED_100;
-
-       if (MII_REG_BITS_IS_ON(BMCR_AUTO, MII_REG_BMCR, regs)) {
-               velocity_mii_read(regs, MII_REG_ANAR, &ANAR);
-               if ((ANAR & (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10))
-                   == (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)) {
-                       if (MII_REG_BITS_IS_ON(G1000CR_1000 | G1000CR_1000FD, MII_REG_G1000CR, regs))
-                               status |= VELOCITY_AUTONEG_ENABLE;
-               }
-       }
-
-       return status;
-}
-
-/**
- *     enable_flow_control_ability     -       flow control
- *     @vptr: veloity to configure
- *
- *     Set up flow control according to the flow control options
- *     determined by the eeprom/configuration.
- */
-
-static void enable_flow_control_ability(struct velocity_info *vptr)
-{
-
-       struct mac_regs * regs = vptr->mac_regs;
-
-       switch (vptr->options.flow_cntl) {
-
-       case FLOW_CNTL_DEFAULT:
-               if (BYTE_REG_BITS_IS_ON(PHYSR0_RXFLC, &regs->PHYSR0))
-                       writel(CR0_FDXRFCEN, &regs->CR0Set);
-               else
-                       writel(CR0_FDXRFCEN, &regs->CR0Clr);
-
-               if (BYTE_REG_BITS_IS_ON(PHYSR0_TXFLC, &regs->PHYSR0))
-                       writel(CR0_FDXTFCEN, &regs->CR0Set);
-               else
-                       writel(CR0_FDXTFCEN, &regs->CR0Clr);
-               break;
-
-       case FLOW_CNTL_TX:
-               writel(CR0_FDXTFCEN, &regs->CR0Set);
-               writel(CR0_FDXRFCEN, &regs->CR0Clr);
-               break;
-
-       case FLOW_CNTL_RX:
-               writel(CR0_FDXRFCEN, &regs->CR0Set);
-               writel(CR0_FDXTFCEN, &regs->CR0Clr);
-               break;
-
-       case FLOW_CNTL_TX_RX:
-               writel(CR0_FDXTFCEN, &regs->CR0Set);
-               writel(CR0_FDXRFCEN, &regs->CR0Set);
-               break;
-
-       case FLOW_CNTL_DISABLE:
-               writel(CR0_FDXRFCEN, &regs->CR0Clr);
-               writel(CR0_FDXTFCEN, &regs->CR0Clr);
-               break;
-
-       default:
-               break;
-       }
-
-}
-
-
-/**
- *     velocity_ethtool_up     -       pre hook for ethtool
- *     @dev: network device
- *
- *     Called before an ethtool operation. We need to make sure the
- *     chip is out of D3 state before we poke at it.
- */
-static int velocity_ethtool_up(struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-       if(!netif_running(dev))
-               pci_set_power_state(vptr->pdev, 0);
-       return 0;
-}      
-
-/**
- *     velocity_ethtool_down   -       post hook for ethtool
- *     @dev: network device
- *
- *     Called after an ethtool operation. Restore the chip back to D3
- *     state if it isn't running.
- */
-static void velocity_ethtool_down(struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-       if(!netif_running(dev))
-               pci_set_power_state(vptr->pdev, 3);
-}
-
-static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-       struct velocity_info *vptr = dev->priv;
-       struct mac_regs * regs = vptr->mac_regs;
-       u32 status;
-       status = check_connection_type(vptr->mac_regs);
-
-       cmd->supported = SUPPORTED_TP | SUPPORTED_Autoneg | SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full;
-       if (status & VELOCITY_SPEED_100)
-               cmd->speed = SPEED_100;
-       else
-               cmd->speed = SPEED_10;
-       cmd->autoneg = (status & VELOCITY_AUTONEG_ENABLE) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
-       cmd->port = PORT_TP;
-       cmd->transceiver = XCVR_INTERNAL;
-       cmd->phy_address = readb(&regs->MIIADR) & 0x1F;
-
-       if (status & VELOCITY_DUPLEX_FULL)
-               cmd->duplex = DUPLEX_FULL;
-       else
-               cmd->duplex = DUPLEX_HALF;
-               
-       return 0;
-}
-
-static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-       struct velocity_info *vptr = dev->priv;
-       u32 curr_status;
-       u32 new_status = 0;
-       int ret = 0;
-       
-       curr_status = check_connection_type(vptr->mac_regs);
-       curr_status &= (~VELOCITY_LINK_FAIL);
-
-       new_status |= ((cmd->autoneg) ? VELOCITY_AUTONEG_ENABLE : 0);
-       new_status |= ((cmd->speed == SPEED_100) ? VELOCITY_SPEED_100 : 0);
-       new_status |= ((cmd->speed == SPEED_10) ? VELOCITY_SPEED_10 : 0);
-       new_status |= ((cmd->duplex == DUPLEX_FULL) ? VELOCITY_DUPLEX_FULL : 0);
-
-       if ((new_status & VELOCITY_AUTONEG_ENABLE) && (new_status != (curr_status | VELOCITY_AUTONEG_ENABLE)))
-               ret = -EINVAL;
-       else
-               velocity_set_media_mode(vptr, new_status);
-
-       return ret;
-}
-
-static u32 velocity_get_link(struct net_device *dev)
-{
-       struct velocity_info *vptr = dev->priv;
-       struct mac_regs * regs = vptr->mac_regs;
-       return BYTE_REG_BITS_IS_ON(PHYSR0_LINKGD, &regs->PHYSR0)  ? 0 : 1;
-}
-
-static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
-{
-       struct velocity_info *vptr = dev->priv;
-       strcpy(info->driver, VELOCITY_NAME);
-       strcpy(info->version, VELOCITY_VERSION);
-       strcpy(info->bus_info, vptr->pdev->slot_name);
-}
-
-static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
-{
-       struct velocity_info *vptr = dev->priv;
-       wol->supported = WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_ARP;
-       wol->wolopts |= WAKE_MAGIC;
-       /*
-          if (vptr->wol_opts & VELOCITY_WOL_PHY)
-                  wol.wolopts|=WAKE_PHY;
-                        */
-       if (vptr->wol_opts & VELOCITY_WOL_UCAST)
-               wol->wolopts |= WAKE_UCAST;
-       if (vptr->wol_opts & VELOCITY_WOL_ARP)
-               wol->wolopts |= WAKE_ARP;
-       memcpy(&wol->sopass, vptr->wol_passwd, 6);
-}
-
-static int velocity_ethtool_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
-{
-       struct velocity_info *vptr = dev->priv;
-
-       if (!(wol->wolopts & (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_ARP)))
-               return -EFAULT;
-       vptr->wol_opts = VELOCITY_WOL_MAGIC;
-
-       /*
-          if (wol.wolopts & WAKE_PHY) {
-          vptr->wol_opts|=VELOCITY_WOL_PHY;
-          vptr->flags |=VELOCITY_FLAGS_WOL_ENABLED;
-          }
-        */
-
-       if (wol->wolopts & WAKE_MAGIC) {
-               vptr->wol_opts |= VELOCITY_WOL_MAGIC;
-               vptr->flags |= VELOCITY_FLAGS_WOL_ENABLED;
-       }
-       if (wol->wolopts & WAKE_UCAST) {
-               vptr->wol_opts |= VELOCITY_WOL_UCAST;
-               vptr->flags |= VELOCITY_FLAGS_WOL_ENABLED;
-       }
-       if (wol->wolopts & WAKE_ARP) {
-               vptr->wol_opts |= VELOCITY_WOL_ARP;
-               vptr->flags |= VELOCITY_FLAGS_WOL_ENABLED;
-       }
-       memcpy(vptr->wol_passwd, wol->sopass, 6);
-       return 0;
-}
-
-static u32 velocity_get_msglevel(struct net_device *dev)
-{
-       return msglevel;
-}
-
-static void velocity_set_msglevel(struct net_device *dev, u32 value)
-{
-        msglevel = value;
-}
-
-static struct ethtool_ops velocity_ethtool_ops = {
-       .get_settings   =       velocity_get_settings,
-       .set_settings   =       velocity_set_settings,
-       .get_drvinfo    =       velocity_get_drvinfo,
-       .get_wol        =       velocity_ethtool_get_wol,
-       .set_wol        =       velocity_ethtool_set_wol,
-       .get_msglevel   =       velocity_get_msglevel,
-       .set_msglevel   =       velocity_set_msglevel,
-       .get_link       =       velocity_get_link,
-       .begin          =       velocity_ethtool_up,
-       .complete       =       velocity_ethtool_down
-};
-
-/**
- *     velocity_mii_ioctl              -       MII ioctl handler
- *     @dev: network device
- *     @ifr: the ifreq block for the ioctl
- *     @cmd: the command
- *
- *     Process MII requests made via ioctl from the network layer. These
- *     are used by tools like kudzu to interrogate the link state of the
- *     hardware
- */
-static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
-       struct velocity_info *vptr = dev->priv;
-       struct mac_regs * regs = vptr->mac_regs;
-       unsigned long flags;
-       struct mii_ioctl_data *miidata = if_mii(ifr);
-       int err;
-       
-       switch (cmd) {
-       case SIOCGMIIPHY:
-               miidata->phy_id = readb(&regs->MIIADR) & 0x1f;
-               break;
-       case SIOCGMIIREG:
-               if (!capable(CAP_NET_ADMIN))
-                       return -EPERM;
-               if(velocity_mii_read(vptr->mac_regs, miidata->reg_num & 0x1f, &(miidata->val_out)) < 0)
-                       return -ETIMEDOUT;
-               break;
-       case SIOCSMIIREG:
-               if (!capable(CAP_NET_ADMIN))
-                       return -EPERM;
-               spin_lock_irqsave(&vptr->lock, flags);
-               err = velocity_mii_write(vptr->mac_regs, miidata->reg_num & 0x1f, miidata->val_in);
-               spin_unlock_irqrestore(&vptr->lock, flags);
-               check_connection_type(vptr->mac_regs);
-               if(err)
-                       return err;
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-       return 0;
-}
-
-#ifdef CONFIG_PM
-
-/**
- *     velocity_save_context   -       save registers
- *     @vptr: velocity 
- *     @context: buffer for stored context
- *
- *     Retrieve the current configuration from the velocity hardware
- *     and stash it in the context structure, for use by the context
- *     restore functions. This allows us to save things we need across
- *     power down states
- */
-static void velocity_save_context(struct velocity_info *vptr, struct velocity_context * context)
-{
-       struct mac_regs * regs = vptr->mac_regs;
-       u16 i;
-       u8 *ptr = (u8 *)regs;
-
-       for (i = MAC_REG_PAR; i < MAC_REG_CR0_CLR; i += 4)
-               *((u32 *) (context->mac_reg + i)) = readl(ptr + i);
-
-       for (i = MAC_REG_MAR; i < MAC_REG_TDCSR_CLR; i += 4)
-               *((u32 *) (context->mac_reg + i)) = readl(ptr + i);
-
-       for (i = MAC_REG_RDBASE_LO; i < MAC_REG_FIFO_TEST0; i += 4)
-               *((u32 *) (context->mac_reg + i)) = readl(ptr + i);
-
-}
-
-/**
- *     velocity_restore_context        -       restore registers
- *     @vptr: velocity 
- *     @context: buffer for stored context
- *
- *     Reload the register configuration from the velocity context 
- *     created by velocity_save_context.
- */
-static void velocity_restore_context(struct velocity_info *vptr, struct velocity_context *context)
-{
-       struct mac_regs * regs = vptr->mac_regs;
-       int i;
-       u8 *ptr = (u8 *)regs;
-
-       for (i = MAC_REG_PAR; i < MAC_REG_CR0_SET; i += 4) {
-               writel(*((u32 *) (context->mac_reg + i)), ptr + i);
-       }
-
-       /* Just skip cr0 */
-       for (i = MAC_REG_CR1_SET; i < MAC_REG_CR0_CLR; i++) {
-               /* Clear */
-               writeb(~(*((u8 *) (context->mac_reg + i))), ptr + i + 4);
-               /* Set */
-               writeb(*((u8 *) (context->mac_reg + i)), ptr + i);
-       }
-
-       for (i = MAC_REG_MAR; i < MAC_REG_IMR; i += 4) {
-               writel(*((u32 *) (context->mac_reg + i)), ptr + i);
-       }
-
-       for (i = MAC_REG_RDBASE_LO; i < MAC_REG_FIFO_TEST0; i += 4) {
-               writel(*((u32 *) (context->mac_reg + i)), ptr + i);
-       }
-
-       for (i = MAC_REG_TDCSR_SET; i <= MAC_REG_RDCSR_SET; i++) {
-               writeb(*((u8 *) (context->mac_reg + i)), ptr + i);
-       }
-
-}
-
-static int velocity_suspend(struct pci_dev *pdev, u32 state)
-{
-       struct velocity_info *vptr = pci_get_drvdata(pdev);
-       unsigned long flags;
-       
-       if(!netif_running(vptr->dev))
-               return 0;
-               
-       netif_device_detach(vptr->dev);
-       
-       spin_lock_irqsave(&vptr->lock, flags);
-       pci_save_state(pdev, vptr->pci_state);
-#ifdef ETHTOOL_GWOL
-       if (vptr->flags & VELOCITY_FLAGS_WOL_ENABLED) {
-               velocity_get_ip(vptr);
-               velocity_save_context(vptr, &vptr->context);
-               velocity_shutdown(vptr);
-               velocity_set_wol(vptr);
-               pci_enable_wake(pdev, 3, 1);
-               pci_set_power_state(pdev, 3);
-       } else {
-               velocity_save_context(vptr, &vptr->context);
-               velocity_shutdown(vptr);
-               pci_disable_device(pdev);
-               pci_set_power_state(pdev, state);
-       }
-#else
-       pci_set_power_state(pdev, state);
-#endif
-       spin_unlock_irqrestore(&vptr->lock, flags);
-       return 0;
-}
-
-static int velocity_resume(struct pci_dev *pdev)
-{
-       struct velocity_info *vptr = pci_get_drvdata(pdev);
-       unsigned long flags;
-       int i;
-       
-       if(!netif_running(vptr->dev))
-               return 0;
-               
-       pci_set_power_state(pdev, 0);
-       pci_enable_wake(pdev, 0, 0);
-       pci_restore_state(pdev, vptr->pci_state);
-
-       mac_wol_reset(vptr->mac_regs);
-
-       spin_lock_irqsave(&vptr->lock, flags);
-       velocity_restore_context(vptr, &vptr->context);
-       velocity_init_registers(vptr, VELOCITY_INIT_WOL);
-       mac_disable_int(vptr->mac_regs);
-
-       velocity_tx_srv(vptr, 0);
-
-       for (i = 0; i < vptr->num_txq; i++) {
-               if (vptr->td_used[i]) {
-                       mac_tx_queue_wake(vptr->mac_regs, i);
-               }
-       }
-
-       mac_enable_int(vptr->mac_regs);
-       spin_unlock_irqrestore(&vptr->lock, flags);
-       netif_device_attach(vptr->dev);
-
-       return 0;
-}
-
-static int velocity_netdev_event(struct notifier_block *nb, unsigned long notification, void *ptr)
-{
-       struct in_ifaddr *ifa = (struct in_ifaddr *) ptr;
-       struct net_device *dev;
-       struct velocity_info *vptr;
-
-       if (ifa) {
-               dev = ifa->ifa_dev->dev;
-               vptr = dev->priv;
-               velocity_get_ip(vptr);
-       }
-       return NOTIFY_DONE;
-}
-#endif
-
-/*
- * Purpose: Functions to set WOL.
- */
-
-const static unsigned short crc16_tab[256] = {
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-
-static u32 mask_pattern[2][4] = {
-       {0x00203000, 0x000003C0, 0x00000000, 0x0000000},        /* ARP          */
-       {0xfffff000, 0xffffffff, 0xffffffff, 0x000ffff}         /* Magic Packet */ 
-};
-
-/**
- *     ether_crc16     -       compute ethernet CRC
- *     @len: buffer length
- *     @cp: buffer
- *     @crc16: initial CRC
- *
- *     Compute a CRC value for a block of data. 
- *     FIXME: can we use generic functions ?
- */
-static u16 ether_crc16(int len, u8 * cp, u16 crc16)
-{
-       while (len--)
-               crc16 = (crc16 >> 8) ^ crc16_tab[(crc16 ^ *cp++) & 0xff];
-       return (crc16);
-}
-
-/**
- *     bit_reverse             -       16bit reverse
- *     @data: 16bit data t reverse
- *
- *     Reverse the order of a 16bit value and return the reversed bits
- */
-static u16 bit_reverse(u16 data)
-{
-       u32 new = 0x00000000;
-       int ii;
-
-
-       for (ii = 0; ii < 16; ii++) {
-               new |= ((u32) (data & 1) << (31 - ii));
-               data >>= 1;
-       }
-
-       return (u16) (new >> 16);
-}
-
-/**
- *     wol_calc_crc            -       WOL CRC
- *     @pattern: data pattern
- *     @mask_pattern: mask
- *
- *     Compute the wake on lan crc hashes for the packet header
- *     we are interested in.
- */
-u16 wol_calc_crc(int size, u8 * pattern, u8 *mask_pattern)
-{
-       u16 crc = 0xFFFF;
-       u8 mask;
-       int i, j;
-
-       for (i = 0; i < size; i++) {
-               mask = mask_pattern[i];
-
-               /* Skip this loop if the mask equals to zero */
-               if (mask == 0x00)
-                       continue;
-
-               for (j = 0; j < 8; j++) {
-                       if ((mask & 0x01) == 0) {
-                               mask >>= 1;
-                               continue;
-                       }
-                       mask >>= 1;
-                       crc = ether_crc16(1, &(pattern[i * 8 + j]), crc);
-               }
-       }
-       /*      Finally, invert the result once to get the correct data */
-       crc = ~crc;
-       return bit_reverse(crc);
-}
-
-/**
- *     velocity_set_wol        -       set up for wake on lan
- *     @vptr: velocity to set WOL status on
- *
- *     Set a card up for wake on lan either by unicast or by
- *     ARP packet.
- *
- *     FIXME: check static buffer is safe here
- */
-static int velocity_set_wol(struct velocity_info *vptr)
-{
-       struct mac_regs * regs = vptr->mac_regs;
-       static u8 buf[256];
-       int i;
-
-       writew(0xFFFF, &regs->WOLCRClr);
-       writeb(WOLCFG_SAB | WOLCFG_SAM, &regs->WOLCFGSet);
-       writew(WOLCR_MAGIC_EN, &regs->WOLCRSet);
-
-       /*
-          if (vptr->wol_opts & VELOCITY_WOL_PHY)
-          writew((WOLCR_LINKON_EN|WOLCR_LINKOFF_EN), &regs->WOLCRSet);
-        */
-
-       if (vptr->wol_opts & VELOCITY_WOL_UCAST) {
-               writew(WOLCR_UNICAST_EN, &regs->WOLCRSet);
-       }
-
-       if (vptr->wol_opts & VELOCITY_WOL_ARP) {
-               struct arp_packet *arp = (struct arp_packet *) buf;
-               u16 crc;
-               memset(buf, 0, sizeof(struct arp_packet) + 7);
-
-               for (i = 0; i < 4; i++)
-                       writel(mask_pattern[0][i], &regs->ByteMask[0][i]);
-
-               arp->type = htons(ETH_P_ARP);
-               arp->ar_op = htons(1);
-
-               memcpy(arp->ar_tip, vptr->ip_addr, 4);
-
-               crc = wol_calc_crc((sizeof(struct arp_packet) + 7) / 8, buf, (u8 *) & mask_pattern[0][0]);
-
-               writew(crc, &regs->PatternCRC[0]);
-               writew(WOLCR_ARP_EN, &regs->WOLCRSet);
-       }
-
-       BYTE_REG_BITS_ON(PWCFG_WOLTYPE, &regs->PWCFGSet);
-       BYTE_REG_BITS_ON(PWCFG_LEGACY_WOLEN, &regs->PWCFGSet);
-
-       writew(0x0FFF, &regs->WOLSRClr);
-
-       if (vptr->mii_status & VELOCITY_AUTONEG_ENABLE) {
-               if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201)
-                       MII_REG_BITS_ON(AUXCR_MDPPS, MII_REG_AUXCR, vptr->mac_regs);
-
-               MII_REG_BITS_OFF(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs);
-       }
-
-       if (vptr->mii_status & VELOCITY_SPEED_1000)
-               MII_REG_BITS_ON(BMCR_REAUTO, MII_REG_BMCR, vptr->mac_regs);
-
-       BYTE_REG_BITS_ON(CHIPGCR_FCMODE, &regs->CHIPGCR);
-
-       {
-               u8 GCR;
-               GCR = readb(&regs->CHIPGCR);
-               GCR = (GCR & ~CHIPGCR_FCGMII) | CHIPGCR_FCFDX;
-               writeb(GCR, &regs->CHIPGCR);
-       }
-
-       BYTE_REG_BITS_OFF(ISR_PWEI, &regs->ISR);
-       /* Turn on SWPTAG just before entering power mode */
-       BYTE_REG_BITS_ON(STICKHW_SWPTAG, &regs->STICKHW);
-       /* Go to bed ..... */
-       BYTE_REG_BITS_ON((STICKHW_DS1 | STICKHW_DS0), &regs->STICKHW);
-
-       return 0;
-}
-
diff --git a/drivers/net/wan/comx-hw-comx.c b/drivers/net/wan/comx-hw-comx.c
deleted file mode 100644 (file)
index a62fe55..0000000
+++ /dev/null
@@ -1,1450 +0,0 @@
-/*
- * Hardware-level driver for the COMX and HICOMX cards
- * for Linux kernel 2.2.X
- *
- * Original authors:  Arpad Bakay <bakay.arpad@synergon.hu>,
- *                    Peter Bajan <bajan.peter@synergon.hu>,
- * Rewritten by: Tivadar Szemethy <tiv@itc.hu>
- * Currently maintained by: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-2000 ITConsult-Pro Co. <info@itc.hu>
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 0.86
- * Daniele Bellucci         <bellucda@tiscali.it>   - 0.87
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.80 (99/06/11):
- *             - port back to kernel, add support builtin driver 
- *             - cleaned up the source code a bit
- *
- * Version 0.81 (99/06/22):
- *             - cleaned up the board load functions, no more long reset
- *               timeouts
- *             - lower modem lines on close
- *             - some interrupt handling fixes
- *
- * Version 0.82 (99/08/24):
- *             - fix multiple board support
- *
- * Version 0.83 (99/11/30):
- *             - interrupt handling and locking fixes during initalization
- *             - really fix multiple board support
- * 
- * Version 0.84 (99/12/02):
- *             - some workarounds for problematic hardware/firmware
- *
- * Version 0.85 (00/01/14):
- *             - some additional workarounds :/
- *             - printk cleanups
- * Version 0.86 (00/08/15):
- *             - resource release on failure at COMX_init
- *
- * Version 0.87 (03/07/09)
- *              - audit copy_from_user in comxhw_write_proc
- */
-
-#define VERSION "0.87"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
-#include "comx.h"
-#include "comxhw.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>, Tivadar Szemethy <tiv@itc.hu>, Arpad Bakay");
-MODULE_DESCRIPTION("Hardware-level driver for the COMX and HICOMX adapters\n");
-MODULE_LICENSE("GPL");
-
-#define        COMX_readw(dev, offset) (readw(dev->mem_start + offset + \
-       (unsigned int)(((struct comx_privdata *)\
-       ((struct comx_channel *)dev->priv)->HW_privdata)->channel) \
-       * COMX_CHANNEL_OFFSET))
-
-#define COMX_WRITE(dev, offset, value) (writew(value, dev->mem_start + offset \
-       + (unsigned int)(((struct comx_privdata *) \
-       ((struct comx_channel *)dev->priv)->HW_privdata)->channel) \
-       * COMX_CHANNEL_OFFSET))
-
-#define COMX_CMD(dev, cmd)     (COMX_WRITE(dev, OFF_A_L2_CMD, cmd))
-
-struct comx_firmware {
-       int     len;
-       unsigned char *data;
-};
-
-struct comx_privdata {
-       struct comx_firmware *firmware;
-       u16     clock;
-       char    channel;                // channel no.
-       int     memory_size;
-       short   io_extent;
-       u_long  histogram[5];
-};
-
-static struct net_device *memory_used[(COMX_MEM_MAX - COMX_MEM_MIN) / 0x10000];
-extern struct comx_hardware hicomx_hw;
-extern struct comx_hardware comx_hw;
-extern struct comx_hardware cmx_hw;
-
-static irqreturn_t COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-static void COMX_board_on(struct net_device *dev)
-{
-       outb_p( (byte) (((dev->mem_start & 0xf0000) >> 16) | 
-           COMX_ENABLE_BOARD_IT | COMX_ENABLE_BOARD_MEM), dev->base_addr);
-}
-
-static void COMX_board_off(struct net_device *dev)
-{
-       outb_p( (byte) (((dev->mem_start & 0xf0000) >> 16) | 
-          COMX_ENABLE_BOARD_IT), dev->base_addr);
-}
-
-static void HICOMX_board_on(struct net_device *dev)
-{
-       outb_p( (byte) (((dev->mem_start & 0xf0000) >> 12) | 
-          HICOMX_ENABLE_BOARD_MEM), dev->base_addr);
-}
-
-static void HICOMX_board_off(struct net_device *dev)
-{
-       outb_p( (byte) (((dev->mem_start & 0xf0000) >> 12) | 
-          HICOMX_DISABLE_BOARD_MEM), dev->base_addr);
-}
-
-static void COMX_set_clock(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-
-       COMX_WRITE(dev, OFF_A_L1_CLKINI, hw->clock);
-}
-
-static struct net_device *COMX_access_board(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct net_device *ret;
-       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
-       unsigned long flags;
-
-
-       save_flags(flags); cli();
-       
-       ret = memory_used[mempos];
-
-       if(ret == dev) {
-               goto out;
-       }
-
-       memory_used[mempos] = dev;
-
-       if (!ch->twin || ret != ch->twin) {
-               if (ret) ((struct comx_channel *)ret->priv)->HW_board_off(ret);
-               ch->HW_board_on(dev);
-       }
-out:
-       restore_flags(flags);
-       return ret;
-}
-
-static void COMX_release_board(struct net_device *dev, struct net_device *savep)
-{
-       unsigned long flags;
-       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
-       struct comx_channel *ch = dev->priv;
-
-       save_flags(flags); cli();
-
-       if (memory_used[mempos] == savep) {
-               goto out;
-       }
-
-       memory_used[mempos] = savep;
-       if (!ch->twin || ch->twin != savep) {
-               ch->HW_board_off(dev);
-               if (savep) ((struct comx_channel*)savep->priv)->HW_board_on(savep);
-       }
-out:
-       restore_flags(flags);
-}
-
-static int COMX_txe(struct net_device *dev) 
-{
-       struct net_device *savep;
-       struct comx_channel *ch = dev->priv;
-       int rc = 0;
-
-       savep = ch->HW_access_board(dev);
-       if (COMX_readw(dev,OFF_A_L2_LINKUP) == LINKUP_READY) {
-               rc = COMX_readw(dev,OFF_A_L2_TxEMPTY);
-       } 
-       ch->HW_release_board(dev,savep);
-       if(rc==0xffff) {
-               printk(KERN_ERR "%s, OFF_A_L2_TxEMPTY is %d\n",dev->name, rc);
-       }
-       return rc;
-}
-
-static int COMX_send_packet(struct net_device *dev, struct sk_buff *skb)
-{
-       struct net_device *savep;
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       int ret = FRAME_DROPPED;
-       word tmp;
-
-       savep = ch->HW_access_board(dev);       
-
-       if (ch->debug_flags & DEBUG_HW_TX) {
-               comx_debug_bytes(dev, skb->data, skb->len,"COMX_send packet");
-       }
-
-       if (skb->len > COMX_MAX_TX_SIZE) {
-               ret=FRAME_DROPPED;
-               goto out;
-       }
-
-       tmp=COMX_readw(dev, OFF_A_L2_TxEMPTY);
-       if ((ch->line_status & LINE_UP) && tmp==1) {
-               int lensave = skb->len;
-               int dest = COMX_readw(dev, OFF_A_L2_TxBUFP);
-               word *data = (word *)skb->data;
-
-               if(dest==0xffff) {
-                       printk(KERN_ERR "%s: OFF_A_L2_TxBUFP is %d\n", dev->name, dest);
-                       ret=FRAME_DROPPED;
-                       goto out;
-               }
-                                       
-               writew((unsigned short)skb->len, dev->mem_start + dest);
-               dest += 2;
-               while (skb->len > 1) {
-                       writew(*data++, dev->mem_start + dest);
-                       dest += 2; skb->len -= 2;
-               }
-               if (skb->len == 1) {
-                       writew(*((byte *)data), dev->mem_start + dest);
-               }
-               writew(0, dev->mem_start + (int)hw->channel * 
-                  COMX_CHANNEL_OFFSET + OFF_A_L2_TxEMPTY);
-               ch->stats.tx_packets++; 
-               ch->stats.tx_bytes += lensave; 
-               ret = FRAME_ACCEPTED;
-       } else {
-               ch->stats.tx_dropped++;
-               printk(KERN_INFO "%s: frame dropped\n",dev->name);
-               if(tmp) {
-                       printk(KERN_ERR "%s: OFF_A_L2_TxEMPTY is %d\n",dev->name,tmp);
-               }
-       }
-       
-out:
-       ch->HW_release_board(dev, savep);
-       dev_kfree_skb(skb);
-       return ret;
-}
-
-static inline int comx_read_buffer(struct net_device *dev) 
-{
-       struct comx_channel *ch = dev->priv;
-       word rbuf_offs;
-       struct sk_buff *skb;
-       word len;
-       int i=0;
-       word *writeptr;
-
-       i = 0;
-       rbuf_offs = COMX_readw(dev, OFF_A_L2_RxBUFP);
-       if(rbuf_offs == 0xffff) {
-               printk(KERN_ERR "%s: OFF_A_L2_RxBUFP is %d\n",dev->name,rbuf_offs);
-               return 0;
-       }
-       len = readw(dev->mem_start + rbuf_offs);
-       if(len > COMX_MAX_RX_SIZE) {
-               printk(KERN_ERR "%s: packet length is %d\n",dev->name,len);
-               return 0;
-       }
-       if ((skb = dev_alloc_skb(len + 16)) == NULL) {
-               ch->stats.rx_dropped++;
-               COMX_WRITE(dev, OFF_A_L2_DAV, 0);
-               return 0;
-       }
-       rbuf_offs += 2;
-       skb_reserve(skb, 16);
-       skb_put(skb, len);
-       skb->dev = dev;
-       writeptr = (word *)skb->data;
-       while (i < len) {
-               *writeptr++ = readw(dev->mem_start + rbuf_offs);
-               rbuf_offs += 2; 
-               i += 2;
-       }
-       COMX_WRITE(dev, OFF_A_L2_DAV, 0);
-       ch->stats.rx_packets++;
-       ch->stats.rx_bytes += len;
-       if (ch->debug_flags & DEBUG_HW_RX) {
-               comx_debug_skb(dev, skb, "COMX_interrupt receiving");
-       }
-       ch->LINE_rx(dev, skb);
-       return 1;
-}
-
-static inline char comx_line_change(struct net_device *dev, char linestat)
-{
-       struct comx_channel *ch=dev->priv;
-       char idle=1;
-       
-       
-       if (linestat & LINE_UP) { /* Vonal fol */
-               if (ch->lineup_delay) {
-                       if (!test_and_set_bit(0, &ch->lineup_pending)) {
-                               ch->lineup_timer.function = comx_lineup_func;
-                               ch->lineup_timer.data = (unsigned long)dev;
-                               ch->lineup_timer.expires = jiffies +
-                                       HZ*ch->lineup_delay;
-                               add_timer(&ch->lineup_timer);
-                               idle=0;
-                       }
-               } else {
-                       idle=0;
-                       ch->LINE_status(dev, ch->line_status |= LINE_UP);
-               }
-       } else { /* Vonal le */
-               idle=0;
-               if (test_and_clear_bit(0, &ch->lineup_pending)) {
-                       del_timer(&ch->lineup_timer);
-               } else {
-                       ch->line_status &= ~LINE_UP;
-                       if (ch->LINE_status) {
-                               ch->LINE_status(dev, ch->line_status);
-                       }
-               }
-       }
-       return idle;
-}
-
-
-
-static irqreturn_t COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct net_device *dev = dev_id;
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       struct net_device *interrupted;
-       unsigned long jiffs;
-       char idle = 0;
-       int count = 0;
-       word tmp;
-
-       if (dev == NULL) {
-               printk(KERN_ERR "COMX_interrupt: irq %d for unknown device\n", irq);
-               return IRQ_NONE;
-       }
-
-       jiffs = jiffies;
-
-       interrupted = ch->HW_access_board(dev);
-
-       while (!idle && count < 5000) {
-               char channel = 0;
-               idle = 1;
-
-               while (channel < 2) {
-                       char linestat = 0;
-                       char buffers_emptied = 0;
-
-                       if (channel == 1) {
-                               if (ch->twin) {
-                                       dev = ch->twin;
-                                       ch = dev->priv;
-                                       hw = ch->HW_privdata;
-                               } else {
-                                       break;
-                               }
-                       } else {
-                               COMX_WRITE(dev, OFF_A_L1_REPENA, 
-                                   COMX_readw(dev, OFF_A_L1_REPENA) & 0xFF00);
-                       }
-                       channel++;
-
-                       if ((ch->init_status & (HW_OPEN | LINE_OPEN)) != 
-                          (HW_OPEN | LINE_OPEN)) {
-                               continue;
-                       }
-       
-                       /* Collect stats */
-                       tmp = COMX_readw(dev, OFF_A_L1_ABOREC);
-                       COMX_WRITE(dev, OFF_A_L1_ABOREC, 0);
-                       if(tmp==0xffff) {
-                               printk(KERN_ERR "%s: OFF_A_L1_ABOREC is %d\n",dev->name,tmp);
-                               break;
-                       } else {
-                               ch->stats.rx_missed_errors += (tmp >> 8) & 0xff;
-                               ch->stats.rx_over_errors += tmp & 0xff;
-                       }
-                       tmp = COMX_readw(dev, OFF_A_L1_CRCREC);
-                       COMX_WRITE(dev, OFF_A_L1_CRCREC, 0);
-                       if(tmp==0xffff) {
-                               printk(KERN_ERR "%s: OFF_A_L1_CRCREC is %d\n",dev->name,tmp);
-                               break;
-                       } else {
-                               ch->stats.rx_crc_errors += (tmp >> 8) & 0xff;
-                               ch->stats.rx_missed_errors += tmp & 0xff;
-                       }
-                       
-                       if ((ch->line_status & LINE_UP) && ch->LINE_rx) {
-                               tmp=COMX_readw(dev, OFF_A_L2_DAV); 
-                               while (tmp==1) {
-                                       idle=0;
-                                       buffers_emptied+=comx_read_buffer(dev);
-                                       tmp=COMX_readw(dev, OFF_A_L2_DAV); 
-                               }
-                               if(tmp) {
-                                       printk(KERN_ERR "%s: OFF_A_L2_DAV is %d\n", dev->name, tmp);
-                                       break;
-                               }
-                       }
-
-                       tmp=COMX_readw(dev, OFF_A_L2_TxEMPTY);
-                       if (tmp==1 && ch->LINE_tx) {
-                               ch->LINE_tx(dev);
-                       } 
-                       if(tmp==0xffff) {
-                               printk(KERN_ERR "%s: OFF_A_L2_TxEMPTY is %d\n", dev->name, tmp);
-                               break;
-                       }
-
-                       if (COMX_readw(dev, OFF_A_L1_PBUFOVR) >> 8) {
-                               linestat &= ~LINE_UP;
-                       } else {
-                               linestat |= LINE_UP;
-                       }
-
-                       if ((linestat & LINE_UP) != (ch->line_status & LINE_UP)) {
-                               ch->stats.tx_carrier_errors++;
-                               idle &= comx_line_change(dev,linestat);
-                       }
-                               
-                       hw->histogram[(int)buffers_emptied]++;
-               }
-               count++;
-       }
-
-       if(count==5000) {
-               printk(KERN_WARNING "%s: interrupt stuck\n",dev->name);
-       }
-
-       ch->HW_release_board(dev, interrupted);
-       return IRQ_HANDLED;
-}
-
-static int COMX_open(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       struct proc_dir_entry *procfile = ch->procdir->subdir;
-       unsigned long jiffs;
-       int twin_open=0;
-       int retval;
-       struct net_device *savep;
-
-       if (!dev->base_addr || !dev->irq || !dev->mem_start) {
-               return -ENODEV;
-       }
-
-       if (ch->twin && (((struct comx_channel *)(ch->twin->priv))->init_status & HW_OPEN)) {
-               twin_open=1;
-       }
-
-       if (!twin_open) {
-               if (!request_region(dev->base_addr, hw->io_extent, dev->name)) {
-                       return -EAGAIN;
-               }
-               if (request_irq(dev->irq, COMX_interrupt, 0, dev->name, 
-                  (void *)dev)) {
-                       printk(KERN_ERR "comx-hw-comx: unable to obtain irq %d\n", dev->irq);
-                       release_region(dev->base_addr, hw->io_extent);
-                       return -EAGAIN;
-               }
-               ch->init_status |= IRQ_ALLOCATED;
-               if (!ch->HW_load_board || ch->HW_load_board(dev)) {
-                       ch->init_status &= ~IRQ_ALLOCATED;
-                       retval=-ENODEV;
-                       goto error;
-               }
-       }
-
-       savep = ch->HW_access_board(dev);
-       COMX_WRITE(dev, OFF_A_L2_LINKUP, 0);
-
-       if (ch->HW_set_clock) {
-               ch->HW_set_clock(dev);
-       }
-
-       COMX_CMD(dev, COMX_CMD_INIT); 
-       jiffs = jiffies;
-       while (COMX_readw(dev, OFF_A_L2_LINKUP) != 1 && time_before(jiffies, jiffs + HZ)) {
-               schedule_timeout(1);
-       }
-       
-       if (time_after_eq(jiffies, jiffs + HZ)) {
-               printk(KERN_ERR "%s: board timeout on INIT command\n", dev->name);
-               ch->HW_release_board(dev, savep);
-               retval=-EIO;
-               goto error;
-       }
-       udelay(1000);
-
-       COMX_CMD(dev, COMX_CMD_OPEN);
-
-       jiffs = jiffies;
-       while (COMX_readw(dev, OFF_A_L2_LINKUP) != 3 && time_before(jiffies, jiffs + HZ)) {
-               schedule_timeout(1);
-       }
-       
-       if (time_after_eq(jiffies, jiffs + HZ)) {
-               printk(KERN_ERR "%s: board timeout on OPEN command\n", dev->name);
-               ch->HW_release_board(dev, savep);
-               retval=-EIO;
-               goto error;
-       }
-       
-       ch->init_status |= HW_OPEN;
-       
-       /* Ez eleg ciki, de ilyen a rendszer */
-       if (COMX_readw(dev, OFF_A_L1_PBUFOVR) >> 8) {
-               ch->line_status &= ~LINE_UP;
-       } else {
-               ch->line_status |= LINE_UP;
-       }
-       
-       if (ch->LINE_status) {
-               ch->LINE_status(dev, ch->line_status);
-       }
-
-       ch->HW_release_board(dev, savep);
-
-       for ( ; procfile ; procfile = procfile->next) {
-               if (strcmp(procfile->name, FILENAME_IRQ) == 0 
-                   || strcmp(procfile->name, FILENAME_IO) == 0
-                   || strcmp(procfile->name, FILENAME_MEMADDR) == 0
-                   || strcmp(procfile->name, FILENAME_CHANNEL) == 0
-                   || strcmp(procfile->name, FILENAME_FIRMWARE) == 0
-                   || strcmp(procfile->name, FILENAME_CLOCK) == 0) {
-                       procfile->mode = S_IFREG | 0444;
-               
-               }
-       }       
-       
-       return 0;       
-
-error:
-       if(!twin_open) {
-               release_region(dev->base_addr, hw->io_extent);
-               free_irq(dev->irq, (void *)dev);
-       }
-       return retval;
-
-}
-
-static int COMX_close(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct proc_dir_entry *procfile = ch->procdir->subdir;
-       struct comx_privdata *hw = ch->HW_privdata;
-       struct comx_channel *twin_ch;
-       struct net_device *savep;
-
-       savep = ch->HW_access_board(dev);
-
-       COMX_CMD(dev, COMX_CMD_CLOSE);
-       udelay(1000);
-       COMX_CMD(dev, COMX_CMD_EXIT);
-
-       ch->HW_release_board(dev, savep);
-
-       if (ch->init_status & IRQ_ALLOCATED) {
-               free_irq(dev->irq, (void *)dev);
-               ch->init_status &= ~IRQ_ALLOCATED;
-       }
-       release_region(dev->base_addr, hw->io_extent);
-
-       if (ch->twin && (twin_ch = ch->twin->priv) && 
-           (twin_ch->init_status & HW_OPEN)) {
-               /* Pass the irq to the twin */
-               if (request_irq(dev->irq, COMX_interrupt, 0, ch->twin->name, 
-                  (void *)ch->twin) == 0) {
-                       twin_ch->init_status |= IRQ_ALLOCATED;
-               }
-       }
-
-       for ( ; procfile ; procfile = procfile->next) {
-               if (strcmp(procfile->name, FILENAME_IRQ) == 0 
-                   || strcmp(procfile->name, FILENAME_IO) == 0
-                   || strcmp(procfile->name, FILENAME_MEMADDR) == 0
-                   || strcmp(procfile->name, FILENAME_CHANNEL) == 0
-                   || strcmp(procfile->name, FILENAME_FIRMWARE) == 0
-                   || strcmp(procfile->name, FILENAME_CLOCK) == 0) {
-                       procfile->mode = S_IFREG | 0644;
-               }
-       }
-       
-       ch->init_status &= ~HW_OPEN;
-       return 0;
-}
-
-static int COMX_statistics(struct net_device *dev, char *page)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       struct net_device *savep;
-       int len = 0;
-
-       savep = ch->HW_access_board(dev);
-
-       len += sprintf(page + len, "Board data: %s %s %s %s\nPBUFOVR: %02x, "
-               "MODSTAT: %02x, LINKUP: %02x, DAV: %02x\nRxBUFP: %02x, "
-               "TxEMPTY: %02x, TxBUFP: %02x\n",
-               (ch->init_status & HW_OPEN) ? "HW_OPEN" : "",
-               (ch->init_status & LINE_OPEN) ? "LINE_OPEN" : "",
-               (ch->init_status & FW_LOADED) ? "FW_LOADED" : "",
-               (ch->init_status & IRQ_ALLOCATED) ? "IRQ_ALLOCATED" : "",
-               COMX_readw(dev, OFF_A_L1_PBUFOVR) & 0xff,
-               (COMX_readw(dev, OFF_A_L1_PBUFOVR) >> 8) & 0xff,
-               COMX_readw(dev, OFF_A_L2_LINKUP) & 0xff,
-               COMX_readw(dev, OFF_A_L2_DAV) & 0xff,
-               COMX_readw(dev, OFF_A_L2_RxBUFP) & 0xff,
-               COMX_readw(dev, OFF_A_L2_TxEMPTY) & 0xff,
-               COMX_readw(dev, OFF_A_L2_TxBUFP) & 0xff);
-
-       len += sprintf(page + len, "hist[0]: %8lu hist[1]: %8lu hist[2]: %8lu\n"
-               "hist[3]: %8lu hist[4]: %8lu\n",hw->histogram[0],hw->histogram[1],
-               hw->histogram[2],hw->histogram[3],hw->histogram[4]);
-
-       ch->HW_release_board(dev, savep);
-
-       return len;
-}
-
-static int COMX_load_board(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       struct comx_firmware *fw = hw->firmware;
-       word board_segment = dev->mem_start >> 16;
-       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
-       unsigned long flags;
-       unsigned char id1, id2;
-       struct net_device *saved;
-       int retval;
-       int loopcount;
-       int len;
-       byte *COMX_address;
-
-       if (!fw || !fw->len) {
-               struct comx_channel *twin_ch = ch->twin ? ch->twin->priv : NULL;
-               struct comx_privdata *twin_hw;
-
-               if (!twin_ch || !(twin_hw = twin_ch->HW_privdata)) {
-                       return -EAGAIN;
-               }
-
-               if (!(fw = twin_hw->firmware) || !fw->len) {
-                       return -EAGAIN;
-               }
-       }
-
-       id1 = fw->data[OFF_FW_L1_ID]; 
-       id2 = fw->data[OFF_FW_L1_ID + 1];
-
-       if (id1 != FW_L1_ID_1 || id2 != FW_L1_ID_2_COMX) {
-               printk(KERN_ERR "%s: incorrect firmware, load aborted\n", 
-                       dev->name);
-               return -EAGAIN;
-       }
-
-       printk(KERN_INFO "%s: Loading COMX Layer 1 firmware %s\n", dev->name, 
-               (char *)(fw->data + OFF_FW_L1_ID + 2));
-
-       id1 = fw->data[OFF_FW_L2_ID]; 
-       id2 = fw->data[OFF_FW_L2_ID + 1];
-       if (id1 == FW_L2_ID_1 && (id2 == 0xc0 || id2 == 0xc1 || id2 == 0xc2)) {
-               printk(KERN_INFO "with Layer 2 code %s\n", 
-                       (char *)(fw->data + OFF_FW_L2_ID + 2));
-       }
-
-       outb_p(board_segment | COMX_BOARD_RESET, dev->base_addr);
-       /* 10 usec should be enough here */
-       udelay(100);
-
-       save_flags(flags); cli();
-       saved=memory_used[mempos];
-       if(saved) {
-               ((struct comx_channel *)saved->priv)->HW_board_off(saved);
-       }
-       memory_used[mempos]=dev;
-
-       outb_p(board_segment | COMX_ENABLE_BOARD_MEM, dev->base_addr);
-
-       writeb(0, dev->mem_start + COMX_JAIL_OFFSET);   
-
-       loopcount=0;
-       while(loopcount++ < 10000 && 
-           readb(dev->mem_start + COMX_JAIL_OFFSET) != COMX_JAIL_VALUE) {
-               udelay(100);
-       }       
-       
-       if (readb(dev->mem_start + COMX_JAIL_OFFSET) != COMX_JAIL_VALUE) {
-               printk(KERN_ERR "%s: Can't reset board, JAIL value is %02x\n",
-                       dev->name, readb(dev->mem_start + COMX_JAIL_OFFSET));
-               retval=-ENODEV;
-               goto out;
-       }
-
-       writeb(0x55, dev->mem_start + 0x18ff);
-       
-       loopcount=0;
-       while(loopcount++ < 10000 && readb(dev->mem_start + 0x18ff) != 0) {
-               udelay(100);
-       }
-
-       if(readb(dev->mem_start + 0x18ff) != 0) {
-               printk(KERN_ERR "%s: Can't reset board, reset timeout\n",
-                       dev->name);
-               retval=-ENODEV;
-               goto out;
-       }               
-
-       len = 0;
-       COMX_address = (byte *)dev->mem_start;
-       while (fw->len > len) {
-               writeb(fw->data[len++], COMX_address++);
-       }
-
-       len = 0;
-       COMX_address = (byte *)dev->mem_start;
-       while (len != fw->len && readb(COMX_address++) == fw->data[len]) {
-               len++;
-       }
-
-       if (len != fw->len) {
-               printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
-                       "instead of 0x%02x\n", dev->name, len, 
-                       readb(COMX_address - 1), fw->data[len]);
-               retval=-EAGAIN;
-               goto out;
-       }
-
-       writeb(0, dev->mem_start + COMX_JAIL_OFFSET);
-
-       loopcount = 0;
-       while ( loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
-               udelay(100);
-       }
-
-       if (COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
-               printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
-                       dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
-               retval=-EAGAIN;
-               goto out;
-       }
-
-
-       ch->init_status |= FW_LOADED;
-       retval=0;
-
-out: 
-       outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-       if(saved) {
-               ((struct comx_channel *)saved->priv)->HW_board_on(saved);
-       }
-       memory_used[mempos]=saved;
-       restore_flags(flags);
-       return retval;
-}
-
-static int CMX_load_board(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       struct comx_firmware *fw = hw->firmware;
-       word board_segment = dev->mem_start >> 16;
-       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
-       #if 0
-       unsigned char id1, id2;
-       #endif
-       struct net_device *saved;
-       unsigned long flags;
-       int retval;
-       int loopcount;
-       int len;
-       byte *COMX_address;
-
-       if (!fw || !fw->len) {
-               struct comx_channel *twin_ch = ch->twin ? ch->twin->priv : NULL;
-               struct comx_privdata *twin_hw;
-
-               if (!twin_ch || !(twin_hw = twin_ch->HW_privdata)) {
-                       return -EAGAIN;
-               }
-
-               if (!(fw = twin_hw->firmware) || !fw->len) {
-                       return -EAGAIN;
-               }
-       }
-
-       /* Ide kell olyat tenni, hogy ellenorizze az ID-t */
-
-       if (inb_p(dev->base_addr) != CMX_ID_BYTE) {
-               printk(KERN_ERR "%s: CMX id byte is invalid(%02x)\n", dev->name,
-                       inb_p(dev->base_addr));
-               return -ENODEV;
-       }
-
-       printk(KERN_INFO "%s: Loading CMX Layer 1 firmware %s\n", dev->name, 
-               (char *)(fw->data + OFF_FW_L1_ID + 2));
-
-       save_flags(flags); cli();
-       saved=memory_used[mempos];
-       if(saved) {
-               ((struct comx_channel *)saved->priv)->HW_board_off(saved);
-       }
-       memory_used[mempos]=dev;
-       
-       outb_p(board_segment | COMX_ENABLE_BOARD_MEM | COMX_BOARD_RESET, 
-               dev->base_addr);
-
-       len = 0;
-       COMX_address = (byte *)dev->mem_start;
-       while (fw->len > len) {
-               writeb(fw->data[len++], COMX_address++);
-       }
-
-       len = 0;
-       COMX_address = (byte *)dev->mem_start;
-       while (len != fw->len && readb(COMX_address++) == fw->data[len]) {
-               len++;
-       }
-
-       outb_p(board_segment | COMX_ENABLE_BOARD_MEM, dev->base_addr);
-
-       if (len != fw->len) {
-               printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
-                       "instead of 0x%02x\n", dev->name, len, 
-                       readb(COMX_address - 1), fw->data[len]);
-               retval=-EAGAIN;
-               goto out;
-       }
-
-       loopcount=0;
-       while( loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
-               udelay(100);
-       }
-
-       if (COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
-               printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
-                       dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
-               retval=-EAGAIN;
-               goto out;
-       }
-
-       ch->init_status |= FW_LOADED;
-       retval=0;
-
-out: 
-       outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-       if(saved) {
-               ((struct comx_channel *)saved->priv)->HW_board_on(saved);
-       }
-       memory_used[mempos]=saved;
-       restore_flags(flags);
-       return retval;
-}
-
-static int HICOMX_load_board(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       struct comx_firmware *fw = hw->firmware;
-       word board_segment = dev->mem_start >> 12;
-       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
-       struct net_device *saved;
-       unsigned char id1, id2;
-       unsigned long flags;
-       int retval;
-       int loopcount;
-       int len;
-       word *HICOMX_address;
-       char id = 1;
-
-       if (!fw || !fw->len) {
-               struct comx_channel *twin_ch = ch->twin ? ch->twin->priv : NULL;
-               struct comx_privdata *twin_hw;
-
-               if (!twin_ch || !(twin_hw = twin_ch->HW_privdata)) {
-                       return -EAGAIN;
-               }
-
-               if (!(fw = twin_hw->firmware) || !fw->len) {
-                       return -EAGAIN;
-               }
-       }
-
-       while (id != 4) {
-               if (inb_p(dev->base_addr + id++) != HICOMX_ID_BYTE) {
-                       break;
-               }
-       }
-
-       if (id != 4) {
-               printk(KERN_ERR "%s: can't find HICOMX at 0x%04x, id[%d] = %02x\n",
-                       dev->name, (unsigned int)dev->base_addr, id - 1,
-                       inb_p(dev->base_addr + id - 1));
-               return -1;      
-       }
-
-       id1 = fw->data[OFF_FW_L1_ID]; 
-       id2 = fw->data[OFF_FW_L1_ID + 1];
-       if (id1 != FW_L1_ID_1 || id2 != FW_L1_ID_2_HICOMX) {
-               printk(KERN_ERR "%s: incorrect firmware, load aborted\n", dev->name);
-               return -EAGAIN;
-       }
-
-       printk(KERN_INFO "%s: Loading HICOMX Layer 1 firmware %s\n", dev->name, 
-               (char *)(fw->data + OFF_FW_L1_ID + 2));
-
-       id1 = fw->data[OFF_FW_L2_ID]; 
-       id2 = fw->data[OFF_FW_L2_ID + 1];
-       if (id1 == FW_L2_ID_1 && (id2 == 0xc0 || id2 == 0xc1 || id2 == 0xc2)) {
-               printk(KERN_INFO "with Layer 2 code %s\n", 
-                       (char *)(fw->data + OFF_FW_L2_ID + 2));
-       }
-
-       outb_p(board_segment | HICOMX_BOARD_RESET, dev->base_addr);
-       udelay(10);     
-
-       save_flags(flags); cli();
-       saved=memory_used[mempos];
-       if(saved) {
-               ((struct comx_channel *)saved->priv)->HW_board_off(saved);
-       }
-       memory_used[mempos]=dev;
-
-       outb_p(board_segment | HICOMX_ENABLE_BOARD_MEM, dev->base_addr);
-       outb_p(HICOMX_PRG_MEM, dev->base_addr + 1);
-
-       len = 0;
-       HICOMX_address = (word *)dev->mem_start;
-       while (fw->len > len) {
-               writeb(fw->data[len++], HICOMX_address++);
-       }
-
-       len = 0;
-       HICOMX_address = (word *)dev->mem_start;
-       while (len != fw->len && (readw(HICOMX_address++) & 0xff) == fw->data[len]) {
-               len++;
-       }
-
-       if (len != fw->len) {
-               printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
-                       "instead of 0x%02x\n", dev->name, len, 
-                       readw(HICOMX_address - 1) & 0xff, fw->data[len]);
-               retval=-EAGAIN;
-               goto out;
-       }
-
-       outb_p(board_segment | HICOMX_BOARD_RESET, dev->base_addr);
-       outb_p(HICOMX_DATA_MEM, dev->base_addr + 1);
-
-       outb_p(board_segment | HICOMX_ENABLE_BOARD_MEM, dev->base_addr);
-
-       loopcount=0;
-       while(loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
-               udelay(100);
-       }
-
-       if ( COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
-               printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
-                       dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
-               retval=-EAGAIN;
-               goto out;
-       }
-
-       ch->init_status |= FW_LOADED;
-       retval=0;
-
-out:
-       outb_p(board_segment | HICOMX_DISABLE_ALL, dev->base_addr);
-       outb_p(HICOMX_DATA_MEM, dev->base_addr + 1);
-
-       if(saved) {
-               ((struct comx_channel *)saved->priv)->HW_board_on(saved);
-       }
-       memory_used[mempos]=saved;
-       restore_flags(flags);
-       return retval;
-}
-
-static struct net_device *comx_twin_check(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct proc_dir_entry *procfile = ch->procdir->parent->subdir;
-       struct comx_privdata *hw = ch->HW_privdata;
-
-       struct net_device *twin;
-       struct comx_channel *ch_twin;
-       struct comx_privdata *hw_twin;
-
-
-       for ( ; procfile ; procfile = procfile->next) {
-       
-               if(!S_ISDIR(procfile->mode)) {
-                       continue;
-               }
-       
-               twin=procfile->data;
-               ch_twin=twin->priv;
-               hw_twin=ch_twin->HW_privdata;
-
-
-               if (twin != dev && dev->irq && dev->base_addr && dev->mem_start &&
-                  dev->irq == twin->irq && dev->base_addr == twin->base_addr &&
-                  dev->mem_start == twin->mem_start &&
-                  hw->channel == (1 - hw_twin->channel) &&
-                  ch->hardware == ch_twin->hardware) {
-                       return twin;
-               }
-       }
-       return NULL;
-}
-
-static int comxhw_write_proc(struct file *file, const char *buffer, 
-       u_long count, void *data)
-{
-       struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
-       struct net_device *dev = entry->parent->data;
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       char *page;
-
-
-       if(ch->init_status & HW_OPEN) {
-               return -EAGAIN; 
-       }
-       
-       if (strcmp(FILENAME_FIRMWARE, entry->name) != 0) {
-               if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
-                       return -ENOMEM;
-               }
-               if(copy_from_user(page, buffer, count = (min_t(int, count, PAGE_SIZE))))
-               {
-                       count = -EFAULT;
-                       goto out;
-               }
-               if (page[count-1] == '\n')
-                       page[count-1] = '\0';
-               else if (count < PAGE_SIZE)
-                       page[count] = '\0';
-               else if (page[count]) {
-                       count = -EINVAL;
-                       goto out;
-               }
-               page[count]=0;  /* Null terminate */
-       } else {
-               byte *tmp;
-
-               if (!hw->firmware) {
-                       if ((hw->firmware = kmalloc(sizeof(struct comx_firmware), 
-                           GFP_KERNEL)) == NULL) {
-                               return -ENOMEM;
-                       }
-                       hw->firmware->len = 0;
-                       hw->firmware->data = NULL;
-               }
-               
-               if ((tmp = kmalloc(count + file->f_pos, GFP_KERNEL)) == NULL) {
-                       return -ENOMEM;
-               }
-               
-               /* Ha nem 0 a fpos, akkor meglevo file-t irunk. Gyenge trukk. */
-               if (hw->firmware && hw->firmware->len && file->f_pos 
-                   && hw->firmware->len < count + file->f_pos) {
-                       memcpy(tmp, hw->firmware->data, hw->firmware->len);
-               }
-               if (hw->firmware->data) {
-                       kfree(hw->firmware->data);
-               }
-               if (copy_from_user(tmp + file->f_pos, buffer, count))
-                       return -EFAULT;
-               hw->firmware->len = entry->size = file->f_pos + count;
-               hw->firmware->data = tmp;
-               file->f_pos += count;
-               return count;
-       }
-
-       if (strcmp(entry->name, FILENAME_CHANNEL) == 0) {
-               hw->channel = simple_strtoul(page, NULL, 0);
-               if (hw->channel >= MAX_CHANNELNO) {
-                       printk(KERN_ERR "Invalid channel number\n");
-                       hw->channel = 0;
-               }
-               if ((ch->twin = comx_twin_check(dev)) != NULL) {
-                       struct comx_channel *twin_ch = ch->twin->priv;
-                       twin_ch->twin = dev;
-               }
-       } else if (strcmp(entry->name, FILENAME_IRQ) == 0) {
-               dev->irq = simple_strtoul(page, NULL, 0);
-               if (dev->irq == 2) {
-                       dev->irq = 9;
-               }
-               if (dev->irq < 3 || dev->irq > 15) {
-                       printk(KERN_ERR "comxhw: Invalid irq number\n");
-                       dev->irq = 0;
-               }
-               if ((ch->twin = comx_twin_check(dev)) != NULL) {
-                       struct comx_channel *twin_ch = ch->twin->priv;
-                       twin_ch->twin = dev;
-               }
-       } else if (strcmp(entry->name, FILENAME_IO) == 0) {
-               dev->base_addr = simple_strtoul(page, NULL, 0);
-               if ((dev->base_addr & 3) != 0 || dev->base_addr < 0x300 
-                  || dev->base_addr > 0x3fc) {
-                       printk(KERN_ERR "Invalid io value\n");
-                       dev->base_addr = 0;
-               }
-               if ((ch->twin = comx_twin_check(dev)) != NULL) {
-                       struct comx_channel *twin_ch = ch->twin->priv;
-
-                       twin_ch->twin = dev;
-               }
-       } else if (strcmp(entry->name, FILENAME_MEMADDR) == 0) {
-               dev->mem_start = simple_strtoul(page, NULL, 0);
-               if (dev->mem_start <= 0xf000 && dev->mem_start >= 0xa000) {
-                       dev->mem_start *= 16;
-               }
-               if ((dev->mem_start & 0xfff) != 0 || dev->mem_start < COMX_MEM_MIN
-                   || dev->mem_start + hw->memory_size > COMX_MEM_MAX) {
-                       printk(KERN_ERR "Invalid memory page\n");
-                       dev->mem_start = 0;
-               }
-               dev->mem_end = dev->mem_start + hw->memory_size;
-               if ((ch->twin = comx_twin_check(dev)) != NULL) {
-                       struct comx_channel *twin_ch = ch->twin->priv;
-
-                       twin_ch->twin = dev;
-               }
-       } else if (strcmp(entry->name, FILENAME_CLOCK) == 0) {
-               if (strncmp("ext", page, 3) == 0) {
-                       hw->clock = 0;
-               } else {
-                       int kbps;
-
-                       kbps = simple_strtoul(page, NULL, 0);
-                       hw->clock = kbps ? COMX_CLOCK_CONST/kbps : 0;
-               }
-       }
-out:
-       free_page((unsigned long)page);
-       return count;
-}
-
-static int comxhw_read_proc(char *page, char **start, off_t off, int count,
-       int *eof, void *data)
-{
-       struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-       struct net_device *dev = file->parent->data;
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-       int len = 0;
-
-
-       if (strcmp(file->name, FILENAME_IO) == 0) {
-               len = sprintf(page, "0x%03x\n", (unsigned int)dev->base_addr);
-       } else if (strcmp(file->name, FILENAME_IRQ) == 0) {
-               len = sprintf(page, "0x%02x\n", dev->irq == 9 ? 2 : dev->irq);
-       } else if (strcmp(file->name, FILENAME_CHANNEL) == 0) {
-               len = sprintf(page, "%01d\n", hw->channel);
-       } else if (strcmp(file->name, FILENAME_MEMADDR) == 0) {
-               len = sprintf(page, "0x%05x\n", (unsigned int)dev->mem_start);
-       } else if (strcmp(file->name, FILENAME_TWIN) == 0) {
-               len = sprintf(page, "%s\n", ch->twin ? ch->twin->name : "none");
-       } else if (strcmp(file->name, FILENAME_CLOCK) == 0) {
-               if (hw->clock) {
-                       len = sprintf(page, "%-8d\n", COMX_CLOCK_CONST/hw->clock);
-               } else {
-                       len = sprintf(page, "external\n");
-               }
-       } else if (strcmp(file->name, FILENAME_FIRMWARE) == 0) {
-               len = min_t(int, FILE_PAGESIZE,
-                         min_t(int, count, 
-                             hw->firmware ?
-                             (hw->firmware->len - off) : 0));
-               if (len < 0) {
-                       len = 0;
-               }
-               *start = hw->firmware ? (hw->firmware->data + off) : NULL;
-               if (off + len >= (hw->firmware ? hw->firmware->len : 0) || len == 0) {
-                       *eof = 1;
-               }
-               return len;
-       }       
-
-       if (off >= len) {
-               *eof = 1;
-               return 0;
-       }
-
-       *start = page + off;
-       if (count >= len - off) {
-               *eof = 1;
-       }
-       return min_t(int, count, len - off);
-}
-
-/* Called on echo comx >boardtype */
-static int COMX_init(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw;
-       struct proc_dir_entry *new_file;
-
-       if ((ch->HW_privdata = kmalloc(sizeof(struct comx_privdata), 
-           GFP_KERNEL)) == NULL) {
-               return -ENOMEM;
-       }
-       memset(hw = ch->HW_privdata, 0, sizeof(struct comx_privdata));
-
-       if (ch->hardware == &comx_hw || ch->hardware == &cmx_hw) {
-               hw->memory_size = COMX_MEMORY_SIZE;
-               hw->io_extent = COMX_IO_EXTENT;
-               dev->base_addr = COMX_DEFAULT_IO;
-               dev->irq = COMX_DEFAULT_IRQ;
-               dev->mem_start = COMX_DEFAULT_MEMADDR;
-               dev->mem_end = COMX_DEFAULT_MEMADDR + COMX_MEMORY_SIZE;
-       } else if (ch->hardware == &hicomx_hw) {
-               hw->memory_size = HICOMX_MEMORY_SIZE;
-               hw->io_extent = HICOMX_IO_EXTENT;
-               dev->base_addr = HICOMX_DEFAULT_IO;
-               dev->irq = HICOMX_DEFAULT_IRQ;
-               dev->mem_start = HICOMX_DEFAULT_MEMADDR;
-               dev->mem_end = HICOMX_DEFAULT_MEMADDR + HICOMX_MEMORY_SIZE;
-       } else {
-               printk(KERN_ERR "SERIOUS INTERNAL ERROR in %s, line %d\n", __FILE__, __LINE__);
-       }
-
-       if ((new_file = create_proc_entry(FILENAME_IO, S_IFREG | 0644, ch->procdir))
-           == NULL) {
-           goto cleanup_HW_privdata;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &comxhw_read_proc;
-       new_file->write_proc = &comxhw_write_proc;
-       new_file->size = 6;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_IRQ, S_IFREG | 0644, ch->procdir))
-           == NULL) {
-           goto cleanup_filename_io;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &comxhw_read_proc;
-       new_file->write_proc = &comxhw_write_proc;
-       new_file->size = 5;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_CHANNEL, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-           goto cleanup_filename_irq;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &comxhw_read_proc;
-       new_file->write_proc = &comxhw_write_proc;
-       new_file->size = 2;             // Ezt tudjuk
-       new_file->nlink = 1;
-
-       if (ch->hardware == &hicomx_hw || ch->hardware == &cmx_hw) {
-               if ((new_file = create_proc_entry(FILENAME_CLOCK, S_IFREG | 0644, 
-                  ch->procdir)) == NULL) {
-                   goto cleanup_filename_channel;
-               }
-               new_file->data = (void *)new_file;
-               new_file->read_proc = &comxhw_read_proc;
-               new_file->write_proc = &comxhw_write_proc;
-               new_file->size = 9;
-               new_file->nlink = 1;
-       }
-
-       if ((new_file = create_proc_entry(FILENAME_MEMADDR, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-                   goto cleanup_filename_clock;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &comxhw_read_proc;
-       new_file->write_proc = &comxhw_write_proc;
-       new_file->size = 8;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_TWIN, S_IFREG | 0444, 
-           ch->procdir)) == NULL) {
-                   goto cleanup_filename_memaddr;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &comxhw_read_proc;
-       new_file->write_proc = NULL;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_FIRMWARE, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-                   goto cleanup_filename_twin;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &comxhw_read_proc;
-       new_file->write_proc = &comxhw_write_proc;
-       new_file->nlink = 1;
-
-       if (ch->hardware == &comx_hw) {
-               ch->HW_board_on = COMX_board_on;
-               ch->HW_board_off = COMX_board_off;
-               ch->HW_load_board = COMX_load_board;
-       } else if (ch->hardware == &cmx_hw) {
-               ch->HW_board_on = COMX_board_on;
-               ch->HW_board_off = COMX_board_off;
-               ch->HW_load_board = CMX_load_board;
-               ch->HW_set_clock = COMX_set_clock;
-       } else if (ch->hardware == &hicomx_hw) {
-               ch->HW_board_on = HICOMX_board_on;
-               ch->HW_board_off = HICOMX_board_off;
-               ch->HW_load_board = HICOMX_load_board;
-               ch->HW_set_clock = COMX_set_clock;
-       } else {
-               printk(KERN_ERR "SERIOUS INTERNAL ERROR in %s, line %d\n", __FILE__, __LINE__);
-       }
-
-       ch->HW_access_board = COMX_access_board;
-       ch->HW_release_board = COMX_release_board;
-       ch->HW_txe = COMX_txe;
-       ch->HW_open = COMX_open;
-       ch->HW_close = COMX_close;
-       ch->HW_send_packet = COMX_send_packet;
-       ch->HW_statistics = COMX_statistics;
-
-       if ((ch->twin = comx_twin_check(dev)) != NULL) {
-               struct comx_channel *twin_ch = ch->twin->priv;
-
-               twin_ch->twin = dev;
-       }
-
-       MOD_INC_USE_COUNT;
-       return 0;
-
-cleanup_filename_twin:
-       remove_proc_entry(FILENAME_TWIN, ch->procdir);
-cleanup_filename_memaddr:
-       remove_proc_entry(FILENAME_MEMADDR, ch->procdir);
-cleanup_filename_clock:
-       if (ch->hardware == &hicomx_hw || ch->hardware == &cmx_hw)
-               remove_proc_entry(FILENAME_CLOCK, ch->procdir);
-cleanup_filename_channel:
-       remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
-cleanup_filename_irq:
-       remove_proc_entry(FILENAME_IRQ, ch->procdir);
-cleanup_filename_io:
-       remove_proc_entry(FILENAME_IO, ch->procdir);
-cleanup_HW_privdata:
-       kfree(ch->HW_privdata);
-       return -EIO;
-}
-
-/* Called on echo valami >boardtype */
-static int COMX_exit(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_privdata *hw = ch->HW_privdata;
-
-       if (hw->firmware) {
-               if (hw->firmware->data) kfree(hw->firmware->data);
-               kfree(hw->firmware);
-       } if (ch->twin) {
-               struct comx_channel *twin_ch = ch->twin->priv;
-
-               twin_ch->twin = NULL;
-       }
-       
-       kfree(ch->HW_privdata);
-       remove_proc_entry(FILENAME_IO, ch->procdir);
-       remove_proc_entry(FILENAME_IRQ, ch->procdir);
-       remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
-       remove_proc_entry(FILENAME_MEMADDR, ch->procdir);
-       remove_proc_entry(FILENAME_FIRMWARE, ch->procdir);
-       remove_proc_entry(FILENAME_TWIN, ch->procdir);
-       if (ch->hardware == &hicomx_hw || ch->hardware == &cmx_hw) {
-               remove_proc_entry(FILENAME_CLOCK, ch->procdir);
-       }
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static int COMX_dump(struct net_device *dev)
-{
-       printk(KERN_INFO "%s: COMX_dump called, why ?\n", dev->name);
-       return 0;
-}
-
-static struct comx_hardware comx_hw = {
-       "comx",
-       VERSION,
-       COMX_init,
-       COMX_exit,
-       COMX_dump,
-       NULL
-};
-
-static struct comx_hardware cmx_hw = {
-       "cmx",
-       VERSION,
-       COMX_init,
-       COMX_exit,
-       COMX_dump,
-       NULL
-};
-
-static struct comx_hardware hicomx_hw = {
-       "hicomx",
-       VERSION,
-       COMX_init,
-       COMX_exit,
-       COMX_dump,
-       NULL
-};
-
-static int __init comx_hw_comx_init(void)
-{
-       comx_register_hardware(&comx_hw);
-       comx_register_hardware(&cmx_hw);
-       comx_register_hardware(&hicomx_hw);
-       return 0;
-}
-
-static void __exit comx_hw_comx_exit(void)
-{
-       comx_unregister_hardware("comx");
-       comx_unregister_hardware("cmx");
-       comx_unregister_hardware("hicomx");
-}
-
-module_init(comx_hw_comx_init);
-module_exit(comx_hw_comx_exit);
diff --git a/drivers/net/wan/comx-hw-locomx.c b/drivers/net/wan/comx-hw-locomx.c
deleted file mode 100644 (file)
index 5246016..0000000
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Hardware driver for the LoCOMX card, using the generic z85230
- * functions
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * Based on skeleton code and old LoCOMX driver by Tivadar Szemethy <tiv@itc.hu> 
- * and the hostess_sv11 driver
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.14)
- *
- * Copyright (C) 1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.10 (99/06/17):
- *             - rewritten for the z85230 layer
- *
- * Version 0.11 (99/06/21):
- *             - some printk's fixed
- *             - get rid of a memory leak (it was impossible though :))
- * 
- * Version 0.12 (99/07/07):
- *             - check CTS for modem lines, not DCD (which is always high
- *               in case of this board)
- * Version 0.13 (99/07/08):
- *             - Fix the transmitter status check
- *             - Handle the net device statistics better
- * Version 0.14 (00/08/15):
- *             - resource release on failure at LOCOMX_init
- */
-
-#define VERSION "0.14"
-
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-#include <asm/dma.h>
-
-#include "comx.h"
-#include "z85230.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Hardware driver for the LoCOMX board");
-MODULE_LICENSE("GPL");
-
-#define RX_DMA 3
-#define TX_DMA 1
-#define LOCOMX_ID 0x33
-#define LOCOMX_IO_EXTENT 8
-#define LOCOMX_DEFAULT_IO 0x368
-#define LOCOMX_DEFAULT_IRQ 7
-
-u8 z8530_locomx[] = {
-       11,     TCRTxCP,
-       14,     DTRREQ,
-       255
-};
-
-struct locomx_data {
-       int     io_extent;
-       struct  z8530_dev board;
-       struct timer_list status_timer;
-};
-
-static int LOCOMX_txe(struct net_device *dev)
-{
-       struct comx_channel *ch = netdev_priv(dev);
-       struct locomx_data *hw = ch->HW_privdata;
-
-       return (!hw->board.chanA.tx_next_skb);
-}
-
-
-static void locomx_rx(struct z8530_channel *c, struct sk_buff *skb)
-{
-       struct net_device *dev = c->netdevice;
-       struct comx_channel *ch = netdev_priv(dev);
-       
-       if (ch->debug_flags & DEBUG_HW_RX) {
-               comx_debug_skb(dev, skb, "locomx_rx receiving");
-       }
-       ch->LINE_rx(dev,skb);
-}
-
-static int LOCOMX_send_packet(struct net_device *dev, struct sk_buff *skb) 
-{
-       struct comx_channel *ch = netdev_priv(dev);
-       struct locomx_data *hw = ch->HW_privdata;
-
-       if (ch->debug_flags & DEBUG_HW_TX) {
-               comx_debug_bytes(dev, skb->data, skb->len, "LOCOMX_send_packet");
-       }
-
-       if (!(ch->line_status & LINE_UP)) {
-               return FRAME_DROPPED;
-       }
-
-       if(z8530_queue_xmit(&hw->board.chanA,skb)) {
-               printk(KERN_WARNING "%s: FRAME_DROPPED\n",dev->name);
-               return FRAME_DROPPED;
-       }
-
-       if (ch->debug_flags & DEBUG_HW_TX) {
-               comx_debug(dev, "%s: LOCOMX_send_packet was successful\n\n", dev->name);
-       }
-
-       if(!hw->board.chanA.tx_next_skb) {
-               return FRAME_QUEUED;
-       } else {
-               return FRAME_ACCEPTED;
-       }
-}
-
-static void locomx_status_timerfun(unsigned long d)
-{
-       struct net_device *dev = (struct net_device *)d;
-       struct comx_channel *ch = netdev_priv(dev);
-       struct locomx_data *hw = ch->HW_privdata;
-
-       if(!(ch->line_status & LINE_UP) &&
-           (hw->board.chanA.status & CTS)) {
-               ch->LINE_status(dev, ch->line_status | LINE_UP);
-       }
-       if((ch->line_status & LINE_UP) &&
-           !(hw->board.chanA.status & CTS)) {
-               ch->LINE_status(dev, ch->line_status & ~LINE_UP);
-       }
-       mod_timer(&hw->status_timer,jiffies + ch->lineup_delay * HZ);
-}
-
-
-static int LOCOMX_open(struct net_device *dev)
-{
-       struct comx_channel *ch = netdev_priv(dev);
-       struct locomx_data *hw = ch->HW_privdata;
-       struct proc_dir_entry *procfile = ch->procdir->subdir;
-       unsigned long flags;
-       int ret;
-
-       if (!dev->base_addr || !dev->irq) {
-               return -ENODEV;
-       }
-
-       if (!request_region(dev->base_addr, hw->io_extent, dev->name)) {
-               return -EAGAIN;
-       }
-
-       hw->board.chanA.ctrlio=dev->base_addr + 5;
-       hw->board.chanA.dataio=dev->base_addr + 7;
-       
-       hw->board.irq=dev->irq;
-       hw->board.chanA.netdevice=dev;
-       hw->board.chanA.dev=&hw->board;
-       hw->board.name=dev->name;
-       hw->board.chanA.txdma=TX_DMA;
-       hw->board.chanA.rxdma=RX_DMA;
-       hw->board.chanA.irqs=&z8530_nop;
-       hw->board.chanB.irqs=&z8530_nop;
-
-       if(request_irq(dev->irq, z8530_interrupt, SA_INTERRUPT, 
-           dev->name, &hw->board)) {
-               printk(KERN_ERR "%s: unable to obtain irq %d\n", dev->name, 
-                       dev->irq);
-               ret=-EAGAIN;
-               goto irq_fail;
-       }
-       if(request_dma(TX_DMA,"LoCOMX (TX)")) {
-               printk(KERN_ERR "%s: unable to obtain TX DMA (DMA channel %d)\n", 
-                       dev->name, TX_DMA);
-               ret=-EAGAIN;
-               goto dma1_fail;
-       }
-
-       if(request_dma(RX_DMA,"LoCOMX (RX)")) {
-               printk(KERN_ERR "%s: unable to obtain RX DMA (DMA channel %d)\n", 
-                       dev->name, RX_DMA);
-               ret=-EAGAIN;
-               goto dma2_fail;
-       }
-       
-       save_flags(flags); 
-       cli();
-
-       if(z8530_init(&hw->board)!=0)
-       {
-               printk(KERN_ERR "%s: Z8530 device not found.\n",dev->name);
-               ret=-ENODEV;
-               goto z8530_fail;
-       }
-
-       hw->board.chanA.dcdcheck=CTS;
-
-       z8530_channel_load(&hw->board.chanA, z8530_hdlc_kilostream_85230);
-       z8530_channel_load(&hw->board.chanA, z8530_locomx);
-       z8530_channel_load(&hw->board.chanB, z8530_dead_port);
-
-       z8530_describe(&hw->board, "I/O", dev->base_addr);
-
-       if((ret=z8530_sync_dma_open(dev, &hw->board.chanA))!=0) {
-               goto z8530_fail;
-       }
-
-       restore_flags(flags);
-
-
-       hw->board.active=1;
-       hw->board.chanA.rx_function=locomx_rx;
-
-       ch->init_status |= HW_OPEN;
-       if (hw->board.chanA.status & DCD) {
-               ch->line_status |= LINE_UP;
-       } else {
-               ch->line_status &= ~LINE_UP;
-       }
-
-       comx_status(dev, ch->line_status);
-
-       init_timer(&hw->status_timer);
-       hw->status_timer.function=locomx_status_timerfun;
-       hw->status_timer.data=(unsigned long)dev;
-       hw->status_timer.expires=jiffies + ch->lineup_delay * HZ;
-       add_timer(&hw->status_timer);
-
-       for (; procfile ; procfile = procfile->next) {
-               if (strcmp(procfile->name, FILENAME_IO) == 0 ||
-                    strcmp(procfile->name, FILENAME_IRQ) == 0) {
-                       procfile->mode = S_IFREG |  0444;
-               }
-       }
-       return 0;
-
-z8530_fail:
-       restore_flags(flags);
-       free_dma(RX_DMA);
-dma2_fail:
-       free_dma(TX_DMA);
-dma1_fail:
-       free_irq(dev->irq, &hw->board);
-irq_fail:
-       release_region(dev->base_addr, hw->io_extent);
-       return ret;
-}
-
-static int LOCOMX_close(struct net_device *dev)
-{
-       struct comx_channel *ch = netdev_priv(dev);
-       struct locomx_data *hw = ch->HW_privdata;
-       struct proc_dir_entry *procfile = ch->procdir->subdir;
-
-       hw->board.chanA.rx_function=z8530_null_rx;
-       netif_stop_queue(dev);
-       z8530_sync_dma_close(dev, &hw->board.chanA);
-
-       z8530_shutdown(&hw->board);
-
-       del_timer(&hw->status_timer);
-       free_dma(RX_DMA);
-       free_dma(TX_DMA);
-       free_irq(dev->irq,&hw->board);
-       release_region(dev->base_addr,8);
-
-       for (; procfile ; procfile = procfile->next) {
-               if (strcmp(procfile->name, FILENAME_IO) == 0 ||
-                   strcmp(procfile->name, FILENAME_IRQ) == 0) {
-                       procfile->mode = S_IFREG |  0644;
-               }
-       }
-
-       ch->init_status &= ~HW_OPEN;
-       return 0;
-}
-
-static int LOCOMX_statistics(struct net_device *dev,char *page)
-{
-       int len = 0;
-
-       len += sprintf(page + len, "Hello\n");
-
-       return len;
-}
-
-static int LOCOMX_dump(struct net_device *dev) {
-       printk(KERN_INFO "LOCOMX_dump called\n");
-       return(-1);
-}
-
-static int locomx_read_proc(char *page, char **start, off_t off, int count,
-       int *eof, void *data)
-{
-       struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-       struct net_device *dev = file->parent->data;
-       int len = 0;
-
-       if (strcmp(file->name, FILENAME_IO) == 0) {
-               len = sprintf(page, "0x%x\n", (unsigned int)dev->base_addr);
-       } else if (strcmp(file->name, FILENAME_IRQ) == 0) {
-               len = sprintf(page, "%d\n", (unsigned int)dev->irq);
-       } else {
-               printk(KERN_ERR "hw_read_proc: internal error, filename %s\n", 
-                       file->name);
-               return -EBADF;
-       }
-
-       if (off >= len) {
-               *eof = 1;
-               return 0;
-       }
-
-       *start = page + off;
-       if (count >= len - off) {
-               *eof = 1;
-       }
-       return min_t(int, count, len - off);
-}
-
-static int locomx_write_proc(struct file *file, const char *buffer,
-       u_long count, void *data)
-{
-       struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
-       struct net_device *dev = (struct net_device *)entry->parent->data;
-       int val;
-       char *page;
-
-       if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
-               return -ENOMEM;
-       }
-
-       if (copy_from_user(page, buffer, count = min_t(unsigned long, count, PAGE_SIZE))) {
-               free_page((unsigned long)page);
-               return -EBADF;
-       }
-       if (*(page + count - 1) == '\n') {
-               *(page + count - 1) = 0;
-       }
-
-       if (strcmp(entry->name, FILENAME_IO) == 0) {
-               val = simple_strtoul(page, NULL, 0);
-               if (val != 0x360 && val != 0x368 && val != 0x370 && 
-                  val != 0x378) {
-                       printk(KERN_ERR "LoCOMX: incorrect io address!\n");     
-               } else {
-                       dev->base_addr = val;
-               }
-       } else if (strcmp(entry->name, FILENAME_IRQ) == 0) {
-               val = simple_strtoul(page, NULL, 0);
-               if (val != 3 && val != 4 && val != 5 && val != 6 && val != 7) {
-                       printk(KERN_ERR "LoCOMX: incorrect irq value!\n");
-               } else {
-                       dev->irq = val;
-               }       
-       } else {
-               printk(KERN_ERR "locomx_write_proc: internal error, filename %s\n", 
-                       entry->name);
-               free_page((unsigned long)page);
-               return -EBADF;
-       }
-
-       free_page((unsigned long)page);
-       return count;
-}
-
-
-
-static int LOCOMX_init(struct net_device *dev) 
-{
-       struct comx_channel *ch = netdev_priv(dev);
-       struct locomx_data *hw;
-       struct proc_dir_entry *new_file;
-
-       /* Alloc data for private structure */
-       if ((ch->HW_privdata = kmalloc(sizeof(struct locomx_data), 
-          GFP_KERNEL)) == NULL) {
-               return -ENOMEM;
-       }
-
-       memset(hw = ch->HW_privdata, 0, sizeof(struct locomx_data));
-       hw->io_extent = LOCOMX_IO_EXTENT;
-
-       /* Register /proc files */
-       if ((new_file = create_proc_entry(FILENAME_IO, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_HW_privdata;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &locomx_read_proc;
-       new_file->write_proc = &locomx_write_proc;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_IRQ, S_IFREG | 0644, 
-           ch->procdir)) == NULL)  {
-               goto cleanup_filename_io;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &locomx_read_proc;
-       new_file->write_proc = &locomx_write_proc;
-       new_file->nlink = 1;
-
-/*     No clock yet */
-/*
-       if ((new_file = create_proc_entry(FILENAME_CLOCK, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               return -EIO;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &locomx_read_proc;
-       new_file->write_proc = &locomx_write_proc;
-       new_file->nlink = 1;
-*/
-
-       ch->HW_access_board = NULL;
-       ch->HW_release_board = NULL;
-       ch->HW_txe = LOCOMX_txe;
-       ch->HW_open = LOCOMX_open;
-       ch->HW_close = LOCOMX_close;
-       ch->HW_send_packet = LOCOMX_send_packet;
-       ch->HW_statistics = LOCOMX_statistics;
-       ch->HW_set_clock = NULL;
-
-       ch->current_stats = &hw->board.chanA.stats;
-       memcpy(ch->current_stats, &ch->stats, sizeof(struct net_device_stats));
-
-       dev->base_addr = LOCOMX_DEFAULT_IO;
-       dev->irq = LOCOMX_DEFAULT_IRQ;
-       
-       
-       /* O.K. Count one more user on this module */
-       MOD_INC_USE_COUNT;
-       return 0;
-cleanup_filename_io:
-       remove_proc_entry(FILENAME_IO, ch->procdir);
-cleanup_HW_privdata:
-       kfree(ch->HW_privdata);
-       return -EIO;
-}
-
-
-static int LOCOMX_exit(struct net_device *dev)
-{
-       struct comx_channel *ch = netdev_priv(dev);
-
-       ch->HW_access_board = NULL;
-       ch->HW_release_board = NULL;
-       ch->HW_txe = NULL;
-       ch->HW_open = NULL;
-       ch->HW_close = NULL;
-       ch->HW_send_packet = NULL;
-       ch->HW_statistics = NULL;
-       ch->HW_set_clock = NULL;
-       memcpy(&ch->stats, ch->current_stats, sizeof(struct net_device_stats));
-       ch->current_stats = &ch->stats;
-
-       kfree(ch->HW_privdata);
-
-       remove_proc_entry(FILENAME_IO, ch->procdir);
-       remove_proc_entry(FILENAME_IRQ, ch->procdir);
-//     remove_proc_entry(FILENAME_CLOCK, ch->procdir);
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static struct comx_hardware locomx_hw = {
-       "locomx",
-       VERSION,
-       LOCOMX_init, 
-       LOCOMX_exit,
-       LOCOMX_dump,
-       NULL
-};
-       
-static int __init comx_hw_locomx_init(void)
-{
-       comx_register_hardware(&locomx_hw);
-       return 0;
-}
-
-static void __exit comx_hw_locomx_exit(void)
-{
-       comx_unregister_hardware("locomx");
-}
-
-module_init(comx_hw_locomx_init);
-module_exit(comx_hw_locomx_exit);
diff --git a/drivers/net/wan/comx-hw-mixcom.c b/drivers/net/wan/comx-hw-mixcom.c
deleted file mode 100644 (file)
index c6fb9ac..0000000
+++ /dev/null
@@ -1,960 +0,0 @@
-/* 
- * Hardware driver for the MixCom synchronous serial board 
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * based on skeleton driver code and a preliminary hscx driver by 
- * Tivadar Szemethy <tiv@itc.hu>
- *
- * Copyright (C) 1998-1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.65)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.60 (99/06/11):
- *             - ported to the kernel, now works as builtin code
- *
- * Version 0.61 (99/06/11):
- *             - recognize the one-channel MixCOM card (id byte = 0x13)
- *             - printk fixes
- * 
- * Version 0.62 (99/07/15):
- *             - fixes according to the new hw docs 
- *             - report line status when open
- *
- * Version 0.63 (99/09/21):
- *             - line status report fixes
- *
- * Version 0.64 (99/12/01):
- *             - some more cosmetical fixes
- *
- * Version 0.65 (00/08/15)
- *             - resource release on failure at MIXCOM_init
- */
-
-#define VERSION "0.65"
-
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/init.h>
-
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
-#include "comx.h"
-#include "mixcom.h"
-#include "hscx.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Hardware-level driver for the serial port of the MixCom board");
-MODULE_LICENSE("GPL");
-
-#define MIXCOM_DATA(d) ((struct mixcom_privdata *)(COMX_CHANNEL(d)-> \
-       HW_privdata))
-
-#define MIXCOM_BOARD_BASE(d) (d->base_addr - MIXCOM_SERIAL_OFFSET - \
-       (1 - MIXCOM_DATA(d)->channel) * MIXCOM_CHANNEL_OFFSET)
-
-#define MIXCOM_DEV_BASE(port,channel) (port + MIXCOM_SERIAL_OFFSET + \
-       (1 - channel) * MIXCOM_CHANNEL_OFFSET)
-
-/* Values used to set the IRQ line */
-static unsigned char mixcom_set_irq[]={0xFF, 0xFF, 0xFF, 0x0, 0xFF, 0x2, 0x4, 0x6, 0xFF, 0xFF, 0x8, 0xA, 0xC, 0xFF, 0xE, 0xFF};
-
-static unsigned char* hscx_versions[]={"A1", NULL, "A2", NULL, "A3", "2.1"};
-
-struct mixcom_privdata {
-       u16     clock;
-       char    channel;
-       long    txbusy;
-       struct sk_buff *sending;
-       unsigned tx_ptr;
-       struct sk_buff *recving;
-       unsigned rx_ptr;
-       unsigned char status;
-       char    card_has_status;
-};
-
-static inline void wr_hscx(struct net_device *dev, int reg, unsigned char val) 
-{
-       outb(val, dev->base_addr + reg);
-}
-
-static inline unsigned char rd_hscx(struct net_device *dev, int reg)
-{
-       return inb(dev->base_addr + reg);
-}
-
-static inline void hscx_cmd(struct net_device *dev, int cmd)
-{
-       unsigned long jiffs = jiffies;
-       unsigned char cec;
-       unsigned delay = 0;
-
-       while ((cec = (rd_hscx(dev, HSCX_STAR) & HSCX_CEC) != 0) && 
-           time_before(jiffies, jiffs + HZ)) {
-               udelay(1);
-               if (++delay > (100000 / HZ)) break;
-       }
-       if (cec) {
-               printk(KERN_WARNING "%s: CEC stuck, probably no clock!\n",dev->name);
-       } else {
-               wr_hscx(dev, HSCX_CMDR, cmd);
-       }
-}
-
-static inline void hscx_fill_fifo(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-       register word to_send = hw->sending->len - hw->tx_ptr;
-
-
-       outsb(dev->base_addr + HSCX_FIFO,
-               &(hw->sending->data[hw->tx_ptr]), min_t(unsigned int, to_send, 32));
-       if (to_send <= 32) {
-               hscx_cmd(dev, HSCX_XTF | HSCX_XME);
-               kfree_skb(hw->sending);
-               hw->sending = NULL; 
-               hw->tx_ptr = 0;
-        } else {
-               hscx_cmd(dev, HSCX_XTF);
-               hw->tx_ptr += 32;
-        }
-}
-
-static inline void hscx_empty_fifo(struct net_device *dev, int cnt)
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-
-       if (hw->recving == NULL) {
-               if (!(hw->recving = dev_alloc_skb(HSCX_MTU + 16))) {
-                       ch->stats.rx_dropped++;
-                       hscx_cmd(dev, HSCX_RHR);
-                } else {
-                       skb_reserve(hw->recving, 16);
-                       skb_put(hw->recving, HSCX_MTU);
-                }
-               hw->rx_ptr = 0;
-        }
-       if (cnt > 32 || !cnt || hw->recving == NULL) {
-               printk(KERN_ERR "hscx_empty_fifo: cnt is %d, hw->recving %p\n",
-                       cnt, (void *)hw->recving);
-               return;
-        }
-        
-       insb(dev->base_addr + HSCX_FIFO, &(hw->recving->data[hw->rx_ptr]),cnt);
-       hw->rx_ptr += cnt;
-       hscx_cmd(dev, HSCX_RMC);
-}
-
-
-static int MIXCOM_txe(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-
-       return !test_bit(0, &hw->txbusy);
-}
-
-static int mixcom_probe(struct net_device *dev)
-{
-       unsigned long flags;
-       int id, vstr, ret=0;
-
-       save_flags(flags); cli();
-
-       id=inb_p(MIXCOM_BOARD_BASE(dev) + MIXCOM_ID_OFFSET) & 0x7f;
-
-       if (id != MIXCOM_ID ) {
-               ret=-ENODEV;
-               printk(KERN_WARNING "%s: no MixCOM board found at 0x%04lx\n",dev->name, dev->base_addr);
-               goto out;
-       }
-
-       vstr=inb_p(dev->base_addr + HSCX_VSTR) & 0x0f;
-       if(vstr>=sizeof(hscx_versions)/sizeof(char*) || 
-           hscx_versions[vstr]==NULL) {
-               printk(KERN_WARNING "%s: board found but no HSCX chip detected at 0x%4lx (vstr = 0x%1x)\n",dev->name,dev->base_addr,vstr);
-               ret = -ENODEV;
-       } else {
-               printk(KERN_INFO "%s: HSCX chip version %s\n",dev->name,hscx_versions[vstr]);
-               ret = 0;
-       }
-
-out:
-
-       restore_flags(flags);
-       return ret;
-}
-
-#if 0
-static void MIXCOM_set_clock(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-
-       if (hw->clock) {
-               ;
-       } else {
-               ;
-       }
-}
-#endif
-
-static void mixcom_board_on(struct net_device *dev)
-{
-       outb_p(MIXCOM_OFF , MIXCOM_BOARD_BASE(dev) + MIXCOM_IT_OFFSET);
-       udelay(1000);
-       outb_p(mixcom_set_irq[dev->irq] | MIXCOM_ON, 
-               MIXCOM_BOARD_BASE(dev) + MIXCOM_IT_OFFSET);
-       udelay(1000);
-}
-
-static void mixcom_board_off(struct net_device *dev)
-{
-       outb_p(MIXCOM_OFF , MIXCOM_BOARD_BASE(dev) + MIXCOM_IT_OFFSET);
-       udelay(1000);
-}
-
-static void mixcom_off(struct net_device *dev)
-{
-       wr_hscx(dev, HSCX_CCR1, 0x0);
-}
-
-static void mixcom_on(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       wr_hscx(dev, HSCX_CCR1, HSCX_PU | HSCX_ODS | HSCX_ITF); // power up, push-pull
-       wr_hscx(dev, HSCX_CCR2, HSCX_CIE /* | HSCX_RIE */ );
-       wr_hscx(dev, HSCX_MODE, HSCX_TRANS | HSCX_ADM8 | HSCX_RAC | HSCX_RTS );
-       wr_hscx(dev, HSCX_RLCR, HSCX_RC | 47); // 1504 bytes
-       wr_hscx(dev, HSCX_MASK, HSCX_RSC | HSCX_TIN );
-       hscx_cmd(dev, HSCX_XRES | HSCX_RHR);
-
-       if (ch->HW_set_clock) ch->HW_set_clock(dev);
-
-}
-
-static int MIXCOM_send_packet(struct net_device *dev, struct sk_buff *skb) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-       unsigned long flags;
-
-       if (ch->debug_flags & DEBUG_HW_TX) {
-               comx_debug_bytes(dev, skb->data, skb->len, "MIXCOM_send_packet");
-       }
-
-       if (!(ch->line_status & LINE_UP)) {
-               return FRAME_DROPPED;
-       }
-
-       if (skb->len > HSCX_MTU) {
-               ch->stats.tx_errors++;  
-               return FRAME_ERROR;
-       }
-
-       save_flags(flags); cli();
-
-       if (test_and_set_bit(0, &hw->txbusy)) {
-               printk(KERN_ERR "%s: transmitter called while busy... dropping frame (length %d)\n", dev->name, skb->len);
-               restore_flags(flags);
-               return FRAME_DROPPED;
-       }
-
-
-       hw->sending = skb;
-       hw->tx_ptr = 0;
-       hw->txbusy = 1;
-//     atomic_inc(&skb->users);        // save it
-       hscx_fill_fifo(dev);
-       restore_flags(flags);
-
-       ch->stats.tx_packets++;
-       ch->stats.tx_bytes += skb->len; 
-
-       if (ch->debug_flags & DEBUG_HW_TX) {
-               comx_debug(dev, "MIXCOM_send_packet was successful\n\n");
-       }
-
-       return FRAME_ACCEPTED;
-}
-
-static inline void mixcom_receive_frame(struct net_device *dev) 
-{
-       struct comx_channel *ch=dev->priv;
-       struct mixcom_privdata *hw=ch->HW_privdata;
-       register byte rsta;
-       register word length;
-
-       rsta = rd_hscx(dev, HSCX_RSTA) & (HSCX_VFR | HSCX_RDO | 
-               HSCX_CRC | HSCX_RAB);
-       length = ((rd_hscx(dev, HSCX_RBCH) & 0x0f) << 8) | 
-               rd_hscx(dev, HSCX_RBCL);
-
-       if ( length > hw->rx_ptr ) {
-               hscx_empty_fifo(dev, length - hw->rx_ptr);
-       }
-       
-       if (!(rsta & HSCX_VFR)) {
-               ch->stats.rx_length_errors++;
-       }
-       if (rsta & HSCX_RDO) {
-               ch->stats.rx_over_errors++;
-       }
-       if (!(rsta & HSCX_CRC)) {
-               ch->stats.rx_crc_errors++;
-       }
-       if (rsta & HSCX_RAB) {
-               ch->stats.rx_frame_errors++;
-       }
-       ch->stats.rx_packets++; 
-       ch->stats.rx_bytes += length;
-
-       if (rsta == (HSCX_VFR | HSCX_CRC) && hw->recving) {
-               skb_trim(hw->recving, hw->rx_ptr - 1);
-               if (ch->debug_flags & DEBUG_HW_RX) {
-                       comx_debug_skb(dev, hw->recving,
-                               "MIXCOM_interrupt receiving");
-               }
-               hw->recving->dev = dev;
-               if (ch->LINE_rx) {
-                       ch->LINE_rx(dev, hw->recving);
-               }
-       }
-       else if(hw->recving) {
-               kfree_skb(hw->recving);
-       }
-       hw->recving = NULL; 
-       hw->rx_ptr = 0;
-}
-
-
-static inline void mixcom_extended_interrupt(struct net_device *dev) 
-{
-       struct comx_channel *ch=dev->priv;
-       struct mixcom_privdata *hw=ch->HW_privdata;
-       register byte exir;
-
-       exir = rd_hscx(dev, HSCX_EXIR) & (HSCX_XDU | HSCX_RFO | HSCX_CSC );
-
-       if (exir & HSCX_RFO) {
-               ch->stats.rx_over_errors++;
-               if (hw->rx_ptr) {
-                       kfree_skb(hw->recving);
-                       hw->recving = NULL; hw->rx_ptr = 0;
-               }
-               printk(KERN_ERR "MIXCOM: rx overrun\n");
-               hscx_cmd(dev, HSCX_RHR);
-       }
-
-       if (exir & HSCX_XDU) { // xmit underrun
-               ch->stats.tx_errors++;
-               ch->stats.tx_aborted_errors++;
-               if (hw->tx_ptr) {
-                       kfree_skb(hw->sending);
-                       hw->sending = NULL; 
-                       hw->tx_ptr = 0;
-               }
-               hscx_cmd(dev, HSCX_XRES);
-               clear_bit(0, &hw->txbusy);
-               if (ch->LINE_tx) {
-                       ch->LINE_tx(dev);
-               }
-               printk(KERN_ERR "MIXCOM: tx underrun\n");
-       }
-
-       if (exir & HSCX_CSC) {        
-               ch->stats.tx_carrier_errors++;
-               if ((rd_hscx(dev, HSCX_STAR) & HSCX_CTS) == 0) { // Vonal le
-                       if (test_and_clear_bit(0, &ch->lineup_pending)) {
-                                       del_timer(&ch->lineup_timer);
-                       } else if (ch->line_status & LINE_UP) {
-                               ch->line_status &= ~LINE_UP;
-                               if (ch->LINE_status) {
-                                       ch->LINE_status(dev,ch->line_status);
-                               }
-                       }
-               }
-               if (!(ch->line_status & LINE_UP) && (rd_hscx(dev, HSCX_STAR) & 
-                   HSCX_CTS)) { // Vonal fol
-                       if (!test_and_set_bit(0,&ch->lineup_pending)) {
-                               ch->lineup_timer.function = comx_lineup_func;
-                               ch->lineup_timer.data = (unsigned long)dev;
-                               ch->lineup_timer.expires = jiffies + HZ * 
-                                       ch->lineup_delay;
-                               add_timer(&ch->lineup_timer);
-                               hscx_cmd(dev, HSCX_XRES);
-                               clear_bit(0, &hw->txbusy);
-                               if (hw->sending) {
-                                       kfree_skb(hw->sending);
-                               }
-                               hw->sending=NULL;
-                               hw->tx_ptr = 0;
-                       }
-               }
-       }
-}
-
-
-static irqreturn_t MIXCOM_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       unsigned long flags;
-       struct net_device *dev = (struct net_device *)dev_id;
-       struct comx_channel *ch, *twin_ch;
-       struct mixcom_privdata *hw, *twin_hw;
-       register unsigned char ista;
-
-       if (dev==NULL) {
-               printk(KERN_ERR "comx_interrupt: irq %d for unknown device\n",irq);
-               return IRQ_NONE;
-       }
-
-       ch = dev->priv; 
-       hw = ch->HW_privdata;
-
-       save_flags(flags); cli(); 
-
-       while((ista = (rd_hscx(dev, HSCX_ISTA) & (HSCX_RME | HSCX_RPF | 
-           HSCX_XPR | HSCX_EXB | HSCX_EXA | HSCX_ICA)))) {
-               register byte ista2 = 0;
-
-               if (ista & HSCX_RME) {
-                       mixcom_receive_frame(dev);
-               }
-               if (ista & HSCX_RPF) {
-                       hscx_empty_fifo(dev, 32);
-               }
-               if (ista & HSCX_XPR) {
-                       if (hw->tx_ptr) {
-                               hscx_fill_fifo(dev);
-                       } else {
-                               clear_bit(0, &hw->txbusy);
-                                       ch->LINE_tx(dev);
-                       }
-               }
-               
-               if (ista & HSCX_EXB) {
-                       mixcom_extended_interrupt(dev);
-               }
-               
-               if ((ista & HSCX_EXA) && ch->twin)  {
-                       mixcom_extended_interrupt(ch->twin);
-               }
-       
-               if ((ista & HSCX_ICA) && ch->twin &&
-                   (ista2 = rd_hscx(ch->twin, HSCX_ISTA) &
-                   (HSCX_RME | HSCX_RPF | HSCX_XPR ))) {
-                       if (ista2 & HSCX_RME) {
-                               mixcom_receive_frame(ch->twin);
-                       }
-                       if (ista2 & HSCX_RPF) {
-                               hscx_empty_fifo(ch->twin, 32);
-                       }
-                       if (ista2 & HSCX_XPR) {
-                               twin_ch=ch->twin->priv;
-                               twin_hw=twin_ch->HW_privdata;
-                               if (twin_hw->tx_ptr) {
-                                       hscx_fill_fifo(ch->twin);
-                               } else {
-                                       clear_bit(0, &twin_hw->txbusy);
-                                       ch->LINE_tx(ch->twin);
-                               }
-                       }
-               }
-       }
-
-       restore_flags(flags);
-       return IRQ_HANDLED;
-}
-
-static int MIXCOM_open(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-       struct proc_dir_entry *procfile = ch->procdir->subdir;
-       unsigned long flags; 
-       int ret = -ENODEV;
-
-       if (!dev->base_addr || !dev->irq)
-               goto err_ret;
-
-
-       if(hw->channel==1) {
-               if(!TWIN(dev) || !(COMX_CHANNEL(TWIN(dev))->init_status & 
-                   IRQ_ALLOCATED)) {
-                       printk(KERN_ERR "%s: channel 0 not yet initialized\n",dev->name);
-                       ret = -EAGAIN;
-                       goto err_ret;
-               }
-       }
-
-
-       /* Is our hw present at all ? Not checking for channel 0 if it is already 
-          open */
-       if(hw->channel!=0 || !(ch->init_status & IRQ_ALLOCATED)) {
-               if (!request_region(dev->base_addr, MIXCOM_IO_EXTENT, dev->name)) {
-                       ret = -EAGAIN;
-                       goto err_ret;
-               }
-               if (mixcom_probe(dev)) {
-                       ret = -ENODEV;
-                       goto err_release_region;
-               }
-       }
-
-       if(hw->channel==0 && !(ch->init_status & IRQ_ALLOCATED)) {
-               if (request_irq(dev->irq, MIXCOM_interrupt, 0, 
-                   dev->name, (void *)dev)) {
-                       printk(KERN_ERR "MIXCOM: unable to obtain irq %d\n", dev->irq);
-                       ret = -EAGAIN;
-                       goto err_release_region;
-               }
-       }
-
-       save_flags(flags); cli();
-
-       if(hw->channel==0 && !(ch->init_status & IRQ_ALLOCATED)) {
-               ch->init_status|=IRQ_ALLOCATED;
-               mixcom_board_on(dev);
-       }
-
-       mixcom_on(dev);
-
-
-       hw->status=inb(MIXCOM_BOARD_BASE(dev) + MIXCOM_STATUS_OFFSET);
-       if(hw->status != 0xff) {
-               printk(KERN_DEBUG "%s: board has status register, good\n", dev->name);
-               hw->card_has_status=1;
-       }
-
-       hw->txbusy = 0;
-       ch->init_status |= HW_OPEN;
-       
-       if (rd_hscx(dev, HSCX_STAR) & HSCX_CTS) {
-               ch->line_status |= LINE_UP;
-       } else {
-               ch->line_status &= ~LINE_UP;
-       }
-
-       restore_flags(flags);
-
-       ch->LINE_status(dev, ch->line_status);
-
-       for (; procfile ; procfile = procfile->next) {
-               if (strcmp(procfile->name, FILENAME_IO) == 0 ||
-                   strcmp(procfile->name, FILENAME_CHANNEL) == 0 ||
-                   strcmp(procfile->name, FILENAME_CLOCK) == 0 ||
-                   strcmp(procfile->name, FILENAME_IRQ) == 0) {
-                       procfile->mode = S_IFREG |  0444;
-               }
-       }
-
-       return 0;
-       
-err_release_region:
-       release_region(dev->base_addr, MIXCOM_IO_EXTENT);
-err_ret:
-       return ret;
-}
-
-static int MIXCOM_close(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-       struct proc_dir_entry *procfile = ch->procdir->subdir;
-       unsigned long flags;
-
-
-       save_flags(flags); cli();
-
-       mixcom_off(dev);
-
-       /* This is channel 0, twin is not open, we can safely turn off everything */
-       if(hw->channel==0 && (!(TWIN(dev)) || 
-           !(COMX_CHANNEL(TWIN(dev))->init_status & HW_OPEN))) {
-               mixcom_board_off(dev);
-               free_irq(dev->irq, dev);
-               release_region(dev->base_addr, MIXCOM_IO_EXTENT);
-               ch->init_status &= ~IRQ_ALLOCATED;
-       }
-
-       /* This is channel 1, channel 0 has already been shutdown, we can release
-          this one too */
-       if(hw->channel==1 && !(COMX_CHANNEL(TWIN(dev))->init_status & HW_OPEN)) {
-               if(COMX_CHANNEL(TWIN(dev))->init_status & IRQ_ALLOCATED) {
-                       mixcom_board_off(TWIN(dev));
-                       free_irq(TWIN(dev)->irq, TWIN(dev));
-                       release_region(TWIN(dev)->base_addr, MIXCOM_IO_EXTENT);
-                       COMX_CHANNEL(TWIN(dev))->init_status &= ~IRQ_ALLOCATED;
-               }
-       }
-
-       /* the ioports for channel 1 can be safely released */
-       if(hw->channel==1) {
-               release_region(dev->base_addr, MIXCOM_IO_EXTENT);
-       }
-
-       restore_flags(flags);
-
-       /* If we don't hold any hardware open */
-       if(!(ch->init_status & IRQ_ALLOCATED)) {
-               for (; procfile ; procfile = procfile->next) {
-                       if (strcmp(procfile->name, FILENAME_IO) == 0 ||
-                           strcmp(procfile->name, FILENAME_CHANNEL) == 0 ||
-                           strcmp(procfile->name, FILENAME_CLOCK) == 0 ||
-                           strcmp(procfile->name, FILENAME_IRQ) == 0) {
-                               procfile->mode = S_IFREG |  0644;
-                       }
-               }
-       }
-
-       /* channel 0 was only waiting for us to close channel 1 
-          close it completely */
-   
-       if(hw->channel==1 && !(COMX_CHANNEL(TWIN(dev))->init_status & HW_OPEN)) {
-               for (procfile=COMX_CHANNEL(TWIN(dev))->procdir->subdir; 
-                   procfile ; procfile = procfile->next) {
-                       if (strcmp(procfile->name, FILENAME_IO) == 0 ||
-                           strcmp(procfile->name, FILENAME_CHANNEL) == 0 ||
-                           strcmp(procfile->name, FILENAME_CLOCK) == 0 ||
-                           strcmp(procfile->name, FILENAME_IRQ) == 0) {
-                               procfile->mode = S_IFREG |  0644;
-                       }
-               }
-       }
-       
-       ch->init_status &= ~HW_OPEN;
-       return 0;
-}
-
-static int MIXCOM_statistics(struct net_device *dev,char *page)
-{
-       struct comx_channel *ch = dev->priv;
-       // struct mixcom_privdata *hw = ch->HW_privdata;
-       int len = 0;
-
-       if(ch->init_status && IRQ_ALLOCATED) {
-               len += sprintf(page + len, "Mixcom board: hardware open\n");
-       }
-
-       return len;
-}
-
-static int MIXCOM_dump(struct net_device *dev) {
-       return 0;
-}
-
-static int mixcom_read_proc(char *page, char **start, off_t off, int count,
-       int *eof, void *data)
-{
-       struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-       struct net_device *dev = file->parent->data;
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-       int len = 0;
-
-       if (strcmp(file->name, FILENAME_IO) == 0) {
-               len = sprintf(page, "0x%x\n", 
-                       (unsigned int)MIXCOM_BOARD_BASE(dev));
-       } else if (strcmp(file->name, FILENAME_IRQ) == 0) {
-               len = sprintf(page, "%d\n", (unsigned int)dev->irq);
-       } else if (strcmp(file->name, FILENAME_CLOCK) == 0) {
-               if (hw->clock) len = sprintf(page, "%d\n", hw->clock);
-                       else len = sprintf(page, "external\n");
-       } else if (strcmp(file->name, FILENAME_CHANNEL) == 0) {
-               len = sprintf(page, "%01d\n", hw->channel);
-       } else if (strcmp(file->name, FILENAME_TWIN) == 0) {
-               if (ch->twin) {
-                       len = sprintf(page, "%s\n",ch->twin->name);
-               } else {
-                       len = sprintf(page, "none\n");
-               }
-       } else {
-               printk(KERN_ERR "mixcom_read_proc: internal error, filename %s\n", file->name);
-               return -EBADF;
-       }
-
-       if (off >= len) {
-               *eof = 1;
-               return 0;
-       }
-       *start = page + off;
-       if (count >= len - off) *eof = 1;
-       return min_t(int, count, len - off);
-}
-
-
-static struct net_device *mixcom_twin_check(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct proc_dir_entry *procfile = ch->procdir->parent->subdir;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-
-       struct net_device *twin;
-       struct comx_channel *ch_twin;
-       struct mixcom_privdata *hw_twin;
-
-
-       for ( ; procfile ; procfile = procfile->next) {
-               if(!S_ISDIR(procfile->mode)) continue;
-                
-               twin = procfile->data;
-               ch_twin = twin->priv;
-               hw_twin = ch_twin->HW_privdata;
-
-
-               if (twin != dev && dev->irq && dev->base_addr && 
-                   dev->irq == twin->irq && 
-                   ch->hardware == ch_twin->hardware &&
-                   dev->base_addr == twin->base_addr + 
-                   (1-2*hw->channel)*MIXCOM_CHANNEL_OFFSET &&
-                   hw->channel == (1 - hw_twin->channel)) {
-                       if  (!TWIN(twin) || TWIN(twin)==dev) {
-                               return twin;
-                       }
-               }
-        }
-       return NULL;
-}
-
-
-static void setup_twin(struct net_device* dev) 
-{
-
-       if(TWIN(dev) && TWIN(TWIN(dev))) {
-               TWIN(TWIN(dev))=NULL;
-       }
-       if ((TWIN(dev) = mixcom_twin_check(dev)) != NULL) {
-               if (TWIN(TWIN(dev)) && TWIN(TWIN(dev)) != dev) {
-                       TWIN(dev)=NULL;
-               } else {
-                       TWIN(TWIN(dev))=dev;
-               }
-       }       
-}
-
-static int mixcom_write_proc(struct file *file, const char *buffer,
-       u_long count, void *data)
-{
-       struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
-       struct net_device *dev = (struct net_device *)entry->parent->data;
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-       char *page;
-       int value;
-
-       if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
-               return -ENOMEM;
-       }
-
-       if (copy_from_user(page, buffer, count = min_t(unsigned long, count, PAGE_SIZE))) {
-               free_page((unsigned long)page);
-               return -EFAULT;
-       }
-       if (*(page + count - 1) == '\n') {
-               *(page + count - 1) = 0;
-       }
-
-       if (strcmp(entry->name, FILENAME_IO) == 0) {
-               value = simple_strtoul(page, NULL, 0);
-               if (value != 0x180 && value != 0x280 && value != 0x380) {
-                       printk(KERN_ERR "MIXCOM: incorrect io address!\n");
-               } else {
-                       dev->base_addr = MIXCOM_DEV_BASE(value,hw->channel);
-               }
-       } else if (strcmp(entry->name, FILENAME_IRQ) == 0) {
-               value = simple_strtoul(page, NULL, 0); 
-               if (value < 0 || value > 15 || mixcom_set_irq[value]==0xFF) {
-                       printk(KERN_ERR "MIXCOM: incorrect irq value!\n");
-               } else {
-                       dev->irq = value;       
-               }
-       } else if (strcmp(entry->name, FILENAME_CLOCK) == 0) {
-               if (strncmp("ext", page, 3) == 0) {
-                       hw->clock = 0;
-               } else {
-                       int kbps;
-
-                       kbps = simple_strtoul(page, NULL, 0);
-                       if (!kbps) {
-                               hw->clock = 0;
-                       } else {
-                               hw->clock = kbps;
-                       }
-                       if (hw->clock < 32 || hw->clock > 2000) {
-                               hw->clock = 0;
-                               printk(KERN_ERR "MIXCOM: invalid clock rate!\n");
-                       }
-               }
-               if (ch->init_status & HW_OPEN && ch->HW_set_clock) {
-                       ch->HW_set_clock(dev);
-               }
-       } else if (strcmp(entry->name, FILENAME_CHANNEL) == 0) {
-               value = simple_strtoul(page, NULL, 0);
-               if (value > 2) {
-                       printk(KERN_ERR "Invalid channel number\n");
-               } else {
-                       dev->base_addr+=(hw->channel - value) * MIXCOM_CHANNEL_OFFSET;
-                       hw->channel = value;
-               }               
-       } else {
-               printk(KERN_ERR "hw_read_proc: internal error, filename %s\n", 
-                       entry->name);
-               return -EBADF;
-       }
-
-       setup_twin(dev);
-
-       free_page((unsigned long)page);
-       return count;
-}
-
-static int MIXCOM_init(struct net_device *dev) {
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw;
-       struct proc_dir_entry *new_file;
-
-       if ((ch->HW_privdata = kmalloc(sizeof(struct mixcom_privdata), 
-           GFP_KERNEL)) == NULL) {
-               return -ENOMEM;
-       }
-
-       memset(hw = ch->HW_privdata, 0, sizeof(struct mixcom_privdata));
-
-       if ((new_file = create_proc_entry(FILENAME_IO, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_HW_privdata;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &mixcom_read_proc;
-       new_file->write_proc = &mixcom_write_proc;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_IRQ, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_filename_io;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &mixcom_read_proc;
-       new_file->write_proc = &mixcom_write_proc;
-       new_file->nlink = 1;
-
-#if 0
-       if ((new_file = create_proc_entry(FILENAME_CLOCK, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               return -EIO;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &mixcom_read_proc;
-       new_file->write_proc = &mixcom_write_proc;
-       new_file->nlink = 1;
-#endif
-
-       if ((new_file = create_proc_entry(FILENAME_CHANNEL, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_filename_irq;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &mixcom_read_proc;
-       new_file->write_proc = &mixcom_write_proc;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_TWIN, S_IFREG | 0444, 
-           ch->procdir)) == NULL) {
-               goto cleanup_filename_channel;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &mixcom_read_proc;
-       new_file->write_proc = &mixcom_write_proc;
-       new_file->nlink = 1;
-
-       setup_twin(dev);
-
-       /* Fill in ch_struct hw specific pointers */
-       ch->HW_access_board = NULL;
-       ch->HW_release_board = NULL;
-       ch->HW_txe = MIXCOM_txe;
-       ch->HW_open = MIXCOM_open;
-       ch->HW_close = MIXCOM_close;
-       ch->HW_send_packet = MIXCOM_send_packet;
-       ch->HW_statistics = MIXCOM_statistics;
-       ch->HW_set_clock = NULL;
-
-       dev->base_addr = MIXCOM_DEV_BASE(MIXCOM_DEFAULT_IO,0);
-       dev->irq = MIXCOM_DEFAULT_IRQ;
-
-       MOD_INC_USE_COUNT;
-       return 0;
-cleanup_filename_channel:
-       remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
-cleanup_filename_irq:
-       remove_proc_entry(FILENAME_IRQ, ch->procdir);
-cleanup_filename_io:
-       remove_proc_entry(FILENAME_IO, ch->procdir);
-cleanup_HW_privdata:
-       kfree(ch->HW_privdata);
-       return -EIO;
-}
-
-static int MIXCOM_exit(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct mixcom_privdata *hw = ch->HW_privdata;
-
-       if(hw->channel==0 && TWIN(dev)) {
-               return -EBUSY;
-       }
-
-       if(hw->channel==1 && TWIN(dev)) {
-               TWIN(TWIN(dev))=NULL;
-       }
-
-       kfree(ch->HW_privdata);
-       remove_proc_entry(FILENAME_IO, ch->procdir);
-       remove_proc_entry(FILENAME_IRQ, ch->procdir);
-#if 0
-       remove_proc_entry(FILENAME_CLOCK, ch->procdir);
-#endif
-       remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
-       remove_proc_entry(FILENAME_TWIN, ch->procdir);
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static struct comx_hardware mixcomhw = {
-       "mixcom",
-       VERSION,
-       MIXCOM_init, 
-       MIXCOM_exit,
-       MIXCOM_dump,
-       NULL
-};
-       
-static int __init comx_hw_mixcom_init(void)
-{
-       return comx_register_hardware(&mixcomhw);
-}
-
-static void __exit comx_hw_mixcom_exit(void)
-{
-       comx_unregister_hardware("mixcom");
-}
-
-module_init(comx_hw_mixcom_init);
-module_exit(comx_hw_mixcom_exit);
diff --git a/drivers/net/wan/comx-hw-munich.c b/drivers/net/wan/comx-hw-munich.c
deleted file mode 100644 (file)
index 195bc2d..0000000
+++ /dev/null
@@ -1,2854 +0,0 @@
-/*
- * Hardware-level driver for the SliceCOM board for Linux kernels 2.4.X
- *
- * Current maintainer / latest changes: Pasztor Szilard <don@itc.hu>
- *
- * Original author: Bartok Istvan <bartoki@itc.hu>
- * Based on skeleton by Tivadar Szemethy <tiv@itc.hu>
- *
- * 0.51:
- *      - port for 2.4.x
- *     - clean up some code, make it more portable
- *     - busted direct hardware access through mapped memory
- *     - fix a possible race
- *     - prevent procfs buffer overflow
- *
- * 0.50:
- *     - support for the pcicom board, lots of rearrangements
- *     - handle modem status lines
- *
- * 0.50a:
- *     - fix for falc version 1.0
- *
- * 0.50b: T&t
- *     - fix for bad localbus
- */
-
-#define VERSION                "0.51"
-#define VERSIONSTR     "SliceCOM v" VERSION ", 2002/01/07\n"
-
-#include <linux/config.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-#include <asm/delay.h>
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
-#define COMX_NEW
-
-#ifndef COMX_NEW
-#include "../include/comx.h"
-#include "../include/munich32x.h"
-#include "../include/falc-lh.h"
-#else
-#include "comx.h"
-#include "munich32x.h"
-#include "falc-lh.h"
-#endif
-
-MODULE_AUTHOR("Bartok Istvan <bartoki@itc.hu>, Gergely Madarasz <gorgo@itc.hu>, Szilard Pasztor <don@itc.hu>");
-MODULE_DESCRIPTION("Hardware-level driver for the SliceCOM and PciCOM (WelCOM) adapters");
-MODULE_LICENSE("GPL");
-/*
- *     TODO: az ilyenek a comxhw.h -ban szoktak lenni, idovel menjenek majd oda:
- */
-
-#define FILENAME_BOARDNUM      "boardnum"      /* /proc/comx/comx0.1/boardnum          */
-#define FILENAME_TIMESLOTS     "timeslots"     /* /proc/comx/comx0.1/timeslots         */
-#define FILENAME_FRAMING       "framing"       /* /proc/comx/comx0.1/framing           */
-#define FILENAME_LINECODE      "linecode"      /* /proc/comx/comx0.1/linecode          */
-#define FILENAME_CLOCK_SOURCE  "clock_source"  /* /proc/comx/comx0.1/clock_source      */
-#define FILENAME_LOOPBACK      "loopback"      /* /proc/comx/comx0.1/loopback          */
-#define FILENAME_REG           "reg"           /* /proc/comx/comx0.1/reg               */
-#define FILENAME_LBIREG                "lbireg"        /* /proc/comx/comx0.1/lbireg            */
-
-#define SLICECOM_BOARDNUM_DEFAULT      0
-
-#define SLICECOM_FRAMING_CRC4          1
-#define SLICECOM_FRAMING_NO_CRC4       2
-#define SLICECOM_FRAMING_DEFAULT       SLICECOM_FRAMING_CRC4
-
-#define SLICECOM_LINECODE_HDB3         1
-#define SLICECOM_LINECODE_AMI          2
-#define SLICECOM_LINECODE_DEFAULT      SLICECOM_LINECODE_HDB3
-
-#define SLICECOM_CLOCK_SOURCE_LINE     1
-#define SLICECOM_CLOCK_SOURCE_INTERNAL 2
-#define SLICECOM_CLOCK_SOURCE_DEFAULT  SLICECOM_CLOCK_SOURCE_LINE
-
-#define SLICECOM_LOOPBACK_NONE         1
-#define SLICECOM_LOOPBACK_LOCAL                2
-#define SLICECOM_LOOPBACK_REMOTE       3
-#define SLICECOM_LOOPBACK_DEFAULT      SLICECOM_LOOPBACK_NONE
-
-#define MUNICH_VIRT(addr) (void *)(&bar1[addr])
-
-struct slicecom_stringtable
-{
-    char *name;
-    int value;
-};
-
-/* A convention: keep "default" the last not NULL when reading from /proc,
-   "error" is an indication that something went wrong, we have an undefined value */
-
-struct slicecom_stringtable slicecom_framings[] =
-{
-    {"crc4", SLICECOM_FRAMING_CRC4},
-    {"no-crc4", SLICECOM_FRAMING_NO_CRC4},
-    {"default", SLICECOM_FRAMING_DEFAULT},
-    {"error", 0}
-};
-
-struct slicecom_stringtable slicecom_linecodes[] =
-{
-    {"hdb3", SLICECOM_LINECODE_HDB3},
-    {"ami", SLICECOM_LINECODE_AMI},
-    {"default", SLICECOM_LINECODE_DEFAULT},
-    {"error", 0}
-};
-
-struct slicecom_stringtable slicecom_clock_sources[] =
-{
-    {"line", SLICECOM_CLOCK_SOURCE_LINE},
-    {"internal", SLICECOM_CLOCK_SOURCE_INTERNAL},
-    {"default", SLICECOM_CLOCK_SOURCE_DEFAULT},
-    {"error", 0}
-};
-
-struct slicecom_stringtable slicecom_loopbacks[] =
-{
-    {"none", SLICECOM_LOOPBACK_NONE},
-    {"local", SLICECOM_LOOPBACK_LOCAL},
-    {"remote", SLICECOM_LOOPBACK_REMOTE},
-    {"default", SLICECOM_LOOPBACK_DEFAULT},
-    {"error", 0}
-};
-
-/*
- *     Some tunable values...
- *
- *     Note: when tuning values which change the length of text in
- *     /proc/comx/comx[n]/status, keep in mind that it must be shorter then
- *     PAGESIZE !
- */
-
-#define MAX_BOARDS     4       /* ezzel 4 kartya lehet a gepben: 0..3          */
-#define RX_DESC_MAX    8       /* Rx ring size, must be >= 4                   */
-#define TX_DESC_MAX    4       /* Tx ring size, must be >= 2                   */
-                               /* a sokkal hosszabb Tx ring mar ronthatja a nem-FIFO packet    */
-                               /* schedulerek (fair queueing, stb.) hatekonysagat.             */
-#define MAX_WORK       10      /* TOD: update the info max. ennyi-1 esemenyt dolgoz fel egy interrupt hivasnal */
-
-/*
- *     These are tunable too, but don't touch them without fully understanding what is happening
- */
-
-#define UDELAY         20      /* We wait UDELAY usecs with disabled interrupts before and     */
-                               /* after each command to avoid writing into each other's        */
-                               /* ccb->action_spec. A _send_packet nem var, mert azt az        */
-                               /* _interrupt()-bol is meghivhatja a LINE_tx()                  */
-
-/*
- *     Just to avoid warnings about implicit declarations:
- */
-
-static int MUNICH_close(struct net_device *dev);
-static struct comx_hardware slicecomhw;
-static struct comx_hardware pcicomhw;
-
-static unsigned long flags;
-static spinlock_t mister_lock = SPIN_LOCK_UNLOCKED;
-
-typedef volatile struct                /* Time Slot Assignment */
-{
-    u32 rxfillmask:8,          // ----------------------------+------+
-                               //                             |      |
-      rxchannel:5,             // ----------------------+---+ |      |
-      rti:1,                   // ---------------------+|   | |      |
-      res2:2,                  // -------------------++||   | |      |
-                               //                    ||||   | |      |
-      txfillmask:8,            // ----------+------+ ||||   | |      |
-                               //           |      | ||||   | |      |
-      txchannel:5,             // ----+---+ |      | ||||   | |      |
-      tti:1,                   // ---+|   | |      | ||||   | |      |
-      res1:2;                  // -++||   | |      | ||||   | |      |
-                               //   3          2          1
-                               //  10987654 32109876 54321098 76543210
-} timeslot_spec_t;
-
-typedef volatile struct                /* Receive Descriptor */
-{
-    u32 zero1:16, no:13, hi:1, hold:1, zero2:1;
-
-    u32 next;
-    u32 data;
-
-    u32 zero3:8, status:8, bno:13, zero4:1, c:1, fe:1;
-} rx_desc_t;
-
-typedef volatile struct                /* Transmit Descriptor */
-{
-    u32 fnum:11, csm:1, no13:1, zero1:2, v110:1, no:13, hi:1, hold:1, fe:1;
-
-    u32 next;
-    u32 data;
-
-} tx_desc_t;
-
-typedef volatile struct                /* Channel Specification */
-{
-    u32 iftf:1, mode:2, fa:1, trv:2, crc:1, inv:1, cs:1, tflag:7, ra:1, ro:1,
-       th:1, ta:1, to:1, ti:1, ri:1, nitbs:1, fit:1, fir:1, re:1, te:1, ch:1,
-       ifc:1, sfe:1, fe2:1;
-
-    u32 frda;
-    u32 ftda;
-
-    u32 itbs:6, zero1:26;
-
-} channel_spec_t;
-
-typedef volatile struct                /* Configuration Control Block */
-{
-    u32 action_spec;
-    u32 reserved1;
-    u32 reserved2;
-    timeslot_spec_t timeslot_spec[32];
-    channel_spec_t channel_spec[32];
-    u32 current_rx_desc[32];
-    u32 current_tx_desc[32];
-    u32 csa;                   /* Control Start Address. CSA = *CCBA; CCB = *CSA */
-                               /* MUNICH does it like: CCB = *( *CCBA )          */
-} munich_ccb_t;
-
-typedef volatile struct                /* Entry in the interrupt queue */
-{
-    u32 all;
-} munich_intq_t;
-
-#define MUNICH_INTQLEN 63      /* Rx/Tx Interrupt Queue Length
-                                  (not the real len, but the TIQL/RIQL value)  */
-#define MUNICH_INTQMAX ( 16*(MUNICH_INTQLEN+1) )       /* Rx/Tx/Periph Interrupt Queue size in munich_intq_t's */
-#define MUNICH_INTQSIZE        ( 4*MUNICH_INTQMAX )    /* Rx/Tx/Periph Interrupt Queue size in bytes           */
-
-#define MUNICH_PIQLEN  4       /* Peripheral Interrupt Queue Length. Unlike the RIQL/TIQL, */
-#define MUNICH_PIQMAX  ( 4*MUNICH_PIQLEN )     /* PIQL register needs it like this                     */
-#define MUNICH_PIQSIZE ( 4*MUNICH_PIQMAX )
-
-typedef volatile u32 vol_u32;  /* TOD: ezek megszunnek ha atirom readw()/writew()-re - kész */
-typedef volatile u8 vol_u8;
-
-typedef volatile struct                /* counters of E1-errors and errored seconds, see rfc2495 */
-{
-    /* use here only unsigned ints, we depend on it when calculating the sum for the last N intervals */
-
-    unsigned line_code_violations,     /* AMI: bipolar violations, HDB3: hdb3 violations                       */
-      path_code_violations,    /* FAS errors and CRC4 errors                                                   */
-      e_bit_errors,            /* E-Bit Errors (the remote side received from us with CRC4-error) */
-      slip_secs,               /* number of seconds with (receive) Controlled Slip(s)          */
-      fr_loss_secs,            /* number of seconds an Out Of Frame defect was detected                */
-      line_err_secs,           /* number of seconds with one or more Line Code Violations              */
-      degraded_mins,           /* Degraded Minute - the estimated error rate is >1E-6, but <1E-3       */
-      errored_secs,            /* Errored Second - at least one of these happened:
-                                  - Path Code Violation
-                                  - Out Of Frame defect
-                                  - Slip
-                                  - receiving AIS
-                                  - not incremented during an Unavailable Second                       */
-      bursty_err_secs,         /* Bursty Errored Second: (rfc2495 says it does not apply to E1)
-                                  - Path Code Violations >1, but <320
-                                  - not a Severely Errored Second
-                                  - no AIS
-                                  - not incremented during an Unavailabla Second                       */
-      severely_err_secs,       /* Severely Errored Second:
-                                  - CRC4: >=832 Path COde Violations || >0 Out Of Frame defects
-                                  - noCRC4: >=2048 Line Code Violations
-                                  - not incremented during an Unavailable Second                       */
-      unavail_secs;            /* number of Unavailable Seconds. Unavailable state is said after:
-                                  - 10 contiguous Severely Errored Seconds
-                                  - or RAI || AIS || LOF || LOS 
-                                  - (any) loopback has been set                                                */
-
-    /*
-     * we do not strictly comply to the rfc: we do not retroactively reduce errored_secs,
-     * bursty_err_secs, severely_err_secs when 'unavailable state' is reached
-     */
-
-} e1_stats_t;
-
-typedef volatile struct                /* ezek board-adatok, nem lehetnek a slicecom_privdata -ban     */
-{
-    int use_count;             /* num. of interfaces using the board                           */
-    int irq;                   /* a kartya irq-ja. belemasoljuk a dev->irq -kba is, de csak hogy       */
-    /* szebb legyen az ifconfig outputja                            */
-    /* ha != 0, az azt jelenti hogy az az irq most nekunk sikeresen */
-    /* le van foglalva                                              */
-    struct pci_dev *pci;       /* a kartya PCI strukturaja. NULL, ha nincs kartya              */
-    u32 *bar1;                 /* pci->base_address[0] ioremap()-ed by munich_probe(),         */
-    /* on x86 can be used both as a bus or virtual address.         */
-    /* These are the Munich's registers                             */
-    u8 *lbi;                   /* pci->base_address[1] ioremap()-ed by munich_probe(),         */
-    /* this is a 256-byte range, the start of the LBI on the board  */
-    munich_ccb_t *ccb;         /* virtual address of CCB                                       */
-    munich_intq_t *tiq;                /* Tx Interrupt Queue                                           */
-    munich_intq_t *riq;                /* Rx Interrupt Queue                                           */
-    munich_intq_t *piq;                /* Peripheral Interrupt Queue (FALC interrupts arrive here)     */
-    int tiq_ptr,               /* A 'current' helyek a tiq/riq/piq -ban.                       */
-      riq_ptr,                 /* amikor feldolgoztam az interruptokat, a legelso ures         */
-      piq_ptr;                 /* interrupt_information szora mutatnak.                        */
-    struct net_device *twins[32];      /* MUNICH channel -> network interface assignment       */
-
-    unsigned long lastcheck;   /* When were the Rx rings last checked. Time in jiffies         */
-
-    struct timer_list modemline_timer;
-    char isx21;
-    char lineup;
-    char framing;              /* a beallitasok tarolasa                               */
-    char linecode;
-    char clock_source;
-    char loopback;
-
-    char devname[30];          /* what to show in /proc/interrupts                     */
-    unsigned histogram[MAX_WORK];      /* number of processed events in the interrupt loop     */
-    unsigned stat_pri_races;   /* number of special events, we try to handle them      */
-    unsigned stat_pti_races;
-    unsigned stat_pri_races_missed;    /* when it can not be handled, because of MAX_WORK      */
-    unsigned stat_pti_races_missed;
-
-#define SLICECOM_BOARD_INTERVALS_SIZE  97
-    e1_stats_t intervals[SLICECOM_BOARD_INTERVALS_SIZE];       /* E1 line statistics           */
-    unsigned current_interval; /* pointer to the current interval                      */
-    unsigned elapsed_seconds;  /* elapsed seconds from the start of the current interval */
-    unsigned ses_seconds;      /* counter of contiguous Severely Errored Seconds       */
-    unsigned is_unavailable;   /* set to 1 after 10 contiguous Severely Errored Seconds */
-    unsigned no_ses_seconds;   /* contiguous Severely Error -free seconds in unavail state */
-
-    unsigned deg_elapsed_seconds;      /* for counting the 'Degraded Mins'                     */
-    unsigned deg_cumulated_errors;
-
-    struct module *owner;      /* pointer to our module to avoid module load races */
-} munich_board_t;
-
-struct slicecom_privdata
-{
-    int busy;                  /* transmitter busy - number of packets in the Tx ring  */
-    int channel;               /* Munich logical channel ('channel-group' in Cisco)    */
-    unsigned boardnum;
-    u32 timeslots;             /* i-th bit means i-th timeslot is our                  */
-
-    int tx_ring_hist[TX_DESC_MAX];     /* histogram: number of packets in Tx ring when _send_packet is called  */
-
-    tx_desc_t tx_desc[TX_DESC_MAX];    /* the ring of Tx descriptors                           */
-    u8 tx_data[TX_DESC_MAX][TXBUFFER_SIZE];    /* buffers for data to transmit                 */
-    int tx_desc_ptr;           /* hanyadik descriptornal tartunk a beirassal   */
-    /* ahol ez all, oda irtunk utoljara                     */
-
-    rx_desc_t rx_desc[RX_DESC_MAX];    /* the ring of Rx descriptors                           */
-    u8 rx_data[RX_DESC_MAX][RXBUFFER_SIZE];    /* buffers for received data                            */
-    int rx_desc_ptr;           /* hanyadik descriptornal tartunk az olvasassal */
-
-    int rafutott;
-};
-
-static u32 reg, reg_ertek;     /* why static: don't write stack trash into regs if strtoul() fails */
-static u32 lbireg;
-static u8 lbireg_ertek;                /* why static: don't write stack trash into regs if strtoul() fails */
-
-static munich_board_t slicecom_boards[MAX_BOARDS];
-static munich_board_t pcicom_boards[MAX_BOARDS];
-
-/*
- * Reprogram Idle Channel Registers in the FALC - send special code in not used channels
- * Should be called from the open and close, when the timeslot assignment changes
- */
-
-void rework_idle_channels(struct net_device *dev)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-    munich_board_t *board = slicecom_boards + hw->boardnum;
-    munich_ccb_t *ccb = board->ccb;
-
-    u8 *lbi = board->lbi;
-    int i, j, tmp;
-
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    for (i = 0; i < 4; i++)
-    {
-       tmp = 0xFF;
-       for (j = 0; j < 8; j++)
-           if (ccb->timeslot_spec[8 * i + j].tti == 0) tmp ^= (0x80 >> j);
-       writeb(tmp, lbi + 0x30 + i);
-    }
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set PCM framing - /proc/comx/comx0/framing
- */
-
-void slicecom_set_framing(int boardnum, int value)
-{
-    u8 *lbi = slicecom_boards[boardnum].lbi;
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    slicecom_boards[boardnum].framing = value;
-    switch (value)
-    {
-       case SLICECOM_FRAMING_CRC4:
-           writeb(readb(lbi + FMR1) | 8, lbi + FMR1);
-           writeb((readb(lbi + FMR2) & 0x3f) | 0x80, lbi + FMR2);
-           break;
-       case SLICECOM_FRAMING_NO_CRC4:
-           writeb(readb(lbi + FMR1) & 0xf7, lbi + FMR1);
-           writeb(readb(lbi + FMR2) & 0x3f, lbi + FMR2);
-           break;
-       default:
-           printk("slicecom: board %d: unhandled " FILENAME_FRAMING
-                  " value %d\n", boardnum, value);
-    }
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set PCM linecode - /proc/comx/comx0/linecode
- */
-
-void slicecom_set_linecode(int boardnum, int value)
-{
-    u8 *lbi = slicecom_boards[boardnum].lbi;
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    slicecom_boards[boardnum].linecode = value;
-    switch (value)
-    {
-       case SLICECOM_LINECODE_HDB3:
-           writeb(readb(lbi + FMR0) | 0xf0, lbi + FMR0);
-           break;
-       case SLICECOM_LINECODE_AMI:
-           writeb((readb(lbi + FMR0) & 0x0f) | 0xa0, lbi + FMR0);
-           break;
-       default:
-           printk("slicecom: board %d: unhandled " FILENAME_LINECODE
-                  " value %d\n", boardnum, value);
-    }
-    spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set PCM clock source - /proc/comx/comx0/clock_source
- */
-
-void slicecom_set_clock_source(int boardnum, int value)
-{
-    u8 *lbi = slicecom_boards[boardnum].lbi;
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    slicecom_boards[boardnum].clock_source = value;
-    switch (value)
-    {
-       case SLICECOM_CLOCK_SOURCE_LINE:
-           writeb(readb(lbi + LIM0) & ~1, lbi + LIM0);
-           break;
-       case SLICECOM_CLOCK_SOURCE_INTERNAL:
-           writeb(readb(lbi + LIM0) | 1, lbi + LIM0);
-           break;
-       default:
-           printk("slicecom: board %d: unhandled " FILENAME_CLOCK_SOURCE
-                  " value %d\n", boardnum, value);
-    }
-    spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set loopbacks - /proc/comx/comx0/loopback
- */
-
-void slicecom_set_loopback(int boardnum, int value)
-{
-    u8 *lbi = slicecom_boards[boardnum].lbi;
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    slicecom_boards[boardnum].loopback = value;
-    switch (value)
-    {
-       case SLICECOM_LOOPBACK_NONE:
-           writeb(readb(lbi + LIM0) & ~2, lbi + LIM0); /* Local Loop OFF  */
-           writeb(readb(lbi + LIM1) & ~2, lbi + LIM1); /* Remote Loop OFF */
-           break;
-       case SLICECOM_LOOPBACK_LOCAL:
-           writeb(readb(lbi + LIM1) & ~2, lbi + LIM1); /* Remote Loop OFF */
-           writeb(readb(lbi + LIM0) | 2, lbi + LIM0);  /* Local Loop ON   */
-           break;
-       case SLICECOM_LOOPBACK_REMOTE:
-           writeb(readb(lbi + LIM0) & ~2, lbi + LIM0); /* Local Loop OFF  */
-           writeb(readb(lbi + LIM1) | 2, lbi + LIM1);  /* Remote Loop ON  */
-           break;
-       default:
-           printk("slicecom: board %d: unhandled " FILENAME_LOOPBACK
-                  " value %d\n", boardnum, value);
-    }
-    spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Update E1 line status LEDs on the adapter
- */
-
-void slicecom_update_leds(munich_board_t * board)
-{
-    u32 *bar1 = board->bar1;
-    u8 *lbi = board->lbi;
-    u8 frs0;
-    u32 leds;
-    int i;
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    leds = 0;
-    frs0 = readb(lbi + FRS0);  /* FRS0 bits described on page 137 */
-
-    if (!(frs0 & 0xa0))
-    {
-       leds |= 0x2000;         /* Green LED: Input signal seems to be OK, no LOS, no LFA       */
-       if (frs0 & 0x10)
-           leds |= 0x8000;     /* Red LED: Receiving Remote Alarm                                      */
-    }
-    writel(leds, MUNICH_VIRT(GPDATA));
-
-    if (leds == 0x2000 && !board->lineup)
-    {                          /* line up */
-       board->lineup = 1;
-       for (i = 0; i < 32; i++)
-       {
-           if (board->twins[i] && (board->twins[i]->flags & IFF_RUNNING))
-           {
-               struct comx_channel *ch = board->twins[i]->priv;
-
-               if (!test_and_set_bit(0, &ch->lineup_pending))
-               {
-                   ch->lineup_timer.function = comx_lineup_func;
-                   ch->lineup_timer.data = (unsigned long)board->twins[i];
-                   ch->lineup_timer.expires = jiffies + HZ * ch->lineup_delay;
-                   add_timer(&ch->lineup_timer);
-               }
-           }
-       }
-    }
-    else if (leds != 0x2000 && board->lineup)
-    {                          /* line down */
-       board->lineup = 0;
-       for (i = 0; i < 32; i++)
-           if (board->twins[i] && (board->twins[i]->flags & IFF_RUNNING))
-           {
-               struct comx_channel *ch = board->twins[i]->priv;
-
-               if (test_and_clear_bit(0, &ch->lineup_pending))
-                   del_timer(&ch->lineup_timer);
-               else if (ch->line_status & LINE_UP)
-               {
-                   ch->line_status &= ~LINE_UP;
-                   if (ch->LINE_status)
-                       ch->LINE_status(board->twins[i], ch->line_status);
-               }
-           }
-    }
-    spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * This function gets called every second when the FALC issues the interrupt.
- * Hardware counters contain error counts for last 1-second time interval.
- * We add them to the global counters here.
- * Read rfc2495 to understand this.
- */
-
-void slicecom_update_line_counters(munich_board_t * board)
-{
-    e1_stats_t *curr_int = &board->intervals[board->current_interval];
-
-    u8 *lbi = board->lbi;
-
-    unsigned framing_errors, code_violations, path_code_violations, crc4_errors,
-       e_bit_errors;
-    unsigned slip_detected,    /* this one has logical value, not the number of slips! */
-      out_of_frame_defect,     /* logical value        */
-      ais_defect,              /* logical value        */
-      errored_sec, bursty_err_sec, severely_err_sec = 0, failure_sec;
-    u8 isr2, isr3, isr5, frs0;
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    isr2 = readb(lbi + ISR2);  /* ISR0-5 described on page 156     */
-    isr3 = readb(lbi + ISR3);
-    isr5 = readb(lbi + ISR5);
-    frs0 = readb(lbi + FRS0);  /* FRS0 described on page 137       */
-
-    /* Error Events: */
-
-    code_violations = readb(lbi + CVCL) + (readb(lbi + CVCH) << 8);
-    framing_errors = readb(lbi + FECL) + (readb(lbi + FECH) << 8);
-    crc4_errors = readb(lbi + CEC1L) + (readb(lbi + CEC1H) << 8);
-    e_bit_errors = readb(lbi + EBCL) + (readb(lbi + EBCH) << 8);
-    slip_detected = isr3 & (ISR3_RSN | ISR3_RSP);
-
-    path_code_violations = framing_errors + crc4_errors;
-
-    curr_int->line_code_violations += code_violations;
-    curr_int->path_code_violations += path_code_violations;
-    curr_int->e_bit_errors += e_bit_errors;
-
-    /* Performance Defects: */
-
-    /* there was an LFA in the last second, but maybe disappeared: */
-    out_of_frame_defect = (isr2 & ISR2_LFA) || (frs0 & FRS0_LFA);
-
-    /* there was an AIS in the last second, but maybe disappeared: */
-    ais_defect = (isr2 & ISR2_AIS) || (frs0 & FRS0_AIS);
-
-    /* Performance Parameters: */
-
-    if (out_of_frame_defect)
-       curr_int->fr_loss_secs++;
-    if (code_violations)
-       curr_int->line_err_secs++;
-
-    errored_sec = ((board->framing == SLICECOM_FRAMING_NO_CRC4) &&
-                  (code_violations)) || path_code_violations ||
-       out_of_frame_defect || slip_detected || ais_defect;
-
-    bursty_err_sec = !out_of_frame_defect && !ais_defect &&
-       (path_code_violations > 1) && (path_code_violations < 320);
-
-    switch (board->framing)
-    {
-       case SLICECOM_FRAMING_CRC4:
-           severely_err_sec = out_of_frame_defect ||
-               (path_code_violations >= 832);
-           break;
-       case SLICECOM_FRAMING_NO_CRC4:
-           severely_err_sec = (code_violations >= 2048);
-           break;
-    }
-
-    /*
-     * failure_sec: true if there was a condition leading to a failure
-     * (and leading to unavailable state) in this second:
-     */
-
-    failure_sec = (isr2 & ISR2_RA) || (frs0 & FRS0_RRA)        /* Remote/Far End/Distant Alarm Failure */
-       || ais_defect || out_of_frame_defect    /* AIS or LOF Failure                           */
-       || (isr2 & ISR2_LOS) || (frs0 & FRS0_LOS)       /* Loss Of Signal Failure                       */
-       || (board->loopback != SLICECOM_LOOPBACK_NONE); /* Loopback has been set                        */
-
-    if (board->is_unavailable)
-    {
-       if (severely_err_sec)
-           board->no_ses_seconds = 0;
-       else
-           board->no_ses_seconds++;
-
-       if ((board->no_ses_seconds >= 10) && !failure_sec)
-       {
-           board->is_unavailable = 0;
-           board->ses_seconds = 0;
-           board->no_ses_seconds = 0;
-       }
-    }
-    else
-    {
-       if (severely_err_sec)
-           board->ses_seconds++;
-       else
-           board->ses_seconds = 0;
-
-       if ((board->ses_seconds >= 10) || failure_sec)
-       {
-           board->is_unavailable = 1;
-           board->ses_seconds = 0;
-           board->no_ses_seconds = 0;
-       }
-    }
-
-    if (board->is_unavailable)
-       curr_int->unavail_secs++;
-    else
-    {
-       if (slip_detected)
-           curr_int->slip_secs++;
-       curr_int->errored_secs += errored_sec;
-       curr_int->bursty_err_secs += bursty_err_sec;
-       curr_int->severely_err_secs += severely_err_sec;
-    }
-
-    /* the RFC does not say clearly which errors to count here, we try to count bit errors */
-
-    if (!board->is_unavailable && !severely_err_sec)
-    {
-       board->deg_cumulated_errors += code_violations;
-       board->deg_elapsed_seconds++;
-       if (board->deg_elapsed_seconds >= 60)
-       {
-           if (board->deg_cumulated_errors >= 123)
-               curr_int->degraded_mins++;
-           board->deg_cumulated_errors = 0;
-           board->deg_elapsed_seconds = 0;
-       }
-
-    }
-
-    board->elapsed_seconds++;
-    if (board->elapsed_seconds >= 900)
-    {
-       board->current_interval =
-           (board->current_interval + 1) % SLICECOM_BOARD_INTERVALS_SIZE;
-       memset((void *)&board->intervals[board->current_interval], 0,
-              sizeof(e1_stats_t));
-       board->elapsed_seconds = 0;
-    }
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-static void pcicom_modemline(unsigned long b)
-{
-    munich_board_t *board = (munich_board_t *) b;
-    struct net_device *dev = board->twins[0];
-    struct comx_channel *ch = netdev_priv(dev);
-    unsigned long regs;
-
-    regs = readl((void *)(&board->bar1[GPDATA]));
-    if ((ch->line_status & LINE_UP) && (regs & 0x0800))
-    {
-       ch->line_status &= ~LINE_UP;
-       board->lineup = 0;
-       if (ch->LINE_status)
-       {
-           ch->LINE_status(dev, ch->line_status);
-       }
-    }
-
-    if (!(ch->line_status & LINE_UP) && !(regs & 0x0800))
-    {
-       ch->line_status |= LINE_UP;
-       board->lineup = 1;
-       if (ch->LINE_status)
-       {
-           ch->LINE_status(dev, ch->line_status);
-       }
-    }
-
-    mod_timer((struct timer_list *)&board->modemline_timer, jiffies + HZ);
-}
-
-/* 
- * Is it possible to transmit ?
- * Called (may be called) by the protocol layer 
- */
-
-static int MUNICH_txe(struct net_device *dev)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-
-    return (hw->busy < TX_DESC_MAX - 1);
-}
-
-/* 
- * Hw probe function. Detects all the boards in the system,
- * and fills up slicecom_boards[] and pcicom_boards[]
- * Returns 0 on success.
- * We do not disable interrupts!
- */
-static int munich_probe(void)
-{
-    struct pci_dev *pci;
-    int boardnum;
-    int slicecom_boardnum;
-    int pcicom_boardnum;
-    u32 *bar1;
-    u8 *lbi;
-    munich_board_t *board;
-
-    for (boardnum = 0; boardnum < MAX_BOARDS; boardnum++)
-    {
-       pcicom_boards[boardnum].pci = 0;
-       pcicom_boards[boardnum].bar1 = 0;
-       pcicom_boards[boardnum].lbi = 0;
-       slicecom_boards[boardnum].pci = 0;
-       slicecom_boards[boardnum].bar1 = 0;
-       slicecom_boards[boardnum].lbi = 0;
-    }
-
-    pci = NULL;
-    board = NULL;
-    slicecom_boardnum = 0;
-    pcicom_boardnum = 0;
-
-    for (boardnum = 0;
-       boardnum < MAX_BOARDS && (pci = pci_find_device(PCI_VENDOR_ID_SIEMENS,
-       PCI_DEVICE_ID_SIEMENS_MUNICH32X, pci)); boardnum++)
-    {
-       if (pci_enable_device(pci))
-           continue;
-
-       printk("munich_probe: munich chip found, IRQ %d\n", pci->irq);
-
-       bar1 = ioremap_nocache(pci->resource[0].start, 0x100);
-       lbi = ioremap_nocache(pci->resource[1].start, 0x100);
-
-       if (bar1 && lbi)
-       {
-           pci_write_config_dword(pci, MUNICH_PCI_PCIRES, 0xe0000);
-           set_current_state(TASK_UNINTERRUPTIBLE);
-           schedule_timeout(1);
-           pci_write_config_dword(pci, MUNICH_PCI_PCIRES, 0);
-           set_current_state(TASK_UNINTERRUPTIBLE);
-           schedule_timeout(1);
-           /* check the type of the card */
-           writel(LREG0_MAGIC, MUNICH_VIRT(LREG0));
-           writel(LREG1_MAGIC, MUNICH_VIRT(LREG1));
-           writel(LREG2_MAGIC, MUNICH_VIRT(LREG2));
-           writel(LREG3_MAGIC, MUNICH_VIRT(LREG3));
-           writel(LREG4_MAGIC, MUNICH_VIRT(LREG4));
-           writel(LREG5_MAGIC, MUNICH_VIRT(LREG5));
-           writel(LCONF_MAGIC2,MUNICH_VIRT(LCONF));    /* enable the DMSM */
-
-           if ((readb(lbi + VSTR) == 0x13) || (readb(lbi + VSTR) == 0x10))
-           {
-               board = slicecom_boards + slicecom_boardnum;
-               sprintf((char *)board->devname, "slicecom%d",
-                       slicecom_boardnum);
-               board->isx21 = 0;
-               slicecom_boardnum++;
-           }
-           else if ((readb(lbi + VSTR) == 0x6) || (readb(lbi + GIS) == 0x6))
-           {
-               board = pcicom_boards + pcicom_boardnum;
-               sprintf((char *)board->devname, "pcicom%d", pcicom_boardnum);
-               board->isx21 = 1;
-               pcicom_boardnum++;
-           }
-           if (board)
-           {
-               printk("munich_probe: %s board found\n", board->devname);
-               writel(LCONF_MAGIC1, MUNICH_VIRT(LCONF));       /* reset the DMSM */
-               board->pci = pci;
-               board->bar1 = bar1;
-               board->lbi = lbi;
-               board->framing = SLICECOM_FRAMING_DEFAULT;
-               board->linecode = SLICECOM_LINECODE_DEFAULT;
-               board->clock_source = SLICECOM_CLOCK_SOURCE_DEFAULT;
-               board->loopback = SLICECOM_LOOPBACK_DEFAULT;
-               board->owner = THIS_MODULE;
-           }
-           else
-           {
-               printk("munich_probe: Board error, VSTR: %02X\n",
-                      readb(lbi + VSTR));
-               iounmap((void *)bar1);
-               iounmap((void *)lbi);
-           }
-       }
-       else
-       {
-           printk("munich_probe: ioremap() failed, not enabling this board!\n");
-           /* .pci = NULL, so the MUNICH_open will not try to open it            */
-           if (bar1) iounmap((void *)bar1);
-           if (lbi) iounmap((void *)lbi);
-       }
-    }
-
-    if (!pci && !boardnum)
-    {
-       printk("munich_probe: no PCI present!\n");
-       return -ENODEV;
-    }
-
-    if (pcicom_boardnum + slicecom_boardnum == 0)
-    {
-       printk
-           ("munich_probe: Couldn't find any munich board: vendor:device %x:%x not found\n",
-            PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_SIEMENS_MUNICH32X);
-       return -ENODEV;
-    }
-
-    /* Found some */
-    if (pcicom_boardnum)
-       printk("%d pcicom board(s) found.\n", pcicom_boardnum);
-    if (slicecom_boardnum)
-       printk("%d slicecom board(s) found.\n", slicecom_boardnum);
-
-    return 0;
-}
-
-/* 
- * Reset the hardware. Get called only from within this module if needed.
- */
-#if 0
-static int slicecom_reset(struct net_device *dev)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-
-    printk("slicecom_reset: resetting the hardware\n");
-
-    /* Begin to reset the hardware */
-
-    if (ch->HW_set_clock)
-       ch->HW_set_clock(dev);
-
-    /* And finish it */
-
-    return 0;
-}
-#endif
-
-/* 
- * Transmit a packet. 
- * Called by the protocol layer
- * Return values:      
- *     FRAME_ACCEPTED: frame is being transmited, transmitter is busy
- *     FRAME_QUEUED:   frame is being transmitted, there's more room in
- *                             the transmitter for additional packet(s)
- *     FRAME_ERROR:
- *     FRAME_DROPPED:  there was some error
- */
-
-static int MUNICH_send_packet(struct net_device *dev, struct sk_buff *skb)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-
-    /* Send it to the debug facility too if needed: */
-
-    if (ch->debug_flags & DEBUG_HW_TX)
-       comx_debug_bytes(dev, skb->data, skb->len, "MUNICH_send_packet");
-
-    /* If the line is inactive, don't accept: */
-
-    /* TODO: atgondolni hogy mi is legyen itt */
-    /* if (!(ch->line_status & LINE_UP)) return FRAME_DROPPED; */
-
-    /* More check, to be sure: */
-
-    if (skb->len > TXBUFFER_SIZE)
-    {
-       ch->stats.tx_errors++;
-       kfree_skb(skb);
-       return FRAME_ERROR;
-    }
-
-    /* Maybe you have to disable irq's while programming the hw: */
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    /* And more check: */
-
-    if (hw->busy >= TX_DESC_MAX - 1)
-    {
-       printk(KERN_ERR
-              "%s: Transmitter called while busy... dropping frame, busy = %d\n",
-              dev->name, hw->busy);
-       spin_unlock_irqrestore(&mister_lock, flags);
-       kfree_skb(skb);
-       return FRAME_DROPPED;
-    }
-
-    if (hw->busy >= 0)
-       hw->tx_ring_hist[hw->busy]++;
-    /* DELL: */
-    else
-       printk("slicecom: %s: FATAL: busy = %d\n", dev->name, hw->busy);
-
-//              /* DEL: */
-//      printk("slicecom: %s: _send_packet called, busy = %d\n", dev->name, hw->busy );
-
-    /* Packet can go, update stats: */
-
-    ch->stats.tx_packets++;
-    ch->stats.tx_bytes += skb->len;
-
-    /* Pass the packet to the HW:                   */
-    /* Step forward with the transmit descriptors:  */
-
-    hw->tx_desc_ptr = (hw->tx_desc_ptr + 1) % TX_DESC_MAX;
-
-    memcpy(&(hw->tx_data[hw->tx_desc_ptr][0]), skb->data, skb->len);
-    hw->tx_desc[hw->tx_desc_ptr].no = skb->len;
-
-    /* We don't issue any command, just step with the HOLD bit      */
-
-    hw->tx_desc[hw->tx_desc_ptr].hold = 1;
-    hw->tx_desc[(hw->tx_desc_ptr + TX_DESC_MAX - 1) % TX_DESC_MAX].hold = 0;
-
-#ifdef COMX_NEW
-    dev_kfree_skb(skb);
-#endif
-    /* csomag kerult a Tx ringbe: */
-
-    hw->busy++;
-
-    /* Report it: */
-
-    if (ch->debug_flags & DEBUG_HW_TX)
-       comx_debug(dev, "%s: MUNICH_send_packet was successful\n\n", dev->name);
-
-    if (hw->busy >= TX_DESC_MAX - 1)
-    {
-       spin_unlock_irqrestore(&mister_lock, flags);
-       return FRAME_ACCEPTED;
-    }
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-
-    /* All done */
-
-    return FRAME_QUEUED;
-}
-
-/*
- * Interrupt handler routine.
- * Called by the Linux kernel.
- * BEWARE! The interrupts are enabled on the call!
- */
-static irqreturn_t MUNICH_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-    struct sk_buff *skb;
-    int length;
-    int rx_status;
-    int work;                  /* hany esemenyt kezeltem mar le                                */
-    u32 *bar1;
-    u8 *lbi;
-    u32 stat,                  /* az esemenyek, amiket a ebben a loop korben le kell meg kezelni       */
-      race_stat = 0,           /* race eseten ebben uzenek magamnak hogy mit kell meg lekezelni        */
-      ack;                     /* ezt fogom a vegen a STAT-ba irni, kiveszek belole 1-1 bitet ha       */
-
-    /* az adott dolgot nem kell ack-olni mert volt vele munkam, es  */
-    /* legjobb ha visszaterek ide megegyszer                        */
-    munich_intq_t int_info;
-
-    struct net_device *dev;
-    struct comx_channel *ch;
-    struct slicecom_privdata *hw;
-    munich_board_t *board = (munich_board_t *) dev_id;
-    int channel;
-
-    //      , boardnum = (int)dev_id;
-
-    // board = munich_boards + boardnum;
-    bar1 = board->bar1;
-    lbi = board->lbi;
-
-    //      Do not uncomment this under heavy load! :->
-    //      printk("MUNICH_interrupt: masked STAT=0x%08x, tiq=0x%08x, riq=0x%08x, piq=0x%08x\n", stat, board->tiq[0].all, board->riq[0].all, board->piq[0].all );
-
-    for (work = 0; (stat = (race_stat | (readl(MUNICH_VIRT(STAT)) & ~STAT_NOT_HANDLED_BY_INTERRUPT))) && (work < MAX_WORK - 1); work++)
-    {
-       ack = stat & (STAT_PRI | STAT_PTI | STAT_LBII);
-
-       /* Handle the interrupt information in the Rx queue. We don't really trust      */
-       /* info from this queue, because it can be overflowed, so later check           */
-       /* every Rx ring for received packets. But there are some errors which can't    */
-       /* be counted from the Rx rings, so we parse it.                                        */
-
-       int_info = board->riq[board->riq_ptr];
-       if (int_info.all & 0xF0000000)  /* ha ez nem 0, akkor itt interrupt_info van                    */
-       {
-           ack &= ~STAT_PRI;   /* don't ack the interrupt, we had some work to do              */
-
-           channel = PCM_INT_CHANNEL(int_info.all);
-           dev = board->twins[channel];
-
-           if (dev == NULL)
-           {
-               printk
-                   ("MUNICH_interrupt: got an Rx interrupt info for NULL device "
-                    "%s.twins[%d], int_info = 0x%08x\n", board->devname,
-                    channel, int_info.all);
-               goto go_for_next_interrupt;
-           }
-
-           ch = netdev_priv(dev);
-           hw = (struct slicecom_privdata *)ch->HW_privdata;
-
-           //      printk("Rx STAT=0x%08x int_info=0x%08x rx_desc_ptr=%d rx_desc.status=0x%01x\n",
-           //              stat, int_info.all, hw->rx_desc_ptr, hw->rx_desc[ hw->rx_desc_ptr ].status );
-
-           if (int_info.all & PCM_INT_HI)
-               printk("SliceCOM: %s: Host Initiated interrupt\n", dev->name);
-           if (int_info.all & PCM_INT_IFC)
-               printk("SliceCOM: %s: Idle/Flag Change\n", dev->name);
-           /* TOD: jo ez az Idle/Flag Change valamire? - azonnal latszik belole hogy mikor ad a masik oldal */
-           /* TOD: ilyen IT most nem is jon, mert ki van maszkolva az interrupt, biztosan kell ez? */
-
-           if (int_info.all & PCM_INT_FO)
-               /* Internal buffer (RB) overrun */
-               ch->stats.rx_over_errors++;     /* TOD: Ez azt jelenti hogy a belso RB nem volt hozzaferheto, es ezert kihagyott valamit. De nem csak csomag lehetett, hanem esemeny, stb. is. lasd page 247. Ezzel a 'cat status'-hoz igazodok, de a netdevice.h szerint nem egyertelmu hogy ide ez kellene. Nem lehet hogy rx_missed ? */
-               /* DE: nem gotozok sehova, elvileg jo igy */
-               /* kesobb meg visszaterek az FO-ra, ha packet-FO volt. Keresd a "packet-FO"-t. */
-           if (int_info.all & PCM_INT_FI)      /* frame received, but we do not trust the int_info queue       */
-               if (int_info.all & PCM_INT_SF)
-               {               /* Short Frame: rovidebb mint a CRC */
-                   /* "rovidebb mint CRC+2byte" vizsgalat a "CRC+2"-nel */
-                   ch->stats.rx_length_errors++;       /* TOD: noveljem? ne noveljem? */
-                   goto go_for_next_interrupt;
-               }
-
-           go_for_next_interrupt:      /* One step in the interrupt queue */
-           board->riq[board->riq_ptr].all = 0; /* megjelolom hogy itt meg nem jart a hw */
-           board->riq_ptr = (board->riq_ptr + 1) % MUNICH_INTQMAX;
-
-       }
-
-       /* Check every Rx ring for incomed packets: */
-
-       for (channel = 0; channel < 32; channel++)
-       {
-           dev = board->twins[channel];
-
-           if (dev != NULL)
-           {
-               ch = netdev_priv(dev);
-               hw = (struct slicecom_privdata *)ch->HW_privdata;
-
-               rx_status = hw->rx_desc[hw->rx_desc_ptr].status;
-
-               if (!(rx_status & 0x80))        /* mar jart itt a hardver */
-               {
-                   ack &= ~STAT_PRI;   /* Don't ack, we had some work          */
-
-                   /* Ez most egy kicsit zuros, mert itt mar nem latom az int_infot        */
-                   if (rx_status & RX_STATUS_ROF)
-                       ch->stats.rx_over_errors++;     /* TOD: 'cat status'-hoz igazodok */
-
-                   if (rx_status & RX_STATUS_RA)
-                       /* Abort received or issued on channel  */
-                       ch->stats.rx_frame_errors++;    /* or HOLD bit in the descriptor                */
-                       /* TOD: 'cat status'-hoz igazodok */
-
-                   if (rx_status & RX_STATUS_LFD)
-                   {           /* Long Frame (longer then MFL in the MODE1) */
-                       ch->stats.rx_length_errors++;
-                       goto go_for_next_frame;
-                   }
-
-                   if (rx_status & RX_STATUS_NOB)
-                   {           /* Not n*8 bits long frame - frame alignment */
-                       ch->stats.rx_frame_errors++;    /* ez viszont nem igazodik a 'cat status'-hoz */
-                       goto go_for_next_frame;
-                   }
-
-                   if (rx_status & RX_STATUS_CRCO)
-                   {           /* CRC error */
-                       ch->stats.rx_crc_errors++;
-                       goto go_for_next_frame;
-                   }
-
-                   if (rx_status & RX_STATUS_SF)
-                   {           /* Short Frame: rovidebb mint CRC+2byte */
-                       ch->stats.rx_errors++;  /* The HW does not set PCI_INT_ERR bit for this one, see page 246 */
-                       ch->stats.rx_length_errors++;
-                       goto go_for_next_frame;
-                   }
-
-                   if (rx_status != 0)
-                   {
-                       printk("SliceCOM: %s: unhandled rx_status: 0x%02x\n",
-                              dev->name, rx_status);
-                       goto go_for_next_frame;
-                   }
-
-                   /* frame received without errors: */
-
-                   length = hw->rx_desc[hw->rx_desc_ptr].bno;
-                   ch->stats.rx_packets++;     /* Count only 'good' packets */
-                   ch->stats.rx_bytes += length;
-
-                   /* Allocate a larger skb and reserve the heading for efficiency: */
-
-                   if ((skb = dev_alloc_skb(length + 16)) == NULL)
-                   {
-                       ch->stats.rx_dropped++;
-                       goto go_for_next_frame;
-                   }
-
-                   /* Do bookkeeping: */
-
-                   skb_reserve(skb, 16);
-                   skb_put(skb, length);
-                   skb->dev = dev;
-
-                   /* Now copy the data into the buffer: */
-
-                   memcpy(skb->data, &(hw->rx_data[hw->rx_desc_ptr][0]), length);
-
-                   /* DEL: UGLY HACK!!!! */
-                   if (*((int *)skb->data) == 0x02000000 &&
-                       *(((int *)skb->data) + 1) == 0x3580008f)
-                   {
-                       printk("%s: swapping hack\n", dev->name);
-                       *((int *)skb->data) = 0x3580008f;
-                       *(((int *)skb->data) + 1) = 0x02000000;
-                   }
-
-                   if (ch->debug_flags & DEBUG_HW_RX)
-                       comx_debug_skb(dev, skb, "MUNICH_interrupt receiving");
-
-                   /* Pass it to the protocol entity: */
-
-                   ch->LINE_rx(dev, skb);
-
-                   go_for_next_frame:
-                   /* DEL: rafutott-e a HOLD bitre -detektalas */
-                   {
-                       if( ((rx_desc_t*)phys_to_virt(board->ccb->current_rx_desc[channel]))->hold
-                           && ((rx_desc_t*)phys_to_virt(board->ccb->current_rx_desc[channel]))->status != 0xff)
-                           hw->rafutott++;     /* rafutott: hanyszor volt olyan hogy a current descriptoron HOLD bit volt, es a hw mar befejezte az irast (azaz a hw rafutott a HOLD bitre) */
-                   }
-
-                   //      if( jiffies % 2 )               /* DELL: okozzunk egy kis Rx ring slipet :) */
-                   //      {
-                   /* Step forward with the receive descriptors: */
-                   /* if you change this, change the copy of it below too! Search for: "RxSlip" */
-                   hw->rx_desc[(hw->rx_desc_ptr + RX_DESC_MAX - 1) % RX_DESC_MAX].hold = 1;
-                   hw->rx_desc[hw->rx_desc_ptr].status = 0xFF; /* megjelolom hogy itt meg nem jart a hw */
-                   hw->rx_desc[(hw->rx_desc_ptr + RX_DESC_MAX - 2) % RX_DESC_MAX].hold = 0;
-                   hw->rx_desc_ptr = (hw->rx_desc_ptr + 1) % RX_DESC_MAX;
-                   //      }
-               }
-           }
-       }
-
-       stat &= ~STAT_PRI;
-
-//      }
-
-//      if( stat & STAT_PTI )   /* TOD: primko megvalositas: mindig csak egy esemenyt dolgozok fel, */
-       /* es nem torlom a STAT-ot, ezert ujra visszajon ide a rendszer. Amikor */
-       /* jon interrupt, de nincs mit feldolgozni, akkor torlom a STAT-ot.     */
-       /* 'needs a rewrite', de elso megoldasnak jo lesz                       */
-//              {
-       int_info = board->tiq[board->tiq_ptr];
-       if (int_info.all & 0xF0000000)  /* ha ez nem 0, akkor itt interrupt_info van    */
-       {
-           ack &= ~STAT_PTI;   /* don't ack the interrupt, we had some work to do      */
-
-           channel = PCM_INT_CHANNEL(int_info.all);
-           dev = board->twins[channel];
-
-           if (dev == NULL)
-           {
-               printk("MUNICH_interrupt: got a Tx interrupt for NULL device "
-                      "%s.twins[%d], int_info = 0x%08x\n",
-                      board->isx21 ? "pcicom" : "slicecom", channel, int_info.all);
-               goto go_for_next_tx_interrupt;
-           }
-
-           ch = netdev_priv(dev);
-           hw = (struct slicecom_privdata *)ch->HW_privdata;
-
-           //      printk("Tx STAT=0x%08x int_info=0x%08x tiq_ptr=%d\n", stat, int_info.all, board->tiq_ptr );
-
-           if (int_info.all & PCM_INT_FE2)
-           {                   /* "Tx available"                               */
-               /* do nothing */
-           }
-           else if (int_info.all & PCM_INT_FO)
-           {                   /* Internal buffer (RB) overrun */
-               ch->stats.rx_over_errors++;
-           }
-           else
-           {
-               printk("slicecom: %s: unhandled Tx int_info: 0x%08x\n",
-                      dev->name, int_info.all);
-           }
-
-           go_for_next_tx_interrupt:
-           board->tiq[board->tiq_ptr].all = 0;
-           board->tiq_ptr = (board->tiq_ptr + 1) % MUNICH_INTQMAX;
-       }
-
-       /* Check every Tx ring for incoming packets: */
-
-       for (channel = 0; channel < 32; channel++)
-       {
-           dev = board->twins[channel];
-
-           if (dev != NULL)
-           {
-               int newbusy;
-
-               ch = netdev_priv(dev);
-               hw = (struct slicecom_privdata *)ch->HW_privdata;
-
-               /* We don't trust the "Tx available" info from the TIQ, but check        */
-               /* every ring if there is some free room                                        */
-
-               if (ch->init_status && netif_running(dev))
-               {
-                   newbusy = ( TX_DESC_MAX + (& hw->tx_desc[ hw->tx_desc_ptr ]) -
-                       (tx_desc_t*)phys_to_virt(board->ccb->current_tx_desc[ hw->channel ]) ) % TX_DESC_MAX;
-
-                   if(newbusy < 0)
-                   {
-                       printk("slicecom: %s: FATAL: fresly computed busy = %d, HW: 0x%p, SW: 0x%p\n",
-                       dev->name, newbusy,
-                       phys_to_virt(board->ccb->current_tx_desc[hw->channel]),
-                       & hw->tx_desc[hw->tx_desc_ptr]);
-                   }
-
-                   /* Fogyott valami a Tx ringbol? */
-
-                   if (newbusy < hw->busy)
-                   {
-                       // ack &= ~STAT_PTI;                            /* Don't ack, we had some work  */
-                       hw->busy = newbusy;
-                       if (ch->LINE_tx)
-                           ch->LINE_tx(dev);   /* Report it to protocol driver */
-                   }
-                   else if (newbusy > hw->busy)
-                       printk("slicecom: %s: newbusy > hw->busy, this should not happen!\n", dev->name);
-               }
-           }
-       }
-       stat &= ~STAT_PTI;
-
-       int_info = board->piq[board->piq_ptr];
-       if (int_info.all & 0xF0000000)  /* ha ez nem 0, akkor itt interrupt_info van            */
-       {
-           ack &= ~STAT_LBII;  /* don't ack the interrupt, we had some work to do      */
-
-           /* We do not really use (yet) the interrupt info from this queue, */
-
-           // printk("slicecom: %s: LBI Interrupt event: %08x\n", board->devname, int_info.all);
-
-           if (!board->isx21)
-           {
-               slicecom_update_leds(board);
-               slicecom_update_line_counters(board);
-           }
-
-           goto go_for_next_lbi_interrupt;     /* To avoid warning about unused label  */
-
-           go_for_next_lbi_interrupt:  /* One step in the interrupt queue */
-           board->piq[board->piq_ptr].all = 0; /* megjelolom hogy itt meg nem jart a hw        */
-           board->piq_ptr = (board->piq_ptr + 1) % MUNICH_PIQMAX;
-       }
-       stat &= ~STAT_LBII;
-
-       writel(ack, MUNICH_VIRT(STAT));
-
-       if (stat & STAT_TSPA)
-       {
-           //      printk("slicecom: %s: PCM TSP Asynchronous\n", board->devname);
-           writel(STAT_TSPA, MUNICH_VIRT(STAT));
-           stat &= ~STAT_TSPA;
-       }
-
-       if (stat & STAT_RSPA)
-       {
-           //      printk("slicecom: %s: PCM RSP Asynchronous\n", board->devname);
-           writel(STAT_RSPA, MUNICH_VIRT(STAT));
-           stat &= ~STAT_RSPA;
-       }
-       if (stat)
-       {
-           printk("MUNICH_interrupt: unhandled interrupt, STAT=0x%08x\n",
-                  stat);
-           writel(stat, MUNICH_VIRT(STAT));    /* ha valamit megsem kezeltunk le, azert ack-ot kuldunk neki */
-       }
-
-    }
-    board->histogram[work]++;
-
-    /* We can miss these if we reach the MAX_WORK   */
-    /* Count it to see how often it happens         */
-
-    if (race_stat & STAT_PRI)
-       board->stat_pri_races_missed++;
-    if (race_stat & STAT_PTI)
-       board->stat_pti_races_missed++;
-    return IRQ_HANDLED;
-}
-
-/* 
- * Hardware open routine.
- * Called by comx (upper) layer when the user wants to bring up the interface
- * with ifconfig.
- * Initializes hardware, allocates resources etc.
- * Returns 0 on OK, or standard error value on error.
- */
-
-static int MUNICH_open(struct net_device *dev)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-    struct proc_dir_entry *procfile = ch->procdir->subdir;
-    munich_board_t *board;
-    munich_ccb_t *ccb;
-
-    u32 *bar1;
-    u8 *lbi;
-    u32 stat;
-    unsigned long flags, jiffs;
-
-    int i, channel;
-    u32 timeslots = hw->timeslots;
-
-    board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
-    bar1 = board->bar1;
-    lbi = board->lbi;
-
-    /* TODO: a timeslotok ellenorzese kell majd ide .. hat, biztos? mar a write_proc-ban is
-       ellenorzom valamennyire.
-       if (!dev->io || !dev->irq) return -ENODEV;
-     */
-
-    if (!board->pci)
-    {
-       printk("MUNICH_open: no %s board with boardnum = %d\n",
-              ch->hardware->name, hw->boardnum);
-       return -ENODEV;
-    }
-
-    spin_lock_irqsave(&mister_lock, flags);
-    /* lock the section to avoid race with multiple opens and make sure
-       that no interrupts get called while this lock is active */
-
-    if (board->use_count == 0) /* bring up the board if it was unused                  */
-       /* if fails, frees allocated resources and returns.     */
-       /* TOD: is it safe? nem kellene resetelni a kartyat?    */
-    {
-       printk("MUNICH_open: %s: bringing up board\n", board->devname);
-
-       /* Clean up the board's static struct if messed: */
-
-       for (i = 0; i < 32; i++)
-           board->twins[i] = NULL;
-       for (i = 0; i < MAX_WORK; i++)
-           board->histogram[i] = 0;
-
-       board->lineup = 0;
-
-       /* Allocate CCB: */
-        board->ccb = kmalloc(sizeof(munich_ccb_t), GFP_KERNEL);
-       if (board->ccb == NULL)
-       {
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -ENOMEM;
-       }
-       memset((void *)board->ccb, 0, sizeof(munich_ccb_t));
-       board->ccb->csa = virt_to_phys(board->ccb);
-       ccb = board->ccb;
-       for (i = 0; i < 32; i++)
-       {
-           ccb->timeslot_spec[i].tti = 1;
-           ccb->timeslot_spec[i].rti = 1;
-       }
-
-       /* Interrupt queues: */
-
-       board->tiq = kmalloc(MUNICH_INTQSIZE, GFP_KERNEL);
-       if (board->tiq == NULL)
-       {
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -ENOMEM;
-       }
-       memset((void *)board->tiq, 0, MUNICH_INTQSIZE);
-
-       board->riq = kmalloc(MUNICH_INTQSIZE, GFP_KERNEL);
-       if (board->riq == NULL)
-       {
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -ENOMEM;
-       }
-       memset((void *)board->riq, 0, MUNICH_INTQSIZE);
-
-       board->piq = kmalloc(MUNICH_PIQSIZE, GFP_KERNEL);
-       if (board->piq == NULL)
-       {
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -ENOMEM;
-       }
-       memset((void *)board->piq, 0, MUNICH_PIQSIZE);
-
-       board->tiq_ptr = 0;
-       board->riq_ptr = 0;
-       board->piq_ptr = 0;
-
-       /* Request irq: */
-
-       board->irq = 0;
-
-       /* (char*) cast to avoid warning about discarding volatile:             */
-       if (request_irq(board->pci->irq, MUNICH_interrupt, 0,
-           (char *)board->devname, (void *)board))
-       {
-           printk("MUNICH_open: %s: unable to obtain irq %d\n", board->devname,
-                  board->pci->irq);
-           /* TOD: free other resources (a sok malloc feljebb)                     */
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -EAGAIN;
-       }
-       board->irq = board->pci->irq;   /* csak akkor legyen != 0, ha tenyleg le van foglalva nekunk */
-
-       /* Programming device: */
-
-       /* Reset the board like a power-on: */
-       /* TOD:
-          - It is not a real power-on: if a DMA transaction fails with master abort, the board
-          stays in half-dead state.
-          - It doesn't reset the FALC line driver */
-
-       pci_write_config_dword(board->pci, MUNICH_PCI_PCIRES, 0xe0000);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(1);
-       pci_write_config_dword(board->pci, MUNICH_PCI_PCIRES, 0);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(1);
-
-        writel(virt_to_phys(&ccb->csa), MUNICH_VIRT(CCBA));
-        writel(virt_to_phys( board->tiq ), MUNICH_VIRT(TIQBA));
-        writel(MUNICH_INTQLEN, MUNICH_VIRT(TIQL));
-        writel(virt_to_phys( board->riq ), MUNICH_VIRT(RIQBA));
-        writel(MUNICH_INTQLEN, MUNICH_VIRT(RIQL));
-        writel(virt_to_phys( board->piq ), MUNICH_VIRT(PIQBA));
-        writel(MUNICH_PIQLEN, MUNICH_VIRT(PIQL));
-        
-       /* Put the magic values into the registers: */
-
-       writel(MODE1_MAGIC, MUNICH_VIRT(MODE1));
-       writel(MODE2_MAGIC, MUNICH_VIRT(MODE2));
-
-       writel(LREG0_MAGIC, MUNICH_VIRT(LREG0));
-       writel(LREG1_MAGIC, MUNICH_VIRT(LREG1));
-       writel(LREG2_MAGIC, MUNICH_VIRT(LREG2));
-       writel(LREG3_MAGIC, MUNICH_VIRT(LREG3));
-       writel(LREG4_MAGIC, MUNICH_VIRT(LREG4));
-       writel(LREG5_MAGIC, MUNICH_VIRT(LREG5));
-
-       writel(LCONF_MAGIC1, MUNICH_VIRT(LCONF));       /* reset the DMSM */
-       writel(LCONF_MAGIC2, MUNICH_VIRT(LCONF));       /* enable the DMSM */
-
-       writel(~0, MUNICH_VIRT(TXPOLL));
-       writel(board->isx21 ? 0x1400 : 0xa000, MUNICH_VIRT(GPDIR));
-
-       if (readl(MUNICH_VIRT(STAT))) writel(readl(MUNICH_VIRT(STAT)), MUNICH_VIRT(STAT));
-
-       ccb->action_spec = CCB_ACTIONSPEC_RES | CCB_ACTIONSPEC_IA;
-       writel(CMD_ARPCM, MUNICH_VIRT(CMD));    /* Start the PCM core reset */
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(1);
-
-       stat = 0;               /* Wait for the action to complete max. 1 second */
-       jiffs = jiffies;
-       while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
-       {
-           set_current_state(TASK_UNINTERRUPTIBLE);
-           schedule_timeout(1);
-       }
-
-       if (stat & STAT_PCMF)
-       {
-           printk(KERN_ERR
-                  "MUNICH_open: %s: Initial ARPCM failed. STAT=0x%08x\n",
-                  board->devname, stat);
-           writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
-           free_irq(board->irq, (void *)board);        /* TOD: free other resources too *//* maybe shut down hw? */
-           board->irq = 0;
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -EAGAIN;
-       }
-       else if (!(stat & STAT_PCMA))
-       {
-           printk(KERN_ERR
-                  "MUNICH_open: %s: Initial ARPCM timeout. STAT=0x%08x\n",
-                  board->devname, stat);
-           free_irq(board->irq, (void *)board);        /* TOD: free other resources too *//* maybe shut off the hw? */
-           board->irq = 0;
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -EIO;
-       }
-
-       writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT));        /* Acknowledge */
-
-       if (board->isx21) writel(0, MUNICH_VIRT(GPDATA));
-
-       printk("MUNICH_open: %s: succesful HW-open took %ld jiffies\n",
-              board->devname, jiffies - jiffs);
-
-       /* Set up the FALC hanging on the Local Bus: */
-
-       if (!board->isx21)
-       {
-           writeb(0x0e, lbi + FMR1);
-           writeb(0, lbi + LIM0);
-           writeb(0xb0, lbi + LIM1);   /* TODO: input threshold */
-           writeb(0xf7, lbi + XPM0);
-           writeb(0x02, lbi + XPM1);
-           writeb(0x00, lbi + XPM2);
-           writeb(0xf0, lbi + FMR0);
-           writeb(0x80, lbi + PCD);
-           writeb(0x80, lbi + PCR);
-           writeb(0x00, lbi + LIM2);
-           writeb(0x07, lbi + XC0);
-           writeb(0x3d, lbi + XC1);
-           writeb(0x05, lbi + RC0);
-           writeb(0x00, lbi + RC1);
-           writeb(0x83, lbi + FMR2);
-           writeb(0x9f, lbi + XSW);
-           writeb(0x0f, lbi + XSP);
-           writeb(0x00, lbi + TSWM);
-           writeb(0xe0, lbi + MODE);
-           writeb(0xff, lbi + IDLE);   /* Idle Code to send in unused timeslots        */
-           writeb(0x83, lbi + IPC);    /* interrupt query line mode: Push/pull output, active high     */
-           writeb(0xbf, lbi + IMR3);   /* send an interrupt every second               */
-
-           slicecom_set_framing(hw->boardnum, board->framing);
-           slicecom_set_linecode(hw->boardnum, board->linecode);
-           slicecom_set_clock_source(hw->boardnum, board->clock_source);
-           slicecom_set_loopback(hw->boardnum, board->loopback);
-
-           memset((void *)board->intervals, 0, sizeof(board->intervals));
-           board->current_interval = 0;
-           board->elapsed_seconds = 0;
-           board->ses_seconds = 0;
-           board->is_unavailable = 0;
-           board->no_ses_seconds = 0;
-           board->deg_elapsed_seconds = 0;
-           board->deg_cumulated_errors = 0;
-       }
-
-       /* Enable the interrupts last                                                   */
-       /* These interrupts will be enabled. We do not need the others. */
-
-       writel(readl(MUNICH_VIRT(IMASK)) & ~(STAT_PTI | STAT_PRI | STAT_LBII | STAT_TSPA | STAT_RSPA), MUNICH_VIRT(IMASK));
-    }
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-
-    dev->irq = board->irq;     /* hogy szep legyen az ifconfig outputja */
-    ccb = board->ccb;          /* TODO: ez igy csunya egy kicsit hogy benn is meg kinn is beletoltom :( */
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    set_current_state(TASK_UNINTERRUPTIBLE);
-    schedule_timeout(1);
-
-    /* Check if the selected timeslots aren't used already */
-
-    for (i = 0; i < 32; i++)
-       if (((1 << i) & timeslots) && !ccb->timeslot_spec[i].tti)
-       {
-           printk("MUNICH_open: %s: timeslot %d already used by %s\n",
-                  dev->name, i, board->twins[ccb->timeslot_spec[i].txchannel]->name);
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -EBUSY;      /* TODO: lehet hogy valami mas errno kellene? */
-       }
-
-    /* find a free channel: */
-    /* TODO: ugly, rewrite it  */
-
-    for (channel = 0; channel <= 32; channel++)
-    {
-       if (channel == 32)
-       {                       /* not found a free one */
-           printk
-               ("MUNICH_open: %s: FATAL: can not find a free channel - this should not happen!\n",
-                dev->name);
-           spin_unlock_irqrestore(&mister_lock, flags);
-           return -ENODEV;
-       }
-       if (board->twins[channel] == NULL)
-           break;              /* found the first free one */
-    }
-
-    board->lastcheck = jiffies;        /* avoid checking uninitialized hardware channel */
-
-    /* Open the channel. If fails, calls MUNICH_close() to properly free resources and stop the HW */
-
-    hw->channel = channel;
-    board->twins[channel] = dev;
-
-    board->use_count++;                /* meg nem nyitottuk meg a csatornat, de a twins-ben
-                                  mar elfoglaltunk egyet, es ha a _close-t akarjuk hivni, akkor ez kell. */
-    for (i = 0; i < 32; i++)
-       if ((1 << i) & timeslots)
-       {
-           ccb->timeslot_spec[i].tti = 0;
-           ccb->timeslot_spec[i].txchannel = channel;
-           ccb->timeslot_spec[i].txfillmask = ~0;
-
-           ccb->timeslot_spec[i].rti = 0;
-           ccb->timeslot_spec[i].rxchannel = channel;
-           ccb->timeslot_spec[i].rxfillmask = ~0;
-       }
-
-    if (!board->isx21) rework_idle_channels(dev);
-
-    memset((void *)&(hw->tx_desc), 0, TX_DESC_MAX * sizeof(tx_desc_t));
-    memset((void *)&(hw->rx_desc), 0, RX_DESC_MAX * sizeof(rx_desc_t));
-
-    for (i = 0; i < TX_DESC_MAX; i++)
-    {
-       hw->tx_desc[i].fe = 1;
-       hw->tx_desc[i].fnum = 2;
-                hw->tx_desc[i].data     = virt_to_phys( & (hw->tx_data[i][0]) );
-                hw->tx_desc[i].next     = virt_to_phys( & (hw->tx_desc[ (i+1) % TX_DESC_MAX ]) );
-
-    }
-    hw->tx_desc_ptr = 0;       /* we will send an initial packet so it is correct: "oda irtunk utoljara" */
-    hw->busy = 0;
-    hw->tx_desc[hw->tx_desc_ptr].hold = 1;
-    hw->tx_desc[hw->tx_desc_ptr].no = 1;       /* TOD: inkabb csak 0 hosszut kuldjunk ki az initkor? */
-
-    for (i = 0; i < RX_DESC_MAX; i++)
-    {
-       hw->rx_desc[i].no = RXBUFFER_SIZE;
-       hw->rx_desc[i].data = virt_to_phys(&(hw->rx_data[i][0]));
-       hw->rx_desc[i].next = virt_to_phys(&(hw->rx_desc[(i+1) % RX_DESC_MAX]));
-       hw->rx_desc[i].status = 0xFF;
-    }
-    hw->rx_desc_ptr = 0;
-
-    hw->rx_desc[(hw->rx_desc_ptr + RX_DESC_MAX - 2) % RX_DESC_MAX].hold = 1;
-
-    memset((void *)&ccb->channel_spec[channel], 0, sizeof(channel_spec_t));
-
-    ccb->channel_spec[channel].ti = 0; /* Transmit off */
-    ccb->channel_spec[channel].to = 1;
-    ccb->channel_spec[channel].ta = 0;
-
-    ccb->channel_spec[channel].th = 1; /* Transmit hold        */
-
-    ccb->channel_spec[channel].ri = 0; /* Receive off  */
-    ccb->channel_spec[channel].ro = 1;
-    ccb->channel_spec[channel].ra = 0;
-
-    ccb->channel_spec[channel].mode = 3;       /* HDLC */
-
-    ccb->action_spec = CCB_ACTIONSPEC_IN | (channel << 8);
-    writel(CMD_ARPCM, MUNICH_VIRT(CMD));
-    set_current_state(TASK_UNINTERRUPTIBLE);
-    schedule_timeout(1);
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-
-    stat = 0;
-    jiffs = jiffies;
-    while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
-    {
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(1);
-    }
-
-    if (stat & STAT_PCMF)
-    {
-       printk(KERN_ERR "MUNICH_open: %s: %s channel %d off failed\n",
-              dev->name, board->devname, channel);
-       writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
-       MUNICH_close(dev);
-       return -EAGAIN;
-    }
-    else if (!(stat & STAT_PCMA))
-    {
-       printk(KERN_ERR "MUNICH_open: %s: %s channel %d off timeout\n",
-              dev->name, board->devname, channel);
-       MUNICH_close(dev);
-       return -EIO;
-    }
-
-    writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT));
-    //      printk("MUNICH_open: %s: succesful channel off took %ld jiffies\n", board->devname, jiffies-jiffs);
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    set_current_state(TASK_UNINTERRUPTIBLE);
-    schedule_timeout(1);
-
-    ccb->channel_spec[channel].ifc = 1;        /* 1 .. 'Idle/Flag change' interrupt letiltva   */
-    ccb->channel_spec[channel].fit = 1;
-    ccb->channel_spec[channel].nitbs = 1;
-    ccb->channel_spec[channel].itbs = 2;
-
-    /* TODOO: lehet hogy jo lenne igy, de utana kellene nezni hogy nem okoz-e fragmentaciot */
-    //      ccb->channel_spec[channel].itbs = 2 * number_of_timeslots;
-    //      printk("open: %s: number_of_timeslots: %d\n", dev->name, number_of_timeslots);
-
-    ccb->channel_spec[channel].mode = 3;       /* HDLC */
-    ccb->channel_spec[channel].ftda = virt_to_phys(&(hw->tx_desc));
-    ccb->channel_spec[channel].frda = virt_to_phys(&(hw->rx_desc[0]));
-
-    ccb->channel_spec[channel].ti = 1; /* Transmit init        */
-    ccb->channel_spec[channel].to = 0;
-    ccb->channel_spec[channel].ta = 1;
-
-    ccb->channel_spec[channel].th = 0;
-
-    ccb->channel_spec[channel].ri = 1; /* Receive init */
-    ccb->channel_spec[channel].ro = 0;
-    ccb->channel_spec[channel].ra = 1;
-
-    ccb->action_spec = CCB_ACTIONSPEC_ICO | (channel << 8);
-    writel(CMD_ARPCM, MUNICH_VIRT(CMD));       /* Start the channel init */
-    set_current_state(TASK_UNINTERRUPTIBLE);
-    schedule_timeout(1);
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-
-    stat = 0;                  /* Wait for the action to complete max. 1 second */
-    jiffs = jiffies;
-    while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
-    {
-       set_current_state(TASK_UNINTERRUPTIBLE);
-        schedule_timeout(1);
-    }
-
-    if (stat & STAT_PCMF)
-    {
-       printk(KERN_ERR "MUNICH_open: %s: channel open ARPCM failed\n",
-              board->devname);
-       writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
-       MUNICH_close(dev);
-       return -EAGAIN;
-    }
-    else if (!(stat & STAT_PCMA))
-    {
-       printk(KERN_ERR "MUNICH_open: %s: channel open ARPCM timeout\n",
-              board->devname);
-       MUNICH_close(dev);
-       return -EIO;
-    }
-
-    writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT));
-    //      printk("MUNICH_open: %s: succesful channel open took %ld jiffies\n", board->devname, jiffies-jiffs);
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    ccb->channel_spec[channel].nitbs = 0;      /* once ITBS defined, these must be 0   */
-    ccb->channel_spec[channel].itbs = 0;
-
-    if (board->isx21)
-    {
-       init_timer(&board->modemline_timer);
-       board->modemline_timer.data = (unsigned long)board;
-       board->modemline_timer.function = pcicom_modemline;
-       board->modemline_timer.expires = jiffies + HZ;
-       add_timer((struct timer_list *)&board->modemline_timer);
-    }
-
-    /* It is done. Declare that we're open: */
-    hw->busy = 0;              /* It may be 1 if the frame at Tx init already ended, but it is not     */
-    /* a real problem: we compute hw->busy on every interrupt                       */
-    hw->rafutott = 0;
-    ch->init_status |= HW_OPEN;
-
-    /* Initialize line state: */
-    if (board->lineup)
-       ch->line_status |= LINE_UP;
-    else
-       ch->line_status &= ~LINE_UP;
-
-    /* Remove w attribute from /proc files associated to hw parameters:
-       no write when the device is open */
-
-    for (; procfile; procfile = procfile->next)
-       if (strcmp(procfile->name, FILENAME_BOARDNUM) == 0 ||
-           strcmp(procfile->name, FILENAME_TIMESLOTS) == 0)
-           procfile->mode = S_IFREG | 0444;
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-
-    return 0;
-}
-
-/*
- * Hardware close routine.
- * Called by comx (upper) layer when the user wants to bring down the interface
- * with ifconfig.
- * We also call it from MUNICH_open, if the open fails.
- * Brings down hardware, frees resources, stops receiver
- * Returns 0 on OK, or standard error value on error.
- */
-
-static int MUNICH_close(struct net_device *dev)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-    struct proc_dir_entry *procfile = ch->procdir->subdir;
-    munich_board_t *board;
-    munich_ccb_t *ccb;
-
-    u32 *bar1;
-    u32 timeslots = hw->timeslots;
-    int stat, i, channel = hw->channel;
-    unsigned long jiffs;
-
-    board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
-    ccb = board->ccb;
-    bar1 = board->bar1;
-
-    if (board->isx21)
-       del_timer((struct timer_list *)&board->modemline_timer);
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    set_current_state(TASK_UNINTERRUPTIBLE);
-    schedule_timeout(1);
-
-    /* Disable receiver for the channel: */
-
-    for (i = 0; i < 32; i++)
-       if ((1 << i) & timeslots)
-       {
-           ccb->timeslot_spec[i].tti = 1;
-           ccb->timeslot_spec[i].txfillmask = 0;       /* just to be double-sure :) */
-
-           ccb->timeslot_spec[i].rti = 1;
-           ccb->timeslot_spec[i].rxfillmask = 0;
-       }
-
-    if (!board->isx21) rework_idle_channels(dev);
-
-    ccb->channel_spec[channel].ti = 0; /* Receive off, Transmit off */
-    ccb->channel_spec[channel].to = 1;
-    ccb->channel_spec[channel].ta = 0;
-    ccb->channel_spec[channel].th = 1;
-
-    ccb->channel_spec[channel].ri = 0;
-    ccb->channel_spec[channel].ro = 1;
-    ccb->channel_spec[channel].ra = 0;
-
-    board->twins[channel] = NULL;
-
-    ccb->action_spec = CCB_ACTIONSPEC_IN | (channel << 8);
-    writel(CMD_ARPCM, MUNICH_VIRT(CMD));
-    set_current_state(TASK_UNINTERRUPTIBLE);
-    schedule_timeout(1);
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-
-    stat = 0;
-    jiffs = jiffies;
-    while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
-    {
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(1);
-    }
-
-    if (stat & STAT_PCMF)
-    {
-       printk(KERN_ERR
-              "MUNICH_close: %s: FATAL: channel off ARPCM failed, not closing!\n",
-              dev->name);
-       writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
-       /* If we return success, the privdata (and the descriptor list) will be freed */
-       return -EIO;
-    }
-    else if (!(stat & STAT_PCMA))
-       printk(KERN_ERR "MUNICH_close: %s: channel off ARPCM timeout\n",
-              board->devname);
-
-    writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT));
-    //      printk("MUNICH_close: %s: channel off took %ld jiffies\n", board->devname, jiffies-jiffs);
-
-    spin_lock_irqsave(&mister_lock, flags);
-
-    if (board->use_count) board->use_count--;
-
-    if (!board->use_count)     /* we were the last user of the board */
-    {
-       printk("MUNICH_close: bringing down board %s\n", board->devname);
-
-       /* program down the board: */
-
-       writel(0x0000FF7F, MUNICH_VIRT(IMASK)); /* do not send any interrupts */
-       writel(0, MUNICH_VIRT(CMD));    /* stop the timer if someone started it */
-       writel(~0U, MUNICH_VIRT(STAT)); /* if an interrupt came between the cli()-sti(), quiet it */
-       if (ch->hardware == &pcicomhw)
-           writel(0x1400, MUNICH_VIRT(GPDATA));
-
-       /* Put the board into 'reset' state: */
-       pci_write_config_dword(board->pci, MUNICH_PCI_PCIRES, 0xe0000);
-
-       /* Free irq and other resources: */
-       if (board->irq)
-           free_irq(board->irq, (void *)board);        /* Ha nem inicializalta magat, akkor meg nincs irq */
-       board->irq = 0;
-
-       /* Free CCB and the interrupt queues */
-       if (board->ccb) kfree((void *)board->ccb);
-       if (board->tiq) kfree((void *)board->tiq);
-       if (board->riq) kfree((void *)board->riq);
-       if (board->piq) kfree((void *)board->piq);
-       board->ccb = NULL;
-       board->tiq = board->riq = board->piq = NULL;
-    }
-
-    /* Enable setting of hw parameters */
-    for (; procfile; procfile = procfile->next)
-       if (strcmp(procfile->name, FILENAME_BOARDNUM) == 0 ||
-           strcmp(procfile->name, FILENAME_TIMESLOTS) == 0)
-           procfile->mode = S_IFREG | 0644;
-
-    /* We're not open anymore */
-    ch->init_status &= ~HW_OPEN;
-
-    spin_unlock_irqrestore(&mister_lock, flags);
-
-    return 0;
-}
-
-/* 
- * Give (textual) status information.
- * The text it returns will be a part of what appears when the user does a
- * cat /proc/comx/comx[n]/status 
- * Don't write more than PAGESIZE.
- * Return value: number of bytes written (length of the string, incl. 0)
- */
-
-static int MUNICH_minden(struct net_device *dev, char *page)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-    munich_board_t *board;
-    struct net_device *devp;
-
-    u8 *lbi;
-    e1_stats_t *curr_int, *prev_int;
-    e1_stats_t last4, last96;  /* sum of last 4, resp. last 96 intervals               */
-    unsigned *sump,            /* running pointer for the sum data                     */
-     *p;                       /* running pointer for the interval data                */
-
-    int len = 0;
-    u8 frs0, frs1;
-    u8 fmr2;
-    int i, j;
-    u32 timeslots;
-
-    board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
-    lbi = board->lbi;
-    curr_int = &board->intervals[board->current_interval];
-    prev_int =
-       &board->
-       intervals[(board->current_interval + SLICECOM_BOARD_INTERVALS_SIZE -
-                  1) % SLICECOM_BOARD_INTERVALS_SIZE];
-
-    if (!board->isx21)
-    {
-       frs0 = readb(lbi + FRS0);
-       fmr2 = readb(lbi + FMR2);
-       len += scnprintf(page + len, PAGE_SIZE - len, "Controller status:\n");
-       if (frs0 == 0)
-           len += scnprintf(page + len, PAGE_SIZE - len, "\tNo alarms\n");
-       else
-       {
-           if (frs0 & FRS0_LOS)
-                   len += scnprintf(page + len, PAGE_SIZE - len, "\tLoss Of Signal\n");
-           else
-           {
-               if (frs0 & FRS0_AIS)
-                   len += scnprintf(page + len, PAGE_SIZE - len,
-                                "\tAlarm Indication Signal\n");
-               else
-               {
-                   if (frs0 & FRS0_AUXP)
-                       len += scnprintf(page + len, PAGE_SIZE - len,
-                                    "\tAuxiliary Pattern Indication\n");
-                   if (frs0 & FRS0_LFA)
-                       len += scnprintf(page + len, PAGE_SIZE - len,
-                                    "\tLoss of Frame Alignment\n");
-                   else
-                   {
-                       if (frs0 & FRS0_RRA)
-                           len += scnprintf(page + len, PAGE_SIZE - len,
-                                        "\tReceive Remote Alarm\n");
-
-                       /* You can't set this framing with the /proc interface, but it  */
-                       /* may be good to have here this alarm if you set it by hand:   */
-
-                       if ((board->framing == SLICECOM_FRAMING_CRC4) &&
-                           (frs0 & FRS0_LMFA))
-                           len += scnprintf(page + len, PAGE_SIZE - len,
-                                        "\tLoss of CRC4 Multiframe Alignment\n");
-
-                       if (((fmr2 & 0xc0) == 0xc0) && (frs0 & FRS0_NMF))
-                           len += scnprintf(page + len, PAGE_SIZE - len,
-                                "\tNo CRC4 Multiframe alignment Found after 400 msec\n");
-                   }
-               }
-           }
-       }
-
-       frs1 = readb(lbi + FRS1);
-       if (FRS1_XLS & frs1)
-           len += scnprintf(page + len, PAGE_SIZE - len,
-                "\tTransmit Line Short\n");
-
-       /* debug Rx ring: DEL: - vagy meghagyni, de akkor legyen kicsit altalanosabb */
-    }
-
-    len += scnprintf(page + len, PAGE_SIZE - len, "Rx ring:\n");
-    len += scnprintf(page + len, PAGE_SIZE - len, "\trafutott: %d\n", hw->rafutott);
-    len += scnprintf(page + len, PAGE_SIZE - len,
-                "\tlastcheck: %ld, jiffies: %ld\n", board->lastcheck, jiffies);
-    len += scnprintf(page + len, PAGE_SIZE - len, "\tbase: %08x\n",
-       (u32) virt_to_phys(&hw->rx_desc[0]));
-    len += scnprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %d\n",
-                hw->rx_desc_ptr);
-    len += scnprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %08x\n",
-       (u32) virt_to_phys(&hw->rx_desc[hw->rx_desc_ptr]));
-    len += scnprintf(page + len, PAGE_SIZE - len, "\thw_curr_ptr: %08x\n",
-                board->ccb->current_rx_desc[hw->channel]);
-
-    for (i = 0; i < RX_DESC_MAX; i++)
-       len += scnprintf(page + len, PAGE_SIZE - len, "\t%08x %08x %08x %08x\n",
-                    *((u32 *) & hw->rx_desc[i] + 0),
-                    *((u32 *) & hw->rx_desc[i] + 1),
-                    *((u32 *) & hw->rx_desc[i] + 2),
-                    *((u32 *) & hw->rx_desc[i] + 3));
-
-    if (!board->isx21)
-    {
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "Interfaces using this board: (channel-group, interface, timeslots)\n");
-       for (i = 0; i < 32; i++)
-       {
-           devp = board->twins[i];
-           if (devp != NULL)
-           {
-               timeslots =
-                   ((struct slicecom_privdata *)((struct comx_channel *)devp->
-                                                 priv)->HW_privdata)->
-                   timeslots;
-               len += scnprintf(page + len, PAGE_SIZE - len, "\t%2d %s: ", i,
-                            devp->name);
-               for (j = 0; j < 32; j++)
-                   if ((1 << j) & timeslots)
-                       len += scnprintf(page + len, PAGE_SIZE - len, "%d ", j);
-               len += scnprintf(page + len, PAGE_SIZE - len, "\n");
-           }
-       }
-    }
-
-    len += scnprintf(page + len, PAGE_SIZE - len, "Interrupt work histogram:\n");
-    for (i = 0; i < MAX_WORK; i++)
-       len += scnprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i,
-                    board->histogram[i], (i &&
-                                          ((i + 1) % 4 == 0 ||
-                                           i == MAX_WORK - 1)) ? '\n' : ' ');
-
-    len += scnprintf(page + len, PAGE_SIZE - len, "Tx ring histogram:\n");
-    for (i = 0; i < TX_DESC_MAX; i++)
-       len += scnprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i,
-                    hw->tx_ring_hist[i], (i &&
-                                          ((i + 1) % 4 == 0 ||
-                                           i ==
-                                           TX_DESC_MAX - 1)) ? '\n' : ' ');
-
-    if (!board->isx21)
-    {
-
-       memset((void *)&last4, 0, sizeof(last4));
-       memset((void *)&last96, 0, sizeof(last96));
-
-       /* Calculate the sum of last 4 intervals: */
-
-       for (i = 1; i <= 4; i++)
-       {
-           p = (unsigned *)&board->intervals[(board->current_interval +
-                          SLICECOM_BOARD_INTERVALS_SIZE -
-                          i) % SLICECOM_BOARD_INTERVALS_SIZE];
-           sump = (unsigned *)&last4;
-           for (j = 0; j < (sizeof(e1_stats_t) / sizeof(unsigned)); j++)
-               sump[j] += p[j];
-       }
-
-       /* Calculate the sum of last 96 intervals: */
-
-       for (i = 1; i <= 96; i++)
-       {
-           p = (unsigned *)&board->intervals[(board->current_interval +
-                          SLICECOM_BOARD_INTERVALS_SIZE -
-                          i) % SLICECOM_BOARD_INTERVALS_SIZE];
-           sump = (unsigned *)&last96;
-           for (j = 0; j < (sizeof(e1_stats_t) / sizeof(unsigned)); j++)
-               sump[j] += p[j];
-       }
-
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "Data in current interval (%d seconds elapsed):\n",
-                    board->elapsed_seconds);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
-                    curr_int->line_code_violations,
-                    curr_int->path_code_violations, curr_int->e_bit_errors);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
-                    curr_int->slip_secs, curr_int->fr_loss_secs,
-                    curr_int->line_err_secs, curr_int->degraded_mins);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
-                    curr_int->errored_secs, curr_int->bursty_err_secs,
-                    curr_int->severely_err_secs, curr_int->unavail_secs);
-
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "Data in Interval 1 (15 minutes):\n");
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
-                    prev_int->line_code_violations,
-                    prev_int->path_code_violations, prev_int->e_bit_errors);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
-                    prev_int->slip_secs, prev_int->fr_loss_secs,
-                    prev_int->line_err_secs, prev_int->degraded_mins);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
-                    prev_int->errored_secs, prev_int->bursty_err_secs,
-                    prev_int->severely_err_secs, prev_int->unavail_secs);
-
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "Data in last 4 intervals (1 hour):\n");
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
-                    last4.line_code_violations, last4.path_code_violations,
-                    last4.e_bit_errors);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
-                    last4.slip_secs, last4.fr_loss_secs, last4.line_err_secs,
-                    last4.degraded_mins);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
-                    last4.errored_secs, last4.bursty_err_secs,
-                    last4.severely_err_secs, last4.unavail_secs);
-
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "Data in last 96 intervals (24 hours):\n");
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
-                    last96.line_code_violations, last96.path_code_violations,
-                    last96.e_bit_errors);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
-                    last96.slip_secs, last96.fr_loss_secs,
-                    last96.line_err_secs, last96.degraded_mins);
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "   %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
-                    last96.errored_secs, last96.bursty_err_secs,
-                    last96.severely_err_secs, last96.unavail_secs);
-
-    }
-
-//      len +=scnprintf( page + len, PAGE_SIZE - len, "Special events:\n" );
-//      len +=scnprintf( page + len, PAGE_SIZE - len, "\tstat_pri/missed: %u / %u\n", board->stat_pri_races, board->stat_pri_races_missed );
-//      len +=scnprintf( page + len, PAGE_SIZE - len, "\tstat_pti/missed: %u / %u\n", board->stat_pti_races, board->stat_pti_races_missed );
-    return len;
-}
-
-/*
- * Memory dump function. Not used currently.
- */
-static int BOARD_dump(struct net_device *dev)
-{
-    printk
-       ("BOARD_dump() requested. It is unimplemented, it should not be called\n");
-    return (-1);
-}
-
-/* 
- * /proc file read function for the files registered by this module.
- * This function is called by the procfs implementation when a user
- * wants to read from a file registered by this module.
- * page is the workspace, start should point to the real start of data,
- * off is the file offset, data points to the file's proc_dir_entry
- * structure.
- * Returns the number of bytes copied to the request buffer.
- */
-
-static int munich_read_proc(char *page, char **start, off_t off, int count,
-                           int *eof, void *data)
-{
-    struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-    struct net_device *dev = file->parent->data;
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-    munich_board_t *board;
-
-    int len = 0, i;
-    u32 timeslots = hw->timeslots;
-
-    board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
-    if (!strcmp(file->name, FILENAME_BOARDNUM))
-       len = sprintf(page, "%d\n", hw->boardnum);
-    else if (!strcmp(file->name, FILENAME_TIMESLOTS))
-    {
-       for (i = 0; i < 32; i++)
-           if ((1 << i) & timeslots)
-               len += scnprintf(page + len, PAGE_SIZE - len, "%d ", i);
-       len += scnprintf(page + len, PAGE_SIZE - len, "\n");
-    }
-    else if (!strcmp(file->name, FILENAME_FRAMING))
-    {
-       i = 0;
-       while (slicecom_framings[i].value &&
-              slicecom_framings[i].value != board->framing)
-           i++;
-       len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
-                    slicecom_framings[i].name);
-    }
-    else if (!strcmp(file->name, FILENAME_LINECODE))
-    {
-       i = 0;
-       while (slicecom_linecodes[i].value &&
-              slicecom_linecodes[i].value != board->linecode)
-           i++;
-       len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
-                    slicecom_linecodes[i].name);
-    }
-    else if (!strcmp(file->name, FILENAME_CLOCK_SOURCE))
-    {
-       i = 0;
-       while (slicecom_clock_sources[i].value &&
-              slicecom_clock_sources[i].value != board->clock_source)
-           i++;
-       len +=
-           scnprintf(page + len, PAGE_SIZE - len, "%s\n",
-                    slicecom_clock_sources[i].name);
-    }
-    else if (!strcmp(file->name, FILENAME_LOOPBACK))
-    {
-       i = 0;
-       while (slicecom_loopbacks[i].value &&
-              slicecom_loopbacks[i].value != board->loopback)
-           i++;
-       len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
-                    slicecom_loopbacks[i].name);
-    }
-    /* We set permissions to write-only for REG and LBIREG, but root can read them anyway: */
-    else if (!strcmp(file->name, FILENAME_REG))
-    {
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "%s: " FILENAME_REG ": write-only file\n", dev->name);
-    }
-    else if (!strcmp(file->name, FILENAME_LBIREG))
-    {
-       len += scnprintf(page + len, PAGE_SIZE - len,
-                    "%s: " FILENAME_LBIREG ": write-only file\n", dev->name);
-    }
-    else
-    {
-       printk("slicecom_read_proc: internal error, filename %s\n", file->name);
-       return -EBADF;
-    }
-    /* file handling administration: count eof status, offset, start address
-       and count: */
-
-    if (off >= len)
-    {
-       *eof = 1;
-       return 0;
-    }
-
-    *start = page + off;
-    if (count >= len - off)
-       *eof = 1;
-    return min((off_t) count, (off_t) len - off);
-}
-
-/* 
- * Write function for /proc files registered by us.
- * See the comment on read function above.
- * Beware! buffer is in userspace!!!
- * Returns the number of bytes written
- */
-
-static int munich_write_proc(struct file *file, const char *buffer,
-                            u_long count, void *data)
-{
-    struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
-    struct net_device *dev = (struct net_device *)entry->parent->data;
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw = ch->HW_privdata;
-    munich_board_t *board;
-
-    unsigned long ts, tmp_boardnum;
-
-    u32 tmp_timeslots = 0;
-    char *page, *p;
-    int i;
-
-    board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
-    /* Paranoia checking: */
-
-    if (PDE(file->f_dentry->d_inode) != entry)
-    {
-       printk(KERN_ERR "munich_write_proc: file <-> data internal error\n");
-       return -EIO;
-    }
-
-    /* Request tmp buffer */
-    if (!(page = (char *)__get_free_page(GFP_KERNEL)))
-       return -ENOMEM;
-
-    /* Copy user data and cut trailing \n */
-    if (copy_from_user(page, buffer, count = min(count, PAGE_SIZE))) {
-           free_page((unsigned long)page);
-           return -EFAULT;
-    }
-    if (*(page + count - 1) == '\n')
-       *(page + count - 1) = 0;
-    *(page + PAGE_SIZE - 1) = 0;
-
-    if (!strcmp(entry->name, FILENAME_BOARDNUM))
-    {
-       tmp_boardnum = simple_strtoul(page, NULL, 0);
-       if (0 <= tmp_boardnum && tmp_boardnum < MAX_BOARDS)
-           hw->boardnum = tmp_boardnum;
-       else
-       {
-           printk("%s: " FILENAME_BOARDNUM " range is 0...%d\n", dev->name,
-                  MAX_BOARDS - 1);
-           free_page((unsigned long)page);
-           return -EINVAL;
-       }
-    }
-    else if (!strcmp(entry->name, FILENAME_TIMESLOTS))
-    {
-       p = page;
-       while (*p)
-       {
-           if (isspace(*p))
-               p++;
-           else
-           {
-               ts = simple_strtoul(p, &p, 10); /* base = 10: Don't read 09 as an octal number */
-               /* ts = 0 ha nem tudta beolvasni a stringet, erre egy kicsit epitek itt: */
-               if (0 <= ts && ts < 32)
-               {
-                   tmp_timeslots |= (1 << ts);
-               }
-               else
-               {
-                   printk("%s: " FILENAME_TIMESLOTS " range is 1...31\n",
-                          dev->name);
-                   free_page((unsigned long)page);
-                   return -EINVAL;
-               }
-           }
-       }
-       hw->timeslots = tmp_timeslots;
-    }
-    else if (!strcmp(entry->name, FILENAME_FRAMING))
-    {
-       i = 0;
-       while (slicecom_framings[i].value &&
-              strncmp(slicecom_framings[i].name, page,
-                      strlen(slicecom_framings[i].name)))
-           i++;
-       if (!slicecom_framings[i].value)
-       {
-           printk("slicecom: %s: Invalid " FILENAME_FRAMING " '%s'\n",
-                  dev->name, page);
-           free_page((unsigned long)page);
-           return -EINVAL;
-       }
-       else
-       {                       /*
-                                * If somebody says:
-                                *      echo >boardnum  0
-                                *      echo >framing   no-crc4
-                                *      echo >boardnum  1
-                                * - when the framing was set, hw->boardnum was 0, so it would set the framing for board 0
-                                * Workaround: allow to set it only if interface is administrative UP
-                                */
-           if (netif_running(dev))
-               slicecom_set_framing(hw->boardnum, slicecom_framings[i].value);
-           else
-           {
-               printk("%s: " FILENAME_FRAMING
-                      " can not be set while the interface is DOWN\n",
-                      dev->name);
-               free_page((unsigned long)page);
-               return -EINVAL;
-           }
-       }
-    }
-    else if (!strcmp(entry->name, FILENAME_LINECODE))
-    {
-       i = 0;
-       while (slicecom_linecodes[i].value &&
-              strncmp(slicecom_linecodes[i].name, page,
-                      strlen(slicecom_linecodes[i].name)))
-           i++;
-       if (!slicecom_linecodes[i].value)
-       {
-           printk("slicecom: %s: Invalid " FILENAME_LINECODE " '%s'\n",
-                  dev->name, page);
-           free_page((unsigned long)page);
-           return -EINVAL;
-       }
-       else
-       {                       /*
-                                * Allow to set it only if interface is administrative UP,
-                                * for the same reason as FILENAME_FRAMING
-                                */
-           if (netif_running(dev))
-               slicecom_set_linecode(hw->boardnum,
-                                     slicecom_linecodes[i].value);
-           else
-           {
-               printk("%s: " FILENAME_LINECODE
-                      " can not be set while the interface is DOWN\n",
-                      dev->name);
-               free_page((unsigned long)page);
-               return -EINVAL;
-           }
-       }
-    }
-    else if (!strcmp(entry->name, FILENAME_CLOCK_SOURCE))
-    {
-       i = 0;
-       while (slicecom_clock_sources[i].value &&
-              strncmp(slicecom_clock_sources[i].name, page,
-                      strlen(slicecom_clock_sources[i].name)))
-           i++;
-       if (!slicecom_clock_sources[i].value)
-       {
-           printk("%s: Invalid " FILENAME_CLOCK_SOURCE " '%s'\n", dev->name,
-                  page);
-           free_page((unsigned long)page);
-           return -EINVAL;
-       }
-       else
-       {                       /*
-                                * Allow to set it only if interface is administrative UP,
-                                * for the same reason as FILENAME_FRAMING
-                                */
-           if (netif_running(dev))
-               slicecom_set_clock_source(hw->boardnum,
-                                         slicecom_clock_sources[i].value);
-           else
-           {
-               printk("%s: " FILENAME_CLOCK_SOURCE
-                      " can not be set while the interface is DOWN\n",
-                      dev->name);
-               free_page((unsigned long)page);
-               return -EINVAL;
-           }
-       }
-    }
-    else if (!strcmp(entry->name, FILENAME_LOOPBACK))
-    {
-       i = 0;
-       while (slicecom_loopbacks[i].value &&
-              strncmp(slicecom_loopbacks[i].name, page,
-                      strlen(slicecom_loopbacks[i].name)))
-           i++;
-       if (!slicecom_loopbacks[i].value)
-       {
-           printk("%s: Invalid " FILENAME_LOOPBACK " '%s'\n", dev->name, page);
-           free_page((unsigned long)page);
-           return -EINVAL;
-       }
-       else
-       {                       /*
-                                * Allow to set it only if interface is administrative UP,
-                                * for the same reason as FILENAME_FRAMING
-                                */
-           if (netif_running(dev))
-               slicecom_set_loopback(hw->boardnum,
-                                     slicecom_loopbacks[i].value);
-           else
-           {
-               printk("%s: " FILENAME_LOOPBACK
-                      " can not be set while the interface is DOWN\n",
-                      dev->name);
-               free_page((unsigned long)page);
-               return -EINVAL;
-           }
-       }
-    }
-    else if (!strcmp(entry->name, FILENAME_REG))
-    {                          /* DEL: 'reg' csak tmp */
-       char *p;
-       u32 *bar1 = board->bar1;
-
-       reg = simple_strtoul(page, &p, 0);
-       reg_ertek = simple_strtoul(p + 1, NULL, 0);
-
-       if (reg < 0x100)
-       {
-           printk("reg(0x%02x) := 0x%08x  jiff: %lu\n", reg, reg_ertek, jiffies);
-           writel(reg_ertek, MUNICH_VIRT(reg >> 2));
-       }
-       else
-       {
-           printk("reg(0x%02x) is 0x%08x  jiff: %lu\n", reg - 0x100,
-                  readl(MUNICH_VIRT((reg - 0x100) >> 2)), jiffies);
-       }
-    }
-    else if (!strcmp(entry->name, FILENAME_LBIREG))
-    {                          /* DEL: 'lbireg' csak tmp */
-       char *p;
-       u8 *lbi = board->lbi;
-
-       lbireg = simple_strtoul(page, &p, 0);
-       lbireg_ertek = simple_strtoul(p + 1, NULL, 0);
-
-       if (lbireg < 0x100)
-       {
-           printk("lbireg(0x%02x) := 0x%02x  jiff: %lu\n", lbireg,
-                  lbireg_ertek, jiffies);
-           writeb(lbireg_ertek, lbi + lbireg);
-       }
-       else
-           printk("lbireg(0x%02x) is 0x%02x  jiff: %lu\n", lbireg - 0x100,
-                  readb(lbi + lbireg - 0x100), jiffies);
-    }
-    else
-    {
-       printk(KERN_ERR "munich_write_proc: internal error, filename %s\n",
-              entry->name);
-       free_page((unsigned long)page);
-       return -EBADF;
-    }
-
-    /* Don't forget to free the workspace */
-    free_page((unsigned long)page);
-    return count;
-}
-
-/* 
- * Boardtype init function.
- * Called by the comx (upper) layer, when you set boardtype.
- * Allocates resources associated to using munich board for this device,
- * initializes ch_struct pointers etc.
- * Returns 0 on success and standard error codes on error.
- */
-
-static int init_escape(struct comx_channel *ch)
-{
-    kfree(ch->HW_privdata);
-    return -EIO;
-}
-
-static int BOARD_init(struct net_device *dev)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-    struct slicecom_privdata *hw;
-    struct proc_dir_entry *new_file;
-
-    /* Alloc data for private structure */
-    if ((ch->HW_privdata =
-       kmalloc(sizeof(struct slicecom_privdata), GFP_KERNEL)) == NULL)
-        return -ENOMEM;
-        
-    memset(hw = ch->HW_privdata, 0, sizeof(struct slicecom_privdata));
-
-    /* Register /proc files */
-    if ((new_file = create_proc_entry(FILENAME_BOARDNUM, S_IFREG | 0644,
-                          ch->procdir)) == NULL)
-       return init_escape(ch);
-    new_file->data = (void *)new_file;
-    new_file->read_proc = &munich_read_proc;
-    new_file->write_proc = &munich_write_proc;
-//      new_file->proc_iops = &comx_normal_inode_ops;
-    new_file->nlink = 1;
-
-    if (ch->hardware == &slicecomhw)
-    {
-       if ((new_file = create_proc_entry(FILENAME_TIMESLOTS, S_IFREG | 0644,
-                              ch->procdir)) == NULL)
-           return init_escape(ch);
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &munich_read_proc;
-       new_file->write_proc = &munich_write_proc;
-//              new_file->proc_iops = &comx_normal_inode_ops;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_FRAMING, S_IFREG | 0644,
-                              ch->procdir)) == NULL)
-           return init_escape(ch);
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &munich_read_proc;
-       new_file->write_proc = &munich_write_proc;
-//              new_file->proc_iops = &comx_normal_inode_ops;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_LINECODE, S_IFREG | 0644,
-                              ch->procdir)) == NULL)
-           return init_escape(ch);
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &munich_read_proc;
-       new_file->write_proc = &munich_write_proc;
-//              new_file->proc_iops = &comx_normal_inode_ops;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_CLOCK_SOURCE, S_IFREG | 0644,
-                              ch->procdir)) == NULL)
-           return init_escape(ch);
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &munich_read_proc;
-       new_file->write_proc = &munich_write_proc;
-//              new_file->proc_iops = &comx_normal_inode_ops;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_LOOPBACK, S_IFREG | 0644,
-                              ch->procdir)) == NULL)
-           return init_escape(ch);
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &munich_read_proc;
-       new_file->write_proc = &munich_write_proc;
-//              new_file->proc_iops = &comx_normal_inode_ops;
-       new_file->nlink = 1;
-    }
-
-    /* DEL: ez itt csak fejlesztesi celokra!! */
-    if ((new_file = create_proc_entry(FILENAME_REG, S_IFREG | 0200, ch->procdir)) == NULL)
-       return init_escape(ch);
-    new_file->data = (void *)new_file;
-    new_file->read_proc = &munich_read_proc;
-    new_file->write_proc = &munich_write_proc;
-//      new_file->proc_iops = &comx_normal_inode_ops;
-    new_file->nlink = 1;
-
-    /* DEL: ez itt csak fejlesztesi celokra!! */
-    if ((new_file = create_proc_entry(FILENAME_LBIREG, S_IFREG | 0200,
-                          ch->procdir)) == NULL)
-       return init_escape(ch);
-    new_file->data = (void *)new_file;
-    new_file->read_proc = &munich_read_proc;
-    new_file->write_proc = &munich_write_proc;
-//      new_file->proc_iops = &comx_normal_inode_ops;
-    new_file->nlink = 1;
-
-    /* Fill in ch_struct hw specific pointers: */
-
-    ch->HW_txe = MUNICH_txe;
-    ch->HW_open = MUNICH_open;
-    ch->HW_close = MUNICH_close;
-    ch->HW_send_packet = MUNICH_send_packet;
-#ifndef COMX_NEW
-    ch->HW_minden = MUNICH_minden;
-#else
-    ch->HW_statistics = MUNICH_minden;
-#endif
-
-    hw->boardnum = SLICECOM_BOARDNUM_DEFAULT;
-    hw->timeslots = ch->hardware == &pcicomhw ?  0xffffffff : 2;
-
-    /* O.K. Count one more user on this module */
-    MOD_INC_USE_COUNT;
-    return 0;
-}
-
-/* 
- * Boardtype exit function.
- * Called by the comx (upper) layer, when you clear boardtype from munich.
- * Frees resources associated to using munich board for this device,
- * resets ch_struct pointers etc.
- */
-static int BOARD_exit(struct net_device *dev)
-{
-    struct comx_channel *ch = netdev_priv(dev);
-
-    /* Free private data area */
-//    board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
-    kfree(ch->HW_privdata);
-    /* Remove /proc files */
-    remove_proc_entry(FILENAME_BOARDNUM, ch->procdir);
-    if (ch->hardware == &slicecomhw)
-    {
-       remove_proc_entry(FILENAME_TIMESLOTS, ch->procdir);
-       remove_proc_entry(FILENAME_FRAMING, ch->procdir);
-       remove_proc_entry(FILENAME_LINECODE, ch->procdir);
-       remove_proc_entry(FILENAME_CLOCK_SOURCE, ch->procdir);
-       remove_proc_entry(FILENAME_LOOPBACK, ch->procdir);
-    }
-    remove_proc_entry(FILENAME_REG, ch->procdir);
-    remove_proc_entry(FILENAME_LBIREG, ch->procdir);
-
-    /* Minus one user for the module accounting */
-    MOD_DEC_USE_COUNT;
-    return 0;
-}
-
-static struct comx_hardware slicecomhw =
-{
-    "slicecom",
-#ifdef COMX_NEW
-    VERSION,
-#endif
-    BOARD_init,
-    BOARD_exit,
-    BOARD_dump,
-    NULL
-};
-
-static struct comx_hardware pcicomhw =
-{
-    "pcicom",
-#ifdef COMX_NEW
-    VERSION,
-#endif
-    BOARD_init,
-    BOARD_exit,
-    BOARD_dump,
-    NULL
-};
-
-/* Module management */
-
-static int __init init_mister(void)
-{
-    printk(VERSIONSTR);
-    comx_register_hardware(&slicecomhw);
-    comx_register_hardware(&pcicomhw);
-    return munich_probe();
-}
-
-static void __exit cleanup_mister(void)
-{
-    int i;
-
-    comx_unregister_hardware("slicecom");
-    comx_unregister_hardware("pcicom");
-
-    for (i = 0; i < MAX_BOARDS; i++)
-    {
-       if (slicecom_boards[i].bar1)
-           iounmap((void *)slicecom_boards[i].bar1);
-       if (slicecom_boards[i].lbi)
-           iounmap((void *)slicecom_boards[i].lbi);
-       if (pcicom_boards[i].bar1)
-           iounmap((void *)pcicom_boards[i].bar1);
-       if (pcicom_boards[i].lbi)
-           iounmap((void *)pcicom_boards[i].lbi);
-    }
-}
-
-module_init(init_mister);
-module_exit(cleanup_mister);
diff --git a/drivers/net/wan/comx-proto-fr.c b/drivers/net/wan/comx-proto-fr.c
deleted file mode 100644 (file)
index c955136..0000000
+++ /dev/null
@@ -1,1014 +0,0 @@
-/*
- * Frame-relay protocol module for the COMX driver 
- * for Linux 2.2.X
- *
- * Original author: Tivadar Szemethy <tiv@itc.hu>
- * Maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1998-1999 ITConsult-Pro Co. <info@itc.hu>
- * 
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.73)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.70 (99/06/14):
- *             - cleaned up the source code a bit
- *             - ported back to kernel, now works as builtin code 
- *
- * Version 0.71 (99/06/25):
- *             - use skb priorities and queues for sending keepalive
- *             - use device queues for slave->master data transmit
- *             - set IFF_RUNNING only line protocol up
- *             - fixes on slave device flags
- * 
- * Version 0.72 (99/07/09):
- *             - handle slave tbusy with master tbusy (should be fixed)
- *             - fix the keepalive timer addition/deletion
- *
- * Version 0.73 (00/08/15)
- *             - resource release on failure at fr_master_init and
- *               fr_slave_init                   
- */
-
-#define VERSION "0.73"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/jiffies.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/if_arp.h>
-#include <linux/inetdevice.h>
-#include <linux/pkt_sched.h>
-#include <linux/init.h>
-
-#include <asm/uaccess.h>
-
-#include "comx.h"
-#include "comxhw.h"
-
-MODULE_AUTHOR("Author: Tivadar Szemethy <tiv@itc.hu>");
-MODULE_DESCRIPTION("Frame Relay protocol implementation for the COMX drivers"
-       "for Linux kernel 2.4.X");
-MODULE_LICENSE("GPL");
-
-#define        FRAD_UI         0x03
-#define        NLPID_IP        0xcc
-#define        NLPID_Q933_LMI  0x08
-#define        NLPID_CISCO_LMI 0x09    
-#define Q933_ENQ       0x75
-#define        Q933_LINESTAT   0x51
-#define        Q933_COUNTERS   0x53
-
-#define        MAXALIVECNT     3               /* No. of failures */
-
-struct fr_data {
-       u16     dlci;
-       struct  net_device *master;
-       char    keepa_pend;
-       char    keepa_freq;
-       char    keepalivecnt, keeploopcnt;
-       struct  timer_list keepa_timer;
-       u8      local_cnt, remote_cnt;
-};
-
-static struct comx_protocol fr_master_protocol;
-static struct comx_protocol fr_slave_protocol;
-static struct comx_hardware fr_dlci;
-
-static void fr_keepalive_send(struct net_device *dev) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct sk_buff *skb;
-       u8 *fr_packet;
-       
-       skb=alloc_skb(dev->hard_header_len + 13, GFP_ATOMIC);
-       
-       if(skb==NULL)
-               return;
-               
-        skb_reserve(skb, dev->hard_header_len);
-        
-        fr_packet=(u8*)skb_put(skb, 13);
-                 
-       fr_packet[0] = (fr->dlci & (1024 - 15)) >> 2;
-       fr_packet[1] = (fr->dlci & 15) << 4 | 1;        // EA bit 1
-       fr_packet[2] = FRAD_UI;
-       fr_packet[3] = NLPID_Q933_LMI;
-       fr_packet[4] = 0;
-       fr_packet[5] = Q933_ENQ;
-       fr_packet[6] = Q933_LINESTAT;
-       fr_packet[7] = 0x01;
-       fr_packet[8] = 0x01;
-       fr_packet[9] = Q933_COUNTERS;
-       fr_packet[10] = 0x02;
-       fr_packet[11] = ++fr->local_cnt;
-       fr_packet[12] = fr->remote_cnt;
-
-       skb->dev = dev;
-       skb->priority = TC_PRIO_CONTROL;
-       dev_queue_xmit(skb);
-}
-
-static void fr_keepalive_timerfun(unsigned long d) 
-{
-       struct net_device *dev = (struct net_device *)d;
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-       struct comx_channel *sch;
-       struct fr_data *sfr;
-       struct net_device *sdev;
-
-       if (ch->init_status & LINE_OPEN) {
-               if (fr->keepalivecnt == MAXALIVECNT) {
-                       comx_status(dev, ch->line_status & ~PROTO_UP);
-                       dev->flags &= ~IFF_RUNNING;
-                       for (; dir ; dir = dir->next) {
-                               if(!S_ISDIR(dir->mode)) {
-                                   continue;
-                               }
-       
-                               if ((sdev = dir->data) && (sch = sdev->priv) && 
-                                   (sdev->type == ARPHRD_DLCI) && 
-                                   (sfr = sch->LINE_privdata) 
-                                   && (sfr->master == dev) && 
-                                   (sdev->flags & IFF_UP)) {
-                                       sdev->flags &= ~IFF_RUNNING;
-                                       comx_status(sdev, 
-                                               sch->line_status & ~PROTO_UP);
-                               }
-                       }
-               }
-               if (fr->keepalivecnt <= MAXALIVECNT) {
-                       ++fr->keepalivecnt;
-               }
-               fr_keepalive_send(dev);
-       }
-       mod_timer(&fr->keepa_timer, jiffies + HZ * fr->keepa_freq);
-}
-
-static void fr_rx_lmi(struct net_device *dev, struct sk_buff *skb, 
-       u16 dlci, u8 nlpid) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-       struct comx_channel *sch;
-       struct fr_data *sfr;
-       struct net_device *sdev;
-
-       if (dlci != fr->dlci || nlpid != NLPID_Q933_LMI || !fr->keepa_freq) {
-               return;
-       }
-
-       fr->remote_cnt = skb->data[7];
-       if (skb->data[8] == fr->local_cnt) { // keepalive UP!
-               fr->keepalivecnt = 0;
-               if ((ch->line_status & LINE_UP) && 
-                   !(ch->line_status & PROTO_UP)) {
-                       comx_status(dev, ch->line_status |= PROTO_UP);
-                       dev->flags |= IFF_RUNNING;
-                       for (; dir ; dir = dir->next) {
-                               if(!S_ISDIR(dir->mode)) {
-                                   continue;
-                               }
-       
-                               if ((sdev = dir->data) && (sch = sdev->priv) && 
-                                   (sdev->type == ARPHRD_DLCI) && 
-                                   (sfr = sch->LINE_privdata) 
-                                   && (sfr->master == dev) && 
-                                   (sdev->flags & IFF_UP)) {
-                                       sdev->flags |= IFF_RUNNING;
-                                       comx_status(sdev, 
-                                               sch->line_status | PROTO_UP);
-                               }
-                       }
-               }
-       }
-}
-
-static void fr_set_keepalive(struct net_device *dev, int keepa) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-
-       if (!keepa && fr->keepa_freq) { // switch off
-               fr->keepa_freq = 0;
-               if (ch->line_status & LINE_UP) {
-                       comx_status(dev, ch->line_status | PROTO_UP);
-                       dev->flags |= IFF_RUNNING;
-                       del_timer(&fr->keepa_timer);
-               }
-               return;
-       }
-
-       if (keepa) { // bekapcs
-               if(fr->keepa_freq && (ch->line_status & LINE_UP)) {
-                       del_timer(&fr->keepa_timer);
-               }
-               fr->keepa_freq = keepa;
-               fr->local_cnt = fr->remote_cnt = 0;
-               init_timer(&fr->keepa_timer);
-               fr->keepa_timer.expires = jiffies + HZ;
-               fr->keepa_timer.function = fr_keepalive_timerfun;
-               fr->keepa_timer.data = (unsigned long)dev;
-               ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
-               dev->flags &= ~IFF_RUNNING;
-               comx_status(dev, ch->line_status);
-               if(ch->line_status & LINE_UP) {
-                       add_timer(&fr->keepa_timer);
-               }
-       }
-}
-
-static void fr_rx(struct net_device *dev, struct sk_buff *skb) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-       struct net_device *sdev = dev;
-       struct comx_channel *sch;
-       struct fr_data *sfr;
-       u16 dlci;
-       u8 nlpid;
-
-       if(skb->len <= 4 || skb->data[2] != FRAD_UI) {
-               kfree_skb(skb);
-               return;
-       }
-
-       /* Itt majd ki kell talalni, melyik slave kapja a csomagot */
-       dlci = ((skb->data[0] & 0xfc) << 2) | ((skb->data[1] & 0xf0) >> 4);
-       if ((nlpid = skb->data[3]) == 0) { // Optional padding 
-               nlpid = skb->data[4];
-               skb_pull(skb, 1);
-       }
-       skb_pull(skb, 4);       /* DLCI and header throw away */
-
-       if (ch->debug_flags & DEBUG_COMX_DLCI) {
-               comx_debug(dev, "Frame received, DLCI: %d, NLPID: 0x%02x\n", 
-                       dlci, nlpid);
-               comx_debug_skb(dev, skb, "Contents");
-       }
-
-       /* Megkeressuk, kihez tartozik */
-       for (; dir ; dir = dir->next) {
-               if(!S_ISDIR(dir->mode)) {
-                       continue;
-               }
-               if ((sdev = dir->data) && (sch = sdev->priv) && 
-                   (sdev->type == ARPHRD_DLCI) && (sfr = sch->LINE_privdata) &&
-                   (sfr->master == dev) && (sfr->dlci == dlci)) {
-                       skb->dev = sdev;        
-                       if (ch->debug_flags & DEBUG_COMX_DLCI) {
-                               comx_debug(dev, "Passing it to %s\n",sdev->name);
-                       }
-                       if (dev != sdev) {
-                               sch->stats.rx_packets++;
-                               sch->stats.rx_bytes += skb->len;
-                       }
-                       break;
-               }
-       }
-       switch(nlpid) {
-               case NLPID_IP:
-                       skb->protocol = htons(ETH_P_IP);
-                       skb->mac.raw = skb->data;
-                       comx_rx(sdev, skb);
-                       break;
-               case NLPID_Q933_LMI:
-                       fr_rx_lmi(dev, skb, dlci, nlpid);
-               default:
-                       kfree_skb(skb);
-                       break;
-       }
-}
-
-static int fr_tx(struct net_device *dev) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-       struct net_device *sdev;
-       struct comx_channel *sch;
-       struct fr_data *sfr;
-       int cnt = 1;
-
-       /* Ha minden igaz, 2 helyen fog allni a tbusy: a masternel, 
-          es annal a slave-nel aki eppen kuldott.
-          Egy helyen akkor all, ha a master kuldott.
-          Ez megint jo lesz majd, ha utemezni akarunk */
-          
-       /* This should be fixed, the slave tbusy should be set when 
-          the masters queue is full and reset when not */
-
-       for (; dir ; dir = dir->next) {
-               if(!S_ISDIR(dir->mode)) {
-                   continue;
-               }
-               if ((sdev = dir->data) && (sch = sdev->priv) && 
-                   (sdev->type == ARPHRD_DLCI) && (sfr = sch->LINE_privdata) &&
-                   (sfr->master == dev) && (netif_queue_stopped(sdev))) {
-                       netif_wake_queue(sdev);
-                       cnt++;
-               }
-       }
-
-       netif_wake_queue(dev);
-       return 0;
-}
-
-static void fr_status(struct net_device *dev, unsigned short status)
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-       struct net_device *sdev;
-       struct comx_channel *sch;
-       struct fr_data *sfr;
-
-       if (status & LINE_UP) {
-               if (!fr->keepa_freq) {
-                       status |= PROTO_UP;
-               }
-       } else {
-               status &= ~(PROTO_UP | PROTO_LOOP);
-       }
-
-       if (dev == fr->master && fr->keepa_freq) {
-               if (status & LINE_UP) {
-                       fr->keepa_timer.expires = jiffies + HZ;
-                       add_timer(&fr->keepa_timer);
-                       fr->keepalivecnt = MAXALIVECNT + 1;
-                       fr->keeploopcnt = 0;
-               } else {
-                       del_timer(&fr->keepa_timer);
-               }
-       }
-               
-       /* Itt a status valtozast vegig kell vinni az osszes slave-n */
-       for (; dir ; dir = dir->next) {
-               if(!S_ISDIR(dir->mode)) {
-                   continue;
-               }
-       
-               if ((sdev = dir->data) && (sch = sdev->priv) && 
-                   (sdev->type == ARPHRD_FRAD || sdev->type == ARPHRD_DLCI) && 
-                   (sfr = sch->LINE_privdata) && (sfr->master == dev)) {
-                       if(status & LINE_UP) {
-                               netif_wake_queue(sdev);
-                       }
-                       comx_status(sdev, status);
-                       if(status & (PROTO_UP | PROTO_LOOP)) {
-                               dev->flags |= IFF_RUNNING;
-                       } else {
-                               dev->flags &= ~IFF_RUNNING;
-                       }
-               }
-       }
-}
-
-static int fr_open(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct proc_dir_entry *comxdir = ch->procdir;
-       struct comx_channel *mch;
-
-       if (!(ch->init_status & HW_OPEN)) {
-               return -ENODEV;
-       }
-
-       if ((ch->hardware == &fr_dlci && ch->protocol != &fr_slave_protocol) ||
-           (ch->protocol == &fr_slave_protocol && ch->hardware != &fr_dlci)) {
-               printk(KERN_ERR "Trying to open an improperly set FR interface, giving up\n");
-               return -EINVAL;
-       }
-
-       if (!fr->master) {
-               return -ENODEV;
-       }
-       mch = fr->master->priv;
-       if (fr->master != dev && (!(mch->init_status & LINE_OPEN) 
-          || (mch->protocol != &fr_master_protocol))) {
-               printk(KERN_ERR "Master %s is inactive, or incorrectly set up, "
-                       "unable to open %s\n", fr->master->name, dev->name);
-               return -ENODEV;
-       }
-
-       ch->init_status |= LINE_OPEN;
-       ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
-       dev->flags &= ~IFF_RUNNING;
-
-       if (fr->master == dev) {
-               if (fr->keepa_freq) {
-                       fr->keepa_timer.function = fr_keepalive_timerfun;
-                       fr->keepa_timer.data = (unsigned long)dev;
-                       add_timer(&fr->keepa_timer);
-               } else {
-                       if (ch->line_status & LINE_UP) {
-                               ch->line_status |= PROTO_UP;
-                               dev->flags |= IFF_RUNNING;
-                       }
-               }
-       } else {
-               ch->line_status = mch->line_status;
-               if(fr->master->flags & IFF_RUNNING) {
-                       dev->flags |= IFF_RUNNING;
-               }
-       }
-
-       for (; comxdir ; comxdir = comxdir->next) {
-               if (strcmp(comxdir->name, FILENAME_DLCI) == 0 ||
-                  strcmp(comxdir->name, FILENAME_MASTER) == 0 ||
-                  strcmp(comxdir->name, FILENAME_KEEPALIVE) == 0) {
-                       comxdir->mode = S_IFREG | 0444;
-               }
-       }
-//     comx_status(dev, ch->line_status);
-       return 0;
-}
-
-static int fr_close(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct proc_dir_entry *comxdir = ch->procdir;
-
-       if (fr->master == dev) { // Ha master 
-               struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-               struct net_device *sdev = dev;
-               struct comx_channel *sch;
-               struct fr_data *sfr;
-
-               if (!(ch->init_status & HW_OPEN)) {
-                       return -ENODEV;
-               }
-
-               if (fr->keepa_freq) {
-                       del_timer(&fr->keepa_timer);
-               }
-               
-               for (; dir ; dir = dir->next) {
-                       if(!S_ISDIR(dir->mode)) {
-                               continue;
-                       }
-                       if ((sdev = dir->data) && (sch = sdev->priv) && 
-                           (sdev->type == ARPHRD_DLCI) && 
-                           (sfr = sch->LINE_privdata) &&
-                           (sfr->master == dev) && 
-                           (sch->init_status & LINE_OPEN)) {
-                               dev_close(sdev);
-                       }
-               }
-       }
-
-       ch->init_status &= ~LINE_OPEN;
-       ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
-       dev->flags &= ~IFF_RUNNING;
-
-       for (; comxdir ; comxdir = comxdir->next) {
-               if (strcmp(comxdir->name, FILENAME_DLCI) == 0 ||
-                   strcmp(comxdir->name, FILENAME_MASTER) == 0 ||
-                   strcmp(comxdir->name, FILENAME_KEEPALIVE) == 0) {
-                       comxdir->mode = S_IFREG | 0444;
-               }
-       }
-
-       return 0;
-}
-
-static int fr_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct comx_channel *sch, *mch;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct fr_data *sfr;
-       struct net_device *sdev;
-       struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-
-       if (!fr->master) {
-               printk(KERN_ERR "BUG: fr_xmit without a master!!! dev: %s\n", dev->name);
-               return 0;
-       }
-
-       mch = fr->master->priv;
-
-       /* Ennek majd a slave utemezeskor lesz igazan jelentosege */
-       if (ch->debug_flags & DEBUG_COMX_DLCI) {
-               comx_debug_skb(dev, skb, "Sending frame");
-       }
-
-       if (dev != fr->master) {
-               struct sk_buff *newskb=skb_clone(skb, GFP_ATOMIC);
-               if (!newskb)
-                       return -ENOMEM;
-               newskb->dev=fr->master;
-               dev_queue_xmit(newskb);
-               ch->stats.tx_bytes += skb->len;
-               ch->stats.tx_packets++;
-               dev_kfree_skb(skb);
-       } else {
-               netif_stop_queue(dev);
-               for (; dir ; dir = dir->next) {
-                       if(!S_ISDIR(dir->mode)) {
-                           continue;
-                       }
-                       if ((sdev = dir->data) && (sch = sdev->priv) && 
-                           (sdev->type == ARPHRD_DLCI) && (sfr = sch->LINE_privdata) &&
-                           (sfr->master == dev) && (netif_queue_stopped(sdev))) {
-                               netif_stop_queue(sdev);
-                       }
-               }
-                       
-               switch(mch->HW_send_packet(dev, skb)) {
-                       case FRAME_QUEUED:
-                               netif_wake_queue(dev);
-                               break;
-                       case FRAME_ACCEPTED:
-                       case FRAME_DROPPED:
-                               break;
-                       case FRAME_ERROR:
-                               printk(KERN_ERR "%s: Transmit frame error (len %d)\n", 
-                                       dev->name, skb->len);
-                               break;
-               }
-       }
-       return 0;
-}
-
-static int fr_header(struct sk_buff *skb, struct net_device *dev, 
-       unsigned short type, void *daddr, void *saddr, unsigned len) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-
-       skb_push(skb, dev->hard_header_len);      
-       /* Put in DLCI */
-       skb->data[0] = (fr->dlci & (1024 - 15)) >> 2;
-       skb->data[1] = (fr->dlci & 15) << 4 | 1;        // EA bit 1
-       skb->data[2] = FRAD_UI;
-       skb->data[3] = NLPID_IP;
-
-       return dev->hard_header_len;  
-}
-
-static int fr_statistics(struct net_device *dev, char *page) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       int len = 0;
-
-       if (fr->master == dev) {
-               struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-               struct net_device *sdev;
-               struct comx_channel *sch;
-               struct fr_data *sfr;
-               int slaves = 0;
-
-               len += sprintf(page + len, 
-                       "This is a Frame Relay master device\nSlaves: ");
-               for (; dir ; dir = dir->next) {
-                       if(!S_ISDIR(dir->mode)) {
-                               continue;
-                       }
-                       if ((sdev = dir->data) && (sch = sdev->priv) && 
-                           (sdev->type == ARPHRD_DLCI) &&
-                           (sfr = sch->LINE_privdata) && 
-                           (sfr->master == dev) && (sdev != dev)) {
-                               slaves++;
-                               len += sprintf(page + len, "%s ", sdev->name);
-                       }
-               }
-               len += sprintf(page + len, "%s\n", slaves ? "" : "(none)");
-               if (fr->keepa_freq) {
-                       len += sprintf(page + len, "Line keepalive (value %d) "
-                               "status %s [%d]\n", fr->keepa_freq, 
-                               ch->line_status & PROTO_LOOP ? "LOOP" :
-                               ch->line_status & PROTO_UP ? "UP" : "DOWN", 
-                               fr->keepalivecnt);
-               } else {
-                       len += sprintf(page + len, "Line keepalive protocol "
-                               "is not set\n");
-               }
-       } else {                // if slave
-               len += sprintf(page + len, 
-                       "This is a Frame Relay slave device, master: %s\n",
-                       fr->master ? fr->master->name : "(not set)");
-       }
-       return len;
-}
-
-static int fr_read_proc(char *page, char **start, off_t off, int count,
-       int *eof, void *data)
-{
-       struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-       struct net_device *dev = file->parent->data;
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = NULL;
-       int len = 0;
-
-       if (ch) {
-               fr = ch->LINE_privdata;
-       }
-
-       if (strcmp(file->name, FILENAME_DLCI) == 0) {
-               len = sprintf(page, "%04d\n", fr->dlci);
-       } else if (strcmp(file->name, FILENAME_MASTER) == 0) {
-               len = sprintf(page, "%-9s\n", fr->master ? fr->master->name :
-                       "(none)");
-       } else if (strcmp(file->name, FILENAME_KEEPALIVE) == 0) {
-               len = fr->keepa_freq ? sprintf(page, "% 3d\n", fr->keepa_freq) 
-                       : sprintf(page, "off\n");
-       } else {
-               printk(KERN_ERR "comxfr: internal error, filename %s\n", file->name);
-               return -EBADF;
-       }
-
-       if (off >= len) {
-               *eof = 1;
-               return 0;
-       }
-
-       *start = page + off;
-       if (count >= len - off) *eof = 1;
-       return min_t(int, count, len - off);
-}
-
-static int fr_write_proc(struct file *file, const char *buffer, 
-       u_long count, void *data)
-{
-       struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
-       struct net_device *dev = entry->parent->data;
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = NULL; 
-       char *page;
-
-       if (ch) {
-               fr = ch->LINE_privdata;
-       }
-
-       if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
-               return -ENOMEM;
-       }
-
-       if (copy_from_user(page, buffer, count)) {
-               free_page((unsigned long)page);
-               return -EFAULT;
-       }
-       if (*(page + count - 1) == '\n') {
-               *(page + count - 1) = 0;
-       }
-
-       if (strcmp(entry->name, FILENAME_DLCI) == 0) {
-               u16 dlci_new = simple_strtoul(page, NULL, 10);
-
-               if (dlci_new > 1023) {
-                       printk(KERN_ERR "Invalid DLCI value\n");
-               }
-               else fr->dlci = dlci_new;
-       } else if (strcmp(entry->name, FILENAME_MASTER) == 0) {
-               struct net_device *new_master = dev_get_by_name(page);
-
-               if (new_master && new_master->type == ARPHRD_FRAD) {
-                       struct comx_channel *sch = new_master->priv;
-                       struct fr_data *sfr = sch->LINE_privdata;
-
-                       if (sfr && sfr->master == new_master) {
-                               if(fr->master)
-                                       dev_put(fr->master);
-                               fr->master = new_master;
-                               /* Megorokli a master statuszat */
-                               ch->line_status = sch->line_status;
-                       }
-               }
-       } else if (strcmp(entry->name, FILENAME_KEEPALIVE) == 0) {
-               int keepa_new = -1;
-
-               if (strcmp(page, KEEPALIVE_OFF) == 0) {
-                       keepa_new = 0;
-               } else {
-                       keepa_new = simple_strtoul(page, NULL, 10);
-               }
-
-               if (keepa_new < 0 || keepa_new > 100) {
-                       printk(KERN_ERR "invalid keepalive\n");
-               } else {
-                       if (fr->keepa_freq && keepa_new != fr->keepa_freq) {
-                               fr_set_keepalive(dev, 0);
-                       }
-                       if (keepa_new) {
-                               fr_set_keepalive(dev, keepa_new);
-                       }
-               }
-       } else {
-               printk(KERN_ERR "comxfr_write_proc: internal error, filename %s\n", 
-                       entry->name);
-               count = -EBADF;
-       }
-
-       free_page((unsigned long)page);
-       return count;
-}
-
-static int fr_exit(struct net_device *dev) 
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-       struct net_device *sdev = dev;
-       struct comx_channel *sch;
-       struct fr_data *sfr;
-       struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-
-       /* Ha lezarunk egy master-t, le kell kattintani a slave-eket is */
-       if (fr->master && fr->master == dev) {
-               for (; dir ; dir = dir->next) {
-                       if(!S_ISDIR(dir->mode)) {
-                               continue;
-                       }
-                       if ((sdev = dir->data) && (sch = sdev->priv) && 
-                           (sdev->type == ARPHRD_DLCI) && 
-                           (sfr = sch->LINE_privdata) && (sfr->master == dev)) {
-                               dev_close(sdev);
-                               sfr->master = NULL;
-                       }
-               }
-       }
-       dev->flags              = 0;
-       dev->type               = 0;
-       dev->mtu                = 0;
-       dev->hard_header_len    = 0;
-
-       ch->LINE_rx     = NULL;
-       ch->LINE_tx     = NULL;
-       ch->LINE_status = NULL;
-       ch->LINE_open   = NULL;
-       ch->LINE_close  = NULL;
-       ch->LINE_xmit   = NULL;
-       ch->LINE_header = NULL;
-       ch->LINE_rebuild_header = NULL;
-       ch->LINE_statistics = NULL;
-
-       ch->LINE_status = 0;
-
-       if (fr->master != dev) { // if not master, remove dlci
-               if(fr->master)
-                       dev_put(fr->master);
-               remove_proc_entry(FILENAME_DLCI, ch->procdir);
-               remove_proc_entry(FILENAME_MASTER, ch->procdir);
-       } else {
-               if (fr->keepa_freq) {
-                       fr_set_keepalive(dev, 0);
-               }
-               remove_proc_entry(FILENAME_KEEPALIVE, ch->procdir);
-               remove_proc_entry(FILENAME_DLCI, ch->procdir);
-       }
-
-       kfree(fr);
-       ch->LINE_privdata = NULL;
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static int fr_master_init(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr;
-       struct proc_dir_entry *new_file;
-
-       if ((fr = ch->LINE_privdata = kmalloc(sizeof(struct fr_data), 
-           GFP_KERNEL)) == NULL) {
-               return -ENOMEM;
-       }
-       memset(fr, 0, sizeof(struct fr_data));
-       fr->master = dev;       // this means master
-       fr->dlci = 0;           // let's say default
-
-       dev->flags      = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
-       dev->type       = ARPHRD_FRAD;
-       dev->mtu        = 1500;
-       dev->hard_header_len    = 4;            
-       dev->addr_len   = 0;
-
-       ch->LINE_rx     = fr_rx;
-       ch->LINE_tx     = fr_tx;
-       ch->LINE_status = fr_status;
-       ch->LINE_open   = fr_open;
-       ch->LINE_close  = fr_close;
-       ch->LINE_xmit   = fr_xmit;
-       ch->LINE_header = fr_header;
-       ch->LINE_rebuild_header = NULL;
-       ch->LINE_statistics = fr_statistics;
-
-       if ((new_file = create_proc_entry(FILENAME_DLCI, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_LINE_privdata;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &fr_read_proc;
-       new_file->write_proc = &fr_write_proc;
-       new_file->size = 5;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_KEEPALIVE, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_filename_dlci;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &fr_read_proc;
-       new_file->write_proc = &fr_write_proc;
-       new_file->size = 4;
-       new_file->nlink = 1;
-
-       fr_set_keepalive(dev, 0);
-
-       MOD_INC_USE_COUNT;
-       return 0;
-cleanup_filename_dlci:
-        remove_proc_entry(FILENAME_DLCI, ch->procdir);
-cleanup_LINE_privdata:
-       kfree(fr);
-       return -EIO;
-}
-
-static int fr_slave_init(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr;
-       struct proc_dir_entry *new_file;
-
-       if ((fr = ch->LINE_privdata = kmalloc(sizeof(struct fr_data), 
-           GFP_KERNEL)) == NULL) {
-               return -ENOMEM;
-       }
-       memset(fr, 0, sizeof(struct fr_data));
-
-       dev->flags      = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
-       dev->type       = ARPHRD_DLCI;
-       dev->mtu        = 1500;
-       dev->hard_header_len    = 4;            
-       dev->addr_len   = 0;
-
-       ch->LINE_rx     = fr_rx;
-       ch->LINE_tx     = fr_tx;
-       ch->LINE_status = fr_status;
-       ch->LINE_open   = fr_open;
-       ch->LINE_close  = fr_close;
-       ch->LINE_xmit   = fr_xmit;
-       ch->LINE_header = fr_header;
-       ch->LINE_rebuild_header = NULL;
-       ch->LINE_statistics = fr_statistics;
-
-       if ((new_file = create_proc_entry(FILENAME_DLCI, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_LINE_privdata;
-       }
-       
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &fr_read_proc;
-       new_file->write_proc = &fr_write_proc;
-       new_file->size = 5;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_MASTER, S_IFREG | 0644, 
-           ch->procdir)) == NULL) {
-               goto cleanup_filename_dlci;
-       }
-       new_file->data = (void *)new_file;
-       new_file->read_proc = &fr_read_proc;
-       new_file->write_proc = &fr_write_proc;
-       new_file->size = 10;
-       new_file->nlink = 1;
-       MOD_INC_USE_COUNT;
-       return 0;
-cleanup_filename_dlci:
-         remove_proc_entry(FILENAME_DLCI, ch->procdir);
-cleanup_LINE_privdata:
-       kfree(fr);
-       return -EIO;
-}
-
-static int dlci_open(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       ch->init_status |= HW_OPEN;
-
-       MOD_INC_USE_COUNT;
-       return 0;
-}
-
-static int dlci_close(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       ch->init_status &= ~HW_OPEN;
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static int dlci_txe(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct fr_data *fr = ch->LINE_privdata;
-
-       if (!fr->master) {
-               return 0;
-       }
-
-       ch = fr->master->priv;
-       fr = ch->LINE_privdata;
-       return ch->HW_txe(fr->master);
-}
-
-static int dlci_statistics(struct net_device *dev, char *page) 
-{
-       return 0;
-}
-
-static int dlci_init(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       ch->HW_open = dlci_open;
-       ch->HW_close = dlci_close;
-       ch->HW_txe = dlci_txe;
-       ch->HW_statistics = dlci_statistics;
-
-       /* Nincs egyeb hw info, mert ugyis a fr->master-bol fog minden kiderulni */
-
-       MOD_INC_USE_COUNT;
-       return 0;
-}
-
-static int dlci_exit(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       ch->HW_open = NULL;
-       ch->HW_close = NULL;
-       ch->HW_txe = NULL;
-       ch->HW_statistics = NULL;
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static int dlci_dump(struct net_device *dev)
-{
-       printk(KERN_INFO "dlci_dump %s, HOGY MI ???\n", dev->name);
-       return -1;
-}
-
-static struct comx_protocol fr_master_protocol = {
-       .name           = "frad", 
-       .version        = VERSION,
-       .encap_type     = ARPHRD_FRAD, 
-       .line_init      = fr_master_init, 
-       .line_exit      = fr_exit, 
-};
-
-static struct comx_protocol fr_slave_protocol = {
-       .name           = "ietf-ip", 
-       .version        = VERSION,
-       .encap_type     = ARPHRD_DLCI, 
-       .line_init      = fr_slave_init, 
-       .line_exit      = fr_exit, 
-};
-
-static struct comx_hardware fr_dlci = { 
-       .name           = "dlci", 
-       .version        = VERSION,
-       .hw_init        = dlci_init, 
-       .hw_exit        = dlci_exit, 
-       .hw_dump        = dlci_dump, 
-};
-
-static int __init comx_proto_fr_init(void)
-{
-       int ret; 
-
-       if ((ret = comx_register_hardware(&fr_dlci))) {
-               return ret;
-       }
-       if ((ret = comx_register_protocol(&fr_master_protocol))) {
-               return ret;
-       }
-       return comx_register_protocol(&fr_slave_protocol);
-}
-
-static void __exit comx_proto_fr_exit(void)
-{
-       comx_unregister_hardware(fr_dlci.name);
-       comx_unregister_protocol(fr_master_protocol.name);
-       comx_unregister_protocol(fr_slave_protocol.name);
-}
-
-module_init(comx_proto_fr_init);
-module_exit(comx_proto_fr_exit);
diff --git a/drivers/net/wan/comx-proto-lapb.c b/drivers/net/wan/comx-proto-lapb.c
deleted file mode 100644 (file)
index b203ff6..0000000
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * LAPB protocol module for the COMX driver 
- * for Linux kernel 2.2.X
- *
- * Original author: Tivadar Szemethy <tiv@itc.hu>
- * Maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1997-1999 (C) ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.80 (99/06/14):
- *             - cleaned up the source code a bit
- *             - ported back to kernel, now works as non-module
- *
- * Changed      (00/10/29, Henner Eisen):
- *             - comx_rx() / comxlapb_data_indication() return status.
- * 
- */
-
-#define VERSION "0.80"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/if_arp.h>
-#include <linux/inetdevice.h>
-#include <asm/uaccess.h>
-#include <linux/lapb.h>
-#include <linux/init.h>
-
-#include       "comx.h"
-#include       "comxhw.h"
-
-static struct proc_dir_entry *create_comxlapb_proc_entry(char *name, int mode,
-       int size, struct proc_dir_entry *dir);
-
-static void comxlapb_rx(struct net_device *dev, struct sk_buff *skb) 
-{
-       if (!dev || !dev->priv) {
-               dev_kfree_skb(skb);
-       } else {
-               lapb_data_received(dev, skb);
-       }
-}
-
-static int comxlapb_tx(struct net_device *dev) 
-{
-       netif_wake_queue(dev);
-       return 0;
-}
-
-static int comxlapb_header(struct sk_buff *skb, struct net_device *dev, 
-       unsigned short type, void *daddr, void *saddr, unsigned len) 
-{
-       return dev->hard_header_len;  
-}
-
-static void comxlapb_status(struct net_device *dev, unsigned short status)
-{
-       struct comx_channel *ch;
-
-       if (!dev || !(ch = dev->priv)) {
-               return;
-       }
-       if (status & LINE_UP) {
-               netif_wake_queue(dev);
-       }
-       comx_status(dev, status);
-}
-
-static int comxlapb_open(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       int err = 0;
-
-       if (!(ch->init_status & HW_OPEN)) {
-               return -ENODEV;
-       }
-
-       err = lapb_connect_request(dev);
-
-       if (ch->debug_flags & DEBUG_COMX_LAPB) {
-               comx_debug(dev, "%s: lapb opened, error code: %d\n", 
-                       dev->name, err);
-       }
-
-       if (!err) {
-               ch->init_status |= LINE_OPEN;
-               MOD_INC_USE_COUNT;
-       }
-       return err;
-}
-
-static int comxlapb_close(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       if (!(ch->init_status & HW_OPEN)) {
-               return -ENODEV;
-       }
-
-       if (ch->debug_flags & DEBUG_COMX_LAPB) {
-               comx_debug(dev, "%s: lapb closed\n", dev->name);
-       }
-
-       lapb_disconnect_request(dev);
-
-       ch->init_status &= ~LINE_OPEN;
-       ch->line_status &= ~PROTO_UP;
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct sk_buff *skb2;
-
-       if (!dev || !(ch = dev->priv) || !(dev->flags & (IFF_UP | IFF_RUNNING))) {
-               return -ENODEV;
-       }
-
-       if (dev->type == ARPHRD_X25) { // first byte tells what to do 
-               switch(skb->data[0]) {
-                       case 0x00:      
-                               break;  // transmit
-                       case 0x01:      
-                               lapb_connect_request(dev);
-                               kfree_skb(skb);
-                               return 0;
-                       case 0x02:      
-                               lapb_disconnect_request(dev);
-                       default:
-                               kfree_skb(skb);
-                               return 0;
-               }
-               skb_pull(skb,1);
-       }
-
-       netif_stop_queue(dev);
-       
-       if ((skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
-               lapb_data_request(dev, skb2);
-       }
-
-       return FRAME_ACCEPTED;
-}
-
-static int comxlapb_statistics(struct net_device *dev, char *page) 
-{
-       struct lapb_parms_struct parms;
-       int len = 0;
-
-       len += sprintf(page + len, "Line status: ");
-       if (lapb_getparms(dev, &parms) != LAPB_OK) {
-               len += sprintf(page + len, "not initialized\n");
-               return len;
-       }
-       len += sprintf(page + len, "%s (%s), T1: %d/%d, T2: %d/%d, N2: %d/%d, "
-               "window: %d\n", parms.mode & LAPB_DCE ? "DCE" : "DTE", 
-               parms.mode & LAPB_EXTENDED ? "EXTENDED" : "STANDARD",
-               parms.t1timer, parms.t1, parms.t2timer, parms.t2, 
-               parms.n2count, parms.n2, parms.window);
-
-       return len;
-}
-
-static int comxlapb_read_proc(char *page, char **start, off_t off, int count,
-       int *eof, void *data)
-{
-       struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-       struct net_device *dev = file->parent->data;
-       struct lapb_parms_struct parms;
-       int len = 0;
-
-       if (lapb_getparms(dev, &parms)) {
-               return -ENODEV;
-       }
-
-       if (strcmp(file->name, FILENAME_T1) == 0) {
-               len += sprintf(page + len, "%02u / %02u\n", 
-                       parms.t1timer, parms.t1);
-       } else if (strcmp(file->name, FILENAME_T2) == 0) {
-               len += sprintf(page + len, "%02u / %02u\n", 
-                       parms.t2timer, parms.t2);
-       } else if (strcmp(file->name, FILENAME_N2) == 0) {
-               len += sprintf(page + len, "%02u / %02u\n", 
-                       parms.n2count, parms.n2);
-       } else if (strcmp(file->name, FILENAME_WINDOW) == 0) {
-               len += sprintf(page + len, "%u\n", parms.window);
-       } else if (strcmp(file->name, FILENAME_MODE) == 0) {
-               len += sprintf(page + len, "%s, %s\n", 
-                       parms.mode & LAPB_DCE ? "DCE" : "DTE",
-                       parms.mode & LAPB_EXTENDED ? "EXTENDED" : "STANDARD");
-       } else {
-               printk(KERN_ERR "comxlapb: internal error, filename %s\n", file->name);
-               return -EBADF;
-       }
-
-       if (off >= len) {
-               *eof = 1;
-               return 0;
-       }
-
-       *start = page + off;
-       if (count >= len - off) {
-               *eof = 1;
-       }
-       return min_t(int, count, len - off);
-}
-
-static int comxlapb_write_proc(struct file *file, const char *buffer, 
-       u_long count, void *data)
-{
-       struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
-       struct net_device *dev = entry->parent->data;
-       struct lapb_parms_struct parms;
-       unsigned long parm;
-       char *page;
-
-       if (lapb_getparms(dev, &parms)) {
-               return -ENODEV;
-       }
-
-       if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
-               return -ENOMEM;
-       }
-
-       if (copy_from_user(page, buffer, count)) {
-               free_page((unsigned long)page);
-               return -EFAULT;
-       }
-       if (*(page + count - 1) == '\n') {
-               *(page + count - 1) = 0;
-       }
-
-       if (strcmp(entry->name, FILENAME_T1) == 0) {
-               parm=simple_strtoul(page,NULL,10);
-               if (parm > 0 && parm < 100) {
-                       parms.t1=parm;
-                       lapb_setparms(dev, &parms);
-               }
-       } else if (strcmp(entry->name, FILENAME_T2) == 0) {
-               parm=simple_strtoul(page, NULL, 10);
-               if (parm > 0 && parm < 100) {
-                       parms.t2=parm;
-                       lapb_setparms(dev, &parms);
-               }
-       } else if (strcmp(entry->name, FILENAME_N2) == 0) {
-               parm=simple_strtoul(page, NULL, 10);
-               if (parm > 0 && parm < 100) {
-                       parms.n2=parm;
-                       lapb_setparms(dev, &parms);
-               }
-       } else if (strcmp(entry->name, FILENAME_WINDOW) == 0) {
-               parms.window = simple_strtoul(page, NULL, 10);
-               lapb_setparms(dev, &parms);
-       } else if (strcmp(entry->name, FILENAME_MODE) == 0) {
-               if (comx_strcasecmp(page, "dte") == 0) {
-                       parms.mode &= ~(LAPB_DCE | LAPB_DTE); 
-                       parms.mode |= LAPB_DTE;
-               } else if (comx_strcasecmp(page, "dce") == 0) {
-                       parms.mode &= ~(LAPB_DTE | LAPB_DCE); 
-                       parms.mode |= LAPB_DCE;
-               } else if (comx_strcasecmp(page, "std") == 0 || 
-                   comx_strcasecmp(page, "standard") == 0) {
-                       parms.mode &= ~LAPB_EXTENDED; 
-                       parms.mode |= LAPB_STANDARD;
-               } else if (comx_strcasecmp(page, "ext") == 0 || 
-                   comx_strcasecmp(page, "extended") == 0) {
-                       parms.mode &= ~LAPB_STANDARD; 
-                       parms.mode |= LAPB_EXTENDED;
-               }
-               lapb_setparms(dev, &parms);
-       } else {
-               printk(KERN_ERR "comxlapb_write_proc: internal error, filename %s\n", 
-                       entry->name);
-               return -EBADF;
-       }
-
-       free_page((unsigned long)page);
-       return count;
-}
-
-static void comxlapb_connected(struct net_device *dev, int reason)
-{
-       struct comx_channel *ch = dev->priv; 
-       struct proc_dir_entry *comxdir = ch->procdir->subdir;
-
-       if (ch->debug_flags & DEBUG_COMX_LAPB) {
-               comx_debug(ch->dev, "%s: lapb connected, reason: %d\n", 
-                       ch->dev->name, reason);
-       }
-
-       if (ch->dev->type == ARPHRD_X25) {
-               unsigned char *p;
-               struct sk_buff *skb;
-
-               if ((skb = dev_alloc_skb(1)) == NULL) {
-                       printk(KERN_ERR "comxlapb: out of memory!\n");
-                       return;
-               }
-               p = skb_put(skb,1);
-               *p = 0x01;              // link established
-               skb->dev = ch->dev;
-               skb->protocol = htons(ETH_P_X25);
-               skb->mac.raw = skb->data;
-               skb->pkt_type = PACKET_HOST;
-
-               netif_rx(skb);
-               ch->dev->last_rx = jiffies;
-       }
-
-       for (; comxdir; comxdir = comxdir->next) {
-               if (strcmp(comxdir->name, FILENAME_MODE) == 0) {
-                       comxdir->mode = S_IFREG | 0444;
-               }
-       }
-
-
-       ch->line_status |= PROTO_UP;
-       comx_status(ch->dev, ch->line_status);
-}
-
-static void comxlapb_disconnected(struct net_device *dev, int reason)
-{
-       struct comx_channel *ch = dev->priv; 
-       struct proc_dir_entry *comxdir = ch->procdir->subdir;
-
-       if (ch->debug_flags & DEBUG_COMX_LAPB) {
-               comx_debug(ch->dev, "%s: lapb disconnected, reason: %d\n", 
-                       ch->dev->name, reason);
-       }
-
-       if (ch->dev->type == ARPHRD_X25) {
-               unsigned char *p;
-               struct sk_buff *skb;
-
-               if ((skb = dev_alloc_skb(1)) == NULL) {
-                       printk(KERN_ERR "comxlapb: out of memory!\n");
-                       return;
-               }
-               p = skb_put(skb,1);
-               *p = 0x02;              // link disconnected
-               skb->dev = ch->dev;
-               skb->protocol = htons(ETH_P_X25);
-               skb->mac.raw = skb->data;
-               skb->pkt_type = PACKET_HOST;
-
-               netif_rx(skb);
-               ch->dev->last_rx = jiffies;
-       }
-
-       for (; comxdir; comxdir = comxdir->next) {
-               if (strcmp(comxdir->name, FILENAME_MODE) == 0) {
-                       comxdir->mode = S_IFREG | 0644;
-               }
-       }
-       
-       ch->line_status &= ~PROTO_UP;
-       comx_status(ch->dev, ch->line_status);
-}
-
-static int comxlapb_data_indication(struct net_device *dev, struct sk_buff *skb)
-{
-       struct comx_channel *ch = dev->priv; 
-
-       if (ch->dev->type == ARPHRD_X25) {
-               skb_push(skb, 1);
-
-               if (skb_cow(skb, 1))
-                       return NET_RX_DROP;
-
-               skb->data[0] = 0;       // indicate data for X25
-               skb->protocol = htons(ETH_P_X25);
-       } else {
-               skb->protocol = htons(ETH_P_IP);
-       }
-
-       skb->dev = ch->dev;
-       skb->mac.raw = skb->data;
-       return comx_rx(ch->dev, skb);
-}
-
-static void comxlapb_data_transmit(struct net_device *dev, struct sk_buff *skb)
-{
-       struct comx_channel *ch = dev->priv; 
-
-       if (ch->HW_send_packet) {
-               ch->HW_send_packet(ch->dev, skb);
-       }
-}
-
-static int comxlapb_exit(struct net_device *dev) 
-{
-       struct comx_channel *ch = dev->priv;
-
-       dev->flags              = 0;
-       dev->type               = 0;
-       dev->mtu                = 0;
-       dev->hard_header_len    = 0;
-
-       ch->LINE_rx     = NULL;
-       ch->LINE_tx     = NULL;
-       ch->LINE_status = NULL;
-       ch->LINE_open   = NULL;
-       ch->LINE_close  = NULL;
-       ch->LINE_xmit   = NULL;
-       ch->LINE_header = NULL;
-       ch->LINE_statistics = NULL;
-
-       if (ch->debug_flags & DEBUG_COMX_LAPB) {
-               comx_debug(dev, "%s: unregistering lapb\n", dev->name);
-       }
-       lapb_unregister(dev);
-
-       remove_proc_entry(FILENAME_T1, ch->procdir);
-       remove_proc_entry(FILENAME_T2, ch->procdir);
-       remove_proc_entry(FILENAME_N2, ch->procdir);
-       remove_proc_entry(FILENAME_MODE, ch->procdir);
-       remove_proc_entry(FILENAME_WINDOW, ch->procdir);
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static int comxlapb_init(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct lapb_register_struct lapbreg;
-
-       dev->mtu                = 1500;
-       dev->hard_header_len    = 4;
-       dev->addr_len           = 0;
-
-       ch->LINE_rx     = comxlapb_rx;
-       ch->LINE_tx     = comxlapb_tx;
-       ch->LINE_status = comxlapb_status;
-       ch->LINE_open   = comxlapb_open;
-       ch->LINE_close  = comxlapb_close;
-       ch->LINE_xmit   = comxlapb_xmit;
-       ch->LINE_header = comxlapb_header;
-       ch->LINE_statistics = comxlapb_statistics;
-
-       lapbreg.connect_confirmation = comxlapb_connected;
-       lapbreg.connect_indication = comxlapb_connected;
-       lapbreg.disconnect_confirmation = comxlapb_disconnected;
-       lapbreg.disconnect_indication = comxlapb_disconnected;
-       lapbreg.data_indication = comxlapb_data_indication;
-       lapbreg.data_transmit = comxlapb_data_transmit;
-       if (lapb_register(dev, &lapbreg)) {
-               return -ENOMEM;
-       }
-       if (ch->debug_flags & DEBUG_COMX_LAPB) {
-               comx_debug(dev, "%s: lapb registered\n", dev->name);
-       }
-
-       if (!create_comxlapb_proc_entry(FILENAME_T1, 0644, 8, ch->procdir)) {
-               return -ENOMEM;
-       }
-       if (!create_comxlapb_proc_entry(FILENAME_T2, 0644, 8, ch->procdir)) {
-               return -ENOMEM;
-       }
-       if (!create_comxlapb_proc_entry(FILENAME_N2, 0644, 8, ch->procdir)) {
-               return -ENOMEM;
-       }
-       if (!create_comxlapb_proc_entry(FILENAME_MODE, 0644, 14, ch->procdir)) {
-               return -ENOMEM;
-       }
-       if (!create_comxlapb_proc_entry(FILENAME_WINDOW, 0644, 0, ch->procdir)) {
-               return -ENOMEM;
-       }
-
-       MOD_INC_USE_COUNT;
-       return 0;
-}
-
-static int comxlapb_init_lapb(struct net_device *dev) 
-{
-       dev->flags      = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
-       dev->type       = ARPHRD_LAPB;
-
-       return(comxlapb_init(dev));
-}
-
-static int comxlapb_init_x25(struct net_device *dev)
-{
-       dev->flags              = IFF_NOARP;
-       dev->type               = ARPHRD_X25;
-
-       return(comxlapb_init(dev));
-}
-
-static struct proc_dir_entry *create_comxlapb_proc_entry(char *name, int mode,
-       int size, struct proc_dir_entry *dir)
-{
-       struct proc_dir_entry *new_file;
-
-       if ((new_file = create_proc_entry(name, S_IFREG | mode, dir)) != NULL) {
-               new_file->data = (void *)new_file;
-               new_file->read_proc = &comxlapb_read_proc;
-               new_file->write_proc = &comxlapb_write_proc;
-               new_file->size = size;
-               new_file->nlink = 1;
-       }
-       return(new_file);
-}
-
-static struct comx_protocol comxlapb_protocol = {
-       "lapb", 
-       VERSION,
-       ARPHRD_LAPB, 
-       comxlapb_init_lapb, 
-       comxlapb_exit, 
-       NULL 
-};
-
-static struct comx_protocol comx25_protocol = {
-       "x25", 
-       VERSION,
-       ARPHRD_X25, 
-       comxlapb_init_x25, 
-       comxlapb_exit, 
-       NULL 
-};
-
-static int __init comx_proto_lapb_init(void)
-{
-       int ret;
-
-       if ((ret = comx_register_protocol(&comxlapb_protocol)) != 0) {
-               return ret;
-       }
-       return comx_register_protocol(&comx25_protocol);
-}
-
-static void __exit comx_proto_lapb_exit(void)
-{
-       comx_unregister_protocol(comxlapb_protocol.name);
-       comx_unregister_protocol(comx25_protocol.name);
-}
-
-module_init(comx_proto_lapb_init);
-module_exit(comx_proto_lapb_exit);
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/net/wan/comx-proto-ppp.c b/drivers/net/wan/comx-proto-ppp.c
deleted file mode 100644 (file)
index 3f45010..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Synchronous PPP / Cisco-HDLC driver for the COMX boards
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * based on skeleton code by Tivadar Szemethy <tiv@itc.hu>
- *
- * Copyright (C) 1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- *
- * Version 0.10 (99/06/10):
- *             - written the first code :)
- *
- * Version 0.20 (99/06/16):
- *             - added hdlc protocol 
- *             - protocol up is IFF_RUNNING
- *
- * Version 0.21 (99/07/15):
- *             - some small fixes with the line status
- *
- * Version 0.22 (99/08/05):
- *             - don't test IFF_RUNNING but the pp_link_state of the sppp
- * 
- * Version 0.23 (99/12/02):
- *             - tbusy fixes
- *
- */
-
-#define VERSION "0.23"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/jiffies.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/if_arp.h>
-#include <linux/inetdevice.h>
-#include <asm/uaccess.h>
-#include <linux/init.h>
-
-#include <net/syncppp.h>
-#include       "comx.h"
-
-MODULE_AUTHOR("Author: Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Cisco-HDLC / Synchronous PPP driver for the COMX sync serial boards");
-MODULE_LICENSE("GPL");
-
-static struct comx_protocol syncppp_protocol;
-static struct comx_protocol hdlc_protocol;
-
-struct syncppp_data {
-       struct timer_list status_timer;
-};
-
-static void syncppp_status_timerfun(unsigned long d) {
-       struct net_device *dev=(struct net_device *)d;
-       struct comx_channel *ch=dev->priv;
-       struct syncppp_data *spch=ch->LINE_privdata;
-       struct sppp *sp = (struct sppp *)sppp_of(dev);
-        
-       if(!(ch->line_status & PROTO_UP) && 
-           (sp->pp_link_state==SPPP_LINK_UP)) {
-               comx_status(dev, ch->line_status | PROTO_UP);
-       }
-       if((ch->line_status & PROTO_UP) &&
-           (sp->pp_link_state==SPPP_LINK_DOWN)) {
-               comx_status(dev, ch->line_status & ~PROTO_UP);
-       }
-       mod_timer(&spch->status_timer,jiffies + HZ*3);
-}
-
-static int syncppp_tx(struct net_device *dev) 
-{
-       struct comx_channel *ch=dev->priv;
-       
-       if(ch->line_status & LINE_UP) {
-               netif_wake_queue(dev);
-       }
-       return 0;
-}
-
-static void syncppp_status(struct net_device *dev, unsigned short status)
-{
-       status &= ~(PROTO_UP | PROTO_LOOP);
-       if(status & LINE_UP) {
-               netif_wake_queue(dev);
-               sppp_open(dev);
-       } else  {
-               /* Line went down */
-               netif_stop_queue(dev);
-               sppp_close(dev);
-       }
-       comx_status(dev, status);
-}
-
-static int syncppp_open(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct syncppp_data *spch = ch->LINE_privdata;
-
-       if (!(ch->init_status & HW_OPEN)) return -ENODEV;
-
-       ch->init_status |= LINE_OPEN;
-       ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
-
-       if(ch->line_status & LINE_UP) {
-               sppp_open(dev);
-       }
-
-       init_timer(&spch->status_timer);
-       spch->status_timer.function=syncppp_status_timerfun;
-       spch->status_timer.data=(unsigned long)dev;
-       spch->status_timer.expires=jiffies + HZ*3;
-       add_timer(&spch->status_timer);
-       
-       return 0;
-}
-
-static int syncppp_close(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct syncppp_data *spch = ch->LINE_privdata;
-
-       if (!(ch->init_status & HW_OPEN)) return -ENODEV;
-       del_timer(&spch->status_timer);
-       
-       sppp_close(dev);
-
-       ch->init_status &= ~LINE_OPEN;
-       ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
-
-       return 0;
-}
-
-static int syncppp_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       netif_stop_queue(dev);
-       switch(ch->HW_send_packet(dev, skb)) {
-               case FRAME_QUEUED:
-                       netif_wake_queue(dev);
-                       break;
-               case FRAME_ACCEPTED:
-               case FRAME_DROPPED:
-                       break;
-               case FRAME_ERROR:
-                       printk(KERN_ERR "%s: Transmit frame error (len %d)\n", 
-                               dev->name, skb->len);
-               break;
-       }
-       return 0;
-}
-
-
-static int syncppp_statistics(struct net_device *dev, char *page) 
-{
-       int len = 0;
-
-       len += sprintf(page + len, " ");
-       return len;
-}
-
-
-static int syncppp_exit(struct net_device *dev) 
-{
-       struct comx_channel *ch = dev->priv;
-
-       sppp_detach(dev);
-
-       dev->flags = 0;
-       dev->type = 0;
-       dev->mtu = 0;
-
-       ch->LINE_rx = NULL;
-       ch->LINE_tx = NULL;
-       ch->LINE_status = NULL;
-       ch->LINE_open = NULL;
-       ch->LINE_close = NULL;
-       ch->LINE_xmit = NULL;
-       ch->LINE_header = NULL;
-       ch->LINE_rebuild_header = NULL;
-       ch->LINE_statistics = NULL;
-
-       kfree(ch->LINE_privdata);
-       ch->LINE_privdata = NULL;
-
-       MOD_DEC_USE_COUNT;
-       return 0;
-}
-
-static int syncppp_init(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct ppp_device *pppdev = (struct ppp_device *)ch->if_ptr;
-
-       ch->LINE_privdata = kmalloc(sizeof(struct syncppp_data), GFP_KERNEL);
-       if (!ch->LINE_privdata)
-               return -ENOMEM;
-
-       pppdev->dev = dev;
-       sppp_attach(pppdev);
-
-       if(ch->protocol == &hdlc_protocol) {
-               pppdev->sppp.pp_flags |= PP_CISCO;
-               dev->type = ARPHRD_HDLC;
-       } else {
-               pppdev->sppp.pp_flags &= ~PP_CISCO;
-               dev->type = ARPHRD_PPP;
-       }
-
-       ch->LINE_rx = sppp_input;
-       ch->LINE_tx = syncppp_tx;
-       ch->LINE_status = syncppp_status;
-       ch->LINE_open = syncppp_open;
-       ch->LINE_close = syncppp_close;
-       ch->LINE_xmit = syncppp_xmit;
-       ch->LINE_header = NULL;
-       ch->LINE_statistics = syncppp_statistics;
-
-
-       MOD_INC_USE_COUNT;
-       return 0;
-}
-
-static struct comx_protocol syncppp_protocol = {
-       "ppp", 
-       VERSION,
-       ARPHRD_PPP, 
-       syncppp_init, 
-       syncppp_exit, 
-       NULL 
-};
-
-static struct comx_protocol hdlc_protocol = {
-       "hdlc", 
-       VERSION,
-       ARPHRD_PPP, 
-       syncppp_init, 
-       syncppp_exit, 
-       NULL 
-};
-
-static int __init comx_proto_ppp_init(void)
-{
-       int ret;
-
-       ret = comx_register_protocol(&hdlc_protocol);
-       if (!ret) {
-               ret = comx_register_protocol(&syncppp_protocol);
-               if (ret)
-                       comx_unregister_protocol(hdlc_protocol.name);
-       }
-       return ret;
-}
-
-static void __exit comx_proto_ppp_exit(void)
-{
-       comx_unregister_protocol(syncppp_protocol.name);
-       comx_unregister_protocol(hdlc_protocol.name);
-}
-
-module_init(comx_proto_ppp_init);
-module_exit(comx_proto_ppp_exit);
diff --git a/drivers/net/wan/comx.c b/drivers/net/wan/comx.c
deleted file mode 100644 (file)
index 6c0e3fc..0000000
+++ /dev/null
@@ -1,1128 +0,0 @@
-/*
- * Device driver framework for the COMX line of synchronous serial boards
- * 
- * for Linux kernel 2.2.X / 2.4.X
- *
- * Original authors:  Arpad Bakay <bakay.arpad@synergon.hu>,
- *                    Peter Bajan <bajan.peter@synergon.hu>,
- * Previous maintainer: Tivadar Szemethy <tiv@itc.hu>
- * Current maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-1999 ITConsult-Pro Co.
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.85)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.80 (99/06/11):
- *             - clean up source code (playing a bit of indent)
- *             - port back to kernel, add support for non-module versions
- *             - add support for board resets when channel protocol is down
- *             - reset the device structure after protocol exit
- *               the syncppp driver needs it
- *             - add support for /proc/comx/protocols and 
- *               /proc/comx/boardtypes
- *
- * Version 0.81 (99/06/21):
- *             - comment out the board reset support code, the locomx
- *               driver seems not buggy now
- *             - printk() levels fixed
- *
- * Version 0.82 (99/07/08):
- *             - Handle stats correctly if the lowlevel driver is
- *               is not a comx one (locomx - z85230)
- *
- * Version 0.83 (99/07/15):
- *             - reset line_status when interface is down
- *
- * Version 0.84 (99/12/01):
- *             - comx_status should not check for IFF_UP (to report
- *               line status from dev->open())
- *
- * Version 0.85 (00/08/15):
- *             - resource release on failure in comx_mkdir
- *             - fix return value on failure at comx_write_proc
- *
- * Changed      (00/10/29, Henner Eisen):
- *             - comx_rx() / comxlapb_data_indication() return status.
- */
-
-#define VERSION "0.85"
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/jiffies.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <asm/uaccess.h>
-#include <linux/ctype.h>
-#include <linux/init.h>
-#include <linux/smp_lock.h>
-
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif
-
-#ifndef CONFIG_PROC_FS
-#error For now, COMX really needs the /proc filesystem
-#endif
-
-#include <net/syncppp.h>
-#include "comx.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Common code for the COMX synchronous serial adapters");
-MODULE_LICENSE("GPL");
-
-static struct comx_hardware *comx_channels = NULL;
-static struct comx_protocol *comx_lines = NULL;
-
-static int comx_mkdir(struct inode *, struct dentry *, int);
-static int comx_rmdir(struct inode *, struct dentry *);
-static struct dentry *comx_lookup(struct inode *, struct dentry *, struct nameidata *);
-
-static struct inode_operations comx_root_inode_ops = {
-       .lookup = comx_lookup,
-       .mkdir = comx_mkdir,
-       .rmdir = comx_rmdir,
-};
-
-static int comx_delete_dentry(struct dentry *dentry);
-static struct proc_dir_entry *create_comx_proc_entry(char *name, int mode,
-       int size, struct proc_dir_entry *dir);
-
-static struct dentry_operations comx_dentry_operations = {
-       .d_delete       = comx_delete_dentry,
-};
-
-
-static struct proc_dir_entry * comx_root_dir;
-
-struct comx_debugflags_struct  comx_debugflags[] = {
-       { "comx_rx",            DEBUG_COMX_RX           },
-       { "comx_tx",            DEBUG_COMX_TX           },
-       { "hw_tx",              DEBUG_HW_TX             },
-       { "hw_rx",              DEBUG_HW_RX             },
-       { "hdlc_keepalive",     DEBUG_HDLC_KEEPALIVE    },
-       { "comxppp",            DEBUG_COMX_PPP          },
-       { "comxlapb",           DEBUG_COMX_LAPB         },
-       { "dlci",               DEBUG_COMX_DLCI         },
-       { NULL,                 0                       } 
-};
-
-
-int comx_debug(struct net_device *dev, char *fmt, ...)
-{
-       struct comx_channel *ch = dev->priv;
-       char *page,*str;
-       va_list args;
-       int len;
-
-       if (!ch->debug_area) return 0;
-
-       if (!(page = (char *)__get_free_page(GFP_ATOMIC))) return -ENOMEM;
-
-       va_start(args, fmt);
-       len = vsprintf(str = page, fmt, args);
-       va_end(args);
-
-       if (len >= PAGE_SIZE) {
-               printk(KERN_ERR "comx_debug: PANIC! len = %d !!!\n", len);
-               free_page((unsigned long)page);
-               return -EINVAL;
-       }
-
-       while (len) {
-               int to_copy;
-               int free = (ch->debug_start - ch->debug_end + ch->debug_size) 
-                       % ch->debug_size;
-
-               to_copy = min_t(int, free ? free : ch->debug_size, 
-                             min_t(int, ch->debug_size - ch->debug_end, len));
-               memcpy(ch->debug_area + ch->debug_end, str, to_copy);
-               str += to_copy;
-               len -= to_copy;
-               ch->debug_end = (ch->debug_end + to_copy) % ch->debug_size;
-               if (ch->debug_start == ch->debug_end) // Full ? push start away
-                       ch->debug_start = (ch->debug_start + len + 1) % 
-                                       ch->debug_size;
-               ch->debug_file->size = (ch->debug_end - ch->debug_start +
-                                       ch->debug_size) % ch->debug_size;
-       } 
-
-       free_page((unsigned long)page);
-       return 0;
-}
-
-int comx_debug_skb(struct net_device *dev, struct sk_buff *skb, char *msg)
-{
-       struct comx_channel *ch = dev->priv;
-
-       if (!ch->debug_area) return 0;
-       if (!skb) comx_debug(dev, "%s: %s NULL skb\n\n", dev->name, msg);
-       if (!skb->len) comx_debug(dev, "%s: %s empty skb\n\n", dev->name, msg);
-
-       return comx_debug_bytes(dev, skb->data, skb->len, msg);
-}
-
-int comx_debug_bytes(struct net_device *dev, unsigned char *bytes, int len, 
-               char *msg)
-{
-       int pos = 0;
-       struct comx_channel *ch = dev->priv;
-
-       if (!ch->debug_area) return 0;
-
-       comx_debug(dev, "%s: %s len %d\n", dev->name, msg, len);
-
-       while (pos != len) {
-               char line[80];
-               int i = 0;
-
-               memset(line, 0, 80);
-               sprintf(line,"%04d ", pos);
-               do {
-                       sprintf(line + 5 + (pos % 16) * 3, "%02x", bytes[pos]);
-                       sprintf(line + 60 + (pos % 16), "%c", 
-                               isprint(bytes[pos]) ? bytes[pos] : '.');
-                       pos++;
-               } while (pos != len && pos % 16);
-
-               while ( i++ != 78 ) if (line[i] == 0) line[i] = ' ';
-               line[77] = '\n';
-               line[78] = 0;
-       
-               comx_debug(dev, "%s", line);
-       }
-       comx_debug(dev, "\n");
-       return 0;
-}
-
-static void comx_loadavg_timerfun(unsigned long d)
-{
-       struct net_device *dev = (struct net_device *)d;
-       struct comx_channel *ch = dev->priv;
-
-       ch->avg_bytes[ch->loadavg_counter] = ch->current_stats->rx_bytes;
-       ch->avg_bytes[ch->loadavg_counter + ch->loadavg_size] = 
-               ch->current_stats->tx_bytes;
-
-       ch->loadavg_counter = (ch->loadavg_counter + 1) % ch->loadavg_size;
-
-       mod_timer(&ch->loadavg_timer,jiffies + HZ * ch->loadavg[0]);
-}
-
-#if 0
-static void comx_reset_timerfun(unsigned long d)
-{ 
-       struct net_device *dev = (struct net_device *)d;
-       struct comx_channel *ch = dev->priv;
-
-       if(!(ch->line_status & (PROTO_LOOP | PROTO_UP))) {
-               if(test_and_set_bit(0,&ch->reset_pending) && ch->HW_reset) {
-                       ch->HW_reset(dev);
-               }
-       }
-
-       mod_timer(&ch->reset_timer, jiffies + HZ * ch->reset_timeout);
-}
-#endif                                            
-
-static int comx_open(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct proc_dir_entry *comxdir = ch->procdir->subdir;
-       int ret=0;
-
-       if (!ch->protocol || !ch->hardware) return -ENODEV;
-
-       if ((ret = ch->HW_open(dev))) return ret;
-       if ((ret = ch->LINE_open(dev))) { 
-               ch->HW_close(dev); 
-               return ret; 
-       };
-
-       for (; comxdir ; comxdir = comxdir->next) {
-               if (strcmp(comxdir->name, FILENAME_HARDWARE) == 0 ||
-                  strcmp(comxdir->name, FILENAME_PROTOCOL) == 0)
-                       comxdir->mode = S_IFREG | 0444;
-       }
-
-#if 0
-       ch->reset_pending = 1;
-       ch->reset_timeout = 30;
-       ch->reset_timer.function = comx_reset_timerfun;
-       ch->reset_timer.data = (unsigned long)dev;
-       ch->reset_timer.expires = jiffies + HZ * ch->reset_timeout;
-       add_timer(&ch->reset_timer);
-#endif
-
-       return 0;
-}
-
-static int comx_close(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       struct proc_dir_entry *comxdir = ch->procdir->subdir;
-       int ret = -ENODEV;
-
-       if (test_and_clear_bit(0, &ch->lineup_pending)) {
-               del_timer(&ch->lineup_timer);
-       }
-
-#if 0  
-       del_timer(&ch->reset_timer);
-#endif
-
-       if (ch->init_status & LINE_OPEN && ch->protocol && ch->LINE_close) {
-               ret = ch->LINE_close(dev);
-       }
-
-       if (ret) return ret;
-
-       if (ch->init_status & HW_OPEN && ch->hardware && ch->HW_close) {
-               ret = ch->HW_close(dev);
-       }
-       
-       ch->line_status=0;
-
-       for (; comxdir ; comxdir = comxdir->next) {
-               if (strcmp(comxdir->name, FILENAME_HARDWARE) == 0 ||
-                   strcmp(comxdir->name, FILENAME_PROTOCOL) == 0)
-                       comxdir->mode = S_IFREG | 0644;
-       }
-
-       return ret;
-}
-
-void comx_status(struct net_device *dev, int status)
-{
-       struct comx_channel *ch = dev->priv;
-
-#if 0
-       if(status & (PROTO_UP | PROTO_LOOP)) {
-               clear_bit(0,&ch->reset_pending);
-       }
-#endif
-
-       printk(KERN_NOTICE "Interface %s: modem status %s, line protocol %s\n",
-                   dev->name, status & LINE_UP ? "UP" : "DOWN", 
-                   status & PROTO_LOOP ? "LOOP" : status & PROTO_UP ? 
-                   "UP" : "DOWN");
-       
-       ch->line_status = status;
-}
-
-static int comx_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-       int rc;
-
-       if (skb->len > dev->mtu + dev->hard_header_len) {
-               printk(KERN_ERR "comx_xmit: %s: skb->len %d > dev->mtu %d\n", dev->name,
-               (int)skb->len, dev->mtu);
-       }
-       
-       if (ch->debug_flags & DEBUG_COMX_TX) {
-               comx_debug_skb(dev, skb, "comx_xmit skb");
-       }
-       
-       rc=ch->LINE_xmit(skb, dev);
-//     if (!rc) dev_kfree_skb(skb);
-
-       return rc;
-}
-
-static int comx_header(struct sk_buff *skb, struct net_device *dev, 
-       unsigned short type, void *daddr, void *saddr, unsigned len) 
-{
-       struct comx_channel *ch = dev->priv;
-
-       if (ch->LINE_header) {
-               return (ch->LINE_header(skb, dev, type, daddr, saddr, len));
-       } else {
-               return 0;
-       }
-}
-
-static int comx_rebuild_header(struct sk_buff *skb) 
-{
-       struct net_device *dev = skb->dev;
-       struct comx_channel *ch = dev->priv;
-
-       if (ch->LINE_rebuild_header) {
-               return(ch->LINE_rebuild_header(skb));
-       } else {
-               return 0;
-       }
-}
-
-int comx_rx(struct net_device *dev, struct sk_buff *skb)
-{
-       struct comx_channel *ch = dev->priv;
-
-       if (ch->debug_flags & DEBUG_COMX_RX) {
-               comx_debug_skb(dev, skb, "comx_rx skb");
-       }
-       if (skb) {
-               netif_rx(skb);
-               dev->last_rx = jiffies;
-       }
-       return 0;
-}
-
-static struct net_device_stats *comx_stats(struct net_device *dev)
-{
-       struct comx_channel *ch = dev->priv;
-
-       return ch->current_stats;
-}
-
-void comx_lineup_func(unsigned long d)
-{
-       struct net_device *dev = (struct net_device *)d;
-       struct comx_channel *ch = dev->priv;
-
-       del_timer(&ch->lineup_timer);
-       clear_bit(0, &ch->lineup_pending);
-
-       if (ch->LINE_status) {
-               ch->LINE_status(dev, ch->line_status |= LINE_UP);
-       }
-}
-
-#define LOADAVG(avg, off) (int) \
-       ((ch->avg_bytes[(ch->loadavg_counter - 1 + ch->loadavg_size * 2) \
-       % ch->loadavg_size + off] -  ch->avg_bytes[(ch->loadavg_counter - 1 \
-               - ch->loadavg[avg] / ch->loadavg[0] + ch->loadavg_size * 2) \
-               % ch->loadavg_size + off]) / ch->loadavg[avg] * 8)
-
-static int comx_statistics(struct net_device *dev, char *page)
-{
-       struct comx_channel *ch = dev->priv;
-       int len = 0;
-       int tmp;
-       int i = 0;
-       char tmpstr[20];
-       int tmpstrlen = 0;
-
-       len += sprintf(page + len, "Interface administrative status is %s, "
-               "modem status is %s, protocol is %s\n", 
-               dev->flags & IFF_UP ? "UP" : "DOWN",
-               ch->line_status & LINE_UP ? "UP" : "DOWN",
-               ch->line_status & PROTO_LOOP ? "LOOP" : 
-               ch->line_status & PROTO_UP ? "UP" : "DOWN");
-       len += sprintf(page + len, "Modem status changes: %lu, Transmitter status "
-               "is %s, tbusy: %d\n", ch->current_stats->tx_carrier_errors, ch->HW_txe ? 
-               ch->HW_txe(dev) ? "IDLE" : "BUSY" : "NOT READY", netif_running(dev));
-       len += sprintf(page + len, "Interface load (input): %d / %d / %d bits/s (",
-               LOADAVG(0,0), LOADAVG(1, 0), LOADAVG(2, 0));
-       tmpstr[0] = 0;
-       for (i=0; i != 3; i++) {
-               char tf;
-
-               tf = ch->loadavg[i] % 60 == 0 && 
-                       ch->loadavg[i] / 60 > 0 ? 'm' : 's';
-               tmpstrlen += sprintf(tmpstr + tmpstrlen, "%d%c%s", 
-                       ch->loadavg[i] / (tf == 'm' ? 60 : 1), tf, 
-                       i == 2 ? ")\n" : "/");
-       }
-       len += sprintf(page + len, 
-               "%s              (output): %d / %d / %d bits/s (%s", tmpstr, 
-               LOADAVG(0,ch->loadavg_size), LOADAVG(1, ch->loadavg_size), 
-               LOADAVG(2, ch->loadavg_size), tmpstr);
-
-       len += sprintf(page + len, "Debug flags: ");
-       tmp = len; i = 0;
-       while (comx_debugflags[i].name) {
-               if (ch->debug_flags & comx_debugflags[i].value) 
-                       len += sprintf(page + len, "%s ", 
-                               comx_debugflags[i].name);
-               i++;
-       }
-       len += sprintf(page + len, "%s\n", tmp == len ? "none" : "");
-
-       len += sprintf(page + len, "RX errors: len: %lu, overrun: %lu, crc: %lu, "
-               "aborts: %lu\n           buffer overrun: %lu, pbuffer overrun: %lu\n"
-               "TX errors: underrun: %lu\n",
-               ch->current_stats->rx_length_errors, ch->current_stats->rx_over_errors, 
-               ch->current_stats->rx_crc_errors, ch->current_stats->rx_frame_errors, 
-               ch->current_stats->rx_missed_errors, ch->current_stats->rx_fifo_errors,
-               ch->current_stats->tx_fifo_errors);
-
-       if (ch->LINE_statistics && (ch->init_status & LINE_OPEN)) {
-               len += ch->LINE_statistics(dev, page + len);
-       } else {
-               len += sprintf(page+len, "Line status: driver not initialized\n");
-       }
-       if (ch->HW_statistics && (ch->init_status & HW_OPEN)) {
-               len += ch->HW_statistics(dev, page + len);
-       } else {
-               len += sprintf(page+len, "Board status: driver not initialized\n");
-       }
-
-       return len;
-}
-
-static int comx_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
-       struct comx_channel *ch = dev->priv;
-
-       if (ch->LINE_ioctl) {
-               return(ch->LINE_ioctl(dev, ifr, cmd));
-       }
-       return -EINVAL;
-}
-
-static void comx_reset_dev(struct net_device *dev)
-{
-       dev->open = comx_open;
-       dev->stop = comx_close;
-       dev->hard_start_xmit = comx_xmit;
-       dev->hard_header = comx_header;
-       dev->rebuild_header = comx_rebuild_header;
-       dev->get_stats = comx_stats;
-       dev->do_ioctl = comx_ioctl;
-       dev->change_mtu = NULL;
-       dev->tx_queue_len = 20;
-       dev->flags = IFF_NOARP;
-}
-
-static int comx_init_dev(struct net_device *dev)
-{
-       struct comx_channel *ch;
-
-       if ((ch = kmalloc(sizeof(struct comx_channel), GFP_KERNEL)) == NULL) {
-               return -ENOMEM;
-       }
-       memset(ch, 0, sizeof(struct comx_channel));
-
-       ch->loadavg[0] = 5;
-       ch->loadavg[1] = 300;
-       ch->loadavg[2] = 900;
-       ch->loadavg_size = ch->loadavg[2] / ch->loadavg[0] + 1; 
-       if ((ch->avg_bytes = kmalloc(ch->loadavg_size * 
-               sizeof(unsigned long) * 2, GFP_KERNEL)) == NULL) {
-               kfree(ch);
-               return -ENOMEM;
-       }
-
-       memset(ch->avg_bytes, 0, ch->loadavg_size * sizeof(unsigned long) * 2);
-       ch->loadavg_counter = 0;
-       ch->loadavg_timer.function = comx_loadavg_timerfun;
-       ch->loadavg_timer.data = (unsigned long)dev;
-       ch->loadavg_timer.expires = jiffies + HZ * ch->loadavg[0];
-       add_timer(&ch->loadavg_timer);
-
-       dev->priv = (void *)ch;
-       ch->dev = dev;
-       ch->line_status &= ~LINE_UP;
-
-       ch->current_stats = &ch->stats;
-
-       comx_reset_dev(dev);
-       return 0;
-}
-
-static int comx_read_proc(char *page, char **start, off_t off, int count, 
-       int *eof, void *data)
-{
-       struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-       struct net_device *dev = file->parent->data;
-       struct comx_channel *ch = dev->priv;
-       int len = 0;
-
-       if (strcmp(file->name, FILENAME_STATUS) == 0) {
-               len = comx_statistics(dev, page);
-       } else if (strcmp(file->name, FILENAME_HARDWARE) == 0) {
-               len = sprintf(page, "%s\n", ch->hardware ? 
-                       ch->hardware->name : HWNAME_NONE);
-       } else if (strcmp(file->name, FILENAME_PROTOCOL) == 0) {
-               len = sprintf(page, "%s\n", ch->protocol ? 
-                       ch->protocol->name : PROTONAME_NONE);
-       } else if (strcmp(file->name, FILENAME_LINEUPDELAY) == 0) {
-               len = sprintf(page, "%01d\n", ch->lineup_delay);
-       }
-
-       if (off >= len) {
-               *eof = 1;
-               return 0;
-       }
-
-       *start = page + off;
-       if (count >= len - off) {
-               *eof = 1;
-       }
-       return min_t(int, count, len - off);
-}
-
-
-static int comx_root_read_proc(char *page, char **start, off_t off, int count, 
-       int *eof, void *data)
-{
-       struct proc_dir_entry *file = (struct proc_dir_entry *)data;
-       struct comx_hardware *hw;
-       struct comx_protocol *line;
-
-       int len = 0;
-
-       if (strcmp(file->name, FILENAME_HARDWARELIST) == 0) {
-               for(hw=comx_channels;hw;hw=hw->next) 
-                       len+=sprintf(page+len, "%s\n", hw->name);
-       } else if (strcmp(file->name, FILENAME_PROTOCOLLIST) == 0) {
-               for(line=comx_lines;line;line=line->next)
-                       len+=sprintf(page+len, "%s\n", line->name);
-       }
-
-       if (off >= len) {
-               *eof = 1;
-               return 0;
-       }
-
-       *start = page + off;
-       if (count >= len - off) {
-               *eof = 1;
-       }
-       return min_t(int, count, len - off);
-}
-
-
-
-static int comx_write_proc(struct file *file, const char *buffer, u_long count,
-       void *data)
-{
-       struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
-       struct net_device *dev = (struct net_device *)entry->parent->data;
-       struct comx_channel *ch = dev->priv;
-       char *page;
-       struct comx_hardware *hw = comx_channels;
-       struct comx_protocol *line = comx_lines;
-       int ret=0;
-
-       if (count > PAGE_SIZE) {
-               printk(KERN_ERR "count is %lu > %d!!!\n", count, (int)PAGE_SIZE);
-               return -ENOSPC;
-       }
-
-       if (!(page = (char *)__get_free_page(GFP_KERNEL))) return -ENOMEM;
-
-       if(copy_from_user(page, buffer, count))
-       {
-               count = -EFAULT;
-               goto out;
-       }
-
-       if (page[count-1] == '\n')
-               page[count-1] = '\0';
-       else if (count < PAGE_SIZE)
-               page[count] = '\0';
-       else if (page[count]) {
-               count = -EINVAL;
-               goto out;
-       }
-
-       if (strcmp(entry->name, FILENAME_DEBUG) == 0) {
-               int i;
-               int ret = 0;
-
-               if ((i = simple_strtoul(page, NULL, 10)) != 0) {
-                       unsigned long flags;
-
-                       save_flags(flags); cli();
-                       if (ch->debug_area) kfree(ch->debug_area);
-                       if ((ch->debug_area = kmalloc(ch->debug_size = i, 
-                               GFP_KERNEL)) == NULL) {
-                               ret = -ENOMEM;
-                       }
-                       ch->debug_start = ch->debug_end = 0;
-                       restore_flags(flags);
-                       free_page((unsigned long)page);
-                       return ret ? ret : count;
-               }
-               
-               if (*page != '+' && *page != '-') {
-                       free_page((unsigned long)page);
-                       return -EINVAL;
-               }
-               while (comx_debugflags[i].value && 
-                       strncmp(comx_debugflags[i].name, page + 1, 
-                       strlen(comx_debugflags[i].name))) {
-                       i++;
-               }
-       
-               if (comx_debugflags[i].value == 0) {
-                       printk(KERN_ERR "Invalid debug option\n");
-                       free_page((unsigned long)page);
-                       return -EINVAL;
-               }
-               if (*page == '+') {
-                       ch->debug_flags |= comx_debugflags[i].value;
-               } else {
-                       ch->debug_flags &= ~comx_debugflags[i].value;
-               }
-       } else if (strcmp(entry->name, FILENAME_HARDWARE) == 0) {
-               if(strlen(page)>10) {
-                       free_page((unsigned long)page);
-                       return -EINVAL;
-               }
-               while (hw) { 
-                       if (strcmp(hw->name, page) == 0) {
-                               break;
-                       } else {
-                               hw = hw->next;
-                       }
-               }
-#ifdef CONFIG_KMOD
-               if(!hw && comx_strcasecmp(HWNAME_NONE,page) != 0){
-                       request_module("comx-hw-%s",page);
-               }               
-               hw=comx_channels;
-               while (hw) {
-                       if (comx_strcasecmp(hw->name, page) == 0) {
-                               break;
-                       } else {
-                               hw = hw->next;
-                       }
-               }
-#endif
-
-               if (comx_strcasecmp(HWNAME_NONE, page) != 0 && !hw)  {
-                       free_page((unsigned long)page);
-                       return -ENODEV;
-               }
-               if (ch->init_status & HW_OPEN) {
-                       free_page((unsigned long)page);
-                       return -EBUSY;
-               }
-               if (ch->hardware && ch->hardware->hw_exit && 
-                  (ret=ch->hardware->hw_exit(dev))) {
-                       free_page((unsigned long)page);
-                       return ret;
-               }
-               ch->hardware = hw;
-               entry->size = strlen(page) + 1;
-               if (hw && hw->hw_init) hw->hw_init(dev);
-       } else if (strcmp(entry->name, FILENAME_PROTOCOL) == 0) {
-               if(strlen(page)>10) {
-                       free_page((unsigned long)page);
-                       return -EINVAL;
-               }
-               while (line) {
-                       if (comx_strcasecmp(line->name, page) == 0) {
-                               break;
-                       } else {
-                               line = line->next;
-                       }
-               }
-#ifdef CONFIG_KMOD
-               if(!line && comx_strcasecmp(PROTONAME_NONE, page) != 0) {
-                       request_module("comx-proto-%s",page);
-               }               
-               line=comx_lines;
-               while (line) {
-                       if (comx_strcasecmp(line->name, page) == 0) {
-                               break;
-                       } else {
-                               line = line->next;
-                       }
-               }
-#endif
-               
-               if (comx_strcasecmp(PROTONAME_NONE, page) != 0 && !line) {
-                       free_page((unsigned long)page);
-                       return -ENODEV;
-               }
-               
-               if (ch->init_status & LINE_OPEN) {
-                       free_page((unsigned long)page);
-                       return -EBUSY;
-               }
-               
-               if (ch->protocol && ch->protocol->line_exit && 
-                   (ret=ch->protocol->line_exit(dev))) {
-                       free_page((unsigned long)page);
-                       return ret;
-               }
-               ch->protocol = line;
-               entry->size = strlen(page) + 1;
-               comx_reset_dev(dev);
-               if (line && line->line_init) line->line_init(dev);
-       } else if (strcmp(entry->name, FILENAME_LINEUPDELAY) == 0) {
-               int i;
-
-               if ((i = simple_strtoul(page, NULL, 10)) != 0) {
-                       if (i >=0 && i < 10) { 
-                               ch->lineup_delay = i; 
-                       } else {
-                               printk(KERN_ERR "comx: invalid lineup_delay value\n");
-                       }
-               }
-       }
-out:
-       free_page((unsigned long)page);
-       return count;
-}
-
-static int comx_mkdir(struct inode *dir, struct dentry *dentry, int mode)
-{
-       struct proc_dir_entry *new_dir, *debug_file;
-       struct net_device *dev;
-       struct comx_channel *ch;
-       int ret = -EIO;
-
-       if ((dev = kmalloc(sizeof(struct net_device), GFP_KERNEL)) == NULL) {
-               return -ENOMEM;
-       }
-       memset(dev, 0, sizeof(struct net_device));
-
-       lock_kernel();
-       if ((new_dir = create_proc_entry(dentry->d_name.name, mode | S_IFDIR, 
-               comx_root_dir)) == NULL) {
-               goto cleanup_dev;
-       }
-
-       new_dir->nlink = 2;
-       new_dir->data = NULL; // ide jon majd a struct dev
-
-       /* Ezek kellenek */
-       if (!create_comx_proc_entry(FILENAME_HARDWARE, 0644, 
-           strlen(HWNAME_NONE) + 1, new_dir)) {
-               goto cleanup_new_dir;
-       }
-       if (!create_comx_proc_entry(FILENAME_PROTOCOL, 0644, 
-           strlen(PROTONAME_NONE) + 1, new_dir)) {
-               goto cleanup_filename_hardware;
-       }
-       if (!create_comx_proc_entry(FILENAME_STATUS, 0444, 0, new_dir)) {
-               goto cleanup_filename_protocol;
-       }
-       if (!create_comx_proc_entry(FILENAME_LINEUPDELAY, 0644, 2, new_dir)) {
-               goto cleanup_filename_status;
-       }
-
-       if ((debug_file = create_proc_entry(FILENAME_DEBUG, 
-           S_IFREG | 0644, new_dir)) == NULL) {
-               goto cleanup_filename_lineupdelay;
-       }
-       debug_file->data = (void *)debug_file; 
-       debug_file->read_proc = NULL; // see below
-       debug_file->write_proc = &comx_write_proc;
-       debug_file->nlink = 1;
-
-       strcpy(dev->name, (char *)new_dir->name);
-       dev->init = comx_init_dev;
-
-       if (register_netdevice(dev)) {
-               goto cleanup_filename_debug;
-       }
-       ch = dev->priv;
-       if((ch->if_ptr = (void *)kmalloc(sizeof(struct ppp_device), 
-                                GFP_KERNEL)) == NULL) {
-               goto cleanup_register;
-       }
-       memset(ch->if_ptr, 0, sizeof(struct ppp_device));
-       ch->debug_file = debug_file; 
-       ch->procdir = new_dir;
-       new_dir->data = dev;
-
-       ch->debug_start = ch->debug_end = 0;
-       if ((ch->debug_area = kmalloc(ch->debug_size = DEFAULT_DEBUG_SIZE, 
-           GFP_KERNEL)) == NULL) {
-               ret = -ENOMEM;
-               goto cleanup_if_ptr;
-       }
-
-       ch->lineup_delay = DEFAULT_LINEUP_DELAY;
-
-       MOD_INC_USE_COUNT;
-       unlock_kernel();
-       return 0;
-cleanup_if_ptr:
-       kfree(ch->if_ptr);
-cleanup_register:
-       unregister_netdevice(dev);
-cleanup_filename_debug:
-       remove_proc_entry(FILENAME_DEBUG, new_dir);
-cleanup_filename_lineupdelay:
-       remove_proc_entry(FILENAME_LINEUPDELAY, new_dir);
-cleanup_filename_status:
-       remove_proc_entry(FILENAME_STATUS, new_dir);
-cleanup_filename_protocol:
-       remove_proc_entry(FILENAME_PROTOCOL, new_dir);
-cleanup_filename_hardware:
-       remove_proc_entry(FILENAME_HARDWARE, new_dir);
-cleanup_new_dir:
-       remove_proc_entry(dentry->d_name.name, comx_root_dir);
-cleanup_dev:
-       kfree(dev);
-       unlock_kernel();
-       return ret;
-}
-
-static int comx_rmdir(struct inode *dir, struct dentry *dentry)
-{
-       struct proc_dir_entry *entry = PDE(dentry->d_inode);
-       struct net_device *dev;
-       struct comx_channel *ch;
-       int ret;
-
-       lock_kernel();
-       dev = entry->data;
-       ch = dev->priv;
-       if (dev->flags & IFF_UP) {
-               printk(KERN_ERR "%s: down interface before removing it\n", dev->name);
-               unlock_kernel();
-               return -EBUSY;
-       }
-
-       if (ch->protocol && ch->protocol->line_exit && 
-           (ret=ch->protocol->line_exit(dev))) {
-               unlock_kernel();
-               return ret;
-       }
-       if (ch->hardware && ch->hardware->hw_exit && 
-          (ret=ch->hardware->hw_exit(dev))) { 
-               if(ch->protocol && ch->protocol->line_init) {
-                       ch->protocol->line_init(dev);
-               }
-               unlock_kernel();
-               return ret;
-       }
-       ch->protocol = NULL;
-       ch->hardware = NULL;
-
-       del_timer(&ch->loadavg_timer);
-       kfree(ch->avg_bytes);
-
-       unregister_netdev(dev);
-       if (ch->debug_area) {
-               kfree(ch->debug_area);
-       }
-       if (dev->priv) {
-               kfree(dev->priv);
-       }
-       free_netdev(dev);
-
-       remove_proc_entry(FILENAME_DEBUG, entry);
-       remove_proc_entry(FILENAME_LINEUPDELAY, entry);
-       remove_proc_entry(FILENAME_STATUS, entry);
-       remove_proc_entry(FILENAME_HARDWARE, entry);
-       remove_proc_entry(FILENAME_PROTOCOL, entry);
-       remove_proc_entry(dentry->d_name.name, comx_root_dir);
-
-       MOD_DEC_USE_COUNT;
-       unlock_kernel();
-       return 0;
-}
-
-static struct dentry *comx_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
-{
-       struct proc_dir_entry *de;
-       struct inode *inode = NULL;
-
-       lock_kernel();
-       if ((de = PDE(dir)) != NULL) {
-               for (de = de->subdir ; de ; de = de->next) {
-                       if ((de->namelen == dentry->d_name.len) &&
-                           (memcmp(dentry->d_name.name, de->name, 
-                           de->namelen) == 0)) {
-                               if ((inode = proc_get_inode(dir->i_sb, 
-                                   de->low_ino, de)) == NULL) { 
-                                       printk(KERN_ERR "COMX: lookup error\n"); 
-                                       unlock_kernel();
-                                       return ERR_PTR(-EINVAL); 
-                               }
-                               break;
-                       }
-               }
-       }
-       unlock_kernel();
-       dentry->d_op = &comx_dentry_operations;
-       d_add(dentry, inode);
-       return NULL;
-}
-
-int comx_strcasecmp(const char *cs, const char *ct)
-{
-       register signed char __res;
-
-       while (1) {
-               if ((__res = toupper(*cs) - toupper(*ct++)) != 0 || !*cs++) {
-                       break;
-               }
-       }
-       return __res;
-}
-
-static int comx_delete_dentry(struct dentry *dentry)
-{
-       return 1;
-}
-
-static struct proc_dir_entry *create_comx_proc_entry(char *name, int mode,
-       int size, struct proc_dir_entry *dir)
-{
-       struct proc_dir_entry *new_file;
-
-       if ((new_file = create_proc_entry(name, S_IFREG | mode, dir)) != NULL) {
-               new_file->data = (void *)new_file;
-               new_file->read_proc = &comx_read_proc;
-               new_file->write_proc = &comx_write_proc;
-               new_file->size = size;
-               new_file->nlink = 1;
-       }
-       return(new_file);
-}
-
-int comx_register_hardware(struct comx_hardware *comx_hw)
-{
-       struct comx_hardware *hw = comx_channels;
-
-       if (!hw) {
-               comx_channels = comx_hw;
-       } else {
-               while (hw->next != NULL && strcmp(comx_hw->name, hw->name) != 0) {
-                       hw = hw->next;
-               }
-               if (strcmp(comx_hw->name, hw->name) == 0) {
-                       return -1;
-               }
-               hw->next = comx_hw;
-       }
-
-       printk(KERN_INFO "COMX: driver for hardware type %s, version %s\n", comx_hw->name, comx_hw->version);
-       return 0;
-}
-
-int comx_unregister_hardware(char *name)
-{
-       struct comx_hardware *hw = comx_channels;
-
-       if (!hw) {
-               return -1;
-       }
-
-       if (strcmp(hw->name, name) == 0) {
-               comx_channels = comx_channels->next;
-               return 0;
-       }
-
-       while (hw->next != NULL && strcmp(hw->next->name,name) != 0) {
-               hw = hw->next;
-       }
-
-       if (hw->next != NULL && strcmp(hw->next->name, name) == 0) {
-               hw->next = hw->next->next;
-               return 0;
-       }
-       return -1;
-}
-
-int comx_register_protocol(struct comx_protocol *comx_line)
-{
-       struct comx_protocol *pr = comx_lines;
-
-       if (!pr) {
-               comx_lines = comx_line;
-       } else {
-               while (pr->next != NULL && strcmp(comx_line->name, pr->name) !=0) {
-                       pr = pr->next;
-               }
-               if (strcmp(comx_line->name, pr->name) == 0) {
-                       return -1;
-               }
-               pr->next = comx_line;
-       }
-
-       printk(KERN_INFO "COMX: driver for protocol type %s, version %s\n", comx_line->name, comx_line->version);
-       return 0;
-}
-
-int comx_unregister_protocol(char *name)
-{
-       struct comx_protocol *pr = comx_lines;
-
-       if (!pr) {
-               return -1;
-       }
-
-       if (strcmp(pr->name, name) == 0) {
-               comx_lines = comx_lines->next;
-               return 0;
-       }
-
-       while (pr->next != NULL && strcmp(pr->next->name,name) != 0) {
-               pr = pr->next;
-       }
-
-       if (pr->next != NULL && strcmp(pr->next->name, name) == 0) {
-               pr->next = pr->next->next;
-               return 0;
-       }
-       return -1;
-}
-
-static int __init comx_init(void)
-{
-       struct proc_dir_entry *new_file;
-
-       comx_root_dir = create_proc_entry("comx", 
-               S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, &proc_root);
-       if (!comx_root_dir)
-               return -ENOMEM;
-       comx_root_dir->proc_iops = &comx_root_inode_ops;
-
-       if ((new_file = create_proc_entry(FILENAME_HARDWARELIST, 
-          S_IFREG | 0444, comx_root_dir)) == NULL) {
-               return -ENOMEM;
-       }
-       
-       new_file->data = new_file;
-       new_file->read_proc = &comx_root_read_proc;
-       new_file->write_proc = NULL;
-       new_file->nlink = 1;
-
-       if ((new_file = create_proc_entry(FILENAME_PROTOCOLLIST, 
-          S_IFREG | 0444, comx_root_dir)) == NULL) {
-               return -ENOMEM;
-       }
-       
-       new_file->data = new_file;
-       new_file->read_proc = &comx_root_read_proc;
-       new_file->write_proc = NULL;
-       new_file->nlink = 1;
-
-
-       printk(KERN_INFO "COMX: driver version %s (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu>\n", 
-               VERSION);
-       return 0;
-}
-
-static void __exit comx_exit(void)
-{
-       remove_proc_entry(FILENAME_HARDWARELIST, comx_root_dir);
-       remove_proc_entry(FILENAME_PROTOCOLLIST, comx_root_dir);
-       remove_proc_entry(comx_root_dir->name, &proc_root);
-}
-
-module_init(comx_init);
-module_exit(comx_exit);
-
-EXPORT_SYMBOL(comx_register_hardware);
-EXPORT_SYMBOL(comx_unregister_hardware);
-EXPORT_SYMBOL(comx_register_protocol);
-EXPORT_SYMBOL(comx_unregister_protocol);
-EXPORT_SYMBOL(comx_debug_skb);
-EXPORT_SYMBOL(comx_debug_bytes);
-EXPORT_SYMBOL(comx_debug);
-EXPORT_SYMBOL(comx_lineup_func);
-EXPORT_SYMBOL(comx_status);
-EXPORT_SYMBOL(comx_rx);
-EXPORT_SYMBOL(comx_strcasecmp);
-EXPORT_SYMBOL(comx_root_dir);
diff --git a/drivers/net/wan/comx.h b/drivers/net/wan/comx.h
deleted file mode 100644 (file)
index 0f7404f..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * General definitions for the COMX driver 
- * 
- * Original authors:  Arpad Bakay <bakay.arpad@synergon.hu>,
- *                    Peter Bajan <bajan.peter@synergon.hu>,
- * Previous maintainer: Tivadar Szemethy <tiv@itc.hu>
- * Currently maintained by: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- *
- * net_device_stats:
- *     rx_length_errors        rec_len < 4 || rec_len > 2000
- *     rx_over_errors          receive overrun (OVR)
- *     rx_crc_errors           rx crc error
- *     rx_frame_errors         aborts rec'd (ABO)
- *     rx_fifo_errors          status fifo overrun (PBUFOVR)
- *     rx_missed_errors        receive buffer overrun (BUFOVR)
- *     tx_aborted_errors       ?
- *     tx_carrier_errors       modem line status changes
- *     tx_fifo_errors          tx underrun (locomx)
- */
-#include <linux/config.h>
-
-struct comx_protocol {
-       char    *name;
-       char    *version;
-       unsigned short encap_type;
-       int     (*line_init)(struct net_device *dev);
-       int     (*line_exit)(struct net_device *dev);
-       struct comx_protocol *next;
-       };
-
-struct comx_hardware {
-       char *name; 
-       char *version;
-       int     (*hw_init)(struct net_device *dev);
-       int     (*hw_exit)(struct net_device *dev);
-       int     (*hw_dump)(struct net_device *dev);
-       struct comx_hardware *next;
-       };
-
-struct comx_channel {
-       void            *if_ptr;        // General purpose pointer
-       struct net_device       *dev;           // Where we belong to
-       struct net_device       *twin;          // On dual-port cards
-       struct proc_dir_entry *procdir; // the directory
-
-       unsigned char   init_status;
-       unsigned char   line_status;
-
-       struct timer_list lineup_timer; // against line jitter
-       long int        lineup_pending;
-       unsigned char   lineup_delay;
-
-#if 0
-       struct timer_list reset_timer; // for board resetting
-       long            reset_pending;
-       int             reset_timeout;
-#endif
-
-       struct net_device_stats stats;  
-       struct net_device_stats *current_stats;
-#if 0
-       unsigned long   board_resets;
-#endif
-       unsigned long   *avg_bytes;
-       int             loadavg_counter, loadavg_size;
-       int             loadavg[3];
-       struct timer_list loadavg_timer;
-       int             debug_flags;
-       char            *debug_area;
-       int             debug_start, debug_end, debug_size;
-       struct proc_dir_entry *debug_file;
-#ifdef CONFIG_COMX_DEBUG_RAW
-       char            *raw;
-       int             raw_len;
-#endif
-       // LINE specific        
-       struct comx_protocol *protocol;
-       void            (*LINE_rx)(struct net_device *dev, struct sk_buff *skb);
-       int             (*LINE_tx)(struct net_device *dev);
-       void            (*LINE_status)(struct net_device *dev, u_short status);
-       int             (*LINE_open)(struct net_device *dev);
-       int             (*LINE_close)(struct net_device *dev);
-       int             (*LINE_xmit)(struct sk_buff *skb, struct net_device *dev);
-       int             (*LINE_header)(struct sk_buff *skb, struct net_device *dev,
-                               u_short type,void *daddr, void *saddr, 
-                               unsigned len);
-       int             (*LINE_rebuild_header)(struct sk_buff *skb);
-       int             (*LINE_statistics)(struct net_device *dev, char *page);
-       int             (*LINE_parameter_check)(struct net_device *dev);
-       int             (*LINE_ioctl)(struct net_device *dev, struct ifreq *ifr,
-                               int cmd);
-       void            (*LINE_mod_use)(int);
-       void *          LINE_privdata;
-
-       // HW specific
-
-       struct comx_hardware *hardware;
-       void    (*HW_board_on)(struct net_device *dev);
-       void    (*HW_board_off)(struct net_device *dev);
-       struct net_device *(*HW_access_board)(struct net_device *dev);
-       void    (*HW_release_board)(struct net_device *dev, struct net_device *savep);
-       int     (*HW_txe)(struct net_device *dev);
-       int     (*HW_open)(struct net_device *dev);
-       int     (*HW_close)(struct net_device *dev);
-       int     (*HW_send_packet)(struct net_device *dev,struct sk_buff *skb);
-       int     (*HW_statistics)(struct net_device *dev, char *page);
-#if 0
-       int     (*HW_reset)(struct net_device *dev, char *page);
-#endif
-       int     (*HW_load_board)(struct net_device *dev);
-       void    (*HW_set_clock)(struct net_device *dev);
-       void    *HW_privdata;
-       };
-
-struct comx_debugflags_struct {
-       char *name;
-       int  value;
-       };
-
-#define        COMX_ROOT_DIR_NAME      "comx"
-
-#define        FILENAME_HARDWARE       "boardtype"
-#define FILENAME_HARDWARELIST  "boardtypes"
-#define FILENAME_PROTOCOL      "protocol"
-#define FILENAME_PROTOCOLLIST  "protocols"
-#define FILENAME_DEBUG         "debug"
-#define FILENAME_CLOCK         "clock"
-#define        FILENAME_STATUS         "status"
-#define        FILENAME_IO             "io"
-#define FILENAME_IRQ           "irq"
-#define        FILENAME_KEEPALIVE      "keepalive"
-#define FILENAME_LINEUPDELAY   "lineup_delay"
-#define FILENAME_CHANNEL       "channel"
-#define FILENAME_FIRMWARE      "firmware"
-#define FILENAME_MEMADDR       "memaddr"
-#define        FILENAME_TWIN           "twin"
-#define FILENAME_T1            "t1"
-#define FILENAME_T2            "t2"
-#define FILENAME_N2            "n2"
-#define FILENAME_WINDOW                "window"
-#define FILENAME_MODE          "mode"
-#define        FILENAME_DLCI           "dlci"
-#define        FILENAME_MASTER         "master"
-#ifdef CONFIG_COMX_DEBUG_RAW
-#define        FILENAME_RAW            "raw"
-#endif
-
-#define PROTONAME_NONE         "none"
-#define HWNAME_NONE            "none"
-#define KEEPALIVE_OFF          "off"
-
-#define FRAME_ACCEPTED         0               /* sending and xmitter busy */
-#define FRAME_DROPPED          1
-#define FRAME_ERROR            2               /* xmitter error */
-#define        FRAME_QUEUED            3               /* sending but more can come */
-
-#define        LINE_UP                 1               /* Modem UP */
-#define PROTO_UP               2
-#define PROTO_LOOP             4
-
-#define        HW_OPEN                 1
-#define        LINE_OPEN               2
-#define FW_LOADED              4
-#define IRQ_ALLOCATED          8
-
-#define DEBUG_COMX_RX          2
-#define        DEBUG_COMX_TX           4
-#define        DEBUG_HW_TX             16
-#define        DEBUG_HW_RX             32
-#define        DEBUG_HDLC_KEEPALIVE    64
-#define        DEBUG_COMX_PPP          128
-#define DEBUG_COMX_LAPB                256
-#define        DEBUG_COMX_DLCI         512
-
-#define        DEBUG_PAGESIZE          3072
-#define DEFAULT_DEBUG_SIZE     4096
-#define        DEFAULT_LINEUP_DELAY    1
-#define        FILE_PAGESIZE           3072
-
-#ifndef        COMX_PPP_MAJOR
-#define        COMX_PPP_MAJOR          88
-#endif
-
-
-#define COMX_CHANNEL(dev) ((struct comx_channel*)dev->priv)
-
-#define TWIN(dev) (COMX_CHANNEL(dev)->twin)
-
-
-#ifndef byte
-typedef u8     byte;
-#endif
-#ifndef word
-typedef u16    word;
-#endif
-
-#ifndef        SEEK_SET
-#define        SEEK_SET        0
-#endif
-#ifndef        SEEK_CUR
-#define        SEEK_CUR        1
-#endif
-#ifndef        SEEK_END
-#define        SEEK_END        2
-#endif
-
-extern struct proc_dir_entry * comx_root_dir;
-
-extern int     comx_register_hardware(struct comx_hardware *comx_hw);
-extern int     comx_unregister_hardware(char *name);
-extern int     comx_register_protocol(struct comx_protocol *comx_line);
-extern int     comx_unregister_protocol(char *name);
-
-extern int     comx_rx(struct net_device *dev, struct sk_buff *skb);
-extern void    comx_status(struct net_device *dev, int status);
-extern void    comx_lineup_func(unsigned long d);
-
-extern int     comx_debug(struct net_device *dev, char *fmt, ...);
-extern int     comx_debug_skb(struct net_device *dev, struct sk_buff *skb, char *msg);
-extern int     comx_debug_bytes(struct net_device *dev, unsigned char *bytes, int len,
-               char *msg);
-extern int     comx_strcasecmp(const char *cs, const char *ct);
-
-extern struct inode_operations comx_normal_inode_ops;
diff --git a/drivers/net/wan/comxhw.h b/drivers/net/wan/comxhw.h
deleted file mode 100644 (file)
index 15230dc..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Defines for comxhw.c
- *
- * Original authors:  Arpad Bakay <bakay.arpad@synergon.hu>,
- *                    Peter Bajan <bajan.peter@synergon.hu>,
- * Previous maintainer: Tivadar Szemethy <tiv@itc.hu>
- * Current maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- */
-
-#define        LOCOMX_IO_EXTENT        8
-#define COMX_IO_EXTENT         4
-#define        HICOMX_IO_EXTENT        16
-
-#define COMX_MAX_TX_SIZE       1600
-#define COMX_MAX_RX_SIZE       2048
-
-#define COMX_JAIL_OFFSET       0xffff
-#define COMX_JAIL_VALUE                0xfe
-#define        COMX_MEMORY_SIZE        65536
-#define HICOMX_MEMORY_SIZE     16384
-#define COMX_MEM_MIN           0xa0000
-#define COMX_MEM_MAX           0xf0000
-
-#define        COMX_DEFAULT_IO         0x360
-#define        COMX_DEFAULT_IRQ        10
-#define        COMX_DEFAULT_MEMADDR    0xd0000
-#define        HICOMX_DEFAULT_IO       0x320
-#define        HICOMX_DEFAULT_IRQ      10
-#define        HICOMX_DEFAULT_MEMADDR  0xd0000
-#define        LOCOMX_DEFAULT_IO       0x368
-#define        LOCOMX_DEFAULT_IRQ      7
-
-#define MAX_CHANNELNO          2
-
-#define        COMX_CHANNEL_OFFSET     0x2000
-
-#define COMX_ENABLE_BOARD_IT    0x40
-#define COMX_BOARD_RESET               0x20
-#define COMX_ENABLE_BOARD_MEM   0x10
-#define COMX_DISABLE_BOARD_MEM  0
-#define COMX_DISABLE_ALL       0x00
-
-#define HICOMX_DISABLE_ALL     0x00
-#define HICOMX_ENABLE_BOARD_MEM        0x02
-#define HICOMX_DISABLE_BOARD_MEM 0x0
-#define HICOMX_BOARD_RESET     0x01
-#define HICOMX_PRG_MEM         4
-#define HICOMX_DATA_MEM                0
-#define HICOMX_ID_BYTE         0x55
-
-#define CMX_ID_BYTE            0x31
-#define COMX_CLOCK_CONST       8000
-
-#define        LINKUP_READY            3
-
-#define        OFF_FW_L1_ID    0x01e    /* ID bytes */
-#define OFF_FW_L2_ID   0x1006
-#define        FW_L1_ID_1      0xab
-#define FW_L1_ID_2_COMX                0xc0
-#define FW_L1_ID_2_HICOMX      0xc1
-#define        FW_L2_ID_1      0xab
-
-#define OFF_A_L2_CMD     0x130   /* command register for L2 */
-#define OFF_A_L2_CMDPAR  0x131   /* command parameter byte */
-#define OFF_A_L1_STATB   0x122   /* stat. block for L1 */
-#define OFF_A_L1_ABOREC  0x122   /* receive ABORT counter */
-#define OFF_A_L1_OVERRUN 0x123   /* receive overrun counter */
-#define OFF_A_L1_CRCREC  0x124   /* CRC error counter */
-#define OFF_A_L1_BUFFOVR 0x125   /* buffer overrun counter */
-#define OFF_A_L1_PBUFOVR 0x126   /* priority buffer overrun counter */
-#define OFF_A_L1_MODSTAT 0x127   /* current state of modem ctrl lines */
-#define OFF_A_L1_STATE   0x127   /* end of stat. block for L1 */
-#define OFF_A_L1_TXPC    0x128   /* Tx counter for the PC */
-#define OFF_A_L1_TXZ80   0x129   /* Tx counter for the Z80 */
-#define OFF_A_L1_RXPC    0x12a   /* Rx counter for the PC */
-#define OFF_A_L1_RXZ80   0x12b   /* Rx counter for the Z80 */
-#define OFF_A_L1_REPENA  0x12c   /* IT rep disable */
-#define OFF_A_L1_CHNR    0x12d   /* L1 channel logical number */
-#define OFF_A_L1_CLKINI  0x12e   /* Timer Const */
-#define OFF_A_L2_LINKUP         0x132   /* Linkup byte */
-#define OFF_A_L2_DAV    0x134   /* Rx DAV */
-#define OFF_A_L2_RxBUFP  0x136  /* Rx buff relative to membase */
-#define OFF_A_L2_TxEMPTY 0x138   /* Tx Empty */
-#define OFF_A_L2_TxBUFP  0x13a   /* Tx Buf */
-#define OFF_A_L2_NBUFFS         0x144   /* Number of buffers to fetch */
-
-#define OFF_A_L2_SABMREC 0x164  /* LAPB no. of SABMs received */
-#define OFF_A_L2_SABMSENT 0x165         /* LAPB no. of SABMs sent */
-#define OFF_A_L2_REJREC  0x166  /* LAPB no. of REJs received */
-#define OFF_A_L2_REJSENT 0x167  /* LAPB no. of REJs sent */
-#define OFF_A_L2_FRMRREC 0x168  /* LAPB no. of FRMRs received */
-#define OFF_A_L2_FRMRSENT 0x169         /* LAPB no. of FRMRs sent */
-#define OFF_A_L2_PROTERR 0x16A  /* LAPB no. of protocol errors rec'd */
-#define OFF_A_L2_LONGREC 0x16B  /* LAPB no. of long frames */
-#define OFF_A_L2_INVNR   0x16C  /* LAPB no. of invalid N(R)s rec'd */
-#define OFF_A_L2_UNDEFFR 0x16D  /* LAPB no. of invalid frames */
-
-#define        OFF_A_L2_T1     0x174    /* T1 timer */
-#define        OFF_A_L2_ADDR   0x176    /* DCE = 1, DTE = 3 */
-
-#define        COMX_CMD_INIT   1
-#define COMX_CMD_EXIT  2
-#define COMX_CMD_OPEN  16
-#define COMX_CMD_CLOSE 17
-
diff --git a/drivers/net/wan/falc-lh.h b/drivers/net/wan/falc-lh.h
deleted file mode 100644 (file)
index e30726c..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *     Defines for comx-hw-slicecom.c - FALC-LH specific
- *
- *     Author:         Bartok Istvan <bartoki@itc.hu>
- *     Last modified:  Mon Feb  7 20:00:38 CET 2000
- *
- *     :set tabstop=6
- */
-
-/*
- *     Control register offsets on the LBI (page 90)
- *     use it like:
- *     lbi[ MODE ] = 0x34;
- */
-
-#define MODE   0x03
-#define IPC            0x08
-#define IMR0   0x14    /* Interrupt Mask Register 0    */
-#define IMR1   0x15
-#define IMR2   0x16
-#define IMR3   0x17
-#define IMR4   0x18
-#define IMR5   0x19
-#define FMR0   0x1a    /* Framer Mode Register 0       */
-#define FMR1   0x1b
-#define FMR2   0x1c
-#define XSW            0x1e
-#define XSP            0x1f
-#define XC0            0x20
-#define XC1            0x21
-#define RC0            0x22
-#define RC1            0x23
-#define XPM0   0x24
-#define XPM1   0x25
-#define XPM2   0x26
-#define TSWM   0x27
-#define IDLE   0x29    /* Idle Code    */
-#define LIM0   0x34
-#define LIM1   0x35
-#define PCD            0x36
-#define PCR            0x37
-#define LIM2   0x38
-
-/*
- *     Status registers on the LBI (page 134)
- *     these are read-only, use it like:
- *     if( lbi[ FRS0 ] ) ...
- */
-
-#define FRS0   0x4c    /* Framer Receive Status register 0     */
-#define FRS1   0x4d    /* Framer Receive Status register 1     */
-#define FECL   0x50    /* Framing Error Counter low byte       */ /* Counts FAS word receive errors            */
-#define FECH   0x51    /*                       high byte      */
-#define CVCL   0x52    /* Code Violation Counter low byte      */ /* Counts bipolar and HDB3 code violations   */
-#define CVCH   0x53    /*                        high byte     */
-#define CEC1L  0x54    /* CRC4 Error Counter 1 low byte        */ /* Counts CRC4 errors in the incoming stream */
-#define CEC1H  0x55    /*                      high byte       */
-#define EBCL   0x56    /* E Bit error Counter low byte */ /* E-bits: the remote end sends them, when   */
-#define EBCH   0x57    /*                     high byte        */ /* it detected a CRC4-error                  */
-#define ISR0   0x68    /* Interrupt Status Register 0  */
-#define ISR1   0x69    /* Interrupt Status Register 1  */
-#define ISR2   0x6a    /* Interrupt Status Register 2  */
-#define ISR3   0x6b    /* Interrupt Status Register 3  */
-#define ISR5   0x6c    /* Interrupt Status Register 5  */
-#define GIS    0x6e    /* Global Interrupt Status Register     */
-#define VSTR   0x6f    /* version information */
-
-/*
- *     Bit fields
- */
-
-#define FRS0_LOS               (1 << 7)
-#define FRS0_AIS               (1 << 6)
-#define FRS0_LFA               (1 << 5)
-#define FRS0_RRA               (1 << 4)
-#define FRS0_AUXP              (1 << 3)
-#define FRS0_NMF               (1 << 2)
-#define FRS0_LMFA              (1 << 1)
-
-#define FRS1_XLS               (1 << 1)
-#define FRS1_XLO               (1)
-
-#define ISR2_FAR               (1 << 7)
-#define ISR2_LFA               (1 << 6)
-#define ISR2_MFAR              (1 << 5)
-#define ISR2_T400MS    (1 << 4)
-#define ISR2_AIS               (1 << 3)
-#define ISR2_LOS               (1 << 2)
-#define ISR2_RAR               (1 << 1)
-#define ISR2_RA                (1)
-
-#define ISR3_ES                (1 << 7)
-#define ISR3_SEC               (1 << 6)
-#define ISR3_LMFA16    (1 << 5)
-#define ISR3_AIS16     (1 << 4)
-#define ISR3_RA16              (1 << 3)
-#define ISR3_API               (1 << 2)
-#define ISR3_RSN               (1 << 1)
-#define ISR3_RSP               (1)
-
-#define ISR5_XSP               (1 << 7)
-#define ISR5_XSN               (1 << 6)
diff --git a/drivers/net/wan/hscx.h b/drivers/net/wan/hscx.h
deleted file mode 100644 (file)
index 675b7b1..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#define        HSCX_MTU        1600
-
-#define        HSCX_ISTA       0x00
-#define HSCX_MASK      0x00
-#define HSCX_STAR      0x01
-#define HSCX_CMDR      0x01
-#define HSCX_MODE      0x02
-#define HSCX_TIMR      0x03
-#define HSCX_EXIR      0x04
-#define HSCX_XAD1      0x04
-#define HSCX_RBCL      0x05
-#define HSCX_SAD2      0x05
-#define HSCX_RAH1      0x06
-#define HSCX_RSTA      0x07
-#define HSCX_RAH2      0x07
-#define HSCX_RAL1      0x08
-#define HSCX_RCHR      0x09
-#define HSCX_RAL2      0x09
-#define HSCX_XBCL      0x0a
-#define HSCX_BGR       0x0b
-#define HSCX_CCR2      0x0c
-#define HSCX_RBCH      0x0d
-#define HSCX_XBCH      0x0d
-#define HSCX_VSTR      0x0e
-#define HSCX_RLCR      0x0e
-#define HSCX_CCR1      0x0f
-#define HSCX_FIFO      0x1e
-
-#define HSCX_HSCX_CHOFFS       0x400
-#define HSCX_SEROFFS   0x1000
-
-#define HSCX_RME       0x80
-#define HSCX_RPF       0x40
-#define HSCX_RSC       0x20
-#define HSCX_XPR       0x10
-#define HSCX_TIN       0x08
-#define HSCX_ICA       0x04
-#define HSCX_EXA       0x02
-#define HSCX_EXB       0x01
-
-#define HSCX_XMR       0x80
-#define HSCX_XDU       0x40
-#define HSCX_EXE       0x40
-#define HSCX_PCE       0x20
-#define HSCX_RFO       0x10
-#define HSCX_CSC       0x08
-#define HSCX_RFS       0x04
-
-#define HSCX_XDOV      0x80
-#define HSCX_XFW       0x40
-#define HSCX_XRNR      0x20
-#define HSCX_RRNR      0x10
-#define HSCX_RLI       0x08
-#define HSCX_CEC       0x04
-#define HSCX_CTS       0x02
-#define HSCX_WFA       0x01
-
-#define HSCX_RMC       0x80
-#define HSCX_RHR       0x40
-#define HSCX_RNR       0x20
-#define HSCX_XREP      0x20
-#define HSCX_STI       0x10
-#define HSCX_XTF       0x08
-#define HSCX_XIF       0x04
-#define HSCX_XME       0x02
-#define HSCX_XRES      0x01
-
-#define HSCX_AUTO      0x00
-#define HSCX_NONAUTO   0x40
-#define HSCX_TRANS     0x80
-#define HSCX_XTRANS    0xc0
-#define HSCX_ADM16     0x20
-#define HSCX_ADM8      0x00
-#define HSCX_TMD_EXT   0x00
-#define HSCX_TMD_INT   0x10
-#define HSCX_RAC       0x08
-#define HSCX_RTS       0x04
-#define HSCX_TLP       0x01
-
-#define HSCX_VFR       0x80
-#define HSCX_RDO       0x40
-#define HSCX_CRC       0x20
-#define HSCX_RAB       0x10
-
-#define HSCX_CIE       0x04
-#define HSCX_RIE       0x02
-
-#define HSCX_DMA       0x80
-#define HSCX_NRM       0x40
-#define HSCX_CAS       0x20
-#define HSCX_XC        0x10
-
-#define HSCX_OV        0x10
-
-#define HSCX_CD        0x80
-
-#define HSCX_RC        0x80
-
-#define HSCX_PU        0x80
-#define HSCX_NRZ       0x00
-#define HSCX_NRZI      0x40
-#define HSCX_ODS       0x10
-#define HSCX_ITF       0x08
diff --git a/drivers/net/wan/mixcom.h b/drivers/net/wan/mixcom.h
deleted file mode 100644 (file)
index 1815eef..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Defines for the mixcom board
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- */
-
-#define        MIXCOM_IO_EXTENT        0x20
-
-#define        MIXCOM_DEFAULT_IO       0x180
-#define        MIXCOM_DEFAULT_IRQ      5
-
-#define MIXCOM_ID              0x11
-#define MIXCOM_SERIAL_OFFSET   0x1000
-#define MIXCOM_CHANNEL_OFFSET  0x400
-#define MIXCOM_IT_OFFSET       0xc14
-#define MIXCOM_STATUS_OFFSET   0xc14
-#define MIXCOM_ID_OFFSET       0xc10
-#define MIXCOM_ON              0x1
-#define MIXCOM_OFF             0x0
-
-/* Status register bits */
-
-#define MIXCOM_CTSB            0x1
-#define MIXCOM_CTSA            0x2
-#define MIXCOM_CHANNELNO       0x20
-#define MIXCOM_POWERFAIL       0x40
-#define MIXCOM_BOOT            0x80
diff --git a/drivers/net/wan/munich32x.h b/drivers/net/wan/munich32x.h
deleted file mode 100644 (file)
index 8f151f2..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- *     Defines for comx-hw-slicecom.c - MUNICH32X specific
- *
- *     Author:        Bartok Istvan <bartoki@itc.hu>
- *     Last modified: Tue Jan 11 14:27:36 CET 2000
- *
- *     :set tabstop=6
- */
-
-#define TXBUFFER_SIZE  1536                    /* Max mennyit tud a kartya hardver atvenni                             */
-#define RXBUFFER_SIZE  (TXBUFFER_SIZE+4)       /* For Rx reasons it must be a multiple of 4, and =>4 (page 265)        */
-                                                       /* +4 .. see page 265, bit FE                                                   */
-                                                       /* TOD: a MODE1-be nem is ezt teszem, hanem a TXBUFFER-t, lehet hogy nem is kell? */
-
-//#define PCI_VENDOR_ID_SIEMENS                        0x110a
-#define PCI_DEVICE_ID_SIEMENS_MUNICH32X        0x2101
-
-/*
- *     PCI config space registers (page 120)
- */
-
-#define MUNICH_PCI_PCIRES      0x4c            /* 0xe0000 resets       the chip        */
-
-
-/*
- *     MUNICH slave register offsets relative to base_address[0] (PCI BAR1) (page 181):
- *     offsets are in bytes, registers are u32's, so we need a >>2 for indexing
- *     the int[] by byte offsets. Use it like:
- *
- *     bar1[ STAT ] = ~0L;  or
- *     x = bar1[ STAT ];
- */
-
-#define CONF   (0x00 >> 2)
-#define CMD            (0x04 >> 2)
-#define STAT   (0x08 >> 2)
-#define STACK  (0x08 >> 2)
-#define IMASK  (0x0c >> 2)
-#define PIQBA  (0x14 >> 2)
-#define PIQL   (0x18 >> 2)
-#define MODE1  (0x20 >> 2)
-#define MODE2  (0x24 >> 2)
-#define CCBA   (0x28 >> 2)
-#define TXPOLL (0x2c >> 2)
-#define TIQBA  (0x30 >> 2)
-#define TIQL   (0x34 >> 2)
-#define RIQBA  (0x38 >> 2)
-#define RIQL   (0x3c >> 2)
-#define LCONF  (0x40 >> 2)             /* LBI Configuration Register           */
-#define LCCBA  (0x44 >> 2)             /* LBI Configuration Control Block      */      /* DE: lehet hogy nem is kell? */
-#define LTIQBA (0x50 >> 2)             /* DE: lehet hogy nem is kell? page 210: LBI DMA Controller intq - nem hasznalunk DMA-t.. */
-#define LTIQL  (0x54 >> 2)             /* DE: lehet hogy nem is kell? */
-#define LRIQBA (0x58 >> 2)             /* DE: lehet hogy nem is kell? */
-#define LRIQL  (0x5c >> 2)             /* DE: lehet hogy nem is kell? */
-#define LREG0  (0x60 >> 2)             /* LBI Indirect External Configuration register 0       */
-#define LREG1  (0x64 >> 2)
-#define LREG2  (0x68 >> 2)
-#define LREG3  (0x6c >> 2)
-#define LREG4  (0x70 >> 2)
-#define LREG5  (0x74 >> 2)
-#define LREG6  (0x78 >> 2)             /* LBI Indirect External Configuration register 6               */
-#define LSTAT  (0x7c >> 2)             /* LBI Status Register                                                  */
-#define GPDIR  (0x80 >> 2)             /* General Purpose Bus DIRection - 0..input, 1..output  */
-#define GPDATA (0x84 >> 2)             /* General Purpose Bus DATA                                             */
-
-
-/*
- *     MUNICH commands: (they go into register CMD)
- */
-
-#define CMD_ARPCM      0x01                    /* Action Request Serial PCM Core       */
-#define CMD_ARLBI      0x02                    /* Action Request LBI                   */
-
-
-/*
- *     MUNICH event bits in the STAT, STACK, IMASK registers (page 188,189)
- */
-
-#define STAT_PTI       (1 << 15)
-#define STAT_PRI       (1 << 14)
-#define STAT_LTI       (1 << 13)
-#define STAT_LRI       (1 << 12)
-#define STAT_IOMI      (1 << 11)
-#define STAT_SSCI      (1 << 10)
-#define STAT_LBII      (1 << 9)
-#define STAT_MBI       (1 << 8)
-
-#define STAT_TI        (1 << 6)
-#define STAT_TSPA      (1 << 5)
-#define STAT_RSPA      (1 << 4)
-#define STAT_LBIF      (1 << 3)
-#define STAT_LBIA      (1 << 2)
-#define STAT_PCMF      (1 << 1)
-#define STAT_PCMA      (1) 
-
-/*
- *     We do not handle these (and do not touch their STAT bits) in the interrupt loop
- */
-
-#define STAT_NOT_HANDLED_BY_INTERRUPT  (STAT_PCMF | STAT_PCMA)
-
-
-/*
- *     MUNICH MODE1/MODE2 slave register fields (page 193,196)
- *     these are not all masks, MODE1_XX_YY are my magic values!
- */
-
-#define MODE1_PCM_E1   (1 << 31)               /* E1, 2.048 Mbit/sec           */
-#define MODE1_TBS_4    (1 << 24)               /* TBS = 4 .. no Tx bit shift   */
-#define MODE1_RBS_4    (1 << 18)               /* RBS = 4 .. no Rx bit shift   */
-#define MODE1_REN              (1 << 15)               /* Rx Enable                    */
-#define MODE1_MFL_MY   TXBUFFER_SIZE   /* Maximum Frame Length         */
-#define MODE1_MAGIC    (MODE1_PCM_E1 | MODE1_TBS_4 | MODE1_RBS_4 | MODE1_REN | MODE1_MFL_MY)
-
-#define MODE2_HPOLL    (1 << 8)                /* Hold Poll                    */
-#define MODE2_SPOLL    (1 << 7)                /* Slow Poll                    */
-#define MODE2_TSF              (1)                     /* real magic - discovered by probing :)        */
-// #define MODE2_MAGIC (MODE2_TSF)
-#define MODE2_MAGIC    (MODE2_SPOLL | MODE2_TSF)
-
-
-/*
- *     LCONF bits (page 205)
- *     these are not all masks, LCONF_XX_YY are my magic values!
- */
-
-#define LCONF_IPA                      (1 << 31)       /* Interrupt Pass. Use 1 for FALC54                                                     */
-#define LCONF_DCA                      (1 << 30)       /* Disregard the int's for Channel A - DMSM does not try to handle them */
-#define LCONF_DCB                      (1 << 29)       /* Disregard the int's for Channel B                                            */
-#define LCONF_EBCRES           (1 << 22)       /* Reset LBI External Bus Controller, 0..reset, 1..normal operation     */
-#define LCONF_LBIRES           (1 << 21)       /* Reset LBI DMSM, 0..reset, 1..normal operation                                */
-#define LCONF_BTYP_16DEMUX     (1 << 7)        /* 16-bit demultiplexed bus     */
-#define LCONF_ABM                      (1 << 4)        /* Arbitration Master           */
-
-/* writing LCONF_MAGIC1 followed by a LCONF_MAGIC2 into LCONF resets the EBC and DMSM: */
-
-#define LCONF_MAGIC1           (LCONF_BTYP_16DEMUX | LCONF_ABM | LCONF_IPA | LCONF_DCA | LCONF_DCB)
-#define LCONF_MAGIC2           (LCONF_MAGIC1 | LCONF_EBCRES | LCONF_LBIRES)
-
-
-/*
- *     LREGx magic values if a FALC54 is on the LBI (page 217)
- */
-
-#define LREG0_MAGIC    0x00000264
-#define LREG1_MAGIC    0x6e6a6b66
-#define LREG2_MAGIC    0x00000264
-#define LREG3_MAGIC    0x6e686966
-#define LREG4_MAGIC    0x00000000
-#define LREG5_MAGIC    ( (7<<27) | (3<<24) | (1<<21) | (7<<3) | (2<<9) )
-
-
-/*
- *     PCM Action Specification fields (munich_ccb_t.action_spec)
- */
-
-#define CCB_ACTIONSPEC_IN                      (1 << 15)       /* init                         */
-#define CCB_ACTIONSPEC_ICO                     (1 << 14)       /* init only this channel       */
-#define CCB_ACTIONSPEC_RES                     (1 << 6)        /* reset all channels           */
-#define CCB_ACTIONSPEC_LOC                     (1 << 5)
-#define CCB_ACTIONSPEC_LOOP                    (1 << 4)
-#define CCB_ACTIONSPEC_LOOPI                   (1 << 3)
-#define CCB_ACTIONSPEC_IA                      (1 << 2)
-
-
-/*
- *     Interrupt Information bits in the TIQ, RIQ
- */
-
-#define PCM_INT_HI     (1 << 12)
-#define PCM_INT_FI     (1 << 11)
-#define PCM_INT_IFC    (1 << 10)
-#define PCM_INT_SF     (1 << 9)
-#define PCM_INT_ERR    (1 << 8)
-#define PCM_INT_FO     (1 << 7)
-#define PCM_INT_FE2    (1 << 6)
-
-#define PCM_INT_CHANNEL( info )        (info & 0x1F)
-
-
-/*
- *     Rx status info in the rx_desc_t.status
- */
-
-#define RX_STATUS_SF   (1 << 6)
-#define RX_STATUS_LOSS (1 << 5)
-#define RX_STATUS_CRCO (1 << 4)
-#define RX_STATUS_NOB  (1 << 3)
-#define RX_STATUS_LFD  (1 << 2)
-#define RX_STATUS_RA   (1 << 1)
-#define RX_STATUS_ROF  1 
diff --git a/drivers/net/wan/wanxlfw.inc b/drivers/net/wan/wanxlfw.inc
deleted file mode 100644 (file)
index 73da688..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-static u8 firmware[]={
-0x60,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0xB9,0x40,0x00,0x00,0x00,0x00,0x00,
-0x10,0x14,0x42,0x80,0x4A,0xB0,0x09,0xB0,0x00,0x00,0x10,0x04,0x67,0x00,0x00,0x0E,
-0x06,0xB0,0x40,0x00,0x00,0x00,0x09,0xB0,0x00,0x00,0x10,0x04,0x58,0x80,0x0C,0x80,
-0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0xDE,0x21,0xFC,0x00,0x00,0x16,0xBC,0x00,0x6C,
-0x21,0xFC,0x00,0x00,0x17,0x5E,0x01,0x00,0x21,0xFC,0x00,0x00,0x16,0xDE,0x01,0x78,
-0x21,0xFC,0x00,0x00,0x16,0xFE,0x01,0x74,0x21,0xFC,0x00,0x00,0x17,0x1E,0x01,0x70,
-0x21,0xFC,0x00,0x00,0x17,0x3E,0x01,0x6C,0x21,0xFC,0x00,0x00,0x18,0x4C,0x02,0x00,
-0x23,0xFC,0x78,0x00,0x00,0x00,0xFF,0xFC,0x15,0x48,0x33,0xFC,0x04,0x80,0xFF,0xFC,
-0x10,0x26,0x33,0xFC,0x01,0x10,0xFF,0xFC,0x10,0x2A,0x23,0xFC,0x00,0xD4,0x9F,0x40,
-0xFF,0xFC,0x15,0x40,0x23,0xFC,0x00,0x00,0x05,0x43,0xFF,0xF9,0x01,0x00,0x23,0xFC,
-0x00,0x00,0x05,0x43,0xFF,0xF9,0x01,0x14,0x23,0xFC,0x00,0x00,0x00,0x00,0xFF,0xF9,
-0x01,0x10,0x23,0xFC,0x00,0x00,0x00,0x08,0xFF,0xF9,0x01,0x24,0x23,0xFC,0x00,0x00,
-0x01,0x01,0xFF,0xF9,0x01,0x28,0x00,0xB9,0x00,0x0F,0x03,0x00,0xFF,0xF9,0x00,0xE8,
-0x23,0xFC,0x00,0x00,0x00,0x01,0xFF,0xF9,0x00,0xD4,0x61,0x00,0x06,0x74,0x33,0xFC,
-0xFF,0xFF,0xFF,0xFC,0x15,0x52,0x42,0x79,0xFF,0xFC,0x15,0x50,0x42,0x79,0xFF,0xFC,
-0x15,0x64,0x2E,0x3A,0x08,0x50,0x42,0xB9,0x00,0x00,0x19,0x54,0x4A,0x87,0x66,0x00,
-0x00,0x0E,0x4E,0x72,0x22,0x00,0x46,0xFC,0x27,0x00,0x60,0x00,0xFF,0xE6,0x42,0x80,
-0x42,0x86,0x08,0x07,0x00,0x04,0x67,0x00,0x00,0x0A,0x08,0x87,0x00,0x00,0x61,0x00,
-0x02,0xA0,0x08,0x07,0x00,0x00,0x67,0x00,0x00,0x06,0x61,0x00,0x00,0x36,0x08,0x07,
-0x00,0x08,0x67,0x00,0x00,0x06,0x61,0x00,0x02,0xB8,0x08,0x07,0x00,0x0C,0x67,0x00,
-0x00,0x0A,0x61,0x00,0x04,0x94,0x61,0x00,0x03,0x60,0xE2,0x8F,0x58,0x80,0x0C,0x80,
-0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0xBC,0x23,0xC6,0xFF,0xF9,0x00,0xE4,0x60,0x00,
-0xFF,0x92,0x20,0x70,0x09,0xB0,0x00,0x00,0x10,0x04,0x4A,0xA8,0x00,0x00,0x66,0x00,
-0x02,0x4E,0x21,0x7C,0x00,0x00,0x00,0x01,0x00,0x00,0x42,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x58,0x42,0xB0,0x09,0xB0,0x00,0x00,0x19,0x68,0x42,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x78,0x42,0xB0,0x09,0xB0,0x00,0x00,0x19,0x88,0x22,0x39,0xFF,0xFC,0x16,0xEC,
-0xC2,0xB0,0x09,0xB0,0x00,0x00,0x18,0xF2,0x0C,0xA8,0x00,0x00,0x00,0x04,0x00,0x18,
-0x66,0x00,0x00,0x0E,0x82,0xB0,0x09,0xB0,0x00,0x00,0x18,0xE2,0x60,0x00,0x00,0x0A,
-0x82,0xB0,0x09,0xB0,0x00,0x00,0x18,0xD2,0x23,0xC1,0xFF,0xFC,0x16,0xEC,0x00,0x70,
-0x10,0x00,0x09,0xB0,0x00,0x00,0x19,0xAA,0x61,0x00,0x05,0x76,0x22,0x30,0x09,0xB0,
-0x00,0x00,0x18,0x92,0x22,0x70,0x09,0xB0,0x00,0x00,0x18,0x72,0x74,0x08,0x26,0x3C,
-0x18,0x00,0x00,0x00,0x0C,0xA8,0x00,0x00,0x00,0x01,0x00,0x10,0x67,0x00,0x00,0x06,
-0x08,0xC3,0x00,0x1A,0x22,0xC3,0x22,0xC1,0x06,0x81,0x00,0x00,0x05,0xFC,0x51,0xCA,
-0xFF,0xF4,0x08,0xC3,0x00,0x1D,0x22,0xC3,0x22,0xC1,0x74,0x1C,0x22,0xFC,0x90,0x00,
-0x00,0x00,0x22,0xC1,0x06,0x81,0x00,0x00,0x05,0xFC,0x51,0xCA,0xFF,0xF0,0x22,0xFC,
-0xB0,0x00,0x00,0x00,0x22,0xC1,0x22,0x70,0x09,0xB0,0x00,0x00,0x18,0x62,0x24,0x70,
-0x09,0xB0,0x00,0x00,0x18,0x52,0x25,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x10,0x25,0x7C,
-0x00,0x00,0x00,0x00,0x00,0x14,0x22,0x30,0x09,0xB0,0x00,0x00,0x18,0x72,0x33,0x41,
-0x00,0x02,0x06,0x81,0x00,0x00,0x00,0x50,0x33,0x41,0x00,0x00,0x13,0x7C,0x00,0x08,
-0x00,0x04,0x13,0x7C,0x00,0x08,0x00,0x05,0x0C,0xA8,0x00,0x00,0x00,0x05,0x00,0x10,
-0x66,0x00,0x00,0x2A,0x42,0x6A,0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,
-0x23,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x38,0x33,0x7C,0x05,0xFA,0x00,0x46,0x31,0xBC,
-0x00,0x02,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,0x00,0xBC,0x0C,0xA8,0x00,0x00,
-0x00,0x07,0x00,0x10,0x66,0x00,0x00,0x2C,0x35,0x7C,0x08,0x00,0x00,0x08,0x23,0x7C,
-0xDE,0xBB,0x20,0xE3,0x00,0x34,0x23,0x7C,0xFF,0xFF,0xFF,0xFF,0x00,0x38,0x33,0x7C,
-0x05,0xFC,0x00,0x46,0x31,0xBC,0x00,0x04,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,
-0x00,0x86,0x0C,0xA8,0x00,0x00,0x00,0x04,0x00,0x10,0x66,0x00,0x00,0x26,0x42,0x6A,
-0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,0x42,0xA9,0x00,0x38,0x33,0x7C,
-0x05,0xFA,0x00,0x46,0x31,0xBC,0x00,0x02,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,
-0x00,0x56,0x0C,0xA8,0x00,0x00,0x00,0x06,0x00,0x10,0x66,0x00,0x00,0x28,0x35,0x7C,
-0x08,0x00,0x00,0x08,0x23,0x7C,0xDE,0xBB,0x20,0xE3,0x00,0x34,0x42,0xA9,0x00,0x38,
-0x33,0x7C,0x05,0xFC,0x00,0x46,0x31,0xBC,0x00,0x04,0x09,0xB0,0x00,0x00,0x19,0x9C,
-0x60,0x00,0x00,0x24,0x42,0x6A,0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,
-0x23,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x38,0x33,0x7C,0x05,0xF8,0x00,0x46,0x42,0x70,
-0x09,0xB0,0x00,0x00,0x19,0x9C,0x25,0x7C,0x00,0x00,0x00,0x03,0x00,0x04,0x0C,0xA8,
-0x00,0x00,0x00,0x02,0x00,0x14,0x66,0x00,0x00,0x0E,0x25,0x7C,0x10,0x04,0x09,0x00,
-0x00,0x00,0x60,0x00,0x00,0x0A,0x25,0x7C,0x10,0x04,0x00,0x00,0x00,0x00,0x33,0x7C,
-0x05,0xFC,0x00,0x06,0x22,0x00,0xE9,0x89,0x00,0x81,0x00,0x00,0x00,0x01,0x33,0xC1,
-0xFF,0xFC,0x15,0xC0,0x08,0x39,0x00,0x00,0xFF,0xFC,0x15,0xC0,0x66,0x00,0xFF,0xF6,
-0x35,0x7C,0x00,0x1F,0x00,0x14,0x00,0xAA,0x00,0x00,0x00,0x30,0x00,0x00,0x4E,0x75,
-0x20,0x70,0x09,0xB0,0x00,0x00,0x18,0x52,0x42,0x68,0x00,0x14,0x02,0xA8,0xFF,0xFF,
-0xFF,0xCF,0x00,0x00,0x02,0x70,0xEF,0xFF,0x09,0xB0,0x00,0x00,0x19,0xAA,0x61,0x00,
-0x03,0x70,0x22,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x42,0xB0,0x19,0x90,0x4E,0x75,
-0x0C,0xB0,0x00,0x00,0x00,0x0A,0x09,0xB0,0x00,0x00,0x19,0x78,0x67,0x00,0x00,0xA8,
-0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x68,0x24,0x01,0x4C,0x3C,0x20,0x00,0x00,0x00,
-0x00,0x0C,0xD4,0xB0,0x09,0xB0,0x00,0x00,0x10,0x04,0x06,0x82,0x00,0x00,0x00,0x1C,
-0x0C,0xB0,0x00,0x00,0x00,0x10,0x29,0x90,0x66,0x00,0x00,0x7C,0x20,0x70,0x29,0xA0,
-0x00,0x04,0xE7,0x89,0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x72,0x22,0x70,0x19,0xA0,
-0x00,0x04,0x24,0x30,0x29,0xA0,0x00,0x08,0x31,0x82,0x19,0xA0,0x00,0x02,0x56,0x82,
-0x02,0x82,0xFF,0xFF,0xFF,0xFC,0x23,0xC8,0xFF,0xF9,0x01,0x04,0x23,0xC9,0xFF,0xF9,
-0x01,0x08,0x23,0xC2,0xFF,0xF9,0x01,0x0C,0x23,0xFC,0x00,0x00,0x01,0x03,0xFF,0xF9,
-0x01,0x28,0x61,0x00,0x01,0xF6,0x08,0xF0,0x00,0x1F,0x19,0x90,0x22,0x30,0x09,0xB0,
-0x00,0x00,0x19,0x68,0x52,0x81,0x0C,0x81,0x00,0x00,0x00,0x0A,0x66,0x00,0x00,0x04,
-0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,0x19,0x68,0x52,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x78,0x60,0x00,0xFF,0x4C,0x4E,0x75,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x88,
-0xE7,0x89,0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x82,0x34,0x30,0x19,0x90,0x08,0x02,
-0x00,0x0F,0x66,0x00,0x01,0x12,0x08,0x02,0x00,0x01,0x66,0x00,0x00,0xE6,0x4A,0x70,
-0x09,0xB0,0x00,0x00,0x19,0x9C,0x66,0x00,0x00,0x06,0x08,0x82,0x00,0x02,0x02,0x42,
-0x0C,0xBC,0x0C,0x42,0x0C,0x00,0x66,0x00,0x00,0xDC,0x42,0x83,0x36,0x30,0x19,0xA0,
-0x00,0x02,0x96,0x70,0x09,0xB0,0x00,0x00,0x19,0x9C,0x0C,0x43,0x05,0xF8,0x6E,0x00,
-0x00,0xC4,0x24,0x3A,0x04,0x84,0x4C,0x3C,0x20,0x00,0x00,0x00,0x00,0x0C,0xD4,0xBA,
-0xFA,0xF4,0x0C,0xB0,0x00,0x00,0x00,0x00,0x29,0x90,0x66,0x00,0x00,0x96,0x21,0x83,
-0x29,0xA0,0x00,0x08,0x20,0x70,0x19,0xA0,0x00,0x04,0x22,0x70,0x29,0xA0,0x00,0x04,
-0x4A,0x89,0x67,0x00,0x00,0x2A,0x56,0x83,0x02,0x83,0xFF,0xFF,0xFF,0xFC,0x23,0xC8,
-0xFF,0xF9,0x01,0x1C,0x23,0xC9,0xFF,0xF9,0x01,0x18,0x23,0xC3,0xFF,0xF9,0x01,0x20,
-0x23,0xFC,0x00,0x00,0x03,0x01,0xFF,0xF9,0x01,0x28,0x61,0x00,0x01,0x2C,0x21,0xB0,
-0x09,0xB0,0x00,0x00,0x18,0xC2,0x29,0x90,0x08,0xC6,0x00,0x04,0x24,0x3A,0x04,0x1A,
-0x52,0x82,0x0C,0x82,0x00,0x00,0x00,0x28,0x66,0x00,0x00,0x04,0x42,0x82,0x23,0xC2,
-0x00,0x00,0x19,0x98,0x02,0x70,0xF0,0x00,0x19,0x90,0x08,0xF0,0x00,0x1F,0x19,0x90,
-0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x88,0x52,0x81,0x0C,0x81,0x00,0x00,0x00,0x1E,
-0x66,0x00,0x00,0x04,0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,0x19,0x88,0x60,0x00,
-0xFE,0xF8,0x24,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x52,0xB0,0x29,0xA0,0x00,0x08,
-0x60,0x00,0xFF,0xC2,0x24,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x52,0xB0,0x29,0xA0,
-0x00,0x0C,0x60,0x00,0xFF,0xB0,0x4E,0x75,0x4A,0xB0,0x09,0xB0,0x00,0x00,0x19,0x78,
-0x67,0x00,0x00,0x86,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x58,0x24,0x01,0xE7,0x89,
-0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x72,0x36,0x30,0x19,0x90,0x08,0x03,0x00,0x0F,
-0x66,0x00,0x00,0x66,0x8C,0xB0,0x09,0xB0,0x00,0x00,0x18,0xA2,0x53,0xB0,0x09,0xB0,
-0x00,0x00,0x19,0x78,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x58,0x52,0x81,0x0C,0x81,
-0x00,0x00,0x00,0x0A,0x66,0x00,0x00,0x04,0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,
-0x19,0x58,0x4C,0x3C,0x20,0x00,0x00,0x00,0x00,0x0C,0xD4,0xB0,0x09,0xB0,0x00,0x00,
-0x10,0x04,0x06,0x82,0x00,0x00,0x00,0x1C,0x08,0x03,0x00,0x01,0x66,0x00,0x00,0x0E,
-0x21,0xBC,0x00,0x00,0x00,0x20,0x29,0x90,0x60,0x00,0xFF,0x7E,0x21,0xBC,0x00,0x00,
-0x00,0x30,0x29,0x90,0x60,0x00,0xFF,0x72,0x4E,0x75,0x2F,0x00,0x40,0xE7,0x20,0x39,
-0xFF,0xF9,0x01,0x28,0x08,0x00,0x00,0x04,0x66,0x00,0x00,0x2C,0x4E,0x72,0x22,0x00,
-0x46,0xFC,0x27,0x00,0x60,0x00,0xFF,0xE8,0x2F,0x00,0x40,0xE7,0x20,0x39,0xFF,0xF9,
-0x01,0x28,0x08,0x00,0x00,0x0C,0x66,0x00,0x00,0x0E,0x4E,0x72,0x22,0x00,0x46,0xFC,
-0x27,0x00,0x60,0x00,0xFF,0xE8,0x46,0xDF,0x20,0x1F,0x4E,0x75,0x2F,0x00,0x20,0x39,
-0xFF,0xF9,0x00,0xE0,0x23,0xC0,0xFF,0xF9,0x00,0xE0,0x81,0xB9,0x00,0x00,0x19,0x54,
-0x23,0xFC,0x00,0x00,0x09,0x09,0xFF,0xF9,0x01,0x28,0x20,0x1F,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x10,0x00,0xB9,0x00,0x00,0x10,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x40,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x30,0x00,0xB9,0x00,0x00,0x20,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x20,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x50,0x00,0xB9,0x00,0x00,0x40,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x10,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x70,0x00,0xB9,0x00,0x00,0x80,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x08,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x4E,0x73,
-0x2F,0x00,0x2F,0x01,0x2F,0x02,0x2F,0x08,0x2F,0x09,0x42,0x80,0x20,0x7C,0xFF,0xFB,
-0x00,0x00,0x32,0x10,0x02,0x81,0x00,0x00,0x00,0xE7,0x0C,0x41,0x00,0x42,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x0E,0x08,0x60,0x00,0x00,0x3E,0x0C,0x41,0x00,0x63,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x04,0x08,0x60,0x00,0x00,0x2E,0x0C,0x41,0x00,0x84,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x02,0x08,0x60,0x00,0x00,0x1E,0x0C,0x41,0x00,0xA5,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x0D,0x08,0x60,0x00,0x00,0x0E,0x32,0x3C,0x00,0x08,0x34,0x3C,
-0x80,0xE7,0x60,0x00,0x00,0x14,0x34,0x30,0x09,0xB0,0x00,0x00,0x19,0xAA,0x02,0x42,
-0x30,0x00,0x82,0x42,0x34,0x3C,0x80,0xFF,0xB2,0x70,0x09,0xB0,0x00,0x00,0x19,0xAC,
-0x67,0x00,0x00,0x0C,0x31,0x81,0x09,0xB0,0x00,0x00,0x19,0xAC,0x30,0x81,0x32,0x39,
-0xFF,0xFC,0x15,0x66,0xC2,0x70,0x09,0xB0,0x00,0x00,0x19,0x02,0x67,0x00,0x00,0x0C,
-0x32,0x10,0x02,0x41,0xFF,0xF7,0x60,0x00,0x00,0x08,0x32,0x10,0x00,0x41,0x00,0x08,
-0xC2,0x42,0x22,0x70,0x09,0xB0,0x00,0x00,0x10,0x04,0xB2,0xA9,0x00,0x04,0x67,0x00,
-0x00,0x12,0x23,0x41,0x00,0x04,0x23,0xF0,0x09,0xB0,0x00,0x00,0x18,0xB2,0xFF,0xF9,
-0x00,0xE4,0x54,0x88,0x58,0x80,0x0C,0x80,0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0x34,
-0x22,0x5F,0x20,0x5F,0x24,0x1F,0x22,0x1F,0x20,0x1F,0x4E,0x75,0x61,0x00,0xFF,0x12,
-0x4E,0x73,0xFF,0xFC,0x16,0x00,0xFF,0xFC,0x16,0x20,0xFF,0xFC,0x16,0x40,0xFF,0xFC,
-0x16,0x60,0xFF,0xFC,0x0C,0x00,0xFF,0xFC,0x0D,0x00,0xFF,0xFC,0x0E,0x00,0xFF,0xFC,
-0x0F,0x00,0xFF,0xFC,0x00,0x00,0xFF,0xFC,0x01,0x40,0xFF,0xFC,0x02,0x80,0xFF,0xFC,
-0x03,0xC0,0xFF,0xFC,0x00,0x50,0xFF,0xFC,0x01,0x90,0xFF,0xFC,0x02,0xD0,0xFF,0xFC,
-0x04,0x10,0x00,0x00,0x40,0x00,0x00,0x01,0x2F,0x60,0x00,0x02,0x1E,0xC0,0x00,0x03,
-0x0E,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,
-0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x00,0x00,
-0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x12,0x00,0x00,
-0x00,0x13,0x00,0x00,0x00,0x2C,0x00,0x00,0x3E,0x00,0x00,0x2C,0x00,0x00,0x3E,0x00,
-0x00,0x00,0x00,0x00,0x00,0x2D,0x00,0x00,0x3F,0x00,0x00,0x2D,0x00,0x00,0x3F,0x00,
-0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,
-0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x80,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,
-0x77,0x61,0x6E,0x58,0x4C,0x20,0x66,0x69,0x72,0x6D,0x77,0x61,0x72,0x65,0x0A,0x43,
-0x6F,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x43,0x29,0x20,0x32,0x30,0x30,
-0x33,0x20,0x4B,0x72,0x7A,0x79,0x73,0x7A,0x74,0x6F,0x66,0x20,0x48,0x61,0x6C,0x61,
-0x73,0x61,0x20,0x3C,0x6B,0x68,0x63,0x40,0x70,0x6D,0x2E,0x77,0x61,0x77,0x2E,0x70,
-0x6C,0x3E,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-};
index 701a83b..1284d3d 100644 (file)
@@ -164,7 +164,7 @@ pci_find_subsys(unsigned int vendor, unsigned int device,
        struct list_head *n;
        struct pci_dev *dev;
 
-       WARN_ON(in_interrupt());
+       BUG_ON(in_interrupt());
        spin_lock(&pci_bus_lock);
        n = from ? from->global_list.next : pci_devices.next;
 
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
deleted file mode 100644 (file)
index 57b1bca..0000000
+++ /dev/null
@@ -1,746 +0,0 @@
-/*
- * Driver for the Cirrus PD6729 PCI-PCMCIA bridge.
- *
- * Based on the i82092.c driver.
- *
- * This software may be used and distributed according to the terms of
- * the GNU General Public License, incorporated herein by reference.
- */
-
-#include <linux/kernel.h>
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <linux/device.h>
-
-#include <pcmcia/cs_types.h>
-#include <pcmcia/ss.h>
-#include <pcmcia/cs.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-
-#include "pd6729.h"
-#include "i82365.h"
-#include "cirrus.h"
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Driver for the Cirrus PD6729 PCI-PCMCIA bridge");
-MODULE_AUTHOR("Jun Komuro <komurojun@mbn.nifty.com>");
-
-#define MAX_SOCKETS 2
-
-/*
- * simple helper functions
- * External clock time, in nanoseconds.  120 ns = 8.33 MHz
- */
-#define to_cycles(ns)  ((ns)/120)
-
-static spinlock_t port_lock = SPIN_LOCK_UNLOCKED;
-
-/* basic value read/write functions */
-
-static unsigned char indirect_read(struct pd6729_socket *socket, unsigned short reg)
-{
-       unsigned long port;
-       unsigned char val;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port_lock, flags);
-       reg += socket->number * 0x40;
-       port = socket->io_base;
-       outb(reg, port);
-       val = inb(port + 1);
-       spin_unlock_irqrestore(&port_lock, flags);
-
-       return val;
-}
-
-static unsigned short indirect_read16(struct pd6729_socket *socket, unsigned short reg)
-{
-       unsigned long port;
-       unsigned short tmp;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port_lock, flags);
-       reg  = reg + socket->number * 0x40;
-       port = socket->io_base;
-       outb(reg, port);
-       tmp = inb(port + 1);
-       reg++;
-       outb(reg, port);
-       tmp = tmp | (inb(port + 1) << 8);
-       spin_unlock_irqrestore(&port_lock, flags);
-
-       return tmp;
-}
-
-static void indirect_write(struct pd6729_socket *socket, unsigned short reg, unsigned char value)
-{
-       unsigned long port;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port_lock, flags);
-       reg = reg + socket->number * 0x40;
-       port = socket->io_base;
-       outb(reg, port);
-       outb(value, port + 1);
-       spin_unlock_irqrestore(&port_lock, flags);
-}
-
-static void indirect_setbit(struct pd6729_socket *socket, unsigned short reg, unsigned char mask)
-{
-       unsigned long port;
-       unsigned char val;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port_lock, flags);
-       reg = reg + socket->number * 0x40;
-       port = socket->io_base;
-       outb(reg, port);
-       val = inb(port + 1);
-       val |= mask;
-       outb(reg, port);
-       outb(val, port + 1);
-       spin_unlock_irqrestore(&port_lock, flags);
-}
-
-static void indirect_resetbit(struct pd6729_socket *socket, unsigned short reg, unsigned char mask)
-{
-       unsigned long port;
-       unsigned char val;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port_lock, flags);
-       reg = reg + socket->number * 0x40;
-       port = socket->io_base;
-       outb(reg, port);
-       val = inb(port + 1);
-       val &= ~mask;
-       outb(reg, port);
-       outb(val, port + 1);
-       spin_unlock_irqrestore(&port_lock, flags);
-}
-
-static void indirect_write16(struct pd6729_socket *socket, unsigned short reg, unsigned short value)
-{
-       unsigned long port;
-       unsigned char val;
-       unsigned long flags;
-
-       spin_lock_irqsave(&port_lock, flags);
-       reg = reg + socket->number * 0x40;
-       port = socket->io_base;
-
-       outb(reg, port);
-       val = value & 255;
-       outb(val, port + 1);
-
-       reg++;
-
-       outb(reg, port);
-       val = value >> 8;
-       outb(val, port + 1);
-       spin_unlock_irqrestore(&port_lock, flags);
-}
-
-/* Interrupt handler functionality */
-
-static irqreturn_t pd6729_interrupt(int irq, void *dev, struct pt_regs *regs)
-{
-       struct pd6729_socket *socket = (struct pd6729_socket *)dev;
-       int i;
-       int loopcount = 0;
-       int handled = 0;
-       unsigned int events, active = 0;
-
-       while (1) {
-               loopcount++;
-               if (loopcount > 20) {
-                       printk(KERN_ERR "pd6729: infinite eventloop in interrupt\n");
-                       break;
-               }
-
-               active = 0;
-
-               for (i = 0; i < MAX_SOCKETS; i++) {
-                       unsigned int csc;
-
-                       /* card status change register */
-                       csc = indirect_read(&socket[i], I365_CSC);
-                       if (csc == 0)  /* no events on this socket */
-                               continue;
-
-                       handled = 1;
-                       events = 0;
-
-                       if (csc & I365_CSC_DETECT) {
-                               events |= SS_DETECT;
-                               dprintk("Card detected in socket %i!\n", i);
-                       }
-
-                       if (indirect_read(&socket[i], I365_INTCTL) & I365_PC_IOCARD) {
-                               /* For IO/CARDS, bit 0 means "read the card" */
-                               events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0;
-                       } else {
-                               /* Check for battery/ready events */
-                               events |= (csc & I365_CSC_BVD1) ? SS_BATDEAD : 0;
-                               events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0;
-                               events |= (csc & I365_CSC_READY) ? SS_READY : 0;
-                       }
-
-                       if (events) {
-                               pcmcia_parse_events(&socket[i].socket, events);
-                       }
-                       active |= events;
-               }
-
-               if (active == 0) /* no more events to handle */
-                       break;
-       }
-       return IRQ_RETVAL(handled);
-}
-
-/* socket functions */
-
-static void set_bridge_state(struct pd6729_socket *socket)
-{
-       indirect_write(socket, I365_GBLCTL, 0x00);
-       indirect_write(socket, I365_GENCTL, 0x00);
-
-       indirect_setbit(socket, I365_INTCTL, 0x08);
-}
-
-static int pd6729_get_status(struct pcmcia_socket *sock, u_int *value)
-{
-       struct pd6729_socket *socket = container_of(sock, struct pd6729_socket, socket);
-       unsigned int status;
-       unsigned int data;
-       struct pd6729_socket *t;
-
-       /* Interface Status Register */
-       status = indirect_read(socket, I365_STATUS);
-       *value = 0;
-
-       if ((status & I365_CS_DETECT) == I365_CS_DETECT) {
-               *value |= SS_DETECT;
-       }
-
-       /*
-        * IO cards have a different meaning of bits 0,1
-        * Also notice the inverse-logic on the bits
-        */
-       if (indirect_read(socket, I365_INTCTL) & I365_PC_IOCARD) {
-               /* IO card */
-               if (!(status & I365_CS_STSCHG))
-                       *value |= SS_STSCHG;
-       } else {
-               /* non I/O card */
-               if (!(status & I365_CS_BVD1))
-                       *value |= SS_BATDEAD;
-               if (!(status & I365_CS_BVD2))
-                       *value |= SS_BATWARN;
-       }
-
-       if (status & I365_CS_WRPROT)
-               *value |= SS_WRPROT;    /* card is write protected */
-
-       if (status & I365_CS_READY)
-               *value |= SS_READY;     /* card is not busy */
-
-       if (status & I365_CS_POWERON)
-               *value |= SS_POWERON;   /* power is applied to the card */
-
-       t = (socket->number) ? socket : socket + 1;
-       indirect_write(t, PD67_EXT_INDEX, PD67_EXTERN_DATA);
-       data = indirect_read16(t, PD67_EXT_DATA);
-       *value |= (data & PD67_EXD_VS1(socket->number)) ? 0 : SS_3VCARD;
-
-       return 0;
-}
-
-
-static int pd6729_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
-{
-       struct pd6729_socket *socket = container_of(sock, struct pd6729_socket, socket);
-       unsigned char reg, vcc, vpp;
-
-       state->flags    = 0;
-       state->Vcc      = 0;
-       state->Vpp      = 0;
-       state->io_irq   = 0;
-       state->csc_mask = 0;
-
-       /*
-        * First the power status of the socket
-        * PCTRL - Power Control Register
-        */
-       reg = indirect_read(socket, I365_POWER);
-
-       if (reg & I365_PWR_AUTO)
-               state->flags |= SS_PWR_AUTO;  /* Automatic Power Switch */
-
-       if (reg & I365_PWR_OUT)
-               state->flags |= SS_OUTPUT_ENA; /* Output signals are enabled */
-
-       vcc = reg & I365_VCC_MASK;    vpp = reg & I365_VPP1_MASK;
-
-       if (reg & I365_VCC_5V) {
-               state->Vcc = (indirect_read(socket, PD67_MISC_CTL_1) &
-                       PD67_MC1_VCC_3V) ? 33 : 50;
-
-               if (vpp == I365_VPP1_5V) {
-                       if (state->Vcc == 50)
-                               state->Vpp = 50;
-                       else
-                               state->Vpp = 33;
-               }
-               if (vpp == I365_VPP1_12V)
-                       state->Vpp = 120;
-       }
-
-       /*
-        * Now the IO card, RESET flags and IO interrupt
-        * IGENC, Interrupt and General Control
-        */
-       reg = indirect_read(socket, I365_INTCTL);
-
-       if ((reg & I365_PC_RESET) == 0)
-               state->flags |= SS_RESET;
-       if (reg & I365_PC_IOCARD)
-               state->flags |= SS_IOCARD; /* This is an IO card */
-
-       /* Set the IRQ number */
-       state->io_irq = socket->socket.pci_irq;
-
-       /*
-        * Card status change
-        * CSCICR, Card Status Change Interrupt Configuration
-        */
-       reg = indirect_read(socket, I365_CSCINT);
-
-       if (reg & I365_CSC_DETECT)
-               state->csc_mask |= SS_DETECT; /* Card detect is enabled */
-
-       if (state->flags & SS_IOCARD) {/* IO Cards behave different */
-               if (reg & I365_CSC_STSCHG)
-                       state->csc_mask |= SS_STSCHG;
-       } else {
-               if (reg & I365_CSC_BVD1)
-                       state->csc_mask |= SS_BATDEAD;
-               if (reg & I365_CSC_BVD2)
-                       state->csc_mask |= SS_BATWARN;
-               if (reg & I365_CSC_READY)
-                       state->csc_mask |= SS_READY;
-       }
-
-       return 0;
-}
-
-static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
-{
-       struct pd6729_socket *socket = container_of(sock, struct pd6729_socket, socket);
-       unsigned char reg;
-
-       /* First, set the global controller options */
-
-       set_bridge_state(socket);
-
-       /* Values for the IGENC register */
-
-       reg = 0;
-       /* The reset bit has "inverse" logic */
-       if (!(state->flags & SS_RESET))
-               reg = reg | I365_PC_RESET;
-       if (state->flags & SS_IOCARD)
-               reg = reg | I365_PC_IOCARD;
-
-       /* IGENC, Interrupt and General Control Register */
-       indirect_write(socket, I365_INTCTL, reg);
-
-       /* Power registers */
-
-       reg = I365_PWR_NORESET; /* default: disable resetdrv on resume */
-
-       if (state->flags & SS_PWR_AUTO) {
-               dprintk("Auto power\n");
-               reg |= I365_PWR_AUTO;   /* automatic power mngmnt */
-       }
-       if (state->flags & SS_OUTPUT_ENA) {
-               dprintk("Power Enabled\n");
-               reg |= I365_PWR_OUT;    /* enable power */
-       }
-
-       switch (state->Vcc) {
-       case 0:
-               break;
-       case 33:
-               dprintk("setting voltage to Vcc to 3.3V on socket %i\n",
-                       socket->number);
-               reg |= I365_VCC_5V;
-               indirect_setbit(socket, PD67_MISC_CTL_1, PD67_MC1_VCC_3V);
-               break;
-       case 50:
-               dprintk("setting voltage to Vcc to 5V on socket %i\n",
-                       socket->number);
-               reg |= I365_VCC_5V;
-               indirect_resetbit(socket, PD67_MISC_CTL_1, PD67_MC1_VCC_3V);
-               break;
-       default:
-               dprintk("pd6729: pd6729_set_socket called with invalid VCC power value: %i\n",
-                       state->Vcc);
-               return -EINVAL;
-       }
-
-       switch (state->Vpp) {
-       case 0:
-               dprintk("not setting Vpp on socket %i\n", socket->number);
-               break;
-       case 33:
-       case 50:
-               dprintk("setting Vpp to Vcc for socket %i\n", socket->number);
-               reg |= I365_VPP1_5V;
-               break;
-       case 120:
-               dprintk("setting Vpp to 12.0\n");
-               reg |= I365_VPP1_12V;
-               break;
-       default:
-               dprintk("pd6729: pd6729_set_socket called with invalid VPP power value: %i\n",
-                       state->Vpp);
-               return -EINVAL;
-       }
-
-       /* only write if changed */
-       if (reg != indirect_read(socket, I365_POWER))
-               indirect_write(socket, I365_POWER, reg);
-
-       /* Now, specifiy that all interrupts are to be done as PCI interrupts */
-       indirect_write(socket, PD67_EXT_INDEX, PD67_EXT_CTL_1);
-       indirect_write(socket, PD67_EXT_DATA, PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_CARD_IRQ);
-
-       /* Enable specific interrupt events */
-
-       reg = 0x00;
-       if (state->csc_mask & SS_DETECT) {
-               reg |= I365_CSC_DETECT;
-       }
-       if (state->flags & SS_IOCARD) {
-               if (state->csc_mask & SS_STSCHG)
-                       reg |= I365_CSC_STSCHG;
-       } else {
-               if (state->csc_mask & SS_BATDEAD)
-                       reg |= I365_CSC_BVD1;
-               if (state->csc_mask & SS_BATWARN)
-                       reg |= I365_CSC_BVD2;
-               if (state->csc_mask & SS_READY)
-                       reg |= I365_CSC_READY;
-       }
-       reg |= 0x30;    /* management IRQ: PCI INTA# = "irq 3" */
-       indirect_write(socket, I365_CSCINT, reg);
-
-       reg = indirect_read(socket, I365_INTCTL);
-       reg |= 0x03;    /* card IRQ: PCI INTA# = "irq 3" */
-       indirect_write(socket, I365_INTCTL, reg);
-
-       /* now clear the (probably bogus) pending stuff by doing a dummy read */
-       (void)indirect_read(socket, I365_CSC);
-
-       return 0;
-}
-
-static int pd6729_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io)
-{
-       struct pd6729_socket *socket = container_of(sock, struct pd6729_socket, socket);
-       unsigned char map, ioctl;
-
-       map = io->map;
-
-       /* Check error conditions */
-       if (map > 1) {
-               dprintk("pd6729_set_io_map with invalid map");
-               return -EINVAL;
-       }
-
-       /* Turn off the window before changing anything */
-       if (indirect_read(socket, I365_ADDRWIN) & I365_ENA_IO(map))
-               indirect_resetbit(socket, I365_ADDRWIN, I365_ENA_IO(map));
-
-/*     dprintk("set_io_map: Setting range to %x - %x\n", io->start, io->stop);*/
-
-       /* write the new values */
-       indirect_write16(socket, I365_IO(map)+I365_W_START, io->start);
-       indirect_write16(socket, I365_IO(map)+I365_W_STOP, io->stop);
-
-       ioctl = indirect_read(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
-
-       if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map);
-       if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map);
-       if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map);
-
-       indirect_write(socket, I365_IOCTL, ioctl);
-
-       /* Turn the window back on if needed */
-       if (io->flags & MAP_ACTIVE)
-               indirect_setbit(socket, I365_ADDRWIN, I365_ENA_IO(map));
-
-       return 0;
-}
-
-static int pd6729_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *mem)
-{
-       struct pd6729_socket *socket = container_of(sock, struct pd6729_socket, socket);
-       unsigned short base, i;
-       unsigned char map;
-
-       map = mem->map;
-       if (map > 4) {
-               printk("pd6729_set_mem_map: invalid map");
-               return -EINVAL;
-       }
-
-       if ((mem->sys_start > mem->sys_stop) || (mem->speed > 1000)) {
-               printk("pd6729_set_mem_map: invalid address / speed");
-               /* printk("invalid mem map for socket %i : %lx to %lx with a start of %x\n",
-                        sock, mem->sys_start, mem->sys_stop, mem->card_start); */
-               return -EINVAL;
-       }
-
-       /* Turn off the window before changing anything */
-       if (indirect_read(socket, I365_ADDRWIN) & I365_ENA_MEM(map))
-               indirect_resetbit(socket, I365_ADDRWIN, I365_ENA_MEM(map));
-
-       /* write the start address */
-       base = I365_MEM(map);
-       i = (mem->sys_start >> 12) & 0x0fff;
-       if (mem->flags & MAP_16BIT)
-               i |= I365_MEM_16BIT;
-       if (mem->flags & MAP_0WS)
-               i |= I365_MEM_0WS;
-       indirect_write16(socket, base + I365_W_START, i);
-
-       /* write the stop address */
-
-       i= (mem->sys_stop >> 12) & 0x0fff;
-       switch (to_cycles(mem->speed)) {
-       case 0:
-               break;
-       case 1:
-               i |= I365_MEM_WS0;
-               break;
-       case 2:
-               i |= I365_MEM_WS1;
-               break;
-       default:
-               i |= I365_MEM_WS1 | I365_MEM_WS0;
-               break;
-       }
-
-       indirect_write16(socket, base + I365_W_STOP, i);
-
-       /* Take care of high byte */
-       indirect_write(socket, PD67_EXT_INDEX, PD67_MEM_PAGE(map));
-       indirect_write(socket, PD67_EXT_DATA, mem->sys_start >> 24);
-
-       /* card start */
-
-       i = ((mem->card_start - mem->sys_start) >> 12) & 0x3fff;
-       if (mem->flags & MAP_WRPROT)
-               i |= I365_MEM_WRPROT;
-       if (mem->flags & MAP_ATTRIB) {
-/*             dprintk("requesting attribute memory for socket %i\n",
-                       socket->number);*/
-               i |= I365_MEM_REG;
-       } else {
-/*             dprintk("requesting normal memory for socket %i\n",
-                       socket->number);*/
-       }
-       indirect_write16(socket, base + I365_W_OFF, i);
-
-       /* Enable the window if necessary */
-       if (mem->flags & MAP_ACTIVE)
-               indirect_setbit(socket, I365_ADDRWIN, I365_ENA_MEM(map));
-
-       return 0;
-}
-
-static int pd6729_suspend(struct pcmcia_socket *sock)
-{
-       return pd6729_set_socket(sock, &dead_socket);
-}
-
-static int pd6729_init(struct pcmcia_socket *sock)
-{
-       int i;
-       struct resource res = { .end = 0x0fff };
-       pccard_io_map io = { 0, 0, 0, 0, 1 };
-       pccard_mem_map mem = { .res = &res, .sys_stop = 0x0fff };
-
-       pd6729_set_socket(sock, &dead_socket);
-       for (i = 0; i < 2; i++) {
-               io.map = i;
-               pd6729_set_io_map(sock, &io);
-       }
-       for (i = 0; i < 5; i++) {
-               mem.map = i;
-               pd6729_set_mem_map(sock, &mem);
-       }
-
-       return 0;
-}
-
-
-/* the pccard structure and its functions */
-static struct pccard_operations pd6729_operations = {
-       .init                   = pd6729_init,
-       .suspend                = pd6729_suspend,
-       .get_status             = pd6729_get_status,
-       .get_socket             = pd6729_get_socket,
-       .set_socket             = pd6729_set_socket,
-       .set_io_map             = pd6729_set_io_map,
-       .set_mem_map            = pd6729_set_mem_map,
-};
-
-static int __devinit pd6729_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
-{
-       int i, j, ret;
-       char configbyte;
-       struct pd6729_socket *socket;
-
-       socket = kmalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, GFP_KERNEL);
-       if (!socket)
-               return -ENOMEM;
-
-       memset(socket, 0, sizeof(struct pd6729_socket) * MAX_SOCKETS);
-
-       if ((ret = pci_enable_device(dev)))
-               goto err_out_free_mem;
-
-       printk(KERN_INFO "pd6729: Cirrus PD6729 PCI to PCMCIA Bridge at 0x%lx on irq %d\n",
-               pci_resource_start(dev, 0), dev->irq);
-       printk(KERN_INFO "pd6729: configured as a %d socket device.\n", MAX_SOCKETS);
-       /*
-        * Since we have no memory BARs some firmware we may not
-        * have had PCI_COMMAND_MEM enabled, yet the device needs
-        * it.
-        */
-       pci_read_config_byte(dev, PCI_COMMAND, &configbyte);
-       if (!(configbyte & PCI_COMMAND_MEMORY)) {
-               printk(KERN_DEBUG "pd6729: Enabling PCI_COMMAND_MEMORY.\n");
-               configbyte |= PCI_COMMAND_MEMORY;
-               pci_write_config_byte(dev, PCI_COMMAND, configbyte);
-       }
-
-       ret = pci_request_regions(dev, "pd6729");
-       if (ret) {
-               printk(KERN_INFO "pd6729: pci request region failed.\n");
-               goto err_out_disable;
-       }
-
-       for (i = 0; i < MAX_SOCKETS; i++) {
-               socket[i].io_base = pci_resource_start(dev, 0);
-               socket[i].socket.features |= SS_CAP_PCCARD;
-               socket[i].socket.map_size = 0x1000;
-               socket[i].socket.irq_mask = 0;
-               socket[i].socket.pci_irq  = dev->irq;
-               socket[i].socket.owner = THIS_MODULE;
-
-               socket[i].number = i;
-
-               socket[i].socket.ops = &pd6729_operations;
-               socket[i].socket.dev.dev = &dev->dev;
-               socket[i].socket.driver_data = &socket[i];
-       }
-
-       pci_set_drvdata(dev, socket);
-
-       /* Register the interrupt handler */
-       if ((ret = request_irq(dev->irq, pd6729_interrupt, SA_SHIRQ, "pd6729", socket))) {
-               printk(KERN_ERR "pd6729: Failed to register irq %d, aborting\n", dev->irq);
-               goto err_out_free_res;
-       }
-
-       for (i = 0; i < MAX_SOCKETS; i++) {
-               ret = pcmcia_register_socket(&socket[i].socket);
-               if (ret) {
-                       printk(KERN_INFO "pd6729: pcmcia_register_socket failed.\n");
-                       for (j = 0; j < i ; j++)
-                               pcmcia_unregister_socket(&socket[j].socket);
-                       goto err_out_free_res2;
-               }
-       }
-
-       return 0;
-
- err_out_free_res2:
-       free_irq(dev->irq, socket);
- err_out_free_res:
-       pci_release_regions(dev);
- err_out_disable:
-       pci_disable_device(dev);
-
- err_out_free_mem:
-       kfree(socket);
-       return ret;
-}
-
-static void __devexit pd6729_pci_remove(struct pci_dev *dev)
-{
-       int i;
-       struct pd6729_socket *socket = pci_get_drvdata(dev);
-
-       for (i = 0; i < MAX_SOCKETS; i++)
-               pcmcia_unregister_socket(&socket[i].socket);
-
-       free_irq(dev->irq, socket);
-       pci_release_regions(dev);
-       pci_disable_device(dev);
-
-       kfree(socket);
-}
-
-static int pd6729_socket_suspend(struct pci_dev *dev, u32 state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev, state);
-}
-
-static int pd6729_socket_resume(struct pci_dev *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
-
-static struct pci_device_id pd6729_pci_ids[] = {
-       {
-               .vendor         = PCI_VENDOR_ID_CIRRUS,
-               .device         = PCI_DEVICE_ID_CIRRUS_6729,
-               .subvendor      = PCI_ANY_ID,
-               .subdevice      = PCI_ANY_ID,
-       },
-       { }
-};
-MODULE_DEVICE_TABLE(pci, pd6729_pci_ids);
-
-static struct pci_driver pd6729_pci_drv = {
-       .name           = "pd6729",
-       .id_table       = pd6729_pci_ids,
-       .probe          = pd6729_pci_probe,
-       .remove         = __devexit_p(pd6729_pci_remove),
-       .suspend        = pd6729_socket_suspend,
-       .resume         = pd6729_socket_resume,
-};
-
-static int pd6729_module_init(void)
-{
-       return pci_module_init(&pd6729_pci_drv);
-}
-
-static void pd6729_module_exit(void)
-{
-       pci_unregister_driver(&pd6729_pci_drv);
-}
-
-module_init(pd6729_module_init);
-module_exit(pd6729_module_exit);
diff --git a/drivers/pcmcia/sa1100.h b/drivers/pcmcia/sa1100.h
deleted file mode 100644 (file)
index d2defe5..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*======================================================================
-
-    Device driver for the PCMCIA control functionality of StrongARM
-    SA-1100 microprocessors.
-
-    The contents of this file are subject to the Mozilla Public
-    License Version 1.1 (the "License"); you may not use this file
-    except in compliance with the License. You may obtain a copy of
-    the License at http://www.mozilla.org/MPL/
-
-    Software distributed under the License is distributed on an "AS
-    IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-    implied. See the License for the specific language governing
-    rights and limitations under the License.
-
-    The initial developer of the original code is John G. Dorsey
-    <john+@cs.cmu.edu>.  Portions created by John G. Dorsey are
-    Copyright (C) 1999 John G. Dorsey.  All Rights Reserved.
-
-    Alternatively, the contents of this file may be used under the
-    terms of the GNU Public License version 2 (the "GPL"), in which
-    case the provisions of the GPL are applicable instead of the
-    above.  If you wish to allow the use of your version of this file
-    only under the terms of the GPL and not to allow others to use
-    your version of this file under the MPL, indicate your decision
-    by deleting the provisions above and replace them with the notice
-    and other provisions required by the GPL.  If you do not delete
-    the provisions above, a recipient may use your version of this
-    file under either the MPL or the GPL.
-    
-======================================================================*/
-
-#if !defined(_PCMCIA_SA1100_H)
-# define _PCMCIA_SA1100_H
-
-#include <pcmcia/cs_types.h>
-#include <pcmcia/ss.h>
-#include <pcmcia/bulkmem.h>
-#include <pcmcia/cistpl.h>
-#include "cs_internal.h"
-#include "sa1100_generic.h"
-
-/* MECR: Expansion Memory Configuration Register
- * (SA-1100 Developers Manual, p.10-13; SA-1110 Developers Manual, p.10-24)
- *
- * MECR layout is:  
- *
- *   FAST1 BSM1<4:0> BSA1<4:0> BSIO1<4:0> FAST0 BSM0<4:0> BSA0<4:0> BSIO0<4:0>
- *
- * (This layout is actually true only for the SA-1110; the FASTn bits are
- * reserved on the SA-1100.)
- */
-
-#define MECR_SOCKET_0_SHIFT (0)
-#define MECR_SOCKET_1_SHIFT (16)
-
-#define MECR_BS_MASK        (0x1f)
-#define MECR_FAST_MODE_MASK (0x01)
-
-#define MECR_BSIO_SHIFT (0)
-#define MECR_BSA_SHIFT  (5)
-#define MECR_BSM_SHIFT  (10)
-#define MECR_FAST_SHIFT (15)
-
-#define MECR_SET(mecr, sock, shift, mask, bs) \
-((mecr)=((mecr)&~(((mask)<<(shift))<<\
-                  ((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))|\
-        (((bs)<<(shift))<<((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))
-
-#define MECR_GET(mecr, sock, shift, mask) \
-((((mecr)>>(((sock)==0)?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT))>>\
- (shift))&(mask))
-
-#define MECR_BSIO_SET(mecr, sock, bs) \
-MECR_SET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK, (bs))
-
-#define MECR_BSIO_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK)
-
-#define MECR_BSA_SET(mecr, sock, bs) \
-MECR_SET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK, (bs))
-
-#define MECR_BSA_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK)
-
-#define MECR_BSM_SET(mecr, sock, bs) \
-MECR_SET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK, (bs))
-
-#define MECR_BSM_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK)
-
-#define MECR_FAST_SET(mecr, sock, fast) \
-MECR_SET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK, (fast))
-
-#define MECR_FAST_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK)
-
-
-/* This function implements the BS value calculation for setting the MECR
- * using integer arithmetic:
- */
-static inline unsigned int sa1100_pcmcia_mecr_bs(unsigned int pcmcia_cycle_ns,
-                                                unsigned int cpu_clock_khz){
-  unsigned int t = ((pcmcia_cycle_ns * cpu_clock_khz) / 6) - 1000000;
-  return (t / 1000000) + (((t % 1000000) == 0) ? 0 : 1);
-}
-
-/* This function returns the (approxmiate) command assertion period, in
- * nanoseconds, for a given CPU clock frequency and MECR BS value:
- */
-static inline unsigned int sa1100_pcmcia_cmd_time(unsigned int cpu_clock_khz,
-                                                 unsigned int pcmcia_mecr_bs){
-  return (((10000000 * 2) / cpu_clock_khz) * (3 * (pcmcia_mecr_bs + 1))) / 10;
-}
-
-
-/* SA-1100 PCMCIA Memory and I/O timing
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * The SA-1110 Developer's Manual, section 10.2.5, says the following:
- *
- *  "To calculate the recommended BS_xx value for each address space:
- *   divide the command width time (the greater of twIOWR and twIORD,
- *   or the greater of twWE and twOE) by processor cycle time; divide
- *   by 2; divide again by 3 (number of BCLK's per command assertion);
- *   round up to the next whole number; and subtract 1."
- *
- * The PC Card Standard, Release 7, section 4.13.4, says that twIORD
- * has a minimum value of 165ns. Section 4.13.5 says that twIOWR has
- * a minimum value of 165ns, as well. Section 4.7.2 (describing
- * common and attribute memory write timing) says that twWE has a
- * minimum value of 150ns for a 250ns cycle time (for 5V operation;
- * see section 4.7.4), or 300ns for a 600ns cycle time (for 3.3V
- * operation, also section 4.7.4). Section 4.7.3 says that taOE
- * has a maximum value of 150ns for a 300ns cycle time (for 5V
- * operation), or 300ns for a 600ns cycle time (for 3.3V operation).
- *
- * When configuring memory maps, Card Services appears to adopt the policy
- * that a memory access time of "0" means "use the default." The default
- * PCMCIA I/O command width time is 165ns. The default PCMCIA 5V attribute
- * and memory command width time is 150ns; the PCMCIA 3.3V attribute and
- * memory command width time is 300ns.
- */
-#define SA1100_PCMCIA_IO_ACCESS      (165)
-#define SA1100_PCMCIA_5V_MEM_ACCESS  (150)
-#define SA1100_PCMCIA_3V_MEM_ACCESS  (300)
-
-
-/* The socket driver actually works nicely in interrupt-driven form,
- * so the (relatively infrequent) polling is "just to be sure."
- */
-#define SA1100_PCMCIA_POLL_PERIOD    (2*HZ)
-
-struct pcmcia_low_level;
-
-/* I/O pins replacing memory pins
- * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
- *
- * These signals change meaning when going from memory-only to 
- * memory-or-I/O interface:
- */
-#define iostschg bvd1
-#define iospkr   bvd2
-
-#endif  /* !defined(_PCMCIA_SA1100_H) */
diff --git a/drivers/pcmcia/sa11xx_core.c b/drivers/pcmcia/sa11xx_core.c
deleted file mode 100644 (file)
index d7249c0..0000000
+++ /dev/null
@@ -1,971 +0,0 @@
-/*======================================================================
-
-    Device driver for the PCMCIA control functionality of StrongARM
-    SA-1100 microprocessors.
-
-    The contents of this file are subject to the Mozilla Public
-    License Version 1.1 (the "License"); you may not use this file
-    except in compliance with the License. You may obtain a copy of
-    the License at http://www.mozilla.org/MPL/
-
-    Software distributed under the License is distributed on an "AS
-    IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-    implied. See the License for the specific language governing
-    rights and limitations under the License.
-
-    The initial developer of the original code is John G. Dorsey
-    <john+@cs.cmu.edu>.  Portions created by John G. Dorsey are
-    Copyright (C) 1999 John G. Dorsey.  All Rights Reserved.
-
-    Alternatively, the contents of this file may be used under the
-    terms of the GNU Public License version 2 (the "GPL"), in which
-    case the provisions of the GPL are applicable instead of the
-    above.  If you wish to allow the use of your version of this file
-    only under the terms of the GPL and not to allow others to use
-    your version of this file under the MPL, indicate your decision
-    by deleting the provisions above and replace them with the notice
-    and other provisions required by the GPL.  If you do not delete
-    the provisions above, a recipient may use your version of this
-    file under either the MPL or the GPL.
-    
-======================================================================*/
-/*
- * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
- * on the low-level kernel interface.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/config.h>
-#include <linux/cpufreq.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/notifier.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-
-#include "sa11xx_core.h"
-#include "sa1100.h"
-
-#ifdef DEBUG
-static int pc_debug;
-
-module_param(pc_debug, int, 0644);
-
-#define debug(skt, lvl, fmt, arg...) do {                      \
-       if (pc_debug > (lvl))                                   \
-               printk(KERN_DEBUG "skt%u: %s: " fmt,            \
-                      (skt)->nr, __func__ , ## arg);           \
-} while (0)
-
-#else
-#define debug(skt, lvl, fmt, arg...) do { } while (0)
-#endif
-
-#define to_sa1100_socket(x)    container_of(x, struct sa1100_pcmcia_socket, socket)
-
-/*
- * sa1100_pcmcia_default_mecr_timing
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * Calculate MECR clock wait states for given CPU clock
- * speed and command wait state. This function can be over-
- * written by a board specific version.
- *
- * The default is to simply calculate the BS values as specified in
- * the INTEL SA1100 development manual
- * "Expansion Memory (PCMCIA) Configuration Register (MECR)"
- * that's section 10.2.5 in _my_ version of the manual ;)
- */
-static unsigned int
-sa1100_pcmcia_default_mecr_timing(struct sa1100_pcmcia_socket *skt,
-                                 unsigned int cpu_speed,
-                                 unsigned int cmd_time)
-{
-       return sa1100_pcmcia_mecr_bs(cmd_time, cpu_speed);
-}
-
-static unsigned short
-calc_speed(unsigned short *spds, int num, unsigned short dflt)
-{
-       unsigned short speed = 0;
-       int i;
-
-       for (i = 0; i < num; i++)
-               if (speed < spds[i])
-                       speed = spds[i];
-       if (speed == 0)
-               speed = dflt;
-
-       return speed;
-}
-
-/* sa1100_pcmcia_set_mecr()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * set MECR value for socket <sock> based on this sockets
- * io, mem and attribute space access speed.
- * Call board specific BS value calculation to allow boards
- * to tweak the BS values.
- */
-static int
-sa1100_pcmcia_set_mecr(struct sa1100_pcmcia_socket *skt, unsigned int cpu_clock)
-{
-       u32 mecr, old_mecr;
-       unsigned long flags;
-       unsigned short speed;
-       unsigned int bs_io, bs_mem, bs_attr;
-
-       speed = calc_speed(skt->spd_io, MAX_IO_WIN, SA1100_PCMCIA_IO_ACCESS);
-       bs_io = skt->ops->socket_get_timing(skt, cpu_clock, speed);
-
-       speed = calc_speed(skt->spd_mem, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS);
-       bs_mem = skt->ops->socket_get_timing(skt, cpu_clock, speed);
-
-       speed = calc_speed(skt->spd_attr, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS);
-       bs_attr = skt->ops->socket_get_timing(skt, cpu_clock, speed);
-
-       local_irq_save(flags);
-
-       old_mecr = mecr = MECR;
-       MECR_FAST_SET(mecr, skt->nr, 0);
-       MECR_BSIO_SET(mecr, skt->nr, bs_io);
-       MECR_BSA_SET(mecr, skt->nr, bs_attr);
-       MECR_BSM_SET(mecr, skt->nr, bs_mem);
-       if (old_mecr != mecr)
-               MECR = mecr;
-
-       local_irq_restore(flags);
-
-       debug(skt, 2, "FAST %X  BSM %X  BSA %X  BSIO %X\n",
-             MECR_FAST_GET(mecr, skt->nr),
-             MECR_BSM_GET(mecr, skt->nr), MECR_BSA_GET(mecr, skt->nr),
-             MECR_BSIO_GET(mecr, skt->nr));
-
-       return 0;
-}
-
-static unsigned int sa1100_pcmcia_skt_state(struct sa1100_pcmcia_socket *skt)
-{
-       struct pcmcia_state state;
-       unsigned int stat;
-
-       memset(&state, 0, sizeof(struct pcmcia_state));
-
-       skt->ops->socket_state(skt, &state);
-
-       stat = state.detect  ? SS_DETECT : 0;
-       stat |= state.ready  ? SS_READY  : 0;
-       stat |= state.wrprot ? SS_WRPROT : 0;
-       stat |= state.vs_3v  ? SS_3VCARD : 0;
-       stat |= state.vs_Xv  ? SS_XVCARD : 0;
-
-       /* The power status of individual sockets is not available
-        * explicitly from the hardware, so we just remember the state
-        * and regurgitate it upon request:
-        */
-       stat |= skt->cs_state.Vcc ? SS_POWERON : 0;
-
-       if (skt->cs_state.flags & SS_IOCARD)
-               stat |= state.bvd1 ? SS_STSCHG : 0;
-       else {
-               if (state.bvd1 == 0)
-                       stat |= SS_BATDEAD;
-               else if (state.bvd2 == 0)
-                       stat |= SS_BATWARN;
-       }
-       return stat;
-}
-
-/*
- * sa1100_pcmcia_config_skt
- * ^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * Convert PCMCIA socket state to our socket configure structure.
- */
-static int
-sa1100_pcmcia_config_skt(struct sa1100_pcmcia_socket *skt, socket_state_t *state)
-{
-       int ret;
-
-       ret = skt->ops->configure_socket(skt, state);
-       if (ret == 0) {
-               /*
-                * This really needs a better solution.  The IRQ
-                * may or may not be claimed by the driver.
-                */
-               if (skt->irq_state != 1 && state->io_irq) {
-                       skt->irq_state = 1;
-                       set_irq_type(skt->irq, IRQT_FALLING);
-               } else if (skt->irq_state == 1 && state->io_irq == 0) {
-                       skt->irq_state = 0;
-                       set_irq_type(skt->irq, IRQT_NOEDGE);
-               }
-
-               skt->cs_state = *state;
-       }
-
-       if (ret < 0)
-               printk(KERN_ERR "sa1100_pcmcia: unable to configure "
-                      "socket %d\n", skt->nr);
-
-       return ret;
-}
-
-/* sa1100_pcmcia_sock_init()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * (Re-)Initialise the socket, turning on status interrupts
- * and PCMCIA bus.  This must wait for power to stabilise
- * so that the card status signals report correctly.
- *
- * Returns: 0
- */
-static int sa1100_pcmcia_sock_init(struct pcmcia_socket *sock)
-{
-       struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
-       debug(skt, 2, "initializing socket\n");
-
-       skt->ops->socket_init(skt);
-       return 0;
-}
-
-
-/*
- * sa1100_pcmcia_suspend()
- * ^^^^^^^^^^^^^^^^^^^^^^^
- *
- * Remove power on the socket, disable IRQs from the card.
- * Turn off status interrupts, and disable the PCMCIA bus.
- *
- * Returns: 0
- */
-static int sa1100_pcmcia_suspend(struct pcmcia_socket *sock)
-{
-       struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-       int ret;
-
-       debug(skt, 2, "suspending socket\n");
-
-       ret = sa1100_pcmcia_config_skt(skt, &dead_socket);
-       if (ret == 0)
-               skt->ops->socket_suspend(skt);
-
-       return ret;
-}
-
-static spinlock_t status_lock = SPIN_LOCK_UNLOCKED;
-
-/* sa1100_check_status()
- * ^^^^^^^^^^^^^^^^^^^^^
- */
-static void sa1100_check_status(struct sa1100_pcmcia_socket *skt)
-{
-       unsigned int events;
-
-       debug(skt, 4, "entering PCMCIA monitoring thread\n");
-
-       do {
-               unsigned int status;
-               unsigned long flags;
-
-               status = sa1100_pcmcia_skt_state(skt);
-
-               spin_lock_irqsave(&status_lock, flags);
-               events = (status ^ skt->status) & skt->cs_state.csc_mask;
-               skt->status = status;
-               spin_unlock_irqrestore(&status_lock, flags);
-
-               debug(skt, 4, "events: %s%s%s%s%s%s\n",
-                       events == 0         ? "<NONE>"   : "",
-                       events & SS_DETECT  ? "DETECT "  : "",
-                       events & SS_READY   ? "READY "   : "",
-                       events & SS_BATDEAD ? "BATDEAD " : "",
-                       events & SS_BATWARN ? "BATWARN " : "",
-                       events & SS_STSCHG  ? "STSCHG "  : "");
-
-               if (events)
-                       pcmcia_parse_events(&skt->socket, events);
-       } while (events);
-}
-
-/* sa1100_pcmcia_poll_event()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Let's poll for events in addition to IRQs since IRQ only is unreliable...
- */
-static void sa1100_pcmcia_poll_event(unsigned long dummy)
-{
-       struct sa1100_pcmcia_socket *skt = (struct sa1100_pcmcia_socket *)dummy;
-       debug(skt, 4, "polling for events\n");
-
-       mod_timer(&skt->poll_timer, jiffies + SA1100_PCMCIA_POLL_PERIOD);
-
-       sa1100_check_status(skt);
-}
-
-
-/* sa1100_pcmcia_interrupt()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^
- * Service routine for socket driver interrupts (requested by the
- * low-level PCMCIA init() operation via sa1100_pcmcia_thread()).
- * The actual interrupt-servicing work is performed by
- * sa1100_pcmcia_thread(), largely because the Card Services event-
- * handling code performs scheduling operations which cannot be
- * executed from within an interrupt context.
- */
-static irqreturn_t sa1100_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
-{
-       struct sa1100_pcmcia_socket *skt = dev;
-
-       debug(skt, 3, "servicing IRQ %d\n", irq);
-
-       sa1100_check_status(skt);
-
-       return IRQ_HANDLED;
-}
-
-
-/* sa1100_pcmcia_get_status()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the get_status() operation for the in-kernel PCMCIA
- * service (formerly SS_GetStatus in Card Services). Essentially just
- * fills in bits in `status' according to internal driver state or
- * the value of the voltage detect chipselect register.
- *
- * As a debugging note, during card startup, the PCMCIA core issues
- * three set_socket() commands in a row the first with RESET deasserted,
- * the second with RESET asserted, and the last with RESET deasserted
- * again. Following the third set_socket(), a get_status() command will
- * be issued. The kernel is looking for the SS_READY flag (see
- * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
- *
- * Returns: 0
- */
-static int
-sa1100_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status)
-{
-       struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
-       skt->status = sa1100_pcmcia_skt_state(skt);
-       *status = skt->status;
-
-       return 0;
-}
-
-
-/* sa1100_pcmcia_get_socket()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the get_socket() operation for the in-kernel PCMCIA
- * service (formerly SS_GetSocket in Card Services). Not a very 
- * exciting routine.
- *
- * Returns: 0
- */
-static int
-sa1100_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
-{
-  struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
-  debug(skt, 2, "\n");
-
-  *state = skt->cs_state;
-
-  return 0;
-}
-
-/* sa1100_pcmcia_set_socket()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the set_socket() operation for the in-kernel PCMCIA
- * service (formerly SS_SetSocket in Card Services). We more or
- * less punt all of this work and let the kernel handle the details
- * of power configuration, reset, &c. We also record the value of
- * `state' in order to regurgitate it to the PCMCIA core later.
- *
- * Returns: 0
- */
-static int
-sa1100_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
-{
-  struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
-  debug(skt, 2, "mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq %d\n",
-       (state->csc_mask==0)?"<NONE> ":"",
-       (state->csc_mask&SS_DETECT)?"DETECT ":"",
-       (state->csc_mask&SS_READY)?"READY ":"",
-       (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"",
-       (state->csc_mask&SS_BATWARN)?"BATWARN ":"",
-       (state->csc_mask&SS_STSCHG)?"STSCHG ":"",
-       (state->flags==0)?"<NONE> ":"",
-       (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"",
-       (state->flags&SS_IOCARD)?"IOCARD ":"",
-       (state->flags&SS_RESET)?"RESET ":"",
-       (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"",
-       (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"",
-       state->Vcc, state->Vpp, state->io_irq);
-
-  return sa1100_pcmcia_config_skt(skt, state);
-}  /* sa1100_pcmcia_set_socket() */
-
-
-/* sa1100_pcmcia_set_io_map()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the set_io_map() operation for the in-kernel PCMCIA
- * service (formerly SS_SetIOMap in Card Services). We configure
- * the map speed as requested, but override the address ranges
- * supplied by Card Services.
- *
- * Returns: 0 on success, -1 on error
- */
-static int
-sa1100_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map)
-{
-       struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-       unsigned short speed = map->speed;
-
-       debug(skt, 2, "map %u  speed %u start 0x%08x stop 0x%08x\n",
-               map->map, map->speed, map->start, map->stop);
-       debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n",
-               (map->flags==0)?"<NONE>":"",
-               (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
-               (map->flags&MAP_16BIT)?"16BIT ":"",
-               (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
-               (map->flags&MAP_0WS)?"0WS ":"",
-               (map->flags&MAP_WRPROT)?"WRPROT ":"",
-               (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"",
-               (map->flags&MAP_PREFETCH)?"PREFETCH ":"");
-
-       if (map->map >= MAX_IO_WIN) {
-               printk(KERN_ERR "%s(): map (%d) out of range\n", __FUNCTION__,
-                      map->map);
-               return -1;
-       }
-
-       if (map->flags & MAP_ACTIVE) {
-               if (speed == 0)
-                       speed = SA1100_PCMCIA_IO_ACCESS;
-       } else {
-               speed = 0;
-       }
-
-       skt->spd_io[map->map] = speed;
-       sa1100_pcmcia_set_mecr(skt, cpufreq_get(0));
-
-       if (map->stop == 1)
-               map->stop = PAGE_SIZE-1;
-
-       map->stop -= map->start;
-       map->stop += (unsigned long)skt->virt_io;
-       map->start = (unsigned long)skt->virt_io;
-
-       return 0;
-}  /* sa1100_pcmcia_set_io_map() */
-
-
-/* sa1100_pcmcia_set_mem_map()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the set_mem_map() operation for the in-kernel PCMCIA
- * service (formerly SS_SetMemMap in Card Services). We configure
- * the map speed as requested, but override the address ranges
- * supplied by Card Services.
- *
- * Returns: 0 on success, -1 on error
- */
-static int
-sa1100_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
-{
-       struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-       struct resource *res;
-       unsigned short speed = map->speed;
-
-       debug(skt, 2, "map %u speed %u card_start %08x\n",
-               map->map, map->speed, map->card_start);
-       debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n",
-               (map->flags==0)?"<NONE>":"",
-               (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
-               (map->flags&MAP_16BIT)?"16BIT ":"",
-               (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
-               (map->flags&MAP_0WS)?"0WS ":"",
-               (map->flags&MAP_WRPROT)?"WRPROT ":"",
-               (map->flags&MAP_ATTRIB)?"ATTRIB ":"",
-               (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"");
-
-       if (map->map >= MAX_WIN)
-               return -EINVAL;
-
-       if (map->flags & MAP_ACTIVE) {
-               if (speed == 0)
-                       speed = 300;
-       } else {
-               speed = 0;
-       }
-
-       if (map->flags & MAP_ATTRIB) {
-               res = &skt->res_attr;
-               skt->spd_attr[map->map] = speed;
-               skt->spd_mem[map->map] = 0;
-       } else {
-               res = &skt->res_mem;
-               skt->spd_attr[map->map] = 0;
-               skt->spd_mem[map->map] = speed;
-       }
-
-       sa1100_pcmcia_set_mecr(skt, cpufreq_get(0));
-
-       map->sys_stop -= map->sys_start;
-       map->sys_stop += res->start + map->card_start;
-       map->sys_start = res->start + map->card_start;
-
-       return 0;
-}
-
-struct bittbl {
-       unsigned int mask;
-       const char *name;
-};
-
-static struct bittbl status_bits[] = {
-       { SS_WRPROT,            "SS_WRPROT"     },
-       { SS_BATDEAD,           "SS_BATDEAD"    },
-       { SS_BATWARN,           "SS_BATWARN"    },
-       { SS_READY,             "SS_READY"      },
-       { SS_DETECT,            "SS_DETECT"     },
-       { SS_POWERON,           "SS_POWERON"    },
-       { SS_STSCHG,            "SS_STSCHG"     },
-       { SS_3VCARD,            "SS_3VCARD"     },
-       { SS_XVCARD,            "SS_XVCARD"     },
-};
-
-static struct bittbl conf_bits[] = {
-       { SS_PWR_AUTO,          "SS_PWR_AUTO"   },
-       { SS_IOCARD,            "SS_IOCARD"     },
-       { SS_RESET,             "SS_RESET"      },
-       { SS_DMA_MODE,          "SS_DMA_MODE"   },
-       { SS_SPKR_ENA,          "SS_SPKR_ENA"   },
-       { SS_OUTPUT_ENA,        "SS_OUTPUT_ENA" },
-};
-
-static void
-dump_bits(char **p, const char *prefix, unsigned int val, struct bittbl *bits, int sz)
-{
-       char *b = *p;
-       int i;
-
-       b += sprintf(b, "%-9s:", prefix);
-       for (i = 0; i < sz; i++)
-               if (val & bits[i].mask)
-                       b += sprintf(b, " %s", bits[i].name);
-       *b++ = '\n';
-       *p = b;
-}
-
-/* show_status()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the /sys/class/pcmcia_socket/??/status file.
- *
- * Returns: the number of characters added to the buffer
- */
-static ssize_t show_status(struct class_device *class_dev, char *buf)
-{
-       struct sa1100_pcmcia_socket *skt = container_of(class_dev, 
-                               struct sa1100_pcmcia_socket, socket.dev);
-       unsigned int clock = cpufreq_get(0);
-       unsigned long mecr = MECR;
-       char *p = buf;
-
-       p+=sprintf(p, "slot     : %d\n", skt->nr);
-
-       dump_bits(&p, "status", skt->status,
-                 status_bits, ARRAY_SIZE(status_bits));
-       dump_bits(&p, "csc_mask", skt->cs_state.csc_mask,
-                 status_bits, ARRAY_SIZE(status_bits));
-       dump_bits(&p, "cs_flags", skt->cs_state.flags,
-                 conf_bits, ARRAY_SIZE(conf_bits));
-
-       p+=sprintf(p, "Vcc      : %d\n", skt->cs_state.Vcc);
-       p+=sprintf(p, "Vpp      : %d\n", skt->cs_state.Vpp);
-       p+=sprintf(p, "IRQ      : %d (%d)\n", skt->cs_state.io_irq, skt->irq);
-
-       p+=sprintf(p, "I/O      : %u (%u)\n",
-               calc_speed(skt->spd_io, MAX_IO_WIN, SA1100_PCMCIA_IO_ACCESS),
-               sa1100_pcmcia_cmd_time(clock, MECR_BSIO_GET(mecr, skt->nr)));
-
-       p+=sprintf(p, "attribute: %u (%u)\n",
-               calc_speed(skt->spd_attr, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS),
-               sa1100_pcmcia_cmd_time(clock, MECR_BSA_GET(mecr, skt->nr)));
-
-       p+=sprintf(p, "common   : %u (%u)\n",
-               calc_speed(skt->spd_mem, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS),
-               sa1100_pcmcia_cmd_time(clock, MECR_BSM_GET(mecr, skt->nr)));
-
-       return p-buf;
-}
-static CLASS_DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
-
-
-static struct pccard_operations sa11xx_pcmcia_operations = {
-       .init                   = sa1100_pcmcia_sock_init,
-       .suspend                = sa1100_pcmcia_suspend,
-       .get_status             = sa1100_pcmcia_get_status,
-       .get_socket             = sa1100_pcmcia_get_socket,
-       .set_socket             = sa1100_pcmcia_set_socket,
-       .set_io_map             = sa1100_pcmcia_set_io_map,
-       .set_mem_map            = sa1100_pcmcia_set_mem_map,
-};
-
-int sa11xx_request_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
-       int i, res = 0;
-
-       for (i = 0; i < nr; i++) {
-               if (irqs[i].sock != skt->nr)
-                       continue;
-               res = request_irq(irqs[i].irq, sa1100_pcmcia_interrupt,
-                                 SA_INTERRUPT, irqs[i].str, skt);
-               if (res)
-                       break;
-               set_irq_type(irqs[i].irq, IRQT_NOEDGE);
-       }
-
-       if (res) {
-               printk(KERN_ERR "PCMCIA: request for IRQ%d failed (%d)\n",
-                       irqs[i].irq, res);
-
-               while (i--)
-                       if (irqs[i].sock == skt->nr)
-                               free_irq(irqs[i].irq, skt);
-       }
-       return res;
-}
-EXPORT_SYMBOL(sa11xx_request_irqs);
-
-void sa11xx_free_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
-       int i;
-
-       for (i = 0; i < nr; i++)
-               if (irqs[i].sock == skt->nr)
-                       free_irq(irqs[i].irq, skt);
-}
-EXPORT_SYMBOL(sa11xx_free_irqs);
-
-void sa11xx_disable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
-       int i;
-
-       for (i = 0; i < nr; i++)
-               if (irqs[i].sock == skt->nr)
-                       set_irq_type(irqs[i].irq, IRQT_NOEDGE);
-}
-EXPORT_SYMBOL(sa11xx_disable_irqs);
-
-void sa11xx_enable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
-       int i;
-
-       for (i = 0; i < nr; i++)
-               if (irqs[i].sock == skt->nr) {
-                       set_irq_type(irqs[i].irq, IRQT_RISING);
-                       set_irq_type(irqs[i].irq, IRQT_BOTHEDGE);
-               }
-}
-EXPORT_SYMBOL(sa11xx_enable_irqs);
-
-static LIST_HEAD(sa1100_sockets);
-static DECLARE_MUTEX(sa1100_sockets_lock);
-
-static const char *skt_names[] = {
-       "PCMCIA socket 0",
-       "PCMCIA socket 1",
-};
-
-struct skt_dev_info {
-       int nskt;
-       struct sa1100_pcmcia_socket skt[0];
-};
-
-#define SKT_DEV_INFO_SIZE(n) \
-       (sizeof(struct skt_dev_info) + (n)*sizeof(struct sa1100_pcmcia_socket))
-
-int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
-{
-       struct skt_dev_info *sinfo;
-       unsigned int cpu_clock;
-       int ret, i;
-
-       /*
-        * set default MECR calculation if the board specific
-        * code did not specify one...
-        */
-       if (!ops->socket_get_timing)
-               ops->socket_get_timing = sa1100_pcmcia_default_mecr_timing;
-
-       down(&sa1100_sockets_lock);
-
-       sinfo = kmalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
-       if (!sinfo) {
-               ret = -ENOMEM;
-               goto out;
-       }
-
-       memset(sinfo, 0, SKT_DEV_INFO_SIZE(nr));
-       sinfo->nskt = nr;
-
-       cpu_clock = cpufreq_get(0);
-
-       /*
-        * Initialise the per-socket structure.
-        */
-       for (i = 0; i < nr; i++) {
-               struct sa1100_pcmcia_socket *skt = &sinfo->skt[i];
-
-               skt->socket.ops = &sa11xx_pcmcia_operations;
-               skt->socket.owner = ops->owner;
-               skt->socket.dev.dev = dev;
-
-               init_timer(&skt->poll_timer);
-               skt->poll_timer.function = sa1100_pcmcia_poll_event;
-               skt->poll_timer.data = (unsigned long)skt;
-               skt->poll_timer.expires = jiffies + SA1100_PCMCIA_POLL_PERIOD;
-
-               skt->nr         = first + i;
-               skt->irq        = NO_IRQ;
-               skt->dev        = dev;
-               skt->ops        = ops;
-
-               skt->res_skt.start      = _PCMCIA(skt->nr);
-               skt->res_skt.end        = _PCMCIA(skt->nr) + PCMCIASp - 1;
-               skt->res_skt.name       = skt_names[skt->nr];
-               skt->res_skt.flags      = IORESOURCE_MEM;
-
-               ret = request_resource(&iomem_resource, &skt->res_skt);
-               if (ret)
-                       goto out_err_1;
-
-               skt->res_io.start       = _PCMCIAIO(skt->nr);
-               skt->res_io.end         = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
-               skt->res_io.name        = "io";
-               skt->res_io.flags       = IORESOURCE_MEM | IORESOURCE_BUSY;
-
-               ret = request_resource(&skt->res_skt, &skt->res_io);
-               if (ret)
-                       goto out_err_2;
-
-               skt->res_mem.start      = _PCMCIAMem(skt->nr);
-               skt->res_mem.end        = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
-               skt->res_mem.name       = "memory";
-               skt->res_mem.flags      = IORESOURCE_MEM;
-
-               ret = request_resource(&skt->res_skt, &skt->res_mem);
-               if (ret)
-                       goto out_err_3;
-
-               skt->res_attr.start     = _PCMCIAAttr(skt->nr);
-               skt->res_attr.end       = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
-               skt->res_attr.name      = "attribute";
-               skt->res_attr.flags     = IORESOURCE_MEM;
-               
-               ret = request_resource(&skt->res_skt, &skt->res_attr);
-               if (ret)
-                       goto out_err_4;
-
-               skt->virt_io = ioremap(skt->res_io.start, 0x10000);
-               if (skt->virt_io == NULL) {
-                       ret = -ENOMEM;
-                       goto out_err_5;
-               }
-
-               list_add(&skt->node, &sa1100_sockets);
-
-               /*
-                * We initialize the MECR to default values here, because
-                * we are not guaranteed to see a SetIOMap operation at
-                * runtime.
-                */
-               sa1100_pcmcia_set_mecr(skt, cpu_clock);
-
-               ret = ops->hw_init(skt);
-               if (ret)
-                       goto out_err_6;
-
-               skt->socket.features = SS_CAP_STATIC_MAP|SS_CAP_PCCARD;
-               skt->socket.irq_mask = 0;
-               skt->socket.map_size = PAGE_SIZE;
-               skt->socket.pci_irq = skt->irq;
-               skt->socket.io_offset = (unsigned long)skt->virt_io;
-
-               skt->status = sa1100_pcmcia_skt_state(skt);
-
-               ret = pcmcia_register_socket(&skt->socket);
-               if (ret)
-                       goto out_err_7;
-
-               WARN_ON(skt->socket.sock != i);
-
-               add_timer(&skt->poll_timer);
-
-               class_device_create_file(&skt->socket.dev, &class_device_attr_status);
-       }
-
-       dev_set_drvdata(dev, sinfo);
-       ret = 0;
-       goto out;
-
-       do {
-               struct sa1100_pcmcia_socket *skt = &sinfo->skt[i];
-
-               del_timer_sync(&skt->poll_timer);
-               pcmcia_unregister_socket(&skt->socket);
-
- out_err_7:
-               flush_scheduled_work();
-
-               ops->hw_shutdown(skt);
- out_err_6:
-               list_del(&skt->node);
-               iounmap(skt->virt_io);
- out_err_5:
-               release_resource(&skt->res_attr);
- out_err_4:
-               release_resource(&skt->res_mem);
- out_err_3:
-               release_resource(&skt->res_io);
- out_err_2:
-               release_resource(&skt->res_skt);
- out_err_1:
-               i--;
-       } while (i > 0);
-
-       kfree(sinfo);
-
- out:
-       up(&sa1100_sockets_lock);
-       return ret;
-}
-EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe);
-
-int sa11xx_drv_pcmcia_remove(struct device *dev)
-{
-       struct skt_dev_info *sinfo = dev_get_drvdata(dev);
-       int i;
-
-       dev_set_drvdata(dev, NULL);
-
-       down(&sa1100_sockets_lock);
-       for (i = 0; i < sinfo->nskt; i++) {
-               struct sa1100_pcmcia_socket *skt = &sinfo->skt[i];
-
-               del_timer_sync(&skt->poll_timer);
-
-               pcmcia_unregister_socket(&skt->socket);
-
-               flush_scheduled_work();
-
-               skt->ops->hw_shutdown(skt);
-
-               sa1100_pcmcia_config_skt(skt, &dead_socket);
-
-               list_del(&skt->node);
-               iounmap(skt->virt_io);
-               skt->virt_io = NULL;
-               release_resource(&skt->res_attr);
-               release_resource(&skt->res_mem);
-               release_resource(&skt->res_io);
-               release_resource(&skt->res_skt);
-       }
-       up(&sa1100_sockets_lock);
-
-       kfree(sinfo);
-
-       return 0;
-}
-EXPORT_SYMBOL(sa11xx_drv_pcmcia_remove);
-
-#ifdef CONFIG_CPU_FREQ
-
-/* sa1100_pcmcia_update_mecr()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * When sa1100_pcmcia_notifier() decides that a MECR adjustment (due
- * to a core clock frequency change) is needed, this routine establishes
- * new BS_xx values consistent with the clock speed `clock'.
- */
-static void sa1100_pcmcia_update_mecr(unsigned int clock)
-{
-       struct sa1100_pcmcia_socket *skt;
-
-       down(&sa1100_sockets_lock);
-       list_for_each_entry(skt, &sa1100_sockets, node)
-               sa1100_pcmcia_set_mecr(skt, clock);
-       up(&sa1100_sockets_lock);
-}
-
-/* sa1100_pcmcia_notifier()
- * ^^^^^^^^^^^^^^^^^^^^^^^^
- * When changing the processor core clock frequency, it is necessary
- * to adjust the MECR timings accordingly. We've recorded the timings
- * requested by Card Services, so this is just a matter of finding
- * out what our current speed is, and then recomputing the new MECR
- * values.
- *
- * Returns: 0 on success, -1 on error
- */
-static int
-sa1100_pcmcia_notifier(struct notifier_block *nb, unsigned long val,
-                      void *data)
-{
-       struct cpufreq_freqs *freqs = data;
-
-       switch (val) {
-       case CPUFREQ_PRECHANGE:
-               if (freqs->new > freqs->old)
-                       sa1100_pcmcia_update_mecr(freqs->new);
-               break;
-
-       case CPUFREQ_POSTCHANGE:
-               if (freqs->new < freqs->old)
-                       sa1100_pcmcia_update_mecr(freqs->new);
-               break;
-       }
-
-       return 0;
-}
-
-static struct notifier_block sa1100_pcmcia_notifier_block = {
-       .notifier_call  = sa1100_pcmcia_notifier
-};
-
-static int __init sa11xx_pcmcia_init(void)
-{
-       int ret;
-
-       printk(KERN_INFO "SA11xx PCMCIA\n");
-
-       ret = cpufreq_register_notifier(&sa1100_pcmcia_notifier_block,
-                                       CPUFREQ_TRANSITION_NOTIFIER);
-       if (ret < 0)
-               printk(KERN_ERR "Unable to register CPU frequency change "
-                       "notifier (%d)\n", ret);
-
-       return ret;
-}
-module_init(sa11xx_pcmcia_init);
-
-static void __exit sa11xx_pcmcia_exit(void)
-{
-       cpufreq_unregister_notifier(&sa1100_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
-}
-
-module_exit(sa11xx_pcmcia_exit);
-#endif
-
-MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
-MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11xx core socket driver");
-MODULE_LICENSE("Dual MPL/GPL");
diff --git a/drivers/pcmcia/sa11xx_core.h b/drivers/pcmcia/sa11xx_core.h
deleted file mode 100644 (file)
index aadf7c0..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * linux/include/asm/arch/pcmcia.h
- *
- * Copyright (C) 2000 John G Dorsey <john+@cs.cmu.edu>
- *
- * This file contains definitions for the low-level SA-1100 kernel PCMCIA
- * interface. Please see linux/Documentation/arm/SA1100/PCMCIA for details.
- */
-#ifndef _ASM_ARCH_PCMCIA
-#define _ASM_ARCH_PCMCIA
-
-/* include the world */
-#include <pcmcia/version.h>
-#include <pcmcia/cs_types.h>
-#include <pcmcia/cs.h>
-#include <pcmcia/ss.h>
-#include <pcmcia/bulkmem.h>
-#include <pcmcia/cistpl.h>
-#include "cs_internal.h"
-
-struct device;
-
-/* Ideally, we'd support up to MAX_SOCK sockets, but the SA-1100 only
- * has support for two. This shows up in lots of hardwired ways, such
- * as the fact that MECR only has enough bits to configure two sockets.
- * Since it's so entrenched in the hardware, limiting the software
- * in this way doesn't seem too terrible.
- */
-#define SA1100_PCMCIA_MAX_SOCK   (2)
-
-struct pcmcia_state {
-  unsigned detect: 1,
-            ready: 1,
-             bvd1: 1,
-             bvd2: 1,
-           wrprot: 1,
-            vs_3v: 1,
-            vs_Xv: 1;
-};
-
-/*
- * This structure encapsulates per-socket state which we might need to
- * use when responding to a Card Services query of some kind.
- */
-struct sa1100_pcmcia_socket {
-       struct pcmcia_socket    socket;
-
-       /*
-        * Info from low level handler
-        */
-       struct device           *dev;
-       unsigned int            nr;
-       unsigned int            irq;
-
-       /*
-        * Core PCMCIA state
-        */
-       struct pcmcia_low_level *ops;
-
-       unsigned int            status;
-       socket_state_t          cs_state;
-
-       unsigned short          spd_io[MAX_IO_WIN];
-       unsigned short          spd_mem[MAX_WIN];
-       unsigned short          spd_attr[MAX_WIN];
-
-       struct resource         res_skt;
-       struct resource         res_io;
-       struct resource         res_mem;
-       struct resource         res_attr;
-       void                    *virt_io;
-
-       unsigned int            irq_state;
-
-       struct timer_list       poll_timer;
-       struct list_head        node;
-};
-
-struct pcmcia_low_level {
-       struct module *owner;
-
-       int (*hw_init)(struct sa1100_pcmcia_socket *);
-       void (*hw_shutdown)(struct sa1100_pcmcia_socket *);
-
-       void (*socket_state)(struct sa1100_pcmcia_socket *, struct pcmcia_state *);
-       int (*configure_socket)(struct sa1100_pcmcia_socket *, const socket_state_t *);
-
-       /*
-        * Enable card status IRQs on (re-)initialisation.  This can
-        * be called at initialisation, power management event, or
-        * pcmcia event.
-        */
-       void (*socket_init)(struct sa1100_pcmcia_socket *);
-
-       /*
-        * Disable card status IRQs and PCMCIA bus on suspend.
-        */
-       void (*socket_suspend)(struct sa1100_pcmcia_socket *);
-
-       /*
-        * Calculate MECR timing clock wait states
-        */
-       unsigned int (*socket_get_timing)(struct sa1100_pcmcia_socket *,
-                       unsigned int cpu_speed, unsigned int cmd_time);
-};
-
-struct pcmcia_irqs {
-       int sock;
-       int irq;
-       const char *str;
-};
-
-int sa11xx_request_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-void sa11xx_free_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-void sa11xx_disable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-void sa11xx_enable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-
-extern int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr);
-extern int sa11xx_drv_pcmcia_remove(struct device *dev);
-
-#endif
index e190f21..bf4e08f 100644 (file)
@@ -37,20 +37,6 @@ config UNIX98_PTYS
          Read the instructions in <file:Documentation/Changes> pertaining to
          pseudo terminals. It's safe to say N.
 
-config UNIX98_PTY_COUNT
-       int "Maximum number of Unix98 PTYs in use (0-2048)"
-       depends on UNIX98_PTYS
-       default "256"
-       help
-         The maximum number of Unix98 PTYs that can be used at any one time.
-         The default is 256, and should be enough for desktop systems. Server
-         machines which support incoming telnet/rlogin/ssh connections and/or
-         serve several X terminals may want to increase this: every incoming
-         connection and every xterm uses up one PTY.
-
-         When not in use, each additional set of 256 PTYs occupy
-         approximately 8 KB of kernel memory on 32-bit architectures.
-
 comment "S/390 character device drivers"
 
 config TN3270
index bc768b6..f35bf04 100644 (file)
@@ -1352,7 +1352,7 @@ next:
 
        }
        kfree(irq_ptr->qdr);
-       kfree(irq_ptr);
+       kfree(irq_ptr->actual_alloc);   /* This frees irq_ptr itself. */
 }
 
 static void
@@ -2585,6 +2585,8 @@ qdio_initialize(struct qdio_initialize *init_data)
 int
 qdio_allocate(struct qdio_initialize *init_data)
 {
+       char *mem;
+       unsigned off;
        struct qdio_irq *irq_ptr;
        char dbf_text[15];
 
@@ -2606,17 +2608,21 @@ qdio_allocate(struct qdio_initialize *init_data)
        qdio_allocate_do_dbf(init_data);
 
        /* create irq */
-       irq_ptr=kmalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA);
+       mem = kmalloc(sizeof(struct qdio_irq) + 0xff, GFP_KERNEL | GFP_DMA);
 
        QDIO_DBF_TEXT0(0,setup,"irq_ptr:");
        QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*));
 
-       if (!irq_ptr) {
+       if (!mem) {
                QDIO_PRINT_ERR("kmalloc of irq_ptr failed!\n");
                return -ENOMEM;
        }
 
+       irq_ptr = (struct qdio_irq *) mem;
+       if ((off = ((unsigned long) mem) & 0xff) != 0)
+               irq_ptr = (struct qdio_irq *)(mem + 0x100 - off);
        memset(irq_ptr,0,sizeof(struct qdio_irq));
+       irq_ptr->actual_alloc = mem;
 
        init_MUTEX(&irq_ptr->setting_up_sema);
 
index 9ad14db..fe85c6f 100644 (file)
@@ -644,5 +644,7 @@ struct qdio_irq {
        struct qdio_q *input_qs[QDIO_MAX_QUEUES_PER_IRQ];
        struct qdio_q *output_qs[QDIO_MAX_QUEUES_PER_IRQ];
        struct semaphore setting_up_sema;
+
+       char *actual_alloc;
 };
 #endif
diff --git a/drivers/s390/cio/requestirq.c b/drivers/s390/cio/requestirq.c
deleted file mode 100644 (file)
index 0ce71a2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  drivers/s390/cio/requestirq.c
- *   S/390 common I/O routines -- enabling and disabling of devices
- *   $Revision: 1.46 $
- *
- *    Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
- *                           IBM Corporation
- *    Author(s): Ingo Adlung (adlung@de.ibm.com)
- *              Cornelia Huck (cohuck@de.ibm.com)
- *              Arnd Bergmann (arndb@de.ibm.com)
- */
-
-#include <linux/module.h>
-#include <linux/config.h>
-#include <linux/device.h>
-#include <linux/init.h>
-#include <asm/lowcore.h>
-
-#include "css.h"
-
-struct pgid global_pgid;
-EXPORT_SYMBOL_GPL(global_pgid);
-
-/*
- * init_IRQ is now only used to set the pgid as early as possible
- */
-void __init
-init_IRQ(void)
-{
-       /*
-        * Let's build our path group ID here.
-        */
-       if (MACHINE_NEW_STIDP)
-               global_pgid.cpu_addr = 0x8000;
-       else {
-#ifdef CONFIG_SMP
-               global_pgid.cpu_addr = hard_smp_processor_id();
-#else
-               global_pgid.cpu_addr = 0;
-#endif
-       }
-       global_pgid.cpu_id = ((cpuid_t *) __LC_CPUID)->ident;
-       global_pgid.cpu_model = ((cpuid_t *) __LC_CPUID)->machine;
-       global_pgid.tod_high = (__u32) (get_clock() >> 32);
-}
diff --git a/drivers/s390/net/ctcdbug.c b/drivers/s390/net/ctcdbug.c
deleted file mode 100644 (file)
index 2c86bfa..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *
- * linux/drivers/s390/net/ctcdbug.c ($Revision: 1.4 $)
- *
- * CTC / ESCON network driver - s390 dbf exploit.
- *
- * Copyright 2000,2003 IBM Corporation
- *
- *    Author(s): Original Code written by
- *                       Peter Tiedemann (ptiedem@de.ibm.com)
- *
- *    $Revision: 1.4 $  $Date: 2004/08/04 10:11:59 $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "ctcdbug.h"
-
-/**
- * Debug Facility Stuff
- */
-debug_info_t *ctc_dbf_setup = NULL;
-debug_info_t *ctc_dbf_data = NULL;
-debug_info_t *ctc_dbf_trace = NULL;
-
-DEFINE_PER_CPU(char[256], ctc_dbf_txt_buf);
-
-void
-ctc_unregister_dbf_views(void)
-{
-       if (ctc_dbf_setup)
-               debug_unregister(ctc_dbf_setup);
-       if (ctc_dbf_data)
-               debug_unregister(ctc_dbf_data);
-       if (ctc_dbf_trace)
-               debug_unregister(ctc_dbf_trace);
-}
-int
-ctc_register_dbf_views(void)
-{
-       ctc_dbf_setup = debug_register(CTC_DBF_SETUP_NAME,
-                                       CTC_DBF_SETUP_INDEX,
-                                       CTC_DBF_SETUP_NR_AREAS,
-                                       CTC_DBF_SETUP_LEN);
-       ctc_dbf_data = debug_register(CTC_DBF_DATA_NAME,
-                                      CTC_DBF_DATA_INDEX,
-                                      CTC_DBF_DATA_NR_AREAS,
-                                      CTC_DBF_DATA_LEN);
-       ctc_dbf_trace = debug_register(CTC_DBF_TRACE_NAME,
-                                       CTC_DBF_TRACE_INDEX,
-                                       CTC_DBF_TRACE_NR_AREAS,
-                                       CTC_DBF_TRACE_LEN);
-
-       if ((ctc_dbf_setup == NULL) || (ctc_dbf_data == NULL) ||
-           (ctc_dbf_trace == NULL)) {
-               ctc_unregister_dbf_views();
-               return -ENOMEM;
-       }
-       debug_register_view(ctc_dbf_setup, &debug_hex_ascii_view);
-       debug_set_level(ctc_dbf_setup, CTC_DBF_SETUP_LEVEL);
-
-       debug_register_view(ctc_dbf_data, &debug_hex_ascii_view);
-       debug_set_level(ctc_dbf_data, CTC_DBF_DATA_LEVEL);
-
-       debug_register_view(ctc_dbf_trace, &debug_hex_ascii_view);
-       debug_set_level(ctc_dbf_trace, CTC_DBF_TRACE_LEVEL);
-
-       return 0;
-}
-
-
diff --git a/drivers/s390/net/ctcdbug.h b/drivers/s390/net/ctcdbug.h
deleted file mode 100644 (file)
index 5c0fcfc..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- *
- * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.3 $)
- *
- * CTC / ESCON network driver - s390 dbf exploit.
- *
- * Copyright 2000,2003 IBM Corporation
- *
- *    Author(s): Original Code written by
- *                       Peter Tiedemann (ptiedem@de.ibm.com)
- *
- *    $Revision: 1.3 $  $Date: 2004/07/28 12:27:54 $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#include <asm/debug.h>
-/**
- * Debug Facility stuff
- */
-#define CTC_DBF_SETUP_NAME "ctc_setup"
-#define CTC_DBF_SETUP_LEN 16
-#define CTC_DBF_SETUP_INDEX 3
-#define CTC_DBF_SETUP_NR_AREAS 1
-#define CTC_DBF_SETUP_LEVEL 3
-
-#define CTC_DBF_DATA_NAME "ctc_data"
-#define CTC_DBF_DATA_LEN 128
-#define CTC_DBF_DATA_INDEX 3
-#define CTC_DBF_DATA_NR_AREAS 1
-#define CTC_DBF_DATA_LEVEL 2
-
-#define CTC_DBF_TRACE_NAME "ctc_trace"
-#define CTC_DBF_TRACE_LEN 16
-#define CTC_DBF_TRACE_INDEX 2
-#define CTC_DBF_TRACE_NR_AREAS 2
-#define CTC_DBF_TRACE_LEVEL 3
-
-#define DBF_TEXT(name,level,text) \
-       do { \
-               debug_text_event(ctc_dbf_##name,level,text); \
-       } while (0)
-
-#define DBF_HEX(name,level,addr,len) \
-       do { \
-               debug_event(ctc_dbf_##name,level,(void*)(addr),len); \
-       } while (0)
-
-extern DEFINE_PER_CPU(char[256], ctc_dbf_txt_buf);
-extern debug_info_t *ctc_dbf_setup;
-extern debug_info_t *ctc_dbf_data;
-extern debug_info_t *ctc_dbf_trace;
-
-
-#define DBF_TEXT_(name,level,text...)                          \
-       do {                                                            \
-               char* ctc_dbf_txt_buf = get_cpu_var(ctc_dbf_txt_buf);   \
-               sprintf(ctc_dbf_txt_buf, text);                         \
-               debug_text_event(ctc_dbf_##name,level,ctc_dbf_txt_buf); \
-               put_cpu_var(ctc_dbf_txt_buf);                           \
-       } while (0)
-
-#define DBF_SPRINTF(name,level,text...) \
-       do { \
-               debug_sprintf_event(ctc_dbf_trace, level, ##text ); \
-               debug_sprintf_event(ctc_dbf_trace, level, text ); \
-       } while (0)
-
-
-int ctc_register_dbf_views(void);
-
-void ctc_unregister_dbf_views(void);
-
-/**
- * some more debug stuff
- */
-
-#define HEXDUMP16(importance,header,ptr) \
-PRINT_##importance(header "%02x %02x %02x %02x  %02x %02x %02x %02x  " \
-                  "%02x %02x %02x %02x  %02x %02x %02x %02x\n", \
-                  *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
-                  *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
-                  *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
-                  *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
-                  *(((char*)ptr)+12),*(((char*)ptr)+13), \
-                  *(((char*)ptr)+14),*(((char*)ptr)+15)); \
-PRINT_##importance(header "%02x %02x %02x %02x  %02x %02x %02x %02x  " \
-                  "%02x %02x %02x %02x  %02x %02x %02x %02x\n", \
-                  *(((char*)ptr)+16),*(((char*)ptr)+17), \
-                  *(((char*)ptr)+18),*(((char*)ptr)+19), \
-                  *(((char*)ptr)+20),*(((char*)ptr)+21), \
-                  *(((char*)ptr)+22),*(((char*)ptr)+23), \
-                  *(((char*)ptr)+24),*(((char*)ptr)+25), \
-                  *(((char*)ptr)+26),*(((char*)ptr)+27), \
-                  *(((char*)ptr)+28),*(((char*)ptr)+29), \
-                  *(((char*)ptr)+30),*(((char*)ptr)+31));
-
-static inline void
-hex_dump(unsigned char *buf, size_t len)
-{
-       size_t i;
-
-       for (i = 0; i < len; i++) {
-               if (i && !(i % 16))
-                       printk("\n");
-               printk("%02x ", *(buf + i));
-       }
-       printk("\n");
-}
-
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
deleted file mode 100644 (file)
index 2bac40c..0000000
+++ /dev/null
@@ -1,2154 +0,0 @@
-/*
-   3w-9xxx.c -- 3ware 9000 Storage Controller device driver for Linux.
-
-   Written By: Adam Radford <linuxraid@amcc.com>
-
-   Copyright (C) 2004 Applied Micro Circuits Corporation.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   NO WARRANTY
-   THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
-   CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
-   LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
-   solely responsible for determining the appropriateness of using and
-   distributing the Program and assumes all risks associated with its
-   exercise of rights under this Agreement, including but not limited to
-   the risks and costs of program errors, damage to or loss of data,
-   programs or equipment, and unavailability or interruption of operations.
-
-   DISCLAIMER OF LIABILITY
-   NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-   DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-   TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-   USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
-   HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-   Bugs/Comments/Suggestions should be mailed to:
-   linuxraid@amcc.com
-
-   For more information, goto:
-   http://www.amcc.com
-
-   Note: This version of the driver does not contain a bundled firmware
-         image.
-
-   History
-   -------
-   2.26.02.000 - Driver cleanup for kernel submission.
-   2.26.02.001 - Replace schedule_timeout() calls with msleep().
-*/
-
-#include <linux/module.h>
-#include <linux/reboot.h>
-#include <linux/spinlock.h>
-#include <linux/interrupt.h>
-#include <linux/moduleparam.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/time.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_tcq.h>
-#include <scsi/scsi_cmnd.h>
-#include "3w-9xxx.h"
-
-/* Globals */
-static const char *twa_driver_version="2.26.02.001";
-static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
-static unsigned int twa_device_extension_count;
-static int twa_major = -1;
-extern struct timezone sys_tz;
-
-/* Module parameters */
-MODULE_AUTHOR ("AMCC");
-MODULE_DESCRIPTION ("3ware 9000 Storage Controller Linux Driver");
-MODULE_LICENSE("GPL");
-
-/* Function prototypes */
-static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header);
-static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
-static char *twa_aen_severity_lookup(unsigned char severity_code);
-static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id);
-static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
-static int twa_chrdev_open(struct inode *inode, struct file *file);
-static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host);
-static void twa_free_request_id(TW_Device_Extension *tw_dev,int request_id);
-static void twa_get_request_id(TW_Device_Extension *tw_dev, int *request_id);
-static int twa_initconnection(TW_Device_Extension *tw_dev, int message_credits,
-                             u32 set_features, unsigned short current_fw_srl, 
-                             unsigned short current_fw_arch_id, 
-                             unsigned short current_fw_branch, 
-                             unsigned short current_fw_build, 
-                             unsigned short *fw_on_ctlr_srl, 
-                             unsigned short *fw_on_ctlr_arch_id, 
-                             unsigned short *fw_on_ctlr_branch, 
-                             unsigned short *fw_on_ctlr_build, 
-                             u32 *init_connect_result);
-static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length);
-static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds);
-static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds);
-static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal);
-static int twa_reset_device_extension(TW_Device_Extension *tw_dev);
-static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset);
-static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Apache *sglistarg);
-static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id);
-static char *twa_string_lookup(twa_message_type *table, unsigned int aen_code);
-static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id);
-
-/* Functions */
-
-/* Show some statistics about the card */
-static ssize_t twa_show_stats(struct class_device *class_dev, char *buf)
-{
-       struct Scsi_Host *host = class_to_shost(class_dev);
-       TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
-       unsigned long flags = 0;
-       ssize_t len;
-
-       spin_lock_irqsave(tw_dev->host->host_lock, flags);
-       len = snprintf(buf, PAGE_SIZE, "Driver version: %s\n"
-                      "Current commands posted:   %4d\n"
-                      "Max commands posted:       %4d\n"
-                      "Current pending commands:  %4d\n"
-                      "Max pending commands:      %4d\n"
-                      "Last sgl length:           %4d\n"
-                      "Max sgl length:            %4d\n"
-                      "Last sector count:         %4d\n"
-                      "Max sector count:          %4d\n"
-                      "SCSI Host Resets:          %4d\n"
-                      "SCSI Aborts/Timeouts:      %4d\n"
-                      "AEN's:                     %4d\n", 
-                      twa_driver_version,
-                      tw_dev->posted_request_count,
-                      tw_dev->max_posted_request_count,
-                      tw_dev->pending_request_count,
-                      tw_dev->max_pending_request_count,
-                      tw_dev->sgl_entries,
-                      tw_dev->max_sgl_entries,
-                      tw_dev->sector_count,
-                      tw_dev->max_sector_count,
-                      tw_dev->num_resets,
-                      tw_dev->num_aborts,
-                      tw_dev->aen_count);
-       spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
-       return len;
-} /* End twa_show_stats() */
-
-/* This function will set a devices queue depth */
-static ssize_t twa_store_queue_depth(struct device *dev, const char *buf, size_t count)
-{
-       int queue_depth;
-       struct scsi_device *sdev = to_scsi_device(dev);
-
-       queue_depth = simple_strtoul(buf, NULL, 0);
-       if (queue_depth > TW_Q_LENGTH-2)
-               return -EINVAL;
-       scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);
-
-       return count;
-} /* End twa_store_queue_depth() */
-
-/* Create sysfs 'queue_depth' entry */
-static struct device_attribute twa_queue_depth_attr = {
-       .attr = {
-               .name =         "queue_depth",
-               .mode =         S_IRUSR | S_IWUSR,
-       },
-       .store = twa_store_queue_depth
-};
-
-/* Device attributes initializer */
-static struct device_attribute *twa_dev_attrs[] = {
-       &twa_queue_depth_attr,
-       NULL,
-};
-
-/* Create sysfs 'stats' entry */
-static struct class_device_attribute twa_host_stats_attr = {
-       .attr = {
-               .name =         "stats",
-               .mode =         S_IRUGO,
-       },
-       .show = twa_show_stats
-};
-
-/* Host attributes initializer */
-static struct class_device_attribute *twa_host_attrs[] = {
-       &twa_host_stats_attr,
-       NULL,
-};
-
-/* File operations struct for character device */
-static struct file_operations twa_fops = {
-       .owner          = THIS_MODULE,
-       .ioctl          = twa_chrdev_ioctl,
-       .open           = twa_chrdev_open,
-       .release        = NULL
-};
-
-/* This function will complete an aen request from the isr */
-static int twa_aen_complete(TW_Device_Extension *tw_dev, int request_id)
-{
-       TW_Command_Full *full_command_packet;
-       TW_Command *command_packet;
-       TW_Command_Apache_Header *header;
-       unsigned short aen;
-       int retval = 1;
-
-       header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id];
-       tw_dev->posted_request_count--;
-       aen = header->status_block.error;
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       command_packet = &full_command_packet->command.oldcommand;
-
-       /* First check for internal completion of set param for time sync */
-       if (TW_OP_OUT(command_packet->opcode__sgloffset) == TW_OP_SET_PARAM) {
-               /* Keep reading the queue in case there are more aen's */
-               if (twa_aen_read_queue(tw_dev, request_id))
-                       goto out2;
-               else {
-                       retval = 0;
-                       goto out;
-               }
-       }
-
-       switch (aen) {
-       case TW_AEN_QUEUE_EMPTY:
-               /* Quit reading the queue if this is the last one */
-               break;
-       case TW_AEN_SYNC_TIME_WITH_HOST:
-               twa_aen_sync_time(tw_dev, request_id);
-               retval = 0;
-               goto out;
-       default:
-               twa_aen_queue_event(tw_dev, header);
-
-               /* If there are more aen's, keep reading the queue */
-               if (twa_aen_read_queue(tw_dev, request_id))
-                       goto out2;
-               else {
-                       retval = 0;
-                       goto out;
-               }
-       }
-       retval = 0;
-out2:
-       tw_dev->state[request_id] = TW_S_COMPLETED;
-       twa_free_request_id(tw_dev, request_id);
-       clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags);
-out:
-       return retval;
-} /* End twa_aen_complete() */
-
-/* This function will drain aen queue */
-static int twa_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset)
-{
-       int request_id = 0;
-       char cdb[TW_MAX_CDB_LEN];
-       TW_SG_Apache sglist[1];
-       int finished = 0, count = 0;
-       TW_Command_Full *full_command_packet;
-       TW_Command_Apache_Header *header;
-       unsigned short aen;
-       int first_reset = 0, queue = 0, retval = 1;
-
-       if (no_check_reset)
-               first_reset = 0;
-       else
-               first_reset = 1;
-
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       memset(full_command_packet, 0, sizeof(TW_Command_Full));
-
-       /* Initialize cdb */
-       memset(&cdb, 0, TW_MAX_CDB_LEN);
-       cdb[0] = REQUEST_SENSE; /* opcode */
-       cdb[4] = TW_ALLOCATION_LENGTH; /* allocation length */
-
-       /* Initialize sglist */
-       memset(&sglist, 0, sizeof(TW_SG_Apache));
-       sglist[0].length = TW_SECTOR_SIZE;
-       sglist[0].address = tw_dev->generic_buffer_phys[request_id];
-
-       if (sglist[0].address & TW_ALIGNMENT_9000_SGL) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1, "Found unaligned address during AEN drain");
-               goto out;
-       }
-
-       /* Mark internal command */
-       tw_dev->srb[request_id] = NULL;
-
-       do {
-               /* Send command to the board */
-               if (twa_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2, "Error posting request sense");
-                       goto out;
-               }
-
-               /* Now poll for completion */
-               if (twa_poll_response(tw_dev, request_id, 30)) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x3, "No valid response while draining AEN queue");
-                       tw_dev->posted_request_count--;
-                       goto out;
-               }
-
-               tw_dev->posted_request_count--;
-               header = (TW_Command_Apache_Header *)tw_dev->generic_buffer_virt[request_id];
-               aen = header->status_block.error;
-               queue = 0;
-               count++;
-
-               switch (aen) {
-               case TW_AEN_QUEUE_EMPTY:
-                       if (first_reset != 1)
-                               goto out;
-                       else
-                               finished = 1;
-                       break;
-               case TW_AEN_SOFT_RESET:
-                       if (first_reset == 0)
-                               first_reset = 1;
-                       else
-                               queue = 1;
-                       break;
-               case TW_AEN_SYNC_TIME_WITH_HOST:
-                       break;
-               default:
-                       queue = 1;
-               }
-
-               /* Now queue an event info */
-               if (queue)
-                       twa_aen_queue_event(tw_dev, header);
-       } while ((finished == 0) && (count < TW_MAX_AEN_DRAIN));
-
-       if (count == TW_MAX_AEN_DRAIN)
-               goto out;
-
-       retval = 0;
-out:
-       tw_dev->state[request_id] = TW_S_INITIAL;
-       return retval;
-} /* End twa_aen_drain_queue() */
-
-/* This function will queue an event */
-static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header)
-{
-       u32 local_time;
-       struct timeval time;
-       TW_Event *event;
-       unsigned short aen;
-       char host[16];
-
-       tw_dev->aen_count++;
-
-       /* Fill out event info */
-       event = tw_dev->event_queue[tw_dev->error_index];
-
-       /* Check for clobber */
-       host[0] = '\0';
-       if (tw_dev->host) {
-               sprintf(host, " scsi%d:", tw_dev->host->host_no);
-               if (event->retrieved == TW_AEN_NOT_RETRIEVED)
-                       tw_dev->aen_clobber = 1;
-       }
-
-       aen = header->status_block.error;
-       memset(event, 0, sizeof(TW_Event));
-
-       event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
-       do_gettimeofday(&time);
-       local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
-       event->time_stamp_sec = local_time;
-       event->aen_code = aen;
-       event->retrieved = TW_AEN_NOT_RETRIEVED;
-       event->sequence_id = tw_dev->error_sequence_id;
-       tw_dev->error_sequence_id++;
-
-       header->err_specific_desc[sizeof(header->err_specific_desc) - 1] = '\0';
-       event->parameter_len = strlen(header->err_specific_desc);
-       memcpy(event->parameter_data, header->err_specific_desc, event->parameter_len);
-       if (event->severity != TW_AEN_SEVERITY_DEBUG)
-               printk(KERN_WARNING "3w-9xxx:%s AEN: %s (0x%02X:0x%04X): %s:%s.\n",
-                      host,
-                      twa_aen_severity_lookup(TW_SEV_OUT(header->status_block.severity__reserved)),
-                      TW_MESSAGE_SOURCE_CONTROLLER_EVENT, aen,
-                      twa_string_lookup(twa_aen_table, aen),
-                      header->err_specific_desc);
-       else
-               tw_dev->aen_count--;
-
-       if ((tw_dev->error_index + 1) == TW_Q_LENGTH)
-               tw_dev->event_queue_wrapped = 1;
-       tw_dev->error_index = (tw_dev->error_index + 1 ) % TW_Q_LENGTH;
-} /* End twa_aen_queue_event() */
-
-/* This function will read the aen queue from the isr */
-static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id)
-{
-       char cdb[TW_MAX_CDB_LEN];
-       TW_SG_Apache sglist[1];
-       TW_Command_Full *full_command_packet;
-       int retval = 1;
-
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       memset(full_command_packet, 0, sizeof(TW_Command_Full));
-
-       /* Initialize cdb */
-       memset(&cdb, 0, TW_MAX_CDB_LEN);
-       cdb[0] = REQUEST_SENSE; /* opcode */
-       cdb[4] = TW_ALLOCATION_LENGTH; /* allocation length */
-
-       /* Initialize sglist */
-       memset(&sglist, 0, sizeof(TW_SG_Apache));
-       sglist[0].length = TW_SECTOR_SIZE;
-       sglist[0].address = tw_dev->generic_buffer_phys[request_id];
-
-       /* Mark internal command */
-       tw_dev->srb[request_id] = NULL;
-
-       /* Now post the command packet */
-       if (twa_scsiop_execute_scsi(tw_dev, request_id, cdb, 1, sglist)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x4, "Post failed while reading AEN queue");
-               goto out;
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_aen_read_queue() */
-
-/* This function will look up an AEN severity string */
-static char *twa_aen_severity_lookup(unsigned char severity_code)
-{
-       char *retval = NULL;
-
-       if ((severity_code < (unsigned char) TW_AEN_SEVERITY_ERROR) ||
-           (severity_code > (unsigned char) TW_AEN_SEVERITY_DEBUG))
-               goto out;
-
-       retval = twa_aen_severity_table[severity_code];
-out:
-       return retval;
-} /* End twa_aen_severity_lookup() */
-
-/* This function will sync firmware time with the host time */
-static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
-{
-       u32 schedulertime;
-       struct timeval utc;
-       TW_Command_Full *full_command_packet;
-       TW_Command *command_packet;
-       TW_Param_Apache *param;
-       u32 local_time;
-
-       /* Fill out the command packet */
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       memset(full_command_packet, 0, sizeof(TW_Command_Full));
-       command_packet = &full_command_packet->command.oldcommand;
-       command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_SET_PARAM);
-       command_packet->request_id = request_id;
-       command_packet->byte8_offset.param.sgl[0].address = tw_dev->generic_buffer_phys[request_id];
-       command_packet->byte8_offset.param.sgl[0].length = TW_SECTOR_SIZE;
-       command_packet->size = TW_COMMAND_SIZE;
-       command_packet->byte6_offset.parameter_count = 1;
-
-       /* Setup the param */
-       param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id];
-       memset(param, 0, TW_SECTOR_SIZE);
-       param->table_id = TW_TIMEKEEP_TABLE | 0x8000; /* Controller time keep table */
-       param->parameter_id = 0x3; /* SchedulerTime */
-       param->parameter_size_bytes = 4;
-
-       /* Convert system time in UTC to local time seconds since last 
-           Sunday 12:00AM */
-       do_gettimeofday(&utc);
-       local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
-       schedulertime = local_time - (3 * 86400);
-       schedulertime = schedulertime % 604800;
-
-       memcpy(param->data, &schedulertime, sizeof(u32));
-
-       /* Mark internal command */
-       tw_dev->srb[request_id] = NULL;
-
-       /* Now post the command */
-       twa_post_command_packet(tw_dev, request_id, 1);
-} /* End twa_aen_sync_time() */
-
-/* This function will allocate memory and check if it is correctly aligned */
-static int twa_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
-{
-       int i;
-       dma_addr_t dma_handle;
-       unsigned long *cpu_addr;
-       int retval = 1;
-
-       cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle);
-       if (!cpu_addr) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
-               goto out;
-       }
-
-       if ((unsigned long)cpu_addr % (TW_ALIGNMENT_9000)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x6, "Failed to allocate correctly aligned memory");
-               pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle);
-               goto out;
-       }
-
-       memset(cpu_addr, 0, size*TW_Q_LENGTH);
-
-       for (i = 0; i < TW_Q_LENGTH; i++) {
-               switch(which) {
-               case 0:
-                       tw_dev->command_packet_phys[i] = dma_handle+(i*size);
-                       tw_dev->command_packet_virt[i] = (TW_Command_Full *)((unsigned char *)cpu_addr + (i*size));
-                       break;
-               case 1:
-                       tw_dev->generic_buffer_phys[i] = dma_handle+(i*size);
-                       tw_dev->generic_buffer_virt[i] = (unsigned long *)((unsigned char *)cpu_addr + (i*size));
-                       break;
-               }
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_allocate_memory() */
-
-/* This function will check the status register for unexpected bits */
-static int twa_check_bits(u32 status_reg_value)
-{
-       int retval = 1;
-
-       if ((status_reg_value & TW_STATUS_EXPECTED_BITS) != TW_STATUS_EXPECTED_BITS)
-               goto out;
-       if ((status_reg_value & TW_STATUS_UNEXPECTED_BITS) != 0)
-               goto out;
-
-       retval = 0;
-out:
-       return retval;
-} /* End twa_check_bits() */
-
-/* This function will check the srl and decide if we are compatible  */
-static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
-{
-       int retval = 1;
-       unsigned short fw_on_ctlr_srl = 0, fw_on_ctlr_arch_id = 0;
-       unsigned short fw_on_ctlr_branch = 0, fw_on_ctlr_build = 0;
-       u32 init_connect_result = 0;
-
-       if (twa_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS,
-                              TW_EXTENDED_INIT_CONNECT, TW_CURRENT_FW_SRL,
-                              TW_9000_ARCH_ID, TW_CURRENT_FW_BRANCH,
-                              TW_CURRENT_FW_BUILD, &fw_on_ctlr_srl,
-                              &fw_on_ctlr_arch_id, &fw_on_ctlr_branch,
-                              &fw_on_ctlr_build, &init_connect_result)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x7, "Initconnection failed while checking SRL");
-               goto out;
-       }
-
-       tw_dev->working_srl = TW_CURRENT_FW_SRL;
-       tw_dev->working_branch = TW_CURRENT_FW_BRANCH;
-       tw_dev->working_build = TW_CURRENT_FW_BUILD;
-
-       /* Try base mode compatibility */
-       if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) {
-               if (twa_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS,
-                                      TW_EXTENDED_INIT_CONNECT,
-                                      TW_BASE_FW_SRL, TW_9000_ARCH_ID,
-                                      TW_BASE_FW_BRANCH, TW_BASE_FW_BUILD,
-                                      &fw_on_ctlr_srl, &fw_on_ctlr_arch_id,
-                                      &fw_on_ctlr_branch, &fw_on_ctlr_build,
-                                      &init_connect_result)) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0xa, "Initconnection (base mode) failed while checking SRL");
-                       goto out;
-               }
-               if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) {
-                       if (TW_CURRENT_FW_SRL > fw_on_ctlr_srl) {
-                               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x32, "Firmware and driver incompatibility: please upgrade firmware");
-                       } else {
-                               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x33, "Firmware and driver incompatibility: please upgrade driver");
-                       }
-                       goto out;
-               }
-               tw_dev->working_srl = TW_BASE_FW_SRL;
-               tw_dev->working_branch = TW_BASE_FW_BRANCH;
-               tw_dev->working_build = TW_BASE_FW_BUILD;
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_check_srl() */
-
-/* This function handles ioctl for the character device */
-static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
-{
-       long timeout;
-       unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
-       dma_addr_t dma_handle;
-       int request_id = 0;
-       unsigned int sequence_id = 0;
-       unsigned char event_index, start_index;
-       TW_Ioctl_Driver_Command driver_command;
-       TW_Ioctl_Buf_Apache *tw_ioctl;
-       TW_Lock *tw_lock;
-       TW_Command_Full *full_command_packet;
-       TW_Compatibility_Info *tw_compat_info;
-       TW_Event *event;
-       struct timeval current_time;
-       u32 current_time_ms;
-       TW_Device_Extension *tw_dev = twa_device_extension_list[iminor(inode)];
-       int retval = TW_IOCTL_ERROR_OS_EFAULT;
-       void __user *argp = (void __user *)arg;
-
-       /* Only let one of these through at a time */
-       if (down_interruptible(&tw_dev->ioctl_sem)) {
-               retval = TW_IOCTL_ERROR_OS_EINTR;
-               goto out;
-       }
-
-       /* First copy down the driver command */
-       if (copy_from_user(&driver_command, argp, sizeof(TW_Ioctl_Driver_Command)))
-               goto out2;
-
-       /* Check data buffer size */
-       if (driver_command.buffer_length > TW_MAX_SECTORS * 512) {
-               retval = TW_IOCTL_ERROR_OS_EINVAL;
-               goto out2;
-       }
-
-       /* Hardware can only do multiple of 512 byte transfers */
-       data_buffer_length_adjusted = (driver_command.buffer_length + 511) & ~511;
-
-       /* Now allocate ioctl buf memory */
-       cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, &dma_handle);
-       if (!cpu_addr) {
-               retval = TW_IOCTL_ERROR_OS_ENOMEM;
-               goto out2;
-       }
-
-       tw_ioctl = (TW_Ioctl_Buf_Apache *)cpu_addr;
-
-       /* Now copy down the entire ioctl */
-       if (copy_from_user(tw_ioctl, argp, driver_command.buffer_length + sizeof(TW_Ioctl_Buf_Apache) - 1))
-               goto out3;
-
-       /* See which ioctl we are doing */
-       switch (cmd) {
-       case TW_IOCTL_FIRMWARE_PASS_THROUGH:
-               spin_lock_irqsave(tw_dev->host->host_lock, flags);
-               twa_get_request_id(tw_dev, &request_id);
-
-               /* Flag internal command */
-               tw_dev->srb[request_id] = NULL;
-
-               /* Flag chrdev ioctl */
-               tw_dev->chrdev_request_id = request_id;
-
-               full_command_packet = &tw_ioctl->firmware_command;
-
-               /* Load request id and sglist for both command types */
-               twa_load_sgl(full_command_packet, request_id, dma_handle, data_buffer_length_adjusted);
-
-               memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_Full));
-
-               /* Now post the command packet to the controller */
-               twa_post_command_packet(tw_dev, request_id, 1);
-               spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
-
-               timeout = TW_IOCTL_CHRDEV_TIMEOUT*HZ;
-
-               /* Now wait for command to complete */
-               timeout = wait_event_interruptible_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
-
-               /* Check if we timed out, got a signal, or didn't get
-                   an interrupt */
-               if ((timeout <= 0) && (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE)) {
-                       /* Now we need to reset the board */
-                       if (timeout == TW_IOCTL_ERROR_OS_ERESTARTSYS) {
-                               retval = timeout;
-                       } else {
-                               printk(KERN_WARNING "3w-9xxx: scsi%d: WARNING: (0x%02X:0x%04X): Character ioctl (0x%x) timed out, resetting card.\n",
-                                      tw_dev->host->host_no, TW_DRIVER, 0xc,
-                                      cmd);
-                               retval = TW_IOCTL_ERROR_OS_EIO;
-                       }
-                       spin_lock_irqsave(tw_dev->host->host_lock, flags);
-                       tw_dev->state[request_id] = TW_S_COMPLETED;
-                       twa_free_request_id(tw_dev, request_id);
-                       tw_dev->posted_request_count--;
-                       twa_reset_device_extension(tw_dev);
-                       spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
-                       goto out3;
-               }
-
-               /* Now copy in the command packet response */
-               memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virt[request_id], sizeof(TW_Command_Full));
-               
-               /* Now complete the io */
-               spin_lock_irqsave(tw_dev->host->host_lock, flags);
-               tw_dev->posted_request_count--;
-               tw_dev->state[request_id] = TW_S_COMPLETED;
-               twa_free_request_id(tw_dev, request_id);
-               spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
-               break;
-       case TW_IOCTL_GET_COMPATIBILITY_INFO:
-               tw_ioctl->driver_command.status = 0;
-               /* Copy compatiblity struct into ioctl data buffer */
-               tw_compat_info = (TW_Compatibility_Info *)tw_ioctl->data_buffer;
-               strncpy(tw_compat_info->driver_version, twa_driver_version, strlen(twa_driver_version));
-               tw_compat_info->working_srl = tw_dev->working_srl;
-               tw_compat_info->working_branch = tw_dev->working_branch;
-               tw_compat_info->working_build = tw_dev->working_build;
-               break;
-       case TW_IOCTL_GET_LAST_EVENT:
-               if (tw_dev->event_queue_wrapped) {
-                       if (tw_dev->aen_clobber) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_AEN_CLOBBER;
-                               tw_dev->aen_clobber = 0;
-                       } else
-                               tw_ioctl->driver_command.status = 0;
-               } else {
-                       if (!tw_dev->error_index) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_NO_MORE_EVENTS;
-                               break;
-                       }
-                       tw_ioctl->driver_command.status = 0;
-               }
-               event_index = (tw_dev->error_index - 1 + TW_Q_LENGTH) % TW_Q_LENGTH;
-               memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event));
-               tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED;
-               break;
-       case TW_IOCTL_GET_FIRST_EVENT:
-               if (tw_dev->event_queue_wrapped) {
-                       if (tw_dev->aen_clobber) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_AEN_CLOBBER;
-                               tw_dev->aen_clobber = 0;
-                       } else 
-                               tw_ioctl->driver_command.status = 0;
-                       event_index = tw_dev->error_index;
-               } else {
-                       if (!tw_dev->error_index) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_NO_MORE_EVENTS;
-                               break;
-                       }
-                       tw_ioctl->driver_command.status = 0;
-                       event_index = 0;
-               }
-               memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event));
-               tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED;
-               break;
-       case TW_IOCTL_GET_NEXT_EVENT:
-               event = (TW_Event *)tw_ioctl->data_buffer;
-               sequence_id = event->sequence_id;
-               tw_ioctl->driver_command.status = 0;
-
-               if (tw_dev->event_queue_wrapped) {
-                       if (tw_dev->aen_clobber) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_AEN_CLOBBER;
-                               tw_dev->aen_clobber = 0;
-                       }
-                       start_index = tw_dev->error_index;
-               } else {
-                       if (!tw_dev->error_index) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_NO_MORE_EVENTS;
-                               break;
-                       }
-                       start_index = 0;
-               }
-               event_index = (start_index + sequence_id - tw_dev->event_queue[start_index]->sequence_id + 1) % TW_Q_LENGTH;
-
-               if (!(tw_dev->event_queue[event_index]->sequence_id > sequence_id)) {
-                       if (tw_ioctl->driver_command.status == TW_IOCTL_ERROR_STATUS_AEN_CLOBBER)
-                               tw_dev->aen_clobber = 1;
-                       tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_NO_MORE_EVENTS;
-                       break;
-               }
-               memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event));
-               tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED;
-               break;
-       case TW_IOCTL_GET_PREVIOUS_EVENT:
-               event = (TW_Event *)tw_ioctl->data_buffer;
-               sequence_id = event->sequence_id;
-               tw_ioctl->driver_command.status = 0;
-
-               if (tw_dev->event_queue_wrapped) {
-                       if (tw_dev->aen_clobber) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_AEN_CLOBBER;
-                               tw_dev->aen_clobber = 0;
-                       }
-                       start_index = tw_dev->error_index;
-               } else {
-                       if (!tw_dev->error_index) {
-                               tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_NO_MORE_EVENTS;
-                               break;
-                       }
-                       start_index = 0;
-               }
-               event_index = (start_index + sequence_id - tw_dev->event_queue[start_index]->sequence_id - 1) % TW_Q_LENGTH;
-
-               if (!(tw_dev->event_queue[event_index]->sequence_id < sequence_id)) {
-                       if (tw_ioctl->driver_command.status == TW_IOCTL_ERROR_STATUS_AEN_CLOBBER)
-                               tw_dev->aen_clobber = 1;
-                       tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_NO_MORE_EVENTS;
-                       break;
-               }
-               memcpy(tw_ioctl->data_buffer, tw_dev->event_queue[event_index], sizeof(TW_Event));
-               tw_dev->event_queue[event_index]->retrieved = TW_AEN_RETRIEVED;
-               break;
-       case TW_IOCTL_GET_LOCK:
-               tw_lock = (TW_Lock *)tw_ioctl->data_buffer;
-               do_gettimeofday(&current_time);
-               current_time_ms = (current_time.tv_sec * 1000) + (current_time.tv_usec / 1000);
-
-               if ((tw_lock->force_flag == 1) || (tw_dev->ioctl_sem_lock == 0) || (current_time_ms >= tw_dev->ioctl_msec)) {
-                       tw_dev->ioctl_sem_lock = 1;
-                       tw_dev->ioctl_msec = current_time_ms + tw_lock->timeout_msec;
-                       tw_ioctl->driver_command.status = 0;
-                       tw_lock->time_remaining_msec = tw_lock->timeout_msec;
-               } else {
-                       tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_LOCKED;
-                       tw_lock->time_remaining_msec = tw_dev->ioctl_msec - current_time_ms;
-               }
-               break;
-       case TW_IOCTL_RELEASE_LOCK:
-               if (tw_dev->ioctl_sem_lock == 1) {
-                       tw_dev->ioctl_sem_lock = 0;
-                       tw_ioctl->driver_command.status = 0;
-               } else {
-                       tw_ioctl->driver_command.status = TW_IOCTL_ERROR_STATUS_NOT_LOCKED;
-               }
-               break;
-       default:
-               retval = TW_IOCTL_ERROR_OS_ENOTTY;
-               goto out3;
-       }
-
-       /* Now copy the entire response to userspace */
-       if (copy_to_user(argp, tw_ioctl, sizeof(TW_Ioctl_Buf_Apache) + driver_command.buffer_length - 1) == 0)
-               retval = 0;
-out3:
-       /* Now free ioctl buf memory */
-       pci_free_consistent(tw_dev->tw_pci_dev, data_buffer_length_adjusted+sizeof(TW_Ioctl_Buf_Apache) - 1, cpu_addr, dma_handle);
-out2:
-       up(&tw_dev->ioctl_sem);
-out:
-       return retval;
-} /* End twa_chrdev_ioctl() */
-
-/* This function handles open for the character device */
-static int twa_chrdev_open(struct inode *inode, struct file *file)
-{
-       unsigned int minor_number;
-       int retval = TW_IOCTL_ERROR_OS_ENODEV;
-
-       minor_number = iminor(inode);
-       if (minor_number >= twa_device_extension_count)
-               goto out;
-       retval = 0;
-out:
-       return retval;
-} /* End twa_chrdev_open() */
-
-/* This function will print readable messages from status register errors */
-static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value)
-{
-       int retval = 1;
-
-       /* Check for various error conditions and handle them appropriately */
-       if (status_reg_value & TW_STATUS_PCI_PARITY_ERROR) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0xc, "PCI Parity Error: clearing");
-               writel(TW_CONTROL_CLEAR_PARITY_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
-       }
-
-       if (status_reg_value & TW_STATUS_PCI_ABORT) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0xd, "PCI Abort: clearing");
-               writel(TW_CONTROL_CLEAR_PCI_ABORT, TW_CONTROL_REG_ADDR(tw_dev));
-               pci_write_config_word(tw_dev->tw_pci_dev, PCI_STATUS, TW_PCI_CLEAR_PCI_ABORT);
-       }
-
-       if (status_reg_value & TW_STATUS_QUEUE_ERROR) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing");
-               writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
-       }
-
-       if (status_reg_value & TW_STATUS_SBUF_WRITE_ERROR) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0xf, "SBUF Write Error: clearing");
-               writel(TW_CONTROL_CLEAR_SBUF_WRITE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
-       }
-
-       if (status_reg_value & TW_STATUS_MICROCONTROLLER_ERROR) {
-               if (tw_dev->reset_print == 0) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Microcontroller Error: clearing");
-                       tw_dev->reset_print = 1;
-               }
-               goto out;
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_decode_bits() */
-
-/* This function will empty the response queue */
-static int twa_empty_response_queue(TW_Device_Extension *tw_dev)
-{
-       u32 status_reg_value, response_que_value;
-       int count = 0, retval = 1;
-
-       status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-
-       while (((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) && (count < TW_MAX_RESPONSE_DRAIN)) {
-               response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
-               status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-               count++;
-       }
-       if (count == TW_MAX_RESPONSE_DRAIN)
-               goto out;
-
-       retval = 0;
-out:
-       return retval;
-} /* End twa_empty_response_queue() */
-
-/* This function passes sense keys from firmware to scsi layer */
-static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host)
-{
-       TW_Command_Full *full_command_packet;
-       unsigned short error;
-       int retval = 1;
-
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       /* Don't print error for Logical unit not supported during rollcall */
-       error = full_command_packet->header.status_block.error;
-       if ((error != TW_ERROR_LOGICAL_UNIT_NOT_SUPPORTED) && (error != TW_ERROR_UNIT_OFFLINE)) {
-               if (print_host)
-                       printk(KERN_WARNING "3w-9xxx: scsi%d: ERROR: (0x%02X:0x%04X): %s:%s.\n",
-                              tw_dev->host->host_no,
-                              TW_MESSAGE_SOURCE_CONTROLLER_ERROR,
-                              full_command_packet->header.status_block.error,
-                              twa_string_lookup(twa_error_table,
-                                                full_command_packet->header.status_block.error),
-                              full_command_packet->header.err_specific_desc);
-               else
-                       printk(KERN_WARNING "3w-9xxx: ERROR: (0x%02X:0x%04X): %s:%s.\n",
-                              TW_MESSAGE_SOURCE_CONTROLLER_ERROR,
-                              full_command_packet->header.status_block.error,
-                              twa_string_lookup(twa_error_table,
-                                                full_command_packet->header.status_block.error),
-                              full_command_packet->header.err_specific_desc);
-       }
-
-       if (copy_sense) {
-               memcpy(tw_dev->srb[request_id]->sense_buffer, full_command_packet->header.sense_data, TW_SENSE_DATA_LENGTH);
-               tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status << 1);
-               retval = TW_ISR_DONT_RESULT;
-               goto out;
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_fill_sense() */
-
-/* This function will free up device extension resources */
-static void twa_free_device_extension(TW_Device_Extension *tw_dev)
-{
-       if (tw_dev->command_packet_virt[0])
-               pci_free_consistent(tw_dev->tw_pci_dev,
-                                   sizeof(TW_Command_Full)*TW_Q_LENGTH,
-                                   tw_dev->command_packet_virt[0],
-                                   tw_dev->command_packet_phys[0]);
-
-       if (tw_dev->generic_buffer_virt[0])
-               pci_free_consistent(tw_dev->tw_pci_dev,
-                                   TW_SECTOR_SIZE*TW_Q_LENGTH,
-                                   tw_dev->generic_buffer_virt[0],
-                                   tw_dev->generic_buffer_phys[0]);
-
-       if (tw_dev->event_queue[0])
-               kfree(tw_dev->event_queue[0]);
-} /* End twa_free_device_extension() */
-
-/* This function will free a request id */
-static void twa_free_request_id(TW_Device_Extension *tw_dev, int request_id)
-{
-       tw_dev->free_queue[tw_dev->free_tail] = request_id;
-       tw_dev->state[request_id] = TW_S_FINISHED;
-       tw_dev->free_tail = (tw_dev->free_tail + 1) % TW_Q_LENGTH;
-} /* End twa_free_request_id() */
-
-/* This function will get parameter table entires from the firmware */
-static void *twa_get_param(TW_Device_Extension *tw_dev, int request_id, int table_id, int parameter_id, int parameter_size_bytes)
-{
-       TW_Command_Full *full_command_packet;
-       TW_Command *command_packet;
-       TW_Param_Apache *param;
-       unsigned long param_value;
-       void *retval = NULL;
-
-       /* Setup the command packet */
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       memset(full_command_packet, 0, sizeof(TW_Command_Full));
-       command_packet = &full_command_packet->command.oldcommand;
-
-       command_packet->opcode__sgloffset = TW_OPSGL_IN(2, TW_OP_GET_PARAM);
-       command_packet->size              = TW_COMMAND_SIZE;
-       command_packet->request_id        = request_id;
-       command_packet->byte6_offset.block_count = 1;
-
-       /* Now setup the param */
-       param = (TW_Param_Apache *)tw_dev->generic_buffer_virt[request_id];
-       memset(param, 0, TW_SECTOR_SIZE);
-       param->table_id = table_id | 0x8000;
-       param->parameter_id = parameter_id;
-       param->parameter_size_bytes = parameter_size_bytes;
-       param_value = tw_dev->generic_buffer_phys[request_id];
-
-       command_packet->byte8_offset.param.sgl[0].address = param_value;
-       command_packet->byte8_offset.param.sgl[0].length = TW_SECTOR_SIZE;
-
-       /* Post the command packet to the board */
-       twa_post_command_packet(tw_dev, request_id, 1);
-
-       /* Poll for completion */
-       if (twa_poll_response(tw_dev, request_id, 30))
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x13, "No valid response during get param")
-       else
-               retval = (void *)&(param->data[0]);
-
-       tw_dev->posted_request_count--;
-       tw_dev->state[request_id] = TW_S_INITIAL;
-
-       return retval;
-} /* End twa_get_param() */
-
-/* This function will assign an available request id */
-static void twa_get_request_id(TW_Device_Extension *tw_dev, int *request_id)
-{
-       *request_id = tw_dev->free_queue[tw_dev->free_head];
-       tw_dev->free_head = (tw_dev->free_head + 1) % TW_Q_LENGTH;
-       tw_dev->state[*request_id] = TW_S_STARTED;
-} /* End twa_get_request_id() */
-
-/* This function will send an initconnection command to controller */
-static int twa_initconnection(TW_Device_Extension *tw_dev, int message_credits,
-                             u32 set_features, unsigned short current_fw_srl, 
-                             unsigned short current_fw_arch_id, 
-                             unsigned short current_fw_branch, 
-                             unsigned short current_fw_build, 
-                             unsigned short *fw_on_ctlr_srl, 
-                             unsigned short *fw_on_ctlr_arch_id, 
-                             unsigned short *fw_on_ctlr_branch, 
-                             unsigned short *fw_on_ctlr_build, 
-                             u32 *init_connect_result)
-{
-       TW_Command_Full *full_command_packet;
-       TW_Initconnect *tw_initconnect;
-       int request_id = 0, retval = 1;
-
-       /* Initialize InitConnection command packet */
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       memset(full_command_packet, 0, sizeof(TW_Command_Full));
-       full_command_packet->header.header_desc.size_header = 128;
-       
-       tw_initconnect = (TW_Initconnect *)&full_command_packet->command.oldcommand;
-       tw_initconnect->opcode__reserved = TW_OPRES_IN(0, TW_OP_INIT_CONNECTION);
-       tw_initconnect->request_id = request_id;
-       tw_initconnect->message_credits = message_credits;
-       tw_initconnect->features = set_features;
-#if BITS_PER_LONG > 32
-       /* Turn on 64-bit sgl support */
-       tw_initconnect->features |= 1;
-#endif
-
-       if (set_features & TW_EXTENDED_INIT_CONNECT) {
-               tw_initconnect->size = TW_INIT_COMMAND_PACKET_SIZE_EXTENDED;
-               tw_initconnect->fw_srl = current_fw_srl;
-               tw_initconnect->fw_arch_id = current_fw_arch_id;
-               tw_initconnect->fw_branch = current_fw_branch;
-               tw_initconnect->fw_build = current_fw_build;
-       } else 
-               tw_initconnect->size = TW_INIT_COMMAND_PACKET_SIZE;
-
-       /* Send command packet to the board */
-       twa_post_command_packet(tw_dev, request_id, 1);
-
-       /* Poll for completion */
-       if (twa_poll_response(tw_dev, request_id, 30)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x15, "No valid response during init connection");
-       } else {
-               if (set_features & TW_EXTENDED_INIT_CONNECT) {
-                       *fw_on_ctlr_srl = tw_initconnect->fw_srl;
-                       *fw_on_ctlr_arch_id = tw_initconnect->fw_arch_id;
-                       *fw_on_ctlr_branch = tw_initconnect->fw_branch;
-                       *fw_on_ctlr_build = tw_initconnect->fw_build;
-                       *init_connect_result = tw_initconnect->result;
-               }
-               retval = 0;
-       }
-
-       tw_dev->posted_request_count--;
-       tw_dev->state[request_id] = TW_S_INITIAL;
-
-       return retval;
-} /* End twa_initconnection() */
-
-/* This function will initialize the fields of a device extension */
-static int twa_initialize_device_extension(TW_Device_Extension *tw_dev)
-{
-       int i, retval = 1;
-
-       /* Initialize command packet buffers */
-       if (twa_allocate_memory(tw_dev, sizeof(TW_Command_Full), 0)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x16, "Command packet memory allocation failed");
-               goto out;
-       }
-
-       /* Initialize generic buffer */
-       if (twa_allocate_memory(tw_dev, TW_SECTOR_SIZE, 1)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x17, "Generic memory allocation failed");
-               goto out;
-       }
-
-       /* Allocate event info space */
-       tw_dev->event_queue[0] = kmalloc(sizeof(TW_Event) * TW_Q_LENGTH, GFP_KERNEL);
-       if (!tw_dev->event_queue[0]) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x18, "Event info memory allocation failed");
-               goto out;
-       }
-
-       memset(tw_dev->event_queue[0], 0, sizeof(TW_Event) * TW_Q_LENGTH);
-
-       for (i = 0; i < TW_Q_LENGTH; i++) {
-               tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Event)));
-               tw_dev->free_queue[i] = i;
-               tw_dev->state[i] = TW_S_INITIAL;
-       }
-
-       tw_dev->pending_head = TW_Q_START;
-       tw_dev->pending_tail = TW_Q_START;
-       tw_dev->free_head = TW_Q_START;
-       tw_dev->free_tail = TW_Q_START;
-       tw_dev->error_sequence_id = 1;
-       tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
-
-       init_MUTEX(&tw_dev->ioctl_sem);
-       init_waitqueue_head(&tw_dev->ioctl_wqueue);
-
-       retval = 0;
-out:
-       return retval;
-} /* End twa_initialize_device_extension() */
-
-/* This function is the interrupt service routine */
-static irqreturn_t twa_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
-{
-       int request_id, error = 0;
-       u32 status_reg_value;
-       TW_Response_Queue response_que;
-       TW_Command_Full *full_command_packet;
-       TW_Command *command_packet;
-       TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance;
-       int handled = 0;
-
-       /* Get the per adapter lock */
-       spin_lock(tw_dev->host->host_lock);
-
-       /* See if the interrupt matches this instance */
-       if (tw_dev->tw_pci_dev->irq == (unsigned int)irq) {
-
-               handled = 1;
-
-               /* Read the registers */
-               status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-
-               /* Check if this is our interrupt, otherwise bail */
-               if (!(status_reg_value & TW_STATUS_VALID_INTERRUPT))
-                       goto twa_interrupt_bail;
-
-               /* Check controller for errors */
-               if (twa_check_bits(status_reg_value)) {
-                       if (twa_decode_bits(tw_dev, status_reg_value)) {
-                               TW_CLEAR_ALL_INTERRUPTS(tw_dev);
-                               goto twa_interrupt_bail;
-                       }
-               }
-
-               /* Handle host interrupt */
-               if (status_reg_value & TW_STATUS_HOST_INTERRUPT)
-                       TW_CLEAR_HOST_INTERRUPT(tw_dev);
-
-               /* Handle attention interrupt */
-               if (status_reg_value & TW_STATUS_ATTENTION_INTERRUPT) {
-                       TW_CLEAR_ATTENTION_INTERRUPT(tw_dev);
-                       if (!(test_and_set_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags))) {
-                               twa_get_request_id(tw_dev, &request_id);
-
-                               error = twa_aen_read_queue(tw_dev, request_id);
-                               if (error) {
-                                       tw_dev->state[request_id] = TW_S_COMPLETED;
-                                       twa_free_request_id(tw_dev, request_id);
-                                       clear_bit(TW_IN_ATTENTION_LOOP, &tw_dev->flags);
-                               }
-                       }
-               }
-
-               /* Handle command interrupt */
-               if (status_reg_value & TW_STATUS_COMMAND_INTERRUPT) {
-                       TW_MASK_COMMAND_INTERRUPT(tw_dev);
-                       /* Drain as many pending commands as we can */
-                       while (tw_dev->pending_request_count > 0) {
-                               request_id = tw_dev->pending_queue[tw_dev->pending_head];
-                               if (tw_dev->state[request_id] != TW_S_PENDING) {
-                                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x19, "Found request id that wasn't pending");
-                                       TW_CLEAR_ALL_INTERRUPTS(tw_dev);
-                                       goto twa_interrupt_bail;
-                               }
-                               if (twa_post_command_packet(tw_dev, request_id, 1)==0) {
-                                       tw_dev->pending_head = (tw_dev->pending_head + 1) % TW_Q_LENGTH;
-                                       tw_dev->pending_request_count--;
-                               } else {
-                                       /* If we get here, we will continue re-posting on the next command interrupt */
-                                       break;
-                               }
-                       }
-               }
-
-               /* Handle response interrupt */
-               if (status_reg_value & TW_STATUS_RESPONSE_INTERRUPT) {
-
-                       /* Drain the response queue from the board */
-                       while ((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) {
-                               /* Complete the response */
-                               response_que.value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
-                               request_id = TW_RESID_OUT(response_que.response_id);
-                               full_command_packet = tw_dev->command_packet_virt[request_id];
-                               error = 0;
-                               command_packet = &full_command_packet->command.oldcommand;
-                               /* Check for command packet errors */
-                               if (full_command_packet->command.newcommand.status != 0) {
-                                       if (tw_dev->srb[request_id] != 0) {
-                                               error = twa_fill_sense(tw_dev, request_id, 1, 1);
-                                       } else {
-                                               /* Skip ioctl error prints */
-                                               if (request_id != tw_dev->chrdev_request_id) {
-                                                       error = twa_fill_sense(tw_dev, request_id, 0, 1);
-                                               }
-                                       }
-                               }
-
-                               /* Check for correct state */
-                               if (tw_dev->state[request_id] != TW_S_POSTED) {
-                                       if (tw_dev->srb[request_id] != 0) {
-                                               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Received a request id that wasn't posted");
-                                               TW_CLEAR_ALL_INTERRUPTS(tw_dev);
-                                               goto twa_interrupt_bail;
-                                       }
-                               }
-
-                               /* Check for internal command completion */
-                               if (tw_dev->srb[request_id] == 0) {
-                                       if (request_id != tw_dev->chrdev_request_id) {
-                                               if (twa_aen_complete(tw_dev, request_id))
-                                                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Error completing AEN during attention interrupt");
-                                       } else {
-                                               tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
-                                               wake_up(&tw_dev->ioctl_wqueue);
-                                       }
-                               } else {
-                                       twa_scsiop_execute_scsi_complete(tw_dev, request_id);
-                                       /* If no error command was a success */
-                                       if (error == 0) {
-                                               tw_dev->srb[request_id]->result = (DID_OK << 16);
-                                       }
-
-                                       /* If error, command failed */
-                                       if (error == 1) {
-                                               /* Ask for a host reset */
-                                               tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
-                                       }
-
-                                       /* Now complete the io */
-                                       tw_dev->state[request_id] = TW_S_COMPLETED;
-                                       twa_free_request_id(tw_dev, request_id);
-                                       tw_dev->posted_request_count--;
-                                       tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
-                                       twa_unmap_scsi_data(tw_dev, request_id);
-                               }
-
-                               /* Check for valid status after each drain */
-                               status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-                               if (twa_check_bits(status_reg_value)) {
-                                       if (twa_decode_bits(tw_dev, status_reg_value)) {
-                                               TW_CLEAR_ALL_INTERRUPTS(tw_dev);
-                                               goto twa_interrupt_bail;
-                                       }
-                               }
-                       }
-               }
-       }
-twa_interrupt_bail:
-       spin_unlock(tw_dev->host->host_lock);
-       return IRQ_RETVAL(handled);
-} /* End twa_interrupt() */
-
-/* This function will load the request id and various sgls for ioctls */
-static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length)
-{
-       TW_Command *oldcommand;
-       TW_Command_Apache *newcommand;
-       TW_SG_Entry *sgl;
-
-       if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) {
-               newcommand = &full_command_packet->command.newcommand;
-               newcommand->request_id = request_id;
-               newcommand->sg_list[0].address = dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1;
-               newcommand->sg_list[0].length = length;
-       } else {
-               oldcommand = &full_command_packet->command.oldcommand;
-               oldcommand->request_id = request_id;
-
-               if (TW_SGL_OUT(oldcommand->opcode__sgloffset)) {
-                       /* Load the sg list */
-                       sgl = (TW_SG_Entry *)((u32 *)oldcommand+TW_SGL_OUT(oldcommand->opcode__sgloffset));
-                       sgl->address = dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1;
-                       sgl->length = length;
-               }
-       }
-} /* End twa_load_sgl() */
-
-/* This function will perform a pci-dma mapping for a scatter gather list */
-static int twa_map_scsi_sg_data(TW_Device_Extension *tw_dev, int request_id)
-{
-       int use_sg;
-       struct scsi_cmnd *cmd = tw_dev->srb[request_id];
-       struct pci_dev *pdev = tw_dev->tw_pci_dev;
-       int retval = 0;
-
-       if (cmd->use_sg == 0)
-               goto out;
-
-       use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, DMA_BIDIRECTIONAL);
-
-       if (use_sg == 0) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to map scatter gather list");
-               goto out;
-       }
-
-       cmd->SCp.phase = TW_PHASE_SGLIST;
-       cmd->SCp.have_data_in = use_sg;
-       retval = use_sg;
-out:
-       return retval;
-} /* End twa_map_scsi_sg_data() */
-
-/* This function will perform a pci-dma map for a single buffer */
-static dma_addr_t twa_map_scsi_single_data(TW_Device_Extension *tw_dev, int request_id)
-{
-       dma_addr_t mapping;
-       struct scsi_cmnd *cmd = tw_dev->srb[request_id];
-       struct pci_dev *pdev = tw_dev->tw_pci_dev;
-       int retval = 0;
-
-       if (cmd->request_bufflen == 0) {
-               retval = 0;
-               goto out;
-       }
-
-       mapping = pci_map_single(pdev, cmd->request_buffer, cmd->request_bufflen, DMA_BIDIRECTIONAL);
-
-       if (mapping == 0) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Failed to map page");
-               goto out;
-       }
-
-       cmd->SCp.phase = TW_PHASE_SINGLE;
-       cmd->SCp.have_data_in = mapping;
-       retval = mapping;
-out:
-       return retval;
-} /* End twa_map_scsi_single_data() */
-
-/* This function will poll for a response interrupt of a request */
-static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds)
-{
-       int retval = 1, found = 0, response_request_id;
-       TW_Response_Queue response_queue;
-       TW_Command_Full *full_command_packet = tw_dev->command_packet_virt[request_id];
-
-       if (twa_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, seconds) == 0) {
-               response_queue.value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
-               response_request_id = TW_RESID_OUT(response_queue.response_id);
-               if (request_id != response_request_id) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1e, "Found unexpected request id while polling for response");
-                       goto out;
-               }
-               if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) {
-                       if (full_command_packet->command.newcommand.status != 0) {
-                               /* bad response */
-                               twa_fill_sense(tw_dev, request_id, 0, 0);
-                               goto out;
-                       }
-                       found = 1;
-               } else {
-                       if (full_command_packet->command.oldcommand.status != 0) {
-                               /* bad response */
-                               twa_fill_sense(tw_dev, request_id, 0, 0);
-                               goto out;
-                       }
-                       found = 1;
-               }
-       }
-
-       if (found)
-               retval = 0;
-out:
-       return retval;
-} /* End twa_poll_response() */
-
-/* This function will poll the status register for a flag */
-static int twa_poll_status(TW_Device_Extension *tw_dev, u32 flag, int seconds)
-{
-       u32 status_reg_value; 
-       unsigned long before;
-       int retval = 1;
-
-       status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-       before = jiffies;
-
-       if (twa_check_bits(status_reg_value))
-               twa_decode_bits(tw_dev, status_reg_value);
-
-       while ((status_reg_value & flag) != flag) {
-               status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-
-               if (twa_check_bits(status_reg_value))
-                       twa_decode_bits(tw_dev, status_reg_value);
-
-               if (time_after(jiffies, before + HZ * seconds))
-                       goto out;
-
-               msleep(50);
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_poll_status() */
-
-/* This function will poll the status register for disappearance of a flag */
-static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds)
-{
-       u32 status_reg_value;
-       unsigned long before;
-       int retval = 1;
-
-       status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-       before = jiffies;
-
-       if (twa_check_bits(status_reg_value))
-               twa_decode_bits(tw_dev, status_reg_value);
-
-       while ((status_reg_value & flag) != 0) {
-               status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-               if (twa_check_bits(status_reg_value))
-                       twa_decode_bits(tw_dev, status_reg_value);
-
-               if (time_after(jiffies, before + HZ * seconds))
-                       goto out;
-
-               msleep(50);
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_poll_status_gone() */
-
-/* This function will attempt to post a command packet to the board */
-static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal)
-{
-       u32 status_reg_value;
-       unsigned long command_que_value;
-       int retval = 1;
-
-       command_que_value = tw_dev->command_packet_phys[request_id];
-       status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
-
-       if (twa_check_bits(status_reg_value))
-               twa_decode_bits(tw_dev, status_reg_value);
-
-       if (((tw_dev->pending_request_count > 0) && (tw_dev->state[request_id] != TW_S_PENDING)) || (status_reg_value & TW_STATUS_COMMAND_QUEUE_FULL)) {
-
-               /* Only pend internal driver commands */
-               if (!internal) {
-                       retval = SCSI_MLQUEUE_HOST_BUSY;
-                       goto out;
-               }
-
-               /* Couldn't post the command packet, so we do it later */
-               if (tw_dev->state[request_id] != TW_S_PENDING) {
-                       tw_dev->state[request_id] = TW_S_PENDING;
-                       tw_dev->pending_request_count++;
-                       if (tw_dev->pending_request_count > tw_dev->max_pending_request_count) {
-                               tw_dev->max_pending_request_count = tw_dev->pending_request_count;
-                       }
-                       tw_dev->pending_queue[tw_dev->pending_tail] = request_id;
-                       tw_dev->pending_tail = (tw_dev->pending_tail + 1) % TW_Q_LENGTH;
-               }
-               TW_UNMASK_COMMAND_INTERRUPT(tw_dev);
-               goto out;
-       } else {
-               /* We successfully posted the command packet */
-#if BITS_PER_LONG > 32
-               writeq(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
-#else
-               writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
-#endif
-               tw_dev->state[request_id] = TW_S_POSTED;
-               tw_dev->posted_request_count++;
-               if (tw_dev->posted_request_count > tw_dev->max_posted_request_count) {
-                       tw_dev->max_posted_request_count = tw_dev->posted_request_count;
-               }
-       }
-       retval = 0;
-out:
-       return retval;
-} /* End twa_post_command_packet() */
-
-/* This function will reset a device extension */
-static int twa_reset_device_extension(TW_Device_Extension *tw_dev)
-{
-       int i = 0;
-       int retval = 1;
-
-       /* Abort all requests that are in progress */
-       for (i = 0; i < TW_Q_LENGTH; i++) {
-               if ((tw_dev->state[i] != TW_S_FINISHED) &&
-                   (tw_dev->state[i] != TW_S_INITIAL) &&
-                   (tw_dev->state[i] != TW_S_COMPLETED)) {
-                       if (tw_dev->srb[i]) {
-                               tw_dev->srb[i]->result = (DID_RESET << 16);
-                               tw_dev->srb[i]->scsi_done(tw_dev->srb[i]);
-                               twa_unmap_scsi_data(tw_dev, i);
-                       }
-               }
-       }
-
-       /* Reset queues and counts */
-       for (i = 0; i < TW_Q_LENGTH; i++) {
-               tw_dev->free_queue[i] = i;
-               tw_dev->state[i] = TW_S_INITIAL;
-       }
-       tw_dev->free_head = TW_Q_START;
-       tw_dev->free_tail = TW_Q_START;
-       tw_dev->posted_request_count = 0;
-       tw_dev->pending_request_count = 0;
-       tw_dev->pending_head = TW_Q_START;
-       tw_dev->pending_tail = TW_Q_START;
-       tw_dev->reset_print = 0;
-       tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
-       tw_dev->flags = 0;
-
-       TW_DISABLE_INTERRUPTS(tw_dev);
-
-       if (twa_reset_sequence(tw_dev, 1))
-               goto out;
-
-        TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
-
-       retval = 0;
-out:
-       return retval;
-} /* End twa_reset_device_extension() */
-
-/* This function will reset a controller */
-static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset)
-{
-       int tries = 0, retval = 1, flashed = 0, do_soft_reset = soft_reset;
-
-       while (tries < TW_MAX_RESET_TRIES) {
-               if (do_soft_reset)
-                       TW_SOFT_RESET(tw_dev);
-
-               /* Make sure controller is in a good state */
-               if (twa_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY | (do_soft_reset == 1 ? TW_STATUS_ATTENTION_INTERRUPT : 0), 30)) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1f, "Microcontroller not ready during reset sequence");
-                       do_soft_reset = 1;
-                       tries++;
-                       continue;
-               }
-
-               /* Empty response queue */
-               if (twa_empty_response_queue(tw_dev)) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x20, "Response queue empty failed during reset sequence");
-                       do_soft_reset = 1;
-                       tries++;
-                       continue;
-               }
-
-               flashed = 0;
-
-               /* Check for compatibility/flash */
-               if (twa_check_srl(tw_dev, &flashed)) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x21, "Compatibility check failed during reset sequence");
-                       do_soft_reset = 1;
-                       tries++;
-                       continue;
-               } else {
-                       if (flashed) {
-                               tries++;
-                               continue;
-                       }
-               }
-
-               /* Drain the AEN queue */
-               if (twa_aen_drain_queue(tw_dev, soft_reset)) {
-                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x22, "AEN drain failed during reset sequence");
-                       do_soft_reset = 1;
-                       tries++;
-                       continue;
-               }
-
-               /* If we got here, controller is in a good state */
-               retval = 0;
-               goto out;
-       }
-out:
-       return retval;
-} /* End twa_reset_sequence() */
-
-/* This funciton returns unit geometry in cylinders/heads/sectors */
-static int twa_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[])
-{
-       int heads, sectors, cylinders;
-       TW_Device_Extension *tw_dev;
-
-       tw_dev = (TW_Device_Extension *)sdev->host->hostdata;
-
-       if (capacity >= 0x200000) {
-               heads = 255;
-               sectors = 63;
-               cylinders = sector_div(capacity, heads * sectors);
-       } else {
-               heads = 64;
-               sectors = 32;
-               cylinders = sector_div(capacity, heads * sectors);
-       }
-
-       geom[0] = heads;
-       geom[1] = sectors;
-       geom[2] = cylinders;
-
-       return 0;
-} /* End twa_scsi_biosparam() */
-
-/* This is the new scsi eh abort function */
-static int twa_scsi_eh_abort(struct scsi_cmnd *SCpnt)
-{
-       int i;
-       TW_Device_Extension *tw_dev = NULL;
-       int retval = FAILED;
-
-       tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
-
-       spin_unlock_irq(tw_dev->host->host_lock);
-
-       tw_dev->num_aborts++;
-
-       /* If we find any IO's in process, we have to reset the card */
-       for (i = 0; i < TW_Q_LENGTH; i++) {
-               if ((tw_dev->state[i] != TW_S_FINISHED) && (tw_dev->state[i] != TW_S_INITIAL)) {
-                       printk(KERN_WARNING "3w-9xxx: scsi%d: WARNING: (0x%02X:0x%04X): Unit #%d: Command (0x%x) timed out, resetting card.\n",
-                              tw_dev->host->host_no, TW_DRIVER, 0x2c,
-                              SCpnt->device->id, SCpnt->cmnd[0]);
-                       if (twa_reset_device_extension(tw_dev)) {
-                               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2a, "Controller reset failed during scsi abort");
-                               goto out;
-                       }
-                       break;
-               }
-       }
-       retval = SUCCESS;
-out:
-       spin_lock_irq(tw_dev->host->host_lock);
-       return retval;
-} /* End twa_scsi_eh_abort() */
-
-/* This is the new scsi eh reset function */
-static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
-{
-       TW_Device_Extension *tw_dev = NULL;
-       int retval = FAILED;
-
-       tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
-
-       spin_unlock_irq(tw_dev->host->host_lock);
-
-       tw_dev->num_resets++;
-
-       printk(KERN_WARNING "3w-9xxx: scsi%d: SCSI host reset started.\n", tw_dev->host->host_no);
-
-       /* Now reset the card and some of the device extension data */
-       if (twa_reset_device_extension(tw_dev)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset");
-               goto out;
-       }
-       printk(KERN_WARNING "3w-9xxx: scsi%d: SCSI host reset succeeded.\n", tw_dev->host->host_no);
-       retval = SUCCESS;
-out:
-       spin_lock_irq(tw_dev->host->host_lock);
-       return retval;
-} /* End twa_scsi_eh_reset() */
-
-/* This is the main scsi queue function to handle scsi opcodes */
-static int twa_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
-{
-       int request_id, retval;
-       TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
-
-       /* Save done function into scsi_cmnd struct */
-       SCpnt->scsi_done = done;
-               
-       /* Get a free request id */
-       twa_get_request_id(tw_dev, &request_id);
-
-       /* Save the scsi command for use by the ISR */
-       tw_dev->srb[request_id] = SCpnt;
-
-       /* Initialize phase to zero */
-       SCpnt->SCp.phase = TW_PHASE_INITIAL;
-
-       retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
-       switch (retval) {
-       case SCSI_MLQUEUE_HOST_BUSY:
-               twa_free_request_id(tw_dev, request_id);
-               break;
-       case 1:
-               tw_dev->state[request_id] = TW_S_COMPLETED;
-               twa_free_request_id(tw_dev, request_id);
-               SCpnt->result = (DID_ERROR << 16);
-               done(SCpnt);
-       }
-
-       return retval;
-} /* End twa_scsi_queue() */
-
-/* This function hands scsi cdb's to the firmware */
-static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Apache *sglistarg)
-{
-       TW_Command_Full *full_command_packet;
-       TW_Command_Apache *command_packet;
-       u32 num_sectors = 0x0;
-       int i, sg_count;
-       struct scsi_cmnd *srb = NULL;
-       struct scatterlist *sglist = NULL;
-       u32 buffaddr = 0x0;
-       int retval = 1;
-
-       if (tw_dev->srb[request_id]) {
-               if (tw_dev->srb[request_id]->request_buffer) {
-                       sglist = (struct scatterlist *)tw_dev->srb[request_id]->request_buffer;
-               }
-               srb = tw_dev->srb[request_id];
-       }
-
-       /* Initialize command packet */
-       full_command_packet = tw_dev->command_packet_virt[request_id];
-       full_command_packet->header.header_desc.size_header = 128;
-       full_command_packet->header.status_block.error = 0;
-       full_command_packet->header.status_block.severity__reserved = 0;
-
-       command_packet = &full_command_packet->command.newcommand;
-       command_packet->status = 0;
-       command_packet->opcode__reserved = TW_OPRES_IN(0, TW_OP_EXECUTE_SCSI);
-
-       /* We forced 16 byte cdb use earlier */
-       if (!cdb)
-               memcpy(command_packet->cdb, srb->cmnd, TW_MAX_CDB_LEN);
-       else
-               memcpy(command_packet->cdb, cdb, TW_MAX_CDB_LEN);
-
-       if (srb)
-               command_packet->unit = srb->device->id;
-       else
-               command_packet->unit = 0;
-
-       command_packet->request_id = request_id;
-       command_packet->sgl_offset = 16;
-
-       if (!sglistarg) {
-               /* Map sglist from scsi layer to cmd packet */
-               if (tw_dev->srb[request_id]->use_sg == 0) {
-                       if (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH) {
-                               command_packet->sg_list[0].address = tw_dev->generic_buffer_phys[request_id];
-                               command_packet->sg_list[0].length = TW_MIN_SGL_LENGTH;
-                       } else {
-                               buffaddr = twa_map_scsi_single_data(tw_dev, request_id);
-                               if (buffaddr == 0)
-                                       goto out;
-
-                               command_packet->sg_list[0].address = buffaddr;
-                               command_packet->sg_list[0].length = tw_dev->srb[request_id]->request_bufflen;
-                       }
-                       command_packet->sgl_entries = 1;
-
-                       if (command_packet->sg_list[0].address & TW_ALIGNMENT_9000_SGL) {
-                               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2d, "Found unaligned address during execute scsi");
-                               goto out;
-                       }
-               }
-
-               if (tw_dev->srb[request_id]->use_sg > 0) {
-                       sg_count = twa_map_scsi_sg_data(tw_dev, request_id);
-                       if (sg_count == 0)
-                               goto out;
-
-                       for (i = 0; i < sg_count; i++) {
-                               command_packet->sg_list[i].address = sg_dma_address(&sglist[i]);
-                               command_packet->sg_list[i].length = sg_dma_len(&sglist[i]);
-                               if (command_packet->sg_list[i].address & TW_ALIGNMENT_9000_SGL) {
-                                       TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2e, "Found unaligned sgl address during execute scsi");
-                                       goto out;
-                               }
-                       }
-                       command_packet->sgl_entries = tw_dev->srb[request_id]->use_sg;
-               }
-       } else {
-               /* Internal cdb post */
-               for (i = 0; i < use_sg; i++) {
-                       command_packet->sg_list[i].address = sglistarg[i].address;
-                       command_packet->sg_list[i].length = sglistarg[i].length;
-                       if (command_packet->sg_list[i].address & TW_ALIGNMENT_9000_SGL) {
-                               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2f, "Found unaligned sgl address during internal post");
-                               goto out;
-                       }
-               }
-               command_packet->sgl_entries = use_sg;
-       }
-
-       if (srb) {
-               if (srb->cmnd[0] == READ_6 || srb->cmnd[0] == WRITE_6)
-                       num_sectors = (u32)srb->cmnd[4];
-
-               if (srb->cmnd[0] == READ_10 || srb->cmnd[0] == WRITE_10)
-                       num_sectors = (u32)srb->cmnd[8] | ((u32)srb->cmnd[7] << 8);
-       }
-
-       /* Update sector statistic */
-       tw_dev->sector_count = num_sectors;
-       if (tw_dev->sector_count > tw_dev->max_sector_count)
-               tw_dev->max_sector_count = tw_dev->sector_count;
-
-       /* Update SG statistics */
-       if (srb) {
-               tw_dev->sgl_entries = tw_dev->srb[request_id]->use_sg;
-               if (tw_dev->sgl_entries > tw_dev->max_sgl_entries)
-                       tw_dev->max_sgl_entries = tw_dev->sgl_entries;
-       }
-
-       /* Now post the command to the board */
-       if (srb) {
-               retval = twa_post_command_packet(tw_dev, request_id, 0);
-       } else {
-               twa_post_command_packet(tw_dev, request_id, 1);
-               retval = 0;
-       }
-out:
-       return retval;
-} /* End twa_scsiop_execute_scsi() */
-
-/* This function completes an execute scsi operation */
-static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id)
-{
-       /* Copy the response if too small */
-       if ((tw_dev->srb[request_id]->request_buffer) && (tw_dev->srb[request_id]->request_bufflen < TW_MIN_SGL_LENGTH)) {
-               memcpy(tw_dev->srb[request_id]->request_buffer,
-                      tw_dev->generic_buffer_virt[request_id],
-                      tw_dev->srb[request_id]->request_bufflen);
-       }
-} /* End twa_scsiop_execute_scsi_complete() */
-
-/* This function tells the controller to shut down */
-static void __twa_shutdown(TW_Device_Extension *tw_dev)
-{
-       /* Disable interrupts */
-       TW_DISABLE_INTERRUPTS(tw_dev);
-
-       printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no);
-
-       /* Tell the card we are shutting down */
-       if (twa_initconnection(tw_dev, 1, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x31, "Connection shutdown failed");
-       } else {
-               printk(KERN_WARNING "3w-9xxx: Shutdown complete.\n");
-       }
-
-       /* Clear all interrupts just before exit */
-       TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
-} /* End __twa_shutdown() */
-
-/* Wrapper for __twa_shutdown */
-static void twa_shutdown(struct device *dev)
-{
-       struct Scsi_Host *host = pci_get_drvdata(to_pci_dev(dev));
-       TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
-
-       __twa_shutdown(tw_dev);
-} /* End twa_shutdown() */
-
-/* This function will look up a string */
-static char *twa_string_lookup(twa_message_type *table, unsigned int code)
-{
-       int index;
-
-       for (index = 0; ((code != table[index].code) &&
-                     (table[index].text != (char *)0)); index++);
-       return(table[index].text);
-} /* End twa_string_lookup() */
-
-/* This function will perform a pci-dma unmap */
-static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id)
-{
-       struct scsi_cmnd *cmd = tw_dev->srb[request_id];
-       struct pci_dev *pdev = tw_dev->tw_pci_dev;
-
-       switch(cmd->SCp.phase) {
-       case TW_PHASE_SINGLE:
-               pci_unmap_single(pdev, cmd->SCp.have_data_in, cmd->request_bufflen, DMA_BIDIRECTIONAL);
-               break;
-       case TW_PHASE_SGLIST:
-               pci_unmap_sg(pdev, cmd->request_buffer, cmd->use_sg, DMA_BIDIRECTIONAL);
-               break;
-       }
-} /* End twa_unmap_scsi_data() */
-
-/* scsi_host_template initializer */
-static struct scsi_host_template driver_template = {
-       .module                 = THIS_MODULE,
-       .name                   = "3ware 9000 Storage Controller",
-       .queuecommand           = twa_scsi_queue,
-       .eh_abort_handler       = twa_scsi_eh_abort,
-       .eh_host_reset_handler  = twa_scsi_eh_reset,
-       .bios_param             = twa_scsi_biosparam,
-       .can_queue              = TW_Q_LENGTH-2,
-       .this_id                = -1,
-       .sg_tablesize           = TW_APACHE_MAX_SGL_LENGTH,
-       .max_sectors            = TW_MAX_SECTORS,
-       .cmd_per_lun            = TW_MAX_CMDS_PER_LUN,
-       .use_clustering         = ENABLE_CLUSTERING,
-       .shost_attrs            = twa_host_attrs,
-       .sdev_attrs             = twa_dev_attrs,
-       .emulated               = 1
-};
-
-/* This function will probe and initialize a card */
-static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
-{
-       struct Scsi_Host *host = NULL;
-       TW_Device_Extension *tw_dev;
-       u32 mem_addr;
-       int retval = -ENODEV;
-
-       retval = pci_enable_device(pdev);
-       if (retval) {
-               TW_PRINTK(host, TW_DRIVER, 0x34, "Failed to enable pci device");
-               goto out_disable_device;
-       }
-
-       pci_set_master(pdev);
-
-       retval = pci_set_dma_mask(pdev, TW_DMA_MASK);
-       if (retval) {
-               TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
-               goto out_disable_device;
-       }
-
-       host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
-       if (!host) {
-               TW_PRINTK(host, TW_DRIVER, 0x24, "Failed to allocate memory for device extension");
-               retval = -ENOMEM;
-               goto out_disable_device;
-       }
-       tw_dev = (TW_Device_Extension *)host->hostdata;
-
-       memset(tw_dev, 0, sizeof(TW_Device_Extension));
-
-       /* Save values to device extension */
-       tw_dev->host = host;
-       tw_dev->tw_pci_dev = pdev;
-
-       if (twa_initialize_device_extension(tw_dev)) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension");
-               goto out_free_device_extension;
-       }
-
-       /* Request IO regions */
-       retval = pci_request_regions(pdev, "3w-9xxx");
-       if (retval) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x26, "Failed to get mem region");
-               goto out_free_device_extension;
-       }
-
-       mem_addr = pci_resource_start(pdev, 1);
-
-       /* Save base address */
-       tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
-       if (!tw_dev->base_addr) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
-               goto out_release_mem_region;
-       }
-
-       /* Disable interrupts on the card */
-       TW_DISABLE_INTERRUPTS(tw_dev);
-
-       /* Initialize the card */
-       if (twa_reset_sequence(tw_dev, 0))
-               goto out_release_mem_region;
-
-       /* Set host specific parameters */
-       host->max_id = TW_MAX_UNITS;
-       host->max_cmd_len = TW_MAX_CDB_LEN;
-
-       /* Luns and channels aren't supported by adapter */
-       host->max_lun = 0;
-       host->max_channel = 0;
-
-       /* Register the card with the kernel SCSI layer */
-       retval = scsi_add_host(host, &pdev->dev);
-       if (retval) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed");
-               goto out_release_mem_region;
-       }
-
-       pci_set_drvdata(pdev, host);
-
-       printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%x, IRQ: %d.\n",
-              host->host_no, mem_addr, pdev->irq);
-       printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n",
-              host->host_no,
-              (char *)twa_get_param(tw_dev, 0, TW_VERSION_TABLE,
-                                    TW_PARAM_FWVER, TW_PARAM_FWVER_LENGTH),
-              (char *)twa_get_param(tw_dev, 1, TW_VERSION_TABLE,
-                                    TW_PARAM_BIOSVER, TW_PARAM_BIOSVER_LENGTH),
-              *(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE,
-                                    TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH));
-
-       /* Now setup the interrupt handler */
-       retval = request_irq(pdev->irq, twa_interrupt, SA_SHIRQ, "3w-9xxx", tw_dev);
-       if (retval) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x30, "Error requesting IRQ");
-               goto out_remove_host;
-       }
-
-       twa_device_extension_list[twa_device_extension_count] = tw_dev;
-       twa_device_extension_count++;
-
-       /* Re-enable interrupts on the card */
-       TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
-
-       /* Finally, scan the host */
-       scsi_scan_host(host);
-
-       if (twa_major == -1) {
-               if ((twa_major = register_chrdev (0, "twa", &twa_fops)) < 0)
-                       TW_PRINTK(host, TW_DRIVER, 0x29, "Failed to register character device");
-       }
-       return 0;
-
-out_remove_host:
-       scsi_remove_host(host);
-out_release_mem_region:
-       pci_release_regions(pdev);
-out_free_device_extension:
-       twa_free_device_extension(tw_dev);
-       scsi_host_put(host);
-out_disable_device:
-       pci_disable_device(pdev);
-
-       return retval;
-} /* End twa_probe() */
-
-/* This function is called to remove a device */
-static void twa_remove(struct pci_dev *pdev)
-{
-       struct Scsi_Host *host = pci_get_drvdata(pdev);
-       TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
-
-       scsi_remove_host(tw_dev->host);
-
-       __twa_shutdown(tw_dev);
-
-       /* Free up the IRQ */
-       free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
-
-       /* Free up the mem region */
-       pci_release_regions(pdev);
-
-       /* Free up device extension resources */
-       twa_free_device_extension(tw_dev);
-
-       /* Unregister character device */
-       if (twa_major >= 0) {
-               unregister_chrdev(twa_major, "twa");
-               twa_major = -1;
-       }
-
-       scsi_host_put(tw_dev->host);
-       pci_disable_device(pdev);
-       twa_device_extension_count--;
-} /* End twa_remove() */
-
-/* PCI Devices supported by this driver */
-static struct pci_device_id twa_pci_tbl[] __devinitdata = {
-       { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9000,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       { }
-};
-MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
-
-/* pci_driver initializer */
-static struct pci_driver twa_driver = {
-       .name           = "3w-9xxx",
-       .id_table       = twa_pci_tbl,
-       .probe          = twa_probe,
-       .remove         = twa_remove,
-       .driver         = {
-               .shutdown = twa_shutdown
-       }
-};
-
-/* This function is called on driver initialization */
-static int __init twa_init(void)
-{
-       printk(KERN_WARNING "3ware 9000 Storage Controller device driver for Linux v%s.\n", twa_driver_version);
-
-       return pci_module_init(&twa_driver);
-} /* End twa_init() */
-
-/* This function is called on driver exit */
-static void __exit twa_exit(void)
-{
-       pci_unregister_driver(&twa_driver);
-} /* End twa_exit() */
-
-module_init(twa_init);
-module_exit(twa_exit);
-
index 4f2a284..2d05c14 100644 (file)
@@ -717,10 +717,16 @@ static ide_driver_t idescsi_driver = {
        .drives                 = LIST_HEAD_INIT(idescsi_driver.drives),
 };
 
+static int ide_scsi_warned;
+
 static int idescsi_ide_open(struct inode *inode, struct file *filp)
 {
        ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
        drive->usage++;
+       if (!ide_scsi_warned++) {
+               printk(KERN_WARNING "ide-scsi: Warning this device driver is only intended for specialist devices.\n");
+               printk(KERN_WARNING "ide-scsi: Do not use for cd burning, use /dev/hdX directly instead.\n");
+       }
        return 0;
 }
 
index 5fd685e..34d71ed 100644 (file)
@@ -4601,6 +4601,21 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
        pci_bus = pdev->bus->number;
        pci_dev_func = pdev->devfn;
+       
+       if(pdev->vendor == PCI_VENDOR_ID_INTEL)         /* The megaraid3 stuff reports the id of the intel
+                                                          part which is not remotely specific to the megaraid */
+       {
+               u16 magic;
+               /* Don't fall over the Compaq management cards using the same PCI identifier */
+               if(pdev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ &&
+                  pdev->subsystem_device == 0xC000)
+                       return -ENODEV;
+               /* Now check the magic signature byte */
+               pci_read_config_word(pdev, PCI_CONF_AMISIG, &magic);
+               if(magic != HBA_SIGNATURE_471 && magic != HBA_SIGNATURE)
+                       return -ENODEV;
+               /* Ok it is probably a megaraid */
+       }
 
        /*
         * The megaraid3 stuff reports the ID of the Intel part which is not
diff --git a/drivers/scsi/pc980155.c b/drivers/scsi/pc980155.c
deleted file mode 100644 (file)
index 046b5c3..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- *
- *  drivers/scsi/pc980155.c
- *
- *  PC-9801-55 SCSI host adapter driver
- *
- *  Copyright (C) 1997-2003  Kyoto University Microcomputer Club
- *                          (Linux/98 project)
- *                          Tomoharu Ugawa <ohirune@kmc.gr.jp>
- *
- */
-
-#include <linux/module.h>
-#include <linux/blkdev.h>
-#include <linux/ioport.h>
-#include <linux/interrupt.h>
-#include <linux/types.h>
-#include <linux/delay.h>
-
-#include <asm/dma.h>
-
-#include "scsi.h"
-#include "hosts.h"
-#include "wd33c93.h"
-#include "pc980155.h"
-
-extern int pc98_bios_param(struct scsi_device *, struct block_device *,
-                               sector_t, int *);
-static int scsi_pc980155_detect(Scsi_Host_Template *);
-static int scsi_pc980155_release(struct Scsi_Host *);
-
-#ifndef CMD_PER_LUN
-#define CMD_PER_LUN 2
-#endif
-
-#ifndef CAN_QUEUE
-#define CAN_QUEUE 16
-#endif
-
-#undef PC_9801_55_DEBUG
-#undef PC_9801_55_DEBUG_VERBOSE
-
-#define NR_BASE_IOS 4
-static int nr_base_ios = NR_BASE_IOS;
-static unsigned int base_ios[NR_BASE_IOS] = {0xcc0, 0xcd0, 0xce0, 0xcf0};
-static wd33c93_regs init_regs;
-static int io;
-
-static struct Scsi_Host *pc980155_host = NULL;
-
-static void pc980155_intr_handle(int irq, void *dev_id, struct pt_regs *regp);
-
-static inline void pc980155_dma_enable(unsigned int base_io)
-{
-       outb(0x01, REG_CWRITE);
-}
-
-static inline void pc980155_dma_disable(unsigned int base_io)
-{
-       outb(0x02, REG_CWRITE);
-}
-
-
-static void pc980155_intr_handle(int irq, void *dev_id, struct pt_regs *regp)
-{
-       wd33c93_intr(pc980155_host);
-}
-
-static int dma_setup(Scsi_Cmnd *sc, int dir_in)
-{
-  /*
-   * sc->SCp.this_residual : transfer count
-   * sc->SCp.ptr : distination address (virtual address)
-   * dir_in : data direction (DATA_OUT_DIR:0 or DATA_IN_DIR:1)
-   *
-   * if success return 0
-   */
-
-   /*
-    * DMA WRITE MODE
-    * bit 7,6 01b single mode (this mode only)
-    * bit 5   inc/dec (default:0 = inc)
-    * bit 4   auto initialize (normaly:0 = off)
-    * bit 3,2 01b memory -> io
-    *         10b io -> memory
-    *         00b verify
-    * bit 1,0 channel
-    */
-       disable_dma(sc->device->host->dma_channel);
-       set_dma_mode(sc->device->host->dma_channel,
-                       0x40 | (dir_in ? 0x04 : 0x08));
-       clear_dma_ff(sc->device->host->dma_channel);
-       set_dma_addr(sc->device->host->dma_channel, virt_to_phys(sc->SCp.ptr));
-       set_dma_count(sc->device->host->dma_channel, sc->SCp.this_residual);
-#ifdef PC_9801_55_DEBUG
-       printk("D%d(%x)D", sc->device->host->dma_channel,
-               sc->SCp.this_residual);
-#endif
-       enable_dma(sc->device->host->dma_channel);
-       pc980155_dma_enable(sc->device->host->io_port);
-       return 0;
-}
-
-static void dma_stop(struct Scsi_Host *instance, Scsi_Cmnd *sc, int status)
-{
-  /*
-   * instance: Hostadapter's instance
-   * sc: scsi command
-   * status: True if success
-   */
-       pc980155_dma_disable(sc->device->host->io_port);
-       disable_dma(sc->device->host->dma_channel);
-}  
-
-/* return non-zero on detection */
-static inline int pc980155_test_port(wd33c93_regs regs)
-{
-       /* Quick and dirty test for presence of the card. */
-       if (inb(regs.SASR) == 0xff)
-               return 0;
-
-       return 1;
-}
-
-static inline int pc980155_getconfig(unsigned int base_io, wd33c93_regs regs,
-                                       unsigned char* irq, unsigned char* dma,
-                                       unsigned char* scsi_id)
-{
-       static unsigned char irqs[] = {3, 5, 6, 9, 12, 13};
-       unsigned char result;
-  
-       printk(KERN_DEBUG "PC-9801-55: base_io=%x SASR=%x SCMD=%x\n",
-               base_io, regs.SASR, regs.SCMD);
-       result = read_pc980155_resetint(regs);
-       printk(KERN_DEBUG "PC-9801-55: getting config (%x)\n", result);
-       *scsi_id = result & 0x07;
-       *irq = (result >> 3) & 0x07;
-       if (*irq > 5) {
-               printk(KERN_ERR "PC-9801-55 (base %#x): impossible IRQ (%d)"
-                       " - other device here?\n", base_io, *irq);
-               return 0;
-       }
-
-       *irq = irqs[*irq];
-       result = inb(REG_STATRD);
-       *dma = result & 0x03;
-       if (*dma == 1) {
-               printk(KERN_ERR
-                       "PC-9801-55 (base %#x): impossible DMA channl (%d)"
-                       " - other device here?\n", base_io, *dma);
-               return 0;
-       }
-#ifdef PC_9801_55_DEBUG
-       printk("PC-9801-55: end of getconfig\n");
-#endif
-       return 1;
-}
-
-/* return non-zero on detection */
-static int scsi_pc980155_detect(Scsi_Host_Template* tpnt)
-{
-       unsigned int base_io;
-       unsigned char irq, dma, scsi_id;
-       int i;
-#ifdef PC_9801_55_DEBUG
-       unsigned char debug;
-#endif
-  
-       if (io) {
-               base_ios[0] = io;
-               nr_base_ios = 1;
-       }
-
-       for (i = 0; i < nr_base_ios; i++) {
-               base_io = base_ios[i];
-               init_regs.SASR = REG_ADDRST;
-               init_regs.SCMD = REG_CONTRL;
-#ifdef PC_9801_55_DEBUG
-               printk("PC-9801-55: SASR(%x = %x)\n", SASR, REG_ADDRST);
-#endif
-               if (!request_region(base_io, 6, "PC-9801-55"))
-                       continue;
-
-               if (pc980155_test_port(init_regs) &&
-                   pc980155_getconfig(base_io, init_regs,
-                                       &irq, &dma, &scsi_id))
-                       goto found;
-
-               release_region(base_io, 6);
-       }
-
-       printk("PC-9801-55: not found\n");
-       return 0;
-
-       found:
-#ifdef PC_9801_55_DEBUG
-       printk("PC-9801-55: config: base io = %x, irq = %d, dma channel = %d, scsi id = %d\n", base_io, irq, dma, scsi_id);
-#endif
-       if (request_irq(irq, pc980155_intr_handle, 0, "PC-9801-55", NULL)) {
-               printk(KERN_ERR "PC-9801-55: unable to allocate IRQ %d\n", irq);
-               goto err1;
-       }
-
-       if (request_dma(dma, "PC-9801-55")) {
-               printk(KERN_ERR "PC-9801-55: unable to allocate DMA channel %d\n", dma);
-               goto err2;
-       }
-
-       pc980155_host = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
-       if (pc980155_host) {
-               pc980155_host->this_id = scsi_id;
-               pc980155_host->io_port = base_io;
-               pc980155_host->n_io_port = 6;
-               pc980155_host->irq = irq;
-               pc980155_host->dma_channel = dma;
-               printk("PC-9801-55: scsi host found at %x irq = %d, use dma channel %d.\n", base_io, irq, dma);
-               pc980155_int_enable(init_regs);
-               wd33c93_init(pc980155_host, init_regs, dma_setup, dma_stop,
-                               WD33C93_FS_12_15);
-               return 1;
-       }
-
-       printk(KERN_ERR "PC-9801-55: failed to register device\n");
-
-err2:
-       free_irq(irq, NULL);
-err1:
-       release_region(base_io, 6);
-       return 0;
-}
-
-static int scsi_pc980155_release(struct Scsi_Host *shost)
-{
-       struct WD33C93_hostdata *hostdata
-               = (struct WD33C93_hostdata *)shost->hostdata;
-
-       pc980155_int_disable(hostdata->regs);
-       release_region(shost->io_port, shost->n_io_port);
-       free_irq(shost->irq, NULL);
-       free_dma(shost->dma_channel);
-       wd33c93_release();
-       return 1;
-}
-
-static int pc980155_bus_reset(Scsi_Cmnd *cmd)
-{
-       struct WD33C93_hostdata *hostdata
-               = (struct WD33C93_hostdata *)cmd->device->host->hostdata;
-
-       pc980155_int_disable(hostdata->regs);
-       pc980155_assert_bus_reset(hostdata->regs);
-       udelay(50);
-       pc980155_negate_bus_reset(hostdata->regs);
-       (void) inb(hostdata->regs.SASR);
-       (void) read_pc980155(hostdata->regs, WD_SCSI_STATUS);
-       pc980155_int_enable(hostdata->regs);
-       wd33c93_host_reset(cmd);
-       return SUCCESS;
-}
-
-
-#ifndef MODULE
-static int __init pc980155_setup(char *str)
-{
-        int ints[4];
-
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0)
-               io = ints[1];
-        return 1;
-}
-__setup("pc980155_io=", pc980155_setup);
-#endif
-
-MODULE_PARM(io, "i");
-MODULE_AUTHOR("Tomoharu Ugawa <ohirune@kmc.gr.jp>");
-MODULE_DESCRIPTION("PC-9801-55 SCSI host adapter driver");
-MODULE_LICENSE("GPL");
-
-static Scsi_Host_Template driver_template = {
-       .proc_info              = wd33c93_proc_info,
-       .name                   = "SCSI PC-9801-55",
-       .detect                 = scsi_pc980155_detect,
-       .release                = scsi_pc980155_release,
-       .queuecommand           = wd33c93_queuecommand,
-       .eh_abort_handler       = wd33c93_abort,
-       .eh_bus_reset_handler   = pc980155_bus_reset,
-       .eh_host_reset_handler  = wd33c93_host_reset,
-       .bios_param             = pc98_bios_param,
-       .can_queue              = CAN_QUEUE,
-       .this_id                = 7,
-       .sg_tablesize           = SG_ALL,
-       .cmd_per_lun            = CMD_PER_LUN, /* dont use link command */
-       .unchecked_isa_dma      = 1, /* use dma **XXXX***/
-       .use_clustering         = ENABLE_CLUSTERING,
-       .proc_name              = "PC_9801_55",
-};
-
-#include "scsi_module.c"
diff --git a/drivers/scsi/pc980155.h b/drivers/scsi/pc980155.h
deleted file mode 100644 (file)
index eef4a80..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *
- *  drivers/scsi/pc980155.h
- *
- *  PC-9801-55 SCSI host adapter driver
- *
- *  Copyright (C) 1997-2003  Kyoto University Microcomputer Club
- *                          (Linux/98 project)
- *                          Tomoharu Ugawa <ohirune@kmc.gr.jp>
- *
- */
-
-#ifndef __PC980155_H
-#define __PC980155_H
-
-#include "wd33c93.h"
-
-#define REG_ADDRST (base_io)
-#define REG_CONTRL (base_io + 2)
-#define REG_CWRITE (base_io + 4)
-#define REG_STATRD (base_io + 4)
-
-#define WD_MEMORYBANK  0x30
-#define WD_RESETINT    0x33
-
-static inline uchar read_pc980155(const wd33c93_regs regs, uchar reg_num)
-{
-       outb(reg_num, regs.SASR);
-       return (uchar)inb(regs.SCMD);
-}
-
-static inline void write_memorybank(const wd33c93_regs regs, uchar value)
-{
-      outb(WD_MEMORYBANK, regs.SASR);
-      outb(value, regs.SCMD);
-}
-
-#define read_pc980155_resetint(regs) \
-       read_pc980155((regs), WD_RESETINT)
-#define pc980155_int_enable(regs) \
-       write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) | 0x04)
-
-#define pc980155_int_disable(regs) \
-       write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) & ~0x04)
-
-#define pc980155_assert_bus_reset(regs) \
-       write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) | 0x02)
-
-#define pc980155_negate_bus_reset(regs) \
-       write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) & ~0x02)
-
-#endif /* __PC980155_H */
diff --git a/drivers/scsi/pcmcia/qlogic_core.c b/drivers/scsi/pcmcia/qlogic_core.c
deleted file mode 100644 (file)
index 78abe22..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#define PCMCIA 1
-#include "qlogicfas.c"
diff --git a/drivers/scsi/qla2xxx/qla_os.h b/drivers/scsi/qla2xxx/qla_os.h
deleted file mode 100644 (file)
index a5d7910..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/******************************************************************************
- *                  QLOGIC LINUX SOFTWARE
- *
- * QLogic ISP2x00 device driver for Linux 2.6.x
- * Copyright (C) 2003-2004 QLogic Corporation
- * (www.qlogic.com)
- *
- * Portions (C) Arjan van de Ven <arjanv@redhat.com> for Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- ******************************************************************************/
-
-#ifndef __QLA_OS_H
-#define __QLA_OS_H
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/sched.h>
-#include <linux/pci.h>
-#include <linux/proc_fs.h>
-#include <linux/blkdev.h>
-#include <linux/interrupt.h>
-#include <linux/stat.h>
-#include <linux/slab.h>
-#include <linux/mempool.h>
-#include <linux/vmalloc.h>
-#include <linux/smp_lock.h>
-#include <linux/bio.h>
-#include <linux/moduleparam.h>
-#include <linux/capability.h>
-#include <linux/list.h>
-
-#include <asm/system.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/segment.h>
-#include <asm/byteorder.h>
-#include <asm/pgtable.h>
-
-#include <linux/ioctl.h>
-#include <asm/uaccess.h>
-
-#include "scsi.h"
-#include "hosts.h"
-
-#include <scsi/scsicam.h>
-#include <scsi/scsi_ioctl.h>
-#include <scsi/scsi_transport.h>
-#include <scsi/scsi_transport_fc.h>
-
-//TODO Fix this!!!
-/*
-* String arrays
-*/
-#define LINESIZE    256
-#define MAXARGS      26
-
-/***********************************************************************
-* We use the struct scsi_pointer structure that's included with each 
-* command SCSI_Cmnd as a scratchpad. 
-*
-* SCp is defined as follows:
-*  - SCp.ptr  -- > pointer to the SRB
-*  - SCp.this_residual  -- > HBA completion status for ioctl code. 
-*
-* Cmnd->host_scribble --> Used to hold the hba actived handle (1..255).
-***********************************************************************/
-#define        CMD_SP(Cmnd)            ((Cmnd)->SCp.ptr)
-#define CMD_COMPL_STATUS(Cmnd)  ((Cmnd)->SCp.this_residual)
-/* Additional fields used by ioctl passthru */
-#define CMD_RESID_LEN(Cmnd)    ((Cmnd)->SCp.buffers_residual)
-#define CMD_SCSI_STATUS(Cmnd)  ((Cmnd)->SCp.Status)
-#define CMD_ACTUAL_SNSLEN(Cmnd)        ((Cmnd)->SCp.Message)
-#define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
-
-#endif
diff --git a/drivers/scsi/qlogicfas.h b/drivers/scsi/qlogicfas.h
deleted file mode 100644 (file)
index 6750e8d..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/* to be used by qlogicfas and qlogic_cs */
-#ifndef __QLOGICFAS_H
-#define __QLOGICFAS_H
-
-/*----------------------------------------------------------------*/
-/* Configuration */
-
-/* Set the following to 2 to use normal interrupt (active high/totempole-
-   tristate), otherwise use 0 (REQUIRED FOR PCMCIA) for active low, open
-   drain */
-
-#define QL_INT_ACTIVE_HIGH 2
-
-/* Set the following to max out the speed of the PIO PseudoDMA transfers,
-   again, 0 tends to be slower, but more stable.  */
-
-#define QL_TURBO_PDMA 1
-
-/* This should be 1 to enable parity detection */
-
-#define QL_ENABLE_PARITY 1
-
-/* This will reset all devices when the driver is initialized (during bootup).
-   The other linux drivers don't do this, but the DOS drivers do, and after
-   using DOS or some kind of crash or lockup this will bring things back
-   without requiring a cold boot.  It does take some time to recover from a
-   reset, so it is slower, and I have seen timeouts so that devices weren't
-   recognized when this was set. */
-
-#define QL_RESET_AT_START 0
-
-/* crystal frequency in megahertz (for offset 5 and 9)
-   Please set this for your card.  Most Qlogic cards are 40 Mhz.  The
-   Control Concepts ISA (not VLB) is 24 Mhz */
-
-#define XTALFREQ       40
-
-/**********/
-/* DANGER! modify these at your own risk */
-/* SLOWCABLE can usually be reset to zero if you have a clean setup and
-   proper termination.  The rest are for synchronous transfers and other
-   advanced features if your device can transfer faster than 5Mb/sec.
-   If you are really curious, email me for a quick howto until I have
-   something official */
-/**********/
-
-/*****/
-/* config register 1 (offset 8) options */
-/* This needs to be set to 1 if your cabling is long or noisy */
-#define SLOWCABLE 1
-
-/*****/
-/* offset 0xc */
-/* This will set fast (10Mhz) synchronous timing when set to 1
-   For this to have an effect, FASTCLK must also be 1 */
-#define FASTSCSI 0
-
-/* This when set to 1 will set a faster sync transfer rate */
-#define FASTCLK 0      /*(XTALFREQ>25?1:0)*/
-
-/*****/
-/* offset 6 */
-/* This is the sync transfer divisor, XTALFREQ/X will be the maximum
-   achievable data rate (assuming the rest of the system is capable
-   and set properly) */
-#define SYNCXFRPD 5    /*(XTALFREQ/5)*/
-
-/*****/
-/* offset 7 */
-/* This is the count of how many synchronous transfers can take place
-       i.e. how many reqs can occur before an ack is given.
-       The maximum value for this is 15, the upper bits can modify
-       REQ/ACK assertion and deassertion during synchronous transfers
-       If this is 0, the bus will only transfer asynchronously */
-#define SYNCOFFST 0
-/* for the curious, bits 7&6 control the deassertion delay in 1/2 cycles
-       of the 40Mhz clock. If FASTCLK is 1, specifying 01 (1/2) will
-       cause the deassertion to be early by 1/2 clock.  Bits 5&4 control
-       the assertion delay, also in 1/2 clocks (FASTCLK is ignored here). */
-
-/*----------------------------------------------------------------*/
-#ifdef PCMCIA
-#undef QL_INT_ACTIVE_HIGH
-#define QL_INT_ACTIVE_HIGH 0
-#endif
-
-struct qlogicfas_priv;
-typedef struct qlogicfas_priv *qlogicfas_priv_t;
-struct qlogicfas_priv {
-        int            qbase;          /* Port */
-        int            qinitid;        /* initiator ID */
-        int            qabort;         /* Flag to cause an abort */
-        int            qlirq;          /* IRQ being used */
-        char           qinfo[80];      /* description */
-        Scsi_Cmnd      *qlcmd;         /* current command being processed */
-        struct Scsi_Host       *shost; /* pointer back to host */
-        qlogicfas_priv_t       next;   /* next private struct */
-};
-
-extern int qlcfg5;
-extern int qlcfg6;
-extern int qlcfg7;
-extern int qlcfg8;
-extern int qlcfg9;
-extern int qlcfgc;
-
-/* The qlogic card uses two register maps - These macros select which one */
-#define REG0 ( outb( inb( qbase + 0xd ) & 0x7f , qbase + 0xd ), outb( 4 , qbase + 0xd ))
-#define REG1 ( outb( inb( qbase + 0xd ) | 0x80 , qbase + 0xd ), outb( 0xb4 | QL_INT_ACTIVE_HIGH , qbase + 0xd ))
-
-/* following is watchdog timeout in microseconds */
-#define WATCHDOG 5000000
-
-/*----------------------------------------------------------------*/
-/* the following will set the monitor border color (useful to find
-   where something crashed or gets stuck at and as a simple profiler) */
-
-#if 0
-#define rtrc(i) {inb(0x3da);outb(0x31,0x3c0);outb((i),0x3c0);}
-#else
-#define rtrc(i) {}
-#endif
-#endif /* __QLOGICFAS_H */
-
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
deleted file mode 100644 (file)
index 29248d6..0000000
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- *  sata_nv.c - NVIDIA nForce SATA
- *
- *  Copyright 2004 NVIDIA Corp.  All rights reserved.
- *  Copyright 2004 Andrew Chew
- *
- *  The contents of this file are subject to the Open
- *  Software License version 1.1 that can be found at
- *  http://www.opensource.org/licenses/osl-1.1.txt and is included herein
- *  by reference.
- *
- *  Alternatively, the contents of this file may be used under the terms
- *  of the GNU General Public License version 2 (the "GPL") as distributed
- *  in the kernel source COPYING file, in which case the provisions of
- *  the GPL are applicable instead of the above.  If you wish to allow
- *  the use of your version of this file only under the terms of the
- *  GPL and not to allow others to use your version of this file under
- *  the OSL, indicate your decision by deleting the provisions above and
- *  replace them with the notice and other provisions required by the GPL.
- *  If you do not delete the provisions above, a recipient may use your
- *  version of this file under either the OSL or the GPL.
- *
- *  0.02
- *     - Added support for CK804 SATA controller.
- *
- *  0.01
- *     - Initial revision.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/blkdev.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include "scsi.h"
-#include <scsi/scsi_host.h>
-#include <linux/libata.h>
-
-#define DRV_NAME                       "sata_nv"
-#define DRV_VERSION                    "0.02"
-
-#define NV_PORTS                       2
-#define NV_PIO_MASK                    0x1f
-#define NV_UDMA_MASK                   0x7f
-#define NV_PORT0_BMDMA_REG_OFFSET      0x00
-#define NV_PORT1_BMDMA_REG_OFFSET      0x08
-#define NV_PORT0_SCR_REG_OFFSET                0x00
-#define NV_PORT1_SCR_REG_OFFSET                0x40
-
-#define NV_INT_STATUS                  0x10
-#define NV_INT_STATUS_CK804            0x440
-#define NV_INT_STATUS_PDEV_INT         0x01
-#define NV_INT_STATUS_PDEV_PM          0x02
-#define NV_INT_STATUS_PDEV_ADDED       0x04
-#define NV_INT_STATUS_PDEV_REMOVED     0x08
-#define NV_INT_STATUS_SDEV_INT         0x10
-#define NV_INT_STATUS_SDEV_PM          0x20
-#define NV_INT_STATUS_SDEV_ADDED       0x40
-#define NV_INT_STATUS_SDEV_REMOVED     0x80
-#define NV_INT_STATUS_PDEV_HOTPLUG     (NV_INT_STATUS_PDEV_ADDED | \
-                                       NV_INT_STATUS_PDEV_REMOVED)
-#define NV_INT_STATUS_SDEV_HOTPLUG     (NV_INT_STATUS_SDEV_ADDED | \
-                                       NV_INT_STATUS_SDEV_REMOVED)
-#define NV_INT_STATUS_HOTPLUG          (NV_INT_STATUS_PDEV_HOTPLUG | \
-                                       NV_INT_STATUS_SDEV_HOTPLUG)
-
-#define NV_INT_ENABLE                  0x11
-#define NV_INT_ENABLE_CK804            0x441
-#define NV_INT_ENABLE_PDEV_MASK                0x01
-#define NV_INT_ENABLE_PDEV_PM          0x02
-#define NV_INT_ENABLE_PDEV_ADDED       0x04
-#define NV_INT_ENABLE_PDEV_REMOVED     0x08
-#define NV_INT_ENABLE_SDEV_MASK                0x10
-#define NV_INT_ENABLE_SDEV_PM          0x20
-#define NV_INT_ENABLE_SDEV_ADDED       0x40
-#define NV_INT_ENABLE_SDEV_REMOVED     0x80
-#define NV_INT_ENABLE_PDEV_HOTPLUG     (NV_INT_ENABLE_PDEV_ADDED | \
-                                       NV_INT_ENABLE_PDEV_REMOVED)
-#define NV_INT_ENABLE_SDEV_HOTPLUG     (NV_INT_ENABLE_SDEV_ADDED | \
-                                       NV_INT_ENABLE_SDEV_REMOVED)
-#define NV_INT_ENABLE_HOTPLUG          (NV_INT_ENABLE_PDEV_HOTPLUG | \
-                                       NV_INT_ENABLE_SDEV_HOTPLUG)
-
-#define NV_INT_CONFIG                  0x12
-#define NV_INT_CONFIG_METHD            0x01 // 0 = INT, 1 = SMI
-
-// For PCI config register 20
-#define NV_MCP_SATA_CFG_20             0x50
-#define NV_MCP_SATA_CFG_20_SATA_SPACE_EN       0x04
-
-static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
-irqreturn_t nv_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
-static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg);
-static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
-static void nv_host_stop (struct ata_host_set *host_set);
-static void nv_enable_hotplug(struct ata_probe_ent *probe_ent);
-static void nv_disable_hotplug(struct ata_host_set *host_set);
-static void nv_check_hotplug(struct ata_host_set *host_set);
-static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent);
-static void nv_disable_hotplug_ck804(struct ata_host_set *host_set);
-static void nv_check_hotplug_ck804(struct ata_host_set *host_set);
-
-enum nv_host_type
-{
-       NFORCE2,
-       NFORCE3,
-       CK804
-};
-
-static struct pci_device_id nv_pci_tbl[] = {
-       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 },
-       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
-       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE3 },
-       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
-       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
-       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
-       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2,
-               PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
-       { 0, } /* terminate list */
-};
-
-#define NV_HOST_FLAGS_SCR_MMIO 0x00000001
-
-struct nv_host_desc
-{
-       enum nv_host_type       host_type;
-       unsigned long           host_flags;
-       void                    (*enable_hotplug)(struct ata_probe_ent *probe_ent);
-       void                    (*disable_hotplug)(struct ata_host_set *host_set);
-       void                    (*check_hotplug)(struct ata_host_set *host_set);
-
-};
-static struct nv_host_desc nv_device_tbl[] = {
-       {
-               .host_type      = NFORCE2,
-               .host_flags     = 0x00000000,
-               .enable_hotplug = nv_enable_hotplug,
-               .disable_hotplug= nv_disable_hotplug,
-               .check_hotplug  = nv_check_hotplug,
-       },
-       {
-               .host_type      = NFORCE3,
-               .host_flags     = 0x00000000,
-               .enable_hotplug = nv_enable_hotplug,
-               .disable_hotplug= nv_disable_hotplug,
-               .check_hotplug  = nv_check_hotplug,
-       },
-       {       .host_type      = CK804,
-               .host_flags     = NV_HOST_FLAGS_SCR_MMIO,
-               .enable_hotplug = nv_enable_hotplug_ck804,
-               .disable_hotplug= nv_disable_hotplug_ck804,
-               .check_hotplug  = nv_check_hotplug_ck804,
-       },
-};
-
-struct nv_host
-{
-       struct nv_host_desc     *host_desc;
-};
-
-static struct pci_driver nv_pci_driver = {
-       .name                   = DRV_NAME,
-       .id_table               = nv_pci_tbl,
-       .probe                  = nv_init_one,
-       .remove                 = ata_pci_remove_one,
-};
-
-static Scsi_Host_Template nv_sht = {
-       .module                 = THIS_MODULE,
-       .name                   = DRV_NAME,
-       .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
-       .can_queue              = ATA_DEF_QUEUE,
-       .this_id                = ATA_SHT_THIS_ID,
-       .sg_tablesize           = ATA_MAX_PRD,
-       .max_sectors            = ATA_MAX_SECTORS,
-       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
-       .emulated               = ATA_SHT_EMULATED,
-       .use_clustering         = ATA_SHT_USE_CLUSTERING,
-       .proc_name              = DRV_NAME,
-       .dma_boundary           = ATA_DMA_BOUNDARY,
-       .slave_configure        = ata_scsi_slave_config,
-       .bios_param             = ata_std_bios_param,
-};
-
-static struct ata_port_operations nv_ops = {
-       .port_disable           = ata_port_disable,
-       .tf_load                = ata_tf_load_pio,
-       .tf_read                = ata_tf_read_pio,
-       .exec_command           = ata_exec_command_pio,
-       .check_status           = ata_check_status_pio,
-       .phy_reset              = sata_phy_reset,
-       .bmdma_setup            = ata_bmdma_setup_pio,
-       .bmdma_start            = ata_bmdma_start_pio,
-       .qc_prep                = ata_qc_prep,
-       .qc_issue               = ata_qc_issue_prot,
-       .eng_timeout            = ata_eng_timeout,
-       .irq_handler            = nv_interrupt,
-       .irq_clear              = ata_bmdma_irq_clear,
-       .scr_read               = nv_scr_read,
-       .scr_write              = nv_scr_write,
-       .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = nv_host_stop,
-};
-
-MODULE_AUTHOR("NVIDIA");
-MODULE_DESCRIPTION("low-level driver for NVIDIA nForce SATA controller");
-MODULE_LICENSE("GPL");
-MODULE_DEVICE_TABLE(pci, nv_pci_tbl);
-
-irqreturn_t nv_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
-{
-       struct ata_host_set *host_set = dev_instance;
-       struct nv_host *host = host_set->private_data;
-       unsigned int i;
-       unsigned int handled = 0;
-       unsigned long flags;
-
-       spin_lock_irqsave(&host_set->lock, flags);
-
-       for (i = 0; i < host_set->n_ports; i++) {
-               struct ata_port *ap;
-
-               ap = host_set->ports[i];
-               if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) {
-                       struct ata_queued_cmd *qc;
-
-                       qc = ata_qc_from_tag(ap, ap->active_tag);
-                       if (qc && (!(qc->tf.ctl & ATA_NIEN)))
-                               handled += ata_host_intr(ap, qc);
-               }
-
-       }
-
-       if (host->host_desc->check_hotplug)
-               host->host_desc->check_hotplug(host_set);
-
-       spin_unlock_irqrestore(&host_set->lock, flags);
-
-       return IRQ_RETVAL(handled);
-}
-
-static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
-{
-       struct ata_host_set *host_set = ap->host_set;
-       struct nv_host *host = host_set->private_data;
-
-       if (sc_reg > SCR_CONTROL)
-               return 0xffffffffU;
-
-       if (host->host_desc->host_flags & NV_HOST_FLAGS_SCR_MMIO)
-               return readl(ap->ioaddr.scr_addr + (sc_reg * 4));
-       else
-               return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
-}
-
-static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
-{
-       struct ata_host_set *host_set = ap->host_set;
-       struct nv_host *host = host_set->private_data;
-
-       if (sc_reg > SCR_CONTROL)
-               return;
-
-       if (host->host_desc->host_flags & NV_HOST_FLAGS_SCR_MMIO)
-               writel(val, ap->ioaddr.scr_addr + (sc_reg * 4));
-       else
-               outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
-}
-
-static void nv_host_stop (struct ata_host_set *host_set)
-{
-       struct nv_host *host = host_set->private_data;
-
-       // Disable hotplug event interrupts.
-       if (host->host_desc->disable_hotplug)
-               host->host_desc->disable_hotplug(host_set);
-
-       kfree(host);
-}
-
-static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-       static int printed_version = 0;
-       struct nv_host *host;
-       struct ata_probe_ent *probe_ent = NULL;
-       int rc;
-
-       if (!printed_version++)
-               printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
-
-       rc = pci_enable_device(pdev);
-       if (rc)
-               return rc;
-
-       rc = pci_request_regions(pdev, DRV_NAME);
-       if (rc)
-               goto err_out;
-
-       rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-       if (rc)
-               goto err_out_regions;
-       rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
-       if (rc)
-               goto err_out_regions;
-
-       probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (!probe_ent) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
-
-       host = kmalloc(sizeof(struct nv_host), GFP_KERNEL);
-       if (!host) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-
-       host->host_desc = &nv_device_tbl[ent->driver_data];
-
-       memset(probe_ent, 0, sizeof(*probe_ent));
-       INIT_LIST_HEAD(&probe_ent->node);
-
-       probe_ent->pdev = pdev;
-       probe_ent->sht = &nv_sht;
-       probe_ent->host_flags = ATA_FLAG_SATA |
-                               ATA_FLAG_SATA_RESET |
-                               ATA_FLAG_SRST |
-                               ATA_FLAG_NO_LEGACY;
-
-       probe_ent->port_ops = &nv_ops;
-       probe_ent->n_ports = NV_PORTS;
-       probe_ent->irq = pdev->irq;
-       probe_ent->irq_flags = SA_SHIRQ;
-       probe_ent->pio_mask = NV_PIO_MASK;
-       probe_ent->udma_mask = NV_UDMA_MASK;
-
-       probe_ent->port[0].cmd_addr = pci_resource_start(pdev, 0);
-       ata_std_ports(&probe_ent->port[0]);
-       probe_ent->port[0].altstatus_addr =
-       probe_ent->port[0].ctl_addr =
-               pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS;
-       probe_ent->port[0].bmdma_addr =
-               pci_resource_start(pdev, 4) | NV_PORT0_BMDMA_REG_OFFSET;
-
-       probe_ent->port[1].cmd_addr = pci_resource_start(pdev, 2);
-       ata_std_ports(&probe_ent->port[1]);
-       probe_ent->port[1].altstatus_addr =
-       probe_ent->port[1].ctl_addr =
-               pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS;
-       probe_ent->port[1].bmdma_addr =
-               pci_resource_start(pdev, 4) | NV_PORT1_BMDMA_REG_OFFSET;
-
-       probe_ent->private_data = host;
-
-       if (host->host_desc->host_flags & NV_HOST_FLAGS_SCR_MMIO) {
-               unsigned long base;
-
-               probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5),
-                               pci_resource_len(pdev, 5));
-               if (probe_ent->mmio_base == NULL)
-                       goto err_out_free_ent;
-
-               base = (unsigned long)probe_ent->mmio_base;
-
-               probe_ent->port[0].scr_addr =
-                       base + NV_PORT0_SCR_REG_OFFSET;
-               probe_ent->port[1].scr_addr =
-                       base + NV_PORT1_SCR_REG_OFFSET;
-       } else {
-
-               probe_ent->port[0].scr_addr =
-                       pci_resource_start(pdev, 5) | NV_PORT0_SCR_REG_OFFSET;
-               probe_ent->port[1].scr_addr =
-                       pci_resource_start(pdev, 5) | NV_PORT1_SCR_REG_OFFSET;
-       }
-
-       pci_set_master(pdev);
-
-       // Enable hotplug event interrupts.
-       if (host->host_desc->enable_hotplug)
-               host->host_desc->enable_hotplug(probe_ent);
-
-       rc = ata_device_add(probe_ent);
-       if (rc != NV_PORTS)
-               goto err_out_free_ent;
-
-       kfree(probe_ent);
-
-       return 0;
-
-err_out_free_ent:
-       kfree(probe_ent);
-
-err_out_regions:
-       pci_release_regions(pdev);
-
-err_out:
-       pci_disable_device(pdev);
-       return rc;
-}
-
-static void nv_enable_hotplug(struct ata_probe_ent *probe_ent)
-{
-       u8 intr_mask;
-
-       outb(NV_INT_STATUS_HOTPLUG,
-               (unsigned long)probe_ent->mmio_base + NV_INT_STATUS);
-
-       intr_mask = inb((unsigned long)probe_ent->mmio_base + NV_INT_ENABLE);
-       intr_mask |= NV_INT_ENABLE_HOTPLUG;
-
-       outb(intr_mask, (unsigned long)probe_ent->mmio_base + NV_INT_ENABLE);
-}
-
-static void nv_disable_hotplug(struct ata_host_set *host_set)
-{
-       u8 intr_mask;
-
-       intr_mask = inb((unsigned long)host_set->mmio_base + NV_INT_ENABLE);
-
-       intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
-
-       outb(intr_mask, (unsigned long)host_set->mmio_base + NV_INT_ENABLE);
-}
-
-static void nv_check_hotplug(struct ata_host_set *host_set)
-{
-       u8 intr_status;
-
-       intr_status = inb((unsigned long)host_set->mmio_base + NV_INT_STATUS);
-
-       // Clear interrupt status.
-       outb(0xff, (unsigned long)host_set->mmio_base + NV_INT_STATUS);
-
-       if (intr_status & NV_INT_STATUS_HOTPLUG) {
-               if (intr_status & NV_INT_STATUS_PDEV_ADDED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Primary device added\n");
-
-               if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Primary device removed\n");
-
-               if (intr_status & NV_INT_STATUS_SDEV_ADDED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Secondary device added\n");
-
-               if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Secondary device removed\n");
-       }
-}
-
-static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent)
-{
-       u8 intr_mask;
-       u8 regval;
-
-       pci_read_config_byte(probe_ent->pdev, NV_MCP_SATA_CFG_20, &regval);
-       regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
-       pci_write_config_byte(probe_ent->pdev, NV_MCP_SATA_CFG_20, regval);
-
-       writeb(NV_INT_STATUS_HOTPLUG, probe_ent->mmio_base + NV_INT_STATUS_CK804);
-
-       intr_mask = readb(probe_ent->mmio_base + NV_INT_ENABLE_CK804);
-       intr_mask |= NV_INT_ENABLE_HOTPLUG;
-
-       writeb(intr_mask, probe_ent->mmio_base + NV_INT_ENABLE_CK804);
-}
-
-static void nv_disable_hotplug_ck804(struct ata_host_set *host_set)
-{
-       u8 intr_mask;
-       u8 regval;
-
-       intr_mask = readb(host_set->mmio_base + NV_INT_ENABLE_CK804);
-
-       intr_mask &= ~(NV_INT_ENABLE_HOTPLUG);
-
-       writeb(intr_mask, host_set->mmio_base + NV_INT_ENABLE_CK804);
-
-       pci_read_config_byte(host_set->pdev, NV_MCP_SATA_CFG_20, &regval);
-       regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN;
-       pci_write_config_byte(host_set->pdev, NV_MCP_SATA_CFG_20, regval);
-}
-
-static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
-{
-       u8 intr_status;
-
-       intr_status = readb(host_set->mmio_base + NV_INT_STATUS_CK804);
-
-       // Clear interrupt status.
-       writeb(0xff, host_set->mmio_base + NV_INT_STATUS_CK804);
-
-       if (intr_status & NV_INT_STATUS_HOTPLUG) {
-               if (intr_status & NV_INT_STATUS_PDEV_ADDED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Primary device added\n");
-
-               if (intr_status & NV_INT_STATUS_PDEV_REMOVED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Primary device removed\n");
-
-               if (intr_status & NV_INT_STATUS_SDEV_ADDED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Secondary device added\n");
-
-               if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
-                       printk(KERN_WARNING "nv_sata: "
-                               "Secondary device removed\n");
-       }
-}
-
-static int __init nv_init(void)
-{
-       return pci_module_init(&nv_pci_driver);
-}
-
-static void __exit nv_exit(void)
-{
-       pci_unregister_driver(&nv_pci_driver);
-}
-
-module_init(nv_init);
-module_exit(nv_exit);
diff --git a/drivers/scsi/scsi_pc98.c b/drivers/scsi/scsi_pc98.c
deleted file mode 100644 (file)
index 13fdfa9..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *  Copyright (C) 2003  Osamu Tomita <tomita@cinet.co.jp>
- *
- *  PC9801 BIOS geometry handling.
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/genhd.h>
-#include <linux/blkdev.h>
-#include <asm/pc9800.h>
-
-#include "scsi.h"
-#include "hosts.h"
-
-
-static int pc98_first_bios_param(struct scsi_device *sdev, int *ip)
-{
-       const u8 *p = (&__PC9800SCA(u8, PC9800SCA_SCSI_PARAMS) + sdev->id * 4);
-
-       ip[0] = p[1];   /* # of heads */
-       ip[1] = p[0];   /* # of sectors/track */
-       ip[2] = *(u16 *)&p[2] & 0x0fff; /* # of cylinders */
-       if (p[3] & (1 << 6)) { /* #-of-cylinders is 16-bit */
-               ip[2] |= (ip[0] & 0xf0) << 8;
-               ip[0] &= 0x0f;
-       }
-
-       return 0;
-}
-
-int pc98_bios_param(struct scsi_device *sdev, struct block_device *bdev,
-                       sector_t capacity, int *ip)
-{
-       struct Scsi_Host *first_real = first_real_host();
-
-       /*
-        * XXX
-        * XXX This needs to become a sysfs attribute that's set
-        * XXX by code that knows which host is the first one.
-        * XXX
-        * XXX Currently we support only one host on with a
-        * XXX PC98ish HBA.
-        * XXX
-        */
-       if (1 || sdev->host == first_real && sdev->id < 7 &&
-           __PC9800SCA_TEST_BIT(PC9800SCA_DISK_EQUIPS, sdev->id))
-               return pc98_first_bios_param(sdev, ip);
-
-       /* Assume PC-9801-92 compatible parameters for HAs without BIOS.  */
-       ip[0] = 8;
-       ip[1] = 32;
-       ip[2] = capacity / (8 * 32);
-       if (ip[2] > 65535) {    /* if capacity >= 8GB */
-               /* Recent on-board adapters seem to use this parameter. */
-               ip[1] = 128;
-               ip[2] = capacity / (8 * 128);
-               if (ip[2] > 65535) { /* if capacity >= 32GB  */
-                       /* Clip the number of cylinders.  Currently
-                          this is the limit that we deal with.  */
-                       ip[2] = 65535;
-               }
-       }
-
-       return 0;
-}
-
-EXPORT_SYMBOL(pc98_bios_param);
index 7b0665d..80dbb14 100644 (file)
@@ -241,6 +241,12 @@ sg_open(struct inode *inode, struct file *filp)
                return -ENXIO;
        if (sdp->detached)
                return -ENODEV;
+               
+       /* scsi generic is only for non-disk, non-cd, non-tape devices */       
+       if ( (sdp->device->type == TYPE_DISK) || (sdp->device->type == TYPE_MOD) || (sdp->device->type == TYPE_ROM) 
+          || (sdp->device->type == TYPE_WORM) || ( sdp->device->type == TYPE_TAPE))
+               printk(KERN_WARNING "%s: Using deprecated /dev/sg mechanism instead of SG_IO on the actual device\n",current->comm);
+               
 
        /* This driver's module count bumped by fops_get in <linux/fs.h> */
        /* Prevent the device driver from vanishing while we sleep */
diff --git a/drivers/serial/8250_hcdp.c b/drivers/serial/8250_hcdp.c
deleted file mode 100644 (file)
index e7b573f..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * linux/drivers/char/hcdp_serial.c
- *
- * Copyright (C) 2002 Hewlett-Packard Co.
- *     Khalid Aziz <khalid_aziz@hp.com>
- *
- * Parse the EFI HCDP table to locate serial console and debug ports and
- * initialize them.
- *
- * 2002/08/29 davidm   Adjust it to new 2.5 serial driver infrastructure.
- */
-
-#include <linux/config.h>
-#include <linux/console.h>
-#include <linux/kernel.h>
-#include <linux/efi.h>
-#include <linux/init.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/serial_core.h>
-#include <linux/types.h>
-#include <linux/acpi.h>
-
-#include <asm/io.h>
-#include <asm/serial.h>
-#include <asm/acpi.h>
-
-#include "8250_hcdp.h"
-
-#undef SERIAL_DEBUG_HCDP
-
-/*
- * Parse the HCDP table to find descriptions for headless console and debug
- * serial ports and add them to rs_table[]. A pointer to HCDP table is
- * passed as parameter. This function should be called before
- * serial_console_init() is called to make sure the HCDP serial console will
- * be available for use. IA-64 kernel calls this function from setup_arch()
- * after the EFI and ACPI tables have been parsed.
- */
-void __init
-setup_serial_hcdp(void *tablep)
-{
-       hcdp_dev_t *hcdp_dev;
-       struct uart_port port;
-       unsigned long iobase;
-       hcdp_t hcdp;
-       int gsi, nr;
-       static char options[16];
-#if 0
-       static int shift_once = 1;
-#endif
-
-#ifdef SERIAL_DEBUG_HCDP
-       printk("Entering setup_serial_hcdp()\n");
-#endif
-
-       /* Verify we have a valid table pointer */
-       if (!tablep)
-               return;
-
-       memset(&port, 0, sizeof(port));
-
-       /*
-        * Don't trust firmware to give us a table starting at an aligned
-        * address. Make a local copy of the HCDP table with aligned
-        * structures.
-        */
-       memcpy(&hcdp, tablep, sizeof(hcdp));
-
-       /*
-        * Perform a sanity check on the table. Table should have a signature
-        * of "HCDP" and it should be atleast 82 bytes long to have any
-        * useful information.
-        */
-       if ((strncmp(hcdp.signature, HCDP_SIGNATURE, HCDP_SIG_LEN) != 0))
-               return;
-       if (hcdp.len < 82)
-               return;
-
-#ifdef SERIAL_DEBUG_HCDP
-       printk("setup_serial_hcdp(): table pointer = 0x%p, sig = '%.4s'\n",
-              tablep, hcdp.signature);
-       printk(" length = %d, rev = %d, ", hcdp.len, hcdp.rev);
-       printk("OEM ID = %.6s, # of entries = %d\n", hcdp.oemid,
-                       hcdp.num_entries);
-#endif
-
-       /*
-        * Parse each device entry
-        */
-       for (nr = 0; nr < hcdp.num_entries; nr++) {
-               hcdp_dev = hcdp.hcdp_dev + nr;
-               /*
-                * We will parse only the primary console device which is
-                * the first entry for these devices. We will ignore rest
-                * of the entries for the same type device that has already
-                * been parsed and initialized
-                */
-               if (hcdp_dev->type != HCDP_DEV_CONSOLE)
-                       continue;
-
-               iobase = ((u64) hcdp_dev->base_addr.addrhi << 32) |
-                                       hcdp_dev->base_addr.addrlo;
-               gsi = hcdp_dev->global_int;
-
-               /* See PCI spec v2.2, Appendix D (Class Codes): */
-               switch (hcdp_dev->pci_prog_intfc) {
-               case 0x00:
-                       port.type = PORT_8250;
-                       break;
-               case 0x01:
-                       port.type = PORT_16450;
-                       break;
-               case 0x02:
-                       port.type = PORT_16550;
-                       break;
-               case 0x03:
-                       port.type = PORT_16650;
-                       break;
-               case 0x04:
-                       port.type = PORT_16750;
-                       break;
-               case 0x05:
-                       port.type = PORT_16850;
-                       break;
-               case 0x06:
-                       port.type = PORT_16C950;
-                       break;
-               default:
-                       printk(KERN_WARNING "warning: EFI HCDP table reports "
-                               "unknown serial programming interface 0x%02x; "
-                               "will autoprobe.\n", hcdp_dev->pci_prog_intfc);
-                       port.type = PORT_UNKNOWN;
-                       break;
-               }
-
-#ifdef SERIAL_DEBUG_HCDP
-               printk("  type = %s, uart = %d\n",
-                       ((hcdp_dev->type == HCDP_DEV_CONSOLE) ?
-                       "Headless Console" :
-                       ((hcdp_dev->type == HCDP_DEV_DEBUG) ?
-                       "Debug port" : "Huh????")), port.type);
-               printk("  base address space = %s, base address = 0x%lx\n",
-                      ((hcdp_dev->base_addr.space_id == ACPI_MEM_SPACE) ?
-                      "Memory Space" :
-                       ((hcdp_dev->base_addr.space_id == ACPI_IO_SPACE) ?
-                       "I/O space" : "PCI space")),
-                      iobase);
-               printk("  gsi = %d, baud rate = %lu, bits = %d, clock = %d\n",
-                      gsi, (unsigned long) hcdp_dev->baud, hcdp_dev->bits,
-                      hcdp_dev->clock_rate);
-               if (HCDP_PCI_UART(hcdp_dev))
-                       printk(" PCI id: %02x:%02x:%02x, vendor ID=0x%x, "
-                               "dev ID=0x%x\n", hcdp_dev->pci_seg,
-                               hcdp_dev->pci_bus, hcdp_dev->pci_dev,
-                               hcdp_dev->pci_vendor_id, hcdp_dev->pci_dev_id);
-#endif
-               /*
-                * Now fill in a port structure to update the 8250 port table..
-                */
-               if (hcdp_dev->clock_rate)
-                       port.uartclk = hcdp_dev->clock_rate;
-               else
-                       port.uartclk = BASE_BAUD * 16;
-
-               /*
-                * Check if this is an I/O mapped address or a memory mapped
-                * address
-                */
-               if (hcdp_dev->base_addr.space_id == ACPI_MEM_SPACE) {
-                       port.iobase = 0;
-                       port.mapbase = iobase;
-                       port.membase = ioremap(iobase, 64);
-                       port.iotype = SERIAL_IO_MEM;
-               } else if (hcdp_dev->base_addr.space_id == ACPI_IO_SPACE) {
-                       port.iobase = iobase;
-                       port.mapbase = 0;
-                       port.membase = NULL;
-                       port.iotype = SERIAL_IO_PORT;
-               } else if (hcdp_dev->base_addr.space_id == ACPI_PCICONF_SPACE) {
-                       printk(KERN_WARNING"warning: No support for PCI serial console\n");
-                       return;
-               }
-
-               if (HCDP_IRQ_SUPPORTED(hcdp_dev)) {
-#ifdef CONFIG_IA64
-                       if (HCDP_PCI_UART(hcdp_dev))
-                               port.irq = acpi_register_irq(gsi,
-                                       ACPI_ACTIVE_LOW, ACPI_LEVEL_SENSITIVE);
-                       else
-                               port.irq = acpi_register_irq(gsi,
-                                       ACPI_ACTIVE_HIGH, ACPI_EDGE_SENSITIVE);
-#else
-                       port.irq = gsi;
-#endif
-                       port.flags |= UPF_AUTO_IRQ;
-
-                       if (HCDP_PCI_UART(hcdp_dev))
-                               port.flags |= UPF_SHARE_IRQ;
-               }
-
-               port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_RESOURCES;
-
-               /*
-                * Note: the above memset() initializes port.line to 0,
-                * so we register this port as ttyS0.
-                */
-               if (early_serial_setup(&port) < 0) {
-                       printk("setup_serial_hcdp(): early_serial_setup() "
-                               "for HCDP serial console port failed. "
-                               "Will try any additional consoles in HCDP.\n");
-                       memset(&port, 0, sizeof(port));
-                       continue;
-               }
-
-               if (efi_uart_console_only()) {
-                       snprintf(options, sizeof(options), "%lun%d",
-                               hcdp_dev->baud, hcdp_dev->bits);
-                       add_preferred_console("ttyS", port.line, options);
-               }
-               break;
-       }
-
-#ifdef SERIAL_DEBUG_HCDP
-       printk("Leaving setup_serial_hcdp()\n");
-#endif
-}
-
-#ifdef CONFIG_IA64_EARLY_PRINTK_UART
-unsigned long
-hcdp_early_uart (void)
-{
-       efi_system_table_t *systab;
-       efi_config_table_t *config_tables;
-       unsigned long addr = 0;
-       hcdp_t *hcdp = 0;
-       hcdp_dev_t *dev;
-       int i;
-
-       systab = (efi_system_table_t *) ia64_boot_param->efi_systab;
-       if (!systab)
-               return 0;
-       systab = __va(systab);
-
-       config_tables = (efi_config_table_t *) systab->tables;
-       if (!config_tables)
-               return 0;
-       config_tables = __va(config_tables);
-
-       for (i = 0; i < systab->nr_tables; i++) {
-               if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
-                       hcdp = (hcdp_t *) config_tables[i].table;
-                       break;
-               }
-       }
-       if (!hcdp)
-               return 0;
-       hcdp = __va(hcdp);
-
-       for (i = 0, dev = hcdp->hcdp_dev; i < hcdp->num_entries; i++, dev++) {
-               if (dev->type == HCDP_DEV_CONSOLE) {
-                       addr = (u64) dev->base_addr.addrhi << 32 | dev->base_addr.addrlo;
-                       break;
-               }
-       }
-       return addr;
-}
-#endif /* CONFIG_IA64_EARLY_PRINTK_UART */
diff --git a/drivers/serial/8250_hcdp.h b/drivers/serial/8250_hcdp.h
deleted file mode 100644 (file)
index fa956a1..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * drivers/serial/8250_hcdp.h
- *
- * Copyright (C) 2002 Hewlett-Packard Co.
- *     Khalid Aziz <khalid_aziz@hp.com>
- *
- * Definitions for HCDP defined serial ports (Serial console and debug
- * ports)
- */
-
-/* ACPI table signatures */
-#define HCDP_SIG_LEN           4
-#define HCDP_SIGNATURE         "HCDP"
-
-/* Space ID as defined in ACPI generic address structure */
-#define ACPI_MEM_SPACE         0
-#define ACPI_IO_SPACE          1
-#define ACPI_PCICONF_SPACE     2
-
-/*
- * Maximum number of HCDP devices we want to read in
- */
-#define MAX_HCDP_DEVICES       6
-
-/*
- * Default UART clock rate if clock rate is 0 in HCDP table.
- */
-#define DEFAULT_UARTCLK                115200
-
-/*
- * ACPI Generic Address Structure
- */
-typedef struct {
-       u8  space_id;
-       u8  bit_width;
-       u8  bit_offset;
-       u8  resv;
-       u32 addrlo;
-       u32 addrhi;
-} acpi_gen_addr;
-
-/* HCDP Device descriptor entry types */
-#define HCDP_DEV_CONSOLE       0
-#define HCDP_DEV_DEBUG         1
-
-/* HCDP Device descriptor type */
-typedef struct {
-       u8      type;
-       u8      bits;
-       u8      parity;
-       u8      stop_bits;
-       u8      pci_seg;
-       u8      pci_bus;
-       u8      pci_dev;
-       u8      pci_func;
-       u64     baud;
-       acpi_gen_addr   base_addr;
-       u16     pci_dev_id;
-       u16     pci_vendor_id;
-       u32     global_int;
-       u32     clock_rate;
-       u8      pci_prog_intfc;
-       u8      resv;
-} hcdp_dev_t;
-
-/* HCDP Table format */
-typedef struct {
-       u8      signature[4];
-       u32     len;
-       u8      rev;
-       u8      chksum;
-       u8      oemid[6];
-       u8      oem_tabid[8];
-       u32     oem_rev;
-       u8      creator_id[4];
-       u32     creator_rev;
-       u32     num_entries;
-       hcdp_dev_t      hcdp_dev[MAX_HCDP_DEVICES];
-} hcdp_t;
-
-#define HCDP_PCI_UART(x) (x->pci_func & 1UL<<7)
-#define HCDP_IRQ_SUPPORTED(x) (x->pci_func & 1UL<<6)
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
deleted file mode 100644 (file)
index 34f4c67..0000000
+++ /dev/null
@@ -1,1156 +0,0 @@
-/*
- *  linux/drivers/serial/cpm_uart.c
- *
- *  Driver for CPM (SCC/SMC) serial ports; core driver
- *
- *  Based on arch/ppc/cpm2_io/uart.c by Dan Malek
- *  Based on ppc8xx.c by Thomas Gleixner
- *  Based on drivers/serial/amba.c by Russell King
- *
- *  Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2)
- *              Pantelis Antoniou (panto@intracom.gr) (CPM1)
- * 
- *  Copyright (C) 2004 Freescale Semiconductor, Inc.
- *            (C) 2004 Intracom, S.A.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/device.h>
-#include <linux/bootmem.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/delay.h>
-
-#if defined(CONFIG_SERIAL_CPM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-#include <linux/kernel.h>
-
-#include "cpm_uart.h"
-
-/***********************************************************************/
-
-/* Track which ports are configured as uarts */
-int cpm_uart_port_map[UART_NR];
-/* How many ports did we config as uarts */
-int cpm_uart_nr;
-
-/**************************************************************/
-
-static int  cpm_uart_tx_pump(struct uart_port *port);
-static void cpm_uart_init_smc(struct uart_cpm_port *pinfo);
-static void cpm_uart_init_scc(struct uart_cpm_port *pinfo);
-static void cpm_uart_initbd(struct uart_cpm_port *pinfo);
-
-/**************************************************************/
-
-/*
- * Check, if transmit buffers are processed            
-*/
-static unsigned int cpm_uart_tx_empty(struct uart_port *port)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       volatile cbd_t *bdp = pinfo->tx_bd_base;
-       int ret = 0;
-
-       while (1) {
-               if (bdp->cbd_sc & BD_SC_READY)
-                       break;
-
-               if (bdp->cbd_sc & BD_SC_WRAP) {
-                       ret = TIOCSER_TEMT;
-                       break;
-               }
-               bdp++;
-       }
-
-       pr_debug("CPM uart[%d]:tx_empty: %d\n", port->line, ret);
-
-       return ret;
-}
-
-static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
-{
-       /* Whee. Do nothing. */
-}
-
-static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
-{
-       /* Whee. Do nothing. */
-       return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
-}
-
-/*
- * Stop transmitter
- */
-static void cpm_uart_stop_tx(struct uart_port *port, unsigned int tty_stop)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       volatile smc_t *smcp = pinfo->smcp;
-       volatile scc_t *sccp = pinfo->sccp;
-
-       pr_debug("CPM uart[%d]:stop tx\n", port->line);
-
-       if (IS_SMC(pinfo))
-               smcp->smc_smcm &= ~SMCM_TX;
-       else
-               sccp->scc_sccm &= ~UART_SCCM_TX;
-}
-
-/*
- * Start transmitter
- */
-static void cpm_uart_start_tx(struct uart_port *port, unsigned int tty_start)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       volatile smc_t *smcp = pinfo->smcp;
-       volatile scc_t *sccp = pinfo->sccp;
-
-       pr_debug("CPM uart[%d]:start tx\n", port->line);
-
-       if (IS_SMC(pinfo)) {
-               if (smcp->smc_smcm & SMCM_TX)
-                       return;
-       } else {
-               if (sccp->scc_sccm & UART_SCCM_TX)
-                       return;
-       }
-
-       if (cpm_uart_tx_pump(port) != 0) {
-               if (IS_SMC(pinfo))
-                       smcp->smc_smcm |= SMCM_TX;
-               else
-                       sccp->scc_sccm |= UART_SCCM_TX;
-       }
-}
-
-/*
- * Stop receiver 
- */
-static void cpm_uart_stop_rx(struct uart_port *port)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       volatile smc_t *smcp = pinfo->smcp;
-       volatile scc_t *sccp = pinfo->sccp;
-
-       pr_debug("CPM uart[%d]:stop rx\n", port->line);
-
-       if (IS_SMC(pinfo))
-               smcp->smc_smcm &= ~SMCM_RX;
-       else
-               sccp->scc_sccm &= ~UART_SCCM_RX;
-}
-
-/*
- * Enable Modem status interrupts
- */
-static void cpm_uart_enable_ms(struct uart_port *port)
-{
-       pr_debug("CPM uart[%d]:enable ms\n", port->line);
-}
-
-/*
- * Generate a break. 
- */
-static void cpm_uart_break_ctl(struct uart_port *port, int break_state)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       int line = pinfo - cpm_uart_ports;
-
-       pr_debug("CPM uart[%d]:break ctrl, break_state: %d\n", port->line,
-               break_state);
-
-       if (break_state)
-               cpm_line_cr_cmd(line, CPM_CR_STOP_TX);
-       else
-               cpm_line_cr_cmd(line, CPM_CR_RESTART_TX);
-}
-
-/*
- * Transmit characters, refill buffer descriptor, if possible
- */
-static void cpm_uart_int_tx(struct uart_port *port, struct pt_regs *regs)
-{
-       pr_debug("CPM uart[%d]:TX INT\n", port->line);
-
-       cpm_uart_tx_pump(port);
-}
-
-/*
- * Receive characters
- */
-static void cpm_uart_int_rx(struct uart_port *port, struct pt_regs *regs)
-{
-       int i;
-       unsigned char ch, *cp;
-       struct tty_struct *tty = port->info->tty;
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       volatile cbd_t *bdp;
-       u16 status;
-       unsigned int flg;
-
-       pr_debug("CPM uart[%d]:RX INT\n", port->line);
-
-       /* Just loop through the closed BDs and copy the characters into
-        * the buffer.
-        */
-       bdp = pinfo->rx_cur;
-       for (;;) {
-               /* get status */
-               status = bdp->cbd_sc;
-               /* If this one is empty, return happy */
-               if (status & BD_SC_EMPTY)
-                       break;
-
-               /* get number of characters, and check spce in flip-buffer */
-               i = bdp->cbd_datlen;
-
-               /* If we have not enough room in tty flip buffer, then we try 
-                * later, which will be the next rx-interrupt or a timeout
-                */
-               if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE) {
-                       tty->flip.work.func((void *)tty);
-                       if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE) {
-                               printk(KERN_WARNING "TTY_DONT_FLIP set\n");
-                               return;
-                       }
-               }
-
-               /* get pointer */
-               cp = (unsigned char *)bus_to_virt(bdp->cbd_bufaddr);
-
-               /* loop through the buffer */
-               while (i-- > 0) {
-                       ch = *cp++;
-                       port->icount.rx++;
-                       flg = TTY_NORMAL;
-
-                       if (status &
-                           (BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV))
-                               goto handle_error;
-                       if (uart_handle_sysrq_char(port, ch, regs))
-                               continue;
-
-                     error_return:
-                       *tty->flip.char_buf_ptr++ = ch;
-                       *tty->flip.flag_buf_ptr++ = flg;
-                       tty->flip.count++;
-
-               }               /* End while (i--) */
-
-               /* This BD is ready to be used again. Clear status. get next */
-               bdp->cbd_sc &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-               bdp->cbd_sc |= BD_SC_EMPTY;
-
-               if (bdp->cbd_sc & BD_SC_WRAP)
-                       bdp = pinfo->rx_bd_base;
-               else
-                       bdp++;
-       } /* End for (;;) */
-
-       /* Write back buffer pointer */
-       pinfo->rx_cur = (volatile cbd_t *) bdp;
-
-       /* activate BH processing */
-       tty_flip_buffer_push(tty);
-
-       return;
-
-       /* Error processing */
-
-      handle_error:
-       /* Statistics */
-       if (status & BD_SC_BR)
-               port->icount.brk++;
-       if (status & BD_SC_PR)
-               port->icount.parity++;
-       if (status & BD_SC_FR)
-               port->icount.frame++;
-       if (status & BD_SC_OV)
-               port->icount.overrun++;
-
-       /* Mask out ignored conditions */
-       status &= port->read_status_mask;
-
-       /* Handle the remaining ones */
-       if (status & BD_SC_BR)
-               flg = TTY_BREAK;
-       else if (status & BD_SC_PR)
-               flg = TTY_PARITY;
-       else if (status & BD_SC_FR)
-               flg = TTY_FRAME;
-
-       /* overrun does not affect the current character ! */
-       if (status & BD_SC_OV) {
-               ch = 0;
-               flg = TTY_OVERRUN;
-               /* We skip this buffer */
-               /* CHECK: Is really nothing senseful there */
-               /* ASSUMPTION: it contains nothing valid */
-               i = 0;
-       }
-#ifdef SUPPORT_SYSRQ
-       port->sysrq = 0;
-#endif
-       goto error_return;
-}
-
-/*
- * Asynchron mode interrupt handler
- */
-static irqreturn_t cpm_uart_int(int irq, void *data, struct pt_regs *regs)
-{
-       u8 events;
-       struct uart_port *port = (struct uart_port *)data;
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       volatile smc_t *smcp = pinfo->smcp;
-       volatile scc_t *sccp = pinfo->sccp;
-
-       pr_debug("CPM uart[%d]:IRQ\n", port->line);
-
-       if (IS_SMC(pinfo)) {
-               events = smcp->smc_smce;
-               if (events & SMCM_BRKE)
-                       uart_handle_break(port);
-               if (events & SMCM_RX)
-                       cpm_uart_int_rx(port, regs);
-               if (events & SMCM_TX)
-                       cpm_uart_int_tx(port, regs);
-               smcp->smc_smce = events;
-       } else {
-               events = sccp->scc_scce;
-               if (events & UART_SCCM_BRKE)
-                       uart_handle_break(port);
-               if (events & UART_SCCM_RX)
-                       cpm_uart_int_rx(port, regs);
-               if (events & UART_SCCM_TX)
-                       cpm_uart_int_tx(port, regs);
-               sccp->scc_scce = events;
-       }
-       return (events) ? IRQ_HANDLED : IRQ_NONE;
-}
-
-static int cpm_uart_startup(struct uart_port *port)
-{
-       int retval;
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-
-       pr_debug("CPM uart[%d]:startup\n", port->line);
-
-       /* Install interrupt handler. */
-       retval = request_irq(port->irq, cpm_uart_int, 0, "cpm_uart", port);
-       if (retval)
-               return retval;
-
-       /* Startup rx-int */
-       if (IS_SMC(pinfo)) {
-               pinfo->smcp->smc_smcm |= SMCM_RX;
-               pinfo->smcp->smc_smcmr |= SMCMR_REN;
-       } else {
-               pinfo->sccp->scc_sccm |= UART_SCCM_RX;
-       }
-
-       return 0;
-}
-
-/*
- * Shutdown the uart
- */
-static void cpm_uart_shutdown(struct uart_port *port)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       int line = pinfo - cpm_uart_ports;
-
-       pr_debug("CPM uart[%d]:shutdown\n", port->line);
-
-       /* free interrupt handler */
-       free_irq(port->irq, port);
-
-       /* If the port is not the console, disable Rx and Tx. */
-       if (!(pinfo->flags & FLAG_CONSOLE)) {
-               /* Stop uarts */
-               if (IS_SMC(pinfo)) {
-                       volatile smc_t *smcp = pinfo->smcp;
-                       smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-                       smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
-               } else {
-                       volatile scc_t *sccp = pinfo->sccp;
-                       sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-                       sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
-               }
-
-               /* Shut them really down and reinit buffer descriptors */
-               cpm_line_cr_cmd(line, CPM_CR_STOP_TX);
-               cpm_uart_initbd(pinfo);
-       }
-}
-
-static void cpm_uart_set_termios(struct uart_port *port,
-                                struct termios *termios, struct termios *old)
-{
-       int baud;
-       unsigned long flags;
-       u16 cval, scval, prev_mode;
-       int bits, sbits;
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       volatile smc_t *smcp = pinfo->smcp;
-       volatile scc_t *sccp = pinfo->sccp;
-
-       pr_debug("CPM uart[%d]:set_termios\n", port->line);
-
-       baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16);
-
-       /* Character length programmed into the mode register is the
-        * sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
-        * 1 or 2 stop bits, minus 1.
-        * The value 'bits' counts this for us.
-        */
-       cval = 0;
-       scval = 0;
-
-       /* byte size */
-       switch (termios->c_cflag & CSIZE) {
-       case CS5:
-               bits = 5;
-               break;
-       case CS6:
-               bits = 6;
-               break;
-       case CS7:
-               bits = 7;
-               break;
-       case CS8:
-               bits = 8;
-               break;
-               /* Never happens, but GCC is too dumb to figure it out */
-       default:
-               bits = 8;
-               break;
-       }
-       sbits = bits - 5;
-
-       if (termios->c_cflag & CSTOPB) {
-               cval |= SMCMR_SL;       /* Two stops */
-               scval |= SCU_PSMR_SL;
-               bits++;
-       }
-
-       if (termios->c_cflag & PARENB) {
-               cval |= SMCMR_PEN;
-               scval |= SCU_PSMR_PEN;
-               bits++;
-               if (!(termios->c_cflag & PARODD)) {
-                       cval |= SMCMR_PM_EVEN;
-                       scval |= (SCU_PSMR_REVP | SCU_PSMR_TEVP);
-               }
-       }
-
-       /*
-        * Set up parity check flag
-        */
-#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
-       port->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
-       if (termios->c_iflag & INPCK)
-               port->read_status_mask |= BD_SC_FR | BD_SC_PR;
-       if ((termios->c_iflag & BRKINT) || (termios->c_iflag & PARMRK))
-               port->read_status_mask |= BD_SC_BR;
-
-       /*
-        * Characters to ignore
-        */
-       port->ignore_status_mask = 0;
-       if (termios->c_iflag & IGNPAR)
-               port->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
-       if (termios->c_iflag & IGNBRK) {
-               port->ignore_status_mask |= BD_SC_BR;
-               /*
-                * If we're ignore parity and break indicators, ignore
-                * overruns too.  (For real raw support).
-                */
-               if (termios->c_iflag & IGNPAR)
-                       port->ignore_status_mask |= BD_SC_OV;
-       }
-       /*
-        * !!! ignore all characters if CREAD is not set
-        */
-       if ((termios->c_cflag & CREAD) == 0)
-               port->read_status_mask &= ~BD_SC_EMPTY;
-       
-       spin_lock_irqsave(&port->lock, flags);
-
-       /* Start bit has not been added (so don't, because we would just
-        * subtract it later), and we need to add one for the number of
-        * stops bits (there is always at least one).
-        */
-       bits++;
-       if (IS_SMC(pinfo)) {
-               /* Set the mode register.  We want to keep a copy of the
-                * enables, because we want to put them back if they were
-                * present.
-                */
-               prev_mode = smcp->smc_smcmr;
-               smcp->smc_smcmr = smcr_mk_clen(bits) | cval | SMCMR_SM_UART;
-               smcp->smc_smcmr |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
-       } else {
-               sccp->scc_psmr = (sbits << 12) | scval;
-       }
-
-       cpm_set_brg(pinfo->brg - 1, baud);
-       spin_unlock_irqrestore(&port->lock, flags);
-
-}
-
-static const char *cpm_uart_type(struct uart_port *port)
-{
-       pr_debug("CPM uart[%d]:uart_type\n", port->line);
-
-       return port->type == PORT_CPM ? "CPM UART" : NULL;
-}
-
-/*
- * verify the new serial_struct (for TIOCSSERIAL).
- */
-static int cpm_uart_verify_port(struct uart_port *port,
-                               struct serial_struct *ser)
-{
-       int ret = 0;
-
-       pr_debug("CPM uart[%d]:verify_port\n", port->line);
-
-       if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM)
-               ret = -EINVAL;
-       if (ser->irq < 0 || ser->irq >= NR_IRQS)
-               ret = -EINVAL;
-       if (ser->baud_base < 9600)
-               ret = -EINVAL;
-       return ret;
-}
-
-/*
- * Transmit characters, refill buffer descriptor, if possible
- */
-static int cpm_uart_tx_pump(struct uart_port *port)
-{
-       volatile cbd_t *bdp;
-       unsigned char *p;
-       int count;
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       struct circ_buf *xmit = &port->info->xmit;
-
-       /* Handle xon/xoff */
-       if (port->x_char) {
-               /* Pick next descriptor and fill from buffer */
-               bdp = pinfo->tx_cur;
-
-               p = bus_to_virt(bdp->cbd_bufaddr);
-               *p++ = xmit->buf[xmit->tail];
-               bdp->cbd_datlen = 1;
-               bdp->cbd_sc |= BD_SC_READY;
-               /* Get next BD. */
-               if (bdp->cbd_sc & BD_SC_WRAP)
-                       bdp = pinfo->tx_bd_base;
-               else
-                       bdp++;
-               pinfo->tx_cur = bdp;
-
-               port->icount.tx++;
-               port->x_char = 0;
-               return 1;
-       }
-
-       if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               cpm_uart_stop_tx(port, 0);
-               return 0;
-       }
-
-       /* Pick next descriptor and fill from buffer */
-       bdp = pinfo->tx_cur;
-
-       while (!(bdp->cbd_sc & BD_SC_READY) && (xmit->tail != xmit->head)) {
-               count = 0;
-               p = bus_to_virt(bdp->cbd_bufaddr);
-               while (count < pinfo->tx_fifosize) {
-                       *p++ = xmit->buf[xmit->tail];
-                       xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
-                       port->icount.tx++;
-                       count++;
-                       if (xmit->head == xmit->tail)
-                               break;
-               }
-               bdp->cbd_datlen = count;
-               bdp->cbd_sc |= BD_SC_READY;
-               /* Get next BD. */
-               if (bdp->cbd_sc & BD_SC_WRAP)
-                       bdp = pinfo->tx_bd_base;
-               else
-                       bdp++;
-       }
-       pinfo->tx_cur = bdp;
-
-       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
-               uart_write_wakeup(port);
-
-       if (uart_circ_empty(xmit)) {
-               cpm_uart_stop_tx(port, 0);
-               return 0;
-       }
-
-       return 1;
-}
-
-/*
- * init buffer descriptors
- */
-static void cpm_uart_initbd(struct uart_cpm_port *pinfo)
-{
-       int i;
-       u8 *mem_addr;
-       volatile cbd_t *bdp;
-
-       pr_debug("CPM uart[%d]:initbd\n", pinfo->port.line);
-
-       /* Set the physical address of the host memory
-        * buffers in the buffer descriptors, and the
-        * virtual address for us to work with.
-        */
-       mem_addr = pinfo->mem_addr;
-       bdp = pinfo->rx_cur = pinfo->rx_bd_base;
-       for (i = 0; i < (pinfo->rx_nrfifos - 1); i++, bdp++) {
-               bdp->cbd_bufaddr = virt_to_bus(mem_addr);
-               bdp->cbd_sc = BD_SC_EMPTY | BD_SC_INTRPT;
-               mem_addr += pinfo->rx_fifosize;
-       }
-       
-       bdp->cbd_bufaddr = virt_to_bus(mem_addr);
-       bdp->cbd_sc = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
-
-       /* Set the physical address of the host memory
-        * buffers in the buffer descriptors, and the
-        * virtual address for us to work with.
-        */
-       mem_addr = pinfo->mem_addr + L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize);
-       bdp = pinfo->tx_cur = pinfo->tx_bd_base;
-       for (i = 0; i < (pinfo->tx_nrfifos - 1); i++, bdp++) {
-               bdp->cbd_bufaddr = virt_to_bus(mem_addr);
-               bdp->cbd_sc = BD_SC_INTRPT;
-               mem_addr += pinfo->tx_fifosize;
-       }
-       
-       bdp->cbd_bufaddr = virt_to_bus(mem_addr);
-       bdp->cbd_sc = BD_SC_WRAP | BD_SC_INTRPT;
-}
-
-static void cpm_uart_init_scc(struct uart_cpm_port *pinfo)
-{
-       int line = pinfo - cpm_uart_ports;
-       volatile scc_t *scp;
-       volatile scc_uart_t *sup;
-
-       pr_debug("CPM uart[%d]:init_scc\n", pinfo->port.line);
-
-       scp = pinfo->sccp;
-       sup = pinfo->sccup;
-
-       /* Store address */
-       pinfo->sccup->scc_genscc.scc_rbase = (unsigned char *)pinfo->rx_bd_base - DPRAM_BASE;
-       pinfo->sccup->scc_genscc.scc_tbase = (unsigned char *)pinfo->tx_bd_base - DPRAM_BASE;
-
-       /* Set up the uart parameters in the
-        * parameter ram.
-        */
-
-       cpm_set_scc_fcr(sup);
-
-       sup->scc_genscc.scc_mrblr = pinfo->rx_fifosize;
-       sup->scc_maxidl = pinfo->rx_fifosize;
-       sup->scc_brkcr = 1;
-       sup->scc_parec = 0;
-       sup->scc_frmec = 0;
-       sup->scc_nosec = 0;
-       sup->scc_brkec = 0;
-       sup->scc_uaddr1 = 0;
-       sup->scc_uaddr2 = 0;
-       sup->scc_toseq = 0;
-       sup->scc_char1 = 0x8000;
-       sup->scc_char2 = 0x8000;
-       sup->scc_char3 = 0x8000;
-       sup->scc_char4 = 0x8000;
-       sup->scc_char5 = 0x8000;
-       sup->scc_char6 = 0x8000;
-       sup->scc_char7 = 0x8000;
-       sup->scc_char8 = 0x8000;
-       sup->scc_rccm = 0xc0ff;
-
-       /* Send the CPM an initialize command.
-        */
-       cpm_line_cr_cmd(line, CPM_CR_INIT_TRX);
-
-       /* Set UART mode, 8 bit, no parity, one stop.
-        * Enable receive and transmit.
-        */
-       scp->scc_gsmrh = 0;
-       scp->scc_gsmrl =
-           (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
-       /* Enable rx interrupts  and clear all pending events.  */
-       scp->scc_sccm = 0;
-       scp->scc_scce = 0xffff;
-       scp->scc_dsr = 0x7e7e;
-       scp->scc_psmr = 0x3000;
-
-       scp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-}
-
-static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
-{
-       int line = pinfo - cpm_uart_ports;
-       volatile smc_t *sp;
-       volatile smc_uart_t *up;
-
-       pr_debug("CPM uart[%d]:init_smc\n", pinfo->port.line);
-
-       sp = pinfo->smcp;
-       up = pinfo->smcup;
-
-       /* Store address */
-       pinfo->smcup->smc_rbase = (u_char *)pinfo->rx_bd_base - DPRAM_BASE;
-       pinfo->smcup->smc_tbase = (u_char *)pinfo->tx_bd_base - DPRAM_BASE;
-
-       /* Set up the uart parameters in the
-        * parameter ram.
-        */
-       cpm_set_smc_fcr(up);
-
-       /* Using idle charater time requires some additional tuning.  */
-       up->smc_mrblr = pinfo->rx_fifosize;
-       up->smc_maxidl = pinfo->rx_fifosize;
-       up->smc_brkcr = 1;
-
-       cpm_line_cr_cmd(line, CPM_CR_INIT_TRX);
-
-       /* Set UART mode, 8 bit, no parity, one stop.
-        * Enable receive and transmit.
-        */
-       sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
-
-       /* Enable only rx interrupts clear all pending events. */
-       sp->smc_smcm = 0;
-       sp->smc_smce = 0xff;
-
-       sp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
-}
-
-/*
- * Initialize port. This is called from early_console stuff
- * so we have to be careful here !
- */
-static int cpm_uart_request_port(struct uart_port *port)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-       int ret;
-
-       pr_debug("CPM uart[%d]:request port\n", port->line);
-
-       if (pinfo->flags & FLAG_CONSOLE)
-               return 0;
-
-       /*
-        * Setup any port IO, connect any baud rate generators,
-        * etc.  This is expected to be handled by board
-        * dependant code 
-        */
-       if (pinfo->set_lineif)
-               pinfo->set_lineif(pinfo);
-
-       if (IS_SMC(pinfo)) {
-               pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
-               pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-       } else {
-               pinfo->sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
-               pinfo->sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       }
-
-       ret = cpm_uart_allocbuf(pinfo, 0);
-
-       if (ret)
-               return ret;
-
-       cpm_uart_initbd(pinfo);
-
-       return 0;
-}
-
-static void cpm_uart_release_port(struct uart_port *port)
-{
-       struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
-
-       if (!(pinfo->flags & FLAG_CONSOLE))
-               cpm_uart_freebuf(pinfo);
-}
-
-/*
- * Configure/autoconfigure the port.
- */
-static void cpm_uart_config_port(struct uart_port *port, int flags)
-{
-       pr_debug("CPM uart[%d]:config_port\n", port->line);
-
-       if (flags & UART_CONFIG_TYPE) {
-               port->type = PORT_CPM;
-               cpm_uart_request_port(port);
-       }
-}
-static struct uart_ops cpm_uart_pops = {
-       .tx_empty       = cpm_uart_tx_empty,
-       .set_mctrl      = cpm_uart_set_mctrl,
-       .get_mctrl      = cpm_uart_get_mctrl,
-       .stop_tx        = cpm_uart_stop_tx,
-       .start_tx       = cpm_uart_start_tx,
-       .stop_rx        = cpm_uart_stop_rx,
-       .enable_ms      = cpm_uart_enable_ms,
-       .break_ctl      = cpm_uart_break_ctl,
-       .startup        = cpm_uart_startup,
-       .shutdown       = cpm_uart_shutdown,
-       .set_termios    = cpm_uart_set_termios,
-       .type           = cpm_uart_type,
-       .release_port   = cpm_uart_release_port,
-       .request_port   = cpm_uart_request_port,
-       .config_port    = cpm_uart_config_port,
-       .verify_port    = cpm_uart_verify_port,
-};
-
-struct uart_cpm_port cpm_uart_ports[UART_NR] = {
-       [UART_SMC1] = {
-               .port = {
-                       .irq            = SMC1_IRQ,
-                       .ops            = &cpm_uart_pops,
-                       .iotype         = SERIAL_IO_MEM,
-               },
-               .flags = FLAG_SMC,
-               .tx_nrfifos = TX_NUM_FIFO,
-               .tx_fifosize = TX_BUF_SIZE,
-               .rx_nrfifos = RX_NUM_FIFO, 
-               .rx_fifosize = RX_BUF_SIZE,
-               .set_lineif = smc1_lineif,
-       },
-       [UART_SMC2] = {
-               .port = {
-                       .irq            = SMC2_IRQ,
-                       .ops            = &cpm_uart_pops,
-                       .iotype         = SERIAL_IO_MEM,
-               },
-               .flags = FLAG_SMC,
-               .tx_nrfifos = TX_NUM_FIFO,
-               .tx_fifosize = TX_BUF_SIZE,
-               .rx_nrfifos = RX_NUM_FIFO, 
-               .rx_fifosize = RX_BUF_SIZE,
-               .set_lineif = smc2_lineif,
-       },
-       [UART_SCC1] = {
-               .port = {
-                       .irq            = SCC1_IRQ,
-                       .ops            = &cpm_uart_pops,
-                       .iotype         = SERIAL_IO_MEM,
-               },
-               .tx_nrfifos = TX_NUM_FIFO,
-               .tx_fifosize = TX_BUF_SIZE,
-               .rx_nrfifos = RX_NUM_FIFO, 
-               .rx_fifosize = RX_BUF_SIZE,
-               .set_lineif = scc1_lineif,
-       },
-       [UART_SCC2] = {
-               .port = {
-                       .irq            = SCC2_IRQ,
-                       .ops            = &cpm_uart_pops,
-                       .iotype         = SERIAL_IO_MEM,
-               },
-               .tx_nrfifos = TX_NUM_FIFO,
-               .tx_fifosize = TX_BUF_SIZE,
-               .rx_nrfifos = RX_NUM_FIFO, 
-               .rx_fifosize = RX_BUF_SIZE,
-               .set_lineif = scc2_lineif,
-       },
-       [UART_SCC3] = {
-               .port = {
-                       .irq            = SCC3_IRQ,
-                       .ops            = &cpm_uart_pops,
-                       .iotype         = SERIAL_IO_MEM,
-               },
-               .tx_nrfifos = TX_NUM_FIFO,
-               .tx_fifosize = TX_BUF_SIZE,
-               .rx_nrfifos = RX_NUM_FIFO, 
-               .rx_fifosize = RX_BUF_SIZE,
-               .set_lineif = scc3_lineif,
-       },
-       [UART_SCC4] = {
-               .port = {
-                       .irq            = SCC4_IRQ,
-                       .ops            = &cpm_uart_pops,
-                       .iotype         = SERIAL_IO_MEM,
-               },
-               .tx_nrfifos = TX_NUM_FIFO,
-               .tx_fifosize = TX_BUF_SIZE,
-               .rx_nrfifos = RX_NUM_FIFO, 
-               .rx_fifosize = RX_BUF_SIZE,
-               .set_lineif = scc4_lineif,
-       },
-};
-
-#ifdef CONFIG_SERIAL_CPM_CONSOLE
-/*
- *     Print a string to the serial port trying not to disturb
- *     any possible real use of the port...
- *
- *     Note that this is called with interrupts already disabled
- */
-static void cpm_uart_console_write(struct console *co, const char *s,
-                                  u_int count)
-{
-       struct uart_cpm_port *pinfo =
-           &cpm_uart_ports[cpm_uart_port_map[co->index]];
-       unsigned int i;
-       volatile cbd_t *bdp, *bdbase;
-       volatile unsigned char *cp;
-
-       /* Get the address of the host memory buffer.
-        */
-       bdp = pinfo->tx_cur;
-       bdbase = pinfo->tx_bd_base;
-
-       /*
-        * Now, do each character.  This is not as bad as it looks
-        * since this is a holding FIFO and not a transmitting FIFO.
-        * We could add the complexity of filling the entire transmit
-        * buffer, but we would just wait longer between accesses......
-        */
-       for (i = 0; i < count; i++, s++) {
-               /* Wait for transmitter fifo to empty.
-                * Ready indicates output is ready, and xmt is doing
-                * that, not that it is ready for us to send.
-                */
-               while ((bdp->cbd_sc & BD_SC_READY) != 0)
-                       ;
-
-               /* Send the character out.
-                * If the buffer address is in the CPM DPRAM, don't
-                * convert it.
-                */
-               if ((uint) (bdp->cbd_bufaddr) > (uint) CPM_ADDR)
-                       cp = (unsigned char *) (bdp->cbd_bufaddr);
-               else
-                       cp = bus_to_virt(bdp->cbd_bufaddr);
-               
-               *cp = *s;
-
-               bdp->cbd_datlen = 1;
-               bdp->cbd_sc |= BD_SC_READY;
-
-               if (bdp->cbd_sc & BD_SC_WRAP)
-                       bdp = bdbase;
-               else
-                       bdp++;
-
-               /* if a LF, also do CR... */
-               if (*s == 10) {
-                       while ((bdp->cbd_sc & BD_SC_READY) != 0)
-                               ;
-
-                       if ((uint) (bdp->cbd_bufaddr) > (uint) CPM_ADDR)
-                               cp = (unsigned char *) (bdp->cbd_bufaddr);
-                       else
-                               cp = bus_to_virt(bdp->cbd_bufaddr);
-
-                       *cp = 13;
-                       bdp->cbd_datlen = 1;
-                       bdp->cbd_sc |= BD_SC_READY;
-
-                       if (bdp->cbd_sc & BD_SC_WRAP)
-                               bdp = bdbase;
-                       else
-                               bdp++;
-               }
-       }
-
-       /*
-        * Finally, Wait for transmitter & holding register to empty
-        *  and restore the IER
-        */
-       while ((bdp->cbd_sc & BD_SC_READY) != 0)
-               ;
-
-       pinfo->tx_cur = (volatile cbd_t *) bdp;
-}
-
-/*
- * Setup console. Be careful is called early !
- */
-static int __init cpm_uart_console_setup(struct console *co, char *options)
-{
-       struct uart_port *port;
-       struct uart_cpm_port *pinfo;
-       int baud = 38400;
-       int bits = 8;
-       int parity = 'n';
-       int flow = 'n';
-       int ret;
-
-       port =
-           (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]];
-       pinfo = (struct uart_cpm_port *)port;
-       
-       pinfo->flags |= FLAG_CONSOLE;
-
-       if (options) {
-               uart_parse_options(options, &baud, &parity, &bits, &flow);
-       } else {
-               bd_t *bd = (bd_t *) __res;
-
-               if (bd->bi_baudrate)
-                       baud = bd->bi_baudrate;
-               else
-                       baud = 9600;
-       }
-
-       /*
-        * Setup any port IO, connect any baud rate generators,
-        * etc.  This is expected to be handled by board
-        * dependant code 
-        */
-       if (pinfo->set_lineif)
-               pinfo->set_lineif(pinfo);
-
-       if (IS_SMC(pinfo)) {
-               pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
-               pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-       } else {
-               pinfo->sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
-               pinfo->sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       }
-
-       ret = cpm_uart_allocbuf(pinfo, 1);
-
-       if (ret)
-               return ret;
-
-       cpm_uart_initbd(pinfo);
-
-       if (IS_SMC(pinfo))
-               cpm_uart_init_smc(pinfo);
-       else
-               cpm_uart_init_scc(pinfo);
-
-       uart_set_options(port, co, baud, parity, bits, flow);
-
-       return 0;
-}
-
-extern struct uart_driver cpm_reg;
-static struct console cpm_scc_uart_console = {
-       .name           "ttyCPM",
-       .write          cpm_uart_console_write,
-       .device         uart_console_device,
-       .setup          cpm_uart_console_setup,
-       .flags          CON_PRINTBUFFER,
-       .index          -1,
-       .data           = &cpm_reg,
-};
-
-int __init cpm_uart_console_init(void)
-{
-       int ret = cpm_uart_init_portdesc();
-
-       if (!ret)
-               register_console(&cpm_scc_uart_console);
-       return ret;
-}
-
-console_initcall(cpm_uart_console_init);
-
-#define CPM_UART_CONSOLE       &cpm_scc_uart_console
-#else
-#define CPM_UART_CONSOLE       NULL
-#endif
-
-static struct uart_driver cpm_reg = {
-       .owner          = THIS_MODULE,
-       .driver_name    = "ttyCPM",
-       .dev_name       = "ttyCPM",
-       .major          = SERIAL_CPM_MAJOR,
-       .minor          = SERIAL_CPM_MINOR,
-       .cons           = CPM_UART_CONSOLE,
-};
-
-static int __init cpm_uart_init(void)
-{
-       int ret, i;
-
-       printk(KERN_INFO "Serial: CPM driver $Revision: 0.01 $\n");
-
-#ifndef CONFIG_SERIAL_CPM_CONSOLE
-       ret = cpm_uart_init_portdesc();
-       if (ret)
-               return ret;
-#endif
-
-       cpm_reg.nr = cpm_uart_nr;
-       ret = uart_register_driver(&cpm_reg);
-
-       if (ret)
-               return ret;
-
-       for (i = 0; i < cpm_uart_nr; i++) {
-               int con = cpm_uart_port_map[i];
-               cpm_uart_ports[con].port.line = i;
-               cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF;
-               uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port);
-       }
-
-       return ret;
-}
-
-static void __exit cpm_uart_exit(void)
-{
-       int i;
-
-       for (i = 0; i < cpm_uart_nr; i++) {
-               int con = cpm_uart_port_map[i];
-               uart_remove_one_port(&cpm_reg, &cpm_uart_ports[con].port);
-       }
-
-       uart_unregister_driver(&cpm_reg);
-}
-
-module_init(cpm_uart_init);
-module_exit(cpm_uart_exit);
-
-MODULE_AUTHOR("Kumar Gala/Antoniou Pantelis");
-MODULE_DESCRIPTION("CPM SCC/SMC port driver $Revision: 0.01 $");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_CHARDEV(SERIAL_CPM_MAJOR, SERIAL_CPM_MINOR);
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
deleted file mode 100644 (file)
index a9ab047..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- *  linux/drivers/serial/cpm_uart.c
- *
- *  Driver for CPM (SCC/SMC) serial ports; CPM1 definitions
- *
- *  Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2)
- *              Pantelis Antoniou (panto@intracom.gr) (CPM1)
- * 
- *  Copyright (C) 2004 Freescale Semiconductor, Inc.
- *            (C) 2004 Intracom, S.A.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/device.h>
-#include <linux/bootmem.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include <linux/serial_core.h>
-#include <linux/kernel.h>
-
-#include "cpm_uart.h"
-
-/**************************************************************/
-
-void cpm_line_cr_cmd(int line, int cmd)
-{
-       ushort val;
-       volatile cpm8xx_t *cp = cpmp;
-
-       switch (line) {
-       case UART_SMC1:
-               val = mk_cr_cmd(CPM_CR_CH_SMC1, cmd) | CPM_CR_FLG;
-               break;
-       case UART_SMC2:
-               val = mk_cr_cmd(CPM_CR_CH_SMC2, cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC1:
-               val = mk_cr_cmd(CPM_CR_CH_SCC1, cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC2:
-               val = mk_cr_cmd(CPM_CR_CH_SCC2, cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC3:
-               val = mk_cr_cmd(CPM_CR_CH_SCC3, cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC4:
-               val = mk_cr_cmd(CPM_CR_CH_SCC4, cmd) | CPM_CR_FLG;
-               break;
-       default:
-               return;
-
-       }
-       cp->cp_cpcr = val;
-       while (cp->cp_cpcr & CPM_CR_FLG) ;
-}
-
-void smc1_lineif(struct uart_cpm_port *pinfo)
-{
-       volatile cpm8xx_t *cp = cpmp;
-
-       cp->cp_pbpar |= 0x000000c0;
-       cp->cp_pbdir &= ~0x000000c0;
-       cp->cp_pbodr &= ~0x000000c0;
-
-       pinfo->brg = 1;
-}
-
-void smc2_lineif(struct uart_cpm_port *pinfo)
-{
-       /* XXX SMC2: insert port configuration here */
-       pinfo->brg = 2;
-}
-
-void scc1_lineif(struct uart_cpm_port *pinfo)
-{
-       /* XXX SCC1: insert port configuration here */
-       pinfo->brg = 1;
-}
-
-void scc2_lineif(struct uart_cpm_port *pinfo)
-{
-       /* XXX SCC2: insert port configuration here */
-       pinfo->brg = 2;
-}
-
-void scc3_lineif(struct uart_cpm_port *pinfo)
-{
-       /* XXX SCC3: insert port configuration here */
-       pinfo->brg = 3;
-}
-
-void scc4_lineif(struct uart_cpm_port *pinfo)
-{
-       /* XXX SCC4: insert port configuration here */
-       pinfo->brg = 4;
-}
-
-/*
- * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 
- * receive buffer descriptors from dual port ram, and a character
- * buffer area from host mem. If we are allocating for the console we need
- * to do it from bootmem
- */
-int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
-{
-       int dpmemsz, memsz;
-       u8 *dp_mem;
-       uint dp_offset;
-       u8 *mem_addr;
-       dma_addr_t dma_addr = 0;
-
-       pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line);
-
-       dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
-       dp_offset = cpm_dpalloc(dpmemsz, 8);
-       if (IS_DPERR(dp_offset)) {
-               printk(KERN_ERR
-                      "cpm_uart_cpm1.c: could not allocate buffer descriptors\n");
-               return -ENOMEM;
-       }
-       dp_mem = cpm_dpram_addr(dp_offset);
-
-       memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) +
-           L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
-       if (is_con) {
-               mem_addr = (u8 *) m8xx_cpm_hostalloc(memsz);
-               dma_addr = 0;
-       } else
-               mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr,
-                                             GFP_KERNEL);
-
-       if (mem_addr == NULL) {
-               cpm_dpfree(dp_offset);
-               printk(KERN_ERR
-                      "cpm_uart_cpm1.c: could not allocate coherent memory\n");
-               return -ENOMEM;
-       }
-
-       pinfo->dp_addr = dp_offset;
-       pinfo->mem_addr = mem_addr;
-       pinfo->dma_addr = dma_addr;
-
-       pinfo->rx_buf = mem_addr;
-       pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos
-                                                      * pinfo->rx_fifosize);
-
-       pinfo->rx_bd_base = (volatile cbd_t *)dp_mem;
-       pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos;
-
-       return 0;
-}
-
-void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
-{
-       dma_free_coherent(NULL, L1_CACHE_ALIGN(pinfo->rx_nrfifos *
-                                              pinfo->rx_fifosize) +
-                         L1_CACHE_ALIGN(pinfo->tx_nrfifos *
-                                        pinfo->tx_fifosize), pinfo->mem_addr,
-                         pinfo->dma_addr);
-
-       cpm_dpfree(pinfo->dp_addr);
-}
-
-/* Setup any dynamic params in the uart desc */
-int cpm_uart_init_portdesc(void)
-{
-       pr_debug("CPM uart[-]:init portdesc\n");
-
-       cpm_uart_nr = 0;
-#ifdef CONFIG_SERIAL_CPM_SMC1
-       cpm_uart_ports[UART_SMC1].smcp = &cpmp->cp_smc[0];
-       cpm_uart_ports[UART_SMC1].smcup =
-           (smc_uart_t *) & cpmp->cp_dparam[PROFF_SMC1];
-       cpm_uart_ports[UART_SMC1].port.mapbase =
-           (unsigned long)&cpmp->cp_smc[0];
-       cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
-       cpm_uart_ports[UART_SMC1].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-       cpm_uart_ports[UART_SMC1].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SMC2
-       cpm_uart_ports[UART_SMC2].smcp = &cpmp->cp_smc[1];
-       cpm_uart_ports[UART_SMC2].smcup =
-           (smc_uart_t *) & cpmp->cp_dparam[PROFF_SMC2];
-       cpm_uart_ports[UART_SMC2].port.mapbase =
-           (unsigned long)&cpmp->cp_smc[1];
-       cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
-       cpm_uart_ports[UART_SMC2].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-       cpm_uart_ports[UART_SMC2].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC1
-       cpm_uart_ports[UART_SCC1].sccp = &cpmp->cp_scc[0];
-       cpm_uart_ports[UART_SCC1].sccup =
-           (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC1];
-       cpm_uart_ports[UART_SCC1].port.mapbase =
-           (unsigned long)&cpmp->cp_scc[0];
-       cpm_uart_ports[UART_SCC1].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC1].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC1].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC2
-       cpm_uart_ports[UART_SCC2].sccp = &cpmp->cp_scc[1];
-       cpm_uart_ports[UART_SCC2].sccup =
-           (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC2];
-       cpm_uart_ports[UART_SCC2].port.mapbase =
-           (unsigned long)&cpmp->cp_scc[1];
-       cpm_uart_ports[UART_SCC2].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC2].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC2].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC3
-       cpm_uart_ports[UART_SCC3].sccp = &cpmp->cp_scc[2];
-       cpm_uart_ports[UART_SCC3].sccup =
-           (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC3];
-       cpm_uart_ports[UART_SCC3].port.mapbase =
-           (unsigned long)&cpmp->cp_scc[2];
-       cpm_uart_ports[UART_SCC3].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC3].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC3].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC4
-       cpm_uart_ports[UART_SCC4].sccp = &cpmp->cp_scc[3];
-       cpm_uart_ports[UART_SCC4].sccup =
-           (scc_uart_t *) & cpmp->cp_dparam[PROFF_SCC4];
-       cpm_uart_ports[UART_SCC4].port.mapbase =
-           (unsigned long)&cpmp->cp_scc[3];
-       cpm_uart_ports[UART_SCC4].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC4].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC4].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4;
-#endif
-       return 0;
-}
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.h b/drivers/serial/cpm_uart/cpm_uart_cpm1.h
deleted file mode 100644 (file)
index 5d867ab..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * linux/drivers/serial/cpm_uart_cpm1.h
- *
- * Driver for CPM (SCC/SMC) serial ports
- * 
- * definitions for cpm1
- *
- */
-
-#ifndef CPM_UART_CPM1_H
-#define CPM_UART_CPM1_H
-
-#include <asm/commproc.h>
-
-/* defines for IRQs */
-#define SMC1_IRQ       (CPM_IRQ_OFFSET + CPMVEC_SMC1)
-#define SMC2_IRQ       (CPM_IRQ_OFFSET + CPMVEC_SMC2)
-#define SCC1_IRQ       (CPM_IRQ_OFFSET + CPMVEC_SCC1)
-#define SCC2_IRQ       (CPM_IRQ_OFFSET + CPMVEC_SCC2)
-#define SCC3_IRQ       (CPM_IRQ_OFFSET + CPMVEC_SCC3)
-#define SCC4_IRQ       (CPM_IRQ_OFFSET + CPMVEC_SCC4)
-
-/* the CPM address */
-#define CPM_ADDR       IMAP_ADDR
-
-static inline void cpm_set_brg(int brg, int baud)
-{
-       cpm_setbrg(brg, baud);
-}
-
-static inline void cpm_set_scc_fcr(volatile scc_uart_t * sup)
-{
-       sup->scc_genscc.scc_rfcr = SMC_EB;
-       sup->scc_genscc.scc_tfcr = SMC_EB;
-}
-
-static inline void cpm_set_smc_fcr(volatile smc_uart_t * up)
-{
-       up->smc_rfcr = SMC_EB;
-       up->smc_tfcr = SMC_EB;
-}
-
-#define DPRAM_BASE     ((unsigned char *)&cpmp->cp_dpmem[0])
-
-#endif
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
deleted file mode 100644 (file)
index 0c12f28..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- *  linux/drivers/serial/cpm_uart_cpm2.c
- *
- *  Driver for CPM (SCC/SMC) serial ports; CPM2 definitions
- *
- *  Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2)
- *              Pantelis Antoniou (panto@intracom.gr) (CPM1)
- * 
- *  Copyright (C) 2004 Freescale Semiconductor, Inc.
- *            (C) 2004 Intracom, S.A.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/device.h>
-#include <linux/bootmem.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include <linux/serial_core.h>
-#include <linux/kernel.h>
-
-#include "cpm_uart.h"
-
-/**************************************************************/
-
-void cpm_line_cr_cmd(int line, int cmd)
-{
-       volatile cpm_cpm2_t *cp = cpmp;
-       ulong val;
-
-       switch (line) {
-       case UART_SMC1:
-               val = mk_cr_cmd(CPM_CR_SMC1_PAGE, CPM_CR_SMC1_SBLOCK, 0,
-                               cmd) | CPM_CR_FLG;
-               break;
-       case UART_SMC2:
-               val = mk_cr_cmd(CPM_CR_SMC2_PAGE, CPM_CR_SMC2_SBLOCK, 0,
-                               cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC1:
-               val = mk_cr_cmd(CPM_CR_SCC1_PAGE, CPM_CR_SCC1_SBLOCK, 0,
-                               cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC2:
-               val = mk_cr_cmd(CPM_CR_SCC2_PAGE, CPM_CR_SCC2_SBLOCK, 0,
-                               cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC3:
-               val = mk_cr_cmd(CPM_CR_SCC3_PAGE, CPM_CR_SCC3_SBLOCK, 0,
-                               cmd) | CPM_CR_FLG;
-               break;
-       case UART_SCC4:
-               val = mk_cr_cmd(CPM_CR_SCC4_PAGE, CPM_CR_SCC4_SBLOCK, 0,
-                               cmd) | CPM_CR_FLG;
-               break;
-       default:
-               return;
-
-       }
-       cp->cp_cpcr = val;
-       while (cp->cp_cpcr & CPM_CR_FLG) ;
-}
-
-void smc1_lineif(struct uart_cpm_port *pinfo)
-{
-       volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
-
-       /* SMC1 is only on port D */
-       io->iop_ppard |= 0x00c00000;
-       io->iop_pdird |= 0x00400000;
-       io->iop_pdird &= ~0x00800000;
-       io->iop_psord &= ~0x00c00000;
-
-       /* Wire BRG1 to SMC1 */
-       cpm2_immr->im_cpmux.cmx_smr &= 0x0f;
-       pinfo->brg = 1;
-}
-
-void smc2_lineif(struct uart_cpm_port *pinfo)
-{
-       volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
-
-       /* SMC2 is only on port A */
-       io->iop_ppara |= 0x00c00000;
-       io->iop_pdira |= 0x00400000;
-       io->iop_pdira &= ~0x00800000;
-       io->iop_psora &= ~0x00c00000;
-
-       /* Wire BRG2 to SMC2 */
-       cpm2_immr->im_cpmux.cmx_smr &= 0xf0;
-       pinfo->brg = 2;
-}
-
-void scc1_lineif(struct uart_cpm_port *pinfo)
-{
-       volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
-
-       /* Use Port D for SCC1 instead of other functions.  */
-       io->iop_ppard |= 0x00000003;
-       io->iop_psord &= ~0x00000001;   /* Rx */
-       io->iop_psord |= 0x00000002;    /* Tx */
-       io->iop_pdird &= ~0x00000001;   /* Rx */
-       io->iop_pdird |= 0x00000002;    /* Tx */
-
-       /* Wire BRG1 to SCC1 */
-       cpm2_immr->im_cpmux.cmx_scr &= ~0x00ffffff;
-       cpm2_immr->im_cpmux.cmx_scr |= 0x00000000;
-       pinfo->brg = 1;
-}
-
-void scc2_lineif(struct uart_cpm_port *pinfo)
-{
-       volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
-       io->iop_pparb |= 0x008b0000;
-       io->iop_pdirb |= 0x00880000;
-       io->iop_psorb |= 0x00880000;
-       io->iop_pdirb &= ~0x00030000;
-       io->iop_psorb &= ~0x00030000;
-       cpm2_immr->im_cpmux.cmx_scr &= ~0xff00ffff;
-       cpm2_immr->im_cpmux.cmx_scr |= 0x00090000;
-       pinfo->brg = 2;
-}
-
-void scc3_lineif(struct uart_cpm_port *pinfo)
-{
-       volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
-       io->iop_pparb |= 0x008b0000;
-       io->iop_pdirb |= 0x00880000;
-       io->iop_psorb |= 0x00880000;
-       io->iop_pdirb &= ~0x00030000;
-       io->iop_psorb &= ~0x00030000;
-       cpm2_immr->im_cpmux.cmx_scr &= ~0xffff00ff;
-       cpm2_immr->im_cpmux.cmx_scr |= 0x00001200;
-       pinfo->brg = 3;
-}
-
-void scc4_lineif(struct uart_cpm_port *pinfo)
-{
-       volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
-
-       io->iop_ppard |= 0x00000600;
-       io->iop_psord &= ~0x00000600;   /* Tx/Rx */
-       io->iop_pdird &= ~0x00000200;   /* Rx */
-       io->iop_pdird |= 0x00000400;    /* Tx */
-
-       cpm2_immr->im_cpmux.cmx_scr &= ~0xffffff00;
-       cpm2_immr->im_cpmux.cmx_scr |= 0x0000001b;
-       pinfo->brg = 4;
-}
-
-/*
- * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 
- * receive buffer descriptors from dual port ram, and a character
- * buffer area from host mem. If we are allocating for the console we need
- * to do it from bootmem
- */
-int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
-{
-       int dpmemsz, memsz;
-       u8 *dp_mem;
-       uint dp_offset;
-       u8 *mem_addr;
-       dma_addr_t dma_addr = 0;
-
-       pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line);
-
-       dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
-       dp_offset = cpm_dpalloc(dpmemsz, 8);
-       if (IS_DPERR(dp_offset)) {
-               printk(KERN_ERR
-                      "cpm_uart_cpm.c: could not allocate buffer descriptors\n");
-               return -ENOMEM;
-       }
-
-       dp_mem = cpm_dpram_addr(dp_offset);
-
-       memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) +
-           L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
-       if (is_con)
-               mem_addr = alloc_bootmem(memsz);
-       else
-               mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr,
-                                             GFP_KERNEL);
-
-       if (mem_addr == NULL) {
-               cpm_dpfree(dp_offset);
-               printk(KERN_ERR
-                      "cpm_uart_cpm.c: could not allocate coherent memory\n");
-               return -ENOMEM;
-       }
-
-       pinfo->dp_addr = dp_offset;
-       pinfo->mem_addr = mem_addr;
-       pinfo->dma_addr = dma_addr;
-
-       pinfo->rx_buf = mem_addr;
-       pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos
-                                                      * pinfo->rx_fifosize);
-
-       pinfo->rx_bd_base = (volatile cbd_t *)dp_mem;
-       pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos;
-
-       return 0;
-}
-
-void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
-{
-       dma_free_coherent(NULL, L1_CACHE_ALIGN(pinfo->rx_nrfifos *
-                                              pinfo->rx_fifosize) +
-                         L1_CACHE_ALIGN(pinfo->tx_nrfifos *
-                                        pinfo->tx_fifosize), pinfo->mem_addr,
-                         pinfo->dma_addr);
-
-       cpm_dpfree(pinfo->dp_addr);
-}
-
-/* Setup any dynamic params in the uart desc */
-int cpm_uart_init_portdesc(void)
-{
-       pr_debug("CPM uart[-]:init portdesc\n");
-
-       cpm_uart_nr = 0;
-#ifdef CONFIG_SERIAL_CPM_SMC1
-       cpm_uart_ports[UART_SMC1].smcp = (smc_t *) & cpm2_immr->im_smc[0];
-       cpm_uart_ports[UART_SMC1].smcup =
-           (smc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SMC1];
-       cpm_uart_ports[UART_SMC1].port.mapbase =
-           (unsigned long)&cpm2_immr->im_smc[0];
-       cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
-       cpm_uart_ports[UART_SMC1].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-       cpm_uart_ports[UART_SMC1].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SMC2
-       cpm_uart_ports[UART_SMC2].smcp = (smc_t *) & cpm2_immr->im_smc[1];
-       cpm_uart_ports[UART_SMC2].smcup =
-           (smc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SMC2];
-       cpm_uart_ports[UART_SMC2].port.mapbase =
-           (unsigned long)&cpm2_immr->im_smc[1];
-       cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
-       cpm_uart_ports[UART_SMC2].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-       cpm_uart_ports[UART_SMC2].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC1
-       cpm_uart_ports[UART_SCC1].sccp = (scc_t *) & cpm2_immr->im_scc[0];
-       cpm_uart_ports[UART_SCC1].sccup =
-           (scc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SCC1];
-       cpm_uart_ports[UART_SCC1].port.mapbase =
-           (unsigned long)&cpm2_immr->im_scc[0];
-       cpm_uart_ports[UART_SCC1].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC1].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC1].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC2
-       cpm_uart_ports[UART_SCC2].sccp = (scc_t *) & cpm2_immr->im_scc[1];
-       cpm_uart_ports[UART_SCC2].sccup =
-           (scc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SCC2];
-       cpm_uart_ports[UART_SCC2].port.mapbase =
-           (unsigned long)&cpm2_immr->im_scc[1];
-       cpm_uart_ports[UART_SCC2].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC2].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC2].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC3
-       cpm_uart_ports[UART_SCC3].sccp = (scc_t *) & cpm2_immr->im_scc[2];
-       cpm_uart_ports[UART_SCC3].sccup =
-           (scc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SCC3];
-       cpm_uart_ports[UART_SCC3].port.mapbase =
-           (unsigned long)&cpm2_immr->im_scc[2];
-       cpm_uart_ports[UART_SCC3].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC3].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC3].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3;
-#endif
-
-#ifdef CONFIG_SERIAL_CPM_SCC4
-       cpm_uart_ports[UART_SCC4].sccp = (scc_t *) & cpm2_immr->im_scc[3];
-       cpm_uart_ports[UART_SCC4].sccup =
-           (scc_uart_t *) & cpm2_immr->im_dprambase[PROFF_SCC4];
-       cpm_uart_ports[UART_SCC4].port.mapbase =
-           (unsigned long)&cpm2_immr->im_scc[3];
-       cpm_uart_ports[UART_SCC4].sccp->scc_sccm &=
-           ~(UART_SCCM_TX | UART_SCCM_RX);
-       cpm_uart_ports[UART_SCC4].sccp->scc_gsmrl &=
-           ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-       cpm_uart_ports[UART_SCC4].port.uartclk = (((bd_t *) __res)->bi_intfreq);
-       cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4;
-#endif
-
-       return 0;
-}
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.h b/drivers/serial/cpm_uart/cpm_uart_cpm2.h
deleted file mode 100644 (file)
index 4793fec..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * linux/drivers/serial/cpm_uart_cpm2.h
- *
- * Driver for CPM (SCC/SMC) serial ports
- * 
- * definitions for cpm2
- *
- */
-
-#ifndef CPM_UART_CPM2_H
-#define CPM_UART_CPM2_H
-
-#include <asm/cpm2.h>
-
-/* defines for IRQs */
-#define SMC1_IRQ       SIU_INT_SMC1
-#define SMC2_IRQ       SIU_INT_SMC2
-#define SCC1_IRQ       SIU_INT_SCC1
-#define SCC2_IRQ       SIU_INT_SCC2
-#define SCC3_IRQ       SIU_INT_SCC3
-#define SCC4_IRQ       SIU_INT_SCC4
-
-/* the CPM address */
-#define CPM_ADDR       CPM_MAP_ADDR
-
-static inline void cpm_set_brg(int brg, int baud)
-{
-       cpm_setbrg(brg, baud);
-}
-
-static inline void cpm_set_scc_fcr(volatile scc_uart_t * sup)
-{
-       sup->scc_genscc.scc_rfcr = CPMFCR_GBL | CPMFCR_EB;
-       sup->scc_genscc.scc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-}
-
-static inline void cpm_set_smc_fcr(volatile smc_uart_t * up)
-{
-       up->smc_rfcr = CPMFCR_GBL | CPMFCR_EB;
-       up->smc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-}
-
-#define DPRAM_BASE     ((unsigned char *)&cpm2_immr->im_dprambase[0])
-
-#endif
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
deleted file mode 100644 (file)
index 3feba05..0000000
+++ /dev/null
@@ -1,869 +0,0 @@
-/*
- * drivers/serial/mpc52xx_uart.c
- *
- * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs.
- *
- * FIXME According to the usermanual the status bits in the status register
- * are only updated when the peripherals access the FIFO and not when the
- * CPU access them. So since we use this bits to know when we stop writing
- * and reading, they may not be updated in-time and a race condition may
- * exists. But I haven't be able to prove this and I don't care. But if
- * any problem arises, it might worth checking. The TX/RX FIFO Stats
- * registers should be used in addition.
- * Update: Actually, they seem updated ... At least the bits we use.
- *
- *
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- * 
- * Some of the code has been inspired/copied from the 2.4 code written
- * by Dale Farnsworth <dfarnsworth@mvista.com>.
- * 
- * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
- * Copyright (C) 2003 MontaVista, Software, Inc.
- * 
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-/* OCP Usage :
- *
- * This drivers uses the OCP model. To load the serial driver for one of the
- * PSCs, just add this to the core_ocp table :
- *
- * {
- *     .vendor         = OCP_VENDOR_FREESCALE,
- *     .function       = OCP_FUNC_PSC_UART,
- *     .index          = 0,
- *     .paddr          = MPC52xx_PSC1,
- *     .irq            = MPC52xx_PSC1_IRQ,
- *     .pm             = OCP_CPM_NA,
- * },
- *
- * This is for PSC1, replace the paddr and irq according to the PSC you want to
- * use. The driver all necessary registers to place the PSC in uart mode without
- * DCD. However, the pin multiplexing aren't changed and should be set either
- * by the bootloader or in the platform init code.
- * The index field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2,
- * and so on). So the PSC1 is mapped to /dev/ttyS0, PSC2 to /dev/ttyS1 and so
- * on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly for
- * the console code : without this 1:1 mapping, at early boot time, when we are
- * parsing the kernel args console=ttyS?, we wouldn't know wich PSC it will be
- * mapped to because OCP stuff is not yet initialized.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/sysrq.h>
-#include <linux/console.h>
-
-#include <asm/delay.h>
-#include <asm/io.h>
-#include <asm/ocp.h>
-
-#include <asm/mpc52xx.h>
-#include <asm/mpc52xx_psc.h>
-
-#if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
-
-
-#define ISR_PASS_LIMIT 256     /* Max number of iteration in the interrupt */
-
-
-static struct uart_port mpc52xx_uart_ports[MPC52xx_PSC_MAXNUM];
-       /* Rem: - We use the read_status_mask as a shadow of
-        *        psc->mpc52xx_psc_imr
-        *      - It's important that is array is all zero on start as we
-        *        use it to know if it's initialized or not ! If it's not sure
-        *        it's cleared, then a memset(...,0,...) should be added to
-        *        the console_init
-        */
-
-#define PSC(port) ((struct mpc52xx_psc *)((port)->membase))
-
-
-/* Forward declaration of the interruption handling routine */
-static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id,struct pt_regs *regs);
-
-
-/* Simple macro to test if a port is console or not. This one is taken
- * for serial_core.c and maybe should be moved to serial_core.h ? */
-#ifdef CONFIG_SERIAL_CORE_CONSOLE
-#define uart_console(port)     ((port)->cons && (port)->cons->index == (port)->line)
-#else
-#define uart_console(port)     (0)
-#endif
-
-
-/* ======================================================================== */
-/* UART operations                                                          */
-/* ======================================================================== */
-
-static unsigned int 
-mpc52xx_uart_tx_empty(struct uart_port *port)
-{
-       int status = in_be16(&PSC(port)->mpc52xx_psc_status);
-       return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0;
-}
-
-static void 
-mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
-{
-       /* Not implemented */
-}
-
-static unsigned int 
-mpc52xx_uart_get_mctrl(struct uart_port *port)
-{
-       /* Not implemented */
-       return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
-}
-
-static void 
-mpc52xx_uart_stop_tx(struct uart_port *port, unsigned int tty_stop)
-{
-       /* port->lock taken by caller */
-       port->read_status_mask &= ~MPC52xx_PSC_IMR_TXRDY;
-       out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
-}
-
-static void 
-mpc52xx_uart_start_tx(struct uart_port *port, unsigned int tty_start)
-{
-       /* port->lock taken by caller */
-       port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
-       out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
-}
-
-static void 
-mpc52xx_uart_send_xchar(struct uart_port *port, char ch)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&port->lock, flags);
-       
-       port->x_char = ch;
-       if (ch) {
-               /* Make sure tx interrupts are on */
-               /* Truly necessary ??? They should be anyway */
-               port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
-               out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
-       }
-       
-       spin_unlock_irqrestore(&port->lock, flags);
-}
-
-static void
-mpc52xx_uart_stop_rx(struct uart_port *port)
-{
-       /* port->lock taken by caller */
-       port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY;
-       out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
-}
-
-static void
-mpc52xx_uart_enable_ms(struct uart_port *port)
-{
-       /* Not implemented */
-}
-
-static void
-mpc52xx_uart_break_ctl(struct uart_port *port, int ctl)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&port->lock, flags);
-
-       if ( ctl == -1 )
-               out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK);
-       else
-               out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK);
-       
-       spin_unlock_irqrestore(&port->lock, flags);
-}
-
-static int
-mpc52xx_uart_startup(struct uart_port *port)
-{
-       struct mpc52xx_psc *psc = PSC(port);
-
-       /* Reset/activate the port, clear and enable interrupts */
-       out_8(&psc->command,MPC52xx_PSC_RST_RX);
-       out_8(&psc->command,MPC52xx_PSC_RST_TX);
-       
-       out_be32(&psc->sicr,0); /* UART mode DCD ignored */
-
-       out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */
-       
-       out_8(&psc->rfcntl, 0x00);
-       out_be16(&psc->rfalarm, 0x1ff);
-       out_8(&psc->tfcntl, 0x07);
-       out_be16(&psc->tfalarm, 0x80);
-
-       port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
-       out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
-       
-       out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
-       out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);
-               
-       return 0;
-}
-
-static void
-mpc52xx_uart_shutdown(struct uart_port *port)
-{
-       struct mpc52xx_psc *psc = PSC(port);
-       
-       /* Shut down the port, interrupt and all */
-       out_8(&psc->command,MPC52xx_PSC_RST_RX);
-       out_8(&psc->command,MPC52xx_PSC_RST_TX);
-       
-       port->read_status_mask = 0; 
-       out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
-}
-
-static void 
-mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
-                         struct termios *old)
-{
-       struct mpc52xx_psc *psc = PSC(port);
-       unsigned long flags;
-       unsigned char mr1, mr2;
-       unsigned short ctr;
-       unsigned int j, baud, quot;
-       
-       /* Prepare what we're gonna write */
-       mr1 = 0;
-       
-       switch (new->c_cflag & CSIZE) {
-               case CS5:       mr1 |= MPC52xx_PSC_MODE_5_BITS;
-                               break;
-               case CS6:       mr1 |= MPC52xx_PSC_MODE_6_BITS;
-                               break;
-               case CS7:       mr1 |= MPC52xx_PSC_MODE_7_BITS;
-                               break;
-               case CS8:
-               default:        mr1 |= MPC52xx_PSC_MODE_8_BITS;
-       }
-
-       if (new->c_cflag & PARENB) {
-               mr1 |= (new->c_cflag & PARODD) ?
-                       MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN;
-       } else
-               mr1 |= MPC52xx_PSC_MODE_PARNONE;
-       
-       
-       mr2 = 0;
-
-       if (new->c_cflag & CSTOPB)
-               mr2 |= MPC52xx_PSC_MODE_TWO_STOP;
-       else
-               mr2 |= ((new->c_cflag & CSIZE) == CS5) ?
-                       MPC52xx_PSC_MODE_ONE_STOP_5_BITS :
-                       MPC52xx_PSC_MODE_ONE_STOP;
-
-
-       baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16);
-       quot = uart_get_divisor(port, baud);
-       ctr = quot & 0xffff;
-       
-       /* Get the lock */
-       spin_lock_irqsave(&port->lock, flags);
-
-       /* Update the per-port timeout */
-       uart_update_timeout(port, new->c_cflag, baud);
-
-       /* Do our best to flush TX & RX, so we don't loose anything */
-       /* But we don't wait indefinitly ! */
-       j = 5000000;    /* Maximum wait */
-       /* FIXME Can't receive chars since set_termios might be called at early
-        * boot for the console, all stuff is not yet ready to receive at that
-        * time and that just makes the kernel oops */
-       /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */
-       while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && 
-              --j)
-               udelay(1);
-
-       if (!j)
-               printk( KERN_ERR "mpc52xx_uart.c: "
-                       "Unable to flush RX & TX fifos in-time in set_termios."
-                       "Some chars may have been lost.\n" ); 
-
-       /* Reset the TX & RX */
-       out_8(&psc->command,MPC52xx_PSC_RST_RX);
-       out_8(&psc->command,MPC52xx_PSC_RST_TX);
-
-       /* Send new mode settings */
-       out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1);
-       out_8(&psc->mode,mr1);
-       out_8(&psc->mode,mr2);
-       out_8(&psc->ctur,ctr >> 8);
-       out_8(&psc->ctlr,ctr & 0xff);
-       
-       /* Reenable TX & RX */
-       out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
-       out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);
-
-       /* We're all set, release the lock */
-       spin_unlock_irqrestore(&port->lock, flags);
-}
-
-static const char *
-mpc52xx_uart_type(struct uart_port *port)
-{
-       return port->type == PORT_MPC52xx ? "MPC52xx PSC" : NULL;
-}
-
-static void
-mpc52xx_uart_release_port(struct uart_port *port)
-{
-       if (port->flags & UPF_IOREMAP) { /* remapped by us ? */
-               iounmap(port->membase);
-               port->membase = NULL;
-       }
-}
-
-static int
-mpc52xx_uart_request_port(struct uart_port *port)
-{
-       if (port->flags & UPF_IOREMAP) /* Need to remap ? */
-               port->membase = ioremap(port->mapbase, sizeof(struct mpc52xx_psc));
-       
-       return port->membase != NULL ? 0 : -EBUSY;
-}
-
-static void
-mpc52xx_uart_config_port(struct uart_port *port, int flags)
-{
-       if ( (flags & UART_CONFIG_TYPE) &&
-            (mpc52xx_uart_request_port(port) == 0) )
-               port->type = PORT_MPC52xx;
-}
-
-static int
-mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
-{
-       if ( ser->type != PORT_UNKNOWN && ser->type != PORT_MPC52xx )
-               return -EINVAL;
-
-       if ( (ser->irq != port->irq) ||
-            (ser->io_type != SERIAL_IO_MEM) ||
-            (ser->baud_base != port->uartclk)  || 
-            // FIXME Should check addresses/irq as well ?
-            (ser->hub6 != 0 ) )
-               return -EINVAL;
-
-       return 0;
-}
-
-
-static struct uart_ops mpc52xx_uart_ops = {
-       .tx_empty       = mpc52xx_uart_tx_empty,
-       .set_mctrl      = mpc52xx_uart_set_mctrl,
-       .get_mctrl      = mpc52xx_uart_get_mctrl,
-       .stop_tx        = mpc52xx_uart_stop_tx,
-       .start_tx       = mpc52xx_uart_start_tx,
-       .send_xchar     = mpc52xx_uart_send_xchar,
-       .stop_rx        = mpc52xx_uart_stop_rx,
-       .enable_ms      = mpc52xx_uart_enable_ms,
-       .break_ctl      = mpc52xx_uart_break_ctl,
-       .startup        = mpc52xx_uart_startup,
-       .shutdown       = mpc52xx_uart_shutdown,
-       .set_termios    = mpc52xx_uart_set_termios,
-/*     .pm             = mpc52xx_uart_pm,              Not supported yet */
-/*     .set_wake       = mpc52xx_uart_set_wake,        Not supported yet */
-       .type           = mpc52xx_uart_type,
-       .release_port   = mpc52xx_uart_release_port,
-       .request_port   = mpc52xx_uart_request_port,
-       .config_port    = mpc52xx_uart_config_port,
-       .verify_port    = mpc52xx_uart_verify_port
-};
-
-       
-/* ======================================================================== */
-/* Interrupt handling                                                       */
-/* ======================================================================== */
-       
-static inline int
-mpc52xx_uart_int_rx_chars(struct uart_port *port, struct pt_regs *regs)
-{
-       struct tty_struct *tty = port->info->tty;
-       unsigned char ch;
-       unsigned short status;
-
-       /* While we can read, do so ! */
-       while ( (status = in_be16(&PSC(port)->mpc52xx_psc_status)) &
-               MPC52xx_PSC_SR_RXRDY) {
-
-               /* If we are full, just stop reading */
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                       break;
-               
-               /* Get the char */
-               ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8);
-
-               /* Handle sysreq char */
-#ifdef SUPPORT_SYSRQ
-               if (uart_handle_sysrq_char(port, ch, regs)) {
-                       port->sysrq = 0;
-                       continue;
-               }
-#endif
-
-               /* Store it */
-               *tty->flip.char_buf_ptr = ch;
-               *tty->flip.flag_buf_ptr = 0;
-               port->icount.rx++;
-       
-               if ( status & (MPC52xx_PSC_SR_PE |
-                              MPC52xx_PSC_SR_FE |
-                              MPC52xx_PSC_SR_RB |
-                              MPC52xx_PSC_SR_OE) ) {
-                       
-                       if (status & MPC52xx_PSC_SR_RB) {
-                               *tty->flip.flag_buf_ptr = TTY_BREAK;
-                               uart_handle_break(port);
-                       } else if (status & MPC52xx_PSC_SR_PE)
-                               *tty->flip.flag_buf_ptr = TTY_PARITY;
-                       else if (status & MPC52xx_PSC_SR_FE)
-                               *tty->flip.flag_buf_ptr = TTY_FRAME;
-                       if (status & MPC52xx_PSC_SR_OE) {
-                               /*
-                                * Overrun is special, since it's
-                                * reported immediately, and doesn't
-                                * affect the current character
-                                */
-                               if (tty->flip.count < (TTY_FLIPBUF_SIZE-1)) {
-                                       tty->flip.flag_buf_ptr++;
-                                       tty->flip.char_buf_ptr++;
-                                       tty->flip.count++;
-                               }
-                               *tty->flip.flag_buf_ptr = TTY_OVERRUN;
-                       }
-
-                       /* Clear error condition */
-                       out_8(&PSC(port)->command,MPC52xx_PSC_RST_ERR_STAT);
-
-               }
-
-               tty->flip.char_buf_ptr++;
-               tty->flip.flag_buf_ptr++;
-               tty->flip.count++;
-
-       }
-
-       tty_flip_buffer_push(tty);
-       
-       return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY;
-}
-
-static inline int
-mpc52xx_uart_int_tx_chars(struct uart_port *port)
-{
-       struct circ_buf *xmit = &port->info->xmit;
-
-       /* Process out of band chars */
-       if (port->x_char) {
-               out_8(&PSC(port)->mpc52xx_psc_buffer_8, port->x_char);
-               port->icount.tx++;
-               port->x_char = 0;
-               return 1;
-       }
-
-       /* Nothing to do ? */
-       if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
-               mpc52xx_uart_stop_tx(port,0);
-               return 0;
-       }
-
-       /* Send chars */
-       while (in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXRDY) {
-               out_8(&PSC(port)->mpc52xx_psc_buffer_8, xmit->buf[xmit->tail]);
-               xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
-               port->icount.tx++;
-               if (uart_circ_empty(xmit))
-                       break;
-       }
-
-       /* Wake up */
-       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
-               uart_write_wakeup(port);
-
-       /* Maybe we're done after all */
-       if (uart_circ_empty(xmit)) {
-               mpc52xx_uart_stop_tx(port,0);
-               return 0;
-       }
-
-       return 1;
-}
-
-static irqreturn_t 
-mpc52xx_uart_int(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct uart_port *port = (struct uart_port *) dev_id;
-       unsigned long pass = ISR_PASS_LIMIT;
-       unsigned int keepgoing;
-       unsigned short status;
-       
-       if ( irq != port->irq ) {
-               printk( KERN_WARNING
-                       "mpc52xx_uart_int : " \
-                       "Received wrong int %d. Waiting for %d\n",
-                      irq, port->irq);
-               return IRQ_NONE;
-       }
-       
-       spin_lock(&port->lock);
-       
-       /* While we have stuff to do, we continue */
-       do {
-               /* If we don't find anything to do, we stop */
-               keepgoing = 0; 
-               
-               /* Read status */
-               status = in_be16(&PSC(port)->mpc52xx_psc_isr);
-               status &= port->read_status_mask;
-                       
-               /* Do we need to receive chars ? */
-               /* For this RX interrupts must be on and some chars waiting */
-               if ( status & MPC52xx_PSC_IMR_RXRDY )
-                       keepgoing |= mpc52xx_uart_int_rx_chars(port, regs);
-
-               /* Do we need to send chars ? */
-               /* For this, TX must be ready and TX interrupt enabled */
-               if ( status & MPC52xx_PSC_IMR_TXRDY )
-                       keepgoing |= mpc52xx_uart_int_tx_chars(port);
-               
-               /* Limit number of iteration */
-               if ( !(--pass) )
-                       keepgoing = 0;
-
-       } while (keepgoing);
-       
-       spin_unlock(&port->lock);
-       
-       return IRQ_HANDLED;
-}
-
-
-/* ======================================================================== */
-/* Console ( if applicable )                                                */
-/* ======================================================================== */
-
-#ifdef CONFIG_SERIAL_MPC52xx_CONSOLE
-
-static void __init
-mpc52xx_console_get_options(struct uart_port *port,
-                            int *baud, int *parity, int *bits, int *flow)
-{
-       struct mpc52xx_psc *psc = PSC(port);
-       unsigned char mr1;
-
-       /* Read the mode registers */
-       out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1);
-       mr1 = in_8(&psc->mode);
-       
-       /* CT{U,L}R are write-only ! */
-       *baud = __res.bi_baudrate ?
-               __res.bi_baudrate : CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD;
-
-       /* Parse them */
-       switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) {
-               case MPC52xx_PSC_MODE_5_BITS:   *bits = 5; break;
-               case MPC52xx_PSC_MODE_6_BITS:   *bits = 6; break;
-               case MPC52xx_PSC_MODE_7_BITS:   *bits = 7; break;
-               case MPC52xx_PSC_MODE_8_BITS:
-               default:                        *bits = 8;
-       }
-       
-       if (mr1 & MPC52xx_PSC_MODE_PARNONE)
-               *parity = 'n';
-       else
-               *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e';
-}
-
-static void  
-mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
-{
-       struct uart_port *port = &mpc52xx_uart_ports[co->index];
-       struct mpc52xx_psc *psc = PSC(port);
-       unsigned int i, j;
-       
-       /* Disable interrupts */
-       out_be16(&psc->mpc52xx_psc_imr, 0);
-
-       /* Wait the TX buffer to be empty */
-       j = 5000000;    /* Maximum wait */      
-       while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && 
-              --j)
-               udelay(1);
-
-       /* Write all the chars */
-       for ( i=0 ; i<count ; i++ ) {
-       
-               /* Send the char */
-               out_8(&psc->mpc52xx_psc_buffer_8, *s);
-
-               /* Line return handling */
-               if ( *s++ == '\n' )
-                       out_8(&psc->mpc52xx_psc_buffer_8, '\r');
-               
-               /* Wait the TX buffer to be empty */
-               j = 20000;      /* Maximum wait */      
-               while (!(in_be16(&psc->mpc52xx_psc_status) & 
-                        MPC52xx_PSC_SR_TXEMP) && --j)
-                       udelay(1);
-       }
-
-       /* Restore interrupt state */
-       out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask);
-}
-
-static int __init
-mpc52xx_console_setup(struct console *co, char *options)
-{
-       struct uart_port *port = &mpc52xx_uart_ports[co->index];
-
-       int baud = 9600;
-       int bits = 8;
-       int parity = 'n';
-       int flow = 'n';
-
-       if (co->index < 0 || co->index >= MPC52xx_PSC_MAXNUM)
-               return -EINVAL;
-       
-       /* Basic port init. Needed since we use some uart_??? func before
-        * real init for early access */
-       port->lock      = SPIN_LOCK_UNLOCKED;
-       port->uartclk   = __res.bi_ipbfreq / 2; /* Look at CTLR doc */
-       port->ops       = &mpc52xx_uart_ops;
-       port->mapbase   = MPC52xx_PSCx(co->index);
-
-               /* We ioremap ourself */
-       port->membase = ioremap(port->mapbase, sizeof(struct mpc52xx_psc));
-       if (port->membase == NULL) {
-               release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc));
-               return -EBUSY;
-       }
-
-       /* Setup the port parameters accoding to options */
-       if (options)
-               uart_parse_options(options, &baud, &parity, &bits, &flow);
-       else
-               mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow);
-
-       return uart_set_options(port, co, baud, parity, bits, flow);
-}
-
-
-extern struct uart_driver mpc52xx_uart_driver;
-
-static struct console mpc52xx_console = {
-       .name   = "ttyS",
-       .write  = mpc52xx_console_write,
-       .device = uart_console_device,
-       .setup  = mpc52xx_console_setup,
-       .flags  = CON_PRINTBUFFER,
-       .index  = -1,   /* Specified on the cmdline (e.g. console=ttyS0 ) */
-       .data   = &mpc52xx_uart_driver,
-};
-
-       
-static int __init 
-mpc52xx_console_init(void)
-{
-       register_console(&mpc52xx_console);
-       return 0;
-}
-
-console_initcall(mpc52xx_console_init);
-
-#define MPC52xx_PSC_CONSOLE &mpc52xx_console
-#else
-#define MPC52xx_PSC_CONSOLE NULL
-#endif
-
-
-/* ======================================================================== */
-/* UART Driver                                                              */
-/* ======================================================================== */
-
-static struct uart_driver mpc52xx_uart_driver = {
-       .owner          = THIS_MODULE,
-       .driver_name    = "mpc52xx_psc_uart",
-       .dev_name       = "ttyS",
-       .devfs_name     = "ttyS",
-       .major          = TTY_MAJOR,
-       .minor          = 64,
-       .nr             = MPC52xx_PSC_MAXNUM,
-       .cons           = MPC52xx_PSC_CONSOLE,
-};
-
-
-/* ======================================================================== */
-/* OCP Driver                                                               */
-/* ======================================================================== */
-
-static int __devinit
-mpc52xx_uart_probe(struct ocp_device *ocp)
-{
-       struct uart_port *port = NULL;
-       int idx, ret;
-
-       /* Get the corresponding port struct */
-       idx = ocp->def->index;
-       if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM)
-               return -EINVAL;
-       
-       port = &mpc52xx_uart_ports[idx];
-
-       /* Init the port structure */
-       port->lock      = SPIN_LOCK_UNLOCKED;
-       port->mapbase   = ocp->def->paddr;
-       port->irq       = ocp->def->irq;
-       port->uartclk   = __res.bi_ipbfreq / 2; /* Look at CTLR doc */
-       port->fifosize  = 255; /* Should be 512 ! But it can't be */
-                              /* stored in a unsigned char       */
-       port->iotype    = UPIO_MEM;
-       port->flags     = UPF_BOOT_AUTOCONF |
-                         ( uart_console(port) ? 0 : UPF_IOREMAP );
-       port->line      = idx;
-       port->ops       = &mpc52xx_uart_ops;
-       port->read_status_mask = 0;
-       
-       /* Requests the mem & irqs */
-       /* Unlike other serial drivers, we reserve the resources here, so we
-        * can detect early if multiple drivers uses the same PSC. Special
-        * care must be taken with the console PSC
-        */
-       ret = request_irq(
-               port->irq, mpc52xx_uart_int,
-               SA_INTERRUPT | SA_SAMPLE_RANDOM, "mpc52xx_psc_uart", port);
-       if (ret)
-               goto error;
-
-       ret = request_mem_region(port->mapbase, sizeof(struct mpc52xx_psc),
-                                "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY;
-       if (ret)
-               goto free_irq;
-
-       /* Add the port to the uart sub-system */
-       ret = uart_add_one_port(&mpc52xx_uart_driver, port);
-       if (ret)
-               goto release_mem;
-
-       ocp_set_drvdata(ocp, (void*)port);
-
-       return 0;
-
-
-free_irq:
-       free_irq(port->irq, mpc52xx_uart_int);
-
-release_mem:
-       release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc));
-
-error:
-       if (uart_console(port))
-               printk( "mpc52xx_uart.c: Error during resource alloction for "
-                       "the console port !!! Check that the console PSC is "
-                       "not used by another OCP driver !!!\n" );
-
-       return ret;
-}
-
-static void
-mpc52xx_uart_remove(struct ocp_device *ocp)
-{
-       struct uart_port *port = (struct uart_port *) ocp_get_drvdata(ocp);
-
-       ocp_set_drvdata(ocp, NULL);
-
-       if (port) {
-               uart_remove_one_port(&mpc52xx_uart_driver, port);
-               release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc));
-               free_irq(port->irq, mpc52xx_uart_int);
-       }
-}
-
-#ifdef CONFIG_PM
-static int
-mpc52xx_uart_suspend(struct ocp_device *ocp, u32 state)
-{
-       struct uart_port *port = (struct uart_port *) ocp_get_drvdata(ocp);
-
-       uart_suspend_port(&mpc52xx_uart_driver, port);
-
-       return 0;
-}
-
-static int
-mpc52xx_uart_resume(struct ocp_device *ocp)
-{
-       struct uart_port *port = (struct uart_port *) ocp_get_drvdata(ocp);
-
-       uart_resume_port(&mpc52xx_uart_driver, port);
-
-       return 0;
-}
-#endif
-
-static struct ocp_device_id mpc52xx_uart_ids[] __devinitdata = {
-       { .vendor = OCP_VENDOR_FREESCALE, .function = OCP_FUNC_PSC_UART },
-       { .vendor = OCP_VENDOR_INVALID /* Terminating entry */ }
-};
-
-MODULE_DEVICE_TABLE(ocp, mpc52xx_uart_ids);
-
-static struct ocp_driver mpc52xx_uart_ocp_driver = {
-       .name           = "mpc52xx_psc_uart",
-       .id_table       = mpc52xx_uart_ids,
-       .probe          = mpc52xx_uart_probe,
-       .remove         = mpc52xx_uart_remove,
-#ifdef CONFIG_PM
-       .suspend        = mpc52xx_uart_suspend,
-       .resume         = mpc52xx_uart_resume,
-#endif
-};
-
-
-/* ======================================================================== */
-/* Module                                                                   */
-/* ======================================================================== */
-
-static int __init
-mpc52xx_uart_init(void)
-{
-       int ret;
-
-       printk(KERN_INFO "Serial: MPC52xx PSC driver\n");
-
-       ret = uart_register_driver(&mpc52xx_uart_driver);
-       if (ret)
-               return ret;
-
-       ret = ocp_register_driver(&mpc52xx_uart_ocp_driver);
-
-       return ret;
-}
-
-static void __exit
-mpc52xx_uart_exit(void)
-{
-       ocp_unregister_driver(&mpc52xx_uart_ocp_driver);
-       uart_unregister_driver(&mpc52xx_uart_driver);
-}
-
-
-module_init(mpc52xx_uart_init);
-module_exit(mpc52xx_uart_exit);
-
-MODULE_AUTHOR("Sylvain Munaut <tnt@246tNt.com>");
-MODULE_DESCRIPTION("Freescale MPC52xx PSC UART");
-MODULE_LICENSE("GPL");
diff --git a/drivers/serial/serial98.c b/drivers/serial/serial98.c
deleted file mode 100644 (file)
index c34f899..0000000
+++ /dev/null
@@ -1,1120 +0,0 @@
-/*
- *  linux/drivers/serial/serial98.c
- *
- *  Driver for NEC PC-9801/PC-9821 standard serial ports
- *
- *  Based on drivers/serial/8250.c, by Russell King.
- *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
- *
- *  Copyright (C) 2002 Osamu Tomita <tomita@cinet.co.jp>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/serial_reg.h>
-#include <linux/delay.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/pc9800.h>
-#include <asm/pc9800_sca.h>
-
-#if defined(CONFIG_SERIAL98_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
-#define SERIAL98_NR            1
-#define SERIAL98_ISR_PASS_LIMIT        256
-#define SERIAL98_EXT           0x434
-
-//#define RX_8251F             0x130   /* In: Receive buffer */
-//#define TX_8251F             0x130   /* Out: Transmit buffer */
-//#define LSR_8251F            0x132   /* In: Line Status Register */
-//#define MSR_8251F            0x134   /* In: Modem Status Register */
-#define IIR_8251F              0x136   /* In: Interrupt ID Register */
-#define FCR_8251F              0x138   /* I/O: FIFO Control Register */
-#define VFAST_8251F            0x13a   /* I/O: VFAST mode Register */
-
-#define CMD_8251F              0x32    /* Out: 8251 Command Resister */
-#define IER2_8251F             0x34    /* I/O: Interrupt Enable Register */
-#define IER1_8251F             0x35    /* I/O: Interrupt Enable Register */
-#define IER1_CTL               0x37    /* Out: Interrupt Enable Register */
-#define DIS_RXR_INT            0x00    /* disable RxRDY Interrupt */
-#define ENA_RXR_INT            0x01    /* enable RxRDY Interrupt */
-#define DIS_TXE_INT            0x02    /* disable TxEMPTY Interrupt */
-#define ENA_TXE_INT            0x03    /* enable TxEMPTY Interrupt */
-#define DIS_TXR_INT            0x04    /* disable TxRDY Interrupt */
-#define ENA_TXR_INT            0x05    /* enable TxRDY Interrupt */
-
-#define CMD_RESET              0x40    /* Reset Command */
-#define CMD_RTS                        0x20    /* Set RTS line */
-#define CMD_CLR_ERR            0x10    /* Clear error flag */
-#define CMD_BREAK              0x08    /* Send Break */
-#define CMD_RXE                        0x04    /* Enable receive */
-#define CMD_DTR                        0x02    /* Set DTR line */
-#define CMD_TXE                        0x01    /* Enable send */
-#define CMD_DUMMY              0x00    /* Dummy Command */
-
-#define VFAST_ENABLE           0x80    /* V.Fast mode Enable */
-
-/* Interrupt masks */
-#define INTR_8251_TXRE         0x04
-#define INTR_8251_TXEE         0x02
-#define INTR_8251_RXRE         0x01
-/* I/O Port */
-//#define PORT_8251_DATA       0
-//#define PORT_8251_CMD                2
-//#define PORT_8251_MOD                2
-//#define PORT_8251_STS                2
-/* status read */
-#define STAT_8251_TXRDY                0x01
-#define STAT_8251_RXRDY                0x02
-#define STAT_8251_TXEMP                0x04
-#define STAT_8251_PER          0x08
-#define STAT_8251_OER          0x10
-#define STAT_8251_FER          0x20
-#define STAT_8251_BRK          0x40
-#define STAT_8251_DSR          0x80
-#if 1
-#define STAT_8251F_TXEMP       0x01
-#define STAT_8251F_TXRDY       0x02
-#define STAT_8251F_RXRDY       0x04
-#define STAT_8251F_DSR         0x08
-#define STAT_8251F_OER         0x10
-#define STAT_8251F_PER         0x20
-#define STAT_8251F_FER         0x40
-#define STAT_8251F_BRK         0x80
-#else
-#define STAT_8251F_TXEMP       0x01
-#define STAT_8251F_TEMT                0x01
-#define STAT_8251F_TXRDY       0x02
-#define STAT_8251F_THRE                0x02
-#define STAT_8251F_RXRDY       0x04
-#define STAT_8251F_DSR         0x04
-#define STAT_8251F_PER         0x08
-#define STAT_8251F_OER         0x10
-#define STAT_8251F_FER         0x20
-#define STAT_8251F_BRK         0x40
-#endif
-
-/*
- * We wrap our port structure around the generic uart_port.
- */
-struct serial98_port {
-       struct uart_port        port;
-       unsigned int            type;
-       unsigned int            ext;
-       unsigned int            lsr_break_flag;
-       unsigned char           cmd;
-       unsigned char           mode;
-       unsigned char           msr;
-       unsigned char           ier;
-       unsigned char           rxchk;
-       unsigned char           txemp;
-       unsigned char           txrdy;
-       unsigned char           rxrdy;
-       unsigned char           brk;
-       unsigned char           fe;
-       unsigned char           oe;
-       unsigned char           pe;
-       unsigned char           dr;
-};
-
-#ifdef CONFIG_SERIAL98_CONSOLE
-static void
-serial98_console_write(struct console *co, const char *s, unsigned int count);
-static int __init serial98_console_setup(struct console *co, char *options);
-
-extern struct uart_driver serial98_reg;
-static struct console serial98_console = {
-       .name           = "ttyS",
-       .write          = serial98_console_write,
-       .device         = uart_console_device,
-       .setup          = serial98_console_setup,
-       .flags          = CON_PRINTBUFFER,
-       .index          = -1,
-       .data           = &serial98_reg,
-};
-
-#define SERIAL98_CONSOLE       &serial98_console
-#else
-#define SERIAL98_CONSOLE       NULL
-#endif
-
-static struct uart_driver serial98_reg = {
-       .owner                  = THIS_MODULE,
-       .driver_name            = "serial98",
-       .dev_name               = "ttyS",
-       .major                  = TTY_MAJOR,
-       .minor                  = 64,
-       .nr                     = SERIAL98_NR,
-       .cons                   = SERIAL98_CONSOLE,
-};
-
-static int serial98_clk;
-static char type_str[48];
-
-#define PORT98 ((struct serial98_port *)port)
-#define PORT (PORT98->port)
-
-static void serial98_fifo_enable(struct uart_port *port, int enable)
-{
-       unsigned char fcr;
-
-       if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
-               fcr = inb(FCR_8251F);
-               if (enable)
-                       fcr |= UART_FCR_ENABLE_FIFO;
-               else
-                       fcr &= ~UART_FCR_ENABLE_FIFO;
-               outb(fcr, FCR_8251F);
-       }
-
-       if (!enable)
-               return;
-
-       outb(0, 0x5f);  /* wait */
-       outb(0, 0x5f);
-       outb(0, 0x5f);
-       outb(0, 0x5f);
-}
-
-static void serial98_cmd_out(struct uart_port *port, unsigned char cmd)
-{
-       serial98_fifo_enable(port, 0);
-       outb(cmd, CMD_8251F);
-       serial98_fifo_enable(port, 1);
-}
-
-static void serial98_mode_set(struct uart_port *port)
-{
-       serial98_cmd_out(port, CMD_DUMMY);
-       serial98_cmd_out(port, CMD_DUMMY);
-       serial98_cmd_out(port, CMD_DUMMY);
-       serial98_cmd_out(port, CMD_RESET);
-       serial98_cmd_out(port, PORT98->mode);
-}
-
-static unsigned char serial98_msr_in(struct uart_port *port)
-{
-       unsigned long flags;
-       unsigned int ms, st;
-       unsigned int tmp;
-
-       spin_lock_irqsave(&PORT.lock, flags);
-       if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
-               PORT98->msr = inb(PORT.iobase + 4);
-       } else {
-               ms = inb(0x33);
-               st = inb(0x32);
-               tmp = 0;
-               if(!(ms & 0x20))
-                       tmp |= UART_MSR_DCD;
-               if(!(ms & 0x80)) {
-                       tmp |= UART_MSR_RI;
-                       PORT98->msr |= UART_MSR_RI;
-               }
-               if(!(ms & 0x40))
-                       tmp |= UART_MSR_CTS;
-               if(st & 0x80)
-                       tmp |= UART_MSR_DSR;
-               PORT98->msr = ((PORT98->msr ^ tmp) >> 4) | tmp;
-       }
-
-       spin_unlock_irqrestore(&PORT.lock, flags);
-       return PORT98->msr;
-}
-
-static void serial98_stop_tx(struct uart_port *port, unsigned int tty_stop)
-{
-       unsigned int ier = inb(IER1_8251F);
-
-       ier &= ~(INTR_8251_TXRE | INTR_8251_TXEE);
-       outb(ier, IER1_8251F);
-}
-
-static void serial98_start_tx(struct uart_port *port, unsigned int tty_start)
-{
-       unsigned int ier = inb(IER1_8251F);
-
-       ier |= INTR_8251_TXRE | INTR_8251_TXEE;
-       outb(ier, IER1_8251F);
-}
-
-static void serial98_stop_rx(struct uart_port *port)
-{
-       PORT.read_status_mask &= ~PORT98->dr;
-       outb(DIS_RXR_INT, IER1_CTL);
-}
-
-static void serial98_enable_ms(struct uart_port *port)
-{
-       outb(PORT98->ier | 0x80, IER2_8251F);
-}
-
-static void serial98_rx_chars(struct uart_port *port, int *status,
-                               struct pt_regs *regs)
-{
-       struct tty_struct *tty = PORT.info->tty;
-       unsigned char ch;
-       int max_count = 256;
-
-       do {
-               if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
-                       tty->flip.work.func((void *)tty);
-                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                               return; // if TTY_DONT_FLIP is set
-               }
-               ch = inb(PORT.iobase);
-               *tty->flip.char_buf_ptr = ch;
-               *tty->flip.flag_buf_ptr = TTY_NORMAL;
-               PORT.icount.rx++;
-
-               if (unlikely(*status & (PORT98->brk | PORT98->pe |
-                                      PORT98->fe | PORT98->oe))) {
-                       /*
-                        * For statistics only
-                        */
-                       if (*status & PORT98->brk) {
-                               *status &= ~(PORT98->fe | PORT98->pe);
-                               PORT.icount.brk++;
-                               /*
-                                * We do the SysRQ and SAK checking
-                                * here because otherwise the break
-                                * may get masked by ignore_status_mask
-                                * or read_status_mask.
-                                */
-                               if (uart_handle_break(&PORT))
-                                       goto ignore_char;
-                       } else if (*status & PORT98->pe)
-                               PORT.icount.parity++;
-                       else if (*status & PORT98->fe)
-                               PORT.icount.frame++;
-                       if (*status & PORT98->oe)
-                               PORT.icount.overrun++;
-
-                       /*
-                        * Mask off conditions which should be ingored.
-                        */
-                       *status &= PORT.read_status_mask;
-
-#ifdef CONFIG_SERIAL98_CONSOLE
-                       if (PORT.line == PORT.cons->index) {
-                               /* Recover the break flag from console xmit */
-                               *status |= PORT98->lsr_break_flag;
-                               PORT98->lsr_break_flag = 0;
-                       }
-#endif
-                       if (*status & PORT98->brk) {
-                               *tty->flip.flag_buf_ptr = TTY_BREAK;
-                       } else if (*status & PORT98->pe)
-                               *tty->flip.flag_buf_ptr = TTY_PARITY;
-                       else if (*status & PORT98->fe)
-                               *tty->flip.flag_buf_ptr = TTY_FRAME;
-               }
-               if (uart_handle_sysrq_char(&PORT, ch, regs))
-                       goto ignore_char;
-               if ((*status & PORT.ignore_status_mask) == 0) {
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
-               }
-               if ((*status & PORT98->oe) &&
-                   tty->flip.count < TTY_FLIPBUF_SIZE) {
-                       /*
-                        * Overrun is special, since it's reported
-                        * immediately, and doesn't affect the current
-                        * character.
-                        */
-                       *tty->flip.flag_buf_ptr = TTY_OVERRUN;
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
-               }
-       ignore_char:
-               *status = inb(PORT.iobase + 2);
-       } while ((*status & PORT98->rxchk) && (max_count-- > 0));
-       tty_flip_buffer_push(tty);
-}
-
-static void serial98_tx_chars(struct uart_port *port)
-{
-       struct circ_buf *xmit = &PORT.info->xmit;
-       int count;
-
-       if (PORT.x_char) {
-               outb(PORT.x_char, PORT.iobase);
-               PORT.icount.tx++;
-               PORT.x_char = 0;
-               return;
-       }
-       if (uart_circ_empty(xmit) || uart_tx_stopped(&PORT)) {
-               serial98_stop_tx(port, 0);
-               return;
-       }
-
-       count = PORT.fifosize;
-       do {
-               outb(xmit->buf[xmit->tail], PORT.iobase);
-               xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
-               PORT.icount.tx++;
-               if (uart_circ_empty(xmit))
-                       break;
-       } while (--count > 0);
-
-       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
-               uart_write_wakeup(&PORT);
-
-       if (uart_circ_empty(xmit))
-               serial98_stop_tx(&PORT, 0);
-}
-
-static void serial98_modem_status(struct uart_port *port)
-{
-       int status;
-
-       status = serial98_msr_in(port);
-
-       if ((status & UART_MSR_ANY_DELTA) == 0)
-               return;
-
-       if (status & UART_MSR_TERI)
-               PORT.icount.rng++;
-       if (status & UART_MSR_DDSR)
-               PORT.icount.dsr++;
-       if (status & UART_MSR_DDCD)
-               uart_handle_dcd_change(&PORT, status & UART_MSR_DCD);
-       if (status & UART_MSR_DCTS)
-               uart_handle_cts_change(&PORT, status & UART_MSR_CTS);
-
-       wake_up_interruptible(&PORT.info->delta_msr_wait);
-}
-
-static void serial98_int(int irq, void *port, struct pt_regs *regs)
-{
-       unsigned int status;
-
-       spin_lock(&PORT.lock);
-       status = inb(PORT.iobase + 2);
-       if (status & PORT98->rxrdy) {
-               serial98_rx_chars(port, &status, regs);
-       }
-       serial98_modem_status(port);
-       if (status & PORT98->txrdy) {
-               serial98_tx_chars(port);
-       }
-       spin_unlock(&PORT.lock);
-}
-
-static unsigned int serial98_tx_empty(struct uart_port *port)
-{
-       unsigned long flags;
-       unsigned int ret = 0;
-
-       spin_lock_irqsave(&PORT.lock, flags);
-       if (inb(PORT.iobase + 2) & PORT98->txemp)
-                       ret = TIOCSER_TEMT;
-
-       spin_unlock_irqrestore(&PORT.lock, flags);
-       return ret;
-}
-
-static unsigned int serial98_get_mctrl(struct uart_port *port)
-{
-       unsigned char status;
-       unsigned int ret = 0;
-
-       status = serial98_msr_in(port);
-       if (status & UART_MSR_DCD)
-               ret |= TIOCM_CAR;
-       if (status & UART_MSR_RI)
-               ret |= TIOCM_RNG;
-       if (status & UART_MSR_DSR)
-               ret |= TIOCM_DSR;
-       if (status & UART_MSR_CTS)
-               ret |= TIOCM_CTS;
-       return ret;
-}
-
-static void serial98_set_mctrl(struct uart_port *port, unsigned int mctrl)
-{
-       PORT98->cmd &= 0xdd;
-       if (mctrl & TIOCM_RTS)
-               PORT98->cmd |= CMD_RTS;
-
-       if (mctrl & TIOCM_DTR)
-               PORT98->cmd |= CMD_DTR;
-
-       serial98_cmd_out(port, PORT98->cmd);
-}
-
-static void serial98_break_ctl(struct uart_port *port, int break_state)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&PORT.lock, flags);
-       if (break_state == -1)
-               PORT98->cmd |= CMD_BREAK;
-       else
-               PORT98->cmd &= ~CMD_BREAK;
-
-       serial98_cmd_out(port, PORT98->cmd);
-       spin_unlock_irqrestore(&PORT.lock, flags);
-}
-
-static int serial98_startup(struct uart_port *port)
-{
-       int retval;
-
-       if (PORT.type == PORT_8251_PC98) {
-               /* Wake up UART */
-               PORT98->mode = 0xfc;
-               serial98_mode_set(port);
-               outb(DIS_RXR_INT, IER1_CTL);
-               outb(DIS_TXE_INT, IER1_CTL);
-               outb(DIS_TXR_INT, IER1_CTL);
-               PORT98->mode = 0;
-               serial98_mode_set(port);
-       }
-
-       /*
-        * Clear the FIFO buffers and disable them.
-        * (they will be reeanbled in set_termios())
-        */
-       if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
-               outb(UART_FCR_ENABLE_FIFO, FCR_8251F);
-               outb((UART_FCR_ENABLE_FIFO
-                       | UART_FCR_CLEAR_RCVR
-                       | UART_FCR_CLEAR_XMIT), FCR_8251F);
-               outb(0, FCR_8251F);
-       }
-
-       /* Clear the interrupt registers. */
-       inb(0x30);
-       inb(0x32);
-       if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
-               inb(PORT.iobase);
-               inb(PORT.iobase + 2);
-               inb(PORT.iobase + 4);
-               inb(PORT.iobase + 6);
-       }
-
-       /* Allocate the IRQ */
-       retval = request_irq(PORT.irq, serial98_int, 0,
-                               serial98_reg.driver_name, port);
-       if (retval)
-               return retval;
-
-       /*
-        * Now, initialize the UART
-        */
-       PORT98->mode = 0x4e;
-       serial98_mode_set(port);
-       PORT98->cmd = 0x15;
-       serial98_cmd_out(port, PORT98->cmd);
-       PORT98->cmd = 0x05;
-
-       /*
-        * Finally, enable interrupts
-        */
-       outb(0x00, IER2_8251F);
-       outb(ENA_RXR_INT, IER1_CTL);
-
-       /*
-        * And clear the interrupt registers again for luck.
-        */
-       inb(0x30);
-       inb(0x32);
-       if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
-               inb(PORT.iobase);
-               inb(PORT.iobase + 2);
-               inb(PORT.iobase + 4);
-               inb(PORT.iobase + 6);
-       }
-
-       return 0;
-}
-
-static void serial98_shutdown(struct uart_port *port)
-{
-       unsigned long flags;
-
-       /*
-        * disable all interrupts
-        */
-       spin_lock_irqsave(&PORT.lock, flags);
-       if (PORT.type == PORT_VFAST_PC98)
-               outb(0, VFAST_8251F);           /* V.FAST mode off */
-
-       /* disnable all modem status interrupt */
-       outb(0x80, IER2_8251F);
-
-       /* disnable TX/RX interrupt */
-       outb(0x00, IER2_8251F);
-       outb(DIS_RXR_INT, IER1_CTL);
-       outb(DIS_TXE_INT, IER1_CTL);
-       outb(DIS_TXR_INT, IER1_CTL);
-       PORT98->ier = 0;
-
-       spin_unlock_irqrestore(&PORT.lock, flags);
-
-       /*
-        * Free the interrupt
-        */
-       free_irq(PORT.irq, port);
-
-       /* disable break condition and disable the port */
-       serial98_mode_set(port);
-
-       /* disable FIFO's */    
-       if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
-               outb((UART_FCR_ENABLE_FIFO
-                       | UART_FCR_CLEAR_RCVR
-                       | UART_FCR_CLEAR_XMIT), FCR_8251F);
-               outb(0, FCR_8251F);
-       }
-
-       inb(PORT.iobase);
-}
-
-static void
-serial98_set_termios(struct uart_port *port, struct termios *termios,
-                      struct termios *old)
-{
-       unsigned char stopbit, cval, fcr = 0, ier = 0;
-       unsigned long flags;
-       unsigned int baud, quot;
-
-       stopbit = 0x80;
-       switch (termios->c_cflag & CSIZE) {
-               case CS5:
-                       cval = 0x42;
-                       stopbit = 0xc0;
-                       break;
-               case CS6:
-                       cval = 0x46;
-                       break;
-               case CS7:
-                       cval = 0x4a;
-                       break;
-               default:
-               case CS8:
-                       cval = 0x4e;
-                       break;
-       }
-
-       if (termios->c_cflag & CSTOPB)
-               cval ^= stopbit;
-       if (termios->c_cflag & PARENB)
-               cval |= 0x10;
-       if (!(termios->c_cflag & PARODD))
-               cval |= 0x20;
-
-       /*
-        * Ask the core to calculate the divisor for us.
-        */
-       baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 
-       quot = uart_get_divisor(port, baud);
-
-       if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
-               if ((PORT.uartclk / quot) < (2400 * 16))
-                       fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
-               else
-                       fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
-       }
-
-       /*
-        * Ok, we're now changing the port state.  Do it with
-        * interrupts disabled.
-        */
-       spin_lock_irqsave(&PORT.lock, flags);
-
-       /*
-        * Update the per-port timeout.
-        */
-       uart_update_timeout(port, termios->c_cflag, baud);
-
-       PORT.read_status_mask = PORT98->oe | PORT98->txemp | PORT98->dr;
-       if (termios->c_iflag & INPCK)
-               PORT.read_status_mask |= PORT98->fe | PORT98->pe;
-
-       if (termios->c_iflag & (BRKINT | PARMRK))
-               PORT.read_status_mask |= PORT98->brk;
-       /*
-        * Characters to ignore
-        */
-       PORT.ignore_status_mask = 0;
-       if (termios->c_iflag & IGNPAR)
-               PORT.ignore_status_mask |= PORT98->fe | PORT98->pe;
-
-       if (termios->c_iflag & IGNBRK) {
-               PORT.ignore_status_mask |= PORT98->brk;
-               /*
-                * If we're ignoring parity and break indicators,
-                * ignore overruns too (for real raw support).
-                */
-               if (termios->c_iflag & IGNPAR)
-                       PORT.ignore_status_mask |= PORT98->oe;
-       }
-
-       /*
-        * ignore all characters if CREAD is not set
-        */
-       if ((termios->c_cflag & CREAD) == 0)
-               PORT.ignore_status_mask |= PORT98->dr;
-
-       /*
-        * CTS flow control flag and modem status interrupts
-        */
-       if (PORT.flags & UPF_HARDPPS_CD)
-               ier |= 0x80;    /* enable modem status interrupt */
-       if (termios->c_cflag & CRTSCTS) {
-               ier |= 0x08;    /* enable CTS interrupt */
-               ier |= 0x80;    /* enable modem status interrupt */
-       }
-       if (!(termios->c_cflag & CLOCAL)) {
-               ier |= 0x20;    /* enable CD interrupt */
-               ier |= 0x80;    /* enable modem status interrupt */
-       }
-       PORT98->ier = ier;
-
-       PORT98->mode = cval;
-       serial98_mode_set(port);
-       if (PORT.type == PORT_VFAST_PC98 && quot <= 48) {
-               quot /= 4;
-               if (quot < 1)
-                       quot = 1;
-               outb(quot | VFAST_ENABLE, VFAST_8251F);
-       } else {
-               quot /= 3;
-               if (quot < 1)
-                       quot = 1;
-               if (PORT.type == PORT_VFAST_PC98)
-                       outb(0, VFAST_8251F);           /* V.FAST mode off */
-               outb(0xb6, 0x77);
-               outb(quot & 0xff, 0x75);                /* LS of divisor */
-               outb(quot >> 8, 0x75);                  /* MS of divisor */
-       }
-
-       if (fcr & UART_FCR_ENABLE_FIFO) {
-               outb(UART_FCR_ENABLE_FIFO, FCR_8251F);
-               outb(fcr, FCR_8251F);
-       }
-
-       /* enable RX/TX */
-       PORT98->cmd = 0x15;
-       serial98_cmd_out(port, PORT98->cmd);
-       PORT98->cmd = 0x05;
-       /* enable interrupts */
-       outb(0x00, IER2_8251F);
-       outb(ENA_RXR_INT, IER1_CTL);
-       spin_unlock_irqrestore(&PORT.lock, flags);
-}
-
-static const char *serial98_type(struct uart_port *port)
-{
-       char *p;
-
-       switch (PORT.type) {
-               case PORT_8251_PC98:
-                       p = "PC98 onboard legacy 8251";
-                       break;
-               case PORT_19K_PC98:
-                       p =  "PC98 onboard max 19200bps";
-                       break;
-               case PORT_FIFO_PC98:
-                       p = "PC98 onboard with FIFO";
-                       break;
-               case PORT_VFAST_PC98:
-                       p = "PC98 onboard V.FAST";
-                       break;
-               case PORT_PC9861:
-                       p = "PC-9861K RS-232C ext. board";
-                       break;
-               case PORT_PC9801_101:
-                       p = "PC-9801-101 RS-232C ext. board";
-                       break;
-               default:
-                       return NULL;
-       }
-
-       sprintf(type_str, "%s  Clock %dMHz", p, serial98_clk);
-       return type_str;
-}
-
-/* Release the region(s) being used by 'port' */
-static void serial98_release_port(struct uart_port *port)
-{
-       switch (PORT.type) {
-               case PORT_VFAST_PC98:
-                       release_region(PORT.iobase + 0xa, 1);
-               case PORT_FIFO_PC98:
-                       release_region(PORT.iobase + 8, 1);
-                       release_region(PORT.iobase + 6, 1);
-                       release_region(PORT.iobase + 4, 1);
-                       release_region(PORT.iobase + 2, 1);
-                       release_region(PORT.iobase, 1);
-               case PORT_19K_PC98:
-                       release_region(SERIAL98_EXT, 1);
-                       release_region(0x34, 1);
-               case PORT_8251_PC98:
-                       release_region(0x32, 1);
-                       release_region(0x30, 1);
-       }
-}
-
-/* Request the region(s) being used by 'port' */
-#define REQ_REGION98(base) (request_region((base), 1, serial98_reg.driver_name))
-static int serial98_request_region(unsigned int type)
-{
-       if (!REQ_REGION98(0x30))
-               return -EBUSY;
-       if (REQ_REGION98(0x32)) {
-               if (type == PORT_8251_PC98)
-                       return 0;
-               if (REQ_REGION98(0x34)) {
-                       if (REQ_REGION98(SERIAL98_EXT)) {
-                               unsigned long base;
-
-                               if (type == PORT_19K_PC98)
-                                       return 0;
-                               for (base = 0x130; base <= 0x138; base += 2) {
-                                       if (!REQ_REGION98(base)) {
-                                               base -= 2;
-                                               goto err;
-                                       }
-                               }
-                               if (type == PORT_FIFO_PC98)
-                                       return 0;
-                               if (type == PORT_VFAST_PC98) {
-                                       if (REQ_REGION98(0x13a))
-                                               return 0;
-                               }
-                               err:
-                               while (base >= 0x130) {
-                                       release_region(base, 1);
-                                       base -= 2;
-                               }
-                               release_region(SERIAL98_EXT, 1);
-                       }
-                       release_region(0x34, 1);
-               }
-               release_region(0x32, 1);
-       }
-       release_region(0x30, 1);
-       return -EBUSY;
-}
-
-static int serial98_request_port(struct uart_port *port)
-{
-       return serial98_request_region(PORT.type);
-}
-
-/*
- * Configure/autoconfigure the port.
- */
-static void serial98_config_port(struct uart_port *port, int flags)
-{
-       if (flags & UART_CONFIG_TYPE)
-               PORT.type = PORT98->type;
-}
-
-/*
- * verify the new serial_struct (for TIOCSSERIAL).
- */
-static int serial98_verify_port(struct uart_port *port, struct serial_struct *ser)
-{
-       switch (ser->type) {
-               case PORT_VFAST_PC98:
-               case PORT_FIFO_PC98:
-               case PORT_19K_PC98:
-               case PORT_8251_PC98:
-               /* not implemented yet
-               case PORT_PC9861:
-               case PORT_PC9801_101:
-               */
-               case PORT_UNKNOWN:
-                       break;
-               default:
-                       return -EINVAL;
-       }
-       if (ser->irq < 0 || ser->irq >= NR_IRQS)
-               return -EINVAL;
-       if (ser->baud_base < 9600)
-               return -EINVAL;
-       return 0;
-}
-
-static struct uart_ops serial98_ops = {
-       .tx_empty       = serial98_tx_empty,
-       .set_mctrl      = serial98_set_mctrl,
-       .get_mctrl      = serial98_get_mctrl,
-       .stop_tx        = serial98_stop_tx,
-       .start_tx       = serial98_start_tx,
-       .stop_rx        = serial98_stop_rx,
-       .enable_ms      = serial98_enable_ms,
-       .break_ctl      = serial98_break_ctl,
-       .startup        = serial98_startup,
-       .shutdown       = serial98_shutdown,
-       .set_termios    = serial98_set_termios,
-       .type           = serial98_type,
-       .release_port   = serial98_release_port,
-       .request_port   = serial98_request_port,
-       .config_port    = serial98_config_port,
-       .verify_port    = serial98_verify_port,
-};
-
-static struct serial98_port serial98_ports[SERIAL98_NR] = {
-       {
-               .port = {
-                               .iobase         = 0x30,
-                               .iotype         = SERIAL_IO_PORT,
-                               .irq            = 4,
-                               .fifosize       = 1,
-                               .ops            = &serial98_ops,
-                               .flags          = ASYNC_BOOT_AUTOCONF,
-                               .line           = 0,
-                       },
-               .rxchk = STAT_8251_RXRDY,
-               .txemp = STAT_8251_TXEMP,
-               .txrdy = STAT_8251_TXRDY,
-               .rxrdy = STAT_8251_RXRDY,
-               .brk = STAT_8251_BRK,
-               .fe = STAT_8251_FER,
-               .oe = STAT_8251_OER,
-               .pe = STAT_8251_PER,
-               .dr = STAT_8251_DSR,
-       },
-};
-
-#ifdef CONFIG_SERIAL98_CONSOLE
-
-#define BOTH_EMPTY (PORT98->txemp | PORT98->txrdy)
-
-/*
- *     Wait for transmitter & holding register to empty
- */
-static inline void wait_for_xmitr(struct uart_port *port)
-{
-       unsigned int status, tmout = 10000;
-
-       /* Wait up to 10ms for the character(s) to be sent. */
-       do {
-               status = inb(PORT.iobase + 2);
-
-               if (status & PORT98->brk)
-                       PORT98->lsr_break_flag = PORT98->brk;
-
-               if (--tmout == 0)
-                       break;
-               udelay(1);
-       } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
-
-       /* Wait up to 1s for flow control if necessary */
-       if (PORT.flags & UPF_CONS_FLOW) {
-               tmout = 1000000;
-               while (--tmout &&
-                      ((serial98_msr_in(port) & UART_MSR_CTS) == 0))
-                       udelay(1);
-       }
-}
-
-/*
- *     Print a string to the serial port trying not to disturb
- *     any possible real use of the port...
- *
- *     The console_lock must be held when we get here.
- */
-static void
-serial98_console_write(struct console *co, const char *s, unsigned int count)
-{
-       struct uart_port *port = (struct uart_port *)&serial98_ports[co->index];
-       unsigned int ier1, ier2;
-       int i;
-
-       /*
-        *      First save the UER then disable the interrupts
-        */
-       ier1 = inb(IER1_8251F);
-       ier2 = inb(IER2_8251F);
-       /* disnable all modem status interrupt */
-       outb(0x80, IER2_8251F);
-
-       /* disnable TX/RX interrupt */
-       outb(0x00, IER2_8251F);
-       outb(DIS_RXR_INT, IER1_CTL);
-       outb(DIS_TXE_INT, IER1_CTL);
-       outb(DIS_TXR_INT, IER1_CTL);
-
-       /*
-        *      Now, do each character
-        */
-       for (i = 0; i < count; i++, s++) {
-               wait_for_xmitr(port);
-
-               /*
-                *      Send the character out.
-                *      If a LF, also do CR...
-                */
-               outb(*s, PORT.iobase);
-               if (*s == 10) {
-                       wait_for_xmitr(port);
-                       outb(13, PORT.iobase);
-               }
-       }
-
-       /*
-        *      Finally, wait for transmitter to become empty
-        *      and restore the IER
-        */
-       wait_for_xmitr(port);
-
-       /* restore TX/RX interrupt */
-       outb(0x00, IER2_8251F);
-       if (ier1 & 0x01)
-               outb(ENA_RXR_INT, IER1_CTL);
-       if (ier1 & 0x02)
-               outb(ENA_TXE_INT, IER1_CTL);
-       if (ier1 & 0x04)
-               outb(ENA_TXR_INT, IER1_CTL);
-
-       /* restore modem status interrupt */
-       outb(ier2, IER2_8251F);
-}
-
-static int __init serial98_console_setup(struct console *co, char *options)
-{
-       struct uart_port *port;
-       int baud = 9600;
-       int bits = 8;
-       int parity = 'n';
-       int flow = 'n';
-
-       /*
-        * Check whether an invalid uart number has been specified, and
-        * if so, search for the first available port that does have
-        * console support.
-        */
-       if (co->index >= SERIAL98_NR)
-               co->index = 0;
-       port = &serial98_ports[co->index].port;
-
-       /*
-        * Temporary fix.
-        */
-       spin_lock_init(&port->lock);
-
-       if (options)
-               uart_parse_options(options, &baud, &parity, &bits, &flow);
-
-       return uart_set_options(port, co, baud, parity, bits, flow);
-}
-
-void __init serial98_console_init(void)
-{
-       register_console(&serial98_console);
-}
-
-#endif /* CONFIG_SERIAL98_CONSOLE */
-
-
-static int __init serial98_init(void)
-{
-       int ret;
-       unsigned char iir1, iir2;
-
-       if (PC9800_8MHz_P()) {
-               serial98_clk = 8;
-               serial98_ports[0].port.uartclk = 374400 * 16;
-       } else {
-               serial98_clk = 5;
-               serial98_ports[0].port.uartclk = 460800 * 16;
-       }
-
-       printk(KERN_INFO "serial98: PC-9801 standard serial port driver Version 0.1alpha\n");
-       serial98_ports[0].type = PORT_8251_PC98;
-       /* Check FIFO exist */
-       iir1 = inb(IIR_8251F);
-       iir2 = inb(IIR_8251F);
-       if ((iir1 & 0x40) != (iir2 & 0x40) && (iir1 & 0x20) == (iir2 & 0x20)) {
-               serial98_ports[0].port.iobase = 0x130;
-               serial98_ports[0].port.fifosize = 16;
-               serial98_ports[0].rxchk = STAT_8251F_DSR;
-               serial98_ports[0].txemp = STAT_8251F_TXEMP;
-               serial98_ports[0].txrdy = STAT_8251F_TXRDY;
-               serial98_ports[0].rxrdy = STAT_8251F_RXRDY;
-               serial98_ports[0].brk = STAT_8251F_BRK;
-               serial98_ports[0].fe = STAT_8251F_FER;
-               serial98_ports[0].oe = STAT_8251F_OER;
-               serial98_ports[0].pe = STAT_8251F_PER;
-               serial98_ports[0].dr = STAT_8251F_DSR;
-
-               if (*(unsigned char*)__va(PC9821SCA_RSFLAGS) & 0x10)
-                       serial98_ports[0].type = PORT_VFAST_PC98;
-               else {
-                       outb(serial98_ports[0].ext | 0x40, SERIAL98_EXT);
-                       serial98_ports[0].port.uartclk *= 4;
-                       serial98_ports[0].type = PORT_FIFO_PC98;
-               }
-       } else if ((serial98_ports[0].ext = inb(SERIAL98_EXT)) != 0xff) {
-               outb(serial98_ports[0].ext | 0x40, SERIAL98_EXT);
-               if (inb(SERIAL98_EXT) == (serial98_ports[0].ext | 0x40)) {
-                       serial98_ports[0].port.uartclk *= 4;
-                       serial98_ports[0].type = PORT_19K_PC98;
-               } else {
-                       serial98_ops.enable_ms = NULL;
-                       outb(serial98_ports[0].ext, SERIAL98_EXT);
-               }
-       }
-
-       if (serial98_request_region(serial98_ports[0].type))
-               return -EBUSY;
-
-       ret = uart_register_driver(&serial98_reg);
-       if (ret == 0) {
-               int i;
-
-               for (i = 0; i < SERIAL98_NR; i++) {
-                       uart_add_one_port(&serial98_reg,
-                                       (struct uart_port *)&serial98_ports[i]);
-               }
-       }
-
-       return ret;
-}
-
-static void __exit serial98_exit(void)
-{
-       int i;
-
-       if (serial98_ports[0].type == PORT_19K_PC98
-                       || serial98_ports[0].type == PORT_FIFO_PC98)
-               outb(serial98_ports[0].ext, SERIAL98_EXT);
-
-       for (i = 0; i < SERIAL98_NR; i++) {
-               uart_remove_one_port(&serial98_reg,
-                                       (struct uart_port *)&serial98_ports[i]);
-       }
-
-       uart_unregister_driver(&serial98_reg);
-}
-
-module_init(serial98_init);
-module_exit(serial98_exit);
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9801 standard serial port driver Version 0.1alpha");
-MODULE_LICENSE("GPL");
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
deleted file mode 100644 (file)
index 98b96c5..0000000
+++ /dev/null
@@ -1,1194 +0,0 @@
-/*
- * C-Brick Serial Port (and console) driver for SGI Altix machines.
- *
- * This driver is NOT suitable for talking to the l1-controller for
- * anything other than 'console activities' --- please use the l1
- * driver for that.
- *
- *
- * Copyright (c) 2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information:  Silicon Graphics, Inc., 1500 Crittenden Lane,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
- */
-
-#include <linux/config.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/module.h>
-#include <linux/sysrq.h>
-#include <linux/circ_buf.h>
-#include <linux/serial_reg.h>
-#include <linux/delay.h> /* for mdelay */
-#include <linux/miscdevice.h>
-#include <linux/serial_core.h>
-
-#include <asm/sn/simulator.h>
-#include <asm/sn/sn2/sn_private.h>
-#include <asm/sn/sn_sal.h>
-
-/* number of characters we can transmit to the SAL console at a time */
-#define SN_SAL_MAX_CHARS 120
-
-/* 64K, when we're asynch, it must be at least printk's LOG_BUF_LEN to
- * avoid losing chars, (always has to be a power of 2) */
-#define SN_SAL_BUFFER_SIZE (64 * (1 << 10))
-
-#define SN_SAL_UART_FIFO_DEPTH 16
-#define SN_SAL_UART_FIFO_SPEED_CPS 9600/10
-
-/* sn_transmit_chars() calling args */
-#define TRANSMIT_BUFFERED      0
-#define TRANSMIT_RAW           1
-
-/* To use dynamic numbers only and not use the assigned major and minor,
- * define the following.. */
-/* #define USE_DYNAMIC_MINOR 1 */ /* use dynamic minor number */
-#define USE_DYNAMIC_MINOR 0 /* Don't rely on misc_register dynamic minor */
-
-/* Device name we're using */
-#define DEVICE_NAME "ttySG"
-#define DEVICE_NAME_DYNAMIC "ttySG0"  /* need full name for misc_register */
-/* The major/minor we are using, ignored for USE_DYNAMIC_MINOR */
-#define DEVICE_MAJOR 204
-#define DEVICE_MINOR 40
-
-/*
- * Port definition - this kinda drives it all
- */
-struct sn_cons_port {
-       struct timer_list sc_timer;
-       struct uart_port sc_port;
-       struct sn_sal_ops {
-               int (*sal_puts_raw) (const char *s, int len);
-               int (*sal_puts) (const char *s, int len);
-               int (*sal_getc) (void);
-               int (*sal_input_pending) (void);
-               void (*sal_wakeup_transmit) (struct sn_cons_port *, int);
-       } *sc_ops;
-       unsigned long sc_interrupt_timeout;
-       int sc_is_asynch;
-};
-
-static struct sn_cons_port sal_console_port;
-
-/* Only used if USE_DYNAMIC_MINOR is set to 1 */
-static struct miscdevice misc; /* used with misc_register for dynamic */
-
-extern u64 master_node_bedrock_address;
-extern void early_sn_setup(void);
-
-#undef DEBUG
-#ifdef DEBUG
-static int sn_debug_printf(const char *fmt, ...);
-#define DPRINTF(x...) sn_debug_printf(x)
-#else
-#define DPRINTF(x...) do { } while (0)
-#endif
-
-/* Prototypes */
-static int snt_hw_puts_raw(const char *, int);
-static int snt_hw_puts_buffered(const char *, int);
-static int snt_poll_getc(void);
-static int snt_poll_input_pending(void);
-static int snt_sim_puts(const char *, int);
-static int snt_sim_getc(void);
-static int snt_sim_input_pending(void);
-static int snt_intr_getc(void);
-static int snt_intr_input_pending(void);
-static void sn_transmit_chars(struct sn_cons_port *, int);
-
-/* A table for polling:
- */
-static struct sn_sal_ops poll_ops = {
-       .sal_puts_raw = snt_hw_puts_raw,
-       .sal_puts = snt_hw_puts_raw,
-       .sal_getc = snt_poll_getc,
-       .sal_input_pending = snt_poll_input_pending
-};
-
-/* A table for the simulator */
-static struct sn_sal_ops sim_ops = {
-       .sal_puts_raw = snt_sim_puts,
-       .sal_puts = snt_sim_puts,
-       .sal_getc = snt_sim_getc,
-       .sal_input_pending = snt_sim_input_pending
-};
-
-/* A table for interrupts enabled */
-static struct sn_sal_ops intr_ops = {
-       .sal_puts_raw = snt_hw_puts_raw,
-       .sal_puts = snt_hw_puts_buffered,
-       .sal_getc = snt_intr_getc,
-       .sal_input_pending = snt_intr_input_pending,
-       .sal_wakeup_transmit = sn_transmit_chars
-};
-
-/* the console does output in two distinctly different ways:
- * synchronous (raw) and asynchronous (buffered).  initally, early_printk
- * does synchronous output.  any data written goes directly to the SAL
- * to be output (incidentally, it is internally buffered by the SAL)
- * after interrupts and timers are initialized and available for use,
- * the console init code switches to asynchronous output.  this is
- * also the earliest opportunity to begin polling for console input.
- * after console initialization, console output and tty (serial port)
- * output is buffered and sent to the SAL asynchronously (either by
- * timer callback or by UART interrupt) */
-
-
-/* routines for running the console in polling mode */
-
-/**
- * snt_poll_getc - Get a character from the console in polling mode
- *
- */
-static int
-snt_poll_getc(void)
-{
-       int ch;
-
-       ia64_sn_console_getc(&ch);
-       return ch;
-}
-
-/**
- * snt_poll_input_pending - Check if any input is waiting - polling mode.
- *
- */
-static int
-snt_poll_input_pending(void)
-{
-       int status, input;
-
-       status = ia64_sn_console_check(&input);
-       return !status && input;
-}
-
-/* routines for running the console on the simulator */
-
-/**
- * snt_sim_puts - send to the console, used in simulator mode
- * @str: String to send
- * @count: length of string
- *
- */
-static int
-snt_sim_puts(const char *str, int count)
-{
-       int counter = count;
-
-#ifdef FLAG_DIRECT_CONSOLE_WRITES
-       /* This is an easy way to pre-pend the output to know whether the output
-        * was done via sal or directly */
-       writeb('[', master_node_bedrock_address + (UART_TX << 3));
-       writeb('+', master_node_bedrock_address + (UART_TX << 3));
-       writeb(']', master_node_bedrock_address + (UART_TX << 3));
-       writeb(' ', master_node_bedrock_address + (UART_TX << 3));
-#endif                         /* FLAG_DIRECT_CONSOLE_WRITES */
-       while (counter > 0) {
-               writeb(*str, master_node_bedrock_address + (UART_TX << 3));
-               counter--;
-               str++;
-       }
-       return count;
-}
-
-/**
- * snt_sim_getc - Get character from console in simulator mode
- *
- */
-static int
-snt_sim_getc(void)
-{
-       return readb(master_node_bedrock_address + (UART_RX << 3));
-}
-
-/**
- * snt_sim_input_pending - Check if there is input pending in simulator mode
- *
- */
-static int
-snt_sim_input_pending(void)
-{
-       return readb(master_node_bedrock_address +
-                    (UART_LSR << 3)) & UART_LSR_DR;
-}
-
-/* routines for an interrupt driven console (normal) */
-
-/**
- * snt_intr_getc - Get a character from the console, interrupt mode
- *
- */
-static int
-snt_intr_getc(void)
-{
-       return ia64_sn_console_readc();
-}
-
-/**
- * snt_intr_input_pending - Check if input is pending, interrupt mode
- *
- */
-static int
-snt_intr_input_pending(void)
-{
-       return ia64_sn_console_intr_status() & SAL_CONSOLE_INTR_RECV;
-}
-
-/* these functions are polled and interrupt */
-
-/**
- * snt_hw_puts_raw - Send raw string to the console, polled or interrupt mode
- * @s: String
- * @len: Length
- *
- */
-static int
-snt_hw_puts_raw(const char *s, int len)
-{
-       /* this will call the PROM and not return until this is done */
-       return ia64_sn_console_putb(s, len);
-}
-
-/**
- * snt_hw_puts_buffered - Send string to console, polled or interrupt mode
- * @s: String
- * @len: Length
- *
- */
-static int
-snt_hw_puts_buffered(const char *s, int len)
-{
-       /* queue data to the PROM */
-       return ia64_sn_console_xmit_chars((char *)s, len);
-}
-
-/* uart interface structs
- * These functions are associated with the uart_port that the serial core
- * infrastructure calls.
- *
- * Note: Due to how the console works, many routines are no-ops.
- */
-
-/**
- * snp_type - What type of console are we?
- * @port: Port to operate with (we ignore since we only have one port)
- *
- */
-static const char *
-snp_type(struct uart_port *port)
-{
-       return ("SGI SN L1");
-}
-
-/**
- * snp_tx_empty - Is the transmitter empty?  We pretend we're always empty
- * @port: Port to operate on (we ignore since we only have one port)
- *
- */
-static unsigned int
-snp_tx_empty(struct uart_port *port)
-{
-       return 1;
-}
-
-/**
- * snp_stop_tx - stop the transmitter - no-op for us
- * @port: Port to operat eon - we ignore - no-op function
- * @tty_stop: Set to 1 if called via uart_stop
- *
- */
-static void
-snp_stop_tx(struct uart_port *port, unsigned int tty_stop)
-{
-}
-
-/**
- * snp_release_port - Free i/o and resources for port - no-op for us
- * @port: Port to operate on - we ignore - no-op function
- *
- */
-static void
-snp_release_port(struct uart_port *port)
-{
-}
-
-/**
- * snp_enable_ms - Force modem status interrupts on - no-op for us
- * @port: Port to operate on - we ignore - no-op function
- *
- */
-static void
-snp_enable_ms(struct uart_port *port)
-{
-}
-
-/**
- * snp_shutdown - shut down the port - free irq and disable - no-op for us
- * @port: Port to shut down - we ignore
- *
- */
-static void
-snp_shutdown(struct uart_port *port)
-{
-}
-
-/**
- * snp_set_mctrl - set control lines (dtr, rts, etc) - no-op for our console
- * @port: Port to operate on - we ignore
- * @mctrl: Lines to set/unset - we ignore
- *
- */
-static void
-snp_set_mctrl(struct uart_port *port, unsigned int mctrl)
-{
-}
-
-/**
- * snp_get_mctrl - get contorl line info, we just return a static value
- * @port: port to operate on - we only have one port so we ignore this
- *
- */
-static unsigned int
-snp_get_mctrl(struct uart_port *port)
-{
-       return TIOCM_CAR | TIOCM_RNG | TIOCM_DSR | TIOCM_CTS;
-}
-
-/**
- * snp_stop_rx - Stop the receiver - we ignor ethis
- * @port: Port to operate on - we ignore
- *
- */
-static void
-snp_stop_rx(struct uart_port *port)
-{
-}
-
-/**
- * snp_start_tx - Start transmitter
- * @port: Port to operate on
- * @tty_stop: Set to 1 if called via uart_start
- *
- */
-static void
-snp_start_tx(struct uart_port *port, unsigned int tty_stop)
-{
-       if (sal_console_port.sc_ops->sal_wakeup_transmit)
-               sal_console_port.sc_ops->sal_wakeup_transmit(&sal_console_port, TRANSMIT_BUFFERED);
-
-}
-
-/**
- * snp_break_ctl - handle breaks - ignored by us
- * @port: Port to operate on
- * @break_state: Break state
- *
- */
-static void
-snp_break_ctl(struct uart_port *port, int break_state)
-{
-}
-
-/**
- * snp_startup - Start up the serial port - always return 0 (We're always on)
- * @port: Port to operate on
- *
- */
-static int
-snp_startup(struct uart_port *port)
-{
-       return 0;
-}
-
-/**
- * snp_set_termios - set termios stuff - we ignore these
- * @port: port to operate on
- * @termios: New settings
- * @termios: Old
- *
- */
-static void
-snp_set_termios(struct uart_port *port, struct termios *termios,
-               struct termios *old)
-{
-}
-
-/**
- * snp_request_port - allocate resources for port - ignored by us
- * @port: port to operate on
- *
- */
-static int
-snp_request_port(struct uart_port *port)
-{
-       return 0;
-}
-
-/**
- * snp_config_port - allocate resources, set up - we ignore,  we're always on
- * @port: Port to operate on
- * @flags: flags used for port setup
- *
- */
-static void
-snp_config_port(struct uart_port *port, int flags)
-{
-}
-
-/* Associate the uart functions above - given to serial core */
-
-static struct uart_ops sn_console_ops = {
-       .tx_empty = snp_tx_empty,
-       .set_mctrl = snp_set_mctrl,
-       .get_mctrl = snp_get_mctrl,
-       .stop_tx = snp_stop_tx,
-       .start_tx = snp_start_tx,
-       .stop_rx = snp_stop_rx,
-       .enable_ms = snp_enable_ms,
-       .break_ctl = snp_break_ctl,
-       .startup = snp_startup,
-       .shutdown = snp_shutdown,
-       .set_termios = snp_set_termios,
-       .pm = NULL,
-       .type = snp_type,
-       .release_port = snp_release_port,
-       .request_port = snp_request_port,
-       .config_port = snp_config_port,
-       .verify_port = NULL,
-};
-
-/* End of uart struct functions and defines */
-
-#ifdef DEBUG
-
-/**
- * sn_debug_printf - close to hardware debugging printf
- * @fmt: printf format
- *
- * This is as "close to the metal" as we can get, used when the driver
- * itself may be broken.
- *
- */
-static int
-sn_debug_printf(const char *fmt, ...)
-{
-       static char printk_buf[1024];
-       int printed_len;
-       va_list args;
-
-       va_start(args, fmt);
-       printed_len = vsnprintf(printk_buf, sizeof (printk_buf), fmt, args);
-
-       if (!sal_console_port.sc_ops) {
-               if (IS_RUNNING_ON_SIMULATOR())
-                       sal_console_port.sc_ops = &sim_ops;
-               else
-                       sal_console_port.sc_ops = &poll_ops;
-
-               early_sn_setup();
-       }
-       sal_console_port.sc_ops->sal_puts_raw(printk_buf, printed_len);
-
-       va_end(args);
-       return printed_len;
-}
-#endif /* DEBUG */
-
-/*
- * Interrupt handling routines.
- */
-
-
-/**
- * sn_receive_chars - Grab characters, pass them to tty layer
- * @port: Port to operate on
- * @regs: Saved registers (needed by uart_handle_sysrq_char)
- *
- * Note: If we're not registered with the serial core infrastructure yet,
- * we don't try to send characters to it...
- *
- */
-static void
-sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs)
-{
-       int ch;
-       struct tty_struct *tty;
-
-       if (!port) {
-               printk(KERN_ERR "sn_receive_chars - port NULL so can't receieve\n");
-               return;
-       }
-
-       if (!port->sc_ops) {
-               printk(KERN_ERR "sn_receive_chars - port->sc_ops  NULL so can't receieve\n");
-               return;
-       }
-
-       if (port->sc_port.info) {
-               /* The serial_core stuffs are initilized, use them */
-               tty = port->sc_port.info->tty;
-       }
-       else {
-               /* Not registered yet - can't pass to tty layer.  */
-               tty = NULL;
-       }
-
-       while (port->sc_ops->sal_input_pending()) {
-               ch = port->sc_ops->sal_getc();
-               if (ch < 0) {
-                       printk(KERN_ERR "sn_console: An error occured while "
-                              "obtaining data from the console (0x%0x)\n", ch);
-                       break;
-               }
-#if defined(CONFIG_SERIAL_SGI_L1_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-               if (uart_handle_sysrq_char(&port->sc_port, ch, regs))
-                       continue;
-#endif                         /* CONFIG_SERIAL_SGI_L1_CONSOLE && CONFIG_MAGIC_SYSRQ */
-
-               /* record the character to pass up to the tty layer */
-               if (tty) {
-                       *tty->flip.char_buf_ptr = ch;
-                       *tty->flip.flag_buf_ptr = TTY_NORMAL;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
-                       if (tty->flip.count == TTY_FLIPBUF_SIZE)
-                               break;
-               }
-               else {
-               }
-               port->sc_port.icount.rx++;
-       }
-
-       if (tty)
-               tty_flip_buffer_push(tty);
-}
-
-/**
- * sn_transmit_chars - grab characters from serial core, send off
- * @port: Port to operate on
- * @raw: Transmit raw or buffered
- *
- * Note: If we're early, before we're registered with serial core, the
- * writes are going through sn_sal_console_write because that's how
- * register_console has been set up.  We currently could have asynch
- * polls calling this function due to sn_sal_switch_to_asynch but we can
- * ignore them until we register with the serial core stuffs.
- *
- */
-static void
-sn_transmit_chars(struct sn_cons_port *port, int raw)
-{
-       int xmit_count, tail, head, loops, ii;
-       int result;
-       char *start;
-       struct circ_buf *xmit;
-
-       if (!port)
-               return;
-
-       BUG_ON(!port->sc_is_asynch);
-
-       if (port->sc_port.info) {
-               /* We're initilized, using serial core infrastructure */
-               xmit = &port->sc_port.info->xmit;
-       }
-       else {
-               /* Probably sn_sal_switch_to_asynch has been run but serial core isn't
-                * initilized yet.  Just return.  Writes are going through
-                * sn_sal_console_write (due to register_console) at this time.
-                */
-               return;
-       }
-
-       if (uart_circ_empty(xmit) || uart_tx_stopped(&port->sc_port)) {
-               /* Nothing to do. */
-               return;
-       }
-
-       head = xmit->head;
-       tail = xmit->tail;
-       start = &xmit->buf[tail];
-
-       /* twice around gets the tail to the end of the buffer and
-        * then to the head, if needed */
-       loops = (head < tail) ? 2 : 1;
-
-       for (ii = 0; ii < loops; ii++) {
-               xmit_count = (head < tail) ?
-                   (UART_XMIT_SIZE - tail) : (head - tail);
-
-               if (xmit_count > 0) {
-                       if (raw == TRANSMIT_RAW)
-                               result =
-                                   port->sc_ops->sal_puts_raw(start,
-                                                              xmit_count);
-                       else
-                               result =
-                                   port->sc_ops->sal_puts(start, xmit_count);
-#ifdef DEBUG
-                       if (!result)
-                               DPRINTF("`");
-#endif
-                       if (result > 0) {
-                               xmit_count -= result;
-                               port->sc_port.icount.tx += result;
-                               tail += result;
-                               tail &= UART_XMIT_SIZE - 1;
-                               xmit->tail = tail;
-                               start = &xmit->buf[tail];
-                       }
-               }
-       }
-
-       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
-               uart_write_wakeup(&port->sc_port);
-
-       if (uart_circ_empty(xmit))
-               snp_stop_tx(&port->sc_port, 0); /* no-op for us */
-}
-
-/**
- * sn_sal_interrupt - Handle console interrupts
- * @irq: irq #, useful for debug statements
- * @dev_id: our pointer to our port (sn_cons_port which contains the uart port)
- * @regs: Saved registers, used by sn_receive_chars for uart_handle_sysrq_char
- *
- */
-static irqreturn_t
-sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct sn_cons_port *port = (struct sn_cons_port *) dev_id;
-       unsigned long flags;
-       int status = ia64_sn_console_intr_status();
-
-       if (!port)
-               return IRQ_NONE;
-
-       spin_lock_irqsave(&port->sc_port.lock, flags);
-       if (status & SAL_CONSOLE_INTR_RECV) {
-               sn_receive_chars(port, regs);
-       }
-       if (status & SAL_CONSOLE_INTR_XMIT) {
-               sn_transmit_chars(port, TRANSMIT_BUFFERED);
-       }
-       spin_unlock_irqrestore(&port->sc_port.lock, flags);
-       return IRQ_HANDLED;
-}
-
-/**
- * sn_sal_connect_interrupt - Request interrupt, handled by sn_sal_interrupt
- * @port: Our sn_cons_port (which contains the uart port)
- *
- * returns the console irq if interrupt is successfully registered, else 0
- *
- */
-static int
-sn_sal_connect_interrupt(struct sn_cons_port *port)
-{
-       if (request_irq(SGI_UART_VECTOR, sn_sal_interrupt, SA_INTERRUPT,
-                       "SAL console driver", port) >= 0) {
-               return SGI_UART_VECTOR;
-       }
-
-       printk(KERN_INFO "sn_console: console proceeding in polled mode\n");
-       return 0;
-}
-
-/**
- * sn_sal_timer_poll - this function handles polled console mode
- * @data: A pointer to our sn_cons_port (which contains the uart port)
- *
- * data is the pointer that init_timer will store for us.  This function is
- * associated with init_timer to see if there is any console traffic.
- * Obviously not used in interrupt mode
- *
- */
-static void
-sn_sal_timer_poll(unsigned long data)
-{
-       struct sn_cons_port *port = (struct sn_cons_port *) data;
-       unsigned long flags;
-
-       if (!port)
-               return;
-
-       if (!port->sc_port.irq) {
-               spin_lock_irqsave(&port->sc_port.lock, flags);
-               sn_receive_chars(port, NULL);
-               sn_transmit_chars(port, TRANSMIT_RAW);
-               spin_unlock_irqrestore(&port->sc_port.lock, flags);
-               mod_timer(&port->sc_timer,
-                         jiffies + port->sc_interrupt_timeout);
-       }
-}
-
-/*
- * Boot-time initialization code
- */
-
-/**
- * sn_sal_switch_to_asynch - Switch to async mode (as opposed to synch)
- * @port: Our sn_cons_port (which contains the uart port)
- *
- * So this is used by sn_sal_serial_console_init (early on, before we're
- * registered with serial core).  It's also used by sn_sal_module_init
- * right after we've registered with serial core.  The later only happens
- * if we didn't already come through here via sn_sal_serial_console_init.
- *
- */
-static void __init
-sn_sal_switch_to_asynch(struct sn_cons_port *port)
-{
-       unsigned long flags;
-
-       if (!port)
-               return;
-
-       DPRINTF("sn_console: about to switch to asynchronous console\n");
-
-       /* without early_printk, we may be invoked late enough to race
-        * with other cpus doing console IO at this point, however
-        * console interrupts will never be enabled */
-       spin_lock_irqsave(&port->sc_port.lock, flags);
-
-       /* early_printk invocation may have done this for us */
-       if (!port->sc_ops) {
-               if (IS_RUNNING_ON_SIMULATOR())
-                       port->sc_ops = &sim_ops;
-               else
-                       port->sc_ops = &poll_ops;
-       }
-
-       /* we can't turn on the console interrupt (as request_irq
-        * calls kmalloc, which isn't set up yet), so we rely on a
-        * timer to poll for input and push data from the console
-        * buffer.
-        */
-       init_timer(&port->sc_timer);
-       port->sc_timer.function = sn_sal_timer_poll;
-       port->sc_timer.data = (unsigned long) port;
-
-       if (IS_RUNNING_ON_SIMULATOR())
-               port->sc_interrupt_timeout = 6;
-       else {
-               /* 960cps / 16 char FIFO = 60HZ
-                * HZ / (SN_SAL_FIFO_SPEED_CPS / SN_SAL_FIFO_DEPTH) */
-               port->sc_interrupt_timeout =
-                   HZ * SN_SAL_UART_FIFO_DEPTH / SN_SAL_UART_FIFO_SPEED_CPS;
-       }
-       mod_timer(&port->sc_timer, jiffies + port->sc_interrupt_timeout);
-
-       port->sc_is_asynch = 1;
-       spin_unlock_irqrestore(&port->sc_port.lock, flags);
-}
-
-/**
- * sn_sal_switch_to_interrupts - Switch to interrupt driven mode
- * @port: Our sn_cons_port (which contains the uart port)
- *
- * In sn_sal_module_init, after we're registered with serial core and
- * the port is added, this function is called to switch us to interrupt
- * mode.  We were previously in asynch/polling mode (using init_timer).
- *
- * We attempt to switch to interrupt mode here by calling
- * sn_sal_connect_interrupt.  If that works out, we enable receive interrupts.
- */
-static void __init
-sn_sal_switch_to_interrupts(struct sn_cons_port *port)
-{
-       int irq;
-       unsigned long flags;
-
-       if (!port)
-               return;
-
-       DPRINTF("sn_console: switching to interrupt driven console\n");
-
-       spin_lock_irqsave(&port->sc_port.lock, flags);
-
-       irq = sn_sal_connect_interrupt(port);
-
-       if (irq) {
-               port->sc_port.irq = irq;
-               port->sc_ops = &intr_ops;
-
-               /* turn on receive interrupts */
-               ia64_sn_console_intr_enable(SAL_CONSOLE_INTR_RECV);
-       }
-       spin_unlock_irqrestore(&port->sc_port.lock, flags);
-}
-
-/*
- * Kernel console definitions
- */
-
-#ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
-static void sn_sal_console_write(struct console *, const char *, unsigned);
-static int __init sn_sal_console_setup(struct console *, char *);
-extern struct uart_driver sal_console_uart;
-extern struct tty_driver *uart_console_device(struct console *, int *);
-
-static struct console sal_console = {
-       .name = DEVICE_NAME,
-       .write = sn_sal_console_write,
-       .device = uart_console_device,
-       .setup = sn_sal_console_setup,
-       .index = -1, /* unspecified */
-       .data = &sal_console_uart,
-};
-
-#define SAL_CONSOLE    &sal_console
-#else
-#define SAL_CONSOLE    0
-#endif                         /* CONFIG_SERIAL_SGI_L1_CONSOLE */
-
-static struct uart_driver sal_console_uart = {
-       .owner = THIS_MODULE,
-       .driver_name = "sn_console",
-       .dev_name = DEVICE_NAME,
-       .major = 0, /* major/minor set at registration time per USE_DYNAMIC_MINOR */
-       .minor = 0,
-       .nr = 1,        /* one port */
-       .cons = SAL_CONSOLE,
-};
-
-/**
- * sn_sal_module_init - When the kernel loads us, get us rolling w/ serial core
- *
- * Before this is called, we've been printing kernel messages in a special
- * early mode not making use of the serial core infrastructure.  When our
- * driver is loaded for real, we register the driver and port with serial
- * core and try to enable interrupt driven mode.
- *
- */
-static int __init
-sn_sal_module_init(void)
-{
-       int retval;
-
-       printk(KERN_INFO "sn_console: Console driver init\n");
-
-       if (!ia64_platform_is("sn2"))
-               return -ENODEV;
-
-       if (USE_DYNAMIC_MINOR == 1) {
-               misc.minor = MISC_DYNAMIC_MINOR;
-               misc.name = DEVICE_NAME_DYNAMIC;
-               retval = misc_register(&misc);
-               if (retval != 0) {
-                       printk("Failed to register console device using misc_register.\n");
-                       return -ENODEV;
-               }
-               sal_console_uart.major = MISC_MAJOR;
-               sal_console_uart.minor = misc.minor;
-       }
-       else {
-               sal_console_uart.major = DEVICE_MAJOR;
-               sal_console_uart.minor = DEVICE_MINOR;
-       }
-
-       /* We register the driver and the port before switching to interrupts
-    * or async above so the proper uart structures are populated */
-
-       if (uart_register_driver(&sal_console_uart) < 0) {
-               printk("ERROR sn_sal_module_init failed uart_register_driver, line %d\n",
-                 __LINE__);
-               return -ENODEV;
-       }
-
-       sal_console_port.sc_port.lock = SPIN_LOCK_UNLOCKED;
-
-       /* Setup the port struct with the minimum needed */
-       sal_console_port.sc_port.membase = (char *)1;   /* just needs to be non-zero */
-       sal_console_port.sc_port.type = PORT_16550A;
-       sal_console_port.sc_port.fifosize = SN_SAL_MAX_CHARS;
-       sal_console_port.sc_port.ops = &sn_console_ops;
-       sal_console_port.sc_port.line = 0;
-
-       if (uart_add_one_port(&sal_console_uart, &sal_console_port.sc_port) < 0) {
-               /* error - not sure what I'd do - so I'll do nothing */
-               printk(KERN_ERR "%s: unable to add port\n", __FUNCTION__);
-       }
-
-       /* when this driver is compiled in, the console initialization
-        * will have already switched us into asynchronous operation
-        * before we get here through the module initcalls */
-       if (!sal_console_port.sc_is_asynch) {
-               sn_sal_switch_to_asynch(&sal_console_port);
-       }
-
-       /* at this point (module_init) we can try to turn on interrupts */
-       if (!IS_RUNNING_ON_SIMULATOR()) {
-               sn_sal_switch_to_interrupts(&sal_console_port);
-       }
-       return 0;
-}
-
-/**
- * sn_sal_module_exit - When we're unloaded, remove the driver/port
- *
- */
-static void __exit
-sn_sal_module_exit(void)
-{
-       del_timer_sync(&sal_console_port.sc_timer);
-       uart_remove_one_port(&sal_console_uart, &sal_console_port.sc_port);
-       uart_unregister_driver(&sal_console_uart);
-       misc_deregister(&misc);
-}
-
-module_init(sn_sal_module_init);
-module_exit(sn_sal_module_exit);
-
-#ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
-
-/**
- * puts_raw_fixed - sn_sal_console_write helper for adding \r's as required
- * @puts_raw : puts function to do the writing
- * @s: input string
- * @count: length
- *
- * We need a \r ahead of every \n for direct writes through
- * ia64_sn_console_putb (what sal_puts_raw below actually does).
- *
- */
-
-static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
-{
-       const char *s1;
-
-       /* Output '\r' before each '\n' */
-       while ((s1 = memchr(s, '\n', count)) != NULL) {
-               puts_raw(s, s1 - s);
-               puts_raw("\r\n", 2);
-               count -= s1 + 1 - s;
-               s = s1 + 1;
-       }
-       puts_raw(s, count);
-}
-
-/**
- * sn_sal_console_write - Print statements before serial core available
- * @console: Console to operate on - we ignore since we have just one
- * @s: String to send
- * @count: length
- *
- * This is referenced in the console struct.  It is used for early
- * console printing before we register with serial core and for things
- * such as kdb.  The console_lock must be held when we get here.
- *
- * This function has some code for trying to print output even if the lock
- * is held.  We try to cover the case where a lock holder could have died.
- * We don't use this special case code if we're not registered with serial
- * core yet.  After we're registered with serial core, the only time this
- * function would be used is for high level kernel output like magic sys req,
- * kdb, and printk's.
- */
-static void
-sn_sal_console_write(struct console *co, const char *s, unsigned count)
-{
-       unsigned long flags = 0;
-       struct sn_cons_port *port = &sal_console_port;
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
-       static int stole_lock = 0;
-#endif
-
-       BUG_ON(!port->sc_is_asynch);
-
-       /* We can't look at the xmit buffer if we're not registered with serial core
-        *  yet.  So only do the fancy recovery after registering
-        */
-       if (port->sc_port.info) {
-
-               /* somebody really wants this output, might be an
-               * oops, kdb, panic, etc.  make sure they get it. */
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
-               if (spin_is_locked(&port->sc_port.lock)) {
-                       int lhead = port->sc_port.info->xmit.head;
-                       int ltail = port->sc_port.info->xmit.tail;
-                       int counter, got_lock = 0;
-
-                       /*
-                        * We attempt to determine if someone has died with the
-                        * lock. We wait ~20 secs after the head and tail ptrs
-                        * stop moving and assume the lock holder is not functional
-                        * and plow ahead. If the lock is freed within the time out
-                        * period we re-get the lock and go ahead normally. We also
-                        * remember if we have plowed ahead so that we don't have
-                        * to wait out the time out period again - the asumption
-                        * is that we will time out again.
-                        */
-
-                       for (counter = 0; counter < 150; mdelay(125), counter++) {
-                               if (!spin_is_locked(&port->sc_port.lock) || stole_lock) {
-                                       if (!stole_lock) {
-                                               spin_lock_irqsave(&port->sc_port.lock, flags);
-                                               got_lock = 1;
-                                       }
-                                       break;
-                               }
-                               else {
-                                       /* still locked */
-                                       if ((lhead != port->sc_port.info->xmit.head) || (ltail != port->sc_port.info->xmit.tail)) {
-                                               lhead = port->sc_port.info->xmit.head;
-                                               ltail = port->sc_port.info->xmit.tail;
-                                               counter = 0;
-                                       }
-                               }
-                       }
-                       /* flush anything in the serial core xmit buffer, raw */
-                       sn_transmit_chars(port, 1);
-                       if (got_lock) {
-                               spin_unlock_irqrestore(&port->sc_port.lock, flags);
-                               stole_lock = 0;
-                       }
-                       else {
-                               /* fell thru */
-                               stole_lock = 1;
-                       }
-                       puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
-               }
-               else {
-                       stole_lock = 0;
-#endif
-                       spin_lock_irqsave(&port->sc_port.lock, flags);
-                       sn_transmit_chars(port, 1);
-                       spin_unlock_irqrestore(&port->sc_port.lock, flags);
-
-                       puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
-               }
-       }
-       else {
-               /* Not yet registered with serial core - simple case */
-               puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
-       }
-}
-
-
-/**
- * sn_sal_console_setup - Set up console for early printing
- * @co: Console to work with
- * @options: Options to set
- *
- * Altix console doesn't do anything with baud rates, etc, anyway.
- *
- * This isn't required since not providing the setup function in the
- * console struct is ok.  However, other patches like KDB plop something
- * here so providing it is easier.
- *
- */
-static int __init
-sn_sal_console_setup(struct console *co, char *options)
-{
-       return 0;
-}
-
-/**
- * sn_sal_console_write_early - simple early output routine
- * @co - console struct
- * @s - string to print
- * @count - count
- *
- * Simple function to provide early output, before even
- * sn_sal_serial_console_init is called.  Referenced in the
- * console struct registerd in sn_serial_console_early_setup.
- *
- */
-static void __init
-sn_sal_console_write_early(struct console *co, const char *s, unsigned count)
-{
-       puts_raw_fixed(sal_console_port.sc_ops->sal_puts_raw, s, count);
-}
-
-/* Used for very early console printing - again, before
- * sn_sal_serial_console_init is run */
-static struct console sal_console_early __initdata = {
-       .name = "sn_sal",
-       .write = sn_sal_console_write_early,
-       .flags = CON_PRINTBUFFER,
-       .index  = -1,
-};
-
-/**
- * sn_serial_console_early_setup - Sets up early console output support
- *
- * Register a console early on...  This is for output before even
- * sn_sal_serial_cosnole_init is called.  This function is called from
- * setup.c.  This allows us to do really early polled writes. When
- * sn_sal_serial_console_init is called, this console is unregistered
- * and a new one registered.
- */
-int __init
-sn_serial_console_early_setup(void)
-{
-       if (!ia64_platform_is("sn2"))
-               return -1;
-
-       if (IS_RUNNING_ON_SIMULATOR())
-               sal_console_port.sc_ops = &sim_ops;
-       else
-               sal_console_port.sc_ops = &poll_ops;
-
-       early_sn_setup(); /* Find SAL entry points */
-       register_console(&sal_console_early);
-
-       return 0;
-}
-
-
-/**
- * sn_sal_serial_console_init - Early console output - set up for register
- *
- * This function is called when regular console init happens.  Because we
- * support even earlier console output with sn_serial_console_early_setup
- * (called from setup.c directly), this function unregisters the really
- * early console.
- *
- * Note: Even if setup.c doesn't register sal_console_early, unregistering
- * it here doesn't hurt anything.
- *
- */
-static int __init
-sn_sal_serial_console_init(void)
-{
-       if (ia64_platform_is("sn2")) {
-               sn_sal_switch_to_asynch(&sal_console_port);
-               DPRINTF ("sn_sal_serial_console_init : register console\n");
-               register_console(&sal_console);
-               unregister_console(&sal_console_early);
-       }
-       return 0;
-}
-
-console_initcall(sn_sal_serial_console_init);
-
-#endif                         /* CONFIG_SERIAL_SGI_L1_CONSOLE */
diff --git a/drivers/usb/core/driverfs.c b/drivers/usb/core/driverfs.c
deleted file mode 100644 (file)
index 51ff9bb..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * drivers/usb/core/driverfs.c
- *
- * (C) Copyright 2002 David Brownell
- * (C) Copyright 2002 Greg Kroah-Hartman
- * (C) Copyright 2002 IBM Corp.
- *
- * All of the driverfs file attributes for usb devices and interfaces.
- *
- */
-
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-
-#ifdef CONFIG_USB_DEBUG
-       #define DEBUG
-#else
-       #undef DEBUG
-#endif
-#include <linux/usb.h>
-
-#include "usb.h"
-
-/* Active configuration fields */
-#define usb_actconfig_show(field, multiplier, format_string)           \
-static ssize_t  show_##field (struct device *dev, char *buf)           \
-{                                                                      \
-       struct usb_device *udev;                                        \
-                                                                       \
-       udev = to_usb_device (dev);                                     \
-       if (udev->actconfig)                                            \
-               return sprintf (buf, format_string,                     \
-                               udev->actconfig->desc.field * multiplier);      \
-       else                                                            \
-               return 0;                                               \
-}                                                                      \
-
-#define usb_actconfig_attr(field, multiplier, format_string)           \
-usb_actconfig_show(field, multiplier, format_string)                   \
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
-
-usb_actconfig_attr (bNumInterfaces, 1, "%2d\n")
-usb_actconfig_attr (bmAttributes, 1, "%2x\n")
-usb_actconfig_attr (bMaxPower, 2, "%3dmA\n")
-
-/* configuration value is always present, and r/w */
-usb_actconfig_show(bConfigurationValue, 1, "%u\n");
-
-static ssize_t
-set_bConfigurationValue (struct device *dev, const char *buf, size_t count)
-{
-       struct usb_device       *udev = udev = to_usb_device (dev);
-       int                     config, value;
-
-       if (sscanf (buf, "%u", &config) != 1 || config > 255)
-               return -EINVAL;
-       down(&udev->serialize);
-       value = usb_set_configuration (udev, config);
-       up(&udev->serialize);
-       return (value < 0) ? value : count;
-}
-
-static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, 
-               show_bConfigurationValue, set_bConfigurationValue);
-
-/* String fields */
-#define usb_string_attr(name, field)           \
-static ssize_t  show_##name(struct device *dev, char *buf)             \
-{                                                                      \
-       struct usb_device *udev;                                        \
-       int len;                                                        \
-                                                                       \
-       udev = to_usb_device (dev);                                     \
-       len = usb_string(udev, udev->descriptor.field, buf, PAGE_SIZE); \
-       if (len < 0)                                                    \
-               return 0;                                               \
-       buf[len] = '\n';                                                \
-       buf[len+1] = 0;                                                 \
-       return len+1;                                                   \
-}                                                                      \
-static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
-
-usb_string_attr(product, iProduct);
-usb_string_attr(manufacturer, iManufacturer);
-usb_string_attr(serial, iSerialNumber);
-
-static ssize_t
-show_speed (struct device *dev, char *buf)
-{
-       struct usb_device *udev;
-       char *speed;
-
-       udev = to_usb_device (dev);
-
-       switch (udev->speed) {
-       case USB_SPEED_LOW:
-               speed = "1.5";
-               break;
-       case USB_SPEED_UNKNOWN:
-       case USB_SPEED_FULL:
-               speed = "12";
-               break;
-       case USB_SPEED_HIGH:
-               speed = "480";
-               break;
-       default:
-               speed = "unknown";
-       }
-       return sprintf (buf, "%s\n", speed);
-}
-static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL);
-
-static ssize_t
-show_devnum (struct device *dev, char *buf)
-{
-       struct usb_device *udev;
-
-       udev = to_usb_device (dev);
-       return sprintf (buf, "%d\n", udev->devnum);
-}
-static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL);
-
-static ssize_t
-show_version (struct device *dev, char *buf)
-{
-       struct usb_device *udev;
-
-       udev = to_usb_device (dev);
-       return sprintf (buf, "%2x.%02x\n", udev->descriptor.bcdUSB >> 8, 
-                       udev->descriptor.bcdUSB & 0xff);
-}
-static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
-
-static ssize_t
-show_maxchild (struct device *dev, char *buf)
-{
-       struct usb_device *udev;
-
-       udev = to_usb_device (dev);
-       return sprintf (buf, "%d\n", udev->maxchild);
-}
-static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL);
-
-/* Descriptor fields */
-#define usb_descriptor_attr(field, format_string)                      \
-static ssize_t                                                         \
-show_##field (struct device *dev, char *buf)                           \
-{                                                                      \
-       struct usb_device *udev;                                        \
-                                                                       \
-       udev = to_usb_device (dev);                                     \
-       return sprintf (buf, format_string, udev->descriptor.field);    \
-}                                                                      \
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
-
-usb_descriptor_attr (idVendor, "%04x\n")
-usb_descriptor_attr (idProduct, "%04x\n")
-usb_descriptor_attr (bcdDevice, "%04x\n")
-usb_descriptor_attr (bDeviceClass, "%02x\n")
-usb_descriptor_attr (bDeviceSubClass, "%02x\n")
-usb_descriptor_attr (bDeviceProtocol, "%02x\n")
-usb_descriptor_attr (bNumConfigurations, "%d\n")
-
-
-void usb_create_driverfs_dev_files (struct usb_device *udev)
-{
-       struct device *dev = &udev->dev;
-
-       /* current configuration's attributes */
-       device_create_file (dev, &dev_attr_bNumInterfaces);
-       device_create_file (dev, &dev_attr_bConfigurationValue);
-       device_create_file (dev, &dev_attr_bmAttributes);
-       device_create_file (dev, &dev_attr_bMaxPower);
-
-       /* device attributes */
-       device_create_file (dev, &dev_attr_idVendor);
-       device_create_file (dev, &dev_attr_idProduct);
-       device_create_file (dev, &dev_attr_bcdDevice);
-       device_create_file (dev, &dev_attr_bDeviceClass);
-       device_create_file (dev, &dev_attr_bDeviceSubClass);
-       device_create_file (dev, &dev_attr_bDeviceProtocol);
-       device_create_file (dev, &dev_attr_bNumConfigurations);
-
-       /* speed varies depending on how you connect the device */
-       device_create_file (dev, &dev_attr_speed);
-       // FIXME iff there are other speed configs, show how many
-
-       if (udev->descriptor.iManufacturer)
-               device_create_file (dev, &dev_attr_manufacturer);
-       if (udev->descriptor.iProduct)
-               device_create_file (dev, &dev_attr_product);
-       if (udev->descriptor.iSerialNumber)
-               device_create_file (dev, &dev_attr_serial);
-
-       device_create_file (dev, &dev_attr_devnum);
-       device_create_file (dev, &dev_attr_version);
-       device_create_file (dev, &dev_attr_maxchild);
-}
-
-/* Interface fields */
-#define usb_intf_attr(field, format_string)                            \
-static ssize_t                                                         \
-show_##field (struct device *dev, char *buf)                           \
-{                                                                      \
-       struct usb_interface *intf = to_usb_interface (dev);            \
-                                                                       \
-       return sprintf (buf, format_string, intf->cur_altsetting->desc.field); \
-}                                                                      \
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
-
-usb_intf_attr (bInterfaceNumber, "%02x\n")
-usb_intf_attr (bAlternateSetting, "%2d\n")
-usb_intf_attr (bNumEndpoints, "%02x\n")
-usb_intf_attr (bInterfaceClass, "%02x\n")
-usb_intf_attr (bInterfaceSubClass, "%02x\n")
-usb_intf_attr (bInterfaceProtocol, "%02x\n")
-usb_intf_attr (iInterface, "%02x\n")
-
-void usb_create_driverfs_intf_files (struct usb_interface *intf)
-{
-       device_create_file (&intf->dev, &dev_attr_bInterfaceNumber);
-       device_create_file (&intf->dev, &dev_attr_bAlternateSetting);
-       device_create_file (&intf->dev, &dev_attr_bNumEndpoints);
-       device_create_file (&intf->dev, &dev_attr_bInterfaceClass);
-       device_create_file (&intf->dev, &dev_attr_bInterfaceSubClass);
-       device_create_file (&intf->dev, &dev_attr_bInterfaceProtocol);
-       device_create_file (&intf->dev, &dev_attr_iInterface);
-}
index d3bb7b5..7299b7c 100644 (file)
@@ -344,6 +344,7 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
        dbg_hcc_params (ehci, "reset");
 
 #ifdef CONFIG_PCI
+       writel(0, &ehci->regs->intr_enable);
        /* EHCI 0.96 and later may have "extended capabilities" */
        if (hcd->self.controller->bus == &pci_bus_type)
                temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
diff --git a/drivers/usb/media/w9968cf_externaldef.h b/drivers/usb/media/w9968cf_externaldef.h
deleted file mode 100644 (file)
index 6817356..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/***************************************************************************
- * Various definitions for compatibility with OVCAMCHIP external module.   *
- * This file is part of the W996[87]CF driver for Linux.                   *
- *                                                                         *
- * The definitions have been taken from the OVCAMCHIP module written by    *
- * Mark McClelland.                                                        *
- *                                                                         *
- * This program is free software; you can redistribute it and/or modify    *
- * it under the terms of the GNU General Public License as published by    *
- * the Free Software Foundation; either version 2 of the License, or       *
- * (at your option) any later version.                                     *
- *                                                                         *
- * This program is distributed in the hope that it will be useful,         *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
- * GNU General Public License for more details.                            *
- *                                                                         *
- * You should have received a copy of the GNU General Public License       *
- * along with this program; if not, write to the Free Software             *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               *
- ***************************************************************************/
-
-#ifndef _W9968CF_EXTERNALDEF_H_
-#define _W9968CF_EXTERNALDEF_H_
-
-#include <linux/videodev.h>
-#include <linux/i2c.h>
-#include <asm/ioctl.h>
-#include <asm/types.h>
-
-#ifndef I2C_DRIVERID_OVCAMCHIP
-#      define I2C_DRIVERID_OVCAMCHIP 0xf00f
-#endif
-
-/* Controls */
-enum {
-       OVCAMCHIP_CID_CONT,       /* Contrast */
-       OVCAMCHIP_CID_BRIGHT,     /* Brightness */
-       OVCAMCHIP_CID_SAT,        /* Saturation */
-       OVCAMCHIP_CID_HUE,        /* Hue */
-       OVCAMCHIP_CID_EXP,        /* Exposure */
-       OVCAMCHIP_CID_FREQ,       /* Light frequency */
-       OVCAMCHIP_CID_BANDFILT,   /* Banding filter */
-       OVCAMCHIP_CID_AUTOBRIGHT, /* Auto brightness */
-       OVCAMCHIP_CID_AUTOEXP,    /* Auto exposure */
-       OVCAMCHIP_CID_BACKLIGHT,  /* Back light compensation */
-       OVCAMCHIP_CID_MIRROR,     /* Mirror horizontally */
-};
-
-/* I2C addresses */
-#define OV7xx0_SID   (0x42 >> 1)
-#define OV6xx0_SID   (0xC0 >> 1)
-
-/* Sensor types */
-enum {
-       CC_UNKNOWN,
-       CC_OV76BE,
-       CC_OV7610,
-       CC_OV7620,
-       CC_OV7620AE,
-       CC_OV6620,
-       CC_OV6630,
-       CC_OV6630AE,
-       CC_OV6630AF,
-};
-
-/* API */
-struct ovcamchip_control {
-       __u32 id;
-       __s32 value;
-};
-
-struct ovcamchip_window {
-       int x;
-       int y;
-       int width;
-       int height;
-       int format;
-       int quarter;  /* Scale width and height down 2x */
-
-       /* This stuff will be removed eventually */
-       int clockdiv; /* Clock divisor setting */
-};
-
-/* Commands. 
-   You must call OVCAMCHIP_CMD_INITIALIZE before any of other commands */
-#define OVCAMCHIP_CMD_Q_SUBTYPE  _IOR  (0x88, 0x00, int)
-#define OVCAMCHIP_CMD_INITIALIZE _IOW  (0x88, 0x01, int)
-#define OVCAMCHIP_CMD_S_CTRL     _IOW  (0x88, 0x02, struct ovcamchip_control)
-#define OVCAMCHIP_CMD_G_CTRL     _IOWR (0x88, 0x03, struct ovcamchip_control)
-#define OVCAMCHIP_CMD_S_MODE     _IOW  (0x88, 0x04, struct ovcamchip_window)
-#define OVCAMCHIP_MAX_CMD        _IO   (0x88, 0x3f)
-
-#endif /* _W9968CF_EXTERNALDEF_H_ */
index d003abe..43cb90d 100644 (file)
@@ -438,7 +438,7 @@ struct scsi_host_template usb_stor_host_template = {
        .sg_tablesize =                 SG_ALL,
 
        /* limit the total size of a transfer to 120 KB */
-       .max_sectors =                  240,
+       .max_sectors =                  256,
 
        /* merge commands... this seems to help performance, but
         * periodically someone should test to see which setting is more
index bd3b24c..acec888 100644 (file)
@@ -1406,19 +1406,23 @@ int radeonfb_set_par(struct fb_info *info)
 {
        struct radeonfb_info *rinfo = info->par;
        struct fb_var_screeninfo *mode = &info->var;
-       struct radeon_regs newmode;
+       struct radeon_regs *newmode;
        int hTotal, vTotal, hSyncStart, hSyncEnd,
            hSyncPol, vSyncStart, vSyncEnd, vSyncPol, cSync;
        u8 hsync_adj_tab[] = {0, 0x12, 9, 9, 6, 5};
        u8 hsync_fudge_fp[] = {2, 2, 0, 0, 5, 5};
        u32 sync, h_sync_pol, v_sync_pol, dotClock, pixClock;
        int i, freq;
-        int format = 0;
+       int format = 0;
        int nopllcalc = 0;
        int hsync_start, hsync_fudge, bytpp, hsync_wid, vsync_wid;
        int primary_mon = PRIMARY_MONITOR(rinfo);
        int depth = var_to_depth(mode);
 
+       newmode = kmalloc(sizeof(struct radeon_regs), GFP_KERNEL);
+       if (!newmode)
+               return -ENOMEM;
+
        /* We always want engine to be idle on a mode switch, even
         * if we won't actually change the mode
         */
@@ -1458,9 +1462,9 @@ int radeonfb_set_par(struct fb_info *info)
 
                if (rinfo->panel_info.use_bios_dividers) {
                        nopllcalc = 1;
-                       newmode.ppll_div_3 = rinfo->panel_info.fbk_divider |
+                       newmode->ppll_div_3 = rinfo->panel_info.fbk_divider |
                                (rinfo->panel_info.post_divider << 16);
-                       newmode.ppll_ref_div = rinfo->panel_info.ref_divider;
+                       newmode->ppll_ref_div = rinfo->panel_info.ref_divider;
                }
        }
        dotClock = 1000000000 / pixClock;
@@ -1498,38 +1502,38 @@ int radeonfb_set_par(struct fb_info *info)
 
        hsync_start = hSyncStart - 8 + hsync_fudge;
 
-       newmode.crtc_gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN |
+       newmode->crtc_gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN |
                                (format << 8);
 
        /* Clear auto-center etc... */
-       newmode.crtc_more_cntl = rinfo->init_state.crtc_more_cntl;
-       newmode.crtc_more_cntl &= 0xfffffff0;
+       newmode->crtc_more_cntl = rinfo->init_state.crtc_more_cntl;
+       newmode->crtc_more_cntl &= 0xfffffff0;
        
        if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) {
-               newmode.crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN;
+               newmode->crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN;
                if (mirror)
-                       newmode.crtc_ext_cntl |= CRTC_CRT_ON;
+                       newmode->crtc_ext_cntl |= CRTC_CRT_ON;
 
-               newmode.crtc_gen_cntl &= ~(CRTC_DBL_SCAN_EN |
+               newmode->crtc_gen_cntl &= ~(CRTC_DBL_SCAN_EN |
                                           CRTC_INTERLACE_EN);
        } else {
-               newmode.crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN |
+               newmode->crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN |
                                        CRTC_CRT_ON;
        }
 
-       newmode.dac_cntl = /* INREG(DAC_CNTL) | */ DAC_MASK_ALL | DAC_VGA_ADR_EN |
+       newmode->dac_cntl = /* INREG(DAC_CNTL) | */ DAC_MASK_ALL | DAC_VGA_ADR_EN |
                           DAC_8BIT_EN;
 
-       newmode.crtc_h_total_disp = ((((hTotal / 8) - 1) & 0x3ff) |
+       newmode->crtc_h_total_disp = ((((hTotal / 8) - 1) & 0x3ff) |
                                     (((mode->xres / 8) - 1) << 16));
 
-       newmode.crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) |
+       newmode->crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) |
                                        (hsync_wid << 16) | (h_sync_pol << 23));
 
-       newmode.crtc_v_total_disp = ((vTotal - 1) & 0xffff) |
+       newmode->crtc_v_total_disp = ((vTotal - 1) & 0xffff) |
                                    ((mode->yres - 1) << 16);
 
-       newmode.crtc_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff) |
+       newmode->crtc_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff) |
                                         (vsync_wid << 16) | (v_sync_pol  << 23));
 
        if (!(info->flags & FBINFO_HWACCEL_DISABLED)) {
@@ -1538,18 +1542,18 @@ int radeonfb_set_par(struct fb_info *info)
                                & ~(0x3f)) >> 6;
 
                /* Then, re-multiply it to get the CRTC pitch */
-               newmode.crtc_pitch = (rinfo->pitch << 3) / ((mode->bits_per_pixel + 1) / 8);
+               newmode->crtc_pitch = (rinfo->pitch << 3) / ((mode->bits_per_pixel + 1) / 8);
        } else
-               newmode.crtc_pitch = (mode->xres_virtual >> 3);
+               newmode->crtc_pitch = (mode->xres_virtual >> 3);
 
-       newmode.crtc_pitch |= (newmode.crtc_pitch << 16);
+       newmode->crtc_pitch |= (newmode->crtc_pitch << 16);
 
        /*
         * It looks like recent chips have a problem with SURFACE_CNTL,
         * setting SURF_TRANSLATION_DIS completely disables the
         * swapper as well, so we leave it unset now.
         */
-       newmode.surface_cntl = 0;
+       newmode->surface_cntl = 0;
 
 #if defined(__BIG_ENDIAN)
 
@@ -1559,28 +1563,28 @@ int radeonfb_set_par(struct fb_info *info)
         */
        switch (mode->bits_per_pixel) {
                case 16:
-                       newmode.surface_cntl |= NONSURF_AP0_SWP_16BPP;
-                       newmode.surface_cntl |= NONSURF_AP1_SWP_16BPP;
+                       newmode->surface_cntl |= NONSURF_AP0_SWP_16BPP;
+                       newmode->surface_cntl |= NONSURF_AP1_SWP_16BPP;
                        break;
                case 24:        
                case 32:
-                       newmode.surface_cntl |= NONSURF_AP0_SWP_32BPP;
-                       newmode.surface_cntl |= NONSURF_AP1_SWP_32BPP;
+                       newmode->surface_cntl |= NONSURF_AP0_SWP_32BPP;
+                       newmode->surface_cntl |= NONSURF_AP1_SWP_32BPP;
                        break;
        }
 #endif
 
        /* Clear surface registers */
        for (i=0; i<8; i++) {
-               newmode.surf_lower_bound[i] = 0;
-               newmode.surf_upper_bound[i] = 0x1f;
-               newmode.surf_info[i] = 0;
+               newmode->surf_lower_bound[i] = 0;
+               newmode->surf_upper_bound[i] = 0x1f;
+               newmode->surf_info[i] = 0;
        }
 
        RTRACE("h_total_disp = 0x%x\t   hsync_strt_wid = 0x%x\n",
-               newmode.crtc_h_total_disp, newmode.crtc_h_sync_strt_wid);
+               newmode->crtc_h_total_disp, newmode->crtc_h_sync_strt_wid);
        RTRACE("v_total_disp = 0x%x\t   vsync_strt_wid = 0x%x\n",
-               newmode.crtc_v_total_disp, newmode.crtc_v_sync_strt_wid);
+               newmode->crtc_v_total_disp, newmode->crtc_v_sync_strt_wid);
 
        rinfo->bpp = mode->bits_per_pixel;
        rinfo->depth = depth;
@@ -1589,9 +1593,9 @@ int radeonfb_set_par(struct fb_info *info)
        RTRACE("freq = %lu\n", (unsigned long)freq);
 
        if (!nopllcalc)
-               radeon_calc_pll_regs(rinfo, &newmode, freq);
+               radeon_calc_pll_regs(rinfo, newmode, freq);
 
-       newmode.vclk_ecp_cntl = rinfo->init_state.vclk_ecp_cntl;
+       newmode->vclk_ecp_cntl = rinfo->init_state.vclk_ecp_cntl;
 
        if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) {
                unsigned int hRatio, vRatio;
@@ -1601,35 +1605,35 @@ int radeonfb_set_par(struct fb_info *info)
                if (mode->yres > rinfo->panel_info.yres)
                        mode->yres = rinfo->panel_info.yres;
 
-               newmode.fp_horz_stretch = (((rinfo->panel_info.xres / 8) - 1)
+               newmode->fp_horz_stretch = (((rinfo->panel_info.xres / 8) - 1)
                                           << HORZ_PANEL_SHIFT);
-               newmode.fp_vert_stretch = ((rinfo->panel_info.yres - 1)
+               newmode->fp_vert_stretch = ((rinfo->panel_info.yres - 1)
                                           << VERT_PANEL_SHIFT);
 
                if (mode->xres != rinfo->panel_info.xres) {
                        hRatio = round_div(mode->xres * HORZ_STRETCH_RATIO_MAX,
                                           rinfo->panel_info.xres);
-                       newmode.fp_horz_stretch = (((((unsigned long)hRatio) & HORZ_STRETCH_RATIO_MASK)) |
-                                                  (newmode.fp_horz_stretch &
+                       newmode->fp_horz_stretch = (((((unsigned long)hRatio) & HORZ_STRETCH_RATIO_MASK)) |
+                                                  (newmode->fp_horz_stretch &
                                                    (HORZ_PANEL_SIZE | HORZ_FP_LOOP_STRETCH |
                                                     HORZ_AUTO_RATIO_INC)));
-                       newmode.fp_horz_stretch |= (HORZ_STRETCH_BLEND |
+                       newmode->fp_horz_stretch |= (HORZ_STRETCH_BLEND |
                                                    HORZ_STRETCH_ENABLE);
                }
-               newmode.fp_horz_stretch &= ~HORZ_AUTO_RATIO;
+               newmode->fp_horz_stretch &= ~HORZ_AUTO_RATIO;
 
                if (mode->yres != rinfo->panel_info.yres) {
                        vRatio = round_div(mode->yres * VERT_STRETCH_RATIO_MAX,
                                           rinfo->panel_info.yres);
-                       newmode.fp_vert_stretch = (((((unsigned long)vRatio) & VERT_STRETCH_RATIO_MASK)) |
-                                                  (newmode.fp_vert_stretch &
+                       newmode->fp_vert_stretch = (((((unsigned long)vRatio) & VERT_STRETCH_RATIO_MASK)) |
+                                                  (newmode->fp_vert_stretch &
                                                   (VERT_PANEL_SIZE | VERT_STRETCH_RESERVED)));
-                       newmode.fp_vert_stretch |= (VERT_STRETCH_BLEND |
+                       newmode->fp_vert_stretch |= (VERT_STRETCH_BLEND |
                                                    VERT_STRETCH_ENABLE);
                }
-               newmode.fp_vert_stretch &= ~VERT_AUTO_RATIO_EN;
+               newmode->fp_vert_stretch &= ~VERT_AUTO_RATIO_EN;
 
-               newmode.fp_gen_cntl = (rinfo->init_state.fp_gen_cntl & (u32)
+               newmode->fp_gen_cntl = (rinfo->init_state.fp_gen_cntl & (u32)
                                       ~(FP_SEL_CRTC2 |
                                         FP_RMX_HVSYNC_CONTROL_EN |
                                         FP_DFP_SYNC_SEL |
@@ -1639,46 +1643,46 @@ int radeonfb_set_par(struct fb_info *info)
                                         FP_CRTC_USE_SHADOW_VEND |
                                         FP_CRT_SYNC_ALT));
 
-               newmode.fp_gen_cntl |= (FP_CRTC_DONT_SHADOW_VPAR |
+               newmode->fp_gen_cntl |= (FP_CRTC_DONT_SHADOW_VPAR |
                                        FP_CRTC_DONT_SHADOW_HEND);
 
-               newmode.lvds_gen_cntl = rinfo->init_state.lvds_gen_cntl;
-               newmode.lvds_pll_cntl = rinfo->init_state.lvds_pll_cntl;
-               newmode.tmds_crc = rinfo->init_state.tmds_crc;
-               newmode.tmds_transmitter_cntl = rinfo->init_state.tmds_transmitter_cntl;
+               newmode->lvds_gen_cntl = rinfo->init_state.lvds_gen_cntl;
+               newmode->lvds_pll_cntl = rinfo->init_state.lvds_pll_cntl;
+               newmode->tmds_crc = rinfo->init_state.tmds_crc;
+               newmode->tmds_transmitter_cntl = rinfo->init_state.tmds_transmitter_cntl;
 
                if (primary_mon == MT_LCD) {
-                       newmode.lvds_gen_cntl |= (LVDS_ON | LVDS_BLON);
-                       newmode.fp_gen_cntl &= ~(FP_FPON | FP_TMDS_EN);
+                       newmode->lvds_gen_cntl |= (LVDS_ON | LVDS_BLON);
+                       newmode->fp_gen_cntl &= ~(FP_FPON | FP_TMDS_EN);
                } else {
                        /* DFP */
-                       newmode.fp_gen_cntl |= (FP_FPON | FP_TMDS_EN);
-                       newmode.tmds_transmitter_cntl = (TMDS_RAN_PAT_RST | TMDS_ICHCSEL) &
+                       newmode->fp_gen_cntl |= (FP_FPON | FP_TMDS_EN);
+                       newmode->tmds_transmitter_cntl = (TMDS_RAN_PAT_RST | TMDS_ICHCSEL) &
                                                         ~(TMDS_PLLRST);
                        /* TMDS_PLL_EN bit is reversed on RV (and mobility) chips */
                        if ((rinfo->family == CHIP_FAMILY_R300) ||
                            (rinfo->family == CHIP_FAMILY_R350) ||
                            (rinfo->family == CHIP_FAMILY_RV350) ||
                            (rinfo->family == CHIP_FAMILY_R200) || !rinfo->has_CRTC2)
-                               newmode.tmds_transmitter_cntl &= ~TMDS_PLL_EN;
+                               newmode->tmds_transmitter_cntl &= ~TMDS_PLL_EN;
                        else
-                               newmode.tmds_transmitter_cntl |= TMDS_PLL_EN;
-                       newmode.crtc_ext_cntl &= ~CRTC_CRT_ON;
+                               newmode->tmds_transmitter_cntl |= TMDS_PLL_EN;
+                       newmode->crtc_ext_cntl &= ~CRTC_CRT_ON;
                }
 
-               newmode.fp_crtc_h_total_disp = (((rinfo->panel_info.hblank / 8) & 0x3ff) |
+               newmode->fp_crtc_h_total_disp = (((rinfo->panel_info.hblank / 8) & 0x3ff) |
                                (((mode->xres / 8) - 1) << 16));
-               newmode.fp_crtc_v_total_disp = (rinfo->panel_info.vblank & 0xffff) |
+               newmode->fp_crtc_v_total_disp = (rinfo->panel_info.vblank & 0xffff) |
                                ((mode->yres - 1) << 16);
-               newmode.fp_h_sync_strt_wid = ((rinfo->panel_info.hOver_plus & 0x1fff) |
+               newmode->fp_h_sync_strt_wid = ((rinfo->panel_info.hOver_plus & 0x1fff) |
                                (hsync_wid << 16) | (h_sync_pol << 23));
-               newmode.fp_v_sync_strt_wid = ((rinfo->panel_info.vOver_plus & 0xfff) |
+               newmode->fp_v_sync_strt_wid = ((rinfo->panel_info.vOver_plus & 0xfff) |
                                (vsync_wid << 16) | (v_sync_pol  << 23));
        }
 
        /* do it! */
        if (!rinfo->asleep) {
-               radeon_write_mode (rinfo, &newmode);
+               radeon_write_mode (rinfo, newmode);
                /* (re)initialize the engine */
                if (!(info->flags & FBINFO_HWACCEL_DISABLED))
                        radeonfb_engine_init (rinfo);
@@ -1698,6 +1702,7 @@ int radeonfb_set_par(struct fb_info *info)
                             rinfo->depth, info->fix.line_length);
 #endif
 
+       kfree(newmode);
        return 0;
 }
 
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
deleted file mode 100644 (file)
index 0a860dd..0000000
+++ /dev/null
@@ -1,1384 +0,0 @@
-/*
- *  linux/drivers/video/pxafb.c
- *
- *  Copyright (C) 1999 Eric A. Thomas.
- *  Copyright (C) 2004 Jean-Frederic Clere.
- *  Copyright (C) 2004 Ian Campbell.
- *  Copyright (C) 2004 Jeff Lackey.
- *   Based on sa1100fb.c Copyright (C) 1999 Eric A. Thomas
- *  which in turn is
- *   Based on acornfb.c Copyright (C) Russell King.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive for
- * more details.
- *
- *             Intel PXA250/210 LCD Controller Frame Buffer Driver
- *
- * Please direct your questions and comments on this driver to the following
- * email address:
- *
- *     linux-arm-kernel@lists.arm.linux.org.uk
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/fb.h>
-#include <linux/delay.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/cpufreq.h>
-#include <linux/device.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/arch/bitfield.h>
-#include <asm/arch/pxafb.h>
-
-/*
- * Complain if VAR is out of range.
- */
-#define DEBUG_VAR 1
-
-#include "pxafb.h"
-
-/* Bits which should not be set in machine configuration structures */
-#define LCCR0_INVALID_CONFIG_MASK (LCCR0_OUM|LCCR0_BM|LCCR0_QDM|LCCR0_DIS|LCCR0_EFM|LCCR0_IUM|LCCR0_SFM|LCCR0_LDM|LCCR0_ENB)
-#define LCCR3_INVALID_CONFIG_MASK (LCCR3_HSP|LCCR3_VSP|LCCR3_PCD|LCCR3_BPP)
-
-static void (*pxafb_backlight_power)(int);
-static void (*pxafb_lcd_power)(int);
-
-static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *);
-static void set_ctrlr_state(struct pxafb_info *fbi, u_int state);
-
-#ifdef CONFIG_FB_PXA_PARAMETERS
-#define PXAFB_OPTIONS_SIZE 256
-static char g_options[PXAFB_OPTIONS_SIZE] __initdata = "";
-#endif
-
-static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state)
-{
-       unsigned long flags;
-
-       local_irq_save(flags);
-       /*
-        * We need to handle two requests being made at the same time.
-        * There are two important cases:
-        *  1. When we are changing VT (C_REENABLE) while unblanking (C_ENABLE)
-        *     We must perform the unblanking, which will do our REENABLE for us.
-        *  2. When we are blanking, but immediately unblank before we have
-        *     blanked.  We do the "REENABLE" thing here as well, just to be sure.
-        */
-       if (fbi->task_state == C_ENABLE && state == C_REENABLE)
-               state = (u_int) -1;
-       if (fbi->task_state == C_DISABLE && state == C_ENABLE)
-               state = C_REENABLE;
-
-       if (state != (u_int)-1) {
-               fbi->task_state = state;
-               schedule_work(&fbi->task);
-       }
-       local_irq_restore(flags);
-}
-
-static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf)
-{
-       chan &= 0xffff;
-       chan >>= 16 - bf->length;
-       return chan << bf->offset;
-}
-
-static int
-pxafb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue,
-                      u_int trans, struct fb_info *info)
-{
-       struct pxafb_info *fbi = (struct pxafb_info *)info;
-       u_int val, ret = 1;
-
-       if (regno < fbi->palette_size) {
-               if (fbi->fb.var.grayscale) {
-                       val = ((blue >> 8) & 0x00ff);
-               } else {
-                       val  = ((red   >>  0) & 0xf800);
-                       val |= ((green >>  5) & 0x07e0);
-                       val |= ((blue  >> 11) & 0x001f);
-               }
-               fbi->palette_cpu[regno] = val;
-               ret = 0;
-       }
-       return ret;
-}
-
-static int
-pxafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
-                  u_int trans, struct fb_info *info)
-{
-       struct pxafb_info *fbi = (struct pxafb_info *)info;
-       unsigned int val;
-       int ret = 1;
-
-       /*
-        * If inverse mode was selected, invert all the colours
-        * rather than the register number.  The register number
-        * is what you poke into the framebuffer to produce the
-        * colour you requested.
-        */
-       if (fbi->cmap_inverse) {
-               red   = 0xffff - red;
-               green = 0xffff - green;
-               blue  = 0xffff - blue;
-       }
-
-       /*
-        * If greyscale is true, then we convert the RGB value
-        * to greyscale no matter what visual we are using.
-        */
-       if (fbi->fb.var.grayscale)
-               red = green = blue = (19595 * red + 38470 * green +
-                                       7471 * blue) >> 16;
-
-       switch (fbi->fb.fix.visual) {
-       case FB_VISUAL_TRUECOLOR:
-               /*
-                * 16-bit True Colour.  We encode the RGB value
-                * according to the RGB bitfield information.
-                */
-               if (regno < 16) {
-                       u32 *pal = fbi->fb.pseudo_palette;
-
-                       val  = chan_to_field(red, &fbi->fb.var.red);
-                       val |= chan_to_field(green, &fbi->fb.var.green);
-                       val |= chan_to_field(blue, &fbi->fb.var.blue);
-
-                       pal[regno] = val;
-                       ret = 0;
-               }
-               break;
-
-       case FB_VISUAL_STATIC_PSEUDOCOLOR:
-       case FB_VISUAL_PSEUDOCOLOR:
-               ret = pxafb_setpalettereg(regno, red, green, blue, trans, info);
-               break;
-       }
-
-       return ret;
-}
-
-/*
- *  pxafb_bpp_to_lccr3():
- *    Convert a bits per pixel value to the correct bit pattern for LCCR3
- */
-static int pxafb_bpp_to_lccr3(struct fb_var_screeninfo *var)
-{
-        int ret = 0;
-        switch (var->bits_per_pixel) {
-        case 1:  ret = LCCR3_1BPP; break;
-        case 2:  ret = LCCR3_2BPP; break;
-        case 4:  ret = LCCR3_4BPP; break;
-        case 8:  ret = LCCR3_8BPP; break;
-        case 16: ret = LCCR3_16BPP; break;
-        }
-        return ret;
-}
-
-#ifdef CONFIG_CPU_FREQ
-/*
- *  pxafb_display_dma_period()
- *    Calculate the minimum period (in picoseconds) between two DMA
- *    requests for the LCD controller.  If we hit this, it means we're
- *    doing nothing but LCD DMA.
- */
-static unsigned int pxafb_display_dma_period(struct fb_var_screeninfo *var)
-{
-       /*
-        * Period = pixclock * bits_per_byte * bytes_per_transfer
-        *              / memory_bits_per_pixel;
-        */
-       return var->pixclock * 8 * 16 / var->bits_per_pixel;
-}
-
-extern unsigned int get_clk_frequency_khz(int info);
-#endif
-
-/*
- *  pxafb_check_var():
- *    Get the video params out of 'var'. If a value doesn't fit, round it up,
- *    if it's too big, return -EINVAL.
- *
- *    Round up in the following order: bits_per_pixel, xres,
- *    yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale,
- *    bitfields, horizontal timing, vertical timing.
- */
-static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
-{
-       struct pxafb_info *fbi = (struct pxafb_info *)info;
-
-       if (var->xres < MIN_XRES)
-               var->xres = MIN_XRES;
-       if (var->yres < MIN_YRES)
-               var->yres = MIN_YRES;
-       if (var->xres > fbi->max_xres)
-               var->xres = fbi->max_xres;
-       if (var->yres > fbi->max_yres)
-               var->yres = fbi->max_yres;
-       var->xres_virtual =
-               max(var->xres_virtual, var->xres);
-       var->yres_virtual =
-               max(var->yres_virtual, var->yres);
-
-        /*
-        * Setup the RGB parameters for this display.
-        *
-        * The pixel packing format is described on page 7-11 of the
-        * PXA2XX Developer's Manual.
-         */
-       if (var->bits_per_pixel == 16) {
-               var->red.offset   = 11; var->red.length   = 5;
-               var->green.offset = 5;  var->green.length = 6;
-               var->blue.offset  = 0;  var->blue.length  = 5;
-               var->transp.offset = var->transp.length = 0;
-       } else {
-               var->red.offset = var->green.offset = var->blue.offset = var->transp.offset = 0;
-               var->red.length   = 8;
-               var->green.length = 8;
-               var->blue.length  = 8;
-               var->transp.length = 0;
-       }
-
-#ifdef CONFIG_CPU_FREQ
-       DPRINTK("dma period = %d ps, clock = %d kHz\n",
-               pxafb_display_dma_period(var),
-               get_clk_frequency_khz(0));
-#endif
-
-       return 0;
-}
-
-static inline void pxafb_set_truecolor(u_int is_true_color)
-{
-       DPRINTK("true_color = %d\n", is_true_color);
-       // do your machine-specific setup if needed
-}
-
-/*
- * pxafb_set_par():
- *     Set the user defined part of the display for the specified console
- */
-static int pxafb_set_par(struct fb_info *info)
-{
-       struct pxafb_info *fbi = (struct pxafb_info *)info;
-       struct fb_var_screeninfo *var = &info->var;
-       unsigned long palette_mem_size;
-
-       DPRINTK("set_par\n");
-
-       if (var->bits_per_pixel == 16)
-               fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR;
-       else if (!fbi->cmap_static)
-               fbi->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
-       else {
-               /*
-                * Some people have weird ideas about wanting static
-                * pseudocolor maps.  I suspect their user space
-                * applications are broken.
-                */
-               fbi->fb.fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
-       }
-
-       fbi->fb.fix.line_length = var->xres_virtual *
-                                 var->bits_per_pixel / 8;
-       if (var->bits_per_pixel == 16)
-               fbi->palette_size = 0;
-       else
-               fbi->palette_size = var->bits_per_pixel == 1 ? 4 : 1 << var->bits_per_pixel;
-
-       palette_mem_size = fbi->palette_size * sizeof(u16);
-
-       DPRINTK("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
-
-       fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size);
-       fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;
-
-       /*
-        * Set (any) board control register to handle new color depth
-        */
-       pxafb_set_truecolor(fbi->fb.fix.visual == FB_VISUAL_TRUECOLOR);
-
-       if (fbi->fb.var.bits_per_pixel == 16)
-               fb_dealloc_cmap(&fbi->fb.cmap);
-       else
-               fb_alloc_cmap(&fbi->fb.cmap, 1<<fbi->fb.var.bits_per_pixel, 0);
-
-       pxafb_activate_var(var, fbi);
-
-       return 0;
-}
-
-/*
- * Formal definition of the VESA spec:
- *  On
- *     This refers to the state of the display when it is in full operation
- *  Stand-By
- *     This defines an optional operating state of minimal power reduction with
- *     the shortest recovery time
- *  Suspend
- *     This refers to a level of power management in which substantial power
- *     reduction is achieved by the display.  The display can have a longer
- *     recovery time from this state than from the Stand-by state
- *  Off
- *     This indicates that the display is consuming the lowest level of power
- *     and is non-operational. Recovery from this state may optionally require
- *     the user to manually power on the monitor
- *
- *  Now, the fbdev driver adds an additional state, (blank), where they
- *  turn off the video (maybe by colormap tricks), but don't mess with the
- *  video itself: think of it semantically between on and Stand-By.
- *
- *  So here's what we should do in our fbdev blank routine:
- *
- *     VESA_NO_BLANKING (mode 0)       Video on,  front/back light on
- *     VESA_VSYNC_SUSPEND (mode 1)     Video on,  front/back light off
- *     VESA_HSYNC_SUSPEND (mode 2)     Video on,  front/back light off
- *     VESA_POWERDOWN (mode 3)         Video off, front/back light off
- *
- *  This will match the matrox implementation.
- */
-
-/*
- * pxafb_blank():
- *     Blank the display by setting all palette values to zero.  Note, the
- *     16 bpp mode does not really use the palette, so this will not
- *      blank the display in all modes.
- */
-static int pxafb_blank(int blank, struct fb_info *info)
-{
-       struct pxafb_info *fbi = (struct pxafb_info *)info;
-       int i;
-
-       DPRINTK("pxafb_blank: blank=%d\n", blank);
-
-       switch (blank) {
-       case VESA_POWERDOWN:
-       case VESA_VSYNC_SUSPEND:
-       case VESA_HSYNC_SUSPEND:
-               if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR ||
-                   fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
-                       for (i = 0; i < fbi->palette_size; i++)
-                               pxafb_setpalettereg(i, 0, 0, 0, 0, info);
-
-               pxafb_schedule_work(fbi, C_DISABLE);
-               //TODO if (pxafb_blank_helper) pxafb_blank_helper(blank);
-               break;
-
-       case VESA_NO_BLANKING:
-               //TODO if (pxafb_blank_helper) pxafb_blank_helper(blank);
-               if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR ||
-                   fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
-                       fb_set_cmap(&fbi->fb.cmap, info);
-               pxafb_schedule_work(fbi, C_ENABLE);
-       }
-       return 0;
-}
-
-static struct fb_ops pxafb_ops = {
-       .owner          = THIS_MODULE,
-       .fb_check_var   = pxafb_check_var,
-       .fb_set_par     = pxafb_set_par,
-       .fb_setcolreg   = pxafb_setcolreg,
-       .fb_fillrect    = cfb_fillrect,
-       .fb_copyarea    = cfb_copyarea,
-       .fb_imageblit   = cfb_imageblit,
-       .fb_blank       = pxafb_blank,
-       .fb_cursor      = soft_cursor,
-};
-
-/*
- * Calculate the PCD value from the clock rate (in picoseconds).
- * We take account of the PPCR clock setting.
- * From PXA Developer's Manual:
- *
- *   PixelClock =      LCLK
- *                -------------
- *                2 ( PCD + 1 )
- *
- *   PCD =      LCLK
- *         ------------- - 1
- *         2(PixelClock)
- *
- * Where:
- *   LCLK = LCD/Memory Clock
- *   PCD = LCCR3[7:0]
- *
- * PixelClock here is in Hz while the pixclock argument given is the
- * period in picoseconds. Hence PixelClock = 1 / ( pixclock * 10^-12 )
- *
- * The function get_lclk_frequency_10khz returns LCLK in units of
- * 10khz. Calling the result of this function lclk gives us the
- * following
- *
- *    PCD = (lclk * 10^4 ) * ( pixclock * 10^-12 )
- *          -------------------------------------- - 1
- *                          2
- *
- * Factoring the 10^4 and 10^-12 out gives 10^-8 == 1 / 100000000 as used below.
- */
-static inline unsigned int get_pcd(unsigned int pixclock)
-{
-       unsigned long long pcd;
-
-       /* FIXME: Need to take into account Double Pixel Clock mode
-         * (DPC) bit? or perhaps set it based on the various clock
-         * speeds */
-
-       pcd = (unsigned long long)get_lcdclk_frequency_10khz() * pixclock;
-       pcd /= 100000000 * 2;
-       /* no need for this, since we should subtract 1 anyway. they cancel */
-       /* pcd += 1; */ /* make up for integer math truncations */
-       return (unsigned int)pcd;
-}
-
-/*
- * pxafb_activate_var():
- *     Configures LCD Controller based on entries in var parameter.  Settings are
- *     only written to the controller if changes were made.
- */
-static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *fbi)
-{
-       struct pxafb_lcd_reg new_regs;
-       u_long flags;
-       u_int lines_per_panel, pcd = get_pcd(var->pixclock);
-
-       DPRINTK("Configuring PXA LCD\n");
-
-       DPRINTK("var: xres=%d hslen=%d lm=%d rm=%d\n",
-               var->xres, var->hsync_len,
-               var->left_margin, var->right_margin);
-       DPRINTK("var: yres=%d vslen=%d um=%d bm=%d\n",
-               var->yres, var->vsync_len,
-               var->upper_margin, var->lower_margin);
-       DPRINTK("var: pixclock=%d pcd=%d\n", var->pixclock, pcd);
-
-#if DEBUG_VAR
-       if (var->xres < 16        || var->xres > 1024)
-               printk(KERN_ERR "%s: invalid xres %d\n",
-                       fbi->fb.fix.id, var->xres);
-       switch(var->bits_per_pixel) {
-       case 1:
-       case 2:
-       case 4:
-       case 8:
-       case 16:
-               break;
-       default:
-               printk(KERN_ERR "%s: invalid bit depth %d\n",
-                      fbi->fb.fix.id, var->bits_per_pixel);
-               break;
-       }
-       if (var->hsync_len < 1    || var->hsync_len > 64)
-               printk(KERN_ERR "%s: invalid hsync_len %d\n",
-                       fbi->fb.fix.id, var->hsync_len);
-       if (var->left_margin < 1  || var->left_margin > 255)
-               printk(KERN_ERR "%s: invalid left_margin %d\n",
-                       fbi->fb.fix.id, var->left_margin);
-       if (var->right_margin < 1 || var->right_margin > 255)
-               printk(KERN_ERR "%s: invalid right_margin %d\n",
-                       fbi->fb.fix.id, var->right_margin);
-       if (var->yres < 1         || var->yres > 1024)
-               printk(KERN_ERR "%s: invalid yres %d\n",
-                       fbi->fb.fix.id, var->yres);
-       if (var->vsync_len < 1    || var->vsync_len > 64)
-               printk(KERN_ERR "%s: invalid vsync_len %d\n",
-                       fbi->fb.fix.id, var->vsync_len);
-       if (var->upper_margin < 0 || var->upper_margin > 255)
-               printk(KERN_ERR "%s: invalid upper_margin %d\n",
-                       fbi->fb.fix.id, var->upper_margin);
-       if (var->lower_margin < 0 || var->lower_margin > 255)
-               printk(KERN_ERR "%s: invalid lower_margin %d\n",
-                       fbi->fb.fix.id, var->lower_margin);
-#endif
-
-       new_regs.lccr0 = fbi->lccr0 |
-               (LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM |
-                 LCCR0_QDM | LCCR0_BM  | LCCR0_OUM);
-
-       new_regs.lccr1 =
-               LCCR1_DisWdth(var->xres) +
-               LCCR1_HorSnchWdth(var->hsync_len) +
-               LCCR1_BegLnDel(var->left_margin) +
-               LCCR1_EndLnDel(var->right_margin);
-
-       /*
-        * If we have a dual scan LCD, we need to halve
-        * the YRES parameter.
-        */
-       lines_per_panel = var->yres;
-       if ((fbi->lccr0 & LCCR0_SDS) == LCCR0_Dual)
-               lines_per_panel /= 2;
-
-       new_regs.lccr2 =
-               LCCR2_DisHght(lines_per_panel) +
-               LCCR2_VrtSnchWdth(var->vsync_len) +
-               LCCR2_BegFrmDel(var->upper_margin) +
-               LCCR2_EndFrmDel(var->lower_margin);
-
-       new_regs.lccr3 = fbi->lccr3 |
-               pxafb_bpp_to_lccr3(var) |
-               (var->sync & FB_SYNC_HOR_HIGH_ACT ? LCCR3_HorSnchH : LCCR3_HorSnchL) |
-               (var->sync & FB_SYNC_VERT_HIGH_ACT ? LCCR3_VrtSnchH : LCCR3_VrtSnchL);
-
-       if (pcd)
-               new_regs.lccr3 |= LCCR3_PixClkDiv(pcd);
-
-       DPRINTK("nlccr0 = 0x%08x\n", new_regs.lccr0);
-       DPRINTK("nlccr1 = 0x%08x\n", new_regs.lccr1);
-       DPRINTK("nlccr2 = 0x%08x\n", new_regs.lccr2);
-       DPRINTK("nlccr3 = 0x%08x\n", new_regs.lccr3);
-
-       /* Update shadow copy atomically */
-       local_irq_save(flags);
-
-       /* setup dma descriptors */
-       fbi->dmadesc_fblow_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 3*16);
-       fbi->dmadesc_fbhigh_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 2*16);
-       fbi->dmadesc_palette_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 1*16);
-
-       fbi->dmadesc_fblow_dma = fbi->palette_dma - 3*16;
-       fbi->dmadesc_fbhigh_dma = fbi->palette_dma - 2*16;
-       fbi->dmadesc_palette_dma = fbi->palette_dma - 1*16;
-
-#define BYTES_PER_PANEL (lines_per_panel * fbi->fb.fix.line_length)
-
-       /* populate descriptors */
-       fbi->dmadesc_fblow_cpu->fdadr = fbi->dmadesc_fblow_dma;
-       fbi->dmadesc_fblow_cpu->fsadr = fbi->screen_dma + BYTES_PER_PANEL;
-       fbi->dmadesc_fblow_cpu->fidr  = 0;
-       fbi->dmadesc_fblow_cpu->ldcmd = BYTES_PER_PANEL;
-
-       fbi->fdadr1 = fbi->dmadesc_fblow_dma; /* only used in dual-panel mode */
-
-       fbi->dmadesc_fbhigh_cpu->fsadr = fbi->screen_dma;
-       fbi->dmadesc_fbhigh_cpu->fidr = 0;
-       fbi->dmadesc_fbhigh_cpu->ldcmd = BYTES_PER_PANEL;
-
-       fbi->dmadesc_palette_cpu->fsadr = fbi->palette_dma;
-       fbi->dmadesc_palette_cpu->fidr  = 0;
-       fbi->dmadesc_palette_cpu->ldcmd = (fbi->palette_size * 2) | LDCMD_PAL;
-
-       if (var->bits_per_pixel == 16) {
-               /* palette shouldn't be loaded in true-color mode */
-               fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_fbhigh_dma;
-               fbi->fdadr0 = fbi->dmadesc_fbhigh_dma; /* no pal just fbhigh */
-               /* init it to something, even though we won't be using it */
-               fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_palette_dma;
-       } else {
-               fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_fbhigh_dma;
-               fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_palette_dma;
-               fbi->fdadr0 = fbi->dmadesc_palette_dma; /* flips back and forth between pal and fbhigh */
-       }
-
-#if 0
-       DPRINTK("fbi->dmadesc_fblow_cpu = 0x%p\n", fbi->dmadesc_fblow_cpu);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu = 0x%p\n", fbi->dmadesc_fbhigh_cpu);
-       DPRINTK("fbi->dmadesc_palette_cpu = 0x%p\n", fbi->dmadesc_palette_cpu);
-       DPRINTK("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma);
-       DPRINTK("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma);
-       DPRINTK("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma);
-
-       DPRINTK("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr);
-       DPRINTK("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr);
-
-       DPRINTK("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr);
-       DPRINTK("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr);
-
-       DPRINTK("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd);
-       DPRINTK("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd);
-#endif
-
-       fbi->reg_lccr0 = new_regs.lccr0;
-       fbi->reg_lccr1 = new_regs.lccr1;
-       fbi->reg_lccr2 = new_regs.lccr2;
-       fbi->reg_lccr3 = new_regs.lccr3;
-       local_irq_restore(flags);
-
-       /*
-        * Only update the registers if the controller is enabled
-        * and something has changed.
-        */
-       if ((LCCR0  != fbi->reg_lccr0) || (LCCR1  != fbi->reg_lccr1) ||
-           (LCCR2  != fbi->reg_lccr2) || (LCCR3  != fbi->reg_lccr3) ||
-           (FDADR0 != fbi->fdadr0)    || (FDADR1 != fbi->fdadr1))
-               pxafb_schedule_work(fbi, C_REENABLE);
-
-       return 0;
-}
-
-/*
- * NOTE!  The following functions are purely helpers for set_ctrlr_state.
- * Do not call them directly; set_ctrlr_state does the correct serialisation
- * to ensure that things happen in the right way 100% of time time.
- *     -- rmk
- */
-static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on)
-{
-       DPRINTK("backlight o%s\n", on ? "n" : "ff");
-
-       if (pxafb_backlight_power)
-               pxafb_backlight_power(on);
-}
-
-static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
-{
-       DPRINTK("LCD power o%s\n", on ? "n" : "ff");
-
-       if (pxafb_lcd_power)
-               pxafb_lcd_power(on);
-}
-
-static void pxafb_setup_gpio(struct pxafb_info *fbi)
-{
-        unsigned int lccr0 = fbi->lccr0;
-
-       /*
-        * setup is based on type of panel supported
-        */
-
-       /* 4 bit interface */
-       if ((lccr0 & LCCR0_CMS) == LCCR0_Mono &&
-           (lccr0 & LCCR0_SDS) == LCCR0_Sngl &&
-           (lccr0 & LCCR0_DPD) == LCCR0_4PixMono)
-       {
-               // bits 58-61
-               GPDR1 |= (0xf << 26);
-               GAFR1_U = (GAFR1_U & ~(0xff << 20)) | (0xaa << 20);
-
-               // bits 74-77
-               GPDR2 |= (0xf << 10);
-               GAFR2_L = (GAFR2_L & ~(0xff << 20)) | (0xaa << 20);
-       }
-
-       /* 8 bit interface */
-        else if (((lccr0 & LCCR0_CMS) == LCCR0_Mono &&
-                 ((lccr0 & LCCR0_SDS) == LCCR0_Dual || (lccr0 & LCCR0_DPD) == LCCR0_8PixMono)) ||
-                 ((lccr0 & LCCR0_CMS) == LCCR0_Color &&
-                 (lccr0 & LCCR0_PAS) == LCCR0_Pas && (lccr0 & LCCR0_SDS) == LCCR0_Sngl))
-       {
-               // bits 58-65
-               GPDR1 |= (0x3f << 26);
-               GPDR2 |= (0x3);
-
-               GAFR1_U = (GAFR1_U & ~(0xfff << 20)) | (0xaaa << 20);
-               GAFR2_L = (GAFR2_L & ~0xf) | (0xa);
-
-               // bits 74-77
-               GPDR2 |= (0xf << 10);
-               GAFR2_L = (GAFR2_L & ~(0xff << 20)) | (0xaa << 20);
-       }
-
-       /* 16 bit interface */
-       else if ((lccr0 & LCCR0_CMS) == LCCR0_Color &&
-                ((lccr0 & LCCR0_SDS) == LCCR0_Dual || (lccr0 & LCCR0_PAS) == LCCR0_Act))
-       {
-               // bits 58-77
-               GPDR1 |= (0x3f << 26);
-               GPDR2 |= 0x00003fff;
-
-               GAFR1_U = (GAFR1_U & ~(0xfff << 20)) | (0xaaa << 20);
-               GAFR2_L = (GAFR2_L & 0xf0000000) | 0x0aaaaaaa;
-       }
-
-       else {
-               printk(KERN_ERR "pxafb_setup_gpio: unable to determine bits per pixel\n");
-        }
-}
-
-static void pxafb_enable_controller(struct pxafb_info *fbi)
-{
-       DPRINTK("Enabling LCD controller\n");
-       DPRINTK("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr0);
-       DPRINTK("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr1);
-       DPRINTK("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0);
-       DPRINTK("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1);
-       DPRINTK("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2);
-       DPRINTK("reg_lccr3 0x%08x\n", (unsigned int) fbi->reg_lccr3);
-
-       /* Sequence from 11.7.10 */
-       LCCR3 = fbi->reg_lccr3;
-       LCCR2 = fbi->reg_lccr2;
-       LCCR1 = fbi->reg_lccr1;
-       LCCR0 = fbi->reg_lccr0 & ~LCCR0_ENB;
-
-       FDADR0 = fbi->fdadr0;
-       FDADR1 = fbi->fdadr1;
-       LCCR0 |= LCCR0_ENB;
-
-       DPRINTK("FDADR0 0x%08x\n", (unsigned int) FDADR0);
-       DPRINTK("FDADR1 0x%08x\n", (unsigned int) FDADR1);
-       DPRINTK("LCCR0 0x%08x\n", (unsigned int) LCCR0);
-       DPRINTK("LCCR1 0x%08x\n", (unsigned int) LCCR1);
-       DPRINTK("LCCR2 0x%08x\n", (unsigned int) LCCR2);
-       DPRINTK("LCCR3 0x%08x\n", (unsigned int) LCCR3);
-}
-
-static void pxafb_disable_controller(struct pxafb_info *fbi)
-{
-       DECLARE_WAITQUEUE(wait, current);
-
-       DPRINTK("Disabling LCD controller\n");
-
-       add_wait_queue(&fbi->ctrlr_wait, &wait);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-
-       LCSR = 0xffffffff;      /* Clear LCD Status Register */
-       LCCR0 &= ~LCCR0_LDM;    /* Enable LCD Disable Done Interrupt */
-       LCCR0 |= LCCR0_DIS;     /* Disable LCD Controller */
-
-       schedule_timeout(20 * HZ / 1000);
-       remove_wait_queue(&fbi->ctrlr_wait, &wait);
-}
-
-/*
- *  pxafb_handle_irq: Handle 'LCD DONE' interrupts.
- */
-static irqreturn_t pxafb_handle_irq(int irq, void *dev_id, struct pt_regs *regs)
-{
-       struct pxafb_info *fbi = dev_id;
-       unsigned int lcsr = LCSR;
-
-       if (lcsr & LCSR_LDD) {
-               LCCR0 |= LCCR0_LDM;
-               wake_up(&fbi->ctrlr_wait);
-       }
-
-       LCSR = lcsr;
-       return IRQ_HANDLED;
-}
-
-/*
- * This function must be called from task context only, since it will
- * sleep when disabling the LCD controller, or if we get two contending
- * processes trying to alter state.
- */
-static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
-{
-       u_int old_state;
-
-       down(&fbi->ctrlr_sem);
-
-       old_state = fbi->state;
-
-       /*
-        * Hack around fbcon initialisation.
-        */
-       if (old_state == C_STARTUP && state == C_REENABLE)
-               state = C_ENABLE;
-
-       switch (state) {
-       case C_DISABLE_CLKCHANGE:
-               /*
-                * Disable controller for clock change.  If the
-                * controller is already disabled, then do nothing.
-                */
-               if (old_state != C_DISABLE && old_state != C_DISABLE_PM) {
-                       fbi->state = state;
-                       //TODO __pxafb_lcd_power(fbi, 0);
-                       pxafb_disable_controller(fbi);
-               }
-               break;
-
-       case C_DISABLE_PM:
-       case C_DISABLE:
-               /*
-                * Disable controller
-                */
-               if (old_state != C_DISABLE) {
-                       fbi->state = state;
-                       __pxafb_backlight_power(fbi, 0);
-                       __pxafb_lcd_power(fbi, 0);
-                       if (old_state != C_DISABLE_CLKCHANGE)
-                               pxafb_disable_controller(fbi);
-               }
-               break;
-
-       case C_ENABLE_CLKCHANGE:
-               /*
-                * Enable the controller after clock change.  Only
-                * do this if we were disabled for the clock change.
-                */
-               if (old_state == C_DISABLE_CLKCHANGE) {
-                       fbi->state = C_ENABLE;
-                       pxafb_enable_controller(fbi);
-                       //TODO __pxafb_lcd_power(fbi, 1);
-               }
-               break;
-
-       case C_REENABLE:
-               /*
-                * Re-enable the controller only if it was already
-                * enabled.  This is so we reprogram the control
-                * registers.
-                */
-               if (old_state == C_ENABLE) {
-                       pxafb_disable_controller(fbi);
-                       pxafb_setup_gpio(fbi);
-                       pxafb_enable_controller(fbi);
-               }
-               break;
-
-       case C_ENABLE_PM:
-               /*
-                * Re-enable the controller after PM.  This is not
-                * perfect - think about the case where we were doing
-                * a clock change, and we suspended half-way through.
-                */
-               if (old_state != C_DISABLE_PM)
-                       break;
-               /* fall through */
-
-       case C_ENABLE:
-               /*
-                * Power up the LCD screen, enable controller, and
-                * turn on the backlight.
-                */
-               if (old_state != C_ENABLE) {
-                       fbi->state = C_ENABLE;
-                       pxafb_setup_gpio(fbi);
-                       pxafb_enable_controller(fbi);
-                       __pxafb_lcd_power(fbi, 1);
-                       __pxafb_backlight_power(fbi, 1);
-               }
-               break;
-       }
-       up(&fbi->ctrlr_sem);
-}
-
-/*
- * Our LCD controller task (which is called when we blank or unblank)
- * via keventd.
- */
-static void pxafb_task(void *dummy)
-{
-       struct pxafb_info *fbi = dummy;
-       u_int state = xchg(&fbi->task_state, -1);
-
-       set_ctrlr_state(fbi, state);
-}
-
-#ifdef CONFIG_CPU_FREQ
-/*
- * CPU clock speed change handler.  We need to adjust the LCD timing
- * parameters when the CPU clock is adjusted by the power management
- * subsystem.
- *
- * TODO: Determine why f->new != 10*get_lclk_frequency_10khz()
- */
-static int
-pxafb_freq_transition(struct notifier_block *nb, unsigned long val, void *data)
-{
-       struct pxafb_info *fbi = TO_INF(nb, freq_transition);
-       //TODO struct cpufreq_freqs *f = data;
-       u_int pcd;
-
-       switch (val) {
-       case CPUFREQ_PRECHANGE:
-               set_ctrlr_state(fbi, C_DISABLE_CLKCHANGE);
-               break;
-
-       case CPUFREQ_POSTCHANGE:
-               pcd = get_pcd(fbi->fb.var.pixclock);
-               fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd);
-               set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE);
-               break;
-       }
-       return 0;
-}
-
-static int
-pxafb_freq_policy(struct notifier_block *nb, unsigned long val, void *data)
-{
-       struct pxafb_info *fbi = TO_INF(nb, freq_policy);
-       struct fb_var_screeninfo *var = &fbi->fb.var;
-       struct cpufreq_policy *policy = data;
-
-       switch (val) {
-       case CPUFREQ_ADJUST:
-       case CPUFREQ_INCOMPATIBLE:
-               printk(KERN_DEBUG "min dma period: %d ps, "
-                       "new clock %d kHz\n", pxafb_display_dma_period(var),
-                       policy->max);
-               // TODO: fill in min/max values
-               break;
-#if 0
-       case CPUFREQ_NOTIFY:
-               printk(KERN_ERR "%s: got CPUFREQ_NOTIFY\n", __FUNCTION__);
-               do {} while(0);
-               /* todo: panic if min/max values aren't fulfilled
-                * [can't really happen unless there's a bug in the
-                * CPU policy verification process *
-                */
-               break;
-#endif
-       }
-       return 0;
-}
-#endif
-
-#ifdef CONFIG_PM
-/*
- * Power management hooks.  Note that we won't be called from IRQ context,
- * unlike the blank functions above, so we may sleep.
- */
-static int pxafb_suspend(struct device *dev, u32 state, u32 level)
-{
-       struct pxafb_info *fbi = dev_get_drvdata(dev);
-
-       if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN)
-               set_ctrlr_state(fbi, C_DISABLE_PM);
-       return 0;
-}
-
-static int pxafb_resume(struct device *dev, u32 level)
-{
-       struct pxafb_info *fbi = dev_get_drvdata(dev);
-
-       if (level == RESUME_ENABLE)
-               set_ctrlr_state(fbi, C_ENABLE_PM);
-       return 0;
-}
-#else
-#define pxafb_suspend  NULL
-#define pxafb_resume   NULL
-#endif
-
-/*
- * pxafb_map_video_memory():
- *      Allocates the DRAM memory for the frame buffer.  This buffer is
- *     remapped into a non-cached, non-buffered, memory region to
- *      allow palette and pixel writes to occur without flushing the
- *      cache.  Once this area is remapped, all virtual memory
- *      access to the video memory should occur at the new region.
- */
-static int __init pxafb_map_video_memory(struct pxafb_info *fbi)
-{
-       u_long palette_mem_size;
-
-       /*
-        * We reserve one page for the palette, plus the size
-        * of the framebuffer.
-        */
-       fbi->map_size = PAGE_ALIGN(fbi->fb.fix.smem_len + PAGE_SIZE);
-       fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
-                                             &fbi->map_dma, GFP_KERNEL);
-
-       if (fbi->map_cpu) {
-               /* prevent initial garbage on screen */
-               memset(fbi->map_cpu, 0, fbi->map_size);
-               fbi->fb.screen_base = fbi->map_cpu + PAGE_SIZE;
-               fbi->screen_dma = fbi->map_dma + PAGE_SIZE;
-               /*
-                * FIXME: this is actually the wrong thing to place in
-                * smem_start.  But fbdev suffers from the problem that
-                * it needs an API which doesn't exist (in this case,
-                * dma_writecombine_mmap)
-                */
-               fbi->fb.fix.smem_start = fbi->screen_dma;
-
-               fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16;
-
-               palette_mem_size = fbi->palette_size * sizeof(u16);
-               DPRINTK("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
-
-               fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size);
-               fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;
-       }
-
-       return fbi->map_cpu ? 0 : -ENOMEM;
-}
-
-static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
-{
-       struct pxafb_info *fbi;
-       void *addr;
-       struct pxafb_mach_info *inf = dev->platform_data;
-
-       /* Alloc the pxafb_info and pseudo_palette in one step */
-       fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL);
-       if (!fbi)
-               return NULL;
-
-       memset(fbi, 0, sizeof(struct pxafb_info));
-       fbi->dev = dev;
-
-       strcpy(fbi->fb.fix.id, PXA_NAME);
-
-       fbi->fb.fix.type        = FB_TYPE_PACKED_PIXELS;
-       fbi->fb.fix.type_aux    = 0;
-       fbi->fb.fix.xpanstep    = 0;
-       fbi->fb.fix.ypanstep    = 0;
-       fbi->fb.fix.ywrapstep   = 0;
-       fbi->fb.fix.accel       = FB_ACCEL_NONE;
-
-       fbi->fb.var.nonstd      = 0;
-       fbi->fb.var.activate    = FB_ACTIVATE_NOW;
-       fbi->fb.var.height      = -1;
-       fbi->fb.var.width       = -1;
-       fbi->fb.var.accel_flags = 0;
-       fbi->fb.var.vmode       = FB_VMODE_NONINTERLACED;
-
-       fbi->fb.fbops           = &pxafb_ops;
-       fbi->fb.flags           = FBINFO_FLAG_DEFAULT;
-       fbi->fb.node            = -1;
-       fbi->fb.currcon         = -1;
-
-       addr = fbi;
-       addr = addr + sizeof(struct pxafb_info);
-       fbi->fb.pseudo_palette  = addr;
-
-       fbi->max_xres                   = inf->xres;
-       fbi->fb.var.xres                = inf->xres;
-       fbi->fb.var.xres_virtual        = inf->xres;
-       fbi->max_yres                   = inf->yres;
-       fbi->fb.var.yres                = inf->yres;
-       fbi->fb.var.yres_virtual        = inf->yres;
-       fbi->max_bpp                    = inf->bpp;
-       fbi->fb.var.bits_per_pixel      = inf->bpp;
-       fbi->fb.var.pixclock            = inf->pixclock;
-       fbi->fb.var.hsync_len           = inf->hsync_len;
-       fbi->fb.var.left_margin         = inf->left_margin;
-       fbi->fb.var.right_margin        = inf->right_margin;
-       fbi->fb.var.vsync_len           = inf->vsync_len;
-       fbi->fb.var.upper_margin        = inf->upper_margin;
-       fbi->fb.var.lower_margin        = inf->lower_margin;
-       fbi->fb.var.sync                = inf->sync;
-       fbi->fb.var.grayscale           = inf->cmap_greyscale;
-       fbi->cmap_inverse               = inf->cmap_inverse;
-       fbi->cmap_static                = inf->cmap_static;
-       fbi->lccr0                      = inf->lccr0;
-       fbi->lccr3                      = inf->lccr3;
-       fbi->state                      = C_STARTUP;
-       fbi->task_state                 = (u_char)-1;
-       fbi->fb.fix.smem_len            = fbi->max_xres * fbi->max_yres *
-                                         fbi->max_bpp / 8;
-
-       init_waitqueue_head(&fbi->ctrlr_wait);
-       INIT_WORK(&fbi->task, pxafb_task, fbi);
-       init_MUTEX(&fbi->ctrlr_sem);
-
-       return fbi;
-}
-
-#ifdef CONFIG_FB_PXA_PARAMETERS
-static int __init pxafb_parse_options(struct device *dev, char *options)
-{
-       struct pxafb_mach_info *inf = dev->platform_data;
-       char *this_opt;
-
-        if (!options || !*options)
-                return 0;
-
-       dev_dbg(dev, "options are \"%s\"\n", options ? options : "null");
-
-       /* could be made table driven or similar?... */
-        while ((this_opt = strsep(&options, ",")) != NULL) {
-                if (!strncmp(this_opt, "mode:", 5)) {
-                       const char *name = this_opt+5;
-                       unsigned int namelen = strlen(name);
-                       int res_specified = 0, bpp_specified = 0;
-                       unsigned int xres = 0, yres = 0, bpp = 0;
-                       int yres_specified = 0;
-                       int i;
-                       for (i = namelen-1; i >= 0; i--) {
-                               switch (name[i]) {
-                               case '-':
-                                       namelen = i;
-                                       if (!bpp_specified && !yres_specified) {
-                                               bpp = simple_strtoul(&name[i+1], NULL, 0);
-                                               bpp_specified = 1;
-                                       } else
-                                               goto done;
-                                       break;
-                               case 'x':
-                                       if (!yres_specified) {
-                                               yres = simple_strtoul(&name[i+1], NULL, 0);
-                                               yres_specified = 1;
-                                       } else
-                                               goto done;
-                                       break;
-                               case '0'...'9':
-                                       break;
-                               default:
-                                       goto done;
-                               }
-                       }
-                       if (i < 0 && yres_specified) {
-                               xres = simple_strtoul(name, NULL, 0);
-                               res_specified = 1;
-                       }
-               done:
-                       if (res_specified) {
-                               dev_info(dev, "overriding resolution: %dx%d\n", xres, yres);
-                               inf->xres = xres; inf->yres = yres;
-                       }
-                       if (bpp_specified)
-                               switch (bpp) {
-                               case 1:
-                               case 2:
-                               case 4:
-                               case 8:
-                               case 16:
-                                       inf->bpp = bpp;
-                                       dev_info(dev, "overriding bit depth: %d\n", bpp);
-                                       break;
-                               default:
-                                       dev_err(dev, "Depth %d is not valid\n", bpp);
-                               }
-                } else if (!strncmp(this_opt, "pixclock:", 9)) {
-                        inf->pixclock = simple_strtoul(this_opt+9, NULL, 0);
-                       dev_info(dev, "override pixclock: %ld\n", inf->pixclock);
-                } else if (!strncmp(this_opt, "left:", 5)) {
-                        inf->left_margin = simple_strtoul(this_opt+5, NULL, 0);
-                       dev_info(dev, "override left: %u\n", inf->left_margin);
-                } else if (!strncmp(this_opt, "right:", 6)) {
-                        inf->right_margin = simple_strtoul(this_opt+6, NULL, 0);
-                       dev_info(dev, "override right: %u\n", inf->right_margin);
-                } else if (!strncmp(this_opt, "upper:", 6)) {
-                        inf->upper_margin = simple_strtoul(this_opt+6, NULL, 0);
-                       dev_info(dev, "override upper: %u\n", inf->upper_margin);
-                } else if (!strncmp(this_opt, "lower:", 6)) {
-                        inf->lower_margin = simple_strtoul(this_opt+6, NULL, 0);
-                       dev_info(dev, "override lower: %u\n", inf->lower_margin);
-                } else if (!strncmp(this_opt, "hsynclen:", 9)) {
-                        inf->hsync_len = simple_strtoul(this_opt+9, NULL, 0);
-                       dev_info(dev, "override hsynclen: %u\n", inf->hsync_len);
-                } else if (!strncmp(this_opt, "vsynclen:", 9)) {
-                        inf->vsync_len = simple_strtoul(this_opt+9, NULL, 0);
-                       dev_info(dev, "override vsynclen: %u\n", inf->vsync_len);
-                } else if (!strncmp(this_opt, "hsync:", 6)) {
-                        if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
-                               dev_info(dev, "override hsync: Active Low\n");
-                               inf->sync &= ~FB_SYNC_HOR_HIGH_ACT;
-                       } else {
-                               dev_info(dev, "override hsync: Active High\n");
-                               inf->sync |= FB_SYNC_HOR_HIGH_ACT;
-                       }
-                } else if (!strncmp(this_opt, "vsync:", 6)) {
-                        if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
-                               dev_info(dev, "override vsync: Active Low\n");
-                               inf->sync &= ~FB_SYNC_VERT_HIGH_ACT;
-                       } else {
-                               dev_info(dev, "override vsync: Active High\n");
-                               inf->sync |= FB_SYNC_VERT_HIGH_ACT;
-                       }
-                } else if (!strncmp(this_opt, "dpc:", 4)) {
-                        if (simple_strtoul(this_opt+4, NULL, 0) == 0) {
-                               dev_info(dev, "override double pixel clock: false\n");
-                               inf->lccr3 &= ~LCCR3_DPC;
-                       } else {
-                               dev_info(dev, "override double pixel clock: true\n");
-                               inf->lccr3 |= LCCR3_DPC;
-                       }
-                } else if (!strncmp(this_opt, "outputen:", 9)) {
-                        if (simple_strtoul(this_opt+9, NULL, 0) == 0) {
-                               dev_info(dev, "override output enable: active low\n");
-                               inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnL;
-                       } else {
-                               dev_info(dev, "override output enable: active high\n");
-                               inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnH;
-                       }
-                } else if (!strncmp(this_opt, "pixclockpol:", 12)) {
-                        if (simple_strtoul(this_opt+12, NULL, 0) == 0) {
-                               dev_info(dev, "override pixel clock polarity: falling edge\n");
-                               inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixFlEdg;
-                       } else {
-                               dev_info(dev, "override pixel clock polarity: rising edge\n");
-                               inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixRsEdg;
-                       }
-                } else if (!strncmp(this_opt, "color", 5)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_CMS) | LCCR0_Color;
-                } else if (!strncmp(this_opt, "mono", 4)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_CMS) | LCCR0_Mono;
-                } else if (!strncmp(this_opt, "active", 6)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_PAS) | LCCR0_Act;
-                } else if (!strncmp(this_opt, "passive", 7)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_PAS) | LCCR0_Pas;
-                } else if (!strncmp(this_opt, "single", 6)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_SDS) | LCCR0_Sngl;
-                } else if (!strncmp(this_opt, "dual", 4)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_SDS) | LCCR0_Dual;
-                } else if (!strncmp(this_opt, "4pix", 4)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_DPD) | LCCR0_4PixMono;
-                } else if (!strncmp(this_opt, "8pix", 4)) {
-                       inf->lccr0 = (inf->lccr0 & ~LCCR0_DPD) | LCCR0_8PixMono;
-               } else {
-                       dev_err(dev, "unknown option: %s\n", this_opt);
-                       return -EINVAL;
-               }
-        }
-        return 0;
-
-}
-#endif
-
-int __init pxafb_probe(struct device *dev)
-{
-       struct pxafb_info *fbi;
-       struct pxafb_mach_info *inf;
-       int ret;
-
-       dev_dbg(dev, "pxafb_probe\n");
-
-       inf = dev->platform_data;
-       ret = -ENOMEM;
-       fbi = NULL;
-       if (!inf)
-               goto failed;
-
-#ifdef CONFIG_FB_PXA_PARAMETERS
-       ret = pxafb_parse_options(dev, g_options);
-       if (ret < 0)
-               goto failed;
-#endif
-
-#ifdef DEBUG_VAR
-        /* Check for various illegal bit-combinations. Currently only
-        * a warning is given. */
-
-        if (inf->lccr0 & LCCR0_INVALID_CONFIG_MASK)
-                dev_warn(dev, "machine LCCR0 setting contains illegal bits: %08x\n",
-                        inf->lccr0 & LCCR0_INVALID_CONFIG_MASK);
-        if (inf->lccr3 & LCCR3_INVALID_CONFIG_MASK)
-                dev_warn(dev, "machine LCCR3 setting contains illegal bits: %08x\n",
-                        inf->lccr3 & LCCR3_INVALID_CONFIG_MASK);
-        if (inf->lccr0 & LCCR0_DPD &&
-           ((inf->lccr0 & LCCR0_PAS) != LCCR0_Pas ||
-            (inf->lccr0 & LCCR0_SDS) != LCCR0_Sngl ||
-            (inf->lccr0 & LCCR0_CMS) != LCCR0_Mono))
-                dev_warn(dev, "Double Pixel Data (DPD) mode is only valid in passive mono"
-                        " single panel mode\n");
-        if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Act &&
-           (inf->lccr0 & LCCR0_SDS) == LCCR0_Dual)
-                dev_warn(dev, "Dual panel only valid in passive mode\n");
-        if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas &&
-             (inf->upper_margin || inf->lower_margin))
-                dev_warn(dev, "Upper and lower margins must be 0 in passive mode\n");
-#endif
-
-       dev_dbg(dev, "got a %dx%dx%d LCD\n",inf->xres, inf->yres, inf->bpp);
-       if (inf->xres == 0 || inf->yres == 0 || inf->bpp == 0) {
-               dev_err(dev, "Invalid resolution or bit depth\n");
-               ret = -EINVAL;
-               goto failed;
-       }
-       pxafb_backlight_power = inf->pxafb_backlight_power;
-       pxafb_lcd_power = inf->pxafb_lcd_power;
-       fbi = pxafb_init_fbinfo(dev);
-       if (!fbi) {
-               dev_err(dev, "Failed to initialize framebuffer device\n");
-               ret = -ENOMEM; // only reason for pxafb_init_fbinfo to fail is kmalloc
-               goto failed;
-       }
-
-       /* Initialize video memory */
-       ret = pxafb_map_video_memory(fbi);
-       if (ret) {
-               dev_err(dev, "Failed to allocate video RAM: %d\n", ret);
-               ret = -ENOMEM;
-               goto failed;
-       }
-       /* enable LCD controller clock */
-       pxa_set_cken(CKEN16_LCD, 1);
-
-       ret = request_irq(IRQ_LCD, pxafb_handle_irq, SA_INTERRUPT, "LCD", fbi);
-       if (ret) {
-               dev_err(dev, "request_irq failed: %d\n", ret);
-               ret = -EBUSY;
-               goto failed;
-       }
-
-       /*
-        * This makes sure that our colour bitfield
-        * descriptors are correctly initialised.
-        */
-       pxafb_check_var(&fbi->fb.var, &fbi->fb);
-       pxafb_set_par(&fbi->fb);
-
-       dev_set_drvdata(dev, fbi);
-
-       ret = register_framebuffer(&fbi->fb);
-       if (ret < 0) {
-               dev_err(dev, "Failed to register framebuffer device: %d\n", ret);
-               goto failed;
-       }
-
-#ifdef CONFIG_PM
-       // TODO
-#endif
-
-#ifdef CONFIG_CPU_FREQ
-       fbi->freq_transition.notifier_call = pxafb_freq_transition;
-       fbi->freq_policy.notifier_call = pxafb_freq_policy;
-       cpufreq_register_notifier(&fbi->freq_transition, CPUFREQ_TRANSITION_NOTIFIER);
-       cpufreq_register_notifier(&fbi->freq_policy, CPUFREQ_POLICY_NOTIFIER);
-#endif
-
-       /*
-        * Ok, now enable the LCD controller
-        */
-       set_ctrlr_state(fbi, C_ENABLE);
-
-       return 0;
-
-failed:
-       dev_set_drvdata(dev, NULL);
-       if (fbi)
-               kfree(fbi);
-       return ret;
-}
-
-static struct device_driver pxafb_driver = {
-       .name           = "pxa2xx-fb",
-       .bus            = &platform_bus_type,
-       .probe          = pxafb_probe,
-#ifdef CONFIG_PM
-       .suspend        = pxafb_suspend,
-       .resume         = pxafb_resume,
-#endif
-};
-
-int __devinit pxafb_init(void)
-{
-       return driver_register(&pxafb_driver);
-}
-
-#ifndef MODULE
-int __devinit pxafb_setup(char *options)
-{
-# ifdef CONFIG_FB_PXA_PARAMETERS
-       strlcpy(g_options, options, sizeof(g_options));
-# endif
-       return 0;
-}
-#else
-module_init(pxafb_init);
-# ifdef CONFIG_FB_PXA_PARAMETERS
-module_param_string(options, g_options, sizeof(g_options), 0);
-MODULE_PARM_DESC(options, "LCD parameters (see Documentation/fb/pxafb.txt)");
-# endif
-#endif
-
-MODULE_DESCRIPTION("loadable framebuffer driver for PXA");
-MODULE_LICENSE("GPL");
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig
deleted file mode 100644 (file)
index bdeb028..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-menu "Dallas's 1-wire bus"
-
-config W1
-       tristate "Dallas's 1-wire support"
-       ---help---
-         Dallas's 1-wire bus is usefull to connect slow 1-pin devices 
-         such as iButtons and thermal sensors.
-         
-         If you want W1 support, you should say Y here.
-
-         This W1 support can also be built as a module.  If so, the module
-         will be called wire.ko.
-
-config W1_MATROX
-       tristate "Matrox G400 transport layer for 1-wire"
-       depends on W1 && PCI
-       help
-         Say Y here if you want to communicate with your 1-wire devices
-         using Matrox's G400 GPIO pins.
-         
-         This support is also available as a module.  If so, the module 
-         will be called matrox_w1.ko.
-
-config W1_THERM
-       tristate "Thermal family implementation"
-       depends on W1
-       help
-         Say Y here if you want to connect 1-wire thermal sensors to you
-         wire.
-
-endmenu
diff --git a/drivers/w1/matrox_w1.c b/drivers/w1/matrox_w1.c
deleted file mode 100644 (file)
index bde1778..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- *     matrox_w1.c
- *
- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
- * 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <asm/atomic.h>
-#include <asm/types.h>
-#include <asm/io.h>
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/list.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-#include <linux/pci_ids.h>
-#include <linux/pci.h>
-#include <linux/timer.h>
-
-#include "w1.h"
-#include "w1_int.h"
-#include "w1_log.h"
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
-MODULE_DESCRIPTION("Driver for transport(Dallas 1-wire prtocol) over VGA DDC(matrox gpio).");
-
-static struct pci_device_id matrox_w1_tbl[] = {
-       { PCI_DEVICE(PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G400) },
-       { },
-};
-MODULE_DEVICE_TABLE(pci, matrox_w1_tbl);
-
-static int __devinit matrox_w1_probe(struct pci_dev *, const struct pci_device_id *);
-static void __devexit matrox_w1_remove(struct pci_dev *);
-
-static struct pci_driver matrox_w1_pci_driver = {
-       .name = "matrox_w1",
-       .id_table = matrox_w1_tbl,
-       .probe = matrox_w1_probe,
-       .remove = __devexit_p(matrox_w1_remove),
-};
-
-/* 
- * Matrox G400 DDC registers.
- */
-
-#define MATROX_G400_DDC_CLK            (1<<4)
-#define MATROX_G400_DDC_DATA           (1<<1)
-
-#define MATROX_BASE                    0x3C00
-#define MATROX_STATUS                  0x1e14
-
-#define MATROX_PORT_INDEX_OFFSET       0x00
-#define MATROX_PORT_DATA_OFFSET                0x0A
-
-#define MATROX_GET_CONTROL             0x2A
-#define MATROX_GET_DATA                        0x2B
-#define MATROX_CURSOR_CTL              0x06
-
-struct matrox_device
-{
-       unsigned long base_addr;
-       unsigned long port_index, port_data;
-       u8 data_mask;
-
-       unsigned long phys_addr, virt_addr;
-       unsigned long found;
-
-       struct w1_bus_master *bus_master;
-};
-
-static u8 matrox_w1_read_ddc_bit(unsigned long);
-static void matrox_w1_write_ddc_bit(unsigned long, u8);
-
-/*
- * These functions read and write DDC Data bit.
- *
- * Using tristate pins, since i can't  fin any open-drain pin in whole motherboard.
- * Unfortunately we can't connect to Intel's 82801xx IO controller
- * since we don't know motherboard schema, wich has pretty unused(may be not) GPIO.
- *
- * I've heard that PIIX also has open drain pin.
- *
- * Port mapping.
- */
-static __inline__ u8 matrox_w1_read_reg(struct matrox_device *dev, u8 reg)
-{
-       u8 ret;
-
-       writeb(reg, dev->port_index);
-       ret = readb(dev->port_data);
-       barrier();
-
-       return ret;
-}
-
-static __inline__ void matrox_w1_write_reg(struct matrox_device *dev, u8 reg, u8 val)
-{
-       writeb(reg, dev->port_index);
-       writeb(val, dev->port_data);
-       wmb();
-}
-
-static void matrox_w1_write_ddc_bit(unsigned long data, u8 bit)
-{
-       u8 ret;
-       struct matrox_device *dev = (struct matrox_device *) data;
-
-       if (bit)
-               bit = 0;
-       else
-               bit = dev->data_mask;
-
-       ret = matrox_w1_read_reg(dev, MATROX_GET_CONTROL);
-       matrox_w1_write_reg(dev, MATROX_GET_CONTROL, ((ret & ~dev->data_mask) | bit));
-       matrox_w1_write_reg(dev, MATROX_GET_DATA, 0x00);
-}
-
-static u8 matrox_w1_read_ddc_bit(unsigned long data)
-{
-       u8 ret;
-       struct matrox_device *dev = (struct matrox_device *) data;
-
-       ret = matrox_w1_read_reg(dev, MATROX_GET_DATA);
-
-       return ret;
-}
-
-static void matrox_w1_hw_init(struct matrox_device *dev)
-{
-       matrox_w1_write_reg(dev, MATROX_GET_DATA, 0xFF);
-       matrox_w1_write_reg(dev, MATROX_GET_CONTROL, 0x00);
-}
-
-static int __devinit matrox_w1_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-       struct matrox_device *dev;
-       int err;
-
-       assert(pdev != NULL);
-       assert(ent != NULL);
-
-       if (pdev->vendor != PCI_VENDOR_ID_MATROX || pdev->device != PCI_DEVICE_ID_MATROX_G400)
-               return -ENODEV;
-
-       dev = kmalloc(sizeof(struct matrox_device) +
-                      sizeof(struct w1_bus_master), GFP_KERNEL);
-       if (!dev) {
-               dev_err(&pdev->dev,
-                       "%s: Failed to create new matrox_device object.\n",
-                       __func__);
-               return -ENOMEM;
-       }
-
-       memset(dev, 0, sizeof(struct matrox_device) + sizeof(struct w1_bus_master));
-
-       dev->bus_master = (struct w1_bus_master *)(dev + 1);
-
-       /* 
-        * True for G400, for some other we need resource 0, see drivers/video/matrox/matroxfb_base.c 
-        */
-
-       dev->phys_addr = pci_resource_start(pdev, 1);
-
-       dev->virt_addr =
-               (unsigned long) ioremap_nocache(dev->phys_addr, 16384);
-       if (!dev->virt_addr) {
-               dev_err(&pdev->dev, "%s: failed to ioremap(0x%lx, %d).\n",
-                       __func__, dev->phys_addr, 16384);
-               err = -EIO;
-               goto err_out_free_device;
-       }
-
-       dev->base_addr = dev->virt_addr + MATROX_BASE;
-       dev->port_index = dev->base_addr + MATROX_PORT_INDEX_OFFSET;
-       dev->port_data = dev->base_addr + MATROX_PORT_DATA_OFFSET;
-       dev->data_mask = (MATROX_G400_DDC_DATA);
-
-       matrox_w1_hw_init(dev);
-
-       dev->bus_master->data = (unsigned long) dev;
-       dev->bus_master->read_bit = &matrox_w1_read_ddc_bit;
-       dev->bus_master->write_bit = &matrox_w1_write_ddc_bit;
-
-       err = w1_add_master_device(dev->bus_master);
-       if (err)
-               goto err_out_free_device;
-
-       pci_set_drvdata(pdev, dev);
-
-       dev->found = 1;
-
-       dev_info(&pdev->dev, "Matrox G400 GPIO transport layer for 1-wire.\n");
-
-       return 0;
-
-err_out_free_device:
-       kfree(dev);
-
-       return err;
-}
-
-static void __devexit matrox_w1_remove(struct pci_dev *pdev)
-{
-       struct matrox_device *dev = pci_get_drvdata(pdev);
-
-       assert(dev != NULL);
-
-       if (dev->found) {
-               w1_remove_master_device(dev->bus_master);
-               iounmap((void *) dev->virt_addr);
-       }
-       kfree(dev);
-}
-
-static int __init matrox_w1_init(void)
-{
-       return pci_module_init(&matrox_w1_pci_driver);
-}
-
-static void __exit matrox_w1_fini(void)
-{
-       pci_unregister_driver(&matrox_w1_pci_driver);
-}
-
-module_init(matrox_w1_init);
-module_exit(matrox_w1_fini);
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
deleted file mode 100644 (file)
index 4f52422..0000000
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- *     w1.c
- *
- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
- * 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <asm/atomic.h>
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/list.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/timer.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/sched.h>
-#include <linux/suspend.h>
-
-#include "w1.h"
-#include "w1_io.h"
-#include "w1_log.h"
-#include "w1_int.h"
-#include "w1_family.h"
-#include "w1_netlink.h"
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
-MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
-
-static int w1_timeout = 5 * HZ;
-int w1_max_slave_count = 10;
-
-module_param_named(timeout, w1_timeout, int, 0);
-module_param_named(max_slave_count, w1_max_slave_count, int, 0);
-
-spinlock_t w1_mlock = SPIN_LOCK_UNLOCKED;
-LIST_HEAD(w1_masters);
-
-static pid_t control_thread;
-static int control_needs_exit;
-static DECLARE_COMPLETION(w1_control_complete);
-static DECLARE_WAIT_QUEUE_HEAD(w1_control_wait);
-
-static int w1_master_match(struct device *dev, struct device_driver *drv)
-{
-       return 1;
-}
-
-static int w1_master_probe(struct device *dev)
-{
-       return -ENODEV;
-}
-
-static int w1_master_remove(struct device *dev)
-{
-       return 0;
-}
-
-static void w1_master_release(struct device *dev)
-{
-       struct w1_master *md = container_of(dev, struct w1_master, dev);
-
-       complete(&md->dev_released);
-}
-
-static void w1_slave_release(struct device *dev)
-{
-       struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
-
-       complete(&sl->dev_released);
-}
-
-static ssize_t w1_default_read_name(struct device *dev, char *buf)
-{
-       return sprintf(buf, "No family registered.\n");
-}
-
-static ssize_t w1_default_read_bin(struct kobject *kobj, char *buf, loff_t off,
-                    size_t count)
-{
-       return sprintf(buf, "No family registered.\n");
-}
-
-struct bus_type w1_bus_type = {
-       .name = "w1",
-       .match = w1_master_match,
-};
-
-struct device_driver w1_driver = {
-       .name = "w1_driver",
-       .bus = &w1_bus_type,
-       .probe = w1_master_probe,
-       .remove = w1_master_remove,
-};
-
-struct device w1_device = {
-       .parent = NULL,
-       .bus = &w1_bus_type,
-       .bus_id = "w1 bus master",
-       .driver = &w1_driver,
-       .release = &w1_master_release
-};
-
-static struct device_attribute w1_slave_attribute = {
-       .attr = {
-                       .name = "name",
-                       .mode = S_IRUGO,
-                       .owner = THIS_MODULE
-       },
-       .show = &w1_default_read_name,
-};
-
-static struct device_attribute w1_slave_attribute_val = {
-       .attr = {
-                       .name = "value",
-                       .mode = S_IRUGO,
-                       .owner = THIS_MODULE
-       },
-       .show = &w1_default_read_name,
-};
-
-static ssize_t w1_master_attribute_show(struct device *dev, char *buf)
-{
-       return sprintf(buf, "please fix me\n");
-#if 0
-       struct w1_master *md = container_of(dev, struct w1_master, dev);
-       int c = PAGE_SIZE;
-
-       if (down_interruptible(&md->mutex))
-               return -EBUSY;
-
-       c -= snprintf(buf + PAGE_SIZE - c, c, "%s\n", md->name);
-       c -= snprintf(buf + PAGE_SIZE - c, c,
-                      "bus_master=0x%p, timeout=%d, max_slave_count=%d, attempts=%lu\n",
-                      md->bus_master, w1_timeout, md->max_slave_count,
-                      md->attempts);
-       c -= snprintf(buf + PAGE_SIZE - c, c, "%d slaves: ",
-                      md->slave_count);
-       if (md->slave_count == 0)
-               c -= snprintf(buf + PAGE_SIZE - c, c, "no.\n");
-       else {
-               struct list_head *ent, *n;
-               struct w1_slave *sl;
-
-               list_for_each_safe(ent, n, &md->slist) {
-                       sl = list_entry(ent, struct w1_slave, w1_slave_entry);
-
-                       c -= snprintf(buf + PAGE_SIZE - c, c, "%s[%p] ",
-                                      sl->name, sl);
-               }
-               c -= snprintf(buf + PAGE_SIZE - c, c, "\n");
-       }
-
-       up(&md->mutex);
-
-       return PAGE_SIZE - c;
-#endif
-}
-
-struct device_attribute w1_master_attribute = {
-       .attr = {
-                       .name = "w1_master_stats",
-                       .mode = S_IRUGO,
-                       .owner = THIS_MODULE,
-       },
-       .show = &w1_master_attribute_show,
-};
-
-static struct bin_attribute w1_slave_bin_attribute = {
-       .attr = {
-                       .name = "w1_slave",
-                       .mode = S_IRUGO,
-                       .owner = THIS_MODULE,
-       },
-       .size = W1_SLAVE_DATA_SIZE,
-       .read = &w1_default_read_bin,
-};
-
-static int __w1_attach_slave_device(struct w1_slave *sl)
-{
-       int err;
-
-       sl->dev.parent = &sl->master->dev;
-       sl->dev.driver = sl->master->driver;
-       sl->dev.bus = &w1_bus_type;
-       sl->dev.release = &w1_slave_release;
-
-       snprintf(&sl->dev.bus_id[0], sizeof(sl->dev.bus_id),
-                 "%x-%llx",
-                 (unsigned int) sl->reg_num.family,
-                 (unsigned long long) sl->reg_num.id);
-       snprintf (&sl->name[0], sizeof(sl->name),
-                 "%x-%llx",
-                 (unsigned int) sl->reg_num.family,
-                 (unsigned long long) sl->reg_num.id);
-
-       dev_dbg(&sl->dev, "%s: registering %s.\n", __func__,
-               &sl->dev.bus_id[0]);
-
-       err = device_register(&sl->dev);
-       if (err < 0) {
-               dev_err(&sl->dev,
-                        "Device registration [%s] failed. err=%d\n",
-                        sl->dev.bus_id, err);
-               return err;
-       }
-
-       w1_slave_bin_attribute.read = sl->family->fops->rbin;
-       w1_slave_attribute.show = sl->family->fops->rname;
-       w1_slave_attribute_val.show = sl->family->fops->rval;
-       w1_slave_attribute_val.attr.name = sl->family->fops->rvalname;
-
-       err = device_create_file(&sl->dev, &w1_slave_attribute);
-       if (err < 0) {
-               dev_err(&sl->dev,
-                        "sysfs file creation for [%s] failed. err=%d\n",
-                        sl->dev.bus_id, err);
-               device_unregister(&sl->dev);
-               return err;
-       }
-
-       err = device_create_file(&sl->dev, &w1_slave_attribute_val);
-       if (err < 0) {
-               dev_err(&sl->dev,
-                        "sysfs file creation for [%s] failed. err=%d\n",
-                        sl->dev.bus_id, err);
-               device_remove_file(&sl->dev, &w1_slave_attribute);
-               device_unregister(&sl->dev);
-               return err;
-       }
-
-       err = sysfs_create_bin_file(&sl->dev.kobj, &w1_slave_bin_attribute);
-       if (err < 0) {
-               dev_err(&sl->dev,
-                        "sysfs file creation for [%s] failed. err=%d\n",
-                        sl->dev.bus_id, err);
-               device_remove_file(&sl->dev, &w1_slave_attribute);
-               device_remove_file(&sl->dev, &w1_slave_attribute_val);
-               device_unregister(&sl->dev);
-               return err;
-       }
-
-       list_add_tail(&sl->w1_slave_entry, &sl->master->slist);
-
-       return 0;
-}
-
-static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
-{
-       struct w1_slave *sl;
-       struct w1_family *f;
-       int err;
-
-       sl = kmalloc(sizeof(struct w1_slave), GFP_KERNEL);
-       if (!sl) {
-               dev_err(&dev->dev,
-                        "%s: failed to allocate new slave device.\n",
-                        __func__);
-               return -ENOMEM;
-       }
-
-       memset(sl, 0, sizeof(*sl));
-
-       sl->owner = THIS_MODULE;
-       sl->master = dev;
-
-       memcpy(&sl->reg_num, rn, sizeof(sl->reg_num));
-       atomic_set(&sl->refcnt, 0);
-       init_completion(&sl->dev_released);
-
-       spin_lock(&w1_flock);
-       f = w1_family_registered(rn->family);
-       if (!f) {
-               spin_unlock(&w1_flock);
-               dev_info(&dev->dev, "Family %x is not registered.\n",
-                         rn->family);
-               kfree(sl);
-               return -ENODEV;
-       }
-       __w1_family_get(f);
-       spin_unlock(&w1_flock);
-
-       sl->family = f;
-
-
-       err = __w1_attach_slave_device(sl);
-       if (err < 0) {
-               dev_err(&dev->dev, "%s: Attaching %s failed.\n", __func__,
-                        sl->name);
-               w1_family_put(sl->family);
-               kfree(sl);
-               return err;
-       }
-
-       dev->slave_count++;
-
-       return 0;
-}
-
-static void w1_slave_detach(struct w1_slave *sl)
-{
-       dev_info(&sl->dev, "%s: detaching %s.\n", __func__, sl->name);
-
-       while (atomic_read(&sl->refcnt))
-               schedule_timeout(10);
-
-       sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_bin_attribute);
-       device_remove_file(&sl->dev, &w1_slave_attribute);
-       device_unregister(&sl->dev);
-       w1_family_put(sl->family);
-}
-
-static void w1_search(struct w1_master *dev)
-{
-       u64 last, rn, tmp;
-       int i, count = 0, slave_count;
-       int last_family_desc, last_zero, last_device;
-       int search_bit, id_bit, comp_bit, desc_bit;
-       struct list_head *ent;
-       struct w1_slave *sl;
-       int family_found = 0;
-       struct w1_netlink_msg msg;
-
-       dev->attempts++;
-
-       memset(&msg, 0, sizeof(msg));
-
-       search_bit = id_bit = comp_bit = 0;
-       rn = tmp = last = 0;
-       last_device = last_zero = last_family_desc = 0;
-
-       desc_bit = 64;
-
-       while (!(id_bit && comp_bit) && !last_device
-               && count++ < dev->max_slave_count) {
-               last = rn;
-               rn = 0;
-
-               last_family_desc = 0;
-
-               /*
-                * Reset bus and all 1-wire device state machines
-                * so they can respond to our requests.
-                *
-                * Return 0 - device(s) present, 1 - no devices present.
-                */
-               if (w1_reset_bus(dev)) {
-                       dev_info(&dev->dev, "No devices present on the wire.\n");
-                       break;
-               }
-
-#if 1
-               memset(&msg, 0, sizeof(msg));
-
-               w1_write_8(dev, W1_SEARCH);
-               for (i = 0; i < 64; ++i) {
-                       /*
-                        * Read 2 bits from bus.
-                        * All who don't sleep must send ID bit and COMPLEMENT ID bit.
-                        * They actually are ANDed between all senders.
-                        */
-                       id_bit = w1_read_bit(dev);
-                       comp_bit = w1_read_bit(dev);
-
-                       if (id_bit && comp_bit)
-                               break;
-
-                       if (id_bit == 0 && comp_bit == 0) {
-                               if (i == desc_bit)
-                                       search_bit = 1;
-                               else if (i > desc_bit)
-                                       search_bit = 0;
-                               else
-                                       search_bit = ((last >> i) & 0x1);
-
-                               if (search_bit == 0) {
-                                       last_zero = i;
-                                       if (last_zero < 9)
-                                               last_family_desc = last_zero;
-                               }
-
-                       }
-                       else
-                               search_bit = id_bit;
-
-                       tmp = search_bit;
-                       rn |= (tmp << i);
-
-                       /*
-                        * Write 1 bit to bus
-                        * and make all who don't have "search_bit" in "i"'th position
-                        * in it's registration number sleep.
-                        */
-                       w1_write_bit(dev, search_bit);
-
-               }
-#endif
-               msg.id.w1_id = rn;
-               msg.val = w1_calc_crc8((u8 *) & rn, 7);
-               w1_netlink_send(dev, &msg);
-
-               if (desc_bit == last_zero)
-                       last_device = 1;
-
-               desc_bit = last_zero;
-
-               slave_count = 0;
-               list_for_each(ent, &dev->slist) {
-                       struct w1_reg_num *tmp;
-
-                       tmp = (struct w1_reg_num *) &rn;
-
-                       sl = list_entry(ent, struct w1_slave, w1_slave_entry);
-
-                       if (sl->reg_num.family == tmp->family &&
-                           sl->reg_num.id == tmp->id &&
-                           sl->reg_num.crc == tmp->crc)
-                               break;
-                       else if (sl->reg_num.family == tmp->family) {
-                               family_found = 1;
-                               break;
-                       }
-
-                       slave_count++;
-               }
-
-               if (slave_count == dev->slave_count &&
-                   msg.val && (*((__u8 *) & msg.val) == msg.id.id.crc)) {
-                       w1_attach_slave_device(dev, (struct w1_reg_num *) &rn);
-               }
-       }
-}
-
-int w1_control(void *data)
-{
-       struct w1_slave *sl;
-       struct w1_master *dev;
-       struct list_head *ent, *ment, *n, *mn;
-       int err, have_to_wait = 0, timeout;
-
-       daemonize("w1_control");
-       allow_signal(SIGTERM);
-
-       while (!control_needs_exit || have_to_wait) {
-               have_to_wait = 0;
-
-               timeout = w1_timeout;
-               do {
-                       timeout = interruptible_sleep_on_timeout(&w1_control_wait, timeout);
-                       if (current->flags & PF_FREEZE)
-                               refrigerator(PF_FREEZE);
-               } while (!signal_pending(current) && (timeout > 0));
-
-               if (signal_pending(current))
-                       flush_signals(current);
-
-               list_for_each_safe(ment, mn, &w1_masters) {
-                       dev = list_entry(ment, struct w1_master, w1_master_entry);
-
-                       if (!control_needs_exit && !dev->need_exit)
-                               continue;
-                       /*
-                        * Little race: we can create thread but not set the flag.
-                        * Get a chance for external process to set flag up.
-                        */
-                       if (!dev->initialized) {
-                               have_to_wait = 1;
-                               continue;
-                       }
-
-                       spin_lock(&w1_mlock);
-                       list_del(&dev->w1_master_entry);
-                       spin_unlock(&w1_mlock);
-
-                       if (control_needs_exit) {
-                               dev->need_exit = 1;
-
-                               err = kill_proc(dev->kpid, SIGTERM, 1);
-                               if (err)
-                                       dev_err(&dev->dev,
-                                                "Failed to send signal to w1 kernel thread %d.\n",
-                                                dev->kpid);
-                       }
-
-                       wait_for_completion(&dev->dev_exited);
-
-                       list_for_each_safe(ent, n, &dev->slist) {
-                               sl = list_entry(ent, struct w1_slave, w1_slave_entry);
-
-                               if (!sl)
-                                       dev_warn(&dev->dev,
-                                                 "%s: slave entry is NULL.\n",
-                                                 __func__);
-                               else {
-                                       list_del(&sl->w1_slave_entry);
-
-                                       w1_slave_detach(sl);
-                                       kfree(sl);
-                               }
-                       }
-                       device_remove_file(&dev->dev, &w1_master_attribute);
-                       atomic_dec(&dev->refcnt);
-               }
-       }
-
-       complete_and_exit(&w1_control_complete, 0);
-}
-
-int w1_process(void *data)
-{
-       struct w1_master *dev = (struct w1_master *) data;
-       unsigned long timeout;
-
-       daemonize("%s", dev->name);
-       allow_signal(SIGTERM);
-
-       while (!dev->need_exit) {
-               timeout = w1_timeout;
-               do {
-                       timeout = interruptible_sleep_on_timeout(&dev->kwait, timeout);
-                       if (current->flags & PF_FREEZE)
-                               refrigerator(PF_FREEZE);
-               } while (!signal_pending(current) && (timeout > 0));
-
-               if (signal_pending(current))
-                       flush_signals(current);
-
-               if (dev->need_exit)
-                       break;
-
-               if (!dev->initialized)
-                       continue;
-
-               if (down_interruptible(&dev->mutex))
-                       continue;
-               w1_search(dev);
-               up(&dev->mutex);
-       }
-
-       atomic_dec(&dev->refcnt);
-       complete_and_exit(&dev->dev_exited, 0);
-
-       return 0;
-}
-
-int w1_init(void)
-{
-       int retval;
-
-       printk(KERN_INFO "Driver for 1-wire Dallas network protocol.\n");
-
-       retval = bus_register(&w1_bus_type);
-       if (retval) {
-               printk(KERN_ERR "Failed to register bus. err=%d.\n", retval);
-               goto err_out_exit_init;
-       }
-
-       retval = driver_register(&w1_driver);
-       if (retval) {
-               printk(KERN_ERR
-                       "Failed to register master driver. err=%d.\n",
-                       retval);
-               goto err_out_bus_unregister;
-       }
-
-       control_thread = kernel_thread(&w1_control, NULL, 0);
-       if (control_thread < 0) {
-               printk(KERN_ERR "Failed to create control thread. err=%d\n",
-                       control_thread);
-               retval = control_thread;
-               goto err_out_driver_unregister;
-       }
-
-       return 0;
-
-err_out_driver_unregister:
-       driver_unregister(&w1_driver);
-
-err_out_bus_unregister:
-       bus_unregister(&w1_bus_type);
-
-err_out_exit_init:
-       return retval;
-}
-
-void w1_fini(void)
-{
-       struct w1_master *dev;
-       struct list_head *ent, *n;
-
-       list_for_each_safe(ent, n, &w1_masters) {
-               dev = list_entry(ent, struct w1_master, w1_master_entry);
-               __w1_remove_master_device(dev);
-       }
-
-       control_needs_exit = 1;
-
-       wait_for_completion(&w1_control_complete);
-
-       driver_unregister(&w1_driver);
-       bus_unregister(&w1_bus_type);
-}
-
-module_init(w1_init);
-module_exit(w1_fini);
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
deleted file mode 100644 (file)
index c75e9f7..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- *     w1_int.c
- *
- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
- * 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <linux/kernel.h>
-#include <linux/list.h>
-
-#include "w1.h"
-#include "w1_log.h"
-
-static u32 w1_ids = 1;
-
-extern struct device_driver w1_driver;
-extern struct bus_type w1_bus_type;
-extern struct device w1_device;
-extern struct device_attribute w1_master_attribute;
-extern int w1_max_slave_count;
-extern struct list_head w1_masters;
-extern spinlock_t w1_mlock;
-
-extern int w1_process(void *);
-
-struct w1_master * w1_alloc_dev(u32 id, int slave_count,
-             struct device_driver *driver, struct device *device)
-{
-       struct w1_master *dev;
-       int err;
-
-       /*
-        * We are in process context(kernel thread), so can sleep.
-        */
-       dev = kmalloc(sizeof(struct w1_master) + sizeof(struct w1_bus_master), GFP_KERNEL);
-       if (!dev) {
-               printk(KERN_ERR
-                       "Failed to allocate %zd bytes for new w1 device.\n",
-                       sizeof(struct w1_master));
-               return NULL;
-       }
-
-       memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
-
-       dev->bus_master = (struct w1_bus_master *)(dev + 1);
-
-       dev->owner              = THIS_MODULE;
-       dev->max_slave_count    = slave_count;
-       dev->slave_count        = 0;
-       dev->attempts           = 0;
-       dev->kpid               = -1;
-       dev->initialized        = 0;
-       dev->id                 = id;
-
-       atomic_set(&dev->refcnt, 2);
-
-       INIT_LIST_HEAD(&dev->slist);
-       init_MUTEX(&dev->mutex);
-
-       init_waitqueue_head(&dev->kwait);
-       init_completion(&dev->dev_released);
-       init_completion(&dev->dev_exited);
-
-       memcpy(&dev->dev, device, sizeof(struct device));
-       snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
-                 "w1_bus_master%u", dev->id);
-       snprintf(dev->name, sizeof(dev->name), "w1_bus_master%u", dev->id);
-
-       dev->driver = driver;
-
-       dev->groups = 23;
-       dev->seq = 1;
-       dev->nls = netlink_kernel_create(NETLINK_NFLOG, NULL);
-       if (!dev->nls) {
-               printk(KERN_ERR "Failed to create new netlink socket(%u).\n",
-                       NETLINK_NFLOG);
-               memset(dev, 0, sizeof(struct w1_master));
-               kfree(dev);
-               dev = NULL;
-       }
-
-       err = device_register(&dev->dev);
-       if (err) {
-               printk(KERN_ERR "Failed to register master device. err=%d\n", err);
-               if (dev->nls->sk_socket)
-                       sock_release(dev->nls->sk_socket);
-               memset(dev, 0, sizeof(struct w1_master));
-               kfree(dev);
-               dev = NULL;
-       }
-
-       return dev;
-}
-
-void w1_free_dev(struct w1_master *dev)
-{
-       device_unregister(&dev->dev);
-       if (dev->nls->sk_socket)
-               sock_release(dev->nls->sk_socket);
-       memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
-       kfree(dev);
-}
-
-int w1_add_master_device(struct w1_bus_master *master)
-{
-       struct w1_master *dev;
-       int retval = 0;
-
-       dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, &w1_driver, &w1_device);
-       if (!dev)
-               return -ENOMEM;
-
-       dev->kpid = kernel_thread(&w1_process, dev, 0);
-       if (dev->kpid < 0) {
-               dev_err(&dev->dev,
-                        "Failed to create new kernel thread. err=%d\n",
-                        dev->kpid);
-               retval = dev->kpid;
-               goto err_out_free_dev;
-       }
-
-       retval = device_create_file(&dev->dev, &w1_master_attribute);
-       if (retval)
-               goto err_out_kill_thread;
-
-       memcpy(dev->bus_master, master, sizeof(struct w1_bus_master));
-
-       dev->initialized = 1;
-
-       spin_lock(&w1_mlock);
-       list_add(&dev->w1_master_entry, &w1_masters);
-       spin_unlock(&w1_mlock);
-
-       return 0;
-
-err_out_kill_thread:
-       dev->need_exit = 1;
-       if (kill_proc(dev->kpid, SIGTERM, 1))
-               dev_err(&dev->dev,
-                        "Failed to send signal to w1 kernel thread %d.\n",
-                        dev->kpid);
-       wait_for_completion(&dev->dev_exited);
-
-err_out_free_dev:
-       w1_free_dev(dev);
-
-       return retval;
-}
-
-void __w1_remove_master_device(struct w1_master *dev)
-{
-       int err;
-
-       dev->need_exit = 1;
-       err = kill_proc(dev->kpid, SIGTERM, 1);
-       if (err)
-               dev_err(&dev->dev,
-                        "%s: Failed to send signal to w1 kernel thread %d.\n",
-                        __func__, dev->kpid);
-
-       while (atomic_read(&dev->refcnt))
-               schedule_timeout(10);
-
-       w1_free_dev(dev);
-}
-
-void w1_remove_master_device(struct w1_bus_master *bm)
-{
-       struct w1_master *dev = NULL;
-       struct list_head *ent, *n;
-
-       list_for_each_safe(ent, n, &w1_masters) {
-               dev = list_entry(ent, struct w1_master, w1_master_entry);
-               if (!dev->initialized)
-                       continue;
-
-               if (dev->bus_master->data == bm->data)
-                       break;
-       }
-
-       if (!dev) {
-               printk(KERN_ERR "Device doesn't exist.\n");
-               return;
-       }
-
-       __w1_remove_master_device(dev);
-}
-
-EXPORT_SYMBOL(w1_alloc_dev);
-EXPORT_SYMBOL(w1_free_dev);
-EXPORT_SYMBOL(w1_add_master_device);
-EXPORT_SYMBOL(w1_remove_master_device);
-EXPORT_SYMBOL(__w1_remove_master_device);
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
deleted file mode 100644 (file)
index 9baacee..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- *     w1_io.c
- *
- * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
- * 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <asm/io.h>
-
-#include <linux/delay.h>
-#include <linux/moduleparam.h>
-
-#include "w1.h"
-#include "w1_log.h"
-#include "w1_io.h"
-
-int w1_delay_parm = 1;
-module_param_named(delay_coef, w1_delay_parm, int, 0);
-
-static u8 w1_crc8_table[] = {
-       0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31, 65,
-       157, 195, 33, 127, 252, 162, 64, 30, 95, 1, 227, 189, 62, 96, 130, 220,
-       35, 125, 159, 193, 66, 28, 254, 160, 225, 191, 93, 3, 128, 222, 60, 98,
-       190, 224, 2, 92, 223, 129, 99, 61, 124, 34, 192, 158, 29, 67, 161, 255,
-       70, 24, 250, 164, 39, 121, 155, 197, 132, 218, 56, 102, 229, 187, 89, 7,
-       219, 133, 103, 57, 186, 228, 6, 88, 25, 71, 165, 251, 120, 38, 196, 154,
-       101, 59, 217, 135, 4, 90, 184, 230, 167, 249, 27, 69, 198, 152, 122, 36,
-       248, 166, 68, 26, 153, 199, 37, 123, 58, 100, 134, 216, 91, 5, 231, 185,
-       140, 210, 48, 110, 237, 179, 81, 15, 78, 16, 242, 172, 47, 113, 147, 205,
-       17, 79, 173, 243, 112, 46, 204, 146, 211, 141, 111, 49, 178, 236, 14, 80,
-       175, 241, 19, 77, 206, 144, 114, 44, 109, 51, 209, 143, 12, 82, 176, 238,
-       50, 108, 142, 208, 83, 13, 239, 177, 240, 174, 76, 18, 145, 207, 45, 115,
-       202, 148, 118, 40, 171, 245, 23, 73, 8, 86, 180, 234, 105, 55, 213, 139,
-       87, 9, 235, 181, 54, 104, 138, 212, 149, 203, 41, 119, 244, 170, 72, 22,
-       233, 183, 85, 11, 136, 214, 52, 106, 43, 117, 151, 201, 74, 20, 246, 168,
-       116, 42, 200, 150, 21, 75, 169, 247, 182, 232, 10, 84, 215, 137, 107, 53
-};
-
-void w1_delay(unsigned long tm)
-{
-       udelay(tm * w1_delay_parm);
-}
-
-void w1_write_bit(struct w1_master *dev, int bit)
-{
-       if (bit) {
-               dev->bus_master->write_bit(dev->bus_master->data, 0);
-               w1_delay(6);
-               dev->bus_master->write_bit(dev->bus_master->data, 1);
-               w1_delay(64);
-       } else {
-               dev->bus_master->write_bit(dev->bus_master->data, 0);
-               w1_delay(60);
-               dev->bus_master->write_bit(dev->bus_master->data, 1);
-               w1_delay(10);
-       }
-}
-
-void w1_write_8(struct w1_master *dev, u8 byte)
-{
-       int i;
-
-       for (i = 0; i < 8; ++i)
-               w1_write_bit(dev, (byte >> i) & 0x1);
-}
-
-u8 w1_read_bit(struct w1_master *dev)
-{
-       int result;
-
-       dev->bus_master->write_bit(dev->bus_master->data, 0);
-       w1_delay(6);
-       dev->bus_master->write_bit(dev->bus_master->data, 1);
-       w1_delay(9);
-
-       result = dev->bus_master->read_bit(dev->bus_master->data);
-       w1_delay(55);
-
-       return result & 0x1;
-}
-
-u8 w1_read_8(struct w1_master * dev)
-{
-       int i;
-       u8 res = 0;
-
-       for (i = 0; i < 8; ++i)
-               res |= (w1_read_bit(dev) << i);
-
-       return res;
-}
-
-int w1_reset_bus(struct w1_master *dev)
-{
-       int result;
-
-       dev->bus_master->write_bit(dev->bus_master->data, 0);
-       w1_delay(480);
-       dev->bus_master->write_bit(dev->bus_master->data, 1);
-       w1_delay(70);
-
-       result = dev->bus_master->read_bit(dev->bus_master->data) & 0x1;
-       w1_delay(410);
-
-       return result;
-}
-
-u8 w1_calc_crc8(u8 * data, int len)
-{
-       u8 crc = 0;
-
-       while (len--)
-               crc = w1_crc8_table[crc ^ *data++];
-
-       return crc;
-}
-
-EXPORT_SYMBOL(w1_write_bit);
-EXPORT_SYMBOL(w1_write_8);
-EXPORT_SYMBOL(w1_read_bit);
-EXPORT_SYMBOL(w1_read_8);
-EXPORT_SYMBOL(w1_reset_bus);
-EXPORT_SYMBOL(w1_calc_crc8);
-EXPORT_SYMBOL(w1_delay);
index a4035fb..460a4cb 100644 (file)
@@ -937,6 +937,56 @@ config RAMFS
          To compile this as a module, choose M here: the module will be called
          ramfs.
 
+config RELAYFS_FS
+       tristate "Relayfs file system support"
+       ---help---
+         Relayfs is a high-speed data relay filesystem designed to provide
+         an efficient mechanism for tools and facilities to relay large
+         amounts of data from kernel space to user space.  It's not useful
+         on its own, and should only be enabled if other facilities that
+         need it are enabled, such as for example klog or the Linux Trace
+         Toolkit.
+
+         See <file:Documentation/filesystems/relayfs.txt> for further
+         information.
+
+         This file system is also available as a module ( = code which can be
+         inserted in and removed from the running kernel whenever you want).
+         The module is called relayfs.  If you want to compile it as a
+         module, say M here and read <file:Documentation/modules.txt>.
+
+         If unsure, say N.
+
+config KLOG_CHANNEL
+       bool "Enable klog debugging support"
+       depends on RELAYFS_FS
+       help
+         If you say Y to this, a relayfs channel named klog will be created
+         in the root of the relayfs file system.  You can write to the klog
+         channel using klog() or klog_raw() from within the kernel or
+         kernel modules, and read from the klog channel by mounting relayfs
+         and using read(2) to read from it (or using cat).  If you're not  
+         sure, say N.
+
+config KLOG_CHANNEL_AUTOENABLE
+       bool "Enable klog logging on startup"
+       depends on KLOG_CHANNEL
+       default y
+       help
+         If you say Y to this, the klog channel will be automatically enabled
+         on startup.  Otherwise, to turn klog logging on, you need use
+         sysctl (fs.relayfs.klog_enabled).  This option is used in cases where
+         you don't actually want the channel to be written to until it's
+         enabled.  If you're not sure, say Y.
+
+config KLOG_CHANNEL_SHIFT
+       depends on KLOG_CHANNEL
+       int "klog debugging channel size (14 => 16KB, 22 => 4MB)"
+       range 14 22
+       default 21
+       help
+         Select klog debugging channel size as a power of 2.
+
 endmenu
 
 menu "Miscellaneous filesystems"
@@ -1262,8 +1312,6 @@ config HPFS_FS
          To compile this file system support as a module, choose M here: the
          module will be called hpfs.  If unsure, say N.
 
-
-
 config QNX4FS_FS
        tristate "QNX4 file system support (read only)"
        help
@@ -1289,8 +1337,6 @@ config QNX4FS_RW
          It's currently broken, so for now:
          answer N.
 
-
-
 config SYSV_FS
        tristate "System V/Xenix/V7/Coherent file system support"
        help
@@ -1327,8 +1373,6 @@ config SYSV_FS
 
          If you haven't heard about all of this before, it's safe to say N.
 
-
-
 config UFS_FS
        tristate "UFS file system support (read only)"
        help
index 41cac35..9911572 100644 (file)
@@ -52,6 +52,7 @@ obj-$(CONFIG_EXT2_FS)         += ext2/
 obj-$(CONFIG_CRAMFS)           += cramfs/
 obj-$(CONFIG_RAMFS)            += ramfs/
 obj-$(CONFIG_HUGETLBFS)                += hugetlbfs/
+obj-$(CONFIG_RELAYFS_FS)       += relayfs/
 obj-$(CONFIG_CODA_FS)          += coda/
 obj-$(CONFIG_MINIX_FS)         += minix/
 obj-$(CONFIG_FAT_FS)           += fat/
@@ -91,3 +92,5 @@ obj-$(CONFIG_JFS_FS)          += jfs/
 obj-$(CONFIG_XFS_FS)           += xfs/
 obj-$(CONFIG_AFS_FS)           += afs/
 obj-$(CONFIG_BEFS_FS)          += befs/
+obj-$(CONFIG_EXTERNFS)         += hostfs/
+obj-$(CONFIG_RCFS_FS)          += rcfs/
index 8b5c1e2..cc225ce 100644 (file)
@@ -235,7 +235,7 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
  */
 static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-       struct nameidata newnd;
+       struct dentry *old_dentry;
        struct vfsmount *newmnt;
        int err;
 
@@ -247,15 +247,18 @@ static int afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
               nd->dentry->d_name.name);
 
        newmnt = afs_mntpt_do_automount(dentry);
-       if (IS_ERR(newmnt))
+       if (IS_ERR(newmnt)) {
+               path_release(nd);
                return PTR_ERR(newmnt);
+       }
 
-       newnd = *nd;
-       newnd.dentry = dentry;
-       err = do_add_mount(newmnt, &newnd, 0, &afs_vfsmounts);
+       old_dentry = nd->dentry;
+       nd->dentry = dentry;
+       err = do_add_mount(newmnt, nd, 0, &afs_vfsmounts);
+       nd->dentry = old_dentry;
 
+       path_release(nd);
        if (!err) {
-               path_release(nd);
                mntget(newmnt);
                nd->mnt = newmnt;
                dget(newmnt->mnt_root);
index 8acb289..89e03f7 100644 (file)
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -14,6 +14,9 @@
 #include <linux/fcntl.h>
 #include <linux/quotaops.h>
 #include <linux/security.h>
+#include <linux/vs_base.h>
+#include <linux/proc_fs.h>
+#include <linux/devpts_fs.h>
 
 /* Taken over from the old code... */
 
@@ -55,6 +58,31 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)
                if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
                        goto error;
        }
+
+       /* Check for evil vserver activity */
+       if (vx_check(0, VX_ADMIN))
+               goto fine;
+
+       if (IS_BARRIER(inode)) {
+               printk(KERN_WARNING
+                       "VSW: xid=%d messing with the barrier.\n",
+                       vx_current_xid());
+               goto error;
+       }
+       switch (inode->i_sb->s_magic) {
+               case PROC_SUPER_MAGIC:
+                       printk(KERN_WARNING
+                               "VSW: xid=%d messing with the procfs.\n",
+                               vx_current_xid());
+                       goto error;
+               case DEVPTS_SUPER_MAGIC:
+                       if (vx_check(inode->i_xid, VX_IDENT))
+                               goto fine;
+                       printk(KERN_WARNING
+                               "VSW: xid=%d messing with the devpts.\n",
+                               vx_current_xid());
+                       goto error;     
+       }
 fine:
        retval = 0;
 error:
@@ -63,6 +91,24 @@ error:
 
 EXPORT_SYMBOL(inode_change_ok);
 
+int inode_setattr_flags(struct inode *inode, unsigned int flags)
+{
+       unsigned int oldflags, newflags;
+
+       oldflags = inode->i_flags;
+       newflags = oldflags & ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER);
+       if (flags & ATTR_FLAG_IMMUTABLE)
+               newflags |= S_IMMUTABLE;
+       if (flags & ATTR_FLAG_IUNLINK)
+               newflags |= S_IUNLINK;
+       if (flags & ATTR_FLAG_BARRIER)
+               newflags |= S_BARRIER;
+
+       if (oldflags ^ newflags)
+               inode->i_flags = newflags;
+       return 0;
+}
+
 int inode_setattr(struct inode * inode, struct iattr * attr)
 {
        unsigned int ia_valid = attr->ia_valid;
@@ -86,6 +132,8 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
                inode->i_uid = attr->ia_uid;
        if (ia_valid & ATTR_GID)
                inode->i_gid = attr->ia_gid;
+       if (ia_valid & ATTR_XID)
+               inode->i_xid = attr->ia_xid;
        if (ia_valid & ATTR_ATIME)
                inode->i_atime = attr->ia_atime;
        if (ia_valid & ATTR_MTIME)
@@ -99,6 +147,8 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
                        mode &= ~S_ISGID;
                inode->i_mode = mode;
        }
+       if (ia_valid & ATTR_ATTR_FLAG)
+               inode_setattr_flags(inode, attr->ia_attr_flags);
        mark_inode_dirty(inode);
 out:
        return error;
@@ -114,6 +164,8 @@ int setattr_mask(unsigned int ia_valid)
                dn_mask |= DN_ATTRIB;
        if (ia_valid & ATTR_GID)
                dn_mask |= DN_ATTRIB;
+       if (ia_valid & ATTR_XID)
+               dn_mask |= DN_ATTRIB;
        if (ia_valid & ATTR_SIZE)
                dn_mask |= DN_MODIFY;
        /* both times implies a utime(s) call */
@@ -177,7 +229,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
                        error = security_inode_setattr(dentry, attr);
                if (!error) {
                        if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
-                           (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
+                           (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
+                           (ia_valid & ATTR_XID && attr->ia_xid != inode->i_xid))
                                error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
                        if (!error)
                                error = inode_setattr(inode, attr);
index b5e1901..651c396 100644 (file)
@@ -23,7 +23,7 @@
 #include "befs.h"
 #include "endian.h"
 
-#define ERRBUFSIZE 1024
+#define ERRBUFSIZE 512
 
 void
 befs_error(const struct super_block *sb, const char *fmt, ...)
index 77d1e68..59d1feb 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/binfmts.h>
 #include <linux/personality.h>
 #include <linux/init.h>
+#include <linux/vs_memory.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -307,9 +308,10 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                (current->mm->start_data = N_DATADDR(ex));
        current->mm->brk = ex.a_bss +
                (current->mm->start_brk = N_BSSADDR(ex));
-       current->mm->free_area_cache = TASK_UNMAPPED_BASE;
+       current->mm->free_area_cache = current->mm->mmap_base;
 
-       current->mm->rss = 0;
+       // current->mm->rss = 0;
+       vx_rsspages_sub(current->mm, current->mm->rss);
        current->mm->mmap = NULL;
        compute_creds(bprm);
        current->flags &= ~PF_FORKNOEXEC;
index 771cb85..fb98fce 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/pagemap.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
+#include <linux/vs_memory.h>
 
 #include <asm/uaccess.h>
 #include <asm/param.h>
@@ -45,7 +46,7 @@
 
 static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs);
 static int load_elf_library(struct file*);
-static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int);
+static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int, unsigned long);
 extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);
 
 #ifndef elf_addr_t
@@ -155,20 +156,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec,
        if (k_platform) {
                size_t len = strlen(k_platform) + 1;
 
-#ifdef CONFIG_X86_HT
-               /*
-                * In some cases (e.g. Hyper-Threading), we want to avoid L1
-                * evictions by the processes running on the same package. One
-                * thing we can do is to shuffle the initial stack for them.
-                *
-                * The conditionals here are unneeded, but kept in to make the
-                * code behaviour the same as pre change unless we have
-                * hyperthreaded processors. This should be cleaned up
-                * before 2.6
-                */
-        
-               if (smp_num_siblings > 1)
-                       STACK_ALLOC(p, ((current->pid % 64) << 7));
+#ifdef __HAVE_ARCH_ALIGN_STACK
+               p = (unsigned long)arch_align_stack((unsigned long)p);
 #endif
                u_platform = (elf_addr_t __user *)STACK_ALLOC(p, len);
                __copy_to_user(u_platform, k_platform, len);
@@ -275,20 +264,59 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec,
 #ifndef elf_map
 
 static unsigned long elf_map(struct file *filep, unsigned long addr,
-                       struct elf_phdr *eppnt, int prot, int type)
+                            struct elf_phdr *eppnt, int prot, int type,
+                            unsigned long total_size)
 {
        unsigned long map_addr;
+       unsigned long size = eppnt->p_filesz + ELF_PAGEOFFSET(eppnt->p_vaddr);
+       unsigned long off = eppnt->p_offset - ELF_PAGEOFFSET(eppnt->p_vaddr);
+
+       addr = ELF_PAGESTART(addr);
+       size = ELF_PAGEALIGN(size);
 
        down_write(&current->mm->mmap_sem);
-       map_addr = do_mmap(filep, ELF_PAGESTART(addr),
-                          eppnt->p_filesz + ELF_PAGEOFFSET(eppnt->p_vaddr), prot, type,
-                          eppnt->p_offset - ELF_PAGEOFFSET(eppnt->p_vaddr));
+
+       /*
+        * total_size is the size of the ELF (interpreter) image.
+        * The _first_ mmap needs to know the full size, otherwise
+        * randomization might put this image into an overlapping
+        * position with the ELF binary image. (since size < total_size)
+        * So we first map the 'big' image - and unmap the remainder at
+        * the end. (which unmap is needed for ELF images with holes.)
+        */
+       if (total_size) {
+               total_size = ELF_PAGEALIGN(total_size);
+               map_addr = do_mmap(filep, addr, total_size, prot, type, off);
+               if (!BAD_ADDR(map_addr))
+                       do_munmap(current->mm, map_addr+size, total_size-size);
+       } else
+               map_addr = do_mmap(filep, addr, size, prot, type, off);
+               
        up_write(&current->mm->mmap_sem);
-       return(map_addr);
+
+       return map_addr;
 }
 
 #endif /* !elf_map */
 
+static inline unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
+{
+       int i, first_idx = -1, last_idx = -1;
+
+       for (i = 0; i < nr; i++)
+               if (cmds[i].p_type == PT_LOAD) {
+                       last_idx = i;
+                       if (first_idx == -1)
+                               first_idx = i;
+               }
+
+       if (first_idx == -1)
+               return 0;
+
+       return cmds[last_idx].p_vaddr + cmds[last_idx].p_memsz -
+                               ELF_PAGESTART(cmds[first_idx].p_vaddr);
+}
+
 /* This is much more generalized than the library routine read function,
    so we keep this separate.  Technically the library read function
    is only provided so that we can read a.out libraries that have
@@ -296,7 +324,8 @@ static unsigned long elf_map(struct file *filep, unsigned long addr,
 
 static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
                                     struct file * interpreter,
-                                    unsigned long *interp_load_addr)
+                                    unsigned long *interp_load_addr,
+                                    unsigned long no_base)
 {
        struct elf_phdr *elf_phdata;
        struct elf_phdr *eppnt;
@@ -304,6 +333,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
        int load_addr_set = 0;
        unsigned long last_bss = 0, elf_bss = 0;
        unsigned long error = ~0UL;
+       unsigned long total_size;
        int retval, i, size;
 
        /* First of all, some simple consistency checks */
@@ -338,6 +368,10 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
        if (retval < 0)
                goto out_close;
 
+       total_size = total_mapping_size(elf_phdata, interp_elf_ex->e_phnum);
+       if (!total_size)
+               goto out_close;
+
        eppnt = elf_phdata;
        for (i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) {
          if (eppnt->p_type == PT_LOAD) {
@@ -352,8 +386,11 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
            vaddr = eppnt->p_vaddr;
            if (interp_elf_ex->e_type == ET_EXEC || load_addr_set)
                elf_type |= MAP_FIXED;
+           else if (no_base && interp_elf_ex->e_type == ET_DYN)
+               load_addr = -vaddr;
 
-           map_addr = elf_map(interpreter, load_addr + vaddr, eppnt, elf_prot, elf_type);
+           map_addr = elf_map(interpreter, load_addr + vaddr, eppnt, elf_prot, elf_type, total_size);
+           total_size = 0;
            error = map_addr;
            if (BAD_ADDR(map_addr))
                goto out_close;
@@ -492,7 +529,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        struct exec interp_ex;
        char passed_fileno[6];
        struct files_struct *files;
-       int have_pt_gnu_stack, executable_stack = EXSTACK_DEFAULT;
+       int have_pt_gnu_stack, executable_stack, relocexec, old_relocexec = current->flags & PF_RELOCEXEC;
        unsigned long def_flags = 0;
        
        /* Get the exec-header */
@@ -619,6 +656,8 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        }
 
        elf_ppnt = elf_phdata;
+       executable_stack = EXSTACK_DEFAULT;
+
        for (i = 0; i < elf_ex.e_phnum; i++, elf_ppnt++)
                if (elf_ppnt->p_type == PT_GNU_STACK) {
                        if (elf_ppnt->p_flags & PF_X)
@@ -629,6 +668,24 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                }
        have_pt_gnu_stack = (i < elf_ex.e_phnum);
 
+       relocexec = 0;
+
+       if (current->personality == PER_LINUX)
+       switch (exec_shield) {
+       case 1:
+               if (executable_stack != EXSTACK_DEFAULT) {
+                       current->flags |= PF_RELOCEXEC;
+                       relocexec = PF_RELOCEXEC;
+               }
+               break;
+
+       case 2:
+               executable_stack = EXSTACK_DISABLE_X;
+               current->flags |= PF_RELOCEXEC;
+               relocexec = PF_RELOCEXEC;
+               break;
+       }
+
        /* Some simple consistency checks for the interpreter */
        if (elf_interpreter) {
                interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT;
@@ -681,6 +738,16 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        retval = flush_old_exec(bprm);
        if (retval)
                goto out_free_dentry;
+       current->flags |= relocexec;
+
+#ifdef __i386__
+       /*
+        * Turn off the CS limit completely if exec-shield disabled or
+        * NX active:
+        */
+       if (!exec_shield)
+               arch_add_exec_range(current->mm, -1);
+#endif
 
        /* Discard our unneeded old files struct */
        if (files) {
@@ -705,8 +772,9 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
 
        /* Do this so that we can load the interpreter, if need be.  We will
           change some of these later */
-       current->mm->rss = 0;
-       current->mm->free_area_cache = TASK_UNMAPPED_BASE;
+       // current->mm->rss = 0;
+       vx_rsspages_sub(current->mm, current->mm->rss);
+       current->mm->free_area_cache = current->mm->mmap_base;
        retval = setup_arg_pages(bprm, executable_stack);
        if (retval < 0) {
                send_sig(SIGKILL, current, 0);
@@ -715,10 +783,10 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        
        current->mm->start_stack = bprm->p;
 
+
        /* Now we do a little grungy work by mmaping the ELF image into
-          the correct location in memory.  At this point, we assume that
-          the image should be loaded at fixed address, not at a variable
-          address. */
+          the correct location in memory.
+        */
 
        for(i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) {
                int elf_prot = 0, elf_flags;
@@ -755,16 +823,16 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                elf_flags = MAP_PRIVATE|MAP_DENYWRITE|MAP_EXECUTABLE;
 
                vaddr = elf_ppnt->p_vaddr;
-               if (elf_ex.e_type == ET_EXEC || load_addr_set) {
+               if (elf_ex.e_type == ET_EXEC || load_addr_set)
                        elf_flags |= MAP_FIXED;
-               } else if (elf_ex.e_type == ET_DYN) {
-                       /* Try and get dynamic programs out of the way of the default mmap
-                          base, as well as whatever program they might try to exec.  This
-                          is because the brk will follow the loader, and is not movable.  */
+               else if (elf_ex.e_type == ET_DYN)
+#ifdef __i386__
+                       load_bias = 0;
+#else
                        load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
-               }
+#endif
 
-               error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, elf_prot, elf_flags);
+               error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, elf_prot, elf_flags, 0);
                if (BAD_ADDR(error))
                        continue;
 
@@ -835,7 +903,8 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                else
                        elf_entry = load_elf_interp(&interp_elf_ex,
                                                    interpreter,
-                                                   &interp_load_addr);
+                                                   &interp_load_addr,
+                                                   load_bias);
                if (BAD_ADDR(elf_entry)) {
                        printk(KERN_ERR "Unable to load interpreter\n");
                        send_sig(SIGSEGV, current, 0);
@@ -858,6 +927,14 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
 
        set_binfmt(&elf_format);
 
+       /*
+        * Map the vsyscall trampoline. This address is then passed via
+        * AT_SYSINFO.
+        */
+#ifdef __HAVE_ARCH_VSYSCALL
+       map_vsyscall();
+#endif
+
        compute_creds(bprm);
        current->flags &= ~PF_FORKNOEXEC;
        create_elf_tables(bprm, &elf_ex, (interpreter_type == INTERPRETER_AOUT),
@@ -871,6 +948,10 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        current->mm->end_data = end_data;
        current->mm->start_stack = bprm->p;
 
+#ifdef __HAVE_ARCH_RANDOMIZE_BRK
+       if (current->flags & PF_RELOCEXEC)
+               randomize_brk(elf_brk);
+#endif
        if (current->personality & MMAP_PAGE_ZERO) {
                /* Why this, you ask???  Well SVr4 maps page 0 as read-only,
                   and some applications "depend" upon this behavior.
@@ -924,6 +1005,8 @@ out_free_fh:
        }
 out_free_ph:
        kfree(elf_phdata);
+       current->flags &= ~PF_RELOCEXEC;
+       current->flags |= old_relocexec;
        goto out;
 }
 
index 64fea54..0bc28fe 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/personality.h>
 #include <linux/init.h>
 #include <linux/flat.h>
+#include <linux/vs_memory.h>
 
 #include <asm/byteorder.h>
 #include <asm/system.h>
@@ -650,7 +651,8 @@ static int load_flat_file(struct linux_binprm * bprm,
                current->mm->start_brk = datapos + data_len + bss_len;
                current->mm->brk = (current->mm->start_brk + 3) & ~3;
                current->mm->context.end_brk = memp + ksize((void *) memp) - stack_len;
-               current->mm->rss = 0;
+               // current->mm->rss = 0;
+               vx_rsspages_sub(current->mm, current->mm->rss);
        }
 
        if (flags & FLAT_FLAG_KTRACE)
index d7e5f1f..4969da6 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/shm.h>
 #include <linux/personality.h>
 #include <linux/init.h>
+#include <linux/vs_memory.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -259,7 +260,8 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        create_som_tables(bprm);
 
        current->mm->start_stack = bprm->p;
-       current->mm->rss = 0;
+       // current->mm->rss = 0;
+       vx_rsspages_sub(current->mm, current->mm->rss);
 
 #if 0
        printk("(start_brk) %08lx\n" , (unsigned long) current->mm->start_brk);
index c70e72e..7e849b1 100644 (file)
@@ -1551,6 +1551,7 @@ __getblk(struct block_device *bdev, sector_t block, int size)
 {
        struct buffer_head *bh = __find_get_block(bdev, block, size);
 
+       might_sleep();
        if (bh == NULL)
                bh = __getblk_slow(bdev, block, size);
        return bh;
@@ -1776,6 +1777,8 @@ void unmap_underlying_metadata(struct block_device *bdev, sector_t block)
 {
        struct buffer_head *old_bh;
 
+       might_sleep();
+
        old_bh = __find_get_block_slow(bdev, block, 0);
        if (old_bh) {
                clear_buffer_dirty(old_bh);
index fbc737e..cd31d19 100644 (file)
@@ -512,6 +512,7 @@ struct inode_operations cifs_file_inode_ops = {
 struct inode_operations cifs_symlink_inode_ops = {
        .readlink = cifs_readlink,
        .follow_link = cifs_follow_link,
+       .put_link = cifs_put_link,
        .permission = cifs_permission,
        /* BB add the following two eventually */
        /* revalidate: cifs_revalidate,
index 866b68c..b1cbc68 100644 (file)
@@ -81,6 +81,7 @@ extern struct dentry_operations cifs_dentry_ops;
 
 /* Functions related to symlinks */
 extern int cifs_follow_link(struct dentry *direntry, struct nameidata *nd);
+extern void cifs_put_link(struct dentry *direntry, struct nameidata *nd);
 extern int cifs_readlink(struct dentry *direntry, char __user *buffer, int buflen);
 extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
                        const char *symname);
index 8d1c2cb..244d441 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/fs.h>
 #include <linux/stat.h>
+#include <linux/namei.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
 #include "cifsglob.h"
@@ -94,7 +95,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
        int rc = -EACCES;
        int xid;
        char *full_path = NULL;
-       char * target_path;
+       char * target_path = ERR_PTR(-ENOMEM);
        struct cifs_sb_info *cifs_sb;
        struct cifsTconInfo *pTcon;
 
@@ -104,22 +105,17 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
        full_path = build_path_from_dentry(direntry);
        up(&direntry->d_sb->s_vfs_rename_sem);
 
-       if(full_path == NULL) {
-               FreeXid(xid);
-               return -ENOMEM;
-       }
+       if (!full_path)
+               goto out;
+
        cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode));
        cifs_sb = CIFS_SB(inode->i_sb);
        pTcon = cifs_sb->tcon;
        target_path = kmalloc(PATH_MAX, GFP_KERNEL);
-       if(target_path == NULL) {
-               if (full_path)
-                       kfree(full_path);
-               FreeXid(xid);
-               return -ENOMEM;
+       if (!target_path) {
+               target_path = ERR_PTR(-ENOMEM);
+               goto out;
        }
-       /* can not call the following line due to EFAULT in vfs_readlink which is presumably expecting a user space buffer */
-       /* length = cifs_readlink(direntry,target_path, sizeof(target_path) - 1);    */
 
 /* BB add read reparse point symlink code and Unix extensions symlink code here BB */
        if (pTcon->ses->capabilities & CAP_UNIX)
@@ -139,16 +135,16 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
 /* BB Add special case check for Samba DFS symlinks */
 
                target_path[PATH_MAX-1] = 0;
-               rc = vfs_follow_link(nd, target_path);
+       } else {
+               kfree(target_path);
+               target_path = ERR_PTR(rc);
        }
-       /* else EACCESS */
 
-       if (target_path)
-               kfree(target_path);
-       if (full_path)
-               kfree(full_path);
+out:
+       kfree(full_path);
        FreeXid(xid);
-       return rc;
+       nd_set_link(nd, target_path);
+       return 0;
 }
 
 int
@@ -326,3 +322,10 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
        FreeXid(xid);
        return rc;
 }
+
+void cifs_put_link(struct dentry *direntry, struct nameidata *nd)
+{
+       char *p = nd_get_link(nd);
+       if (!IS_ERR(p))
+               kfree(p);
+}
index 425c2e5..e779a1c 100644 (file)
@@ -61,6 +61,9 @@ static unsigned int d_hash_shift;
 static struct hlist_head *dentry_hashtable;
 static LIST_HEAD(dentry_unused);
 
+static void prune_dcache(int count);
+
+
 /* Statistics gathering. */
 struct dentry_stat_t dentry_stat = {
        .age_limit = 45,
@@ -83,6 +86,10 @@ static void d_free(struct dentry *dentry)
 {
        if (dentry->d_op && dentry->d_op->d_release)
                dentry->d_op->d_release(dentry);
+       if (dentry->d_extra_attributes) {
+               kfree(dentry->d_extra_attributes);
+               dentry->d_extra_attributes = NULL;
+       }
        call_rcu(&dentry->d_rcu, d_callback);
 }
 
@@ -379,6 +386,8 @@ static void prune_dcache(int count)
                struct dentry *dentry;
                struct list_head *tmp;
 
+               cond_resched_lock(&dcache_lock);
+
                tmp = dentry_unused.prev;
                if (tmp == &dentry_unused)
                        break;
@@ -683,6 +692,19 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
        struct dentry *dentry;
        char *dname;
 
+#define DENTRY_UNUSED_THRESHOLD 30000
+#define DENTRY_BATCH_COUNT 32
+       if (dentry_stat.nr_unused > DENTRY_UNUSED_THRESHOLD) {
+               int doit = 1;
+               spin_lock(&dcache_lock);
+               if (dentry_stat.nr_unused < DENTRY_UNUSED_THRESHOLD)
+                       doit = 0;
+               spin_unlock(&dcache_lock);
+               if (doit)
+                       prune_dcache(DENTRY_BATCH_COUNT);
+       }
+
        dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL); 
        if (!dentry)
                return NULL;
@@ -711,6 +733,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
        dentry->d_sb = NULL;
        dentry->d_op = NULL;
        dentry->d_fsdata = NULL;
+       dentry->d_extra_attributes = NULL;
        dentry->d_mounted = 0;
        dentry->d_cookie = NULL;
        dentry->d_bucket = NULL;
@@ -1233,6 +1256,16 @@ already_unhashed:
        /* Unhash the target: dput() will then get rid of it */
        __d_drop(target);
 
+       /* flush any possible attributes */
+       if (dentry->d_extra_attributes) {
+               kfree(dentry->d_extra_attributes);
+               dentry->d_extra_attributes = NULL;
+       }
+       if (target->d_extra_attributes) {
+               kfree(target->d_extra_attributes);
+               target->d_extra_attributes = NULL;
+       }
+
        list_del(&dentry->d_child);
        list_del(&target->d_child);
 
@@ -1277,7 +1310,7 @@ already_unhashed:
  *
  * "buflen" should be positive. Caller holds the dcache_lock.
  */
-static char * __d_path( struct dentry *dentry, struct vfsmount *vfsmnt,
+char * __d_path( struct dentry *dentry, struct vfsmount *vfsmnt,
                        struct dentry *root, struct vfsmount *rootmnt,
                        char *buffer, int buflen)
 {
@@ -1345,6 +1378,8 @@ Elong:
        return ERR_PTR(-ENAMETOOLONG);
 }
 
+EXPORT_SYMBOL_GPL(__d_path);
+
 /* write full pathname into buffer and return start of pathname */
 char * d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
                                char *buf, int buflen)
@@ -1580,6 +1615,23 @@ static void __init dcache_init_early(void)
                INIT_HLIST_HEAD(&dentry_hashtable[loop]);
 }
 
+void flush_dentry_attributes (void)
+{
+       struct hlist_node *tmp;
+       struct dentry *dentry;
+       int i;
+
+       spin_lock(&dcache_lock);
+       for (i = 0; i <= d_hash_mask; i++)
+               hlist_for_each_entry(dentry, tmp, dentry_hashtable+i, d_hash) {
+                       kfree(dentry->d_extra_attributes);
+                       dentry->d_extra_attributes = NULL;
+               }
+       spin_unlock(&dcache_lock);
+}
+
+EXPORT_SYMBOL_GPL(flush_dentry_attributes);
+
 static void __init dcache_init(unsigned long mempages)
 {
        /* 
index 1d49ef4..a429f28 100644 (file)
 #include <linux/mount.h>
 #include <linux/tty.h>
 #include <linux/devpts_fs.h>
+#include <linux/vs_base.h>
 #include "xattr.h"
 
-#define DEVPTS_SUPER_MAGIC 0x1cd1
-
 static struct vfsmount *devpts_mnt;
 static struct dentry *devpts_root;
 
@@ -97,6 +96,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
        inode->i_op = &simple_dir_inode_operations;
        inode->i_fop = &simple_dir_operations;
        inode->i_nlink = 2;
+       inode->i_xid = vx_current_xid();
 
        devpts_root = s->s_root = d_alloc_root(inode);
        if (s->s_root)
@@ -134,11 +134,21 @@ static struct dentry *get_node(int num)
        return lookup_one_len(s, root, sprintf(s, "%d", num));
 }
 
+static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+       int ret = -EACCES;
+       
+       if (vx_check(inode->i_xid, VX_IDENT))
+               ret = vfs_permission(inode, mask);
+       return ret;
+}
+
 static struct inode_operations devpts_file_inode_operations = {
        .setxattr       = devpts_setxattr,
        .getxattr       = devpts_getxattr,
        .listxattr      = devpts_listxattr,
        .removexattr    = devpts_removexattr,
+       .permission     = devpts_permission,
 };
 
 int devpts_pty_new(struct tty_struct *tty)
@@ -162,6 +172,7 @@ int devpts_pty_new(struct tty_struct *tty)
        inode->i_gid = config.setgid ? config.gid : current->fsgid;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
        init_special_inode(inode, S_IFCHR|config.mode, device);
+       inode->i_xid = vx_current_xid();
        inode->i_op = &devpts_file_inode_operations;
        inode->u.generic_ip = tty;
 
index be4366c..90580ec 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -46,6 +46,9 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/rmap.h>
+#include <linux/ckrm.h>
+#include <linux/vs_memory.h>
+#include <linux/ckrm_mem.h>
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
@@ -319,7 +322,8 @@ void install_arg_page(struct vm_area_struct *vma,
                pte_unmap(pte);
                goto out;
        }
-       mm->rss++;
+       // mm->rss++;
+       vx_rsspages_inc(mm);
        lru_cache_add_active(page);
        set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(
                                        page, vma->vm_page_prot))));
@@ -388,8 +392,13 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
        /* zero pages that were copied above */
        while (i < MAX_ARG_PAGES)
                bprm->page[i++] = NULL;
+#else
+#ifdef __HAVE_ARCH_ALIGN_STACK
+       stack_base = arch_align_stack(STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE);
+       stack_base = PAGE_ALIGN(stack_base);
 #else
        stack_base = STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE;
+#endif
        mm->arg_start = bprm->p + stack_base;
        arg_size = STACK_TOP - (PAGE_MASK & (unsigned long) mm->arg_start);
 #endif
@@ -403,7 +412,8 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
        if (!mpnt)
                return -ENOMEM;
 
-       if (security_vm_enough_memory(arg_size >> PAGE_SHIFT)) {
+       if (security_vm_enough_memory(arg_size >> PAGE_SHIFT) ||
+               !vx_vmpages_avail(mm, arg_size >> PAGE_SHIFT)) {
                kmem_cache_free(vm_area_cachep, mpnt);
                return -ENOMEM;
        }
@@ -433,7 +443,9 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
                mpnt->vm_flags |= mm->def_flags;
                mpnt->vm_page_prot = protection_map[mpnt->vm_flags & 0x7];
                insert_vm_struct(mm, mpnt);
-               mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               // mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               vx_vmpages_sub(mm, mm->total_vm -
+                       ((mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT));
        }
 
        for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
@@ -546,6 +558,19 @@ static int exec_mmap(struct mm_struct *mm)
        tsk->active_mm = mm;
        activate_mm(active_mm, mm);
        task_unlock(tsk);
+       arch_pick_mmap_layout(mm);
+#ifdef CONFIG_CKRM_RES_MEM
+       if (old_mm) {
+               spin_lock(&old_mm->peertask_lock);
+               list_del(&tsk->mm_peers);
+               ckrm_mem_evaluate_mm(old_mm);
+               spin_unlock(&old_mm->peertask_lock);
+       }
+       spin_lock(&mm->peertask_lock);
+       list_add_tail(&tsk->mm_peers, &mm->tasklist);
+       ckrm_mem_evaluate_mm(mm);
+       spin_unlock(&mm->peertask_lock);
+#endif
        if (old_mm) {
                if (active_mm != old_mm) BUG();
                mmput(old_mm);
@@ -836,6 +861,7 @@ int flush_old_exec(struct linux_binprm * bprm)
        }
        current->comm[i] = '\0';
 
+       current->flags &= ~PF_RELOCEXEC;
        flush_thread();
 
        if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || 
@@ -1035,6 +1061,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
                                        fput(bprm->file);
                                bprm->file = NULL;
                                current->did_exec = 1;
+                               ckrm_cb_exec(bprm->filename);
                                return retval;
                        }
                        read_lock(&binfmt_lock);
index 89d1df9..74acc78 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
+#include <linux/namei.h> 
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
@@ -291,7 +292,8 @@ ext2_permission(struct inode *inode, int mask, struct nameidata *nd)
        int mode = inode->i_mode;
 
        /* Nobody gets write access to a read-only fs */
-       if ((mask & MAY_WRITE) && IS_RDONLY(inode) &&
+       if ((mask & MAY_WRITE) && (IS_RDONLY(inode) ||
+           (nd && MNT_IS_RDONLY(nd->mnt))) &&
            (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                return -EROFS;
        /* Nobody gets write access to an immutable file */
index f5a6b33..7b776af 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/quotaops.h>
 #include <linux/sched.h>
 #include <linux/buffer_head.h>
+#include <linux/vs_base.h>
+#include <linux/vs_dlimit.h>
 
 /*
  * balloc.c contains the blocks allocation and deallocation routines
@@ -108,6 +110,8 @@ static int reserve_blocks(struct super_block *sb, int count)
        free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
        root_blocks = le32_to_cpu(es->s_r_blocks_count);
 
+       DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks);
+
        if (free_blocks < count)
                count = free_blocks;
 
@@ -258,6 +262,7 @@ do_more:
        }
 error_return:
        brelse(bitmap_bh);
+       DLIMIT_FREE_BLOCK(sb, inode->i_xid, freed);
        release_blocks(sb, freed);
        DQUOT_FREE_BLOCK(inode, freed);
 }
@@ -361,6 +366,10 @@ int ext2_new_block(struct inode *inode, unsigned long goal,
                *err = -ENOSPC;
                goto out_dquot;
        }
+       if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, es_alloc)) {
+               *err = -ENOSPC;
+               goto out_dlimit;
+       }
 
        ext2_debug ("goal=%lu.\n", goal);
 
@@ -508,6 +517,8 @@ got_block:
        *err = 0;
 out_release:
        group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
+       DLIMIT_FREE_BLOCK(sb, inode->i_xid, es_alloc);
+out_dlimit:
        release_blocks(sb, es_alloc);
 out_dquot:
        DQUOT_FREE_BLOCK(inode, dq_alloc);
index e03b542..1b1dce4 100644 (file)
@@ -18,6 +18,9 @@
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 #include <linux/random.h>
+#include <linux/vs_base.h>
+#include <linux/vs_dlimit.h>
+
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
@@ -124,6 +127,7 @@ void ext2_free_inode (struct inode * inode)
        if (!is_bad_inode(inode)) {
                /* Quota is already initialized in iput() */
                ext2_xattr_delete_inode(inode);
+               DLIMIT_FREE_INODE(sb, inode->i_xid);
                DQUOT_FREE_INODE(inode);
                DQUOT_DROP(inode);
        }
@@ -465,6 +469,15 @@ struct inode *ext2_new_inode(struct inode *dir, int mode)
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
+        if (sb->s_flags & MS_TAGXID)
+               inode->i_xid = current->xid;
+       else
+               inode->i_xid = 0;
+
+       if (DLIMIT_ALLOC_INODE(sb, inode->i_xid)) {
+               err = -ENOSPC;
+               goto fail_dlim;
+       }
        ei = EXT2_I(inode);
        sbi = EXT2_SB(sb);
        es = sbi->s_es;
@@ -579,7 +592,8 @@ got:
        inode->i_blocks = 0;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
        memset(ei->i_data, 0, sizeof(ei->i_data));
-       ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
+       ei->i_flags = EXT2_I(dir)->i_flags &
+               ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
        if (S_ISLNK(mode))
                ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
        /* dirsync is only applied to directories */
@@ -620,12 +634,15 @@ got:
        return inode;
 
 fail2:
+       DLIMIT_FREE_INODE(sb, inode->i_xid);    
        inode->i_flags |= S_NOQUOTA;
        inode->i_nlink = 0;
        iput(inode);
        return ERR_PTR(err);
 
 fail:
+       DLIMIT_FREE_INODE(sb, inode->i_xid);    
+fail_dlim:
        make_bad_inode(inode);
        iput(inode);
        return ERR_PTR(err);
index 694e6ee..1ef02bc 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/writeback.h>
 #include <linux/buffer_head.h>
 #include <linux/mpage.h>
+#include <linux/vserver/xid.h>
 #include "ext2.h"
 #include "acl.h"
 
@@ -65,6 +66,8 @@ void ext2_put_inode(struct inode *inode)
                ext2_discard_prealloc(inode);
 }
 
+static void ext2_truncate_nocheck (struct inode * inode);
+
 /*
  * Called at the last iput() if i_nlink is zero.
  */
@@ -78,7 +81,7 @@ void ext2_delete_inode (struct inode * inode)
 
        inode->i_size = 0;
        if (inode->i_blocks)
-               ext2_truncate (inode);
+               ext2_truncate_nocheck(inode);
        ext2_free_inode (inode);
 
        return;
@@ -878,7 +881,7 @@ static void ext2_free_branches(struct inode *inode, u32 *p, u32 *q, int depth)
                ext2_free_data(inode, p, q);
 }
 
-void ext2_truncate (struct inode * inode)
+static void ext2_truncate_nocheck(struct inode * inode)
 {
        u32 *i_data = EXT2_I(inode)->i_data;
        int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb);
@@ -895,8 +898,6 @@ void ext2_truncate (struct inode * inode)
                return;
        if (ext2_inode_is_fast_symlink(inode))
                return;
-       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
-               return;
 
        ext2_discard_prealloc(inode);
 
@@ -1018,6 +1019,13 @@ Egdp:
        return ERR_PTR(-EIO);
 }
 
+void ext2_truncate (struct inode * inode)
+{
+       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
+               return;
+       ext2_truncate_nocheck(inode);
+}
+
 void ext2_set_inode_flags(struct inode *inode)
 {
        unsigned int flags = EXT2_I(inode)->i_flags;
@@ -1029,6 +1037,10 @@ void ext2_set_inode_flags(struct inode *inode)
                inode->i_flags |= S_APPEND;
        if (flags & EXT2_IMMUTABLE_FL)
                inode->i_flags |= S_IMMUTABLE;
+       if (flags & EXT2_IUNLINK_FL)
+               inode->i_flags |= S_IUNLINK;
+       if (flags & EXT2_BARRIER_FL)
+               inode->i_flags |= S_BARRIER;
        if (flags & EXT2_NOATIME_FL)
                inode->i_flags |= S_NOATIME;
        if (flags & EXT2_DIRSYNC_FL)
@@ -1041,6 +1053,8 @@ void ext2_read_inode (struct inode * inode)
        ino_t ino = inode->i_ino;
        struct buffer_head * bh;
        struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
+       uid_t uid;
+       gid_t gid;
        int n;
 
 #ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -1051,12 +1065,17 @@ void ext2_read_inode (struct inode * inode)
                goto bad_inode;
 
        inode->i_mode = le16_to_cpu(raw_inode->i_mode);
-       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
-       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
+       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
+       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
        if (!(test_opt (inode->i_sb, NO_UID32))) {
-               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
-               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
+               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
+               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
        }
+       inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
+       inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
+       inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid,
+               le16_to_cpu(raw_inode->i_raw_xid));
+
        inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
        inode->i_size = le32_to_cpu(raw_inode->i_size);
        inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime);
@@ -1149,8 +1168,8 @@ static int ext2_update_inode(struct inode * inode, int do_sync)
        struct ext2_inode_info *ei = EXT2_I(inode);
        struct super_block *sb = inode->i_sb;
        ino_t ino = inode->i_ino;
-       uid_t uid = inode->i_uid;
-       gid_t gid = inode->i_gid;
+       uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
+       gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
        struct buffer_head * bh;
        struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
        int n;
@@ -1185,6 +1204,9 @@ static int ext2_update_inode(struct inode * inode, int do_sync)
                raw_inode->i_uid_high = 0;
                raw_inode->i_gid_high = 0;
        }
+#ifdef CONFIG_INOXID_GID32
+       raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid);
+#endif
        raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
        raw_inode->i_size = cpu_to_le32(inode->i_size);
        raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
@@ -1262,6 +1284,27 @@ int ext2_sync_inode(struct inode *inode)
        return sync_inode(inode, &wbc);
 }
 
+int ext2_setattr_flags(struct inode *inode, unsigned int flags)
+{
+       unsigned int oldflags, newflags;
+
+       oldflags = EXT2_I(inode)->i_flags;
+       newflags = oldflags &
+               ~(EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL | EXT2_BARRIER_FL);       
+       if (flags & ATTR_FLAG_IMMUTABLE)
+               newflags |= EXT2_IMMUTABLE_FL;
+       if (flags & ATTR_FLAG_IUNLINK)
+               newflags |= EXT2_IUNLINK_FL;
+       if (flags & ATTR_FLAG_BARRIER)
+               newflags |= EXT2_BARRIER_FL;
+
+       if (oldflags ^ newflags) {
+               EXT2_I(inode)->i_flags = newflags;
+               inode->i_ctime = CURRENT_TIME;
+       }
+       return 0;
+}
+
 int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
 {
        struct inode *inode = dentry->d_inode;
@@ -1271,11 +1314,15 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
        if (error)
                return error;
        if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
-           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
+           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
+           (iattr->ia_valid & ATTR_XID && iattr->ia_xid != inode->i_xid)) {
                error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
                if (error)
                        return error;
        }
+       if (iattr->ia_valid & ATTR_ATTR_FLAG)
+               ext2_setattr_flags(inode, iattr->ia_attr_flags);
+
        error = inode_setattr(inode, iattr);
        if (!error && (iattr->ia_valid & ATTR_MODE))
                error = ext2_acl_chmod(inode);
index 945d22a..f6043a6 100644 (file)
@@ -29,7 +29,8 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
        case EXT2_IOC_SETFLAGS: {
                unsigned int oldflags;
 
-               if (IS_RDONLY(inode))
+               if (IS_RDONLY(inode) ||
+                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
                        return -EROFS;
 
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
@@ -49,7 +50,9 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                 *
                 * This test looks nicer. Thanks to Pauline Middelink
                 */
-               if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
+               if ((oldflags & EXT2_IMMUTABLE_FL) ||
+                       ((flags ^ oldflags) &
+                       (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL))) {
                        if (!capable(CAP_LINUX_IMMUTABLE))
                                return -EPERM;
                }
@@ -68,7 +71,8 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
        case EXT2_IOC_SETVERSION:
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
                        return -EPERM;
-               if (IS_RDONLY(inode))
+               if (IS_RDONLY(inode) ||
+                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
                        return -EROFS;
                if (get_user(inode->i_generation, (int __user *) arg))
                        return -EFAULT; 
index 3a06830..3e54fbe 100644 (file)
@@ -270,7 +270,7 @@ enum {
        Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
        Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
        Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, Opt_nobh,
-       Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
+       Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_tagxid,
        Opt_ignore, Opt_err,
 };
 
@@ -299,6 +299,7 @@ static match_table_t tokens = {
        {Opt_nouser_xattr, "nouser_xattr"},
        {Opt_acl, "acl"},
        {Opt_noacl, "noacl"},
+       {Opt_tagxid, "tagxid"},
        {Opt_ignore, "grpquota"},
        {Opt_ignore, "noquota"},
        {Opt_ignore, "quota"},
@@ -362,6 +363,11 @@ static int parse_options (char * options,
                case Opt_nouid32:
                        set_opt (sbi->s_mount_opt, NO_UID32);
                        break;
+#ifndef CONFIG_INOXID_NONE
+               case Opt_tagxid:
+                       set_opt (sbi->s_mount_opt, TAG_XID);
+                       break;
+#endif
                case Opt_check:
 #ifdef CONFIG_EXT2_CHECK
                        set_opt (sbi->s_mount_opt, CHECK);
@@ -646,6 +652,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
        if (!parse_options ((char *) data, sbi))
                goto failed_mount;
 
+       if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAG_XID)
+               sb->s_flags |= MS_TAGXID;
        sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
                ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
                 MS_POSIXACL : 0);
index 85ee4e8..ab8308a 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/mbcache.h>
 #include <linux/quotaops.h>
 #include <linux/rwsem.h>
+#include <linux/vs_dlimit.h>
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
@@ -749,8 +750,12 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
                                   the inode.  */
                                ea_bdebug(new_bh, "reusing block");
 
+                               error = -ENOSPC;
+                               if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
+                                       goto cleanup;
                                error = -EDQUOT;
                                if (DQUOT_ALLOC_BLOCK(inode, 1)) {
+                                       DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
                                        unlock_buffer(new_bh);
                                        goto cleanup;
                                }
@@ -830,6 +835,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
                        /* Decrement the refcount only. */
                        HDR(old_bh)->h_refcount = cpu_to_le32(
                                le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
+                       DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
                        DQUOT_FREE_BLOCK(inode, 1);
                        mark_buffer_dirty(old_bh);
                        ea_bdebug(old_bh, "refcount now=%d",
@@ -885,6 +891,7 @@ ext2_xattr_delete_inode(struct inode *inode)
                mark_buffer_dirty(bh);
                if (IS_SYNC(inode))
                        sync_dirty_buffer(bh);
+               DLIMIT_FREE_BLOCK(inode->i_sb, inode->i_xid, 1);
                DQUOT_FREE_BLOCK(inode, 1);
        }
        ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
index a3cf77d..cc26948 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
+#include <linux/namei.h> 
 #include <linux/ext3_jbd.h>
 #include <linux/ext3_fs.h>
 #include "xattr.h"
@@ -296,7 +297,8 @@ ext3_permission(struct inode *inode, int mask, struct nameidata *nd)
        int mode = inode->i_mode;
 
        /* Nobody gets write access to a read-only fs */
-       if ((mask & MAY_WRITE) && IS_RDONLY(inode) &&
+       if ((mask & MAY_WRITE) && (IS_RDONLY(inode) ||
+           (nd && nd->mnt && MNT_IS_RDONLY(nd->mnt))) &&
            (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                return -EROFS;
        /* Nobody gets write access to an immutable file */
index 4ebdcf4..3b3160d 100644 (file)
@@ -19,6 +19,8 @@
 #include <linux/ext3_jbd.h>
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
+#include <linux/vs_base.h>
+#include <linux/vs_dlimit.h>
 
 /*
  * balloc.c contains the blocks allocation and deallocation routines
@@ -275,8 +277,10 @@ do_more:
 error_return:
        brelse(bitmap_bh);
        ext3_std_error(sb, err);
-       if (dquot_freed_blocks)
+       if (dquot_freed_blocks) {
+               DLIMIT_FREE_BLOCK(sb, inode->i_xid, dquot_freed_blocks);
                DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
+       }
        return;
 }
 
@@ -465,18 +469,32 @@ fail:
        return -1;
 }
 
-static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
+static int ext3_has_free_blocks(struct super_block *sb)
 {
-       int free_blocks, root_blocks;
+       struct ext3_sb_info *sbi = EXT3_SB(sb);
+       int free_blocks, root_blocks, cond;
 
        free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
        root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
-       if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
+
+       vxdprintk(VXD_CBIT(dlim, 3),
+               "ext3_has_free_blocks(%p): free=%u, root=%u",
+               sb, free_blocks, root_blocks);
+
+       DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks);
+
+       cond = (free_blocks < root_blocks + 1 &&
+               !capable(CAP_SYS_RESOURCE) &&
                sbi->s_resuid != current->fsuid &&
-               (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
-               return 0;
-       }
-       return 1;
+               (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
+
+       vxdprintk(VXD_CBIT(dlim, 3),
+               "ext3_has_free_blocks(%p): %u<%u+1, %c, %u!=%u r=%d",
+               sb, free_blocks, root_blocks,
+               !capable(CAP_SYS_RESOURCE)?'1':'0',
+               sbi->s_resuid, current->fsuid, cond?0:1);
+
+       return (cond ? 0 : 1);
 }
 
 /*
@@ -487,7 +505,7 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
  */
 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
 {
-       if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
+       if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
                return 0;
 
        jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
@@ -537,12 +555,14 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal,
                *errp = -EDQUOT;
                return 0;
        }
+       if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
+               goto out_dlimit;
 
        sbi = EXT3_SB(sb);
        es = EXT3_SB(sb)->s_es;
        ext3_debug("goal=%lu.\n", goal);
 
-       if (!ext3_has_free_blocks(sbi)) {
+       if (!ext3_has_free_blocks(sb)) {
                *errp = -ENOSPC;
                goto out;
        }
@@ -697,6 +717,9 @@ allocated:
 io_error:
        *errp = -EIO;
 out:
+       if (!performed_allocation)
+               DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
+out_dlimit:
        if (fatal) {
                *errp = fatal;
                ext3_std_error(sb, fatal);
index ac238b2..f30a4f4 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
 #include <linux/random.h>
+#include <linux/vs_dlimit.h>
 
 #include <asm/bitops.h>
 #include <asm/byteorder.h>
@@ -124,6 +125,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
         */
        DQUOT_INIT(inode);
        ext3_xattr_delete_inode(handle, inode);
+       DLIMIT_FREE_INODE(sb, inode->i_xid);
        DQUOT_FREE_INODE(inode);
        DQUOT_DROP(inode);
 
@@ -444,6 +446,16 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
        inode = new_inode(sb);
        if (!inode)
                return ERR_PTR(-ENOMEM);
+
+       if (sb->s_flags & MS_TAGXID)
+               inode->i_xid = current->xid;
+       else
+               inode->i_xid = 0;
+
+       if (DLIMIT_ALLOC_INODE(sb, inode->i_xid)) {
+               err = -ENOSPC;
+               goto out;
+       }
        ei = EXT3_I(inode);
 
        sbi = EXT3_SB(sb);
@@ -567,7 +579,8 @@ got:
        ei->i_dir_start_lookup = 0;
        ei->i_disksize = 0;
 
-       ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
+       ei->i_flags = EXT3_I(dir)->i_flags &
+               ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
        if (S_ISLNK(mode))
                ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
        /* dirsync only applies to directories */
@@ -618,6 +631,7 @@ got:
        ext3_debug("allocating inode %lu\n", inode->i_ino);
        goto really_out;
 fail:
+       DLIMIT_FREE_INODE(sb, inode->i_xid);
        ext3_std_error(sb, err);
 out:
        iput(inode);
@@ -627,6 +641,7 @@ really_out:
        return ret;
 
 fail2:
+       DLIMIT_FREE_INODE(sb, inode->i_xid);
        inode->i_flags |= S_NOQUOTA;
        inode->i_nlink = 0;
        iput(inode);
index 909b7d9..962aef2 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/writeback.h>
 #include <linux/mpage.h>
 #include <linux/uio.h>
+#include <linux/vserver/xid.h>
 #include "xattr.h"
 #include "acl.h"
 
@@ -66,6 +67,8 @@ int ext3_forget(handle_t *handle, int is_metadata,
 {
        int err;
 
+       might_sleep();
+
        BUFFER_TRACE(bh, "enter");
 
        jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, "
@@ -176,6 +179,8 @@ static int ext3_journal_test_restart(handle_t *handle, struct inode *inode)
        return ext3_journal_restart(handle, blocks_for_truncate(inode));
 }
 
+static void ext3_truncate_nocheck (struct inode *inode);
+
 /*
  * Called at each iput()
  *
@@ -212,7 +217,7 @@ void ext3_delete_inode (struct inode * inode)
                handle->h_sync = 1;
        inode->i_size = 0;
        if (inode->i_blocks)
-               ext3_truncate(inode);
+               ext3_truncate_nocheck(inode);
        /*
         * Kill off the orphan record which ext3_truncate created.
         * AKPM: I think this can be inside the above `if'.
@@ -2131,7 +2136,7 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,
  * ext3_truncate() run will find them and release them.
  */
 
-void ext3_truncate(struct inode * inode)
+void ext3_truncate_nocheck(struct inode * inode)
 {
        handle_t *handle;
        struct ext3_inode_info *ei = EXT3_I(inode);
@@ -2152,8 +2157,6 @@ void ext3_truncate(struct inode * inode)
                return;
        if (ext3_inode_is_fast_symlink(inode))
                return;
-       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
-               return;
 
        ext3_discard_prealloc(inode);
 
@@ -2460,6 +2463,13 @@ has_buffer:
        return 0;
 }
 
+void ext3_truncate(struct inode * inode)
+{
+       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
+               return;
+       ext3_truncate_nocheck(inode);
+}
+
 void ext3_set_inode_flags(struct inode *inode)
 {
        unsigned int flags = EXT3_I(inode)->i_flags;
@@ -2471,6 +2481,10 @@ void ext3_set_inode_flags(struct inode *inode)
                inode->i_flags |= S_APPEND;
        if (flags & EXT3_IMMUTABLE_FL)
                inode->i_flags |= S_IMMUTABLE;
+       if (flags & EXT3_IUNLINK_FL)
+               inode->i_flags |= S_IUNLINK;
+       if (flags & EXT3_BARRIER_FL)
+               inode->i_flags |= S_BARRIER;
        if (flags & EXT3_NOATIME_FL)
                inode->i_flags |= S_NOATIME;
        if (flags & EXT3_DIRSYNC_FL)
@@ -2484,6 +2498,8 @@ void ext3_read_inode(struct inode * inode)
        struct ext3_inode_info *ei = EXT3_I(inode);
        struct buffer_head *bh;
        int block;
+       uid_t uid;
+       gid_t gid;
 
 #ifdef CONFIG_EXT3_FS_POSIX_ACL
        ei->i_acl = EXT3_ACL_NOT_CACHED;
@@ -2494,12 +2510,17 @@ void ext3_read_inode(struct inode * inode)
        bh = iloc.bh;
        raw_inode = ext3_raw_inode(&iloc);
        inode->i_mode = le16_to_cpu(raw_inode->i_mode);
-       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
-       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
+       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
+       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
        if(!(test_opt (inode->i_sb, NO_UID32))) {
-               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
-               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
+               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
+               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
        }
+       inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
+       inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
+       inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid,
+               le16_to_cpu(raw_inode->i_raw_xid));
+
        inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
        inode->i_size = le32_to_cpu(raw_inode->i_size);
        inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime);
@@ -2607,6 +2628,8 @@ static int ext3_do_update_inode(handle_t *handle,
        struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
        struct ext3_inode_info *ei = EXT3_I(inode);
        struct buffer_head *bh = iloc->bh;
+       uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
+       gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
        int err = 0, rc, block;
 
        /* For fields not not tracking in the in-memory inode,
@@ -2616,29 +2639,32 @@ static int ext3_do_update_inode(handle_t *handle,
 
        raw_inode->i_mode = cpu_to_le16(inode->i_mode);
        if(!(test_opt(inode->i_sb, NO_UID32))) {
-               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
-               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
+               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
+               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
 /*
  * Fix up interoperability with old kernels. Otherwise, old inodes get
  * re-used with the upper 16 bits of the uid/gid intact
  */
                if(!ei->i_dtime) {
                        raw_inode->i_uid_high =
-                               cpu_to_le16(high_16_bits(inode->i_uid));
+                               cpu_to_le16(high_16_bits(uid));
                        raw_inode->i_gid_high =
-                               cpu_to_le16(high_16_bits(inode->i_gid));
+                               cpu_to_le16(high_16_bits(gid));
                } else {
                        raw_inode->i_uid_high = 0;
                        raw_inode->i_gid_high = 0;
                }
        } else {
                raw_inode->i_uid_low =
-                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
+                       cpu_to_le16(fs_high2lowuid(uid));
                raw_inode->i_gid_low =
-                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
+                       cpu_to_le16(fs_high2lowgid(gid));
                raw_inode->i_uid_high = 0;
                raw_inode->i_gid_high = 0;
        }
+#ifdef CONFIG_INOXID_GID32
+       raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid);
+#endif
        raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
        raw_inode->i_size = cpu_to_le32(ei->i_disksize);
        raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
@@ -2760,6 +2786,44 @@ void ext3_write_inode(struct inode *inode, int wait)
        ext3_force_commit(inode->i_sb);
 }
 
+int ext3_setattr_flags(struct inode *inode, unsigned int flags)
+{
+       unsigned int oldflags, newflags;
+       int err = 0;
+
+       oldflags = EXT3_I(inode)->i_flags;
+       newflags = oldflags &
+               ~(EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL | EXT3_BARRIER_FL);       
+       if (flags & ATTR_FLAG_IMMUTABLE)
+               newflags |= EXT3_IMMUTABLE_FL;
+       if (flags & ATTR_FLAG_IUNLINK)
+               newflags |= EXT3_IUNLINK_FL;
+       if (flags & ATTR_FLAG_BARRIER)
+               newflags |= EXT3_BARRIER_FL;
+
+       if (oldflags ^ newflags) {
+               handle_t *handle;
+               struct ext3_iloc iloc;
+
+               handle = ext3_journal_start(inode, 1);
+               if (IS_ERR(handle))
+                       return PTR_ERR(handle);
+               if (IS_SYNC(inode))
+                       handle->h_sync = 1;
+               err = ext3_reserve_inode_write(handle, inode, &iloc);
+               if (err)
+                       goto flags_err;
+               
+               EXT3_I(inode)->i_flags = newflags;
+               inode->i_ctime = CURRENT_TIME;
+
+               err = ext3_mark_iloc_dirty(handle, inode, &iloc);
+       flags_err:
+               ext3_journal_stop(handle);
+       }
+       return err;
+}
+
 /*
  * ext3_setattr()
  *
@@ -2788,7 +2852,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
                return error;
 
        if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
-               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
+               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
+               (ia_valid & ATTR_XID && attr->ia_xid != inode->i_xid)) {
                handle_t *handle;
 
                /* (user+group)*(old+new) structure, inode write (sb,
@@ -2809,6 +2874,10 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
                        inode->i_uid = attr->ia_uid;
                if (attr->ia_valid & ATTR_GID)
                        inode->i_gid = attr->ia_gid;
+               if ((attr->ia_valid & ATTR_XID)
+                       && inode->i_sb
+                       && (inode->i_sb->s_flags & MS_TAGXID))
+                       inode->i_xid = attr->ia_xid;
                error = ext3_mark_inode_dirty(handle, inode);
                ext3_journal_stop(handle);
        }
@@ -2831,6 +2900,12 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
                ext3_journal_stop(handle);
        }
 
+       if (ia_valid & ATTR_ATTR_FLAG) {
+               rc = ext3_setattr_flags(inode, attr->ia_attr_flags);
+               if (!error)
+                       error = rc;
+       }
+
        rc = inode_setattr(inode, attr);
 
        /* If inode_setattr's call to ext3_truncate failed to get a
@@ -2966,6 +3041,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
        struct ext3_iloc iloc;
        int err;
 
+       might_sleep();
        err = ext3_reserve_inode_write(handle, inode, &iloc);
        if (!err)
                err = ext3_mark_iloc_dirty(handle, inode, &iloc);
index 0d50039..37bd450 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
 #include <linux/time.h>
+#include <linux/vserver/xid.h>
 #include <asm/uaccess.h>
 
 
@@ -34,7 +35,8 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                unsigned int oldflags;
                unsigned int jflag;
 
-               if (IS_RDONLY(inode))
+               if (IS_RDONLY(inode) ||
+                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
                        return -EROFS;
 
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
@@ -57,7 +59,9 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                 *
                 * This test looks nicer. Thanks to Pauline Middelink
                 */
-               if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
+               if ((oldflags & EXT3_IMMUTABLE_FL) ||
+                       ((flags ^ oldflags) &
+                       (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL))) {
                        if (!capable(CAP_LINUX_IMMUTABLE))
                                return -EPERM;
                }
@@ -110,7 +114,8 @@ flags_err:
 
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
                        return -EPERM;
-               if (IS_RDONLY(inode))
+               if (IS_RDONLY(inode) ||
+                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
                        return -EROFS;
                if (get_user(generation, (int __user *) arg))
                        return -EFAULT;
@@ -150,6 +155,38 @@ flags_err:
                        remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
                        return ret;
                }
+#endif
+#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_INOXID_NONE)
+       case EXT3_IOC_SETXID: {
+               handle_t *handle;
+               struct ext3_iloc iloc;
+               int xid;
+               int err;
+
+               /* fixme: if stealth, return -ENOTTY */
+               if (!capable(CAP_CONTEXT))
+                       return -EPERM;
+               if (IS_RDONLY(inode))
+                       return -EROFS;
+               if (!(inode->i_sb->s_flags & MS_TAGXID))
+                       return -ENOSYS;
+               if (get_user(xid, (int *) arg))
+                       return -EFAULT; 
+
+               handle = ext3_journal_start(inode, 1);
+               if (IS_ERR(handle))
+                       return PTR_ERR(handle);
+               err = ext3_reserve_inode_write(handle, inode, &iloc);
+               if (err)
+                       return err;
+
+               inode->i_xid = (xid & 0xFFFF);
+               inode->i_ctime = CURRENT_TIME;
+
+               err = ext3_mark_iloc_dirty(handle, inode, &iloc);
+               ext3_journal_stop(handle);
+               return err;
+       }
 #endif
        default:
                return -ENOTTY;
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
deleted file mode 100644 (file)
index d1fe21d..0000000
+++ /dev/null
@@ -1,956 +0,0 @@
-/*
- *  linux/fs/ext3/resize.c
- *
- * Support for resizing an ext3 filesystem while it is mounted.
- *
- * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com>
- *
- * This could probably be made into a module, because it is not often in use.
- */
-
-#include <linux/config.h>
-
-#define EXT3FS_DEBUG
-
-#include <linux/sched.h>
-#include <linux/smp_lock.h>
-#include <linux/ext3_jbd.h>
-
-#include <linux/errno.h>
-#include <linux/slab.h>
-
-
-#define outside(b, first, last)        ((b) < (first) || (b) >= (last))
-#define inside(b, first, last) ((b) >= (first) && (b) < (last))
-
-static int verify_group_input(struct super_block *sb,
-                             struct ext3_new_group_data *input)
-{
-       struct ext3_sb_info *sbi = EXT3_SB(sb);
-       struct ext3_super_block *es = sbi->s_es;
-       unsigned start = le32_to_cpu(es->s_blocks_count);
-       unsigned end = start + input->blocks_count;
-       unsigned group = input->group;
-       unsigned itend = input->inode_table + EXT3_SB(sb)->s_itb_per_group;
-       unsigned overhead = ext3_bg_has_super(sb, group) ?
-               (1 + ext3_bg_num_gdb(sb, group) +
-                le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
-       unsigned metaend = start + overhead;
-       struct buffer_head *bh;
-       int free_blocks_count;
-       int err = -EINVAL;
-
-       input->free_blocks_count = free_blocks_count =
-               input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
-
-       if (test_opt(sb, DEBUG))
-               printk("EXT3-fs: adding %s group %u: %u blocks "
-                      "(%d free, %u reserved)\n",
-                      ext3_bg_has_super(sb, input->group) ? "normal" :
-                      "no-super", input->group, input->blocks_count,
-                      free_blocks_count, input->reserved_blocks);
-
-       if (group != sbi->s_groups_count)
-               ext3_warning(sb, __FUNCTION__,
-                            "Cannot add at group %u (only %lu groups)",
-                            input->group, sbi->s_groups_count);
-       else if ((start - le32_to_cpu(es->s_first_data_block)) %
-                EXT3_BLOCKS_PER_GROUP(sb))
-               ext3_warning(sb, __FUNCTION__, "Last group not full");
-       else if (input->reserved_blocks > input->blocks_count / 5)
-               ext3_warning(sb, __FUNCTION__, "Reserved blocks too high (%u)",
-                            input->reserved_blocks);
-       else if (free_blocks_count < 0)
-               ext3_warning(sb, __FUNCTION__, "Bad blocks count %u",
-                            input->blocks_count);
-       else if (!(bh = sb_bread(sb, end - 1)))
-               ext3_warning(sb, __FUNCTION__, "Cannot read last block (%u)",
-                            end - 1);
-       else if (outside(input->block_bitmap, start, end))
-               ext3_warning(sb, __FUNCTION__,
-                            "Block bitmap not in group (block %u)",
-                            input->block_bitmap);
-       else if (outside(input->inode_bitmap, start, end))
-               ext3_warning(sb, __FUNCTION__,
-                            "Inode bitmap not in group (block %u)",
-                            input->inode_bitmap);
-       else if (outside(input->inode_table, start, end) ||
-                outside(itend - 1, start, end))
-               ext3_warning(sb, __FUNCTION__,
-                            "Inode table not in group (blocks %u-%u)",
-                            input->inode_table, itend - 1);
-       else if (input->inode_bitmap == input->block_bitmap)
-               ext3_warning(sb, __FUNCTION__,
-                            "Block bitmap same as inode bitmap (%u)",
-                            input->block_bitmap);
-       else if (inside(input->block_bitmap, input->inode_table, itend))
-               ext3_warning(sb, __FUNCTION__,
-                            "Block bitmap (%u) in inode table (%u-%u)",
-                            input->block_bitmap, input->inode_table, itend-1);
-       else if (inside(input->inode_bitmap, input->inode_table, itend))
-               ext3_warning(sb, __FUNCTION__,
-                            "Inode bitmap (%u) in inode table (%u-%u)",
-                            input->inode_bitmap, input->inode_table, itend-1);
-       else if (inside(input->block_bitmap, start, metaend))
-               ext3_warning(sb, __FUNCTION__,
-                            "Block bitmap (%u) in GDT table (%u-%u)",
-                            input->block_bitmap, start, metaend - 1);
-       else if (inside(input->inode_bitmap, start, metaend))
-               ext3_warning(sb, __FUNCTION__,
-                            "Inode bitmap (%u) in GDT table (%u-%u)",
-                            input->inode_bitmap, start, metaend - 1);
-       else if (inside(input->inode_table, start, metaend) ||
-                inside(itend - 1, start, metaend))
-               ext3_warning(sb, __FUNCTION__,
-                            "Inode table (%u-%u) overlaps GDT table (%u-%u)",
-                            input->inode_table, itend - 1, start, metaend - 1);
-       else {
-               brelse(bh);
-               err = 0;
-       }
-
-       return err;
-}
-
-static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
-                                 unsigned long blk)
-{
-       struct buffer_head *bh;
-       int err;
-
-       bh = sb_getblk(sb, blk);
-       set_buffer_uptodate(bh);
-       if ((err = ext3_journal_get_write_access(handle, bh))) {
-               brelse(bh);
-               bh = ERR_PTR(err);
-       } else
-               memset(bh->b_data, 0, sb->s_blocksize);
-
-       return bh;
-}
-
-/*
- * To avoid calling the atomic setbit hundreds or thousands of times, we only
- * need to use it within a single byte (to ensure we get endianness right).
- * We can use memset for the rest of the bitmap as there are no other users.
- */
-static void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
-{
-       int i;
-
-       if (start_bit >= end_bit)
-               return;
-
-       ext3_debug("mark end bits +%d through +%d used\n", start_bit, end_bit);
-       for (i = start_bit; i < ((start_bit + 7) & ~7UL); i++)
-               ext3_set_bit(i, bitmap);
-       if (i < end_bit)
-               memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
-}
-
-/*
- * Set up the block and inode bitmaps, and the inode table for the new group.
- * This doesn't need to be part of the main transaction, since we are only
- * changing blocks outside the actual filesystem.  We still do journaling to
- * ensure the recovery is correct in case of a failure just after resize.
- * If any part of this fails, we simply abort the resize.
- *
- * We only pass inode because of the ext3 journal wrappers.
- */
-static int setup_new_group_blocks(struct super_block *sb, struct inode *inode,
-                                 struct ext3_new_group_data *input)
-{
-       struct ext3_sb_info *sbi = EXT3_SB(sb);
-       unsigned long start = input->group * sbi->s_blocks_per_group +
-               le32_to_cpu(sbi->s_es->s_first_data_block);
-       int reserved_gdb = ext3_bg_has_super(sb, input->group) ?
-               le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0;
-       unsigned long gdblocks = ext3_bg_num_gdb(sb, input->group);
-       struct buffer_head *bh;
-       handle_t *handle;
-       unsigned long block;
-       int bit;
-       int i;
-       int err = 0, err2;
-
-       handle = ext3_journal_start(inode, reserved_gdb + gdblocks +
-                                   2 + sbi->s_itb_per_group);
-       if (IS_ERR(handle))
-               return PTR_ERR(handle);
-
-       lock_super(sb);
-       if (input->group != sbi->s_groups_count) {
-               err = -EBUSY;
-               goto exit_journal;
-       }
-
-       if (IS_ERR(bh = bclean(handle, sb, input->block_bitmap))) {
-               err = PTR_ERR(bh);
-               goto exit_journal;
-       }
-
-       if (ext3_bg_has_super(sb, input->group)) {
-               ext3_debug("mark backup superblock %#04lx (+0)\n", start);
-               ext3_set_bit(0, bh->b_data);
-       }
-
-       /* Copy all of the GDT blocks into the backup in this group */
-       for (i = 0, bit = 1, block = start + 1;
-            i < gdblocks; i++, block++, bit++) {
-               struct buffer_head *gdb;
-
-               ext3_debug("update backup group %#04lx (+%d)\n", block, bit);
-
-               gdb = sb_getblk(sb, block);
-               set_buffer_uptodate(gdb);
-               if ((err = ext3_journal_get_write_access(handle, gdb))) {
-                       brelse(gdb);
-                       goto exit_bh;
-               }
-               memcpy(gdb->b_data, sbi->s_group_desc[i], bh->b_size);
-               ext3_journal_dirty_metadata(handle, gdb);
-               ext3_set_bit(bit, bh->b_data);
-               brelse(gdb);
-       }
-
-       /* Zero out all of the reserved backup group descriptor table blocks */
-       for (i = 0, bit = gdblocks + 1, block = start + bit;
-            i < reserved_gdb; i++, block++, bit++) {
-               struct buffer_head *gdb;
-
-               ext3_debug("clear reserved block %#04lx (+%d)\n", block, bit);
-
-               if (IS_ERR(gdb = bclean(handle, sb, block))) {
-                       err = PTR_ERR(bh);
-                       goto exit_bh;
-               }
-               ext3_journal_dirty_metadata(handle, gdb);
-               ext3_set_bit(bit, bh->b_data);
-               brelse(gdb);
-       }
-       ext3_debug("mark block bitmap %#04x (+%ld)\n", input->block_bitmap,
-                  input->block_bitmap - start);
-       ext3_set_bit(input->block_bitmap - start, bh->b_data);
-       ext3_debug("mark inode bitmap %#04x (+%ld)\n", input->inode_bitmap,
-                  input->inode_bitmap - start);
-       ext3_set_bit(input->inode_bitmap - start, bh->b_data);
-
-       /* Zero out all of the inode table blocks */
-       for (i = 0, block = input->inode_table, bit = block - start;
-            i < sbi->s_itb_per_group; i++, bit++, block++) {
-               struct buffer_head *it;
-
-               ext3_debug("clear inode block %#04x (+%ld)\n", block, bit);
-               if (IS_ERR(it = bclean(handle, sb, block))) {
-                       err = PTR_ERR(it);
-                       goto exit_bh;
-               }
-               ext3_journal_dirty_metadata(handle, it);
-               brelse(it);
-               ext3_set_bit(bit, bh->b_data);
-       }
-       mark_bitmap_end(input->blocks_count, EXT3_BLOCKS_PER_GROUP(sb),
-                       bh->b_data);
-       ext3_journal_dirty_metadata(handle, bh);
-       brelse(bh);
-
-       /* Mark unused entries in inode bitmap used */
-       ext3_debug("clear inode bitmap %#04x (+%ld)\n",
-                  input->inode_bitmap, input->inode_bitmap - start);
-       if (IS_ERR(bh = bclean(handle, sb, input->inode_bitmap))) {
-               err = PTR_ERR(bh);
-               goto exit_journal;
-       }
-
-       mark_bitmap_end(EXT3_INODES_PER_GROUP(sb), EXT3_BLOCKS_PER_GROUP(sb),
-                       bh->b_data);
-       ext3_journal_dirty_metadata(handle, bh);
-exit_bh:
-       brelse(bh);
-
-exit_journal:
-       unlock_super(sb);
-       if ((err2 = ext3_journal_stop(handle)) && !err)
-               err = err2;
-
-       return err;
-}
-
-/*
- * Iterate through the groups which hold BACKUP superblock/GDT copies in an
- * ext3 filesystem.  The counters should be initialized to 1, 5, and 7 before
- * calling this for the first time.  In a sparse filesystem it will be the
- * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
- * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
- */
-unsigned ext3_list_backups(struct super_block *sb, unsigned *three,
-                          unsigned *five, unsigned *seven)
-{
-       unsigned *min = three;
-       int mult = 3;
-       unsigned ret;
-
-       if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
-                                       EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
-               ret = *min;
-               *min += 1;
-               return ret;
-       }
-
-       if (*five < *min) {
-               min = five;
-               mult = 5;
-       }
-       if (*seven < *min) {
-               min = seven;
-               mult = 7;
-       }
-
-       ret = *min;
-       *min *= mult;
-
-       return ret;
-}
-
-/*
- * Check that all of the backup GDT blocks are held in the primary GDT block.
- * It is assumed that they are stored in group order.  Returns the number of
- * groups in current filesystem that have BACKUPS, or -ve error code.
- */
-static int verify_reserved_gdb(struct super_block *sb,
-                              struct buffer_head *primary)
-{
-       const unsigned long blk = primary->b_blocknr;
-       const unsigned long end = EXT3_SB(sb)->s_groups_count;
-       unsigned three = 1;
-       unsigned five = 5;
-       unsigned seven = 7;
-       unsigned grp;
-       __u32 *p = (__u32 *)primary->b_data;
-       int gdbackups = 0;
-
-       while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
-               if (le32_to_cpu(*p++) != grp * EXT3_BLOCKS_PER_GROUP(sb) + blk){
-                       ext3_warning(sb, __FUNCTION__,
-                                    "reserved GDT %ld missing grp %d (%ld)\n",
-                                    blk, grp,
-                                    grp * EXT3_BLOCKS_PER_GROUP(sb) + blk);
-                       return -EINVAL;
-               }
-               if (++gdbackups > EXT3_ADDR_PER_BLOCK(sb))
-                       return -EFBIG;
-       }
-
-       return gdbackups;
-}
-
-/*
- * Called when we need to bring a reserved group descriptor table block into
- * use from the resize inode.  The primary copy of the new GDT block currently
- * is an indirect block (under the double indirect block in the resize inode).
- * The new backup GDT blocks will be stored as leaf blocks in this indirect
- * block, in group order.  Even though we know all the block numbers we need,
- * we check to ensure that the resize inode has actually reserved these blocks.
- *
- * Don't need to update the block bitmaps because the blocks are still in use.
- *
- * We get all of the error cases out of the way, so that we are sure to not
- * fail once we start modifying the data on disk, because JBD has no rollback.
- */
-static int add_new_gdb(handle_t *handle, struct inode *inode,
-                      struct ext3_new_group_data *input,
-                      struct buffer_head **primary)
-{
-       struct super_block *sb = inode->i_sb;
-       struct ext3_super_block *es = EXT3_SB(sb)->s_es;
-       unsigned long gdb_num = input->group / EXT3_DESC_PER_BLOCK(sb);
-       unsigned long gdb_off = input->group % EXT3_DESC_PER_BLOCK(sb);
-       unsigned long gdblock = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + gdb_num;
-       struct buffer_head **o_group_desc, **n_group_desc;
-       struct buffer_head *dind;
-       int gdbackups;
-       struct ext3_iloc iloc;
-       __u32 *data;
-       int err;
-
-       if (test_opt(sb, DEBUG))
-               printk("EXT3-fs: ext3_add_new_gdb: adding group block %lu\n",
-                      gdb_num);
-
-       /*
-        * If we are not using the primary superblock/GDT copy don't resize,
-        * because the user tools have no way of handling this.  Probably a
-        * bad time to do it anyways.
-        */
-       if (EXT3_SB(sb)->s_sbh->b_blocknr !=
-           le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) {
-               ext3_warning(sb, __FUNCTION__,
-                            "won't resize using backup superblock at %lu\n",
-                            EXT3_SB(sb)->s_sbh->b_blocknr);
-               return -EPERM;
-       }
-
-       *primary = sb_bread(sb, gdblock);
-       if (!*primary)
-               return -EIO;
-
-       if ((gdbackups = verify_reserved_gdb(sb, *primary)) < 0) {
-               err = gdbackups;
-               goto exit_bh;
-       }
-
-       data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
-       dind = sb_bread(sb, le32_to_cpu(*data));
-       if (!dind) {
-               err = -EIO;
-               goto exit_bh;
-       }
-
-       data = (__u32 *)dind->b_data;
-       if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
-               ext3_warning(sb, __FUNCTION__,
-                            "new group %u GDT block %lu not reserved\n",
-                            input->group, gdblock);
-               err = -EINVAL;
-               goto exit_dind;
-       }
-
-       if ((err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh)))
-               goto exit_dind;
-
-       if ((err = ext3_journal_get_write_access(handle, *primary)))
-               goto exit_sbh;
-
-       if ((err = ext3_journal_get_write_access(handle, dind)))
-               goto exit_primary;
-
-       /* ext3_reserve_inode_write() gets a reference on the iloc */
-       if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
-               goto exit_dindj;
-
-       n_group_desc = (struct buffer_head **)kmalloc((gdb_num + 1) *
-                               sizeof(struct buffer_head *), GFP_KERNEL);
-       if (!n_group_desc) {
-               err = -ENOMEM;
-               ext3_warning (sb, __FUNCTION__,
-                             "not enough memory for %lu groups", gdb_num + 1);
-               goto exit_inode;
-       }
-
-       /*
-        * Finally, we have all of the possible failures behind us...
-        *
-        * Remove new GDT block from inode double-indirect block and clear out
-        * the new GDT block for use (which also "frees" the backup GDT blocks
-        * from the reserved inode).  We don't need to change the bitmaps for
-        * these blocks, because they are marked as in-use from being in the
-        * reserved inode, and will become GDT blocks (primary and backup).
-        */
-       /*
-       printk("removing block %d = %ld from dindir %ld[%ld]\n",
-              ((__u32 *)(dind->b_data))[gdb_off], gdblock, dind->b_blocknr,
-              gdb_num); */
-       data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)] = 0;
-       ext3_journal_dirty_metadata(handle, dind);
-       brelse(dind);
-       inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
-       ext3_mark_iloc_dirty(handle, inode, &iloc);
-       memset((*primary)->b_data, 0, sb->s_blocksize);
-       ext3_journal_dirty_metadata(handle, *primary);
-
-       o_group_desc = EXT3_SB(sb)->s_group_desc;
-       memcpy(n_group_desc, o_group_desc,
-              EXT3_SB(sb)->s_gdb_count * sizeof(struct buffer_head *));
-       n_group_desc[gdb_num] = *primary;
-       EXT3_SB(sb)->s_group_desc = n_group_desc;
-       EXT3_SB(sb)->s_gdb_count++;
-       kfree(o_group_desc);
-
-       es->s_reserved_gdt_blocks =
-               cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1);
-       ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
-
-       return 0;
-
-exit_inode:
-       //ext3_journal_release_buffer(handle, iloc.bh);
-       brelse(iloc.bh);
-exit_dindj:
-       //ext3_journal_release_buffer(handle, dind);
-exit_primary:
-       //ext3_journal_release_buffer(handle, *primary);
-exit_sbh:
-       //ext3_journal_release_buffer(handle, *primary);
-exit_dind:
-       brelse(dind);
-exit_bh:
-       brelse(*primary);
-
-       ext3_debug("leaving with error %d\n", err);
-       return err;
-}
-
-/*
- * Called when we are adding a new group which has a backup copy of each of
- * the GDT blocks (i.e. sparse group) and there are reserved GDT blocks.
- * We need to add these reserved backup GDT blocks to the resize inode, so
- * that they are kept for future resizing and not allocated to files.
- *
- * Each reserved backup GDT block will go into a different indirect block.
- * The indirect blocks are actually the primary reserved GDT blocks,
- * so we know in advance what their block numbers are.  We only get the
- * double-indirect block to verify it is pointing to the primary reserved
- * GDT blocks so we don't overwrite a data block by accident.  The reserved
- * backup GDT blocks are stored in their reserved primary GDT block.
- */
-static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
-                             struct ext3_new_group_data *input)
-{
-       struct super_block *sb = inode->i_sb;
-       int reserved_gdb =le16_to_cpu(EXT3_SB(sb)->s_es->s_reserved_gdt_blocks);
-       struct buffer_head **primary;
-       struct buffer_head *dind;
-       struct ext3_iloc iloc;
-       unsigned long blk;
-       __u32 *data, *end;
-       int gdbackups = 0;
-       int res, i;
-       int err;
-
-       primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_KERNEL);
-       if (!primary)
-               return -ENOMEM;
-
-       data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
-       dind = sb_bread(sb, le32_to_cpu(*data));
-       if (!dind) {
-               err = -EIO;
-               goto exit_free;
-       }
-
-       blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count;
-       data = (__u32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
-       end = (__u32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);
-
-       /* Get each reserved primary GDT block and verify it holds backups */
-       for (res = 0; res < reserved_gdb; res++, blk++) {
-               if (le32_to_cpu(*data) != blk) {
-                       ext3_warning(sb, __FUNCTION__,
-                                    "reserved block %lu not at offset %ld\n",
-                                    blk, (long)(data - (__u32 *)dind->b_data));
-                       err = -EINVAL;
-                       goto exit_bh;
-               }
-               primary[res] = sb_bread(sb, blk);
-               if (!primary[res]) {
-                       err = -EIO;
-                       goto exit_bh;
-               }
-               if ((gdbackups = verify_reserved_gdb(sb, primary[res])) < 0) {
-                       brelse(primary[res]);
-                       err = gdbackups;
-                       goto exit_bh;
-               }
-               if (++data >= end)
-                       data = (__u32 *)dind->b_data;
-       }
-
-       for (i = 0; i < reserved_gdb; i++) {
-               if ((err = ext3_journal_get_write_access(handle, primary[i]))) {
-                       /*
-                       int j;
-                       for (j = 0; j < i; j++)
-                               ext3_journal_release_buffer(handle, primary[j]);
-                        */
-                       goto exit_bh;
-               }
-       }
-
-       if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
-               goto exit_bh;
-
-       /*
-        * Finally we can add each of the reserved backup GDT blocks from
-        * the new group to its reserved primary GDT block.
-        */
-       blk = input->group * EXT3_BLOCKS_PER_GROUP(sb);
-       for (i = 0; i < reserved_gdb; i++) {
-               int err2;
-               data = (__u32 *)primary[i]->b_data;
-               /* printk("reserving backup %lu[%u] = %lu\n",
-                      primary[i]->b_blocknr, gdbackups,
-                      blk + primary[i]->b_blocknr); */
-               data[gdbackups] = cpu_to_le32(blk + primary[i]->b_blocknr);
-               err2 = ext3_journal_dirty_metadata(handle, primary[i]);
-               if (!err)
-                       err = err2;
-       }
-       inode->i_blocks += reserved_gdb * sb->s_blocksize >> 9;
-       ext3_mark_iloc_dirty(handle, inode, &iloc);
-
-exit_bh:
-       while (--res >= 0)
-               brelse(primary[res]);
-       brelse(dind);
-
-exit_free:
-       kfree(primary);
-
-       return err;
-}
-
-/*
- * Update the backup copies of the ext3 metadata.  These don't need to be part
- * of the main resize transaction, because e2fsck will re-write them if there
- * is a problem (basically only OOM will cause a problem).  However, we
- * _should_ update the backups if possible, in case the primary gets trashed
- * for some reason and we need to run e2fsck from a backup superblock.  The
- * important part is that the new block and inode counts are in the backup
- * superblocks, and the location of the new group metadata in the GDT backups.
- *
- * We do not need lock_super() for this, because these blocks are not
- * otherwise touched by the filesystem code when it is mounted.  We don't
- * need to worry about last changing from sbi->s_groups_count, because the
- * worst that can happen is that we do not copy the full number of backups
- * at this time.  The resize which changed s_groups_count will backup again.
- *
- * We only pass inode because of the ext3 journal wrappers.
- */
-static void update_backups(struct super_block *sb, struct inode *inode,
-                          int blk_off, char *data, int size)
-{
-       struct ext3_sb_info *sbi = EXT3_SB(sb);
-       const unsigned long last = sbi->s_groups_count;
-       const int bpg = EXT3_BLOCKS_PER_GROUP(sb);
-       unsigned three = 1;
-       unsigned five = 5;
-       unsigned seven = 7;
-       unsigned group;
-       int rest = sb->s_blocksize - size;
-       handle_t *handle;
-       int err = 0, err2;
-
-       handle = ext3_journal_start(inode, EXT3_MAX_TRANS_DATA);
-       if (IS_ERR(handle)) {
-               group = 1;
-               err = PTR_ERR(handle);
-               goto exit_err;
-       }
-
-       while ((group = ext3_list_backups(sb, &three, &five, &seven)) < last) {
-               struct buffer_head *bh;
-
-               /* Out of journal space, and can't get more - abort - so sad */
-               if (handle->h_buffer_credits == 0 &&
-                   ext3_journal_extend(handle, EXT3_MAX_TRANS_DATA) &&
-                   (err = ext3_journal_restart(handle, EXT3_MAX_TRANS_DATA)))
-                       break;
-
-               bh = sb_getblk(sb, group * bpg + blk_off);
-               set_buffer_uptodate(bh);
-               ext3_debug(sb, __FUNCTION__, "update metadata backup %#04lx\n",
-                          bh->b_blocknr);
-               if ((err = ext3_journal_get_write_access(handle, bh)))
-                       break;
-               memcpy(bh->b_data, data, size);
-               if (rest)
-                       memset(bh->b_data + size, 0, rest);
-               ext3_journal_dirty_metadata(handle, bh);
-               brelse(bh);
-       }
-       if ((err2 = ext3_journal_stop(handle)) && !err)
-               err = err2;
-
-       /*
-        * Ugh! Need to have e2fsck write the backup copies.  It is too
-        * late to revert the resize, we shouldn't fail just because of
-        * the backup copies (they are only needed in case of corruption).
-        *
-        * However, if we got here we have a journal problem too, so we
-        * can't really start a transaction to mark the superblock.
-        * Chicken out and just set the flag on the hope it will be written
-        * to disk, and if not - we will simply wait until next fsck.
-        */
-exit_err:
-       if (err) {
-               ext3_warning(sb, __FUNCTION__,
-                            "can't update backup for group %d (err %d), "
-                            "forcing fsck on next reboot\n", group, err);
-               sbi->s_mount_state &= ~EXT3_VALID_FS;
-               sbi->s_es->s_state &= ~cpu_to_le16(EXT3_VALID_FS);
-               mark_buffer_dirty(sbi->s_sbh);
-       }
-}
-
-/* Add group descriptor data to an existing or new group descriptor block.
- * Ensure we handle all possible error conditions _before_ we start modifying
- * the filesystem, because we cannot abort the transaction and not have it
- * write the data to disk.
- *
- * If we are on a GDT block boundary, we need to get the reserved GDT block.
- * Otherwise, we may need to add backup GDT blocks for a sparse group.
- *
- * We only need to hold the superblock lock while we are actually adding
- * in the new group's counts to the superblock.  Prior to that we have
- * not really "added" the group at all.  We re-check that we are still
- * adding in the last group in case things have changed since verifying.
- */
-int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
-{
-       struct ext3_sb_info *sbi = EXT3_SB(sb);
-       struct ext3_super_block *es = sbi->s_es;
-       int reserved_gdb = ext3_bg_has_super(sb, input->group) ?
-               le16_to_cpu(es->s_reserved_gdt_blocks) : 0;
-       struct buffer_head *primary = NULL;
-       struct ext3_group_desc *gdp;
-       struct inode *inode = NULL;
-       struct inode bogus;
-       handle_t *handle;
-       int gdb_off, gdb_num;
-       int err, err2;
-
-       gdb_num = input->group / EXT3_DESC_PER_BLOCK(sb);
-       gdb_off = input->group % EXT3_DESC_PER_BLOCK(sb);
-
-       if (gdb_off == 0 && !EXT3_HAS_RO_COMPAT_FEATURE(sb,
-                                       EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
-               ext3_warning(sb, __FUNCTION__,
-                            "Can't resize non-sparse filesystem further\n");
-               return -EPERM;
-       }
-
-       if (reserved_gdb || gdb_off == 0) {
-               if (!EXT3_HAS_COMPAT_FEATURE(sb,
-                                            EXT3_FEATURE_COMPAT_RESIZE_INODE)){
-                       ext3_warning(sb, __FUNCTION__,
-                                    "No reserved GDT blocks, can't resize\n");
-                       return -EPERM;
-               }
-               inode = iget(sb, EXT3_RESIZE_INO);
-               if (!inode || is_bad_inode(inode)) {
-                       ext3_warning(sb, __FUNCTION__,
-                                    "Error opening resize inode\n");
-                       iput(inode);
-                       return -ENOENT;
-               }
-       } else {
-               /* Used only for ext3 journal wrapper functions to get sb */
-               inode = &bogus;
-               bogus.i_sb = sb;
-       }
-
-       if ((err = verify_group_input(sb, input)))
-               goto exit_put;
-
-       if ((err = setup_new_group_blocks(sb, inode, input)))
-               goto exit_put;
-
-       /*
-        * We will always be modifying at least the superblock and a GDT
-        * block.  If we are adding a group past the last current GDT block,
-        * we will also modify the inode and the dindirect block.  If we
-        * are adding a group with superblock/GDT backups  we will also
-        * modify each of the reserved GDT dindirect blocks.
-        */
-       handle = ext3_journal_start(inode, ext3_bg_has_super(sb, input->group) ?
-                                   3 + reserved_gdb : 4);
-       if (IS_ERR(handle)) {
-               err = PTR_ERR(handle);
-               goto exit_put;
-       }
-
-       lock_super(sb);
-       if (input->group != EXT3_SB(sb)->s_groups_count) {
-               ext3_warning(sb, __FUNCTION__,
-                            "multiple resizers run on filesystem!\n");
-               goto exit_journal;
-       }
-
-       if ((err = ext3_journal_get_write_access(handle, sbi->s_sbh)))
-               goto exit_journal;
-
-       /*
-        * We will only either add reserved group blocks to a backup group
-        * or remove reserved blocks for the first group in a new group block.
-        * Doing both would be mean more complex code, and sane people don't
-        * use non-sparse filesystems anymore.  This is already checked above.
-        */
-       if (gdb_off) {
-               primary = sbi->s_group_desc[gdb_num];
-               if ((err = ext3_journal_get_write_access(handle, primary)))
-                       goto exit_journal;
-
-               if (reserved_gdb && ext3_bg_num_gdb(sb, input->group) &&
-                   (err = reserve_backup_gdb(handle, inode, input)))
-                       goto exit_journal;
-       } else if ((err = add_new_gdb(handle, inode, input, &primary)))
-               goto exit_journal;
-
-       /* Finally update group descriptor block for new group */
-       gdp = (struct ext3_group_desc *)primary->b_data + gdb_off;
-
-       gdp->bg_block_bitmap = cpu_to_le32(input->block_bitmap);
-       gdp->bg_inode_bitmap = cpu_to_le32(input->inode_bitmap);
-       gdp->bg_inode_table = cpu_to_le32(input->inode_table);
-       gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
-       gdp->bg_free_inodes_count = cpu_to_le16(EXT3_INODES_PER_GROUP(sb));
-
-       EXT3_SB(sb)->s_groups_count++;
-       ext3_journal_dirty_metadata(handle, primary);
-
-       /* Update superblock with new block counts */
-       es->s_blocks_count = cpu_to_le32(le32_to_cpu(es->s_blocks_count) +
-               input->blocks_count);
-       es->s_free_blocks_count =
-               cpu_to_le32(le32_to_cpu(es->s_free_blocks_count) +
-                           input->free_blocks_count);
-       es->s_r_blocks_count = cpu_to_le32(le32_to_cpu(es->s_r_blocks_count) +
-               input->reserved_blocks);
-       es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
-               EXT3_INODES_PER_GROUP(sb));
-       es->s_free_inodes_count =
-               cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) +
-                           EXT3_INODES_PER_GROUP(sb));
-       ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
-       sb->s_dirt = 1;
-
-exit_journal:
-       unlock_super(sb);
-       handle->h_sync = 1;
-       if ((err2 = ext3_journal_stop(handle)) && !err)
-               err = err2;
-       if (!err) {
-               update_backups(sb, inode, sbi->s_sbh->b_blocknr, (char *)es,
-                              sizeof(struct ext3_super_block));
-               update_backups(sb, inode, primary->b_blocknr, primary->b_data,
-                              primary->b_size);
-       }
-exit_put:
-       if (inode != &bogus)
-               iput(inode);
-       return err;
-} /* ext3_group_add */
-
-/* Extend the filesystem to the new number of blocks specified.  This entry
- * point is only used to extend the current filesystem to the end of the last
- * existing group.  It can be accessed via ioctl, or by "remount,resize=<size>"
- * for emergencies (because it has no dependencies on reserved blocks).
- *
- * If we _really_ wanted, we could use default values to call ext3_group_add()
- * allow the "remount" trick to work for arbitrary resizing, assuming enough
- * GDT blocks are reserved to grow to the desired size.
- */
-int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
-                     unsigned long n_blocks_count)
-{
-       unsigned long o_blocks_count;
-       unsigned long o_groups_count;
-       unsigned long last;
-       int add;
-       struct inode *inode;
-       struct buffer_head * bh;
-       handle_t *handle;
-       int err;
-
-       o_blocks_count = le32_to_cpu(es->s_blocks_count);
-       o_groups_count = EXT3_SB(sb)->s_groups_count;
-
-       if (test_opt(sb, DEBUG))
-               printk("EXT3-fs: extending last group from %lu to %lu blocks\n",
-                      o_blocks_count, n_blocks_count);
-
-       if (n_blocks_count == 0 || n_blocks_count == o_blocks_count)
-               return 0;
-
-       if (n_blocks_count < o_blocks_count) {
-               ext3_warning(sb, __FUNCTION__,
-                            "can't shrink FS - resize aborted");
-               return -EBUSY;
-       }
-
-       /* Handle the remaining blocks in the last group only. */
-       last = (o_blocks_count - le32_to_cpu(es->s_first_data_block)) %
-               EXT3_BLOCKS_PER_GROUP(sb);
-
-       if (last == 0) {
-               ext3_warning(sb, __FUNCTION__,
-                            "need to use ext2online to resize further\n");
-               return -EPERM;
-       }
-
-       add = EXT3_BLOCKS_PER_GROUP(sb) - last;
-
-       if (o_blocks_count + add > n_blocks_count)
-               add = n_blocks_count - o_blocks_count;
-
-       if (o_blocks_count + add < n_blocks_count)
-               ext3_warning(sb, __FUNCTION__,
-                            "will only finish group (%lu blocks, %u new)",
-                            o_blocks_count + add, add);
-
-       /* See if the device is actually as big as what was requested */
-       bh = sb_bread(sb, o_blocks_count + add -1);
-       if (!bh) {
-               ext3_warning(sb, __FUNCTION__,
-                            "can't read last block, resize aborted");
-               return -ENOSPC;
-       }
-       brelse(bh);
-
-       /* Get a bogus inode to "free" the new blocks in this group. */
-       if (!(inode = new_inode(sb))) {
-               ext3_warning(sb, __FUNCTION__,
-                            "error getting dummy resize inode");
-               return -ENOMEM;
-       }
-       inode->i_ino = 0;
-
-       EXT3_I(inode)->i_state = EXT3_STATE_RESIZE;
-
-       /* We will update the superblock, one block bitmap, and
-        * one group descriptor via ext3_free_blocks().
-        */
-       handle = ext3_journal_start(inode, 3);
-       if (IS_ERR(handle)) {
-               err = PTR_ERR(handle);
-               ext3_warning(sb, __FUNCTION__, "error %d on journal start",err);
-               goto exit_put;
-       }
-
-       lock_super(sb);
-       if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) {
-               ext3_warning(sb, __FUNCTION__,
-                            "multiple resizers run on filesystem!\n");
-               err = -EBUSY;
-               goto exit_put;
-       }
-
-       if ((err = ext3_journal_get_write_access(handle,
-                                                EXT3_SB(sb)->s_sbh))) {
-               ext3_warning(sb, __FUNCTION__,
-                            "error %d on journal write access", err);
-               unlock_super(sb);
-               ext3_journal_stop(handle);
-               goto exit_put;
-       }
-       es->s_blocks_count = cpu_to_le32(o_blocks_count + add);
-       ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
-       sb->s_dirt = 1;
-       unlock_super(sb);
-       ext3_debug("freeing blocks %ld through %ld\n", o_blocks_count,
-                  o_blocks_count + add);
-       ext3_free_blocks(handle, inode, o_blocks_count, add);
-       ext3_debug("freed blocks %ld through %ld\n", o_blocks_count,
-                  o_blocks_count + add);
-       if ((err = ext3_journal_stop(handle)))
-               goto exit_put;
-       if (test_opt(sb, DEBUG))
-               printk("EXT3-fs: extended group to %u blocks\n",
-                      le32_to_cpu(es->s_blocks_count));
-       update_backups(sb, inode, EXT3_SB(sb)->s_sbh->b_blocknr, (char *)es,
-                      sizeof(struct ext3_super_block));
-exit_put:
-       iput(inode);
-
-       return err;
-} /* ext3_group_extend */
index b50e468..61943d3 100644 (file)
@@ -587,7 +587,7 @@ enum {
        Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
        Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
        Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0,
-       Opt_ignore, Opt_err,
+       Opt_tagxid, Opt_ignore, Opt_err
 };
 
 static match_table_t tokens = {
@@ -628,6 +628,7 @@ static match_table_t tokens = {
        {Opt_grpjquota, "grpjquota=%s"},
        {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
        {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
+       {Opt_tagxid, "tagxid"},
        {Opt_ignore, "grpquota"},
        {Opt_ignore, "noquota"},
        {Opt_ignore, "quota"},
@@ -721,6 +722,16 @@ static int parse_options (char * options, struct super_block *sb,
                case Opt_nouid32:
                        set_opt (sbi->s_mount_opt, NO_UID32);
                        break;
+#ifndef CONFIG_INOXID_NONE
+               case Opt_tagxid:
+                       if (is_remount) {
+                               printk(KERN_ERR "EXT3-fs: cannot specify "
+                                      "tagxid on remount\n");
+                               return 0;
+                       }
+                       set_opt (sbi->s_mount_opt, TAG_XID);
+                       break;
+#endif
                case Opt_check:
 #ifdef CONFIG_EXT3_CHECK
                        set_opt (sbi->s_mount_opt, CHECK);
@@ -1291,6 +1302,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
        if (!parse_options ((char *) data, sb, &journal_inum, 0))
                goto failed_mount;
 
+       if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAG_XID)
+               sb->s_flags |= MS_TAGXID;
        sb->s_flags |= MS_ONE_SECOND;
        sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
                ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
index 163db30..b6c382c 100644 (file)
@@ -59,6 +59,7 @@
 #include <linux/mbcache.h>
 #include <linux/quotaops.h>
 #include <linux/rwsem.h>
+#include <linux/vs_dlimit.h>
 #include "xattr.h"
 #include "acl.h"
 
@@ -761,8 +762,12 @@ ext3_xattr_set_handle2(handle_t *handle, struct inode *inode,
                                   the inode. */
                                ea_bdebug(new_bh, "reusing block");
 
+                               error = -ENOSPC;
+                               if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
+                                       goto cleanup;
                                error = -EDQUOT;
                                if (DQUOT_ALLOC_BLOCK(inode, 1)) {
+                                       DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
                                        unlock_buffer(new_bh);
                                        journal_release_buffer(handle, new_bh,
                                                               credits);
@@ -848,6 +853,7 @@ getblk_failed:
                        /* Decrement the refcount only. */
                        HDR(old_bh)->h_refcount = cpu_to_le32(
                                le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
+                       DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
                        DQUOT_FREE_BLOCK(inode, 1);
                        ext3_journal_dirty_metadata(handle, old_bh);
                        ea_bdebug(old_bh, "refcount now=%d",
@@ -939,6 +945,7 @@ ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
                ext3_journal_dirty_metadata(handle, bh);
                if (IS_SYNC(inode))
                        handle->h_sync = 1;
+               DLIMIT_FREE_BLOCK(inode->i_sb, inode->i_xid, 1);
                DQUOT_FREE_BLOCK(inode, 1);
        }
        ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
index 305abb4..a7966c9 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/security.h>
 #include <linux/ptrace.h>
+#include <linux/vs_limit.h>
 
 #include <asm/poll.h>
 #include <asm/siginfo.h>
@@ -107,6 +108,8 @@ repeat:
        error = -EMFILE;
        if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
                goto out;
+       if (!vx_files_avail(1))
+               goto out;
 
        error = expand_files(files, newfd);
        if (error < 0)
@@ -128,7 +131,7 @@ out:
        return error;
 }
 
-static int dupfd(struct file *file, unsigned int start)
+int dupfd(struct file *file, unsigned int start)
 {
        struct files_struct * files = current->files;
        int fd;
@@ -139,6 +142,7 @@ static int dupfd(struct file *file, unsigned int start)
                FD_SET(fd, files->open_fds);
                FD_CLR(fd, files->close_on_exec);
                spin_unlock(&files->file_lock);
+               // vx_openfd_inc(fd);
                fd_install(fd, file);
        } else {
                spin_unlock(&files->file_lock);
@@ -148,6 +152,8 @@ static int dupfd(struct file *file, unsigned int start)
        return fd;
 }
 
+EXPORT_SYMBOL_GPL(dupfd);
+
 asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
 {
        int err = -EBADF;
@@ -186,6 +192,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
        FD_SET(newfd, files->open_fds);
        FD_CLR(newfd, files->close_on_exec);
        spin_unlock(&files->file_lock);
+       // vx_openfd_inc(newfd);
 
        if (tofree)
                filp_close(tofree, files);
index 6e97427..8996d4d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/eventpoll.h>
 #include <linux/mount.h>
 #include <linux/cdev.h>
+#include <linux/vs_limit.h>
 
 /* sysctl tunables... */
 struct files_stat_struct files_stat = {
@@ -87,6 +88,7 @@ static int old_max;
                        f->f_owner.lock = RW_LOCK_UNLOCKED;
                        /* f->f_version: 0 */
                        INIT_LIST_HEAD(&f->f_list);
+                       vx_files_inc(f);
                        return f;
                }
        }
@@ -184,6 +186,7 @@ void fastcall __fput(struct file *file)
        fops_put(file->f_op);
        if (file->f_mode & FMODE_WRITE)
                put_write_access(inode);
+       vx_files_dec(file);
        file_kill(file);
        file->f_dentry = NULL;
        file->f_vfsmnt = NULL;
index 430afc3..1369676 100644 (file)
@@ -360,6 +360,7 @@ sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc)
                        list_move(&inode->i_list, &sb->s_dirty);
                }
                spin_unlock(&inode_lock);
+               cond_resched();
                iput(inode);
                spin_lock(&inode_lock);
                if (wbc->nr_to_write <= 0)
@@ -392,6 +393,7 @@ writeback_inodes(struct writeback_control *wbc)
 {
        struct super_block *sb;
 
+       might_sleep();
        spin_lock(&inode_lock);
        spin_lock(&sb_lock);
 restart:
@@ -547,6 +549,7 @@ void write_inode_now(struct inode *inode, int sync)
        if (inode->i_mapping->backing_dev_info->memory_backed)
                return;
 
+       might_sleep();
        spin_lock(&inode_lock);
        __writeback_single_inode(inode, &wbc);
        spin_unlock(&inode_lock);
index bd05477..cf0118e 100644 (file)
@@ -33,7 +33,8 @@ int hfsplus_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
                        flags |= EXT2_FLAG_NODUMP; /* EXT2_NODUMP_FL */
                return put_user(flags, (int __user *)arg);
        case HFSPLUS_IOC_EXT2_SETFLAGS: {
-               if (IS_RDONLY(inode))
+               if (IS_RDONLY(inode) ||
+                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
                        return -EROFS;
 
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
diff --git a/fs/hostfs/Makefile b/fs/hostfs/Makefile
deleted file mode 100644 (file)
index 794292e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# 
-# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
-# Licensed under the GPL
-#
-
-# struct stat64 changed the inode field name between 2.2 and 2.4 from st_ino
-# to __st_ino.  It stayed in the same place, so as long as the correct name
-# is used, hostfs compiled on 2.2 should work on 2.4 and vice versa.
-
-STAT64_INO_FIELD := $(shell grep -q __st_ino /usr/include/bits/stat.h && \
-                               echo __)st_ino
-
-hostfs-objs := hostfs_kern.o hostfs_user.o
-
-obj-y = 
-obj-$(CONFIG_HOSTFS) += hostfs.o
-
-SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs))
-
-USER_OBJS := $(filter %_user.o,$(obj-y) $(obj-m) $(SINGLE_OBJS))
-USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
-
-USER_CFLAGS += -DSTAT64_INO_FIELD=$(STAT64_INO_FIELD)
-
-$(USER_OBJS) : %.o: %.c
-       $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h
deleted file mode 100644 (file)
index d1f6c33..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef __UM_FS_HOSTFS
-#define __UM_FS_HOSTFS
-
-#include "os.h"
-
-/* These are exactly the same definitions as in fs.h, but the names are 
- * changed so that this file can be included in both kernel and user files.
- */
-
-#define HOSTFS_ATTR_MODE       1
-#define HOSTFS_ATTR_UID        2
-#define HOSTFS_ATTR_GID        4
-#define HOSTFS_ATTR_SIZE       8
-#define HOSTFS_ATTR_ATIME      16
-#define HOSTFS_ATTR_MTIME      32
-#define HOSTFS_ATTR_CTIME      64
-#define HOSTFS_ATTR_ATIME_SET  128
-#define HOSTFS_ATTR_MTIME_SET  256
-#define HOSTFS_ATTR_FORCE      512     /* Not a change, but a change it */
-#define HOSTFS_ATTR_ATTR_FLAG  1024
-
-struct hostfs_iattr {
-       unsigned int    ia_valid;
-       mode_t          ia_mode;
-       uid_t           ia_uid;
-       gid_t           ia_gid;
-       loff_t          ia_size;
-       struct timespec ia_atime;
-       struct timespec ia_mtime;
-       struct timespec ia_ctime;
-       unsigned int    ia_attr_flags;
-};
-
-extern int stat_file(const char *path, unsigned long long *inode_out, 
-                    int *mode_out, int *nlink_out, int *uid_out, int *gid_out,
-                    unsigned long long *size_out, struct timespec *atime_out, 
-                    struct timespec *mtime_out, struct timespec *ctime_out, 
-                    int *blksize_out, unsigned long long *blocks_out);
-extern int access_file(char *path, int r, int w, int x);
-extern int open_file(char *path, int r, int w, int append);
-extern int file_type(const char *path, int *rdev);
-extern void *open_dir(char *path, int *err_out);
-extern char *read_dir(void *stream, unsigned long long *pos, 
-                     unsigned long long *ino_out, int *len_out);
-extern void close_file(void *stream);
-extern void close_dir(void *stream);
-extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
-extern int write_file(int fd, unsigned long long *offset, const char *buf,
-                     int len);
-extern int lseek_file(int fd, long long offset, int whence);
-extern int file_create(char *name, int ur, int uw, int ux, int gr, 
-                      int gw, int gx, int or, int ow, int ox);
-extern int set_attr(const char *file, struct hostfs_iattr *attrs);
-extern int make_symlink(const char *from, const char *to);
-extern int unlink_file(const char *file);
-extern int do_mkdir(const char *file, int mode);
-extern int do_rmdir(const char *file);
-extern int do_mknod(const char *file, int mode, int dev);
-extern int link_file(const char *from, const char *to);
-extern int do_readlink(char *file, char *buf, int size);
-extern int rename_file(char *from, char *to);
-extern int do_statfs(char *root, long *bsize_out, long long *blocks_out, 
-                    long long *bfree_out, long long *bavail_out, 
-                    long long *files_out, long long *ffree_out, 
-                    void *fsid_out, int fsid_size, long *namelen_out, 
-                    long *spare_out);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
deleted file mode 100644 (file)
index ef5d5d1..0000000
+++ /dev/null
@@ -1,1008 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- *
- * Ported the filesystem routines to 2.5.
- * 2003-02-10 Petr Baudis <pasky@ucw.cz>
- */
-
-#include <linux/stddef.h>
-#include <linux/fs.h>
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
-#include <linux/blkdev.h>
-#include <linux/list.h>
-#include <linux/buffer_head.h>
-#include <linux/root_dev.h>
-#include <linux/statfs.h>
-#include <asm/uaccess.h>
-#include "hostfs.h"
-#include "kern_util.h"
-#include "kern.h"
-#include "user_util.h"
-#include "2_5compat.h"
-#include "init.h"
-
-struct hostfs_inode_info {
-       char *host_filename;
-       int fd;
-       int mode;
-       struct inode vfs_inode;
-};
-
-static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
-{
-       return(list_entry(inode, struct hostfs_inode_info, vfs_inode));
-}
-
-#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_dentry->d_inode)
-
-int hostfs_d_delete(struct dentry *dentry)
-{
-       return(1);
-}
-
-struct dentry_operations hostfs_dentry_ops = {
-       .d_delete               = hostfs_d_delete,
-};
-
-/* Changed in hostfs_args before the kernel starts running */
-static char *root_ino = "/";
-static int append = 0;
-
-#define HOSTFS_SUPER_MAGIC 0x00c0ffee
-
-static struct inode_operations hostfs_iops;
-static struct inode_operations hostfs_dir_iops;
-static struct address_space_operations hostfs_link_aops;
-
-static int __init hostfs_args(char *options, int *add)
-{
-       char *ptr;
-
-       ptr = strchr(options, ',');
-       if(ptr != NULL)
-               *ptr++ = '\0';
-       if(*options != '\0')
-               root_ino = options;
-
-       options = ptr;
-       while(options){
-               ptr = strchr(options, ',');
-               if(ptr != NULL)
-                       *ptr++ = '\0';
-               if(*options != '\0'){
-                       if(!strcmp(options, "append"))
-                               append = 1;
-                       else printf("hostfs_args - unsupported option - %s\n",
-                                   options);
-               }
-               options = ptr;
-       }
-       return(0);
-}
-
-__uml_setup("hostfs=", hostfs_args,
-"hostfs=<root dir>,<flags>,...\n"
-"    This is used to set hostfs parameters.  The root directory argument\n"
-"    is used to confine all hostfs mounts to within the specified directory\n"
-"    tree on the host.  If this isn't specified, then a user inside UML can\n"
-"    mount anything on the host that's accessible to the user that's running\n"
-"    it.\n"
-"    The only flag currently supported is 'append', which specifies that all\n"
-"    files opened by hostfs will be opened in append mode.\n\n"
-);
-
-static char *dentry_name(struct dentry *dentry, int extra)
-{
-       struct dentry *parent;
-       char *root, *name;
-       int len;
-
-       len = 0;
-       parent = dentry;
-       while(parent->d_parent != parent){
-               len += parent->d_name.len + 1;
-               parent = parent->d_parent;
-       }
-       
-       root = HOSTFS_I(parent->d_inode)->host_filename;
-       len += strlen(root);
-       name = kmalloc(len + extra + 1, GFP_KERNEL);
-       if(name == NULL) return(NULL);
-
-       name[len] = '\0';
-       parent = dentry;
-       while(parent->d_parent != parent){
-               len -= parent->d_name.len + 1;
-               name[len] = '/';
-               strncpy(&name[len + 1], parent->d_name.name, 
-                       parent->d_name.len);
-               parent = parent->d_parent;
-       }
-       strncpy(name, root, strlen(root));
-       return(name);
-}
-
-static char *inode_name(struct inode *ino, int extra)
-{
-       struct dentry *dentry;
-
-       dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias);
-       return(dentry_name(dentry, extra));
-}
-
-static int read_name(struct inode *ino, char *name)
-{
-       /* The non-int inode fields are copied into ints by stat_file and
-        * then copied into the inode because passing the actual pointers
-        * in and having them treated as int * breaks on big-endian machines
-        */
-       int err;
-       int i_mode, i_nlink, i_blksize;
-       unsigned long long i_size;
-       unsigned long long i_ino;
-       unsigned long long i_blocks;
-
-       err = stat_file(name, &i_ino, &i_mode, &i_nlink, &ino->i_uid, 
-                       &ino->i_gid, &i_size, &ino->i_atime, &ino->i_mtime, 
-                       &ino->i_ctime, &i_blksize, &i_blocks);
-       if(err) 
-               return(err);
-
-       ino->i_ino = i_ino;
-       ino->i_mode = i_mode;
-       ino->i_nlink = i_nlink;
-       ino->i_size = i_size;
-       ino->i_blksize = i_blksize;
-       ino->i_blocks = i_blocks;
-       if((ino->i_sb->s_dev == ROOT_DEV) && (ino->i_uid == getuid()))
-               ino->i_uid = 0;
-       return(0);
-}
-
-static char *follow_link(char *link)
-{
-       int len, n;
-       char *name, *resolved, *end;
-
-       len = 64;
-       while(1){
-               n = -ENOMEM;
-               name = kmalloc(len, GFP_KERNEL);
-               if(name == NULL)
-                       goto out;
-
-               n = do_readlink(link, name, len);
-               if(n < len)
-                       break;
-               len *= 2;
-               kfree(name);
-       }
-       if(n < 0)
-               goto out_free;
-
-       if(*name == '/')
-               return(name);
-
-       end = strrchr(link, '/');
-       if(end == NULL)
-               return(name);
-
-       *(end + 1) = '\0';
-       len = strlen(link) + strlen(name) + 1;
-
-       resolved = kmalloc(len, GFP_KERNEL);
-       if(resolved == NULL){
-               n = -ENOMEM;
-               goto out_free;
-       }
-
-       sprintf(resolved, "%s%s", link, name);
-       kfree(name);
-       kfree(link);
-       return(resolved);
-
- out_free:
-       kfree(name);
- out:
-       return(ERR_PTR(n));
-}
-
-static int read_inode(struct inode *ino)
-{
-       char *name;
-       int err = 0;
-
-       /* Unfortunately, we are called from iget() when we don't have a dentry
-        * allocated yet.
-        */
-       if(list_empty(&ino->i_dentry))
-               goto out;
-       err = -ENOMEM;
-       name = inode_name(ino, 0);
-       if(name == NULL) 
-               goto out;
-
-       if(file_type(name, NULL) == OS_TYPE_SYMLINK){
-               name = follow_link(name);
-               if(IS_ERR(name)){
-                       err = PTR_ERR(name);
-                       goto out;
-               }
-       }
-       
-       err = read_name(ino, name);
-       kfree(name);
- out:
-       return(err);
-}
-
-int hostfs_statfs(struct super_block *sb, struct kstatfs *sf)
-{
-       /* do_statfs uses struct statfs64 internally, but the linux kernel
-        * struct statfs still has 32-bit versions for most of these fields,
-        * so we convert them here
-        */
-       int err;
-       long long f_blocks;
-       long long f_bfree;
-       long long f_bavail;
-       long long f_files;
-       long long f_ffree;
-
-       err = do_statfs(HOSTFS_I(sb->s_root->d_inode)->host_filename,
-                       &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files,
-                       &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid), 
-                       &sf->f_namelen, sf->f_spare);
-       if(err) return(err);
-       sf->f_blocks = f_blocks;
-       sf->f_bfree = f_bfree;
-       sf->f_bavail = f_bavail;
-       sf->f_files = f_files;
-       sf->f_ffree = f_ffree;
-       sf->f_type = HOSTFS_SUPER_MAGIC;
-       return(0);
-}
-
-static struct inode *hostfs_alloc_inode(struct super_block *sb)
-{
-       struct hostfs_inode_info *hi;
-
-       hi = kmalloc(sizeof(*hi), GFP_KERNEL);
-       if(hi == NULL) 
-               return(NULL);
-
-       *hi = ((struct hostfs_inode_info) { .host_filename      = NULL,
-                                           .fd                 = -1,
-                                           .mode               = 0 });
-       inode_init_once(&hi->vfs_inode);
-       return(&hi->vfs_inode);
-}
-
-static void hostfs_destroy_inode(struct inode *inode)
-{
-       if(HOSTFS_I(inode)->host_filename) 
-               kfree(HOSTFS_I(inode)->host_filename);
-
-       if(HOSTFS_I(inode)->fd != -1) 
-               close_file(&HOSTFS_I(inode)->fd);
-
-       kfree(HOSTFS_I(inode));
-}
-
-static void hostfs_read_inode(struct inode *inode)
-{
-       read_inode(inode);
-}
-
-static struct super_operations hostfs_sbops = { 
-       .alloc_inode    = hostfs_alloc_inode,
-       .destroy_inode  = hostfs_destroy_inode,
-       .read_inode     = hostfs_read_inode,
-       .statfs         = hostfs_statfs,
-};
-
-int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
-{
-       void *dir;
-       char *name;
-       unsigned long long next, ino;
-       int error, len;
-
-       name = dentry_name(file->f_dentry, 0);
-       if(name == NULL) return(-ENOMEM);
-       dir = open_dir(name, &error);
-       kfree(name);
-       if(dir == NULL) return(-error);
-       next = file->f_pos;
-       while((name = read_dir(dir, &next, &ino, &len)) != NULL){
-               error = (*filldir)(ent, name, len, file->f_pos, 
-                                  ino, DT_UNKNOWN);
-               if(error) break;
-               file->f_pos = next;
-       }
-       close_dir(dir);
-       return(0);
-}
-
-int hostfs_file_open(struct inode *ino, struct file *file)
-{
-       char *name;
-       int mode = 0, r = 0, w = 0, fd;
-
-       mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
-       if((mode & HOSTFS_I(ino)->mode) == mode)
-               return(0);
-
-       /* The file may already have been opened, but with the wrong access,
-        * so this resets things and reopens the file with the new access.
-        */
-       if(HOSTFS_I(ino)->fd != -1){
-               close_file(&HOSTFS_I(ino)->fd);
-               HOSTFS_I(ino)->fd = -1;
-       }
-
-       HOSTFS_I(ino)->mode |= mode;
-       if(HOSTFS_I(ino)->mode & FMODE_READ) 
-               r = 1;
-       if(HOSTFS_I(ino)->mode & FMODE_WRITE) 
-               w = 1;
-       if(w) 
-               r = 1;
-
-       name = dentry_name(file->f_dentry, 0);
-       if(name == NULL) 
-               return(-ENOMEM);
-
-       fd = open_file(name, r, w, append);
-       kfree(name);
-       if(fd < 0) return(fd);
-       FILE_HOSTFS_I(file)->fd = fd;
-
-       return(0);
-}
-
-int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync)
-{
-       return(0);
-}
-
-static struct file_operations hostfs_file_fops = {
-       .llseek         = generic_file_llseek,
-       .read           = generic_file_read,
-       .write          = generic_file_write,
-       .mmap           = generic_file_mmap,
-       .open           = hostfs_file_open,
-       .release        = NULL,
-       .fsync          = hostfs_fsync,
-};
-
-static struct file_operations hostfs_dir_fops = {
-       .readdir        = hostfs_readdir,
-       .read           = generic_read_dir,
-};
-
-int hostfs_writepage(struct page *page, struct writeback_control *wbc)
-{
-       struct address_space *mapping = page->mapping;
-       struct inode *inode = mapping->host;
-       char *buffer;
-       unsigned long long base;
-       int count = PAGE_CACHE_SIZE;
-       int end_index = inode->i_size >> PAGE_CACHE_SHIFT;
-       int err;
-
-       if (page->index >= end_index)
-               count = inode->i_size & (PAGE_CACHE_SIZE-1);
-
-       buffer = kmap(page);
-       base = ((unsigned long long) page->index) << PAGE_CACHE_SHIFT;
-
-       err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
-       if(err != count){
-               ClearPageUptodate(page);
-               goto out;
-       }
-
-       if (base > inode->i_size)
-               inode->i_size = base;
-
-       if (PageError(page))
-               ClearPageError(page);   
-       err = 0;
-
- out:  
-       kunmap(page);
-
-       unlock_page(page);
-       return err; 
-}
-
-int hostfs_readpage(struct file *file, struct page *page)
-{
-       char *buffer;
-       long long start;
-       int err = 0;
-
-       start = (long long) page->index << PAGE_CACHE_SHIFT;
-       buffer = kmap(page);
-       err = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
-                       PAGE_CACHE_SIZE);
-       if(err < 0) goto out;
-
-       memset(&buffer[err], 0, PAGE_CACHE_SIZE - err);
-
-       flush_dcache_page(page);
-       SetPageUptodate(page);
-       if (PageError(page)) ClearPageError(page);
-       err = 0;
- out:
-       kunmap(page);
-       unlock_page(page);
-       return(err);
-}
-
-int hostfs_prepare_write(struct file *file, struct page *page, 
-                        unsigned int from, unsigned int to)
-{
-       char *buffer;
-       long long start, tmp;
-       int err;
-
-       start = (long long) page->index << PAGE_CACHE_SHIFT;
-       buffer = kmap(page);
-       if(from != 0){
-               tmp = start;
-               err = read_file(FILE_HOSTFS_I(file)->fd, &tmp, buffer,
-                               from);
-               if(err < 0) goto out;
-       }
-       if(to != PAGE_CACHE_SIZE){
-               start += to;
-               err = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer + to,
-                               PAGE_CACHE_SIZE - to);
-               if(err < 0) goto out;           
-       }
-       err = 0;
- out:
-       kunmap(page);
-       return(err);
-}
-
-int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
-                unsigned to)
-{
-       struct address_space *mapping = page->mapping;
-       struct inode *inode = mapping->host;
-       char *buffer;
-       long long start;
-       int err = 0;
-
-       start = (long long) (page->index << PAGE_CACHE_SHIFT) + from;
-       buffer = kmap(page);
-       err = write_file(FILE_HOSTFS_I(file)->fd, &start, buffer + from, 
-                        to - from);
-       if(err > 0) err = 0;
-       if(!err && (start > inode->i_size))
-               inode->i_size = start;
-
-       kunmap(page);
-       return(err);
-}
-
-static struct address_space_operations hostfs_aops = {
-       .writepage      = hostfs_writepage,
-       .readpage       = hostfs_readpage,
-/*     .set_page_dirty = __set_page_dirty_nobuffers, */
-       .prepare_write  = hostfs_prepare_write,
-       .commit_write   = hostfs_commit_write
-};
-
-static int init_inode(struct inode *inode, struct dentry *dentry)
-{
-       char *name;
-       int type, err = -ENOMEM, rdev;
-
-       if(dentry){
-               name = dentry_name(dentry, 0);
-               if(name == NULL)
-                       goto out;
-               type = file_type(name, &rdev);
-               kfree(name);
-       }
-       else type = OS_TYPE_DIR;
-
-       err = 0;
-       if(type == OS_TYPE_SYMLINK)
-               inode->i_op = &page_symlink_inode_operations;
-       else if(type == OS_TYPE_DIR)
-               inode->i_op = &hostfs_dir_iops;
-       else inode->i_op = &hostfs_iops;
-
-       if(type == OS_TYPE_DIR) inode->i_fop = &hostfs_dir_fops;
-       else inode->i_fop = &hostfs_file_fops;
-
-       if(type == OS_TYPE_SYMLINK) 
-               inode->i_mapping->a_ops = &hostfs_link_aops;
-       else inode->i_mapping->a_ops = &hostfs_aops;
-
-       switch (type) {
-       case OS_TYPE_CHARDEV:
-               init_special_inode(inode, S_IFCHR, rdev);
-               break;
-       case OS_TYPE_BLOCKDEV:
-               init_special_inode(inode, S_IFBLK, rdev);
-               break;
-       case OS_TYPE_FIFO:
-               init_special_inode(inode, S_IFIFO, 0);
-               break;
-       case OS_TYPE_SOCK:
-               init_special_inode(inode, S_IFSOCK, 0);
-               break;
-       }
- out:
-       return(err);
-}
-
-int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, 
-                 struct nameidata *nd)
-{
-       struct inode *inode;
-       char *name;
-       int error, fd;
-
-       error = -ENOMEM;
-       inode = iget(dir->i_sb, 0);
-       if(inode == NULL) goto out;
-
-       error = init_inode(inode, dentry);
-       if(error) 
-               goto out_put;
-       
-       error = -ENOMEM;
-       name = dentry_name(dentry, 0);
-       if(name == NULL)
-               goto out_put;
-
-       fd = file_create(name, 
-                        mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR, 
-                        mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP, 
-                        mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
-       if(fd < 0) 
-               error = fd;
-       else error = read_name(inode, name);
-
-       kfree(name);
-       if(error)
-               goto out_put;
-
-       HOSTFS_I(inode)->fd = fd;
-       HOSTFS_I(inode)->mode = FMODE_READ | FMODE_WRITE;
-       d_instantiate(dentry, inode);
-       return(0);
-
- out_put:
-       iput(inode);
- out:
-       return(error);
-}
-
-struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, 
-                            struct nameidata *nd)
-{
-       struct inode *inode;
-       char *name;
-       int err;
-
-       err = -ENOMEM;
-       inode = iget(ino->i_sb, 0);
-       if(inode == NULL) 
-               goto out;
-       err = init_inode(inode, dentry);
-       if(err) 
-               goto out_put;
-
-       err = -ENOMEM;
-       name = dentry_name(dentry, 0);
-       if(name == NULL)
-               goto out_put;
-
-       err = read_name(inode, name);
-       kfree(name);
-       if(err == -ENOENT){
-               iput(inode);
-               inode = NULL;
-       }
-       else if(err)
-               goto out_put;
-
-       d_add(dentry, inode);
-       dentry->d_op = &hostfs_dentry_ops;
-       return(NULL);
-
- out_put:
-       iput(inode);
- out:
-       return(ERR_PTR(err));
-}
-
-static char *inode_dentry_name(struct inode *ino, struct dentry *dentry)
-{
-        char *file;
-       int len;
-
-       file = inode_name(ino, dentry->d_name.len + 1);
-       if(file == NULL) return(NULL);
-        strcat(file, "/");
-       len = strlen(file);
-        strncat(file, dentry->d_name.name, dentry->d_name.len);
-       file[len + dentry->d_name.len] = '\0';
-        return(file);
-}
-
-int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from)
-{
-        char *from_name, *to_name;
-        int err;
-
-        if((from_name = inode_dentry_name(ino, from)) == NULL) 
-                return(-ENOMEM);
-        to_name = dentry_name(to, 0);
-       if(to_name == NULL){
-               kfree(from_name);
-               return(-ENOMEM);
-       }
-        err = link_file(to_name, from_name);
-        kfree(from_name);
-        kfree(to_name);
-        return(err);
-}
-
-int hostfs_unlink(struct inode *ino, struct dentry *dentry)
-{
-       char *file;
-       int err;
-
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
-       if(append)
-               return(-EPERM);
-
-       err = unlink_file(file);
-       kfree(file);
-       return(err);
-}
-
-int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
-{
-       char *file;
-       int err;
-
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
-       err = make_symlink(file, to);
-       kfree(file);
-       return(err);
-}
-
-int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
-{
-       char *file;
-       int err;
-
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
-       err = do_mkdir(file, mode);
-       kfree(file);
-       return(err);
-}
-
-int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
-{
-       char *file;
-       int err;
-
-       if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
-       err = do_rmdir(file);
-       kfree(file);
-       return(err);
-}
-
-int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
-{
-       struct inode *inode;
-       char *name;
-       int err = -ENOMEM;
-       inode = iget(dir->i_sb, 0);
-       if(inode == NULL) 
-               goto out;
-
-       err = init_inode(inode, dentry);
-       if(err) 
-               goto out_put;
-
-       err = -ENOMEM;
-       name = dentry_name(dentry, 0);
-       if(name == NULL)
-               goto out_put;
-
-       init_special_inode(inode, mode, dev);
-       err = do_mknod(name, mode, dev);
-       if(err)
-               goto out_free;
-
-       err = read_name(inode, name);
-       kfree(name);
-       if(err)
-               goto out_put;
-
-       d_instantiate(dentry, inode);
-       return(0);
-
- out_free:
-       kfree(name);
- out_put:
-       iput(inode);
- out:
-       return(err);
-}
-
-int hostfs_rename(struct inode *from_ino, struct dentry *from,
-                 struct inode *to_ino, struct dentry *to)
-{
-       char *from_name, *to_name;
-       int err;
-
-       if((from_name = inode_dentry_name(from_ino, from)) == NULL)
-               return(-ENOMEM);
-       if((to_name = inode_dentry_name(to_ino, to)) == NULL){
-               kfree(from_name);
-               return(-ENOMEM);
-       }
-       err = rename_file(from_name, to_name);
-       kfree(from_name);
-       kfree(to_name);
-       return(err);
-}
-
-void hostfs_truncate(struct inode *ino)
-{
-       not_implemented();
-}
-
-int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
-{
-       char *name;
-       int r = 0, w = 0, x = 0, err;
-
-       if(desired & MAY_READ) r = 1;
-       if(desired & MAY_WRITE) w = 1;
-       if(desired & MAY_EXEC) x = 1;
-       name = inode_name(ino, 0);
-       if(name == NULL) return(-ENOMEM);
-       err = access_file(name, r, w, x);
-       kfree(name);
-       if(!err) err = vfs_permission(ino, desired);
-       return(err);
-}
-
-int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
-{
-       struct hostfs_iattr attrs;
-       char *name;
-       int err;
-       
-       if(append) 
-               attr->ia_valid &= ~ATTR_SIZE;
-
-       attrs.ia_valid = 0;
-       if(attr->ia_valid & ATTR_MODE){
-               attrs.ia_valid |= HOSTFS_ATTR_MODE;
-               attrs.ia_mode = attr->ia_mode;
-       }
-       if(attr->ia_valid & ATTR_UID){
-               if((dentry->d_inode->i_sb->s_dev == ROOT_DEV) && 
-                  (attr->ia_uid == 0))
-                       attr->ia_uid = getuid();
-               attrs.ia_valid |= HOSTFS_ATTR_UID;
-               attrs.ia_uid = attr->ia_uid;
-       }
-       if(attr->ia_valid & ATTR_GID){
-               if((dentry->d_inode->i_sb->s_dev == ROOT_DEV) && 
-                  (attr->ia_gid == 0))
-                       attr->ia_gid = getuid();
-               attrs.ia_valid |= HOSTFS_ATTR_GID;
-               attrs.ia_gid = attr->ia_gid;
-       }
-       if(attr->ia_valid & ATTR_SIZE){
-               attrs.ia_valid |= HOSTFS_ATTR_SIZE;
-               attrs.ia_size = attr->ia_size;
-       }
-       if(attr->ia_valid & ATTR_ATIME){
-               attrs.ia_valid |= HOSTFS_ATTR_ATIME;
-               attrs.ia_atime = attr->ia_atime;
-       }
-       if(attr->ia_valid & ATTR_MTIME){
-               attrs.ia_valid |= HOSTFS_ATTR_MTIME;
-               attrs.ia_mtime = attr->ia_mtime;
-       }
-       if(attr->ia_valid & ATTR_CTIME){
-               attrs.ia_valid |= HOSTFS_ATTR_CTIME;
-               attrs.ia_ctime = attr->ia_ctime;
-       }
-       if(attr->ia_valid & ATTR_ATIME_SET){
-               attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
-       }
-       if(attr->ia_valid & ATTR_MTIME_SET){
-               attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
-       }
-       name = dentry_name(dentry, 0);
-       if(name == NULL) return(-ENOMEM);
-       err = set_attr(name, &attrs);
-       kfree(name);
-       if(err)
-               return(err);
-
-       return(inode_setattr(dentry->d_inode, attr));
-}
-
-int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry, 
-          struct kstat *stat)
-{
-       generic_fillattr(dentry->d_inode, stat);
-       return(0);
-}
-
-static struct inode_operations hostfs_iops = {
-       .create         = hostfs_create,
-       .link           = hostfs_link,
-       .unlink         = hostfs_unlink,
-       .symlink        = hostfs_symlink,
-       .mkdir          = hostfs_mkdir,
-       .rmdir          = hostfs_rmdir,
-       .mknod          = hostfs_mknod,
-       .rename         = hostfs_rename,
-       .truncate       = hostfs_truncate,
-       .permission     = hostfs_permission,
-       .setattr        = hostfs_setattr,
-       .getattr        = hostfs_getattr,
-};
-
-static struct inode_operations hostfs_dir_iops = {
-       .create         = hostfs_create,
-       .lookup         = hostfs_lookup,
-       .link           = hostfs_link,
-       .unlink         = hostfs_unlink,
-       .symlink        = hostfs_symlink,
-       .mkdir          = hostfs_mkdir,
-       .rmdir          = hostfs_rmdir,
-       .mknod          = hostfs_mknod,
-       .rename         = hostfs_rename,
-       .truncate       = hostfs_truncate,
-       .permission     = hostfs_permission,
-       .setattr        = hostfs_setattr,
-       .getattr        = hostfs_getattr,
-};
-
-int hostfs_link_readpage(struct file *file, struct page *page)
-{
-       char *buffer, *name;
-       long long start;
-       int err;
-
-       start = page->index << PAGE_CACHE_SHIFT;
-       buffer = kmap(page);
-       name = inode_name(page->mapping->host, 0);
-       if(name == NULL) return(-ENOMEM);
-       err = do_readlink(name, buffer, PAGE_CACHE_SIZE);
-       kfree(name);
-       if(err == PAGE_CACHE_SIZE)
-               err = -E2BIG;
-       else if(err > 0){
-               flush_dcache_page(page);
-               SetPageUptodate(page);
-               if (PageError(page)) ClearPageError(page);
-               err = 0;
-       }
-       kunmap(page);
-       unlock_page(page);
-       return(err);
-}
-
-static struct address_space_operations hostfs_link_aops = {
-       .readpage       = hostfs_link_readpage,
-};
-
-static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
-{
-       struct inode *root_inode;
-       char *name, *data = d;
-       int err;
-
-       sb->s_blocksize = 1024;
-       sb->s_blocksize_bits = 10;
-       sb->s_magic = HOSTFS_SUPER_MAGIC;
-       sb->s_op = &hostfs_sbops;
-
-       if((data == NULL) || (*data == '\0')) 
-               data = root_ino;
-
-       err = -ENOMEM;
-       name = kmalloc(strlen(data) + 1, GFP_KERNEL);
-       if(name == NULL) 
-               goto out;
-
-       strcpy(name, data);
-
-       root_inode = iget(sb, 0);
-       if(root_inode == NULL)
-               goto out_free;
-
-       err = init_inode(root_inode, NULL);
-       if(err)
-               goto out_put;
-
-       HOSTFS_I(root_inode)->host_filename = name;
-
-       err = -ENOMEM;
-       sb->s_root = d_alloc_root(root_inode);
-       if(sb->s_root == NULL)
-               goto out_put;
-
-       err = read_inode(root_inode);
-       if(err)
-               goto out_put;
-
-       return(0);
-
- out_put:
-       iput(root_inode);
- out_free:
-       kfree(name);
- out:
-       return(err);
-}
-
-static struct super_block *hostfs_read_sb(struct file_system_type *type,
-                                            int flags, const char *dev_name,
-                                            void *data)
-{
-       return(get_sb_nodev(type, flags, data, hostfs_fill_sb_common));
-}
-
-static struct file_system_type hostfs_type = {
-       .owner          = THIS_MODULE,
-       .name           = "hostfs",
-       .get_sb         = hostfs_read_sb,
-       .kill_sb        = kill_anon_super,
-       .fs_flags       = 0,
-};
-
-static int __init init_hostfs(void)
-{
-       return(register_filesystem(&hostfs_type));
-}
-
-static void __exit exit_hostfs(void)
-{
-       unregister_filesystem(&hostfs_type);
-}
-
-module_init(init_hostfs)
-module_exit(exit_hostfs)
-MODULE_LICENSE("GPL");
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/fs/hostfs/hostfs_user.c b/fs/hostfs/hostfs_user.c
deleted file mode 100644 (file)
index c406266..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/vfs.h>
-#include "hostfs.h"
-#include "kern_util.h"
-#include "user.h"
-
-int stat_file(const char *path, unsigned long long *inode_out, int *mode_out,
-             int *nlink_out, int *uid_out, int *gid_out, 
-             unsigned long long *size_out, struct timespec *atime_out,
-             struct timespec *mtime_out, struct timespec *ctime_out,
-             int *blksize_out, unsigned long long *blocks_out)
-{
-       struct stat64 buf;
-
-       if(lstat64(path, &buf) < 0) 
-               return(-errno);
-
-       /* See the Makefile for why STAT64_INO_FIELD is passed in
-        * by the build
-        */
-       if(inode_out != NULL) *inode_out = buf.STAT64_INO_FIELD;
-       if(mode_out != NULL) *mode_out = buf.st_mode;
-       if(nlink_out != NULL) *nlink_out = buf.st_nlink;
-       if(uid_out != NULL) *uid_out = buf.st_uid;
-       if(gid_out != NULL) *gid_out = buf.st_gid;
-       if(size_out != NULL) *size_out = buf.st_size;
-       if(atime_out != NULL) {
-               atime_out->tv_sec = buf.st_atime;
-               atime_out->tv_nsec = 0;
-       }
-       if(mtime_out != NULL) {
-               mtime_out->tv_sec = buf.st_mtime;
-               mtime_out->tv_nsec = 0;
-       }
-       if(ctime_out != NULL) {
-               ctime_out->tv_sec = buf.st_ctime;
-               ctime_out->tv_nsec = 0;
-       }
-       if(blksize_out != NULL) *blksize_out = buf.st_blksize;
-       if(blocks_out != NULL) *blocks_out = buf.st_blocks;
-       return(0);
-}
-
-int file_type(const char *path, int *rdev)
-{
-       struct stat64 buf;
-
-       if(lstat64(path, &buf) < 0) 
-               return(-errno);
-       if(rdev != NULL) 
-               *rdev = buf.st_rdev;
-
-       if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR);
-       else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK);
-       else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV);
-       else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV);
-       else if(S_ISFIFO(buf.st_mode))return(OS_TYPE_FIFO);
-       else if(S_ISSOCK(buf.st_mode))return(OS_TYPE_SOCK);
-       else return(OS_TYPE_FILE);
-}
-
-int access_file(char *path, int r, int w, int x)
-{
-       int mode = 0;
-
-       if(r) mode = R_OK;
-       if(w) mode |= W_OK;
-       if(x) mode |= X_OK;
-       if(access(path, mode) != 0) return(-errno);
-       else return(0);
-}
-
-int open_file(char *path, int r, int w, int append)
-{
-       int mode = 0, fd;
-
-       if(r && !w) 
-               mode = O_RDONLY;
-       else if(!r && w) 
-               mode = O_WRONLY;
-       else if(r && w) 
-               mode = O_RDWR;
-       else panic("Impossible mode in open_file");
-
-       if(append)
-               mode |= O_APPEND;
-       fd = open64(path, mode);
-       if(fd < 0) return(-errno);
-       else return(fd);
-}
-
-void *open_dir(char *path, int *err_out)
-{
-       DIR *dir;
-
-       dir = opendir(path);
-       *err_out = errno;
-       if(dir == NULL) return(NULL);
-       return(dir);
-}
-
-char *read_dir(void *stream, unsigned long long *pos, 
-              unsigned long long *ino_out, int *len_out)
-{
-       DIR *dir = stream;
-       struct dirent *ent;
-
-       seekdir(dir, *pos);
-       ent = readdir(dir);
-       if(ent == NULL) return(NULL);
-       *len_out = strlen(ent->d_name);
-       *ino_out = ent->d_ino;
-       *pos = telldir(dir);
-       return(ent->d_name);
-}
-
-int read_file(int fd, unsigned long long *offset, char *buf, int len)
-{
-       int n;
-
-       n = pread64(fd, buf, len, *offset);
-       if(n < 0) return(-errno);
-       *offset += n;
-       return(n);
-}
-
-int write_file(int fd, unsigned long long *offset, const char *buf, int len)
-{
-       int n;
-
-       n = pwrite64(fd, buf, len, *offset);
-       if(n < 0) return(-errno);
-       *offset += n;
-       return(n);
-}
-
-int lseek_file(int fd, long long offset, int whence)
-{
-       int ret;
-
-       ret = lseek64(fd, offset, whence);
-       if(ret < 0) return(-errno);
-       return(0);
-}
-
-void close_file(void *stream)
-{
-       close(*((int *) stream));
-}
-
-void close_dir(void *stream)
-{
-       closedir(stream);
-}
-
-int file_create(char *name, int ur, int uw, int ux, int gr, 
-               int gw, int gx, int or, int ow, int ox)
-{
-       int mode, fd;
-
-       mode = 0;
-       mode |= ur ? S_IRUSR : 0;
-       mode |= uw ? S_IWUSR : 0;
-       mode |= ux ? S_IXUSR : 0;
-       mode |= gr ? S_IRGRP : 0;
-       mode |= gw ? S_IWGRP : 0;
-       mode |= gx ? S_IXGRP : 0;
-       mode |= or ? S_IROTH : 0;
-       mode |= ow ? S_IWOTH : 0;
-       mode |= ox ? S_IXOTH : 0;
-       fd = open64(name, O_CREAT | O_RDWR, mode);
-       if(fd < 0) 
-               return(-errno);
-       return(fd);
-}
-
-int set_attr(const char *file, struct hostfs_iattr *attrs)
-{
-       struct utimbuf buf;
-       int err, ma;
-
-       if(attrs->ia_valid & HOSTFS_ATTR_MODE){
-               if(chmod(file, attrs->ia_mode) != 0) return(-errno);
-       }
-       if(attrs->ia_valid & HOSTFS_ATTR_UID){
-               if(chown(file, attrs->ia_uid, -1)) return(-errno);
-       }
-       if(attrs->ia_valid & HOSTFS_ATTR_GID){
-               if(chown(file, -1, attrs->ia_gid)) return(-errno);
-       }
-       if(attrs->ia_valid & HOSTFS_ATTR_SIZE){
-               if(truncate(file, attrs->ia_size)) return(-errno);
-       }
-       ma = HOSTFS_ATTR_ATIME_SET | HOSTFS_ATTR_MTIME_SET;
-       if((attrs->ia_valid & ma) == ma){
-               buf.actime = attrs->ia_atime.tv_sec;
-               buf.modtime = attrs->ia_mtime.tv_sec;
-               if(utime(file, &buf) != 0) return(-errno);
-       }
-       else {
-               struct timespec ts;
-
-               if(attrs->ia_valid & HOSTFS_ATTR_ATIME_SET){
-                       err = stat_file(file, NULL, NULL, NULL, NULL, NULL, 
-                                       NULL, NULL, &ts, NULL, NULL, NULL);
-                       if(err != 0) 
-                               return(err);
-                       buf.actime = attrs->ia_atime.tv_sec;
-                       buf.modtime = ts.tv_sec;
-                       if(utime(file, &buf) != 0) 
-                               return(-errno);
-               }
-               if(attrs->ia_valid & HOSTFS_ATTR_MTIME_SET){
-                       err = stat_file(file, NULL, NULL, NULL, NULL, NULL, 
-                                       NULL, &ts, NULL, NULL, NULL, NULL);
-                       if(err != 0) 
-                               return(err);
-                       buf.actime = ts.tv_sec;
-                       buf.modtime = attrs->ia_mtime.tv_sec;
-                       if(utime(file, &buf) != 0) 
-                               return(-errno);
-               }
-       }
-       if(attrs->ia_valid & HOSTFS_ATTR_CTIME) ;
-       if(attrs->ia_valid & (HOSTFS_ATTR_ATIME | HOSTFS_ATTR_MTIME)){
-               err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL, 
-                               &attrs->ia_atime, &attrs->ia_mtime, NULL, 
-                               NULL, NULL);
-               if(err != 0) return(err);
-       }
-       return(0);
-}
-
-int make_symlink(const char *from, const char *to)
-{
-       int err;
-
-       err = symlink(to, from);
-       if(err) return(-errno);
-       return(0);
-}
-
-int unlink_file(const char *file)
-{
-       int err;
-
-       err = unlink(file);
-       if(err) return(-errno);
-       return(0);
-}
-
-int do_mkdir(const char *file, int mode)
-{
-       int err;
-
-       err = mkdir(file, mode);
-       if(err) return(-errno);
-       return(0);
-}
-
-int do_rmdir(const char *file)
-{
-       int err;
-
-       err = rmdir(file);
-       if(err) return(-errno);
-       return(0);
-}
-
-int do_mknod(const char *file, int mode, int dev)
-{
-       int err;
-
-       err = mknod(file, mode, dev);
-       if(err) return(-errno);
-       return(0);
-}
-
-int link_file(const char *to, const char *from)
-{
-       int err;
-
-       err = link(to, from);
-       if(err) return(-errno);
-       return(0);
-}
-
-int do_readlink(char *file, char *buf, int size)
-{
-       int n;
-
-       n = readlink(file, buf, size);
-       if(n < 0) 
-               return(-errno);
-       if(n < size) 
-               buf[n] = '\0';
-       return(n);
-}
-
-int rename_file(char *from, char *to)
-{
-       int err;
-
-       err = rename(from, to);
-       if(err < 0) return(-errno);
-       return(0);      
-}
-
-int do_statfs(char *root, long *bsize_out, long long *blocks_out, 
-             long long *bfree_out, long long *bavail_out, 
-             long long *files_out, long long *ffree_out,
-             void *fsid_out, int fsid_size, long *namelen_out, 
-             long *spare_out)
-{
-       struct statfs64 buf;
-       int err;
-
-       err = statfs64(root, &buf);
-       if(err < 0) return(-errno);
-       *bsize_out = buf.f_bsize;
-       *blocks_out = buf.f_blocks;
-       *bfree_out = buf.f_bfree;
-       *bavail_out = buf.f_bavail;
-       *files_out = buf.f_files;
-       *ffree_out = buf.f_ffree;
-       memcpy(fsid_out, &buf.f_fsid, 
-              sizeof(buf.f_fsid) > fsid_size ? fsid_size : 
-              sizeof(buf.f_fsid));
-       *namelen_out = buf.f_namelen;
-       spare_out[0] = buf.f_spare[0];
-       spare_out[1] = buf.f_spare[1];
-       spare_out[2] = buf.f_spare[2];
-       spare_out[3] = buf.f_spare[3];
-       spare_out[4] = buf.f_spare[4];
-       spare_out[5] = buf.f_spare[5];
-       return(0);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/fs/hppfs/Makefile b/fs/hppfs/Makefile
deleted file mode 100644 (file)
index e67f038..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# 
-# Copyright (C) 2002, 2003 Jeff Dike (jdike@karaya.com)
-# Licensed under the GPL
-#
-
-hppfs-objs := hppfs_kern.o
-
-obj-y = 
-obj-$(CONFIG_HPPFS) += hppfs.o
-
-clean:
-
-modules:
-
-fastdep:
-
-dep:
-
-archmrproper: clean
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c
deleted file mode 100644 (file)
index ebf08cb..0000000
+++ /dev/null
@@ -1,811 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/kernel.h>
-#include <linux/ctype.h>
-#include <linux/dcache.h>
-#include <linux/statfs.h>
-#include <asm/uaccess.h>
-#include <asm/fcntl.h>
-#include "os.h"
-
-static int init_inode(struct inode *inode, struct dentry *dentry);
-
-struct hppfs_data {
-       struct list_head list;
-       char contents[PAGE_SIZE - sizeof(struct list_head)];
-};
-
-struct hppfs_private {
-       struct file proc_file;
-       int host_fd;
-       loff_t len;
-       struct hppfs_data *contents;
-};
-
-struct hppfs_inode_info {
-        struct dentry *proc_dentry;
-       struct inode vfs_inode;
-};
-
-static inline struct hppfs_inode_info *HPPFS_I(struct inode *inode)
-{
-       return(list_entry(inode, struct hppfs_inode_info, vfs_inode));
-}
-
-#define HPPFS_SUPER_MAGIC 0xb00000ee
-
-static struct super_operations hppfs_sbops;
-
-static int is_pid(struct dentry *dentry)
-{
-       struct super_block *sb;
-       int i;
-
-       sb = dentry->d_sb;
-       if((sb->s_op != &hppfs_sbops) || (dentry->d_parent != sb->s_root))
-               return(0);
-
-       for(i = 0; i < dentry->d_name.len; i++){
-               if(!isdigit(dentry->d_name.name[i]))
-                       return(0);
-       }
-       return(1);
-}
-
-static char *dentry_name(struct dentry *dentry, int extra)
-{
-       struct dentry *parent;
-       char *root, *name;
-       const char *seg_name;
-       int len, seg_len;
-
-       len = 0;
-       parent = dentry;
-       while(parent->d_parent != parent){
-               if(is_pid(parent))
-                       len += strlen("pid") + 1;
-               else len += parent->d_name.len + 1;
-               parent = parent->d_parent;
-       }
-       
-       root = "proc";
-       len += strlen(root);
-       name = kmalloc(len + extra + 1, GFP_KERNEL);
-       if(name == NULL) return(NULL);
-
-       name[len] = '\0';
-       parent = dentry;
-       while(parent->d_parent != parent){
-               if(is_pid(parent)){
-                       seg_name = "pid";
-                       seg_len = strlen("pid");
-               }
-               else {
-                       seg_name = parent->d_name.name;
-                       seg_len = parent->d_name.len;
-               }
-
-               len -= seg_len + 1;
-               name[len] = '/';
-               strncpy(&name[len + 1], seg_name, seg_len);
-               parent = parent->d_parent;
-       }
-       strncpy(name, root, strlen(root));
-       return(name);
-}
-
-struct dentry_operations hppfs_dentry_ops = {
-};
-
-static int file_removed(struct dentry *dentry, const char *file)
-{
-       char *host_file;
-       int extra, fd;
-
-       extra = 0;
-       if(file != NULL) extra += strlen(file) + 1;
-
-       host_file = dentry_name(dentry, extra + strlen("/remove"));
-       if(host_file == NULL){
-               printk("file_removed : allocation failed\n");
-               return(-ENOMEM);
-       }
-
-       if(file != NULL){
-               strcat(host_file, "/");
-               strcat(host_file, file);
-       }
-       strcat(host_file, "/remove");
-
-       fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
-       kfree(host_file);
-       if(fd > 0){
-               os_close_file(fd);
-               return(1);
-       }
-       return(0);
-}
-
-static void hppfs_read_inode(struct inode *ino)
-{
-       struct inode *proc_ino;
-
-       if(HPPFS_I(ino)->proc_dentry == NULL)
-               return;
-
-       proc_ino = HPPFS_I(ino)->proc_dentry->d_inode;
-       ino->i_uid = proc_ino->i_uid;
-       ino->i_gid = proc_ino->i_gid;
-       ino->i_atime = proc_ino->i_atime;
-       ino->i_mtime = proc_ino->i_mtime;
-       ino->i_ctime = proc_ino->i_ctime;
-       ino->i_ino = proc_ino->i_ino;
-       ino->i_mode = proc_ino->i_mode;
-       ino->i_nlink = proc_ino->i_nlink;
-       ino->i_size = proc_ino->i_size;
-       ino->i_blksize = proc_ino->i_blksize;
-       ino->i_blocks = proc_ino->i_blocks;
-}
-
-static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, 
-                                  struct nameidata *nd)
-{
-       struct dentry *proc_dentry, *new, *parent;
-       struct inode *inode;
-       int err, deleted;
-
-       deleted = file_removed(dentry, NULL);
-       if(deleted < 0)
-               return(ERR_PTR(deleted));
-       else if(deleted)
-               return(ERR_PTR(-ENOENT));
-
-       err = -ENOMEM;
-       parent = HPPFS_I(ino)->proc_dentry;
-       down(&parent->d_inode->i_sem);
-       proc_dentry = d_lookup(parent, &dentry->d_name);
-       if(proc_dentry == NULL){
-               proc_dentry = d_alloc(parent, &dentry->d_name);
-               if(proc_dentry == NULL){
-                       up(&parent->d_inode->i_sem);
-                       goto out;
-               }
-               new = (*parent->d_inode->i_op->lookup)(parent->d_inode, 
-                                                      proc_dentry, NULL);
-               if(new){
-                       dput(proc_dentry);
-                       proc_dentry = new;
-               }
-       }
-       up(&parent->d_inode->i_sem);
-
-       if(IS_ERR(proc_dentry))
-               return(proc_dentry);
-
-       inode = iget(ino->i_sb, 0);
-       if(inode == NULL) 
-               goto out_dput;
-
-       err = init_inode(inode, proc_dentry);
-       if(err) 
-               goto out_put;
-       
-       hppfs_read_inode(inode);
-
-       d_add(dentry, inode);
-       dentry->d_op = &hppfs_dentry_ops;
-       return(NULL);
-
- out_put:
-       iput(inode);
- out_dput:
-       dput(proc_dentry);
- out:
-       return(ERR_PTR(err));
-}
-
-static struct inode_operations hppfs_file_iops = {
-};
-
-static ssize_t read_proc(struct file *file, char *buf, ssize_t count, 
-                        loff_t *ppos, int is_user)
-{
-       ssize_t (*read)(struct file *, char *, size_t, loff_t *);
-       ssize_t n;
-
-       read = file->f_dentry->d_inode->i_fop->read;
-
-       if(!is_user)
-               set_fs(KERNEL_DS);
-               
-       n = (*read)(file, buf, count, &file->f_pos);
-
-       if(!is_user)
-               set_fs(USER_DS);
-
-       if(ppos) *ppos = file->f_pos;
-       return(n);
-}
-
-static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count)
-{
-       ssize_t n;
-       int cur, err;
-       char *new_buf;
-
-       n = -ENOMEM;
-       new_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-       if(new_buf == NULL){
-               printk("hppfs_read_file : kmalloc failed\n");
-               goto out;
-       }
-       n = 0;
-       while(count > 0){
-               cur = min_t(ssize_t, count, PAGE_SIZE);
-               err = os_read_file(fd, new_buf, cur);
-               if(err < 0){
-                       printk("hppfs_read : read failed, errno = %d\n",
-                              count);
-                       n = err;
-                       goto out_free;
-               }
-               else if(err == 0)
-                       break;
-
-               if(copy_to_user(buf, new_buf, err)){
-                       n = -EFAULT;
-                       goto out_free;
-               }
-               n += err;
-               count -= err;
-       }
- out_free:
-       kfree(new_buf);
- out:
-       return(n);
-}
-
-static ssize_t hppfs_read(struct file *file, char *buf, size_t count, 
-                         loff_t *ppos)
-{
-       struct hppfs_private *hppfs = file->private_data;
-       struct hppfs_data *data;
-       loff_t off;
-       int err;
-
-       if(hppfs->contents != NULL){
-               if(*ppos >= hppfs->len) return(0);
-
-               data = hppfs->contents;
-               off = *ppos;
-               while(off >= sizeof(data->contents)){
-                       data = list_entry(data->list.next, struct hppfs_data,
-                                         list);
-                       off -= sizeof(data->contents);
-               }
-
-               if(off + count > hppfs->len)
-                       count = hppfs->len - off;
-               copy_to_user(buf, &data->contents[off], count);
-               *ppos += count;
-       }
-       else if(hppfs->host_fd != -1){
-               err = os_seek_file(hppfs->host_fd, *ppos);
-               if(err){
-                       printk("hppfs_read : seek failed, errno = %d\n", err);
-                       return(err);
-               }
-               count = hppfs_read_file(hppfs->host_fd, buf, count);
-               if(count > 0)
-                       *ppos += count;
-       }
-       else count = read_proc(&hppfs->proc_file, buf, count, ppos, 1);
-
-       return(count);
-}
-
-static ssize_t hppfs_write(struct file *file, const char *buf, size_t len, 
-                          loff_t *ppos)
-{
-       struct hppfs_private *data = file->private_data;
-       struct file *proc_file = &data->proc_file;
-       ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
-       int err;
-
-       write = proc_file->f_dentry->d_inode->i_fop->write;
-
-       proc_file->f_pos = file->f_pos;
-       err = (*write)(proc_file, buf, len, &proc_file->f_pos);
-       file->f_pos = proc_file->f_pos;
-
-       return(err);
-}
-
-static int open_host_sock(char *host_file, int *filter_out)
-{
-       char *end;
-       int fd;
-
-       end = &host_file[strlen(host_file)];
-       strcpy(end, "/rw");
-       *filter_out = 1;
-       fd = os_connect_socket(host_file);
-       if(fd > 0)
-               return(fd);
-
-       strcpy(end, "/r");
-       *filter_out = 0;
-       fd = os_connect_socket(host_file);
-       return(fd);
-}
-
-static void free_contents(struct hppfs_data *head)
-{
-       struct hppfs_data *data;
-       struct list_head *ele, *next;
-
-       if(head == NULL) return;
-
-       list_for_each_safe(ele, next, &head->list){
-               data = list_entry(ele, struct hppfs_data, list);
-               kfree(data);
-       }
-       kfree(head);
-}
-
-static struct hppfs_data *hppfs_get_data(int fd, int filter, 
-                                        struct file *proc_file, 
-                                        struct file *hppfs_file, 
-                                        loff_t *size_out)
-{
-       struct hppfs_data *data, *new, *head;
-       int n, err;
-
-       err = -ENOMEM;
-       data = kmalloc(sizeof(*data), GFP_KERNEL);
-       if(data == NULL){
-               printk("hppfs_get_data : head allocation failed\n");
-               goto failed;
-       }
-
-       INIT_LIST_HEAD(&data->list);
-
-       head = data;
-       *size_out = 0;
-
-       if(filter){
-               while((n = read_proc(proc_file, data->contents,
-                                    sizeof(data->contents), NULL, 0)) > 0)
-                       os_write_file(fd, data->contents, n);
-               err = os_shutdown_socket(fd, 0, 1);
-               if(err){
-                       printk("hppfs_get_data : failed to shut down "
-                              "socket\n");
-                       goto failed_free;
-               }
-       }
-       while(1){
-               n = os_read_file(fd, data->contents, sizeof(data->contents));
-               if(n < 0){
-                       err = n;
-                       printk("hppfs_get_data : read failed, errno = %d\n",
-                              err);
-                       goto failed_free;
-               }
-               else if(n == 0)
-                       break;
-
-               *size_out += n;
-
-               if(n < sizeof(data->contents))
-                       break;
-
-               new = kmalloc(sizeof(*data), GFP_KERNEL);
-               if(new == 0){
-                       printk("hppfs_get_data : data allocation failed\n");
-                       err = -ENOMEM;
-                       goto failed_free;
-               }
-       
-               INIT_LIST_HEAD(&new->list);
-               list_add(&new->list, &data->list);
-               data = new;
-       }
-       return(head);
-
- failed_free:
-       free_contents(head);
- failed:               
-       return(ERR_PTR(err));
-}
-
-static struct hppfs_private *hppfs_data(void)
-{
-       struct hppfs_private *data;
-
-       data = kmalloc(sizeof(*data), GFP_KERNEL);
-       if(data == NULL)
-               return(data);
-
-       *data = ((struct hppfs_private ) { .host_fd             = -1,
-                                          .len                 = -1,
-                                          .contents            = NULL } );
-       return(data);
-}
-
-static int file_mode(int fmode)
-{
-       if(fmode == (FMODE_READ | FMODE_WRITE))
-               return(O_RDWR);
-       if(fmode == FMODE_READ)
-               return(O_RDONLY);
-       if(fmode == FMODE_WRITE)
-               return(O_WRONLY);
-       return(0);
-}
-
-static int hppfs_open(struct inode *inode, struct file *file)
-{
-       struct hppfs_private *data;
-       struct dentry *proc_dentry;
-       char *host_file;
-       int err, fd, type, filter;
-
-       err = -ENOMEM;
-       data = hppfs_data();
-       if(data == NULL)
-               goto out;
-
-       host_file = dentry_name(file->f_dentry, strlen("/rw"));
-       if(host_file == NULL)
-               goto out_free2;
-
-       proc_dentry = HPPFS_I(inode)->proc_dentry;
-
-       /* XXX This isn't closed anywhere */
-       err = open_private_file(&data->proc_file, proc_dentry, 
-                               file_mode(file->f_mode));
-       if(err)
-               goto out_free1;
-
-       type = os_file_type(host_file);
-       if(type == OS_TYPE_FILE){
-               fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
-               if(fd >= 0) 
-                       data->host_fd = fd;
-               else printk("hppfs_open : failed to open '%s', errno = %d\n",
-                           host_file, -fd);
-
-               data->contents = NULL;
-       }
-       else if(type == OS_TYPE_DIR){
-               fd = open_host_sock(host_file, &filter);
-               if(fd > 0){
-                       data->contents = hppfs_get_data(fd, filter, 
-                                                       &data->proc_file, 
-                                                       file, &data->len);
-                       if(!IS_ERR(data->contents))
-                               data->host_fd = fd;
-               }
-               else printk("hppfs_open : failed to open a socket in "
-                           "'%s', errno = %d\n", host_file, -fd);
-       }
-       kfree(host_file);
-
-       file->private_data = data;
-       return(0);
-
- out_free1:
-       kfree(host_file);
- out_free2:
-       free_contents(data->contents);
-       kfree(data);
- out:
-       return(err);
-}
-
-static int hppfs_dir_open(struct inode *inode, struct file *file)
-{
-       struct hppfs_private *data;
-       struct dentry *proc_dentry;
-       int err;
-
-       err = -ENOMEM;
-       data = hppfs_data();
-       if(data == NULL)
-               goto out;
-
-       proc_dentry = HPPFS_I(inode)->proc_dentry;
-       err = open_private_file(&data->proc_file, proc_dentry, 
-                               file_mode(file->f_mode));
-       if(err)
-               goto out_free;
-
-       file->private_data = data;
-       return(0);
-
- out_free:
-       kfree(data);
- out:
-       return(err);
-}
-
-static loff_t hppfs_llseek(struct file *file, loff_t off, int where)
-{
-       struct hppfs_private *data = file->private_data;
-       struct file *proc_file = &data->proc_file;
-       loff_t (*llseek)(struct file *, loff_t, int);
-       loff_t ret;
-
-       llseek = proc_file->f_dentry->d_inode->i_fop->llseek;
-       if(llseek != NULL){
-               ret = (*llseek)(proc_file, off, where);
-               if(ret < 0)
-                       return(ret);
-       }
-
-       return(default_llseek(file, off, where));
-}
-
-static struct file_operations hppfs_file_fops = {
-       .owner          = NULL,
-       .llseek         = hppfs_llseek,
-       .read           = hppfs_read,
-       .write          = hppfs_write,
-       .open           = hppfs_open,
-};
-
-struct hppfs_dirent {
-       void *vfs_dirent;
-       filldir_t filldir;
-       struct dentry *dentry;
-};
-
-static int hppfs_filldir(void *d, const char *name, int size, 
-                        loff_t offset, ino_t inode, unsigned int type)
-{
-       struct hppfs_dirent *dirent = d;
-
-       if(file_removed(dirent->dentry, name))
-               return(0);
-
-       return((*dirent->filldir)(dirent->vfs_dirent, name, size, offset, 
-                                 inode, type));
-}
-
-static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
-{
-       struct hppfs_private *data = file->private_data;
-       struct file *proc_file = &data->proc_file;
-       int (*readdir)(struct file *, void *, filldir_t);
-       struct hppfs_dirent dirent = ((struct hppfs_dirent)
-                                     { .vfs_dirent     = ent,
-                                       .filldir        = filldir,
-                                       .dentry         = file->f_dentry } );
-       int err;
-
-       readdir = proc_file->f_dentry->d_inode->i_fop->readdir;
-
-       proc_file->f_pos = file->f_pos;
-       err = (*readdir)(proc_file, &dirent, hppfs_filldir);
-       file->f_pos = proc_file->f_pos;
-
-       return(err);
-}
-
-static int hppfs_fsync(struct file *file, struct dentry *dentry, int datasync)
-{
-       return(0);
-}
-
-static struct file_operations hppfs_dir_fops = {
-       .owner          = NULL,
-       .readdir        = hppfs_readdir,
-       .open           = hppfs_dir_open,
-       .fsync          = hppfs_fsync,
-};
-
-static int hppfs_statfs(struct super_block *sb, struct kstatfs *sf)
-{
-       sf->f_blocks = 0;
-       sf->f_bfree = 0;
-       sf->f_bavail = 0;
-       sf->f_files = 0;
-       sf->f_ffree = 0;
-       sf->f_type = HPPFS_SUPER_MAGIC;
-       return(0);
-}
-
-static struct inode *hppfs_alloc_inode(struct super_block *sb)
-{
-       struct hppfs_inode_info *hi;
-
-       hi = kmalloc(sizeof(*hi), GFP_KERNEL);
-       if(hi == NULL) 
-               return(NULL);
-
-       *hi = ((struct hppfs_inode_info) { .proc_dentry = NULL });
-       inode_init_once(&hi->vfs_inode);
-       return(&hi->vfs_inode);
-}
-
-void hppfs_delete_inode(struct inode *ino)
-{
-       clear_inode(ino);
-}
-
-static void hppfs_destroy_inode(struct inode *inode)
-{
-       kfree(HPPFS_I(inode));
-}
-
-static struct super_operations hppfs_sbops = { 
-       .alloc_inode    = hppfs_alloc_inode,
-       .destroy_inode  = hppfs_destroy_inode,
-       .read_inode     = hppfs_read_inode,
-       .delete_inode   = hppfs_delete_inode,
-       .statfs         = hppfs_statfs,
-};
-
-static int hppfs_readlink(struct dentry *dentry, char *buffer, int buflen)
-{
-       struct file proc_file;
-       struct dentry *proc_dentry;
-       int (*readlink)(struct dentry *, char *, int);
-       int err, n;
-
-       proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
-       err = open_private_file(&proc_file, proc_dentry, O_RDONLY);
-       if(err) 
-               return(err);
-
-       readlink = proc_dentry->d_inode->i_op->readlink;
-       n = (*readlink)(proc_dentry, buffer, buflen);
-
-       close_private_file(&proc_file);
-       
-       return(n);
-}
-
-static int hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
-{
-       struct file proc_file;
-       struct dentry *proc_dentry;
-       int (*follow_link)(struct dentry *, struct nameidata *);
-       int err, n;
-
-       proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
-       err = open_private_file(&proc_file, proc_dentry, O_RDONLY);
-       if(err) 
-               return(err);
-
-       follow_link = proc_dentry->d_inode->i_op->follow_link;
-       n = (*follow_link)(proc_dentry, nd);
-
-       close_private_file(&proc_file);
-       
-       return(n);
-}
-
-static struct inode_operations hppfs_dir_iops = {
-       .lookup         = hppfs_lookup,
-};
-
-static struct inode_operations hppfs_link_iops = {
-       .readlink       = hppfs_readlink,
-       .follow_link    = hppfs_follow_link,
-};
-
-static int init_inode(struct inode *inode, struct dentry *dentry)
-{
-       if(S_ISDIR(dentry->d_inode->i_mode)){
-               inode->i_op = &hppfs_dir_iops;
-               inode->i_fop = &hppfs_dir_fops;
-       }
-       else if(S_ISLNK(dentry->d_inode->i_mode)){
-               inode->i_op = &hppfs_link_iops;
-               inode->i_fop = &hppfs_file_fops;
-       }
-       else {
-               inode->i_op = &hppfs_file_iops;
-               inode->i_fop = &hppfs_file_fops;
-       }
-
-       HPPFS_I(inode)->proc_dentry = dentry;
-
-       return(0);
-}
-
-static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
-{
-       struct inode *root_inode;
-       struct file_system_type *procfs;
-       struct super_block *proc_sb;
-       int err;
-
-       err = -ENOENT;
-       procfs = get_fs_type("proc");
-       if(procfs == NULL) 
-               goto out;
-
-       if(list_empty(&procfs->fs_supers))
-               goto out;
-
-       proc_sb = list_entry(procfs->fs_supers.next, struct super_block,
-                            s_instances);
-       
-       sb->s_blocksize = 1024;
-       sb->s_blocksize_bits = 10;
-       sb->s_magic = HPPFS_SUPER_MAGIC;
-       sb->s_op = &hppfs_sbops;
-
-       root_inode = iget(sb, 0);
-       if(root_inode == NULL)
-               goto out;
-
-       err = init_inode(root_inode, proc_sb->s_root);
-       if(err)
-               goto out_put;
-
-       err = -ENOMEM;
-       sb->s_root = d_alloc_root(root_inode);
-       if(sb->s_root == NULL)
-               goto out_put;
-
-       hppfs_read_inode(root_inode);
-
-       return(0);
-
- out_put:
-       iput(root_inode);
- out:
-       return(err);
-}
-
-static struct super_block *hppfs_read_super(struct file_system_type *type,
-                                            int flags, const char *dev_name,
-                                            void *data)
-{
-       return(get_sb_nodev(type, flags, data, hppfs_fill_super));
-}
-
-static struct file_system_type hppfs_type = {
-       .owner          = THIS_MODULE,
-       .name           = "hppfs",
-       .get_sb         = hppfs_read_super,
-       .kill_sb        = kill_anon_super,
-       .fs_flags       = 0,
-};
-
-static int __init init_hppfs(void)
-{
-       return(register_filesystem(&hppfs_type));
-}
-
-static void __exit exit_hppfs(void)
-{
-       unregister_filesystem(&hppfs_type);
-}
-
-module_init(init_hppfs)
-module_exit(exit_hppfs)
-MODULE_LICENSE("GPL");
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 4ec4283..794f9e5 100644 (file)
@@ -43,8 +43,6 @@ static struct backing_dev_info hugetlbfs_backing_dev_info = {
        .memory_backed  = 1,    /* Does not contribute to dirty memory */
 };
 
-int sysctl_hugetlb_shm_group;
-
 static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
        struct inode *inode = file->f_dentry->d_inode;
@@ -718,27 +716,24 @@ static unsigned long hugetlbfs_counter(void)
        return ret;
 }
 
-static int can_do_hugetlb_shm(void)
-{
-       return likely(capable(CAP_IPC_LOCK) ||
-                       in_group_p(sysctl_hugetlb_shm_group));
-}
-
 struct file *hugetlb_zero_setup(size_t size)
 {
-       int error;
+       int error = -ENOMEM;
        struct file *file;
        struct inode *inode;
        struct dentry *dentry, *root;
        struct qstr quick_string;
        char buf[16];
 
-       if (!can_do_hugetlb_shm())
+       if (!capable(CAP_IPC_LOCK))
                return ERR_PTR(-EPERM);
 
        if (!is_hugepage_mem_enough(size))
                return ERR_PTR(-ENOMEM);
 
+       if (!user_shm_lock(size, current->user))
+               return ERR_PTR(-ENOMEM);
+
        root = hugetlbfs_vfsmount->mnt_root;
        snprintf(buf, 16, "%lu", hugetlbfs_counter());
        quick_string.name = buf;
@@ -746,7 +741,7 @@ struct file *hugetlb_zero_setup(size_t size)
        quick_string.hash = 0;
        dentry = d_alloc(root, &quick_string);
        if (!dentry)
-               return ERR_PTR(-ENOMEM);
+               goto out_shm_unlock;
 
        error = -ENFILE;
        file = get_empty_filp();
@@ -773,6 +768,8 @@ out_file:
        put_filp(file);
 out_dentry:
        dput(dentry);
+out_shm_unlock:
+       user_shm_unlock(size, current->user);
        return ERR_PTR(error);
 }
 
index ec09459..d858616 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/pagemap.h>
 #include <linux/cdev.h>
 #include <linux/bootmem.h>
+#include <linux/vs_base.h>
 
 /*
  * This is needed for the following functions:
@@ -99,13 +100,36 @@ struct inodes_stat_t inodes_stat;
 
 static kmem_cache_t * inode_cachep;
 
+static void prune_icache(int nr_to_scan);
+
+
+#define INODE_UNUSED_THRESHOLD 15000
+#define PRUNE_BATCH_COUNT 32
+
+void try_to_clip_inodes(void)
+{
+       unsigned long count = 0; 
+       /* if there are a LOT of unused inodes in cache, better shrink a few first */
+       
+       /* check lockless first to not take the lock always here; racing occasionally isn't a big deal */
+       if (inodes_stat.nr_unused > INODE_UNUSED_THRESHOLD) {
+               spin_lock(&inode_lock);
+               if (inodes_stat.nr_unused > INODE_UNUSED_THRESHOLD)
+                       count = inodes_stat.nr_unused - INODE_UNUSED_THRESHOLD;
+               spin_unlock(&inode_lock);
+               if (count)
+                       prune_icache(count);
+       }
+}
+
+
 static struct inode *alloc_inode(struct super_block *sb)
 {
        static struct address_space_operations empty_aops;
        static struct inode_operations empty_iops;
        static struct file_operations empty_fops;
        struct inode *inode;
-
+       
        if (sb->s_op->alloc_inode)
                inode = sb->s_op->alloc_inode(sb);
        else
@@ -115,6 +139,10 @@ static struct inode *alloc_inode(struct super_block *sb)
                struct address_space * const mapping = &inode->i_data;
 
                inode->i_sb = sb;
+               // inode->i_dqh = dqhget(sb->s_dqh);
+
+               /* important because of inode slab reuse */
+               inode->i_xid = 0;
                inode->i_blkbits = sb->s_blocksize_bits;
                inode->i_flags = 0;
                atomic_set(&inode->i_count, 1);
@@ -243,6 +271,7 @@ void __iget(struct inode * inode)
  */
 void clear_inode(struct inode *inode)
 {
+       might_sleep();
        invalidate_inode_buffers(inode);
        
        if (inode->i_data.nrpages)
@@ -1181,14 +1210,14 @@ EXPORT_SYMBOL(update_atime);
  *     When ctime_too is specified update the ctime too.
  */
 
-void inode_update_time(struct inode *inode, int ctime_too)
+void inode_update_time(struct inode *inode, struct vfsmount *mnt, int ctime_too)
 {
        struct timespec now;
        int sync_it = 0;
 
        if (IS_NOCMTIME(inode))
                return;
-       if (IS_RDONLY(inode))
+       if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
                return;
 
        now = current_kernel_time();
diff --git a/fs/intermezzo/Makefile b/fs/intermezzo/Makefile
deleted file mode 100644 (file)
index 260c7af..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Makefile 1.00 Peter Braam <braam@clusterfs.com>
-#
-
-obj-$(CONFIG_INTERMEZZO_FS) += intermezzo.o
-
-intermezzo-objs := cache.o dcache.o dir.o ext_attr.o file.o fileset.o \
-                  inode.o journal.o journal_ext2.o journal_ext3.o \
-                  journal_obdfs.o journal_reiserfs.o journal_tmpfs.o journal_xfs.o \
-                  kml_reint.o kml_unpack.o methods.o presto.o psdev.o replicator.o \
-                  super.o sysctl.o upcall.o vfs.o
diff --git a/fs/intermezzo/cache.c b/fs/intermezzo/cache.c
deleted file mode 100644 (file)
index f97bc16..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2000 Stelias Computing, Inc.
- *  Copyright (C) 2000 Red Hat, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/module.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-/*
-   This file contains the routines associated with managing a
-   cache of files for InterMezzo.  These caches have two reqs:
-   - need to be found fast so they are hashed by the device, 
-     with an attempt to have collision chains of length 1.
-   The methods for the cache are set up in methods.
-*/
-
-extern kmem_cache_t * presto_dentry_slab;
-
-/* the intent of this hash is to have collision chains of length 1 */
-#define CACHES_BITS 8
-#define CACHES_SIZE (1 << CACHES_BITS)
-#define CACHES_MASK CACHES_SIZE - 1
-static struct list_head presto_caches[CACHES_SIZE];
-
-static inline int presto_cache_hash(struct super_block *s)
-{
-        return (CACHES_MASK) & ((unsigned long)s >> L1_CACHE_SHIFT);
-}
-
-inline void presto_cache_add(struct presto_cache *cache)
-{
-        list_add(&cache->cache_chain,
-                 &presto_caches[presto_cache_hash(cache->cache_sb)]);
-}
-
-inline void presto_cache_init_hash(void)
-{
-        int i;
-        for ( i = 0; i < CACHES_SIZE; i++ ) {
-                INIT_LIST_HEAD(&presto_caches[i]);
-        }
-}
-
-int izo_ioctl_packlen(struct izo_ioctl_data *data)
-{
-        int len = sizeof(struct izo_ioctl_data);
-        len += size_round(data->ioc_inllen1);
-        len += size_round(data->ioc_inllen2);
-        return len;
-}
-
-/* map a device to a cache */
-struct presto_cache *presto_cache_find(struct super_block *s)
-{
-        struct presto_cache *cache;
-        struct list_head *lh, *tmp;
-
-        lh = tmp = &(presto_caches[presto_cache_hash(s)]);
-        while ( (tmp = lh->next) != lh ) {
-                cache = list_entry(tmp, struct presto_cache, cache_chain);
-                if (cache->cache_sb == s)
-                        return cache;
-        }
-        return NULL;
-}
-
-
-/* map an inode to a cache */
-struct presto_cache *presto_get_cache(struct inode *inode)
-{
-        struct presto_cache *cache;
-        ENTRY;
-        /* find the correct presto_cache here, based on the device */
-        cache = presto_cache_find(inode->i_sb);
-        if ( !cache ) {
-                CERROR("WARNING: no presto cache for %s, ino %ld\n",
-                       inode->i_sb->s_id, inode->i_ino);
-                EXIT;
-                return NULL;
-        }
-        EXIT;
-        return cache;
-}
-
-/* another debugging routine: check fs is InterMezzo fs */
-int presto_ispresto(struct inode *inode)
-{
-        struct presto_cache *cache;
-
-        if ( !inode )
-                return 0;
-        cache = presto_get_cache(inode);
-        if ( !cache )
-                return 0;
-        return inode->i_sb == cache->cache_sb;
-}
-
-/* setup a cache structure when we need one */
-struct presto_cache *presto_cache_init(void)
-{
-        struct presto_cache *cache;
-
-        PRESTO_ALLOC(cache, sizeof(struct presto_cache));
-        if ( cache ) {
-                memset(cache, 0, sizeof(struct presto_cache));
-                INIT_LIST_HEAD(&cache->cache_chain);
-                INIT_LIST_HEAD(&cache->cache_fset_list);
-                cache->cache_lock = SPIN_LOCK_UNLOCKED;
-                cache->cache_reserved = 0; 
-        }
-        return cache;
-}
-
-/* free a cache structure and all of the memory it is pointing to */
-inline void presto_free_cache(struct presto_cache *cache)
-{
-        if (!cache)
-                return;
-
-        list_del(&cache->cache_chain);
-        if (cache->cache_sb && cache->cache_sb->s_root &&
-                        presto_d2d(cache->cache_sb->s_root)) {
-                kmem_cache_free(presto_dentry_slab, 
-                                presto_d2d(cache->cache_sb->s_root));
-                cache->cache_sb->s_root->d_fsdata = NULL;
-        }
-
-        PRESTO_FREE(cache, sizeof(struct presto_cache));
-}
-
-int presto_reserve_space(struct presto_cache *cache, loff_t req)
-{
-        struct filter_fs *filter; 
-        loff_t avail; 
-        struct super_block *sb = cache->cache_sb;
-        filter = cache->cache_filter;
-        if (!filter ) {
-                EXIT;
-                return 0; 
-        }
-        if (!filter->o_trops ) {
-                EXIT;
-                return 0; 
-        }
-        if (!filter->o_trops->tr_avail ) {
-                EXIT;
-                return 0; 
-        }
-
-        spin_lock(&cache->cache_lock);
-        avail = filter->o_trops->tr_avail(cache, sb); 
-        CDEBUG(D_SUPER, "ESC::%ld +++> %ld \n", (long) cache->cache_reserved,
-                 (long) (cache->cache_reserved + req)); 
-        CDEBUG(D_SUPER, "ESC::Avail::%ld \n", (long) avail);
-        if (req + cache->cache_reserved > avail) {
-                spin_unlock(&cache->cache_lock);
-                EXIT;
-                return -ENOSPC;
-        }
-        cache->cache_reserved += req; 
-        spin_unlock(&cache->cache_lock);
-
-        EXIT;
-        return 0;
-}
-
-void presto_release_space(struct presto_cache *cache, loff_t req)
-{
-        CDEBUG(D_SUPER, "ESC::%ld ---> %ld \n", (long) cache->cache_reserved,
-                 (long) (cache->cache_reserved - req)); 
-        spin_lock(&cache->cache_lock);
-        cache->cache_reserved -= req; 
-        spin_unlock(&cache->cache_lock);
-}
diff --git a/fs/intermezzo/dcache.c b/fs/intermezzo/dcache.c
deleted file mode 100644 (file)
index 8f8e2c5..0000000
+++ /dev/null
@@ -1,342 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Original version: Copyright (C) 1996 P. Braam and M. Callahan
- *  Rewritten for Linux 2.1. Copyright (C) 1997 Carnegie Mellon University
- *  d_fsdata and NFS compatiblity fixes Copyright (C) 2001 Tacit Networks, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Directory operations for InterMezzo filesystem
- */
-
-/* inode dentry alias list walking code adapted from linux/fs/dcache.c
- *
- * fs/dcache.c
- *
- * (C) 1997 Thomas Schoebel-Theuer,
- * with heavy changes by Linus Torvalds
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#include <linux/vmalloc.h>
-
-#include "intermezzo_fs.h"
-
-kmem_cache_t * presto_dentry_slab;
-
-/* called when a cache lookup succeeds */
-static int presto_d_revalidate(struct dentry *de, struct nameidata *nd)
-{
-        struct inode *inode = de->d_inode;
-        struct presto_file_set * root_fset;
-
-        ENTRY;
-        if (!inode) {
-                EXIT;
-                return 0;
-        }
-
-        if (is_bad_inode(inode)) {
-                EXIT;
-                return 0;
-        }
-
-        if (!presto_d2d(de)) {
-                presto_set_dd(de);
-        }
-
-        if (!presto_d2d(de)) {
-                EXIT;
-                return 0;
-        }
-
-        root_fset = presto_d2d(de->d_inode->i_sb->s_root)->dd_fset;
-        if (root_fset->fset_flags & FSET_FLAT_BRANCH && 
-            (presto_d2d(de)->dd_fset != root_fset )) {
-                presto_d2d(de)->dd_fset = root_fset;
-        }
-
-        EXIT;
-        return 1;
-
-#if 0
-        /* The following is needed for metadata on demand. */
-        if ( S_ISDIR(inode->i_mode) ) {
-                EXIT;
-                return (presto_chk(de, PRESTO_DATA) &&
-                        (presto_chk(de, PRESTO_ATTR)));
-        } else {
-                EXIT;
-                return presto_chk(de, PRESTO_ATTR);
-        }
-#endif
-}
-
-static void presto_d_release(struct dentry *dentry)
-{
-        if (!presto_d2d(dentry)) {
-                /* This can happen for dentries from NFSd */
-                return;
-        }
-        presto_d2d(dentry)->dd_count--;
-
-        if (!presto_d2d(dentry)->dd_count) {
-                kmem_cache_free(presto_dentry_slab, presto_d2d(dentry));
-                dentry->d_fsdata = NULL;
-        }
-}
-
-struct dentry_operations presto_dentry_ops = 
-{
-        .d_revalidate =  presto_d_revalidate,
-        .d_release = presto_d_release
-};
-
-static inline int presto_is_dentry_ROOT (struct dentry *dentry)
-{
-        return(dentry_name_cmp(dentry,"ROOT") &&
-               !dentry_name_cmp(dentry->d_parent,".intermezzo"));
-}
-
-static struct presto_file_set* presto_try_find_fset(struct dentry* dentry,
-                int *is_under_d_intermezzo)
-{
-        struct dentry* temp_dentry;
-        struct presto_dentry_data *d_data;
-        int found_root=0;
-
-        ENTRY;
-        CDEBUG(D_FSDATA, "finding fileset for %p:%s\n", dentry, 
-                        dentry->d_name.name);
-
-        *is_under_d_intermezzo = 0;
-
-        /* walk up through the branch to get the fileset */
-        /* The dentry we are passed presumably does not have the correct
-         * fset information. However, we still want to start walking up
-         * the branch from this dentry to get our found_root and 
-         * is_under_d_intermezzo decisions correct
-         */
-        for (temp_dentry = dentry ; ; temp_dentry = temp_dentry->d_parent) {
-                CDEBUG(D_FSDATA, "--->dentry %p:%*s\n", temp_dentry, 
-                        temp_dentry->d_name.len,temp_dentry->d_name.name);
-                if (presto_is_dentry_ROOT(temp_dentry))
-                        found_root = 1;
-                if (!found_root &&
-                    dentry_name_cmp(temp_dentry, ".intermezzo")) {
-                        *is_under_d_intermezzo = 1;
-                }
-                d_data = presto_d2d(temp_dentry);
-                if (d_data) {
-                        /* If we found a "ROOT" dentry while walking up the
-                         * branch, we will journal regardless of whether
-                         * we are under .intermezzo or not.
-                         * If we are already under d_intermezzo don't reverse
-                         * the decision here...even if we found a "ROOT"
-                         * dentry above .intermezzo (if we were ever to
-                         * modify the directory structure).
-                         */
-                        if (!*is_under_d_intermezzo)  
-                                *is_under_d_intermezzo = !found_root &&
-                                  (d_data->dd_flags & PRESTO_DONT_JOURNAL);
-                        EXIT;
-                        return d_data->dd_fset;
-                }
-                if (temp_dentry->d_parent == temp_dentry) {
-                        break;
-                }
-        }
-        EXIT;
-        return NULL;
-}
-
-/* Only call this function on positive dentries */
-static struct presto_dentry_data* presto_try_find_alias_with_dd (
-                  struct dentry* dentry)
-{
-        struct inode *inode=dentry->d_inode;
-        struct list_head *head, *next, *tmp;
-        struct dentry *tmp_dentry;
-
-        /* Search through the alias list for dentries with d_fsdata */
-        spin_lock(&dcache_lock);
-        head = &inode->i_dentry;
-        next = inode->i_dentry.next;
-        while (next != head) {
-                tmp = next;
-                next = tmp->next;
-                tmp_dentry = list_entry(tmp, struct dentry, d_alias);
-                if (!presto_d2d(tmp_dentry)) {
-                        spin_unlock(&dcache_lock);
-                        return presto_d2d(tmp_dentry);
-                }
-        }
-        spin_unlock(&dcache_lock);
-        return NULL;
-}
-
-/* Only call this function on positive dentries */
-static void presto_set_alias_dd (struct dentry *dentry, 
-                struct presto_dentry_data* dd)
-{
-        struct inode *inode=dentry->d_inode;
-        struct list_head *head, *next, *tmp;
-        struct dentry *tmp_dentry;
-
-        /* Set d_fsdata for this dentry */
-        dd->dd_count++;
-        dentry->d_fsdata = dd;
-
-        /* Now set d_fsdata for all dentries in the alias list. */
-        spin_lock(&dcache_lock);
-        head = &inode->i_dentry;
-        next = inode->i_dentry.next;
-        while (next != head) {
-                tmp = next;
-                next = tmp->next;
-                tmp_dentry = list_entry(tmp, struct dentry, d_alias);
-                if (!presto_d2d(tmp_dentry)) {
-                        dd->dd_count++;
-                        tmp_dentry->d_fsdata = dd;
-                }
-        }
-        spin_unlock(&dcache_lock);
-        return;
-}
-
-inline struct presto_dentry_data *izo_alloc_ddata(void)
-{
-        struct presto_dentry_data *dd;
-
-        dd = kmem_cache_alloc(presto_dentry_slab, SLAB_KERNEL);
-        if (dd == NULL) {
-                CERROR("IZO: out of memory trying to allocate presto_dentry_data\n");
-                return NULL;
-        }
-        memset(dd, 0, sizeof(*dd));
-        dd->dd_count = 1;
-
-        return dd;
-}
-
-/* This uses the BKL! */
-int presto_set_dd(struct dentry * dentry)
-{
-        struct presto_file_set *fset;
-        struct presto_dentry_data *dd;
-        int is_under_d_izo;
-        int error=0;
-
-        ENTRY;
-
-        if (!dentry)
-                BUG();
-
-        lock_kernel();
-
-        /* Did we lose a race? */
-        if (dentry->d_fsdata) {
-                CERROR("dentry %p already has d_fsdata set\n", dentry);
-                if (dentry->d_inode)
-                        CERROR("    inode: %ld\n", dentry->d_inode->i_ino);
-                EXIT;
-                goto out_unlock;
-        }
-
-        if (dentry->d_inode != NULL) {
-                /* NFSd runs find_fh_dentry which instantiates disconnected
-                 * dentries which are then connected without a lookup(). 
-                 * So it is possible to have connected dentries that do not 
-                 * have d_fsdata set. So we walk the list trying to find 
-                 * an alias which has its d_fsdata set and then use that 
-                 * for all the other dentries  as well. 
-                 * - SHP,Vinny. 
-                 */
-
-                /* If there is an alias with d_fsdata use it. */
-                if ((dd = presto_try_find_alias_with_dd (dentry))) {
-                        presto_set_alias_dd (dentry, dd);
-                        EXIT;
-                        goto out_unlock;
-                }
-        } else {
-                /* Negative dentry */
-                CDEBUG(D_FSDATA,"negative dentry %p: %*s\n", dentry, 
-                                dentry->d_name.len, dentry->d_name.name);
-        }
-
-        /* No pre-existing d_fsdata, we need to construct one.
-         * First, we must walk up the tree to find the fileset 
-         * If a fileset can't be found, we leave a null fsdata
-         * and return EROFS to indicate that we can't journal
-         * updates. 
-         */
-        fset = presto_try_find_fset (dentry, &is_under_d_izo);
-        if (!fset) { 
-#ifdef PRESTO_NO_NFS
-                CERROR("No fileset for dentry %p: %*s\n", dentry,
-                                dentry->d_name.len, dentry->d_name.name);
-#endif
-                error = -EROFS;
-                EXIT;
-                goto out_unlock;
-        }
-
-        dentry->d_fsdata = izo_alloc_ddata();
-        if (!presto_d2d(dentry)) {
-                CERROR ("InterMezzo: out of memory allocating d_fsdata\n");
-                error = -ENOMEM;
-                goto out_unlock;
-        }
-        presto_d2d(dentry)->dd_fset = fset;
-        if (is_under_d_izo)
-                presto_d2d(dentry)->dd_flags |= PRESTO_DONT_JOURNAL;
-        EXIT;
-
-out_unlock:    
-        CDEBUG(D_FSDATA,"presto_set_dd dentry %p: %*s, d_fsdata %p\n", 
-                        dentry, dentry->d_name.len, dentry->d_name.name, 
-                        dentry->d_fsdata);
-        unlock_kernel();
-        return error; 
-}
-
-int presto_init_ddata_cache(void)
-{
-        ENTRY;
-        presto_dentry_slab =
-                kmem_cache_create("presto_cache",
-                                  sizeof(struct presto_dentry_data), 0,
-                                  SLAB_HWCACHE_ALIGN, NULL,
-                                  NULL);
-        EXIT;
-        return (presto_dentry_slab != NULL);
-}
-
-void presto_cleanup_ddata_cache(void)
-{
-        kmem_cache_destroy(presto_dentry_slab);
-}
diff --git a/fs/intermezzo/dir.c b/fs/intermezzo/dir.c
deleted file mode 100644 (file)
index 3ec2e69..0000000
+++ /dev/null
@@ -1,1333 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2000 Stelias Computing, Inc.
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 Tacitus Systems
- *  Copyright (C) 2000 Peter J. Braam
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <asm/bitops.h>
-#include <asm/termios.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-static inline void presto_relock_sem(struct inode *dir) 
-{
-        /* the lock from sys_mkdir / lookup_create */
-        down(&dir->i_sem);
-        /* the rest is done by the do_{create,mkdir, ...} */
-}
-
-static inline void presto_relock_other(struct inode *dir) 
-{
-        /* vfs_mkdir locks */
-        //        down(&dir->i_zombie);
-        //lock_kernel(); 
-}
-
-static inline void presto_fulllock(struct inode *dir) 
-{
-        /* the lock from sys_mkdir / lookup_create */
-        down(&dir->i_sem);
-        /* vfs_mkdir locks */
-        //        down(&dir->i_zombie);
-        //lock_kernel(); 
-}
-
-static inline void presto_unlock(struct inode *dir) 
-{
-        /* vfs_mkdir locks */
-        //unlock_kernel(); 
-        //        up(&dir->i_zombie);
-        /* the lock from sys_mkdir / lookup_create */
-        up(&dir->i_sem);
-}
-
-
-/*
- * these are initialized in super.c
- */
-extern int presto_permission(struct inode *inode, int mask, struct nameidata *nd);
-static int izo_authorized_uid;
-
-int izo_dentry_is_ilookup(struct dentry *dentry, ino_t *id,
-                          unsigned int *generation)
-{
-        char tmpname[64];
-        char *next;
-
-        ENTRY;
-        /* prefix is 7 characters: '...ino:' */
-        if ( dentry->d_name.len < 7 || dentry->d_name.len > 64 ||
-             memcmp(dentry->d_name.name, PRESTO_ILOOKUP_MAGIC, 7) != 0 ) {
-                EXIT;
-                return 0;
-        }
-
-        memcpy(tmpname, dentry->d_name.name + 7, dentry->d_name.len - 7);
-        *(tmpname + dentry->d_name.len - 7) = '\0';
-
-        /* name is of the form ...ino:<inode number>:<generation> */
-        *id = simple_strtoul(tmpname, &next, 16);
-        if ( *next == PRESTO_ILOOKUP_SEP ) {
-                *generation = simple_strtoul(next + 1, 0, 16);
-                CDEBUG(D_INODE, "ino string: %s, Id = %lx (%lu), "
-                       "generation %x (%d)\n",
-                       tmpname, *id, *id, *generation, *generation);
-                EXIT;
-                return 1;
-        } else {
-                EXIT;
-                return 0;
-        }
-}
-
-struct dentry *presto_tmpfs_ilookup(struct inode *dir, 
-                                    struct dentry *dentry,
-                                    ino_t ino, 
-                                    unsigned int generation)
-{
-        return dentry; 
-}
-
-
-inline int presto_can_ilookup(void)
-{
-        return (current->euid == izo_authorized_uid ||
-                capable(CAP_DAC_READ_SEARCH));
-}
-
-struct dentry *presto_iget_ilookup(struct inode *dir, 
-                                          struct dentry *dentry,
-                                          ino_t ino, 
-                                          unsigned int generation)
-{
-        struct inode *inode;
-        int error;
-
-        ENTRY;
-
-        if ( !presto_can_ilookup() ) {
-                CERROR("ilookup denied: euid %u, authorized_uid %u\n",
-                       current->euid, izo_authorized_uid);
-                return ERR_PTR(-EPERM);
-        }
-        error = -ENOENT;
-        inode = iget(dir->i_sb, ino);
-        if (!inode) { 
-                CERROR("fatal: NULL inode ino %lu\n", ino); 
-                goto cleanup_iput;
-        }
-        if (is_bad_inode(inode) || inode->i_nlink == 0) {
-                CERROR("fatal: bad inode ino %lu, links %d\n", ino, inode->i_nlink); 
-                goto cleanup_iput;
-        }
-        if (inode->i_generation != generation) {
-                CERROR("fatal: bad generation %u (want %u)\n",
-                       inode->i_generation, generation);
-                goto cleanup_iput;
-        }
-
-        d_instantiate(dentry, inode);
-        dentry->d_flags |= DCACHE_DISCONNECTED; /* NFS hack */
-
-        EXIT;
-        return NULL;
-
-cleanup_iput:
-        if (inode)
-                iput(inode);
-        return ERR_PTR(error);
-}
-
-struct dentry *presto_add_ilookup_dentry(struct dentry *parent,
-                                         struct dentry *real)
-{
-        struct inode *inode = real->d_inode;
-        struct dentry *de;
-        char buf[32];
-        char *ptr = buf;
-        struct dentry *inodir;
-        struct presto_dentry_data *dd;
-
-        inodir = lookup_one_len("..iopen..", parent,  strlen("..iopen..")); 
-        if (!inodir || IS_ERR(inodir) || !inodir->d_inode ) { 
-                CERROR("%s: bad ..iopen.. lookup\n", __FUNCTION__); 
-                return NULL; 
-        }
-        inodir->d_inode->i_op = &presto_dir_iops;
-
-        snprintf(ptr, 32, "...ino:%lx:%x", inode->i_ino, inode->i_generation);
-
-        de = lookup_one_len(ptr, inodir,  strlen(ptr)); 
-        if (!de || IS_ERR(de)) {
-                CERROR("%s: bad ...ino lookup %ld\n", 
-                       __FUNCTION__, PTR_ERR(de)); 
-                dput(inodir);
-                return NULL; 
-        }
-
-        dd = presto_d2d(real);
-        if (!dd) 
-                BUG();
-
-        /* already exists */
-        if (de->d_inode)
-                BUG();
-#if 0 
-                if (de->d_inode != inode ) { 
-                        CERROR("XX de->d_inode %ld, inode %ld\n", 
-                               de->d_inode->i_ino, inode->i_ino); 
-                        BUG();
-                }
-                if (dd->dd_inodentry) { 
-                        CERROR("inodentry exists %ld \n", inode->i_ino);
-                        BUG();
-                }
-                dput(inodir);
-                return de;
-        }
-#endif 
-
-        if (presto_d2d(de)) 
-                BUG();
-
-        atomic_inc(&inode->i_count);
-        de->d_op = &presto_dentry_ops;
-        d_add(de, inode);
-        if (!de->d_op)
-                CERROR("DD: no ops dentry %p, dd %p\n", de, dd);
-        dd->dd_inodentry = de;
-        dd->dd_count++;
-        de->d_fsdata = dd;
-
-        dput(inodir);
-        return de;
-}
-
-struct dentry *presto_lookup(struct inode * dir, struct dentry *dentry, struct nameidata *nd)
-{
-        int rc = 0;
-        struct dentry *de;
-        struct presto_cache *cache;
-        int minor;
-        ino_t ino;
-        unsigned int generation;
-        struct inode_operations *iops;
-        int is_ilookup = 0;
-
-        ENTRY;
-        cache = presto_get_cache(dir);
-        if (cache == NULL) {
-                CERROR("InterMezzo BUG: no cache in presto_lookup "
-                       "(dir ino: %ld)!\n", dir->i_ino);
-                EXIT;
-                return NULL;
-        }
-        minor = presto_c2m(cache);
-
-        iops = filter_c2cdiops(cache->cache_filter);
-        if (!iops || !iops->lookup) {
-                CERROR("InterMezzo BUG: filesystem has no lookup\n");
-                EXIT;
-                return NULL;
-        }
-
-
-        CDEBUG(D_CACHE, "dentry %p, dir ino: %ld, name: %*s, islento: %d\n",
-               dentry, dir->i_ino, dentry->d_name.len, dentry->d_name.name,
-               ISLENTO(minor));
-
-        if (dentry->d_fsdata)
-                CERROR("DD -- BAD dentry %p has data\n", dentry);
-                       
-        dentry->d_fsdata = NULL;
-#if 0
-        if (ext2_check_for_iopen(dir, dentry))
-                de = NULL;
-        else {
-#endif
-                if ( izo_dentry_is_ilookup(dentry, &ino, &generation) ) { 
-                        de = cache->cache_filter->o_trops->tr_ilookup
-                                (dir, dentry, ino, generation);
-                        is_ilookup = 1;
-                } else
-                        de = iops->lookup(dir, dentry, nd);
-#if 0
-        }
-#endif
-
-        if ( IS_ERR(de) ) {
-                CERROR("dentry lookup error %ld\n", PTR_ERR(de));
-                return de;
-        }
-
-        /* some file systems have no read_inode: set methods here */
-        if (dentry->d_inode)
-                presto_set_ops(dentry->d_inode, cache->cache_filter);
-
-        filter_setup_dentry_ops(cache->cache_filter,
-                                dentry->d_op, &presto_dentry_ops);
-        dentry->d_op = filter_c2udops(cache->cache_filter);
-
-        /* In lookup we will tolerate EROFS return codes from presto_set_dd
-         * to placate NFS. EROFS indicates that a fileset was not found but
-         * we should still be able to continue through a lookup.
-         * Anything else is a hard error and must be returned to VFS. */
-        if (!is_ilookup)
-                rc = presto_set_dd(dentry);
-        if (rc && rc != -EROFS) {
-                CERROR("presto_set_dd failed (dir %ld, name %*s): %d\n",
-                       dir->i_ino, dentry->d_name.len, dentry->d_name.name, rc);
-                return ERR_PTR(rc);
-        }
-
-        EXIT;
-        return NULL;
-}
-
-static inline int presto_check_set_fsdata (struct dentry *de)
-{
-        if (presto_d2d(de) == NULL) {
-#ifdef PRESTO_NO_NFS
-                CERROR("dentry without fsdata: %p: %*s\n", de, 
-                                de->d_name.len, de->d_name.name);
-                BUG();
-#endif
-                return presto_set_dd (de);
-        }
-
-        return 0;
-}
-
-int presto_setattr(struct dentry *de, struct iattr *iattr)
-{
-        int error;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct lento_vfs_context info = { 0, {0}, 0 };
-
-        ENTRY;
-
-        error = presto_prep(de, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        if (!iattr->ia_valid)
-                CDEBUG(D_INODE, "presto_setattr: iattr is not valid\n");
-
-        CDEBUG(D_INODE, "valid %#x, mode %#o, uid %u, gid %u, size %Lu, "
-               "atime %lu mtime %lu ctime %lu flags %d\n",
-               iattr->ia_valid, iattr->ia_mode, iattr->ia_uid, iattr->ia_gid,
-               iattr->ia_size, iattr->ia_atime.tv_sec, iattr->ia_mtime.tv_sec,
-               iattr->ia_ctime.tv_sec, iattr->ia_attr_flags);
-        
-        if ( presto_get_permit(de->d_inode) < 0 ) {
-                EXIT;
-                return -EROFS;
-        }
-
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-        error = presto_do_setattr(fset, de, iattr, &info);
-        presto_put_permit(de->d_inode);
-        return error;
-}
-
-/*
- *  Now the meat: the fs operations that require journaling
- *
- *
- *  XXX: some of these need modifications for hierarchical filesets
- */
-
-int presto_prep(struct dentry *dentry, struct presto_cache **cache,
-                struct presto_file_set **fset)
-{       
-        int rc;
-
-        /* NFS might pass us dentries which have not gone through lookup.
-         * Test and set d_fsdata for such dentries
-         */
-        rc = presto_check_set_fsdata (dentry);
-        if (rc) return rc;
-
-        *fset = presto_fset(dentry);
-        if ( *fset == NULL ) {
-                CERROR("No file set for dentry at %p: %*s\n", dentry,
-                                dentry->d_name.len, dentry->d_name.name);
-                return -EROFS;
-        }
-
-        *cache = (*fset)->fset_cache;
-        if ( *cache == NULL ) {
-                CERROR("PRESTO: BAD, BAD: cannot find cache\n");
-                return -EBADF;
-        }
-
-        CDEBUG(D_PIOCTL, "---> cache flags %x, fset flags %x\n",
-              (*cache)->cache_flags, (*fset)->fset_flags);
-        if( presto_is_read_only(*fset) ) {
-                CERROR("PRESTO: cannot modify read-only fileset, minor %d.\n",
-                       presto_c2m(*cache));
-                return -EROFS;
-        }
-        return 0;
-}
-
-static int presto_create(struct inode * dir, struct dentry * dentry, int mode,
-                struct nameidata *nd)
-{
-        int error;
-        struct presto_cache *cache;
-        struct dentry *parent = dentry->d_parent;
-        struct lento_vfs_context info;
-        struct presto_file_set *fset;
-
-        ENTRY;
-        error = presto_check_set_fsdata(dentry);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_prep(dentry->d_parent, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-        presto_unlock(dir);
-
-        /* Does blocking and non-blocking behavious need to be 
-           checked for.  Without blocking (return 1), the permit
-           was acquired without reintegration
-        */
-        if ( presto_get_permit(dir) < 0 ) {
-                EXIT;
-                presto_fulllock(dir);
-                return -EROFS;
-        }
-
-        presto_relock_sem(dir);
-        parent = dentry->d_parent; 
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-        error = presto_do_create(fset, parent, dentry, mode, &info);
-
-        presto_relock_other(dir);
-        presto_put_permit(dir);
-        EXIT;
-        return error;
-}
-
-static int presto_link(struct dentry *old_dentry, struct inode *dir,
-                struct dentry *new_dentry)
-{
-        int error;
-        struct presto_cache *cache, *new_cache;
-        struct presto_file_set *fset, *new_fset;
-        struct dentry *parent = new_dentry->d_parent;
-        struct lento_vfs_context info;
-
-        ENTRY;
-        error = presto_prep(old_dentry, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_check_set_fsdata(new_dentry);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_prep(new_dentry->d_parent, &new_cache, &new_fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        if (fset != new_fset) { 
-                EXIT;
-                return -EXDEV;
-        }
-
-        presto_unlock(dir);
-        if ( presto_get_permit(old_dentry->d_inode) < 0 ) {
-                EXIT;
-                presto_fulllock(dir);
-                return -EROFS;
-        }
-
-        if ( presto_get_permit(dir) < 0 ) {
-                EXIT;
-                presto_fulllock(dir);
-                return -EROFS;
-        }
-
-        presto_relock_sem(dir);
-        parent = new_dentry->d_parent;
-
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-        error = presto_do_link(fset, old_dentry, parent,
-                               new_dentry, &info);
-
-#if 0
-        /* XXX for links this is not right */
-        if (cache->cache_filter->o_trops->tr_add_ilookup ) { 
-                struct dentry *d;
-                d = cache->cache_filter->o_trops->tr_add_ilookup
-                        (dir->i_sb->s_root, new_dentry, 1); 
-        }
-#endif 
-
-        presto_relock_other(dir);
-        presto_put_permit(dir);
-        presto_put_permit(old_dentry->d_inode);
-        return error;
-}
-
-static int presto_mkdir(struct inode * dir, struct dentry * dentry, int mode)
-{
-        int error;
-        struct presto_file_set *fset;
-        struct presto_cache *cache;
-        struct dentry *parent = dentry->d_parent;
-        struct lento_vfs_context info;
-
-        ENTRY;
-
-        error = presto_check_set_fsdata(dentry);
-        if ( error  ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_prep(dentry->d_parent, &cache, &fset);
-        if ( error  ) {
-                EXIT;
-                return error;
-        }
-
-        presto_unlock(dir); 
-
-        if ( presto_get_permit(dir) < 0 ) {
-                EXIT;
-                presto_fulllock(dir);
-                return -EROFS;
-        }
-
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-
-        presto_relock_sem(dir); 
-        parent = dentry->d_parent;
-        error = presto_do_mkdir(fset, parent, dentry, mode, &info);
-        presto_relock_other(dir); 
-        presto_put_permit(dir);
-        return error;
-}
-
-
-
-static int presto_symlink(struct inode *dir, struct dentry *dentry,
-                   const char *name)
-{
-        int error;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct dentry *parent = dentry->d_parent;
-        struct lento_vfs_context info;
-
-        ENTRY;
-        error = presto_check_set_fsdata(dentry);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_prep(dentry->d_parent, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        presto_unlock(dir);
-        if ( presto_get_permit(dir) < 0 ) {
-                EXIT;
-                presto_fulllock(dir);
-                return -EROFS;
-        }
-
-        presto_relock_sem(dir);
-        parent = dentry->d_parent;
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-        error = presto_do_symlink(fset, parent, dentry, name, &info);
-        presto_relock_other(dir);
-        presto_put_permit(dir);
-        return error;
-}
-
-int presto_unlink(struct inode *dir, struct dentry *dentry)
-{
-        int error;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct dentry *parent = dentry->d_parent;
-        struct lento_vfs_context info;
-
-        ENTRY;
-        error = presto_check_set_fsdata(dentry);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_prep(dentry->d_parent, &cache, &fset);
-        if ( error  ) {
-                EXIT;
-                return error;
-        }
-
-        presto_unlock(dir);
-        if ( presto_get_permit(dir) < 0 ) {
-                EXIT;
-                presto_fulllock(dir);
-                return -EROFS;
-        }
-
-        presto_relock_sem(dir);
-        parent = dentry->d_parent;
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-
-        error = presto_do_unlink(fset, parent, dentry, &info);
-
-        presto_relock_other(dir);
-        presto_put_permit(dir);
-        return error;
-}
-
-static int presto_rmdir(struct inode *dir, struct dentry *dentry)
-{
-        int error;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct dentry *parent = dentry->d_parent;
-        struct lento_vfs_context info;
-
-        ENTRY;
-        CDEBUG(D_FILE, "prepping presto\n");
-        error = presto_check_set_fsdata(dentry);
-
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_prep(dentry->d_parent, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        CDEBUG(D_FILE, "unlocking\n");
-        /* We need to dget() before the dput in double_unlock, to ensure we
-         * still have dentry references.  double_lock doesn't do dget for us.
-         */
-        if (d_unhashed(dentry))
-                d_rehash(dentry);
-        //        double_up(&dir->i_zombie, &dentry->d_inode->i_zombie);
-        up(&dentry->d_inode->i_sem);
-        up(&dir->i_sem);
-
-        CDEBUG(D_FILE, "getting permit\n");
-        if ( presto_get_permit(parent->d_inode) < 0 ) {
-                EXIT;
-                down(&dir->i_sem);
-                down(&dentry->d_inode->i_sem);
-                //                double_down(&dir->i_sem, &dentry->d_inode->i_sem);
-                //                double_down(&dir->i_zombie, &dentry->d_inode->i_zombie);
-                
-                lock_kernel();
-                return -EROFS;
-        }
-        CDEBUG(D_FILE, "locking\n");
-
-        down(&dir->i_sem);
-        down(&dentry->d_inode->i_sem);
-        parent = dentry->d_parent;
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-        error = presto_do_rmdir(fset, parent, dentry, &info);
-        presto_put_permit(parent->d_inode);
-        lock_kernel();
-        EXIT;
-        return error;
-}
-
-static int presto_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_t rdev)
-{
-        int error;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct dentry *parent = dentry->d_parent;
-        struct lento_vfs_context info;
-
-       if (!old_valid_dev(rdev))
-               return -EINVAL;
-
-        ENTRY;
-        error = presto_check_set_fsdata(dentry);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_prep(dentry->d_parent, &cache, &fset);
-        if ( error  ) {
-                EXIT;
-                return error;
-        }
-
-        presto_unlock(dir);
-        if ( presto_get_permit(dir) < 0 ) {
-                EXIT;
-                presto_fulllock(dir);
-                return -EROFS;
-        }
-        
-        presto_relock_sem(dir);
-        parent = dentry->d_parent;
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-        error = presto_do_mknod(fset, parent, dentry, mode, rdev, &info);
-        presto_relock_other(dir);
-        presto_put_permit(dir);
-        EXIT;
-        return error;
-}
-
-
-
-// XXX this can be optimized: renamtes across filesets only require 
-//     multiple KML records, but can locally be executed normally. 
-int presto_rename(struct inode *old_dir, struct dentry *old_dentry,
-                  struct inode *new_dir, struct dentry *new_dentry)
-{
-        int error;
-        struct presto_cache *cache, *new_cache;
-        struct presto_file_set *fset, *new_fset;
-        struct lento_vfs_context info;
-        struct dentry *old_parent = old_dentry->d_parent;
-        struct dentry *new_parent = new_dentry->d_parent;
-        int triple;
-
-        ENTRY;
-        error = presto_prep(old_dentry, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-        error = presto_prep(new_parent, &new_cache, &new_fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        if ( fset != new_fset ) {
-                EXIT;
-                return -EXDEV;
-        }
-
-        /* We need to do dget before the dput in double_unlock, to ensure we
-         * still have dentry references.  double_lock doesn't do dget for us.
-         */
-
-        triple = (S_ISDIR(old_dentry->d_inode->i_mode) && new_dentry->d_inode)?
-                1:0;
-
-        unlock_rename(new_dentry->d_parent, old_dentry->d_parent);
-
-        if ( presto_get_permit(old_dir) < 0 ) {
-                EXIT;
-                return -EROFS;
-        }
-        if ( presto_get_permit(new_dir) < 0 ) {
-                EXIT;
-                return -EROFS;
-        }
-
-        lock_rename(new_dentry->d_parent, old_dentry->d_parent);
-        memset(&info, 0, sizeof(info));
-        if (!ISLENTO(presto_c2m(cache)))
-                info.flags = LENTO_FL_KML;
-        info.flags |= LENTO_FL_IGNORE_TIME;
-        error = do_rename(fset, old_parent, old_dentry, new_parent,
-                          new_dentry, &info);
-
-        presto_put_permit(new_dir);
-        presto_put_permit(old_dir);
-        return error;
-}
-
-/* basically this allows the ilookup processes access to all files for
- * reading, while not making ilookup totally insecure.  This could all
- * go away if we could set the CAP_DAC_READ_SEARCH capability for the client.
- */
-/* If posix acls are available, the underlying cache fs will export the
- * appropriate permission function. Thus we do not worry here about ACLs
- * or EAs. -SHP
- */
-int presto_permission(struct inode *inode, int mask, struct nameidata *nd)
-{
-        unsigned short mode = inode->i_mode;
-        struct presto_cache *cache;
-        int rc;
-
-        ENTRY;
-        if ( presto_can_ilookup() && !(mask & S_IWOTH)) {
-                CDEBUG(D_CACHE, "ilookup on %ld OK\n", inode->i_ino);
-                EXIT;
-                return 0;
-        }
-
-        cache = presto_get_cache(inode);
-
-        if ( cache ) {
-                /* we only override the file/dir permission operations */
-                struct inode_operations *fiops = filter_c2cfiops(cache->cache_filter);
-                struct inode_operations *diops = filter_c2cdiops(cache->cache_filter);
-
-                if ( S_ISREG(mode) && fiops && fiops->permission ) {
-                        EXIT;
-                        return fiops->permission(inode, mask, nd);
-                }
-                if ( S_ISDIR(mode) && diops && diops->permission ) {
-                        EXIT;
-                        return diops->permission(inode, mask, nd);
-                }
-        }
-
-        /* The cache filesystem doesn't have its own permission function,
-         * so we call the default one.
-         */
-        rc = vfs_permission(inode, mask);
-
-        EXIT;
-        return rc;
-}
-
-
-int presto_ioctl(struct inode *inode, struct file *file,
-                        unsigned int cmd, unsigned long arg)
-{
-        char buf[1024];
-        struct izo_ioctl_data *data = NULL;
-        struct presto_dentry_data *dd;
-        int rc;
-
-        ENTRY;
-
-        /* Try the filesystem's ioctl first, and return if it succeeded. */
-        dd = presto_d2d(file->f_dentry); 
-        if (dd && dd->dd_fset) { 
-                int (*cache_ioctl)(struct inode *, struct file *, unsigned int, unsigned long ) = filter_c2cdfops(dd->dd_fset->fset_cache->cache_filter)->ioctl;
-                rc = -ENOTTY;
-                if (cache_ioctl)
-                        rc = cache_ioctl(inode, file, cmd, arg);
-                if (rc != -ENOTTY) {
-                        EXIT;
-                        return rc;
-                }
-        }
-
-        if (current->euid != 0 && current->euid != izo_authorized_uid) {
-                EXIT;
-                return -EPERM;
-        }
-
-        memset(buf, 0, sizeof(buf));
-        
-        if (izo_ioctl_getdata(buf, buf + 1024, (void *)arg)) { 
-                CERROR("intermezzo ioctl: data error\n");
-                return -EINVAL;
-        }
-        data = (struct izo_ioctl_data *)buf;
-        
-        switch(cmd) {
-        case IZO_IOC_REINTKML: { 
-                int rc;
-                int cperr;
-                rc = kml_reint_rec(file, data);
-
-                EXIT;
-                cperr = copy_to_user((char *)arg, data, sizeof(*data));
-                if (cperr) { 
-                        CERROR("WARNING: cperr %d\n", cperr); 
-                        rc = -EFAULT;
-                }
-                return rc;
-        }
-
-        case IZO_IOC_GET_RCVD: {
-                struct izo_rcvd_rec rec;
-                struct presto_file_set *fset;
-                int rc;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                rc = izo_rcvd_get(&rec, fset, data->ioc_uuid);
-                if (rc < 0) {
-                        EXIT;
-                        return rc;
-                }
-
-                EXIT;
-                return copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0;
-        }
-
-        case IZO_IOC_REPSTATUS: {
-                __u64 client_kmlsize;
-                struct izo_rcvd_rec *lr_client;
-                struct izo_rcvd_rec rec;
-                struct presto_file_set *fset;
-                int minor;
-                int rc;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                client_kmlsize = data->ioc_kmlsize;
-                lr_client =  (struct izo_rcvd_rec *) data->ioc_pbuf1;
-
-                rc = izo_repstatus(fset, client_kmlsize, 
-                                       lr_client, &rec);
-                if (rc < 0) {
-                        EXIT;
-                        return rc;
-                }
-
-                EXIT;
-                return copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0;
-        }
-
-        case IZO_IOC_GET_CHANNEL: {
-                struct presto_file_set *fset;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                
-                data->ioc_dev = fset->fset_cache->cache_psdev->uc_minor;
-                CDEBUG(D_PSDEV, "CHANNEL %d\n", data->ioc_dev); 
-                EXIT;
-                return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0;
-        }
-
-        case IZO_IOC_SET_IOCTL_UID:
-                izo_authorized_uid = data->ioc_uid;
-                EXIT;
-                return 0;
-
-        case IZO_IOC_SET_PID:
-                rc = izo_psdev_setpid(data->ioc_dev);
-                EXIT;
-                return rc;
-
-        case IZO_IOC_SET_CHANNEL:
-                rc = izo_psdev_setchannel(file, data->ioc_dev);
-                EXIT;
-                return rc;
-
-        case IZO_IOC_GET_KML_SIZE: {
-                struct presto_file_set *fset;
-                __u64 kmlsize;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-
-                kmlsize = presto_kml_offset(fset) + fset->fset_kml_logical_off;
-
-                EXIT;
-                return copy_to_user((char *)arg, &kmlsize, sizeof(kmlsize))?-EFAULT : 0;
-        }
-
-        case IZO_IOC_PURGE_FILE_DATA: {
-                struct presto_file_set *fset;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-
-                rc = izo_purge_file(fset, data->ioc_inlbuf1);
-                EXIT;
-                return rc;
-        }
-
-        case IZO_IOC_GET_FILEID: {
-                rc = izo_get_fileid(file, data);
-                EXIT;
-                if (rc)
-                        return rc;
-                return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0;
-        }
-
-        case IZO_IOC_SET_FILEID: {
-                rc = izo_set_fileid(file, data);
-                EXIT;
-                if (rc)
-                        return rc;
-                return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT  : 0;
-        }
-
-        case IZO_IOC_ADJUST_LML: { 
-                struct lento_vfs_context *info; 
-                info = (struct lento_vfs_context *)data->ioc_inlbuf1;
-                rc = presto_adjust_lml(file, info); 
-                EXIT;
-                return rc;
-        }
-
-        case IZO_IOC_CONNECT: {
-                struct presto_file_set *fset;
-                int minor;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                rc = izo_upc_connect(minor, data->ioc_ino,
-                                     data->ioc_generation, data->ioc_uuid,
-                                     data->ioc_flags);
-                EXIT;
-                return rc;
-        }
-
-        case IZO_IOC_GO_FETCH_KML: {
-                struct presto_file_set *fset;
-                int minor;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                rc = izo_upc_go_fetch_kml(minor, fset->fset_name,
-                                          data->ioc_uuid, data->ioc_kmlsize);
-                EXIT;
-                return rc;
-        }
-
-        case IZO_IOC_REVOKE_PERMIT:
-                if (data->ioc_flags)
-                        rc = izo_revoke_permit(file->f_dentry, data->ioc_uuid);
-                else
-                        rc = izo_revoke_permit(file->f_dentry, NULL);
-                EXIT;
-                return rc;
-
-        case IZO_IOC_CLEAR_FSET:
-                rc = izo_clear_fsetroot(file->f_dentry);
-                EXIT;
-                return rc;
-
-        case IZO_IOC_CLEAR_ALL_FSETS: { 
-                struct presto_file_set *fset;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-
-                rc = izo_clear_all_fsetroots(fset->fset_cache);
-                EXIT;
-                return rc;
-        }
-
-        case IZO_IOC_SET_FSET:
-                /*
-                 * Mark this dentry as being a fileset root.
-                 */
-                rc = presto_set_fsetroot_from_ioc(file->f_dentry, 
-                                                  data->ioc_inlbuf1,
-                                                  data->ioc_flags);
-                EXIT;
-                return rc;
-
-
-        case IZO_IOC_MARK: {
-                int res = 0;  /* resulting flags - returned to user */
-                int error;
-
-                CDEBUG(D_DOWNCALL, "mark inode: %ld, and: %x, or: %x, what %d\n",
-                       file->f_dentry->d_inode->i_ino, data->ioc_and_flag,
-                       data->ioc_or_flag, data->ioc_mark_what);
-
-                switch (data->ioc_mark_what) {
-                case MARK_DENTRY:               
-                        error = izo_mark_dentry(file->f_dentry,
-                                                   data->ioc_and_flag,
-                                                   data->ioc_or_flag, &res);
-                        break;
-                case MARK_FSET:
-                        error = izo_mark_fset(file->f_dentry,
-                                                 data->ioc_and_flag,
-                                                 data->ioc_or_flag, &res);
-                        break;
-                case MARK_CACHE:
-                        error = izo_mark_cache(file->f_dentry,
-                                                  data->ioc_and_flag,
-                                                  data->ioc_or_flag, &res);
-                        break;
-                case MARK_GETFL: {
-                        int fflags, cflags;
-                        data->ioc_and_flag = 0xffffffff;
-                        data->ioc_or_flag = 0; 
-                        error = izo_mark_dentry(file->f_dentry,
-                                                   data->ioc_and_flag,
-                                                   data->ioc_or_flag, &res);
-                        if (error) 
-                                break;
-                        error = izo_mark_fset(file->f_dentry,
-                                                 data->ioc_and_flag,
-                                                 data->ioc_or_flag, &fflags);
-                        if (error) 
-                                break;
-                        error = izo_mark_cache(file->f_dentry,
-                                                  data->ioc_and_flag,
-                                                  data->ioc_or_flag,
-                                                  &cflags);
-
-                        if (error) 
-                                break;
-                        data->ioc_and_flag = fflags;
-                        data->ioc_or_flag = cflags;
-                        break;
-                }
-                default:
-                        error = -EINVAL;
-                }
-
-                if (error) { 
-                        EXIT;
-                        return error;
-                }
-                data->ioc_mark_what = res;
-                CDEBUG(D_DOWNCALL, "mark inode: %ld, and: %x, or: %x, what %x\n",
-                       file->f_dentry->d_inode->i_ino, data->ioc_and_flag,
-                       data->ioc_or_flag, data->ioc_mark_what);
-
-                EXIT;
-                return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0;
-        }
-#if 0
-        case IZO_IOC_CLIENT_MAKE_BRANCH: {
-                struct presto_file_set *fset;
-                int minor;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                rc = izo_upc_client_make_branch(minor, fset->fset_name,
-                                                data->ioc_inlbuf1,
-                                                data->ioc_inlbuf2);
-                EXIT;
-                return rc;
-        }
-#endif
-        case IZO_IOC_SERVER_MAKE_BRANCH: {
-                struct presto_file_set *fset;
-                int minor;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                izo_upc_server_make_branch(minor, data->ioc_inlbuf1);
-                EXIT;
-                return 0;
-        }
-        case IZO_IOC_SET_KMLSIZE: {
-                struct presto_file_set *fset;
-                int minor;
-                struct izo_rcvd_rec rec;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                rc = izo_upc_set_kmlsize(minor, fset->fset_name, data->ioc_uuid,
-                                         data->ioc_kmlsize);
-
-                if (rc != 0) {
-                        EXIT;
-                        return rc;
-                }
-
-                rc = izo_rcvd_get(&rec, fset, data->ioc_uuid);
-                if (rc == -EINVAL) {
-                        /* We don't know anything about this uuid yet; no
-                         * worries. */
-                        memset(&rec, 0, sizeof(rec));
-                } else if (rc <= 0) {
-                        CERROR("InterMezzo: error reading last_rcvd: %d\n", rc);
-                        EXIT;
-                        return rc;
-                }
-                rec.lr_remote_offset = data->ioc_kmlsize;
-                rc = izo_rcvd_write(fset, &rec);
-                if (rc <= 0) {
-                        CERROR("InterMezzo: error writing last_rcvd: %d\n", rc);
-                        EXIT;
-                        return rc;
-                }
-                EXIT;
-                return rc;
-        }
-        case IZO_IOC_BRANCH_UNDO: {
-                struct presto_file_set *fset;
-                int minor;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                rc = izo_upc_branch_undo(minor, fset->fset_name,
-                                         data->ioc_inlbuf1);
-                EXIT;
-                return rc;
-        }
-        case IZO_IOC_BRANCH_REDO: {
-                struct presto_file_set *fset;
-                int minor;
-
-                fset = presto_fset(file->f_dentry);
-                if (fset == NULL) {
-                        EXIT;
-                        return -ENODEV;
-                }
-                minor = presto_f2m(fset);
-
-                rc = izo_upc_branch_redo(minor, fset->fset_name,
-                                         data->ioc_inlbuf1);
-                EXIT;
-                return rc;
-        }
-
-        default:
-                EXIT;
-                return -ENOTTY;
-                
-        }
-        EXIT;
-        return 0;
-}
-
-struct file_operations presto_dir_fops = {
-        .ioctl =  presto_ioctl
-};
-
-struct inode_operations presto_dir_iops = {
-        .create       = presto_create,
-        .lookup       = presto_lookup,
-        .link         = presto_link,
-        .unlink       = presto_unlink,
-        .symlink      = presto_symlink,
-        .mkdir        = presto_mkdir,
-        .rmdir        = presto_rmdir,
-        .mknod        = presto_mknod,
-        .rename       = presto_rename,
-        .permission   = presto_permission,
-        .setattr      = presto_setattr,
-#ifdef CONFIG_FS_EXT_ATTR
-        .set_ext_attr = presto_set_ext_attr,
-#endif
-};
-
-
diff --git a/fs/intermezzo/ext_attr.c b/fs/intermezzo/ext_attr.c
deleted file mode 100644 (file)
index be91417..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- * 
- *  Copyright (C) 2001 Tacit Networks, Inc.
- *    Author: Shirish H. Phatak <shirish@tacitnetworks.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Extended attribute handling for presto.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/unistd.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <asm/segment.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef CONFIG_FS_EXT_ATTR
-#include <linux/ext_attr.h>
-
-extern inline void presto_debug_fail_blkdev(struct presto_file_set *fset,
-                                            unsigned long value);
-
-
-/* VFS interface */
-/* XXX! Fixme test for user defined attributes */
-int presto_set_ext_attr(struct inode *inode, 
-                        const char *name, void *buffer,
-                        size_t buffer_len, int flags) 
-{
-        int error;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct lento_vfs_context info;
-        struct dentry *dentry;
-        int minor = presto_i2m(inode);
-        char *buf = NULL;
-
-        ENTRY;
-        if (minor < 0) {
-                EXIT;
-                return -1;
-        }
-
-        if ( ISLENTO(minor) ) {
-                EXIT;
-                return -EINVAL;
-        }
-
-        /* BAD...vfs should really pass down the dentry to use, especially
-         * since every other operation in iops does. But for now
-         * we do a reverse mapping from inode to the first dentry 
-         */
-        if (list_empty(&inode->i_dentry)) {
-                CERROR("No alias for inode %d\n", (int) inode->i_ino);
-                EXIT;
-                return -EINVAL;
-        }
-
-        dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-
-        error = presto_prep(dentry, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        if ((buffer != NULL) && (buffer_len != 0)) {
-            /* If buffer is a user space pointer copy it to kernel space
-            * and reset the flag. We do this since the journal functions need
-            * access to the contents of the buffer, and the file system
-            * does not care. When we actually invoke the function, we remove
-            * the EXT_ATTR_FLAG_USER flag.
-            *
-            * XXX:Check if the "fs does not care" assertion is always true -SHP
-            * (works for ext3)
-            */
-            if (flags & EXT_ATTR_FLAG_USER) {
-                PRESTO_ALLOC(buf, buffer_len);
-                if (!buf) {
-                        CERROR("InterMezzo: out of memory!!!\n");
-                        return -ENOMEM;
-                }
-                error = copy_from_user(buf, buffer, buffer_len);
-                if (error) 
-                        return -EFAULT;
-            } else 
-                buf = buffer;
-        } else
-                buf = buffer;
-
-        if ( presto_get_permit(inode) < 0 ) {
-                EXIT;
-                if (buffer_len && (flags & EXT_ATTR_FLAG_USER))
-                        PRESTO_FREE(buf, buffer_len);
-                return -EROFS;
-        }
-
-        /* Simulate presto_setup_info */
-        memset(&info, 0, sizeof(info));
-        /* For now redundant..but we keep it around just in case */
-        info.flags = LENTO_FL_IGNORE_TIME;
-        if (!ISLENTO(cache->cache_psdev->uc_minor))
-            info.flags |= LENTO_FL_KML;
-
-        /* We pass in the kernel space pointer and reset the 
-         * EXT_ATTR_FLAG_USER flag.
-         * See comments above. 
-         */ 
-        /* Note that mode is already set by VFS so we send in a NULL */
-        error = presto_do_set_ext_attr(fset, dentry, name, buf,
-                                       buffer_len, flags & ~EXT_ATTR_FLAG_USER,
-                                       NULL, &info);
-        presto_put_permit(inode);
-
-        if (buffer_len && (flags & EXT_ATTR_FLAG_USER))
-                PRESTO_FREE(buf, buffer_len);
-        EXIT;
-        return error;
-}
-
-/* Lento Interface */
-/* XXX: ignore flags? We should be forcing these operations through? -SHP*/
-int lento_set_ext_attr(const char *path, const char *name, 
-                       void *buffer, size_t buffer_len, int flags, mode_t mode, 
-                       struct lento_vfs_context *info) 
-{
-        int error;
-        char * pathname;
-        struct nameidata nd;
-        struct dentry *dentry;
-        struct presto_file_set *fset;
-
-        ENTRY;
-        lock_kernel();
-
-        pathname=getname(path);
-        error = PTR_ERR(pathname);
-        if (IS_ERR(pathname)) {
-                EXIT;
-                goto exit;
-        }
-
-        /* Note that ext_attrs apply to both files and directories..*/
-        error=presto_walk(pathname,&nd);
-        if (error) 
-               goto exit;
-        dentry = nd.dentry;
-
-        fset = presto_fset(dentry);
-        error = -EINVAL;
-        if ( !fset ) {
-                CERROR("No fileset!\n");
-                EXIT;
-                goto exit_dentry;
-        }
-
-        if (buffer==NULL) buffer_len=0;
-
-        error = presto_do_set_ext_attr(fset, dentry, name, buffer,
-                                       buffer_len, flags, &mode, info);
-exit_dentry:
-        path_release(&nd);
-exit_path:
-        putname(pathname);
-exit:
-        unlock_kernel();
-        return error; 
-}
-
-#endif /*CONFIG_FS_EXT_ATTR*/
diff --git a/fs/intermezzo/file.c b/fs/intermezzo/file.c
deleted file mode 100644 (file)
index f625642..0000000
+++ /dev/null
@@ -1,534 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2000 Stelias Computing, Inc.
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 TurboLinux, Inc.
- *  Copyright (C) 2000 Los Alamos National Laboratory.
- *  Copyright (C) 2000, 2001 Tacit Networks, Inc.
- *  Copyright (C) 2000 Peter J. Braam
- *  Copyright (C) 2001 Mountain View Data, Inc. 
- *  Copyright (C) 2001 Cluster File Systems, Inc. 
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  This file manages file I/O
- * 
- */
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include <linux/fsfilter.h>
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-/*
- * these are initialized in super.c
- */
-extern int presto_permission(struct inode *inode, int mask, struct nameidata *nd);
-
-
-static int presto_open_upcall(int minor, struct dentry *de)
-{
-        int rc = 0;
-        char *path, *buffer;
-        struct presto_file_set *fset;
-        int pathlen;
-        struct lento_vfs_context info;
-        struct presto_dentry_data *dd = presto_d2d(de);
-
-        PRESTO_ALLOC(buffer, PAGE_SIZE);
-        if ( !buffer ) {
-                CERROR("PRESTO: out of memory!\n");
-                return -ENOMEM;
-        }
-        fset = presto_fset(de);
-        path = presto_path(de, fset->fset_dentry, buffer, PAGE_SIZE);
-        pathlen = MYPATHLEN(buffer, path);
-        
-        CDEBUG(D_FILE, "de %p, dd %p\n", de, dd);
-        if (dd->remote_ino == 0) {
-                rc = presto_get_fileid(minor, fset, de);
-        }
-        memset (&info, 0, sizeof(info));
-        if (dd->remote_ino > 0) {
-                info.remote_ino = dd->remote_ino;
-                info.remote_generation = dd->remote_generation;
-        } else
-                CERROR("get_fileid failed %d, ino: %Lx, fetching by name\n", rc,
-                       (unsigned long long) dd->remote_ino);
-
-        rc = izo_upc_open(minor, pathlen, path, fset->fset_name, &info);
-        PRESTO_FREE(buffer, PAGE_SIZE);
-        return rc;
-}
-
-static inline int open_check_dod(struct file *file,
-                                 struct presto_file_set *fset)
-{
-        int gen, is_iopen = 0, minor;
-        struct presto_cache *cache = fset->fset_cache;
-        ino_t inum;
-
-        minor = presto_c2m(cache);
-
-        if ( ISLENTO(minor) ) {
-                CDEBUG(D_CACHE, "is lento, not doing DOD.\n");
-                return 0;
-        }
-
-        /* Files are only ever opened by inode during backfetches, when by
-         * definition we have the authoritative copy of the data.  No DOD. */
-        is_iopen = izo_dentry_is_ilookup(file->f_dentry, &inum, &gen);
-
-        if (is_iopen) {
-                CDEBUG(D_CACHE, "doing iopen, not doing DOD.\n");
-                return 0;
-        }
-
-        if (!(fset->fset_flags & FSET_DATA_ON_DEMAND)) {
-                CDEBUG(D_CACHE, "fileset not on demand.\n");
-                return 0;
-        }
-                
-        if (file->f_flags & O_TRUNC) {
-                CDEBUG(D_CACHE, "fileset dod: O_TRUNC.\n");
-                return 0;
-        }
-                
-        if (presto_chk(file->f_dentry, PRESTO_DONT_JOURNAL)) {
-                CDEBUG(D_CACHE, "file under .intermezzo, not doing DOD\n");
-                return 0;
-        }
-
-        if (presto_chk(file->f_dentry, PRESTO_DATA)) {
-                CDEBUG(D_CACHE, "PRESTO_DATA is set, not doing DOD.\n");
-                return 0;
-        }
-
-        if (cache->cache_filter->o_trops->tr_all_data(file->f_dentry->d_inode)) {
-                CDEBUG(D_CACHE, "file not sparse, not doing DOD.\n");
-                return 0;
-        }
-
-        return 1;
-}
-
-static int presto_file_open(struct inode *inode, struct file *file)
-{
-        int rc = 0;
-        struct file_operations *fops;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct presto_file_data *fdata;
-        int writable = (file->f_flags & (O_RDWR | O_WRONLY));
-        int minor, i;
-
-        ENTRY;
-
-        if (presto_prep(file->f_dentry, &cache, &fset) < 0) {
-                EXIT;
-                return -EBADF;
-        }
-
-        minor = presto_c2m(cache);
-
-        CDEBUG(D_CACHE, "DATA_OK: %d, ino: %ld, islento: %d\n",
-               presto_chk(file->f_dentry, PRESTO_DATA), inode->i_ino,
-               ISLENTO(minor));
-
-        if ( !ISLENTO(minor) && (file->f_flags & O_RDWR ||
-                                 file->f_flags & O_WRONLY)) {
-                CDEBUG(D_CACHE, "calling presto_get_permit\n");
-                if ( presto_get_permit(inode) < 0 ) {
-                        EXIT;
-                        return -EROFS;
-                }
-                presto_put_permit(inode);
-        }
-
-        if (open_check_dod(file, fset)) {
-                CDEBUG(D_CACHE, "presto_open_upcall\n");
-                CDEBUG(D_CACHE, "dentry: %p setting DATA, ATTR\n", file->f_dentry);
-                presto_set(file->f_dentry, PRESTO_ATTR | PRESTO_DATA);
-                rc = presto_open_upcall(minor, file->f_dentry);
-                if (rc) {
-                        EXIT;
-                        CERROR("%s: returning error %d\n", __FUNCTION__, rc);
-                        return rc;
-                }
-
-        }
-
-        /* file was truncated upon open: do not refetch */
-        if (file->f_flags & O_TRUNC) { 
-                CDEBUG(D_CACHE, "setting DATA, ATTR\n");
-                presto_set(file->f_dentry, PRESTO_ATTR | PRESTO_DATA);
-        }
-
-        fops = filter_c2cffops(cache->cache_filter);
-        if ( fops->open ) {
-                CDEBUG(D_CACHE, "calling fs open\n");
-                rc = fops->open(inode, file);
-
-                if (rc) {
-                        EXIT;
-                        return rc;
-                }
-        }
-
-        if (writable) {
-                PRESTO_ALLOC(fdata, sizeof(*fdata));
-                if (!fdata) {
-                        EXIT;
-                        return -ENOMEM;
-                }
-                /* LOCK: XXX check that the kernel lock protects this alloc */
-                fdata->fd_do_lml = 0;
-                fdata->fd_bytes_written = 0;
-                fdata->fd_fsuid = current->fsuid;
-                fdata->fd_fsgid = current->fsgid;
-                fdata->fd_mode = file->f_dentry->d_inode->i_mode;
-                fdata->fd_uid = file->f_dentry->d_inode->i_uid;
-                fdata->fd_gid = file->f_dentry->d_inode->i_gid;
-                fdata->fd_ngroups = current->group_info->ngroups;
-                for (i=0 ; i < current->group_info->ngroups ; i++)
-                        fdata->fd_groups[i] = GROUP_AT(current->group_info,i);
-                if (!ISLENTO(minor)) 
-                        fdata->fd_info.flags = LENTO_FL_KML; 
-                else { 
-                        /* this is for the case of DOD, 
-                           reint_close will adjust flags if needed */
-                        fdata->fd_info.flags = 0;
-                }
-
-                presto_getversion(&fdata->fd_version, inode);
-                file->private_data = fdata;
-        } else {
-                file->private_data = NULL;
-        }
-
-        EXIT;
-        return 0;
-}
-
-int presto_adjust_lml(struct file *file, struct lento_vfs_context *info)
-{
-        struct presto_file_data *fdata = 
-                (struct presto_file_data *) file->private_data;
-
-        if (!fdata) { 
-                EXIT;
-                return -EINVAL;
-        }
-                
-        memcpy(&fdata->fd_info, info, sizeof(*info));
-        EXIT;
-        return 0; 
-}
-
-
-static int presto_file_release(struct inode *inode, struct file *file)
-{
-        int rc;
-        struct file_operations *fops;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct presto_file_data *fdata = 
-                (struct presto_file_data *)file->private_data;
-        ENTRY;
-
-        rc = presto_prep(file->f_dentry, &cache, &fset);
-        if ( rc ) {
-                EXIT;
-                return rc;
-        }
-
-        fops = filter_c2cffops(cache->cache_filter);
-        if (fops && fops->release)
-                rc = fops->release(inode, file);
-
-        CDEBUG(D_CACHE, "islento = %d (minor %d), rc %d, data %p\n",
-               ISLENTO(cache->cache_psdev->uc_minor), 
-               cache->cache_psdev->uc_minor, rc, fdata);
-
-        /* this file was modified: ignore close errors, write KML */
-        if (fdata && fdata->fd_do_lml) {
-                /* XXX: remove when lento gets file granularity cd */
-                if ( presto_get_permit(inode) < 0 ) {
-                        EXIT;
-                        return -EROFS;
-                }
-        
-                fdata->fd_info.updated_time = file->f_dentry->d_inode->i_mtime;
-                rc = presto_do_close(fset, file); 
-                presto_put_permit(inode);
-        }
-
-        if (!rc && fdata) {
-                PRESTO_FREE(fdata, sizeof(*fdata));
-                file->private_data = NULL; 
-        }
-        
-        EXIT;
-        return rc;
-}
-
-static void presto_apply_write_policy(struct file *file,
-                                      struct presto_file_set *fset, loff_t res)
-{
-        struct presto_file_data *fdata =
-                (struct presto_file_data *)file->private_data;
-        struct presto_cache *cache = fset->fset_cache;
-        struct presto_version new_file_ver;
-        int error;
-        struct rec_info rec;
-
-        /* Here we do a journal close after a fixed or a specified
-         amount of KBytes, currently a global parameter set with
-         sysctl. If files are open for a long time, this gives added
-         protection. (XXX todo: per cache, add ioctl, handle
-         journaling in a thread, add more options etc.)
-        */ 
-        if ((fset->fset_flags & FSET_JCLOSE_ON_WRITE) &&
-            (!ISLENTO(cache->cache_psdev->uc_minor))) {
-                fdata->fd_bytes_written += res;
-                if (fdata->fd_bytes_written >= fset->fset_file_maxio) {
-                        presto_getversion(&new_file_ver,
-                                          file->f_dentry->d_inode);
-                        /* This is really heavy weight and should be fixed
-                           ASAP. At most we should be recording the number
-                           of bytes written and not locking the kernel, 
-                           wait for permits, etc, on the write path. SHP
-                        */
-                        lock_kernel();
-                        if ( presto_get_permit(file->f_dentry->d_inode) < 0 ) {
-                                EXIT;
-                                /* we must be disconnected, not to worry */
-                                unlock_kernel();
-                                return; 
-                        }
-                        error = presto_journal_close(&rec, fset, fdata,
-                                                     file->f_dentry,
-                                                     &fdata->fd_version,
-                                                     &new_file_ver);
-                        presto_put_permit(file->f_dentry->d_inode);
-                        unlock_kernel();
-                        if ( error ) {
-                                CERROR("presto_close: cannot journal close\n");
-                                /* XXX these errors are really bad */
-                                /* panic(); */
-                                return;
-                        }
-                        fdata->fd_bytes_written = 0;
-                }
-        }
-}
-
-static ssize_t presto_file_write(struct file *file, const char *buf,
-                                 size_t size, loff_t *off)
-{
-        struct rec_info rec;
-        int error;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct file_operations *fops;
-        ssize_t res;
-        int do_lml_here;
-        void *handle = NULL;
-        unsigned long blocks;
-        struct presto_file_data *fdata;
-        loff_t res_size; 
-
-        error = presto_prep(file->f_dentry, &cache, &fset);
-        if ( error ) {
-                EXIT;
-                return error;
-        }
-
-        blocks = (size >> file->f_dentry->d_inode->i_sb->s_blocksize_bits) + 1;
-        /* XXX 3 is for ext2 indirect blocks ... */ 
-        res_size = 2 * PRESTO_REQHIGH + ((blocks+3) 
-                << file->f_dentry->d_inode->i_sb->s_blocksize_bits);
-
-        error = presto_reserve_space(fset->fset_cache, res_size); 
-        CDEBUG(D_INODE, "Reserved %Ld for %Zd\n", res_size, size);
-        if ( error ) { 
-                EXIT;
-                return -ENOSPC;
-        }
-
-        CDEBUG(D_INODE, "islento %d, minor: %d\n", 
-               ISLENTO(cache->cache_psdev->uc_minor),
-               cache->cache_psdev->uc_minor); 
-
-        /* 
-         *  XXX this lock should become a per inode lock when 
-         *  Vinny's changes are in; we could just use i_sem.
-         */
-        read_lock(&fset->fset_lml.fd_lock); 
-        fdata = (struct presto_file_data *)file->private_data;
-        do_lml_here = size && (fdata->fd_do_lml == 0) &&
-                !presto_chk(file->f_dentry, PRESTO_DONT_JOURNAL);
-
-        if (do_lml_here)
-                fdata->fd_do_lml = 1;
-        read_unlock(&fset->fset_lml.fd_lock); 
-
-        /* XXX 
-           There might be a bug here.  We need to make 
-           absolutely sure that the ext3_file_write commits 
-           after our transaction that writes the LML record.
-           Nesting the file write helps if new blocks are allocated. 
-        */
-        res = 0;
-        if (do_lml_here) {
-                struct presto_version file_version;
-                /* handle different space reqs from file system below! */
-                handle = presto_trans_start(fset, file->f_dentry->d_inode, 
-                                            KML_OPCODE_WRITE);
-                if ( IS_ERR(handle) ) {
-                        presto_release_space(fset->fset_cache, res_size); 
-                        CERROR("presto_write: no space for transaction\n");
-                        return -ENOSPC;
-                }
-
-                presto_getversion(&file_version, file->f_dentry->d_inode); 
-                res = presto_write_lml_close(&rec, fset, file, 
-                                             fdata->fd_info.remote_ino, 
-                                             fdata->fd_info.remote_generation, 
-                                             &fdata->fd_info.remote_version, 
-                                             &file_version);
-                fdata->fd_lml_offset = rec.offset;
-                if ( res ) {
-                        CERROR("intermezzo: PANIC failed to write LML\n");
-                        *(int *)0 = 1;
-                        EXIT;
-                        goto exit_write;
-                }
-                presto_trans_commit(fset, handle);
-        }
-
-        fops = filter_c2cffops(cache->cache_filter);
-        res = fops->write(file, buf, size, off);
-        if ( res != size ) {
-                CDEBUG(D_FILE, "file write returns short write: size %Zd, res %Zd\n", size, res); 
-        }
-
-        if ( (res > 0) && fdata ) 
-                 presto_apply_write_policy(file, fset, res);
-
- exit_write:
-        presto_release_space(fset->fset_cache, res_size); 
-        return res;
-}
-
-struct file_operations presto_file_fops = {
-        .write   = presto_file_write,
-        .open    = presto_file_open,
-        .release = presto_file_release,
-        .ioctl   = presto_ioctl
-};
-
-struct inode_operations presto_file_iops = {
-        .permission   = presto_permission,
-        .setattr      = presto_setattr,
-#ifdef CONFIG_FS_EXT_ATTR
-        .set_ext_attr = presto_set_ext_attr,
-#endif
-};
-
-/* FIXME: I bet we want to add a lock here and in presto_file_open. */
-int izo_purge_file(struct presto_file_set *fset, char *file)
-{
-#if 0
-        void *handle = NULL;
-        char *path = NULL;
-        struct nameidata nd;
-        struct dentry *dentry;
-        int rc = 0, len;
-        loff_t oldsize;
-
-        /* FIXME: not mtpt it's gone */
-        len = strlen(fset->fset_cache->cache_mtpt) + strlen(file) + 1;
-        PRESTO_ALLOC(path, len + 1);
-        if (path == NULL)
-                return -1;
-
-        sprintf(path, "%s/%s", fset->fset_cache->cache_mtpt, file);
-        rc = izo_lookup_file(fset, path, &nd);
-        if (rc)
-                goto error;
-        dentry = nd.dentry;
-
-        /* FIXME: take a lock here */
-
-        if (dentry->d_inode->i_atime.tv_sec > get_seconds() - 5) {
-                /* We lost the race; this file was accessed while we were doing
-                 * ioctls and lookups and whatnot. */
-                rc = -EBUSY;
-                goto error_unlock;
-        }
-
-        /* FIXME: Check if this file is open. */
-
-        handle = presto_trans_start(fset, dentry->d_inode, KML_OPCODE_TRUNC);
-        if (IS_ERR(handle)) {
-                rc = -ENOMEM;
-                goto error_unlock;
-        }
-
-        /* FIXME: Write LML record */
-
-        oldsize = dentry->d_inode->i_size;
-        rc = izo_do_truncate(fset, dentry, 0, oldsize);
-        if (rc != 0)
-                goto error_clear;
-        rc = izo_do_truncate(fset, dentry, oldsize, 0);
-        if (rc != 0)
-                goto error_clear;
-
- error_clear:
-        /* FIXME: clear LML record */
-
- error_unlock:
-        /* FIXME: release the lock here */
-
- error:
-        if (handle != NULL && !IS_ERR(handle))
-                presto_trans_commit(fset, handle);
-        if (path != NULL)
-                PRESTO_FREE(path, len + 1);
-        return rc;
-#else
-        return 0;
-#endif
-}
diff --git a/fs/intermezzo/fileset.c b/fs/intermezzo/fileset.c
deleted file mode 100644 (file)
index 9db8cab..0000000
+++ /dev/null
@@ -1,674 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Managing filesets
- *
- */
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-static inline struct presto_file_set *presto_dentry2fset(struct dentry *dentry)
-{
-        if (presto_d2d(dentry) == NULL) {
-                EXIT;
-                return NULL;
-        }
-        return presto_d2d(dentry)->dd_fset;
-}
-
-/* find the fileset dentry for this dentry */
-struct presto_file_set *presto_fset(struct dentry *de)
-{
-        struct dentry *fsde;
-        ENTRY;
-        if ( !de->d_inode ) {
-                /* FIXME: is this ok to be NULL? */
-                CDEBUG(D_INODE,"presto_fset: warning %*s has NULL inode.\n",
-                de->d_name.len, de->d_name.name);
-        }
-        for (fsde = de;; fsde = fsde->d_parent) {
-                if ( presto_dentry2fset(fsde) ) {
-                        EXIT;
-                        return presto_dentry2fset(fsde);
-                }
-                if (fsde->d_parent == fsde)
-                        break;
-        }
-        EXIT;
-        return NULL;
-}
-
-int presto_get_lastrecno(char *path, off_t *recno)
-{
-        struct nameidata nd; 
-        struct presto_file_set *fset;
-        struct dentry *dentry;
-        int error;
-        ENTRY;
-
-        error = presto_walk(path, &nd);
-        if (error) {
-                EXIT;
-                return error;
-        }
-
-        dentry = nd.dentry;
-
-        error = -ENXIO;
-        if ( !presto_ispresto(dentry->d_inode) ) {
-                EXIT;
-                goto kml_out;
-        }
-
-        error = -EINVAL;
-        if ( ! presto_dentry2fset(dentry)) {
-                EXIT;
-                goto kml_out;
-        }
-
-        fset = presto_dentry2fset(dentry);
-        if (!fset) {
-                EXIT;
-                goto kml_out;
-        }
-        error = 0;
-        *recno = fset->fset_kml.fd_recno;
-
- kml_out:
-        path_release(&nd);
-        return error;
-}
-
-static char * _izo_make_path(char *fsetname, char *name)
-{
-        char *path = NULL;
-        int len;
-
-        len = strlen("/.intermezzo/") + strlen(fsetname) 
-                + 1 + strlen(name) + 1;
-
-        PRESTO_ALLOC(path, len);
-        if (path == NULL)
-                return NULL;
-
-        sprintf(path, "/.intermezzo/%s/%s", fsetname, name);
-
-        return path;
-}
-
-char * izo_make_path(struct presto_file_set *fset, char *name)
-{
-        return _izo_make_path(fset->fset_name, name);
-}
-
-static struct file *_izo_fset_open(char *fsetname, char *name, int flags, int mode) 
-{
-        char *path;
-        struct file *f;
-        int error;
-        ENTRY;
-
-        path = _izo_make_path(fsetname, name);
-        if (path == NULL) {
-                EXIT;
-                return ERR_PTR(-ENOMEM);
-        }
-
-        CDEBUG(D_INODE, "opening file %s\n", path);
-        f = filp_open(path, flags, mode);
-        error = PTR_ERR(f);
-        if (IS_ERR(f)) {
-                CDEBUG(D_INODE, "Error %d\n", error);
-        }
-
-        PRESTO_FREE(path, strlen(path));
-
-        EXIT;
-        return f;
-
-}
-
-struct file *izo_fset_open(struct presto_file_set *fset, char *name, int flags, int mode) 
-{
-        return _izo_fset_open(fset->fset_name, name, flags, mode);
-}
-
-
-
-/*
- *  note: this routine "pins" a dentry for a fileset root
- */
-int presto_set_fsetroot(struct dentry *ioctl_dentry, char *fsetname,
-                        unsigned int flags)
-{
-        struct presto_file_set *fset = NULL;
-        struct presto_cache *cache;
-        int error;
-        struct file  *fset_root;
-        struct dentry *dentry;
-
-        ENTRY;
-
-        fset_root = _izo_fset_open(fsetname, "ROOT",  O_RDONLY, 000);
-        if (IS_ERR(fset_root)) {
-                CERROR("Can't open %s/ROOT\n", fsetname);
-                EXIT;
-                error = PTR_ERR(fset_root);
-                goto out;
-        }
-        dentry = dget(fset_root->f_dentry);
-        filp_close(fset_root, NULL);
-
-        dentry->d_inode->i_op = ioctl_dentry->d_inode->i_op;
-        dentry->d_inode->i_fop = ioctl_dentry->d_inode->i_fop;
-        dentry->d_op = ioctl_dentry->d_op;
-        fset = presto_dentry2fset(dentry);
-        if (fset && (fset->fset_dentry == dentry) ) { 
-                CERROR("Fsetroot already set (inode %ld)\n",
-                       dentry->d_inode->i_ino);
-                /* XXX: ignore because clear_fsetroot is broken  */
-#if 0
-                dput(dentry);
-                EXIT;
-                error = -EEXIST;
-                goto out;
-#endif
-        }
-
-        cache = presto_get_cache(dentry->d_inode);
-        if (!cache) { 
-                CERROR("No cache found for inode %ld\n",
-                       dentry->d_inode->i_ino);
-                EXIT;
-                error = -ENODEV;
-                goto out_free;
-        }
-
-        PRESTO_ALLOC(fset, sizeof(*fset));
-        if ( !fset ) {
-                CERROR("No memory allocating fset for %s\n", fsetname);
-                EXIT;
-                error = -ENOMEM;
-                goto out_free;
-        }
-        CDEBUG(D_INODE, "fset at %p\n", fset);
-
-        CDEBUG(D_INODE, "InterMezzo: fsetroot: inode %ld, fileset name %s\n",
-               dentry->d_inode->i_ino, fsetname);
-
-        fset->fset_mnt = mntget(current->fs->pwdmnt); 
-        fset->fset_cache = cache;
-        fset->fset_dentry = dentry; 
-        fset->fset_name = strdup(fsetname);
-        fset->fset_chunkbits = CHUNK_BITS;
-        fset->fset_flags = flags;
-        fset->fset_file_maxio = FSET_DEFAULT_MAX_FILEIO; 
-        fset->fset_permit_lock = SPIN_LOCK_UNLOCKED;
-        PRESTO_ALLOC(fset->fset_reint_buf, 64 * 1024);
-        if (fset->fset_reint_buf == NULL) {
-                EXIT;
-                error = -ENOMEM;
-                goto out_free;
-        }
-        init_waitqueue_head(&fset->fset_permit_queue);
-
-        if (presto_d2d(dentry) == NULL) { 
-                dentry->d_fsdata = izo_alloc_ddata();
-        }
-        if (presto_d2d(dentry) == NULL) {
-                CERROR("InterMezzo: %s: no memory\n", __FUNCTION__);
-                EXIT;
-                error = -ENOMEM;
-                goto out_free;
-        }
-        presto_d2d(dentry)->dd_fset = fset;
-        list_add(&fset->fset_list, &cache->cache_fset_list);
-
-        error = izo_init_kml_file(fset, &fset->fset_kml);
-        if ( error ) {
-                EXIT;
-                CDEBUG(D_JOURNAL, "Error init_kml %d\n", error);
-                goto out_list_del;
-        }
-
-        error = izo_init_lml_file(fset, &fset->fset_lml);
-        if ( error ) {
-                int rc;
-                EXIT;
-                rc = izo_log_close(&fset->fset_kml);
-                CDEBUG(D_JOURNAL, "Error init_lml %d, cleanup %d\n", error, rc);
-                goto out_list_del;
-        }
-
-        /* init_last_rcvd_file could trigger a presto_file_write(), which
-         * requires that the lml structure be initialized. -phil */
-        error = izo_init_last_rcvd_file(fset, &fset->fset_rcvd);
-        if ( error ) {
-                int rc;
-                EXIT;
-                rc = izo_log_close(&fset->fset_kml);
-                rc = izo_log_close(&fset->fset_lml);
-                CDEBUG(D_JOURNAL, "Error init_lastrcvd %d, cleanup %d\n", error, rc);
-                goto out_list_del;
-        }
-
-        CDEBUG(D_PIOCTL, "-------> fset at %p, dentry at %p, mtpt %p,"
-               "fset %s, cache %p, presto_d2d(dentry)->dd_fset %p\n",
-               fset, dentry, fset->fset_dentry, fset->fset_name, cache,
-               presto_d2d(dentry)->dd_fset);
-
-        EXIT;
-        return 0;
-
- out_list_del:
-        list_del(&fset->fset_list);
-        presto_d2d(dentry)->dd_fset = NULL;
- out_free:
-        if (fset) {
-                mntput(fset->fset_mnt); 
-                if (fset->fset_reint_buf != NULL)
-                        PRESTO_FREE(fset->fset_reint_buf, 64 * 1024);
-                PRESTO_FREE(fset, sizeof(*fset));
-        }
-        dput(dentry); 
- out:
-        return error;
-}
-
-static int izo_cleanup_fset(struct presto_file_set *fset)
-{
-        int error;
-        struct presto_cache *cache;
-
-        ENTRY;
-
-        CERROR("Cleaning up fset %s\n", fset->fset_name);
-
-        error = izo_log_close(&fset->fset_kml);
-        if (error)
-                CERROR("InterMezzo: Closing kml for fset %s: %d\n",
-                       fset->fset_name, error);
-        error = izo_log_close(&fset->fset_lml);
-        if (error)
-                CERROR("InterMezzo: Closing lml for fset %s: %d\n",
-                       fset->fset_name, error);
-        error = izo_log_close(&fset->fset_rcvd);
-        if (error)
-                CERROR("InterMezzo: Closing last_rcvd for fset %s: %d\n",
-                       fset->fset_name, error);
-
-        cache = fset->fset_cache;
-
-        list_del(&fset->fset_list);
-
-        presto_d2d(fset->fset_dentry)->dd_fset = NULL;
-        dput(fset->fset_dentry);
-        mntput(fset->fset_mnt);
-
-        PRESTO_FREE(fset->fset_name, strlen(fset->fset_name) + 1);
-        PRESTO_FREE(fset->fset_reint_buf, 64 * 1024);
-        PRESTO_FREE(fset, sizeof(*fset));
-        EXIT;
-        return error;
-}
-
-int izo_clear_fsetroot(struct dentry *dentry)
-{
-        struct presto_file_set *fset;
-
-        ENTRY;
-
-        fset = presto_dentry2fset(dentry);
-        if (!fset) {
-                EXIT;
-                return -EINVAL;
-        }
-
-        izo_cleanup_fset(fset);
-        EXIT;
-        return 0;
-}
-
-int izo_clear_all_fsetroots(struct presto_cache *cache)
-{
-        struct presto_file_set *fset;
-        struct list_head *tmp,*tmpnext;
-        int error;
-        error = 0;
-        tmp = &cache->cache_fset_list;
-        tmpnext = tmp->next;
-        while ( tmpnext != &cache->cache_fset_list) {
-                tmp = tmpnext;
-                tmpnext = tmp->next;
-                fset = list_entry(tmp, struct presto_file_set, fset_list);
-
-                error = izo_cleanup_fset(fset);
-                if (error)
-                        break;
-        }
-        return error;
-}
-
-static struct vfsmount *izo_alloc_vfsmnt(void)
-{
-        struct vfsmount *mnt;
-        PRESTO_ALLOC(mnt, sizeof(*mnt));
-        if (mnt) {
-                memset(mnt, 0, sizeof(struct vfsmount));
-                atomic_set(&mnt->mnt_count,1);
-                INIT_LIST_HEAD(&mnt->mnt_hash);
-                INIT_LIST_HEAD(&mnt->mnt_child);
-                INIT_LIST_HEAD(&mnt->mnt_mounts);
-                INIT_LIST_HEAD(&mnt->mnt_list);
-        }
-        return mnt;
-}
-
-
-static void izo_setup_ctxt(struct dentry *root, struct vfsmount *mnt,
-                           struct run_ctxt *save) 
-{
-        struct run_ctxt new;
-
-        mnt->mnt_root = root;
-        mnt->mnt_sb = root->d_inode->i_sb;
-        unlock_super(mnt->mnt_sb);
-
-        new.rootmnt = mnt;
-        new.root = root;
-        new.pwdmnt = mnt;
-        new.pwd = root;
-        new.fsuid = 0;
-        new.fsgid = 0;
-        new.fs = get_fs(); 
-        /* XXX where can we get the groups from? */
-        new.group_info = groups_alloc(0);
-
-        push_ctxt(save, &new); 
-}
-
-static void izo_cleanup_ctxt(struct vfsmount *mnt, struct run_ctxt *save) 
-{
-        lock_super(mnt->mnt_sb);
-        pop_ctxt(save); 
-}
-
-static int izo_simple_mkdir(struct dentry *dir, char *name, int mode)
-{
-        struct dentry *dchild; 
-        int err;
-        ENTRY;
-        
-        dchild = lookup_one_len(name, dir, strlen(name));
-        if (IS_ERR(dchild)) { 
-                EXIT;
-                return PTR_ERR(dchild); 
-        }
-
-        if (dchild->d_inode) { 
-                dput(dchild);
-                EXIT;
-                return -EEXIST;
-        }
-
-        err = vfs_mkdir(dir->d_inode, dchild, mode);
-        dput(dchild);
-        
-        EXIT;
-        return err;
-}
-
-static int izo_simple_symlink(struct dentry *dir, char *name, char *tgt)
-{
-        struct dentry *dchild; 
-        int err;
-        ENTRY;
-        
-        dchild = lookup_one_len(name, dir, strlen(name));
-        if (IS_ERR(dchild)) { 
-                EXIT;
-                return PTR_ERR(dchild); 
-        }
-
-        if (dchild->d_inode) { 
-                dput(dchild);
-                EXIT;
-                return -EEXIST;
-        }
-
-        err = vfs_symlink(dir->d_inode, dchild, tgt);
-        dput(dchild);
-        
-        EXIT;
-        return err;
-}
-
-/*
- * run set_fsetroot in chroot environment
- */
-int presto_set_fsetroot_from_ioc(struct dentry *root, char *fsetname,
-                                 unsigned int flags)
-{
-        int rc;
-        struct presto_cache *cache;
-        struct vfsmount *mnt;
-        struct run_ctxt save;
-
-        if (root != root->d_inode->i_sb->s_root) {
-                CERROR ("IOC_SET_FSET must be called on mount point\n");
-                return -ENODEV;
-        }
-
-        cache = presto_get_cache(root->d_inode);
-        mnt = cache->cache_vfsmount;
-        if (!mnt) { 
-                EXIT;
-                return -ENOMEM;
-        }
-        
-        izo_setup_ctxt(root, mnt, &save); 
-        rc = presto_set_fsetroot(root, fsetname, flags);
-        izo_cleanup_ctxt(mnt, &save);
-        return rc;
-}
-
-/* XXX: this function should detect if fsetname is already in use for
-   the cache under root
-*/ 
-int izo_prepare_fileset(struct dentry *root, char *fsetname) 
-{
-        int err;
-        struct dentry *dotizo = NULL, *fsetdir = NULL, *dotiopen = NULL; 
-        struct presto_cache *cache;
-        struct vfsmount *mnt;
-        struct run_ctxt save;
-
-        cache = presto_get_cache(root->d_inode);
-        mnt = cache->cache_vfsmount = izo_alloc_vfsmnt();
-        if (!mnt) { 
-                EXIT;
-                return -ENOMEM;
-        }
-        
-        if (!fsetname) 
-                fsetname = "rootfset"; 
-
-        izo_setup_ctxt(root, mnt, &save); 
-
-        err = izo_simple_mkdir(root, ".intermezzo", 0755);
-        CDEBUG(D_CACHE, "mkdir on .intermezzo err %d\n", err); 
-
-        err = izo_simple_mkdir(root, "..iopen..", 0755);
-        CDEBUG(D_CACHE, "mkdir on ..iopen.. err %d\n", err); 
-
-        dotiopen = lookup_one_len("..iopen..", root, strlen("..iopen.."));
-        if (IS_ERR(dotiopen)) { 
-                EXIT;
-                goto out;
-        }
-        dotiopen->d_inode->i_op = &presto_dir_iops;
-        dput(dotiopen);
-
-
-        dotizo = lookup_one_len(".intermezzo", root, strlen(".intermezzo"));
-        if (IS_ERR(dotizo)) { 
-                EXIT;
-                goto out;
-        }
-
-
-        err = izo_simple_mkdir(dotizo, fsetname, 0755);
-        CDEBUG(D_CACHE, "mkdir err %d\n", err); 
-
-        /* XXX find the dentry of the root of the fileset (root for now) */ 
-        fsetdir = lookup_one_len(fsetname, dotizo, strlen(fsetname));
-        if (IS_ERR(fsetdir)) { 
-                EXIT;
-                goto out;
-        }
-
-        err = izo_simple_symlink(fsetdir, "ROOT", "../.."); 
-
-        /* XXX read flags from flags file */ 
-        err =  presto_set_fsetroot(root, fsetname, 0); 
-        CDEBUG(D_CACHE, "set_fsetroot err %d\n", err); 
-
- out:
-        if (dotizo && !IS_ERR(dotizo)) 
-                dput(dotizo); 
-        if (fsetdir && !IS_ERR(fsetdir)) 
-                dput(fsetdir); 
-        izo_cleanup_ctxt(mnt, &save);
-        return err; 
-}
-
-int izo_set_fileid(struct file *dir, struct izo_ioctl_data *data)
-{
-        int rc = 0;
-        struct presto_cache *cache;
-        struct vfsmount *mnt;
-        struct run_ctxt save;
-        struct nameidata nd;
-        struct dentry *dentry;
-        struct presto_dentry_data *dd;
-        struct dentry *root;
-        char *buf = NULL; 
-
-        ENTRY;
-
-
-        root = dir->f_dentry;
-
-        /* actually, needs to be called on ROOT of fset, not mount point  
-        if (root != root->d_inode->i_sb->s_root) {
-                CERROR ("IOC_SET_FSET must be called on mount point\n");
-                return -ENODEV;
-        }
-        */
-
-        cache = presto_get_cache(root->d_inode);
-        mnt = cache->cache_vfsmount;
-        if (!mnt) { 
-                EXIT;
-                return -ENOMEM;
-        }
-        
-        izo_setup_ctxt(root, mnt, &save); 
-        
-        PRESTO_ALLOC(buf, data->ioc_plen1);
-        if (!buf) { 
-                rc = -ENOMEM;
-                EXIT;
-                goto out;
-        }
-        if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) { 
-                rc =  -EFAULT;
-                EXIT;
-                goto out;
-        }
-
-        rc = presto_walk(buf, &nd);
-        if (rc) {
-                CERROR("Unable to open: %s\n", buf);
-                EXIT;
-                goto out;
-        }
-        dentry = nd.dentry;
-        if (!dentry) {
-                CERROR("no dentry!\n");
-                rc =  -EINVAL;
-                EXIT;
-                goto out_close;
-        }
-        dd = presto_d2d(dentry);
-        if (!dd) {
-                CERROR("no dentry_data!\n");
-                rc = -EINVAL;
-                EXIT;
-                goto out_close;
-        }
-
-        CDEBUG(D_FILE,"de:%p dd:%p\n", dentry, dd);
-
-        if (dd->remote_ino != 0) {
-                CERROR("remote_ino already set? %Lx:%Lx\n",
-                       (unsigned long long) dd->remote_ino,
-                       (unsigned long long) dd->remote_generation);
-                rc = 0;
-                EXIT;
-                goto out_close;
-        }
-
-
-        CDEBUG(D_FILE,"setting %p %p, %s to %Lx:%Lx\n", dentry, dd, 
-               buf,
-               (unsigned long long) data->ioc_ino,
-               (unsigned long long) data->ioc_generation);
-        dd->remote_ino = data->ioc_ino;
-        dd->remote_generation = data->ioc_generation;
-
-        EXIT;
- out_close:
-        path_release(&nd);
- out:
-        if (buf)
-                PRESTO_FREE(buf, data->ioc_plen1);
-        izo_cleanup_ctxt(mnt, &save);
-        return rc;
-}
diff --git a/fs/intermezzo/inode.c b/fs/intermezzo/inode.c
deleted file mode 100644 (file)
index fda188b..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1996 Peter J. Braam <braam@maths.ox.ac.uk> and
- *    Michael Callahan <callahan@maths.ox.ac.uk>
- *  Copyright (C) 1999 Carnegie Mellon University
- *    Rewritten for Linux 2.1.  Peter Braam <braam@cs.cmu.edu>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Super block/filesystem wide operations
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/unistd.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <asm/segment.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-extern void presto_free_cache(struct presto_cache *);
-
-void presto_set_ops(struct inode *inode, struct  filter_fs *filter)
-{
-        ENTRY; 
-
-        if (!inode || is_bad_inode(inode))
-                return;
-
-        if (S_ISREG(inode->i_mode)) {
-                if ( !filter_c2cfiops(filter) ) {
-                       filter_setup_file_ops(filter, 
-                                             inode, &presto_file_iops,
-                                             &presto_file_fops);
-                }
-                inode->i_op = filter_c2ufiops(filter);
-                inode->i_fop = filter_c2uffops(filter);
-                CDEBUG(D_INODE, "set file methods for %ld to %p\n",
-                       inode->i_ino, inode->i_op);
-        } else if (S_ISDIR(inode->i_mode)) {
-                inode->i_op = filter_c2udiops(filter);
-                inode->i_fop = filter_c2udfops(filter);
-                CDEBUG(D_INODE, "set dir methods for %ld to %p ioctl %p\n",
-                       inode->i_ino, inode->i_op, inode->i_fop->ioctl);
-        } else if (S_ISLNK(inode->i_mode)) {
-                if ( !filter_c2csiops(filter)) {
-                        filter_setup_symlink_ops(filter, 
-                                                 inode,
-                                                 &presto_sym_iops, 
-                                                 &presto_sym_fops);
-                }
-                inode->i_op = filter_c2usiops(filter);
-                inode->i_fop = filter_c2usfops(filter);
-                CDEBUG(D_INODE, "set link methods for %ld to %p\n",
-                       inode->i_ino, inode->i_op);
-        }
-        EXIT;
-}
-
-void presto_read_inode(struct inode *inode)
-{
-        struct presto_cache *cache;
-
-        cache = presto_get_cache(inode);
-        if ( !cache ) {
-                CERROR("PRESTO: BAD, BAD: cannot find cache\n");
-                make_bad_inode(inode);
-                return ;
-        }
-
-        filter_c2csops(cache->cache_filter)->read_inode(inode);
-
-        CDEBUG(D_INODE, "presto_read_inode: ino %ld, gid %d\n", 
-               inode->i_ino, inode->i_gid);
-
-        presto_set_ops(inode, cache->cache_filter); 
-        /* XXX handle special inodes here or not - probably not? */
-}
-
-static void presto_put_super(struct super_block *sb)
-{
-        struct presto_cache *cache;
-        struct upc_channel *channel;
-        struct super_operations *sops;
-        struct list_head *lh;
-        int err;
-
-        ENTRY;
-        cache = presto_cache_find(sb);
-        if (!cache) {
-                EXIT;
-                goto exit;
-        }
-        channel = &izo_channels[presto_c2m(cache)];
-        sops = filter_c2csops(cache->cache_filter);
-        err = izo_clear_all_fsetroots(cache); 
-        if (err) { 
-                CERROR("%s: err %d\n", __FUNCTION__, err);
-        }
-        PRESTO_FREE(cache->cache_vfsmount, sizeof(struct vfsmount));
-
-        /* look at kill_super - fsync_super is not exported GRRR but 
-           probably not needed */ 
-        unlock_super(sb);
-        shrink_dcache_parent(cache->cache_root); 
-        dput(cache->cache_root); 
-        //fsync_super(sb); 
-        lock_super(sb);
-
-        if (sops->write_super)
-                sops->write_super(sb); 
-
-        if (sops->put_super)
-                sops->put_super(sb);
-
-        /* free any remaining async upcalls when the filesystem is unmounted */
-        spin_lock(&channel->uc_lock);
-        lh = channel->uc_pending.next;
-        while ( lh != &channel->uc_pending) {
-                struct upc_req *req;
-                req = list_entry(lh, struct upc_req, rq_chain);
-
-                /* assignment must be here: we are about to free &lh */
-                lh = lh->next;
-                if ( ! (req->rq_flags & REQ_ASYNC) ) 
-                        continue;
-                list_del(&(req->rq_chain));
-                PRESTO_FREE(req->rq_data, req->rq_bufsize);
-                PRESTO_FREE(req, sizeof(struct upc_req));
-        }
-        list_del(&cache->cache_channel_list); 
-        spin_unlock(&channel->uc_lock);
-
-        presto_free_cache(cache);
-
-exit:
-        CDEBUG(D_MALLOC, "after umount: kmem %ld, vmem %ld\n",
-               presto_kmemory, presto_vmemory);
-        return ;
-}
-
-struct super_operations presto_super_ops = {
-        .read_inode    = presto_read_inode,
-        .put_super     = presto_put_super,
-};
-
-
-/* symlinks can be chowned */
-struct inode_operations presto_sym_iops = {
-        .setattr       = presto_setattr
-};
-
-/* NULL for now */
-struct file_operations presto_sym_fops; 
diff --git a/fs/intermezzo/intermezzo_fs.h b/fs/intermezzo/intermezzo_fs.h
deleted file mode 100644 (file)
index 3500365..0000000
+++ /dev/null
@@ -1,923 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- *  Copyright (C) 2001 Tacitus Systems, Inc.
- *  Copyright (C) 2000 Stelias Computing, Inc.
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 TurboLinux, Inc.
- *  Copyright (C) 2000 Los Alamos National Laboratory.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __INTERMEZZO_FS_H_
-#define __INTERMEZZO_FS_H_ 1
-
-#include "intermezzo_lib.h"
-#include "intermezzo_idl.h"
-
-
-#ifdef __KERNEL__
-typedef __u8 uuid_t[16];
-#else
-# include <uuid/uuid.h>
-#endif
-
-struct lento_vfs_context {
-        __u64 kml_offset;
-        struct timespec updated_time;
-        __u64 remote_ino;
-        __u64 remote_generation;
-        __u32 slot_offset;
-        __u32 recno;
-        __u32 flags;
-        uuid_t uuid;
-        struct presto_version remote_version;
-};
-
-#ifdef __KERNEL__
-# include <linux/smp.h>
-# include <linux/fsfilter.h>
-# include <linux/mount.h>
-# include <linux/slab.h>
-# include <linux/vmalloc.h>
-# include <linux/smp_lock.h>
-
-/* fixups for fs.h */
-# ifndef fs_down
-#  define fs_down(sem) down(sem)
-# endif
-
-# ifndef fs_up
-#  define fs_up(sem) up(sem)
-# endif
-
-# define KML_IDLE                        0
-# define KML_DECODE                      1
-# define KML_OPTIMIZE                    2
-# define KML_REINT                       3
-
-# define KML_OPEN_REINT                  0x0100
-# define KML_REINT_BEGIN                 0x0200
-# define KML_BACKFETCH                   0x0400
-# define KML_REINT_END                   0x0800
-# define KML_CLOSE_REINT                 0x1000
-# define KML_REINT_MAXBUF                (64 * 1024)
-
-# define CACHE_CLIENT_RO       0x4
-# define CACHE_LENTO_RO        0x8
-
-/* global variables */
-extern int presto_debug;
-extern int presto_print_entry;
-extern long presto_kmemory;
-extern long presto_vmemory;
-
-# define PRESTO_DEBUG
-# ifdef PRESTO_DEBUG
-/* debugging masks */
-#  define D_SUPER       1
-#  define D_INODE       2
-#  define D_FILE        4
-#  define D_CACHE       8  /* cache debugging */
-#  define D_MALLOC     16  /* print malloc, de-alloc information */
-#  define D_JOURNAL    32
-#  define D_UPCALL     64  /* up and downcall debugging */
-#  define D_PSDEV     128
-#  define D_PIOCTL    256
-#  define D_SPECIAL   512
-#  define D_TIMING   1024
-#  define D_DOWNCALL 2048
-#  define D_KML      4096
-#  define D_FSDATA   8192
-
-#  define CDEBUG(mask, format, a...)                                    \
-        do {                                                            \
-                if (presto_debug & mask) {                              \
-                        printk("(%s:%s,l. %d %d): " format, __FILE__,   \
-                               __FUNCTION__, __LINE__, current->pid     \
-                               , ## a);                                 \
-                }                                                       \
-        } while (0)
-
-#define CERROR(format, a...)                                            \
-do {                                                                    \
-        printk("(%s:%s,l. %d %d): " format, __FILE__, __FUNCTION__,     \
-               __LINE__, current->pid , ## a);                          \
-} while (0)
-
-#  define ENTRY                                                         \
-        if (presto_print_entry)                                         \
-                printk("Process %d entered %s\n", current->pid, __FUNCTION__)
-
-#  define EXIT                                                          \
-        if (presto_print_entry)                                         \
-                printk("Process %d leaving %s at %d\n", current->pid,   \
-                       __FUNCTION__, __LINE__)
-
-#  define presto_kmem_inc(ptr, size) presto_kmemory += (size)
-#  define presto_kmem_dec(ptr, size) presto_kmemory -= (size)
-#  define presto_vmem_inc(ptr, size) presto_vmemory += (size)
-#  define presto_vmem_dec(ptr, size) presto_vmemory -= (size)
-# else /* !PRESTO_DEBUG */
-#  define CDEBUG(mask, format, a...) do {} while (0)
-#  define ENTRY do {} while (0)
-#  define EXIT do {} while (0)
-#  define presto_kmem_inc(ptr, size) do {} while (0)
-#  define presto_kmem_dec(ptr, size) do {} while (0)
-#  define presto_vmem_inc(ptr, size) do {} while (0)
-#  define presto_vmem_dec(ptr, size) do {} while (0)
-# endif /* PRESTO_DEBUG */
-
-
-struct run_ctxt {
-        struct vfsmount *pwdmnt;
-        struct dentry   *pwd;
-        struct vfsmount *rootmnt;
-        struct dentry   *root;
-        uid_t            fsuid;
-        gid_t            fsgid;
-        mm_segment_t     fs;
-        struct group_info * group_info;
-/*     int              ngroups;
-       gid_t            groups[NGROUPS];*/
-
-};
-
-static inline void push_ctxt(struct run_ctxt *save, struct run_ctxt *new)
-{
-        save->fs = get_fs();
-        save->pwd = dget(current->fs->pwd);
-        save->pwdmnt = mntget(current->fs->pwdmnt);
-        save->fsgid = current->fsgid;
-        save->fsuid = current->fsuid;
-        save->root = current->fs->root;
-        save->rootmnt = current->fs->rootmnt;
-        save->group_info = current->group_info;
-/*      save->ngroups = current->ngroups;
-        for (i = 0; i< current->ngroups; i++) 
-                save->groups[i] = current->groups[i];*/
-
-        set_fs(new->fs);
-        lock_kernel();
-        set_fs_pwd(current->fs, new->pwdmnt, new->pwd);
-        if (new->root)
-                set_fs_root(current->fs, new->rootmnt, new->root);
-        unlock_kernel();
-        current->fsuid = new->fsuid;
-        current->fsgid = new->fsgid;
-        /*if (new->ngroups > 0) {
-                current->ngroups = new->ngroups;
-                for (i = 0; i< new->ngroups; i++) 
-                        current->groups[i] = new->groups[i];
-        }*/
-        current->group_info = new->group_info;
-        
-}
-
-static inline void pop_ctxt(struct run_ctxt *saved)
-{
-        set_fs(saved->fs);
-        lock_kernel();
-        set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
-        if (saved->root)
-                set_fs_root(current->fs, saved->rootmnt, saved->root);
-        unlock_kernel();
-        current->fsuid = saved->fsuid;
-        current->fsgid = saved->fsgid;
-        current->group_info = saved->group_info;
-/*
-        current->ngroups = saved->ngroups;
-        for (i = 0; i< saved->ngroups; i++) 
-                current->groups[i] = saved->groups[i];
-*/
-        mntput(saved->pwdmnt);
-        dput(saved->pwd);
-}
-
-static inline struct presto_dentry_data *presto_d2d(struct dentry *dentry)
-{
-        return (struct presto_dentry_data *)(dentry->d_fsdata);
-}
-
-struct presto_cache {
-        spinlock_t          cache_lock;
-        loff_t              cache_reserved;
-        struct  vfsmount   *cache_vfsmount;
-        struct super_block *cache_sb;
-        struct  dentry     *cache_root;
-        struct list_head    cache_chain; /* for the dev/cache hash */
-
-        int   cache_flags;
-
-        char *cache_type;            /* filesystem type of cache */
-        struct filter_fs *cache_filter;
-
-        struct upc_channel *cache_psdev;  /* points to channel used */
-        struct list_head cache_channel_list; 
-        struct list_head cache_fset_list; /* filesets mounted in cache */
-};
-
-struct presto_log_fd {
-        rwlock_t         fd_lock;
-        loff_t           fd_offset;  /* offset where next record should go */
-        struct file    *fd_file;
-        int             fd_truncating;
-        unsigned int   fd_recno;   /* last recno written */
-        struct list_head  fd_reservations;
-};
-
-/* file sets */
-# define CHUNK_BITS  16
-
-struct presto_file_set {
-        struct list_head fset_list;
-        struct presto_log_fd fset_kml;
-        struct presto_log_fd fset_lml;
-        struct presto_log_fd fset_rcvd;
-        struct list_head *fset_clients;  /* cache of clients */
-        struct dentry *fset_dentry;
-        struct vfsmount *fset_mnt;
-        struct presto_cache *fset_cache;
-
-        unsigned int fset_lento_recno;  /* last recno mentioned to lento */
-        loff_t fset_lento_off;    /* last offset mentioned to lento */
-        loff_t fset_kml_logical_off; /* logical offset of kml file byte 0 */
-        char * fset_name;
-
-        int fset_flags;
-        int fset_chunkbits;
-        char *fset_reint_buf; /* temporary buffer holds kml during reint */
-
-        spinlock_t fset_permit_lock;
-        int fset_permit_count;
-        int fset_permit_upcall_count;
-        /* This queue is used both for processes waiting for the kernel to give
-         * up the permit as well as processes waiting for the kernel to be given
-         * the permit, depending on the state of FSET_HASPERMIT. */
-        wait_queue_head_t fset_permit_queue;
-
-        loff_t  fset_file_maxio;  /* writing more than this causes a close */
-        unsigned long int kml_truncate_size;
-};
-
-/* This is the default number of bytes written before a close is recorded*/
-#define FSET_DEFAULT_MAX_FILEIO (1024<<10)
-
-struct dentry *presto_tmpfs_ilookup(struct inode *dir, struct dentry *dentry, 
-                                    ino_t ino, unsigned int generation);
-struct dentry *presto_iget_ilookup(struct inode *dir, struct dentry *dentry, 
-                                    ino_t ino, unsigned int generation);
-struct dentry *presto_add_ilookup_dentry(struct dentry *parent,
-                                         struct dentry *real);
-
-struct journal_ops {
-        int (*tr_all_data)(struct inode *);
-        loff_t (*tr_avail)(struct presto_cache *fset, struct super_block *);
-        void *(*tr_start)(struct presto_file_set *, struct inode *, int op);
-        void (*tr_commit)(struct presto_file_set *, void *handle);
-        void (*tr_journal_data)(struct inode *);
-        struct dentry *(*tr_ilookup)(struct inode *dir, struct dentry *dentry, ino_t ino, unsigned int generation);
-        struct dentry *(*tr_add_ilookup)(struct dentry *parent, struct dentry *real);
-};
-
-extern struct journal_ops presto_ext2_journal_ops;
-extern struct journal_ops presto_ext3_journal_ops;
-extern struct journal_ops presto_tmpfs_journal_ops;
-extern struct journal_ops presto_xfs_journal_ops;
-extern struct journal_ops presto_reiserfs_journal_ops;
-extern struct journal_ops presto_obdfs_journal_ops;
-
-# define LENTO_FL_KML            0x0001
-# define LENTO_FL_EXPECT         0x0002
-# define LENTO_FL_VFSCHECK       0x0004
-# define LENTO_FL_JUSTLOG        0x0008
-# define LENTO_FL_WRITE_KML      0x0010
-# define LENTO_FL_CANCEL_LML     0x0020
-# define LENTO_FL_WRITE_EXPECT   0x0040
-# define LENTO_FL_IGNORE_TIME    0x0080
-# define LENTO_FL_TOUCH_PARENT   0x0100
-# define LENTO_FL_TOUCH_NEWOBJ   0x0200
-# define LENTO_FL_SET_DDFILEID   0x0400
-
-struct presto_cache *presto_get_cache(struct inode *inode);
-int presto_sprint_mounts(char *buf, int buflen, int minor);
-struct presto_file_set *presto_fset(struct dentry *de);
-int presto_journal(struct dentry *dentry, char *buf, size_t size);
-int presto_fwrite(struct file *file, const char *str, int len, loff_t *off);
-int presto_ispresto(struct inode *);
-
-/* super.c */
-extern struct file_system_type presto_fs_type;
-extern int init_intermezzo_fs(void);
-
-/* fileset.c */
-extern int izo_prepare_fileset(struct dentry *root, char *fsetname);
-char * izo_make_path(struct presto_file_set *fset, char *name);
-struct file *izo_fset_open(struct presto_file_set *fset, char *name, int flags, int mode);
-
-/* psdev.c */
-int izo_psdev_get_free_channel(void);
-int presto_psdev_init(void);
-int izo_psdev_setpid(int minor);
-extern void presto_psdev_cleanup(void);
-int presto_lento_up(int minor);
-int izo_psdev_setchannel(struct file *file, int fd);
-
-/* inode.c */
-extern struct super_operations presto_super_ops;
-void presto_set_ops(struct inode *inode, struct  filter_fs *filter);
-
-/* dcache.c */
-void presto_frob_dop(struct dentry *de);
-char *presto_path(struct dentry *dentry, struct dentry *root,
-                  char *buffer, int buflen);
-struct presto_dentry_data *izo_alloc_ddata(void);
-int presto_set_dd(struct dentry *);
-int presto_init_ddata_cache(void);
-void presto_cleanup_ddata_cache(void);
-extern struct dentry_operations presto_dentry_ops;
-
-/* dir.c */
-extern struct inode_operations presto_dir_iops;
-extern struct inode_operations presto_file_iops;
-extern struct inode_operations presto_sym_iops;
-extern struct file_operations presto_dir_fops;
-extern struct file_operations presto_file_fops;
-extern struct file_operations presto_sym_fops;
-int presto_setattr(struct dentry *de, struct iattr *iattr);
-int presto_settime(struct presto_file_set *fset, struct dentry *newobj,
-                   struct dentry *parent, struct dentry *target,
-                   struct lento_vfs_context *ctx, int valid);
-int presto_ioctl(struct inode *inode, struct file *file,
-                 unsigned int cmd, unsigned long arg);
-
-extern int presto_ilookup_uid;
-# define PRESTO_ILOOKUP_MAGIC "...ino:"
-# define PRESTO_ILOOKUP_SEP ':'
-int izo_dentry_is_ilookup(struct dentry *, ino_t *id, unsigned int *generation);
-struct dentry *presto_lookup(struct inode * dir, struct dentry *dentry, struct nameidata *nd);
-
-struct presto_dentry_data {
-        int dd_count; /* how mnay dentries are using this dentry */
-        struct presto_file_set *dd_fset;
-        struct dentry *dd_inodentry; 
-        loff_t dd_kml_offset;
-        int dd_flags;
-        __u64 remote_ino;
-        __u64 remote_generation;
-};
-
-struct presto_file_data {
-        int fd_do_lml;
-        loff_t fd_lml_offset;
-        size_t fd_bytes_written;
-        /* authorization related data of file at open time */
-        uid_t fd_uid;
-        gid_t fd_gid;
-        mode_t fd_mode;
-        /* identification data of calling process */
-        uid_t fd_fsuid;
-        gid_t fd_fsgid;
-        int fd_ngroups;
-        gid_t fd_groups[NGROUPS_SMALL];
-        /* information how to complete the close operation */
-        struct lento_vfs_context fd_info;
-        struct presto_version fd_version;
-};
-
-/* presto.c and Lento::Downcall */
-
-int presto_walk(const char *name, struct nameidata *nd);
-int izo_clear_fsetroot(struct dentry *dentry);
-int izo_clear_all_fsetroots(struct presto_cache *cache);
-int presto_get_kmlsize(char *path, __u64 *size);
-int presto_get_lastrecno(char *path, off_t *size);
-int presto_set_fsetroot(struct dentry *dentry, char *fsetname,
-                       unsigned int flags);
-int presto_set_fsetroot_from_ioc(struct dentry *dentry, char *fsetname,
-                                 unsigned int flags);
-int presto_is_read_only(struct presto_file_set *);
-int presto_truncate_lml(struct presto_file_set *fset);
-int lento_write_lml(char *path,
-                     __u64 remote_ino,
-                     __u32 remote_generation,
-                     __u32 remote_version,
-                    struct presto_version *remote_file_version);
-int lento_complete_closes(char *path);
-int presto_f2m(struct presto_file_set *fset);
-int presto_prep(struct dentry *, struct presto_cache **,
-                       struct presto_file_set **);
-/* cache.c */
-extern struct presto_cache *presto_cache_init(void);
-extern void presto_cache_add(struct presto_cache *cache);
-extern void presto_cache_init_hash(void);
-
-struct presto_cache *presto_cache_find(struct super_block *sb);
-
-#define PRESTO_REQLOW  (3 * 4096)
-#define PRESTO_REQHIGH (6 * 4096)
-void presto_release_space(struct presto_cache *cache, loff_t req);
-int presto_reserve_space(struct presto_cache *cache, loff_t req);
-
-#define PRESTO_DATA             0x00000002 /* cached data is valid */
-#define PRESTO_ATTR             0x00000004 /* attributes cached */
-#define PRESTO_DONT_JOURNAL     0x00000008 /* things like .intermezzo/ */
-
-struct presto_file_set *presto_path2fileset(const char *name);
-int izo_revoke_permit(struct dentry *, uuid_t uuid);
-int presto_chk(struct dentry *dentry, int flag);
-void presto_set(struct dentry *dentry, int flag);
-int presto_get_permit(struct inode *inode);
-int presto_put_permit(struct inode *inode);
-int presto_set_max_kml_size(const char *path, unsigned long max_size);
-int izo_mark_dentry(struct dentry *dentry, int and, int or, int *res);
-int izo_mark_cache(struct dentry *dentry, int and_bits, int or_bits, int *);
-int izo_mark_fset(struct dentry *dentry, int and_bits, int or_bits, int *);
-void presto_getversion(struct presto_version *pv, struct inode *inode);
-int presto_i2m(struct inode *inode);
-int presto_c2m(struct presto_cache *cache);
-
-
-/* file.c */
-int izo_purge_file(struct presto_file_set *fset, char *file);
-int presto_adjust_lml(struct file *file, struct lento_vfs_context *info);
-
-/* journal.c */
-struct rec_info {
-        loff_t offset;
-        int size;
-        int recno;
-        int is_kml;
-};
-
-void presto_trans_commit(struct presto_file_set *fset, void *handle);
-void *presto_trans_start(struct presto_file_set *fset, struct inode *inode,
-                         int op);
-int presto_fread(struct file *file, char *str, int len, loff_t *off);
-int presto_clear_lml_close(struct presto_file_set *fset,
-                           loff_t  lml_offset);
-int presto_complete_lml(struct presto_file_set *fset);
-int presto_read_kml_logical_offset(struct rec_info *recinfo,
-                                   struct presto_file_set *fset);
-int presto_write_kml_logical_offset(struct presto_file_set *fset);
-struct file *presto_copy_kml_tail(struct presto_file_set *fset,
-                                  unsigned long int start);
-int presto_finish_kml_truncate(struct presto_file_set *fset,
-                               unsigned long int offset);
-int izo_lookup_file(struct presto_file_set *fset, char *path,
-                    struct nameidata *nd);
-int izo_do_truncate(struct presto_file_set *fset, struct dentry *dentry,
-                    loff_t length,  loff_t size_check);
-int izo_log_close(struct presto_log_fd *logfd);
-struct file *izo_log_open(struct presto_file_set *fset, char *name, int flags);
-int izo_init_kml_file(struct presto_file_set *, struct presto_log_fd *);
-int izo_init_lml_file(struct presto_file_set *, struct presto_log_fd *);
-int izo_init_last_rcvd_file(struct presto_file_set *, struct presto_log_fd *);
-
-/* vfs.c */
-
-/* Extra data needed in the KML for rollback operations; this structure is
- * passed around during the KML-writing process. */
-struct izo_rollback_data {
-        __u32 rb_mode;
-        __u32 rb_rdev;
-        __u64 rb_uid;
-        __u64 rb_gid;
-};
-
-int presto_write_last_rcvd(struct rec_info *recinfo,
-                           struct presto_file_set *fset,
-                           struct lento_vfs_context *info);
-void izo_get_rollback_data(struct inode *inode, struct izo_rollback_data *rb);
-int presto_do_close(struct presto_file_set *fset, struct file *file);
-int presto_do_setattr(struct presto_file_set *fset, struct dentry *dentry,
-                      struct iattr *iattr, struct lento_vfs_context *info);
-int presto_do_create(struct presto_file_set *fset, struct dentry *dir,
-                     struct dentry *dentry, int mode,
-                     struct lento_vfs_context *info);
-int presto_do_link(struct presto_file_set *fset, struct dentry *dir,
-                   struct dentry *old_dentry, struct dentry *new_dentry,
-                   struct lento_vfs_context *info);
-int presto_do_unlink(struct presto_file_set *fset, struct dentry *dir,
-                     struct dentry *dentry, struct lento_vfs_context *info);
-int presto_do_symlink(struct presto_file_set *fset, struct dentry *dir,
-                      struct dentry *dentry, const char *name,
-                      struct lento_vfs_context *info);
-int presto_do_mkdir(struct presto_file_set *fset, struct dentry *dir,
-                    struct dentry *dentry, int mode,
-                    struct lento_vfs_context *info);
-int presto_do_rmdir(struct presto_file_set *fset, struct dentry *dir,
-                    struct dentry *dentry, struct lento_vfs_context *info);
-int presto_do_mknod(struct presto_file_set *fset, struct dentry *dir,
-                    struct dentry *dentry, int mode, dev_t dev,
-                    struct lento_vfs_context *info);
-int do_rename(struct presto_file_set *fset, struct dentry *old_dir,
-              struct dentry *old_dentry, struct dentry *new_dir,
-              struct dentry *new_dentry, struct lento_vfs_context *info);
-int presto_do_statfs (struct presto_file_set *fset,
-                      struct kstatfs * buf);
-
-int lento_setattr(const char *name, struct iattr *iattr,
-                  struct lento_vfs_context *info);
-int lento_create(const char *name, int mode, struct lento_vfs_context *info);
-int lento_link(const char *oldname, const char *newname,
-               struct lento_vfs_context *info);
-int lento_unlink(const char *name, struct lento_vfs_context *info);
-int lento_symlink(const char *oldname,const char *newname,
-                  struct lento_vfs_context *info);
-int lento_mkdir(const char *name, int mode, struct lento_vfs_context *info);
-int lento_rmdir(const char *name, struct lento_vfs_context *info);
-int lento_mknod(const char *name, int mode, dev_t dev,
-                struct lento_vfs_context *info);
-int lento_rename(const char *oldname, const char *newname,
-                 struct lento_vfs_context *info);
-int lento_iopen(const char *name, ino_t ino, unsigned int generation,int flags);
-
-/* journal.c */
-
-#define JOURNAL_PAGE_SZ  PAGE_SIZE
-
-int presto_no_journal(struct presto_file_set *fset);
-int journal_fetch(int minor);
-int presto_log(struct presto_file_set *fset, struct rec_info *rec,
-               const char *buf, size_t size,
-               const char *string1, int len1, 
-               const char *string2, int len2,
-               const char *string3, int len3);
-int presto_get_fileid(int minor, struct presto_file_set *fset,
-                      struct dentry *dentry);
-int presto_journal_setattr(struct rec_info *rec, struct presto_file_set *fset,
-                           struct dentry *dentry, struct presto_version *old_ver,
-                           struct izo_rollback_data *, struct iattr *iattr);
-int presto_journal_create(struct rec_info *rec, struct presto_file_set *fset,
-                          struct dentry *dentry,
-                          struct presto_version *tgt_dir_ver,
-                          struct presto_version *new_file_ver, int mode);
-int presto_journal_link(struct rec_info *rec, struct presto_file_set *fset,
-                        struct dentry *src, struct dentry *tgt,
-                        struct presto_version *tgt_dir_ver,
-                        struct presto_version *new_link_ver);
-int presto_journal_unlink(struct rec_info *rec, struct presto_file_set *fset,
-                          struct dentry *dir,
-                          struct presto_version *tgt_dir_ver,
-                          struct presto_version *old_file_ver,
-                          struct izo_rollback_data *, struct dentry *dentry,
-                          char *old_target, int old_targetlen);
-int presto_journal_symlink(struct rec_info *rec, struct presto_file_set *fset,
-                           struct dentry *dentry, const char *target,
-                           struct presto_version *tgt_dir_ver,
-                           struct presto_version *new_link_ver);
-int presto_journal_mkdir(struct rec_info *rec, struct presto_file_set *fset,
-                         struct dentry *dentry,
-                         struct presto_version *tgt_dir_ver,
-                         struct presto_version *new_dir_ver, int mode);
-int presto_journal_rmdir(struct rec_info *rec, struct presto_file_set *fset,
-                         struct dentry *dentry,
-                         struct presto_version *tgt_dir_ver,
-                         struct presto_version *old_dir_ver,
-                         struct izo_rollback_data *, int len, const char *name);
-int presto_journal_mknod(struct rec_info *rec, struct presto_file_set *fset,
-                         struct dentry *dentry,
-                         struct presto_version *tgt_dir_ver,
-                         struct presto_version *new_node_ver, int mode,
-                         int dmajor, int dminor);
-int presto_journal_rename(struct rec_info *rec, struct presto_file_set *fset,
-                          struct dentry *src, struct dentry *tgt,
-                          struct presto_version *src_dir_ver,
-                          struct presto_version *tgt_dir_ver);
-int presto_journal_open(struct rec_info *, struct presto_file_set *,
-                        struct dentry *, struct presto_version *old_ver);
-int presto_journal_close(struct rec_info *rec, struct presto_file_set *,
-                         struct presto_file_data *, struct dentry *,
-                         struct presto_version *old_file_ver,
-                         struct presto_version *new_file_ver);
-int presto_write_lml_close(struct rec_info *rec,
-                           struct presto_file_set *fset, 
-                           struct file *file,
-                           __u64 remote_ino,
-                           __u64 remote_generation,
-                           struct presto_version *remote_version,
-                           struct presto_version *new_file_ver);
-void presto_log_op(void *data, int len);
-loff_t presto_kml_offset(struct presto_file_set *fset);
-
-/* upcall.c */
-#define SYNCHRONOUS 0
-#define ASYNCHRONOUS 1
-/* asynchronous calls */
-int izo_upc_kml(int minor, __u64 offset, __u32 first_recno, __u64 length,
-                __u32 last_recno, char *fsetname);
-int izo_upc_kml_truncate(int minor, __u64 length, __u32 last_recno,
-                         char *fsetname);
-int izo_upc_go_fetch_kml(int minor, char *fsetname, uuid_t uuid, __u64 kmlsize);
-int izo_upc_backfetch(int minor, char *path, char *fileset, 
-                      struct lento_vfs_context *);
-
-/* synchronous calls */
-int izo_upc_get_fileid(int minor, __u32 reclen, char *rec, 
-                       __u32 pathlen, char *path, char *fsetname);
-int izo_upc_permit(int minor, struct dentry *, __u32 pathlen, char *path,
-                   char *fset);
-int izo_upc_open(int minor, __u32 pathlen, char *path, char *fsetname, 
-                 struct lento_vfs_context *info);
-int izo_upc_connect(int minor, __u64 ip_address, __u64 port, __u8 uuid[16],
-                    int client_flag);
-int izo_upc_revoke_permit(int minor, char *fsetname, uuid_t uuid);
-int izo_upc_set_kmlsize(int minor, char *fsetname, uuid_t uuid, __u64 kmlsize);
-int izo_upc_client_make_branch(int minor, char *fsetname);
-int izo_upc_server_make_branch(int minor, char *fsetname);
-int izo_upc_branch_undo(int minor, char *fsetname, char *branchname);
-int izo_upc_branch_redo(int minor, char *fsetname, char *branchname);
-int izo_upc_repstatus(int minor,  char * fsetname, struct izo_rcvd_rec *lr_server);
-
-/* general mechanism */
-int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *, int async);
-
-/* replicator.c */
-int izo_repstatus(struct presto_file_set *fset, __u64 client_kmlsize, 
-                  struct izo_rcvd_rec *lr_client, struct izo_rcvd_rec *lr_server);
-int izo_rep_cache_init(struct presto_file_set *);
-loff_t izo_rcvd_get(struct izo_rcvd_rec *, struct presto_file_set *, char *uuid);
-loff_t izo_rcvd_write(struct presto_file_set *, struct izo_rcvd_rec *);
-loff_t izo_rcvd_upd_remote(struct presto_file_set *fset, char * uuid,  __u64 remote_recno,
-                           __u64 remote_offset);
-
-int izo_ioctl_packlen(struct izo_ioctl_data *data);
-
-/* sysctl.c */
-int init_intermezzo_sysctl(void);
-void cleanup_intermezzo_sysctl(void);
-
-/* ext_attr.c */
-/* We will be more tolerant than the default ea patch with attr name sizes and
- * the size of value. If these come via VFS from the default ea patches, the
- * corresponding character strings will be truncated anyway. During journalling- * we journal length for both name and value. See journal_set_ext_attr.
- */
-#define PRESTO_EXT_ATTR_NAME_MAX 128
-#define PRESTO_EXT_ATTR_VALUE_MAX 8192
-
-#define PRESTO_ALLOC(ptr, size)                                         \
-do {                                                                    \
-        long s = (size);                                                \
-        (ptr) = kmalloc(s, GFP_KERNEL);                                 \
-        if ((ptr) == NULL)                                              \
-                CERROR("IZO: out of memory at %s:%d (trying to "        \
-                       "allocate %ld)\n", __FILE__, __LINE__, s);       \
-        else {                                                          \
-                presto_kmem_inc((ptr), s);                              \
-                memset((ptr), 0, s);                                    \
-        }                                                               \
-        CDEBUG(D_MALLOC, "kmalloced: %ld at %p (tot %ld).\n",           \
-               s, (ptr), presto_kmemory);                               \
-} while (0)
-
-#define PRESTO_FREE(ptr, size)                                          \
-do {                                                                    \
-        long s = (size);                                                \
-        if ((ptr) == NULL) {                                            \
-                CERROR("IZO: free NULL pointer (%ld bytes) at "         \
-                       "%s:%d\n", s, __FILE__, __LINE__);               \
-                break;                                                  \
-        }                                                               \
-        kfree(ptr);                                                     \
-        CDEBUG(D_MALLOC, "kfreed: %ld at %p (tot %ld).\n",              \
-               s, (ptr), presto_kmemory);                               \
-        presto_kmem_dec((ptr), s);                                      \
-} while (0)
-
-static inline int dentry_name_cmp(struct dentry *dentry, char *name)
-{
-        return (strlen(name) == dentry->d_name.len &&
-                memcmp(name, dentry->d_name.name, dentry->d_name.len) == 0);
-}
-
-static inline char *strdup(char *str)
-{
-        char *tmp;
-        tmp = kmalloc(strlen(str) + 1, GFP_KERNEL);
-        if (tmp)
-                memcpy(tmp, str, strlen(str) + 1);
-               
-        return tmp;
-}
-
-static inline int izo_ioctl_is_invalid(struct izo_ioctl_data *data)
-{
-        if (data->ioc_len > (1<<30)) {
-                CERROR("IZO ioctl: ioc_len larger than 1<<30\n");
-                return 1;
-        }
-        if (data->ioc_inllen1 > (1<<30)) {
-                CERROR("IZO ioctl: ioc_inllen1 larger than 1<<30\n");
-                return 1;
-        }
-        if (data->ioc_inllen2 > (1<<30)) {
-                CERROR("IZO ioctl: ioc_inllen2 larger than 1<<30\n");
-                return 1;
-        }
-        if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
-                CERROR("IZO ioctl: inlbuf1 pointer but 0 length\n");
-                return 1;
-        }
-        if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
-                CERROR("IZO ioctl: inlbuf2 pointer but 0 length\n");
-                return 1;
-        }
-        if (data->ioc_pbuf1 && !data->ioc_plen1) {
-                CERROR("IZO ioctl: pbuf1 pointer but 0 length\n");
-                return 1;
-        }
-        if (data->ioc_pbuf2 && !data->ioc_plen2) {
-                CERROR("IZO ioctl: pbuf2 pointer but 0 length\n");
-                return 1;
-        }
-        if (izo_ioctl_packlen(data) != data->ioc_len ) {
-                CERROR("IZO ioctl: packlen exceeds ioc_len\n");
-                return 1;
-        }
-        if (data->ioc_inllen1 &&
-            data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
-                CERROR("IZO ioctl: inlbuf1 not 0 terminated\n");
-                return 1;
-        }
-        if (data->ioc_inllen2 &&
-            data->ioc_bulk[size_round(data->ioc_inllen1) + data->ioc_inllen2
-                           - 1] != '\0') {
-                CERROR("IZO ioctl: inlbuf2 not 0 terminated\n");
-                return 1;
-        }
-        return 0;
-}
-
-/* buffer MUST be at least the size of izo_ioctl_hdr */
-static inline int izo_ioctl_getdata(char *buf, char *end, void *arg)
-{
-        struct izo_ioctl_hdr *hdr;
-        struct izo_ioctl_data *data;
-        int err;
-        ENTRY;
-
-        hdr = (struct izo_ioctl_hdr *)buf;
-        data = (struct izo_ioctl_data *)buf;
-
-        err = copy_from_user(buf, (void *)arg, sizeof(*hdr));
-        if ( err ) {
-                EXIT;
-                return err;
-        }
-
-        if (hdr->ioc_version != IZO_IOCTL_VERSION) {
-                CERROR("IZO: version mismatch kernel vs application\n");
-                return -EINVAL;
-        }
-
-        if (hdr->ioc_len + buf >= end) {
-                CERROR("IZO: user buffer exceeds kernel buffer\n");
-                return -EINVAL;
-        }
-
-        if (hdr->ioc_len < sizeof(struct izo_ioctl_data)) {
-                CERROR("IZO: user buffer too small for ioctl\n");
-                return -EINVAL;
-        }
-
-        err = copy_from_user(buf, (void *)arg, hdr->ioc_len);
-        if ( err ) {
-                EXIT;
-                return err;
-        }
-
-        if (izo_ioctl_is_invalid(data)) {
-                CERROR("IZO: ioctl not correctly formatted\n");
-                return -EINVAL;
-        }
-
-        if (data->ioc_inllen1) {
-                data->ioc_inlbuf1 = &data->ioc_bulk[0];
-        }
-
-        if (data->ioc_inllen2) {
-                data->ioc_inlbuf2 = &data->ioc_bulk[0] +
-                        size_round(data->ioc_inllen1);
-        }
-
-        EXIT;
-        return 0;
-}
-
-# define MYPATHLEN(buffer, path) ((buffer) + PAGE_SIZE - (path))
-
-# define free kfree
-# define malloc(a) kmalloc(a, GFP_KERNEL)
-# define printf printk
-int kml_reint_rec(struct file *dir, struct izo_ioctl_data *data);
-int izo_get_fileid(struct file *dir, struct izo_ioctl_data *data);
-int izo_set_fileid(struct file *dir, struct izo_ioctl_data *data);
-
-#else /* __KERNEL__ */
-# include <stdlib.h>
-# include <stdio.h>
-# include <sys/types.h>
-# include <sys/ioctl.h>
-# include <string.h>
-
-# define printk printf
-# ifndef CERROR
-#   define CERROR printf
-# endif
-# define kmalloc(a,b) malloc(a)
-
-void init_fsreintdata (void);
-int kml_fsreint(struct kml_rec *rec, char *basedir);
-int kml_iocreint(__u32 size, char *ptr, __u32 offset, int dird,
-                 uuid_t uuid, __u32 generate_kml);
-
-static inline void izo_ioctl_init(struct izo_ioctl_data *data)
-{
-        memset(data, 0, sizeof(*data));
-        data->ioc_len = sizeof(*data);
-        data->ioc_version = IZO_IOCTL_VERSION;
-}
-
-static inline int
-izo_ioctl_pack(struct izo_ioctl_data *data, char **pbuf, int max)
-{
-        char *ptr;
-        struct izo_ioctl_data *overlay;
-        data->ioc_len = izo_ioctl_packlen(data);
-        data->ioc_version = IZO_IOCTL_VERSION;
-
-        if (*pbuf && izo_ioctl_packlen(data) > max)
-                return 1;
-        if (*pbuf == NULL)
-                *pbuf = malloc(data->ioc_len);
-        if (*pbuf == NULL)
-                return 1;
-        overlay = (struct izo_ioctl_data *)*pbuf;
-        memcpy(*pbuf, data, sizeof(*data));
-
-        ptr = overlay->ioc_bulk;
-        if (data->ioc_inlbuf1)
-                LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
-        if (data->ioc_inlbuf2)
-                LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
-        if (izo_ioctl_is_invalid(overlay))
-                return 1;
-
-        return 0;
-}
-
-#endif /* __KERNEL__*/
-
-#define IZO_ERROR_NAME 1
-#define IZO_ERROR_UPDATE 2
-#define IZO_ERROR_DELETE 3
-#define IZO_ERROR_RENAME 4
-
-static inline char *izo_error(int err)
-{
-#ifndef __KERNEL__
-        if (err <= 0)
-                return strerror(-err);
-#endif
-        switch (err) {
-        case IZO_ERROR_NAME:
-                return "InterMezzo name/name conflict";
-        case IZO_ERROR_UPDATE:
-                return "InterMezzo update/update conflict";
-        case IZO_ERROR_DELETE:
-                return "InterMezzo update/delete conflict";
-        case IZO_ERROR_RENAME:
-                return "InterMezzo rename/rename conflict";
-        }
-        return "Unknown InterMezzo error";
-}
-
-/* kml_unpack.c */
-char *kml_print_rec(struct kml_rec *rec, int brief);
-int kml_unpack(struct kml_rec *rec, char **buf, char *end);
-
-/* fs 2.5 compat */
-
-/* is_read_only() is replaced by bdev_read_only which takes struct
-   block_device *.  Since this is only needed for debugging, it can be
-   safely ignored now.
-*/
-#define is_read_only(dev) 0
-
-#endif
diff --git a/fs/intermezzo/intermezzo_idl.h b/fs/intermezzo/intermezzo_idl.h
deleted file mode 100644 (file)
index 4371b16..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- *  Copyright (C) 2001 Tacit Networks, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __INTERMEZZO_IDL_H__
-#define __INTERMEZZO_IDL_H__
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-/* this file contains all data structures used in InterMezzo's interfaces:
- * - upcalls
- * - ioctl's
- * - KML records
- * - RCVD records
- * - rpc's
- */ 
-
-/* UPCALL */
-#define INTERMEZZO_MINOR 248   
-
-
-#define IZO_UPC_VERSION 0x00010002
-#define IZO_UPC_PERMIT        1
-#define IZO_UPC_CONNECT       2
-#define IZO_UPC_GO_FETCH_KML  3
-#define IZO_UPC_OPEN          4
-#define IZO_UPC_REVOKE_PERMIT 5
-#define IZO_UPC_KML           6
-#define IZO_UPC_BACKFETCH     7
-#define IZO_UPC_KML_TRUNC     8
-#define IZO_UPC_SET_KMLSIZE   9
-#define IZO_UPC_BRANCH_UNDO   10
-#define IZO_UPC_BRANCH_REDO   11
-#define IZO_UPC_GET_FILEID    12
-#define IZO_UPC_CLIENT_MAKE_BRANCH    13
-#define IZO_UPC_SERVER_MAKE_BRANCH    14
-#define IZO_UPC_REPSTATUS    15
-
-#define IZO_UPC_LARGEST_OPCODE 15
-
-struct izo_upcall_hdr {
-        __u32 u_len;
-        __u32 u_version;
-        __u32 u_opc;
-        __u32 u_uniq;
-        __u32 u_pid;
-        __u32 u_uid;
-        __u32 u_pathlen;
-        __u32 u_fsetlen;
-        __u64 u_offset;
-        __u64 u_length;
-        __u32 u_first_recno;
-        __u32 u_last_recno;
-        __u32 u_async;
-        __u32 u_reclen;
-        __u8  u_uuid[16];
-};
-
-/* This structure _must_ sit at the beginning of the buffer */
-struct izo_upcall_resp {
-        __u32 opcode;
-        __u32 unique;    
-        __u32 result;
-};
-
-
-/* IOCTL */
-
-#define IZO_IOCTL_VERSION 0x00010003
-
-/* maximum size supported for ioc_pbuf1 */
-#define KML_MAX_BUF (64*1024)
-
-struct izo_ioctl_hdr { 
-        __u32  ioc_len;
-        __u32  ioc_version;
-};
-
-struct izo_ioctl_data {
-        __u32 ioc_len;
-        __u32 ioc_version;
-        __u32 ioc_izodev;
-        __u32 ioc_kmlrecno;
-        __u64 ioc_kmlsize;
-        __u32 ioc_flags;
-        __s32 ioc_inofd;
-        __u64 ioc_ino;
-        __u64 ioc_generation;
-        __u32 ioc_mark_what;
-        __u32 ioc_and_flag;
-        __u32 ioc_or_flag;
-        __u32 ioc_dev;
-        __u32 ioc_offset;
-        __u32 ioc_slot;
-        __u64 ioc_uid;
-        __u8  ioc_uuid[16];
-
-        __u32 ioc_inllen1;   /* path */
-        char *ioc_inlbuf1;
-        __u32 ioc_inllen2;   /* fileset */
-        char *ioc_inlbuf2;
-
-        __u32 ioc_plen1;     /* buffers in user space (KML) */
-        char *ioc_pbuf1;
-        __u32 ioc_plen2;     /* buffers in user space (KML) */
-        char *ioc_pbuf2;
-
-        char  ioc_bulk[0];
-};
-
-#define IZO_IOC_DEVICE          _IOW ('p',0x50, void *)
-#define IZO_IOC_REINTKML        _IOW ('p',0x51, void *)
-#define IZO_IOC_GET_RCVD        _IOW ('p',0x52, void *)
-#define IZO_IOC_SET_IOCTL_UID   _IOW ('p',0x53, void *)
-#define IZO_IOC_GET_KML_SIZE    _IOW ('p',0x54, void *)
-#define IZO_IOC_PURGE_FILE_DATA _IOW ('p',0x55, void *)
-#define IZO_IOC_CONNECT         _IOW ('p',0x56, void *)
-#define IZO_IOC_GO_FETCH_KML    _IOW ('p',0x57, void *)
-#define IZO_IOC_MARK            _IOW ('p',0x58, void *)
-#define IZO_IOC_CLEAR_FSET      _IOW ('p',0x59, void *)
-#define IZO_IOC_CLEAR_ALL_FSETS _IOW ('p',0x60, void *)
-#define IZO_IOC_SET_FSET        _IOW ('p',0x61, void *)
-#define IZO_IOC_REVOKE_PERMIT   _IOW ('p',0x62, void *)
-#define IZO_IOC_SET_KMLSIZE     _IOW ('p',0x63, void *)
-#define IZO_IOC_CLIENT_MAKE_BRANCH _IOW ('p',0x64, void *)
-#define IZO_IOC_SERVER_MAKE_BRANCH _IOW ('p',0x65, void *)
-#define IZO_IOC_BRANCH_UNDO    _IOW ('p',0x66, void *)
-#define IZO_IOC_BRANCH_REDO    _IOW ('p',0x67, void *)
-#define IZO_IOC_SET_PID        _IOW ('p',0x68, void *)
-#define IZO_IOC_SET_CHANNEL    _IOW ('p',0x69, void *)
-#define IZO_IOC_GET_CHANNEL    _IOW ('p',0x70, void *)
-#define IZO_IOC_GET_FILEID    _IOW ('p',0x71, void *)
-#define IZO_IOC_ADJUST_LML    _IOW ('p',0x72, void *)
-#define IZO_IOC_SET_FILEID    _IOW ('p',0x73, void *)
-#define IZO_IOC_REPSTATUS    _IOW ('p',0x74, void *)
-
-/* marking flags for fsets */
-#define FSET_CLIENT_RO        0x00000001
-#define FSET_LENTO_RO         0x00000002
-#define FSET_HASPERMIT        0x00000004 /* we have a permit to WB */
-#define FSET_INSYNC           0x00000008 /* this fileset is in sync */
-#define FSET_PERMIT_WAITING   0x00000010 /* Lento is waiting for permit */
-#define FSET_STEAL_PERMIT     0x00000020 /* take permit if Lento is dead */
-#define FSET_JCLOSE_ON_WRITE  0x00000040 /* Journal closes on writes */
-#define FSET_DATA_ON_DEMAND   0x00000080 /* update data on file_open() */
-#define FSET_PERMIT_EXCLUSIVE 0x00000100 /* only one permitholder allowed */
-#define FSET_HAS_BRANCHES     0x00000200 /* this fileset contains branches */
-#define FSET_IS_BRANCH        0x00000400 /* this fileset is a branch */
-#define FSET_FLAT_BRANCH      0x00000800 /* this fileset is ROOT with branches */
-
-/* what to mark indicator (ioctl parameter) */
-#define MARK_DENTRY   101
-#define MARK_FSET     102
-#define MARK_CACHE    103
-#define MARK_GETFL    104
-
-/* KML */
-
-#define KML_MAJOR_VERSION 0x00010000
-#define KML_MINOR_VERSION 0x00000002
-#define KML_OPCODE_NOOP          0
-#define KML_OPCODE_CREATE        1
-#define KML_OPCODE_MKDIR         2
-#define KML_OPCODE_UNLINK        3
-#define KML_OPCODE_RMDIR         4
-#define KML_OPCODE_CLOSE         5
-#define KML_OPCODE_SYMLINK       6
-#define KML_OPCODE_RENAME        7
-#define KML_OPCODE_SETATTR       8
-#define KML_OPCODE_LINK          9
-#define KML_OPCODE_OPEN          10
-#define KML_OPCODE_MKNOD         11
-#define KML_OPCODE_WRITE         12
-#define KML_OPCODE_RELEASE       13
-#define KML_OPCODE_TRUNC         14
-#define KML_OPCODE_SETEXTATTR    15
-#define KML_OPCODE_DELEXTATTR    16
-#define KML_OPCODE_KML_TRUNC     17
-#define KML_OPCODE_GET_FILEID    18
-#define KML_OPCODE_NUM           19
-/* new stuff */
-struct presto_version {
-        __u32 pv_mtime_sec;
-        __u32 pv_mtime_nsec;
-        __u32 pv_ctime_sec;
-        __u32 pv_ctime_nsec;
-        __u64 pv_size;
-};
-
-struct kml_prefix_hdr {
-        __u32                    len;
-        __u32                    version;
-        __u32                    pid;
-        __u32                    auid;
-        __u32                    fsuid;
-        __u32                    fsgid;
-        __u32                    opcode;
-        __u32                    ngroups;
-};
-
-struct kml_prefix { 
-        struct kml_prefix_hdr    *hdr;
-        __u32                    *groups;
-};
-
-struct kml_suffix { 
-        __u32                    prevrec;
-        __u32                    recno;
-        __u32                    time;
-        __u32                    len;
-};
-
-struct kml_rec {
-        char                   *buf;
-        struct kml_prefix       prefix;
-        __u64                   offset;
-        char                   *path;
-        int                     pathlen;
-        char                   *name;
-        int                     namelen;
-        char                   *target;
-        int                     targetlen;
-        struct presto_version  *old_objectv;
-        struct presto_version  *new_objectv;
-        struct presto_version  *old_parentv;
-        struct presto_version  *new_parentv;
-        struct presto_version  *old_targetv;
-        struct presto_version  *new_targetv;
-        __u32                   valid;
-        __u32                   mode;
-        __u32                   uid;
-        __u32                   gid;
-        __u64                   size;
-        __u32                   mtime_sec;
-        __u32                   mtime_nsec;
-        __u32                   ctime_sec;
-        __u32                   ctime_nsec;
-        __u32                   flags;
-        __u32                   ino;
-        __u32                   rdev;
-        __u32                   major;
-        __u32                   minor;
-        __u32                   generation;
-        __u32                   old_mode;
-        __u32                   old_rdev;
-        __u64                   old_uid;
-        __u64                   old_gid;
-        char                   *old_target;
-        int                     old_targetlen;
-        struct kml_suffix      *suffix;
-};
-
-
-/* RCVD */ 
-
-/* izo_rcvd_rec fills the .intermezzo/fset/last_rcvd file and provides data about
- * our view of reintegration offsets for a given peer.
- *
- * The only exception is the last_rcvd record which has a UUID consisting of all
- * zeroes; this record's lr_local_offset field is the logical byte offset of our
- * KML, which is updated when KML truncation takes place.  All other fields are
- * reserved. */
-
-/* XXX - document how clean shutdowns are recorded */
-
-struct izo_rcvd_rec { 
-        __u8    lr_uuid[16];       /* which peer? */
-        __u64   lr_remote_recno;   /* last confirmed remote recno  */
-        __u64   lr_remote_offset;  /* last confirmed remote offset */
-        __u64   lr_local_recno;    /* last locally reinted recno   */
-        __u64   lr_local_offset;   /* last locally reinted offset  */
-        __u64   lr_last_ctime;     /* the largest ctime that has reintegrated */
-};
-
-/* Cache purge database
- *
- * Each DB entry is this structure followed by the path name, no trailing NUL. */
-struct izo_purge_entry {
-        __u64 p_atime;
-        __u32 p_pathlen;
-};
-
-/* RPC */
-
-#endif
diff --git a/fs/intermezzo/intermezzo_journal.h b/fs/intermezzo/intermezzo_journal.h
deleted file mode 100644 (file)
index 99d588d..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __PRESTO_JOURNAL_H
-#define __PRESTO_JOURNAL_H
-
-
-struct journal_prefix {
-       int len;
-        u32 version;
-       int pid;
-       int uid;
-       int fsuid;
-       int fsgid;
-       int opcode;
-        u32 ngroups;
-        u32 groups[0];
-};
-
-struct journal_suffix {
-       unsigned long prevrec;  /* offset of previous record for dentry */
-       int recno;
-       int time;
-       int len;
-};
-
-#endif
diff --git a/fs/intermezzo/intermezzo_kml.h b/fs/intermezzo/intermezzo_kml.h
deleted file mode 100644 (file)
index ca612e6..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-#ifndef __INTERMEZZO_KML_H
-#define __INTERMEZZO_KML_H
-
-#include "intermezzo_psdev.h"
-#include <linux/fs.h>
-#include "intermezzo_journal.h"
-
-#define PRESTO_KML_MAJOR_VERSION 0x00010000
-#define PRESTO_KML_MINOR_VERSION 0x00002001
-#define PRESTO_OP_NOOP          0
-#define PRESTO_OP_CREATE        1
-#define PRESTO_OP_MKDIR         2
-#define PRESTO_OP_UNLINK        3
-#define PRESTO_OP_RMDIR         4
-#define PRESTO_OP_CLOSE         5
-#define PRESTO_OP_SYMLINK       6
-#define PRESTO_OP_RENAME        7
-#define PRESTO_OP_SETATTR       8
-#define PRESTO_OP_LINK          9
-#define PRESTO_OP_OPEN          10
-#define PRESTO_OP_MKNOD         11
-#define PRESTO_OP_WRITE         12
-#define PRESTO_OP_RELEASE       13
-#define PRESTO_OP_TRUNC         14
-#define PRESTO_OP_SETEXTATTR    15
-#define PRESTO_OP_DELEXTATTR    16
-
-#define PRESTO_LML_DONE        1 /* flag to get first write to do LML */
-#define KML_KOP_MARK            0xffff
-
-struct presto_lml_data {
-        loff_t   rec_offset;
-};
-
-struct big_journal_prefix {
-        u32 len;
-        u32 version; 
-        u32 pid;
-        u32 uid;
-        u32 fsuid;
-        u32 fsgid;
-        u32 opcode;
-        u32 ngroups;
-        u32 groups[NGROUPS_SMALL];
-};
-
-enum kml_opcode {
-        KML_CREATE = 1,
-        KML_MKDIR,
-        KML_UNLINK,
-        KML_RMDIR,
-        KML_CLOSE,
-        KML_SYMLINK,
-        KML_RENAME,
-        KML_SETATTR,
-        KML_LINK,
-        KML_OPEN,
-        KML_MKNOD,
-        KML_ENDMARK = 0xff
-};
-
-struct kml_create {
-       char                    *path;
-       struct presto_version   new_objectv, 
-                               old_parentv, 
-                               new_parentv;
-       int                     mode;
-       int                     uid;
-       int                     gid;
-};
-
-struct kml_open {
-};
-
-struct kml_mkdir {
-       char                    *path;
-       struct presto_version   new_objectv, 
-                               old_parentv, 
-                               new_parentv;
-       int                     mode;
-       int                     uid;
-       int                     gid;
-};
-
-struct kml_unlink {
-       char                    *path,  
-                               *name;
-       struct presto_version   old_tgtv, 
-                               old_parentv, 
-                               new_parentv;
-};
-
-struct kml_rmdir {
-       char                    *path, 
-                               *name;
-       struct presto_version   old_tgtv, 
-                               old_parentv, 
-                               new_parentv;
-};
-
-struct kml_close {
-       int                     open_mode, 
-                               open_uid, 
-                               open_gid;
-       char                    *path;
-       struct presto_version   new_objectv;
-       __u64                   ino;
-       int                     generation;
-};
-
-struct kml_symlink {
-       char                    *sourcepath,    
-                               *targetpath;
-       struct presto_version   new_objectv, 
-                               old_parentv, 
-                               new_parentv;
-       int                     uid;
-       int                     gid;
-};
-
-struct kml_rename {
-       char                    *sourcepath, 
-                               *targetpath;
-       struct presto_version   old_objectv, 
-                               new_objectv, 
-                               old_tgtv, 
-                               new_tgtv;
-};
-
-struct kml_setattr {
-       char                    *path;
-       struct presto_version   old_objectv;
-       struct iattr            iattr;
-};
-
-struct kml_link {
-       char                    *sourcepath,    
-                               *targetpath;
-       struct presto_version   new_objectv, 
-                               old_parentv, 
-                               new_parentv;
-};
-
-struct kml_mknod {
-       char                    *path;
-       struct presto_version   new_objectv, 
-                               old_parentv, 
-                               new_parentv;
-       int                     mode;
-       int                     uid;
-       int                     gid;
-               int                     major;
-       int                     minor;
-};
-
-/* kml record items for optimizing */
-struct kml_kop_node
-{
-        u32             kml_recno;
-        u32             kml_flag;
-        u32             kml_op;
-        nlink_t         i_nlink;
-        u32             i_ino;
-};
-
-struct kml_kop_lnode
-{
-        struct list_head chains;
-        struct kml_kop_node node;
-};
-
-struct kml_endmark {
-       u32                     total;
-       struct kml_kop_node     *kop;
-};
-
-/* kml_flag */
-#define  KML_REC_DELETE               1
-#define  KML_REC_EXIST                0
-
-struct kml_optimize {
-       struct list_head kml_chains;
-        u32              kml_flag;
-        u32              kml_op;
-        nlink_t          i_nlink;
-        u32              i_ino;
-};
-
-struct kml_rec {
-       /* attribute of this record */
-       int                             rec_size;
-        int                            rec_kml_offset;
-
-       struct  big_journal_prefix      rec_head;
-       union {
-               struct kml_create       create;
-               struct kml_open         open;
-               struct kml_mkdir        mkdir;
-               struct kml_unlink       unlink;
-               struct kml_rmdir        rmdir;
-               struct kml_close        close;
-               struct kml_symlink      symlink;
-               struct kml_rename       rename;
-               struct kml_setattr      setattr;
-               struct kml_mknod        mknod;
-               struct kml_link         link;
-               struct kml_endmark      endmark;
-       } rec_kml;
-        struct         journal_suffix          rec_tail;
-
-        /* for kml optimize only */
-        struct  kml_optimize kml_optimize;
-};
-
-/* kml record items for optimizing */
-extern void kml_kop_init (struct presto_file_set *fset);
-extern void kml_kop_addrec (struct presto_file_set *fset, 
-               struct inode *ino, u32 op, u32 flag);
-extern int  kml_kop_flush (struct presto_file_set *fset);
-
-/* defined in kml_setup.c */
-extern int kml_init (struct presto_file_set *fset);
-extern int kml_cleanup (struct presto_file_set *fset);
-
-/* defined in kml.c */
-extern int begin_kml_reint (struct file *file, unsigned long arg);
-extern int do_kml_reint (struct file *file, unsigned long arg);
-extern int end_kml_reint (struct file *file, unsigned long arg);
-
-/* kml_utils.c */
-extern char *dlogit (void *tbuf, const void *sbuf, int size);
-extern char * bdup_printf (char *format, ...);
-
-/* defined in kml_decode.c */
-/* printop */
-#define  PRINT_KML_PREFIX             0x1
-#define  PRINT_KML_SUFFIX             0x2
-#define  PRINT_KML_REC                0x4
-#define  PRINT_KML_OPTIMIZE           0x8
-#define  PRINT_KML_EXIST              0x10
-#define  PRINT_KML_DELETE             0x20
-extern void   kml_printrec (struct kml_rec *rec, int printop);
-extern int    print_allkmlrec (struct list_head *head, int printop);
-extern int    delete_kmlrec (struct list_head *head);
-extern int    kml_decoderec (char *buf, int pos, int buflen, int *size,
-                            struct kml_rec **newrec);
-extern int decode_kmlrec (struct list_head *head, char *kml_buf, int buflen);
-extern void kml_freerec (struct kml_rec *rec);
-
-/* defined in kml_reint.c */
-#define KML_CLOSE_BACKFETCH            1
-extern int kml_reintbuf (struct  kml_fsdata *kml_fsdata,
-                       char *mtpt, struct kml_rec **rec);
-
-/* defined in kml_setup.c */
-extern int kml_init (struct presto_file_set *fset);
-extern int kml_cleanup (struct presto_file_set *fset);
-
-#endif
-
diff --git a/fs/intermezzo/intermezzo_lib.h b/fs/intermezzo/intermezzo_lib.h
deleted file mode 100644 (file)
index 21cc0b9..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Data structures unpacking/packing macros & inlines
- *
- */
-
-#ifndef _INTERMEZZO_LIB_H
-#define _INTERMEZZO_LIB_H
-
-#ifdef __KERNEL__
-# include <linux/types.h>
-#else
-# include <string.h>
-# include <sys/types.h>
-#endif
-
-static inline int size_round (int val)
-{
-       return (val + 3) & (~0x3);
-}
-
-static inline int size_round0(int val)
-{
-        if (!val) 
-                return 0;
-       return (val + 1 + 3) & (~0x3);
-}
-
-static inline size_t round_strlen(char *fset)
-{
-       return size_round(strlen(fset) + 1);
-}
-
-#ifdef __KERNEL__
-# define NTOH__u32(var) le32_to_cpu(var)
-# define NTOH__u64(var) le64_to_cpu(var)
-# define HTON__u32(var) cpu_to_le32(var)
-# define HTON__u64(var) cpu_to_le64(var)
-#else
-# include <glib.h>
-# define NTOH__u32(var) GUINT32_FROM_LE(var)
-# define NTOH__u64(var) GUINT64_FROM_LE(var)
-# define HTON__u32(var) GUINT32_TO_LE(var)
-# define HTON__u64(var) GUINT64_TO_LE(var)
-#endif
-
-/* 
- * copy sizeof(type) bytes from pointer to var and move ptr forward.
- * return EFAULT if pointer goes beyond end
- */
-#define UNLOGV(var,type,ptr,end)                \
-do {                                            \
-        var = *(type *)ptr;                     \
-        ptr += sizeof(type);                    \
-        if (ptr > end )                         \
-                return -EFAULT;                 \
-} while (0)
-
-/* the following two macros convert to little endian */
-/* type MUST be __u32 or __u64 */
-#define LUNLOGV(var,type,ptr,end)               \
-do {                                            \
-        var = NTOH##type(*(type *)ptr);         \
-        ptr += sizeof(type);                    \
-        if (ptr > end )                         \
-                return -EFAULT;                 \
-} while (0)
-
-/* now log values */
-#define LOGV(var,type,ptr)                      \
-do {                                            \
-        *((type *)ptr) = var;                   \
-        ptr += sizeof(type);                    \
-} while (0)
-
-/* and in network order */
-#define LLOGV(var,type,ptr)                     \
-do {                                            \
-        *((type *)ptr) = HTON##type(var);       \
-        ptr += sizeof(type);                    \
-} while (0)
-
-
-/* 
- * set var to point at (type *)ptr, move ptr forward with sizeof(type)
- * return from function with EFAULT if ptr goes beyond end
- */
-#define UNLOGP(var,type,ptr,end)                \
-do {                                            \
-        var = (type *)ptr;                      \
-        ptr += sizeof(type);                    \
-        if (ptr > end )                         \
-                return -EFAULT;                 \
-} while (0)
-
-#define LOGP(var,type,ptr)                      \
-do {                                            \
-        memcpy(ptr, var, sizeof(type));         \
-        ptr += sizeof(type);                    \
-} while (0)
-
-/* 
- * set var to point at (char *)ptr, move ptr forward by size_round(len);
- * return from function with EFAULT if ptr goes beyond end
- */
-#define UNLOGL(var,type,len,ptr,end)                    \
-do {                                                    \
-        if (len == 0)                                   \
-                var = (type *)0;                        \
-        else {                                          \
-                var = (type *)ptr;                      \
-                ptr += size_round(len * sizeof(type));  \
-        }                                               \
-        if (ptr > end )                                 \
-                return -EFAULT;                         \
-} while (0)
-
-#define UNLOGL0(var,type,len,ptr,end)                           \
-do {                                                            \
-        UNLOGL(var,type,len+1,ptr,end);                         \
-        if ( *((char *)ptr - size_round(len+1) + len) != '\0')  \
-                        return -EFAULT;                         \
-} while (0)
-
-#define LOGL(var,len,ptr)                               \
-do {                                                    \
-        size_t __fill = size_round(len);                \
-        /* Prevent data leakage. */                     \
-        if (__fill > 0)                                 \
-                memset((char *)ptr, 0, __fill);         \
-        memcpy((char *)ptr, (const char *)var, len);    \
-        ptr += __fill;                                  \
-} while (0)
-
-#define LOGL0(var,len,ptr)                              \
-do {                                                    \
-        if (!len) break;                                \
-        memcpy((char *)ptr, (const char *)var, len);    \
-        *((char *)(ptr) + len) = 0;                     \
-        ptr += size_round(len + 1);                     \
-} while (0)
-
-#endif /* _INTERMEZZO_LIB_H */
-
diff --git a/fs/intermezzo/intermezzo_psdev.h b/fs/intermezzo/intermezzo_psdev.h
deleted file mode 100644 (file)
index fff728a..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- */
-
-#ifndef __PRESTO_PSDEV_H
-#define __PRESTO_PSDEV_H
-
-#define MAX_CHANNEL 16
-#define PROCNAME_SIZE 32
-#include <linux/smp_lock.h>
-
-/* represents state of an instance reached with /dev/intermezzo */
-/* communication pending & processing queues */
-struct upc_channel {
-        unsigned int         uc_seq;
-        wait_queue_head_t    uc_waitq;    /* Lento wait queue */
-        struct list_head     uc_pending;
-        struct list_head     uc_processing;
-        spinlock_t            uc_lock;
-        int                  uc_pid;      /* Lento's pid */
-        int                  uc_hard;     /* allows signals during upcalls */
-        int                  uc_no_filter;
-        int                  uc_no_journal;
-        int                  uc_no_upcall;
-        int                  uc_timeout;  /* . sec: signals will dequeue upc */
-        long                 uc_errorval; /* for testing I/O failures */
-        struct list_head     uc_cache_list;
-        int                  uc_minor;
-};
-
-#define ISLENTO(minor) (current->pid == izo_channels[minor].uc_pid \
-                || current->real_parent->pid == izo_channels[minor].uc_pid \
-                || current->real_parent->real_parent->pid == izo_channels[minor].uc_pid)
-
-extern struct upc_channel izo_channels[MAX_CHANNEL];
-
-/* message types between presto filesystem in kernel */
-#define REQ_READ   1
-#define REQ_WRITE  2
-#define REQ_ASYNC  4
-#define REQ_DEAD   8
-
-struct upc_req {
-        struct list_head   rq_chain;
-        caddr_t            rq_data;
-        int                rq_flags;
-        int                rq_bufsize;
-        int                rq_rep_size;
-        int                rq_opcode;  /* copied from data to save lookup */
-        int                rq_unique;
-        wait_queue_head_t  rq_sleep;   /* process' wait queue */
-        unsigned long      rq_posttime;
-};
-
-#endif
diff --git a/fs/intermezzo/intermezzo_upcall.h b/fs/intermezzo/intermezzo_upcall.h
deleted file mode 100644 (file)
index 0b3e6ff..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Based on cfs.h from Coda, but revamped for increased simplicity.
- * Linux modifications by Peter Braam, Aug 1996
- * Rewritten for InterMezzo
- */
-
-#ifndef _PRESTO_HEADER_
-#define _PRESTO_HEADER_
-
-
-/* upcall.c */
-#define SYNCHRONOUS 0
-#define ASYNCHRONOUS 1
-
-int lento_permit(int minor, int pathlen, int fsetnamelen, char *path, char *fset);
-int lento_opendir(int minor, int pathlen, char *path, int async);
-int lento_kml(int minor, unsigned int offset, unsigned int first_recno,
-              unsigned int length, unsigned int last_recno, int namelen,
-              char *fsetname);
-int lento_open(int minor, int pathlen, char *path);
-int lento_journal(int minor, char *page, int async);
-int lento_release_permit(int minor, int cookie);
-
-/*
- * Kernel <--> Lento communications.
- */
-/* upcalls */
-#define LENTO_PERMIT    1
-#define LENTO_JOURNAL   2
-#define LENTO_OPENDIR   3
-#define LENTO_OPEN      4
-#define LENTO_SIGNAL    5
-#define LENTO_KML       6
-#define LENTO_COOKIE    7
-
-/*         Lento <-> Presto  RPC arguments       */
-struct lento_up_hdr {
-        unsigned int opcode;
-        unsigned int unique;    /* Keep multiple outstanding msgs distinct */
-        u_short pid;            /* Common to all */
-        u_short uid;
-};
-
-/* This structure _must_ sit at the beginning of the buffer */
-struct lento_down_hdr {
-        unsigned int opcode;
-        unsigned int unique;    
-        unsigned int result;
-};
-
-/* lento_permit: */
-struct lento_permit_in {
-        struct lento_up_hdr uh;
-        int pathlen;
-        int fsetnamelen;
-        char path[0];
-};
-struct lento_permit_out {
-        struct lento_down_hdr dh;
-};
-
-
-/* lento_opendir: */
-struct lento_opendir_in {
-        struct lento_up_hdr uh;
-        int async;
-        int pathlen;
-        char path[0];
-};
-struct lento_opendir_out {
-        struct lento_down_hdr dh;
-};
-
-
-/* lento_kml: */
-struct lento_kml_in {
-        struct lento_up_hdr uh;
-        unsigned int offset;
-        unsigned int first_recno;
-        unsigned int length;
-        unsigned int last_recno;
-        int namelen;
-        char fsetname[0];
-};
-
-struct lento_kml_out {
-        struct lento_down_hdr dh;
-};
-
-
-/* lento_open: */
-struct lento_open_in {
-        struct lento_up_hdr uh;
-        int pathlen;
-        char path[0];
-};
-struct lento_open_out {
-    struct lento_down_hdr dh;
-};
-
-/* lento_response_cookie */
-struct lento_response_cookie_in {
-        struct lento_up_hdr uh;
-        int cookie;
-};
-
-struct lento_response_cookie_out {
-    struct lento_down_hdr dh;
-};
-
-
-struct lento_mknod {
-  struct lento_down_hdr dh;
-  int    major;
-  int    minor;
-  int    mode;
-  char   path[0];
-};
-
-
-/* NB: every struct below begins with an up_hdr */
-union up_args {
-    struct lento_up_hdr uh;             
-    struct lento_permit_in lento_permit;
-    struct lento_open_in lento_open;
-    struct lento_opendir_in lento_opendir;
-    struct lento_kml_in lento_kml;
-    struct lento_response_cookie_in lento_response_cookie;
-};
-
-union down_args {
-    struct lento_down_hdr dh;
-    struct lento_permit_out lento_permit;
-    struct lento_open_out lento_open;
-    struct lento_opendir_out lento_opendir;
-    struct lento_kml_out lento_kml;
-    struct lento_response_cookie_out lento_response_cookie;
-};    
-
-#include "intermezzo_psdev.h"
-
-int lento_upcall(int minor, int read_size, int *rep_size, 
-                 union up_args *buffer, int async,
-                 struct upc_req *rq );
-#endif 
-
diff --git a/fs/intermezzo/journal.c b/fs/intermezzo/journal.c
deleted file mode 100644 (file)
index 2beda38..0000000
+++ /dev/null
@@ -1,2452 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam
- *  Copyright (C) 2001 Cluster File Systems, Inc. 
- *  Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- *  Support for journalling extended attributes
- *  Copyright (C) 2001 Shirish H. Phatak, Tacit Networks, Inc.
- * 
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/time.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-struct presto_reservation_data {
-        unsigned int ri_recno;
-        loff_t ri_offset;
-        loff_t ri_size;
-        struct list_head ri_list;
-};
-
-/* 
- *  Locking Semantics
- * 
- * write lock in struct presto_log_fd: 
- *  - name: fd_lock
- *  - required for: accessing any field in a presto_log_fd 
- *  - may not be held across I/O
- *  - 
- *  
- */
-
-/*
- *  reserve record space and/or atomically request state of the log
- *  rec will hold the location reserved record upon return
- *  this reservation will be placed in the queue
- */ 
-static void presto_reserve_record(struct presto_file_set *fset, 
-                           struct presto_log_fd *fd, 
-                           struct rec_info *rec,
-                           struct presto_reservation_data *rd)
-{
-        int chunked_record = 0; 
-        ENTRY;
-        
-        write_lock(&fd->fd_lock);
-        if ( rec->is_kml ) { 
-                int chunk = 1 << fset->fset_chunkbits;
-                int chunk_mask = ~(chunk -1); 
-                loff_t boundary; 
-
-                boundary =  (fd->fd_offset + chunk - 1) & chunk_mask;
-                if ( fd->fd_offset + rec->size >= boundary ) {
-                        chunked_record = 1;
-                        fd->fd_offset = boundary; 
-                }
-        }
-
-        fd->fd_recno++;
-        
-        /* this moves the fd_offset back after truncation */ 
-        if ( list_empty(&fd->fd_reservations) && 
-             !chunked_record) { 
-                fd->fd_offset = fd->fd_file->f_dentry->d_inode->i_size;
-        }
-
-        rec->offset = fd->fd_offset;
-        if (rec->is_kml)
-                rec->offset += fset->fset_kml_logical_off;
-
-        rec->recno = fd->fd_recno;
-
-        /* add the reservation data to the end of the list */
-        rd->ri_offset = fd->fd_offset;
-        rd->ri_size = rec->size;
-        rd->ri_recno = rec->recno; 
-        list_add(&rd->ri_list, fd->fd_reservations.prev);
-
-        fd->fd_offset += rec->size;
-
-        write_unlock(&fd->fd_lock); 
-
-        EXIT;
-}
-
-static inline void presto_release_record(struct presto_log_fd *fd,
-                                         struct presto_reservation_data *rd)
-{
-        write_lock(&fd->fd_lock);
-        list_del(&rd->ri_list);
-        write_unlock(&fd->fd_lock);
-}
-
-/* XXX should we ask for do_truncate to be exported? */
-int izo_do_truncate(struct presto_file_set *fset, struct dentry *dentry,
-                    loff_t length,  loff_t size_check)
-{
-        struct inode *inode = dentry->d_inode;
-        int error;
-        struct iattr newattrs;
-
-        ENTRY;
-
-        if (length < 0) {
-                EXIT;
-                return -EINVAL;
-        }
-
-        down(&inode->i_sem);
-        lock_kernel();
-        
-        if (size_check != inode->i_size) { 
-                unlock_kernel();
-                up(&inode->i_sem);
-                EXIT;
-                return -EALREADY; 
-        }
-
-        newattrs.ia_size = length;
-        newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-
-        if (inode->i_op && inode->i_op->setattr)
-                error = inode->i_op->setattr(dentry, &newattrs);
-        else {
-                inode_setattr(dentry->d_inode, &newattrs);
-                error = 0;
-        }
-
-        unlock_kernel();
-        up(&inode->i_sem);
-        EXIT;
-        return error;
-}
-
-static void presto_kml_truncate(struct presto_file_set *fset)
-{
-        int rc;
-        ENTRY;
-
-        write_lock(&fset->fset_kml.fd_lock);
-        if (fset->fset_kml.fd_truncating == 1 ) {
-                write_unlock(&fset->fset_kml.fd_lock);
-                EXIT;
-                return;
-        }
-
-        fset->fset_kml.fd_truncating = 1;
-        write_unlock(&fset->fset_kml.fd_lock);
-
-        CERROR("islento: %d, count: %d\n",
-               ISLENTO(presto_i2m(fset->fset_dentry->d_inode)),
-               fset->fset_permit_count);
-
-        rc = izo_upc_kml_truncate(fset->fset_cache->cache_psdev->uc_minor,
-                                fset->fset_lento_off, fset->fset_lento_recno,
-                                fset->fset_name);
-
-        /* Userspace is the only permitholder now, and will retain an exclusive
-         * hold on the permit until KML truncation completes. */
-        /* FIXME: double check this code path now that the precise semantics of
-         * fset->fset_permit_count have changed. */
-
-        if (rc != 0) {
-                write_lock(&fset->fset_kml.fd_lock);
-                fset->fset_kml.fd_truncating = 0;
-                write_unlock(&fset->fset_kml.fd_lock);
-        }
-
-        EXIT;
-}
-
-void *presto_trans_start(struct presto_file_set *fset, struct inode *inode,
-                         int op)
-{
-        ENTRY;
-        if ( !fset->fset_cache->cache_filter->o_trops ) {
-                EXIT;
-                return NULL;
-        }
-        EXIT;
-        return fset->fset_cache->cache_filter->o_trops->tr_start
-                (fset, inode, op);
-}
-
-void presto_trans_commit(struct presto_file_set *fset, void *handle)
-{
-        ENTRY;
-        if (!fset->fset_cache->cache_filter->o_trops ) {
-                EXIT;
-                return;
-        }
-
-        fset->fset_cache->cache_filter->o_trops->tr_commit(fset, handle);
-
-        /* Check to see if the KML needs truncated. */
-        if (fset->kml_truncate_size > 0 &&
-            !fset->fset_kml.fd_truncating &&
-            fset->fset_kml.fd_offset > fset->kml_truncate_size) {
-                CDEBUG(D_JOURNAL, "kml size: %lu; truncating\n",
-                       (unsigned long)fset->fset_kml.fd_offset);
-                presto_kml_truncate(fset);
-        }
-        EXIT;
-}
-
-inline int presto_no_journal(struct presto_file_set *fset)
-{
-        int minor = fset->fset_cache->cache_psdev->uc_minor;
-        return izo_channels[minor].uc_no_journal;
-}
-
-#define size_round(x)  (((x)+3) & ~0x3)
-
-#define BUFF_FREE(buf) PRESTO_FREE(buf, PAGE_SIZE)
-#define BUFF_ALLOC(newbuf, oldbuf)              \
-        PRESTO_ALLOC(newbuf, PAGE_SIZE);        \
-        if ( !newbuf ) {                        \
-                if (oldbuf)                     \
-                        BUFF_FREE(oldbuf);      \
-                return -ENOMEM;                 \
-        }
-
-/*
- * "buflen" should be PAGE_SIZE or more.
- * Give relative path wrt to a fsetroot
- */
-char * presto_path(struct dentry *dentry, struct dentry *root,
-                   char *buffer, int buflen)
-{
-        char * end = buffer+buflen;
-        char * retval;
-
-        *--end = '\0';
-        buflen--;
-        if (dentry->d_parent != dentry && d_unhashed(dentry)) {
-                buflen -= 10;
-                end -= 10;
-                memcpy(end, " (deleted)", 10);
-        }
-
-        /* Get '/' right */
-        retval = end-1;
-        *retval = '/';
-
-        for (;;) {
-                struct dentry * parent;
-                int namelen;
-
-                if (dentry == root)
-                        break;
-                parent = dentry->d_parent;
-                if (dentry == parent)
-                        break;
-                namelen = dentry->d_name.len;
-                buflen -= namelen + 1;
-                if (buflen < 0)
-                        break;
-                end -= namelen;
-                memcpy(end, dentry->d_name.name, namelen);
-                *--end = '/';
-                retval = end;
-                dentry = parent;
-        }
-        return retval;
-}
-
-static inline char *logit(char *buf, const void *value, int size)
-{
-        char *ptr = (char *)value;
-
-        memcpy(buf, ptr, size);
-        buf += size;
-        return buf;
-}
-
-
-static inline char *
-journal_log_prefix_with_groups_and_ids(char *buf, int opcode, 
-                                       struct rec_info *rec,
-                                       __u32 ngroups, gid_t *groups,
-                                       __u32 fsuid, __u32 fsgid)
-{
-        struct kml_prefix_hdr p;
-        u32 loggroups[NGROUPS_SMALL];
-
-        int i; 
-
-        p.len = cpu_to_le32(rec->size);
-        p.version = KML_MAJOR_VERSION | KML_MINOR_VERSION;
-        p.pid = cpu_to_le32(current->pid);
-        p.auid = cpu_to_le32(current->uid);
-        p.fsuid = cpu_to_le32(fsuid);
-        p.fsgid = cpu_to_le32(fsgid);
-        p.ngroups = cpu_to_le32(ngroups);
-        p.opcode = cpu_to_le32(opcode);
-        for (i=0 ; i < ngroups ; i++)
-                loggroups[i] = cpu_to_le32((__u32) groups[i]);
-
-        buf = logit(buf, &p, sizeof(struct kml_prefix_hdr));
-        buf = logit(buf, &loggroups, sizeof(__u32) * ngroups);
-        return buf;
-}
-
-static inline char *
-journal_log_prefix(char *buf, int opcode, struct rec_info *rec)
-{
-        __u32 groups[NGROUPS_SMALL]; 
-        int i; 
-
-        /* convert 16 bit gid's to 32 bit gid's */
-        for (i=0; i<current->group_info->ngroups; i++) 
-                groups[i] = GROUP_AT(current->group_info,i);
-        
-        return journal_log_prefix_with_groups_and_ids(buf, opcode, rec,
-                                                      (__u32)current->group_info->ngroups,
-                                                      groups,
-                                                      (__u32)current->fsuid,
-                                                      (__u32)current->fsgid);
-}
-
-static inline char *
-journal_log_prefix_with_groups(char *buf, int opcode, struct rec_info *rec, 
-                               __u32 ngroups, gid_t *groups)
-{
-        return journal_log_prefix_with_groups_and_ids(buf, opcode, rec,
-                                                      ngroups, groups,
-                                                      (__u32)current->fsuid,
-                                                      (__u32)current->fsgid);
-}
-
-static inline char *log_dentry_version(char *buf, struct dentry *dentry)
-{
-        struct presto_version version;
-
-        presto_getversion(&version, dentry->d_inode);
-        
-        version.pv_mtime_sec = HTON__u32(version.pv_mtime_sec);
-        version.pv_ctime_sec = HTON__u32(version.pv_ctime_sec);
-        version.pv_mtime_nsec = HTON__u32(version.pv_mtime_nsec);
-        version.pv_ctime_nsec = HTON__u32(version.pv_ctime_nsec);
-        version.pv_size = HTON__u64(version.pv_size);
-
-        return logit(buf, &version, sizeof(version));
-}
-
-static inline char *log_version(char *buf, struct presto_version *pv)
-{
-        struct presto_version version;
-
-        memcpy(&version, pv, sizeof(version));
-        
-        version.pv_mtime_sec = HTON__u32(version.pv_mtime_sec);
-        version.pv_mtime_nsec = HTON__u32(version.pv_mtime_nsec);
-        version.pv_ctime_sec = HTON__u32(version.pv_ctime_sec);
-        version.pv_ctime_nsec = HTON__u32(version.pv_ctime_nsec);
-        version.pv_size = HTON__u64(version.pv_size);
-
-        return logit(buf, &version, sizeof(version));
-}
-
-static inline char *log_rollback(char *buf, struct izo_rollback_data *rb)
-{
-        struct izo_rollback_data rollback;
-        
-        rollback.rb_mode = HTON__u32(rb->rb_mode);
-        rollback.rb_rdev = HTON__u32(rb->rb_rdev);
-        rollback.rb_uid = HTON__u64(rb->rb_uid);
-        rollback.rb_gid = HTON__u64(rb->rb_gid);
-
-        return logit(buf, &rollback, sizeof(rollback));
-}
-
-static inline char *journal_log_suffix(char *buf, char *log,
-                                       struct presto_file_set *fset,
-                                       struct dentry *dentry,
-                                       struct rec_info *rec)
-{
-        struct kml_suffix s;
-        struct kml_prefix_hdr *p = (struct kml_prefix_hdr *)log;
-
-#if 0
-        /* XXX needs to be done after reservation, 
-           disable ths until version 1.2 */
-        if ( dentry ) { 
-                s.prevrec = cpu_to_le32(rec->offset - 
-                                        presto_d2d(dentry)->dd_kml_offset);
-                presto_d2d(dentry)->dd_kml_offset = rec->offset;
-        } else { 
-                s.prevrec = -1;
-        }
-#endif
-        s.prevrec = 0; 
-
-        /* record number needs to be filled in after reservation 
-           s.recno = cpu_to_le32(rec->recno); */ 
-        s.time = cpu_to_le32(get_seconds());
-        s.len = p->len;
-        return logit(buf, &s, sizeof(s));
-}
-
-int izo_log_close(struct presto_log_fd *logfd)
-{
-        int rc = 0;
-
-        if (logfd->fd_file) {
-                rc = filp_close(logfd->fd_file, 0);
-                logfd->fd_file = NULL;
-        } else
-                CERROR("InterMezzo: %s: no filp\n", __FUNCTION__);
-        if (rc != 0)
-                CERROR("InterMezzo: close files: filp won't close: %d\n", rc);
-
-        return rc;
-}
-
-int presto_fwrite(struct file *file, const char *str, int len, loff_t *off)
-{
-        int rc;
-        mm_segment_t old_fs;
-        ENTRY;
-
-        rc = -EINVAL;
-        if ( !off ) {
-                EXIT;
-                return rc;
-        }
-
-        if ( ! file ) {
-                EXIT;
-                return rc;
-        }
-
-        if ( ! file->f_op ) {
-                EXIT;
-                return rc;
-        }
-
-        if ( ! file->f_op->write ) {
-                EXIT;
-                return rc;
-        }
-
-        old_fs = get_fs();
-        set_fs(get_ds());
-        rc = file->f_op->write(file, str, len, off);
-        if (rc != len) {
-                CERROR("presto_fwrite: wrote %d bytes instead of "
-                       "%d at %ld\n", rc, len, (long)*off);
-                rc = -EIO; 
-        }
-        set_fs(old_fs);
-        EXIT;
-        return rc;
-}
-
-int presto_fread(struct file *file, char *str, int len, loff_t *off)
-{
-        int rc;
-        mm_segment_t old_fs;
-        ENTRY;
-
-        if (len > 512)
-                CERROR("presto_fread: read at %Ld for %d bytes, ino %ld\n",
-                       *off, len, file->f_dentry->d_inode->i_ino); 
-
-        rc = -EINVAL;
-        if ( !off ) {
-                EXIT;
-                return rc;
-        }
-
-        if ( ! file ) {
-                EXIT;
-                return rc;
-        }
-
-        if ( ! file->f_op ) {
-                EXIT;
-                return rc;
-        }
-
-        if ( ! file->f_op->read ) {
-                EXIT;
-                return rc;
-        }
-
-        old_fs = get_fs();
-        set_fs(get_ds());
-        rc = file->f_op->read(file, str, len, off);
-        if (rc != len) {
-                CDEBUG(D_FILE, "presto_fread: read %d bytes instead of "
-                       "%d at %Ld\n", rc, len, *off);
-                rc = -EIO; 
-        }
-        set_fs(old_fs);
-        EXIT;
-        return rc;
-}
-
-loff_t presto_kml_offset(struct presto_file_set *fset)
-{
-        unsigned int kml_recno;
-        struct presto_log_fd *fd = &fset->fset_kml;
-        loff_t  offset;
-        ENTRY;
-
-        write_lock(&fd->fd_lock); 
-
-        /* Determine the largest valid offset, i.e. up until the first
-         * reservation held on the file. */
-        if ( !list_empty(&fd->fd_reservations) ) {
-                struct presto_reservation_data *rd;
-                rd = list_entry(fd->fd_reservations.next, 
-                                struct presto_reservation_data, 
-                                ri_list);
-                offset = rd->ri_offset;
-                kml_recno = rd->ri_recno;
-        } else {
-                offset = fd->fd_file->f_dentry->d_inode->i_size;
-                kml_recno = fset->fset_kml.fd_recno; 
-        }
-        write_unlock(&fd->fd_lock); 
-        return offset; 
-}
-
-static int presto_kml_dispatch(struct presto_file_set *fset)
-{
-        int rc = 0;
-        unsigned int kml_recno;
-        struct presto_log_fd *fd = &fset->fset_kml;
-        loff_t offset;
-        ENTRY;
-
-        write_lock(&fd->fd_lock); 
-
-        /* Determine the largest valid offset, i.e. up until the first
-         * reservation held on the file. */
-        if ( !list_empty(&fd->fd_reservations) ) {
-                struct presto_reservation_data *rd;
-                rd = list_entry(fd->fd_reservations.next, 
-                                struct presto_reservation_data, 
-                                ri_list);
-                offset = rd->ri_offset;
-                kml_recno = rd->ri_recno;
-        } else {
-                offset = fd->fd_file->f_dentry->d_inode->i_size;
-                kml_recno = fset->fset_kml.fd_recno; 
-        }
-
-        if ( kml_recno < fset->fset_lento_recno ) {
-                CERROR("presto_kml_dispatch: smoke is coming\n"); 
-                write_unlock(&fd->fd_lock);
-                EXIT;
-                return 0; 
-        } else if ( kml_recno == fset->fset_lento_recno ) {
-                write_unlock(&fd->fd_lock);
-                EXIT;
-                return 0; 
-                /* XXX add a further "if" here to delay the KML upcall */ 
-#if 0
-        } else if ( kml_recno < fset->fset_lento_recno + 100) {
-                write_unlock(&fd->fd_lock);
-                EXIT;
-                return 0;
-#endif
-        }
-        CDEBUG(D_PIOCTL, "fset: %s\n", fset->fset_name);
-
-        rc = izo_upc_kml(fset->fset_cache->cache_psdev->uc_minor,
-                       fset->fset_lento_off, fset->fset_lento_recno,
-                       offset + fset->fset_kml_logical_off, kml_recno,
-                       fset->fset_name);
-
-        if ( rc ) {
-                write_unlock(&fd->fd_lock);
-                EXIT;
-                return rc;
-        }
-
-        fset->fset_lento_off = offset;
-        fset->fset_lento_recno = kml_recno; 
-        write_unlock(&fd->fd_lock);
-        EXIT;
-        return 0;
-}
-
-int izo_lookup_file(struct presto_file_set *fset, char *path,
-                    struct nameidata *nd)
-{
-        int error = 0;
-
-        CDEBUG(D_CACHE, "looking up: %s\n", path);
-
-        error = path_lookup(path, LOOKUP_PARENT, nd);
-        if (error) {
-                EXIT;
-                return error;
-        }
-
-        return 0;
-}
-
-/* FIXME: this function is a mess of locking and error handling.  There's got to
- * be a better way. */
-static int do_truncate_rename(struct presto_file_set *fset, char *oldname,
-                              char *newname)
-{
-        struct dentry *old_dentry, *new_dentry;
-        struct nameidata oldnd, newnd;
-        char *oldpath, *newpath;
-        int error;
-
-        ENTRY;
-
-        oldpath = izo_make_path(fset, oldname);
-        if (oldpath == NULL) {
-                EXIT;
-                return -ENOENT;
-        }
-
-        newpath = izo_make_path(fset, newname);
-        if (newpath == NULL) {
-                error = -ENOENT;
-                EXIT;
-                goto exit;
-        }
-
-        if ((error = izo_lookup_file(fset, oldpath, &oldnd)) != 0) {
-                EXIT;
-                goto exit1;
-        }
-
-        if ((error = izo_lookup_file(fset, newpath, &newnd)) != 0) {
-                EXIT;
-                goto exit2;
-        }
-
-        lock_rename(newnd.dentry, oldnd.dentry);
-        old_dentry = lookup_hash(&oldnd.last, oldnd.dentry);
-        error = PTR_ERR(old_dentry);
-        if (IS_ERR(old_dentry)) {
-                EXIT;
-                goto exit3;
-        }
-        error = -ENOENT;
-        if (!old_dentry->d_inode) {
-                EXIT;
-                goto exit4;
-        }
-        new_dentry = lookup_hash(&newnd.last, newnd.dentry);
-        error = PTR_ERR(new_dentry);
-        if (IS_ERR(new_dentry)) {
-                EXIT;
-                goto exit4;
-        }
-
-        {
-        extern int presto_rename(struct inode *old_dir,struct dentry *old_dentry,
-                                struct inode *new_dir,struct dentry *new_dentry);
-        error = presto_rename(old_dentry->d_parent->d_inode, old_dentry,
-                              new_dentry->d_parent->d_inode, new_dentry);
-        }
-
-        dput(new_dentry);
-        EXIT;
- exit4:
-        dput(old_dentry);
- exit3:
-        unlock_rename(newnd.dentry, oldnd.dentry);
-        path_release(&newnd);
- exit2:
-        path_release(&oldnd);
- exit1:
-        PRESTO_FREE(newpath, strlen(newpath) + 1);
- exit:
-        PRESTO_FREE(oldpath, strlen(oldpath) + 1);
-        return error;
-}
-
-/* This function is called with the fset->fset_kml.fd_lock held */
-int presto_finish_kml_truncate(struct presto_file_set *fset,
-                               unsigned long int offset)
-{
-        struct lento_vfs_context info;
-        void *handle;
-        struct file *f;
-        struct dentry *dentry;
-        int error = 0, len;
-        struct nameidata nd;
-        char *kmlpath = NULL, *smlpath = NULL;
-        ENTRY;
-
-        if (offset == 0) {
-                /* Lento couldn't do what it needed to; abort the truncation. */
-                fset->fset_kml.fd_truncating = 0;
-                EXIT;
-                return 0;
-        }
-
-        /* someone is about to write to the end of the KML; try again later. */
-        if ( !list_empty(&fset->fset_kml.fd_reservations) ) {
-                EXIT;
-                return -EAGAIN;
-        }
-
-        f = presto_copy_kml_tail(fset, offset);
-        if (IS_ERR(f)) {
-                EXIT;
-                return PTR_ERR(f);
-        }                        
-
-        /* In a single transaction:
-         *
-         *   - unlink 'kml'
-         *   - rename 'kml_tmp' to 'kml'
-         *   - unlink 'sml'
-         *   - rename 'sml_tmp' to 'sml'
-         *   - rewrite the first record of last_rcvd with the new kml
-         *     offset.
-         */
-        handle = presto_trans_start(fset, fset->fset_dentry->d_inode,
-                                    KML_OPCODE_KML_TRUNC);
-        if (IS_ERR(handle)) {
-                presto_release_space(fset->fset_cache, PRESTO_REQLOW);
-                CERROR("ERROR: presto_finish_kml_truncate: no space for transaction\n");
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memset(&info, 0, sizeof(info));
-        info.flags = LENTO_FL_IGNORE_TIME;
-
-        kmlpath = izo_make_path(fset, "kml");
-        if (kmlpath == NULL) {
-                error = -ENOMEM;
-                CERROR("make_path failed: ENOMEM\n");
-                EXIT;
-                goto exit_commit;
-        }
-
-        if ((error = izo_lookup_file(fset, kmlpath, &nd)) != 0) {
-                CERROR("izo_lookup_file(kml) failed: %d.\n", error);
-                EXIT;
-                goto exit_commit;
-        }
-        down(&nd.dentry->d_inode->i_sem);
-        dentry = lookup_hash(&nd.last, nd.dentry);
-        error = PTR_ERR(dentry);
-        if (IS_ERR(dentry)) {
-                up(&nd.dentry->d_inode->i_sem);
-                path_release(&nd);
-                CERROR("lookup_hash failed\n");
-                EXIT;
-                goto exit_commit;
-        }
-        error = presto_do_unlink(fset, dentry->d_parent, dentry, &info);
-        dput(dentry);
-        up(&nd.dentry->d_inode->i_sem);
-        path_release(&nd);
-
-        if (error != 0) {
-                CERROR("presto_do_unlink(kml) failed: %d.\n", error);
-                EXIT;
-                goto exit_commit;
-        }
-
-        smlpath = izo_make_path(fset, "sml");
-        if (smlpath == NULL) {
-                error = -ENOMEM;
-                CERROR("make_path() failed: ENOMEM\n");
-                EXIT;
-                goto exit_commit;
-        }
-
-        if ((error = izo_lookup_file(fset, smlpath, &nd)) != 0) {
-                CERROR("izo_lookup_file(sml) failed: %d.\n", error);
-                EXIT;
-                goto exit_commit;
-        }
-        down(&nd.dentry->d_inode->i_sem);
-        dentry = lookup_hash(&nd.last, nd.dentry);
-        error = PTR_ERR(dentry);
-        if (IS_ERR(dentry)) {
-                up(&nd.dentry->d_inode->i_sem);
-                path_release(&nd);
-                CERROR("lookup_hash failed\n");
-                EXIT;
-                goto exit_commit;
-        }
-        error = presto_do_unlink(fset, dentry->d_parent, dentry, &info);
-        dput(dentry);
-        up(&nd.dentry->d_inode->i_sem);
-        path_release(&nd);
-
-        if (error != 0) {
-                CERROR("presto_do_unlink(sml) failed: %d.\n", error);
-                EXIT;
-                goto exit_commit;
-        }
-
-        error = do_truncate_rename(fset, "kml_tmp", "kml");
-        if (error != 0)
-                CERROR("do_truncate_rename(kml_tmp, kml) failed: %d\n", error);
-        error = do_truncate_rename(fset, "sml_tmp", "sml");
-        if (error != 0)
-                CERROR("do_truncate_rename(sml_tmp, sml) failed: %d\n", error);
-
-        /* Write a new 'last_rcvd' record with the new KML offset */
-        fset->fset_kml_logical_off += offset;
-        CDEBUG(D_CACHE, "new kml_logical_offset: %Lu\n",
-               fset->fset_kml_logical_off);
-        if (presto_write_kml_logical_offset(fset) != 0) {
-                CERROR("presto_write_kml_logical_offset failed\n");
-        }
-
-        presto_trans_commit(fset, handle);
-
-        /* Everything was successful, so swap the KML file descriptors */
-        filp_close(fset->fset_kml.fd_file, NULL);
-        fset->fset_kml.fd_file = f;
-        fset->fset_kml.fd_offset -= offset;
-        fset->fset_kml.fd_truncating = 0;
-
-        EXIT;
-        return 0;
-
- exit_commit:
-        presto_trans_commit(fset, handle);
-        len = strlen("/.intermezzo/") + strlen(fset->fset_name) +strlen("sml");
-        if (kmlpath != NULL)
-                PRESTO_FREE(kmlpath, len);
-        if (smlpath != NULL)
-                PRESTO_FREE(smlpath, len);
-        return error;
-}
-
-/* structure of an extended log record:
-
-   buf-prefix  buf-body [string1 [string2 [string3]]] buf-suffix
-
-   note: moves offset forward
-*/
-static inline int presto_write_record(struct file *f, loff_t *off,
-                        const char *buf, size_t size,
-                        const char *string1, int len1, 
-                        const char *string2, int len2,
-                        const char *string3, int len3)
-{
-        size_t prefix_size; 
-        int rc;
-
-        prefix_size = size - sizeof(struct kml_suffix);
-        rc = presto_fwrite(f, buf, prefix_size, off);
-        if ( rc != prefix_size ) {
-                CERROR("Write error!\n");
-                EXIT;
-                return -EIO;
-        }
-
-        if  ( string1  && len1 ) {
-                rc = presto_fwrite(f, string1, len1, off);
-                if ( rc != len1 ) {
-                        CERROR("Write error!\n");
-                        EXIT;
-                        return -EIO;
-                }
-        }
-
-        if  ( string2 && len2 ) {
-                rc = presto_fwrite(f, string2, len2, off);
-                if ( rc != len2 ) {
-                        CERROR("Write error!\n");
-                        EXIT;
-                        return -EIO;
-                }
-        }
-
-        if  ( string3 && len3 ) {
-                rc = presto_fwrite(f, string3, len3, off);
-                if ( rc != len3 ) {
-                        CERROR("Write error!\n");
-                        EXIT;
-                        return -EIO;
-                }
-        }
-
-        rc = presto_fwrite(f, buf + prefix_size,
-                           sizeof(struct kml_suffix), off);
-        if ( rc != sizeof(struct kml_suffix) ) {
-                CERROR("Write error!\n");
-                EXIT;
-                return -EIO;
-        }
-        return 0;
-}
-
-
-/*
- * rec->size must be valid prior to calling this function.
- *
- * had to export this for branch_reinter in kml_reint.c 
- */
-int presto_log(struct presto_file_set *fset, struct rec_info *rec,
-               const char *buf, size_t size,
-               const char *string1, int len1, 
-               const char *string2, int len2,
-               const char *string3, int len3)
-{
-        int rc;
-        struct presto_reservation_data rd;
-        loff_t offset;
-        struct presto_log_fd *fd;
-        struct kml_suffix *s;
-        int prefix_size; 
-
-        ENTRY;
-
-        /* buf is NULL when no_journal is in effect */
-        if (!buf) {
-                EXIT;
-                return -EINVAL;
-        }
-
-        if (rec->is_kml) {
-                fd = &fset->fset_kml;
-        } else {
-                fd = &fset->fset_lml;
-        }
-
-        presto_reserve_record(fset, fd, rec, &rd);
-
-        if (rec->is_kml) {
-                if (rec->offset < fset->fset_kml_logical_off) {
-                        CERROR("record with pre-trunc offset.  tell phil.\n");
-                        BUG();
-                }
-                offset = rec->offset - fset->fset_kml_logical_off;
-        } else {
-                offset = rec->offset;
-        }
-
-        /* now we know the record number */ 
-        prefix_size = size - sizeof(struct kml_suffix);
-        s = (struct kml_suffix *) (buf + prefix_size); 
-        s->recno = cpu_to_le32(rec->recno); 
-
-        rc = presto_write_record(fd->fd_file, &offset, buf, size, 
-                                 string1, len1, string2, len2, string3, len3); 
-        if (rc) {
-                CERROR("presto: error writing record to %s\n",
-                        rec->is_kml ? "KML" : "LML"); 
-                return rc;
-        }
-        presto_release_record(fd, &rd);
-
-        rc = presto_kml_dispatch(fset);
-
-        EXIT;
-        return rc;
-}
-
-/* read from the record at tail */
-static int presto_last_record(struct presto_log_fd *fd, loff_t *size, 
-                             loff_t *tail_offset, __u32 *recno, loff_t tail)
-{
-        struct kml_suffix suffix;
-        int rc;
-        loff_t zeroes;
-
-        *recno = 0;
-        *tail_offset = 0;
-        *size = 0;
-        
-        if (tail < sizeof(struct kml_prefix_hdr) + sizeof(suffix)) {
-                EXIT;
-                return 0;
-        }
-
-        zeroes = tail - sizeof(int);
-        while ( zeroes >= 0 ) {
-                int data;
-                rc = presto_fread(fd->fd_file, (char *)&data, sizeof(data), 
-                                  &zeroes);
-                if ( rc != sizeof(data) ) { 
-                        rc = -EIO;
-                        return rc;
-                }
-                if (data)
-                        break;
-                zeroes -= 2 * sizeof(data);
-        }
-
-        /* zeroes at the begining of file. this is needed to prevent
-           presto_fread errors  -SHP
-        */
-        if (zeroes <= 0) return 0;
-                       
-        zeroes -= sizeof(suffix) + sizeof(int);
-        rc = presto_fread(fd->fd_file, (char *)&suffix, sizeof(suffix), &zeroes);
-        if ( rc != sizeof(suffix) ) {
-                EXIT;
-                return rc;
-        }
-        if ( suffix.len > 500 ) {
-                CERROR("InterMezzo: Warning long record tail at %ld, rec tail_offset at %ld (size %d)\n", 
-                        (long) zeroes, (long)*tail_offset, suffix.len); 
-        }
-
-        *recno = suffix.recno;
-        *size = suffix.len;
-        *tail_offset = zeroes;
-        return 0;
-}
-
-static int izo_kml_last_recno(struct presto_log_fd *logfd)
-{
-        int rc; 
-        loff_t size;
-        loff_t tail_offset;
-        int recno;
-        loff_t tail = logfd->fd_file->f_dentry->d_inode->i_size;
-
-        rc = presto_last_record(logfd, &size, &tail_offset, &recno, tail);
-        if (rc != 0) {
-                EXIT;
-                return rc;
-        }
-
-        logfd->fd_offset = tail_offset;
-        logfd->fd_recno = recno;
-        CDEBUG(D_JOURNAL, "setting fset_kml->fd_recno to %d, offset  %Ld\n",
-               recno, tail_offset); 
-        EXIT;
-        return 0;
-}
-
-struct file *izo_log_open(struct presto_file_set *fset, char *name, int flags)
-{
-        struct presto_cache *cache = fset->fset_cache;
-        struct file *f;
-        int error;
-        ENTRY;
-
-        f = izo_fset_open(fset, name, flags, 0644);
-        error = PTR_ERR(f);
-        if (IS_ERR(f)) {
-                EXIT;
-                return f;
-        }
-
-        error = -EINVAL;
-        if ( cache != presto_get_cache(f->f_dentry->d_inode) ) {
-                CERROR("InterMezzo: %s cache does not match fset cache!\n",name);
-                fset->fset_kml.fd_file = NULL;
-                filp_close(f, NULL);
-                f = NULL;
-                EXIT;
-                return f;
-        }
-
-        if (cache->cache_filter &&  cache->cache_filter->o_trops &&
-            cache->cache_filter->o_trops->tr_journal_data) {
-                cache->cache_filter->o_trops->tr_journal_data
-                        (f->f_dentry->d_inode);
-        } else {
-                CERROR("InterMezzo WARNING: no file data logging!\n"); 
-        }
-
-        EXIT;
-
-        return f;
-}
-
-int izo_init_kml_file(struct presto_file_set *fset, struct presto_log_fd *logfd)
-{
-        int error = 0;
-        struct file *f;
-
-        ENTRY;
-        if (logfd->fd_file) {
-                CDEBUG(D_INODE, "fset already has KML open\n");
-                EXIT;
-                return 0;
-        }
-
-        logfd->fd_lock = RW_LOCK_UNLOCKED;
-        INIT_LIST_HEAD(&logfd->fd_reservations); 
-        f = izo_log_open(fset, "kml",  O_RDWR | O_CREAT);
-        if (IS_ERR(f)) {
-                error = PTR_ERR(f);
-                return error;
-        }
-
-        logfd->fd_file = f;
-        error = izo_kml_last_recno(logfd);
-
-        if (error) {
-                logfd->fd_file = NULL;
-                filp_close(f, NULL);
-                CERROR("InterMezzo: IO error in KML of fset %s\n",
-                       fset->fset_name);
-                EXIT;
-                return error;
-        }
-        fset->fset_lento_off = logfd->fd_offset;
-        fset->fset_lento_recno = logfd->fd_recno;
-
-        EXIT;
-        return error;
-}
-
-int izo_init_last_rcvd_file(struct presto_file_set *fset, struct presto_log_fd *logfd)
-{
-        int error = 0;
-        struct file *f;
-        struct rec_info recinfo;
-
-        ENTRY;
-        if (logfd->fd_file != NULL) {
-                CDEBUG(D_INODE, "fset already has last_rcvd open\n");
-                EXIT;
-                return 0;
-        }
-
-        logfd->fd_lock = RW_LOCK_UNLOCKED;
-        INIT_LIST_HEAD(&logfd->fd_reservations); 
-        f = izo_log_open(fset, "last_rcvd", O_RDWR | O_CREAT);
-        if (IS_ERR(f)) {
-                error = PTR_ERR(f);
-                return error;
-        }
-
-        logfd->fd_file = f;
-        logfd->fd_offset = f->f_dentry->d_inode->i_size;
-
-        error = izo_rep_cache_init(fset);
-
-        if (presto_read_kml_logical_offset(&recinfo, fset) == 0) {
-                fset->fset_kml_logical_off = recinfo.offset;
-        } else {
-                /* The 'last_rcvd' file doesn't contain a kml offset record,
-                 * probably because we just created 'last_rcvd'.  Write one. */
-                fset->fset_kml_logical_off = 0;
-                presto_write_kml_logical_offset(fset);
-        }
-
-        EXIT;
-        return error;
-}
-
-int izo_init_lml_file(struct presto_file_set *fset, struct presto_log_fd *logfd)
-{
-        int error = 0;
-        struct file *f;
-
-        ENTRY;
-        if (logfd->fd_file) {
-                CDEBUG(D_INODE, "fset already has lml open\n");
-                EXIT;
-                return 0;
-        }
-
-        logfd->fd_lock = RW_LOCK_UNLOCKED;
-        INIT_LIST_HEAD(&logfd->fd_reservations); 
-        f = izo_log_open(fset, "lml", O_RDWR | O_CREAT);
-        if (IS_ERR(f)) {
-                error = PTR_ERR(f);
-                return error;
-        }
-
-        logfd->fd_file = f;
-        logfd->fd_offset = f->f_dentry->d_inode->i_size;
-
-        EXIT;
-        return error;
-}
-
-/* Get the KML-offset record from the last_rcvd file */
-int presto_read_kml_logical_offset(struct rec_info *recinfo,
-                                   struct presto_file_set *fset)
-{
-        loff_t off;
-        struct izo_rcvd_rec rec;
-        char uuid[16] = {0};
-
-        off = izo_rcvd_get(&rec, fset, uuid);
-        if (off < 0)
-                return -1;
-
-        recinfo->offset = rec.lr_local_offset;
-        return 0;
-}
-
-int presto_write_kml_logical_offset(struct presto_file_set *fset)
-{
-        loff_t rc;
-        struct izo_rcvd_rec rec;
-        char uuid[16] = {0};
-
-        rc = izo_rcvd_get(&rec, fset, uuid);
-        if (rc < 0)
-                memset(&rec, 0, sizeof(rec));
-
-        rec.lr_local_offset =
-                cpu_to_le64(fset->fset_kml_logical_off);
-
-        return izo_rcvd_write(fset, &rec);
-}
-
-struct file * presto_copy_kml_tail(struct presto_file_set *fset,
-                                   unsigned long int start)
-{
-        struct file *f;
-        int len;
-        loff_t read_off, write_off, bytes;
-
-        ENTRY;
-
-        /* Copy the tail of 'kml' to 'kml_tmp' */
-        f = izo_log_open(fset, "kml_tmp", O_RDWR);
-        if (IS_ERR(f)) {
-                EXIT;
-                return f;
-        }
-
-        write_off = 0;
-        read_off = start;
-        bytes = fset->fset_kml.fd_offset - start;
-        while (bytes > 0) {
-                char buf[4096];
-                int toread;
-
-                if (bytes > sizeof(buf))
-                        toread = sizeof(buf);
-                else
-                        toread = bytes;
-
-                len = presto_fread(fset->fset_kml.fd_file, buf, toread,
-                                   &read_off);
-                if (len <= 0)
-                        break;
-
-                if (presto_fwrite(f, buf, len, &write_off) != len) {
-                        filp_close(f, NULL);
-                        EXIT;
-                        return ERR_PTR(-EIO);
-                }
-
-                bytes -= len;
-        }
-
-        EXIT;
-        return f;
-}
-
-
-/* LML records here */
-/* this writes an LML record to the LML file (rec->is_kml =0)  */
-int presto_write_lml_close(struct rec_info *rec,
-                           struct presto_file_set *fset, 
-                           struct file *file,
-                           __u64 remote_ino,
-                           __u64 remote_generation,
-                           struct presto_version *remote_version,
-                           struct presto_version *new_file_ver)
-{
-        int opcode = KML_OPCODE_CLOSE;
-        char *buffer;
-        struct dentry *dentry = file->f_dentry; 
-        __u64 ino;
-        __u32 pathlen;
-        char *path;
-        __u32 generation;
-        int size;
-        char *logrecord;
-        char record[292];
-        struct dentry *root;
-        int error;
-
-        ENTRY;
-
-        if ( presto_no_journal(fset) ) {
-          EXIT;
-          return 0;
-        }
-        root = fset->fset_dentry;
-
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        CDEBUG(D_INODE, "Path: %s\n", path);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        ino = cpu_to_le64(dentry->d_inode->i_ino);
-        generation = cpu_to_le32(dentry->d_inode->i_generation);
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + sizeof(*new_file_ver) +
-                sizeof(ino) + sizeof(generation) + sizeof(pathlen) +
-                sizeof(remote_ino) + sizeof(remote_generation) + 
-                sizeof(remote_version) + sizeof(rec->offset) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-        
-        rec->is_kml = 0;
-        rec->size = size + size_round(le32_to_cpu(pathlen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, new_file_ver);
-        logrecord = logit(logrecord, &ino, sizeof(ino));
-        logrecord = logit(logrecord, &generation, sizeof(generation));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = logit(logrecord, &remote_ino, sizeof(remote_ino));
-        logrecord = logit(logrecord, &remote_generation,
-                          sizeof(remote_generation));
-        logrecord = log_version(logrecord, remote_version);
-        logrecord = logit(logrecord, &rec->offset, sizeof(rec->offset));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0, NULL, 0);
-
-        BUFF_FREE(buffer);
-
-        EXIT;
-        return error;
-}
-
-/* 
- * Check if the given record is at the end of the file. If it is, truncate
- * the lml to the record's offset, removing it. Repeat on prior record,
- * until we reach an active record or a reserved record (as defined by the
- * reservations list).
- */
-static int presto_truncate_lml_tail(struct presto_file_set *fset)
-{
-        loff_t lml_tail;
-        loff_t lml_last_rec;
-        loff_t lml_last_recsize;
-        loff_t local_offset;
-        int recno;
-        struct kml_prefix_hdr prefix;
-        struct inode *inode = fset->fset_lml.fd_file->f_dentry->d_inode;
-        void *handle;
-        int rc;
-
-        ENTRY;
-        /* If someone else is already truncating the LML, return. */
-        write_lock(&fset->fset_lml.fd_lock); 
-        if (fset->fset_lml.fd_truncating == 1 ) {
-                write_unlock(&fset->fset_lml.fd_lock); 
-                EXIT;
-                return 0;
-        }
-        /* someone is about to write to the end of the LML */ 
-        if ( !list_empty(&fset->fset_lml.fd_reservations) ) {
-                write_unlock(&fset->fset_lml.fd_lock); 
-                EXIT;
-                return 0;
-        }
-       lml_tail = fset->fset_lml.fd_file->f_dentry->d_inode->i_size;
-       /* Nothing to truncate?*/
-       if (lml_tail == 0) {
-                write_unlock(&fset->fset_lml.fd_lock); 
-                EXIT;
-                return 0;
-       }
-       fset->fset_lml.fd_truncating = 1;
-       write_unlock(&fset->fset_lml.fd_lock); 
-
-       presto_last_record(&fset->fset_lml, &lml_last_recsize,
-                          &lml_last_rec, &recno, lml_tail);
-       /* Do we have a record to check? If not we have zeroes at the
-          beginning of the file. -SHP
-       */
-       if (lml_last_recsize != 0) {
-                local_offset = lml_last_rec - lml_last_recsize;
-                rc = presto_fread(fset->fset_lml.fd_file, (char *)&prefix,  
-                                        sizeof(prefix), &local_offset); 
-                if (rc != sizeof(prefix)) {
-                        EXIT;
-                        goto tr_out;
-                }
-       
-                if ( prefix.opcode != KML_OPCODE_NOOP ) {
-                        EXIT;
-                        rc = 0;
-                        /* We may have zeroes at the end of the file, should
-                           we clear them out? -SHP
-                        */
-                        goto tr_out;
-                }
-        } else 
-                lml_last_rec=0;
-
-        handle = presto_trans_start(fset, inode, KML_OPCODE_TRUNC);
-        if ( IS_ERR(handle) ) {
-                EXIT;
-                rc = -ENOMEM;
-                goto tr_out;
-        }
-
-        rc = izo_do_truncate(fset, fset->fset_lml.fd_file->f_dentry, 
-                                lml_last_rec - lml_last_recsize, lml_tail);
-        presto_trans_commit(fset, handle); 
-        if ( rc == 0 ) {
-                rc = 1;
-        }
-        EXIT;
-
- tr_out:
-        CDEBUG(D_JOURNAL, "rc = %d\n", rc);
-        write_lock(&fset->fset_lml.fd_lock);
-        fset->fset_lml.fd_truncating = 0;
-        write_unlock(&fset->fset_lml.fd_lock);
-        return rc;
-}
-
-int presto_truncate_lml(struct presto_file_set *fset)
-{
-        int rc; 
-        ENTRY;
-        
-        while ( (rc = presto_truncate_lml_tail(fset)) > 0);
-        if ( rc < 0 && rc != -EALREADY) {
-                CERROR("truncate_lml error %d\n", rc); 
-        }
-        EXIT;
-        return rc;
-}
-
-int presto_clear_lml_close(struct presto_file_set *fset, loff_t lml_offset)
-{
-        int rc;
-        struct kml_prefix_hdr record;
-        loff_t offset = lml_offset;
-
-        ENTRY;
-
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        CDEBUG(D_JOURNAL, "reading prefix: off %ld, size %Zd\n", 
-               (long)lml_offset, sizeof(record));
-        rc = presto_fread(fset->fset_lml.fd_file, (char *)&record,
-                          sizeof(record), &offset);
-
-        if ( rc != sizeof(record) ) {
-                CERROR("presto: clear_lml io error %d\n", rc); 
-                EXIT;
-                return -EIO;
-        }
-
-        /* overwrite the prefix */ 
-        CDEBUG(D_JOURNAL, "overwriting prefix: off %ld\n", (long)lml_offset);
-        record.opcode = KML_OPCODE_NOOP;
-        offset = lml_offset;
-        /* note: this does just a single transaction in the cache */
-        rc = presto_fwrite(fset->fset_lml.fd_file, (char *)(&record), 
-                              sizeof(record), &offset);
-        if ( rc != sizeof(record) ) {
-                EXIT;
-                return -EIO;
-        }
-
-        EXIT;
-        return 0; 
-}
-
-
-
-/* now a journal function for every operation */
-
-int presto_journal_setattr(struct rec_info *rec, struct presto_file_set *fset,
-                           struct dentry *dentry, struct presto_version *old_ver,
-                           struct izo_rollback_data *rb, struct iattr *iattr)
-{
-        int opcode = KML_OPCODE_SETATTR;
-        char *buffer, *path, *logrecord, record[316];
-        struct dentry *root;
-        __u32 uid, gid, mode, valid, flags, pathlen;
-        __u64 fsize, mtime, ctime;
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        if (!dentry->d_inode || (dentry->d_inode->i_nlink == 0) 
-            || ((dentry->d_parent != dentry) && d_unhashed(dentry))) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + sizeof(*old_ver) +
-                sizeof(valid) + sizeof(mode) + sizeof(uid) + sizeof(gid) +
-                sizeof(fsize) + sizeof(mtime) + sizeof(ctime) + sizeof(flags) +
-                sizeof(pathlen) + sizeof(*rb) + sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        /* Only journal one kind of mtime, and not atime at all.  Also don't
-         * journal bogus data in iattr, to make the journal more compressible.
-         */
-        if (iattr->ia_valid & ATTR_MTIME_SET)
-                iattr->ia_valid = iattr->ia_valid | ATTR_MTIME;
-        valid = cpu_to_le32(iattr->ia_valid & ~(ATTR_ATIME | ATTR_MTIME_SET |
-                                                ATTR_ATIME_SET));
-        mode = iattr->ia_valid & ATTR_MODE ? cpu_to_le32(iattr->ia_mode): 0;
-        uid = iattr->ia_valid & ATTR_UID ? cpu_to_le32(iattr->ia_uid): 0;
-        gid = iattr->ia_valid & ATTR_GID ? cpu_to_le32(iattr->ia_gid): 0;
-        fsize = iattr->ia_valid & ATTR_SIZE ? cpu_to_le64(iattr->ia_size): 0;
-        mtime = iattr->ia_valid & ATTR_MTIME ? cpu_to_le64(iattr->ia_mtime.tv_sec): 0;
-        ctime = iattr->ia_valid & ATTR_CTIME ? cpu_to_le64(iattr->ia_ctime.tv_sec): 0;
-        flags = iattr->ia_valid & ATTR_ATTR_FLAG ?
-                cpu_to_le32(iattr->ia_attr_flags): 0;
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, old_ver);
-        logrecord = logit(logrecord, &valid, sizeof(valid));
-        logrecord = logit(logrecord, &mode, sizeof(mode));
-        logrecord = logit(logrecord, &uid, sizeof(uid));
-        logrecord = logit(logrecord, &gid, sizeof(gid));
-        logrecord = logit(logrecord, &fsize, sizeof(fsize));
-        logrecord = logit(logrecord, &mtime, sizeof(mtime));
-        logrecord = logit(logrecord, &ctime, sizeof(ctime));
-        logrecord = logit(logrecord, &flags, sizeof(flags));
-        logrecord = log_rollback(logrecord, rb);
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0, NULL, 0);
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-int presto_get_fileid(int minor, struct presto_file_set *fset,
-                      struct dentry *dentry)
-{
-        int opcode = KML_OPCODE_GET_FILEID;
-        struct rec_info rec;
-        char *buffer, *path, *logrecord, record[4096]; /*include path*/
-        struct dentry *root;
-        __u32 uid, gid, pathlen;
-        int error, size;
-        struct kml_suffix *suffix;
-
-        ENTRY;
-
-        root = fset->fset_dentry;
-
-        uid = cpu_to_le32(dentry->d_inode->i_uid);
-        gid = cpu_to_le32(dentry->d_inode->i_gid);
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + sizeof(pathlen) +
-                size_round(le32_to_cpu(pathlen)) +
-                sizeof(struct kml_suffix);
-
-        CDEBUG(D_FILE, "kml size: %d\n", size);
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        memset(&rec, 0, sizeof(rec));
-        rec.is_kml = 1;
-        rec.size = size;
-
-        logrecord = journal_log_prefix(record, opcode, &rec);
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = logit(logrecord, path, size_round(le32_to_cpu(pathlen)));
-        suffix = (struct kml_suffix *)logrecord;
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, &rec);
-        /* journal_log_suffix expects journal_log to set this */
-        suffix->recno = 0;
-
-        CDEBUG(D_FILE, "actual kml size: %Zd\n", logrecord - record);
-        CDEBUG(D_FILE, "get fileid: uid %d, gid %d, path: %s\n", uid, gid,path);
-
-        error = izo_upc_get_fileid(minor, size, record, 
-                                   size_round(le32_to_cpu(pathlen)), path,
-                                   fset->fset_name);
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-int presto_journal_create(struct rec_info *rec, struct presto_file_set *fset,
-                          struct dentry *dentry,
-                          struct presto_version *tgt_dir_ver,
-                          struct presto_version *new_file_ver, int mode)
-{
-        int opcode = KML_OPCODE_CREATE;
-        char *buffer, *path, *logrecord, record[292];
-        struct dentry *root;
-        __u32 uid, gid, lmode, pathlen;
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        uid = cpu_to_le32(dentry->d_inode->i_uid);
-        gid = cpu_to_le32(dentry->d_inode->i_gid);
-        lmode = cpu_to_le32(mode);
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
-                sizeof(lmode) + sizeof(uid) + sizeof(gid) + sizeof(pathlen) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, dentry->d_parent);
-        logrecord = log_version(logrecord, new_file_ver);
-        logrecord = logit(logrecord, &lmode, sizeof(lmode));
-        logrecord = logit(logrecord, &uid, sizeof(uid));
-        logrecord = logit(logrecord, &gid, sizeof(gid));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0, NULL, 0);
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-int presto_journal_symlink(struct rec_info *rec, struct presto_file_set *fset,
-                           struct dentry *dentry, const char *target,
-                           struct presto_version *tgt_dir_ver,
-                           struct presto_version *new_link_ver)
-{
-        int opcode = KML_OPCODE_SYMLINK;
-        char *buffer, *path, *logrecord, record[292];
-        struct dentry *root;
-        __u32 uid, gid, pathlen;
-        __u32 targetlen = cpu_to_le32(strlen(target));
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        uid = cpu_to_le32(dentry->d_inode->i_uid);
-        gid = cpu_to_le32(dentry->d_inode->i_gid);
-
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
-                sizeof(uid) + sizeof(gid) + sizeof(pathlen) +
-                sizeof(targetlen) + sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen)) +
-                size_round(le32_to_cpu(targetlen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, dentry->d_parent);
-        logrecord = log_version(logrecord, new_link_ver);
-        logrecord = logit(logrecord, &uid, sizeof(uid));
-        logrecord = logit(logrecord, &gid, sizeof(gid));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = logit(logrecord, &targetlen, sizeof(targetlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           target, size_round(le32_to_cpu(targetlen)),
-                           NULL, 0);
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-int presto_journal_mkdir(struct rec_info *rec, struct presto_file_set *fset,
-                         struct dentry *dentry,
-                         struct presto_version *tgt_dir_ver,
-                         struct presto_version *new_dir_ver, int mode)
-{
-        int opcode = KML_OPCODE_MKDIR;
-        char *buffer, *path, *logrecord, record[292];
-        struct dentry *root;
-        __u32 uid, gid, lmode, pathlen;
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        uid = cpu_to_le32(dentry->d_inode->i_uid);
-        gid = cpu_to_le32(dentry->d_inode->i_gid);
-        lmode = cpu_to_le32(mode);
-
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size = sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
-                sizeof(lmode) + sizeof(uid) + sizeof(gid) + sizeof(pathlen) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen));
-        logrecord = journal_log_prefix(record, opcode, rec);
-
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, dentry->d_parent);
-        logrecord = log_version(logrecord, new_dir_ver);
-        logrecord = logit(logrecord, &lmode, sizeof(lmode));
-        logrecord = logit(logrecord, &uid, sizeof(uid));
-        logrecord = logit(logrecord, &gid, sizeof(gid));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0, NULL, 0);
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-
-int
-presto_journal_rmdir(struct rec_info *rec, struct presto_file_set *fset,
-                     struct dentry *dir, struct presto_version *tgt_dir_ver,
-                     struct presto_version *old_dir_ver,
-                     struct izo_rollback_data *rb, int len, const char *name)
-{
-        int opcode = KML_OPCODE_RMDIR;
-        char *buffer, *path, *logrecord, record[316];
-        __u32 pathlen, llen;
-        struct dentry *root;
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        llen = cpu_to_le32(len);
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dir, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
-                sizeof(pathlen) + sizeof(llen) + sizeof(*rb) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        CDEBUG(D_JOURNAL, "path: %s (%d), name: %s (%d), size %d\n",
-               path, pathlen, name, len, size);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen)) + 
-                size_round(len);
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, dir);
-        logrecord = log_version(logrecord, old_dir_ver);
-        logrecord = logit(logrecord, rb, sizeof(*rb));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = logit(logrecord, &llen, sizeof(llen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dir, rec);
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           name, size_round(len),
-                           NULL, 0);
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-
-int
-presto_journal_mknod(struct rec_info *rec, struct presto_file_set *fset,
-                     struct dentry *dentry, struct presto_version *tgt_dir_ver,
-                     struct presto_version *new_node_ver, int mode,
-                     int dmajor, int dminor )
-{
-        int opcode = KML_OPCODE_MKNOD;
-        char *buffer, *path, *logrecord, record[292];
-        struct dentry *root;
-        __u32 uid, gid, lmode, lmajor, lminor, pathlen;
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        uid = cpu_to_le32(dentry->d_inode->i_uid);
-        gid = cpu_to_le32(dentry->d_inode->i_gid);
-        lmode = cpu_to_le32(mode);
-        lmajor = cpu_to_le32(dmajor);
-        lminor = cpu_to_le32(dminor);
-
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size = sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
-                sizeof(lmode) + sizeof(uid) + sizeof(gid) + sizeof(lmajor) +
-                sizeof(lminor) + sizeof(pathlen) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, dentry->d_parent);
-        logrecord = log_version(logrecord, new_node_ver);
-        logrecord = logit(logrecord, &lmode, sizeof(lmode));
-        logrecord = logit(logrecord, &uid, sizeof(uid));
-        logrecord = logit(logrecord, &gid, sizeof(gid));
-        logrecord = logit(logrecord, &lmajor, sizeof(lmajor));
-        logrecord = logit(logrecord, &lminor, sizeof(lminor));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0, NULL, 0);
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-int
-presto_journal_link(struct rec_info *rec, struct presto_file_set *fset,
-                    struct dentry *src, struct dentry *tgt,
-                    struct presto_version *tgt_dir_ver,
-                    struct presto_version *new_link_ver)
-{
-        int opcode = KML_OPCODE_LINK;
-        char *buffer, *srcbuffer, *path, *srcpath, *logrecord, record[292];
-        __u32 pathlen, srcpathlen;
-        struct dentry *root;
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        BUFF_ALLOC(srcbuffer, NULL);
-        srcpath = presto_path(src, root, srcbuffer, PAGE_SIZE);
-        srcpathlen = cpu_to_le32(MYPATHLEN(srcbuffer, srcpath));
-
-        BUFF_ALLOC(buffer, srcbuffer);
-        path = presto_path(tgt, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
-                sizeof(srcpathlen) + sizeof(pathlen) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen)) + 
-                size_round(le32_to_cpu(srcpathlen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, tgt->d_parent);
-        logrecord = log_version(logrecord, new_link_ver);
-        logrecord = logit(logrecord, &srcpathlen, sizeof(srcpathlen));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, tgt, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           srcpath, size_round(le32_to_cpu(srcpathlen)),
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0);
-
-        BUFF_FREE(srcbuffer);
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-
-int presto_journal_rename(struct rec_info *rec, struct presto_file_set *fset,
-                          struct dentry *src, struct dentry *tgt,
-                          struct presto_version *src_dir_ver,
-                          struct presto_version *tgt_dir_ver)
-{
-        int opcode = KML_OPCODE_RENAME;
-        char *buffer, *srcbuffer, *path, *srcpath, *logrecord, record[292];
-        __u32 pathlen, srcpathlen;
-        struct dentry *root;
-        int error, size;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        BUFF_ALLOC(srcbuffer, NULL);
-        srcpath = presto_path(src, root, srcbuffer, PAGE_SIZE);
-        srcpathlen = cpu_to_le32(MYPATHLEN(srcbuffer, srcpath));
-
-        BUFF_ALLOC(buffer, srcbuffer);
-        path = presto_path(tgt, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 4 * sizeof(*src_dir_ver) +
-                sizeof(srcpathlen) + sizeof(pathlen) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen)) + 
-                size_round(le32_to_cpu(srcpathlen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, src_dir_ver);
-        logrecord = log_dentry_version(logrecord, src->d_parent);
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, tgt->d_parent);
-        logrecord = logit(logrecord, &srcpathlen, sizeof(srcpathlen));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, tgt, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           srcpath, size_round(le32_to_cpu(srcpathlen)),
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0);
-
-        BUFF_FREE(buffer);
-        BUFF_FREE(srcbuffer);
-        EXIT;
-        return error;
-}
-
-int presto_journal_unlink(struct rec_info *rec, struct presto_file_set *fset,
-                          struct dentry *dir, struct presto_version *tgt_dir_ver,
-                          struct presto_version *old_file_ver,
-                          struct izo_rollback_data *rb, struct dentry *dentry,
-                          char *old_target, int old_targetlen)
-{
-        int opcode = KML_OPCODE_UNLINK;
-        char *buffer, *path, *logrecord, record[316];
-        const char *name;
-        __u32 pathlen, llen;
-        struct dentry *root;
-        int error, size, len;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        name = dentry->d_name.name;
-        len = dentry->d_name.len;
-
-        llen = cpu_to_le32(len);
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dir, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        size = sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
-                sizeof(pathlen) + sizeof(llen) + sizeof(*rb) +
-                sizeof(old_targetlen) + sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen)) + size_round(len) +
-                size_round(old_targetlen);
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, tgt_dir_ver);
-        logrecord = log_dentry_version(logrecord, dir);
-        logrecord = log_version(logrecord, old_file_ver);
-        logrecord = log_rollback(logrecord, rb);
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = logit(logrecord, &llen, sizeof(llen));
-        logrecord = logit(logrecord, &old_targetlen, sizeof(old_targetlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dir, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           name, size_round(len),
-                           old_target, size_round(old_targetlen));
-
-        BUFF_FREE(buffer);
-        EXIT;
-        return error;
-}
-
-int
-presto_journal_close(struct rec_info *rec, struct presto_file_set *fset,
-                     struct presto_file_data *fd, struct dentry *dentry,
-                     struct presto_version *old_file_ver,
-                     struct presto_version *new_file_ver)
-{
-        int opcode = KML_OPCODE_CLOSE;
-        char *buffer, *path, *logrecord, record[316];
-        struct dentry *root;
-        int error, size, i;
-        __u32 pathlen, generation;
-        __u64 ino;
-        __u32 open_fsuid;
-        __u32 open_fsgid;
-        __u32 open_ngroups;
-        __u32 open_groups[NGROUPS_SMALL];
-        __u32 open_mode;
-        __u32 open_uid;
-        __u32 open_gid;
-
-        ENTRY;
-
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        if (!dentry->d_inode || (dentry->d_inode->i_nlink == 0) 
-            || ((dentry->d_parent != dentry) && d_unhashed(dentry))) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        if (fd) {
-                open_ngroups = fd->fd_ngroups;
-                for (i = 0; i < fd->fd_ngroups; i++)
-                        open_groups[i] = (__u32) fd->fd_groups[i];
-                open_mode = fd->fd_mode;
-                open_uid = fd->fd_uid;
-                open_gid = fd->fd_gid;
-                open_fsuid = fd->fd_fsuid;
-                open_fsgid = fd->fd_fsgid;
-        } else {
-                open_ngroups = current->group_info->ngroups;
-                for (i=0; i<current->group_info->ngroups; i++)
-                        open_groups[i] =  (__u32) GROUP_AT(current->group_info,i); 
-                open_mode = dentry->d_inode->i_mode;
-                open_uid = dentry->d_inode->i_uid;
-                open_gid = dentry->d_inode->i_gid;
-                open_fsuid = current->fsuid;
-                open_fsgid = current->fsgid;
-        }
-        BUFF_ALLOC(buffer, NULL);
-        path = presto_path(dentry, root, buffer, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
-        ino = cpu_to_le64(dentry->d_inode->i_ino);
-        generation = cpu_to_le32(dentry->d_inode->i_generation);
-        size =  sizeof(__u32) * open_ngroups +
-                sizeof(open_mode) + sizeof(open_uid) + sizeof(open_gid) +
-                sizeof(struct kml_prefix_hdr) + sizeof(*old_file_ver) +
-                sizeof(*new_file_ver) + sizeof(ino) + sizeof(generation) +
-                sizeof(pathlen) + sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen));
-
-        logrecord = journal_log_prefix_with_groups_and_ids(
-                record, opcode, rec, open_ngroups, open_groups,
-                open_fsuid, open_fsgid);
-        logrecord = logit(logrecord, &open_mode, sizeof(open_mode));
-        logrecord = logit(logrecord, &open_uid, sizeof(open_uid));
-        logrecord = logit(logrecord, &open_gid, sizeof(open_gid));
-        logrecord = log_version(logrecord, old_file_ver);
-        logrecord = log_version(logrecord, new_file_ver);
-        logrecord = logit(logrecord, &ino, sizeof(ino));
-        logrecord = logit(logrecord, &generation, sizeof(generation));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0, NULL, 0);
-        BUFF_FREE(buffer);
-
-        EXIT;
-        return error;
-}
-
-int presto_rewrite_close(struct rec_info *rec, struct presto_file_set *fset, 
-                         char *path, __u32 pathlen, 
-                         int ngroups, __u32 *groups, 
-                         __u64 ino,     __u32 generation, 
-                         struct presto_version *new_file_ver)
-{
-        int opcode = KML_OPCODE_CLOSE;
-        char *logrecord, record[292];
-        struct dentry *root;
-        int error, size;
-
-        ENTRY;
-
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        size =  sizeof(__u32) * ngroups + 
-                sizeof(struct kml_prefix_hdr) + sizeof(*new_file_ver) +
-                sizeof(ino) + sizeof(generation) + 
-                sizeof(le32_to_cpu(pathlen)) +
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        rec->size = size + size_round(le32_to_cpu(pathlen));
-
-        logrecord = journal_log_prefix_with_groups(record, opcode, rec,
-                                                   ngroups, groups);
-        logrecord = log_version(logrecord, new_file_ver);
-        logrecord = logit(logrecord, &ino, sizeof(ino));
-        logrecord = logit(logrecord, &generation, sizeof(generation));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = journal_log_suffix(logrecord, record, fset, NULL, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           NULL, 0, NULL, 0);
-
-        EXIT;
-        return error;
-}
-
-
-/* write closes for the local close records in the LML */ 
-int presto_complete_lml(struct presto_file_set *fset)
-{
-        __u32 groups[NGROUPS_SMALL];
-        loff_t lml_offset;
-        loff_t read_offset; 
-        char *buffer;
-        void *handle;
-        struct rec_info rec;
-        struct close_rec { 
-                struct presto_version new_file_ver;
-                __u64 ino;
-                __u32 generation;
-                __u32 pathlen;
-                __u64 remote_ino;
-                __u32 remote_generation;
-                __u32 remote_version;
-                __u64 lml_offset;
-        } close_rec; 
-        struct file *file = fset->fset_lml.fd_file;
-        struct kml_prefix_hdr prefix;
-        int rc = 0;
-        ENTRY;
-
-        lml_offset = 0; 
- again: 
-        if (lml_offset >= file->f_dentry->d_inode->i_size) {
-                EXIT;
-                return rc;
-        }
-
-        read_offset = lml_offset;
-        rc = presto_fread(file, (char *)&prefix,
-                          sizeof(prefix), &read_offset);
-        if ( rc != sizeof(prefix) ) {
-                EXIT;
-                CERROR("presto_complete_lml: ioerror - 1, tell Peter\n");
-                return -EIO;
-        }
-
-        if ( prefix.opcode == KML_OPCODE_NOOP ) {
-                lml_offset += prefix.len; 
-                goto again; 
-        }
-
-        rc = presto_fread(file, (char *)groups, 
-                          prefix.ngroups * sizeof(__u32), &read_offset); 
-        if ( rc != prefix.ngroups * sizeof(__u32) ) {
-                EXIT;
-                CERROR("presto_complete_lml: ioerror - 2, tell Peter\n");
-                return -EIO;
-        }
-
-        rc = presto_fread(file, (char *)&close_rec, 
-                          sizeof(close_rec), &read_offset); 
-        if ( rc != sizeof(close_rec) ) {
-                EXIT;
-                CERROR("presto_complete_lml: ioerror - 3, tell Peter\n");
-                return -EIO;
-        }
-
-        /* is this a backfetch or a close record? */ 
-        if ( le64_to_cpu(close_rec.remote_ino) != 0 ) { 
-                lml_offset += prefix.len;
-                goto again; 
-        }
-
-        BUFF_ALLOC(buffer, NULL);
-        rc = presto_fread(file, (char *)buffer, 
-                          le32_to_cpu(close_rec.pathlen), &read_offset); 
-        if ( rc != le32_to_cpu(close_rec.pathlen) ) {
-                EXIT;
-                CERROR("presto_complete_lml: ioerror - 4, tell Peter\n");
-                return -EIO;
-        }
-        
-        handle = presto_trans_start(fset, file->f_dentry->d_inode, 
-                                    KML_OPCODE_RELEASE);
-        if ( IS_ERR(handle) ) {
-                EXIT;
-                return -ENOMEM; 
-        }
-
-        rc = presto_clear_lml_close(fset, lml_offset); 
-        if ( rc ) {
-                CERROR("error during clearing: %d\n", rc);
-                presto_trans_commit(fset, handle);
-                EXIT; 
-                return rc; 
-        }
-
-        rc = presto_rewrite_close(&rec, fset, buffer, close_rec.pathlen, 
-                                  prefix.ngroups, groups, 
-                                  close_rec.ino, close_rec.generation,
-                                  &close_rec.new_file_ver); 
-        if ( rc ) {
-                CERROR("error during rewrite close: %d\n", rc);
-                presto_trans_commit(fset, handle);
-                EXIT; 
-                return rc; 
-        }
-
-        presto_trans_commit(fset, handle); 
-        if ( rc ) { 
-                CERROR("error during truncation: %d\n", rc);
-                EXIT; 
-                return rc;
-        }
-        
-        lml_offset += prefix.len; 
-        CDEBUG(D_JOURNAL, "next LML record at: %ld\n", (long)lml_offset);
-        goto again;
-
-        EXIT;
-        return -EINVAL;
-}
-
-
-#ifdef CONFIG_FS_EXT_ATTR
-/* Journal an ea operation. A NULL buffer implies the attribute is 
- * getting deleted. In this case we simply change the opcode, but nothing
- * else is affected.
- */
-int presto_journal_set_ext_attr (struct rec_info *rec, 
-                                 struct presto_file_set *fset, 
-                                 struct dentry *dentry, 
-                                 struct presto_version *ver, const char *name, 
-                                 const char *buffer, int buffer_len, 
-                                 int flags) 
-{ 
-        int opcode = (buffer == NULL) ? 
-                     KML_OPCODE_DELEXTATTR : 
-                     KML_OPCODE_SETEXTATTR ;
-        char *temp, *path, *logrecord, record[292];
-        struct dentry *root;
-        int error, size;
-        __u32 namelen=cpu_to_le32(strnlen(name,PRESTO_EXT_ATTR_NAME_MAX));
-        __u32 buflen=(buffer != NULL)? cpu_to_le32(buffer_len): cpu_to_le32(0);
-        __u32 mode, pathlen;
-
-        ENTRY;
-        if ( presto_no_journal(fset) ) {
-                EXIT;
-                return 0;
-        }
-
-        if (!dentry->d_inode || (dentry->d_inode->i_nlink == 0) 
-            || ((dentry->d_parent != dentry) && d_unhashed(dentry))) {
-                EXIT;
-                return 0;
-        }
-
-        root = fset->fset_dentry;
-
-        BUFF_ALLOC(temp, NULL);
-        path = presto_path(dentry, root, temp, PAGE_SIZE);
-        pathlen = cpu_to_le32(MYPATHLEN(temp, path));
-
-        flags=cpu_to_le32(flags);
-        /* Ugly, but needed. posix ACLs change the mode without using
-         * setattr, we need to record these changes. The EA code per se
-         * is not really affected.
-         */
-        mode=cpu_to_le32(dentry->d_inode->i_mode);
-
-        size =  sizeof(__u32) * current->group_info->ngroups + 
-                sizeof(struct kml_prefix_hdr) + 
-                2 * sizeof(struct presto_version) +
-                sizeof(flags) + sizeof(mode) + sizeof(namelen) + 
-                sizeof(buflen) + sizeof(pathlen) + 
-                sizeof(struct kml_suffix);
-
-        if ( size > sizeof(record) )
-                CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
-        rec->is_kml = 1;
-        /* Make space for a path, a attr name and value*/
-        /* We use the buflen instead of buffer_len to make sure that we 
-         * journal the right length. This may be a little paranoid, but
-         * with 64 bits round the corner, I would rather be safe than sorry!
-         * Also this handles deletes with non-zero buffer_lengths correctly.
-         * SHP
-         */
-        rec->size = size + size_round(le32_to_cpu(pathlen)) +
-                    size_round(le32_to_cpu(namelen)) + 
-                    size_round(le32_to_cpu(buflen));
-
-        logrecord = journal_log_prefix(record, opcode, rec);
-        logrecord = log_version(logrecord, ver);
-        logrecord = log_dentry_version(logrecord, dentry);
-        logrecord = logit(logrecord, &flags, sizeof(flags));
-        logrecord = logit(logrecord, &mode, sizeof(flags));
-        logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
-        logrecord = logit(logrecord, &namelen, sizeof(namelen));
-        logrecord = logit(logrecord, &buflen, sizeof(buflen));
-        logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
-        error = presto_log(fset, rec, record, size,
-                           path, size_round(le32_to_cpu(pathlen)),
-                           name, size_round(le32_to_cpu(namelen)),
-                           buffer, size_round(le32_to_cpu(buflen)));
-
-        BUFF_FREE(temp);
-        EXIT;
-        return error;
-}
-#endif
diff --git a/fs/intermezzo/journal_ext2.c b/fs/intermezzo/journal_ext2.c
deleted file mode 100644 (file)
index d1cb293..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#include <linux/ext2_fs.h> 
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_EXT2_FS)
-
-/* EXT2 has no journalling, so these functions do nothing */
-static loff_t presto_e2_freespace(struct presto_cache *cache,
-                                         struct super_block *sb)
-{
-        unsigned long freebl = le32_to_cpu(EXT2_SB(sb)->s_es->s_free_blocks_count);
-        unsigned long avail =   freebl - le32_to_cpu(EXT2_SB(sb)->s_es->s_r_blocks_count);
-       return (avail <<  EXT2_BLOCK_SIZE_BITS(sb));
-}
-
-/* start the filesystem journal operations */
-static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *inode, int op)
-{
-        __u32 avail_kmlblocks;
-
-        if ( presto_no_journal(fset) ||
-             strcmp(fset->fset_cache->cache_type, "ext2"))
-                return NULL;
-
-        avail_kmlblocks = EXT2_SB(inode->i_sb)->s_es->s_free_blocks_count;
-        
-        if ( avail_kmlblocks < 3 ) {
-                return ERR_PTR(-ENOSPC);
-        }
-        
-        if (  (op != KML_OPCODE_UNLINK && op != KML_OPCODE_RMDIR)
-              && avail_kmlblocks < 6 ) {
-                return ERR_PTR(-ENOSPC);
-        }            
-       return (void *) 1;
-}
-
-static void presto_e2_trans_commit(struct presto_file_set *fset, void *handle)
-{
-        do {} while (0);
-}
-
-static int presto_e2_has_all_data(struct inode *inode)
-{
-        BUG();
-        return 0;
-}
-
-struct journal_ops presto_ext2_journal_ops = {
-        .tr_all_data            = presto_e2_has_all_data,
-        .tr_avail               = presto_e2_freespace,
-        .tr_start               = presto_e2_trans_start,
-        .tr_commit              = presto_e2_trans_commit,
-        .tr_journal_data        = NULL
-};
-
-#endif /* CONFIG_EXT2_FS */
diff --git a/fs/intermezzo/journal_ext3.c b/fs/intermezzo/journal_ext3.c
deleted file mode 100644 (file)
index b847b61..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 Los Alamos National Laboratory
- *  Copyright (C) 2000 TurboLinux, Inc.
- *  Copyright (C) 2001 Mountain View Data, Inc.
- *  Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE)
-#include <linux/jbd.h>
-#include <linux/ext3_fs.h>
-#include <linux/ext3_jbd.h>
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE)
-
-#define MAX_PATH_BLOCKS(inode) (PATH_MAX >> EXT3_BLOCK_SIZE_BITS((inode)->i_sb))
-#define MAX_NAME_BLOCKS(inode) (NAME_MAX >> EXT3_BLOCK_SIZE_BITS((inode)->i_sb))
-
-/* space requirements: 
-   presto_do_truncate: 
-        used to truncate the KML forward to next fset->chunksize boundary
-          - zero partial block
-          - update inode
-   presto_write_record: 
-        write header (< one block) 
-        write one path (< MAX_PATHLEN) 
-        possibly write another path (< MAX_PATHLEN)
-        write suffix (< one block) 
-   presto_update_last_rcvd
-        write one block
-*/
-
-static loff_t presto_e3_freespace(struct presto_cache *cache,
-                                         struct super_block *sb)
-{
-        loff_t freebl = le32_to_cpu(EXT3_SB(sb)->s_es->s_free_blocks_count);
-        loff_t avail =   freebl - 
-                le32_to_cpu(EXT3_SB(sb)->s_es->s_r_blocks_count);
-        return (avail <<  EXT3_BLOCK_SIZE_BITS(sb));
-}
-
-/* start the filesystem journal operations */
-static void *presto_e3_trans_start(struct presto_file_set *fset, 
-                                   struct inode *inode, 
-                                   int op)
-{
-        int jblocks;
-        int trunc_blks, one_path_blks, extra_path_blks, 
-                extra_name_blks, lml_blks; 
-        __u32 avail_kmlblocks;
-        handle_t *handle;
-
-        if ( presto_no_journal(fset) ||
-             strcmp(fset->fset_cache->cache_type, "ext3"))
-          {
-            CDEBUG(D_JOURNAL, "got cache_type \"%s\"\n",
-                   fset->fset_cache->cache_type);
-            return NULL;
-          }
-
-        avail_kmlblocks = EXT3_SB(inode->i_sb)->s_es->s_free_blocks_count;
-        
-        if ( avail_kmlblocks < 3 ) {
-                return ERR_PTR(-ENOSPC);
-        }
-        
-        if (  (op != KML_OPCODE_UNLINK && op != KML_OPCODE_RMDIR)
-              && avail_kmlblocks < 6 ) {
-                return ERR_PTR(-ENOSPC);
-        }            
-
-        /* Need journal space for:
-             at least three writes to KML (two one block writes, one a path) 
-             possibly a second name (unlink, rmdir)
-             possibly a second path (symlink, rename)
-             a one block write to the last rcvd file 
-        */
-
-        trunc_blks = EXT3_DATA_TRANS_BLOCKS + 1; 
-        one_path_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 3;
-        lml_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 2;
-        extra_path_blks = EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode); 
-        extra_name_blks = EXT3_DATA_TRANS_BLOCKS + MAX_NAME_BLOCKS(inode); 
-
-        /* additional blocks appear for "two pathname" operations
-           and operations involving the LML records 
-        */
-        switch (op) {
-        case KML_OPCODE_TRUNC:
-                jblocks = one_path_blks + extra_name_blks + trunc_blks
-                        + EXT3_DELETE_TRANS_BLOCKS; 
-                break;
-        case KML_OPCODE_KML_TRUNC:
-                /* Hopefully this is a little better, but I'm still mostly
-                 * guessing here. */
-                /* unlink 1 */
-                jblocks = extra_name_blks + trunc_blks +
-                        EXT3_DELETE_TRANS_BLOCKS + 2; 
-
-                /* unlink 2 */
-                jblocks += extra_name_blks + trunc_blks +
-                        EXT3_DELETE_TRANS_BLOCKS + 2; 
-
-                /* rename 1 */
-                jblocks += 2 * extra_path_blks + trunc_blks + 
-                        2 * EXT3_DATA_TRANS_BLOCKS + 2 + 3;
-
-                /* rename 2 */
-                jblocks += 2 * extra_path_blks + trunc_blks + 
-                        2 * EXT3_DATA_TRANS_BLOCKS + 2 + 3;
-                break;
-        case KML_OPCODE_RELEASE:
-                /* 
-                jblocks = one_path_blks + lml_blks + 2*trunc_blks; 
-                */
-                jblocks = one_path_blks; 
-                break;
-        case KML_OPCODE_SETATTR:
-                jblocks = one_path_blks + trunc_blks + 1 ; 
-                break;
-        case KML_OPCODE_CREATE:
-                jblocks = one_path_blks + trunc_blks 
-                        + EXT3_DATA_TRANS_BLOCKS + 3 + 2; 
-                break;
-        case KML_OPCODE_LINK:
-                jblocks = one_path_blks + trunc_blks 
-                        + EXT3_DATA_TRANS_BLOCKS + 2; 
-                break;
-        case KML_OPCODE_UNLINK:
-                jblocks = one_path_blks + extra_name_blks + trunc_blks
-                        + EXT3_DELETE_TRANS_BLOCKS + 2; 
-                break;
-        case KML_OPCODE_SYMLINK:
-                jblocks = one_path_blks + extra_path_blks + trunc_blks
-                        + EXT3_DATA_TRANS_BLOCKS + 5; 
-                break;
-        case KML_OPCODE_MKDIR:
-                jblocks = one_path_blks + trunc_blks
-                        + EXT3_DATA_TRANS_BLOCKS + 4 + 2;
-                break;
-        case KML_OPCODE_RMDIR:
-                jblocks = one_path_blks + extra_name_blks + trunc_blks
-                        + EXT3_DELETE_TRANS_BLOCKS + 1; 
-                break;
-        case KML_OPCODE_MKNOD:
-                jblocks = one_path_blks + trunc_blks + 
-                        EXT3_DATA_TRANS_BLOCKS + 3 + 2;
-                break;
-        case KML_OPCODE_RENAME:
-                jblocks = one_path_blks + extra_path_blks + trunc_blks + 
-                        2 * EXT3_DATA_TRANS_BLOCKS + 2 + 3;
-                break;
-        case KML_OPCODE_WRITE:
-                jblocks = one_path_blks; 
-                /*  add this when we can wrap our transaction with 
-                    that of ext3_file_write (ordered writes)
-                    +  EXT3_DATA_TRANS_BLOCKS;
-                */
-                break;
-        default:
-                CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
-                return NULL;
-        }
-
-        CDEBUG(D_JOURNAL, "creating journal handle (%d blocks) for op %d\n",
-               jblocks, op);
-        /* journal_start/stop does not do its own locking while updating
-         * the handle/transaction information. Hence we create our own
-         * critical section to protect these calls. -SHP
-         */
-        lock_kernel();
-        handle = journal_start(EXT3_JOURNAL(inode), jblocks);
-        unlock_kernel();
-        return handle;
-}
-
-static void presto_e3_trans_commit(struct presto_file_set *fset, void *handle)
-{
-        if ( presto_no_journal(fset) || !handle)
-                return;
-
-        /* See comments before journal_start above. -SHP */
-        lock_kernel();
-        journal_stop(handle);
-        unlock_kernel();
-}
-
-static void presto_e3_journal_file_data(struct inode *inode)
-{
-#ifdef EXT3_JOURNAL_DATA_FL
-        EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL;
-#else
-#warning You must have a facility to enable journaled writes for recovery!
-#endif
-}
-
-/* The logic here is a slightly modified version of ext3/inode.c:block_to_path
- */
-static int presto_e3_has_all_data(struct inode *inode)
-{
-        int ptrs = EXT3_ADDR_PER_BLOCK(inode->i_sb);
-        int ptrs_bits = EXT3_ADDR_PER_BLOCK_BITS(inode->i_sb);
-        const long direct_blocks = EXT3_NDIR_BLOCKS,
-                indirect_blocks = ptrs,
-                double_blocks = (1 << (ptrs_bits * 2));
-        long block = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
-                inode->i_sb->s_blocksize_bits;
-
-        ENTRY;
-
-        if (inode->i_size == 0) {
-                EXIT;
-                return 1;
-        }
-
-        if (block < direct_blocks) {
-                /* No indirect blocks, no problem. */
-        } else if (block < indirect_blocks + direct_blocks) {
-                block++;
-        } else if (block < double_blocks + indirect_blocks + direct_blocks) {
-                block += 2;
-        } else if (((block - double_blocks - indirect_blocks - direct_blocks)
-                    >> (ptrs_bits * 2)) < ptrs) {
-                block += 3;
-        }
-
-        block *= (inode->i_sb->s_blocksize / 512);
-
-        CDEBUG(D_CACHE, "Need %ld blocks, have %ld.\n", block, inode->i_blocks);
-
-        if (block > inode->i_blocks) {
-                EXIT;
-                return 0;
-        }
-
-        EXIT;
-        return 1;
-}
-
-struct journal_ops presto_ext3_journal_ops = {
-        .tr_all_data     = presto_e3_has_all_data,
-        .tr_avail        = presto_e3_freespace,
-        .tr_start        =  presto_e3_trans_start,
-        .tr_commit       = presto_e3_trans_commit,
-        .tr_journal_data = presto_e3_journal_file_data,
-        .tr_ilookup      = presto_iget_ilookup
-};
-
-#endif /* CONFIG_EXT3_FS */
diff --git a/fs/intermezzo/journal_obdfs.c b/fs/intermezzo/journal_obdfs.c
deleted file mode 100644 (file)
index 702ee8b..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 Los Alamos National Laboratory
- *  Copyright (C) 2000 TurboLinux, Inc.
- *  Copyright (C) 2001 Mountain View Data, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#ifdef CONFIG_OBDFS_FS
-#include /usr/src/obd/include/linux/obdfs.h
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef CONFIG_OBDFS_FS
-
-
-static unsigned long presto_obdfs_freespace(struct presto_file_set *fset,
-                                         struct super_block *sb)
-{
-        return 0x0fffff; 
-}
-
-/* start the filesystem journal operations */
-static void *presto_obdfs_trans_start(struct presto_file_set *fset, 
-                                   struct inode *inode, 
-                                   int op)
-{
-
-        return (void *) 1;
-}
-
-#if 0
-        int jblocks;
-        int trunc_blks, one_path_blks, extra_path_blks, 
-                extra_name_blks, lml_blks; 
-        __u32 avail_kmlblocks;
-
-        if ( presto_no_journal(fset) ||
-             strcmp(fset->fset_cache->cache_type, "ext3"))
-          {
-            CDEBUG(D_JOURNAL, "got cache_type \"%s\"\n",
-                   fset->fset_cache->cache_type);
-            return NULL;
-          }
-
-        avail_kmlblocks = inode->i_sb->u.ext3_sb.s_es->s_free_blocks_count;
-        
-        if ( avail_kmlblocks < 3 ) {
-                return ERR_PTR(-ENOSPC);
-        }
-        
-        if (  (op != PRESTO_OP_UNLINK && op != PRESTO_OP_RMDIR)
-              && avail_kmlblocks < 6 ) {
-                return ERR_PTR(-ENOSPC);
-        }            
-
-        /* Need journal space for:
-             at least three writes to KML (two one block writes, one a path) 
-             possibly a second name (unlink, rmdir)
-             possibly a second path (symlink, rename)
-             a one block write to the last rcvd file 
-        */
-
-        trunc_blks = EXT3_DATA_TRANS_BLOCKS + 1; 
-        one_path_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 3;
-        lml_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 2;
-        extra_path_blks = EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode); 
-        extra_name_blks = EXT3_DATA_TRANS_BLOCKS + MAX_NAME_BLOCKS(inode); 
-
-        /* additional blocks appear for "two pathname" operations
-           and operations involving the LML records 
-        */
-        switch (op) {
-        case PRESTO_OP_TRUNC:
-                jblocks = one_path_blks + extra_name_blks + trunc_blks
-                        + EXT3_DELETE_TRANS_BLOCKS; 
-                break;
-        case PRESTO_OP_RELEASE:
-                /* 
-                jblocks = one_path_blks + lml_blks + 2*trunc_blks; 
-                */
-                jblocks = one_path_blks; 
-                break;
-        case PRESTO_OP_SETATTR:
-                jblocks = one_path_blks + trunc_blks + 1 ; 
-                break;
-        case PRESTO_OP_CREATE:
-                jblocks = one_path_blks + trunc_blks 
-                        + EXT3_DATA_TRANS_BLOCKS + 3; 
-                break;
-        case PRESTO_OP_LINK:
-                jblocks = one_path_blks + trunc_blks 
-                        + EXT3_DATA_TRANS_BLOCKS; 
-                break;
-        case PRESTO_OP_UNLINK:
-                jblocks = one_path_blks + extra_name_blks + trunc_blks
-                        + EXT3_DELETE_TRANS_BLOCKS; 
-                break;
-        case PRESTO_OP_SYMLINK:
-                jblocks = one_path_blks + extra_path_blks + trunc_blks
-                        + EXT3_DATA_TRANS_BLOCKS + 5; 
-                break;
-        case PRESTO_OP_MKDIR:
-                jblocks = one_path_blks + trunc_blks
-                        + EXT3_DATA_TRANS_BLOCKS + 4;
-                break;
-        case PRESTO_OP_RMDIR:
-                jblocks = one_path_blks + extra_name_blks + trunc_blks
-                        + EXT3_DELETE_TRANS_BLOCKS; 
-                break;
-        case PRESTO_OP_MKNOD:
-                jblocks = one_path_blks + trunc_blks + 
-                        EXT3_DATA_TRANS_BLOCKS + 3;
-                break;
-        case PRESTO_OP_RENAME:
-                jblocks = one_path_blks + extra_path_blks + trunc_blks + 
-                        2 * EXT3_DATA_TRANS_BLOCKS + 2;
-                break;
-        case PRESTO_OP_WRITE:
-                jblocks = one_path_blks; 
-                /*  add this when we can wrap our transaction with 
-                    that of ext3_file_write (ordered writes)
-                    +  EXT3_DATA_TRANS_BLOCKS;
-                */
-                break;
-        default:
-                CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
-                return NULL;
-        }
-
-        CDEBUG(D_JOURNAL, "creating journal handle (%d blocks)\n", jblocks);
-        return journal_start(EXT3_JOURNAL(inode), jblocks);
-}
-#endif
-
-void presto_obdfs_trans_commit(struct presto_file_set *fset, void *handle)
-{
-#if 0
-        if ( presto_no_journal(fset) || !handle)
-                return;
-
-        journal_stop(handle);
-#endif
-}
-
-void presto_obdfs_journal_file_data(struct inode *inode)
-{
-#ifdef EXT3_JOURNAL_DATA_FL
-        inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL;
-#else
-#warning You must have a facility to enable journaled writes for recovery!
-#endif
-}
-
-struct journal_ops presto_obdfs_journal_ops = {
-        .tr_avail        = presto_obdfs_freespace,
-        .tr_start        =  presto_obdfs_trans_start,
-        .tr_commit       = presto_obdfs_trans_commit,
-        .tr_journal_data = presto_obdfs_journal_file_data
-};
-
-#endif
diff --git a/fs/intermezzo/journal_reiserfs.c b/fs/intermezzo/journal_reiserfs.c
deleted file mode 100644 (file)
index 93fc148..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 Los Alamos National Laboratory
- *  Copyright (C) 2000 TurboLinux, Inc.
- *  Copyright (C) 2001 Mountain View Data, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if 0
-#if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE)
-#include <linux/reiserfs_fs.h>
-#include <linux/reiserfs_fs_sb.h>
-#include <linux/reiserfs_fs_i.h>
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE)
-
-
-static loff_t presto_reiserfs_freespace(struct presto_cache *cache,
-                                         struct super_block *sb)
-{
-        struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (sb);
-       loff_t avail;
-
-        avail =   le32_to_cpu(rs->s_free_blocks) * 
-               le16_to_cpu(rs->s_blocksize);
-        return avail; 
-}
-
-/* start the filesystem journal operations */
-static void *presto_reiserfs_trans_start(struct presto_file_set *fset, 
-                                   struct inode *inode, 
-                                   int op)
-{
-       int jblocks;
-        __u32 avail_kmlblocks;
-       struct reiserfs_transaction_handle *th ;
-
-       PRESTO_ALLOC(th, sizeof(*th));
-       if (!th) { 
-               CERROR("presto: No memory for trans handle\n");
-               return NULL;
-       }
-
-        avail_kmlblocks = presto_reiserfs_freespace(fset->fset_cache, 
-                                                   inode->i_sb);
-        if ( presto_no_journal(fset) ||
-             strcmp(fset->fset_cache->cache_type, "reiserfs"))
-               {
-                       CDEBUG(D_JOURNAL, "got cache_type \"%s\"\n",
-                              fset->fset_cache->cache_type);
-                       return NULL;
-               }
-
-        if ( avail_kmlblocks < 3 ) {
-                return ERR_PTR(-ENOSPC);
-        }
-        
-        if (  (op != PRESTO_OP_UNLINK && op != PRESTO_OP_RMDIR)
-              && avail_kmlblocks < 6 ) {
-                return ERR_PTR(-ENOSPC);
-        }            
-
-       jblocks = 3 + JOURNAL_PER_BALANCE_CNT * 4;
-        CDEBUG(D_JOURNAL, "creating journal handle (%d blocks)\n", jblocks);
-
-       lock_kernel();
-       journal_begin(th, inode->i_sb, jblocks);
-       unlock_kernel();
-       return th; 
-}
-
-static void presto_reiserfs_trans_commit(struct presto_file_set *fset,
-                                         void *handle)
-{
-       int jblocks;
-       jblocks = 3 + JOURNAL_PER_BALANCE_CNT * 4;
-       
-       lock_kernel();
-       journal_end(handle, fset->fset_cache->cache_sb, jblocks);
-       unlock_kernel();
-       PRESTO_FREE(handle, sizeof(struct reiserfs_transaction_handle));
-}
-
-static void presto_reiserfs_journal_file_data(struct inode *inode)
-{
-#ifdef EXT3_JOURNAL_DATA_FL
-        inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL;
-#else
-#warning You must have a facility to enable journaled writes for recovery!
-#endif
-}
-
-static int presto_reiserfs_has_all_data(struct inode *inode)
-{
-        BUG();
-        return 0;
-}
-
-struct journal_ops presto_reiserfs_journal_ops = {
-        .tr_all_data     = presto_reiserfs_has_all_data,
-        .tr_avail        = presto_reiserfs_freespace,
-        .tr_start        = presto_reiserfs_trans_start,
-        .tr_commit       = presto_reiserfs_trans_commit,
-        .tr_journal_data = presto_reiserfs_journal_file_data
-};
-
-#endif
-#endif
diff --git a/fs/intermezzo/journal_tmpfs.c b/fs/intermezzo/journal_tmpfs.c
deleted file mode 100644 (file)
index 4f3c463..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 Los Alamos National Laboratory
- *  Copyright (C) 2000 TurboLinux, Inc.
- *  Copyright (C) 2001 Mountain View Data, Inc.
- *  Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if defined(CONFIG_TMPFS)
-#include <linux/jbd.h>
-#if defined(CONFIG_EXT3)
-#include <linux/ext3_fs.h>
-#include <linux/ext3_jbd.h>
-#endif
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_TMPFS)
-
-/* space requirements: 
-   presto_do_truncate: 
-        used to truncate the KML forward to next fset->chunksize boundary
-          - zero partial block
-          - update inode
-   presto_write_record: 
-        write header (< one block) 
-        write one path (< MAX_PATHLEN) 
-        possibly write another path (< MAX_PATHLEN)
-        write suffix (< one block) 
-   presto_update_last_rcvd
-        write one block
-*/
-
-static loff_t presto_tmpfs_freespace(struct presto_cache *cache,
-                                         struct super_block *sb)
-{
-        return (1<<30);
-}
-
-/* start the filesystem journal operations */
-static void *presto_tmpfs_trans_start(struct presto_file_set *fset, 
-                                   struct inode *inode, 
-                                   int op)
-{
-        return (void *)1; 
-}
-
-static void presto_tmpfs_trans_commit(struct presto_file_set *fset, void *handle)
-{
-        return;
-}
-
-static void presto_tmpfs_journal_file_data(struct inode *inode)
-{
-        return; 
-}
-
-/* The logic here is a slightly modified version of ext3/inode.c:block_to_path
- */
-static int presto_tmpfs_has_all_data(struct inode *inode)
-{
-        return 0;
-}
-
-struct journal_ops presto_tmpfs_journal_ops = {
-        .tr_all_data            = presto_tmpfs_has_all_data,
-        .tr_avail               = presto_tmpfs_freespace,
-        .tr_start               = presto_tmpfs_trans_start,
-        .tr_commit              = presto_tmpfs_trans_commit,
-        .tr_journal_data        = presto_tmpfs_journal_file_data,
-        .tr_ilookup             = presto_tmpfs_ilookup,
-        .tr_add_ilookup         = presto_add_ilookup_dentry
-};
-
-#endif /* CONFIG_EXT3_FS */
diff --git a/fs/intermezzo/journal_xfs.c b/fs/intermezzo/journal_xfs.c
deleted file mode 100644 (file)
index 59b22a5..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if 0
-/* XFS Support not there yet */
-#ifdef CONFIG_FS_XFS
-#include <linux/xfs_fs.h>
-#endif
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-#include "intermezzo_journal.h"
-
-#if 0
-
-/* XFS has journalling, but these functions do nothing yet... */
-
-static unsigned long presto_xfs_freespace(struct presto_file_set *fset,
-                                         struct super_block *sb)
-{
-
-#if 0
-        vfs_t *vfsp = LINVFS_GET_VFS(sb);
-        struct statvfs_t stat; 
-        bhv_desc_t *bdp;
-        unsigned long avail; 
-        int rc;
-
-        VFS_STATVFS(vfsp, &stat, NULL, rc);
-        avail = statp.f_bfree;
-
-        return sbp->sb_fdblocks;
-#endif
-        return 0x0fffffff;
-}
-
-
-/* start the filesystem journal operations */
-static void *
-presto_xfs_trans_start(struct presto_file_set *fset,
-                      struct inode *inode, int op)
-{
-       int xfs_op;
-       /* do a free blocks check as in journal_ext3? does anything protect
-        * the space in that case or can it disappear out from under us
-        * anyway? */
-       
-/* copied from xfs_trans.h, skipping header maze for now */
-#define XFS_TRANS_SETATTR_NOT_SIZE      1
-#define XFS_TRANS_SETATTR_SIZE          2
-#define XFS_TRANS_INACTIVE              3
-#define XFS_TRANS_CREATE                4
-#define XFS_TRANS_CREATE_TRUNC          5
-#define XFS_TRANS_TRUNCATE_FILE         6
-#define XFS_TRANS_REMOVE                7
-#define XFS_TRANS_LINK                  8
-#define XFS_TRANS_RENAME                9
-#define XFS_TRANS_MKDIR                 10
-#define XFS_TRANS_RMDIR                 11
-#define XFS_TRANS_SYMLINK               12
-
-       /* map the op onto the values for XFS so it can do reservation. if
-        * we don't have enough info to differentiate between e.g. setattr
-        * with or without size, what do we do? will it adjust? */
-       switch (op) {
-       case PRESTO_OP_SETATTR:
-               /* or XFS_TRANS_SETATTR_NOT_SIZE? */
-               xfs_op = XFS_TRANS_SETATTR_SIZE;
-               break;
-       case PRESTO_OP_CREATE:
-               /* or CREATE_TRUNC? */
-               xfs_op = XFS_TRANS_CREATE;
-               break;
-       case PRESTO_OP_LINK:
-               xfs_op = XFS_TRANS_LINK;
-               break;
-       case PRESTO_OP_UNLINK:
-               xfs_op = XFS_TRANS_REMOVE;
-               break;
-       case PRESTO_OP_SYMLINK:
-               xfs_op = XFS_TRANS_SYMLINK;
-               break;
-       case PRESTO_OP_MKDIR:
-               xfs_op = XFS_TRANS_MKDIR;
-               break;
-       case PRESTO_OP_RMDIR:
-               xfs_op = XFS_TRANS_RMDIR;
-               break;
-       case PRESTO_OP_MKNOD:
-               /* XXX can't find an analog for mknod? */
-               xfs_op = XFS_TRANS_CREATE;
-               break;
-       case PRESTO_OP_RENAME:
-               xfs_op = XFS_TRANS_RENAME;
-               break;
-       default:
-               CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
-               return NULL;
-       }
-
-       return xfs_trans_start(inode, xfs_op);
-}
-
-static void presto_xfs_trans_commit(struct presto_file_set *fset, void *handle)
-{
-       /* assert (handle == current->j_handle) */
-       xfs_trans_stop(handle);
-}
-
-static void presto_xfs_journal_file_data(struct inode *inode)
-{
-        return; 
-}
-
-static int presto_xfs_has_all_data(struct inode *inode)
-{
-        BUG();
-        return 0;
-}
-
-struct journal_ops presto_xfs_journal_ops = {
-        .tr_all_data     = presto_xfs_has_all_data,
-        .tr_avail        = presto_xfs_freespace,
-        .tr_start        = presto_xfs_trans_start,
-        .tr_commit       = presto_xfs_trans_commit,
-        .tr_journal_data = presto_xfs_journal_file_data
-};
-
-#endif
-
-
-#endif /* CONFIG_XFS_FS */
-
diff --git a/fs/intermezzo/kml.c b/fs/intermezzo/kml.c
deleted file mode 100644 (file)
index e992c18..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_upcall.h"
-#include "intermezzo_psdev.h"
-#include "intermezzo_kml.h"
-
-static struct presto_file_set * kml_getfset (char *path)
-{
-        return presto_path2fileset(path);
-}
-
-/* Send the KML buffer and related volume info into kernel */
-int begin_kml_reint (struct file *file, unsigned long arg)
-{
-        struct {
-                char *volname;
-                int   namelen;  
-                char *recbuf;
-                int   reclen;     /* int   newpos; */
-        } input;
-        struct kml_fsdata *kml_fsdata = NULL;
-        struct presto_file_set *fset = NULL;
-        char   *path;
-        int    error;
-
-        ENTRY;
-        /* allocate buffer & copy it to kernel space */
-        if (copy_from_user(&input, (char *)arg, sizeof(input))) {
-                EXIT;
-                return -EFAULT;
-        }
-
-        if (input.reclen > kml_fsdata->kml_maxsize)
-                return -ENOMEM; /* we'll find solution to this in the future */
-
-        PRESTO_ALLOC(path, char *, input.namelen + 1);
-        if ( !path ) {
-                EXIT;
-                return -ENOMEM;
-        }
-        if (copy_from_user(path, input.volname, input.namelen)) {
-                PRESTO_FREE(path, input.namelen + 1);
-                EXIT;
-                return -EFAULT;
-        }
-        path[input.namelen] = '\0';
-        fset = kml_getfset (path);
-        PRESTO_FREE(path, input.namelen + 1);
-
-        kml_fsdata = FSET_GET_KMLDATA(fset);
-        /* read the buf from user memory here */
-        if (copy_from_user(kml_fsdata->kml_buf, input.recbuf, input.reclen)) {
-                EXIT;
-                return -EFAULT;
-        }
-        kml_fsdata->kml_len = input.reclen;
-
-        decode_kmlrec (&kml_fsdata->kml_reint_cache,
-                        kml_fsdata->kml_buf, kml_fsdata->kml_len);
-
-        kml_fsdata->kml_reint_current = kml_fsdata->kml_reint_cache.next;
-        kml_fsdata->kml_reintpos = 0;
-        kml_fsdata->kml_count = 0;
-        return 0;
-}
-
-/* DO_KML_REINT  */
-int do_kml_reint (struct file *file, unsigned long arg)
-{
-        struct {
-                char *volname;
-                int   namelen;  
-                char *path;
-                int pathlen;
-                int recno;
-                int offset;
-                int len;
-                int generation;
-                __u64 ino;
-        } input;
-        int error;
-        char   *path;
-        struct kml_rec *close_rec;
-        struct kml_fsdata *kml_fsdata;
-        struct presto_file_set *fset;
-
-        ENTRY;
-        if (copy_from_user(&input, (char *)arg, sizeof(input))) {
-                EXIT;
-                return -EFAULT;
-        }
-        PRESTO_ALLOC(path, char *, input.namelen + 1);
-        if ( !path ) {
-                EXIT;
-                return -ENOMEM;
-        }
-        if (copy_from_user(path, input.volname, input.namelen)) {
-                PRESTO_FREE(path, input.namelen + 1);
-                EXIT;
-                return -EFAULT;
-        }
-        path[input.namelen] = '\0';
-        fset = kml_getfset (path);
-        PRESTO_FREE(path, input.namelen + 1);
-
-        kml_fsdata = FSET_GET_KMLDATA(fset);
-
-        error = kml_reintbuf(kml_fsdata, 
-                fset->fset_mtpt->d_name.name, 
-                &close_rec);
-
-        if (error == KML_CLOSE_BACKFETCH && close_rec != NULL) {
-                struct kml_close *close = &close_rec->rec_kml.close;
-                input.ino = close->ino;
-                input.generation = close->generation;
-                if (strlen (close->path) + 1 < input.pathlen) {
-                        strcpy (input.path, close->path);
-                        input.pathlen = strlen (close->path) + 1;
-                        input.recno = close_rec->rec_tail.recno;
-                        input.offset = close_rec->rec_kml_offset;
-                        input.len = close_rec->rec_size;
-                        input.generation = close->generation;
-                        input.ino = close->ino;
-                }
-                else {
-                        CDEBUG(D_KML, "KML_DO_REINT::no space to save:%d < %d",
-                                strlen (close->path) + 1, input.pathlen);
-                        error = -ENOMEM;
-                }
-                if (copy_to_user((char *)arg, &input, sizeof (input)))
-                       return -EFAULT;
-        }
-        return error;
-}
-
-/* END_KML_REINT */
-int end_kml_reint (struct file *file, unsigned long arg)
-{
-        /* Free KML buffer and related volume info */
-        struct {
-                char *volname;
-                int   namelen;  
-#if 0
-                int   count; 
-                int   newpos; 
-#endif
-        } input;
-        struct presto_file_set *fset = NULL;
-        struct kml_fsdata *kml_fsdata = NULL;
-        int error;
-        char *path;
-
-        ENTRY;
-        if (copy_from_user(&input, (char *)arg, sizeof(input))) { 
-               EXIT;
-               return -EFAULT;
-        }
-
-        PRESTO_ALLOC(path, char *, input.namelen + 1);
-        if ( !path ) {
-                EXIT;
-                return -ENOMEM;
-        }
-        if (copy_from_user(path, input.volname, input.namelen)) {
-        if ( error ) {
-                PRESTO_FREE(path, input.namelen + 1);
-                EXIT;
-                return -EFAULT;
-        }
-        path[input.namelen] = '\0';
-        fset = kml_getfset (path);
-        PRESTO_FREE(path, input.namelen + 1);
-
-        kml_fsdata = FSET_GET_KMLDATA(fset);
-        delete_kmlrec (&kml_fsdata->kml_reint_cache);
-
-        /* kml reint support */
-        kml_fsdata->kml_reint_current = NULL;
-        kml_fsdata->kml_len = 0;
-        kml_fsdata->kml_reintpos = 0;
-        kml_fsdata->kml_count = 0;
-#if 0
-        input.newpos = kml_upc->newpos;
-        input.count = kml_upc->count;
-        if (copy_to_user((char *)arg, &input, sizeof (input)))
-               return -EFAULT;
-#endif
-        return error;
-}
diff --git a/fs/intermezzo/kml_decode.c b/fs/intermezzo/kml_decode.c
deleted file mode 100644 (file)
index f04e7d5..0000000
+++ /dev/null
@@ -1,1016 +0,0 @@
-/*
- * KML Decoding
- *
- * Copryright (C) 1996 Arthur Ma <arthur.ma@mountainviewdata.com> 
- *
- * Copyright (C) 2001 Mountainview Data, Inc.
- */
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include "intermezzo_fs.h"
-#include "intermezzo_kml.h"
-
-static int size_round (int val);
-static int unpack_create (struct kml_create *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_open (struct kml_open *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_symlink (struct kml_symlink *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_mknod (struct kml_mknod *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_link (struct kml_link *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_rename (struct kml_rename *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_unlink (struct kml_unlink *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_rmdir (struct kml_rmdir *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_setattr (struct kml_setattr *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_close (struct kml_close *rec, char *buf,
-                                int pos, int *rec_offs);
-static int unpack_mkdir (struct kml_mkdir *rec, char *buf,
-                                int pos, int *rec_offs);
-
-#if 0
-static int unpack_endmark (struct kml_endmark *rec, char *buf,
-                                int pos, int *rec_offs);
-static void print_kml_endmark (struct kml_endmark *rec);
-#endif
-
-static int kml_unpack (char *kml_buf, int rec_size, int kml_offset,
-                        struct kml_rec **newrec);
-static char *kml_version (struct presto_version *ver);
-static void print_kml_prefix (struct big_journal_prefix *head);
-static void print_kml_create (struct kml_create *rec);
-static void print_kml_mkdir (struct kml_mkdir *rec);
-static void print_kml_unlink (struct kml_unlink *rec);
-static void print_kml_rmdir (struct kml_rmdir *rec);
-static void print_kml_close (struct kml_close *rec);
-static void print_kml_symlink (struct kml_symlink *rec);
-static void print_kml_rename (struct kml_rename *rec);
-static void print_kml_setattr (struct kml_setattr *rec);
-static void print_kml_link (struct kml_link *rec);
-static void print_kml_mknod (struct kml_mknod *rec);
-static void print_kml_open (struct kml_open *rec);
-static void print_kml_suffix (struct journal_suffix *tail);
-static char *readrec (char *recbuf, int reclen, int pos, int *size);
-
-#define  KML_PREFIX_WORDS           8
-static int kml_unpack (char *kml_buf, int rec_size, int kml_offset, 
-                        struct kml_rec **newrec)
-{
-        struct kml_rec  *rec;
-        char            *p;
-        int             pos, rec_offs;
-        int             error;
-
-        ENTRY;
-        if (rec_size < sizeof (struct journal_prefix) +
-                       sizeof (struct journal_suffix))
-                return -EBADF;
-
-        PRESTO_ALLOC(rec, struct kml_rec *, sizeof (struct kml_rec));
-        if (rec == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-        rec->rec_kml_offset = kml_offset;
-        rec->rec_size = rec_size;
-        p = kml_buf;
-        p = dlogit (&rec->rec_head, p, KML_PREFIX_WORDS * sizeof (int));
-        p = dlogit (&rec->rec_head.groups, p, 
-                        sizeof (int) * rec->rec_head.ngroups);
-
-        pos = sizeof (struct journal_prefix) + 
-                        sizeof (int) * rec->rec_head.ngroups;
-        switch (rec->rec_head.opcode)
-        {
-                case KML_CREATE:
-                        error = unpack_create (&rec->rec_kml.create, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_MKDIR:
-                        error = unpack_mkdir (&rec->rec_kml.mkdir, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_UNLINK:
-                        error = unpack_unlink (&rec->rec_kml.unlink, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_RMDIR:
-                        error = unpack_rmdir (&rec->rec_kml.rmdir, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_CLOSE:
-                        error = unpack_close (&rec->rec_kml.close, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_SYMLINK:
-                        error = unpack_symlink (&rec->rec_kml.symlink, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_RENAME:
-                        error = unpack_rename (&rec->rec_kml.rename, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_SETATTR:
-                        error = unpack_setattr (&rec->rec_kml.setattr, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_LINK:
-                        error = unpack_link (&rec->rec_kml.link, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_OPEN:
-                        error = unpack_open (&rec->rec_kml.open, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-                case KML_MKNOD:
-                        error = unpack_mknod (&rec->rec_kml.mknod, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-#if 0
-                case KML_ENDMARK:
-                        error = unpack_endmark (&rec->rec_kml.endmark, 
-                                        kml_buf, pos, &rec_offs);
-                        break;
-#endif
-                default:
-                        CDEBUG (D_KML, "wrong opcode::%u\n", 
-                                        rec->rec_head.opcode);
-                        EXIT;
-                        return -EINVAL;
-        } 
-        if (error) {
-                PRESTO_FREE (rec, sizeof (struct kml_rec));
-                return -EINVAL;
-        }
-        p = kml_buf + rec_offs;
-        p = dlogit (&rec->rec_tail, p, sizeof (struct journal_suffix));
-        memset (&rec->kml_optimize, 0, sizeof (struct kml_optimize));
-        *newrec = rec;
-        EXIT;
-        return 0;
-}
-
-static int size_round (int val)
-{
-        return (val + 3) & (~0x3);
-}
-
-static int unpack_create (struct kml_create *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 88;
-        int pathlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->mode, p, sizeof (int));
-        p = dlogit (&rec->uid, p, sizeof (int));
-        p = dlogit (&rec->gid, p, sizeof (int));
-        p = dlogit (&pathlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->path = q;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_open (struct kml_open *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        *rec_offs = pos;
-        return 0;
-}
-
-static int unpack_symlink (struct kml_symlink *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 88;
-        int pathlen, targetlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->uid, p, sizeof (int));
-        p = dlogit (&rec->gid, p, sizeof (int));
-        p = dlogit (&pathlen, p, sizeof (int));
-        p = dlogit (&targetlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->sourcepath = q;
-
-        PRESTO_ALLOC(q, char *, targetlen + 1);
-        if (q == NULL) {
-                PRESTO_FREE (rec->sourcepath, pathlen + 1);
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, targetlen);
-        q[targetlen] = '\0';
-        rec->targetpath = q;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen) +
-                        size_round(targetlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_mknod (struct kml_mknod *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 96;
-        int pathlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->mode, p, sizeof (int));
-        p = dlogit (&rec->uid, p, sizeof (int));
-        p = dlogit (&rec->gid, p, sizeof (int));
-        p = dlogit (&rec->major, p, sizeof (int));
-        p = dlogit (&rec->minor, p, sizeof (int));
-        p = dlogit (&pathlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->path = q;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_link (struct kml_link *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 80;
-        int pathlen, targetlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&pathlen, p, sizeof (int));
-        p = dlogit (&targetlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->sourcepath = q;
-        p += size_round (pathlen);
-
-        PRESTO_ALLOC(q, char *, targetlen + 1);
-        if (q == NULL) {
-                PRESTO_FREE (rec->sourcepath, pathlen + 1);
-                EXIT;
-                return -ENOMEM;
-        }
-        memcpy (q, p, targetlen);
-        q[targetlen] = '\0';
-        rec->targetpath = q;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen) +
-                        size_round(targetlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_rename (struct kml_rename *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 104;
-        int pathlen, targetlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_tgtv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->old_tgtv, p, sizeof (struct presto_version));
-        p = dlogit (&pathlen, p, sizeof (int));
-        p = dlogit (&targetlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->sourcepath = q;
-        p += size_round (pathlen);
-
-        PRESTO_ALLOC(q, char *, targetlen + 1);
-        if (q == NULL) {
-                PRESTO_FREE (rec->sourcepath, pathlen + 1);
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, targetlen);
-        q[targetlen] = '\0';
-        rec->targetpath = q;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen) +
-                        size_round(targetlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_unlink (struct kml_unlink *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 80;
-        int pathlen, targetlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->old_tgtv, p, sizeof (struct presto_version));
-        p = dlogit (&pathlen, p, sizeof (int));
-        p = dlogit (&targetlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->path = q;
-        p += size_round (pathlen);
-
-        PRESTO_ALLOC(q, char *, targetlen + 1);
-        if (q == NULL) {
-                PRESTO_FREE (rec->path, pathlen + 1);
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, targetlen);
-        q[targetlen] = '\0';
-        rec->name = q;
-
-        /* fix the presto_journal_unlink problem */
-        *rec_offs = pos + unpack_size + size_round(pathlen) +
-                        size_round(targetlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_rmdir (struct kml_rmdir *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 80;
-        int pathlen, targetlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->old_tgtv, p, sizeof (struct presto_version));
-        p = dlogit (&pathlen, p, sizeof (int));
-        p = dlogit (&targetlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->path = q;
-        p += size_round (pathlen);
-
-        PRESTO_ALLOC(q, char *, targetlen + 1);
-        if (q == NULL) {
-                PRESTO_FREE (rec->path, pathlen + 1);
-                EXIT;
-                return -ENOMEM;
-        }
-        memcpy (q, p, targetlen);
-        q[targetlen] = '\0';
-        rec->name = q;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen) +
-                        size_round(targetlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_setattr (struct kml_setattr *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 72;
-        struct kml_attr {
-                __u64   size, mtime, ctime;
-        } objattr;
-        int     valid, mode, uid, gid, flags;
-        int pathlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&valid, p, sizeof (int));
-        p = dlogit (&mode, p, sizeof (int));
-        p = dlogit (&uid, p, sizeof (int));
-        p = dlogit (&gid, p, sizeof (int));
-        p = dlogit (&objattr, p, sizeof (struct kml_attr));
-        p = dlogit (&flags, p, sizeof (int));
-        p = dlogit (&pathlen, p, sizeof (int));
-
-        rec->iattr.ia_valid = valid;
-        rec->iattr.ia_mode = mode;
-        rec->iattr.ia_uid = uid;
-        rec->iattr.ia_gid = gid;
-        rec->iattr.ia_size = objattr.size;
-        rec->iattr.ia_mtime = objattr.mtime;
-        rec->iattr.ia_ctime = objattr.ctime;
-        rec->iattr.ia_atime = 0;
-        rec->iattr.ia_attr_flags = flags;
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->path = q;
-        p += pathlen;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_close (struct kml_close *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 52;
-        int pathlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->open_mode, p, sizeof (int));
-        p = dlogit (&rec->open_uid, p, sizeof (int));
-        p = dlogit (&rec->open_gid, p, sizeof (int));
-        p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->ino, p, sizeof (__u64));
-        p = dlogit (&rec->generation, p, sizeof (int));
-        p = dlogit (&pathlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->path = q;
-        p += pathlen;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen);
-        EXIT;
-        return 0;
-}
-
-static int unpack_mkdir (struct kml_mkdir *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p, *q;
-        int unpack_size = 88;
-        int pathlen;
-
-        ENTRY;
-        p = buf + pos;
-        p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
-        p = dlogit (&rec->mode, p, sizeof (int));
-        p = dlogit (&rec->uid, p, sizeof (int));
-        p = dlogit (&rec->gid, p, sizeof (int));
-        p = dlogit (&pathlen, p, sizeof (int));
-
-        PRESTO_ALLOC(q, char *, pathlen + 1);
-        if (q == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        memcpy (q, p, pathlen);
-        q[pathlen] = '\0';
-        rec->path = q;
-        p += pathlen;
-
-        *rec_offs = pos + unpack_size + size_round(pathlen);
-        EXIT;
-        return 0;
-}
-
-#if 0
-static int unpack_endmark (struct kml_endmark *rec, char *buf, 
-                                int pos, int *rec_offs)
-{
-        char *p;
-        p = buf + pos;
-        p = dlogit (&rec->total, p, sizeof (int));
-
-        PRESTO_ALLOC (rec->kop, struct kml_kop_node *, 
-                        sizeof (struct kml_kop_node) * rec->total);
-        if (rec->kop == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        p = dlogit (rec->kop, p, sizeof (struct kml_kop_node) * rec->total);
-
-        *rec_offs = pos + sizeof (int) + sizeof (struct kml_kop_node) * rec->total;
-        return 0;
-}
-#endif
-
-static char *kml_version (struct presto_version *ver)
-{
-        static char buf[256];
-        sprintf (buf, "mt::%lld, ct::%lld, size::%lld",
-                ver->pv_mtime, ver->pv_ctime, ver->pv_size); 
-        return buf;
-}
-
-static void print_kml_prefix (struct big_journal_prefix *head)
-{
-        int i;
-
-        CDEBUG (D_KML, " === KML PREFIX\n");
-        CDEBUG (D_KML, "     len        = %u\n", head->len);
-        CDEBUG (D_KML, "     version    = %u\n", head->version);
-        CDEBUG (D_KML, "     pid        = %u\n", head->pid);
-        CDEBUG (D_KML, "     uid        = %u\n", head->uid);
-        CDEBUG (D_KML, "     fsuid      = %u\n", head->fsuid);
-        CDEBUG (D_KML, "     fsgid      = %u\n", head->fsgid);
-        CDEBUG (D_KML, "     opcode     = %u\n", head->opcode);
-        CDEBUG (D_KML, "     ngroup     = %u",  head->ngroups);
-        for (i = 0; i < head->ngroups; i++)
-                CDEBUG (D_KML, "%u  ",  head->groups[i]);
-        CDEBUG (D_KML, "\n");
-}
-
-static void print_kml_create (struct kml_create *rec)
-{
-        CDEBUG (D_KML, " === CREATE\n");
-        CDEBUG (D_KML, "     path::%s\n", rec->path);
-        CDEBUG (D_KML, "     new_objv::%s\n", kml_version (&rec->new_objectv));
-        CDEBUG (D_KML, "     old_parv::%s\n", kml_version (&rec->old_parentv));
-        CDEBUG (D_KML, "     new_parv::%s\n", kml_version (&rec->new_parentv));
-        CDEBUG (D_KML, "     mode::%o\n", rec->mode);
-        CDEBUG (D_KML, "     uid::%d\n", rec->uid);
-        CDEBUG (D_KML, "     gid::%d\n", rec->gid);
-}
-
-static void print_kml_mkdir (struct kml_mkdir *rec)
-{
-        CDEBUG (D_KML, " === MKDIR\n");
-        CDEBUG (D_KML, "     path::%s\n", rec->path);
-        CDEBUG (D_KML, "     new_objv::%s\n", kml_version (&rec->new_objectv));
-        CDEBUG (D_KML, "     old_parv::%s\n", kml_version (&rec->old_parentv));
-        CDEBUG (D_KML, "     new_parv::%s\n", kml_version (&rec->new_parentv));
-        CDEBUG (D_KML, "     mode::%o\n", rec->mode);
-        CDEBUG (D_KML, "     uid::%d\n", rec->uid);
-        CDEBUG (D_KML, "     gid::%d\n", rec->gid);
-}
-
-static void print_kml_unlink (struct kml_unlink *rec)
-{
-        CDEBUG (D_KML, " === UNLINK\n");
-        CDEBUG (D_KML, "     path::%s/%s\n", rec->path, rec->name);
-        CDEBUG (D_KML, "     old_tgtv::%s\n", kml_version (&rec->old_tgtv));
-        CDEBUG (D_KML, "     old_parv::%s\n", kml_version (&rec->old_parentv));
-        CDEBUG (D_KML, "     new_parv::%s\n", kml_version (&rec->new_parentv));
-}
-
-static void print_kml_rmdir (struct kml_rmdir *rec)
-{
-        CDEBUG (D_KML, " === RMDIR\n");
-        CDEBUG (D_KML, "     path::%s/%s\n", rec->path, rec->name);
-        CDEBUG (D_KML, "     old_tgtv::%s\n", kml_version (&rec->old_tgtv));
-        CDEBUG (D_KML, "     old_parv::%s\n", kml_version (&rec->old_parentv));
-        CDEBUG (D_KML, "     new_parv::%s\n", kml_version (&rec->new_parentv));
-}
-
-static void print_kml_close (struct kml_close *rec)
-{
-        CDEBUG (D_KML, " === CLOSE\n");
-        CDEBUG (D_KML, "     mode::%o\n", rec->open_mode);
-        CDEBUG (D_KML, "     uid::%d\n", rec->open_uid);
-        CDEBUG (D_KML, "     gid::%d\n", rec->open_gid);
-        CDEBUG (D_KML, "     path::%s\n", rec->path);
-        CDEBUG (D_KML, "     new_objv::%s\n", kml_version (&rec->new_objectv));
-        CDEBUG (D_KML, "     ino::%lld\n", rec->ino);
-        CDEBUG (D_KML, "     gen::%u\n", rec->generation);
-}
-
-static void print_kml_symlink (struct kml_symlink *rec)
-{
-        CDEBUG (D_KML, " === SYMLINK\n");
-        CDEBUG (D_KML, "     s-path::%s\n", rec->sourcepath);
-        CDEBUG (D_KML, "     t-path::%s\n", rec->targetpath);
-        CDEBUG (D_KML, "     old_parv::%s\n", kml_version (&rec->old_parentv));
-        CDEBUG (D_KML, "     new_parv::%s\n", kml_version (&rec->new_parentv));
-        CDEBUG (D_KML, "     new_objv::%s\n", kml_version (&rec->new_objectv));
-        CDEBUG (D_KML, "     uid::%d\n", rec->uid);
-        CDEBUG (D_KML, "     gid::%d\n", rec->gid);
-}
-
-static void print_kml_rename (struct kml_rename *rec)
-{
-        CDEBUG (D_KML, " === RENAME\n");
-        CDEBUG (D_KML, "     s-path::%s\n", rec->sourcepath);
-        CDEBUG (D_KML, "     t-path::%s\n", rec->targetpath);
-        CDEBUG (D_KML, "     old_tgtv::%s\n", kml_version (&rec->old_tgtv));
-        CDEBUG (D_KML, "     new_tgtv::%s\n", kml_version (&rec->new_tgtv));
-        CDEBUG (D_KML, "     new_objv::%s\n", kml_version (&rec->new_objectv));
-        CDEBUG (D_KML, "     old_objv::%s\n", kml_version (&rec->old_objectv));
-}
-
-static void print_kml_setattr (struct kml_setattr *rec)
-{
-        CDEBUG (D_KML, " === SETATTR\n");
-        CDEBUG (D_KML, "     path::%s\n", rec->path);
-        CDEBUG (D_KML, "     old_objv::%s\n", kml_version (&rec->old_objectv));
-        CDEBUG (D_KML, "     valid::0x%x\n", rec->iattr.ia_valid);
-        CDEBUG (D_KML, "     mode::%o\n", rec->iattr.ia_mode);
-        CDEBUG (D_KML, "     uid::%d\n", rec->iattr.ia_uid);
-        CDEBUG (D_KML, "     gid::%d\n", rec->iattr.ia_gid);
-        CDEBUG (D_KML, "     size::%u\n", (u32) rec->iattr.ia_size);
-        CDEBUG (D_KML, "     mtime::%u\n", (u32) rec->iattr.ia_mtime);
-        CDEBUG (D_KML, "     ctime::%u\n", (u32) rec->iattr.ia_ctime);
-        CDEBUG (D_KML, "     flags::%u\n", (u32) rec->iattr.ia_attr_flags);
-}
-
-static void print_kml_link (struct kml_link *rec)
-{
-        CDEBUG (D_KML, " === LINK\n");
-        CDEBUG (D_KML, "     path::%s ==> %s\n", rec->sourcepath, rec->targetpath);
-        CDEBUG (D_KML, "     old_parv::%s\n", kml_version (&rec->old_parentv));
-        CDEBUG (D_KML, "     new_obj::%s\n", kml_version (&rec->new_objectv));
-        CDEBUG (D_KML, "     new_parv::%s\n", kml_version (&rec->new_parentv));
-}
-
-static void print_kml_mknod (struct kml_mknod *rec)
-{
-        CDEBUG (D_KML, " === MKNOD\n");
-        CDEBUG (D_KML, "     path::%s\n", rec->path);
-        CDEBUG (D_KML, "     new_obj::%s\n", kml_version (&rec->new_objectv));
-        CDEBUG (D_KML, "     old_parv::%s\n", kml_version (&rec->old_parentv));
-        CDEBUG (D_KML, "     new_parv::%s\n", kml_version (&rec->new_parentv));
-        CDEBUG (D_KML, "     mode::%o\n", rec->mode);
-        CDEBUG (D_KML, "     uid::%d\n", rec->uid);
-        CDEBUG (D_KML, "     gid::%d\n", rec->gid);
-        CDEBUG (D_KML, "     major::%d\n", rec->major);
-        CDEBUG (D_KML, "     minor::%d\n", rec->minor);
-}
-
-static void print_kml_open (struct kml_open *rec)
-{
-        CDEBUG (D_KML, " === OPEN\n");
-}
-
-#if 0
-static void print_kml_endmark (struct kml_endmark *rec)
-{
-        int i;
-        CDEBUG (D_KML, " === ENDMARK\n");
-        CDEBUG (D_KML, "     total::%u\n", rec->total);
-        for (i = 0; i < rec->total; i++)
-        {       
-                CDEBUG (D_KML, "         recno=%ld::flag=%ld,op=%ld, i_ino=%ld, \
-                        i_nlink=%ld\n", (long) rec->kop[i].kml_recno, 
-                        (long) rec->kop[i].kml_flag, (long) rec->kop[i].kml_op, 
-                        (long) rec->kop[i].i_ino, (long) rec->kop[i].i_nlink);
-        }
-}
-#endif
-
-static void print_kml_optimize (struct kml_optimize  *rec)
-{
-        CDEBUG (D_KML, " === OPTIMIZE\n");
-        if (rec->kml_flag == KML_REC_DELETE)
-                CDEBUG (D_KML, "     kml_flag::deleted\n");
-        else
-                CDEBUG (D_KML, "     kml_flag::exist\n");
-        CDEBUG (D_KML, "     kml_op::%u\n", rec->kml_op);
-        CDEBUG (D_KML, "     i_nlink::%d\n", rec->i_nlink);
-        CDEBUG (D_KML, "     i_ino::%u\n", rec->i_ino);
-}
-
-static void print_kml_suffix (struct journal_suffix *tail)
-{
-        CDEBUG (D_KML, " === KML SUFFIX\n");
-        CDEBUG (D_KML, "     prevrec::%ld\n", tail->prevrec);
-        CDEBUG (D_KML, "     recno::%ld\n", (long) tail->recno);
-        CDEBUG (D_KML, "     time::%d\n", tail->time);
-        CDEBUG (D_KML, "     len::%d\n", tail->len);
-}
-
-void kml_printrec (struct kml_rec *rec, int kml_printop)
-{
-        if (kml_printop & PRINT_KML_PREFIX)
-                print_kml_prefix (&rec->rec_head);
-        if (kml_printop & PRINT_KML_REC) 
-        { 
-                switch (rec->rec_head.opcode)
-                {
-                        case KML_CREATE:
-                                print_kml_create (&rec->rec_kml.create);
-                                break;
-                        case KML_MKDIR:
-                                print_kml_mkdir (&rec->rec_kml.mkdir);
-                                break;
-                        case KML_UNLINK:
-                                print_kml_unlink (&rec->rec_kml.unlink);
-                                break;
-                        case KML_RMDIR:
-                                print_kml_rmdir (&rec->rec_kml.rmdir);
-                                break;
-                        case KML_CLOSE:
-                                print_kml_close (&rec->rec_kml.close);
-                                break;
-                        case KML_SYMLINK:
-                                print_kml_symlink (&rec->rec_kml.symlink);
-                                break;
-                        case KML_RENAME:
-                                print_kml_rename (&rec->rec_kml.rename);
-                                break;
-                        case KML_SETATTR:
-                                print_kml_setattr (&rec->rec_kml.setattr);
-                                break;
-                        case KML_LINK:
-                                print_kml_link (&rec->rec_kml.link);
-                                break;
-                        case KML_OPEN:
-                                print_kml_open (&rec->rec_kml.open);
-                                break;
-                        case KML_MKNOD:
-                                print_kml_mknod (&rec->rec_kml.mknod);
-                                break;
-#if 0
-                        case KML_ENDMARK:
-                                print_kml_endmark (&rec->rec_kml.endmark);
-#endif
-                                break;
-                        default:
-                                CDEBUG (D_KML, " === BAD RECORD, opcode=%u\n",
-                                        rec->rec_head.opcode);
-                                break;
-                }
-        }
-        if (kml_printop & PRINT_KML_SUFFIX)
-                print_kml_suffix (&rec->rec_tail);
-        if (kml_printop & PRINT_KML_OPTIMIZE)
-                print_kml_optimize (&rec->kml_optimize);
-}
-
-void kml_freerec (struct kml_rec *rec)
-{
-        char *sourcepath = NULL,
-             *targetpath = NULL;
-        switch (rec->rec_head.opcode)
-        {
-                case KML_CREATE:
-                        sourcepath = rec->rec_kml.create.path;
-                        break;
-                case KML_MKDIR:
-                        sourcepath = rec->rec_kml.create.path;
-                        break;
-                case KML_UNLINK:
-                        sourcepath = rec->rec_kml.unlink.path;
-                        targetpath = rec->rec_kml.unlink.name;
-                        break;
-                case KML_RMDIR:
-                        sourcepath = rec->rec_kml.rmdir.path;
-                        targetpath = rec->rec_kml.rmdir.name;
-                        break;
-                case KML_CLOSE:
-                        sourcepath = rec->rec_kml.close.path;
-                        break;
-                case KML_SYMLINK:
-                        sourcepath = rec->rec_kml.symlink.sourcepath;
-                        targetpath = rec->rec_kml.symlink.targetpath;
-                        break;
-                case KML_RENAME:
-                        sourcepath = rec->rec_kml.rename.sourcepath;
-                        targetpath = rec->rec_kml.rename.targetpath;
-                        break;
-                case KML_SETATTR:
-                        sourcepath = rec->rec_kml.setattr.path;
-                        break;
-                case KML_LINK:
-                        sourcepath = rec->rec_kml.link.sourcepath;
-                        targetpath = rec->rec_kml.link.targetpath;
-                        break;
-                case KML_OPEN:
-                        break;
-                case KML_MKNOD:
-                        sourcepath = rec->rec_kml.mknod.path;
-                        break;
-#if 0
-                case KML_ENDMARK:
-                        PRESTO_FREE (rec->rec_kml.endmark.kop, sizeof (int) + 
-                                sizeof (struct kml_kop_node) * 
-                                rec->rec_kml.endmark.total);
-#endif
-                        break;
-                default:
-                        break;
-        }
-        if (sourcepath != NULL)
-                PRESTO_FREE (sourcepath, strlen (sourcepath) + 1);
-        if (targetpath != NULL)
-                PRESTO_FREE (targetpath, strlen (targetpath) + 1);
-}
-
-char *readrec (char *recbuf, int reclen, int pos, int *size)
-{
-        char *p = recbuf + pos;
-        *size = *((int *) p);
-        if (*size > (reclen - pos))
-            return NULL;
-        return p; 
-}
-
-int kml_decoderec (char *buf, int pos, int buflen, int *size, 
-                        struct kml_rec **newrec)
-{
-        char *tmp;
-        int  error;
-        tmp = readrec (buf, buflen, pos, size);
-        if (tmp == NULL)
-                return -EBADF;
-        error = kml_unpack (tmp, *size, pos, newrec); 
-        return error;
-}
-
-#if 0
-static void fill_kmlrec_optimize (struct list_head *head, 
-                struct kml_rec *optrec)
-{
-        struct kml_rec *kmlrec;
-        struct list_head *tmp;
-        struct kml_endmark *km;
-        struct kml_optimize *ko;
-        int    n;
-
-        if (optrec->rec_kml.endmark.total == 0)
-                return;
-        n = optrec->rec_kml.endmark.total - 1;
-        tmp = head->prev;
-        km = &optrec->rec_kml.endmark;
-        while ( n >= 0 && tmp != head ) 
-        {
-                kmlrec = list_entry(tmp, struct kml_rec,
-                        kml_optimize.kml_chains);
-                tmp = tmp->prev;
-                if (kmlrec->rec_tail.recno == km->kop[n].kml_recno) 
-                {
-                        ko = &kmlrec->kml_optimize;
-                        ko->kml_flag = km->kop[n].kml_flag;
-                        ko->kml_op   = km->kop[n].kml_op;
-                        ko->i_nlink  = km->kop[n].i_nlink;
-                        ko->i_ino    = km->kop[n].i_ino;
-                        n --;
-                }
-        }
-        if (n != -1)
-                CDEBUG (D_KML, "Yeah!!!, KML optimize error, recno=%d, n=%d\n",
-                        optrec->rec_tail.recno, n);     
-}
-#endif
-
-int decode_kmlrec (struct list_head *head, char *kml_buf, int buflen)
-{
-        struct kml_rec *rec;
-        int    pos = 0, size;
-        int    err;
-        while (pos < buflen) {
-                err = kml_decoderec (kml_buf, pos, buflen, &size, &rec);
-                if (err != 0)
-                        break;
-#if 0
-                if (rec->rec_head.opcode == KML_ENDMARK) {
-                        fill_kmlrec_optimize (head, rec);
-                        mark_rec_deleted (rec);
-                }
-#endif
-                list_add_tail (&rec->kml_optimize.kml_chains, head);
-                pos += size;
-        }
-        return err;
-}
-
-int delete_kmlrec (struct list_head *head)
-{
-        struct kml_rec *rec;
-        struct list_head *tmp;
-
-        if (list_empty(head))
-                return 0;
-        tmp = head->next;
-        while ( tmp != head ) {
-                rec = list_entry(tmp, struct kml_rec, 
-                        kml_optimize.kml_chains);
-                tmp = tmp->next;
-                kml_freerec (rec);
-        }
-        INIT_LIST_HEAD(head);
-        return 0;
-}
-
-int print_allkmlrec (struct list_head *head, int printop)
-{
-        struct kml_rec *rec;
-        struct list_head *tmp;
-
-        if (list_empty(head))
-                return 0;
-        tmp = head->next;
-        while ( tmp != head ) {
-                rec = list_entry(tmp, struct kml_rec,
-                        kml_optimize.kml_chains);
-                tmp = tmp->next;
-#if 0
-                if (printop & PRINT_KML_EXIST) {
-                        if (is_deleted_node (rec))
-                                continue;
-                }
-                else if (printop & PRINT_KML_DELETE) {
-                        if (! is_deleted_node (rec))
-                                continue;
-                }
-#endif
-                kml_printrec (rec, printop);
-        }
-        INIT_LIST_HEAD(head);
-        return 0;
-}
-
diff --git a/fs/intermezzo/kml_reint.c b/fs/intermezzo/kml_reint.c
deleted file mode 100644 (file)
index e447b76..0000000
+++ /dev/null
@@ -1,647 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Reintegration of KML records
- *
- */
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-#include <asm/mmu_context.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-static void kmlreint_pre_secure(struct kml_rec *rec, struct file *dir,
-                                struct run_ctxt *saved)
-{
-        struct run_ctxt ctxt; 
-        struct presto_dentry_data *dd = presto_d2d(dir->f_dentry);
-        int i;
-
-        ctxt.fsuid = rec->prefix.hdr->fsuid;
-        ctxt.fsgid = rec->prefix.hdr->fsgid;
-        ctxt.fs = KERNEL_DS; 
-        ctxt.pwd = dd->dd_fset->fset_dentry;
-        ctxt.pwdmnt = dd->dd_fset->fset_mnt;
-
-        ctxt.root = ctxt.pwd;
-        ctxt.rootmnt = ctxt.pwdmnt;
-        if (rec->prefix.hdr->ngroups > 0) {
-                ctxt.group_info = groups_alloc(rec->prefix.hdr->ngroups);
-                for (i = 0; i< ctxt.group_info->ngroups; i++) 
-                        GROUP_AT(ctxt.group_info,i)= rec->prefix.groups[i];
-        } else
-                ctxt.group_info = groups_alloc(0);
-
-        push_ctxt(saved, &ctxt);
-}
-
-
-/* Append two strings in a less-retarded fashion. */
-static char * path_join(char *p1, int p1len, char *p2, int p2len)
-{
-        int size = p1len + p2len + 2; /* possibly one extra /, one NULL */
-        char *path;
-
-        path = kmalloc(size, GFP_KERNEL);
-        if (path == NULL)
-                return NULL;
-
-        memcpy(path, p1, p1len);
-        if (path[p1len - 1] != '/') {
-                path[p1len] = '/';
-                p1len++;
-        }
-        memcpy(path + p1len, p2, p2len);
-        path[p1len + p2len] = '\0';
-
-        return path;
-}
-
-static inline int kml_recno_equal(struct kml_rec *rec,
-                                  struct presto_file_set *fset)
-{
-        return (rec->suffix->recno == fset->fset_lento_recno + 1);
-}
-
-static inline int version_equal(struct presto_version *a, struct inode *inode)
-{
-        if (a == NULL)
-                return 1;
-
-        if (inode == NULL) {
-                CERROR("InterMezzo: NULL inode in version_equal()\n");
-                return 0;
-        }
-
-        if (inode->i_mtime.tv_sec == a->pv_mtime_sec &&
-            inode->i_mtime.tv_nsec == a->pv_mtime_nsec &&
-            (S_ISDIR(inode->i_mode) || inode->i_size == a->pv_size))
-                return 1;
-
-        return 0;
-}
-
-static int reint_close(struct kml_rec *rec, struct file *file,
-                       struct lento_vfs_context *given_info)
-{
-        struct run_ctxt saved_ctxt;
-        int error;
-        struct presto_file_set *fset;
-        struct lento_vfs_context info; 
-        ENTRY;
-
-        memcpy(&info, given_info, sizeof(*given_info));
-
-
-        CDEBUG (D_KML, "=====REINT_CLOSE::%s\n", rec->path);
-
-        fset = presto_fset(file->f_dentry);
-        if (fset->fset_flags & FSET_DATA_ON_DEMAND) {
-                struct iattr iattr;
-
-                iattr.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_SIZE;
-                iattr.ia_mtime.tv_sec = (time_t)rec->new_objectv->pv_mtime_sec;
-                iattr.ia_mtime.tv_nsec = (time_t)rec->new_objectv->pv_mtime_nsec;
-                iattr.ia_ctime.tv_sec = (time_t)rec->new_objectv->pv_ctime_sec;
-                iattr.ia_ctime.tv_nsec = (time_t)rec->new_objectv->pv_ctime_nsec;
-                iattr.ia_size = (time_t)rec->new_objectv->pv_size;
-
-                /* no kml record, but update last rcvd */
-                /* save fileid in dentry for later backfetch */
-                info.flags |= LENTO_FL_EXPECT | LENTO_FL_SET_DDFILEID;
-                info.remote_ino = rec->ino;
-                info.remote_generation = rec->generation;
-                info.flags &= ~LENTO_FL_KML;
-                kmlreint_pre_secure(rec, file, &saved_ctxt);
-                error = lento_setattr(rec->path, &iattr, &info);
-                pop_ctxt(&saved_ctxt);
-
-                presto_d2d(file->f_dentry)->dd_flags &= ~PRESTO_DATA;
-        } else {
-                int minor = presto_f2m(fset);
-
-                info.updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
-                info.updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
-                memcpy(&info.remote_version, rec->old_objectv, 
-                       sizeof(*rec->old_objectv));
-                info.remote_ino = rec->ino;
-                info.remote_generation = rec->generation;
-                error = izo_upc_backfetch(minor, rec->path, fset->fset_name,
-                                          &info);
-                if (error) {
-                        CERROR("backfetch error %d\n", error);
-                        /* if file doesn't exist anymore,  then ignore the CLOSE
-                         * and just update the last_rcvd.
-                         */
-                        if (error == ENOENT) {
-                                CDEBUG(D_KML, "manually updating remote offset uuid %s"
-                                       "recno %d offset %Lu\n", info.uuid, info.recno,
-                                       (unsigned long long) info.kml_offset);
-                                error = izo_rcvd_upd_remote(fset, info.uuid, info.recno, info.kml_offset);
-                                if(error)
-                                        CERROR("izo_rcvd_upd_remote error %d\n", error);
-
-                        } 
-                }
-                        
-                /* propagate error to avoid further reint */
-        }
-
-        EXIT;
-        return error;
-}
-
-static int reint_create(struct kml_rec *rec, struct file *dir,
-                        struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;        ENTRY;
-
-        CDEBUG (D_KML, "=====REINT_CREATE::%s\n", rec->path);
-        info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
-        info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_create(rec->path, rec->mode, info);
-        pop_ctxt(&saved_ctxt); 
-
-        EXIT;
-        return error;
-}
-
-static int reint_link(struct kml_rec *rec, struct file *dir,
-                      struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;
-
-        ENTRY;
-
-        CDEBUG (D_KML, "=====REINT_LINK::%s -> %s\n", rec->path, rec->target);
-        info->updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
-        info->updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_link(rec->path, rec->target, info);
-        pop_ctxt(&saved_ctxt); 
-
-        EXIT;
-        return error;
-}
-
-static int reint_mkdir(struct kml_rec *rec, struct file *dir,
-                       struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;
-
-        ENTRY;
-
-        CDEBUG (D_KML, "=====REINT_MKDIR::%s\n", rec->path);
-        info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
-        info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_mkdir(rec->path, rec->mode, info);
-        pop_ctxt(&saved_ctxt); 
-
-        EXIT;
-        return error;
-}
-
-static int reint_mknod(struct kml_rec *rec, struct file *dir,
-                       struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;
-       dev_t dev;
-
-        ENTRY;
-
-        CDEBUG (D_KML, "=====REINT_MKNOD::%s\n", rec->path);
-        info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
-        info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-
-        dev = rec->rdev ? old_decode_dev(rec->rdev) : MKDEV(rec->major, rec->minor);
-
-        error = lento_mknod(rec->path, rec->mode, dev, info);
-        pop_ctxt(&saved_ctxt); 
-
-        EXIT;
-        return error;
-}
-
-
-static int reint_noop(struct kml_rec *rec, struct file *dir,
-                      struct lento_vfs_context *info)
-{
-        return 0;
-}
-
-static int reint_rename(struct kml_rec *rec, struct file *dir,
-                        struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;
-
-        ENTRY;
-
-        CDEBUG (D_KML, "=====REINT_RENAME::%s -> %s\n", rec->path, rec->target);
-        info->updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
-        info->updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_rename(rec->path, rec->target, info);
-        pop_ctxt(&saved_ctxt); 
-
-        EXIT;
-        return error;
-}
-
-static int reint_rmdir(struct kml_rec *rec, struct file *dir,
-                       struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;
-        char *path;
-
-        ENTRY;
-
-        path = path_join(rec->path, rec->pathlen - 1, rec->target, rec->targetlen);
-        if (path == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        CDEBUG (D_KML, "=====REINT_RMDIR::%s\n", path);
-        info->updated_time.tv_sec = rec->new_parentv->pv_mtime_sec;
-        info->updated_time.tv_nsec = rec->new_parentv->pv_mtime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_rmdir(path, info);
-        pop_ctxt(&saved_ctxt); 
-
-        kfree(path);
-        EXIT;
-        return error;
-}
-
-static int reint_setattr(struct kml_rec *rec, struct file *dir,
-                         struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        struct iattr iattr;
-        int     error;
-
-        ENTRY;
-
-        iattr.ia_valid = rec->valid;
-        iattr.ia_mode  = (umode_t)rec->mode;
-        iattr.ia_uid   = (uid_t)rec->uid;
-        iattr.ia_gid   = (gid_t)rec->gid;
-        iattr.ia_size  = (off_t)rec->size;
-        iattr.ia_ctime.tv_sec = rec->ctime_sec;
-        iattr.ia_ctime.tv_nsec = rec->ctime_nsec;
-        iattr.ia_mtime.tv_sec = rec->mtime_sec;
-        iattr.ia_mtime.tv_nsec = rec->mtime_nsec;
-        iattr.ia_atime = iattr.ia_mtime; /* We don't track atimes. */
-        iattr.ia_attr_flags = rec->flags;
-
-        CDEBUG (D_KML, "=====REINT_SETATTR::%s (%d)\n", rec->path, rec->valid);
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_setattr(rec->path, &iattr, info);
-        pop_ctxt(&saved_ctxt); 
-
-        EXIT;
-        return error;
-}
-
-static int reint_symlink(struct kml_rec *rec, struct file *dir,
-                         struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;
-
-        ENTRY;
-
-        CDEBUG (D_KML, "=====REINT_SYMLINK::%s -> %s\n", rec->path, rec->target);
-        info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
-        info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_symlink(rec->target, rec->path, info);
-        pop_ctxt(&saved_ctxt); 
-
-        EXIT;
-        return error;
-}
-
-static int reint_unlink(struct kml_rec *rec, struct file *dir,
-                        struct lento_vfs_context *info)
-{
-        struct run_ctxt saved_ctxt;
-        int     error;
-        char *path;
-
-        ENTRY;
-
-        path = path_join(rec->path, rec->pathlen - 1, rec->target, rec->targetlen);
-        if (path == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-
-        CDEBUG (D_KML, "=====REINT_UNLINK::%s\n", path);
-        info->updated_time.tv_sec = rec->new_parentv->pv_mtime_sec;
-        info->updated_time.tv_nsec = rec->new_parentv->pv_mtime_nsec;
-        kmlreint_pre_secure(rec, dir, &saved_ctxt);
-        error = lento_unlink(path, info);
-        pop_ctxt(&saved_ctxt); 
-
-        kfree(path);
-        EXIT;
-        return error;
-}
-
-static int branch_reint_rename(struct presto_file_set *fset, struct kml_rec *rec, 
-                   struct file *dir, struct lento_vfs_context *info,
-                   char * kml_data, __u64 kml_size)
-{
-        int     error;
-
-        ENTRY;
-
-        error = reint_rename(rec, dir, info);
-        if (error == -ENOENT) {
-                /* normal reint failed because path was not found */
-                struct rec_info rec;
-                
-                CDEBUG(D_KML, "saving branch rename kml\n");
-                rec.is_kml = 1;
-                rec.size = kml_size;
-                error = presto_log(fset, &rec, kml_data, kml_size,
-                           NULL, 0, NULL, 0,  NULL, 0);
-                if (error == 0)
-                        error = presto_write_last_rcvd(&rec, fset, info);
-        }
-
-        EXIT;
-        return error;
-}
-
-int branch_reinter(struct presto_file_set *fset, struct kml_rec *rec, 
-                   struct file *dir, struct lento_vfs_context *info,
-                   char * kml_data, __u64 kml_size)
-{
-        int error = 0;
-        int op = rec->prefix.hdr->opcode;
-
-        if (op == KML_OPCODE_CLOSE) {
-                /* regular close and backfetch */
-                error = reint_close(rec, dir, info);
-        } else if  (op == KML_OPCODE_RENAME) {
-                /* rename only if name already exists  */
-                error = branch_reint_rename(fset, rec, dir, info,
-                                            kml_data, kml_size);
-        } else {
-                /* just rewrite kml into branch/kml and update last_rcvd */
-                struct rec_info rec;
-                
-                CDEBUG(D_KML, "Saving branch kml\n");
-                rec.is_kml = 1;
-                rec.size = kml_size;
-                error = presto_log(fset, &rec, kml_data, kml_size,
-                           NULL, 0, NULL, 0,  NULL, 0);
-                if (error == 0)
-                        error = presto_write_last_rcvd(&rec, fset, info);
-        }
-                
-        return error;
-}
-
-typedef int (*reinter_t)(struct kml_rec *rec, struct file *basedir,
-                         struct lento_vfs_context *info);
-
-static reinter_t presto_reinters[KML_OPCODE_NUM] =
-{
-        [KML_OPCODE_CLOSE] = reint_close,
-        [KML_OPCODE_CREATE] = reint_create,
-        [KML_OPCODE_LINK] = reint_link,
-        [KML_OPCODE_MKDIR] = reint_mkdir,
-        [KML_OPCODE_MKNOD] = reint_mknod,
-        [KML_OPCODE_NOOP] = reint_noop,
-        [KML_OPCODE_RENAME] = reint_rename,
-        [KML_OPCODE_RMDIR] = reint_rmdir,
-        [KML_OPCODE_SETATTR] = reint_setattr,
-        [KML_OPCODE_SYMLINK] = reint_symlink,
-        [KML_OPCODE_UNLINK] = reint_unlink,
-};
-
-static inline reinter_t get_reinter(int op)
-{
-        if (op < 0 || op >= sizeof(presto_reinters) / sizeof(reinter_t)) 
-                return NULL; 
-        else 
-                return  presto_reinters[op];
-}
-
-int kml_reint_rec(struct file *dir, struct izo_ioctl_data *data)
-{
-        char *ptr;
-        char *end;
-        struct kml_rec rec;
-        int error = 0;
-        struct lento_vfs_context info;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct presto_dentry_data *dd = presto_d2d(dir->f_dentry);
-        int op;
-        reinter_t reinter;
-
-        struct izo_rcvd_rec lr_rec;
-        int off;
-
-        ENTRY;
-
-        error = presto_prep(dir->f_dentry, &cache, &fset);
-        if ( error  ) {
-                CERROR("intermezzo: Reintegration on invalid file\n");
-                return error;
-        }
-
-        if (!dd || !dd->dd_fset || dd->dd_fset->fset_dentry != dir->f_dentry) { 
-                CERROR("intermezzo: reintegration on non-fset root (ino %ld)\n",
-                       dir->f_dentry->d_inode->i_ino);
-                    
-                return -EINVAL;
-        }
-
-        if (data->ioc_plen1 > 64 * 1024) {
-                EXIT;
-                return -ENOSPC;
-        }
-
-        ptr = fset->fset_reint_buf;
-        end = ptr + data->ioc_plen1;
-
-        if (copy_from_user(ptr, data->ioc_pbuf1, data->ioc_plen1)) { 
-                EXIT;
-                error = -EFAULT;
-                goto out;
-        }
-
-        error = kml_unpack(&rec, &ptr, end);
-        if (error) { 
-                EXIT;
-                error = -EFAULT;
-                goto out;
-        }
-
-        off = izo_rcvd_get(&lr_rec, fset, data->ioc_uuid);
-        if (off < 0) {
-                CERROR("No last_rcvd record, setting to 0\n");
-                memset(&lr_rec, 0, sizeof(lr_rec));
-        }
-        data->ioc_kmlsize = ptr - fset->fset_reint_buf;
-
-        if (rec.suffix->recno != lr_rec.lr_remote_recno + 1) {
-                CERROR("KML record number %Lu expected, not %d\n",
-                       (unsigned long long) (lr_rec.lr_remote_recno + 1),
-                       rec.suffix->recno);
-
-#if 0
-                if (!version_check(&rec, dd->dd_fset, &info)) {
-                        /* FIXME: do an upcall to resolve conflicts */
-                        CERROR("intermezzo: would be a conflict!\n");
-                        error = -EINVAL;
-                        EXIT;
-                        goto out;
-                }
-#endif
-        }
-
-        op = rec.prefix.hdr->opcode;
-
-        reinter = get_reinter(op);
-        if (!reinter) { 
-                CERROR("%s: Unrecognized KML opcode %d\n", __FUNCTION__, op);
-                error = -EINVAL;
-                EXIT;
-                goto out;
-        }
-
-        info.kml_offset = data->ioc_offset + data->ioc_kmlsize;
-        info.recno = rec.suffix->recno;
-        info.flags = LENTO_FL_EXPECT;
-        if (data->ioc_flags)
-                info.flags |= LENTO_FL_KML;
-
-        memcpy(info.uuid, data->ioc_uuid, sizeof(info.uuid));
-
-        if (fset->fset_flags & FSET_IS_BRANCH && data->ioc_flags)
-                error = branch_reinter(fset, &rec, dir, &info, fset->fset_reint_buf,
-                                       data->ioc_kmlsize);
-        else 
-                error = reinter(&rec, dir, &info);
- out: 
-        EXIT;
-        return error;
-}
-
-int izo_get_fileid(struct file *dir, struct izo_ioctl_data *data)
-{
-        char *buf = NULL; 
-        char *ptr;
-        char *end;
-        struct kml_rec rec;
-        struct file *file;
-        struct presto_cache *cache;
-        struct presto_file_set *fset;
-        struct presto_dentry_data *dd = presto_d2d(dir->f_dentry);
-        struct run_ctxt saved_ctxt;
-        int     error;
-
-        ENTRY;
-
-        error = presto_prep(dir->f_dentry, &cache, &fset);
-        if ( error  ) {
-                CERROR("intermezzo: Reintegration on invalid file\n");
-                return error;
-        }
-
-        if (!dd || !dd->dd_fset || dd->dd_fset->fset_dentry != dir->f_dentry) { 
-                CERROR("intermezzo: reintegration on non-fset root (ino %ld)\n",
-                       dir->f_dentry->d_inode->i_ino);
-                    
-                return -EINVAL;
-        }
-
-
-        PRESTO_ALLOC(buf, data->ioc_plen1);
-        if (!buf) { 
-                EXIT;
-                return -ENOMEM;
-        }
-        ptr = buf;
-        end = buf + data->ioc_plen1;
-
-        if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) { 
-                EXIT;
-                PRESTO_FREE(buf, data->ioc_plen1);
-                return -EFAULT;
-        }
-
-        error = kml_unpack(&rec, &ptr, end);
-        if (error) { 
-                EXIT;
-                PRESTO_FREE(buf, data->ioc_plen1);
-                return -EFAULT;
-        }
-
-        kmlreint_pre_secure(&rec, dir, &saved_ctxt);
-
-        file = filp_open(rec.path, O_RDONLY, 0);
-        if (!file || IS_ERR(file)) { 
-                error = PTR_ERR(file);
-                goto out;
-        }
-        data->ioc_ino = file->f_dentry->d_inode->i_ino;
-        data->ioc_generation = file->f_dentry->d_inode->i_generation; 
-        filp_close(file, 0); 
-
-        CDEBUG(D_FILE, "%s ino %Lx, gen %Lx\n", rec.path,
-               (unsigned long long) data->ioc_ino,
-               (unsigned long long) data->ioc_generation);
-
- out:
-        if (buf) 
-                PRESTO_FREE(buf, data->ioc_plen1);
-        pop_ctxt(&saved_ctxt); 
-        EXIT;
-        return error;
-}
-
-
diff --git a/fs/intermezzo/kml_setup.c b/fs/intermezzo/kml_setup.c
deleted file mode 100644 (file)
index 8a01718..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_upcall.h"
-#include "intermezzo_psdev.h"
-#include "intermezzo_kml.h"
-
-int kml_init (struct presto_file_set *fset)
-{
-        struct kml_fsdata *data;
-
-        ENTRY;
-        PRESTO_ALLOC (data, struct kml_fsdata *, sizeof (struct kml_fsdata));
-        if (data == NULL) {
-                EXIT;
-                return -ENOMEM;
-        }
-        INIT_LIST_HEAD (&data->kml_reint_cache);
-        INIT_LIST_HEAD (&data->kml_kop_cache);
-
-        PRESTO_ALLOC (data->kml_buf, char *, KML_REINT_MAXBUF);
-        if (data->kml_buf == NULL) {
-                PRESTO_FREE (data, sizeof (struct kml_fsdata));
-                EXIT;
-                return -ENOMEM;
-        }
-
-        data->kml_maxsize = KML_REINT_MAXBUF;
-        data->kml_len = 0;
-        data->kml_reintpos = 0;
-        data->kml_count = 0;
-        fset->fset_kmldata = data;
-        EXIT;
-        return 0;
-}
-
-int kml_cleanup (struct presto_file_set *fset)
-{
-        struct kml_fsdata *data = fset->fset_kmldata;
-
-        if (data == NULL)
-                return 0;
-
-        fset->fset_kmldata = NULL;
-#if 0
-        kml_sop_cleanup (&data->kml_reint_cache);
-        kml_kop_cleanup (&data->kml_kop_cache);
-#endif
-        PRESTO_FREE (data->kml_buf, KML_REINT_MAXBUF);
-        PRESTO_FREE (data, sizeof (struct kml_fsdata));
-        return 0;
-}
-
-
diff --git a/fs/intermezzo/kml_unpack.c b/fs/intermezzo/kml_unpack.c
deleted file mode 100644 (file)
index d12a346..0000000
+++ /dev/null
@@ -1,712 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Unpacking of KML records
- *
- */
-
-#ifdef __KERNEL__
-#  include <linux/module.h>
-#  include <linux/errno.h>
-#  include <linux/kernel.h>
-#  include <linux/major.h>
-#  include <linux/sched.h>
-#  include <linux/lp.h>
-#  include <linux/slab.h>
-#  include <linux/ioport.h>
-#  include <linux/fcntl.h>
-#  include <linux/delay.h>
-#  include <linux/skbuff.h>
-#  include <linux/proc_fs.h>
-#  include <linux/vmalloc.h>
-#  include <linux/fs.h>
-#  include <linux/poll.h>
-#  include <linux/init.h>
-#  include <linux/list.h>
-#  include <linux/stat.h>
-#  include <asm/io.h>
-#  include <asm/segment.h>
-#  include <asm/system.h>
-#  include <asm/poll.h>
-#  include <asm/uaccess.h>
-#else
-#  include <time.h>
-#  include <stdio.h>
-#  include <string.h>
-#  include <stdlib.h>
-#  include <errno.h>
-#  include <sys/stat.h>
-#  include <glib.h>
-#endif
-
-#include "intermezzo_lib.h"
-#include "intermezzo_idl.h"
-#include "intermezzo_fs.h"
-
-int kml_unpack_version(struct presto_version **ver, char **buf, char *end) 
-{
-       char *ptr = *buf;
-        struct presto_version *pv;
-
-       UNLOGP(*ver, struct presto_version, ptr, end);
-        pv = *ver;
-        pv->pv_mtime_sec   = NTOH__u32(pv->pv_mtime_sec);
-        pv->pv_mtime_nsec   = NTOH__u32(pv->pv_mtime_nsec);
-        pv->pv_ctime_sec   = NTOH__u32(pv->pv_ctime_sec);
-        pv->pv_ctime_nsec   = NTOH__u32(pv->pv_ctime_nsec);
-        pv->pv_size    = NTOH__u64(pv->pv_size);
-
-       *buf = ptr;
-
-        return 0;
-}
-
-
-static int kml_unpack_noop(struct kml_rec *rec, char **buf, char *end)
-{
-       return 0;
-}
-
-static int kml_unpack_get_fileid(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
-       *buf = ptr;
-       return 0;
-}
-
-static int kml_unpack_create(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->mode, __u32, ptr, end);
-       LUNLOGV(rec->uid, __u32, ptr, end);
-       LUNLOGV(rec->gid, __u32, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-static int kml_unpack_mkdir(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->mode, __u32, ptr, end);
-       LUNLOGV(rec->uid, __u32, ptr, end);
-       LUNLOGV(rec->gid, __u32, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_unlink(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       kml_unpack_version(&rec->old_objectv, &ptr, end);
-        LUNLOGV(rec->old_mode, __u32, ptr, end);
-        LUNLOGV(rec->old_rdev, __u32, ptr, end);
-        LUNLOGV(rec->old_uid, __u64, ptr, end);
-        LUNLOGV(rec->old_gid, __u64, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       LUNLOGV(rec->targetlen, __u32, ptr, end);
-        LUNLOGV(rec->old_targetlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-        UNLOGL(rec->old_target, char, rec->old_targetlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_rmdir(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       kml_unpack_version(&rec->old_objectv, &ptr, end);
-        LUNLOGV(rec->old_mode, __u32, ptr, end);
-        LUNLOGV(rec->old_rdev, __u32, ptr, end);
-        LUNLOGV(rec->old_uid, __u64, ptr, end);
-        LUNLOGV(rec->old_gid, __u64, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       LUNLOGV(rec->targetlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_close(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       LUNLOGV(rec->mode, __u32, ptr, end);  // used for open_mode
-       LUNLOGV(rec->uid, __u32, ptr, end);   // used for open_uid
-       LUNLOGV(rec->gid, __u32, ptr, end);   // used for open_gid
-       kml_unpack_version(&rec->old_objectv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->ino, __u64, ptr, end);
-       LUNLOGV(rec->generation, __u32, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_symlink(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->uid, __u32, ptr, end);
-       LUNLOGV(rec->gid, __u32, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       LUNLOGV(rec->targetlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_rename(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_objectv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       LUNLOGV(rec->targetlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_setattr(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_objectv, &ptr, end);
-       LUNLOGV(rec->valid, __u32, ptr, end);
-       LUNLOGV(rec->mode, __u32, ptr, end);
-       LUNLOGV(rec->uid, __u32, ptr, end);
-       LUNLOGV(rec->gid, __u32, ptr, end);
-       LUNLOGV(rec->size, __u64, ptr, end);
-       LUNLOGV(rec->mtime_sec, __u32, ptr, end);
-       LUNLOGV(rec->mtime_nsec, __u32, ptr, end);
-       LUNLOGV(rec->ctime_sec, __u32, ptr, end);
-       LUNLOGV(rec->ctime_nsec, __u32, ptr, end);
-       LUNLOGV(rec->flags, __u32, ptr, end);
-        LUNLOGV(rec->old_mode, __u32, ptr, end);
-        LUNLOGV(rec->old_rdev, __u32, ptr, end);
-        LUNLOGV(rec->old_uid, __u64, ptr, end);
-        LUNLOGV(rec->old_gid, __u64, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_link(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       LUNLOGV(rec->targetlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-static int kml_unpack_mknod(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_parentv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->mode, __u32, ptr, end);
-       LUNLOGV(rec->uid, __u32, ptr, end);
-       LUNLOGV(rec->gid, __u32, ptr, end);
-       LUNLOGV(rec->major, __u32, ptr, end);
-       LUNLOGV(rec->minor, __u32, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_write(struct kml_rec *rec, char **buf, char *end)
-{
-       printf("NOT IMPLEMENTED");
-       return 0;
-}
-
-
-static int kml_unpack_release(struct kml_rec *rec, char **buf, char *end)
-{
-       printf("NOT IMPLEMENTED");
-       return 0;
-}
-
-
-static int kml_unpack_trunc(struct kml_rec *rec, char **buf, char *end)
-{
-       printf("NOT IMPLEMENTED");
-       return 0;
-}
-
-
-static int kml_unpack_setextattr(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_objectv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->flags, __u32, ptr, end);
-       LUNLOGV(rec->mode, __u32, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       LUNLOGV(rec->namelen, __u32, ptr, end);
-       LUNLOGV(rec->targetlen, __u32, ptr, end);
-        UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       UNLOGL(rec->name, char, rec->namelen, ptr, end);
-       UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-
-static int kml_unpack_delextattr(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-
-       kml_unpack_version(&rec->old_objectv, &ptr, end);
-       kml_unpack_version(&rec->new_objectv, &ptr, end);
-       LUNLOGV(rec->flags, __u32, ptr, end);
-       LUNLOGV(rec->mode, __u32, ptr, end);
-       LUNLOGV(rec->pathlen, __u32, ptr, end);
-       LUNLOGV(rec->namelen, __u32, ptr, end);
-       LUNLOGV(rec->targetlen, __u32, ptr, end);
-       UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-       UNLOGL(rec->name, char, rec->namelen, ptr, end);
-
-       *buf = ptr;
-
-       return 0;
-}
-
-static int kml_unpack_open(struct kml_rec *rec, char **buf, char *end)
-{
-       printf("NOT IMPLEMENTED");
-       return 0;
-}
-
-static int kml_unpack_kml_trunc(struct kml_rec *rec, char **buf, char *end)
-{
-
-       printf("NOT IMPLEMENTED");
-       return 0;
-}
-
-
-typedef int (*unpacker)(struct kml_rec *rec, char **buf, char *end);
-
-static unpacker unpackers[KML_OPCODE_NUM] = 
-{
-       [KML_OPCODE_NOOP] = kml_unpack_noop,
-       [KML_OPCODE_CREATE] = kml_unpack_create, 
-       [KML_OPCODE_MKDIR] = kml_unpack_mkdir,
-       [KML_OPCODE_UNLINK] = kml_unpack_unlink,
-       [KML_OPCODE_RMDIR] = kml_unpack_rmdir,
-       [KML_OPCODE_CLOSE] = kml_unpack_close,
-       [KML_OPCODE_SYMLINK] = kml_unpack_symlink,
-       [KML_OPCODE_RENAME] = kml_unpack_rename,
-       [KML_OPCODE_SETATTR] = kml_unpack_setattr,
-       [KML_OPCODE_LINK] = kml_unpack_link,
-       [KML_OPCODE_OPEN] = kml_unpack_open,
-       [KML_OPCODE_MKNOD] = kml_unpack_mknod,
-       [KML_OPCODE_WRITE] = kml_unpack_write,
-       [KML_OPCODE_RELEASE] = kml_unpack_release,
-       [KML_OPCODE_TRUNC] = kml_unpack_trunc,
-       [KML_OPCODE_SETEXTATTR] = kml_unpack_setextattr,
-       [KML_OPCODE_DELEXTATTR] = kml_unpack_delextattr,
-       [KML_OPCODE_KML_TRUNC] = kml_unpack_kml_trunc,
-       [KML_OPCODE_GET_FILEID] = kml_unpack_get_fileid
-};
-
-int kml_unpack_prefix(struct kml_rec *rec, char **buf, char *end) 
-{
-       char *ptr = *buf;
-        int n;
-
-        UNLOGP(rec->prefix.hdr, struct kml_prefix_hdr, ptr, end);
-        rec->prefix.hdr->len     = NTOH__u32(rec->prefix.hdr->len);
-        rec->prefix.hdr->version = NTOH__u32(rec->prefix.hdr->version);
-        rec->prefix.hdr->pid     = NTOH__u32(rec->prefix.hdr->pid);
-        rec->prefix.hdr->auid    = NTOH__u32(rec->prefix.hdr->auid);
-        rec->prefix.hdr->fsuid   = NTOH__u32(rec->prefix.hdr->fsuid);
-        rec->prefix.hdr->fsgid   = NTOH__u32(rec->prefix.hdr->fsgid);
-        rec->prefix.hdr->opcode  = NTOH__u32(rec->prefix.hdr->opcode);
-        rec->prefix.hdr->ngroups = NTOH__u32(rec->prefix.hdr->ngroups);
-
-       UNLOGL(rec->prefix.groups, __u32, rec->prefix.hdr->ngroups, ptr, end);
-        for (n = 0; n < rec->prefix.hdr->ngroups; n++) {
-                rec->prefix.groups[n] = NTOH__u32(rec->prefix.groups[n]);
-        }
-
-       *buf = ptr;
-
-        return 0;
-}
-
-int kml_unpack_suffix(struct kml_rec *rec, char **buf, char *end) 
-{
-       char *ptr = *buf;
-
-       UNLOGP(rec->suffix, struct kml_suffix, ptr, end);
-        rec->suffix->prevrec   = NTOH__u32(rec->suffix->prevrec);
-        rec->suffix->recno    = NTOH__u32(rec->suffix->recno);
-        rec->suffix->time     = NTOH__u32(rec->suffix->time);
-        rec->suffix->len      = NTOH__u32(rec->suffix->len);
-
-       *buf = ptr;
-
-        return 0;
-}
-
-int kml_unpack(struct kml_rec *rec, char **buf, char *end)
-{
-       char *ptr = *buf;
-       int err; 
-
-        if (((unsigned long)ptr % 4) != 0) {
-                printf("InterMezzo: %s: record misaligned.\n", __FUNCTION__);
-                return -EINVAL;
-        }
-
-        while (ptr < end) { 
-                __u32 *i = (__u32 *)ptr;
-                if (*i)
-                        break;
-                ptr += sizeof(*i);
-        }
-       *buf = ptr;
-
-       memset(rec, 0, sizeof(*rec));
-
-        err = kml_unpack_prefix(rec, &ptr, end);
-       if (err) {
-                printf("InterMezzo: %s: unpack_prefix failed: %d\n",
-                       __FUNCTION__, err);
-               return err;
-        }
-
-        if (rec->prefix.hdr->opcode < 0  ||
-            rec->prefix.hdr->opcode >= KML_OPCODE_NUM) {
-                printf("InterMezzo: %s: invalid opcode (%d)\n",
-                       __FUNCTION__, rec->prefix.hdr->opcode);
-               return -EINVAL;
-        }
-       err = unpackers[rec->prefix.hdr->opcode](rec, &ptr, end);
-       if (err) {
-                printf("InterMezzo: %s: unpacker failed: %d\n",
-                       __FUNCTION__, err);
-               return err;
-        }
-
-        err = kml_unpack_suffix(rec, &ptr, end);
-       if (err) {
-                printf("InterMezzo: %s: unpack_suffix failed: %d\n",
-                       __FUNCTION__, err);
-               return err;
-        }
-
-
-       if (rec->prefix.hdr->len != rec->suffix->len) {
-                printf("InterMezzo: %s: lengths don't match\n",
-                       __FUNCTION__);
-               return -EINVAL;
-        }
-        if ((rec->prefix.hdr->len % 4) != 0) {
-                printf("InterMezzo: %s: record length not a "
-                       "multiple of 4.\n", __FUNCTION__);
-                return -EINVAL;
-        }
-        if (ptr - *buf != rec->prefix.hdr->len) {
-                printf("InterMezzo: %s: unpacking error\n",
-                       __FUNCTION__);
-                return -EINVAL;
-        }
-        while (ptr < end) { 
-                __u32 *i = (__u32 *)ptr;
-                if (*i)
-                        break;
-                ptr += sizeof(*i);
-        }
-       *buf = ptr;
-       return 0;
-}
-
-
-#ifndef __KERNEL__
-#define STR(ptr) ((ptr))? (ptr) : ""
-
-#define OPNAME(n) [KML_OPCODE_##n] = #n
-static char *opnames[KML_OPCODE_NUM] = {
-       OPNAME(NOOP),
-       OPNAME(CREATE),
-       OPNAME(MKDIR), 
-       OPNAME(UNLINK),
-       OPNAME(RMDIR),
-       OPNAME(CLOSE),
-       OPNAME(SYMLINK),
-       OPNAME(RENAME),
-       OPNAME(SETATTR),
-       OPNAME(LINK),
-       OPNAME(OPEN),
-       OPNAME(MKNOD),
-       OPNAME(WRITE),
-       OPNAME(RELEASE),
-       OPNAME(TRUNC),
-       OPNAME(SETEXTATTR),
-       OPNAME(DELEXTATTR),
-       OPNAME(KML_TRUNC),
-       OPNAME(GET_FILEID)
-};
-#undef OPNAME
-
-static char *print_opname(int op)
-{
-       if (op < 0 || op >= sizeof (opnames) / sizeof (*opnames))
-               return NULL;
-       return opnames[op];
-}
-
-
-static char *print_time(__u64 i)
-{
-       char buf[128];
-       
-       memset(buf, 0, 128);
-
-#ifndef __KERNEL__
-       strftime(buf, 128, "%Y/%m/%d %H:%M:%S", gmtime((time_t *)&i));
-#else
-       sprintf(buf, "%Ld\n", i);
-#endif
-
-       return strdup(buf);
-}
-
-static char *print_version(struct presto_version *ver)
-{
-       char ver_buf[128];
-       char *mtime;
-       char *ctime;
-
-       if (!ver || ver->pv_ctime == 0) {
-               return strdup("");
-       } 
-       mtime = print_time(ver->pv_mtime);
-       ctime = print_time(ver->pv_ctime);
-       sprintf(ver_buf, "mtime %s, ctime %s, len %lld", 
-               mtime, ctime, ver->pv_size);
-       free(mtime);
-       free(ctime);
-       return strdup(ver_buf);
-}
-
-
-char *kml_print_rec(struct kml_rec *rec, int brief)
-{
-       char *str;
-       char *nov, *oov, *ntv, *otv, *npv, *opv;
-       char *rectime, *mtime, *ctime;
-
-        if (brief) {
-               str = g_strdup_printf(" %08d %7s %*s %*s", 
-                                      rec->suffix->recno,
-                                      print_opname (rec->prefix.hdr->opcode),
-                                      rec->pathlen, STR(rec->path),
-                                      rec->targetlen, STR(rec->target));
-                
-               return str;
-       }
-
-       rectime = print_time(rec->suffix->time);
-       mtime = print_time(rec->mtime);
-       ctime = print_time(rec->ctime);
-
-       nov = print_version(rec->new_objectv);
-       oov = print_version(rec->old_objectv);
-       ntv = print_version(rec->new_targetv);
-       otv = print_version(rec->old_targetv);
-       npv = print_version(rec->new_parentv);
-       opv = print_version(rec->old_parentv);
-
-       str = g_strdup_printf("\n -- Record:\n"
-               "    Recno     %d\n"
-               "    KML off   %lld\n" 
-               "    Version   %d\n" 
-               "    Len       %d\n"
-               "    Suf len   %d\n"
-               "    Time      %s\n"
-               "    Opcode    %d\n"
-               "    Op        %s\n"
-               "    Pid       %d\n"
-               "    AUid      %d\n"
-               "    Fsuid     %d\n" 
-               "    Fsgid     %d\n"
-               "    Prevrec   %d\n" 
-               "    Ngroups   %d\n"
-               //"    Groups    @{$self->{groups}}\n" 
-               " -- Path:\n"
-               "    Inode     %d\n"
-               "    Gen num   %u\n"
-                "    Old mode  %o\n"
-                "    Old rdev  %x\n"
-                "    Old uid   %llu\n"
-                "    Old gid   %llu\n"
-               "    Path      %*s\n"
-               //"    Open_mode %o\n",
-               "    Pathlen   %d\n"
-               "    Tgt       %*s\n"
-               "    Tgtlen    %d\n" 
-               "    Old Tgt   %*s\n"
-               "    Old Tgtln %d\n" 
-               " -- Attr:\n"
-               "    Valid     %x\n"
-               "    mode %o, uid %d, gid %d, size %lld, mtime %s, ctime %s rdev %x (%d:%d)\n"
-               " -- Versions:\n"
-               "    New object %s\n"
-               "    Old object %s\n"
-               "    New target %s\n"
-               "    Old target %s\n"
-               "    New parent %s\n"
-               "    Old parent %s\n", 
-               
-               rec->suffix->recno, 
-               rec->offset, 
-               rec->prefix.hdr->version, 
-               rec->prefix.hdr->len, 
-               rec->suffix->len, 
-               rectime,
-               rec->prefix.hdr->opcode, 
-               print_opname (rec->prefix.hdr->opcode),
-               rec->prefix.hdr->pid,
-               rec->prefix.hdr->auid,
-               rec->prefix.hdr->fsuid,
-               rec->prefix.hdr->fsgid,
-               rec->suffix->prevrec,
-               rec->prefix.hdr->ngroups,
-               rec->ino,
-               rec->generation,
-                rec->old_mode,
-                rec->old_rdev,
-                rec->old_uid,
-                rec->old_gid,
-               rec->pathlen,
-               STR(rec->path),
-               rec->pathlen,
-               rec->targetlen,
-               STR(rec->target),
-               rec->targetlen,
-               rec->old_targetlen,
-               STR(rec->old_target),
-               rec->old_targetlen,
-               
-               rec->valid, 
-               rec->mode,
-               rec->uid,
-               rec->gid,
-               rec->size,
-               mtime,
-               ctime,
-               rec->rdev, rec->major, rec->minor,
-               nov, oov, ntv, otv, npv, opv);
-               
-       free(nov);
-       free(oov);
-       free(ntv);
-       free(otv);
-       free(npv);
-       free(opv);
-
-       free(rectime); 
-       free(ctime);
-       free(mtime);
-
-       return str;
-}
-#endif
diff --git a/fs/intermezzo/kml_utils.c b/fs/intermezzo/kml_utils.c
deleted file mode 100644 (file)
index 5062e2d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <linux/list.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_kml.h"
-
-
-// dlogit -- oppsite to logit ()
-//         return the sbuf + size;
-char *dlogit (void *tbuf, const void *sbuf, int size)
-{
-        char *ptr = (char *)sbuf;
-        memcpy(tbuf, ptr, size);
-        ptr += size;
-        return ptr;
-}
-
-static spinlock_t kml_lock = SPIN_LOCK_UNLOCKED;
-static char  buf[1024];
-char * bdup_printf (char *format, ...)
-{
-        va_list args;
-        int  i;
-        char *path;
-        unsigned long flags;
-
-        spin_lock_irqsave(&kml_lock, flags);
-        va_start(args, format);
-        i = vsprintf(buf, format, args); /* hopefully i < sizeof(buf) */
-        va_end(args);
-
-        PRESTO_ALLOC (path, char *, i + 1);
-        if (path == NULL)
-                return NULL;
-        strcpy (path, buf);
-
-        spin_unlock_irqrestore(&kml_lock, flags);
-        return path;
-}
-
-
diff --git a/fs/intermezzo/methods.c b/fs/intermezzo/methods.c
deleted file mode 100644 (file)
index 8950efc..0000000
+++ /dev/null
@@ -1,493 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2000 Stelias Computing, Inc.
- *  Copyright (C) 2000 Red Hat, Inc.
- *  Copyright (C) 2000 Mountain View Data, Inc.
- *
- *  Extended Attribute Support
- *  Copyright (C) 2001 Shirish H. Phatak, Tacit Networks, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include <linux/fsfilter.h>
-#include "intermezzo_fs.h"
-
-
-int filter_print_entry = 0;
-int filter_debug = 0xfffffff;
-/*
- * The function in this file are responsible for setting up the 
- * correct methods layered file systems like InterMezzo and snapfs
- */
-
-
-static struct filter_fs filter_oppar[FILTER_FS_TYPES];
-
-/* get to the upper methods (intermezzo, snapfs) */
-inline struct super_operations *filter_c2usops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_sops;
-}
-
-inline struct inode_operations *filter_c2udiops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_dir_iops;
-}
-
-
-inline struct inode_operations *filter_c2ufiops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_file_iops;
-}
-
-inline struct inode_operations *filter_c2usiops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_sym_iops;
-}
-
-
-inline struct file_operations *filter_c2udfops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_dir_fops;
-}
-
-inline struct file_operations *filter_c2uffops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_file_fops;
-}
-
-inline struct file_operations *filter_c2usfops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_sym_fops;
-}
-
-inline struct dentry_operations *filter_c2udops(struct filter_fs *cache)
-{
-        return &cache->o_fops.filter_dentry_ops;
-}
-
-/* get to the cache (lower) methods */
-inline struct super_operations *filter_c2csops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_sops;
-}
-
-inline struct inode_operations *filter_c2cdiops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_dir_iops;
-}
-
-inline struct inode_operations *filter_c2cfiops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_file_iops;
-}
-
-inline struct inode_operations *filter_c2csiops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_sym_iops;
-}
-
-inline struct file_operations *filter_c2cdfops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_dir_fops;
-}
-
-inline struct file_operations *filter_c2cffops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_file_fops;
-}
-
-inline struct file_operations *filter_c2csfops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_sym_fops;
-}
-
-inline struct dentry_operations *filter_c2cdops(struct filter_fs *cache)
-{
-        return cache->o_caops.cache_dentry_ops;
-}
-
-
-void filter_setup_journal_ops(struct filter_fs *ops, char *cache_type)
-{
-        if ( strlen(cache_type) == strlen("ext2") &&
-             memcmp(cache_type, "ext2", strlen("ext2")) == 0 ) {
-#ifdef CONFIG_EXT2_FS
-                ops->o_trops = &presto_ext2_journal_ops;
-#else
-                ops->o_trops = NULL;
-#endif
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("ext3") &&
-             memcmp(cache_type, "ext3", strlen("ext3")) == 0 ) {
-#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE)
-                ops->o_trops = &presto_ext3_journal_ops;
-#else
-                ops->o_trops = NULL;
-#endif
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("tmpfs") &&
-             memcmp(cache_type, "tmpfs", strlen("tmpfs")) == 0 ) {
-#if defined(CONFIG_TMPFS)
-                ops->o_trops = &presto_tmpfs_journal_ops;
-#else
-                ops->o_trops = NULL;
-#endif
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("reiserfs") &&
-             memcmp(cache_type, "reiserfs", strlen("reiserfs")) == 0 ) {
-#if 0
-               /* #if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE) */
-                ops->o_trops = &presto_reiserfs_journal_ops;
-#else
-                ops->o_trops = NULL;
-#endif
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("xfs") &&
-             memcmp(cache_type, "xfs", strlen("xfs")) == 0 ) {
-#if 0
-/*#if defined(CONFIG_XFS_FS) || defined (CONFIG_XFS_FS_MODULE) */
-                ops->o_trops = &presto_xfs_journal_ops;
-#else
-                ops->o_trops = NULL;
-#endif
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("obdfs") &&
-             memcmp(cache_type, "obdfs", strlen("obdfs")) == 0 ) {
-#if defined(CONFIG_OBDFS_FS) || defined (CONFIG_OBDFS_FS_MODULE)
-                ops->o_trops = presto_obdfs_journal_ops;
-#else
-                ops->o_trops = NULL;
-#endif
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-}
-
-
-/* find the cache for this FS */
-struct filter_fs *filter_get_filter_fs(const char *cache_type)
-{
-        struct filter_fs *ops = NULL;
-        FENTRY;
-
-        if ( strlen(cache_type) == strlen("ext2") &&
-             memcmp(cache_type, "ext2", strlen("ext2")) == 0 ) {
-                ops = &filter_oppar[FILTER_FS_EXT2];
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("xfs") &&
-             memcmp(cache_type, "xfs", strlen("xfs")) == 0 ) {
-                ops = &filter_oppar[FILTER_FS_XFS];
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("ext3") &&
-             memcmp(cache_type, "ext3", strlen("ext3")) == 0 ) {
-                ops = &filter_oppar[FILTER_FS_EXT3];
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("tmpfs") &&
-             memcmp(cache_type, "tmpfs", strlen("tmpfs")) == 0 ) {
-                ops = &filter_oppar[FILTER_FS_TMPFS];
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if ( strlen(cache_type) == strlen("reiserfs") &&
-             memcmp(cache_type, "reiserfs", strlen("reiserfs")) == 0 ) {
-                ops = &filter_oppar[FILTER_FS_REISERFS];
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-        if ( strlen(cache_type) == strlen("obdfs") &&
-             memcmp(cache_type, "obdfs", strlen("obdfs")) == 0 ) {
-                ops = &filter_oppar[FILTER_FS_OBDFS];
-                FDEBUG(D_SUPER, "ops at %p\n", ops);
-        }
-
-        if (ops == NULL) {
-                CERROR("prepare to die: unrecognized cache type for Filter\n");
-        }
-        FEXIT;
-        return ops;
-}
-
-
-/*
- *  Frobnicate the InterMezzo operations
- *    this establishes the link between the InterMezzo file system
- *    and the underlying file system used for the cache.
- */
-
-void filter_setup_super_ops(struct filter_fs *cache, struct super_operations *cache_sops, struct super_operations *filter_sops)
-{
-        /* Get ptr to the shared struct snapfs_ops structure. */
-        struct filter_ops *props = &cache->o_fops;
-        /* Get ptr to the shared struct cache_ops structure. */
-        struct cache_ops *caops = &cache->o_caops;
-
-        FENTRY;
-
-        if ( cache->o_flags & FILTER_DID_SUPER_OPS ) {
-                FEXIT;
-                return;
-        }
-        cache->o_flags |= FILTER_DID_SUPER_OPS;
-
-        /* Set the cache superblock operations to point to the
-           superblock operations of the underlying file system.  */
-        caops->cache_sops = cache_sops;
-
-        /*
-         * Copy the cache (real fs) superblock ops to the "filter"
-         * superblock ops as defaults. Some will be changed below
-         */
-        memcpy(&props->filter_sops, cache_sops, sizeof(*cache_sops));
-
-        /* 'put_super' unconditionally is that of filter */
-        if (filter_sops->put_super) { 
-                props->filter_sops.put_super = filter_sops->put_super;
-        }
-
-        if (cache_sops->read_inode) {
-                props->filter_sops.read_inode = filter_sops->read_inode;
-                FDEBUG(D_INODE, "setting filter_read_inode, cache_ops %p, cache %p, ri at %p\n",
-                      cache, cache, props->filter_sops.read_inode);
-        }
-
-        if (cache_sops->remount_fs)
-                props->filter_sops.remount_fs = filter_sops->remount_fs;
-        FEXIT;
-}
-
-
-void filter_setup_dir_ops(struct filter_fs *cache, struct inode *inode, struct inode_operations *filter_iops, struct file_operations *filter_fops)
-{
-        struct inode_operations *cache_filter_iops;
-        struct inode_operations *cache_iops = inode->i_op;
-        struct file_operations *cache_fops = inode->i_fop;
-        FENTRY;
-
-        if ( cache->o_flags & FILTER_DID_DIR_OPS ) {
-                FEXIT;
-                return;
-        }
-        cache->o_flags |= FILTER_DID_DIR_OPS;
-
-        /* former ops become cache_ops */
-        cache->o_caops.cache_dir_iops = cache_iops;
-        cache->o_caops.cache_dir_fops = cache_fops;
-        FDEBUG(D_SUPER, "filter at %p, cache iops %p, iops %p\n",
-               cache, cache_iops, filter_c2udiops(cache));
-
-        /* setup our dir iops: copy and modify */
-        memcpy(filter_c2udiops(cache), cache_iops, sizeof(*cache_iops));
-
-        /* abbreviate */
-        cache_filter_iops = filter_c2udiops(cache);
-
-        /* methods that filter if cache filesystem has these ops */
-        if (cache_iops->lookup && filter_iops->lookup)
-                cache_filter_iops->lookup = filter_iops->lookup;
-        if (cache_iops->create && filter_iops->create)
-                cache_filter_iops->create = filter_iops->create;
-        if (cache_iops->link && filter_iops->link)
-                cache_filter_iops->link = filter_iops->link;
-        if (cache_iops->unlink && filter_iops->unlink)
-                cache_filter_iops->unlink = filter_iops->unlink;
-        if (cache_iops->mkdir && filter_iops->mkdir)
-                cache_filter_iops->mkdir = filter_iops->mkdir;
-        if (cache_iops->rmdir && filter_iops->rmdir)
-                cache_filter_iops->rmdir = filter_iops->rmdir;
-        if (cache_iops->symlink && filter_iops->symlink)
-                cache_filter_iops->symlink = filter_iops->symlink;
-        if (cache_iops->rename && filter_iops->rename)
-                cache_filter_iops->rename = filter_iops->rename;
-        if (cache_iops->mknod && filter_iops->mknod)
-                cache_filter_iops->mknod = filter_iops->mknod;
-        if (cache_iops->permission && filter_iops->permission)
-                cache_filter_iops->permission = filter_iops->permission;
-        if (cache_iops->getattr)
-                cache_filter_iops->getattr = filter_iops->getattr;
-        /* Some filesystems do not use a setattr method of their own
-           instead relying on inode_setattr/write_inode. We still need to
-           journal these so we make setattr an unconditional operation. 
-           XXX: we should probably check for write_inode. SHP
-        */
-        /*if (cache_iops->setattr)*/
-                cache_filter_iops->setattr = filter_iops->setattr;
-#ifdef CONFIG_FS_EXT_ATTR
-       /* For now we assume that posix acls are handled through extended
-       * attributes. If this is not the case, we must explicitly trap 
-       * posix_set_acl. SHP
-       */
-       if (cache_iops->set_ext_attr && filter_iops->set_ext_attr)
-               cache_filter_iops->set_ext_attr = filter_iops->set_ext_attr;
-#endif
-
-
-        /* copy dir fops */
-        memcpy(filter_c2udfops(cache), cache_fops, sizeof(*cache_fops));
-
-        /* unconditional filtering operations */
-        filter_c2udfops(cache)->ioctl = filter_fops->ioctl;
-
-        FEXIT;
-}
-
-
-void filter_setup_file_ops(struct filter_fs *cache, struct inode *inode, struct inode_operations *filter_iops, struct file_operations *filter_fops)
-{
-        struct inode_operations *pr_iops;
-        struct inode_operations *cache_iops = inode->i_op;
-        struct file_operations *cache_fops = inode->i_fop;
-        FENTRY;
-
-        if ( cache->o_flags & FILTER_DID_FILE_OPS ) {
-                FEXIT;
-                return;
-        }
-        cache->o_flags |= FILTER_DID_FILE_OPS;
-
-        /* steal the old ops */
-        /* former ops become cache_ops */
-        cache->o_caops.cache_file_iops = cache_iops;
-        cache->o_caops.cache_file_fops = cache_fops;
-        
-        /* abbreviate */
-        pr_iops = filter_c2ufiops(cache); 
-
-        /* setup our dir iops: copy and modify */
-        memcpy(pr_iops, cache_iops, sizeof(*cache_iops));
-
-        /* copy dir fops */
-        CERROR("*** cache file ops at %p\n", cache_fops);
-        memcpy(filter_c2uffops(cache), cache_fops, sizeof(*cache_fops));
-
-        /* assign */
-        /* See comments above in filter_setup_dir_ops. SHP */
-        /*if (cache_iops->setattr)*/
-                pr_iops->setattr = filter_iops->setattr;
-        if (cache_iops->getattr)
-                pr_iops->getattr = filter_iops->getattr;
-        /* XXX Should this be conditional rmr ? */
-        pr_iops->permission = filter_iops->permission;
-#ifdef CONFIG_FS_EXT_ATTR
-       /* For now we assume that posix acls are handled through extended
-       * attributes. If this is not the case, we must explicitly trap and 
-       * posix_set_acl
-       */
-       if (cache_iops->set_ext_attr && filter_iops->set_ext_attr)
-               pr_iops->set_ext_attr = filter_iops->set_ext_attr;
-#endif
-
-
-        /* unconditional filtering operations */
-        filter_c2uffops(cache)->open = filter_fops->open;
-        filter_c2uffops(cache)->release = filter_fops->release;
-        filter_c2uffops(cache)->write = filter_fops->write;
-        filter_c2uffops(cache)->ioctl = filter_fops->ioctl;
-
-        FEXIT;
-}
-
-/* XXX in 2.3 there are "fast" and "slow" symlink ops for ext2 XXX */
-void filter_setup_symlink_ops(struct filter_fs *cache, struct inode *inode, struct inode_operations *filter_iops, struct file_operations *filter_fops)
-{
-        struct inode_operations *pr_iops;
-        struct inode_operations *cache_iops = inode->i_op;
-        struct file_operations *cache_fops = inode->i_fop;
-        FENTRY;
-
-        if ( cache->o_flags & FILTER_DID_SYMLINK_OPS ) {
-                FEXIT;
-                return;
-        }
-        cache->o_flags |= FILTER_DID_SYMLINK_OPS;
-
-        /* steal the old ops */
-        cache->o_caops.cache_sym_iops = cache_iops;
-        cache->o_caops.cache_sym_fops = cache_fops;
-
-        /* abbreviate */
-        pr_iops = filter_c2usiops(cache); 
-
-        /* setup our dir iops: copy and modify */
-        memcpy(pr_iops, cache_iops, sizeof(*cache_iops));
-
-        /* See comments above in filter_setup_dir_ops. SHP */
-        /* if (cache_iops->setattr) */
-                pr_iops->setattr = filter_iops->setattr;
-        if (cache_iops->getattr)
-                pr_iops->getattr = filter_iops->getattr;
-
-        /* assign */
-        /* copy fops - careful for symlinks they might be NULL */
-        if ( cache_fops ) { 
-                memcpy(filter_c2usfops(cache), cache_fops, sizeof(*cache_fops));
-        }
-
-        FEXIT;
-}
-
-void filter_setup_dentry_ops(struct filter_fs *cache,
-                             struct dentry_operations *cache_dop,
-                             struct dentry_operations *filter_dop)
-{
-        if ( cache->o_flags & FILTER_DID_DENTRY_OPS ) {
-                FEXIT;
-                return;
-        }
-        cache->o_flags |= FILTER_DID_DENTRY_OPS;
-
-        cache->o_caops.cache_dentry_ops = cache_dop;
-        memcpy(&cache->o_fops.filter_dentry_ops,
-               filter_dop, sizeof(*filter_dop));
-        
-        if (cache_dop &&  cache_dop != filter_dop && cache_dop->d_revalidate){
-                CERROR("WARNING: filter overriding revalidation!\n");
-        }
-        return;
-}
diff --git a/fs/intermezzo/presto.c b/fs/intermezzo/presto.c
deleted file mode 100644 (file)
index bf16031..0000000
+++ /dev/null
@@ -1,736 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Author: Peter J. Braam <braam@clusterfs.com>
- *  Copyright (C) 1998 Stelias Computing Inc
- *  Copyright (C) 1999 Red Hat Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * This file implements basic routines supporting the semantics
- */
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-int presto_walk(const char *name, struct nameidata *nd)
-{
-        int err;
-        /* we do not follow symlinks to support symlink operations 
-           correctly. The vfs should always hand us resolved dentries
-           so we should not be required to use LOOKUP_FOLLOW. At the
-           reintegrating end, lento again should be working with the 
-           resolved pathname and not the symlink. SHP
-           XXX: This code implies that direct symlinks do not work. SHP
-        */
-        unsigned int flags = 0; //LOOKUP_POSITIVE;
-
-        ENTRY;
-        err = path_lookup(name, flags, nd);
-        return err;
-}
-
-
-/* find the presto minor device for this inode */
-int presto_i2m(struct inode *inode)
-{
-        struct presto_cache *cache;
-        ENTRY;
-        cache = presto_get_cache(inode);
-        CDEBUG(D_PSDEV, "\n");
-        if ( !cache ) {
-                CERROR("PRESTO: BAD: cannot find cache for dev %s, ino %ld\n",
-                       inode->i_sb->s_id, inode->i_ino);
-                EXIT;
-                return -1;
-        }
-        EXIT;
-        return cache->cache_psdev->uc_minor;
-}
-
-inline int presto_f2m(struct presto_file_set *fset)
-{
-        return fset->fset_cache->cache_psdev->uc_minor;
-
-}
-
-inline int presto_c2m(struct presto_cache *cache)
-{
-        return cache->cache_psdev->uc_minor;
-
-}
-
-/* XXX check this out */
-struct presto_file_set *presto_path2fileset(const char *name)
-{
-        struct nameidata nd;
-        struct presto_file_set *fileset;
-        int error;
-        ENTRY;
-
-        error = presto_walk(name, &nd);
-        if (!error) { 
-#if 0
-                error = do_revalidate(nd.dentry);
-#endif
-                if (!error) 
-                        fileset = presto_fset(nd.dentry); 
-                path_release(&nd); 
-                EXIT;
-        } else 
-                fileset = ERR_PTR(error);
-
-        EXIT;
-        return fileset;
-}
-
-/* check a flag on this dentry or fset root.  Semantics:
-   - most flags: test if it is set
-   - PRESTO_ATTR, PRESTO_DATA return 1 if PRESTO_FSETINSYNC is set
-*/
-int presto_chk(struct dentry *dentry, int flag)
-{
-        int minor;
-        struct presto_file_set *fset = presto_fset(dentry);
-
-        ENTRY;
-        minor = presto_i2m(dentry->d_inode);
-        if ( izo_channels[minor].uc_no_filter ) {
-                EXIT;
-                return ~0;
-        }
-
-        /* if the fileset is in sync DATA and ATTR are OK */
-        if ( fset &&
-             (flag == PRESTO_ATTR || flag == PRESTO_DATA) &&
-             (fset->fset_flags & FSET_INSYNC) ) {
-                CDEBUG(D_INODE, "fset in sync (ino %ld)!\n",
-                       fset->fset_dentry->d_inode->i_ino);
-                EXIT;
-                return 1;
-        }
-
-        EXIT;
-        return (presto_d2d(dentry)->dd_flags & flag);
-}
-
-/* set a bit in the dentry flags */
-void presto_set(struct dentry *dentry, int flag)
-{
-        ENTRY;
-        if ( dentry->d_inode ) {
-                CDEBUG(D_INODE, "SET ino %ld, flag %x\n",
-                       dentry->d_inode->i_ino, flag);
-        }
-        if ( presto_d2d(dentry) == NULL) {
-                CERROR("dentry without d_fsdata in presto_set: %p: %*s", dentry,
-                                dentry->d_name.len, dentry->d_name.name);
-                BUG();
-        }
-        presto_d2d(dentry)->dd_flags |= flag;
-        EXIT;
-}
-
-/* given a path: complete the closes on the fset */
-int lento_complete_closes(char *path)
-{
-        struct nameidata nd;
-        struct dentry *dentry;
-        int error;
-        struct presto_file_set *fset;
-        ENTRY;
-
-        error = presto_walk(path, &nd);
-        if (error) {
-                EXIT;
-                return error;
-        }
-
-        dentry = nd.dentry;
-
-        error = -ENXIO;
-        if ( !presto_ispresto(dentry->d_inode) ) {
-                EXIT;
-                goto out_complete;
-        }
-        
-        fset = presto_fset(dentry);
-        error = -EINVAL;
-        if ( !fset ) {
-                CERROR("No fileset!\n");
-                EXIT;
-                goto out_complete;
-        }
-        
-        /* transactions and locking are internal to this function */ 
-        error = presto_complete_lml(fset);
-        
-        EXIT;
- out_complete:
-        path_release(&nd); 
-        return error;
-}       
-
-#if 0
-/* given a path: write a close record and cancel an LML record, finally
-   call truncate LML.  Lento is doing this so it goes in with uid/gid's 
-   root. 
-*/ 
-int lento_cancel_lml(char *path, 
-                     __u64 lml_offset, 
-                     __u64 remote_ino, 
-                     __u32 remote_generation,
-                     __u32 remote_version, 
-                     struct lento_vfs_context *info)
-{
-        struct nameidata nd;
-        struct rec_info rec;
-        struct dentry *dentry;
-        int error;
-        struct presto_file_set *fset;
-        void *handle; 
-        struct presto_version new_ver;
-        ENTRY;
-
-
-        error = presto_walk(path, &nd);
-        if (error) {
-                EXIT;
-                return error;
-        }
-        dentry = nd.dentry;
-
-        error = -ENXIO;
-        if ( !presto_ispresto(dentry->d_inode) ) {
-                EXIT;
-                goto out_cancel_lml;
-        }
-        
-        fset = presto_fset(dentry);
-
-        error=-EINVAL;
-        if (fset==NULL) {
-                CERROR("No fileset!\n");
-                EXIT;
-                goto out_cancel_lml;
-        }
-        
-        /* this only requires a transaction below which is automatic */
-        handle = presto_trans_start(fset, dentry->d_inode, PRESTO_OP_RELEASE); 
-        if ( IS_ERR(handle) ) {
-                error = -ENOMEM; 
-                EXIT; 
-                goto out_cancel_lml; 
-        } 
-        
-        if (info->flags & LENTO_FL_CANCEL_LML) {
-                error = presto_clear_lml_close(fset, lml_offset);
-                if ( error ) {
-                        presto_trans_commit(fset, handle);
-                        EXIT; 
-                        goto out_cancel_lml;
-                }
-        }
-
-
-        if (info->flags & LENTO_FL_WRITE_KML) {
-                presto_getversion(&new_ver, dentry->d_inode);
-                error = presto_journal_close(&rec, fset, NULL, dentry,
-                                             &new_ver);
-                if ( error ) {
-                        EXIT; 
-                        presto_trans_commit(fset, handle);
-                        goto out_cancel_lml;
-                }
-        }
-
-        if (info->flags & LENTO_FL_WRITE_EXPECT) {
-                error = presto_write_last_rcvd(&rec, fset, info); 
-                if ( error < 0 ) {
-                        EXIT; 
-                        presto_trans_commit(fset, handle);
-                        goto out_cancel_lml;
-                }
-        }
-
-        presto_trans_commit(fset, handle);
-
-        if (info->flags & LENTO_FL_CANCEL_LML) {
-            presto_truncate_lml(fset); 
-        }
-                
-
- out_cancel_lml:
-        EXIT;
-        path_release(&nd); 
-        return error;
-}       
-#endif 
-
-/* given a dentry, operate on the flags in its dentry.  Used by downcalls */
-int izo_mark_dentry(struct dentry *dentry, int and_flag, int or_flag, 
-                       int *res)
-{
-        int error = 0;
-
-        if (presto_d2d(dentry) == NULL) {
-                CERROR("InterMezzo: no ddata for inode %ld in %s\n",
-                       dentry->d_inode->i_ino, __FUNCTION__);
-                return -EINVAL;
-        }
-
-        CDEBUG(D_INODE, "inode: %ld, and flag %x, or flag %x, dd_flags %x\n",
-               dentry->d_inode->i_ino, and_flag, or_flag,
-               presto_d2d(dentry)->dd_flags);
-
-        presto_d2d(dentry)->dd_flags &= and_flag;
-        presto_d2d(dentry)->dd_flags |= or_flag;
-        if (res) 
-                *res = presto_d2d(dentry)->dd_flags;
-
-        return error;
-}
-
-/* given a path, operate on the flags in its cache.  Used by mark_ioctl */
-int izo_mark_cache(struct dentry *dentry, int and_flag, int or_flag, 
-                   int *res)
-{
-        struct presto_cache *cache;
-
-        if (presto_d2d(dentry) == NULL) {
-                CERROR("InterMezzo: no ddata for inode %ld in %s\n",
-                       dentry->d_inode->i_ino, __FUNCTION__);
-                return -EINVAL;
-        }
-
-        CDEBUG(D_INODE, "inode: %ld, and flag %x, or flag %x, dd_flags %x\n",
-               dentry->d_inode->i_ino, and_flag, or_flag,
-               presto_d2d(dentry)->dd_flags);
-
-        cache = presto_get_cache(dentry->d_inode);
-        if ( !cache ) {
-                CERROR("PRESTO: BAD: cannot find cache in izo_mark_cache\n");
-                return -EBADF;
-        }
-
-        cache->cache_flags &= and_flag;
-        cache->cache_flags |= or_flag;
-        if (res)
-                *res = (int)cache->cache_flags;
-
-        return 0;
-}
-
-int presto_set_max_kml_size(const char *path, unsigned long max_size)
-{
-        struct presto_file_set *fset;
-
-        ENTRY;
-
-        fset = presto_path2fileset(path);
-        if (IS_ERR(fset)) {
-                EXIT;
-                return PTR_ERR(fset);
-        }
-
-        fset->kml_truncate_size = max_size;
-        CDEBUG(D_CACHE, "KML truncate size set to %lu bytes for fset %s.\n",
-               max_size, path);
-
-        EXIT;
-        return 0;
-}
-
-int izo_mark_fset(struct dentry *dentry, int and_flag, int or_flag, 
-                  int * res)
-{
-        struct presto_file_set *fset;
-        
-        fset = presto_fset(dentry);
-        if ( !fset ) {
-                CERROR("PRESTO: BAD: cannot find cache in izo_mark_cache\n");
-                make_bad_inode(dentry->d_inode);
-                return -EBADF;
-        }
-        fset->fset_flags &= and_flag;
-        fset->fset_flags |= or_flag;
-        if (res)
-                *res = (int)fset->fset_flags;
-
-        return 0;
-}
-
-/* talk to Lento about the permit */
-static int presto_permit_upcall(struct dentry *dentry)
-{
-        int rc;
-        char *path, *buffer;
-        int pathlen;
-        int minor;
-        int fsetnamelen;
-        struct presto_file_set *fset = NULL;
-
-        ENTRY;
-
-        if ( (minor = presto_i2m(dentry->d_inode)) < 0) {
-                EXIT;
-                return -EINVAL;
-        }
-
-        fset = presto_fset(dentry);
-        if (!fset) {
-                EXIT;
-                return -ENOTCONN;
-        }
-        
-        if ( !presto_lento_up(minor) ) {
-                if ( fset->fset_flags & FSET_STEAL_PERMIT ) {
-                        EXIT;
-                        return 0;
-                } else {
-                        EXIT;
-                        return -ENOTCONN;
-                }
-        }
-
-        PRESTO_ALLOC(buffer, PAGE_SIZE);
-        if ( !buffer ) {
-                CERROR("PRESTO: out of memory!\n");
-                EXIT;
-                return -ENOMEM;
-        }
-        path = presto_path(dentry, fset->fset_dentry, buffer, PAGE_SIZE);
-        pathlen = MYPATHLEN(buffer, path);
-        fsetnamelen = strlen(fset->fset_name); 
-        rc = izo_upc_permit(minor, dentry, pathlen, path, fset->fset_name);
-        PRESTO_FREE(buffer, PAGE_SIZE);
-        EXIT;
-        return rc;
-}
-
-/* get a write permit for the fileset of this inode
- *  - if this returns a negative value there was an error
- *  - if 0 is returned the permit was already in the kernel -- or --
- *    Lento gave us the permit without reintegration
- *  - lento returns the number of records it reintegrated 
- *
- * Note that if this fileset has branches, a permit will -never- to a normal
- * process for writing in the data area (ie, outside of .intermezzo)
- */
-int presto_get_permit(struct inode * inode)
-{
-        struct dentry *de;
-        struct presto_file_set *fset;
-        int minor = presto_i2m(inode);
-        int rc = 0;
-
-        ENTRY;
-        if (minor < 0) {
-                EXIT;
-                return -1;
-        }
-
-        if ( ISLENTO(minor) ) {
-                EXIT;
-                return 0;
-        }
-
-        if (list_empty(&inode->i_dentry)) {
-                CERROR("No alias for inode %d\n", (int) inode->i_ino);
-                EXIT;
-                return -EINVAL;
-        }
-
-        de = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-
-        if (presto_chk(de, PRESTO_DONT_JOURNAL)) {
-                EXIT;
-                return 0;
-        }
-
-        fset = presto_fset(de);
-        if ( !fset ) {
-                CERROR("Presto: no fileset in presto_get_permit!\n");
-                EXIT;
-                return -EINVAL;
-        }
-
-        if (fset->fset_flags & FSET_HAS_BRANCHES) {
-                EXIT;
-                return -EROFS;
-        }
-
-        spin_lock(&fset->fset_permit_lock);
-        if (fset->fset_flags & FSET_HASPERMIT) {
-                fset->fset_permit_count++;
-                CDEBUG(D_INODE, "permit count now %d, inode %lx\n", 
-                       fset->fset_permit_count, inode->i_ino);
-                spin_unlock(&fset->fset_permit_lock);
-                EXIT;
-                return 0;
-        }
-
-        /* Allow reintegration to proceed without locks -SHP */
-        fset->fset_permit_upcall_count++;
-        if (fset->fset_permit_upcall_count == 1) {
-                spin_unlock(&fset->fset_permit_lock);
-                rc = presto_permit_upcall(fset->fset_dentry);
-                spin_lock(&fset->fset_permit_lock);
-                fset->fset_permit_upcall_count--;
-                if (rc == 0) {
-                        izo_mark_fset(fset->fset_dentry, ~0, FSET_HASPERMIT,
-                                      NULL);
-                        fset->fset_permit_count++;
-                } else if (rc == ENOTCONN) {
-                        CERROR("InterMezzo: disconnected operation. stealing permit.\n");
-                        izo_mark_fset(fset->fset_dentry, ~0, FSET_HASPERMIT,
-                                      NULL);
-                        fset->fset_permit_count++;
-                        /* set a disconnected flag here to stop upcalls */
-                        rc = 0;
-                } else {
-                        CERROR("InterMezzo: presto_permit_upcall failed: %d\n", rc);
-                        rc = -EROFS;
-                        /* go to sleep here and try again? */
-                }
-                wake_up_interruptible(&fset->fset_permit_queue);
-        } else {
-                /* Someone is already doing an upcall; go to sleep. */
-                DECLARE_WAITQUEUE(wait, current);
-
-                spin_unlock(&fset->fset_permit_lock);
-                add_wait_queue(&fset->fset_permit_queue, &wait);
-                while (1) {
-                        set_current_state(TASK_INTERRUPTIBLE);
-
-                        spin_lock(&fset->fset_permit_lock);
-                        if (fset->fset_permit_upcall_count == 0)
-                                break;
-                        spin_unlock(&fset->fset_permit_lock);
-
-                        if (signal_pending(current)) {
-                                remove_wait_queue(&fset->fset_permit_queue,
-                                                  &wait);
-                                return -ERESTARTSYS;
-                        }
-                        schedule();
-                }
-                remove_wait_queue(&fset->fset_permit_queue, &wait);
-                /* We've been woken up: do we have the permit? */
-                if (fset->fset_flags & FSET_HASPERMIT)
-                        /* FIXME: Is this the right thing? */
-                        rc = -EAGAIN;
-        }
-
-        CDEBUG(D_INODE, "permit count now %d, ino %ld (likely 1), "
-               "rc %d\n", fset->fset_permit_count, inode->i_ino, rc);
-        spin_unlock(&fset->fset_permit_lock);
-        EXIT;
-        return rc;
-}
-
-int presto_put_permit(struct inode * inode)
-{
-        struct dentry *de;
-        struct presto_file_set *fset;
-        int minor = presto_i2m(inode);
-
-        ENTRY;
-        if (minor < 0) {
-                EXIT;
-                return -1;
-        }
-
-        if ( ISLENTO(minor) ) {
-                EXIT;
-                return 0;
-        }
-
-        if (list_empty(&inode->i_dentry)) {
-                CERROR("No alias for inode %d\n", (int) inode->i_ino);
-                EXIT;
-                return -1;
-        }
-
-        de = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-
-        fset = presto_fset(de);
-        if ( !fset ) {
-                CERROR("InterMezzo: no fileset in %s!\n", __FUNCTION__);
-                EXIT;
-                return -1;
-        }
-
-        if (presto_chk(de, PRESTO_DONT_JOURNAL)) {
-                EXIT;
-                return 0;
-        }
-
-        spin_lock(&fset->fset_permit_lock);
-        if (fset->fset_flags & FSET_HASPERMIT) {
-                if (fset->fset_permit_count > 0)
-                        fset->fset_permit_count--;
-                else
-                        CERROR("Put permit while permit count is 0, "
-                               "inode %ld!\n", inode->i_ino); 
-        } else {
-                fset->fset_permit_count = 0;
-                CERROR("InterMezzo: put permit while no permit, inode %ld, "
-                       "flags %x!\n", inode->i_ino, fset->fset_flags);
-        }
-
-        CDEBUG(D_INODE, "permit count now %d, inode %ld\n",
-               fset->fset_permit_count, inode->i_ino);
-
-        if (fset->fset_flags & FSET_PERMIT_WAITING &&
-            fset->fset_permit_count == 0) {
-                CDEBUG(D_INODE, "permit count now 0, ino %ld, wake sleepers\n",
-                       inode->i_ino);
-                wake_up_interruptible(&fset->fset_permit_queue);
-        }
-        spin_unlock(&fset->fset_permit_lock);
-
-        EXIT;
-        return 0;
-}
-
-void presto_getversion(struct presto_version * presto_version,
-                       struct inode * inode)
-{
-        presto_version->pv_mtime_sec = inode->i_mtime.tv_sec;
-        presto_version->pv_mtime_nsec = inode->i_mtime.tv_nsec;
-        presto_version->pv_ctime_sec = inode->i_ctime.tv_sec;
-        presto_version->pv_ctime_nsec = inode->i_ctime.tv_nsec;
-        presto_version->pv_size  = (__u64)inode->i_size;
-}
-
-
-/* If uuid is non-null, it is the uuid of the peer that's making the revocation
- * request.  If it is null, this request was made locally, without external
- * pressure to give up the permit.  This most often occurs when a client
- * starts up.
- *
- * FIXME: this function needs to be refactored slightly once we start handling
- * multiple clients.
- */
-int izo_revoke_permit(struct dentry *dentry, __u8 uuid[16])
-{
-        struct presto_file_set *fset; 
-        DECLARE_WAITQUEUE(wait, current);
-        int minor, rc;
-
-        ENTRY;
-
-        minor = presto_i2m(dentry->d_inode);
-        if (minor < 0) {
-                EXIT;
-                return -ENODEV;
-        }
-
-        fset = presto_fset(dentry);
-        if (fset == NULL) {
-                EXIT;
-                return -ENODEV;
-        }
-
-        spin_lock(&fset->fset_permit_lock);
-        if (fset->fset_flags & FSET_PERMIT_WAITING) {
-                CERROR("InterMezzo: Two processes are waiting on the same permit--this not yet supported!  Aborting this particular permit request...\n");
-                EXIT;
-                spin_unlock(&fset->fset_permit_lock);
-                return -EINVAL;
-        }
-
-        if (fset->fset_permit_count == 0)
-                goto got_permit;
-
-        /* Something is still using this permit.  Mark that we're waiting for it
-         * and go to sleep. */
-        rc = izo_mark_fset(dentry, ~0, FSET_PERMIT_WAITING, NULL);
-        spin_unlock(&fset->fset_permit_lock);
-        if (rc < 0) {
-                EXIT;
-                return rc;
-        }
-
-        add_wait_queue(&fset->fset_permit_queue, &wait);
-        while (1) {
-                set_current_state(TASK_INTERRUPTIBLE);
-
-                spin_lock(&fset->fset_permit_lock);
-                if (fset->fset_permit_count == 0)
-                        break;
-                spin_unlock(&fset->fset_permit_lock);
-
-                if (signal_pending(current)) {
-                        /* FIXME: there must be a better thing to return... */
-                        remove_wait_queue(&fset->fset_permit_queue, &wait);
-                        EXIT;
-                        return -ERESTARTSYS;
-                }
-
-                /* FIXME: maybe there should be a timeout here. */
-
-                schedule();
-        }
-
-        remove_wait_queue(&fset->fset_permit_queue, &wait);
- got_permit:
-        /* By this point fset->fset_permit_count is zero and we're holding the
-         * lock. */
-        CDEBUG(D_CACHE, "InterMezzo: releasing permit inode %ld\n",
-               dentry->d_inode->i_ino);
-
-        if (uuid != NULL) {
-                rc = izo_upc_revoke_permit(minor, fset->fset_name, uuid);
-                if (rc < 0) {
-                        spin_unlock(&fset->fset_permit_lock);
-                        EXIT;
-                        return rc;
-                }
-        }
-
-        izo_mark_fset(fset->fset_dentry, ~FSET_PERMIT_WAITING, 0, NULL);
-        izo_mark_fset(fset->fset_dentry, ~FSET_HASPERMIT, 0, NULL);
-        spin_unlock(&fset->fset_permit_lock);
-        EXIT;
-        return 0;
-}
-
-inline int presto_is_read_only(struct presto_file_set * fset)
-{
-        int minor, mask;
-        struct presto_cache *cache = fset->fset_cache;
-
-        minor= cache->cache_psdev->uc_minor;
-        mask= (ISLENTO(minor)? FSET_LENTO_RO : FSET_CLIENT_RO);
-        if ( fset->fset_flags & mask )
-                return 1;
-        mask= (ISLENTO(minor)? CACHE_LENTO_RO : CACHE_CLIENT_RO);
-        return  ((cache->cache_flags & mask)? 1 : 0);
-}
diff --git a/fs/intermezzo/psdev.c b/fs/intermezzo/psdev.c
deleted file mode 100644 (file)
index 40a85cc..0000000
+++ /dev/null
@@ -1,647 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *              An implementation of a loadable kernel mode driver providing
- *              multiple kernel/user space bidirectional communications links.
- *
- *              Author:         Alan Cox <alan@cymru.net>
- *
- *              This program is free software; you can redistribute it and/or
- *              modify it under the terms of the GNU General Public License
- *              version 2 as published by the Free Software Foundation.
- *
- *              Adapted to become the Linux 2.0 Coda pseudo device
- *              Peter  Braam  <braam@maths.ox.ac.uk>
- *              Michael Callahan <mjc@emmy.smith.edu>
- *
- *              Changes for Linux 2.1
- *              Copyright (c) 1997 Carnegie-Mellon University
- *
- *              Redone again for InterMezzo
- *              Copyright (c) 1998 Peter J. Braam
- *              Copyright (c) 2000 Mountain View Data, Inc.
- *              Copyright (c) 2000 Tacitus Systems, Inc.
- *              Copyright (c) 2001 Cluster File Systems, Inc.
- *
- */
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/lp.h>
-#include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/skbuff.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/list.h>
-#include <linux/devfs_fs_kernel.h>
-#include <asm/io.h>
-#include <asm/segment.h>
-#include <asm/system.h>
-#include <asm/poll.h>
-#include <asm/uaccess.h>
-#include <linux/miscdevice.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-
-#ifdef PRESTO_DEVEL
-int  presto_print_entry = 1;
-int  presto_debug = 4095;
-#else
-int  presto_print_entry = 0;
-int  presto_debug = 0;
-#endif
-
-/* Like inode.c (presto_sym_iops), the initializer is just to prevent
-   izo_channels from appearing as a COMMON symbol (and therefore
-   interfering with other modules that use the same variable name). */
-struct upc_channel izo_channels[MAX_CHANNEL] = {{0}};
-
-int izo_psdev_get_free_channel(void)
-{
-        int i, result = -1;
-        
-        for (i = 0 ; i < MAX_CHANNEL ; i++ ) {
-                if (list_empty(&(izo_channels[i].uc_cache_list))) { 
-                    result = i;
-                    break;
-                }
-        }
-        return result;
-}
-
-
-int izo_psdev_setpid(int minor)
-{
-        struct upc_channel *channel; 
-        if (minor < 0 || minor >= MAX_CHANNEL) { 
-                return -EINVAL;
-        }
-
-        channel = &(izo_channels[minor]); 
-        /*
-         * This ioctl is performed by each Lento that starts up
-         * and wants to do further communication with presto.
-         */
-        CDEBUG(D_PSDEV, "Setting current pid to %d channel %d\n", 
-               current->pid, minor);
-        channel->uc_pid = current->pid;
-        spin_lock(&channel->uc_lock); 
-        if ( !list_empty(&channel->uc_processing) ) {
-                struct list_head *lh;
-                struct upc_req *req;
-                CERROR("WARNING: setpid & processing not empty!\n");
-               list_for_each(lh, &channel->uc_processing) {
-                        req = list_entry(lh, struct upc_req, rq_chain);
-                        /* freeing of req and data is done by the sleeper */
-                        wake_up(&req->rq_sleep);
-                }
-        }
-        if ( !list_empty(&channel->uc_processing) ) {
-                CERROR("BAD: FAILDED TO CLEAN PROCESSING LIST!\n");
-        }
-        spin_unlock(&channel->uc_lock); 
-        EXIT;
-        return 0;
-}
-
-int izo_psdev_setchannel(struct file *file, int fd)
-{
-
-        struct file *psdev_file = fget(fd); 
-        struct presto_cache *cache = presto_get_cache(file->f_dentry->d_inode);
-
-        if (!psdev_file) { 
-                CERROR("%s: no psdev_file!\n", __FUNCTION__);
-                return -EINVAL;
-        }
-
-        if (!cache) { 
-                CERROR("%s: no cache!\n", __FUNCTION__);
-                fput(psdev_file); 
-                return -EINVAL;
-        } 
-
-        if (psdev_file->private_data) { 
-                CERROR("%s: channel already set!\n", __FUNCTION__);
-                fput(psdev_file); 
-                return -EINVAL;
-        }
-
-        psdev_file->private_data = cache->cache_psdev;
-        fput(psdev_file); 
-        EXIT; 
-        return 0; 
-}
-
-inline int presto_lento_up(int minor) 
-{
-        return izo_channels[minor].uc_pid;
-}
-
-static unsigned int presto_psdev_poll(struct file *file, poll_table * wait)
- {
-        struct upc_channel *channel = (struct upc_channel *)file->private_data;
-        unsigned int mask = POLLOUT | POLLWRNORM;
-
-        /* ENTRY; this will flood you */
-        if ( ! channel ) { 
-                CERROR("%s: bad psdev file\n", __FUNCTION__);
-                return -EBADF;
-        }
-
-        poll_wait(file, &(channel->uc_waitq), wait);
-
-        spin_lock(&channel->uc_lock);
-        if (!list_empty(&channel->uc_pending)) {
-                CDEBUG(D_PSDEV, "Non-empty pending list.\n");
-                mask |= POLLIN | POLLRDNORM;
-        }
-        spin_unlock(&channel->uc_lock);
-
-        /* EXIT; will flood you */
-        return mask;
-}
-
-/*
- *      Receive a message written by Lento to the psdev
- */
-static ssize_t presto_psdev_write(struct file *file, const char *buf,
-                                  size_t count, loff_t *off)
-{
-        struct upc_channel *channel = (struct upc_channel *)file->private_data;
-        struct upc_req *req = NULL;
-        struct upc_req *tmp;
-        struct list_head *lh;
-        struct izo_upcall_resp hdr;
-        int error;
-
-        if ( ! channel ) { 
-                CERROR("%s: bad psdev file\n", __FUNCTION__);
-                return -EBADF;
-        }
-
-        /* Peek at the opcode, uniquefier */
-        if ( count < sizeof(hdr) ) {
-              CERROR("presto_psdev_write: Lento didn't write full hdr.\n");
-                return -EINVAL;
-        }
-
-        error = copy_from_user(&hdr, buf, sizeof(hdr));
-        if ( error )
-                return -EFAULT;
-
-        CDEBUG(D_PSDEV, "(process,opc,uniq)=(%d,%d,%d)\n",
-               current->pid, hdr.opcode, hdr.unique);
-
-        spin_lock(&channel->uc_lock); 
-        /* Look for the message on the processing queue. */
-       list_for_each(lh, &channel->uc_processing) {
-                tmp = list_entry(lh, struct upc_req , rq_chain);
-                if (tmp->rq_unique == hdr.unique) {
-                        req = tmp;
-                        /* unlink here: keeps search length minimal */
-                        list_del_init(&req->rq_chain);
-                        CDEBUG(D_PSDEV,"Eureka opc %d uniq %d!\n",
-                               hdr.opcode, hdr.unique);
-                        break;
-                }
-        }
-        spin_unlock(&channel->uc_lock); 
-        if (!req) {
-                CERROR("psdev_write: msg (%d, %d) not found\n",
-                       hdr.opcode, hdr.unique);
-                return(-ESRCH);
-        }
-
-        /* move data into response buffer. */
-        if (req->rq_bufsize < count) {
-                CERROR("psdev_write: too much cnt: %d, cnt: %Zd, "
-                       "opc: %d, uniq: %d.\n",
-                       req->rq_bufsize, count, hdr.opcode, hdr.unique);
-                count = req->rq_bufsize; /* don't have more space! */
-        }
-        error = copy_from_user(req->rq_data, buf, count);
-        if ( error )
-                return -EFAULT;
-
-        /* adjust outsize: good upcalls can be aware of this */
-        req->rq_rep_size = count;
-        req->rq_flags |= REQ_WRITE;
-
-        wake_up(&req->rq_sleep);
-        return(count);
-}
-
-/*
- *      Read a message from the kernel to Lento
- */
-static ssize_t presto_psdev_read(struct file * file, char * buf,
-                                 size_t count, loff_t *off)
-{
-        struct upc_channel *channel = (struct upc_channel *)file->private_data;
-        struct upc_req *req;
-        int result = count;
-
-        if ( ! channel ) { 
-                CERROR("%s: bad psdev file\n", __FUNCTION__);
-                return -EBADF;
-        }
-
-        spin_lock(&channel->uc_lock); 
-        if (list_empty(&(channel->uc_pending))) {
-                CDEBUG(D_UPCALL, "Empty pending list in read, not good\n");
-                spin_unlock(&channel->uc_lock); 
-                return -EINVAL;
-        }
-        req = list_entry((channel->uc_pending.next), struct upc_req, rq_chain);
-        list_del(&(req->rq_chain));
-        if (! (req->rq_flags & REQ_ASYNC) ) {
-                list_add(&(req->rq_chain), channel->uc_processing.prev);
-        }
-        spin_unlock(&channel->uc_lock); 
-
-        req->rq_flags |= REQ_READ;
-
-        /* Move the input args into userspace */
-        CDEBUG(D_PSDEV, "\n");
-        if (req->rq_bufsize <= count) {
-                result = req->rq_bufsize;
-        }
-
-        if (count < req->rq_bufsize) {
-                CERROR ("psdev_read: buffer too small, read %Zd of %d bytes\n",
-                        count, req->rq_bufsize);
-        }
-
-        if ( copy_to_user(buf, req->rq_data, result) ) {
-                BUG();
-                return -EFAULT;
-        }
-
-        /* If request was asynchronous don't enqueue, but free */
-        if (req->rq_flags & REQ_ASYNC) {
-                CDEBUG(D_PSDEV, "psdev_read: async msg (%d, %d), result %d\n",
-                       req->rq_opcode, req->rq_unique, result);
-                PRESTO_FREE(req->rq_data, req->rq_bufsize);
-                PRESTO_FREE(req, sizeof(*req));
-                return result;
-        }
-
-        return result;
-}
-
-
-static int presto_psdev_open(struct inode * inode, struct file * file)
-{
-        ENTRY;
-
-        file->private_data = NULL;  
-
-        CDEBUG(D_PSDEV, "Psdev_open: caller: %d, flags: %d\n", current->pid, file->f_flags);
-
-        EXIT;
-        return 0;
-}
-
-
-
-static int presto_psdev_release(struct inode * inode, struct file * file)
-{
-        struct upc_channel *channel = (struct upc_channel *)file->private_data;
-        struct upc_req *req;
-        struct list_head *lh;
-        ENTRY;
-
-        if ( ! channel ) { 
-                CERROR("%s: bad psdev file\n", __FUNCTION__);
-                return -EBADF;
-        }
-
-        CDEBUG(D_PSDEV, "Lento: pid %d\n", current->pid);
-        channel->uc_pid = 0;
-
-        /* Wake up clients so they can return. */
-        CDEBUG(D_PSDEV, "Wake up clients sleeping for pending.\n");
-        spin_lock(&channel->uc_lock); 
-       list_for_each(lh, &channel->uc_pending) {
-                req = list_entry(lh, struct upc_req, rq_chain);
-
-                /* Async requests stay around for a new lento */
-                if (req->rq_flags & REQ_ASYNC) {
-                        continue;
-                }
-                /* the sleeper will free the req and data */
-                req->rq_flags |= REQ_DEAD; 
-                wake_up(&req->rq_sleep);
-        }
-
-        CDEBUG(D_PSDEV, "Wake up clients sleeping for processing\n");
-       list_for_each(lh, &channel->uc_processing) {
-                req = list_entry(lh, struct upc_req, rq_chain);
-                /* freeing of req and data is done by the sleeper */
-                req->rq_flags |= REQ_DEAD; 
-                wake_up(&req->rq_sleep);
-        }
-        spin_unlock(&channel->uc_lock); 
-        CDEBUG(D_PSDEV, "Done.\n");
-
-        EXIT;
-        return 0;
-}
-
-static struct file_operations presto_psdev_fops = {
-       .owner   = THIS_MODULE,
-        .read    = presto_psdev_read,
-        .write   = presto_psdev_write,
-        .poll    = presto_psdev_poll,
-        .open    = presto_psdev_open,
-        .release = presto_psdev_release
-};
-
-/* modules setup */
-static struct miscdevice intermezzo_psdev = {
-        INTERMEZZO_MINOR,
-        "intermezzo",
-        &presto_psdev_fops
-};
-
-int  presto_psdev_init(void)
-{
-        int i;
-        int err; 
-
-        if ( (err = misc_register(&intermezzo_psdev)) ) { 
-                CERROR("%s: cannot register %d err %d\n", 
-                       __FUNCTION__, INTERMEZZO_MINOR, err);
-                return -EIO;
-        }
-
-        memset(&izo_channels, 0, sizeof(izo_channels));
-        for ( i = 0 ; i < MAX_CHANNEL ; i++ ) {
-                struct upc_channel *channel = &(izo_channels[i]);
-                INIT_LIST_HEAD(&channel->uc_pending);
-                INIT_LIST_HEAD(&channel->uc_processing);
-                INIT_LIST_HEAD(&channel->uc_cache_list);
-                init_waitqueue_head(&channel->uc_waitq);
-                channel->uc_lock = SPIN_LOCK_UNLOCKED;
-                channel->uc_hard = 0;
-                channel->uc_no_filter = 0;
-                channel->uc_no_journal = 0;
-                channel->uc_no_upcall = 0;
-                channel->uc_timeout = 30;
-                channel->uc_errorval = 0;
-                channel->uc_minor = i;
-        }
-        return 0;
-}
-
-void presto_psdev_cleanup(void)
-{
-        int i;
-
-        misc_deregister(&intermezzo_psdev);
-
-        for ( i = 0 ; i < MAX_CHANNEL ; i++ ) {
-                struct upc_channel *channel = &(izo_channels[i]);
-                struct list_head *lh, *next;
-
-                spin_lock(&channel->uc_lock); 
-                if ( ! list_empty(&channel->uc_pending)) { 
-                        CERROR("Weird, tell Peter: module cleanup and pending list not empty dev %d\n", i);
-                }
-                if ( ! list_empty(&channel->uc_processing)) { 
-                        CERROR("Weird, tell Peter: module cleanup and processing list not empty dev %d\n", i);
-                }
-                if ( ! list_empty(&channel->uc_cache_list)) { 
-                        CERROR("Weird, tell Peter: module cleanup and cache listnot empty dev %d\n", i);
-                }
-               list_for_each_safe(lh, next, &channel->uc_pending) {
-                        struct upc_req *req;
-
-                        req = list_entry(lh, struct upc_req, rq_chain);
-                        if ( req->rq_flags & REQ_ASYNC ) {
-                                list_del(&(req->rq_chain));
-                                CDEBUG(D_UPCALL, "free pending upcall type %d\n",
-                                       req->rq_opcode);
-                                PRESTO_FREE(req->rq_data, req->rq_bufsize);
-                                PRESTO_FREE(req, sizeof(struct upc_req));
-                        } else {
-                                req->rq_flags |= REQ_DEAD; 
-                                wake_up(&req->rq_sleep);
-                        }
-                }
-               list_for_each(lh, &channel->uc_processing) {
-                        struct upc_req *req;
-                        req = list_entry(lh, struct upc_req, rq_chain);
-                        list_del(&(req->rq_chain));
-                        req->rq_flags |= REQ_DEAD; 
-                        wake_up(&req->rq_sleep);
-                }
-                spin_unlock(&channel->uc_lock); 
-        }
-}
-
-/*
- * lento_upcall and lento_downcall routines
- */
-static inline unsigned long lento_waitfor_upcall
-            (struct upc_channel *channel, struct upc_req *req, int minor)
-{
-        DECLARE_WAITQUEUE(wait, current);
-        unsigned long posttime;
-
-        req->rq_posttime = posttime = jiffies;
-
-        add_wait_queue(&req->rq_sleep, &wait);
-        for (;;) {
-                if ( izo_channels[minor].uc_hard == 0 )
-                        set_current_state(TASK_INTERRUPTIBLE);
-                else
-                        set_current_state(TASK_UNINTERRUPTIBLE);
-
-                /* got a reply */
-                if ( req->rq_flags & (REQ_WRITE | REQ_DEAD) )
-                        break;
-
-                /* these cases only apply when TASK_INTERRUPTIBLE */ 
-                if ( !izo_channels[minor].uc_hard && signal_pending(current) ) {
-                        /* if this process really wants to die, let it go */
-                        if (sigismember(&(current->pending.signal), SIGKILL)||
-                            sigismember(&(current->pending.signal), SIGINT) )
-                                break;
-                        /* signal is present: after timeout always return
-                           really smart idea, probably useless ... */
-                        if ( time_after(jiffies, req->rq_posttime +
-                             izo_channels[minor].uc_timeout * HZ) )
-                                break;
-                }
-                schedule();
-        }
-
-        spin_lock(&channel->uc_lock);
-        list_del_init(&req->rq_chain); 
-        spin_unlock(&channel->uc_lock);
-        remove_wait_queue(&req->rq_sleep, &wait);
-        set_current_state(TASK_RUNNING);
-
-        CDEBUG(D_SPECIAL, "posttime: %ld, returned: %ld\n",
-               posttime, jiffies-posttime);
-        return  (jiffies - posttime);
-}
-
-/*
- * lento_upcall will return an error in the case of
- * failed communication with Lento _or_ will peek at Lento
- * reply and return Lento's error.
- *
- * As lento has 2 types of errors, normal errors (positive) and internal
- * errors (negative), normal errors are negated, while internal errors
- * are all mapped to -EINTR, while showing a nice warning message. (jh)
- *
- * lento_upcall will always free buffer, either directly, when an upcall
- * is read (in presto_psdev_read), when the filesystem is unmounted, or
- * when the module is unloaded.
- */
-int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer, 
-                   int async)
-{
-        unsigned long runtime;
-        struct upc_channel *channel;
-        struct izo_upcall_resp *out;
-        struct upc_req *req;
-        int error = 0;
-
-        ENTRY;
-        channel = &(izo_channels[minor]);
-
-        if (channel->uc_no_upcall) {
-                EXIT;
-                goto exit_buf;
-        }
-        if (!channel->uc_pid && !async) {
-                EXIT;
-                error = -ENXIO;
-                goto exit_buf;
-        }
-
-        /* Format the request message. */
-        PRESTO_ALLOC(req, sizeof(struct upc_req));
-        if ( !req ) {
-                EXIT;
-                error = -ENOMEM;
-                goto exit_buf;
-        }
-        req->rq_data = (void *)buffer;
-        req->rq_flags = 0;
-        req->rq_bufsize = *size;
-        req->rq_rep_size = 0;
-        req->rq_opcode = buffer->u_opc;
-        req->rq_unique = ++channel->uc_seq;
-        init_waitqueue_head(&req->rq_sleep);
-
-        /* Fill in the common input args. */
-        buffer->u_uniq = req->rq_unique;
-        buffer->u_async = async;
-
-        /* Remove potential datarace possibility*/
-        if ( async ) 
-                req->rq_flags = REQ_ASYNC;
-
-        spin_lock(&channel->uc_lock); 
-        /* Append msg to pending queue and poke Lento. */
-        list_add(&req->rq_chain, channel->uc_pending.prev);
-        spin_unlock(&channel->uc_lock); 
-        CDEBUG(D_UPCALL,
-               "Proc %d waking Lento %d for(opc,uniq) =(%d,%d) msg at %p.\n",
-               current->pid, channel->uc_pid, req->rq_opcode,
-               req->rq_unique, req);
-        wake_up_interruptible(&channel->uc_waitq);
-
-        if ( async ) {
-                /* req, rq_data are freed in presto_psdev_read for async */
-                /* req->rq_flags = REQ_ASYNC;*/
-                EXIT;
-                return 0;
-        }
-
-        /* We can be interrupted while we wait for Lento to process
-         * our request.  If the interrupt occurs before Lento has read
-         * the request, we dequeue and return. If it occurs after the
-         * read but before the reply, we dequeue, send a signal
-         * message, and return. If it occurs after the reply we ignore
-         * it. In no case do we want to restart the syscall.  If it
-         * was interrupted by a lento shutdown (psdev_close), return
-         * ENODEV.  */
-
-        /* Go to sleep.  Wake up on signals only after the timeout. */
-        runtime = lento_waitfor_upcall(channel, req, minor);
-
-        CDEBUG(D_TIMING, "opc: %d time: %ld uniq: %d size: %d\n",
-               req->rq_opcode, jiffies - req->rq_posttime,
-               req->rq_unique, req->rq_rep_size);
-        CDEBUG(D_UPCALL,
-               "..process %d woken up by Lento for req at 0x%p, data at %p\n",
-               current->pid, req, req->rq_data);
-
-        if (channel->uc_pid) {      /* i.e. Lento is still alive */
-          /* Op went through, interrupt or not we go on */
-            if (req->rq_flags & REQ_WRITE) {
-                    out = (struct izo_upcall_resp *)req->rq_data;
-                    /* here we map positive Lento errors to kernel errors */
-                    if ( out->result < 0 ) {
-                            CERROR("Tell Peter: Lento returns negative error %d, for oc %d!\n",
-                                   out->result, out->opcode);
-                          out->result = EINVAL;
-                    }
-                    error = -out->result;
-                    CDEBUG(D_UPCALL, "upcall: (u,o,r) (%d, %d, %d) out at %p\n",
-                           out->unique, out->opcode, out->result, out);
-                    *size = req->rq_rep_size;
-                    EXIT;
-                    goto exit_req;
-            }
-            /* Interrupted before lento read it. */
-            if ( !(req->rq_flags & REQ_READ) && signal_pending(current)) {
-                    CDEBUG(D_UPCALL,
-                           "Interrupt before read: (op,un)=(%d,%d), flags %x\n",
-                           req->rq_opcode, req->rq_unique, req->rq_flags);
-                    /* perhaps the best way to convince the app to give up? */
-                    error = -EINTR;
-                    EXIT;
-                    goto exit_req;
-            }
-
-            /* interrupted after Lento did its read, send signal */
-            if ( (req->rq_flags & REQ_READ) && signal_pending(current) ) {
-                    CDEBUG(D_UPCALL,"Interrupt after read: op = %d.%d, flags = %x\n",
-                           req->rq_opcode, req->rq_unique, req->rq_flags);
-
-                    error = -EINTR;
-            } else {
-                  CERROR("Lento: Strange interruption - tell Peter.\n");
-                    error = -EINTR;
-            }
-        } else {        /* If lento died i.e. !UC_OPEN(channel) */
-                CERROR("lento_upcall: Lento dead on (op,un) (%d.%d) flags %d\n",
-                       req->rq_opcode, req->rq_unique, req->rq_flags);
-                error = -ENODEV;
-        }
-
-exit_req:
-        PRESTO_FREE(req, sizeof(struct upc_req));
-exit_buf:
-        PRESTO_FREE(buffer,*size);
-        return error;
-}
diff --git a/fs/intermezzo/replicator.c b/fs/intermezzo/replicator.c
deleted file mode 100644 (file)
index e7a0c5c..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- * Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Manage RCVD records for clients in the kernel
- *
- */
-
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/fsfilter.h>
-
-#include "intermezzo_fs.h"
-
-/*
- * this file contains a hash table of replicators/clients for a
- * fileset. It allows fast lookup and update of reintegration status
- */
-
-struct izo_offset_rec {
-       struct list_head or_list;
-       char             or_uuid[16];
-       loff_t           or_offset;
-};
-
-#define RCACHE_BITS 8
-#define RCACHE_SIZE (1 << RCACHE_BITS)
-#define RCACHE_MASK (RCACHE_SIZE - 1)
-
-static struct list_head *
-izo_rep_cache(void)
-{
-       int i;
-       struct list_head *cache;
-       PRESTO_ALLOC(cache, sizeof(struct list_head) * RCACHE_SIZE);
-       if (cache == NULL) {
-               CERROR("intermezzo-fatal: no memory for replicator cache\n");
-                return NULL;
-       }
-       memset(cache, 0, sizeof(struct list_head) * RCACHE_SIZE);
-       for (i = 0; i < RCACHE_SIZE; i++)
-               INIT_LIST_HEAD(&cache[i]);
-
-       return cache;
-}
-
-static struct list_head *
-izo_rep_hash(struct list_head *cache, char *uuid)
-{
-        return &cache[(RCACHE_MASK & uuid[1])];
-}
-
-static void
-izo_rep_cache_clean(struct presto_file_set *fset)
-{
-       int i;
-       struct list_head *bucket;
-       struct list_head *tmp;
-
-        if (fset->fset_clients == NULL)
-               return;
-        for (i = 0; i < RCACHE_SIZE; i++) {
-               tmp = bucket = &fset->fset_clients[i];
-
-               tmp = tmp->next;
-                while (tmp != bucket) {
-                       struct izo_offset_rec *offrec;
-                       tmp = tmp->next;
-                       list_del(tmp);
-                       offrec = list_entry(tmp, struct izo_offset_rec,
-                                           or_list);
-                       PRESTO_FREE(offrec, sizeof(struct izo_offset_rec));
-               }
-       }
-}
-
-struct izo_offset_rec *
-izo_rep_cache_find(struct presto_file_set *fset, char *uuid)
-{
-       struct list_head *tmp, *buck = izo_rep_hash(fset->fset_clients, uuid);
-        struct izo_offset_rec *rec = NULL;
-
-       list_for_each(tmp, buck) {
-               rec = list_entry(tmp, struct izo_offset_rec, or_list);
-                if ( memcmp(rec->or_uuid, uuid, sizeof(rec->or_uuid)) == 0 )
-                       return rec;
-       }
-
-       return NULL;
-}
-
-static int
-izo_rep_cache_add(struct presto_file_set *fset, struct izo_rcvd_rec *rec,
-                  loff_t offset)
-{
-        struct izo_offset_rec *offrec;
-
-        if (izo_rep_cache_find(fset, rec->lr_uuid)) {
-                CERROR("izo: duplicate client entry %s off %Ld\n",
-                       fset->fset_name, offset);
-                return -EINVAL;
-        }
-
-        PRESTO_ALLOC(offrec, sizeof(*offrec));
-        if (offrec == NULL) {
-                CERROR("izo: cannot allocate offrec\n");
-                return -ENOMEM;
-        }
-
-        memcpy(offrec->or_uuid, rec->lr_uuid, sizeof(rec->lr_uuid));
-        offrec->or_offset = offset;
-
-        list_add(&offrec->or_list,
-                 izo_rep_hash(fset->fset_clients, rec->lr_uuid));
-        return 0;
-}
-
-int
-izo_rep_cache_init(struct presto_file_set *fset)
-{
-       struct izo_rcvd_rec rec;
-        loff_t offset = 0, last_offset = 0;
-
-       fset->fset_clients = izo_rep_cache();
-        if (fset->fset_clients == NULL) {
-               CERROR("Error initializing client cache\n");
-               return -ENOMEM;
-       }
-
-        while ( presto_fread(fset->fset_rcvd.fd_file, (char *)&rec,
-                             sizeof(rec), &offset) == sizeof(rec) ) {
-                int rc;
-
-                if ((rc = izo_rep_cache_add(fset, &rec, last_offset)) < 0) {
-                       izo_rep_cache_clean(fset);
-                       return rc;
-               }
-
-                last_offset = offset;
-       }
-
-       return 0;
-}
-
-/*
- * Return local last_rcvd record for the client. Update or create 
- * if necessary.
- *
- * XXX: After this call, any -EINVAL from izo_rcvd_get is a real error.
- */
-int
-izo_repstatus(struct presto_file_set *fset,  __u64 client_kmlsize, 
-              struct izo_rcvd_rec *lr_client, struct izo_rcvd_rec *lr_server)
-{
-        int rc;
-        rc = izo_rcvd_get(lr_server, fset, lr_client->lr_uuid);
-        if (rc < 0 && rc != -EINVAL) {
-                return rc;
-        }
-
-        /* client is new or has been reset. */
-        if (rc < 0 || (client_kmlsize == 0 && lr_client->lr_remote_offset == 0)) {
-                memset(lr_server, 0, sizeof(*lr_server));
-                memcpy(lr_server->lr_uuid, lr_client->lr_uuid, sizeof(lr_server->lr_uuid));
-                rc = izo_rcvd_write(fset, lr_server);
-                if (rc < 0)
-                        return rc;
-        }
-
-        /* update intersync */
-        rc = izo_upc_repstatus(presto_f2m(fset), fset->fset_name, lr_server);
-        return rc;
-}
-
-loff_t
-izo_rcvd_get(struct izo_rcvd_rec *rec, struct presto_file_set *fset, char *uuid)
-{
-        struct izo_offset_rec *offrec;
-        struct izo_rcvd_rec tmprec;
-        loff_t offset;
-
-        offrec = izo_rep_cache_find(fset, uuid);
-        if (offrec == NULL) {
-                CDEBUG(D_SPECIAL, "izo_get_rcvd: uuid not in hash.\n");
-                return -EINVAL;
-        }
-        offset = offrec->or_offset;
-
-        if (rec == NULL)
-                return offset;
-
-        if (presto_fread(fset->fset_rcvd.fd_file, (char *)&tmprec,
-                         sizeof(tmprec), &offset) != sizeof(tmprec)) {
-                CERROR("izo_get_rcvd: Unable to read from last_rcvd file offset "
-                       "%Lu\n", offset);
-                return -EIO;
-        }
-
-        memcpy(rec->lr_uuid, tmprec.lr_uuid, sizeof(tmprec.lr_uuid));
-        rec->lr_remote_recno = le64_to_cpu(tmprec.lr_remote_recno);
-        rec->lr_remote_offset = le64_to_cpu(tmprec.lr_remote_offset);
-        rec->lr_local_recno = le64_to_cpu(tmprec.lr_local_recno);
-        rec->lr_local_offset = le64_to_cpu(tmprec.lr_local_offset);
-        rec->lr_last_ctime = le64_to_cpu(tmprec.lr_last_ctime);
-
-        return offrec->or_offset;
-}
-
-/* Try to lookup the UUID in the hash.  Insert it if it isn't found.  Write the
- * data to the file.
- *
- * Returns the offset of the beginning of the record in the last_rcvd file. */
-loff_t
-izo_rcvd_write(struct presto_file_set *fset, struct izo_rcvd_rec *rec)
-{
-        struct izo_offset_rec *offrec;
-        loff_t offset, rc;
-
-        ENTRY;
-
-        offrec = izo_rep_cache_find(fset, rec->lr_uuid);
-        if (offrec == NULL) {
-                /* I don't think it should be possible for an entry to be not in
-                 * the hash table without also having an invalid offset, but we
-                 * handle it gracefully regardless. */
-                write_lock(&fset->fset_rcvd.fd_lock);
-                offset = fset->fset_rcvd.fd_offset;
-                fset->fset_rcvd.fd_offset += sizeof(*rec);
-                write_unlock(&fset->fset_rcvd.fd_lock);
-
-                rc = izo_rep_cache_add(fset, rec, offset);
-                if (rc < 0) {
-                        EXIT;
-                        return rc;
-                }
-        } else
-                offset = offrec->or_offset;
-        
-
-        rc = presto_fwrite(fset->fset_rcvd.fd_file, (char *)rec, sizeof(*rec),
-                           &offset);
-        if (rc == sizeof(*rec))
-                /* presto_fwrite() advances 'offset' */
-                rc = offset - sizeof(*rec);
-
-        EXIT;
-        return rc;
-}
-
-loff_t
-izo_rcvd_upd_remote(struct presto_file_set *fset, char * uuid,  __u64 remote_recno, 
-                    __u64 remote_offset)
-{
-        struct izo_rcvd_rec rec;
-        
-        loff_t rc;
-
-        ENTRY;
-        rc = izo_rcvd_get(&rec, fset, uuid);
-        if (rc < 0)
-                return rc;
-        rec.lr_remote_recno = remote_recno;
-        rec.lr_remote_offset = remote_offset;
-
-        rc = izo_rcvd_write(fset, &rec);
-        EXIT;
-        if (rc < 0)
-                return rc;
-        return 0;
-}
diff --git a/fs/intermezzo/super.c b/fs/intermezzo/super.c
deleted file mode 100644 (file)
index 9993ef2..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *  Copyright (C) 2000 Stelias Computing, Inc.
- *  Copyright (C) 2000 Red Hat, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  presto's super.c
- */
-
-static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.4 2002/10/12 02:16:19 rread Exp $";
-#define INTERMEZZO_VERSION "$Revision: 1.4 $"
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
-#include <linux/module.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef PRESTO_DEBUG
-long presto_vmemory = 0;
-long presto_kmemory = 0;
-#endif
-
-/* returns an allocated string, copied out from data if opt is found */
-static char *opt_read(const char *opt, char *data)
-{
-        char *value;
-        char *retval;
-
-        CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
-        if ( strncmp(opt, data, strlen(opt)) )
-                return NULL;
-
-        if ( (value = strchr(data, '=')) == NULL )
-                return NULL;
-
-        value++;
-        PRESTO_ALLOC(retval, strlen(value) + 1);
-        if ( !retval ) {
-                CERROR("InterMezzo: Out of memory!\n");
-                return NULL;
-        }
-
-        strcpy(retval, value);
-        CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
-        return retval;
-}
-
-static void opt_store(char **dst, char *opt)
-{
-        if (!dst) 
-                CERROR("intermezzo: store_opt, error dst == NULL\n"); 
-
-        if (*dst)
-                PRESTO_FREE(*dst, strlen(*dst) + 1);
-        *dst = opt;
-}
-
-static void opt_set_default(char **dst, char *defval)
-{
-        if (!dst) 
-                CERROR("intermezzo: store_opt, error dst == NULL\n"); 
-
-        if (*dst)
-                PRESTO_FREE(*dst, strlen(*dst) + 1);
-        if (defval) {
-                char *def_alloced; 
-                PRESTO_ALLOC(def_alloced, strlen(defval)+1);
-                if (!def_alloced) {
-                        CERROR("InterMezzo: Out of memory!\n");
-                        return ;
-                }
-                strcpy(def_alloced, defval);
-                *dst = def_alloced; 
-        }
-}
-
-
-/* Find the options for InterMezzo in "options", saving them into the
- * passed pointers.  If the pointer is null, the option is discarded.
- * Copy out all non-InterMezzo options into cache_data (to be passed
- * to the read_super operation of the cache).  The return value will
- * be a pointer to the end of the cache_data.
- */
-static char *presto_options(struct file_system_type *fstype, 
-                            char *options, char *cache_data,
-                            char **cache_type, char **fileset,
-                            char **channel)
-{
-        char *this_char;
-        char *opt_ptr = options;
-        char *cache_data_end = cache_data;
-
-        /* set the defaults */ 
-        if (strcmp(fstype->name, "intermezzo") == 0)
-            opt_set_default(cache_type, "ext3"); 
-        else 
-            opt_set_default(cache_type, "tmpfs"); 
-            
-        if (!options || !cache_data)
-                return cache_data_end;
-
-
-        CDEBUG(D_SUPER, "parsing options\n");
-        while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
-                char *opt;
-                if (!*this_char)
-                        continue;
-                CDEBUG(D_SUPER, "this_char %s\n", this_char);
-
-                if ( (opt = opt_read("fileset", this_char)) ) {
-                        opt_store(fileset, opt);
-                        continue;
-                }
-                if ( (opt = opt_read("cache_type", this_char)) ) {
-                        opt_store(cache_type, opt);
-                        continue;
-                }
-                if ( (opt = opt_read("channel", this_char)) ) {
-                        opt_store(channel, opt);
-                        continue;
-                }
-
-                cache_data_end += 
-                        sprintf(cache_data_end, "%s%s",
-                                cache_data_end != cache_data ? ",":"", 
-                                this_char);
-        }
-
-        return cache_data_end;
-}
-
-static int presto_set_channel(struct presto_cache *cache, char *channel)
-{
-        int minor; 
-
-        ENTRY;
-        if (!channel) {
-                minor = izo_psdev_get_free_channel();
-        } else {
-                minor = simple_strtoul(channel, NULL, 0); 
-        }
-        if (minor < 0 || minor >= MAX_CHANNEL) { 
-                CERROR("all channels in use or channel too large %d\n", 
-                       minor);
-                return -EINVAL;
-        }
-        
-        cache->cache_psdev = &(izo_channels[minor]);
-        list_add(&cache->cache_channel_list, 
-                 &cache->cache_psdev->uc_cache_list); 
-
-        EXIT;
-        return minor;
-}
-
-/* We always need to remove the presto options before passing 
-   mount options to cache FS */
-struct super_block *
-presto_get_sb(struct file_system_type *izo_type, int flags,
-             const char *devname, void *data)
-{
-        struct file_system_type *fstype;
-        struct presto_cache *cache = NULL;
-        char *cache_data = NULL;
-        char *cache_data_end;
-        char *cache_type = NULL;
-        char *fileset = NULL;
-        char *channel = NULL;
-        struct super_block *sb;
-        int err; 
-        unsigned int minor;
-
-        ENTRY;
-
-        /* reserve space for the cache's data */
-        PRESTO_ALLOC(cache_data, PAGE_SIZE);
-        if ( !cache_data ) {
-                CERROR("presto_read_super: Cannot allocate data page.\n");
-                EXIT;
-                goto out_err;
-        }
-
-        /* read and validate options */
-        cache_data_end = presto_options(izo_type, data, cache_data, &cache_type, 
-                                        &fileset, &channel);
-
-        /* was there anything for the cache filesystem in the data? */
-        if (cache_data_end == cache_data) {
-                PRESTO_FREE(cache_data, PAGE_SIZE);
-                cache_data_end = cache_data = NULL;
-        } else {
-                CDEBUG(D_SUPER, "cache_data at %p is: %s\n", cache_data,
-                       cache_data);
-        }
-
-        /* set up the cache */
-        cache = presto_cache_init();
-        if ( !cache ) {
-                CERROR("presto_read_super: failure allocating cache.\n");
-                EXIT;
-                goto out_err;
-        }
-        cache->cache_type = cache_type;
-
-        /* link cache to channel */ 
-        minor = presto_set_channel(cache, channel);
-        if (minor < 0) { 
-                EXIT;
-                goto out_err;
-        }
-
-        CDEBUG(D_SUPER, "Presto: type=%s, fset=%s, dev= %d, flags %x\n",
-               cache_type, fileset?fileset:"NULL", minor, cache->cache_flags);
-
-        /* get the filter for the cache */
-        fstype = get_fs_type(cache_type);
-        cache->cache_filter = filter_get_filter_fs((const char *)cache_type); 
-        if ( !fstype || !cache->cache_filter) {
-                CERROR("Presto: unrecognized fs type or cache type\n");
-                EXIT;
-                goto out_err;
-        }
-
-        sb = fstype->get_sb(fstype, flags, devname, cache_data);
-
-        if ( !sb || IS_ERR(sb)) {
-                CERROR("InterMezzo: cache mount failure.\n");
-                EXIT;
-                goto out_err;
-        }
-
-        /* can we in fact mount the cache */ 
-        if (sb->s_bdev && (strcmp(fstype->name, "vintermezzo") == 0)) {
-                CERROR("vintermezzo must not be used with a  block device\n");
-                EXIT;
-                goto out_err;
-        }
-
-        /* this might have been freed above */
-        if (cache_data) {
-                PRESTO_FREE(cache_data, PAGE_SIZE);
-                cache_data = NULL;
-        }
-
-        cache->cache_sb = sb;
-        cache->cache_root = dget(sb->s_root);
-
-        /* we now know the dev of the cache: hash the cache */
-        presto_cache_add(cache);
-        err = izo_prepare_fileset(sb->s_root, fileset); 
-
-        filter_setup_journal_ops(cache->cache_filter, cache->cache_type); 
-
-        /* make sure we have our own super operations: sb
-           still contains the cache operations */
-        filter_setup_super_ops(cache->cache_filter, sb->s_op, 
-                               &presto_super_ops);
-        sb->s_op = filter_c2usops(cache->cache_filter);
-
-        /* get izo directory operations: sb->s_root->d_inode exists now */
-        filter_setup_dir_ops(cache->cache_filter, sb->s_root->d_inode,
-                             &presto_dir_iops, &presto_dir_fops);
-        filter_setup_dentry_ops(cache->cache_filter, sb->s_root->d_op, 
-                                &presto_dentry_ops);
-        sb->s_root->d_inode->i_op = filter_c2udiops(cache->cache_filter);
-        sb->s_root->d_inode->i_fop = filter_c2udfops(cache->cache_filter);
-        sb->s_root->d_op = filter_c2udops(cache->cache_filter);
-
-        EXIT;
-        return sb;
-
- out_err:
-        CDEBUG(D_SUPER, "out_err called\n");
-        if (cache)
-                PRESTO_FREE(cache, sizeof(struct presto_cache));
-        if (cache_data)
-                PRESTO_FREE(cache_data, PAGE_SIZE);
-        if (fileset)
-                PRESTO_FREE(fileset, strlen(fileset) + 1);
-        if (channel)
-                PRESTO_FREE(channel, strlen(channel) + 1);
-        if (cache_type)
-                PRESTO_FREE(cache_type, strlen(cache_type) + 1);
-
-        CDEBUG(D_MALLOC, "mount error exit: kmem %ld, vmem %ld\n",
-               presto_kmemory, presto_vmemory);
-        return ERR_PTR(-EINVAL);
-}
-
-
-
-
-#ifdef PRESTO_DEVEL
-static DECLARE_FSTYPE(presto_fs_type, "izo", presto_read_super, FS_REQUIRES_DEV);
-static DECLARE_FSTYPE(vpresto_fs_type, "vintermezzo", presto_read_super, FS_LITTER);
-#else 
-static struct file_system_type vpresto_fs_type = {
-       .owner          = THIS_MODULE,
-       .name           = "vintermezzo",
-       .get_sb         = presto_get_sb,
-       .kill_sb        = kill_litter_super,
-};
-static struct file_system_type presto_fs_type = {
-       .owner          = THIS_MODULE,
-       .name           = "intermezzo",
-       .get_sb         = presto_get_sb,
-       .kill_sb        = kill_block_super,
-       .fs_flags       = FS_REQUIRES_DEV,
-};
-#endif
-
-
-
-int __init init_intermezzo_fs(void)
-{
-        int status;
-
-        printk(KERN_INFO "InterMezzo Kernel/Intersync communications " INTERMEZZO_VERSION
-               " info@clusterfs.com\n");
-
-        status = presto_psdev_init();
-        if ( status ) {
-                CERROR("Problem (%d) in init_intermezzo_psdev\n", status);
-                return status;
-        }
-
-        status = init_intermezzo_sysctl();
-        if (status) {
-                CERROR("presto: failed in init_intermezzo_sysctl!\n");
-        }
-
-        presto_cache_init_hash();
-
-        if (!presto_init_ddata_cache()) {
-                CERROR("presto out of memory!\n");
-                return -ENOMEM;
-        }
-
-        status = register_filesystem(&presto_fs_type);
-        if (status) {
-                CERROR("presto: failed in register_filesystem!\n");
-        }
-        status = register_filesystem(&vpresto_fs_type);
-        if (status) {
-                CERROR("vpresto: failed in register_filesystem!\n");
-        }
-        return status;
-}
-
-void __exit exit_intermezzo_fs(void)
-{
-        int err;
-
-        ENTRY;
-
-        if ( (err = unregister_filesystem(&presto_fs_type)) != 0 ) {
-                CERROR("presto: failed to unregister filesystem\n");
-        }
-        if ( (err = unregister_filesystem(&vpresto_fs_type)) != 0 ) {
-                CERROR("vpresto: failed to unregister filesystem\n");
-        }
-
-        presto_psdev_cleanup();
-        cleanup_intermezzo_sysctl();
-        presto_cleanup_ddata_cache();
-        CERROR("after cleanup: kmem %ld, vmem %ld\n",
-               presto_kmemory, presto_vmemory);
-}
-
-
-MODULE_AUTHOR("Cluster Filesystems Inc. <info@clusterfs.com>");
-MODULE_DESCRIPTION("InterMezzo Kernel/Intersync communications " INTERMEZZO_VERSION);
-MODULE_LICENSE("GPL");
-
-module_init(init_intermezzo_fs)
-module_exit(exit_intermezzo_fs)
diff --git a/fs/intermezzo/sysctl.c b/fs/intermezzo/sysctl.c
deleted file mode 100644 (file)
index 9436adf..0000000
+++ /dev/null
@@ -1,368 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 1999 Peter J. Braam <braam@clusterfs.com>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Sysctrl entries for Intermezzo!
- */
-
-#include <linux/config.h> /* for CONFIG_PROC_FS */
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/sysctl.h>
-#include <linux/proc_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/ctype.h>
-#include <linux/init.h>
-#include <asm/bitops.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/utsname.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-/* /proc entries */
-
-#ifdef CONFIG_PROC_FS
-struct proc_dir_entry *proc_fs_intermezzo;
-int intermezzo_mount_get_info( char * buffer, char ** start, off_t offset,
-                              int length)
-{
-       int len=0;
-
-       /* this works as long as we are below 1024 characters! */
-       *start = buffer + offset;
-       len -= offset;
-
-       if ( len < 0 )
-               return -EINVAL;
-
-       return len;
-}
-
-#endif
-
-
-/* SYSCTL below */
-
-static struct ctl_table_header *intermezzo_table_header = NULL;
-/* 0x100 to avoid any chance of collisions at any point in the tree with
- * non-directories
- */
-#define PSDEV_INTERMEZZO  (0x100)
-
-#define PSDEV_DEBUG       1      /* control debugging */
-#define PSDEV_TRACE       2      /* control enter/leave pattern */
-#define PSDEV_TIMEOUT      3      /* timeout on upcalls to become intrble */
-#define PSDEV_HARD         4      /* mount type "hard" or "soft" */
-#define PSDEV_NO_FILTER    5      /* controls presto_chk */
-#define PSDEV_NO_JOURNAL   6      /* controls presto_chk */
-#define PSDEV_NO_UPCALL    7      /* controls lento_upcall */
-#define PSDEV_ERRORVAL     8      /* controls presto_debug_fail_blkdev */
-#define PSDEV_EXCL_GID     9      /* which GID is ignored by presto */
-#define PSDEV_BYTES_TO_CLOSE 11   /* bytes to write before close */
-
-/* These are global presto control options */
-#define PRESTO_PRIMARY_CTLCNT 2
-static struct ctl_table presto_table[ PRESTO_PRIMARY_CTLCNT + MAX_CHANNEL + 1] =
-{
-       {PSDEV_DEBUG, "debug", &presto_debug, sizeof(int), 0644, NULL, &proc_dointvec},
-       {PSDEV_TRACE, "trace", &presto_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
-};
-
-/*
- * Intalling the sysctl entries: strategy
- * - have templates for each /proc/sys/intermezzo/ entry
- *   such an entry exists for each /dev/presto
- *    (proto_channel_entry)
- * - have a template for the contents of such directories
- *    (proto_psdev_table)
- * - have the master table (presto_table)
- *
- * When installing, malloc, memcpy and fix up the pointers to point to
- * the appropriate constants in izo_channels[your_minor]
- */
-
-static ctl_table proto_psdev_table[] = {
-       {PSDEV_HARD, "hard", 0, sizeof(int), 0644, NULL, &proc_dointvec},
-       {PSDEV_NO_FILTER, "no_filter", 0, sizeof(int), 0644, NULL, &proc_dointvec},
-       {PSDEV_NO_JOURNAL, "no_journal", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
-       {PSDEV_NO_UPCALL, "no_upcall", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
-       {PSDEV_TIMEOUT, "timeout", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
-#ifdef PRESTO_DEBUG
-       {PSDEV_ERRORVAL, "errorval", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
-#endif
-       { 0 }
-};
-
-static ctl_table proto_channel_entry = {
-       PSDEV_INTERMEZZO, 0,  NULL, 0, 0555, 0,
-};
-
-static ctl_table intermezzo_table[2] = {
-       {PSDEV_INTERMEZZO, "intermezzo",    NULL, 0, 0555, presto_table},
-       {0}
-};
-
-/* support for external setting and getting of opts. */
-/* particularly via ioctl. The Right way to do this is via sysctl,
- * but that will have to wait until intermezzo gets its own nice set of
- * sysctl IDs
- */
-/* we made these separate as setting may in future be more restricted
- * than getting
- */
-#ifdef RON_MINNICH
-int dosetopt(int minor, struct psdev_opt *opt)
-{
-       int retval = 0;
-       int newval = opt->optval;
-
-       ENTRY;
-
-       switch(opt->optname) {
-
-       case PSDEV_TIMEOUT:
-               izo_channels[minor].uc_timeout = newval;
-               break;
-
-       case PSDEV_HARD:
-               izo_channels[minor].uc_hard = newval;
-               break;
-
-       case PSDEV_NO_FILTER:
-               izo_channels[minor].uc_no_filter = newval;
-               break;
-
-       case PSDEV_NO_JOURNAL:
-               izo_channels[minor].uc_no_journal = newval;
-               break;
-
-       case PSDEV_NO_UPCALL:
-               izo_channels[minor].uc_no_upcall = newval;
-               break;
-
-#ifdef PRESTO_DEBUG
-       case PSDEV_ERRORVAL: {
-               /* If we have a positive arg, set a breakpoint for that
-                * value.  If we have a negative arg, make that device
-                * read-only.  FIXME  It would be much better to only
-                * allow setting the underlying device read-only for the
-                * current presto cache.
-                */
-               int errorval = izo_channels[minor].uc_errorval;
-               if (errorval < 0) {
-                       if (newval == 0)
-                               set_device_ro(-errorval, 0);
-                       else
-                               CERROR("device %s already read only\n",
-                                      kdevname(-errorval));
-               } else {
-                       if (newval < 0)
-                               set_device_ro(-newval, 1);
-                       izo_channels[minor].uc_errorval = newval;
-                       CDEBUG(D_PSDEV, "setting errorval to %d\n", newval);
-               }
-
-               break;
-       }
-#endif
-
-       case PSDEV_TRACE:
-       case PSDEV_DEBUG:
-       case PSDEV_BYTES_TO_CLOSE:
-       default:
-               CDEBUG(D_PSDEV,
-                      "ioctl: dosetopt: minor %d, bad optname 0x%x, \n",
-                      minor, opt->optname);
-
-               retval = -EINVAL;
-       }
-
-       EXIT;
-       return retval;
-}
-
-int dogetopt(int minor, struct psdev_opt *opt)
-{
-       int retval = 0;
-
-       ENTRY;
-
-       switch(opt->optname) {
-
-       case PSDEV_TIMEOUT:
-               opt->optval = izo_channels[minor].uc_timeout;
-               break;
-
-       case PSDEV_HARD:
-               opt->optval = izo_channels[minor].uc_hard;
-               break;
-
-       case PSDEV_NO_FILTER:
-               opt->optval = izo_channels[minor].uc_no_filter;
-               break;
-
-       case PSDEV_NO_JOURNAL:
-               opt->optval = izo_channels[minor].uc_no_journal;
-               break;
-
-       case PSDEV_NO_UPCALL:
-               opt->optval = izo_channels[minor].uc_no_upcall;
-               break;
-
-#ifdef PSDEV_DEBUG
-       case PSDEV_ERRORVAL: {
-               int errorval = izo_channels[minor].uc_errorval;
-               if (errorval < 0 && is_read_only(-errorval))
-                       CERROR("device %s has been set read-only\n",
-                              kdevname(-errorval));
-               opt->optval = izo_channels[minor].uc_errorval;
-               break;
-       }
-#endif
-
-       case PSDEV_TRACE:
-       case PSDEV_DEBUG:
-       case PSDEV_BYTES_TO_CLOSE:
-       default:
-               CDEBUG(D_PSDEV,
-                      "ioctl: dogetopt: minor %d, bad optval 0x%x, \n",
-                      minor, opt->optname);
-
-               retval = -EINVAL;
-       }
-
-       EXIT;
-       return retval;
-}
-#endif
-
-
-/* allocate the tables for the presto devices. We need
- * sizeof(proto_channel_table)/sizeof(proto_channel_table[0])
- * entries for each dev
- */
-int /* __init */ init_intermezzo_sysctl(void)
-{
-       int i;
-       int total_dev = MAX_CHANNEL;
-       int entries_per_dev = sizeof(proto_psdev_table) /
-               sizeof(proto_psdev_table[0]);
-       int total_entries = entries_per_dev * total_dev;
-       ctl_table *dev_ctl_table;
-
-       PRESTO_ALLOC(dev_ctl_table, sizeof(ctl_table) * total_entries);
-
-       if (! dev_ctl_table) {
-               CERROR("WARNING: presto couldn't allocate dev_ctl_table\n");
-               EXIT;
-               return -ENOMEM;
-       }
-
-       /* now fill in the entries ... we put the individual presto<x>
-        * entries at the end of the table, and the per-presto stuff
-        * starting at the front.  We assume that the compiler makes
-        * this code more efficient, but really, who cares ... it
-        * happens once per reboot.
-        */
-       for(i = 0; i < total_dev; i++) {
-               void *p;
-
-               /* entry for this /proc/sys/intermezzo/intermezzo"i" */
-               ctl_table *psdev = &presto_table[i + PRESTO_PRIMARY_CTLCNT];
-               /* entries for the individual "files" in this "directory" */
-               ctl_table *psdev_entries = &dev_ctl_table[i * entries_per_dev];
-               /* init the psdev and psdev_entries with the prototypes */
-               *psdev = proto_channel_entry;
-               memcpy(psdev_entries, proto_psdev_table,
-                      sizeof(proto_psdev_table));
-               /* now specialize them ... */
-               /* the psdev has to point to psdev_entries, and fix the number */
-               psdev->ctl_name = psdev->ctl_name + i + 1; /* sorry */
-
-               PRESTO_ALLOC(p, PROCNAME_SIZE);
-               psdev->procname = p;
-               if (!psdev->procname) {
-                       PRESTO_FREE(dev_ctl_table,
-                                   sizeof(ctl_table) * total_entries);
-                       return -ENOMEM;
-               }
-               sprintf((char *) psdev->procname, "intermezzo%d", i);
-               /* hook presto into */
-               psdev->child = psdev_entries;
-
-               /* now for each psdev entry ... */
-               psdev_entries[0].data = &(izo_channels[i].uc_hard);
-               psdev_entries[1].data = &(izo_channels[i].uc_no_filter);
-               psdev_entries[2].data = &(izo_channels[i].uc_no_journal);
-               psdev_entries[3].data = &(izo_channels[i].uc_no_upcall);
-               psdev_entries[4].data = &(izo_channels[i].uc_timeout);
-#ifdef PRESTO_DEBUG
-               psdev_entries[5].data = &(izo_channels[i].uc_errorval);
-#endif
-       }
-
-
-#ifdef CONFIG_SYSCTL
-       if ( !intermezzo_table_header )
-               intermezzo_table_header =
-                       register_sysctl_table(intermezzo_table, 0);
-#endif
-#ifdef CONFIG_PROC_FS
-       proc_fs_intermezzo = proc_mkdir("intermezzo", proc_root_fs);
-       proc_fs_intermezzo->owner = THIS_MODULE;
-       create_proc_info_entry("mounts", 0, proc_fs_intermezzo, 
-                              intermezzo_mount_get_info);
-#endif
-       return 0;
-}
-
-void cleanup_intermezzo_sysctl(void)
-{
-       int total_dev = MAX_CHANNEL;
-       int entries_per_dev = sizeof(proto_psdev_table) /
-               sizeof(proto_psdev_table[0]);
-       int total_entries = entries_per_dev * total_dev;
-       int i;
-
-#ifdef CONFIG_SYSCTL
-       if ( intermezzo_table_header )
-               unregister_sysctl_table(intermezzo_table_header);
-       intermezzo_table_header = NULL;
-#endif
-       for(i = 0; i < total_dev; i++) {
-               /* entry for this /proc/sys/intermezzo/intermezzo"i" */
-               ctl_table *psdev = &presto_table[i + PRESTO_PRIMARY_CTLCNT];
-               PRESTO_FREE(psdev->procname, PROCNAME_SIZE);
-       }
-       /* presto_table[PRESTO_PRIMARY_CTLCNT].child points to the
-        * dev_ctl_table previously allocated in init_intermezzo_psdev()
-        */
-       PRESTO_FREE(presto_table[PRESTO_PRIMARY_CTLCNT].child, sizeof(ctl_table) * total_entries);
-
-#ifdef CONFIG_PROC_FS
-       remove_proc_entry("mounts", proc_fs_intermezzo);
-       remove_proc_entry("intermezzo", proc_root_fs);
-#endif
-}
-
diff --git a/fs/intermezzo/upcall.c b/fs/intermezzo/upcall.c
deleted file mode 100644 (file)
index 8019157..0000000
+++ /dev/null
@@ -1,559 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc. <braam@clusterfs.com>
- * Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Mostly platform independent upcall operations to a cache manager:
- *  -- upcalls
- *  -- upcall routines
- *
- */
-
-#include <asm/system.h>
-#include <asm/segment.h>
-#include <asm/signal.h>
-#include <linux/signal.h>
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <asm/uaccess.h>
-
-#include "intermezzo_lib.h"
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#include "intermezzo_idl.h"
-
-/*
-  At present:
-  -- Asynchronous calls:
-   - kml:            give a "more" kml indication to userland
-   - kml_truncate:   initiate KML truncation
-   - release_permit: kernel is done with permit
-  -- Synchronous
-   - open:           fetch file
-   - permit:         get a permit
-
-  Errors returned by user level code are positive
-
- */
-
-static struct izo_upcall_hdr *upc_pack(__u32 opcode, int pathlen, char *path,
-                                       char *fsetname, int reclen, char *rec,
-                                       int *size)
-{
-        struct izo_upcall_hdr *hdr;
-        char *ptr;
-        ENTRY;
-
-        *size = sizeof(struct izo_upcall_hdr);
-        if ( fsetname ) {
-                *size += round_strlen(fsetname);
-        }
-        if ( path ) { 
-                *size += round_strlen(path);
-        }
-        if ( rec ) { 
-                *size += size_round(reclen);
-        }
-        PRESTO_ALLOC(hdr, *size);
-        if (!hdr) { 
-                CERROR("intermezzo upcall: out of memory (opc %d)\n", opcode);
-                EXIT;
-                return NULL;
-        }
-        memset(hdr, 0, *size);
-
-        ptr = (char *)hdr + sizeof(*hdr);
-
-        /* XXX do we need fsuid ? */
-        hdr->u_len = *size;
-        hdr->u_version = IZO_UPC_VERSION;
-        hdr->u_opc = opcode;
-        hdr->u_pid = current->pid;
-        hdr->u_uid = current->fsuid;
-
-        if (path) { 
-                /*XXX Robert: please review what len to pass in for 
-                  NUL terminated strings */
-                hdr->u_pathlen = strlen(path);
-                LOGL0(path, hdr->u_pathlen, ptr);
-        }
-        if (fsetname) { 
-                hdr->u_fsetlen = strlen(fsetname);
-                LOGL0(fsetname, strlen(fsetname), ptr);
-        }
-        if (rec) { 
-                hdr->u_reclen = reclen;
-                LOGL(rec, reclen, ptr);
-        }
-        
-        EXIT;
-        return hdr;
-}
-
-/* the upcalls */
-int izo_upc_kml(int minor, __u64 offset, __u32 first_recno, __u64 length, __u32 last_recno, char *fsetname)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-
-        ENTRY;
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return 0;
-        }
-
-        hdr = upc_pack(IZO_UPC_KML, 0, NULL, fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        hdr->u_offset = offset;
-        hdr->u_first_recno = first_recno;
-        hdr->u_length = length;
-        hdr->u_last_recno = last_recno;
-
-        CDEBUG(D_UPCALL, "KML: fileset %s, offset %Lu, length %Lu, "
-               "first %u, last %d; minor %d\n",
-               fsetname,
-               (unsigned long long) hdr->u_offset,
-               (unsigned long long) hdr->u_length,
-               hdr->u_first_recno,
-               hdr->u_last_recno, minor);
-
-        error = izo_upc_upcall(minor, &size, hdr, ASYNCHRONOUS);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_kml_truncate(int minor, __u64 length, __u32 last_recno, char *fsetname)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-
-        ENTRY;
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return 0;
-        }
-
-        hdr = upc_pack(IZO_UPC_KML_TRUNC, 0, NULL, fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        hdr->u_length = length;
-        hdr->u_last_recno = last_recno;
-
-        CDEBUG(D_UPCALL, "KML TRUNCATE: fileset %s, length %Lu, "
-               "last recno %d, minor %d\n",
-               fsetname,
-               (unsigned long long) hdr->u_length,
-               hdr->u_last_recno, minor);
-
-        error = izo_upc_upcall(minor, &size, hdr, ASYNCHRONOUS);
-
-        EXIT;
-        return error;
-}
-
-int izo_upc_open(int minor, __u32 pathlen, char *path, char *fsetname, struct lento_vfs_context *info)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_OPEN, pathlen, path, fsetname, 
-                       sizeof(*info), (char*)info, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        CDEBUG(D_UPCALL, "path %s\n", path);
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_get_fileid(int minor, __u32 reclen, char *rec, 
-                       __u32 pathlen, char *path, char *fsetname)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_GET_FILEID, pathlen, path, fsetname, reclen, rec, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        CDEBUG(D_UPCALL, "path %s\n", path);
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_backfetch(int minor, char *path, char *fsetname, struct lento_vfs_context *info)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_BACKFETCH, strlen(path), path, fsetname, 
-                       sizeof(*info), (char *)info, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        /* This is currently synchronous, kml_reint_record blocks */
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_permit(int minor, struct dentry *dentry, __u32 pathlen, char *path,
-                   char *fsetname)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-
-        ENTRY;
-
-        hdr = upc_pack(IZO_UPC_PERMIT, pathlen, path, fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        CDEBUG(D_UPCALL, "Permit minor %d path %s\n", minor, path);
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-
-        if (error == -EROFS) {
-                int err;
-                CERROR("InterMezzo: ERROR - requested permit for read-only "
-                       "fileset.\n   Setting \"%s\" read-only!\n", path);
-                err = izo_mark_cache(dentry, 0xFFFFFFFF, CACHE_CLIENT_RO, NULL);
-                if (err)
-                        CERROR("InterMezzo ERROR: mark_cache %d\n", err);
-        } else if (error) {
-                CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-        }
-
-        EXIT;
-        return error;
-}
-
-/* This is a ping-pong upcall handled on the server when a client (uuid)
- * requests the permit for itself. */
-int izo_upc_revoke_permit(int minor, char *fsetname, __u8 uuid[16])
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-
-        ENTRY;
-
-        hdr = upc_pack(IZO_UPC_REVOKE_PERMIT, 0, NULL, fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-
-        if (error)
-                CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_go_fetch_kml(int minor, char *fsetname, __u8 uuid[16],
-                         __u64 kmlsize)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_GO_FETCH_KML, 0, NULL, fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        hdr->u_offset = kmlsize;
-        memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
-
-        error = izo_upc_upcall(minor, &size, hdr, ASYNCHRONOUS);
-        if (error)
-                CERROR("%s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_connect(int minor, __u64 ip_address, __u64 port, __u8 uuid[16],
-                    int client_flag)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_CONNECT, 0, NULL, NULL, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        hdr->u_offset = ip_address;
-        hdr->u_length = port;
-        memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
-        hdr->u_first_recno = client_flag;
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error) {
-                CERROR("%s: error %d\n", __FUNCTION__, error);
-        }
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_set_kmlsize(int minor, char *fsetname, __u8 uuid[16], __u64 kmlsize)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_SET_KMLSIZE, 0, NULL, fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
-        hdr->u_length = kmlsize;
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("%s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_repstatus(int minor,  char * fsetname, struct izo_rcvd_rec *lr_server)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_REPSTATUS, 0, NULL, fsetname, 
-                       sizeof(*lr_server), (char*)lr_server, 
-                       &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("%s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-
-#if 0
-int izo_upc_client_make_branch(int minor, char *fsetname, char *tagname,
-                               char *branchname)
-{
-        int size, error;
-        struct izo_upcall_hdr *hdr;
-        int pathlen;
-        char *path;
-        ENTRY;
-
-        hdr = upc_pack(IZO_UPC_CLIENT_MAKE_BRANCH, strlen(tagname), tagname,
-                       fsetname, strlen(branchname) + 1, branchname, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                error = -PTR_ERR(hdr);
-                goto error;
-        }
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("InterMezzo: error %d\n", error);
-
- error:
-        PRESTO_FREE(path, pathlen);
-        EXIT;
-        return error;
-}
-#endif
-
-int izo_upc_server_make_branch(int minor, char *fsetname)
-{
-        int size, error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        hdr = upc_pack(IZO_UPC_SERVER_MAKE_BRANCH, 0, NULL, fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                error = -PTR_ERR(hdr);
-                goto error;
-        }
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("InterMezzo: error %d\n", error);
-
- error:
-        EXIT;
-        return -error;
-}
-
-int izo_upc_branch_undo(int minor, char *fsetname, char *branchname)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_BRANCH_UNDO, strlen(branchname), branchname,
-                       fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
-
-int izo_upc_branch_redo(int minor, char *fsetname, char *branchname)
-{
-        int size;
-        int error;
-        struct izo_upcall_hdr *hdr;
-        ENTRY;
-
-        if (!presto_lento_up(minor)) {
-                EXIT;
-                return -EIO;
-        }
-
-        hdr = upc_pack(IZO_UPC_BRANCH_REDO, strlen(branchname) + 1, branchname,
-                       fsetname, 0, NULL, &size);
-        if (!hdr || IS_ERR(hdr)) {
-                EXIT;
-                return -PTR_ERR(hdr);
-        }
-
-        error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-        if (error)
-                CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
-        EXIT;
-        return -error;
-}
diff --git a/fs/intermezzo/vfs.c b/fs/intermezzo/vfs.c
deleted file mode 100644 (file)
index 84b5882..0000000
+++ /dev/null
@@ -1,2416 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- *  Copyright (C) 2000 Stelias Computing, Inc.
- *  Copyright (C) 2000 Red Hat, Inc.
- *
- *   This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- *   InterMezzo is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   InterMezzo is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with InterMezzo; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * vfs.c
- *
- * This file implements kernel downcalls from lento.
- *
- * Author: Rob Simmonds <simmonds@stelias.com>
- *         Andreas Dilger <adilger@stelias.com>
- * Copyright (C) 2000 Stelias Computing Inc
- * Copyright (C) 2000 Red Hat Inc.
- *
- * Extended attribute support
- * Copyright (C) 2001 Shirish H. Phatak, Tacit Networks, Inc.
- *
- * This code is based on code from namei.c in the linux file system;
- * see copyright notice below.
- */
-
-/** namei.c copyright **/
-
-/*
- *  linux/fs/namei.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- */
-/*
- * Some corrections by tytso.
- */
-
-/* [Feb 1997 T. Schoebel-Theuer] Complete rewrite of the pathname
- * lookup logic.
- */
-
-/** end of namei.c copyright **/
-
-#include <linux/mm.h>
-#include <linux/proc_fs.h>
-#include <linux/quotaops.h>
-
-#include <asm/uaccess.h>
-#include <asm/unaligned.h>
-#include <asm/semaphore.h>
-#include <asm/pgtable.h>
-
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/genhd.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef CONFIG_FS_EXT_ATTR
-# include <linux/ext_attr.h>
-
-# if 0 /* was a broken check for Posix ACLs */
-#  include <linux/posix_acl.h>
-# endif
-#endif
-
-extern struct inode_operations presto_sym_iops;
-
-/* Write the last_rcvd values to the last_rcvd file.  We don't know what the
- * UUID or last_ctime values are, so we have to read from the file first
- * (sigh). 
- * exported for branch_reinter in kml_reint.c*/
-int presto_write_last_rcvd(struct rec_info *recinfo,
-                           struct presto_file_set *fset,
-                           struct lento_vfs_context *info)
-{
-        int rc;
-        struct izo_rcvd_rec rcvd_rec;
-
-        ENTRY;
-
-        memset(&rcvd_rec, 0, sizeof(rcvd_rec));
-        memcpy(rcvd_rec.lr_uuid, info->uuid, sizeof(rcvd_rec.lr_uuid));
-        rcvd_rec.lr_remote_recno = HTON__u64(info->recno);
-        rcvd_rec.lr_remote_offset = HTON__u64(info->kml_offset);
-        rcvd_rec.lr_local_recno = HTON__u64(recinfo->recno);
-        rcvd_rec.lr_local_offset = HTON__u64(recinfo->offset + recinfo->size);
-
-        rc = izo_rcvd_write(fset, &rcvd_rec);
-        if (rc < 0) {
-                /* izo_rcvd_write returns negative errors and non-negative
-                 * offsets */
-                CERROR("InterMezzo: izo_rcvd_write failed: %d\n", rc);
-                EXIT;
-                return rc;
-        }
-        EXIT;
-        return 0;
-}
-
-/*
- * It's inline, so penalty for filesystems that don't use sticky bit is
- * minimal.
- */
-static inline int check_sticky(struct inode *dir, struct inode *inode)
-{
-        if (!(dir->i_mode & S_ISVTX))
-                return 0;
-        if (inode->i_uid == current->fsuid)
-                return 0;
-        if (dir->i_uid == current->fsuid)
-                return 0;
-        return !capable(CAP_FOWNER);
-}
-
-/* from linux/fs/namei.c */
-static inline int may_delete(struct inode *dir,struct dentry *victim, int isdir)
-{
-        int error;
-        if (!victim->d_inode || victim->d_parent->d_inode != dir)
-                return -ENOENT;
-        error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
-        if (error)
-                return error;
-        if (IS_APPEND(dir))
-                return -EPERM;
-        if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
-            IS_IMMUTABLE(victim->d_inode))
-                return -EPERM;
-        if (isdir) {
-                if (!S_ISDIR(victim->d_inode->i_mode))
-                        return -ENOTDIR;
-                if (IS_ROOT(victim))
-                        return -EBUSY;
-        } else if (S_ISDIR(victim->d_inode->i_mode))
-                return -EISDIR;
-        return 0;
-}
-
-/* from linux/fs/namei.c */
-static inline int may_create(struct inode *dir, struct dentry *child) {
-        if (child->d_inode)
-                return -EEXIST;
-        if (IS_DEADDIR(dir))
-                return -ENOENT;
-        return permission(dir,MAY_WRITE | MAY_EXEC, NULL);
-}
-
-#ifdef PRESTO_DEBUG
-/* The loop_discard_io() function is available via a kernel patch to the
- * loop block device.  It "works" by accepting writes, but throwing them
- * away, rather than trying to write them to disk.  The old method worked
- * by setting the underlying device read-only, but that has the problem
- * that dirty buffers are kept in memory, and ext3 didn't like that at all.
- */
-#ifdef CONFIG_LOOP_DISCARD
-#define BLKDEV_FAIL(dev,fail) loop_discard_io(dev,fail)
-#else
-#define BLKDEV_FAIL(dev,fail) set_device_ro(dev, 1)
-#endif
-
-/* If a breakpoint has been set via /proc/sys/intermezzo/intermezzoX/errorval,
- * that is the same as "value", the underlying device will "fail" now.
- */
-inline void presto_debug_fail_blkdev(struct presto_file_set *fset,
-                                     unsigned long value)
-{
-        int minor = presto_f2m(fset);
-        int errorval = izo_channels[minor].uc_errorval;
-       struct block_device *bdev = fset->fset_dentry->d_inode->i_sb->s_bdev;
-       char b[BDEVNAME_SIZE];
-
-        if (errorval && errorval == (long)value && !bdev_read_only(bdev)) {
-                CDEBUG(D_SUPER, "setting device %s read only\n",
-                               bdevname(bdev, b));
-                BLKDEV_FAIL(bdev, 1);
-                izo_channels[minor].uc_errorval = -bdev->bd_dev;
-        }
-}
-#else
-#define presto_debug_fail_blkdev(dev,value) do {} while (0)
-#endif
-
-
-static inline int presto_do_kml(struct lento_vfs_context *info,
-                                struct dentry *dentry)
-{
-        if ( ! (info->flags & LENTO_FL_KML) )
-                return 0;
-        if ( presto_chk(dentry, PRESTO_DONT_JOURNAL) )
-                return 0;
-        return 1;
-}
-
-static inline int presto_do_rcvd(struct lento_vfs_context *info,
-                                 struct dentry *dentry)
-{
-        if ( ! (info->flags & LENTO_FL_EXPECT) ) 
-                return 0;
-        if ( presto_chk(dentry, PRESTO_DONT_JOURNAL) )
-                return 0;
-        return 1;
-}
-
-
-/* XXX fixme: this should not fail, all these dentries are in memory
-   when _we_ call this */
-int presto_settime(struct presto_file_set *fset, 
-                   struct dentry *newobj,
-                   struct dentry *parent,
-                   struct dentry *target,
-                   struct lento_vfs_context *ctx, 
-                   int valid)
-{
-        int error = 0;
-        struct dentry *dentry;
-        struct inode *inode;
-        struct inode_operations *iops;
-        struct iattr iattr;
-
-        ENTRY;
-        if (ctx->flags &  LENTO_FL_IGNORE_TIME ) { 
-                EXIT;
-                return 0;
-        }
-
-        iattr.ia_ctime = ctx->updated_time;
-        iattr.ia_mtime = ctx->updated_time;
-        iattr.ia_valid = valid;
-
-        while (1) {
-                if (parent && ctx->flags & LENTO_FL_TOUCH_PARENT) {
-                        dentry = parent;
-                        parent = NULL;
-                } else if (newobj && ctx->flags & LENTO_FL_TOUCH_NEWOBJ) {
-                        dentry = newobj;
-                        newobj = NULL;
-                } else if (target) {
-                        dentry = target;
-                        target = NULL;
-                } else
-                        break;
-
-                inode = dentry->d_inode;
-
-                error = -EROFS;
-                if (IS_RDONLY(inode)) {
-                        EXIT;
-                        return -EROFS;
-                }
-
-                if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
-                        EXIT;
-                        return -EPERM;
-                }
-
-                error = -EPERM;
-                iops = filter_c2cdiops(fset->fset_cache->cache_filter); 
-                if (!iops) { 
-                        EXIT;
-                        return error;
-                }
-
-                if (iops->setattr != NULL)
-                        error = iops->setattr(dentry, &iattr);
-                else {
-                        error = 0;
-                        inode_setattr(dentry->d_inode, &iattr);
-                }
-        }
-        EXIT;
-        return error;
-}
-
-void izo_get_rollback_data(struct inode *inode, struct izo_rollback_data *rb)
-{
-        rb->rb_mode = (__u32)inode->i_mode;
-        rb->rb_rdev = (__u32)old_encode_dev(inode->i_rdev);
-        rb->rb_uid  = (__u64)inode->i_uid;
-        rb->rb_gid  = (__u64)inode->i_gid;
-}
-
-
-int presto_do_close(struct presto_file_set *fset, struct file *file)
-{
-        struct rec_info rec;
-        int rc = -ENOSPC; 
-        void *handle;
-        struct inode *inode = file->f_dentry->d_inode;
-        struct presto_file_data *fdata = 
-                (struct presto_file_data *)file->private_data;
-
-        ENTRY;
-        presto_getversion(&fdata->fd_info.remote_version, inode);
-
-        rc = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH); 
-        if (rc) { 
-                EXIT;
-                return rc;
-        }
-
-        handle = presto_trans_start(fset, file->f_dentry->d_inode, 
-                                            KML_OPCODE_RELEASE);
-        if ( IS_ERR(handle) ) {
-                CERROR("presto_release: no space for transaction\n");
-                return rc;
-        }
-
-        if (fdata->fd_info.flags & LENTO_FL_KML) 
-                rc = presto_journal_close(&rec, fset, fdata, file->f_dentry,
-                                          &fdata->fd_version, 
-                                          &fdata->fd_info.remote_version);
-        if (rc) { 
-                CERROR("presto_close: cannot journal close\n");
-                goto out;
-        }
-
-        if (fdata->fd_info.flags & LENTO_FL_EXPECT) 
-                rc = presto_write_last_rcvd(&rec, fset, &fdata->fd_info);
-
-        if (rc) { 
-                CERROR("presto_close: cannot journal last_rcvd\n");
-                goto out;
-        }
-        presto_trans_commit(fset, handle); 
-        
-        /* cancel the LML record */ 
-        handle = presto_trans_start(fset, inode, KML_OPCODE_WRITE);
-        if ( IS_ERR(handle) ) {
-                CERROR("presto_release: no space for clear\n");
-                return -ENOSPC;
-        }
-
-        rc = presto_clear_lml_close(fset, fdata->fd_lml_offset); 
-        if (rc < 0 ) { 
-                CERROR("presto_close: cannot journal close\n");
-                goto out;
-        }
-        presto_truncate_lml(fset);
-
- out:
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-        presto_trans_commit(fset, handle); 
-        EXIT;
-        return rc;
-}
-
-int presto_do_setattr(struct presto_file_set *fset, struct dentry *dentry,
-                      struct iattr *iattr, struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        struct inode *inode = dentry->d_inode;
-        struct inode_operations *iops;
-        int error;
-        struct presto_version old_ver, new_ver;
-        struct izo_rollback_data rb;
-        void *handle;
-        loff_t old_size=inode->i_size;
-
-        ENTRY;
-        error = -EROFS;
-        if (IS_RDONLY(inode)) {
-                EXIT;
-                return -EROFS;
-        }
-
-        if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
-                EXIT;
-                return -EPERM;
-        }
-
-        presto_getversion(&old_ver, dentry->d_inode);
-        izo_get_rollback_data(dentry->d_inode, &rb);
-        error = -EPERM;
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter); 
-
-        error = presto_reserve_space(fset->fset_cache, 2*PRESTO_REQHIGH); 
-        if (error) {
-                EXIT;
-                return error;
-        }
-
-        if  (iattr->ia_valid & ATTR_SIZE) {
-                if (izo_mark_dentry(dentry, ~PRESTO_DATA, 0, NULL) != 0)
-                        CERROR("izo_mark_dentry(inode %ld, ~PRESTO_DATA) "
-                               "failed\n", dentry->d_inode->i_ino);
-                handle = presto_trans_start(fset, dentry->d_inode,
-                                            KML_OPCODE_TRUNC);
-        } else {
-                handle = presto_trans_start(fset, dentry->d_inode,
-                                            KML_OPCODE_SETATTR);
-        }
-
-        if ( IS_ERR(handle) ) {
-                CERROR("presto_do_setattr: no space for transaction\n");
-                presto_release_space(fset->fset_cache, 2*PRESTO_REQHIGH); 
-                return -ENOSPC;
-        }
-
-        if (dentry->d_inode && iops && iops->setattr) {
-                error = iops->setattr(dentry, iattr);
-        } else {
-                error = inode_change_ok(dentry->d_inode, iattr);
-                if (!error) 
-                        inode_setattr(inode, iattr);
-        }
-
-        if (!error && (iattr->ia_valid & ATTR_SIZE))
-                vmtruncate(inode, iattr->ia_size);
-
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SETATTR | 0x10);
-
-        if ( presto_do_kml(info, dentry) ) {
-                if ((iattr->ia_valid & ATTR_SIZE) && (old_size != inode->i_size)) {
-                        /* Journal a close whenever we see a potential truncate
-                        * At the receiving end, lento should explicitly remove
-                        * ATTR_SIZE from the list of valid attributes */
-                        presto_getversion(&new_ver, inode);
-                        error = presto_journal_close(&rec, fset, NULL, dentry,
-                                                     &old_ver, &new_ver);
-                }
-
-                if (!error)
-                        error = presto_journal_setattr(&rec, fset, dentry,
-                                                       &old_ver, &rb, iattr);
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SETATTR | 0x20);
-        if ( presto_do_rcvd(info, dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SETATTR | 0x30);
-
-        EXIT;
-exit:
-        presto_release_space(fset->fset_cache, 2*PRESTO_REQHIGH); 
-        presto_trans_commit(fset, handle);
-        return error;
-}
-
-int lento_setattr(const char *name, struct iattr *iattr,
-                  struct lento_vfs_context *info)
-{
-        struct nameidata nd;
-        struct dentry *dentry;
-        struct presto_file_set *fset;
-        int error;
-#if 0 /* was a broken check for Posix ACLs */
-        int (*set_posix_acl)(struct inode *, int type, posix_acl_t *)=NULL;
-#endif
-
-        ENTRY;
-        CDEBUG(D_PIOCTL,"name %s, valid %#x, mode %#o, uid %d, gid %d, size %Ld\n",
-               name, iattr->ia_valid, iattr->ia_mode, iattr->ia_uid,
-               iattr->ia_gid, iattr->ia_size);
-        CDEBUG(D_PIOCTL, "atime %#lx, mtime %#lx, ctime %#lx, attr_flags %#x\n",
-               iattr->ia_atime.tv_sec, iattr->ia_mtime.tv_sec, iattr->ia_ctime.tv_sec,
-               iattr->ia_attr_flags);
-        CDEBUG(D_PIOCTL, "offset %d, recno %d, flags %#x\n",
-               info->slot_offset, info->recno, info->flags);
-
-        lock_kernel();
-        error = presto_walk(name, &nd);
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-        dentry = nd.dentry;
-        
-        fset = presto_fset(dentry);
-        error = -EINVAL;
-        if ( !fset ) {
-                CERROR("No fileset!\n");
-                EXIT;
-                goto exit_lock;
-        }
-
-        /* NOTE: this prevents us from changing the filetype on setattr,
-         *       as we normally only want to change permission bits.
-         *       If this is not correct, then we need to fix the perl code
-         *       to always send the file type OR'ed with the permission.
-         */
-        if (iattr->ia_valid & ATTR_MODE) {
-                int set_mode = iattr->ia_mode;
-                iattr->ia_mode = (iattr->ia_mode & S_IALLUGO) |
-                                 (dentry->d_inode->i_mode & ~S_IALLUGO);
-                CDEBUG(D_PIOCTL, "chmod: orig %#o, set %#o, result %#o\n",
-                       dentry->d_inode->i_mode, set_mode, iattr->ia_mode);
-#if 0 /* was a broken check for Posix ACLs */
-                /* ACl code interacts badly with setattr 
-                 * since it tries to modify the ACL using 
-                 * set_ext_attr which recurses back into presto.  
-                 * This only happens if ATTR_MODE is set.
-                 * Here we are doing a "forced" mode set 
-                 * (initiated by lento), so we disable the 
-                 * set_posix_acl operation which 
-                 * prevents such recursion.  -SHP
-                 *
-                 * This will probably still be required when native
-                 * acl journalling is in place.
-                 */
-                set_posix_acl=dentry->d_inode->i_op->set_posix_acl;
-                dentry->d_inode->i_op->set_posix_acl=NULL;
-#endif
-        }
-
-        error = presto_do_setattr(fset, dentry, iattr, info);
-
-        if (info->flags & LENTO_FL_SET_DDFILEID) {
-                struct presto_dentry_data *dd = presto_d2d(dentry);
-                if (dd) {
-                        dd->remote_ino = info->remote_ino;
-                        dd->remote_generation = info->remote_generation;
-                }
-        }
-
-#if 0 /* was a broken check for Posix ACLs */
-        /* restore the inode_operations if we changed them*/
-        if (iattr->ia_valid & ATTR_MODE) 
-                dentry->d_inode->i_op->set_posix_acl=set_posix_acl;
-#endif
-
-
-        EXIT;
-exit_lock:
-        path_release(&nd);
-exit:
-        unlock_kernel();
-        return error;
-}
-
-int presto_do_create(struct presto_file_set *fset, struct dentry *dir,
-                     struct dentry *dentry, int mode,
-                     struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        int error;
-        struct presto_version tgt_dir_ver, new_file_ver;
-        struct inode_operations *iops;
-        void *handle;
-
-        ENTRY;
-        mode &= S_IALLUGO;
-        mode |= S_IFREG;
-
-        //        down(&dir->d_inode->i_zombie);
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH); 
-        if (error) {
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-
-        error = may_create(dir->d_inode, dentry);
-        if (error) {
-                EXIT;
-                goto exit_pre_lock;
-        }
-
-        error = -EPERM;
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-        if (!iops->create) {
-                EXIT;
-                goto exit_pre_lock;
-        }
-
-        presto_getversion(&tgt_dir_ver, dir->d_inode);
-        handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_CREATE);
-        if ( IS_ERR(handle) ) {
-                EXIT;
-                presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-                CERROR("presto_do_create: no space for transaction\n");
-                error=-ENOSPC;
-                goto exit_pre_lock;
-        }
-        DQUOT_INIT(dir->d_inode);
-        lock_kernel();
-        error = iops->create(dir->d_inode, dentry, mode, NULL);
-        if (error) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        if (dentry->d_inode) {
-                struct presto_cache *cache = fset->fset_cache;
-                /* was this already done? */
-                presto_set_ops(dentry->d_inode, cache->cache_filter);
-
-                filter_setup_dentry_ops(cache->cache_filter, 
-                                        dentry->d_op, 
-                                        &presto_dentry_ops);
-                dentry->d_op = filter_c2udops(cache->cache_filter);
-
-                /* if Lento creates this file, we won't have data */
-                if ( ISLENTO(presto_c2m(cache)) ) {
-                        presto_set(dentry, PRESTO_ATTR);
-                } else {
-                        presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
-                }
-        }
-
-        info->flags |= LENTO_FL_TOUCH_PARENT;
-        error = presto_settime(fset, NULL, dir, dentry,
-                               info, ATTR_CTIME | ATTR_MTIME);
-        if (error) { 
-                EXIT;
-                goto exit_lock;
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_CREATE | 0x10);
-
-        if ( presto_do_kml(info, dentry) ) { 
-                presto_getversion(&new_file_ver, dentry->d_inode);
-                error = presto_journal_create(&rec, fset, dentry, &tgt_dir_ver,
-                                              &new_file_ver, 
-                                              dentry->d_inode->i_mode);
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_CREATE | 0x20);
-
-        if ( presto_do_rcvd(info, dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_CREATE | 0x30);
-
-        /* add inode dentry */
-        if (fset->fset_cache->cache_filter->o_trops->tr_add_ilookup ) { 
-                struct dentry *d;
-                d = fset->fset_cache->cache_filter->o_trops->tr_add_ilookup
-                        (dir->d_inode->i_sb->s_root, dentry);
-        }
-
-        EXIT;
-
- exit_lock:
-        unlock_kernel();
-        presto_trans_commit(fset, handle);
- exit_pre_lock:
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-        //        up(&dir->d_inode->i_zombie);
-        return error;
-}
-
-int lento_create(const char *name, int mode, struct lento_vfs_context *info)
-{
-        int error;
-        struct nameidata nd;
-        char * pathname;
-        struct dentry *dentry;
-        struct presto_file_set *fset;
-
-        ENTRY;
-        pathname = getname(name);
-        error = PTR_ERR(pathname);
-        if (IS_ERR(pathname)) {
-                EXIT;
-                goto exit;
-        }
-
-        /* this looks up the parent */
-        error = path_lookup(pathname,  LOOKUP_PARENT, &nd);
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-        dentry = lookup_create(&nd, 0);
-        error = PTR_ERR(dentry);
-        if (IS_ERR(dentry)) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        fset = presto_fset(dentry);
-        error = -EINVAL;
-        if ( !fset ) {
-                CERROR("No fileset!\n");
-                EXIT;
-                goto exit_lock;
-        }
-        error = presto_do_create(fset, dentry->d_parent, dentry, (mode&S_IALLUGO)|S_IFREG,
-                                 info);
-
-        EXIT;
-
- exit_lock:
-        path_release (&nd);
-        dput(dentry); 
-        up(&dentry->d_parent->d_inode->i_sem);
-        putname(pathname);
-exit:
-        return error;
-}
-
-int presto_do_link(struct presto_file_set *fset, struct dentry *old_dentry,
-                   struct dentry *dir, struct dentry *new_dentry,
-                   struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        struct inode *inode;
-        int error;
-        struct inode_operations *iops;
-        struct presto_version tgt_dir_ver;
-        struct presto_version new_link_ver;
-        void *handle;
-
-        //        down(&dir->d_inode->i_zombie);
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH); 
-        if (error) {
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-        error = -ENOENT;
-        inode = old_dentry->d_inode;
-        if (!inode)
-                goto exit_lock;
-
-        error = may_create(dir->d_inode, new_dentry);
-        if (error)
-                goto exit_lock;
-
-        error = -EXDEV;
-        if (dir->d_inode->i_sb != inode->i_sb)
-                goto exit_lock;
-
-        /*
-         * A link to an append-only or immutable file cannot be created.
-         */
-        error = -EPERM;
-        if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-        if (!iops->link) {
-                EXIT;
-                goto exit_lock;
-        }
-
-
-        presto_getversion(&tgt_dir_ver, dir->d_inode);
-        handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_LINK);
-        if ( IS_ERR(handle) ) {
-                presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-                CERROR("presto_do_link: no space for transaction\n");
-                return -ENOSPC;
-        }
-
-        DQUOT_INIT(dir->d_inode);
-        lock_kernel();
-        error = iops->link(old_dentry, dir->d_inode, new_dentry);
-        unlock_kernel();
-        if (error) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        /* link dd data to that of existing dentry */
-        old_dentry->d_op->d_release(new_dentry); 
-        if (!presto_d2d(old_dentry)) 
-                BUG();
-        presto_d2d(old_dentry)->dd_count++;
-
-        new_dentry->d_fsdata = presto_d2d(old_dentry);
-
-        info->flags |= LENTO_FL_TOUCH_PARENT;
-        error = presto_settime(fset, NULL, dir, new_dentry,
-                               info, ATTR_CTIME);
-        if (error) { 
-                EXIT;
-                goto exit_lock;
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_LINK | 0x10);
-        presto_getversion(&new_link_ver, new_dentry->d_inode);
-        if ( presto_do_kml(info, old_dentry) )
-                error = presto_journal_link(&rec, fset, old_dentry, new_dentry,
-                                            &tgt_dir_ver, &new_link_ver);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_LINK | 0x20);
-        if ( presto_do_rcvd(info, old_dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_LINK | 0x30);
-        EXIT;
-        presto_trans_commit(fset, handle);
-exit_lock:
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-        //        up(&dir->d_inode->i_zombie);
-        return error;
-}
-
-
-int lento_link(const char * oldname, const char * newname, 
-                         struct lento_vfs_context *info)
-{
-        int error;
-        char * to;
-        struct presto_file_set *fset;
-
-        to = getname(newname);
-        error = PTR_ERR(to);
-        if (!IS_ERR(to)) {
-                struct dentry *new_dentry;
-                struct nameidata nd, old_nd;
-
-                error = __user_walk(oldname, 0, &old_nd);
-                if (error)
-                        goto exit;
-                error = path_lookup(to, LOOKUP_PARENT, &nd);
-                if (error)
-                        goto out;
-                error = -EXDEV;
-                if (old_nd.mnt != nd.mnt)
-                        goto out;
-                new_dentry = lookup_create(&nd, 0);
-                error = PTR_ERR(new_dentry);
-
-                if (!IS_ERR(new_dentry)) {
-                        fset = presto_fset(new_dentry);
-                        error = -EINVAL;
-                        if ( !fset ) {
-                                CERROR("No fileset!\n");
-                                EXIT;
-                                goto out2;
-                        }
-                        error = presto_do_link(fset, old_nd.dentry, 
-                                               nd.dentry,
-                                               new_dentry, info);
-                        dput(new_dentry);
-                }
-        out2:
-                up(&nd.dentry->d_inode->i_sem);
-                path_release(&nd);
-        out:
-                path_release(&old_nd);
-        exit:
-                putname(to);
-        }
-        return error;
-}
-
-int presto_do_unlink(struct presto_file_set *fset, struct dentry *dir,
-                     struct dentry *dentry, struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        struct inode_operations *iops;
-        struct presto_version tgt_dir_ver, old_file_ver;
-        struct izo_rollback_data rb;
-        void *handle;
-        int do_kml = 0, do_rcvd = 0, linkno = 0, error, old_targetlen = 0;
-        char *old_target = NULL;
-
-        ENTRY;
-        //        down(&dir->d_inode->i_zombie);
-        error = may_delete(dir->d_inode, dentry, 0);
-        if (error) {
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-
-        error = -EPERM;
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-        if (!iops->unlink) {
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQLOW); 
-        if (error) {
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-
-
-        if (presto_d2d(dentry)) { 
-                struct presto_dentry_data *dd = presto_d2d(dentry); 
-                struct dentry *de = dd->dd_inodentry;
-                if (de && dentry->d_inode->i_nlink == 1) { 
-                        dd->dd_count--;
-                        dd->dd_inodentry = NULL; 
-                        de->d_fsdata = NULL; 
-                        atomic_dec(&de->d_inode->i_count); 
-                        de->d_inode = NULL;
-                        dput(de); 
-                }
-        }
-
-        presto_getversion(&tgt_dir_ver, dir->d_inode);
-        presto_getversion(&old_file_ver, dentry->d_inode);
-        izo_get_rollback_data(dentry->d_inode, &rb);
-        handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_UNLINK);
-        if ( IS_ERR(handle) ) {
-                presto_release_space(fset->fset_cache, PRESTO_REQLOW); 
-                CERROR("ERROR: presto_do_unlink: no space for transaction. Tell Peter.\n");
-                //                up(&dir->d_inode->i_zombie);
-                return -ENOSPC;
-        }
-        DQUOT_INIT(dir->d_inode);
-        if (d_mountpoint(dentry))
-                error = -EBUSY;
-        else {
-                lock_kernel();
-                linkno = dentry->d_inode->i_nlink;
-                if (linkno > 1) {
-                        dget(dentry);
-                }
-
-                if (S_ISLNK(dentry->d_inode->i_mode)) {
-                        mm_segment_t old_fs;
-                        struct inode_operations *riops;
-                        riops = filter_c2csiops(fset->fset_cache->cache_filter);
-
-                        PRESTO_ALLOC(old_target, PATH_MAX);
-                        if (old_target == NULL) {
-                                error = -ENOMEM;
-                                EXIT;
-                                goto exit;
-                        }
-
-                        old_fs = get_fs();
-                        set_fs(get_ds());
-
-                        if (riops->readlink == NULL)
-                                CERROR("InterMezzo %s: no readlink iops.\n",
-                                       __FUNCTION__);
-                        else
-                                old_targetlen =
-                                        riops->readlink(dentry, old_target,
-                                                        PATH_MAX);
-                        if (old_targetlen < 0) {
-                                CERROR("InterMezzo: readlink failed: %ld\n",
-                                       PTR_ERR(old_target));
-                                PRESTO_FREE(old_target, PATH_MAX);
-                                old_target = NULL;
-                                old_targetlen = 0;
-                        }
-                        set_fs(old_fs);
-                }
-
-                do_kml = presto_do_kml(info, dir);
-                do_rcvd = presto_do_rcvd(info, dir);
-                error = iops->unlink(dir->d_inode, dentry);
-                unlock_kernel();
-        }
-
-        if (linkno > 1) { 
-                /* FIXME: Combine this with the next call? */
-                error = presto_settime(fset, NULL, NULL, dentry,
-                                       info, ATTR_CTIME);
-                dput(dentry); 
-                if (error) { 
-                        EXIT;
-                        goto exit;
-                }
-        }
-
-        error = presto_settime(fset, NULL, NULL, dir,
-                               info, ATTR_CTIME | ATTR_MTIME);
-        if (error) { 
-                EXIT;
-                goto exit;
-        }
-
-        //        up(&dir->d_inode->i_zombie);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_UNLINK | 0x10);
-        if ( do_kml )
-                error = presto_journal_unlink(&rec, fset, dir, &tgt_dir_ver,
-                                              &old_file_ver, &rb, dentry,
-                                              old_target, old_targetlen);
-        presto_debug_fail_blkdev(fset, KML_OPCODE_UNLINK | 0x20);
-        if ( do_rcvd ) { 
-                error = presto_write_last_rcvd(&rec, fset, info);
-        }
-        presto_debug_fail_blkdev(fset, KML_OPCODE_UNLINK | 0x30);
-        EXIT;
-exit:
-        presto_release_space(fset->fset_cache, PRESTO_REQLOW); 
-        presto_trans_commit(fset, handle);
-        if (old_target != NULL)
-                PRESTO_FREE(old_target, PATH_MAX);
-        return error;
-}
-
-
-int lento_unlink(const char *pathname, struct lento_vfs_context *info)
-{
-        int error = 0;
-        char * name;
-        struct dentry *dentry;
-        struct nameidata nd;
-        struct presto_file_set *fset;
-
-        ENTRY;
-
-        name = getname(pathname);
-        if(IS_ERR(name))
-                return PTR_ERR(name);
-
-        error = path_lookup(name, LOOKUP_PARENT, &nd);
-        if (error)
-                goto exit;
-        error = -EISDIR;
-        if (nd.last_type != LAST_NORM)
-                goto exit1;
-        down(&nd.dentry->d_inode->i_sem);
-        dentry = lookup_hash(&nd.last, nd.dentry);
-        error = PTR_ERR(dentry);
-        if (!IS_ERR(dentry)) {
-                fset = presto_fset(dentry);
-                error = -EINVAL;
-                if ( !fset ) {
-                        CERROR("No fileset!\n");
-                        EXIT;
-                        goto exit2;
-                }
-                /* Why not before? Because we want correct error value */
-                if (nd.last.name[nd.last.len])
-                        goto slashes;
-                error = presto_do_unlink(fset, nd.dentry, dentry, info);
-                if (!error)
-                        d_delete(dentry);
-        exit2:
-                EXIT;
-                dput(dentry);
-        }
-        up(&nd.dentry->d_inode->i_sem);
-exit1:
-        path_release(&nd);
-exit:
-        putname(name);
-
-        return error;
-
-slashes:
-        error = !dentry->d_inode ? -ENOENT :
-                S_ISDIR(dentry->d_inode->i_mode) ? -EISDIR : -ENOTDIR;
-        goto exit2;
-}
-
-int presto_do_symlink(struct presto_file_set *fset, struct dentry *dir,
-                      struct dentry *dentry, const char *oldname,
-                      struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        int error;
-        struct presto_version tgt_dir_ver, new_link_ver;
-        struct inode_operations *iops;
-        void *handle;
-
-        ENTRY;
-        //        down(&dir->d_inode->i_zombie);
-        /* record + max path len + space to free */ 
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH + 4096); 
-        if (error) {
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-
-        error = may_create(dir->d_inode, dentry);
-        if (error) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        error = -EPERM;
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-        if (!iops->symlink) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        presto_getversion(&tgt_dir_ver, dir->d_inode);
-        handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_SYMLINK);
-        if ( IS_ERR(handle) ) {
-                presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096); 
-                CERROR("ERROR: presto_do_symlink: no space for transaction. Tell Peter.\n"); 
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return -ENOSPC;
-        }
-        DQUOT_INIT(dir->d_inode);
-        lock_kernel();
-        error = iops->symlink(dir->d_inode, dentry, oldname);
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-
-        if (dentry->d_inode) {
-                struct presto_cache *cache = fset->fset_cache;
-                
-                presto_set_ops(dentry->d_inode, cache->cache_filter);
-
-                filter_setup_dentry_ops(cache->cache_filter, dentry->d_op, 
-                                        &presto_dentry_ops);
-                dentry->d_op = filter_c2udops(cache->cache_filter);
-                /* XXX ? Cache state ? if Lento creates a symlink */
-                if ( ISLENTO(presto_c2m(cache)) ) {
-                        presto_set(dentry, PRESTO_ATTR);
-                } else {
-                        presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
-                }
-        }
-
-        info->flags |= LENTO_FL_TOUCH_PARENT;
-        error = presto_settime(fset, NULL, dir, dentry,
-                               info, ATTR_CTIME | ATTR_MTIME);
-        if (error) { 
-                EXIT;
-                goto exit;
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SYMLINK | 0x10);
-        presto_getversion(&new_link_ver, dentry->d_inode);
-        if ( presto_do_kml(info, dentry) )
-                error = presto_journal_symlink(&rec, fset, dentry, oldname,
-                                               &tgt_dir_ver, &new_link_ver);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SYMLINK | 0x20);
-        if ( presto_do_rcvd(info, dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SYMLINK | 0x30);
-        EXIT;
-exit:
-        unlock_kernel();
-        presto_trans_commit(fset, handle);
- exit_lock:
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096); 
-        //        up(&dir->d_inode->i_zombie);
-        return error;
-}
-
-int lento_symlink(const char *oldname, const char *newname,
-                  struct lento_vfs_context *info)
-{
-        int error;
-        char *from;
-        char *to;
-        struct dentry *dentry;
-        struct presto_file_set *fset;
-        struct nameidata nd;
-
-        ENTRY;
-        lock_kernel();
-        from = getname(oldname);
-        error = PTR_ERR(from);
-        if (IS_ERR(from)) {
-                EXIT;
-                goto exit;
-        }
-
-        to = getname(newname);
-        error = PTR_ERR(to);
-        if (IS_ERR(to)) {
-                EXIT;
-                goto exit_from;
-        }
-
-        error = path_lookup(to, LOOKUP_PARENT, &nd);
-        if (error) {
-                EXIT;
-                goto exit_to;
-        }
-
-        dentry = lookup_create(&nd, 0);
-        error = PTR_ERR(dentry);
-        if (IS_ERR(dentry)) {
-                path_release(&nd);
-                EXIT;
-                goto exit_to;
-        }
-
-        fset = presto_fset(dentry);
-        error = -EINVAL;
-        if ( !fset ) {
-                CERROR("No fileset!\n");
-                path_release(&nd);
-                EXIT;
-                goto exit_lock;
-        }
-        error = presto_do_symlink(fset, nd.dentry,
-                                  dentry, from, info);
-        path_release(&nd);
-        EXIT;
- exit_lock:
-        up(&nd.dentry->d_inode->i_sem);
-        dput(dentry);
- exit_to:
-        putname(to);
- exit_from:
-        putname(from);
- exit:
-        unlock_kernel();
-        return error;
-}
-
-int presto_do_mkdir(struct presto_file_set *fset, struct dentry *dir,
-                    struct dentry *dentry, int mode,
-                    struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        int error;
-        struct presto_version tgt_dir_ver, new_dir_ver;
-        void *handle;
-
-        ENTRY;
-        //        down(&dir->d_inode->i_zombie);
-
-        /* one journal record + directory block + room for removals*/ 
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH + 4096); 
-        if (error) { 
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-
-        error = may_create(dir->d_inode, dentry);
-        if (error) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        error = -EPERM;
-        if (!filter_c2cdiops(fset->fset_cache->cache_filter)->mkdir) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        error = -ENOSPC;
-        presto_getversion(&tgt_dir_ver, dir->d_inode);
-        handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_MKDIR);
-        if ( IS_ERR(handle) ) {
-                presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096); 
-                CERROR("presto_do_mkdir: no space for transaction\n");
-                goto exit_lock;
-        }
-
-        DQUOT_INIT(dir->d_inode);
-        mode &= (S_IRWXUGO|S_ISVTX);
-        lock_kernel();
-        error = filter_c2cdiops(fset->fset_cache->cache_filter)->mkdir(dir->d_inode, dentry, mode);
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-
-        if ( dentry->d_inode && !error) {
-                struct presto_cache *cache = fset->fset_cache;
-
-                presto_set_ops(dentry->d_inode, cache->cache_filter);
-
-                filter_setup_dentry_ops(cache->cache_filter, 
-                                        dentry->d_op, 
-                                        &presto_dentry_ops);
-                dentry->d_op = filter_c2udops(cache->cache_filter);
-                /* if Lento does this, we won't have data */
-                if ( ISLENTO(presto_c2m(cache)) ) {
-                        presto_set(dentry, PRESTO_ATTR);
-                } else {
-                        presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
-                }
-        }
-
-        info->flags |= LENTO_FL_TOUCH_PARENT;
-        error = presto_settime(fset, NULL, dir, dentry,
-                             info, ATTR_CTIME | ATTR_MTIME);
-        if (error) { 
-                EXIT;
-                goto exit;
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_MKDIR | 0x10);
-        presto_getversion(&new_dir_ver, dentry->d_inode);
-        if ( presto_do_kml(info, dir) )
-                error = presto_journal_mkdir(&rec, fset, dentry, &tgt_dir_ver,
-                                             &new_dir_ver, 
-                                             dentry->d_inode->i_mode);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_MKDIR | 0x20);
-        if ( presto_do_rcvd(info, dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_MKDIR | 0x30);
-        EXIT;
-exit:
-        unlock_kernel();
-        presto_trans_commit(fset, handle);
- exit_lock:
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096); 
-        //        up(&dir->d_inode->i_zombie);
-        return error;
-}
-
-/*
- * Look out: this function may change a normal dentry
- * into a directory dentry (different size)..
- */
-int lento_mkdir(const char *name, int mode, struct lento_vfs_context *info)
-{
-        int error;
-        char *pathname;
-        struct dentry *dentry;
-        struct presto_file_set *fset;
-        struct nameidata nd;
-
-        ENTRY;
-        CDEBUG(D_PIOCTL, "name: %s, mode %o, offset %d, recno %d, flags %x\n",
-               name, mode, info->slot_offset, info->recno, info->flags);
-        pathname = getname(name);
-        error = PTR_ERR(pathname);
-        if (IS_ERR(pathname)) {
-                EXIT;
-                return error;
-        }
-
-        error = path_lookup(pathname, LOOKUP_PARENT, &nd);
-        if (error)
-                goto out_name;
-
-        dentry = lookup_create(&nd, 1);
-        error = PTR_ERR(dentry);
-        if (!IS_ERR(dentry)) {
-                fset = presto_fset(dentry);
-                error = -EINVAL;
-                if (!fset) {
-                        CERROR("No fileset!\n");
-                        EXIT;
-                        goto out_dput;
-                }
-
-                error = presto_do_mkdir(fset, nd.dentry, dentry, 
-                                        mode & S_IALLUGO, info);
-out_dput:
-                dput(dentry);
-        }
-        up(&nd.dentry->d_inode->i_sem);
-        path_release(&nd);
-out_name:
-        EXIT;
-        putname(pathname);
-        CDEBUG(D_PIOCTL, "error: %d\n", error);
-        return error;
-}
-
-static void d_unhash(struct dentry *dentry)
-{
-        dget(dentry);
-        switch (atomic_read(&dentry->d_count)) {
-        default:
-                shrink_dcache_parent(dentry);
-                if (atomic_read(&dentry->d_count) != 2)
-                        break;
-        case 2:
-                d_drop(dentry);
-        }
-}
-
-int presto_do_rmdir(struct presto_file_set *fset, struct dentry *dir,
-                    struct dentry *dentry, struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        int error;
-        struct presto_version tgt_dir_ver, old_dir_ver;
-        struct izo_rollback_data rb;
-        struct inode_operations *iops;
-        void *handle;
-        int do_kml, do_rcvd;
-        int size;
-
-        ENTRY;
-        error = may_delete(dir->d_inode, dentry, 1);
-        if (error)
-                return error;
-
-        error = -EPERM;
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-        if (!iops->rmdir) {
-                EXIT;
-                return error;
-        }
-
-        size = PRESTO_REQHIGH - dentry->d_inode->i_size; 
-        error = presto_reserve_space(fset->fset_cache, size); 
-        if (error) { 
-                EXIT;
-                return error;
-        }
-
-        presto_getversion(&tgt_dir_ver, dir->d_inode);
-        presto_getversion(&old_dir_ver, dentry->d_inode);
-        izo_get_rollback_data(dentry->d_inode, &rb);
-        handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_RMDIR);
-        if ( IS_ERR(handle) ) {
-                presto_release_space(fset->fset_cache, size); 
-                CERROR("ERROR: presto_do_rmdir: no space for transaction. Tell Peter.\n");
-                return -ENOSPC;
-        }
-
-        DQUOT_INIT(dir->d_inode);
-
-        do_kml = presto_do_kml(info, dir);
-        do_rcvd = presto_do_rcvd(info, dir);
-
-        //        double_down(&dir->d_inode->i_zombie, &dentry->d_inode->i_zombie);
-        d_unhash(dentry);
-        if (IS_DEADDIR(dir->d_inode))
-                error = -ENOENT;
-        else if (d_mountpoint(dentry)) {
-                CERROR("foo: d_mountpoint(dentry): ino %ld\n",
-                       dentry->d_inode->i_ino);
-                error = -EBUSY;
-        } else {
-                lock_kernel();
-                error = iops->rmdir(dir->d_inode, dentry);
-                unlock_kernel();
-                if (!error) {
-                        dentry->d_inode->i_flags |= S_DEAD;
-                        error = presto_settime(fset, NULL, NULL, dir, info,
-                                               ATTR_CTIME | ATTR_MTIME);
-                }
-        }
-        //        double_up(&dir->d_inode->i_zombie, &dentry->d_inode->i_zombie);
-        if (!error)
-                d_delete(dentry);
-        dput(dentry);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_RMDIR | 0x10);
-        if ( !error && do_kml )
-                error = presto_journal_rmdir(&rec, fset, dir, &tgt_dir_ver,
-                                             &old_dir_ver, &rb,
-                                             dentry->d_name.len,
-                                             dentry->d_name.name);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_RMDIR | 0x20);
-        if ( !error && do_rcvd ) 
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_RMDIR | 0x30);
-        EXIT;
-
-        presto_trans_commit(fset, handle);
-        presto_release_space(fset->fset_cache, size); 
-        return error;
-}
-
-int lento_rmdir(const char *pathname, struct lento_vfs_context *info)
-{
-        int error = 0;
-        char * name;
-        struct dentry *dentry;
-        struct presto_file_set *fset;
-        struct nameidata nd;
-
-        ENTRY;
-        name = getname(pathname);
-        if(IS_ERR(name)) {
-                EXIT;
-                return PTR_ERR(name);
-        }
-
-        error = path_lookup(name, LOOKUP_PARENT, &nd);
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-        switch(nd.last_type) {
-        case LAST_DOTDOT:
-                error = -ENOTEMPTY;
-                EXIT;
-                goto exit1;
-        case LAST_ROOT:
-        case LAST_DOT:
-                error = -EBUSY;
-                EXIT;
-                goto exit1;
-        }
-        down(&nd.dentry->d_inode->i_sem);
-        dentry = lookup_hash(&nd.last, nd.dentry);
-        error = PTR_ERR(dentry);
-        if (!IS_ERR(dentry)) {
-                fset = presto_fset(dentry);
-                error = -EINVAL;
-                if ( !fset ) {
-                        CERROR("No fileset!\n");
-                        EXIT;
-                        goto exit_put;
-                }
-                error = presto_do_rmdir(fset, nd.dentry, dentry, info);
-        exit_put:
-                dput(dentry);
-        }
-        up(&nd.dentry->d_inode->i_sem);
-exit1:
-        path_release(&nd);
-exit:
-        putname(name);
-        EXIT;
-        return error;
-}
-
-int presto_do_mknod(struct presto_file_set *fset, struct dentry *dir,
-                    struct dentry *dentry, int mode, dev_t dev,
-                    struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        int error = -EPERM;
-        struct presto_version tgt_dir_ver, new_node_ver;
-        struct inode_operations *iops;
-        void *handle;
-
-        ENTRY;
-
-        //        down(&dir->d_inode->i_zombie);
-        /* one KML entry */ 
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH); 
-        if (error) {
-                EXIT;
-                //                up(&dir->d_inode->i_zombie);
-                return error;
-        }
-
-        if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        error = may_create(dir->d_inode, dentry);
-        if (error) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        error = -EPERM;
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-        if (!iops->mknod) {
-                EXIT;
-                goto exit_lock;
-        }
-
-        DQUOT_INIT(dir->d_inode);
-        lock_kernel();
-        
-        error = -ENOSPC;
-        presto_getversion(&tgt_dir_ver, dir->d_inode);
-        handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_MKNOD);
-        if ( IS_ERR(handle) ) {
-                presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-                CERROR("presto_do_mknod: no space for transaction\n");
-                goto exit_lock2;
-        }
-
-        error = iops->mknod(dir->d_inode, dentry, mode, dev);
-        if (error) {
-                EXIT;
-                goto exit_commit;
-        }
-        if ( dentry->d_inode) {
-                struct presto_cache *cache = fset->fset_cache;
-
-                presto_set_ops(dentry->d_inode, cache->cache_filter);
-
-                filter_setup_dentry_ops(cache->cache_filter, dentry->d_op, 
-                                        &presto_dentry_ops);
-                dentry->d_op = filter_c2udops(cache->cache_filter);
-
-                /* if Lento does this, we won't have data */
-                if ( ISLENTO(presto_c2m(cache)) ) {
-                        presto_set(dentry, PRESTO_ATTR);
-                } else {
-                        presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
-                }
-        }
-
-        error = presto_settime(fset, NULL, NULL, dir,
-                               info, ATTR_MTIME);
-        if (error) { 
-                EXIT;
-        }
-        error = presto_settime(fset, NULL, NULL, dentry,
-                               info, ATTR_CTIME | ATTR_MTIME);
-        if (error) { 
-                EXIT;
-        }
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_MKNOD | 0x10);
-        presto_getversion(&new_node_ver, dentry->d_inode);
-        if ( presto_do_kml(info, dentry) )
-                error = presto_journal_mknod(&rec, fset, dentry, &tgt_dir_ver,
-                                             &new_node_ver, 
-                                             dentry->d_inode->i_mode,
-                                             MAJOR(dev), MINOR(dev) );
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_MKNOD | 0x20);
-        if ( presto_do_rcvd(info, dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_MKNOD | 0x30);
-        EXIT;
- exit_commit:
-        presto_trans_commit(fset, handle);
- exit_lock2:
-        unlock_kernel();
- exit_lock:
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-        //        up(&dir->d_inode->i_zombie);
-        return error;
-}
-
-int lento_mknod(const char *filename, int mode, dev_t dev,
-                struct lento_vfs_context *info)
-{
-        int error = 0;
-        char * tmp;
-        struct dentry * dentry;
-        struct nameidata nd;
-        struct presto_file_set *fset;
-
-        ENTRY;
-
-        if (S_ISDIR(mode))
-                return -EPERM;
-        tmp = getname(filename);
-        if (IS_ERR(tmp))
-                return PTR_ERR(tmp);
-
-        error = path_lookup(tmp, LOOKUP_PARENT, &nd);
-        if (error)
-                goto out;
-        dentry = lookup_create(&nd, 0);
-        error = PTR_ERR(dentry);
-        if (!IS_ERR(dentry)) {
-                fset = presto_fset(dentry);
-                error = -EINVAL;
-                if ( !fset ) {
-                        CERROR("No fileset!\n");
-                        EXIT;
-                        goto exit_put;
-                }
-                switch (mode & S_IFMT) {
-                case 0: case S_IFREG:
-                        error = -EOPNOTSUPP;
-                        break;
-                case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
-                        error = presto_do_mknod(fset, nd.dentry, dentry, 
-                                                mode, dev, info);
-                        break;
-                case S_IFDIR:
-                        error = -EPERM;
-                        break;
-                default:
-                        error = -EINVAL;
-                }
-        exit_put:
-                dput(dentry);
-        }
-        up(&nd.dentry->d_inode->i_sem);
-        path_release(&nd);
-out:
-        putname(tmp);
-
-        return error;
-}
-
-int do_rename(struct presto_file_set *fset,
-                     struct dentry *old_parent, struct dentry *old_dentry,
-                     struct dentry *new_parent, struct dentry *new_dentry,
-                     struct lento_vfs_context *info)
-{
-        struct rec_info rec;
-        int error;
-        struct inode_operations *iops;
-        struct presto_version src_dir_ver, tgt_dir_ver;
-        void *handle;
-        int new_inode_unlink = 0;
-        struct inode *old_dir = old_parent->d_inode;
-        struct inode *new_dir = new_parent->d_inode;
-
-        ENTRY;
-        presto_getversion(&src_dir_ver, old_dir);
-        presto_getversion(&tgt_dir_ver, new_dir);
-
-        error = -EPERM;
-        iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-        if (!iops || !iops->rename) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH); 
-        if (error) {
-                EXIT;
-                return error;
-        }
-        handle = presto_trans_start(fset, old_dir, KML_OPCODE_RENAME);
-        if ( IS_ERR(handle) ) {
-                presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-                CERROR("presto_do_rename: no space for transaction\n");
-                return -ENOSPC;
-        }
-        if (new_dentry->d_inode && new_dentry->d_inode->i_nlink > 1) { 
-                dget(new_dentry); 
-                new_inode_unlink = 1;
-        }
-
-        error = iops->rename(old_dir, old_dentry, new_dir, new_dentry);
-
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-
-        if (new_inode_unlink) { 
-                error = presto_settime(fset, NULL, NULL, old_dentry,
-                                       info, ATTR_CTIME);
-                dput(old_dentry); 
-                if (error) { 
-                        EXIT;
-                        goto exit;
-                }
-        }
-        info->flags |= LENTO_FL_TOUCH_PARENT;
-        error = presto_settime(fset, NULL, new_parent, old_parent,
-                               info, ATTR_CTIME | ATTR_MTIME);
-        if (error) { 
-                EXIT;
-                goto exit;
-        }
-
-        /* XXX make a distinction between cross file set
-         * and intra file set renames here
-         */
-        presto_debug_fail_blkdev(fset, KML_OPCODE_RENAME | 0x10);
-        if ( presto_do_kml(info, old_dentry) )
-                error = presto_journal_rename(&rec, fset, old_dentry,
-                                              new_dentry,
-                                              &src_dir_ver, &tgt_dir_ver);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_RENAME | 0x20);
-
-        if ( presto_do_rcvd(info, old_dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_RENAME | 0x30);
-        EXIT;
-exit:
-        presto_trans_commit(fset, handle);
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-        return error;
-}
-
-static
-int presto_rename_dir(struct presto_file_set *fset, struct dentry *old_parent,
-                      struct dentry *old_dentry, struct dentry *new_parent,
-                      struct dentry *new_dentry, struct lento_vfs_context *info)
-{
-        int error;
-        struct inode *target;
-        struct inode *old_dir = old_parent->d_inode;
-        struct inode *new_dir = new_parent->d_inode;
-
-        if (old_dentry->d_inode == new_dentry->d_inode)
-                return 0;
-
-        error = may_delete(old_dir, old_dentry, 1);
-        if (error)
-                return error;
-
-        if (new_dir->i_sb != old_dir->i_sb)
-                return -EXDEV;
-
-        if (!new_dentry->d_inode)
-                error = may_create(new_dir, new_dentry);
-        else
-                error = may_delete(new_dir, new_dentry, 1);
-        if (error)
-                return error;
-
-        if (!old_dir->i_op || !old_dir->i_op->rename)
-                return -EPERM;
-
-        /*
-         * If we are going to change the parent - check write permissions,
-         * we'll need to flip '..'.
-         */
-        if (new_dir != old_dir) {
-                error = permission(old_dentry->d_inode, MAY_WRITE, NULL);
-        }
-        if (error)
-                return error;
-
-        DQUOT_INIT(old_dir);
-        DQUOT_INIT(new_dir);
-        down(&old_dir->i_sb->s_vfs_rename_sem);
-        error = -EINVAL;
-        if (is_subdir(new_dentry, old_dentry))
-                goto out_unlock;
-        target = new_dentry->d_inode;
-        if (target) { /* Hastur! Hastur! Hastur! */
-                //                triple_down(&old_dir->i_zombie,
-                //                            &new_dir->i_zombie,
-                //                            &target->i_zombie);
-                d_unhash(new_dentry);
-        } else
-                //                double_down(&old_dir->i_zombie,
-                //                            &new_dir->i_zombie);
-        if (IS_DEADDIR(old_dir)||IS_DEADDIR(new_dir))
-                error = -ENOENT;
-        else if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
-                error = -EBUSY;
-        else 
-                error = do_rename(fset, old_parent, old_dentry,
-                                         new_parent, new_dentry, info);
-        if (target) {
-                if (!error)
-                        target->i_flags |= S_DEAD;
-                //                triple_up(&old_dir->i_zombie,
-                //                          &new_dir->i_zombie,
-                //                          &target->i_zombie);
-                if (d_unhashed(new_dentry))
-                        d_rehash(new_dentry);
-                dput(new_dentry);
-        } else
-                //                double_up(&old_dir->i_zombie,
-                //                          &new_dir->i_zombie);
-                
-        if (!error)
-                d_move(old_dentry,new_dentry);
-out_unlock:
-        up(&old_dir->i_sb->s_vfs_rename_sem);
-        return error;
-}
-
-static
-int presto_rename_other(struct presto_file_set *fset, struct dentry *old_parent,
-                        struct dentry *old_dentry, struct dentry *new_parent,
-                        struct dentry *new_dentry, struct lento_vfs_context *info)
-{
-        struct inode *old_dir = old_parent->d_inode;
-        struct inode *new_dir = new_parent->d_inode;
-        int error;
-
-        if (old_dentry->d_inode == new_dentry->d_inode)
-                return 0;
-
-        error = may_delete(old_dir, old_dentry, 0);
-        if (error)
-                return error;
-
-        if (new_dir->i_sb != old_dir->i_sb)
-                return -EXDEV;
-
-        if (!new_dentry->d_inode)
-                error = may_create(new_dir, new_dentry);
-        else
-                error = may_delete(new_dir, new_dentry, 0);
-        if (error)
-                return error;
-
-        if (!old_dir->i_op || !old_dir->i_op->rename)
-                return -EPERM;
-
-        DQUOT_INIT(old_dir);
-        DQUOT_INIT(new_dir);
-        //        double_down(&old_dir->i_zombie, &new_dir->i_zombie);
-        if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
-                error = -EBUSY;
-        else
-                error = do_rename(fset, old_parent, old_dentry,
-                                  new_parent, new_dentry, info);
-        //        double_up(&old_dir->i_zombie, &new_dir->i_zombie);
-        if (error)
-                return error;
-        /* The following d_move() should become unconditional */
-        if (!(old_dir->i_sb->s_type->fs_flags & FS_ODD_RENAME)) {
-                d_move(old_dentry, new_dentry);
-        }
-        return 0;
-}
-
-int presto_do_rename(struct presto_file_set *fset, 
-              struct dentry *old_parent, struct dentry *old_dentry,
-              struct dentry *new_parent, struct dentry *new_dentry,
-              struct lento_vfs_context *info)
-{
-        if (S_ISDIR(old_dentry->d_inode->i_mode))
-                return presto_rename_dir(fset, old_parent,old_dentry,new_parent,
-                                      new_dentry, info);
-        else
-                return presto_rename_other(fset, old_parent, old_dentry,
-                                           new_parent,new_dentry, info);
-}
-
-
-int lento_do_rename(const char *oldname, const char *newname,
-                 struct lento_vfs_context *info)
-{
-        int error = 0;
-        struct dentry * old_dir, * new_dir;
-        struct dentry * old_dentry, *new_dentry;
-        struct nameidata oldnd, newnd;
-        struct presto_file_set *fset;
-
-        ENTRY;
-
-        error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
-        if (error)
-                goto exit;
-
-        error = path_lookup(newname, LOOKUP_PARENT, &newnd);
-        if (error)
-                goto exit1;
-
-        error = -EXDEV;
-        if (oldnd.mnt != newnd.mnt)
-                goto exit2;
-
-        old_dir = oldnd.dentry;
-        error = -EBUSY;
-        if (oldnd.last_type != LAST_NORM)
-                goto exit2;
-
-        new_dir = newnd.dentry;
-        if (newnd.last_type != LAST_NORM)
-                goto exit2;
-
-        lock_rename(new_dir, old_dir);
-
-        old_dentry = lookup_hash(&oldnd.last, old_dir);
-        error = PTR_ERR(old_dentry);
-        if (IS_ERR(old_dentry))
-                goto exit3;
-        /* source must exist */
-        error = -ENOENT;
-        if (!old_dentry->d_inode)
-                goto exit4;
-        fset = presto_fset(old_dentry);
-        error = -EINVAL;
-        if ( !fset ) {
-                CERROR("No fileset!\n");
-                EXIT;
-                goto exit4;
-        }
-        /* unless the source is a directory trailing slashes give -ENOTDIR */
-        if (!S_ISDIR(old_dentry->d_inode->i_mode)) {
-                error = -ENOTDIR;
-                if (oldnd.last.name[oldnd.last.len])
-                        goto exit4;
-                if (newnd.last.name[newnd.last.len])
-                        goto exit4;
-        }
-        new_dentry = lookup_hash(&newnd.last, new_dir);
-        error = PTR_ERR(new_dentry);
-        if (IS_ERR(new_dentry))
-                goto exit4;
-
-        lock_kernel();
-        error = presto_do_rename(fset, old_dir, old_dentry,
-                                   new_dir, new_dentry, info);
-        unlock_kernel();
-
-        dput(new_dentry);
-exit4:
-        dput(old_dentry);
-exit3:
-        unlock_rename(new_dir, old_dir);
-exit2:
-        path_release(&newnd);
-exit1:
-        path_release(&oldnd);
-exit:
-        return error;
-}
-
-int  lento_rename(const char * oldname, const char * newname,
-                  struct lento_vfs_context *info)
-{
-        int error;
-        char * from;
-        char * to;
-
-        from = getname(oldname);
-        if(IS_ERR(from))
-                return PTR_ERR(from);
-        to = getname(newname);
-        error = PTR_ERR(to);
-        if (!IS_ERR(to)) {
-                error = lento_do_rename(from,to, info);
-                putname(to);
-        } 
-        putname(from);
-        return error;
-}
-
-struct dentry *presto_iopen(struct dentry *dentry,
-                            ino_t ino, unsigned int generation)
-{
-        struct presto_file_set *fset;
-        char name[48];
-        int error;
-
-        ENTRY;
-        /* see if we already have the dentry we want */
-        if (dentry->d_inode && dentry->d_inode->i_ino == ino &&
-            dentry->d_inode->i_generation == generation) {
-                EXIT;
-                return dentry;
-        }
-
-        /* Make sure we have a cache beneath us.  We should always find at
-         * least one dentry inside the cache (if it exists), otherwise not
-         * even the cache root exists, or we passed in a bad name.
-         */
-        fset = presto_fset(dentry);
-        error = -EINVAL;
-        if (!fset) {
-                CERROR("No fileset for %*s!\n",
-                       dentry->d_name.len, dentry->d_name.name);
-                EXIT;
-                dput(dentry);
-                return ERR_PTR(error);
-        }
-        dput(dentry);
-
-        sprintf(name, "%s%#lx%c%#x",
-                PRESTO_ILOOKUP_MAGIC, ino, PRESTO_ILOOKUP_SEP, generation);
-        CDEBUG(D_PIOCTL, "opening %ld by number (as %s)\n", ino, name);
-        return lookup_one_len(name, fset->fset_dentry, strlen(name));
-}
-
-static struct file *presto_filp_dopen(struct dentry *dentry, int flags)
-{
-        struct file *f;
-        struct inode *inode;
-        int flag, error;
-
-        ENTRY;
-        error = -ENFILE;
-        f = get_empty_filp();
-        if (!f) {
-                CDEBUG(D_PIOCTL, "error getting file pointer\n");
-                EXIT;
-                goto out;
-        }
-        f->f_flags = flag = flags;
-        f->f_mode = (flag+1) & O_ACCMODE;
-        inode = dentry->d_inode;
-        if (f->f_mode & FMODE_WRITE) {
-                error = get_write_access(inode);
-                if (error) {
-                        CDEBUG(D_PIOCTL, "error getting write access\n");
-                        EXIT;                        goto cleanup_file;
-                }
-        }
-
-       /* XXX: where the fuck is ->f_vfsmnt? */
-        f->f_dentry = dentry;
-        f->f_mapping = dentry->d_inode->i_mapping;
-        f->f_pos = 0;
-        //f->f_reada = 0;
-        f->f_op = NULL;
-        if (inode->i_op)
-                /* XXX should we set to presto ops, or leave at cache ops? */
-                f->f_op = inode->i_fop;
-        if (f->f_op && f->f_op->open) {
-                error = f->f_op->open(inode, f);
-                if (error) {
-                        CDEBUG(D_PIOCTL, "error calling cache 'open'\n");
-                        EXIT;
-                        goto cleanup_all;
-                }
-        }
-        f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
-
-        return f;
-
-cleanup_all:
-        if (f->f_mode & FMODE_WRITE)
-                put_write_access(inode);
-cleanup_file:
-        put_filp(f);
-out:
-        return ERR_PTR(error);
-}
-
-
-/* Open an inode by number.  We pass in the cache root name (or a subdirectory
- * from the cache that is guaranteed to exist) to be able to access the cache.
- */
-int lento_iopen(const char *name, ino_t ino, unsigned int generation,
-                int flags)
-{
-        char * tmp;
-        struct dentry *dentry;
-        struct nameidata nd;
-        int fd;
-        int error;
-
-        ENTRY;
-        CDEBUG(D_PIOCTL,
-               "open %s:inode %#lx (%ld), generation %x (%d), flags %d \n",
-               name, ino, ino, generation, generation, flags);
-        /* We don't allow creation of files by number only, as it would
-         * lead to a dangling files not in any directory.  We could also
-         * just turn off the flag and ignore it.
-         */
-        if (flags & O_CREAT) {
-                CERROR("%s: create file by inode number (%ld) not allowed\n",
-                       __FUNCTION__, ino);
-                EXIT;
-                return -EACCES;
-        }
-
-        tmp = getname(name);
-        if (IS_ERR(tmp)) {
-                EXIT;
-                return PTR_ERR(tmp);
-        }
-
-        lock_kernel();
-again:  /* look the named file or a parent directory so we can get the cache */
-        error = presto_walk(tmp, &nd);
-        if ( error && error != -ENOENT ) {
-                EXIT;
-                unlock_kernel();
-               putname(tmp);
-                return error;
-        } 
-        if (error == -ENOENT)
-                dentry = NULL;
-        else 
-                dentry = nd.dentry;
-
-        /* we didn't find the named file, so see if a parent exists */
-        if (!dentry) {
-                char *slash;
-
-                slash = strrchr(tmp, '/');
-                if (slash && slash != tmp) {
-                        *slash = '\0';
-                        path_release(&nd);
-                        goto again;
-                }
-                /* we should never get here... */
-                CDEBUG(D_PIOCTL, "no more path components to try!\n");
-                fd = -ENOENT;
-                goto exit;
-        }
-        CDEBUG(D_PIOCTL, "returned dentry %p\n", dentry);
-
-        dentry = presto_iopen(dentry, ino, generation);
-        fd = PTR_ERR(dentry);
-        if (IS_ERR(dentry)) {
-                EXIT;
-                goto exit;
-        }
-
-        /* XXX start of code that might be replaced by something like:
-         * if (flags & (O_WRONLY | O_RDWR)) {
-         *      error = get_write_access(dentry->d_inode);
-         *      if (error) {
-         *              EXIT;
-         *              goto cleanup_dput;
-         *      }
-         * }
-         * fd = open_dentry(dentry, flags);
-         *
-         * including the presto_filp_dopen() function (check dget counts!)
-         */
-        fd = get_unused_fd();
-        if (fd < 0) {
-                EXIT;
-                goto exit;
-        }
-
-        {
-                int error;
-                struct file * f = presto_filp_dopen(dentry, flags);
-                error = PTR_ERR(f);
-                if (IS_ERR(f)) {
-                        put_unused_fd(fd);
-                        fd = error;
-                } else {
-                       fd_install(fd, f);
-               }
-        }
-        /* end of code that might be replaced by open_dentry */
-
-        EXIT;
-exit:
-        unlock_kernel();
-        path_release(&nd);
-        putname(tmp);
-        return fd;
-}
-
-#ifdef CONFIG_FS_EXT_ATTR
-
-#if 0 /* was a broken check for Posix ACLs */
-/* Posix ACL code changes i_mode without using a notify_change (or
- * a mark_inode_dirty!). We need to duplicate this at the reintegrator
- * which is done by this function. This function also takes care of 
- * resetting the cached posix acls in this inode. If we don't reset these
- * VFS continues using the old acl information, which by now may be out of
- * date.
- */
-int presto_setmode(struct presto_file_set *fset, struct dentry *dentry,
-                   mode_t mode)
-{
-        struct inode *inode = dentry->d_inode;
-
-        ENTRY;
-        /* The extended attributes for this inode were modified. 
-         * At this point we can not be sure if any of the ACL 
-         * information for this inode was updated. So we will 
-         * force VFS to reread the acls. Note that we do this 
-         * only when called from the SETEXTATTR ioctl, which is why we
-         * do this while setting the mode of the file. Also note
-         * that mark_inode_dirty is not be needed for i_*acl only
-         * to force i_mode info to disk, and should be removed once
-         * we use notify_change to update the mode.
-         * XXX: is mode setting really needed? Just setting acl's should
-         * be enough! VFS should change the i_mode as needed? SHP
-         */
-        if (inode->i_acl && 
-            inode->i_acl != POSIX_ACL_NOT_CACHED) 
-            posix_acl_release(inode->i_acl);
-        if (inode->i_default_acl && 
-            inode->i_default_acl != POSIX_ACL_NOT_CACHED) 
-            posix_acl_release(inode->i_default_acl);
-        inode->i_acl = POSIX_ACL_NOT_CACHED;
-        inode->i_default_acl = POSIX_ACL_NOT_CACHED;
-        inode->i_mode = mode;
-        /* inode should already be dirty...but just in case */
-        mark_inode_dirty(inode);
-        return 0;
-
-#if 0
-        /* XXX: The following code is the preferred way to set mode, 
-         * however, I need to carefully go through possible recursion
-         * paths back into presto. See comments in presto_do_setattr.
-         */
-        {    
-        int error=0; 
-        struct super_operations *sops;
-        struct iattr iattr;
-
-        iattr.ia_mode = mode;
-        iattr.ia_valid = ATTR_MODE|ATTR_FORCE;
-
-        error = -EPERM;
-        sops = filter_c2csops(fset->fset_cache->cache_filter); 
-        if (!sops &&
-            !sops->notify_change) {
-                EXIT;
-                return error;
-        }
-
-        error = sops->notify_change(dentry, &iattr);
-
-        EXIT;
-        return error;
-        }
-#endif
-}
-#endif
-
-/* setextattr Interface to cache filesystem */
-int presto_do_set_ext_attr(struct presto_file_set *fset, 
-                           struct dentry *dentry, 
-                           const char *name, void *buffer,
-                           size_t buffer_len, int flags, mode_t *mode,
-                           struct lento_vfs_context *info) 
-{
-        struct rec_info rec;
-        struct inode *inode = dentry->d_inode;
-        struct inode_operations *iops;
-        int error;
-        struct presto_version ver;
-        void *handle;
-        char temp[PRESTO_EXT_ATTR_NAME_MAX+1];
-
-        ENTRY;
-        error = -EROFS;
-        if (IS_RDONLY(inode)) {
-                EXIT;
-                return -EROFS;
-        }
-
-        if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
-                EXIT;
-                return -EPERM;
-        }
-
-        presto_getversion(&ver, inode);
-        error = -EPERM;
-        /* We need to invoke different filters based on whether
-         * this dentry is a regular file, directory or symlink.
-         */
-        switch (inode->i_mode & S_IFMT) {
-                case S_IFLNK: /* symlink */
-                    iops = filter_c2csiops(fset->fset_cache->cache_filter); 
-                    break;
-                case S_IFDIR: /* directory */
-                    iops = filter_c2cdiops(fset->fset_cache->cache_filter); 
-                    break;
-                case S_IFREG:
-                default: /* everything else including regular files */
-                    iops = filter_c2cfiops(fset->fset_cache->cache_filter); 
-        }
-
-        if (!iops && !iops->set_ext_attr) {
-                EXIT;
-                return error;
-        }
-
-        error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH); 
-        if (error) {
-                EXIT;
-                return error;
-        }
-
-        
-        handle = presto_trans_start(fset,dentry->d_inode,KML_OPCODE_SETEXTATTR);
-        if ( IS_ERR(handle) ) {
-                CERROR("presto_do_set_ext_attr: no space for transaction\n");
-                presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-                return -ENOSPC;
-        }
-
-        /* We first "truncate" name to the maximum allowable in presto */
-        /* This simulates the strncpy_from_use code in fs/ext_attr.c */
-        strlcpy(temp,name,sizeof(temp));
-
-        /* Pass down to cache*/
-        error = iops->set_ext_attr(inode,temp,buffer,buffer_len,flags);
-        if (error) {
-                EXIT;
-                goto exit;
-        }
-
-#if 0 /* was a broken check for Posix ACLs */
-        /* Reset mode if specified*/
-        /* XXX: when we do native acl support, move this code out! */
-        if (mode != NULL) {
-                error = presto_setmode(fset, dentry, *mode);
-                if (error) { 
-                    EXIT;
-                    goto exit;
-                }
-        }
-#endif
-
-        /* Reset ctime. Only inode change time (ctime) is affected */
-        error = presto_settime(fset, NULL, NULL, dentry, info, ATTR_CTIME);
-        if (error) { 
-                EXIT;
-                goto exit;
-        }
-
-        if (flags & EXT_ATTR_FLAG_USER) {
-                CERROR(" USER flag passed to presto_do_set_ext_attr!\n");
-                BUG();
-        }
-
-        /* We are here, so set_ext_attr succeeded. We no longer need to keep
-         * track of EXT_ATTR_FLAG_{EXISTS,CREATE}, instead, we will force
-         * the attribute value during log replay. -SHP
-         */
-        flags &= ~(EXT_ATTR_FLAG_EXISTS | EXT_ATTR_FLAG_CREATE);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SETEXTATTR | 0x10);
-        if ( presto_do_kml(info, dentry) )
-                error = presto_journal_set_ext_attr
-                        (&rec, fset, dentry, &ver, name, buffer, 
-                         buffer_len, flags);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SETEXTATTR | 0x20);
-        if ( presto_do_rcvd(info, dentry) )
-                error = presto_write_last_rcvd(&rec, fset, info);
-
-        presto_debug_fail_blkdev(fset, KML_OPCODE_SETEXTATTR | 0x30);
-        EXIT;
-exit:
-        presto_release_space(fset->fset_cache, PRESTO_REQHIGH); 
-        presto_trans_commit(fset, handle);
-
-        return error;
-}
-#endif
index c84ce99..96a1b60 100644 (file)
 #include <linux/fs.h>
 #include <linux/security.h>
 #include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/vserver/inode.h>
+#include <linux/vserver/xid.h>
+#include <linux/module.h>
 
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
 
+#ifdef CONFIG_VSERVER_LEGACY           
+extern int vx_proc_ioctl(struct inode *, struct file *,
+       unsigned int, unsigned long);
+#endif
+
 static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
 {
        int error;
@@ -122,6 +131,48 @@ asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
                        else
                                error = -ENOTTY;
                        break;
+#ifdef CONFIG_VSERVER_LEGACY           
+#ifndef CONFIG_INOXID_NONE
+               case FIOC_GETXID: {
+                       struct inode *inode = filp->f_dentry->d_inode;
+
+                       /* fixme: if stealth, return -ENOTTY */
+                       error = -EPERM;
+                       if (capable(CAP_CONTEXT))
+                               error = put_user(inode->i_xid, (int *) arg);
+                       break;
+               }
+               case FIOC_SETXID: {
+                       struct inode *inode = filp->f_dentry->d_inode;
+                       int xid;
+
+                       /* fixme: if stealth, return -ENOTTY */
+                       error = -EPERM;
+                       if (!capable(CAP_CONTEXT))
+                               break;
+                       error = -EROFS;
+                       if (IS_RDONLY(inode))
+                               break;
+                       error = -ENOSYS;
+                       if (!(inode->i_sb->s_flags & MS_TAGXID))
+                               break;
+                       error = -EFAULT;
+                       if (get_user(xid, (int *) arg))
+                               break;
+                       error = 0;
+                       inode->i_xid = (xid & 0xFFFF);
+                       inode->i_ctime = CURRENT_TIME;
+                       mark_inode_dirty(inode);
+                       break;  
+               }
+#endif
+               case FIOC_GETXFLG:
+               case FIOC_SETXFLG:
+                       error = -ENOTTY;
+                       if (filp->f_dentry->d_inode->i_sb->s_magic == PROC_SUPER_MAGIC)
+                               error = vx_proc_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+                       break;
+#endif
                default:
                        error = -ENOTTY;
                        if (S_ISREG(filp->f_dentry->d_inode->i_mode))
index a540c7f..9645163 100644 (file)
@@ -545,6 +545,7 @@ wait_for_iobuf:
                        wait_on_buffer(bh);
                        goto wait_for_iobuf;
                }
+               cond_resched();
 
                if (unlikely(!buffer_uptodate(bh)))
                        err = -EIO;
@@ -599,6 +600,7 @@ wait_for_iobuf:
                        wait_on_buffer(bh);
                        goto wait_for_ctlbuf;
                }
+               cond_resched();
 
                if (unlikely(!buffer_uptodate(bh)))
                        err = -EIO;
@@ -764,6 +766,7 @@ skip_commit: /* The journal should be unlocked by now. */
                        release_buffer_page(bh);
                }
                spin_unlock(&journal->j_list_lock);
+               cond_resched();
        }
 
        /* Done with this transaction! */
index 87cd050..df95ec1 100644 (file)
@@ -332,6 +332,7 @@ int journal_revoke(handle_t *handle, unsigned long blocknr,
        struct block_device *bdev;
        int err;
 
+       might_sleep();
        if (bh_in)
                BUFFER_TRACE(bh_in, "enter");
 
diff --git a/fs/jffs2/compr.h b/fs/jffs2/compr.h
deleted file mode 100644 (file)
index 6777d8c..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * JFFS2 -- Journalling Flash File System, Version 2.
- *
- * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
- *                    University of Szeged, Hungary
- *
- * For licensing information, see the file 'LICENCE' in the 
- * jffs2 directory.
- *
- * $Id: compr.h,v 1.6 2004/07/16 15:17:57 dwmw2 Exp $
- *
- */
-
-#ifndef __JFFS2_COMPR_H__
-#define __JFFS2_COMPR_H__
-
-#include <linux/kernel.h>
-#include <linux/vmalloc.h>
-#include <linux/list.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/jffs2.h>
-#include <linux/jffs2_fs_i.h>
-#include <linux/jffs2_fs_sb.h>
-#include "nodelist.h"
-
-#define JFFS2_RUBINMIPS_PRIORITY 10
-#define JFFS2_DYNRUBIN_PRIORITY  20
-#define JFFS2_LZARI_PRIORITY     30
-#define JFFS2_LZO_PRIORITY       40
-#define JFFS2_RTIME_PRIORITY     50
-#define JFFS2_ZLIB_PRIORITY      60
-
-#define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
-#define JFFS2_DYNRUBIN_DISABLED  /*        for decompression */
-
-#define JFFS2_COMPR_MODE_NONE       0
-#define JFFS2_COMPR_MODE_PRIORITY   1
-#define JFFS2_COMPR_MODE_SIZE       2
-
-void jffs2_set_compression_mode(int mode);
-int jffs2_get_compression_mode(void);
-
-struct jffs2_compressor {
-        struct list_head list;
-        int priority;              /* used by prirority comr. mode */
-        char *name;
-        char compr;                /* JFFS2_COMPR_XXX */
-        int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
-                        uint32_t *srclen, uint32_t *destlen, void *model);
-        int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
-                        uint32_t cdatalen, uint32_t datalen, void *model);
-        int usecount;
-        int disabled;              /* if seted the compressor won't compress */
-        unsigned char *compr_buf;  /* used by size compr. mode */
-        uint32_t compr_buf_size;   /* used by size compr. mode */
-        uint32_t stat_compr_orig_size;
-        uint32_t stat_compr_new_size;
-        uint32_t stat_compr_blocks;
-        uint32_t stat_decompr_blocks;
-};
-
-int jffs2_register_compressor(struct jffs2_compressor *comp);
-int jffs2_unregister_compressor(struct jffs2_compressor *comp);
-
-int jffs2_compressors_init(void);
-int jffs2_compressors_exit(void);
-
-uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
-                             unsigned char *data_in, unsigned char **cpage_out,
-                             uint32_t *datalen, uint32_t *cdatalen);
-
-int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
-                     uint16_t comprtype, unsigned char *cdata_in,
-                     unsigned char *data_out, uint32_t cdatalen, uint32_t datalen);
-
-void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig);
-
-#ifdef CONFIG_JFFS2_PROC
-int jffs2_enable_compressor_name(const char *name);
-int jffs2_disable_compressor_name(const char *name);
-int jffs2_set_compression_mode_name(const char *mode_name);
-char *jffs2_get_compression_mode_name(void);
-int jffs2_set_compressor_priority(const char *mode_name, int priority);
-char *jffs2_list_compressors(void);
-char *jffs2_stats(void);
-#endif
-
-/* Compressor modules */
-/* These functions will be called by jffs2_compressors_init/exit */
-
-#ifdef CONFIG_JFFS2_RUBIN
-int jffs2_rubinmips_init(void);
-void jffs2_rubinmips_exit(void);
-int jffs2_dynrubin_init(void);
-void jffs2_dynrubin_exit(void);
-#endif
-#ifdef CONFIG_JFFS2_RTIME
-int jffs2_rtime_init(void);
-void jffs2_rtime_exit(void);
-#endif
-#ifdef CONFIG_JFFS2_ZLIB
-int jffs2_zlib_init(void);
-void jffs2_zlib_exit(void);
-#endif
-#ifdef CONFIG_JFFS2_LZARI
-int jffs2_lzari_init(void);
-void jffs2_lzari_exit(void);
-#endif
-#ifdef CONFIG_JFFS2_LZO
-int jffs2_lzo_init(void);
-void jffs2_lzo_exit(void);
-#endif
-
-#endif /* __JFFS2_COMPR_H__ */
index 8353f48..a1cef90 100644 (file)
@@ -136,7 +136,7 @@ int jfs_permission(struct inode * inode, int mask, struct nameidata *nd)
                /*
                 * Nobody gets write access to a read-only fs.
                 */
-               if (IS_RDONLY(inode) &&
+               if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
                    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                        return -EROFS;
 
index cfb582d..6a6f147 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
+#include <linux/vserver/xid.h>
 
 #include "jfs_incore.h"
 #include "jfs_filsys.h"
@@ -3104,14 +3105,21 @@ static void duplicateIXtree(struct super_block *sb, s64 blkno,
 static int copy_from_dinode(struct dinode * dip, struct inode *ip)
 {
        struct jfs_inode_info *jfs_ip = JFS_IP(ip);
+       uid_t uid;
+       gid_t gid;
 
        jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
        jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
 
        ip->i_mode = le32_to_cpu(dip->di_mode) & 0xffff;
        ip->i_nlink = le32_to_cpu(dip->di_nlink);
-       ip->i_uid = le32_to_cpu(dip->di_uid);
-       ip->i_gid = le32_to_cpu(dip->di_gid);
+
+       uid = le32_to_cpu(dip->di_uid);
+       gid = le32_to_cpu(dip->di_gid);
+       ip->i_uid = INOXID_UID(XID_TAG(ip), uid, gid);
+       ip->i_gid = INOXID_GID(XID_TAG(ip), uid, gid);
+       ip->i_xid = INOXID_XID(XID_TAG(ip), uid, gid, 0);
+       
        ip->i_size = le64_to_cpu(dip->di_size);
        ip->i_atime.tv_sec = le32_to_cpu(dip->di_atime.tv_sec);
        ip->i_atime.tv_nsec = le32_to_cpu(dip->di_atime.tv_nsec);
@@ -3162,6 +3170,8 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip)
 static void copy_to_dinode(struct dinode * dip, struct inode *ip)
 {
        struct jfs_inode_info *jfs_ip = JFS_IP(ip);
+       uid_t uid;
+       gid_t gid;
 
        dip->di_fileset = cpu_to_le32(jfs_ip->fileset);
        dip->di_inostamp = cpu_to_le32(JFS_SBI(ip->i_sb)->inostamp);
@@ -3170,8 +3180,11 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip)
        dip->di_size = cpu_to_le64(ip->i_size);
        dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
        dip->di_nlink = cpu_to_le32(ip->i_nlink);
-       dip->di_uid = cpu_to_le32(ip->i_uid);
-       dip->di_gid = cpu_to_le32(ip->i_gid);
+
+       uid = XIDINO_UID(XID_TAG(ip), ip->i_uid, ip->i_xid);
+       gid = XIDINO_GID(XID_TAG(ip), ip->i_gid, ip->i_xid);
+       dip->di_uid = cpu_to_le32(uid);
+       dip->di_gid = cpu_to_le32(gid);
        /*
         * mode2 is only needed for storing the higher order bits.
         * Trust i_mode for the lower order ones
index 59c6c49..f16c784 100644 (file)
@@ -70,6 +70,7 @@ nlmclnt_block(struct nlm_host *host, struct file_lock *fl, u32 *statp)
         * nlmclnt_lock for an explanation.
         */
        sleep_on_timeout(&block.b_wait, 30*HZ);
+       #warning race
 
        for (head = &nlm_blocked; *head; head = &(*head)->b_next) {
                if (*head == &block) {
index 3f170ce..17f4081 100644 (file)
@@ -27,6 +27,8 @@
 #include <linux/security.h>
 #include <linux/mount.h>
 #include <linux/audit.h>
+#include <linux/vs_base.h>
+
 #include <asm/namei.h>
 #include <asm/uaccess.h>
 
@@ -208,14 +210,35 @@ int vfs_permission(struct inode * inode, int mask)
        return -EACCES;
 }
 
+static inline int xid_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+       if (inode->i_xid == 0)
+               return 0;
+       if (vx_check(inode->i_xid, VX_ADMIN|VX_WATCH|VX_IDENT))
+               return 0;
+/*
+       printk("VSW: xid=%d denied access to %p[#%d,%lu] Â»%*s«.\n",
+               vx_current_xid(), inode, inode->i_xid, inode->i_ino,
+               nd->dentry->d_name.len, nd->dentry->d_name.name);
+*/
+       return -EACCES;
+}
+
 int permission(struct inode * inode,int mask, struct nameidata *nd)
 {
        int retval;
        int submask;
+       umode_t mode = inode->i_mode;
 
        /* Ordinary permission routines do not understand MAY_APPEND. */
        submask = mask & ~MAY_APPEND;
 
+       if (nd && (mask & MAY_WRITE) && MNT_IS_RDONLY(nd->mnt) &&
+               (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
+               return -EROFS;
+
+       if ((retval = xid_permission(inode, mask, nd)))
+               return retval;
        if (inode->i_op && inode->i_op->permission)
                retval = inode->i_op->permission(inode, submask, nd);
        else
@@ -658,9 +681,11 @@ int fastcall link_path_walk(const char * name, struct nameidata *nd)
 {
        struct path next;
        struct inode *inode;
-       int err;
+       int err, atomic;
        unsigned int lookup_flags = nd->flags;
-       
+
+       atomic = (lookup_flags & LOOKUP_ATOMIC);
+
        while (*name=='/')
                name++;
        if (!*name)
@@ -728,6 +753,9 @@ int fastcall link_path_walk(const char * name, struct nameidata *nd)
                        if (err < 0)
                                break;
                }
+               err = -EWOULDBLOCKIO;
+               if (atomic)
+                       break;
                nd->flags |= LOOKUP_CONTINUE;
                /* This does the actual lookups.. */
                err = do_lookup(nd, &this, &next);
@@ -792,6 +820,9 @@ last_component:
                        if (err < 0)
                                break;
                }
+               err = -EWOULDBLOCKIO;
+               if (atomic)
+                       break;
                err = do_lookup(nd, &this, &next);
                if (err)
                        break;
@@ -868,29 +899,31 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
                return 0;               /* something went wrong... */
 
        if (!nd->dentry->d_inode || S_ISDIR(nd->dentry->d_inode->i_mode)) {
-               struct nameidata nd_root;
+               struct dentry *old_dentry = nd->dentry;
+               struct vfsmount *old_mnt = nd->mnt;
+               struct qstr last = nd->last;
+               int last_type = nd->last_type;
                /*
                 * NAME was not found in alternate root or it's a directory.  Try to find
                 * it in the normal root:
                 */
-               nd_root.last_type = LAST_ROOT;
-               nd_root.flags = nd->flags;
-               nd_root.depth = 0;
-               memcpy(&nd_root.intent, &nd->intent, sizeof(nd_root.intent));
+               nd->last_type = LAST_ROOT;
                read_lock(&current->fs->lock);
-               nd_root.mnt = mntget(current->fs->rootmnt);
-               nd_root.dentry = dget(current->fs->root);
+               nd->mnt = mntget(current->fs->rootmnt);
+               nd->dentry = dget(current->fs->root);
                read_unlock(&current->fs->lock);
-               if (path_walk(name, &nd_root))
-                       return 1;
-               if (nd_root.dentry->d_inode) {
+               if (path_walk(name, nd) == 0) {
+                       if (nd->dentry->d_inode) {
+                               dput(old_dentry);
+                               mntput(old_mnt);
+                               return 1;
+                       }
                        path_release(nd);
-                       nd->dentry = nd_root.dentry;
-                       nd->mnt = nd_root.mnt;
-                       nd->last = nd_root.last;
-                       return 1;
                }
-               path_release(&nd_root);
+               nd->dentry = old_dentry;
+               nd->mnt = old_mnt;
+               nd->last = last;
+               nd->last_type = last_type;
        }
        return 1;
 }
@@ -943,8 +976,7 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
                }
                nd->mnt = mntget(current->fs->rootmnt);
                nd->dentry = dget(current->fs->root);
-       }
-       else{
+       } else {
                nd->mnt = mntget(current->fs->pwdmnt);
                nd->dentry = dget(current->fs->pwd);
        }
@@ -1094,15 +1126,18 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
 static inline int may_delete(struct inode *dir,struct dentry *victim,int isdir)
 {
        int error;
-       if (!victim->d_inode || victim->d_parent->d_inode != dir)
+       if (!victim->d_inode)
                return -ENOENT;
+       if (victim->d_parent->d_inode != dir)
+               BUG();
+                       
        error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
        if (error)
                return error;
        if (IS_APPEND(dir))
                return -EPERM;
        if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
-           IS_IMMUTABLE(victim->d_inode))
+               IS_IXORUNLINK(victim->d_inode))
                return -EPERM;
        if (isdir) {
                if (!S_ISDIR(victim->d_inode->i_mode))
@@ -1136,6 +1171,24 @@ static inline int may_create(struct inode *dir, struct dentry *child,
        return permission(dir,MAY_WRITE | MAY_EXEC, nd);
 }
 
+static inline int mnt_may_create(struct vfsmount *mnt, struct inode *dir, struct dentry *child) {
+       if (child->d_inode)
+               return -EEXIST;
+       if (IS_DEADDIR(dir))
+               return -ENOENT;
+       if (mnt->mnt_flags & MNT_RDONLY)
+               return -EROFS;
+       return 0;
+}
+
+static inline int mnt_may_unlink(struct vfsmount *mnt, struct inode *dir, struct dentry *child) {
+       if (!child->d_inode)
+               return -ENOENT;
+       if (mnt->mnt_flags & MNT_RDONLY)
+               return -EROFS;
+       return 0;
+}
+
 /* 
  * Special case: O_CREAT|O_EXCL implies O_NOFOLLOW for security
  * reasons.
@@ -1154,6 +1207,8 @@ static inline int lookup_flags(unsigned int f)
        
        if (f & O_DIRECTORY)
                retval |= LOOKUP_DIRECTORY;
+       if (f & O_ATOMICLOOKUP)
+               retval |= LOOKUP_ATOMIC;
 
        return retval;
 }
@@ -1257,7 +1312,8 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
                        return -EACCES;
 
                flag &= ~O_TRUNC;
-       } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
+       } else if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt)))
+               && (flag & FMODE_WRITE))
                return -EROFS;
        /*
         * An append-only file must be opened in append mode for writing.
@@ -1495,23 +1551,28 @@ do_link:
 struct dentry *lookup_create(struct nameidata *nd, int is_dir)
 {
        struct dentry *dentry;
+       int error;
 
        down(&nd->dentry->d_inode->i_sem);
-       dentry = ERR_PTR(-EEXIST);
+       error = -EEXIST;
        if (nd->last_type != LAST_NORM)
-               goto fail;
+               goto out;
        nd->flags &= ~LOOKUP_PARENT;
        dentry = lookup_hash(&nd->last, nd->dentry);
        if (IS_ERR(dentry))
+               goto ret;
+       error = mnt_may_create(nd->mnt, nd->dentry->d_inode, dentry);
+       if (error)
                goto fail;
+       error = -ENOENT;
        if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
-               goto enoent;
+               goto fail;
+ret:
        return dentry;
-enoent:
-       dput(dentry);
-       dentry = ERR_PTR(-ENOENT);
 fail:
-       return dentry;
+       dput(dentry);
+out:
+       return ERR_PTR(error);
 }
 
 int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
@@ -1740,7 +1801,11 @@ asmlinkage long sys_rmdir(const char __user * pathname)
        dentry = lookup_hash(&nd.last, nd.dentry);
        error = PTR_ERR(dentry);
        if (!IS_ERR(dentry)) {
+               error = mnt_may_unlink(nd.mnt, nd.dentry->d_inode, dentry);
+               if (error)
+                       goto exit2;
                error = vfs_rmdir(nd.dentry->d_inode, dentry);
+       exit2:
                dput(dentry);
        }
        up(&nd.dentry->d_inode->i_sem);
@@ -1812,6 +1877,9 @@ asmlinkage long sys_unlink(const char __user * pathname)
                /* Why not before? Because we want correct error value */
                if (nd.last.name[nd.last.len])
                        goto slashes;
+               error = mnt_may_unlink(nd.mnt, nd.dentry->d_inode, dentry);
+               if (error)
+                       goto exit2;
                inode = dentry->d_inode;
                if (inode)
                        atomic_inc(&inode->i_count);
@@ -1909,7 +1977,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
        /*
         * A link to an append-only or immutable file cannot be created.
         */
-       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
+       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
                return -EPERM;
        if (!dir->i_op || !dir->i_op->link)
                return -EPERM;
@@ -1957,8 +2025,13 @@ asmlinkage long sys_link(const char __user * oldname, const char __user * newnam
        error = path_lookup(to, LOOKUP_PARENT, &nd);
        if (error)
                goto out;
-       error = -EXDEV;
-       if (old_nd.mnt != nd.mnt)
+       /*
+        * We allow hard-links to be created to a bind-mount as long
+        * as the bind-mount is not read-only.  Checking for cross-dev
+        * links is subsumed by the superblock check in vfs_link().
+        */
+       error = -EROFS;
+       if (MNT_IS_RDONLY(old_nd.mnt))
                goto out_release;
        new_dentry = lookup_create(&nd, 0);
        error = PTR_ERR(new_dentry);
@@ -2176,6 +2249,9 @@ static inline int do_rename(const char * oldname, const char * newname)
        error = -EINVAL;
        if (old_dentry == trap)
                goto exit4;
+       error = -EROFS;
+       if (MNT_IS_RDONLY(newnd.mnt))
+               goto exit4;
        new_dentry = lookup_hash(&newnd.last, new_dir);
        error = PTR_ERR(new_dentry);
        if (IS_ERR(new_dentry))
@@ -2299,12 +2375,8 @@ int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
 int page_follow_link_light(struct dentry *dentry, struct nameidata *nd)
 {
        struct page *page;
-       char *s = page_getlink(dentry, &page);
-       if (!IS_ERR(s)) {
-               nd_set_link(nd, s);
-               s = NULL;
-       }
-       return PTR_ERR(s);
+       nd_set_link(nd, page_getlink(dentry, &page));
+       return 0;
 }
 
 void page_put_link(struct dentry *dentry, struct nameidata *nd)
index 9e8350d..96a4d73 100644 (file)
@@ -21,6 +21,8 @@
 #include <linux/namei.h>
 #include <linux/security.h>
 #include <linux/mount.h>
+#include <linux/vs_base.h>
+
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
 
@@ -221,37 +223,44 @@ static int show_vfsmnt(struct seq_file *m, void *v)
        struct vfsmount *mnt = v;
        int err = 0;
        static struct proc_fs_info {
-               int flag;
-               char *str;
+               int s_flag;
+               int mnt_flag;
+               char *set_str;
+               char *unset_str;
        } fs_info[] = {
-               { MS_SYNCHRONOUS, ",sync" },
-               { MS_DIRSYNC, ",dirsync" },
-               { MS_MANDLOCK, ",mand" },
-               { MS_NOATIME, ",noatime" },
-               { MS_NODIRATIME, ",nodiratime" },
-               { 0, NULL }
-       };
-       static struct proc_fs_info mnt_info[] = {
-               { MNT_NOSUID, ",nosuid" },
-               { MNT_NODEV, ",nodev" },
-               { MNT_NOEXEC, ",noexec" },
-               { 0, NULL }
+               { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
+               { MS_SYNCHRONOUS, 0, ",sync", NULL },
+               { MS_DIRSYNC, 0, ",dirsync", NULL },
+               { MS_MANDLOCK, 0, ",mand", NULL },
+               { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
+               { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
+               { MS_TAGXID, MS_TAGXID, ",tagxid", NULL },
+               { 0, MNT_NOSUID, ",nosuid", NULL },
+               { 0, MNT_NODEV, ",nodev", NULL },
+               { 0, MNT_NOEXEC, ",noexec", NULL },
+               { 0, 0, NULL, NULL }
        };
-       struct proc_fs_info *fs_infop;
+       struct proc_fs_info *p;
+       unsigned long s_flags = mnt->mnt_sb->s_flags;
+       int mnt_flags = mnt->mnt_flags;
+
+       if (vx_flags(VXF_HIDE_MOUNT, 0))
+               return 0;
 
        mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
        seq_putc(m, ' ');
        seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
        seq_putc(m, ' ');
        mangle(m, mnt->mnt_sb->s_type->name);
-       seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
-       for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
-               if (mnt->mnt_sb->s_flags & fs_infop->flag)
-                       seq_puts(m, fs_infop->str);
-       }
-       for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
-               if (mnt->mnt_flags & fs_infop->flag)
-                       seq_puts(m, fs_infop->str);
+       seq_putc(m, ' ');
+       for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
+               if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
+                       if (p->set_str)
+                               seq_puts(m, p->set_str);
+               } else {
+                       if (p->unset_str)
+                               seq_puts(m, p->unset_str);
+               }
        }
        if (mnt->mnt_sb->s_op->show_options)
                err = mnt->mnt_sb->s_op->show_options(m, mnt);
@@ -338,18 +347,10 @@ int may_umount(struct vfsmount *mnt)
 
 EXPORT_SYMBOL(may_umount);
 
-void umount_tree(struct vfsmount *mnt)
+static inline void __umount_tree(struct vfsmount *mnt, struct list_head *kill)
 {
-       struct vfsmount *p;
-       LIST_HEAD(kill);
-
-       for (p = mnt; p; p = next_mnt(p, mnt)) {
-               list_del(&p->mnt_list);
-               list_add(&p->mnt_list, &kill);
-       }
-
-       while (!list_empty(&kill)) {
-               mnt = list_entry(kill.next, struct vfsmount, mnt_list);
+       while (!list_empty(kill)) {
+               mnt = list_entry(kill->next, struct vfsmount, mnt_list);
                list_del_init(&mnt->mnt_list);
                list_del_init(&mnt->mnt_fslink);
                if (mnt->mnt_parent == mnt) {
@@ -365,6 +366,32 @@ void umount_tree(struct vfsmount *mnt)
        }
 }
 
+void umount_tree(struct vfsmount *mnt)
+{
+       struct vfsmount *p;
+       LIST_HEAD(kill);
+
+       for (p = mnt; p; p = next_mnt(p, mnt)) {
+               list_del(&p->mnt_list);
+               list_add(&p->mnt_list, &kill);
+       }
+       __umount_tree(mnt, &kill);
+}
+
+void umount_unused(struct vfsmount *mnt, struct fs_struct *fs)
+{
+       struct vfsmount *p;
+       LIST_HEAD(kill);
+
+       for (p = mnt; p; p = next_mnt(p, mnt)) {
+               if (p == fs->rootmnt || p == fs->pwdmnt)
+                       continue;
+               list_del(&p->mnt_list);
+               list_add(&p->mnt_list, &kill);
+       }
+       __umount_tree(mnt, &kill);
+}
+
 static int do_umount(struct vfsmount *mnt, int flags)
 {
        struct super_block * sb = mnt->mnt_sb;
@@ -480,7 +507,7 @@ asmlinkage long sys_umount(char __user * name, int flags)
                goto dput_and_out;
 
        retval = -EPERM;
-       if (!capable(CAP_SYS_ADMIN))
+       if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SECURE_MOUNT))
                goto dput_and_out;
 
        retval = do_umount(nd.mnt, flags);
@@ -507,6 +534,8 @@ static int mount_is_safe(struct nameidata *nd)
 {
        if (capable(CAP_SYS_ADMIN))
                return 0;
+       if (vx_ccaps(VXC_SECURE_MOUNT))
+               return 0;
        return -EPERM;
 #ifdef notyet
        if (S_ISLNK(nd->dentry->d_inode->i_mode))
@@ -618,11 +647,13 @@ out_unlock:
 /*
  * do loopback mount.
  */
-static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
+static int do_loopback(struct nameidata *nd, char *old_name, unsigned long flags, int mnt_flags)
 {
        struct nameidata old_nd;
        struct vfsmount *mnt = NULL;
+       int recurse = flags & MS_REC;
        int err = mount_is_safe(nd);
+
        if (err)
                return err;
        if (!old_name || !*old_name)
@@ -654,6 +685,7 @@ static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
                        spin_unlock(&vfsmount_lock);
                } else
                        mntput(mnt);
+               mnt->mnt_flags = mnt_flags;
        }
 
        up_write(&current->namespace->sem);
@@ -769,7 +801,7 @@ static int do_new_mount(struct nameidata *nd, char *type, int flags,
                return -EINVAL;
 
        /* we need capabilities... */
-       if (!capable(CAP_SYS_ADMIN))
+       if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SECURE_MOUNT))
                return -EPERM;
 
        mnt = do_kern_mount(type, flags, name, data);
@@ -999,14 +1031,23 @@ long do_mount(char * dev_name, char * dir_name, char *type_page,
                ((char *)data_page)[PAGE_SIZE - 1] = 0;
 
        /* Separate the per-mountpoint flags */
+       if (flags & MS_RDONLY)
+               mnt_flags |= MNT_RDONLY;
        if (flags & MS_NOSUID)
                mnt_flags |= MNT_NOSUID;
        if (flags & MS_NODEV)
                mnt_flags |= MNT_NODEV;
        if (flags & MS_NOEXEC)
                mnt_flags |= MNT_NOEXEC;
+       if (flags & MS_NOATIME)
+               mnt_flags |= MNT_NOATIME;
+       if (flags & MS_NODIRATIME)
+               mnt_flags |= MNT_NODIRATIME;
        flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
 
+       if (vx_ccaps(VXC_SECURE_MOUNT))
+               mnt_flags |= MNT_NODEV;
+
        /* ... and get the mountpoint */
        retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
        if (retval)
@@ -1020,7 +1061,7 @@ long do_mount(char * dev_name, char * dir_name, char *type_page,
                retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
                                    data_page);
        else if (flags & MS_BIND)
-               retval = do_loopback(&nd, dev_name, flags & MS_REC);
+               retval = do_loopback(&nd, dev_name, flags, mnt_flags);
        else if (flags & MS_MOVE)
                retval = do_move_mount(&nd, dev_name);
        else
index c1745b6..ed1009d 100644 (file)
@@ -175,7 +175,7 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
        *ppos = pos;
 
-       if (!IS_RDONLY(inode)) {
+       if (!IS_RDONLY(inode) || (file && MNT_IS_RDONLY(file->f_vfsmnt))) {
                inode->i_atime = CURRENT_TIME;
        }
        
index bea651f..0ca23f2 100644 (file)
@@ -235,8 +235,9 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
 
 #if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
 static struct inode_operations ncp_symlink_inode_operations = {
-       .readlink       = page_readlink,
-       .follow_link    = page_follow_link,
+       .readlink       = generic_readlink,
+       .follow_link    = page_follow_link_light,
+       .put_link       = page_put_link,
        .setattr        = ncp_notify_change,
 };
 #endif
index 5fb8e87..bae04d6 100644 (file)
@@ -123,7 +123,7 @@ int ncp_mmap(struct file *file, struct vm_area_struct *vma)
        if (((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff 
           > (1U << (32 - PAGE_SHIFT)))
                return -EFBIG;
-       if (!IS_RDONLY(inode)) {
+       if (!IS_RDONLY(inode) || (file && MNT_IS_RDONLY(file->f_vfsmnt))) {
                inode->i_atime = CURRENT_TIME;
        }
 
index f061e70..5f9aa3a 100644 (file)
@@ -778,7 +778,8 @@ static int is_atomic_open(struct inode *dir, struct nameidata *nd)
        if (nd->flags & LOOKUP_DIRECTORY)
                return 0;
        /* Are we trying to write to a read only partition? */
-       if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
+       if ((IS_RDONLY(dir) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
+               (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
                return 0;
        return 1;
 }
@@ -1514,7 +1515,7 @@ nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
                 * Nobody gets write access to a read-only fs.
                 *
                 */
-               if (IS_RDONLY(inode) &&
+               if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
                    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                        return -EROFS;
 
index 6d9150d..91bd053 100644 (file)
@@ -156,163 +156,7 @@ nfs_file_read(struct kiocb *iocb, char __user * buf, size_t count, loff_t pos)
 }
 
 static ssize_t
-nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count,
-               read_actor_t actor, void *target)
-{
-       struct dentry *dentry = filp->f_dentry;
-       struct inode *inode = dentry->d_inode;
-       ssize_t res;
-
-       dfprintk(VFS, "nfs: sendfile(%s/%s, %lu@%Lu)\n",
-               dentry->d_parent->d_name.name, dentry->d_name.name,
-               (unsigned long) count, (unsigned long long) *ppos);
-
-       res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
-       if (!res)
-               res = generic_file_sendfile(filp, ppos, count, actor, target);
-       return res;
-}
-
-static int
-nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
-{
-       struct dentry *dentry = file->f_dentry;
-       struct inode *inode = dentry->d_inode;
-       int     status;
-
-       dfprintk(VFS, "nfs: mmap(%s/%s)\n",
-               dentry->d_parent->d_name.name, dentry->d_name.name);
-
-       status = nfs_revalidate_inode(NFS_SERVER(inode), inode);
-       if (!status)
-               status = generic_file_mmap(file, vma);
-       return status;
-}
-
-/*
- * Flush any dirty pages for this process, and check for write errors.
- * The return status from this call provides a reliable indication of
- * whether any write errors occurred for this process.
- */
-static int
-nfs_fsync(struct file *file, struct dentry *dentry, int datasync)
-{
-       struct inode *inode = dentry->d_inode;
-       int status;
-
-       dfprintk(VFS, "nfs: fsync(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino);
-
-       lock_kernel();
-       status = nfs_wb_all(inode);
-       if (!status) {
-               status = file->f_error;
-               file->f_error = 0;
-       }
-       unlock_kernel();
-       return status;
-}
-
-/*
- * This does the "real" work of the write. The generic routine has
- * allocated the page, locked it, done all the page alignment stuff
- * calculations etc. Now we should just copy the data from user
- * space and write it back to the real medium..
- *
- * If the writer ends up delaying the write, the writer needs to
- * increment the page use counts until he is done with the page.
- */
-static int nfs_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
-{
-       return nfs_flush_incompatible(file, page);
-}
-
-static int nfs_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to)
-{
-       long status;
-
-       lock_kernel();
-       status = nfs_updatepage(file, page, offset, to-offset);
-       unlock_kernel();
-       return status;
-}
-
-struct address_space_operations nfs_file_aops = {
-       .readpage = nfs_readpage,
-       .readpages = nfs_readpages,
-       .set_page_dirty = __set_page_dirty_nobuffers,
-       .writepage = nfs_writepage,
-       .writepages = nfs_writepages,
-       .prepare_write = nfs_prepare_write,
-       .commit_write = nfs_commit_write,
-#ifdef CONFIG_NFS_DIRECTIO
-       .direct_IO = nfs_direct_IO,
-#endif
-};
-
-/* 
- * Write to a file (through the page cache).
- */
-static ssize_t
-nfs_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos)
-{
-       struct dentry * dentry = iocb->ki_filp->f_dentry;
-       struct inode * inode = dentry->d_inode;
-       ssize_t result;
-
-#ifdef CONFIG_NFS_DIRECTIO
-       if (iocb->ki_filp->f_flags & O_DIRECT)
-               return nfs_file_direct_write(iocb, buf, count, pos);
-#endif
-
-       dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%lu)\n",
-               dentry->d_parent->d_name.name, dentry->d_name.name,
-               inode->i_ino, (unsigned long) count, (unsigned long) pos);
-
-       result = -EBUSY;
-       if (IS_SWAPFILE(inode))
-               goto out_swapfile;
-       result = nfs_revalidate_inode(NFS_SERVER(inode), inode);
-       if (result)
-               goto out;
-
-       result = count;
-       if (!count)
-               goto out;
-
-       result = generic_file_aio_write(iocb, buf, count, pos);
-out:
-       return result;
-
-out_swapfile:
-       printk(KERN_INFO "NFS: attempt to write to active swap file!\n");
-       goto out;
-}
-
-/*
- * Lock a (portion of) a file
- */
-int
-nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
-{
-       struct inode * inode = filp->f_mapping->host;
-       int     status = 0;
-       int     status2;
-
-       dprintk("NFS: nfs_lock(f=%s/%ld, t=%x, fl=%x, r=%Ld:%Ld)\n",
-                       inode->i_sb->s_id, inode->i_ino,
-                       fl->fl_type, fl->fl_flags,
-                       (long long)fl->fl_start, (long long)fl->fl_end);
-
-       if (!inode)
-               return -EINVAL;
-
-       /* No mandatory locks over NFS */
-       if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
-               return -ENOLCK;
-
-       if (NFS_PROTO(inode)->version != 4) {
-               /* Fake OK code if mounted without NLM support */
-               if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM) {
+nfs_file_sendfile(struct file *f
                        if (IS_GETLK(cmd))
                                status = LOCK_USE_CLNT;
                        goto out_ok;
index 36f5abc..7f25c31 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/mount.h>
 #include <linux/nfs_idmap.h>
 #include <linux/vfs.h>
+#include <linux/vserver/xid.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -332,6 +333,9 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
        }
        server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD;
 
+       if (server->flags & NFS_MOUNT_TAGXID)
+               sb->s_flags |= MS_TAGXID;
+
        sb->s_maxbytes = fsinfo.maxfilesize;
        if (sb->s_maxbytes > MAX_LFS_FILESIZE) 
                sb->s_maxbytes = MAX_LFS_FILESIZE; 
@@ -386,6 +390,7 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
        clnt->cl_intr     = (server->flags & NFS_MOUNT_INTR) ? 1 : 0;
        clnt->cl_softrtry = (server->flags & NFS_MOUNT_SOFT) ? 1 : 0;
        clnt->cl_droppriv = (server->flags & NFS_MOUNT_BROKEN_SUID) ? 1 : 0;
+       clnt->cl_tagxid   = (server->flags & NFS_MOUNT_TAGXID) ? 1 : 0;
        clnt->cl_chatty   = 1;
 
        return clnt;
@@ -563,6 +568,7 @@ static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
                { NFS_MOUNT_NOAC, ",noac", "" },
                { NFS_MOUNT_NONLM, ",nolock", ",lock" },
                { NFS_MOUNT_BROKEN_SUID, ",broken_suid", "" },
+               { NFS_MOUNT_TAGXID, ",tagxid", "" },
                { 0, NULL, NULL }
        };
        struct proc_nfs_info *nfs_infop;
@@ -728,8 +734,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                        nfsi->change_attr = fattr->change_attr;
                inode->i_size = nfs_size_to_loff_t(fattr->size);
                inode->i_nlink = fattr->nlink;
-               inode->i_uid = fattr->uid;
-               inode->i_gid = fattr->gid;
+               inode->i_uid = INOXID_UID(XID_TAG(inode), fattr->uid, fattr->gid);
+               inode->i_gid = INOXID_GID(XID_TAG(inode), fattr->uid, fattr->gid);
+               inode->i_xid = INOXID_XID(XID_TAG(inode), fattr->uid, fattr->gid, 0);
+                                        /* maybe fattr->xid someday */
                if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
                        /*
                         * report the blocks in 512byte units
@@ -755,13 +763,19 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
 
 out:
        return inode;
-
+/*
+fail_dlim:
+        make_bad_inode(inode);
+        iput(inode);
+       inode = NULL;
+*/
 out_no_inode:
        printk("nfs_fhget: iget failed\n");
        goto out;
 }
 
-#define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET)
+#define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_XID|ATTR_SIZE|\
+                        ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET)
 
 int
 nfs_setattr(struct dentry *dentry, struct iattr *attr)
@@ -801,6 +815,8 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
                        inode->i_uid = attr->ia_uid;
                if ((attr->ia_valid & ATTR_GID) != 0)
                        inode->i_gid = attr->ia_gid;
+               if ((attr->ia_valid & ATTR_XID) != 0)
+                       inode->i_xid = attr->ia_xid;
                if ((attr->ia_valid & ATTR_SIZE) != 0) {
                        inode->i_size = attr->ia_size;
                        vmtruncate(inode, attr->ia_size);
@@ -1067,6 +1083,9 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
        struct nfs_inode *nfsi = NFS_I(inode);
        loff_t cur_size, new_isize;
        int data_unstable;
+       uid_t uid;
+       gid_t gid;
+       xid_t xid = 0;
 
        /* Are we in the process of updating data on the server? */
        data_unstable = nfs_caches_unstable(inode);
@@ -1106,10 +1125,15 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
        } else if (S_ISREG(inode->i_mode) && new_isize > cur_size)
                        nfsi->flags |= NFS_INO_INVALID_ATTR;
 
+       uid = INOXID_UID(XID_TAG(inode), fattr->uid, fattr->gid);
+       gid = INOXID_GID(XID_TAG(inode), fattr->uid, fattr->gid);
+       xid = INOXID_XID(XID_TAG(inode), fattr->uid, fattr->gid, 0);
+
        /* Have any file permissions changed? */
        if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
-                       || inode->i_uid != fattr->uid
-                       || inode->i_gid != fattr->gid)
+                       || inode->i_uid != uid
+                       || inode->i_gid != gid
+                       || inode->i_xid != xid)
                nfsi->flags |= NFS_INO_INVALID_ATTR;
 
        /* Has the link count changed? */
@@ -1143,6 +1167,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
        unsigned int    invalid = 0;
        loff_t          cur_isize;
        int data_unstable;
+       uid_t           uid;
+       gid_t           gid;
+       xid_t           xid = 0;
 
        dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
                        __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
@@ -1225,9 +1252,14 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
        memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
        memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
 
+       uid = INOXID_UID(XID_TAG(inode), fattr->uid, fattr->gid);
+       gid = INOXID_GID(XID_TAG(inode), fattr->uid, fattr->gid);
+       xid = INOXID_XID(XID_TAG(inode), fattr->uid, fattr->gid, 0);
+
        if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
-           inode->i_uid != fattr->uid ||
-           inode->i_gid != fattr->gid) {
+           inode->i_uid != uid ||
+           inode->i_gid != gid ||
+           inode->i_xid != xid) {
                struct rpc_cred **cred = &NFS_I(inode)->cache_access.cred;
                if (*cred) {
                        put_rpccred(*cred);
@@ -1238,8 +1270,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
 
        inode->i_mode = fattr->mode;
        inode->i_nlink = fattr->nlink;
-       inode->i_uid = fattr->uid;
-       inode->i_gid = fattr->gid;
+       inode->i_uid = uid;
+       inode->i_gid = gid;
+       inode->i_xid = xid;
 
        if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
                /*
index 415fa5b..ebfc607 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/nfs.h>
 #include <linux/nfs3.h>
 #include <linux/nfs_fs.h>
+#include <linux/vserver/xid.h>
 
 #define NFSDBG_FACILITY                NFSDBG_XDR
 
@@ -177,7 +178,7 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
 }
 
 static inline u32 *
-xdr_encode_sattr(u32 *p, struct iattr *attr)
+xdr_encode_sattr(u32 *p, struct iattr *attr, int tagxid)
 {
        if (attr->ia_valid & ATTR_MODE) {
                *p++ = xdr_one;
@@ -185,15 +186,17 @@ xdr_encode_sattr(u32 *p, struct iattr *attr)
        } else {
                *p++ = xdr_zero;
        }
-       if (attr->ia_valid & ATTR_UID) {
+       if (attr->ia_valid & ATTR_UID ||
+               (tagxid && (attr->ia_valid & ATTR_XID))) {
                *p++ = xdr_one;
-               *p++ = htonl(attr->ia_uid);
+               *p++ = htonl(XIDINO_UID(tagxid, attr->ia_uid, attr->ia_xid));
        } else {
                *p++ = xdr_zero;
        }
-       if (attr->ia_valid & ATTR_GID) {
+       if (attr->ia_valid & ATTR_GID ||
+               (tagxid && (attr->ia_valid & ATTR_XID))) {
                *p++ = xdr_one;
-               *p++ = htonl(attr->ia_gid);
+               *p++ = htonl(XIDINO_GID(tagxid, attr->ia_gid, attr->ia_xid));
        } else {
                *p++ = xdr_zero;
        }
@@ -278,7 +281,8 @@ static int
 nfs3_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs3_sattrargs *args)
 {
        p = xdr_encode_fhandle(p, args->fh);
-       p = xdr_encode_sattr(p, args->sattr);
+       p = xdr_encode_sattr(p, args->sattr,
+               req->rq_task->tk_client->cl_tagxid);
        *p++ = htonl(args->guard);
        if (args->guard)
                p = xdr_encode_time3(p, &args->guardtime);
@@ -369,7 +373,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs3_createargs *args)
                *p++ = args->verifier[0];
                *p++ = args->verifier[1];
        } else
-               p = xdr_encode_sattr(p, args->sattr);
+               p = xdr_encode_sattr(p, args->sattr,
+                       req->rq_task->tk_client->cl_tagxid);
 
        req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
        return 0;
@@ -383,7 +388,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req, u32 *p, struct nfs3_mkdirargs *args)
 {
        p = xdr_encode_fhandle(p, args->fh);
        p = xdr_encode_array(p, args->name, args->len);
-       p = xdr_encode_sattr(p, args->sattr);
+       p = xdr_encode_sattr(p, args->sattr,
+               req->rq_task->tk_client->cl_tagxid);
        req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
        return 0;
 }
@@ -396,7 +402,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs3_symlinkargs *args
 {
        p = xdr_encode_fhandle(p, args->fromfh);
        p = xdr_encode_array(p, args->fromname, args->fromlen);
-       p = xdr_encode_sattr(p, args->sattr);
+       p = xdr_encode_sattr(p, args->sattr,
+               req->rq_task->tk_client->cl_tagxid);
        p = xdr_encode_array(p, args->topath, args->tolen);
        req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
        return 0;
@@ -411,7 +418,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req, u32 *p, struct nfs3_mknodargs *args)
        p = xdr_encode_fhandle(p, args->fh);
        p = xdr_encode_array(p, args->name, args->len);
        *p++ = htonl(args->type);
-       p = xdr_encode_sattr(p, args->sattr);
+       p = xdr_encode_sattr(p, args->sattr,
+               req->rq_task->tk_client->cl_tagxid);
        if (args->type == NF3CHR || args->type == NF3BLK) {
                *p++ = htonl(MAJOR(args->rdev));
                *p++ = htonl(MINOR(args->rdev));
index 8646159..7db9747 100644 (file)
@@ -87,6 +87,7 @@
 #include <linux/root_dev.h>
 #include <net/ipconfig.h>
 #include <linux/parser.h>
+#include <linux/vs_cvirt.h>
 
 /* Define this to allow debugging output */
 #undef NFSROOT_DEBUG
@@ -124,7 +125,7 @@ enum {
        Opt_soft, Opt_hard, Opt_intr,
        Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac, 
        Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
-       Opt_broken_suid,
+       Opt_broken_suid, Opt_tagxid,
        /* Error token */
        Opt_err
 };
@@ -160,6 +161,7 @@ static match_table_t __initdata tokens = {
        {Opt_tcp, "proto=tcp"},
        {Opt_tcp, "tcp"},
        {Opt_broken_suid, "broken_suid"},
+       {Opt_tagxid, "tagxid"},
        {Opt_err, NULL}
        
 };
@@ -271,6 +273,9 @@ static int __init root_nfs_parse(char *name, char *buf)
                        case Opt_broken_suid:
                                nfs_data.flags |= NFS_MOUNT_BROKEN_SUID;
                                break;
+                       case Opt_tagxid:
+                               nfs_data.flags |= NFS_MOUNT_TAGXID;
+                               break;
                        default : 
                                return 0;
                }
@@ -306,7 +311,7 @@ static int __init root_nfs_name(char *name)
        /* Override them by options set on kernel command-line */
        root_nfs_parse(name, buf);
 
-       cp = system_utsname.nodename;
+       cp = vx_new_uts(nodename);
        if (strlen(buf) + strlen(cp) > NFS_MAXPATHLEN) {
                printk(KERN_ERR "Root-NFS: Pathname for remote directory too long.\n");
                return -1;
index fabadfb..d601eb7 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/smp_lock.h>
+#include <linux/namei.h>
 
 /* Symlink caching in the page cache is even more simplistic
  * and straight-forward than readdir caching.
@@ -50,8 +51,13 @@ error:
        return -EIO;
 }
 
-static char *nfs_getlink(struct inode *inode, struct page **ppage)
+enum {
+       Page_Offset = (PAGE_SIZE - sizeof(void *)) / 4
+};
+
+static int nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
+       struct inode *inode = dentry->d_inode;
        struct page *page;
        u32 *p;
 
@@ -64,47 +70,44 @@ static char *nfs_getlink(struct inode *inode, struct page **ppage)
                goto read_failed;
        if (!PageUptodate(page))
                goto getlink_read_error;
-       *ppage = page;
        p = kmap(page);
-       return (char*)(p+1);
+       if (*p > Page_Offset * 4 - 1 - 4)
+               goto too_long;
+       *(struct page **)(p + Page_Offset) = page;
 
+       nd_set_link(nd, (char *)(p+1));
+       return 0;
+
+too_long:
+       kunmap(page);
+       page_cache_release(page);
+       page = ERR_PTR(-ENAMETOOLONG);
+       goto read_failed;
 getlink_read_error:
        page_cache_release(page);
        page = ERR_PTR(-EIO);
 read_failed:
-       return (char*)page;
-}
-
-static int nfs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
-{
-       struct inode *inode = dentry->d_inode;
-       struct page *page = NULL;
-       int res = vfs_readlink(dentry,buffer,buflen,nfs_getlink(inode,&page));
-       if (page) {
-               kunmap(page);
-               page_cache_release(page);
-       }
-       return res;
+       nd_set_link(nd, (char*)page);
+       return 0;
 }
 
-static int nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
+static void nfs_put_link(struct dentry *dentry, struct nameidata *nd)
 {
-       struct inode *inode = dentry->d_inode;
-       struct page *page = NULL;
-       int res = vfs_follow_link(nd, nfs_getlink(inode,&page));
-       if (page) {
+       u32 *s = (u32 *)nd_get_link(nd);
+       if (!IS_ERR(s)) {
+               struct page *page = *(struct page **)(s + Page_Offset - 1);
                kunmap(page);
                page_cache_release(page);
        }
-       return res;
 }
 
 /*
  * symlinks can't do much...
  */
 struct inode_operations nfs_symlink_inode_operations = {
-       .readlink       = nfs_readlink,
+       .readlink       = generic_readlink,
        .follow_link    = nfs_follow_link,
+       .put_link       = nfs_put_link,
        .getattr        = nfs_getattr,
        .setattr        = nfs_setattr,
 };
index cfe9ce8..8d35f45 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svcauth.h>
 #include <linux/nfsd/nfsd.h>
+#include <linux/vserver/xid.h>
 
 #define        CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
 
@@ -42,18 +43,20 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
        }
 
        if (cred->cr_uid != (uid_t) -1)
-               current->fsuid = cred->cr_uid;
+               current->fsuid = INOXID_UID(1, cred->cr_uid, cred->cr_gid);
        else
                current->fsuid = exp->ex_anon_uid;
        if (cred->cr_gid != (gid_t) -1)
-               current->fsgid = cred->cr_gid;
+               current->fsgid = INOXID_GID(1, cred->cr_uid, cred->cr_gid);
        else
                current->fsgid = exp->ex_anon_gid;
+       
+       current->xid = INOXID_XID(1, cred->cr_uid, cred->cr_gid, 0);
 
        if (!cred->cr_group_info)
                return -ENOMEM;
        ret = set_current_groups(cred->cr_group_info);
-       if ((cred->cr_uid)) {
+       if (INOXID_UID(1, cred->cr_uid, cred->cr_gid)) {
                cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
        } else {
                cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
index e7f907d..d102365 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/sunrpc/svc.h>
 #include <linux/nfsd/nfsd.h>
 #include <linux/nfsd/xdr3.h>
+#include <linux/vserver/xid.h>
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
 
@@ -121,6 +122,8 @@ static inline u32 *
 decode_sattr3(u32 *p, struct iattr *iap)
 {
        u32     tmp;
+       uid_t   uid = 0;
+       gid_t   gid = 0;
 
        iap->ia_valid = 0;
 
@@ -130,12 +133,15 @@ decode_sattr3(u32 *p, struct iattr *iap)
        }
        if (*p++) {
                iap->ia_valid |= ATTR_UID;
-               iap->ia_uid = ntohl(*p++);
+               uid = ntohl(*p++);
        }
        if (*p++) {
                iap->ia_valid |= ATTR_GID;
-               iap->ia_gid = ntohl(*p++);
+               gid = ntohl(*p++);
        }
+       iap->ia_uid = INOXID_UID(1, uid, gid);
+       iap->ia_gid = INOXID_GID(1, uid, gid);
+       iap->ia_xid = INOXID_XID(1, uid, gid, 0);
        if (*p++) {
                u64     newsize;
 
@@ -176,8 +182,10 @@ encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp)
        *p++ = htonl(nfs3_ftypes[(stat.mode & S_IFMT) >> 12]);
        *p++ = htonl((u32) stat.mode);
        *p++ = htonl((u32) stat.nlink);
-       *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid));
-       *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid));
+       *p++ = htonl((u32) nfsd_ruid(rqstp,
+               XIDINO_UID(XID_TAG(dentry->d_inode), stat.uid, stat.xid)));
+       *p++ = htonl((u32) nfsd_rgid(rqstp,
+               XIDINO_GID(XID_TAG(dentry->d_inode), stat.gid, stat.xid)));
        if (S_ISLNK(stat.mode) && stat.size > NFS3_MAXPATHLEN) {
                p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
        } else {
index fb458b6..e95b02a 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/nfsd/state.h>
 #include <linux/nfsd/xdr4.h>
 #include <linux/nfsd_idmap.h>
+#include <linux/vserver/xid.h>
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
 
@@ -1560,14 +1561,18 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
                WRITE32(stat.nlink);
        }
        if (bmval1 & FATTR4_WORD1_OWNER) {
-               status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
+               status = nfsd4_encode_user(rqstp,
+                       XIDINO_UID(XID_TAG(dentry->d_inode),
+                       stat.uid, stat.xid), &p, &buflen);
                if (status == nfserr_resource)
                        goto out_resource;
                if (status)
                        goto out;
        }
        if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
-               status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
+               status = nfsd4_encode_group(rqstp,
+                       XIDINO_GID(XID_TAG(dentry->d_inode),
+                       stat.gid, stat.xid), &p, &buflen);
                if (status == nfserr_resource)
                        goto out_resource;
                if (status)
index 948b082..77b18ba 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/nfsd/nfsd.h>
 #include <linux/nfsd/xdr.h>
 #include <linux/mm.h>
+#include <linux/vserver/xid.h>
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
 
@@ -96,6 +97,8 @@ static inline u32 *
 decode_sattr(u32 *p, struct iattr *iap)
 {
        u32     tmp, tmp1;
+       uid_t   uid = 0;
+       gid_t   gid = 0;
 
        iap->ia_valid = 0;
 
@@ -109,12 +112,15 @@ decode_sattr(u32 *p, struct iattr *iap)
        }
        if ((tmp = ntohl(*p++)) != (u32)-1) {
                iap->ia_valid |= ATTR_UID;
-               iap->ia_uid = tmp;
+               uid = tmp;
        }
        if ((tmp = ntohl(*p++)) != (u32)-1) {
                iap->ia_valid |= ATTR_GID;
-               iap->ia_gid = tmp;
+               gid = tmp;
        }
+       iap->ia_uid = INOXID_UID(1, uid, gid);
+       iap->ia_gid = INOXID_GID(1, uid, gid);
+       iap->ia_xid = INOXID_XID(1, uid, gid, 0);
        if ((tmp = ntohl(*p++)) != (u32)-1) {
                iap->ia_valid |= ATTR_SIZE;
                iap->ia_size = tmp;
@@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp)
        *p++ = htonl(nfs_ftypes[type >> 12]);
        *p++ = htonl((u32) stat.mode);
        *p++ = htonl((u32) stat.nlink);
-       *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid));
-       *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid));
+       *p++ = htonl((u32) nfsd_ruid(rqstp,
+               XIDINO_UID(XID_TAG(dentry->d_inode), stat.uid, stat.xid)));
+       *p++ = htonl((u32) nfsd_rgid(rqstp,
+               XIDINO_GID(XID_TAG(dentry->d_inode), stat.gid, stat.xid)));
 
        if (S_ISLNK(type) && stat.size > NFS_MAXPATHLEN) {
                *p++ = htonl(NFS_MAXPATHLEN);
index d50269b..6ad7bc7 100644 (file)
@@ -1556,7 +1556,8 @@ nfsd_permission(struct svc_export *exp, struct dentry *dentry, int acc)
         */
        if (!(acc & MAY_LOCAL_ACCESS))
                if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
-                       if (EX_RDONLY(exp) || IS_RDONLY(inode))
+                       if (EX_RDONLY(exp) || IS_RDONLY(inode)
+                               || (exp && MNT_IS_RDONLY(exp->ex_mnt)))
                                return nfserr_rofs;
                        if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
                                return nfserr_perm;
index 8e53993..6c81173 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
 #include <asm/uaccess.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
+#include <linux/vs_base.h>
+#include <linux/vs_limit.h>
+#include <linux/vs_dlimit.h>
+#include <linux/vserver/xid.h>
 
 #include <asm/unistd.h>
 
@@ -40,6 +44,8 @@ int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
                        if (retval == 0 && buf->f_frsize == 0)
                                buf->f_frsize = buf->f_bsize;
                }
+               if (!vx_check(0, VX_ADMIN|VX_WATCH))
+                       vx_vsi_statfs(sb, buf);
        }
        return retval;
 }
@@ -239,7 +245,7 @@ static inline long do_sys_truncate(const char __user * path, loff_t length)
                goto dput_and_out;
 
        error = -EROFS;
-       if (IS_RDONLY(inode))
+       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
                goto dput_and_out;
 
        error = -EPERM;
@@ -363,7 +369,7 @@ asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times)
        inode = nd.dentry->d_inode;
 
        error = -EROFS;
-       if (IS_RDONLY(inode))
+       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
                goto dput_and_out;
 
        /* Don't worry, the checks are done in inode_change_ok() */
@@ -420,7 +426,7 @@ long do_utimes(char __user * filename, struct timeval * times)
        inode = nd.dentry->d_inode;
 
        error = -EROFS;
-       if (IS_RDONLY(inode))
+       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
                goto dput_and_out;
 
        /* Don't worry, the checks are done in inode_change_ok() */
@@ -502,7 +508,8 @@ asmlinkage long sys_access(const char __user * filename, int mode)
        if (!res) {
                res = permission(nd.dentry->d_inode, mode, &nd);
                /* SuS v2 requires we report a read only fs too */
-               if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
+               if(!res && (mode & S_IWOTH)
+                  && (IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
                   && !special_file(nd.dentry->d_inode->i_mode))
                        res = -EROFS;
                path_release(&nd);
@@ -608,7 +615,7 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
        inode = dentry->d_inode;
 
        err = -EROFS;
-       if (IS_RDONLY(inode))
+       if (IS_RDONLY(inode) || (file && MNT_IS_RDONLY(file->f_vfsmnt)))
                goto out_putf;
        err = -EPERM;
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
@@ -640,7 +647,7 @@ asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
        inode = nd.dentry->d_inode;
 
        error = -EROFS;
-       if (IS_RDONLY(inode))
+       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
                goto dput_and_out;
 
        error = -EPERM;
@@ -661,7 +668,8 @@ out:
        return error;
 }
 
-static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
+static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
+       uid_t user, gid_t group)
 {
        struct inode * inode;
        int error;
@@ -673,19 +681,20 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
                goto out;
        }
        error = -EROFS;
-       if (IS_RDONLY(inode))
+       if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
                goto out;
        error = -EPERM;
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
                goto out;
+
        newattrs.ia_valid =  ATTR_CTIME;
        if (user != (uid_t) -1) {
                newattrs.ia_valid |= ATTR_UID;
-               newattrs.ia_uid = user;
+               newattrs.ia_uid = vx_map_uid(user);
        }
        if (group != (gid_t) -1) {
                newattrs.ia_valid |= ATTR_GID;
-               newattrs.ia_gid = group;
+               newattrs.ia_gid = vx_map_gid(group);
        }
        if (!S_ISDIR(inode->i_mode))
                newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
@@ -703,7 +712,7 @@ asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group)
 
        error = user_path_walk(filename, &nd);
        if (!error) {
-               error = chown_common(nd.dentry, user, group);
+               error = chown_common(nd.dentry, nd.mnt, user, group);
                path_release(&nd);
        }
        return error;
@@ -716,7 +725,7 @@ asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group
 
        error = user_path_walk_link(filename, &nd);
        if (!error) {
-               error = chown_common(nd.dentry, user, group);
+               error = chown_common(nd.dentry, nd.mnt, user, group);
                path_release(&nd);
        }
        return error;
@@ -730,7 +739,7 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
 
        file = fget(fd);
        if (file) {
-               error = chown_common(file->f_dentry, user, group);
+               error = chown_common(file->f_dentry, file->f_vfsmnt, user, group);
                fput(file);
        }
        return error;
@@ -880,6 +889,7 @@ repeat:
        FD_SET(fd, files->open_fds);
        FD_CLR(fd, files->close_on_exec);
        files->next_fd = fd + 1;
+       // vx_openfd_inc(fd);
 #if 1
        /* Sanity check */
        if (files->fd[fd] != NULL) {
@@ -901,6 +911,7 @@ static inline void __put_unused_fd(struct files_struct *files, unsigned int fd)
        __FD_CLR(fd, files->open_fds);
        if (fd < files->next_fd)
                files->next_fd = fd;
+       // vx_openfd_dec(fd);
 }
 
 void fastcall put_unused_fd(unsigned int fd)
@@ -967,7 +978,6 @@ out_error:
        fd = error;
        goto out;
 }
-EXPORT_SYMBOL_GPL(sys_open);
 
 #ifndef __alpha__
 
@@ -1041,7 +1051,6 @@ out_unlock:
        return -EBADF;
 }
 
-EXPORT_SYMBOL(sys_close);
 
 /*
  * This routine simulates a hangup on the tty, to arrange that users
diff --git a/fs/partitions/nec98.c b/fs/partitions/nec98.c
deleted file mode 100644 (file)
index 08c72ae..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- *  NEC PC-9800 series partition supports
- *
- *  Copyright (C) 1999 Kyoto University Microcomputer Club
- */
-
-#include <linux/config.h>
-#include <linux/fs.h>
-#include <linux/genhd.h>
-#include <linux/kernel.h>
-#include <linux/hdreg.h>
-
-#include "check.h"
-#include "nec98.h"
-
-struct nec98_partition {
-       __u8    mid;            /* 0x80 - active */
-       __u8    sid;            /* 0x80 - bootable */
-       __u16   pad1;           /* dummy for padding */
-       __u8    ipl_sector;     /* IPL sector   */
-       __u8    ipl_head;       /* IPL head     */
-       __u16   ipl_cyl;        /* IPL cylinder */
-       __u8    sector;         /* starting sector      */
-       __u8    head;           /* starting head        */
-       __u16   cyl;            /* starting cylinder    */
-       __u8    end_sector;     /* end sector   */
-       __u8    end_head;       /* end head     */
-       __u16   end_cyl;        /* end cylinder */
-       unsigned char name[16];
-} __attribute__((__packed__));
-
-#define NEC98_BSD_PARTITION_MID 0x14
-#define NEC98_BSD_PARTITION_SID 0x44
-#define MID_SID_16(mid, sid)   (((mid) & 0xFF) | (((sid) & 0xFF) << 8))
-#define NEC98_BSD_PARTITION_MID_SID    \
-       MID_SID_16(NEC98_BSD_PARTITION_MID, NEC98_BSD_PARTITION_SID)
-#define NEC98_VALID_PTABLE_ENTRY(P) \
-       (!(P)->pad1 && (P)->cyl <= (P)->end_cyl)
-
-extern int pc98_bios_param(struct block_device *bdev, int *ip);
-
-static inline int
-is_valid_nec98_partition_table(const struct nec98_partition *ptable,
-                               __u8 nsectors, __u8 nheads)
-{
-       int i;
-       int valid = 0;
-
-       for (i = 0; i < 16; i++) {
-               if (!*(__u16 *)&ptable[i])
-                       continue;       /* empty slot */
-               if (ptable[i].pad1      /* `pad1' contains junk */
-                   || ptable[i].ipl_sector     >= nsectors
-                   || ptable[i].sector         >= nsectors
-                   || ptable[i].end_sector     >= nsectors
-                   || ptable[i].ipl_head       >= nheads
-                   || ptable[i].head           >= nheads
-                   || ptable[i].end_head       >= nheads
-                   || ptable[i].cyl > ptable[i].end_cyl)
-                       return 0;
-               valid = 1;      /* We have a valid partition.  */
-       }
-       /* If no valid PC-9800-style partitions found,
-          the disk may have other type of partition table.  */
-       return valid;
-}
-
-int nec98_partition(struct parsed_partitions *state, struct block_device *bdev)
-{
-       unsigned int nr;
-       struct hd_geometry geo;
-       Sector sect;
-       const struct nec98_partition *part;
-       unsigned char *data;
-       int sector_size = bdev_hardsect_size(bdev);
-
-       if (ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)&geo) != 0) {
-               printk(" unsupported disk (%s)\n", bdev->bd_disk->disk_name);
-               return 0;
-       }
-
-#ifdef NEC98_PARTITION_DEBUG
-       printk("ioctl_by_bdev head=%d sect=%d\n", geo.heads, geo.sectors);
-#endif
-       data = read_dev_sector(bdev, 0, &sect);
-       if (!data) {
-               if (warn_no_part)
-                       printk(" unable to read partition table\n");
-               return -1;
-       }
-
-       /* magic(?) check */
-       if (*(__u16 *)(data + sector_size - 2) != NEC98_PTABLE_MAGIC) {
-               put_dev_sector(sect);
-               return 0;
-       }
-
-       put_dev_sector(sect);
-       data = read_dev_sector(bdev, 1, &sect);
-       if (!data) {
-               if (warn_no_part)
-                       printk(" unable to read partition table\n");
-               return -1;
-       }
-
-       if (!is_valid_nec98_partition_table((struct nec98_partition *)data,
-                                            geo.sectors, geo.heads)) {
-#ifdef NEC98_PARTITION_DEBUG
-               if (warn_no_part)
-                       printk(" partition table consistency check failed"
-                               " (not PC-9800 disk?)\n");
-#endif
-               put_dev_sector(sect);
-               return 0;
-       }
-
-       part = (const struct nec98_partition *)data;
-       for (nr = 0; nr < 16; nr++, part++) {
-               unsigned int start_sect, end_sect;
-
-               if (part->mid == 0 || part->sid == 0)
-                       continue;
-
-               if (nr)
-                       printk("     ");
-
-               {       /* Print partition name. Fdisk98 might put NUL
-                          characters in partition name... */
-
-                       int j;
-                       unsigned char *p;
-                       unsigned char buf[sizeof (part->name) * 2 + 1];
-
-                       for (p = buf, j = 0; j < sizeof (part->name); j++, p++)
-                               if ((*p = part->name[j]) < ' ') {
-                                       *p++ = '^';
-                                       *p = part->name[j] + '@';
-                               }
-
-                       *p = 0;
-                       printk(" <%s>", buf);
-               }
-               start_sect = (part->cyl * geo.heads + part->head) * geo.sectors
-                       + part->sector;
-               end_sect = (part->end_cyl + 1) * geo.heads * geo.sectors;
-               if (end_sect <= start_sect) {
-                       printk(" (invalid partition info)\n");
-                       continue;
-               }
-
-               put_partition(state, nr + 1, start_sect, end_sect - start_sect);
-#ifdef CONFIG_BSD_DISKLABEL
-               if ((*(__u16 *)&part->mid & 0x7F7F)
-                   == NEC98_BSD_PARTITION_MID_SID) {
-                       printk("!");
-                       /* NEC98_BSD_PARTITION_MID_SID is not valid SYSIND for
-                          IBM PC's MS-DOS partition table, so we simply pass
-                          it to bsd_disklabel_partition;
-                          it will just print `<bsd: ... >'. */
-                       parse_bsd(state, bdev, start_sect,
-                                       end_sect - start_sect, nr + 1,
-                                       "bsd98", BSD_MAXPARTITIONS);
-               }
-#endif
-               {       /* Pretty size printing. */
-                       /* XXX sector size? */
-                       unsigned int psize = (end_sect - start_sect) / 2;
-                       int unit_char = 'K';
-
-                       if (psize > 99999) {
-                               psize >>= 10;
-                               unit_char = 'M';
-                       }
-                       printk(" %5d%cB (%5d-%5d)\n", 
-                              psize, unit_char, part->cyl, part->end_cyl);
-               }
-       }
-
-       put_dev_sector(sect);
-
-       return nr ? 1 : 0;
-}
-\f
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/fs/partitions/nec98.h b/fs/partitions/nec98.h
deleted file mode 100644 (file)
index 5ae2da0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- *  NEC PC-9800 series partition supports
- *
- *  Copyright (C) 1998-2000    Kyoto University Microcomputer Club
- */
-
-#define NEC98_PTABLE_MAGIC     0xAA55
-
-extern int nec98_partition(struct parsed_partitions *state,
-                               struct block_device *bdev);
index 2b42a25..3e3e2e5 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -255,7 +255,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
                kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
        }
        if (ret > 0)
-               inode_update_time(inode, 1);    /* mtime and ctime */
+               inode_update_time(inode, filp->f_vfsmnt, 1);    /* mtime and ctime */
        return ret;
 }
 
@@ -680,6 +680,8 @@ no_files:
        return error;   
 }
 
+EXPORT_SYMBOL_GPL(do_pipe);
+
 /*
  * pipefs should _never_ be mounted by userland - too much of security hassle,
  * no real gain from having the whole whorehouse mounted. So we don't need
index fe14439..47e2543 100644 (file)
 #include <linux/highmem.h>
 #include <linux/file.h>
 #include <linux/times.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_network.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -128,7 +132,8 @@ static const char *task_state_array[] = {
        "D (disk sleep)",       /*  2 */
        "T (stopped)",          /*  4 */
        "Z (zombie)",           /*  8 */
-       "X (dead)"              /* 16 */
+       "X (dead)",             /* 16 */
+       "H (on hold)"           /* 32 */
 };
 
 static inline const char * get_task_state(struct task_struct *tsk)
@@ -138,7 +143,8 @@ static inline const char * get_task_state(struct task_struct *tsk)
                                           TASK_UNINTERRUPTIBLE |
                                           TASK_ZOMBIE |
                                           TASK_DEAD |
-                                          TASK_STOPPED);
+                                          TASK_STOPPED |
+                                          TASK_ONHOLD);
        const char **p = &task_state_array[0];
 
        while (state) {
@@ -152,8 +158,12 @@ static inline char * task_state(struct task_struct *p, char *buffer)
 {
        struct group_info *group_info;
        int g;
+       pid_t pid, ppid, tgid;
 
        read_lock(&tasklist_lock);
+       tgid = vx_map_tgid(current->vx_info, p->tgid);
+       pid = vx_map_tgid(current->vx_info, p->pid);
+       ppid = vx_map_tgid(current->vx_info, p->real_parent->pid);
        buffer += sprintf(buffer,
                "State:\t%s\n"
                "SleepAVG:\t%lu%%\n"
@@ -165,8 +175,7 @@ static inline char * task_state(struct task_struct *p, char *buffer)
                "Gid:\t%d\t%d\t%d\t%d\n",
                get_task_state(p),
                (p->sleep_avg/1024)*100/(1020000000/1024),
-               p->tgid,
-               p->pid, p->pid ? p->real_parent->pid : 0,
+               tgid, pid, p->pid ? ppid : 0,
                p->pid && p->ptrace ? p->parent->pid : 0,
                p->uid, p->euid, p->suid, p->fsuid,
                p->gid, p->egid, p->sgid, p->fsgid);
@@ -279,6 +288,10 @@ extern char *task_mem(struct mm_struct *, char *);
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
        char * orig = buffer;
+#ifdef CONFIG_VSERVER_LEGACY           
+       struct vx_info *vxi;
+       struct nx_info *nxi;
+#endif
        struct mm_struct *mm = get_task_mm(task);
 
        buffer = task_name(task, buffer);
@@ -290,6 +303,39 @@ int proc_pid_status(struct task_struct *task, char * buffer)
        }
        buffer = task_sig(task, buffer);
        buffer = task_cap(task, buffer);
+
+#ifdef CONFIG_VSERVER_LEGACY           
+       buffer += sprintf (buffer,"s_context: %d\n", vx_task_xid(task));
+       vxi = task_get_vx_info(task);
+       if (vxi) {
+               buffer += sprintf (buffer,"ctxflags: %08llx\n"
+                       ,(unsigned long long)vxi->vx_flags);
+               buffer += sprintf (buffer,"initpid: %d\n"
+                       ,vxi->vx_initpid);
+       } else {
+               buffer += sprintf (buffer,"ctxflags: none\n");
+               buffer += sprintf (buffer,"initpid: none\n");
+       }
+       put_vx_info(vxi);
+       nxi = task_get_nx_info(task);
+       if (nxi) {
+               int i;
+
+               buffer += sprintf (buffer,"ipv4root:");
+               for (i=0; i<nxi->nbipv4; i++){
+                       buffer += sprintf (buffer," %08x/%08x"
+                               ,nxi->ipv4[i]
+                               ,nxi->mask[i]);
+               }
+               *buffer++ = '\n';
+               buffer += sprintf (buffer,"ipv4root_bcast: %08x\n"
+                       ,nxi->v4_bcast);
+       } else {
+               buffer += sprintf (buffer,"ipv4root: 0\n");
+               buffer += sprintf (buffer,"ipv4root_bcast: 0\n");
+       }
+       put_nx_info(nxi);
+#endif
 #if defined(CONFIG_ARCH_S390)
        buffer = task_show_regs(task, buffer);
 #endif
@@ -301,18 +347,29 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
 {
        unsigned long vsize, eip, esp, wchan;
        long priority, nice;
+       unsigned long long bias_jiffies;
        int tty_pgrp = -1, tty_nr = 0;
        sigset_t sigign, sigcatch;
        char state;
        int res;
-       pid_t ppid, pgid = -1, sid = -1;
+       pid_t pid, ppid, pgid = -1, sid = -1;
        int num_threads = 0;
        struct mm_struct *mm;
        unsigned long long start_time;
 
        state = *get_task_state(task);
        vsize = eip = esp = 0;
+       bias_jiffies = INITIAL_JIFFIES;
+
        task_lock(task);
+       if (__vx_task_flags(task, VXF_VIRT_UPTIME, 0)) {
+               bias_jiffies = task->vx_info->cvirt.bias_jiffies;
+               /* hmm, do we need that? */
+               if (bias_jiffies > task->start_time)
+                       bias_jiffies = task->start_time;
+       }
+       pid = vx_map_tgid(task->vx_info, task->pid);
+
        mm = task->mm;
        if(mm)
                mm = mmgrab(mm);
@@ -325,7 +382,10 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
                up_read(&mm->mmap_sem);
        }
 
-       wchan = get_wchan(task);
+       wchan = 0;
+       if (current->uid == task->uid || current->euid == task->uid ||
+                                                       capable(CAP_SYS_NICE))
+               wchan = get_wchan(task);
 
        sigemptyset(&sigign);
        sigemptyset(&sigcatch);
@@ -356,12 +416,12 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
        read_unlock(&tasklist_lock);
 
        /* Temporary variable needed for gcc-2.96 */
-       start_time = jiffies_64_to_clock_t(task->start_time - INITIAL_JIFFIES);
+       start_time = jiffies_64_to_clock_t(task->start_time - bias_jiffies);
 
        res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu \
 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n",
-               task->pid,
+               pid,
                task->comm,
                state,
                ppid,
@@ -428,3 +488,21 @@ int proc_pid_statm(struct task_struct *task, char *buffer)
        return sprintf(buffer,"%d %d %d %d %d %d %d\n",
                       size, resident, shared, text, lib, data, 0);
 }
+
+
+int proc_pid_delay(struct task_struct *task, char * buffer)
+{
+       int res;
+
+       res  = sprintf(buffer,"%u %llu %llu %u %llu %u %llu\n",
+                      get_delay(task,runs),
+                      (unsigned long long)get_delay(task,runcpu_total),
+                      (unsigned long long)get_delay(task,waitcpu_total),
+                      get_delay(task,num_iowaits),
+                      (unsigned long long)get_delay(task,iowait_total),
+                      get_delay(task,num_memwaits),
+                      (unsigned long long)get_delay(task,mem_iowait_total)
+               );
+       return res;
+}
+
index 9e3a70e..199e761 100644 (file)
@@ -32,6 +32,8 @@
 #include <linux/mount.h>
 #include <linux/security.h>
 #include <linux/ptrace.h>
+#include <linux/vs_network.h>
+#include <linux/vs_cvirt.h>
 
 /*
  * For hysterical raisins we keep the same inumbers as in the old procfs.
@@ -67,6 +69,8 @@ enum pid_directory_inos {
        PROC_TGID_ATTR_EXEC,
        PROC_TGID_ATTR_FSCREATE,
 #endif
+       PROC_TGID_VX_INFO,
+       PROC_TGID_IP_INFO,
        PROC_TGID_FD_DIR,
        PROC_TID_INO,
        PROC_TID_STATUS,
@@ -89,6 +93,12 @@ enum pid_directory_inos {
        PROC_TID_ATTR_PREV,
        PROC_TID_ATTR_EXEC,
        PROC_TID_ATTR_FSCREATE,
+#endif
+       PROC_TID_VX_INFO,
+       PROC_TID_IP_INFO,
+#ifdef CONFIG_DELAY_ACCT
+        PROC_TID_DELAY_ACCT,
+        PROC_TGID_DELAY_ACCT,
 #endif
        PROC_TID_FD_DIR = 0x8000,       /* 0x8000-0xffff */
 };
@@ -111,7 +121,7 @@ static struct pid_entry tgid_base_stuff[] = {
        E(PROC_TGID_CMDLINE,   "cmdline", S_IFREG|S_IRUGO),
        E(PROC_TGID_STAT,      "stat",    S_IFREG|S_IRUGO),
        E(PROC_TGID_STATM,     "statm",   S_IFREG|S_IRUGO),
-       E(PROC_TGID_MAPS,      "maps",    S_IFREG|S_IRUGO),
+       E(PROC_TGID_MAPS,      "maps",    S_IFREG|S_IRUSR),
        E(PROC_TGID_MEM,       "mem",     S_IFREG|S_IRUSR|S_IWUSR),
        E(PROC_TGID_CWD,       "cwd",     S_IFLNK|S_IRWXUGO),
        E(PROC_TGID_ROOT,      "root",    S_IFLNK|S_IRWXUGO),
@@ -120,9 +130,14 @@ static struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_SECURITY
        E(PROC_TGID_ATTR,      "attr",    S_IFDIR|S_IRUGO|S_IXUGO),
 #endif
+#ifdef CONFIG_DELAY_ACCT
+       E(PROC_TGID_DELAY_ACCT,"delay",   S_IFREG|S_IRUGO),
+#endif
 #ifdef CONFIG_KALLSYMS
        E(PROC_TGID_WCHAN,     "wchan",   S_IFREG|S_IRUGO),
 #endif
+       E(PROC_TGID_VX_INFO,   "vinfo",   S_IFREG|S_IRUGO),
+       E(PROC_TGID_IP_INFO,   "ninfo",   S_IFREG|S_IRUGO),
        {0,0,NULL,0}
 };
 static struct pid_entry tid_base_stuff[] = {
@@ -133,7 +148,7 @@ static struct pid_entry tid_base_stuff[] = {
        E(PROC_TID_CMDLINE,    "cmdline", S_IFREG|S_IRUGO),
        E(PROC_TID_STAT,       "stat",    S_IFREG|S_IRUGO),
        E(PROC_TID_STATM,      "statm",   S_IFREG|S_IRUGO),
-       E(PROC_TID_MAPS,       "maps",    S_IFREG|S_IRUGO),
+       E(PROC_TID_MAPS,       "maps",    S_IFREG|S_IRUSR),
        E(PROC_TID_MEM,        "mem",     S_IFREG|S_IRUSR|S_IWUSR),
        E(PROC_TID_CWD,        "cwd",     S_IFLNK|S_IRWXUGO),
        E(PROC_TID_ROOT,       "root",    S_IFLNK|S_IRWXUGO),
@@ -142,9 +157,14 @@ static struct pid_entry tid_base_stuff[] = {
 #ifdef CONFIG_SECURITY
        E(PROC_TID_ATTR,       "attr",    S_IFDIR|S_IRUGO|S_IXUGO),
 #endif
+#ifdef CONFIG_DELAY_ACCT
+       E(PROC_TGID_DELAY_ACCT,"delay",   S_IFREG|S_IRUGO),
+#endif
 #ifdef CONFIG_KALLSYMS
        E(PROC_TID_WCHAN,      "wchan",   S_IFREG|S_IRUGO),
 #endif
+       E(PROC_TID_VX_INFO,    "vinfo",   S_IFREG|S_IRUGO),
+       E(PROC_TID_IP_INFO,    "ninfo",   S_IFREG|S_IRUGO),
        {0,0,NULL,0}
 };
 
@@ -181,6 +201,7 @@ int proc_pid_stat(struct task_struct*,char*);
 int proc_pid_status(struct task_struct*,char*);
 int proc_pid_statm(struct task_struct*,char*);
 int proc_pid_cpu(struct task_struct*,char*);
+int proc_pid_delay(struct task_struct*,char*);
 
 static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
 {
@@ -954,6 +975,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
                inode->i_uid = task->euid;
                inode->i_gid = task->egid;
        }
+       inode->i_xid = vx_task_xid(task);
        security_task_to_inode(task, inode);
 
 out:
@@ -979,6 +1001,11 @@ static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
 {
        struct inode *inode = dentry->d_inode;
        struct task_struct *task = proc_task(inode);
+
+       if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               goto out_drop;
+       /* discard wrong fakeinit */
+
        if (pid_alive(task)) {
                if (proc_type(inode) == PROC_TGID_INO || proc_type(inode) == PROC_TID_INO || task_dumpable(task)) {
                        inode->i_uid = task->euid;
@@ -990,6 +1017,7 @@ static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
                security_task_to_inode(task, inode);
                return 1;
        }
+out_drop:
        d_drop(dentry);
        return 0;
 }
@@ -1374,6 +1402,23 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
                        inode->i_fop = &proc_info_file_operations;
                        ei->op.proc_read = proc_pid_wchan;
                        break;
+#endif
+               case PROC_TID_VX_INFO:
+               case PROC_TGID_VX_INFO:
+                       inode->i_fop = &proc_info_file_operations;
+                       ei->op.proc_read = proc_pid_vx_info;
+                       break;
+               case PROC_TID_IP_INFO:
+               case PROC_TGID_IP_INFO:
+                       inode->i_fop = &proc_info_file_operations;
+                       ei->op.proc_read = proc_pid_nx_info;
+                       break;
+#ifdef CONFIG_DELAY_ACCT
+               case PROC_TID_DELAY_ACCT:
+               case PROC_TGID_DELAY_ACCT:
+                       inode->i_fop = &proc_info_file_operations;
+                       ei->op.proc_read = proc_pid_delay;
+                       break;
 #endif
                default:
                        printk("procfs: impossible type (%d)",p->type);
@@ -1526,6 +1571,7 @@ struct dentry *proc_pid_unhash(struct task_struct *p)
        
 void proc_pid_flush(struct dentry *proc_dentry)
 {
+       might_sleep();
        if(proc_dentry != NULL) {
                shrink_dcache_parent(proc_dentry);
                dput(proc_dentry);
@@ -1556,7 +1602,7 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct
                d_add(dentry, inode);
                return NULL;
        }
-       tgid = name_to_int(dentry);
+       tgid = vx_rmap_tgid(current->vx_info, name_to_int(dentry));
        if (tgid == ~0U)
                goto out;
 
@@ -1568,8 +1614,9 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct
        if (!task)
                goto out;
 
-       inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);
-
+       inode = NULL;
+       if (vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);
 
        if (!inode) {
                put_task_struct(task);
@@ -1611,10 +1658,12 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry
        struct inode *inode;
        unsigned tid;
 
-       tid = name_to_int(dentry);
+       tid = vx_rmap_tgid(current->vx_info, name_to_int(dentry));
        if (tid == ~0U)
                goto out;
 
+/*     handle fakeinit */
+
        read_lock(&tasklist_lock);
        task = find_task_by_pid(tid);
        if (task)
@@ -1625,8 +1674,9 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry
        if (leader->tgid != task->tgid)
                goto out_drop_task;
 
-       inode = proc_pid_make_inode(dir->i_sb, task, PROC_TID_INO);
-
+       inode = NULL;
+       if (vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               inode = proc_pid_make_inode(dir->i_sb, task, PROC_TID_INO);
 
        if (!inode)
                goto out_drop_task;
@@ -1677,11 +1727,14 @@ static int get_tgid_list(int index, unsigned long version, unsigned int *tgids)
 
        for ( ; p != &init_task; p = next_task(p)) {
                int tgid = p->pid;
+
                if (!pid_alive(p))
                        continue;
+               if (!vx_check(vx_task_xid(p), VX_WATCH|VX_IDENT))
+                       continue;
                if (--index >= 0)
                        continue;
-               tgids[nr_tgids] = tgid;
+               tgids[nr_tgids] = vx_map_tgid(current->vx_info, tgid);
                nr_tgids++;
                if (nr_tgids >= PROC_MAXPIDS)
                        break;
@@ -1711,9 +1764,11 @@ static int get_tid_list(int index, unsigned int *tids, struct inode *dir)
        if (pid_alive(task)) do {
                int tid = task->pid;
 
+               if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+                       continue;
                if (--index >= 0)
                        continue;
-               tids[nr_tids] = tid;
+               tids[nr_tids] = vx_map_tgid(current->vx_info, tid);
                nr_tids++;
                if (nr_tids >= PROC_MAXPIDS)
                        break;
@@ -1769,11 +1824,14 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
        unsigned int nr_tids, i;
        struct dentry *dentry = filp->f_dentry;
        struct inode *inode = dentry->d_inode;
+       struct task_struct *task = proc_task(inode);
        int retval = -ENOENT;
        ino_t ino;
        unsigned long pos = filp->f_pos;  /* avoiding "long long" filp->f_pos */
 
-       if (!pid_alive(proc_task(inode)))
+       if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
+               goto out;
+       if (!pid_alive(task))
                goto out;
        retval = 0;
 
index 72febc0..e7ec42f 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/init.h>
 #include <linux/idr.h>
 #include <linux/namei.h>
+#include <linux/vs_base.h>
+#include <linux/vserver/inode.h>
 #include <asm/uaccess.h>
 #include <asm/bitops.h>
 
@@ -351,8 +353,15 @@ static int proc_delete_dentry(struct dentry * dentry)
        return 1;
 }
 
+static int proc_revalidate_dentry(struct dentry *de, struct nameidata *nd)
+{
+       /* maybe add a check if it's really necessary? */
+       return 0;
+}
+
 static struct dentry_operations proc_dentry_operations =
 {
+       .d_revalidate   = proc_revalidate_dentry,
        .d_delete       = proc_delete_dentry,
 };
 
@@ -372,11 +381,14 @@ struct dentry *proc_lookup(struct inode * dir, struct dentry *dentry, struct nam
                for (de = de->subdir; de ; de = de->next) {
                        if (de->namelen != dentry->d_name.len)
                                continue;
+                       if (!vx_hide_check(0, de->vx_flags))
+                               continue;
                        if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
                                unsigned int ino = de->low_ino;
 
                                error = -EINVAL;
                                inode = proc_get_inode(dir->i_sb, ino, de);
+                               inode->i_xid = vx_current_xid();
                                break;
                        }
                }
@@ -448,9 +460,12 @@ int proc_readdir(struct file * filp,
                        }
 
                        do {
+                               if (!vx_hide_check(0, de->vx_flags))
+                                       goto skip;
                                if (filldir(dirent, de->name, de->namelen, filp->f_pos,
                                            de->low_ino, de->mode >> 12) < 0)
                                        goto out;
+                       skip:
                                filp->f_pos++;
                                de = de->next;
                        } while (de);
@@ -562,6 +577,7 @@ static struct proc_dir_entry *proc_create(struct proc_dir_entry **parent,
        ent->namelen = len;
        ent->mode = mode;
        ent->nlink = nlink;
+       ent->vx_flags = IATTR_PROC_DEFAULT;
  out:
        return ent;
 }
@@ -582,7 +598,8 @@ struct proc_dir_entry *proc_symlink(const char *name,
                                kfree(ent->data);
                                kfree(ent);
                                ent = NULL;
-                       }
+                       } else
+                               ent->vx_flags = IATTR_PROC_SYMLINK;
                } else {
                        kfree(ent);
                        ent = NULL;
@@ -685,7 +702,7 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
                        parent->nlink--;
                proc_kill_inodes(de);
                de->nlink = 0;
-               WARN_ON(de->subdir);
+               BUG_ON(de->subdir);
                if (!atomic_read(&de->count))
                        free_proc_entry(de);
                else {
index 2d38f02..bf090da 100644 (file)
@@ -211,6 +211,8 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
                        inode->i_uid = de->uid;
                        inode->i_gid = de->gid;
                }
+               if (de->vx_flags)
+                       PROC_I(inode)->vx_flags = de->vx_flags;
                if (de->size)
                        inode->i_size = de->size;
                if (de->nlink)
index f7c0cda..ee1b56b 100644 (file)
@@ -25,7 +25,7 @@
 
 static int open_kcore(struct inode * inode, struct file * filp)
 {
-       return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
+       return -EPERM;
 }
 
 static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *);
index 415d6ee..f2d7bf0 100644 (file)
@@ -44,6 +44,9 @@
 #include <linux/jiffies.h>
 #include <linux/sysrq.h>
 #include <linux/vmalloc.h>
+#include <linux/vs_base.h>
+#include <linux/vs_cvirt.h>
+
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
@@ -140,6 +143,9 @@ static int uptime_read_proc(char *page, char **start, off_t off,
 
        do_posix_clock_monotonic_gettime(&uptime);
        jiffies_to_timespec(idle_jiffies, &idle);
+       if (vx_flags(VXF_VIRT_UPTIME, 0))
+               vx_vsi_uptime(&uptime, &idle);
+
        len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
                        (unsigned long) uptime.tv_sec,
                        (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
@@ -418,12 +424,14 @@ int show_stat(struct seq_file *p, void *v)
                "btime %lu\n"
                "processes %lu\n"
                "procs_running %lu\n"
-               "procs_blocked %lu\n",
+               "procs_blocked %lu\n"
+               "preempt %llu\n",
                nr_context_switches(),
                (unsigned long)jif,
                total_forks,
                nr_running(),
-               nr_iowait());
+               nr_iowait(),
+               nr_preempt());
 
        return 0;
 }
index 4ece27d..6d8492b 100644 (file)
@@ -23,6 +23,9 @@ struct proc_dir_entry *proc_net, *proc_bus, *proc_root_fs, *proc_root_driver;
 #ifdef CONFIG_SYSCTL
 struct proc_dir_entry *proc_sys_root;
 #endif
+struct proc_dir_entry *proc_virtual;
+
+extern void proc_vx_init(void);
 
 static struct super_block *proc_get_sb(struct file_system_type *fs_type,
        int flags, const char *dev_name, void *data)
@@ -75,6 +78,7 @@ void __init proc_root_init(void)
        proc_device_tree_init();
 #endif
        proc_bus = proc_mkdir("bus", NULL);
+       proc_vx_init();
 }
 
 static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, struct nameidata *nd)
index bbdfc94..43301d8 100644 (file)
@@ -34,12 +34,23 @@ char *task_mem(struct mm_struct *mm, char *buffer)
                "VmData:\t%8lu kB\n"
                "VmStk:\t%8lu kB\n"
                "VmExe:\t%8lu kB\n"
-               "VmLib:\t%8lu kB\n",
+               "VmLib:\t%8lu kB\n"
+               "StaBrk:\t%08lx kB\n"
+               "Brk:\t%08lx kB\n"
+               "StaStk:\t%08lx kB\n"
+#if __i386__
+               "ExecLim:\t%08lx\n"
+#endif
+               ,
                mm->total_vm << (PAGE_SHIFT-10),
                mm->locked_vm << (PAGE_SHIFT-10),
                mm->rss << (PAGE_SHIFT-10),
                data - stack, stack,
-               exec - lib, lib);
+               exec - lib, lib, mm->start_brk, mm->brk, mm->start_stack
+#if __i386__
+               , mm->context.exec_limit
+#endif
+               );
        up_read(&mm->mmap_sem);
        return buffer;
 }
diff --git a/fs/rcfs/Makefile b/fs/rcfs/Makefile
new file mode 100644 (file)
index 0000000..13c3d67
--- /dev/null
@@ -0,0 +1,9 @@
+#
+# Makefile for rcfs routines.
+#
+
+obj-$(CONFIG_RCFS_FS) += rcfs.o 
+rcfs-objs := super.o inode.o dir.o rootdir.o magic.o tc_magic.o socket_fs.o
+
+rcfs-objs-$(CONFIG_CKRM_TYPE_TASKCLASS) += tc_magic.o
+rcfs-objs-$(CONFIG_CKRM_TYPE_SOCKETCLASS) += socket_fs.o
diff --git a/fs/rcfs/dir.c b/fs/rcfs/dir.c
new file mode 100644 (file)
index 0000000..545500e
--- /dev/null
@@ -0,0 +1,311 @@
+/* 
+ * fs/rcfs/dir.c 
+ *
+ * Copyright (C) Shailabh Nagar,  IBM Corp. 2004
+ *               Vivek Kashyap,   IBM Corp. 2004
+ *           
+ * 
+ * Directory operations for rcfs
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 08 Mar 2004
+ *        Created.
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/namespace.h>
+#include <linux/dcache.h>
+#include <linux/seq_file.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/smp_lock.h>
+#include <linux/backing-dev.h>
+#include <linux/parser.h>
+
+#include <asm/uaccess.h>
+
+#include <linux/rcfs.h>
+
+#define rcfs_positive(dentry)  ((dentry)->d_inode && !d_unhashed((dentry)))
+
+int rcfs_empty(struct dentry *dentry)
+{
+       struct dentry *child;
+       int ret = 0;
+
+       spin_lock(&dcache_lock);
+       list_for_each_entry(child, &dentry->d_subdirs, d_child)
+           if (!rcfs_is_magic(child) && rcfs_positive(child))
+               goto out;
+       ret = 1;
+      out:
+       spin_unlock(&dcache_lock);
+       return ret;
+}
+
+/* Directory inode operations */
+
+int
+rcfs_create(struct inode *dir, struct dentry *dentry, int mode,
+           struct nameidata *nd)
+{
+       return rcfs_mknod(dir, dentry, mode | S_IFREG, 0);
+}
+
+EXPORT_SYMBOL(rcfs_create);
+
+/* Symlinks permitted ?? */
+int rcfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
+{
+       struct inode *inode;
+       int error = -ENOSPC;
+
+       inode = rcfs_get_inode(dir->i_sb, S_IFLNK | S_IRWXUGO, 0);
+       if (inode) {
+               int l = strlen(symname) + 1;
+               error = page_symlink(inode, symname, l);
+               if (!error) {
+                       if (dir->i_mode & S_ISGID)
+                               inode->i_gid = dir->i_gid;
+                       d_instantiate(dentry, inode);
+                       dget(dentry);
+               } else
+                       iput(inode);
+       }
+       return error;
+}
+
+EXPORT_SYMBOL(rcfs_symlink);
+
+int rcfs_create_coredir(struct inode *dir, struct dentry *dentry)
+{
+
+       struct rcfs_inode_info *ripar, *ridir;
+       int sz;
+
+       ripar = RCFS_I(dir);
+       ridir = RCFS_I(dentry->d_inode);
+
+       // Inform RC's - do Core operations 
+       if (ckrm_is_core_valid(ripar->core)) {
+               sz = strlen(ripar->name) + strlen(dentry->d_name.name) + 2;
+               ridir->name = kmalloc(sz, GFP_KERNEL);
+               if (!ridir->name) {
+                       return -ENOMEM;
+               }
+               snprintf(ridir->name, sz, "%s/%s", ripar->name,
+                        dentry->d_name.name);
+               ridir->core = (*(ripar->core->classtype->alloc))
+                   (ripar->core, ridir->name);
+       } else {
+               printk(KERN_ERR "rcfs_mkdir: Invalid parent core %p\n",
+                      ripar->core);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+EXPORT_SYMBOL(rcfs_create_coredir);
+
+int rcfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+
+       int retval = 0;
+       ckrm_classtype_t *clstype;
+
+#if 0
+       struct dentry *pd = list_entry(dir->i_dentry.next, struct dentry,
+                                      d_alias);
+       if ((!strcmp(pd->d_name.name, "/") &&
+            !strcmp(dentry->d_name.name, "ce"))) {
+               // Call CE's mkdir if it has registered, else fail.
+               if (rcfs_eng_callbacks.mkdir) {
+                       return (*rcfs_eng_callbacks.mkdir) (dir, dentry, mode);
+               } else {
+                       return -EINVAL;
+               }
+       }
+#endif
+
+       if (_rcfs_mknod(dir, dentry, mode | S_IFDIR, 0)) {
+               printk(KERN_ERR "rcfs_mkdir: error in _rcfs_mknod\n");
+               return retval;
+       }
+
+       dir->i_nlink++;
+
+       // Inherit parent's ops since _rcfs_mknod assigns noperm ops
+       dentry->d_inode->i_op = dir->i_op;
+       dentry->d_inode->i_fop = dir->i_fop;
+
+       retval = rcfs_create_coredir(dir, dentry);
+       if (retval) {
+               simple_rmdir(dir, dentry);
+               return retval;
+               // goto mkdir_err;
+       }
+       // create the default set of magic files 
+       clstype = (RCFS_I(dentry->d_inode))->core->classtype;
+       rcfs_create_magic(dentry, &(((struct rcfs_magf *)clstype->mfdesc)[1]),
+                         clstype->mfcount - 3);
+
+       return retval;
+
+//mkdir_err:
+       dir->i_nlink--;
+       return retval;
+}
+
+EXPORT_SYMBOL(rcfs_mkdir);
+
+int rcfs_rmdir(struct inode *dir, struct dentry *dentry)
+{
+       struct rcfs_inode_info *ri = RCFS_I(dentry->d_inode);
+
+#if 0
+       struct dentry *pd = list_entry(dir->i_dentry.next,
+                                      struct dentry, d_alias);
+       if ((!strcmp(pd->d_name.name, "/") &&
+            !strcmp(dentry->d_name.name, "ce"))) {
+               // Call CE's mkdir if it has registered, else fail.
+               if (rcfs_eng_callbacks.rmdir) {
+                       return (*rcfs_eng_callbacks.rmdir) (dir, dentry);
+               } else {
+                       return simple_rmdir(dir, dentry);
+               }
+       } else if ((!strcmp(pd->d_name.name, "/") &&
+                   !strcmp(dentry->d_name.name, "network"))) {
+               return -EPERM;
+       }
+#endif
+
+       if (!rcfs_empty(dentry)) {
+               printk(KERN_ERR "rcfs_rmdir: directory not empty\n");
+               return -ENOTEMPTY;
+       }
+       // Core class removal 
+
+       if (ri->core == NULL) {
+               printk(KERN_ERR "rcfs_rmdir: core==NULL\n");
+               // likely a race condition
+               return 0;
+       }
+
+       if ((*(ri->core->classtype->free)) (ri->core)) {
+               printk(KERN_ERR "rcfs_rmdir: ckrm_free_core_class failed\n");
+               goto out;
+       }
+       ri->core = NULL;        // just to be safe 
+
+       // Clear magic files only after core successfully removed 
+       rcfs_clear_magic(dentry);
+
+       return simple_rmdir(dir, dentry);
+
+      out:
+       return -EBUSY;
+}
+
+EXPORT_SYMBOL(rcfs_rmdir);
+
+int rcfs_unlink(struct inode *dir, struct dentry *dentry)
+{
+       // -ENOENT and not -ENOPERM to allow rm -rf to work despite 
+       // magic files being present
+       return -ENOENT;
+}
+
+EXPORT_SYMBOL(rcfs_unlink);
+
+// rename is allowed on directories only
+int
+rcfs_rename(struct inode *old_dir, struct dentry *old_dentry,
+           struct inode *new_dir, struct dentry *new_dentry)
+{
+       if (S_ISDIR(old_dentry->d_inode->i_mode))
+               return simple_rename(old_dir, old_dentry, new_dir, new_dentry);
+       else
+               return -EINVAL;
+}
+
+EXPORT_SYMBOL(rcfs_rename);
+
+struct inode_operations rcfs_dir_inode_operations = {
+       .create = rcfs_create,
+       .lookup = simple_lookup,
+       .link = simple_link,
+       .unlink = rcfs_unlink,
+       .symlink = rcfs_symlink,
+       .mkdir = rcfs_mkdir,
+       .rmdir = rcfs_rmdir,
+       .mknod = rcfs_mknod,
+       .rename = rcfs_rename,
+};
+
+int
+rcfs_root_create(struct inode *dir, struct dentry *dentry, int mode,
+                struct nameidata *nd)
+{
+       return -EPERM;
+}
+
+int
+rcfs_root_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
+{
+       return -EPERM;
+}
+
+int rcfs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+       return -EPERM;
+}
+
+int rcfs_root_rmdir(struct inode *dir, struct dentry *dentry)
+{
+       return -EPERM;
+}
+
+int rcfs_root_unlink(struct inode *dir, struct dentry *dentry)
+{
+       return -EPERM;
+}
+
+int
+rcfs_root_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
+{
+       return -EPERM;
+}
+
+int
+rcfs_root_rename(struct inode *old_dir, struct dentry *old_dentry,
+                struct inode *new_dir, struct dentry *new_dentry)
+{
+       return -EPERM;
+}
+
+struct inode_operations rcfs_rootdir_inode_operations = {
+       .create = rcfs_root_create,
+       .lookup = simple_lookup,
+       .link = simple_link,
+       .unlink = rcfs_root_unlink,
+       .symlink = rcfs_root_symlink,
+       .mkdir = rcfs_root_mkdir,
+       .rmdir = rcfs_root_rmdir,
+       .mknod = rcfs_root_mknod,
+       .rename = rcfs_root_rename,
+};
diff --git a/fs/rcfs/inode.c b/fs/rcfs/inode.c
new file mode 100644 (file)
index 0000000..23ef014
--- /dev/null
@@ -0,0 +1,191 @@
+/* 
+ * fs/rcfs/inode.c 
+ *
+ * Copyright (C) Shailabh Nagar,  IBM Corp. 2004
+ *               Vivek Kashyap,   IBM Corp. 2004
+ *           
+ * 
+ * Resource class filesystem (rcfs) forming the 
+ * user interface to Class-based Kernel Resource Management (CKRM).
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 05 Mar 2004
+ *        Created.
+ * 06 Mar 2004
+ *        Parsing for shares added
+ */
+
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/namespace.h>
+#include <linux/dcache.h>
+#include <linux/seq_file.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/smp_lock.h>
+#include <linux/backing-dev.h>
+#include <linux/parser.h>
+#include <asm/uaccess.h>
+
+#include <linux/rcfs.h>
+
+// Address of variable used as flag to indicate a magic file, 
+// ; value unimportant 
+int RCFS_IS_MAGIC;
+
+struct inode *rcfs_get_inode(struct super_block *sb, int mode, dev_t dev)
+{
+       struct inode *inode = new_inode(sb);
+
+       if (inode) {
+               inode->i_mode = mode;
+               inode->i_uid = current->fsuid;
+               inode->i_gid = current->fsgid;
+               inode->i_blksize = PAGE_CACHE_SIZE;
+               inode->i_blocks = 0;
+               inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+               switch (mode & S_IFMT) {
+               default:
+                       init_special_inode(inode, mode, dev);
+                       break;
+               case S_IFREG:
+                       // Treat as default assignment */
+                       inode->i_op = &rcfs_file_inode_operations;
+                       // inode->i_fop = &rcfs_file_operations;
+                       break;
+               case S_IFDIR:
+                       // inode->i_op = &rcfs_dir_inode_operations;
+                       inode->i_op = &rcfs_rootdir_inode_operations;
+                       inode->i_fop = &simple_dir_operations;
+
+                       // directory inodes start off with i_nlink == 2 
+                       //  (for "." entry)
+
+                       inode->i_nlink++;
+                       break;
+               case S_IFLNK:
+                       inode->i_op = &page_symlink_inode_operations;
+                       break;
+               }
+       }
+       return inode;
+}
+
+int _rcfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
+{
+       struct inode *inode;
+       int error = -EPERM;
+
+       if (dentry->d_inode)
+               return -EEXIST;
+
+       inode = rcfs_get_inode(dir->i_sb, mode, dev);
+       if (inode) {
+               if (dir->i_mode & S_ISGID) {
+                       inode->i_gid = dir->i_gid;
+                       if (S_ISDIR(mode))
+                               inode->i_mode |= S_ISGID;
+               }
+               d_instantiate(dentry, inode);
+               dget(dentry);
+               error = 0;
+       }
+
+       return error;
+}
+
+EXPORT_SYMBOL(_rcfs_mknod);
+
+int rcfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
+{
+       // User can only create directories, not files
+       if ((mode & S_IFMT) != S_IFDIR)
+               return -EINVAL;
+
+       return dir->i_op->mkdir(dir, dentry, mode);
+}
+
+EXPORT_SYMBOL(rcfs_mknod);
+
+struct dentry *rcfs_create_internal(struct dentry *parent,
+                                   struct rcfs_magf *magf, int magic)
+{
+       struct qstr qstr;
+       struct dentry *mfdentry;
+
+       // Get new dentry for name  
+       qstr.name = magf->name;
+       qstr.len = strlen(magf->name);
+       qstr.hash = full_name_hash(magf->name, qstr.len);
+       mfdentry = lookup_hash(&qstr, parent);
+
+       if (!IS_ERR(mfdentry)) {
+               int err;
+
+               down(&parent->d_inode->i_sem);
+               if (magic && (magf->mode & S_IFDIR))
+                       err = parent->d_inode->i_op->mkdir(parent->d_inode,
+                                                          mfdentry,
+                                                          magf->mode);
+               else {
+                       err = _rcfs_mknod(parent->d_inode, mfdentry,
+                                         magf->mode, 0);
+                       // _rcfs_mknod doesn't increment parent's link count, 
+                       // i_op->mkdir does.
+                       parent->d_inode->i_nlink++;
+               }
+               up(&parent->d_inode->i_sem);
+
+               if (err) {
+                       dput(mfdentry);
+                       return mfdentry;
+               }
+       }
+       return mfdentry;
+}
+
+EXPORT_SYMBOL(rcfs_create_internal);
+
+int rcfs_delete_internal(struct dentry *mfdentry)
+{
+       struct dentry *parent;
+
+       if (!mfdentry || !mfdentry->d_parent)
+               return -EINVAL;
+
+       parent = mfdentry->d_parent;
+
+       if (!mfdentry->d_inode) {
+               return 0;
+       }
+       down(&mfdentry->d_inode->i_sem);
+       if (S_ISDIR(mfdentry->d_inode->i_mode))
+               simple_rmdir(parent->d_inode, mfdentry);
+       else
+               simple_unlink(parent->d_inode, mfdentry);
+       up(&mfdentry->d_inode->i_sem);
+
+       d_delete(mfdentry);
+
+       return 0;
+}
+
+EXPORT_SYMBOL(rcfs_delete_internal);
+
+struct inode_operations rcfs_file_inode_operations = {
+       .getattr = simple_getattr,
+};
diff --git a/fs/rcfs/magic.c b/fs/rcfs/magic.c
new file mode 100644 (file)
index 0000000..1cada33
--- /dev/null
@@ -0,0 +1,575 @@
+/* 
+ * fs/rcfs/magic.c 
+ *
+ * Copyright (C) Shailabh Nagar,      IBM Corp. 2004
+ *           (C) Vivek Kashyap,       IBM Corp. 2004
+ *           (C) Chandra Seetharaman, IBM Corp. 2004
+ *           (C) Hubertus Franke,     IBM Corp. 2004
+ * 
+ * File operations for common magic files in rcfs, 
+ * the user interface for CKRM. 
+ * 
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 23 Apr 2004
+ *        Created from code kept earlier in fs/rcfs/magic_*.c
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/namespace.h>
+#include <linux/dcache.h>
+#include <linux/seq_file.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/smp_lock.h>
+#include <linux/parser.h>
+#include <asm/uaccess.h>
+
+#include <linux/rcfs.h>
+
+/******************************************************
+ * Macros
+ *
+ * generic macros to assist in writing magic fileops
+ *
+ *****************************************************/
+
+#define MAGIC_SHOW(FUNC)                                               \
+static int                                                             \
+FUNC ## _show(struct seq_file *s, void *v)                            \
+{                                                                     \
+       int rc=0;                                                      \
+        ssize_t precnt;                                                \
+       ckrm_core_class_t *core ;                                      \
+                                                                      \
+       core = (ckrm_core_class_t *)                                   \
+               (((struct rcfs_inode_info *)s->private)->core);        \
+                                                                      \
+       if (!ckrm_is_core_valid(core)) {                               \
+               return -EINVAL;                                        \
+        }                                                              \
+        precnt = s->count ;                                            \
+       if (core->classtype->show_ ## FUNC)                            \
+               rc = (* core->classtype->show_ ## FUNC)(core, s);      \
+                                                                       \
+        if (s->count == precnt)                                        \
+               seq_printf(s, "No data to display\n");                 \
+       return rc;                                                     \
+};
+
+#define MAGIC_OPEN(FUNC)                                               \
+static int                                                             \
+FUNC ## _open(struct inode *inode, struct file *file)                  \
+{                                                                      \
+       struct rcfs_inode_info *ri;                                    \
+       int ret=-EINVAL;                                               \
+                                                                      \
+       if (file->f_dentry && file->f_dentry->d_parent) {              \
+                                                                      \
+               ri = RCFS_I(file->f_dentry->d_parent->d_inode);        \
+               ret = single_open(file,FUNC ## _show, (void *)ri);     \
+       }                                                              \
+       return ret;                                                    \
+}
+
+#define MAGIC_CLOSE(FUNC)                                              \
+static int                                                             \
+FUNC ## _close(struct inode *inode, struct file *file)                \
+{                                                                     \
+       return single_release(inode,file);                             \
+}
+
+#define MAGIC_PARSE(FUNC)                                              \
+static int                                                             \
+FUNC ## _parse(char *options, char **resstr, char **otherstr)         \
+{                                                                     \
+       char *p;                                                       \
+       *resstr = NULL;                                                \
+                                                                      \
+       if (!options)                                                  \
+               return 0;                                              \
+                                                                      \
+       while ((p = strsep(&options, ",")) != NULL) {                  \
+               substring_t args[MAX_OPT_ARGS];                        \
+               int token;                                             \
+                                                                      \
+               if (!*p)                                               \
+                       continue;                                      \
+                                                                      \
+               token = match_token(p, FUNC##_tokens, args);           \
+               switch (token) {                                       \
+               case FUNC ## _res_type:                                \
+                       *resstr = match_strdup(args);                  \
+                       if (!strcmp(#FUNC, "config")) {                \
+                               char *str = p + strlen(p) + 1;         \
+                               *otherstr = kmalloc(strlen(str) + 1,   \
+                                                        GFP_KERNEL);  \
+                               if (*otherstr == NULL) {               \
+                                       kfree(*resstr);                \
+                                       *resstr = NULL;                \
+                                       return 0;                      \
+                               } else {                               \
+                                       strcpy(*otherstr, str);        \
+                                       return 1;                      \
+                               }                                      \
+                       }                                              \
+                       break;                                         \
+               case FUNC ## _str:                                     \
+                       *otherstr = match_strdup(args);                \
+                       break;                                         \
+               default:                                               \
+                       return 0;                                      \
+               }                                                      \
+       }                                                              \
+       return (*resstr != NULL);                                      \
+}
+
+#define MAGIC_WRITE(FUNC,CLSTYPEFUN)                                   \
+static ssize_t                                                         \
+FUNC ## _write(struct file *file, const char __user *buf,             \
+                          size_t count, loff_t *ppos)                 \
+{                                                                     \
+       struct rcfs_inode_info *ri =                                   \
+               RCFS_I(file->f_dentry->d_parent->d_inode);             \
+       char *optbuf, *otherstr=NULL, *resname=NULL;                   \
+       int done, rc = 0;                                              \
+       ckrm_core_class_t *core ;                                      \
+                                                                      \
+       core = ri->core;                                               \
+       if (!ckrm_is_core_valid(core))                                 \
+               return -EINVAL;                                        \
+                                                                      \
+       if ((ssize_t) count < 0                                        \
+           || (ssize_t) count > FUNC ## _max_input_size)              \
+               return -EINVAL;                                        \
+                                                                      \
+       if (!access_ok(VERIFY_READ, buf, count))                       \
+               return -EFAULT;                                        \
+                                                                      \
+       down(&(ri->vfs_inode.i_sem));                                  \
+                                                                      \
+       optbuf = kmalloc(FUNC ## _max_input_size, GFP_KERNEL);         \
+       __copy_from_user(optbuf, buf, count);                          \
+       if (optbuf[count-1] == '\n')                                   \
+               optbuf[count-1]='\0';                                  \
+                                                                      \
+       done = FUNC ## _parse(optbuf, &resname, &otherstr);            \
+                                                                      \
+       if (!done) {                                                   \
+               printk(KERN_ERR "Error parsing FUNC \n");              \
+               goto FUNC ## _write_out;                               \
+       }                                                              \
+                                                                      \
+       if (core->classtype-> CLSTYPEFUN) {                            \
+               rc = (*core->classtype->CLSTYPEFUN)                    \
+                       (core, resname, otherstr);                     \
+               if (rc) {                                              \
+                       printk(KERN_ERR "FUNC_write: CLSTYPEFUN error\n");   \
+                       goto FUNC ## _write_out;                       \
+               }                                                      \
+       }                                                              \
+                                                                      \
+FUNC ## _write_out:                                                   \
+       up(&(ri->vfs_inode.i_sem));                                    \
+       kfree(optbuf);                                                 \
+       kfree(otherstr);                                               \
+       kfree(resname);                                                \
+       return rc ? rc : count;                                        \
+}
+
+#define MAGIC_RD_FILEOPS(FUNC)                                         \
+struct file_operations FUNC ## _fileops = {                            \
+       .open           = FUNC ## _open,                               \
+       .read           = seq_read,                                    \
+       .llseek         = seq_lseek,                                   \
+       .release        = FUNC ## _close,                              \
+};                                                                     \
+EXPORT_SYMBOL(FUNC ## _fileops);
+
+#define MAGIC_RDWR_FILEOPS(FUNC)                                       \
+struct file_operations FUNC ## _fileops = {                            \
+       .open           = FUNC ## _open,                               \
+       .read           = seq_read,                                    \
+       .llseek         = seq_lseek,                                   \
+       .release        = FUNC ## _close,                              \
+       .write          = FUNC ## _write,                              \
+};                                                                     \
+EXPORT_SYMBOL(FUNC ## _fileops);
+
+/******************************************************************************
+ * Shared function used by Target / Reclassify
+ *
+ *
+ *****************************************************************************/
+
+#define TARGET_MAX_INPUT_SIZE 100
+
+static ssize_t
+target_reclassify_write(struct file *file, const char __user * buf,
+                       size_t count, loff_t * ppos, int manual)
+{
+       struct rcfs_inode_info *ri = RCFS_I(file->f_dentry->d_inode);
+       char *optbuf;
+       int rc = -EINVAL;
+       ckrm_classtype_t *clstype;
+
+       if ((ssize_t) count < 0 || (ssize_t) count > TARGET_MAX_INPUT_SIZE)
+               return -EINVAL;
+
+       if (!access_ok(VERIFY_READ, buf, count))
+               return -EFAULT;
+
+       down(&(ri->vfs_inode.i_sem));
+
+       optbuf = kmalloc(TARGET_MAX_INPUT_SIZE, GFP_KERNEL);
+       __copy_from_user(optbuf, buf, count);
+       if (optbuf[count - 1] == '\n')
+               optbuf[count - 1] = '\0';
+
+       clstype = ri->core->classtype;
+       if (clstype->forced_reclassify)
+               rc = (*clstype->forced_reclassify) (manual ? ri->core: NULL, optbuf);
+
+       up(&(ri->vfs_inode.i_sem));
+       kfree(optbuf);
+       return (!rc ? count : rc);
+
+}
+
+/******************************************************************************
+ * Target
+ *
+ * pseudo file for manually reclassifying members to a class
+ *
+ *****************************************************************************/
+
+static ssize_t
+target_write(struct file *file, const char __user * buf,
+            size_t count, loff_t * ppos)
+{
+       return target_reclassify_write(file,buf,count,ppos,1);
+}
+
+struct file_operations target_fileops = {
+       .write = target_write,
+};
+
+EXPORT_SYMBOL(target_fileops);
+
+/******************************************************************************
+ * Reclassify
+ *
+ * pseudo file for reclassification of an object through CE
+ *
+ *****************************************************************************/
+
+static ssize_t
+reclassify_write(struct file *file, const char __user * buf,
+                size_t count, loff_t * ppos)
+{
+       return target_reclassify_write(file,buf,count,ppos,0);
+}
+
+struct file_operations reclassify_fileops = {
+       .write = reclassify_write,
+};
+
+EXPORT_SYMBOL(reclassify_fileops);
+
+/******************************************************************************
+ * Config
+ *
+ * Set/get configuration parameters of a class. 
+ *
+ *****************************************************************************/
+
+/* Currently there are no per-class config parameters defined.
+ * Use existing code as a template
+ */
+
+#define config_max_input_size  300
+
+enum config_token_t {
+       config_str, config_res_type, config_err
+};
+
+static match_table_t config_tokens = {
+       {config_res_type, "res=%s"},
+       {config_err, NULL},
+};
+
+MAGIC_PARSE(config);
+MAGIC_WRITE(config, set_config);
+MAGIC_SHOW(config);
+MAGIC_OPEN(config);
+MAGIC_CLOSE(config);
+
+MAGIC_RDWR_FILEOPS(config);
+
+/******************************************************************************
+ * Members
+ *
+ * List members of a class
+ *
+ *****************************************************************************/
+
+MAGIC_SHOW(members);
+MAGIC_OPEN(members);
+MAGIC_CLOSE(members);
+
+MAGIC_RD_FILEOPS(members);
+
+/******************************************************************************
+ * Stats
+ *
+ * Get/reset class statistics
+ * No standard set of stats defined. Each resource controller chooses
+ * its own set of statistics to maintain and export.
+ *
+ *****************************************************************************/
+
+#define stats_max_input_size  50
+
+enum stats_token_t {
+       stats_res_type, stats_str, stats_err
+};
+
+static match_table_t stats_tokens = {
+       {stats_res_type, "res=%s"},
+       {stats_str, NULL},
+       {stats_err, NULL},
+};
+
+MAGIC_PARSE(stats);
+MAGIC_WRITE(stats, reset_stats);
+MAGIC_SHOW(stats);
+MAGIC_OPEN(stats);
+MAGIC_CLOSE(stats);
+
+MAGIC_RDWR_FILEOPS(stats);
+
+/******************************************************************************
+ * Shares
+ *
+ * Set/get shares of a taskclass.
+ * Share types and semantics are defined by rcfs and ckrm core 
+ * 
+ *****************************************************************************/
+
+#define SHARES_MAX_INPUT_SIZE  300
+
+/* The enums for the share types should match the indices expected by
+   array parameter to ckrm_set_resshare */
+
+/* Note only the first NUM_SHAREVAL enums correspond to share types,
+   the remaining ones are for token matching purposes */
+
+enum share_token_t {
+       MY_GUAR, MY_LIM, TOT_GUAR, MAX_LIM, SHARE_RES_TYPE, SHARE_ERR
+};
+
+/* Token matching for parsing input to this magic file */
+static match_table_t shares_tokens = {
+       {SHARE_RES_TYPE, "res=%s"},
+       {MY_GUAR, "guarantee=%d"},
+       {MY_LIM, "limit=%d"},
+       {TOT_GUAR, "total_guarantee=%d"},
+       {MAX_LIM, "max_limit=%d"},
+       {SHARE_ERR, NULL}
+};
+
+static int
+shares_parse(char *options, char **resstr, struct ckrm_shares *shares)
+{
+       char *p;
+       int option;
+
+       if (!options)
+               return 1;
+
+       while ((p = strsep(&options, ",")) != NULL) {
+
+               substring_t args[MAX_OPT_ARGS];
+               int token;
+
+               if (!*p)
+                       continue;
+
+               token = match_token(p, shares_tokens, args);
+               switch (token) {
+               case SHARE_RES_TYPE:
+                       *resstr = match_strdup(args);
+                       break;
+               case MY_GUAR:
+                       if (match_int(args, &option))
+                               return 0;
+                       shares->my_guarantee = option;
+                       break;
+               case MY_LIM:
+                       if (match_int(args, &option))
+                               return 0;
+                       shares->my_limit = option;
+                       break;
+               case TOT_GUAR:
+                       if (match_int(args, &option))
+                               return 0;
+                       shares->total_guarantee = option;
+                       break;
+               case MAX_LIM:
+                       if (match_int(args, &option))
+                               return 0;
+                       shares->max_limit = option;
+                       break;
+               default:
+                       return 0;
+               }
+
+       }
+       return 1;
+}
+
+static ssize_t
+shares_write(struct file *file, const char __user * buf,
+            size_t count, loff_t * ppos)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct rcfs_inode_info *ri;
+       char *optbuf;
+       int rc = 0;
+       struct ckrm_core_class *core;
+       int done;
+       char *resname = NULL;
+
+       struct ckrm_shares newshares = {
+               CKRM_SHARE_UNCHANGED,
+               CKRM_SHARE_UNCHANGED,
+               CKRM_SHARE_UNCHANGED,
+               CKRM_SHARE_UNCHANGED,
+               CKRM_SHARE_UNCHANGED,
+               CKRM_SHARE_UNCHANGED
+       };
+
+       if ((ssize_t) count < 0 || (ssize_t) count > SHARES_MAX_INPUT_SIZE)
+               return -EINVAL;
+
+       if (!access_ok(VERIFY_READ, buf, count))
+               return -EFAULT;
+
+       ri = RCFS_I(file->f_dentry->d_parent->d_inode);
+
+       if (!ri || !ckrm_is_core_valid((ckrm_core_class_t *) (ri->core))) {
+               printk(KERN_ERR "shares_write: Error accessing core class\n");
+               return -EFAULT;
+       }
+
+       down(&inode->i_sem);
+
+       core = ri->core;
+       optbuf = kmalloc(SHARES_MAX_INPUT_SIZE, GFP_KERNEL);
+       if (!optbuf) {
+               up(&inode->i_sem);
+               return -ENOMEM;
+       }
+
+       __copy_from_user(optbuf, buf, count);
+       if (optbuf[count - 1] == '\n')
+               optbuf[count - 1] = '\0';
+
+       done = shares_parse(optbuf, &resname, &newshares);
+       if (!done) {
+               printk(KERN_ERR "Error parsing shares\n");
+               rc = -EINVAL;
+               goto write_out;
+       }
+
+       if (core->classtype->set_shares) {
+               rc = (*core->classtype->set_shares) (core, resname, &newshares);
+               if (rc) {
+                       printk(KERN_ERR
+                              "shares_write: resctlr share set error\n");
+                       goto write_out;
+               }
+       }
+
+       printk(KERN_DEBUG "Set %s shares to %d %d %d %d\n",
+              resname,
+              newshares.my_guarantee,
+              newshares.my_limit,
+              newshares.total_guarantee, newshares.max_limit);
+
+       rc = count;
+
+      write_out:
+
+       up(&inode->i_sem);
+       kfree(optbuf);
+       kfree(resname);
+       return rc;
+}
+
+MAGIC_SHOW(shares);
+MAGIC_OPEN(shares);
+MAGIC_CLOSE(shares);
+
+MAGIC_RDWR_FILEOPS(shares);
+
+/*
+ * magic file creation/deletion
+ *
+ */
+
+int rcfs_clear_magic(struct dentry *parent)
+{
+       struct dentry *mftmp, *mfdentry;
+
+       list_for_each_entry_safe(mfdentry, mftmp, &parent->d_subdirs, d_child) {
+
+               if (!rcfs_is_magic(mfdentry))
+                       continue;
+
+               if (rcfs_delete_internal(mfdentry))
+                       printk(KERN_ERR
+                              "rcfs_clear_magic: error deleting one\n");
+       }
+
+       return 0;
+
+}
+
+EXPORT_SYMBOL(rcfs_clear_magic);
+
+int rcfs_create_magic(struct dentry *parent, struct rcfs_magf magf[], int count)
+{
+       int i;
+       struct dentry *mfdentry;
+
+       for (i = 0; i < count; i++) {
+               mfdentry = rcfs_create_internal(parent, &magf[i], 0);
+               if (IS_ERR(mfdentry)) {
+                       rcfs_clear_magic(parent);
+                       return -ENOMEM;
+               }
+               RCFS_I(mfdentry->d_inode)->core = RCFS_I(parent->d_inode)->core;
+               mfdentry->d_fsdata = &RCFS_IS_MAGIC;
+               if (magf[i].i_fop)
+                       mfdentry->d_inode->i_fop = magf[i].i_fop;
+               if (magf[i].i_op)
+                       mfdentry->d_inode->i_op = magf[i].i_op;
+       }
+       return 0;
+}
+
+EXPORT_SYMBOL(rcfs_create_magic);
diff --git a/fs/rcfs/rootdir.c b/fs/rcfs/rootdir.c
new file mode 100644 (file)
index 0000000..d827db6
--- /dev/null
@@ -0,0 +1,227 @@
+/* 
+ * fs/rcfs/rootdir.c 
+ *
+ * Copyright (C)   Vivek Kashyap,   IBM Corp. 2004
+ *           
+ * 
+ * Functions for creating root directories and magic files 
+ * for classtypes and classification engines under rcfs
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 08 April 2004
+ *        Created.
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/namespace.h>
+#include <linux/dcache.h>
+#include <linux/seq_file.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/smp_lock.h>
+#include <linux/backing-dev.h>
+#include <linux/parser.h>
+
+#include <asm/uaccess.h>
+
+#include <linux/rcfs.h>
+
+rbce_eng_callback_t rcfs_eng_callbacks = {
+       NULL, NULL
+};
+
+int rcfs_register_engine(rbce_eng_callback_t * rcbs)
+{
+       if (!rcbs->mkdir || rcfs_eng_callbacks.mkdir) {
+               return -EINVAL;
+       }
+       rcfs_eng_callbacks = *rcbs;
+       rcfs_engine_regd++;
+       return 0;
+}
+
+EXPORT_SYMBOL(rcfs_register_engine);
+
+int rcfs_unregister_engine(rbce_eng_callback_t * rcbs)
+{
+       if (!rcbs->mkdir || !rcfs_eng_callbacks.mkdir ||
+           (rcbs->mkdir != rcfs_eng_callbacks.mkdir)) {
+               return -EINVAL;
+       }
+       rcfs_eng_callbacks.mkdir = NULL;
+       rcfs_eng_callbacks.rmdir = NULL;
+       rcfs_engine_regd--;
+       return 0;
+}
+
+EXPORT_SYMBOL(rcfs_unregister_engine);
+
+/* rcfs_mkroot
+ * Create and return a "root" dentry under /rcfs. 
+ * Also create associated magic files 
+ *
+ * @mfdesc: array of rcfs_magf describing root dir and its magic files
+ * @count: number of entries in mfdesc
+ * @core:  core class to be associated with root
+ * @rootde: output parameter to return the newly created root dentry
+ */
+
+int rcfs_mkroot(struct rcfs_magf *mfdesc, int mfcount, struct dentry **rootde)
+{
+       int sz;
+       struct rcfs_magf *rootdesc = &mfdesc[0];
+       struct dentry *dentry;
+       struct rcfs_inode_info *rootri;
+
+       if ((mfcount < 0) || (!mfdesc))
+               return -EINVAL;
+
+       rootdesc = &mfdesc[0];
+       printk(KERN_DEBUG "allocating classtype root <%s>\n", rootdesc->name);
+       dentry = rcfs_create_internal(rcfs_rootde, rootdesc, 0);
+
+       if (!dentry) {
+               printk(KERN_ERR "Could not create %s\n", rootdesc->name);
+               return -ENOMEM;
+       }
+
+       rootri = RCFS_I(dentry->d_inode);
+       sz = strlen(rootdesc->name) + strlen(RCFS_ROOT) + 2;
+       rootri->name = kmalloc(sz, GFP_KERNEL);
+       if (!rootri->name) {
+               printk(KERN_ERR "Error allocating name for %s\n",
+                      rootdesc->name);
+               rcfs_delete_internal(dentry);
+               return -ENOMEM;
+       }
+       snprintf(rootri->name, sz, "%s/%s", RCFS_ROOT, rootdesc->name);
+
+       if (rootdesc->i_fop)
+               dentry->d_inode->i_fop = rootdesc->i_fop;
+       if (rootdesc->i_op)
+               dentry->d_inode->i_op = rootdesc->i_op;
+
+       // set output parameters
+       *rootde = dentry;
+
+       return 0;
+}
+
+EXPORT_SYMBOL(rcfs_mkroot);
+
+int rcfs_rmroot(struct dentry *rootde)
+{
+       struct rcfs_inode_info *ri;
+
+       if (!rootde)
+               return -EINVAL;
+
+       rcfs_clear_magic(rootde);
+       ri = RCFS_I(rootde->d_inode);
+       kfree(ri->name);
+       ri->name = NULL;
+       rcfs_delete_internal(rootde);
+       return 0;
+}
+
+EXPORT_SYMBOL(rcfs_rmroot);
+
+int rcfs_register_classtype(ckrm_classtype_t * clstype)
+{
+       int rc;
+       struct rcfs_inode_info *rootri;
+       struct rcfs_magf *mfdesc;
+
+       // Initialize mfdesc, mfcount 
+       clstype->mfdesc = (void *)genmfdesc[clstype->mfidx]->rootmf;
+       clstype->mfcount = genmfdesc[clstype->mfidx]->rootmflen;
+
+       mfdesc = (struct rcfs_magf *)clstype->mfdesc;
+
+       /* rcfs root entry has the same name as the classtype */
+       strncpy(mfdesc[0].name, clstype->name, RCFS_MAGF_NAMELEN);
+
+       rc = rcfs_mkroot(mfdesc, clstype->mfcount,
+                        (struct dentry **)&(clstype->rootde));
+       if (rc)
+               return rc;
+
+       rootri = RCFS_I(((struct dentry *)(clstype->rootde))->d_inode);
+       rootri->core = clstype->default_class;
+       clstype->default_class->name = rootri->name;
+       ckrm_core_grab(clstype->default_class);
+
+       // Create magic files under root 
+       if ((rc = rcfs_create_magic(clstype->rootde, &mfdesc[1],
+                                   clstype->mfcount - 1))) {
+               kfree(rootri->name);
+               rootri->name = NULL;
+               rcfs_delete_internal(clstype->rootde);
+               return rc;
+       }
+
+       return rc;
+}
+
+EXPORT_SYMBOL(rcfs_register_classtype);
+
+int rcfs_deregister_classtype(ckrm_classtype_t * clstype)
+{
+       int rc;
+
+       rc = rcfs_rmroot((struct dentry *)clstype->rootde);
+       if (!rc) {
+               clstype->default_class->name = NULL;
+               ckrm_core_drop(clstype->default_class);
+       }
+       return rc;
+}
+
+EXPORT_SYMBOL(rcfs_deregister_classtype);
+
+// Common root and magic file entries.
+// root name, root permissions, magic file names and magic file permissions 
+// are needed by all entities (classtypes and classification engines) existing 
+// under the rcfs mount point
+
+// The common sets of these attributes are listed here as a table. Individual 
+// classtypes and classification engines can simple specify the index into the 
+// table to initialize their magf entries. 
+//
+
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+extern struct rcfs_mfdesc tc_mfdesc;
+#endif
+
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+extern struct rcfs_mfdesc sock_mfdesc;
+#endif
+
+// extern struct rcfs_magf rbce_mfdesc;
+
+struct rcfs_mfdesc *genmfdesc[] = {
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+       &tc_mfdesc,
+#else
+       NULL,
+#endif
+#ifdef CONFIG_CKRM_TYPE_SOCKETCLASS
+       &sock_mfdesc,
+#else
+       NULL,
+#endif
+};
diff --git a/fs/rcfs/socket_fs.c b/fs/rcfs/socket_fs.c
new file mode 100644 (file)
index 0000000..f1c0899
--- /dev/null
@@ -0,0 +1,334 @@
+/* ckrm_socketaq.c 
+ *
+ * Copyright (C) Vivek Kashyap,      IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * Initial version
+ */
+
+/*******************************************************************************
+ *  Socket class type
+ *   
+ * Defines the root structure for socket based classes. Currently only inbound
+ * connection control is supported based on prioritized accept queues. 
+ ******************************************************************************/
+
+#include <linux/rcfs.h>
+#include <net/tcp.h>
+
+extern int rcfs_create(struct inode *, struct dentry *, int,
+                      struct nameidata *);
+extern int rcfs_unlink(struct inode *, struct dentry *);
+extern int rcfs_symlink(struct inode *, struct dentry *, const char *);
+extern int rcfs_mknod(struct inode *, struct dentry *, int mode, dev_t);
+extern int rcfs_mkdir(struct inode *, struct dentry *, int);
+extern int rcfs_rmdir(struct inode *, struct dentry *);
+extern int rcfs_rename(struct inode *, struct dentry *, struct inode *,
+                      struct dentry *);
+
+extern int rcfs_create_coredir(struct inode *, struct dentry *);
+int sock_mkdir(struct inode *, struct dentry *, int mode);
+int sock_rmdir(struct inode *, struct dentry *);
+
+int sock_create_noperm(struct inode *, struct dentry *, int,
+                      struct nameidata *);
+int sock_unlink_noperm(struct inode *, struct dentry *);
+int sock_mkdir_noperm(struct inode *, struct dentry *, int);
+int sock_rmdir_noperm(struct inode *, struct dentry *);
+int sock_mknod_noperm(struct inode *, struct dentry *, int, dev_t);
+
+void sock_set_directory(void);
+
+extern struct file_operations config_fileops,
+    members_fileops, shares_fileops, stats_fileops, target_fileops;
+
+struct inode_operations my_iops = {
+       .create = rcfs_create,
+       .lookup = simple_lookup,
+       .link = simple_link,
+       .unlink = rcfs_unlink,
+       .symlink = rcfs_symlink,
+       .mkdir = sock_mkdir,
+       .rmdir = sock_rmdir,
+       .mknod = rcfs_mknod,
+       .rename = rcfs_rename,
+};
+
+struct inode_operations class_iops = {
+       .create = sock_create_noperm,
+       .lookup = simple_lookup,
+       .link = simple_link,
+       .unlink = sock_unlink_noperm,
+       .symlink = rcfs_symlink,
+       .mkdir = sock_mkdir_noperm,
+       .rmdir = sock_rmdir_noperm,
+       .mknod = sock_mknod_noperm,
+       .rename = rcfs_rename,
+};
+
+struct inode_operations sub_iops = {
+       .create = sock_create_noperm,
+       .lookup = simple_lookup,
+       .link = simple_link,
+       .unlink = sock_unlink_noperm,
+       .symlink = rcfs_symlink,
+       .mkdir = sock_mkdir_noperm,
+       .rmdir = sock_rmdir_noperm,
+       .mknod = sock_mknod_noperm,
+       .rename = rcfs_rename,
+};
+
+struct rcfs_magf def_magf = {
+       .mode = RCFS_DEFAULT_DIR_MODE,
+       .i_op = &sub_iops,
+       .i_fop = NULL,
+};
+
+struct rcfs_magf sock_rootdesc[] = {
+       {
+        //      .name = should not be set, copy from classtype name,
+        .mode = RCFS_DEFAULT_DIR_MODE,
+        .i_op = &my_iops,
+        //.i_fop   = &simple_dir_operations,
+        .i_fop = NULL,
+        },
+       {
+        .name = "members",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &members_fileops,
+        },
+       {
+        .name = "target",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &target_fileops,
+        },
+       {
+        .name = "reclassify",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &reclassify_fileops,
+        },
+};
+
+struct rcfs_magf sock_magf[] = {
+       {
+        .name = "config",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &config_fileops,
+        },
+       {
+        .name = "members",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &members_fileops,
+        },
+       {
+        .name = "shares",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &shares_fileops,
+        },
+       {
+        .name = "stats",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &stats_fileops,
+        },
+       {
+        .name = "target",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &target_fileops,
+        },
+};
+
+struct rcfs_magf sub_magf[] = {
+       {
+        .name = "config",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &config_fileops,
+        },
+       {
+        .name = "shares",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &shares_fileops,
+        },
+       {
+        .name = "stats",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_op = &my_iops,
+        .i_fop = &stats_fileops,
+        },
+};
+
+struct rcfs_mfdesc sock_mfdesc = {
+       .rootmf = sock_rootdesc,
+       .rootmflen = (sizeof(sock_rootdesc) / sizeof(struct rcfs_magf)),
+};
+
+#define SOCK_MAX_MAGF (sizeof(sock_magf)/sizeof(struct rcfs_magf))
+#define LAQ_MAX_SUBMAGF (sizeof(sub_magf)/sizeof(struct rcfs_magf))
+
+int sock_rmdir(struct inode *p, struct dentry *me)
+{
+       struct dentry *mftmp, *mfdentry;
+       int ret = 0;
+
+       // delete all magic sub directories
+       list_for_each_entry_safe(mfdentry, mftmp, &me->d_subdirs, d_child) {
+               if (S_ISDIR(mfdentry->d_inode->i_mode)) {
+                       ret = rcfs_rmdir(me->d_inode, mfdentry);
+                       if (ret)
+                               return ret;
+               }
+       }
+       // delete ourselves
+       ret = rcfs_rmdir(p, me);
+
+       return ret;
+}
+
+#ifdef NUM_ACCEPT_QUEUES
+#define LAQ_NUM_ACCEPT_QUEUES NUM_ACCEPT_QUEUES
+#else
+#define LAQ_NUM_ACCEPT_QUEUES 0
+#endif
+
+int sock_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+       int retval = 0;
+       int i, j;
+       struct dentry *pentry, *mfdentry;
+
+       if (_rcfs_mknod(dir, dentry, mode | S_IFDIR, 0)) {
+               printk(KERN_ERR "rcfs_mkdir: error reaching parent\n");
+               return retval;
+       }
+       // Needed if only _rcfs_mknod is used instead of i_op->mkdir
+       dir->i_nlink++;
+
+       retval = rcfs_create_coredir(dir, dentry);
+       if (retval)
+               goto mkdir_err;
+
+       /* create the default set of magic files */
+       for (i = 0; i < SOCK_MAX_MAGF; i++) {
+               mfdentry = rcfs_create_internal(dentry, &sock_magf[i], 0);
+               mfdentry->d_fsdata = &RCFS_IS_MAGIC;
+               RCFS_I(mfdentry->d_inode)->core = RCFS_I(dentry->d_inode)->core;
+               if (sock_magf[i].i_fop)
+                       mfdentry->d_inode->i_fop = sock_magf[i].i_fop;
+               if (sock_magf[i].i_op)
+                       mfdentry->d_inode->i_op = sock_magf[i].i_op;
+       }
+
+       for (i = 1; i < LAQ_NUM_ACCEPT_QUEUES; i++) {
+               j = sprintf(def_magf.name, "%d", i);
+               def_magf.name[j] = '\0';
+
+               pentry = rcfs_create_internal(dentry, &def_magf, 0);
+               retval = rcfs_create_coredir(dentry->d_inode, pentry);
+               if (retval)
+                       goto mkdir_err;
+               pentry->d_fsdata = &RCFS_IS_MAGIC;
+               for (j = 0; j < LAQ_MAX_SUBMAGF; j++) {
+                       mfdentry =
+                           rcfs_create_internal(pentry, &sub_magf[j], 0);
+                       mfdentry->d_fsdata = &RCFS_IS_MAGIC;
+                       RCFS_I(mfdentry->d_inode)->core =
+                           RCFS_I(pentry->d_inode)->core;
+                       if (sub_magf[j].i_fop)
+                               mfdentry->d_inode->i_fop = sub_magf[j].i_fop;
+                       if (sub_magf[j].i_op)
+                               mfdentry->d_inode->i_op = sub_magf[j].i_op;
+               }
+               pentry->d_inode->i_op = &sub_iops;
+       }
+       dentry->d_inode->i_op = &class_iops;
+       return 0;
+
+      mkdir_err:
+       // Needed
+       dir->i_nlink--;
+       return retval;
+}
+
+#ifndef NUM_ACCEPT_QUEUES
+#define NUM_ACCEPT_QUEUES 0
+#endif
+
+char *sock_get_name(struct ckrm_core_class *c)
+{
+       char *p = (char *)c->name;
+
+       while (*p)
+               p++;
+       while (*p != '/' && p != c->name)
+               p--;
+
+       return ++p;
+}
+
+int
+sock_create_noperm(struct inode *dir, struct dentry *dentry, int mode,
+                  struct nameidata *nd)
+{
+       return -EPERM;
+}
+
+int sock_unlink_noperm(struct inode *dir, struct dentry *dentry)
+{
+       return -EPERM;
+}
+
+int sock_mkdir_noperm(struct inode *dir, struct dentry *dentry, int mode)
+{
+       return -EPERM;
+}
+
+int sock_rmdir_noperm(struct inode *dir, struct dentry *dentry)
+{
+       return -EPERM;
+}
+
+int
+sock_mknod_noperm(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
+{
+       return -EPERM;
+}
+
+#if 0
+void sock_set_directory()
+{
+       struct dentry *pentry, *dentry;
+
+       pentry = rcfs_set_magf_byname("listen_aq", (void *)&my_dir_magf[0]);
+       if (pentry) {
+               dentry = rcfs_create_internal(pentry, &my_dir_magf[1], 0);
+               if (my_dir_magf[1].i_fop)
+                       dentry->d_inode->i_fop = my_dir_magf[1].i_fop;
+               RCFS_I(dentry->d_inode)->core = RCFS_I(pentry->d_inode)->core;
+               dentry = rcfs_create_internal(pentry, &my_dir_magf[2], 0);
+               if (my_dir_magf[2].i_fop)
+                       dentry->d_inode->i_fop = my_dir_magf[2].i_fop;
+               RCFS_I(dentry->d_inode)->core = RCFS_I(pentry->d_inode)->core;
+       } else {
+               printk(KERN_ERR "Could not create /rcfs/listen_aq\n"
+                      "Perhaps /rcfs needs to be mounted\n");
+       }
+}
+#endif
diff --git a/fs/rcfs/super.c b/fs/rcfs/super.c
new file mode 100644 (file)
index 0000000..f013df2
--- /dev/null
@@ -0,0 +1,302 @@
+/* 
+ * fs/rcfs/super.c 
+ *
+ * Copyright (C) Shailabh Nagar,  IBM Corp. 2004
+ *              Vivek Kashyap,   IBM Corp. 2004
+ *           
+ * Super block operations for rcfs
+ * 
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 08 Mar 2004
+ *        Created.
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/namespace.h>
+#include <linux/dcache.h>
+#include <linux/seq_file.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/smp_lock.h>
+#include <linux/backing-dev.h>
+#include <linux/parser.h>
+
+#include <asm/uaccess.h>
+
+#include <linux/rcfs.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_rc.h>
+#include <linux/ckrm_ce.h>
+
+static kmem_cache_t *rcfs_inode_cachep;
+
+inline struct rcfs_inode_info *RCFS_I(struct inode *inode)
+{
+       return container_of(inode, struct rcfs_inode_info, vfs_inode);
+}
+
+EXPORT_SYMBOL(RCFS_I);
+
+static struct inode *rcfs_alloc_inode(struct super_block *sb)
+{
+       struct rcfs_inode_info *ri;
+       ri = (struct rcfs_inode_info *)kmem_cache_alloc(rcfs_inode_cachep,
+                                                       SLAB_KERNEL);
+       if (!ri)
+               return NULL;
+       ri->name = NULL;
+       return &ri->vfs_inode;
+}
+
+static void rcfs_destroy_inode(struct inode *inode)
+{
+       struct rcfs_inode_info *ri = RCFS_I(inode);
+
+       kfree(ri->name);
+       kmem_cache_free(rcfs_inode_cachep, ri);
+}
+
+static void
+rcfs_init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
+{
+       struct rcfs_inode_info *ri = (struct rcfs_inode_info *)foo;
+
+       if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
+           SLAB_CTOR_CONSTRUCTOR)
+               inode_init_once(&ri->vfs_inode);
+}
+
+int rcfs_init_inodecache(void)
+{
+       rcfs_inode_cachep = kmem_cache_create("rcfs_inode_cache",
+                                             sizeof(struct rcfs_inode_info),
+                                             0,
+                                             SLAB_HWCACHE_ALIGN |
+                                             SLAB_RECLAIM_ACCOUNT,
+                                             rcfs_init_once, NULL);
+       if (rcfs_inode_cachep == NULL)
+               return -ENOMEM;
+       return 0;
+}
+
+void rcfs_destroy_inodecache(void)
+{
+       printk(KERN_WARNING "destroy inodecache was called\n");
+       if (kmem_cache_destroy(rcfs_inode_cachep))
+               printk(KERN_INFO
+                      "rcfs_inode_cache: not all structures were freed\n");
+}
+
+struct super_operations rcfs_super_ops = {
+       .alloc_inode = rcfs_alloc_inode,
+       .destroy_inode = rcfs_destroy_inode,
+       .statfs = simple_statfs,
+       .drop_inode = generic_delete_inode,
+};
+
+struct dentry *rcfs_rootde;    /* redundant; can also get it from sb */
+static struct inode *rcfs_root;
+static struct rcfs_inode_info *rcfs_rootri;
+
+static int rcfs_fill_super(struct super_block *sb, void *data, int silent)
+{
+       struct inode *inode;
+       struct dentry *root;
+       struct rcfs_inode_info *rootri;
+       struct ckrm_classtype *clstype;
+       int i, rc;
+
+       sb->s_fs_info = NULL;
+       if (rcfs_mounted) {
+               return -EPERM;
+       }
+       rcfs_mounted++;
+
+       sb->s_blocksize = PAGE_CACHE_SIZE;
+       sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+       sb->s_magic = RCFS_MAGIC;
+       sb->s_op = &rcfs_super_ops;
+       inode = rcfs_get_inode(sb, S_IFDIR | 0755, 0);
+       if (!inode)
+               return -ENOMEM;
+       inode->i_op = &rcfs_rootdir_inode_operations;
+
+       root = d_alloc_root(inode);
+       if (!root) {
+               iput(inode);
+               return -ENOMEM;
+       }
+       sb->s_root = root;
+
+       // Link inode and core class 
+       rootri = RCFS_I(inode);
+       rootri->name = kmalloc(strlen(RCFS_ROOT) + 1, GFP_KERNEL);
+       if (!rootri->name) {
+               d_delete(root);
+               iput(inode);
+               return -ENOMEM;
+       }
+       strcpy(rootri->name, RCFS_ROOT);
+       rootri->core = NULL;
+
+       rcfs_root = inode;
+       sb->s_fs_info = rcfs_root = inode;
+       rcfs_rootde = root;
+       rcfs_rootri = rootri;
+
+       // register metatypes
+       for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
+               clstype = ckrm_classtypes[i];
+               if (clstype == NULL)
+                       continue;
+               printk(KERN_DEBUG "A non null classtype\n");
+
+               if ((rc = rcfs_register_classtype(clstype)))
+                       continue;       // could return with an error too 
+       }
+
+       // do post-mount initializations needed by CE
+       // this is distinct from CE registration done on rcfs module load
+       if (rcfs_engine_regd) {
+               if (rcfs_eng_callbacks.mnt)
+                       if ((rc = (*rcfs_eng_callbacks.mnt) ())) {
+                               printk(KERN_ERR "Error in CE mnt %d\n", rc);
+                       }
+       }
+       // Following comment handled by code above; keep nonetheless if it
+       // can be done better
+       //
+       // register CE's with rcfs 
+       // check if CE loaded
+       // call rcfs_register_engine for each classtype
+       // AND rcfs_mkroot (preferably subsume latter in former) 
+
+       return 0;
+}
+
+static struct super_block *rcfs_get_sb(struct file_system_type *fs_type,
+                                      int flags, const char *dev_name,
+                                      void *data)
+{
+       return get_sb_nodev(fs_type, flags, data, rcfs_fill_super);
+}
+
+void rcfs_kill_sb(struct super_block *sb)
+{
+       int i, rc;
+       struct ckrm_classtype *clstype;
+
+       if (sb->s_fs_info != rcfs_root) {
+               generic_shutdown_super(sb);
+               return;
+       }
+       rcfs_mounted--;
+
+       for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
+
+               clstype = ckrm_classtypes[i];
+               if (clstype == NULL || clstype->rootde == NULL)
+                       continue;
+
+               if ((rc = rcfs_deregister_classtype(clstype))) {
+                       printk(KERN_ERR "Error removing classtype %s\n",
+                              clstype->name);
+                       // return ;   // can also choose to stop here
+               }
+       }
+
+       // do pre-umount shutdown needed by CE
+       // this is distinct from CE deregistration done on rcfs module unload
+       if (rcfs_engine_regd) {
+               if (rcfs_eng_callbacks.umnt)
+                       if ((rc = (*rcfs_eng_callbacks.umnt) ())) {
+                               printk(KERN_ERR "Error in CE umnt %d\n", rc);
+                               // return ; until error handling improves
+                       }
+       }
+       // Following comment handled by code above; keep nonetheless if it 
+       // can be done better
+       //
+       // deregister CE with rcfs
+       // Check if loaded
+       // if ce is in  one directory /rcfs/ce, 
+       //       rcfs_deregister_engine for all classtypes within above 
+       //             codebase 
+       //       followed by
+       //       rcfs_rmroot here
+       // if ce in multiple (per-classtype) directories
+       //       call rbce_deregister_engine within ckrm_deregister_classtype
+
+       // following will automatically clear rcfs root entry including its 
+       //  rcfs_inode_info
+
+       generic_shutdown_super(sb);
+
+       // printk(KERN_ERR "Removed all entries\n");
+}
+
+static struct file_system_type rcfs_fs_type = {
+       .name = "rcfs",
+       .get_sb = rcfs_get_sb,
+       .kill_sb = rcfs_kill_sb,
+};
+
+struct rcfs_functions my_rcfs_fn = {
+       .mkroot = rcfs_mkroot,
+       .rmroot = rcfs_rmroot,
+       .register_classtype = rcfs_register_classtype,
+       .deregister_classtype = rcfs_deregister_classtype,
+};
+
+extern struct rcfs_functions rcfs_fn;
+
+static int __init init_rcfs_fs(void)
+{
+       int ret;
+
+       ret = register_filesystem(&rcfs_fs_type);
+       if (ret)
+               goto init_register_err;
+
+       ret = rcfs_init_inodecache();
+       if (ret)
+               goto init_cache_err;
+
+       rcfs_fn = my_rcfs_fn;
+
+       // Due to tight coupling of this module with ckrm
+       // do not allow this module to be removed.
+       try_module_get(THIS_MODULE);
+       return ret;
+
+      init_cache_err:
+       unregister_filesystem(&rcfs_fs_type);
+      init_register_err:
+       return ret;
+}
+
+static void __exit exit_rcfs_fs(void)
+{
+       rcfs_destroy_inodecache();
+       unregister_filesystem(&rcfs_fs_type);
+}
+
+module_init(init_rcfs_fs)
+    module_exit(exit_rcfs_fs)
+
+    MODULE_LICENSE("GPL");
diff --git a/fs/rcfs/tc_magic.c b/fs/rcfs/tc_magic.c
new file mode 100644 (file)
index 0000000..9ef6d4d
--- /dev/null
@@ -0,0 +1,100 @@
+/* 
+ * fs/rcfs/tc_magic.c 
+ *
+ * Copyright (C) Shailabh Nagar,      IBM Corp. 2004
+ *           (C) Vivek Kashyap,       IBM Corp. 2004
+ *           (C) Chandra Seetharaman, IBM Corp. 2004
+ *           (C) Hubertus Franke,     IBM Corp. 2004
+ *           
+ * 
+ * define magic fileops for taskclass classtype
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 23 Apr 2004
+ *        Created.
+ *
+ */
+
+#include <linux/rcfs.h>
+#include <linux/ckrm_tc.h>
+
+/*****************************************************************************
+ * Taskclass general
+ *
+ * Define structures for taskclass root directory and its magic files 
+ * In taskclasses, there is one set of magic files, created automatically under
+ * the taskclass root (upon classtype registration) and each directory (class) 
+ * created subsequently. However, classtypes can also choose to have different 
+ * sets of magic files created under their root and other directories under 
+ * root using their mkdir function. RCFS only provides helper functions for 
+ * creating the root directory and its magic files
+ * 
+ *****************************************************************************/
+
+#define TC_FILE_MODE (S_IFREG | S_IRUGO | S_IWUSR)
+
+#define NR_TCROOTMF  7
+struct rcfs_magf tc_rootdesc[NR_TCROOTMF] = {
+       /* First entry must be root */
+       {
+//              .name    = should not be set, copy from classtype name
+        .mode = RCFS_DEFAULT_DIR_MODE,
+        .i_op = &rcfs_dir_inode_operations,
+        .i_fop = &simple_dir_operations,
+        },
+       /* Rest are root's magic files */
+       {
+        .name = "target",
+        .mode = TC_FILE_MODE,
+        .i_fop = &target_fileops,
+        .i_op = &rcfs_file_inode_operations,
+        },
+       {
+        .name = "members",
+        .mode = TC_FILE_MODE,
+        .i_fop = &members_fileops,
+        .i_op = &rcfs_file_inode_operations,
+        },
+       {
+        .name = "stats",
+        .mode = TC_FILE_MODE,
+        .i_fop = &stats_fileops,
+        .i_op = &rcfs_file_inode_operations,
+        },
+       {
+        .name = "shares",
+        .mode = TC_FILE_MODE,
+        .i_fop = &shares_fileops,
+        .i_op = &rcfs_file_inode_operations,
+        },
+       // Reclassify and Config should be made available only at the 
+       // root level. Make sure they are the last two entries, as 
+       // rcfs_mkdir depends on it
+       {
+        .name = "reclassify",
+        .mode = TC_FILE_MODE,
+        .i_fop = &reclassify_fileops,
+        .i_op = &rcfs_file_inode_operations,
+        },
+       {
+        .name = "config",
+        .mode = TC_FILE_MODE,
+        .i_fop = &config_fileops,
+        .i_op = &rcfs_file_inode_operations,
+        },
+};
+
+struct rcfs_mfdesc tc_mfdesc = {
+       .rootmf = tc_rootdesc,
+       .rootmflen = NR_TCROOTMF,
+};
index d85431d..7bf9572 100644 (file)
@@ -145,7 +145,6 @@ asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
 bad:
        return retval;
 }
-EXPORT_SYMBOL_GPL(sys_lseek);
 
 #ifdef __ARCH_WANT_SYS_LLSEEK
 asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high,
@@ -296,7 +295,6 @@ asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(sys_read);
 
 asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t count)
 {
index f52b701..11ce15e 100644 (file)
@@ -1160,7 +1160,7 @@ ssize_t reiserfs_file_write( struct file *file, /* the file we are going to writ
     if (res)
        goto out;
 
-    inode_update_time(inode, 1); /* Both mtime and ctime */
+    inode_update_time(inode, file->f_vfsmnt, 1); /* Both mtime and ctime */
 
     // Ok, we are done with all the checks.
 
index 335e006..bf51301 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mpage.h>
 #include <linux/writeback.h>
 #include <linux/quotaops.h>
+#include <linux/vserver/xid.h>
 
 extern int reiserfs_default_io_size; /* default io size devuned in super.c */
 
@@ -1010,6 +1011,8 @@ static void init_inode (struct inode * inode, struct path * path)
     struct buffer_head * bh;
     struct item_head * ih;
     __u32 rdev;
+    uid_t uid;
+    gid_t gid;
     //int version = ITEM_VERSION_1;
 
     bh = PATH_PLAST_BUFFER (path);
@@ -1033,12 +1036,13 @@ static void init_inode (struct inode * inode, struct path * path)
        struct stat_data_v1 * sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih);
        unsigned long blocks;
 
+       uid = sd_v1_uid(sd);
+       gid = sd_v1_gid(sd);
+
        set_inode_item_key_version (inode, KEY_FORMAT_3_5);
         set_inode_sd_version (inode, STAT_DATA_V1);
        inode->i_mode  = sd_v1_mode(sd);
        inode->i_nlink = sd_v1_nlink(sd);
-       inode->i_uid   = sd_v1_uid(sd);
-       inode->i_gid   = sd_v1_gid(sd);
        inode->i_size  = sd_v1_size(sd);
        inode->i_atime.tv_sec = sd_v1_atime(sd);
        inode->i_mtime.tv_sec = sd_v1_mtime(sd);
@@ -1078,11 +1082,12 @@ static void init_inode (struct inode * inode, struct path * path)
        // (directories and symlinks)
        struct stat_data * sd = (struct stat_data *)B_I_PITEM (bh, ih);
 
+       uid    = sd_v2_uid(sd);
+       gid    = sd_v2_gid(sd);
+
        inode->i_mode   = sd_v2_mode(sd);
        inode->i_nlink  = sd_v2_nlink(sd);
-       inode->i_uid    = sd_v2_uid(sd);
        inode->i_size   = sd_v2_size(sd);
-       inode->i_gid    = sd_v2_gid(sd);
        inode->i_mtime.tv_sec  = sd_v2_mtime(sd);
        inode->i_atime.tv_sec = sd_v2_atime(sd);
        inode->i_ctime.tv_sec  = sd_v2_ctime(sd);
@@ -1109,6 +1114,9 @@ static void init_inode (struct inode * inode, struct path * path)
        REISERFS_I(inode)->i_attrs = sd_v2_attrs( sd );
        sd_attrs_to_i_attrs( sd_v2_attrs( sd ), inode );
     }
+    inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
+    inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
+    inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid, 0);
 
     pathrelse (path);
     if (S_ISREG (inode->i_mode)) {
@@ -1133,13 +1141,15 @@ static void init_inode (struct inode * inode, struct path * path)
 static void inode2sd (void * sd, struct inode * inode, loff_t size)
 {
     struct stat_data * sd_v2 = (struct stat_data *)sd;
+    uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
+    gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
     __u16 flags;
 
+    set_sd_v2_uid(sd_v2, uid );
+    set_sd_v2_gid(sd_v2, gid );
     set_sd_v2_mode(sd_v2, inode->i_mode );
     set_sd_v2_nlink(sd_v2, inode->i_nlink );
-    set_sd_v2_uid(sd_v2, inode->i_uid );
     set_sd_v2_size(sd_v2, size );
-    set_sd_v2_gid(sd_v2, inode->i_gid );
     set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec );
     set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec );
     set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec );
@@ -2454,6 +2464,14 @@ void sd_attrs_to_i_attrs( __u16 sd_attrs, struct inode *inode )
                        inode -> i_flags |= S_IMMUTABLE;
                else
                        inode -> i_flags &= ~S_IMMUTABLE;
+               if( sd_attrs & REISERFS_IUNLINK_FL )
+                       inode -> i_flags |= S_IUNLINK;
+               else
+                       inode -> i_flags &= ~S_IUNLINK;
+               if( sd_attrs & REISERFS_BARRIER_FL )
+                       inode -> i_flags |= S_BARRIER;
+               else
+                       inode -> i_flags &= ~S_BARRIER;
                if( sd_attrs & REISERFS_APPEND_FL )
                        inode -> i_flags |= S_APPEND;
                else
@@ -2476,6 +2494,14 @@ void i_attrs_to_sd_attrs( struct inode *inode, __u16 *sd_attrs )
                        *sd_attrs |= REISERFS_IMMUTABLE_FL;
                else
                        *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
+               if( inode -> i_flags & S_IUNLINK )
+                       *sd_attrs |= REISERFS_IUNLINK_FL;
+               else
+                       *sd_attrs &= ~REISERFS_IUNLINK_FL;
+               if( inode -> i_flags & S_BARRIER )
+                       *sd_attrs |= REISERFS_BARRIER_FL;
+               else
+                       *sd_attrs &= ~REISERFS_BARRIER_FL;
                if( inode -> i_flags & S_SYNC )
                        *sd_attrs |= REISERFS_SYNC_FL;
                else
@@ -2648,11 +2674,36 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
                        offset, nr_segs, reiserfs_get_blocks_direct_io, NULL);
 }
 
+int reiserfs_setattr_flags(struct inode *inode, unsigned int flags)
+{
+       unsigned int oldflags, newflags;
+
+       oldflags = REISERFS_I(inode)->i_flags;
+       newflags = oldflags & ~(REISERFS_IMMUTABLE_FL |
+               REISERFS_IUNLINK_FL | REISERFS_BARRIER_FL);
+       if (flags & ATTR_FLAG_IMMUTABLE)
+               newflags |= REISERFS_IMMUTABLE_FL;
+       if (flags & ATTR_FLAG_IUNLINK)
+               newflags |= REISERFS_IUNLINK_FL;
+       if (flags & ATTR_FLAG_BARRIER)
+               newflags |= REISERFS_BARRIER_FL;
+
+       if (oldflags ^ newflags) {
+               REISERFS_I(inode)->i_flags = newflags;
+               inode->i_ctime = CURRENT_TIME;
+       }
+       return 0;
+}
+
 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) {
     struct inode *inode = dentry->d_inode ;
     int error ;
     unsigned int ia_valid = attr->ia_valid;
+
     reiserfs_write_lock(inode->i_sb);
+    if (S_ISDIR(inode->i_mode))
+       goto is_dir;
+
     if (attr->ia_valid & ATTR_SIZE) {
        /* version 2 items will be caught by the s_maxbytes check
        ** done for us in vmtruncate
@@ -2685,7 +2736,12 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) {
            goto out;
        }
 
+ is_dir:
     error = inode_change_ok(inode, attr) ;
+
+    if (!error && attr->ia_valid & ATTR_ATTR_FLAG)
+       reiserfs_setattr_flags(inode, attr->ia_attr_flags);
+
     if (!error) {
        if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
            (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
index 7f2fba5..201cf8b 100644 (file)
@@ -20,7 +20,7 @@
 int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                unsigned long arg)
 {
-       unsigned int flags;
+       unsigned int flags, oldflags;
 
        switch (cmd) {
            case REISERFS_IOC_UNPACK:
@@ -36,9 +36,11 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
        case REISERFS_IOC_GETFLAGS:
                flags = REISERFS_I(inode) -> i_attrs;
                i_attrs_to_sd_attrs( inode, ( __u16 * ) &flags );
+               flags &= REISERFS_FL_USER_VISIBLE;
                return put_user(flags, (int __user *) arg);
        case REISERFS_IOC_SETFLAGS: {
-               if (IS_RDONLY(inode))
+               if (IS_RDONLY(inode) ||
+                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
                        return -EROFS;
 
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
@@ -47,8 +49,12 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                if (get_user(flags, (int __user *) arg))
                        return -EFAULT;
 
-               if ( ( ( flags ^ REISERFS_I(inode) -> i_attrs) & ( REISERFS_IMMUTABLE_FL | REISERFS_APPEND_FL)) &&
-                    !capable( CAP_LINUX_IMMUTABLE ) )
+               oldflags = REISERFS_I(inode) -> i_attrs;
+               if ( ( (oldflags & REISERFS_IMMUTABLE_FL) ||
+                       ( (flags ^ oldflags) &
+                       (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
+                        REISERFS_APPEND_FL) ) ) &&
+                       !capable( CAP_LINUX_IMMUTABLE ) )
                        return -EPERM;
                        
                if( ( flags & REISERFS_NOTAIL_FL ) &&
@@ -59,6 +65,9 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                                if( result )
                                        return result;
                }
+               
+               flags = flags & REISERFS_FL_USER_MODIFYABLE;
+               flags |= oldflags & ~REISERFS_FL_USER_MODIFYABLE;
                sd_attrs_to_i_attrs( flags, inode );
                REISERFS_I(inode) -> i_attrs = flags;
                inode->i_ctime = CURRENT_TIME;
@@ -70,7 +79,8 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
        case REISERFS_IOC_SETVERSION:
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
                        return -EPERM;
-               if (IS_RDONLY(inode))
+               if (IS_RDONLY(inode) ||
+                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
                        return -EROFS;
                if (get_user(inode->i_generation, (int __user *) arg))
                        return -EFAULT; 
index 83ccc66..71eaa06 100644 (file)
@@ -703,6 +703,7 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st
        {"noattrs",     .clrmask = 1<<REISERFS_ATTRS},
        {"user_xattr",  .setmask = 1<<REISERFS_XATTRS_USER},
        {"nouser_xattr",.clrmask = 1<<REISERFS_XATTRS_USER},
+       {"tagxid",      .setmask = 1<<REISERFS_TAGXID},
 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
        {"acl",         .setmask = 1<<REISERFS_POSIXACL},
        {"noacl",       .clrmask = 1<<REISERFS_POSIXACL},
index 7ef7b45..f8babe6 100644 (file)
@@ -1342,7 +1342,7 @@ __reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd,
                /*
                 * Nobody gets write access to a read-only fs.
                 */
-               if (IS_RDONLY(inode) &&
+               if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
                    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                        return -EROFS;
 
@@ -1397,7 +1397,9 @@ __reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd,
                 }
 #endif
        } else {
+#ifdef CONFIG_REISERFS_FS_POSIX_ACL
 check_groups:
+#endif
                if (in_group_p(inode->i_gid))
                        mode >>= 3;
        }
@@ -1408,7 +1410,9 @@ check_groups:
        if (((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask))
                return 0;
 
+#ifdef CONFIG_REISERFS_FS_POSIX_ACL
 check_capabilities:
+#endif
        /*
         * Read/write DACs are always overridable.
         * Executable DACs are overridable if at least one exec bit is set.
diff --git a/fs/relayfs/Makefile b/fs/relayfs/Makefile
new file mode 100644 (file)
index 0000000..09f098a
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# relayfs Makefile
+#
+
+obj-$(CONFIG_RELAYFS_FS) += relayfs.o
+
+relayfs-y := relay.o relay_lockless.o relay_locking.o inode.o resize.o
+relayfs-$(CONFIG_KLOG_CHANNEL) += klog.o
diff --git a/fs/relayfs/inode.c b/fs/relayfs/inode.c
new file mode 100644 (file)
index 0000000..6e87360
--- /dev/null
@@ -0,0 +1,629 @@
+/*
+ * VFS-related code for RelayFS, a high-speed data relay filesystem.
+ *
+ * Copyright (C) 2003 - Tom Zanussi <zanussi@us.ibm.com>, IBM Corp
+ * Copyright (C) 2003 - Karim Yaghmour <karim@opersys.com>
+ *
+ * Based on ramfs, Copyright (C) 2002 - Linus Torvalds
+ *
+ * This file is released under the GPL.
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/mount.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/smp_lock.h>
+#include <linux/backing-dev.h>
+#include <linux/namei.h>
+#include <linux/poll.h>
+#include <asm/uaccess.h>
+#include <asm/relay.h>
+
+#define RELAYFS_MAGIC                  0x26F82121
+
+static struct super_operations         relayfs_ops;
+static struct address_space_operations relayfs_aops;
+static struct inode_operations         relayfs_file_inode_operations;
+static struct file_operations          relayfs_file_operations;
+static struct inode_operations         relayfs_dir_inode_operations;
+
+static struct vfsmount *               relayfs_mount;
+static int                             relayfs_mount_count;
+
+static struct backing_dev_info         relayfs_backing_dev_info = {
+       .ra_pages       = 0,    /* No readahead */
+       .memory_backed  = 1,    /* Does not contribute to dirty memory */
+};
+
+static struct inode *
+relayfs_get_inode(struct super_block *sb, int mode, dev_t dev)
+{
+       struct inode * inode;
+       
+       inode = new_inode(sb);
+
+       if (inode) {
+               inode->i_mode = mode;
+               inode->i_uid = current->fsuid;
+               inode->i_gid = current->fsgid;
+               inode->i_blksize = PAGE_CACHE_SIZE;
+               inode->i_blocks = 0;
+               inode->i_mapping->a_ops = &relayfs_aops;
+               inode->i_mapping->backing_dev_info = &relayfs_backing_dev_info;
+               inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+               switch (mode & S_IFMT) {
+               default:
+                       init_special_inode(inode, mode, dev);
+                       break;
+               case S_IFREG:
+                       inode->i_op = &relayfs_file_inode_operations;
+                       inode->i_fop = &relayfs_file_operations;
+                       break;
+               case S_IFDIR:
+                       inode->i_op = &relayfs_dir_inode_operations;
+                       inode->i_fop = &simple_dir_operations;
+
+                       /* directory inodes start off with i_nlink == 2 (for "." entry) */
+                       inode->i_nlink++;
+                       break;
+               case S_IFLNK:
+                       inode->i_op = &page_symlink_inode_operations;
+                       break;
+               }
+       }
+       return inode;
+}
+
+/*
+ * File creation. Allocate an inode, and we're done..
+ */
+/* SMP-safe */
+static int 
+relayfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
+{
+       struct inode * inode;
+       int error = -ENOSPC;
+
+       inode = relayfs_get_inode(dir->i_sb, mode, dev);
+
+       if (inode) {
+               d_instantiate(dentry, inode);
+               dget(dentry);   /* Extra count - pin the dentry in core */
+               error = 0;
+       }
+       return error;
+}
+
+static int 
+relayfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
+{
+       int retval;
+
+       retval = relayfs_mknod(dir, dentry, mode | S_IFDIR, 0);
+
+       if (!retval)
+               dir->i_nlink++;
+       return retval;
+}
+
+static int 
+relayfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
+{
+       return relayfs_mknod(dir, dentry, mode | S_IFREG, 0);
+}
+
+static int 
+relayfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
+{
+       struct inode *inode;
+       int error = -ENOSPC;
+
+       inode = relayfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
+
+       if (inode) {
+               int l = strlen(symname)+1;
+               error = page_symlink(inode, symname, l);
+               if (!error) {
+                       d_instantiate(dentry, inode);
+                       dget(dentry);
+               } else
+                       iput(inode);
+       }
+       return error;
+}
+
+/**
+ *     relayfs_create_entry - create a relayfs directory or file
+ *     @name: the name of the file to create
+ *     @parent: parent directory
+ *     @dentry: result dentry
+ *     @entry_type: type of file to create (S_IFREG, S_IFDIR)
+ *     @mode: mode
+ *     @data: data to associate with the file
+ *
+ *     Creates a file or directory with the specifed permissions.
+ */
+static int 
+relayfs_create_entry(const char * name, struct dentry * parent, struct dentry **dentry, int entry_type, int mode, void * data)
+{
+       struct qstr qname;
+       struct dentry * d;
+       
+       int error = 0;
+
+       error = simple_pin_fs("relayfs", &relayfs_mount, &relayfs_mount_count);
+       if (error) {
+               printk(KERN_ERR "Couldn't mount relayfs: errcode %d\n", error);
+               return error;
+       }
+
+       qname.name = name;
+       qname.len = strlen(name);
+       qname.hash = full_name_hash(name, qname.len);
+
+       if (parent == NULL)
+               if (relayfs_mount && relayfs_mount->mnt_sb)
+                       parent = relayfs_mount->mnt_sb->s_root;
+
+       if (parent == NULL) {
+               simple_release_fs(&relayfs_mount, &relayfs_mount_count);
+               return -EINVAL;
+       }
+
+       parent = dget(parent);
+       down(&parent->d_inode->i_sem);
+       d = lookup_hash(&qname, parent);
+       if (IS_ERR(d)) {
+               error = PTR_ERR(d);
+               goto release_mount;
+       }
+       
+       if (d->d_inode) {
+               error = -EEXIST;
+               goto release_mount;
+       }
+
+       if (entry_type == S_IFREG)
+               error = relayfs_create(parent->d_inode, d, entry_type | mode, NULL);
+       else
+               error = relayfs_mkdir(parent->d_inode, d, entry_type | mode);
+       if (error)
+               goto release_mount;
+
+       if ((entry_type == S_IFREG) && data) {
+               d->d_inode->u.generic_ip = data;
+               goto exit; /* don't release mount for regular files */
+       }
+
+release_mount:
+       simple_release_fs(&relayfs_mount, &relayfs_mount_count);
+exit:  
+       *dentry = d;
+       up(&parent->d_inode->i_sem);
+       dput(parent);
+
+       return error;
+}
+
+/**
+ *     relayfs_create_file - create a file in the relay filesystem
+ *     @name: the name of the file to create
+ *     @parent: parent directory
+ *     @dentry: result dentry
+ *     @data: data to associate with the file
+ *     @mode: mode, if not specied the default perms are used
+ *
+ *     The file will be created user rw on behalf of current user.
+ */
+int 
+relayfs_create_file(const char * name, struct dentry * parent, struct dentry **dentry, void * data, int mode)
+{
+       if (!mode)
+               mode = S_IRUSR | S_IWUSR;
+       
+       return relayfs_create_entry(name, parent, dentry, S_IFREG,
+                                   mode, data);
+}
+
+/**
+ *     relayfs_create_dir - create a directory in the relay filesystem
+ *     @name: the name of the directory to create
+ *     @parent: parent directory
+ *     @dentry: result dentry
+ *
+ *     The directory will be created world rwx on behalf of current user.
+ */
+int 
+relayfs_create_dir(const char * name, struct dentry * parent, struct dentry **dentry)
+{
+       return relayfs_create_entry(name, parent, dentry, S_IFDIR,
+                                   S_IRWXU | S_IRUGO | S_IXUGO, NULL);
+}
+
+/**
+ *     relayfs_remove_file - remove a file in the relay filesystem
+ *     @dentry: file dentry
+ *
+ *     Remove a file previously created by relayfs_create_file.
+ */
+int 
+relayfs_remove_file(struct dentry *dentry)
+{
+       struct dentry *parent;
+       int is_reg;
+       
+       parent = dentry->d_parent;
+       if (parent == NULL)
+               return -EINVAL;
+
+       is_reg = S_ISREG(dentry->d_inode->i_mode);
+
+       parent = dget(parent);
+       down(&parent->d_inode->i_sem);
+       if (dentry->d_inode) {
+               simple_unlink(parent->d_inode, dentry);
+               d_delete(dentry);
+       }
+       dput(dentry);
+       up(&parent->d_inode->i_sem);
+       dput(parent);
+
+       if(is_reg)
+               simple_release_fs(&relayfs_mount, &relayfs_mount_count);
+
+       return 0;
+}
+
+/**
+ *     relayfs_open - open file op for relayfs files
+ *     @inode: the inode
+ *     @filp: the file
+ *
+ *     Associates the channel with the file, and increments the
+ *     channel refcount.  Reads will be 'auto-consuming'.
+ */
+int
+relayfs_open(struct inode *inode, struct file *filp)
+{
+       struct rchan *rchan;
+       struct rchan_reader *reader;
+       int retval = 0;
+
+       if (inode->u.generic_ip) {
+               rchan = (struct rchan *)inode->u.generic_ip;
+               if (rchan == NULL)
+                       return -EACCES;
+               reader = __add_rchan_reader(rchan, filp, 1, 0);
+               if (reader == NULL)
+                       return -ENOMEM;
+               filp->private_data = reader;
+               retval = rchan->callbacks->fileop_notify(rchan->id, filp,
+                                                        RELAY_FILE_OPEN);
+               if (retval == 0)
+                       /* Inc relay channel refcount for file */
+                       rchan_get(rchan->id);
+               else {
+                       __remove_rchan_reader(reader);
+                       retval = -EPERM;
+               }
+       }
+
+       return retval;
+}
+
+/**
+ *     relayfs_mmap - mmap file op for relayfs files
+ *     @filp: the file
+ *     @vma: the vma describing what to map
+ *
+ *     Calls upon relay_mmap_buffer to map the file into user space.
+ */
+int 
+relayfs_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+       struct rchan *rchan;
+       
+       rchan = ((struct rchan_reader *)filp->private_data)->rchan;
+
+       return __relay_mmap_buffer(rchan, vma);
+}
+
+/**
+ *     relayfs_file_read - read file op for relayfs files
+ *     @filp: the file
+ *     @buf: user buf to read into
+ *     @count: bytes requested
+ *     @offset: offset into file
+ *
+ *     Reads count bytes from the channel, or as much as is available within
+ *     the sub-buffer currently being read.  Reads are 'auto-consuming'.
+ *     See relay_read() for details.
+ *
+ *     Returns bytes read on success, 0 or -EAGAIN if nothing available,
+ *     negative otherwise.
+ */
+ssize_t 
+relayfs_file_read(struct file *filp, char * buf, size_t count, loff_t *offset)
+{
+       size_t read_count;
+       struct rchan_reader *reader;
+       u32 dummy; /* all VFS readers are auto-consuming */
+
+       if (offset != &filp->f_pos) /* pread, seeking not supported */
+               return -ESPIPE;
+
+       if (count == 0)
+               return 0;
+
+       reader = (struct rchan_reader *)filp->private_data;
+       read_count = relay_read(reader, buf, count,
+               filp->f_flags & (O_NDELAY | O_NONBLOCK) ? 0 : 1, &dummy);
+
+       return read_count;
+}
+
+/**
+ *     relayfs_file_write - write file op for relayfs files
+ *     @filp: the file
+ *     @buf: user buf to write from
+ *     @count: bytes to write
+ *     @offset: offset into file
+ *
+ *     Reserves a slot in the relay buffer and writes count bytes
+ *     into it.  The current limit for a single write is 2 pages
+ *     worth.  The user_deliver() channel callback will be invoked on
+ *     
+ *     Returns bytes written on success, 0 or -EAGAIN if nothing available,
+ *     negative otherwise.
+ */
+ssize_t 
+relayfs_file_write(struct file *filp, const char *buf, size_t count, loff_t *offset)
+{
+       int write_count;
+       char * write_buf;
+       struct rchan *rchan;
+       int err = 0;
+       void *wrote_pos;
+       struct rchan_reader *reader;
+
+       reader = (struct rchan_reader *)filp->private_data;
+       if (reader == NULL)
+               return -EPERM;
+
+       rchan = reader->rchan;
+       if (rchan == NULL)
+               return -EPERM;
+
+       if (count == 0)
+               return 0;
+
+       /* Change this if need to write more than 2 pages at once */
+       if (count > 2 * PAGE_SIZE)
+               return -EINVAL;
+       
+       write_buf = (char *)__get_free_pages(GFP_KERNEL, 1);
+       if (write_buf == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(write_buf, buf, count))
+               return -EFAULT;
+
+       if (filp->f_flags & (O_NDELAY | O_NONBLOCK)) {
+               write_count = relay_write(rchan->id, write_buf, count, -1, &wrote_pos);
+               if (write_count == 0)
+                       return -EAGAIN;
+       } else {
+               err = wait_event_interruptible(rchan->write_wait,
+                (write_count = relay_write(rchan->id, write_buf, count, -1, &wrote_pos)));
+               if (err)
+                       return err;
+       }
+       
+       free_pages((unsigned long)write_buf, 1);
+       
+        rchan->callbacks->user_deliver(rchan->id, wrote_pos, write_count);
+
+       return write_count;
+}
+
+/**
+ *     relayfs_ioctl - ioctl file op for relayfs files
+ *     @inode: the inode
+ *     @filp: the file
+ *     @cmd: the command
+ *     @arg: command arg
+ *
+ *     Passes the specified cmd/arg to the kernel client.  arg may be a 
+ *     pointer to user-space data, in which case the kernel client is 
+ *     responsible for copying the data to/from user space appropriately.
+ *     The kernel client is also responsible for returning a meaningful
+ *     return value for ioctl calls.
+ *     
+ *     Returns result of relay channel callback, -EPERM if unsuccessful.
+ */
+int
+relayfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
+{
+       struct rchan *rchan;
+       struct rchan_reader *reader;
+
+       reader = (struct rchan_reader *)filp->private_data;
+       if (reader == NULL)
+               return -EPERM;
+
+       rchan = reader->rchan;
+       if (rchan == NULL)
+               return -EPERM;
+
+       return rchan->callbacks->ioctl(rchan->id, cmd, arg);
+}
+
+/**
+ *     relayfs_poll - poll file op for relayfs files
+ *     @filp: the file
+ *     @wait: poll table
+ *
+ *     Poll implemention.
+ */
+static unsigned int
+relayfs_poll(struct file *filp, poll_table *wait)
+{
+       struct rchan_reader *reader;
+       unsigned int mask = 0;
+       
+       reader = (struct rchan_reader *)filp->private_data;
+
+       if (reader->rchan->finalized)
+               return POLLERR;
+
+       if (filp->f_mode & FMODE_READ) {
+               poll_wait(filp, &reader->rchan->read_wait, wait);
+               if (!rchan_empty(reader))
+                       mask |= POLLIN | POLLRDNORM;
+       }
+       
+       if (filp->f_mode & FMODE_WRITE) {
+               poll_wait(filp, &reader->rchan->write_wait, wait);
+               if (!rchan_full(reader))
+                       mask |= POLLOUT | POLLWRNORM;
+       }
+       
+       return mask;
+}
+
+/**
+ *     relayfs_release - release file op for relayfs files
+ *     @inode: the inode
+ *     @filp: the file
+ *
+ *     Decrements the channel refcount, as the filesystem is
+ *     no longer using it.
+ */
+int
+relayfs_release(struct inode *inode, struct file *filp)
+{
+       struct rchan_reader *reader;
+       struct rchan *rchan;
+
+       reader = (struct rchan_reader *)filp->private_data;
+       if (reader == NULL || reader->rchan == NULL)
+               return 0;
+       rchan = reader->rchan;
+       
+        rchan->callbacks->fileop_notify(reader->rchan->id, filp,
+                                       RELAY_FILE_CLOSE);
+       __remove_rchan_reader(reader);
+       /* The channel is no longer in use as far as this file is concerned */
+       rchan_put(rchan);
+
+       return 0;
+}
+
+static struct address_space_operations relayfs_aops = {
+       .readpage       = simple_readpage,
+       .prepare_write  = simple_prepare_write,
+       .commit_write   = simple_commit_write
+};
+
+static struct file_operations relayfs_file_operations = {
+       .open           = relayfs_open,
+       .read           = relayfs_file_read,
+       .write          = relayfs_file_write,
+       .ioctl          = relayfs_ioctl,
+       .poll           = relayfs_poll,
+       .mmap           = relayfs_mmap,
+       .fsync          = simple_sync_file,
+       .release        = relayfs_release,
+};
+
+static struct inode_operations relayfs_file_inode_operations = {
+       .getattr        = simple_getattr,
+};
+
+static struct inode_operations relayfs_dir_inode_operations = {
+       .create         = relayfs_create,
+       .lookup         = simple_lookup,
+       .link           = simple_link,
+       .unlink         = simple_unlink,
+       .symlink        = relayfs_symlink,
+       .mkdir          = relayfs_mkdir,
+       .rmdir          = simple_rmdir,
+       .mknod          = relayfs_mknod,
+       .rename         = simple_rename,
+};
+
+static struct super_operations relayfs_ops = {
+       .statfs         = simple_statfs,
+       .drop_inode     = generic_delete_inode,
+};
+
+static int 
+relayfs_fill_super(struct super_block * sb, void * data, int silent)
+{
+       struct inode * inode;
+       struct dentry * root;
+
+       sb->s_blocksize = PAGE_CACHE_SIZE;
+       sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+       sb->s_magic = RELAYFS_MAGIC;
+       sb->s_op = &relayfs_ops;
+       inode = relayfs_get_inode(sb, S_IFDIR | 0755, 0);
+
+       if (!inode)
+               return -ENOMEM;
+
+       root = d_alloc_root(inode);
+       if (!root) {
+               iput(inode);
+               return -ENOMEM;
+       }
+       sb->s_root = root;
+
+       return 0;
+}
+
+static struct super_block *
+relayfs_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data)
+{
+       return get_sb_single(fs_type, flags, data, relayfs_fill_super);
+}
+
+static struct file_system_type relayfs_fs_type = {
+       .owner          = THIS_MODULE,
+       .name           = "relayfs",
+       .get_sb         = relayfs_get_sb,
+       .kill_sb        = kill_litter_super,
+};
+
+static int __init 
+init_relayfs_fs(void)
+{
+       int err = register_filesystem(&relayfs_fs_type);
+#ifdef CONFIG_KLOG_CHANNEL
+       if (!err)
+               create_klog_channel();
+#endif
+       return err;
+}
+
+static void __exit 
+exit_relayfs_fs(void)
+{
+#ifdef CONFIG_KLOG_CHANNEL
+       remove_klog_channel();
+#endif
+       unregister_filesystem(&relayfs_fs_type);
+}
+
+module_init(init_relayfs_fs)
+module_exit(exit_relayfs_fs)
+
+MODULE_AUTHOR("Tom Zanussi <zanussi@us.ibm.com> and Karim Yaghmour <karim@opersys.com>");
+MODULE_DESCRIPTION("Relay Filesystem");
+MODULE_LICENSE("GPL");
+
diff --git a/fs/relayfs/klog.c b/fs/relayfs/klog.c
new file mode 100644 (file)
index 0000000..3f2d31d
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * KLOG                Generic Logging facility built upon the relayfs infrastructure
+ *
+ * Authors:    Hubertus Franke  (frankeh@us.ibm.com)
+ *             Tom Zanussi  (zanussi@us.ibm.com)
+ *
+ *             Please direct all questions/comments to zanussi@us.ibm.com
+ *
+ *             Copyright (C) 2003, IBM Corp
+ *
+ *             This program is free software; you can redistribute it and/or
+ *             modify it under the terms of the GNU General Public License
+ *             as published by the Free Software Foundation; either version
+ *             2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/smp_lock.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/delay.h>
+#include <linux/smp.h>
+#include <linux/sysctl.h>
+#include <linux/relayfs_fs.h>
+#include <linux/klog.h>
+
+/* klog channel id */
+static int klog_channel = -1;
+
+/* maximum size of klog formatting buffer beyond which truncation will occur */
+#define KLOG_BUF_SIZE (512)
+/* per-cpu klog formatting buffer */
+static char buf[NR_CPUS][KLOG_BUF_SIZE];
+
+/*
+ *     klog_enabled determines whether klog()/klog_raw() actually do write
+ *     to the klog channel at any given time. If klog_enabled == 1 they do,
+ *     otherwise they don't.  Settable using sysctl fs.relayfs.klog_enabled.
+ */
+#ifdef CONFIG_KLOG_CHANNEL_AUTOENABLE
+static int klog_enabled = 1;
+#else
+static int klog_enabled = 0;
+#endif
+
+/**
+ *     klog - write a formatted string into the klog channel
+ *     @fmt: format string
+ *
+ *     Returns number of bytes written, negative number on failure.
+ */
+int klog(const char *fmt, ...)
+{
+       va_list args;
+       int len, err;
+       char *cbuf;
+       unsigned long flags;
+
+       if (!klog_enabled || klog_channel < 0) 
+               return 0;
+
+       local_irq_save(flags);
+       cbuf = buf[smp_processor_id()];
+
+       va_start(args, fmt);
+       len = vsnprintf(cbuf, KLOG_BUF_SIZE, fmt, args);
+       va_end(args);
+       
+       err = relay_write(klog_channel, cbuf, len, -1, NULL);
+       local_irq_restore(flags);
+
+       return err;
+}
+
+/**
+ *     klog_raw - directly write into the klog channel
+ *     @buf: buffer containing data to write
+ *     @len: # bytes to write
+ *
+ *     Returns number of bytes written, negative number on failure.
+ */
+int klog_raw(const char *buf,int len)
+{
+       int err = 0;
+       
+       if (klog_enabled && klog_channel >= 0)
+               err = relay_write(klog_channel, buf, len, -1, NULL);
+
+       return err;
+}
+
+/**
+ *     relayfs sysctl data
+ *
+ *     Only sys/fs/relayfs/klog_enabled for now.
+ */
+#define CTL_ENABLE_KLOG                100
+#define CTL_RELAYFS            100
+
+static struct ctl_table_header *relayfs_ctl_table_header;
+
+static struct ctl_table relayfs_table[] =
+{
+       {
+               .ctl_name       = CTL_ENABLE_KLOG,
+               .procname       = "klog_enabled",
+               .data           = &klog_enabled,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
+       {
+               0
+       }
+};
+
+static struct ctl_table relayfs_dir_table[] =
+{
+       {
+               .ctl_name       = CTL_RELAYFS,
+               .procname       = "relayfs",
+               .data           = NULL,
+               .maxlen         = 0,
+               .mode           = 0555,
+               .child          = relayfs_table,
+       },
+       {
+               0
+       }
+};
+
+static struct ctl_table relayfs_root_table[] =
+{
+       {
+               .ctl_name       = CTL_FS,
+               .procname       = "fs",
+               .data           = NULL,
+               .maxlen         = 0,
+               .mode           = 0555,
+               .child          = relayfs_dir_table,
+       },
+       {
+               0
+       }
+};
+
+/**
+ *     create_klog_channel - creates channel /mnt/relay/klog
+ *
+ *     Returns channel id on success, negative otherwise.
+ */
+int 
+create_klog_channel(void)
+{
+       u32 bufsize, nbufs;
+       u32 channel_flags;
+
+       channel_flags = RELAY_DELIVERY_PACKET | RELAY_USAGE_GLOBAL;
+       channel_flags |= RELAY_SCHEME_ANY | RELAY_TIMESTAMP_ANY;
+
+       bufsize = 1 << (CONFIG_KLOG_CHANNEL_SHIFT - 2);
+       nbufs = 4;
+
+       klog_channel = relay_open("klog",
+                                 bufsize,
+                                 nbufs,
+                                 channel_flags,
+                                 NULL,
+                                 0,
+                                 0,
+                                 0,
+                                 0,
+                                 0,
+                                 0,
+                                 NULL,
+                                 0);
+
+       if (klog_channel < 0)
+               printk("klog channel creation failed, errcode: %d\n", klog_channel);
+       else {
+               printk("klog channel created (%u bytes)\n", 1 << CONFIG_KLOG_CHANNEL_SHIFT);
+               relayfs_ctl_table_header = register_sysctl_table(relayfs_root_table, 1);
+       }
+
+       return klog_channel;
+}
+
+/**
+ *     remove_klog_channel - destroys channel /mnt/relay/klog
+ *
+ *     Returns 0, negative otherwise.
+ */
+int
+remove_klog_channel(void)
+{
+       if (relayfs_ctl_table_header)
+               unregister_sysctl_table(relayfs_ctl_table_header);
+       
+       return relay_close(klog_channel);
+}
+
+EXPORT_SYMBOL(klog);
+EXPORT_SYMBOL(klog_raw);
+
diff --git a/fs/relayfs/relay.c b/fs/relayfs/relay.c
new file mode 100644 (file)
index 0000000..11f4636
--- /dev/null
@@ -0,0 +1,1911 @@
+/*
+ * Public API and common code for RelayFS.
+ *
+ * Please see Documentation/filesystems/relayfs.txt for API description.
+ * 
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
+ *
+ * This file is released under the GPL.
+ */
+
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/stddef.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/time.h>
+#include <linux/page-flags.h>
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+#include <linux/mman.h>
+#include <linux/delay.h>
+
+#include <asm/io.h>
+#include <asm/current.h>
+#include <asm/uaccess.h>
+#include <asm/bitops.h>
+#include <asm/pgtable.h>
+#include <asm/relay.h>
+#include <asm/hardirq.h>
+
+#include "relay_lockless.h"
+#include "relay_locking.h"
+#include "resize.h"
+
+/* Relay channel table, indexed by channel id */
+static struct rchan *  rchan_table[RELAY_MAX_CHANNELS];
+static rwlock_t                rchan_table_lock = RW_LOCK_UNLOCKED;
+
+/* Relay operation structs, one per scheme */
+static struct relay_ops lockless_ops = {
+       .reserve = lockless_reserve,
+       .commit = lockless_commit,
+       .get_offset = lockless_get_offset,
+       .finalize = lockless_finalize,
+       .reset = lockless_reset,
+       .reset_index = lockless_reset_index
+};
+
+static struct relay_ops locking_ops = {
+       .reserve = locking_reserve,
+       .commit = locking_commit,
+       .get_offset = locking_get_offset,
+       .finalize = locking_finalize,
+       .reset = locking_reset,
+       .reset_index = locking_reset_index
+};
+
+/*
+ * Low-level relayfs kernel API.  These functions should not normally be 
+ * used by clients.  See high-level kernel API below.
+ */
+
+/**
+ *     rchan_get - get channel associated with id, incrementing refcount 
+ *     @rchan_id: the channel id
+ *
+ *     Returns channel if successful, NULL otherwise.
+ */
+struct rchan *
+rchan_get(int rchan_id)
+{
+       struct rchan *rchan;
+       
+       if ((rchan_id < 0) || (rchan_id >= RELAY_MAX_CHANNELS))
+               return NULL;
+       
+       read_lock(&rchan_table_lock);
+       rchan = rchan_table[rchan_id];
+       if (rchan)
+               atomic_inc(&rchan->refcount);
+       read_unlock(&rchan_table_lock);
+
+       return rchan;
+}
+
+/**
+ *     clear_readers - clear non-VFS readers
+ *     @rchan: the channel
+ *
+ *     Clear the channel pointers of all non-VFS readers open on the channel.
+ */
+static inline void
+clear_readers(struct rchan *rchan)
+{
+       struct list_head *p;
+       struct rchan_reader *reader;
+       
+       read_lock(&rchan->open_readers_lock);
+       list_for_each(p, &rchan->open_readers) {
+               reader = list_entry(p, struct rchan_reader, list);
+               if (!reader->vfs_reader)
+                       reader->rchan = NULL;
+       }
+       read_unlock(&rchan->open_readers_lock);
+}
+
+/**
+ *     rchan_alloc_id - reserve a channel id and store associated channel
+ *     @rchan: the channel
+ *
+ *     Returns channel id if successful, -1 otherwise.
+ */
+static inline int
+rchan_alloc_id(struct rchan *rchan)
+{
+       int i;
+       int rchan_id = -1;
+       
+       if (rchan == NULL)
+               return -1;
+
+       write_lock(&rchan_table_lock);
+       for (i = 0; i < RELAY_MAX_CHANNELS; i++) {
+               if (rchan_table[i] == NULL) {
+                       rchan_table[i] = rchan;
+                       rchan_id = rchan->id = i;
+                       break;
+               }
+       }
+       if (rchan_id != -1)
+               atomic_inc(&rchan->refcount);
+       write_unlock(&rchan_table_lock);
+       
+       return rchan_id;
+}
+
+/**
+ *     rchan_free_id - revoke a channel id and remove associated channel
+ *     @rchan_id: the channel id
+ */
+static inline void
+rchan_free_id(int rchan_id)
+{
+       struct rchan *rchan;
+
+       if ((rchan_id < 0) || (rchan_id >= RELAY_MAX_CHANNELS))
+               return;
+
+       write_lock(&rchan_table_lock);
+       rchan = rchan_table[rchan_id];
+       rchan_table[rchan_id] = NULL;
+       write_unlock(&rchan_table_lock);
+}
+
+/**
+ *     rchan_destroy_buf - destroy the current channel buffer
+ *     @rchan: the channel
+ */
+static inline void
+rchan_destroy_buf(struct rchan *rchan)
+{
+       if (rchan->buf && !rchan->init_buf)
+               free_rchan_buf(rchan->buf,
+                              rchan->buf_page_array,
+                              rchan->buf_page_count);
+}
+
+/**
+ *     relay_release - perform end-of-buffer processing for last buffer
+ *     @rchan: the channel
+ *
+ *     Returns 0 if successful, negative otherwise.
+ *
+ *     Releases the channel buffer, destroys the channel, and removes the
+ *     relay file from the relayfs filesystem.  Should only be called from 
+ *     rchan_put().  If we're here, it means by definition refcount is 0.
+ */
+static int 
+relay_release(struct rchan *rchan)
+{
+       if (rchan == NULL)
+               return -EBADF;
+
+       rchan_destroy_buf(rchan);
+       rchan_free_id(rchan->id);
+       relayfs_remove_file(rchan->dentry);
+       clear_readers(rchan);
+       kfree(rchan);
+
+       return 0;
+}
+
+/**
+ *     rchan_get - decrement channel refcount, releasing it if 0
+ *     @rchan: the channel
+ *
+ *     If the refcount reaches 0, the channel will be destroyed.
+ */
+void 
+rchan_put(struct rchan *rchan)
+{
+       if (atomic_dec_and_test(&rchan->refcount))
+               relay_release(rchan);
+}
+
+/**
+ *     relay_reserve -  reserve a slot in the channel buffer
+ *     @rchan: the channel
+ *     @len: the length of the slot to reserve
+ *     @td: the time delta between buffer start and current write, or TSC
+ *     @err: receives the result flags
+ *     @interrupting: 1 if interrupting previous, used only in locking scheme
+ *
+ *     Returns pointer to the beginning of the reserved slot, NULL if error.
+ *
+ *     The errcode value contains the result flags and is an ORed combination 
+ *     of the following:
+ *
+ *     RELAY_BUFFER_SWITCH_NONE - no buffer switch occurred
+ *     RELAY_EVENT_DISCARD_NONE - event should not be discarded
+ *     RELAY_BUFFER_SWITCH - buffer switch occurred
+ *     RELAY_EVENT_DISCARD - event should be discarded (all buffers are full)
+ *     RELAY_EVENT_TOO_LONG - event won't fit into even an empty buffer
+ *
+ *     buffer_start and buffer_end callbacks are triggered at this point
+ *     if applicable.
+ */
+char *
+relay_reserve(struct rchan *rchan,
+             u32 len,
+             struct timeval *ts,
+             u32 *td,
+             int *err,
+             int *interrupting)
+{
+       if (rchan == NULL)
+               return NULL;
+       
+       *interrupting = 0;
+
+       return rchan->relay_ops->reserve(rchan, len, ts, td, err, interrupting);
+}
+
+
+/**
+ *     wakeup_readers - wake up VFS readers waiting on a channel
+ *     @private: the channel
+ *
+ *     This is the work function used to defer reader waking.  The
+ *     reason waking is deferred is that calling directly from commit
+ *     causes problems if you're writing from say the scheduler.
+ */
+static void 
+wakeup_readers(void *private)
+{
+       struct rchan *rchan = (struct rchan *)private;
+
+       wake_up_interruptible(&rchan->read_wait);
+}
+
+
+/**
+ *     relay_commit - commit a reserved slot in the buffer
+ *     @rchan: the channel
+ *     @from: commit the length starting here
+ *     @len: length committed
+ *     @interrupting: 1 if interrupting previous, used only in locking scheme
+ *
+ *      After the write into the reserved buffer has been complted, this
+ *      function must be called in order for the relay to determine whether 
+ *      buffers are complete and to wake up VFS readers.
+ *
+ *     delivery callback is triggered at this point if applicable.
+ */
+void
+relay_commit(struct rchan *rchan,
+            char *from,
+            u32 len,
+            int reserve_code,
+            int interrupting)
+{
+       int deliver;
+
+       if (rchan == NULL)
+               return;
+       
+       deliver = packet_delivery(rchan) || 
+                  (reserve_code & RELAY_BUFFER_SWITCH);
+
+       rchan->relay_ops->commit(rchan, from, len, deliver, interrupting);
+
+       /* The params are always the same, so no worry about re-queuing */
+       if (deliver &&  waitqueue_active(&rchan->read_wait)) {
+               PREPARE_WORK(&rchan->wake_readers, wakeup_readers, rchan);
+               schedule_delayed_work(&rchan->wake_readers, 1);
+       }
+}
+
+/**
+ *     relay_get_offset - get current and max channel buffer offsets
+ *     @rchan: the channel
+ *     @max_offset: maximum channel offset
+ *
+ *     Returns the current and maximum channel buffer offsets.
+ */
+u32
+relay_get_offset(struct rchan *rchan, u32 *max_offset)
+{
+       return rchan->relay_ops->get_offset(rchan, max_offset);
+}
+
+/**
+ *     reset_index - try once to reset the current channel index
+ *     @rchan: the channel
+ *     @old_index: the index read before reset
+ *
+ *     Attempts to reset the channel index to 0.  It tries once, and
+ *     if it fails, returns negative, 0 otherwise.
+ */
+int
+reset_index(struct rchan *rchan, u32 old_index)
+{
+       return rchan->relay_ops->reset_index(rchan, old_index);
+}
+
+/*
+ * close() vm_op implementation for relayfs file mapping.
+ */
+static void
+relay_file_mmap_close(struct vm_area_struct *vma)
+{
+       struct file *filp = vma->vm_file;
+       struct rchan_reader *reader;
+       struct rchan *rchan;
+
+       reader = (struct rchan_reader *)filp->private_data;
+       rchan = reader->rchan;
+
+       atomic_dec(&rchan->mapped);
+
+       rchan->callbacks->fileop_notify(reader->rchan->id, filp,
+                                       RELAY_FILE_UNMAP);
+}
+
+/*
+ * vm_ops for relay file mappings.
+ */
+static struct vm_operations_struct relay_file_mmap_ops = {
+       .close = relay_file_mmap_close
+};
+
+/* \begin{Code inspired from BTTV driver} */
+static inline unsigned long 
+kvirt_to_pa(unsigned long adr)
+{
+       unsigned long kva, ret;
+
+       kva = (unsigned long) page_address(vmalloc_to_page((void *) adr));
+       kva |= adr & (PAGE_SIZE - 1);
+       ret = __pa(kva);
+       return ret;
+}
+
+static int
+relay_mmap_region(struct vm_area_struct *vma,
+                 const char *adr,
+                 const char *start_pos,
+                 unsigned long size)
+{
+       unsigned long start = (unsigned long) adr;
+       unsigned long page, pos;
+
+       pos = (unsigned long) start_pos;
+
+       while (size > 0) {
+               page = kvirt_to_pa(pos);
+               if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
+                       return -EAGAIN;
+               start += PAGE_SIZE;
+               pos += PAGE_SIZE;
+               size -= PAGE_SIZE;
+       }
+
+       return 0;
+}
+/* \end{Code inspired from BTTV driver} */
+
+/**
+ *     relay_mmap_buffer: - mmap buffer to process address space
+ *     @rchan_id: relay channel id
+ *     @vma: vm_area_struct describing memory to be mapped
+ *
+ *     Returns:
+ *     0 if ok
+ *     -EAGAIN, when remap failed
+ *     -EINVAL, invalid requested length
+ *
+ *     Caller should already have grabbed mmap_sem.
+ */
+int 
+__relay_mmap_buffer(struct rchan *rchan,
+                   struct vm_area_struct *vma)
+{
+       int err = 0;
+       unsigned long length = vma->vm_end - vma->vm_start;
+       struct file *filp = vma->vm_file;
+
+       if (rchan == NULL) {
+               err = -EBADF;
+               goto exit;
+       }
+
+       if (rchan->init_buf) {
+               err = -EPERM;
+               goto exit;
+       }
+       
+       if (length != (unsigned long)rchan->alloc_size) {
+               err = -EINVAL;
+               goto exit;
+       }
+
+       err = relay_mmap_region(vma,
+                               (char *)vma->vm_start,
+                               rchan->buf,
+                               rchan->alloc_size);
+
+       if (err == 0) {
+               vma->vm_ops = &relay_file_mmap_ops;
+               err = rchan->callbacks->fileop_notify(rchan->id, filp,
+                                                     RELAY_FILE_MAP);
+               if (err == 0)
+                       atomic_inc(&rchan->mapped);
+       }
+exit:  
+       return err;
+}
+
+/*
+ * High-level relayfs kernel API.  See Documentation/filesystems/relafys.txt.
+ */
+
+/*
+ * rchan_callback implementations defining default channel behavior.  Used
+ * in place of corresponding NULL values in client callback struct.
+ */
+
+/*
+ * buffer_end() default callback.  Does nothing.
+ */
+static int 
+buffer_end_default_callback(int rchan_id,
+                           char *current_write_pos,
+                           char *end_of_buffer,
+                           struct timeval end_time,
+                           u32 end_tsc,
+                           int using_tsc) 
+{
+       return 0;
+}
+
+/*
+ * buffer_start() default callback.  Does nothing.
+ */
+static int 
+buffer_start_default_callback(int rchan_id,
+                             char *current_write_pos,
+                             u32 buffer_id,
+                             struct timeval start_time,
+                             u32 start_tsc,
+                             int using_tsc)
+{
+       return 0;
+}
+
+/*
+ * deliver() default callback.  Does nothing.
+ */
+static void 
+deliver_default_callback(int rchan_id, char *from, u32 len)
+{
+}
+
+/*
+ * user_deliver() default callback.  Does nothing.
+ */
+static void 
+user_deliver_default_callback(int rchan_id, char *from, u32 len)
+{
+}
+
+/*
+ * needs_resize() default callback.  Does nothing.
+ */
+static void
+needs_resize_default_callback(int rchan_id,
+                             int resize_type,
+                             u32 suggested_buf_size,
+                             u32 suggested_n_bufs)
+{
+}
+
+/*
+ * fileop_notify() default callback.  Does nothing.
+ */
+static int
+fileop_notify_default_callback(int rchan_id,
+                              struct file *filp,
+                              enum relay_fileop fileop)
+{
+       return 0;
+}
+
+/*
+ * ioctl() default callback.  Does nothing.
+ */
+static int
+ioctl_default_callback(int rchan_id,
+                      unsigned int cmd,
+                      unsigned long arg)
+{
+       return 0;
+}
+
+/* relay channel default callbacks */
+static struct rchan_callbacks default_channel_callbacks = {
+       .buffer_start = buffer_start_default_callback,
+       .buffer_end = buffer_end_default_callback,
+       .deliver = deliver_default_callback,
+       .user_deliver = user_deliver_default_callback,
+       .needs_resize = needs_resize_default_callback,
+       .fileop_notify = fileop_notify_default_callback,
+       .ioctl = ioctl_default_callback,
+};
+
+/**
+ *     check_attribute_flags - check sanity of channel attributes
+ *     @flags: channel attributes
+ *     @resizeable: 1 if true
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+static int
+check_attribute_flags(u32 *attribute_flags, int resizeable)
+{
+       u32 flags = *attribute_flags;
+       
+       if (!(flags & RELAY_DELIVERY_BULK) && !(flags & RELAY_DELIVERY_PACKET))
+               return -EINVAL; /* Delivery mode must be specified */
+       
+       if (!(flags & RELAY_USAGE_SMP) && !(flags & RELAY_USAGE_GLOBAL))
+               return -EINVAL; /* Usage must be specified */
+       
+       if (resizeable) {  /* Resizeable can never be continuous */
+               *attribute_flags &= ~RELAY_MODE_CONTINUOUS;
+               *attribute_flags |= RELAY_MODE_NO_OVERWRITE;
+       }
+       
+       if ((flags & RELAY_MODE_CONTINUOUS) &&
+           (flags & RELAY_MODE_NO_OVERWRITE))
+               return -EINVAL; /* Can't have it both ways */
+       
+       if (!(flags & RELAY_MODE_CONTINUOUS) &&
+           !(flags & RELAY_MODE_NO_OVERWRITE))
+               *attribute_flags |= RELAY_MODE_CONTINUOUS; /* Default to continuous */
+       
+       if (!(flags & RELAY_SCHEME_ANY))
+               return -EINVAL; /* One or both must be specified */
+       else if (flags & RELAY_SCHEME_LOCKLESS) {
+               if (have_cmpxchg())
+                       *attribute_flags &= ~RELAY_SCHEME_LOCKING;
+               else if (flags & RELAY_SCHEME_LOCKING)
+                       *attribute_flags &= ~RELAY_SCHEME_LOCKLESS;
+               else
+                       return -EINVAL; /* Locking scheme not an alternative */
+       }
+       
+       if (!(flags & RELAY_TIMESTAMP_ANY))
+               return -EINVAL; /* One or both must be specified */
+       else if (flags & RELAY_TIMESTAMP_TSC) {
+               if (have_tsc())
+                       *attribute_flags &= ~RELAY_TIMESTAMP_GETTIMEOFDAY;
+               else if (flags & RELAY_TIMESTAMP_GETTIMEOFDAY)
+                       *attribute_flags &= ~RELAY_TIMESTAMP_TSC;
+               else
+                       return -EINVAL; /* gettimeofday not an alternative */
+       }
+
+       return 0;
+}
+
+/*
+ * High-level API functions.
+ */
+
+/**
+ *     __relay_reset - internal reset function
+ *     @rchan: the channel
+ *     @init: 1 if this is a first-time channel initialization
+ *
+ *     See relay_reset for description of effect.
+ */
+void
+__relay_reset(struct rchan *rchan, int init)
+{
+       int i;
+       
+       if (init) {
+               rchan->version = RELAYFS_CHANNEL_VERSION;
+               init_MUTEX(&rchan->resize_sem);
+               init_waitqueue_head(&rchan->read_wait);
+               init_waitqueue_head(&rchan->write_wait);
+               atomic_set(&rchan->refcount, 0);
+               INIT_LIST_HEAD(&rchan->open_readers);
+               rchan->open_readers_lock = RW_LOCK_UNLOCKED;
+       }
+       
+       rchan->buf_id = rchan->buf_idx = 0;
+       atomic_set(&rchan->suspended, 0);
+       atomic_set(&rchan->mapped, 0);
+       rchan->half_switch = 0;
+       rchan->bufs_produced = 0;
+       rchan->bufs_consumed = 0;
+       rchan->bytes_consumed = 0;
+       rchan->initialized = 0;
+       rchan->finalized = 0;
+       rchan->resize_min = rchan->resize_max = 0;
+       rchan->resizing = 0;
+       rchan->replace_buffer = 0;
+       rchan->resize_buf = NULL;
+       rchan->resize_buf_size = 0;
+       rchan->resize_alloc_size = 0;
+       rchan->resize_n_bufs = 0;
+       rchan->resize_err = 0;
+       rchan->resize_failures = 0;
+       rchan->resize_order = 0;
+
+       rchan->expand_page_array = NULL;
+       rchan->expand_page_count = 0;
+       rchan->shrink_page_array = NULL;
+       rchan->shrink_page_count = 0;
+       rchan->resize_page_array = NULL;
+       rchan->resize_page_count = 0;
+       rchan->old_buf_page_array = NULL;
+       rchan->expand_buf_id = 0;
+
+       INIT_WORK(&rchan->wake_readers, NULL, NULL);
+       INIT_WORK(&rchan->wake_writers, NULL, NULL);
+
+       for (i = 0; i < RELAY_MAX_BUFS; i++)
+               rchan->unused_bytes[i] = 0;
+       
+       rchan->relay_ops->reset(rchan, init);
+}
+
+/**
+ *     relay_reset - reset the channel
+ *     @rchan: the channel
+ *
+ *     Returns 0 if successful, negative if not.
+ *
+ *     This has the effect of erasing all data from the buffer and
+ *     restarting the channel in its initial state.  The buffer itself
+ *     is not freed, so any mappings are still in effect.
+ *
+ *     NOTE: Care should be taken that the channnel isn't actually
+ *     being used by anything when this call is made.
+ */
+int
+relay_reset(int rchan_id)
+{
+       struct rchan *rchan;
+
+       rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return -EBADF;
+
+       __relay_reset(rchan, 0);
+       update_readers_consumed(rchan, 0, 0);
+
+       rchan_put(rchan);
+
+       return 0;
+}
+
+/**
+ *     check_init_buf - check the sanity of init_buf, if present
+ *     @init_buf: the initbuf
+ *     @init_buf_size: the total initbuf size
+ *     @bufsize: the channel's sub-buffer size
+ *     @nbufs: the number of sub-buffers in the channel
+ *
+ *     Returns 0 if ok, negative otherwise.
+ */
+static int
+check_init_buf(char *init_buf, u32 init_buf_size, u32 bufsize, u32 nbufs)
+{
+       int err = 0;
+       
+       if (init_buf && nbufs == 1) /* 1 sub-buffer makes no sense */
+               err = -EINVAL;
+
+       if (init_buf && (bufsize * nbufs != init_buf_size))
+               err = -EINVAL;
+
+       return err;
+}
+
+/**
+ *     rchan_create_buf - allocate the initial channel buffer
+ *     @rchan: the channel
+ *     @size_alloc: the total size of the channel buffer
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+static inline int
+rchan_create_buf(struct rchan *rchan, int size_alloc)
+{
+       struct page **page_array;
+       int page_count;
+
+       if ((rchan->buf = (char *)alloc_rchan_buf(size_alloc, &page_array, &page_count)) == NULL) {
+               rchan->buf_page_array = NULL;
+               rchan->buf_page_count = 0;
+               return -ENOMEM;
+       }
+
+       rchan->buf_page_array = page_array;
+       rchan->buf_page_count = page_count;
+
+       return 0;
+}
+
+/**
+ *     rchan_create - allocate and initialize a channel, including buffer
+ *     @chanpath: path specifying the relayfs channel file to create
+ *     @bufsize: the size of the sub-buffers within the channel buffer
+ *     @nbufs: the number of sub-buffers within the channel buffer
+ *     @rchan_flags: flags specifying buffer attributes
+ *     @err: err code
+ *
+ *     Returns channel if successful, NULL otherwise, err receives errcode.
+ *
+ *     Allocates a struct rchan representing a relay channel, according
+ *     to the attributes passed in via rchan_flags.  Does some basic sanity
+ *     checking but doesn't try to do anything smart.  In particular, the
+ *     number of buffers must be a power of 2, and if the lockless scheme
+ *     is being used, the sub-buffer size must also be a power of 2.  The
+ *     locking scheme can use buffers of any size.
+ */
+static struct rchan *
+rchan_create(const char *chanpath, 
+            int bufsize, 
+            int nbufs, 
+            u32 rchan_flags,
+            char *init_buf,
+            u32 init_buf_size,
+            int *err)
+{
+       int size_alloc;
+       struct rchan *rchan = NULL;
+
+       *err = 0;
+
+       rchan = (struct rchan *)kmalloc(sizeof(struct rchan), GFP_KERNEL);
+       if (rchan == NULL) {
+               *err = -ENOMEM;
+               return NULL;
+       }
+       rchan->buf = rchan->init_buf = NULL;
+
+       *err = check_init_buf(init_buf, init_buf_size, bufsize, nbufs);
+       if (*err)
+               goto exit;
+       
+       if (nbufs == 1 && bufsize) {
+               rchan->n_bufs = nbufs;
+               rchan->buf_size = bufsize;
+               size_alloc = bufsize;
+               goto alloc;
+       }
+       
+       if (bufsize <= 0 ||
+           (rchan_flags & RELAY_SCHEME_LOCKLESS && hweight32(bufsize) != 1) ||
+           hweight32(nbufs) != 1 ||
+           nbufs < RELAY_MIN_BUFS ||
+           nbufs > RELAY_MAX_BUFS) {
+               *err = -EINVAL;
+               goto exit;
+       }
+
+       size_alloc = FIX_SIZE(bufsize * nbufs);
+       if (size_alloc > RELAY_MAX_BUF_SIZE) {
+               *err = -EINVAL;
+               goto exit;
+       }
+       rchan->n_bufs = nbufs;
+       rchan->buf_size = bufsize;
+
+       if (rchan_flags & RELAY_SCHEME_LOCKLESS) {
+               offset_bits(rchan) = ffs(bufsize) - 1;
+               offset_mask(rchan) =  RELAY_BUF_OFFSET_MASK(offset_bits(rchan));
+               bufno_bits(rchan) = ffs(nbufs) - 1;
+       }
+alloc:
+       if (rchan_alloc_id(rchan) == -1) {
+               *err = -ENOMEM;
+               goto exit;
+       }
+
+       if (init_buf == NULL) {
+               *err = rchan_create_buf(rchan, size_alloc);
+               if (*err) {
+                       rchan_free_id(rchan->id);
+                       goto exit;
+               }
+       } else
+               rchan->buf = rchan->init_buf = init_buf;
+       
+       rchan->alloc_size = size_alloc;
+
+       if (rchan_flags & RELAY_SCHEME_LOCKLESS)
+               rchan->relay_ops = &lockless_ops;
+       else
+               rchan->relay_ops = &locking_ops;
+
+exit:
+       if (*err) {
+               kfree(rchan);
+               rchan = NULL;
+       }
+
+       return rchan;
+}
+
+
+static char tmpname[NAME_MAX];
+
+/**
+ *     rchan_create_dir - create directory for file
+ *     @chanpath: path to file, including filename
+ *     @residual: filename remaining after parse
+ *     @topdir: the directory filename should be created in
+ *
+ *     Returns 0 if successful, negative otherwise.
+ *
+ *     Inspired by xlate_proc_name() in procfs.  Given a file path which
+ *     includes the filename, creates any and all directories necessary 
+ *     to create the file.
+ */
+static int 
+rchan_create_dir(const char * chanpath, 
+                const char **residual, 
+                struct dentry **topdir)
+{
+       const char *cp = chanpath, *next;
+       struct dentry *parent = NULL;
+       int len, err = 0;
+       
+       while (1) {
+               next = strchr(cp, '/');
+               if (!next)
+                       break;
+
+               len = next - cp;
+
+               strncpy(tmpname, cp, len);
+               tmpname[len] = '\0';
+               err = relayfs_create_dir(tmpname, parent, &parent);
+               if (err && (err != -EEXIST))
+                       return err;
+               cp += len + 1;
+       }
+
+       *residual = cp;
+       *topdir = parent;
+
+       return err;
+}
+
+/**
+ *     rchan_create_file - create file, including parent directories
+ *     @chanpath: path to file, including filename
+ *     @dentry: result dentry
+ *     @data: data to associate with the file
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+static int 
+rchan_create_file(const char * chanpath, 
+                 struct dentry **dentry, 
+                 struct rchan * data,
+                 int mode)
+{
+       int err;
+       const char * fname;
+       struct dentry *topdir;
+
+       err = rchan_create_dir(chanpath, &fname, &topdir);
+       if (err && (err != -EEXIST))
+               return err;
+
+       err = relayfs_create_file(fname, topdir, dentry, (void *)data, mode);
+
+       return err;
+}
+
+/**
+ *     relay_open - create a new file/channel buffer in relayfs
+ *     @chanpath: name of file to create, including path
+ *     @bufsize: size of sub-buffers
+ *     @nbufs: number of sub-buffers
+ *     @flags: channel attributes
+ *     @callbacks: client callback functions
+ *     @start_reserve: number of bytes to reserve at start of each sub-buffer
+ *     @end_reserve: number of bytes to reserve at end of each sub-buffer
+ *     @rchan_start_reserve: additional reserve at start of first sub-buffer
+ *     @resize_min: minimum total buffer size, if set
+ *     @resize_max: maximum total buffer size, if set
+ *     @mode: the perms to be given to the relayfs file, 0 to accept defaults
+ *     @init_buf: initial memory buffer to start out with, NULL if N/A
+ *     @init_buf_size: initial memory buffer size to start out with, 0 if N/A
+ *
+ *     Returns channel id if successful, negative otherwise.
+ *
+ *     Creates a relay channel using the sizes and attributes specified.
+ *     The default permissions, used if mode == 0 are S_IRUSR | S_IWUSR.  See
+ *     Documentation/filesystems/relayfs.txt for details.
+ */
+int
+relay_open(const char *chanpath,
+          int bufsize,
+          int nbufs,
+          u32 flags,
+          struct rchan_callbacks *channel_callbacks,
+          u32 start_reserve,
+          u32 end_reserve,
+          u32 rchan_start_reserve,
+          u32 resize_min,
+          u32 resize_max,
+          int mode,
+          char *init_buf,
+          u32 init_buf_size)
+{
+       int err;
+       struct rchan *rchan;
+       struct dentry *dentry;
+       struct rchan_callbacks *callbacks = NULL;
+
+       if (chanpath == NULL)
+               return -EINVAL;
+
+       if (nbufs != 1) {
+               err = check_attribute_flags(&flags, resize_min ? 1 : 0);
+               if (err)
+                       return err;
+       }
+
+       rchan = rchan_create(chanpath, bufsize, nbufs, flags, init_buf, init_buf_size, &err);
+
+       if (err < 0)
+               return err;
+
+       /* Create file in fs */
+       if ((err = rchan_create_file(chanpath, &dentry, rchan, mode)) < 0) {
+               rchan_destroy_buf(rchan);
+               rchan_free_id(rchan->id);
+               kfree(rchan);
+               return err;
+       }
+
+       rchan->dentry = dentry;
+
+       if (channel_callbacks == NULL)
+               callbacks = &default_channel_callbacks;
+       else
+               callbacks = channel_callbacks;
+
+       if (callbacks->buffer_end == NULL)
+               callbacks->buffer_end = buffer_end_default_callback;
+       if (callbacks->buffer_start == NULL)
+               callbacks->buffer_start = buffer_start_default_callback;
+       if (callbacks->deliver == NULL)
+               callbacks->deliver = deliver_default_callback;
+       if (callbacks->user_deliver == NULL)
+               callbacks->user_deliver = user_deliver_default_callback;
+       if (callbacks->needs_resize == NULL)
+               callbacks->needs_resize = needs_resize_default_callback;
+       if (callbacks->fileop_notify == NULL)
+               callbacks->fileop_notify = fileop_notify_default_callback;
+       if (callbacks->ioctl == NULL)
+               callbacks->ioctl = ioctl_default_callback;
+       rchan->callbacks = callbacks;
+
+       /* Just to let the client know the sizes used */
+       rchan->callbacks->needs_resize(rchan->id,
+                                      RELAY_RESIZE_REPLACED,
+                                      rchan->buf_size,
+                                      rchan->n_bufs);
+
+       rchan->flags = flags;
+       rchan->start_reserve = start_reserve;
+       rchan->end_reserve = end_reserve;
+       rchan->rchan_start_reserve = rchan_start_reserve;
+
+       __relay_reset(rchan, 1);
+
+       if (resize_min > 0 && resize_max > 0 && 
+          resize_max < RELAY_MAX_TOTAL_BUF_SIZE) {
+               rchan->resize_min = resize_min;
+               rchan->resize_max = resize_max;
+               init_shrink_timer(rchan);
+       }
+
+       rchan_get(rchan->id);
+
+       return rchan->id;
+}
+
+/**
+ *     relay_discard_init_buf - alloc channel buffer and copy init_buf into it
+ *     @rchan_id: the channel id
+ *
+ *     Returns 0 if successful, negative otherwise.
+ *
+ *     NOTE: May sleep.  Should also be called only when the channel isn't
+ *     actively being written into.
+ */
+int
+relay_discard_init_buf(int rchan_id)
+{
+       struct rchan *rchan;
+       int err = 0;
+       
+       rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return -EBADF;
+
+       if (rchan->init_buf == NULL) {
+               err = -EINVAL;
+               goto out;
+       }
+       
+       err = rchan_create_buf(rchan, rchan->alloc_size);
+       if (err)
+               goto out;
+       
+       memcpy(rchan->buf, rchan->init_buf, rchan->n_bufs * rchan->buf_size);
+       rchan->init_buf = NULL;
+out:
+       rchan_put(rchan);
+       
+       return err;
+}
+
+/**
+ *     relay_finalize - perform end-of-buffer processing for last buffer
+ *     @rchan_id: the channel id
+ *     @releasing: true if called when releasing file
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+static int 
+relay_finalize(int rchan_id)
+{
+       struct rchan *rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return -EBADF;
+
+       if (rchan->finalized == 0) {
+               rchan->relay_ops->finalize(rchan);
+               rchan->finalized = 1;
+       }
+
+       if (waitqueue_active(&rchan->read_wait)) {
+               PREPARE_WORK(&rchan->wake_readers, wakeup_readers, rchan);
+               schedule_delayed_work(&rchan->wake_readers, 1);
+       }
+
+       rchan_put(rchan);
+
+       return 0;
+}
+
+/**
+ *     restore_callbacks - restore default channel callbacks
+ *     @rchan: the channel
+ *
+ *     Restore callbacks to the default versions.
+ */
+static inline void
+restore_callbacks(struct rchan *rchan)
+{
+       if (rchan->callbacks != &default_channel_callbacks)
+               rchan->callbacks = &default_channel_callbacks;
+}
+
+/**
+ *     relay_close - close the channel
+ *     @rchan_id: relay channel id
+ *     
+ *     Finalizes the last sub-buffer and marks the channel as finalized.
+ *     The channel buffer and channel data structure are then freed
+ *     automatically when the last reference to the channel is given up.
+ */
+int 
+relay_close(int rchan_id)
+{
+       int err;
+       struct rchan *rchan;
+
+       if ((rchan_id < 0) || (rchan_id >= RELAY_MAX_CHANNELS))
+               return -EBADF;
+
+       err = relay_finalize(rchan_id);
+
+       if (!err) {
+               read_lock(&rchan_table_lock);
+               rchan = rchan_table[rchan_id];
+               read_unlock(&rchan_table_lock);
+
+               if (rchan) {
+                       restore_callbacks(rchan);
+                       if (rchan->resize_min)
+                               del_timer(&rchan->shrink_timer);
+                       rchan_put(rchan);
+               }
+       }
+       
+       return err;
+}
+
+/**
+ *     relay_write - reserve a slot in the channel and write data into it
+ *     @rchan_id: relay channel id
+ *     @data_ptr: data to be written into reserved slot
+ *     @count: number of bytes to write
+ *     @td_offset: optional offset where time delta should be written
+ *     @wrote_pos: optional ptr returning buf pos written to, ignored if NULL 
+ *
+ *     Returns the number of bytes written, 0 or negative on failure.
+ *
+ *     Reserves space in the channel and writes count bytes of data_ptr
+ *     to it.  Automatically performs any necessary locking, depending
+ *     on the scheme and SMP usage in effect (no locking is done for the
+ *     lockless scheme regardless of usage). 
+ *
+ *     If td_offset is >= 0, the internal time delta calculated when
+ *     slot was reserved will be written at that offset.
+ *
+ *     If wrote_pos is non-NULL, it will receive the location the data
+ *     was written to, which may be needed for some applications but is not
+ *     normally interesting.
+ */
+int
+relay_write(int rchan_id, 
+           const void *data_ptr, 
+           size_t count,
+           int td_offset,
+           void **wrote_pos)
+{
+       unsigned long flags;
+       char *reserved, *write_pos;
+       int bytes_written = 0;
+       int reserve_code, interrupting;
+       struct timeval ts;
+       u32 td;
+       struct rchan *rchan;
+       
+       rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return -EBADF;
+
+       relay_lock_channel(rchan, flags); /* nop for lockless */
+
+       write_pos = reserved = relay_reserve(rchan, count, &ts, &td, 
+                                            &reserve_code, &interrupting);
+
+       if (reserved != NULL) {
+               relay_write_direct(write_pos, data_ptr, count);
+               if ((td_offset >= 0) && (td_offset < count - sizeof(td)))
+                       *((u32 *)(reserved + td_offset)) = td;
+               bytes_written = count;
+       } else if (reserve_code == RELAY_WRITE_TOO_LONG)
+               bytes_written = -EINVAL;
+
+       if (bytes_written > 0)
+               relay_commit(rchan, reserved, bytes_written, reserve_code, interrupting);
+
+       relay_unlock_channel(rchan, flags); /* nop for lockless */
+
+       rchan_put(rchan);
+
+       if (wrote_pos)
+               *wrote_pos = reserved;
+       
+       return bytes_written;
+}
+
+/**
+ *     wakeup_writers - wake up VFS writers waiting on a channel
+ *     @private: the channel
+ *
+ *     This is the work function used to defer writer waking.  The
+ *     reason waking is deferred is that calling directly from 
+ *     buffers_consumed causes problems if you're writing from say 
+ *     the scheduler.
+ */
+static void 
+wakeup_writers(void *private)
+{
+       struct rchan *rchan = (struct rchan *)private;
+       
+       wake_up_interruptible(&rchan->write_wait);
+}
+
+
+/**
+ *     __relay_buffers_consumed - internal version of relay_buffers_consumed
+ *     @rchan: the relay channel
+ *     @bufs_consumed: number of buffers to add to current count for channel
+ *     
+ *     Internal - updates the channel's consumed buffer count.
+ */
+static void
+__relay_buffers_consumed(struct rchan *rchan, u32 bufs_consumed)
+{
+       rchan->bufs_consumed += bufs_consumed;
+       
+       if (rchan->bufs_consumed > rchan->bufs_produced)
+               rchan->bufs_consumed = rchan->bufs_produced;
+       
+       atomic_set(&rchan->suspended, 0);
+
+       PREPARE_WORK(&rchan->wake_writers, wakeup_writers, rchan);
+       schedule_delayed_work(&rchan->wake_writers, 1);
+}
+
+/**
+ *     __reader_buffers_consumed - update reader/channel consumed buffer count
+ *     @reader: channel reader
+ *     @bufs_consumed: number of buffers to add to current count for channel
+ *     
+ *     Internal - updates the reader's consumed buffer count.  If the reader's
+ *     resulting total is greater than the channel's, update the channel's.
+*/
+static void
+__reader_buffers_consumed(struct rchan_reader *reader, u32 bufs_consumed)
+{
+       reader->bufs_consumed += bufs_consumed;
+       
+       if (reader->bufs_consumed > reader->rchan->bufs_consumed)
+               __relay_buffers_consumed(reader->rchan, bufs_consumed);
+}
+
+/**
+ *     relay_buffers_consumed - add to the # buffers consumed for the channel
+ *     @reader: channel reader
+ *     @bufs_consumed: number of buffers to add to current count for channel
+ *     
+ *     Adds to the channel's consumed buffer count.  buffers_consumed should
+ *     be the number of buffers newly consumed, not the total number consumed.
+ *
+ *     NOTE: kernel clients don't need to call this function if the reader
+ *     is auto-consuming or the channel is MODE_CONTINUOUS.
+ */
+void 
+relay_buffers_consumed(struct rchan_reader *reader, u32 bufs_consumed)
+{
+       if (reader && reader->rchan)
+               __reader_buffers_consumed(reader, bufs_consumed);
+}
+
+/**
+ *     __relay_bytes_consumed - internal version of relay_bytes_consumed 
+ *     @rchan: the relay channel
+ *     @bytes_consumed: number of bytes to add to current count for channel
+ *     @read_offset: where the bytes were consumed from
+ *     
+ *     Internal - updates the channel's consumed count.
+*/
+static void
+__relay_bytes_consumed(struct rchan *rchan, u32 bytes_consumed, u32 read_offset)
+{
+       u32 consuming_idx;
+       u32 unused;
+
+       consuming_idx = read_offset / rchan->buf_size;
+
+       if (consuming_idx >= rchan->n_bufs)
+               consuming_idx = rchan->n_bufs - 1;
+       rchan->bytes_consumed += bytes_consumed;
+
+       unused = rchan->unused_bytes[consuming_idx];
+       
+       if (rchan->bytes_consumed + unused >= rchan->buf_size) {
+               __relay_buffers_consumed(rchan, 1);
+               rchan->bytes_consumed = 0;
+       }
+}
+
+/**
+ *     __reader_bytes_consumed - update reader/channel consumed count
+ *     @reader: channel reader
+ *     @bytes_consumed: number of bytes to add to current count for channel
+ *     @read_offset: where the bytes were consumed from
+ *     
+ *     Internal - updates the reader's consumed count.  If the reader's
+ *     resulting total is greater than the channel's, update the channel's.
+*/
+static void
+__reader_bytes_consumed(struct rchan_reader *reader, u32 bytes_consumed, u32 read_offset)
+{
+       u32 consuming_idx;
+       u32 unused;
+
+       consuming_idx = read_offset / reader->rchan->buf_size;
+
+       if (consuming_idx >= reader->rchan->n_bufs)
+               consuming_idx = reader->rchan->n_bufs - 1;
+
+       reader->bytes_consumed += bytes_consumed;
+       
+       unused = reader->rchan->unused_bytes[consuming_idx];
+       
+       if (reader->bytes_consumed + unused >= reader->rchan->buf_size) {
+               reader->bufs_consumed++;
+               reader->bytes_consumed = 0;
+       }
+
+       if ((reader->bufs_consumed > reader->rchan->bufs_consumed) ||
+           ((reader->bufs_consumed == reader->rchan->bufs_consumed) &&
+            (reader->bytes_consumed > reader->rchan->bytes_consumed)))
+               __relay_bytes_consumed(reader->rchan, bytes_consumed, read_offset);
+}
+
+/**
+ *     relay_bytes_consumed - add to the # bytes consumed for the channel
+ *     @reader: channel reader
+ *     @bytes_consumed: number of bytes to add to current count for channel
+ *     @read_offset: where the bytes were consumed from
+ *     
+ *     Adds to the channel's consumed count.  bytes_consumed should be the
+ *     number of bytes actually read e.g. return value of relay_read() and
+ *     the read_offset should be the actual offset the bytes were read from
+ *     e.g. the actual_read_offset set by relay_read(). See
+ *     Documentation/filesystems/relayfs.txt for more details.
+ *
+ *     NOTE: kernel clients don't need to call this function if the reader
+ *     is auto-consuming or the channel is MODE_CONTINUOUS.
+ */
+void
+relay_bytes_consumed(struct rchan_reader *reader, u32 bytes_consumed, u32 read_offset)
+{
+       if (reader && reader->rchan)
+               __reader_bytes_consumed(reader, bytes_consumed, read_offset);
+}
+
+/**
+ *     update_readers_consumed - apply offset change to reader
+ *     @rchan: the channel
+ *
+ *     Apply the consumed counts to all readers open on the channel.
+ */
+void
+update_readers_consumed(struct rchan *rchan, u32 bufs_consumed, u32 bytes_consumed)
+{
+       struct list_head *p;
+       struct rchan_reader *reader;
+       
+       read_lock(&rchan->open_readers_lock);
+       list_for_each(p, &rchan->open_readers) {
+               reader = list_entry(p, struct rchan_reader, list);
+               reader->bufs_consumed = bufs_consumed;
+               reader->bytes_consumed = bytes_consumed;
+               if (reader->vfs_reader) 
+                       reader->pos.file->f_pos = 0;
+               else
+                       reader->pos.f_pos = 0;
+               reader->offset_changed = 1;
+       }
+       read_unlock(&rchan->open_readers_lock);
+}
+
+/**
+ *     do_read - utility function to do the actual read to user
+ *     @rchan: the channel
+ *     @buf: user buf to read into, NULL if just getting info
+ *     @count: bytes requested
+ *     @read_offset: offset into channel
+ *     @new_offset: new offset into channel after read
+ *     @actual_read_offset: read offset actually used
+ *
+ *     Returns the number of bytes read, 0 if none.
+ */
+static ssize_t
+do_read(struct rchan *rchan, char *buf, size_t count, u32 read_offset, u32 *new_offset, u32 *actual_read_offset)
+{
+       u32 read_bufno, cur_bufno;
+       u32 avail_offset, cur_idx, max_offset, buf_end_offset;
+       u32 avail_count, buf_size;
+       int unused_bytes = 0;
+       size_t read_count = 0;
+       u32 last_buf_byte_offset;
+
+       *actual_read_offset = read_offset;
+       
+       buf_size = rchan->buf_size;
+       if (unlikely(!buf_size)) BUG();
+
+       read_bufno = read_offset / buf_size;
+       if (unlikely(read_bufno >= RELAY_MAX_BUFS)) BUG();
+       unused_bytes = rchan->unused_bytes[read_bufno];
+
+       avail_offset = cur_idx = relay_get_offset(rchan, &max_offset);
+
+       if (cur_idx == read_offset) {
+               if (atomic_read(&rchan->suspended) == 1) {
+                       read_offset += 1;
+                       if (read_offset >= max_offset)
+                               read_offset = 0;
+                       *actual_read_offset = read_offset;
+               } else {
+                       *new_offset = read_offset;
+                       return 0;
+               }
+       } else {
+               last_buf_byte_offset = (read_bufno + 1) * buf_size - 1;
+               if (read_offset == last_buf_byte_offset) {
+                       if (unused_bytes != 1) {
+                               read_offset += 1;
+                               if (read_offset >= max_offset)
+                                       read_offset = 0;
+                               *actual_read_offset = read_offset;
+                       }
+               }
+       }
+
+       read_bufno = read_offset / buf_size;
+       if (unlikely(read_bufno >= RELAY_MAX_BUFS)) BUG();
+       unused_bytes = rchan->unused_bytes[read_bufno];
+
+       cur_bufno = cur_idx / buf_size;
+
+       buf_end_offset = (read_bufno + 1) * buf_size - unused_bytes;
+       if (avail_offset > buf_end_offset)
+               avail_offset = buf_end_offset;
+       else if (avail_offset < read_offset)
+               avail_offset = buf_end_offset;
+       avail_count = avail_offset - read_offset;
+       read_count = avail_count >= count ? count : avail_count;
+
+       if (read_count && buf != NULL)
+               if (copy_to_user(buf, rchan->buf + read_offset, read_count))
+                       return -EFAULT;
+
+       if (read_bufno == cur_bufno)
+               if (read_count && (read_offset + read_count >= buf_end_offset) && (read_offset + read_count <= cur_idx)) {
+                       *new_offset = cur_idx;
+                       return read_count;
+               }
+
+       if (read_offset + read_count + unused_bytes > max_offset)
+               *new_offset = 0;
+       else if (read_offset + read_count >= buf_end_offset)
+               *new_offset = read_offset + read_count + unused_bytes;
+       else
+               *new_offset = read_offset + read_count;
+
+       return read_count;
+}
+
+/**
+ *     __relay_read - read bytes from channel, relative to current reader pos
+ *     @reader: channel reader
+ *     @buf: user buf to read into, NULL if just getting info
+ *     @count: bytes requested
+ *     @read_offset: offset into channel
+ *     @new_offset: new offset into channel after read
+ *     @actual_read_offset: read offset actually used
+ *     @wait: if non-zero, wait for something to read
+ *
+ *     Internal - see relay_read() for details.
+ *
+ *     Returns the number of bytes read, 0 if none, negative on failure.
+ */
+static ssize_t
+__relay_read(struct rchan_reader *reader, char *buf, size_t count, u32 read_offset, u32 *new_offset, u32 *actual_read_offset, int wait)
+{
+       int err = 0;
+       size_t read_count = 0;
+       struct rchan *rchan = reader->rchan;
+
+       if (!wait && !rchan->initialized)
+               return -EAGAIN;
+
+       if (using_lockless(rchan))
+               read_offset &= idx_mask(rchan);
+
+       if (read_offset >= rchan->n_bufs * rchan->buf_size) {
+               *new_offset = 0;
+               if (!wait)
+                       return -EAGAIN;
+               else
+                       return -EINTR;
+       }
+       
+       if (buf != NULL && wait) {
+               err = wait_event_interruptible(rchan->read_wait,
+                      ((rchan->finalized == 1) ||
+                       (atomic_read(&rchan->suspended) == 1) ||
+                       (relay_get_offset(rchan, NULL) != read_offset)));
+
+               if (rchan->finalized)
+                       return 0;
+
+               if (reader->offset_changed) {
+                       reader->offset_changed = 0;
+                       return -EINTR;
+               }
+               
+               if (err)
+                       return err;
+       }
+
+       read_count = do_read(rchan, buf, count, read_offset, new_offset, actual_read_offset);
+
+       if (read_count < 0)
+               err = read_count;
+       
+       if (err)
+               return err;
+       else
+               return read_count;
+}
+
+/**
+ *     relay_read - read bytes from channel, relative to current reader pos
+ *     @reader: channel reader
+ *     @buf: user buf to read into, NULL if just getting info
+ *     @count: bytes requested
+ *     @wait: if non-zero, wait for something to read
+ *     @actual_read_offset: set read offset actually used, must not be NULL
+ *
+ *     Reads count bytes from the channel, or as much as is available within
+ *     the sub-buffer currently being read.  The read offset that will be
+ *     read from is the position contained within the reader object.  If the
+ *     wait flag is set, buf is non-NULL, and there is nothing available,
+ *     it will wait until there is.  If the wait flag is 0 and there is
+ *     nothing available, -EAGAIN is returned.  If buf is NULL, the value
+ *     returned is the number of bytes that would have been read.
+ *     actual_read_offset is the value that should be passed as the read
+ *     offset to relay_bytes_consumed, needed only if the reader is not
+ *     auto-consuming and the channel is MODE_NO_OVERWRITE, but in any case,
+ *     it must not be NULL.  See Documentation/filesystems/relayfs.txt for
+ *     more details.
+ */
+ssize_t
+relay_read(struct rchan_reader *reader, char *buf, size_t count, int wait, u32 *actual_read_offset)
+{
+       u32 new_offset;
+       u32 read_offset;
+       ssize_t read_count;
+       
+       if (reader == NULL || reader->rchan == NULL)
+               return -EBADF;
+
+       if (actual_read_offset == NULL)
+               return -EINVAL;
+
+       if (reader->vfs_reader)
+               read_offset = (u32)(reader->pos.file->f_pos);
+       else
+               read_offset = reader->pos.f_pos;
+       *actual_read_offset = read_offset;
+       
+       read_count = __relay_read(reader, buf, count, read_offset,
+                                 &new_offset, actual_read_offset, wait);
+
+       if (read_count < 0)
+               return read_count;
+
+       if (reader->vfs_reader)
+               reader->pos.file->f_pos = new_offset;
+       else
+               reader->pos.f_pos = new_offset;
+
+       if (reader->auto_consume && ((read_count) || (new_offset != read_offset)))
+               __reader_bytes_consumed(reader, read_count, *actual_read_offset);
+
+       if (read_count == 0 && !wait)
+               return -EAGAIN;
+       
+       return read_count;
+}
+
+/**
+ *     relay_bytes_avail - number of bytes available in current sub-buffer
+ *     @reader: channel reader
+ *     
+ *     Returns the number of bytes available relative to the reader's
+ *     current read position within the corresponding sub-buffer, 0 if
+ *     there is nothing available.  See Documentation/filesystems/relayfs.txt
+ *     for more details.
+ */
+ssize_t
+relay_bytes_avail(struct rchan_reader *reader)
+{
+       u32 f_pos;
+       u32 new_offset;
+       u32 actual_read_offset;
+       ssize_t bytes_read;
+       
+       if (reader == NULL || reader->rchan == NULL)
+               return -EBADF;
+       
+       if (reader->vfs_reader)
+               f_pos = (u32)reader->pos.file->f_pos;
+       else
+               f_pos = reader->pos.f_pos;
+       new_offset = f_pos;
+
+       bytes_read = __relay_read(reader, NULL, reader->rchan->buf_size,
+                                 f_pos, &new_offset, &actual_read_offset, 0);
+
+       if ((new_offset != f_pos) &&
+           ((bytes_read == -EINTR) || (bytes_read == 0)))
+               bytes_read = -EAGAIN;
+       else if ((bytes_read < 0) && (bytes_read != -EAGAIN))
+               bytes_read = 0;
+
+       return bytes_read;
+}
+
+/**
+ *     rchan_empty - boolean, is the channel empty wrt reader?
+ *     @reader: channel reader
+ *     
+ *     Returns 1 if the channel is empty, 0 otherwise.
+ */
+int
+rchan_empty(struct rchan_reader *reader)
+{
+       ssize_t avail_count;
+       u32 buffers_ready;
+       struct rchan *rchan = reader->rchan;
+       u32 cur_idx, curbuf_bytes;
+       int mapped;
+
+       if (atomic_read(&rchan->suspended) == 1)
+               return 0;
+
+       mapped = atomic_read(&rchan->mapped);
+       
+       if (mapped && bulk_delivery(rchan)) {
+               buffers_ready = rchan->bufs_produced - rchan->bufs_consumed;
+               return buffers_ready ? 0 : 1;
+       }
+
+       if (mapped && packet_delivery(rchan)) {
+               buffers_ready = rchan->bufs_produced - rchan->bufs_consumed;
+               if (buffers_ready)
+                       return 0;
+               else {
+                       cur_idx = relay_get_offset(rchan, NULL);
+                       curbuf_bytes = cur_idx % rchan->buf_size;
+                       return curbuf_bytes == rchan->bytes_consumed ? 1 : 0;
+               }
+       }
+
+       avail_count = relay_bytes_avail(reader);
+
+       return avail_count ? 0 : 1;
+}
+
+/**
+ *     rchan_full - boolean, is the channel full wrt consuming reader?
+ *     @reader: channel reader
+ *     
+ *     Returns 1 if the channel is full, 0 otherwise.
+ */
+int
+rchan_full(struct rchan_reader *reader)
+{
+       u32 buffers_ready;
+       struct rchan *rchan = reader->rchan;
+
+       if (mode_continuous(rchan))
+               return 0;
+
+       buffers_ready = rchan->bufs_produced - rchan->bufs_consumed;
+
+       return buffers_ready > reader->rchan->n_bufs - 1 ? 1 : 0;
+}
+
+/**
+ *     relay_info - get status and other information about a relay channel
+ *     @rchan_id: relay channel id
+ *     @rchan_info: pointer to the rchan_info struct to be filled in
+ *     
+ *     Fills in an rchan_info struct with channel status and attribute 
+ *     information.  See Documentation/filesystems/relayfs.txt for details.
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+int 
+relay_info(int rchan_id, struct rchan_info *rchan_info)
+{
+       int i;
+       struct rchan *rchan;
+
+       rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return -EBADF;
+
+       rchan_info->flags = rchan->flags;
+       rchan_info->buf_size = rchan->buf_size;
+       rchan_info->buf_addr = rchan->buf;
+       rchan_info->alloc_size = rchan->alloc_size;
+       rchan_info->n_bufs = rchan->n_bufs;
+       rchan_info->cur_idx = relay_get_offset(rchan, NULL);
+       rchan_info->bufs_produced = rchan->bufs_produced;
+       rchan_info->bufs_consumed = rchan->bufs_consumed;
+       rchan_info->buf_id = rchan->buf_id;
+
+       for (i = 0; i < rchan->n_bufs; i++) {
+               rchan_info->unused_bytes[i] = rchan->unused_bytes[i];
+               if (using_lockless(rchan))
+                       rchan_info->buffer_complete[i] = (atomic_read(&fill_count(rchan, i)) == rchan->buf_size);
+               else
+                       rchan_info->buffer_complete[i] = 0;
+       }
+
+       rchan_put(rchan);
+
+       return 0;
+}
+
+/**
+ *     __add_rchan_reader - creates and adds a reader to a channel
+ *     @rchan: relay channel
+ *     @filp: the file associated with rchan, if applicable
+ *     @auto_consume: boolean, whether reader's reads automatically consume
+ *     @map_reader: boolean, whether reader's reading via a channel mapping
+ *
+ *     Returns a pointer to the reader object create, NULL if unsuccessful
+ *
+ *     Creates and initializes an rchan_reader object for reading the channel.
+ *     If filp is non-NULL, the reader is a VFS reader, otherwise not.
+ *
+ *     If the reader is a map reader, it isn't considered a VFS reader for
+ *     our purposes.  Also, map_readers can't be auto-consuming.
+ */
+struct rchan_reader *
+__add_rchan_reader(struct rchan *rchan, struct file *filp, int auto_consume, int map_reader)
+{
+       struct rchan_reader *reader;
+       u32 will_read;
+       
+       reader = kmalloc(sizeof(struct rchan_reader), GFP_KERNEL);
+
+       if (reader) {
+               write_lock(&rchan->open_readers_lock);
+               reader->rchan = rchan;
+               if (filp) {
+                       reader->vfs_reader = 1;
+                       reader->pos.file = filp;
+               } else {
+                       reader->vfs_reader = 0;
+                       reader->pos.f_pos = 0;
+               }
+               reader->map_reader = map_reader;
+               reader->auto_consume = auto_consume;
+
+               if (!map_reader) {
+                       will_read = rchan->bufs_produced % rchan->n_bufs;
+                       if (!will_read && atomic_read(&rchan->suspended))
+                               will_read = rchan->n_bufs;
+                       reader->bufs_consumed = rchan->bufs_produced - will_read;
+                       rchan->bufs_consumed = reader->bufs_consumed;
+                       rchan->bytes_consumed = reader->bytes_consumed = 0;
+                       reader->offset_changed = 0;
+               }
+               
+               list_add(&reader->list, &rchan->open_readers);
+               write_unlock(&rchan->open_readers_lock);
+       }
+
+       return reader;
+}
+
+/**
+ *     add_rchan_reader - create a reader for a channel
+ *     @rchan_id: relay channel handle
+ *     @auto_consume: boolean, whether reader's reads automatically consume
+ *
+ *     Returns a pointer to the reader object created, NULL if unsuccessful
+ *
+ *     Creates and initializes an rchan_reader object for reading the channel.
+ *     This function is useful only for non-VFS readers.
+ */
+struct rchan_reader *
+add_rchan_reader(int rchan_id, int auto_consume)
+{
+       struct rchan *rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return NULL;
+
+       return __add_rchan_reader(rchan, NULL, auto_consume, 0);
+}
+
+/**
+ *     add_map_reader - create a map reader for a channel
+ *     @rchan_id: relay channel handle
+ *
+ *     Returns a pointer to the reader object created, NULL if unsuccessful
+ *
+ *     Creates and initializes an rchan_reader object for reading the channel.
+ *     This function is useful only for map readers.
+ */
+struct rchan_reader *
+add_map_reader(int rchan_id)
+{
+       struct rchan *rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return NULL;
+
+       return __add_rchan_reader(rchan, NULL, 0, 1);
+}
+
+/**
+ *     __remove_rchan_reader - destroy a channel reader
+ *     @reader: channel reader
+ *
+ *     Internal - removes reader from the open readers list, and frees it.
+ */
+void
+__remove_rchan_reader(struct rchan_reader *reader)
+{
+       struct list_head *p;
+       struct rchan_reader *found_reader = NULL;
+       
+       write_lock(&reader->rchan->open_readers_lock);
+       list_for_each(p, &reader->rchan->open_readers) {
+               found_reader = list_entry(p, struct rchan_reader, list);
+               if (found_reader == reader) {
+                       list_del(&found_reader->list);
+                       break;
+               }
+       }
+       write_unlock(&reader->rchan->open_readers_lock);
+
+       if (found_reader)
+               kfree(found_reader);
+}
+
+/**
+ *     remove_rchan_reader - destroy a channel reader
+ *     @reader: channel reader
+ *
+ *     Finds and removes the given reader from the channel.  This function
+ *     is useful only for non-VFS readers.
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+int 
+remove_rchan_reader(struct rchan_reader *reader)
+{
+       int err = 0;
+       
+       if (reader) {
+               rchan_put(reader->rchan);
+               __remove_rchan_reader(reader);
+       } else
+               err = -EINVAL;
+
+       return err;
+}
+
+/**
+ *     remove_map_reader - destroy a map reader
+ *     @reader: channel reader
+ *
+ *     Finds and removes the given map reader from the channel.  This function
+ *     is useful only for map readers.
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+int 
+remove_map_reader(struct rchan_reader *reader)
+{
+       return remove_rchan_reader(reader);
+}
+
+EXPORT_SYMBOL(relay_open);
+EXPORT_SYMBOL(relay_close);
+EXPORT_SYMBOL(relay_reset);
+EXPORT_SYMBOL(relay_reserve);
+EXPORT_SYMBOL(relay_commit);
+EXPORT_SYMBOL(relay_read);
+EXPORT_SYMBOL(relay_write);
+EXPORT_SYMBOL(relay_bytes_avail);
+EXPORT_SYMBOL(relay_buffers_consumed);
+EXPORT_SYMBOL(relay_bytes_consumed);
+EXPORT_SYMBOL(relay_info);
+EXPORT_SYMBOL(relay_discard_init_buf);
+
+
diff --git a/fs/relayfs/relay_locking.c b/fs/relayfs/relay_locking.c
new file mode 100644 (file)
index 0000000..718f149
--- /dev/null
@@ -0,0 +1,322 @@
+/*
+ * RelayFS locking scheme implementation.
+ *
+ * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ *
+ * This file is released under the GPL.
+ */
+
+#include <asm/relay.h>
+#include "relay_locking.h"
+#include "resize.h"
+
+/**
+ *     switch_buffers - switches between read and write buffers.
+ *     @cur_time: current time.
+ *     @cur_tsc: the TSC associated with current_time, if applicable
+ *     @rchan: the channel
+ *     @finalizing: if true, don't start a new buffer 
+ *     @resetting: if true, 
+ *
+ *     This should be called from with interrupts disabled.
+ */
+static void 
+switch_buffers(struct timeval cur_time,
+              u32 cur_tsc,
+              struct rchan *rchan,
+              int finalizing,
+              int resetting,
+              int finalize_buffer_only)
+{
+       char *chan_buf_end;
+       int bytes_written;
+
+       if (!rchan->half_switch) {
+               bytes_written = rchan->callbacks->buffer_end(rchan->id,
+                            cur_write_pos(rchan), write_buf_end(rchan),
+                            cur_time, cur_tsc, using_tsc(rchan));
+               if (bytes_written == 0)
+                       rchan->unused_bytes[rchan->buf_idx % rchan->n_bufs] = 
+                               write_buf_end(rchan) - cur_write_pos(rchan);
+       }
+
+       if (finalize_buffer_only) {
+               rchan->bufs_produced++;
+               return;
+       }
+       
+       chan_buf_end = rchan->buf + rchan->n_bufs * rchan->buf_size;
+       if((write_buf(rchan) + rchan->buf_size >= chan_buf_end) || resetting)
+               write_buf(rchan) = rchan->buf;
+       else
+               write_buf(rchan) += rchan->buf_size;
+       write_buf_end(rchan) = write_buf(rchan) + rchan->buf_size;
+       write_limit(rchan) = write_buf_end(rchan) - rchan->end_reserve;
+       cur_write_pos(rchan) = write_buf(rchan);
+
+       rchan->buf_start_time = cur_time;
+       rchan->buf_start_tsc = cur_tsc;
+
+       if (resetting)
+               rchan->buf_idx = 0;
+       else
+               rchan->buf_idx++;
+       rchan->buf_id++;
+
+       if (!packet_delivery(rchan))
+               rchan->unused_bytes[rchan->buf_idx % rchan->n_bufs] = 0;
+
+       if (resetting) {
+               rchan->bufs_produced = rchan->bufs_produced + rchan->n_bufs;
+               rchan->bufs_produced -= rchan->bufs_produced % rchan->n_bufs;
+               rchan->bufs_consumed = rchan->bufs_produced;
+               rchan->bytes_consumed = 0;
+               update_readers_consumed(rchan, rchan->bufs_consumed, rchan->bytes_consumed);
+       } else if (!rchan->half_switch)
+               rchan->bufs_produced++;
+
+       rchan->half_switch = 0;
+       
+       if (!finalizing) {
+               bytes_written = rchan->callbacks->buffer_start(rchan->id, cur_write_pos(rchan), rchan->buf_id, cur_time, cur_tsc, using_tsc(rchan));
+               cur_write_pos(rchan) += bytes_written;
+       }
+}
+
+/**
+ *     locking_reserve - reserve a slot in the buffer for an event.
+ *     @rchan: the channel
+ *     @slot_len: the length of the slot to reserve
+ *     @ts: variable that will receive the time the slot was reserved
+ *     @tsc: the timestamp counter associated with time
+ *     @err: receives the result flags
+ *     @interrupting: if this write is interrupting another, set to non-zero 
+ *
+ *     Returns pointer to the beginning of the reserved slot, NULL if error.
+ *
+ *     The err value contains the result flags and is an ORed combination 
+ *     of the following:
+ *
+ *     RELAY_BUFFER_SWITCH_NONE - no buffer switch occurred
+ *     RELAY_EVENT_DISCARD_NONE - event should not be discarded
+ *     RELAY_BUFFER_SWITCH - buffer switch occurred
+ *     RELAY_EVENT_DISCARD - event should be discarded (all buffers are full)
+ *     RELAY_EVENT_TOO_LONG - event won't fit into even an empty buffer
+ */
+inline char *
+locking_reserve(struct rchan *rchan,
+               u32 slot_len,
+               struct timeval *ts,
+               u32 *tsc,
+               int *err,
+               int *interrupting)
+{
+       u32 buffers_ready;
+       int bytes_written;
+
+       *err = RELAY_BUFFER_SWITCH_NONE;
+
+       if (slot_len >= rchan->buf_size) {
+               *err = RELAY_WRITE_DISCARD | RELAY_WRITE_TOO_LONG;
+               return NULL;
+       }
+
+       if (rchan->initialized == 0) {
+               rchan->initialized = 1;
+               get_timestamp(&rchan->buf_start_time, 
+                             &rchan->buf_start_tsc, rchan);
+               rchan->unused_bytes[0] = 0;
+               bytes_written = rchan->callbacks->buffer_start(
+                       rchan->id, cur_write_pos(rchan), 
+                       rchan->buf_id, rchan->buf_start_time, 
+                       rchan->buf_start_tsc, using_tsc(rchan));
+               cur_write_pos(rchan) += bytes_written;
+               *tsc = get_time_delta(ts, rchan);
+               return cur_write_pos(rchan);
+       }
+
+       *tsc = get_time_delta(ts, rchan);
+
+       if (in_progress_event_size(rchan)) {
+               interrupted_pos(rchan) = cur_write_pos(rchan);
+               cur_write_pos(rchan) = in_progress_event_pos(rchan) 
+                       + in_progress_event_size(rchan) 
+                       + interrupting_size(rchan);
+               *interrupting = 1;
+       } else {
+               in_progress_event_pos(rchan) = cur_write_pos(rchan);
+               in_progress_event_size(rchan) = slot_len;
+               interrupting_size(rchan) = 0;
+       }
+
+       if (cur_write_pos(rchan) + slot_len > write_limit(rchan)) {
+               if (atomic_read(&rchan->suspended) == 1) {
+                       in_progress_event_pos(rchan) = NULL;
+                       in_progress_event_size(rchan) = 0;
+                       interrupting_size(rchan) = 0;
+                       *err = RELAY_WRITE_DISCARD;
+                       return NULL;
+               }
+
+               buffers_ready = rchan->bufs_produced - rchan->bufs_consumed;
+               if (buffers_ready == rchan->n_bufs - 1) {
+                       if (!mode_continuous(rchan)) {
+                               atomic_set(&rchan->suspended, 1);
+                               in_progress_event_pos(rchan) = NULL;
+                               in_progress_event_size(rchan) = 0;
+                               interrupting_size(rchan) = 0;
+                               get_timestamp(ts, tsc, rchan);
+                               switch_buffers(*ts, *tsc, rchan, 0, 0, 1);
+                               recalc_time_delta(ts, tsc, rchan);
+                               rchan->half_switch = 1;
+
+                               cur_write_pos(rchan) = write_buf_end(rchan) - 1;
+                               *err = RELAY_BUFFER_SWITCH | RELAY_WRITE_DISCARD;
+                               return NULL;
+                       }
+               }
+
+               get_timestamp(ts, tsc, rchan);
+               switch_buffers(*ts, *tsc, rchan, 0, 0, 0);
+               recalc_time_delta(ts, tsc, rchan);
+               *err = RELAY_BUFFER_SWITCH;
+       }
+
+       return cur_write_pos(rchan);
+}
+
+/**
+ *     locking_commit - commit a reserved slot in the buffer
+ *     @rchan: the channel
+ *     @from: commit the length starting here
+ *     @len: length committed
+ *     @deliver: length committed
+ *     @interrupting: not used
+ *
+ *      Commits len bytes and calls deliver callback if applicable.
+ */
+inline void
+locking_commit(struct rchan *rchan,
+              char *from,
+              u32 len, 
+              int deliver, 
+              int interrupting)
+{
+       cur_write_pos(rchan) += len;
+       
+       if (interrupting) {
+               cur_write_pos(rchan) = interrupted_pos(rchan);
+               interrupting_size(rchan) += len;
+       } else {
+               in_progress_event_size(rchan) = 0;
+               if (interrupting_size(rchan)) {
+                       cur_write_pos(rchan) += interrupting_size(rchan);
+                       interrupting_size(rchan) = 0;
+               }
+       }
+
+       if (deliver) {
+               if (bulk_delivery(rchan)) {
+                       u32 cur_idx = cur_write_pos(rchan) - rchan->buf;
+                       u32 cur_bufno = cur_idx / rchan->buf_size;
+                       from = rchan->buf + cur_bufno * rchan->buf_size;
+                       len = cur_idx - cur_bufno * rchan->buf_size;
+               }
+               rchan->callbacks->deliver(rchan->id, from, len);
+               expand_check(rchan);
+       }
+}
+
+/**
+ *     locking_finalize: - finalize last buffer at end of channel use
+ *     @rchan: the channel
+ */
+inline void 
+locking_finalize(struct rchan *rchan)
+{
+       unsigned long int flags;
+       struct timeval time;
+       u32 tsc;
+
+       local_irq_save(flags);
+       get_timestamp(&time, &tsc, rchan);
+       switch_buffers(time, tsc, rchan, 1, 0, 0);
+       local_irq_restore(flags);
+}
+
+/**
+ *     locking_get_offset - get current and max 'file' offsets for VFS
+ *     @rchan: the channel
+ *     @max_offset: maximum channel offset
+ *
+ *     Returns the current and maximum buffer offsets in VFS terms.
+ */
+u32
+locking_get_offset(struct rchan *rchan,
+                  u32 *max_offset)
+{
+       if (max_offset)
+               *max_offset = rchan->buf_size * rchan->n_bufs - 1;
+
+       return cur_write_pos(rchan) - rchan->buf;
+}
+
+/**
+ *     locking_reset - reset the channel
+ *     @rchan: the channel
+ *     @init: 1 if this is a first-time channel initialization
+ */
+void locking_reset(struct rchan *rchan, int init)
+{
+       if (init)
+               channel_lock(rchan) = SPIN_LOCK_UNLOCKED;
+       write_buf(rchan) = rchan->buf;
+       write_buf_end(rchan) = write_buf(rchan) + rchan->buf_size;
+       cur_write_pos(rchan) = write_buf(rchan);
+       write_limit(rchan) = write_buf_end(rchan) - rchan->end_reserve;
+       in_progress_event_pos(rchan) = NULL;
+       in_progress_event_size(rchan) = 0;
+       interrupted_pos(rchan) = NULL;
+       interrupting_size(rchan) = 0;
+}
+
+/**
+ *     locking_reset_index - atomically set channel index to the beginning
+ *     @rchan: the channel
+ *
+ *     If this fails, it means that something else just logged something
+ *     and therefore we probably no longer want to do this.  It's up to the
+ *     caller anyway...
+ *
+ *     Returns 0 if the index was successfully set, negative otherwise
+ */
+int
+locking_reset_index(struct rchan *rchan, u32 old_idx)
+{
+       unsigned long flags;
+       struct timeval time;
+       u32 tsc;
+       u32 cur_idx;
+       
+       relay_lock_channel(rchan, flags);
+       cur_idx = locking_get_offset(rchan, NULL);
+       if (cur_idx != old_idx) {
+               relay_unlock_channel(rchan, flags);
+               return -1;
+       }
+
+       get_timestamp(&time, &tsc, rchan);
+       switch_buffers(time, tsc, rchan, 0, 1, 0);
+
+       relay_unlock_channel(rchan, flags);
+
+       return 0;
+}
+
+
+
+
+
+
+
diff --git a/fs/relayfs/relay_locking.h b/fs/relayfs/relay_locking.h
new file mode 100644 (file)
index 0000000..3dde7df
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef _RELAY_LOCKING_H
+#define _RELAY_LOCKING_H
+
+extern char *
+locking_reserve(struct rchan *rchan,
+               u32 slot_len, 
+               struct timeval *time_stamp,
+               u32 *tsc,
+               int *err,
+               int *interrupting);
+
+extern void 
+locking_commit(struct rchan *rchan,
+              char *from,
+              u32 len, 
+              int deliver, 
+              int interrupting);
+
+extern void 
+locking_resume(struct rchan *rchan);
+
+extern void 
+locking_finalize(struct rchan *rchan);
+
+extern u32 
+locking_get_offset(struct rchan *rchan, u32 *max_offset);
+
+extern void 
+locking_reset(struct rchan *rchan, int init);
+
+extern int
+locking_reset_index(struct rchan *rchan, u32 old_idx);
+
+#endif /* _RELAY_LOCKING_H */
diff --git a/fs/relayfs/relay_lockless.c b/fs/relayfs/relay_lockless.c
new file mode 100644 (file)
index 0000000..98524bf
--- /dev/null
@@ -0,0 +1,541 @@
+/*
+ * RelayFS lockless scheme implementation.
+ *
+ * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 2002, 2003 - Bob Wisniewski (bob@watson.ibm.com), IBM Corp
+ *
+ * This file is released under the GPL.
+ */
+
+#include <asm/relay.h>
+#include "relay_lockless.h"
+#include "resize.h"
+
+/**
+ *     compare_and_store_volatile - self-explicit
+ *     @ptr: ptr to the word that will receive the new value
+ *     @oval: the value we think is currently in *ptr
+ *     @nval: the value *ptr will get if we were right
+ */
+inline int 
+compare_and_store_volatile(volatile u32 *ptr, 
+                          u32 oval,
+                          u32 nval)
+{
+       u32 prev;
+
+       barrier();
+       prev = cmpxchg(ptr, oval, nval);
+       barrier();
+
+       return (prev == oval);
+}
+
+/**
+ *     atomic_set_volatile - atomically set the value in ptr to nval.
+ *     @ptr: ptr to the word that will receive the new value
+ *     @nval: the new value
+ */
+inline void 
+atomic_set_volatile(atomic_t *ptr,
+                   u32 nval)
+{
+       barrier();
+       atomic_set(ptr, (int)nval);
+       barrier();
+}
+
+/**
+ *     atomic_add_volatile - atomically add val to the value at ptr.
+ *     @ptr: ptr to the word that will receive the addition
+ *     @val: the value to add to *ptr
+ */
+inline void 
+atomic_add_volatile(atomic_t *ptr, u32 val)
+{
+       barrier();
+       atomic_add((int)val, ptr);
+       barrier();
+}
+
+/**
+ *     atomic_sub_volatile - atomically substract val from the value at ptr.
+ *     @ptr: ptr to the word that will receive the subtraction
+ *     @val: the value to subtract from *ptr
+ */
+inline void 
+atomic_sub_volatile(atomic_t *ptr, s32 val)
+{
+       barrier();
+       atomic_sub((int)val, ptr);
+       barrier();
+}
+
+/**
+ *     lockless_commit - commit a reserved slot in the buffer
+ *     @rchan: the channel
+ *     @from: commit the length starting here
+ *     @len: length committed
+ *     @deliver: length committed
+ *     @interrupting: not used
+ *
+ *      Commits len bytes and calls deliver callback if applicable.
+ */
+inline void 
+lockless_commit(struct rchan *rchan,
+               char *from,
+               u32 len, 
+               int deliver, 
+               int interrupting)
+{
+       u32 bufno, idx;
+       
+       idx = from - rchan->buf;
+
+       if (len > 0) {
+               bufno = RELAY_BUFNO_GET(idx, offset_bits(rchan));
+               atomic_add_volatile(&fill_count(rchan, bufno), len);
+       }
+
+       if (deliver) {
+               u32 mask = offset_mask(rchan);
+               if (bulk_delivery(rchan)) {
+                       from = rchan->buf + RELAY_BUF_OFFSET_CLEAR(idx, mask);
+                       len += RELAY_BUF_OFFSET_GET(idx, mask);
+               }
+               rchan->callbacks->deliver(rchan->id, from, len);
+               expand_check(rchan);
+       }
+}
+
+/**
+ *     get_buffer_end - get the address of the end of buffer 
+ *     @rchan: the channel
+ *     @buf_idx: index into channel corresponding to address
+ */
+static inline char * 
+get_buffer_end(struct rchan *rchan, u32 buf_idx)
+{
+       return rchan->buf
+               + RELAY_BUF_OFFSET_CLEAR(buf_idx, offset_mask(rchan))
+               + RELAY_BUF_SIZE(offset_bits(rchan));
+}
+
+
+/**
+ *     finalize_buffer - utility function consolidating end-of-buffer tasks.
+ *     @rchan: the channel
+ *     @end_idx: index into buffer to write the end-buffer event at
+ *     @size_lost: number of unused bytes at the end of the buffer
+ *     @time_stamp: the time of the end-buffer event
+ *     @tsc: the timestamp counter associated with time
+ *     @resetting: are we resetting the channel?
+ *
+ *     This function must be called with local irqs disabled.
+ */
+static inline void 
+finalize_buffer(struct rchan *rchan,
+               u32 end_idx,
+               u32 size_lost, 
+               struct timeval *time_stamp,
+               u32 *tsc, 
+               int resetting)
+{
+       char* cur_write_pos;
+       char* write_buf_end;
+       u32 bufno;
+       int bytes_written;
+       
+       cur_write_pos = rchan->buf + end_idx;
+       write_buf_end = get_buffer_end(rchan, end_idx - 1);
+
+       bytes_written = rchan->callbacks->buffer_end(rchan->id, cur_write_pos, 
+                    write_buf_end, *time_stamp, *tsc, using_tsc(rchan));
+       if (bytes_written == 0)
+               rchan->unused_bytes[rchan->buf_idx % rchan->n_bufs] = size_lost;
+       
+        bufno = RELAY_BUFNO_GET(end_idx, offset_bits(rchan));
+        atomic_add_volatile(&fill_count(rchan, bufno), size_lost);
+       if (resetting) {
+               rchan->bufs_produced = rchan->bufs_produced + rchan->n_bufs;
+               rchan->bufs_produced -= rchan->bufs_produced % rchan->n_bufs;
+               rchan->bufs_consumed = rchan->bufs_produced;
+               rchan->bytes_consumed = 0;
+               update_readers_consumed(rchan, rchan->bufs_consumed, rchan->bytes_consumed);
+       } else
+               rchan->bufs_produced++;
+}
+
+/**
+ *     lockless_finalize: - finalize last buffer at end of channel use
+ *     @rchan: the channel
+ */
+inline void
+lockless_finalize(struct rchan *rchan)
+{
+       u32 event_end_idx;
+       u32 size_lost;
+       unsigned long int flags;
+       struct timeval time;
+       u32 tsc;
+
+       event_end_idx = RELAY_BUF_OFFSET_GET(idx(rchan), offset_mask(rchan));
+       size_lost = RELAY_BUF_SIZE(offset_bits(rchan)) - event_end_idx;
+
+       local_irq_save(flags);
+       get_timestamp(&time, &tsc, rchan);
+       finalize_buffer(rchan, idx(rchan) & idx_mask(rchan), size_lost, 
+                       &time, &tsc, 0);
+       local_irq_restore(flags);
+}
+
+/**
+ *     discard_check: - determine whether a write should be discarded
+ *     @rchan: the channel
+ *     @old_idx: index into buffer where check for space should begin
+ *     @write_len: the length of the write to check
+ *     @time_stamp: the time of the end-buffer event
+ *     @tsc: the timestamp counter associated with time
+ *
+ *     The return value contains the result flags and is an ORed combination 
+ *     of the following:
+ *
+ *     RELAY_WRITE_DISCARD_NONE - write should not be discarded
+ *     RELAY_BUFFER_SWITCH - buffer switch occurred
+ *     RELAY_WRITE_DISCARD - write should be discarded (all buffers are full)
+ *     RELAY_WRITE_TOO_LONG - write won't fit into even an empty buffer
+ */
+static inline int
+discard_check(struct rchan *rchan,
+             u32 old_idx,
+             u32 write_len, 
+             struct timeval *time_stamp,
+             u32 *tsc)
+{
+       u32 buffers_ready;
+       u32 offset_mask = offset_mask(rchan);
+       u8 offset_bits = offset_bits(rchan);
+       u32 idx_mask = idx_mask(rchan);
+       u32 size_lost;
+       unsigned long int flags;
+
+       if (write_len > RELAY_BUF_SIZE(offset_bits))
+               return RELAY_WRITE_DISCARD | RELAY_WRITE_TOO_LONG;
+
+       if (mode_continuous(rchan))
+               return RELAY_WRITE_DISCARD_NONE;
+       
+       local_irq_save(flags);
+       if (atomic_read(&rchan->suspended) == 1) {
+               local_irq_restore(flags);
+               return RELAY_WRITE_DISCARD;
+       }
+       if (rchan->half_switch) {
+               local_irq_restore(flags);
+               return RELAY_WRITE_DISCARD_NONE;
+       }
+       buffers_ready = rchan->bufs_produced - rchan->bufs_consumed;
+       if (buffers_ready == rchan->n_bufs - 1) {
+               atomic_set(&rchan->suspended, 1);
+               size_lost = RELAY_BUF_SIZE(offset_bits)
+                       - RELAY_BUF_OFFSET_GET(old_idx, offset_mask);
+               finalize_buffer(rchan, old_idx & idx_mask, size_lost, 
+                               time_stamp, tsc, 0);
+               rchan->half_switch = 1;
+               idx(rchan) = RELAY_BUF_OFFSET_CLEAR((old_idx & idx_mask), offset_mask(rchan)) + RELAY_BUF_SIZE(offset_bits) - 1;
+               local_irq_restore(flags);
+
+               return RELAY_BUFFER_SWITCH | RELAY_WRITE_DISCARD;
+       }
+       local_irq_restore(flags);
+
+       return RELAY_WRITE_DISCARD_NONE;
+}
+
+/**
+ *     switch_buffers - switch over to a new sub-buffer
+ *     @rchan: the channel
+ *     @slot_len: the length of the slot needed for the current write
+ *     @offset: the offset calculated for the new index
+ *     @ts: timestamp
+ *     @tsc: the timestamp counter associated with time
+ *     @old_idx: the value of the buffer control index when we were called
+ *     @old_idx: the new calculated value of the buffer control index
+ *     @resetting: are we resetting the channel?
+ */
+static inline void
+switch_buffers(struct rchan *rchan,
+              u32 slot_len,
+              u32 offset,
+              struct timeval *ts,
+              u32 *tsc,
+              u32 new_idx,
+              u32 old_idx,
+              int resetting)
+{
+       u32 size_lost = rchan->end_reserve;
+       unsigned long int flags;
+       u32 idx_mask = idx_mask(rchan);
+       u8 offset_bits = offset_bits(rchan);
+       char *cur_write_pos;
+       u32 new_buf_no;
+       u32 start_reserve = rchan->start_reserve;
+       
+       if (resetting)
+               size_lost = RELAY_BUF_SIZE(offset_bits(rchan)) - old_idx % rchan->buf_size;
+
+       if (offset > 0)
+               size_lost += slot_len - offset;
+       else
+               old_idx += slot_len;
+
+       local_irq_save(flags);
+       if (!rchan->half_switch)
+               finalize_buffer(rchan, old_idx & idx_mask, size_lost,
+                               ts, tsc, resetting);
+       rchan->half_switch = 0;
+       rchan->buf_start_time = *ts;
+       rchan->buf_start_tsc = *tsc;
+       local_irq_restore(flags);
+
+       cur_write_pos = rchan->buf + RELAY_BUF_OFFSET_CLEAR((new_idx
+                                            & idx_mask), offset_mask(rchan));
+       if (resetting)
+               rchan->buf_idx = 0;
+       else
+               rchan->buf_idx++;
+       rchan->buf_id++;
+       
+       rchan->unused_bytes[rchan->buf_idx % rchan->n_bufs] = 0;
+
+       rchan->callbacks->buffer_start(rchan->id, cur_write_pos, 
+                              rchan->buf_id, *ts, *tsc, using_tsc(rchan));
+       new_buf_no = RELAY_BUFNO_GET(new_idx & idx_mask, offset_bits);
+       atomic_sub_volatile(&fill_count(rchan, new_buf_no),
+                           RELAY_BUF_SIZE(offset_bits) - start_reserve);
+       if (atomic_read(&fill_count(rchan, new_buf_no)) < start_reserve)
+               atomic_set_volatile(&fill_count(rchan, new_buf_no), 
+                                   start_reserve);
+}
+
+/**
+ *     lockless_reserve_slow - the slow reserve path in the lockless scheme
+ *     @rchan: the channel
+ *     @slot_len: the length of the slot to reserve
+ *     @ts: variable that will receive the time the slot was reserved
+ *     @tsc: the timestamp counter associated with time
+ *     @old_idx: the value of the buffer control index when we were called
+ *     @err: receives the result flags
+ *
+ *     Returns pointer to the beginning of the reserved slot, NULL if error.
+
+ *     err values same as for lockless_reserve.
+ */
+static inline char *
+lockless_reserve_slow(struct rchan *rchan,
+                     u32 slot_len,
+                     struct timeval *ts,
+                     u32 *tsc,
+                     u32 old_idx,
+                     int *err)
+{
+       u32 new_idx, offset;
+       unsigned long int flags;
+       u32 offset_mask = offset_mask(rchan);
+       u32 idx_mask = idx_mask(rchan);
+       u32 start_reserve = rchan->start_reserve;
+       u32 end_reserve = rchan->end_reserve;
+       int discard_event;
+       u32 reserved_idx;
+       char *cur_write_pos;
+       int initializing = 0;
+
+       *err = RELAY_BUFFER_SWITCH_NONE;
+
+       discard_event = discard_check(rchan, old_idx, slot_len, ts, tsc);
+       if (discard_event != RELAY_WRITE_DISCARD_NONE) {
+               *err = discard_event;
+               return NULL;
+       }
+
+       local_irq_save(flags);
+       if (rchan->initialized == 0) {
+               rchan->initialized = initializing = 1;
+               idx(rchan) = rchan->start_reserve + rchan->rchan_start_reserve;
+       }
+       local_irq_restore(flags);
+
+       do {
+               old_idx = idx(rchan);
+               new_idx = old_idx + slot_len;
+
+               offset = RELAY_BUF_OFFSET_GET(new_idx + end_reserve,
+                                             offset_mask);
+               if ((offset < slot_len) && (offset > 0)) {
+                       reserved_idx = RELAY_BUF_OFFSET_CLEAR(new_idx 
+                               + end_reserve, offset_mask) + start_reserve;
+                       new_idx = reserved_idx + slot_len;
+               } else if (offset < slot_len) {
+                       reserved_idx = old_idx;
+                       new_idx = RELAY_BUF_OFFSET_CLEAR(new_idx
+                             + end_reserve, offset_mask) + start_reserve;
+               } else
+                       reserved_idx = old_idx;
+               get_timestamp(ts, tsc, rchan);
+       } while (!compare_and_store_volatile(&idx(rchan), old_idx, new_idx));
+
+       reserved_idx &= idx_mask;
+
+       if (initializing == 1) {
+               cur_write_pos = rchan->buf 
+                       + RELAY_BUF_OFFSET_CLEAR((old_idx & idx_mask),
+                                                offset_mask(rchan));
+               rchan->buf_start_time = *ts;
+               rchan->buf_start_tsc = *tsc;
+               rchan->unused_bytes[0] = 0;
+
+               rchan->callbacks->buffer_start(rchan->id, cur_write_pos, 
+                              rchan->buf_id, *ts, *tsc, using_tsc(rchan));
+       }
+
+       if (offset < slot_len) {
+               switch_buffers(rchan, slot_len, offset, ts, tsc, new_idx,
+                              old_idx, 0);
+               *err = RELAY_BUFFER_SWITCH;
+       }
+
+       /* If not using TSC, need to calc time delta */
+       recalc_time_delta(ts, tsc, rchan);
+
+       return rchan->buf + reserved_idx;
+}
+
+/**
+ *     lockless_reserve - reserve a slot in the buffer for an event.
+ *     @rchan: the channel
+ *     @slot_len: the length of the slot to reserve
+ *     @ts: variable that will receive the time the slot was reserved
+ *     @tsc: the timestamp counter associated with time
+ *     @err: receives the result flags
+ *     @interrupting: not used
+ *
+ *     Returns pointer to the beginning of the reserved slot, NULL if error.
+ *
+ *     The err value contains the result flags and is an ORed combination 
+ *     of the following:
+ *
+ *     RELAY_BUFFER_SWITCH_NONE - no buffer switch occurred
+ *     RELAY_EVENT_DISCARD_NONE - event should not be discarded
+ *     RELAY_BUFFER_SWITCH - buffer switch occurred
+ *     RELAY_EVENT_DISCARD - event should be discarded (all buffers are full)
+ *     RELAY_EVENT_TOO_LONG - event won't fit into even an empty buffer
+ */
+inline char * 
+lockless_reserve(struct rchan *rchan,
+                u32 slot_len,
+                struct timeval *ts,
+                u32 *tsc,
+                int *err,
+                int *interrupting)
+{
+       u32 old_idx, new_idx, offset;
+       u32 offset_mask = offset_mask(rchan);
+
+       do {
+               old_idx = idx(rchan);
+               new_idx = old_idx + slot_len;
+
+               offset = RELAY_BUF_OFFSET_GET(new_idx + rchan->end_reserve, 
+                                             offset_mask);
+               if (offset < slot_len)
+                       return lockless_reserve_slow(rchan, slot_len, 
+                                    ts, tsc, old_idx, err);
+               get_time_or_tsc(ts, tsc, rchan);
+       } while (!compare_and_store_volatile(&idx(rchan), old_idx, new_idx));
+
+       /* If not using TSC, need to calc time delta */
+       recalc_time_delta(ts, tsc, rchan);
+
+       *err = RELAY_BUFFER_SWITCH_NONE;
+
+       return rchan->buf + (old_idx & idx_mask(rchan));
+}
+
+/**
+ *     lockless_get_offset - get current and max channel offsets
+ *     @rchan: the channel
+ *     @max_offset: maximum channel offset
+ *
+ *     Returns the current and maximum channel offsets.
+ */
+u32 
+lockless_get_offset(struct rchan *rchan,
+                       u32 *max_offset)
+{
+       if (max_offset)
+               *max_offset = rchan->buf_size * rchan->n_bufs - 1;
+
+       return rchan->initialized ? idx(rchan) & idx_mask(rchan) : 0;
+}
+
+/**
+ *     lockless_reset - reset the channel
+ *     @rchan: the channel
+ *     @init: 1 if this is a first-time channel initialization
+ */
+void lockless_reset(struct rchan *rchan, int init)
+{
+       int i;
+       
+       /* Start first buffer at 0 - (end_reserve + 1) so that it
+          gets initialized via buffer_start callback as well. */
+       idx(rchan) =  0UL - (rchan->end_reserve + 1);
+       idx_mask(rchan) =
+               (1UL << (bufno_bits(rchan) + offset_bits(rchan))) - 1;
+       atomic_set(&fill_count(rchan, 0), 
+                  (int)rchan->start_reserve + 
+                  (int)rchan->rchan_start_reserve);
+       for (i = 1; i < rchan->n_bufs; i++)
+               atomic_set(&fill_count(rchan, i),
+                          (int)RELAY_BUF_SIZE(offset_bits(rchan)));
+}
+
+/**
+ *     lockless_reset_index - atomically set channel index to the beginning
+ *     @rchan: the channel
+ *     @old_idx: the current index
+ *
+ *     If this fails, it means that something else just logged something
+ *     and therefore we probably no longer want to do this.  It's up to the
+ *     caller anyway...
+ *
+ *     Returns 0 if the index was successfully set, negative otherwise
+ */
+int
+lockless_reset_index(struct rchan *rchan, u32 old_idx)
+{
+       struct timeval ts;
+       u32 tsc;
+       u32 new_idx;
+
+       if (compare_and_store_volatile(&idx(rchan), old_idx, 0)) {
+               new_idx = rchan->start_reserve;
+               switch_buffers(rchan, 0, 0, &ts, &tsc, new_idx, old_idx, 1);
+               return 0;
+       } else
+               return -1;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fs/relayfs/relay_lockless.h b/fs/relayfs/relay_lockless.h
new file mode 100644 (file)
index 0000000..8d4189e
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef _RELAY_LOCKLESS_H
+#define _RELAY_LOCKLESS_H
+
+extern char *
+lockless_reserve(struct rchan *rchan,
+                u32 slot_len,
+                struct timeval *time_stamp,
+                u32 *tsc,
+                int * interrupting,
+                int * errcode);
+
+extern void 
+lockless_commit(struct rchan *rchan,
+               char * from,
+               u32 len, 
+               int deliver, 
+               int interrupting);
+
+extern void 
+lockless_resume(struct rchan *rchan);
+
+extern void 
+lockless_finalize(struct rchan *rchan);
+
+extern u32 
+lockless_get_offset(struct rchan *rchan, u32 *max_offset);
+
+extern void
+lockless_reset(struct rchan *rchan, int init);
+
+extern int
+lockless_reset_index(struct rchan *rchan, u32 old_idx);
+
+#endif/* _RELAY_LOCKLESS_H */
diff --git a/fs/relayfs/resize.c b/fs/relayfs/resize.c
new file mode 100644 (file)
index 0000000..25f00bf
--- /dev/null
@@ -0,0 +1,1091 @@
+/*
+ * RelayFS buffer management and resizing code.
+ *
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
+ *
+ * This file is released under the GPL.
+ */
+
+#include <linux/module.h>
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+#include <asm/relay.h>
+#include "resize.h"
+
+/**
+ *     alloc_page_array - alloc array to hold pages, but not pages
+ *     @size: the total size of the memory represented by the page array
+ *     @page_count: the number of pages the array can hold
+ *     @err: 0 on success, negative otherwise
+ *
+ *     Returns a pointer to the page array if successful, NULL otherwise.
+ */
+static struct page **
+alloc_page_array(int size, int *page_count, int *err)
+{
+       int n_pages;
+       struct page **page_array;
+       int page_array_size;
+
+       *err = 0;
+       
+       size = PAGE_ALIGN(size);
+       n_pages = size >> PAGE_SHIFT;
+       page_array_size = n_pages * sizeof(struct page *);
+       page_array = kmalloc(page_array_size, GFP_KERNEL);
+       if (page_array == NULL) {
+               *err = -ENOMEM;
+               return NULL;
+       }
+       *page_count = n_pages;
+       memset(page_array, 0, page_array_size);
+
+       return page_array;
+}
+
+/**
+ *     free_page_array - free array to hold pages, but not pages
+ *     @page_array: pointer to the page array
+ */
+static inline void
+free_page_array(struct page **page_array)
+{
+       kfree(page_array);
+}
+
+/**
+ *     depopulate_page_array - free and unreserve all pages in the array
+ *     @page_array: pointer to the page array
+ *     @page_count: number of pages to free
+ */
+static void
+depopulate_page_array(struct page **page_array, int page_count)
+{
+       int i;
+       
+       for (i = 0; i < page_count; i++) {
+               ClearPageReserved(page_array[i]);
+               __free_page(page_array[i]);
+       }
+}
+
+/**
+ *     populate_page_array - allocate and reserve pages
+ *     @page_array: pointer to the page array
+ *     @page_count: number of pages to allocate
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+static int
+populate_page_array(struct page **page_array, int page_count)
+{
+       int i;
+       
+       for (i = 0; i < page_count; i++) {
+               page_array[i] = alloc_page(GFP_KERNEL);
+               if (unlikely(!page_array[i])) {
+                       depopulate_page_array(page_array, i);
+                       return -ENOMEM;
+               }
+               SetPageReserved(page_array[i]);
+       }
+       return 0;
+}
+
+/**
+ *     alloc_rchan_buf - allocate the initial channel buffer
+ *     @size: total size of the buffer
+ *     @page_array: receives a pointer to the buffer's page array
+ *     @page_count: receives the number of pages allocated
+ *
+ *     Returns a pointer to the resulting buffer, NULL if unsuccessful
+ */
+void *
+alloc_rchan_buf(unsigned long size, struct page ***page_array, int *page_count)
+{
+       void *mem;
+       int err;
+
+       *page_array = alloc_page_array(size, page_count, &err);
+       if (!*page_array)
+               return NULL;
+
+       err = populate_page_array(*page_array, *page_count);
+       if (err) {
+               free_page_array(*page_array);
+               *page_array = NULL;
+               return NULL;
+       }
+
+       mem = vmap(*page_array, *page_count, GFP_KERNEL, PAGE_KERNEL);
+       if (!mem) {
+               depopulate_page_array(*page_array, *page_count);
+               free_page_array(*page_array);
+               *page_array = NULL;
+               return NULL;
+       }
+       memset(mem, 0, size);
+
+       return mem;
+}
+
+/**
+ *     free_rchan_buf - free a channel buffer
+ *     @buf: pointer to the buffer to free
+ *     @page_array: pointer to the buffer's page array
+ *     @page_count: number of pages in page array
+ */
+void
+free_rchan_buf(void *buf, struct page **page_array, int page_count)
+{
+       vunmap(buf);
+       depopulate_page_array(page_array, page_count);
+       free_page_array(page_array);
+}
+
+/**
+ *     expand_check - check whether the channel needs expanding
+ *     @rchan: the channel
+ *
+ *     If the channel needs expanding, the needs_resize callback is
+ *     called with RELAY_RESIZE_EXPAND.
+ *
+ *     Returns the suggested number of sub-buffers for the new
+ *     buffer.
+ */
+void
+expand_check(struct rchan *rchan)
+{
+       u32 active_bufs;
+       u32 new_n_bufs = 0;
+       u32 threshold = rchan->n_bufs * RESIZE_THRESHOLD;
+
+       if (rchan->init_buf)
+               return;
+
+       if (rchan->resize_min == 0)
+               return;
+
+       if (rchan->resizing || rchan->replace_buffer)
+               return;
+       
+       active_bufs = rchan->bufs_produced - rchan->bufs_consumed + 1;
+
+       if (rchan->resize_max && active_bufs == threshold) {
+               new_n_bufs = rchan->n_bufs * 2;
+       }
+
+       if (new_n_bufs && (new_n_bufs * rchan->buf_size <= rchan->resize_max))
+               rchan->callbacks->needs_resize(rchan->id,
+                                              RELAY_RESIZE_EXPAND,
+                                              rchan->buf_size, 
+                                              new_n_bufs);
+}
+
+/**
+ *     can_shrink - check whether the channel can shrink
+ *     @rchan: the channel
+ *     @cur_idx: the current channel index
+ *
+ *     Returns the suggested number of sub-buffers for the new
+ *     buffer, 0 if the buffer is not shrinkable.
+ */
+static inline u32
+can_shrink(struct rchan *rchan, u32 cur_idx)
+{
+       u32 active_bufs = rchan->bufs_produced - rchan->bufs_consumed + 1;
+       u32 new_n_bufs = 0;
+       u32 cur_bufno_bytes = cur_idx % rchan->buf_size;
+
+       if (rchan->resize_min == 0 ||
+           rchan->resize_min >= rchan->n_bufs * rchan->buf_size)
+               goto out;
+       
+       if (active_bufs > 1)
+               goto out;
+
+       if (cur_bufno_bytes != rchan->bytes_consumed)
+               goto out;
+       
+       new_n_bufs = rchan->resize_min / rchan->buf_size;
+out:
+       return new_n_bufs;
+}
+
+/**
+ *     shrink_check: - timer function checking whether the channel can shrink
+ *     @data: unused
+ *
+ *     Every SHRINK_TIMER_SECS, check whether the channel is shrinkable.
+ *     If so, we attempt to atomically reset the channel to the beginning.
+ *     The needs_resize callback is then called with RELAY_RESIZE_SHRINK.
+ *     If the reset fails, it means we really shouldn't be shrinking now
+ *     and need to wait until the next time around.
+ */
+static void
+shrink_check(unsigned long data)
+{
+       struct rchan *rchan = (struct rchan *)data;
+       u32 shrink_to_nbufs, cur_idx;
+       
+       del_timer(&rchan->shrink_timer);
+       rchan->shrink_timer.expires = jiffies + SHRINK_TIMER_SECS * HZ;
+       add_timer(&rchan->shrink_timer);
+
+       if (rchan->init_buf)
+               return;
+
+       if (rchan->resizing || rchan->replace_buffer)
+               return;
+
+       if (using_lockless(rchan))
+               cur_idx = idx(rchan);
+       else
+               cur_idx = relay_get_offset(rchan, NULL);
+
+       shrink_to_nbufs = can_shrink(rchan, cur_idx);
+       if (shrink_to_nbufs != 0 && reset_index(rchan, cur_idx) == 0) {
+               update_readers_consumed(rchan, rchan->bufs_consumed, 0);
+               rchan->callbacks->needs_resize(rchan->id,
+                                              RELAY_RESIZE_SHRINK,
+                                              rchan->buf_size, 
+                                              shrink_to_nbufs);
+       }
+}
+
+/**
+ *     init_shrink_timer: - Start timer used to check shrinkability.
+ *     @rchan: the channel
+ */
+void
+init_shrink_timer(struct rchan *rchan)
+{
+       if (rchan->resize_min) {
+               init_timer(&rchan->shrink_timer);
+               rchan->shrink_timer.function = shrink_check;
+               rchan->shrink_timer.data = (unsigned long)rchan;
+               rchan->shrink_timer.expires = jiffies + SHRINK_TIMER_SECS * HZ;
+               add_timer(&rchan->shrink_timer);
+       }
+}
+
+
+/**
+ *     alloc_new_pages - allocate new pages for expanding buffer
+ *     @rchan: the channel
+ *
+ *     Returns 0 on success, negative otherwise.
+ */
+static int
+alloc_new_pages(struct rchan *rchan)
+{
+       int new_pages_size, err;
+
+       if (unlikely(rchan->expand_page_array)) BUG();
+
+       new_pages_size = rchan->resize_alloc_size - rchan->alloc_size;
+       rchan->expand_page_array = alloc_page_array(new_pages_size,
+                                           &rchan->expand_page_count, &err);
+       if (rchan->expand_page_array == NULL) {
+               rchan->resize_err = -ENOMEM;
+               return -ENOMEM;
+       }
+       
+       err = populate_page_array(rchan->expand_page_array,
+                                 rchan->expand_page_count);
+       if (err) {
+               rchan->resize_err = -ENOMEM;
+               free_page_array(rchan->expand_page_array);
+               rchan->expand_page_array = NULL;
+       }
+
+       return err;
+}
+
+/**
+ *     clear_resize_offset - helper function for buffer resizing
+ *     @rchan: the channel
+ *
+ *     Clear the saved offset change.
+ */
+static inline void
+clear_resize_offset(struct rchan *rchan)
+{
+       rchan->resize_offset.ge = 0UL;
+       rchan->resize_offset.le = 0UL;
+       rchan->resize_offset.delta = 0;
+}
+
+/**
+ *     save_resize_offset - helper function for buffer resizing
+ *     @rchan: the channel
+ *     @ge: affected region ge this
+ *     @le: affected region le this
+ *     @delta: apply this delta
+ *
+ *     Save a resize offset.
+ */
+static inline void
+save_resize_offset(struct rchan *rchan, u32 ge, u32 le, int delta)
+{
+       rchan->resize_offset.ge = ge;
+       rchan->resize_offset.le = le;
+       rchan->resize_offset.delta = delta;
+}
+
+/**
+ *     update_file_offset - apply offset change to reader
+ *     @reader: the channel reader
+ *     @change_idx: the offset index into the offsets array
+ *
+ *     Returns non-zero if the offset was applied.
+ *
+ *     Apply the offset delta saved in change_idx to the reader's
+ *     current read position.
+ */
+static inline int
+update_file_offset(struct rchan_reader *reader)
+{
+       int applied = 0;
+       struct rchan *rchan = reader->rchan;
+       u32 f_pos;
+       int delta = reader->rchan->resize_offset.delta;
+
+       if (reader->vfs_reader)
+               f_pos = (u32)reader->pos.file->f_pos;
+       else
+               f_pos = reader->pos.f_pos;
+
+       if (f_pos == relay_get_offset(rchan, NULL))
+               return 0;
+
+       if ((f_pos >= rchan->resize_offset.ge - 1) &&
+           (f_pos <= rchan->resize_offset.le)) {
+               if (reader->vfs_reader)
+                       reader->pos.file->f_pos += delta;
+               else
+                       reader->pos.f_pos += delta;
+               applied = 1;
+       }
+
+       return applied;
+}
+
+/**
+ *     update_file_offsets - apply offset change to readers
+ *     @rchan: the channel
+ *
+ *     Apply the saved offset deltas to all files open on the channel.
+ */
+static inline void
+update_file_offsets(struct rchan *rchan)
+{
+       struct list_head *p;
+       struct rchan_reader *reader;
+       
+       read_lock(&rchan->open_readers_lock);
+       list_for_each(p, &rchan->open_readers) {
+               reader = list_entry(p, struct rchan_reader, list);
+               if (update_file_offset(reader))
+                       reader->offset_changed = 1;
+       }
+       read_unlock(&rchan->open_readers_lock);
+}
+
+/**
+ *     setup_expand_buf - setup expand buffer for replacement
+ *     @rchan: the channel
+ *     @newsize: the size of the new buffer
+ *     @oldsize: the size of the old buffer
+ *     @old_n_bufs: the number of sub-buffers in the old buffer
+ *
+ *     Inserts new pages into the old buffer to create a larger
+ *     new channel buffer, splitting them at old_cur_idx, the bottom
+ *     half of the old buffer going to the bottom of the new, likewise
+ *     for the top half.
+ */
+static void
+setup_expand_buf(struct rchan *rchan, int newsize, int oldsize, u32 old_n_bufs)
+{
+       u32 cur_idx;
+       int cur_bufno, delta, i, j;
+       u32 ge, le;
+       int cur_pageno;
+       u32 free_bufs, free_pages;
+       u32 free_pages_in_cur_buf;
+       u32 free_bufs_to_end;
+       u32 cur_pages = rchan->alloc_size >> PAGE_SHIFT;
+       u32 pages_per_buf = cur_pages / rchan->n_bufs;
+       u32 bufs_ready = rchan->bufs_produced - rchan->bufs_consumed;
+
+       if (!rchan->resize_page_array || !rchan->expand_page_array ||
+           !rchan->buf_page_array)
+               return;
+
+       if (bufs_ready >= rchan->n_bufs) {
+               bufs_ready = rchan->n_bufs;
+               free_bufs = 0;
+       } else
+               free_bufs = rchan->n_bufs - bufs_ready - 1;
+
+       cur_idx = relay_get_offset(rchan, NULL);
+       cur_pageno = cur_idx / PAGE_SIZE;
+       cur_bufno = cur_idx / rchan->buf_size;
+
+       free_pages_in_cur_buf = (pages_per_buf - 1) - (cur_pageno % pages_per_buf);
+       free_pages = free_bufs * pages_per_buf + free_pages_in_cur_buf;
+       free_bufs_to_end = (rchan->n_bufs - 1) - cur_bufno;
+       if (free_bufs >= free_bufs_to_end) {
+               free_pages = free_bufs_to_end * pages_per_buf + free_pages_in_cur_buf;
+               free_bufs = free_bufs_to_end;
+       }
+               
+       for (i = 0, j = 0; i <= cur_pageno + free_pages; i++, j++)
+               rchan->resize_page_array[j] = rchan->buf_page_array[i];
+       for (i = 0; i < rchan->expand_page_count; i++, j++)
+               rchan->resize_page_array[j] = rchan->expand_page_array[i];
+       for (i = cur_pageno + free_pages + 1; i < rchan->buf_page_count; i++, j++)
+               rchan->resize_page_array[j] = rchan->buf_page_array[i];
+
+       delta = newsize - oldsize;
+       ge = (cur_pageno + 1 + free_pages) * PAGE_SIZE;
+       le = oldsize;
+       save_resize_offset(rchan, ge, le, delta);
+
+       rchan->expand_buf_id = rchan->buf_id + 1 + free_bufs;
+}
+
+/**
+ *     setup_shrink_buf - setup shrink buffer for replacement
+ *     @rchan: the channel
+ *
+ *     Removes pages from the old buffer to create a smaller
+ *     new channel buffer.
+ */
+static void
+setup_shrink_buf(struct rchan *rchan)
+{
+       int i;
+       int copy_end_page;
+
+       if (!rchan->resize_page_array || !rchan->shrink_page_array || 
+           !rchan->buf_page_array)
+               return;
+       
+       copy_end_page = rchan->resize_alloc_size / PAGE_SIZE;
+
+       for (i = 0; i < copy_end_page; i++)
+               rchan->resize_page_array[i] = rchan->buf_page_array[i];
+}
+
+/**
+ *     cleanup_failed_alloc - relaybuf_alloc helper
+ */
+static void
+cleanup_failed_alloc(struct rchan *rchan)
+{
+       if (rchan->expand_page_array) {
+               depopulate_page_array(rchan->expand_page_array,
+                                     rchan->expand_page_count);
+               free_page_array(rchan->expand_page_array);
+               rchan->expand_page_array = NULL;
+               rchan->expand_page_count = 0;
+       } else if (rchan->shrink_page_array) {
+               free_page_array(rchan->shrink_page_array);
+               rchan->shrink_page_array = NULL;
+               rchan->shrink_page_count = 0;
+       }
+
+       if (rchan->resize_page_array) {
+               free_page_array(rchan->resize_page_array);
+               rchan->resize_page_array = NULL;
+               rchan->resize_page_count = 0;
+       }
+}
+
+/**
+ *     relaybuf_alloc - allocate a new resized channel buffer
+ *     @private: pointer to the channel struct
+ *
+ *     Internal - manages the allocation and remapping of new channel
+ *     buffers.
+ */
+static void 
+relaybuf_alloc(void *private)
+{
+       struct rchan *rchan = (struct rchan *)private;
+       int i, j, err;
+       u32 old_cur_idx;
+       int free_size;
+       int free_start_page, free_end_page;
+       u32 newsize, oldsize;
+
+       if (rchan->resize_alloc_size > rchan->alloc_size) {
+               err = alloc_new_pages(rchan);
+               if (err) goto cleanup;
+       } else {
+               free_size = rchan->alloc_size - rchan->resize_alloc_size;
+               BUG_ON(free_size <= 0);
+               rchan->shrink_page_array = alloc_page_array(free_size,
+                                           &rchan->shrink_page_count, &err);
+               if (rchan->shrink_page_array == NULL)
+                       goto cleanup;
+               free_start_page = rchan->resize_alloc_size / PAGE_SIZE;
+               free_end_page = rchan->alloc_size / PAGE_SIZE;
+               for (i = 0, j = free_start_page; j < free_end_page; i++, j++)
+                       rchan->shrink_page_array[i] = rchan->buf_page_array[j];
+       }
+
+       rchan->resize_page_array = alloc_page_array(rchan->resize_alloc_size,
+                                           &rchan->resize_page_count, &err);
+       if (rchan->resize_page_array == NULL)
+               goto cleanup;
+
+       old_cur_idx = relay_get_offset(rchan, NULL);
+       clear_resize_offset(rchan);
+       newsize = rchan->resize_alloc_size;
+       oldsize = rchan->alloc_size;
+       if (newsize > oldsize)
+               setup_expand_buf(rchan, newsize, oldsize, rchan->n_bufs);
+       else
+               setup_shrink_buf(rchan);
+
+       rchan->resize_buf = vmap(rchan->resize_page_array, rchan->resize_page_count, GFP_KERNEL, PAGE_KERNEL);
+
+       if (rchan->resize_buf == NULL)
+               goto cleanup;
+
+       rchan->replace_buffer = 1;
+       rchan->resizing = 0;
+
+       rchan->callbacks->needs_resize(rchan->id, RELAY_RESIZE_REPLACE, 0, 0);
+       return;
+
+cleanup:
+       cleanup_failed_alloc(rchan);
+       rchan->resize_err = -ENOMEM;
+       return;
+}
+
+/**
+ *     relaybuf_free - free a resized channel buffer
+ *     @private: pointer to the channel struct
+ *
+ *     Internal - manages the de-allocation and unmapping of old channel
+ *     buffers.
+ */
+static void
+relaybuf_free(void *private)
+{
+       struct free_rchan_buf *free_buf = (struct free_rchan_buf *)private;
+       int i;
+
+       if (free_buf->unmap_buf)
+               vunmap(free_buf->unmap_buf);
+
+       for (i = 0; i < 3; i++) {
+               if (!free_buf->page_array[i].array)
+                       continue;
+               if (free_buf->page_array[i].count)
+                       depopulate_page_array(free_buf->page_array[i].array,
+                                             free_buf->page_array[i].count);
+               free_page_array(free_buf->page_array[i].array);
+       }
+
+       kfree(free_buf);
+}
+
+/**
+ *     calc_order - determine the power-of-2 order of a resize
+ *     @high: the larger size
+ *     @low: the smaller size
+ *
+ *     Returns order
+ */
+static inline int
+calc_order(u32 high, u32 low)
+{
+       int order = 0;
+       
+       if (!high || !low || high <= low)
+               return 0;
+       
+       while (high > low) {
+               order++;
+               high /= 2;
+       }
+       
+       return order;
+}
+
+/**
+ *     check_size - check the sanity of the requested channel size
+ *     @rchan: the channel
+ *     @nbufs: the new number of sub-buffers
+ *     @err: return code
+ *
+ *     Returns the non-zero total buffer size if ok, otherwise 0 and
+ *     sets errcode if not.
+ */
+static inline u32
+check_size(struct rchan *rchan, u32 nbufs, int *err)
+{
+       u32 new_channel_size = 0;
+
+       *err = 0;
+       
+       if (nbufs > rchan->n_bufs) {
+               rchan->resize_order = calc_order(nbufs, rchan->n_bufs);
+               if (!rchan->resize_order) {
+                       *err = -EINVAL;
+                       goto out;
+               }
+
+               new_channel_size = rchan->buf_size * nbufs;
+               if (new_channel_size > rchan->resize_max) {
+                       *err = -EINVAL;
+                       goto out;
+               }
+       } else if (nbufs < rchan->n_bufs) {
+               if (rchan->n_bufs < 2) {
+                       *err = -EINVAL;
+                       goto out;
+               }
+               rchan->resize_order = -calc_order(rchan->n_bufs, nbufs);
+               if (!rchan->resize_order) {
+                       *err = -EINVAL;
+                       goto out;
+               }
+               
+               new_channel_size = rchan->buf_size * nbufs;
+               if (new_channel_size < rchan->resize_min) {
+                       *err = -EINVAL;
+                       goto out;
+               }
+       } else
+               *err = -EINVAL;
+out:
+       return new_channel_size;
+}
+
+/**
+ *     __relay_realloc_buffer - allocate a new channel buffer
+ *     @rchan: the channel
+ *     @new_nbufs: the new number of sub-buffers
+ *     @async: do the allocation using a work queue
+ *
+ *     Internal - see relay_realloc_buffer() for details.
+ */
+static int
+__relay_realloc_buffer(struct rchan *rchan, u32 new_nbufs, int async)
+{
+       u32 new_channel_size;
+       int err = 0;
+       
+       if (new_nbufs == rchan->n_bufs)
+               return -EINVAL;
+               
+       if (down_trylock(&rchan->resize_sem))
+               return -EBUSY;
+
+       if (rchan->init_buf) {
+               err = -EPERM;
+               goto out;
+       }
+
+       if (rchan->replace_buffer) {
+               err = -EBUSY;
+               goto out;
+       }
+
+       if (rchan->resizing) {
+               err = -EBUSY;
+               goto out;
+       } else
+               rchan->resizing = 1;
+
+       if (rchan->resize_failures > MAX_RESIZE_FAILURES) {
+               err = -ENOMEM;
+               goto out;
+       }
+
+       new_channel_size = check_size(rchan, new_nbufs, &err);
+       if (err)
+               goto out;
+       
+       rchan->resize_n_bufs = new_nbufs;
+       rchan->resize_buf_size = rchan->buf_size;
+       rchan->resize_alloc_size = FIX_SIZE(new_channel_size);
+       
+       if (async) {
+               INIT_WORK(&rchan->work, relaybuf_alloc, rchan);
+               schedule_delayed_work(&rchan->work, 1);
+       } else
+               relaybuf_alloc((void *)rchan);
+out:
+       up(&rchan->resize_sem);
+       
+       return err;
+}
+
+/**
+ *     relay_realloc_buffer - allocate a new channel buffer
+ *     @rchan_id: the channel id
+ *     @bufsize: the new sub-buffer size
+ *     @nbufs: the new number of sub-buffers
+ *
+ *     Allocates a new channel buffer using the specified sub-buffer size
+ *     and count.  If async is non-zero, the allocation is done in the
+ *     background using a work queue.  When the allocation has completed,
+ *     the needs_resize() callback is called with a resize_type of
+ *     RELAY_RESIZE_REPLACE.  This function doesn't replace the old buffer
+ *     with the new - see relay_replace_buffer().  See
+ *     Documentation/filesystems/relayfs.txt for more details.
+ *
+ *     Returns 0 on success, or errcode if the channel is busy or if
+ *     the allocation couldn't happen for some reason.
+ */
+int
+relay_realloc_buffer(int rchan_id, u32 new_nbufs, int async)
+{
+       int err;
+       
+       struct rchan *rchan;
+
+       rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return -EBADF;
+
+       err = __relay_realloc_buffer(rchan, new_nbufs, async);
+       
+       rchan_put(rchan);
+
+       return err;
+}
+
+/**
+ *     expand_cancel_check - check whether the current expand needs canceling
+ *     @rchan: the channel
+ *
+ *     Returns 1 if the expand should be canceled, 0 otherwise.
+ */
+static int
+expand_cancel_check(struct rchan *rchan)
+{
+       if (rchan->buf_id >= rchan->expand_buf_id)
+               return 1;
+       else
+               return 0;
+}
+
+/**
+ *     shrink_cancel_check - check whether the current shrink needs canceling
+ *     @rchan: the channel
+ *
+ *     Returns 1 if the shrink should be canceled, 0 otherwise.
+ */
+static int
+shrink_cancel_check(struct rchan *rchan, u32 newsize)
+{
+       u32 active_bufs = rchan->bufs_produced - rchan->bufs_consumed + 1;
+       u32 cur_idx = relay_get_offset(rchan, NULL);
+
+       if (cur_idx >= newsize)
+               return 1;
+
+       if (active_bufs > 1)
+               return 1;
+
+       return 0;
+}
+
+/**
+ *     switch_rchan_buf - do_replace_buffer helper
+ */
+static void
+switch_rchan_buf(struct rchan *rchan,
+                int newsize,
+                int oldsize,
+                u32 old_nbufs,
+                u32 cur_idx)
+{
+       u32 newbufs, cur_bufno;
+       int i;
+
+       cur_bufno = cur_idx / rchan->buf_size;
+
+       rchan->buf = rchan->resize_buf;
+       rchan->alloc_size = rchan->resize_alloc_size;
+       rchan->n_bufs = rchan->resize_n_bufs;
+
+       if (newsize > oldsize) {
+               u32 ge = rchan->resize_offset.ge;
+               u32 moved_buf = ge / rchan->buf_size;
+
+               newbufs = (newsize - oldsize) / rchan->buf_size;
+               for (i = moved_buf; i < old_nbufs; i++) {
+                       if (using_lockless(rchan))
+                               atomic_set(&fill_count(rchan, i + newbufs), 
+                                          atomic_read(&fill_count(rchan, i)));
+                       rchan->unused_bytes[i + newbufs] = rchan->unused_bytes[i];
+               }
+               for (i = moved_buf; i < moved_buf + newbufs; i++) {
+                       if (using_lockless(rchan))
+                               atomic_set(&fill_count(rchan, i),
+                                          (int)RELAY_BUF_SIZE(offset_bits(rchan)));
+                       rchan->unused_bytes[i] = 0;
+               }
+       }
+
+       rchan->buf_idx = cur_bufno;
+
+       if (!using_lockless(rchan)) {
+               cur_write_pos(rchan) = rchan->buf + cur_idx;
+               write_buf(rchan) = rchan->buf + cur_bufno * rchan->buf_size;
+               write_buf_end(rchan) = write_buf(rchan) + rchan->buf_size;
+               write_limit(rchan) = write_buf_end(rchan) - rchan->end_reserve;
+       } else {
+               idx(rchan) &= idx_mask(rchan);
+               bufno_bits(rchan) += rchan->resize_order;
+               idx_mask(rchan) =
+                       (1UL << (bufno_bits(rchan) + offset_bits(rchan))) - 1;
+       }
+}
+
+/**
+ *     do_replace_buffer - does the work of channel buffer replacement
+ *     @rchan: the channel
+ *     @newsize: new channel buffer size
+ *     @oldsize: old channel buffer size
+ *     @old_n_bufs: old channel sub-buffer count
+ *
+ *     Returns 0 if replacement happened, 1 if canceled
+ *
+ *     Does the work of switching buffers and fixing everything up
+ *     so the channel can continue with a new size.
+ */
+static int
+do_replace_buffer(struct rchan *rchan,
+                 int newsize,
+                 int oldsize,
+                 u32 old_nbufs)
+{
+       u32 cur_idx;
+       int err = 0;
+       int canceled;
+
+       cur_idx = relay_get_offset(rchan, NULL);
+
+       if (newsize > oldsize)
+               canceled = expand_cancel_check(rchan);
+       else
+               canceled = shrink_cancel_check(rchan, newsize);
+
+       if (canceled) {
+               err = -EAGAIN;
+               goto out;
+       }
+
+       switch_rchan_buf(rchan, newsize, oldsize, old_nbufs, cur_idx);
+
+       if (rchan->resize_offset.delta)
+               update_file_offsets(rchan);
+
+       atomic_set(&rchan->suspended, 0);
+
+       rchan->old_buf_page_array = rchan->buf_page_array;
+       rchan->buf_page_array = rchan->resize_page_array;
+       rchan->buf_page_count = rchan->resize_page_count;
+       rchan->resize_page_array = NULL;
+       rchan->resize_page_count = 0;
+       rchan->resize_buf = NULL;
+       rchan->resize_buf_size = 0;
+       rchan->resize_alloc_size = 0;
+       rchan->resize_n_bufs = 0;
+       rchan->resize_err = 0;
+       rchan->resize_order = 0;
+out:
+       rchan->callbacks->needs_resize(rchan->id,
+                                      RELAY_RESIZE_REPLACED,
+                                      rchan->buf_size,
+                                      rchan->n_bufs);
+       return err;
+}
+
+/**
+ *     add_free_page_array - add a page_array to be freed
+ *     @free_rchan_buf: the free_rchan_buf struct
+ *     @page_array: the page array to free
+ *     @page_count: the number of pages to free, 0 to free the array only
+ *
+ *     Internal - Used add page_arrays to be freed asynchronously.
+ */
+static inline void
+add_free_page_array(struct free_rchan_buf *free_rchan_buf,
+                   struct page **page_array, int page_count)
+{
+       int cur = free_rchan_buf->cur++;
+       
+       free_rchan_buf->page_array[cur].array = page_array;
+       free_rchan_buf->page_array[cur].count = page_count;
+}
+
+/**
+ *     free_replaced_buffer - free a channel's old buffer
+ *     @rchan: the channel
+ *     @oldbuf: the old buffer
+ *     @oldsize: old buffer size
+ *
+ *     Frees a channel buffer via work queue.
+ */
+static int
+free_replaced_buffer(struct rchan *rchan, char *oldbuf, int oldsize)
+{
+       struct free_rchan_buf *free_buf;
+
+       free_buf = kmalloc(sizeof(struct free_rchan_buf), GFP_ATOMIC);
+       if (!free_buf)
+               return -ENOMEM;
+       memset(free_buf, 0, sizeof(struct free_rchan_buf));
+
+       free_buf->unmap_buf = oldbuf;
+       add_free_page_array(free_buf, rchan->old_buf_page_array, 0);
+       rchan->old_buf_page_array = NULL;
+       add_free_page_array(free_buf, rchan->expand_page_array, 0);
+       add_free_page_array(free_buf, rchan->shrink_page_array, rchan->shrink_page_count);
+
+       rchan->expand_page_array = NULL;
+       rchan->expand_page_count = 0;
+       rchan->shrink_page_array = NULL;
+       rchan->shrink_page_count = 0;
+
+       INIT_WORK(&free_buf->work, relaybuf_free, free_buf);
+       schedule_delayed_work(&free_buf->work, 1);
+
+       return 0;
+}
+
+/**
+ *     free_canceled_resize - free buffers allocated for a canceled resize
+ *     @rchan: the channel
+ *
+ *     Frees canceled buffers via work queue.
+ */
+static int
+free_canceled_resize(struct rchan *rchan)
+{
+       struct free_rchan_buf *free_buf;
+
+       free_buf = kmalloc(sizeof(struct free_rchan_buf), GFP_ATOMIC);
+       if (!free_buf)
+               return -ENOMEM;
+       memset(free_buf, 0, sizeof(struct free_rchan_buf));
+
+       if (rchan->resize_alloc_size > rchan->alloc_size)
+               add_free_page_array(free_buf, rchan->expand_page_array, rchan->expand_page_count);
+       else
+               add_free_page_array(free_buf, rchan->shrink_page_array, 0);
+       
+       add_free_page_array(free_buf, rchan->resize_page_array, 0);
+       free_buf->unmap_buf = rchan->resize_buf;
+
+       rchan->expand_page_array = NULL;
+       rchan->expand_page_count = 0;
+       rchan->shrink_page_array = NULL;
+       rchan->shrink_page_count = 0;
+       rchan->resize_page_array = NULL;
+       rchan->resize_page_count = 0;
+       rchan->resize_buf = NULL;
+
+       INIT_WORK(&free_buf->work, relaybuf_free, free_buf);
+       schedule_delayed_work(&free_buf->work, 1);
+
+       return 0;
+}
+
+/**
+ *     __relay_replace_buffer - replace channel buffer with new buffer
+ *     @rchan: the channel
+ *
+ *     Internal - see relay_replace_buffer() for details.
+ *
+ *     Returns 0 if successful, negative otherwise.
+ */
+static int
+__relay_replace_buffer(struct rchan *rchan)
+{
+       int oldsize;
+       int err = 0;
+       char *oldbuf;
+       
+       if (down_trylock(&rchan->resize_sem))
+               return -EBUSY;
+
+       if (rchan->init_buf) {
+               err = -EPERM;
+               goto out;
+       }
+
+       if (!rchan->replace_buffer)
+               goto out;
+
+       if (rchan->resizing) {
+               err = -EBUSY;
+               goto out;
+       }
+
+       if (rchan->resize_buf == NULL) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       oldbuf = rchan->buf;
+       oldsize = rchan->alloc_size;
+
+       err = do_replace_buffer(rchan, rchan->resize_alloc_size,
+                               oldsize, rchan->n_bufs);
+       if (err == 0)
+               err = free_replaced_buffer(rchan, oldbuf, oldsize);
+       else
+               err = free_canceled_resize(rchan);
+out:
+       rchan->replace_buffer = 0;
+       up(&rchan->resize_sem);
+       
+       return err;
+}
+
+/**
+ *     relay_replace_buffer - replace channel buffer with new buffer
+ *     @rchan_id: the channel id
+ *
+ *     Replaces the current channel buffer with the new buffer allocated
+ *     by relay_alloc_buffer and contained in the channel struct.  When the
+ *     replacement is complete, the needs_resize() callback is called with
+ *     RELAY_RESIZE_REPLACED.
+ *
+ *     Returns 0 on success, or errcode if the channel is busy or if
+ *     the replacement or previous allocation didn't happen for some reason.
+ */
+int
+relay_replace_buffer(int rchan_id)
+{
+       int err;
+       
+       struct rchan *rchan;
+
+       rchan = rchan_get(rchan_id);
+       if (rchan == NULL)
+               return -EBADF;
+
+       err = __relay_replace_buffer(rchan);
+       
+       rchan_put(rchan);
+
+       return err;
+}
+
+EXPORT_SYMBOL(relay_realloc_buffer);
+EXPORT_SYMBOL(relay_replace_buffer);
+
diff --git a/fs/relayfs/resize.h b/fs/relayfs/resize.h
new file mode 100644 (file)
index 0000000..6f06d22
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef _RELAY_RESIZE_H
+#define _RELAY_RESIZE_H
+
+/* 
+ * If the channel usage has been below the low water mark for more than
+ * this amount of time, we can shrink the buffer if necessary.
+ */
+#define SHRINK_TIMER_SECS      60
+
+/* This inspired by rtai/shmem */
+#define FIX_SIZE(x) (((x) - 1) & PAGE_MASK) + PAGE_SIZE
+
+/* Don't attempt resizing again after this many failures */
+#define MAX_RESIZE_FAILURES    1
+
+/* Trigger resizing if a resizable channel is this full */
+#define RESIZE_THRESHOLD       3 / 4
+
+/*
+ * Used for deferring resized channel free
+ */
+struct free_rchan_buf
+{
+       char *unmap_buf;
+       struct 
+       {
+               struct page **array;
+               int count;
+       } page_array[3];
+       
+       int cur;
+       struct work_struct work;        /* resize de-allocation work struct */
+};
+
+extern void *
+alloc_rchan_buf(unsigned long size,
+               struct page ***page_array,
+               int *page_count);
+
+extern void
+free_rchan_buf(void *buf,
+              struct page **page_array,
+              int page_count);
+
+extern void
+expand_check(struct rchan *rchan);
+
+extern void
+init_shrink_timer(struct rchan *rchan);
+
+#endif/* _RELAY_RESIZE_H */
index 16fc1ef..39029ce 100644 (file)
@@ -243,6 +243,7 @@ int do_select(int n, fd_set_bits *fds, long *timeout)
                                                retval++;
                                        }
                                }
+                               cond_resched();
                        }
                        if (res_in)
                                *rinp = res_in;
index 6bda9bf..6e94fc8 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
        stat->nlink = inode->i_nlink;
        stat->uid = inode->i_uid;
        stat->gid = inode->i_gid;
+       stat->xid = inode->i_xid;
        stat->rdev = inode->i_rdev;
        stat->atime = inode->i_atime;
        stat->mtime = inode->i_mtime;
index 38c23bf..37b76d7 100644 (file)
@@ -35,6 +35,8 @@
 #include <linux/vfs.h>
 #include <linux/writeback.h>           /* for the emergency remount stuff */
 #include <linux/idr.h>
+#include <linux/devpts_fs.h>
+#include <linux/proc_fs.h>
 #include <asm/uaccess.h>
 
 
@@ -786,6 +788,13 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data)
        sb = type->get_sb(type, flags, name, data);
        if (IS_ERR(sb))
                goto out_free_secdata;
+
+       error = -EPERM;
+       if (!capable(CAP_SYS_ADMIN) && !sb->s_bdev &&
+               (sb->s_magic != PROC_SUPER_MAGIC) &&
+               (sb->s_magic != DEVPTS_SUPER_MAGIC))
+               goto out_sb;
+
        error = security_sb_kern_mount(sb, secdata);
        if (error)
                goto out_sb;
index c3e5dbe..823813c 100644 (file)
@@ -11,8 +11,6 @@
 
 #include "sysfs.h"
 
-/* Random magic number */
-#define SYSFS_MAGIC 0x62656572
 
 struct vfsmount *sysfs_mount;
 struct super_block * sysfs_sb = NULL;
@@ -29,7 +27,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
 
        sb->s_blocksize = PAGE_CACHE_SIZE;
        sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
-       sb->s_magic = SYSFS_MAGIC;
+       sb->s_magic = SYSFS_SUPER_MAGIC;
        sb->s_op = &sysfs_ops;
        sysfs_sb = sb;
 
index c8bfec6..3169fe5 100644 (file)
@@ -5,12 +5,14 @@
 #include <linux/fs.h>
 #include <linux/module.h>
 #include <linux/kobject.h>
+#include <linux/namei.h>
 
 #include "sysfs.h"
 
 static struct inode_operations sysfs_symlink_inode_operations = {
-       .readlink = sysfs_readlink,
+       .readlink = generic_readlink,
        .follow_link = sysfs_follow_link,
+       .put_link = sysfs_put_link,
 };
 
 static int init_symlink(struct inode * inode)
@@ -140,38 +142,21 @@ static int sysfs_getlink(struct dentry *dentry, char * path)
 
 }
 
-int sysfs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
+int sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-       int error = 0;
+       int error = -ENOMEM;
        unsigned long page = get_zeroed_page(GFP_KERNEL);
-
-       if (!page)
-               return -ENOMEM;
-
-       error = sysfs_getlink(dentry, (char *) page);
-       if (!error)
-               error = vfs_readlink(dentry, buffer, buflen, (char *) page);
-
-       free_page(page);
-
-       return error;
+       if (page)
+               error = sysfs_getlink(dentry, (char *) page); 
+       nd_set_link(nd, error ? ERR_PTR(error) : (char *)page);
+       return 0;
 }
 
-int sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
+void sysfs_put_link(struct dentry *dentry, struct nameidata *nd)
 {
-       int error = 0;
-       unsigned long page = get_zeroed_page(GFP_KERNEL);
-
-       if (!page)
-               return -ENOMEM;
-
-       error = sysfs_getlink(dentry, (char *) page); 
-       if (!error)
-               error = vfs_follow_link(nd, (char *) page);
-
-       free_page(page);
-
-       return error;
+       char *page = nd_get_link(nd);
+       if (!IS_ERR(page))
+               free_page((unsigned long)page);
 }
 
 EXPORT_SYMBOL(sysfs_create_link);
index ff5d147..4a8c215 100644 (file)
@@ -12,8 +12,8 @@ extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
 extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
 extern void sysfs_remove_subdir(struct dentry *);
 
-extern int sysfs_readlink(struct dentry *, char __user *, int );
 extern int sysfs_follow_link(struct dentry *, struct nameidata *);
+extern void sysfs_put_link(struct dentry *, struct nameidata *);
 extern struct rw_semaphore sysfs_rename_sem;
 
 static inline struct kobject *sysfs_get_kobject(struct dentry *dentry)
index e348ef8..5c5a9a7 100644 (file)
@@ -1017,6 +1017,8 @@ xfs_ioc_fsgeometry(
 #define LINUX_XFLAG_APPEND     0x00000020 /* writes to file may only append */
 #define LINUX_XFLAG_NODUMP     0x00000040 /* do not dump file */
 #define LINUX_XFLAG_NOATIME    0x00000080 /* do not update atime */
+#define LINUX_XFLAG_BARRIER    0x00004000 /* chroot() barrier */
+#define LINUX_XFLAG_IUNLINK    0x00008000 /* Immutable unlink */
 
 STATIC unsigned int
 xfs_merge_ioc_xflags(
@@ -1057,6 +1059,8 @@ xfs_di2lxflags(
 
        if (di_flags & XFS_DIFLAG_IMMUTABLE)
                flags |= LINUX_XFLAG_IMMUTABLE;
+       if (di_flags & XFS_DIFLAG_IUNLINK)
+               flags |= LINUX_XFLAG_IUNLINK;
        if (di_flags & XFS_DIFLAG_APPEND)
                flags |= LINUX_XFLAG_APPEND;
        if (di_flags & XFS_DIFLAG_SYNC)
@@ -1081,6 +1085,7 @@ xfs_ioc_xattr(
        int                     error;
        int                     attr_flags;
        unsigned int            flags;
+       unsigned int            old_flags;
 
        switch (cmd) {
        case XFS_IOC_FSGETXATTR: {
@@ -1105,7 +1110,7 @@ xfs_ioc_xattr(
                attr_flags = 0;
                if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
                        attr_flags |= ATTR_NONBLOCK;
-
+               
                va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE;
                va.va_xflags  = fa.fsx_xflags;
                va.va_extsize = fa.fsx_extsize;
index a76f596..962cf8d 100644 (file)
@@ -498,6 +498,28 @@ linvfs_getattr(
        return 0;
 }
 
+STATIC int
+linvfs_setattr_flags(
+       vattr_t *vap,
+       unsigned int flags)
+{
+       unsigned int oldflags, newflags;
+
+       oldflags = vap->va_xflags;
+       newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
+               XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
+       if (flags & ATTR_FLAG_IMMUTABLE)
+               newflags |= XFS_XFLAG_IMMUTABLE;
+       if (flags & ATTR_FLAG_IUNLINK)
+               newflags |= XFS_XFLAG_IUNLINK;
+       if (flags & ATTR_FLAG_BARRIER)
+               newflags |= XFS_XFLAG_BARRIER;
+
+       if (oldflags ^ newflags)
+               vap->va_xflags = newflags;
+       return 0;
+}
+
 STATIC int
 linvfs_setattr(
        struct dentry   *dentry,
@@ -549,6 +571,11 @@ linvfs_setattr(
                flags |= ATTR_NONBLOCK;
 #endif
 
+       if (ia_valid & ATTR_ATTR_FLAG) {
+               vattr.va_mask |= XFS_AT_XFLAGS;
+               linvfs_setattr_flags(&vattr, attr->ia_attr_flags);
+       }
+
        VOP_SETATTR(vp, &vattr, flags, NULL, error);
        if (error)
                return -error;
index 00818cd..3a2e961 100644 (file)
@@ -191,6 +191,14 @@ xfs_revalidate_inode(
                inode->i_flags |= S_IMMUTABLE;
        else
                inode->i_flags &= ~S_IMMUTABLE;
+       if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
+               inode->i_flags |= S_IUNLINK;
+       else
+               inode->i_flags &= ~S_IUNLINK;
+       if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
+               inode->i_flags |= S_BARRIER;
+       else
+               inode->i_flags &= ~S_BARRIER;
        if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
                inode->i_flags |= S_APPEND;
        else
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
deleted file mode 100644 (file)
index 4a173d3..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_rw.h"
-#include <linux/sysctl.h>
-#include <linux/proc_fs.h>
-
-
-static struct ctl_table_header *xfs_table_header;
-
-
-#ifdef CONFIG_PROC_FS
-STATIC int
-xfs_stats_clear_proc_handler(
-       ctl_table       *ctl,
-       int             write,
-       struct file     *filp,
-       void            *buffer,
-       size_t          *lenp,
-       loff_t          *ppos)
-{
-       int             c, ret, *valp = ctl->data;
-       __uint32_t      vn_active;
-
-       ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp, ppos);
-
-       if (!ret && write && *valp) {
-               printk("XFS Clearing xfsstats\n");
-               for (c = 0; c < NR_CPUS; c++) {
-                       if (!cpu_possible(c)) continue;
-                       preempt_disable();
-                       /* save vn_active, it's a universal truth! */
-                       vn_active = per_cpu(xfsstats, c).vn_active;
-                       memset(&per_cpu(xfsstats, c), 0,
-                              sizeof(struct xfsstats));
-                       per_cpu(xfsstats, c).vn_active = vn_active;
-                       preempt_enable();
-               }
-               xfs_stats_clear = 0;
-       }
-
-       return ret;
-}
-#endif /* CONFIG_PROC_FS */
-
-STATIC ctl_table xfs_table[] = {
-       {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
-
-       {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
-
-       {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
-
-       {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
-
-       {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.error_level.min, &xfs_params.error_level.max},
-
-       {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max},
-
-       {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
-
-       {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
-
-       {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
-       
-       {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.xfs_buf_timer.min, &xfs_params.xfs_buf_timer.max},
-
-       {XFS_BUF_AGE, "age_buffer_centisecs", &xfs_params.xfs_buf_age.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.xfs_buf_age.min, &xfs_params.xfs_buf_age.max},
-
-       /* please keep this the last entry */
-#ifdef CONFIG_PROC_FS
-       {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
-       sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
-       &sysctl_intvec, NULL, 
-       &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
-#endif /* CONFIG_PROC_FS */
-
-       {0}
-};
-
-STATIC ctl_table xfs_dir_table[] = {
-       {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
-       {0}
-};
-
-STATIC ctl_table xfs_root_table[] = {
-       {CTL_FS, "fs",  NULL, 0, 0555, xfs_dir_table},
-       {0}
-};
-
-void
-xfs_sysctl_register(void)
-{
-       xfs_table_header = register_sysctl_table(xfs_root_table, 1);
-}
-
-void
-xfs_sysctl_unregister(void)
-{
-       if (xfs_table_header)
-               unregister_sysctl_table(xfs_table_header);
-}
index 9240efb..44ba5e5 100644 (file)
@@ -217,6 +217,14 @@ vn_revalidate(
                        inode->i_flags |= S_IMMUTABLE;
                else
                        inode->i_flags &= ~S_IMMUTABLE;
+               if (va.va_xflags & XFS_XFLAG_IUNLINK)
+                       inode->i_flags |= S_IUNLINK;
+               else
+                       inode->i_flags &= ~S_IUNLINK;
+               if (va.va_xflags & XFS_XFLAG_BARRIER)
+                       inode->i_flags |= S_BARRIER;
+               else
+                       inode->i_flags &= ~S_BARRIER;
                if (va.va_xflags & XFS_XFLAG_APPEND)
                        inode->i_flags |= S_APPEND;
                else
diff --git a/fs/xfs/linux/kmem.h b/fs/xfs/linux/kmem.h
deleted file mode 100644 (file)
index c9df164..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_KMEM_H__
-#define __XFS_SUPPORT_KMEM_H__
-
-#include <linux/mm.h>
-#include <linux/highmem.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-
-/*
- * Cutoff point to use vmalloc instead of kmalloc.
- */
-#define MAX_SLAB_SIZE  0x10000
-
-/*
- * XFS uses slightly different names for these due to the
- * IRIX heritage.
- */
-#define        kmem_zone       kmem_cache_s
-#define kmem_zone_t    kmem_cache_t
-
-#define KM_SLEEP       0x0001
-#define KM_NOSLEEP     0x0002
-#define KM_NOFS                0x0004
-
-typedef unsigned long xfs_pflags_t;
-
-#define PFLAGS_TEST_FSTRANS()           (current->flags & PF_FSTRANS)
-
-/* these could be nested, so we save state */
-#define PFLAGS_SET_FSTRANS(STATEP) do {        \
-       *(STATEP) = current->flags;     \
-       current->flags |= PF_FSTRANS;   \
-} while (0)
-
-#define PFLAGS_CLEAR_FSTRANS(STATEP) do { \
-       *(STATEP) = current->flags;     \
-       current->flags &= ~PF_FSTRANS;  \
-} while (0)
-
-/* Restore the PF_FSTRANS state to what was saved in STATEP */
-#define PFLAGS_RESTORE_FSTRANS(STATEP) do {                    \
-       current->flags = ((current->flags & ~PF_FSTRANS) |      \
-                         (*(STATEP) & PF_FSTRANS));            \
-} while (0)
-
-#define PFLAGS_DUP(OSTATEP, NSTATEP) do { \
-       *(NSTATEP) = *(OSTATEP);        \
-} while (0)
-
-/*
- * XXX get rid of the unconditional  __GFP_NOFAIL by adding
- * a KM_FAIL flag and using it where we're allowed to fail.
- */
-static __inline unsigned int
-kmem_flags_convert(int flags)
-{
-       int lflags;
-
-#if DEBUG
-       if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS))) {
-               printk(KERN_WARNING
-                   "XFS: memory allocation with wrong flags (%x)\n", flags);
-               BUG();
-       }
-#endif
-
-       lflags = (flags & KM_NOSLEEP) ? GFP_ATOMIC : (GFP_KERNEL|__GFP_NOFAIL);
-
-       /* avoid recusive callbacks to filesystem during transactions */
-       if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
-               lflags &= ~__GFP_FS;
-
-       return lflags;
-}
-
-static __inline void *
-kmem_alloc(size_t size, int flags)
-{
-       if (unlikely(MAX_SLAB_SIZE < size))
-               /* Avoid doing filesystem sensitive stuff to get this */
-               return __vmalloc(size, kmem_flags_convert(flags), PAGE_KERNEL);
-       return kmalloc(size, kmem_flags_convert(flags));
-}
-
-static __inline void *
-kmem_zalloc(size_t size, int flags)
-{
-       void *ptr = kmem_alloc(size, flags);
-       if (likely(ptr != NULL))
-               memset(ptr, 0, size);
-       return ptr;
-}
-
-static __inline void
-kmem_free(void *ptr, size_t size)
-{
-       if (unlikely((unsigned long)ptr < VMALLOC_START ||
-                    (unsigned long)ptr >= VMALLOC_END))
-               kfree(ptr);
-       else
-               vfree(ptr);
-}
-
-static __inline void *
-kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags)
-{
-       void *new = kmem_alloc(newsize, flags);
-
-       if (likely(ptr != NULL)) {
-               if (likely(new != NULL))
-                       memcpy(new, ptr, min(oldsize, newsize));
-               kmem_free(ptr, oldsize);
-       }
-
-       return new;
-}
-
-static __inline kmem_zone_t *
-kmem_zone_init(int size, char *zone_name)
-{
-       return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL);
-}
-
-static __inline void *
-kmem_zone_alloc(kmem_zone_t *zone, int flags)
-{
-       return kmem_cache_alloc(zone, kmem_flags_convert(flags));
-}
-
-static __inline void *
-kmem_zone_zalloc(kmem_zone_t *zone, int flags)
-{
-       void *ptr = kmem_zone_alloc(zone, flags);
-       if (likely(ptr != NULL))
-               memset(ptr, 0, kmem_cache_size(zone));
-       return ptr;
-}
-
-static __inline void
-kmem_zone_free(kmem_zone_t *zone, void *ptr)
-{
-       kmem_cache_free(zone, ptr);
-}
-
-typedef struct shrinker *kmem_shaker_t;
-typedef int (*kmem_shake_func_t)(int, unsigned int);
-
-static __inline kmem_shaker_t
-kmem_shake_register(kmem_shake_func_t sfunc)
-{
-       return set_shrinker(DEFAULT_SEEKS, sfunc);
-}
-
-static __inline void
-kmem_shake_deregister(kmem_shaker_t shrinker)
-{
-       remove_shrinker(shrinker);
-}
-
-static __inline int
-kmem_shake_allow(unsigned int gfp_mask)
-{
-       return (gfp_mask & __GFP_WAIT);
-}
-
-#endif /* __XFS_SUPPORT_KMEM_H__ */
diff --git a/fs/xfs/linux/mrlock.h b/fs/xfs/linux/mrlock.h
deleted file mode 100644 (file)
index d2c11a0..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_MRLOCK_H__
-#define __XFS_SUPPORT_MRLOCK_H__
-
-#include <linux/rwsem.h>
-
-enum { MR_NONE, MR_ACCESS, MR_UPDATE };
-
-typedef struct {
-       struct rw_semaphore     mr_lock;
-       int                     mr_writer;
-} mrlock_t;
-
-#define mrinit(mrp, name)      \
-       ( (mrp)->mr_writer = 0, init_rwsem(&(mrp)->mr_lock) )
-#define mrlock_init(mrp, t,n,s)        mrinit(mrp, n)
-#define mrfree(mrp)            do { } while (0)
-#define mraccess(mrp)          mraccessf(mrp, 0)
-#define mrupdate(mrp)          mrupdatef(mrp, 0)
-
-static inline void mraccessf(mrlock_t *mrp, int flags)
-{
-       down_read(&mrp->mr_lock);
-}
-
-static inline void mrupdatef(mrlock_t *mrp, int flags)
-{
-       down_write(&mrp->mr_lock);
-       mrp->mr_writer = 1;
-}
-
-static inline int mrtryaccess(mrlock_t *mrp)
-{
-       return down_read_trylock(&mrp->mr_lock);
-}
-
-static inline int mrtryupdate(mrlock_t *mrp)
-{
-       if (!down_write_trylock(&mrp->mr_lock))
-               return 0;
-       mrp->mr_writer = 1;
-       return 1;
-}
-
-static inline void mrunlock(mrlock_t *mrp)
-{
-       if (mrp->mr_writer) {
-               mrp->mr_writer = 0;
-               up_write(&mrp->mr_lock);
-       } else {
-               up_read(&mrp->mr_lock);
-       }
-}
-
-static inline void mrdemote(mrlock_t *mrp)
-{
-       mrp->mr_writer = 0;
-       downgrade_write(&mrp->mr_lock);
-}
-
-#ifdef DEBUG
-/*
- * Debug-only routine, without some platform-specific asm code, we can
- * now only answer requests regarding whether we hold the lock for write
- * (reader state is outside our visibility, we only track writer state).
- * Note: means !ismrlocked would give false positivies, so don't do that.
- */
-static inline int ismrlocked(mrlock_t *mrp, int type)
-{
-       if (mrp && type == MR_UPDATE)
-               return mrp->mr_writer;
-       return 1;
-}
-#endif
-
-#endif /* __XFS_SUPPORT_MRLOCK_H__ */
diff --git a/fs/xfs/linux/mutex.h b/fs/xfs/linux/mutex.h
deleted file mode 100644 (file)
index 0b296bb..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_MUTEX_H__
-#define __XFS_SUPPORT_MUTEX_H__
-
-#include <linux/spinlock.h>
-#include <asm/semaphore.h>
-
-/*
- * Map the mutex'es from IRIX to Linux semaphores.
- *
- * Destroy just simply initializes to -99 which should block all other
- * callers.
- */
-#define MUTEX_DEFAULT          0x0
-typedef struct semaphore       mutex_t;
-
-#define mutex_init(lock, type, name)           sema_init(lock, 1)
-#define mutex_destroy(lock)                    sema_init(lock, -99)
-#define mutex_lock(lock, num)                  down(lock)
-#define mutex_trylock(lock)                    (down_trylock(lock) ? 0 : 1)
-#define mutex_unlock(lock)                     up(lock)
-
-#endif /* __XFS_SUPPORT_MUTEX_H__ */
diff --git a/fs/xfs/linux/sema.h b/fs/xfs/linux/sema.h
deleted file mode 100644 (file)
index 30b67b4..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_SEMA_H__
-#define __XFS_SUPPORT_SEMA_H__
-
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <asm/atomic.h>
-#include <asm/semaphore.h>
-
-/*
- * sema_t structure just maps to struct semaphore in Linux kernel.
- */
-
-typedef struct semaphore sema_t;
-
-#define init_sema(sp, val, c, d)       sema_init(sp, val)
-#define initsema(sp, val)              sema_init(sp, val)
-#define initnsema(sp, val, name)       sema_init(sp, val)
-#define psema(sp, b)                   down(sp)
-#define vsema(sp)                      up(sp)
-#define valusema(sp)                   (atomic_read(&(sp)->count))
-#define freesema(sema)
-
-/*
- * Map cpsema (try to get the sema) to down_trylock. We need to switch
- * the return values since cpsema returns 1 (acquired) 0 (failed) and
- * down_trylock returns the reverse 0 (acquired) 1 (failed).
- */
-
-#define cpsema(sp)                     (down_trylock(sp) ? 0 : 1)
-
-/*
- * Didn't do cvsema(sp). Not sure how to map this to up/down/...
- * It does a vsema if the values is < 0 other wise nothing.
- */
-
-#endif /* __XFS_SUPPORT_SEMA_H__ */
diff --git a/fs/xfs/linux/spin.h b/fs/xfs/linux/spin.h
deleted file mode 100644 (file)
index 80a3a6b..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_SPIN_H__
-#define __XFS_SUPPORT_SPIN_H__
-
-#include <linux/sched.h>       /* preempt needs this */
-#include <linux/spinlock.h>
-
-/*
- * Map lock_t from IRIX to Linux spinlocks.
- *
- * Note that linux turns on/off spinlocks depending on CONFIG_SMP.
- * We don't need to worry about SMP or not here.
- */
-
-#define SPLDECL(s)             unsigned long s
-
-typedef spinlock_t lock_t;
-
-#define spinlock_init(lock, name)      spin_lock_init(lock)
-#define        spinlock_destroy(lock)
-
-static inline unsigned long mutex_spinlock(lock_t *lock)
-{
-       spin_lock(lock);
-       return 0;
-}
-
-/*ARGSUSED*/
-static inline void mutex_spinunlock(lock_t *lock, unsigned long s)
-{
-       spin_unlock(lock);
-}
-
-static inline void nested_spinlock(lock_t *lock)
-{
-       spin_lock(lock);
-}
-
-static inline void nested_spinunlock(lock_t *lock)
-{
-       spin_unlock(lock);
-}
-
-#endif /* __XFS_SUPPORT_SPIN_H__ */
diff --git a/fs/xfs/linux/sv.h b/fs/xfs/linux/sv.h
deleted file mode 100644 (file)
index 821d316..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_SV_H__
-#define __XFS_SUPPORT_SV_H__
-
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-
-/*
- * Synchronisation variables.
- *
- * (Parameters "pri", "svf" and "rts" are not implemented)
- */
-
-typedef struct sv_s {
-       wait_queue_head_t waiters;
-} sv_t;
-
-#define SV_FIFO                0x0             /* sv_t is FIFO type */
-#define SV_LIFO                0x2             /* sv_t is LIFO type */
-#define SV_PRIO                0x4             /* sv_t is PRIO type */
-#define SV_KEYED       0x6             /* sv_t is KEYED type */
-#define SV_DEFAULT      SV_FIFO
-
-
-static inline void _sv_wait(sv_t *sv, spinlock_t *lock, int state,
-                            unsigned long timeout)
-{
-       DECLARE_WAITQUEUE(wait, current);
-
-       add_wait_queue_exclusive(&sv->waiters, &wait);
-       __set_current_state(state);
-       spin_unlock(lock);
-
-       schedule_timeout(timeout);
-
-       remove_wait_queue(&sv->waiters, &wait);
-}
-
-#define init_sv(sv,type,name,flag) \
-       init_waitqueue_head(&(sv)->waiters)
-#define sv_init(sv,flag,name) \
-       init_waitqueue_head(&(sv)->waiters)
-#define sv_destroy(sv) \
-       /*NOTHING*/
-#define sv_wait(sv, pri, lock, s) \
-       _sv_wait(sv, lock, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT)
-#define sv_wait_sig(sv, pri, lock, s)   \
-       _sv_wait(sv, lock, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT)
-#define sv_timedwait(sv, pri, lock, s, svf, ts, rts) \
-       _sv_wait(sv, lock, TASK_UNINTERRUPTIBLE, timespec_to_jiffies(ts))
-#define sv_timedwait_sig(sv, pri, lock, s, svf, ts, rts) \
-       _sv_wait(sv, lock, TASK_INTERRUPTIBLE, timespec_to_jiffies(ts))
-#define sv_signal(sv) \
-       wake_up(&(sv)->waiters)
-#define sv_broadcast(sv) \
-       wake_up_all(&(sv)->waiters)
-
-#endif /* __XFS_SUPPORT_SV_H__ */
diff --git a/fs/xfs/linux/time.h b/fs/xfs/linux/time.h
deleted file mode 100644 (file)
index 109b5c0..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_TIME_H__
-#define __XFS_SUPPORT_TIME_H__
-
-#include <linux/sched.h>
-#include <linux/time.h>
-
-typedef struct timespec timespec_t;
-
-static inline void delay(long ticks)
-{
-       current->state = TASK_UNINTERRUPTIBLE;
-       schedule_timeout(ticks);
-}
-
-static inline void nanotime(struct timespec *tvp)
-{
-       *tvp = CURRENT_TIME;
-}
-
-#endif /* __XFS_SUPPORT_TIME_H__ */
diff --git a/fs/xfs/linux/xfs_aops.c b/fs/xfs/linux/xfs_aops.c
deleted file mode 100644 (file)
index 3afc61d..0000000
+++ /dev/null
@@ -1,1276 +0,0 @@
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.         Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_trans.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_alloc.h"
-#include "xfs_btree.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_error.h"
-#include "xfs_rw.h"
-#include "xfs_iomap.h"
-#include <linux/mpage.h>
-
-STATIC void xfs_count_page_state(struct page *, int *, int *, int *);
-STATIC void xfs_convert_page(struct inode *, struct page *,
-                               xfs_iomap_t *, void *, int, int);
-
-#if defined(XFS_RW_TRACE)
-void
-xfs_page_trace(
-       int             tag,
-       struct inode    *inode,
-       struct page     *page,
-       int             mask)
-{
-       xfs_inode_t     *ip;
-       bhv_desc_t      *bdp;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       loff_t          isize = i_size_read(inode);
-       loff_t          offset = page->index << PAGE_CACHE_SHIFT;
-       int             delalloc = -1, unmapped = -1, unwritten = -1;
-
-       if (page_has_buffers(page))
-               xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
-
-       bdp = vn_bhv_lookup(VN_BHV_HEAD(vp), &xfs_vnodeops);
-       ip = XFS_BHVTOI(bdp);
-       if (!ip->i_rwtrace)
-               return;
-
-       ktrace_enter(ip->i_rwtrace,
-               (void *)((unsigned long)tag),
-               (void *)ip,
-               (void *)inode,
-               (void *)page,
-               (void *)((unsigned long)mask),
-               (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
-               (void *)((unsigned long)((isize >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(isize & 0xffffffff)),
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)delalloc),
-               (void *)((unsigned long)unmapped),
-               (void *)((unsigned long)unwritten),
-               (void *)NULL,
-               (void *)NULL);
-}
-#else
-#define xfs_page_trace(tag, inode, page, mask)
-#endif
-
-void
-linvfs_unwritten_done(
-       struct buffer_head      *bh,
-       int                     uptodate)
-{
-       xfs_buf_t               *pb = (xfs_buf_t *)bh->b_private;
-
-       ASSERT(buffer_unwritten(bh));
-       bh->b_end_io = NULL;
-       clear_buffer_unwritten(bh);
-       if (!uptodate)
-               pagebuf_ioerror(pb, EIO);
-       if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
-               pagebuf_iodone(pb, 1, 1);
-       }
-       end_buffer_async_write(bh, uptodate);
-}
-
-/*
- * Issue transactions to convert a buffer range from unwritten
- * to written extents (buffered IO).
- */
-STATIC void
-linvfs_unwritten_convert(
-       xfs_buf_t       *bp)
-{
-       vnode_t         *vp = XFS_BUF_FSPRIVATE(bp, vnode_t *);
-       int             error;
-
-       BUG_ON(atomic_read(&bp->pb_hold) < 1);
-       VOP_BMAP(vp, XFS_BUF_OFFSET(bp), XFS_BUF_SIZE(bp),
-                       BMAPI_UNWRITTEN, NULL, NULL, error);
-       XFS_BUF_SET_FSPRIVATE(bp, NULL);
-       XFS_BUF_CLR_IODONE_FUNC(bp);
-       XFS_BUF_UNDATAIO(bp);
-       iput(LINVFS_GET_IP(vp));
-       pagebuf_iodone(bp, 0, 0);
-}
-
-/*
- * Issue transactions to convert a buffer range from unwritten
- * to written extents (direct IO).
- */
-STATIC void
-linvfs_unwritten_convert_direct(
-       struct inode    *inode,
-       loff_t          offset,
-       ssize_t         size,
-       void            *private)
-{
-       ASSERT(!private || inode == (struct inode *)private);
-
-       /* private indicates an unwritten extent lay beneath this IO,
-        * see linvfs_get_block_core.
-        */
-       if (private && size > 0) {
-               vnode_t *vp = LINVFS_GET_VP(inode);
-               int     error;
-
-               VOP_BMAP(vp, offset, size, BMAPI_UNWRITTEN, NULL, NULL, error);
-       }
-}
-
-STATIC int
-xfs_map_blocks(
-       struct inode            *inode,
-       loff_t                  offset,
-       ssize_t                 count,
-       xfs_iomap_t             *iomapp,
-       int                     flags)
-{
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
-       int                     error, niomaps = 1;
-
-       if (((flags & (BMAPI_DIRECT|BMAPI_SYNC)) == BMAPI_DIRECT) &&
-           (offset >= i_size_read(inode)))
-               count = max_t(ssize_t, count, XFS_WRITE_IO_LOG);
-retry:
-       VOP_BMAP(vp, offset, count, flags, iomapp, &niomaps, error);
-       if ((error == EAGAIN) || (error == EIO))
-               return -error;
-       if (unlikely((flags & (BMAPI_WRITE|BMAPI_DIRECT)) ==
-                                       (BMAPI_WRITE|BMAPI_DIRECT) && niomaps &&
-                                       (iomapp->iomap_flags & IOMAP_DELAY))) {
-               flags = BMAPI_ALLOCATE;
-               goto retry;
-       }
-       if (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
-               VMODIFY(vp);
-       }
-       return -error;
-}
-
-/*
- * Finds the corresponding mapping in block @map array of the
- * given @offset within a @page.
- */
-STATIC xfs_iomap_t *
-xfs_offset_to_map(
-       struct page             *page,
-       xfs_iomap_t             *iomapp,
-       unsigned long           offset)
-{
-       loff_t                  full_offset;    /* offset from start of file */
-
-       ASSERT(offset < PAGE_CACHE_SIZE);
-
-       full_offset = page->index;              /* NB: using 64bit number */
-       full_offset <<= PAGE_CACHE_SHIFT;       /* offset from file start */
-       full_offset += offset;                  /* offset from page start */
-
-       if (full_offset < iomapp->iomap_offset)
-               return NULL;
-       if (iomapp->iomap_offset + iomapp->iomap_bsize > full_offset)
-               return iomapp;
-       return NULL;
-}
-
-STATIC void
-xfs_map_at_offset(
-       struct page             *page,
-       struct buffer_head      *bh,
-       unsigned long           offset,
-       int                     block_bits,
-       xfs_iomap_t             *iomapp)
-{
-       xfs_daddr_t             bn;
-       loff_t                  delta;
-       int                     sector_shift;
-
-       ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
-       ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
-       ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
-
-       delta = page->index;
-       delta <<= PAGE_CACHE_SHIFT;
-       delta += offset;
-       delta -= iomapp->iomap_offset;
-       delta >>= block_bits;
-
-       sector_shift = block_bits - BBSHIFT;
-       bn = iomapp->iomap_bn >> sector_shift;
-       bn += delta;
-       ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
-
-       lock_buffer(bh);
-       bh->b_blocknr = bn;
-       bh->b_bdev = iomapp->iomap_target->pbr_bdev;
-       set_buffer_mapped(bh);
-       clear_buffer_delay(bh);
-}
-
-/*
- * Look for a page at index which is unlocked and contains our
- * unwritten extent flagged buffers at its head.  Returns page
- * locked and with an extra reference count, and length of the
- * unwritten extent component on this page that we can write,
- * in units of filesystem blocks.
- */
-STATIC struct page *
-xfs_probe_unwritten_page(
-       struct address_space    *mapping,
-       pgoff_t                 index,
-       xfs_iomap_t             *iomapp,
-       xfs_buf_t               *pb,
-       unsigned long           max_offset,
-       unsigned long           *fsbs,
-       unsigned int            bbits)
-{
-       struct page             *page;
-
-       page = find_trylock_page(mapping, index);
-       if (!page)
-               return 0;
-       if (PageWriteback(page))
-               goto out;
-
-       if (page->mapping && page_has_buffers(page)) {
-               struct buffer_head      *bh, *head;
-               unsigned long           p_offset = 0;
-
-               *fsbs = 0;
-               bh = head = page_buffers(page);
-               do {
-                       if (!buffer_unwritten(bh))
-                               break;
-                       if (!xfs_offset_to_map(page, iomapp, p_offset))
-                               break;
-                       if (p_offset >= max_offset)
-                               break;
-                       xfs_map_at_offset(page, bh, p_offset, bbits, iomapp);
-                       set_buffer_unwritten_io(bh);
-                       bh->b_private = pb;
-                       p_offset += bh->b_size;
-                       (*fsbs)++;
-               } while ((bh = bh->b_this_page) != head);
-
-               if (p_offset)
-                       return page;
-       }
-
-out:
-       unlock_page(page);
-       return NULL;
-}
-
-/*
- * Look for a page at index which is unlocked and not mapped
- * yet - clustering for mmap write case.
- */
-STATIC unsigned int
-xfs_probe_unmapped_page(
-       struct address_space    *mapping,
-       pgoff_t                 index,
-       unsigned int            pg_offset)
-{
-       struct page             *page;
-       int                     ret = 0;
-
-       page = find_trylock_page(mapping, index);
-       if (!page)
-               return 0;
-       if (PageWriteback(page))
-               goto out;
-
-       if (page->mapping && PageDirty(page)) {
-               if (page_has_buffers(page)) {
-                       struct buffer_head      *bh, *head;
-
-                       bh = head = page_buffers(page);
-                       do {
-                               if (buffer_mapped(bh) || !buffer_uptodate(bh))
-                                       break;
-                               ret += bh->b_size;
-                               if (ret >= pg_offset)
-                                       break;
-                       } while ((bh = bh->b_this_page) != head);
-               } else
-                       ret = PAGE_CACHE_SIZE;
-       }
-
-out:
-       unlock_page(page);
-       return ret;
-}
-
-STATIC unsigned int
-xfs_probe_unmapped_cluster(
-       struct inode            *inode,
-       struct page             *startpage,
-       struct buffer_head      *bh,
-       struct buffer_head      *head)
-{
-       pgoff_t                 tindex, tlast, tloff;
-       unsigned int            pg_offset, len, total = 0;
-       struct address_space    *mapping = inode->i_mapping;
-
-       /* First sum forwards in this page */
-       do {
-               if (buffer_mapped(bh))
-                       break;
-               total += bh->b_size;
-       } while ((bh = bh->b_this_page) != head);
-
-       /* If we reached the end of the page, sum forwards in
-        * following pages.
-        */
-       if (bh == head) {
-               tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
-               /* Prune this back to avoid pathological behavior */
-               tloff = min(tlast, startpage->index + 64);
-               for (tindex = startpage->index + 1; tindex < tloff; tindex++) {
-                       len = xfs_probe_unmapped_page(mapping, tindex,
-                                                       PAGE_CACHE_SIZE);
-                       if (!len)
-                               return total;
-                       total += len;
-               }
-               if (tindex == tlast &&
-                   (pg_offset = i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
-                       total += xfs_probe_unmapped_page(mapping,
-                                                       tindex, pg_offset);
-               }
-       }
-       return total;
-}
-
-/*
- * Probe for a given page (index) in the inode and test if it is delayed
- * and without unwritten buffers.  Returns page locked and with an extra
- * reference count.
- */
-STATIC struct page *
-xfs_probe_delalloc_page(
-       struct inode            *inode,
-       pgoff_t                 index)
-{
-       struct page             *page;
-
-       page = find_trylock_page(inode->i_mapping, index);
-       if (!page)
-               return NULL;
-       if (PageWriteback(page))
-               goto out;
-
-       if (page->mapping && page_has_buffers(page)) {
-               struct buffer_head      *bh, *head;
-               int                     acceptable = 0;
-
-               bh = head = page_buffers(page);
-               do {
-                       if (buffer_unwritten(bh)) {
-                               acceptable = 0;
-                               break;
-                       } else if (buffer_delay(bh)) {
-                               acceptable = 1;
-                       }
-               } while ((bh = bh->b_this_page) != head);
-
-               if (acceptable)
-                       return page;
-       }
-
-out:
-       unlock_page(page);
-       return NULL;
-}
-
-STATIC int
-xfs_map_unwritten(
-       struct inode            *inode,
-       struct page             *start_page,
-       struct buffer_head      *head,
-       struct buffer_head      *curr,
-       unsigned long           p_offset,
-       int                     block_bits,
-       xfs_iomap_t             *iomapp,
-       int                     startio,
-       int                     all_bh)
-{
-       struct buffer_head      *bh = curr;
-       xfs_iomap_t             *tmp;
-       xfs_buf_t               *pb;
-       loff_t                  offset, size;
-       unsigned long           nblocks = 0;
-
-       offset = start_page->index;
-       offset <<= PAGE_CACHE_SHIFT;
-       offset += p_offset;
-
-       /* get an "empty" pagebuf to manage IO completion
-        * Proper values will be set before returning */
-       pb = pagebuf_lookup(iomapp->iomap_target, 0, 0, 0);
-       if (!pb)
-               return -EAGAIN;
-
-       /* Take a reference to the inode to prevent it from
-        * being reclaimed while we have outstanding unwritten
-        * extent IO on it.
-        */
-       if ((igrab(inode)) != inode) {
-               pagebuf_free(pb);
-               return -EAGAIN;
-       }
-
-       /* Set the count to 1 initially, this will stop an I/O
-        * completion callout which happens before we have started
-        * all the I/O from calling pagebuf_iodone too early.
-        */
-       atomic_set(&pb->pb_io_remaining, 1);
-
-       /* First map forwards in the page consecutive buffers
-        * covering this unwritten extent
-        */
-       do {
-               if (!buffer_unwritten(bh))
-                       break;
-               tmp = xfs_offset_to_map(start_page, iomapp, p_offset);
-               if (!tmp)
-                       break;
-               xfs_map_at_offset(start_page, bh, p_offset, block_bits, iomapp);
-               set_buffer_unwritten_io(bh);
-               bh->b_private = pb;
-               p_offset += bh->b_size;
-               nblocks++;
-       } while ((bh = bh->b_this_page) != head);
-
-       atomic_add(nblocks, &pb->pb_io_remaining);
-
-       /* If we reached the end of the page, map forwards in any
-        * following pages which are also covered by this extent.
-        */
-       if (bh == head) {
-               struct address_space    *mapping = inode->i_mapping;
-               pgoff_t                 tindex, tloff, tlast;
-               unsigned long           bs;
-               unsigned int            pg_offset, bbits = inode->i_blkbits;
-               struct page             *page;
-
-               tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
-               tloff = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
-               tloff = min(tlast, tloff);
-               for (tindex = start_page->index + 1; tindex < tloff; tindex++) {
-                       page = xfs_probe_unwritten_page(mapping,
-                                               tindex, iomapp, pb,
-                                               PAGE_CACHE_SIZE, &bs, bbits);
-                       if (!page)
-                               break;
-                       nblocks += bs;
-                       atomic_add(bs, &pb->pb_io_remaining);
-                       xfs_convert_page(inode, page, iomapp, pb,
-                                                       startio, all_bh);
-                       /* stop if converting the next page might add
-                        * enough blocks that the corresponding byte
-                        * count won't fit in our ulong page buf length */
-                       if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
-                               goto enough;
-               }
-
-               if (tindex == tlast &&
-                   (pg_offset = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1)))) {
-                       page = xfs_probe_unwritten_page(mapping,
-                                                       tindex, iomapp, pb,
-                                                       pg_offset, &bs, bbits);
-                       if (page) {
-                               nblocks += bs;
-                               atomic_add(bs, &pb->pb_io_remaining);
-                               xfs_convert_page(inode, page, iomapp, pb,
-                                                       startio, all_bh);
-                               if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
-                                       goto enough;
-                       }
-               }
-       }
-
-enough:
-       size = nblocks;         /* NB: using 64bit number here */
-       size <<= block_bits;    /* convert fsb's to byte range */
-
-       XFS_BUF_DATAIO(pb);
-       XFS_BUF_ASYNC(pb);
-       XFS_BUF_SET_SIZE(pb, size);
-       XFS_BUF_SET_COUNT(pb, size);
-       XFS_BUF_SET_OFFSET(pb, offset);
-       XFS_BUF_SET_FSPRIVATE(pb, LINVFS_GET_VP(inode));
-       XFS_BUF_SET_IODONE_FUNC(pb, linvfs_unwritten_convert);
-
-       if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
-               pagebuf_iodone(pb, 1, 1);
-       }
-
-       return 0;
-}
-
-STATIC void
-xfs_submit_page(
-       struct page             *page,
-       struct buffer_head      *bh_arr[],
-       int                     cnt)
-{
-       struct buffer_head      *bh;
-       int                     i;
-
-       BUG_ON(PageWriteback(page));
-       set_page_writeback(page);
-       clear_page_dirty(page);
-       unlock_page(page);
-
-       if (cnt) {
-               for (i = 0; i < cnt; i++) {
-                       bh = bh_arr[i];
-                       mark_buffer_async_write(bh);
-                       if (buffer_unwritten(bh))
-                               set_buffer_unwritten_io(bh);
-                       set_buffer_uptodate(bh);
-                       clear_buffer_dirty(bh);
-               }
-
-               for (i = 0; i < cnt; i++)
-                       submit_bh(WRITE, bh_arr[i]);
-       } else
-               end_page_writeback(page);
-}
-
-/*
- * Allocate & map buffers for page given the extent map. Write it out.
- * except for the original page of a writepage, this is called on
- * delalloc/unwritten pages only, for the original page it is possible
- * that the page has no mapping at all.
- */
-STATIC void
-xfs_convert_page(
-       struct inode            *inode,
-       struct page             *page,
-       xfs_iomap_t             *iomapp,
-       void                    *private,
-       int                     startio,
-       int                     all_bh)
-{
-       struct buffer_head      *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
-       xfs_iomap_t             *mp = iomapp, *tmp;
-       unsigned long           end, offset;
-       pgoff_t                 end_index;
-       int                     i = 0, index = 0;
-       int                     bbits = inode->i_blkbits;
-
-       end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
-       if (page->index < end_index) {
-               end = PAGE_CACHE_SIZE;
-       } else {
-               end = i_size_read(inode) & (PAGE_CACHE_SIZE-1);
-       }
-       bh = head = page_buffers(page);
-       do {
-               offset = i << bbits;
-               if (!(PageUptodate(page) || buffer_uptodate(bh)))
-                       continue;
-               if (buffer_mapped(bh) && all_bh &&
-                   !buffer_unwritten(bh) && !buffer_delay(bh)) {
-                       if (startio && (offset < end)) {
-                               lock_buffer(bh);
-                               bh_arr[index++] = bh;
-                       }
-                       continue;
-               }
-               tmp = xfs_offset_to_map(page, mp, offset);
-               if (!tmp)
-                       continue;
-               ASSERT(!(tmp->iomap_flags & IOMAP_HOLE));
-               ASSERT(!(tmp->iomap_flags & IOMAP_DELAY));
-
-               /* If this is a new unwritten extent buffer (i.e. one
-                * that we haven't passed in private data for, we must
-                * now map this buffer too.
-                */
-               if (buffer_unwritten(bh) && !bh->b_end_io) {
-                       ASSERT(tmp->iomap_flags & IOMAP_UNWRITTEN);
-                       xfs_map_unwritten(inode, page, head, bh,
-                                       offset, bbits, tmp, startio, all_bh);
-               } else if (! (buffer_unwritten(bh) && buffer_locked(bh))) {
-                       xfs_map_at_offset(page, bh, offset, bbits, tmp);
-                       if (buffer_unwritten(bh)) {
-                               set_buffer_unwritten_io(bh);
-                               bh->b_private = private;
-                               ASSERT(private);
-                       }
-               }
-               if (startio && (offset < end)) {
-                       bh_arr[index++] = bh;
-               } else {
-                       set_buffer_dirty(bh);
-                       unlock_buffer(bh);
-                       mark_buffer_dirty(bh);
-               }
-       } while (i++, (bh = bh->b_this_page) != head);
-
-       if (startio) {
-               xfs_submit_page(page, bh_arr, index);
-       } else {
-               unlock_page(page);
-       }
-}
-
-/*
- * Convert & write out a cluster of pages in the same extent as defined
- * by mp and following the start page.
- */
-STATIC void
-xfs_cluster_write(
-       struct inode            *inode,
-       pgoff_t                 tindex,
-       xfs_iomap_t             *iomapp,
-       int                     startio,
-       int                     all_bh)
-{
-       pgoff_t                 tlast;
-       struct page             *page;
-
-       tlast = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
-       for (; tindex < tlast; tindex++) {
-               page = xfs_probe_delalloc_page(inode, tindex);
-               if (!page)
-                       break;
-               xfs_convert_page(inode, page, iomapp, NULL, startio, all_bh);
-       }
-}
-
-/*
- * Calling this without startio set means we are being asked to make a dirty
- * page ready for freeing it's buffers.  When called with startio set then
- * we are coming from writepage.
- *
- * When called with startio set it is important that we write the WHOLE
- * page if possible.
- * The bh->b_state's cannot know if any of the blocks or which block for
- * that matter are dirty due to mmap writes, and therefore bh uptodate is
- * only vaild if the page itself isn't completely uptodate.  Some layers
- * may clear the page dirty flag prior to calling write page, under the
- * assumption the entire page will be written out; by not writing out the
- * whole page the page can be reused before all valid dirty data is
- * written out.  Note: in the case of a page that has been dirty'd by
- * mapwrite and but partially setup by block_prepare_write the
- * bh->b_states's will not agree and only ones setup by BPW/BCW will have
- * valid state, thus the whole page must be written out thing.
- */
-
-STATIC int
-xfs_page_state_convert(
-       struct inode    *inode,
-       struct page     *page,
-       int             startio,
-       int             unmapped) /* also implies page uptodate */
-{
-       struct buffer_head      *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
-       xfs_iomap_t             *iomp, iomap;
-       unsigned long           p_offset = 0;
-       pgoff_t                 end_index;
-       loff_t                  offset;
-       unsigned long long      end_offset;
-       int                     len, err, i, cnt = 0, uptodate = 1;
-       int                     flags = startio ? 0 : BMAPI_TRYLOCK;
-       int                     page_dirty = 1;
-
-
-       /* Are we off the end of the file ? */
-       end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
-       if (page->index >= end_index) {
-               if ((page->index >= end_index + 1) ||
-                   !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
-                       err = -EIO;
-                       goto error;
-               }
-       }
-
-       offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
-       end_offset = min_t(unsigned long long,
-                       offset + PAGE_CACHE_SIZE, i_size_read(inode));
-
-       bh = head = page_buffers(page);
-       iomp = NULL;
-
-       len = bh->b_size;
-       do {
-               if (offset >= end_offset)
-                       break;
-               if (!buffer_uptodate(bh))
-                       uptodate = 0;
-               if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio)
-                       continue;
-
-               if (iomp) {
-                       iomp = xfs_offset_to_map(page, &iomap, p_offset);
-               }
-
-               /*
-                * First case, map an unwritten extent and prepare for
-                * extent state conversion transaction on completion.
-                */
-               if (buffer_unwritten(bh)) {
-                       if (!iomp) {
-                               err = xfs_map_blocks(inode, offset, len, &iomap,
-                                               BMAPI_READ|BMAPI_IGNSTATE);
-                               if (err) {
-                                       goto error;
-                               }
-                               iomp = xfs_offset_to_map(page, &iomap,
-                                                               p_offset);
-                       }
-                       if (iomp && startio) {
-                               if (!bh->b_end_io) {
-                                       err = xfs_map_unwritten(inode, page,
-                                                       head, bh, p_offset,
-                                                       inode->i_blkbits, iomp,
-                                                       startio, unmapped);
-                                       if (err) {
-                                               goto error;
-                                       }
-                               }
-                               bh_arr[cnt++] = bh;
-                               page_dirty = 0;
-                       }
-               /*
-                * Second case, allocate space for a delalloc buffer.
-                * We can return EAGAIN here in the release page case.
-                */
-               } else if (buffer_delay(bh)) {
-                       if (!iomp) {
-                               err = xfs_map_blocks(inode, offset, len, &iomap,
-                                               BMAPI_ALLOCATE | flags);
-                               if (err) {
-                                       goto error;
-                               }
-                               iomp = xfs_offset_to_map(page, &iomap,
-                                                               p_offset);
-                       }
-                       if (iomp) {
-                               xfs_map_at_offset(page, bh, p_offset,
-                                               inode->i_blkbits, iomp);
-                               if (startio) {
-                                       bh_arr[cnt++] = bh;
-                               } else {
-                                       set_buffer_dirty(bh);
-                                       unlock_buffer(bh);
-                                       mark_buffer_dirty(bh);
-                               }
-                               page_dirty = 0;
-                       }
-               } else if ((buffer_uptodate(bh) || PageUptodate(page)) &&
-                          (unmapped || startio)) {
-
-                       if (!buffer_mapped(bh)) {
-                               int     size;
-
-                               /*
-                                * Getting here implies an unmapped buffer
-                                * was found, and we are in a path where we
-                                * need to write the whole page out.
-                                */
-                               if (!iomp) {
-                                       size = xfs_probe_unmapped_cluster(
-                                                       inode, page, bh, head);
-                                       err = xfs_map_blocks(inode, offset,
-                                                       size, &iomap,
-                                                       BMAPI_WRITE|BMAPI_MMAP);
-                                       if (err) {
-                                               goto error;
-                                       }
-                                       iomp = xfs_offset_to_map(page, &iomap,
-                                                                    p_offset);
-                               }
-                               if (iomp) {
-                                       xfs_map_at_offset(page,
-                                                       bh, p_offset,
-                                                       inode->i_blkbits, iomp);
-                                       if (startio) {
-                                               bh_arr[cnt++] = bh;
-                                       } else {
-                                               set_buffer_dirty(bh);
-                                               unlock_buffer(bh);
-                                               mark_buffer_dirty(bh);
-                                       }
-                                       page_dirty = 0;
-                               }
-                       } else if (startio) {
-                               if (buffer_uptodate(bh) &&
-                                   !test_and_set_bit(BH_Lock, &bh->b_state)) {
-                                       bh_arr[cnt++] = bh;
-                                       page_dirty = 0;
-                               }
-                       }
-               }
-       } while (offset += len, p_offset += len,
-               ((bh = bh->b_this_page) != head));
-
-       if (uptodate && bh == head)
-               SetPageUptodate(page);
-
-       if (startio)
-               xfs_submit_page(page, bh_arr, cnt);
-
-       if (iomp)
-               xfs_cluster_write(inode, page->index + 1, iomp, startio, unmapped);
-
-       return page_dirty;
-
-error:
-       for (i = 0; i < cnt; i++) {
-               unlock_buffer(bh_arr[i]);
-       }
-
-       /*
-        * If it's delalloc and we have nowhere to put it,
-        * throw it away, unless the lower layers told
-        * us to try again.
-        */
-       if (err != -EAGAIN) {
-               if (!unmapped) {
-                       block_invalidatepage(page, 0);
-               }
-               ClearPageUptodate(page);
-       }
-       return err;
-}
-
-STATIC int
-linvfs_get_block_core(
-       struct inode            *inode,
-       sector_t                iblock,
-       unsigned long           blocks,
-       struct buffer_head      *bh_result,
-       int                     create,
-       int                     direct,
-       bmapi_flags_t           flags)
-{
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
-       xfs_iomap_t             iomap;
-       int                     retpbbm = 1;
-       int                     error;
-       ssize_t                 size;
-       loff_t                  offset = (loff_t)iblock << inode->i_blkbits;
-
-       /* If we are doing writes at the end of the file,
-        * allocate in chunks
-        */
-       if (blocks)
-               size = blocks << inode->i_blkbits;
-       else if (create && (offset >= i_size_read(inode)))
-               size = 1 << XFS_WRITE_IO_LOG;
-       else
-               size = 1 << inode->i_blkbits;
-
-       VOP_BMAP(vp, offset, size,
-               create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
-       if (error)
-               return -error;
-
-       if (retpbbm == 0)
-               return 0;
-
-       if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
-               xfs_daddr_t             bn;
-               loff_t                  delta;
-
-               /* For unwritten extents do not report a disk address on
-                * the read case (treat as if we're reading into a hole).
-                */
-               if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
-                       delta = offset - iomap.iomap_offset;
-                       delta >>= inode->i_blkbits;
-
-                       bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
-                       bn += delta;
-
-                       bh_result->b_blocknr = bn;
-                       bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
-                       set_buffer_mapped(bh_result);
-               }
-               if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
-                       if (direct)
-                               bh_result->b_private = inode;
-                       set_buffer_unwritten(bh_result);
-                       set_buffer_delay(bh_result);
-               }
-       }
-
-       /* If this is a realtime file, data might be on a new device */
-       bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
-
-       /* If we previously allocated a block out beyond eof and
-        * we are now coming back to use it then we will need to
-        * flag it as new even if it has a disk address.
-        */
-       if (create &&
-           ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
-            (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) {
-               set_buffer_new(bh_result);
-       }
-
-       if (iomap.iomap_flags & IOMAP_DELAY) {
-               if (unlikely(direct))
-                       BUG();
-               if (create) {
-                       set_buffer_mapped(bh_result);
-                       set_buffer_uptodate(bh_result);
-               }
-               bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
-               set_buffer_delay(bh_result);
-       }
-
-       if (blocks) {
-               loff_t iosize;
-               iosize = (iomap.iomap_bsize - iomap.iomap_delta);
-               bh_result->b_size =
-                   (ssize_t)min(iosize, (loff_t)(blocks << inode->i_blkbits));
-       }
-
-       return 0;
-}
-
-int
-linvfs_get_block(
-       struct inode            *inode,
-       sector_t                iblock,
-       struct buffer_head      *bh_result,
-       int                     create)
-{
-       return linvfs_get_block_core(inode, iblock, 0, bh_result,
-                                       create, 0, BMAPI_WRITE);
-}
-
-STATIC int
-linvfs_get_block_sync(
-       struct inode            *inode,
-       sector_t                iblock,
-       struct buffer_head      *bh_result,
-       int                     create)
-{
-       return linvfs_get_block_core(inode, iblock, 0, bh_result,
-                                       create, 0, BMAPI_SYNC|BMAPI_WRITE);
-}
-
-STATIC int
-linvfs_get_blocks_direct(
-       struct inode            *inode,
-       sector_t                iblock,
-       unsigned long           max_blocks,
-       struct buffer_head      *bh_result,
-       int                     create)
-{
-       return linvfs_get_block_core(inode, iblock, max_blocks, bh_result,
-                                       create, 1, BMAPI_WRITE|BMAPI_DIRECT);
-}
-
-STATIC ssize_t
-linvfs_direct_IO(
-       int                     rw,
-       struct kiocb            *iocb,
-       const struct iovec      *iov,
-       loff_t                  offset,
-       unsigned long           nr_segs)
-{
-       struct file     *file = iocb->ki_filp;
-       struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       xfs_iomap_t     iomap;
-       int             maps = 1;
-       int             error;
-
-       VOP_BMAP(vp, offset, 0, BMAPI_DEVICE, &iomap, &maps, error);
-       if (error)
-               return -error;
-
-       return blockdev_direct_IO_no_locking(rw, iocb, inode,
-               iomap.iomap_target->pbr_bdev,
-               iov, offset, nr_segs,
-               linvfs_get_blocks_direct,
-               linvfs_unwritten_convert_direct);
-}
-
-
-STATIC sector_t
-linvfs_bmap(
-       struct address_space    *mapping,
-       sector_t                block)
-{
-       struct inode            *inode = (struct inode *)mapping->host;
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
-       int                     error;
-
-       vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address);
-
-       VOP_RWLOCK(vp, VRWLOCK_READ);
-       VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error);
-       VOP_RWUNLOCK(vp, VRWLOCK_READ);
-       return generic_block_bmap(mapping, block, linvfs_get_block);
-}
-
-STATIC int
-linvfs_readpage(
-       struct file             *unused,
-       struct page             *page)
-{
-       return mpage_readpage(page, linvfs_get_block);
-}
-
-STATIC int
-linvfs_readpages(
-       struct file             *unused,
-       struct address_space    *mapping,
-       struct list_head        *pages,
-       unsigned                nr_pages)
-{
-       return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block);
-}
-
-STATIC void
-xfs_count_page_state(
-       struct page             *page,
-       int                     *delalloc,
-       int                     *unmapped,
-       int                     *unwritten)
-{
-       struct buffer_head      *bh, *head;
-
-       *delalloc = *unmapped = *unwritten = 0;
-
-       bh = head = page_buffers(page);
-       do {
-               if (buffer_uptodate(bh) && !buffer_mapped(bh))
-                       (*unmapped) = 1;
-               else if (buffer_unwritten(bh) && !buffer_delay(bh))
-                       clear_buffer_unwritten(bh);
-               else if (buffer_unwritten(bh))
-                       (*unwritten) = 1;
-               else if (buffer_delay(bh))
-                       (*delalloc) = 1;
-       } while ((bh = bh->b_this_page) != head);
-}
-
-
-/*
- * writepage: Called from one of two places:
- *
- * 1. we are flushing a delalloc buffer head.
- *
- * 2. we are writing out a dirty page. Typically the page dirty
- *    state is cleared before we get here. In this case is it
- *    conceivable we have no buffer heads.
- *
- * For delalloc space on the page we need to allocate space and
- * flush it. For unmapped buffer heads on the page we should
- * allocate space if the page is uptodate. For any other dirty
- * buffer heads on the page we should flush them.
- *
- * If we detect that a transaction would be required to flush
- * the page, we have to check the process flags first, if we
- * are already in a transaction or disk I/O during allocations
- * is off, we need to fail the writepage and redirty the page.
- */
-
-STATIC int
-linvfs_writepage(
-       struct page             *page,
-       struct writeback_control *wbc)
-{
-       int                     error;
-       int                     need_trans;
-       int                     delalloc, unmapped, unwritten;
-       struct inode            *inode = page->mapping->host;
-
-       xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
-
-       /*
-        * We need a transaction if:
-        *  1. There are delalloc buffers on the page
-        *  2. The page is uptodate and we have unmapped buffers
-        *  3. The page is uptodate and we have no buffers
-        *  4. There are unwritten buffers on the page
-        */
-
-       if (!page_has_buffers(page)) {
-               unmapped = 1;
-               need_trans = 1;
-       } else {
-               xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
-               if (!PageUptodate(page))
-                       unmapped = 0;
-               need_trans = delalloc + unmapped + unwritten;
-       }
-
-       /*
-        * If we need a transaction and the process flags say
-        * we are already in a transaction, or no IO is allowed
-        * then mark the page dirty again and leave the page
-        * as is.
-        */
-       if (PFLAGS_TEST_FSTRANS() && need_trans)
-               goto out_fail;
-
-       /*
-        * Delay hooking up buffer heads until we have
-        * made our go/no-go decision.
-        */
-       if (!page_has_buffers(page))
-               create_empty_buffers(page, 1 << inode->i_blkbits, 0);
-
-       /*
-        * Convert delayed allocate, unwritten or unmapped space
-        * to real space and flush out to disk.
-        */
-       error = xfs_page_state_convert(inode, page, 1, unmapped);
-       if (error == -EAGAIN)
-               goto out_fail;
-       if (unlikely(error < 0))
-               goto out_unlock;
-
-       return 0;
-
-out_fail:
-       set_page_dirty(page);
-       unlock_page(page);
-       return 0;
-out_unlock:
-       unlock_page(page);
-       return error;
-}
-
-/*
- * Called to move a page into cleanable state - and from there
- * to be released. Possibly the page is already clean. We always
- * have buffer heads in this call.
- *
- * Returns 0 if the page is ok to release, 1 otherwise.
- *
- * Possible scenarios are:
- *
- * 1. We are being called to release a page which has been written
- *    to via regular I/O. buffer heads will be dirty and possibly
- *    delalloc. If no delalloc buffer heads in this case then we
- *    can just return zero.
- *
- * 2. We are called to release a page which has been written via
- *    mmap, all we need to do is ensure there is no delalloc
- *    state in the buffer heads, if not we can let the caller
- *    free them and we should come back later via writepage.
- */
-STATIC int
-linvfs_release_page(
-       struct page             *page,
-       int                     gfp_mask)
-{
-       struct inode            *inode = page->mapping->host;
-       int                     dirty, delalloc, unmapped, unwritten;
-
-       xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
-
-       xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
-       if (!delalloc && !unwritten)
-               goto free_buffers;
-
-       if (!(gfp_mask & __GFP_FS))
-               return 0;
-
-       /* If we are already inside a transaction or the thread cannot
-        * do I/O, we cannot release this page.
-        */
-       if (PFLAGS_TEST_FSTRANS())
-               return 0;
-
-       /*
-        * Convert delalloc space to real space, do not flush the
-        * data out to disk, that will be done by the caller.
-        * Never need to allocate space here - we will always
-        * come back to writepage in that case.
-        */
-       dirty = xfs_page_state_convert(inode, page, 0, 0);
-       if (dirty == 0 && !unwritten)
-               goto free_buffers;
-       return 0;
-
-free_buffers:
-       return try_to_free_buffers(page);
-}
-
-STATIC int
-linvfs_prepare_write(
-       struct file             *file,
-       struct page             *page,
-       unsigned int            from,
-       unsigned int            to)
-{
-       if (file && (file->f_flags & O_SYNC)) {
-               return block_prepare_write(page, from, to,
-                                               linvfs_get_block_sync);
-       } else {
-               return block_prepare_write(page, from, to,
-                                               linvfs_get_block);
-       }
-}
-
-struct address_space_operations linvfs_aops = {
-       .readpage               = linvfs_readpage,
-       .readpages              = linvfs_readpages,
-       .writepage              = linvfs_writepage,
-       .sync_page              = block_sync_page,
-       .releasepage            = linvfs_release_page,
-       .prepare_write          = linvfs_prepare_write,
-       .commit_write           = generic_commit_write,
-       .bmap                   = linvfs_bmap,
-       .direct_IO              = linvfs_direct_IO,
-};
diff --git a/fs/xfs/linux/xfs_buf.c b/fs/xfs/linux/xfs_buf.c
deleted file mode 100644 (file)
index 69050a0..0000000
+++ /dev/null
@@ -1,1811 +0,0 @@
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- *     The xfs_buf.c code provides an abstract buffer cache model on top
- *     of the Linux page cache.  Cached metadata blocks for a file system
- *     are hashed to the inode for the block device.  xfs_buf.c assembles
- *     buffers (xfs_buf_t) on demand to aggregate such cached pages for I/O.
- *
- *      Written by Steve Lord, Jim Mostek, Russell Cattelan
- *                 and Rajagopal Ananthanarayanan ("ananth") at SGI.
- *
- */
-
-#include <linux/stddef.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
-#include <linux/init.h>
-#include <linux/vmalloc.h>
-#include <linux/bio.h>
-#include <linux/sysctl.h>
-#include <linux/proc_fs.h>
-#include <linux/workqueue.h>
-#include <linux/suspend.h>
-#include <linux/percpu.h>
-
-#include "xfs_linux.h"
-
-#ifndef GFP_READAHEAD
-#define GFP_READAHEAD  (__GFP_NOWARN|__GFP_NORETRY)
-#endif
-
-/*
- * File wide globals
- */
-
-STATIC kmem_cache_t *pagebuf_cache;
-STATIC void pagebuf_daemon_wakeup(void);
-STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
-STATIC struct workqueue_struct *pagebuf_logio_workqueue;
-STATIC struct workqueue_struct *pagebuf_dataio_workqueue;
-
-/*
- * Pagebuf debugging
- */
-
-#ifdef PAGEBUF_TRACE
-void
-pagebuf_trace(
-       xfs_buf_t       *pb,
-       char            *id,
-       void            *data,
-       void            *ra)
-{
-       ktrace_enter(pagebuf_trace_buf,
-               pb, id,
-               (void *)(unsigned long)pb->pb_flags,
-               (void *)(unsigned long)pb->pb_hold.counter,
-               (void *)(unsigned long)pb->pb_sema.count.counter,
-               (void *)current,
-               data, ra,
-               (void *)(unsigned long)((pb->pb_file_offset>>32) & 0xffffffff),
-               (void *)(unsigned long)(pb->pb_file_offset & 0xffffffff),
-               (void *)(unsigned long)pb->pb_buffer_length,
-               NULL, NULL, NULL, NULL, NULL);
-}
-ktrace_t *pagebuf_trace_buf;
-#define PAGEBUF_TRACE_SIZE     4096
-#define PB_TRACE(pb, id, data) \
-       pagebuf_trace(pb, id, (void *)data, (void *)__builtin_return_address(0))
-#else
-#define PB_TRACE(pb, id, data) do { } while (0)
-#endif
-
-#ifdef PAGEBUF_LOCK_TRACKING
-# define PB_SET_OWNER(pb)      ((pb)->pb_last_holder = current->pid)
-# define PB_CLEAR_OWNER(pb)    ((pb)->pb_last_holder = -1)
-# define PB_GET_OWNER(pb)      ((pb)->pb_last_holder)
-#else
-# define PB_SET_OWNER(pb)      do { } while (0)
-# define PB_CLEAR_OWNER(pb)    do { } while (0)
-# define PB_GET_OWNER(pb)      do { } while (0)
-#endif
-
-/*
- * Pagebuf allocation / freeing.
- */
-
-#define pb_to_gfp(flags) \
-       (((flags) & PBF_READ_AHEAD) ? GFP_READAHEAD : \
-        ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL)
-
-#define pb_to_km(flags) \
-        (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
-
-
-#define pagebuf_allocate(flags) \
-       kmem_zone_alloc(pagebuf_cache, pb_to_km(flags))
-#define pagebuf_deallocate(pb) \
-       kmem_zone_free(pagebuf_cache, (pb));
-
-/*
- * Pagebuf hashing
- */
-
-#define NBITS  8
-#define NHASH  (1<<NBITS)
-
-typedef struct {
-       struct list_head        pb_hash;
-       spinlock_t              pb_hash_lock;
-} pb_hash_t;
-
-STATIC pb_hash_t       pbhash[NHASH];
-#define pb_hash(pb)    &pbhash[pb->pb_hash_index]
-
-STATIC int
-_bhash(
-       struct block_device *bdev,
-       loff_t          base)
-{
-       int             bit, hval;
-
-       base >>= 9;
-       base ^= (unsigned long)bdev / L1_CACHE_BYTES;
-       for (bit = hval = 0; base && bit < sizeof(base) * 8; bit += NBITS) {
-               hval ^= (int)base & (NHASH-1);
-               base >>= NBITS;
-       }
-       return hval;
-}
-
-/*
- * Mapping of multi-page buffers into contiguous virtual space
- */
-
-typedef struct a_list {
-       void            *vm_addr;
-       struct a_list   *next;
-} a_list_t;
-
-STATIC a_list_t                *as_free_head;
-STATIC int             as_list_len;
-STATIC spinlock_t      as_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * Try to batch vunmaps because they are costly.
- */
-STATIC void
-free_address(
-       void            *addr)
-{
-       a_list_t        *aentry;
-
-       aentry = kmalloc(sizeof(a_list_t), GFP_ATOMIC);
-       if (aentry) {
-               spin_lock(&as_lock);
-               aentry->next = as_free_head;
-               aentry->vm_addr = addr;
-               as_free_head = aentry;
-               as_list_len++;
-               spin_unlock(&as_lock);
-       } else {
-               vunmap(addr);
-       }
-}
-
-STATIC void
-purge_addresses(void)
-{
-       a_list_t        *aentry, *old;
-
-       if (as_free_head == NULL)
-               return;
-
-       spin_lock(&as_lock);
-       aentry = as_free_head;
-       as_free_head = NULL;
-       as_list_len = 0;
-       spin_unlock(&as_lock);
-
-       while ((old = aentry) != NULL) {
-               vunmap(aentry->vm_addr);
-               aentry = aentry->next;
-               kfree(old);
-       }
-}
-
-/*
- *     Internal pagebuf object manipulation
- */
-
-STATIC void
-_pagebuf_initialize(
-       xfs_buf_t               *pb,
-       xfs_buftarg_t           *target,
-       loff_t                  range_base,
-       size_t                  range_length,
-       page_buf_flags_t        flags)
-{
-       /*
-        * We don't want certain flags to appear in pb->pb_flags.
-        */
-       flags &= ~(PBF_LOCK|PBF_MAPPED|PBF_DONT_BLOCK|PBF_READ_AHEAD);
-
-       memset(pb, 0, sizeof(xfs_buf_t));
-       atomic_set(&pb->pb_hold, 1);
-       init_MUTEX_LOCKED(&pb->pb_iodonesema);
-       INIT_LIST_HEAD(&pb->pb_list);
-       INIT_LIST_HEAD(&pb->pb_hash_list);
-       init_MUTEX_LOCKED(&pb->pb_sema); /* held, no waiters */
-       PB_SET_OWNER(pb);
-       pb->pb_target = target;
-       pb->pb_file_offset = range_base;
-       /*
-        * Set buffer_length and count_desired to the same value initially.
-        * I/O routines should use count_desired, which will be the same in
-        * most cases but may be reset (e.g. XFS recovery).
-        */
-       pb->pb_buffer_length = pb->pb_count_desired = range_length;
-       pb->pb_flags = flags | PBF_NONE;
-       pb->pb_bn = XFS_BUF_DADDR_NULL;
-       atomic_set(&pb->pb_pin_count, 0);
-       init_waitqueue_head(&pb->pb_waiters);
-
-       XFS_STATS_INC(pb_create);
-       PB_TRACE(pb, "initialize", target);
-}
-
-/*
- * Allocate a page array capable of holding a specified number
- * of pages, and point the page buf at it.
- */
-STATIC int
-_pagebuf_get_pages(
-       xfs_buf_t               *pb,
-       int                     page_count,
-       page_buf_flags_t        flags)
-{
-       /* Make sure that we have a page list */
-       if (pb->pb_pages == NULL) {
-               pb->pb_offset = page_buf_poff(pb->pb_file_offset);
-               pb->pb_page_count = page_count;
-               if (page_count <= PB_PAGES) {
-                       pb->pb_pages = pb->pb_page_array;
-               } else {
-                       pb->pb_pages = kmem_alloc(sizeof(struct page *) *
-                                       page_count, pb_to_km(flags));
-                       if (pb->pb_pages == NULL)
-                               return -ENOMEM;
-               }
-               memset(pb->pb_pages, 0, sizeof(struct page *) * page_count);
-       }
-       return 0;
-}
-
-/*
- *     Frees pb_pages if it was malloced.
- */
-STATIC void
-_pagebuf_free_pages(
-       xfs_buf_t       *bp)
-{
-       if (bp->pb_pages != bp->pb_page_array) {
-               kmem_free(bp->pb_pages,
-                         bp->pb_page_count * sizeof(struct page *));
-       }
-}
-
-/*
- *     Releases the specified buffer.
- *
- *     The modification state of any associated pages is left unchanged.
- *     The buffer most not be on any hash - use pagebuf_rele instead for
- *     hashed and refcounted buffers
- */
-void
-pagebuf_free(
-       xfs_buf_t               *bp)
-{
-       PB_TRACE(bp, "free", 0);
-
-       ASSERT(list_empty(&bp->pb_hash_list));
-
-       if (bp->pb_flags & _PBF_PAGE_CACHE) {
-               uint            i;
-
-               if ((bp->pb_flags & PBF_MAPPED) && (bp->pb_page_count > 1))
-                       free_address(bp->pb_addr - bp->pb_offset);
-
-               for (i = 0; i < bp->pb_page_count; i++)
-                       page_cache_release(bp->pb_pages[i]);
-               _pagebuf_free_pages(bp);
-       } else if (bp->pb_flags & _PBF_KMEM_ALLOC) {
-                /*
-                 * XXX(hch): bp->pb_count_desired might be incorrect (see
-                 * pagebuf_associate_memory for details), but fortunately
-                 * the Linux version of kmem_free ignores the len argument..
-                 */
-               kmem_free(bp->pb_addr, bp->pb_count_desired);
-               _pagebuf_free_pages(bp);
-       }
-
-       pagebuf_deallocate(bp);
-}
-
-/*
- *     Finds all pages for buffer in question and builds it's page list.
- */
-STATIC int
-_pagebuf_lookup_pages(
-       xfs_buf_t               *bp,
-       uint                    flags)
-{
-       struct address_space    *mapping = bp->pb_target->pbr_mapping;
-       unsigned int            sectorshift = bp->pb_target->pbr_sshift;
-       size_t                  blocksize = bp->pb_target->pbr_bsize;
-       size_t                  size = bp->pb_count_desired;
-       size_t                  nbytes, offset;
-       int                     gfp_mask = pb_to_gfp(flags);
-       unsigned short          page_count, i;
-       pgoff_t                 first;
-       loff_t                  end;
-       int                     error;
-
-       end = bp->pb_file_offset + bp->pb_buffer_length;
-       page_count = page_buf_btoc(end) - page_buf_btoct(bp->pb_file_offset);
-
-       error = _pagebuf_get_pages(bp, page_count, flags);
-       if (unlikely(error))
-               return error;
-
-       offset = bp->pb_offset;
-       first = bp->pb_file_offset >> PAGE_CACHE_SHIFT;
-
-       for (i = 0; i < bp->pb_page_count; i++) {
-               struct page     *page;
-               uint            retries = 0;
-
-             retry:
-               page = find_or_create_page(mapping, first + i, gfp_mask);
-               if (unlikely(page == NULL)) {
-                       if (flags & PBF_READ_AHEAD)
-                               return -ENOMEM;
-
-                       /*
-                        * This could deadlock.
-                        *
-                        * But until all the XFS lowlevel code is revamped to
-                        * handle buffer allocation failures we can't do much.
-                        */
-                       if (!(++retries % 100)) {
-                               printk(KERN_ERR "possibly deadlocking in %s\n",
-                                               __FUNCTION__);
-                       }
-
-                       XFS_STATS_INC(pb_page_retries);
-                       pagebuf_daemon_wakeup();
-                       current->state = TASK_UNINTERRUPTIBLE;
-                       schedule_timeout(10);
-                       goto retry;
-               }
-
-               XFS_STATS_INC(pb_page_found);
-
-               nbytes = min_t(size_t, size, PAGE_CACHE_SIZE - offset);
-               size -= nbytes;
-
-               if (!PageUptodate(page)) {
-                       page_count--;
-                       if (blocksize == PAGE_CACHE_SIZE) {
-                               if (flags & PBF_READ)
-                                       bp->pb_locked = 1;
-                       } else if (!PagePrivate(page)) {
-                               unsigned long   j, range;
-
-                               /*
-                                * In this case page->private holds a bitmap
-                                * of uptodate sectors within the page
-                                */
-                               ASSERT(blocksize < PAGE_CACHE_SIZE);
-                               range = (offset + nbytes) >> sectorshift;
-                               for (j = offset >> sectorshift; j < range; j++)
-                                       if (!test_bit(j, &page->private))
-                                               break;
-                               if (j == range)
-                                       page_count++;
-                       }
-               }
-
-               bp->pb_pages[i] = page;
-               offset = 0;
-       }
-
-       if (!bp->pb_locked) {
-               for (i = 0; i < bp->pb_page_count; i++)
-                       unlock_page(bp->pb_pages[i]);
-       }
-
-       bp->pb_flags |= _PBF_PAGE_CACHE;
-
-       if (page_count) {
-               /* if we have any uptodate pages, mark that in the buffer */
-               bp->pb_flags &= ~PBF_NONE;
-
-               /* if some pages aren't uptodate, mark that in the buffer */
-               if (page_count != bp->pb_page_count)
-                       bp->pb_flags |= PBF_PARTIAL;
-       }
-
-       PB_TRACE(bp, "lookup_pages", (long)page_count);
-       return error;
-}
-
-/*
- *     Map buffer into kernel address-space if nessecary.
- */
-STATIC int
-_pagebuf_map_pages(
-       xfs_buf_t               *bp,
-       uint                    flags)
-{
-       /* A single page buffer is always mappable */
-       if (bp->pb_page_count == 1) {
-               bp->pb_addr = page_address(bp->pb_pages[0]) + bp->pb_offset;
-               bp->pb_flags |= PBF_MAPPED;
-       } else if (flags & PBF_MAPPED) {
-               if (as_list_len > 64)
-                       purge_addresses();
-               bp->pb_addr = vmap(bp->pb_pages, bp->pb_page_count,
-                               VM_MAP, PAGE_KERNEL);
-               if (unlikely(bp->pb_addr == NULL))
-                       return -ENOMEM;
-               bp->pb_addr += bp->pb_offset;
-               bp->pb_flags |= PBF_MAPPED;
-       }
-
-       return 0;
-}
-
-/*
- *     Finding and Reading Buffers
- */
-
-/*
- *     _pagebuf_find
- *
- *     Looks up, and creates if absent, a lockable buffer for
- *     a given range of an inode.  The buffer is returned
- *     locked.  If other overlapping buffers exist, they are
- *     released before the new buffer is created and locked,
- *     which may imply that this call will block until those buffers
- *     are unlocked.  No I/O is implied by this call.
- */
-STATIC xfs_buf_t *
-_pagebuf_find(                         /* find buffer for block        */
-       xfs_buftarg_t           *target,/* target for block             */
-       loff_t                  ioff,   /* starting offset of range     */
-       size_t                  isize,  /* length of range              */
-       page_buf_flags_t        flags,  /* PBF_TRYLOCK                  */
-       xfs_buf_t               *new_pb)/* newly allocated buffer       */
-{
-       loff_t                  range_base;
-       size_t                  range_length;
-       int                     hval;
-       pb_hash_t               *h;
-       xfs_buf_t               *pb, *n;
-       int                     not_locked;
-
-       range_base = (ioff << BBSHIFT);
-       range_length = (isize << BBSHIFT);
-
-       /* Ensure we never do IOs smaller than the sector size */
-       BUG_ON(range_length < (1 << target->pbr_sshift));
-
-       /* Ensure we never do IOs that are not sector aligned */
-       BUG_ON(range_base & (loff_t)target->pbr_smask);
-
-       hval = _bhash(target->pbr_bdev, range_base);
-       h = &pbhash[hval];
-
-       spin_lock(&h->pb_hash_lock);
-       list_for_each_entry_safe(pb, n, &h->pb_hash, pb_hash_list) {
-               if (pb->pb_target == target &&
-                   pb->pb_file_offset == range_base &&
-                   pb->pb_buffer_length == range_length) {
-                       /* If we look at something bring it to the
-                        * front of the list for next time
-                        */
-                       atomic_inc(&pb->pb_hold);
-                       list_move(&pb->pb_hash_list, &h->pb_hash);
-                       goto found;
-               }
-       }
-
-       /* No match found */
-       if (new_pb) {
-               _pagebuf_initialize(new_pb, target, range_base,
-                               range_length, flags);
-               new_pb->pb_hash_index = hval;
-               list_add(&new_pb->pb_hash_list, &h->pb_hash);
-       } else {
-               XFS_STATS_INC(pb_miss_locked);
-       }
-
-       spin_unlock(&h->pb_hash_lock);
-       return (new_pb);
-
-found:
-       spin_unlock(&h->pb_hash_lock);
-
-       /* Attempt to get the semaphore without sleeping,
-        * if this does not work then we need to drop the
-        * spinlock and do a hard attempt on the semaphore.
-        */
-       not_locked = down_trylock(&pb->pb_sema);
-       if (not_locked) {
-               if (!(flags & PBF_TRYLOCK)) {
-                       /* wait for buffer ownership */
-                       PB_TRACE(pb, "get_lock", 0);
-                       pagebuf_lock(pb);
-                       XFS_STATS_INC(pb_get_locked_waited);
-               } else {
-                       /* We asked for a trylock and failed, no need
-                        * to look at file offset and length here, we
-                        * know that this pagebuf at least overlaps our
-                        * pagebuf and is locked, therefore our buffer
-                        * either does not exist, or is this buffer
-                        */
-
-                       pagebuf_rele(pb);
-                       XFS_STATS_INC(pb_busy_locked);
-                       return (NULL);
-               }
-       } else {
-               /* trylock worked */
-               PB_SET_OWNER(pb);
-       }
-
-       if (pb->pb_flags & PBF_STALE)
-               pb->pb_flags &= PBF_MAPPED;
-       PB_TRACE(pb, "got_lock", 0);
-       XFS_STATS_INC(pb_get_locked);
-       return (pb);
-}
-
-
-/*
- *     pagebuf_find
- *
- *     pagebuf_find returns a buffer matching the specified range of
- *     data for the specified target, if any of the relevant blocks
- *     are in memory.  The buffer may have unallocated holes, if
- *     some, but not all, of the blocks are in memory.  Even where
- *     pages are present in the buffer, not all of every page may be
- *     valid.
- */
-xfs_buf_t *
-pagebuf_find(                          /* find buffer for block        */
-                                       /* if the block is in memory    */
-       xfs_buftarg_t           *target,/* target for block             */
-       loff_t                  ioff,   /* starting offset of range     */
-       size_t                  isize,  /* length of range              */
-       page_buf_flags_t        flags)  /* PBF_TRYLOCK                  */
-{
-       return _pagebuf_find(target, ioff, isize, flags, NULL);
-}
-
-/*
- *     pagebuf_get
- *
- *     pagebuf_get assembles a buffer covering the specified range.
- *     Some or all of the blocks in the range may be valid.  Storage
- *     in memory for all portions of the buffer will be allocated,
- *     although backing storage may not be.  If PBF_READ is set in
- *     flags, pagebuf_iostart is called also.
- */
-xfs_buf_t *
-pagebuf_get(                           /* allocate a buffer            */
-       xfs_buftarg_t           *target,/* target for buffer            */
-       loff_t                  ioff,   /* starting offset of range     */
-       size_t                  isize,  /* length of range              */
-       page_buf_flags_t        flags)  /* PBF_TRYLOCK                  */
-{
-       xfs_buf_t               *pb, *new_pb;
-       int                     error = 0, i;
-
-       new_pb = pagebuf_allocate(flags);
-       if (unlikely(!new_pb))
-               return NULL;
-
-       pb = _pagebuf_find(target, ioff, isize, flags, new_pb);
-       if (pb == new_pb) {
-               error = _pagebuf_lookup_pages(pb, flags);
-               if (unlikely(error)) {
-                       printk(KERN_WARNING
-                              "pagebuf_get: failed to lookup pages\n");
-                       goto no_buffer;
-               }
-       } else {
-               pagebuf_deallocate(new_pb);
-               if (unlikely(pb == NULL))
-                       return NULL;
-       }
-
-       for (i = 0; i < pb->pb_page_count; i++)
-               mark_page_accessed(pb->pb_pages[i]);
-
-       if (!(pb->pb_flags & PBF_MAPPED)) {
-               error = _pagebuf_map_pages(pb, flags);
-               if (unlikely(error)) {
-                       printk(KERN_WARNING
-                              "pagebuf_get: failed to map pages\n");
-                       goto no_buffer;
-               }
-       }
-
-       XFS_STATS_INC(pb_get);
-
-       /*
-        * Always fill in the block number now, the mapped cases can do
-        * their own overlay of this later.
-        */
-       pb->pb_bn = ioff;
-       pb->pb_count_desired = pb->pb_buffer_length;
-
-       if (flags & PBF_READ) {
-               if (PBF_NOT_DONE(pb)) {
-                       PB_TRACE(pb, "get_read", (unsigned long)flags);
-                       XFS_STATS_INC(pb_get_read);
-                       pagebuf_iostart(pb, flags);
-               } else if (flags & PBF_ASYNC) {
-                       PB_TRACE(pb, "get_read_async", (unsigned long)flags);
-                       /*
-                        * Read ahead call which is already satisfied,
-                        * drop the buffer
-                        */
-                       goto no_buffer;
-               } else {
-                       PB_TRACE(pb, "get_read_done", (unsigned long)flags);
-                       /* We do not want read in the flags */
-                       pb->pb_flags &= ~PBF_READ;
-               }
-       } else {
-               PB_TRACE(pb, "get_write", (unsigned long)flags);
-       }
-
-       return pb;
-
-no_buffer:
-       if (flags & (PBF_LOCK | PBF_TRYLOCK))
-               pagebuf_unlock(pb);
-       pagebuf_rele(pb);
-       return NULL;
-}
-
-/*
- * Create a skeletal pagebuf (no pages associated with it).
- */
-xfs_buf_t *
-pagebuf_lookup(
-       xfs_buftarg_t           *target,
-       loff_t                  ioff,
-       size_t                  isize,
-       page_buf_flags_t        flags)
-{
-       xfs_buf_t               *pb;
-
-       pb = pagebuf_allocate(flags);
-       if (pb) {
-               _pagebuf_initialize(pb, target, ioff, isize, flags);
-       }
-       return pb;
-}
-
-/*
- * If we are not low on memory then do the readahead in a deadlock
- * safe manner.
- */
-void
-pagebuf_readahead(
-       xfs_buftarg_t           *target,
-       loff_t                  ioff,
-       size_t                  isize,
-       page_buf_flags_t        flags)
-{
-       struct backing_dev_info *bdi;
-
-       bdi = target->pbr_mapping->backing_dev_info;
-       if (bdi_read_congested(bdi))
-               return;
-       if (bdi_write_congested(bdi))
-               return;
-
-       flags |= (PBF_TRYLOCK|PBF_READ|PBF_ASYNC|PBF_READ_AHEAD);
-       pagebuf_get(target, ioff, isize, flags);
-}
-
-xfs_buf_t *
-pagebuf_get_empty(
-       size_t                  len,
-       xfs_buftarg_t           *target)
-{
-       xfs_buf_t               *pb;
-
-       pb = pagebuf_allocate(0);
-       if (pb)
-               _pagebuf_initialize(pb, target, 0, len, 0);
-       return pb;
-}
-
-static inline struct page *
-mem_to_page(
-       void                    *addr)
-{
-       if (((unsigned long)addr < VMALLOC_START) ||
-           ((unsigned long)addr >= VMALLOC_END)) {
-               return virt_to_page(addr);
-       } else {
-               return vmalloc_to_page(addr);
-       }
-}
-
-int
-pagebuf_associate_memory(
-       xfs_buf_t               *pb,
-       void                    *mem,
-       size_t                  len)
-{
-       int                     rval;
-       int                     i = 0;
-       size_t                  ptr;
-       size_t                  end, end_cur;
-       off_t                   offset;
-       int                     page_count;
-
-       page_count = PAGE_CACHE_ALIGN(len) >> PAGE_CACHE_SHIFT;
-       offset = (off_t) mem - ((off_t)mem & PAGE_CACHE_MASK);
-       if (offset && (len > PAGE_CACHE_SIZE))
-               page_count++;
-
-       /* Free any previous set of page pointers */
-       if (pb->pb_pages)
-               _pagebuf_free_pages(pb);
-
-       pb->pb_pages = NULL;
-       pb->pb_addr = mem;
-
-       rval = _pagebuf_get_pages(pb, page_count, 0);
-       if (rval)
-               return rval;
-
-       pb->pb_offset = offset;
-       ptr = (size_t) mem & PAGE_CACHE_MASK;
-       end = PAGE_CACHE_ALIGN((size_t) mem + len);
-       end_cur = end;
-       /* set up first page */
-       pb->pb_pages[0] = mem_to_page(mem);
-
-       ptr += PAGE_CACHE_SIZE;
-       pb->pb_page_count = ++i;
-       while (ptr < end) {
-               pb->pb_pages[i] = mem_to_page((void *)ptr);
-               pb->pb_page_count = ++i;
-               ptr += PAGE_CACHE_SIZE;
-       }
-       pb->pb_locked = 0;
-
-       pb->pb_count_desired = pb->pb_buffer_length = len;
-       pb->pb_flags |= PBF_MAPPED;
-
-       return 0;
-}
-
-xfs_buf_t *
-pagebuf_get_no_daddr(
-       size_t                  len,
-       xfs_buftarg_t           *target)
-{
-       size_t                  malloc_len = len;
-       xfs_buf_t               *bp;
-       void                    *data;
-       int                     error;
-
-       if (unlikely(len > 0x20000))
-               goto fail;
-
-       bp = pagebuf_allocate(0);
-       if (unlikely(bp == NULL))
-               goto fail;
-       _pagebuf_initialize(bp, target, 0, len, PBF_FORCEIO);
-
- try_again:
-       data = kmem_alloc(malloc_len, KM_SLEEP);
-       if (unlikely(data == NULL))
-               goto fail_free_buf;
-
-       /* check whether alignment matches.. */
-       if ((__psunsigned_t)data !=
-           ((__psunsigned_t)data & ~target->pbr_smask)) {
-               /* .. else double the size and try again */
-               kmem_free(data, malloc_len);
-               malloc_len <<= 1;
-               goto try_again;
-       }
-
-       error = pagebuf_associate_memory(bp, data, len);
-       if (error)
-               goto fail_free_mem;
-       bp->pb_flags |= _PBF_KMEM_ALLOC;
-
-       pagebuf_unlock(bp);
-
-       PB_TRACE(bp, "no_daddr", data);
-       return bp;
- fail_free_mem:
-       kmem_free(data, malloc_len);
- fail_free_buf:
-       pagebuf_free(bp);
- fail:
-       return NULL;
-}
-
-/*
- *     pagebuf_hold
- *
- *     Increment reference count on buffer, to hold the buffer concurrently
- *     with another thread which may release (free) the buffer asynchronously.
- *
- *     Must hold the buffer already to call this function.
- */
-void
-pagebuf_hold(
-       xfs_buf_t               *pb)
-{
-       atomic_inc(&pb->pb_hold);
-       PB_TRACE(pb, "hold", 0);
-}
-
-/*
- *     pagebuf_rele
- *
- *     pagebuf_rele releases a hold on the specified buffer.  If the
- *     the hold count is 1, pagebuf_rele calls pagebuf_free.
- */
-void
-pagebuf_rele(
-       xfs_buf_t               *pb)
-{
-       pb_hash_t               *hash = pb_hash(pb);
-
-       PB_TRACE(pb, "rele", pb->pb_relse);
-
-       if (atomic_dec_and_lock(&pb->pb_hold, &hash->pb_hash_lock)) {
-               int             do_free = 1;
-
-               if (pb->pb_relse) {
-                       atomic_inc(&pb->pb_hold);
-                       spin_unlock(&hash->pb_hash_lock);
-                       (*(pb->pb_relse)) (pb);
-                       spin_lock(&hash->pb_hash_lock);
-                       do_free = 0;
-               }
-
-               if (pb->pb_flags & PBF_DELWRI) {
-                       pb->pb_flags |= PBF_ASYNC;
-                       atomic_inc(&pb->pb_hold);
-                       pagebuf_delwri_queue(pb, 0);
-                       do_free = 0;
-               } else if (pb->pb_flags & PBF_FS_MANAGED) {
-                       do_free = 0;
-               }
-
-               if (do_free) {
-                       list_del_init(&pb->pb_hash_list);
-                       spin_unlock(&hash->pb_hash_lock);
-                       pagebuf_free(pb);
-               } else {
-                       spin_unlock(&hash->pb_hash_lock);
-               }
-       }
-}
-
-
-/*
- *     Mutual exclusion on buffers.  Locking model:
- *
- *     Buffers associated with inodes for which buffer locking
- *     is not enabled are not protected by semaphores, and are
- *     assumed to be exclusively owned by the caller.  There is a
- *     spinlock in the buffer, used by the caller when concurrent
- *     access is possible.
- */
-
-/*
- *     pagebuf_cond_lock
- *
- *     pagebuf_cond_lock locks a buffer object, if it is not already locked.
- *     Note that this in no way
- *     locks the underlying pages, so it is only useful for synchronizing
- *     concurrent use of page buffer objects, not for synchronizing independent
- *     access to the underlying pages.
- */
-int
-pagebuf_cond_lock(                     /* lock buffer, if not locked   */
-                                       /* returns -EBUSY if locked)    */
-       xfs_buf_t               *pb)
-{
-       int                     locked;
-
-       locked = down_trylock(&pb->pb_sema) == 0;
-       if (locked) {
-               PB_SET_OWNER(pb);
-       }
-       PB_TRACE(pb, "cond_lock", (long)locked);
-       return(locked ? 0 : -EBUSY);
-}
-
-/*
- *     pagebuf_lock_value
- *
- *     Return lock value for a pagebuf
- */
-int
-pagebuf_lock_value(
-       xfs_buf_t               *pb)
-{
-       return(atomic_read(&pb->pb_sema.count));
-}
-
-/*
- *     pagebuf_lock
- *
- *     pagebuf_lock locks a buffer object.  Note that this in no way
- *     locks the underlying pages, so it is only useful for synchronizing
- *     concurrent use of page buffer objects, not for synchronizing independent
- *     access to the underlying pages.
- */
-int
-pagebuf_lock(
-       xfs_buf_t               *pb)
-{
-       PB_TRACE(pb, "lock", 0);
-       if (atomic_read(&pb->pb_io_remaining))
-               blk_run_address_space(pb->pb_target->pbr_mapping);
-       down(&pb->pb_sema);
-       PB_SET_OWNER(pb);
-       PB_TRACE(pb, "locked", 0);
-       return 0;
-}
-
-/*
- *     pagebuf_unlock
- *
- *     pagebuf_unlock releases the lock on the buffer object created by
- *     pagebuf_lock or pagebuf_cond_lock (not any
- *     pinning of underlying pages created by pagebuf_pin).
- */
-void
-pagebuf_unlock(                                /* unlock buffer                */
-       xfs_buf_t               *pb)    /* buffer to unlock             */
-{
-       PB_CLEAR_OWNER(pb);
-       up(&pb->pb_sema);
-       PB_TRACE(pb, "unlock", 0);
-}
-
-
-/*
- *     Pinning Buffer Storage in Memory
- */
-
-/*
- *     pagebuf_pin
- *
- *     pagebuf_pin locks all of the memory represented by a buffer in
- *     memory.  Multiple calls to pagebuf_pin and pagebuf_unpin, for
- *     the same or different buffers affecting a given page, will
- *     properly count the number of outstanding "pin" requests.  The
- *     buffer may be released after the pagebuf_pin and a different
- *     buffer used when calling pagebuf_unpin, if desired.
- *     pagebuf_pin should be used by the file system when it wants be
- *     assured that no attempt will be made to force the affected
- *     memory to disk.  It does not assure that a given logical page
- *     will not be moved to a different physical page.
- */
-void
-pagebuf_pin(
-       xfs_buf_t               *pb)
-{
-       atomic_inc(&pb->pb_pin_count);
-       PB_TRACE(pb, "pin", (long)pb->pb_pin_count.counter);
-}
-
-/*
- *     pagebuf_unpin
- *
- *     pagebuf_unpin reverses the locking of memory performed by
- *     pagebuf_pin.  Note that both functions affected the logical
- *     pages associated with the buffer, not the buffer itself.
- */
-void
-pagebuf_unpin(
-       xfs_buf_t               *pb)
-{
-       if (atomic_dec_and_test(&pb->pb_pin_count)) {
-               wake_up_all(&pb->pb_waiters);
-       }
-       PB_TRACE(pb, "unpin", (long)pb->pb_pin_count.counter);
-}
-
-int
-pagebuf_ispin(
-       xfs_buf_t               *pb)
-{
-       return atomic_read(&pb->pb_pin_count);
-}
-
-/*
- *     pagebuf_wait_unpin
- *
- *     pagebuf_wait_unpin waits until all of the memory associated
- *     with the buffer is not longer locked in memory.  It returns
- *     immediately if none of the affected pages are locked.
- */
-static inline void
-_pagebuf_wait_unpin(
-       xfs_buf_t               *pb)
-{
-       DECLARE_WAITQUEUE       (wait, current);
-
-       if (atomic_read(&pb->pb_pin_count) == 0)
-               return;
-
-       add_wait_queue(&pb->pb_waiters, &wait);
-       for (;;) {
-               current->state = TASK_UNINTERRUPTIBLE;
-               if (atomic_read(&pb->pb_pin_count) == 0)
-                       break;
-               if (atomic_read(&pb->pb_io_remaining))
-                       blk_run_address_space(pb->pb_target->pbr_mapping);
-               schedule();
-       }
-       remove_wait_queue(&pb->pb_waiters, &wait);
-       current->state = TASK_RUNNING;
-}
-
-/*
- *     Buffer Utility Routines
- */
-
-/*
- *     pagebuf_iodone
- *
- *     pagebuf_iodone marks a buffer for which I/O is in progress
- *     done with respect to that I/O.  The pb_iodone routine, if
- *     present, will be called as a side-effect.
- */
-void
-pagebuf_iodone_work(
-       void                    *v)
-{
-       xfs_buf_t               *bp = (xfs_buf_t *)v;
-
-       if (bp->pb_iodone)
-               (*(bp->pb_iodone))(bp);
-       else if (bp->pb_flags & PBF_ASYNC)
-               xfs_buf_relse(bp);
-}
-
-void
-pagebuf_iodone(
-       xfs_buf_t               *pb,
-       int                     dataio,
-       int                     schedule)
-{
-       pb->pb_flags &= ~(PBF_READ | PBF_WRITE);
-       if (pb->pb_error == 0) {
-               pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE);
-       }
-
-       PB_TRACE(pb, "iodone", pb->pb_iodone);
-
-       if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
-               if (schedule) {
-                       INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb);
-                       queue_work(dataio ? pagebuf_dataio_workqueue :
-                               pagebuf_logio_workqueue, &pb->pb_iodone_work);
-               } else {
-                       pagebuf_iodone_work(pb);
-               }
-       } else {
-               up(&pb->pb_iodonesema);
-       }
-}
-
-/*
- *     pagebuf_ioerror
- *
- *     pagebuf_ioerror sets the error code for a buffer.
- */
-void
-pagebuf_ioerror(                       /* mark/clear buffer error flag */
-       xfs_buf_t               *pb,    /* buffer to mark               */
-       int                     error)  /* error to store (0 if none)   */
-{
-       ASSERT(error >= 0 && error <= 0xffff);
-       pb->pb_error = (unsigned short)error;
-       PB_TRACE(pb, "ioerror", (unsigned long)error);
-}
-
-/*
- *     pagebuf_iostart
- *
- *     pagebuf_iostart initiates I/O on a buffer, based on the flags supplied.
- *     If necessary, it will arrange for any disk space allocation required,
- *     and it will break up the request if the block mappings require it.
- *     The pb_iodone routine in the buffer supplied will only be called
- *     when all of the subsidiary I/O requests, if any, have been completed.
- *     pagebuf_iostart calls the pagebuf_ioinitiate routine or
- *     pagebuf_iorequest, if the former routine is not defined, to start
- *     the I/O on a given low-level request.
- */
-int
-pagebuf_iostart(                       /* start I/O on a buffer          */
-       xfs_buf_t               *pb,    /* buffer to start                */
-       page_buf_flags_t        flags)  /* PBF_LOCK, PBF_ASYNC, PBF_READ, */
-                                       /* PBF_WRITE, PBF_DELWRI,         */
-                                       /* PBF_DONT_BLOCK                 */
-{
-       int                     status = 0;
-
-       PB_TRACE(pb, "iostart", (unsigned long)flags);
-
-       if (flags & PBF_DELWRI) {
-               pb->pb_flags &= ~(PBF_READ | PBF_WRITE | PBF_ASYNC);
-               pb->pb_flags |= flags & (PBF_DELWRI | PBF_ASYNC);
-               pagebuf_delwri_queue(pb, 1);
-               return status;
-       }
-
-       pb->pb_flags &= ~(PBF_READ | PBF_WRITE | PBF_ASYNC | PBF_DELWRI | \
-                       PBF_READ_AHEAD | _PBF_RUN_QUEUES);
-       pb->pb_flags |= flags & (PBF_READ | PBF_WRITE | PBF_ASYNC | \
-                       PBF_READ_AHEAD | _PBF_RUN_QUEUES);
-
-       BUG_ON(pb->pb_bn == XFS_BUF_DADDR_NULL);
-
-       /* For writes allow an alternate strategy routine to precede
-        * the actual I/O request (which may not be issued at all in
-        * a shutdown situation, for example).
-        */
-       status = (flags & PBF_WRITE) ?
-               pagebuf_iostrategy(pb) : pagebuf_iorequest(pb);
-
-       /* Wait for I/O if we are not an async request.
-        * Note: async I/O request completion will release the buffer,
-        * and that can already be done by this point.  So using the
-        * buffer pointer from here on, after async I/O, is invalid.
-        */
-       if (!status && !(flags & PBF_ASYNC))
-               status = pagebuf_iowait(pb);
-
-       return status;
-}
-
-/*
- * Helper routine for pagebuf_iorequest
- */
-
-STATIC __inline__ int
-_pagebuf_iolocked(
-       xfs_buf_t               *pb)
-{
-       ASSERT(pb->pb_flags & (PBF_READ|PBF_WRITE));
-       if (pb->pb_flags & PBF_READ)
-               return pb->pb_locked;
-       return 0;
-}
-
-STATIC __inline__ void
-_pagebuf_iodone(
-       xfs_buf_t               *pb,
-       int                     schedule)
-{
-       if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
-               pb->pb_locked = 0;
-               pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), schedule);
-       }
-}
-
-STATIC int
-bio_end_io_pagebuf(
-       struct bio              *bio,
-       unsigned int            bytes_done,
-       int                     error)
-{
-       xfs_buf_t               *pb = (xfs_buf_t *)bio->bi_private;
-       unsigned int            i, blocksize = pb->pb_target->pbr_bsize;
-       unsigned int            sectorshift = pb->pb_target->pbr_sshift;
-       struct bio_vec          *bvec = bio->bi_io_vec;
-
-       if (bio->bi_size)
-               return 1;
-
-       if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
-               pb->pb_error = EIO;
-
-       for (i = 0; i < bio->bi_vcnt; i++, bvec++) {
-               struct page     *page = bvec->bv_page;
-
-               if (pb->pb_error) {
-                       SetPageError(page);
-               } else if (blocksize == PAGE_CACHE_SIZE) {
-                       SetPageUptodate(page);
-               } else if (!PagePrivate(page) &&
-                               (pb->pb_flags & _PBF_PAGE_CACHE)) {
-                       unsigned long   j, range;
-
-                       ASSERT(blocksize < PAGE_CACHE_SIZE);
-                       range = (bvec->bv_offset + bvec->bv_len) >> sectorshift;
-                       for (j = bvec->bv_offset >> sectorshift; j < range; j++)
-                               set_bit(j, &page->private);
-                       if (page->private == (unsigned long)(PAGE_CACHE_SIZE-1))
-                               SetPageUptodate(page);
-               }
-
-               if (_pagebuf_iolocked(pb)) {
-                       unlock_page(page);
-               }
-       }
-
-       _pagebuf_iodone(pb, 1);
-       bio_put(bio);
-       return 0;
-}
-
-void
-_pagebuf_ioapply(
-       xfs_buf_t               *pb)
-{
-       int                     i, map_i, total_nr_pages, nr_pages;
-       struct bio              *bio;
-       int                     offset = pb->pb_offset;
-       int                     size = pb->pb_count_desired;
-       sector_t                sector = pb->pb_bn;
-       unsigned int            blocksize = pb->pb_target->pbr_bsize;
-       int                     locking = _pagebuf_iolocked(pb);
-
-       total_nr_pages = pb->pb_page_count;
-       map_i = 0;
-
-       /* Special code path for reading a sub page size pagebuf in --
-        * we populate up the whole page, and hence the other metadata
-        * in the same page.  This optimization is only valid when the
-        * filesystem block size and the page size are equal.
-        */
-       if ((pb->pb_buffer_length < PAGE_CACHE_SIZE) &&
-           (pb->pb_flags & PBF_READ) && locking &&
-           (blocksize == PAGE_CACHE_SIZE)) {
-               bio = bio_alloc(GFP_NOIO, 1);
-
-               bio->bi_bdev = pb->pb_target->pbr_bdev;
-               bio->bi_sector = sector - (offset >> BBSHIFT);
-               bio->bi_end_io = bio_end_io_pagebuf;
-               bio->bi_private = pb;
-
-               bio_add_page(bio, pb->pb_pages[0], PAGE_CACHE_SIZE, 0);
-               size = 0;
-
-               atomic_inc(&pb->pb_io_remaining);
-
-               goto submit_io;
-       }
-
-       /* Lock down the pages which we need to for the request */
-       if (locking && (pb->pb_flags & PBF_WRITE) && (pb->pb_locked == 0)) {
-               for (i = 0; size; i++) {
-                       int             nbytes = PAGE_CACHE_SIZE - offset;
-                       struct page     *page = pb->pb_pages[i];
-
-                       if (nbytes > size)
-                               nbytes = size;
-
-                       lock_page(page);
-
-                       size -= nbytes;
-                       offset = 0;
-               }
-               offset = pb->pb_offset;
-               size = pb->pb_count_desired;
-       }
-
-next_chunk:
-       atomic_inc(&pb->pb_io_remaining);
-       nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT);
-       if (nr_pages > total_nr_pages)
-               nr_pages = total_nr_pages;
-
-       bio = bio_alloc(GFP_NOIO, nr_pages);
-       bio->bi_bdev = pb->pb_target->pbr_bdev;
-       bio->bi_sector = sector;
-       bio->bi_end_io = bio_end_io_pagebuf;
-       bio->bi_private = pb;
-
-       for (; size && nr_pages; nr_pages--, map_i++) {
-               int     nbytes = PAGE_CACHE_SIZE - offset;
-
-               if (nbytes > size)
-                       nbytes = size;
-
-               if (bio_add_page(bio, pb->pb_pages[map_i],
-                                       nbytes, offset) < nbytes)
-                       break;
-
-               offset = 0;
-               sector += nbytes >> BBSHIFT;
-               size -= nbytes;
-               total_nr_pages--;
-       }
-
-submit_io:
-       if (likely(bio->bi_size)) {
-               submit_bio((pb->pb_flags & PBF_READ) ? READ : WRITE, bio);
-               if (size)
-                       goto next_chunk;
-       } else {
-               bio_put(bio);
-               pagebuf_ioerror(pb, EIO);
-       }
-
-       if (pb->pb_flags & _PBF_RUN_QUEUES) {
-               pb->pb_flags &= ~_PBF_RUN_QUEUES;
-               if (atomic_read(&pb->pb_io_remaining) > 1)
-                       blk_run_address_space(pb->pb_target->pbr_mapping);
-       }
-}
-
-/*
- *     pagebuf_iorequest -- the core I/O request routine.
- */
-int
-pagebuf_iorequest(                     /* start real I/O               */
-       xfs_buf_t               *pb)    /* buffer to convey to device   */
-{
-       PB_TRACE(pb, "iorequest", 0);
-
-       if (pb->pb_flags & PBF_DELWRI) {
-               pagebuf_delwri_queue(pb, 1);
-               return 0;
-       }
-
-       if (pb->pb_flags & PBF_WRITE) {
-               _pagebuf_wait_unpin(pb);
-       }
-
-       pagebuf_hold(pb);
-
-       /* Set the count to 1 initially, this will stop an I/O
-        * completion callout which happens before we have started
-        * all the I/O from calling pagebuf_iodone too early.
-        */
-       atomic_set(&pb->pb_io_remaining, 1);
-       _pagebuf_ioapply(pb);
-       _pagebuf_iodone(pb, 0);
-
-       pagebuf_rele(pb);
-       return 0;
-}
-
-/*
- *     pagebuf_iowait
- *
- *     pagebuf_iowait waits for I/O to complete on the buffer supplied.
- *     It returns immediately if no I/O is pending.  In any case, it returns
- *     the error code, if any, or 0 if there is no error.
- */
-int
-pagebuf_iowait(
-       xfs_buf_t               *pb)
-{
-       PB_TRACE(pb, "iowait", 0);
-       if (atomic_read(&pb->pb_io_remaining))
-               blk_run_address_space(pb->pb_target->pbr_mapping);
-       down(&pb->pb_iodonesema);
-       PB_TRACE(pb, "iowaited", (long)pb->pb_error);
-       return pb->pb_error;
-}
-
-caddr_t
-pagebuf_offset(
-       xfs_buf_t               *pb,
-       size_t                  offset)
-{
-       struct page             *page;
-
-       offset += pb->pb_offset;
-
-       page = pb->pb_pages[offset >> PAGE_CACHE_SHIFT];
-       return (caddr_t) page_address(page) + (offset & (PAGE_CACHE_SIZE - 1));
-}
-
-/*
- *     pagebuf_iomove
- *
- *     Move data into or out of a buffer.
- */
-void
-pagebuf_iomove(
-       xfs_buf_t               *pb,    /* buffer to process            */
-       size_t                  boff,   /* starting buffer offset       */
-       size_t                  bsize,  /* length to copy               */
-       caddr_t                 data,   /* data address                 */
-       page_buf_rw_t           mode)   /* read/write flag              */
-{
-       size_t                  bend, cpoff, csize;
-       struct page             *page;
-
-       bend = boff + bsize;
-       while (boff < bend) {
-               page = pb->pb_pages[page_buf_btoct(boff + pb->pb_offset)];
-               cpoff = page_buf_poff(boff + pb->pb_offset);
-               csize = min_t(size_t,
-                             PAGE_CACHE_SIZE-cpoff, pb->pb_count_desired-boff);
-
-               ASSERT(((csize + cpoff) <= PAGE_CACHE_SIZE));
-
-               switch (mode) {
-               case PBRW_ZERO:
-                       memset(page_address(page) + cpoff, 0, csize);
-                       break;
-               case PBRW_READ:
-                       memcpy(data, page_address(page) + cpoff, csize);
-                       break;
-               case PBRW_WRITE:
-                       memcpy(page_address(page) + cpoff, data, csize);
-               }
-
-               boff += csize;
-               data += csize;
-       }
-}
-
-/*
- *     Handling of buftargs.
- */
-
-void
-xfs_free_buftarg(
-       xfs_buftarg_t           *btp,
-       int                     external)
-{
-       xfs_flush_buftarg(btp, 1);
-       if (external)
-               xfs_blkdev_put(btp->pbr_bdev);
-       kmem_free(btp, sizeof(*btp));
-}
-
-void
-xfs_incore_relse(
-       xfs_buftarg_t           *btp,
-       int                     delwri_only,
-       int                     wait)
-{
-       invalidate_bdev(btp->pbr_bdev, 1);
-       truncate_inode_pages(btp->pbr_mapping, 0LL);
-}
-
-void
-xfs_setsize_buftarg(
-       xfs_buftarg_t           *btp,
-       unsigned int            blocksize,
-       unsigned int            sectorsize)
-{
-       btp->pbr_bsize = blocksize;
-       btp->pbr_sshift = ffs(sectorsize) - 1;
-       btp->pbr_smask = sectorsize - 1;
-
-       if (set_blocksize(btp->pbr_bdev, sectorsize)) {
-               printk(KERN_WARNING
-                       "XFS: Cannot set_blocksize to %u on device %s\n",
-                       sectorsize, XFS_BUFTARG_NAME(btp));
-       }
-}
-
-xfs_buftarg_t *
-xfs_alloc_buftarg(
-       struct block_device     *bdev)
-{
-       xfs_buftarg_t           *btp;
-
-       btp = kmem_zalloc(sizeof(*btp), KM_SLEEP);
-
-       btp->pbr_dev =  bdev->bd_dev;
-       btp->pbr_bdev = bdev;
-       btp->pbr_mapping = bdev->bd_inode->i_mapping;
-       xfs_setsize_buftarg(btp, PAGE_CACHE_SIZE, bdev_hardsect_size(bdev));
-
-       return btp;
-}
-
-
-/*
- * Pagebuf delayed write buffer handling
- */
-
-STATIC LIST_HEAD(pbd_delwrite_queue);
-STATIC spinlock_t pbd_delwrite_lock = SPIN_LOCK_UNLOCKED;
-
-STATIC void
-pagebuf_delwri_queue(
-       xfs_buf_t               *pb,
-       int                     unlock)
-{
-       PB_TRACE(pb, "delwri_q", (long)unlock);
-       ASSERT(pb->pb_flags & PBF_DELWRI);
-
-       spin_lock(&pbd_delwrite_lock);
-       /* If already in the queue, dequeue and place at tail */
-       if (!list_empty(&pb->pb_list)) {
-               if (unlock) {
-                       atomic_dec(&pb->pb_hold);
-               }
-               list_del(&pb->pb_list);
-       }
-
-       list_add_tail(&pb->pb_list, &pbd_delwrite_queue);
-       pb->pb_queuetime = jiffies;
-       spin_unlock(&pbd_delwrite_lock);
-
-       if (unlock)
-               pagebuf_unlock(pb);
-}
-
-void
-pagebuf_delwri_dequeue(
-       xfs_buf_t               *pb)
-{
-       PB_TRACE(pb, "delwri_uq", 0);
-       spin_lock(&pbd_delwrite_lock);
-       list_del_init(&pb->pb_list);
-       pb->pb_flags &= ~PBF_DELWRI;
-       spin_unlock(&pbd_delwrite_lock);
-}
-
-STATIC void
-pagebuf_runall_queues(
-       struct workqueue_struct *queue)
-{
-       flush_workqueue(queue);
-}
-
-/* Defines for pagebuf daemon */
-STATIC DECLARE_COMPLETION(pagebuf_daemon_done);
-STATIC struct task_struct *pagebuf_daemon_task;
-STATIC int pagebuf_daemon_active;
-STATIC int force_flush;
-
-STATIC void
-pagebuf_daemon_wakeup(void)
-{
-       force_flush = 1;
-       barrier();
-       wake_up_process(pagebuf_daemon_task);
-}
-
-STATIC int
-pagebuf_daemon(
-       void                    *data)
-{
-       struct list_head        tmp;
-       xfs_buf_t               *pb, *n;
-
-       /*  Set up the thread  */
-       daemonize("xfsbufd");
-       current->flags |= PF_MEMALLOC;
-
-       pagebuf_daemon_task = current;
-       pagebuf_daemon_active = 1;
-       barrier();
-
-       INIT_LIST_HEAD(&tmp);
-       do {
-               /* swsusp */
-               if (current->flags & PF_FREEZE)
-                       refrigerator(PF_FREEZE);
-
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(xfs_flush_interval);
-
-               spin_lock(&pbd_delwrite_lock);
-               list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) {
-                       PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
-                       ASSERT(pb->pb_flags & PBF_DELWRI);
-
-                       if (!pagebuf_ispin(pb) && !pagebuf_cond_lock(pb)) {
-                               if (!force_flush &&
-                                   time_before(jiffies,
-                                               pb->pb_queuetime +
-                                               xfs_age_buffer)) {
-                                       pagebuf_unlock(pb);
-                                       break;
-                               }
-
-                               pb->pb_flags &= ~PBF_DELWRI;
-                               pb->pb_flags |= PBF_WRITE;
-                               list_move(&pb->pb_list, &tmp);
-                       }
-               }
-               spin_unlock(&pbd_delwrite_lock);
-
-               while (!list_empty(&tmp)) {
-                       pb = list_entry(tmp.next, xfs_buf_t, pb_list);
-                       list_del_init(&pb->pb_list);
-                       pagebuf_iostrategy(pb);
-                       blk_run_address_space(pb->pb_target->pbr_mapping);
-               }
-
-               if (as_list_len > 0)
-                       purge_addresses();
-
-               force_flush = 0;
-       } while (pagebuf_daemon_active);
-
-       complete_and_exit(&pagebuf_daemon_done, 0);
-}
-
-/*
- * Go through all incore buffers, and release buffers if they belong to
- * the given device. This is used in filesystem error handling to
- * preserve the consistency of its metadata.
- */
-int
-xfs_flush_buftarg(
-       xfs_buftarg_t           *target,
-       int                     wait)
-{
-       struct list_head        tmp;
-       xfs_buf_t               *pb, *n;
-       int                     pincount = 0;
-
-       pagebuf_runall_queues(pagebuf_dataio_workqueue);
-       pagebuf_runall_queues(pagebuf_logio_workqueue);
-
-       INIT_LIST_HEAD(&tmp);
-       spin_lock(&pbd_delwrite_lock);
-       list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) {
-
-               if (pb->pb_target != target)
-                       continue;
-
-               ASSERT(pb->pb_flags & PBF_DELWRI);
-               PB_TRACE(pb, "walkq2", (long)pagebuf_ispin(pb));
-               if (pagebuf_ispin(pb)) {
-                       pincount++;
-                       continue;
-               }
-
-               pb->pb_flags &= ~PBF_DELWRI;
-               pb->pb_flags |= PBF_WRITE;
-               list_move(&pb->pb_list, &tmp);
-       }
-       spin_unlock(&pbd_delwrite_lock);
-
-       /*
-        * Dropped the delayed write list lock, now walk the temporary list
-        */
-       list_for_each_entry_safe(pb, n, &tmp, pb_list) {
-               if (wait)
-                       pb->pb_flags &= ~PBF_ASYNC;
-               else
-                       list_del_init(&pb->pb_list);
-
-               pagebuf_lock(pb);
-               pagebuf_iostrategy(pb);
-       }
-
-       /*
-        * Remaining list items must be flushed before returning
-        */
-       while (!list_empty(&tmp)) {
-               pb = list_entry(tmp.next, xfs_buf_t, pb_list);
-
-               list_del_init(&pb->pb_list);
-               xfs_iowait(pb);
-               xfs_buf_relse(pb);
-       }
-
-       if (wait)
-               blk_run_address_space(target->pbr_mapping);
-
-       return pincount;
-}
-
-STATIC int
-pagebuf_daemon_start(void)
-{
-       int             rval;
-
-       pagebuf_logio_workqueue = create_workqueue("xfslogd");
-       if (!pagebuf_logio_workqueue)
-               return -ENOMEM;
-
-       pagebuf_dataio_workqueue = create_workqueue("xfsdatad");
-       if (!pagebuf_dataio_workqueue) {
-               destroy_workqueue(pagebuf_logio_workqueue);
-               return -ENOMEM;
-       }
-
-       rval = kernel_thread(pagebuf_daemon, NULL, CLONE_FS|CLONE_FILES);
-       if (rval < 0) {
-               destroy_workqueue(pagebuf_logio_workqueue);
-               destroy_workqueue(pagebuf_dataio_workqueue);
-       }
-
-       return rval;
-}
-
-/*
- * pagebuf_daemon_stop
- *
- * Note: do not mark as __exit, it is called from pagebuf_terminate.
- */
-STATIC void
-pagebuf_daemon_stop(void)
-{
-       pagebuf_daemon_active = 0;
-       barrier();
-       wait_for_completion(&pagebuf_daemon_done);
-
-       destroy_workqueue(pagebuf_logio_workqueue);
-       destroy_workqueue(pagebuf_dataio_workqueue);
-}
-
-/*
- *     Initialization and Termination
- */
-
-int __init
-pagebuf_init(void)
-{
-       int                     i;
-
-       pagebuf_cache = kmem_cache_create("xfs_buf_t", sizeof(xfs_buf_t), 0,
-                       SLAB_HWCACHE_ALIGN, NULL, NULL);
-       if (pagebuf_cache == NULL) {
-               printk("pagebuf: couldn't init pagebuf cache\n");
-               pagebuf_terminate();
-               return -ENOMEM;
-       }
-
-       for (i = 0; i < NHASH; i++) {
-               spin_lock_init(&pbhash[i].pb_hash_lock);
-               INIT_LIST_HEAD(&pbhash[i].pb_hash);
-       }
-
-#ifdef PAGEBUF_TRACE
-       pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
-#endif
-
-       pagebuf_daemon_start();
-       return 0;
-}
-
-
-/*
- *     pagebuf_terminate.
- *
- *     Note: do not mark as __exit, this is also called from the __init code.
- */
-void
-pagebuf_terminate(void)
-{
-       pagebuf_daemon_stop();
-
-#ifdef PAGEBUF_TRACE
-       ktrace_free(pagebuf_trace_buf);
-#endif
-
-       kmem_cache_destroy(pagebuf_cache);
-}
diff --git a/fs/xfs/linux/xfs_buf.h b/fs/xfs/linux/xfs_buf.h
deleted file mode 100644 (file)
index f97e6c0..0000000
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * Written by Steve Lord, Jim Mostek, Russell Cattelan at SGI
- */
-
-#ifndef __XFS_BUF_H__
-#define __XFS_BUF_H__
-
-#include <linux/config.h>
-#include <linux/list.h>
-#include <linux/types.h>
-#include <linux/spinlock.h>
-#include <asm/system.h>
-#include <linux/mm.h>
-#include <linux/fs.h>
-#include <linux/buffer_head.h>
-#include <linux/uio.h>
-
-/*
- *     Base types
- */
-
-#define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL))
-
-#define page_buf_ctob(pp)      ((pp) * PAGE_CACHE_SIZE)
-#define page_buf_btoc(dd)      (((dd) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
-#define page_buf_btoct(dd)     ((dd) >> PAGE_CACHE_SHIFT)
-#define page_buf_poff(aa)      ((aa) & ~PAGE_CACHE_MASK)
-
-typedef enum page_buf_rw_e {
-       PBRW_READ = 1,                  /* transfer into target memory */
-       PBRW_WRITE = 2,                 /* transfer from target memory */
-       PBRW_ZERO = 3                   /* Zero target memory */
-} page_buf_rw_t;
-
-
-typedef enum page_buf_flags_e {                /* pb_flags values */
-       PBF_READ = (1 << 0),    /* buffer intended for reading from device */
-       PBF_WRITE = (1 << 1),   /* buffer intended for writing to device   */
-       PBF_MAPPED = (1 << 2),  /* buffer mapped (pb_addr valid)           */
-       PBF_PARTIAL = (1 << 3), /* buffer partially read                   */
-       PBF_ASYNC = (1 << 4),   /* initiator will not wait for completion  */
-       PBF_NONE = (1 << 5),    /* buffer not read at all                  */
-       PBF_DELWRI = (1 << 6),  /* buffer has dirty pages                  */
-       PBF_STALE = (1 << 7),   /* buffer has been staled, do not find it  */
-       PBF_FS_MANAGED = (1 << 8),  /* filesystem controls freeing memory  */
-       PBF_FS_DATAIOD = (1 << 9),  /* schedule IO completion on fs datad  */
-       PBF_FORCEIO = (1 << 10),    /* ignore any cache state              */
-       PBF_FLUSH = (1 << 11),      /* flush disk write cache              */
-       PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead             */
-
-       /* flags used only as arguments to access routines */
-       PBF_LOCK = (1 << 14),       /* lock requested                      */
-       PBF_TRYLOCK = (1 << 15),    /* lock requested, but do not wait     */
-       PBF_DONT_BLOCK = (1 << 16), /* do not block in current thread      */
-
-       /* flags used only internally */
-       _PBF_PAGE_CACHE = (1 << 17),/* backed by pagecache                 */
-       _PBF_KMEM_ALLOC = (1 << 18),/* backed by kmem_alloc()              */
-       _PBF_RUN_QUEUES = (1 << 19),/* run block device task queue         */
-} page_buf_flags_t;
-
-#define PBF_UPDATE (PBF_READ | PBF_WRITE)
-#define PBF_NOT_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) != 0)
-#define PBF_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) == 0)
-
-typedef struct xfs_buftarg {
-       dev_t                   pbr_dev;
-       struct block_device     *pbr_bdev;
-       struct address_space    *pbr_mapping;
-       unsigned int            pbr_bsize;
-       unsigned int            pbr_sshift;
-       size_t                  pbr_smask;
-} xfs_buftarg_t;
-
-/*
- *     xfs_buf_t:  Buffer structure for page cache-based buffers
- *
- * This buffer structure is used by the page cache buffer management routines
- * to refer to an assembly of pages forming a logical buffer.  The actual
- * I/O is performed with buffer_head or bio structures, as required by drivers,
- * for drivers which do not understand this structure.  The buffer structure is
- * used on temporary basis only, and discarded when released.
- *
- * The real data storage is recorded in the page cache.  Metadata is
- * hashed to the inode for the block device on which the file system resides.
- * File data is hashed to the inode for the file.  Pages which are only
- * partially filled with data have bits set in their block_map entry
- * to indicate which disk blocks in the page are not valid.
- */
-
-struct xfs_buf;
-typedef void (*page_buf_iodone_t)(struct xfs_buf *);
-                       /* call-back function on I/O completion */
-typedef void (*page_buf_relse_t)(struct xfs_buf *);
-                       /* call-back function on I/O completion */
-typedef int (*page_buf_bdstrat_t)(struct xfs_buf *);
-
-#define PB_PAGES       4
-
-typedef struct xfs_buf {
-       struct semaphore        pb_sema;        /* semaphore for lockables  */
-       unsigned long           pb_queuetime;   /* time buffer was queued   */
-       atomic_t                pb_pin_count;   /* pin count                */
-       wait_queue_head_t       pb_waiters;     /* unpin waiters            */
-       struct list_head        pb_list;
-       page_buf_flags_t        pb_flags;       /* status flags */
-       struct list_head        pb_hash_list;
-       xfs_buftarg_t           *pb_target;     /* logical object */
-       atomic_t                pb_hold;        /* reference count */
-       xfs_daddr_t             pb_bn;          /* block number for I/O */
-       loff_t                  pb_file_offset; /* offset in file */
-       size_t                  pb_buffer_length; /* size of buffer in bytes */
-       size_t                  pb_count_desired; /* desired transfer size */
-       void                    *pb_addr;       /* virtual address of buffer */
-       struct work_struct      pb_iodone_work;
-       atomic_t                pb_io_remaining;/* #outstanding I/O requests */
-       page_buf_iodone_t       pb_iodone;      /* I/O completion function */
-       page_buf_relse_t        pb_relse;       /* releasing function */
-       page_buf_bdstrat_t      pb_strat;       /* pre-write function */
-       struct semaphore        pb_iodonesema;  /* Semaphore for I/O waiters */
-       void                    *pb_fspriv;
-       void                    *pb_fspriv2;
-       void                    *pb_fspriv3;
-       unsigned short          pb_error;       /* error code on I/O */
-       unsigned short          pb_page_count;  /* size of page array */
-       unsigned short          pb_offset;      /* page offset in first page */
-       unsigned char           pb_locked;      /* page array is locked */
-       unsigned char           pb_hash_index;  /* hash table index     */
-       struct page             **pb_pages;     /* array of page pointers */
-       struct page             *pb_page_array[PB_PAGES]; /* inline pages */
-#ifdef PAGEBUF_LOCK_TRACKING
-       int                     pb_last_holder;
-#endif
-} xfs_buf_t;
-
-
-/* Finding and Reading Buffers */
-
-extern xfs_buf_t *pagebuf_find(        /* find buffer for block if     */
-                                       /* the block is in memory       */
-               xfs_buftarg_t *,        /* inode for block              */
-               loff_t,                 /* starting offset of range     */
-               size_t,                 /* length of range              */
-               page_buf_flags_t);      /* PBF_LOCK                     */
-
-extern xfs_buf_t *pagebuf_get(         /* allocate a buffer            */
-               xfs_buftarg_t *,        /* inode for buffer             */
-               loff_t,                 /* starting offset of range     */
-               size_t,                 /* length of range              */
-               page_buf_flags_t);      /* PBF_LOCK, PBF_READ,          */
-                                       /* PBF_ASYNC                    */
-
-extern xfs_buf_t *pagebuf_lookup(
-               xfs_buftarg_t *,
-               loff_t,                 /* starting offset of range     */
-               size_t,                 /* length of range              */
-               page_buf_flags_t);      /* PBF_READ, PBF_WRITE,         */
-                                       /* PBF_FORCEIO,                 */
-
-extern xfs_buf_t *pagebuf_get_empty(   /* allocate pagebuf struct with */
-                                       /*  no memory or disk address   */
-               size_t len,
-               xfs_buftarg_t *);       /* mount point "fake" inode     */
-
-extern xfs_buf_t *pagebuf_get_no_daddr(/* allocate pagebuf struct      */
-                                       /* without disk address         */
-               size_t len,
-               xfs_buftarg_t *);       /* mount point "fake" inode     */
-
-extern int pagebuf_associate_memory(
-               xfs_buf_t *,
-               void *,
-               size_t);
-
-extern void pagebuf_hold(              /* increment reference count    */
-               xfs_buf_t *);           /* buffer to hold               */
-
-extern void pagebuf_readahead(         /* read ahead into cache        */
-               xfs_buftarg_t  *,       /* target for buffer (or NULL)  */
-               loff_t,                 /* starting offset of range     */
-               size_t,                 /* length of range              */
-               page_buf_flags_t);      /* additional read flags        */
-
-/* Releasing Buffers */
-
-extern void pagebuf_free(              /* deallocate a buffer          */
-               xfs_buf_t *);           /* buffer to deallocate         */
-
-extern void pagebuf_rele(              /* release hold on a buffer     */
-               xfs_buf_t *);           /* buffer to release            */
-
-/* Locking and Unlocking Buffers */
-
-extern int pagebuf_cond_lock(          /* lock buffer, if not locked   */
-                                       /* (returns -EBUSY if locked)   */
-               xfs_buf_t *);           /* buffer to lock               */
-
-extern int pagebuf_lock_value(         /* return count on lock         */
-               xfs_buf_t *);          /* buffer to check              */
-
-extern int pagebuf_lock(               /* lock buffer                  */
-               xfs_buf_t *);          /* buffer to lock               */
-
-extern void pagebuf_unlock(            /* unlock buffer                */
-               xfs_buf_t *);           /* buffer to unlock             */
-
-/* Buffer Read and Write Routines */
-
-extern void pagebuf_iodone(            /* mark buffer I/O complete     */
-               xfs_buf_t *,            /* buffer to mark               */
-               int,                    /* use data/log helper thread.  */
-               int);                   /* run completion locally, or in
-                                        * a helper thread.             */
-
-extern void pagebuf_ioerror(           /* mark buffer in error (or not) */
-               xfs_buf_t *,            /* buffer to mark               */
-               int);                   /* error to store (0 if none)   */
-
-extern int pagebuf_iostart(            /* start I/O on a buffer        */
-               xfs_buf_t *,            /* buffer to start              */
-               page_buf_flags_t);      /* PBF_LOCK, PBF_ASYNC,         */
-                                       /* PBF_READ, PBF_WRITE,         */
-                                       /* PBF_DELWRI                   */
-
-extern int pagebuf_iorequest(          /* start real I/O               */
-               xfs_buf_t *);           /* buffer to convey to device   */
-
-extern int pagebuf_iowait(             /* wait for buffer I/O done     */
-               xfs_buf_t *);           /* buffer to wait on            */
-
-extern void pagebuf_iomove(            /* move data in/out of pagebuf  */
-               xfs_buf_t *,            /* buffer to manipulate         */
-               size_t,                 /* starting buffer offset       */
-               size_t,                 /* length in buffer             */
-               caddr_t,                /* data pointer                 */
-               page_buf_rw_t);         /* direction                    */
-
-static inline int pagebuf_iostrategy(xfs_buf_t *pb)
-{
-       return pb->pb_strat ? pb->pb_strat(pb) : pagebuf_iorequest(pb);
-}
-
-static inline int pagebuf_geterror(xfs_buf_t *pb)
-{
-       return pb ? pb->pb_error : ENOMEM;
-}
-
-/* Buffer Utility Routines */
-
-extern caddr_t pagebuf_offset(         /* pointer at offset in buffer  */
-               xfs_buf_t *,            /* buffer to offset into        */
-               size_t);                /* offset                       */
-
-/* Pinning Buffer Storage in Memory */
-
-extern void pagebuf_pin(               /* pin buffer in memory         */
-               xfs_buf_t *);           /* buffer to pin                */
-
-extern void pagebuf_unpin(             /* unpin buffered data          */
-               xfs_buf_t *);           /* buffer to unpin              */
-
-extern int pagebuf_ispin(              /* check if buffer is pinned    */
-               xfs_buf_t *);           /* buffer to check              */
-
-/* Delayed Write Buffer Routines */
-
-extern void pagebuf_delwri_dequeue(xfs_buf_t *);
-
-/* Buffer Daemon Setup Routines */
-
-extern int pagebuf_init(void);
-extern void pagebuf_terminate(void);
-
-
-#ifdef PAGEBUF_TRACE
-extern ktrace_t *pagebuf_trace_buf;
-extern void pagebuf_trace(
-               xfs_buf_t *,            /* buffer being traced          */
-               char *,                 /* description of operation     */
-               void *,                 /* arbitrary diagnostic value   */
-               void *);                /* return address               */
-#else
-# define pagebuf_trace(pb, id, ptr, ra)        do { } while (0)
-#endif
-
-#define pagebuf_target_name(target)    \
-       ({ char __b[BDEVNAME_SIZE]; bdevname((target)->pbr_bdev, __b); __b; })
-
-
-
-
-
-/* These are just for xfs_syncsub... it sets an internal variable
- * then passes it to VOP_FLUSH_PAGES or adds the flags to a newly gotten buf_t
- */
-#define XFS_B_ASYNC            PBF_ASYNC
-#define XFS_B_DELWRI           PBF_DELWRI
-#define XFS_B_READ             PBF_READ
-#define XFS_B_WRITE            PBF_WRITE
-#define XFS_B_STALE            PBF_STALE
-
-#define XFS_BUF_TRYLOCK                PBF_TRYLOCK
-#define XFS_INCORE_TRYLOCK     PBF_TRYLOCK
-#define XFS_BUF_LOCK           PBF_LOCK
-#define XFS_BUF_MAPPED         PBF_MAPPED
-
-#define BUF_BUSY               PBF_DONT_BLOCK
-
-#define XFS_BUF_BFLAGS(x)      ((x)->pb_flags)
-#define XFS_BUF_ZEROFLAGS(x)   \
-       ((x)->pb_flags &= ~(PBF_READ|PBF_WRITE|PBF_ASYNC|PBF_DELWRI))
-
-#define XFS_BUF_STALE(x)       ((x)->pb_flags |= XFS_B_STALE)
-#define XFS_BUF_UNSTALE(x)     ((x)->pb_flags &= ~XFS_B_STALE)
-#define XFS_BUF_ISSTALE(x)     ((x)->pb_flags & XFS_B_STALE)
-#define XFS_BUF_SUPER_STALE(x) do {                            \
-                                       XFS_BUF_STALE(x);       \
-                                       xfs_buf_undelay(x);     \
-                                       XFS_BUF_DONE(x);        \
-                               } while (0)
-
-#define XFS_BUF_MANAGE         PBF_FS_MANAGED
-#define XFS_BUF_UNMANAGE(x)    ((x)->pb_flags &= ~PBF_FS_MANAGED)
-
-static inline void xfs_buf_undelay(xfs_buf_t *pb)
-{
-       if (pb->pb_flags & PBF_DELWRI) {
-               if (pb->pb_list.next != &pb->pb_list) {
-                       pagebuf_delwri_dequeue(pb);
-                       pagebuf_rele(pb);
-               } else {
-                       pb->pb_flags &= ~PBF_DELWRI;
-               }
-       }
-}
-
-#define XFS_BUF_DELAYWRITE(x)   ((x)->pb_flags |= PBF_DELWRI)
-#define XFS_BUF_UNDELAYWRITE(x)         xfs_buf_undelay(x)
-#define XFS_BUF_ISDELAYWRITE(x)         ((x)->pb_flags & PBF_DELWRI)
-
-#define XFS_BUF_ERROR(x,no)     pagebuf_ioerror(x,no)
-#define XFS_BUF_GETERROR(x)     pagebuf_geterror(x)
-#define XFS_BUF_ISERROR(x)      (pagebuf_geterror(x)?1:0)
-
-#define XFS_BUF_DONE(x)                 ((x)->pb_flags &= ~(PBF_PARTIAL|PBF_NONE))
-#define XFS_BUF_UNDONE(x)       ((x)->pb_flags |= PBF_PARTIAL|PBF_NONE)
-#define XFS_BUF_ISDONE(x)       (!(PBF_NOT_DONE(x)))
-
-#define XFS_BUF_BUSY(x)                 ((x)->pb_flags |= PBF_FORCEIO)
-#define XFS_BUF_UNBUSY(x)       ((x)->pb_flags &= ~PBF_FORCEIO)
-#define XFS_BUF_ISBUSY(x)       (1)
-
-#define XFS_BUF_ASYNC(x)        ((x)->pb_flags |= PBF_ASYNC)
-#define XFS_BUF_UNASYNC(x)      ((x)->pb_flags &= ~PBF_ASYNC)
-#define XFS_BUF_ISASYNC(x)      ((x)->pb_flags & PBF_ASYNC)
-
-#define XFS_BUF_FLUSH(x)        ((x)->pb_flags |= PBF_FLUSH)
-#define XFS_BUF_UNFLUSH(x)      ((x)->pb_flags &= ~PBF_FLUSH)
-#define XFS_BUF_ISFLUSH(x)      ((x)->pb_flags & PBF_FLUSH)
-
-#define XFS_BUF_SHUT(x)                 printk("XFS_BUF_SHUT not implemented yet\n")
-#define XFS_BUF_UNSHUT(x)       printk("XFS_BUF_UNSHUT not implemented yet\n")
-#define XFS_BUF_ISSHUT(x)       (0)
-
-#define XFS_BUF_HOLD(x)                pagebuf_hold(x)
-#define XFS_BUF_READ(x)                ((x)->pb_flags |= PBF_READ)
-#define XFS_BUF_UNREAD(x)      ((x)->pb_flags &= ~PBF_READ)
-#define XFS_BUF_ISREAD(x)      ((x)->pb_flags & PBF_READ)
-
-#define XFS_BUF_WRITE(x)       ((x)->pb_flags |= PBF_WRITE)
-#define XFS_BUF_UNWRITE(x)     ((x)->pb_flags &= ~PBF_WRITE)
-#define XFS_BUF_ISWRITE(x)     ((x)->pb_flags & PBF_WRITE)
-
-#define XFS_BUF_ISUNINITIAL(x)  (0)
-#define XFS_BUF_UNUNINITIAL(x)  (0)
-
-#define XFS_BUF_BP_ISMAPPED(bp)         1
-
-#define XFS_BUF_DATAIO(x)      ((x)->pb_flags |= PBF_FS_DATAIOD)
-#define XFS_BUF_UNDATAIO(x)    ((x)->pb_flags &= ~PBF_FS_DATAIOD)
-
-#define XFS_BUF_IODONE_FUNC(buf)       (buf)->pb_iodone
-#define XFS_BUF_SET_IODONE_FUNC(buf, func)     \
-                       (buf)->pb_iodone = (func)
-#define XFS_BUF_CLR_IODONE_FUNC(buf)           \
-                       (buf)->pb_iodone = NULL
-#define XFS_BUF_SET_BDSTRAT_FUNC(buf, func)    \
-                       (buf)->pb_strat = (func)
-#define XFS_BUF_CLR_BDSTRAT_FUNC(buf)          \
-                       (buf)->pb_strat = NULL
-
-#define XFS_BUF_FSPRIVATE(buf, type)           \
-                       ((type)(buf)->pb_fspriv)
-#define XFS_BUF_SET_FSPRIVATE(buf, value)      \
-                       (buf)->pb_fspriv = (void *)(value)
-#define XFS_BUF_FSPRIVATE2(buf, type)          \
-                       ((type)(buf)->pb_fspriv2)
-#define XFS_BUF_SET_FSPRIVATE2(buf, value)     \
-                       (buf)->pb_fspriv2 = (void *)(value)
-#define XFS_BUF_FSPRIVATE3(buf, type)          \
-                       ((type)(buf)->pb_fspriv3)
-#define XFS_BUF_SET_FSPRIVATE3(buf, value)     \
-                       (buf)->pb_fspriv3  = (void *)(value)
-#define XFS_BUF_SET_START(buf)
-
-#define XFS_BUF_SET_BRELSE_FUNC(buf, value) \
-                       (buf)->pb_relse = (value)
-
-#define XFS_BUF_PTR(bp)                (xfs_caddr_t)((bp)->pb_addr)
-
-extern inline xfs_caddr_t xfs_buf_offset(xfs_buf_t *bp, size_t offset)
-{
-       if (bp->pb_flags & PBF_MAPPED)
-               return XFS_BUF_PTR(bp) + offset;
-       return (xfs_caddr_t) pagebuf_offset(bp, offset);
-}
-
-#define XFS_BUF_SET_PTR(bp, val, count)                \
-                               pagebuf_associate_memory(bp, val, count)
-#define XFS_BUF_ADDR(bp)       ((bp)->pb_bn)
-#define XFS_BUF_SET_ADDR(bp, blk)              \
-                       ((bp)->pb_bn = (blk))
-#define XFS_BUF_OFFSET(bp)     ((bp)->pb_file_offset)
-#define XFS_BUF_SET_OFFSET(bp, off)            \
-                       ((bp)->pb_file_offset = (off))
-#define XFS_BUF_COUNT(bp)      ((bp)->pb_count_desired)
-#define XFS_BUF_SET_COUNT(bp, cnt)             \
-                       ((bp)->pb_count_desired = (cnt))
-#define XFS_BUF_SIZE(bp)       ((bp)->pb_buffer_length)
-#define XFS_BUF_SET_SIZE(bp, cnt)              \
-                       ((bp)->pb_buffer_length = (cnt))
-#define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
-#define XFS_BUF_SET_VTYPE(bp, type)
-#define XFS_BUF_SET_REF(bp, ref)
-
-#define XFS_BUF_ISPINNED(bp)   pagebuf_ispin(bp)
-
-#define XFS_BUF_VALUSEMA(bp)   pagebuf_lock_value(bp)
-#define XFS_BUF_CPSEMA(bp)     (pagebuf_cond_lock(bp) == 0)
-#define XFS_BUF_VSEMA(bp)      pagebuf_unlock(bp)
-#define XFS_BUF_PSEMA(bp,x)    pagebuf_lock(bp)
-#define XFS_BUF_V_IODONESEMA(bp) up(&bp->pb_iodonesema);
-
-/* setup the buffer target from a buftarg structure */
-#define XFS_BUF_SET_TARGET(bp, target) \
-               (bp)->pb_target = (target)
-#define XFS_BUF_TARGET(bp)     ((bp)->pb_target)
-#define XFS_BUFTARG_NAME(target)       \
-               pagebuf_target_name(target)
-
-#define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
-#define XFS_BUF_SET_VTYPE(bp, type)
-#define XFS_BUF_SET_REF(bp, ref)
-
-#define xfs_buf_read(target, blkno, len, flags) \
-               pagebuf_get((target), (blkno), (len), \
-                       PBF_LOCK | PBF_READ | PBF_MAPPED)
-#define xfs_buf_get(target, blkno, len, flags) \
-               pagebuf_get((target), (blkno), (len), \
-                       PBF_LOCK | PBF_MAPPED)
-
-#define xfs_buf_read_flags(target, blkno, len, flags) \
-               pagebuf_get((target), (blkno), (len), PBF_READ | (flags))
-#define xfs_buf_get_flags(target, blkno, len, flags) \
-               pagebuf_get((target), (blkno), (len), (flags))
-
-static inline int      xfs_bawrite(void *mp, xfs_buf_t *bp)
-{
-       bp->pb_fspriv3 = mp;
-       bp->pb_strat = xfs_bdstrat_cb;
-       xfs_buf_undelay(bp);
-       return pagebuf_iostart(bp, PBF_WRITE | PBF_ASYNC | _PBF_RUN_QUEUES);
-}
-
-static inline void     xfs_buf_relse(xfs_buf_t *bp)
-{
-       if (!bp->pb_relse)
-               pagebuf_unlock(bp);
-       pagebuf_rele(bp);
-}
-
-#define xfs_bpin(bp)           pagebuf_pin(bp)
-#define xfs_bunpin(bp)         pagebuf_unpin(bp)
-
-#define xfs_buftrace(id, bp)   \
-           pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
-
-#define xfs_biodone(pb)                    \
-           pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0)
-
-#define xfs_incore(buftarg,blkno,len,lockit) \
-           pagebuf_find(buftarg, blkno ,len, lockit)
-
-
-#define xfs_biomove(pb, off, len, data, rw) \
-           pagebuf_iomove((pb), (off), (len), (data), \
-               ((rw) == XFS_B_WRITE) ? PBRW_WRITE : PBRW_READ)
-
-#define xfs_biozero(pb, off, len) \
-           pagebuf_iomove((pb), (off), (len), NULL, PBRW_ZERO)
-
-
-static inline int      XFS_bwrite(xfs_buf_t *pb)
-{
-       int     iowait = (pb->pb_flags & PBF_ASYNC) == 0;
-       int     error = 0;
-
-       if (!iowait)
-               pb->pb_flags |= _PBF_RUN_QUEUES;
-
-       xfs_buf_undelay(pb);
-       pagebuf_iostrategy(pb);
-       if (iowait) {
-               error = pagebuf_iowait(pb);
-               xfs_buf_relse(pb);
-       }
-       return error;
-}
-
-#define XFS_bdwrite(pb)                     \
-           pagebuf_iostart(pb, PBF_DELWRI | PBF_ASYNC)
-
-static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp)
-{
-       bp->pb_strat = xfs_bdstrat_cb;
-       bp->pb_fspriv3 = mp;
-
-       return pagebuf_iostart(bp, PBF_DELWRI | PBF_ASYNC);
-}
-
-#define XFS_bdstrat(bp) pagebuf_iorequest(bp)
-
-#define xfs_iowait(pb) pagebuf_iowait(pb)
-
-#define xfs_baread(target, rablkno, ralen)  \
-       pagebuf_readahead((target), (rablkno), (ralen), PBF_DONT_BLOCK)
-
-#define xfs_buf_get_empty(len, target) pagebuf_get_empty((len), (target))
-#define xfs_buf_get_noaddr(len, target)        pagebuf_get_no_daddr((len), (target))
-#define xfs_buf_free(bp)               pagebuf_free(bp)
-
-
-/*
- *     Handling of buftargs.
- */
-
-extern xfs_buftarg_t *xfs_alloc_buftarg(struct block_device *);
-extern void xfs_free_buftarg(xfs_buftarg_t *, int);
-extern void xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int);
-extern void xfs_incore_relse(xfs_buftarg_t *, int, int);
-extern int xfs_flush_buftarg(xfs_buftarg_t *, int);
-
-#define xfs_getsize_buftarg(buftarg) \
-       block_size((buftarg)->pbr_bdev)
-#define xfs_readonly_buftarg(buftarg) \
-       bdev_read_only((buftarg)->pbr_bdev)
-#define xfs_binval(buftarg) \
-       xfs_flush_buftarg(buftarg, 1)
-#define XFS_bflush(buftarg) \
-       xfs_flush_buftarg(buftarg, 1)
-
-#endif /* __XFS_BUF_H__ */
diff --git a/fs/xfs/linux/xfs_cred.h b/fs/xfs/linux/xfs_cred.h
deleted file mode 100644 (file)
index 00c4584..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_CRED_H__
-#define __XFS_CRED_H__
-
-/*
- * Credentials
- */
-typedef struct cred {
-       /* EMPTY */
-} cred_t;
-
-extern struct cred *sys_cred;
-
-/* this is a hack.. (assums sys_cred is the only cred_t in the system) */
-static __inline int capable_cred(cred_t *cr, int cid)
-{
-       return (cr == sys_cred) ? 1 : capable(cid);
-}
-
-#endif  /* __XFS_CRED_H__ */
diff --git a/fs/xfs/linux/xfs_file.c b/fs/xfs/linux/xfs_file.c
deleted file mode 100644 (file)
index 8d9f3b5..0000000
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_trans.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_alloc.h"
-#include "xfs_btree.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_error.h"
-#include "xfs_rw.h"
-
-#include <linux/dcache.h>
-
-static struct vm_operations_struct linvfs_file_vm_ops;
-
-
-STATIC inline ssize_t
-__linvfs_read(
-       struct kiocb            *iocb,
-       char __user             *buf,
-       int                     ioflags,
-       size_t                  count,
-       loff_t                  pos)
-{
-       struct iovec            iov = {buf, count};
-       struct file             *file = iocb->ki_filp;
-       vnode_t                 *vp = LINVFS_GET_VP(file->f_dentry->d_inode);
-       ssize_t                 rval;
-
-       BUG_ON(iocb->ki_pos != pos);
-
-       if (unlikely(file->f_flags & O_DIRECT))
-               ioflags |= IO_ISDIRECT;
-       VOP_READ(vp, iocb, &iov, 1, &iocb->ki_pos, ioflags, NULL, rval);
-       return rval;
-}
-
-
-STATIC ssize_t
-linvfs_read(
-       struct kiocb            *iocb,
-       char __user             *buf,
-       size_t                  count,
-       loff_t                  pos)
-{
-       return __linvfs_read(iocb, buf, 0, count, pos);
-}
-
-STATIC ssize_t
-linvfs_read_invis(
-       struct kiocb            *iocb,
-       char __user             *buf,
-       size_t                  count,
-       loff_t                  pos)
-{
-       return __linvfs_read(iocb, buf, IO_INVIS, count, pos);
-}
-
-
-STATIC inline ssize_t
-__linvfs_write(
-       struct kiocb    *iocb,
-       const char      *buf,
-       int             ioflags,
-       size_t          count,
-       loff_t          pos)
-{
-       struct iovec    iov = {(void *)buf, count};
-       struct file     *file = iocb->ki_filp;
-       struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       ssize_t         rval;
-
-       BUG_ON(iocb->ki_pos != pos);
-       if (unlikely(file->f_flags & O_DIRECT)) {
-               ioflags |= IO_ISDIRECT;
-               VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos,
-                               ioflags, NULL, rval);
-       } else {
-               down(&inode->i_sem);
-               VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos,
-                               ioflags, NULL, rval);
-               up(&inode->i_sem);
-       }
-
-       return rval;
-}
-
-
-STATIC ssize_t
-linvfs_write(
-       struct kiocb            *iocb,
-       const char __user       *buf,
-       size_t                  count,
-       loff_t                  pos)
-{
-       return __linvfs_write(iocb, buf, 0, count, pos);
-}
-
-STATIC ssize_t
-linvfs_write_invis(
-       struct kiocb            *iocb,
-       const char __user       *buf,
-       size_t                  count,
-       loff_t                  pos)
-{
-       return __linvfs_write(iocb, buf, IO_INVIS, count, pos);
-}
-
-
-STATIC inline ssize_t
-__linvfs_readv(
-       struct file             *file,
-       const struct iovec      *iov,
-       int                     ioflags,
-       unsigned long           nr_segs,
-       loff_t                  *ppos)
-{
-       struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       struct          kiocb kiocb;
-       ssize_t         rval;
-
-       init_sync_kiocb(&kiocb, file);
-       kiocb.ki_pos = *ppos;
-
-       if (unlikely(file->f_flags & O_DIRECT))
-               ioflags |= IO_ISDIRECT;
-       VOP_READ(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval);
-       if (rval == -EIOCBQUEUED)
-               rval = wait_on_sync_kiocb(&kiocb);
-
-       *ppos = kiocb.ki_pos;
-       return rval;
-}
-
-STATIC ssize_t
-linvfs_readv(
-       struct file             *file,
-       const struct iovec      *iov,
-       unsigned long           nr_segs,
-       loff_t                  *ppos)
-{
-       return __linvfs_readv(file, iov, 0, nr_segs, ppos);
-}
-
-STATIC ssize_t
-linvfs_readv_invis(
-       struct file             *file,
-       const struct iovec      *iov,
-       unsigned long           nr_segs,
-       loff_t                  *ppos)
-{
-       return __linvfs_readv(file, iov, IO_INVIS, nr_segs, ppos);
-}
-
-
-STATIC inline ssize_t
-__linvfs_writev(
-       struct file             *file,
-       const struct iovec      *iov,
-       int                     ioflags,
-       unsigned long           nr_segs,
-       loff_t                  *ppos)
-{
-       struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       struct          kiocb kiocb;
-       ssize_t         rval;
-
-       init_sync_kiocb(&kiocb, file);
-       kiocb.ki_pos = *ppos;
-       if (unlikely(file->f_flags & O_DIRECT)) {
-               ioflags |= IO_ISDIRECT;
-               VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos,
-                               ioflags, NULL, rval);
-       } else {
-               down(&inode->i_sem);
-               VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos,
-                               ioflags, NULL, rval);
-               up(&inode->i_sem);
-       }
-
-       if (rval == -EIOCBQUEUED)
-               rval = wait_on_sync_kiocb(&kiocb);
-
-       *ppos = kiocb.ki_pos;
-       return rval;
-}
-
-
-STATIC ssize_t
-linvfs_writev(
-       struct file             *file,
-       const struct iovec      *iov,
-       unsigned long           nr_segs,
-       loff_t                  *ppos)
-{
-       return __linvfs_writev(file, iov, 0, nr_segs, ppos);
-}
-
-STATIC ssize_t
-linvfs_writev_invis(
-       struct file             *file,
-       const struct iovec      *iov,
-       unsigned long           nr_segs,
-       loff_t                  *ppos)
-{
-       return __linvfs_writev(file, iov, IO_INVIS, nr_segs, ppos);
-}
-
-STATIC ssize_t
-linvfs_sendfile(
-       struct file             *filp,
-       loff_t                  *ppos,
-       size_t                  count,
-       read_actor_t            actor,
-       void                    *target)
-{
-       vnode_t                 *vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
-       int                     error;
-
-       VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, error);
-       return error;
-}
-
-
-STATIC int
-linvfs_open(
-       struct inode    *inode,
-       struct file     *filp)
-{
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       int             error;
-
-       if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
-               return -EFBIG;
-
-       ASSERT(vp);
-       VOP_OPEN(vp, NULL, error);
-       return -error;
-}
-
-
-STATIC int
-linvfs_release(
-       struct inode    *inode,
-       struct file     *filp)
-{
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       int             error = 0;
-
-       if (vp)
-               VOP_RELEASE(vp, error);
-       return -error;
-}
-
-
-STATIC int
-linvfs_fsync(
-       struct file     *filp,
-       struct dentry   *dentry,
-       int             datasync)
-{
-       struct inode    *inode = dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       int             error;
-       int             flags = FSYNC_WAIT;
-
-       if (datasync)
-               flags |= FSYNC_DATA;
-
-       ASSERT(vp);
-       VOP_FSYNC(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1, error);
-       return -error;
-}
-
-/*
- * linvfs_readdir maps to VOP_READDIR().
- * We need to build a uio, cred, ...
- */
-
-#define nextdp(dp)      ((struct xfs_dirent *)((char *)(dp) + (dp)->d_reclen))
-
-STATIC int
-linvfs_readdir(
-       struct file     *filp,
-       void            *dirent,
-       filldir_t       filldir)
-{
-       int             error = 0;
-       vnode_t         *vp;
-       uio_t           uio;
-       iovec_t         iov;
-       int             eof = 0;
-       caddr_t         read_buf;
-       int             namelen, size = 0;
-       size_t          rlen = PAGE_CACHE_SIZE;
-       xfs_off_t       start_offset, curr_offset;
-       xfs_dirent_t    *dbp = NULL;
-
-       vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
-       ASSERT(vp);
-
-       /* Try fairly hard to get memory */
-       do {
-               if ((read_buf = (caddr_t)kmalloc(rlen, GFP_KERNEL)))
-                       break;
-               rlen >>= 1;
-       } while (rlen >= 1024);
-
-       if (read_buf == NULL)
-               return -ENOMEM;
-
-       uio.uio_iov = &iov;
-       uio.uio_segflg = UIO_SYSSPACE;
-       curr_offset = filp->f_pos;
-       if (filp->f_pos != 0x7fffffff)
-               uio.uio_offset = filp->f_pos;
-       else
-               uio.uio_offset = 0xffffffff;
-
-       while (!eof) {
-               uio.uio_resid = iov.iov_len = rlen;
-               iov.iov_base = read_buf;
-               uio.uio_iovcnt = 1;
-
-               start_offset = uio.uio_offset;
-
-               VOP_READDIR(vp, &uio, NULL, &eof, error);
-               if ((uio.uio_offset == start_offset) || error) {
-                       size = 0;
-                       break;
-               }
-
-               size = rlen - uio.uio_resid;
-               dbp = (xfs_dirent_t *)read_buf;
-               while (size > 0) {
-                       namelen = strlen(dbp->d_name);
-
-                       if (filldir(dirent, dbp->d_name, namelen,
-                                       (loff_t) curr_offset & 0x7fffffff,
-                                       (ino_t) dbp->d_ino,
-                                       DT_UNKNOWN)) {
-                               goto done;
-                       }
-                       size -= dbp->d_reclen;
-                       curr_offset = (loff_t)dbp->d_off /* & 0x7fffffff */;
-                       dbp = nextdp(dbp);
-               }
-       }
-done:
-       if (!error) {
-               if (size == 0)
-                       filp->f_pos = uio.uio_offset & 0x7fffffff;
-               else if (dbp)
-                       filp->f_pos = curr_offset;
-       }
-
-       kfree(read_buf);
-       return -error;
-}
-
-
-STATIC int
-linvfs_file_mmap(
-       struct file     *filp,
-       struct vm_area_struct *vma)
-{
-       struct inode    *ip = filp->f_dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(ip);
-       vattr_t         va = { .va_mask = XFS_AT_UPDATIME };
-       int             error;
-
-       if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
-               xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);
-
-               error = -XFS_SEND_MMAP(mp, vma, 0);
-               if (error)
-                       return error;
-       }
-
-       vma->vm_ops = &linvfs_file_vm_ops;
-
-       VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
-       return 0;
-}
-
-
-STATIC int
-linvfs_ioctl(
-       struct inode    *inode,
-       struct file     *filp,
-       unsigned int    cmd,
-       unsigned long   arg)
-{
-       int             error;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-
-       ASSERT(vp);
-       VOP_IOCTL(vp, inode, filp, 0, cmd, arg, error);
-       VMODIFY(vp);
-
-       /* NOTE:  some of the ioctl's return positive #'s as a
-        *        byte count indicating success, such as
-        *        readlink_by_handle.  So we don't "sign flip"
-        *        like most other routines.  This means true
-        *        errors need to be returned as a negative value.
-        */
-       return error;
-}
-
-STATIC int
-linvfs_ioctl_invis(
-       struct inode    *inode,
-       struct file     *filp,
-       unsigned int    cmd,
-       unsigned long   arg)
-{
-       int             error;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-
-       ASSERT(vp);
-       VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, arg, error);
-       VMODIFY(vp);
-
-       /* NOTE:  some of the ioctl's return positive #'s as a
-        *        byte count indicating success, such as
-        *        readlink_by_handle.  So we don't "sign flip"
-        *        like most other routines.  This means true
-        *        errors need to be returned as a negative value.
-        */
-       return error;
-}
-
-#ifdef HAVE_VMOP_MPROTECT
-STATIC int
-linvfs_mprotect(
-       struct vm_area_struct *vma,
-       unsigned int    newflags)
-{
-       vnode_t         *vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode);
-       int             error = 0;
-
-       if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
-               if ((vma->vm_flags & VM_MAYSHARE) &&
-                   (newflags & VM_WRITE) && !(vma->vm_flags & VM_WRITE)) {
-                       xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);
-
-                       error = XFS_SEND_MMAP(mp, vma, VM_WRITE);
-                   }
-       }
-       return error;
-}
-#endif /* HAVE_VMOP_MPROTECT */
-
-
-struct file_operations linvfs_file_operations = {
-       .llseek         = generic_file_llseek,
-       .read           = do_sync_read,
-       .write          = do_sync_write,
-       .readv          = linvfs_readv,
-       .writev         = linvfs_writev,
-       .aio_read       = linvfs_read,
-       .aio_write      = linvfs_write,
-       .sendfile       = linvfs_sendfile,
-       .ioctl          = linvfs_ioctl,
-       .mmap           = linvfs_file_mmap,
-       .open           = linvfs_open,
-       .release        = linvfs_release,
-       .fsync          = linvfs_fsync,
-};
-
-struct file_operations linvfs_invis_file_operations = {
-       .llseek         = generic_file_llseek,
-       .read           = do_sync_read,
-       .write          = do_sync_write,
-       .readv          = linvfs_readv_invis,
-       .writev         = linvfs_writev_invis,
-       .aio_read       = linvfs_read_invis,
-       .aio_write      = linvfs_write_invis,
-       .sendfile       = linvfs_sendfile,
-       .ioctl          = linvfs_ioctl_invis,
-       .mmap           = linvfs_file_mmap,
-       .open           = linvfs_open,
-       .release        = linvfs_release,
-       .fsync          = linvfs_fsync,
-};
-
-
-struct file_operations linvfs_dir_operations = {
-       .read           = generic_read_dir,
-       .readdir        = linvfs_readdir,
-       .ioctl          = linvfs_ioctl,
-       .fsync          = linvfs_fsync,
-};
-
-static struct vm_operations_struct linvfs_file_vm_ops = {
-       .nopage         = filemap_nopage,
-#ifdef HAVE_VMOP_MPROTECT
-       .mprotect       = linvfs_mprotect,
-#endif
-};
diff --git a/fs/xfs/linux/xfs_fs_subr.c b/fs/xfs/linux/xfs_fs_subr.c
deleted file mode 100644 (file)
index afad970..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-/*
- * Stub for no-op vnode operations that return error status.
- */
-int
-fs_noerr()
-{
-       return 0;
-}
-
-/*
- * Operation unsupported under this file system.
- */
-int
-fs_nosys()
-{
-       return ENOSYS;
-}
-
-/*
- * Stub for inactive, strategy, and read/write lock/unlock.  Does nothing.
- */
-/* ARGSUSED */
-void
-fs_noval()
-{
-}
-
-/*
- * vnode pcache layer for vnode_tosspages.
- * 'last' parameter unused but left in for IRIX compatibility
- */
-void
-fs_tosspages(
-       bhv_desc_t      *bdp,
-       xfs_off_t       first,
-       xfs_off_t       last,
-       int             fiopt)
-{
-       vnode_t         *vp = BHV_TO_VNODE(bdp);
-       struct inode    *ip = LINVFS_GET_IP(vp);
-
-       if (VN_CACHED(vp))
-               truncate_inode_pages(ip->i_mapping, first);
-}
-
-
-/*
- * vnode pcache layer for vnode_flushinval_pages.
- * 'last' parameter unused but left in for IRIX compatibility
- */
-void
-fs_flushinval_pages(
-       bhv_desc_t      *bdp,
-       xfs_off_t       first,
-       xfs_off_t       last,
-       int             fiopt)
-{
-       vnode_t         *vp = BHV_TO_VNODE(bdp);
-       struct inode    *ip = LINVFS_GET_IP(vp);
-
-       if (VN_CACHED(vp)) {
-               filemap_fdatawrite(ip->i_mapping);
-               filemap_fdatawait(ip->i_mapping);
-
-               truncate_inode_pages(ip->i_mapping, first);
-       }
-}
-
-/*
- * vnode pcache layer for vnode_flush_pages.
- * 'last' parameter unused but left in for IRIX compatibility
- */
-int
-fs_flush_pages(
-       bhv_desc_t      *bdp,
-       xfs_off_t       first,
-       xfs_off_t       last,
-       uint64_t        flags,
-       int             fiopt)
-{
-       vnode_t         *vp = BHV_TO_VNODE(bdp);
-       struct inode    *ip = LINVFS_GET_IP(vp);
-
-       if (VN_CACHED(vp)) {
-               filemap_fdatawrite(ip->i_mapping);
-               filemap_fdatawait(ip->i_mapping);
-       }
-
-       return 0;
-}
diff --git a/fs/xfs/linux/xfs_fs_subr.h b/fs/xfs/linux/xfs_fs_subr.h
deleted file mode 100644 (file)
index 198b8dd..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef        __XFS_SUBR_H__
-#define __XFS_SUBR_H__
-
-/*
- * Utilities shared among file system implementations.
- */
-
-struct cred;
-
-extern int     fs_noerr(void);
-extern int     fs_nosys(void);
-extern int     fs_nodev(void);
-extern void    fs_noval(void);
-extern void    fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-extern void    fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-extern int     fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
-
-#endif /* __XFS_FS_SUBR_H__ */
diff --git a/fs/xfs/linux/xfs_globals.c b/fs/xfs/linux/xfs_globals.c
deleted file mode 100644 (file)
index 1144a8b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * This file contains globals needed by XFS that were normally defined
- * somewhere else in IRIX.
- */
-
-#include "xfs.h"
-#include "xfs_cred.h"
-#include "xfs_sysctl.h"
-
-/*
- * System memory size - used to scale certain data structures in XFS.
- */
-unsigned long xfs_physmem;
-
-/*
- * Tunable XFS parameters.  xfs_params is required even when CONFIG_SYSCTL=n,
- * other XFS code uses these values.
- */
-
-xfs_param_t xfs_params = {
-                         /*    MIN             DFLT            MAX     */
-       .restrict_chown = {     0,              1,              1       },
-       .sgid_inherit   = {     0,              0,              1       },
-       .symlink_mode   = {     0,              0,              1       },
-       .panic_mask     = {     0,              0,              127     },
-       .error_level    = {     0,              3,              11      },
-       .sync_interval  = {     USER_HZ,        30*USER_HZ,     7200*USER_HZ },
-       .stats_clear    = {     0,              0,              1       },
-       .inherit_sync   = {     0,              1,              1       },
-       .inherit_nodump = {     0,              1,              1       },
-       .inherit_noatim = {     0,              1,              1       },
-       .flush_interval = {     USER_HZ/2,      USER_HZ,        30*USER_HZ },
-       .age_buffer     = {     1*USER_HZ,      15*USER_HZ,     7200*USER_HZ },
-};
-
-/*
- * Global system credential structure.
- */
-cred_t sys_cred_val, *sys_cred = &sys_cred_val;
-
diff --git a/fs/xfs/linux/xfs_globals.h b/fs/xfs/linux/xfs_globals.h
deleted file mode 100644 (file)
index e81e2f3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_GLOBALS_H__
-#define __XFS_GLOBALS_H__
-
-/*
- * This file declares globals needed by XFS that were normally defined
- * somewhere else in IRIX.
- */
-
-extern uint64_t        xfs_panic_mask;         /* set to cause more panics */
-extern unsigned long xfs_physmem;
-extern struct cred *sys_cred;
-
-#endif /* __XFS_GLOBALS_H__ */
diff --git a/fs/xfs/linux/xfs_ioctl.c b/fs/xfs/linux/xfs_ioctl.c
deleted file mode 100644 (file)
index d6402d7..0000000
+++ /dev/null
@@ -1,1236 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-#include "xfs_fs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-#include "xfs_dfrag.h"
-#include "xfs_fsops.h"
-
-#include <linux/dcache.h>
-#include <linux/mount.h>
-#include <linux/namei.h>
-#include <linux/pagemap.h>
-
-/*
- * ioctl commands that are used by Linux filesystems
- */
-#define XFS_IOC_GETXFLAGS      _IOR('f', 1, long)
-#define XFS_IOC_SETXFLAGS      _IOW('f', 2, long)
-#define XFS_IOC_GETVERSION     _IOR('v', 1, long)
-
-
-/*
- * xfs_find_handle maps from userspace xfs_fsop_handlereq structure to
- * a file or fs handle.
- *
- * XFS_IOC_PATH_TO_FSHANDLE
- *    returns fs handle for a mount point or path within that mount point
- * XFS_IOC_FD_TO_HANDLE
- *    returns full handle for a FD opened in user space
- * XFS_IOC_PATH_TO_HANDLE
- *    returns full handle for a path
- */
-STATIC int
-xfs_find_handle(
-       unsigned int            cmd,
-       unsigned long           arg)
-{
-       int                     hsize;
-       xfs_handle_t            handle;
-       xfs_fsop_handlereq_t    hreq;
-       struct inode            *inode;
-       struct vnode            *vp;
-
-       if (copy_from_user(&hreq, (xfs_fsop_handlereq_t *)arg, sizeof(hreq)))
-               return -XFS_ERROR(EFAULT);
-
-       memset((char *)&handle, 0, sizeof(handle));
-
-       switch (cmd) {
-       case XFS_IOC_PATH_TO_FSHANDLE:
-       case XFS_IOC_PATH_TO_HANDLE: {
-               struct nameidata        nd;
-               int                     error;
-
-               error = user_path_walk_link(hreq.path, &nd);
-               if (error)
-                       return error;
-
-               ASSERT(nd.dentry);
-               ASSERT(nd.dentry->d_inode);
-               inode = igrab(nd.dentry->d_inode);
-               path_release(&nd);
-               break;
-       }
-
-       case XFS_IOC_FD_TO_HANDLE: {
-               struct file     *file;
-
-               file = fget(hreq.fd);
-               if (!file)
-                   return -EBADF;
-
-               ASSERT(file->f_dentry);
-               ASSERT(file->f_dentry->d_inode);
-               inode = igrab(file->f_dentry->d_inode);
-               fput(file);
-               break;
-       }
-
-       default:
-               ASSERT(0);
-               return -XFS_ERROR(EINVAL);
-       }
-
-       if (inode->i_sb->s_magic != XFS_SB_MAGIC) {
-               /* we're not in XFS anymore, Toto */
-               iput(inode);
-               return -XFS_ERROR(EINVAL);
-       }
-
-       /* we need the vnode */
-       vp = LINVFS_GET_VP(inode);
-       if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) {
-               iput(inode);
-               return -XFS_ERROR(EBADF);
-       }
-
-       /* now we can grab the fsid */
-       memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t));
-       hsize = sizeof(xfs_fsid_t);
-
-       if (cmd != XFS_IOC_PATH_TO_FSHANDLE) {
-               xfs_inode_t     *ip;
-               bhv_desc_t      *bhv;
-               int             lock_mode;
-
-               /* need to get access to the xfs_inode to read the generation */
-               bhv = vn_bhv_lookup_unlocked(VN_BHV_HEAD(vp), &xfs_vnodeops);
-               ASSERT(bhv);
-               ip = XFS_BHVTOI(bhv);
-               ASSERT(ip);
-               lock_mode = xfs_ilock_map_shared(ip);
-
-               /* fill in fid section of handle from inode */
-               handle.ha_fid.xfs_fid_len = sizeof(xfs_fid_t) -
-                                           sizeof(handle.ha_fid.xfs_fid_len);
-               handle.ha_fid.xfs_fid_pad = 0;
-               handle.ha_fid.xfs_fid_gen = ip->i_d.di_gen;
-               handle.ha_fid.xfs_fid_ino = ip->i_ino;
-
-               xfs_iunlock_map_shared(ip, lock_mode);
-
-               hsize = XFS_HSIZE(handle);
-       }
-
-       /* now copy our handle into the user buffer & write out the size */
-       if (copy_to_user((xfs_handle_t *)hreq.ohandle, &handle, hsize) ||
-           copy_to_user(hreq.ohandlen, &hsize, sizeof(__s32))) {
-               iput(inode);
-               return -XFS_ERROR(EFAULT);
-       }
-
-       iput(inode);
-       return 0;
-}
-
-
-/*
- * Convert userspace handle data into vnode (and inode).
- * We [ab]use the fact that all the fsop_handlereq ioctl calls
- * have a data structure argument whose first component is always
- * a xfs_fsop_handlereq_t, so we can cast to and from this type.
- * This allows us to optimise the copy_from_user calls and gives
- * a handy, shared routine.
- *
- * If no error, caller must always VN_RELE the returned vp.
- */
-STATIC int
-xfs_vget_fsop_handlereq(
-       xfs_mount_t             *mp,
-       struct inode            *parinode,      /* parent inode pointer    */
-       int                     cap,            /* capability level for op */
-       unsigned long           arg,            /* userspace data pointer  */
-       unsigned long           size,           /* size of expected struct */
-       /* output arguments */
-       xfs_fsop_handlereq_t    *hreq,
-       vnode_t                 **vp,
-       struct inode            **inode)
-{
-       void                    *hanp;
-       size_t                  hlen;
-       xfs_fid_t               *xfid;
-       xfs_handle_t            *handlep;
-       xfs_handle_t            handle;
-       xfs_inode_t             *ip;
-       struct inode            *inodep;
-       vnode_t                 *vpp;
-       xfs_ino_t               ino;
-       __u32                   igen;
-       int                     error;
-
-       if (!capable(cap))
-               return XFS_ERROR(EPERM);
-
-       /*
-        * Only allow handle opens under a directory.
-        */
-       if (!S_ISDIR(parinode->i_mode))
-               return XFS_ERROR(ENOTDIR);
-
-       /*
-        * Copy the handle down from the user and validate
-        * that it looks to be in the correct format.
-        */
-       if (copy_from_user(hreq, (struct xfs_fsop_handlereq *)arg, size))
-               return XFS_ERROR(EFAULT);
-
-       hanp = hreq->ihandle;
-       hlen = hreq->ihandlen;
-       handlep = &handle;
-
-       if (hlen < sizeof(handlep->ha_fsid) || hlen > sizeof(*handlep))
-               return XFS_ERROR(EINVAL);
-       if (copy_from_user(handlep, hanp, hlen))
-               return XFS_ERROR(EFAULT);
-       if (hlen < sizeof(*handlep))
-               memset(((char *)handlep) + hlen, 0, sizeof(*handlep) - hlen);
-       if (hlen > sizeof(handlep->ha_fsid)) {
-               if (handlep->ha_fid.xfs_fid_len !=
-                               (hlen - sizeof(handlep->ha_fsid)
-                                       - sizeof(handlep->ha_fid.xfs_fid_len))
-                   || handlep->ha_fid.xfs_fid_pad)
-                       return XFS_ERROR(EINVAL);
-       }
-
-       /*
-        * Crack the handle, obtain the inode # & generation #
-        */
-       xfid = (struct xfs_fid *)&handlep->ha_fid;
-       if (xfid->xfs_fid_len == sizeof(*xfid) - sizeof(xfid->xfs_fid_len)) {
-               ino  = xfid->xfs_fid_ino;
-               igen = xfid->xfs_fid_gen;
-       } else {
-               return XFS_ERROR(EINVAL);
-       }
-
-       /*
-        * Get the XFS inode, building a vnode to go with it.
-        */
-       error = xfs_iget(mp, NULL, ino, XFS_ILOCK_SHARED, &ip, 0);
-       if (error)
-               return error;
-       if (ip == NULL)
-               return XFS_ERROR(EIO);
-       if (ip->i_d.di_mode == 0 || ip->i_d.di_gen != igen) {
-               xfs_iput_new(ip, XFS_ILOCK_SHARED);
-               return XFS_ERROR(ENOENT);
-       }
-
-       vpp = XFS_ITOV(ip);
-       inodep = LINVFS_GET_IP(vpp);
-       xfs_iunlock(ip, XFS_ILOCK_SHARED);
-
-       *vp = vpp;
-       *inode = inodep;
-       return 0;
-}
-
-STATIC int
-xfs_open_by_handle(
-       xfs_mount_t             *mp,
-       unsigned long           arg,
-       struct file             *parfilp,
-       struct inode            *parinode)
-{
-       int                     error;
-       int                     new_fd;
-       int                     permflag;
-       struct file             *filp;
-       struct inode            *inode;
-       struct dentry           *dentry;
-       vnode_t                 *vp;
-       xfs_fsop_handlereq_t    hreq;
-
-       error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
-                                       sizeof(xfs_fsop_handlereq_t),
-                                       &hreq, &vp, &inode);
-       if (error)
-               return -error;
-
-       /* Restrict xfs_open_by_handle to directories & regular files. */
-       if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) {
-               iput(inode);
-               return -XFS_ERROR(EINVAL);
-       }
-
-#if BITS_PER_LONG != 32
-       hreq.oflags |= O_LARGEFILE;
-#endif
-       /* Put open permission in namei format. */
-       permflag = hreq.oflags;
-       if ((permflag+1) & O_ACCMODE)
-               permflag++;
-       if (permflag & O_TRUNC)
-               permflag |= 2;
-
-       if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
-           (permflag & FMODE_WRITE) && IS_APPEND(inode)) {
-               iput(inode);
-               return -XFS_ERROR(EPERM);
-       }
-
-       if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
-               iput(inode);
-               return -XFS_ERROR(EACCES);
-       }
-
-       /* Can't write directories. */
-       if ( S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) {
-               iput(inode);
-               return -XFS_ERROR(EISDIR);
-       }
-
-       if ((new_fd = get_unused_fd()) < 0) {
-               iput(inode);
-               return new_fd;
-       }
-
-       dentry = d_alloc_anon(inode);
-       if (dentry == NULL) {
-               iput(inode);
-               put_unused_fd(new_fd);
-               return -XFS_ERROR(ENOMEM);
-       }
-
-       /* Ensure umount returns EBUSY on umounts while this file is open. */
-       mntget(parfilp->f_vfsmnt);
-
-       /* Create file pointer. */
-       filp = dentry_open(dentry, parfilp->f_vfsmnt, hreq.oflags);
-       if (IS_ERR(filp)) {
-               put_unused_fd(new_fd);
-               return -XFS_ERROR(-PTR_ERR(filp));
-       }
-       if (inode->i_mode & S_IFREG)
-               filp->f_op = &linvfs_invis_file_operations;
-
-       fd_install(new_fd, filp);
-       return new_fd;
-}
-
-STATIC int
-xfs_readlink_by_handle(
-       xfs_mount_t             *mp,
-       unsigned long           arg,
-       struct file             *parfilp,
-       struct inode            *parinode)
-{
-       int                     error;
-       struct iovec            aiov;
-       struct uio              auio;
-       struct inode            *inode;
-       xfs_fsop_handlereq_t    hreq;
-       vnode_t                 *vp;
-       __u32                   olen;
-
-       error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
-                                       sizeof(xfs_fsop_handlereq_t),
-                                       &hreq, &vp, &inode);
-       if (error)
-               return -error;
-
-       /* Restrict this handle operation to symlinks only. */
-       if (vp->v_type != VLNK) {
-               VN_RELE(vp);
-               return -XFS_ERROR(EINVAL);
-       }
-
-       if (copy_from_user(&olen, hreq.ohandlen, sizeof(__u32))) {
-               VN_RELE(vp);
-               return -XFS_ERROR(EFAULT);
-       }
-       aiov.iov_len    = olen;
-       aiov.iov_base   = hreq.ohandle;
-
-       auio.uio_iov    = &aiov;
-       auio.uio_iovcnt = 1;
-       auio.uio_offset = 0;
-       auio.uio_segflg = UIO_USERSPACE;
-       auio.uio_resid  = olen;
-
-       VOP_READLINK(vp, &auio, IO_INVIS, NULL, error);
-
-       VN_RELE(vp);
-       return (olen - auio.uio_resid);
-}
-
-STATIC int
-xfs_fssetdm_by_handle(
-       xfs_mount_t             *mp,
-       unsigned long           arg,
-       struct file             *parfilp,
-       struct inode            *parinode)
-{
-       int                     error;
-       struct fsdmidata        fsd;
-       xfs_fsop_setdm_handlereq_t dmhreq;
-       struct inode            *inode;
-       bhv_desc_t              *bdp;
-       vnode_t                 *vp;
-
-       error = xfs_vget_fsop_handlereq(mp, parinode, CAP_MKNOD, arg,
-                                       sizeof(xfs_fsop_setdm_handlereq_t),
-                                       (xfs_fsop_handlereq_t *)&dmhreq,
-                                       &vp, &inode);
-       if (error)
-               return -error;
-
-       if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
-               VN_RELE(vp);
-               return -XFS_ERROR(EPERM);
-       }
-
-       if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {
-               VN_RELE(vp);
-               return -XFS_ERROR(EFAULT);
-       }
-
-       bdp = bhv_base_unlocked(VN_BHV_HEAD(vp));
-       error = xfs_set_dmattrs(bdp, fsd.fsd_dmevmask, fsd.fsd_dmstate, NULL);
-
-       VN_RELE(vp);
-       if (error)
-               return -error;
-       return 0;
-}
-
-STATIC int
-xfs_attrlist_by_handle(
-       xfs_mount_t             *mp,
-       unsigned long           arg,
-       struct file             *parfilp,
-       struct inode            *parinode)
-{
-       int                     error;
-       attrlist_cursor_kern_t  *cursor;
-       xfs_fsop_attrlist_handlereq_t al_hreq;
-       struct inode            *inode;
-       vnode_t                 *vp;
-
-       error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
-                                       sizeof(xfs_fsop_attrlist_handlereq_t),
-                                       (xfs_fsop_handlereq_t *)&al_hreq,
-                                       &vp, &inode);
-       if (error)
-               return -error;
-
-       cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
-       VOP_ATTR_LIST(vp, al_hreq.buffer, al_hreq.buflen, al_hreq.flags,
-                       cursor, NULL, error);
-       VN_RELE(vp);
-       if (error)
-               return -error;
-       return 0;
-}
-
-STATIC int
-xfs_attrmulti_by_handle(
-       xfs_mount_t             *mp,
-       unsigned long           arg,
-       struct file             *parfilp,
-       struct inode            *parinode)
-{
-       int                     error;
-       xfs_attr_multiop_t      *ops;
-       xfs_fsop_attrmulti_handlereq_t am_hreq;
-       struct inode            *inode;
-       vnode_t                 *vp;
-       int                     i, size;
-
-       error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
-                                       sizeof(xfs_fsop_attrmulti_handlereq_t),
-                                       (xfs_fsop_handlereq_t *)&am_hreq,
-                                       &vp, &inode);
-       if (error)
-               return -error;
-
-       size = am_hreq.opcount * sizeof(attr_multiop_t);
-       ops = (xfs_attr_multiop_t *)kmalloc(size, GFP_KERNEL);
-       if (!ops) {
-               VN_RELE(vp);
-               return -XFS_ERROR(ENOMEM);
-       }
-
-       if (copy_from_user(ops, am_hreq.ops, size)) {
-               kfree(ops);
-               VN_RELE(vp);
-               return -XFS_ERROR(EFAULT);
-       }
-
-       for (i = 0; i < am_hreq.opcount; i++) {
-               switch(ops[i].am_opcode) {
-               case ATTR_OP_GET:
-                       VOP_ATTR_GET(vp,ops[i].am_attrname, ops[i].am_attrvalue,
-                                       &ops[i].am_length, ops[i].am_flags,
-                                       NULL, ops[i].am_error);
-                       break;
-               case ATTR_OP_SET:
-                       if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
-                               ops[i].am_error = EPERM;
-                               break;
-                       }
-                       VOP_ATTR_SET(vp,ops[i].am_attrname, ops[i].am_attrvalue,
-                                       ops[i].am_length, ops[i].am_flags,
-                                       NULL, ops[i].am_error);
-                       break;
-               case ATTR_OP_REMOVE:
-                       if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
-                               ops[i].am_error = EPERM;
-                               break;
-                       }
-                       VOP_ATTR_REMOVE(vp, ops[i].am_attrname, ops[i].am_flags,
-                                       NULL, ops[i].am_error);
-                       break;
-               default:
-                       ops[i].am_error = EINVAL;
-               }
-       }
-
-       if (copy_to_user(am_hreq.ops, ops, size))
-               error = -XFS_ERROR(EFAULT);
-
-       kfree(ops);
-       VN_RELE(vp);
-       return error;
-}
-
-/* prototypes for a few of the stack-hungry cases that have
- * their own functions.  Functions are defined after their use
- * so gcc doesn't get fancy and inline them with -03 */
-
-STATIC int
-xfs_ioc_space(
-       bhv_desc_t              *bdp,
-       vnode_t                 *vp,
-       struct file             *filp,
-       int                     flags,
-       unsigned int            cmd,
-       unsigned long           arg);
-
-STATIC int
-xfs_ioc_bulkstat(
-       xfs_mount_t             *mp,
-       unsigned int            cmd,
-       unsigned long           arg);
-
-STATIC int
-xfs_ioc_fsgeometry_v1(
-       xfs_mount_t             *mp,
-       unsigned long           arg);
-
-STATIC int
-xfs_ioc_fsgeometry(
-       xfs_mount_t             *mp,
-       unsigned long           arg);
-
-STATIC int
-xfs_ioc_xattr(
-       vnode_t                 *vp,
-       xfs_inode_t             *ip,
-       struct file             *filp,
-       unsigned int            cmd,
-       unsigned long           arg);
-
-STATIC int
-xfs_ioc_getbmap(
-       bhv_desc_t              *bdp,
-       struct file             *filp,
-       int                     flags,
-       unsigned int            cmd,
-       unsigned long           arg);
-
-STATIC int
-xfs_ioc_getbmapx(
-       bhv_desc_t              *bdp,
-       unsigned long           arg);
-
-int
-xfs_ioctl(
-       bhv_desc_t              *bdp,
-       struct inode            *inode,
-       struct file             *filp,
-       int                     ioflags,
-       unsigned int            cmd,
-       unsigned long           arg)
-{
-       int                     error;
-       vnode_t                 *vp;
-       xfs_inode_t             *ip;
-       xfs_mount_t             *mp;
-
-       vp = LINVFS_GET_VP(inode);
-
-       vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
-
-       ip = XFS_BHVTOI(bdp);
-       mp = ip->i_mount;
-
-       switch (cmd) {
-
-       case XFS_IOC_ALLOCSP:
-       case XFS_IOC_FREESP:
-       case XFS_IOC_RESVSP:
-       case XFS_IOC_UNRESVSP:
-       case XFS_IOC_ALLOCSP64:
-       case XFS_IOC_FREESP64:
-       case XFS_IOC_RESVSP64:
-       case XFS_IOC_UNRESVSP64:
-               /*
-                * Only allow the sys admin to reserve space unless
-                * unwritten extents are enabled.
-                */
-               if (!XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) &&
-                   !capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               return xfs_ioc_space(bdp, vp, filp, ioflags, cmd, arg);
-
-       case XFS_IOC_DIOINFO: {
-               struct dioattr  da;
-               xfs_buftarg_t   *target =
-                       (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
-                       mp->m_rtdev_targp : mp->m_ddev_targp;
-
-               da.d_mem = da.d_miniosz = 1 << target->pbr_sshift;
-               /* The size dio will do in one go */
-               da.d_maxiosz = 64 * PAGE_CACHE_SIZE;
-
-               if (copy_to_user((struct dioattr *)arg, &da, sizeof(da)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
-       }
-
-       case XFS_IOC_FSBULKSTAT_SINGLE:
-       case XFS_IOC_FSBULKSTAT:
-       case XFS_IOC_FSINUMBERS:
-               return xfs_ioc_bulkstat(mp, cmd, arg);
-
-       case XFS_IOC_FSGEOMETRY_V1:
-               return xfs_ioc_fsgeometry_v1(mp, arg);
-
-       case XFS_IOC_FSGEOMETRY:
-               return xfs_ioc_fsgeometry(mp, arg);
-
-       case XFS_IOC_GETVERSION:
-       case XFS_IOC_GETXFLAGS:
-       case XFS_IOC_SETXFLAGS:
-       case XFS_IOC_FSGETXATTR:
-       case XFS_IOC_FSSETXATTR:
-       case XFS_IOC_FSGETXATTRA:
-               return xfs_ioc_xattr(vp, ip, filp, cmd, arg);
-
-       case XFS_IOC_FSSETDM: {
-               struct fsdmidata        dmi;
-
-               if (copy_from_user(&dmi, (struct fsdmidata *)arg, sizeof(dmi)))
-                       return -XFS_ERROR(EFAULT);
-
-               error = xfs_set_dmattrs(bdp, dmi.fsd_dmevmask, dmi.fsd_dmstate,
-                                                       NULL);
-               return -error;
-       }
-
-       case XFS_IOC_GETBMAP:
-       case XFS_IOC_GETBMAPA:
-               return xfs_ioc_getbmap(bdp, filp, ioflags, cmd, arg);
-
-       case XFS_IOC_GETBMAPX:
-               return xfs_ioc_getbmapx(bdp, arg);
-
-       case XFS_IOC_FD_TO_HANDLE:
-       case XFS_IOC_PATH_TO_HANDLE:
-       case XFS_IOC_PATH_TO_FSHANDLE:
-               return xfs_find_handle(cmd, arg);
-
-       case XFS_IOC_OPEN_BY_HANDLE:
-               return xfs_open_by_handle(mp, arg, filp, inode);
-
-       case XFS_IOC_FSSETDM_BY_HANDLE:
-               return xfs_fssetdm_by_handle(mp, arg, filp, inode);
-
-       case XFS_IOC_READLINK_BY_HANDLE:
-               return xfs_readlink_by_handle(mp, arg, filp, inode);
-
-       case XFS_IOC_ATTRLIST_BY_HANDLE:
-               return xfs_attrlist_by_handle(mp, arg, filp, inode);
-
-       case XFS_IOC_ATTRMULTI_BY_HANDLE:
-               return xfs_attrmulti_by_handle(mp, arg, filp, inode);
-
-       case XFS_IOC_SWAPEXT: {
-               error = xfs_swapext((struct xfs_swapext *)arg);
-               return -error;
-       }
-
-       case XFS_IOC_FSCOUNTS: {
-               xfs_fsop_counts_t out;
-
-               error = xfs_fs_counts(mp, &out);
-               if (error)
-                       return -error;
-
-               if (copy_to_user((char *)arg, &out, sizeof(out)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
-       }
-
-       case XFS_IOC_SET_RESBLKS: {
-               xfs_fsop_resblks_t inout;
-               __uint64_t         in;
-
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               if (copy_from_user(&inout, (char *)arg, sizeof(inout)))
-                       return -XFS_ERROR(EFAULT);
-
-               /* input parameter is passed in resblks field of structure */
-               in = inout.resblks;
-               error = xfs_reserve_blocks(mp, &in, &inout);
-               if (error)
-                       return -error;
-
-               if (copy_to_user((char *)arg, &inout, sizeof(inout)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
-       }
-
-       case XFS_IOC_GET_RESBLKS: {
-               xfs_fsop_resblks_t out;
-
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               error = xfs_reserve_blocks(mp, NULL, &out);
-               if (error)
-                       return -error;
-
-               if (copy_to_user((char *)arg, &out, sizeof(out)))
-                       return -XFS_ERROR(EFAULT);
-
-               return 0;
-       }
-
-       case XFS_IOC_FSGROWFSDATA: {
-               xfs_growfs_data_t in;
-
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               if (copy_from_user(&in, (char *)arg, sizeof(in)))
-                       return -XFS_ERROR(EFAULT);
-
-               error = xfs_growfs_data(mp, &in);
-               return -error;
-       }
-
-       case XFS_IOC_FSGROWFSLOG: {
-               xfs_growfs_log_t in;
-
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               if (copy_from_user(&in, (char *)arg, sizeof(in)))
-                       return -XFS_ERROR(EFAULT);
-
-               error = xfs_growfs_log(mp, &in);
-               return -error;
-       }
-
-       case XFS_IOC_FSGROWFSRT: {
-               xfs_growfs_rt_t in;
-
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               if (copy_from_user(&in, (char *)arg, sizeof(in)))
-                       return -XFS_ERROR(EFAULT);
-
-               error = xfs_growfs_rt(mp, &in);
-               return -error;
-       }
-
-       case XFS_IOC_FREEZE:
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               freeze_bdev(inode->i_sb->s_bdev);
-               return 0;
-
-       case XFS_IOC_THAW:
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-               thaw_bdev(inode->i_sb->s_bdev, inode->i_sb);
-               return 0;
-
-       case XFS_IOC_GOINGDOWN: {
-               __uint32_t in;
-
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               if (get_user(in, (__uint32_t *)arg))
-                       return -XFS_ERROR(EFAULT);
-
-               error = xfs_fs_goingdown(mp, in);
-               return -error;
-       }
-
-       case XFS_IOC_ERROR_INJECTION: {
-               xfs_error_injection_t in;
-
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               if (copy_from_user(&in, (char *)arg, sizeof(in)))
-                       return -XFS_ERROR(EFAULT);
-
-               error = xfs_errortag_add(in.errtag, mp);
-               return -error;
-       }
-
-       case XFS_IOC_ERROR_CLEARALL:
-               if (!capable(CAP_SYS_ADMIN))
-                       return -EPERM;
-
-               error = xfs_errortag_clearall(mp);
-               return -error;
-
-       default:
-               return -ENOTTY;
-       }
-}
-
-STATIC int
-xfs_ioc_space(
-       bhv_desc_t              *bdp,
-       vnode_t                 *vp,
-       struct file             *filp,
-       int                     ioflags,
-       unsigned int            cmd,
-       unsigned long           arg)
-{
-       xfs_flock64_t           bf;
-       int                     attr_flags = 0;
-       int                     error;
-
-       if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND))
-               return -XFS_ERROR(EPERM);
-
-       if (!(filp->f_flags & FMODE_WRITE))
-               return -XFS_ERROR(EBADF);
-
-       if (vp->v_type != VREG)
-               return -XFS_ERROR(EINVAL);
-
-       if (copy_from_user(&bf, (xfs_flock64_t *)arg, sizeof(bf)))
-               return -XFS_ERROR(EFAULT);
-
-       if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
-               attr_flags |= ATTR_NONBLOCK;
-       if (ioflags & IO_INVIS)
-               attr_flags |= ATTR_DMI;
-
-       error = xfs_change_file_space(bdp, cmd, &bf, filp->f_pos,
-                                             NULL, attr_flags);
-       return -error;
-}
-
-STATIC int
-xfs_ioc_bulkstat(
-       xfs_mount_t             *mp,
-       unsigned int            cmd,
-       unsigned long           arg)
-{
-       xfs_fsop_bulkreq_t      bulkreq;
-       int                     count;  /* # of records returned */
-       xfs_ino_t               inlast; /* last inode number */
-       int                     done;
-       int                     error;
-
-       /* done = 1 if there are more stats to get and if bulkstat */
-       /* should be called again (unused here, but used in dmapi) */
-
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
-
-       if (XFS_FORCED_SHUTDOWN(mp))
-               return -XFS_ERROR(EIO);
-
-       if (copy_from_user(&bulkreq, (xfs_fsop_bulkreq_t *)arg,
-                                       sizeof(xfs_fsop_bulkreq_t)))
-               return -XFS_ERROR(EFAULT);
-
-       if (copy_from_user(&inlast, (__s64 *)bulkreq.lastip,
-                                               sizeof(__s64)))
-               return -XFS_ERROR(EFAULT);
-
-       if ((count = bulkreq.icount) <= 0)
-               return -XFS_ERROR(EINVAL);
-
-       if (cmd == XFS_IOC_FSINUMBERS)
-               error = xfs_inumbers(mp, NULL, &inlast, &count,
-                                               bulkreq.ubuffer);
-       else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE)
-               error = xfs_bulkstat_single(mp, &inlast,
-                                               bulkreq.ubuffer, &done);
-       else {  /* XFS_IOC_FSBULKSTAT */
-               if (count == 1 && inlast != 0) {
-                       inlast++;
-                       error = xfs_bulkstat_single(mp, &inlast,
-                                       bulkreq.ubuffer, &done);
-               } else {
-                       error = xfs_bulkstat(mp, NULL, &inlast, &count,
-                               (bulkstat_one_pf)xfs_bulkstat_one, NULL,
-                               sizeof(xfs_bstat_t), bulkreq.ubuffer,
-                               BULKSTAT_FG_QUICK, &done);
-               }
-       }
-
-       if (error)
-               return -error;
-
-       if (bulkreq.ocount != NULL) {
-               if (copy_to_user((xfs_ino_t *)bulkreq.lastip, &inlast,
-                                               sizeof(xfs_ino_t)))
-                       return -XFS_ERROR(EFAULT);
-
-               if (copy_to_user((__s32 *)bulkreq.ocount, &count,
-                                               sizeof(count)))
-                       return -XFS_ERROR(EFAULT);
-       }
-
-       return 0;
-}
-
-STATIC int
-xfs_ioc_fsgeometry_v1(
-       xfs_mount_t             *mp,
-       unsigned long           arg)
-{
-       xfs_fsop_geom_v1_t      fsgeo;
-       int                     error;
-
-       error = xfs_fs_geometry(mp, (xfs_fsop_geom_t *)&fsgeo, 3);
-       if (error)
-               return -error;
-
-       if (copy_to_user((xfs_fsop_geom_t *)arg, &fsgeo, sizeof(fsgeo)))
-               return -XFS_ERROR(EFAULT);
-       return 0;
-}
-
-STATIC int
-xfs_ioc_fsgeometry(
-       xfs_mount_t             *mp,
-       unsigned long           arg)
-{
-       xfs_fsop_geom_t         fsgeo;
-       int                     error;
-
-       error = xfs_fs_geometry(mp, &fsgeo, 4);
-       if (error)
-               return -error;
-
-       if (copy_to_user((xfs_fsop_geom_t *)arg, &fsgeo, sizeof(fsgeo)))
-               return -XFS_ERROR(EFAULT);
-       return 0;
-}
-
-/*
- * Linux extended inode flags interface.
- */
-#define LINUX_XFLAG_SYNC       0x00000008 /* Synchronous updates */
-#define LINUX_XFLAG_IMMUTABLE  0x00000010 /* Immutable file */
-#define LINUX_XFLAG_APPEND     0x00000020 /* writes to file may only append */
-#define LINUX_XFLAG_NODUMP     0x00000040 /* do not dump file */
-#define LINUX_XFLAG_NOATIME    0x00000080 /* do not update atime */
-
-STATIC unsigned int
-xfs_merge_ioc_xflags(
-       unsigned int    flags,
-       unsigned int    start)
-{
-       unsigned int    xflags = start;
-
-       if (flags & LINUX_XFLAG_IMMUTABLE)
-               xflags |= XFS_XFLAG_IMMUTABLE;
-       else
-               xflags &= ~XFS_XFLAG_IMMUTABLE;
-       if (flags & LINUX_XFLAG_APPEND)
-               xflags |= XFS_XFLAG_APPEND;
-       else
-               xflags &= ~XFS_XFLAG_APPEND;
-       if (flags & LINUX_XFLAG_SYNC)
-               xflags |= XFS_XFLAG_SYNC;
-       else
-               xflags &= ~XFS_XFLAG_SYNC;
-       if (flags & LINUX_XFLAG_NOATIME)
-               xflags |= XFS_XFLAG_NOATIME;
-       else
-               xflags &= ~XFS_XFLAG_NOATIME;
-       if (flags & LINUX_XFLAG_NODUMP)
-               xflags |= XFS_XFLAG_NODUMP;
-       else
-               xflags &= ~XFS_XFLAG_NODUMP;
-
-       return xflags;
-}
-
-STATIC int
-xfs_ioc_xattr(
-       vnode_t                 *vp,
-       xfs_inode_t             *ip,
-       struct file             *filp,
-       unsigned int            cmd,
-       unsigned long           arg)
-{
-       struct fsxattr          fa;
-       vattr_t                 va;
-       int                     error;
-       int                     attr_flags;
-       unsigned int            flags;
-
-       switch (cmd) {
-       case XFS_IOC_FSGETXATTR: {
-               va.va_mask = XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_NEXTENTS;
-               VOP_GETATTR(vp, &va, 0, NULL, error);
-               if (error)
-                       return -error;
-
-               fa.fsx_xflags   = va.va_xflags;
-               fa.fsx_extsize  = va.va_extsize;
-               fa.fsx_nextents = va.va_nextents;
-
-               if (copy_to_user((struct fsxattr *)arg, &fa, sizeof(fa)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
-       }
-
-       case XFS_IOC_FSSETXATTR: {
-               if (copy_from_user(&fa, (struct fsxattr *)arg, sizeof(fa)))
-                       return -XFS_ERROR(EFAULT);
-
-               attr_flags = 0;
-               if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
-                       attr_flags |= ATTR_NONBLOCK;
-
-               va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE;
-               va.va_xflags  = fa.fsx_xflags;
-               va.va_extsize = fa.fsx_extsize;
-
-               VOP_SETATTR(vp, &va, attr_flags, NULL, error);
-               if (!error)
-                       vn_revalidate(vp);      /* update Linux inode flags */
-               return -error;
-       }
-
-       case XFS_IOC_FSGETXATTRA: {
-               va.va_mask = XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_ANEXTENTS;
-               VOP_GETATTR(vp, &va, 0, NULL, error);
-               if (error)
-                       return -error;
-
-               fa.fsx_xflags   = va.va_xflags;
-               fa.fsx_extsize  = va.va_extsize;
-               fa.fsx_nextents = va.va_anextents;
-
-               if (copy_to_user((struct fsxattr *)arg, &fa, sizeof(fa)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
-       }
-
-       case XFS_IOC_GETXFLAGS: {
-               flags = 0;
-               if (ip->i_d.di_flags & XFS_XFLAG_IMMUTABLE)
-                       flags |= LINUX_XFLAG_IMMUTABLE;
-               if (ip->i_d.di_flags & XFS_XFLAG_APPEND)
-                       flags |= LINUX_XFLAG_APPEND;
-               if (ip->i_d.di_flags & XFS_XFLAG_SYNC)
-                       flags |= LINUX_XFLAG_SYNC;
-               if (ip->i_d.di_flags & XFS_XFLAG_NOATIME)
-                       flags |= LINUX_XFLAG_NOATIME;
-               if (ip->i_d.di_flags & XFS_XFLAG_NODUMP)
-                       flags |= LINUX_XFLAG_NODUMP;
-               if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
-       }
-
-       case XFS_IOC_SETXFLAGS: {
-               if (copy_from_user(&flags, (unsigned int *)arg, sizeof(flags)))
-                       return -XFS_ERROR(EFAULT);
-
-               if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \
-                             LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \
-                             LINUX_XFLAG_SYNC))
-                       return -XFS_ERROR(EOPNOTSUPP);
-
-               attr_flags = 0;
-               if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
-                       attr_flags |= ATTR_NONBLOCK;
-
-               va.va_mask = XFS_AT_XFLAGS;
-               va.va_xflags = xfs_merge_ioc_xflags(flags, ip->i_d.di_flags);
-
-               VOP_SETATTR(vp, &va, attr_flags, NULL, error);
-               if (!error)
-                       vn_revalidate(vp);      /* update Linux inode flags */
-               return -error;
-       }
-
-       case XFS_IOC_GETVERSION: {
-               flags = LINVFS_GET_IP(vp)->i_generation;
-               if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
-       }
-
-       default:
-               return -ENOTTY;
-       }
-}
-
-STATIC int
-xfs_ioc_getbmap(
-       bhv_desc_t              *bdp,
-       struct file             *filp,
-       int                     ioflags,
-       unsigned int            cmd,
-       unsigned long           arg)
-{
-       struct getbmap          bm;
-       int                     iflags;
-       int                     error;
-
-       if (copy_from_user(&bm, (struct getbmap *)arg, sizeof(bm)))
-               return -XFS_ERROR(EFAULT);
-
-       if (bm.bmv_count < 2)
-               return -XFS_ERROR(EINVAL);
-
-       iflags = (cmd == XFS_IOC_GETBMAPA ? BMV_IF_ATTRFORK : 0);
-       if (ioflags & IO_INVIS)
-               iflags |= BMV_IF_NO_DMAPI_READ;
-
-       error = xfs_getbmap(bdp, &bm, (struct getbmap *)arg+1, iflags);
-       if (error)
-               return -error;
-
-       if (copy_to_user((struct getbmap *)arg, &bm, sizeof(bm)))
-               return -XFS_ERROR(EFAULT);
-       return 0;
-}
-
-STATIC int
-xfs_ioc_getbmapx(
-       bhv_desc_t              *bdp,
-       unsigned long           arg)
-{
-       struct getbmapx         bmx;
-       struct getbmap          bm;
-       int                     iflags;
-       int                     error;
-
-       if (copy_from_user(&bmx, (struct getbmapx *)arg, sizeof(bmx)))
-               return -XFS_ERROR(EFAULT);
-
-       if (bmx.bmv_count < 2)
-               return -XFS_ERROR(EINVAL);
-
-       /*
-        * Map input getbmapx structure to a getbmap
-        * structure for xfs_getbmap.
-        */
-       GETBMAP_CONVERT(bmx, bm);
-
-       iflags = bmx.bmv_iflags;
-
-       if (iflags & (~BMV_IF_VALID))
-               return -XFS_ERROR(EINVAL);
-
-       iflags |= BMV_IF_EXTENDED;
-
-       error = xfs_getbmap(bdp, &bm, (struct getbmapx *)arg+1, iflags);
-       if (error)
-               return -error;
-
-       GETBMAP_CONVERT(bm, bmx);
-
-       if (copy_to_user((struct getbmapx *)arg, &bmx, sizeof(bmx)))
-               return -XFS_ERROR(EFAULT);
-
-       return 0;
-}
diff --git a/fs/xfs/linux/xfs_iops.c b/fs/xfs/linux/xfs_iops.c
deleted file mode 100644 (file)
index 4b3e61d..0000000
+++ /dev/null
@@ -1,708 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_ag.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_quota.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-
-#include <linux/xattr.h>
-
-
-/*
- * Pull the link count and size up from the xfs inode to the linux inode
- */
-STATIC void
-validate_fields(
-       struct inode    *ip)
-{
-       vnode_t         *vp = LINVFS_GET_VP(ip);
-       vattr_t         va;
-       int             error;
-
-       va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
-       VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error);
-       if (likely(!error)) {
-               ip->i_nlink = va.va_nlink;
-               ip->i_blocks = va.va_nblocks;
-
-               /* we're under i_sem so i_size can't change under us */
-               if (i_size_read(ip) != va.va_size)
-                       i_size_write(ip, va.va_size);
-       }
-}
-
-/*
- * Determine whether a process has a valid fs_struct (kernel daemons
- * like knfsd don't have an fs_struct).
- *
- * XXX(hch):  nfsd is broken, better fix it instead.
- */
-STATIC inline int
-has_fs_struct(struct task_struct *task)
-{
-       return (task->fs != init_task.fs);
-}
-
-STATIC int
-linvfs_mknod(
-       struct inode    *dir,
-       struct dentry   *dentry,
-       int             mode,
-       dev_t           rdev)
-{
-       struct inode    *ip;
-       vattr_t         va;
-       vnode_t         *vp = NULL, *dvp = LINVFS_GET_VP(dir);
-       xfs_acl_t       *default_acl = NULL;
-       attrexists_t    test_default_acl = _ACL_DEFAULT_EXISTS;
-       int             error;
-
-       /*
-        * Irix uses Missed'em'V split, but doesn't want to see
-        * the upper 5 bits of (14bit) major.
-        */
-       if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)
-               return -EINVAL;
-
-       if (test_default_acl && test_default_acl(dvp)) {
-               if (!_ACL_ALLOC(default_acl))
-                       return -ENOMEM;
-               if (!_ACL_GET_DEFAULT(dvp, default_acl)) {
-                       _ACL_FREE(default_acl);
-                       default_acl = NULL;
-               }
-       }
-
-       if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current))
-               mode &= ~current->fs->umask;
-
-       memset(&va, 0, sizeof(va));
-       va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
-       va.va_type = IFTOVT(mode);
-       va.va_mode = mode;
-
-       switch (mode & S_IFMT) {
-       case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
-               va.va_rdev = sysv_encode_dev(rdev);
-               va.va_mask |= XFS_AT_RDEV;
-               /*FALLTHROUGH*/
-       case S_IFREG:
-               VOP_CREATE(dvp, dentry, &va, &vp, NULL, error);
-               break;
-       case S_IFDIR:
-               VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error);
-               break;
-       default:
-               error = EINVAL;
-               break;
-       }
-
-       if (default_acl) {
-               if (!error) {
-                       error = _ACL_INHERIT(vp, &va, default_acl);
-                       if (!error) {
-                               VMODIFY(vp);
-                       } else {
-                               struct dentry   teardown = {};
-                               int             err2;
-
-                               /* Oh, the horror.
-                                * If we can't add the ACL we must back out.
-                                * ENOSPC can hit here, among other things.
-                                */
-                               teardown.d_inode = ip = LINVFS_GET_IP(vp);
-                               teardown.d_name = dentry->d_name;
-                               remove_inode_hash(ip);
-                               make_bad_inode(ip);
-                               if (S_ISDIR(mode))
-                                       VOP_RMDIR(dvp, &teardown, NULL, err2);
-                               else
-                                       VOP_REMOVE(dvp, &teardown, NULL, err2);
-                               VN_RELE(vp);
-                       }
-               }
-               _ACL_FREE(default_acl);
-       }
-
-       if (!error) {
-               ASSERT(vp);
-               ip = LINVFS_GET_IP(vp);
-
-               if (S_ISCHR(mode) || S_ISBLK(mode))
-                       ip->i_rdev = rdev;
-               else if (S_ISDIR(mode))
-                       validate_fields(ip);
-               d_instantiate(dentry, ip);
-               validate_fields(dir);
-       }
-       return -error;
-}
-
-STATIC int
-linvfs_create(
-       struct inode    *dir,
-       struct dentry   *dentry,
-       int             mode,
-       struct nameidata *nd)
-{
-       return linvfs_mknod(dir, dentry, mode, 0);
-}
-
-STATIC int
-linvfs_mkdir(
-       struct inode    *dir,
-       struct dentry   *dentry,
-       int             mode)
-{
-       return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0);
-}
-
-STATIC struct dentry *
-linvfs_lookup(
-       struct inode    *dir,
-       struct dentry   *dentry,
-       struct nameidata *nd)
-{
-       struct inode    *ip = NULL;
-       vnode_t         *vp, *cvp = NULL;
-       int             error;
-
-       if (dentry->d_name.len >= MAXNAMELEN)
-               return ERR_PTR(-ENAMETOOLONG);
-
-       vp = LINVFS_GET_VP(dir);
-       VOP_LOOKUP(vp, dentry, &cvp, 0, NULL, NULL, error);
-       if (!error) {
-               ASSERT(cvp);
-               ip = LINVFS_GET_IP(cvp);
-               if (!ip) {
-                       VN_RELE(cvp);
-                       return ERR_PTR(-EACCES);
-               }
-       }
-       if (error && (error != ENOENT))
-               return ERR_PTR(-error);
-       return d_splice_alias(ip, dentry);
-}
-
-STATIC int
-linvfs_link(
-       struct dentry   *old_dentry,
-       struct inode    *dir,
-       struct dentry   *dentry)
-{
-       struct inode    *ip;    /* inode of guy being linked to */
-       vnode_t         *tdvp;  /* target directory for new name/link */
-       vnode_t         *vp;    /* vp of name being linked */
-       int             error;
-
-       ip = old_dentry->d_inode;       /* inode being linked to */
-       if (S_ISDIR(ip->i_mode))
-               return -EPERM;
-
-       tdvp = LINVFS_GET_VP(dir);
-       vp = LINVFS_GET_VP(ip);
-
-       VOP_LINK(tdvp, vp, dentry, NULL, error);
-       if (!error) {
-               VMODIFY(tdvp);
-               VN_HOLD(vp);
-               validate_fields(ip);
-               d_instantiate(dentry, ip);
-       }
-       return -error;
-}
-
-STATIC int
-linvfs_unlink(
-       struct inode    *dir,
-       struct dentry   *dentry)
-{
-       struct inode    *inode;
-       vnode_t         *dvp;   /* directory containing name to remove */
-       int             error;
-
-       inode = dentry->d_inode;
-       dvp = LINVFS_GET_VP(dir);
-
-       VOP_REMOVE(dvp, dentry, NULL, error);
-       if (!error) {
-               validate_fields(dir);   /* For size only */
-               validate_fields(inode);
-       }
-
-       return -error;
-}
-
-STATIC int
-linvfs_symlink(
-       struct inode    *dir,
-       struct dentry   *dentry,
-       const char      *symname)
-{
-       struct inode    *ip;
-       vattr_t         va;
-       vnode_t         *dvp;   /* directory containing name to remove */
-       vnode_t         *cvp;   /* used to lookup symlink to put in dentry */
-       int             error;
-
-       dvp = LINVFS_GET_VP(dir);
-       cvp = NULL;
-
-       memset(&va, 0, sizeof(va));
-       va.va_type = VLNK;
-       va.va_mode = irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO;
-       va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
-
-       error = 0;
-       VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
-       if (!error && cvp) {
-               ASSERT(cvp->v_type == VLNK);
-               ip = LINVFS_GET_IP(cvp);
-               d_instantiate(dentry, ip);
-               validate_fields(dir);
-               validate_fields(ip); /* size needs update */
-       }
-       return -error;
-}
-
-STATIC int
-linvfs_rmdir(
-       struct inode    *dir,
-       struct dentry   *dentry)
-{
-       struct inode    *inode = dentry->d_inode;
-       vnode_t         *dvp = LINVFS_GET_VP(dir);
-       int             error;
-
-       VOP_RMDIR(dvp, dentry, NULL, error);
-       if (!error) {
-               validate_fields(inode);
-               validate_fields(dir);
-       }
-       return -error;
-}
-
-STATIC int
-linvfs_rename(
-       struct inode    *odir,
-       struct dentry   *odentry,
-       struct inode    *ndir,
-       struct dentry   *ndentry)
-{
-       struct inode    *new_inode = ndentry->d_inode;
-       vnode_t         *fvp;   /* from directory */
-       vnode_t         *tvp;   /* target directory */
-       int             error;
-
-       fvp = LINVFS_GET_VP(odir);
-       tvp = LINVFS_GET_VP(ndir);
-
-       VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
-       if (error)
-               return -error;
-
-       if (new_inode)
-               validate_fields(new_inode);
-
-       validate_fields(odir);
-       if (ndir != odir)
-               validate_fields(ndir);
-       return 0;
-}
-
-STATIC int
-linvfs_readlink(
-       struct dentry   *dentry,
-       char            *buf,
-       int             size)
-{
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
-       uio_t           uio;
-       iovec_t         iov;
-       int             error;
-
-       iov.iov_base = buf;
-       iov.iov_len = size;
-
-       uio.uio_iov = &iov;
-       uio.uio_offset = 0;
-       uio.uio_segflg = UIO_USERSPACE;
-       uio.uio_resid = size;
-       uio.uio_iovcnt = 1;
-
-       VOP_READLINK(vp, &uio, 0, NULL, error);
-       if (error)
-               return -error;
-
-       return (size - uio.uio_resid);
-}
-
-/*
- * careful here - this function can get called recursively, so
- * we need to be very careful about how much stack we use.
- * uio is kmalloced for this reason...
- */
-STATIC int
-linvfs_follow_link(
-       struct dentry           *dentry,
-       struct nameidata        *nd)
-{
-       vnode_t                 *vp;
-       uio_t                   *uio;
-       iovec_t                 iov;
-       int                     error;
-       char                    *link;
-
-       ASSERT(dentry);
-       ASSERT(nd);
-
-       link = (char *)kmalloc(MAXNAMELEN+1, GFP_KERNEL);
-       if (!link)
-               return -ENOMEM;
-
-       uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL);
-       if (!uio) {
-               kfree(link);
-               return -ENOMEM;
-       }
-
-       vp = LINVFS_GET_VP(dentry->d_inode);
-
-       iov.iov_base = link;
-       iov.iov_len = MAXNAMELEN;
-
-       uio->uio_iov = &iov;
-       uio->uio_offset = 0;
-       uio->uio_segflg = UIO_SYSSPACE;
-       uio->uio_resid = MAXNAMELEN;
-       uio->uio_iovcnt = 1;
-
-       VOP_READLINK(vp, uio, 0, NULL, error);
-       if (error) {
-               kfree(uio);
-               kfree(link);
-               return -error;
-       }
-
-       link[MAXNAMELEN - uio->uio_resid] = '\0';
-       kfree(uio);
-
-       /* vfs_follow_link returns (-) errors */
-       error = vfs_follow_link(nd, link);
-       kfree(link);
-       return error;
-}
-
-#ifdef CONFIG_XFS_POSIX_ACL
-STATIC int
-linvfs_permission(
-       struct inode    *inode,
-       int             mode,
-       struct nameidata *nd)
-{
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       int             error;
-
-       mode <<= 6;             /* convert from linux to vnode access bits */
-       VOP_ACCESS(vp, mode, NULL, error);
-       return -error;
-}
-#else
-#define linvfs_permission NULL
-#endif
-
-STATIC int
-linvfs_getattr(
-       struct vfsmount *mnt,
-       struct dentry   *dentry,
-       struct kstat    *stat)
-{
-       struct inode    *inode = dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       int             error = 0;
-
-       if (unlikely(vp->v_flag & VMODIFIED))
-               error = vn_revalidate(vp);
-       if (!error)
-               generic_fillattr(inode, stat);
-       return 0;
-}
-
-STATIC int
-linvfs_setattr(
-       struct dentry   *dentry,
-       struct iattr    *attr)
-{
-       struct inode    *inode = dentry->d_inode;
-       unsigned int    ia_valid = attr->ia_valid;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       vattr_t         vattr;
-       int             flags = 0;
-       int             error;
-
-       memset(&vattr, 0, sizeof(vattr_t));
-       if (ia_valid & ATTR_UID) {
-               vattr.va_mask |= XFS_AT_UID;
-               vattr.va_uid = attr->ia_uid;
-       }
-       if (ia_valid & ATTR_GID) {
-               vattr.va_mask |= XFS_AT_GID;
-               vattr.va_gid = attr->ia_gid;
-       }
-       if (ia_valid & ATTR_SIZE) {
-               vattr.va_mask |= XFS_AT_SIZE;
-               vattr.va_size = attr->ia_size;
-       }
-       if (ia_valid & ATTR_ATIME) {
-               vattr.va_mask |= XFS_AT_ATIME;
-               vattr.va_atime = attr->ia_atime;
-       }
-       if (ia_valid & ATTR_MTIME) {
-               vattr.va_mask |= XFS_AT_MTIME;
-               vattr.va_mtime = attr->ia_mtime;
-       }
-       if (ia_valid & ATTR_CTIME) {
-               vattr.va_mask |= XFS_AT_CTIME;
-               vattr.va_ctime = attr->ia_ctime;
-       }
-       if (ia_valid & ATTR_MODE) {
-               vattr.va_mask |= XFS_AT_MODE;
-               vattr.va_mode = attr->ia_mode;
-               if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
-                       inode->i_mode &= ~S_ISGID;
-       }
-
-       if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))
-               flags = ATTR_UTIME;
-#ifdef ATTR_NO_BLOCK
-       if ((ia_valid & ATTR_NO_BLOCK))
-               flags |= ATTR_NONBLOCK;
-#endif
-
-       VOP_SETATTR(vp, &vattr, flags, NULL, error);
-       if (error)
-               return(-error); /* Positive error up from XFS */
-       if (ia_valid & ATTR_SIZE) {
-               error = vmtruncate(inode, attr->ia_size);
-       }
-
-       if (!error) {
-               vn_revalidate(vp);
-       }
-       return error;
-}
-
-STATIC void
-linvfs_truncate(
-       struct inode    *inode)
-{
-       block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
-}
-
-STATIC int
-linvfs_setxattr(
-       struct dentry   *dentry,
-       const char      *name,
-       const void      *data,
-       size_t          size,
-       int             flags)
-{
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
-       char            *attr = (char *)name;
-       attrnames_t     *namesp;
-       int             xflags = 0;
-       int             error;
-
-       namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
-       if (!namesp)
-               return -EOPNOTSUPP;
-       attr += namesp->attr_namelen;
-       error = namesp->attr_capable(vp, NULL);
-       if (error)
-               return error;
-
-       /* Convert Linux syscall to XFS internal ATTR flags */
-       if (flags & XATTR_CREATE)
-               xflags |= ATTR_CREATE;
-       if (flags & XATTR_REPLACE)
-               xflags |= ATTR_REPLACE;
-       xflags |= namesp->attr_flag;
-       return namesp->attr_set(vp, attr, (void *)data, size, xflags);
-}
-
-STATIC ssize_t
-linvfs_getxattr(
-       struct dentry   *dentry,
-       const char      *name,
-       void            *data,
-       size_t          size)
-{
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
-       char            *attr = (char *)name;
-       attrnames_t     *namesp;
-       int             xflags = 0;
-       ssize_t         error;
-
-       namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
-       if (!namesp)
-               return -EOPNOTSUPP;
-       attr += namesp->attr_namelen;
-       error = namesp->attr_capable(vp, NULL);
-       if (error)
-               return error;
-
-       /* Convert Linux syscall to XFS internal ATTR flags */
-       if (!size) {
-               xflags |= ATTR_KERNOVAL;
-               data = NULL;
-       }
-       xflags |= namesp->attr_flag;
-       return namesp->attr_get(vp, attr, (void *)data, size, xflags);
-}
-
-STATIC ssize_t
-linvfs_listxattr(
-       struct dentry           *dentry,
-       char                    *data,
-       size_t                  size)
-{
-       vnode_t                 *vp = LINVFS_GET_VP(dentry->d_inode);
-       int                     error, xflags = ATTR_KERNAMELS;
-       ssize_t                 result;
-
-       if (!size)
-               xflags |= ATTR_KERNOVAL;
-       xflags |= capable(CAP_SYS_ADMIN) ? ATTR_KERNFULLS : ATTR_KERNORMALS;
-
-       error = attr_generic_list(vp, data, size, xflags, &result);
-       if (error < 0)
-               return error;
-       return result;
-}
-
-STATIC int
-linvfs_removexattr(
-       struct dentry   *dentry,
-       const char      *name)
-{
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
-       char            *attr = (char *)name;
-       attrnames_t     *namesp;
-       int             xflags = 0;
-       int             error;
-
-       namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
-       if (!namesp)
-               return -EOPNOTSUPP;
-       attr += namesp->attr_namelen;
-       error = namesp->attr_capable(vp, NULL);
-       if (error)
-               return error;
-       xflags |= namesp->attr_flag;
-       return namesp->attr_remove(vp, attr, xflags);
-}
-
-
-struct inode_operations linvfs_file_inode_operations = {
-       .permission             = linvfs_permission,
-       .truncate               = linvfs_truncate,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
-};
-
-struct inode_operations linvfs_dir_inode_operations = {
-       .create                 = linvfs_create,
-       .lookup                 = linvfs_lookup,
-       .link                   = linvfs_link,
-       .unlink                 = linvfs_unlink,
-       .symlink                = linvfs_symlink,
-       .mkdir                  = linvfs_mkdir,
-       .rmdir                  = linvfs_rmdir,
-       .mknod                  = linvfs_mknod,
-       .rename                 = linvfs_rename,
-       .permission             = linvfs_permission,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
-};
-
-struct inode_operations linvfs_symlink_inode_operations = {
-       .readlink               = linvfs_readlink,
-       .follow_link            = linvfs_follow_link,
-       .permission             = linvfs_permission,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
-};
diff --git a/fs/xfs/linux/xfs_iops.h b/fs/xfs/linux/xfs_iops.h
deleted file mode 100644 (file)
index f0f5c87..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_IOPS_H__
-#define __XFS_IOPS_H__
-
-extern struct inode_operations linvfs_file_inode_operations;
-extern struct inode_operations linvfs_dir_inode_operations;
-extern struct inode_operations linvfs_symlink_inode_operations;
-
-extern struct file_operations linvfs_file_operations;
-extern struct file_operations linvfs_invis_file_operations;
-extern struct file_operations linvfs_dir_operations;
-
-extern struct address_space_operations linvfs_aops;
-
-extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
-extern void linvfs_unwritten_done(struct buffer_head *, int);
-
-extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
-                        int, unsigned int, unsigned long);
-
-#endif /* __XFS_IOPS_H__ */
diff --git a/fs/xfs/linux/xfs_linux.h b/fs/xfs/linux/xfs_linux.h
deleted file mode 100644 (file)
index 70481f8..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_LINUX__
-#define __XFS_LINUX__
-
-#include <linux/types.h>
-#include <linux/config.h>
-
-/*
- * Some types are conditional depending on the target system.
- * XFS_BIG_BLKNOS needs block layer disk addresses to be 64 bits.
- * XFS_BIG_INUMS needs the VFS inode number to be 64 bits, as well
- * as requiring XFS_BIG_BLKNOS to be set.
- */
-#if defined(CONFIG_LBD) || (BITS_PER_LONG == 64)
-# define XFS_BIG_BLKNOS        1
-# if BITS_PER_LONG == 64
-#  define XFS_BIG_INUMS        1
-# else
-#  define XFS_BIG_INUMS        0
-# endif
-#else
-# define XFS_BIG_BLKNOS        0
-# define XFS_BIG_INUMS 0
-#endif
-
-#include <xfs_types.h>
-#include <xfs_arch.h>
-
-#include <kmem.h>
-#include <mrlock.h>
-#include <spin.h>
-#include <sv.h>
-#include <mutex.h>
-#include <sema.h>
-#include <time.h>
-
-#include <support/qsort.h>
-#include <support/ktrace.h>
-#include <support/debug.h>
-#include <support/move.h>
-#include <support/uuid.h>
-
-#include <linux/mm.h>
-#include <linux/kernel.h>
-#include <linux/blkdev.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/file.h>
-#include <linux/swap.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/bitops.h>
-#include <linux/major.h>
-#include <linux/pagemap.h>
-#include <linux/vfs.h>
-#include <linux/seq_file.h>
-#include <linux/init.h>
-#include <linux/proc_fs.h>
-#include <linux/version.h>
-
-#include <asm/page.h>
-#include <asm/div64.h>
-#include <asm/param.h>
-#include <asm/uaccess.h>
-#include <asm/byteorder.h>
-#include <asm/unaligned.h>
-
-#include <xfs_behavior.h>
-#include <xfs_vfs.h>
-#include <xfs_cred.h>
-#include <xfs_vnode.h>
-#include <xfs_stats.h>
-#include <xfs_sysctl.h>
-#include <xfs_iops.h>
-#include <xfs_super.h>
-#include <xfs_globals.h>
-#include <xfs_fs_subr.h>
-#include <xfs_lrw.h>
-#include <xfs_buf.h>
-
-/*
- * Feature macros (disable/enable)
- */
-#undef  HAVE_REFCACHE  /* reference cache not needed for NFS in 2.6 */
-#define HAVE_SENDFILE  /* sendfile(2) exists in 2.6, but not in 2.4 */
-
-/*
- * State flag for unwritten extent buffers.
- *
- * We need to be able to distinguish between these and delayed
- * allocate buffers within XFS.  The generic IO path code does
- * not need to distinguish - we use the BH_Delay flag for both
- * delalloc and these ondisk-uninitialised buffers.
- */
-BUFFER_FNS(PrivateStart, unwritten);
-static inline void set_buffer_unwritten_io(struct buffer_head *bh)
-{
-       bh->b_end_io = linvfs_unwritten_done;
-}
-
-#define xfs_refcache_size      xfs_params.refcache_size.val
-#define xfs_refcache_purge_count xfs_params.refcache_purge.val
-#define restricted_chown       xfs_params.restrict_chown.val
-#define irix_sgid_inherit      xfs_params.sgid_inherit.val
-#define irix_symlink_mode      xfs_params.symlink_mode.val
-#define xfs_panic_mask         xfs_params.panic_mask.val
-#define xfs_error_level                xfs_params.error_level.val
-#define xfs_syncd_interval     (xfs_params.sync_interval.val * HZ / USER_HZ)
-#define xfs_stats_clear                xfs_params.stats_clear.val
-#define xfs_inherit_sync       xfs_params.inherit_sync.val
-#define xfs_inherit_nodump     xfs_params.inherit_nodump.val
-#define xfs_inherit_noatime    xfs_params.inherit_noatim.val
-#define xfs_flush_interval     (xfs_params.flush_interval.val * HZ / USER_HZ)
-#define xfs_age_buffer         (xfs_params.age_buffer.val * HZ / USER_HZ)
-
-#define current_cpu()          smp_processor_id()
-#define current_pid()          (current->pid)
-#define current_fsuid(cred)    (current->fsuid)
-#define current_fsgid(cred)    (current->fsgid)
-
-#define NBPP           PAGE_SIZE
-#define DPPSHFT                (PAGE_SHIFT - 9)
-#define NDPP           (1 << (PAGE_SHIFT - 9))
-#define dtop(DD)       (((DD) + NDPP - 1) >> DPPSHFT)
-#define dtopt(DD)      ((DD) >> DPPSHFT)
-#define dpoff(DD)      ((DD) & (NDPP-1))
-
-#define NBBY           8               /* number of bits per byte */
-#define        NBPC            PAGE_SIZE       /* Number of bytes per click */
-#define        BPCSHIFT        PAGE_SHIFT      /* LOG2(NBPC) if exact */
-
-/*
- * Size of block device i/o is parameterized here.
- * Currently the system supports page-sized i/o.
- */
-#define        BLKDEV_IOSHIFT          BPCSHIFT
-#define        BLKDEV_IOSIZE           (1<<BLKDEV_IOSHIFT)
-/* number of BB's per block device block */
-#define        BLKDEV_BB               BTOBB(BLKDEV_IOSIZE)
-
-/* bytes to clicks */
-#define        btoc(x)         (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT)
-#define        btoct(x)        ((__psunsigned_t)(x)>>BPCSHIFT)
-#define        btoc64(x)       (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT)
-#define        btoct64(x)      ((__uint64_t)(x)>>BPCSHIFT)
-#define        io_btoc(x)      (((__psunsigned_t)(x)+(IO_NBPC-1))>>IO_BPCSHIFT)
-#define        io_btoct(x)     ((__psunsigned_t)(x)>>IO_BPCSHIFT)
-
-/* off_t bytes to clicks */
-#define offtoc(x)       (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT)
-#define offtoct(x)      ((xfs_off_t)(x)>>BPCSHIFT)
-
-/* clicks to off_t bytes */
-#define        ctooff(x)       ((xfs_off_t)(x)<<BPCSHIFT)
-
-/* clicks to bytes */
-#define        ctob(x)         ((__psunsigned_t)(x)<<BPCSHIFT)
-#define btoct(x)        ((__psunsigned_t)(x)>>BPCSHIFT)
-#define        ctob64(x)       ((__uint64_t)(x)<<BPCSHIFT)
-#define        io_ctob(x)      ((__psunsigned_t)(x)<<IO_BPCSHIFT)
-
-/* bytes to clicks */
-#define btoc(x)         (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT)
-
-#ifndef CELL_CAPABLE
-#define FSC_NOTIFY_NAME_CHANGED(vp)
-#endif
-
-#ifndef ENOATTR
-#define ENOATTR                ENODATA         /* Attribute not found */
-#endif
-
-/* Note: EWRONGFS never visible outside the kernel */
-#define        EWRONGFS        EINVAL          /* Mount with wrong filesystem type */
-
-/*
- * XXX EFSCORRUPTED needs a real value in errno.h. asm-i386/errno.h won't
- *     return codes out of its known range in errno.
- * XXX Also note: needs to be < 1000 and fairly unique on Linux (mustn't
- *     conflict with any code we use already or any code a driver may use)
- * XXX Some options (currently we do #2):
- *     1/ New error code ["Filesystem is corrupted", _after_ glibc updated]
- *     2/ 990 ["Unknown error 990"]
- *     3/ EUCLEAN ["Structure needs cleaning"]
- *     4/ Convert EFSCORRUPTED to EIO [just prior to return into userspace]
- */
-#define EFSCORRUPTED    990            /* Filesystem is corrupted */
-
-#define SYNCHRONIZE()  barrier()
-#define __return_address __builtin_return_address(0)
-
-/*
- * IRIX (BSD) quotactl makes use of separate commands for user/group,
- * whereas on Linux the syscall encodes this information into the cmd
- * field (see the QCMD macro in quota.h).  These macros help keep the
- * code portable - they are not visible from the syscall interface.
- */
-#define Q_XSETGQLIM    XQM_CMD(0x8)    /* set groups disk limits */
-#define Q_XGETGQUOTA   XQM_CMD(0x9)    /* get groups disk limits */
-
-/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */
-/* we may well need to fine-tune this if it ever becomes an issue.  */
-#define DQUOT_MAX_HEURISTIC    1024    /* NR_DQUOTS */
-#define ndquot                 DQUOT_MAX_HEURISTIC
-
-/* IRIX uses the current size of the name cache to guess a good value */
-/* - this isn't the same but is a good enough starting point for now. */
-#define DQUOT_HASH_HEURISTIC   files_stat.nr_files
-
-/* IRIX inodes maintain the project ID also, zero this field on Linux */
-#define DEFAULT_PROJID 0
-#define dfltprid       DEFAULT_PROJID
-
-#define MAXPATHLEN     1024
-
-#define MIN(a,b)       (min(a,b))
-#define MAX(a,b)       (max(a,b))
-#define howmany(x, y)  (((x)+((y)-1))/(y))
-#define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))
-
-#define xfs_stack_trace()      dump_stack()
-
-#define xfs_itruncate_data(ip, off)    \
-       (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off)))
-
-
-/* Move the kernel do_div definition off to one side */
-
-#if defined __i386__
-/* For ia32 we need to pull some tricks to get past various versions
- * of the compiler which do not like us using do_div in the middle
- * of large functions.
- */
-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
-{
-       __u32   mod;
-
-       switch (n) {
-               case 4:
-                       mod = *(__u32 *)a % b;
-                       *(__u32 *)a = *(__u32 *)a / b;
-                       return mod;
-               case 8:
-                       {
-                       unsigned long __upper, __low, __high, __mod;
-                       __u64   c = *(__u64 *)a;
-                       __upper = __high = c >> 32;
-                       __low = c;
-                       if (__high) {
-                               __upper = __high % (b);
-                               __high = __high / (b);
-                       }
-                       asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper));
-                       asm("":"=A" (c):"a" (__low),"d" (__high));
-                       *(__u64 *)a = c;
-                       return __mod;
-                       }
-       }
-
-       /* NOTREACHED */
-       return 0;
-}
-
-/* Side effect free 64 bit mod operation */
-static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
-{
-       switch (n) {
-               case 4:
-                       return *(__u32 *)a % b;
-               case 8:
-                       {
-                       unsigned long __upper, __low, __high, __mod;
-                       __u64   c = *(__u64 *)a;
-                       __upper = __high = c >> 32;
-                       __low = c;
-                       if (__high) {
-                               __upper = __high % (b);
-                               __high = __high / (b);
-                       }
-                       asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper));
-                       asm("":"=A" (c):"a" (__low),"d" (__high));
-                       return __mod;
-                       }
-       }
-
-       /* NOTREACHED */
-       return 0;
-}
-#else
-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
-{
-       __u32   mod;
-
-       switch (n) {
-               case 4:
-                       mod = *(__u32 *)a % b;
-                       *(__u32 *)a = *(__u32 *)a / b;
-                       return mod;
-               case 8:
-                       mod = do_div(*(__u64 *)a, b);
-                       return mod;
-       }
-
-       /* NOTREACHED */
-       return 0;
-}
-
-/* Side effect free 64 bit mod operation */
-static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
-{
-       switch (n) {
-               case 4:
-                       return *(__u32 *)a % b;
-               case 8:
-                       {
-                       __u64   c = *(__u64 *)a;
-                       return do_div(c, b);
-                       }
-       }
-
-       /* NOTREACHED */
-       return 0;
-}
-#endif
-
-#undef do_div
-#define do_div(a, b)   xfs_do_div(&(a), (b), sizeof(a))
-#define do_mod(a, b)   xfs_do_mod(&(a), (b), sizeof(a))
-
-static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y)
-{
-       x += y - 1;
-       do_div(x, y);
-       return(x * y);
-}
-
-#endif /* __XFS_LINUX__ */
diff --git a/fs/xfs/linux/xfs_lrw.c b/fs/xfs/linux/xfs_lrw.c
deleted file mode 100644 (file)
index 4bacdb7..0000000
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-/*
- *  fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff)
- *
- */
-
-#include "xfs.h"
-
-#include "xfs_fs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_ag.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_quota.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_inode_item.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-#include "xfs_iomap.h"
-
-#include <linux/capability.h>
-
-
-#if defined(XFS_RW_TRACE)
-void
-xfs_rw_enter_trace(
-       int                     tag,
-       xfs_iocore_t            *io,
-       const struct iovec      *iovp,
-       size_t                  segs,
-       loff_t                  offset,
-       int                     ioflags)
-{
-       xfs_inode_t     *ip = XFS_IO_INODE(io);
-
-       if (ip->i_rwtrace == NULL)
-               return;
-       ktrace_enter(ip->i_rwtrace,
-               (void *)(unsigned long)tag,
-               (void *)ip,
-               (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
-               (void *)(__psint_t)iovp,
-               (void *)((unsigned long)segs),
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)ioflags),
-               (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(io->io_new_size & 0xffffffff)),
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL);
-}
-
-void
-xfs_inval_cached_trace(
-       xfs_iocore_t    *io,
-       xfs_off_t       offset,
-       xfs_off_t       len,
-       xfs_off_t       first,
-       xfs_off_t       last)
-{
-       xfs_inode_t     *ip = XFS_IO_INODE(io);
-
-       if (ip->i_rwtrace == NULL)
-               return;
-       ktrace_enter(ip->i_rwtrace,
-               (void *)(__psint_t)XFS_INVAL_CACHED,
-               (void *)ip,
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)((len >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(len & 0xffffffff)),
-               (void *)((unsigned long)((first >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(first & 0xffffffff)),
-               (void *)((unsigned long)((last >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(last & 0xffffffff)),
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL);
-}
-#endif
-
-/*
- *     xfs_iozero
- *
- *     xfs_iozero clears the specified range of buffer supplied,
- *     and marks all the affected blocks as valid and modified.  If
- *     an affected block is not allocated, it will be allocated.  If
- *     an affected block is not completely overwritten, and is not
- *     valid before the operation, it will be read from disk before
- *     being partially zeroed.
- */
-STATIC int
-xfs_iozero(
-       struct inode            *ip,    /* inode                        */
-       loff_t                  pos,    /* offset in file               */
-       size_t                  count,  /* size of data to zero         */
-       loff_t                  end_size)       /* max file size to set */
-{
-       unsigned                bytes;
-       struct page             *page;
-       struct address_space    *mapping;
-       char                    *kaddr;
-       int                     status;
-
-       mapping = ip->i_mapping;
-       do {
-               unsigned long index, offset;
-
-               offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */
-               index = pos >> PAGE_CACHE_SHIFT;
-               bytes = PAGE_CACHE_SIZE - offset;
-               if (bytes > count)
-                       bytes = count;
-
-               status = -ENOMEM;
-               page = grab_cache_page(mapping, index);
-               if (!page)
-                       break;
-
-               kaddr = kmap(page);
-               status = mapping->a_ops->prepare_write(NULL, page, offset,
-                                                       offset + bytes);
-               if (status) {
-                       goto unlock;
-               }
-
-               memset((void *) (kaddr + offset), 0, bytes);
-               flush_dcache_page(page);
-               status = mapping->a_ops->commit_write(NULL, page, offset,
-                                                       offset + bytes);
-               if (!status) {
-                       pos += bytes;
-                       count -= bytes;
-                       if (pos > i_size_read(ip))
-                               i_size_write(ip, pos < end_size ? pos : end_size);
-               }
-
-unlock:
-               kunmap(page);
-               unlock_page(page);
-               page_cache_release(page);
-               if (status)
-                       break;
-       } while (count);
-
-       return (-status);
-}
-
-/*
- * xfs_inval_cached_pages
- * 
- * This routine is responsible for keeping direct I/O and buffered I/O
- * somewhat coherent.  From here we make sure that we're at least
- * temporarily holding the inode I/O lock exclusively and then call
- * the page cache to flush and invalidate any cached pages.  If there
- * are no cached pages this routine will be very quick.
- */
-void
-xfs_inval_cached_pages(
-       vnode_t         *vp,
-       xfs_iocore_t    *io,
-       xfs_off_t       offset,
-       int             write,
-       int             relock)
-{
-       xfs_mount_t     *mp;
-
-       if (!VN_CACHED(vp)) {
-               return;
-       }
-
-       mp = io->io_mount;
-
-       /*
-        * We need to get the I/O lock exclusively in order
-        * to safely invalidate pages and mappings.
-        */
-       if (relock) {
-               XFS_IUNLOCK(mp, io, XFS_IOLOCK_SHARED);
-               XFS_ILOCK(mp, io, XFS_IOLOCK_EXCL);
-       }
-
-       /* Writing beyond EOF creates a hole that must be zeroed */
-       if (write && (offset > XFS_SIZE(mp, io))) {
-               xfs_fsize_t     isize;
-
-               XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-               isize = XFS_SIZE(mp, io);
-               if (offset > isize) {
-                       xfs_zero_eof(vp, io, offset, isize, offset);
-               }
-               XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-       }
-
-       xfs_inval_cached_trace(io, offset, -1, ctooff(offtoct(offset)), -1);
-       VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
-       if (relock) {
-               XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
-       }
-}
-
-ssize_t                        /* bytes read, or (-)  error */
-xfs_read(
-       bhv_desc_t              *bdp,
-       struct kiocb            *iocb,
-       const struct iovec      *iovp,
-       unsigned int            segs,
-       loff_t                  *offset,
-       int                     ioflags,
-       cred_t                  *credp)
-{
-       struct file             *file = iocb->ki_filp;
-       size_t                  size = 0;
-       ssize_t                 ret;
-       xfs_fsize_t             n;
-       xfs_inode_t             *ip;
-       xfs_mount_t             *mp;
-       vnode_t                 *vp;
-       unsigned long           seg;
-
-       ip = XFS_BHVTOI(bdp);
-       vp = BHV_TO_VNODE(bdp);
-       mp = ip->i_mount;
-
-       XFS_STATS_INC(xs_read_calls);
-
-       /* START copy & waste from filemap.c */
-       for (seg = 0; seg < segs; seg++) {
-               const struct iovec *iv = &iovp[seg];
-
-               /*
-                * If any segment has a negative length, or the cumulative
-                * length ever wraps negative then return -EINVAL.
-                */
-               size += iv->iov_len;
-               if (unlikely((ssize_t)(size|iv->iov_len) < 0))
-                       return XFS_ERROR(-EINVAL);
-       }
-       /* END copy & waste from filemap.c */
-
-       if (ioflags & IO_ISDIRECT) {
-               xfs_buftarg_t   *target =
-                       (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
-                               mp->m_rtdev_targp : mp->m_ddev_targp;
-               if ((*offset & target->pbr_smask) ||
-                   (size & target->pbr_smask)) {
-                       if (*offset == ip->i_d.di_size) {
-                               return (0);
-                       }
-                       return -XFS_ERROR(EINVAL);
-               }
-       }
-
-       n = XFS_MAXIOFFSET(mp) - *offset;
-       if ((n <= 0) || (size == 0))
-               return 0;
-
-       if (n < size)
-               size = n;
-
-       if (XFS_FORCED_SHUTDOWN(mp)) {
-               return -EIO;
-       }
-
-       /* OK so we are holding the I/O lock for the duration
-        * of the submission, then what happens if the I/O
-        * does not really happen here, but is scheduled 
-        * later?
-        */
-       xfs_ilock(ip, XFS_IOLOCK_SHARED);
-
-       if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
-           !(ioflags & IO_INVIS)) {
-               vrwlock_t locktype = VRWLOCK_READ;
-
-               ret = XFS_SEND_DATA(mp, DM_EVENT_READ,
-                                       BHV_TO_VNODE(bdp), *offset, size,
-                                       FILP_DELAY_FLAG(file), &locktype);
-               if (ret) {
-                       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-                       return -ret;
-               }
-       }
-
-       xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
-                               iovp, segs, *offset, ioflags);
-       ret = __generic_file_aio_read(iocb, iovp, segs, offset);
-       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-
-       if (ret > 0)
-               XFS_STATS_ADD(xs_read_bytes, ret);
-
-       if (likely(!(ioflags & IO_INVIS)))
-               xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
-
-       return ret;
-}
-
-ssize_t
-xfs_sendfile(
-       bhv_desc_t              *bdp,
-       struct file             *filp,
-       loff_t                  *offset,
-       int                     ioflags,
-       size_t                  count,
-       read_actor_t            actor,
-       void                    *target,
-       cred_t                  *credp)
-{
-       ssize_t                 ret;
-       xfs_fsize_t             n;
-       xfs_inode_t             *ip;
-       xfs_mount_t             *mp;
-       vnode_t                 *vp;
-
-       ip = XFS_BHVTOI(bdp);
-       vp = BHV_TO_VNODE(bdp);
-       mp = ip->i_mount;
-
-       XFS_STATS_INC(xs_read_calls);
-
-       n = XFS_MAXIOFFSET(mp) - *offset;
-       if ((n <= 0) || (count == 0))
-               return 0;
-
-       if (n < count)
-               count = n;
-
-       if (XFS_FORCED_SHUTDOWN(ip->i_mount))
-               return -EIO;
-
-       xfs_ilock(ip, XFS_IOLOCK_SHARED);
-
-       if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
-           (!(ioflags & IO_INVIS))) {
-               vrwlock_t locktype = VRWLOCK_READ;
-               int error;
-
-               error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, count,
-                                     FILP_DELAY_FLAG(filp), &locktype);
-               if (error) {
-                       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-                       return -error;
-               }
-       }
-       xfs_rw_enter_trace(XFS_SENDFILE_ENTER, &ip->i_iocore,
-                               target, count, *offset, ioflags);
-       ret = generic_file_sendfile(filp, offset, count, actor, target);
-       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-
-       XFS_STATS_ADD(xs_read_bytes, ret);
-       xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
-       return ret;
-}
-
-/*
- * This routine is called to handle zeroing any space in the last
- * block of the file that is beyond the EOF.  We do this since the
- * size is being increased without writing anything to that block
- * and we don't want anyone to read the garbage on the disk.
- */
-STATIC int                             /* error (positive) */
-xfs_zero_last_block(
-       struct inode    *ip,
-       xfs_iocore_t    *io,
-       xfs_off_t       offset,
-       xfs_fsize_t     isize,
-       xfs_fsize_t     end_size)
-{
-       xfs_fileoff_t   last_fsb;
-       xfs_mount_t     *mp;
-       int             nimaps;
-       int             zero_offset;
-       int             zero_len;
-       int             isize_fsb_offset;
-       int             error = 0;
-       xfs_bmbt_irec_t imap;
-       loff_t          loff;
-       size_t          lsize;
-
-       ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);
-       ASSERT(offset > isize);
-
-       mp = io->io_mount;
-
-       isize_fsb_offset = XFS_B_FSB_OFFSET(mp, isize);
-       if (isize_fsb_offset == 0) {
-               /*
-                * There are no extra bytes in the last block on disk to
-                * zero, so return.
-                */
-               return 0;
-       }
-
-       last_fsb = XFS_B_TO_FSBT(mp, isize);
-       nimaps = 1;
-       error = XFS_BMAPI(mp, NULL, io, last_fsb, 1, 0, NULL, 0, &imap,
-                         &nimaps, NULL);
-       if (error) {
-               return error;
-       }
-       ASSERT(nimaps > 0);
-       /*
-        * If the block underlying isize is just a hole, then there
-        * is nothing to zero.
-        */
-       if (imap.br_startblock == HOLESTARTBLOCK) {
-               return 0;
-       }
-       /*
-        * Zero the part of the last block beyond the EOF, and write it
-        * out sync.  We need to drop the ilock while we do this so we
-        * don't deadlock when the buffer cache calls back to us.
-        */
-       XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);
-       loff = XFS_FSB_TO_B(mp, last_fsb);
-       lsize = XFS_FSB_TO_B(mp, 1);
-
-       zero_offset = isize_fsb_offset;
-       zero_len = mp->m_sb.sb_blocksize - isize_fsb_offset;
-
-       error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size);
-
-       XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-       ASSERT(error >= 0);
-       return error;
-}
-
-/*
- * Zero any on disk space between the current EOF and the new,
- * larger EOF.  This handles the normal case of zeroing the remainder
- * of the last block in the file and the unusual case of zeroing blocks
- * out beyond the size of the file.  This second case only happens
- * with fixed size extents and when the system crashes before the inode
- * size was updated but after blocks were allocated.  If fill is set,
- * then any holes in the range are filled and zeroed.  If not, the holes
- * are left alone as holes.
- */
-
-int                                    /* error (positive) */
-xfs_zero_eof(
-       vnode_t         *vp,
-       xfs_iocore_t    *io,
-       xfs_off_t       offset,         /* starting I/O offset */
-       xfs_fsize_t     isize,          /* current inode size */
-       xfs_fsize_t     end_size)       /* terminal inode size */
-{
-       struct inode    *ip = LINVFS_GET_IP(vp);
-       xfs_fileoff_t   start_zero_fsb;
-       xfs_fileoff_t   end_zero_fsb;
-       xfs_fileoff_t   prev_zero_fsb;
-       xfs_fileoff_t   zero_count_fsb;
-       xfs_fileoff_t   last_fsb;
-       xfs_extlen_t    buf_len_fsb;
-       xfs_extlen_t    prev_zero_count;
-       xfs_mount_t     *mp;
-       int             nimaps;
-       int             error = 0;
-       xfs_bmbt_irec_t imap;
-       loff_t          loff;
-       size_t          lsize;
-
-       ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
-       ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
-
-       mp = io->io_mount;
-
-       /*
-        * First handle zeroing the block on which isize resides.
-        * We only zero a part of that block so it is handled specially.
-        */
-       error = xfs_zero_last_block(ip, io, offset, isize, end_size);
-       if (error) {
-               ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
-               ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
-               return error;
-       }
-
-       /*
-        * Calculate the range between the new size and the old
-        * where blocks needing to be zeroed may exist.  To get the
-        * block where the last byte in the file currently resides,
-        * we need to subtract one from the size and truncate back
-        * to a block boundary.  We subtract 1 in case the size is
-        * exactly on a block boundary.
-        */
-       last_fsb = isize ? XFS_B_TO_FSBT(mp, isize - 1) : (xfs_fileoff_t)-1;
-       start_zero_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)isize);
-       end_zero_fsb = XFS_B_TO_FSBT(mp, offset - 1);
-       ASSERT((xfs_sfiloff_t)last_fsb < (xfs_sfiloff_t)start_zero_fsb);
-       if (last_fsb == end_zero_fsb) {
-               /*
-                * The size was only incremented on its last block.
-                * We took care of that above, so just return.
-                */
-               return 0;
-       }
-
-       ASSERT(start_zero_fsb <= end_zero_fsb);
-       prev_zero_fsb = NULLFILEOFF;
-       prev_zero_count = 0;
-       while (start_zero_fsb <= end_zero_fsb) {
-               nimaps = 1;
-               zero_count_fsb = end_zero_fsb - start_zero_fsb + 1;
-               error = XFS_BMAPI(mp, NULL, io, start_zero_fsb, zero_count_fsb,
-                                 0, NULL, 0, &imap, &nimaps, NULL);
-               if (error) {
-                       ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
-                       ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
-                       return error;
-               }
-               ASSERT(nimaps > 0);
-
-               if (imap.br_state == XFS_EXT_UNWRITTEN ||
-                   imap.br_startblock == HOLESTARTBLOCK) {
-                       /*
-                        * This loop handles initializing pages that were
-                        * partially initialized by the code below this
-                        * loop. It basically zeroes the part of the page
-                        * that sits on a hole and sets the page as P_HOLE
-                        * and calls remapf if it is a mapped file.
-                        */
-                       prev_zero_fsb = NULLFILEOFF;
-                       prev_zero_count = 0;
-                       start_zero_fsb = imap.br_startoff +
-                                        imap.br_blockcount;
-                       ASSERT(start_zero_fsb <= (end_zero_fsb + 1));
-                       continue;
-               }
-
-               /*
-                * There are blocks in the range requested.
-                * Zero them a single write at a time.  We actually
-                * don't zero the entire range returned if it is
-                * too big and simply loop around to get the rest.
-                * That is not the most efficient thing to do, but it
-                * is simple and this path should not be exercised often.
-                */
-               buf_len_fsb = XFS_FILBLKS_MIN(imap.br_blockcount,
-                                             mp->m_writeio_blocks << 8);
-               /*
-                * Drop the inode lock while we're doing the I/O.
-                * We'll still have the iolock to protect us.
-                */
-               XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-
-               loff = XFS_FSB_TO_B(mp, start_zero_fsb);
-               lsize = XFS_FSB_TO_B(mp, buf_len_fsb);
-
-               error = xfs_iozero(ip, loff, lsize, end_size);
-
-               if (error) {
-                       goto out_lock;
-               }
-
-               prev_zero_fsb = start_zero_fsb;
-               prev_zero_count = buf_len_fsb;
-               start_zero_fsb = imap.br_startoff + buf_len_fsb;
-               ASSERT(start_zero_fsb <= (end_zero_fsb + 1));
-
-               XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-       }
-
-       return 0;
-
-out_lock:
-
-       XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-       ASSERT(error >= 0);
-       return error;
-}
-
-ssize_t                                /* bytes written, or (-) error */
-xfs_write(
-       bhv_desc_t              *bdp,
-       struct kiocb            *iocb,
-       const struct iovec      *iovp,
-       unsigned int            segs,
-       loff_t                  *offset,
-       int                     ioflags,
-       cred_t                  *credp)
-{
-       struct file             *file = iocb->ki_filp;
-       size_t                  size = 0;
-       xfs_inode_t             *xip;
-       xfs_mount_t             *mp;
-       ssize_t                 ret;
-       int                     error = 0;
-       xfs_fsize_t             isize, new_size;
-       xfs_fsize_t             n, limit;
-       xfs_iocore_t            *io;
-       vnode_t                 *vp;
-       unsigned long           seg;
-       int                     iolock;
-       int                     eventsent = 0;
-       vrwlock_t               locktype;
-
-       XFS_STATS_INC(xs_write_calls);
-
-       vp = BHV_TO_VNODE(bdp);
-       xip = XFS_BHVTOI(bdp);
-
-       /* START copy & waste from filemap.c */
-       for (seg = 0; seg < segs; seg++) {
-               const struct iovec *iv = &iovp[seg];
-
-               /*
-                * If any segment has a negative length, or the cumulative
-                * length ever wraps negative then return -EINVAL.
-                */
-               size += iv->iov_len;
-               if (unlikely((ssize_t)(size|iv->iov_len) < 0))
-                       return XFS_ERROR(-EINVAL);
-       }
-       /* END copy & waste from filemap.c */
-
-       if (size == 0)
-               return 0;
-
-       io = &xip->i_iocore;
-       mp = io->io_mount;
-
-       if (XFS_FORCED_SHUTDOWN(mp)) {
-               return -EIO;
-       }
-
-       if (ioflags & IO_ISDIRECT) {
-               xfs_buftarg_t   *target =
-                       (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
-                               mp->m_rtdev_targp : mp->m_ddev_targp;
-
-               if ((*offset & target->pbr_smask) ||
-                   (size & target->pbr_smask)) {
-                       return XFS_ERROR(-EINVAL);
-               }
-               iolock = XFS_IOLOCK_SHARED;
-               locktype = VRWLOCK_WRITE_DIRECT;
-       } else {
-               iolock = XFS_IOLOCK_EXCL;
-               locktype = VRWLOCK_WRITE;
-       }
-
-       xfs_ilock(xip, XFS_ILOCK_EXCL|iolock);
-
-       isize = xip->i_d.di_size;
-       limit = XFS_MAXIOFFSET(mp);
-
-       if (file->f_flags & O_APPEND)
-               *offset = isize;
-
-start:
-       n = limit - *offset;
-       if (n <= 0) {
-               xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
-               return -EFBIG;
-       }
-
-       if (n < size)
-               size = n;
-
-       new_size = *offset + size;
-       if (new_size > isize) {
-               io->io_new_size = new_size;
-       }
-
-       if ((DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_WRITE) &&
-           !(ioflags & IO_INVIS) && !eventsent)) {
-               loff_t          savedsize = *offset;
-               int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
-
-               xfs_iunlock(xip, XFS_ILOCK_EXCL);
-               error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp,
-                                     *offset, size,
-                                     dmflags, &locktype);
-               if (error) {
-                       xfs_iunlock(xip, iolock);
-                       return -error;
-               }
-               xfs_ilock(xip, XFS_ILOCK_EXCL);
-               eventsent = 1;
-
-               /*
-                * The iolock was dropped and reaquired in XFS_SEND_DATA
-                * so we have to recheck the size when appending.
-                * We will only "goto start;" once, since having sent the
-                * event prevents another call to XFS_SEND_DATA, which is
-                * what allows the size to change in the first place.
-                */
-               if ((file->f_flags & O_APPEND) &&
-                   savedsize != xip->i_d.di_size) {
-                       *offset = isize = xip->i_d.di_size;
-                       goto start;
-               }
-       }
-
-       /*
-        * On Linux, generic_file_write updates the times even if
-        * no data is copied in so long as the write had a size.
-        *
-        * We must update xfs' times since revalidate will overcopy xfs.
-        */
-       if (size && !(ioflags & IO_INVIS))
-               xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-
-       /*
-        * If the offset is beyond the size of the file, we have a couple
-        * of things to do. First, if there is already space allocated
-        * we need to either create holes or zero the disk or ...
-        *
-        * If there is a page where the previous size lands, we need
-        * to zero it out up to the new size.
-        */
-
-       if (!(ioflags & IO_ISDIRECT) && (*offset > isize && isize)) {
-               error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, *offset,
-                       isize, *offset + size);
-               if (error) {
-                       xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
-                       return(-error);
-               }
-       }
-       xfs_iunlock(xip, XFS_ILOCK_EXCL);
-
-       /*
-        * If we're writing the file then make sure to clear the
-        * setuid and setgid bits if the process is not being run
-        * by root.  This keeps people from modifying setuid and
-        * setgid binaries.
-        */
-
-       if (((xip->i_d.di_mode & S_ISUID) ||
-           ((xip->i_d.di_mode & (S_ISGID | S_IXGRP)) ==
-               (S_ISGID | S_IXGRP))) &&
-            !capable(CAP_FSETID)) {
-               error = xfs_write_clear_setuid(xip);
-               if (error) {
-                       xfs_iunlock(xip, iolock);
-                       return -error;
-               }
-       }
-
-retry:
-       if (ioflags & IO_ISDIRECT) {
-               xfs_inval_cached_pages(vp, io, *offset, 1, 1);
-               xfs_rw_enter_trace(XFS_DIOWR_ENTER,
-                               io, iovp, segs, *offset, ioflags);
-       } else {
-               xfs_rw_enter_trace(XFS_WRITE_ENTER,
-                               io, iovp, segs, *offset, ioflags);
-       }
-       ret = generic_file_aio_write_nolock(iocb, iovp, segs, offset);
-
-       if ((ret == -ENOSPC) &&
-           DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_NOSPACE) &&
-           !(ioflags & IO_INVIS)) {
-
-               xfs_rwunlock(bdp, locktype);
-               error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
-                               DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
-                               0, 0, 0); /* Delay flag intentionally  unused */
-               if (error)
-                       return -error;
-               xfs_rwlock(bdp, locktype);
-               *offset = xip->i_d.di_size;
-               goto retry;
-       }
-
-       if (*offset > xip->i_d.di_size) {
-               xfs_ilock(xip, XFS_ILOCK_EXCL);
-               if (*offset > xip->i_d.di_size) {
-                       struct inode    *inode = LINVFS_GET_IP(vp);
-
-                       xip->i_d.di_size = *offset;
-                       i_size_write(inode, *offset);
-                       xip->i_update_core = 1;
-                       xip->i_update_size = 1;
-               }
-               xfs_iunlock(xip, XFS_ILOCK_EXCL);
-       }
-
-       if (ret <= 0) {
-               xfs_rwunlock(bdp, locktype);
-               return ret;
-       }
-
-       XFS_STATS_ADD(xs_write_bytes, ret);
-
-       /* Handle various SYNC-type writes */
-       if ((file->f_flags & O_SYNC) || IS_SYNC(file->f_dentry->d_inode)) {
-
-               /*
-                * If we're treating this as O_DSYNC and we have not updated the
-                * size, force the log.
-                */
-
-               if (!(mp->m_flags & XFS_MOUNT_OSYNCISOSYNC)
-                       && !(xip->i_update_size)) {
-                       /*
-                        * If an allocation transaction occurred
-                        * without extending the size, then we have to force
-                        * the log up the proper point to ensure that the
-                        * allocation is permanent.  We can't count on
-                        * the fact that buffered writes lock out direct I/O
-                        * writes - the direct I/O write could have extended
-                        * the size nontransactionally, then finished before
-                        * we started.  xfs_write_file will think that the file
-                        * didn't grow but the update isn't safe unless the
-                        * size change is logged.
-                        *
-                        * Force the log if we've committed a transaction
-                        * against the inode or if someone else has and
-                        * the commit record hasn't gone to disk (e.g.
-                        * the inode is pinned).  This guarantees that
-                        * all changes affecting the inode are permanent
-                        * when we return.
-                        */
-
-                       xfs_inode_log_item_t *iip;
-                       xfs_lsn_t lsn;
-
-                       iip = xip->i_itemp;
-                       if (iip && iip->ili_last_lsn) {
-                               lsn = iip->ili_last_lsn;
-                               xfs_log_force(mp, lsn,
-                                               XFS_LOG_FORCE | XFS_LOG_SYNC);
-                       } else if (xfs_ipincount(xip) > 0) {
-                               xfs_log_force(mp, (xfs_lsn_t)0,
-                                               XFS_LOG_FORCE | XFS_LOG_SYNC);
-                       }
-
-               } else {
-                       xfs_trans_t     *tp;
-
-                       /*
-                        * O_SYNC or O_DSYNC _with_ a size update are handled
-                        * the same way.
-                        *
-                        * If the write was synchronous then we need to make
-                        * sure that the inode modification time is permanent.
-                        * We'll have updated the timestamp above, so here
-                        * we use a synchronous transaction to log the inode.
-                        * It's not fast, but it's necessary.
-                        *
-                        * If this a dsync write and the size got changed
-                        * non-transactionally, then we need to ensure that
-                        * the size change gets logged in a synchronous
-                        * transaction.
-                        */
-
-                       tp = xfs_trans_alloc(mp, XFS_TRANS_WRITE_SYNC);
-                       if ((error = xfs_trans_reserve(tp, 0,
-                                                     XFS_SWRITE_LOG_RES(mp),
-                                                     0, 0, 0))) {
-                               /* Transaction reserve failed */
-                               xfs_trans_cancel(tp, 0);
-                       } else {
-                               /* Transaction reserve successful */
-                               xfs_ilock(xip, XFS_ILOCK_EXCL);
-                               xfs_trans_ijoin(tp, xip, XFS_ILOCK_EXCL);
-                               xfs_trans_ihold(tp, xip);
-                               xfs_trans_log_inode(tp, xip, XFS_ILOG_CORE);
-                               xfs_trans_set_sync(tp);
-                               error = xfs_trans_commit(tp, 0, (xfs_lsn_t)0);
-                               xfs_iunlock(xip, XFS_ILOCK_EXCL);
-                       }
-               }
-       } /* (ioflags & O_SYNC) */
-
-       xfs_rwunlock(bdp, locktype);
-       return(ret);
-}
-
-/*
- * All xfs metadata buffers except log state machine buffers
- * get this attached as their b_bdstrat callback function.
- * This is so that we can catch a buffer
- * after prematurely unpinning it to forcibly shutdown the filesystem.
- */
-int
-xfs_bdstrat_cb(struct xfs_buf *bp)
-{
-       xfs_mount_t     *mp;
-
-       mp = XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *);
-       if (!XFS_FORCED_SHUTDOWN(mp)) {
-               pagebuf_iorequest(bp);
-               return 0;
-       } else {
-               xfs_buftrace("XFS__BDSTRAT IOERROR", bp);
-               /*
-                * Metadata write that didn't get logged but
-                * written delayed anyway. These aren't associated
-                * with a transaction, and can be ignored.
-                */
-               if (XFS_BUF_IODONE_FUNC(bp) == NULL &&
-                   (XFS_BUF_ISREAD(bp)) == 0)
-                       return (xfs_bioerror_relse(bp));
-               else
-                       return (xfs_bioerror(bp));
-       }
-}
-
-
-int
-xfs_bmap(bhv_desc_t    *bdp,
-       xfs_off_t       offset,
-       ssize_t         count,
-       int             flags,
-       xfs_iomap_t     *iomapp,
-       int             *niomaps)
-{
-       xfs_inode_t     *ip = XFS_BHVTOI(bdp);
-       xfs_iocore_t    *io = &ip->i_iocore;
-
-       ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
-       ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
-              ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
-
-       return xfs_iomap(io, offset, count, flags, iomapp, niomaps);
-}
-
-/*
- * Wrapper around bdstrat so that we can stop data
- * from going to disk in case we are shutting down the filesystem.
- * Typically user data goes thru this path; one of the exceptions
- * is the superblock.
- */
-int
-xfsbdstrat(
-       struct xfs_mount        *mp,
-       struct xfs_buf          *bp)
-{
-       ASSERT(mp);
-       if (!XFS_FORCED_SHUTDOWN(mp)) {
-               /* Grio redirection would go here
-                * if (XFS_BUF_IS_GRIO(bp)) {
-                */
-
-               pagebuf_iorequest(bp);
-               return 0;
-       }
-
-       xfs_buftrace("XFSBDSTRAT IOERROR", bp);
-       return (xfs_bioerror_relse(bp));
-}
-
-/*
- * If the underlying (data/log/rt) device is readonly, there are some
- * operations that cannot proceed.
- */
-int
-xfs_dev_is_read_only(
-       xfs_mount_t             *mp,
-       char                    *message)
-{
-       if (xfs_readonly_buftarg(mp->m_ddev_targp) ||
-           xfs_readonly_buftarg(mp->m_logdev_targp) ||
-           (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) {
-               cmn_err(CE_NOTE,
-                       "XFS: %s required on read-only device.", message);
-               cmn_err(CE_NOTE,
-                       "XFS: write access unavailable, cannot proceed.");
-               return EROFS;
-       }
-       return 0;
-}
diff --git a/fs/xfs/linux/xfs_lrw.h b/fs/xfs/linux/xfs_lrw.h
deleted file mode 100644 (file)
index faf0afc..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_LRW_H__
-#define __XFS_LRW_H__
-
-struct vnode;
-struct bhv_desc;
-struct xfs_mount;
-struct xfs_iocore;
-struct xfs_inode;
-struct xfs_bmbt_irec;
-struct xfs_buf;
-struct xfs_iomap;
-
-#if defined(XFS_RW_TRACE)
-/*
- * Defines for the trace mechanisms in xfs_lrw.c.
- */
-#define        XFS_RW_KTRACE_SIZE      128
-
-#define        XFS_READ_ENTER          1
-#define        XFS_WRITE_ENTER         2
-#define XFS_IOMAP_READ_ENTER   3
-#define        XFS_IOMAP_WRITE_ENTER   4
-#define        XFS_IOMAP_READ_MAP      5
-#define        XFS_IOMAP_WRITE_MAP     6
-#define        XFS_IOMAP_WRITE_NOSPACE 7
-#define        XFS_ITRUNC_START        8
-#define        XFS_ITRUNC_FINISH1      9
-#define        XFS_ITRUNC_FINISH2      10
-#define        XFS_CTRUNC1             11
-#define        XFS_CTRUNC2             12
-#define        XFS_CTRUNC3             13
-#define        XFS_CTRUNC4             14
-#define        XFS_CTRUNC5             15
-#define        XFS_CTRUNC6             16
-#define        XFS_BUNMAPI             17
-#define        XFS_INVAL_CACHED        18
-#define        XFS_DIORD_ENTER         19
-#define        XFS_DIOWR_ENTER         20
-#define        XFS_SENDFILE_ENTER      21
-#define        XFS_WRITEPAGE_ENTER     22
-#define        XFS_RELEASEPAGE_ENTER   23
-#define        XFS_IOMAP_ALLOC_ENTER   24
-#define        XFS_IOMAP_ALLOC_MAP     25
-#define        XFS_IOMAP_UNWRITTEN     26
-extern void xfs_rw_enter_trace(int, struct xfs_iocore *,
-                       const struct iovec *, size_t, loff_t, int);
-extern void xfs_inval_cached_trace(struct xfs_iocore *,
-                       xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t);
-#else
-#define xfs_rw_enter_trace(tag, io, iovec, segs, offset, ioflags)
-#define xfs_inval_cached_trace(io, offset, len, first, last)
-#endif
-
-/*
- * Maximum count of bmaps used by read and write paths.
- */
-#define        XFS_MAX_RW_NBMAPS       4
-
-extern int xfs_bmap(struct bhv_desc *, xfs_off_t, ssize_t, int,
-                       struct xfs_iomap *, int *);
-extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
-extern int xfs_bdstrat_cb(struct xfs_buf *);
-
-extern int xfs_zero_eof(struct vnode *, struct xfs_iocore *, xfs_off_t,
-                               xfs_fsize_t, xfs_fsize_t);
-extern void xfs_inval_cached_pages(struct vnode        *, struct xfs_iocore *,
-                               xfs_off_t, int, int);
-extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *,
-                               const struct iovec *, unsigned int,
-                               loff_t *, int, struct cred *);
-extern ssize_t xfs_write(struct bhv_desc *, struct kiocb *,
-                               const struct iovec *, unsigned int,
-                               loff_t *, int, struct cred *);
-extern ssize_t xfs_sendfile(struct bhv_desc *, struct file *,
-                               loff_t *, int, size_t, read_actor_t,
-                               void *, struct cred *);
-
-extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
-
-#define XFS_FSB_TO_DB_IO(io,fsb) \
-               (((io)->io_flags & XFS_IOCORE_RT) ? \
-                XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
-                XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
-
-#endif /* __XFS_LRW_H__ */
diff --git a/fs/xfs/linux/xfs_stats.c b/fs/xfs/linux/xfs_stats.c
deleted file mode 100644 (file)
index b7de296..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include <linux/proc_fs.h>
-
-DEFINE_PER_CPU(struct xfsstats, xfsstats);
-
-STATIC int
-xfs_read_xfsstats(
-       char            *buffer,
-       char            **start,
-       off_t           offset,
-       int             count,
-       int             *eof,
-       void            *data)
-{
-       int             c, i, j, len, val;
-       __uint64_t      xs_xstrat_bytes = 0;
-       __uint64_t      xs_write_bytes = 0;
-       __uint64_t      xs_read_bytes = 0;
-
-       static struct xstats_entry {
-               char    *desc;
-               int     endpoint;
-       } xstats[] = {
-               { "extent_alloc",       XFSSTAT_END_EXTENT_ALLOC        },
-               { "abt",                XFSSTAT_END_ALLOC_BTREE         },
-               { "blk_map",            XFSSTAT_END_BLOCK_MAPPING       },
-               { "bmbt",               XFSSTAT_END_BLOCK_MAP_BTREE     },
-               { "dir",                XFSSTAT_END_DIRECTORY_OPS       },
-               { "trans",              XFSSTAT_END_TRANSACTIONS        },
-               { "ig",                 XFSSTAT_END_INODE_OPS           },
-               { "log",                XFSSTAT_END_LOG_OPS             },
-               { "push_ail",           XFSSTAT_END_TAIL_PUSHING        },
-               { "xstrat",             XFSSTAT_END_WRITE_CONVERT       },
-               { "rw",                 XFSSTAT_END_READ_WRITE_OPS      },
-               { "attr",               XFSSTAT_END_ATTRIBUTE_OPS       },
-               { "icluster",           XFSSTAT_END_INODE_CLUSTER       },
-               { "vnodes",             XFSSTAT_END_VNODE_OPS           },
-               { "buf",                XFSSTAT_END_BUF                 },
-       };
-
-       /* Loop over all stats groups */
-       for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
-               len += sprintf(buffer + len, xstats[i].desc);
-               /* inner loop does each group */
-               while (j < xstats[i].endpoint) {
-                       val = 0;
-                       /* sum over all cpus */
-                       for (c = 0; c < NR_CPUS; c++) {
-                               if (!cpu_possible(c)) continue;
-                               val += *(((__u32*)&per_cpu(xfsstats, c) + j));
-                       }
-                       len += sprintf(buffer + len, " %u", val);
-                       j++;
-               }
-               buffer[len++] = '\n';
-       }
-       /* extra precision counters */
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!cpu_possible(i)) continue;
-               xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
-               xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
-               xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
-       }
-
-       len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n",
-                       xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
-       len += sprintf(buffer + len, "debug %u\n",
-#if defined(XFSDEBUG)
-               1);
-#else
-               0);
-#endif
-
-       if (offset >= len) {
-               *start = buffer;
-               *eof = 1;
-               return 0;
-       }
-       *start = buffer + offset;
-       if ((len -= offset) > count)
-               return count;
-       *eof = 1;
-
-       return len;
-}
-
-void
-xfs_init_procfs(void)
-{
-       if (!proc_mkdir("fs/xfs", 0))
-               return;
-       create_proc_read_entry("fs/xfs/stat", 0, 0, xfs_read_xfsstats, NULL);
-}
-
-void
-xfs_cleanup_procfs(void)
-{
-       remove_proc_entry("fs/xfs/stat", NULL);
-       remove_proc_entry("fs/xfs", NULL);
-}
diff --git a/fs/xfs/linux/xfs_stats.h b/fs/xfs/linux/xfs_stats.h
deleted file mode 100644 (file)
index 0456600..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_STATS_H__
-#define __XFS_STATS_H__
-
-
-#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
-
-#include <linux/percpu.h>
-
-/*
- * XFS global statistics
- */
-struct xfsstats {
-# define XFSSTAT_END_EXTENT_ALLOC      4
-       __uint32_t              xs_allocx;
-       __uint32_t              xs_allocb;
-       __uint32_t              xs_freex;
-       __uint32_t              xs_freeb;
-# define XFSSTAT_END_ALLOC_BTREE       (XFSSTAT_END_EXTENT_ALLOC+4)
-       __uint32_t              xs_abt_lookup;
-       __uint32_t              xs_abt_compare;
-       __uint32_t              xs_abt_insrec;
-       __uint32_t              xs_abt_delrec;
-# define XFSSTAT_END_BLOCK_MAPPING     (XFSSTAT_END_ALLOC_BTREE+7)
-       __uint32_t              xs_blk_mapr;
-       __uint32_t              xs_blk_mapw;
-       __uint32_t              xs_blk_unmap;
-       __uint32_t              xs_add_exlist;
-       __uint32_t              xs_del_exlist;
-       __uint32_t              xs_look_exlist;
-       __uint32_t              xs_cmp_exlist;
-# define XFSSTAT_END_BLOCK_MAP_BTREE   (XFSSTAT_END_BLOCK_MAPPING+4)
-       __uint32_t              xs_bmbt_lookup;
-       __uint32_t              xs_bmbt_compare;
-       __uint32_t              xs_bmbt_insrec;
-       __uint32_t              xs_bmbt_delrec;
-# define XFSSTAT_END_DIRECTORY_OPS     (XFSSTAT_END_BLOCK_MAP_BTREE+4)
-       __uint32_t              xs_dir_lookup;
-       __uint32_t              xs_dir_create;
-       __uint32_t              xs_dir_remove;
-       __uint32_t              xs_dir_getdents;
-# define XFSSTAT_END_TRANSACTIONS      (XFSSTAT_END_DIRECTORY_OPS+3)
-       __uint32_t              xs_trans_sync;
-       __uint32_t              xs_trans_async;
-       __uint32_t              xs_trans_empty;
-# define XFSSTAT_END_INODE_OPS         (XFSSTAT_END_TRANSACTIONS+7)
-       __uint32_t              xs_ig_attempts;
-       __uint32_t              xs_ig_found;
-       __uint32_t              xs_ig_frecycle;
-       __uint32_t              xs_ig_missed;
-       __uint32_t              xs_ig_dup;
-       __uint32_t              xs_ig_reclaims;
-       __uint32_t              xs_ig_attrchg;
-# define XFSSTAT_END_LOG_OPS           (XFSSTAT_END_INODE_OPS+5)
-       __uint32_t              xs_log_writes;
-       __uint32_t              xs_log_blocks;
-       __uint32_t              xs_log_noiclogs;
-       __uint32_t              xs_log_force;
-       __uint32_t              xs_log_force_sleep;
-# define XFSSTAT_END_TAIL_PUSHING      (XFSSTAT_END_LOG_OPS+10)
-       __uint32_t              xs_try_logspace;
-       __uint32_t              xs_sleep_logspace;
-       __uint32_t              xs_push_ail;
-       __uint32_t              xs_push_ail_success;
-       __uint32_t              xs_push_ail_pushbuf;
-       __uint32_t              xs_push_ail_pinned;
-       __uint32_t              xs_push_ail_locked;
-       __uint32_t              xs_push_ail_flushing;
-       __uint32_t              xs_push_ail_restarts;
-       __uint32_t              xs_push_ail_flush;
-# define XFSSTAT_END_WRITE_CONVERT     (XFSSTAT_END_TAIL_PUSHING+2)
-       __uint32_t              xs_xstrat_quick;
-       __uint32_t              xs_xstrat_split;
-# define XFSSTAT_END_READ_WRITE_OPS    (XFSSTAT_END_WRITE_CONVERT+2)
-       __uint32_t              xs_write_calls;
-       __uint32_t              xs_read_calls;
-# define XFSSTAT_END_ATTRIBUTE_OPS     (XFSSTAT_END_READ_WRITE_OPS+4)
-       __uint32_t              xs_attr_get;
-       __uint32_t              xs_attr_set;
-       __uint32_t              xs_attr_remove;
-       __uint32_t              xs_attr_list;
-# define XFSSTAT_END_INODE_CLUSTER     (XFSSTAT_END_ATTRIBUTE_OPS+3)
-       __uint32_t              xs_iflush_count;
-       __uint32_t              xs_icluster_flushcnt;
-       __uint32_t              xs_icluster_flushinode;
-# define XFSSTAT_END_VNODE_OPS         (XFSSTAT_END_INODE_CLUSTER+8)
-       __uint32_t              vn_active;      /* # vnodes not on free lists */
-       __uint32_t              vn_alloc;       /* # times vn_alloc called */
-       __uint32_t              vn_get;         /* # times vn_get called */
-       __uint32_t              vn_hold;        /* # times vn_hold called */
-       __uint32_t              vn_rele;        /* # times vn_rele called */
-       __uint32_t              vn_reclaim;     /* # times vn_reclaim called */
-       __uint32_t              vn_remove;      /* # times vn_remove called */
-       __uint32_t              vn_free;        /* # times vn_free called */
-#define XFSSTAT_END_BUF                        (XFSSTAT_END_VNODE_OPS+9)
-       __uint32_t              pb_get;
-       __uint32_t              pb_create;
-       __uint32_t              pb_get_locked;
-       __uint32_t              pb_get_locked_waited;
-       __uint32_t              pb_busy_locked;
-       __uint32_t              pb_miss_locked;
-       __uint32_t              pb_page_retries;
-       __uint32_t              pb_page_found;
-       __uint32_t              pb_get_read;
-/* Extra precision counters */
-       __uint64_t              xs_xstrat_bytes;
-       __uint64_t              xs_write_bytes;
-       __uint64_t              xs_read_bytes;
-};
-
-DECLARE_PER_CPU(struct xfsstats, xfsstats);
-
-/* We don't disable preempt, not too worried about poking the
- * wrong cpu's stat for now */
-#define XFS_STATS_INC(count)           (__get_cpu_var(xfsstats).count++)
-#define XFS_STATS_DEC(count)           (__get_cpu_var(xfsstats).count--)
-#define XFS_STATS_ADD(count, inc)      (__get_cpu_var(xfsstats).count += (inc))
-
-extern void xfs_init_procfs(void);
-extern void xfs_cleanup_procfs(void);
-
-
-#else  /* !CONFIG_PROC_FS */
-
-# define XFS_STATS_INC(count)
-# define XFS_STATS_DEC(count)
-# define XFS_STATS_ADD(count, inc)
-
-static __inline void xfs_init_procfs(void) { };
-static __inline void xfs_cleanup_procfs(void) { };
-
-#endif /* !CONFIG_PROC_FS */
-
-#endif /* __XFS_STATS_H__ */
diff --git a/fs/xfs/linux/xfs_super.c b/fs/xfs/linux/xfs_super.c
deleted file mode 100644 (file)
index bbaf61b..0000000
+++ /dev/null
@@ -1,850 +0,0 @@
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_clnt.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_quota.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-#include "xfs_version.h"
-
-#include <linux/namei.h>
-#include <linux/init.h>
-#include <linux/mount.h>
-#include <linux/suspend.h>
-
-STATIC struct quotactl_ops linvfs_qops;
-STATIC struct super_operations linvfs_sops;
-STATIC struct export_operations linvfs_export_ops;
-STATIC kmem_cache_t * linvfs_inode_cachep;
-
-STATIC struct xfs_mount_args *
-xfs_args_allocate(
-       struct super_block      *sb)
-{
-       struct xfs_mount_args   *args;
-
-       args = kmem_zalloc(sizeof(struct xfs_mount_args), KM_SLEEP);
-       args->logbufs = args->logbufsize = -1;
-       strncpy(args->fsname, sb->s_id, MAXNAMELEN);
-
-       /* Copy the already-parsed mount(2) flags we're interested in */
-       if (sb->s_flags & MS_NOATIME)
-               args->flags |= XFSMNT_NOATIME;
-
-       /* Default to 32 bit inodes on Linux all the time */
-       args->flags |= XFSMNT_32BITINODES;
-
-       return args;
-}
-
-__uint64_t
-xfs_max_file_offset(
-       unsigned int            blockshift)
-{
-       unsigned int            pagefactor = 1;
-       unsigned int            bitshift = BITS_PER_LONG - 1;
-
-       /* Figure out maximum filesize, on Linux this can depend on
-        * the filesystem blocksize (on 32 bit platforms).
-        * __block_prepare_write does this in an [unsigned] long...
-        *      page->index << (PAGE_CACHE_SHIFT - bbits)
-        * So, for page sized blocks (4K on 32 bit platforms),
-        * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
-        *      (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
-        * but for smaller blocksizes it is less (bbits = log2 bsize).
-        * Note1: get_block_t takes a long (implicit cast from above)
-        * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
-        * can optionally convert the [unsigned] long from above into
-        * an [unsigned] long long.
-        */
-
-#if BITS_PER_LONG == 32
-# if defined(CONFIG_LBD)
-       ASSERT(sizeof(sector_t) == 8);
-       pagefactor = PAGE_CACHE_SIZE;
-       bitshift = BITS_PER_LONG;
-# else
-       pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
-# endif
-#endif
-
-       return (((__uint64_t)pagefactor) << bitshift) - 1;
-}
-
-STATIC __inline__ void
-xfs_set_inodeops(
-       struct inode            *inode)
-{
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
-
-       if (vp->v_type == VNON) {
-               make_bad_inode(inode);
-       } else if (S_ISREG(inode->i_mode)) {
-               inode->i_op = &linvfs_file_inode_operations;
-               inode->i_fop = &linvfs_file_operations;
-               inode->i_mapping->a_ops = &linvfs_aops;
-       } else if (S_ISDIR(inode->i_mode)) {
-               inode->i_op = &linvfs_dir_inode_operations;
-               inode->i_fop = &linvfs_dir_operations;
-       } else if (S_ISLNK(inode->i_mode)) {
-               inode->i_op = &linvfs_symlink_inode_operations;
-               if (inode->i_blocks)
-                       inode->i_mapping->a_ops = &linvfs_aops;
-       } else {
-               inode->i_op = &linvfs_file_inode_operations;
-               init_special_inode(inode, inode->i_mode, inode->i_rdev);
-       }
-}
-
-STATIC __inline__ void
-xfs_revalidate_inode(
-       xfs_mount_t             *mp,
-       vnode_t                 *vp,
-       xfs_inode_t             *ip)
-{
-       struct inode            *inode = LINVFS_GET_IP(vp);
-
-       inode->i_mode   = (ip->i_d.di_mode & MODEMASK) | VTTOIF(vp->v_type);
-       inode->i_nlink  = ip->i_d.di_nlink;
-       inode->i_uid    = ip->i_d.di_uid;
-       inode->i_gid    = ip->i_d.di_gid;
-       if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) {
-               inode->i_rdev = 0;
-       } else {
-               xfs_dev_t dev = ip->i_df.if_u2.if_rdev;
-               inode->i_rdev = MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev));
-       }
-       inode->i_blksize = PAGE_CACHE_SIZE;
-       inode->i_generation = ip->i_d.di_gen;
-       i_size_write(inode, ip->i_d.di_size);
-       inode->i_blocks =
-               XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
-       inode->i_atime.tv_sec   = ip->i_d.di_atime.t_sec;
-       inode->i_atime.tv_nsec  = ip->i_d.di_atime.t_nsec;
-       inode->i_mtime.tv_sec   = ip->i_d.di_mtime.t_sec;
-       inode->i_mtime.tv_nsec  = ip->i_d.di_mtime.t_nsec;
-       inode->i_ctime.tv_sec   = ip->i_d.di_ctime.t_sec;
-       inode->i_ctime.tv_nsec  = ip->i_d.di_ctime.t_nsec;
-       if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
-               inode->i_flags |= S_IMMUTABLE;
-       else
-               inode->i_flags &= ~S_IMMUTABLE;
-       if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
-               inode->i_flags |= S_APPEND;
-       else
-               inode->i_flags &= ~S_APPEND;
-       if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
-               inode->i_flags |= S_SYNC;
-       else
-               inode->i_flags &= ~S_SYNC;
-       if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
-               inode->i_flags |= S_NOATIME;
-       else
-               inode->i_flags &= ~S_NOATIME;
-       vp->v_flag &= ~VMODIFIED;
-}
-
-void
-xfs_initialize_vnode(
-       bhv_desc_t              *bdp,
-       vnode_t                 *vp,
-       bhv_desc_t              *inode_bhv,
-       int                     unlock)
-{
-       xfs_inode_t             *ip = XFS_BHVTOI(inode_bhv);
-       struct inode            *inode = LINVFS_GET_IP(vp);
-
-       if (!inode_bhv->bd_vobj) {
-               vp->v_vfsp = bhvtovfs(bdp);
-               bhv_desc_init(inode_bhv, ip, vp, &xfs_vnodeops);
-               bhv_insert(VN_BHV_HEAD(vp), inode_bhv);
-       }
-
-       vp->v_type = IFTOVT(ip->i_d.di_mode);
-
-       /* Have we been called during the new inode create process,
-        * in which case we are too early to fill in the Linux inode.
-        */
-       if (vp->v_type == VNON)
-               return;
-
-       xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
-
-       /* For new inodes we need to set the ops vectors,
-        * and unlock the inode.
-        */
-       if (unlock && (inode->i_state & I_NEW)) {
-               xfs_set_inodeops(inode);
-               unlock_new_inode(inode);
-       }
-}
-
-void
-xfs_flush_inode(
-       xfs_inode_t     *ip)
-{
-       struct inode    *inode = LINVFS_GET_IP(XFS_ITOV(ip));
-
-       filemap_flush(inode->i_mapping);
-}
-
-void
-xfs_flush_device(
-       xfs_inode_t     *ip)
-{
-       sync_blockdev(XFS_ITOV(ip)->v_vfsp->vfs_super->s_bdev);
-       xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
-}
-
-int
-xfs_blkdev_get(
-       xfs_mount_t             *mp,
-       const char              *name,
-       struct block_device     **bdevp)
-{
-       int                     error = 0;
-
-       *bdevp = open_bdev_excl(name, 0, mp);
-       if (IS_ERR(*bdevp)) {
-               error = PTR_ERR(*bdevp);
-               printk("XFS: Invalid device [%s], error=%d\n", name, error);
-       }
-
-       return -error;
-}
-
-void
-xfs_blkdev_put(
-       struct block_device     *bdev)
-{
-       if (bdev)
-               close_bdev_excl(bdev);
-}
-
-
-STATIC struct inode *
-linvfs_alloc_inode(
-       struct super_block      *sb)
-{
-       vnode_t                 *vp;
-
-       vp = (vnode_t *)kmem_cache_alloc(linvfs_inode_cachep, 
-                kmem_flags_convert(KM_SLEEP));
-       if (!vp)
-               return NULL;
-       return LINVFS_GET_IP(vp);
-}
-
-STATIC void
-linvfs_destroy_inode(
-       struct inode            *inode)
-{
-       kmem_cache_free(linvfs_inode_cachep, LINVFS_GET_VP(inode));
-}
-
-STATIC void
-init_once(
-       void                    *data,
-       kmem_cache_t            *cachep,
-       unsigned long           flags)
-{
-       vnode_t                 *vp = (vnode_t *)data;
-
-       if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-           SLAB_CTOR_CONSTRUCTOR)
-               inode_init_once(LINVFS_GET_IP(vp));
-}
-
-STATIC int
-init_inodecache( void )
-{
-       linvfs_inode_cachep = kmem_cache_create("linvfs_icache",
-                               sizeof(vnode_t), 0,
-                               SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
-                               init_once, NULL);
-
-       if (linvfs_inode_cachep == NULL)
-               return -ENOMEM;
-       return 0;
-}
-
-STATIC void
-destroy_inodecache( void )
-{
-       if (kmem_cache_destroy(linvfs_inode_cachep))
-               printk(KERN_WARNING "%s: cache still in use!\n", __FUNCTION__);
-}
-
-/*
- * Attempt to flush the inode, this will actually fail
- * if the inode is pinned, but we dirty the inode again
- * at the point when it is unpinned after a log write,
- * since this is when the inode itself becomes flushable. 
- */
-STATIC void
-linvfs_write_inode(
-       struct inode            *inode,
-       int                     sync)
-{
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
-       int                     error, flags = FLUSH_INODE;
-
-       if (vp) {
-               vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
-               if (sync)
-                       flags |= FLUSH_SYNC;
-               VOP_IFLUSH(vp, flags, error);
-       }
-}
-
-STATIC void
-linvfs_clear_inode(
-       struct inode            *inode)
-{
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
-
-       if (vp) {
-               vn_rele(vp);
-               vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
-               /*
-                * Do all our cleanup, and remove this vnode.
-                */
-               vn_remove(vp);
-       }
-}
-
-
-#define SYNCD_FLAGS    (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR)
-
-STATIC int
-xfssyncd(
-       void                    *arg)
-{
-       vfs_t                   *vfsp = (vfs_t *) arg;
-       int                     error;
-
-       daemonize("xfssyncd");
-
-       vfsp->vfs_sync_task = current;
-       wmb();
-       wake_up(&vfsp->vfs_wait_sync_task);
-
-       for (;;) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(xfs_syncd_interval);
-               /* swsusp */
-               if (current->flags & PF_FREEZE)
-                       refrigerator(PF_FREEZE);
-               if (vfsp->vfs_flag & VFS_UMOUNT)
-                       break;
-               if (vfsp->vfs_flag & VFS_RDONLY)
-                       continue;
-               VFS_SYNC(vfsp, SYNCD_FLAGS, NULL, error);
-       }
-
-       vfsp->vfs_sync_task = NULL;
-       wmb();
-       wake_up(&vfsp->vfs_wait_sync_task);
-
-       return 0;
-}
-
-STATIC int
-linvfs_start_syncd(
-       vfs_t                   *vfsp)
-{
-       int                     pid;
-
-       pid = kernel_thread(xfssyncd, (void *) vfsp,
-                       CLONE_VM | CLONE_FS | CLONE_FILES);
-       if (pid < 0)
-               return -pid;
-       wait_event(vfsp->vfs_wait_sync_task, vfsp->vfs_sync_task);
-       return 0;
-}
-
-STATIC void
-linvfs_stop_syncd(
-       vfs_t                   *vfsp)
-{
-       vfsp->vfs_flag |= VFS_UMOUNT;
-       wmb();
-
-       wake_up_process(vfsp->vfs_sync_task);
-       wait_event(vfsp->vfs_wait_sync_task, !vfsp->vfs_sync_task);
-}
-
-STATIC void
-linvfs_put_super(
-       struct super_block      *sb)
-{
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
-       int                     error;
-
-       linvfs_stop_syncd(vfsp);
-       VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error);
-       if (!error)
-               VFS_UNMOUNT(vfsp, 0, NULL, error);
-       if (error) {
-               printk("XFS unmount got error %d\n", error);
-               printk("%s: vfsp/0x%p left dangling!\n", __FUNCTION__, vfsp);
-               return;
-       }
-
-       vfs_deallocate(vfsp);
-}
-
-STATIC void
-linvfs_write_super(
-       struct super_block      *sb)
-{
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
-       int                     error;
-
-       if (sb->s_flags & MS_RDONLY) {
-               sb->s_dirt = 0; /* paranoia */
-               return;
-       }
-       /* Push the log and superblock a little */
-       VFS_SYNC(vfsp, SYNC_FSDATA, NULL, error);
-       sb->s_dirt = 0;
-}
-
-STATIC int
-linvfs_sync_super(
-       struct super_block      *sb,
-       int                     wait)
-{
-       vfs_t           *vfsp = LINVFS_GET_VFS(sb);
-       int             error;
-       int             flags = SYNC_FSDATA;
-
-       if (wait)
-               flags |= SYNC_WAIT;
-
-       VFS_SYNC(vfsp, flags, NULL, error);
-       sb->s_dirt = 0;
-
-       return -error;
-}
-
-STATIC int
-linvfs_statfs(
-       struct super_block      *sb,
-       struct kstatfs          *statp)
-{
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
-       int                     error;
-
-       VFS_STATVFS(vfsp, statp, NULL, error);
-       return -error;
-}
-
-STATIC int
-linvfs_remount(
-       struct super_block      *sb,
-       int                     *flags,
-       char                    *options)
-{
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
-       struct xfs_mount_args   *args = xfs_args_allocate(sb);
-       int                     error;
-
-       VFS_PARSEARGS(vfsp, options, args, 1, error);
-       if (!error)
-               VFS_MNTUPDATE(vfsp, flags, args, error);
-       kmem_free(args, sizeof(*args));
-       return -error;
-}
-
-STATIC void
-linvfs_freeze_fs(
-       struct super_block      *sb)
-{
-       VFS_FREEZE(LINVFS_GET_VFS(sb));
-}
-
-STATIC struct dentry *
-linvfs_get_parent(
-       struct dentry           *child)
-{
-       int                     error;
-       vnode_t                 *vp, *cvp;
-       struct dentry           *parent;
-       struct inode            *ip = NULL;
-       struct dentry           dotdot;
-
-       dotdot.d_name.name = "..";
-       dotdot.d_name.len = 2;
-       dotdot.d_inode = 0;
-
-       cvp = NULL;
-       vp = LINVFS_GET_VP(child->d_inode);
-       VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error);
-
-       if (!error) {
-               ASSERT(cvp);
-               ip = LINVFS_GET_IP(cvp);
-               if (!ip) {
-                       VN_RELE(cvp);
-                       return ERR_PTR(-EACCES);
-               }
-       }
-       if (error)
-               return ERR_PTR(-error);
-       parent = d_alloc_anon(ip);
-       if (!parent) {
-               VN_RELE(cvp);
-               parent = ERR_PTR(-ENOMEM);
-       }
-       return parent;
-}
-
-STATIC struct dentry *
-linvfs_get_dentry(
-       struct super_block      *sb,
-       void                    *data)
-{
-       vnode_t                 *vp;
-       struct inode            *inode;
-       struct dentry           *result;
-       xfs_fid2_t              xfid;
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
-       int                     error;
-
-       xfid.fid_len = sizeof(xfs_fid2_t) - sizeof(xfid.fid_len);
-       xfid.fid_pad = 0;
-       xfid.fid_gen = ((__u32 *)data)[1];
-       xfid.fid_ino = ((__u32 *)data)[0];
-
-       VFS_VGET(vfsp, &vp, (fid_t *)&xfid, error);
-       if (error || vp == NULL)
-               return ERR_PTR(-ESTALE) ;
-
-       inode = LINVFS_GET_IP(vp);
-       result = d_alloc_anon(inode);
-        if (!result) {
-               iput(inode);
-               return ERR_PTR(-ENOMEM);
-       }
-       return result;
-}
-
-STATIC int
-linvfs_show_options(
-       struct seq_file         *m,
-       struct vfsmount         *mnt)
-{
-       struct vfs              *vfsp = LINVFS_GET_VFS(mnt->mnt_sb);
-       int                     error;
-
-       VFS_SHOWARGS(vfsp, m, error);
-       return error;
-}
-
-STATIC int
-linvfs_getxstate(
-       struct super_block      *sb,
-       struct fs_quota_stat    *fqs)
-{
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
-       int                     error;
-
-       VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error);
-       return -error;
-}
-
-STATIC int
-linvfs_setxstate(
-       struct super_block      *sb,
-       unsigned int            flags,
-       int                     op)
-{
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
-       int                     error;
-
-       VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error);
-       return -error;
-}
-
-STATIC int
-linvfs_getxquota(
-       struct super_block      *sb,
-       int                     type,
-       qid_t                   id,
-       struct fs_disk_quota    *fdq)
-{
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
-       int                     error, getmode;
-
-       getmode = (type == GRPQUOTA) ? Q_XGETGQUOTA : Q_XGETQUOTA;
-       VFS_QUOTACTL(vfsp, getmode, id, (caddr_t)fdq, error);
-       return -error;
-}
-
-STATIC int
-linvfs_setxquota(
-       struct super_block      *sb,
-       int                     type,
-       qid_t                   id,
-       struct fs_disk_quota    *fdq)
-{
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
-       int                     error, setmode;
-
-       setmode = (type == GRPQUOTA) ? Q_XSETGQLIM : Q_XSETQLIM;
-       VFS_QUOTACTL(vfsp, setmode, id, (caddr_t)fdq, error);
-       return -error;
-}
-
-STATIC int
-linvfs_fill_super(
-       struct super_block      *sb,
-       void                    *data,
-       int                     silent)
-{
-       vnode_t                 *rootvp;
-       struct vfs              *vfsp = vfs_allocate();
-       struct xfs_mount_args   *args = xfs_args_allocate(sb);
-       struct kstatfs          statvfs;
-       int                     error, error2;
-
-       vfsp->vfs_super = sb;
-       LINVFS_SET_VFS(sb, vfsp);
-       if (sb->s_flags & MS_RDONLY)
-               vfsp->vfs_flag |= VFS_RDONLY;
-       bhv_insert_all_vfsops(vfsp);
-
-       VFS_PARSEARGS(vfsp, (char *)data, args, 0, error);
-       if (error) {
-               bhv_remove_all_vfsops(vfsp, 1);
-               goto fail_vfsop;
-       }
-
-       sb_min_blocksize(sb, BBSIZE);
-       sb->s_export_op = &linvfs_export_ops;
-       sb->s_qcop = &linvfs_qops;
-       sb->s_op = &linvfs_sops;
-
-       VFS_MOUNT(vfsp, args, NULL, error);
-       if (error) {
-               bhv_remove_all_vfsops(vfsp, 1);
-               goto fail_vfsop;
-       }
-
-       VFS_STATVFS(vfsp, &statvfs, NULL, error);
-       if (error)
-               goto fail_unmount;
-
-       sb->s_dirt = 1;
-       sb->s_magic = statvfs.f_type;
-       sb->s_blocksize = statvfs.f_bsize;
-       sb->s_blocksize_bits = ffs(statvfs.f_bsize) - 1;
-       sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
-       set_posix_acl_flag(sb);
-
-       VFS_ROOT(vfsp, &rootvp, error);
-       if (error)
-               goto fail_unmount;
-
-       sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp));
-       if (!sb->s_root) {
-               error = ENOMEM;
-               goto fail_vnrele;
-       }
-       if (is_bad_inode(sb->s_root->d_inode)) {
-               error = EINVAL;
-               goto fail_vnrele;
-       }
-       if ((error = linvfs_start_syncd(vfsp)))
-               goto fail_vnrele;
-       vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
-
-       kmem_free(args, sizeof(*args));
-       return 0;
-
-fail_vnrele:
-       if (sb->s_root) {
-               dput(sb->s_root);
-               sb->s_root = NULL;
-       } else {
-               VN_RELE(rootvp);
-       }
-
-fail_unmount:
-       VFS_UNMOUNT(vfsp, 0, NULL, error2);
-
-fail_vfsop:
-       vfs_deallocate(vfsp);
-       kmem_free(args, sizeof(*args));
-       return -error;
-}
-
-STATIC struct super_block *
-linvfs_get_sb(
-       struct file_system_type *fs_type,
-       int                     flags,
-       const char              *dev_name,
-       void                    *data)
-{
-       return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super);
-}
-
-
-STATIC struct export_operations linvfs_export_ops = {
-       .get_parent             = linvfs_get_parent,
-       .get_dentry             = linvfs_get_dentry,
-};
-
-STATIC struct super_operations linvfs_sops = {
-       .alloc_inode            = linvfs_alloc_inode,
-       .destroy_inode          = linvfs_destroy_inode,
-       .write_inode            = linvfs_write_inode,
-       .clear_inode            = linvfs_clear_inode,
-       .put_super              = linvfs_put_super,
-       .write_super            = linvfs_write_super,
-       .sync_fs                = linvfs_sync_super,
-       .write_super_lockfs     = linvfs_freeze_fs,
-       .statfs                 = linvfs_statfs,
-       .remount_fs             = linvfs_remount,
-       .show_options           = linvfs_show_options,
-};
-
-STATIC struct quotactl_ops linvfs_qops = {
-       .get_xstate             = linvfs_getxstate,
-       .set_xstate             = linvfs_setxstate,
-       .get_xquota             = linvfs_getxquota,
-       .set_xquota             = linvfs_setxquota,
-};
-
-STATIC struct file_system_type xfs_fs_type = {
-       .owner                  = THIS_MODULE,
-       .name                   = "xfs",
-       .get_sb                 = linvfs_get_sb,
-       .kill_sb                = kill_block_super,
-       .fs_flags               = FS_REQUIRES_DEV,
-};
-
-
-STATIC int __init
-init_xfs_fs( void )
-{
-       int                     error;
-       struct sysinfo          si;
-       static char             message[] __initdata = KERN_INFO \
-               XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
-
-       printk(message);
-
-       si_meminfo(&si);
-       xfs_physmem = si.totalram;
-
-       ktrace_init(64);
-
-       error = init_inodecache();
-       if (error < 0)
-               goto undo_inodecache;
-
-       error = pagebuf_init();
-       if (error < 0)
-               goto undo_pagebuf;
-
-       vn_init();
-       xfs_init();
-       uuid_init();
-       vfs_initdmapi();
-       vfs_initquota();
-
-       error = register_filesystem(&xfs_fs_type);
-       if (error)
-               goto undo_register;
-       return 0;
-
-undo_register:
-       pagebuf_terminate();
-
-undo_pagebuf:
-       destroy_inodecache();
-
-undo_inodecache:
-       return error;
-}
-
-STATIC void __exit
-exit_xfs_fs( void )
-{
-       vfs_exitquota();
-       vfs_exitdmapi();
-       unregister_filesystem(&xfs_fs_type);
-       xfs_cleanup();
-       pagebuf_terminate();
-       destroy_inodecache();
-       ktrace_uninit();
-}
-
-module_init(init_xfs_fs);
-module_exit(exit_xfs_fs);
-
-MODULE_AUTHOR("Silicon Graphics, Inc.");
-MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
-MODULE_LICENSE("GPL");
diff --git a/fs/xfs/linux/xfs_super.h b/fs/xfs/linux/xfs_super.h
deleted file mode 100644 (file)
index 5576269..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPER_H__
-#define __XFS_SUPER_H__
-
-#ifdef CONFIG_XFS_DMAPI
-# define vfs_insertdmapi(vfs)  vfs_insertops(vfsp, &xfs_dmops)
-# define vfs_initdmapi()       dmapi_init()
-# define vfs_exitdmapi()       dmapi_uninit()
-#else
-# define vfs_insertdmapi(vfs)  do { } while (0)
-# define vfs_initdmapi()       do { } while (0)
-# define vfs_exitdmapi()       do { } while (0)
-#endif
-
-#ifdef CONFIG_XFS_QUOTA
-# define vfs_insertquota(vfs)  vfs_insertops(vfsp, &xfs_qmops)
-extern void xfs_qm_init(void);
-extern void xfs_qm_exit(void);
-# define vfs_initquota()       xfs_qm_init()
-# define vfs_exitquota()       xfs_qm_exit()
-#else
-# define vfs_insertquota(vfs)  do { } while (0)
-# define vfs_initquota()       do { } while (0)
-# define vfs_exitquota()       do { } while (0)
-#endif
-
-#ifdef CONFIG_XFS_POSIX_ACL
-# define XFS_ACL_STRING                "ACLs, "
-# define set_posix_acl_flag(sb)        ((sb)->s_flags |= MS_POSIXACL)
-#else
-# define XFS_ACL_STRING
-# define set_posix_acl_flag(sb)        do { } while (0)
-#endif
-
-#ifdef CONFIG_XFS_SECURITY
-# define XFS_SECURITY_STRING   "security attributes, "
-# define ENOSECURITY           0
-#else
-# define XFS_SECURITY_STRING
-# define ENOSECURITY           EOPNOTSUPP
-#endif
-
-#ifdef CONFIG_XFS_RT
-# define XFS_REALTIME_STRING   "realtime, "
-#else
-# define XFS_REALTIME_STRING
-#endif
-
-#if XFS_BIG_BLKNOS
-# if XFS_BIG_INUMS
-#  define XFS_BIGFS_STRING     "large block/inode numbers, "
-# else
-#  define XFS_BIGFS_STRING     "large block numbers, "
-# endif
-#else
-# define XFS_BIGFS_STRING
-#endif
-
-#ifdef CONFIG_XFS_TRACE
-# define XFS_TRACE_STRING      "tracing, "
-#else
-# define XFS_TRACE_STRING
-#endif
-
-#ifdef XFSDEBUG
-# define XFS_DBG_STRING                "debug"
-#else
-# define XFS_DBG_STRING                "no debug"
-#endif
-
-#define XFS_BUILD_OPTIONS      XFS_ACL_STRING \
-                               XFS_SECURITY_STRING \
-                               XFS_REALTIME_STRING \
-                               XFS_BIGFS_STRING \
-                               XFS_TRACE_STRING \
-                               XFS_DBG_STRING /* DBG must be last */
-
-#define LINVFS_GET_VFS(s) \
-       (vfs_t *)((s)->s_fs_info)
-#define LINVFS_SET_VFS(s, vfsp) \
-       ((s)->s_fs_info = vfsp)
-
-struct xfs_inode;
-struct xfs_mount;
-struct xfs_buftarg;
-struct block_device;
-
-extern __uint64_t xfs_max_file_offset(unsigned int);
-
-extern void xfs_initialize_vnode(bhv_desc_t *, vnode_t *, bhv_desc_t *, int);
-
-extern void xfs_flush_inode(struct xfs_inode *);
-extern void xfs_flush_device(struct xfs_inode *);
-
-extern int  xfs_blkdev_get(struct xfs_mount *, const char *,
-                               struct block_device **);
-extern void xfs_blkdev_put(struct block_device *);
-
-#endif /* __XFS_SUPER_H__ */
diff --git a/fs/xfs/linux/xfs_sysctl.c b/fs/xfs/linux/xfs_sysctl.c
deleted file mode 100644 (file)
index b9a97c9..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_rw.h"
-#include <linux/sysctl.h>
-#include <linux/proc_fs.h>
-
-
-static struct ctl_table_header *xfs_table_header;
-
-
-#ifdef CONFIG_PROC_FS
-STATIC int
-xfs_stats_clear_proc_handler(
-       ctl_table       *ctl,
-       int             write,
-       struct file     *filp,
-       void            *buffer,
-       size_t          *lenp)
-{
-       int             c, ret, *valp = ctl->data;
-       __uint32_t      vn_active;
-
-       ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
-
-       if (!ret && write && *valp) {
-               printk("XFS Clearing xfsstats\n");
-               for (c = 0; c < NR_CPUS; c++) {
-                       if (!cpu_possible(c)) continue;
-                       preempt_disable();
-                       /* save vn_active, it's a universal truth! */
-                       vn_active = per_cpu(xfsstats, c).vn_active;
-                       memset(&per_cpu(xfsstats, c), 0,
-                              sizeof(struct xfsstats));
-                       per_cpu(xfsstats, c).vn_active = vn_active;
-                       preempt_enable();
-               }
-               xfs_stats_clear = 0;
-       }
-
-       return ret;
-}
-#endif /* CONFIG_PROC_FS */
-
-STATIC ctl_table xfs_table[] = {
-       {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
-
-       {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
-
-       {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
-
-       {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
-
-       {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.error_level.min, &xfs_params.error_level.max},
-
-       {XFS_SYNC_INTERVAL, "sync_interval", &xfs_params.sync_interval.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL, 
-       &xfs_params.sync_interval.min, &xfs_params.sync_interval.max},
-
-       {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
-
-       {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
-
-       {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
-       
-       {XFS_FLUSH_INTERVAL, "flush_interval", &xfs_params.flush_interval.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.flush_interval.min, &xfs_params.flush_interval.max},
-
-       {XFS_AGE_BUFFER, "age_buffer", &xfs_params.age_buffer.val,
-       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
-       &sysctl_intvec, NULL,
-       &xfs_params.age_buffer.min, &xfs_params.age_buffer.max},
-
-       /* please keep this the last entry */
-#ifdef CONFIG_PROC_FS
-       {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
-       sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
-       &sysctl_intvec, NULL, 
-       &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
-#endif /* CONFIG_PROC_FS */
-
-       {0}
-};
-
-STATIC ctl_table xfs_dir_table[] = {
-       {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
-       {0}
-};
-
-STATIC ctl_table xfs_root_table[] = {
-       {CTL_FS, "fs",  NULL, 0, 0555, xfs_dir_table},
-       {0}
-};
-
-void
-xfs_sysctl_register(void)
-{
-       xfs_table_header = register_sysctl_table(xfs_root_table, 1);
-}
-
-void
-xfs_sysctl_unregister(void)
-{
-       if (xfs_table_header)
-               unregister_sysctl_table(xfs_table_header);
-}
diff --git a/fs/xfs/linux/xfs_sysctl.h b/fs/xfs/linux/xfs_sysctl.h
deleted file mode 100644 (file)
index 0532d40..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#ifndef __XFS_SYSCTL_H__
-#define __XFS_SYSCTL_H__
-
-#include <linux/sysctl.h>
-
-/*
- * Tunable xfs parameters
- */
-
-typedef struct xfs_sysctl_val {
-       int min;
-       int val;
-       int max;
-} xfs_sysctl_val_t;
-
-typedef struct xfs_param {
-       xfs_sysctl_val_t restrict_chown;/* Root/non-root can give away files.*/
-       xfs_sysctl_val_t sgid_inherit;  /* Inherit S_ISGID bit if process' GID 
-                                        * is not a member of the parent dir
-                                        * GID */
-       xfs_sysctl_val_t symlink_mode;  /* Link creat mode affected by umask */
-       xfs_sysctl_val_t panic_mask;    /* bitmask to cause panic on errors. */
-       xfs_sysctl_val_t error_level;   /* Degree of reporting for problems  */
-       xfs_sysctl_val_t sync_interval; /* time between sync calls           */
-       xfs_sysctl_val_t stats_clear;   /* Reset all XFS statistics to zero. */
-       xfs_sysctl_val_t inherit_sync;  /* Inherit the "sync" inode flag. */
-       xfs_sysctl_val_t inherit_nodump;/* Inherit the "nodump" inode flag. */
-       xfs_sysctl_val_t inherit_noatim;/* Inherit the "noatime" inode flag. */
-       xfs_sysctl_val_t flush_interval;/* interval between runs of the
-                                        * delwri flush daemon.  */
-       xfs_sysctl_val_t age_buffer;    /* time for buffer to age before
-                                        * we flush it.  */
-} xfs_param_t;
-
-/*
- * xfs_error_level:
- *
- * How much error reporting will be done when internal problems are
- * encountered.  These problems normally return an EFSCORRUPTED to their
- * caller, with no other information reported.
- *
- * 0   No error reports
- * 1   Report EFSCORRUPTED errors that will cause a filesystem shutdown
- * 5   Report all EFSCORRUPTED errors (all of the above errors, plus any
- *     additional errors that are known to not cause shutdowns)
- *
- * xfs_panic_mask bit 0x8 turns the error reports into panics
- */
-
-enum {
-       XFS_RESTRICT_CHOWN = 3,
-       XFS_SGID_INHERIT = 4,
-       XFS_SYMLINK_MODE = 5,
-       XFS_PANIC_MASK = 6,
-       XFS_ERRLEVEL = 7,
-       XFS_SYNC_INTERVAL = 8,
-       XFS_STATS_CLEAR = 12,
-       XFS_INHERIT_SYNC = 13,
-       XFS_INHERIT_NODUMP = 14,
-       XFS_INHERIT_NOATIME = 15,
-       XFS_FLUSH_INTERVAL = 16,
-       XFS_AGE_BUFFER = 17,
-};
-
-extern xfs_param_t     xfs_params;
-
-#ifdef CONFIG_SYSCTL
-extern void xfs_sysctl_register(void);
-extern void xfs_sysctl_unregister(void);
-#else
-# define xfs_sysctl_register()         do { } while (0)
-# define xfs_sysctl_unregister()       do { } while (0)
-#endif /* CONFIG_SYSCTL */
-
-#endif /* __XFS_SYSCTL_H__ */
diff --git a/fs/xfs/linux/xfs_version.h b/fs/xfs/linux/xfs_version.h
deleted file mode 100644 (file)
index 96f9639..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.         Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * Dummy file that can contain a timestamp to put into the
- * XFS init string, to help users keep track of what they're
- * running
- */
-
-#ifndef __XFS_VERSION_H__
-#define __XFS_VERSION_H__
-
-#define XFS_VERSION_STRING "SGI XFS"
-
-#endif /* __XFS_VERSION_H__ */
diff --git a/fs/xfs/linux/xfs_vfs.c b/fs/xfs/linux/xfs_vfs.c
deleted file mode 100644 (file)
index 2b75ccc..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_macros.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_clnt.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_ag.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_imap.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_quota.h"
-
-int
-vfs_mount(
-       struct bhv_desc         *bdp,
-       struct xfs_mount_args   *args,
-       struct cred             *cr)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_mount)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_mount)(next, args, cr));
-}
-
-int
-vfs_parseargs(
-       struct bhv_desc         *bdp,
-       char                    *s,
-       struct xfs_mount_args   *args,
-       int                     f)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_parseargs)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_parseargs)(next, s, args, f));
-}
-
-int
-vfs_showargs(
-       struct bhv_desc         *bdp,
-       struct seq_file         *m)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_showargs)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_showargs)(next, m));
-}
-
-int
-vfs_unmount(
-       struct bhv_desc         *bdp,
-       int                     fl,
-       struct cred             *cr)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_unmount)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_unmount)(next, fl, cr));
-}
-
-int
-vfs_mntupdate(
-       struct bhv_desc         *bdp,
-       int                     *fl,
-       struct xfs_mount_args   *args)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_mntupdate)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_mntupdate)(next, fl, args));
-}
-
-int
-vfs_root(
-       struct bhv_desc         *bdp,
-       struct vnode            **vpp)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_root)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_root)(next, vpp));
-}
-
-int
-vfs_statvfs(
-       struct bhv_desc         *bdp,
-       xfs_statfs_t            *sp,
-       struct vnode            *vp)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_statvfs)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_statvfs)(next, sp, vp));
-}
-
-int
-vfs_sync(
-       struct bhv_desc         *bdp,
-       int                     fl,
-       struct cred             *cr)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_sync)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_sync)(next, fl, cr));
-}
-
-int
-vfs_vget(
-       struct bhv_desc         *bdp,
-       struct vnode            **vpp,
-       struct fid              *fidp)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_vget)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_vget)(next, vpp, fidp));
-}
-
-int
-vfs_dmapiops(
-       struct bhv_desc         *bdp,
-       caddr_t                 addr)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_dmapiops)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_dmapiops)(next, addr));
-}
-
-int
-vfs_quotactl(
-       struct bhv_desc         *bdp,
-       int                     cmd,
-       int                     id,
-       caddr_t                 addr)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_quotactl)
-               next = BHV_NEXT(next);
-       return ((*bhvtovfsops(next)->vfs_quotactl)(next, cmd, id, addr));
-}
-
-void
-vfs_init_vnode(
-       struct bhv_desc         *bdp,
-       struct vnode            *vp,
-       struct bhv_desc         *bp,
-       int                     unlock)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_init_vnode)
-               next = BHV_NEXT(next);
-       ((*bhvtovfsops(next)->vfs_init_vnode)(next, vp, bp, unlock));
-}
-
-void
-vfs_force_shutdown(
-       struct bhv_desc         *bdp,
-       int                     fl,
-       char                    *file,
-       int                     line)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_force_shutdown)
-               next = BHV_NEXT(next);
-       ((*bhvtovfsops(next)->vfs_force_shutdown)(next, fl, file, line));
-}
-
-void
-vfs_freeze(
-       struct bhv_desc         *bdp)
-{
-       struct bhv_desc         *next = bdp;
-
-       ASSERT(next);
-       while (! (bhvtovfsops(next))->vfs_freeze)
-               next = BHV_NEXT(next);
-       ((*bhvtovfsops(next)->vfs_freeze)(next));
-}
-
-vfs_t *
-vfs_allocate( void )
-{
-       struct vfs              *vfsp;
-
-       vfsp = kmem_zalloc(sizeof(vfs_t), KM_SLEEP);
-       bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
-       init_waitqueue_head(&vfsp->vfs_wait_sync_task);
-       return vfsp;
-}
-
-void
-vfs_deallocate(
-       struct vfs              *vfsp)
-{
-       bhv_head_destroy(VFS_BHVHEAD(vfsp));
-       kmem_free(vfsp, sizeof(vfs_t));
-}
-
-void
-vfs_insertops(
-       struct vfs              *vfsp,
-       struct bhv_vfsops       *vfsops)
-{
-       struct bhv_desc         *bdp;
-
-       bdp = kmem_alloc(sizeof(struct bhv_desc), KM_SLEEP);
-       bhv_desc_init(bdp, NULL, vfsp, vfsops);
-       bhv_insert(&vfsp->vfs_bh, bdp);
-}
-
-void
-vfs_insertbhv(
-       struct vfs              *vfsp,
-       struct bhv_desc         *bdp,
-       struct vfsops           *vfsops,
-       void                    *mount)
-{
-       bhv_desc_init(bdp, mount, vfsp, vfsops);
-       bhv_insert_initial(&vfsp->vfs_bh, bdp);
-}
-
-void
-bhv_remove_vfsops(
-       struct vfs              *vfsp,
-       int                     pos)
-{
-       struct bhv_desc         *bhv;
-
-       bhv = bhv_lookup_range(&vfsp->vfs_bh, pos, pos);
-       if (!bhv)
-               return;
-       bhv_remove(&vfsp->vfs_bh, bhv);
-       kmem_free(bhv, sizeof(*bhv));
-}
-
-void
-bhv_remove_all_vfsops(
-       struct vfs              *vfsp,
-       int                     freebase)
-{
-       struct xfs_mount        *mp;
-
-       bhv_remove_vfsops(vfsp, VFS_POSITION_QM);
-       bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
-       if (!freebase)
-               return;
-       mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops));
-       VFS_REMOVEBHV(vfsp, &mp->m_bhv);
-       xfs_mount_free(mp, 0);
-}
-
-void
-bhv_insert_all_vfsops(
-       struct vfs              *vfsp)
-{
-       struct xfs_mount        *mp;
-
-       mp = xfs_mount_init();
-       vfs_insertbhv(vfsp, &mp->m_bhv, &xfs_vfsops, mp);
-       vfs_insertdmapi(vfsp);
-       vfs_insertquota(vfsp);
-}
diff --git a/fs/xfs/linux/xfs_vfs.h b/fs/xfs/linux/xfs_vfs.h
deleted file mode 100644 (file)
index dc1cd19..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_VFS_H__
-#define __XFS_VFS_H__
-
-#include <linux/vfs.h>
-#include "xfs_fs.h"
-
-struct fid;
-struct cred;
-struct vnode;
-struct kstatfs;
-struct seq_file;
-struct super_block;
-struct xfs_mount_args;
-
-typedef struct kstatfs xfs_statfs_t;
-
-typedef struct vfs {
-       u_int                   vfs_flag;       /* flags */
-       xfs_fsid_t              vfs_fsid;       /* file system ID */
-       xfs_fsid_t              *vfs_altfsid;   /* An ID fixed for life of FS */
-       bhv_head_t              vfs_bh;         /* head of vfs behavior chain */
-       struct super_block      *vfs_super;     /* Linux superblock structure */
-       struct task_struct      *vfs_sync_task;
-       wait_queue_head_t       vfs_wait_sync_task;
-} vfs_t;
-
-#define vfs_fbhv               vfs_bh.bh_first /* 1st on vfs behavior chain */
-
-#define bhvtovfs(bdp)          ( (struct vfs *)BHV_VOBJ(bdp) )
-#define bhvtovfsops(bdp)       ( (struct vfsops *)BHV_OPS(bdp) )
-#define VFS_BHVHEAD(vfs)       ( &(vfs)->vfs_bh )
-#define VFS_REMOVEBHV(vfs, bdp)        ( bhv_remove(VFS_BHVHEAD(vfs), bdp) )
-
-#define VFS_POSITION_BASE      BHV_POSITION_BASE       /* chain bottom */
-#define VFS_POSITION_TOP       BHV_POSITION_TOP        /* chain top */
-#define VFS_POSITION_INVALID   BHV_POSITION_INVALID    /* invalid pos. num */
-
-typedef enum {
-       VFS_BHV_UNKNOWN,        /* not specified */
-       VFS_BHV_XFS,            /* xfs */
-       VFS_BHV_DM,             /* data migration */
-       VFS_BHV_QM,             /* quota manager */
-       VFS_BHV_IO,             /* IO path */
-       VFS_BHV_END             /* housekeeping end-of-range */
-} vfs_bhv_t;
-
-#define VFS_POSITION_XFS       (BHV_POSITION_BASE)
-#define VFS_POSITION_DM                (VFS_POSITION_BASE+10)
-#define VFS_POSITION_QM                (VFS_POSITION_BASE+20)
-#define VFS_POSITION_IO                (VFS_POSITION_BASE+30)
-
-#define VFS_RDONLY             0x0001  /* read-only vfs */
-#define VFS_GRPID              0x0002  /* group-ID assigned from directory */
-#define VFS_DMI                        0x0004  /* filesystem has the DMI enabled */
-#define VFS_UMOUNT             0x0008  /* unmount in progress */
-#define VFS_END                        0x0008  /* max flag */
-
-#define SYNC_ATTR              0x0001  /* sync attributes */
-#define SYNC_CLOSE             0x0002  /* close file system down */
-#define SYNC_DELWRI            0x0004  /* look at delayed writes */
-#define SYNC_WAIT              0x0008  /* wait for i/o to complete */
-#define SYNC_BDFLUSH           0x0010  /* BDFLUSH is calling -- don't block */
-#define SYNC_FSDATA            0x0020  /* flush fs data (e.g. superblocks) */
-#define SYNC_REFCACHE          0x0040  /* prune some of the nfs ref cache */
-#define SYNC_REMOUNT           0x0080  /* remount readonly, no dummy LRs */
-
-typedef int    (*vfs_mount_t)(bhv_desc_t *,
-                               struct xfs_mount_args *, struct cred *);
-typedef int    (*vfs_parseargs_t)(bhv_desc_t *, char *,
-                               struct xfs_mount_args *, int);
-typedef        int     (*vfs_showargs_t)(bhv_desc_t *, struct seq_file *);
-typedef int    (*vfs_unmount_t)(bhv_desc_t *, int, struct cred *);
-typedef int    (*vfs_mntupdate_t)(bhv_desc_t *, int *,
-                               struct xfs_mount_args *);
-typedef int    (*vfs_root_t)(bhv_desc_t *, struct vnode **);
-typedef int    (*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
-typedef int    (*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
-typedef int    (*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *);
-typedef int    (*vfs_dmapiops_t)(bhv_desc_t *, caddr_t);
-typedef int    (*vfs_quotactl_t)(bhv_desc_t *, int, int, caddr_t);
-typedef void   (*vfs_init_vnode_t)(bhv_desc_t *,
-                               struct vnode *, bhv_desc_t *, int);
-typedef void   (*vfs_force_shutdown_t)(bhv_desc_t *, int, char *, int);
-typedef void   (*vfs_freeze_t)(bhv_desc_t *);
-
-typedef struct vfsops {
-       bhv_position_t          vf_position;    /* behavior chain position */
-       vfs_mount_t             vfs_mount;      /* mount file system */
-       vfs_parseargs_t         vfs_parseargs;  /* parse mount options */
-       vfs_showargs_t          vfs_showargs;   /* unparse mount options */
-       vfs_unmount_t           vfs_unmount;    /* unmount file system */
-       vfs_mntupdate_t         vfs_mntupdate;  /* update file system options */
-       vfs_root_t              vfs_root;       /* get root vnode */
-       vfs_statvfs_t           vfs_statvfs;    /* file system statistics */
-       vfs_sync_t              vfs_sync;       /* flush files */
-       vfs_vget_t              vfs_vget;       /* get vnode from fid */
-       vfs_dmapiops_t          vfs_dmapiops;   /* data migration */
-       vfs_quotactl_t          vfs_quotactl;   /* disk quota */
-       vfs_init_vnode_t        vfs_init_vnode; /* initialize a new vnode */
-       vfs_force_shutdown_t    vfs_force_shutdown;     /* crash and burn */
-       vfs_freeze_t            vfs_freeze;     /* freeze fs for snapshot */
-} vfsops_t;
-
-/*
- * VFS's.  Operates on vfs structure pointers (starts at bhv head).
- */
-#define VHEAD(v)                       ((v)->vfs_fbhv)
-#define VFS_MOUNT(v, ma,cr, rv)                ((rv) = vfs_mount(VHEAD(v), ma,cr))
-#define VFS_PARSEARGS(v, o,ma,f, rv)   ((rv) = vfs_parseargs(VHEAD(v), o,ma,f))
-#define VFS_SHOWARGS(v, m, rv)         ((rv) = vfs_showargs(VHEAD(v), m))
-#define VFS_UNMOUNT(v, f, cr, rv)      ((rv) = vfs_unmount(VHEAD(v), f,cr))
-#define VFS_MNTUPDATE(v, fl, args, rv) ((rv) = vfs_mntupdate(VHEAD(v), fl, args))
-#define VFS_ROOT(v, vpp, rv)           ((rv) = vfs_root(VHEAD(v), vpp))
-#define VFS_STATVFS(v, sp,vp, rv)      ((rv) = vfs_statvfs(VHEAD(v), sp,vp))
-#define VFS_SYNC(v, flag,cr, rv)       ((rv) = vfs_sync(VHEAD(v), flag,cr))
-#define VFS_VGET(v, vpp,fidp, rv)      ((rv) = vfs_vget(VHEAD(v), vpp,fidp))
-#define VFS_DMAPIOPS(v, p, rv)         ((rv) = vfs_dmapiops(VHEAD(v), p))
-#define VFS_QUOTACTL(v, c,id,p, rv)    ((rv) = vfs_quotactl(VHEAD(v), c,id,p))
-#define VFS_INIT_VNODE(v, vp,b,ul)     ( vfs_init_vnode(VHEAD(v), vp,b,ul) )
-#define VFS_FORCE_SHUTDOWN(v, fl,f,l)  ( vfs_force_shutdown(VHEAD(v), fl,f,l) )
-#define VFS_FREEZE(v)                  ( vfs_freeze(VHEAD(v)) )
-
-/*
- * PVFS's.  Operates on behavior descriptor pointers.
- */
-#define PVFS_MOUNT(b, ma,cr, rv)       ((rv) = vfs_mount(b, ma,cr))
-#define PVFS_PARSEARGS(b, o,ma,f, rv)  ((rv) = vfs_parseargs(b, o,ma,f))
-#define PVFS_SHOWARGS(b, m, rv)                ((rv) = vfs_showargs(b, m))
-#define PVFS_UNMOUNT(b, f,cr, rv)      ((rv) = vfs_unmount(b, f,cr))
-#define PVFS_MNTUPDATE(b, fl, args, rv)        ((rv) = vfs_mntupdate(b, fl, args))
-#define PVFS_ROOT(b, vpp, rv)          ((rv) = vfs_root(b, vpp))
-#define PVFS_STATVFS(b, sp,vp, rv)     ((rv) = vfs_statvfs(b, sp,vp))
-#define PVFS_SYNC(b, flag,cr, rv)      ((rv) = vfs_sync(b, flag,cr))
-#define PVFS_VGET(b, vpp,fidp, rv)     ((rv) = vfs_vget(b, vpp,fidp))
-#define PVFS_DMAPIOPS(b, p, rv)                ((rv) = vfs_dmapiops(b, p))
-#define PVFS_QUOTACTL(b, c,id,p, rv)   ((rv) = vfs_quotactl(b, c,id,p))
-#define PVFS_INIT_VNODE(b, vp,b2,ul)   ( vfs_init_vnode(b, vp,b2,ul) )
-#define PVFS_FORCE_SHUTDOWN(b, fl,f,l) ( vfs_force_shutdown(b, fl,f,l) )
-#define PVFS_FREEZE(b)                 ( vfs_freeze(b) )
-
-extern int vfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *);
-extern int vfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int);
-extern int vfs_showargs(bhv_desc_t *, struct seq_file *);
-extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
-extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
-extern int vfs_root(bhv_desc_t *, struct vnode **);
-extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
-extern int vfs_sync(bhv_desc_t *, int, struct cred *);
-extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *);
-extern int vfs_dmapiops(bhv_desc_t *, caddr_t);
-extern int vfs_quotactl(bhv_desc_t *, int, int, caddr_t);
-extern void vfs_init_vnode(bhv_desc_t *, struct vnode *, bhv_desc_t *, int);
-extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int);
-extern void vfs_freeze(bhv_desc_t *);
-
-typedef struct bhv_vfsops {
-       struct vfsops           bhv_common;
-       void *                  bhv_custom;
-} bhv_vfsops_t;
-
-#define vfs_bhv_lookup(v, id)  ( bhv_lookup_range(&(v)->vfs_bh, (id), (id)) )
-#define vfs_bhv_custom(b)      ( ((bhv_vfsops_t *)BHV_OPS(b))->bhv_custom )
-#define vfs_bhv_set_custom(b,o)        ( (b)->bhv_custom = (void *)(o))
-#define vfs_bhv_clr_custom(b)  ( (b)->bhv_custom = NULL )
-
-extern vfs_t *vfs_allocate(void);
-extern void vfs_deallocate(vfs_t *);
-extern void vfs_insertops(vfs_t *, bhv_vfsops_t *);
-extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *);
-
-extern void bhv_insert_all_vfsops(struct vfs *);
-extern void bhv_remove_all_vfsops(struct vfs *, int);
-extern void bhv_remove_vfsops(struct vfs *, int);
-
-#endif /* __XFS_VFS_H__ */
diff --git a/fs/xfs/linux/xfs_vnode.c b/fs/xfs/linux/xfs_vnode.c
deleted file mode 100644 (file)
index 9240efb..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-
-uint64_t vn_generation;                /* vnode generation number */
-spinlock_t vnumber_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * Dedicated vnode inactive/reclaim sync semaphores.
- * Prime number of hash buckets since address is used as the key.
- */
-#define NVSYNC                  37
-#define vptosync(v)             (&vsync[((unsigned long)v) % NVSYNC])
-sv_t vsync[NVSYNC];
-
-/*
- * Translate stat(2) file types to vnode types and vice versa.
- * Aware of numeric order of S_IFMT and vnode type values.
- */
-enum vtype iftovt_tab[] = {
-       VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
-       VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VNON
-};
-
-u_short vttoif_tab[] = {
-       0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, S_IFIFO, 0, S_IFSOCK
-};
-
-
-void
-vn_init(void)
-{
-       register sv_t *svp;
-       register int i;
-
-       for (svp = vsync, i = 0; i < NVSYNC; i++, svp++)
-               init_sv(svp, SV_DEFAULT, "vsy", i);
-}
-
-/*
- * Clean a vnode of filesystem-specific data and prepare it for reuse.
- */
-STATIC int
-vn_reclaim(
-       struct vnode    *vp)
-{
-       int             error;
-
-       XFS_STATS_INC(vn_reclaim);
-       vn_trace_entry(vp, "vn_reclaim", (inst_t *)__return_address);
-
-       /*
-        * Only make the VOP_RECLAIM call if there are behaviors
-        * to call.
-        */
-       if (vp->v_fbhv) {
-               VOP_RECLAIM(vp, error);
-               if (error)
-                       return -error;
-       }
-       ASSERT(vp->v_fbhv == NULL);
-
-       VN_LOCK(vp);
-       vp->v_flag &= (VRECLM|VWAIT);
-       VN_UNLOCK(vp, 0);
-
-       vp->v_type = VNON;
-       vp->v_fbhv = NULL;
-
-#ifdef XFS_VNODE_TRACE
-       ktrace_free(vp->v_trace);
-       vp->v_trace = NULL;
-#endif
-
-       return 0;
-}
-
-STATIC void
-vn_wakeup(
-       struct vnode    *vp)
-{
-       VN_LOCK(vp);
-       if (vp->v_flag & VWAIT)
-               sv_broadcast(vptosync(vp));
-       vp->v_flag &= ~(VRECLM|VWAIT|VMODIFIED);
-       VN_UNLOCK(vp, 0);
-}
-
-int
-vn_wait(
-       struct vnode    *vp)
-{
-       VN_LOCK(vp);
-       if (vp->v_flag & (VINACT | VRECLM)) {
-               vp->v_flag |= VWAIT;
-               sv_wait(vptosync(vp), PINOD, &vp->v_lock, 0);
-               return 1;
-       }
-       VN_UNLOCK(vp, 0);
-       return 0;
-}
-
-struct vnode *
-vn_initialize(
-       struct inode    *inode)
-{
-       struct vnode    *vp = LINVFS_GET_VP(inode);
-
-       XFS_STATS_INC(vn_active);
-       XFS_STATS_INC(vn_alloc);
-
-       vp->v_flag = VMODIFIED;
-       spinlock_init(&vp->v_lock, "v_lock");
-
-       spin_lock(&vnumber_lock);
-       if (!++vn_generation)   /* v_number shouldn't be zero */
-               vn_generation++;
-       vp->v_number = vn_generation;
-       spin_unlock(&vnumber_lock);
-
-       ASSERT(VN_CACHED(vp) == 0);
-
-       /* Initialize the first behavior and the behavior chain head. */
-       vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
-
-#ifdef XFS_VNODE_TRACE
-       vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
-       printk("Allocated VNODE_TRACE at 0x%p\n", vp->v_trace);
-#endif /* XFS_VNODE_TRACE */
-
-       vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
-       return vp;
-}
-
-/*
- * Get a reference on a vnode.
- */
-vnode_t *
-vn_get(
-       struct vnode    *vp,
-       vmap_t          *vmap)
-{
-       struct inode    *inode;
-
-       XFS_STATS_INC(vn_get);
-       inode = LINVFS_GET_IP(vp);
-       if (inode->i_state & I_FREEING)
-               return NULL;
-
-       inode = ilookup(vmap->v_vfsp->vfs_super, vmap->v_ino);
-       if (!inode)     /* Inode not present */
-               return NULL;
-
-       vn_trace_exit(vp, "vn_get", (inst_t *)__return_address);
-
-       return vp;
-}
-
-/*
- * Revalidate the Linux inode from the vnode.
- */
-int
-vn_revalidate(
-       struct vnode    *vp)
-{
-       struct inode    *inode;
-       vattr_t         va;
-       int             error;
-
-       vn_trace_entry(vp, "vn_revalidate", (inst_t *)__return_address);
-       ASSERT(vp->v_fbhv != NULL);
-
-       va.va_mask = XFS_AT_STAT|XFS_AT_XFLAGS;
-       VOP_GETATTR(vp, &va, 0, NULL, error);
-       if (!error) {
-               inode = LINVFS_GET_IP(vp);
-               inode->i_mode       = VTTOIF(va.va_type) | va.va_mode;
-               inode->i_nlink      = va.va_nlink;
-               inode->i_uid        = va.va_uid;
-               inode->i_gid        = va.va_gid;
-               inode->i_blocks     = va.va_nblocks;
-               inode->i_mtime      = va.va_mtime;
-               inode->i_ctime      = va.va_ctime;
-               inode->i_atime      = va.va_atime;
-               if (va.va_xflags & XFS_XFLAG_IMMUTABLE)
-                       inode->i_flags |= S_IMMUTABLE;
-               else
-                       inode->i_flags &= ~S_IMMUTABLE;
-               if (va.va_xflags & XFS_XFLAG_APPEND)
-                       inode->i_flags |= S_APPEND;
-               else
-                       inode->i_flags &= ~S_APPEND;
-               if (va.va_xflags & XFS_XFLAG_SYNC)
-                       inode->i_flags |= S_SYNC;
-               else
-                       inode->i_flags &= ~S_SYNC;
-               if (va.va_xflags & XFS_XFLAG_NOATIME)
-                       inode->i_flags |= S_NOATIME;
-               else
-                       inode->i_flags &= ~S_NOATIME;
-               VUNMODIFY(vp);
-       }
-       return -error;
-}
-
-/*
- * purge a vnode from the cache
- * At this point the vnode is guaranteed to have no references (vn_count == 0)
- * The caller has to make sure that there are no ways someone could
- * get a handle (via vn_get) on the vnode (usually done via a mount/vfs lock).
- */
-void
-vn_purge(
-       struct vnode    *vp,
-       vmap_t          *vmap)
-{
-       vn_trace_entry(vp, "vn_purge", (inst_t *)__return_address);
-
-again:
-       /*
-        * Check whether vp has already been reclaimed since our caller
-        * sampled its version while holding a filesystem cache lock that
-        * its VOP_RECLAIM function acquires.
-        */
-       VN_LOCK(vp);
-       if (vp->v_number != vmap->v_number) {
-               VN_UNLOCK(vp, 0);
-               return;
-       }
-
-       /*
-        * If vp is being reclaimed or inactivated, wait until it is inert,
-        * then proceed.  Can't assume that vnode is actually reclaimed
-        * just because the reclaimed flag is asserted -- a vn_alloc
-        * reclaim can fail.
-        */
-       if (vp->v_flag & (VINACT | VRECLM)) {
-               ASSERT(vn_count(vp) == 0);
-               vp->v_flag |= VWAIT;
-               sv_wait(vptosync(vp), PINOD, &vp->v_lock, 0);
-               goto again;
-       }
-
-       /*
-        * Another process could have raced in and gotten this vnode...
-        */
-       if (vn_count(vp) > 0) {
-               VN_UNLOCK(vp, 0);
-               return;
-       }
-
-       XFS_STATS_DEC(vn_active);
-       vp->v_flag |= VRECLM;
-       VN_UNLOCK(vp, 0);
-
-       /*
-        * Call VOP_RECLAIM and clean vp. The FSYNC_INVAL flag tells
-        * vp's filesystem to flush and invalidate all cached resources.
-        * When vn_reclaim returns, vp should have no private data,
-        * either in a system cache or attached to v_data.
-        */
-       if (vn_reclaim(vp) != 0)
-               panic("vn_purge: cannot reclaim");
-
-       /*
-        * Wakeup anyone waiting for vp to be reclaimed.
-        */
-       vn_wakeup(vp);
-}
-
-/*
- * Add a reference to a referenced vnode.
- */
-struct vnode *
-vn_hold(
-       struct vnode    *vp)
-{
-       struct inode    *inode;
-
-       XFS_STATS_INC(vn_hold);
-
-       VN_LOCK(vp);
-       inode = igrab(LINVFS_GET_IP(vp));
-       ASSERT(inode);
-       VN_UNLOCK(vp, 0);
-
-       return vp;
-}
-
-/*
- *  Call VOP_INACTIVE on last reference.
- */
-void
-vn_rele(
-       struct vnode    *vp)
-{
-       int             vcnt;
-       int             cache;
-
-       XFS_STATS_INC(vn_rele);
-
-       VN_LOCK(vp);
-
-       vn_trace_entry(vp, "vn_rele", (inst_t *)__return_address);
-       vcnt = vn_count(vp);
-
-       /*
-        * Since we always get called from put_inode we know
-        * that i_count won't be decremented after we
-        * return.
-        */
-       if (!vcnt) {
-               /*
-                * As soon as we turn this on, noone can find us in vn_get
-                * until we turn off VINACT or VRECLM
-                */
-               vp->v_flag |= VINACT;
-               VN_UNLOCK(vp, 0);
-
-               /*
-                * Do not make the VOP_INACTIVE call if there
-                * are no behaviors attached to the vnode to call.
-                */
-               if (vp->v_fbhv)
-                       VOP_INACTIVE(vp, NULL, cache);
-
-               VN_LOCK(vp);
-               if (vp->v_flag & VWAIT)
-                       sv_broadcast(vptosync(vp));
-
-               vp->v_flag &= ~(VINACT|VWAIT|VRECLM|VMODIFIED);
-       }
-
-       VN_UNLOCK(vp, 0);
-
-       vn_trace_exit(vp, "vn_rele", (inst_t *)__return_address);
-}
-
-/*
- * Finish the removal of a vnode.
- */
-void
-vn_remove(
-       struct vnode    *vp)
-{
-       vmap_t          vmap;
-
-       /* Make sure we don't do this to the same vnode twice */
-       if (!(vp->v_fbhv))
-               return;
-
-       XFS_STATS_INC(vn_remove);
-       vn_trace_exit(vp, "vn_remove", (inst_t *)__return_address);
-
-       /*
-        * After the following purge the vnode
-        * will no longer exist.
-        */
-       VMAP(vp, vmap);
-       vn_purge(vp, &vmap);
-}
-
-
-#ifdef XFS_VNODE_TRACE
-
-#define KTRACE_ENTER(vp, vk, s, line, ra)                      \
-       ktrace_enter(   (vp)->v_trace,                          \
-/*  0 */               (void *)(__psint_t)(vk),                \
-/*  1 */               (void *)(s),                            \
-/*  2 */               (void *)(__psint_t) line,               \
-/*  3 */               (void *)(vn_count(vp)), \
-/*  4 */               (void *)(ra),                           \
-/*  5 */               (void *)(__psunsigned_t)(vp)->v_flag,   \
-/*  6 */               (void *)(__psint_t)smp_processor_id(),  \
-/*  7 */               (void *)(__psint_t)(current->pid),      \
-/*  8 */               (void *)__return_address,               \
-/*  9 */               0, 0, 0, 0, 0, 0, 0)
-
-/*
- * Vnode tracing code.
- */
-void
-vn_trace_entry(vnode_t *vp, char *func, inst_t *ra)
-{
-       KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra);
-}
-
-void
-vn_trace_exit(vnode_t *vp, char *func, inst_t *ra)
-{
-       KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra);
-}
-
-void
-vn_trace_hold(vnode_t *vp, char *file, int line, inst_t *ra)
-{
-       KTRACE_ENTER(vp, VNODE_KTRACE_HOLD, file, line, ra);
-}
-
-void
-vn_trace_ref(vnode_t *vp, char *file, int line, inst_t *ra)
-{
-       KTRACE_ENTER(vp, VNODE_KTRACE_REF, file, line, ra);
-}
-
-void
-vn_trace_rele(vnode_t *vp, char *file, int line, inst_t *ra)
-{
-       KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
-}
-#endif /* XFS_VNODE_TRACE */
diff --git a/fs/xfs/linux/xfs_vnode.h b/fs/xfs/linux/xfs_vnode.h
deleted file mode 100644 (file)
index af0b65f..0000000
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- *
- * Portions Copyright (c) 1989, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef __XFS_VNODE_H__
-#define __XFS_VNODE_H__
-
-struct uio;
-struct file;
-struct vattr;
-struct xfs_iomap;
-struct attrlist_cursor_kern;
-
-/*
- * Vnode types.  VNON means no type.
- */
-enum vtype     { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VFIFO, VBAD, VSOCK };
-
-typedef xfs_ino_t vnumber_t;
-typedef struct dentry vname_t;
-typedef bhv_head_t vn_bhv_head_t;
-
-/*
- * MP locking protocols:
- *     v_flag, v_vfsp                          VN_LOCK/VN_UNLOCK
- *     v_type                                  read-only or fs-dependent
- */
-typedef struct vnode {
-       __u32           v_flag;                 /* vnode flags (see below) */
-       enum vtype      v_type;                 /* vnode type */
-       struct vfs      *v_vfsp;                /* ptr to containing VFS */
-       vnumber_t       v_number;               /* in-core vnode number */
-       vn_bhv_head_t   v_bh;                   /* behavior head */
-       spinlock_t      v_lock;                 /* VN_LOCK/VN_UNLOCK */
-       struct inode    v_inode;                /* Linux inode */
-#ifdef XFS_VNODE_TRACE
-       struct ktrace   *v_trace;               /* trace header structure    */
-#endif
-} vnode_t;
-
-#define v_fbhv                 v_bh.bh_first          /* first behavior */
-#define v_fops                 v_bh.bh_first->bd_ops  /* first behavior ops */
-
-#define VNODE_POSITION_BASE    BHV_POSITION_BASE       /* chain bottom */
-#define VNODE_POSITION_TOP     BHV_POSITION_TOP        /* chain top */
-#define VNODE_POSITION_INVALID BHV_POSITION_INVALID    /* invalid pos. num */
-
-typedef enum {
-       VN_BHV_UNKNOWN,         /* not specified */
-       VN_BHV_XFS,             /* xfs */
-       VN_BHV_DM,              /* data migration */
-       VN_BHV_QM,              /* quota manager */
-       VN_BHV_IO,              /* IO path */
-       VN_BHV_END              /* housekeeping end-of-range */
-} vn_bhv_t;
-
-#define VNODE_POSITION_XFS     (VNODE_POSITION_BASE)
-#define VNODE_POSITION_DM      (VNODE_POSITION_BASE+10)
-#define VNODE_POSITION_QM      (VNODE_POSITION_BASE+20)
-#define VNODE_POSITION_IO      (VNODE_POSITION_BASE+30)
-
-/*
- * Macros for dealing with the behavior descriptor inside of the vnode.
- */
-#define BHV_TO_VNODE(bdp)      ((vnode_t *)BHV_VOBJ(bdp))
-#define BHV_TO_VNODE_NULL(bdp) ((vnode_t *)BHV_VOBJNULL(bdp))
-
-#define VN_BHV_HEAD(vp)                        ((bhv_head_t *)(&((vp)->v_bh)))
-#define vn_bhv_head_init(bhp,name)     bhv_head_init(bhp,name)
-#define vn_bhv_remove(bhp,bdp)         bhv_remove(bhp,bdp)
-#define vn_bhv_lookup(bhp,ops)         bhv_lookup(bhp,ops)
-#define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops)
-
-/*
- * Vnode to Linux inode mapping.
- */
-#define LINVFS_GET_VP(inode)   ((vnode_t *)list_entry(inode, vnode_t, v_inode))
-#define LINVFS_GET_IP(vp)      (&(vp)->v_inode)
-
-/*
- * Convert between vnode types and inode formats (since POSIX.1
- * defines mode word of stat structure in terms of inode formats).
- */
-extern enum vtype      iftovt_tab[];
-extern u_short         vttoif_tab[];
-#define IFTOVT(mode)   (iftovt_tab[((mode) & S_IFMT) >> 12])
-#define VTTOIF(indx)   (vttoif_tab[(int)(indx)])
-#define MAKEIMODE(indx, mode)  (int)(VTTOIF(indx) | (mode))
-
-
-/*
- * Vnode flags.
- */
-#define VINACT                0x1      /* vnode is being inactivated   */
-#define VRECLM                0x2      /* vnode is being reclaimed     */
-#define VWAIT                 0x4      /* waiting for VINACT/VRECLM to end */
-#define VMODIFIED             0x8      /* XFS inode state possibly differs */
-                                       /* to the Linux inode state.    */
-
-/*
- * Values for the VOP_RWLOCK and VOP_RWUNLOCK flags parameter.
- */
-typedef enum vrwlock {
-       VRWLOCK_NONE,
-       VRWLOCK_READ,
-       VRWLOCK_WRITE,
-       VRWLOCK_WRITE_DIRECT,
-       VRWLOCK_TRY_READ,
-       VRWLOCK_TRY_WRITE
-} vrwlock_t;
-
-/*
- * Return values for VOP_INACTIVE.  A return value of
- * VN_INACTIVE_NOCACHE implies that the file system behavior
- * has disassociated its state and bhv_desc_t from the vnode.
- */
-#define        VN_INACTIVE_CACHE       0
-#define        VN_INACTIVE_NOCACHE     1
-
-/*
- * Values for the cmd code given to VOP_VNODE_CHANGE.
- */
-typedef enum vchange {
-       VCHANGE_FLAGS_FRLOCKS           = 0,
-       VCHANGE_FLAGS_ENF_LOCKING       = 1,
-       VCHANGE_FLAGS_TRUNCATED         = 2,
-       VCHANGE_FLAGS_PAGE_DIRTY        = 3,
-       VCHANGE_FLAGS_IOEXCL_COUNT      = 4
-} vchange_t;
-
-
-typedef int    (*vop_open_t)(bhv_desc_t *, struct cred *);
-typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *,
-                               const struct iovec *, unsigned int,
-                               loff_t *, int, struct cred *);
-typedef ssize_t (*vop_write_t)(bhv_desc_t *, struct kiocb *,
-                               const struct iovec *, unsigned int,
-                               loff_t *, int, struct cred *);
-typedef ssize_t (*vop_sendfile_t)(bhv_desc_t *, struct file *,
-                               loff_t *, int, size_t, read_actor_t,
-                               void *, struct cred *);
-typedef int    (*vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *,
-                               int, unsigned int, unsigned long);
-typedef int    (*vop_getattr_t)(bhv_desc_t *, struct vattr *, int,
-                               struct cred *);
-typedef int    (*vop_setattr_t)(bhv_desc_t *, struct vattr *, int,
-                               struct cred *);
-typedef int    (*vop_access_t)(bhv_desc_t *, int, struct cred *);
-typedef int    (*vop_lookup_t)(bhv_desc_t *, vname_t *, vnode_t **,
-                               int, vnode_t *, struct cred *);
-typedef int    (*vop_create_t)(bhv_desc_t *, vname_t *, struct vattr *,
-                               vnode_t **, struct cred *);
-typedef int    (*vop_remove_t)(bhv_desc_t *, vname_t *, struct cred *);
-typedef int    (*vop_link_t)(bhv_desc_t *, vnode_t *, vname_t *,
-                               struct cred *);
-typedef int    (*vop_rename_t)(bhv_desc_t *, vname_t *, vnode_t *, vname_t *,
-                               struct cred *);
-typedef int    (*vop_mkdir_t)(bhv_desc_t *, vname_t *, struct vattr *,
-                               vnode_t **, struct cred *);
-typedef int    (*vop_rmdir_t)(bhv_desc_t *, vname_t *, struct cred *);
-typedef int    (*vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *,
-                               int *);
-typedef int    (*vop_symlink_t)(bhv_desc_t *, vname_t *, struct vattr *,
-                               char *, vnode_t **, struct cred *);
-typedef int    (*vop_readlink_t)(bhv_desc_t *, struct uio *, int,
-                               struct cred *);
-typedef int    (*vop_fsync_t)(bhv_desc_t *, int, struct cred *,
-                               xfs_off_t, xfs_off_t);
-typedef int    (*vop_inactive_t)(bhv_desc_t *, struct cred *);
-typedef int    (*vop_fid2_t)(bhv_desc_t *, struct fid *);
-typedef int    (*vop_release_t)(bhv_desc_t *);
-typedef int    (*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
-typedef void   (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
-typedef int    (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
-                               struct xfs_iomap *, int *);
-typedef int    (*vop_reclaim_t)(bhv_desc_t *);
-typedef int    (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int,
-                               struct cred *);
-typedef        int     (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int,
-                               struct cred *);
-typedef        int     (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *);
-typedef        int     (*vop_attr_list_t)(bhv_desc_t *, char *, int, int,
-                               struct attrlist_cursor_kern *, struct cred *);
-typedef void   (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);
-typedef void   (*vop_vnode_change_t)(bhv_desc_t *, vchange_t, __psint_t);
-typedef void   (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-typedef void   (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-typedef int    (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t,
-                               uint64_t, int);
-typedef int    (*vop_iflush_t)(bhv_desc_t *, int);
-
-
-typedef struct vnodeops {
-       bhv_position_t  vn_position;    /* position within behavior chain */
-       vop_open_t              vop_open;
-       vop_read_t              vop_read;
-       vop_write_t             vop_write;
-       vop_sendfile_t          vop_sendfile;
-       vop_ioctl_t             vop_ioctl;
-       vop_getattr_t           vop_getattr;
-       vop_setattr_t           vop_setattr;
-       vop_access_t            vop_access;
-       vop_lookup_t            vop_lookup;
-       vop_create_t            vop_create;
-       vop_remove_t            vop_remove;
-       vop_link_t              vop_link;
-       vop_rename_t            vop_rename;
-       vop_mkdir_t             vop_mkdir;
-       vop_rmdir_t             vop_rmdir;
-       vop_readdir_t           vop_readdir;
-       vop_symlink_t           vop_symlink;
-       vop_readlink_t          vop_readlink;
-       vop_fsync_t             vop_fsync;
-       vop_inactive_t          vop_inactive;
-       vop_fid2_t              vop_fid2;
-       vop_rwlock_t            vop_rwlock;
-       vop_rwunlock_t          vop_rwunlock;
-       vop_bmap_t              vop_bmap;
-       vop_reclaim_t           vop_reclaim;
-       vop_attr_get_t          vop_attr_get;
-       vop_attr_set_t          vop_attr_set;
-       vop_attr_remove_t       vop_attr_remove;
-       vop_attr_list_t         vop_attr_list;
-       vop_link_removed_t      vop_link_removed;
-       vop_vnode_change_t      vop_vnode_change;
-       vop_ptossvp_t           vop_tosspages;
-       vop_pflushinvalvp_t     vop_flushinval_pages;
-       vop_pflushvp_t          vop_flush_pages;
-       vop_release_t           vop_release;
-       vop_iflush_t            vop_iflush;
-} vnodeops_t;
-
-/*
- * VOP's.
- */
-#define _VOP_(op, vp)  (*((vnodeops_t *)(vp)->v_fops)->op)
-
-#define VOP_READ(vp,file,iov,segs,offset,ioflags,cr,rv)                        \
-       rv = _VOP_(vop_read, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
-#define VOP_WRITE(vp,file,iov,segs,offset,ioflags,cr,rv)               \
-       rv = _VOP_(vop_write, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
-#define VOP_SENDFILE(vp,f,off,ioflags,cnt,act,targ,cr,rv)              \
-       rv = _VOP_(vop_sendfile, vp)((vp)->v_fbhv,f,off,ioflags,cnt,act,targ,cr)
-#define VOP_BMAP(vp,of,sz,rw,b,n,rv)                                   \
-       rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n)
-#define VOP_OPEN(vp, cr, rv)                                           \
-       rv = _VOP_(vop_open, vp)((vp)->v_fbhv, cr)
-#define VOP_GETATTR(vp, vap, f, cr, rv)                                        \
-       rv = _VOP_(vop_getattr, vp)((vp)->v_fbhv, vap, f, cr)
-#define        VOP_SETATTR(vp, vap, f, cr, rv)                                 \
-       rv = _VOP_(vop_setattr, vp)((vp)->v_fbhv, vap, f, cr)
-#define        VOP_ACCESS(vp, mode, cr, rv)                                    \
-       rv = _VOP_(vop_access, vp)((vp)->v_fbhv, mode, cr)
-#define        VOP_LOOKUP(vp,d,vpp,f,rdir,cr,rv)                               \
-       rv = _VOP_(vop_lookup, vp)((vp)->v_fbhv,d,vpp,f,rdir,cr)
-#define VOP_CREATE(dvp,d,vap,vpp,cr,rv)                                        \
-       rv = _VOP_(vop_create, dvp)((dvp)->v_fbhv,d,vap,vpp,cr)
-#define VOP_REMOVE(dvp,d,cr,rv)                                                \
-       rv = _VOP_(vop_remove, dvp)((dvp)->v_fbhv,d,cr)
-#define        VOP_LINK(tdvp,fvp,d,cr,rv)                                      \
-       rv = _VOP_(vop_link, tdvp)((tdvp)->v_fbhv,fvp,d,cr)
-#define        VOP_RENAME(fvp,fnm,tdvp,tnm,cr,rv)                              \
-       rv = _VOP_(vop_rename, fvp)((fvp)->v_fbhv,fnm,tdvp,tnm,cr)
-#define        VOP_MKDIR(dp,d,vap,vpp,cr,rv)                                   \
-       rv = _VOP_(vop_mkdir, dp)((dp)->v_fbhv,d,vap,vpp,cr)
-#define        VOP_RMDIR(dp,d,cr,rv)                                           \
-       rv = _VOP_(vop_rmdir, dp)((dp)->v_fbhv,d,cr)
-#define        VOP_READDIR(vp,uiop,cr,eofp,rv)                                 \
-       rv = _VOP_(vop_readdir, vp)((vp)->v_fbhv,uiop,cr,eofp)
-#define        VOP_SYMLINK(dvp,d,vap,tnm,vpp,cr,rv)                            \
-       rv = _VOP_(vop_symlink, dvp) ((dvp)->v_fbhv,d,vap,tnm,vpp,cr)
-#define        VOP_READLINK(vp,uiop,fl,cr,rv)                                  \
-       rv = _VOP_(vop_readlink, vp)((vp)->v_fbhv,uiop,fl,cr)
-#define        VOP_FSYNC(vp,f,cr,b,e,rv)                                       \
-       rv = _VOP_(vop_fsync, vp)((vp)->v_fbhv,f,cr,b,e)
-#define VOP_INACTIVE(vp, cr, rv)                                       \
-       rv = _VOP_(vop_inactive, vp)((vp)->v_fbhv, cr)
-#define VOP_RELEASE(vp, rv)                                            \
-       rv = _VOP_(vop_release, vp)((vp)->v_fbhv)
-#define VOP_FID2(vp, fidp, rv)                                         \
-       rv = _VOP_(vop_fid2, vp)((vp)->v_fbhv, fidp)
-#define VOP_RWLOCK(vp,i)                                               \
-       (void)_VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
-#define VOP_RWLOCK_TRY(vp,i)                                           \
-       _VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
-#define VOP_RWUNLOCK(vp,i)                                             \
-       (void)_VOP_(vop_rwunlock, vp)((vp)->v_fbhv, i)
-#define VOP_FRLOCK(vp,c,fl,flags,offset,fr,rv)                         \
-       rv = _VOP_(vop_frlock, vp)((vp)->v_fbhv,c,fl,flags,offset,fr)
-#define VOP_RECLAIM(vp, rv)                                            \
-       rv = _VOP_(vop_reclaim, vp)((vp)->v_fbhv)
-#define VOP_ATTR_GET(vp, name, val, vallenp, fl, cred, rv)             \
-       rv = _VOP_(vop_attr_get, vp)((vp)->v_fbhv,name,val,vallenp,fl,cred)
-#define        VOP_ATTR_SET(vp, name, val, vallen, fl, cred, rv)               \
-       rv = _VOP_(vop_attr_set, vp)((vp)->v_fbhv,name,val,vallen,fl,cred)
-#define        VOP_ATTR_REMOVE(vp, name, flags, cred, rv)                      \
-       rv = _VOP_(vop_attr_remove, vp)((vp)->v_fbhv,name,flags,cred)
-#define        VOP_ATTR_LIST(vp, buf, buflen, fl, cursor, cred, rv)            \
-       rv = _VOP_(vop_attr_list, vp)((vp)->v_fbhv,buf,buflen,fl,cursor,cred)
-#define VOP_LINK_REMOVED(vp, dvp, linkzero)                            \
-       (void)_VOP_(vop_link_removed, vp)((vp)->v_fbhv, dvp, linkzero)
-#define VOP_VNODE_CHANGE(vp, cmd, val)                                 \
-       (void)_VOP_(vop_vnode_change, vp)((vp)->v_fbhv,cmd,val)
-/*
- * These are page cache functions that now go thru VOPs.
- * 'last' parameter is unused and left in for IRIX compatibility
- */
-#define VOP_TOSS_PAGES(vp, first, last, fiopt)                         \
-       _VOP_(vop_tosspages, vp)((vp)->v_fbhv,first, last, fiopt)
-/*
- * 'last' parameter is unused and left in for IRIX compatibility
- */
-#define VOP_FLUSHINVAL_PAGES(vp, first, last, fiopt)                   \
-       _VOP_(vop_flushinval_pages, vp)((vp)->v_fbhv,first,last,fiopt)
-/*
- * 'last' parameter is unused and left in for IRIX compatibility
- */
-#define VOP_FLUSH_PAGES(vp, first, last, flags, fiopt, rv)             \
-       rv = _VOP_(vop_flush_pages, vp)((vp)->v_fbhv,first,last,flags,fiopt)
-#define VOP_IOCTL(vp, inode, filp, fl, cmd, arg, rv)                   \
-       rv = _VOP_(vop_ioctl, vp)((vp)->v_fbhv,inode,filp,fl,cmd,arg)
-#define VOP_IFLUSH(vp, flags, rv)                                      \
-       rv = _VOP_(vop_iflush, vp)((vp)->v_fbhv, flags)
-
-/*
- * Flags for read/write calls - same values as IRIX
- */
-#define IO_ISDIRECT    0x00004         /* bypass page cache */
-#define IO_INVIS       0x00020         /* don't update inode timestamps */
-
-/*
- * Flags for VOP_IFLUSH call
- */
-#define FLUSH_SYNC             1       /* wait for flush to complete   */
-#define FLUSH_INODE            2       /* flush the inode itself       */
-#define FLUSH_LOG              4       /* force the last log entry for
-                                        * this inode out to disk       */
-
-/*
- * Flush/Invalidate options for VOP_TOSS_PAGES, VOP_FLUSHINVAL_PAGES and
- *     VOP_FLUSH_PAGES.
- */
-#define FI_NONE                        0       /* none */
-#define FI_REMAPF              1       /* Do a remapf prior to the operation */
-#define FI_REMAPF_LOCKED       2       /* Do a remapf prior to the operation.
-                                          Prevent VM access to the pages until
-                                          the operation completes. */
-
-/*
- * Vnode attributes.  va_mask indicates those attributes the caller
- * wants to set or extract.
- */
-typedef struct vattr {
-       int             va_mask;        /* bit-mask of attributes present */
-       enum vtype      va_type;        /* vnode type (for create) */
-       mode_t          va_mode;        /* file access mode and type */
-       nlink_t         va_nlink;       /* number of references to file */
-       uid_t           va_uid;         /* owner user id */
-       gid_t           va_gid;         /* owner group id */
-       xfs_ino_t       va_nodeid;      /* file id */
-       xfs_off_t       va_size;        /* file size in bytes */
-       u_long          va_blocksize;   /* blocksize preferred for i/o */
-       struct timespec va_atime;       /* time of last access */
-       struct timespec va_mtime;       /* time of last modification */
-       struct timespec va_ctime;       /* time file changed */
-       u_int           va_gen;         /* generation number of file */
-       xfs_dev_t       va_rdev;        /* device the special file represents */
-       __int64_t       va_nblocks;     /* number of blocks allocated */
-       u_long          va_xflags;      /* random extended file flags */
-       u_long          va_extsize;     /* file extent size */
-       u_long          va_nextents;    /* number of extents in file */
-       u_long          va_anextents;   /* number of attr extents in file */
-       int             va_projid;      /* project id */
-} vattr_t;
-
-/*
- * setattr or getattr attributes
- */
-#define XFS_AT_TYPE            0x00000001
-#define XFS_AT_MODE            0x00000002
-#define XFS_AT_UID             0x00000004
-#define XFS_AT_GID             0x00000008
-#define XFS_AT_FSID            0x00000010
-#define XFS_AT_NODEID          0x00000020
-#define XFS_AT_NLINK           0x00000040
-#define XFS_AT_SIZE            0x00000080
-#define XFS_AT_ATIME           0x00000100
-#define XFS_AT_MTIME           0x00000200
-#define XFS_AT_CTIME           0x00000400
-#define XFS_AT_RDEV            0x00000800
-#define XFS_AT_BLKSIZE         0x00001000
-#define XFS_AT_NBLOCKS         0x00002000
-#define XFS_AT_VCODE           0x00004000
-#define XFS_AT_MAC             0x00008000
-#define XFS_AT_UPDATIME                0x00010000
-#define XFS_AT_UPDMTIME                0x00020000
-#define XFS_AT_UPDCTIME                0x00040000
-#define XFS_AT_ACL             0x00080000
-#define XFS_AT_CAP             0x00100000
-#define XFS_AT_INF             0x00200000
-#define XFS_AT_XFLAGS          0x00400000
-#define XFS_AT_EXTSIZE         0x00800000
-#define XFS_AT_NEXTENTS                0x01000000
-#define XFS_AT_ANEXTENTS       0x02000000
-#define XFS_AT_PROJID          0x04000000
-#define XFS_AT_SIZE_NOPERM     0x08000000
-#define XFS_AT_GENCOUNT                0x10000000
-
-#define XFS_AT_ALL     (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
-               XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
-               XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
-               XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
-               XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
-               XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
-
-#define XFS_AT_STAT    (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
-               XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
-               XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
-               XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID)
-
-#define XFS_AT_TIMES   (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME)
-
-#define XFS_AT_UPDTIMES        (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME)
-
-#define XFS_AT_NOSET   (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\
-               XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
-               XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
-
-/*
- *  Modes.
- */
-#define VSUID  S_ISUID         /* set user id on execution */
-#define VSGID  S_ISGID         /* set group id on execution */
-#define VSVTX  S_ISVTX         /* save swapped text even after use */
-#define VREAD  S_IRUSR         /* read, write, execute permissions */
-#define VWRITE S_IWUSR
-#define VEXEC  S_IXUSR
-
-#define MODEMASK S_IALLUGO     /* mode bits plus permission bits */
-
-/*
- * Check whether mandatory file locking is enabled.
- */
-#define MANDLOCK(vp, mode)     \
-       ((vp)->v_type == VREG && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
-
-extern void    vn_init(void);
-extern int     vn_wait(struct vnode *);
-extern vnode_t *vn_initialize(struct inode *);
-
-/*
- * Acquiring and invalidating vnodes:
- *
- *     if (vn_get(vp, version, 0))
- *             ...;
- *     vn_purge(vp, version);
- *
- * vn_get and vn_purge must be called with vmap_t arguments, sampled
- * while a lock that the vnode's VOP_RECLAIM function acquires is
- * held, to ensure that the vnode sampled with the lock held isn't
- * recycled (VOP_RECLAIMed) or deallocated between the release of the lock
- * and the subsequent vn_get or vn_purge.
- */
-
-/*
- * vnode_map structures _must_ match vn_epoch and vnode structure sizes.
- */
-typedef struct vnode_map {
-       vfs_t           *v_vfsp;
-       vnumber_t       v_number;               /* in-core vnode number */
-       xfs_ino_t       v_ino;                  /* inode #      */
-} vmap_t;
-
-#define VMAP(vp, vmap) {(vmap).v_vfsp   = (vp)->v_vfsp,        \
-                        (vmap).v_number = (vp)->v_number,      \
-                        (vmap).v_ino    = (vp)->v_inode.i_ino; }
-
-extern void    vn_purge(struct vnode *, vmap_t *);
-extern vnode_t *vn_get(struct vnode *, vmap_t *);
-extern int     vn_revalidate(struct vnode *);
-extern void    vn_remove(struct vnode *);
-
-static inline int vn_count(struct vnode *vp)
-{
-       return atomic_read(&LINVFS_GET_IP(vp)->i_count);
-}
-
-/*
- * Vnode reference counting functions (and macros for compatibility).
- */
-extern vnode_t *vn_hold(struct vnode *);
-extern void    vn_rele(struct vnode *);
-
-#if defined(XFS_VNODE_TRACE)
-#define VN_HOLD(vp)            \
-       ((void)vn_hold(vp),     \
-         vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
-#define VN_RELE(vp)            \
-         (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
-          iput(LINVFS_GET_IP(vp)))
-#else
-#define VN_HOLD(vp)            ((void)vn_hold(vp))
-#define VN_RELE(vp)            (iput(LINVFS_GET_IP(vp)))
-#endif
-
-/*
- * Vname handling macros.
- */
-#define VNAME(dentry)          ((char *) (dentry)->d_name.name)
-#define VNAMELEN(dentry)       ((dentry)->d_name.len)
-#define VNAME_TO_VNODE(dentry) (LINVFS_GET_VP((dentry)->d_inode))
-
-/*
- * Vnode spinlock manipulation.
- */
-#define VN_LOCK(vp)            mutex_spinlock(&(vp)->v_lock)
-#define VN_UNLOCK(vp, s)       mutex_spinunlock(&(vp)->v_lock, s)
-#define VN_FLAGSET(vp,b)       vn_flagset(vp,b)
-#define VN_FLAGCLR(vp,b)       vn_flagclr(vp,b)
-
-static __inline__ void vn_flagset(struct vnode *vp, uint flag)
-{
-       spin_lock(&vp->v_lock);
-       vp->v_flag |= flag;
-       spin_unlock(&vp->v_lock);
-}
-
-static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
-{
-       spin_lock(&vp->v_lock);
-       vp->v_flag &= ~flag;
-       spin_unlock(&vp->v_lock);
-}
-
-/*
- * Update modify/access/change times on the vnode
- */
-#define VN_MTIMESET(vp, tvp)   (LINVFS_GET_IP(vp)->i_mtime = *(tvp))
-#define VN_ATIMESET(vp, tvp)   (LINVFS_GET_IP(vp)->i_atime = *(tvp))
-#define VN_CTIMESET(vp, tvp)   (LINVFS_GET_IP(vp)->i_ctime = *(tvp))
-
-/*
- * Some useful predicates.
- */
-#define VN_MAPPED(vp)  mapping_mapped(LINVFS_GET_IP(vp)->i_mapping)
-#define VN_CACHED(vp)  (LINVFS_GET_IP(vp)->i_mapping->nrpages)
-#define VN_DIRTY(vp)   mapping_tagged(LINVFS_GET_IP(vp)->i_mapping, \
-                                       PAGECACHE_TAG_DIRTY)
-#define VMODIFY(vp)    VN_FLAGSET(vp, VMODIFIED)
-#define VUNMODIFY(vp)  VN_FLAGCLR(vp, VMODIFIED)
-
-/*
- * Flags to VOP_SETATTR/VOP_GETATTR.
- */
-#define        ATTR_UTIME      0x01    /* non-default utime(2) request */
-#define        ATTR_DMI        0x08    /* invocation from a DMI function */
-#define        ATTR_LAZY       0x80    /* set/get attributes lazily */
-#define        ATTR_NONBLOCK   0x100   /* return EAGAIN if operation would block */
-
-/*
- * Flags to VOP_FSYNC and VOP_RECLAIM.
- */
-#define FSYNC_NOWAIT   0       /* asynchronous flush */
-#define FSYNC_WAIT     0x1     /* synchronous fsync or forced reclaim */
-#define FSYNC_INVAL    0x2     /* flush and invalidate cached data */
-#define FSYNC_DATA     0x4     /* synchronous fsync of data only */
-
-/*
- * Tracking vnode activity.
- */
-#if defined(XFS_VNODE_TRACE)
-
-#define        VNODE_TRACE_SIZE        16              /* number of trace entries */
-#define        VNODE_KTRACE_ENTRY      1
-#define        VNODE_KTRACE_EXIT       2
-#define        VNODE_KTRACE_HOLD       3
-#define        VNODE_KTRACE_REF        4
-#define        VNODE_KTRACE_RELE       5
-
-extern void vn_trace_entry(struct vnode *, char *, inst_t *);
-extern void vn_trace_exit(struct vnode *, char *, inst_t *);
-extern void vn_trace_hold(struct vnode *, char *, int, inst_t *);
-extern void vn_trace_ref(struct vnode *, char *, int, inst_t *);
-extern void vn_trace_rele(struct vnode *, char *, int, inst_t *);
-
-#define        VN_TRACE(vp)            \
-       vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
-#else
-#define        vn_trace_entry(a,b,c)
-#define        vn_trace_exit(a,b,c)
-#define        vn_trace_hold(a,b,c,d)
-#define        vn_trace_ref(a,b,c,d)
-#define        vn_trace_rele(a,b,c,d)
-#define        VN_TRACE(vp)
-#endif
-
-#endif /* __XFS_VNODE_H__ */
index e0b529b..f8f6e0f 100644 (file)
@@ -456,6 +456,9 @@ xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp);
 #define XFS_DIFLAG_SYNC_BIT      5     /* inode is written synchronously */
 #define XFS_DIFLAG_NOATIME_BIT   6     /* do not update atime */
 #define XFS_DIFLAG_NODUMP_BIT    7     /* do not dump */
+#define XFS_DIFLAG_BARRIER_BIT   10    /* chroot() barrier */
+#define XFS_DIFLAG_IUNLINK_BIT   11    /* inode has iunlink */
+
 #define XFS_DIFLAG_REALTIME      (1 << XFS_DIFLAG_REALTIME_BIT)
 #define XFS_DIFLAG_PREALLOC      (1 << XFS_DIFLAG_PREALLOC_BIT)
 #define XFS_DIFLAG_NEWRTBM       (1 << XFS_DIFLAG_NEWRTBM_BIT)
@@ -464,5 +467,8 @@ xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp);
 #define XFS_DIFLAG_SYNC          (1 << XFS_DIFLAG_SYNC_BIT)
 #define XFS_DIFLAG_NOATIME       (1 << XFS_DIFLAG_NOATIME_BIT)
 #define XFS_DIFLAG_NODUMP        (1 << XFS_DIFLAG_NODUMP_BIT)
+#define XFS_DIFLAG_BARRIER       (1 << XFS_DIFLAG_BARRIER_BIT)
+#define XFS_DIFLAG_IUNLINK       (1 << XFS_DIFLAG_IUNLINK_BIT)
+
 
 #endif /* __XFS_DINODE_H__ */
index 1ed650e..7e1b82c 100644 (file)
@@ -76,6 +76,8 @@ struct fsxattr {
 #define XFS_XFLAG_SYNC         0x00000020      /* all writes synchronous */
 #define XFS_XFLAG_NOATIME      0x00000040      /* do not update access time */
 #define XFS_XFLAG_NODUMP       0x00000080      /* do not include in backups */
+#define XFS_XFLAG_BARRIER      0x00004000      /* chroot() barrier */
+#define XFS_XFLAG_IUNLINK      0x00008000      /* Immutable unlink */
 #define XFS_XFLAG_HASATTR      0x80000000      /* no DIFLAG for this   */
 
 /*
index 8a821fe..0a73218 100644 (file)
@@ -869,6 +869,10 @@ xfs_dic2xflags(
                flags |= XFS_XFLAG_PREALLOC;
        if (di_flags & XFS_DIFLAG_IMMUTABLE)
                flags |= XFS_XFLAG_IMMUTABLE;
+       if (di_flags & XFS_DIFLAG_IUNLINK)
+               flags |= XFS_XFLAG_IUNLINK;
+       if (di_flags & XFS_DIFLAG_BARRIER)
+               flags |= XFS_XFLAG_BARRIER;
        if (di_flags & XFS_DIFLAG_APPEND)
                flags |= XFS_XFLAG_APPEND;
        if (di_flags & XFS_DIFLAG_SYNC)
index 72a04a1..05ab682 100644 (file)
@@ -830,6 +830,10 @@ xfs_setattr(
                        }
                        if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
                                ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
+                       if (vap->va_xflags & XFS_XFLAG_IUNLINK)
+                               ip->i_d.di_flags |= XFS_DIFLAG_IUNLINK;
+                       if (vap->va_xflags & XFS_XFLAG_BARRIER)
+                               ip->i_d.di_flags |= XFS_DIFLAG_BARRIER;
                        if (vap->va_xflags & XFS_XFLAG_APPEND)
                                ip->i_d.di_flags |= XFS_DIFLAG_APPEND;
                        if (vap->va_xflags & XFS_XFLAG_SYNC)
index 82db061..7751db5 100644 (file)
@@ -44,7 +44,8 @@
 #ifndef __ACLINUX_H__
 #define __ACLINUX_H__
 
-#define ACPI_OS_NAME                "Linux"
+#define ACPI_OS_NAME                "Microsoft Windows NT"
+ /* Microsoft, Microsoft Windows, Microsoft Windows NT are trademarks of Microsoft Corp. */
 
 #define ACPI_USE_SYSTEM_CLIBRARY
 #define ACPI_USE_DO_WHILE_0
diff --git a/include/asm-alpha/cpumask.h b/include/asm-alpha/cpumask.h
deleted file mode 100644 (file)
index bc3381a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_ALPHA_CPUMASK_H
-#define _ASM_ALPHA_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_ALPHA_CPUMASK_H */
index 6b7d6c1..d475904 100644 (file)
@@ -20,6 +20,7 @@
 #define O_DIRECTORY    0100000 /* must be a directory */
 #define O_NOFOLLOW     0200000 /* don't follow links */
 #define O_LARGEFILE    0400000 /* will be set by the kernel on every open */
+#define O_ATOMICLOOKUP 01000000 /* do atomic file lookup */
 #define O_DIRECT       02000000 /* direct disk access - should check with OSF/1 */
 #define O_NOATIME      04000000
 
diff --git a/include/asm-alpha/init.h b/include/asm-alpha/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
index b316fc6..d53c53e 100644 (file)
@@ -106,6 +106,7 @@ extern __inline__ int get_order(unsigned long size)
 #define VM_DATA_DEFAULT_FLAGS          (VM_READ | VM_WRITE | VM_EXEC | \
                                         VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
 #endif /* __KERNEL__ */
 
 #endif /* _ALPHA_PAGE_H */
diff --git a/include/asm-alpha/relay.h b/include/asm-alpha/relay.h
new file mode 100644 (file)
index 0000000..104091f
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_ALPHA_RELAY_H
+#define _ASM_ALPHA_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index b94759c..d2d03a4 100644 (file)
@@ -41,7 +41,7 @@
     {INR_OPEN, INR_OPEN},                      /* RLIMIT_NOFILE */     \
     {LONG_MAX, LONG_MAX},                      /* RLIMIT_AS */         \
     {LONG_MAX, LONG_MAX},                      /* RLIMIT_NPROC */      \
-    {LONG_MAX, LONG_MAX},                      /* RLIMIT_MEMLOCK */    \
+    {32768,    32768   },                      /* RLIMIT_MEMLOCK */    \
     {LONG_MAX, LONG_MAX},                      /* RLIMIT_LOCKS */      \
     {MAX_SIGPENDING, MAX_SIGPENDING},          /* RLIMIT_SIGPENDING */ \
     {MQ_BYTES_MAX, MQ_BYTES_MAX},              /* RLIMIT_MSGQUEUE */   \
diff --git a/include/asm-alpha/rmap.h b/include/asm-alpha/rmap.h
deleted file mode 100644 (file)
index 08b2236..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _ALPHA_RMAP_H
-#define _ALPHA_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index c9bb9f1..cc5394e 100644 (file)
@@ -395,6 +395,10 @@ __copy_tofrom_user(void *to, const void *from, long len, const void __user *vali
        __copy_tofrom_user_nocheck((to),(__force void *)(from),(n));    \
 })
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
+
 extern inline long
 copy_to_user(void __user *to, const void *from, long n)
 {
index ceda5fc..aae3ab6 100644 (file)
 #define __NR_osf_memcntl       260     /* not implemented */
 #define __NR_osf_fdatasync     261     /* not implemented */
 
+#define __NR_vserver           273
 
 /*
  * Linux-specific system calls begin at 300
diff --git a/include/asm-arm/arch-adifcc/adi_evb.h b/include/asm-arm/arch-adifcc/adi_evb.h
deleted file mode 100644 (file)
index f4b74c6..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * linux/include/asm/arch-80200fcc/adi_evb.h
- *
- * ADI 80200FCC evaluation board definitions
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (C) 2001 MontaVista Software Inc.
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
-
-#define ADI_EVB__RAMBASE       0xa0000000
-#define ADI_EVB__UART          0x00400000    /* UART */
-#define ADI_EVB_7SEG_1         0x00500000    /* 7-Segment */
-
diff --git a/include/asm-arm/arch-adifcc/dma.h b/include/asm-arm/arch-adifcc/dma.h
deleted file mode 100644 (file)
index 19aa1db..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * linux/include/asm-arm/arch-80200fcc/dma.h
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __ASM_ARCH_DMA_H
-#define __ASM_ARCH_DMA_H
-
-#define MAX_DMA_ADDRESS                0xffffffff
-
-/* No DMA */
-#define MAX_DMA_CHANNELS       0
-
-#endif /* _ASM_ARCH_DMA_H */
diff --git a/include/asm-arm/arch-adifcc/hardware.h b/include/asm-arm/arch-adifcc/hardware.h
deleted file mode 100644 (file)
index 9eeb3cb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/hardware.h
- *
- * Hardware definitions for ADI based systems
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (C) 2000-2001 MontaVista Software Inc.
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-#include <linux/config.h>
-
-#define PCIO_BASE      0
-
-#if defined(CONFIG_ARCH_ADI_EVB)
-#include "adi_evb.h"
-#endif
-
-#endif  /* _ASM_ARCH_HARDWARE_H */
diff --git a/include/asm-arm/arch-adifcc/io.h b/include/asm-arm/arch-adifcc/io.h
deleted file mode 100644 (file)
index bdcaec0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/io.h
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (C) 2001  MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __ASM_ARM_ARCH_IO_H
-#define __ASM_ARM_ARCH_IO_H
-
-#define IO_SPACE_LIMIT 0xffffffff
-
-#define __io(a)                        (PCIO_BASE + (a))
-#define __mem_pci(a)           ((unsigned long)(a))
-#define __mem_isa(a)           ((unsigned long)(a))
-
-#endif
diff --git a/include/asm-arm/arch-adifcc/irqs.h b/include/asm-arm/arch-adifcc/irqs.h
deleted file mode 100644 (file)
index b559ca7..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * linux/include/asm-arm/arch-80200fcc/irqs.h
- *
- * Author:     Deepak Saxena <dsaxena@mvista.com>
- * Copyright:  (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#define IRQ_XS80200_BCU                0       /* Bus Control Unit */
-#define IRQ_XS80200_PMU                1       /* Performance Monitoring Unit */
-#define IRQ_XS80200_EXTIRQ     2       /* external IRQ signal */
-#define IRQ_XS80200_EXTFIQ     3       /* external IRQ signal */
-
-#define NR_XS80200_IRQS                4
-#define NR_IRQS                        NR_XS80200_IRQS
-
-#define        IRQ_XSCALE_PMU          IRQ_XS80200_PMU
diff --git a/include/asm-arm/arch-adifcc/memory.h b/include/asm-arm/arch-adifcc/memory.h
deleted file mode 100644 (file)
index b76187d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/memory.h
- *
- * Copyright (c) 2001 MontaVista Software, Inc.
- */
-
-#ifndef __ASM_ARCH_MEMORY_H
-#define __ASM_ARCH_MEMORY_H
-
-/*
- * Physical DRAM offset.
- */
-#define PHYS_OFFSET    (0xC0000000UL)
-
-/*
- * Virtual view <-> DMA view memory address translations
- * virt_to_bus: Used to translate the virtual address to an
- *             address suitable to be passed to set_dma_addr
- * bus_to_virt: Used to convert an address for DMA operations
- *             to an address that the kernel can use.
- *
- * These are dummies for now.
- */
-#define __virt_to_bus(x)        __virt_to_phys(x)
-#define __bus_to_virt(x)        __phys_to_virt(x)
-
-#endif
diff --git a/include/asm-arm/arch-adifcc/param.h b/include/asm-arm/arch-adifcc/param.h
deleted file mode 100644 (file)
index b1a410e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-adifcc/param.h
- */
diff --git a/include/asm-arm/arch-adifcc/serial.h b/include/asm-arm/arch-adifcc/serial.h
deleted file mode 100644 (file)
index ce4e876..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * include/asm-arm/arch-adifcc/serial.h
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (c) 2001 MontaVista Software, Inc.
- */
-#include <linux/config.h>
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD ( 1852000 / 16 )
-
-/* Standard COM flags */
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-#ifdef CONFIG_ARCH_ADI_EVB
-
-/*
- * One serial port, int goes to FIQ, so we run in polled mode
- */
-#define STD_SERIAL_PORT_DEFNS                  \
-       /* UART CLK      PORT        IRQ        FLAGS        */                 \
-       { 0, BASE_BAUD, 0xff400000, 0,  STD_COM_FLAGS }  /* ttyS0 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
-
diff --git a/include/asm-arm/arch-adifcc/system.h b/include/asm-arm/arch-adifcc/system.h
deleted file mode 100644 (file)
index 4bffbdc..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/system.h
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-static inline void arch_idle(void)
-{
-#if 0
-       cpu_do_idle();
-#endif
-}
-
-
-static inline void arch_reset(char mode)
-{
-       if ( 1 && mode == 's') {
-               /* Jump into ROM at address 0 */
-               cpu_reset(0);
-       } else {
-               /* Use on-chip reset capability */
-       }
-}
-
diff --git a/include/asm-arm/arch-adifcc/time.h b/include/asm-arm/arch-adifcc/time.h
deleted file mode 100644 (file)
index 2237ef0..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/time.h
- *
- */
-
-/*
- * No on board timer, implementation @ arch/arm/kernel/xscale-time.c
- */
-
diff --git a/include/asm-arm/arch-adifcc/timex.h b/include/asm-arm/arch-adifcc/timex.h
deleted file mode 100644 (file)
index d994c8a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/timex.h
- *
- * XScale architecture timex specifications
- */
-
-/* This is for a timer based on the XS80200's PMU counter */
-
-#define CLOCK_TICK_RATE 600000000 /* Underlying HZ */
-
diff --git a/include/asm-arm/arch-adifcc/uncompress.h b/include/asm-arm/arch-adifcc/uncompress.h
deleted file mode 100644 (file)
index 792b4e1..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/uncompress.h
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (c) 2001 MontaVista Software, Inc.
- *
- */
-
-#define UART_BASE    ((volatile unsigned char *)0x00400000)
-
-static __inline__ void putc(char c)
-{
-       while ((UART_BASE[5] & 0x60) != 0x60);
-       UART_BASE[0] = c;
-}
-
-/*
- * This does not append a newline
- */
-static void puts(const char *s)
-{
-       while (*s) {
-               putc(*s);
-               if (*s == '\n')
-                       putc('\r');
-               s++;
-       }
-}
-
-/*
- * nothing to do
- */
-#define arch_decomp_setup()
-#define arch_decomp_wdog()
diff --git a/include/asm-arm/arch-adifcc/vmalloc.h b/include/asm-arm/arch-adifcc/vmalloc.h
deleted file mode 100644 (file)
index d45b27e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * linux/include/asm-arm/arch-adifcc/vmalloc.h
- */
-
-/*
- * Just any arbitrary offset to the start of the vmalloc VM area: the
- * current 8MB value just means that there will be a 8MB "hole" after the
- * physical memory until the kernel virtual memory starts.  That means that
- * any out-of-bounds memory accesses will hopefully be caught.
- * The vmalloc() routines leaves a hole of 4kB between each vmalloced
- * area for the same reason. ;)
- */
-#define VMALLOC_OFFSET   (8*1024*1024)
-#define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
-#define VMALLOC_END       (0xe8000000)
diff --git a/include/asm-arm/arch-cl7500/ide.h b/include/asm-arm/arch-cl7500/ide.h
deleted file mode 100644 (file)
index 78f97a3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * linux/include/asm-arm/arch-cl7500/ide.h
- *
- * Copyright (c) 1997 Russell King
- *
- * Modifications:
- *  29-07-1998 RMK     Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-#include <asm/arch/hardware.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-
-       memset(hw, 0, sizeof(*hw));
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += 1;
-       }
-       if (ctrl_port) {
-               hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-       } else {
-               hw->io_ports[IDE_CONTROL_OFFSET] = data_port + 0x206;
-       }
-       if (irq != NULL)
-               *irq = 0;
-       hw->io_ports[IDE_IRQ_OFFSET] = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
-       hw_regs_t hw;
-
-       ide_init_hwif_ports(&hw, ISASLOT_IO + 0x1f0, ISASLOT_IO + 0x3f6, NULL);
-       hw.irq = IRQ_ISA_14;
-       ide_register_hw(&hw);
-}
diff --git a/include/asm-arm/arch-cl7500/keyboard.h b/include/asm-arm/arch-cl7500/keyboard.h
deleted file mode 100644 (file)
index 660b31a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * linux/include/asm-arm/arch-cl7500/keyboard.h
- *  from linux/include/asm-arm/arch-rpc/keyboard.h
- *
- * Keyboard driver definitions for CL7500 architecture
- *
- * Copyright (C) 1998-2001 Russell King
- */
-#include <asm/irq.h>
-#define NR_SCANCODES 128
-
-extern int ps2kbd_init_hw(void);
-
-#define kbd_disable_irq()      disable_irq(IRQ_KEYBOARDRX)
-#define kbd_enable_irq()       enable_irq(IRQ_KEYBOARDRX)
-#define kbd_init_hw()          ps2kbd_init_hw()
diff --git a/include/asm-arm/arch-cl7500/time.h b/include/asm-arm/arch-cl7500/time.h
deleted file mode 100644 (file)
index e5e5be5..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * linux/include/asm-arm/arch-cl7500/time.h
- *
- * Copyright (c) 1996-2000 Russell King.
- *
- * Changelog:
- *  24-Sep-1996        RMK     Created
- *  10-Oct-1996        RMK     Brought up to date with arch-sa110eval
- *  04-Dec-1997        RMK     Updated for new arch/arm/time.c
- */
-
-extern void ioctime_init(void);
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       do_timer(regs);
-       do_set_rtc();
-       do_profile(regs);
-
-       {
-               /* Twinkle the lights. */
-               static int count, state = 0xff00;
-               if (count-- == 0) {
-                       state ^= 0x100;
-                       count = 25;
-                       *((volatile unsigned int *)LED_ADDRESS) = state;
-               }
-       }
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
-       ioctime_init();
-
-       timer_irq.handler = timer_interrupt;
-
-       setup_irq(IRQ_TIMER, &timer_irq);
-}
diff --git a/include/asm-arm/arch-clps711x/keyboard.h b/include/asm-arm/arch-clps711x/keyboard.h
deleted file mode 100644 (file)
index 30ab219..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * linux/include/asm-arm/arch-clps711x/keyboard.h
- *
- * Copyright (C) 1998-2001 Russell King
- */
-#include <asm/mach-types.h>
-
-#define NR_SCANCODES 128
-
-#define kbd_disable_irq()      do { } while (0)
-#define kbd_enable_irq()       do { } while (0)
-
-/*
- * EDB7211 keyboard driver
- */
-extern void edb7211_kbd_init_hw(void);
-extern void clps711x_kbd_init_hw(void);
-
-static inline void kbd_init_hw(void)
-{
-       if (machine_is_edb7211())
-               edb7211_kbd_init_hw();
-
-       if (machine_is_autcpu12())
-               clps711x_kbd_init_hw();
-}
diff --git a/include/asm-arm/arch-ebsa110/ide.h b/include/asm-arm/arch-ebsa110/ide.h
deleted file mode 100644 (file)
index 35eff5c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/* no ide */
diff --git a/include/asm-arm/arch-ebsa110/time.h b/include/asm-arm/arch-ebsa110/time.h
deleted file mode 100644 (file)
index c482e37..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-ebsa110/time.h
- *
- *  Copyright (C) 1996,1997,1998 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * No real time clock on the evalulation board!
- *
- * Changelog:
- *  10-Oct-1996        RMK     Created
- *  04-Dec-1997        RMK     Updated for new arch/arm/kernel/time.c
- *  07-Aug-1998        RMK     Updated for arch/arm/kernel/leds.c
- *  28-Dec-1998        APH     Made leds code optional
- */
-
-#include <asm/leds.h>
-#include <asm/io.h>
-
-extern unsigned long (*gettimeoffset)(void);
-
-#define PIT_CTRL               (PIT_BASE + 0x0d)
-#define PIT_T2                 (PIT_BASE + 0x09)
-#define PIT_T1                 (PIT_BASE + 0x05)
-#define PIT_T0                 (PIT_BASE + 0x01)
-
-/*
- * This is the rate at which your MCLK signal toggles (in Hz)
- * This was measured on a 10 digit frequency counter sampling
- * over 1 second.
- */
-#define MCLK   47894000
-
-/*
- * This is the rate at which the PIT timers get clocked
- */
-#define CLKBY7 (MCLK / 7)
-
-/*
- * This is the counter value.  We tick at 200Hz on this platform.
- */
-#define COUNT  ((CLKBY7 + (HZ / 2)) / HZ)
-
-/*
- * Get the time offset from the system PIT.  Note that if we have missed an
- * interrupt, then the PIT counter will roll over (ie, be negative).
- * This actually works out to be convenient.
- */
-static unsigned long ebsa110_gettimeoffset(void)
-{
-       unsigned long offset, count;
-
-       __raw_writeb(0x40, PIT_CTRL);
-       count = __raw_readb(PIT_T1);
-       count |= __raw_readb(PIT_T1) << 8;
-
-       /*
-        * If count > COUNT, make the number negative.
-        */
-       if (count > COUNT)
-               count |= 0xffff0000;
-
-       offset = COUNT;
-       offset -= count;
-
-       /*
-        * `offset' is in units of timer counts.  Convert
-        * offset to units of microseconds.
-        */
-       offset = offset * (1000000 / HZ) / COUNT;
-
-       return offset;
-}
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       u32 count;
-
-       /* latch and read timer 1 */
-       __raw_writeb(0x40, PIT_CTRL);
-       count = __raw_readb(PIT_T1);
-       count |= __raw_readb(PIT_T1) << 8;
-
-       count += COUNT;
-
-       __raw_writeb(count & 0xff, PIT_T1);
-       __raw_writeb(count >> 8, PIT_T1);
-
-       do_leds();
-       do_timer(regs);
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
-       /*
-        * Timer 1, mode 2, LSB/MSB
-        */
-       __raw_writeb(0x70, PIT_CTRL);
-       __raw_writeb(COUNT & 0xff, PIT_T1);
-       __raw_writeb(COUNT >> 8, PIT_T1);
-
-       gettimeoffset = ebsa110_gettimeoffset;
-
-       timer_irq.handler = timer_interrupt;
-
-       setup_irq(IRQ_EBSA110_TIMER0, &timer_irq);
-}
-
-
diff --git a/include/asm-arm/arch-ebsa285/ide.h b/include/asm-arm/arch-ebsa285/ide.h
deleted file mode 100644 (file)
index 09c0310..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-ebsa285/ide.h
- *
- *  Copyright (C) 1998 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Modifications:
- *   29-07-1998        RMK     Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += 1;
-       }
-       hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-       if (irq)
-               *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void ide_init_default_hwifs(void)
-{
-#if 0
-       hw_regs_t hw;
-
-       memset(hw, 0, sizeof(*hw));
-
-       ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
-       hw.irq = IRQ_HARDDISK;
-       ide_register_hw(&hw);
-#endif
-}
diff --git a/include/asm-arm/arch-ebsa285/time.h b/include/asm-arm/arch-ebsa285/time.h
deleted file mode 100644 (file)
index f651eeb..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-ebsa285/time.h
- *
- *  Copyright (C) 1998 Russell King.
- *  Copyright (C) 1998 Phil Blundell
- *
- * CATS has a real-time clock, though the evaluation board doesn't.
- *
- * Changelog:
- *  21-Mar-1998        RMK     Created
- *  27-Aug-1998        PJB     CATS support
- *  28-Dec-1998        APH     Made leds optional
- *  20-Jan-1999        RMK     Started merge of EBSA285, CATS and NetWinder
- *  16-Mar-1999        RMK     More support for EBSA285-like machines with RTCs in
- */
-
-#define RTC_PORT(x)            (rtc_base+(x))
-#define RTC_ALWAYS_BCD         0
-
-#include <linux/mc146818rtc.h>
-#include <linux/bcd.h>
-
-#include <asm/hardware/dec21285.h>
-#include <asm/leds.h>
-#include <asm/mach-types.h>
-
-static int rtc_base;
-
-#define mSEC_10_from_14 ((14318180 + 100) / 200)
-
-static unsigned long isa_gettimeoffset(void)
-{
-       int count;
-
-       static int count_p = (mSEC_10_from_14/6);    /* for the first call after boot */
-       static unsigned long jiffies_p = 0;
-
-       /*
-        * cache volatile jiffies temporarily; we have IRQs turned off. 
-        */
-       unsigned long jiffies_t;
-
-       /* timer count may underflow right here */
-       outb_p(0x00, 0x43);     /* latch the count ASAP */
-
-       count = inb_p(0x40);    /* read the latched count */
-
-       /*
-        * We do this guaranteed double memory access instead of a _p 
-        * postfix in the previous port access. Wheee, hackady hack
-        */
-       jiffies_t = jiffies;
-
-       count |= inb_p(0x40) << 8;
-
-       /* Detect timer underflows.  If we haven't had a timer tick since 
-          the last time we were called, and time is apparently going
-          backwards, the counter must have wrapped during this routine. */
-       if ((jiffies_t == jiffies_p) && (count > count_p))
-               count -= (mSEC_10_from_14/6);
-       else
-               jiffies_p = jiffies_t;
-
-       count_p = count;
-
-       count = (((mSEC_10_from_14/6)-1) - count) * (tick_nsec / 1000);
-       count = (count + (mSEC_10_from_14/6)/2) / (mSEC_10_from_14/6);
-
-       return count;
-}
-
-static irqreturn_t
-isa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       if (machine_is_netwinder())
-               do_leds();
-
-       do_timer(regs);
-       do_set_rtc();
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-static unsigned long __init get_isa_cmos_time(void)
-{
-       unsigned int year, mon, day, hour, min, sec;
-       int i;
-
-       // check to see if the RTC makes sense.....
-       if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0)
-               return mktime(1970, 1, 1, 0, 0, 0);
-
-       /* The Linux interpretation of the CMOS clock register contents:
-        * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
-        * RTC registers show the second which has precisely just started.
-        * Let's hope other operating systems interpret the RTC the same way.
-        */
-       /* read RTC exactly on falling edge of update flag */
-       for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
-               if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
-                       break;
-
-       for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */
-               if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
-                       break;
-
-       do { /* Isn't this overkill ? UIP above should guarantee consistency */
-               sec  = CMOS_READ(RTC_SECONDS);
-               min  = CMOS_READ(RTC_MINUTES);
-               hour = CMOS_READ(RTC_HOURS);
-               day  = CMOS_READ(RTC_DAY_OF_MONTH);
-               mon  = CMOS_READ(RTC_MONTH);
-               year = CMOS_READ(RTC_YEAR);
-       } while (sec != CMOS_READ(RTC_SECONDS));
-
-       if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-               BCD_TO_BIN(sec);
-               BCD_TO_BIN(min);
-               BCD_TO_BIN(hour);
-               BCD_TO_BIN(day);
-               BCD_TO_BIN(mon);
-               BCD_TO_BIN(year);
-       }
-       if ((year += 1900) < 1970)
-               year += 100;
-       return mktime(year, mon, day, hour, min, sec);
-}
-
-static int
-set_isa_cmos_time(void)
-{
-       int retval = 0;
-       int real_seconds, real_minutes, cmos_minutes;
-       unsigned char save_control, save_freq_select;
-       unsigned long nowtime = xtime.tv_sec;
-
-       save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
-       CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
-
-       save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
-       CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
-
-       cmos_minutes = CMOS_READ(RTC_MINUTES);
-       if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
-               BCD_TO_BIN(cmos_minutes);
-
-       /*
-        * since we're only adjusting minutes and seconds,
-        * don't interfere with hour overflow. This avoids
-        * messing with unknown time zones but requires your
-        * RTC not to be off by more than 15 minutes
-        */
-       real_seconds = nowtime % 60;
-       real_minutes = nowtime / 60;
-       if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
-               real_minutes += 30;             /* correct for half hour time zone */
-       real_minutes %= 60;
-
-       if (abs(real_minutes - cmos_minutes) < 30) {
-               if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-                       BIN_TO_BCD(real_seconds);
-                       BIN_TO_BCD(real_minutes);
-               }
-               CMOS_WRITE(real_seconds,RTC_SECONDS);
-               CMOS_WRITE(real_minutes,RTC_MINUTES);
-       } else
-               retval = -1;
-
-       /* The following flags have to be released exactly in this order,
-        * otherwise the DS12887 (popular MC146818A clone with integrated
-        * battery and quartz) will not reset the oscillator and will not
-        * update precisely 500 ms later. You won't find this mentioned in
-        * the Dallas Semiconductor data sheets, but who believes data
-        * sheets anyway ...                           -- Markus Kuhn
-        */
-       CMOS_WRITE(save_control, RTC_CONTROL);
-       CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
-
-       return retval;
-}
-
-
-static unsigned long timer1_latch;
-
-static unsigned long timer1_gettimeoffset (void)
-{
-       unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
-
-       return ((tick_nsec / 1000) * value) / timer1_latch;
-}
-
-static irqreturn_t
-timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       *CSR_TIMER1_CLR = 0;
-
-       /* Do the LEDs things */
-       do_leds();
-       do_timer(regs);
-       do_set_rtc();
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
-       int irq;
-
-       if (machine_is_co285() ||
-           machine_is_personal_server())
-               /*
-                * Add-in 21285s shouldn't access the RTC
-                */
-               rtc_base = 0;
-       else
-               rtc_base = 0x70;
-
-       if (rtc_base) {
-               int reg_d, reg_b;
-
-               /*
-                * Probe for the RTC.
-                */
-               reg_d = CMOS_READ(RTC_REG_D);
-
-               /*
-                * make sure the divider is set
-                */
-               CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_REG_A);
-
-               /*
-                * Set control reg B
-                *   (24 hour mode, update enabled)
-                */
-               reg_b = CMOS_READ(RTC_REG_B) & 0x7f;
-               reg_b |= 2;
-               CMOS_WRITE(reg_b, RTC_REG_B);
-
-               if ((CMOS_READ(RTC_REG_A) & 0x7f) == RTC_REF_CLCK_32KHZ &&
-                   CMOS_READ(RTC_REG_B) == reg_b) {
-                       struct timespec tv;
-
-                       /*
-                        * We have a RTC.  Check the battery
-                        */
-                       if ((reg_d & 0x80) == 0)
-                               printk(KERN_WARNING "RTC: *** warning: CMOS battery bad\n");
-
-                       tv.tv_nsec = 0;
-                       tv.tv_sec = get_isa_cmos_time();
-                       do_settimeofday(&tv);
-                       set_rtc = set_isa_cmos_time;
-               } else
-                       rtc_base = 0;
-       }
-
-       if (machine_is_ebsa285() ||
-           machine_is_co285() ||
-           machine_is_personal_server()) {
-               gettimeoffset = timer1_gettimeoffset;
-
-               timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
-
-               *CSR_TIMER1_CLR  = 0;
-               *CSR_TIMER1_LOAD = timer1_latch;
-               *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
-
-               timer_irq.handler = timer1_interrupt;
-               irq = IRQ_TIMER1;
-       } else {
-               /* enable PIT timer */
-               /* set for periodic (4) and LSB/MSB write (0x30) */
-               outb(0x34, 0x43);
-               outb((mSEC_10_from_14/6) & 0xFF, 0x40);
-               outb((mSEC_10_from_14/6) >> 8, 0x40);
-
-               gettimeoffset = isa_gettimeoffset;
-               timer_irq.handler = isa_timer_interrupt;
-               irq = IRQ_ISA_TIMER;
-       }
-       setup_irq(irq, &timer_irq);
-}
diff --git a/include/asm-arm/arch-epxa10db/time.h b/include/asm-arm/arch-epxa10db/time.h
deleted file mode 100644 (file)
index 749770b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-epxa10db/time.h
- *
- *  Copyright (C) 2001 Altera Corporation
- * 
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <asm/system.h>
-#include <asm/leds.h>
-#include <asm/arch/hardware.h>
-#define TIMER00_TYPE (volatile unsigned int*)
-#include <asm/arch/timer00.h>
-
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t
-excalibur_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-
-       // ...clear the interrupt
-       *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))|=TIMER0_CR_CI_MSK;
-
-       do_leds();
-       do_timer(regs);
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-void __init time_init(void)
-{
-       timer_irq.handler = excalibur_timer_interrupt;
-
-       /* 
-        * Make irqs happen for the system timer
-        */
-       setup_irq(IRQ_TIMER0, &timer_irq);
-
-       /* Start the timer */
-       *TIMER0_LIMIT(IO_ADDRESS(EXC_TIMER00_BASE))=(unsigned int)(EXC_AHB2_CLK_FREQUENCY/200);
-       *TIMER0_PRESCALE(IO_ADDRESS(EXC_TIMER00_BASE))=1;
-       *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))=TIMER0_CR_IE_MSK | TIMER0_CR_S_MSK;
-}
diff --git a/include/asm-arm/arch-iop3xx/ide.h b/include/asm-arm/arch-iop3xx/ide.h
deleted file mode 100644 (file)
index c2b0265..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * include/asm-arm/arch-iop3xx/ide.h
- *
- * Generic IDE functions for IOP310 systems
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright 2001 MontaVista Software Inc.
- *
- * 09/26/2001 - Sharon Baartmans
- *     Fixed so it actually works.
- */
-
-#ifndef _ASM_ARCH_IDE_H_
-#define _ASM_ARCH_IDE_H_
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-       int regincr = 1;
-
-       memset(hw, 0, sizeof(*hw));
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += regincr;
-       }
-
-       hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-
-       if (irq) *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void ide_init_default_hwifs(void)
-{
-       /* There are no standard ports */
-}
-
-#endif
diff --git a/include/asm-arm/arch-iop3xx/time.h b/include/asm-arm/arch-iop3xx/time.h
deleted file mode 100644 (file)
index b58ac84..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * linux/include/asm-arm/arch-iop80310/time.h
- *
- * Author:  Nicolas Pitre
- * Copyright:   (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
diff --git a/include/asm-arm/arch-ixp4xx/time.h b/include/asm-arm/arch-ixp4xx/time.h
deleted file mode 100644 (file)
index e79f4ac..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * linux/include/asm-arm/arch-ixp4xx/time.h
- *
- * We implement timer code in arch/arm/mach-ixp4xx/time.c
- *
- */
-
diff --git a/include/asm-arm/arch-l7200/ide.h b/include/asm-arm/arch-l7200/ide.h
deleted file mode 100644 (file)
index 62ee12a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * linux/include/asm-arm/arch-l7200/ide.h
- *
- * Copyright (c) 2000 Steve Hill (sjhill@cotw.com)
- *
- * Changelog:
- *  03-29-2000 SJH     Created file placeholder
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
-}
diff --git a/include/asm-arm/arch-l7200/keyboard.h b/include/asm-arm/arch-l7200/keyboard.h
deleted file mode 100644 (file)
index 6628bd3..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-l7200/keyboard.h
- *
- *  Keyboard driver definitions for LinkUp Systems L7200 architecture
- *
- *  Copyright (C) 2000 Scott A McConnell (samcconn@cotw.com)
- *                     Steve Hill (sjhill@cotw.com)
- *
- *  This file is subject to the terms and conditions of the GNU General Public
- *  License. See the file COPYING in the main directory of this archive for
- *  more details.
- *
- * Changelog:
- *   07-18-2000        SAM     Created file
- *   07-28-2000        SJH     Complete rewrite
- */
-
-#include <asm/irq.h>
-
-#error This needs fixing --rmk
-
-/*
- * Layout of L7200 keyboard registers
- */
-struct KBD_Port {       
-       unsigned int KBDR;
-       unsigned int KBDMR;
-       unsigned int KBSBSR;
-       unsigned int Reserved;
-       unsigned int KBKSR;
-};
-
-#define KBD_BASE        IO_BASE_2 + 0x4000
-#define l7200kbd_hwregs ((volatile struct KBD_Port *) (KBD_BASE))
-
-extern void l7200kbd_init_hw(void);
-extern int l7200kbd_translate(unsigned char scancode, unsigned char *keycode,
-                             char raw_mode);
-
-#define kbd_setkeycode(sc,kc)          (-EINVAL)
-#define kbd_getkeycode(sc)             (-EINVAL)
-
-#define kbd_translate(sc, kcp, rm)      ({ *(kcp) = (sc); 1; })
-#define kbd_unexpected_up(kc)           (0200)
-#define kbd_leds(leds)                  do {} while (0)
-#define kbd_init_hw()                   l7200kbd_init_hw()
-#define kbd_sysrq_xlate                 ((unsigned char *)NULL)
-#define kbd_disable_irq()               disable_irq(IRQ_GCTC2)
-#define kbd_enable_irq()                enable_irq(IRQ_GCTC2)
-
-#define SYSRQ_KEY      13
diff --git a/include/asm-arm/arch-lh7a40x/ide.h b/include/asm-arm/arch-lh7a40x/ide.h
deleted file mode 100644 (file)
index fb50c07..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* include/asm-arm/arch-lh7a40x/ide.h
- *
- *  Copyright (C) 2004 Logic Product Development
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public License
- *  version 2 as published by the Free Software Foundation.
- *
- */
-
-#ifndef __ASM_ARCH_IDE_H
-#define __ASM_ARCH_IDE_H
-
-#if defined (CONFIG_MACH_LPD7A400) || defined (CONFIG_MACH_LPD7A404)
-
-/*  This implementation of ide.h only applies to the LPD CardEngines.
- *  Thankfully, there is less to do for the KEV.
- */
-
-#include <linux/config.h>
-#include <asm/irq.h>
-#include <asm/hardware.h>
-#include <asm/arch/registers.h>
-
-#define IDE_REG_LINE   (1<<12) /* A12 drives !REG  */
-#define IDE_ALT_LINE   (1<<11) /* Unused A11 allows non-overlapping regions */
-#define IDE_CONTROLREG_OFFSET  (0xe)
-
-void lpd7a40x_hwif_ioops (struct hwif_s* hwif);
-
-static __inline__ void ide_init_hwif_ports (hw_regs_t *hw, int data_port,
-                                           int ctrl_port, int *irq)
-{
-       ide_ioreg_t reg;
-        int i;
-        int regincr = 1;
-
-        memset (hw, 0, sizeof (*hw));
-
-        reg = (ide_ioreg_t) data_port;
-
-        for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-                hw->io_ports[i] = reg;
-                reg += regincr;
-        }
-
-        hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t) ctrl_port;
-
-        if (irq)
-                *irq = IDE_NO_IRQ;
-}
-
-static __inline__  void ide_init_default_hwifs (void)
-{
-       hw_regs_t hw;
-       struct hwif_s* hwif;
-
-       ide_init_hwif_ports (&hw,
-                            CF_VIRT + IDE_REG_LINE,
-                            CF_VIRT + IDE_REG_LINE + IDE_ALT_LINE
-                            + IDE_CONTROLREG_OFFSET,
-                            NULL);
-
-       ide_register_hw (&hw, &hwif);
-       lpd7a40x_hwif_ioops (hwif); /* Override IO routines */
-}
-#endif
-
-#endif
diff --git a/include/asm-arm/arch-lh7a40x/time.h b/include/asm-arm/arch-lh7a40x/time.h
deleted file mode 100644 (file)
index 5f1cf4f..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* include/asm-arm/arch-lh7a40x/time.h
- *
- *  Copyright (C) 2004 Logic Product Development
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public License
- *  version 2 as published by the Free Software Foundation.
- *
- */
-
-#if HZ < 100
-# define TIMER_CONTROL TIMER_CONTROL1
-# define TIMER_LOAD    TIMER_LOAD1
-# define TIMER_CONSTANT        (508469/HZ)
-# define TIMER_MODE    (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ)
-# define TIMER_EOI     TIMER_EOI1
-# define TIMER_IRQ     IRQ_T1UI
-#else
-# define TIMER_CONTROL TIMER_CONTROL3
-# define TIMER_LOAD    TIMER_LOAD3
-# define TIMER_CONSTANT        (3686400/HZ)
-# define TIMER_MODE    (TIMER_C_ENABLE | TIMER_C_PERIODIC)
-# define TIMER_EOI     TIMER_EOI3
-# define TIMER_IRQ     IRQ_T3UI
-#endif
-
-static irqreturn_t
-lh7a40x_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       TIMER_EOI = 0;
-       do_profile (regs);
-       do_leds();
-       do_set_rtc();
-       do_timer (regs);
-
-       return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
-                               /* Stop/disable all timers */
-       TIMER_CONTROL1 = 0;
-       TIMER_CONTROL2 = 0;
-       TIMER_CONTROL3 = 0;
-
-       timer_irq.handler = lh7a40x_timer_interrupt;
-       timer_irq.flags |= SA_INTERRUPT;
-       setup_irq (TIMER_IRQ, &timer_irq);
-
-       TIMER_LOAD = TIMER_CONSTANT;
-       TIMER_CONTROL = TIMER_MODE;
-}
-
diff --git a/include/asm-arm/arch-nexuspci/dma.h b/include/asm-arm/arch-nexuspci/dma.h
deleted file mode 100644 (file)
index dee1ea2..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/dma.h
- *
- * Architecture DMA routines
- *
- * Copyright (C) 1998, 1999 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * This is the maximum DMA address that can be DMAd to.
- */
-#define MAX_DMA_ADDRESS                0xffffffff
-#define MAX_DMA_CHANNELS       0
diff --git a/include/asm-arm/arch-nexuspci/hardware.h b/include/asm-arm/arch-nexuspci/hardware.h
deleted file mode 100644 (file)
index 303dc2c..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/hardware.h
- *
- * Copyright (C) 1998, 1999, 2000 FutureTV Labs Ltd.
- *
- * This file contains the hardware definitions of the FTV PCI card.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-/*    Logical    Physical
- * 0xffe00000  0x20000000      INTCONT
- * 0xffd00000  0x30000000      Status
- * 0xffc00000  0x60000000      PLX registers
- * 0xfe000000  0xC0000000      PCI I/O
- * 0xfd000000  0x70000000      cache flush
- * 0xfc000000  0x80000000      PCI/ISA memory
- * 0xe0000000  0x10000000      SCC2691 DUART
- */
-
-/*
- * Mapping areas
- */
-#define INTCONT_BASE           0xffe00000
-#define STATUS_BASE            0xffd00000
-#define PLX_BASE               0xffc00000
-#define PCIO_BASE              0xfe000000
-#define FLUSH_BASE             0xfd000000
-#define DUART_BASE             0xe0000000
-#define PCIMEM_BASE            0xfc000000
-
-#define PLX_IO_START           0xC0000000
-#define PLX_MEM_START          0x80000000
-#define PLX_START              0x60000000
-#define STATUS_START           0x30000000
-#define INTCONT_START          0x20000000
-#define DUART_START            0x10000000
-
-/*
- * RAM definitions
- */
-#define RAM_BASE               0x40000000
-#define FLUSH_BASE_PHYS                0x70000000
-
-/*
- * Miscellaneous INTCONT bits
- */
-#define INTCONT_FIQ_PLX                0x00
-#define INTCONT_FIQ_D          0x02
-#define INTCONT_FIQ_C          0x04
-#define INTCONT_FIQ_B          0x06
-#define INTCONT_FIQ_A          0x08
-#define INTCONT_FIQ_SYSERR     0x0a
-#define INTCONT_IRQ_DUART      0x0c
-#define INTCONT_IRQ_PLX                0x0e
-#define INTCONT_IRQ_D          0x10
-#define INTCONT_IRQ_C          0x12
-#define INTCONT_IRQ_B          0x14
-#define INTCONT_IRQ_A          0x16
-#define INTCONT_IRQ_SYSERR     0x1e
-
-#define INTCONT_WATCHDOG       0x18
-#define INTCONT_LED            0x1a
-#define INTCONT_PCI_RESET      0x1c
-
-#define UNCACHEABLE_ADDR       STATUS_BASE
-
-#endif
diff --git a/include/asm-arm/arch-nexuspci/ide.h b/include/asm-arm/arch-nexuspci/ide.h
deleted file mode 100644 (file)
index 5514808..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/ide.h
- *
- * Copyright (c) 1998 Russell King
- *
- * Modifications:
- *  29-07-1998 RMK     Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += 1;
-       }
-       hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-       if (irq)
-               *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void ide_init_default_hwifs(void)
-{
-       /* There are no standard ports */
-}
diff --git a/include/asm-arm/arch-nexuspci/io.h b/include/asm-arm/arch-nexuspci/io.h
deleted file mode 100644 (file)
index 181bdb5..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/io.h
- *
- * Copyright (C) 1997-1999 Russell King
- * Copyright (C) 2000 FutureTV Labs Ltd.
- */
-#ifndef __ASM_ARM_ARCH_IO_H
-#define __ASM_ARM_ARCH_IO_H
-
-#define IO_SPACE_LIMIT 0xffff
-
-/*
- * Translation of various region addresses to virtual addresses
- */
-#define __io(a)                        (PCIO_BASE + (a))
-#if 1
-#define __mem_pci(a)           ((unsigned long)(a))
-#define __mem_isa(a)           (PCIMEM_BASE + (unsigned long)(a))
-#else
-
-static inline unsigned long ___mem_pci(unsigned long a)
-{
-       /* PCI addresses must have been ioremapped */
-       if (a <= 0xc0000000 || a >= 0xe0000000)
-               *((int *)0) = 0;
-       return a;
-}
-
-static inline unsigned long ___mem_isa(unsigned long a)
-{
-       BUG_ON(a >= 16*1048576);
-       return PCIMEM_BASE + a;
-}
-#define __mem_pci(a)           ___mem_pci((unsigned long)(a))
-#define __mem_isa(a)           ___mem_isa((unsigned long)(a))
-#endif
-
-/*
- * ioremap support - validate a PCI memory address,
- * and convert a PCI memory address to a physical
- * address for the page tables.
- */
-#define iomem_valid_addr(iomem,sz)     \
-       ((iomem) < 0x80000000 && (iomem) + (sz) <= 0x80000000)
-#define iomem_to_phys(iomem)   ((iomem) + PLX_MEM_START)
-
-#define __arch_ioremap(off,sz,nocache)                         \
- ({                                                            \
-       unsigned long _off = (off), _size = (sz);               \
-       void *_ret = (void *)0;                                 \
-       if (iomem_valid_addr(_off, _size))                      \
-               _ret = __ioremap(iomem_to_phys(_off),_size,0);  \
-       _ret;                                                   \
- })
-
-#define __arch_iounmap __iounmap
-
-#endif
diff --git a/include/asm-arm/arch-nexuspci/irqs.h b/include/asm-arm/arch-nexuspci/irqs.h
deleted file mode 100644 (file)
index 006c14b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/irqs.h
- *
- * Copyright (C) 1997, 1998, 2000 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * The hardware is capable of routing any interrupt source (except the
- * DUART) to either IRQ or FIQ.  We ignore FIQ and use IRQ exclusively
- * for simplicity.  
- */
-
-#define IRQ_DUART              0
-#define IRQ_PLX                1
-#define IRQ_PCI_D              2
-#define IRQ_PCI_C              3
-#define IRQ_PCI_B              4
-#define IRQ_PCI_A              5
-#define IRQ_SYSERR             6       /* only from IOSLAVE rev B */
-
-#define FIRST_IRQ              IRQ_DUART
-#define LAST_IRQ               IRQ_SYSERR
-
-/* timer is part of the DUART */
-#define IRQ_TIMER              IRQ_DUART
-
-#define irq_canonicalize(i)    (i)
diff --git a/include/asm-arm/arch-nexuspci/memory.h b/include/asm-arm/arch-nexuspci/memory.h
deleted file mode 100644 (file)
index 85d7c45..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/memory.h
- *
- * Copyright (c) 1997, 1998, 2000 FutureTV Labs Ltd.
- * Copyright (c) 1999 Russell King
- *
- */
-#ifndef __ASM_ARCH_MEMORY_H
-#define __ASM_ARCH_MEMORY_H
-
-/*
- * Physical DRAM offset.
- */
-#define PHYS_OFFSET    (0x40000000UL)
-#define BUS_OFFSET     (0xe0000000UL)
-
-/*
- * On the PCI bus the DRAM appears at address 0xe0000000
- */
-#define __virt_to_bus(x) ((unsigned long)(x) - PAGE_OFFSET + BUS_OFFSET)
-#define __bus_to_virt(x) ((unsigned long)(x) + PAGE_OFFSET - BUS_OFFSET)
-
-#endif
diff --git a/include/asm-arm/arch-nexuspci/param.h b/include/asm-arm/arch-nexuspci/param.h
deleted file mode 100644 (file)
index d57753d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-nexuspci/param.h
- */
diff --git a/include/asm-arm/arch-nexuspci/system.h b/include/asm-arm/arch-nexuspci/system.h
deleted file mode 100644 (file)
index 824a1d7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/system.h
- *
- * Copyright (c) 1996, 97, 98, 99, 2000 FutureTV Labs Ltd.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#ifndef __ASM_ARCH_SYSTEM_H
-#define __ASM_ARCH_SYSTEM_H
-
-static inline void arch_idle(void)
-{
-       cpu_do_idle();
-}
-
-#define arch_reset(mode)       do { } while (0)
-
-#endif
diff --git a/include/asm-arm/arch-nexuspci/time.h b/include/asm-arm/arch-nexuspci/time.h
deleted file mode 100644 (file)
index c0fd0cd..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/time.h
- *
- * Copyright (c) 1997, 1998, 1999, 2000 FutureTV Labs Ltd.
- *
- * The FTV PCI card has no real-time clock.  We get timer ticks from the
- * SCC chip.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       static int count = 25;
-       unsigned char stat = __raw_readb(DUART_BASE + 0x14);
-       if (!(stat & 0x10))
-               return;         /* Not for us */
-
-       /* Reset counter */
-       __raw_writeb(0x90, DUART_BASE + 8);
-
-       if (--count == 0) {
-               static int state = 1;
-               state ^= 1;
-               __raw_writeb(0x1a + state, INTCONT_BASE);
-               __raw_writeb(0x18 + state, INTCONT_BASE);
-               count = 50;
-       }
-
-       /* Wait for slow rise time */
-       __raw_readb(DUART_BASE + 0x14);
-       __raw_readb(DUART_BASE + 0x14);
-       __raw_readb(DUART_BASE + 0x14);
-       __raw_readb(DUART_BASE + 0x14);
-       __raw_readb(DUART_BASE + 0x14);
-       __raw_readb(DUART_BASE + 0x14);
-
-       do_timer(regs);
-
-       return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
-       int tick = 3686400 / 16 / 2 / 100;
-
-       __raw_writeb(tick & 0xff, DUART_BASE + 0x1c);
-       __raw_writeb(tick >> 8, DUART_BASE + 0x18);
-       __raw_writeb(0x80, DUART_BASE + 8);
-       __raw_writeb(0x10, DUART_BASE + 0x14);
-
-       timer_irq.handler = timer_interrupt;
-       timer_irq.flags = SA_SHIRQ;
-
-       setup_irq(IRQ_TIMER, &timer_irq);
-}
diff --git a/include/asm-arm/arch-nexuspci/timex.h b/include/asm-arm/arch-nexuspci/timex.h
deleted file mode 100644 (file)
index 63d4e2c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/timex.h
- *
- * NexusPCI StrongARM card timex specifications
- *
- * Copyright (C) 1998 Philip Blundell
- */
-
diff --git a/include/asm-arm/arch-nexuspci/uncompress.h b/include/asm-arm/arch-nexuspci/uncompress.h
deleted file mode 100644 (file)
index dd697a9..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/uncompress.h
- *
- * Copyright (C) 1998, 1999, 2000 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-
-/*
- * Write a character to the UART
- */
-void _ll_write_char(char c)
-{
-       while (!(__raw_readb(DUART_START + 0x4) & 0x4))
-               ;
-       __raw_writeb(c, DUART_START + 0xc);
-}
-
-/*
- * This does not append a newline
- */
-static void puts(const char *s)
-{
-       while (*s) {
-               if (*s == '\n')
-                       _ll_write_char('\r');
-               _ll_write_char(*(s++));
-       }
-}
-
-/*
- * Set up for decompression
- */
-static void arch_decomp_setup(void)
-{
-       /* LED off */
-       __raw_writel(INTCONT_LED, INTCONT_START);
-
-       /* Set up SCC */
-       __raw_writeb(42, DUART_START + 8);
-       __raw_writeb(48, DUART_START + 8);
-       __raw_writeb(16, DUART_START + 8);
-       __raw_writeb(0x93, DUART_START);
-       __raw_writeb(0x17, DUART_START);
-       __raw_writeb(0xbb, DUART_START + 4);
-       __raw_writeb(0x78, DUART_START + 16);
-       __raw_writeb(0xa0, DUART_START + 8);
-       __raw_writeb(5, DUART_START + 8);
-}
-
-/*
- * Stroke the watchdog so we don't get reset during decompression.
- */
-static inline void arch_decomp_wdog(void)
-{
-       __raw_writel(INTCONT_WATCHDOG, INTCONT_START);
-       __raw_writel(INTCONT_WATCHDOG | 1, INTCONT_START);
-}
diff --git a/include/asm-arm/arch-nexuspci/vmalloc.h b/include/asm-arm/arch-nexuspci/vmalloc.h
deleted file mode 100644 (file)
index 7e93df2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/vmalloc.h
- */
-
-/*
- * Just any arbitrary offset to the start of the vmalloc VM area: the
- * current 8MB value just means that there will be a 8MB "hole" after the
- * physical memory until the kernel virtual memory starts.  That means that
- * any out-of-bounds memory accesses will hopefully be caught.
- * The vmalloc() routines leaves a hole of 4kB between each vmalloced
- * area for the same reason. ;)
- */
-#define VMALLOC_OFFSET   (8*1024*1024)
-#define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
-#define VMALLOC_END       (PAGE_OFFSET + 0x20000000)
diff --git a/include/asm-arm/arch-omap/omap-h2.h b/include/asm-arm/arch-omap/omap-h2.h
deleted file mode 100644 (file)
index 9eeb892..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * linux/include/asm-arm/arch-omap/omap-h2.h
- *
- * Hardware definitions for TI OMAP1610 H2 board.
- *
- * Cleanup for Linux-2.6 by Dirk Behme <dirk.behme@de.bosch.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * You should have received a copy of the  GNU General Public License along
- * with this program; if not, write  to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __ASM_ARCH_OMAP_H2_H
-#define __ASM_ARCH_OMAP_H2_H
-
-/* Placeholder for H2 specific defines */
-
-#endif /*  __ASM_ARCH_OMAP_H2_H */
-
diff --git a/include/asm-arm/arch-omap/omap-innovator.h b/include/asm-arm/arch-omap/omap-innovator.h
deleted file mode 100644 (file)
index ccdc313..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * linux/include/asm-arm/arch-omap/omap-innovator.h
- *
- * Copyright (C) 2001 RidgeRun, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * You should have received a copy of the  GNU General Public License along
- * with this program; if not, write  to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#ifndef __ASM_ARCH_OMAP_INNOVATOR_H
-#define __ASM_ARCH_OMAP_INNOVATOR_H
-
-#if defined (CONFIG_ARCH_OMAP1510)
-
-/*
- * ---------------------------------------------------------------------------
- *  OMAP-1510 FPGA
- * ---------------------------------------------------------------------------
- */
-#define OMAP1510P1_FPGA_BASE                   0xE8000000      /* Virtual */
-#define OMAP1510P1_FPGA_SIZE                   SZ_4K
-#define OMAP1510P1_FPGA_START                  0x08000000      /* Physical */
-
-/* Revision */
-#define OMAP1510P1_FPGA_REV_LOW                        (OMAP1510P1_FPGA_BASE + 0x0)
-#define OMAP1510P1_FPGA_REV_HIGH               (OMAP1510P1_FPGA_BASE + 0x1)
-
-#define OMAP1510P1_FPGA_LCD_PANEL_CONTROL      (OMAP1510P1_FPGA_BASE + 0x2)
-#define OMAP1510P1_FPGA_LED_DIGIT              (OMAP1510P1_FPGA_BASE + 0x3)
-#define INNOVATOR_FPGA_HID_SPI                 (OMAP1510P1_FPGA_BASE + 0x4)
-#define OMAP1510P1_FPGA_POWER                  (OMAP1510P1_FPGA_BASE + 0x5)
-
-/* Interrupt status */
-#define OMAP1510P1_FPGA_ISR_LO                 (OMAP1510P1_FPGA_BASE + 0x6)
-#define OMAP1510P1_FPGA_ISR_HI                 (OMAP1510P1_FPGA_BASE + 0x7)
-
-/* Interrupt mask */
-#define OMAP1510P1_FPGA_IMR_LO                 (OMAP1510P1_FPGA_BASE + 0x8)
-#define OMAP1510P1_FPGA_IMR_HI                 (OMAP1510P1_FPGA_BASE + 0x9)
-
-/* Reset registers */
-#define OMAP1510P1_FPGA_HOST_RESET             (OMAP1510P1_FPGA_BASE + 0xa)
-#define OMAP1510P1_FPGA_RST                    (OMAP1510P1_FPGA_BASE + 0xb)
-
-#define OMAP1510P1_FPGA_AUDIO                  (OMAP1510P1_FPGA_BASE + 0xc)
-#define OMAP1510P1_FPGA_DIP                    (OMAP1510P1_FPGA_BASE + 0xe)
-#define OMAP1510P1_FPGA_FPGA_IO                        (OMAP1510P1_FPGA_BASE + 0xf)
-#define OMAP1510P1_FPGA_UART1                  (OMAP1510P1_FPGA_BASE + 0x14)
-#define OMAP1510P1_FPGA_UART2                  (OMAP1510P1_FPGA_BASE + 0x15)
-#define OMAP1510P1_FPGA_OMAP1510_STATUS                (OMAP1510P1_FPGA_BASE + 0x16)
-#define OMAP1510P1_FPGA_BOARD_REV              (OMAP1510P1_FPGA_BASE + 0x18)
-#define OMAP1510P1_PPT_DATA                    (OMAP1510P1_FPGA_BASE + 0x100)
-#define OMAP1510P1_PPT_STATUS                  (OMAP1510P1_FPGA_BASE + 0x101)
-#define OMAP1510P1_PPT_CONTROL                 (OMAP1510P1_FPGA_BASE + 0x102)
-
-#define OMAP1510P1_FPGA_TOUCHSCREEN            (OMAP1510P1_FPGA_BASE + 0x204)
-
-#define INNOVATOR_FPGA_INFO                    (OMAP1510P1_FPGA_BASE + 0x205)
-#define INNOVATOR_FPGA_LCD_BRIGHT_LO           (OMAP1510P1_FPGA_BASE + 0x206)
-#define INNOVATOR_FPGA_LCD_BRIGHT_HI           (OMAP1510P1_FPGA_BASE + 0x207)
-#define INNOVATOR_FPGA_LED_GRN_LO              (OMAP1510P1_FPGA_BASE + 0x208)
-#define INNOVATOR_FPGA_LED_GRN_HI              (OMAP1510P1_FPGA_BASE + 0x209)
-#define INNOVATOR_FPGA_LED_RED_LO              (OMAP1510P1_FPGA_BASE + 0x20a)
-#define INNOVATOR_FPGA_LED_RED_HI              (OMAP1510P1_FPGA_BASE + 0x20b)
-#define INNOVATOR_FPGA_CAM_USB_CONTROL         (OMAP1510P1_FPGA_BASE + 0x20c)
-#define INNOVATOR_FPGA_EXP_CONTROL             (OMAP1510P1_FPGA_BASE + 0x20d)
-#define INNOVATOR_FPGA_ISR2                    (OMAP1510P1_FPGA_BASE + 0x20e)
-#define INNOVATOR_FPGA_IMR2                    (OMAP1510P1_FPGA_BASE + 0x210)
-
-#define OMAP1510P1_FPGA_ETHR_START             (OMAP1510P1_FPGA_START + 0x300)
-#define OMAP1510P1_FPGA_ETHR_BASE              (OMAP1510P1_FPGA_BASE + 0x300)
-
-/*
- * Power up Giga UART driver, turn on HID clock.
- * Turn off BT power, since we're not using it and it
- * draws power.
- */
-#define OMAP1510P1_FPGA_RESET_VALUE            0x42
-
-#define OMAP1510P1_FPGA_PCR_IF_PD0             (1 << 7)
-#define OMAP1510P1_FPGA_PCR_COM2_EN            (1 << 6)
-#define OMAP1510P1_FPGA_PCR_COM1_EN            (1 << 5)
-#define OMAP1510P1_FPGA_PCR_EXP_PD0            (1 << 4)
-#define OMAP1510P1_FPGA_PCR_EXP_PD1            (1 << 3)
-#define OMAP1510P1_FPGA_PCR_48MHZ_CLK          (1 << 2)
-#define OMAP1510P1_FPGA_PCR_4MHZ_CLK           (1 << 1)
-#define OMAP1510P1_FPGA_PCR_RSRVD_BIT0         (1 << 0)
-
-/*
- * Innovator/OMAP1510 FPGA HID register bit definitions
- */
-#define FPGA_HID_SCLK  (1<<0)  /* output */
-#define FPGA_HID_MOSI  (1<<1)  /* output */
-#define FPGA_HID_nSS   (1<<2)  /* output 0/1 chip idle/select */
-#define FPGA_HID_nHSUS (1<<3)  /* output 0/1 host active/suspended */
-#define FPGA_HID_MISO  (1<<4)  /* input */
-#define FPGA_HID_ATN   (1<<5)  /* input  0/1 chip idle/ATN */
-#define FPGA_HID_rsrvd (1<<6)
-#define FPGA_HID_RESETn (1<<7) /* output - 0/1 USAR reset/run */
-
-#ifndef OMAP_SDRAM_DEVICE
-#define OMAP_SDRAM_DEVICE                      D256M_1X16_4B
-#endif
-
-#define OMAP1510P1_IMIF_PRI_VALUE              0x00
-#define OMAP1510P1_EMIFS_PRI_VALUE             0x00
-#define OMAP1510P1_EMIFF_PRI_VALUE             0x00
-
-/*
- * These definitions define an area of FLASH set aside
- * for the use of MTD/JFFS2. This is the area of flash
- * that a JFFS2 filesystem will reside which is mounted
- * at boot with the "root=/dev/mtdblock/0 rw"
- * command line option. The flash address used here must
- * fall within the legal range defined by rrload for storing
- * the filesystem component. This address will be sufficiently
- * deep into the overall flash range to avoid the other
- * components also stored in flash such as the bootloader,
- * the bootloader params, and the kernel.
- * The SW2 settings for the map below are:
- * 1 off, 2 off, 3 on, 4 off.
- */
-
-/* Intel flash_0, partitioned as expected by rrload */
-#define OMAP_FLASH_0_BASE      0xD8000000
-#define OMAP_FLASH_0_START     0x00000000
-#define OMAP_FLASH_0_SIZE      SZ_16M
-
-/* Intel flash_1, used for cramfs or other flash file systems */
-#define OMAP_FLASH_1_BASE      0xD9000000
-#define OMAP_FLASH_1_START     0x01000000
-#define OMAP_FLASH_1_SIZE      SZ_16M
-
-/* The FPGA IRQ is cascaded through GPIO_13 */
-#define INT_FPGA               (IH_GPIO_BASE + 13)
-
-/* IRQ Numbers for interrupts muxed through the FPGA */
-#define IH_FPGA_BASE           IH_BOARD_BASE
-#define INT_FPGA_ATN           (IH_FPGA_BASE + 0)
-#define INT_FPGA_ACK           (IH_FPGA_BASE + 1)
-#define INT_FPGA2              (IH_FPGA_BASE + 2)
-#define INT_FPGA3              (IH_FPGA_BASE + 3)
-#define INT_FPGA4              (IH_FPGA_BASE + 4)
-#define INT_FPGA5              (IH_FPGA_BASE + 5)
-#define INT_FPGA6              (IH_FPGA_BASE + 6)
-#define INT_FPGA7              (IH_FPGA_BASE + 7)
-#define INT_FPGA8              (IH_FPGA_BASE + 8)
-#define INT_FPGA9              (IH_FPGA_BASE + 9)
-#define INT_FPGA10             (IH_FPGA_BASE + 10)
-#define INT_FPGA11             (IH_FPGA_BASE + 11)
-#define INT_FPGA12             (IH_FPGA_BASE + 12)
-#define INT_ETHER              (IH_FPGA_BASE + 13)
-#define INT_FPGAUART1          (IH_FPGA_BASE + 14)
-#define INT_FPGAUART2          (IH_FPGA_BASE + 15)
-#define INT_FPGA_TS            (IH_FPGA_BASE + 16)
-#define INT_FPGA17             (IH_FPGA_BASE + 17)
-#define INT_FPGA_CAM           (IH_FPGA_BASE + 18)
-#define INT_FPGA_RTC_A         (IH_FPGA_BASE + 19)
-#define INT_FPGA_RTC_B         (IH_FPGA_BASE + 20)
-#define INT_FPGA_CD            (IH_FPGA_BASE + 21)
-#define INT_FPGA22             (IH_FPGA_BASE + 22)
-#define INT_FPGA23             (IH_FPGA_BASE + 23)
-
-#define NR_FPGA_IRQS            24
-
-#define MAXIRQNUM              (IH_FPGA_BASE + NR_FPGA_IRQS - 1)
-#define MAXFIQNUM              MAXIRQNUM
-#define MAXSWINUM              MAXIRQNUM
-
-#define NR_IRQS                        256
-
-#ifndef __ASSEMBLY__
-void fpga_write(unsigned char val, int reg);
-unsigned char fpga_read(int reg);
-#endif
-
-#elif defined (CONFIG_ARCH_OMAP1610)
-
-/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
-#define OMAP1610_ETHR_BASE             0xE8000000
-#define OMAP1610_ETHR_SIZE             SZ_4K
-#define OMAP1610_ETHR_START            0x04000000
-
-/* Intel STRATA NOR flash at CS3 */
-#define OMAP1610_NOR_FLASH_BASE                0xD8000000
-#define OMAP1610_NOR_FLASH_SIZE                SZ_32M
-#define OMAP1610_NOR_FLASH_START       0x0C000000
-
-#define MAXIRQNUM                      (IH_BOARD_BASE)
-#define MAXFIQNUM                      MAXIRQNUM
-#define MAXSWINUM                      MAXIRQNUM
-
-#define NR_IRQS                                (MAXIRQNUM + 1)
-
-#else
-#error "Only OMAP1510 and OMAP1610 Innovator supported!"
-#endif
-#endif
diff --git a/include/asm-arm/arch-omap/omap-perseus2.h b/include/asm-arm/arch-omap/omap-perseus2.h
deleted file mode 100644 (file)
index 41fa2dd..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-omap/omap-perseus2.h
- *
- *  Copyright 2003 by Texas Instruments Incorporated
- *    OMAP730 / P2-sample additions
- *    Author: Jean Pihet
- *
- * Copyright (C) 2001 RidgeRun, Inc. (http://www.ridgerun.com)
- * Author: RidgeRun, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#ifndef __ASM_ARCH_OMAP_P2SAMPLE_H
-#define __ASM_ARCH_OMAP_P2SAMPLE_H
-
-#if defined(CONFIG_ARCH_OMAP730) && defined (CONFIG_MACH_OMAP_PERSEUS2)
-
-/*
- * NOTE:  ALL DEFINITIONS IN THIS FILE NEED TO BE PREFIXED BY IDENTIFIER
- *       P2SAMPLE_ since they are specific to the EVM and not the chip.
- */
-
-/* ---------------------------------------------------------------------------
- *  OMAP730 Debug Board FPGA
- * ---------------------------------------------------------------------------
- *
- */
-
-/* maps in the FPGA registers and the ETHR registers */
-#define OMAP730_FPGA_BASE              0xE8000000      /* VA */
-#define OMAP730_FPGA_SIZE              SZ_4K           /* SIZE */
-#define OMAP730_FPGA_START             0x04000000      /* PA */
-
-#define OMAP730_FPGA_ETHR_START                OMAP730_FPGA_START
-#define OMAP730_FPGA_ETHR_BASE         OMAP730_FPGA_BASE
-#define OMAP730_FPGA_FPGA_REV          (OMAP730_FPGA_BASE + 0x10)      /* FPGA Revision */
-#define OMAP730_FPGA_BOARD_REV         (OMAP730_FPGA_BASE + 0x12)      /* Board Revision */
-#define OMAP730_FPGA_GPIO              (OMAP730_FPGA_BASE + 0x14)      /* GPIO outputs */
-#define OMAP730_FPGA_LEDS              (OMAP730_FPGA_BASE + 0x16)      /* LEDs outputs */
-#define OMAP730_FPGA_MISC_INPUTS       (OMAP730_FPGA_BASE + 0x18)      /* Misc inputs */
-#define OMAP730_FPGA_LAN_STATUS                (OMAP730_FPGA_BASE + 0x1A)      /* LAN Status line */
-#define OMAP730_FPGA_LAN_RESET         (OMAP730_FPGA_BASE + 0x1C)      /* LAN Reset line */
-
-// LEDs definition on debug board (16 LEDs)
-#define OMAP730_FPGA_LED_CLAIMRELEASE  (1 << 15)
-#define OMAP730_FPGA_LED_STARTSTOP     (1 << 14)
-#define OMAP730_FPGA_LED_HALTED                (1 << 13)
-#define OMAP730_FPGA_LED_IDLE          (1 << 12)
-#define OMAP730_FPGA_LED_TIMER         (1 << 11)
-// cpu0 load-meter LEDs
-#define OMAP730_FPGA_LOAD_METER                (1 << 0)        // A bit of fun on our board ...
-#define OMAP730_FPGA_LOAD_METER_SIZE   11
-#define OMAP730_FPGA_LOAD_METER_MASK   ((1 << OMAP730_FPGA_LOAD_METER_SIZE) - 1)
-
-#ifndef OMAP_SDRAM_DEVICE
-#define OMAP_SDRAM_DEVICE              D256M_1X16_4B
-#endif
-
-
-/*
- * These definitions define an area of FLASH set aside
- * for the use of MTD/JFFS2. This is the area of flash
- * that a JFFS2 filesystem will reside which is mounted
- * at boot with the "root=/dev/mtdblock/0 rw"
- * command line option.
- */
-
-/* Intel flash_0, partitioned as expected by rrload */
-#define OMAP_FLASH_0_BASE      0xD8000000      /* VA */
-#define OMAP_FLASH_0_START     0x00000000      /* PA */
-#define OMAP_FLASH_0_SIZE      SZ_32M
-
-/* 2.9.6 Traffic Controller Memory Interface Registers */
-#define OMAP_FLASH_CFG_0               0xfffecc10
-#define OMAP_FLASH_ACFG_0              0xfffecc50
-
-#define OMAP_FLASH_CFG_1               0xfffecc14
-#define OMAP_FLASH_ACFG_1              0xfffecc54
-
-/*
- * Configuration Registers
- */
-#define PERSEUS2_CONFIG_BASE      0xfffe1000
-#define PERSEUS2_IO_CONF_0        0xfffe1070
-#define PERSEUS2_IO_CONF_1        0xfffe1074
-#define PERSEUS2_IO_CONF_2        0xfffe1078
-#define PERSEUS2_IO_CONF_3        0xfffe107c
-#define PERSEUS2_IO_CONF_4        0xfffe1080
-#define PERSEUS2_IO_CONF_5        0xfffe1084
-#define PERSEUS2_IO_CONF_6        0xfffe1088
-#define PERSEUS2_IO_CONF_7        0xfffe108c
-#define PERSEUS2_IO_CONF_8        0xfffe1090
-#define PERSEUS2_IO_CONF_9        0xfffe1094
-#define PERSEUS2_IO_CONF_10       0xfffe1098
-#define PERSEUS2_IO_CONF_11       0xfffe109c
-#define PERSEUS2_IO_CONF_12       0xfffe10a0
-#define PERSEUS2_IO_CONF_13       0xfffe10a4
-
-#define PERSEUS2_MODE_1                   0xfffe1010
-#define PERSEUS2_MODE_2                   0xfffe1014
-
-/* CSMI specials: in terms of base + offset */
-#define PERSEUS2_MODE2_OFFSET     0x14
-
-/* DSP control: ICR registers */
-#define ICR_BASE               0xfffbb800
-/* M_CTL */
-#define DSP_M_CTL              ((volatile __u16 *)0xfffbb804)
-/* DSP control: MMU registers */
-#define DSP_MMU_BASE           ((volatile __u16 *)0xfffed200)
-
-/* The Ethernet Controller IRQ is cascaded to MPU_EXT_nIRQ througb the FPGA */
-#define INT_ETHER              INT_730_MPU_EXT_NIRQ
-
-#define MAXIRQNUM              IH_BOARD_BASE
-#define MAXFIQNUM              MAXIRQNUM
-#define MAXSWINUM              MAXIRQNUM
-
-#define NR_IRQS                        (MAXIRQNUM + 1)
-
-#ifndef __ASSEMBLY__
-void fpga_write(unsigned char val, int reg);
-unsigned char fpga_read(int reg);
-#endif
-
-/* PCC_UPLD control register: OMAP730 */
-#define PCC_UPLD_CTRL_REG_BASE (0xfffe0900)
-#define PCC_UPLD_CTRL_REG      (volatile __u16 *)(PCC_UPLD_CTRL_REG_BASE + 0x00)
-
-#else
-#error "Only OMAP730 Perseus2 supported!"
-#endif
-
-#endif
diff --git a/include/asm-arm/arch-omap/time.h b/include/asm-arm/arch-omap/time.h
deleted file mode 100644 (file)
index 85d4812..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * linux/include/asm-arm/arch-omap/time.h
- *
- * 32kHz timer definition
- *
- * Copyright (C) 2000 RidgeRun, Inc.
- * Author: Greg Lonnon <glonnon@ridgerun.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * You should have received a copy of the  GNU General Public License along
- * with this program; if not, write  to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#if !defined(__ASM_ARCH_OMAP_TIME_H)
-#define __ASM_ARCH_OMAP_TIME_H
-
-#include <linux/config.h>
-#include <linux/delay.h>
-#include <asm/system.h>
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/leds.h>
-#include <asm/irq.h>
-#include <asm/mach/irq.h>
-#include <asm/arch/clocks.h>
-
-#ifndef __instrument
-#define __instrument
-#define __noinstrument __attribute__ ((no_instrument_function))
-#endif
-
-typedef struct {
-       u32 cntl;     /* CNTL_TIMER, R/W */
-       u32 load_tim; /* LOAD_TIM,   W */
-       u32 read_tim; /* READ_TIM,   R */
-} mputimer_regs_t;
-
-#define mputimer_base(n) \
-    ((volatile mputimer_regs_t*)IO_ADDRESS(OMAP_MPUTIMER_BASE + \
-                                (n)*OMAP_MPUTIMER_OFFSET))
-
-static inline unsigned long timer32k_read(int reg) {
-       unsigned long val;
-       val = omap_readw(reg + OMAP_32kHz_TIMER_BASE);
-       return val;
-}
-static inline void timer32k_write(int reg,int val) {
-       omap_writew(val, reg + OMAP_32kHz_TIMER_BASE);
-}
-
-/*
- * How long is the timer interval? 100 HZ, right...
- * IRQ rate = (TVR + 1) / 32768 seconds
- * TVR = 32768 * IRQ_RATE -1
- * IRQ_RATE =  1/100
- * TVR = 326
- */
-#define TIMER32k_PERIOD 326
-//#define TIMER32k_PERIOD 0x7ff
-
-static inline void start_timer32k(void) {
-       timer32k_write(TIMER32k_CR,
-                      TIMER32k_TSS | TIMER32k_TRB |
-                      TIMER32k_INT | TIMER32k_ARL);
-}
-
-#ifdef CONFIG_MACH_OMAP_PERSEUS2
-/*
- * After programming PTV with 0 and setting the MPUTIM_CLOCK_ENABLE
- * (external clock enable)  bit, the timer count rate is 6.5 MHz (13
- * MHZ input/2). !! The divider by 2 is undocumented !!
- */
-#define MPUTICKS_PER_SEC (13000000/2)
-#else
-/*
- * After programming PTV with 0, the timer count rate is 6 MHz.
- * WARNING! this must be an even number, or machinecycles_to_usecs
- * below will break.
- */
-#define MPUTICKS_PER_SEC  (12000000/2)
-#endif
-
-static int mputimer_started[3] = {0,0,0};
-
-static inline void __noinstrument start_mputimer(int n,
-                                                unsigned long load_val)
-{
-       volatile mputimer_regs_t* timer = mputimer_base(n);
-
-       mputimer_started[n] = 0;
-       timer->cntl = MPUTIM_CLOCK_ENABLE;
-       udelay(1);
-
-       timer->load_tim = load_val;
-        udelay(1);
-       timer->cntl = (MPUTIM_CLOCK_ENABLE | MPUTIM_AR | MPUTIM_ST);
-       mputimer_started[n] = 1;
-}
-
-static inline unsigned long __noinstrument
-read_mputimer(int n)
-{
-       volatile mputimer_regs_t* timer = mputimer_base(n);
-       return (mputimer_started[n] ? timer->read_tim : 0);
-}
-
-void __noinstrument start_mputimer1(unsigned long load_val)
-{
-       start_mputimer(0, load_val);
-}
-void __noinstrument start_mputimer2(unsigned long load_val)
-{
-       start_mputimer(1, load_val);
-}
-void __noinstrument start_mputimer3(unsigned long load_val)
-{
-       start_mputimer(2, load_val);
-}
-
-unsigned long __noinstrument read_mputimer1(void)
-{
-       return read_mputimer(0);
-}
-unsigned long __noinstrument read_mputimer2(void)
-{
-       return read_mputimer(1);
-}
-unsigned long __noinstrument read_mputimer3(void)
-{
-       return read_mputimer(2);
-}
-
-unsigned long __noinstrument do_getmachinecycles(void)
-{
-       return 0 - read_mputimer(0);
-}
-
-unsigned long __noinstrument machinecycles_to_usecs(unsigned long mputicks)
-{
-       /* Round up to nearest usec */
-       return ((mputicks * 1000) / (MPUTICKS_PER_SEC / 2 / 1000) + 1) >> 1;
-}
-
-/*
- * This marks the time of the last system timer interrupt
- * that was *processed by the ISR* (timer 2).
- */
-static unsigned long systimer_mark;
-
-static unsigned long omap1510_gettimeoffset(void)
-{
-       /* Return elapsed usecs since last system timer ISR */
-       return machinecycles_to_usecs(do_getmachinecycles() - systimer_mark);
-}
-
-static irqreturn_t
-omap1510_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       unsigned long now, ilatency;
-
-       /*
-        * Mark the time at which the timer interrupt ocurred using
-        * timer1. We need to remove interrupt latency, which we can
-        * retrieve from the current system timer2 counter. Both the
-        * offset timer1 and the system timer2 are counting at 6MHz,
-        * so we're ok.
-        */
-       now = 0 - read_mputimer1();
-       ilatency = MPUTICKS_PER_SEC / 100 - read_mputimer2();
-       systimer_mark = now - ilatency;
-
-       do_leds();
-       do_timer(regs);
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
-       /* Since we don't call request_irq, we must init the structure */
-       gettimeoffset = omap1510_gettimeoffset;
-
-       timer_irq.handler = omap1510_timer_interrupt;
-       timer_irq.flags = SA_INTERRUPT;
-#ifdef OMAP1510_USE_32KHZ_TIMER
-       timer32k_write(TIMER32k_CR, 0x0);
-       timer32k_write(TIMER32k_TVR,TIMER32k_PERIOD);
-       setup_irq(INT_OS_32kHz_TIMER, &timer_irq);
-       start_timer32k();
-#else
-       setup_irq(INT_TIMER2, &timer_irq);
-       start_mputimer2(MPUTICKS_PER_SEC / 100 - 1);
-#endif
-}
-
-#endif
diff --git a/include/asm-arm/arch-pxa/ide.h b/include/asm-arm/arch-pxa/ide.h
deleted file mode 100644 (file)
index a9efdce..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * linux/include/asm-arm/arch-pxa/ide.h
- *
- * Author:     George Davis
- * Created:    Jan 10, 2002
- * Copyright:  MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *
- * Originally based upon linux/include/asm-arm/arch-sa1100/ide.h
- *
- */
-
-#include <asm/irq.h>
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-       int regincr = 1;
-
-       memset(hw, 0, sizeof(*hw));
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += regincr;
-       }
-
-       hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-
-       if (irq)
-               *irq = 0;
-}
-
-
-/*
- * Register the standard ports for this architecture with the IDE driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
-       /* Nothing to declare... */
-}
diff --git a/include/asm-arm/arch-pxa/keyboard.h b/include/asm-arm/arch-pxa/keyboard.h
deleted file mode 100644 (file)
index 7bec317..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-pxa/keyboard.h
- *
- *  This file contains the architecture specific keyboard definitions
- */
-
-#ifndef _PXA_KEYBOARD_H
-#define _PXA_KEYBOARD_H
-
-#include <asm/mach-types.h>
-#include <asm/hardware.h>
-
-extern struct kbd_ops_struct *kbd_ops;
-
-#define kbd_disable_irq()      do { } while(0);
-#define kbd_enable_irq()       do { } while(0);
-
-extern int sa1111_kbd_init_hw(void);
-
-static inline void kbd_init_hw(void)
-{
-       if (machine_is_lubbock())
-               sa1111_kbd_init_hw();
-}
-
-
-#endif  /* _PXA_KEYBOARD_H */
-
diff --git a/include/asm-arm/arch-pxa/time.h b/include/asm-arm/arch-pxa/time.h
deleted file mode 100644 (file)
index bc9437a..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * linux/include/asm-arm/arch-pxa/time.h
- *
- * Author:     Nicolas Pitre
- * Created:    Jun 15, 2001
- * Copyright:  MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-
-static inline unsigned long pxa_get_rtc_time(void)
-{
-       return RCNR;
-}
-
-static int pxa_set_rtc(void)
-{
-       unsigned long current_time = xtime.tv_sec;
-
-       if (RTSR & RTSR_ALE) {
-               /* make sure not to forward the clock over an alarm */
-               unsigned long alarm = RTAR;
-               if (current_time >= alarm && alarm >= RCNR)
-                       return -ERESTARTSYS;
-       }
-       RCNR = current_time;
-       return 0;
-}
-
-/* IRQs are disabled before entering here from do_gettimeofday() */
-static unsigned long pxa_gettimeoffset (void)
-{
-       long ticks_to_match, elapsed, usec;
-
-       /* Get ticks before next timer match */
-       ticks_to_match = OSMR0 - OSCR;
-
-       /* We need elapsed ticks since last match */
-       elapsed = LATCH - ticks_to_match;
-
-       /* don't get fooled by the workaround in pxa_timer_interrupt() */
-       if (elapsed <= 0)
-               return 0;
-
-       /* Now convert them to usec */
-       usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
-
-       return usec;
-}
-
-static irqreturn_t
-pxa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       int next_match;
-
-       do_profile(regs);
-
-       /* Loop until we get ahead of the free running timer.
-        * This ensures an exact clock tick count and time accuracy.
-        * IRQs are disabled inside the loop to ensure coherence between
-        * lost_ticks (updated in do_timer()) and the match reg value, so we
-        * can use do_gettimeofday() from interrupt handlers.
-        *
-        * HACK ALERT: it seems that the PXA timer regs aren't updated right
-        * away in all cases when a write occurs.  We therefore compare with
-        * 8 instead of 0 in the while() condition below to avoid missing a
-        * match if OSCR has already reached the next OSMR value.
-        * Experience has shown that up to 6 ticks are needed to work around
-        * this problem, but let's use 8 to be conservative.  Note that this
-        * affect things only when the timer IRQ has been delayed by nearly
-        * exactly one tick period which should be a pretty rare event.
-        */
-       do {
-               do_leds();
-               do_set_rtc();
-               do_timer(regs);
-               OSSR = OSSR_M0;  /* Clear match on timer 0 */
-               next_match = (OSMR0 += LATCH);
-       } while( (signed long)(next_match - OSCR) <= 8 );
-
-       return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
-       struct timespec tv;
-
-       gettimeoffset = pxa_gettimeoffset;
-       set_rtc = pxa_set_rtc;
-
-       tv.tv_nsec = 0;
-       tv.tv_sec = pxa_get_rtc_time();
-       do_settimeofday(&tv);
-
-       timer_irq.handler = pxa_timer_interrupt;
-       OSMR0 = 0;              /* set initial match at 0 */
-       OSSR = 0xf;             /* clear status on all timers */
-       setup_irq(IRQ_OST0, &timer_irq);
-       OIER |= OIER_E0;        /* enable match on timer 0 to cause interrupts */
-       OSCR = 0;               /* initialize free-running timer, force first match */
-}
-
diff --git a/include/asm-arm/arch-rpc/ide.h b/include/asm-arm/arch-rpc/ide.h
deleted file mode 100644 (file)
index 92c7030..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-rpc/ide.h
- *
- *  Copyright (C) 1997 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Modifications:
- *   29-07-1998        RMK     Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-
-       memset(hw, 0, sizeof(*hw));
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += 1;
-       }
-       hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-       if (irq)
-               *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
-       hw_regs_t hw;
-
-       ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
-       hw.irq = IRQ_HARDDISK;
-       ide_register_hw(&hw, NULL);
-}
diff --git a/include/asm-arm/arch-rpc/time.h b/include/asm-arm/arch-rpc/time.h
deleted file mode 100644 (file)
index 1df6a12..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-rpc/time.h
- *
- *  Copyright (C) 1996-2000 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Changelog:
- *   24-Sep-1996 RMK   Created
- *   10-Oct-1996 RMK   Brought up to date with arch-sa110eval
- *   04-Dec-1997 RMK   Updated for new arch/arm/time.c
- */
-extern void ioctime_init(void);
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       do_timer(regs);
-       do_set_rtc();
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
-       ioctime_init();
-
-       timer_irq.handler = timer_interrupt;
-
-       setup_irq(IRQ_TIMER, &timer_irq);
-}
diff --git a/include/asm-arm/arch-s3c2410/ide.h b/include/asm-arm/arch-s3c2410/ide.h
deleted file mode 100644 (file)
index de651e7..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* linux/include/asm-arm/arch-s3c2410/ide.h
- *
- *  Copyright (C) 1997 Russell King
- *  Copyright (C) 2003 Simtec Electronics
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Modifications:
- *   29-07-1998        RMK     Major re-work of IDE architecture specific code
- *   16-05-2003 BJD    Changed to work with BAST IDE ports
- *   04-09-2003 BJD    Modifications for V2.6
- */
-
-#ifndef __ASM_ARCH_IDE_H
-#define __ASM_ARCH_IDE_H
-
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-
-       memset(hw, 0, sizeof(*hw));
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += 1;
-       }
-       hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-       if (irq)
-               *irq = 0;
-}
-
-/* we initialise our ide devices from the main ide core, due to problems
- * with doing it in this function
-*/
-
-#define ide_init_default_hwifs() do { } while(0)
-
-#endif /* __ASM_ARCH_IDE_H */
diff --git a/include/asm-arm/arch-s3c2410/time.h b/include/asm-arm/arch-s3c2410/time.h
deleted file mode 100644 (file)
index 8aab343..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/* linux/include/asm-arm/arch-s3c2410/time.h
- *
- *  Copyright (C) 2003 Simtec Electronics <linux@simtec.co.uk>
- *    Ben Dooks, <ben@simtec.co.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <asm/system.h>
-#include <asm/leds.h>
-#include <asm/mach-types.h>
-
-#include <asm/io.h>
-#include <asm/arch/map.h>
-#include <asm/arch/regs-timer.h>
-
-extern unsigned long (*gettimeoffset)(void);
-
-static unsigned long timer_startval;
-static unsigned long timer_ticks_usec;
-
-#ifdef CONFIG_S3C2410_RTC
-extern void s3c2410_rtc_check();
-#endif
-
-/* with an 12MHz clock, we get 12 ticks per-usec
- */
-
-
-/***
- * Returns microsecond  since last clock interrupt.  Note that interrupts
- * will have been disabled by do_gettimeoffset()
- * IRQs are disabled before entering here from do_gettimeofday()
- */
-static unsigned long s3c2410_gettimeoffset (void)
-{
-       unsigned long tdone;
-       unsigned long usec;
-
-       /* work out how many ticks have gone since last timer interrupt */
-
-       tdone = timer_startval - __raw_readl(S3C2410_TCNTO(4));
-
-       /* currently, tcnt is in 12MHz units, but this may change
-        * for non-bast machines...
-        */
-
-       usec = tdone / timer_ticks_usec;
-
-       return usec;
-}
-
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t
-s3c2410_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       do_leds();
-       do_timer(regs);
-
-       do_set_rtc();
-       //s3c2410_rtc_check();
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-
-/* currently we only use timer4, as it is the only timer which has no
- * other function that can be exploited externally
-*/
-
-void __init time_init (void)
-{
-       unsigned long tcon;
-       unsigned long tcnt;
-       unsigned long tcfg1;
-       unsigned long tcfg0;
-
-       gettimeoffset = s3c2410_gettimeoffset;
-       timer_irq.handler = s3c2410_timer_interrupt;
-
-       tcnt = 0xffff;  /* default value for tcnt */
-
-       /* read the current timer configuration bits */
-
-       tcon = __raw_readl(S3C2410_TCON);
-       tcfg1 = __raw_readl(S3C2410_TCFG1);
-       tcfg0 = __raw_readl(S3C2410_TCFG0);
-
-       /* configure the system for whichever machine is in use */
-
-       if (machine_is_bast() || machine_is_vr1000()) {
-               timer_ticks_usec = 12;        /* timer is at 12MHz */
-               tcnt = (timer_ticks_usec * (1000*1000)) / HZ;
-       }
-
-       /* for the h1940, we use the pclk from the core to generate
-        * the timer values. since 67.5MHz is not a value we can directly
-        * generate the timer value from, we need to pre-scale and
-        * divied before using it.
-        *
-        * overall divsior to get 200Hz is 337500
-        *   we can fit tcnt if we pre-scale by 6, producing a tick rate
-        *   of 11.25MHz, and a tcnt of 56250.
-        */
-
-       if (machine_is_h1940() || machine_is_smdk2410() ) {
-               timer_ticks_usec = s3c2410_pclk / (1000*1000);
-               timer_ticks_usec /= 6;
-
-               tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK;
-               tcfg1 |= S3C2410_TCFG1_MUX4_DIV2;
-
-               tcfg0 &= ~S3C2410_TCFG_PRESCALER1_MASK;
-               tcfg0 |= ((6 - 1) / 2) << S3C2410_TCFG_PRESCALER1_SHIFT;
-
-               tcnt = (s3c2410_pclk / 6) / HZ;
-       }
-
-
-       printk("setup_timer tcon=%08lx, tcnt %04lx, tcfg %08lx,%08lx\n",
-              tcon, tcnt, tcfg0, tcfg1);
-
-       /* check to see if timer is within 16bit range... */
-       if (tcnt > 0xffff) {
-               panic("setup_timer: HZ is too small, cannot configure timer!");
-               return;
-       }
-
-       __raw_writel(tcfg1, S3C2410_TCFG1);
-       __raw_writel(tcfg0, S3C2410_TCFG0);
-
-       timer_startval = tcnt;
-       __raw_writel(tcnt, S3C2410_TCNTB(4));
-
-       /* ensure timer is stopped... */
-
-       tcon &= ~(7<<20);
-       tcon |= S3C2410_TCON_T4RELOAD;
-       tcon |= S3C2410_TCON_T4MANUALUPD;
-
-       __raw_writel(tcon, S3C2410_TCON);
-       __raw_writel(tcnt, S3C2410_TCNTB(4));
-       __raw_writel(tcnt, S3C2410_TCMPB(4));
-
-       setup_irq(IRQ_TIMER4, &timer_irq);
-
-       /* start the timer running */
-       tcon |= S3C2410_TCON_T4START;
-       tcon &= ~S3C2410_TCON_T4MANUALUPD;
-       __raw_writel(tcon, S3C2410_TCON);
-}
-
-
-
diff --git a/include/asm-arm/arch-sa1100/keyboard.h b/include/asm-arm/arch-sa1100/keyboard.h
deleted file mode 100644 (file)
index 3dacd71..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-sa1100/keyboard.h
- *  Created 16 Dec 1999 by Nicolas Pitre <nico@cam.org>
- *  This file contains the SA1100 architecture specific keyboard definitions
- */
-#ifndef _SA1100_KEYBOARD_H
-#define _SA1100_KEYBOARD_H
-
-#include <linux/config.h>
-#include <asm/mach-types.h>
-
-extern void gc_kbd_init_hw(void);
-extern void smartio_kbd_init_hw(void);
-
-static inline void kbd_init_hw(void)
-{
-       if (machine_is_graphicsclient())
-               gc_kbd_init_hw();
-       if (machine_is_adsbitsy())
-               smartio_kbd_init_hw();
-}
-
-#endif  /* _SA1100_KEYBOARD_H */
diff --git a/include/asm-arm/arch-sa1100/time.h b/include/asm-arm/arch-sa1100/time.h
deleted file mode 100644 (file)
index d962626..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/time.h
- *
- * Copyright (C) 1998 Deborah Wallach.
- * Twiddles  (C) 1999  Hugo Fiennes <hugo@empeg.com>
- * 
- * 2000/03/29 (C) Nicolas Pitre <nico@cam.org>
- *     Rewritten: big cleanup, much simpler, better HZ accuracy.
- *
- */
-
-
-#define RTC_DEF_DIVIDER                (32768 - 1)
-#define RTC_DEF_TRIM            0
-
-static unsigned long __init sa1100_get_rtc_time(void)
-{
-       /*
-        * According to the manual we should be able to let RTTR be zero
-        * and then a default diviser for a 32.768KHz clock is used.
-        * Apparently this doesn't work, at least for my SA1110 rev 5.
-        * If the clock divider is uninitialized then reset it to the
-        * default value to get the 1Hz clock.
-        */
-       if (RTTR == 0) {
-               RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
-               printk(KERN_WARNING "Warning: uninitialized Real Time Clock\n");
-               /* The current RTC value probably doesn't make sense either */
-               RCNR = 0;
-               return 0;
-       }
-       return RCNR;
-}
-
-static int sa1100_set_rtc(void)
-{
-       unsigned long current_time = xtime.tv_sec;
-
-       if (RTSR & RTSR_ALE) {
-               /* make sure not to forward the clock over an alarm */
-               unsigned long alarm = RTAR;
-               if (current_time >= alarm && alarm >= RCNR)
-                       return -ERESTARTSYS;
-       }
-       RCNR = current_time;
-       return 0;
-}
-
-/* IRQs are disabled before entering here from do_gettimeofday() */
-static unsigned long sa1100_gettimeoffset (void)
-{
-       unsigned long ticks_to_match, elapsed, usec;
-
-       /* Get ticks before next timer match */
-       ticks_to_match = OSMR0 - OSCR;
-
-       /* We need elapsed ticks since last match */
-       elapsed = LATCH - ticks_to_match;
-
-       /* Now convert them to usec */
-       usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
-
-       return usec;
-}
-
-/*
- * We will be entered with IRQs enabled.
- *
- * Loop until we get ahead of the free running timer.
- * This ensures an exact clock tick count and time accuracy.
- * IRQs are disabled inside the loop to ensure coherence between
- * lost_ticks (updated in do_timer()) and the match reg value, so we
- * can use do_gettimeofday() from interrupt handlers.
- */
-static irqreturn_t
-sa1100_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       unsigned int next_match;
-
-       do {
-               do_leds();
-               do_timer(regs);
-               OSSR = OSSR_M0;  /* Clear match on timer 0 */
-               next_match = (OSMR0 += LATCH);
-               do_set_rtc();
-       } while ((signed long)(next_match - OSCR) <= 0);
-
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
-       struct timespec tv;
-
-       gettimeoffset = sa1100_gettimeoffset;
-       set_rtc = sa1100_set_rtc;
-
-       tv.tv_nsec = 0;
-       tv.tv_sec = sa1100_get_rtc_time();
-       do_settimeofday(&tv);
-
-       timer_irq.handler = sa1100_timer_interrupt;
-       OSMR0 = 0;              /* set initial match at 0 */
-       OSSR = 0xf;             /* clear status on all timers */
-       setup_irq(IRQ_OST0, &timer_irq);
-       OIER |= OIER_E0;        /* enable match on timer 0 to cause interrupts */
-       OSCR = 0;               /* initialize free-running timer, force first match */
-}
-
diff --git a/include/asm-arm/arch-shark/ide.h b/include/asm-arm/arch-shark/ide.h
deleted file mode 100644 (file)
index f6a99b2..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * linux/include/asm-arm/arch-shark/ide.h
- *
- * by Alexander Schulz
- *
- * derived from:
- * linux/include/asm-arm/arch-ebsa285/ide.h
- * Copyright (c) 1998 Russell King
- */
-
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-                                      unsigned long ctrl_port, int *irq)
-{
-       unsigned long reg = data_port;
-       int i;
-
-       memset(hw, 0, sizeof(*hw));
-
-       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
-               hw->io_ports[i] = reg;
-               reg += 1;
-       }
-       hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-       if (irq)
-               *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
-       hw_regs_t hw;
-
-       ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
-       hw.irq = 14;
-       ide_register_hw(&hw,NULL);
-}
-
diff --git a/include/asm-arm/arch-shark/keyboard.h b/include/asm-arm/arch-shark/keyboard.h
deleted file mode 100644 (file)
index 52b5ed6..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * linux/include/asm-arm/arch-shark/keyboard.h
- * by Alexander Schulz
- * 
- * Derived from linux/include/asm-arm/arch-ebsa285/keyboard.h
- * (C) 1998 Russell King
- * (C) 1998 Phil Blundell
- */
-#include <linux/config.h>
-#include <linux/ioport.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/system.h>
-
-#define KEYBOARD_IRQ                   IRQ_ISA_KEYBOARD
-#define NR_SCANCODES                   128
-
-#define kbd_disable_irq()              do { } while (0)
-#define kbd_enable_irq()               do { } while (0)
-
-extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
-extern int pckbd_getkeycode(unsigned int scancode);
-extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
-                          char raw_mode);
-extern char pckbd_unexpected_up(unsigned char keycode);
-extern void pckbd_leds(unsigned char leds);
-extern void pckbd_init_hw(void);
-extern unsigned char pckbd_sysrq_xlate[128];
-
-static inline void kbd_init_hw(void)
-{
-               k_setkeycode    = pckbd_setkeycode;
-               k_getkeycode    = pckbd_getkeycode;
-               k_translate     = pckbd_translate;
-               k_unexpected_up = pckbd_unexpected_up;
-               k_leds          = pckbd_leds;
-#ifdef CONFIG_MAGIC_SYSRQ
-               k_sysrq_key     = 0x54;
-               k_sysrq_xlate   = pckbd_sysrq_xlate;
-#endif
-               pckbd_init_hw();
-}
-
-/*
- * PC Keyboard specifics
- */
-
-/* resource allocation */
-#define kbd_request_region() request_region(0x60, 16, "keyboard")
-#define kbd_request_irq(handler) request_irq(KEYBOARD_IRQ, handler, 0, \
-                                             "keyboard", NULL)
-
-/* How to access the keyboard macros on this platform.  */
-#define kbd_read_input() inb(KBD_DATA_REG)
-#define kbd_read_status() inb(KBD_STATUS_REG)
-#define kbd_write_output(val) outb(val, KBD_DATA_REG)
-#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
-
-/* Some stoneage hardware needs delays after some operations.  */
-#define kbd_pause() do { } while(0)
-
-/*
- * Machine specific bits for the PS/2 driver
- */
-#define aux_request_irq(hand, dev_id)                                  \
-       request_irq(AUX_IRQ, hand, SA_SHIRQ, "PS/2 Mouse", dev_id)
-
-#define aux_free_irq(dev_id) free_irq(AUX_IRQ, dev_id)
diff --git a/include/asm-arm/arch-shark/time.h b/include/asm-arm/arch-shark/time.h
deleted file mode 100644 (file)
index 66e4525..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * linux/include/asm-arm/arch-shark/time.h
- *
- * by Alexander Schulz
- *
- * derived from include/asm-arm/arch-ebsa110/time.h
- * Copyright (c) 1996,1997,1998 Russell King.
- */
-
-#include <asm/leds.h>
-#include <asm/param.h>
-
-#define IRQ_TIMER 0
-#define HZ_TIME ((1193180 + HZ/2) / HZ)
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       do_leds();
-       do_timer(regs);
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-void __init time_init(void)
-{
-        unsigned long flags;
-
-       outb(0x34, 0x43);               /* binary, mode 0, LSB/MSB, Ch 0 */
-       outb(HZ_TIME & 0xff, 0x40);     /* LSB of count */
-       outb(HZ_TIME >> 8, 0x40);
-
-       timer_irq.handler = timer_interrupt;
-       setup_irq(IRQ_TIMER, &timer_irq);
-}
diff --git a/include/asm-arm/arch-tbox/dma.h b/include/asm-arm/arch-tbox/dma.h
deleted file mode 100644 (file)
index 1d5d391..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/dma.h
- *
- * Architecture DMA routines.  We have to contend with the bizarre DMA
- * machine built into the Tbox hardware.
- *
- * Copyright (C) 1998 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * DMA channel definitions.  Some of these are physically strange but
- * we sort it out inside dma.c so the user never has to care.  The
- * exception is the double-buffering which we can't really abstract
- * away sensibly.
- */
-#define DMA_VIDEO                      0
-#define DMA_MPEG_B                     1
-#define DMA_AUDIO_B                    2
-#define DMA_ASHRX_B                    3
-#define DMA_ASHTX                      4
-#define DMA_MPEG                       5
-#define DMA_AUDIO                      6
-#define DMA_ASHRX                      7
-
-#define MAX_DMA_CHANNELS               0       /* XXX */
-
-/*
- * This is the maximum DMA address that can be DMAd to.
- */
-#define MAX_DMA_ADDRESS                0xffffffff
diff --git a/include/asm-arm/arch-tbox/hardware.h b/include/asm-arm/arch-tbox/hardware.h
deleted file mode 100644 (file)
index 9aa3f45..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/hardware.h
- *
- * Copyright (C) 1998, 1999, 2000 Philip Blundell
- * Copyright (C) 2000 FutureTV Labs Ltd
- *
- * This file contains the hardware definitions of the Tbox
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-/*    Logical    Physical
- * 0xfff00000  0x00100000      I/O
- * 0xfff00000  0x00100000        Expansion CS0
- * 0xfff10000  0x00110000        DMA
- * 0xfff20000  0x00120000        C-Cube
- * 0xfff30000  0x00130000        FPGA 1
- * 0xfff40000  0x00140000        UART 2
- * 0xfff50000  0x00150000        UART 1
- * 0xfff60000  0x00160000        CS8900
- * 0xfff70000  0x00170000        INTCONT
- * 0xfff80000  0x00180000        RAMDAC
- * 0xfff90000  0x00190000        Control 0
- * 0xfffa0000  0x001a0000        Control 1
- * 0xfffb0000  0x001b0000        Control 2
- * 0xfffc0000  0x001c0000        FPGA 2
- * 0xfffd0000  0x001d0000        INTRESET
- * 0xfffe0000  0x001e0000        C-Cube DMA throttle
- * 0xffff0000  0x001f0000        Expansion CS1
- * 0xffe00000  0x82000000      cache flush
- */
-
-/*
- * Mapping areas
- */
-#define IO_BASE                        0xfff00000
-#define IO_START               0x00100000
-#define FLUSH_BASE             0xffe00000
-
-#define INTCONT                        0xfff70000
-
-#define FPGA1CONT              0xffff3000
-
-/*
- * RAM definitions
- */
-#define RAM_BASE               0x80000000
-#define FLUSH_BASE_PHYS                0x82000000
-
-#define UNCACHEABLE_ADDR       INTCONT
-
-#endif
diff --git a/include/asm-arm/arch-tbox/ide.h b/include/asm-arm/arch-tbox/ide.h
deleted file mode 100644 (file)
index d66e67c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/ide.h
- */
diff --git a/include/asm-arm/arch-tbox/io.h b/include/asm-arm/arch-tbox/io.h
deleted file mode 100644 (file)
index 8697985..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/io.h
- *
- * Copyright (C) 1996-1999 Russell King
- * Copyright (C) 1998, 1999 Philip Blundell
- *
- */
-#ifndef __ASM_ARM_ARCH_IO_H
-#define __ASM_ARM_ARCH_IO_H
-
-#define IO_SPACE_LIMIT 0xffffffff
-
-#define __io(_x)               ((_x) << 2)
-
-/*
- * Generic virtual read/write
- */
-static inline unsigned int __arch_getw(unsigned long a)
-{
-       unsigned int value;
-       __asm__ __volatile__("ldr%?h    %0, [%1, #0]    @ getw"
-               : "=&r" (value)
-               : "r" (a));
-       return value;
-}
-
-static inline void __arch_putw(unsigned int value, unsigned long a)
-{
-       __asm__ __volatile__("str%?h    %0, [%1, #0]    @ putw"
-               : : "r" (value), "r" (a));
-}
-
-/* Idem, for devices on the upper byte lanes */
-#define inb_u(p)               __arch_getb(__io_pc(p) + 2)
-#define inw_u(p)               __arch_getw(__io_pc(p) + 2)
-
-#define outb_u(v,p)            __arch_putb(v,__io_pc(p) + 2)
-#define outw_u(v,p)            __arch_putw(v,__io_pc(p) + 2)
-
-#endif
diff --git a/include/asm-arm/arch-tbox/irqs.h b/include/asm-arm/arch-tbox/irqs.h
deleted file mode 100644 (file)
index 1ee5eba..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/irqs.h
- *
- * Copyright (C) 1998, 2000 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#define IRQ_MPEGDMA            0
-#define IRQ_ASHTX              1
-#define IRQ_ASHRX              2
-#define IRQ_VSYNC              3
-#define IRQ_HSYNC              4
-#define IRQ_MPEG               5
-#define IRQ_UART2              6
-#define IRQ_UART1              7
-#define IRQ_ETHERNET           8
-#define IRQ_TIMER              9
-#define IRQ_AUDIODMA           10
-/* bit 11 used for video field ident */
-#define IRQ_EXPMODCS0          12
-#define IRQ_EXPMODCS1          13
-
-#define irq_canonicalize(i)    (i)
diff --git a/include/asm-arm/arch-tbox/memory.h b/include/asm-arm/arch-tbox/memory.h
deleted file mode 100644 (file)
index a204794..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/memory.h
- *
- * Copyright (c) 1996-1999 Russell King.
- * Copyright (c) 1998-1999 Phil Blundell
- */
-#ifndef __ASM_ARCH_MEMORY_H
-#define __ASM_ARCH_MEMORY_H
-
-/*
- * Physical DRAM offset.
- */
-#define PHYS_OFFSET            (0x80000000UL)
-
-/*
- * Bus view is the same as physical view
- */
-#define __virt_to_bus(x)       __virt_to_phys(x)
-#define __bus_to_virt(x)       __phys_to_virt(x)
-
-#endif
diff --git a/include/asm-arm/arch-tbox/param.h b/include/asm-arm/arch-tbox/param.h
deleted file mode 100644 (file)
index 4b47fe3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-tbox/param.h
- */
-#define __KERNEL_HZ 1000
diff --git a/include/asm-arm/arch-tbox/serial.h b/include/asm-arm/arch-tbox/serial.h
deleted file mode 100644 (file)
index 7e4aff9..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/serial.h
- *
- * Copyright (c) 1996 Russell King.
- * Copyright (c) 1998 Phil Blundell
- *
- * Changelog:
- *  15-10-1996 RMK     Created
- *  09-06-1998  PJB    tbox version
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-     /* UART CLK        PORT  IRQ     FLAGS        */
-#define STD_SERIAL_PORT_DEFNS \
-       { 0, BASE_BAUD, 0xffff4000 >> 2, 6, STD_COM_FLAGS }, /* ttyS0 */ \
-       { 0, BASE_BAUD, 0xffff5000 >> 2, 7, STD_COM_FLAGS }, /* ttyS1 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
diff --git a/include/asm-arm/arch-tbox/system.h b/include/asm-arm/arch-tbox/system.h
deleted file mode 100644 (file)
index da2cb88..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/system.h
- *
- * Copyright (c) 1996-1999 Russell King.
- */
-#ifndef __ASM_ARCH_SYSTEM_H
-#define __ASM_ARCH_SYSTEM_H
-
-static inline void arch_idle(void)
-{
-       cpu_do_idle();
-}
-
-#define arch_reset(mode)       do { } while (0)
-
-#endif
diff --git a/include/asm-arm/arch-tbox/time.h b/include/asm-arm/arch-tbox/time.h
deleted file mode 100644 (file)
index 4617871..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/time.h
- *
- * Copyright (c) 1997, 1999 Phil Blundell.
- * Copyright (c) 2000 FutureTV Labs Ltd
- *
- * Tbox has no real-time clock -- we get millisecond ticks to update
- * our soft copy.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <asm/io.h>
-#include <asm/hardware.h>
-
-#define update_rtc()
-
-static irqreturn_t
-timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
-{
-       /* Clear irq */
-       __raw_writel(1, FPGA1CONT + 0xc); 
-       __raw_writel(0, FPGA1CONT + 0xc);
-
-       do_timer(regs);
-
-       return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
-       timer_irq.handler = timer_interrupt;
-       setup_irq(IRQ_TIMER, &timer_irq);
-}
diff --git a/include/asm-arm/arch-tbox/timex.h b/include/asm-arm/arch-tbox/timex.h
deleted file mode 100644 (file)
index c5489cd..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/timex.h
- *
- * Tbox timex specifications
- *
- * Copyright (C) 1999 Philip Blundell
- */
-
diff --git a/include/asm-arm/arch-tbox/uncompress.h b/include/asm-arm/arch-tbox/uncompress.h
deleted file mode 100644 (file)
index 17a5034..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * linux/include/asm-arm/arch-nexuspci/uncompress.h
- *  from linux/include/asm-arm/arch-ebsa110/uncompress.h
- *
- * Copyright (C) 1996,1997,1998 Russell King
- * Copyright (C) 1998, 1999 Phil Blundell
- */
-
-#include <asm/io.h>
-
-#define UARTBASE 0x00400000
-
-/*
- * This does not append a newline
- */
-static void puts(const char *s)
-{
-  while (*s)
-  {
-    char c = *(s++);
-    while (!(__raw_readb(UARTBASE + 0x14) & 0x20));
-    __raw_writeb(c, UARTBASE);
-    if (c == 10) {
-      while (!(__raw_readb(UARTBASE + 0x14) & 0x20));
-      __raw_writeb(13, UARTBASE);
-    }
-  }
-}
-
-/*
- * nothing to do
- */
-#define arch_decomp_setup()
-
-/*
- * Stroke the watchdog so we don't get reset during decompression.
- */
-#define arch_decomp_wdog()                             \
-       do {                                            \
-       __raw_writel(1, 0xa00000);                      \
-       __raw_writel(0, 0xa00000);                      \
-       } while (0)
diff --git a/include/asm-arm/arch-tbox/vmalloc.h b/include/asm-arm/arch-tbox/vmalloc.h
deleted file mode 100644 (file)
index da4a5c0..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * linux/include/asm-arm/arch-tbox/vmalloc.h
- */
-
-/*
- * Just any arbitrary offset to the start of the vmalloc VM area: the
- * current 8MB value just means that there will be a 8MB "hole" after the
- * physical memory until the kernel virtual memory starts.  That means that
- * any out-of-bounds memory accesses will hopefully be caught.
- * The vmalloc() routines leaves a hole of 4kB between each vmalloced
- * area for the same reason. ;)
- */
-#define VMALLOC_OFFSET   (8*1024*1024)
-#define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
-#define VMALLOC_END       (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-versatile/time.h b/include/asm-arm/arch-versatile/time.h
deleted file mode 100644 (file)
index 7d97d95..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- *  linux/include/asm-arm/arch-versatile/time.h
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <asm/system.h>
-#include <asm/leds.h>
-
-/*
- * Where is the timer (VA)?
- */
-#define TIMER0_VA_BASE          IO_ADDRESS(VERSATILE_TIMER0_1_BASE)
-#define TIMER1_VA_BASE         (IO_ADDRESS(VERSATILE_TIMER0_1_BASE) + 0x20)
-#define TIMER2_VA_BASE          IO_ADDRESS(VERSATILE_TIMER2_3_BASE)
-#define TIMER3_VA_BASE         (IO_ADDRESS(VERSATILE_TIMER2_3_BASE) + 0x20)
-#define VA_IC_BASE              IO_ADDRESS(VERSATILE_VIC_BASE) 
-
-/*
- * How long is the timer interval?
- */
-#define TIMER_INTERVAL (TICKS_PER_uSEC * mSEC_10)
-#if TIMER_INTERVAL >= 0x100000
-#define TIMER_RELOAD   (TIMER_INTERVAL >> 8)           /* Divide by 256 */
-#define TIMER_CTRL     0x88                            /* Enable, Clock / 256 */
-#define TICKS2USECS(x) (256 * (x) / TICKS_PER_uSEC)
-#elif TIMER_INTERVAL >= 0x10000
-#define TIMER_RELOAD   (TIMER_INTERVAL >> 4)           /* Divide by 16 */
-#define TIMER_CTRL     0x84                            /* Enable, Clock / 16 */
-#define TICKS2USECS(x) (16 * (x) / TICKS_PER_uSEC)
-#else
-#define TIMER_RELOAD   (TIMER_INTERVAL)
-#define TIMER_CTRL     0x80                            /* Enable */
-#define TICKS2USECS(x) ((x) / TICKS_PER_uSEC)
-#endif
-
-#define TIMER_CTRL_IE  (1 << 5)        /* Interrupt Enable */
-
-/*
- * What does it look like?
- */
-typedef struct TimerStruct {
-       unsigned long TimerLoad;
-       unsigned long TimerValue;
-       unsigned long TimerControl;
-       unsigned long TimerClear;
-} TimerStruct_t;
-
-extern unsigned long (*gettimeoffset)(void);
-
-/*
- * Returns number of ms since last clock interrupt.  Note that interrupts
- * will have been disabled by do_gettimeoffset()
- */
-static unsigned long versatile_gettimeoffset(void)
-{
-       volatile TimerStruct_t *timer0 = (TimerStruct_t *)TIMER0_VA_BASE;
-       unsigned long ticks1, ticks2, status;
-
-       /*
-        * Get the current number of ticks.  Note that there is a race
-        * condition between us reading the timer and checking for
-        * an interrupt.  We get around this by ensuring that the
-        * counter has not reloaded between our two reads.
-        */
-       ticks2 = timer0->TimerValue & 0xffff;
-       do {
-               ticks1 = ticks2;
-               status = __raw_readl(VA_IC_BASE + VIC_IRQ_RAW_STATUS);
-               ticks2 = timer0->TimerValue & 0xffff;
-       } while (ticks2 > ticks1);
-
-       /*
-        * Number of ticks since last interrupt.
-        */
-       ticks1 = TIMER_RELOAD - ticks2;
-
-       /*
-        * Interrupt pending?  If so, we've reloaded once already.
-        *
-        * FIXME: Need to check this is effectively timer 0 that expires
-        */
-       if (status & IRQMASK_TIMERINT0_1)
-               ticks1 += TIMER_RELOAD;
-
-       /*
-        * Convert the ticks to usecs
-        */
-       return TICKS2USECS(ticks1);
-}
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t versatile_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-       volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
-
-       // ...clear the interrupt
-       timer0->TimerClear = 1;
-
-       do_leds();
-       do_timer(regs);
-       do_profile(regs);
-
-       return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-void __init time_init(void)
-{
-       volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
-       volatile TimerStruct_t *timer1 = (volatile TimerStruct_t *)TIMER1_VA_BASE;
-       volatile TimerStruct_t *timer2 = (volatile TimerStruct_t *)TIMER2_VA_BASE;
-       volatile TimerStruct_t *timer3 = (volatile TimerStruct_t *)TIMER3_VA_BASE;
-
-       /* 
-        * set clock frequency: 
-        *      VERSATILE_REFCLK is 32KHz
-        *      VERSATILE_TIMCLK is 1MHz
-        */
-       *(volatile unsigned int *)IO_ADDRESS(VERSATILE_SCTL_BASE) |= 
-         ((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | 
-          (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel));
-
-       timer_irq.handler = versatile_timer_interrupt;
-
-       /*
-        * Initialise to a known state (all timers off)
-        */
-       timer0->TimerControl = 0;
-       timer1->TimerControl = 0;
-       timer2->TimerControl = 0;
-       timer3->TimerControl = 0;
-
-       timer0->TimerLoad    = TIMER_RELOAD;
-       timer0->TimerValue   = TIMER_RELOAD;
-       timer0->TimerControl = TIMER_CTRL | 0x40 | TIMER_CTRL_IE;  /* periodic + IE */
-
-       /* 
-        * Make irqs happen for the system timer
-        */
-       setup_irq(IRQ_TIMERINT0_1, &timer_irq);
-       gettimeoffset = versatile_gettimeoffset;
-}
diff --git a/include/asm-arm/cpumask.h b/include/asm-arm/cpumask.h
deleted file mode 100644 (file)
index e3cf01f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_ARM_CPUMASK_H
-#define _ASM_ARM_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_ARM_CPUMASK_H */
index bb86668..05f6f1e 100644 (file)
@@ -196,6 +196,8 @@ static inline int get_order(unsigned long size)
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif
diff --git a/include/asm-arm/relay.h b/include/asm-arm/relay.h
new file mode 100644 (file)
index 0000000..f9913f1
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_ARM_RELAY_H
+#define _ASM_ARM_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 748c660..f98f259 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },       \
        { 0,             0             },       \
        { INR_OPEN,      INR_OPEN      },       \
-       { RLIM_INFINITY, RLIM_INFINITY },       \
+       { 32768,         32768         },       \
        { RLIM_INFINITY, RLIM_INFINITY },       \
        { RLIM_INFINITY, RLIM_INFINITY },       \
        { MAX_SIGPENDING, MAX_SIGPENDING},      \
diff --git a/include/asm-arm/rmap.h b/include/asm-arm/rmap.h
deleted file mode 100644 (file)
index bb9ee93..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ARM_RMAP_H
-#define _ARM_RMAP_H
-
-#include <asm-generic/rmap.h>
-
-#endif /* _ARM_RMAP_H */
index ab3cad4..a21e6a0 100644 (file)
@@ -58,7 +58,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
 
        if (rss < freed)
                freed = rss;
-       mm->rss = rss - freed;
+       // mm->rss = rss - freed;
+       vx_rsspages_sub(mm, freed);
 
        if (freed) {
                flush_tlb_mm(mm);
index 51bc2a9..f367152 100644 (file)
@@ -394,6 +394,9 @@ static inline unsigned long __copy_to_user(void __user *to, const void *from, un
        return __arch_copy_to_user(to, from, n);
 }
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 static inline unsigned long clear_user (void __user *to, unsigned long n)
 {
        if (access_ok(VERIFY_WRITE, to, n))
diff --git a/include/asm-arm26/cpumask.h b/include/asm-arm26/cpumask.h
deleted file mode 100644 (file)
index d181df4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_ARM26_CPUMASK_H
-#define _ASM_ARM26_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_ARM26_CPUMASK_H */
index c334079..29f2836 100644 (file)
@@ -110,6 +110,8 @@ static inline int get_order(unsigned long size)
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif
diff --git a/include/asm-arm26/relay.h b/include/asm-arm26/relay.h
new file mode 100644 (file)
index 0000000..f9913f1
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_ARM_RELAY_H
+#define _ASM_ARM_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 748c660..f98f259 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },       \
        { 0,             0             },       \
        { INR_OPEN,      INR_OPEN      },       \
-       { RLIM_INFINITY, RLIM_INFINITY },       \
+       { 32768,         32768         },       \
        { RLIM_INFINITY, RLIM_INFINITY },       \
        { RLIM_INFINITY, RLIM_INFINITY },       \
        { MAX_SIGPENDING, MAX_SIGPENDING},      \
diff --git a/include/asm-arm26/rmap.h b/include/asm-arm26/rmap.h
deleted file mode 100644 (file)
index 6d5b6e0..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef _ARM_RMAP_H
-#define _ARM_RMAP_H
-
-/*
- * linux/include/asm-arm26/proc-armv/rmap.h
- *
- * Architecture dependant parts of the reverse mapping code,
- *
- * ARM is different since hardware page tables are smaller than
- * the page size and Linux uses a "duplicate" one with extra info.
- * For rmap this means that the first 2 kB of a page are the hardware
- * page tables and the last 2 kB are the software page tables.
- */
-
-static inline void pgtable_add_rmap(struct page *page, struct mm_struct * mm, unsigned long address)
-{
-        page->mapping = (void *)mm;
-        page->index = address & ~((PTRS_PER_PTE * PAGE_SIZE) - 1);
-        inc_page_state(nr_page_table_pages);
-}
-
-static inline void pgtable_remove_rmap(struct page *page)
-{
-        page->mapping = NULL;
-        page->index = 0;
-        dec_page_state(nr_page_table_pages);
-}
-
-static inline struct mm_struct * ptep_to_mm(pte_t * ptep)
-{
-       struct page * page = virt_to_page(ptep);
-        return (struct mm_struct *)page->mapping;
-}
-
-/* The page table takes half of the page */
-#define PTE_MASK  ((PAGE_SIZE / 2) - 1)
-
-static inline unsigned long ptep_to_address(pte_t * ptep)
-{
-        struct page * page = virt_to_page(ptep);
-        unsigned long low_bits;
-
-        low_bits = ((unsigned long)ptep & PTE_MASK) * PTRS_PER_PTE;
-        return page->index + low_bits;
-}
-//FIXME!!! IS these correct?
-static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
-{
-        return (pte_addr_t)ptep;
-}
-
-static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
-{
-        return (pte_t *)pte_paddr;
-}
-
-static inline void rmap_ptep_unmap(pte_t *pte)
-{
-        return;
-}
-
-
-//#include <asm-generic/rmap.h>
-
-#endif /* _ARM_RMAP_H */
index b58e259..2da3018 100644 (file)
@@ -39,7 +39,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
 
         if (rss < freed)
                 freed = rss;
-        mm->rss = rss - freed;
+        // mm->rss = rss - freed;
+       vx_rsspages_sub(mm, freed);
 
         if (freed) {
                 flush_tlb_mm(mm);
index ae557c0..3818aa9 100644 (file)
@@ -217,6 +217,9 @@ static __inline__ unsigned long __copy_to_user(void *to, const void *from, unsig
        return n;
 }
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 static __inline__ unsigned long clear_user (void *to, unsigned long n)
 {
        if (access_ok(VERIFY_WRITE, to, n))
diff --git a/include/asm-cris/cpumask.h b/include/asm-cris/cpumask.h
deleted file mode 100644 (file)
index 123b032..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_CRIS_CPUMASK_H
-#define _ASM_CRIS_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_CRIS_CPUMASK_H */
index bebb889..e290e34 100644 (file)
@@ -96,6 +96,8 @@ static inline int get_order(unsigned long size)
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _CRIS_PAGE_H */
diff --git a/include/asm-cris/relay.h b/include/asm-cris/relay.h
new file mode 100644 (file)
index 0000000..30ee42c
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_CRIS_RELAY_H
+#define _ASM_CRIS_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index e33ada0..bae364c 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-cris/rmap.h b/include/asm-cris/rmap.h
deleted file mode 100644 (file)
index c5bf2a8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _CRIS_RMAP_H
-#define _CRIS_RMAP_H
-
-/* nothing to see, move along :) */
-#include <asm-generic/rmap.h>
-
-#endif
index 7532cd7..2f58e19 100644 (file)
@@ -434,6 +434,8 @@ __generic_clear_user_nocheck(void *to, unsigned long n)
 
 #define __copy_to_user(to,from,n)   __generic_copy_to_user_nocheck((to),(from),(n))
 #define __copy_from_user(to,from,n) __generic_copy_from_user_nocheck((to),(from),(n))
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
 #define __clear_user(to,n) __generic_clear_user_nocheck((to),(n))
 
 #define strlen_user(str)       strnlen_user((str), 0x7ffffffe)
diff --git a/include/asm-generic/cpumask.h b/include/asm-generic/cpumask.h
deleted file mode 100644 (file)
index a510325..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __ASM_GENERIC_CPUMASK_H
-#define __ASM_GENERIC_CPUMASK_H
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/threads.h>
-#include <linux/types.h>
-#include <linux/bitmap.h>
-
-#if NR_CPUS > BITS_PER_LONG && NR_CPUS != 1
-#define CPU_ARRAY_SIZE         BITS_TO_LONGS(NR_CPUS)
-
-struct cpumask
-{
-       unsigned long mask[CPU_ARRAY_SIZE];
-};
-
-typedef struct cpumask cpumask_t;
-
-#else
-typedef unsigned long cpumask_t;
-#endif
-
-#ifdef CONFIG_SMP
-#if NR_CPUS > BITS_PER_LONG
-#include <asm-generic/cpumask_array.h>
-#else
-#include <asm-generic/cpumask_arith.h>
-#endif
-#else
-#include <asm-generic/cpumask_up.h>
-#endif
-
-#if NR_CPUS <= 4*BITS_PER_LONG
-#include <asm-generic/cpumask_const_value.h>
-#else
-#include <asm-generic/cpumask_const_reference.h>
-#endif
-
-#endif /* __ASM_GENERIC_CPUMASK_H */
diff --git a/include/asm-generic/cpumask_arith.h b/include/asm-generic/cpumask_arith.h
deleted file mode 100644 (file)
index b4d25ac..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef __ASM_GENERIC_CPUMASK_ARITH_H
-#define __ASM_GENERIC_CPUMASK_ARITH_H
-
-/*
- * Arithmetic type -based cpu bitmaps. A single unsigned long is used
- * to contain the whole cpu bitmap.
- */
-
-#define cpu_set(cpu, map)              set_bit(cpu, &(map))
-#define cpu_clear(cpu, map)            clear_bit(cpu, &(map))
-#define cpu_isset(cpu, map)            test_bit(cpu, &(map))
-#define cpu_test_and_set(cpu, map)     test_and_set_bit(cpu, &(map))
-
-#define cpus_and(dst,src1,src2)                do { dst = (src1) & (src2); } while (0)
-#define cpus_or(dst,src1,src2)         do { dst = (src1) | (src2); } while (0)
-#define cpus_clear(map)                        do { map = 0; } while (0)
-#define cpus_complement(map)           do { map = ~(map); } while (0)
-#define cpus_equal(map1, map2)         ((map1) == (map2))
-#define cpus_empty(map)                        ((map) == 0)
-#define cpus_addr(map)                 (&(map))
-
-#if BITS_PER_LONG == 32
-#define cpus_weight(map)               hweight32(map)
-#elif BITS_PER_LONG == 64
-#define cpus_weight(map)               hweight64(map)
-#endif
-
-#define cpus_shift_right(dst, src, n)  do { dst = (src) >> (n); } while (0)
-#define cpus_shift_left(dst, src, n)   do { dst = (src) << (n); } while (0)
-
-#define any_online_cpu(map)                    \
-({                                             \
-       cpumask_t __tmp__;                      \
-       cpus_and(__tmp__, map, cpu_online_map); \
-       __tmp__ ? first_cpu(__tmp__) : NR_CPUS; \
-})
-
-#define CPU_MASK_ALL   (~((cpumask_t)0) >> (8*sizeof(cpumask_t) - NR_CPUS))
-#define CPU_MASK_NONE  ((cpumask_t)0)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce(map)               ((unsigned long)(map))
-#define cpus_promote(map)              ({ map; })
-#define cpumask_of_cpu(cpu)            ({ ((cpumask_t)1) << (cpu); })
-
-#define first_cpu(map)                 find_first_bit(&(map), NR_CPUS)
-#define next_cpu(cpu, map)             find_next_bit(&(map), NR_CPUS, cpu + 1)
-
-#endif /* __ASM_GENERIC_CPUMASK_ARITH_H */
diff --git a/include/asm-generic/cpumask_array.h b/include/asm-generic/cpumask_array.h
deleted file mode 100644 (file)
index ddd6e11..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef __ASM_GENERIC_CPUMASK_ARRAY_H
-#define __ASM_GENERIC_CPUMASK_ARRAY_H
-
-/*
- * Array-based cpu bitmaps. An array of unsigned longs is used to contain
- * the bitmap, and then contained in a structure so it may be passed by
- * value.
- */
-
-#define CPU_ARRAY_SIZE         BITS_TO_LONGS(NR_CPUS)
-
-#define cpu_set(cpu, map)              set_bit(cpu, (map).mask)
-#define cpu_clear(cpu, map)            clear_bit(cpu, (map).mask)
-#define cpu_isset(cpu, map)            test_bit(cpu, (map).mask)
-#define cpu_test_and_set(cpu, map)     test_and_set_bit(cpu, (map).mask)
-
-#define cpus_and(dst,src1,src2)        bitmap_and((dst).mask,(src1).mask, (src2).mask, NR_CPUS)
-#define cpus_or(dst,src1,src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, NR_CPUS)
-#define cpus_clear(map)                bitmap_zero((map).mask, NR_CPUS)
-#define cpus_complement(map)   bitmap_complement((map).mask, NR_CPUS)
-#define cpus_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, NR_CPUS)
-#define cpus_empty(map)                bitmap_empty(map.mask, NR_CPUS)
-#define cpus_addr(map)         ((map).mask)
-#define cpus_weight(map)               bitmap_weight((map).mask, NR_CPUS)
-#define cpus_shift_right(d, s, n)      bitmap_shift_right((d).mask, (s).mask, n, NR_CPUS)
-#define cpus_shift_left(d, s, n)       bitmap_shift_left((d).mask, (s).mask, n, NR_CPUS)
-#define first_cpu(map)         find_first_bit((map).mask, NR_CPUS)
-#define next_cpu(cpu, map)     find_next_bit((map).mask, NR_CPUS, cpu + 1)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce(map)       ((map).mask[0])
-#define cpus_promote(map)      ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
-                                       __cpu_mask.mask[0] = map;       \
-                                       __cpu_mask;                     \
-                               })
-#define cpumask_of_cpu(cpu)    ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
-                                       cpu_set(cpu, __cpu_mask);       \
-                                       __cpu_mask;                     \
-                               })
-#define any_online_cpu(map)                    \
-({                                             \
-       cpumask_t __tmp__;                      \
-       cpus_and(__tmp__, map, cpu_online_map); \
-       find_first_bit(__tmp__.mask, NR_CPUS);  \
-})
-
-
-/*
- * um, these need to be usable as static initializers
- */
-#define CPU_MASK_ALL   ((cpumask_t) { {[0 ... CPU_ARRAY_SIZE-1] = ~0UL} })
-#define CPU_MASK_NONE  ((cpumask_t) { {[0 ... CPU_ARRAY_SIZE-1] =  0UL} })
-
-#endif /* __ASM_GENERIC_CPUMASK_ARRAY_H */
diff --git a/include/asm-generic/cpumask_const_reference.h b/include/asm-generic/cpumask_const_reference.h
deleted file mode 100644 (file)
index e98da01..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
-#define __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
-
-struct cpumask_ref {
-       const cpumask_t *val;
-};
-
-typedef const struct cpumask_ref cpumask_const_t;
-
-#define mk_cpumask_const(map)          ((cpumask_const_t){ &(map) })
-#define cpu_isset_const(cpu, map)      cpu_isset(cpu, *(map).val)
-
-#define cpus_and_const(dst,src1,src2)  cpus_and(dst,*(src1).val,*(src2).val)
-#define cpus_or_const(dst,src1,src2)   cpus_or(dst,*(src1).val,*(src2).val)
-
-#define cpus_equal_const(map1, map2)   cpus_equal(*(map1).val, *(map2).val)
-
-#define cpus_copy_const(map1, map2)    bitmap_copy((map1).mask, (map2).val->mask, NR_CPUS)
-
-#define cpus_empty_const(map)          cpus_empty(*(map).val)
-#define cpus_weight_const(map)         cpus_weight(*(map).val)
-#define first_cpu_const(map)           first_cpu(*(map).val)
-#define next_cpu_const(cpu, map)       next_cpu(cpu, *(map).val)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce_const(map)         cpus_coerce(*(map).val)
-#define any_online_cpu_const(map)      any_online_cpu(*(map).val)
-
-#endif /* __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H */
diff --git a/include/asm-generic/cpumask_const_value.h b/include/asm-generic/cpumask_const_value.h
deleted file mode 100644 (file)
index 16ca16d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __ASM_GENERIC_CPUMASK_CONST_VALUE_H
-#define __ASM_GENERIC_CPUMASK_CONST_VALUE_H
-
-typedef const cpumask_t cpumask_const_t;
-
-#define mk_cpumask_const(map)          (map)
-#define cpu_isset_const(cpu, map)      cpu_isset(cpu, map)
-#define cpus_and_const(dst,src1,src2)  cpus_and(dst, src1, src2)
-#define cpus_or_const(dst,src1,src2)   cpus_or(dst, src1, src2)
-#define cpus_equal_const(map1, map2)   cpus_equal(map1, map2)
-#define cpus_empty_const(map)          cpus_empty(map)
-#define cpus_copy_const(map1, map2)    do { map1 = (cpumask_t)map2; } while (0)
-#define cpus_weight_const(map)         cpus_weight(map)
-#define first_cpu_const(map)           first_cpu(map)
-#define next_cpu_const(cpu, map)       next_cpu(cpu, map)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce_const(map)         cpus_coerce(map)
-#define any_online_cpu_const(map)      any_online_cpu(map)
-
-#endif /* __ASM_GENERIC_CPUMASK_CONST_VALUE_H */
diff --git a/include/asm-generic/cpumask_up.h b/include/asm-generic/cpumask_up.h
deleted file mode 100644 (file)
index f55c265..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef __ASM_GENERIC_CPUMASK_UP_H
-#define __ASM_GENERIC_CPUMASK_UP_H
-
-#define cpus_coerce(map)       (map)
-
-#define cpu_set(cpu, map)              do { (void)(cpu); cpus_coerce(map) = 1UL; } while (0)
-#define cpu_clear(cpu, map)            do { (void)(cpu); cpus_coerce(map) = 0UL; } while (0)
-#define cpu_isset(cpu, map)            ((void)(cpu), cpus_coerce(map) != 0UL)
-#define cpu_test_and_set(cpu, map)     ((void)(cpu), test_and_set_bit(0, &(map)))
-
-#define cpus_and(dst, src1, src2)                                      \
-       do {                                                            \
-               if (cpus_coerce(src1) && cpus_coerce(src2))             \
-                       cpus_coerce(dst) = 1UL;                         \
-               else                                                    \
-                       cpus_coerce(dst) = 0UL;                         \
-       } while (0)
-
-#define cpus_or(dst, src1, src2)                                       \
-       do {                                                            \
-               if (cpus_coerce(src1) || cpus_coerce(src2))             \
-                       cpus_coerce(dst) = 1UL;                         \
-               else                                                    \
-                       cpus_coerce(dst) = 0UL;                         \
-       } while (0)
-
-#define cpus_clear(map)                        do { cpus_coerce(map) = 0UL; } while (0)
-
-#define cpus_complement(map)                                           \
-       do {                                                            \
-               cpus_coerce(map) = !cpus_coerce(map);                   \
-       } while (0)
-
-#define cpus_equal(map1, map2)         (cpus_coerce(map1) == cpus_coerce(map2))
-#define cpus_empty(map)                        (cpus_coerce(map) == 0UL)
-#define cpus_addr(map)                 (&(map))
-#define cpus_weight(map)               (cpus_coerce(map) ? 1UL : 0UL)
-#define cpus_shift_right(d, s, n)      do { cpus_coerce(d) = 0UL; } while (0)
-#define cpus_shift_left(d, s, n)       do { cpus_coerce(d) = 0UL; } while (0)
-#define first_cpu(map)                 (cpus_coerce(map) ? 0 : 1)
-#define next_cpu(cpu, map)             1
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_promote(map)                                              \
-       ({                                                              \
-               cpumask_t __tmp__;                                      \
-               cpus_coerce(__tmp__) = map;                             \
-               __tmp__;                                                \
-       })
-#define cpumask_of_cpu(cpu)            ((void)(cpu), cpus_promote(1))
-#define any_online_cpu(map)            (cpus_coerce(map) ? 0 : 1)
-
-/*
- * um, these need to be usable as static initializers
- */
-#define CPU_MASK_ALL   1UL
-#define CPU_MASK_NONE  0UL
-
-#endif /* __ASM_GENERIC_CPUMASK_UP_H */
diff --git a/include/asm-generic/netdump.h b/include/asm-generic/netdump.h
new file mode 100644 (file)
index 0000000..5cf447f
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef _ASM_GENERIC_NETDUMP_H_
+#define _ASM_GENERIC_NETDUMP_H_
+
+/*
+ * linux/include/asm-generic/netdump.h
+ *
+ * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifdef __KERNEL__
+
+#warning netdump is not supported on this platform
+const static int platform_supports_netdump = 0;
+
+static inline int page_is_ram(unsigned long x) { return 0; }
+
+#define platform_timestamp(x) do { (x) = 0; } while (0)  
+
+#define platform_fix_regs() do { } while (0)
+#define platform_init_stack(stackptr) do { } while (0)
+#define platform_cleanup_stack(stackptr) do { } while (0)
+#define platform_start_netdump(stackptr,regs) do { } while (0)
+#define platform_max_pfn() do { int ret = 0; } while (0)
+
+#undef ELF_CORE_COPY_REGS
+#define ELF_CORE_COPY_REGS(x, y) do { struct pt_regs *z; z = (y); } while (0)
+
+#define show_mem() do {} while (0)
+
+#define show_state() do {} while (0)
+
+#define show_regs(x) do { struct pt_regs *z; z = (x); } while (0)
+
+#undef ZERO_PAGE
+static inline struct page *ZERO_PAGE(void *x) { return NULL; }
+
+#undef KM_NETDUMP
+#define KM_NETDUMP 0
+
+#undef kmap_atomic
+#undef kunmap_atomic
+static inline char *kmap_atomic(void *page, int idx)  { return NULL; }
+#define kunmap_atomic(addr, idx)  do { } while (0)
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_GENERIC_NETDUMP_H */
diff --git a/include/asm-generic/relay.h b/include/asm-generic/relay.h
new file mode 100644 (file)
index 0000000..c6d8dea
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef _ASM_GENERIC_RELAY_H
+#define _ASM_GENERIC_RELAY_H
+/*
+ * linux/include/asm-generic/relay.h
+ *
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 2002 - Karim Yaghmour (karim@opersys.com)
+ *
+ * Architecture-independent definitions for relayfs
+ */
+
+#include <linux/relayfs_fs.h>
+
+/**
+ *     get_time_delta - utility function for getting time delta
+ *     @now: pointer to a timeval struct that may be given current time
+ *     @rchan: the channel
+ *
+ *     Returns the time difference between the current time and the buffer
+ *     start time.
+ */
+static inline u32
+get_time_delta(struct timeval *now, struct rchan *rchan)
+{
+       u32 time_delta;
+
+       do_gettimeofday(now);
+       time_delta = calc_time_delta(now, &rchan->buf_start_time);
+
+       return time_delta;
+}
+
+/**
+ *     get_timestamp - utility function for getting a time and TSC pair
+ *     @now: current time
+ *     @tsc: the TSC associated with now
+ *     @rchan: the channel
+ *
+ *     Sets the value pointed to by now to the current time. Value pointed to
+ *     by tsc is not set since there is no generic TSC support.
+ */
+static inline void 
+get_timestamp(struct timeval *now, 
+             u32 *tsc,
+             struct rchan *rchan)
+{
+       do_gettimeofday(now);
+}
+
+/**
+ *     get_time_or_tsc: - Utility function for getting a time or a TSC.
+ *     @now: current time
+ *     @tsc: current TSC
+ *     @rchan: the channel
+ *
+ *     Sets the value pointed to by now to the current time.
+ */
+static inline void 
+get_time_or_tsc(struct timeval *now, 
+               u32 *tsc,
+               struct rchan *rchan)
+{
+       do_gettimeofday(now);
+}
+
+/**
+ *     have_tsc - does this platform have a useable TSC?
+ *
+ *     Returns 0.
+ */
+static inline int 
+have_tsc(void)
+{
+       return 0;
+}
+#endif
diff --git a/include/asm-generic/rmap.h b/include/asm-generic/rmap.h
deleted file mode 100644 (file)
index f743d9f..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef _GENERIC_RMAP_H
-#define _GENERIC_RMAP_H
-/*
- * linux/include/asm-generic/rmap.h
- *
- * Architecture dependent parts of the reverse mapping code,
- * this version should work for most architectures with a
- * 'normal' page table layout.
- *
- * We use the struct page of the page table page to find out
- * the process and full address of a page table entry:
- * - page->mapping points to the process' mm_struct
- * - page->index has the high bits of the address
- * - the lower bits of the address are calculated from the
- *   offset of the page table entry within the page table page
- *
- * For CONFIG_HIGHPTE, we need to represent the address of a pte in a
- * scalar pte_addr_t.  The pfn of the pte's page is shifted left by PAGE_SIZE
- * bits and is then ORed with the byte offset of the pte within its page.
- *
- * For CONFIG_HIGHMEM4G, the pte_addr_t is 32 bits.  20 for the pfn, 12 for
- * the offset.
- *
- * For CONFIG_HIGHMEM64G, the pte_addr_t is 64 bits.  52 for the pfn, 12 for
- * the offset.
- */
-#include <linux/mm.h>
-
-static inline void pgtable_add_rmap(struct page * page, struct mm_struct * mm, unsigned long address)
-{
-#ifdef BROKEN_PPC_PTE_ALLOC_ONE
-       /* OK, so PPC calls pte_alloc() before mem_map[] is setup ... ;( */
-       extern int mem_init_done;
-
-       if (!mem_init_done)
-               return;
-#endif
-       page->mapping = (void *)mm;
-       page->index = address & ~((PTRS_PER_PTE * PAGE_SIZE) - 1);
-       inc_page_state(nr_page_table_pages);
-}
-
-static inline void pgtable_remove_rmap(struct page * page)
-{
-       page->mapping = NULL;
-       page->index = 0;
-       dec_page_state(nr_page_table_pages);
-}
-
-static inline struct mm_struct * ptep_to_mm(pte_t * ptep)
-{
-       struct page * page = kmap_atomic_to_page(ptep);
-       return (struct mm_struct *) page->mapping;
-}
-
-static inline unsigned long ptep_to_address(pte_t * ptep)
-{
-       struct page * page = kmap_atomic_to_page(ptep);
-       unsigned long low_bits;
-       low_bits = ((unsigned long)ptep & (PTRS_PER_PTE*sizeof(pte_t) - 1))
-                       * (PAGE_SIZE/sizeof(pte_t));
-       return page->index + low_bits;
-}
-
-#ifdef CONFIG_HIGHPTE
-static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
-{
-       pte_addr_t paddr;
-       paddr = ((pte_addr_t)page_to_pfn(kmap_atomic_to_page(ptep))) << PAGE_SHIFT;
-       return paddr + (pte_addr_t)((unsigned long)ptep & ~PAGE_MASK);
-}
-#else
-static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
-{
-       return (pte_addr_t)ptep;
-}
-#endif
-
-#ifndef CONFIG_HIGHPTE
-static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
-{
-       return (pte_t *)pte_paddr;
-}
-
-static inline void rmap_ptep_unmap(pte_t *pte)
-{
-       return;
-}
-#endif
-
-#endif /* _GENERIC_RMAP_H */
index c617f38..c293149 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/config.h>
 #include <linux/swap.h>
+#include <linux/vs_memory.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 
@@ -92,7 +93,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
 
        if (rss < freed)
                freed = rss;
-       mm->rss = rss - freed;
+       // mm->rss = rss - freed;
+       vx_rsspages_sub(mm, freed);
        tlb_flush_mmu(tlb, start, end);
 
        /* keep the page table cache within bounds */
diff --git a/include/asm-h8300/aki3068net/machine-depend.h b/include/asm-h8300/aki3068net/machine-depend.h
deleted file mode 100644 (file)
index 510b86b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* AE-3068 board depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#define H8300_TIMER_COUNT_DATA 20000*10/8192
-#define H8300_TIMER_FREQ 20000*1000/8192
-#endif
-
-/* AE-3068 RTL8019AS Config */
-#ifdef H8300_NE_DEFINE
-
-#define NE2000_ADDR            0x200000
-#define NE2000_IRQ              5
-#define        NE2000_BYTE             volatile unsigned short
-
-#define WCRL                    0xfee023
-#define MAR0A                   0xffff20
-#define ETCR0A                  0xffff24
-#define DTCR0A                  0xffff27
-#define MAR0B                   0xffff28
-#define DTCR0B                  0xffff2f
-
-#define H8300_INIT_NE()                  \
-do {                                     \
-       wordlength = 1;                  \
-        outb_p(0x48, ioaddr + EN0_DCFG); \
-} while(0)
-
-#endif
diff --git a/include/asm-h8300/cpumask.h b/include/asm-h8300/cpumask.h
deleted file mode 100644 (file)
index 3b40385..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_H8300_CPUMASK_H
-#define _ASM_H8300_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_H8300_CPUMASK_H */
diff --git a/include/asm-h8300/edosk2674/machine-depend.h b/include/asm-h8300/edosk2674/machine-depend.h
deleted file mode 100644 (file)
index 1e98b40..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* EDOSK2674 board depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#define H8300_TIMER_COUNT_DATA 33000*10/8192
-#define H8300_TIMER_FREQ 33000*1000/8192
-#endif
-
-/* EDOSK-2674R SMSC Network Controler Target Depend impliments */
-#ifdef H8300_SMSC_DEFINE
-
-#define SMSC_BASE 0xf80000
-#define SMSC_IRQ 16
-
-/* sorry quick hack */
-#if defined(outw)
-# undef outw
-#endif
-#define outw(d,a) edosk2674_smsc_outw(d,(volatile unsigned short *)(a))
-#if defined(inw)
-# undef inw
-#endif
-#define inw(a) edosk2674_smsc_inw((volatile unsigned short *)(a))
-#if defined(outsw)
-# undef outsw
-#endif
-#define outsw(a,p,l) edosk2674_smsc_outsw((volatile unsigned short *)(a),p,l)
-#if defined(insw)
-# undef insw
-#endif
-#define insw(a,p,l) edosk2674_smsc_insw((volatile unsigned short *)(a),p,l)
-
-static inline void edosk2674_smsc_outw(
-       unsigned short d,
-       volatile unsigned short *a
-       )
-{
-       *a = (d >> 8) | (d << 8);
-}
-
-static inline unsigned short edosk2674_smsc_inw(
-       volatile unsigned short *a
-       )
-{
-       unsigned short d;
-       d = *a;
-       return (d >> 8) | (d << 8);
-}
-
-static inline void edosk2674_smsc_outsw(
-       volatile unsigned short *a,
-       unsigned short *p,
-       unsigned long l
-       )
-{
-       for (; l != 0; --l, p++)
-               *a = *p;
-}
-
-static inline void edosk2674_smsc_insw(
-       volatile unsigned short *a,
-       unsigned short *p,
-       unsigned long l
-       )
-{
-       for (; l != 0; --l, p++)
-               *p = *a;
-}
-
-#endif
diff --git a/include/asm-h8300/generic/machine-depend.h b/include/asm-h8300/generic/machine-depend.h
deleted file mode 100644 (file)
index 2d78096..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/* machine depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#include <linux/config.h>
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068) || defined(CONFIG_H8S2678)
-#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
-#endif
-
-#if defined(CONFIG_H8_3002) || defined(CONFIG_H83048)
-#define H8300_TIMER_COUNT_DATA  CONFIG_CPU_CLOCK*10/8
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8
-#endif
-
-#endif
-
diff --git a/include/asm-h8300/generic/timer_rate.h b/include/asm-h8300/generic/timer_rate.h
deleted file mode 100644 (file)
index 0f6f419..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <linux/config.h>
-
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068) || defined(CONFIG_H8S2678)
-#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
-#endif
-
-#if defined(H8_3002) || defined(CONFIG_H83048)
-#define H8300_TIMER_COUNT_DATA  CONFIG_CPU_CLOCK*10/8
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8
-#endif
-
-#if !defined(H8300_TIMER_COUNT_DATA)
-#error illigal configuration
-#endif
diff --git a/include/asm-h8300/h8300_ne.h b/include/asm-h8300/h8300_ne.h
deleted file mode 100644 (file)
index c797603..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/****************************************************************************/
-
-/*
- *     h8300_ne.h -- NE2000 in H8/300H Evalution Board.
- *      
- *     (C) Copyright 2002, Yoshinori Sato <ysato@users.sourceforge.jp>
- */
-
-/****************************************************************************/
-#ifndef        h8300ne_h
-#define        h8300ne_h
-/****************************************************************************/
-
-#define H8300_NE_DEFINE
-#include <asm/machine-depend.h>
-#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
-#undef  H8300_NE_DEFINE
-
-/****************************************************************************/
-#endif /* h8300ne_h */
diff --git a/include/asm-h8300/h8300_smsc.h b/include/asm-h8300/h8300_smsc.h
deleted file mode 100644 (file)
index f8fa7f9..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/****************************************************************************/
-
-/*
- *     h8300_smsc.h -- SMSC in H8/300H and H8S Evalution Board.
- *      
- *     (C) Copyright 2003, Yoshinori Sato <ysato@users.sourceforge.jp>
- */
-
-/****************************************************************************/
-#ifndef        h8300smsc_h
-#define        h8300smsc_h
-/****************************************************************************/
-
-/* Such a description is OK ? */
-#define H8300_SMSC_DEFINE
-#include <asm/machine-depend.h>
-#undef  H8300_SMSC_DEFINE
-
-/****************************************************************************/
-#endif /* h8300smsc_h */
diff --git a/include/asm-h8300/h8max/machine-depend.h b/include/asm-h8300/h8max/machine-depend.h
deleted file mode 100644 (file)
index e87d22e..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* H8MAX board depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#define H8300_TIMER_COUNT_DATA 25000*10/8192
-#define H8300_TIMER_FREQ 25000*1000/8192
-#endif
-
-/* H8MAX RTL8019AS Config */
-#ifdef H8300_NE_DEFINE
-
-#define NE2000_ADDR            0x800600
-#define NE2000_IRQ              4
-#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
-#define        NE2000_BYTE             volatile unsigned short
-
-/* sorry quick hack */
-#if defined(outb)
-# undef outb
-#endif
-#define outb(d,a)               h8max_outb((d),(a) - NE2000_ADDR)
-#if defined(inb)
-# undef inb
-#endif
-#define inb(a)                  h8max_inb((a) - NE2000_ADDR)
-#if defined(outb_p)
-# undef outb_p
-#endif
-#define outb_p(d,a)             h8max_outb((d),(a) - NE2000_ADDR)
-#if defined(inb_p)
-# undef inb_p
-#endif
-#define inb_p(a)                h8max_inb((a) - NE2000_ADDR)
-#if defined(outsw)
-# undef outsw
-#endif
-#define outsw(a,p,l)            h8max_outsw((a) - NE2000_ADDR,(unsigned short *)p,l)
-#if defined(insw)
-# undef insw
-#endif
-#define insw(a,p,l)             h8max_insw((a) - NE2000_ADDR,(unsigned short *)p,l)
-#if defined(outsb)
-# undef outsb
-#endif
-#define outsb(a,p,l)            h8max_outsb((a) - NE2000_ADDR,(unsigned char *)p,l)
-#if defined(insb)
-# undef insb
-#endif
-#define insb(a,p,l)             h8max_insb((a) - NE2000_ADDR,(unsigned char *)p,l)
-
-#define H8300_INIT_NE()                  \
-do {                                     \
-       wordlength = 2;                  \
-       h8max_outb(0x49, ioaddr + EN0_DCFG); \
-       SA_prom[14] = SA_prom[15] = 0x57;\
-} while(0)
-
-static inline void h8max_outb(unsigned char d,unsigned char a)
-{
-       *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
-}
-
-static inline unsigned char h8max_inb(unsigned char a)
-{
-       return *(unsigned char *)(NE2000_ADDR + (a << 1) +1);
-}
-
-static inline void h8max_outsw(unsigned char a,unsigned short *p,unsigned long l)
-{
-       unsigned short d;
-       for (; l != 0; --l, p++) {
-               d = (((*p) >> 8) & 0xff) | ((*p) << 8);
-               *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
-       }
-}
-
-static inline void h8max_insw(unsigned char a,unsigned short *p,unsigned long l)
-{
-       unsigned short d;
-       for (; l != 0; --l, p++) {
-               d = *(unsigned short *)(NE2000_ADDR + (a << 1));
-               *p = (d << 8)|((d >> 8) & 0xff);
-       }
-}
-
-static inline void h8max_outsb(unsigned char a,unsigned char *p,unsigned long l)
-{
-       for (; l != 0; --l, p++) {
-               *(unsigned short *)(NE2000_ADDR + (a << 1)) = *p;
-       }
-}
-
-static inline void h8max_insb(unsigned char a,unsigned char *p,unsigned long l)
-{
-       for (; l != 0; --l, p++) {
-               *p = *((unsigned char *)(NE2000_ADDR + (a << 1))+1);
-       }
-}
-
-#endif
diff --git a/include/asm-h8300/init.h b/include/asm-h8300/init.h
deleted file mode 100644 (file)
index 6c90804..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _H8300_INIT_H
-#define _H8300_INIT_H
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-/* For assembly routines */
-#define __INIT         .section        ".text.init",#alloc,#execinstr
-#define __FINIT                .previous
-#define __INITDATA     .section        ".data.init",#alloc,#write
-
-#endif
index 132b0ea..7bc99ea 100644 (file)
@@ -96,6 +96,8 @@ extern unsigned long memory_end;
 
 #endif /* __ASSEMBLY__ */
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _H8300_PAGE_H */
diff --git a/include/asm-h8300/relay.h b/include/asm-h8300/relay.h
new file mode 100644 (file)
index 0000000..34ebfdd
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_H8300_RELAY_H
+#define _ASM_H8300_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index a87720b..f580cf8 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
index 46c0261..f3f4ffe 100644 (file)
@@ -123,6 +123,8 @@ extern int __get_user_bad(void);
 
 #define __copy_from_user(to, from, n) copy_from_user(to, from, n)
 #define __copy_to_user(to, from, n) copy_to_user(to, from, n)
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
 
 #define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
 
diff --git a/include/asm-i386/atomic_kmap.h b/include/asm-i386/atomic_kmap.h
new file mode 100644 (file)
index 0000000..5a1b901
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * atomic_kmap.h: temporary virtual kernel memory mappings
+ *
+ * Copyright (C) 2003 Ingo Molnar <mingo@redhat.com>
+ */
+
+#ifndef _ASM_ATOMIC_KMAP_H
+#define _ASM_ATOMIC_KMAP_H
+
+#ifdef __KERNEL__
+
+#include <linux/config.h>
+#include <asm/tlbflush.h>
+
+#ifdef CONFIG_DEBUG_HIGHMEM
+#define HIGHMEM_DEBUG 1
+#else
+#define HIGHMEM_DEBUG 0
+#endif
+
+extern pte_t *kmap_pte;
+#define kmap_prot PAGE_KERNEL
+#define kmap_prot_nocache PAGE_KERNEL_NOCACHE
+
+#define PKMAP_BASE (0xff000000UL)
+#define NR_SHARED_PMDS ((0xffffffff-PKMAP_BASE+1)/PMD_SIZE)
+
+static inline unsigned long __kmap_atomic_vaddr(enum km_type type)
+{
+       enum fixed_addresses idx;
+
+       idx = type + KM_TYPE_NR*smp_processor_id();
+       return __fix_to_virt(FIX_KMAP_BEGIN + idx);
+}
+
+static inline void *__kmap_atomic_noflush(struct page *page, enum km_type type)
+{
+       enum fixed_addresses idx;
+       unsigned long vaddr;
+
+       idx = type + KM_TYPE_NR*smp_processor_id();
+       vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+       /*
+        * NOTE: entries that rely on some secondary TLB-flush
+        * effect must not be global:
+        */
+       set_pte(kmap_pte-idx, mk_pte(page, PAGE_KERNEL));
+
+       return (void*) vaddr;
+}
+
+static inline void *__kmap_atomic(struct page *page, enum km_type type)
+{
+       enum fixed_addresses idx;
+       unsigned long vaddr;
+
+       idx = type + KM_TYPE_NR*smp_processor_id();
+       vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+#if HIGHMEM_DEBUG
+       BUG_ON(!pte_none(*(kmap_pte-idx)));
+#else
+       /*
+        * Performance optimization - do not flush if the new
+        * pte is the same as the old one:
+        */
+       if (pte_val(*(kmap_pte-idx)) == pte_val(mk_pte(page, kmap_prot)))
+               return (void *) vaddr;
+#endif
+       set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
+       __flush_tlb_one(vaddr);
+
+       return (void*) vaddr;
+}
+
+static inline void __kunmap_atomic(void *kvaddr, enum km_type type)
+{
+#if HIGHMEM_DEBUG
+       unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
+       enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
+
+       BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx));
+       /*
+        * force other mappings to Oops if they'll try to access
+        * this pte without first remap it
+        */
+       pte_clear(kmap_pte-idx);
+       __flush_tlb_one(vaddr);
+#endif
+}
+
+#define __kunmap_atomic_type(type) \
+               __kunmap_atomic((void *)__kmap_atomic_vaddr(type), (type))
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_ATOMIC_KMAP_H */
index 96e4b2d..04b4d2a 100644 (file)
@@ -25,7 +25,7 @@ asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsign
  * better 64-bit) boundary
  */
 
-asmlinkage unsigned int csum_partial_copy_generic( const char *src, char *dst, int len, int sum,
+asmlinkage unsigned int direct_csum_partial_copy_generic( const char *src, char *dst, int len, int sum,
                                                   int *src_err_ptr, int *dst_err_ptr);
 
 /*
@@ -39,14 +39,19 @@ static __inline__
 unsigned int csum_partial_copy_nocheck ( const char *src, char *dst,
                                        int len, int sum)
 {
-       return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
+       /*
+        * The direct function is OK for kernel-space => kernel-space copies:
+        */
+       return direct_csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
 }
 
 static __inline__
 unsigned int csum_partial_copy_from_user ( const char __user *src, char *dst,
                                                int len, int sum, int *err_ptr)
 {
-       return csum_partial_copy_generic ( (__force char *)src, dst, len, sum, err_ptr, NULL);
+       if (copy_from_user(dst, src, len))
+               *err_ptr = -EFAULT;
+       return csum_partial(dst, len, sum);
 }
 
 /*
@@ -172,13 +177,28 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
  *     Copy and checksum to user
  */
 #define HAVE_CSUM_COPY_USER
-static __inline__ unsigned int csum_and_copy_to_user(const char *src, 
+static __inline__ unsigned int direct_csum_and_copy_to_user(const char *src, 
                                                     char __user *dst,
                                                     int len, int sum, 
                                                     int *err_ptr)
 {
        if (access_ok(VERIFY_WRITE, dst, len))
-               return csum_partial_copy_generic(src, (__force char *)dst, len, sum, NULL, err_ptr);
+               return direct_csum_partial_copy_generic(src, dst, len, sum, NULL, err_ptr);
+
+       if (len)
+               *err_ptr = -EFAULT;
+
+       return -1; /* invalid checksum */
+}
+
+static __inline__ unsigned int csum_and_copy_to_user(const char *src, char __user *dst,
+                                   int len, int sum, int *err_ptr)
+{
+       if (access_ok(VERIFY_WRITE, dst, len)) {
+               if (copy_to_user(dst, src, len))
+                       *err_ptr = -EFAULT;
+               return csum_partial(src, len, sum);
+       }
 
        if (len)
                *err_ptr = -EFAULT;
diff --git a/include/asm-i386/cpumask.h b/include/asm-i386/cpumask.h
deleted file mode 100644 (file)
index 8bf5a82..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_I386_CPUMASK_H
-#define _ASM_I386_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_I386_CPUMASK_H */
diff --git a/include/asm-i386/crash.h b/include/asm-i386/crash.h
new file mode 100644 (file)
index 0000000..b6ae4f3
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef _ASM_I386_CRASH_H
+#define _ASM_I386_CRASH_H
+
+/*
+ * linux/include/asm-i386/crash.h
+ *
+ * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifdef __KERNEL__
+
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <asm/mmzone.h>
+
+extern int page_is_ram(unsigned long);
+
+static inline void *
+map_virtual(u64 offset, struct page **pp)
+{
+       struct page *page;
+       unsigned long pfn;
+       void *vaddr;
+
+        pfn = (unsigned long)(offset >> PAGE_SHIFT);
+
+        if (!page_is_ram(pfn)) {
+               printk(KERN_INFO
+                   "crash memory driver: !page_is_ram(pfn: %lx)\n", pfn);
+                return NULL;
+       }
+
+       if (!pfn_valid(pfn)) {
+               printk(KERN_INFO
+                   "crash memory driver: invalid pfn: %lx )\n", pfn);
+               return NULL;
+       }
+
+       page = pfn_to_page(pfn);
+
+       vaddr = kmap(page);
+       if (!vaddr) {
+               printk(KERN_INFO
+                   "crash memory driver: pfn: %lx kmap(page: %lx) failed\n", 
+                       pfn, (unsigned long)page);
+               return NULL;
+       }
+
+       *pp = page;
+       return (vaddr + (offset & (PAGE_SIZE-1)));
+}
+
+static inline void unmap_virtual(struct page *page) 
+{ 
+       kunmap(page);
+}
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_I386_CRASH_H */
index 5d126f7..942c279 100644 (file)
@@ -21,6 +21,13 @@ struct Xgt_desc_struct {
 
 extern struct Xgt_desc_struct idt_descr, cpu_gdt_descr[NR_CPUS];
 
+extern void trap_init_virtual_IDT(void);
+extern void trap_init_virtual_GDT(void);
+
+asmlinkage int system_call(void);
+asmlinkage void lcall7(void);
+asmlinkage void lcall27(void);
+
 #define load_TR_desc() __asm__ __volatile__("ltr %%ax"::"a" (GDT_ENTRY_TSS*8))
 #define load_LDT_desc() __asm__ __volatile__("lldt %%ax"::"a" (GDT_ENTRY_LDT*8))
 
@@ -30,6 +37,7 @@ extern struct Xgt_desc_struct idt_descr, cpu_gdt_descr[NR_CPUS];
  */
 extern struct desc_struct default_ldt[];
 extern void set_intr_gate(unsigned int irq, void * addr);
+extern void set_trap_gate(unsigned int n, void *addr);
 
 #define _set_tssldt_desc(n,addr,limit,type) \
 __asm__ __volatile__ ("movw %w3,0(%2)\n\t" \
@@ -44,8 +52,7 @@ __asm__ __volatile__ ("movw %w3,0(%2)\n\t" \
 
 static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, void *addr)
 {
-       _set_tssldt_desc(&cpu_gdt_table[cpu][entry], (int)addr,
-               offsetof(struct tss_struct, __cacheline_filler) - 1, 0x89);
+       _set_tssldt_desc(&cpu_gdt_table[cpu][entry], (int)addr, 235, 0x89);
 }
 
 #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
@@ -91,39 +98,30 @@ static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
 #undef C
 }
 
-static inline void clear_LDT(void)
+extern struct page *default_ldt_page;
+extern void load_LDT_nolock(mm_context_t *pc, int cpu);
+
+static inline void load_LDT(mm_context_t *pc)
 {
        int cpu = get_cpu();
-
-       set_ldt_desc(cpu, &default_ldt[0], 5);
-       load_LDT_desc();
+       load_LDT_nolock(pc, cpu);
        put_cpu();
 }
 
-/*
- * load one particular LDT into the current CPU
- */
-static inline void load_LDT_nolock(mm_context_t *pc, int cpu)
+static inline void set_user_cs(struct desc_struct *desc, unsigned long limit)
 {
-       void *segments = pc->ldt;
-       int count = pc->size;
-
-       if (likely(!count)) {
-               segments = &default_ldt[0];
-               count = 5;
-       }
-               
-       set_ldt_desc(cpu, segments, count);
-       load_LDT_desc();
+       limit = (limit - 1) / PAGE_SIZE;
+       desc->a = limit & 0xffff;
+       desc->b = (limit & 0xf0000) | 0x00c0fb00;
 }
 
-static inline void load_LDT(mm_context_t *pc)
-{
-       int cpu = get_cpu();
-       load_LDT_nolock(pc, cpu);
-       put_cpu();
-}
+#define load_user_cs_desc(cpu, mm) \
+       cpu_gdt_table[(cpu)][GDT_ENTRY_DEFAULT_USER_CS] = (mm)->context.user_cs
 
-#endif /* !__ASSEMBLY__ */
+extern void arch_add_exec_range(struct mm_struct *mm, unsigned long limit);
+extern void arch_remove_exec_range(struct mm_struct *mm, unsigned long limit);
+extern void arch_flush_exec_range(struct mm_struct *mm);
 
+
+#endif /* !__ASSEMBLY__ */
 #endif
diff --git a/include/asm-i386/dump.h b/include/asm-i386/dump.h
new file mode 100644 (file)
index 0000000..a0921e9
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Kernel header file for Linux crash dumps.
+ *
+ * Created by: Matt Robinson (yakker@sgi.com)
+ *
+ * Copyright 1999 Silicon Graphics, Inc. All rights reserved.
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/* This header file holds the architecture specific crash dump header */
+#ifndef _ASM_DUMP_H
+#define _ASM_DUMP_H
+
+/* necessary header files */
+#include <asm/ptrace.h>
+#include <asm/page.h>
+#include <linux/threads.h>
+#include <linux/mm.h>
+
+/* definitions */
+#define DUMP_ASM_MAGIC_NUMBER  0xdeaddeadULL   /* magic number            */
+#define DUMP_ASM_VERSION_NUMBER        0x3     /* version number          */
+
+/* max number of cpus */
+#define DUMP_MAX_NUM_CPUS 32
+
+/*
+ * Structure: __dump_header_asm
+ *  Function: This is the header for architecture-specific stuff.  It
+ *            follows right after the dump header.
+ */
+struct __dump_header_asm {
+       /* the dump magic number -- unique to verify dump is valid */
+       u64             dha_magic_number;
+
+       /* the version number of this dump */
+       u32             dha_version;
+
+       /* the size of this header (in case we can't read it) */
+       u32             dha_header_size;
+
+       /* the esp for i386 systems */
+       u32             dha_esp;
+
+       /* the eip for i386 systems */
+       u32             dha_eip;
+
+       /* the dump registers */
+       struct pt_regs  dha_regs;
+
+       /* smp specific */
+       u32             dha_smp_num_cpus;
+       u32             dha_dumping_cpu;
+       struct pt_regs  dha_smp_regs[DUMP_MAX_NUM_CPUS];
+       u32             dha_smp_current_task[DUMP_MAX_NUM_CPUS];
+       u32             dha_stack[DUMP_MAX_NUM_CPUS];
+       u32             dha_stack_ptr[DUMP_MAX_NUM_CPUS];
+} __attribute__((packed));
+
+#ifdef __KERNEL__
+
+extern struct __dump_header_asm dump_header_asm;
+
+#ifdef CONFIG_SMP
+extern cpumask_t irq_affinity[];
+extern int (*dump_ipi_function_ptr)(struct pt_regs *);
+extern void dump_send_ipi(void);
+#else
+#define dump_send_ipi() do { } while(0)
+#endif
+
+static inline void get_current_regs(struct pt_regs *regs)
+{
+       __asm__ __volatile__("movl %%ebx,%0" : "=m"(regs->ebx));
+       __asm__ __volatile__("movl %%ecx,%0" : "=m"(regs->ecx));
+       __asm__ __volatile__("movl %%edx,%0" : "=m"(regs->edx));
+       __asm__ __volatile__("movl %%esi,%0" : "=m"(regs->esi));
+       __asm__ __volatile__("movl %%edi,%0" : "=m"(regs->edi));
+       __asm__ __volatile__("movl %%ebp,%0" : "=m"(regs->ebp));
+       __asm__ __volatile__("movl %%eax,%0" : "=m"(regs->eax));
+       __asm__ __volatile__("movl %%esp,%0" : "=m"(regs->esp));
+       __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(regs->xss));
+       __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(regs->xcs));
+       __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(regs->xds));
+       __asm__ __volatile__("movw %%es, %%ax;" :"=a"(regs->xes));
+       __asm__ __volatile__("pushfl; popl %0" :"=m"(regs->eflags));
+       regs->eip = (unsigned long)current_text_addr();
+}
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_DUMP_H */
index a53f1fc..c960aa0 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/user.h>
 #include <asm/processor.h>
 #include <asm/system.h>                /* for savesegment */
+#include <asm/desc.h>
 
 #include <linux/utsname.h>
 
@@ -133,15 +134,22 @@ extern int dump_task_extended_fpu (struct task_struct *, struct user_fxsr_struct
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
 #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
 
-#define VSYSCALL_BASE  (__fix_to_virt(FIX_VSYSCALL))
-#define VSYSCALL_EHDR  ((const struct elfhdr *) VSYSCALL_BASE)
-#define VSYSCALL_ENTRY ((unsigned long) &__kernel_vsyscall)
 extern void __kernel_vsyscall;
-
-#define ARCH_DLINFO                                            \
-do {                                                           \
-               NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY);        \
-               NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL_BASE);    \
+#define VSYSCALL_BASE  ((unsigned long)current->mm->context.vdso)
+#define VSYSCALL_EHDR  ((const struct elfhdr *) VSYSCALL_BASE)
+#define VSYSCALL_OFFSET        ((unsigned long) &__kernel_vsyscall)
+#define VSYSCALL_ENTRY (VSYSCALL_BASE + VSYSCALL_OFFSET)
+
+/* kernel-internal fixmap address: */
+#define __VSYSCALL_BASE        (__fix_to_virt(FIX_VSYSCALL))
+#define __VSYSCALL_EHDR        ((const struct elfhdr *) __VSYSCALL_BASE)
+
+#define ARCH_DLINFO                                                    \
+do {                                                                   \
+       if (VSYSCALL_BASE) {                                            \
+               NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY);                \
+               NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL_BASE);            \
+       }                                                               \
 } while (0)
 
 /*
@@ -152,15 +160,15 @@ do {                                                              \
  * Dumping its extra ELF program headers includes all the other information
  * a debugger needs to easily find how the vsyscall DSO was being used.
  */
-#define ELF_CORE_EXTRA_PHDRS           (VSYSCALL_EHDR->e_phnum)
+#define ELF_CORE_EXTRA_PHDRS           (__VSYSCALL_EHDR->e_phnum)
 #define ELF_CORE_WRITE_EXTRA_PHDRS                                           \
 do {                                                                         \
        const struct elf_phdr *const vsyscall_phdrs =                         \
-               (const struct elf_phdr *) (VSYSCALL_BASE                      \
-                                          + VSYSCALL_EHDR->e_phoff);         \
+               (const struct elf_phdr *) (__VSYSCALL_BASE                    \
+                                          + __VSYSCALL_EHDR->e_phoff);       \
        int i;                                                                \
        Elf32_Off ofs = 0;                                                    \
-       for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
+       for (i = 0; i < __VSYSCALL_EHDR->e_phnum; ++i) {                      \
                struct elf_phdr phdr = vsyscall_phdrs[i];                     \
                if (phdr.p_type == PT_LOAD) {                                 \
                        BUG_ON(ofs != 0);                                     \
@@ -178,10 +186,10 @@ do {                                                                            \
 #define ELF_CORE_WRITE_EXTRA_DATA                                            \
 do {                                                                         \
        const struct elf_phdr *const vsyscall_phdrs =                         \
-               (const struct elf_phdr *) (VSYSCALL_BASE                      \
-                                          + VSYSCALL_EHDR->e_phoff);         \
+               (const struct elf_phdr *) (__VSYSCALL_BASE                    \
+                                          + __VSYSCALL_EHDR->e_phoff);       \
        int i;                                                                \
-       for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
+       for (i = 0; i < __VSYSCALL_EHDR->e_phnum; ++i) {                      \
                if (vsyscall_phdrs[i].p_type == PT_LOAD)                      \
                        DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr,        \
                                   PAGE_ALIGN(vsyscall_phdrs[i].p_memsz));    \
@@ -190,4 +198,10 @@ do {                                                                             \
 
 #endif
 
+#define __HAVE_ARCH_RANDOMIZE_BRK
+extern void randomize_brk(unsigned long old_brk);
+
+#define __HAVE_ARCH_VSYSCALL
+extern void map_vsyscall(void);
+
 #endif
index 511cde9..6fb3e35 100644 (file)
@@ -21,6 +21,7 @@
 #define O_DIRECTORY    0200000 /* must be a directory */
 #define O_NOFOLLOW     0400000 /* don't follow links */
 #define O_NOATIME      01000000
+#define O_ATOMICLOOKUP 02000000 /* do atomic file lookup */
 
 #define F_DUPFD                0       /* dup */
 #define F_GETFD                1       /* get close_on_exec */
index 07d4c64..df4ae58 100644 (file)
 #include <asm/acpi.h>
 #include <asm/apicdef.h>
 #include <asm/page.h>
-#ifdef CONFIG_HIGHMEM
 #include <linux/threads.h>
 #include <asm/kmap_types.h>
-#endif
 
 /*
  * Here we define all the compile-time 'special' virtual
  * addresses. The point is to have a constant address at
  * compile time, but to set the physical address only
- * in the boot process. We allocate these special addresses
- * from the end of virtual memory (0xfffff000) backwards.
+ * in the boot process. We allocate these special  addresses
+ * from the end of virtual memory (0xffffe000) backwards.
  * Also this lets us do fail-safe vmalloc(), we
  * can guarantee that these special addresses and
  * vmalloc()-ed addresses never overlap.
  * TLB entries of such buffers will not be flushed across
  * task switches.
  */
+
+/*
+ * on UP currently we will have no trace of the fixmap mechanizm,
+ * no page table allocations, etc. This might change in the
+ * future, say framebuffers for the console driver(s) could be
+ * fix-mapped?
+ */
 enum fixed_addresses {
        FIX_HOLE,
        FIX_VSYSCALL,
 #ifdef CONFIG_X86_LOCAL_APIC
        FIX_APIC_BASE,  /* local (CPU) APIC) -- required for SMP or not */
+#else
+       FIX_VSTACK_HOLE_1,
 #endif
 #ifdef CONFIG_X86_IO_APIC
        FIX_IO_APIC_BASE_0,
@@ -57,16 +64,21 @@ enum fixed_addresses {
        FIX_LI_PCIA,    /* Lithium PCI Bridge A */
        FIX_LI_PCIB,    /* Lithium PCI Bridge B */
 #endif
-#ifdef CONFIG_X86_F00F_BUG
-       FIX_F00F_IDT,   /* Virtual mapping for IDT */
-#endif
+       FIX_IDT,
+       FIX_GDT_1,
+       FIX_GDT_0,
+       FIX_TSS_3,
+       FIX_TSS_2,
+       FIX_TSS_1,
+       FIX_TSS_0,
+       FIX_ENTRY_TRAMPOLINE_1,
+       FIX_ENTRY_TRAMPOLINE_0,
 #ifdef CONFIG_X86_CYCLONE_TIMER
        FIX_CYCLONE_TIMER, /*cyclone timer register*/
+       FIX_VSTACK_HOLE_2,
 #endif 
-#ifdef CONFIG_HIGHMEM
        FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
        FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
-#endif
 #ifdef CONFIG_ACPI_BOOT
        FIX_ACPI_BEGIN,
        FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
@@ -98,12 +110,15 @@ extern void __set_fixmap (enum fixed_addresses idx,
                __set_fixmap(idx, 0, __pgprot(0))
 
 /*
- * used by vmalloc.c.
+ * used by vmalloc.c and various other places.
  *
  * Leave one empty page between vmalloc'ed areas and
  * the start of the fixmap.
+ *
+ * IMPORTANT: we have to align FIXADDR_TOP so that the virtual stack
+ * is THREAD_SIZE aligned.
  */
-#define FIXADDR_TOP    (0xfffff000UL)
+#define FIXADDR_TOP    (0xffffe000UL & ~(THREAD_SIZE-1))
 #define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
 #define FIXADDR_START  (FIXADDR_TOP - __FIXADDR_SIZE)
 
index 454b23f..baf5b5a 100644 (file)
 #include <linux/threads.h>
 #include <asm/kmap_types.h>
 #include <asm/tlbflush.h>
+#include <asm/atomic_kmap.h>
 
 /* declarations for highmem.c */
 extern unsigned long highstart_pfn, highend_pfn;
 
-extern pte_t *kmap_pte;
-extern pgprot_t kmap_prot;
 extern pte_t *pkmap_page_table;
-
-extern void kmap_init(void);
+extern void kmap_init(void) __init;
 
 /*
  * Right now we initialize only a single pte table. It can be extended
  * easily, subsequent pte tables have to be allocated in one physical
  * chunk of RAM.
  */
-#if NR_CPUS <= 32
-#define PKMAP_BASE (0xff800000UL)
-#else
-#define PKMAP_BASE (0xff600000UL)
-#endif
 #ifdef CONFIG_X86_PAE
 #define LAST_PKMAP 512
 #else
@@ -60,6 +53,7 @@ extern void FASTCALL(kunmap_high(struct page *page));
 void *kmap(struct page *page);
 void kunmap(struct page *page);
 void *kmap_atomic(struct page *page, enum km_type type);
+void *kmap_atomic_nocache_pfn(unsigned long pfn, enum km_type type);
 void kunmap_atomic(void *kvaddr, enum km_type type);
 struct page *kmap_atomic_to_page(void *ptr);
 
diff --git a/include/asm-i386/init.h b/include/asm-i386/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
index 5649b4a..d1a4dd6 100644 (file)
@@ -31,7 +31,6 @@ extern int can_request_irq(unsigned int, unsigned long flags);
 #define ARCH_HAS_NMI_WATCHDOG          /* See include/linux/nmi.h */
 #endif
 
-#ifdef CONFIG_4KSTACKS
 /*
  * per-CPU IRQ handling contexts (thread information and stack)
  */
@@ -46,9 +45,6 @@ extern union irq_ctx *softirq_ctx[NR_CPUS];
 extern void irq_ctx_init(int cpu);
 
 #define __ARCH_HAS_DO_SOFTIRQ
-#else
-#define irq_ctx_init(cpu) do { ; } while (0)
-#endif
 
 struct irqaction;
 struct pt_regs;
index 6886a0c..ca46a62 100644 (file)
@@ -2,30 +2,37 @@
 #define _ASM_KMAP_TYPES_H
 
 #include <linux/config.h>
-
-#ifdef CONFIG_DEBUG_HIGHMEM
-# define D(n) __KM_FENCE_##n ,
-#else
-# define D(n)
-#endif
+#include <linux/thread_info.h>
 
 enum km_type {
-D(0)   KM_BOUNCE_READ,
-D(1)   KM_SKB_SUNRPC_DATA,
-D(2)   KM_SKB_DATA_SOFTIRQ,
-D(3)   KM_USER0,
-D(4)   KM_USER1,
-D(5)   KM_BIO_SRC_IRQ,
-D(6)   KM_BIO_DST_IRQ,
-D(7)   KM_PTE0,
-D(8)   KM_PTE1,
-D(9)   KM_IRQ0,
-D(10)  KM_IRQ1,
-D(11)  KM_SOFTIRQ0,
-D(12)  KM_SOFTIRQ1,
-D(13)  KM_TYPE_NR
-};
+       /*
+        * IMPORTANT: don't move these 3 entries, be wary when adding entries,
+        * the 4G/4G virtual stack must be THREAD_SIZE aligned on each cpu.
+        */
+       KM_BOUNCE_READ,
+       KM_VSTACK_BASE,
+       KM_VSTACK_TOP = KM_VSTACK_BASE + STACK_PAGE_COUNT-1,
 
-#undef D
+       KM_LDT_PAGE15,
+       KM_LDT_PAGE0 = KM_LDT_PAGE15 + 16-1,
+       KM_USER_COPY,
+       KM_VSTACK_HOLE,
+       KM_SKB_SUNRPC_DATA,
+       KM_SKB_DATA_SOFTIRQ,
+       KM_USER0,
+       KM_USER1,
+       KM_BIO_SRC_IRQ,
+       KM_BIO_DST_IRQ,
+       KM_PTE0,
+       KM_PTE1,
+       KM_IRQ0,
+       KM_IRQ1,
+       KM_SOFTIRQ0,
+       KM_SOFTIRQ1,
+       KM_NETDUMP,
+       KM_UNUSED,
+       KM_TYPE_NR,
+       KM_DUMP
+};
 
 #endif
index 881c63c..0bcc6f1 100644 (file)
@@ -48,6 +48,7 @@
 #define INVALIDATE_TLB_VECTOR  0xfd
 #define RESCHEDULE_VECTOR      0xfc
 #define CALL_FUNCTION_VECTOR   0xfb
+#define DUMP_VECTOR            0xfa
 
 #define THERMAL_APIC_VECTOR    0xf0
 /*
diff --git a/include/asm-i386/mach-pc9800/apm.h b/include/asm-i386/mach-pc9800/apm.h
deleted file mode 100644 (file)
index 54a8ab2..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *  include/asm-i386/mach-pc9800/apm.h
- *
- *  Machine specific APM BIOS functions for NEC PC9800.
- *  Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp>
- */
-
-#ifndef _ASM_APM_H
-#define _ASM_APM_H
-
-#include <linux/apm_bios.h>
-
-#ifdef APM_ZERO_SEGS
-#      define APM_DO_ZERO_SEGS \
-               "pushl %%ds\n\t" \
-               "pushl %%es\n\t" \
-               "xorl %%edx, %%edx\n\t" \
-               "mov %%dx, %%ds\n\t" \
-               "mov %%dx, %%es\n\t" \
-               "mov %%dx, %%fs\n\t" \
-               "mov %%dx, %%gs\n\t"
-#      define APM_DO_POP_SEGS \
-               "popl %%es\n\t" \
-               "popl %%ds\n\t"
-#else
-#      define APM_DO_ZERO_SEGS
-#      define APM_DO_POP_SEGS
-#endif
-
-static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
-                                       u32 *eax, u32 *ebx, u32 *ecx,
-                                       u32 *edx, u32 *esi)
-{
-       /*
-        * N.B. We do NOT need a cld after the BIOS call
-        * because we always save and restore the flags.
-        */
-       __asm__ __volatile__(APM_DO_ZERO_SEGS
-               "pushl %%edi\n\t"
-               "pushl %%ebp\n\t"
-               "pushfl\n\t"
-               "lcall *%%cs:apm_bios_entry\n\t"
-               "setc %%al\n\t"
-               "popl %%ebp\n\t"
-               "popl %%edi\n\t"
-               APM_DO_POP_SEGS
-               : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx),
-                 "=S" (*esi)
-               : "a" (func), "b" (ebx_in), "c" (ecx_in)
-               : "memory", "cc");
-}
-
-static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
-                                               u32 ecx_in, u32 *eax)
-{
-       int     cx, dx, si;
-       u8      error;
-
-       /*
-        * N.B. We do NOT need a cld after the BIOS call
-        * because we always save and restore the flags.
-        */
-       __asm__ __volatile__(APM_DO_ZERO_SEGS
-               "pushl %%edi\n\t"
-               "pushl %%ebp\n\t"
-               "pushfl\n\t"
-               "lcall *%%cs:apm_bios_entry\n\t"
-               "setc %%bl\n\t"
-               "popl %%ebp\n\t"
-               "popl %%edi\n\t"
-               APM_DO_POP_SEGS
-               : "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx),
-                 "=S" (si)
-               : "a" (func), "b" (ebx_in), "c" (ecx_in)
-               : "memory", "cc");
-       if (func == APM_FUNC_VERSION)
-               *eax = (*eax & 0xff00) | ((*eax & 0x00f0) >> 4);
-
-       return error;
-}
-
-#endif /* _ASM_APM_H */
diff --git a/include/asm-i386/mach-pc9800/bios_ebda.h b/include/asm-i386/mach-pc9800/bios_ebda.h
deleted file mode 100644 (file)
index 4e9e064..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _MACH_BIOS_EBDA_H
-#define _MACH_BIOS_EBDA_H
-
-/*
- * PC-9800 has no EBDA.
- * Its BIOS uses 0x40E for other purpose,
- * Not pointer to 4K EBDA area.
- */
-static inline unsigned int get_bios_ebda(void)
-{
-       return 0;       /* 0 means none */
-}
-
-#endif /* _MACH_BIOS_EBDA_H */
diff --git a/include/asm-i386/mach-pc9800/do_timer.h b/include/asm-i386/mach-pc9800/do_timer.h
deleted file mode 100644 (file)
index 0aefe08..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* defines for inline arch setup functions */
-
-#include <asm/apic.h>
-
-/**
- * do_timer_interrupt_hook - hook into timer tick
- * @regs:      standard registers from interrupt
- *
- * Description:
- *     This hook is called immediately after the timer interrupt is ack'd.
- *     It's primary purpose is to allow architectures that don't possess
- *     individual per CPU clocks (like the CPU APICs supply) to broadcast the
- *     timer interrupt as a means of triggering reschedules etc.
- **/
-
-static inline void do_timer_interrupt_hook(struct pt_regs *regs)
-{
-       do_timer(regs);
-/*
- * In the SMP case we use the local APIC timer interrupt to do the
- * profiling, except when we simulate SMP mode on a uniprocessor
- * system, in that case we have to call the local interrupt handler.
- */
-#ifndef CONFIG_X86_LOCAL_APIC
-       x86_do_profile(regs);
-#else
-       if (!using_apic_timer)
-               smp_local_timer_interrupt(regs);
-#endif
-}
-
-
-/* you can safely undefine this if you don't have the Neptune chipset */
-
-#define BUGGY_NEPTUN_TIMER
-
-/**
- * do_timer_overflow - process a detected timer overflow condition
- * @count:     hardware timer interrupt count on overflow
- *
- * Description:
- *     This call is invoked when the jiffies count has not incremented but
- *     the hardware timer interrupt has.  It means that a timer tick interrupt
- *     came along while the previous one was pending, thus a tick was missed
- **/
-static inline int do_timer_overflow(int count)
-{
-       int i;
-
-       spin_lock(&i8259A_lock);
-       /*
-        * This is tricky when I/O APICs are used;
-        * see do_timer_interrupt().
-        */
-       i = inb(0x00);
-       spin_unlock(&i8259A_lock);
-       
-       /* assumption about timer being IRQ0 */
-       if (i & 0x01) {
-               /*
-                * We cannot detect lost timer interrupts ... 
-                * well, that's why we call them lost, don't we? :)
-                * [hmm, on the Pentium and Alpha we can ... sort of]
-                */
-               count -= LATCH;
-       } else {
-#ifdef BUGGY_NEPTUN_TIMER
-               /*
-                * for the Neptun bug we know that the 'latch'
-                * command doesn't latch the high and low value
-                * of the counter atomically. Thus we have to 
-                * substract 256 from the counter 
-                * ... funny, isnt it? :)
-                */
-               
-               count -= 256;
-#else
-               printk("do_slow_gettimeoffset(): hardware timer problem?\n");
-#endif
-       }
-       return count;
-}
diff --git a/include/asm-i386/mach-pc9800/io_ports.h b/include/asm-i386/mach-pc9800/io_ports.h
deleted file mode 100644 (file)
index 4e60742..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *  arch/i386/mach-pc9800/io_ports.h
- *
- *  Machine specific IO port address definition for PC-9800.
- *  Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_IO_PORTS_H
-#define _MACH_IO_PORTS_H
-
-/* i8253A PIT registers */
-#define PIT_MODE               0x77
-#define PIT_CH0                        0x71
-#define PIT_CH2                        0x75
-
-/* i8259A PIC registers */
-#define PIC_MASTER_CMD         0x00
-#define PIC_MASTER_IMR         0x02
-#define PIC_MASTER_ISR         PIC_MASTER_CMD
-#define PIC_MASTER_POLL                PIC_MASTER_ISR
-#define PIC_MASTER_OCW3                PIC_MASTER_ISR
-#define PIC_SLAVE_CMD          0x08
-#define PIC_SLAVE_IMR          0x0a
-
-/* i8259A PIC related values */
-#define PIC_CASCADE_IR         7
-#define MASTER_ICW4_DEFAULT    0x1d
-#define SLAVE_ICW4_DEFAULT     0x09
-#define PIC_ICW4_AEOI          0x02
-
-#endif /* !_MACH_IO_PORTS_H */
diff --git a/include/asm-i386/mach-pc9800/irq_vectors.h b/include/asm-i386/mach-pc9800/irq_vectors.h
deleted file mode 100644 (file)
index 8d9a0fa..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * This file should contain #defines for all of the interrupt vector
- * numbers used by this architecture.
- *
- * In addition, there are some standard defines:
- *
- *     FIRST_EXTERNAL_VECTOR:
- *             The first free place for external interrupts
- *
- *     SYSCALL_VECTOR:
- *             The IRQ vector a syscall makes the user to kernel transition
- *             under.
- *
- *     TIMER_IRQ:
- *             The IRQ number the timer interrupt comes in at.
- *
- *     NR_IRQS:
- *             The total number of interrupt vectors (including all the
- *             architecture specific interrupts) needed.
- *
- *     NR_IRQ_VECTORS:
- *             The total number of IO APIC vector inputs
- *
- */                    
-#ifndef _ASM_IRQ_VECTORS_H
-#define _ASM_IRQ_VECTORS_H
-
-/*
- * IDT vectors usable for external interrupt sources start
- * at 0x20:
- */
-#define FIRST_EXTERNAL_VECTOR  0x20
-
-#define SYSCALL_VECTOR         0x80
-
-/*
- * Vectors 0x20-0x2f are used for ISA interrupts.
- */
-
-/*
- * Special IRQ vectors used by the SMP architecture, 0xf0-0xff
- *
- *  some of the following vectors are 'rare', they are merged
- *  into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
- *  TLB, reschedule and local APIC vectors are performance-critical.
- *
- *  Vectors 0xf0-0xfa are free (reserved for future Linux use).
- */
-#define SPURIOUS_APIC_VECTOR   0xff
-#define ERROR_APIC_VECTOR      0xfe
-#define INVALIDATE_TLB_VECTOR  0xfd
-#define RESCHEDULE_VECTOR      0xfc
-#define CALL_FUNCTION_VECTOR   0xfb
-
-#define THERMAL_APIC_VECTOR    0xf0
-/*
- * Local APIC timer IRQ vector is on a different priority level,
- * to work around the 'lost local interrupt if more than 2 IRQ
- * sources per level' errata.
- */
-#define LOCAL_TIMER_VECTOR     0xef
-
-/*
- * First APIC vector available to drivers: (vectors 0x30-0xee)
- * we start at 0x31 to spread out vectors evenly between priority
- * levels. (0x80 is the syscall vector)
- */
-#define FIRST_DEVICE_VECTOR    0x31
-#define FIRST_SYSTEM_VECTOR    0xef
-
-#define TIMER_IRQ 0
-
-/*
- * 16 8259A IRQ's, 208 potential APIC interrupt sources.
- * Right now the APIC is mostly only used for SMP.
- * 256 vectors is an architectural limit. (we can have
- * more than 256 devices theoretically, but they will
- * have to use shared interrupts)
- * Since vectors 0x00-0x1f are used/reserved for the CPU,
- * the usable vector space is 0x20-0xff (224 vectors)
- */
-#ifdef CONFIG_X86_IO_APIC
-#define NR_IRQS 224
-#else
-#define NR_IRQS 16
-#endif
-
-#define NR_VECTORS 256
-#define NR_IRQ_VECTORS NR_IRQS
-
-#define FPU_IRQ                        8
-
-#define        FIRST_VM86_IRQ          2
-#define LAST_VM86_IRQ          15
-#define invalid_vm86_irq(irq)  ((irq) < 2 || (irq) == 7 || (irq) > 15)
-
-#endif /* _ASM_IRQ_VECTORS_H */
-
-
diff --git a/include/asm-i386/mach-pc9800/mach_reboot.h b/include/asm-i386/mach-pc9800/mach_reboot.h
deleted file mode 100644 (file)
index ab35646..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- *  arch/i386/mach-pc9800/mach_reboot.h
- *
- *  Machine specific reboot functions for PC-9800.
- *  Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_REBOOT_H
-#define _MACH_REBOOT_H
-
-#ifdef CMOS_WRITE
-#undef CMOS_WRITE
-#define CMOS_WRITE(a,b)        do{}while(0)
-#endif
-
-static inline void mach_reboot(void)
-{
-       outb(0, 0xf0);          /* signal CPU reset */
-       mdelay(1);
-}
-
-#endif /* !_MACH_REBOOT_H */
diff --git a/include/asm-i386/mach-pc9800/mach_time.h b/include/asm-i386/mach-pc9800/mach_time.h
deleted file mode 100644 (file)
index 971a9db..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *  include/asm-i386/mach-pc9800/mach_time.h
- *
- *  Machine specific set RTC function for PC-9800.
- *  Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_TIME_H
-#define _MACH_TIME_H
-
-#include <linux/bcd.h>
-#include <linux/upd4990a.h>
-
-/* for check timing call set_rtc_mmss() */
-/* used in arch/i386/time.c::do_timer_interrupt() */
-/*
- * Because PC-9800's RTC (NEC uPD4990A) does not allow setting
- * time partially, we always have to read-modify-write the
- * entire time (including year) so that set_rtc_mmss() will
- * take quite much time to execute.  You may want to relax
- * RTC resetting interval (currently ~11 minuts)...
- */
-#define USEC_AFTER     1000000
-#define USEC_BEFORE    0
-
-static inline int mach_set_rtc_mmss(unsigned long nowtime)
-{
-       int retval = 0;
-       int real_seconds, real_minutes, cmos_minutes;
-       struct upd4990a_raw_data data;
-
-       upd4990a_get_time(&data, 1);
-       cmos_minutes = BCD2BIN(data.min);
-
-       /*
-        * since we're only adjusting minutes and seconds,
-        * don't interfere with hour overflow. This avoids
-        * messing with unknown time zones but requires your
-        * RTC not to be off by more than 15 minutes
-        */
-       real_seconds = nowtime % 60;
-       real_minutes = nowtime / 60;
-       if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1)
-               real_minutes += 30;     /* correct for half hour time zone */
-       real_minutes %= 60;
-
-       if (abs(real_minutes - cmos_minutes) < 30) {
-               u8 temp_seconds = (real_seconds / 10) * 16 + real_seconds % 10;
-               u8 temp_minutes = (real_minutes / 10) * 16 + real_minutes % 10;
-
-               if (data.sec != temp_seconds || data.min != temp_minutes) {
-                       data.sec = temp_seconds;
-                       data.min = temp_minutes;
-                       upd4990a_set_time(&data, 1);
-               }
-       } else {
-               printk(KERN_WARNING
-                      "set_rtc_mmss: can't update from %d to %d\n",
-                      cmos_minutes, real_minutes);
-               retval = -1;
-       }
-
-       /* uPD4990A users' manual says we should issue Register Hold
-        * command after reading time, or future Time Read command
-        * may not work.  When we have set the time, this also starts
-        * the clock.
-        */
-       upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-
-       return retval;
-}
-
-static inline unsigned long mach_get_cmos_time(void)
-{
-       int i;
-       u8 prev, cur;
-       unsigned int year;
-       struct upd4990a_raw_data data;
-
-       /* Connect uPD4990A's DATA OUT pin to its 1Hz reference clock. */
-       upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-
-       /* Catch rising edge of reference clock.  */
-       prev = ~UPD4990A_READ_DATA();
-       for (i = 0; i < 1800000; i++) { /* may take up to 1 second... */
-               __asm__ ("outb %%al,%0" : : "N" (0x5f)); /* 0.6usec delay */
-               cur = UPD4990A_READ_DATA();
-               if (!(prev & cur & 1))
-                       break;
-               prev = ~cur;
-       }
-
-       upd4990a_get_time(&data, 0);
-
-       if ((year = BCD2BIN(data.year) + 1900) < 1995)
-               year += 100;
-       return mktime(year, data.mon, BCD2BIN(data.mday), BCD2BIN(data.hour),
-                       BCD2BIN(data.min), BCD2BIN(data.sec));
-}
-
-#endif /* !_MACH_TIME_H */
diff --git a/include/asm-i386/mach-pc9800/mach_timer.h b/include/asm-i386/mach-pc9800/mach_timer.h
deleted file mode 100644 (file)
index dbe78eb..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  include/asm-i386/mach-pc9800/mach_timer.h
- *
- *  Machine specific calibrate_tsc() for PC-9800.
- *  Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-/* ------ Calibrate the TSC ------- 
- * PC-9800:
- *  CTC cannot be used because some models (especially
- *  note-machines) may disable clock to speaker channel (#1)
- *  unless speaker is enabled.  We use ARTIC instead.
- */
-#ifndef _MACH_TIMER_H
-#define _MACH_TIMER_H
-
-#define CALIBRATE_LATCH        (5 * 307200/HZ) /* 0.050sec * 307200Hz = 15360 */
-
-static inline void mach_prepare_counter(void)
-{
-       /* ARTIC can't be stopped nor reset. So we wait roundup. */
-       while (inw(0x5c));
-}
-
-static inline void mach_countup(unsigned long *count)
-{
-       do {
-               *count = inw(0x5c);
-       } while (*count < CALIBRATE_LATCH);
-}
-
-#endif /* !_MACH_TIMER_H */
diff --git a/include/asm-i386/mach-pc9800/mach_traps.h b/include/asm-i386/mach-pc9800/mach_traps.h
deleted file mode 100644 (file)
index 621c8f9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *  include/asm-i386/mach-pc9800/mach_traps.h
- *
- *  Machine specific NMI handling for PC-9800.
- *  Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_TRAPS_H
-#define _MACH_TRAPS_H
-
-static inline void clear_mem_error(unsigned char reason)
-{
-       outb(0x08, 0x37);
-       outb(0x09, 0x37);
-}
-
-static inline unsigned char get_nmi_reason(void)
-{
-       return (inb(0x33) & 6) ? 0x80 : 0;
-}
-
-static inline void reassert_nmi(void)
-{
-       outb(0x09, 0x50);       /* disable NMI once */
-       outb(0x09, 0x52);       /* re-enable it */
-}
-
-#endif /* !_MACH_TRAPS_H */
diff --git a/include/asm-i386/mach-pc9800/mach_wakecpu.h b/include/asm-i386/mach-pc9800/mach_wakecpu.h
deleted file mode 100644 (file)
index 536444f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __ASM_MACH_WAKECPU_H
-#define __ASM_MACH_WAKECPU_H
-
-/* 
- * This file copes with machines that wakeup secondary CPUs by the
- * INIT, INIT, STARTUP sequence.
- */
-
-#define WAKE_SECONDARY_VIA_INIT
-
-/*
- * On PC-9800, continuation on warm reset is done by loading
- * %ss:%sp from 0x0000:0404 and executing 'lret', so:
- */
-#define TRAMPOLINE_LOW phys_to_virt(0x4fa)
-#define TRAMPOLINE_HIGH phys_to_virt(0x4fc)
-
-#define boot_cpu_apicid boot_cpu_physical_apicid
-
-static inline void wait_for_init_deassert(atomic_t *deassert)
-{
-       while (!atomic_read(deassert));
-       return;
-}
-
-/* Nothing to do for most platforms, since cleared by the INIT cycle */
-static inline void smp_callin_clear_local_apic(void)
-{
-}
-
-static inline void store_NMI_vector(unsigned short *high, unsigned short *low)
-{
-}
-
-static inline void restore_NMI_vector(unsigned short *high, unsigned short *low)
-{
-}
-
-#if APIC_DEBUG
- #define inquire_remote_apic(apicid) __inquire_remote_apic(apicid)
-#else
- #define inquire_remote_apic(apicid) {}
-#endif
-
-#endif /* __ASM_MACH_WAKECPU_H */
diff --git a/include/asm-i386/mach-pc9800/pci-functions.h b/include/asm-i386/mach-pc9800/pci-functions.h
deleted file mode 100644 (file)
index 9130cab..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- *     PCI BIOS function codes for the PC9800. Different to
- *     standard PC systems
- */
-
-/* Note: PC-9800 confirms PCI 2.1 on only few models */
-
-#define PCIBIOS_PCI_FUNCTION_ID        0xccXX
-#define PCIBIOS_PCI_BIOS_PRESENT       0xcc81
-#define PCIBIOS_FIND_PCI_DEVICE                0xcc82
-#define PCIBIOS_FIND_PCI_CLASS_CODE    0xcc83
-/*      PCIBIOS_GENERATE_SPECIAL_CYCLE 0xcc86  (not supported by bios) */
-#define PCIBIOS_READ_CONFIG_BYTE       0xcc88
-#define PCIBIOS_READ_CONFIG_WORD       0xcc89
-#define PCIBIOS_READ_CONFIG_DWORD      0xcc8a
-#define PCIBIOS_WRITE_CONFIG_BYTE      0xcc8b
-#define PCIBIOS_WRITE_CONFIG_WORD      0xcc8c
-#define PCIBIOS_WRITE_CONFIG_DWORD     0xcc8d
-#define PCIBIOS_GET_ROUTING_OPTIONS    0xcc8e  /* PCI 2.1 only */
-#define PCIBIOS_SET_PCI_HW_INT         0xcc8f  /* PCI 2.1 only */
diff --git a/include/asm-i386/mach-pc9800/setup_arch_post.h b/include/asm-i386/mach-pc9800/setup_arch_post.h
deleted file mode 100644 (file)
index f7303fe..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * machine_specific_memory_setup - Hook for machine specific memory setup.
- *
- * Description:
- *     This is included late in kernel/setup.c so that it can make
- *     use of all of the static functions.
- **/
-
-static inline char * __init machine_specific_memory_setup(void)
-{
-       char *who;
-       unsigned long low_mem_size, lower_high, higher_high;
-
-
-       who = "BIOS (common area)";
-
-       low_mem_size = ((*(unsigned char *)__va(PC9800SCA_BIOS_FLAG) & 7) + 1) << 17;
-       add_memory_region(0, low_mem_size, 1);
-       lower_high = (__u32) *(__u8 *) bus_to_virt(PC9800SCA_EXPMMSZ) << 17;
-       higher_high = (__u32) *(__u16 *) bus_to_virt(PC9800SCA_MMSZ16M) << 20;
-       if (lower_high != 0x00f00000UL) {
-               add_memory_region(HIGH_MEMORY, lower_high, 1);
-               add_memory_region(0x01000000UL, higher_high, 1);
-       }
-       else
-               add_memory_region(HIGH_MEMORY, lower_high + higher_high, 1);
-
-       return who;
-}
diff --git a/include/asm-i386/mach-pc9800/setup_arch_pre.h b/include/asm-i386/mach-pc9800/setup_arch_pre.h
deleted file mode 100644 (file)
index bd53bdd..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Hook to call BIOS initialisation function */
-
-/* no action for generic */
-
-#define ARCH_SETUP arch_setup_pc9800();
-
-#include <linux/timex.h>
-#include <asm/io.h>
-#include <asm/pc9800.h>
-#include <asm/pc9800_sca.h>
-
-int CLOCK_TICK_RATE;
-extern unsigned long tick_usec;        /* ACTHZ          period (usec) */
-extern unsigned long tick_nsec;        /* USER_HZ period (nsec) */
-unsigned char pc9800_misc_flags;
-/* (bit 0) 1:High Address Video ram exists 0:otherwise */
-
-#ifdef CONFIG_SMP
-#define MPC_TABLE_SIZE 512
-#define MPC_TABLE ((char *) (PARAM+0x400))
-char mpc_table[MPC_TABLE_SIZE];
-#endif
-
-static  inline void arch_setup_pc9800(void)
-{
-       CLOCK_TICK_RATE = PC9800_8MHz_P() ? 1996800 : 2457600;
-       printk(KERN_DEBUG "CLOCK_TICK_RATE = %d\n", CLOCK_TICK_RATE);
-       tick_usec = TICK_USEC;          /* USER_HZ period (usec) */
-       tick_nsec = TICK_NSEC;          /* ACTHZ period (nsec) */
-
-       pc9800_misc_flags = PC9800_MISC_FLAGS;
-#ifdef CONFIG_SMP
-       if ((*(u32 *)(MPC_TABLE)) == 0x504d4350)
-               memcpy(mpc_table, MPC_TABLE, *(u16 *)(MPC_TABLE + 4));
-#endif /* CONFIG_SMP */
-}
diff --git a/include/asm-i386/mach-pc9800/smpboot_hooks.h b/include/asm-i386/mach-pc9800/smpboot_hooks.h
deleted file mode 100644 (file)
index 6c8f1d3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* two abstractions specific to kernel/smpboot.c, mainly to cater to visws
- * which needs to alter them. */
-
-static inline void smpboot_clear_io_apic_irqs(void)
-{
-       io_apic_irqs = 0;
-}
-
-static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)
-{
-       /* reset code is stored in 8255 on PC-9800. */
-       outb(0x0e, 0x37);       /* SHUT0 = 0 */
-       local_flush_tlb();
-       Dprintk("1.\n");
-       *((volatile unsigned short *) TRAMPOLINE_HIGH) = start_eip >> 4;
-       Dprintk("2.\n");
-       *((volatile unsigned short *) TRAMPOLINE_LOW) = start_eip & 0xf;
-       Dprintk("3.\n");
-       /*
-        * On PC-9800, continuation on warm reset is done by loading
-        * %ss:%sp from 0x0000:0404 and executing 'lret', so:
-        */
-       /* 0x3f0 is on unused interrupt vector and should be safe... */
-       *((volatile unsigned long *) phys_to_virt(0x404)) = 0x000003f0;
-       Dprintk("4.\n");
-}
-
-static inline void smpboot_restore_warm_reset_vector(void)
-{
-       /*
-        * Install writable page 0 entry to set BIOS data area.
-        */
-       local_flush_tlb();
-
-       /*
-        * Paranoid:  Set warm reset code and vector here back
-        * to default values.
-        */
-       outb(0x0f, 0x37);       /* SHUT0 = 1 */
-
-       *((volatile long *) phys_to_virt(0x404)) = 0;
-}
-
-static inline void smpboot_setup_io_apic(void)
-{
-       /*
-        * Here we can be sure that there is an IO-APIC in the system. Let's
-        * go and set it up:
-        */
-       if (!skip_ioapic_setup && nr_ioapics)
-               setup_IO_APIC();
-}
index f431a0b..2623313 100644 (file)
@@ -7,11 +7,20 @@
  * we put the segment information here.
  *
  * cpu_vm_mask is used to optimize ldt flushing.
+ *
+ * exec_limit is used to track the range PROT_EXEC
+ * mappings span.
  */
+
+#define MAX_LDT_PAGES 16
+
 typedef struct { 
        int size;
        struct semaphore sem;
-       void *ldt;
+       struct page *ldt_pages[MAX_LDT_PAGES];
+       struct desc_struct user_cs;
+       unsigned long exec_limit;
+       void *vdso;
 } mm_context_t;
 
 #endif
index 99cff65..52beaf7 100644 (file)
@@ -29,6 +29,10 @@ static inline void switch_mm(struct mm_struct *prev,
 {
        int cpu = smp_processor_id();
 
+#ifdef CONFIG_X86_SWITCH_PAGETABLES
+       if (tsk->mm)
+               tsk->thread_info->user_pgd = (void *)__pa(tsk->mm->pgd);
+#endif
        if (likely(prev != next)) {
                /* stop flush ipis for the previous mm */
                cpu_clear(cpu, prev->cpu_vm_mask);
@@ -39,12 +43,14 @@ static inline void switch_mm(struct mm_struct *prev,
                cpu_set(cpu, next->cpu_vm_mask);
 
                /* Re-load page tables */
+#if !defined(CONFIG_X86_SWITCH_PAGETABLES)
                load_cr3(next->pgd);
+#endif
 
                /*
                 * load the LDT, if the LDT is different:
                 */
-               if (unlikely(prev->context.ldt != next->context.ldt))
+               if (unlikely(prev->context.size + next->context.size))
                        load_LDT_nolock(&next->context, cpu);
        }
 #ifdef CONFIG_SMP
@@ -56,7 +62,9 @@ static inline void switch_mm(struct mm_struct *prev,
                        /* We were in lazy tlb mode and leave_mm disabled 
                         * tlb flush IPI delivery. We must reload %cr3.
                         */
+#if !defined(CONFIG_X86_SWITCH_PAGETABLES)
                        load_cr3(next->pgd);
+#endif
                        load_LDT_nolock(&next->context, cpu);
                }
        }
@@ -67,6 +75,6 @@ static inline void switch_mm(struct mm_struct *prev,
        asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
 
 #define activate_mm(prev, next) \
-       switch_mm((prev),(next),NULL)
+       switch_mm((prev),(next),current)
 
 #endif
index 8ec1dae..614d05f 100644 (file)
@@ -60,11 +60,7 @@ struct mod_arch_specific
 #define MODULE_REGPARM ""
 #endif
 
-#ifdef CONFIG_4KSTACKS
 #define MODULE_STACKSIZE "4KSTACKS "
-#else
-#define MODULE_STACKSIZE ""
-#endif
 
 #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_REGPARM MODULE_STACKSIZE
 
diff --git a/include/asm-i386/netdump.h b/include/asm-i386/netdump.h
new file mode 100644 (file)
index 0000000..988c276
--- /dev/null
@@ -0,0 +1,100 @@
+#ifndef _ASM_I386_NETDUMP_H
+#define _ASM_I386_NETDUMP_H
+
+/*
+ * linux/include/asm-i386/netdump.h
+ *
+ * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifdef __KERNEL__
+
+#include <asm/irq.h>
+
+extern int page_is_ram (unsigned long);
+const static int platform_supports_netdump = 1;
+extern union irq_ctx *netdump_irq_ctx;
+
+#define platform_timestamp(x) rdtscll(x)
+
+#define platform_fix_regs()                                            \
+{                                                                      \
+       unsigned long esp;                                              \
+       unsigned short ss;                                              \
+       esp = (unsigned long) ((char *)regs + sizeof (struct pt_regs)); \
+       ss = __KERNEL_DS;                                               \
+       if (regs->xcs & 3) {                                            \
+               esp = regs->esp;                                                \
+               ss = regs->xss & 0xffff;                                        \
+       }                                                               \
+       myregs = *regs;                                                 \
+       myregs.esp = esp;                                               \
+       myregs.xss = (myregs.xss & 0xffff0000) | ss;                    \
+};
+
+static inline void platform_init_stack(void **stackptr)
+{
+       *stackptr = (void *)kmalloc(sizeof(union irq_ctx), GFP_KERNEL);
+       if (*stackptr)
+               memset(*stackptr, 0, sizeof(union irq_ctx));
+       else
+               printk(KERN_WARNING
+                      "netdump: unable to allocate separate stack\n");
+}
+
+static inline void platform_start_netdump(void *stackptr, struct pt_regs *regs)
+{
+       u32 *dsp;
+       union irq_ctx * curctx;
+       union irq_ctx * dumpctx;
+
+       if (!stackptr)
+               netpoll_netdump(regs);
+       else {
+               curctx = (union irq_ctx *) current_thread_info();
+               dumpctx = (union irq_ctx *) stackptr;
+
+               /* build the stack frame on the IRQ stack */
+               dsp = (u32*) ((char*)dumpctx + sizeof(*dumpctx));
+               dumpctx->tinfo.task = curctx->tinfo.task;
+               dumpctx->tinfo.real_stack = curctx->tinfo.real_stack;
+               dumpctx->tinfo.virtual_stack = curctx->tinfo.virtual_stack;
+               dumpctx->tinfo.previous_esp = current_stack_pointer();
+
+               *--dsp = (u32) regs;
+
+               asm volatile(
+                       "       xchgl   %%ebx,%%esp     \n"
+                       "       call    netpoll_netdump \n"
+                       "       xchgl   %%ebx,%%esp     \n"
+                       : : "b"(dsp) :  "memory", "cc", "edx", "ecx"
+               );
+       }
+}
+
+#define platform_cleanup_stack(stackptr)       \
+do {                                           \
+       if (stackptr)                           \
+               kfree(stackptr);                \
+} while (0)
+
+#define platform_max_pfn() (num_physpages)
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_I386_NETDUMP_H */
index eb0e11f..5716db1 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _I386_PAGE_H
 #define _I386_PAGE_H
 
+#include <linux/config.h>
+
 /* PAGE_SHIFT determines the page size */
 #define PAGE_SHIFT     12
 #define PAGE_SIZE      (1UL << PAGE_SHIFT)
 #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
 #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
 
-#ifdef __KERNEL__
-#ifndef __ASSEMBLY__
-
 #include <linux/config.h>
 
+#ifdef __KERNEL__
+#ifndef __ASSEMBLY__
 #ifdef CONFIG_X86_USE_3DNOW
 
 #include <asm/mmx.h>
@@ -92,8 +93,19 @@ typedef struct { unsigned long pgprot; } pgprot_t;
  *
  * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
  * and CONFIG_HIGHMEM64G options in the kernel configuration.
+ *
+ * Note: on PAE the kernel must never go below 32 MB, we use the
+ * first 8 entries of the 2-level boot pgd for PAE magic.
  */
 
+#ifdef CONFIG_X86_4G_VM_LAYOUT
+#define __PAGE_OFFSET          (0x02000000)
+#define TASK_SIZE              (0xff000000)
+#else
+#define __PAGE_OFFSET          (0xc0000000)
+#define TASK_SIZE              (0xc0000000)
+#endif
+
 /*
  * This much address space is reserved for vmalloc() and iomap()
  * as well as fixmap mappings.
@@ -116,18 +128,14 @@ static __inline__ int get_order(unsigned long size)
        return order;
 }
 
-#endif /* __ASSEMBLY__ */
-
-#ifdef __ASSEMBLY__
-#define __PAGE_OFFSET          (0xC0000000)
-#else
-#define __PAGE_OFFSET          (0xC0000000UL)
-#endif
+extern int devmem_is_allowed(unsigned long pagenr);
 
+#endif /* __ASSEMBLY__ */
 
 #define PAGE_OFFSET            ((unsigned long)__PAGE_OFFSET)
 #define VMALLOC_RESERVE                ((unsigned long)__VMALLOC_RESERVE)
-#define MAXMEM                 (-__PAGE_OFFSET-__VMALLOC_RESERVE)
+#define __MAXMEM               (-__PAGE_OFFSET-__VMALLOC_RESERVE)
+#define MAXMEM                 ((unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE))
 #define __pa(x)                        ((unsigned long)(x)-PAGE_OFFSET)
 #define __va(x)                        ((void *)((unsigned long)(x)+PAGE_OFFSET))
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
@@ -145,6 +153,8 @@ static __inline__ int get_order(unsigned long size)
        ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+
+
 #endif /* __KERNEL__ */
 
 #endif /* _I386_PAGE_H */
diff --git a/include/asm-i386/pc9800.h b/include/asm-i386/pc9800.h
deleted file mode 100644 (file)
index 1268f35..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *  PC-9800 machine types.
- *
- *  Copyright (C) 1999 TAKAI Kosuke <tak@kmc.kyoto-u.ac.jp>
- *                     (Linux/98 Project)
- */
-
-#ifndef _ASM_PC9800_H_
-#define _ASM_PC9800_H_
-
-#include <asm/pc9800_sca.h>
-#include <asm/types.h>
-
-#define __PC9800SCA(type, pa)  (*(type *) phys_to_virt(pa))
-#define __PC9800SCA_TEST_BIT(pa, n)    \
-       ((__PC9800SCA(u8, pa) & (1U << (n))) != 0)
-
-#define PC9800_HIGHRESO_P()    __PC9800SCA_TEST_BIT(PC9800SCA_BIOS_FLAG, 3)
-#define PC9800_8MHz_P()                __PC9800SCA_TEST_BIT(PC9800SCA_BIOS_FLAG, 7)
-
-                               /* 0x2198 is 98 21 on memory... */
-#define PC9800_9821_P()                (__PC9800SCA(u16, PC9821SCA_ROM_ID) == 0x2198)
-
-/* Note PC9821_...() are valid only when PC9800_9821_P() was true. */
-#define PC9821_IDEIF_DOUBLE_P()        __PC9800SCA_TEST_BIT(PC9821SCA_ROM_FLAG4, 4)
-
-#endif
diff --git a/include/asm-i386/pc9800_sca.h b/include/asm-i386/pc9800_sca.h
deleted file mode 100644 (file)
index 14731ed..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  System-common area definitions for NEC PC-9800 series
- *
- *  Copyright (C) 1999 TAKAI Kousuke <tak@kmc.kyoto-u.ac.jp>,
- *                     Kyoto University Microcomputer Club.
- */
-
-#ifndef _ASM_I386_PC9800SCA_H_
-#define _ASM_I386_PC9800SCA_H_
-
-#define PC9800SCA_EXPMMSZ              (0x0401)        /* B */
-#define PC9800SCA_SCSI_PARAMS          (0x0460)        /* 8 * 4B */
-#define PC9800SCA_DISK_EQUIPS          (0x0482)        /* B */
-#define PC9800SCA_XROM_ID              (0x04C0)        /* 52B */
-#define PC9800SCA_BIOS_FLAG            (0x0501)        /* B */
-#define PC9800SCA_MMSZ16M              (0x0594)        /* W */
-
-/* PC-9821 have additional system common area in their BIOS-ROM segment. */
-
-#define PC9821SCA__BASE                        (0xF8E8 << 4)
-#define PC9821SCA_ROM_ID               (PC9821SCA__BASE + 0x00)
-#define PC9821SCA_ROM_FLAG4            (PC9821SCA__BASE + 0x05)
-#define PC9821SCA_RSFLAGS              (PC9821SCA__BASE + 0x11)        /* B */
-
-#endif /* !_ASM_I386_PC9800SCA_H_ */
index a44e266..3cf7bb0 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/fixmap.h>
+#include <asm/desc.h>
 #include <linux/threads.h>
 #include <linux/mm.h>          /* for struct page */
 
index 8f9fcab..94e7fac 100644 (file)
 #include <asm/processor.h>
 #include <asm/fixmap.h>
 #include <linux/threads.h>
+#include <linux/slab.h>
 
 #ifndef _I386_BITOPS_H
 #include <asm/bitops.h>
 #endif
 
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/spinlock.h>
-
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-extern unsigned long empty_zero_page[1024];
 extern pgd_t swapper_pg_dir[1024];
-extern kmem_cache_t *pgd_cache;
-extern kmem_cache_t *pmd_cache;
+extern kmem_cache_t *pgd_cache, *pmd_cache, *kpmd_cache;
 extern spinlock_t pgd_lock;
 extern struct page *pgd_list;
-
 void pmd_ctor(void *, kmem_cache_t *, unsigned long);
+void kpmd_ctor(void *, kmem_cache_t *, unsigned long);
 void pgd_ctor(void *, kmem_cache_t *, unsigned long);
 void pgd_dtor(void *, kmem_cache_t *, unsigned long);
 void pgtable_cache_init(void);
-void paging_init(void);
+extern void paging_init(void);
+void setup_identity_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end);
+
+/*
+ * ZERO_PAGE is a global shared page that is always zero: used
+ * for zero-mapped memory areas etc..
+ */
+extern unsigned long empty_zero_page[1024];
+#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
 
 /*
  * The Linux x86 paging architecture is 'compile-time dual-mode', it
  * implements both the traditional 2-level x86 page tables and the
  * newer 3-level PAE-mode page tables.
  */
+
+extern void set_system_gate(unsigned int n, void *addr);
+extern void init_entry_mappings(void);
+extern void entry_trampoline_setup(void);
+
 #ifdef CONFIG_X86_PAE
 # include <asm/pgtable-3level-defs.h>
 #else
@@ -59,7 +62,12 @@ void paging_init(void);
 #define PGDIR_SIZE     (1UL << PGDIR_SHIFT)
 #define PGDIR_MASK     (~(PGDIR_SIZE-1))
 
-#define USER_PTRS_PER_PGD      (TASK_SIZE/PGDIR_SIZE)
+#if defined(CONFIG_X86_PAE) && defined(CONFIG_X86_4G_VM_LAYOUT)
+# define USER_PTRS_PER_PGD     4
+#else
+# define USER_PTRS_PER_PGD     ((TASK_SIZE/PGDIR_SIZE) + ((TASK_SIZE % PGDIR_SIZE) + PGDIR_SIZE-1)/PGDIR_SIZE)
+#endif
+
 #define FIRST_USER_PGD_NR      0
 
 #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
@@ -274,6 +282,7 @@ static inline void ptep_mkdirty(pte_t *ptep)                        { set_bit(_PAGE_BIT_DIRTY, &ptep-
 
 #define mk_pte(page, pgprot)   pfn_pte(page_to_pfn(page), (pgprot))
 #define mk_pte_huge(entry) ((entry).pte_low |= _PAGE_PRESENT | _PAGE_PSE)
+#define mk_pte_phys(physpage, pgprot) pfn_pte((physpage) >> PAGE_SHIFT, pgprot)
 
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
@@ -421,4 +430,11 @@ extern pte_t *lookup_address(unsigned long address);
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
 
+/*
+ * The size of the low 1:1 mappings we use during bootup,
+ * SMP-boot and ACPI-sleep:
+ */
+#define LOW_MAPPINGS_SIZE (16*1024*1024)
+
+
 #endif /* _I386_PGTABLE_H */
index 6fcdb7d..cd8708b 100644 (file)
@@ -286,20 +286,20 @@ extern unsigned int machine_submodel_id;
 extern unsigned int BIOS_revision;
 extern unsigned int mca_pentium_flag;
 
-/*
- * User space process size: 3GB (default).
- */
-#define TASK_SIZE      (PAGE_OFFSET)
-
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
  */
-#define TASK_UNMAPPED_BASE     (PAGE_ALIGN(TASK_SIZE / 3))
+#define TASK_UNMAPPED_BASE     PAGE_ALIGN(TASK_SIZE/3)
+
+#define __HAVE_ARCH_ALIGN_STACK
+extern unsigned long arch_align_stack(unsigned long sp);
+
+#define HAVE_ARCH_PICK_MMAP_LAYOUT
 
 /*
- * Size of io_bitmap.
+ * Size of io_bitmap, covering ports 0 to 0x3ff.
  */
-#define IO_BITMAP_BITS  65536
+#define IO_BITMAP_BITS  1024
 #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
 #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
 #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
@@ -391,7 +391,7 @@ struct tss_struct {
        /*
         * pads the TSS to be cacheline-aligned (size is 0x100)
         */
-       unsigned long __cacheline_filler[37];
+       unsigned long __cacheline_filler[5];
        /*
         * .. and then another 0x100 bytes for emergency kernel stack
         */
@@ -400,9 +400,16 @@ struct tss_struct {
 
 #define ARCH_MIN_TASKALIGN     16
 
+
+#define STACK_PAGE_COUNT       (4096/PAGE_SIZE)
+
+
+
+
 struct thread_struct {
 /* cached TLS descriptors. */
        struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
+       void *stack_page[STACK_PAGE_COUNT];
        unsigned long   esp0;
        unsigned long   sysenter_cs;
        unsigned long   eip;
@@ -446,7 +453,8 @@ struct thread_struct {
        .io_bitmap      = { [ 0 ... IO_BITMAP_LONGS] = ~0 },            \
 }
 
-static inline void load_esp0(struct tss_struct *tss, struct thread_struct *thread)
+static inline void
+load_esp0(struct tss_struct *tss, struct thread_struct *thread)
 {
        tss->esp0 = thread->esp0;
        /* This can only happen when SEP is enabled, no need to test "SEP"arately */
@@ -465,6 +473,7 @@ static inline void load_esp0(struct tss_struct *tss, struct thread_struct *threa
        regs->xcs = __USER_CS;                                  \
        regs->eip = new_eip;                                    \
        regs->esp = new_esp;                                    \
+       load_user_cs_desc(smp_processor_id(), current->mm);     \
 } while (0)
 
 /* Forward declaration, a strange C thing */
@@ -482,6 +491,23 @@ extern void prepare_to_copy(struct task_struct *tsk);
  */
 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
 
+#ifdef CONFIG_X86_HIGH_ENTRY
+#define virtual_esp0(tsk) \
+       ((unsigned long)(tsk)->thread_info->virtual_stack + ((tsk)->thread.esp0 - (unsigned long)(tsk)->thread_info->real_stack))
+#else
+# define virtual_esp0(tsk) ((tsk)->thread.esp0)
+#endif
+
+#define load_virtual_esp0(tss, task)                                   \
+       do {                                                            \
+               tss->esp0 = virtual_esp0(task);                         \
+               if (likely(cpu_has_sep) && unlikely(tss->ss1 != task->thread.sysenter_cs)) {    \
+                       tss->ss1 = task->thread.sysenter_cs;            \
+                       wrmsr(MSR_IA32_SYSENTER_CS,                     \
+                               task->thread.sysenter_cs, 0);           \
+               }                                                       \
+       } while (0)
+
 extern unsigned long thread_saved_pc(struct task_struct *tsk);
 void show_trace(struct task_struct *task, unsigned long *stack);
 
diff --git a/include/asm-i386/relay.h b/include/asm-i386/relay.h
new file mode 100644 (file)
index 0000000..98e5b72
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef _ASM_I386_RELAY_H
+#define _ASM_I386_RELAY_H
+/*
+ * linux/include/asm-i386/relay.h
+ *
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 2002 - Karim Yaghmour (karim@opersys.com)
+ *
+ * i386 definitions for relayfs
+ */
+
+#include <linux/relayfs_fs.h>
+
+#ifdef CONFIG_X86_TSC
+#include <asm/msr.h>
+
+/**
+ *     get_time_delta - utility function for getting time delta
+ *     @now: pointer to a timeval struct that may be given current time
+ *     @rchan: the channel
+ *
+ *     Returns either the TSC if TSCs are being used, or the time and the
+ *     time difference between the current time and the buffer start time 
+ *     if TSCs are not being used.
+ */
+static inline u32
+get_time_delta(struct timeval *now, struct rchan *rchan)
+{
+       u32 time_delta;
+
+       if ((using_tsc(rchan) == 1) && cpu_has_tsc)
+               rdtscl(time_delta);
+       else {
+               do_gettimeofday(now);
+               time_delta = calc_time_delta(now, &rchan->buf_start_time);
+       }
+
+       return time_delta;
+}
+
+/**
+ *     get_timestamp - utility function for getting a time and TSC pair
+ *     @now: current time
+ *     @tsc: the TSC associated with now
+ *     @rchan: the channel
+ *
+ *     Sets the value pointed to by now to the current time and the value
+ *     pointed to by tsc to the tsc associated with that time, if the 
+ *     platform supports TSC.
+ */
+static inline void 
+get_timestamp(struct timeval *now,
+             u32 *tsc,
+             struct rchan *rchan)
+{
+       do_gettimeofday(now);
+
+       if ((using_tsc(rchan) == 1) && cpu_has_tsc)
+               rdtscl(*tsc);
+}
+
+/**
+ *     get_time_or_tsc - utility function for getting a time or a TSC
+ *     @now: current time
+ *     @tsc: current TSC
+ *     @rchan: the channel
+ *
+ *     Sets the value pointed to by now to the current time or the value
+ *     pointed to by tsc to the current tsc, depending on whether we're
+ *     using TSCs or not.
+ */
+static inline void 
+get_time_or_tsc(struct timeval *now,
+               u32 *tsc,
+               struct rchan *rchan)
+{
+       if ((using_tsc(rchan) == 1) && cpu_has_tsc)
+               rdtscl(*tsc);
+       else
+               do_gettimeofday(now);
+}
+
+/**
+ *     have_tsc - does this platform have a useable TSC?
+ *
+ *     Returns 1 if this platform has a useable TSC counter for
+ *     timestamping purposes, 0 otherwise.
+ */
+static inline int
+have_tsc(void)
+{
+       if (cpu_has_tsc)
+               return 1;
+       else
+               return 0;
+}
+
+#else /* No TSC support (#ifdef CONFIG_X86_TSC) */
+#include <asm-generic/relay.h>
+#endif /* #ifdef CONFIG_X86_TSC */
+#endif
index 3e391b2..f81444a 100644 (file)
@@ -40,7 +40,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-i386/rmap.h b/include/asm-i386/rmap.h
deleted file mode 100644 (file)
index 353afee..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _I386_RMAP_H
-#define _I386_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#ifdef CONFIG_HIGHPTE
-static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
-{
-       unsigned long pfn = (unsigned long)(pte_paddr >> PAGE_SHIFT);
-       unsigned long off = ((unsigned long)pte_paddr) & ~PAGE_MASK;
-       return (pte_t *)((char *)kmap_atomic(pfn_to_page(pfn), KM_PTE2) + off);
-}
-
-static inline void rmap_ptep_unmap(pte_t *pte)
-{
-       kunmap_atomic(pte, KM_PTE2);
-}
-#endif
-
-#endif
index 88c461e..bd8fa4c 100644 (file)
@@ -37,6 +37,7 @@ extern int smp_num_siblings;
 extern cpumask_t cpu_sibling_map[];
 
 extern void smp_flush_tlb(void);
+extern void dump_send_ipi(void);
 extern void smp_message_irq(int cpl, void *dev_id, struct pt_regs *regs);
 extern void smp_invalidate_rcv(void);          /* Process an NMI */
 extern void (*mtrr_hook) (void);
diff --git a/include/asm-i386/std_resources.h b/include/asm-i386/std_resources.h
deleted file mode 100644 (file)
index 5373398..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * include/asm-i386/std_resources.h
- */
-
-#ifndef __ASM_I386_STD_RESOURCES_H
-#define __ASM_I386_STD_RESOURCES_H
-
-#include <linux/init.h>
-
-void probe_roms(void) __init;
-void request_graphics_resource(void) __init;
-void request_standard_io_resources(void) __init;
-
-#endif
index fc66609..55c3220 100644 (file)
@@ -60,6 +60,29 @@ __asm__ __volatile__(
 return dest;
 }
 
+/*
+ * This is a more generic variant of strncpy_count() suitable for
+ * implementing string-access routines with all sorts of return
+ * code semantics. It's used by mm/usercopy.c.
+ */
+static inline size_t strncpy_count(char * dest,const char *src,size_t count)
+{
+       __asm__ __volatile__(
+
+       "1:\tdecl %0\n\t"
+       "js 2f\n\t"
+       "lodsb\n\t"
+       "stosb\n\t"
+       "testb %%al,%%al\n\t"
+       "jne 1b\n\t"
+       "2:"
+       "incl %0"
+       : "=c" (count)
+       :"S" (src),"D" (dest),"0" (count) : "memory");
+
+       return count;
+}
+
 #define __HAVE_ARCH_STRCAT
 static inline char * strcat(char * dest,const char * src)
 {
index 4ef147f..d941e6d 100644 (file)
@@ -37,6 +37,8 @@ struct thread_info {
                                                   0-0xBFFFFFFF for user-thead
                                                   0-0xFFFFFFFF for kernel-thread
                                                */
+       void                    *sysenter_return;
+       void                    *real_stack, *virtual_stack, *user_pgd;
        struct restart_block    restart_block;
 
        unsigned long           previous_esp;   /* ESP of the previous stack in case
@@ -52,11 +54,7 @@ struct thread_info {
 #endif
 
 #define PREEMPT_ACTIVE         0x4000000
-#ifdef CONFIG_4KSTACKS
 #define THREAD_SIZE            (4096)
-#else
-#define THREAD_SIZE            (8192)
-#endif
 
 #define STACK_WARN             (THREAD_SIZE/8)
 /*
@@ -66,7 +64,7 @@ struct thread_info {
  */
 #ifndef __ASSEMBLY__
 
-#define INIT_THREAD_INFO(tsk)                  \
+#define INIT_THREAD_INFO(tsk, thread_info)     \
 {                                              \
        .task           = &tsk,                 \
        .exec_domain    = &default_exec_domain, \
@@ -77,6 +75,7 @@ struct thread_info {
        .restart_block = {                      \
                .fn = do_no_restart_syscall,    \
        },                                      \
+       .real_stack     = &thread_info,         \
 }
 
 #define init_thread_info       (init_thread_union.thread_info)
@@ -143,6 +142,7 @@ static inline unsigned long current_stack_pointer(void)
 #define TIF_NEED_RESCHED       3       /* rescheduling necessary */
 #define TIF_SINGLESTEP         4       /* restore singlestep on return to user mode */
 #define TIF_IRET               5       /* return with iret */
+#define TIF_DB7                        6       /* has debug registers */
 #define TIF_SYSCALL_AUDIT      7       /* syscall auditing active */
 #define TIF_POLLING_NRFLAG     16      /* true if poll_idle() is polling TIF_NEED_RESCHED */
 
@@ -153,6 +153,7 @@ static inline unsigned long current_stack_pointer(void)
 #define _TIF_SINGLESTEP                (1<<TIF_SINGLESTEP)
 #define _TIF_IRET              (1<<TIF_IRET)
 #define _TIF_SYSCALL_AUDIT     (1<<TIF_SYSCALL_AUDIT)
+#define _TIF_DB7               (1<<TIF_DB7)
 #define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)
 
 /* work to do on interrupt/exception return */
index 2f4c8ee..84975eb 100644 (file)
@@ -85,22 +85,28 @@ extern unsigned long pgkern_mask;
 
 static inline void flush_tlb_mm(struct mm_struct *mm)
 {
+#ifndef CONFIG_X86_SWITCH_PAGETABLES
        if (mm == current->active_mm)
                __flush_tlb();
+#endif
 }
 
 static inline void flush_tlb_page(struct vm_area_struct *vma,
        unsigned long addr)
 {
+#ifndef CONFIG_X86_SWITCH_PAGETABLES
        if (vma->vm_mm == current->active_mm)
                __flush_tlb_one(addr);
+#endif
 }
 
 static inline void flush_tlb_range(struct vm_area_struct *vma,
        unsigned long start, unsigned long end)
 {
+#ifndef CONFIG_X86_SWITCH_PAGETABLES
        if (vma->vm_mm == current->active_mm)
                __flush_tlb();
+#endif
 }
 
 #else
@@ -111,11 +117,10 @@ static inline void flush_tlb_range(struct vm_area_struct *vma,
        __flush_tlb()
 
 extern void flush_tlb_all(void);
-extern void flush_tlb_current_task(void);
 extern void flush_tlb_mm(struct mm_struct *);
 extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
 
-#define flush_tlb()    flush_tlb_current_task()
+#define flush_tlb()    flush_tlb_all()
 
 static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
 {
index bb202d2..47351a3 100644 (file)
@@ -26,7 +26,7 @@
 
 
 #define KERNEL_DS      MAKE_MM_SEG(0xFFFFFFFFUL)
-#define USER_DS                MAKE_MM_SEG(PAGE_OFFSET)
+#define USER_DS                MAKE_MM_SEG(TASK_SIZE)
 
 #define get_ds()       (KERNEL_DS)
 #define get_fs()       (current_thread_info()->addr_limit)
@@ -150,6 +150,45 @@ extern void __get_user_4(void);
                :"=a" (ret),"=d" (x) \
                :"0" (ptr))
 
+extern int get_user_size(unsigned int size, void *val, const void *ptr);
+extern int put_user_size(unsigned int size, const void *val, void *ptr);
+extern int zero_user_size(unsigned int size, void *ptr);
+extern int copy_str_fromuser_size(unsigned int size, void *val, const void *ptr);
+extern int strlen_fromuser_size(unsigned int size, const void *ptr);
+
+
+# define indirect_get_user(x,ptr)                                      \
+({     int __ret_gu,__val_gu;                                          \
+       __typeof__(ptr) __ptr_gu = (ptr);                               \
+       __ret_gu = get_user_size(sizeof(*__ptr_gu), &__val_gu,__ptr_gu) ? -EFAULT : 0;\
+       (x) = (__typeof__(*__ptr_gu))__val_gu;                          \
+       __ret_gu;                                                       \
+})
+#define indirect_put_user(x,ptr)                                       \
+({                                                                     \
+       __typeof__(*(ptr)) *__ptr_pu = (ptr), __x_pu = (x);             \
+       put_user_size(sizeof(*__ptr_pu), &__x_pu, __ptr_pu) ? -EFAULT : 0; \
+})
+#define __indirect_put_user indirect_put_user
+#define __indirect_get_user indirect_get_user
+
+#define indirect_copy_from_user(to,from,n) get_user_size(n,to,from)
+#define indirect_copy_to_user(to,from,n) put_user_size(n,from,to)
+
+#define __indirect_copy_from_user indirect_copy_from_user
+#define __indirect_copy_to_user indirect_copy_to_user
+
+#define indirect_strncpy_from_user(dst, src, count) \
+               copy_str_fromuser_size(count, dst, src)
+
+extern int strlen_fromuser_size(unsigned int size, const void *ptr);
+#define indirect_strnlen_user(str, n) strlen_fromuser_size(n, str)
+#define indirect_strlen_user(str) indirect_strnlen_user(str, ~0UL >> 1)
+
+extern int zero_user_size(unsigned int size, void *ptr);
+
+#define indirect_clear_user(mem, len) zero_user_size(len, mem)
+#define __indirect_clear_user clear_user
 
 /* Careful: we have to cast the result to the type of the pointer for sign reasons */
 /**
@@ -169,7 +208,7 @@ extern void __get_user_4(void);
  * Returns zero on success, or -EFAULT on error.
  * On error, the variable @x is set to zero.
  */
-#define get_user(x,ptr)                                                        \
+#define direct_get_user(x,ptr)                                         \
 ({     int __ret_gu,__val_gu;                                          \
        __chk_user_ptr(ptr);                                            \
        switch(sizeof (*(ptr))) {                                       \
@@ -200,7 +239,7 @@ extern void __put_user_bad(void);
  *
  * Returns zero on success, or -EFAULT on error.
  */
-#define put_user(x,ptr)                                                        \
+#define direct_put_user(x,ptr)                                         \
   __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
 
@@ -224,7 +263,7 @@ extern void __put_user_bad(void);
  * Returns zero on success, or -EFAULT on error.
  * On error, the variable @x is set to zero.
  */
-#define __get_user(x,ptr) \
+#define __direct_get_user(x,ptr) \
   __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
 
 
@@ -247,7 +286,7 @@ extern void __put_user_bad(void);
  *
  * Returns zero on success, or -EFAULT on error.
  */
-#define __put_user(x,ptr) \
+#define __direct_put_user(x,ptr) \
   __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
 #define __put_user_nocheck(x,ptr,size)                         \
@@ -400,7 +439,7 @@ unsigned long __copy_from_user_ll(void *to, const void __user *from, unsigned lo
  * On success, this will be zero.
  */
 static inline unsigned long
-__copy_to_user(void __user *to, const void *from, unsigned long n)
+__direct_copy_to_user(void __user *to, const void *from, unsigned long n)
 {
        if (__builtin_constant_p(n)) {
                unsigned long ret;
@@ -438,7 +477,7 @@ __copy_to_user(void __user *to, const void *from, unsigned long n)
  * data to the requested size using zero bytes.
  */
 static inline unsigned long
-__copy_from_user(void *to, const void __user *from, unsigned long n)
+__direct_copy_from_user(void *to, const void __user *from, unsigned long n)
 {
        if (__builtin_constant_p(n)) {
                unsigned long ret;
@@ -458,9 +497,55 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
        return __copy_from_user_ll(to, from, n);
 }
 
-unsigned long copy_to_user(void __user *to, const void *from, unsigned long n);
-unsigned long copy_from_user(void *to,
-                       const void __user *from, unsigned long n);
+/**
+ * copy_to_user: - Copy a block of data into user space.
+ * @to:   Destination address, in user space.
+ * @from: Source address, in kernel space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from kernel space to user space.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ */
+static inline unsigned long
+direct_copy_to_user(void __user *to, const void *from, unsigned long n)
+{
+       might_sleep();
+       if (access_ok(VERIFY_WRITE, to, n))
+               n = __direct_copy_to_user(to, from, n);
+       return n;
+}
+
+/**
+ * copy_from_user: - Copy a block of data from user space.
+ * @to:   Destination address, in kernel space.
+ * @from: Source address, in user space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from user space to kernel space.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ *
+ * If some data could not be copied, this function will pad the copied
+ * data to the requested size using zero bytes.
+ */
+static inline unsigned long
+direct_copy_from_user(void *to, const void __user *from, unsigned long n)
+{
+       might_sleep();
+       if (access_ok(VERIFY_READ, from, n))
+               n = __direct_copy_from_user(to, from, n);
+       else
+               memset(to, 0, n);
+       return n;
+}
+
 long strncpy_from_user(char *dst, const char __user *src, long count);
 long __strncpy_from_user(char *dst, const char __user *src, long count);
 
@@ -478,10 +563,71 @@ long __strncpy_from_user(char *dst, const char __user *src, long count);
  * If there is a limit on the length of a valid string, you may wish to
  * consider using strnlen_user() instead.
  */
-#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
 
-long strnlen_user(const char __user *str, long n);
-unsigned long clear_user(void __user *mem, unsigned long len);
-unsigned long __clear_user(void __user *mem, unsigned long len);
+long direct_strncpy_from_user(char *dst, const char *src, long count);
+long __direct_strncpy_from_user(char *dst, const char *src, long count);
+#define direct_strlen_user(str) direct_strnlen_user(str, ~0UL >> 1)
+long direct_strnlen_user(const char *str, long n);
+unsigned long direct_clear_user(void *mem, unsigned long len);
+unsigned long __direct_clear_user(void *mem, unsigned long len);
+
+extern int indirect_uaccess;
+
+#ifdef CONFIG_X86_UACCESS_INDIRECT
+
+/*
+ * Return code and zeroing semantics:
+
+ __clear_user          0                      <-> bytes not done
+ clear_user            0                      <-> bytes not done
+ __copy_to_user        0                      <-> bytes not done
+ copy_to_user          0                      <-> bytes not done
+ __copy_from_user      0                      <-> bytes not done, zero rest
+ copy_from_user        0                      <-> bytes not done, zero rest
+ __get_user            0                      <-> -EFAULT
+ get_user              0                      <-> -EFAULT
+ __put_user            0                      <-> -EFAULT
+ put_user              0                      <-> -EFAULT
+ strlen_user           strlen + 1             <-> 0
+ strnlen_user          strlen + 1 (or n+1)    <-> 0
+ strncpy_from_user     strlen (or n)          <-> -EFAULT
+
+ */
+
+#define __clear_user(mem,len) __indirect_clear_user(mem,len)
+#define clear_user(mem,len) indirect_clear_user(mem,len)
+#define __copy_to_user(to,from,n) __indirect_copy_to_user(to,from,n)
+#define copy_to_user(to,from,n) indirect_copy_to_user(to,from,n)
+#define __copy_from_user(to,from,n) __indirect_copy_from_user(to,from,n)
+#define copy_from_user(to,from,n) indirect_copy_from_user(to,from,n)
+#define __get_user(val,ptr) __indirect_get_user(val,ptr)
+#define get_user(val,ptr) indirect_get_user(val,ptr)
+#define __put_user(val,ptr) __indirect_put_user(val,ptr)
+#define put_user(val,ptr) indirect_put_user(val,ptr)
+#define strlen_user(str) indirect_strlen_user(str)
+#define strnlen_user(src,count) indirect_strnlen_user(src,count)
+#define strncpy_from_user(dst,src,count) \
+                       indirect_strncpy_from_user(dst,src,count)
+
+#else
+
+#define __clear_user __direct_clear_user
+#define clear_user direct_clear_user
+#define __copy_to_user __direct_copy_to_user
+#define copy_to_user direct_copy_to_user
+#define __copy_from_user __direct_copy_from_user
+#define copy_from_user direct_copy_from_user
+#define __get_user __direct_get_user
+#define get_user direct_get_user
+#define __put_user __direct_put_user
+#define put_user direct_put_user
+#define strlen_user direct_strlen_user
+#define strnlen_user direct_strnlen_user
+#define strncpy_from_user direct_strncpy_from_user
+
+#endif /* CONFIG_X86_UACCESS_INDIRECT */
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 
 #endif /* __i386_UACCESS_H */
index ef936b8..d27db19 100644 (file)
 #define __NR_mq_notify         (__NR_mq_open+4)
 #define __NR_mq_getsetattr     (__NR_mq_open+5)
 #define __NR_sys_kexec_load    283
+#define __NR_ioprio_set                284
+#define __NR_ioprio_get                285
 
-#define NR_syscalls 284
+#define NR_syscalls 286
 
+#ifndef __KERNEL_SYSCALLS_NO_ERRNO__
 /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
 
 #define __syscall_return(type, res) \
@@ -303,6 +306,10 @@ do { \
        return (type) (res); \
 } while (0)
 
+#else
+# define __syscall_return(type, res) return (type) (res)
+#endif
+
 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
 #define _syscall0(type,name) \
 type name(void) \
diff --git a/include/asm-i386/upd4990a.h b/include/asm-i386/upd4990a.h
deleted file mode 100644 (file)
index de4f4ed..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *  Architecture dependent definitions
- *  for NEC uPD4990A serial I/O real-time clock.
- *
- *  Copyright 2001  TAKAI Kousuke <tak@kmc.kyoto-u.ac.jp>
- *                 Kyoto University Microcomputer Club (KMC).
- *
- *  References:
- *     uPD4990A serial I/O real-time clock users' manual (Japanese)
- *     No. S12828JJ4V0UM00 (4th revision), NEC Corporation, 1999.
- */
-
-#ifndef _ASM_I386_uPD4990A_H
-#define _ASM_I386_uPD4990A_H
-
-#include <asm/io.h>
-
-#define UPD4990A_IO            (0x0020)
-#define UPD4990A_IO_DATAOUT    (0x0033)
-
-#define UPD4990A_OUTPUT_DATA_CLK(data, clk)            \
-       outb((((data) & 1) << 5) | (((clk) & 1) << 4)   \
-             | UPD4990A_PAR_SERIAL_MODE, UPD4990A_IO)
-
-#define UPD4990A_OUTPUT_CLK(clk)       UPD4990A_OUTPUT_DATA_CLK(0, (clk))
-
-#define UPD4990A_OUTPUT_STROBE(stb) \
-       outb(((stb) << 3) | UPD4990A_PAR_SERIAL_MODE, UPD4990A_IO)
-
-/*
- * Note: udelay() is *not* usable for UPD4990A_DELAY because
- *      the Linux kernel reads uPD4990A to set up system clock
- *      before calibrating delay...
- */
-#define UPD4990A_DELAY(usec)                                           \
-       do {                                                            \
-               if (__builtin_constant_p((usec)) && (usec) < 5) \
-                       __asm__ (".rept %c1\n\toutb %%al,%0\n\t.endr"   \
-                                : : "N" (0x5F),                        \
-                                    "i" (((usec) * 10 + 5) / 6));      \
-               else {                                                  \
-                       int _count = ((usec) * 10 + 5) / 6;             \
-                       __asm__ volatile ("1: outb %%al,%1\n\tloop 1b"  \
-                                         : "=c" (_count)               \
-                                         : "N" (0x5F), "0" (_count));  \
-               }                                                       \
-       } while (0)
-
-/* Caller should ignore all bits except bit0 */
-#define UPD4990A_READ_DATA()   inb(UPD4990A_IO_DATAOUT)
-
-#endif
diff --git a/include/asm-ia64/cpumask.h b/include/asm-ia64/cpumask.h
deleted file mode 100644 (file)
index 7764aef..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_IA64_CPUMASK_H
-#define _ASM_IA64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_IA64_CPUMASK_H */
diff --git a/include/asm-ia64/crash.h b/include/asm-ia64/crash.h
new file mode 100644 (file)
index 0000000..f51e828
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef _ASM_IA64_CRASH_H
+#define _ASM_IA64_CRASH_H
+
+/*
+ * linux/include/asm-ia64/crash.h
+ *
+ * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifdef __KERNEL__
+
+#include <linux/efi.h>
+#include <linux/mm.h>
+#include <asm/mmzone.h>
+
+static inline void *
+map_virtual(u64 offset, struct page **pp)
+{
+       struct page *page;
+       unsigned long pfn;
+       u32 type;
+
+       if (REGION_NUMBER(offset) == 5) {
+               char byte;
+
+               if (__get_user(byte, (char *)offset) == 0)
+                       return (void *)offset;
+               else
+                       return NULL;
+       }
+
+       switch (type = efi_mem_type(offset)) 
+       {
+       case EFI_LOADER_CODE:
+       case EFI_LOADER_DATA:
+       case EFI_BOOT_SERVICES_CODE:
+       case EFI_BOOT_SERVICES_DATA:
+       case EFI_CONVENTIONAL_MEMORY:
+               break;
+
+       default:
+               printk(KERN_INFO
+                   "crash memory driver: invalid memory type for %lx: %d\n", 
+                       offset, type);
+               return NULL;
+       }
+
+       pfn = offset >> PAGE_SHIFT;
+
+        if (!pfn_valid(pfn)) {
+                printk(KERN_INFO
+                    "crash memory driver: invalid pfn: %lx )\n", pfn);
+                return NULL;
+        }
+
+       page = pfn_to_page(pfn);
+
+       if (!page->virtual) {
+               printk(KERN_INFO
+                   "crash memory driver: offset: %lx page: %lx page->virtual: NULL\n", 
+                       offset, (unsigned long)page);
+               return NULL;
+       }
+
+       return (page->virtual + (offset & (PAGE_SIZE-1)));
+}
+
+static inline void unmap_virtual(struct page *page) 
+{ 
+       return;
+}
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_IA64_CRASH_H */
index d193981..7499eaa 100644 (file)
@@ -29,6 +29,7 @@
 #define O_DIRECTORY    0200000 /* must be a directory */
 #define O_NOFOLLOW     0400000 /* don't follow links */
 #define O_NOATIME      01000000
+#define O_ATOMICLOOKUP  02000000 /* do atomic file lookup */
 
 #define F_DUPFD                0       /* dup */
 #define F_GETFD                1       /* get close_on_exec */
diff --git a/include/asm-ia64/netdump.h b/include/asm-ia64/netdump.h
new file mode 100644 (file)
index 0000000..49f3fbd
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _ASM_IA64_NETDUMP_H_
+#define _ASM_IA64_NETDUMP_H_
+
+#include <asm-generic/netdump.h>
+
+#endif /* _ASM_IA64_NETDUMP_H_ */
index 315a863..7b1e650 100644 (file)
@@ -187,4 +187,6 @@ get_order (unsigned long size)
                                         (((current->personality & READ_IMPLIES_EXEC) != 0)     \
                                          ? VM_EXEC : 0))
 
+#define devmem_is_allowed(x) 1
+
 #endif /* _ASM_IA64_PAGE_H */
index 9733168..4e9da65 100644 (file)
 #include <asm/mmu_context.h>
 #include <asm/processor.h>
 
+#define arch_add_exec_range(mm, limit)         do { ; } while (0)
+#define arch_flush_exec_range(mm)              do { ; } while (0)
+#define arch_remove_exec_range(mm, limit)      do { ; } while (0)
+
 /*
  * Very stupidly, we used to get new pgd's and pmd's, init their contents
  * to point to the NULL versions of the next level page table, later on
diff --git a/include/asm-ia64/relay.h b/include/asm-ia64/relay.h
new file mode 100644 (file)
index 0000000..1d7628e
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_IA64_RELAY_H
+#define _ASM_IA64_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 76345b5..d4f90c2 100644 (file)
@@ -46,7 +46,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-ia64/rmap.h b/include/asm-ia64/rmap.h
deleted file mode 100644 (file)
index 179c565..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _ASM_IA64_RMAP_H
-#define _ASM_IA64_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif /* _ASM_IA64_RMAP_H */
index fa472c3..ef60438 100644 (file)
@@ -9,11 +9,11 @@
 #define _ASM_IA64_SN_PDA_H
 
 #include <linux/cache.h>
+#include <linux/numa.h>
 #include <asm/percpu.h>
 #include <asm/system.h>
 #include <asm/sn/bte.h>
 
-
 /*
  * CPU-specific data structure.
  *
index 6019e23..d5c39f7 100644 (file)
@@ -164,7 +164,8 @@ tlb_finish_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long end)
 
        if (rss < freed)
                freed = rss;
-       mm->rss = rss - freed;
+       // mm->rss = rss - freed;
+       vx_rsspages_sub(mm, freed);
        /*
         * Note: tlb->nr may be 0 at this point, so we can't rely on tlb->start_addr and
         * tlb->end_addr.
index 31d60e5..b52fd32 100644 (file)
@@ -202,7 +202,8 @@ extern unsigned long __copy_user (void *to, const void *from, unsigned long coun
 
 #define __copy_to_user(to, from, n)    __copy_user((to), (from), (n))
 #define __copy_from_user(to, from, n)  __copy_user((to), (from), (n))
-
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
 #define copy_to_user(to, from, n)      __copy_tofrom_user((to), (from), (n), 1)
 #define copy_from_user(to, from, n)    __copy_tofrom_user((to), (from), (n), 0)
 
index d46f47f..1f0a16b 100644 (file)
 #define __NR_syslog                    1117
 #define __NR_setitimer                 1118
 #define __NR_getitimer                 1119
-/* 1120 was __NR_old_stat */
+#define __NR_tux                       1120 /* was __NR_old_stat */
 /* 1121 was __NR_old_lstat */
 /* 1122 was __NR_old_fstat */
 #define __NR_vhangup                   1123
diff --git a/include/asm-m68k/cpumask.h b/include/asm-m68k/cpumask.h
deleted file mode 100644 (file)
index b124503..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_M68K_CPUMASK_H
-#define _ASM_M68K_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_M68K_CPUMASK_H */
diff --git a/include/asm-m68k/init.h b/include/asm-m68k/init.h
deleted file mode 100644 (file)
index aa33519..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _M68K_INIT_H
-#define _M68K_INIT_H
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-/* For assembly routines */
-#define __INIT         .section        ".text.init",#alloc,#execinstr
-#define __FINIT                .previous
-#define __INITDATA     .section        ".data.init",#alloc,#write
-
-#endif
index 99a5167..3fa5600 100644 (file)
@@ -190,6 +190,8 @@ static inline void *__va(unsigned long x)
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _M68K_PAGE_H */
diff --git a/include/asm-m68k/relay.h b/include/asm-m68k/relay.h
new file mode 100644 (file)
index 0000000..ec637ff
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_M68K_RELAY_H
+#define _ASM_M68K_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 8362001..e1f406b 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-m68k/rmap.h b/include/asm-m68k/rmap.h
deleted file mode 100644 (file)
index 85119e4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _M68K_RMAP_H
-#define _M68K_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index 5ea8444..38388dc 100644 (file)
@@ -521,6 +521,9 @@ __constant_copy_from_user(void *to, const void *from, unsigned long n)
         : "0"(to), "1"(from), "2"(n/4)                 \
         : "d0", "memory")
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 static inline unsigned long
 __constant_copy_to_user(void *to, const void *from, unsigned long n)
 {
index 6a10578..f842fcd 100644 (file)
 #define __NR_fremovexattr      234
 #define __NR_futex             235
 
-#define NR_syscalls            236
+#define __NR_vserver           273
+
+#define NR_syscalls            274
 
 /* user-visible error numbers are in the range -1 - -124: see
    <asm-m68k/errno.h> */
diff --git a/include/asm-m68knommu/cpumask.h b/include/asm-m68knommu/cpumask.h
deleted file mode 100644 (file)
index cd9cc78..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_M68KNOMMU_CPUMASK_H
-#define _ASM_M68KNOMMU_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_M68KNOMMU_CPUMASK_H */
diff --git a/include/asm-m68knommu/init.h b/include/asm-m68knommu/init.h
deleted file mode 100644 (file)
index 596fd41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-m68k/init.h>
index 0d063a9..14e8d8f 100644 (file)
@@ -96,6 +96,8 @@ extern unsigned long memory_end;
 
 #endif /* __ASSEMBLY__ */
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _M68KNOMMU_PAGE_H */
diff --git a/include/asm-m68knommu/relay.h b/include/asm-m68knommu/relay.h
new file mode 100644 (file)
index 0000000..ef1afa6
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_M68KNOMMU_RELAY_H
+#define _ASM_M68KNOMMU_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
diff --git a/include/asm-m68knommu/rmap.h b/include/asm-m68knommu/rmap.h
deleted file mode 100644 (file)
index b3664cc..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Do not need anything here */
-
index 9f890ed..9bda787 100644 (file)
@@ -134,6 +134,8 @@ extern int __get_user_bad(void);
 
 #define __copy_from_user(to, from, n) copy_from_user(to, from, n)
 #define __copy_to_user(to, from, n) copy_to_user(to, from, n)
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
 
 #define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
 
index b10e469..833cb04 100644 (file)
 #define __NR_setfsuid32                215
 #define __NR_setfsgid32                216
 
-#define        NR_syscalls             256
+#define __NR_vserver           273
+
+#define NR_syscalls            274
 
 /* user-visible error numbers are in the range -1 - -122: see
    <asm-m68k/errno.h> */
diff --git a/include/asm-mips/cpumask.h b/include/asm-mips/cpumask.h
deleted file mode 100644 (file)
index cf562af..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_MIPS_CPUMASK_H
-#define _ASM_MIPS_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_MIPS_CPUMASK_H */
diff --git a/include/asm-mips/init.h b/include/asm-mips/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
index 47ca67f..47fcb86 100644 (file)
@@ -137,4 +137,6 @@ static __inline__ int get_order(unsigned long size)
 #define WANT_PAGE_VIRTUAL
 #endif
 
+#define devmem_is_allowed(x) 1
+
 #endif /* _ASM_PAGE_H */
index a502e83..8e38389 100644 (file)
@@ -137,9 +137,9 @@ extern unsigned int vced_count, vcei_count;
 #endif
 
 /*
- * Size of io_bitmap in longwords.
+ * Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
  */
-#define IO_BITMAP_SIZE 2048
+#define IO_BITMAP_SIZE 32
 
 #define NUM_FPU_REGS   32
 
diff --git a/include/asm-mips/relay.h b/include/asm-mips/relay.h
new file mode 100644 (file)
index 0000000..37304bd
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_RELAY_H
+#define _ASM_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
diff --git a/include/asm-mips/rmap.h b/include/asm-mips/rmap.h
deleted file mode 100644 (file)
index c9efd7b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __ASM_RMAP_H
-#define __ASM_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif /* __ASM_RMAP_H */
index e143e4e..759d072 100644 (file)
@@ -463,6 +463,9 @@ extern size_t __copy_user(void *__to, const void *__from, size_t __n);
        __cu_len;                                                       \
 })
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 /*
  * copy_to_user: - Copy a block of data into user space.
  * @to:   Destination address, in user space.
diff --git a/include/asm-mips/vr41xx/eagle.h b/include/asm-mips/vr41xx/eagle.h
deleted file mode 100644 (file)
index 9cbd61c..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * FILE NAME
- *     include/asm-mips/vr41xx/eagle.h
- *
- * BRIEF MODULE DESCRIPTION
- *     Include file for NEC Eagle board.
- *
- * Author: MontaVista Software, Inc.
- *         yyuasa@mvista.com or source@mvista.com
- *
- * Copyright 2001-2003 MontaVista Software Inc.
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2 of the License, or (at your
- *  option) any later version.
- *
- *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#ifndef __NEC_EAGLE_H
-#define __NEC_EAGLE_H
-
-#include <asm/addrspace.h>
-#include <asm/vr41xx/vr41xx.h>
-
-/*
- * Board specific address mapping
- */
-#define VR41XX_PCI_MEM1_BASE           0x10000000
-#define VR41XX_PCI_MEM1_SIZE           0x04000000
-#define VR41XX_PCI_MEM1_MASK           0x7c000000
-
-#define VR41XX_PCI_MEM2_BASE           0x14000000
-#define VR41XX_PCI_MEM2_SIZE           0x02000000
-#define VR41XX_PCI_MEM2_MASK           0x7e000000
-
-#define VR41XX_PCI_IO_BASE             0x16000000
-#define VR41XX_PCI_IO_SIZE             0x02000000
-#define VR41XX_PCI_IO_MASK             0x7e000000
-
-#define VR41XX_PCI_IO_START            0x01000000
-#define VR41XX_PCI_IO_END              0x01ffffff
-
-#define VR41XX_PCI_MEM_START           0x12000000
-#define VR41XX_PCI_MEM_END             0x15ffffff
-
-#define IO_PORT_BASE                   KSEG1ADDR(VR41XX_PCI_IO_BASE)
-#define IO_PORT_RESOURCE_START         0
-#define IO_PORT_RESOURCE_END           VR41XX_PCI_IO_SIZE
-#define IO_MEM1_RESOURCE_START         VR41XX_PCI_MEM1_BASE
-#define IO_MEM1_RESOURCE_END           (VR41XX_PCI_MEM1_BASE + VR41XX_PCI_MEM1_SIZE)
-#define IO_MEM2_RESOURCE_START         VR41XX_PCI_MEM2_BASE
-#define IO_MEM2_RESOURCE_END           (VR41XX_PCI_MEM2_BASE + VR41XX_PCI_MEM2_SIZE)
-
-/*
- * General-Purpose I/O Pin Number
- */
-#define VRC4173_PIN                    1
-#define PCISLOT_PIN                    4
-#define FPGA_PIN                       5
-#define DCD_PIN                                15
-
-/*
- * Interrupt Number
- */
-#define VRC4173_CASCADE_IRQ            GIU_IRQ(VRC4173_PIN)
-#define PCISLOT_IRQ                    GIU_IRQ(PCISLOT_PIN)
-#define FPGA_CASCADE_IRQ               GIU_IRQ(FPGA_PIN)
-#define DCD_IRQ                                GIU_IRQ(DCD_PIN)
-
-#define SDBINT_IRQ_BASE                        88
-#define SDBINT_IRQ(x)                  (SDBINT_IRQ_BASE + (x))
-/* RFU */
-#define DEG_IRQ                                SDBINT_IRQ(1)
-#define ENUM_IRQ                       SDBINT_IRQ(2)
-#define SIO1INT_IRQ                    SDBINT_IRQ(3)
-#define SIO2INT_IRQ                    SDBINT_IRQ(4)
-#define PARINT_IRQ                     SDBINT_IRQ(5)
-#define SDBINT_IRQ_LAST                        PARINT_IRQ
-
-#define PCIINT_IRQ_BASE                        96
-#define PCIINT_IRQ(x)                  (PCIINT_IRQ_BASE + (x))
-#define CP_INTA_IRQ                    PCIINT_IRQ(0)
-#define CP_INTB_IRQ                    PCIINT_IRQ(1)
-#define CP_INTC_IRQ                    PCIINT_IRQ(2)
-#define CP_INTD_IRQ                    PCIINT_IRQ(3)
-#define LANINTA_IRQ                    PCIINT_IRQ(4)
-#define PCIINT_IRQ_LAST                        LANINTA_IRQ
-
-/*
- * On board Devices I/O Mapping
- */
-#define NEC_EAGLE_SIO1RB               KSEG1ADDR(0x0DFFFEC0)
-#define NEC_EAGLE_SIO1TH               KSEG1ADDR(0x0DFFFEC0)
-#define NEC_EAGLE_SIO1IE               KSEG1ADDR(0x0DFFFEC2)
-#define NEC_EAGLE_SIO1IID              KSEG1ADDR(0x0DFFFEC4)
-#define NEC_EAGLE_SIO1FC               KSEG1ADDR(0x0DFFFEC4)
-#define NEC_EAGLE_SIO1LC               KSEG1ADDR(0x0DFFFEC6)
-#define NEC_EAGLE_SIO1MC               KSEG1ADDR(0x0DFFFEC8)
-#define NEC_EAGLE_SIO1LS               KSEG1ADDR(0x0DFFFECA)
-#define NEC_EAGLE_SIO1MS               KSEG1ADDR(0x0DFFFECC)
-#define NEC_EAGLE_SIO1SC               KSEG1ADDR(0x0DFFFECE)
-
-#define NEC_EAGLE_SIO2TH               KSEG1ADDR(0x0DFFFED0)
-#define NEC_EAGLE_SIO2IE               KSEG1ADDR(0x0DFFFED2)
-#define NEC_EAGLE_SIO2IID              KSEG1ADDR(0x0DFFFED4)
-#define NEC_EAGLE_SIO2FC               KSEG1ADDR(0x0DFFFED4)
-#define NEC_EAGLE_SIO2LC               KSEG1ADDR(0x0DFFFED6)
-#define NEC_EAGLE_SIO2MC               KSEG1ADDR(0x0DFFFED8)
-#define NEC_EAGLE_SIO2LS               KSEG1ADDR(0x0DFFFEDA)
-#define NEC_EAGLE_SIO2MS               KSEG1ADDR(0x0DFFFEDC)
-#define NEC_EAGLE_SIO2SC               KSEG1ADDR(0x0DFFFEDE)
-
-#define NEC_EAGLE_PIOPP_DATA           KSEG1ADDR(0x0DFFFEE0)
-#define NEC_EAGLE_PIOPP_STATUS         KSEG1ADDR(0x0DFFFEE2)
-#define NEC_EAGLE_PIOPP_CNT            KSEG1ADDR(0x0DFFFEE4)
-#define NEC_EAGLE_PIOPP_EPPADDR                KSEG1ADDR(0x0DFFFEE6)
-#define NEC_EAGLE_PIOPP_EPPDATA0       KSEG1ADDR(0x0DFFFEE8)
-#define NEC_EAGLE_PIOPP_EPPDATA1       KSEG1ADDR(0x0DFFFEEA)
-#define NEC_EAGLE_PIOPP_EPPDATA2       KSEG1ADDR(0x0DFFFEEC)
-
-#define NEC_EAGLE_PIOECP_DATA          KSEG1ADDR(0x0DFFFEF0)
-#define NEC_EAGLE_PIOECP_CONFIG                KSEG1ADDR(0x0DFFFEF2)
-#define NEC_EAGLE_PIOECP_EXTCNT                KSEG1ADDR(0x0DFFFEF4)
-
-/*
- *  FLSHCNT Register
- */
-#define NEC_EAGLE_FLSHCNT              KSEG1ADDR(0x0DFFFFA0)
-#define NEC_EAGLE_FLSHCNT_FRDY         0x80
-#define NEC_EAGLE_FLSHCNT_VPPE         0x40
-#define NEC_EAGLE_FLSHCNT_WP2          0x01
-
-/*
- * FLSHBANK Register
- */
-#define NEC_EAGLE_FLSHBANK             KSEG1ADDR(0x0DFFFFA4)
-#define NEC_EAGLE_FLSHBANK_S_BANK2     0x40
-#define NEC_EAGLE_FLSHBANK_S_BANK1     0x20
-#define NEC_EAGLE_FLSHBANK_BNKQ4       0x10
-#define NEC_EAGLE_FLSHBANK_BNKQ3       0x08
-#define NEC_EAGLE_FLSHBANK_BNKQ2       0x04
-#define NEC_EAGLE_FLSHBANK_BNKQ1       0x02
-#define NEC_EAGLE_FLSHBANK_BNKQ0       0x01
-
-/*
- * SWITCH Setting Register
- */
-#define NEC_EAGLE_SWTCHSET             KSEG1ADDR(0x0DFFFFA8)
-#define NEC_EAGLE_SWTCHSET_DP2SW4      0x80
-#define NEC_EAGLE_SWTCHSET_DP2SW3      0x40
-#define NEC_EAGLE_SWTCHSET_DP2SW2      0x20
-#define NEC_EAGLE_SWTCHSET_DP2SW1      0x10
-#define NEC_EAGLE_SWTCHSET_DP1SW4      0x08
-#define NEC_EAGLE_SWTCHSET_DP1SW3      0x04
-#define NEC_EAGLE_SWTCHSET_DP1SW2      0x02
-#define NEC_EAGLE_SWTCHSET_DP1SW1      0x01
-
-/*
- * PPT Parallel Port Device Controller
- */
-#define NEC_EAGLE_PPT_WRITE_DATA       KSEG1ADDR(0x0DFFFFB0)
-#define NEC_EAGLE_PPT_READ_DATA                KSEG1ADDR(0x0DFFFFB2)
-#define NEC_EAGLE_PPT_CNT              KSEG1ADDR(0x0DFFFFB4)
-#define NEC_EAGLE_PPT_CNT2             KSEG1ADDR(0x0DFFFFB4)
-
-/* Control Register */
-#define NEC_EAGLE_PPT_INTMSK           0x20
-#define NEC_EAGLE_PPT_PARIINT          0x10
-#define NEC_EAGLE_PPT_SELECTIN         0x08
-#define NEC_EAGLE_PPT_INIT             0x04
-#define NEC_EAGLE_PPT_AUTOFD           0x02
-#define NEC_EAGLE_PPT_STROBE           0x01
-
-/* Control Rgister 2 */
-#define NEC_EAGLE_PPT_PAREN            0x80
-#define NEC_EAGLE_PPT_AUTOEN           0x20
-#define NEC_EAGLE_PPT_BUSY             0x10
-#define NEC_EAGLE_PPT_ACK              0x08
-#define NEC_EAGLE_PPT_PE               0x04
-#define NEC_EAGLE_PPT_SELECT           0x02
-#define NEC_EAGLE_PPT_FAULT            0x01
-
-/*
- * LEDWR Register
- */
-#define NEC_EAGLE_LEDWR1               KSEG1ADDR(0x0DFFFFC0)
-#define NEC_EAGLE_LEDWR2               KSEG1ADDR(0x0DFFFFC4)
-
-/*
- * SDBINT Register
- */
-#define NEC_EAGLE_SDBINT               KSEG1ADDR(0x0DFFFFD0)
-#define NEC_EAGLE_SDBINT_PARINT                0x20
-#define NEC_EAGLE_SDBINT_SIO2INT       0x10
-#define NEC_EAGLE_SDBINT_SIO1INT       0x08
-#define NEC_EAGLE_SDBINT_ENUM          0x04
-#define NEC_EAGLE_SDBINT_DEG           0x02
-
-/*
- * SDB INTMSK Register
- */
-#define NEC_EAGLE_SDBINTMSK            KSEG1ADDR(0x0DFFFFD4)
-#define NEC_EAGLE_SDBINTMSK_MSKPAR     0x20
-#define NEC_EAGLE_SDBINTMSK_MSKSIO2    0x10
-#define NEC_EAGLE_SDBINTMSK_MSKSIO1    0x08
-#define NEC_EAGLE_SDBINTMSK_MSKENUM    0x04
-#define NEC_EAGLE_SDBINTMSK_MSKDEG     0x02
-
-/*
- * RSTREG Register
- */
-#define NEC_EAGLE_RSTREG               KSEG1ADDR(0x0DFFFFD8)
-#define NEC_EAGLE_RST_RSTSW            0x02
-#define NEC_EAGLE_RST_LEDOFF           0x01
-
-/*
- * PCI INT Rgister
- */
-#define NEC_EAGLE_PCIINTREG            KSEG1ADDR(0x0DFFFFDC)
-#define NEC_EAGLE_PCIINT_LANINT                0x10
-#define NEC_EAGLE_PCIINT_CP_INTD       0x08
-#define NEC_EAGLE_PCIINT_CP_INTC       0x04
-#define NEC_EAGLE_PCIINT_CP_INTB       0x02
-#define NEC_EAGLE_PCIINT_CP_INTA       0x01
-
-/*
- * PCI INT Mask Register
- */
-#define NEC_EAGLE_PCIINTMSKREG         KSEG1ADDR(0x0DFFFFE0)
-#define NEC_EAGLE_PCIINTMSK_MSKLANINT  0x10
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTD 0x08
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTC 0x04
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTB 0x02
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTA 0x01
-
-/*
- * CLK Division Register
- */
-#define NEC_EAGLE_CLKDIV               KSEG1ADDR(0x0DFFFFE4)
-#define NEC_EAGLE_CLKDIV_PCIDIV1       0x10
-#define NEC_EAGLE_CLKDIV_PCIDIV0       0x08
-#define NEC_EAGLE_CLKDIV_VTDIV2                0x04
-#define NEC_EAGLE_CLKDIV_VTDIV1                0x02
-#define NEC_EAGLE_CLKDIV_VTDIV0                0x01
-
-/*
- * Source Revision Register
- */
-#define NEC_EAGLE_REVISION             KSEG1ADDR(0x0DFFFFE8)
-
-#endif /* __NEC_EAGLE_H */
diff --git a/include/asm-mips/vr41xx/tb0229.h b/include/asm-mips/vr41xx/tb0229.h
deleted file mode 100644 (file)
index bd8cbc8..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * FILE NAME
- *     include/asm-mips/vr41xx/tb0229.h
- *
- * BRIEF MODULE DESCRIPTION
- *     Include file for TANBAC TB0229 and TB0219.
- *
- * Copyright 2002,2003 Yoichi Yuasa
- *                yuasa@hh.iij4u.or.jp
- *
- * Modified for TANBAC TB0229:
- * Copyright 2003 Megasolution Inc.
- *                matsu@megasolution.jp
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2 of the License, or (at your
- *  option) any later version.
- */
-#ifndef __TANBAC_TB0229_H
-#define __TANBAC_TB0229_H
-
-#include <asm/addrspace.h>
-#include <asm/vr41xx/vr41xx.h>
-
-/*
- * Board specific address mapping
- */
-#define VR41XX_PCI_MEM1_BASE           0x10000000
-#define VR41XX_PCI_MEM1_SIZE           0x04000000
-#define VR41XX_PCI_MEM1_MASK           0x7c000000
-
-#define VR41XX_PCI_MEM2_BASE           0x14000000
-#define VR41XX_PCI_MEM2_SIZE           0x02000000
-#define VR41XX_PCI_MEM2_MASK           0x7e000000
-
-#define VR41XX_PCI_IO_BASE             0x16000000
-#define VR41XX_PCI_IO_SIZE             0x02000000
-#define VR41XX_PCI_IO_MASK             0x7e000000
-
-#define VR41XX_PCI_IO_START            0x01000000
-#define VR41XX_PCI_IO_END              0x01ffffff
-
-#define VR41XX_PCI_MEM_START           0x12000000
-#define VR41XX_PCI_MEM_END             0x15ffffff
-
-#define IO_PORT_BASE                   KSEG1ADDR(VR41XX_PCI_IO_BASE)
-#define IO_PORT_RESOURCE_START         0
-#define IO_PORT_RESOURCE_END           VR41XX_PCI_IO_SIZE
-#define IO_MEM1_RESOURCE_START         VR41XX_PCI_MEM1_BASE
-#define IO_MEM1_RESOURCE_END           (VR41XX_PCI_MEM1_BASE + VR41XX_PCI_MEM1_SIZE)
-#define IO_MEM2_RESOURCE_START         VR41XX_PCI_MEM2_BASE
-#define IO_MEM2_RESOURCE_END           (VR41XX_PCI_MEM2_BASE + VR41XX_PCI_MEM2_SIZE)
-
-/*
- * General-Purpose I/O Pin Number
- */
-#define TB0219_PCI_SLOT1_PIN           2
-#define TB0219_PCI_SLOT2_PIN           3
-#define TB0219_PCI_SLOT3_PIN           4
-
-/*
- * Interrupt Number
- */
-#define TB0219_PCI_SLOT1_IRQ           GIU_IRQ(TB0219_PCI_SLOT1_PIN)
-#define TB0219_PCI_SLOT2_IRQ           GIU_IRQ(TB0219_PCI_SLOT2_PIN)
-#define TB0219_PCI_SLOT3_IRQ           GIU_IRQ(TB0219_PCI_SLOT3_PIN)
-
-#define TB0219_RESET_REGS              KSEG1ADDR(0x0a00000e)
-
-extern void tanbac_tb0229_restart(char *command);
-
-#endif /* __TANBAC_TB0229_H */
diff --git a/include/asm-mips64/relay.h b/include/asm-mips64/relay.h
new file mode 100644 (file)
index 0000000..37304bd
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_RELAY_H
+#define _ASM_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
diff --git a/include/asm-parisc/cpumask.h b/include/asm-parisc/cpumask.h
deleted file mode 100644 (file)
index 27f4f17..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_PARISC_CPUMASK_H
-#define _ASM_PARISC_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_PARISC_CPUMASK_H */
index 4a12692..cb77536 100644 (file)
@@ -157,6 +157,8 @@ extern int npmem_ranges;
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _PARISC_PAGE_H */
diff --git a/include/asm-parisc/relay.h b/include/asm-parisc/relay.h
new file mode 100644 (file)
index 0000000..cea0c77
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_PARISC_RELAY_H
+#define _ASM_PARISC_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 59a4465..a60e62e 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-parisc/rmap.h b/include/asm-parisc/rmap.h
deleted file mode 100644 (file)
index 4ea8eb4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _PARISC_RMAP_H
-#define _PARISC_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index f147bac..ee2e2a5 100644 (file)
@@ -279,5 +279,7 @@ extern long lstrnlen_user(const char __user *,long);
 #define __copy_to_user lcopy_to_user
 #define copy_in_user lcopy_in_user
 #define __copy_in_user lcopy_in_user
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
 
 #endif /* __PARISC_UACCESS_H */
index c862d24..2a3434d 100644 (file)
 #define __NR_mq_notify          (__NR_Linux + 233)
 #define __NR_mq_getsetattr      (__NR_Linux + 234)
 
-#define __NR_Linux_syscalls     235
+#define __NR_vserver           (__NR_Linux + 273)
+
+#define __NR_Linux_syscalls     273
 
 #define HPUX_GATEWAY_ADDR       0xC0000004
 #define LINUX_GATEWAY_ADDR      0x100
diff --git a/include/asm-parisc/unwind.h b/include/asm-parisc/unwind.h
deleted file mode 100644 (file)
index ff9396b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef _UNWIND_H_
-#define _UNWIND_H_
-
-/* From ABI specifications */
-struct unwind_table_entry {
-       unsigned int region_start;
-       unsigned int region_end;
-       unsigned int Cannot_unwind:1; /* 0 */
-       unsigned int Millicode:1;       /* 1 */
-       unsigned int Millicode_save_sr0:1;      /* 2 */
-       unsigned int Region_description:2;      /* 3..4 */
-       unsigned int reserved1:1;       /* 5 */
-       unsigned int Entry_SR:1;        /* 6 */
-       unsigned int Entry_FR:4;        /* number saved *//* 7..10 */
-       unsigned int Entry_GR:5;        /* number saved *//* 11..15 */
-       unsigned int Args_stored:1;     /* 16 */
-       unsigned int Variable_Frame:1;  /* 17 */
-       unsigned int Separate_Package_Body:1;   /* 18 */
-       unsigned int Frame_Extension_Millicode:1;       /* 19 */
-       unsigned int Stack_Overflow_Check:1;    /* 20 */
-       unsigned int Two_Instruction_SP_Increment:1;    /* 21 */
-       unsigned int Ada_Region:1;      /* 22 */
-       unsigned int cxx_info:1;        /* 23 */
-       unsigned int cxx_try_catch:1;   /* 24 */
-       unsigned int sched_entry_seq:1; /* 25 */
-       unsigned int reserved2:1;       /* 26 */
-       unsigned int Save_SP:1; /* 27 */
-       unsigned int Save_RP:1; /* 28 */
-       unsigned int Save_MRP_in_frame:1;       /* 29 */
-       unsigned int extn_ptr_defined:1;        /* 30 */
-       unsigned int Cleanup_defined:1; /* 31 */
-       
-       unsigned int MPE_XL_interrupt_marker:1; /* 0 */
-       unsigned int HP_UX_interrupt_marker:1;  /* 1 */
-       unsigned int Large_frame:1;     /* 2 */
-       unsigned int Pseudo_SP_Set:1;   /* 3 */
-       unsigned int reserved4:1;       /* 4 */
-       unsigned int Total_frame_size:27;       /* 5..31 */
-};
-
-struct unwind_table {
-       struct unwind_table *next;
-       const char *name;
-       unsigned long gp;
-       unsigned long base_addr;
-       unsigned long start;
-       unsigned long end;
-       const struct unwind_table_entry *table;
-       unsigned long length;
-};
-
-struct unwind_frame_info {
-       struct task_struct *t;
-       /* Eventually we would like to be able to get at any of the registers
-          available; but for now we only try to get the sp and ip for each
-          frame */
-       /* struct pt_regs regs; */
-       unsigned long sp, ip, rp;
-       unsigned long prev_sp, prev_ip;
-};
-
-void * unwind_table_add(const char *name, unsigned long base_addr, 
-                unsigned long gp,
-                 void *start, void *end);
-void unwind_frame_init(struct unwind_frame_info *info, struct task_struct *t, 
-                      unsigned long sp, unsigned long ip, unsigned long rp);
-void unwind_frame_init_from_blocked_task(struct unwind_frame_info *info, struct task_struct *t);
-void unwind_frame_init_running(struct unwind_frame_info *info, struct pt_regs *regs);
-int unwind_once(struct unwind_frame_info *info);
-int unwind_to_user(struct unwind_frame_info *info);
-
-#endif
diff --git a/include/asm-ppc/cpm2.h b/include/asm-ppc/cpm2.h
deleted file mode 100644 (file)
index 2957e79..0000000
+++ /dev/null
@@ -1,1044 +0,0 @@
-/*
- * Communication Processor Module v2.
- *
- * This file contains structures and information for the communication
- * processor channels found in the dual port RAM or parameter RAM.
- * All CPM control and status is available through the CPM2 internal
- * memory map.  See immap_cpm2.h for details.
- */
-#ifdef __KERNEL__
-#ifndef __CPM2__
-#define __CPM2__
-
-#include <asm/immap_cpm2.h>
-
-/* CPM Command register.
-*/
-#define CPM_CR_RST     ((uint)0x80000000)
-#define CPM_CR_PAGE    ((uint)0x7c000000)
-#define CPM_CR_SBLOCK  ((uint)0x03e00000)
-#define CPM_CR_FLG     ((uint)0x00010000)
-#define CPM_CR_MCN     ((uint)0x00003fc0)
-#define CPM_CR_OPCODE  ((uint)0x0000000f)
-
-/* Device sub-block and page codes.
-*/
-#define CPM_CR_SCC1_SBLOCK     (0x04)
-#define CPM_CR_SCC2_SBLOCK     (0x05)
-#define CPM_CR_SCC3_SBLOCK     (0x06)
-#define CPM_CR_SCC4_SBLOCK     (0x07)
-#define CPM_CR_SMC1_SBLOCK     (0x08)
-#define CPM_CR_SMC2_SBLOCK     (0x09)
-#define CPM_CR_SPI_SBLOCK      (0x0a)
-#define CPM_CR_I2C_SBLOCK      (0x0b)
-#define CPM_CR_TIMER_SBLOCK    (0x0f)
-#define CPM_CR_RAND_SBLOCK     (0x0e)
-#define CPM_CR_FCC1_SBLOCK     (0x10)
-#define CPM_CR_FCC2_SBLOCK     (0x11)
-#define CPM_CR_FCC3_SBLOCK     (0x12)
-#define CPM_CR_IDMA1_SBLOCK    (0x14)
-#define CPM_CR_IDMA2_SBLOCK    (0x15)
-#define CPM_CR_IDMA3_SBLOCK    (0x16)
-#define CPM_CR_IDMA4_SBLOCK    (0x17)
-#define CPM_CR_MCC1_SBLOCK     (0x1c)
-
-#define CPM_CR_SCC1_PAGE       (0x00)
-#define CPM_CR_SCC2_PAGE       (0x01)
-#define CPM_CR_SCC3_PAGE       (0x02)
-#define CPM_CR_SCC4_PAGE       (0x03)
-#define CPM_CR_SMC1_PAGE       (0x07)
-#define CPM_CR_SMC2_PAGE       (0x08)
-#define CPM_CR_SPI_PAGE                (0x09)
-#define CPM_CR_I2C_PAGE                (0x0a)
-#define CPM_CR_TIMER_PAGE      (0x0a)
-#define CPM_CR_RAND_PAGE       (0x0a)
-#define CPM_CR_FCC1_PAGE       (0x04)
-#define CPM_CR_FCC2_PAGE       (0x05)
-#define CPM_CR_FCC3_PAGE       (0x06)
-#define CPM_CR_IDMA1_PAGE      (0x07)
-#define CPM_CR_IDMA2_PAGE      (0x08)
-#define CPM_CR_IDMA3_PAGE      (0x09)
-#define CPM_CR_IDMA4_PAGE      (0x0a)
-#define CPM_CR_MCC1_PAGE       (0x07)
-#define CPM_CR_MCC2_PAGE       (0x08)
-
-/* Some opcodes (there are more...later)
-*/
-#define CPM_CR_INIT_TRX                ((ushort)0x0000)
-#define CPM_CR_INIT_RX         ((ushort)0x0001)
-#define CPM_CR_INIT_TX         ((ushort)0x0002)
-#define CPM_CR_HUNT_MODE       ((ushort)0x0003)
-#define CPM_CR_STOP_TX         ((ushort)0x0004)
-#define CPM_CR_RESTART_TX      ((ushort)0x0006)
-#define CPM_CR_SET_GADDR       ((ushort)0x0008)
-#define CPM_CR_START_IDMA      ((ushort)0x0009)
-#define CPM_CR_STOP_IDMA       ((ushort)0x000b)
-
-#define mk_cr_cmd(PG, SBC, MCN, OP) \
-       ((PG << 26) | (SBC << 21) | (MCN << 6) | OP)
-
-/* Dual Port RAM addresses.  The first 16K is available for almost
- * any CPM use, so we put the BDs there.  The first 128 bytes are
- * used for SMC1 and SMC2 parameter RAM, so we start allocating
- * BDs above that.  All of this must change when we start
- * downloading RAM microcode.
- */
-#define CPM_DATAONLY_BASE      ((uint)128)
-#define CPM_DP_NOSPACE         ((uint)0x7fffffff)
-#ifdef CONFIG_8272
-#define CPM_DATAONLY_SIZE      ((uint)(8 * 1024) - CPM_DATAONLY_BASE)
-#define CPM_FCC_SPECIAL_BASE   ((uint)0x00009000)
-#else
-#define CPM_DATAONLY_SIZE      ((uint)(16 * 1024) - CPM_DATAONLY_BASE)
-#define CPM_FCC_SPECIAL_BASE   ((uint)0x0000b000)
-#endif
-
-/* The number of pages of host memory we allocate for CPM.  This is
- * done early in kernel initialization to get physically contiguous
- * pages.
- */
-#define NUM_CPM_HOST_PAGES     2
-
-static inline long IS_DPERR(const uint offset)
-{
-       return (uint)offset > (uint)-1000L;
-}
-
-/* Export the base address of the communication processor registers
- * and dual port ram.
- */
-extern         cpm_cpm2_t      *cpmp;   /* Pointer to comm processor */
-extern uint cpm_dpalloc(uint size, uint align);
-extern int cpm_dpfree(uint offset);
-extern uint cpm_dpalloc_fixed(uint offset, uint size, uint align);
-extern void cpm_dpdump(void);
-extern void *cpm_dpram_addr(uint offset);
-extern void cpm_setbrg(uint brg, uint rate);
-extern void cpm2_fastbrg(uint brg, uint rate, int div16);
-
-/* Buffer descriptors used by many of the CPM protocols.
-*/
-typedef struct cpm_buf_desc {
-       ushort  cbd_sc;         /* Status and Control */
-       ushort  cbd_datlen;     /* Data length in buffer */
-       uint    cbd_bufaddr;    /* Buffer address in host memory */
-} cbd_t;
-
-#define BD_SC_EMPTY    ((ushort)0x8000)        /* Receive is empty */
-#define BD_SC_READY    ((ushort)0x8000)        /* Transmit is ready */
-#define BD_SC_WRAP     ((ushort)0x2000)        /* Last buffer descriptor */
-#define BD_SC_INTRPT   ((ushort)0x1000)        /* Interrupt on change */
-#define BD_SC_LAST     ((ushort)0x0800)        /* Last buffer in frame */
-#define BD_SC_CM       ((ushort)0x0200)        /* Continous mode */
-#define BD_SC_ID       ((ushort)0x0100)        /* Rec'd too many idles */
-#define BD_SC_P                ((ushort)0x0100)        /* xmt preamble */
-#define BD_SC_BR       ((ushort)0x0020)        /* Break received */
-#define BD_SC_FR       ((ushort)0x0010)        /* Framing error */
-#define BD_SC_PR       ((ushort)0x0008)        /* Parity error */
-#define BD_SC_OV       ((ushort)0x0002)        /* Overrun */
-#define BD_SC_CD       ((ushort)0x0001)        /* ?? */
-
-/* Function code bits, usually generic to devices.
-*/
-#define CPMFCR_GBL     ((u_char)0x20)  /* Set memory snooping */
-#define CPMFCR_EB      ((u_char)0x10)  /* Set big endian byte order */
-#define CPMFCR_TC2     ((u_char)0x04)  /* Transfer code 2 value */
-#define CPMFCR_DTB     ((u_char)0x02)  /* Use local bus for data when set */
-#define CPMFCR_BDB     ((u_char)0x01)  /* Use local bus for BD when set */
-
-/* Parameter RAM offsets from the base.
-*/
-#define PROFF_SCC1             ((uint)0x8000)
-#define PROFF_SCC2             ((uint)0x8100)
-#define PROFF_SCC3             ((uint)0x8200)
-#define PROFF_SCC4             ((uint)0x8300)
-#define PROFF_FCC1             ((uint)0x8400)
-#define PROFF_FCC2             ((uint)0x8500)
-#define PROFF_FCC3             ((uint)0x8600)
-#define PROFF_MCC1             ((uint)0x8700)
-#define PROFF_SMC1_BASE                ((uint)0x87fc)
-#define PROFF_IDMA1_BASE       ((uint)0x87fe)
-#define PROFF_MCC2             ((uint)0x8800)
-#define PROFF_SMC2_BASE                ((uint)0x88fc)
-#define PROFF_IDMA2_BASE       ((uint)0x88fe)
-#define PROFF_SPI_BASE         ((uint)0x89fc)
-#define PROFF_IDMA3_BASE       ((uint)0x89fe)
-#define PROFF_TIMERS           ((uint)0x8ae0)
-#define PROFF_REVNUM           ((uint)0x8af0)
-#define PROFF_RAND             ((uint)0x8af8)
-#define PROFF_I2C_BASE         ((uint)0x8afc)
-#define PROFF_IDMA4_BASE       ((uint)0x8afe)
-
-/* The SMCs are relocated to any of the first eight DPRAM pages.
- * We will fix these at the first locations of DPRAM, until we
- * get some microcode patches :-).
- * The parameter ram space for the SMCs is fifty-some bytes, and
- * they are required to start on a 64 byte boundary.
- */
-#define PROFF_SMC1     (0)
-#define PROFF_SMC2     (64)
-
-
-/* Define enough so I can at least use the serial port as a UART.
- */
-typedef struct smc_uart {
-       ushort  smc_rbase;      /* Rx Buffer descriptor base address */
-       ushort  smc_tbase;      /* Tx Buffer descriptor base address */
-       u_char  smc_rfcr;       /* Rx function code */
-       u_char  smc_tfcr;       /* Tx function code */
-       ushort  smc_mrblr;      /* Max receive buffer length */
-       uint    smc_rstate;     /* Internal */
-       uint    smc_idp;        /* Internal */
-       ushort  smc_rbptr;      /* Internal */
-       ushort  smc_ibc;        /* Internal */
-       uint    smc_rxtmp;      /* Internal */
-       uint    smc_tstate;     /* Internal */
-       uint    smc_tdp;        /* Internal */
-       ushort  smc_tbptr;      /* Internal */
-       ushort  smc_tbc;        /* Internal */
-       uint    smc_txtmp;      /* Internal */
-       ushort  smc_maxidl;     /* Maximum idle characters */
-       ushort  smc_tmpidl;     /* Temporary idle counter */
-       ushort  smc_brklen;     /* Last received break length */
-       ushort  smc_brkec;      /* rcv'd break condition counter */
-       ushort  smc_brkcr;      /* xmt break count register */
-       ushort  smc_rmask;      /* Temporary bit mask */
-       uint    smc_stmp;       /* SDMA Temp */
-} smc_uart_t;
-
-/* SMC uart mode register (Internal memory map).
-*/
-#define SMCMR_REN      ((ushort)0x0001)
-#define SMCMR_TEN      ((ushort)0x0002)
-#define SMCMR_DM       ((ushort)0x000c)
-#define SMCMR_SM_GCI   ((ushort)0x0000)
-#define SMCMR_SM_UART  ((ushort)0x0020)
-#define SMCMR_SM_TRANS ((ushort)0x0030)
-#define SMCMR_SM_MASK  ((ushort)0x0030)
-#define SMCMR_PM_EVEN  ((ushort)0x0100)        /* Even parity, else odd */
-#define SMCMR_REVD     SMCMR_PM_EVEN
-#define SMCMR_PEN      ((ushort)0x0200)        /* Parity enable */
-#define SMCMR_BS       SMCMR_PEN
-#define SMCMR_SL       ((ushort)0x0400)        /* Two stops, else one */
-#define SMCR_CLEN_MASK ((ushort)0x7800)        /* Character length */
-#define smcr_mk_clen(C)        (((C) << 11) & SMCR_CLEN_MASK)
-
-/* SMC Event and Mask register.
-*/
-#define SMCM_BRKE       ((unsigned char)0x40)   /* When in UART Mode */
-#define SMCM_BRK        ((unsigned char)0x10)   /* When in UART Mode */
-#define SMCM_TXE       ((unsigned char)0x10)
-#define SMCM_BSY       ((unsigned char)0x04)
-#define SMCM_TX                ((unsigned char)0x02)
-#define SMCM_RX                ((unsigned char)0x01)
-
-/* Baud rate generators.
-*/
-#define CPM_BRG_RST            ((uint)0x00020000)
-#define CPM_BRG_EN             ((uint)0x00010000)
-#define CPM_BRG_EXTC_INT       ((uint)0x00000000)
-#define CPM_BRG_EXTC_CLK3_9    ((uint)0x00004000)
-#define CPM_BRG_EXTC_CLK5_15   ((uint)0x00008000)
-#define CPM_BRG_ATB            ((uint)0x00002000)
-#define CPM_BRG_CD_MASK                ((uint)0x00001ffe)
-#define CPM_BRG_DIV16          ((uint)0x00000001)
-
-/* SCCs.
-*/
-#define SCC_GSMRH_IRP          ((uint)0x00040000)
-#define SCC_GSMRH_GDE          ((uint)0x00010000)
-#define SCC_GSMRH_TCRC_CCITT   ((uint)0x00008000)
-#define SCC_GSMRH_TCRC_BISYNC  ((uint)0x00004000)
-#define SCC_GSMRH_TCRC_HDLC    ((uint)0x00000000)
-#define SCC_GSMRH_REVD         ((uint)0x00002000)
-#define SCC_GSMRH_TRX          ((uint)0x00001000)
-#define SCC_GSMRH_TTX          ((uint)0x00000800)
-#define SCC_GSMRH_CDP          ((uint)0x00000400)
-#define SCC_GSMRH_CTSP         ((uint)0x00000200)
-#define SCC_GSMRH_CDS          ((uint)0x00000100)
-#define SCC_GSMRH_CTSS         ((uint)0x00000080)
-#define SCC_GSMRH_TFL          ((uint)0x00000040)
-#define SCC_GSMRH_RFW          ((uint)0x00000020)
-#define SCC_GSMRH_TXSY         ((uint)0x00000010)
-#define SCC_GSMRH_SYNL16       ((uint)0x0000000c)
-#define SCC_GSMRH_SYNL8                ((uint)0x00000008)
-#define SCC_GSMRH_SYNL4                ((uint)0x00000004)
-#define SCC_GSMRH_RTSM         ((uint)0x00000002)
-#define SCC_GSMRH_RSYN         ((uint)0x00000001)
-
-#define SCC_GSMRL_SIR          ((uint)0x80000000)      /* SCC2 only */
-#define SCC_GSMRL_EDGE_NONE    ((uint)0x60000000)
-#define SCC_GSMRL_EDGE_NEG     ((uint)0x40000000)
-#define SCC_GSMRL_EDGE_POS     ((uint)0x20000000)
-#define SCC_GSMRL_EDGE_BOTH    ((uint)0x00000000)
-#define SCC_GSMRL_TCI          ((uint)0x10000000)
-#define SCC_GSMRL_TSNC_3       ((uint)0x0c000000)
-#define SCC_GSMRL_TSNC_4       ((uint)0x08000000)
-#define SCC_GSMRL_TSNC_14      ((uint)0x04000000)
-#define SCC_GSMRL_TSNC_INF     ((uint)0x00000000)
-#define SCC_GSMRL_RINV         ((uint)0x02000000)
-#define SCC_GSMRL_TINV         ((uint)0x01000000)
-#define SCC_GSMRL_TPL_128      ((uint)0x00c00000)
-#define SCC_GSMRL_TPL_64       ((uint)0x00a00000)
-#define SCC_GSMRL_TPL_48       ((uint)0x00800000)
-#define SCC_GSMRL_TPL_32       ((uint)0x00600000)
-#define SCC_GSMRL_TPL_16       ((uint)0x00400000)
-#define SCC_GSMRL_TPL_8                ((uint)0x00200000)
-#define SCC_GSMRL_TPL_NONE     ((uint)0x00000000)
-#define SCC_GSMRL_TPP_ALL1     ((uint)0x00180000)
-#define SCC_GSMRL_TPP_01       ((uint)0x00100000)
-#define SCC_GSMRL_TPP_10       ((uint)0x00080000)
-#define SCC_GSMRL_TPP_ZEROS    ((uint)0x00000000)
-#define SCC_GSMRL_TEND         ((uint)0x00040000)
-#define SCC_GSMRL_TDCR_32      ((uint)0x00030000)
-#define SCC_GSMRL_TDCR_16      ((uint)0x00020000)
-#define SCC_GSMRL_TDCR_8       ((uint)0x00010000)
-#define SCC_GSMRL_TDCR_1       ((uint)0x00000000)
-#define SCC_GSMRL_RDCR_32      ((uint)0x0000c000)
-#define SCC_GSMRL_RDCR_16      ((uint)0x00008000)
-#define SCC_GSMRL_RDCR_8       ((uint)0x00004000)
-#define SCC_GSMRL_RDCR_1       ((uint)0x00000000)
-#define SCC_GSMRL_RENC_DFMAN   ((uint)0x00003000)
-#define SCC_GSMRL_RENC_MANCH   ((uint)0x00002000)
-#define SCC_GSMRL_RENC_FM0     ((uint)0x00001000)
-#define SCC_GSMRL_RENC_NRZI    ((uint)0x00000800)
-#define SCC_GSMRL_RENC_NRZ     ((uint)0x00000000)
-#define SCC_GSMRL_TENC_DFMAN   ((uint)0x00000600)
-#define SCC_GSMRL_TENC_MANCH   ((uint)0x00000400)
-#define SCC_GSMRL_TENC_FM0     ((uint)0x00000200)
-#define SCC_GSMRL_TENC_NRZI    ((uint)0x00000100)
-#define SCC_GSMRL_TENC_NRZ     ((uint)0x00000000)
-#define SCC_GSMRL_DIAG_LE      ((uint)0x000000c0)      /* Loop and echo */
-#define SCC_GSMRL_DIAG_ECHO    ((uint)0x00000080)
-#define SCC_GSMRL_DIAG_LOOP    ((uint)0x00000040)
-#define SCC_GSMRL_DIAG_NORM    ((uint)0x00000000)
-#define SCC_GSMRL_ENR          ((uint)0x00000020)
-#define SCC_GSMRL_ENT          ((uint)0x00000010)
-#define SCC_GSMRL_MODE_ENET    ((uint)0x0000000c)
-#define SCC_GSMRL_MODE_DDCMP   ((uint)0x00000009)
-#define SCC_GSMRL_MODE_BISYNC  ((uint)0x00000008)
-#define SCC_GSMRL_MODE_V14     ((uint)0x00000007)
-#define SCC_GSMRL_MODE_AHDLC   ((uint)0x00000006)
-#define SCC_GSMRL_MODE_PROFIBUS        ((uint)0x00000005)
-#define SCC_GSMRL_MODE_UART    ((uint)0x00000004)
-#define SCC_GSMRL_MODE_SS7     ((uint)0x00000003)
-#define SCC_GSMRL_MODE_ATALK   ((uint)0x00000002)
-#define SCC_GSMRL_MODE_HDLC    ((uint)0x00000000)
-
-#define SCC_TODR_TOD           ((ushort)0x8000)
-
-/* SCC Event and Mask register.
-*/
-#define SCCM_TXE       ((unsigned char)0x10)
-#define SCCM_BSY       ((unsigned char)0x04)
-#define SCCM_TX                ((unsigned char)0x02)
-#define SCCM_RX                ((unsigned char)0x01)
-
-typedef struct scc_param {
-       ushort  scc_rbase;      /* Rx Buffer descriptor base address */
-       ushort  scc_tbase;      /* Tx Buffer descriptor base address */
-       u_char  scc_rfcr;       /* Rx function code */
-       u_char  scc_tfcr;       /* Tx function code */
-       ushort  scc_mrblr;      /* Max receive buffer length */
-       uint    scc_rstate;     /* Internal */
-       uint    scc_idp;        /* Internal */
-       ushort  scc_rbptr;      /* Internal */
-       ushort  scc_ibc;        /* Internal */
-       uint    scc_rxtmp;      /* Internal */
-       uint    scc_tstate;     /* Internal */
-       uint    scc_tdp;        /* Internal */
-       ushort  scc_tbptr;      /* Internal */
-       ushort  scc_tbc;        /* Internal */
-       uint    scc_txtmp;      /* Internal */
-       uint    scc_rcrc;       /* Internal */
-       uint    scc_tcrc;       /* Internal */
-} sccp_t;
-
-/* CPM Ethernet through SCC1.
- */
-typedef struct scc_enet {
-       sccp_t  sen_genscc;
-       uint    sen_cpres;      /* Preset CRC */
-       uint    sen_cmask;      /* Constant mask for CRC */
-       uint    sen_crcec;      /* CRC Error counter */
-       uint    sen_alec;       /* alignment error counter */
-       uint    sen_disfc;      /* discard frame counter */
-       ushort  sen_pads;       /* Tx short frame pad character */
-       ushort  sen_retlim;     /* Retry limit threshold */
-       ushort  sen_retcnt;     /* Retry limit counter */
-       ushort  sen_maxflr;     /* maximum frame length register */
-       ushort  sen_minflr;     /* minimum frame length register */
-       ushort  sen_maxd1;      /* maximum DMA1 length */
-       ushort  sen_maxd2;      /* maximum DMA2 length */
-       ushort  sen_maxd;       /* Rx max DMA */
-       ushort  sen_dmacnt;     /* Rx DMA counter */
-       ushort  sen_maxb;       /* Max BD byte count */
-       ushort  sen_gaddr1;     /* Group address filter */
-       ushort  sen_gaddr2;
-       ushort  sen_gaddr3;
-       ushort  sen_gaddr4;
-       uint    sen_tbuf0data0; /* Save area 0 - current frame */
-       uint    sen_tbuf0data1; /* Save area 1 - current frame */
-       uint    sen_tbuf0rba;   /* Internal */
-       uint    sen_tbuf0crc;   /* Internal */
-       ushort  sen_tbuf0bcnt;  /* Internal */
-       ushort  sen_paddrh;     /* physical address (MSB) */
-       ushort  sen_paddrm;
-       ushort  sen_paddrl;     /* physical address (LSB) */
-       ushort  sen_pper;       /* persistence */
-       ushort  sen_rfbdptr;    /* Rx first BD pointer */
-       ushort  sen_tfbdptr;    /* Tx first BD pointer */
-       ushort  sen_tlbdptr;    /* Tx last BD pointer */
-       uint    sen_tbuf1data0; /* Save area 0 - current frame */
-       uint    sen_tbuf1data1; /* Save area 1 - current frame */
-       uint    sen_tbuf1rba;   /* Internal */
-       uint    sen_tbuf1crc;   /* Internal */
-       ushort  sen_tbuf1bcnt;  /* Internal */
-       ushort  sen_txlen;      /* Tx Frame length counter */
-       ushort  sen_iaddr1;     /* Individual address filter */
-       ushort  sen_iaddr2;
-       ushort  sen_iaddr3;
-       ushort  sen_iaddr4;
-       ushort  sen_boffcnt;    /* Backoff counter */
-
-       /* NOTE: Some versions of the manual have the following items
-        * incorrectly documented.  Below is the proper order.
-        */
-       ushort  sen_taddrh;     /* temp address (MSB) */
-       ushort  sen_taddrm;
-       ushort  sen_taddrl;     /* temp address (LSB) */
-} scc_enet_t;
-
-
-/* SCC Event register as used by Ethernet.
-*/
-#define SCCE_ENET_GRA  ((ushort)0x0080)        /* Graceful stop complete */
-#define SCCE_ENET_TXE  ((ushort)0x0010)        /* Transmit Error */
-#define SCCE_ENET_RXF  ((ushort)0x0008)        /* Full frame received */
-#define SCCE_ENET_BSY  ((ushort)0x0004)        /* All incoming buffers full */
-#define SCCE_ENET_TXB  ((ushort)0x0002)        /* A buffer was transmitted */
-#define SCCE_ENET_RXB  ((ushort)0x0001)        /* A buffer was received */
-
-/* SCC Mode Register (PSMR) as used by Ethernet.
-*/
-#define SCC_PSMR_HBC   ((ushort)0x8000)        /* Enable heartbeat */
-#define SCC_PSMR_FC    ((ushort)0x4000)        /* Force collision */
-#define SCC_PSMR_RSH   ((ushort)0x2000)        /* Receive short frames */
-#define SCC_PSMR_IAM   ((ushort)0x1000)        /* Check individual hash */
-#define SCC_PSMR_ENCRC ((ushort)0x0800)        /* Ethernet CRC mode */
-#define SCC_PSMR_PRO   ((ushort)0x0200)        /* Promiscuous mode */
-#define SCC_PSMR_BRO   ((ushort)0x0100)        /* Catch broadcast pkts */
-#define SCC_PSMR_SBT   ((ushort)0x0080)        /* Special backoff timer */
-#define SCC_PSMR_LPB   ((ushort)0x0040)        /* Set Loopback mode */
-#define SCC_PSMR_SIP   ((ushort)0x0020)        /* Sample Input Pins */
-#define SCC_PSMR_LCW   ((ushort)0x0010)        /* Late collision window */
-#define SCC_PSMR_NIB22 ((ushort)0x000a)        /* Start frame search */
-#define SCC_PSMR_FDE   ((ushort)0x0001)        /* Full duplex enable */
-
-/* Buffer descriptor control/status used by Ethernet receive.
- * Common to SCC and FCC.
- */
-#define BD_ENET_RX_EMPTY       ((ushort)0x8000)
-#define BD_ENET_RX_WRAP                ((ushort)0x2000)
-#define BD_ENET_RX_INTR                ((ushort)0x1000)
-#define BD_ENET_RX_LAST                ((ushort)0x0800)
-#define BD_ENET_RX_FIRST       ((ushort)0x0400)
-#define BD_ENET_RX_MISS                ((ushort)0x0100)
-#define BD_ENET_RX_BC          ((ushort)0x0080)        /* FCC Only */
-#define BD_ENET_RX_MC          ((ushort)0x0040)        /* FCC Only */
-#define BD_ENET_RX_LG          ((ushort)0x0020)
-#define BD_ENET_RX_NO          ((ushort)0x0010)
-#define BD_ENET_RX_SH          ((ushort)0x0008)
-#define BD_ENET_RX_CR          ((ushort)0x0004)
-#define BD_ENET_RX_OV          ((ushort)0x0002)
-#define BD_ENET_RX_CL          ((ushort)0x0001)
-#define BD_ENET_RX_STATS       ((ushort)0x01ff)        /* All status bits */
-
-/* Buffer descriptor control/status used by Ethernet transmit.
- * Common to SCC and FCC.
- */
-#define BD_ENET_TX_READY       ((ushort)0x8000)
-#define BD_ENET_TX_PAD         ((ushort)0x4000)
-#define BD_ENET_TX_WRAP                ((ushort)0x2000)
-#define BD_ENET_TX_INTR                ((ushort)0x1000)
-#define BD_ENET_TX_LAST                ((ushort)0x0800)
-#define BD_ENET_TX_TC          ((ushort)0x0400)
-#define BD_ENET_TX_DEF         ((ushort)0x0200)
-#define BD_ENET_TX_HB          ((ushort)0x0100)
-#define BD_ENET_TX_LC          ((ushort)0x0080)
-#define BD_ENET_TX_RL          ((ushort)0x0040)
-#define BD_ENET_TX_RCMASK      ((ushort)0x003c)
-#define BD_ENET_TX_UN          ((ushort)0x0002)
-#define BD_ENET_TX_CSL         ((ushort)0x0001)
-#define BD_ENET_TX_STATS       ((ushort)0x03ff)        /* All status bits */
-
-/* SCC as UART
-*/
-typedef struct scc_uart {
-       sccp_t  scc_genscc;
-       uint    scc_res1;       /* Reserved */
-       uint    scc_res2;       /* Reserved */
-       ushort  scc_maxidl;     /* Maximum idle chars */
-       ushort  scc_idlc;       /* temp idle counter */
-       ushort  scc_brkcr;      /* Break count register */
-       ushort  scc_parec;      /* receive parity error counter */
-       ushort  scc_frmec;      /* receive framing error counter */
-       ushort  scc_nosec;      /* receive noise counter */
-       ushort  scc_brkec;      /* receive break condition counter */
-       ushort  scc_brkln;      /* last received break length */
-       ushort  scc_uaddr1;     /* UART address character 1 */
-       ushort  scc_uaddr2;     /* UART address character 2 */
-       ushort  scc_rtemp;      /* Temp storage */
-       ushort  scc_toseq;      /* Transmit out of sequence char */
-       ushort  scc_char1;      /* control character 1 */
-       ushort  scc_char2;      /* control character 2 */
-       ushort  scc_char3;      /* control character 3 */
-       ushort  scc_char4;      /* control character 4 */
-       ushort  scc_char5;      /* control character 5 */
-       ushort  scc_char6;      /* control character 6 */
-       ushort  scc_char7;      /* control character 7 */
-       ushort  scc_char8;      /* control character 8 */
-       ushort  scc_rccm;       /* receive control character mask */
-       ushort  scc_rccr;       /* receive control character register */
-       ushort  scc_rlbc;       /* receive last break character */
-} scc_uart_t;
-
-/* SCC Event and Mask registers when it is used as a UART.
-*/
-#define UART_SCCM_GLR          ((ushort)0x1000)
-#define UART_SCCM_GLT          ((ushort)0x0800)
-#define UART_SCCM_AB           ((ushort)0x0200)
-#define UART_SCCM_IDL          ((ushort)0x0100)
-#define UART_SCCM_GRA          ((ushort)0x0080)
-#define UART_SCCM_BRKE         ((ushort)0x0040)
-#define UART_SCCM_BRKS         ((ushort)0x0020)
-#define UART_SCCM_CCR          ((ushort)0x0008)
-#define UART_SCCM_BSY          ((ushort)0x0004)
-#define UART_SCCM_TX           ((ushort)0x0002)
-#define UART_SCCM_RX           ((ushort)0x0001)
-
-/* The SCC PSMR when used as a UART.
-*/
-#define SCU_PSMR_FLC           ((ushort)0x8000)
-#define SCU_PSMR_SL            ((ushort)0x4000)
-#define SCU_PSMR_CL            ((ushort)0x3000)
-#define SCU_PSMR_UM            ((ushort)0x0c00)
-#define SCU_PSMR_FRZ           ((ushort)0x0200)
-#define SCU_PSMR_RZS           ((ushort)0x0100)
-#define SCU_PSMR_SYN           ((ushort)0x0080)
-#define SCU_PSMR_DRT           ((ushort)0x0040)
-#define SCU_PSMR_PEN           ((ushort)0x0010)
-#define SCU_PSMR_RPM           ((ushort)0x000c)
-#define SCU_PSMR_REVP          ((ushort)0x0008)
-#define SCU_PSMR_TPM           ((ushort)0x0003)
-#define SCU_PSMR_TEVP          ((ushort)0x0003)
-
-/* CPM Transparent mode SCC.
- */
-typedef struct scc_trans {
-       sccp_t  st_genscc;
-       uint    st_cpres;       /* Preset CRC */
-       uint    st_cmask;       /* Constant mask for CRC */
-} scc_trans_t;
-
-#define BD_SCC_TX_LAST         ((ushort)0x0800)
-
-/* How about some FCCs.....
-*/
-#define FCC_GFMR_DIAG_NORM     ((uint)0x00000000)
-#define FCC_GFMR_DIAG_LE       ((uint)0x40000000)
-#define FCC_GFMR_DIAG_AE       ((uint)0x80000000)
-#define FCC_GFMR_DIAG_ALE      ((uint)0xc0000000)
-#define FCC_GFMR_TCI           ((uint)0x20000000)
-#define FCC_GFMR_TRX           ((uint)0x10000000)
-#define FCC_GFMR_TTX           ((uint)0x08000000)
-#define FCC_GFMR_TTX           ((uint)0x08000000)
-#define FCC_GFMR_CDP           ((uint)0x04000000)
-#define FCC_GFMR_CTSP          ((uint)0x02000000)
-#define FCC_GFMR_CDS           ((uint)0x01000000)
-#define FCC_GFMR_CTSS          ((uint)0x00800000)
-#define FCC_GFMR_SYNL_NONE     ((uint)0x00000000)
-#define FCC_GFMR_SYNL_AUTO     ((uint)0x00004000)
-#define FCC_GFMR_SYNL_8                ((uint)0x00008000)
-#define FCC_GFMR_SYNL_16       ((uint)0x0000c000)
-#define FCC_GFMR_RTSM          ((uint)0x00002000)
-#define FCC_GFMR_RENC_NRZ      ((uint)0x00000000)
-#define FCC_GFMR_RENC_NRZI     ((uint)0x00000800)
-#define FCC_GFMR_REVD          ((uint)0x00000400)
-#define FCC_GFMR_TENC_NRZ      ((uint)0x00000000)
-#define FCC_GFMR_TENC_NRZI     ((uint)0x00000100)
-#define FCC_GFMR_TCRC_16       ((uint)0x00000000)
-#define FCC_GFMR_TCRC_32       ((uint)0x00000080)
-#define FCC_GFMR_ENR           ((uint)0x00000020)
-#define FCC_GFMR_ENT           ((uint)0x00000010)
-#define FCC_GFMR_MODE_ENET     ((uint)0x0000000c)
-#define FCC_GFMR_MODE_ATM      ((uint)0x0000000a)
-#define FCC_GFMR_MODE_HDLC     ((uint)0x00000000)
-
-/* Generic FCC parameter ram.
-*/
-typedef struct fcc_param {
-       ushort  fcc_riptr;      /* Rx Internal temp pointer */
-       ushort  fcc_tiptr;      /* Tx Internal temp pointer */
-       ushort  fcc_res1;
-       ushort  fcc_mrblr;      /* Max receive buffer length, mod 32 bytes */
-       uint    fcc_rstate;     /* Upper byte is Func code, must be set */
-       uint    fcc_rbase;      /* Receive BD base */
-       ushort  fcc_rbdstat;    /* RxBD status */
-       ushort  fcc_rbdlen;     /* RxBD down counter */
-       uint    fcc_rdptr;      /* RxBD internal data pointer */
-       uint    fcc_tstate;     /* Upper byte is Func code, must be set */
-       uint    fcc_tbase;      /* Transmit BD base */
-       ushort  fcc_tbdstat;    /* TxBD status */
-       ushort  fcc_tbdlen;     /* TxBD down counter */
-       uint    fcc_tdptr;      /* TxBD internal data pointer */
-       uint    fcc_rbptr;      /* Rx BD Internal buf pointer */
-       uint    fcc_tbptr;      /* Tx BD Internal buf pointer */
-       uint    fcc_rcrc;       /* Rx temp CRC */
-       uint    fcc_res2;
-       uint    fcc_tcrc;       /* Tx temp CRC */
-} fccp_t;
-
-
-/* Ethernet controller through FCC.
-*/
-typedef struct fcc_enet {
-       fccp_t  fen_genfcc;
-       uint    fen_statbuf;    /* Internal status buffer */
-       uint    fen_camptr;     /* CAM address */
-       uint    fen_cmask;      /* Constant mask for CRC */
-       uint    fen_cpres;      /* Preset CRC */
-       uint    fen_crcec;      /* CRC Error counter */
-       uint    fen_alec;       /* alignment error counter */
-       uint    fen_disfc;      /* discard frame counter */
-       ushort  fen_retlim;     /* Retry limit */
-       ushort  fen_retcnt;     /* Retry counter */
-       ushort  fen_pper;       /* Persistence */
-       ushort  fen_boffcnt;    /* backoff counter */
-       uint    fen_gaddrh;     /* Group address filter, high 32-bits */
-       uint    fen_gaddrl;     /* Group address filter, low 32-bits */
-       ushort  fen_tfcstat;    /* out of sequence TxBD */
-       ushort  fen_tfclen;
-       uint    fen_tfcptr;
-       ushort  fen_mflr;       /* Maximum frame length (1518) */
-       ushort  fen_paddrh;     /* MAC address */
-       ushort  fen_paddrm;
-       ushort  fen_paddrl;
-       ushort  fen_ibdcount;   /* Internal BD counter */
-       ushort  fen_ibdstart;   /* Internal BD start pointer */
-       ushort  fen_ibdend;     /* Internal BD end pointer */
-       ushort  fen_txlen;      /* Internal Tx frame length counter */
-       uint    fen_ibdbase[8]; /* Internal use */
-       uint    fen_iaddrh;     /* Individual address filter */
-       uint    fen_iaddrl;
-       ushort  fen_minflr;     /* Minimum frame length (64) */
-       ushort  fen_taddrh;     /* Filter transfer MAC address */
-       ushort  fen_taddrm;
-       ushort  fen_taddrl;
-       ushort  fen_padptr;     /* Pointer to pad byte buffer */
-       ushort  fen_cftype;     /* control frame type */
-       ushort  fen_cfrange;    /* control frame range */
-       ushort  fen_maxb;       /* maximum BD count */
-       ushort  fen_maxd1;      /* Max DMA1 length (1520) */
-       ushort  fen_maxd2;      /* Max DMA2 length (1520) */
-       ushort  fen_maxd;       /* internal max DMA count */
-       ushort  fen_dmacnt;     /* internal DMA counter */
-       uint    fen_octc;       /* Total octect counter */
-       uint    fen_colc;       /* Total collision counter */
-       uint    fen_broc;       /* Total broadcast packet counter */
-       uint    fen_mulc;       /* Total multicast packet count */
-       uint    fen_uspc;       /* Total packets < 64 bytes */
-       uint    fen_frgc;       /* Total packets < 64 bytes with errors */
-       uint    fen_ospc;       /* Total packets > 1518 */
-       uint    fen_jbrc;       /* Total packets > 1518 with errors */
-       uint    fen_p64c;       /* Total packets == 64 bytes */
-       uint    fen_p65c;       /* Total packets 64 < bytes <= 127 */
-       uint    fen_p128c;      /* Total packets 127 < bytes <= 255 */
-       uint    fen_p256c;      /* Total packets 256 < bytes <= 511 */
-       uint    fen_p512c;      /* Total packets 512 < bytes <= 1023 */
-       uint    fen_p1024c;     /* Total packets 1024 < bytes <= 1518 */
-       uint    fen_cambuf;     /* Internal CAM buffer poiner */
-       ushort  fen_rfthr;      /* Received frames threshold */
-       ushort  fen_rfcnt;      /* Received frames count */
-} fcc_enet_t;
-
-/* FCC Event/Mask register as used by Ethernet.
-*/
-#define FCC_ENET_GRA   ((ushort)0x0080)        /* Graceful stop complete */
-#define FCC_ENET_RXC   ((ushort)0x0040)        /* Control Frame Received */
-#define FCC_ENET_TXC   ((ushort)0x0020)        /* Out of seq. Tx sent */
-#define FCC_ENET_TXE   ((ushort)0x0010)        /* Transmit Error */
-#define FCC_ENET_RXF   ((ushort)0x0008)        /* Full frame received */
-#define FCC_ENET_BSY   ((ushort)0x0004)        /* Busy.  Rx Frame dropped */
-#define FCC_ENET_TXB   ((ushort)0x0002)        /* A buffer was transmitted */
-#define FCC_ENET_RXB   ((ushort)0x0001)        /* A buffer was received */
-
-/* FCC Mode Register (FPSMR) as used by Ethernet.
-*/
-#define FCC_PSMR_HBC   ((uint)0x80000000)      /* Enable heartbeat */
-#define FCC_PSMR_FC    ((uint)0x40000000)      /* Force Collision */
-#define FCC_PSMR_SBT   ((uint)0x20000000)      /* Stop backoff timer */
-#define FCC_PSMR_LPB   ((uint)0x10000000)      /* Local protect. 1 = FDX */
-#define FCC_PSMR_LCW   ((uint)0x08000000)      /* Late collision select */
-#define FCC_PSMR_FDE   ((uint)0x04000000)      /* Full Duplex Enable */
-#define FCC_PSMR_MON   ((uint)0x02000000)      /* RMON Enable */
-#define FCC_PSMR_PRO   ((uint)0x00400000)      /* Promiscuous Enable */
-#define FCC_PSMR_FCE   ((uint)0x00200000)      /* Flow Control Enable */
-#define FCC_PSMR_RSH   ((uint)0x00100000)      /* Receive Short Frames */
-#define FCC_PSMR_CAM   ((uint)0x00000400)      /* CAM enable */
-#define FCC_PSMR_BRO   ((uint)0x00000200)      /* Broadcast pkt discard */
-#define FCC_PSMR_ENCRC ((uint)0x00000080)      /* Use 32-bit CRC */
-
-/* IIC parameter RAM.
-*/
-typedef struct iic {
-       ushort  iic_rbase;      /* Rx Buffer descriptor base address */
-       ushort  iic_tbase;      /* Tx Buffer descriptor base address */
-       u_char  iic_rfcr;       /* Rx function code */
-       u_char  iic_tfcr;       /* Tx function code */
-       ushort  iic_mrblr;      /* Max receive buffer length */
-       uint    iic_rstate;     /* Internal */
-       uint    iic_rdp;        /* Internal */
-       ushort  iic_rbptr;      /* Internal */
-       ushort  iic_rbc;        /* Internal */
-       uint    iic_rxtmp;      /* Internal */
-       uint    iic_tstate;     /* Internal */
-       uint    iic_tdp;        /* Internal */
-       ushort  iic_tbptr;      /* Internal */
-       ushort  iic_tbc;        /* Internal */
-       uint    iic_txtmp;      /* Internal */
-} iic_t;
-
-/* SPI parameter RAM.
-*/
-typedef struct spi {
-       ushort  spi_rbase;      /* Rx Buffer descriptor base address */
-       ushort  spi_tbase;      /* Tx Buffer descriptor base address */
-       u_char  spi_rfcr;       /* Rx function code */
-       u_char  spi_tfcr;       /* Tx function code */
-       ushort  spi_mrblr;      /* Max receive buffer length */
-       uint    spi_rstate;     /* Internal */
-       uint    spi_rdp;        /* Internal */
-       ushort  spi_rbptr;      /* Internal */
-       ushort  spi_rbc;        /* Internal */
-       uint    spi_rxtmp;      /* Internal */
-       uint    spi_tstate;     /* Internal */
-       uint    spi_tdp;        /* Internal */
-       ushort  spi_tbptr;      /* Internal */
-       ushort  spi_tbc;        /* Internal */
-       uint    spi_txtmp;      /* Internal */
-       uint    spi_res;        /* Tx temp. */
-       uint    spi_res1[4];    /* SDMA temp. */
-} spi_t;
-
-/* SPI Mode register.
-*/
-#define SPMODE_LOOP    ((ushort)0x4000)        /* Loopback */
-#define SPMODE_CI      ((ushort)0x2000)        /* Clock Invert */
-#define SPMODE_CP      ((ushort)0x1000)        /* Clock Phase */
-#define SPMODE_DIV16   ((ushort)0x0800)        /* BRG/16 mode */
-#define SPMODE_REV     ((ushort)0x0400)        /* Reversed Data */
-#define SPMODE_MSTR    ((ushort)0x0200)        /* SPI Master */
-#define SPMODE_EN      ((ushort)0x0100)        /* Enable */
-#define SPMODE_LENMSK  ((ushort)0x00f0)        /* character length */
-#define SPMODE_PMMSK   ((ushort)0x000f)        /* prescale modulus */
-
-#define SPMODE_LEN(x)  ((((x)-1)&0xF)<<4)
-#define SPMODE_PM(x)   ((x) &0xF)
-
-#define SPI_EB         ((u_char)0x10)          /* big endian byte order */
-
-#define BD_IIC_START           ((ushort)0x0400)
-
-/* IDMA parameter RAM
-*/
-typedef struct idma {
-       ushort ibase;           /* IDMA buffer descriptor table base address */
-       ushort dcm;             /* DMA channel mode */
-       ushort ibdptr;          /* IDMA current buffer descriptor pointer */
-       ushort dpr_buf;         /* IDMA transfer buffer base address */
-       ushort buf_inv;         /* internal buffer inventory */
-       ushort ss_max;          /* steady-state maximum transfer size */
-       ushort dpr_in_ptr;      /* write pointer inside the internal buffer */
-       ushort sts;             /* source transfer size */
-       ushort dpr_out_ptr;     /* read pointer inside the internal buffer */
-       ushort seob;            /* source end of burst */
-       ushort deob;            /* destination end of burst */
-       ushort dts;             /* destination transfer size */
-       ushort ret_add;         /* return address when working in ERM=1 mode */
-       ushort res0;            /* reserved */
-       uint   bd_cnt;          /* internal byte count */
-       uint   s_ptr;           /* source internal data pointer */
-       uint   d_ptr;           /* destination internal data pointer */
-       uint   istate;          /* internal state */
-       u_char res1[20];        /* pad to 64-byte length */
-} idma_t;
-
-/* DMA channel mode bit fields
-*/
-#define IDMA_DCM_FB            ((ushort)0x8000) /* fly-by mode */
-#define IDMA_DCM_LP            ((ushort)0x4000) /* low priority */
-#define IDMA_DCM_TC2           ((ushort)0x0400) /* value driven on TC[2] */
-#define IDMA_DCM_DMA_WRAP_MASK ((ushort)0x01c0) /* mask for DMA wrap */
-#define IDMA_DCM_DMA_WRAP_64   ((ushort)0x0000) /* 64-byte DMA xfer buffer */
-#define IDMA_DCM_DMA_WRAP_128  ((ushort)0x0040) /* 128-byte DMA xfer buffer */
-#define IDMA_DCM_DMA_WRAP_256  ((ushort)0x0080) /* 256-byte DMA xfer buffer */
-#define IDMA_DCM_DMA_WRAP_512  ((ushort)0x00c0) /* 512-byte DMA xfer buffer */
-#define IDMA_DCM_DMA_WRAP_1024 ((ushort)0x0100) /* 1024-byte DMA xfer buffer */
-#define IDMA_DCM_DMA_WRAP_2048 ((ushort)0x0140) /* 2048-byte DMA xfer buffer */
-#define IDMA_DCM_SINC          ((ushort)0x0020) /* source inc addr */
-#define IDMA_DCM_DINC          ((ushort)0x0010) /* destination inc addr */
-#define IDMA_DCM_ERM           ((ushort)0x0008) /* external request mode */
-#define IDMA_DCM_DT            ((ushort)0x0004) /* DONE treatment */
-#define IDMA_DCM_SD_MASK       ((ushort)0x0003) /* mask for SD bit field */
-#define IDMA_DCM_SD_MEM2MEM    ((ushort)0x0000) /* memory-to-memory xfer */
-#define IDMA_DCM_SD_PER2MEM    ((ushort)0x0002) /* peripheral-to-memory xfer */
-#define IDMA_DCM_SD_MEM2PER    ((ushort)0x0001) /* memory-to-peripheral xfer */
-
-/* IDMA Buffer Descriptors
-*/
-typedef struct idma_bd {
-       uint flags;
-       uint len;       /* data length */
-       uint src;       /* source data buffer pointer */
-       uint dst;       /* destination data buffer pointer */
-} idma_bd_t;
-
-/* IDMA buffer descriptor flag bit fields
-*/
-#define IDMA_BD_V      ((uint)0x80000000)      /* valid */
-#define IDMA_BD_W      ((uint)0x20000000)      /* wrap */
-#define IDMA_BD_I      ((uint)0x10000000)      /* interrupt */
-#define IDMA_BD_L      ((uint)0x08000000)      /* last */
-#define IDMA_BD_CM     ((uint)0x02000000)      /* continuous mode */
-#define IDMA_BD_SDN    ((uint)0x00400000)      /* source done */
-#define IDMA_BD_DDN    ((uint)0x00200000)      /* destination done */
-#define IDMA_BD_DGBL   ((uint)0x00100000)      /* destination global */
-#define IDMA_BD_DBO_LE ((uint)0x00040000)      /* little-end dest byte order */
-#define IDMA_BD_DBO_BE ((uint)0x00080000)      /* big-end dest byte order */
-#define IDMA_BD_DDTB   ((uint)0x00010000)      /* destination data bus */
-#define IDMA_BD_SGBL   ((uint)0x00002000)      /* source global */
-#define IDMA_BD_SBO_LE ((uint)0x00000800)      /* little-end src byte order */
-#define IDMA_BD_SBO_BE ((uint)0x00001000)      /* big-end src byte order */
-#define IDMA_BD_SDTB   ((uint)0x00000200)      /* source data bus */
-
-/* per-channel IDMA registers
-*/
-typedef struct im_idma {
-       u_char idsr;                    /* IDMAn event status register */
-       u_char res0[3];
-       u_char idmr;                    /* IDMAn event mask register */
-       u_char res1[3];
-} im_idma_t;
-
-/* IDMA event register bit fields
-*/
-#define IDMA_EVENT_SC  ((unsigned char)0x08)   /* stop completed */
-#define IDMA_EVENT_OB  ((unsigned char)0x04)   /* out of buffers */
-#define IDMA_EVENT_EDN ((unsigned char)0x02)   /* external DONE asserted */
-#define IDMA_EVENT_BC  ((unsigned char)0x01)   /* buffer descriptor complete */
-
-/* RISC Controller Configuration Register (RCCR) bit fields
-*/
-#define RCCR_TIME      ((uint)0x80000000) /* timer enable */
-#define RCCR_TIMEP_MASK        ((uint)0x3f000000) /* mask for timer period bit field */
-#define RCCR_DR0M      ((uint)0x00800000) /* IDMA0 request mode */
-#define RCCR_DR1M      ((uint)0x00400000) /* IDMA1 request mode */
-#define RCCR_DR2M      ((uint)0x00000080) /* IDMA2 request mode */
-#define RCCR_DR3M      ((uint)0x00000040) /* IDMA3 request mode */
-#define RCCR_DR0QP_MASK        ((uint)0x00300000) /* mask for IDMA0 req priority */
-#define RCCR_DR0QP_HIGH ((uint)0x00000000) /* IDMA0 has high req priority */
-#define RCCR_DR0QP_MED ((uint)0x00100000) /* IDMA0 has medium req priority */
-#define RCCR_DR0QP_LOW ((uint)0x00200000) /* IDMA0 has low req priority */
-#define RCCR_DR1QP_MASK        ((uint)0x00030000) /* mask for IDMA1 req priority */
-#define RCCR_DR1QP_HIGH ((uint)0x00000000) /* IDMA1 has high req priority */
-#define RCCR_DR1QP_MED ((uint)0x00010000) /* IDMA1 has medium req priority */
-#define RCCR_DR1QP_LOW ((uint)0x00020000) /* IDMA1 has low req priority */
-#define RCCR_DR2QP_MASK        ((uint)0x00000030) /* mask for IDMA2 req priority */
-#define RCCR_DR2QP_HIGH ((uint)0x00000000) /* IDMA2 has high req priority */
-#define RCCR_DR2QP_MED ((uint)0x00000010) /* IDMA2 has medium req priority */
-#define RCCR_DR2QP_LOW ((uint)0x00000020) /* IDMA2 has low req priority */
-#define RCCR_DR3QP_MASK        ((uint)0x00000003) /* mask for IDMA3 req priority */
-#define RCCR_DR3QP_HIGH ((uint)0x00000000) /* IDMA3 has high req priority */
-#define RCCR_DR3QP_MED ((uint)0x00000001) /* IDMA3 has medium req priority */
-#define RCCR_DR3QP_LOW ((uint)0x00000002) /* IDMA3 has low req priority */
-#define RCCR_EIE       ((uint)0x00080000) /* external interrupt enable */
-#define RCCR_SCD       ((uint)0x00040000) /* scheduler configuration */
-#define RCCR_ERAM_MASK ((uint)0x0000e000) /* mask for enable RAM microcode */
-#define RCCR_ERAM_0KB  ((uint)0x00000000) /* use 0KB of dpram for microcode */
-#define RCCR_ERAM_2KB  ((uint)0x00002000) /* use 2KB of dpram for microcode */
-#define RCCR_ERAM_4KB  ((uint)0x00004000) /* use 4KB of dpram for microcode */
-#define RCCR_ERAM_6KB  ((uint)0x00006000) /* use 6KB of dpram for microcode */
-#define RCCR_ERAM_8KB  ((uint)0x00008000) /* use 8KB of dpram for microcode */
-#define RCCR_ERAM_10KB ((uint)0x0000a000) /* use 10KB of dpram for microcode */
-#define RCCR_ERAM_12KB ((uint)0x0000c000) /* use 12KB of dpram for microcode */
-#define RCCR_EDM0      ((uint)0x00000800) /* DREQ0 edge detect mode */
-#define RCCR_EDM1      ((uint)0x00000400) /* DREQ1 edge detect mode */
-#define RCCR_EDM2      ((uint)0x00000200) /* DREQ2 edge detect mode */
-#define RCCR_EDM3      ((uint)0x00000100) /* DREQ3 edge detect mode */
-#define RCCR_DEM01     ((uint)0x00000008) /* DONE0/DONE1 edge detect mode */
-#define RCCR_DEM23     ((uint)0x00000004) /* DONE2/DONE3 edge detect mode */
-
-/*-----------------------------------------------------------------------
- * CMXFCR - CMX FCC Clock Route Register
- */
-#define CMXFCR_FC1         0x40000000   /* FCC1 connection              */
-#define CMXFCR_RF1CS_MSK   0x38000000   /* Receive FCC1 Clock Source Mask */
-#define CMXFCR_TF1CS_MSK   0x07000000   /* Transmit FCC1 Clock Source Mask */
-#define CMXFCR_FC2         0x00400000   /* FCC2 connection              */
-#define CMXFCR_RF2CS_MSK   0x00380000   /* Receive FCC2 Clock Source Mask */
-#define CMXFCR_TF2CS_MSK   0x00070000   /* Transmit FCC2 Clock Source Mask */
-#define CMXFCR_FC3         0x00004000   /* FCC3 connection              */
-#define CMXFCR_RF3CS_MSK   0x00003800   /* Receive FCC3 Clock Source Mask */
-#define CMXFCR_TF3CS_MSK   0x00000700   /* Transmit FCC3 Clock Source Mask */
-
-#define CMXFCR_RF1CS_BRG5  0x00000000   /* Receive FCC1 Clock Source is BRG5 */
-#define CMXFCR_RF1CS_BRG6  0x08000000   /* Receive FCC1 Clock Source is BRG6 */
-#define CMXFCR_RF1CS_BRG7  0x10000000   /* Receive FCC1 Clock Source is BRG7 */
-#define CMXFCR_RF1CS_BRG8  0x18000000   /* Receive FCC1 Clock Source is BRG8 */
-#define CMXFCR_RF1CS_CLK9  0x20000000   /* Receive FCC1 Clock Source is CLK9 */
-#define CMXFCR_RF1CS_CLK10 0x28000000   /* Receive FCC1 Clock Source is CLK10 */
-#define CMXFCR_RF1CS_CLK11 0x30000000   /* Receive FCC1 Clock Source is CLK11 */
-#define CMXFCR_RF1CS_CLK12 0x38000000   /* Receive FCC1 Clock Source is CLK12 */
-
-#define CMXFCR_TF1CS_BRG5  0x00000000   /* Transmit FCC1 Clock Source is BRG5 */
-#define CMXFCR_TF1CS_BRG6  0x01000000   /* Transmit FCC1 Clock Source is BRG6 */
-#define CMXFCR_TF1CS_BRG7  0x02000000   /* Transmit FCC1 Clock Source is BRG7 */
-#define CMXFCR_TF1CS_BRG8  0x03000000   /* Transmit FCC1 Clock Source is BRG8 */
-#define CMXFCR_TF1CS_CLK9  0x04000000   /* Transmit FCC1 Clock Source is CLK9 */
-#define CMXFCR_TF1CS_CLK10 0x05000000   /* Transmit FCC1 Clock Source is CLK10 */
-#define CMXFCR_TF1CS_CLK11 0x06000000   /* Transmit FCC1 Clock Source is CLK11 */
-#define CMXFCR_TF1CS_CLK12 0x07000000   /* Transmit FCC1 Clock Source is CLK12 */
-
-#define CMXFCR_RF2CS_BRG5  0x00000000   /* Receive FCC2 Clock Source is BRG5 */
-#define CMXFCR_RF2CS_BRG6  0x00080000   /* Receive FCC2 Clock Source is BRG6 */
-#define CMXFCR_RF2CS_BRG7  0x00100000   /* Receive FCC2 Clock Source is BRG7 */
-#define CMXFCR_RF2CS_BRG8  0x00180000   /* Receive FCC2 Clock Source is BRG8 */
-#define CMXFCR_RF2CS_CLK13 0x00200000   /* Receive FCC2 Clock Source is CLK13 */
-#define CMXFCR_RF2CS_CLK14 0x00280000   /* Receive FCC2 Clock Source is CLK14 */
-#define CMXFCR_RF2CS_CLK15 0x00300000   /* Receive FCC2 Clock Source is CLK15 */
-#define CMXFCR_RF2CS_CLK16 0x00380000   /* Receive FCC2 Clock Source is CLK16 */
-
-#define CMXFCR_TF2CS_BRG5  0x00000000   /* Transmit FCC2 Clock Source is BRG5 */
-#define CMXFCR_TF2CS_BRG6  0x00010000   /* Transmit FCC2 Clock Source is BRG6 */
-#define CMXFCR_TF2CS_BRG7  0x00020000   /* Transmit FCC2 Clock Source is BRG7 */
-#define CMXFCR_TF2CS_BRG8  0x00030000   /* Transmit FCC2 Clock Source is BRG8 */
-#define CMXFCR_TF2CS_CLK13 0x00040000   /* Transmit FCC2 Clock Source is CLK13 */
-#define CMXFCR_TF2CS_CLK14 0x00050000   /* Transmit FCC2 Clock Source is CLK14 */
-#define CMXFCR_TF2CS_CLK15 0x00060000   /* Transmit FCC2 Clock Source is CLK15 */
-#define CMXFCR_TF2CS_CLK16 0x00070000   /* Transmit FCC2 Clock Source is CLK16 */
-
-#define CMXFCR_RF3CS_BRG5  0x00000000   /* Receive FCC3 Clock Source is BRG5 */
-#define CMXFCR_RF3CS_BRG6  0x00000800   /* Receive FCC3 Clock Source is BRG6 */
-#define CMXFCR_RF3CS_BRG7  0x00001000   /* Receive FCC3 Clock Source is BRG7 */
-#define CMXFCR_RF3CS_BRG8  0x00001800   /* Receive FCC3 Clock Source is BRG8 */
-#define CMXFCR_RF3CS_CLK13 0x00002000   /* Receive FCC3 Clock Source is CLK13 */
-#define CMXFCR_RF3CS_CLK14 0x00002800   /* Receive FCC3 Clock Source is CLK14 */
-#define CMXFCR_RF3CS_CLK15 0x00003000   /* Receive FCC3 Clock Source is CLK15 */
-#define CMXFCR_RF3CS_CLK16 0x00003800   /* Receive FCC3 Clock Source is CLK16 */
-
-#define CMXFCR_TF3CS_BRG5  0x00000000   /* Transmit FCC3 Clock Source is BRG5 */
-#define CMXFCR_TF3CS_BRG6  0x00000100   /* Transmit FCC3 Clock Source is BRG6 */
-#define CMXFCR_TF3CS_BRG7  0x00000200   /* Transmit FCC3 Clock Source is BRG7 */
-#define CMXFCR_TF3CS_BRG8  0x00000300   /* Transmit FCC3 Clock Source is BRG8 */
-#define CMXFCR_TF3CS_CLK13 0x00000400   /* Transmit FCC3 Clock Source is CLK13 */
-#define CMXFCR_TF3CS_CLK14 0x00000500   /* Transmit FCC3 Clock Source is CLK14 */
-#define CMXFCR_TF3CS_CLK15 0x00000600   /* Transmit FCC3 Clock Source is CLK15 */
-#define CMXFCR_TF3CS_CLK16 0x00000700   /* Transmit FCC3 Clock Source is CLK16 */
-
-/*-----------------------------------------------------------------------
- * CMXSCR - CMX SCC Clock Route Register
- */
-#define CMXSCR_GR1         0x80000000   /* Grant Support of SCC1        */
-#define CMXSCR_SC1         0x40000000   /* SCC1 connection              */
-#define CMXSCR_RS1CS_MSK   0x38000000   /* Receive SCC1 Clock Source Mask */
-#define CMXSCR_TS1CS_MSK   0x07000000   /* Transmit SCC1 Clock Source Mask */
-#define CMXSCR_GR2         0x00800000   /* Grant Support of SCC2        */
-#define CMXSCR_SC2         0x00400000   /* SCC2 connection              */
-#define CMXSCR_RS2CS_MSK   0x00380000   /* Receive SCC2 Clock Source Mask */
-#define CMXSCR_TS2CS_MSK   0x00070000   /* Transmit SCC2 Clock Source Mask */
-#define CMXSCR_GR3         0x00008000   /* Grant Support of SCC3        */
-#define CMXSCR_SC3         0x00004000   /* SCC3 connection              */
-#define CMXSCR_RS3CS_MSK   0x00003800   /* Receive SCC3 Clock Source Mask */
-#define CMXSCR_TS3CS_MSK   0x00000700   /* Transmit SCC3 Clock Source Mask */
-#define CMXSCR_GR4         0x00000080   /* Grant Support of SCC4        */
-#define CMXSCR_SC4         0x00000040   /* SCC4 connection              */
-#define CMXSCR_RS4CS_MSK   0x00000038   /* Receive SCC4 Clock Source Mask */
-#define CMXSCR_TS4CS_MSK   0x00000007   /* Transmit SCC4 Clock Source Mask */
-
-#define CMXSCR_RS1CS_BRG1  0x00000000   /* SCC1 Rx Clock Source is BRG1 */
-#define CMXSCR_RS1CS_BRG2  0x08000000   /* SCC1 Rx Clock Source is BRG2 */
-#define CMXSCR_RS1CS_BRG3  0x10000000   /* SCC1 Rx Clock Source is BRG3 */
-#define CMXSCR_RS1CS_BRG4  0x18000000   /* SCC1 Rx Clock Source is BRG4 */
-#define CMXSCR_RS1CS_CLK11 0x20000000   /* SCC1 Rx Clock Source is CLK11 */
-#define CMXSCR_RS1CS_CLK12 0x28000000   /* SCC1 Rx Clock Source is CLK12 */
-#define CMXSCR_RS1CS_CLK3  0x30000000   /* SCC1 Rx Clock Source is CLK3 */
-#define CMXSCR_RS1CS_CLK4  0x38000000   /* SCC1 Rx Clock Source is CLK4 */
-
-#define CMXSCR_TS1CS_BRG1  0x00000000   /* SCC1 Tx Clock Source is BRG1 */
-#define CMXSCR_TS1CS_BRG2  0x01000000   /* SCC1 Tx Clock Source is BRG2 */
-#define CMXSCR_TS1CS_BRG3  0x02000000   /* SCC1 Tx Clock Source is BRG3 */
-#define CMXSCR_TS1CS_BRG4  0x03000000   /* SCC1 Tx Clock Source is BRG4 */
-#define CMXSCR_TS1CS_CLK11 0x04000000   /* SCC1 Tx Clock Source is CLK11 */
-#define CMXSCR_TS1CS_CLK12 0x05000000   /* SCC1 Tx Clock Source is CLK12 */
-#define CMXSCR_TS1CS_CLK3  0x06000000   /* SCC1 Tx Clock Source is CLK3 */
-#define CMXSCR_TS1CS_CLK4  0x07000000   /* SCC1 Tx Clock Source is CLK4 */
-
-#define CMXSCR_RS2CS_BRG1  0x00000000   /* SCC2 Rx Clock Source is BRG1 */
-#define CMXSCR_RS2CS_BRG2  0x00080000   /* SCC2 Rx Clock Source is BRG2 */
-#define CMXSCR_RS2CS_BRG3  0x00100000   /* SCC2 Rx Clock Source is BRG3 */
-#define CMXSCR_RS2CS_BRG4  0x00180000   /* SCC2 Rx Clock Source is BRG4 */
-#define CMXSCR_RS2CS_CLK11 0x00200000   /* SCC2 Rx Clock Source is CLK11 */
-#define CMXSCR_RS2CS_CLK12 0x00280000   /* SCC2 Rx Clock Source is CLK12 */
-#define CMXSCR_RS2CS_CLK3  0x00300000   /* SCC2 Rx Clock Source is CLK3 */
-#define CMXSCR_RS2CS_CLK4  0x00380000   /* SCC2 Rx Clock Source is CLK4 */
-
-#define CMXSCR_TS2CS_BRG1  0x00000000   /* SCC2 Tx Clock Source is BRG1 */
-#define CMXSCR_TS2CS_BRG2  0x00010000   /* SCC2 Tx Clock Source is BRG2 */
-#define CMXSCR_TS2CS_BRG3  0x00020000   /* SCC2 Tx Clock Source is BRG3 */
-#define CMXSCR_TS2CS_BRG4  0x00030000   /* SCC2 Tx Clock Source is BRG4 */
-#define CMXSCR_TS2CS_CLK11 0x00040000   /* SCC2 Tx Clock Source is CLK11 */
-#define CMXSCR_TS2CS_CLK12 0x00050000   /* SCC2 Tx Clock Source is CLK12 */
-#define CMXSCR_TS2CS_CLK3  0x00060000   /* SCC2 Tx Clock Source is CLK3 */
-#define CMXSCR_TS2CS_CLK4  0x00070000   /* SCC2 Tx Clock Source is CLK4 */
-
-#define CMXSCR_RS3CS_BRG1  0x00000000   /* SCC3 Rx Clock Source is BRG1 */
-#define CMXSCR_RS3CS_BRG2  0x00000800   /* SCC3 Rx Clock Source is BRG2 */
-#define CMXSCR_RS3CS_BRG3  0x00001000   /* SCC3 Rx Clock Source is BRG3 */
-#define CMXSCR_RS3CS_BRG4  0x00001800   /* SCC3 Rx Clock Source is BRG4 */
-#define CMXSCR_RS3CS_CLK5  0x00002000   /* SCC3 Rx Clock Source is CLK5 */
-#define CMXSCR_RS3CS_CLK6  0x00002800   /* SCC3 Rx Clock Source is CLK6 */
-#define CMXSCR_RS3CS_CLK7  0x00003000   /* SCC3 Rx Clock Source is CLK7 */
-#define CMXSCR_RS3CS_CLK8  0x00003800   /* SCC3 Rx Clock Source is CLK8 */
-
-#define CMXSCR_TS3CS_BRG1  0x00000000   /* SCC3 Tx Clock Source is BRG1 */
-#define CMXSCR_TS3CS_BRG2  0x00000100   /* SCC3 Tx Clock Source is BRG2 */
-#define CMXSCR_TS3CS_BRG3  0x00000200   /* SCC3 Tx Clock Source is BRG3 */
-#define CMXSCR_TS3CS_BRG4  0x00000300   /* SCC3 Tx Clock Source is BRG4 */
-#define CMXSCR_TS3CS_CLK5  0x00000400   /* SCC3 Tx Clock Source is CLK5 */
-#define CMXSCR_TS3CS_CLK6  0x00000500   /* SCC3 Tx Clock Source is CLK6 */
-#define CMXSCR_TS3CS_CLK7  0x00000600   /* SCC3 Tx Clock Source is CLK7 */
-#define CMXSCR_TS3CS_CLK8  0x00000700   /* SCC3 Tx Clock Source is CLK8 */
-
-#define CMXSCR_RS4CS_BRG1  0x00000000   /* SCC4 Rx Clock Source is BRG1 */
-#define CMXSCR_RS4CS_BRG2  0x00000008   /* SCC4 Rx Clock Source is BRG2 */
-#define CMXSCR_RS4CS_BRG3  0x00000010   /* SCC4 Rx Clock Source is BRG3 */
-#define CMXSCR_RS4CS_BRG4  0x00000018   /* SCC4 Rx Clock Source is BRG4 */
-#define CMXSCR_RS4CS_CLK5  0x00000020   /* SCC4 Rx Clock Source is CLK5 */
-#define CMXSCR_RS4CS_CLK6  0x00000028   /* SCC4 Rx Clock Source is CLK6 */
-#define CMXSCR_RS4CS_CLK7  0x00000030   /* SCC4 Rx Clock Source is CLK7 */
-#define CMXSCR_RS4CS_CLK8  0x00000038   /* SCC4 Rx Clock Source is CLK8 */
-
-#define CMXSCR_TS4CS_BRG1  0x00000000   /* SCC4 Tx Clock Source is BRG1 */
-#define CMXSCR_TS4CS_BRG2  0x00000001   /* SCC4 Tx Clock Source is BRG2 */
-#define CMXSCR_TS4CS_BRG3  0x00000002   /* SCC4 Tx Clock Source is BRG3 */
-#define CMXSCR_TS4CS_BRG4  0x00000003   /* SCC4 Tx Clock Source is BRG4 */
-#define CMXSCR_TS4CS_CLK5  0x00000004   /* SCC4 Tx Clock Source is CLK5 */
-#define CMXSCR_TS4CS_CLK6  0x00000005   /* SCC4 Tx Clock Source is CLK6 */
-#define CMXSCR_TS4CS_CLK7  0x00000006   /* SCC4 Tx Clock Source is CLK7 */
-#define CMXSCR_TS4CS_CLK8  0x00000007   /* SCC4 Tx Clock Source is CLK8 */
-
-#endif /* __CPM2__ */
-#endif /* __KERNEL__ */
-
-
diff --git a/include/asm-ppc/cpm_8260.h b/include/asm-ppc/cpm_8260.h
deleted file mode 100644 (file)
index 0afe638..0000000
+++ /dev/null
@@ -1,702 +0,0 @@
-/*
- * MPC8260 Communication Processor Module.
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- *
- * This file contains structures and information for the communication
- * processor channels found in the dual port RAM or parameter RAM.
- * All CPM control and status is available through the MPC8260 internal
- * memory map.  See immap.h for details.
- */
-#ifdef __KERNEL__
-#ifndef __CPM_82XX__
-#define __CPM_82XX__
-
-#include <asm/immap_8260.h>
-
-/* CPM Command register.
-*/
-#define CPM_CR_RST     ((uint)0x80000000)
-#define CPM_CR_PAGE    ((uint)0x7c000000)
-#define CPM_CR_SBLOCK  ((uint)0x03e00000)
-#define CPM_CR_FLG     ((uint)0x00010000)
-#define CPM_CR_MCN     ((uint)0x00003fc0)
-#define CPM_CR_OPCODE  ((uint)0x0000000f)
-
-/* Device sub-block and page codes.
-*/
-#define CPM_CR_SCC1_SBLOCK     (0x04)
-#define CPM_CR_SCC2_SBLOCK     (0x05)
-#define CPM_CR_SCC3_SBLOCK     (0x06)
-#define CPM_CR_SCC4_SBLOCK     (0x07)
-#define CPM_CR_SMC1_SBLOCK     (0x08)
-#define CPM_CR_SMC2_SBLOCK     (0x09)
-#define CPM_CR_SPI_SBLOCK      (0x0a)
-#define CPM_CR_I2C_SBLOCK      (0x0b)
-#define CPM_CR_TIMER_SBLOCK    (0x0f)
-#define CPM_CR_RAND_SBLOCK     (0x0e)
-#define CPM_CR_FCC1_SBLOCK     (0x10)
-#define CPM_CR_FCC2_SBLOCK     (0x11)
-#define CPM_CR_FCC3_SBLOCK     (0x12)
-#define CPM_CR_IDMA1_SBLOCK    (0x14)
-#define CPM_CR_IDMA2_SBLOCK    (0x15)
-#define CPM_CR_IDMA3_SBLOCK    (0x16)
-#define CPM_CR_IDMA4_SBLOCK    (0x17)
-#define CPM_CR_MCC1_SBLOCK     (0x1c)
-
-#define CPM_CR_SCC1_PAGE       (0x00)
-#define CPM_CR_SCC2_PAGE       (0x01)
-#define CPM_CR_SCC3_PAGE       (0x02)
-#define CPM_CR_SCC4_PAGE       (0x03)
-#define CPM_CR_SMC1_PAGE       (0x07)
-#define CPM_CR_SMC2_PAGE       (0x08)
-#define CPM_CR_SPI_PAGE                (0x09)
-#define CPM_CR_I2C_PAGE                (0x0a)
-#define CPM_CR_TIMER_PAGE      (0x0a)
-#define CPM_CR_RAND_PAGE       (0x0a)
-#define CPM_CR_FCC1_PAGE       (0x04)
-#define CPM_CR_FCC2_PAGE       (0x05)
-#define CPM_CR_FCC3_PAGE       (0x06)
-#define CPM_CR_IDMA1_PAGE      (0x07)
-#define CPM_CR_IDMA2_PAGE      (0x08)
-#define CPM_CR_IDMA3_PAGE      (0x09)
-#define CPM_CR_IDMA4_PAGE      (0x0a)
-#define CPM_CR_MCC1_PAGE       (0x07)
-#define CPM_CR_MCC2_PAGE       (0x08)
-
-/* Some opcodes (there are more...later)
-*/
-#define CPM_CR_INIT_TRX                ((ushort)0x0000)
-#define CPM_CR_INIT_RX         ((ushort)0x0001)
-#define CPM_CR_INIT_TX         ((ushort)0x0002)
-#define CPM_CR_HUNT_MODE       ((ushort)0x0003)
-#define CPM_CR_STOP_TX         ((ushort)0x0004)
-#define CPM_CR_RESTART_TX      ((ushort)0x0006)
-#define CPM_CR_SET_GADDR       ((ushort)0x0008)
-
-#define mk_cr_cmd(PG, SBC, MCN, OP) \
-       ((PG << 26) | (SBC << 21) | (MCN << 6) | OP)
-
-/* Dual Port RAM addresses.  The first 16K is available for almost
- * any CPM use, so we put the BDs there.  The first 128 bytes are
- * used for SMC1 and SMC2 parameter RAM, so we start allocating
- * BDs above that.  All of this must change when we start
- * downloading RAM microcode.
- */
-#define CPM_DATAONLY_BASE      ((uint)128)
-#define CPM_DATAONLY_SIZE      ((uint)(16 * 1024) - CPM_DATAONLY_BASE)
-#define CPM_DP_NOSPACE         ((uint)0x7fffffff)
-#define CPM_FCC_SPECIAL_BASE   ((uint)0x0000b000)
-
-/* The number of pages of host memory we allocate for CPM.  This is
- * done early in kernel initialization to get physically contiguous
- * pages.
- */
-#define NUM_CPM_HOST_PAGES     2
-
-
-/* Export the base address of the communication processor registers
- * and dual port ram.
- */
-extern cpm8260_t       *cpmp;          /* Pointer to comm processor */
-uint           m8260_cpm_dpalloc(uint size, uint align);
-uint           m8260_cpm_hostalloc(uint size, uint align);
-void           m8260_cpm_setbrg(uint brg, uint rate);
-void           m8260_cpm_fastbrg(uint brg, uint rate, int div16);
-
-/* Buffer descriptors used by many of the CPM protocols.
-*/
-typedef struct cpm_buf_desc {
-       ushort  cbd_sc;         /* Status and Control */
-       ushort  cbd_datlen;     /* Data length in buffer */
-       uint    cbd_bufaddr;    /* Buffer address in host memory */
-} cbd_t;
-
-#define BD_SC_EMPTY    ((ushort)0x8000)        /* Receive is empty */
-#define BD_SC_READY    ((ushort)0x8000)        /* Transmit is ready */
-#define BD_SC_WRAP     ((ushort)0x2000)        /* Last buffer descriptor */
-#define BD_SC_INTRPT   ((ushort)0x1000)        /* Interrupt on change */
-#define BD_SC_LAST     ((ushort)0x0800)        /* Last buffer in frame */
-#define BD_SC_CM       ((ushort)0x0200)        /* Continous mode */
-#define BD_SC_ID       ((ushort)0x0100)        /* Rec'd too many idles */
-#define BD_SC_P                ((ushort)0x0100)        /* xmt preamble */
-#define BD_SC_BR       ((ushort)0x0020)        /* Break received */
-#define BD_SC_FR       ((ushort)0x0010)        /* Framing error */
-#define BD_SC_PR       ((ushort)0x0008)        /* Parity error */
-#define BD_SC_OV       ((ushort)0x0002)        /* Overrun */
-#define BD_SC_CD       ((ushort)0x0001)        /* ?? */
-
-/* Function code bits, usually generic to devices.
-*/
-#define CPMFCR_GBL     ((u_char)0x20)  /* Set memory snooping */
-#define CPMFCR_EB      ((u_char)0x10)  /* Set big endian byte order */
-#define CPMFCR_TC2     ((u_char)0x04)  /* Transfer code 2 value */
-#define CPMFCR_DTB     ((u_char)0x02)  /* Use local bus for data when set */
-#define CPMFCR_BDB     ((u_char)0x01)  /* Use local bus for BD when set */
-
-/* Parameter RAM offsets from the base.
-*/
-#define PROFF_SCC1             ((uint)0x8000)
-#define PROFF_SCC2             ((uint)0x8100)
-#define PROFF_SCC3             ((uint)0x8200)
-#define PROFF_SCC4             ((uint)0x8300)
-#define PROFF_FCC1             ((uint)0x8400)
-#define PROFF_FCC2             ((uint)0x8500)
-#define PROFF_FCC3             ((uint)0x8600)
-#define PROFF_MCC1             ((uint)0x8700)
-#define PROFF_SMC1_BASE                ((uint)0x87fc)
-#define PROFF_IDMA1_BASE       ((uint)0x87fe)
-#define PROFF_MCC2             ((uint)0x8800)
-#define PROFF_SMC2_BASE                ((uint)0x88fc)
-#define PROFF_IDMA2_BASE       ((uint)0x88fe)
-#define PROFF_SPI_BASE         ((uint)0x89fc)
-#define PROFF_IDMA3_BASE       ((uint)0x89fe)
-#define PROFF_TIMERS           ((uint)0x8ae0)
-#define PROFF_REVNUM           ((uint)0x8af0)
-#define PROFF_RAND             ((uint)0x8af8)
-#define PROFF_I2C_BASE         ((uint)0x8afc)
-#define PROFF_IDMA4_BASE       ((uint)0x8afe)
-
-/* The SMCs are relocated to any of the first eight DPRAM pages.
- * We will fix these at the first locations of DPRAM, until we
- * get some microcode patches :-).
- * The parameter ram space for the SMCs is fifty-some bytes, and
- * they are required to start on a 64 byte boundary.
- */
-#define PROFF_SMC1     (0)
-#define PROFF_SMC2     (64)
-
-
-/* Define enough so I can at least use the serial port as a UART.
- */
-typedef struct smc_uart {
-       ushort  smc_rbase;      /* Rx Buffer descriptor base address */
-       ushort  smc_tbase;      /* Tx Buffer descriptor base address */
-       u_char  smc_rfcr;       /* Rx function code */
-       u_char  smc_tfcr;       /* Tx function code */
-       ushort  smc_mrblr;      /* Max receive buffer length */
-       uint    smc_rstate;     /* Internal */
-       uint    smc_idp;        /* Internal */
-       ushort  smc_rbptr;      /* Internal */
-       ushort  smc_ibc;        /* Internal */
-       uint    smc_rxtmp;      /* Internal */
-       uint    smc_tstate;     /* Internal */
-       uint    smc_tdp;        /* Internal */
-       ushort  smc_tbptr;      /* Internal */
-       ushort  smc_tbc;        /* Internal */
-       uint    smc_txtmp;      /* Internal */
-       ushort  smc_maxidl;     /* Maximum idle characters */
-       ushort  smc_tmpidl;     /* Temporary idle counter */
-       ushort  smc_brklen;     /* Last received break length */
-       ushort  smc_brkec;      /* rcv'd break condition counter */
-       ushort  smc_brkcr;      /* xmt break count register */
-       ushort  smc_rmask;      /* Temporary bit mask */
-       uint    smc_stmp;       /* SDMA Temp */
-} smc_uart_t;
-
-/* SMC uart mode register (Internal memory map).
-*/
-#define SMCMR_REN      ((ushort)0x0001)
-#define SMCMR_TEN      ((ushort)0x0002)
-#define SMCMR_DM       ((ushort)0x000c)
-#define SMCMR_SM_GCI   ((ushort)0x0000)
-#define SMCMR_SM_UART  ((ushort)0x0020)
-#define SMCMR_SM_TRANS ((ushort)0x0030)
-#define SMCMR_SM_MASK  ((ushort)0x0030)
-#define SMCMR_PM_EVEN  ((ushort)0x0100)        /* Even parity, else odd */
-#define SMCMR_REVD     SMCMR_PM_EVEN
-#define SMCMR_PEN      ((ushort)0x0200)        /* Parity enable */
-#define SMCMR_BS       SMCMR_PEN
-#define SMCMR_SL       ((ushort)0x0400)        /* Two stops, else one */
-#define SMCR_CLEN_MASK ((ushort)0x7800)        /* Character length */
-#define smcr_mk_clen(C)        (((C) << 11) & SMCR_CLEN_MASK)
-
-/* SMC Event and Mask register.
-*/
-#define SMCM_BRKE       ((unsigned char)0x40)   /* When in UART Mode */
-#define SMCM_BRK        ((unsigned char)0x10)   /* When in UART Mode */
-#define SMCM_TXE       ((unsigned char)0x10)
-#define SMCM_BSY       ((unsigned char)0x04)
-#define SMCM_TX                ((unsigned char)0x02)
-#define SMCM_RX                ((unsigned char)0x01)
-
-/* Baud rate generators.
-*/
-#define CPM_BRG_RST            ((uint)0x00020000)
-#define CPM_BRG_EN             ((uint)0x00010000)
-#define CPM_BRG_EXTC_INT       ((uint)0x00000000)
-#define CPM_BRG_EXTC_CLK3_9    ((uint)0x00004000)
-#define CPM_BRG_EXTC_CLK5_15   ((uint)0x00008000)
-#define CPM_BRG_ATB            ((uint)0x00002000)
-#define CPM_BRG_CD_MASK                ((uint)0x00001ffe)
-#define CPM_BRG_DIV16          ((uint)0x00000001)
-
-/* SCCs.
-*/
-#define SCC_GSMRH_IRP          ((uint)0x00040000)
-#define SCC_GSMRH_GDE          ((uint)0x00010000)
-#define SCC_GSMRH_TCRC_CCITT   ((uint)0x00008000)
-#define SCC_GSMRH_TCRC_BISYNC  ((uint)0x00004000)
-#define SCC_GSMRH_TCRC_HDLC    ((uint)0x00000000)
-#define SCC_GSMRH_REVD         ((uint)0x00002000)
-#define SCC_GSMRH_TRX          ((uint)0x00001000)
-#define SCC_GSMRH_TTX          ((uint)0x00000800)
-#define SCC_GSMRH_CDP          ((uint)0x00000400)
-#define SCC_GSMRH_CTSP         ((uint)0x00000200)
-#define SCC_GSMRH_CDS          ((uint)0x00000100)
-#define SCC_GSMRH_CTSS         ((uint)0x00000080)
-#define SCC_GSMRH_TFL          ((uint)0x00000040)
-#define SCC_GSMRH_RFW          ((uint)0x00000020)
-#define SCC_GSMRH_TXSY         ((uint)0x00000010)
-#define SCC_GSMRH_SYNL16       ((uint)0x0000000c)
-#define SCC_GSMRH_SYNL8                ((uint)0x00000008)
-#define SCC_GSMRH_SYNL4                ((uint)0x00000004)
-#define SCC_GSMRH_RTSM         ((uint)0x00000002)
-#define SCC_GSMRH_RSYN         ((uint)0x00000001)
-
-#define SCC_GSMRL_SIR          ((uint)0x80000000)      /* SCC2 only */
-#define SCC_GSMRL_EDGE_NONE    ((uint)0x60000000)
-#define SCC_GSMRL_EDGE_NEG     ((uint)0x40000000)
-#define SCC_GSMRL_EDGE_POS     ((uint)0x20000000)
-#define SCC_GSMRL_EDGE_BOTH    ((uint)0x00000000)
-#define SCC_GSMRL_TCI          ((uint)0x10000000)
-#define SCC_GSMRL_TSNC_3       ((uint)0x0c000000)
-#define SCC_GSMRL_TSNC_4       ((uint)0x08000000)
-#define SCC_GSMRL_TSNC_14      ((uint)0x04000000)
-#define SCC_GSMRL_TSNC_INF     ((uint)0x00000000)
-#define SCC_GSMRL_RINV         ((uint)0x02000000)
-#define SCC_GSMRL_TINV         ((uint)0x01000000)
-#define SCC_GSMRL_TPL_128      ((uint)0x00c00000)
-#define SCC_GSMRL_TPL_64       ((uint)0x00a00000)
-#define SCC_GSMRL_TPL_48       ((uint)0x00800000)
-#define SCC_GSMRL_TPL_32       ((uint)0x00600000)
-#define SCC_GSMRL_TPL_16       ((uint)0x00400000)
-#define SCC_GSMRL_TPL_8                ((uint)0x00200000)
-#define SCC_GSMRL_TPL_NONE     ((uint)0x00000000)
-#define SCC_GSMRL_TPP_ALL1     ((uint)0x00180000)
-#define SCC_GSMRL_TPP_01       ((uint)0x00100000)
-#define SCC_GSMRL_TPP_10       ((uint)0x00080000)
-#define SCC_GSMRL_TPP_ZEROS    ((uint)0x00000000)
-#define SCC_GSMRL_TEND         ((uint)0x00040000)
-#define SCC_GSMRL_TDCR_32      ((uint)0x00030000)
-#define SCC_GSMRL_TDCR_16      ((uint)0x00020000)
-#define SCC_GSMRL_TDCR_8       ((uint)0x00010000)
-#define SCC_GSMRL_TDCR_1       ((uint)0x00000000)
-#define SCC_GSMRL_RDCR_32      ((uint)0x0000c000)
-#define SCC_GSMRL_RDCR_16      ((uint)0x00008000)
-#define SCC_GSMRL_RDCR_8       ((uint)0x00004000)
-#define SCC_GSMRL_RDCR_1       ((uint)0x00000000)
-#define SCC_GSMRL_RENC_DFMAN   ((uint)0x00003000)
-#define SCC_GSMRL_RENC_MANCH   ((uint)0x00002000)
-#define SCC_GSMRL_RENC_FM0     ((uint)0x00001000)
-#define SCC_GSMRL_RENC_NRZI    ((uint)0x00000800)
-#define SCC_GSMRL_RENC_NRZ     ((uint)0x00000000)
-#define SCC_GSMRL_TENC_DFMAN   ((uint)0x00000600)
-#define SCC_GSMRL_TENC_MANCH   ((uint)0x00000400)
-#define SCC_GSMRL_TENC_FM0     ((uint)0x00000200)
-#define SCC_GSMRL_TENC_NRZI    ((uint)0x00000100)
-#define SCC_GSMRL_TENC_NRZ     ((uint)0x00000000)
-#define SCC_GSMRL_DIAG_LE      ((uint)0x000000c0)      /* Loop and echo */
-#define SCC_GSMRL_DIAG_ECHO    ((uint)0x00000080)
-#define SCC_GSMRL_DIAG_LOOP    ((uint)0x00000040)
-#define SCC_GSMRL_DIAG_NORM    ((uint)0x00000000)
-#define SCC_GSMRL_ENR          ((uint)0x00000020)
-#define SCC_GSMRL_ENT          ((uint)0x00000010)
-#define SCC_GSMRL_MODE_ENET    ((uint)0x0000000c)
-#define SCC_GSMRL_MODE_DDCMP   ((uint)0x00000009)
-#define SCC_GSMRL_MODE_BISYNC  ((uint)0x00000008)
-#define SCC_GSMRL_MODE_V14     ((uint)0x00000007)
-#define SCC_GSMRL_MODE_AHDLC   ((uint)0x00000006)
-#define SCC_GSMRL_MODE_PROFIBUS        ((uint)0x00000005)
-#define SCC_GSMRL_MODE_UART    ((uint)0x00000004)
-#define SCC_GSMRL_MODE_SS7     ((uint)0x00000003)
-#define SCC_GSMRL_MODE_ATALK   ((uint)0x00000002)
-#define SCC_GSMRL_MODE_HDLC    ((uint)0x00000000)
-
-#define SCC_TODR_TOD           ((ushort)0x8000)
-
-/* SCC Event and Mask register.
-*/
-#define SCCM_TXE       ((unsigned char)0x10)
-#define SCCM_BSY       ((unsigned char)0x04)
-#define SCCM_TX                ((unsigned char)0x02)
-#define SCCM_RX                ((unsigned char)0x01)
-
-typedef struct scc_param {
-       ushort  scc_rbase;      /* Rx Buffer descriptor base address */
-       ushort  scc_tbase;      /* Tx Buffer descriptor base address */
-       u_char  scc_rfcr;       /* Rx function code */
-       u_char  scc_tfcr;       /* Tx function code */
-       ushort  scc_mrblr;      /* Max receive buffer length */
-       uint    scc_rstate;     /* Internal */
-       uint    scc_idp;        /* Internal */
-       ushort  scc_rbptr;      /* Internal */
-       ushort  scc_ibc;        /* Internal */
-       uint    scc_rxtmp;      /* Internal */
-       uint    scc_tstate;     /* Internal */
-       uint    scc_tdp;        /* Internal */
-       ushort  scc_tbptr;      /* Internal */
-       ushort  scc_tbc;        /* Internal */
-       uint    scc_txtmp;      /* Internal */
-       uint    scc_rcrc;       /* Internal */
-       uint    scc_tcrc;       /* Internal */
-} sccp_t;
-
-/* CPM Ethernet through SCC1.
- */
-typedef struct scc_enet {
-       sccp_t  sen_genscc;
-       uint    sen_cpres;      /* Preset CRC */
-       uint    sen_cmask;      /* Constant mask for CRC */
-       uint    sen_crcec;      /* CRC Error counter */
-       uint    sen_alec;       /* alignment error counter */
-       uint    sen_disfc;      /* discard frame counter */
-       ushort  sen_pads;       /* Tx short frame pad character */
-       ushort  sen_retlim;     /* Retry limit threshold */
-       ushort  sen_retcnt;     /* Retry limit counter */
-       ushort  sen_maxflr;     /* maximum frame length register */
-       ushort  sen_minflr;     /* minimum frame length register */
-       ushort  sen_maxd1;      /* maximum DMA1 length */
-       ushort  sen_maxd2;      /* maximum DMA2 length */
-       ushort  sen_maxd;       /* Rx max DMA */
-       ushort  sen_dmacnt;     /* Rx DMA counter */
-       ushort  sen_maxb;       /* Max BD byte count */
-       ushort  sen_gaddr1;     /* Group address filter */
-       ushort  sen_gaddr2;
-       ushort  sen_gaddr3;
-       ushort  sen_gaddr4;
-       uint    sen_tbuf0data0; /* Save area 0 - current frame */
-       uint    sen_tbuf0data1; /* Save area 1 - current frame */
-       uint    sen_tbuf0rba;   /* Internal */
-       uint    sen_tbuf0crc;   /* Internal */
-       ushort  sen_tbuf0bcnt;  /* Internal */
-       ushort  sen_paddrh;     /* physical address (MSB) */
-       ushort  sen_paddrm;
-       ushort  sen_paddrl;     /* physical address (LSB) */
-       ushort  sen_pper;       /* persistence */
-       ushort  sen_rfbdptr;    /* Rx first BD pointer */
-       ushort  sen_tfbdptr;    /* Tx first BD pointer */
-       ushort  sen_tlbdptr;    /* Tx last BD pointer */
-       uint    sen_tbuf1data0; /* Save area 0 - current frame */
-       uint    sen_tbuf1data1; /* Save area 1 - current frame */
-       uint    sen_tbuf1rba;   /* Internal */
-       uint    sen_tbuf1crc;   /* Internal */
-       ushort  sen_tbuf1bcnt;  /* Internal */
-       ushort  sen_txlen;      /* Tx Frame length counter */
-       ushort  sen_iaddr1;     /* Individual address filter */
-       ushort  sen_iaddr2;
-       ushort  sen_iaddr3;
-       ushort  sen_iaddr4;
-       ushort  sen_boffcnt;    /* Backoff counter */
-
-       /* NOTE: Some versions of the manual have the following items
-        * incorrectly documented.  Below is the proper order.
-        */
-       ushort  sen_taddrh;     /* temp address (MSB) */
-       ushort  sen_taddrm;
-       ushort  sen_taddrl;     /* temp address (LSB) */
-} scc_enet_t;
-
-
-/* SCC Event register as used by Ethernet.
-*/
-#define SCCE_ENET_GRA  ((ushort)0x0080)        /* Graceful stop complete */
-#define SCCE_ENET_TXE  ((ushort)0x0010)        /* Transmit Error */
-#define SCCE_ENET_RXF  ((ushort)0x0008)        /* Full frame received */
-#define SCCE_ENET_BSY  ((ushort)0x0004)        /* All incoming buffers full */
-#define SCCE_ENET_TXB  ((ushort)0x0002)        /* A buffer was transmitted */
-#define SCCE_ENET_RXB  ((ushort)0x0001)        /* A buffer was received */
-
-/* SCC Mode Register (PSMR) as used by Ethernet.
-*/
-#define SCC_PSMR_HBC   ((ushort)0x8000)        /* Enable heartbeat */
-#define SCC_PSMR_FC    ((ushort)0x4000)        /* Force collision */
-#define SCC_PSMR_RSH   ((ushort)0x2000)        /* Receive short frames */
-#define SCC_PSMR_IAM   ((ushort)0x1000)        /* Check individual hash */
-#define SCC_PSMR_ENCRC ((ushort)0x0800)        /* Ethernet CRC mode */
-#define SCC_PSMR_PRO   ((ushort)0x0200)        /* Promiscuous mode */
-#define SCC_PSMR_BRO   ((ushort)0x0100)        /* Catch broadcast pkts */
-#define SCC_PSMR_SBT   ((ushort)0x0080)        /* Special backoff timer */
-#define SCC_PSMR_LPB   ((ushort)0x0040)        /* Set Loopback mode */
-#define SCC_PSMR_SIP   ((ushort)0x0020)        /* Sample Input Pins */
-#define SCC_PSMR_LCW   ((ushort)0x0010)        /* Late collision window */
-#define SCC_PSMR_NIB22 ((ushort)0x000a)        /* Start frame search */
-#define SCC_PSMR_FDE   ((ushort)0x0001)        /* Full duplex enable */
-
-/* Buffer descriptor control/status used by Ethernet receive.
- * Common to SCC and FCC.
- */
-#define BD_ENET_RX_EMPTY       ((ushort)0x8000)
-#define BD_ENET_RX_WRAP                ((ushort)0x2000)
-#define BD_ENET_RX_INTR                ((ushort)0x1000)
-#define BD_ENET_RX_LAST                ((ushort)0x0800)
-#define BD_ENET_RX_FIRST       ((ushort)0x0400)
-#define BD_ENET_RX_MISS                ((ushort)0x0100)
-#define BD_ENET_RX_BC          ((ushort)0x0080)        /* FCC Only */
-#define BD_ENET_RX_MC          ((ushort)0x0040)        /* FCC Only */
-#define BD_ENET_RX_LG          ((ushort)0x0020)
-#define BD_ENET_RX_NO          ((ushort)0x0010)
-#define BD_ENET_RX_SH          ((ushort)0x0008)
-#define BD_ENET_RX_CR          ((ushort)0x0004)
-#define BD_ENET_RX_OV          ((ushort)0x0002)
-#define BD_ENET_RX_CL          ((ushort)0x0001)
-#define BD_ENET_RX_STATS       ((ushort)0x01ff)        /* All status bits */
-
-/* Buffer descriptor control/status used by Ethernet transmit.
- * Common to SCC and FCC.
- */
-#define BD_ENET_TX_READY       ((ushort)0x8000)
-#define BD_ENET_TX_PAD         ((ushort)0x4000)
-#define BD_ENET_TX_WRAP                ((ushort)0x2000)
-#define BD_ENET_TX_INTR                ((ushort)0x1000)
-#define BD_ENET_TX_LAST                ((ushort)0x0800)
-#define BD_ENET_TX_TC          ((ushort)0x0400)
-#define BD_ENET_TX_DEF         ((ushort)0x0200)
-#define BD_ENET_TX_HB          ((ushort)0x0100)
-#define BD_ENET_TX_LC          ((ushort)0x0080)
-#define BD_ENET_TX_RL          ((ushort)0x0040)
-#define BD_ENET_TX_RCMASK      ((ushort)0x003c)
-#define BD_ENET_TX_UN          ((ushort)0x0002)
-#define BD_ENET_TX_CSL         ((ushort)0x0001)
-#define BD_ENET_TX_STATS       ((ushort)0x03ff)        /* All status bits */
-
-/* SCC as UART
-*/
-typedef struct scc_uart {
-       sccp_t  scc_genscc;
-       uint    scc_res1;       /* Reserved */
-       uint    scc_res2;       /* Reserved */
-       ushort  scc_maxidl;     /* Maximum idle chars */
-       ushort  scc_idlc;       /* temp idle counter */
-       ushort  scc_brkcr;      /* Break count register */
-       ushort  scc_parec;      /* receive parity error counter */
-       ushort  scc_frmec;      /* receive framing error counter */
-       ushort  scc_nosec;      /* receive noise counter */
-       ushort  scc_brkec;      /* receive break condition counter */
-       ushort  scc_brkln;      /* last received break length */
-       ushort  scc_uaddr1;     /* UART address character 1 */
-       ushort  scc_uaddr2;     /* UART address character 2 */
-       ushort  scc_rtemp;      /* Temp storage */
-       ushort  scc_toseq;      /* Transmit out of sequence char */
-       ushort  scc_char1;      /* control character 1 */
-       ushort  scc_char2;      /* control character 2 */
-       ushort  scc_char3;      /* control character 3 */
-       ushort  scc_char4;      /* control character 4 */
-       ushort  scc_char5;      /* control character 5 */
-       ushort  scc_char6;      /* control character 6 */
-       ushort  scc_char7;      /* control character 7 */
-       ushort  scc_char8;      /* control character 8 */
-       ushort  scc_rccm;       /* receive control character mask */
-       ushort  scc_rccr;       /* receive control character register */
-       ushort  scc_rlbc;       /* receive last break character */
-} scc_uart_t;
-
-/* SCC Event and Mask registers when it is used as a UART.
-*/
-#define UART_SCCM_GLR          ((ushort)0x1000)
-#define UART_SCCM_GLT          ((ushort)0x0800)
-#define UART_SCCM_AB           ((ushort)0x0200)
-#define UART_SCCM_IDL          ((ushort)0x0100)
-#define UART_SCCM_GRA          ((ushort)0x0080)
-#define UART_SCCM_BRKE         ((ushort)0x0040)
-#define UART_SCCM_BRKS         ((ushort)0x0020)
-#define UART_SCCM_CCR          ((ushort)0x0008)
-#define UART_SCCM_BSY          ((ushort)0x0004)
-#define UART_SCCM_TX           ((ushort)0x0002)
-#define UART_SCCM_RX           ((ushort)0x0001)
-
-/* The SCC PMSR when used as a UART.
-*/
-#define SCU_PMSR_FLC           ((ushort)0x8000)
-#define SCU_PMSR_SL            ((ushort)0x4000)
-#define SCU_PMSR_CL            ((ushort)0x3000)
-#define SCU_PMSR_UM            ((ushort)0x0c00)
-#define SCU_PMSR_FRZ           ((ushort)0x0200)
-#define SCU_PMSR_RZS           ((ushort)0x0100)
-#define SCU_PMSR_SYN           ((ushort)0x0080)
-#define SCU_PMSR_DRT           ((ushort)0x0040)
-#define SCU_PMSR_PEN           ((ushort)0x0010)
-#define SCU_PMSR_RPM           ((ushort)0x000c)
-#define SCU_PMSR_REVP          ((ushort)0x0008)
-#define SCU_PMSR_TPM           ((ushort)0x0003)
-#define SCU_PMSR_TEVP          ((ushort)0x0003)
-
-/* CPM Transparent mode SCC.
- */
-typedef struct scc_trans {
-       sccp_t  st_genscc;
-       uint    st_cpres;       /* Preset CRC */
-       uint    st_cmask;       /* Constant mask for CRC */
-} scc_trans_t;
-
-#define BD_SCC_TX_LAST         ((ushort)0x0800)
-
-/* How about some FCCs.....
-*/
-#define FCC_GFMR_DIAG_NORM     ((uint)0x00000000)
-#define FCC_GFMR_DIAG_LE       ((uint)0x40000000)
-#define FCC_GFMR_DIAG_AE       ((uint)0x80000000)
-#define FCC_GFMR_DIAG_ALE      ((uint)0xc0000000)
-#define FCC_GFMR_TCI           ((uint)0x20000000)
-#define FCC_GFMR_TRX           ((uint)0x10000000)
-#define FCC_GFMR_TTX           ((uint)0x08000000)
-#define FCC_GFMR_TTX           ((uint)0x08000000)
-#define FCC_GFMR_CDP           ((uint)0x04000000)
-#define FCC_GFMR_CTSP          ((uint)0x02000000)
-#define FCC_GFMR_CDS           ((uint)0x01000000)
-#define FCC_GFMR_CTSS          ((uint)0x00800000)
-#define FCC_GFMR_SYNL_NONE     ((uint)0x00000000)
-#define FCC_GFMR_SYNL_AUTO     ((uint)0x00004000)
-#define FCC_GFMR_SYNL_8                ((uint)0x00008000)
-#define FCC_GFMR_SYNL_16       ((uint)0x0000c000)
-#define FCC_GFMR_RTSM          ((uint)0x00002000)
-#define FCC_GFMR_RENC_NRZ      ((uint)0x00000000)
-#define FCC_GFMR_RENC_NRZI     ((uint)0x00000800)
-#define FCC_GFMR_REVD          ((uint)0x00000400)
-#define FCC_GFMR_TENC_NRZ      ((uint)0x00000000)
-#define FCC_GFMR_TENC_NRZI     ((uint)0x00000100)
-#define FCC_GFMR_TCRC_16       ((uint)0x00000000)
-#define FCC_GFMR_TCRC_32       ((uint)0x00000080)
-#define FCC_GFMR_ENR           ((uint)0x00000020)
-#define FCC_GFMR_ENT           ((uint)0x00000010)
-#define FCC_GFMR_MODE_ENET     ((uint)0x0000000c)
-#define FCC_GFMR_MODE_ATM      ((uint)0x0000000a)
-#define FCC_GFMR_MODE_HDLC     ((uint)0x00000000)
-
-/* Generic FCC parameter ram.
-*/
-typedef struct fcc_param {
-       ushort  fcc_riptr;      /* Rx Internal temp pointer */
-       ushort  fcc_tiptr;      /* Tx Internal temp pointer */
-       ushort  fcc_res1;
-       ushort  fcc_mrblr;      /* Max receive buffer length, mod 32 bytes */
-       uint    fcc_rstate;     /* Upper byte is Func code, must be set */
-       uint    fcc_rbase;      /* Receive BD base */
-       ushort  fcc_rbdstat;    /* RxBD status */
-       ushort  fcc_rbdlen;     /* RxBD down counter */
-       uint    fcc_rdptr;      /* RxBD internal data pointer */
-       uint    fcc_tstate;     /* Upper byte is Func code, must be set */
-       uint    fcc_tbase;      /* Transmit BD base */
-       ushort  fcc_tbdstat;    /* TxBD status */
-       ushort  fcc_tbdlen;     /* TxBD down counter */
-       uint    fcc_tdptr;      /* TxBD internal data pointer */
-       uint    fcc_rbptr;      /* Rx BD Internal buf pointer */
-       uint    fcc_tbptr;      /* Tx BD Internal buf pointer */
-       uint    fcc_rcrc;       /* Rx temp CRC */
-       uint    fcc_res2;
-       uint    fcc_tcrc;       /* Tx temp CRC */
-} fccp_t;
-
-
-/* Ethernet controller through FCC.
-*/
-typedef struct fcc_enet {
-       fccp_t  fen_genfcc;
-       uint    fen_statbuf;    /* Internal status buffer */
-       uint    fen_camptr;     /* CAM address */
-       uint    fen_cmask;      /* Constant mask for CRC */
-       uint    fen_cpres;      /* Preset CRC */
-       uint    fen_crcec;      /* CRC Error counter */
-       uint    fen_alec;       /* alignment error counter */
-       uint    fen_disfc;      /* discard frame counter */
-       ushort  fen_retlim;     /* Retry limit */
-       ushort  fen_retcnt;     /* Retry counter */
-       ushort  fen_pper;       /* Persistence */
-       ushort  fen_boffcnt;    /* backoff counter */
-       uint    fen_gaddrh;     /* Group address filter, high 32-bits */
-       uint    fen_gaddrl;     /* Group address filter, low 32-bits */
-       ushort  fen_tfcstat;    /* out of sequence TxBD */
-       ushort  fen_tfclen;
-       uint    fen_tfcptr;
-       ushort  fen_mflr;       /* Maximum frame length (1518) */
-       ushort  fen_paddrh;     /* MAC address */
-       ushort  fen_paddrm;
-       ushort  fen_paddrl;
-       ushort  fen_ibdcount;   /* Internal BD counter */
-       ushort  fen_idbstart;   /* Internal BD start pointer */
-       ushort  fen_ibdend;     /* Internal BD end pointer */
-       ushort  fen_txlen;      /* Internal Tx frame length counter */
-       uint    fen_ibdbase[8]; /* Internal use */
-       uint    fen_iaddrh;     /* Individual address filter */
-       uint    fen_iaddrl;
-       ushort  fen_minflr;     /* Minimum frame length (64) */
-       ushort  fen_taddrh;     /* Filter transfer MAC address */
-       ushort  fen_taddrm;
-       ushort  fen_taddrl;
-       ushort  fen_padptr;     /* Pointer to pad byte buffer */
-       ushort  fen_cftype;     /* control frame type */
-       ushort  fen_cfrange;    /* control frame range */
-       ushort  fen_maxb;       /* maximum BD count */
-       ushort  fen_maxd1;      /* Max DMA1 length (1520) */
-       ushort  fen_maxd2;      /* Max DMA2 length (1520) */
-       ushort  fen_maxd;       /* internal max DMA count */
-       ushort  fen_dmacnt;     /* internal DMA counter */
-       uint    fen_octc;       /* Total octect counter */
-       uint    fen_colc;       /* Total collision counter */
-       uint    fen_broc;       /* Total broadcast packet counter */
-       uint    fen_mulc;       /* Total multicast packet count */
-       uint    fen_uspc;       /* Total packets < 64 bytes */
-       uint    fen_frgc;       /* Total packets < 64 bytes with errors */
-       uint    fen_ospc;       /* Total packets > 1518 */
-       uint    fen_jbrc;       /* Total packets > 1518 with errors */
-       uint    fen_p64c;       /* Total packets == 64 bytes */
-       uint    fen_p65c;       /* Total packets 64 < bytes <= 127 */
-       uint    fen_p128c;      /* Total packets 127 < bytes <= 255 */
-       uint    fen_p256c;      /* Total packets 256 < bytes <= 511 */
-       uint    fen_p512c;      /* Total packets 512 < bytes <= 1023 */
-       uint    fen_p1024c;     /* Total packets 1024 < bytes <= 1518 */
-       uint    fen_cambuf;     /* Internal CAM buffer poiner */
-       ushort  fen_rfthr;      /* Received frames threshold */
-       ushort  fen_rfcnt;      /* Received frames count */
-} fcc_enet_t;
-
-/* FCC Event/Mask register as used by Ethernet.
-*/
-#define FCC_ENET_GRA   ((ushort)0x0080)        /* Graceful stop complete */
-#define FCC_ENET_RXC   ((ushort)0x0040)        /* Control Frame Received */
-#define FCC_ENET_TXC   ((ushort)0x0020)        /* Out of seq. Tx sent */
-#define FCC_ENET_TXE   ((ushort)0x0010)        /* Transmit Error */
-#define FCC_ENET_RXF   ((ushort)0x0008)        /* Full frame received */
-#define FCC_ENET_BSY   ((ushort)0x0004)        /* Busy.  Rx Frame dropped */
-#define FCC_ENET_TXB   ((ushort)0x0002)        /* A buffer was transmitted */
-#define FCC_ENET_RXB   ((ushort)0x0001)        /* A buffer was received */
-
-/* FCC Mode Register (FPSMR) as used by Ethernet.
-*/
-#define FCC_PSMR_HBC   ((uint)0x80000000)      /* Enable heartbeat */
-#define FCC_PSMR_FC    ((uint)0x40000000)      /* Force Collision */
-#define FCC_PSMR_SBT   ((uint)0x20000000)      /* Stop backoff timer */
-#define FCC_PSMR_LPB   ((uint)0x10000000)      /* Local protect. 1 = FDX */
-#define FCC_PSMR_LCW   ((uint)0x08000000)      /* Late collision select */
-#define FCC_PSMR_FDE   ((uint)0x04000000)      /* Full Duplex Enable */
-#define FCC_PSMR_MON   ((uint)0x02000000)      /* RMON Enable */
-#define FCC_PSMR_PRO   ((uint)0x00400000)      /* Promiscuous Enable */
-#define FCC_PSMR_FCE   ((uint)0x00200000)      /* Flow Control Enable */
-#define FCC_PSMR_RSH   ((uint)0x00100000)      /* Receive Short Frames */
-#define FCC_PSMR_CAM   ((uint)0x00000400)      /* CAM enable */
-#define FCC_PSMR_BRO   ((uint)0x00000200)      /* Broadcast pkt discard */
-#define FCC_PSMR_ENCRC ((uint)0x00000080)      /* Use 32-bit CRC */
-
-/* IIC parameter RAM.
-*/
-typedef struct iic {
-       ushort  iic_rbase;      /* Rx Buffer descriptor base address */
-       ushort  iic_tbase;      /* Tx Buffer descriptor base address */
-       u_char  iic_rfcr;       /* Rx function code */
-       u_char  iic_tfcr;       /* Tx function code */
-       ushort  iic_mrblr;      /* Max receive buffer length */
-       uint    iic_rstate;     /* Internal */
-       uint    iic_rdp;        /* Internal */
-       ushort  iic_rbptr;      /* Internal */
-       ushort  iic_rbc;        /* Internal */
-       uint    iic_rxtmp;      /* Internal */
-       uint    iic_tstate;     /* Internal */
-       uint    iic_tdp;        /* Internal */
-       ushort  iic_tbptr;      /* Internal */
-       ushort  iic_tbc;        /* Internal */
-       uint    iic_txtmp;      /* Internal */
-} iic_t;
-
-#define BD_IIC_START           ((ushort)0x0400)
-
-#endif /* __CPM_82XX__ */
-#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/cpumask.h b/include/asm-ppc/cpumask.h
deleted file mode 100644 (file)
index 3090108..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_PPC_CPUMASK_H
-#define _ASM_PPC_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_PPC_CPUMASK_H */
index 5e28e41..093022f 100644 (file)
@@ -21,6 +21,7 @@
 #define O_LARGEFILE     0200000
 #define O_DIRECT       0400000 /* direct disk access hint */
 #define O_NOATIME      01000000
+#define O_ATOMICLOOKUP 01000000 /* tux hack */
 
 #define F_DUPFD                0       /* dup */
 #define F_GETFD                1       /* get close_on_exec */
diff --git a/include/asm-ppc/immap_8260.h b/include/asm-ppc/immap_8260.h
deleted file mode 100644 (file)
index cee53ba..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * MPC8260 Internal Memory Map
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- *
- * The Internal Memory Map of the 8260.  I don't know how generic
- * this will be, as I don't have any knowledge of the subsequent
- * parts at this time.  I copied this from the 8xx_immap.h.
- */
-#ifdef __KERNEL__
-#ifndef __IMMAP_82XX__
-#define __IMMAP_82XX__
-
-/* System configuration registers.
-*/
-typedef        struct sys_conf {
-       uint    sc_siumcr;
-       uint    sc_sypcr;
-       char    res1[6];
-       ushort  sc_swsr;
-       char    res2[20];
-       uint    sc_bcr;
-       u_char  sc_ppc_acr;
-       char    res3[3];
-       uint    sc_ppc_alrh;
-       uint    sc_ppc_alrl;
-       u_char  sc_lcl_acr;
-       char    res4[3];
-       uint    sc_lcl_alrh;
-       uint    sc_lcl_alrl;
-       uint    sc_tescr1;
-       uint    sc_tescr2;
-       uint    sc_ltescr1;
-       uint    sc_ltescr2;
-       uint    sc_pdtea;
-       u_char  sc_pdtem;
-       char    res5[3];
-       uint    sc_ldtea;
-       u_char  sc_ldtem;
-       char    res6[163];
-} sysconf8260_t;
-
-
-/* Memory controller registers.
-*/
-typedef struct mem_ctlr {
-       uint    memc_br0;
-       uint    memc_or0;
-       uint    memc_br1;
-       uint    memc_or1;
-       uint    memc_br2;
-       uint    memc_or2;
-       uint    memc_br3;
-       uint    memc_or3;
-       uint    memc_br4;
-       uint    memc_or4;
-       uint    memc_br5;
-       uint    memc_or5;
-       uint    memc_br6;
-       uint    memc_or6;
-       uint    memc_br7;
-       uint    memc_or7;
-       uint    memc_br8;
-       uint    memc_or8;
-       uint    memc_br9;
-       uint    memc_or9;
-       uint    memc_br10;
-       uint    memc_or10;
-       uint    memc_br11;
-       uint    memc_or11;
-       char    res1[8];
-       uint    memc_mar;
-       char    res2[4];
-       uint    memc_mamr;
-       uint    memc_mbmr;
-       uint    memc_mcmr;
-       char    res3[8];
-       ushort  memc_mptpr;
-       char    res4[2];
-       uint    memc_mdr;
-       char    res5[4];
-       uint    memc_psdmr;
-       uint    memc_lsdmr;
-       u_char  memc_purt;
-       char    res6[3];
-       u_char  memc_psrt;
-       char    res7[3];
-       u_char  memc_lurt;
-       char    res8[3];
-       u_char  memc_lsrt;
-       char    res9[3];
-       uint    memc_immr;
-       char    res10[84];
-} memctl8260_t;
-
-/* System Integration Timers.
-*/
-typedef struct sys_int_timers {
-       char    res1[32];
-       ushort  sit_tmcntsc;
-       char    res2[2];
-       uint    sit_tmcnt;
-       char    res3[4];
-       uint    sit_tmcntal;
-       char    res4[16];
-       ushort  sit_piscr;
-       char    res5[2];
-       uint    sit_pitc;
-       uint    sit_pitr;
-       char    res6[94];
-       char    res7[2390];
-} sit8260_t;
-
-#define PISCR_PIRQ_MASK                ((ushort)0xff00)
-#define PISCR_PS               ((ushort)0x0080)
-#define PISCR_PIE              ((ushort)0x0004)
-#define PISCR_PTF              ((ushort)0x0002)
-#define PISCR_PTE              ((ushort)0x0001)
-
-/* Interrupt Controller.
-*/
-typedef struct interrupt_controller {
-       ushort  ic_sicr;
-       char    res1[2];
-       uint    ic_sivec;
-       uint    ic_sipnrh;
-       uint    ic_sipnrl;
-       uint    ic_siprr;
-       uint    ic_scprrh;
-       uint    ic_scprrl;
-       uint    ic_simrh;
-       uint    ic_simrl;
-       uint    ic_siexr;
-       char    res2[88];
-} intctl8260_t;
-
-/* Clocks and Reset.
-*/
-typedef struct clk_and_reset {
-       uint    car_sccr;
-       char    res1[4];
-       uint    car_scmr;
-       char    res2[4];
-       uint    car_rsr;
-       uint    car_rmr;
-       char    res[104];
-} car8260_t;
-
-/* Input/Output Port control/status registers.
- * Names consistent with processor manual, although they are different
- * from the original 8xx names.......
- */
-typedef struct io_port {
-       uint    iop_pdira;
-       uint    iop_ppara;
-       uint    iop_psora;
-       uint    iop_podra;
-       uint    iop_pdata;
-       char    res1[12];
-       uint    iop_pdirb;
-       uint    iop_pparb;
-       uint    iop_psorb;
-       uint    iop_podrb;
-       uint    iop_pdatb;
-       char    res2[12];
-       uint    iop_pdirc;
-       uint    iop_pparc;
-       uint    iop_psorc;
-       uint    iop_podrc;
-       uint    iop_pdatc;
-       char    res3[12];
-       uint    iop_pdird;
-       uint    iop_ppard;
-       uint    iop_psord;
-       uint    iop_podrd;
-       uint    iop_pdatd;
-       char    res4[12];
-} iop8260_t;
-
-/* Communication Processor Module Timers
-*/
-typedef struct cpm_timers {
-       u_char  cpmt_tgcr1;
-       char    res1[3];
-       u_char  cpmt_tgcr2;
-       char    res2[11];
-       ushort  cpmt_tmr1;
-       ushort  cpmt_tmr2;
-       ushort  cpmt_trr1;
-       ushort  cpmt_trr2;
-       ushort  cpmt_tcr1;
-       ushort  cpmt_tcr2;
-       ushort  cpmt_tcn1;
-       ushort  cpmt_tcn2;
-       ushort  cpmt_tmr3;
-       ushort  cpmt_tmr4;
-       ushort  cpmt_trr3;
-       ushort  cpmt_trr4;
-       ushort  cpmt_tcr3;
-       ushort  cpmt_tcr4;
-       ushort  cpmt_tcn3;
-       ushort  cpmt_tcn4;
-       ushort  cpmt_ter1;
-       ushort  cpmt_ter2;
-       ushort  cpmt_ter3;
-       ushort  cpmt_ter4;
-       char    res3[584];
-} cpmtimer8260_t;
-
-/* DMA control/status registers.
-*/
-typedef struct sdma_csr {
-       char    res0[24];
-       u_char  sdma_sdsr;
-       char    res1[3];
-       u_char  sdma_sdmr;
-       char    res2[3];
-       u_char  sdma_idsr1;
-       char    res3[3];
-       u_char  sdma_idmr1;
-       char    res4[3];
-       u_char  sdma_idsr2;
-       char    res5[3];
-       u_char  sdma_idmr2;
-       char    res6[3];
-       u_char  sdma_idsr3;
-       char    res7[3];
-       u_char  sdma_idmr3;
-       char    res8[3];
-       u_char  sdma_idsr4;
-       char    res9[3];
-       u_char  sdma_idmr4;
-       char    res10[707];
-} sdma8260_t;
-
-/* Fast controllers
-*/
-typedef struct fcc {
-       uint    fcc_gfmr;
-       uint    fcc_fpsmr;
-       ushort  fcc_ftodr;
-       char    res1[2];
-       ushort  fcc_fdsr;
-       char    res2[2];
-       ushort  fcc_fcce;
-       char    res3[2];
-       ushort  fcc_fccm;
-       char    res4[2];
-       u_char  fcc_fccs;
-       char    res5[3];
-       u_char  fcc_ftirr_phy[4];
-} fcc_t;
-
-/* I2C
-*/
-typedef struct i2c {
-       u_char  i2c_i2mod;
-       char    res1[3];
-       u_char  i2c_i2add;
-       char    res2[3];
-       u_char  i2c_i2brg;
-       char    res3[3];
-       u_char  i2c_i2com;
-       char    res4[3];
-       u_char  i2c_i2cer;
-       char    res5[3];
-       u_char  i2c_i2cmr;
-       char    res6[331];
-} i2c8260_t;
-
-typedef struct scc {           /* Serial communication channels */
-       uint    scc_gsmrl;
-       uint    scc_gsmrh;
-       ushort  scc_pmsr;
-       char    res1[2];
-       ushort  scc_todr;
-       ushort  scc_dsr;
-       ushort  scc_scce;
-       char    res2[2];
-       ushort  scc_sccm;
-       char    res3;
-       u_char  scc_sccs;
-       char    res4[8];
-} scc_t;
-
-typedef struct smc {           /* Serial management channels */
-       char    res1[2];
-       ushort  smc_smcmr;
-       char    res2[2];
-       u_char  smc_smce;
-       char    res3[3];
-       u_char  smc_smcm;
-       char    res4[5];
-} smc_t;
-
-/* Serial Peripheral Interface.
-*/
-typedef struct spi {
-       ushort  spi_spmode;
-       char    res1[4];
-       u_char  spi_spie;
-       char    res2[3];
-       u_char  spi_spim;
-       char    res3[2];
-       u_char  spi_spcom;
-       char    res4[82];
-} spi_t;
-
-/* CPM Mux.
-*/
-typedef struct cpmux {
-       u_char  cmx_si1cr;
-       char    res1;
-       u_char  cmx_si2cr;
-       char    res2;
-       uint    cmx_fcr;
-       uint    cmx_scr;
-       u_char  cmx_smr;
-       char    res3;
-       ushort  cmx_uar;
-       char    res4[16];
-} cpmux_t;
-
-/* SIRAM control
-*/
-typedef struct siram {
-       ushort  si_amr;
-       ushort  si_bmr;
-       ushort  si_cmr;
-       ushort  si_dmr;
-       u_char  si_gmr;
-       char    res1;
-       u_char  si_cmdr;
-       char    res2;
-       u_char  si_str;
-       char    res3;
-       ushort  si_rsr;
-} siramctl_t;
-
-typedef struct mcc {
-       ushort  mcc_mcce;
-       char    res1[2];
-       ushort  mcc_mccm;
-       char    res2[2];
-       u_char  mcc_mccf;
-       char    res3[7];
-} mcc_t;
-
-typedef struct comm_proc {
-       uint    cp_cpcr;
-       uint    cp_rccr;
-       char    res1[14];
-       ushort  cp_rter;
-       char    res2[2];
-       ushort  cp_rtmr;
-       ushort  cp_rtscr;
-       char    res3[2];
-       uint    cp_rtsr;
-       char    res4[12];
-} cpm8260_t;
-
-/* ...and the whole thing wrapped up....
-*/
-typedef struct immap {
-       /* Some references are into the unique and known dpram spaces,
-        * others are from the generic base.
-        */
-#define im_dprambase   im_dpram1
-       u_char          im_dpram1[16*1024];
-       char            res1[16*1024];
-       u_char          im_dpram2[4*1024];
-       char            res2[8*1024];
-       u_char          im_dpram3[4*1024];
-       char            res3[16*1024];
-
-       sysconf8260_t   im_siu_conf;    /* SIU Configuration */
-       memctl8260_t    im_memctl;      /* Memory Controller */
-       sit8260_t       im_sit;         /* System Integration Timers */
-       intctl8260_t    im_intctl;      /* Interrupt Controller */
-       car8260_t       im_clkrst;      /* Clocks and reset */
-       iop8260_t       im_ioport;      /* IO Port control/status */
-       cpmtimer8260_t  im_cpmtimer;    /* CPM timers */
-       sdma8260_t      im_sdma;        /* SDMA control/status */
-
-       fcc_t           im_fcc[3];      /* Three FCCs */
-
-       char            res4[159];
-
-       /* First set of baud rate generators.
-       */
-       char            res4a[496];
-       uint            im_brgc5;
-       uint            im_brgc6;
-       uint            im_brgc7;
-       uint            im_brgc8;
-
-       char            res5[608];
-
-       i2c8260_t       im_i2c;         /* I2C control/status */
-       cpm8260_t       im_cpm;         /* Communication processor */
-
-       /* Second set of baud rate generators.
-       */
-       uint            im_brgc1;
-       uint            im_brgc2;
-       uint            im_brgc3;
-       uint            im_brgc4;
-
-       scc_t           im_scc[4];      /* Four SCCs */
-       smc_t           im_smc[2];      /* Couple of SMCs */
-       spi_t           im_spi;         /* A SPI */
-       cpmux_t         im_cpmux;       /* CPM clock route mux */
-       siramctl_t      im_siramctl1;   /* First SI RAM Control */
-       mcc_t           im_mcc1;        /* First MCC */
-       siramctl_t      im_siramctl2;   /* Second SI RAM Control */
-       mcc_t           im_mcc2;        /* Second MCC */
-
-       char            res6[1184];
-
-       ushort          im_si1txram[256];
-       char            res7[512];
-       ushort          im_si1rxram[256];
-       char            res8[512];
-       ushort          im_si2txram[256];
-       char            res9[512];
-       ushort          im_si2rxram[256];
-       char            res10[512];
-       char            res11[4096];
-} immap_t;
-
-extern immap_t *immr;
-
-#endif /* __IMMAP_82XX__ */
-#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/mpc52xx.h b/include/asm-ppc/mpc52xx.h
deleted file mode 100644 (file)
index 4fb6e57..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * include/asm-ppc/mpc52xx.h
- * 
- * Prototypes, etc. for the Freescale MPC52xx embedded cpu chips
- * May need to be cleaned as the port goes on ...
- *
- *
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- *
- * Originally written by Dale Farnsworth <dfarnsworth@mvista.com> 
- * for the 2.4 kernel.
- *
- * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
- * Copyright (C) 2003 MontaVista, Software, Inc.
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#ifndef __ASM_MPC52xx_H__
-#define __ASM_MPC52xx_H__
-
-#ifndef __ASSEMBLY__
-#include <asm/ppcboot.h>
-#include <asm/types.h>
-
-struct pt_regs;
-struct ocp_def;
-#endif /* __ASSEMBLY__ */
-
-
-/* ======================================================================== */
-/* Main registers/struct addresses                                          */
-/* ======================================================================== */
-/* Theses are PHYSICAL addresses !                                          */
-/* TODO : There should be no static mapping, but it's not yet the case, so  */
-/*        we require a 1:1 mapping                                          */
-
-#define MPC52xx_MBAR           0xf0000000      /* Phys address */
-#define MPC52xx_MBAR_SIZE      0x00010000
-#define MPC52xx_MBAR_VIRT      0xf0000000      /* Virt address */
-
-#define MPC52xx_MMAP_CTL       (MPC52xx_MBAR + 0x0000)
-#define MPC52xx_CDM            (MPC52xx_MBAR + 0x0200)
-#define MPC52xx_SFTRST         (MPC52xx_MBAR + 0x0220)
-#define MPC52xx_SFTRST_BIT     0x01000000
-#define MPC52xx_INTR           (MPC52xx_MBAR + 0x0500)
-#define MPC52xx_GPTx(x)                (MPC52xx_MBAR + 0x0600 + ((x)<<4))
-#define MPC52xx_RTC            (MPC52xx_MBAR + 0x0800)
-#define MPC52xx_MSCAN1         (MPC52xx_MBAR + 0x0900)
-#define MPC52xx_MSCAN2         (MPC52xx_MBAR + 0x0980)
-#define MPC52xx_GPIO           (MPC52xx_MBAR + 0x0b00)
-#define MPC52xx_PCI            (MPC52xx_MBAR + 0x0d00)
-#define MPC52xx_USB_OHCI       (MPC52xx_MBAR + 0x1000)
-#define MPC52xx_SDMA           (MPC52xx_MBAR + 0x1200)
-#define MPC52xx_XLB            (MPC52xx_MBAR + 0x1f00)
-#define MPC52xx_PSCx(x)                (MPC52xx_MBAR + 0x2000 + ((x)<<9))
-#define MPC52xx_PSC1           (MPC52xx_MBAR + 0x2000)
-#define MPC52xx_PSC2           (MPC52xx_MBAR + 0x2200)
-#define MPC52xx_PSC3           (MPC52xx_MBAR + 0x2400)
-#define MPC52xx_PSC4           (MPC52xx_MBAR + 0x2600)
-#define MPC52xx_PSC5           (MPC52xx_MBAR + 0x2800)
-#define MPC52xx_PSC6           (MPC52xx_MBAR + 0x2C00)
-#define MPC52xx_FEC            (MPC52xx_MBAR + 0x3000)
-#define MPC52xx_ATA            (MPC52xx_MBAR + 0x3a00)
-#define MPC52xx_I2C1           (MPC52xx_MBAR + 0x3d00)
-#define MPC52xx_I2C_MICR       (MPC52xx_MBAR + 0x3d20)
-#define MPC52xx_I2C2           (MPC52xx_MBAR + 0x3d40)
-
-/* SRAM used for SDMA */
-#define MPC52xx_SRAM           (MPC52xx_MBAR + 0x8000)
-#define MPC52xx_SRAM_SIZE      (16*1024)
-#define MPC52xx_SDMA_MAX_TASKS 16
-
-       /* Memory allocation block size */
-#define MPC52xx_SDRAM_UNIT     0x8000          /* 32K byte */
-
-
-/* ======================================================================== */
-/* IRQ mapping                                                              */
-/* ======================================================================== */
-/* Be sure to look at mpc52xx_pic.h if you wish for whatever reason to change
- * this
- */
-
-#define MPC52xx_CRIT_IRQ_NUM   4
-#define MPC52xx_MAIN_IRQ_NUM   17
-#define MPC52xx_SDMA_IRQ_NUM   17
-#define MPC52xx_PERP_IRQ_NUM   23
-
-#define MPC52xx_CRIT_IRQ_BASE  0
-#define MPC52xx_MAIN_IRQ_BASE  (MPC52xx_CRIT_IRQ_BASE + MPC52xx_CRIT_IRQ_NUM)
-#define MPC52xx_SDMA_IRQ_BASE  (MPC52xx_MAIN_IRQ_BASE + MPC52xx_MAIN_IRQ_NUM)
-#define MPC52xx_PERP_IRQ_BASE  (MPC52xx_SDMA_IRQ_BASE + MPC52xx_SDMA_IRQ_NUM)
-
-#define MPC52xx_IRQ0                   (MPC52xx_CRIT_IRQ_BASE + 0)
-#define MPC52xx_SLICE_TIMER_0_IRQ      (MPC52xx_CRIT_IRQ_BASE + 1)
-#define MPC52xx_HI_INT_IRQ             (MPC52xx_CRIT_IRQ_BASE + 2)
-#define MPC52xx_CCS_IRQ                        (MPC52xx_CRIT_IRQ_BASE + 3)
-
-#define MPC52xx_IRQ1                   (MPC52xx_MAIN_IRQ_BASE + 1)
-#define MPC52xx_IRQ2                   (MPC52xx_MAIN_IRQ_BASE + 2)
-#define MPC52xx_IRQ3                   (MPC52xx_MAIN_IRQ_BASE + 3)
-
-#define MPC52xx_SDMA_IRQ               (MPC52xx_PERP_IRQ_BASE + 0)
-#define MPC52xx_PSC1_IRQ               (MPC52xx_PERP_IRQ_BASE + 1)
-#define MPC52xx_PSC2_IRQ               (MPC52xx_PERP_IRQ_BASE + 2)
-#define MPC52xx_PSC3_IRQ               (MPC52xx_PERP_IRQ_BASE + 3)
-#define MPC52xx_PSC6_IRQ               (MPC52xx_PERP_IRQ_BASE + 4)
-#define MPC52xx_IRDA_IRQ               (MPC52xx_PERP_IRQ_BASE + 4)
-#define MPC52xx_FEC_IRQ                        (MPC52xx_PERP_IRQ_BASE + 5)
-#define MPC52xx_USB_IRQ                        (MPC52xx_PERP_IRQ_BASE + 6)
-#define MPC52xx_ATA_IRQ                        (MPC52xx_PERP_IRQ_BASE + 7)
-#define MPC52xx_PCI_CNTRL_IRQ          (MPC52xx_PERP_IRQ_BASE + 8)
-#define MPC52xx_PCI_SCIRX_IRQ          (MPC52xx_PERP_IRQ_BASE + 9)
-#define MPC52xx_PCI_SCITX_IRQ          (MPC52xx_PERP_IRQ_BASE + 10)
-#define MPC52xx_PSC4_IRQ               (MPC52xx_PERP_IRQ_BASE + 11)
-#define MPC52xx_PSC5_IRQ               (MPC52xx_PERP_IRQ_BASE + 12)
-#define MPC52xx_SPI_MODF_IRQ           (MPC52xx_PERP_IRQ_BASE + 13)
-#define MPC52xx_SPI_SPIF_IRQ           (MPC52xx_PERP_IRQ_BASE + 14)
-#define MPC52xx_I2C1_IRQ               (MPC52xx_PERP_IRQ_BASE + 15)
-#define MPC52xx_I2C2_IRQ               (MPC52xx_PERP_IRQ_BASE + 16)
-#define MPC52xx_CAN1_IRQ               (MPC52xx_PERP_IRQ_BASE + 17)
-#define MPC52xx_CAN2_IRQ               (MPC52xx_PERP_IRQ_BASE + 18)
-#define MPC52xx_IR_RX_IRQ              (MPC52xx_PERP_IRQ_BASE + 19)
-#define MPC52xx_IR_TX_IRQ              (MPC52xx_PERP_IRQ_BASE + 20)
-#define MPC52xx_XLB_ARB_IRQ            (MPC52xx_PERP_IRQ_BASE + 21)
-
-
-
-/* ======================================================================== */
-/* Structures mapping of some unit register set                             */
-/* ======================================================================== */
-
-#ifndef __ASSEMBLY__
-
-/* Memory Mapping Control */
-struct mpc52xx_mmap_ctl {
-       volatile u32    mbar;           /* MMAP_CTRL + 0x00 */
-
-       volatile u32    cs0_start;      /* MMAP_CTRL + 0x04 */
-       volatile u32    cs0_stop;       /* MMAP_CTRL + 0x08 */
-       volatile u32    cs1_start;      /* MMAP_CTRL + 0x0c */
-       volatile u32    cs1_stop;       /* MMAP_CTRL + 0x10 */
-       volatile u32    cs2_start;      /* MMAP_CTRL + 0x14 */
-       volatile u32    cs2_stop;       /* MMAP_CTRL + 0x18 */
-       volatile u32    cs3_start;      /* MMAP_CTRL + 0x1c */
-       volatile u32    cs3_stop;       /* MMAP_CTRL + 0x20 */
-       volatile u32    cs4_start;      /* MMAP_CTRL + 0x24 */
-       volatile u32    cs4_stop;       /* MMAP_CTRL + 0x28 */
-       volatile u32    cs5_start;      /* MMAP_CTRL + 0x2c */
-       volatile u32    cs5_stop;       /* MMAP_CTRL + 0x30 */
-
-       volatile u32    sdram0;         /* MMAP_CTRL + 0x34 */
-       volatile u32    sdram1;         /* MMAP_CTRL + 0X38 */
-
-       volatile u32    reserved[4];    /* MMAP_CTRL + 0x3c .. 0x48 */
-
-       volatile u32    boot_start;     /* MMAP_CTRL + 0x4c */
-       volatile u32    boot_stop;      /* MMAP_CTRL + 0x50 */
-       
-       volatile u32    ipbi_ws_ctrl;   /* MMAP_CTRL + 0x54 */
-       
-       volatile u32    cs6_start;      /* MMAP_CTRL + 0x58 */
-       volatile u32    cs6_stop;       /* MMAP_CTRL + 0x5c */
-       volatile u32    cs7_start;      /* MMAP_CTRL + 0x60 */
-       volatile u32    cs7_stop;       /* MMAP_CTRL + 0x60 */
-};
-
-/* Interrupt controller */
-struct mpc52xx_intr {
-       volatile u32    per_mask;       /* INTR + 0x00 */
-       volatile u32    per_pri1;       /* INTR + 0x04 */
-       volatile u32    per_pri2;       /* INTR + 0x08 */
-       volatile u32    per_pri3;       /* INTR + 0x0c */
-       volatile u32    ctrl;           /* INTR + 0x10 */
-       volatile u32    main_mask;      /* INTR + 0x14 */
-       volatile u32    main_pri1;      /* INTR + 0x18 */
-       volatile u32    main_pri2;      /* INTR + 0x1c */
-       volatile u32    reserved1;      /* INTR + 0x20 */
-       volatile u32    enc_status;     /* INTR + 0x24 */
-       volatile u32    crit_status;    /* INTR + 0x28 */
-       volatile u32    main_status;    /* INTR + 0x2c */
-       volatile u32    per_status;     /* INTR + 0x30 */
-       volatile u32    reserved2;      /* INTR + 0x34 */
-       volatile u32    per_error;      /* INTR + 0x38 */
-};
-
-/* SDMA */
-struct mpc52xx_sdma {
-       volatile u32    taskBar;        /* SDMA + 0x00 */
-       volatile u32    currentPointer; /* SDMA + 0x04 */
-       volatile u32    endPointer;     /* SDMA + 0x08 */
-       volatile u32    variablePointer;/* SDMA + 0x0c */
-
-       volatile u8     IntVect1;       /* SDMA + 0x10 */
-       volatile u8     IntVect2;       /* SDMA + 0x11 */
-       volatile u16    PtdCntrl;       /* SDMA + 0x12 */
-
-       volatile u32    IntPend;        /* SDMA + 0x14 */
-       volatile u32    IntMask;        /* SDMA + 0x18 */
-       
-       volatile u16    tcr[16];        /* SDMA + 0x1c .. 0x3a */
-
-       volatile u8     ipr[31];        /* SDMA + 0x3c .. 5b */
-
-       volatile u32    res1;           /* SDMA + 0x5c */
-       volatile u32    task_size0;     /* SDMA + 0x60 */
-       volatile u32    task_size1;     /* SDMA + 0x64 */
-       volatile u32    MDEDebug;       /* SDMA + 0x68 */
-       volatile u32    ADSDebug;       /* SDMA + 0x6c */
-       volatile u32    Value1;         /* SDMA + 0x70 */
-       volatile u32    Value2;         /* SDMA + 0x74 */
-       volatile u32    Control;        /* SDMA + 0x78 */
-       volatile u32    Status;         /* SDMA + 0x7c */
-};
-
-/* GPT */
-struct mpc52xx_gpt {
-       volatile u32    mode;           /* GPTx + 0x00 */
-       volatile u32    count;          /* GPTx + 0x04 */
-       volatile u32    pwm;            /* GPTx + 0x08 */
-       volatile u32    status;         /* GPTx + 0X0c */
-};
-
-/* RTC */
-struct mpc52xx_rtc {
-       volatile u32    time_set;       /* RTC + 0x00 */
-       volatile u32    date_set;       /* RTC + 0x04 */
-       volatile u32    stopwatch;      /* RTC + 0x08 */
-       volatile u32    int_enable;     /* RTC + 0x0c */
-       volatile u32    time;           /* RTC + 0x10 */
-       volatile u32    date;           /* RTC + 0x14 */
-       volatile u32    stopwatch_intr; /* RTC + 0x18 */
-       volatile u32    bus_error;      /* RTC + 0x1c */
-       volatile u32    dividers;       /* RTC + 0x20 */
-};
-
-/* GPIO */
-struct mpc52xx_gpio {
-       volatile u32    port_config;    /* GPIO + 0x00 */
-       volatile u32    simple_gpioe;   /* GPIO + 0x04 */
-       volatile u32    simple_ode;     /* GPIO + 0x08 */
-       volatile u32    simple_ddr;     /* GPIO + 0x0c */
-       volatile u32    simple_dvo;     /* GPIO + 0x10 */
-       volatile u32    simple_ival;    /* GPIO + 0x14 */
-       volatile u8     outo_gpioe;     /* GPIO + 0x18 */
-       volatile u8     reserved1[3];   /* GPIO + 0x19 */
-       volatile u8     outo_dvo;       /* GPIO + 0x1c */
-       volatile u8     reserved2[3];   /* GPIO + 0x1d */
-       volatile u8     sint_gpioe;     /* GPIO + 0x20 */
-       volatile u8     reserved3[3];   /* GPIO + 0x21 */
-       volatile u8     sint_ode;       /* GPIO + 0x24 */
-       volatile u8     reserved4[3];   /* GPIO + 0x25 */
-       volatile u8     sint_ddr;       /* GPIO + 0x28 */
-       volatile u8     reserved5[3];   /* GPIO + 0x29 */
-       volatile u8     sint_dvo;       /* GPIO + 0x2c */
-       volatile u8     reserved6[3];   /* GPIO + 0x2d */
-       volatile u8     sint_inten;     /* GPIO + 0x30 */
-       volatile u8     reserved7[3];   /* GPIO + 0x31 */
-       volatile u16    sint_itype;     /* GPIO + 0x34 */
-       volatile u16    reserved8;      /* GPIO + 0x36 */
-       volatile u8     gpio_control;   /* GPIO + 0x38 */
-       volatile u8     reserved9[3];   /* GPIO + 0x39 */
-       volatile u8     sint_istat;     /* GPIO + 0x3c */
-       volatile u8     sint_ival;      /* GPIO + 0x3d */
-       volatile u8     bus_errs;       /* GPIO + 0x3e */
-       volatile u8     reserved10;     /* GPIO + 0x3f */
-};
-
-#define MPC52xx_GPIO_PSC_CONFIG_UART_WITHOUT_CD        4
-#define MPC52xx_GPIO_PSC_CONFIG_UART_WITH_CD   5
-#define MPC52xx_GPIO_PCI_DIS                   (1<<15)
-
-/* XLB Bus control */
-struct mpc52xx_xlb {
-       volatile u8 reserved[0x40];
-       volatile u32 config;            /* XLB + 0x40 */
-       volatile u32 version;           /* XLB + 0x44 */
-       volatile u32 status;            /* XLB + 0x48 */
-       volatile u32 int_enable;        /* XLB + 0x4c */
-       volatile u32 addr_capture;      /* XLB + 0x50 */
-       volatile u32 bus_sig_capture;   /* XLB + 0x54 */
-       volatile u32 addr_timeout;      /* XLB + 0x58 */
-       volatile u32 data_timeout;      /* XLB + 0x5c */
-       volatile u32 bus_act_timeout;   /* XLB + 0x60 */
-       volatile u32 master_pri_enable; /* XLB + 0x64 */
-       volatile u32 master_priority;   /* XLB + 0x68 */
-       volatile u32 base_address;      /* XLB + 0x6c */
-       volatile u32 snoop_window;      /* XLB + 0x70 */
-};
-
-
-/* Clock Distribution control */
-struct mpc52xx_cdm {
-       volatile u32    jtag_id;        /* MBAR_CDM + 0x00  reg0 read only */
-       volatile u32    rstcfg;         /* MBAR_CDM + 0x04  reg1 read only */
-       volatile u32    breadcrumb;     /* MBAR_CDM + 0x08  reg2 */
-
-       volatile u8     mem_clk_sel;    /* MBAR_CDM + 0x0c  reg3 byte0 */
-       volatile u8     xlb_clk_sel;    /* MBAR_CDM + 0x0d  reg3 byte1 read only */
-       volatile u8     ipb_clk_sel;    /* MBAR_CDM + 0x0e  reg3 byte2 */
-       volatile u8     pci_clk_sel;    /* MBAR_CDM + 0x0f  reg3 byte3 */
-
-       volatile u8     ext_48mhz_en;   /* MBAR_CDM + 0x10  reg4 byte0 */
-       volatile u8     fd_enable;      /* MBAR_CDM + 0x11  reg4 byte1 */
-       volatile u16    fd_counters;    /* MBAR_CDM + 0x12  reg4 byte2,3 */
-
-       volatile u32    clk_enables;    /* MBAR_CDM + 0x14  reg5 */
-
-       volatile u8     osc_disable;    /* MBAR_CDM + 0x18  reg6 byte0 */
-       volatile u8     reserved0[3];   /* MBAR_CDM + 0x19  reg6 byte1,2,3 */
-
-       volatile u8     ccs_sleep_enable;/* MBAR_CDM + 0x1c  reg7 byte0 */
-       volatile u8     osc_sleep_enable;/* MBAR_CDM + 0x1d  reg7 byte1 */
-       volatile u8     reserved1;      /* MBAR_CDM + 0x1e  reg7 byte2 */
-       volatile u8     ccs_qreq_test;  /* MBAR_CDM + 0x1f  reg7 byte3 */
-
-       volatile u8     soft_reset;     /* MBAR_CDM + 0x20  u8 byte0 */
-       volatile u8     no_ckstp;       /* MBAR_CDM + 0x21  u8 byte0 */
-       volatile u8     reserved2[2];   /* MBAR_CDM + 0x22  u8 byte1,2,3 */
-
-       volatile u8     pll_lock;       /* MBAR_CDM + 0x24  reg9 byte0 */
-       volatile u8     pll_looselock;  /* MBAR_CDM + 0x25  reg9 byte1 */
-       volatile u8     pll_sm_lockwin; /* MBAR_CDM + 0x26  reg9 byte2 */
-       volatile u8     reserved3;      /* MBAR_CDM + 0x27  reg9 byte3 */
-
-       volatile u16    reserved4;      /* MBAR_CDM + 0x28  reg10 byte0,1 */
-       volatile u16    mclken_div_psc1;/* MBAR_CDM + 0x2a  reg10 byte2,3 */
-    
-       volatile u16    reserved5;      /* MBAR_CDM + 0x2c  reg11 byte0,1 */
-       volatile u16    mclken_div_psc2;/* MBAR_CDM + 0x2e  reg11 byte2,3 */
-               
-       volatile u16    reserved6;      /* MBAR_CDM + 0x30  reg12 byte0,1 */
-       volatile u16    mclken_div_psc3;/* MBAR_CDM + 0x32  reg12 byte2,3 */
-    
-       volatile u16    reserved7;      /* MBAR_CDM + 0x34  reg13 byte0,1 */
-       volatile u16    mclken_div_psc6;/* MBAR_CDM + 0x36  reg13 byte2,3 */
-};
-
-#endif /* __ASSEMBLY__ */
-
-
-/* ========================================================================= */
-/* Prototypes for MPC52xx syslib                                             */
-/* ========================================================================= */
-
-#ifndef __ASSEMBLY__
-
-extern void mpc52xx_init_irq(void);
-extern int mpc52xx_get_irq(struct pt_regs *regs);
-
-extern unsigned long mpc52xx_find_end_of_memory(void);
-extern void mpc52xx_set_bat(void);
-extern void mpc52xx_map_io(void);
-extern void mpc52xx_restart(char *cmd);
-extern void mpc52xx_halt(void);
-extern void mpc52xx_power_off(void);
-extern void mpc52xx_progress(char *s, unsigned short hex);
-extern void mpc52xx_calibrate_decr(void);
-extern void mpc52xx_add_board_devices(struct ocp_def board_ocp[]);
-
-#endif /* __ASSEMBLY__ */
-
-
-/* ========================================================================= */
-/* Platform configuration                                                    */
-/* ========================================================================= */
-
-/* The U-Boot platform information struct */
-extern bd_t __res;
-
-/* Platform options */
-#if defined(CONFIG_LITE5200)
-#include <platforms/lite5200.h>
-#endif
-
-
-#endif /* __ASM_MPC52xx_H__ */
diff --git a/include/asm-ppc/mpc52xx_psc.h b/include/asm-ppc/mpc52xx_psc.h
deleted file mode 100644 (file)
index 483102e..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * include/asm-ppc/mpc52xx_psc.h
- * 
- * Definitions of consts/structs to drive the Freescale MPC52xx OnChip
- * PSCs. Theses are shared between multiple drivers since a PSC can be
- * UART, AC97, IR, I2S, ... So this header is in asm-ppc.
- *
- *
- * Maintainer : Sylvain Munaut <tnt@246tNt.com>
- *
- * Based/Extracted from some header of the 2.4 originally written by 
- * Dale Farnsworth <dfarnsworth@mvista.com> 
- *
- * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
- * Copyright (C) 2003 MontaVista, Software, Inc.
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#ifndef __MPC52xx_PSC_H__
-#define __MPC52xx_PSC_H__
-
-#include <asm/types.h>
-
-/* Max number of PSCs */
-#define MPC52xx_PSC_MAXNUM     6
-
-/* Programmable Serial Controller (PSC) status register bits */
-#define MPC52xx_PSC_SR_CDE     0x0080
-#define MPC52xx_PSC_SR_RXRDY   0x0100
-#define MPC52xx_PSC_SR_RXFULL  0x0200
-#define MPC52xx_PSC_SR_TXRDY   0x0400
-#define MPC52xx_PSC_SR_TXEMP   0x0800
-#define MPC52xx_PSC_SR_OE      0x1000
-#define MPC52xx_PSC_SR_PE      0x2000
-#define MPC52xx_PSC_SR_FE      0x4000
-#define MPC52xx_PSC_SR_RB      0x8000
-
-/* PSC Command values */
-#define MPC52xx_PSC_RX_ENABLE          0x0001
-#define MPC52xx_PSC_RX_DISABLE         0x0002
-#define MPC52xx_PSC_TX_ENABLE          0x0004
-#define MPC52xx_PSC_TX_DISABLE         0x0008
-#define MPC52xx_PSC_SEL_MODE_REG_1     0x0010
-#define MPC52xx_PSC_RST_RX             0x0020
-#define MPC52xx_PSC_RST_TX             0x0030
-#define MPC52xx_PSC_RST_ERR_STAT       0x0040
-#define MPC52xx_PSC_RST_BRK_CHG_INT    0x0050
-#define MPC52xx_PSC_START_BRK          0x0060
-#define MPC52xx_PSC_STOP_BRK           0x0070
-
-/* PSC TxRx FIFO status bits */
-#define MPC52xx_PSC_RXTX_FIFO_ERR      0x0040
-#define MPC52xx_PSC_RXTX_FIFO_UF       0x0020
-#define MPC52xx_PSC_RXTX_FIFO_OF       0x0010
-#define MPC52xx_PSC_RXTX_FIFO_FR       0x0008
-#define MPC52xx_PSC_RXTX_FIFO_FULL     0x0004
-#define MPC52xx_PSC_RXTX_FIFO_ALARM    0x0002
-#define MPC52xx_PSC_RXTX_FIFO_EMPTY    0x0001
-
-/* PSC interrupt mask bits */
-#define MPC52xx_PSC_IMR_TXRDY          0x0100
-#define MPC52xx_PSC_IMR_RXRDY          0x0200
-#define MPC52xx_PSC_IMR_DB             0x0400
-#define MPC52xx_PSC_IMR_IPC            0x8000
-
-/* PSC input port change bit */
-#define MPC52xx_PSC_CTS                        0x01
-#define MPC52xx_PSC_DCD                        0x02
-#define MPC52xx_PSC_D_CTS              0x10
-#define MPC52xx_PSC_D_DCD              0x20
-
-/* PSC mode fields */
-#define MPC52xx_PSC_MODE_5_BITS                        0x00
-#define MPC52xx_PSC_MODE_6_BITS                        0x01
-#define MPC52xx_PSC_MODE_7_BITS                        0x02
-#define MPC52xx_PSC_MODE_8_BITS                        0x03
-#define MPC52xx_PSC_MODE_BITS_MASK             0x03
-#define MPC52xx_PSC_MODE_PAREVEN               0x00
-#define MPC52xx_PSC_MODE_PARODD                        0x04
-#define MPC52xx_PSC_MODE_PARFORCE              0x08
-#define MPC52xx_PSC_MODE_PARNONE               0x10
-#define MPC52xx_PSC_MODE_ERR                   0x20
-#define MPC52xx_PSC_MODE_FFULL                 0x40
-#define MPC52xx_PSC_MODE_RXRTS                 0x80
-
-#define MPC52xx_PSC_MODE_ONE_STOP_5_BITS       0x00
-#define MPC52xx_PSC_MODE_ONE_STOP              0x07
-#define MPC52xx_PSC_MODE_TWO_STOP              0x0f
-
-#define MPC52xx_PSC_RFNUM_MASK 0x01ff
-
-
-/* Structure of the hardware registers */
-struct mpc52xx_psc {
-       volatile u8             mode;           /* PSC + 0x00 */
-       volatile u8             reserved0[3];
-       union {                                 /* PSC + 0x04 */
-               volatile u16    status;
-               volatile u16    clock_select;
-       } sr_csr;
-#define mpc52xx_psc_status     sr_csr.status
-#define mpc52xx_psc_clock_select       sr_csr.clock_select
-       volatile u16            reserved1;
-       volatile u8             command;        /* PSC + 0x08 */
-volatile u8            reserved2[3];
-       union {                                 /* PSC + 0x0c */
-               volatile u8     buffer_8;
-               volatile u16    buffer_16;
-               volatile u32    buffer_32;
-       } buffer;
-#define mpc52xx_psc_buffer_8   buffer.buffer_8
-#define mpc52xx_psc_buffer_16  buffer.buffer_16
-#define mpc52xx_psc_buffer_32  buffer.buffer_32
-       union {                                 /* PSC + 0x10 */
-               volatile u8     ipcr;
-               volatile u8     acr;
-       } ipcr_acr;
-#define mpc52xx_psc_ipcr       ipcr_acr.ipcr
-#define mpc52xx_psc_acr                ipcr_acr.acr
-       volatile u8             reserved3[3];
-       union {                                 /* PSC + 0x14 */
-               volatile u16    isr;
-               volatile u16    imr;
-       } isr_imr;
-#define mpc52xx_psc_isr                isr_imr.isr
-#define mpc52xx_psc_imr                isr_imr.imr
-       volatile u16            reserved4;
-       volatile u8             ctur;           /* PSC + 0x18 */
-       volatile u8             reserved5[3];
-       volatile u8             ctlr;           /* PSC + 0x1c */
-       volatile u8             reserved6[3];
-       volatile u16            ccr;            /* PSC + 0x20 */
-       volatile u8             reserved7[14];
-       volatile u8             ivr;            /* PSC + 0x30 */
-       volatile u8             reserved8[3];
-       volatile u8             ip;             /* PSC + 0x34 */
-       volatile u8             reserved9[3];
-       volatile u8             op1;            /* PSC + 0x38 */
-       volatile u8             reserved10[3];
-       volatile u8             op0;            /* PSC + 0x3c */
-       volatile u8             reserved11[3];
-       volatile u32            sicr;           /* PSC + 0x40 */
-       volatile u8             ircr1;          /* PSC + 0x44 */
-       volatile u8             reserved13[3];
-       volatile u8             ircr2;          /* PSC + 0x44 */
-       volatile u8             reserved14[3];
-       volatile u8             irsdr;          /* PSC + 0x4c */
-       volatile u8             reserved15[3];
-       volatile u8             irmdr;          /* PSC + 0x50 */
-       volatile u8             reserved16[3];
-       volatile u8             irfdr;          /* PSC + 0x54 */
-       volatile u8             reserved17[3];
-       volatile u16            rfnum;          /* PSC + 0x58 */
-       volatile u16            reserved18;
-       volatile u16            tfnum;          /* PSC + 0x5c */
-       volatile u16            reserved19;
-       volatile u32            rfdata;         /* PSC + 0x60 */
-       volatile u16            rfstat;         /* PSC + 0x64 */
-       volatile u16            reserved20;
-       volatile u8             rfcntl;         /* PSC + 0x68 */
-       volatile u8             reserved21[5];
-       volatile u16            rfalarm;        /* PSC + 0x6e */
-       volatile u16            reserved22;
-       volatile u16            rfrptr;         /* PSC + 0x72 */
-       volatile u16            reserved23;
-       volatile u16            rfwptr;         /* PSC + 0x76 */
-       volatile u16            reserved24;
-       volatile u16            rflrfptr;       /* PSC + 0x7a */
-       volatile u16            reserved25;
-       volatile u16            rflwfptr;       /* PSC + 0x7e */
-       volatile u32            tfdata;         /* PSC + 0x80 */
-       volatile u16            tfstat;         /* PSC + 0x84 */
-       volatile u16            reserved26;
-       volatile u8             tfcntl;         /* PSC + 0x88 */
-       volatile u8             reserved27[5];
-       volatile u16            tfalarm;        /* PSC + 0x8e */
-       volatile u16            reserved28;
-       volatile u16            tfrptr;         /* PSC + 0x92 */
-       volatile u16            reserved29;
-       volatile u16            tfwptr;         /* PSC + 0x96 */
-       volatile u16            reserved30;
-       volatile u16            tflrfptr;       /* PSC + 0x9a */
-       volatile u16            reserved31;
-       volatile u16            tflwfptr;       /* PSC + 0x9e */
-};
-
-
-#endif  /* __MPC52xx_PSC_H__ */
diff --git a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
deleted file mode 100644 (file)
index d3be235..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * include/asm-ppc/mpc85xx.h
- *
- * MPC85xx definitions
- *
- * Maintainer: Kumar Gala <kumar.gala@freescale.com>
- *
- * Copyright 2004 Freescale Semiconductor, Inc
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_MPC85xx_H__
-#define __ASM_MPC85xx_H__
-
-#include <linux/config.h>
-#include <asm/mmu.h>
-
-#ifdef CONFIG_85xx
-
-#ifdef CONFIG_MPC8540_ADS
-#include <platforms/85xx/mpc8540_ads.h>
-#endif
-#ifdef CONFIG_MPC8555_CDS
-#include <platforms/85xx/mpc8555_cds.h>
-#endif
-#ifdef CONFIG_MPC8560_ADS
-#include <platforms/85xx/mpc8560_ads.h>
-#endif
-#ifdef CONFIG_SBC8560
-#include <platforms/85xx/sbc8560.h>
-#endif
-
-#define _IO_BASE        isa_io_base
-#define _ISA_MEM_BASE   isa_mem_base
-#ifdef CONFIG_PCI
-#define PCI_DRAM_OFFSET pci_dram_offset
-#else
-#define PCI_DRAM_OFFSET 0
-#endif
-
-/*
- * The "residual" board information structure the boot loader passes
- * into the kernel.
- */
-extern unsigned char __res[];
-
-/* Internal IRQs on MPC85xx OpenPIC */
-/* Not all of these exist on all MPC85xx implementations */
-
-#ifndef MPC85xx_OPENPIC_IRQ_OFFSET
-#define MPC85xx_OPENPIC_IRQ_OFFSET     64
-#endif
-
-/* The 32 internal sources */
-#define MPC85xx_IRQ_L2CACHE    ( 0 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_ECM                ( 1 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_DDR                ( 2 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_LBIU       ( 3 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_DMA0       ( 4 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_DMA1       ( 5 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_DMA2       ( 6 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_DMA3       ( 7 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_PCI1       ( 8 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_PCI2       ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_RIO_ERROR  ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_RIO_BELL   (10 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_RIO_TX     (11 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_RIO_RX     (12 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_TSEC1_TX   (13 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_TSEC1_RX   (14 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_TSEC1_ERROR        (18 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_TSEC2_TX   (19 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_TSEC2_RX   (20 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_TSEC2_ERROR        (24 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_FEC                (25 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_DUART      (26 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_IIC1       (27 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_PERFMON    (28 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_CPM                (30 + MPC85xx_OPENPIC_IRQ_OFFSET)
-
-/* The 12 external interrupt lines */
-#define MPC85xx_IRQ_EXT0        (32 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT1        (33 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT2        (34 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT3        (35 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT4        (36 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT5        (37 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT6        (38 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT7        (39 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT8        (40 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT9        (41 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT10       (42 + MPC85xx_OPENPIC_IRQ_OFFSET)
-#define MPC85xx_IRQ_EXT11       (43 + MPC85xx_OPENPIC_IRQ_OFFSET)
-
-/* Offset from CCSRBAR */
-#define MPC85xx_CPM_OFFSET     (0x80000)
-#define MPC85xx_CPM_SIZE       (0x40000)
-#define MPC85xx_DMA_OFFSET     (0x21000)
-#define MPC85xx_DMA_SIZE       (0x01000)
-#define MPC85xx_ENET1_OFFSET   (0x24000)
-#define MPC85xx_ENET1_SIZE     (0x01000)
-#define MPC85xx_ENET2_OFFSET   (0x25000)
-#define MPC85xx_ENET2_SIZE     (0x01000)
-#define MPC85xx_ENET3_OFFSET   (0x26000)
-#define MPC85xx_ENET3_SIZE     (0x01000)
-#define MPC85xx_GUTS_OFFSET    (0xe0000)
-#define MPC85xx_GUTS_SIZE      (0x01000)
-#define MPC85xx_IIC1_OFFSET    (0x03000)
-#define MPC85xx_IIC1_SIZE      (0x01000)
-#define MPC85xx_OPENPIC_OFFSET (0x40000)
-#define MPC85xx_OPENPIC_SIZE   (0x40000)
-#define MPC85xx_PCI1_OFFSET    (0x08000)
-#define MPC85xx_PCI1_SIZE      (0x01000)
-#define MPC85xx_PCI2_OFFSET    (0x09000)
-#define MPC85xx_PCI2_SIZE      (0x01000)
-#define MPC85xx_PERFMON_OFFSET (0xe1000)
-#define MPC85xx_PERFMON_SIZE   (0x01000)
-#define MPC85xx_UART0_OFFSET   (0x04500)
-#define MPC85xx_UART0_SIZE     (0x00100)
-#define MPC85xx_UART1_OFFSET   (0x04600)
-#define MPC85xx_UART1_SIZE     (0x00100)
-
-#define MPC85xx_CCSRBAR_SIZE   (1024*1024)
-
-/* Let modules/drivers get at CCSRBAR */
-extern phys_addr_t get_ccsrbar(void);
-
-#ifdef MODULE
-#define CCSRBAR get_ccsrbar()
-#else
-#define CCSRBAR BOARD_CCSRBAR
-#endif
-
-#endif /* CONFIG_85xx */
-#endif /* __ASM_MPC85xx_H__ */
-#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/mv64x60.h b/include/asm-ppc/mv64x60.h
deleted file mode 100644 (file)
index 0aa5482..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * include/asm-ppc/mv64x60.h
- * 
- * Prototypes, etc. for the Marvell/Galileo MV64x60 host bridge routines.
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2001-2002 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#ifndef __ASMPPC_MV64x60_H
-#define __ASMPPC_MV64x60_H
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/config.h>
-
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mv64x60_defs.h>
-
-extern u8      mv64x60_pci_exclude_bridge;
-
-extern spinlock_t mv64x60_lock;
-extern spinlock_t mv64x60_rmw_lock;
-
-#ifndef        TRUE
-#define        TRUE    1
-#endif
-
-#ifndef        FALSE
-#define        FALSE   0
-#endif
-
-/* 32-bit Window table entry defines */
-#define        MV64x60_CPU2MEM_0_WIN                   0
-#define        MV64x60_CPU2MEM_1_WIN                   1
-#define        MV64x60_CPU2MEM_2_WIN                   2
-#define        MV64x60_CPU2MEM_3_WIN                   3
-#define        MV64x60_CPU2DEV_0_WIN                   4
-#define        MV64x60_CPU2DEV_1_WIN                   5
-#define        MV64x60_CPU2DEV_2_WIN                   6
-#define        MV64x60_CPU2DEV_3_WIN                   7
-#define        MV64x60_CPU2BOOT_WIN                    8
-#define        MV64x60_CPU2PCI0_IO_WIN                 9
-#define        MV64x60_CPU2PCI0_MEM_0_WIN              10
-#define        MV64x60_CPU2PCI0_MEM_1_WIN              11
-#define        MV64x60_CPU2PCI0_MEM_2_WIN              12
-#define        MV64x60_CPU2PCI0_MEM_3_WIN              13
-#define        MV64x60_CPU2PCI1_IO_WIN                 14
-#define        MV64x60_CPU2PCI1_MEM_0_WIN              15
-#define        MV64x60_CPU2PCI1_MEM_1_WIN              16
-#define        MV64x60_CPU2PCI1_MEM_2_WIN              17
-#define        MV64x60_CPU2PCI1_MEM_3_WIN              18
-#define        MV64x60_CPU2SRAM_WIN                    19
-#define        MV64x60_CPU2PCI0_IO_REMAP_WIN           20
-#define        MV64x60_CPU2PCI1_IO_REMAP_WIN           21
-#define        MV64x60_CPU_PROT_0_WIN                  22
-#define        MV64x60_CPU_PROT_1_WIN                  23
-#define        MV64x60_CPU_PROT_2_WIN                  24
-#define        MV64x60_CPU_PROT_3_WIN                  25
-#define        MV64x60_CPU_SNOOP_0_WIN                 26
-#define        MV64x60_CPU_SNOOP_1_WIN                 27
-#define        MV64x60_CPU_SNOOP_2_WIN                 28
-#define        MV64x60_CPU_SNOOP_3_WIN                 29
-#define        MV64x60_PCI02MEM_REMAP_0_WIN            30
-#define        MV64x60_PCI02MEM_REMAP_1_WIN            31
-#define        MV64x60_PCI02MEM_REMAP_2_WIN            32
-#define        MV64x60_PCI02MEM_REMAP_3_WIN            33
-#define        MV64x60_PCI12MEM_REMAP_0_WIN            34
-#define        MV64x60_PCI12MEM_REMAP_1_WIN            35
-#define        MV64x60_PCI12MEM_REMAP_2_WIN            36
-#define        MV64x60_PCI12MEM_REMAP_3_WIN            37
-
-#define        MV64x60_32BIT_WIN_COUNT                 38
-
-/* 64-bit Window table entry defines */
-#define        MV64x60_CPU2PCI0_MEM_0_REMAP_WIN        0
-#define        MV64x60_CPU2PCI0_MEM_1_REMAP_WIN        1
-#define        MV64x60_CPU2PCI0_MEM_2_REMAP_WIN        2
-#define        MV64x60_CPU2PCI0_MEM_3_REMAP_WIN        3
-#define        MV64x60_CPU2PCI1_MEM_0_REMAP_WIN        4
-#define        MV64x60_CPU2PCI1_MEM_1_REMAP_WIN        5
-#define        MV64x60_CPU2PCI1_MEM_2_REMAP_WIN        6
-#define        MV64x60_CPU2PCI1_MEM_3_REMAP_WIN        7
-#define        MV64x60_PCI02MEM_ACC_CNTL_0_WIN         8
-#define        MV64x60_PCI02MEM_ACC_CNTL_1_WIN         9
-#define        MV64x60_PCI02MEM_ACC_CNTL_2_WIN         10
-#define        MV64x60_PCI02MEM_ACC_CNTL_3_WIN         11
-#define        MV64x60_PCI12MEM_ACC_CNTL_0_WIN         12
-#define        MV64x60_PCI12MEM_ACC_CNTL_1_WIN         13
-#define        MV64x60_PCI12MEM_ACC_CNTL_2_WIN         14
-#define        MV64x60_PCI12MEM_ACC_CNTL_3_WIN         15
-#define        MV64x60_PCI02MEM_SNOOP_0_WIN            16
-#define        MV64x60_PCI02MEM_SNOOP_1_WIN            17
-#define        MV64x60_PCI02MEM_SNOOP_2_WIN            18
-#define        MV64x60_PCI02MEM_SNOOP_3_WIN            19
-#define        MV64x60_PCI12MEM_SNOOP_0_WIN            20
-#define        MV64x60_PCI12MEM_SNOOP_1_WIN            21
-#define        MV64x60_PCI12MEM_SNOOP_2_WIN            22
-#define        MV64x60_PCI12MEM_SNOOP_3_WIN            23
-
-#define        MV64x60_64BIT_WIN_COUNT                 24
-
-
-/*
- * Define a structure that's used to pass in config information to the
- * core routines.
- */
-typedef struct {
-       u32     cpu_base;
-       u32     pci_base_hi;
-       u32     pci_base_lo;
-       u32     size;
-       u32     swap;
-} mv64x60_pci_window_t;
-
-typedef        struct {
-       u8      enable_bus;     /* allow access to this PCI bus? */
-       u8      enumerate_bus;  /* enumerate devices on this bus? */
-
-       mv64x60_pci_window_t    pci_io;
-       mv64x60_pci_window_t    pci_mem[3];
-
-       u32     acc_cntl_options[MV64x60_CPU2MEM_WINDOWS];
-       u32     snoop_options[MV64x60_CPU2MEM_WINDOWS];
-       u16     pci_cmd_bits;
-       u16     latency_timer;
-} mv64x60_pci_info_t;
-
-typedef struct {
-       u32     phys_reg_base;
-
-       u32     window_preserve_mask_32;
-       u32     window_preserve_mask_64;
-
-       u32     base_irq;       /* Starting irq # for this intr ctlr */
-       int     ((*map_irq)(struct pci_dev *, unsigned char, unsigned char));
-
-       u32     cpu_prot_options[MV64x60_CPU2MEM_WINDOWS];
-       u32     cpu_snoop_options[MV64x60_CPU2MEM_WINDOWS];
-
-       mv64x60_pci_info_t      pci_0;
-       mv64x60_pci_info_t      pci_1;
-} mv64x60_setup_info_t;
-
-/*
- * Define the 'handle' struct that will be passed between the 64x60 core
- * code and the platform-specific code that will use it.  The handle
- * will contain pointers to chip-specific routines & information.
- */
-typedef struct {
-       u32     base_reg;
-       u32     size_reg;
-       u8      base_bits;
-       u8      size_bits;
-       u32     (*get_from_field)(u32 val, u32 num_bits);
-       u32     (*map_to_field)(u32 val, u32 num_bits);
-       u32     extra;
-} mv64x60_32bit_window_t;
-
-typedef struct {
-       u32     base_hi_reg;
-       u32     base_lo_reg;
-       u32     size_reg;
-       u8      base_lo_bits;
-       u8      size_bits;
-       u32     (*get_from_field)(u32 val, u32 num_bits);
-       u32     (*map_to_field)(u32 val, u32 num_bits);
-       u32     extra;
-} mv64x60_64bit_window_t;
-
-typedef        struct mv64x60_handle   mv64x60_handle_t;
-
-typedef struct {
-       u32     (*translate_size)(u32 base, u32 size, u32 num_bits);
-       u32     (*untranslate_size)(u32 base, u32 size, u32 num_bits);
-       void    (*set_pci2mem_window)(struct pci_controller *hose, u32 window,
-                       u32 base);
-       u32     (*is_enabled_32bit)(mv64x60_handle_t *bh, u32 window);
-       void    (*enable_window_32bit)(mv64x60_handle_t *bh, u32 window);
-       void    (*disable_window_32bit)(mv64x60_handle_t *bh, u32 window);
-       void    (*enable_window_64bit)(mv64x60_handle_t *bh, u32 window);
-       void    (*disable_window_64bit)(mv64x60_handle_t *bh, u32 window);
-       void    (*disable_all_windows)(mv64x60_handle_t *bh,
-                                      mv64x60_setup_info_t *si);
-       void    (*chip_specific_init)(mv64x60_handle_t *bh,
-                                     mv64x60_setup_info_t *si);
-
-       mv64x60_32bit_window_t  *window_tab_32bit;
-       mv64x60_64bit_window_t  *window_tab_64bit;
-} mv64x60_chip_info_t;
-
-struct mv64x60_handle {
-       u32     type;           /* type of bridge */
-       u32     v_base;         /* virtual base addr of bridge regs */
-       u32     p_base;         /* physical base addr of bridge regs */
-       u32     base_irq;       /* Base irq # for intrs on this intr cltr */
-
-       u32     io_base_a;      /* vaddr of pci 0's I/O space */
-       u32     io_base_b;      /* vaddr of pci 1's I/O space */
-
-       struct pci_controller   *hose_a;
-       struct pci_controller   *hose_b;
-
-       mv64x60_chip_info_t     *ci;    /* chip/bridge-specific info */
-};
-
-
-/* Define I/O routines for accessing registers on the 64x60 bridge. */
-extern inline void
-mv64x60_write(mv64x60_handle_t *bh, u32 offset, u32 val) {
-       out_le32((volatile u32 *)(bh->v_base + offset), val);
-}
-
-extern inline u32
-mv64x60_read(mv64x60_handle_t *bh, u32 offset) {
-       return in_le32((volatile u32 *)(bh->v_base + offset));
-}
-
-extern inline void
-mv64x60_modify(mv64x60_handle_t *bh, u32 offs, u32 data, u32 mask)
-{
-       uint32_t reg;
-       unsigned long flags;
-
-       spin_lock_irqsave(&mv64x60_rmw_lock, flags);
-       reg = mv64x60_read(bh, offs) & (~mask); /* zero any bits we care about*/
-       reg |= data & mask; /* set bits from the data */
-       mv64x60_write(bh, offs, reg);
-       spin_unlock_irqrestore(&mv64x60_rmw_lock, flags);
-}
-
-#define        mv64x60_set_bits(bh, offs, bits) mv64x60_modify(bh, offs, ~0, bits) 
-#define        mv64x60_clr_bits(bh, offs, bits) mv64x60_modify(bh, offs, 0, bits)
-
-
-/* Externally visible function prototypes */
-int mv64x60_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-u32 mv64x60_get_mem_size(u32 bridge_base, u32 chip_type);
-void mv64x60_get_32bit_window(mv64x60_handle_t *bh, u32 window,
-                                       u32 *base, u32 *size);
-void mv64x60_set_32bit_window(mv64x60_handle_t *bh, u32 window, u32 base,
-                                       u32 size, u32 other_bits);
-void mv64x60_get_64bit_window(mv64x60_handle_t *bh, u32 window, u32 *base_hi,
-                                       u32 *base_lo, u32 *size);
-void mv64x60_set_64bit_window(mv64x60_handle_t *bh, u32 window, u32 base_hi,
-                                       u32 base_lo, u32 size, u32 other_bits);
-
-
-void gt64260_init_irq(void);
-int gt64260_get_irq(struct pt_regs *regs);
-
-/*
- * OCP Related Definitions
- */
-typedef struct {
-       u8      mirror_regs;
-       u8      cache_mgmt;
-       u8      max_idle;
-       int     default_baud;
-       int     default_bits;
-       int     default_parity;
-       int     default_flow;
-       u32     chr_1_val;
-       u32     chr_2_val;
-       u32     chr_10_val;
-       u32     mpcr_val;
-       u32     mrr_val;
-       u32     rcrr_val;
-       u32     tcrr_val;
-       u32     intr_mask_val;
-       u32     bcr_val;
-       u32     sdma_irq;
-       u8      brg_can_tune;
-       u8      brg_clk_src;
-       u32     brg_clk_freq;
-} mv64x60_ocp_mpsc_data_t;
-
-#define MV64x60_OCP_SYSFS_MPSC_DATA()                                  \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, mirror_regs)    \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, cache_mgmt)     \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, max_idle)       \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, default_baud)   \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, default_bits)   \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%c\n", mpsc, default_parity) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%c\n", mpsc, default_flow)   \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, chr_1_val)    \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, chr_2_val)    \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, chr_10_val)   \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, mpcr_val)     \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, mrr_val)      \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, rcrr_val)     \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, tcrr_val)     \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, intr_mask_val)        \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, bcr_val)      \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, sdma_irq)       \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, brg_can_tune)   \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, brg_clk_src)    \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, brg_clk_freq)   \
-                                                                       \
-void                                                                   \
-mv64x60_ocp_show_mpsc(struct device *dev)                              \
-{                                                                      \
-       device_create_file(dev, &dev_attr_mpsc_mirror_regs);            \
-       device_create_file(dev, &dev_attr_mpsc_cache_mgmt);             \
-       device_create_file(dev, &dev_attr_mpsc_max_idle);               \
-       device_create_file(dev, &dev_attr_mpsc_default_baud);           \
-       device_create_file(dev, &dev_attr_mpsc_default_bits);           \
-       device_create_file(dev, &dev_attr_mpsc_default_parity);         \
-       device_create_file(dev, &dev_attr_mpsc_default_flow);           \
-       device_create_file(dev, &dev_attr_mpsc_chr_1_val);              \
-       device_create_file(dev, &dev_attr_mpsc_chr_2_val);              \
-       device_create_file(dev, &dev_attr_mpsc_chr_10_val);             \
-       device_create_file(dev, &dev_attr_mpsc_mpcr_val);               \
-       device_create_file(dev, &dev_attr_mpsc_mrr_val);                \
-       device_create_file(dev, &dev_attr_mpsc_rcrr_val);               \
-       device_create_file(dev, &dev_attr_mpsc_tcrr_val);               \
-       device_create_file(dev, &dev_attr_mpsc_intr_mask_val);          \
-       device_create_file(dev, &dev_attr_mpsc_bcr_val);                \
-       device_create_file(dev, &dev_attr_mpsc_sdma_irq);               \
-       device_create_file(dev, &dev_attr_mpsc_brg_can_tune);           \
-       device_create_file(dev, &dev_attr_mpsc_brg_clk_src);            \
-       device_create_file(dev, &dev_attr_mpsc_brg_clk_freq);           \
-}
-
-#endif /* __ASMPPC_MV64x60_H */
diff --git a/include/asm-ppc/mv64x60_defs.h b/include/asm-ppc/mv64x60_defs.h
deleted file mode 100644 (file)
index 6f7899d..0000000
+++ /dev/null
@@ -1,996 +0,0 @@
-/*
- * include/asm-ppc/gt64260_defs.h
- * 
- * Register definitions for the Marvell/Galileo GT64260, MV64360, etc.
- * host bridges.
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2001-2002 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#ifndef __ASMPPC_MV64x60_DEFS_H
-#define __ASMPPC_MV64x60_DEFS_H
-
-/*
- * Define the Marvell bridges that are supported
- */
-#define        MV64x60_TYPE_INVALID            0
-#define        MV64x60_TYPE_GT64260A           1
-#define        MV64x60_TYPE_GT64260B           2
-#define        MV64x60_TYPE_MV64360            3
-#define        MV64x60_TYPE_MV64361            4
-#define        MV64x60_TYPE_MV64362            5
-#define        MV64x60_TYPE_MV64460            6
-
-
-/* Revisions of each supported chip */
-#define        GT64260_REV_A                   0x10
-#define        GT64260_REV_B                   0x20
-#define        MV64360                         0x01
-#define        MV64460                         0x01
-
-/* Minimum window size supported by 64260 is 1MB */
-#define GT64260_WINDOW_SIZE_MIN                0x00100000
-#define MV64360_WINDOW_SIZE_MIN                0x00010000
-
-/* IRQ's for embedded controllers */
-#define        MV64x60_IRQ_DEV                 1
-#define        MV64x60_IRQ_CPU_ERR             3
-#define        MV64x60_IRQ_TIMER_0_1           8
-#define        MV64x60_IRQ_TIMER_2_3           9
-#define        MV64x60_IRQ_TIMER_4_5           10
-#define        MV64x60_IRQ_TIMER_6_7           11
-#define        MV64x60_IRQ_ETH_0               32
-#define        MV64x60_IRQ_ETH_1               33
-#define        MV64x60_IRQ_ETH_2               34
-#define        MV64x60_IRQ_SDMA_0              36
-#define        MV64x60_IRQ_I2C                 37
-#define        MV64x60_IRQ_SDMA_1              38
-#define        MV64x60_IRQ_BRG                 39
-#define        MV64x60_IRQ_MPSC_0              40
-#define        MV64x60_IRQ_MPSC_1              42
-#define        MV64x60_IRQ_COMM                43
-
-#define        MV64360_IRQ_PCI0                12
-#define        MV64360_IRQ_SRAM_PAR_ERR        13
-#define        MV64360_IRQ_PCI1                16
-
-/* Offsets for register blocks */
-#define        MV64x60_MPSC_0_OFFSET           0x8000
-#define        MV64x60_MPSC_1_OFFSET           0x9000
-#define        MV64x60_MPSC_ROUTING_OFFSET     0xb400
-#define        MV64x60_SDMA_0_OFFSET           0x4000
-#define        MV64x60_SDMA_1_OFFSET           0x6000
-#define        MV64x60_SDMA_INTR_OFFSET        0xb800
-#define        MV64x60_BRG_0_OFFSET            0xb200
-#define        MV64x60_BRG_1_OFFSET            0xb208
-
-/*
- *****************************************************************************
- *
- *     CPU Interface Registers
- *
- *****************************************************************************
- */
-
-/* CPU physical address of 64260's registers */
-#define MV64x60_INTERNAL_SPACE_DECODE                  0x0068
-#define MV64x60_INTERNAL_SPACE_SIZE                    0x10000
-#define MV64x60_INTERNAL_SPACE_DEFAULT_ADDR            0x14000000
-
-#define        MV64360_CPU_BAR_ENABLE                          0x0278
-
-/* CPU Memory Controller Window Registers (4 windows) */
-#define        MV64x60_CPU2MEM_WINDOWS                         4
-
-#define        MV64x60_CPU2MEM_0_BASE                          0x0008
-#define        MV64x60_CPU2MEM_0_SIZE                          0x0010
-#define        MV64x60_CPU2MEM_1_BASE                          0x0208
-#define        MV64x60_CPU2MEM_1_SIZE                          0x0210
-#define        MV64x60_CPU2MEM_2_BASE                          0x0018
-#define        MV64x60_CPU2MEM_2_SIZE                          0x0020
-#define        MV64x60_CPU2MEM_3_BASE                          0x0218
-#define        MV64x60_CPU2MEM_3_SIZE                          0x0220
-
-/* CPU Device Controller Window Registers (4 windows) */
-#define        MV64x60_CPU2DEV_CS_WINDOWS                      4
-
-#define        MV64x60_CPU2DEV_0_BASE                          0x0028
-#define        MV64x60_CPU2DEV_0_SIZE                          0x0030
-#define        MV64x60_CPU2DEV_1_BASE                          0x0228
-#define        MV64x60_CPU2DEV_1_SIZE                          0x0230
-#define        MV64x60_CPU2DEV_2_BASE                          0x0248
-#define        MV64x60_CPU2DEV_2_SIZE                          0x0250
-#define        MV64x60_CPU2DEV_3_BASE                          0x0038
-#define        MV64x60_CPU2DEV_3_SIZE                          0x0040
-
-#define        MV64x60_CPU2BOOT_0_BASE                         0x0238
-#define        MV64x60_CPU2BOOT_0_SIZE                         0x0240
-
-/* CPU Windows to PCI space (2 PCI buses each w/ 1 I/O & 4 MEM windows) */
-#define        MV64x60_PCI_BUSES                               2
-#define        MV64x60_PCI_IO_WINDOWS_PER_BUS                  1
-#define        MV64x60_PCI_MEM_WINDOWS_PER_BUS                 4
-
-#define        MV64x60_CPU2PCI_SWAP_BYTE                       0x00000000
-#define        MV64x60_CPU2PCI_SWAP_NONE                       0x01000000
-#define        MV64x60_CPU2PCI_SWAP_BYTE_WORD                  0x02000000
-#define        MV64x60_CPU2PCI_SWAP_WORD                       0x03000000
-
-#define        MV64x60_CPU2PCI_MEM_REQ64                       (1<<27)
-
-#define        MV64x60_CPU2PCI0_IO_BASE                        0x0048
-#define        MV64x60_CPU2PCI0_IO_SIZE                        0x0050
-#define        MV64x60_CPU2PCI0_MEM_0_BASE                     0x0058
-#define        MV64x60_CPU2PCI0_MEM_0_SIZE                     0x0060
-#define        MV64x60_CPU2PCI0_MEM_1_BASE                     0x0080
-#define        MV64x60_CPU2PCI0_MEM_1_SIZE                     0x0088
-#define        MV64x60_CPU2PCI0_MEM_2_BASE                     0x0258
-#define        MV64x60_CPU2PCI0_MEM_2_SIZE                     0x0260
-#define        MV64x60_CPU2PCI0_MEM_3_BASE                     0x0280
-#define        MV64x60_CPU2PCI0_MEM_3_SIZE                     0x0288
-
-#define        MV64x60_CPU2PCI0_IO_REMAP                       0x00f0
-#define        MV64x60_CPU2PCI0_MEM_0_REMAP_LO                 0x00f8
-#define        MV64x60_CPU2PCI0_MEM_0_REMAP_HI                 0x0320
-#define        MV64x60_CPU2PCI0_MEM_1_REMAP_LO                 0x0100
-#define        MV64x60_CPU2PCI0_MEM_1_REMAP_HI                 0x0328
-#define        MV64x60_CPU2PCI0_MEM_2_REMAP_LO                 0x02f8
-#define        MV64x60_CPU2PCI0_MEM_2_REMAP_HI                 0x0330
-#define        MV64x60_CPU2PCI0_MEM_3_REMAP_LO                 0x0300
-#define        MV64x60_CPU2PCI0_MEM_3_REMAP_HI                 0x0338
-
-#define        MV64x60_CPU2PCI1_IO_BASE                        0x0090
-#define        MV64x60_CPU2PCI1_IO_SIZE                        0x0098
-#define        MV64x60_CPU2PCI1_MEM_0_BASE                     0x00a0
-#define        MV64x60_CPU2PCI1_MEM_0_SIZE                     0x00a8
-#define        MV64x60_CPU2PCI1_MEM_1_BASE                     0x00b0
-#define        MV64x60_CPU2PCI1_MEM_1_SIZE                     0x00b8
-#define        MV64x60_CPU2PCI1_MEM_2_BASE                     0x02a0
-#define        MV64x60_CPU2PCI1_MEM_2_SIZE                     0x02a8
-#define        MV64x60_CPU2PCI1_MEM_3_BASE                     0x02b0
-#define        MV64x60_CPU2PCI1_MEM_3_SIZE                     0x02b8
-
-#define        MV64360_CPU2SRAM_BASE                           0x0268
-
-#define        MV64x60_CPU2PCI1_IO_REMAP                       0x0108
-#define        MV64x60_CPU2PCI1_MEM_0_REMAP_LO                 0x0110
-#define        MV64x60_CPU2PCI1_MEM_0_REMAP_HI                 0x0340
-#define        MV64x60_CPU2PCI1_MEM_1_REMAP_LO                 0x0118
-#define        MV64x60_CPU2PCI1_MEM_1_REMAP_HI                 0x0348
-#define        MV64x60_CPU2PCI1_MEM_2_REMAP_LO                 0x0310
-#define        MV64x60_CPU2PCI1_MEM_2_REMAP_HI                 0x0350
-#define        MV64x60_CPU2PCI1_MEM_3_REMAP_LO                 0x0318
-#define        MV64x60_CPU2PCI1_MEM_3_REMAP_HI                 0x0358
-
-/* CPU Control Registers */
-#define MV64x60_CPU_CONFIG                             0x0000
-#define MV64x60_CPU_MODE                               0x0120
-#define MV64x60_CPU_MASTER_CNTL                                0x0160
-#define MV64x60_CPU_XBAR_CNTL_LO                       0x0150
-#define MV64x60_CPU_XBAR_CNTL_HI                       0x0158
-#define MV64x60_CPU_XBAR_TO                            0x0168
-
-#define GT64260_CPU_RR_XBAR_CNTL_LO                    0x0170
-#define GT64260_CPU_RR_XBAR_CNTL_HI                    0x0178
-
-#define MV64360_CPU_PADS_CALIBRATION                   0x03b4
-#define MV64360_CPU_RESET_SAMPLE_LO                    0x03c4
-#define MV64360_CPU_RESET_SAMPLE_HI                    0x03d4
-
-/* SMP Register Map */
-#define MV64360_WHO_AM_I                               0x0200
-#define MV64360_CPU0_DOORBELL                          0x0214
-#define MV64360_CPU0_DOORBELL_CLR                      0x021c
-#define MV64360_CPU0_DOORBELL_MASK                     0x0234
-#define MV64360_CPU1_DOORBELL                          0x0224
-#define MV64360_CPU1_DOORBELL_CLR                      0x022c
-#define MV64360_CPU1_DOORBELL_MASK                     0x023c
-#define MV64360_CPUx_DOORBELL(x)                       (0x0214 + ((x)*0x10))
-#define MV64360_CPUx_DOORBELL_CLR(x)                   (0x021c + ((x)*0x10))
-#define MV64360_CPUx_DOORBELL_MASK(x)                  (0x0234 + ((x)*0x08))
-#define MV64360_SEMAPHORE_0                            0x0244
-#define MV64360_SEMAPHORE_1                            0x024c
-#define MV64360_SEMAPHORE_2                            0x0254
-#define MV64360_SEMAPHORE_3                            0x025c
-#define MV64360_SEMAPHORE_4                            0x0264
-#define MV64360_SEMAPHORE_5                            0x026c
-#define MV64360_SEMAPHORE_6                            0x0274
-#define MV64360_SEMAPHORE_7                            0x027c
-
-/* CPU Sync Barrier Registers */
-#define GT64260_CPU_SYNC_BARRIER_PCI0                  0x00c0
-#define GT64260_CPU_SYNC_BARRIER_PCI1                  0x00c8
-
-#define MV64360_CPU0_SYNC_BARRIER_TRIG                 0x00c0
-#define MV64360_CPU0_SYNC_BARRIER_VIRT                 0x00c8
-#define MV64360_CPU1_SYNC_BARRIER_TRIG                 0x00d0
-#define MV64360_CPU1_SYNC_BARRIER_VIRT                 0x00d8
-
-/* CPU Deadlock and Ordering registers (Rev B part only) */
-#define GT64260_CPU_DEADLOCK_ORDERING                   0x02d0
-#define GT64260_CPU_WB_PRIORITY_BUFFER_DEPTH            0x02d8
-#define GT64260_CPU_COUNTERS_SYNC_BARRIER_ATTRIBUTE     0x02e0
-
-/* CPU Access Protection Registers (gt64260 realy has 8 but don't need) */
-#define        MV64x260_CPU_PROT_WINDOWS                       4
-
-#define        GT64260_CPU_PROT_ACCPROTECT                     (1<<16)
-#define        GT64260_CPU_PROT_WRPROTECT                      (1<<17)
-#define        GT64260_CPU_PROT_CACHEPROTECT                   (1<<18)
-
-#define        MV64360_CPU_PROT_ACCPROTECT                     (1<<20)
-#define        MV64360_CPU_PROT_WRPROTECT                      (1<<21)
-#define        MV64360_CPU_PROT_CACHEPROTECT                   (1<<22)
-#define        MV64360_CPU_PROT_WIN_ENABLE                     (1<<31)
-
-#define MV64x60_CPU_PROT_BASE_0                                0x0180
-#define MV64x60_CPU_PROT_SIZE_0                                0x0188
-#define MV64x60_CPU_PROT_BASE_1                                0x0190
-#define MV64x60_CPU_PROT_SIZE_1                                0x0198
-#define MV64x60_CPU_PROT_BASE_2                                0x01a0
-#define MV64x60_CPU_PROT_SIZE_2                                0x01a8
-#define MV64x60_CPU_PROT_BASE_3                                0x01b0
-#define MV64x60_CPU_PROT_SIZE_3                                0x01b8
-
-#define GT64260_CPU_PROT_BASE_4                                0x01c0
-#define GT64260_CPU_PROT_SIZE_4                                0x01c8
-#define GT64260_CPU_PROT_BASE_5                                0x01d0
-#define GT64260_CPU_PROT_SIZE_5                                0x01d8
-#define GT64260_CPU_PROT_BASE_6                                0x01e0
-#define GT64260_CPU_PROT_SIZE_6                                0x01e8
-#define GT64260_CPU_PROT_BASE_7                                0x01f0
-#define GT64260_CPU_PROT_SIZE_7                                0x01f8
-
-/* CPU Snoop Control Registers (64260 only) */
-#define        GT64260_CPU_SNOOP_WINDOWS                       4
-
-#define        GT64260_CPU_SNOOP_NONE                          0x00000000
-#define        GT64260_CPU_SNOOP_WT                            0x00010000
-#define        GT64260_CPU_SNOOP_WB                            0x00020000
-#define        GT64260_CPU_SNOOP_MASK                          0x00030000
-#define        GT64260_CPU_SNOOP_ALL_BITS                      GT64260_CPU_SNOOP_MASK
-
-#define GT64260_CPU_SNOOP_BASE_0                       0x0380
-#define GT64260_CPU_SNOOP_SIZE_0                       0x0388
-#define GT64260_CPU_SNOOP_BASE_1                       0x0390
-#define GT64260_CPU_SNOOP_SIZE_1                       0x0398
-#define GT64260_CPU_SNOOP_BASE_2                       0x03a0
-#define GT64260_CPU_SNOOP_SIZE_2                       0x03a8
-#define GT64260_CPU_SNOOP_BASE_3                       0x03b0
-#define GT64260_CPU_SNOOP_SIZE_3                       0x03b8
-
-/* CPU Error Report Registers */
-#define MV64x60_CPU_ERR_ADDR_LO                                0x0070
-#define MV64x60_CPU_ERR_ADDR_HI                                0x0078
-#define MV64x60_CPU_ERR_DATA_LO                                0x0128
-#define MV64x60_CPU_ERR_DATA_HI                                0x0130
-#define MV64x60_CPU_ERR_PARITY                         0x0138
-#define MV64x60_CPU_ERR_CAUSE                          0x0140
-#define MV64x60_CPU_ERR_MASK                           0x0148
-
-/*
- *****************************************************************************
- *
- *     SRAM Cotnroller Registers
- *
- *****************************************************************************
- */
-
-#define        MV64360_SRAM_CONFIG                             0x0380
-#define        MV64360_SRAM_TEST_MODE                          0x03f4
-#define        MV64360_SRAM_ERR_CAUSE                          0x0388
-#define        MV64360_SRAM_ERR_ADDR_LO                        0x0390
-#define        MV64360_SRAM_ERR_ADDR_HI                        0x03f8
-#define        MV64360_SRAM_ERR_DATA_LO                        0x0398
-#define        MV64360_SRAM_ERR_DATA_HI                        0x03a0
-#define        MV64360_SRAM_ERR_PARITY                         0x03a8
-
-
-/*
- *****************************************************************************
- *
- *     SDRAM Cotnroller Registers
- *
- *****************************************************************************
- */
-
-/* SDRAM Config Registers (64260) */
-#define        GT64260_SDRAM_CONFIG                            0x0448
-
-/* SDRAM Error Report Registers (64260) */
-#define        GT64260_SDRAM_ERR_DATA_LO                       0x0484
-#define        GT64260_SDRAM_ERR_DATA_HI                       0x0480
-#define        GT64260_SDRAM_ERR_ADDR                          0x0490
-#define        GT64260_SDRAM_ERR_ECC_RCVD                      0x0488
-#define        GT64260_SDRAM_ERR_ECC_CALC                      0x048c
-#define        GT64260_SDRAM_ERR_ECC_CNTL                      0x0494
-#define        GT64260_SDRAM_ERR_ECC_ERR_CNT                   0x0498
-
-/* SDRAM Config Registers (64360) */
-#define        MV64360_SDRAM_CONFIG                            0x1400
-
-/* SDRAM Error Report Registers (64360) */
-#define        MV64360_SDRAM_ERR_DATA_LO                       0x1444
-#define        MV64360_SDRAM_ERR_DATA_HI                       0x1440
-#define        MV64360_SDRAM_ERR_ADDR                          0x1450
-#define        MV64360_SDRAM_ERR_ECC_RCVD                      0x1448
-#define        MV64360_SDRAM_ERR_ECC_CALC                      0x144c
-#define        MV64360_SDRAM_ERR_ECC_CNTL                      0x1454
-#define        MV64360_SDRAM_ERR_ECC_ERR_CNT                   0x1458
-
-
-/*
- *****************************************************************************
- *
- *     Device/BOOT Cotnroller Registers
- *
- *****************************************************************************
- */
-
-/* Device Control Registers */
-#define        MV64x60_DEV_BANK_PARAMS_0                       0x045c
-#define        MV64x60_DEV_BANK_PARAMS_1                       0x0460
-#define        MV64x60_DEV_BANK_PARAMS_2                       0x0464
-#define        MV64x60_DEV_BANK_PARAMS_3                       0x0468
-#define        MV64x60_DEV_BOOT_PARAMS                         0x046c
-#define        MV64x60_DEV_IF_CNTL                             0x04c0
-#define        MV64x60_DEV_IF_XBAR_CNTL_LO                     0x04c8
-#define        MV64x60_DEV_IF_XBAR_CNTL_HI                     0x04cc
-#define        MV64x60_DEV_IF_XBAR_CNTL_TO                     0x04c4
-
-/* Device Interrupt Registers */
-#define        MV64x60_DEV_INTR_CAUSE                          0x04d0
-#define        MV64x60_DEV_INTR_MASK                           0x04d4
-#define        MV64x60_DEV_INTR_ERR_ADDR                       0x04d8
-
-#define        MV64360_DEV_INTR_ERR_DATA                       0x04dc
-#define        MV64360_DEV_INTR_ERR_PAR                        0x04e0
-
-
-/*
- *****************************************************************************
- *
- *     PCI Bridge Interface Registers
- *
- *****************************************************************************
- */
-
-/* PCI Configuration Access Registers */
-#define        MV64x60_PCI0_CONFIG_ADDR                        0x0cf8
-#define        MV64x60_PCI0_CONFIG_DATA                        0x0cfc
-#define        MV64x60_PCI0_IACK                               0x0c34
-
-#define        MV64x60_PCI1_CONFIG_ADDR                        0x0c78
-#define        MV64x60_PCI1_CONFIG_DATA                        0x0c7c
-#define        MV64x60_PCI1_IACK                               0x0cb4
-
-/* PCI Control Registers */
-#define        MV64x60_PCI0_CMD                                0x0c00
-#define        MV64x60_PCI0_MODE                               0x0d00
-#define        MV64x60_PCI0_TO_RETRY                           0x0c04
-#define        MV64x60_PCI0_RD_BUF_DISCARD_TIMER               0x0d04
-#define        MV64x60_PCI0_MSI_TRIGGER_TIMER                  0x0c38
-#define        MV64x60_PCI0_ARBITER_CNTL                       0x1d00
-#define        MV64x60_PCI0_XBAR_CNTL_LO                       0x1d08
-#define        MV64x60_PCI0_XBAR_CNTL_HI                       0x1d0c
-#define        MV64x60_PCI0_XBAR_CNTL_TO                       0x1d04
-#define        MV64x60_PCI0_RD_RESP_XBAR_CNTL_LO               0x1d18
-#define        MV64x60_PCI0_RD_RESP_XBAR_CNTL_HI               0x1d1c
-#define        MV64x60_PCI0_SYNC_BARRIER                       0x1d10
-#define        MV64x60_PCI0_P2P_CONFIG                         0x1d14
-#define        MV64x60_PCI0_INTR_MASK
-
-#define        GT64260_PCI0_P2P_SWAP_CNTL                      0x1d54
-
-#define        MV64x60_PCI1_CMD                                0x0c80
-#define        MV64x60_PCI1_MODE                               0x0d80
-#define        MV64x60_PCI1_TO_RETRY                           0x0c84
-#define        MV64x60_PCI1_RD_BUF_DISCARD_TIMER               0x0d84
-#define        MV64x60_PCI1_MSI_TRIGGER_TIMER                  0x0cb8
-#define        MV64x60_PCI1_ARBITER_CNTL                       0x1d80
-#define        MV64x60_PCI1_XBAR_CNTL_LO                       0x1d88
-#define        MV64x60_PCI1_XBAR_CNTL_HI                       0x1d8c
-#define        MV64x60_PCI1_XBAR_CNTL_TO                       0x1d84
-#define        MV64x60_PCI1_RD_RESP_XBAR_CNTL_LO               0x1d98
-#define        MV64x60_PCI1_RD_RESP_XBAR_CNTL_HI               0x1d9c
-#define        MV64x60_PCI1_SYNC_BARRIER                       0x1d90
-#define        MV64x60_PCI1_P2P_CONFIG                         0x1d94
-
-#define        GT64260_PCI1_P2P_SWAP_CNTL                      0x1dd4
-
-/* PCI Access Control Regions Registers */
-#define        GT64260_PCI_ACC_CNTL_PREFETCHEN                 (1<<12)
-#define        GT64260_PCI_ACC_CNTL_DREADEN                    (1<<13)
-#define        GT64260_PCI_ACC_CNTL_RDPREFETCH                 (1<<16)
-#define        GT64260_PCI_ACC_CNTL_RDLINEPREFETCH             (1<<17)
-#define        GT64260_PCI_ACC_CNTL_RDMULPREFETCH              (1<<18)
-#define        GT64260_PCI_ACC_CNTL_MBURST_32_BTYES            0x00000000
-#define        GT64260_PCI_ACC_CNTL_MBURST_64_BYTES            0x00100000
-#define        GT64260_PCI_ACC_CNTL_MBURST_128_BYTES           0x00200000
-#define        GT64260_PCI_ACC_CNTL_MBURST_MASK                0x00300000
-#define        GT64260_PCI_ACC_CNTL_SWAP_BYTE                  0x00000000
-#define        GT64260_PCI_ACC_CNTL_SWAP_NONE                  0x01000000
-#define        GT64260_PCI_ACC_CNTL_SWAP_BYTE_WORD             0x02000000
-#define        GT64260_PCI_ACC_CNTL_SWAP_WORD                  0x03000000
-#define        GT64260_PCI_ACC_CNTL_SWAP_MASK                  0x03000000
-#define        GT64260_PCI_ACC_CNTL_ACCPROT                    (1<<28)
-#define        GT64260_PCI_ACC_CNTL_WRPROT                     (1<<29)
-
-#define        GT64260_PCI_ACC_CNTL_ALL_BITS   (GT64260_PCI_ACC_CNTL_PREFETCHEN |    \
-                                        GT64260_PCI_ACC_CNTL_DREADEN |       \
-                                        GT64260_PCI_ACC_CNTL_RDPREFETCH |    \
-                                        GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |\
-                                        GT64260_PCI_ACC_CNTL_RDMULPREFETCH | \
-                                        GT64260_PCI_ACC_CNTL_MBURST_MASK |   \
-                                        GT64260_PCI_ACC_CNTL_SWAP_MASK |     \
-                                        GT64260_PCI_ACC_CNTL_ACCPROT|        \
-                                        GT64260_PCI_ACC_CNTL_WRPROT)
-
-#define        MV64360_PCI_ACC_CNTL_ENABLE                     (1<<0)
-#define        MV64360_PCI_ACC_CNTL_REQ64                      (1<<1)
-#define        MV64360_PCI_ACC_CNTL_SNOOP_NONE                 0x00000000
-#define        MV64360_PCI_ACC_CNTL_SNOOP_WT                   0x00000004
-#define        MV64360_PCI_ACC_CNTL_SNOOP_WB                   0x00000008
-#define        MV64360_PCI_ACC_CNTL_SNOOP_MASK                 0x0000000c
-#define        MV64360_PCI_ACC_CNTL_ACCPROT                    (1<<4)
-#define        MV64360_PCI_ACC_CNTL_WRPROT                     (1<<5)
-#define        MV64360_PCI_ACC_CNTL_SWAP_BYTE                  0x00000000
-#define        MV64360_PCI_ACC_CNTL_SWAP_NONE                  0x00000040
-#define        MV64360_PCI_ACC_CNTL_SWAP_BYTE_WORD             0x00000080
-#define        MV64360_PCI_ACC_CNTL_SWAP_WORD                  0x000000c0
-#define        MV64360_PCI_ACC_CNTL_SWAP_MASK                  0x000000c0
-#define        MV64360_PCI_ACC_CNTL_MBURST_32_BYTES            0x00000000
-#define        MV64360_PCI_ACC_CNTL_MBURST_64_BYTES            0x00000100
-#define        MV64360_PCI_ACC_CNTL_MBURST_128_BYTES           0x00000200
-#define        MV64360_PCI_ACC_CNTL_MBURST_MASK                0x00000300
-#define        MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES            0x00000000
-#define        MV64360_PCI_ACC_CNTL_RDSIZE_64_BYTES            0x00000400
-#define        MV64360_PCI_ACC_CNTL_RDSIZE_128_BYTES           0x00000800
-#define        MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES           0x00000c00
-#define        MV64360_PCI_ACC_CNTL_RDSIZE_MASK                0x00000c00
-
-#define        MV64360_PCI_ACC_CNTL_ALL_BITS   (MV64360_PCI_ACC_CNTL_ENABLE |      \
-                                        MV64360_PCI_ACC_CNTL_REQ64 |       \
-                                        MV64360_PCI_ACC_CNTL_SNOOP_MASK |  \
-                                        MV64360_PCI_ACC_CNTL_ACCPROT |     \
-                                        MV64360_PCI_ACC_CNTL_WRPROT |      \
-                                        MV64360_PCI_ACC_CNTL_SWAP_MASK |   \
-                                        MV64360_PCI_ACC_CNTL_MBURST_MASK | \
-                                        MV64360_PCI_ACC_CNTL_RDSIZE_MASK)
-
-#define        MV64x60_PCI0_ACC_CNTL_0_BASE_LO                 0x1e00
-#define        MV64x60_PCI0_ACC_CNTL_0_BASE_HI                 0x1e04
-#define        MV64x60_PCI0_ACC_CNTL_0_SIZE                    0x1e08
-#define        MV64x60_PCI0_ACC_CNTL_1_BASE_LO                 0x1e10
-#define        MV64x60_PCI0_ACC_CNTL_1_BASE_HI                 0x1e14
-#define        MV64x60_PCI0_ACC_CNTL_1_SIZE                    0x1e18
-#define        MV64x60_PCI0_ACC_CNTL_2_BASE_LO                 0x1e20
-#define        MV64x60_PCI0_ACC_CNTL_2_BASE_HI                 0x1e24
-#define        MV64x60_PCI0_ACC_CNTL_2_SIZE                    0x1e28
-#define        MV64x60_PCI0_ACC_CNTL_3_BASE_LO                 0x1e30
-#define        MV64x60_PCI0_ACC_CNTL_3_BASE_HI                 0x1e34
-#define        MV64x60_PCI0_ACC_CNTL_3_SIZE                    0x1e38
-#define        MV64x60_PCI0_ACC_CNTL_4_BASE_LO                 0x1e40
-#define        MV64x60_PCI0_ACC_CNTL_4_BASE_HI                 0x1e44
-#define        MV64x60_PCI0_ACC_CNTL_4_SIZE                    0x1e48
-#define        MV64x60_PCI0_ACC_CNTL_5_BASE_LO                 0x1e50
-#define        MV64x60_PCI0_ACC_CNTL_5_BASE_HI                 0x1e54
-#define        MV64x60_PCI0_ACC_CNTL_5_SIZE                    0x1e58
-
-#define        GT64260_PCI0_ACC_CNTL_6_BASE_LO                 0x1e60
-#define        GT64260_PCI0_ACC_CNTL_6_BASE_HI                 0x1e64
-#define        GT64260_PCI0_ACC_CNTL_6_SIZE                    0x1e68
-#define        GT64260_PCI0_ACC_CNTL_7_BASE_LO                 0x1e70
-#define        GT64260_PCI0_ACC_CNTL_7_BASE_HI                 0x1e74
-#define        GT64260_PCI0_ACC_CNTL_7_SIZE                    0x1e78
-
-#define        MV64x60_PCI1_ACC_CNTL_0_BASE_LO                 0x1e80
-#define        MV64x60_PCI1_ACC_CNTL_0_BASE_HI                 0x1e84
-#define        MV64x60_PCI1_ACC_CNTL_0_SIZE                    0x1e88
-#define        MV64x60_PCI1_ACC_CNTL_1_BASE_LO                 0x1e90
-#define        MV64x60_PCI1_ACC_CNTL_1_BASE_HI                 0x1e94
-#define        MV64x60_PCI1_ACC_CNTL_1_SIZE                    0x1e98
-#define        MV64x60_PCI1_ACC_CNTL_2_BASE_LO                 0x1ea0
-#define        MV64x60_PCI1_ACC_CNTL_2_BASE_HI                 0x1ea4
-#define        MV64x60_PCI1_ACC_CNTL_2_SIZE                    0x1ea8
-#define        MV64x60_PCI1_ACC_CNTL_3_BASE_LO                 0x1eb0
-#define        MV64x60_PCI1_ACC_CNTL_3_BASE_HI                 0x1eb4
-#define        MV64x60_PCI1_ACC_CNTL_3_SIZE                    0x1eb8
-#define        MV64x60_PCI1_ACC_CNTL_4_BASE_LO                 0x1ec0
-#define        MV64x60_PCI1_ACC_CNTL_4_BASE_HI                 0x1ec4
-#define        MV64x60_PCI1_ACC_CNTL_4_SIZE                    0x1ec8
-#define        MV64x60_PCI1_ACC_CNTL_5_BASE_LO                 0x1ed0
-#define        MV64x60_PCI1_ACC_CNTL_5_BASE_HI                 0x1ed4
-#define        MV64x60_PCI1_ACC_CNTL_5_SIZE                    0x1ed8
-
-#define        GT64260_PCI1_ACC_CNTL_6_BASE_LO                 0x1ee0
-#define        GT64260_PCI1_ACC_CNTL_6_BASE_HI                 0x1ee4
-#define        GT64260_PCI1_ACC_CNTL_6_SIZE                    0x1ee8
-#define        GT64260_PCI1_ACC_CNTL_7_BASE_LO                 0x1ef0
-#define        GT64260_PCI1_ACC_CNTL_7_BASE_HI                 0x1ef4
-#define        GT64260_PCI1_ACC_CNTL_7_SIZE                    0x1ef8
-
-/* PCI Snoop Control Registers (64260 only) */
-#define        GT64260_PCI_SNOOP_NONE                          0x00000000
-#define        GT64260_PCI_SNOOP_WT                            0x00001000
-#define        GT64260_PCI_SNOOP_WB                            0x00002000
-
-#define        GT64260_PCI0_SNOOP_0_BASE_LO                    0x1f00
-#define        GT64260_PCI0_SNOOP_0_BASE_HI                    0x1f04
-#define        GT64260_PCI0_SNOOP_0_SIZE                       0x1f08
-#define        GT64260_PCI0_SNOOP_1_BASE_LO                    0x1f10
-#define        GT64260_PCI0_SNOOP_1_BASE_HI                    0x1f14
-#define        GT64260_PCI0_SNOOP_1_SIZE                       0x1f18
-#define        GT64260_PCI0_SNOOP_2_BASE_LO                    0x1f20
-#define        GT64260_PCI0_SNOOP_2_BASE_HI                    0x1f24
-#define        GT64260_PCI0_SNOOP_2_SIZE                       0x1f28
-#define        GT64260_PCI0_SNOOP_3_BASE_LO                    0x1f30
-#define        GT64260_PCI0_SNOOP_3_BASE_HI                    0x1f34
-#define        GT64260_PCI0_SNOOP_3_SIZE                       0x1f38
-
-#define        GT64260_PCI1_SNOOP_0_BASE_LO                    0x1f80
-#define        GT64260_PCI1_SNOOP_0_BASE_HI                    0x1f84
-#define        GT64260_PCI1_SNOOP_0_SIZE                       0x1f88
-#define        GT64260_PCI1_SNOOP_1_BASE_LO                    0x1f90
-#define        GT64260_PCI1_SNOOP_1_BASE_HI                    0x1f94
-#define        GT64260_PCI1_SNOOP_1_SIZE                       0x1f98
-#define        GT64260_PCI1_SNOOP_2_BASE_LO                    0x1fa0
-#define        GT64260_PCI1_SNOOP_2_BASE_HI                    0x1fa4
-#define        GT64260_PCI1_SNOOP_2_SIZE                       0x1fa8
-#define        GT64260_PCI1_SNOOP_3_BASE_LO                    0x1fb0
-#define        GT64260_PCI1_SNOOP_3_BASE_HI                    0x1fb4
-#define        GT64260_PCI1_SNOOP_3_SIZE                       0x1fb8
-
-/* PCI Error Report Registers */
-#define MV64x60_PCI0_ERR_SERR_MASK                     0x0c28
-#define MV64x60_PCI0_ERR_ADDR_LO                       0x1d40
-#define MV64x60_PCI0_ERR_ADDR_HI                       0x1d44
-#define MV64x60_PCI0_ERR_DATA_LO                       0x1d48
-#define MV64x60_PCI0_ERR_DATA_HI                       0x1d4c
-#define MV64x60_PCI0_ERR_CMD                           0x1d50
-#define MV64x60_PCI0_ERR_CAUSE                         0x1d58
-#define MV64x60_PCI0_ERR_MASK                          0x1d5c
-
-#define MV64x60_PCI1_ERR_SERR_MASK                     0x0ca8
-#define MV64x60_PCI1_ERR_ADDR_LO                       0x1dc0
-#define MV64x60_PCI1_ERR_ADDR_HI                       0x1dc4
-#define MV64x60_PCI1_ERR_DATA_LO                       0x1dc8
-#define MV64x60_PCI1_ERR_DATA_HI                       0x1dcc
-#define MV64x60_PCI1_ERR_CMD                           0x1dd0
-#define MV64x60_PCI1_ERR_CAUSE                         0x1dd8
-#define MV64x60_PCI1_ERR_MASK                          0x1ddc
-
-/* PCI Slave Address Decoding Registers */
-#define        MV64x60_PCI0_MEM_0_SIZE                         0x0c08
-#define        MV64x60_PCI0_MEM_1_SIZE                         0x0d08
-#define        MV64x60_PCI0_MEM_2_SIZE                         0x0c0c
-#define        MV64x60_PCI0_MEM_3_SIZE                         0x0d0c
-#define        MV64x60_PCI1_MEM_0_SIZE                         0x0c88
-#define        MV64x60_PCI1_MEM_1_SIZE                         0x0d88
-#define        MV64x60_PCI1_MEM_2_SIZE                         0x0c8c
-#define        MV64x60_PCI1_MEM_3_SIZE                         0x0d8c
-
-#define        MV64x60_PCI0_BAR_ENABLE                         0x0c3c
-#define        MV64x60_PCI1_BAR_ENABLE                         0x0cbc
-
-#define        MV64x60_PCI0_PCI_DECODE_CNTL                    0x0d3c
-
-
-
-
-
-#define        MV64x60_PCI0_SLAVE_BAR_REG_ENABLES              0x0c3c
-#define        MV64x60_PCI0_SLAVE_MEM_0_REMAP                  0x0c48
-#define        MV64x60_PCI0_SLAVE_MEM_1_REMAP                  0x0d48
-#define        MV64x60_PCI0_SLAVE_MEM_2_REMAP                  0x0c4c
-#define        MV64x60_PCI0_SLAVE_MEM_3_REMAP                  0x0d4c
-#define        MV64x60_PCI0_SLAVE_CS_0_REMAP                   0x0c50
-#define        MV64x60_PCI0_SLAVE_CS_1_REMAP                   0x0d50
-#define        MV64x60_PCI0_SLAVE_CS_2_REMAP                   0x0d58
-#define        MV64x60_PCI0_SLAVE_CS_3_REMAP                   0x0c54
-#define        MV64x60_PCI0_SLAVE_BOOT_REMAP                   0x0d54
-#define        MV64x60_PCI0_SLAVE_P2P_MEM_0_REMAP_LO           0x0d5c
-#define        MV64x60_PCI0_SLAVE_P2P_MEM_0_REMAP_HI           0x0d60
-#define        MV64x60_PCI0_SLAVE_P2P_MEM_1_REMAP_LO           0x0d64
-#define        MV64x60_PCI0_SLAVE_P2P_MEM_1_REMAP_HI           0x0d68
-#define        MV64x60_PCI0_SLAVE_P2P_IO_REMAP                 0x0d6c
-#define        MV64x60_PCI0_SLAVE_CPU_REMAP                    0x0d70
-
-#define        GT64260_PCI0_SLAVE_DAC_SCS_0_REMAP              0x0f00
-#define        GT64260_PCI0_SLAVE_DAC_SCS_1_REMAP              0x0f04
-#define        GT64260_PCI0_SLAVE_DAC_SCS_2_REMAP              0x0f08
-#define        GT64260_PCI0_SLAVE_DAC_SCS_3_REMAP              0x0f0c
-#define        GT64260_PCI0_SLAVE_DAC_CS_0_REMAP               0x0f10
-#define        GT64260_PCI0_SLAVE_DAC_CS_1_REMAP               0x0f14
-#define        GT64260_PCI0_SLAVE_DAC_CS_2_REMAP               0x0f18
-#define        GT64260_PCI0_SLAVE_DAC_CS_3_REMAP               0x0f1c
-#define        GT64260_PCI0_SLAVE_DAC_BOOT_REMAP               0x0f20
-#define        GT64260_PCI0_SLAVE_DAC_P2P_MEM_0_REMAP_LO       0x0f24
-#define        GT64260_PCI0_SLAVE_DAC_P2P_MEM_0_REMAP_HI       0x0f28
-#define        GT64260_PCI0_SLAVE_DAC_P2P_MEM_1_REMAP_LO       0x0f2c
-#define        GT64260_PCI0_SLAVE_DAC_P2P_MEM_1_REMAP_HI       0x0f30
-#define        GT64260_PCI0_SLAVE_DAC_CPU_REMAP                0x0f34
-
-#define        GT64260_PCI0_SLAVE_EXP_ROM_REMAP                0x0f38
-#define        GT64260_PCI0_SLAVE_PCI_DECODE_CNTL              0x0d3c
-
-
-
-
-
-/* XXXX BEGIN */
-#define        MV64x60_PCI1_PCI_DECODE_CNTL                    0x0dbc
-
-#define        MV64x60_PCI1_SLAVE_MEM_0_SIZE                   0x0c88
-#define        MV64x60_PCI1_SLAVE_MEM_1_SIZE                   0x0d88
-#define        MV64x60_PCI1_SLAVE_MEM_2_SIZE                   0x0c8c
-#define        MV64x60_PCI1_SLAVE_MEM_3_SIZE                   0x0d8c
-#define        MV64x60_PCI1_SLAVE_CS_0_SIZE                    0x0c90
-#define        MV64x60_PCI1_SLAVE_CS_1_SIZE                    0x0d90
-#define        MV64x60_PCI1_SLAVE_CS_2_SIZE                    0x0d98
-#define        MV64x60_PCI1_SLAVE_CS_3_SIZE                    0x0c94
-#define        MV64x60_PCI1_SLAVE_BOOT_SIZE                    0x0d94
-#define        MV64x60_PCI1_SLAVE_P2P_MEM_0_SIZE               0x0d9c
-#define        MV64x60_PCI1_SLAVE_P2P_MEM_1_SIZE               0x0da0
-#define        MV64x60_PCI1_SLAVE_P2P_IO_SIZE                  0x0da4
-#define        MV64x60_PCI1_SLAVE_CPU_SIZE                     0x0da8
-
-
-/* XXXXX END */
-
-
-#define        GT64260_PCI1_SLAVE_DAC_SCS_0_SIZE               0x0e80
-#define        GT64260_PCI1_SLAVE_DAC_SCS_1_SIZE               0x0e84
-#define        GT64260_PCI1_SLAVE_DAC_SCS_2_SIZE               0x0e88
-#define        GT64260_PCI1_SLAVE_DAC_SCS_3_SIZE               0x0e8c
-#define        GT64260_PCI1_SLAVE_DAC_CS_0_SIZE                0x0e90
-#define        GT64260_PCI1_SLAVE_DAC_CS_1_SIZE                0x0e94
-#define        GT64260_PCI1_SLAVE_DAC_CS_2_SIZE                0x0e98
-#define        GT64260_PCI1_SLAVE_DAC_CS_3_SIZE                0x0e9c
-#define        GT64260_PCI1_SLAVE_DAC_BOOT_SIZE                0x0ea0
-#define        GT64260_PCI1_SLAVE_DAC_P2P_MEM_0_SIZE           0x0ea4
-#define        GT64260_PCI1_SLAVE_DAC_P2P_MEM_1_SIZE           0x0ea8
-#define        GT64260_PCI1_SLAVE_DAC_CPU_SIZE                 0x0eac
-
-#define        GT64260_PCI1_SLAVE_EXP_ROM_SIZE                 0x0dac
-
-
-
-
-/* XXXX BEGIN */
-
-#define        MV64x60_PCI1_SLAVE_BAR_REG_ENABLES              0x0cbc
-#define        MV64x60_PCI1_SLAVE_MEM_0_REMAP                  0x0cc8
-#define        MV64x60_PCI1_SLAVE_MEM_1_REMAP                  0x0dc8
-#define        MV64x60_PCI1_SLAVE_MEM_2_REMAP                  0x0ccc
-#define        MV64x60_PCI1_SLAVE_MEM_3_REMAP                  0x0dcc
-#define        MV64x60_PCI1_SLAVE_CS_0_REMAP                   0x0cd0
-#define        MV64x60_PCI1_SLAVE_CS_1_REMAP                   0x0dd0
-#define        MV64x60_PCI1_SLAVE_CS_2_REMAP                   0x0dd8
-#define        MV64x60_PCI1_SLAVE_CS_3_REMAP                   0x0cd4
-#define        MV64x60_PCI1_SLAVE_BOOT_REMAP                   0x0dd4
-#define        MV64x60_PCI1_SLAVE_P2P_MEM_0_REMAP_LO           0x0ddc
-#define        MV64x60_PCI1_SLAVE_P2P_MEM_0_REMAP_HI           0x0de0
-#define        MV64x60_PCI1_SLAVE_P2P_MEM_1_REMAP_LO           0x0de4
-#define        MV64x60_PCI1_SLAVE_P2P_MEM_1_REMAP_HI           0x0de8
-#define        MV64x60_PCI1_SLAVE_P2P_IO_REMAP                 0x0dec
-#define        MV64x60_PCI1_SLAVE_CPU_REMAP                    0x0df0
-
-/* XXXXX END */
-
-
-
-#define        GT64260_PCI1_SLAVE_DAC_SCS_0_REMAP              0x0f80
-#define        GT64260_PCI1_SLAVE_DAC_SCS_1_REMAP              0x0f84
-#define        GT64260_PCI1_SLAVE_DAC_SCS_2_REMAP              0x0f88
-#define        GT64260_PCI1_SLAVE_DAC_SCS_3_REMAP              0x0f8c
-#define        GT64260_PCI1_SLAVE_DAC_CS_0_REMAP               0x0f90
-#define        GT64260_PCI1_SLAVE_DAC_CS_1_REMAP               0x0f94
-#define        GT64260_PCI1_SLAVE_DAC_CS_2_REMAP               0x0f98
-#define        GT64260_PCI1_SLAVE_DAC_CS_3_REMAP               0x0f9c
-#define        GT64260_PCI1_SLAVE_DAC_BOOT_REMAP               0x0fa0
-#define        GT64260_PCI1_SLAVE_DAC_P2P_MEM_0_REMAP_LO       0x0fa4
-#define        GT64260_PCI1_SLAVE_DAC_P2P_MEM_0_REMAP_HI       0x0fa8
-#define        GT64260_PCI1_SLAVE_DAC_P2P_MEM_1_REMAP_LO       0x0fac
-#define        GT64260_PCI1_SLAVE_DAC_P2P_MEM_1_REMAP_HI       0x0fb0
-#define        GT64260_PCI1_SLAVE_DAC_CPU_REMAP                0x0fb4
-
-#define        GT64260_PCI1_SLAVE_EXP_ROM_REMAP                0x0fb8
-#define        GT64260_PCI1_SLAVE_PCI_DECODE_CNTL              0x0dbc
-
-
-/*
- *****************************************************************************
- *
- *     Timer/Counter Interface Registers
- *
- *****************************************************************************
- */
-
-#define        MV64x60_TIMR_CNTR_0                             0x0850
-#define        MV64x60_TIMR_CNTR_1                             0x0854
-#define        MV64x60_TIMR_CNTR_2                             0x0858
-#define        MV64x60_TIMR_CNTR_3                             0x085c
-#define        MV64x60_TIMR_CNTR_0_3_CNTL                      0x0864
-#define        MV64x60_TIMR_CNTR_0_3_INTR_CAUSE                0x0868
-#define        MV64x60_TIMR_CNTR_0_3_INTR_MASK                 0x086c
-
-#define        GT64260_TIMR_CNTR_4                             0x0950
-#define        GT64260_TIMR_CNTR_5                             0x0954
-#define        GT64260_TIMR_CNTR_6                             0x0958
-#define        GT64260_TIMR_CNTR_7                             0x095c
-#define        GT64260_TIMR_CNTR_4_7_CNTL                      0x0964
-#define        GT64260_TIMR_CNTR_4_7_INTR_CAUSE                0x0968
-#define        GT64260_TIMR_CNTR_4_7_INTR_MASK                 0x096c
-
-
-/*
- *****************************************************************************
- *
- *     Communications Controller (Enet, Serial, etc.) Interface Registers
- *
- *****************************************************************************
- */
-
-#define        GT64260_COMM_ENET_0_OFFSET              0xf200
-#define        GT64260_COMM_ENET_1_OFFSET              0xf220
-#define        GT64260_COMM_ENET_2_OFFSET              0xf240
-
-#define        GT64260_ENET_CNTL_LO                    \
-       (0xf200 - GT64260_COMM_ENET_0_BASE)
-#define        GT64260_ENET_CNTL_HI                    \
-       (0xf204 - GT64260_COMM_ENET_0_BASE)
-#define        GT64260_ENET_RX_BUF_PCI_ADDR_HI         \
-       (0xf208 - GT64260_COMM_ENET_0_BASE)
-#define        GT64260_ENET_TX_BUF_PCI_ADDR_HI         \
-       (0xf20c - GT64260_COMM_ENET_0_BASE)
-#define        GT64260_ENET_RX_DESC_ADDR_HI            \
-       (0xf210 - GT64260_COMM_ENET_0_BASE)
-#define        GT64260_ENET_TX_DESC_ADDR_HI            \
-       (0xf214 - GT64260_COMM_ENET_0_BASE)
-#define        GT64260_ENET_HASH_TAB_PCI_ADDR_HI       \
-       (0xf218 - GT64260_COMM_ENET_0_BASE)
-
-#define        GT64260_COMM_MPSC_0_OFFSET              0xf280
-#define        GT64260_COMM_MPSC_1_OFFSET              0xf2c0
-
-#define        GT64260_MPSC_CNTL_LO                    \
-       (0xf280 - GT64260_COMM_MPSC_0_BASE)
-#define        GT64260_MPSC_CNTL_HI                    \
-       (0xf284 - GT64260_COMM_MPSC_0_BASE)
-#define        GT64260_MPSC_RX_BUF_PCI_ADDR_HI \
-       (0xf288 - GT64260_COMM_MPSC_0_BASE)
-#define        GT64260_MPSC_TX_BUF_PCI_ADDR_HI \
-       (0xf28c - GT64260_COMM_MPSC_0_BASE)
-#define        GT64260_MPSC_RX_DESC_ADDR_HI            \
-       (0xf290 - GT64260_COMM_MPSC_0_BASE)
-#define        GT64260_MPSC_TX_DESC_ADDR_HI            \
-       (0xf294 - GT64260_COMM_MPSC_0_BASE)
-
-#define        GT64260_SER_INIT_PCI_ADDR_HI            0xf320
-#define        GT64260_SER_INIT_LAST_DATA              0xf324
-#define        GT64260_SER_INIT_CONTROL                0xf328
-#define        GT64260_SER_INIT_STATUS                 0xf32c
-
-#define        GT64260_COMM_ARBITER_CNTL               0xf300
-#define        GT64260_COMM_CONFIG                     0xb40c
-#define        GT64260_COMM_XBAR_TO                    0xf304
-#define        GT64260_COMM_INTR_CAUSE                 0xf310
-#define        GT64260_COMM_INTR_MASK                  0xf314
-#define        GT64260_COMM_ERR_ADDR                   0xf318
-
-
-/*
- *****************************************************************************
- *
- *     Fast Ethernet Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define        GT64260_ENET_PHY_ADDR                   0x2000
-#define        GT64260_ENET_ESMIR                      0x2010
-
-#define GT64260_ENET_0_OFFSET                  0x2400
-#define GT64260_ENET_1_OFFSET                  0x2800
-#define GT64260_ENET_2_OFFSET                  0x2c00
-
-#define        GT64260_ENET_EPCR                       (0x2400 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EPCXR                      (0x2408 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EPCMR                      (0x2410 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EPSR                       (0x2418 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ESPR                       (0x2420 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EHTPR                      (0x2428 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EFCSAL                     (0x2430 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EFCSAH                     (0x2438 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ESDCR                      (0x2440 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ESDCMR                     (0x2448 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EICR                       (0x2450 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EIMR                       (0x2458 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EFRDP0                     (0x2480 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EFRDP1                     (0x2484 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EFRDP2                     (0x2488 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_EFRDP3                     (0x248c - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ECRDP0                     (0x24a0 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ECRDP1                     (0x24a4 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ECRDP2                     (0x24a8 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ECRDP3                     (0x24ac - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ECTDP0                     (0x24e0 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_ECTDP1                     (0x24e4 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_DSCP2P0L                   (0x2460 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_DSCP2P0H                   (0x2464 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_DSCP2P1L                   (0x2468 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_DSCP2P1H                   (0x246c - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_VPT2P                      (0x2470 - GT64260_ENET_0_OFFSET)
-#define        GT64260_ENET_MIB_CTRS                   (0x2500 - GT64260_ENET_0_OFFSET)
-
-/*
- *****************************************************************************
- *
- *     IDMA Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define        GT64260_IDMA_0_OFFSET                   0x0800
-#define        GT64260_IDMA_1_OFFSET                   0x0804
-#define        GT64260_IDMA_2_OFFSET                   0x0808
-#define        GT64260_IDMA_3_OFFSET                   0x080c
-#define        GT64260_IDMA_4_OFFSET                   0x0900
-#define        GT64260_IDMA_5_OFFSET                   0x0904
-#define        GT64260_IDMA_6_OFFSET                   0x0908
-#define        GT64260_IDMA_7_OFFSET                   0x090c
-
-#define        GT64260_IDMA_BYTE_COUNT                 (0x0800 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_SRC_ADDR                   (0x0810 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_DST_ADDR                   (0x0820 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_NEXT_DESC                  (0x0830 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_CUR_DESC                   (0x0870 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_SRC_PCI_ADDR_HI            (0x0890 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_DST_PCI_ADDR_HI            (0x08a0 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_NEXT_DESC_PCI_ADDR_HI      (0x08b0 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_CONTROL_LO                 (0x0840 - GT64260_IDMA_0_OFFSET)
-#define        GT64260_IDMA_CONTROL_HI                 (0x0880 - GT64260_IDMA_0_OFFSET)
-
-#define        GT64260_IDMA_0_3_ARBITER_CNTL           0x0860
-#define        GT64260_IDMA_4_7_ARBITER_CNTL           0x0960
-
-#define        GT64260_IDMA_0_3_XBAR_TO                0x08d0
-#define        GT64260_IDMA_4_7_XBAR_TO                0x09d0
-
-#define        GT64260_IDMA_0_3_INTR_CAUSE             0x08c0
-#define        GT64260_IDMA_0_3_INTR_MASK              0x08c4
-#define        GT64260_IDMA_0_3_ERROR_ADDR             0x08c8
-#define        GT64260_IDMA_0_3_ERROR_SELECT           0x08cc
-#define        GT64260_IDMA_4_7_INTR_CAUSE             0x09c0
-#define        GT64260_IDMA_4_7_INTR_MASK              0x09c4
-#define        GT64260_IDMA_4_7_ERROR_ADDR             0x09c8
-#define        GT64260_IDMA_4_7_ERROR_SELECT           0x09cc
-
-/*
- *****************************************************************************
- *
- *     Watchdog Timer Interface Registers
- *
- *****************************************************************************
- */
-
-#define        GT64260_WDT_WDC                                 0xb410
-#define        GT64260_WDT_WDV                                 0xb414
-
-
-/*
- *****************************************************************************
- *
- *      General Purpose Pins Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define        MV64x60_GPP_IO_CNTL                             0xf100
-#define        MV64x60_GPP_LEVEL_CNTL                          0xf110
-#define        MV64x60_GPP_VALUE                               0xf104
-#define        MV64x60_GPP_INTR_CAUSE                          0xf108
-#define        MV64x60_GPP_INTR_MASK                           0xf10c
-
-
-/*
- *****************************************************************************
- *
- *     Multi-Purpose Pins Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define        MV64x60_MPP_CNTL_0                              0xf000
-#define        MV64x60_MPP_CNTL_1                              0xf004
-#define        MV64x60_MPP_CNTL_2                              0xf008
-#define        MV64x60_MPP_CNTL_3                              0xf00c
-#define        GT64260_MPP_SERIAL_PORTS_MULTIPLEX              0xf010
-
-
-/*
- *****************************************************************************
- *
- *     I2C Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define GT64260_I2C_OFFSET                     0xc000
-
-#define GT64260_I2C_ADDR                       (0xc000 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_EX_ADDR                    (0xc010 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_DATA                       (0xc004 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_CONTROL                    (0xc008 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_STATUS                     (0xc00c - GT64260_I2C_OFFSET)
-#define GT64260_I2C_BAUD_RATE                  (0xc00c - GT64260_I2C_OFFSET)
-#define GT64260_I2C_RESET                      (0xc01c - GT64260_I2C_OFFSET)
-
-#define GT64260_I2C_ACK_BIT                    (1<<2)
-#define GT64260_I2C_IFLG_BIT                   (1<<3)
-#define GT64260_I2C_STOP_BIT                   (1<<4)
-#define GT64260_I2C_START_BIT                  (1<<5)
-#define GT64260_I2C_ENABLE_BIT                 (1<<6)
-#define GT64260_I2C_INT_ENABLE_BIT             (1<<7)
-
-#define GT64260_I2C_DATA_READ_BIT              0x01
-
-#define GT64260_I2C_STATUS_SENT_START          0x08
-#define GT64260_I2C_STATUS_RESENT_START                0x10
-#define GT64260_I2C_STATUS_WRITE_ADDR_ACK      0x18
-#define GT64260_I2C_STATUS_WRITE_ACK           0x28
-#define GT64260_I2C_STATUS_READ_ADDR_ACK       0x40
-#define GT64260_I2C_STATUS_READ_ACK            0x50
-#define GT64260_I2C_STATUS_READ_NO_ACK         0x58
-#define GT64260_I2C_STATUS_IDLE                        0xf8
-
-
-/*
- *****************************************************************************
- *
- *     Interrupt Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define        GT64260_IC_OFFSET                               0x0c18
-
-#define        GT64260_IC_MAIN_CAUSE_LO                (0x0c18 - GT64260_IC_OFFSET)
-#define        GT64260_IC_MAIN_CAUSE_HI                (0x0c68 - GT64260_IC_OFFSET)
-#define        GT64260_IC_CPU_INTR_MASK_LO             (0x0c1c - GT64260_IC_OFFSET)
-#define        GT64260_IC_CPU_INTR_MASK_HI             (0x0c6c - GT64260_IC_OFFSET)
-#define        GT64260_IC_CPU_SELECT_CAUSE             (0x0c70 - GT64260_IC_OFFSET)
-#define        GT64260_IC_PCI0_INTR_MASK_LO            (0x0c24 - GT64260_IC_OFFSET)
-#define        GT64260_IC_PCI0_INTR_MASK_HI            (0x0c64 - GT64260_IC_OFFSET)
-#define        GT64260_IC_PCI0_SELECT_CAUSE            (0x0c74 - GT64260_IC_OFFSET)
-#define        GT64260_IC_PCI1_INTR_MASK_LO            (0x0ca4 - GT64260_IC_OFFSET)
-#define        GT64260_IC_PCI1_INTR_MASK_HI            (0x0ce4 - GT64260_IC_OFFSET)
-#define        GT64260_IC_PCI1_SELECT_CAUSE            (0x0cf4 - GT64260_IC_OFFSET)
-#define        GT64260_IC_CPU_INT_0_MASK               (0x0e60 - GT64260_IC_OFFSET)
-#define        GT64260_IC_CPU_INT_1_MASK               (0x0e64 - GT64260_IC_OFFSET)
-#define        GT64260_IC_CPU_INT_2_MASK               (0x0e68 - GT64260_IC_OFFSET)
-#define        GT64260_IC_CPU_INT_3_MASK               (0x0e6c - GT64260_IC_OFFSET)
-
-#define        MV64360_IC_OFFSET                               0x0000
-
-#define        MV64360_IC_MAIN_CAUSE_LO                (0x0004 - MV64360_IC_OFFSET)
-#define        MV64360_IC_MAIN_CAUSE_HI                (0x000c - MV64360_IC_OFFSET)
-#define        MV64360_IC_CPU0_INTR_MASK_LO            (0x0014 - MV64360_IC_OFFSET)
-#define        MV64360_IC_CPU0_INTR_MASK_HI            (0x001c - MV64360_IC_OFFSET)
-#define        MV64360_IC_CPU0_SELECT_CAUSE            (0x0024 - MV64360_IC_OFFSET)
-#define        MV64360_IC_CPU1_INTR_MASK_LO            (0x0034 - MV64360_IC_OFFSET)
-#define        MV64360_IC_CPU1_INTR_MASK_HI            (0x003c - MV64360_IC_OFFSET)
-#define        MV64360_IC_CPU1_SELECT_CAUSE            (0x0044 - MV64360_IC_OFFSET)
-#define        MV64360_IC_INT0_MASK_LO                 (0x0054 - MV64360_IC_OFFSET)
-#define        MV64360_IC_INT0_MASK_HI                 (0x005c - MV64360_IC_OFFSET)
-#define        MV64360_IC_INT0_SELECT_CAUSE            (0x0064 - MV64360_IC_OFFSET)
-#define        MV64360_IC_INT1_MASK_LO                 (0x0074 - MV64360_IC_OFFSET)
-#define        MV64360_IC_INT1_MASK_HI                 (0x007c - MV64360_IC_OFFSET)
-#define        MV64360_IC_INT1_SELECT_CAUSE            (0x0084 - MV64360_IC_OFFSET)
-
-#endif /* __ASMPPC_MV64x60_DEFS_H */
index 57838e8..b01542b 100644 (file)
@@ -163,5 +163,7 @@ extern __inline__ int get_order(unsigned long size)
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 #endif /* _PPC_PAGE_H */
index 931b6de..0ec3df2 100644 (file)
@@ -40,5 +40,10 @@ extern void pte_free(struct page *pte);
 
 #define check_pgt_cache()      do { } while (0)
 
+#define arch_add_exec_range(mm, limit)         do { ; } while (0)
+#define arch_flush_exec_range(mm)              do { ; } while (0)
+#define arch_remove_exec_range(mm, limit)      do { ; } while (0)
+
+
 #endif /* _PPC_PGALLOC_H */
 #endif /* __KERNEL__ */
diff --git a/include/asm-ppc/ppc405_dma.h b/include/asm-ppc/ppc405_dma.h
deleted file mode 100644 (file)
index 489eec5..0000000
+++ /dev/null
@@ -1,1271 +0,0 @@
-/*
- * Author: Pete Popov <ppopov@mvista.com>
- *
- * 2000 (c) MontaVista, Software, Inc.  This file is licensed under
- * the terms of the GNU General Public License version 2.  This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- *
- * Data structures specific to the IBM PowerPC 405 on-chip DMA controller
- * and API.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASMPPC_405_DMA_H
-#define __ASMPPC_405_DMA_H
-
-#include <linux/types.h>
-
-/* #define DEBUG_405DMA */
-
-#define TRUE  1
-#define FALSE 0
-
-#define SGL_LIST_SIZE 4096
-/* #define PCI_ALLOC_IS_NONCONSISTENT */
-
-#define MAX_405GP_DMA_CHANNELS 4
-
-/* The maximum address that we can perform a DMA transfer to on this platform */
-/* Doesn't really apply... */
-#define MAX_DMA_ADDRESS                0xFFFFFFFF
-
-extern unsigned long ISA_DMA_THRESHOLD;
-
-#define dma_outb       outb
-#define dma_inb                inb
-
-
-/*
- * Function return status codes
- * These values are used to indicate whether or not the function
- * call was successful, or a bad/invalid parameter was passed.
- */
-#define DMA_STATUS_GOOD                        0
-#define DMA_STATUS_BAD_CHANNEL         1
-#define DMA_STATUS_BAD_HANDLE          2
-#define DMA_STATUS_BAD_MODE            3
-#define DMA_STATUS_NULL_POINTER                4
-#define DMA_STATUS_OUT_OF_MEMORY       5
-#define DMA_STATUS_SGL_LIST_EMPTY      6
-#define DMA_STATUS_GENERAL_ERROR       7
-
-
-/*
- * These indicate status as returned from the DMA Status Register.
- */
-#define DMA_STATUS_NO_ERROR    0
-#define DMA_STATUS_CS          1       /* Count Status        */
-#define DMA_STATUS_TS          2       /* Transfer Status     */
-#define DMA_STATUS_DMA_ERROR   3       /* DMA Error Occurred  */
-#define DMA_STATUS_DMA_BUSY    4       /* The channel is busy */
-
-
-/*
- * Transfer Modes
- * These modes are defined in a way that makes it possible to
- * simply "or" in the value in the control register.
- */
-#define DMA_MODE_READ          DMA_TD                /* Peripheral to Memory */
-#define DMA_MODE_WRITE         0                     /* Memory to Peripheral */
-#define DMA_MODE_MM            (SET_DMA_TM(TM_S_MM)) /* memory to memory */
-
-                               /* Device-paced memory to memory, */
-                               /* device is at source address    */
-#define DMA_MODE_MM_DEVATSRC   (DMA_TD | SET_DMA_TM(TM_D_MM))
-
-                               /* Device-paced memory to memory,      */
-                               /* device is at destination address    */
-#define DMA_MODE_MM_DEVATDST   (SET_DMA_TM(TM_D_MM))
-
-
-/*
- * DMA Polarity Configuration Register
- */
-#define DMAReq0_ActiveLow (1<<31)
-#define DMAAck0_ActiveLow (1<<30)
-#define EOT0_ActiveLow    (1<<29)           /* End of Transfer      */
-
-#define DMAReq1_ActiveLow (1<<28)
-#define DMAAck1_ActiveLow (1<<27)
-#define EOT1_ActiveLow    (1<<26)
-
-#define DMAReq2_ActiveLow (1<<25)
-#define DMAAck2_ActiveLow (1<<24)
-#define EOT2_ActiveLow    (1<<23)
-
-#define DMAReq3_ActiveLow (1<<22)
-#define DMAAck3_ActiveLow (1<<21)
-#define EOT3_ActiveLow    (1<<20)
-
-/*
- * DMA Sleep Mode Register
- */
-#define SLEEP_MODE_ENABLE (1<<21)
-
-
-/*
- * DMA Status Register
- */
-#define DMA_CS0           (1<<31) /* Terminal Count has been reached */
-#define DMA_CS1           (1<<30)
-#define DMA_CS2           (1<<29)
-#define DMA_CS3           (1<<28)
-
-#define DMA_TS0           (1<<27) /* End of Transfer has been requested */
-#define DMA_TS1           (1<<26)
-#define DMA_TS2           (1<<25)
-#define DMA_TS3           (1<<24)
-
-#define DMA_CH0_ERR       (1<<23) /* DMA Chanel 0 Error */
-#define DMA_CH1_ERR       (1<<22)
-#define DMA_CH2_ERR       (1<<21)
-#define DMA_CH3_ERR       (1<<20)
-
-#define DMA_IN_DMA_REQ0   (1<<19) /* Internal DMA Request is pending */
-#define DMA_IN_DMA_REQ1   (1<<18)
-#define DMA_IN_DMA_REQ2   (1<<17)
-#define DMA_IN_DMA_REQ3   (1<<16)
-
-#define DMA_EXT_DMA_REQ0  (1<<15) /* External DMA Request is pending */
-#define DMA_EXT_DMA_REQ1  (1<<14)
-#define DMA_EXT_DMA_REQ2  (1<<13)
-#define DMA_EXT_DMA_REQ3  (1<<12)
-
-#define DMA_CH0_BUSY      (1<<11) /* DMA Channel 0 Busy */
-#define DMA_CH1_BUSY      (1<<10)
-#define DMA_CH2_BUSY       (1<<9)
-#define DMA_CH3_BUSY       (1<<8)
-
-#define DMA_SG0            (1<<7) /* DMA Channel 0 Scatter/Gather in progress */
-#define DMA_SG1            (1<<6)
-#define DMA_SG2            (1<<5)
-#define DMA_SG3            (1<<4)
-
-
-
-/*
- * DMA Channel Control Registers
- */
-#define DMA_CH_ENABLE         (1<<31)     /* DMA Channel Enable */
-#define SET_DMA_CH_ENABLE(x)  (((x)&0x1)<<31)
-#define GET_DMA_CH_ENABLE(x)  (((x)&DMA_CH_ENABLE)>>31)
-
-#define DMA_CIE_ENABLE        (1<<30)     /* DMA Channel Interrupt Enable */
-#define SET_DMA_CIE_ENABLE(x) (((x)&0x1)<<30)
-#define GET_DMA_CIE_ENABLE(x) (((x)&DMA_CIE_ENABLE)>>30)
-
-#define DMA_TD                (1<<29)
-#define SET_DMA_TD(x)         (((x)&0x1)<<29)
-#define GET_DMA_TD(x)         (((x)&DMA_TD)>>29)
-
-#define DMA_PL                (1<<28)     /* Peripheral Location */
-#define SET_DMA_PL(x)         (((x)&0x1)<<28)
-#define GET_DMA_PL(x)         (((x)&DMA_PL)>>28)
-
-#define EXTERNAL_PERIPHERAL    0
-#define INTERNAL_PERIPHERAL    1
-
-
-#define SET_DMA_PW(x)     (((x)&0x3)<<26) /* Peripheral Width */
-#define DMA_PW_MASK       SET_DMA_PW(3)
-#define   PW_8                 0
-#define   PW_16                1
-#define   PW_32                2
-#define   PW_64                3
-#define GET_DMA_PW(x)     (((x)&DMA_PW_MASK)>>26)
-
-#define DMA_DAI           (1<<25)         /* Destination Address Increment */
-#define SET_DMA_DAI(x)    (((x)&0x1)<<25)
-
-#define DMA_SAI           (1<<24)         /* Source Address Increment */
-#define SET_DMA_SAI(x)    (((x)&0x1)<<24)
-
-#define DMA_BEN           (1<<23)         /* Buffer Enable */
-#define SET_DMA_BEN(x)    (((x)&0x1)<<23)
-
-#define SET_DMA_TM(x)     (((x)&0x3)<<21) /* Transfer Mode */
-#define DMA_TM_MASK       SET_DMA_TM(3)
-#define   TM_PERIPHERAL        0          /* Peripheral */
-#define   TM_RESERVED          1          /* Reserved */
-#define   TM_S_MM              2          /* Memory to Memory */
-#define   TM_D_MM              3          /* Device Paced Memory to Memory */
-#define GET_DMA_TM(x)     (((x)&DMA_TM_MASK)>>21)
-
-#define SET_DMA_PSC(x)    (((x)&0x3)<<19) /* Peripheral Setup Cycles */
-#define DMA_PSC_MASK      SET_DMA_PSC(3)
-#define GET_DMA_PSC(x)    (((x)&DMA_PSC_MASK)>>19)
-
-#define SET_DMA_PWC(x)    (((x)&0x3F)<<13) /* Peripheral Wait Cycles */
-#define DMA_PWC_MASK      SET_DMA_PWC(0x3F)
-#define GET_DMA_PWC(x)    (((x)&DMA_PWC_MASK)>>13)
-
-#define SET_DMA_PHC(x)    (((x)&0x7)<<10) /* Peripheral Hold Cycles */
-#define DMA_PHC_MASK      SET_DMA_PHC(0x7)
-#define GET_DMA_PHC(x)    (((x)&DMA_PHC_MASK)>>10)
-
-#define DMA_ETD_OUTPUT     (1<<9)         /* EOT pin is a TC output */
-#define SET_DMA_ETD(x)     (((x)&0x1)<<9)
-
-#define DMA_TCE_ENABLE     (1<<8)
-#define SET_DMA_TCE(x)     (((x)&0x1)<<8)
-
-#define SET_DMA_PRIORITY(x)   (((x)&0x3)<<6)   /* DMA Channel Priority */
-#define DMA_PRIORITY_MASK SET_DMA_PRIORITY(3)
-#define   PRIORITY_LOW         0
-#define   PRIORITY_MID_LOW     1
-#define   PRIORITY_MID_HIGH    2
-#define   PRIORITY_HIGH        3
-#define GET_DMA_PRIORITY(x) (((x)&DMA_PRIORITY_MASK)>>6)
-
-#define SET_DMA_PREFETCH(x)   (((x)&0x3)<<4)  /* Memory Read Prefetch */
-#define DMA_PREFETCH_MASK      SET_DMA_PREFETCH(3)
-#define   PREFETCH_1           0              /* Prefetch 1 Double Word */
-#define   PREFETCH_2           1
-#define   PREFETCH_4           2
-#define GET_DMA_PREFETCH(x) (((x)&DMA_PREFETCH_MASK)>>4)
-
-#define DMA_PCE            (1<<3)         /* Parity Check Enable */
-#define SET_DMA_PCE(x)     (((x)&0x1)<<3)
-#define GET_DMA_PCE(x)     (((x)&DMA_PCE)>>3)
-
-#define DMA_DEC            (1<<2)         /* Address Decrement */
-#define SET_DMA_DEC(x)     (((x)&0x1)<<2)
-#define GET_DMA_DEC(x)     (((x)&DMA_DEC)>>2)
-
-/*
- * DMA SG Command Register
- */
-#define SSG0_ENABLE        (1<<31)        /* Start Scatter Gather */
-#define SSG1_ENABLE        (1<<30)
-#define SSG2_ENABLE        (1<<29)
-#define SSG3_ENABLE        (1<<28)
-#define SSG0_MASK_ENABLE   (1<<15)        /* Enable writing to SSG0 bit */
-#define SSG1_MASK_ENABLE   (1<<14)
-#define SSG2_MASK_ENABLE   (1<<13)
-#define SSG3_MASK_ENABLE   (1<<12)
-
-
-/*
- * DMA Scatter/Gather Descriptor Bit fields
- */
-#define SG_LINK            (1<<31)        /* Link */
-#define SG_TCI_ENABLE      (1<<29)        /* Enable Terminal Count Interrupt */
-#define SG_ETI_ENABLE      (1<<28)        /* Enable End of Transfer Interrupt */
-#define SG_ERI_ENABLE      (1<<27)        /* Enable Error Interrupt */
-#define SG_COUNT_MASK       0xFFFF        /* Count Field */
-
-
-
-
-typedef uint32_t sgl_handle_t;
-
-typedef struct {
-
-       /*
-        * Valid polarity settings:
-        *   DMAReq0_ActiveLow
-        *   DMAAck0_ActiveLow
-        *   EOT0_ActiveLow
-        *
-        *   DMAReq1_ActiveLow
-        *   DMAAck1_ActiveLow
-        *   EOT1_ActiveLow
-        *
-        *   DMAReq2_ActiveLow
-        *   DMAAck2_ActiveLow
-        *   EOT2_ActiveLow
-        *
-        *   DMAReq3_ActiveLow
-        *   DMAAck3_ActiveLow
-        *   EOT3_ActiveLow
-        */
-       unsigned int polarity;
-
-       char buffer_enable;      /* Boolean: buffer enable            */
-       char tce_enable;         /* Boolean: terminal count enable    */
-       char etd_output;         /* Boolean: eot pin is a tc output   */
-       char pce;                /* Boolean: parity check enable      */
-
-       /*
-        * Peripheral location:
-        * INTERNAL_PERIPHERAL (UART0 on the 405GP)
-        * EXTERNAL_PERIPHERAL
-        */
-       char pl;                 /* internal/external peripheral      */
-
-       /*
-        * Valid pwidth settings:
-        *   PW_8
-        *   PW_16
-        *   PW_32
-        *   PW_64
-        */
-       unsigned int pwidth;
-
-       char dai;                /* Boolean: dst address increment   */
-       char sai;                /* Boolean: src address increment   */
-
-       /*
-        * Valid psc settings: 0-3
-        */
-       unsigned int psc;        /* Peripheral Setup Cycles         */
-
-       /*
-        * Valid pwc settings:
-        * 0-63
-        */
-       unsigned int pwc;        /* Peripheral Wait Cycles          */
-
-       /*
-        * Valid phc settings:
-        * 0-7
-        */
-       unsigned int phc;        /* Peripheral Hold Cycles          */
-
-       /*
-        * Valid cp (channel priority) settings:
-        *   PRIORITY_LOW
-        *   PRIORITY_MID_LOW
-        *   PRIORITY_MID_HIGH
-        *   PRIORITY_HIGH
-        */
-       unsigned int cp;         /* channel priority                */
-
-       /*
-        * Valid pf (memory read prefetch) settings:
-        *
-        *   PREFETCH_1
-        *   PREFETCH_2
-        *   PREFETCH_4
-        */
-       unsigned int pf;         /* memory read prefetch            */
-
-       /*
-        * Boolean: channel interrupt enable
-        * NOTE: for sgl transfers, only the last descriptor will be setup to
-        * interrupt.
-        */
-       char int_enable;
-
-       char shift;              /* easy access to byte_count shift, based on */
-                                /* the width of the channel                  */
-
-       uint32_t control;        /* channel control word                      */
-
-
-       /* These variabled are used ONLY in single dma transfers              */
-       unsigned int mode;       /* transfer mode                     */
-       dma_addr_t addr;
-
-} ppc_dma_ch_t;
-
-
-typedef struct {
-       uint32_t control;
-       uint32_t src_addr;
-       uint32_t dst_addr;
-       uint32_t control_count;
-       uint32_t next;
-} ppc_sgl_t;
-
-
-
-typedef struct {
-       unsigned int dmanr;
-       uint32_t control;     /* channel ctrl word; loaded from each descrptr */
-       uint32_t sgl_control; /* LK, TCI, ETI, and ERI bits in sgl descriptor */
-       dma_addr_t dma_addr;  /* dma (physical) address of this list          */
-       ppc_sgl_t *phead;
-       ppc_sgl_t *ptail;
-
-} sgl_list_info_t;
-
-
-typedef struct {
-       unsigned int *src_addr;
-       unsigned int *dst_addr;
-       dma_addr_t dma_src_addr;
-       dma_addr_t dma_dst_addr;
-} pci_alloc_desc_t;
-
-
-extern ppc_dma_ch_t dma_channels[];
-
-/*
- *
- * DMA API inline functions
- * These functions are implemented here as inline functions for
- * performance reasons.
- *
- */
-
-static __inline__ int get_405gp_dma_status(void)
-{
-       return (mfdcr(DCRN_DMASR));
-}
-
-
-static __inline__ int enable_405gp_dma(unsigned int dmanr)
-{
-       unsigned int control;
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-#ifdef DEBUG_405DMA
-       if (dmanr >= MAX_405GP_DMA_CHANNELS) {
-               printk("enable_dma: bad channel: %d\n", dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-#endif
-
-
-       switch (dmanr) {
-       case 0:
-               if (p_dma_ch->mode == DMA_MODE_READ) {
-                       /* peripheral to memory */
-                       mtdcr(DCRN_DMASA0, NULL);
-                       mtdcr(DCRN_DMADA0, p_dma_ch->addr);
-                       }
-               else if (p_dma_ch->mode == DMA_MODE_WRITE) {
-                       /* memory to peripheral */
-                       mtdcr(DCRN_DMASA0, p_dma_ch->addr);
-                       mtdcr(DCRN_DMADA0, NULL);
-               }
-               /* for other xfer modes, the addresses are already set */
-               control = mfdcr(DCRN_DMACR0);
-               control &= ~(DMA_TM_MASK | DMA_TD);   /* clear all mode bits */
-               control |= (p_dma_ch->mode | DMA_CH_ENABLE);
-               mtdcr(DCRN_DMACR0, control);
-               break;
-       case 1:
-               if (p_dma_ch->mode == DMA_MODE_READ) {
-                       mtdcr(DCRN_DMASA1, NULL);
-                       mtdcr(DCRN_DMADA1, p_dma_ch->addr);
-               } else if (p_dma_ch->mode == DMA_MODE_WRITE) {
-                       mtdcr(DCRN_DMASA1, p_dma_ch->addr);
-                       mtdcr(DCRN_DMADA1, NULL);
-               }
-               control = mfdcr(DCRN_DMACR1);
-               control &= ~(DMA_TM_MASK | DMA_TD);
-               control |= (p_dma_ch->mode | DMA_CH_ENABLE);
-               mtdcr(DCRN_DMACR1, control);
-               break;
-       case 2:
-               if (p_dma_ch->mode == DMA_MODE_READ) {
-                       mtdcr(DCRN_DMASA2, NULL);
-                       mtdcr(DCRN_DMADA2, p_dma_ch->addr);
-               } else if (p_dma_ch->mode == DMA_MODE_WRITE) {
-                       mtdcr(DCRN_DMASA2, p_dma_ch->addr);
-                       mtdcr(DCRN_DMADA2, NULL);
-               }
-               control = mfdcr(DCRN_DMACR2);
-               control &= ~(DMA_TM_MASK | DMA_TD);
-               control |= (p_dma_ch->mode | DMA_CH_ENABLE);
-               mtdcr(DCRN_DMACR2, control);
-               break;
-       case 3:
-               if (p_dma_ch->mode == DMA_MODE_READ) {
-                       mtdcr(DCRN_DMASA3, NULL);
-                       mtdcr(DCRN_DMADA3, p_dma_ch->addr);
-               } else if (p_dma_ch->mode == DMA_MODE_WRITE) {
-                       mtdcr(DCRN_DMASA3, p_dma_ch->addr);
-                       mtdcr(DCRN_DMADA3, NULL);
-               }
-               control = mfdcr(DCRN_DMACR3);
-               control &= ~(DMA_TM_MASK | DMA_TD);
-               control |= (p_dma_ch->mode | DMA_CH_ENABLE);
-               mtdcr(DCRN_DMACR3, control);
-               break;
-       default:
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-       return DMA_STATUS_GOOD;
-}
-
-
-
-static __inline__ void disable_405gp_dma(unsigned int dmanr)
-{
-       unsigned int control;
-
-       switch (dmanr) {
-       case 0:
-               control = mfdcr(DCRN_DMACR0);
-               control &= ~DMA_CH_ENABLE;
-               mtdcr(DCRN_DMACR0, control);
-               break;
-       case 1:
-               control = mfdcr(DCRN_DMACR1);
-               control &= ~DMA_CH_ENABLE;
-               mtdcr(DCRN_DMACR1, control);
-               break;
-       case 2:
-               control = mfdcr(DCRN_DMACR2);
-               control &= ~DMA_CH_ENABLE;
-               mtdcr(DCRN_DMACR2, control);
-               break;
-       case 3:
-               control = mfdcr(DCRN_DMACR3);
-               control &= ~DMA_CH_ENABLE;
-               mtdcr(DCRN_DMACR3, control);
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("disable_dma: bad channel: %d\n", dmanr);
-#endif
-       }
-}
-
-
-
-/*
- * Sets the dma mode for single DMA transfers only.
- * For scatter/gather transfers, the mode is passed to the
- * alloc_dma_handle() function as one of the parameters.
- *
- * The mode is simply saved and used later.  This allows
- * the driver to call set_dma_mode() and set_dma_addr() in
- * any order.
- *
- * Valid mode values are:
- *
- * DMA_MODE_READ          peripheral to memory
- * DMA_MODE_WRITE         memory to peripheral
- * DMA_MODE_MM            memory to memory
- * DMA_MODE_MM_DEVATSRC   device-paced memory to memory, device at src
- * DMA_MODE_MM_DEVATDST   device-paced memory to memory, device at dst
- */
-static __inline__ int set_405gp_dma_mode(unsigned int dmanr, unsigned int mode)
-{
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-#ifdef DEBUG_405DMA
-       switch (mode) {
-       case DMA_MODE_READ:
-       case DMA_MODE_WRITE:
-       case DMA_MODE_MM:
-       case DMA_MODE_MM_DEVATSRC:
-       case DMA_MODE_MM_DEVATDST:
-               break;
-       default:
-               printk("set_dma_mode: bad mode 0x%x\n", mode);
-               return DMA_STATUS_BAD_MODE;
-       }
-       if (dmanr >= MAX_405GP_DMA_CHANNELS) {
-               printk("set_dma_mode: bad channel 0x%x\n", dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-#endif
-
-       p_dma_ch->mode = mode;
-       return DMA_STATUS_GOOD;
-}
-
-
-
-/*
- * Sets the DMA Count register. Note that 'count' is in bytes.
- * However, the DMA Count register counts the number of "transfers",
- * where each transfer is equal to the bus width.  Thus, count
- * MUST be a multiple of the bus width.
- */
-static __inline__ void
-set_405gp_dma_count(unsigned int dmanr, unsigned int count)
-{
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-#ifdef DEBUG_405DMA
-       {
-       int error = 0;
-       switch(p_dma_ch->pwidth) {
-       case PW_8:
-               break;
-       case PW_16:
-               if (count & 0x1)
-               error = 1;
-               break;
-       case PW_32:
-               if (count & 0x3)
-               error = 1;
-               break;
-       case PW_64:
-               if (count & 0x7)
-               error = 1;
-               break;
-       default:
-               printk("set_dma_count: invalid bus width: 0x%x\n",
-                       p_dma_ch->pwidth);
-               return;
-       }
-       if (error)
-               printk("Warning: set_dma_count count 0x%x bus width %d\n",
-                       count, p_dma_ch->pwidth);
-       }
-#endif
-
-       count = count >> p_dma_ch->shift;
-       switch (dmanr) {
-       case 0:
-               mtdcr(DCRN_DMACT0, count);
-               break;
-       case 1:
-               mtdcr(DCRN_DMACT1, count);
-               break;
-       case 2:
-               mtdcr(DCRN_DMACT2, count);
-               break;
-       case 3:
-               mtdcr(DCRN_DMACT3, count);
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("set_dma_count: bad channel: %d\n", dmanr);
-#endif
-       }
-}
-
-
-
-/*
- *   Returns the number of bytes left to be transfered.
- *   After a DMA transfer, this should return zero.
- *   Reading this while a DMA transfer is still in progress will return
- *   unpredictable results.
- */
-static __inline__ int get_405gp_dma_residue(unsigned int dmanr)
-{
-       unsigned int count;
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-       switch (dmanr) {
-       case 0:
-               count = mfdcr(DCRN_DMACT0);
-               break;
-       case 1:
-               count = mfdcr(DCRN_DMACT1);
-               break;
-       case 2:
-               count = mfdcr(DCRN_DMACT2);
-               break;
-       case 3:
-               count = mfdcr(DCRN_DMACT3);
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("get_dma_residue: bad channel: %d\n", dmanr);
-#endif
-           return 0;
-       }
-
-       return (count << p_dma_ch->shift);
-}
-
-
-
-/*
- * Sets the DMA address for a memory to peripheral or peripheral
- * to memory transfer.  The address is just saved in the channel
- * structure for now and used later in enable_dma().
- */
-static __inline__ void set_405gp_dma_addr(unsigned int dmanr, dma_addr_t addr)
-{
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-#ifdef DEBUG_405DMA
-       {
-       int error = 0;
-       switch(p_dma_ch->pwidth) {
-       case PW_8:
-               break;
-       case PW_16:
-               if ((unsigned)addr & 0x1)
-               error = 1;
-               break;
-       case PW_32:
-               if ((unsigned)addr & 0x3)
-               error = 1;
-               break;
-       case PW_64:
-               if ((unsigned)addr & 0x7)
-               error = 1;
-               break;
-       default:
-               printk("set_dma_addr: invalid bus width: 0x%x\n",
-                       p_dma_ch->pwidth);
-               return;
-       }
-       if (error)
-               printk("Warning: set_dma_addr addr 0x%x bus width %d\n",
-                       addr, p_dma_ch->pwidth);
-       }
-#endif
-
-       /* save dma address and program it later after we know the xfer mode */
-       p_dma_ch->addr = addr;
-}
-
-
-
-
-/*
- * Sets both DMA addresses for a memory to memory transfer.
- * For memory to peripheral or peripheral to memory transfers
- * the function set_dma_addr() should be used instead.
- */
-static __inline__ void
-set_405gp_dma_addr2(unsigned int dmanr, dma_addr_t src_dma_addr,
-       dma_addr_t dst_dma_addr)
-{
-#ifdef DEBUG_405DMA
-       {
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-       int error = 0;
-       switch(p_dma_ch->pwidth) {
-       case PW_8:
-               break;
-       case PW_16:
-               if (((unsigned)src_dma_addr & 0x1) ||
-                   ((unsigned)dst_dma_addr & 0x1)
-                  )
-                       error = 1;
-               break;
-       case PW_32:
-               if (((unsigned)src_dma_addr & 0x3) ||
-                   ((unsigned)dst_dma_addr & 0x3)
-                  )
-                       error = 1;
-               break;
-       case PW_64:
-               if (((unsigned)src_dma_addr & 0x7) ||
-                   ((unsigned)dst_dma_addr & 0x7)
-                  )
-                       error = 1;
-               break;
-       default:
-               printk("set_dma_addr2: invalid bus width: 0x%x\n",
-                       p_dma_ch->pwidth);
-               return;
-       }
-       if (error)
-               printk("Warning: set_dma_addr2 src 0x%x dst 0x%x bus width %d\n",
-                       src_dma_addr, dst_dma_addr, p_dma_ch->pwidth);
-       }
-#endif
-
-       switch (dmanr) {
-       case 0:
-               mtdcr(DCRN_DMASA0, src_dma_addr);
-               mtdcr(DCRN_DMADA0, dst_dma_addr);
-               break;
-       case 1:
-               mtdcr(DCRN_DMASA1, src_dma_addr);
-               mtdcr(DCRN_DMADA1, dst_dma_addr);
-               break;
-       case 2:
-               mtdcr(DCRN_DMASA2, src_dma_addr);
-               mtdcr(DCRN_DMADA2, dst_dma_addr);
-               break;
-       case 3:
-               mtdcr(DCRN_DMASA3, src_dma_addr);
-               mtdcr(DCRN_DMADA3, dst_dma_addr);
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("set_dma_addr2: bad channel: %d\n", dmanr);
-#endif
-       }
-}
-
-
-
-/*
- * Enables the channel interrupt.
- *
- * If performing a scatter/gatter transfer, this function
- * MUST be called before calling alloc_dma_handle() and building
- * the sgl list.  Otherwise, interrupts will not be enabled, if
- * they were previously disabled.
- */
-static __inline__ int
-enable_405gp_dma_interrupt(unsigned int dmanr)
-{
-       unsigned int control;
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-       p_dma_ch->int_enable = TRUE;
-       switch (dmanr) {
-       case 0:
-               control = mfdcr(DCRN_DMACR0);
-               control|= DMA_CIE_ENABLE;        /* Channel Interrupt Enable */
-               mtdcr(DCRN_DMACR0, control);
-               break;
-       case 1:
-               control = mfdcr(DCRN_DMACR1);
-               control|= DMA_CIE_ENABLE;
-               mtdcr(DCRN_DMACR1, control);
-               break;
-       case 2:
-               control = mfdcr(DCRN_DMACR2);
-               control|= DMA_CIE_ENABLE;
-               mtdcr(DCRN_DMACR2, control);
-               break;
-       case 3:
-               control = mfdcr(DCRN_DMACR3);
-               control|= DMA_CIE_ENABLE;
-               mtdcr(DCRN_DMACR3, control);
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("enable_dma_interrupt: bad channel: %d\n", dmanr);
-#endif
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-       return DMA_STATUS_GOOD;
-}
-
-
-
-/*
- * Disables the channel interrupt.
- *
- * If performing a scatter/gatter transfer, this function
- * MUST be called before calling alloc_dma_handle() and building
- * the sgl list.  Otherwise, interrupts will not be disabled, if
- * they were previously enabled.
- */
-static __inline__ int
-disable_405gp_dma_interrupt(unsigned int dmanr)
-{
-       unsigned int control;
-       ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-       p_dma_ch->int_enable = TRUE;
-       switch (dmanr) {
-       case 0:
-               control = mfdcr(DCRN_DMACR0);
-               control &= ~DMA_CIE_ENABLE;       /* Channel Interrupt Enable */
-               mtdcr(DCRN_DMACR0, control);
-               break;
-       case 1:
-               control = mfdcr(DCRN_DMACR1);
-               control &= ~DMA_CIE_ENABLE;
-               mtdcr(DCRN_DMACR1, control);
-               break;
-       case 2:
-               control = mfdcr(DCRN_DMACR2);
-               control &= ~DMA_CIE_ENABLE;
-               mtdcr(DCRN_DMACR2, control);
-               break;
-       case 3:
-               control = mfdcr(DCRN_DMACR3);
-               control &= ~DMA_CIE_ENABLE;
-               mtdcr(DCRN_DMACR3, control);
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("enable_dma_interrupt: bad channel: %d\n", dmanr);
-#endif
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-       return DMA_STATUS_GOOD;
-}
-
-
-#ifdef DCRNCAP_DMA_SG
-
-/*
- *   Add a new sgl descriptor to the end of a scatter/gather list
- *   which was created by alloc_dma_handle().
- *
- *   For a memory to memory transfer, both dma addresses must be
- *   valid. For a peripheral to memory transfer, one of the addresses
- *   must be set to NULL, depending on the direction of the transfer:
- *   memory to peripheral: set dst_addr to NULL,
- *   peripheral to memory: set src_addr to NULL.
- */
-static __inline__ int
-add_405gp_dma_sgl(sgl_handle_t handle, dma_addr_t src_addr, dma_addr_t dst_addr,
-       unsigned int count)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
-       ppc_dma_ch_t *p_dma_ch;
-
-       if (!handle) {
-#ifdef DEBUG_405DMA
-               printk("add_dma_sgl: null handle\n");
-#endif
-               return DMA_STATUS_BAD_HANDLE;
-       }
-
-#ifdef DEBUG_405DMA
-       if (psgl->dmanr >= MAX_405GP_DMA_CHANNELS) {
-               printk("add_dma_sgl error: psgl->dmanr == %d\n", psgl->dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-#endif
-
-       p_dma_ch = &dma_channels[psgl->dmanr];
-
-#ifdef DEBUG_405DMA
-       {
-       int error = 0;
-       unsigned int aligned = (unsigned)src_addr | (unsigned)dst_addr | count;
-       switch(p_dma_ch->pwidth) {
-       case PW_8:
-               break;
-       case PW_16:
-               if (aligned & 0x1)
-               error = 1;
-               break;
-       case PW_32:
-               if (aligned & 0x3)
-                       error = 1;
-               break;
-       case PW_64:
-               if (aligned & 0x7)
-                       error = 1;
-               break;
-       default:
-               printk("add_dma_sgl: invalid bus width: 0x%x\n",
-                       p_dma_ch->pwidth);
-               return DMA_STATUS_GENERAL_ERROR;
-       }
-       if (error)
-               printk("Alignment warning: add_dma_sgl src 0x%x dst 0x%x count 0x%x bus width var %d\n",
-                       src_addr, dst_addr, count, p_dma_ch->pwidth);
-
-       }
-#endif
-
-       if ((unsigned)(psgl->ptail + 1) >= ((unsigned)psgl + SGL_LIST_SIZE)) {
-#ifdef DEBUG_405DMA
-               printk("sgl handle out of memory \n");
-#endif
-               return DMA_STATUS_OUT_OF_MEMORY;
-       }
-
-
-       if (!psgl->ptail) {
-               psgl->phead = (ppc_sgl_t *)
-                             ((unsigned)psgl + sizeof(sgl_list_info_t));
-               psgl->ptail = psgl->phead;
-       } else {
-               psgl->ptail->next = virt_to_bus(psgl->ptail + 1);
-               psgl->ptail++;
-       }
-
-       psgl->ptail->control       = psgl->control;
-       psgl->ptail->src_addr      = src_addr;
-       psgl->ptail->dst_addr      = dst_addr;
-       psgl->ptail->control_count = (count >> p_dma_ch->shift) |
-                                    psgl->sgl_control;
-       psgl->ptail->next          = (uint32_t)NULL;
-
-       return DMA_STATUS_GOOD;
-}
-
-
-
-/*
- * Enable (start) the DMA described by the sgl handle.
- */
-static __inline__ void enable_405gp_dma_sgl(sgl_handle_t handle)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
-       ppc_dma_ch_t *p_dma_ch;
-       uint32_t sg_command;
-
-#ifdef DEBUG_405DMA
-       if (!handle) {
-               printk("enable_dma_sgl: null handle\n");
-               return;
-       } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
-               printk("enable_dma_sgl: bad channel in handle %d\n",
-                       psgl->dmanr);
-               return;
-       } else if (!psgl->phead) {
-               printk("enable_dma_sgl: sg list empty\n");
-               return;
-       }
-#endif
-
-       p_dma_ch = &dma_channels[psgl->dmanr];
-       psgl->ptail->control_count &= ~SG_LINK; /* make this the last dscrptr */
-       sg_command = mfdcr(DCRN_ASGC);
-
-       switch(psgl->dmanr) {
-       case 0:
-               mtdcr(DCRN_ASG0, virt_to_bus(psgl->phead));
-               sg_command |= SSG0_ENABLE;
-               break;
-       case 1:
-               mtdcr(DCRN_ASG1, virt_to_bus(psgl->phead));
-               sg_command |= SSG1_ENABLE;
-               break;
-       case 2:
-               mtdcr(DCRN_ASG2, virt_to_bus(psgl->phead));
-               sg_command |= SSG2_ENABLE;
-               break;
-       case 3:
-               mtdcr(DCRN_ASG3, virt_to_bus(psgl->phead));
-               sg_command |= SSG3_ENABLE;
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("enable_dma_sgl: bad channel: %d\n", psgl->dmanr);
-#endif
-       }
-
-#if 0 /* debug */
-       printk("\n\nenable_dma_sgl at dma_addr 0x%x\n",
-               virt_to_bus(psgl->phead));
-       {
-       ppc_sgl_t *pnext, *sgl_addr;
-
-       pnext = psgl->phead;
-       while (pnext) {
-               printk("dma descriptor at 0x%x, dma addr 0x%x\n",
-                       (unsigned)pnext, (unsigned)virt_to_bus(pnext));
-               printk("control 0x%x src 0x%x dst 0x%x c_count 0x%x, next 0x%x\n",
-                       (unsigned)pnext->control, (unsigned)pnext->src_addr,
-                       (unsigned)pnext->dst_addr,
-                       (unsigned)pnext->control_count, (unsigned)pnext->next);
-
-               (unsigned)pnext = bus_to_virt(pnext->next);
-       }
-       printk("sg_command 0x%x\n", sg_command);
-       }
-#endif
-
-#ifdef PCI_ALLOC_IS_NONCONSISTENT
-       /*
-       * This is temporary only, until pci_alloc_consistent() really does
-       * return "consistent" memory.
-       */
-       flush_dcache_range((unsigned)handle, (unsigned)handle + SGL_LIST_SIZE);
-#endif
-
-       mtdcr(DCRN_ASGC, sg_command);             /* start transfer */
-}
-
-
-
-/*
- * Halt an active scatter/gather DMA operation.
- */
-static __inline__ void disable_405gp_dma_sgl(sgl_handle_t handle)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
-       uint32_t sg_command;
-
-#ifdef DEBUG_405DMA
-       if (!handle) {
-               printk("enable_dma_sgl: null handle\n");
-               return;
-       } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
-               printk("enable_dma_sgl: bad channel in handle %d\n",
-                       psgl->dmanr);
-               return;
-       }
-#endif
-       sg_command = mfdcr(DCRN_ASGC);
-       switch(psgl->dmanr) {
-       case 0:
-               sg_command &= ~SSG0_ENABLE;
-               break;
-       case 1:
-               sg_command &= ~SSG1_ENABLE;
-               break;
-       case 2:
-               sg_command &= ~SSG2_ENABLE;
-               break;
-       case 3:
-               sg_command &= ~SSG3_ENABLE;
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("enable_dma_sgl: bad channel: %d\n", psgl->dmanr);
-#endif
-       }
-
-       mtdcr(DCRN_ASGC, sg_command);             /* stop transfer */
-}
-
-
-
-/*
- *  Returns number of bytes left to be transferred from the entire sgl list.
- *  *src_addr and *dst_addr get set to the source/destination address of
- *  the sgl descriptor where the DMA stopped.
- *
- *  An sgl transfer must NOT be active when this function is called.
- */
-static __inline__ int
-get_405gp_dma_sgl_residue(sgl_handle_t handle, dma_addr_t *src_addr,
-       dma_addr_t *dst_addr)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
-       ppc_dma_ch_t *p_dma_ch;
-       ppc_sgl_t *pnext, *sgl_addr;
-       uint32_t count_left;
-
-#ifdef DEBUG_405DMA
-       if (!handle) {
-               printk("get_dma_sgl_residue: null handle\n");
-               return DMA_STATUS_BAD_HANDLE;
-       } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
-               printk("get_dma_sgl_residue: bad channel in handle %d\n",
-                       psgl->dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-#endif
-
-       switch(psgl->dmanr) {
-       case 0:
-               sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG0));
-               count_left = mfdcr(DCRN_DMACT0);
-               break;
-       case 1:
-               sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG1));
-               count_left = mfdcr(DCRN_DMACT1);
-               break;
-       case 2:
-               sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG2));
-               count_left = mfdcr(DCRN_DMACT2);
-               break;
-       case 3:
-               sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG3));
-               count_left = mfdcr(DCRN_DMACT3);
-               break;
-       default:
-#ifdef DEBUG_405DMA
-               printk("get_dma_sgl_residue: bad channel: %d\n", psgl->dmanr);
-#endif
-               goto error;
-       }
-
-       if (!sgl_addr) {
-#ifdef DEBUG_405DMA
-               printk("get_dma_sgl_residue: sgl addr register is null\n");
-#endif
-               goto error;
-       }
-
-       pnext = psgl->phead;
-       while (pnext &&
-               ((unsigned)pnext < ((unsigned)psgl + SGL_LIST_SIZE) &&
-               (pnext != sgl_addr))
-             ) {
-               pnext = pnext++;
-       }
-
-       if (pnext == sgl_addr) {           /* found the sgl descriptor */
-
-               *src_addr = pnext->src_addr;
-               *dst_addr = pnext->dst_addr;
-
-               /*
-                * Now search the remaining descriptors and add their count.
-                * We already have the remaining count from this descriptor in
-                * count_left.
-                */
-               pnext++;
-
-               while ((pnext != psgl->ptail) &&
-                       ((unsigned)pnext < ((unsigned)psgl + SGL_LIST_SIZE))
-                     ) {
-                       count_left += pnext->control_count & SG_COUNT_MASK;
-               }
-
-               if (pnext != psgl->ptail) { /* should never happen */
-#ifdef DEBUG_405DMA
-                       printk("get_dma_sgl_residue error (1) psgl->ptail 0x%x handle 0x%x\n",
-                               (unsigned int)psgl->ptail,
-                               (unsigned int)handle);
-#endif
-                       goto error;
-               }
-
-               /* success */
-               p_dma_ch = &dma_channels[psgl->dmanr];
-               return (count_left << p_dma_ch->shift);  /* count in bytes */
-
-       } else {
-       /* this shouldn't happen */
-#ifdef DEBUG_405DMA
-               printk("get_dma_sgl_residue, unable to match current address 0x%x, handle 0x%x\n",
-                       (unsigned int)sgl_addr, (unsigned int)handle);
-
-#endif
-       }
-
-
-error:
-       *src_addr = (dma_addr_t)NULL;
-       *dst_addr = (dma_addr_t)NULL;
-       return 0;
-}
-
-
-
-
-/*
- * Returns the address(es) of the buffer(s) contained in the head element of
- * the scatter/gather list.  The element is removed from the scatter/gather
- * list and the next element becomes the head.
- *
- * This function should only be called when the DMA is not active.
- */
-static __inline__ int
-delete_405gp_dma_sgl_element(sgl_handle_t handle, dma_addr_t *src_dma_addr,
-       dma_addr_t *dst_dma_addr)
-{
-       sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
-
-#ifdef DEBUG_405DMA
-       if (!handle) {
-               printk("delete_sgl_element: null handle\n");
-               return DMA_STATUS_BAD_HANDLE;
-       } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
-               printk("delete_sgl_element: bad channel in handle %d\n",
-                       psgl->dmanr);
-               return DMA_STATUS_BAD_CHANNEL;
-       }
-#endif
-
-       if (!psgl->phead) {
-#ifdef DEBUG_405DMA
-               printk("delete_sgl_element: sgl list empty\n");
-#endif
-               *src_dma_addr = (dma_addr_t)NULL;
-               *dst_dma_addr = (dma_addr_t)NULL;
-               return DMA_STATUS_SGL_LIST_EMPTY;
-       }
-
-       *src_dma_addr = (dma_addr_t)psgl->phead->src_addr;
-       *dst_dma_addr = (dma_addr_t)psgl->phead->dst_addr;
-
-       if (psgl->phead == psgl->ptail) {
-               /* last descriptor on the list */
-               psgl->phead = NULL;
-               psgl->ptail = NULL;
-       } else {
-               psgl->phead++;
-       }
-
-       return DMA_STATUS_GOOD;
-}
-
-#endif /* DCRNCAP_DMA_SG */
-
-/*
- * The rest of the DMA API, in ppc405_dma.c
- */
-extern int hw_init_dma_channel(unsigned int,  ppc_dma_ch_t *);
-extern int get_channel_config(unsigned int, ppc_dma_ch_t *);
-extern int set_channel_priority(unsigned int, unsigned int);
-extern unsigned int get_peripheral_width(unsigned int);
-extern int alloc_dma_handle(sgl_handle_t *, unsigned int, unsigned int);
-extern void free_dma_handle(sgl_handle_t);
-
-#endif
-#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/ppc4xx_dma.h b/include/asm-ppc/ppc4xx_dma.h
deleted file mode 100644 (file)
index 5b82faf..0000000
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * include/asm-ppc/ppc4xx_dma.h
- *
- * IBM PPC4xx DMA engine library
- *
- * Copyright 2000-2004 MontaVista Software Inc.
- *
- * Cleaned up a bit more, Matt Porter <mporter@kernel.crashing.org>
- *
- * Original code by Armin Kuster <akuster@mvista.com>
- * and Pete Popov <ppopov@mvista.com>
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- * You should have received a copy of the  GNU General Public License along
- * with this program; if not, write  to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASMPPC_PPC4xx_DMA_H
-#define __ASMPPC_PPC4xx_DMA_H
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <asm/mmu.h>
-#include <asm/ibm4xx.h>
-
-#undef DEBUG_4xxDMA
-
-#define MAX_PPC4xx_DMA_CHANNELS                4
-
-/* in arch/ppc/kernel/setup.c -- Cort */
-extern unsigned long DMA_MODE_WRITE, DMA_MODE_READ;
-
-/*
- * Function return status codes
- * These values are used to indicate whether or not the function
- * call was successful, or a bad/invalid parameter was passed.
- */
-#define DMA_STATUS_GOOD                        0
-#define DMA_STATUS_BAD_CHANNEL         1
-#define DMA_STATUS_BAD_HANDLE          2
-#define DMA_STATUS_BAD_MODE            3
-#define DMA_STATUS_NULL_POINTER                4
-#define DMA_STATUS_OUT_OF_MEMORY       5
-#define DMA_STATUS_SGL_LIST_EMPTY      6
-#define DMA_STATUS_GENERAL_ERROR       7
-#define DMA_STATUS_CHANNEL_NOTFREE     8
-
-#define DMA_CHANNEL_BUSY               0x80000000
-
-/*
- * These indicate status as returned from the DMA Status Register.
- */
-#define DMA_STATUS_NO_ERROR    0
-#define DMA_STATUS_CS          1       /* Count Status        */
-#define DMA_STATUS_TS          2       /* Transfer Status     */
-#define DMA_STATUS_DMA_ERROR   3       /* DMA Error Occurred  */
-#define DMA_STATUS_DMA_BUSY    4       /* The channel is busy */
-
-
-/*
- * DMA Channel Control Registers
- */
-
-#ifdef CONFIG_44x
-#define        PPC4xx_DMA_64BIT
-#define DMA_CR_OFFSET 1
-#else
-#define DMA_CR_OFFSET 0
-#endif
-
-#define DMA_CE_ENABLE        (1<<31)   /* DMA Channel Enable */
-#define SET_DMA_CE_ENABLE(x) (((x)&0x1)<<31)
-#define GET_DMA_CE_ENABLE(x) (((x)&DMA_CE_ENABLE)>>31)
-
-#define DMA_CIE_ENABLE        (1<<30)  /* DMA Channel Interrupt Enable */
-#define SET_DMA_CIE_ENABLE(x) (((x)&0x1)<<30)
-#define GET_DMA_CIE_ENABLE(x) (((x)&DMA_CIE_ENABLE)>>30)
-
-#define DMA_TD                (1<<29)
-#define SET_DMA_TD(x)         (((x)&0x1)<<29)
-#define GET_DMA_TD(x)         (((x)&DMA_TD)>>29)
-
-#define DMA_PL                (1<<28)  /* Peripheral Location */
-#define SET_DMA_PL(x)         (((x)&0x1)<<28)
-#define GET_DMA_PL(x)         (((x)&DMA_PL)>>28)
-
-#define EXTERNAL_PERIPHERAL    0
-#define INTERNAL_PERIPHERAL    1
-
-#define SET_DMA_PW(x)     (((x)&0x3)<<(26-DMA_CR_OFFSET))      /* Peripheral Width */
-#define DMA_PW_MASK       SET_DMA_PW(3)
-#define   PW_8                 0
-#define   PW_16                1
-#define   PW_32                2
-#define   PW_64                3
-/* FIXME: Add PW_128 support for 440GP DMA block */
-#define GET_DMA_PW(x)     (((x)&DMA_PW_MASK)>>(26-DMA_CR_OFFSET))
-
-#define DMA_DAI           (1<<(25-DMA_CR_OFFSET))      /* Destination Address Increment */
-#define SET_DMA_DAI(x)    (((x)&0x1)<<(25-DMA_CR_OFFSET))
-
-#define DMA_SAI           (1<<(24-DMA_CR_OFFSET))      /* Source Address Increment */
-#define SET_DMA_SAI(x)    (((x)&0x1)<<(24-DMA_CR_OFFSET))
-
-#define DMA_BEN           (1<<(23-DMA_CR_OFFSET))      /* Buffer Enable */
-#define SET_DMA_BEN(x)    (((x)&0x1)<<(23-DMA_CR_OFFSET))
-
-#define SET_DMA_TM(x)     (((x)&0x3)<<(21-DMA_CR_OFFSET))      /* Transfer Mode */
-#define DMA_TM_MASK       SET_DMA_TM(3)
-#define   TM_PERIPHERAL        0       /* Peripheral */
-#define   TM_RESERVED          1       /* Reserved */
-#define   TM_S_MM              2       /* Memory to Memory */
-#define   TM_D_MM              3       /* Device Paced Memory to Memory */
-#define GET_DMA_TM(x)     (((x)&DMA_TM_MASK)>>(21-DMA_CR_OFFSET))
-
-#define SET_DMA_PSC(x)    (((x)&0x3)<<(19-DMA_CR_OFFSET))      /* Peripheral Setup Cycles */
-#define DMA_PSC_MASK      SET_DMA_PSC(3)
-#define GET_DMA_PSC(x)    (((x)&DMA_PSC_MASK)>>(19-DMA_CR_OFFSET))
-
-#define SET_DMA_PWC(x)    (((x)&0x3F)<<(13-DMA_CR_OFFSET))     /* Peripheral Wait Cycles */
-#define DMA_PWC_MASK      SET_DMA_PWC(0x3F)
-#define GET_DMA_PWC(x)    (((x)&DMA_PWC_MASK)>>(13-DMA_CR_OFFSET))
-
-#define SET_DMA_PHC(x)    (((x)&0x7)<<(10-DMA_CR_OFFSET))      /* Peripheral Hold Cycles */
-#define DMA_PHC_MASK      SET_DMA_PHC(0x7)
-#define GET_DMA_PHC(x)    (((x)&DMA_PHC_MASK)>>(10-DMA_CR_OFFSET))
-
-#define DMA_ETD_OUTPUT     (1<<(9-DMA_CR_OFFSET))      /* EOT pin is a TC output */
-#define SET_DMA_ETD(x)     (((x)&0x1)<<(9-DMA_CR_OFFSET))
-
-#define DMA_TCE_ENABLE     (1<<(8-DMA_CR_OFFSET))
-#define SET_DMA_TCE(x)     (((x)&0x1)<<(8-DMA_CR_OFFSET))
-
-#define DMA_DEC            (1<<(2)     /* Address Decrement */
-#define SET_DMA_DEC(x)     (((x)&0x1)<<2)
-#define GET_DMA_DEC(x)     (((x)&DMA_DEC)>>2)
-
-/*
- * Transfer Modes
- * These modes are defined in a way that makes it possible to
- * simply "or" in the value in the control register.
- */
-
-#define DMA_MODE_MM            (SET_DMA_TM(TM_S_MM))   /* memory to memory */
-
-                               /* Device-paced memory to memory, */
-                               /* device is at source address    */
-#define DMA_MODE_MM_DEVATSRC   (DMA_TD | SET_DMA_TM(TM_D_MM))
-
-                               /* Device-paced memory to memory,      */
-                               /* device is at destination address    */
-#define DMA_MODE_MM_DEVATDST   (SET_DMA_TM(TM_D_MM))
-
-/* 405gp/440gp */
-#define SET_DMA_PREFETCH(x)   (((x)&0x3)<<(4-DMA_CR_OFFSET))   /* Memory Read Prefetch */
-#define DMA_PREFETCH_MASK      SET_DMA_PREFETCH(3)
-#define   PREFETCH_1           0       /* Prefetch 1 Double Word */
-#define   PREFETCH_2           1
-#define   PREFETCH_4           2
-#define GET_DMA_PREFETCH(x) (((x)&DMA_PREFETCH_MASK)>>(4-DMA_CR_OFFSET))
-
-#define DMA_PCE            (1<<(3-DMA_CR_OFFSET))      /* Parity Check Enable */
-#define SET_DMA_PCE(x)     (((x)&0x1)<<(3-DMA_CR_OFFSET))
-#define GET_DMA_PCE(x)     (((x)&DMA_PCE)>>(3-DMA_CR_OFFSET))
-
-/* stb3x */
-
-#define DMA_ECE_ENABLE (1<<5)
-#define SET_DMA_ECE(x) (((x)&0x1)<<5)
-#define GET_DMA_ECE(x) (((x)&DMA_ECE_ENABLE)>>5)
-
-#define DMA_TCD_DISABLE        (1<<4)
-#define SET_DMA_TCD(x) (((x)&0x1)<<4)
-#define GET_DMA_TCD(x) (((x)&DMA_TCD_DISABLE)>>4)
-
-typedef uint32_t sgl_handle_t;
-
-#ifdef CONFIG_PPC4xx_EDMA
-
-#define SGL_LIST_SIZE 4096
-#define DMA_PPC4xx_SIZE SGL_LIST_SIZE
-
-#define SET_DMA_PRIORITY(x)   (((x)&0x3)<<(6-DMA_CR_OFFSET))   /* DMA Channel Priority */
-#define DMA_PRIORITY_MASK SET_DMA_PRIORITY(3)
-#define PRIORITY_LOW           0
-#define PRIORITY_MID_LOW       1
-#define PRIORITY_MID_HIGH      2
-#define PRIORITY_HIGH          3
-#define GET_DMA_PRIORITY(x) (((x)&DMA_PRIORITY_MASK)>>(6-DMA_CR_OFFSET))
-
-/*
- * DMA Polarity Configuration Register
- */
-#define DMAReq_ActiveLow(chan) (1<<(31-(chan*3)))
-#define DMAAck_ActiveLow(chan) (1<<(30-(chan*3)))
-#define EOT_ActiveLow(chan)    (1<<(29-(chan*3)))      /* End of Transfer */
-
-/*
- * DMA Sleep Mode Register
- */
-#define SLEEP_MODE_ENABLE (1<<21)
-
-/*
- * DMA Status Register
- */
-#define DMA_CS0           (1<<31)      /* Terminal Count has been reached */
-#define DMA_CS1           (1<<30)
-#define DMA_CS2           (1<<29)
-#define DMA_CS3           (1<<28)
-
-#define DMA_TS0           (1<<27)      /* End of Transfer has been requested */
-#define DMA_TS1           (1<<26)
-#define DMA_TS2           (1<<25)
-#define DMA_TS3           (1<<24)
-
-#define DMA_CH0_ERR       (1<<23)      /* DMA Chanel 0 Error */
-#define DMA_CH1_ERR       (1<<22)
-#define DMA_CH2_ERR       (1<<21)
-#define DMA_CH3_ERR       (1<<20)
-
-#define DMA_IN_DMA_REQ0   (1<<19)      /* Internal DMA Request is pending */
-#define DMA_IN_DMA_REQ1   (1<<18)
-#define DMA_IN_DMA_REQ2   (1<<17)
-#define DMA_IN_DMA_REQ3   (1<<16)
-
-#define DMA_EXT_DMA_REQ0  (1<<15)      /* External DMA Request is pending */
-#define DMA_EXT_DMA_REQ1  (1<<14)
-#define DMA_EXT_DMA_REQ2  (1<<13)
-#define DMA_EXT_DMA_REQ3  (1<<12)
-
-#define DMA_CH0_BUSY      (1<<11)      /* DMA Channel 0 Busy */
-#define DMA_CH1_BUSY      (1<<10)
-#define DMA_CH2_BUSY       (1<<9)
-#define DMA_CH3_BUSY       (1<<8)
-
-#define DMA_SG0            (1<<7)      /* DMA Channel 0 Scatter/Gather in progress */
-#define DMA_SG1            (1<<6)
-#define DMA_SG2            (1<<5)
-#define DMA_SG3            (1<<4)
-
-/*
- * DMA SG Command Register
- */
-#define SSG_ENABLE(chan)       (1<<(31-chan))  /* Start Scatter Gather */
-#define SSG_MASK_ENABLE(chan)  (1<<(15-chan))  /* Enable writing to SSG0 bit */
-
-/*
- * DMA Scatter/Gather Descriptor Bit fields
- */
-#define SG_LINK            (1<<31)     /* Link */
-#define SG_TCI_ENABLE      (1<<29)     /* Enable Terminal Count Interrupt */
-#define SG_ETI_ENABLE      (1<<28)     /* Enable End of Transfer Interrupt */
-#define SG_ERI_ENABLE      (1<<27)     /* Enable Error Interrupt */
-#define SG_COUNT_MASK       0xFFFF     /* Count Field */
-
-#define SET_DMA_CONTROL \
-               (SET_DMA_CIE_ENABLE(p_init->int_enable) | /* interrupt enable         */ \
-               SET_DMA_BEN(p_init->buffer_enable)     | /* buffer enable            */\
-               SET_DMA_ETD(p_init->etd_output)        | /* end of transfer pin      */ \
-               SET_DMA_TCE(p_init->tce_enable)        | /* terminal count enable    */ \
-                SET_DMA_PL(p_init->pl)                 | /* peripheral location      */ \
-                SET_DMA_DAI(p_init->dai)               | /* dest addr increment      */ \
-                SET_DMA_SAI(p_init->sai)               | /* src addr increment       */ \
-                SET_DMA_PRIORITY(p_init->cp)           |  /* channel priority        */ \
-                SET_DMA_PW(p_init->pwidth)             |  /* peripheral/bus width    */ \
-                SET_DMA_PSC(p_init->psc)               |  /* peripheral setup cycles */ \
-                SET_DMA_PWC(p_init->pwc)               |  /* peripheral wait cycles  */ \
-                SET_DMA_PHC(p_init->phc)               |  /* peripheral hold cycles  */ \
-                SET_DMA_PREFETCH(p_init->pf)              /* read prefetch           */)
-
-#define GET_DMA_POLARITY(chan) (DMAReq_ActiveLow(chan) | DMAAck_ActiveLow(chan) | EOT_ActiveLow(chan))
-
-#elif defined(CONFIG_STBXXX_DMA)               /* stb03xxx */
-
-#define DMA_PPC4xx_SIZE        4096
-
-/*
- * DMA Status Register
- */
-
-#define SET_DMA_PRIORITY(x)   (((x)&0x00800001))       /* DMA Channel Priority */
-#define DMA_PRIORITY_MASK      0x00800001
-#define   PRIORITY_LOW                 0x00000000
-#define   PRIORITY_MID_LOW             0x00000001
-#define   PRIORITY_MID_HIGH            0x00800000
-#define   PRIORITY_HIGH                0x00800001
-#define GET_DMA_PRIORITY(x) (((((x)&DMA_PRIORITY_MASK) &0x00800000) >> 22 ) | (((x)&DMA_PRIORITY_MASK) &0x00000001))
-
-#define DMA_CS0           (1<<31)      /* Terminal Count has been reached */
-#define DMA_CS1           (1<<30)
-#define DMA_CS2           (1<<29)
-#define DMA_CS3           (1<<28)
-
-#define DMA_TS0           (1<<27)      /* End of Transfer has been requested */
-#define DMA_TS1           (1<<26)
-#define DMA_TS2           (1<<25)
-#define DMA_TS3           (1<<24)
-
-#define DMA_CH0_ERR       (1<<23)      /* DMA Chanel 0 Error */
-#define DMA_CH1_ERR       (1<<22)
-#define DMA_CH2_ERR       (1<<21)
-#define DMA_CH3_ERR       (1<<20)
-
-#define DMA_CT0                  (1<<19)       /* Chained transfere */
-
-#define DMA_IN_DMA_REQ0   (1<<18)      /* Internal DMA Request is pending */
-#define DMA_IN_DMA_REQ1   (1<<17)
-#define DMA_IN_DMA_REQ2   (1<<16)
-#define DMA_IN_DMA_REQ3   (1<<15)
-
-#define DMA_EXT_DMA_REQ0  (1<<14)      /* External DMA Request is pending */
-#define DMA_EXT_DMA_REQ1  (1<<13)
-#define DMA_EXT_DMA_REQ2  (1<<12)
-#define DMA_EXT_DMA_REQ3  (1<<11)
-
-#define DMA_CH0_BUSY      (1<<10)      /* DMA Channel 0 Busy */
-#define DMA_CH1_BUSY      (1<<9)
-#define DMA_CH2_BUSY       (1<<8)
-#define DMA_CH3_BUSY       (1<<7)
-
-#define DMA_CT1            (1<<6)      /* Chained transfere */
-#define DMA_CT2            (1<<5)
-#define DMA_CT3            (1<<4)
-
-#define DMA_CH_ENABLE (1<<7)
-#define SET_DMA_CH(x) (((x)&0x1)<<7)
-#define GET_DMA_CH(x) (((x)&DMA_CH_ENABLE)>>7)
-
-/* STBx25xxx dma unique */
-/* enable device port on a dma channel
- * example ext 0 on dma 1
- */
-
-#define        SSP0_RECV       15
-#define        SSP0_XMIT       14
-#define EXT_DMA_0      12
-#define        SC1_XMIT        11
-#define SC1_RECV       10
-#define EXT_DMA_2      9
-#define        EXT_DMA_3       8
-#define SERIAL2_XMIT   7
-#define SERIAL2_RECV   6
-#define SC0_XMIT       5
-#define        SC0_RECV        4
-#define        SERIAL1_XMIT    3
-#define SERIAL1_RECV   2
-#define        SERIAL0_XMIT    1
-#define SERIAL0_RECV   0
-
-#define DMA_CHAN_0     1
-#define DMA_CHAN_1     2
-#define DMA_CHAN_2     3
-#define DMA_CHAN_3     4
-
-/* end STBx25xx */
-
-/*
- * Bit 30 must be one for Redwoods, otherwise transfers may receive errors.
- */
-#define DMA_CR_MB0 0x2
-
-#define SET_DMA_CONTROL \
-                       (SET_DMA_CIE_ENABLE(p_init->int_enable) |  /* interrupt enable         */ \
-               SET_DMA_ETD(p_init->etd_output)        |  /* end of transfer pin      */ \
-               SET_DMA_TCE(p_init->tce_enable)        |  /* terminal count enable    */ \
-               SET_DMA_PL(p_init->pl)                 |  /* peripheral location      */ \
-               SET_DMA_DAI(p_init->dai)               |  /* dest addr increment      */ \
-               SET_DMA_SAI(p_init->sai)               |  /* src addr increment       */ \
-               SET_DMA_PRIORITY(p_init->cp)           |  /* channel priority        */  \
-               SET_DMA_PW(p_init->pwidth)             |  /* peripheral/bus width    */ \
-               SET_DMA_PSC(p_init->psc)               |  /* peripheral setup cycles */ \
-               SET_DMA_PWC(p_init->pwc)               |  /* peripheral wait cycles  */ \
-               SET_DMA_PHC(p_init->phc)               |  /* peripheral hold cycles  */ \
-               SET_DMA_TCD(p_init->tcd_disable)          |  /* TC chain mode disable   */ \
-               SET_DMA_ECE(p_init->ece_enable)   |  /* ECE chanin mode enable  */ \
-               SET_DMA_CH(p_init->ch_enable)   |    /* Chain enable            */ \
-               DMA_CR_MB0                              /* must be one */)
-
-#define GET_DMA_POLARITY(chan) chan
-
-#endif
-
-typedef struct {
-       unsigned short in_use;  /* set when channel is being used, clr when
-                                * available.
-                                */
-       /*
-        * Valid polarity settings:
-        *   DMAReq_ActiveLow(n)
-        *   DMAAck_ActiveLow(n)
-        *   EOT_ActiveLow(n)
-        *
-        *   n is 0 to max dma chans
-        */
-       unsigned int polarity;
-
-       char buffer_enable;     /* Boolean: buffer enable            */
-       char tce_enable;        /* Boolean: terminal count enable    */
-       char etd_output;        /* Boolean: eot pin is a tc output   */
-       char pce;               /* Boolean: parity check enable      */
-
-       /*
-        * Peripheral location:
-        * INTERNAL_PERIPHERAL (UART0 on the 405GP)
-        * EXTERNAL_PERIPHERAL
-        */
-       char pl;                /* internal/external peripheral      */
-
-       /*
-        * Valid pwidth settings:
-        *   PW_8
-        *   PW_16
-        *   PW_32
-        *   PW_64
-        */
-       unsigned int pwidth;
-
-       char dai;               /* Boolean: dst address increment   */
-       char sai;               /* Boolean: src address increment   */
-
-       /*
-        * Valid psc settings: 0-3
-        */
-       unsigned int psc;       /* Peripheral Setup Cycles         */
-
-       /*
-        * Valid pwc settings:
-        * 0-63
-        */
-       unsigned int pwc;       /* Peripheral Wait Cycles          */
-
-       /*
-        * Valid phc settings:
-        * 0-7
-        */
-       unsigned int phc;       /* Peripheral Hold Cycles          */
-
-       /*
-        * Valid cp (channel priority) settings:
-        *   PRIORITY_LOW
-        *   PRIORITY_MID_LOW
-        *   PRIORITY_MID_HIGH
-        *   PRIORITY_HIGH
-        */
-       unsigned int cp;        /* channel priority                */
-
-       /*
-        * Valid pf (memory read prefetch) settings:
-        *
-        *   PREFETCH_1
-        *   PREFETCH_2
-        *   PREFETCH_4
-        */
-       unsigned int pf;        /* memory read prefetch            */
-
-       /*
-        * Boolean: channel interrupt enable
-        * NOTE: for sgl transfers, only the last descriptor will be setup to
-        * interrupt.
-        */
-       char int_enable;
-
-       char shift;             /* easy access to byte_count shift, based on */
-       /* the width of the channel                  */
-
-       uint32_t control;       /* channel control word                      */
-
-       /* These variabled are used ONLY in single dma transfers              */
-       unsigned int mode;      /* transfer mode                     */
-       phys_addr_t addr;
-       char ce;                /* channel enable */
-#ifdef CONFIG_STB03xxx
-       char ch_enable;
-       char tcd_disable;
-       char ece_enable;
-       char td;                /* transfer direction */
-#endif
-
-} ppc_dma_ch_t;
-
-/*
- * PPC44x DMA implementations have a slightly different
- * descriptor layout.  Probably moved about due to the
- * change to 64-bit addresses and link pointer. I don't
- * know why they didn't just leave control_count after
- * the dst_addr.
- */
-#ifdef PPC4xx_DMA_64BIT
-typedef struct {
-       uint32_t control;
-       uint32_t control_count;
-       phys_addr_t src_addr;
-       phys_addr_t dst_addr;
-       phys_addr_t next;
-} ppc_sgl_t;
-#else
-typedef struct {
-       uint32_t control;
-       phys_addr_t src_addr;
-       phys_addr_t dst_addr;
-       uint32_t control_count;
-       uint32_t next;
-} ppc_sgl_t;
-#endif
-
-typedef struct {
-       unsigned int dmanr;
-       uint32_t control;       /* channel ctrl word; loaded from each descrptr */
-       uint32_t sgl_control;   /* LK, TCI, ETI, and ERI bits in sgl descriptor */
-       dma_addr_t dma_addr;    /* dma (physical) address of this list          */
-       ppc_sgl_t *phead;
-       dma_addr_t phead_dma;
-       ppc_sgl_t *ptail;
-       dma_addr_t ptail_dma;
-} sgl_list_info_t;
-
-typedef struct {
-       phys_addr_t *src_addr;
-       phys_addr_t *dst_addr;
-       phys_addr_t dma_src_addr;
-       phys_addr_t dma_dst_addr;
-} pci_alloc_desc_t;
-
-extern ppc_dma_ch_t dma_channels[];
-
-/*
- * The DMA API are in ppc4xx_dma.c and ppc4xx_sgdma.c
- */
-extern int ppc4xx_init_dma_channel(unsigned int, ppc_dma_ch_t *);
-extern int ppc4xx_get_channel_config(unsigned int, ppc_dma_ch_t *);
-extern int ppc4xx_set_channel_priority(unsigned int, unsigned int);
-extern unsigned int ppc4xx_get_peripheral_width(unsigned int);
-extern void ppc4xx_set_sg_addr(int, phys_addr_t);
-extern int ppc4xx_add_dma_sgl(sgl_handle_t, phys_addr_t, phys_addr_t, unsigned int);
-extern void ppc4xx_enable_dma_sgl(sgl_handle_t);
-extern void ppc4xx_disable_dma_sgl(sgl_handle_t);
-extern int ppc4xx_get_dma_sgl_residue(sgl_handle_t, phys_addr_t *, phys_addr_t *);
-extern int ppc4xx_delete_dma_sgl_element(sgl_handle_t, phys_addr_t *, phys_addr_t *);
-extern int ppc4xx_alloc_dma_handle(sgl_handle_t *, unsigned int, unsigned int);
-extern void ppc4xx_free_dma_handle(sgl_handle_t);
-extern int ppc4xx_get_dma_status(void);
-extern void ppc4xx_set_src_addr(int dmanr, phys_addr_t src_addr);
-extern void ppc4xx_set_dst_addr(int dmanr, phys_addr_t dst_addr);
-extern void ppc4xx_enable_dma(unsigned int dmanr);
-extern void ppc4xx_disable_dma(unsigned int dmanr);
-extern void ppc4xx_set_dma_count(unsigned int dmanr, unsigned int count);
-extern int ppc4xx_get_dma_residue(unsigned int dmanr);
-extern void ppc4xx_set_dma_addr2(unsigned int dmanr, phys_addr_t src_dma_addr,
-                                phys_addr_t dst_dma_addr);
-extern int ppc4xx_enable_dma_interrupt(unsigned int dmanr);
-extern int ppc4xx_disable_dma_interrupt(unsigned int dmanr);
-extern int ppc4xx_clr_dma_status(unsigned int dmanr);
-extern int ppc4xx_map_dma_port(unsigned int dmanr, unsigned int ocp_dma,short dma_chan);
-extern int ppc4xx_disable_dma_port(unsigned int dmanr, unsigned int ocp_dma,short dma_chan);
-extern int ppc4xx_set_dma_mode(unsigned int dmanr, unsigned int mode);
-
-/* These are in kernel/dma.c: */
-
-/* reserve a DMA channel */
-extern int request_dma(unsigned int dmanr, const char *device_id);
-/* release it again */
-extern void free_dma(unsigned int dmanr);
-#endif
-#endif                         /* __KERNEL__ */
diff --git a/include/asm-ppc/relay.h b/include/asm-ppc/relay.h
new file mode 100644 (file)
index 0000000..c5b8526
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_PPC_RELAY_H
+#define _ASM_PPC_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 3d29914..f4325ea 100644 (file)
@@ -36,7 +36,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-ppc/rmap.h b/include/asm-ppc/rmap.h
deleted file mode 100644 (file)
index 50556b5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _PPC_RMAP_H
-#define _PPC_RMAP_H
-
-/* PPC calls pte_alloc() before mem_map[] is setup ... */
-#define BROKEN_PPC_PTE_ALLOC_ONE
-
-#include <asm-generic/rmap.h>
-
-#endif
index d2d19ee..ad1c621 100644 (file)
@@ -2,8 +2,8 @@
 #ifndef _PPC_SETUP_H
 #define _PPC_SETUP_H
 
-#define m68k_num_memory num_memory
-#define m68k_memory memory
+#define m68k_num_memory ppc_num_memory
+#define m68k_memory ppc_memory
 
 #include <asm-m68k/setup.h>
 /* We have a bigger command line buffer. */
index b9d763e..10aeae0 100644 (file)
@@ -331,6 +331,8 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
        __copy_tofrom_user((void __user *)(to), (from), (size))
 #define __copy_to_user(to, from, size) \
        __copy_tofrom_user((to), (void __user *)(from), (size))
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
 
 extern unsigned long __clear_user(void __user *addr, unsigned long size);
 
index 57fb02c..64e443d 100644 (file)
 #define __NR_fadvise64_64      254
 #define __NR_rtas              255
 /* Number 256 is reserved for sys_debug_setcontext */
-/* Number 257 is reserved for vserver */
+#define __NR_vserver           257
 /* Number 258 is reserved for new sys_remap_file_pages */
 /* Number 259 is reserved for new sys_mbind */
 /* Number 260 is reserved for new sys_get_mempolicy */
 #define __NR_mq_notify         266
 #define __NR_mq_getsetattr     267
 #define __NR_kexec_load                268
+#define __NR_ioprio_set                269
+#define __NR_ioprio_get                270
 
-#define __NR_syscalls          269
+#define __NR_syscalls          271
 
 #define __NR(n)        #n
 
diff --git a/include/asm-ppc64/cpumask.h b/include/asm-ppc64/cpumask.h
deleted file mode 100644 (file)
index 0914511..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_PPC64_CPUMASK_H
-#define _ASM_PPC64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_PPC64_CPUMASK_H */
index 842560d..59a3555 100644 (file)
@@ -28,6 +28,7 @@
 #define O_LARGEFILE     0200000
 #define O_DIRECT       0400000 /* direct disk access hint */
 #define O_NOATIME      01000000
+#define O_ATOMICLOOKUP 02000000 /* do atomic file lookup */
 
 #define F_DUPFD                0       /* dup */
 #define F_GETFD                1       /* get close_on_exec */
diff --git a/include/asm-ppc64/hvcserver.h b/include/asm-ppc64/hvcserver.h
deleted file mode 100644 (file)
index cee9a14..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * hvcserver.h
- * Copyright (C) 2004 Ryan S Arnold, IBM Corporation
- *
- * PPC64 virtual I/O console server support.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-
-#ifndef _PPC64_HVCSERVER_H
-#define _PPC64_HVCSERVER_H
-
-#include <linux/list.h>
-
-/* Converged Location Code length */
-#define HVCS_CLC_LENGTH        79
-
-struct hvcs_partner_info {
-       struct list_head node;
-       unsigned int unit_address;
-       unsigned int partition_ID;
-       char location_code[HVCS_CLC_LENGTH + 1]; /* CLC + 1 null-term char */
-};
-
-extern int hvcs_free_partner_info(struct list_head *head);
-extern int hvcs_get_partner_info(unsigned int unit_address,
-               struct list_head *head, unsigned long *pi_buff);
-extern int hvcs_register_connection(unsigned int unit_address,
-               unsigned int p_partition_ID, unsigned int p_unit_address);
-extern int hvcs_free_connection(unsigned int unit_address);
-
-#endif /* _PPC64_HVCSERVER_H */
diff --git a/include/asm-ppc64/init.h b/include/asm-ppc64/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
diff --git a/include/asm-ppc64/netdump.h b/include/asm-ppc64/netdump.h
new file mode 100644 (file)
index 0000000..8b9fef2
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _ASM_PPC64_NETDUMP_H_
+#define _ASM_PPC64_NETDUMP_H_
+
+#include <asm-generic/netdump.h>
+
+#endif /* _ASM_PPC64_NETDUMP_H_ */
index a30e2a9..9d390be 100644 (file)
@@ -246,5 +246,7 @@ extern int page_is_ram(unsigned long physaddr);
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 #endif /* _PPC64_PAGE_H */
index 8b79f36..cddaa2f 100644 (file)
 
 extern kmem_cache_t *zero_cache;
 
+/* Dummy functions since we don't support execshield on ppc */
+#define arch_add_exec_range(mm, limit) do { ; } while (0)
+#define arch_flush_exec_range(mm)      do { ; } while (0)
+#define arch_remove_exec_range(mm, limit) do { ; } while (0)
+
 /*
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
index d5e3837..0378011 100644 (file)
@@ -633,6 +633,8 @@ static inline void prefetchw(const void *x)
 
 #endif /* ASSEMBLY */
 
+#define HAVE_ARCH_PICK_MMAP_LAYOUT
+
 /*
  * Number of entries in the SLB. If this ever changes we should handle
  * it with a use a cpu feature fixup.
diff --git a/include/asm-ppc64/relay.h b/include/asm-ppc64/relay.h
new file mode 100644 (file)
index 0000000..3c428ef
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_PPC64_RELAY_H
+#define _ASM_PPC64_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index c54e9d6..d95a919 100644 (file)
@@ -45,7 +45,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-ppc64/rmap.h b/include/asm-ppc64/rmap.h
deleted file mode 100644 (file)
index cf58a01..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _PPC64_RMAP_H
-#define _PPC64_RMAP_H
-
-/* PPC64 calls pte_alloc() before mem_map[] is setup ... */
-#define BROKEN_PPC_PTE_ALLOC_ONE
-
-#include <asm-generic/rmap.h>
-
-#endif
index 77906c9..16dbcb9 100644 (file)
@@ -281,6 +281,9 @@ extern unsigned long copy_in_user(void __user *to, const void __user *from,
 
 extern unsigned long __clear_user(void __user *addr, unsigned long size);
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 static inline unsigned long
 clear_user(void __user *addr, unsigned long size)
 {
index 20c4b3a..414c037 100644 (file)
 #define __NR_fadvise64_64      254
 #define __NR_rtas              255
 /* Number 256 is reserved for sys_debug_setcontext */
-/* Number 257 is reserved for vserver */
+#define __NR_vserver           257
 /* Number 258 is reserved for new sys_remap_file_pages */
 /* Number 259 is reserved for new sys_mbind */
 /* Number 260 is reserved for new sys_get_mempolicy */
diff --git a/include/asm-s390/cpumask.h b/include/asm-s390/cpumask.h
deleted file mode 100644 (file)
index 4deef16..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_S390_CPUMASK_H
-#define _ASM_S390_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_S390_CPUMASK_H */
index 48f692b..c36e16d 100644 (file)
@@ -28,6 +28,7 @@
 #define O_DIRECTORY    0200000 /* must be a directory */
 #define O_NOFOLLOW     0400000 /* don't follow links */
 #define O_NOATIME      01000000
+#define O_ATOMICLOOKUP 02000000        /* do atomic file lookup (tux) */
 
 #define F_DUPFD                0       /* dup */
 #define F_GETFD                1       /* get close_on_exec */
diff --git a/include/asm-s390/init.h b/include/asm-s390/init.h
deleted file mode 100644 (file)
index 16fcb9a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- *  include/asm-s390/init.h
- *
- *  S390 version
- */
-
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
diff --git a/include/asm-s390/netdump.h b/include/asm-s390/netdump.h
new file mode 100644 (file)
index 0000000..0ad1104
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _ASM_S390_NETDUMP_H_
+#define _ASM_S390_NETDUMP_H_
+
+#include <asm-generic/netdump.h>
+
+#endif /* _ASM_S390_NETDUMP_H_ */
index 6bed8d9..f377bc1 100644 (file)
@@ -181,6 +181,8 @@ typedef struct { unsigned long pgd; } pgd_t;
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _S390_PAGE_H */
index 9030813..8b9bfd2 100644 (file)
 #include <linux/gfp.h>
 #include <linux/mm.h>
 
+#define arch_add_exec_range(mm, limit) do { ; } while (0)
+#define arch_flush_exec_range(mm)      do { ; } while (0)
+#define arch_remove_exec_range(mm, limit) do { ; } while (0)
+
 #define check_pgt_cache()      do {} while (0)
 
 extern void diag10(unsigned long addr);
index 4c9d607..b99592e 100644 (file)
@@ -76,6 +76,8 @@ extern struct task_struct *last_task_used_math;
 
 #define MM_VM_SIZE(mm)         DEFAULT_TASK_SIZE
 
+#define HAVE_ARCH_PICK_MMAP_LAYOUT
+
 typedef struct {
         __u32 ar4;
 } mm_segment_t;
diff --git a/include/asm-s390/relay.h b/include/asm-s390/relay.h
new file mode 100644 (file)
index 0000000..502eb3b
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_S390_RELAY_H
+#define _ASM_S390_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 5f0f2ba..68ba34e 100644 (file)
@@ -47,7 +47,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        { INR_OPEN, INR_OPEN },                         \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-s390/rmap.h b/include/asm-s390/rmap.h
deleted file mode 100644 (file)
index 43d6a87..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _S390_RMAP_H
-#define _S390_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index bec57b7..0b654b3 100644 (file)
@@ -272,6 +272,9 @@ __copy_to_user(void __user *to, const void *from, unsigned long n)
        return __copy_to_user_asm(from, n, to);
 }
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 /**
  * copy_to_user: - Copy a block of data into user space.
  * @to:   Destination address, in user space.
index 4d46012..3af9562 100644 (file)
 #define __NR_clock_gettime     (__NR_timer_create+6)
 #define __NR_clock_getres      (__NR_timer_create+7)
 #define __NR_clock_nanosleep   (__NR_timer_create+8)
-/* Number 263 is reserved for vserver */
+#define __NR_vserver           263
 #define __NR_fadvise64_64      264
 #define __NR_statfs64          265
 #define __NR_fstatfs64         266
diff --git a/include/asm-sh/cpumask.h b/include/asm-sh/cpumask.h
deleted file mode 100644 (file)
index deaf3bb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_SH_CPUMASK_H
-#define _ASM_SH_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_SH_CPUMASK_H */
diff --git a/include/asm-sh/init.h b/include/asm-sh/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
index edd2934..a19c266 100644 (file)
@@ -133,6 +133,8 @@ static __inline__ int get_order(unsigned long size)
 
 #endif
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_SH_PAGE_H */
diff --git a/include/asm-sh/relay.h b/include/asm-sh/relay.h
new file mode 100644 (file)
index 0000000..fd8b764
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_SH_RELAY_H
+#define _ASM_SH_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 73e517a..b3d6ae5 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-sh/rmap.h b/include/asm-sh/rmap.h
deleted file mode 100644 (file)
index 31db8cc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _SH_RMAP_H
-#define _SH_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index 9186bba..df9a9b2 100644 (file)
@@ -446,6 +446,10 @@ __copy_res; })
        __copy_user((void *)(to),               \
                    (void *)(from), n)
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
+
 #define copy_from_user(to,from,n) ({ \
 void *__copy_to = (void *) (to); \
 void *__copy_from = (void *) (from); \
diff --git a/include/asm-sh64/page.h b/include/asm-sh64/page.h
deleted file mode 100644 (file)
index e1f7f5a..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#ifndef __ASM_SH64_PAGE_H
-#define __ASM_SH64_PAGE_H
-
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * include/asm-sh64/page.h
- *
- * Copyright (C) 2000, 2001  Paolo Alberelli
- * Copyright (C) 2003, 2004  Paul Mundt
- *
- * benedict.gaster@superh.com 19th, 24th July 2002.
- *
- * Modified to take account of enabling for D-CACHE support.
- *
- */
-
-#include <linux/config.h>
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT     12
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE      4096
-#else
-#define PAGE_SIZE      (1UL << PAGE_SHIFT)
-#endif
-#define PAGE_MASK      (~(PAGE_SIZE-1))
-#define PTE_MASK       PAGE_MASK
-
-#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
-#define HPAGE_SHIFT    16
-#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
-#define HPAGE_SHIFT    20
-#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB)
-#define HPAGE_SHIFT    29
-#endif
-
-#ifdef CONFIG_HUGETLB_PAGE
-#define HPAGE_SIZE             (1UL << HPAGE_SHIFT)
-#define HPAGE_MASK             (~(HPAGE_SIZE-1))
-#define HUGETLB_PAGE_ORDER     (HPAGE_SHIFT-PAGE_SHIFT)
-#endif
-
-#ifdef __KERNEL__
-#ifndef __ASSEMBLY__
-
-extern struct page *mem_map;
-extern void sh64_page_clear(void *page);
-extern void sh64_page_copy(void *from, void *to);
-
-#define clear_page(page)               sh64_page_clear(page)
-#define copy_page(to,from)             sh64_page_copy(from, to)
-
-#if defined(CONFIG_DCACHE_DISABLED)
-
-#define clear_user_page(page, vaddr, pg)       clear_page(page)
-#define copy_user_page(to, from, vaddr, pg)    copy_page(to, from)
-
-#else
-
-extern void clear_user_page(void *to, unsigned long address, struct page *pg);
-extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
-
-#endif /* defined(CONFIG_DCACHE_DISABLED) */
-
-/*
- * These are used to make use of C type-checking..
- */
-typedef struct { unsigned long long pte; } pte_t;
-typedef struct { unsigned long pmd; } pmd_t;
-typedef struct { unsigned long pgd; } pgd_t;
-typedef struct { unsigned long pgprot; } pgprot_t;
-
-#define pte_val(x)     ((x).pte)
-#define pmd_val(x)     ((x).pmd)
-#define pgd_val(x)     ((x).pgd)
-#define pgprot_val(x)  ((x).pgprot)
-
-#define __pte(x) ((pte_t) { (x) } )
-#define __pmd(x) ((pmd_t) { (x) } )
-#define __pgd(x) ((pgd_t) { (x) } )
-#define __pgprot(x)    ((pgprot_t) { (x) } )
-
-#endif /* !__ASSEMBLY__ */
-
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-/*
- * Kconfig defined.
- */
-#define __MEMORY_START         (CONFIG_MEMORY_START)
-#define PAGE_OFFSET            (CONFIG_CACHED_MEMORY_OFFSET)
-
-#define __pa(x)                        ((unsigned long)(x)-PAGE_OFFSET)
-#define __va(x)                        ((void *)((unsigned long)(x)+PAGE_OFFSET))
-#define MAP_NR(addr)           ((__pa(addr)-__MEMORY_START) >> PAGE_SHIFT)
-#define VALID_PAGE(page)       ((page - mem_map) < max_mapnr)
-
-#define phys_to_page(phys)     (mem_map + (((phys) - __MEMORY_START) >> PAGE_SHIFT))
-#define page_to_phys(page)     (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
-
-/* PFN start number, because of __MEMORY_START */
-#define PFN_START              (__MEMORY_START >> PAGE_SHIFT)
-
-#define pfn_to_page(pfn)       (mem_map + (pfn) - PFN_START)
-#define page_to_pfn(page)      ((unsigned long)((page) - mem_map) + PFN_START)
-#define virt_to_page(kaddr)    pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
-#define pfn_valid(pfn)         (((pfn) - PFN_START) < max_mapnr)
-#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
-
-#define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
-                                VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
-
-#ifndef __ASSEMBLY__
-
-/* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
-{
-       int order;
-
-       size = (size-1) >> (PAGE_SHIFT-1);
-       order = -1;
-       do {
-               size >>= 1;
-               order++;
-       } while (size);
-       return order;
-}
-
-#endif
-
-#endif /* __KERNEL__ */
-
-#endif /* __ASM_SH64_PAGE_H */
index 0207bae..588065c 100644 (file)
@@ -261,6 +261,9 @@ if (__copy_from_user(to,from,n)) \
        return retval; \
 })
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 /* XXX: Not sure it works well..
    should be such that: 4byte clear and the rest. */
 extern __kernel_size_t __clear_user(void *addr, __kernel_size_t size);
diff --git a/include/asm-sparc/cpumask.h b/include/asm-sparc/cpumask.h
deleted file mode 100644 (file)
index 272f31d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_SPARC_CPUMASK_H
-#define _ASM_SPARC_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_SPARC_CPUMASK_H */
index df9c75d..8464d26 100644 (file)
@@ -20,6 +20,7 @@
 #define O_DIRECTORY    0x10000 /* must be a directory */
 #define O_NOFOLLOW     0x20000 /* don't follow links */
 #define O_LARGEFILE    0x40000
+#define O_ATOMICLOOKUP 0x80000 /* do atomic file lookup */
 #define O_DIRECT        0x100000 /* direct disk access hint */
 #define O_NOATIME      0x200000
 
diff --git a/include/asm-sparc/init.h b/include/asm-sparc/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
index 383060e..fb230be 100644 (file)
@@ -176,6 +176,8 @@ extern unsigned long pfn_base;
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _SPARC_PAGE_H */
index 126800a..8db5662 100644 (file)
@@ -66,4 +66,8 @@ BTFIXUPDEF_CALL(void, pte_free, struct page *)
 #define pte_free(pte)          BTFIXUP_CALL(pte_free)(pte)
 #define __pte_free_tlb(tlb, pte)       pte_free(pte)
 
+#define arch_add_exec_range(mm, limit)         do { ; } while (0)
+#define arch_flush_exec_range(mm)              do { ; } while (0)
+#define arch_remove_exec_range(mm, limit)      do { ; } while (0)
+
 #endif /* _SPARC_PGALLOC_H */
diff --git a/include/asm-sparc/relay.h b/include/asm-sparc/relay.h
new file mode 100644 (file)
index 0000000..2141eac
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_SPARC_RELAY_H
+#define _ASM_SPARC_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 58e90f7..7df635a 100644 (file)
@@ -44,7 +44,7 @@
     {       0, RLIM_INFINITY},         \
     {RLIM_INFINITY, RLIM_INFINITY},    \
     {INR_OPEN, INR_OPEN}, {0, 0},      \
-    {RLIM_INFINITY, RLIM_INFINITY},    \
+    {32768,         32768},    \
     {RLIM_INFINITY, RLIM_INFINITY},    \
     {RLIM_INFINITY, RLIM_INFINITY},    \
     {MAX_SIGPENDING, MAX_SIGPENDING},  \
diff --git a/include/asm-sparc/rmap.h b/include/asm-sparc/rmap.h
deleted file mode 100644 (file)
index 06063cf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _SPARC_RMAP_H
-#define _SPARC_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index 8ef47f1..b6a87c2 100644 (file)
@@ -322,6 +322,9 @@ static inline unsigned long __copy_from_user(void *to, const void __user *from,
        return __copy_user((void __user *) to, from, n);
 }
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 static inline unsigned long __clear_user(void __user *addr, unsigned long size)
 {
        unsigned long ret;
index 62eaacd..b742c9f 100644 (file)
 #define __NR_timer_getoverrun  264
 #define __NR_timer_delete      265
 #define __NR_timer_create      266
-/* #define __NR_vserver                267 Reserved for VSERVER */
+#define __NR_vserver           267
 #define __NR_io_setup          268
 #define __NR_io_destroy                269
 #define __NR_io_submit         270
diff --git a/include/asm-sparc64/cpumask.h b/include/asm-sparc64/cpumask.h
deleted file mode 100644 (file)
index ee60cae..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_SPARC64_CPUMASK_H
-#define _ASM_SPARC64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_SPARC64_CPUMASK_H */
index e36def0..42c8ab4 100644 (file)
@@ -20,6 +20,7 @@
 #define O_DIRECTORY    0x10000 /* must be a directory */
 #define O_NOFOLLOW     0x20000 /* don't follow links */
 #define O_LARGEFILE    0x40000
+#define O_ATOMICLOOKUP 0x80000 /* do atomic file lookup */
 #define O_DIRECT        0x100000 /* direct disk access hint */
 #define O_NOATIME      0x200000
 
diff --git a/include/asm-sparc64/init.h b/include/asm-sparc64/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
index 7259d99..45ff8ed 100644 (file)
@@ -165,6 +165,8 @@ static __inline__ int get_order(unsigned long size)
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
+#define devmem_is_allowed(x) 1
+
 #endif /* !(__KERNEL__) */
 
 #endif /* !(_SPARC64_PAGE_H) */
index fa5c704..91b30ef 100644 (file)
@@ -261,4 +261,8 @@ static inline void pte_free(struct page *ptepage)
 #define pgd_free(pgd)          free_pgd_fast(pgd)
 #define pgd_alloc(mm)          get_pgd_fast()
 
+#define arch_add_exec_range(mm, limit)         do { ; } while (0)
+#define arch_flush_exec_range(mm)              do { ; } while (0)
+#define arch_remove_exec_range(mm, limit)      do { ; } while (0)
+
 #endif /* _SPARC64_PGALLOC_H */
diff --git a/include/asm-sparc64/relay.h b/include/asm-sparc64/relay.h
new file mode 100644 (file)
index 0000000..72ea164
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_SPARC64_RELAY_H
+#define _ASM_SPARC64_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 4a77dd6..2716da1 100644 (file)
@@ -43,7 +43,7 @@
     {       0, RLIM_INFINITY},         \
     {RLIM_INFINITY, RLIM_INFINITY},    \
     {INR_OPEN, INR_OPEN}, {0, 0},      \
-    {RLIM_INFINITY, RLIM_INFINITY},    \
+    {32768,      32768           },    \
     {RLIM_INFINITY, RLIM_INFINITY},    \
     {RLIM_INFINITY, RLIM_INFINITY},    \
     {MAX_SIGPENDING, MAX_SIGPENDING},  \
diff --git a/include/asm-sparc64/rmap.h b/include/asm-sparc64/rmap.h
deleted file mode 100644 (file)
index 681849b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _SPARC64_RMAP_H
-#define _SPARC64_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index e1ce87c..01198c7 100644 (file)
@@ -264,6 +264,8 @@ extern unsigned long __copy_in_user(void __user *to, const void __user *from,
 #define copy_from_user __copy_from_user
 #define copy_to_user __copy_to_user
 #define copy_in_user __copy_in_user
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
 
 extern unsigned long __bzero_noasi(void __user *, unsigned long);
 
index 0ce57c1..0a06763 100644 (file)
 #define __NR_timer_getoverrun  264
 #define __NR_timer_delete      265
 #define __NR_timer_create      266
-/* #define __NR_vserver                267 Reserved for VSERVER */
+#define __NR_vserver           267
 #define __NR_io_setup          268
 #define __NR_io_destroy                269
 #define __NR_io_submit         270
index a23261b..85fd033 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -56,6 +56,93 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
        pr_reg[16] = PT_REGS_SS(regs);          \
 } while(0);
 
+#if 0 /* Turn this back on when UML has VSYSCALL working */
+#define VSYSCALL_BASE  (__fix_to_virt(FIX_VSYSCALL))
+#else
+#define VSYSCALL_BASE  0
+#endif
+
+#define VSYSCALL_EHDR  ((const struct elfhdr *) VSYSCALL_BASE)
+#define VSYSCALL_ENTRY ((unsigned long) &__kernel_vsyscall)
+extern void *__kernel_vsyscall;
+
+/*
+ * Architecture-neutral AT_ values in 0-17, leave some room
+ * for more of them, start the x86-specific ones at 32.
+ */
+#define AT_SYSINFO             32
+#define AT_SYSINFO_EHDR                33
+
+#define ARCH_DLINFO                                            \
+do {                                                           \
+               NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY);        \
+               NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL_BASE);    \
+} while (0)
+
+/*
+ * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
+ * extra segments containing the vsyscall DSO contents.  Dumping its
+ * contents makes post-mortem fully interpretable later without matching up
+ * the same kernel and hardware config to see what PC values meant.
+ * Dumping its extra ELF program headers includes all the other information
+ * a debugger needs to easily find how the vsyscall DSO was being used.
+ */
+#if 0
+#define ELF_CORE_EXTRA_PHDRS           (VSYSCALL_EHDR->e_phnum)
+#endif
+
+#undef ELF_CORE_EXTRA_PHDRS
+
+#if 0
+#define ELF_CORE_WRITE_EXTRA_PHDRS                                           \
+do {                                                                         \
+       const struct elf_phdr *const vsyscall_phdrs =                         \
+               (const struct elf_phdr *) (VSYSCALL_BASE                      \
+                                          + VSYSCALL_EHDR->e_phoff);         \
+       int i;                                                                \
+       Elf32_Off ofs = 0;                                                    \
+       for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
+               struct elf_phdr phdr = vsyscall_phdrs[i];                     \
+               if (phdr.p_type == PT_LOAD) {                                 \
+                       ofs = phdr.p_offset = offset;                         \
+                       offset += phdr.p_filesz;                              \
+               }                                                             \
+               else                                                          \
+                       phdr.p_offset += ofs;                                 \
+               phdr.p_paddr = 0; /* match other core phdrs */                \
+               DUMP_WRITE(&phdr, sizeof(phdr));                              \
+       }                                                                     \
+} while (0)
+#define ELF_CORE_WRITE_EXTRA_DATA                                            \
+do {                                                                         \
+       const struct elf_phdr *const vsyscall_phdrs =                         \
+               (const struct elf_phdr *) (VSYSCALL_BASE                      \
+                                          + VSYSCALL_EHDR->e_phoff);         \
+       int i;                                                                \
+       for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
+               if (vsyscall_phdrs[i].p_type == PT_LOAD)                      \
+                       DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr,        \
+                                  vsyscall_phdrs[i].p_filesz);               \
+       }                                                                     \
+} while (0)
+#endif
+
+#undef ELF_CORE_WRITE_EXTRA_PHDRS
+#undef ELF_CORE_WRITE_EXTRA_DATA
+
+#define R_386_NONE     0
+#define R_386_32       1
+#define R_386_PC32     2
+#define R_386_GOT32    3
+#define R_386_PLT32    4
+#define R_386_COPY     5
+#define R_386_GLOB_DAT 6
+#define R_386_JMP_SLOT 7
+#define R_386_RELATIVE 8
+#define R_386_GOTOFF   9
+#define R_386_GOTPC    10
+#define R_386_NUM      11
+
 /********* Bits for asm-um/delay.h **********/
 
 typedef unsigned long um_udelay_t;
index f5836c5..9a244ca 100644 (file)
@@ -23,8 +23,6 @@
        } \
 } while (0)
 
-extern int foo;
-
 #endif
 
 #endif
index d2517a0..992315c 100644 (file)
@@ -1,3 +1,5 @@
+#include <asm-generic/vmlinux.lds.h>
+
   .fini      : { *(.fini)    } =0x9090
   _etext = .;
   PROVIDE (etext = .);
 
   RODATA
 
-  __start___ksymtab = .;       /* Kernel symbol table */
-  __ksymtab : { *(__ksymtab) }
-  __stop___ksymtab = .;
-
-  __start___gpl_ksymtab = .;   /* Kernel symbol table: GPL-only symbols */
-  __gpl_ksymtab : { *(__gpl_ksymtab) }
-  __stop___gpl_ksymtab = .;
-
-  __start___kallsyms = .;       /* All kernel symbols */
-  __kallsyms : { *(__kallsyms) }
-  __stop___kallsyms = .;
-
   .unprotected : { *(.unprotected) }
   . = ALIGN(4096);
   PROVIDE (_unprotected_end = .);
   }
   __initcall_end = .;
 
+  __con_initcall_start = .;
+  .con_initcall.init : { *(.con_initcall.init) }
+  __con_initcall_end = .;
+
   __uml_initcall_start = .;
   .uml.initcall.init : { *(.uml.initcall.init) }
   __uml_initcall_end = .;
   __init_end = .;
 
+  SECURITY_INIT
+
   __exitcall_begin = .;
   .exitcall : { *(.exitcall.exit) }
   __exitcall_end = .;
   .uml.exitcall : { *(.uml.exitcall.exit) }
   __uml_exitcall_end = .;
 
-  . = ALIGN(4096);
+  . = ALIGN(4);
+  __alt_instructions = .;
+  .altinstructions : { *(.altinstructions) } 
+  __alt_instructions_end = .; 
+  .altinstr_replacement : { *(.altinstr_replacement) } 
+  /* .exit.text is discard at runtime, not link time, to deal with references
+     from .altinstructions and .eh_frame */
+  .exit.text : { *(.exit.text) }
+  .exit.data : { *(.exit.data) }
+  __preinit_array_start = .;
+  .preinit_array : { *(.preinit_array) }
+  __preinit_array_end = .;
+  __init_array_start = .;
+  .init_array : { *(.init_array) }
+  __init_array_end = .;
+  __fini_array_start = .;
+  .fini_array : { *(.fini_array) }
+  __fini_array_end = .;
+
+   . = ALIGN(4096);
   __initramfs_start = .;
   .init.ramfs : { *(.init.ramfs) }
   __initramfs_end = .;
+
+  /* Sections to be discarded */
+  /DISCARD/ : {
+       *(.exitcall.exit)
+  }
diff --git a/include/asm-um/cpufeature.h b/include/asm-um/cpufeature.h
deleted file mode 100644 (file)
index fb7bd42..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __UM_CPUFEATURE_H
-#define __UM_CPUFEATURE_H
-
-#include "asm/arch/cpufeature.h"
-
-#endif
diff --git a/include/asm-um/cpumask.h b/include/asm-um/cpumask.h
deleted file mode 100644 (file)
index 90f0d00..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_UM_CPUMASK_H
-#define _ASM_UM_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_UM_CPUMASK_H */
index adfe568..72a4cbd 100644 (file)
@@ -16,8 +16,10 @@ struct thread_info;
 #define CURRENT_THREAD(dummy) (((unsigned long) &dummy) & \
                                (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER))
 
-#define current ({ int dummy; \
-                   ((struct thread_info *) CURRENT_THREAD(dummy))->task; })
+#define current_thread \
+       ({ int dummy; ((struct thread_info *) CURRENT_THREAD(dummy)); })
+
+#define current (current_thread->task)
 
 #endif /* __ASSEMBLY__ */
 
index e7e1690..2ea8828 100644 (file)
@@ -1 +1,119 @@
-#include <asm-generic/dma-mapping.h>
+#ifndef _ASM_DMA_MAPPING_H
+#define _ASM_DMA_MAPPING_H
+
+static inline int
+dma_supported(struct device *dev, u64 mask)
+{
+       BUG();
+       return(0);
+}
+
+static inline int
+dma_set_mask(struct device *dev, u64 dma_mask)
+{
+       BUG();
+       return(0);
+}
+
+static inline void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+                  int flag)
+{
+       BUG();
+       return((void *) 0);
+}
+
+static inline void
+dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
+                 dma_addr_t dma_handle)
+{
+       BUG();
+}
+
+static inline dma_addr_t
+dma_map_single(struct device *dev, void *cpu_addr, size_t size,
+              enum dma_data_direction direction)
+{
+       BUG();
+       return(0);
+}
+
+static inline void
+dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
+                enum dma_data_direction direction)
+{
+       BUG();
+}
+
+static inline dma_addr_t
+dma_map_page(struct device *dev, struct page *page,
+            unsigned long offset, size_t size,
+            enum dma_data_direction direction)
+{
+       BUG();
+       return(0);
+}
+
+static inline void
+dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
+              enum dma_data_direction direction)
+{
+       BUG();
+}
+
+static inline int
+dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
+          enum dma_data_direction direction)
+{
+       BUG();
+       return(0);
+}
+
+static inline void
+dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
+            enum dma_data_direction direction)
+{
+       BUG();
+}
+
+static inline void
+dma_sync_single(struct device *dev, dma_addr_t dma_handle, size_t size,
+               enum dma_data_direction direction)
+{
+       BUG();
+}
+
+static inline void
+dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems,
+           enum dma_data_direction direction)
+{
+       BUG();
+}
+
+#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
+#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
+#define dma_is_consistent(d) (1)
+
+static inline int
+dma_get_cache_alignment(void)
+{
+       BUG();
+       return(0);
+}
+
+static inline void
+dma_sync_single_range(struct device *dev, dma_addr_t dma_handle,
+                     unsigned long offset, size_t size,
+                     enum dma_data_direction direction)
+{
+       BUG();
+}
+
+static inline void
+dma_cache_sync(void *vaddr, size_t size,
+              enum dma_data_direction direction)
+{
+       BUG();
+}
+
+#endif
index f33a353..c96c5eb 100644 (file)
 
 #define USE_ELF_CORE_DUMP
 
+#define R_386_NONE     0
+#define R_386_32       1
+#define R_386_PC32     2
+#define R_386_GOT32    3
+#define R_386_PLT32    4
+#define R_386_COPY     5
+#define R_386_GLOB_DAT 6
+#define R_386_JMP_SLOT 7
+#define R_386_RELATIVE 8
+#define R_386_GOTOFF   9
+#define R_386_GOTPC    10
+#define R_386_NUM      11
+
 #endif
index 0e8a4c1..ef4890b 100644 (file)
@@ -34,6 +34,7 @@ enum fixed_addresses {
        FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
        FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
 #endif
+       FIX_VSYSCALL,
        __end_of_fixed_addresses
 };
 
@@ -63,6 +64,13 @@ extern unsigned long get_kmem_end(void);
 #define __fix_to_virt(x)       (FIXADDR_TOP - ((x) << PAGE_SHIFT))
 #define __virt_to_fix(x)      ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
 
+/*
+ * This is the range that is readable by user mode, and things
+ * acting like user mode such as get_user_pages.
+ */
+#define FIXADDR_USER_START     (__fix_to_virt(FIX_VSYSCALL))
+#define FIXADDR_USER_END       (FIXADDR_USER_START + PAGE_SIZE)
+
 extern void __this_fixmap_does_not_exist(void);
 
 /*
diff --git a/include/asm-um/init.h b/include/asm-um/init.h
deleted file mode 100644 (file)
index 1e271ca..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _UM_INIT_H
-#define _UM_INIT_H
-
-#ifdef notdef
-#define __init
-#define __initdata
-#define __initfunc(__arginit) __arginit
-#define __cacheline_aligned 
-#endif
-
-#endif
index 8300c20..bccf537 100644 (file)
@@ -1,15 +1,6 @@
 #ifndef __UM_IRQ_H
 #define __UM_IRQ_H
 
-/* The i386 irq.h has a struct task_struct in a prototype without including
- * sched.h.  This forward declaration kills the resulting warning.
- */
-struct task_struct;
-
-#include "asm/ptrace.h"
-
-#undef NR_IRQS
-
 #define TIMER_IRQ              0
 #define UMN_IRQ                        1
 #define CONSOLE_IRQ            2
@@ -24,17 +15,9 @@ struct task_struct;
 #define SIGIO_WRITE_IRQ        11
 #define TELNETD_IRQ            12
 #define XTERM_IRQ              13
-
-#define LAST_IRQ XTERM_IRQ
+#define HUMFS_IRQ              14
+#define LAST_IRQ HUMFS_IRQ
 #define NR_IRQS (LAST_IRQ + 1)
 
-extern int um_request_irq(unsigned int irq, int fd, int type,
-                         void (*handler)(int, void *, struct pt_regs *),
-                         unsigned long irqflags,  const char * devname,
-                         void *dev_id);
-
-struct irqaction;
-struct pt_regs;
-int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
-
 #endif
diff --git a/include/asm-um/local.h b/include/asm-um/local.h
deleted file mode 100644 (file)
index 9a280c5..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __UM_LOCAL_H
-#define __UM_LOCAL_H
-
-#include "asm/arch/local.h"
-
-#endif
index 4ddffc1..89bff31 100644 (file)
@@ -26,8 +26,8 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
        unsigned cpu = smp_processor_id();
 
        if(prev != next){
-               clear_bit(cpu, &prev->cpu_vm_mask);
-               set_bit(cpu, &next->cpu_vm_mask);
+               cpu_clear(cpu, prev->cpu_vm_mask);
+               cpu_set(cpu, next->cpu_vm_mask);
                if(next != &init_mm)
                        CHOOSE_MODE((void) 0, 
                                    switch_mm_skas(next->context.skas.mm_fd));
diff --git a/include/asm-um/module-generic.h b/include/asm-um/module-generic.h
deleted file mode 100644 (file)
index 5a265f5..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __UM_MODULE_GENERIC_H
-#define __UM_MODULE_GENERIC_H
-
-#include "asm/arch/module.h"
-
-#endif
index ad97bc0..8e7134b 100644 (file)
@@ -1,10 +1,14 @@
+/* 
+ *  Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Licensed under the GPL
+ */
+
 #ifndef __UM_PAGE_H
 #define __UM_PAGE_H
 
 struct page;
 
 #include "asm/arch/page.h"
-#include "asm/bug.h"
 
 #undef __pa
 #undef __va
@@ -24,25 +28,37 @@ extern unsigned long uml_physmem;
 
 #define __va_space (8*1024*1024)
 
-extern unsigned long region_pa(void *virt);
-extern void *region_va(unsigned long phys);
-
-#define __pa(virt) region_pa((void *) (virt))
-#define __va(phys) region_va((unsigned long) (phys))
-
-extern unsigned long page_to_pfn(struct page *page);
-extern struct page *pfn_to_page(unsigned long pfn);
+extern unsigned long to_phys(void *virt);
+extern void *to_virt(unsigned long phys);
 
-extern struct page *phys_to_page(unsigned long phys);
+#define __pa(virt) to_phys((void *) virt)
+#define __va(phys) to_virt((unsigned long) phys)
 
-#define virt_to_page(v) (phys_to_page(__pa(v)))
+#define page_to_pfn(page) ((page) - mem_map)
+#define pfn_to_page(pfn) (mem_map + (pfn))
 
-extern struct page *page_mem_map(struct page *page);
+#define phys_to_pfn(p) ((p) >> PAGE_SHIFT)
+#define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
 
-#define pfn_valid(pfn) (page_mem_map(pfn_to_page(pfn)) != NULL)
-#define virt_addr_valid(v) pfn_valid(__pa(v) >> PAGE_SHIFT)
+#define pfn_valid(pfn) ((pfn) < max_mapnr)
+#define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v)))
 
 extern struct page *arch_validate(struct page *page, int mask, int order);
 #define HAVE_ARCH_VALIDATE
+#define devmem_is_allowed(x) 1
+
+extern void arch_free_page(struct page *page, int order);
+#define HAVE_ARCH_FREE_PAGE
 
 #endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
index 73973ae..e56bed3 100644 (file)
@@ -49,6 +49,10 @@ static inline void pte_free(struct page *pte)
 
 #define check_pgt_cache()      do { } while (0)
 
+#define arch_add_exec_range(mm, limit)         do { ; } while (0)
+#define arch_flush_exec_range(mm)              do { ; } while (0)
+#define arch_remove_exec_range(mm, limit)      do { ; } while (0)
+
 #endif
 
 /*
index 148dd8e..6006b0b 100644 (file)
@@ -12,8 +12,6 @@
 #include "asm/page.h"
 #include "asm/fixmap.h"
 
-extern pgd_t swapper_pg_dir[1024];
-
 extern void *um_virt_to_phys(struct task_struct *task, unsigned long virt,
                             pte_t *pte_out);
 
@@ -49,6 +47,8 @@ extern unsigned long *empty_zero_page;
 #define pgd_ERROR(e) \
         printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
 
+extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
+
 /*
  * pgd entries used up by user/kernel:
  */
@@ -65,10 +65,10 @@ extern unsigned long *empty_zero_page;
  * area for the same reason. ;)
  */
 
-extern unsigned long high_physmem;
+extern unsigned long end_iomem;
 
 #define VMALLOC_OFFSET (__va_space)
-#define VMALLOC_START  (((unsigned long) high_physmem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
+#define VMALLOC_START  ((end_iomem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
 
 #ifdef CONFIG_HIGHMEM
 # define VMALLOC_END   (PKMAP_BASE-2*PAGE_SIZE)
@@ -78,12 +78,13 @@ extern unsigned long high_physmem;
 
 #define _PAGE_PRESENT  0x001
 #define _PAGE_NEWPAGE  0x002
-#define _PAGE_PROTNONE 0x004   /* If not present */
-#define _PAGE_RW       0x008
-#define _PAGE_USER     0x010
-#define _PAGE_ACCESSED 0x020
-#define _PAGE_DIRTY    0x040
-#define _PAGE_NEWPROT   0x080
+#define _PAGE_NEWPROT   0x004
+#define _PAGE_FILE     0x008   /* set:pagecache unset:swap */
+#define _PAGE_PROTNONE 0x010   /* If not present */
+#define _PAGE_RW       0x020
+#define _PAGE_USER     0x040
+#define _PAGE_ACCESSED 0x080
+#define _PAGE_DIRTY    0x100
 
 #define REGION_MASK    0xf0000000
 #define REGION_SHIFT   28
@@ -143,7 +144,8 @@ extern pte_t * __bad_pagetable(void);
 
 #define BAD_PAGETABLE __bad_pagetable()
 #define BAD_PAGE __bad_page()
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
+
+#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
 
 /* number of bits that fit into a memory pointer */
 #define BITS_PER_PTR                   (8*sizeof(unsigned long))
@@ -164,9 +166,6 @@ extern pte_t * __bad_pagetable(void);
 
 #define pte_clear(xp)  do { pte_val(*(xp)) = _PAGE_NEWPAGE; } while (0)
 
-#define phys_region_index(x) (((x) & REGION_MASK) >> REGION_SHIFT)
-#define pte_region_index(x) phys_region_index(pte_val(x))
-
 #define pmd_none(x)    (!(pmd_val(x) & ~_PAGE_NEWPAGE))
 #define        pmd_bad(x)      ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
 #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
@@ -188,19 +187,25 @@ static inline void pgd_clear(pgd_t * pgdp)        { }
 
 #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
 
-extern struct page *pte_mem_map(pte_t pte);
-extern struct page *phys_mem_map(unsigned long phys);
-extern unsigned long phys_to_pfn(unsigned long p);
-extern unsigned long pfn_to_phys(unsigned long pfn);
+#define pte_page(pte) phys_to_page(pte_val(pte))
+#define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK)
 
-#define pte_page(x) pfn_to_page(pte_pfn(x))
-#define pte_address(x) (__va(pte_val(x) & PAGE_MASK))
-#define mk_phys(a, r) ((a) + (r << REGION_SHIFT))
-#define phys_addr(p) ((p) & ~REGION_MASK)
-#define phys_page(p) (phys_mem_map(p) + ((phys_addr(p)) >> PAGE_SHIFT))
 #define pte_pfn(x) phys_to_pfn(pte_val(x))
 #define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot))
-#define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot))
+
+extern struct page *phys_to_page(const unsigned long phys);
+extern struct page *__virt_to_page(const unsigned long virt);
+#define virt_to_page(addr) __virt_to_page((const unsigned long) addr)
+  
+/*
+ * Bits 0 through 3 are taken
+ */
+#define PTE_FILE_MAX_BITS      28
+
+#define pte_to_pgoff(pte) ((pte).pte_low >> 4)
+
+#define pgoff_to_pte(off) \
+       ((pte_t) { ((off) << 4) + _PAGE_FILE })
 
 static inline pte_t pte_mknewprot(pte_t pte)
 {
@@ -235,6 +240,12 @@ static inline void set_pte(pte_t *pteptr, pte_t pteval)
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
+static inline int pte_user(pte_t pte)
+{ 
+       return((pte_val(pte) & _PAGE_USER) && 
+              !(pte_val(pte) & _PAGE_PROTNONE));
+}
+
 static inline int pte_read(pte_t pte)
 { 
        return((pte_val(pte) & _PAGE_USER) && 
@@ -252,6 +263,14 @@ static inline int pte_write(pte_t pte)
               !(pte_val(pte) & _PAGE_PROTNONE));
 }
 
+/*
+ * The following only works if pte_present() is not true.
+ */
+static inline int pte_file(pte_t pte)
+{ 
+       return (pte).pte_low & _PAGE_FILE; 
+}
+
 static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
 static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
 static inline int pte_newpage(pte_t pte) { return pte_val(pte) & _PAGE_NEWPAGE; }
@@ -334,14 +353,7 @@ extern unsigned long page_to_phys(struct page *page);
  * and a page entry and page directory to the page they refer to.
  */
 
-#define mk_pte(page, pgprot) \
-({                                     \
-       pte_t __pte;                    \
-                                        \
-       pte_val(__pte) = page_to_phys(page) + pgprot_val(pgprot);\
-       if(pte_present(__pte)) pte_mknewprot(pte_mknewpage(__pte)); \
-       __pte;                          \
-})
+extern pte_t mk_pte(struct page *page, pgprot_t pgprot);
 
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
@@ -351,17 +363,27 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 }
 
 #define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
-#define pmd_page(pmd) (phys_mem_map(pmd_val(pmd) & PAGE_MASK) + \
-                      ((phys_addr(pmd_val(pmd)) >> PAGE_SHIFT)))
 
-/* to find an entry in a page-table-directory. */
+/*
+ * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
+ *
+ * this macro returns the index of the entry in the pgd page which would
+ * control the given virtual address
+ */
 #define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 
-/* to find an entry in a page-table-directory */
+/*
+ * pgd_offset() returns a (pgd_t *)
+ * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
+ */
 #define pgd_offset(mm, address) \
 ((mm)->pgd + ((address) >> PGDIR_SHIFT))
 
-/* to find an entry in a kernel page-table-directory */
+
+/*
+ * a shortcut which implies the use of the kernel's pgd, instead
+ * of a process's
+ */
 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
 
 #define pmd_index(address) \
@@ -373,7 +395,12 @@ static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
        return (pmd_t *) dir;
 }
 
-/* Find an entry in the third-level page table.. */ 
+/*
+ * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
+ *
+ * this macro returns the index of the entry in the pte page which would
+ * control the given virtual address
+ */
 #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) \
        ((pte_t *) pmd_page_kernel(*(dir)) +  pte_index(address))
@@ -387,11 +414,11 @@ static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
 #define update_mmu_cache(vma,address,pte) do ; while (0)
 
 /* Encode and de-code a swap entry */
-#define __swp_type(x)                  (((x).val >> 3) & 0x7f)
-#define __swp_offset(x)                        ((x).val >> 10)
+#define __swp_type(x)                  (((x).val >> 4) & 0x3f)
+#define __swp_offset(x)                        ((x).val >> 11)
 
 #define __swp_entry(type, offset) \
-       ((swp_entry_t) { ((type) << 3) | ((offset) << 10) })
+       ((swp_entry_t) { ((type) << 4) | ((offset) << 11) })
 #define __pte_to_swp_entry(pte) \
        ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
 #define __swp_entry_to_pte(x)          ((pte_t) { (x).val })
index 618a490..2f06a7b 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2004 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
  */
 
@@ -11,41 +11,24 @@ struct pt_regs;
 struct task_struct;
 
 #include "linux/config.h"
-#include "linux/signal.h"
 #include "asm/ptrace.h"
-#include "asm/siginfo.h"
 #include "choose-mode.h"
 
 struct mm_struct;
 
 #define current_text_addr() ((void *) 0)
 
-#define cpu_relax()    do ; while (0)
+#define cpu_relax()   barrier()
 
-#ifdef CONFIG_MODE_TT
-struct proc_tt_mode {
-       int extern_pid;
-       int tracing;
-       int switch_pipe[2];
-       int singlestep_syscall;
-       int vm_seq;
-};
-#endif
-
-#ifdef CONFIG_MODE_SKAS
-struct proc_skas_mode {
-       void *switch_buf;
-       void *fork_buf;
-};
-#endif
+#define STACK_PAGE_COUNT       (4096/PAGE_SIZE)
 
 struct thread_struct {
        int forking;
-       unsigned long kernel_stack;
        int nsyscalls;
        struct pt_regs regs;
        unsigned long cr2;
        int err;
+       unsigned long trap_no;
        void *fault_addr;
        void *fault_catcher;
        struct task_struct *prev_sched;
@@ -54,10 +37,20 @@ struct thread_struct {
        struct arch_thread arch;
        union {
 #ifdef CONFIG_MODE_TT
-               struct proc_tt_mode tt;
+               struct {
+                       int extern_pid;
+                       int tracing;
+                       int switch_pipe[2];
+                       int singlestep_syscall;
+                       int vm_seq;
+               } tt;
 #endif
 #ifdef CONFIG_MODE_SKAS
-               struct proc_skas_mode skas;
+               struct {
+                       void *switch_buf;
+                       void *fork_buf;
+                       int mm_count;
+               } skas;
 #endif
        } mode;
        struct {
@@ -81,7 +74,6 @@ struct thread_struct {
 #define INIT_THREAD \
 { \
        .forking                = 0, \
-       .kernel_stack           = 0, \
        .nsyscalls              = 0, \
         .regs                  = EMPTY_REGS, \
        .cr2                    = 0, \
@@ -99,14 +91,19 @@ typedef struct {
 } mm_segment_t;
 
 extern struct task_struct *alloc_task_struct(void);
-extern void free_task_struct(struct task_struct *task);
 
 extern void release_thread(struct task_struct *);
 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
 extern void dump_thread(struct pt_regs *regs, struct user *u);
+extern void prepare_to_copy(struct task_struct *tsk);
 
 extern unsigned long thread_saved_pc(struct task_struct *t);
 
+static inline void mm_copy_segments(struct mm_struct *from_mm, 
+                                   struct mm_struct *new_mm)
+{
+}
+
 #define init_stack     (init_thread_union.stack)
 
 /*
@@ -114,6 +111,7 @@ extern unsigned long thread_saved_pc(struct task_struct *t);
  */
 extern unsigned long task_size;
 
+#undef TASK_SIZE
 #define TASK_SIZE      (task_size)
 
 /* This decides where the kernel will search for a free chunk of vm
index 02decdc..0f08c02 100644 (file)
@@ -6,8 +6,8 @@
 #ifndef __UM_PROCESSOR_I386_H
 #define __UM_PROCESSOR_I386_H
 
-extern int cpu_has_xmm;
-extern int cpu_has_cmov;
+extern int host_has_xmm;
+extern int host_has_cmov;
 
 struct arch_thread {
        unsigned long debugregs[8];
diff --git a/include/asm-um/rmap.h b/include/asm-um/rmap.h
deleted file mode 100644 (file)
index a244d48..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __UM_RMAP_H
-#define __UM_RMAP_H
-
-#include "asm/arch/rmap.h"
-
-#endif
diff --git a/include/asm-um/sections.h b/include/asm-um/sections.h
deleted file mode 100644 (file)
index 6b0231e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _UM_SECTIONS_H
-#define _UM_SECTIONS_H
-
-/* nothing to see, move along */
-#include <asm-generic/sections.h>
-
-#endif
index 4629de8..20c6457 100644 (file)
@@ -10,7 +10,7 @@
 
 extern cpumask_t cpu_online_map;
 
-#define smp_processor_id() (current->thread_info->cpu)
+#define smp_processor_id() (current_thread->cpu)
 #define cpu_logical_map(n) (n)
 #define cpu_number_map(n) (n)
 #define PROC_CHANGE_PENALTY    15 /* Pick a number, any number */
diff --git a/include/asm-um/smplock.h b/include/asm-um/smplock.h
deleted file mode 100644 (file)
index aacda39..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __UM_SMPLOCK_H
-#define __UM_SMPLOCK_H
-
-#include "asm/arch/smplock.h"
-
-#endif
diff --git a/include/asm-um/spinlock.h b/include/asm-um/spinlock.h
deleted file mode 100644 (file)
index bd6c35d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __UM_SPINLOCK_H
-#define __UM_SPINLOCK_H
-
-#include "linux/config.h"
-
-#ifdef CONFIG_SMP
-#include "asm/arch/spinlock.h"
-#endif
-
-#endif
index 80b24a3..5bcfa35 100644 (file)
@@ -23,8 +23,10 @@ extern int get_signals(void);
 extern void block_signals(void);
 extern void unblock_signals(void);
 
-#define local_save_flags(flags) do { (flags) = get_signals(); } while(0)
-#define local_irq_restore(flags) do { set_signals(flags); } while(0)
+#define local_save_flags(flags) do { typecheck(unsigned long, flags); \
+                                    (flags) = get_signals(); } while(0)
+#define local_irq_restore(flags) do { typecheck(unsigned long, flags); \
+                                     set_signals(flags); } while(0)
 
 #define local_irq_save(flags) do { local_save_flags(flags); \
                                    local_irq_disable(); } while(0)
@@ -39,4 +41,7 @@ extern void unblock_signals(void);
         (flags == 0);                   \
 })
 
+extern void *_switch_to(void *prev, void *next, void *last);
+#define switch_to(prev, next, last) prev = _switch_to(prev, next, last)
+
 #endif
index 4d71ed3..c436263 100644 (file)
@@ -2,36 +2,5 @@
 #define __UM_SYSTEM_I386_H
 
 #include "asm/system-generic.h"
-
-static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-                                     unsigned long new, int size)
-{
-       unsigned long prev;
-       switch (size) {
-       case 1:
-               __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
-                                    : "=a"(prev)
-                                    : "q"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       case 2:
-               __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
-                                    : "=a"(prev)
-                                    : "q"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       case 4:
-               __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
-                                    : "=a"(prev)
-                                    : "q"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       }
-       return old;
-}
-
-#define cmpxchg(ptr,o,n)\
-       ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
-                                       (unsigned long)(n),sizeof(*(ptr))))
     
 #endif
index 6a606bf..bb1bc2d 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef __ASSEMBLY__
 
 #include <asm/processor.h>
+#include <asm/types.h>
 
 struct thread_info {
        struct task_struct      *task;          /* main task structure */
@@ -43,15 +44,18 @@ struct thread_info {
 static inline struct thread_info *current_thread_info(void)
 {
        struct thread_info *ti;
-       __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~16383UL));
+       unsigned long mask = PAGE_SIZE * 
+               (1 << CONFIG_KERNEL_STACK_ORDER) - 1;
+       __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~mask));
        return ti;
 }
 
 /* thread information allocation */
-#define THREAD_SIZE (4*PAGE_SIZE)
-#define alloc_thread_info(tsk) ((struct thread_info *) \
-       __get_free_pages(GFP_KERNEL,2))
-#define free_thread_info(ti) free_pages((unsigned long) (ti), 2)
+#define THREAD_SIZE ((1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE)
+#define alloc_thread_info(tsk) \
+       ((struct thread_info *) kmalloc(THREAD_SIZE, GFP_KERNEL))
+#define free_thread_info(ti) kfree(ti)
+       
 #define get_thread_info(ti) get_task_struct((ti)->task)
 #define put_thread_info(ti) put_task_struct((ti)->task)
 
@@ -65,11 +69,13 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_POLLING_NRFLAG      3       /* true if poll_idle() is polling 
                                         * TIF_NEED_RESCHED 
                                         */
+#define TIF_RESTART_BLOCK      4
 
 #define _TIF_SYSCALL_TRACE     (1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING                (1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED      (1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
+#define _TIF_RESTART_BLOCK     (1 << TIF_RESTART_BLOCK)
 
 #endif
 
index 6a87313..5805811 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef __UM_TIMEX_H
 #define __UM_TIMEX_H
 
-#include "linux/time.h"
-
 typedef unsigned long cycles_t;
 
 #define cacheflush_time (0)
index e1dfea1..0070590 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef __UM_UACCESS_H
 #define __UM_UACCESS_H
 
+#include "linux/sched.h"
+
 #define VERIFY_READ 0
 #define VERIFY_WRITE 1
 
@@ -34,6 +36,9 @@
 
 #define __copy_to_user(to, from, n) copy_to_user(to, from, n)
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 #define __get_user(x, ptr) \
 ({ \
         const __typeof__(ptr) __private_ptr = ptr; \
index 5850620..512f225 100644 (file)
@@ -48,7 +48,10 @@ extern int um_execve(const char *file, char *const argv[], char *const env[]);
        set_fs(KERNEL_DS);                      \
        ret = sys(args);                        \
        set_fs(fs);                             \
-       return ret;
+       if (ret >= 0)                           \
+               return ret;                     \
+       errno = -(long)ret;                     \
+       return -1;
 
 static inline long open(const char *pathname, int flags, int mode) 
 {
diff --git a/include/asm-v850/cpumask.h b/include/asm-v850/cpumask.h
deleted file mode 100644 (file)
index 09aebd0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_V850_CPUMASK_H
-#define _ASM_V850_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_V850_CPUMASK_H */
index 06085b0..60d9ea1 100644 (file)
@@ -141,6 +141,8 @@ extern __inline__ int get_order (unsigned long size)
 #define __va(x)                     ((void *)__phys_to_virt ((unsigned long)(x)))
 
 
+#define devmem_is_allowed(x) 1
+
 #endif /* KERNEL */
 
 #endif /* __V850_PAGE_H__ */
diff --git a/include/asm-v850/relay.h b/include/asm-v850/relay.h
new file mode 100644 (file)
index 0000000..869a538
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef __V850_RELAY_H
+#define __V850_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 9f4ca4a..27d2f58 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-v850/rmap.h b/include/asm-v850/rmap.h
deleted file mode 100644 (file)
index c0ebee6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/* Do not need anything here */
index 1db9010..7068dfc 100644 (file)
@@ -112,6 +112,9 @@ extern int bad_user_access_length (void);
 #define __copy_from_user(to, from, n)  (memcpy (to, from, n), 0)
 #define __copy_to_user(to, from, n)    (memcpy(to, from, n), 0)
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 #define copy_from_user(to, from, n)    __copy_from_user (to, from, n)
 #define copy_to_user(to, from, n)      __copy_to_user(to, from, n)
 
diff --git a/include/asm-x86_64/cpumask.h b/include/asm-x86_64/cpumask.h
deleted file mode 100644 (file)
index d9ea497..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _ASM_X86_64_CPUMASK_H
-#define _ASM_X86_64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_X86_64_CPUMASK_H */
index 4411f22..89425e2 100644 (file)
@@ -21,6 +21,7 @@
 #define O_DIRECTORY    0200000 /* must be a directory */
 #define O_NOFOLLOW     0400000 /* don't follow links */
 #define O_NOATIME      01000000
+#define O_ATOMICLOOKUP 02000000 /* TUX */
 
 #define F_DUPFD                0       /* dup */
 #define F_GETFD                1       /* get close_on_exec */
diff --git a/include/asm-x86_64/init.h b/include/asm-x86_64/init.h
deleted file mode 100644 (file)
index 17d2155..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
diff --git a/include/asm-x86_64/netdump.h b/include/asm-x86_64/netdump.h
new file mode 100644 (file)
index 0000000..3be9bad
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_64_NETDUMP_H_
+#define _ASM_X86_64_NETDUMP_H_
+
+#include <asm-generic/netdump.h>
+
+#endif /* _ASM_X86_64_NETDUMP_H_ */
index c5c2b01..c0c8e23 100644 (file)
@@ -148,6 +148,7 @@ extern __inline__ int get_order(unsigned long size)
 struct task_struct;
 struct vm_area_struct *get_gate_vma(struct task_struct *tsk);
 int in_gate_area(struct task_struct *task, unsigned long addr);
+extern int devmem_is_allowed(unsigned long pagenr);
 #endif
 
 #endif /* __KERNEL__ */
index bebcaab..d496958 100644 (file)
@@ -7,6 +7,11 @@
 #include <linux/threads.h>
 #include <linux/mm.h>
 
+#define arch_add_exec_range(mm, limit) do { ; } while (0)
+#define arch_flush_exec_range(mm)      do { ; } while (0)
+#define arch_remove_exec_range(mm, limit) do { ; } while (0)
+
+
 #define pmd_populate_kernel(mm, pmd, pte) \
                set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)))
 #define pgd_populate(mm, pgd, pmd) \
index 934828c..597df19 100644 (file)
@@ -163,10 +163,6 @@ static inline void clear_in_cr4 (unsigned long mask)
 #define MCA_bus__is_a_macro
 
 
-/*
- * User space process size: 512GB - 1GB (default).
- */
-#define TASK_SIZE      (0x0000007fc0000000UL)
 
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
@@ -177,10 +173,18 @@ static inline void clear_in_cr4 (unsigned long mask)
 #define TASK_UNMAPPED_BASE     \
        (test_thread_flag(TIF_IA32) ? TASK_UNMAPPED_32 : TASK_UNMAPPED_64)  
 
+
+/*
+ * User space process size: 512GB - 1GB (default).
+ */
+#define TASK_SIZE_64   (0x0000007fc0000000UL)
+
+#define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE_64)
+
 /*
- * Size of io_bitmap.
+ * Size of io_bitmap, covering ports 0 to 0x3ff.
  */
-#define IO_BITMAP_BITS  65536
+#define IO_BITMAP_BITS  1024
 #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
 #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
 #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
@@ -461,4 +465,6 @@ static inline void __mwait(unsigned long eax, unsigned long ecx)
 #define ARCH_HAS_SCHED_WAKE_IDLE
 #endif
 
+#define HAVE_ARCH_PICK_MMAP_LAYOUT
+
 #endif /* __ASM_X86_64_PROCESSOR_H */
diff --git a/include/asm-x86_64/relay.h b/include/asm-x86_64/relay.h
new file mode 100644 (file)
index 0000000..d8b1b88
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _ASM_X86_64_RELAY_H
+#define _ASM_X86_64_RELAY_H
+
+#include <asm-generic/relay.h>
+#endif
index 9628f77..a946b0b 100644 (file)
@@ -39,7 +39,7 @@
        { RLIM_INFINITY, RLIM_INFINITY },               \
        {             0,             0 },               \
        {      INR_OPEN,     INR_OPEN  },               \
-       { RLIM_INFINITY, RLIM_INFINITY },               \
+       {         32768,         32768 },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { RLIM_INFINITY, RLIM_INFINITY },               \
        { MAX_SIGPENDING, MAX_SIGPENDING },             \
diff --git a/include/asm-x86_64/rmap.h b/include/asm-x86_64/rmap.h
deleted file mode 100644 (file)
index 24c1783..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _X8664_RMAP_H
-#define _X8664_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
index ba3d49d..8d0598d 100644 (file)
@@ -351,4 +351,7 @@ long strlen_user(const char __user *str);
 unsigned long clear_user(void __user *mem, unsigned long len);
 unsigned long __clear_user(void __user *mem, unsigned long len);
 
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
 #endif /* __X86_64_UACCESS_H */
index 26e0aa3..81e4e85 100644 (file)
@@ -531,9 +531,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
 #define __NR_utimes            235
 __SYSCALL(__NR_utimes, sys_utimes)
 #define __NR_vserver           236
-__SYSCALL(__NR_vserver, sys_ni_syscall)
-#define __NR_vserver           236
-__SYSCALL(__NR_vserver, sys_ni_syscall)
+__SYSCALL(__NR_vserver, sys_vserver)
 #define __NR_mbind             237
 __SYSCALL(__NR_mbind, sys_mbind)
 #define __NR_set_mempolicy     238
@@ -554,8 +552,12 @@ __SYSCALL(__NR_mq_notify, sys_mq_notify)
 __SYSCALL(__NR_mq_getsetattr, sys_mq_getsetattr)
 #define __NR_kexec_load        246
 __SYSCALL(__NR_kexec_load, sys_ni_syscall)
+#define __NR_ioprio_set                247
+__SYSCALL(__NR_ioprio_set, sys_ioprio_set);
+#define __NR_ioprio_get                248
+__SYSCALL(__NR_ioprio_get, sys_ioprio_get);
 
-#define __NR_syscall_max __NR_kexec_load
+#define __NR_syscall_max __NR_ioprio_get
 #ifndef __NO_STUBS
 
 /* user-visible error numbers are in the range -1 - -4095 */
diff --git a/include/linux/802_11.h b/include/linux/802_11.h
deleted file mode 100644 (file)
index bd5196c..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-#ifndef IEEE_802_11
-#define IEEE_802_11  
-
-#include <linux/types.h>
-
-enum ieee_802_11_link_status_failure_reason {
-       reserved0, Unspecified=1, Previous_not_valid, 
-       Sender_Quits_ESS_or_IBSS,
-       Due_Inactivity, AP_Overload, 
-       Class_2_from_NonAuth,
-       Class_3_from_NonAuth,
-       Sender_Quits_BSS,
-       Association_requester_not_authenticated,
-       Reserved10 
-};
-       
-       
-#define IEEE_802_11_LINK_STATUS_FAILURE_REASON_STRINGS \
-{      \
-        {reserved0,            0xff," Reserved reason "},\
-        {Unspecified,          0xff," Unspecified Reason "},\
-        {Previous_not_valid,   0xff," Previous Authentication no longer valid "},\
-        {Sender_Quits_ESS_or_IBSS,0xff," Deauthenticated because sending station is leaving (has left) IBSS or ESS "},\
-        {Due_Inactivity,       0xff," Disassociated due to inactivity "},\
-        {AP_Overload,          0xff," Disassociated because AP is unable to handle all currently associated stations "},\
-        {Class_2_from_NonAuth, 0xff," Class 2 frame received from non-Authenticated station"},\
-        {Class_3_from_NonAuth, 0xff," Class 3 frame received from non­Associated station"},\
-        {Sender_Quits_BSS,     0xff," Disassociated because sending station is leaving (has left) BSS"},\
-        {Association_requester_not_authenticated,0xff," Station requesting (Re)Association is not Authenticated with responding station"},\
-        {Reserved10,           0xff," Reserved"},\
-       {0,0,NULL}\
-};
-
-
-
-struct ieee_802_11_header {
-       u16     frame_control;// needs to be subtyped
-       u16     duration;
-       u8      mac1[6];
-       u8      mac2[6];
-       u8      mac3[6];
-       u16     SeqCtl;
-       u8      mac4[6];
-       u16     gapLen;
-       u8      gap[8];
-};
-
-
-struct ieee_802_3_header {
-
-       u16     status;
-       u16     payload_length;
-       u8      dst_mac[6];
-       u8      src_mac[6];
-       
-};
-
-#define P80211_OUI_LEN 3
-
-struct ieee_802_11_snap_header { 
-
-       u8    dsap;   /* always 0xAA */
-       u8    ssap;   /* always 0xAA */
-       u8    ctrl;   /* always 0x03 */
-       u8    oui[P80211_OUI_LEN];    /* organizational universal id */
-
-} __attribute__ ((packed));
-
-#define P80211_LLC_OUI_LEN 3
-
-struct ieee_802_11_802_1H_header {
-
-       u8    dsap;   
-       u8    ssap;   /* always 0xAA */
-       u8    ctrl;   /* always 0x03 */
-       u8    oui[P80211_OUI_LEN];    /* organizational universal id */
-       u16    unknown1;      /* packet type ID fields */
-       u16    unknown2;                /* here is something like length in some cases */
-} __attribute__ ((packed));
-
-struct ieee_802_11_802_2_header {
-
-       u8    dsap;   
-       u8    ssap;   /* always 0xAA */
-       u8    ctrl;   /* always 0x03 */
-       u8    oui[P80211_OUI_LEN];    /* organizational universal id */
-       u8    type;      /* packet type ID field. i guess,  */
-
-} __attribute__ ((packed));
-
-
-
-// following is incoplete and may be incorrect and need reorganization
-
-#define ieee_802_11_frame_type_Management      0x00
-#define ieee_802_11_frame_type_Control         0x01
-#define ieee_802_11_frame_type_Data            0x10
-#define ieee_802_11_frame_type_Reserved                0x11
-
-#define ieee_802_11_frame_subtype_Association_Req      0x0 // Association Request
-#define ieee_802_11_frame_subtype_Association_Resp     0x1 // Association Response
-#define ieee_802_11_frame_subtype_Reassociation_Req    0x2 // Reassociation Request
-#define ieee_802_11_frame_subtype_Reassociation_Resp   0x3 // Reassociation Response
-#define ieee_802_11_frame_subtype_Probe_Req            0x4 // Probe Request
-#define ieee_802_11_frame_subtype_Probe_Resp           0x5 // Probe Response
-#define ieee_802_11_frame_subtype_Beacon               0x8 // Beacon
-#define ieee_802_11_frame_subtype_ATIM                         0x9 // ATIM
-#define ieee_802_11_frame_subtype_Disassociation       0xA // Disassociation
-#define ieee_802_11_frame_subtype_Authentication       0xB // Authentication
-#define ieee_802_11_frame_subtype_Deauthentication     0xC // Deauthentication
-#define ieee_802_11_frame_subtype_PS_Poll              0xA // PS-Poll
-#define ieee_802_11_frame_subtype_RTS                  0xB // RTS
-#define ieee_802_11_frame_subtype_CTS                  0xC // CTS
-#define ieee_802_11_frame_subtype_ACK                  0xD // ACK
-#define ieee_802_11_frame_subtype_CFEnd                0xE // CF-End
-#define ieee_802_11_frame_subtype_CFEnd_CFAck          0xF // CF-End + CF-Ack
-#define ieee_802_11_frame_subtype_Data                         0x0 // Data
-#define ieee_802_11_frame_subtype_Data_CFAck           0x1 // Data + CF-Ack
-#define ieee_802_11_frame_subtype_Data_CF_Poll                 0x2 // Data + CF-Poll
-#define ieee_802_11_frame_subtype_Data_CF_AckCF_Poll   0x3 // Data + CF-Ack + CF-Poll
-#define ieee_802_11_frame_subtype_NullFunction                 0x4 // Null Function (no data)
-#define ieee_802_11_frame_subtype_CF_Ack               0x5 // CF-Ack (no data)
-#define ieee_802_11_frame_subtype_CF_Poll              0x6 // CF-Poll (no data)
-#define ieee_802_11_frame_subtype_CF_AckCF_Poll        0x7 // CF-Ack + CF-Poll (no data)
-
-
-#define ieee_802_11_frame_subtype_strings {\
-       { ieee_802_11_frame_subtype_Association_Req,    0xF,"f  Association Request"},\
-       { ieee_802_11_frame_subtype_Association_Resp,   0xF,"1  Association Response"},\
-       { ieee_802_11_frame_subtype_Reassociation_Req,  0xF,"2  Reassociation Request"},\
-       { ieee_802_11_frame_subtype_Reassociation_Resp, 0xF,"3  Reassociation Response"},\
-       { ieee_802_11_frame_subtype_Probe_Req   ,       0xF,"4  Probe Request"},\
-       { ieee_802_11_frame_subtype_Probe_Resp  ,       0xF,"5  Probe Response"},\
-       { ieee_802_11_frame_subtype_Beacon      ,       0xF,"8  Beacon"},\
-       { ieee_802_11_frame_subtype_ATIM        ,       0xF,"9  ATIM"},\
-       { ieee_802_11_frame_subtype_Disassociation,     0xF,"A  Disassociation"},\
-       { ieee_802_11_frame_subtype_Authentication,     0xF,"B  Authentication"},\
-       { ieee_802_11_frame_subtype_Deauthentication,   0xF,"C  Deauthentication"},\
-       { ieee_802_11_frame_subtype_PS_Poll     ,       0xF,"A  PS-Poll"},\
-       { ieee_802_11_frame_subtype_RTS         ,       0xF,"B  RTS"},\
-       { ieee_802_11_frame_subtype_CTS         ,       0xF,"C  CTS"},\
-       { ieee_802_11_frame_subtype_ACK         ,       0xF,"D  ACK"},\
-       { ieee_802_11_frame_subtype_CFEnd       ,       0xF,"E  CF-End"},\
-       { ieee_802_11_frame_subtype_CFEnd_CFAck ,       0xF,"F  CF-End + CF-Ack"},\
-       { ieee_802_11_frame_subtype_Data        ,       0xF,"0  Data"},\
-       { ieee_802_11_frame_subtype_Data_CFAck  ,       0xF,"1  Data + CF-Ack"},\
-       { ieee_802_11_frame_subtype_Data_CFPoll ,       0xF,"2  Data + CF-Poll"},\
-       { ieee_802_11_frame_subtype_Data_CFAck_CFPoll,  0xF,"3  Data + CF-Ack + CF-Poll"},\
-       { ieee_802_11_frame_subtype_Null_Function ,     0xF,"4  Null Function (no data)"},\
-       { ieee_802_11_frame_subtype_CFAck ,             0xF,"5  CF-Ack (no data)"},\
-       { ieee_802_11_frame_subtype_CFPoll ,            0xF,"6  CF-Poll (no data)"},\
-       { ieee_802_11_frame_subtype_CFAck_CFPoll,       0xF,"y7  CF-Ack + CF-Poll (no data)"},\
-       { 0,0,NULL}\
-}
-struct ieee_802_11_frame_subtype_class {
-       u8      subtype;
-       u8      mask;
-       u8      class;
-       u8      type;
-};
-#define ieee_802_11_frame_subtype_classes {\
-       { ieee_802_11_frame_subtype_Association_Req,    0xF,2,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Association_Resp,   0xF,2,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Reassociation_Req,  0xF,2,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Reassociation_Resp, 0xF,2,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Probe_Req   ,       0xF,1,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Probe_Resp  ,       0xF,1,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Beacon      ,       0xF,1,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_ATIM        ,       0xF,1,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Disassociation,     0xF,2,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Authentication,     0xF,1,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_Deauthentication,   0xF,3,ieee_802_11_frame_type_Management},\
-       { ieee_802_11_frame_subtype_PS-Poll     ,       0xF,3,ieee_802_11_frame_type_Control},\
-       { ieee_802_11_frame_subtype_RTS         ,       0xF,1,ieee_802_11_frame_type_Control},\
-       { ieee_802_11_frame_subtype_CTS         ,       0xF,1,ieee_802_11_frame_type_Control},\
-       { ieee_802_11_frame_subtype_ACK         ,       0xF,1,ieee_802_11_frame_type_Control},\
-       { ieee_802_11_frame_subtype_CFEnd       ,       0xF,1,ieee_802_11_frame_type_Control},\
-       { ieee_802_11_frame_subtype_CFEnd_CFAck ,       0xF,1,ieee_802_11_frame_type_Control},\
-       { ieee_802_11_frame_subtype_Data        ,       0xF,3,ieee_802_11_frame_type_Data},\
-       { ieee_802_11_frame_subtype_Data_CFAck  ,       0xF,3,ieee_802_11_frame_type_Data},\
-       { ieee_802_11_frame_subtype_Data_CF_Poll        0xF,3,ieee_802_11_frame_type_Data},\
-       { ieee_802_11_frame_subtype_Data_CF_AckCF_Poll, 0xF,3,ieee_802_11_frame_type_Data},\
-       { ieee_802_11_frame_subtype_NullFunction        0xF,1,ieee_802_11_frame_type_Data},\
-       { ieee_802_11_frame_subtype_CF_Ack ,            0xF,1,ieee_802_11_frame_type_Data},\
-       { ieee_802_11_frame_subtype_CF_Poll ,           0xF,1,ieee_802_11_frame_type_Data},\
-       { ieee_802_11_frame_subtype_CF_AckCF_Poll,      0xF,1,ieee_802_11_frame_type_Data},\
-       { 0,0,NULL}\
-}
-
-
-#endif
diff --git a/include/linux/acpi_serial.h b/include/linux/acpi_serial.h
deleted file mode 100644 (file)
index e4b87c5..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *  linux/include/linux/acpi_serial.h
- *
- *  Copyright (C) 2000  Hewlett-Packard Co.
- *  Copyright (C) 2000  Khalid Aziz <khalid_aziz@hp.com>
- *
- *  Definitions for ACPI defined serial ports (headless console and 
- *  debug ports)
- *
- */
-
-#include <linux/serial.h>
-
-extern void setup_serial_acpi(void *);
-
-#define ACPI_SIG_LEN           4
-
-/* ACPI table signatures */
-#define ACPI_SPCRT_SIGNATURE   "SPCR"
-#define ACPI_DBGPT_SIGNATURE   "DBGP"
-
-/* Interface type as defined in ACPI serial port tables */
-#define ACPI_SERIAL_INTFC_16550        0
-#define ACPI_SERIAL_INTFC_16450        1
-
-/* Interrupt types for ACPI serial port tables */
-#define ACPI_SERIAL_INT_PCAT   0x01
-#define ACPI_SERIAL_INT_APIC   0x02
-#define ACPI_SERIAL_INT_SAPIC  0x04
-
-/* Baud rates as defined in ACPI serial port tables */
-#define ACPI_SERIAL_BAUD_9600          3
-#define ACPI_SERIAL_BAUD_19200         4
-#define ACPI_SERIAL_BAUD_57600         6
-#define ACPI_SERIAL_BAUD_115200                7
-
-/* Parity as defined in ACPI serial port tables */
-#define ACPI_SERIAL_PARITY_NONE                0
-
-/* Flow control methods as defined in ACPI serial port tables */
-#define ACPI_SERIAL_FLOW_DCD   0x01
-#define ACPI_SERIAL_FLOW_RTS   0x02
-#define ACPI_SERIAL_FLOW_XON   0x04
-
-/* Terminal types as defined in ACPI serial port tables */
-#define ACPI_SERIAL_TERM_VT100         0
-#define ACPI_SERIAL_TERM_VT100X        1
-
-/* PCI Flags as defined by SPCR table */
-#define ACPI_SERIAL_PCIFLAG_PNP        0x00000001
-
-/* Space ID as defined in base address structure in ACPI serial port tables */
-#define ACPI_SERIAL_MEM_SPACE          0
-#define ACPI_SERIAL_IO_SPACE           1
-#define ACPI_SERIAL_PCICONF_SPACE      2
-
-/* 
- * Generic Register Address Structure - as defined by Microsoft 
- * in http://www.microsoft.com/hwdev/onnow/download/LFreeACPI.doc
- *
-*/
-typedef struct {
-       u8  space_id;
-       u8  bit_width;
-       u8  bit_offset;
-       u8  resv;
-       u32 addrl;
-       u32 addrh;
-} gen_regaddr;
-
-/* Space ID for generic register address structure */
-#define REGADDR_SPACE_SYSMEM   0
-#define REGADDR_SPACE_SYSIO    1
-#define REGADDR_SPACE_PCICONFIG        2
-
-/* Serial Port Console Redirection and Debug Port Table formats */
-typedef struct {
-       u8 signature[4];
-       u32 length;
-       u8  rev;
-       u8  chksum;
-       u8  oemid[6];
-       u8  oem_tabid[8];
-       u32 oem_rev;
-       u8  creator_id[4];
-       u32 creator_rev;
-       u8  intfc_type;
-       u8  resv1[3];
-       gen_regaddr base_addr;
-       u8  int_type;
-       u8  irq;
-       u8  global_int[4];
-       u8  baud;
-       u8  parity;
-       u8  stop_bits;
-       u8  flow_ctrl;
-       u8  termtype;
-       u8  language;
-       u16 pci_dev_id;
-       u16 pci_vendor_id;
-       u8  pci_bus;
-       u8  pci_dev;
-       u8  pci_func;
-       u8  pci_flags[4];
-       u8  pci_seg;
-       u32 resv2;
-} acpi_ser_t;
diff --git a/include/linux/adb_mouse.h b/include/linux/adb_mouse.h
deleted file mode 100644 (file)
index 8791780..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _LINUX_ADB_MOUSE_H
-#define _LINUX_ADB_MOUSE_H
-
-/*
- * linux/include/linux/mac_mouse.h
- * header file for Macintosh ADB mouse driver
- * 27-10-97 Michael Schmitz
- * copied from:
- * header file for Atari Mouse driver
- * by Robert de Vries (robert@and.nl) on 19Jul93
- */
-
-struct mouse_status {
-       char            buttons;
-       short           dx;
-       short           dy;
-       int             ready;
-       int             active;
-       struct wait_queue *wait;
-       struct fasync_struct *fasyncptr;
-};
-
-#endif
diff --git a/include/linux/atapi.h b/include/linux/atapi.h
deleted file mode 100644 (file)
index 806aa4e..0000000
+++ /dev/null
@@ -1,370 +0,0 @@
-/**** vi:set ts=8 sts=8 sw=8:************************************************
- *
- * Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-#include <linux/types.h>
-#include <asm/byteorder.h>
-
-/*
- * With each packet command, we allocate a buffer.
- * This is used for several packet
- * commands (Not for READ/WRITE commands).
- */
-#define IDEFLOPPY_PC_BUFFER_SIZE       256
-#define IDETAPE_PC_BUFFER_SIZE         256
-
-/*
- * Packet flags bits.
- */
-
-#define        PC_ABORT                0       /* set when an error is considered normal - we won't retry */
-#define PC_WAIT_FOR_DSC                1       /* 1 when polling for DSC on a media access command */
-#define PC_DMA_RECOMMENDED     2       /* 1 when we prefer to use DMA if possible */
-#define        PC_DMA_IN_PROGRESS      3       /* 1 while DMA in progress */
-#define        PC_DMA_ERROR            4       /* 1 when encountered problem during DMA */
-#define        PC_WRITING              5       /* data direction */
-#define        PC_SUPPRESS_ERROR       6       /* suppress error reporting */
-#define PC_TRANSFORM           7       /* transform SCSI commands */
-
-/* This struct get's shared between different drivers.
- */
-struct atapi_packet_command {
-       u8 c[12];                       /* Actual packet bytes */
-       char *buffer;                   /* Data buffer */
-       int buffer_size;                /* Size of our data buffer */
-       char *current_position;         /* Pointer into the above buffer */
-       int request_transfer;           /* Bytes to transfer */
-       int actually_transferred;       /* Bytes actually transferred */
-
-       unsigned long flags;            /* Status/Action bit flags: long for set_bit */
-
-       /* FIXME: the following is ugly as hell, but the only way we can start
-        * actually to unify the code.
-        */
-       /* driver specific data. */
-       /* floppy/tape */
-       int retries;                            /* On each retry, we increment retries */
-       int error;                              /* Error code */
-       char *b_data;                           /* Pointer which runs on the buffers */
-       unsigned int b_count;                   /* Missing/Available data on the current buffer */
-       u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */
-       /* Called when this packet command is completed */
-       void (*callback) (struct ata_device *, struct request *);
-
-       /* only tape */
-       struct bio *bio;
-
-       /* only scsi */
-       struct {
-               unsigned int b_count;                   /* Bytes transferred from current entry */
-               struct scatterlist *sg;                 /* Scatter gather table */
-               struct scsi_cmnd *scsi_cmd;             /* SCSI command */
-               void (*done)(struct scsi_cmnd *);       /* Scsi completion routine */
-               unsigned long timeout;                  /* Command timeout */
-       } s;
-};
-
-/*
- *     ATAPI Status Register.
- */
-typedef union {
-       u8 all                  : 8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               u8 check        : 1;    /* Error occurred */
-               u8 idx          : 1;    /* Reserved */
-               u8 corr         : 1;    /* Correctable error occurred */
-               u8 drq          : 1;    /* Data is request by the device */
-               u8 dsc          : 1;    /* Media access command finished / Buffer availability */
-               u8 reserved5    : 1;    /* Reserved */
-               u8 drdy         : 1;    /* Ignored for ATAPI commands (ready to accept ATA command) */
-               u8 bsy          : 1;    /* The device has access to the command block */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               u8 bsy          : 1;
-               u8 drdy         : 1;
-               u8 reserved5    : 1;
-               u8 dsc          : 1;
-               u8 drq          : 1;
-               u8 corr         : 1;
-               u8 idx          : 1;
-               u8 check        : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_status_reg_t;
-
-/*
- *     ATAPI error register.
- */
-typedef union {
-       u8 all                  : 8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               u8 ili          : 1;    /* Illegal Length Indication */
-               u8 eom          : 1;    /* End Of Media Detected */
-               u8 abrt         : 1;    /* Aborted command - As defined by ATA */
-               u8 mcr          : 1;    /* Media Change Requested - As defined by ATA */
-               u8 sense_key    : 4;    /* Sense key of the last failed packet command */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               u8 sense_key    : 4;
-               u8 mcr          : 1;
-               u8 abrt         : 1;
-               u8 eom          : 1;
-               u8 ili          : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_error_reg_t;
-
-/* Currently unused, but please do not remove.  --bkz */
-/*
- *     ATAPI Feature Register.
- */
-typedef union {
-       u8 all                  : 8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               u8 dma          : 1;    /* Using DMA or PIO */
-               u8 reserved321  : 3;    /* Reserved */
-               u8 reserved654  : 3;    /* Reserved (Tag Type) */
-               u8 reserved7    : 1;    /* Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               u8 reserved7    : 1;
-               u8 reserved654  : 3;
-               u8 reserved321  : 3;
-               u8 dma          : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_feature_reg_t;
-
-/*
- *     ATAPI Byte Count Register.
- */
-typedef union {
-       u16 all                 : 16;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               u8 low;                 /* LSB */
-               u8 high;                /* MSB */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               u8 high;
-               u8 low;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_bcount_reg_t;
-
-/*
- *     ATAPI Interrupt Reason Register.
- */
-typedef union {
-       u8 all                  : 8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               u8 cod          : 1;    /* Information transferred is command (1) or data (0) */
-               u8 io           : 1;    /* The device requests us to read (1) or write (0) */
-               u8 reserved     : 6;    /* Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               u8 reserved     : 6;
-               u8 io           : 1;
-               u8 cod          : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_ireason_reg_t;
-
-/* Currently unused, but please do not remove.  --bkz */
-/*
- *     ATAPI Drive Select Register.
- */
-typedef union {
-       u8 all                  :8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               u8 sam_lun      :3;     /* Logical unit number */
-               u8 reserved3    :1;     /* Reserved */
-               u8 drv          :1;     /* The responding drive will be drive 0 (0) or drive 1 (1) */
-               u8 one5         :1;     /* Should be set to 1 */
-               u8 reserved6    :1;     /* Reserved */
-               u8 one7         :1;     /* Should be set to 1 */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               u8 one7         :1;
-               u8 reserved6    :1;
-               u8 one5         :1;
-               u8 drv          :1;
-               u8 reserved3    :1;
-               u8 sam_lun      :3;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_drivesel_reg_t;
-
-/* Currently unused, but please do not remove.  --bkz */
-/*
- *     ATAPI Device Control Register.
- */
-typedef union {
-       u8 all                  : 8;
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               u8 zero0        : 1;    /* Should be set to zero */
-               u8 nien         : 1;    /* Device interrupt is disabled (1) or enabled (0) */
-               u8 srst         : 1;    /* ATA software reset. ATAPI devices should use the new ATAPI srst. */
-               u8 one3         : 1;    /* Should be set to 1 */
-               u8 reserved4567 : 4;    /* Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               u8 reserved4567 : 4;
-               u8 one3         : 1;
-               u8 srst         : 1;
-               u8 nien         : 1;
-               u8 zero0        : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       } b;
-} atapi_control_reg_t;
-
-/*
- *     The following is used to format the general configuration word
- *     of the ATAPI IDENTIFY DEVICE command.
- */
-struct atapi_id_gcw {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-       u8 packet_size          : 2;    /* Packet Size */
-       u8 reserved234          : 3;    /* Reserved */
-       u8 drq_type             : 2;    /* Command packet DRQ type */
-       u8 removable            : 1;    /* Removable media */
-       u8 device_type          : 5;    /* Device type */
-       u8 reserved13           : 1;    /* Reserved */
-       u8 protocol             : 2;    /* Protocol type */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-       u8 protocol             : 2;
-       u8 reserved13           : 1;
-       u8 device_type          : 5;
-       u8 removable            : 1;
-       u8 drq_type             : 2;
-       u8 reserved234          : 3;
-       u8 packet_size          : 2;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-};
-
-/*
- *     INQUIRY packet command - Data Format.
- */
-typedef struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-       u8      device_type     : 5;    /* Peripheral Device Type */
-       u8      reserved0_765   : 3;    /* Peripheral Qualifier - Reserved */
-       u8      reserved1_6t0   : 7;    /* Reserved */
-       u8      rmb             : 1;    /* Removable Medium Bit */
-       u8      ansi_version    : 3;    /* ANSI Version */
-       u8      ecma_version    : 3;    /* ECMA Version */
-       u8      iso_version     : 2;    /* ISO Version */
-       u8      response_format : 4;    /* Response Data Format */
-       u8      reserved3_45    : 2;    /* Reserved */
-       u8      reserved3_6     : 1;    /* TrmIOP - Reserved */
-       u8      reserved3_7     : 1;    /* AENC - Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-       u8      reserved0_765   : 3;
-       u8      device_type     : 5;
-       u8      rmb             : 1;
-       u8      reserved1_6t0   : 7;
-       u8      iso_version     : 2;
-       u8      ecma_version    : 3;
-       u8      ansi_version    : 3;
-       u8      reserved3_7     : 1;
-       u8      reserved3_6     : 1;
-       u8      reserved3_45    : 2;
-       u8      response_format : 4;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       u8      additional_length;      /* Additional Length (total_length-4) */
-       u8      rsv5, rsv6, rsv7;       /* Reserved */
-       u8      vendor_id[8];           /* Vendor Identification */
-       u8      product_id[16];         /* Product Identification */
-       u8      revision_level[4];      /* Revision Level */
-       u8      vendor_specific[20];    /* Vendor Specific - Optional */
-       u8      reserved56t95[40];      /* Reserved - Optional */
-                                       /* Additional information may be returned */
-} atapi_inquiry_result_t;
-
-/*
- *     REQUEST SENSE packet command result - Data Format.
- */
-typedef struct atapi_request_sense {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-       u8      error_code      : 7;    /* Error Code (0x70 - current or 0x71 - deferred) */
-       u8      valid           : 1;    /* The information field conforms to standard */
-       u8      reserved1       : 8;    /* Reserved (Segment Number) */
-       u8      sense_key       : 4;    /* Sense Key */
-       u8      reserved2_4     : 1;    /* Reserved */
-       u8      ili             : 1;    /* Incorrect Length Indicator */
-       u8      eom             : 1;    /* End Of Medium */
-       u8      filemark        : 1;    /* Filemark */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-       u8      valid           : 1;
-       u8      error_code      : 7;
-       u8      reserved1       : 8;
-       u8      filemark        : 1;
-       u8      eom             : 1;
-       u8      ili             : 1;
-       u8      reserved2_4     : 1;
-       u8      sense_key       : 4;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       u32     information __attribute__ ((packed));
-       u8      asl;                    /* Additional sense length (n-7) */
-       u32     command_specific;       /* Additional command specific information */
-       u8      asc;                    /* Additional Sense Code */
-       u8      ascq;                   /* Additional Sense Code Qualifier */
-       u8      replaceable_unit_code;  /* Field Replaceable Unit Code */
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-       u8      sk_specific1    : 7;    /* Sense Key Specific */
-       u8      sksv            : 1;    /* Sense Key Specific information is valid */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-       u8      sksv            : 1;    /* Sense Key Specific information is valid */
-       u8      sk_specific1    : 7;    /* Sense Key Specific */
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-       u8      sk_specific[2];         /* Sense Key Specific */
-       u8      pad[2];                 /* Padding to 20 bytes */
-} atapi_request_sense_result_t;
-
-
-extern void atapi_init_pc(struct atapi_packet_command *pc);
-
-extern void atapi_discard_data(struct ata_device *, unsigned int);
-extern void atapi_write_zeros(struct ata_device *, unsigned int);
-
-extern void atapi_read(struct ata_device *, u8 *, unsigned int);
-extern void atapi_write(struct ata_device *, u8 *, unsigned int);
-
-typedef enum {
-       ide_wait,       /* insert rq at end of list, and wait for it */
-       ide_preempt,    /* insert rq in front of current request */
-       ide_end         /* insert rq at end of list, but don't wait for it */
-} ide_action_t;
-
-extern int ide_do_drive_cmd(struct ata_device *, struct request *, ide_action_t);
index 6d70bd5..2908c7a 100644 (file)
@@ -194,6 +194,7 @@ int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
 int generic_cont_expand(struct inode *inode, loff_t size) ;
 int block_commit_write(struct page *page, unsigned from, unsigned to);
 int block_sync_page(struct page *);
+void flush_inode_pages (struct inode * inode);
 sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
 int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
 int block_truncate_page(struct address_space *, loff_t, get_block_t *);
@@ -274,6 +275,7 @@ map_bh(struct buffer_head *bh, struct super_block *sb, sector_t block)
  */
 static inline void wait_on_buffer(struct buffer_head *bh)
 {
+       might_sleep();
        if (buffer_locked(bh) || atomic_read(&bh->b_count) == 0)
                __wait_on_buffer(bh);
 }
index c96e7b6..7798d2c 100644 (file)
@@ -235,6 +235,7 @@ typedef __u32 kernel_cap_t;
 /* Allow enabling/disabling tagged queuing on SCSI controllers and sending
    arbitrary SCSI commands */
 /* Allow setting encryption key on loopback filesystem */
+/* Allow the selection of a security context */
 
 #define CAP_SYS_ADMIN        21
 
@@ -284,6 +285,11 @@ typedef __u32 kernel_cap_t;
 
 #define CAP_LEASE            28
 
+/* Allow context manipulations */
+/* Allow changing context info on files */
+
+#define CAP_CONTEXT          29
+
 #ifdef __KERNEL__
 /* 
  * Bounding set
diff --git a/include/linux/ckrm-io.h b/include/linux/ckrm-io.h
new file mode 100644 (file)
index 0000000..36040b9
--- /dev/null
@@ -0,0 +1,40 @@
+/* linux/drivers/block/ckrm_io.c : Block I/O Resource Controller for CKRM
+ *
+ * Copyright (C) Shailabh Nagar, IBM Corp. 2004
+ * 
+ * 
+ * Provides best-effort block I/O bandwidth control for CKRM 
+ * This file provides the CKRM API. The underlying scheduler is a 
+ * modified Complete-Fair Queueing (CFQ) iosched.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 29 July 2004
+ *          Third complete rewrite for CKRM's current API
+ *
+ */
+
+
+#ifndef _LINUX_CKRM_IO_H
+#define _LINUX_CKRM_IO_H
+
+typedef void *(*icls_tsk_t) (struct task_struct *tsk);
+typedef int (*icls_ioprio_t) (struct task_struct *tsk);
+
+#ifdef CONFIG_CKRM_RES_BLKIO
+
+extern void *cki_tsk_icls (struct task_struct *tsk);
+extern int cki_tsk_ioprio (struct task_struct *tsk);
+
+#endif /* CONFIG_CKRM_RES_BLKIO */
+
+#endif 
diff --git a/include/linux/ckrm.h b/include/linux/ckrm.h
new file mode 100644 (file)
index 0000000..a29bf28
--- /dev/null
@@ -0,0 +1,166 @@
+/* ckrm.h - Class-based Kernel Resource Management (CKRM)
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003,2004
+ *           (C) Shailabh Nagar,  IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ * 
+ * 
+ * Provides a base header file including macros and basic data structures.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+/* Changes
+ *
+ * 28 Aug 2003
+ *        Created.
+ * 06 Nov 2003
+ *        Made modifications to suit the new RBCE module.
+ * 10 Nov 2003
+ *        Added callbacks_active and surrounding logic. Added task paramter
+ *        for all CE callbacks.
+ * 19 Nov 2004
+ *        New Event callback structure
+ */
+
+#ifndef _LINUX_CKRM_H
+#define _LINUX_CKRM_H
+
+#ifdef CONFIG_CKRM
+
+// Data structure and function to get the list of registered 
+// resource controllers.
+
+// #include <linux/sched.h>
+
+/* CKRM defines a set of events at particular points in the kernel
+ * at which callbacks registered by various class types are called
+ */
+
+enum ckrm_event {
+       /* we distinguish various events types
+        *
+        * (a) CKRM_LATCHABLE_EVENTS
+        *      events can be latched for event callbacks by classtypes
+        *
+        * (b) CKRM_NONLATACHBLE_EVENTS
+        *     events can not be latched but can be used to call classification
+        * 
+        * (c) event that are used for notification purposes
+        *     range: [ CKRM_EVENT_CANNOT_CLASSIFY .. )
+        */
+
+       /* events (a) */
+
+       CKRM_LATCHABLE_EVENTS,
+
+       CKRM_EVENT_NEWTASK = CKRM_LATCHABLE_EVENTS,
+       CKRM_EVENT_FORK,
+       CKRM_EVENT_EXIT,
+       CKRM_EVENT_EXEC,
+       CKRM_EVENT_UID,
+       CKRM_EVENT_GID,
+       CKRM_EVENT_XID,
+       CKRM_EVENT_LOGIN,
+       CKRM_EVENT_USERADD,
+       CKRM_EVENT_USERDEL,
+       CKRM_EVENT_LISTEN_START,
+       CKRM_EVENT_LISTEN_STOP,
+       CKRM_EVENT_APPTAG,
+
+       /* events (b) */
+
+       CKRM_NONLATCHABLE_EVENTS,
+
+       CKRM_EVENT_RECLASSIFY = CKRM_NONLATCHABLE_EVENTS,
+
+       /* events (c) */
+       CKRM_NOTCLASSIFY_EVENTS,
+
+       CKRM_EVENT_MANUAL = CKRM_NOTCLASSIFY_EVENTS,
+
+       CKRM_NUM_EVENTS
+};
+#endif
+
+#ifdef __KERNEL__
+#ifdef CONFIG_CKRM
+
+extern void ckrm_invoke_event_cb_chain(enum ckrm_event ev, void *arg);
+
+typedef void (*ckrm_event_cb) (void *arg);
+
+struct ckrm_hook_cb {
+       ckrm_event_cb fct;
+       struct ckrm_hook_cb *next;
+};
+
+#define CKRM_DEF_CB(EV,fct)                                    \
+static inline void ckrm_cb_##fct(void)                         \
+{                                                              \
+         ckrm_invoke_event_cb_chain(CKRM_EVENT_##EV,NULL);      \
+}
+
+#define CKRM_DEF_CB_ARG(EV,fct,argtp)                                  \
+static inline void ckrm_cb_##fct(argtp arg)                            \
+{                                                                      \
+         ckrm_invoke_event_cb_chain(CKRM_EVENT_##EV,(void*)arg);       \
+}
+
+#else                          // !CONFIG_CKRM
+
+#define CKRM_DEF_CB(EV,fct)                    \
+static inline void ckrm_cb_##fct(void)  { }
+
+#define CKRM_DEF_CB_ARG(EV,fct,argtp)          \
+static inline void ckrm_cb_##fct(argtp arg) { }
+
+#endif                         // CONFIG_CKRM
+
+/*-----------------------------------------------------------------
+ *   define the CKRM event functions 
+ *               EVENT          FCT           ARG         
+ *-----------------------------------------------------------------*/
+
+// types we refer at 
+struct task_struct;
+struct sock;
+struct user_struct;
+
+CKRM_DEF_CB_ARG(FORK, fork, struct task_struct *);
+CKRM_DEF_CB_ARG(EXEC, exec, const char *);
+CKRM_DEF_CB(UID, uid);
+CKRM_DEF_CB(GID, gid);
+CKRM_DEF_CB_ARG(XID, xid, struct task_struct *);
+CKRM_DEF_CB(APPTAG, apptag);
+CKRM_DEF_CB(LOGIN, login);
+CKRM_DEF_CB_ARG(USERADD, useradd, struct user_struct *);
+CKRM_DEF_CB_ARG(USERDEL, userdel, struct user_struct *);
+CKRM_DEF_CB_ARG(LISTEN_START, listen_start, struct sock *);
+CKRM_DEF_CB_ARG(LISTEN_STOP, listen_stop, struct sock *);
+
+// some other functions required
+#ifdef CONFIG_CKRM
+extern void ckrm_init(void);
+void ckrm_cb_newtask(struct task_struct *);
+void ckrm_cb_exit(struct task_struct *);
+#else
+#define ckrm_init(x)           do { } while (0)
+#define ckrm_cb_newtask(x)     do { } while (0)
+#define ckrm_cb_exit(x)                do { } while (0)
+#endif
+
+extern int get_exe_path_name(struct task_struct *, char *, int);
+
+#endif                         // __KERNEL__
+
+#endif                         // _LINUX_CKRM_H
diff --git a/include/linux/ckrm_ce.h b/include/linux/ckrm_ce.h
new file mode 100644 (file)
index 0000000..f4e91e9
--- /dev/null
@@ -0,0 +1,112 @@
+/* ckrm_ce.h - Header file to be used by Classification Engine of CKRM
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *           (C) Shailabh Nagar,  IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ * 
+ * Provides data structures, macros and kernel API of CKRM for 
+ * classification engine.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+/* Changes
+ *
+ * 12 Nov 2003
+ *        Created.
+ * 22 Apr 2004
+ *        Adopted to classtypes
+ */
+
+#ifndef _LINUX_CKRM_CE_H
+#define _LINUX_CKRM_CE_H
+
+#ifdef CONFIG_CKRM
+
+#include <linux/ckrm.h>                // getting the event names
+
+/* Action parameters identifying the cause of a task<->class notify callback 
+ * these can perculate up to user daemon consuming records send by the 
+ * classification engine
+ */
+
+#ifdef __KERNEL__
+
+typedef void *(*ce_classify_fct_t) (enum ckrm_event event, void *obj, ...);
+typedef void (*ce_notify_fct_t) (enum ckrm_event event, void *classobj,
+                                void *obj);
+
+typedef struct ckrm_eng_callback {
+       /* general state information */
+       int always_callback;    /* set if CE should always be called back 
+                                  regardless of numclasses */
+
+
+
+
+       /* callbacks which are called without holding locks */
+
+       unsigned long c_interest;       /* set of classification events of 
+                                          interest to CE 
+                                       */
+
+       /* generic classify */
+       ce_classify_fct_t classify;     
+       /* class added */
+       void (*class_add) (const char *name, void *core, int classtype);
+       /* class deleted */
+       void (*class_delete) (const char *name, void *core, int classtype);
+
+
+       /* callbacks which are called while holding task_lock(tsk) */
+
+       unsigned long n_interest;       /* set of notification events of 
+                                          interest to CE 
+                                       */
+       /* notify on class switch */
+       ce_notify_fct_t notify; 
+
+} ckrm_eng_callback_t;
+
+struct inode;
+struct dentry;
+
+typedef struct rbce_eng_callback {
+       int (*mkdir) (struct inode *, struct dentry *, int);    // mkdir
+       int (*rmdir) (struct inode *, struct dentry *); // rmdir
+       int (*mnt) (void);
+       int (*umnt) (void);
+} rbce_eng_callback_t;
+
+extern int ckrm_register_engine(const char *name, ckrm_eng_callback_t *);
+extern int ckrm_unregister_engine(const char *name);
+
+extern void *ckrm_classobj(char *, int *classtype);
+extern int get_exe_path_name(struct task_struct *t, char *filename,
+                            int max_size);
+
+extern int rcfs_register_engine(rbce_eng_callback_t *);
+extern int rcfs_unregister_engine(rbce_eng_callback_t *);
+
+extern int ckrm_reclassify(int pid);
+
+#ifndef _LINUX_CKRM_RC_H
+// ckrm kernel has inlined functions for this which are exported
+extern void ckrm_core_grab(void *);
+extern void ckrm_core_drop(void *);
+#endif
+
+#endif                         // CONFIG_CKRM
+
+#endif                         // __KERNEL__
+
+#endif                         // _LINUX_CKRM_CE_H
diff --git a/include/linux/ckrm_classqueue.h b/include/linux/ckrm_classqueue.h
new file mode 100644 (file)
index 0000000..3041c81
--- /dev/null
@@ -0,0 +1,130 @@
+/* include/linux/ckrm_classqueue.h : cpu control for CKRM
+ *
+ * Copyright (C) Haoqiang Zheng, IBM Corp. 2003
+ *           (C) Hubertus Franke, IBM Corp. 2003
+ * 
+ * Circular queue functionality for CKRM cpu controller
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * Aug 28, 2003
+ *        Created.
+ * July 07, 2004
+ *   clean up, add comments     
+ *   
+ */
+
+#ifndef _CKRM_CLASSQUEUE_H
+#define _CKRM_CLASSQUEUE_H
+
+#include <linux/list.h>
+
+#define CLASSQUEUE_SIZE 1024   // acb: changed from 128
+//#define CLASSQUEUE_SIZE 128
+#define CQ_BITMAP_SIZE ((((CLASSQUEUE_SIZE+1+7)/8)+sizeof(long)-1)/sizeof(long))
+
+/**
+ * struct cq_prio_array: duplicates prio_array defined in sched.c 
+ *
+ * I duplicate this data structure to make ckrm_classqueue implementation more modular
+ */
+struct cq_prio_array {
+       int nr_active;
+       unsigned long bitmap[CQ_BITMAP_SIZE];
+       struct list_head queue[CLASSQUEUE_SIZE];
+};
+
+/**
+ * struct classqueue_struct - a runqueue of class local runqueues
+ * @array: priority array
+ * @base: base priority
+ * @base_offset: index in array for the base
+ *
+ * classqueue can be thought of as runqueue of classes (instead of runqueue of tasks)
+ * as task runqueue, each processor has a classqueue
+ * a class enters the classqueue when the first task in this class local runqueue shows up
+ * a class enters the classqueue when the last task in the local runqueue leaves
+ * class local runqueues are ordered based their priority
+ *
+ * status:
+ *   hzheng: is 32bit base long enough?
+ */
+struct classqueue_struct {
+       struct cq_prio_array array;
+       unsigned long base;
+       unsigned long base_offset;
+};
+
+/** 
+ * struct cq_node_struct - the link object between class local runqueue and classqueue
+ * @list: links the class local runqueue to classqueue
+ * @prio: class priority, which is caculated based on it's progress (cvt) and urgency (top_priority)
+ * @index: real index into the classqueue array, calculated based on priority
+ *
+ * NOTE: make sure list is empty when it's not in classqueue
+ */
+struct cq_node_struct {
+       struct list_head list;
+       int prio;
+       int index;
+};
+typedef struct cq_node_struct cq_node_t;
+
+typedef unsigned long long CVT_t;      // cummulative virtual time
+
+static inline void cq_node_init(cq_node_t * node)
+{
+       node->prio = 0;
+       node->index = -1;
+       INIT_LIST_HEAD(&node->list);
+}
+
+/*if the class is in classqueue*/
+static inline int cls_in_classqueue(cq_node_t * node)
+{
+       return !list_empty(&node->list);
+}
+
+/*initialize the data structure*/
+int classqueue_init(struct classqueue_struct *cq);
+
+/*add the class to classqueue*/
+void classqueue_enqueue(struct classqueue_struct *cq, cq_node_t * node, int prio);
+
+/**
+ * classqueue_dequeue - remove the class from classqueue
+ * 
+ * internal:
+ *   called when the last task is removed from the queue
+ *   checked on load balancing and schedule
+ *   hzheng: why don't I call it on class_dequeue_task?
+ */
+void classqueue_dequeue(struct classqueue_struct *cq, cq_node_t * node);
+
+/*change the position of the class in classqueue*/
+void classqueue_update_prio(struct classqueue_struct *cq, cq_node_t * node, int new_prio);
+
+/*return the first class in classqueue*/
+cq_node_t *classqueue_get_head(struct classqueue_struct *cq);
+
+/*update the base priority of the classqueue*/
+void classqueue_update_base(struct classqueue_struct *cq);
+
+/**
+ * class_compare_prio: compare the priority of this two nodes
+ */
+static inline int class_compare_prio(struct cq_node_struct* node1, struct cq_node_struct* node2)
+{
+       return ( node1->prio - node2->prio);
+}
+
+#endif
diff --git a/include/linux/ckrm_mem.h b/include/linux/ckrm_mem.h
new file mode 100644 (file)
index 0000000..4efebb9
--- /dev/null
@@ -0,0 +1,107 @@
+/* include/linux/ckrm_mem.h : memory control for CKRM
+ *
+ * Copyright (C) Jiantao Kong, IBM Corp. 2003
+ *           (C) Shailabh Nagar, IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2004
+ * 
+ * 
+ * Memory control functions of the CKRM kernel API 
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 28 Aug 2003
+ *        Created.
+ */
+
+#ifndef _LINUX_CKRM_MEM_H
+#define _LINUX_CKRM_MEM_H
+
+#ifdef CONFIG_CKRM_RES_MEM
+
+#include <linux/list.h>
+#include <linux/ckrm_rc.h>
+
+typedef struct ckrm_mem_res {
+       unsigned long reclaim_flags; 
+       unsigned long flags; 
+       struct ckrm_core_class *core; // the core i am part of...
+       struct ckrm_core_class *parent; // parent of the core i am part of....
+       struct ckrm_shares shares;
+       struct list_head mcls_list; // list of all 1-level classes
+       struct list_head shrink_list; // list of classes need to be shrunk
+       atomic_t nr_users; // # of references to this class/data structure
+       atomic_t pg_total;  // # of pages used by this class
+       int pg_guar; // # of pages this class is guaranteed
+       int pg_limit; // max # of pages this class can get
+       int pg_borrowed; // # of pages this class borrowed from its parent
+       int pg_lent; // # of pages this class lent to its children
+       int pg_unused; // # of pages left to this class (after giving the
+                               // guarantees to children. need to borrow from parent if
+                               // more than this is needed.
+       int nr_active[MAX_NR_ZONES];
+       int nr_inactive[MAX_NR_ZONES];
+       int tmp_cnt;
+       int shrink_count;
+       unsigned long last_shrink;
+       int over_limit_failures;
+       int hier; // hiearchy, root = 0
+} ckrm_mem_res_t;
+
+extern atomic_t ckrm_mem_real_count;
+extern unsigned int ckrm_tot_lru_pages;
+extern struct list_head ckrm_shrink_list;
+extern spinlock_t ckrm_mem_lock;
+extern struct ckrm_res_ctlr mem_rcbs;
+
+#define page_class(page)       ((ckrm_mem_res_t*)((page)->memclass))
+
+// used to fill reclaim_flags, used only when memory is low in the system
+#define CLS_CLEAR              (0)      // class under its guarantee
+#define CLS_OVER_GUAR  (1 << 0) // class is over its guarantee
+#define CLS_PARENT_OVER        (1 << 1) // parent is over 110% mark over limit
+#define CLS_OVER_25            (1 << 2) // class over 25% mark bet guar(0) & limit(100)
+#define CLS_OVER_50            (1 << 3) // class over 50% mark bet guar(0) & limit(100)
+#define CLS_OVER_75            (1 << 4) // class over 75% mark bet guar(0) & limit(100)
+#define CLS_OVER_100   (1 << 5) // class over its limit
+#define CLS_OVER_110   (1 << 6) // class over 110% mark over limit
+#define CLS_FLAGS_ALL  ( CLS_OVER_GUAR | CLS_PARENT_OVER | CLS_OVER_25 | \
+                                       CLS_OVER_50 | CLS_OVER_75 | CLS_OVER_100 | CLS_OVER_110 )
+#define CLS_SHRINK_BIT (31)      // used to both lock and set the bit
+#define CLS_SHRINK             (1 << CLS_SHRINK_BIT) // shrink the given class
+
+// used in flags. set when a class is more than 90% of its maxlimit
+#define MEM_AT_LIMIT 1
+
+extern void ckrm_set_aggressive(ckrm_mem_res_t *);
+extern unsigned int ckrm_setup_reclamation(void);
+extern void ckrm_teardown_reclamation(void);
+extern void ckrm_get_reclaim_bits(unsigned int *, unsigned int *);
+extern void ckrm_init_mm_to_task(struct mm_struct *, struct task_struct *);
+extern void ckrm_mem_evaluate_mm(struct mm_struct *);
+extern void ckrm_at_limit(ckrm_mem_res_t *);
+extern int ckrm_memclass_valid(ckrm_mem_res_t *);
+#define ckrm_get_reclaim_flags(cls)    ((cls)->reclaim_flags)
+
+#else
+
+#define ckrm_init_mm_to_current(a)                     do {} while (0)
+#define ckrm_mem_evaluate_mm(a)                                do {} while (0)
+#define ckrm_get_reclaim_flags(a)                      (0)
+#define ckrm_setup_reclamation()                       (0)
+#define ckrm_teardown_reclamation()                    do {} while (0)
+#define ckrm_get_reclaim_bits(a, b)                    do { *(a) = 0; *(b)= 0; } while (0)
+#define ckrm_init_mm_to_task(a,b)                      do {} while (0)
+
+#endif // CONFIG_CKRM_RES_MEM
+
+#endif //_LINUX_CKRM_MEM_H
+
diff --git a/include/linux/ckrm_mem_inline.h b/include/linux/ckrm_mem_inline.h
new file mode 100644 (file)
index 0000000..221f936
--- /dev/null
@@ -0,0 +1,312 @@
+/* include/linux/ckrm_mem_inline.h : memory control for CKRM
+ *
+ * Copyright (C) Jiantao Kong, IBM Corp. 2003
+ *           (C) Shailabh Nagar, IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2004
+ * 
+ * 
+ * Memory control functions of the CKRM kernel API 
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 28 Aug 2003
+ *        Created.
+ */
+
+
+#ifndef _LINUX_CKRM_MEM_INLINE_H_
+#define _LINUX_CKRM_MEM_INLINE_H_
+
+#include <linux/rmap.h>
+#include <linux/mmzone.h>
+#include <linux/ckrm_mem.h>
+
+
+#ifdef CONFIG_CKRM_RES_MEM
+
+#define GET_MEM_CLASS(tsk) \
+       ckrm_get_res_class(tsk->taskclass, mem_rcbs.resid, ckrm_mem_res_t)
+
+#define ckrm_set_shrink(cls) \
+       set_bit(CLS_SHRINK_BIT, (unsigned long *)&(cls)->reclaim_flags)
+#define ckrm_test_set_shrink(cls) \
+       test_and_set_bit(CLS_SHRINK_BIT, (unsigned long *)&(cls)->reclaim_flags)
+#define ckrm_clear_shrink(cls) \
+       clear_bit(CLS_SHRINK_BIT, (unsigned long *)&(cls)->reclaim_flags)
+
+#define ckrm_shrink_list_empty()       list_empty(&ckrm_shrink_list)
+
+/*
+ * Currently, the class of an address is assigned to the class with max
+ * available guarantee. Simply replace this function for other policies.
+ */
+static inline int
+ckrm_mem_share_compare(ckrm_mem_res_t *a, ckrm_mem_res_t *b)
+{
+       if (a == NULL) 
+               return -(b != NULL) ;
+       if (b == NULL)
+               return 0;
+       if (a->pg_guar == CKRM_SHARE_DONTCARE)
+               return 1;
+       if (b->pg_guar == CKRM_SHARE_DONTCARE)
+               return -1;
+       return (a->pg_unused - b->pg_unused);
+}
+
+static inline void
+mem_class_get(ckrm_mem_res_t *cls)
+{
+       if (cls)
+               atomic_inc(&((cls)->nr_users));
+}
+
+static inline void
+mem_class_put(ckrm_mem_res_t *cls)
+{
+       const char *name;
+       
+       if (cls && atomic_dec_and_test(&(cls->nr_users)) ) {
+               if (cls->core == NULL) {
+                       name = "unknown";
+               } else {
+                       name = cls->core->name;
+               }
+               printk(KERN_DEBUG "freeing memclass %p of <core:%s>\n", cls, name);
+
+               // BUG_ON(ckrm_memclass_valid(cls));
+               // kfree(cls);
+       }       
+}
+
+static inline void
+incr_use_count(ckrm_mem_res_t *cls, int borrow)
+{
+       atomic_inc(&cls->pg_total);
+
+       if (borrow) 
+               cls->pg_lent++;
+       if ((cls->pg_guar == CKRM_SHARE_DONTCARE) ||
+                               (atomic_read(&cls->pg_total) > cls->pg_unused)) {
+               ckrm_mem_res_t *parcls = ckrm_get_res_class(cls->parent,
+                               mem_rcbs.resid, ckrm_mem_res_t);
+               if (parcls) {
+                       incr_use_count(parcls, 1);
+                       cls->pg_borrowed++;
+               }
+       } else {
+               atomic_inc(&ckrm_mem_real_count);
+       }
+       if ((cls->pg_limit != CKRM_SHARE_DONTCARE) && 
+                       (atomic_read(&cls->pg_total) >= cls->pg_limit) &&
+                       ((cls->flags & MEM_AT_LIMIT) != MEM_AT_LIMIT)) {
+               ckrm_at_limit(cls);
+       }
+       return;
+}
+
+static inline void
+decr_use_count(ckrm_mem_res_t *cls, int borrowed)
+{
+       atomic_dec(&cls->pg_total);
+       if (borrowed)
+               cls->pg_lent--;
+       if (cls->pg_borrowed > 0) {
+               ckrm_mem_res_t *parcls = ckrm_get_res_class(cls->parent,
+                               mem_rcbs.resid, ckrm_mem_res_t);
+               if (parcls) {
+                       decr_use_count(parcls, 1);
+                       cls->pg_borrowed--;
+                       return;
+               }
+       }
+       atomic_dec(&ckrm_mem_real_count);
+}
+
+static inline void
+ckrm_set_page_class(struct page *page, ckrm_mem_res_t *cls)
+{
+       if (mem_rcbs.resid != -1 && cls != NULL) {
+               if (unlikely(page->memclass)) {
+                       mem_class_put(page->memclass);
+               }
+               page->memclass = cls;
+               mem_class_get(cls);
+       } else {
+               page->memclass = NULL;
+       }
+}
+
+static inline void
+ckrm_set_pages_class(struct page *pages, int numpages, ckrm_mem_res_t *cls)
+{
+       int i;
+       for (i = 0; i < numpages; pages++, i++) {
+               ckrm_set_page_class(pages, cls);
+       }
+}
+
+static inline void
+ckrm_clear_page_class(struct page *page)
+{
+       if (page->memclass != NULL) {
+               mem_class_put(page->memclass);
+               page->memclass = NULL;
+       }
+}
+
+static inline void
+ckrm_clear_pages_class(struct page *pages, int numpages)
+{
+       int i;
+       for (i = 0; i < numpages; pages++, i++) {
+               ckrm_clear_page_class(pages);
+       }
+}
+
+static inline void
+ckrm_change_page_class(struct page *page, ckrm_mem_res_t *newcls)
+{
+       ckrm_mem_res_t *oldcls = page_class(page);
+
+       if (!newcls || oldcls == newcls)
+               return;
+
+       ckrm_clear_page_class(page);
+       ckrm_set_page_class(page, newcls);
+       if (test_bit(PG_ckrm_account, &page->flags)) {
+               decr_use_count(oldcls, 0);
+               incr_use_count(newcls, 0);
+               if (PageActive(page)) {
+                       oldcls->nr_active[page_zonenum(page)]--;
+                       newcls->nr_active[page_zonenum(page)]++;
+               } else {
+                       oldcls->nr_inactive[page_zonenum(page)]--;
+                       newcls->nr_inactive[page_zonenum(page)]++;
+               }
+       }
+}
+
+static inline void
+ckrm_change_pages_class(struct page *pages, int numpages, 
+                                       ckrm_mem_res_t *cls)
+{
+       int i;
+       for (i = 0; i < numpages; pages++, i++) {
+               ckrm_change_page_class(pages, cls);
+       }
+}
+
+static inline void
+ckrm_mem_inc_active(struct page *page)
+{
+       ckrm_mem_res_t *cls = page_class(page), *curcls;
+       if (unlikely(!cls)) {
+               return;
+       }
+       BUG_ON(test_bit(PG_ckrm_account, &page->flags));
+       if (unlikely(cls != (curcls = GET_MEM_CLASS(current)))) {
+               cls = curcls;
+               ckrm_change_page_class(page, cls);
+       }
+       cls->nr_active[page_zonenum(page)]++;
+       incr_use_count(cls, 0);
+       set_bit(PG_ckrm_account, &page->flags);
+}
+
+static inline void
+ckrm_mem_dec_active(struct page *page)
+{
+       ckrm_mem_res_t *cls = page_class(page);
+       if (unlikely(!cls)) {
+               return;
+       }
+       BUG_ON(!test_bit(PG_ckrm_account, &page->flags));
+       cls->nr_active[page_zonenum(page)]--;
+       decr_use_count(cls, 0);
+       clear_bit(PG_ckrm_account, &page->flags);
+}
+
+static inline void
+ckrm_mem_inc_inactive(struct page *page)
+{
+       ckrm_mem_res_t *cls = page_class(page), *curcls;
+       if (unlikely(!cls)) {
+               return;
+       }
+       BUG_ON(test_bit(PG_ckrm_account, &page->flags));
+       if (unlikely(cls != (curcls = GET_MEM_CLASS(current)))) {
+               cls = curcls;
+               ckrm_change_page_class(page, cls);
+       }
+       cls->nr_inactive[page_zonenum(page)]++;
+       incr_use_count(cls, 0);
+       set_bit(PG_ckrm_account, &page->flags);
+}
+
+static inline void
+ckrm_mem_dec_inactive(struct page *page)
+{
+       ckrm_mem_res_t *cls = page_class(page);
+       if (unlikely(!cls)) {
+               return;
+       }
+       BUG_ON(!test_bit(PG_ckrm_account, &page->flags));
+       cls->nr_inactive[page_zonenum(page)]--;
+       decr_use_count(cls, 0);
+       clear_bit(PG_ckrm_account, &page->flags);
+}
+
+static inline int
+ckrm_kick_page(struct page *page, unsigned int bits)
+{
+       if (page_class(page) == NULL) {
+               return bits;
+       } else {
+               return (page_class(page)->reclaim_flags & bits);
+       }
+}
+
+static inline int 
+ckrm_class_limit_ok(ckrm_mem_res_t *cls)
+{
+       if ((mem_rcbs.resid == -1) || !cls) {
+               return 1;
+       }
+       if (cls->pg_limit == CKRM_SHARE_DONTCARE) {
+               ckrm_mem_res_t *parcls = ckrm_get_res_class(cls->parent,
+                                               mem_rcbs.resid, ckrm_mem_res_t);
+               return (!parcls ?: ckrm_class_limit_ok(parcls));
+       } else {
+               return (atomic_read(&cls->pg_total) <= (11 * cls->pg_limit) / 10);
+       }
+}
+
+#else // !CONFIG_CKRM_RES_MEM
+
+#define ckrm_set_page_class(a,b)               do{}while(0)
+#define ckrm_set_pages_class(a,b,c)            do{}while(0)
+#define ckrm_clear_page_class(a)               do{}while(0)
+#define ckrm_clear_pages_class(a,b)            do{}while(0)
+#define ckrm_change_page_class(a,b)            do{}while(0)
+#define ckrm_change_pages_class(a,b,c) do{}while(0)
+#define ckrm_mem_inc_active(a)                 do{}while(0)
+#define ckrm_mem_dec_active(a)                 do{}while(0)
+#define ckrm_mem_inc_inactive(a)               do{}while(0)
+#define ckrm_mem_dec_inactive(a)               do{}while(0)
+#define ckrm_shrink_list_empty()               (1)
+#define ckrm_kick_page(a,b)                            (0)
+#define ckrm_class_limit_ok(a)                 (1)
+
+#endif // CONFIG_CKRM_RES_MEM
+
+#endif // _LINUX_CKRM_MEM_INLINE_H_
diff --git a/include/linux/ckrm_net.h b/include/linux/ckrm_net.h
new file mode 100644 (file)
index 0000000..bb4bdbb
--- /dev/null
@@ -0,0 +1,42 @@
+/* ckrm_rc.h - Header file to be used by Resource controllers of CKRM
+ *
+ * Copyright (C) Vivek Kashyap , IBM Corp. 2004
+ * 
+ * Provides data structures, macros and kernel API of CKRM for 
+ * resource controllers.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#ifndef _LINUX_CKRM_NET_H
+#define _LINUX_CKRM_NET_H
+
+struct ckrm_sock_class;
+
+struct ckrm_net_struct {
+       int ns_type;            // type of net class
+       struct sock *ns_sk;     // pointer to socket
+       pid_t ns_tgid;          // real process id
+       pid_t ns_pid;           // calling thread's pid
+       struct task_struct *ns_tsk;
+       int ns_family;          // IPPROTO_IPV4 || IPPROTO_IPV6
+       // Currently only IPV4 is supported
+       union {
+               __u32 ns_dipv4; // V4 listener's address
+       } ns_daddr;
+       __u16 ns_dport;         // listener's port
+       __u16 ns_sport;         // sender's port
+       atomic_t ns_refcnt;
+       struct ckrm_sock_class *core;
+       struct list_head ckrm_link;
+};
+
+#define ns_daddrv4     ns_daddr.ns_dipv4
+
+#endif
diff --git a/include/linux/ckrm_rc.h b/include/linux/ckrm_rc.h
new file mode 100644 (file)
index 0000000..1bf2d07
--- /dev/null
@@ -0,0 +1,400 @@
+/* ckrm_rc.h - Header file to be used by Resource controllers of CKRM
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *           (C) Shailabh Nagar,  IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ *          (C) Vivek Kashyap , IBM Corp. 2004
+ * 
+ * Provides data structures, macros and kernel API of CKRM for 
+ * resource controllers.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 12 Nov 2003
+ *        Created.
+ */
+
+#ifndef _LINUX_CKRM_RC_H
+#define _LINUX_CKRM_RC_H
+
+#ifdef __KERNEL__
+
+#ifdef CONFIG_CKRM
+
+#include <linux/list.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_ce.h>
+#include <linux/seq_file.h>
+
+/* maximum number of class types */
+#define CKRM_MAX_CLASSTYPES         32
+/* maximum classtype name length */
+#define CKRM_MAX_CLASSTYPE_NAME     32
+
+/* maximum resource controllers per classtype */
+#define CKRM_MAX_RES_CTLRS           8
+/* maximum resource controller name length */
+#define CKRM_MAX_RES_NAME          128
+
+struct ckrm_core_class;
+struct ckrm_classtype;
+
+/*****************************************************************************
+ * Share specifications
+ *****************************************************************************/
+
+typedef struct ckrm_shares {
+       int my_guarantee;
+       int my_limit;
+       int total_guarantee;
+       int max_limit;
+       int unused_guarantee;   // not used as parameters
+       int cur_max_limit;      // not used as parameters
+} ckrm_shares_t;
+
+#define CKRM_SHARE_UNCHANGED     (-1)  
+#define CKRM_SHARE_DONTCARE      (-2)  
+#define CKRM_SHARE_DFLT_TOTAL_GUARANTEE (100) 
+#define CKRM_SHARE_DFLT_MAX_LIMIT     (100)  
+
+/******************************************************************************
+ * RESOURCE CONTROLLERS
+ *****************************************************************************/
+
+/* resource controller callback structure */
+
+typedef struct ckrm_res_ctlr {
+       char res_name[CKRM_MAX_RES_NAME];
+       int res_hdepth;         // maximum hierarchy
+       int resid;              // (for now) same as the enum resid
+       struct ckrm_classtype *classtype;    // classtype owning this res ctlr
+
+       /* allocate/free new resource class object for resource controller */
+       void *(*res_alloc) (struct ckrm_core_class * this,
+                           struct ckrm_core_class * parent);
+       void (*res_free) (void *);
+
+       /* set/get limits/guarantees for a resource controller class */
+       int (*set_share_values) (void *, struct ckrm_shares * shares);
+       int (*get_share_values) (void *, struct ckrm_shares * shares);
+
+       /* statistics and configuration access */
+       int (*get_stats) (void *, struct seq_file *);
+       int (*reset_stats) (void *);
+       int (*show_config) (void *, struct seq_file *);
+       int (*set_config) (void *, const char *cfgstr);
+
+       void (*change_resclass) (void *, void *, void *);
+
+} ckrm_res_ctlr_t;
+
+/******************************************************************************
+ * CKRM_CLASSTYPE
+ *
+ * A <struct ckrm_classtype> object describes a dimension for CKRM to classify 
+ * along. Need to provide methods to create and manipulate class objects in
+ * this dimension
+ *****************************************************************************/
+
+/* list of predefined class types, we always recognize */
+#define CKRM_CLASSTYPE_TASK_CLASS    0
+#define CKRM_CLASSTYPE_SOCKET_CLASS  1
+#define CKRM_RESV_CLASSTYPES         2 /* always +1 of last known type */
+
+#define CKRM_MAX_TYPENAME_LEN       32
+
+typedef struct ckrm_classtype {
+       /* Hubertus:   Rearrange slots later for cache friendliness */
+
+       /* resource controllers */
+       spinlock_t res_ctlrs_lock;  // protect res ctlr related data
+       int max_res_ctlrs;          // max number of res ctlrs allowed 
+       int max_resid;              // max resid used                      
+       int resid_reserved;         // max number of reserved controllers  
+       long bit_res_ctlrs;         // bitmap of resource ID used              
+       atomic_t nr_resusers[CKRM_MAX_RES_CTLRS];
+       ckrm_res_ctlr_t *res_ctlrs[CKRM_MAX_RES_CTLRS];
+
+
+       /* state about my classes */
+
+       struct ckrm_core_class *default_class;  
+       struct list_head classes;  // link all classes of this classtype
+       int num_classes;         
+
+       /* state about my ce interaction */
+       atomic_t ce_regd;               // if CE registered
+       int ce_cb_active;       // if Callbacks active
+       atomic_t ce_nr_users;   // number of active transient calls 
+       struct ckrm_eng_callback ce_callbacks;  // callback engine
+
+       // Begin classtype-rcfs private data. No rcfs/fs specific types used. 
+       int mfidx;              // Index into genmfdesc array used to initialize
+       void *mfdesc;           // Array of descriptors of root and magic files
+       int mfcount;            // length of above array 
+       void *rootde;           // root dentry created by rcfs
+       // End rcfs private data 
+
+       char name[CKRM_MAX_TYPENAME_LEN]; // currently same as mfdesc[0]->name 
+                                         // but could be different
+       int typeID;             // unique TypeID
+       int maxdepth;           // maximum depth supported
+
+       /* functions to be called on any class type by external API's */
+
+       struct ckrm_core_class *(*alloc) (struct ckrm_core_class * parent, 
+                                         const char *name);    
+       int (*free) (struct ckrm_core_class * cls);     
+       int (*show_members) (struct ckrm_core_class *, struct seq_file *);
+       int (*show_stats) (struct ckrm_core_class *, struct seq_file *);
+       int (*show_config) (struct ckrm_core_class *, struct seq_file *);
+       int (*show_shares) (struct ckrm_core_class *, struct seq_file *);
+
+       int (*reset_stats) (struct ckrm_core_class *, const char *resname,
+                           const char *);
+       int (*set_config) (struct ckrm_core_class *, const char *resname,
+                          const char *cfgstr);
+       int (*set_shares) (struct ckrm_core_class *, const char *resname,
+                          struct ckrm_shares * shares);
+       int (*forced_reclassify) (struct ckrm_core_class *, const char *);
+
+       /* functions to be called on a class type by ckrm internals */
+
+       /* class initialization for new RC */
+       void (*add_resctrl) (struct ckrm_core_class *, int resid);      
+
+} ckrm_classtype_t;
+
+/******************************************************************************
+ * CKRM CORE CLASS
+ *      common part to any class structure (i.e. instance of a classtype)
+ ******************************************************************************/
+
+/* basic definition of a hierarchy that is to be used by the the CORE classes
+ * and can be used by the resource class objects
+ */
+
+#define CKRM_CORE_MAGIC                0xBADCAFFE
+
+typedef struct ckrm_hnode {
+       struct ckrm_core_class *parent;
+       struct list_head siblings;      
+       struct list_head children;      
+} ckrm_hnode_t;
+
+typedef struct ckrm_core_class {
+       struct ckrm_classtype *classtype;       
+       void *res_class[CKRM_MAX_RES_CTLRS];    // resource classes 
+       spinlock_t class_lock;                  // protects list,array above 
+
+       
+       struct list_head objlist;               // generic object list 
+       struct list_head clslist;               // peer classtype classes
+       struct dentry *dentry;                  // dentry of inode in the RCFS
+       int magic;
+
+       struct ckrm_hnode hnode;                // hierarchy
+       rwlock_t hnode_rwlock;                  // protects hnode above.
+       atomic_t refcnt;
+       const char *name;
+       int delayed;                            // core deletion delayed 
+                                               // because of race conditions
+} ckrm_core_class_t;
+
+/* type coerce between derived class types and ckrm core class type */
+#define class_type(type,coreptr)   container_of(coreptr,type,core)
+#define class_core(clsptr)         (&(clsptr)->core)
+/* locking classes */
+#define class_lock(coreptr)        spin_lock(&(coreptr)->class_lock)
+#define class_unlock(coreptr)      spin_unlock(&(coreptr)->class_lock)
+/* what type is a class of ISA */
+#define class_isa(clsptr)          (class_core(clsptr)->classtype)
+
+/******************************************************************************
+ * OTHER
+ ******************************************************************************/
+
+#define ckrm_get_res_class(rescls, resid, type) \
+       ((type*) (((resid != -1) && ((rescls) != NULL) \
+                          && ((rescls) != (void *)-1)) ? \
+        ((struct ckrm_core_class *)(rescls))->res_class[resid] : NULL))
+
+
+extern int ckrm_register_res_ctlr(struct ckrm_classtype *, ckrm_res_ctlr_t *);
+extern int ckrm_unregister_res_ctlr(ckrm_res_ctlr_t *);
+
+extern int ckrm_validate_and_grab_core(struct ckrm_core_class *core);
+extern int ckrm_init_core_class(struct ckrm_classtype *clstype,
+                               struct ckrm_core_class *dcore,
+                               struct ckrm_core_class *parent,
+                               const char *name);
+extern int ckrm_release_core_class(struct ckrm_core_class *);  
+// Hubertus .. can disappear after cls del debugging
+extern struct ckrm_res_ctlr *ckrm_resctlr_lookup(struct ckrm_classtype *type,
+                                                const char *resname);
+
+#if 0
+
+// Hubertus ... need to straighten out all these I don't think we will even 
+// call this or are we 
+
+/* interface to the RCFS filesystem */
+extern struct ckrm_core_class *ckrm_alloc_core_class(struct ckrm_core_class *,
+                                                    const char *, int);
+
+// Reclassify the given pid to the given core class by force
+extern void ckrm_forced_reclassify_pid(int, struct ckrm_core_class *);
+
+// Reclassify the given net_struct  to the given core class by force
+extern void ckrm_forced_reclassify_laq(struct ckrm_net_struct *,
+                                      struct ckrm_core_class *);
+
+#endif
+
+extern void ckrm_lock_hier(struct ckrm_core_class *);
+extern void ckrm_unlock_hier(struct ckrm_core_class *);
+extern struct ckrm_core_class *ckrm_get_next_child(struct ckrm_core_class *,
+                                                  struct ckrm_core_class *);
+
+extern void child_guarantee_changed(struct ckrm_shares *, int, int);
+extern void child_maxlimit_changed(struct ckrm_shares *, int);
+extern int set_shares(struct ckrm_shares *, struct ckrm_shares *,
+                     struct ckrm_shares *);
+
+/* classtype registration and lookup */
+extern int ckrm_register_classtype(struct ckrm_classtype *clstype);
+extern int ckrm_unregister_classtype(struct ckrm_classtype *clstype);
+extern struct ckrm_classtype *ckrm_find_classtype_by_name(const char *name);
+
+/* default functions that can be used in classtypes's function table */
+extern int ckrm_class_show_shares(struct ckrm_core_class *core,
+                                 struct seq_file *seq);
+extern int ckrm_class_show_stats(struct ckrm_core_class *core,
+                                struct seq_file *seq);
+extern int ckrm_class_show_config(struct ckrm_core_class *core,
+                                 struct seq_file *seq);
+extern int ckrm_class_set_config(struct ckrm_core_class *core,
+                                const char *resname, const char *cfgstr);
+extern int ckrm_class_set_shares(struct ckrm_core_class *core,
+                                const char *resname,
+                                struct ckrm_shares *shares);
+extern int ckrm_class_reset_stats(struct ckrm_core_class *core,
+                                 const char *resname, const char *unused);
+
+#if 0
+extern void ckrm_ns_hold(struct ckrm_net_struct *);
+extern void ckrm_ns_put(struct ckrm_net_struct *);
+extern void *ckrm_set_rootcore_byname(char *, void *);
+#endif
+
+static inline void ckrm_core_grab(struct ckrm_core_class *core)
+{
+       if (core)
+               atomic_inc(&core->refcnt);
+}
+
+static inline void ckrm_core_drop(struct ckrm_core_class *core)
+{
+       // only make definition available in this context
+       extern void ckrm_free_core_class(struct ckrm_core_class *core);
+       if (core && (atomic_dec_and_test(&core->refcnt)))
+               ckrm_free_core_class(core);
+}
+
+static inline unsigned int ckrm_is_core_valid(ckrm_core_class_t * core)
+{
+       return (core && (core->magic == CKRM_CORE_MAGIC));
+}
+
+// iterate through all associate resource controllers:
+// requires following arguments (ckrm_core_class *cls, 
+//                               ckrm_res_ctrl   *ctlr,
+//                               void            *robj,
+//                               int              bmap)
+#define forall_class_resobjs(cls,rcbs,robj,bmap)                       \
+       for ( bmap=((cls->classtype)->bit_res_ctlrs) ;                  \
+            ({ int rid; ((rid=ffs(bmap)-1) >= 0) &&                    \
+                        (bmap &= ~(1<<rid),                            \
+                               ((rcbs=cls->classtype->res_ctlrs[rid])  \
+                                && (robj=cls->res_class[rid]))); });   \
+           )
+
+extern struct ckrm_classtype *ckrm_classtypes[];       
+/* should provide a different interface */
+
+/*-----------------------------------------------------------------------------
+ * CKRM event callback specification for the classtypes or resource controllers 
+ *   typically an array is specified using CKRM_EVENT_SPEC terminated with 
+ *   CKRM_EVENT_SPEC_LAST and then that array is registered using
+ *   ckrm_register_event_set.
+ *   Individual registration of event_cb is also possible
+ *-----------------------------------------------------------------------------*/
+
+struct ckrm_event_spec {
+       enum ckrm_event ev;
+       struct ckrm_hook_cb cb;
+};
+#define CKRM_EVENT_SPEC(EV,FCT) { CKRM_EVENT_##EV, \
+                                       { (ckrm_event_cb)FCT, NULL } }
+
+int ckrm_register_event_set(struct ckrm_event_spec especs[]);
+int ckrm_unregister_event_set(struct ckrm_event_spec especs[]);
+int ckrm_register_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb);
+int ckrm_unregister_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb);
+
+/******************************************************************************
+ * CE Invocation interface
+ ******************************************************************************/
+
+#define ce_protect(ctype)      (atomic_inc(&((ctype)->ce_nr_users)))
+#define ce_release(ctype)      (atomic_dec(&((ctype)->ce_nr_users)))
+
+// CE Classification callbacks with 
+
+#define CE_CLASSIFY_NORET(ctype, event, objs_to_classify...)           \
+do {                                                                   \
+       if ((ctype)->ce_cb_active                                       \
+           && (test_bit(event,&(ctype)->ce_callbacks.c_interest)))     \
+               (*(ctype)->ce_callbacks.classify)(event,                \
+                                                 objs_to_classify);    \
+} while (0)
+
+#define CE_CLASSIFY_RET(ret, ctype, event, objs_to_classify...)                \
+do {                                                                   \
+       if ((ctype)->ce_cb_active                                       \
+           && (test_bit(event,&(ctype)->ce_callbacks.c_interest)))     \
+               ret = (*(ctype)->ce_callbacks.classify)(event,          \
+                                                       objs_to_classify);\
+} while (0)
+
+#define CE_NOTIFY(ctype, event, cls, objs_to_classify)                 \
+do {                                                                   \
+       if ((ctype)->ce_cb_active                                       \
+           && (test_bit(event,&(ctype)->ce_callbacks.n_interest)))     \
+               (*(ctype)->ce_callbacks.notify)(event,                  \
+                                               cls,objs_to_classify);  \
+} while (0)
+
+/***************
+ * RCFS related 
+ ***************/
+
+/* vars needed by other modules/core */
+
+extern int rcfs_mounted;
+extern int rcfs_engine_regd;
+
+#endif                         // CONFIG_CKRM
+
+#endif                         // __KERNEL__
+
+#endif                         // _LINUX_CKRM_RC_H
diff --git a/include/linux/ckrm_sched.h b/include/linux/ckrm_sched.h
new file mode 100644 (file)
index 0000000..3611c2d
--- /dev/null
@@ -0,0 +1,563 @@
+/* include/linux/ckrm_sched.h - Supports CKRM scheduling
+ *
+ * Copyright (C) Haoqiang Zheng,  IBM Corp. 2004
+ * Copyright (C) Hubertus Franke,  IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#ifndef _CKRM_SCHED_H
+#define _CKRM_SCHED_H
+
+#include <linux/sched.h>
+#include <linux/ckrm_rc.h>
+#include <linux/ckrm_classqueue.h>
+
+#define BITMAP_SIZE ((((MAX_PRIO+1+7)/8)+sizeof(long)-1)/sizeof(long))
+
+struct prio_array {
+       unsigned int nr_active;
+       unsigned long bitmap[BITMAP_SIZE];
+       struct list_head queue[MAX_PRIO];
+};
+
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+#define rq_active(p,rq)   (get_task_lrq(p)->active)
+#define rq_expired(p,rq)  (get_task_lrq(p)->expired)
+int __init init_ckrm_sched_res(void);
+#else
+#define rq_active(p,rq)   (rq->active)
+#define rq_expired(p,rq)  (rq->expired)
+static inline void init_ckrm_sched_res(void) {}
+static inline int ckrm_cpu_monitor_init(void) {return 0;}
+#endif //CONFIG_CKRM_CPU_SCHEDULE
+
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+struct ckrm_runqueue {
+       cq_node_t classqueue_linkobj;   /*links in classqueue */
+       struct ckrm_cpu_class *cpu_class;       // class it belongs to
+       struct classqueue_struct *classqueue;   // classqueue it belongs tow
+       unsigned long long uncounted_ns;
+
+       prio_array_t *active, *expired, arrays[2];
+       /*
+          set to 0 on init, become null or array switch
+          set to jiffies whenever an non-interactive job expires
+          reset to jiffies if expires
+        */
+       unsigned long expired_timestamp;
+
+       /* 
+        * highest priority of tasks in active
+        * initialized to be MAX_PRIO
+        * updated on enqueue, dequeue
+        */
+       int top_priority;
+       CVT_t local_cvt;
+
+       unsigned long lrq_load;
+       int local_weight; 
+
+
+       /*
+        * unused CPU time accumulated while thoe class 
+        * is inactive goes to savings
+        * 
+        * initialized to be 0
+        * a class can't accumulate more than SAVING_THRESHOLD of savings
+        */
+       unsigned long long savings;
+
+       unsigned long magic;    //for debugging
+};
+
+typedef struct ckrm_runqueue ckrm_lrq_t;
+
+/**
+ * ckrm_cpu_class_stat - cpu usage statistics maintained for each class
+ * 
+ */
+struct ckrm_cpu_class_stat {
+       spinlock_t stat_lock;
+
+       unsigned long long total_ns;    /*how much nano-secs it has consumed */
+
+       struct ckrm_cpu_demand_stat local_stats[NR_CPUS];
+
+       /* 
+        * 
+        */
+       unsigned long max_demand; /* the maximun a class can consume */
+       int egrt,megrt; /*effective guarantee*/
+       int ehl,mehl; /*effective hard limit, my effective hard limit*/
+
+       /*
+        * eshare: for both default class and its children
+        * meshare: just for the default class
+        */
+       int eshare;
+       int meshare;
+};
+
+#define CKRM_CPU_CLASS_MAGIC 0x7af2abe3
+
+#define USAGE_SAMPLE_FREQ HZ  //sample every 1 seconds
+#define NS_PER_SAMPLE (USAGE_SAMPLE_FREQ*(NSEC_PER_SEC/HZ))
+#define USAGE_WINDOW_SIZE 60  //keep the last 60 sample
+
+struct ckrm_usage {
+       unsigned long samples[USAGE_WINDOW_SIZE]; //record usages 
+       unsigned long sample_pointer; //pointer for the sliding window
+       unsigned long long last_ns; //ns for last sample
+       long long last_sample_jiffies; //in number of jiffies
+};
+
+/*
+ * manages the class status
+ * there should be only one instance of this object for each class in the whole system  
+ */
+struct ckrm_cpu_class {
+       struct ckrm_core_class *core;
+       struct ckrm_core_class *parent;
+       struct ckrm_shares shares;
+       spinlock_t cnt_lock;    // always grab parent's lock first and then child's
+       struct ckrm_cpu_class_stat stat;
+       struct list_head links; // for linking up in cpu classes
+       ckrm_lrq_t local_queues[NR_CPUS];       // runqueues 
+       struct ckrm_usage usage;
+       unsigned long magic;    //for debugging
+};
+
+#define cpu_class_weight(cls) (cls->stat.meshare)
+#define local_class_weight(lrq) (lrq->local_weight)
+
+static inline int valid_cpu_class(struct ckrm_cpu_class * cls)
+{
+       return (cls && cls->magic == CKRM_CPU_CLASS_MAGIC);
+}
+
+struct classqueue_struct *get_cpu_classqueue(int cpu);
+struct ckrm_cpu_class * get_default_cpu_class(void);
+
+
+static inline void ckrm_usage_init(struct ckrm_usage* usage)
+{
+       int i;
+
+       for (i=0; i < USAGE_WINDOW_SIZE; i++)
+               usage->samples[i] = 0;
+       usage->sample_pointer = 0;
+       usage->last_ns = 0;
+       usage->last_sample_jiffies = 0;
+}
+
+/*
+ * this function can be called at any frequency
+ * it's self-contained
+ */
+static inline void ckrm_sample_usage(struct ckrm_cpu_class* clsptr)
+{
+       struct ckrm_usage* usage = &clsptr->usage;
+       unsigned long long cur_sample;
+       int duration = jiffies - usage->last_sample_jiffies;
+
+       //jiffies wasn't start from 0
+       //so it need to be properly handled
+       if (unlikely(!usage->last_sample_jiffies)) 
+               usage->last_sample_jiffies = jiffies;
+
+       //called too frequenctly
+       if (duration < USAGE_SAMPLE_FREQ)
+               return;
+
+       usage->last_sample_jiffies = jiffies;
+
+       cur_sample = clsptr->stat.total_ns - usage->last_ns; 
+       usage->last_ns = clsptr->stat.total_ns;
+
+       //scale it based on the sample duration
+       cur_sample *= ((USAGE_SAMPLE_FREQ<< 15)/duration);
+       cur_sample >>= 15;
+       usage->samples[usage->sample_pointer] = cur_sample;
+       //      printk("sample = %llu jiffies=%lu \n",cur_sample, jiffies);
+
+       usage->sample_pointer ++;
+       if (usage->sample_pointer >= USAGE_WINDOW_SIZE)
+               usage->sample_pointer = 0;
+}
+
+//duration is specified in number of jiffies
+//return the usage in percentage
+static inline int get_ckrm_usage(struct ckrm_cpu_class* clsptr, int duration)
+{
+       int nr_samples = duration/USAGE_SAMPLE_FREQ?:1;
+       struct ckrm_usage* usage = &clsptr->usage;
+       unsigned long long total = 0;
+       int i, idx;
+
+       if (nr_samples > USAGE_WINDOW_SIZE)
+               nr_samples = USAGE_WINDOW_SIZE;
+
+       idx = usage->sample_pointer;    
+       for (i = 0; i< nr_samples; i++) {
+               if (! idx)
+                       idx = USAGE_WINDOW_SIZE;
+               idx --;
+               total += usage->samples[idx];
+       }
+        total *= 100;
+        do_div(total,nr_samples);
+        do_div(total,NS_PER_SAMPLE);
+       do_div(total,cpus_weight(cpu_online_map));
+        return total;
+}
+
+
+#define lrq_nr_running(lrq) \
+             (lrq->active->nr_active + lrq->expired->nr_active)
+
+static inline ckrm_lrq_t *
+get_ckrm_lrq(struct ckrm_cpu_class*cls, int cpu)
+{
+       return &(cls->local_queues[cpu]);
+}
+
+static inline ckrm_lrq_t *get_task_lrq(struct task_struct *p)
+{
+       return &(p->cpu_class->local_queues[task_cpu(p)]);
+}
+
+#define task_list_entry(list)  list_entry(list,struct task_struct,run_list)
+#define class_list_entry(list) list_entry(list,struct ckrm_runqueue,classqueue_linkobj)
+
+/* some additional interfaces exported from sched.c */
+struct runqueue;
+extern rwlock_t class_list_lock;
+extern struct list_head active_cpu_classes;
+unsigned int task_timeslice(task_t *p);
+void _ckrm_cpu_change_class(task_t *task, struct ckrm_cpu_class *newcls);
+
+void init_cpu_classes(void);
+void init_cpu_class(struct ckrm_cpu_class *cls,ckrm_shares_t* shares);
+void ckrm_cpu_change_class(void *task, void *old, void *new);
+
+
+#define CPU_DEMAND_ENQUEUE 0
+#define CPU_DEMAND_DEQUEUE 1
+#define CPU_DEMAND_DESCHEDULE 2
+#define CPU_DEMAND_INIT 3
+
+/*functions exported by ckrm_cpu_monitor.c*/
+void ckrm_cpu_monitor(int check_min);
+int ckrm_cpu_monitor_init(void);
+void ckrm_cpu_stat_init(struct ckrm_cpu_class_stat *stat);
+void cpu_demand_event(struct ckrm_cpu_demand_stat* local_stat, int event, unsigned long long len);
+void adjust_local_weight(void);
+
+#define get_task_lrq_stat(p) (&(p)->cpu_class->stat.local_stats[task_cpu(p)])
+#define get_cls_local_stat(cls,cpu) (&(cls)->stat.local_stats[cpu])
+#define get_rq_local_stat(lrq,cpu) (get_cls_local_stat((lrq)->cpu_class,cpu))
+
+/********************************************************************
+ * Parameters that determine how quickly CVT's progress and how
+ * priority can impact a LRQ's runqueue position. See also
+ * get_effective_prio(). These parameters need to adjusted
+ * in accordance to the following example and understanding.
+ * 
+ * CLASS_QUANTIZER:
+ * 
+ * A class with 50% share, can execute 500 ms / per sec ~ 2^29 ns.
+ * It's share will be set to 512 = 2^9. The globl CLASSQUEUE_SIZE is set to 2^7.
+ * With CLASS_QUANTIZER=16, the local_cvt of this class will increase
+ * by 2^29/2^9 = 2^20 = 1024K.
+ * Setting CLASS_QUANTIZER to 16, 2^(20-16) = 16 slots / per second.
+  * Do the same math, a class with any share value, will cover 16 slots / per second. 
+ * So 2^8 total slots is good track for 8 seconds of system execution
+ *
+ * PRIORITY_QUANTIZER:
+ *
+ * How much can top priorities of class impact slot bonus.
+ * There are 40 nice priorities, range from -20 to 19, with default nice = 0
+ * "2" will allow upto 5 slots improvement 
+ * when certain task within the class  has a nice value of -20 
+ * in the RQ thus for 50% class it can perform ~300 msec starvation.
+ *
+ *******************************************************************/
+
+#define CLASS_QUANTIZER 16     //shift from ns to increase class bonus
+#define PRIORITY_QUANTIZER 2   //controls how much a high prio task can borrow
+
+#define CKRM_SHARE_ACCURACY 13
+#define NSEC_PER_MS 1000000
+#define NSEC_PER_JIFFIES (NSEC_PER_SEC/HZ)
+
+
+#define MAX_SAVINGS_ABSOLUTE (10LLU*NSEC_PER_SEC)  // 10 seconds
+
+#define CVT_UPDATE_TICK     ((HZ/2)?:1)
+
+// ABSOLUTE_CKRM_TUNING determines whether classes can make up
+// lost time in absolute time or in relative values
+
+#define ABSOLUTE_CKRM_TUNING         // preferred due to more predictable behavior
+
+#ifdef ABSOLUTE_CKRM_TUNING
+
+#define MAX_SAVINGS        MAX_SAVINGS_ABSOLUTE
+//an absolute bonus of 200ms for classes when reactivated
+#define INTERACTIVE_BONUS(lrq) ((200*NSEC_PER_MS)/local_class_weight(lrq))
+#define SAVINGS_LEAK_SPEED (CVT_UPDATE_TICK/10*NSEC_PER_JIFFIES)
+
+#define scale_cvt(val,lrq)   ((val)*local_class_weight(lrq))
+#define unscale_cvt(val,lrq) (do_div(val,local_class_weight(lrq)))
+
+#else
+
+#define MAX_SAVINGS (MAX_SAVINGS_ABSOLUTE >> CKRM_SHARE_ACCURACY) 
+/*
+ * to improve system responsiveness
+ * an inactive class is put a little bit ahead of the current class when it wakes up
+ * the amount is set in normalized term to simplify the calculation
+ * for class with 100% share, it can be 2s ahead
+ * while for class with 10% share, it can be 200ms ahead
+ */
+#define INTERACTIVE_BONUS(lrq) (2*NSEC_PER_MS)  
+
+/*
+ * normalized savings can't be more than MAX_NORMALIZED_SAVINGS
+ * based on the current configuration
+ * this means that a class with share 100% will accumulate 10s at most
+ * while a class with 1% of the share can only accumulate 100ms
+ */
+
+//a class with share 100% can get 100ms every 500ms
+//while a class with share 10% can only get 10ms every 500ms
+#define SAVINGS_LEAK_SPEED ((CVT_UPDATE_TICK/5*NSEC_PER_JIFFIES) >> CKRM_SHARE_ACCURACY)
+
+#define scale_cvt(val,lrq)   (val)
+#define unscale_cvt(val,lrq) (val)
+
+#endif
+
+
+/**
+ * get_effective_prio: return the effective priority of a class local queue
+ *
+ * class priority = progress * a + urgency * b
+ * progress = queue cvt
+ * urgency = queue top priority
+ * a and b are scaling factors  
+ * currently, prio increases by 1 if either: top_priority increase by one
+ *                                   or, local_cvt increases by 4ms
+ */
+static inline int get_effective_prio(ckrm_lrq_t * lrq)
+{
+       int prio;
+
+       prio = lrq->local_cvt >> CLASS_QUANTIZER;  // cumulative usage
+#ifndef URGENCY_SUPPORT
+#warning "ACB removing urgency calculation from get_effective_prio"
+#else
+       prio += lrq->top_priority >> PRIORITY_QUANTIZER; // queue urgency
+#endif
+
+       return prio;
+}
+
+CVT_t get_local_cur_cvt(int cpu);
+
+/** 
+ * update_class_priority:
+ * 
+ * called whenever cvt or top_priority changes
+ *
+ * internal: (calling structure)
+ * update_class_priority
+ *   -- set_top_priority
+ *      -- class_enqueue_task
+ *      -- class_dequeue_task
+ *      -- rq_get_next_task (queue switch)
+ *   -- update_local_cvt
+ *      -- schedule
+ */
+static inline void update_class_priority(ckrm_lrq_t *local_rq)
+{
+       int effective_prio = get_effective_prio(local_rq);
+       classqueue_update_prio(local_rq->classqueue,
+                              &local_rq->classqueue_linkobj,
+                              effective_prio);
+}
+
+/*
+ *  set the new top priority and reposition the queue
+ *  called when: task enqueue/dequeue and queue switch
+ */
+static inline void set_top_priority(ckrm_lrq_t *lrq,
+                                   int new_priority)
+{
+       lrq->top_priority = new_priority;
+       update_class_priority(lrq);
+}
+
+/*
+ * task_load: how much load this task counts
+ */
+static inline unsigned long task_load(struct task_struct* p)
+{
+       return (task_timeslice(p) * p->demand_stat.cpu_demand);
+}
+
+/*
+ * runqueue load is the local_weight of all the classes on this cpu
+ * must be called with class_list_lock held
+ */
+static inline unsigned long ckrm_cpu_load(int cpu)
+{
+       struct ckrm_cpu_class *clsptr;
+       ckrm_lrq_t* lrq;
+       struct ckrm_cpu_demand_stat* l_stat;
+       int total_load = 0;
+       int load;
+
+       list_for_each_entry(clsptr,&active_cpu_classes,links) {
+               lrq =  get_ckrm_lrq(clsptr,cpu);
+               l_stat = get_cls_local_stat(clsptr,cpu);
+               load = lrq->local_weight;
+               if (l_stat->cpu_demand < load)
+                       load = l_stat->cpu_demand;
+               total_load += load;
+       }       
+       return total_load;
+}
+
+static inline void class_enqueue_task(struct task_struct *p,
+                                     prio_array_t * array)
+{
+       ckrm_lrq_t *lrq;
+       int effective_prio;
+
+       lrq = get_task_lrq(p);
+
+       cpu_demand_event(&p->demand_stat,CPU_DEMAND_ENQUEUE,0);
+       lrq->lrq_load += task_load(p);
+
+       if ((p->prio < lrq->top_priority) && (array == lrq->active))
+               set_top_priority(lrq, p->prio); 
+
+       if (! cls_in_classqueue(&lrq->classqueue_linkobj)) {
+               cpu_demand_event(get_task_lrq_stat(p),CPU_DEMAND_ENQUEUE,0);
+               effective_prio = get_effective_prio(lrq);
+               classqueue_enqueue(lrq->classqueue, &lrq->classqueue_linkobj, effective_prio);
+       } 
+
+}
+
+static inline void class_dequeue_task(struct task_struct *p,
+                                     prio_array_t * array)
+{
+       ckrm_lrq_t *lrq = get_task_lrq(p);
+       unsigned long load = task_load(p);
+
+       BUG_ON(lrq->lrq_load < load);
+       lrq->lrq_load -= load;
+
+       cpu_demand_event(&p->demand_stat,CPU_DEMAND_DEQUEUE,0);
+
+       if ((array == lrq->active) && (p->prio == lrq->top_priority)
+           && list_empty(&(array->queue[p->prio])))
+               set_top_priority(lrq,
+                                find_next_bit(array->bitmap, MAX_PRIO,
+                                              p->prio));
+}
+
+/*
+ *  called after a task is switched out. Update the local cvt accounting 
+ *  we need to stick with long instead of long long due to nonexistent 64-bit division
+ */
+static inline void update_local_cvt(struct task_struct *p, unsigned long nsec)
+{
+       ckrm_lrq_t * lrq = get_task_lrq(p);
+
+       unsigned long cvt_inc = nsec / local_class_weight(lrq);
+
+       lrq->local_cvt += cvt_inc;
+       lrq->uncounted_ns += nsec;
+
+       update_class_priority(lrq);
+}
+
+static inline int class_preempts_curr(struct task_struct * p, struct task_struct* curr)
+{
+       struct cq_node_struct* node1 = &(get_task_lrq(p)->classqueue_linkobj);
+       struct cq_node_struct* node2 = &(get_task_lrq(curr)->classqueue_linkobj);
+
+       return (class_compare_prio(node1,node2) < 0);
+}
+
+/*
+ * return a random value with range [0, (val-1)]
+ */
+static inline int get_ckrm_rand(unsigned long val)
+{
+       int rand;
+       static int last_rand[NR_CPUS];
+       int cpu = smp_processor_id();
+
+       rand = last_rand[cpu];
+       rand ++;
+       if (rand >= val)
+               rand = 0; 
+       
+       last_rand[cpu] = rand;
+       return rand;
+}
+
+void update_class_cputime(int this_cpu);
+
+/**********************************************/
+/*          PID_LOAD_BALANCING                */
+/**********************************************/
+struct ckrm_load_struct {
+       unsigned long load_p;   /*propotional*/
+       unsigned long load_i;   /*integral   */
+       long load_d;   /*derivative */
+};
+
+typedef struct ckrm_load_struct ckrm_load_t;
+
+static inline void ckrm_load_init(ckrm_load_t* ckrm_load) {
+       ckrm_load->load_p = 0;
+       ckrm_load->load_i = 0;
+       ckrm_load->load_d = 0;
+}
+
+void ckrm_load_sample(ckrm_load_t* ckrm_load,int cpu);
+long pid_get_pressure(ckrm_load_t* ckrm_load, int local_group);
+#define rq_ckrm_load(rq) (&((rq)->ckrm_load))
+
+static inline void ckrm_sched_tick(unsigned long j,int this_cpu,struct ckrm_load_struct* ckrm_load)
+{
+       read_lock(&class_list_lock);
+       
+#ifdef CONFIG_SMP
+       ckrm_load_sample(ckrm_load,this_cpu);
+#endif
+
+       if (! (j % CVT_UPDATE_TICK)) {
+               //              printk("ckrm_sched j=%lu\n",j);
+               classqueue_update_base(get_cpu_classqueue(this_cpu));
+               update_class_cputime(this_cpu);
+       }
+
+       read_unlock(&class_list_lock);
+}
+
+#endif //CONFIG_CKRM_CPU_SCHEDULE
+
+#endif
diff --git a/include/linux/ckrm_tc.h b/include/linux/ckrm_tc.h
new file mode 100644 (file)
index 0000000..5650dd3
--- /dev/null
@@ -0,0 +1,13 @@
+#include <linux/ckrm_rc.h>
+
+#define TASK_CLASS_TYPE_NAME "taskclass"
+
+typedef struct ckrm_task_class {
+       struct ckrm_core_class core;
+} ckrm_task_class_t;
+
+// Index into genmfdesc array, defined in rcfs/dir_modules.c,
+// which has the mfdesc entry that taskclass wants to use
+#define TC_MF_IDX  0
+
+extern int ckrm_forced_reclassify_pid(int pid, struct ckrm_task_class *cls);
diff --git a/include/linux/ckrm_tsk.h b/include/linux/ckrm_tsk.h
new file mode 100644 (file)
index 0000000..d0b4530
--- /dev/null
@@ -0,0 +1,34 @@
+/* ckrm_tsk.h - No. of tasks resource controller for CKRM
+ *
+ * Copyright (C) Chandra Seetharaman, IBM Corp. 2003
+ * 
+ * Provides No. of tasks resource controller for CKRM
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 31 Mar 2004
+ *    Created.
+ */
+
+#ifndef _LINUX_CKRM_TSK_H
+#define _LINUX_CKRM_TSK_H
+
+#include <linux/ckrm_rc.h>
+
+typedef int (*get_ref_t) (void *, int);
+typedef void (*put_ref_t) (void *);
+
+extern int numtasks_get_ref(void *, int);
+extern void numtasks_put_ref(void *);
+extern void ckrm_numtasks_register(get_ref_t, put_ref_t);
+
+#endif                         // _LINUX_CKRM_RES_H
index f8159dd..d43dbfe 100644 (file)
@@ -384,6 +384,7 @@ COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
 COMPATIBLE_IOCTL(DVD_AUTH)
 /* Big L */
 ULONG_IOCTL(LOOP_SET_FD)
+ULONG_IOCTL(LOOP_CHANGE_FD)
 COMPATIBLE_IOCTL(LOOP_CLR_FD)
 COMPATIBLE_IOCTL(LOOP_GET_STATUS64)
 COMPATIBLE_IOCTL(LOOP_SET_STATUS64)
index 9d1c14f..83b6c3d 100644 (file)
@@ -2,5 +2,7 @@
 #define _LINUX_CONFIG_H
 
 #include <linux/autoconf.h>
-
+#ifndef __KERNEL__
+#error including kernel header in userspace; use the glibc headers instead!
+#endif
 #endif
diff --git a/include/linux/crbce.h b/include/linux/crbce.h
new file mode 100644 (file)
index 0000000..6a2190d
--- /dev/null
@@ -0,0 +1,175 @@
+/* 
+ * crbce.h
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ * 
+ * This files contains the type definition of the record 
+ * created by the CRBCE CKRM classification engine
+ * 
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 
+ *
+ */
+
+/*
+ * Changes
+ *
+ * 2003-11-11   Created                                        by H.Franke
+ * 2003-12-01   Sanitized for Delivery                  by H.Franke
+ *        
+ */
+
+#ifndef CRBCE_RECORDS_H
+#define CRBCE_RECORDS_H
+
+#ifdef __KERNEL__
+#include <linux/autoconf.h>    
+#else
+#define  CONFIG_CKRM
+#define  CONFIG_CRBCE
+#define  CONFIG_DELAY_ACCT
+#endif
+
+#include <linux/types.h>           
+#include <linux/ckrm.h>
+#include <linux/ckrm_ce.h>
+
+#define CRBCE_UKCC_NAME   "crbce_ukcc"
+#define CRBCE_UKCC_PATH   "/mnt/relayfs"
+
+#define CRBCE_UKCC_PATH_NAME   CRBCE_UKCC_PATH"/"CRBCE_UKCC_NAME
+
+#define CRBCE_MAX_CLASS_NAME_LEN  256
+
+/****************************************************************
+ * 
+ *  CRBCE EVENT SET is and extension to the standard CKRM_EVENTS
+ *
+ ****************************************************************/
+enum {
+
+       /* we use the standard CKRM_EVENT_<..> 
+        * to identify reclassification cause actions
+        * and extend by additional ones we need
+        */
+
+       /* up event flow */
+
+       CRBCE_REC_EXIT = CKRM_NUM_EVENTS,
+       CRBCE_REC_DATA_DELIMITER,
+       CRBCE_REC_SAMPLE,
+       CRBCE_REC_TASKINFO,
+       CRBCE_REC_SYS_INFO,
+       CRBCE_REC_CLASS_INFO,
+       CRBCE_REC_KERNEL_CMD_DONE,
+       CRBCE_REC_UKCC_FULL,
+
+       /* down command issueance */
+       CRBCE_REC_KERNEL_CMD,
+
+       CRBCE_NUM_EVENTS
+};
+
+struct task_sample_info {
+       uint32_t cpu_running;
+       uint32_t cpu_waiting;
+       uint32_t io_delayed;
+       uint32_t memio_delayed;
+};
+
+/*********************************************
+ *          KERNEL -> USER  records          *
+ *********************************************/
+
+/* we have records with either a time stamp or not */
+struct crbce_hdr {
+       int type;
+       pid_t pid;
+};
+
+struct crbce_hdr_ts {
+       int type;
+       pid_t pid;
+       uint32_t jiffies;
+       uint64_t cls;
+};
+
+/* individual records */
+
+struct crbce_rec_fork {
+       struct crbce_hdr_ts hdr;
+       pid_t ppid;
+};
+
+struct crbce_rec_data_delim {
+       struct crbce_hdr_ts hdr;
+       int is_stop;            /* 0 start, 1 stop */
+};
+
+struct crbce_rec_task_data {
+       struct crbce_hdr_ts hdr;
+       struct task_sample_info sample;
+       struct task_delay_info delay;
+};
+
+struct crbce_ukcc_full {
+       struct crbce_hdr_ts hdr;
+};
+
+struct crbce_class_info {
+       struct crbce_hdr_ts hdr;
+       int action;
+       int namelen;
+       char name[CRBCE_MAX_CLASS_NAME_LEN];
+};
+
+/*********************************************
+ *           USER -> KERNEL records          *
+ *********************************************/
+
+enum crbce_kernel_cmd {
+       CRBCE_CMD_START,
+       CRBCE_CMD_STOP,
+       CRBCE_CMD_SET_TIMER,
+       CRBCE_CMD_SEND_DATA,
+};
+
+struct crbce_command {
+       int type;               /* we need this for the K->U reflection */
+       int cmd;
+       uint32_t len;   /* added in the kernel for reflection */
+};
+
+#define set_cmd_hdr(rec,tok) \
+((rec).hdr.type=CRBCE_REC_KERNEL_CMD,(rec).hdr.cmd=(tok))
+
+struct crbce_cmd_done {
+       struct crbce_command hdr;
+       int rc;
+};
+
+struct crbce_cmd {
+       struct crbce_command hdr;
+};
+
+struct crbce_cmd_send_data {
+       struct crbce_command hdr;
+       int delta_mode;
+};
+
+struct crbce_cmd_settimer {
+       struct crbce_command hdr;
+       uint32_t interval;      /* in msec .. 0 means stop */
+};
+
+#endif
index 0f0d8a9..c22ea3f 100644 (file)
@@ -156,6 +156,8 @@ struct digest_tfm {
        void (*dit_init)(struct crypto_tfm *tfm);
        void (*dit_update)(struct crypto_tfm *tfm,
                           struct scatterlist *sg, unsigned int nsg);
+       void (*dit_update_kernel)(struct crypto_tfm *tfm,
+                                 const void *data, size_t count);
        void (*dit_final)(struct crypto_tfm *tfm, u8 *out);
        void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg,
                           unsigned int nsg, u8 *out);
@@ -202,10 +204,14 @@ struct crypto_tfm {
  * will then attempt to load a module of the same name or alias.  A refcount
  * is grabbed on the algorithm which is then associated with the new transform.
  *
+ * crypto_alloc_tfm2() is similar, but allows module loading to be suppressed.
+ *
  * crypto_free_tfm() frees up the transform and any associated resources,
  * then drops the refcount on the associated algorithm.
  */
 struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
+struct crypto_tfm *crypto_alloc_tfm2(const char *alg_name, u32 tfm_flags,
+                                    int nomodload);
 void crypto_free_tfm(struct crypto_tfm *tfm);
 
 /*
@@ -272,6 +278,14 @@ static inline void crypto_digest_update(struct crypto_tfm *tfm,
        tfm->crt_digest.dit_update(tfm, sg, nsg);
 }
 
+static inline void crypto_digest_update_kernel(struct crypto_tfm *tfm,
+                                              const void *data,
+                                              size_t count)
+{
+       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+       tfm->crt_digest.dit_update_kernel(tfm, data, count);
+}
+
 static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
diff --git a/include/linux/crypto/ksign.h b/include/linux/crypto/ksign.h
new file mode 100644 (file)
index 0000000..5569cd3
--- /dev/null
@@ -0,0 +1,22 @@
+/* ksign.h: in-kernel signature checker
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_CRYPTO_KSIGN_H
+#define _LINUX_CRYPTO_KSIGN_H
+
+#include <linux/types.h>
+
+#ifdef CONFIG_CRYPTO_SIGNATURE
+extern int ksign_verify_signature(const char *sig, unsigned sig_size,
+                                 struct crypto_tfm *sha1);
+#endif
+
+#endif /* _LINUX_CRYPTO_KSIGN_H */
diff --git a/include/linux/crypto/mpi.h b/include/linux/crypto/mpi.h
new file mode 100644 (file)
index 0000000..4de3ba0
--- /dev/null
@@ -0,0 +1,147 @@
+/* mpi.h  -  Multi Precision Integers
+ *     Copyright (C) 1994, 1996, 1998, 1999,
+ *                    2000, 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GNUPG.
+ *
+ * GNUPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNUPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
+ */
+
+#ifndef G10_MPI_H
+#define G10_MPI_H
+
+#include <linux/types.h>
+
+/* DSI defines */
+
+#define SHA1_DIGEST_LENGTH   20
+
+/*end of DSI defines */
+
+#define BYTES_PER_MPI_LIMB     (BITS_PER_LONG / 8)
+#define BITS_PER_MPI_LIMB      BITS_PER_LONG
+
+typedef unsigned long int mpi_limb_t;
+typedef   signed long int mpi_limb_signed_t;
+
+struct gcry_mpi {
+       int     alloced;    /* array size (# of allocated limbs) */
+       int     nlimbs;     /* number of valid limbs */
+       int     nbits;      /* the real number of valid bits (info only) */
+       int     sign;       /* indicates a negative number */
+       unsigned flags; /* bit 0: array must be allocated in secure memory space */
+       /* bit 1: not used */
+       /* bit 2: the limb is a pointer to some m_alloced data */
+       mpi_limb_t *d;  /* array with the limbs */
+};
+
+typedef struct gcry_mpi *MPI;
+
+#define MPI_NULL NULL
+
+#define mpi_get_nlimbs(a)     ((a)->nlimbs)
+#define mpi_is_neg(a)        ((a)->sign)
+
+/*-- mpiutil.c --*/
+MPI mpi_alloc( unsigned nlimbs );
+MPI mpi_alloc_secure( unsigned nlimbs );
+MPI mpi_alloc_like( MPI a );
+void mpi_free( MPI a );
+int mpi_resize( MPI a, unsigned nlimbs );
+int  mpi_copy( MPI *copy, const MPI a );
+void mpi_clear( MPI a );
+int mpi_set( MPI w, MPI u);
+int mpi_set_ui( MPI w, ulong u);
+MPI  mpi_alloc_set_ui( unsigned long u);
+void mpi_m_check( MPI a );
+void mpi_swap( MPI a, MPI b);
+
+/*-- mpicoder.c --*/
+MPI do_encode_md(const void *sha_buffer, unsigned nbits);
+MPI mpi_read_from_buffer(const void *buffer, unsigned *ret_nread);
+int mpi_fromstr(MPI val, const char *str);
+u32 mpi_get_keyid( MPI a, u32 *keyid );
+void *mpi_get_buffer( MPI a, unsigned *nbytes, int *sign );
+void *mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign );
+int  mpi_set_buffer( MPI a, const void *buffer, unsigned nbytes, int sign );
+
+#define log_mpidump g10_log_mpidump
+
+/*-- mpi-add.c --*/
+int mpi_add_ui(MPI w, MPI u, ulong v );
+int mpi_add(MPI w, MPI u, MPI v);
+int mpi_addm(MPI w, MPI u, MPI v, MPI m);
+int mpi_sub_ui(MPI w, MPI u, ulong v );
+int mpi_sub( MPI w, MPI u, MPI v);
+int mpi_subm( MPI w, MPI u, MPI v, MPI m);
+
+/*-- mpi-mul.c --*/
+int mpi_mul_ui(MPI w, MPI u, ulong v );
+int mpi_mul_2exp( MPI w, MPI u, ulong cnt);
+int mpi_mul( MPI w, MPI u, MPI v);
+int mpi_mulm( MPI w, MPI u, MPI v, MPI m);
+
+/*-- mpi-div.c --*/
+ulong mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor );
+int mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor );
+int mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor );
+int mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor );
+int mpi_tdiv_r( MPI rem, MPI num, MPI den);
+int mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den);
+int mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count );
+int   mpi_divisible_ui(const MPI dividend, ulong divisor );
+
+/*-- mpi-gcd.c --*/
+int mpi_gcd( MPI g, const MPI a, const MPI b );
+
+/*-- mpi-pow.c --*/
+int mpi_pow( MPI w, MPI u, MPI v);
+int mpi_powm( MPI res, MPI base, MPI exp, MPI mod);
+
+/*-- mpi-mpow.c --*/
+int mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI mod);
+
+/*-- mpi-cmp.c --*/
+int mpi_cmp_ui( MPI u, ulong v );
+int mpi_cmp( MPI u, MPI v );
+
+/*-- mpi-scan.c --*/
+int mpi_getbyte( MPI a, unsigned idx );
+void mpi_putbyte( MPI a, unsigned idx, int value );
+unsigned mpi_trailing_zeros( MPI a );
+
+/*-- mpi-bit.c --*/
+void mpi_normalize( MPI a );
+unsigned mpi_get_nbits( MPI a );
+int  mpi_test_bit( MPI a, unsigned n );
+int mpi_set_bit( MPI a, unsigned n );
+int mpi_set_highbit( MPI a, unsigned n );
+void mpi_clear_highbit( MPI a, unsigned n );
+void mpi_clear_bit( MPI a, unsigned n );
+int mpi_rshift( MPI x, MPI a, unsigned n );
+
+/*-- mpi-inv.c --*/
+int mpi_invm( MPI x, MPI u, MPI v );
+
+
+#endif /*G10_MPI_H*/
index 66e2732..a4c8f46 100644 (file)
@@ -103,6 +103,7 @@ struct dentry {
        struct super_block *d_sb;       /* The root of the dentry tree */
        int d_mounted;
        void *d_fsdata;                 /* fs-specific data */
+       void * d_extra_attributes;      /* TUX-specific data */
        struct rcu_head d_rcu;
        struct dcookie_struct *d_cookie; /* cookie, if any */
        struct hlist_node d_hash;       /* lookup hash list */  
@@ -210,6 +211,7 @@ extern void shrink_dcache_sb(struct super_block *);
 extern void shrink_dcache_parent(struct dentry *);
 extern void shrink_dcache_anon(struct hlist_head *);
 extern int d_invalidate(struct dentry *);
+extern void flush_dentry_attributes(void);
 
 /* only used at mount-time */
 extern struct dentry * d_alloc_root(struct inode *);
@@ -253,8 +255,12 @@ extern struct dentry * __d_lookup(struct dentry *, struct qstr *);
 /* validate "insecure" dentry pointer */
 extern int d_validate(struct dentry *, struct dentry *);
 
+char * __d_path( struct dentry *dentry, struct vfsmount *vfsmnt,
+                struct dentry *root, struct vfsmount *rootmnt,
+                char *buffer, int buflen);
+
 extern char * d_path(struct dentry *, struct vfsmount *, char *, int);
-  
 /* Allocation counts.. */
 
 /**
index f561091..f0b96ae 100644 (file)
@@ -10,7 +10,7 @@
 extern unsigned long loops_per_jiffy;
 
 #include <asm/delay.h>
-
+#include <asm/hardirq.h>
 /*
  * Using udelay() for intervals greater than a few milliseconds can
  * risk overflow for high loops_per_jiffy (high bogomips) machines. The
@@ -25,14 +25,13 @@ extern unsigned long loops_per_jiffy;
 #define MAX_UDELAY_MS  5
 #endif
 
-#ifdef notdef
-#define mdelay(n) (\
-       {unsigned long __ms=(n); while (__ms--) udelay(1000);})
-#else
-#define mdelay(n) (\
-       (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
-       ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
-#endif
+#define mdelay(n) (                                    \
+       {                                               \
+               static int warned=0;                    \
+               unsigned long __ms=(n);                 \
+               WARN_ON(in_irq() && !(warned++));       \
+               while (__ms--) udelay(1000);            \
+       })
 
 #ifndef ndelay
 #define ndelay(x)      udelay(((x)+999)/1000)
index b672ddc..5f82699 100644 (file)
@@ -30,5 +30,7 @@ static inline void devpts_pty_kill(int number) { }
 
 #endif
 
+#define DEVPTS_SUPER_MAGIC 0x1cd1
+
 
 #endif /* _LINUX_DEVPTS_FS_H */
diff --git a/include/linux/dump.h b/include/linux/dump.h
new file mode 100644 (file)
index 0000000..00c690f
--- /dev/null
@@ -0,0 +1,385 @@
+/*
+ * Kernel header file for Linux crash dumps.
+ *
+ * Created by: Matt Robinson (yakker@sgi.com)
+ * Copyright 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ *
+ * vmdump.h to dump.h by: Matt D. Robinson (yakker@sourceforge.net)
+ * Copyright 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 Free Software Foundation, Inc. All rights reserved.
+ *
+ * Most of this is the same old stuff from vmdump.h, except now we're
+ * actually a stand-alone driver plugged into the block layer interface,
+ * with the exception that we now allow for compression modes externally
+ * loaded (e.g., someone can come up with their own).
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+/* This header file includes all structure definitions for crash dumps. */
+#ifndef _DUMP_H
+#define _DUMP_H
+
+#if defined(CONFIG_CRASH_DUMP) || defined (CONFIG_CRASH_DUMP_MODULE)
+
+#include <linux/list.h>
+#include <linux/notifier.h>
+#include <linux/dumpdev.h>
+#include <asm/ioctl.h>
+
+/* 
+ * Predefine default DUMP_PAGE constants, asm header may override.
+ *
+ * On ia64 discontinuous memory systems it's possible for the memory
+ * banks to stop at 2**12 page alignments, the smallest possible page
+ * size. But the system page size, PAGE_SIZE, is in fact larger.
+ */
+#define DUMP_PAGE_SHIFT        PAGE_SHIFT
+#define DUMP_PAGE_MASK         PAGE_MASK
+#define DUMP_PAGE_ALIGN(addr)  PAGE_ALIGN(addr)
+#define DUMP_HEADER_OFFSET     PAGE_SIZE
+
+#define OLDMINORBITS   8
+#define OLDMINORMASK   ((1U << OLDMINORBITS) -1)
+
+/* keep DUMP_PAGE_SIZE constant to 4K = 1<<12
+ * it may be different from PAGE_SIZE then.
+ */
+#define DUMP_PAGE_SIZE         4096
+
+/* 
+ * Predefined default memcpy() to use when copying memory to the dump buffer.
+ *
+ * On ia64 there is a heads up function that can be called to let the prom
+ * machine check monitor know that the current activity is risky and it should
+ * ignore the fault (nofault). In this case the ia64 header will redefine this
+ * macro to __dump_memcpy() and use it's arch specific version.
+ */
+#define DUMP_memcpy            memcpy
+
+/* necessary header files */
+#include <asm/dump.h>                  /* for architecture-specific header */
+
+/* 
+ * Size of the buffer that's used to hold:
+ *
+ *     1. the dump header (padded to fill the complete buffer)
+ *     2. the possibly compressed page headers and data
+ */
+#define DUMP_BUFFER_SIZE       (64 * 1024)  /* size of dump buffer         */
+#define DUMP_HEADER_SIZE       DUMP_BUFFER_SIZE
+
+/* standard header definitions */
+#define DUMP_MAGIC_NUMBER      0xa8190173618f23edULL  /* dump magic number */
+#define DUMP_MAGIC_LIVE                0xa8190173618f23cdULL  /* live magic number */
+#define DUMP_VERSION_NUMBER    0x8     /* dump version number              */
+#define DUMP_PANIC_LEN         0x100   /* dump panic string length         */
+
+/* dump levels - type specific stuff added later -- add as necessary */
+#define DUMP_LEVEL_NONE                0x0     /* no dumping at all -- just bail   */
+#define DUMP_LEVEL_HEADER      0x1     /* kernel dump header only          */
+#define DUMP_LEVEL_KERN                0x2     /* dump header and kernel pages     */
+#define DUMP_LEVEL_USED                0x4     /* dump header, kernel/user pages   */
+#define DUMP_LEVEL_ALL_RAM     0x8     /* dump header, all RAM pages       */
+#define DUMP_LEVEL_ALL         0x10    /* dump all memory RAM and firmware */
+
+
+/* dump compression options -- add as necessary */
+#define DUMP_COMPRESS_NONE     0x0     /* don't compress this dump         */
+#define DUMP_COMPRESS_RLE      0x1     /* use RLE compression              */
+#define DUMP_COMPRESS_GZIP     0x2     /* use GZIP compression             */
+
+/* dump flags - any dump-type specific flags -- add as necessary */
+#define DUMP_FLAGS_NONE                0x0     /* no flags are set for this dump   */
+#define DUMP_FLAGS_SOFTBOOT    0x2     /* 2 stage soft-boot based dump     */
+#define DUMP_FLAGS_NONDISRUPT   0X1    /* non-disruptive dumping           */
+
+#define DUMP_FLAGS_TARGETMASK  0xf0000000 /* handle special case targets   */
+#define DUMP_FLAGS_DISKDUMP    0x80000000 /* dump to local disk            */
+#define DUMP_FLAGS_NETDUMP     0x40000000 /* dump over the network         */
+
+/* dump header flags -- add as necessary */
+#define DUMP_DH_FLAGS_NONE     0x0     /* no flags set (error condition!)  */
+#define DUMP_DH_RAW            0x1     /* raw page (no compression)        */
+#define DUMP_DH_COMPRESSED     0x2     /* page is compressed               */
+#define DUMP_DH_END            0x4     /* end marker on a full dump        */
+#define DUMP_DH_TRUNCATED      0x8     /* dump is incomplete               */
+#define DUMP_DH_TEST_PATTERN   0x10    /* dump page is a test pattern      */
+#define DUMP_DH_NOT_USED       0x20    /* 1st bit not used in flags        */
+
+/* names for various dump parameters in /proc/kernel */
+#define DUMP_ROOT_NAME         "sys/dump"
+#define DUMP_DEVICE_NAME       "device"
+#define DUMP_COMPRESS_NAME     "compress"
+#define DUMP_LEVEL_NAME                "level"
+#define DUMP_FLAGS_NAME                "flags"
+#define DUMP_ADDR_NAME         "addr"
+
+#define DUMP_SYSRQ_KEY         'd'     /* key to use for MAGIC_SYSRQ key   */
+
+/* CTL_DUMP names: */
+enum
+{
+       CTL_DUMP_DEVICE=1,
+       CTL_DUMP_COMPRESS=3,
+       CTL_DUMP_LEVEL=3,
+       CTL_DUMP_FLAGS=4,
+       CTL_DUMP_ADDR=5,
+       CTL_DUMP_TEST=6,
+};
+
+
+/* page size for gzip compression -- buffered slightly beyond hardware PAGE_SIZE used by DUMP */
+#define DUMP_DPC_PAGE_SIZE     (DUMP_PAGE_SIZE + 512)
+
+/* dump ioctl() control options */
+#define DIOSDUMPDEV     _IOW('p', 0xA0, unsigned int)  /* set the dump device              */
+#define DIOGDUMPDEV     _IOR('p', 0xA1, unsigned int)  /* get the dump device              */
+#define DIOSDUMPLEVEL   _IOW('p', 0xA2, unsigned int)  /* set the dump level               */
+#define DIOGDUMPLEVEL   _IOR('p', 0xA3, unsigned int)  /* get the dump level               */
+#define DIOSDUMPFLAGS   _IOW('p', 0xA4, unsigned int)  /* set the dump flag parameters     */
+#define DIOGDUMPFLAGS   _IOR('p', 0xA5, unsigned int)  /* get the dump flag parameters     */
+#define DIOSDUMPCOMPRESS _IOW('p', 0xA6, unsigned int) /* set the dump compress level      */
+#define DIOGDUMPCOMPRESS _IOR('p', 0xA7, unsigned int) /* get the dump compress level      */
+
+/* these ioctls are used only by netdump module */
+#define DIOSTARGETIP    _IOW('p', 0xA8, unsigned int)  /* set the target m/c's ip           */
+#define DIOGTARGETIP    _IOR('p', 0xA9, unsigned int)  /* get the target m/c's ip           */
+#define DIOSTARGETPORT  _IOW('p', 0xAA, unsigned int) /* set the target m/c's port          */
+#define DIOGTARGETPORT  _IOR('p', 0xAB, unsigned int) /* get the target m/c's port          */
+#define DIOSSOURCEPORT  _IOW('p', 0xAC, unsigned int) /* set the source m/c's port          */
+#define DIOGSOURCEPORT  _IOR('p', 0xAD, unsigned int) /* get the source m/c's port          */
+#define DIOSETHADDR     _IOW('p', 0xAE, unsigned int) /* set ethernet address      */
+#define DIOGETHADDR     _IOR('p', 0xAF, unsigned int) /* get ethernet address       */
+#define DIOGDUMPOKAY   _IOR('p', 0xB0, unsigned int) /* check if dump is configured      */
+#define DIOSDUMPTAKE    _IOW('p', 0xB1, unsigned int) /* Take a manual dump               */
+
+/*
+ * Structure: __dump_header
+ *  Function: This is the header dumped at the top of every valid crash
+ *            dump.  
+ */
+struct __dump_header {
+       /* the dump magic number -- unique to verify dump is valid */
+       u64     dh_magic_number;
+
+       /* the version number of this dump */
+       u32     dh_version;
+
+       /* the size of this header (in case we can't read it) */
+       u32     dh_header_size;
+
+       /* the level of this dump (just a header?) */
+       u32     dh_dump_level;
+
+       /* 
+        * We assume dump_page_size to be 4K in every case.
+        * Store here the configurable system page size (4K, 8K, 16K, etc.) 
+        */
+       u32     dh_page_size;
+
+       /* the size of all physical memory */
+       u64     dh_memory_size;
+
+       /* the start of physical memory */
+       u64     dh_memory_start;
+
+       /* the end of physical memory */
+       u64     dh_memory_end;
+
+       /* the number of hardware/physical pages in this dump specifically */
+       u32     dh_num_dump_pages;
+
+       /* the panic string, if available */
+       char    dh_panic_string[DUMP_PANIC_LEN];
+
+       /* timeval depends on architecture, two long values */
+       struct {
+               u64 tv_sec;
+               u64 tv_usec;
+       } dh_time; /* the time of the system crash */
+
+       /* the NEW utsname (uname) information -- in character form */
+       /* we do this so we don't have to include utsname.h         */
+       /* plus it helps us be more architecture independent        */
+       /* now maybe one day soon they'll make the [65] a #define!  */
+       char    dh_utsname_sysname[65];
+       char    dh_utsname_nodename[65];
+       char    dh_utsname_release[65];
+       char    dh_utsname_version[65];
+       char    dh_utsname_machine[65];
+       char    dh_utsname_domainname[65];
+
+       /* the address of current task (OLD = void *, NEW = u64) */
+       u64     dh_current_task;
+
+       /* what type of compression we're using in this dump (if any) */
+       u32     dh_dump_compress;
+
+       /* any additional flags */
+       u32     dh_dump_flags;
+
+       /* any additional flags */
+       u32     dh_dump_device;
+} __attribute__((packed));
+
+/*
+ * Structure: __dump_page
+ *  Function: To act as the header associated to each physical page of
+ *            memory saved in the system crash dump.  This allows for
+ *            easy reassembly of each crash dump page.  The address bits
+ *            are split to make things easier for 64-bit/32-bit system
+ *            conversions.
+ *
+ * dp_byte_offset and dp_page_index are landmarks that are helpful when
+ * looking at a hex dump of /dev/vmdump,
+ */
+struct __dump_page {
+       /* the address of this dump page */
+       u64     dp_address;
+
+       /* the size of this dump page */
+       u32     dp_size;
+
+       /* flags (currently DUMP_COMPRESSED, DUMP_RAW or DUMP_END) */
+       u32     dp_flags;
+} __attribute__((packed));
+
+/*
+ * Structure: __lkcdinfo
+ * Function:  This structure contains information needed for the lkcdutils
+ *            package (particularly lcrash) to determine what information is
+ *            associated to this kernel, specifically.
+ */
+struct __lkcdinfo {
+       int     arch;
+       int     ptrsz;
+       int     byte_order;
+       int     linux_release;
+       int     page_shift;
+       int     page_size;
+       u64     page_mask;
+       u64     page_offset;
+       int     stack_offset;
+};
+
+#ifdef __KERNEL__
+
+/*
+ * Structure: __dump_compress
+ *  Function: This is what an individual compression mechanism can use
+ *            to plug in their own compression techniques.  It's always
+ *            best to build these as individual modules so that people
+ *            can put in whatever they want.
+ */
+struct __dump_compress {
+       /* the list_head structure for list storage */
+       struct list_head list;
+
+       /* the type of compression to use (DUMP_COMPRESS_XXX) */
+       int compress_type;
+       const char *compress_name;
+
+       /* the compression function to call */
+       u16 (*compress_func)(const u8 *, u16, u8 *, u16);
+};
+
+/* functions for dump compression registration */
+extern void dump_register_compression(struct __dump_compress *);
+extern void dump_unregister_compression(int);
+
+/*
+ * Structure dump_mbank[]:
+ *
+ * For CONFIG_DISCONTIGMEM systems this array specifies the
+ * memory banks/chunks that need to be dumped after a panic.
+ *
+ * For classic systems it specifies a single set of pages from
+ * 0 to max_mapnr.
+ */
+struct __dump_mbank {
+       u64     start;
+       u64     end;
+       int     type;
+       int     pad1;
+       long    pad2;
+};
+
+#define DUMP_MBANK_TYPE_CONVENTIONAL_MEMORY            1
+#define DUMP_MBANK_TYPE_OTHER                          2
+
+#define MAXCHUNKS 256
+extern int dump_mbanks;
+extern struct __dump_mbank dump_mbank[MAXCHUNKS];
+
+/* notification event codes */
+#define DUMP_BEGIN             0x0001  /* dump beginning */
+#define DUMP_END               0x0002  /* dump ending */
+
+/* Scheduler soft spin control.
+ *
+ * 0 - no dump in progress
+ * 1 - cpu0 is dumping, ...
+ */
+extern unsigned long dump_oncpu;
+extern void dump_execute(const char *, const struct pt_regs *);
+
+/*
+ *     Notifier list for kernel code which wants to be called
+ *     at kernel dump. 
+ */
+extern struct notifier_block *dump_notifier_list;
+static inline int register_dump_notifier(struct notifier_block *nb)
+{
+       return notifier_chain_register(&dump_notifier_list, nb);
+}
+static inline int unregister_dump_notifier(struct notifier_block * nb)
+{
+       return notifier_chain_unregister(&dump_notifier_list, nb);
+}
+
+extern void (*dump_function_ptr)(const char *, const struct pt_regs *);
+static inline void dump(char * str, struct pt_regs * regs)
+{
+       if (dump_function_ptr)
+               dump_function_ptr(str, regs);
+}
+
+/*
+ * Common Arch Specific Functions should be declared here.
+ * This allows the C compiler to detect discrepancies.
+ */
+extern void    __dump_open(void);
+extern void    __dump_cleanup(void);
+extern void    __dump_init(u64);
+extern void    __dump_save_regs(struct pt_regs *, const struct pt_regs *);
+extern int     __dump_configure_header(const struct pt_regs *);
+extern int     __dump_irq_enable(void);
+extern void    __dump_irq_restore(void);
+extern int     __dump_page_valid(unsigned long index);
+#ifdef CONFIG_SMP
+extern void    __dump_save_other_cpus(void);
+#else
+#define        __dump_save_other_cpus()
+#endif
+
+extern int manual_handle_crashdump(void);
+
+/* to track all used (compound + zero order) pages */
+#define PageInuse(p)   (PageCompound(p) || page_count(p))
+
+#endif /* __KERNEL__ */
+
+#else  /* !CONFIG_CRASH_DUMP */
+
+/* If not configured then make code disappear! */
+#define register_dump_watchdog(x)      do { } while(0)
+#define unregister_dump_watchdog(x)    do { } while(0)
+#define register_dump_notifier(x)      do { } while(0)
+#define unregister_dump_notifier(x)    do { } while(0)
+#define dump_in_progress()             0
+#define dump(x, y)                     do { } while(0)
+
+#endif /* !CONFIG_CRASH_DUMP */
+
+#endif /* _DUMP_H */
diff --git a/include/linux/dump_netdev.h b/include/linux/dump_netdev.h
new file mode 100644 (file)
index 0000000..b2f811f
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *  linux/drivers/net/netconsole.h
+ *
+ *  Copyright (C) 2001  Ingo Molnar <mingo@redhat.com>
+ *
+ *  This file contains the implementation of an IRQ-safe, crash-safe
+ *  kernel console implementation that outputs kernel messages to the
+ *  network.
+ *
+ * Modification history:
+ *
+ * 2001-09-17    started by Ingo Molnar.
+ */
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+#define NETCONSOLE_VERSION 0x03
+
+enum netdump_commands {
+       COMM_NONE = 0,
+       COMM_SEND_MEM = 1,
+       COMM_EXIT = 2,
+       COMM_REBOOT = 3,
+       COMM_HELLO = 4,
+       COMM_GET_NR_PAGES = 5,
+       COMM_GET_PAGE_SIZE = 6,
+       COMM_START_NETDUMP_ACK = 7,
+       COMM_GET_REGS = 8,
+       COMM_GET_MAGIC = 9,
+       COMM_START_WRITE_NETDUMP_ACK = 10,
+};
+
+typedef struct netdump_req_s {
+       u64 magic;
+       u32 nr;
+       u32 command;
+       u32 from;
+       u32 to;
+} req_t;
+
+enum netdump_replies {
+       REPLY_NONE = 0,
+       REPLY_ERROR = 1,
+       REPLY_LOG = 2,
+       REPLY_MEM = 3,
+       REPLY_RESERVED = 4,
+       REPLY_HELLO = 5,
+       REPLY_NR_PAGES = 6,
+       REPLY_PAGE_SIZE = 7,
+       REPLY_START_NETDUMP = 8,
+       REPLY_END_NETDUMP = 9,
+       REPLY_REGS = 10,
+       REPLY_MAGIC = 11,
+       REPLY_START_WRITE_NETDUMP = 12,
+};
+
+typedef struct netdump_reply_s {
+       u32 nr;
+       u32 code;
+       u32 info;
+} reply_t;
+
+#define HEADER_LEN (1 + sizeof(reply_t))
+
+
diff --git a/include/linux/dumpdev.h b/include/linux/dumpdev.h
new file mode 100644 (file)
index 0000000..51ef84d
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Generic dump device interfaces for flexible system dump 
+ * (Enables variation of dump target types e.g disk, network, memory)
+ *
+ * These interfaces have evolved based on discussions on lkcd-devel. 
+ * Eventually the intent is to support primary and secondary or 
+ * alternate targets registered at the same time, with scope for 
+ * situation based failover or multiple dump devices used for parallel 
+ * dump i/o.
+ *
+ * Started: Oct 2002 - Suparna Bhattacharya (suparna@in.ibm.com)
+ *
+ * Copyright (C) 2001 - 2002 Matt D. Robinson.  All rights reserved.
+ * Copyright (C) 2002 International Business Machines Corp. 
+ *
+ * This code is released under version 2 of the GNU GPL.
+ */
+
+#ifndef _LINUX_DUMPDEV_H
+#define _LINUX_DUMPDEV_H
+
+#include <linux/kernel.h>
+#include <linux/wait.h>
+#include <linux/bio.h>
+
+/* Determined by the dump target (device) type */
+
+struct dump_dev;
+
+struct dump_dev_ops {
+       int (*open)(struct dump_dev *, unsigned long); /* configure */
+       int (*release)(struct dump_dev *); /* unconfigure */
+       int (*silence)(struct dump_dev *); /* when dump starts */
+       int (*resume)(struct dump_dev *); /* when dump is over */
+       int (*seek)(struct dump_dev *, loff_t);
+       /* trigger a write (async in nature typically) */
+       int (*write)(struct dump_dev *, void *, unsigned long);
+       /* not usually used during dump, but option available */
+       int (*read)(struct dump_dev *, void *, unsigned long);
+       /* use to poll for completion */
+       int (*ready)(struct dump_dev *, void *); 
+       int (*ioctl)(struct dump_dev *, unsigned int, unsigned long);
+};
+
+struct dump_dev {
+       char type_name[32]; /* block, net-poll etc */
+       unsigned long device_id; /* interpreted differently for various types */
+       struct dump_dev_ops *ops;
+       struct list_head list;
+       loff_t curr_offset;
+};
+
+/*
+ * dump_dev type variations: 
+ */
+
+/* block */
+struct dump_blockdev {
+       struct dump_dev ddev;
+       dev_t dev_id;
+       struct block_device *bdev;
+       struct bio *bio;
+       loff_t start_offset;
+       loff_t limit;
+       int err;
+};
+
+static inline struct dump_blockdev *DUMP_BDEV(struct dump_dev *dev)
+{
+       return container_of(dev, struct dump_blockdev, ddev);
+}
+
+
+/* mem  - for internal use by soft-boot based dumper */
+struct dump_memdev {
+       struct dump_dev ddev;
+       unsigned long indirect_map_root;
+       unsigned long nr_free;
+       struct page *curr_page;
+       unsigned long *curr_map;
+       unsigned long curr_map_offset;
+       unsigned long last_offset;
+       unsigned long last_used_offset;
+       unsigned long last_bs_offset;
+};     
+
+static inline struct dump_memdev *DUMP_MDEV(struct dump_dev *dev)
+{
+       return container_of(dev, struct dump_memdev, ddev);
+}
+
+/* Todo/future - meant for raw dedicated interfaces e.g. mini-ide driver */
+struct dump_rdev {
+       struct dump_dev ddev;
+       char name[32];
+       int (*reset)(struct dump_rdev *, unsigned int, 
+               unsigned long);
+       /* ... to do ... */
+};
+
+/* just to get the size right when saving config across a soft-reboot */
+struct dump_anydev {
+       union {
+               struct dump_blockdev bddev;
+               /* .. add other types here .. */
+       };
+};
+
+
+
+/* Dump device / target operation wrappers */
+/* These assume that dump_dev is initiatized to dump_config.dumper->dev */
+
+extern struct dump_dev *dump_dev;
+
+static inline int dump_dev_open(unsigned long arg)
+{
+       return dump_dev->ops->open(dump_dev, arg);
+}
+
+static inline int dump_dev_release(void)
+{
+       return dump_dev->ops->release(dump_dev);
+}
+
+static inline int dump_dev_silence(void)
+{
+       return dump_dev->ops->silence(dump_dev);
+}
+
+static inline int dump_dev_resume(void)
+{
+       return dump_dev->ops->resume(dump_dev);
+}
+
+static inline int dump_dev_seek(loff_t offset)
+{
+       return dump_dev->ops->seek(dump_dev, offset);
+}
+
+static inline int dump_dev_write(void *buf, unsigned long len)
+{
+       return dump_dev->ops->write(dump_dev, buf, len);
+}
+
+static inline int dump_dev_ready(void *buf)
+{
+       return dump_dev->ops->ready(dump_dev, buf);
+}
+
+static inline int dump_dev_ioctl(unsigned int cmd, unsigned long arg)
+{
+       if (!dump_dev || !dump_dev->ops->ioctl)
+               return -EINVAL;
+       return dump_dev->ops->ioctl(dump_dev, cmd, arg);
+}
+
+extern int dump_register_device(struct dump_dev *);
+extern void dump_unregister_device(struct dump_dev *);
+
+#endif /*  _LINUX_DUMPDEV_H */
index 27e8183..b42a9c4 100644 (file)
@@ -17,6 +17,7 @@ typedef void (elevator_requeue_req_fn) (request_queue_t *, struct request *);
 typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *);
 typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *);
 typedef int (elevator_may_queue_fn) (request_queue_t *, int);
+typedef void (elevator_set_congested_fn) (request_queue_t *);
 
 typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, int);
 typedef void (elevator_put_req_fn) (request_queue_t *, struct request *);
@@ -45,6 +46,7 @@ struct elevator_s
        elevator_put_req_fn *elevator_put_req_fn;
 
        elevator_may_queue_fn *elevator_may_queue_fn;
+       elevator_set_congested_fn *elevator_set_congested_fn;
 
        elevator_init_fn *elevator_init_fn;
        elevator_exit_fn *elevator_exit_fn;
@@ -74,6 +76,7 @@ extern struct request *elv_latter_request(request_queue_t *, struct request *);
 extern int elv_register_queue(request_queue_t *q);
 extern void elv_unregister_queue(request_queue_t *q);
 extern int elv_may_queue(request_queue_t *, int);
+extern void elv_set_congested(request_queue_t *);
 extern void elv_completed_request(request_queue_t *, struct request *);
 extern int elv_set_request(request_queue_t *, struct request *, int);
 extern void elv_put_request(request_queue_t *, struct request *);
@@ -119,4 +122,6 @@ extern int elv_try_last_merge(request_queue_t *, struct bio *);
 #define ELEVATOR_INSERT_BACK   2
 #define ELEVATOR_INSERT_SORT   3
 
+#define RQ_ELV_DATA(rq)                (rq)->elevator_private
+
 #endif
index a1f948f..96c5313 100644 (file)
@@ -23,6 +23,9 @@
 #define EJUKEBOX       528     /* Request initiated, but will not complete before timeout */
 #define EIOCBQUEUED    529     /* iocb queued, will get completion event */
 
+/* Defined for TUX async IO */
+#define EWOULDBLOCKIO  530     /* Would block due to block-IO */
+
 #endif
 
 #endif
index d701ba8..7c6f650 100644 (file)
@@ -192,6 +192,8 @@ struct ext2_group_desc
 #define EXT2_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
 #define EXT2_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
 #define EXT2_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
+#define EXT2_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
+#define EXT2_IUNLINK_FL                        0x08000000 /* Immutable unlink */
 #define EXT2_RESERVED_FL               0x80000000 /* reserved for ext2 lib */
 
 #define EXT2_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
@@ -240,7 +242,7 @@ struct ext2_inode {
                struct {
                        __u8    l_i_frag;       /* Fragment number */
                        __u8    l_i_fsize;      /* Fragment size */
-                       __u16   i_pad1;
+                       __u16   l_i_xid;        /* LRU Context */
                        __u16   l_i_uid_high;   /* these 2 fields    */
                        __u16   l_i_gid_high;   /* were reserved2[0] */
                        __u32   l_i_reserved2;
@@ -272,6 +274,7 @@ struct ext2_inode {
 #define i_gid_low      i_gid
 #define i_uid_high     osd2.linux2.l_i_uid_high
 #define i_gid_high     osd2.linux2.l_i_gid_high
+#define i_raw_xid      osd2.linux2.l_i_xid
 #define i_reserved2    osd2.linux2.l_i_reserved2
 #endif
 
@@ -312,6 +315,7 @@ struct ext2_inode {
 #define EXT2_MOUNT_NO_UID32            0x0200  /* Disable 32-bit UIDs */
 #define EXT2_MOUNT_XATTR_USER          0x4000  /* Extended user attributes */
 #define EXT2_MOUNT_POSIX_ACL           0x8000  /* POSIX Access Control Lists */
+#define EXT2_MOUNT_TAG_XID             (1<<16) /* Enable Context Tags */
 
 #define clear_opt(o, opt)              o &= ~EXT2_MOUNT_##opt
 #define set_opt(o, opt)                        o |= EXT2_MOUNT_##opt
index 0814515..100fba9 100644 (file)
@@ -185,6 +185,8 @@ struct ext3_group_desc
 #define EXT3_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
 #define EXT3_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
 #define EXT3_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
+#define EXT3_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
+#define EXT3_IUNLINK_FL                        0x08000000 /* Immutable unlink */
 #define EXT3_RESERVED_FL               0x80000000 /* reserved for ext3 lib */
 
 #define EXT3_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
@@ -208,6 +210,9 @@ struct ext3_group_desc
 #ifdef CONFIG_JBD_DEBUG
 #define EXT3_IOC_WAIT_FOR_READONLY     _IOR('f', 99, long)
 #endif
+#ifdef CONFIG_VSERVER_LEGACY           
+#define EXT3_IOC_SETXID                        FIOC_SETXIDJ
+#endif
 
 /*
  * Structure of an inode on the disk
@@ -244,7 +249,7 @@ struct ext3_inode {
                struct {
                        __u8    l_i_frag;       /* Fragment number */
                        __u8    l_i_fsize;      /* Fragment size */
-                       __u16   i_pad1;
+                       __u16   l_i_xid;        /* LRU Context */
                        __u16   l_i_uid_high;   /* these 2 fields    */
                        __u16   l_i_gid_high;   /* were reserved2[0] */
                        __u32   l_i_reserved2;
@@ -276,6 +281,7 @@ struct ext3_inode {
 #define i_gid_low      i_gid
 #define i_uid_high     osd2.linux2.l_i_uid_high
 #define i_gid_high     osd2.linux2.l_i_gid_high
+#define i_raw_xid      osd2.linux2.l_i_xid
 #define i_reserved2    osd2.linux2.l_i_reserved2
 
 #elif defined(__GNU__)
@@ -324,6 +330,7 @@ struct ext3_inode {
 #define EXT3_MOUNT_NO_UID32            0x2000  /* Disable 32-bit UIDs */
 #define EXT3_MOUNT_XATTR_USER          0x4000  /* Extended user attributes */
 #define EXT3_MOUNT_POSIX_ACL           0x8000  /* POSIX Access Control Lists */
+#define EXT3_MOUNT_TAG_XID             0x20000 /* Enable Context Tags */
 
 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
 #ifndef _LINUX_EXT2_FS_H
index b3fbadf..1c1e0b3 100644 (file)
@@ -81,4 +81,6 @@ struct task_struct;
 struct files_struct *get_files_struct(struct task_struct *);
 void FASTCALL(put_files_struct(struct files_struct *fs));
 
+extern int dupfd(struct file *file, unsigned int start);
+
 #endif /* __LINUX_FILE_H */
index 7e10a25..996b737 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/cache.h>
 #include <linux/prio_tree.h>
 #include <linux/kobject.h>
+#include <linux/mount.h>
 #include <asm/atomic.h>
 
 struct iovec;
@@ -119,6 +120,7 @@ extern int leases_enable, dir_notify_enable, lease_break_time;
 #define MS_VERBOSE     32768
 #define MS_POSIXACL    (1<<16) /* VFS does not apply the umask */
 #define MS_ONE_SECOND  (1<<17) /* fs has 1 sec a/m/ctime resolution */
+#define MS_TAGXID      (1<<24) /* tag inodes with context information */
 #define MS_ACTIVE      (1<<30)
 #define MS_NOUSER      (1<<31)
 
@@ -145,6 +147,8 @@ extern int leases_enable, dir_notify_enable, lease_break_time;
 #define S_DIRSYNC      64      /* Directory modifications are synchronous */
 #define S_NOCMTIME     128     /* Do not update file c/mtime */
 #define S_SWAPFILE     256     /* Do not truncate: swapon got its bmaps */
+#define S_BARRIER      512     /* Barrier for chroot() */
+#define S_IUNLINK      1024    /* Immutable unlink */
 
 /*
  * Note that nosuid etc flags are inode-specific: setting some file-system
@@ -161,7 +165,7 @@ extern int leases_enable, dir_notify_enable, lease_break_time;
  */
 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
 
-#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
+#define IS_RDONLY(inode)       __IS_FLG(inode, MS_RDONLY)
 #define IS_SYNC(inode)         (__IS_FLG(inode, MS_SYNCHRONOUS) || \
                                        ((inode)->i_flags & S_SYNC))
 #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
@@ -171,11 +175,14 @@ extern int leases_enable, dir_notify_enable, lease_break_time;
 #define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
 #define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
 #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
+#define IS_IUNLINK(inode)      ((inode)->i_flags & S_IUNLINK)
+#define IS_IXORUNLINK(inode)   ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
 #define IS_NOATIME(inode)      (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
 #define IS_NODIRATIME(inode)   __IS_FLG(inode, MS_NODIRATIME)
 #define IS_POSIXACL(inode)     __IS_FLG(inode, MS_POSIXACL)
 #define IS_ONE_SECOND(inode)   __IS_FLG(inode, MS_ONE_SECOND)
 
+#define IS_BARRIER(inode)      (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
 #define IS_DEADDIR(inode)      ((inode)->i_flags & S_DEAD)
 #define IS_NOCMTIME(inode)     ((inode)->i_flags & S_NOCMTIME)
 #define IS_SWAPFILE(inode)     ((inode)->i_flags & S_SWAPFILE)
@@ -257,6 +264,7 @@ typedef void (dio_iodone_t)(struct inode *inode, loff_t offset,
 #define ATTR_ATTR_FLAG 1024
 #define ATTR_KILL_SUID 2048
 #define ATTR_KILL_SGID 4096
+#define ATTR_XID       8192
 
 /*
  * This is the Inode Attributes structure, used for notify_change().  It
@@ -272,6 +280,7 @@ struct iattr {
        umode_t         ia_mode;
        uid_t           ia_uid;
        gid_t           ia_gid;
+       xid_t           ia_xid;
        loff_t          ia_size;
        struct timespec ia_atime;
        struct timespec ia_mtime;
@@ -288,6 +297,9 @@ struct iattr {
 #define ATTR_FLAG_IMMUTABLE    8       /* Immutable file */
 #define ATTR_FLAG_NODIRATIME   16      /* Don't update atime for directory */
 
+#define ATTR_FLAG_BARRIER      512     /* Barrier for chroot() */
+#define ATTR_FLAG_IUNLINK      1024    /* Immutable unlink */
+
 /*
  * Includes for diskquotas.
  */
@@ -426,6 +438,7 @@ struct inode {
        unsigned int            i_nlink;
        uid_t                   i_uid;
        gid_t                   i_gid;
+       xid_t                   i_xid;
        dev_t                   i_rdev;
        loff_t                  i_size;
        struct timespec         i_atime;
@@ -981,8 +994,16 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
 
 static inline void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
 {
-       /* per-mountpoint checks will go here */
-       update_atime(dentry->d_inode);
+       struct inode *inode = dentry->d_inode;
+
+       if (MNT_IS_NOATIME(mnt))
+               return;
+       if (S_ISDIR(inode->i_mode) && MNT_IS_NODIRATIME(mnt))
+               return;
+       if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
+               return;
+
+       update_atime(inode);
 }
 
 static inline void file_accessed(struct file *file)
@@ -1419,7 +1440,7 @@ ssize_t generic_file_write_nolock(struct file *file, const struct iovec *iov,
 extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
 extern void do_generic_mapping_read(struct address_space *mapping,
                                    struct file_ra_state *, struct file *,
-                                   loff_t *, read_descriptor_t *, read_actor_t);
+                                   loff_t *, read_descriptor_t *, read_actor_t, int);
 extern void
 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
 extern ssize_t generic_file_direct_IO(int rw, struct kiocb *iocb,
@@ -1436,14 +1457,15 @@ extern int nonseekable_open(struct inode * inode, struct file * filp);
 
 static inline void do_generic_file_read(struct file * filp, loff_t *ppos,
                                        read_descriptor_t * desc,
-                                       read_actor_t actor)
+                                       read_actor_t actor, int nonblock)
 {
        do_generic_mapping_read(filp->f_mapping,
                                &filp->f_ra,
                                filp,
                                ppos,
                                desc,
-                               actor);
+                               actor,
+                               nonblock);
 }
 
 ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
@@ -1535,7 +1557,7 @@ extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const vo
 extern int inode_change_ok(struct inode *, struct iattr *);
 extern int __must_check inode_setattr(struct inode *, struct iattr *);
 
-extern void inode_update_time(struct inode *inode, int ctime_too);
+extern void inode_update_time(struct inode *inode, struct vfsmount *mnt, int ctime_too);
 
 static inline ino_t parent_ino(struct dentry *dentry)
 {
@@ -1570,5 +1592,17 @@ static inline void free_secdata(void *secdata)
 { }
 #endif /* CONFIG_SECURITY */
 
+/* io priorities */
+
+#define IOPRIO_NR      21
+
+#define IOPRIO_IDLE    0
+#define IOPRIO_NORM    10
+#define IOPRIO_RT      20
+
+asmlinkage int sys_ioprio_set(int ioprio);
+asmlinkage int sys_ioprio_get(void);
+
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_FS_H */
diff --git a/include/linux/fsfilter.h b/include/linux/fsfilter.h
deleted file mode 100644 (file)
index 0cd4677..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- */
-
-#ifndef __FILTER_H_
-#define __FILTER_H_ 1
-
-#ifdef __KERNEL__
-
-/* cachetype.c */
-
-/* 
- * it is important that things like inode, super and file operations
- * for intermezzo are not defined statically.  If methods are NULL
- * the VFS takes special action based on that.  Given that different
- * cache types have NULL ops at different slots, we must install opeation 
- * talbes for InterMezzo with NULL's in the same spot
- */
-
-struct filter_ops { 
-        struct super_operations filter_sops;
-
-        struct inode_operations filter_dir_iops;
-        struct inode_operations filter_file_iops;
-        struct inode_operations filter_sym_iops;
-
-        struct file_operations filter_dir_fops;
-        struct file_operations filter_file_fops;
-        struct file_operations filter_sym_fops;
-
-        struct dentry_operations filter_dentry_ops;
-};
-
-struct cache_ops {
-        /* operations on the file store */
-        struct super_operations *cache_sops;
-
-        struct inode_operations *cache_dir_iops;
-        struct inode_operations *cache_file_iops;
-        struct inode_operations *cache_sym_iops;
-
-        struct file_operations *cache_dir_fops;
-        struct file_operations *cache_file_fops;
-        struct file_operations *cache_sym_fops;
-
-        struct dentry_operations *cache_dentry_ops;
-};
-
-
-#define FILTER_DID_SUPER_OPS 0x1
-#define FILTER_DID_INODE_OPS 0x2
-#define FILTER_DID_FILE_OPS 0x4
-#define FILTER_DID_DENTRY_OPS 0x8
-#define FILTER_DID_DEV_OPS 0x10
-#define FILTER_DID_SYMLINK_OPS 0x20
-#define FILTER_DID_DIR_OPS 0x40
-
-struct filter_fs {
-        int o_flags;
-        struct filter_ops o_fops;
-        struct cache_ops  o_caops;
-        struct journal_ops *o_trops;
-        struct snapshot_ops *o_snops;
-};
-
-#define FILTER_FS_TYPES 6
-#define FILTER_FS_EXT2 0
-#define FILTER_FS_EXT3 1
-#define FILTER_FS_REISERFS 2
-#define FILTER_FS_XFS 3
-#define FILTER_FS_OBDFS 4
-#define FILTER_FS_TMPFS 5
-extern struct filter_fs filter_oppar[FILTER_FS_TYPES];
-
-struct filter_fs *filter_get_filter_fs(const char *cache_type);
-void filter_setup_journal_ops(struct filter_fs *ops, char *cache_type);
-struct super_operations *filter_c2usops(struct filter_fs *cache);
-struct inode_operations *filter_c2ufiops(struct filter_fs *cache);
-struct inode_operations *filter_c2udiops(struct filter_fs *cache);
-struct inode_operations *filter_c2usiops(struct filter_fs *cache);
-struct file_operations *filter_c2uffops(struct filter_fs *cache);
-struct file_operations *filter_c2udfops(struct filter_fs *cache);
-struct file_operations *filter_c2usfops(struct filter_fs *cache);
-struct super_operations *filter_c2csops(struct filter_fs *cache);
-struct inode_operations *filter_c2cfiops(struct filter_fs *cache);
-struct inode_operations *filter_c2cdiops(struct filter_fs *cache);
-struct inode_operations *filter_c2csiops(struct filter_fs *cache);
-struct file_operations *filter_c2cffops(struct filter_fs *cache);
-struct file_operations *filter_c2cdfops(struct filter_fs *cache);
-struct file_operations *filter_c2csfops(struct filter_fs *cache);
-struct dentry_operations *filter_c2cdops(struct filter_fs *cache);
-struct dentry_operations *filter_c2udops(struct filter_fs *cache);
-
-void filter_setup_super_ops(struct filter_fs *cache, struct super_operations *cache_ops, struct super_operations *filter_sops);
-void filter_setup_dir_ops(struct filter_fs *cache, struct inode *cache_inode, struct inode_operations *filter_iops, struct file_operations *ffops);
-void filter_setup_file_ops(struct filter_fs *cache, struct inode *cache_inode, struct inode_operations *filter_iops, struct file_operations *filter_op);
-void filter_setup_symlink_ops(struct filter_fs *cache, struct inode *cache_inode, struct inode_operations *filter_iops, struct file_operations *filter_op);
-void filter_setup_dentry_ops(struct filter_fs *cache, struct dentry_operations *cache_dop,  struct dentry_operations *filter_dop);
-
-
-#define PRESTO_DEBUG
-#ifdef PRESTO_DEBUG
-/* debugging masks */
-#define D_SUPER     1  
-#define D_INODE     2   /* print entry and exit into procedure */
-#define D_FILE      4
-#define D_CACHE     8   /* cache debugging */
-#define D_MALLOC    16  /* print malloc, de-alloc information */
-#define D_JOURNAL   32
-#define D_UPCALL    64  /* up and downcall debugging */
-#define D_PSDEV    128
-#define D_PIOCTL   256
-#define D_SPECIAL  512
-#define D_TIMING  1024
-#define D_DOWNCALL 2048
-
-#define FDEBUG(mask, format, a...)                                      \
-        do {                                                            \
-                if (filter_debug & mask) {                              \
-                        printk("(%s,l. %d): ", __FUNCTION__, __LINE__); \
-                        printk(format, ##a); }                          \
-        } while (0)
-
-#define FENTRY                                                          \
-        if(filter_print_entry)                                          \
-                printk("Process %d entered %s\n", current->pid, __FUNCTION__)
-
-#define FEXIT                                                           \
-        if(filter_print_entry)                                          \
-                printk("Process %d leaving %s at %d\n", current->pid,   \
-                       __FUNCTION__,__LINE__)
-#endif
-#endif
-#endif
index 8980d1f..6026cfd 100644 (file)
@@ -46,7 +46,7 @@ struct vm_area_struct;
                        __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \
                        __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP)
 
-#define GFP_ATOMIC     (__GFP_HIGH)
+#define GFP_ATOMIC     (__GFP_HIGH | __GFP_NOWARN)
 #define GFP_NOIO       (__GFP_WAIT)
 #define GFP_NOFS       (__GFP_WAIT | __GFP_IO)
 #define GFP_KERNEL     (__GFP_WAIT | __GFP_IO | __GFP_FS)
@@ -73,16 +73,20 @@ struct vm_area_struct;
  * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets
  * optimized to &contig_page_data at compile-time.
  */
-extern struct page *
-FASTCALL(__alloc_pages(unsigned int, unsigned int, struct zonelist *));
 
-static inline struct page *alloc_pages_node(int nid, unsigned int gfp_mask,
-                                               unsigned int order)
+#ifndef HAVE_ARCH_FREE_PAGE
+static inline void arch_free_page(struct page *page, int order) { }
+#endif
+
+extern struct page * 
+FASTCALL(__alloc_pages(unsigned int, unsigned int, struct zonelist *));
+static inline struct page * alloc_pages_node(int nid, unsigned int gfp_mask, 
+                                            unsigned int order)
 {
        if (unlikely(order >= MAX_ORDER))
                return NULL;
 
-       return __alloc_pages(gfp_mask, order,
+       return __alloc_pages(gfp_mask, order, 
                NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK));
 }
 
index 232d8fd..e334a5f 100644 (file)
@@ -28,9 +28,10 @@ static inline void *kmap(struct page *page)
 
 #define kunmap(page) do { (void) (page); } while (0)
 
-#define kmap_atomic(page, idx)         page_address(page)
-#define kunmap_atomic(addr, idx)       do { } while (0)
-#define kmap_atomic_to_page(ptr)       virt_to_page(ptr)
+#define kmap_atomic(page, idx)                 page_address(page)
+#define kmap_atomic_nocache_pfn(pfn, idx)      pfn_to_kaddr(pfn)
+#define kunmap_atomic(addr, idx)               do { } while (0)
+#define kmap_atomic_to_page(ptr)               virt_to_page(ptr)
 
 #endif /* CONFIG_HIGHMEM */
 
index 954af9d..7a5de34 100644 (file)
@@ -33,7 +33,6 @@ void free_huge_page(struct page *);
 
 extern unsigned long max_huge_pages;
 extern const unsigned long hugetlb_zero, hugetlb_infinity;
-extern int sysctl_hugetlb_shm_group;
 
 #ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
 #define is_hugepage_only_range(addr, len)      0
diff --git a/include/linux/in_systm.h b/include/linux/in_systm.h
deleted file mode 100644 (file)
index eac9a58..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * INET                An implementation of the TCP/IP protocol suite for the LINUX
- *             operating system.  INET is implemented using the  BSD Socket
- *             interface as the means of communication with the user level.
- *
- *             Miscellaneous internetwork definitions for kernel.
- *
- * Version:    @(#)in_systm.h  1.0.0   12/17/93
- *
- * Authors:    Original taken from Berkeley BSD UNIX 4.3-RENO.
- *             Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- */
-#ifndef _LINUX_IN_SYSTM_H
-#define _LINUX_IN_SYSTM_H
-
-/*
- * Network types.
- * The n_ types are network-order variants of their natural
- * equivalents.  The Linux kernel NET-2 code does not use
- * them (yet), but it might in the future.  This is mostly
- * there for compatibility with BSD user-level programs.
- */
-typedef u_short        n_short;        /* short as received from the net       */
-typedef u_long n_long;         /* long as received from the net        */
-typedef u_long n_time;         /* ms since 00:00 GMT, byte rev         */
-
-#endif /* _LINUX_IN_SYSTM_H */
index 9937c8d..3a43ff4 100644 (file)
@@ -112,6 +112,11 @@ extern struct group_info init_groups;
        .proc_lock      = SPIN_LOCK_UNLOCKED,                           \
        .switch_lock    = SPIN_LOCK_UNLOCKED,                           \
        .journal_info   = NULL,                                         \
+       .xid            = 0,                                            \
+       .vx_info        = NULL,                                         \
+       .nid            = 0,                                            \
+       .nx_info        = NULL,                                         \
+       .ioprio         = IOPRIO_NORM,                                  \
 }
 
 
index 12d504e..ed8b641 100644 (file)
@@ -111,6 +111,7 @@ struct inet_opt {
        /* Socket demultiplex comparisons on incoming packets. */
        __u32                   daddr;          /* Foreign IPv4 addr */
        __u32                   rcv_saddr;      /* Bound local IPv4 addr */
+       __u32                   rcv_saddr2;     /* Second bound ipv4 addr, for ipv4root */
        __u16                   dport;          /* Destination port */
        __u16                   num;            /* Local port */
        __u32                   saddr;          /* Sending source */
index b291189..079c2fe 100644 (file)
@@ -66,6 +66,7 @@ struct kern_ipc_perm
        mode_t          mode; 
        unsigned long   seq;
        void            *security;
+       xid_t           xid;
 };
 
 #endif /* __KERNEL__ */
diff --git a/include/linux/isdn_lzscomp.h b/include/linux/isdn_lzscomp.h
deleted file mode 100644 (file)
index ca16cb1..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* $Id: isdn_lzscomp.h,v 1.1.10.1 2001/09/23 22:25:05 kai Exp $
- *
- * Header for isdn_lzscomp.c
- * Concentrated here to not mess up half a dozen kernel headers with code
- * snippets
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#define CI_LZS_COMPRESS                17
-#define CILEN_LZS_COMPRESS     5
-
-#define LZS_CMODE_NONE         0
-#define LZS_CMODE_LCB          1
-#define LZS_CMODE_CRC          2
-#define LZS_CMODE_SEQNO                3       /* MUST be implemented (default) */
-#define LZS_CMODE_EXT          4       /* Seems to be what Win0.95 uses */
-
-#define LZS_COMP_MAX_HISTS     1       /* Don't waste peers ressources */
-#define LZS_COMP_DEF_HISTS     1       /* Most likely to negotiate */
-#define LZS_DECOMP_MAX_HISTS   32      /* More is really nonsense */
-#define LZS_DECOMP_DEF_HISTS   8       /* If we get it, this may be optimal */
-
-#define LZS_HIST_BYTE1(word)           (word>>8)       /* Just for better reading */
-#define LZS_HIST_BYTE2(word)   (word&0xff)     /* of this big endian stuff */
-#define LZS_HIST_WORD(b1,b2)   ((b1<<8)|b2)    /* (network byte order rulez) */
index c4c8626..d83acc4 100644 (file)
@@ -45,15 +45,23 @@ extern int console_printk[];
 
 struct completion;
 
+#ifdef CONFIG_PREEMPT_VOLUNTARY
+extern void __cond_resched(void);
+# define might_resched() __cond_resched()
+#else
+# define might_resched() do { } while (0)
+#endif
+
 #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
-void __might_sleep(char *file, int line);
-#define might_sleep() __might_sleep(__FILE__, __LINE__)
-#define might_sleep_if(cond) do { if (unlikely(cond)) might_sleep(); } while (0)
+  void __might_sleep(char *file, int line, int atomic_depth);
+# define might_sleep() \
+       do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
 #else
-#define might_sleep() do {} while(0)
-#define might_sleep_if(cond) do {} while (0)
+# define might_sleep() do { might_resched(); } while (0)
 #endif
 
+#define might_sleep_if(cond) do { if (unlikely(cond)) might_sleep(); } while (0)
+
 #define abs(x) ({                              \
                int __x = (x);                  \
                (__x < 0) ? -__x : __x;         \
@@ -130,10 +138,14 @@ extern int oops_in_progress;              /* If set, an oops, panic(), BUG() or die() is in
 extern int panic_on_oops;
 extern int tainted;
 extern const char *print_tainted(void);
+struct pt_regs;
+extern void (*netdump_func) (struct pt_regs *regs);
+extern int netdump_mode;
 
 /* Values used for system_state */
 extern enum system_states {
        SYSTEM_BOOTING,
+       SYSTEM_BOOTING_SCHEDULER_OK,
        SYSTEM_RUNNING,
        SYSTEM_HALT,
        SYSTEM_POWER_OFF,
index 4594ccc..1f3bc24 100644 (file)
@@ -35,6 +35,7 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
 #define kstat_this_cpu __get_cpu_var(kstat)
 
 extern unsigned long long nr_context_switches(void);
+extern unsigned long long nr_preempt(void);
 
 /*
  * Number of interrupts per specific IRQ source, since bootup
diff --git a/include/linux/klog.h b/include/linux/klog.h
new file mode 100644 (file)
index 0000000..cb79bea
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * KLOG                Generic Logging facility built upon the relayfs infrastructure
+ *
+ * Authors:    Hubertus Frankeh  (frankeh@us.ibm.com)
+ *             Tom Zanussi  (zanussi@us.ibm.com)
+ *
+ *             Please direct all questions/comments to zanussi@us.ibm.com
+ *
+ *             Copyright (C) 2003, IBM Corp
+ *
+ *
+ *             This program is free software; you can redistribute it and/or
+ *             modify it under the terms of the GNU General Public License
+ *             as published by the Free Software Foundation; either version
+ *             2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_KLOG_H
+#define _LINUX_KLOG_H
+
+extern int klog(const char *fmt, ...);
+extern int klog_raw(const char *buf,int len); 
+
+#endif /* _LINUX_KLOG_H */
index d82d4c0..32e45b7 100644 (file)
@@ -12,6 +12,7 @@
        CACHE(256)
        CACHE(512)
        CACHE(1024)
+       CACHE(1620)
        CACHE(2048)
        CACHE(4096)
        CACHE(8192)
index b646a48..acbd719 100644 (file)
@@ -69,6 +69,7 @@
 /* defines only for the constants which don't work well as enums */
 #define ATA_TAG_POISON         0xfafbfcfdU
 
+#undef PORT_UNKNOWN
 enum {
        /* various global constants */
        LIBATA_MAX_PRD          = ATA_MAX_PRD / 2,
index 041263a..5cb08ee 100644 (file)
@@ -24,6 +24,7 @@
 #define MICROCODE_MINOR                184
 #define MWAVE_MINOR    219             /* ACP/Mwave Modem */
 #define MPT_MINOR      220
+#define CRASH_DUMP_MINOR   230         /* LKCD */
 #define MISC_DYNAMIC_MINOR 255
 
 #define TUN_MINOR           200
index 5c584cc..3fb1893 100644 (file)
@@ -26,6 +26,8 @@ extern void * high_memory;
 extern unsigned long vmalloc_earlyreserve;
 extern int page_cluster;
 
+extern int sysctl_legacy_va_layout;
+
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
@@ -229,6 +231,9 @@ struct page {
        void *virtual;                  /* Kernel virtual address (NULL if
                                           not kmapped, ie. highmem) */
 #endif /* WANT_PAGE_VIRTUAL */
+#ifdef CONFIG_CKRM_RES_MEM
+       void *memclass;
+#endif // CONFIG_CKRM_RES_MEM
 };
 
 /*
@@ -496,9 +501,20 @@ int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *new);
 struct mempolicy *shmem_get_policy(struct vm_area_struct *vma,
                                        unsigned long addr);
 struct file *shmem_file_setup(char * name, loff_t size, unsigned long flags);
-void shmem_lock(struct file * file, int lock);
+int shmem_lock(struct file *file, int lock, struct user_struct *user);
 int shmem_zero_setup(struct vm_area_struct *);
 
+static inline int can_do_mlock(void)
+{
+       if (capable(CAP_IPC_LOCK))
+               return 1;
+       if (current->rlim[RLIMIT_MEMLOCK].rlim_cur != 0)
+               return 1;
+       return 0;
+}
+extern int user_shm_lock(size_t, struct user_struct *);
+extern void user_shm_unlock(size_t, struct user_struct *);
+
 /*
  * Parameter block passed down to zap_pte_range in exceptional cases.
  */
@@ -565,6 +581,9 @@ int clear_page_dirty_for_io(struct page *page);
  */
 typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask);
 
+extern long do_mprotect(struct mm_struct *mm, unsigned long start, 
+                       size_t len, unsigned long prot);
+
 /*
  * Add an aging callback.  The int is the number of 'seeks' it takes
  * to recreate one of the objects that these functions age.
@@ -631,11 +650,19 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
        unsigned long addr, unsigned long len, pgoff_t pgoff);
 extern void exit_mmap(struct mm_struct *);
 
-extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
+extern unsigned long get_unmapped_area_prot(struct file *, unsigned long, unsigned long, unsigned long, unsigned long, int);
 
-extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
-       unsigned long len, unsigned long prot,
-       unsigned long flag, unsigned long pgoff);
+
+static inline unsigned long get_unmapped_area(struct file * file, unsigned long addr, 
+               unsigned long len, unsigned long pgoff, unsigned long flags)
+{
+       return get_unmapped_area_prot(file, addr, len, pgoff, flags, 0);        
+}
+
+extern unsigned long do_mmap_pgoff(struct mm_struct *mm, struct file *file, 
+                                  unsigned long addr, unsigned long len,
+                                  unsigned long prot, unsigned long flag,
+                                  unsigned long pgoff);
 
 static inline unsigned long do_mmap(struct file *file, unsigned long addr,
        unsigned long len, unsigned long prot,
@@ -645,7 +672,8 @@ static inline unsigned long do_mmap(struct file *file, unsigned long addr,
        if ((offset + PAGE_ALIGN(len)) < offset)
                goto out;
        if (!(offset & ~PAGE_MASK))
-               ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
+               ret = do_mmap_pgoff(current->mm, file, addr, len, prot, flag, 
+                                   offset >> PAGE_SHIFT);
 out:
        return ret;
 }
@@ -709,6 +737,8 @@ extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned lon
 extern struct page * vmalloc_to_page(void *addr);
 extern struct page * follow_page(struct mm_struct *mm, unsigned long address,
                int write);
+extern struct page * follow_page_pfn(struct mm_struct *mm,
+               unsigned long address, int write, unsigned long *pfn);
 extern int remap_page_range(struct vm_area_struct *vma, unsigned long from,
                unsigned long to, unsigned long size, pgprot_t prot);
 
index 47762ca..5edb739 100644 (file)
@@ -1,9 +1,11 @@
+#include <linux/ckrm_mem_inline.h>
 
 static inline void
 add_page_to_active_list(struct zone *zone, struct page *page)
 {
        list_add(&page->lru, &zone->active_list);
        zone->nr_active++;
+       ckrm_mem_inc_active(page);
 }
 
 static inline void
@@ -11,6 +13,7 @@ add_page_to_inactive_list(struct zone *zone, struct page *page)
 {
        list_add(&page->lru, &zone->inactive_list);
        zone->nr_inactive++;
+       ckrm_mem_inc_inactive(page);
 }
 
 static inline void
@@ -18,6 +21,7 @@ del_page_from_active_list(struct zone *zone, struct page *page)
 {
        list_del(&page->lru);
        zone->nr_active--;
+       ckrm_mem_dec_active(page);
 }
 
 static inline void
@@ -25,6 +29,7 @@ del_page_from_inactive_list(struct zone *zone, struct page *page)
 {
        list_del(&page->lru);
        zone->nr_inactive--;
+       ckrm_mem_dec_inactive(page);
 }
 
 static inline void
@@ -34,7 +39,9 @@ del_page_from_lru(struct zone *zone, struct page *page)
        if (PageActive(page)) {
                ClearPageActive(page);
                zone->nr_active--;
+               ckrm_mem_dec_active(page);
        } else {
                zone->nr_inactive--;
+               ckrm_mem_dec_inactive(page);
        }
 }
index 8a23709..e2f19aa 100644 (file)
  *   permitted by MAX_ORDER, so we allocate with the bootmem allocator, and are
  *   limited to this size
  */
-#if MAX_ORDER > 14
-#define MAX_SYS_HASH_TABLE_ORDER MAX_ORDER
-#else
-#define MAX_SYS_HASH_TABLE_ORDER 14
-#endif
+#define MAX_SYS_HASH_TABLE_ORDER 7
 
 struct free_area {
        struct list_head        free_list;
index fbf2dfc..9fa25f6 100644 (file)
@@ -291,6 +291,9 @@ struct module
 
        /* Am I GPL-compatible */
        int license_gplok;
+       
+       /* Am I gpg signed */
+       int gpgsig_ok;
 
 #ifdef CONFIG_MODULE_UNLOAD
        /* Reference counts */
@@ -551,29 +554,8 @@ struct obsolete_modparm {
 struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \
 { __stringify(var), type };
 
-static inline void __deprecated MOD_INC_USE_COUNT(struct module *module)
-{
-       __unsafe(module);
-
-#if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE)
-       local_inc(&module->ref[get_cpu()].count);
-       put_cpu();
-#else
-       (void)try_module_get(module);
-#endif
-}
-
-static inline void __deprecated MOD_DEC_USE_COUNT(struct module *module)
-{
-       module_put(module);
-}
-
-#define MOD_INC_USE_COUNT      MOD_INC_USE_COUNT(THIS_MODULE)
-#define MOD_DEC_USE_COUNT      MOD_DEC_USE_COUNT(THIS_MODULE)
 #else
 #define MODULE_PARM(var,type)
-#define MOD_INC_USE_COUNT      do { } while (0)
-#define MOD_DEC_USE_COUNT      do { } while (0)
 #endif
 
 #define __MODULE_STRING(x) __stringify(x)
index 42e2c94..c69739b 100644 (file)
@@ -17,6 +17,9 @@
 #define MNT_NOSUID     1
 #define MNT_NODEV      2
 #define MNT_NOEXEC     4
+#define MNT_RDONLY     8
+#define MNT_NOATIME    16
+#define MNT_NODIRATIME 32
 
 struct vfsmount
 {
@@ -36,6 +39,10 @@ struct vfsmount
        struct namespace *mnt_namespace; /* containing namespace */
 };
 
+#define        MNT_IS_RDONLY(m)        ((m) && ((m)->mnt_flags & MNT_RDONLY))
+#define        MNT_IS_NOATIME(m)       ((m) && ((m)->mnt_flags & MNT_NOATIME))
+#define        MNT_IS_NODIRATIME(m)    ((m) && ((m)->mnt_flags & MNT_NODIRATIME))
+
 static inline struct vfsmount *mntget(struct vfsmount *mnt)
 {
        if (mnt)
diff --git a/include/linux/mpp.h b/include/linux/mpp.h
deleted file mode 100644 (file)
index 2dd02ff..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _LINUX_MPP_H
-#define _LINUX_MPP_H
-
-/*
- * Definitions related to Massively Parallel Processing support.
- */
-
-/* All mpp implementations must supply these functions */
-
-extern void mpp_init(void);
-extern void mpp_hw_init(void);
-extern void mpp_procfs_init(void);
-
-extern int mpp_num_cells(void);
-extern int mpp_cid(void);
-extern int get_mppinfo(char *buffer);
-
-#endif
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h
deleted file mode 100644 (file)
index 05aa497..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * For boards with physically mapped flash and using 
- * drivers/mtd/maps/physmap.c mapping driver.
- *
- * $Id: physmap.h,v 1.3 2004/07/21 00:16:15 jwboyer Exp $
- *
- * Copyright (C) 2003 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-
-#ifndef __LINUX_MTD_PHYSMAP__
-
-#include <linux/config.h>
-
-#if defined(CONFIG_MTD_PHYSMAP) 
-
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-
-/*
- * The map_info for physmap.  Board can override size, buswidth, phys,
- * (*set_vpp)(), etc in their initial setup routine.
- */
-extern struct map_info physmap_map;
-
-/*
- * Board needs to specify the exact mapping during their setup time.
- */
-static inline void physmap_configure(unsigned long addr, unsigned long size, int bankwidth, void (*set_vpp)(struct map_info *, int) )
-{
-       physmap_map.phys = addr;
-       physmap_map.size = size;
-       physmap_map.bankwidth = bankwidth;
-       physmap_map.set_vpp = set_vpp;
-}
-
-#if defined(CONFIG_MTD_PARTITIONS)
-
-/*
- * Machines that wish to do flash partition may want to call this function in 
- * their setup routine.  
- *
- *     physmap_set_partitions(mypartitions, num_parts);
- *
- * Note that one can always override this hard-coded partition with 
- * command line partition (you need to enable CONFIG_MTD_CMDLINE_PARTS).
- */
-void physmap_set_partitions(struct mtd_partition *parts, int num_parts);
-
-#endif /* defined(CONFIG_MTD_PARTITIONS) */
-#endif /* defined(CONFIG_MTD) */
-
-#endif /* __LINUX_MTD_PHYSMAP__ */
-
index 1bbfa29..43a5c67 100644 (file)
@@ -10,7 +10,7 @@ struct open_intent {
        int     create_mode;
 };
 
-enum { MAX_NESTED_LINKS = 5 };
+enum { MAX_NESTED_LINKS = 8 };
 
 struct nameidata {
        struct dentry   *dentry;
@@ -45,6 +45,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
 #define LOOKUP_CONTINUE                 4
 #define LOOKUP_PARENT          16
 #define LOOKUP_NOALT           32
+#define LOOKUP_ATOMIC          64
+
 /*
  * Intent data
  */
index 9eca155..8728b30 100644 (file)
@@ -13,6 +13,7 @@ struct namespace {
 };
 
 extern void umount_tree(struct vfsmount *);
+extern void umount_unused(struct vfsmount *, struct fs_struct *);
 extern int copy_namespace(int, struct task_struct *);
 extern void __put_namespace(struct namespace *namespace);
 
index cec1482..22daf78 100644 (file)
@@ -60,6 +60,8 @@ typedef enum {
 #define SOCK_ASYNC_NOSPACE     0
 #define SOCK_ASYNC_WAITDATA    1
 #define SOCK_NOSPACE           2
+#define SOCK_PASS_CRED         16
+#define SOCK_USER_SOCKET       17
 
 /**
  *  struct socket - general BSD socket
@@ -82,7 +84,6 @@ struct socket {
        struct sock             *sk;
        wait_queue_head_t       wait;
        short                   type;
-       unsigned char           passcred;
 };
 
 struct vm_area_struct;
diff --git a/include/linux/netbeui.h b/include/linux/netbeui.h
deleted file mode 100644 (file)
index 2fb2f71..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _LINUX_NETBEUI_H
-#define _LINUX_NETBEUI_H
-
-#include <linux/if.h>
-
-#define NB_NAME_LEN    20      /* Set this properly from the full docs when
-                                  I get them */
-                                  
-struct sockaddr_netbeui
-{
-       sa_family       snb_family;
-       char            snb_name[NB_NAME_LEN];
-       char            snb_devhint[IFNAMSIZ];
-};
-
-#endif
index 5edb93f..d35a75b 100644 (file)
@@ -462,7 +462,7 @@ struct net_device
                                                     unsigned char *haddr);
        int                     (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
        int                     (*accept_fastpath)(struct net_device *, struct dst_entry*);
-#ifdef CONFIG_NETPOLL_RX
+#ifdef CONFIG_NETPOLL
        int                     netpoll_rx;
 #endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -684,6 +684,12 @@ extern void                dev_init(void);
 
 extern int             netdev_nit;
 
+/* netconsole rx hook registration */
+extern int netdump_register_hooks(int (*)(struct sk_buff *),
+                                 int (*)(struct sk_buff *),
+                                 void (*)(struct pt_regs *));
+extern void netdump_unregister_hooks(void);
+
 /* Post buffer to the network code from _non interrupt_ context.
  * see net/core/dev.c for netif_rx description.
  */
diff --git a/include/linux/netfilter_ddp.h b/include/linux/netfilter_ddp.h
deleted file mode 100644 (file)
index 7c63c94..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __LINUX_DDP_NETFILTER_H
-#define __LINUX_DDP_NETFILTER_H
-
-/* DDP-specific defines for netfilter.  Complete me sometime.
- * (C)1998 Rusty Russell -- This code is GPL.
- */
-
-#include <linux/netfilter.h>
-
-/* Appletalk hooks */
-#define NF_DDP_INPUT   0
-#define NF_DDP_FORWARD 1
-#define NF_DDP_OUTPUT  2
-#endif /*__LINUX_DDP_NETFILTER_H*/
index 1974f16..a325de5 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
 #include <linux/bitops.h>
 #include <linux/compiler.h>
+#include <linux/vserver/context.h>
 #include <asm/atomic.h>
 
 enum ip_conntrack_info
@@ -207,6 +208,9 @@ struct ip_conntrack
        } nat;
 #endif /* CONFIG_IP_NF_NAT_NEEDED */
 
+       /* VServer context id */
+       xid_t xid[IP_CT_DIR_MAX];
+
 };
 
 /* get master conntrack via master expectation */
diff --git a/include/linux/netfilter_ipx.h b/include/linux/netfilter_ipx.h
deleted file mode 100644 (file)
index ebd93bf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __LINUX_IPX_NETFILTER_H
-#define __LINUX_IPX_NETFILTER_H
-
-/* IPX-specific defines for netfilter.  Complete me sometime.
- * (C)1998 Rusty Russell -- This code is GPL.
- */
-
-#include <linux/netfilter.h>
-
-/* IPX Hooks */
-#define NF_IPX_INPUT   0
-#define NF_IPX_FORWARD 1
-#define NF_IPX_OUTPUT  2
-#endif /*__LINUX_IPX_NETFILTER_H*/
diff --git a/include/linux/netfilter_x25.h b/include/linux/netfilter_x25.h
deleted file mode 100644 (file)
index 88e2354..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __LINUX_X25_NETFILTER_H
-#define __LINUX_X25_NETFILTER_H
-
-/* X25-specific defines for netfilter.  Complete me sometime.
- * (C)1998 Rusty Russell -- This code is GPL.
- */
-
-#include <linux/netfilter.h>
-
-/* Hooks */
-#define NF_X25_INPUT   0
-#define NF_X25_FORWARD 1
-#define NF_X25_OUTPUT  2
-
-#endif /*__LINUX_X25_NETFILTER_H*/
index a9e4817..806fa16 100644 (file)
@@ -16,7 +16,8 @@ struct netpoll;
 struct netpoll {
        struct net_device *dev;
        char dev_name[16], *name;
-       void (*rx_hook)(struct netpoll *, int, char *, int);
+       void (*rx_hook)(struct netpoll *, short, char *, int);
+       void (*dump_func)(struct pt_regs *);
        u32 local_ip, remote_ip;
        u16 local_port, remote_port;
        unsigned char local_mac[6], remote_mac[6];
@@ -32,6 +33,7 @@ int netpoll_trap(void);
 void netpoll_set_trap(int trap);
 void netpoll_cleanup(struct netpoll *np);
 int netpoll_rx(struct sk_buff *skb);
+void netpoll_reset_locks(struct netpoll *np);
 
 
 #endif
index 0071428..254fc07 100644 (file)
@@ -60,6 +60,7 @@ struct nfs_mount_data {
 #define NFS_MOUNT_BROKEN_SUID  0x0400  /* 4 */
 #define NFS_MOUNT_STRICTLOCK   0x1000  /* reserved for NFSv4 */
 #define NFS_MOUNT_SECFLAVOUR   0x2000  /* 5 */
+#define        NFS_MOUNT_TAGXID        0x8000  /* tagxid */
 #define NFS_MOUNT_FLAGMASK     0xFFFF
 
 #endif
index c6f5063..c70f46a 100644 (file)
@@ -77,6 +77,7 @@
 #define PG_compound            19      /* Part of a compound page */
 
 #define PG_anon                        20      /* Anonymous: anon_vma in mapping */
+#define PG_ckrm_account        21      /* This page is accounted by CKRM */
 
 
 /*
index 4da205f..12f8116 100644 (file)
@@ -156,6 +156,7 @@ extern void FASTCALL(unlock_page(struct page *page));
 
 static inline void lock_page(struct page *page)
 {
+       might_sleep();
        if (TestSetPageLocked(page))
                __lock_page(page);
 }
index 2ce5f95..8935251 100644 (file)
@@ -773,9 +773,9 @@ void pci_set_master(struct pci_dev *dev);
 #define HAVE_PCI_SET_MWI
 int pci_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
-int pci_set_dma_mask(struct pci_dev *dev, u64 mask);
+int __must_check pci_set_dma_mask(struct pci_dev *dev, u64 mask);
 int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask);
-int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
+int __must_check pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
 int pci_assign_resource(struct pci_dev *dev, int i);
 
 /* Power management related routines */
index 9b009b6..7efc05e 100644 (file)
@@ -30,6 +30,7 @@ extern int abi_fake_utsname;
  */
 enum {
        MMAP_PAGE_ZERO =        0x0100000,
+       ADDR_COMPAT_LAYOUT =    0x0200000,
        READ_IMPLIES_EXEC =     0x0400000,
        ADDR_LIMIT_32BIT =      0x0800000,
        SHORT_INODE =           0x1000000,
index 2d439a8..3c32260 100644 (file)
@@ -55,6 +55,7 @@ struct proc_dir_entry {
        nlink_t nlink;
        uid_t uid;
        gid_t gid;
+       int vx_flags;
        unsigned long size;
        struct inode_operations * proc_iops;
        struct file_operations * proc_fops;
@@ -237,9 +238,11 @@ extern struct kcore_list *kclist_del(void *);
 struct proc_inode {
        struct task_struct *task;
        int type;
+       int vx_flags;
        union {
                int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
                int (*proc_read)(struct task_struct *task, char *page);
+               int (*proc_vid_read)(int vid, char *page);
        } op;
        struct proc_dir_entry *pde;
        struct inode vfs_inode;
index 53132cd..7a6fdcf 100644 (file)
@@ -74,6 +74,8 @@
 
 #include <linux/compiler.h>            /* For unlikely.  */
 #include <linux/sched.h>               /* For struct task_struct.  */
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
 
 extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
 extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
index 9ccb52f..fb7473c 100644 (file)
@@ -73,6 +73,9 @@ extern __u32 secure_ipv6_id(__u32 *daddr);
 extern struct file_operations random_fops, urandom_fops;
 #endif
 
+unsigned int get_random_int(void);
+unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
+
 #endif /* __KERNEL___ */
 
 #endif /* _LINUX_RANDOM_H */
diff --git a/include/linux/rbce.h b/include/linux/rbce.h
new file mode 100644 (file)
index 0000000..91afba9
--- /dev/null
@@ -0,0 +1,127 @@
+/* Rule-based Classification Engine (RBCE) module
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ * 
+ * Module for loading of classification policies and providing
+ * a user API for Class-based Kernel Resource Management (CKRM)
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 
+ *
+ */
+
+/* Changes
+ *
+ * 25 Mar 2004
+ *        Integrate RBCE and CRBE into a single module
+ * 
+ */
+
+#ifndef RBCE_H
+#define RBCE_H
+
+// data types defined in main rbcemod.c 
+struct rbce_private_data;
+struct rbce_class;
+struct ckrm_core_class;
+
+#ifndef RBCE_EXTENSION
+
+/****************************************************************************
+ *
+ *   RBCE STANDALONE VERSION, NO CHOICE FOR DATA COLLECTION
+ *
+ ****************************************************************************/
+
+#ifdef RBCE_SHOW_INCL
+#warning " ... RBCE .."
+#endif
+
+#define RBCE_MOD_DESCR "Rule Based Classification Engine Module for CKRM"
+#define RBCE_MOD_NAME  "rbce"
+
+/* extension to private data: NONE */
+struct rbce_ext_private_data {
+       /* empty data */
+};
+static inline void init_ext_private_data(struct rbce_private_data *dst)
+{
+}
+
+/* sending notification to user: NONE */
+
+static void notify_class_action(struct rbce_class *cls, int action)
+{
+}
+static inline void send_fork_notification(struct task_struct *tsk,
+                                         struct ckrm_core_class *cls)
+{
+}
+static inline void send_exit_notification(struct task_struct *tsk)
+{
+}
+static inline void send_manual_notification(struct task_struct *tsk)
+{
+}
+
+/* extension initialization and destruction at module init and exit */
+static inline int init_rbce_ext_pre(void)
+{
+       return 0;
+}
+static inline int init_rbce_ext_post(void)
+{
+       return 0;
+}
+static inline void exit_rbce_ext(void)
+{
+}
+
+#else
+
+/***************************************************************************
+ *
+ *   RBCE with User Level Notification
+ *
+ ***************************************************************************/
+
+#ifdef RBCE_SHOW_INCL
+#warning " ... CRBCE .."
+#ifdef RBCE_DO_SAMPLE
+#warning " ... CRBCE doing sampling ..."
+#endif
+#ifdef RBCE_DO_DELAY
+#warning " ... CRBCE doing delay ..."
+#endif
+#endif
+
+#define RBCE_MOD_DESCR         "Rule Based Classification Engine Module" \
+                       "with Data Sampling/Delivery for CKRM"
+#define RBCE_MOD_NAME  "crbce"
+
+#include <linux/crbce.h>
+
+struct rbce_ext_private_data {
+       struct task_sample_info sample;
+};
+
+static void notify_class_action(struct rbce_class *cls, int action);
+#if 0
+static void send_fork_notification(struct task_struct *tsk,
+                                  struct ckrm_core_class *cls);
+static void send_exit_notification(struct task_struct *tsk);
+static void send_manual_notification(struct task_struct *tsk);
+#endif
+
+#endif
+
+#endif                         // RBCE_H
diff --git a/include/linux/rcfs.h b/include/linux/rcfs.h
new file mode 100644 (file)
index 0000000..13aa5a7
--- /dev/null
@@ -0,0 +1,96 @@
+#ifndef _LINUX_RCFS_H
+#define _LINUX_RCFS_H
+
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_rc.h>
+#include <linux/ckrm_ce.h>
+
+/* The following declarations cannot be included in any of ckrm*.h files 
+   without jumping hoops. Remove later when rearrangements done */
+
+// Hubertus .. taken out 
+//extern ckrm_res_callback_t ckrm_res_ctlrs[CKRM_MAX_RES_CTLRS];
+
+#define RCFS_MAGIC     0x4feedbac
+#define RCFS_MAGF_NAMELEN 20
+extern int RCFS_IS_MAGIC;
+
+#define rcfs_is_magic(dentry)  ((dentry)->d_fsdata == &RCFS_IS_MAGIC)
+
+typedef struct rcfs_inode_info {
+       ckrm_core_class_t *core;
+       char *name;
+       struct inode vfs_inode;
+} rcfs_inode_info_t;
+
+#define RCFS_DEFAULT_DIR_MODE  (S_IFDIR | S_IRUGO | S_IXUGO)
+#define RCFS_DEFAULT_FILE_MODE (S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP |S_IROTH)
+
+struct rcfs_magf {
+       char name[RCFS_MAGF_NAMELEN];
+       int mode;
+       struct inode_operations *i_op;
+       struct file_operations *i_fop;
+};
+
+struct rcfs_mfdesc {
+       struct rcfs_magf *rootmf;       // Root directory and its magic files
+       int rootmflen;                  // length of above array
+       // Can have a different magf describing magic files 
+       // for non-root entries too
+};
+
+extern struct rcfs_mfdesc *genmfdesc[];
+
+inline struct rcfs_inode_info *RCFS_I(struct inode *inode);
+
+int rcfs_empty(struct dentry *);
+struct inode *rcfs_get_inode(struct super_block *, int, dev_t);
+int rcfs_mknod(struct inode *, struct dentry *, int, dev_t);
+int _rcfs_mknod(struct inode *, struct dentry *, int, dev_t);
+int rcfs_mkdir(struct inode *, struct dentry *, int);
+ckrm_core_class_t *rcfs_make_core(struct dentry *, struct ckrm_core_class *);
+struct dentry *rcfs_set_magf_byname(char *, void *);
+
+struct dentry *rcfs_create_internal(struct dentry *, struct rcfs_magf *, int);
+int rcfs_delete_internal(struct dentry *);
+int rcfs_create_magic(struct dentry *, struct rcfs_magf *, int);
+int rcfs_clear_magic(struct dentry *);
+
+extern struct super_operations rcfs_super_ops;
+extern struct address_space_operations rcfs_aops;
+
+extern struct inode_operations rcfs_dir_inode_operations;
+extern struct inode_operations rcfs_rootdir_inode_operations;
+extern struct inode_operations rcfs_file_inode_operations;
+
+extern struct file_operations target_fileops;
+extern struct file_operations shares_fileops;
+extern struct file_operations stats_fileops;
+extern struct file_operations config_fileops;
+extern struct file_operations members_fileops;
+extern struct file_operations reclassify_fileops;
+extern struct file_operations rcfs_file_operations;
+
+// Callbacks into rcfs from ckrm 
+
+typedef struct rcfs_functions {
+       int (*mkroot) (struct rcfs_magf *, int, struct dentry **);
+       int (*rmroot) (struct dentry *);
+       int (*register_classtype) (ckrm_classtype_t *);
+       int (*deregister_classtype) (ckrm_classtype_t *);
+} rcfs_fn_t;
+
+int rcfs_register_classtype(ckrm_classtype_t *);
+int rcfs_deregister_classtype(ckrm_classtype_t *);
+int rcfs_mkroot(struct rcfs_magf *, int, struct dentry **);
+int rcfs_rmroot(struct dentry *);
+
+#define RCFS_ROOT "/rcfs"      // Hubertus .. we should use the mount point 
+                               // instead of hardcoded
+extern struct dentry *rcfs_rootde;
+extern rbce_eng_callback_t rcfs_eng_callbacks;
+
+#endif                         /* _LINUX_RCFS_H */
index 1784fb0..2a206e8 100644 (file)
@@ -888,6 +888,13 @@ struct stat_data_v1
 #define REISERFS_COMPR_FL     EXT2_COMPR_FL
 #define REISERFS_NOTAIL_FL    EXT2_NOTAIL_FL
 
+/* unfortunately reiserfs sdattr is only 16 bit */
+#define REISERFS_BARRIER_FL   (EXT2_BARRIER_FL >> 16)
+#define REISERFS_IUNLINK_FL   (EXT2_IUNLINK_FL >> 16)
+
+#define        REISERFS_FL_USER_VISIBLE        0x80FF
+#define        REISERFS_FL_USER_MODIFYABLE     0x80FF
+
 /* persistent flags that file inherits from the parent directory */
 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |        \
                                REISERFS_SYNC_FL |      \
index 3870877..8cc1494 100644 (file)
@@ -444,6 +444,7 @@ enum reiserfs_mount_options {
     REISERFS_XATTRS,
     REISERFS_XATTRS_USER,
     REISERFS_POSIXACL,
+    REISERFS_TAGXID,
 
     REISERFS_TEST1,
     REISERFS_TEST2,
diff --git a/include/linux/relayfs_fs.h b/include/linux/relayfs_fs.h
new file mode 100644 (file)
index 0000000..2c52874
--- /dev/null
@@ -0,0 +1,686 @@
+/*
+ * linux/include/linux/relayfs_fs.h
+ *
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
+ *
+ * RelayFS definitions and declarations
+ *
+ * Please see Documentation/filesystems/relayfs.txt for more info.
+ */
+
+#ifndef _LINUX_RELAYFS_FS_H
+#define _LINUX_RELAYFS_FS_H
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+#include <linux/list.h>
+#include <linux/fs.h>
+
+/*
+ * Tracks changes to rchan struct
+ */
+#define RELAYFS_CHANNEL_VERSION                1
+
+/*
+ * Maximum number of simultaneously open channels
+ */
+#define RELAY_MAX_CHANNELS             256
+
+/*
+ * Relay properties
+ */
+#define RELAY_MIN_BUFS                 2
+#define RELAY_MIN_BUFSIZE              4096
+#define RELAY_MAX_BUFS                 256
+#define RELAY_MAX_BUF_SIZE             0x1000000
+#define RELAY_MAX_TOTAL_BUF_SIZE       0x8000000
+
+/*
+ * Lockless scheme utility macros
+ */
+#define RELAY_MAX_BUFNO(bufno_bits) (1UL << (bufno_bits))
+#define RELAY_BUF_SIZE(offset_bits) (1UL << (offset_bits))
+#define RELAY_BUF_OFFSET_MASK(offset_bits) (RELAY_BUF_SIZE(offset_bits) - 1)
+#define RELAY_BUFNO_GET(index, offset_bits) ((index) >> (offset_bits))
+#define RELAY_BUF_OFFSET_GET(index, mask) ((index) & (mask))
+#define RELAY_BUF_OFFSET_CLEAR(index, mask) ((index) & ~(mask))
+
+/*
+ * Flags returned by relay_reserve()
+ */
+#define RELAY_BUFFER_SWITCH_NONE       0x0
+#define RELAY_WRITE_DISCARD_NONE       0x0
+#define RELAY_BUFFER_SWITCH            0x1
+#define RELAY_WRITE_DISCARD            0x2
+#define RELAY_WRITE_TOO_LONG           0x4
+
+/*
+ * Relay attribute flags
+ */
+#define RELAY_DELIVERY_BULK            0x1
+#define RELAY_DELIVERY_PACKET          0x2
+#define RELAY_SCHEME_LOCKLESS          0x4
+#define RELAY_SCHEME_LOCKING           0x8
+#define RELAY_SCHEME_ANY               0xC
+#define RELAY_TIMESTAMP_TSC            0x10
+#define RELAY_TIMESTAMP_GETTIMEOFDAY   0x20
+#define RELAY_TIMESTAMP_ANY            0x30
+#define RELAY_USAGE_SMP                        0x40
+#define RELAY_USAGE_GLOBAL             0x80
+#define RELAY_MODE_CONTINUOUS          0x100
+#define RELAY_MODE_NO_OVERWRITE                0x200
+
+/*
+ * Flags for needs_resize() callback
+ */
+#define RELAY_RESIZE_NONE      0x0
+#define RELAY_RESIZE_EXPAND    0x1
+#define RELAY_RESIZE_SHRINK    0x2
+#define RELAY_RESIZE_REPLACE   0x4
+#define RELAY_RESIZE_REPLACED  0x8
+
+/*
+ * Values for fileop_notify() callback
+ */
+enum relay_fileop
+{
+       RELAY_FILE_OPEN,
+       RELAY_FILE_CLOSE,
+       RELAY_FILE_MAP,
+       RELAY_FILE_UNMAP
+};
+
+/*
+ * Data structure returned by relay_info()
+ */
+struct rchan_info
+{
+       u32 flags;              /* relay attribute flags for channel */
+       u32 buf_size;           /* channel's sub-buffer size */
+       char *buf_addr;         /* address of channel start */
+       u32 alloc_size;         /* total buffer size actually allocated */
+       u32 n_bufs;             /* number of sub-buffers in channel */
+       u32 cur_idx;            /* current write index into channel */
+       u32 bufs_produced;      /* current count of sub-buffers produced */
+       u32 bufs_consumed;      /* current count of sub-buffers consumed */
+       u32 buf_id;             /* buf_id of current sub-buffer */
+       int buffer_complete[RELAY_MAX_BUFS];    /* boolean per sub-buffer */
+       int unused_bytes[RELAY_MAX_BUFS];       /* count per sub-buffer */
+};
+
+/*
+ * Relay channel client callbacks
+ */
+struct rchan_callbacks
+{
+       /*
+        * buffer_start - called at the beginning of a new sub-buffer
+        * @rchan_id: the channel id
+        * @current_write_pos: position in sub-buffer client should write to
+        * @buffer_id: the id of the new sub-buffer
+        * @start_time: the timestamp associated with the start of sub-buffer
+        * @start_tsc: the TSC associated with the timestamp, if using_tsc
+        * @using_tsc: boolean, indicates whether start_tsc is valid
+        *
+        * Return value should be the number of bytes written by the client.
+        *
+        * See Documentation/filesystems/relayfs.txt for details.
+        */
+       int (*buffer_start) (int rchan_id,
+                            char *current_write_pos,
+                            u32 buffer_id,
+                            struct timeval start_time,
+                            u32 start_tsc,
+                            int using_tsc);
+
+       /*
+        * buffer_end - called at the end of a sub-buffer
+        * @rchan_id: the channel id
+        * @current_write_pos: position in sub-buffer of end of data
+        * @end_of_buffer: the position of the end of the sub-buffer
+        * @end_time: the timestamp associated with the end of the sub-buffer
+        * @end_tsc: the TSC associated with the end_time, if using_tsc
+        * @using_tsc: boolean, indicates whether end_tsc is valid
+        *
+        * Return value should be the number of bytes written by the client.
+        *
+        * See Documentation/filesystems/relayfs.txt for details.
+        */
+       int (*buffer_end) (int rchan_id,
+                          char *current_write_pos,
+                          char *end_of_buffer,
+                          struct timeval end_time,
+                          u32 end_tsc,
+                          int using_tsc);
+
+       /*
+        * deliver - called when data is ready for the client
+        * @rchan_id: the channel id
+        * @from: the start of the delivered data
+        * @len: the length of the delivered data
+        *
+        * See Documentation/filesystems/relayfs.txt for details.
+        */
+       void (*deliver) (int rchan_id, char *from, u32 len);
+
+       /*
+        * user_deliver - called when data has been written from userspace
+        * @rchan_id: the channel id
+        * @from: the start of the delivered data
+        * @len: the length of the delivered data
+        *
+        * See Documentation/filesystems/relayfs.txt for details.
+        */
+       void (*user_deliver) (int rchan_id, char *from, u32 len);
+
+       /*
+        * needs_resize - called when a resizing event occurs
+        * @rchan_id: the channel id
+        * @resize_type: the type of resizing event
+        * @suggested_buf_size: the suggested new sub-buffer size
+        * @suggested_buf_size: the suggested new number of sub-buffers
+        *
+        * See Documentation/filesystems/relayfs.txt for details.
+        */
+       void (*needs_resize)(int rchan_id,
+                            int resize_type,
+                            u32 suggested_buf_size,
+                            u32 suggested_n_bufs);
+
+       /*
+        * fileop_notify - called on open/close/mmap/munmap of a relayfs file
+        * @rchan_id: the channel id
+        * @filp: relayfs file pointer
+        * @fileop: which file operation is in progress
+        *
+        * The return value can direct the outcome of the operation.
+        *
+        * See Documentation/filesystems/relayfs.txt for details.
+        */
+        int (*fileop_notify)(int rchan_id,
+                            struct file *filp,
+                            enum relay_fileop fileop);
+
+       /*
+        * ioctl - called in ioctl context from userspace
+        * @rchan_id: the channel id
+        * @cmd: ioctl cmd
+        * @arg: ioctl cmd arg
+        *
+        * The return value is returned as the value from the ioctl call.
+        *
+        * See Documentation/filesystems/relayfs.txt for details.
+        */
+       int (*ioctl) (int rchan_id, unsigned int cmd, unsigned long arg);
+};
+
+/*
+ * Lockless scheme-specific data
+ */
+struct lockless_rchan
+{
+       u8 bufno_bits;          /* # bits used for sub-buffer id */
+       u8 offset_bits;         /* # bits used for offset within sub-buffer */
+       u32 index;              /* current index = sub-buffer id and offset */
+       u32 offset_mask;        /* used to obtain offset portion of index */
+       u32 index_mask;         /* used to mask off unused bits index */
+       atomic_t fill_count[RELAY_MAX_BUFS];    /* fill count per sub-buffer */
+};
+
+/*
+ * Locking scheme-specific data
+ */
+struct locking_rchan
+{
+       char *write_buf;                /* start of write sub-buffer */
+       char *write_buf_end;            /* end of write sub-buffer */
+       char *current_write_pos;        /* current write pointer */
+       char *write_limit;              /* takes reserves into account */
+       char *in_progress_event_pos;    /* used for interrupted writes */
+       u16 in_progress_event_size;     /* used for interrupted writes */
+       char *interrupted_pos;          /* used for interrupted writes */
+       u16 interrupting_size;          /* used for interrupted writes */
+       spinlock_t lock;                /* channel lock for locking scheme */
+};
+
+struct relay_ops;
+
+/*
+ * Offset resizing data structure
+ */
+struct resize_offset
+{
+       u32 ge;
+       u32 le;
+       int delta;
+};
+
+/*
+ * Relay channel data structure
+ */
+struct rchan
+{
+       u32 version;                    /* the version of this struct */
+       char *buf;                      /* the channel buffer */
+       union
+       {
+               struct lockless_rchan lockless;
+               struct locking_rchan locking;
+       } scheme;                       /* scheme-specific channel data */
+
+       int id;                         /* the channel id */
+       struct rchan_callbacks *callbacks;      /* client callbacks */
+       u32 flags;                      /* relay channel attributes */
+       u32 buf_id;                     /* current sub-buffer id */
+       u32 buf_idx;                    /* current sub-buffer index */
+
+       atomic_t mapped;                /* map count */
+
+       atomic_t suspended;             /* channel suspended i.e full? */
+       int half_switch;                /* used internally for suspend */
+
+       struct timeval  buf_start_time; /* current sub-buffer start time */
+       u32 buf_start_tsc;              /* current sub-buffer start TSC */
+       
+       u32 buf_size;                   /* sub-buffer size */
+       u32 alloc_size;                 /* total buffer size allocated */
+       u32 n_bufs;                     /* number of sub-buffers */
+
+       u32 bufs_produced;              /* count of sub-buffers produced */
+       u32 bufs_consumed;              /* count of sub-buffers consumed */
+       u32 bytes_consumed;             /* bytes consumed in cur sub-buffer */
+
+       int initialized;                /* first buffer initialized? */
+       int finalized;                  /* channel finalized? */
+
+       u32 start_reserve;              /* reserve at start of sub-buffers */
+       u32 end_reserve;                /* reserve at end of sub-buffers */
+       u32 rchan_start_reserve;        /* additional reserve sub-buffer 0 */
+       
+       struct dentry *dentry;          /* channel file dentry */
+
+       wait_queue_head_t read_wait;    /* VFS read wait queue */
+       wait_queue_head_t write_wait;   /* VFS write wait queue */
+       struct work_struct wake_readers; /* reader wake-up work struct */
+       struct work_struct wake_writers; /* reader wake-up work struct */
+       atomic_t refcount;              /* channel refcount */
+
+       struct relay_ops *relay_ops;    /* scheme-specific channel ops */
+
+       int unused_bytes[RELAY_MAX_BUFS]; /* unused count per sub-buffer */
+
+       struct semaphore resize_sem;    /* serializes alloc/repace */
+       struct work_struct work;        /* resize allocation work struct */
+
+       struct list_head open_readers;  /* open readers for this channel */
+       rwlock_t open_readers_lock;     /* protection for open_readers list */
+
+       char *init_buf;                 /* init channel buffer, if non-NULL */
+       
+       u32 resize_min;                 /* minimum resized total buffer size */
+       u32 resize_max;                 /* maximum resized total buffer size */
+       char *resize_buf;               /* for autosize alloc/free */
+       u32 resize_buf_size;            /* resized sub-buffer size */
+       u32 resize_n_bufs;              /* resized number of sub-buffers */
+       u32 resize_alloc_size;          /* resized actual total size */
+       int resizing;                   /* is resizing in progress? */
+       int resize_err;                 /* resizing err code */
+       int resize_failures;            /* number of resize failures */
+       int replace_buffer;             /* is the alloced buffer ready?  */
+       struct resize_offset resize_offset; /* offset change */
+       struct timer_list shrink_timer; /* timer used for shrinking */
+       int resize_order;               /* size of last resize */
+       u32 expand_buf_id;              /* subbuf id expand will occur at */
+
+       struct page **buf_page_array;   /* array of current buffer pages */
+       int buf_page_count;             /* number of current buffer pages */
+       struct page **expand_page_array;/* new pages to be inserted */
+       int expand_page_count;          /* number of new pages */
+       struct page **shrink_page_array;/* old pages to be freed */
+       int shrink_page_count;          /* number of old pages */
+       struct page **resize_page_array;/* will become current pages */
+       int resize_page_count;          /* number of resize pages */
+       struct page **old_buf_page_array; /* hold for freeing */
+} ____cacheline_aligned;
+
+/*
+ * Relay channel reader struct
+ */
+struct rchan_reader
+{
+       struct list_head list;          /* for list inclusion */
+       struct rchan *rchan;            /* the channel we're reading from */
+       int auto_consume;               /* does this reader auto-consume? */
+       u32 bufs_consumed;              /* buffers this reader has consumed */
+       u32 bytes_consumed;             /* bytes consumed in cur sub-buffer */
+       int offset_changed;             /* have channel offsets changed? */
+       int vfs_reader;                 /* are we a VFS reader? */
+       int map_reader;                 /* are we an mmap reader? */
+
+       union
+       {
+               struct file *file;
+               u32 f_pos;
+       } pos;                          /* current read offset */
+};
+
+/*
+ * These help make union member access less tedious
+ */
+#define channel_buffer(rchan) ((rchan)->buf)
+#define idx(rchan) ((rchan)->scheme.lockless.index)
+#define bufno_bits(rchan) ((rchan)->scheme.lockless.bufno_bits)
+#define offset_bits(rchan) ((rchan)->scheme.lockless.offset_bits)
+#define offset_mask(rchan) ((rchan)->scheme.lockless.offset_mask)
+#define idx_mask(rchan) ((rchan)->scheme.lockless.index_mask)
+#define bulk_delivery(rchan) (((rchan)->flags & RELAY_DELIVERY_BULK) ? 1 : 0)
+#define packet_delivery(rchan) (((rchan)->flags & RELAY_DELIVERY_PACKET) ? 1 : 0)
+#define using_lockless(rchan) (((rchan)->flags & RELAY_SCHEME_LOCKLESS) ? 1 : 0)
+#define using_locking(rchan) (((rchan)->flags & RELAY_SCHEME_LOCKING) ? 1 : 0)
+#define using_tsc(rchan) (((rchan)->flags & RELAY_TIMESTAMP_TSC) ? 1 : 0)
+#define using_gettimeofday(rchan) (((rchan)->flags & RELAY_TIMESTAMP_GETTIMEOFDAY) ? 1 : 0)
+#define usage_smp(rchan) (((rchan)->flags & RELAY_USAGE_SMP) ? 1 : 0)
+#define usage_global(rchan) (((rchan)->flags & RELAY_USAGE_GLOBAL) ? 1 : 0)
+#define mode_continuous(rchan) (((rchan)->flags & RELAY_MODE_CONTINUOUS) ? 1 : 0)
+#define fill_count(rchan, i) ((rchan)->scheme.lockless.fill_count[(i)])
+#define write_buf(rchan) ((rchan)->scheme.locking.write_buf)
+#define read_buf(rchan) ((rchan)->scheme.locking.read_buf)
+#define write_buf_end(rchan) ((rchan)->scheme.locking.write_buf_end)
+#define read_buf_end(rchan) ((rchan)->scheme.locking.read_buf_end)
+#define cur_write_pos(rchan) ((rchan)->scheme.locking.current_write_pos)
+#define read_limit(rchan) ((rchan)->scheme.locking.read_limit)
+#define write_limit(rchan) ((rchan)->scheme.locking.write_limit)
+#define in_progress_event_pos(rchan) ((rchan)->scheme.locking.in_progress_event_pos)
+#define in_progress_event_size(rchan) ((rchan)->scheme.locking.in_progress_event_size)
+#define interrupted_pos(rchan) ((rchan)->scheme.locking.interrupted_pos)
+#define interrupting_size(rchan) ((rchan)->scheme.locking.interrupting_size)
+#define channel_lock(rchan) ((rchan)->scheme.locking.lock)
+
+
+/**
+ *     calc_time_delta - utility function for time delta calculation
+ *     @now: current time
+ *     @start: start time
+ *
+ *     Returns the time delta produced by subtracting start time from now.
+ */
+static inline u32
+calc_time_delta(struct timeval *now, 
+               struct timeval *start)
+{
+       return (now->tv_sec - start->tv_sec) * 1000000
+               + (now->tv_usec - start->tv_usec);
+}
+
+/**
+ *     recalc_time_delta - utility function for time delta recalculation
+ *     @now: current time
+ *     @new_delta: the new time delta calculated
+ *     @cpu: the associated CPU id
+ */
+static inline void 
+recalc_time_delta(struct timeval *now,
+                 u32 *new_delta,
+                 struct rchan *rchan)
+{
+       if (using_tsc(rchan) == 0)
+               *new_delta = calc_time_delta(now, &rchan->buf_start_time);
+}
+
+/**
+ *     have_cmpxchg - does this architecture have a cmpxchg?
+ *
+ *     Returns 1 if this architecture has a cmpxchg useable by 
+ *     the lockless scheme, 0 otherwise.
+ */
+static inline int 
+have_cmpxchg(void)
+{
+#if defined(__HAVE_ARCH_CMPXCHG)
+       return 1;
+#else
+       return 0;
+#endif
+}
+
+/**
+ *     relay_write_direct - write data directly into destination buffer
+ */
+#define relay_write_direct(DEST, SRC, SIZE) \
+do\
+{\
+   memcpy(DEST, SRC, SIZE);\
+   DEST += SIZE;\
+} while (0);
+
+/**
+ *     relay_lock_channel - lock the relay channel if applicable
+ *
+ *     This macro only affects the locking scheme.  If the locking scheme
+ *     is in use and the channel usage is SMP, does a local_irq_save.  If the 
+ *     locking sheme is in use and the channel usage is GLOBAL, uses 
+ *     spin_lock_irqsave.  FLAGS is initialized to 0 since we know that
+ *     it is being initialized prior to use and we avoid the compiler warning.
+ */
+#define relay_lock_channel(RCHAN, FLAGS) \
+do\
+{\
+   FLAGS = 0;\
+   if (using_locking(RCHAN)) {\
+      if (usage_smp(RCHAN)) {\
+         local_irq_save(FLAGS); \
+      } else {\
+         spin_lock_irqsave(&(RCHAN)->scheme.locking.lock, FLAGS); \
+      }\
+   }\
+} while (0);
+
+/**
+ *     relay_unlock_channel - unlock the relay channel if applicable
+ *
+ *     This macro only affects the locking scheme.  See relay_lock_channel.
+ */
+#define relay_unlock_channel(RCHAN, FLAGS) \
+do\
+{\
+   if (using_locking(RCHAN)) {\
+      if (usage_smp(RCHAN)) {\
+         local_irq_restore(FLAGS); \
+      } else {\
+         spin_unlock_irqrestore(&(RCHAN)->scheme.locking.lock, FLAGS); \
+      }\
+   }\
+} while (0);
+
+/*
+ * Define cmpxchg if we don't have it
+ */
+#ifndef __HAVE_ARCH_CMPXCHG
+#define cmpxchg(p,o,n) 0
+#endif
+
+/*
+ * High-level relayfs kernel API, fs/relayfs/relay.c
+ */
+extern int
+relay_open(const char *chanpath,
+          int bufsize,
+          int nbufs,
+          u32 flags,
+          struct rchan_callbacks *channel_callbacks,
+          u32 start_reserve,
+          u32 end_reserve,
+          u32 rchan_start_reserve,
+          u32 resize_min,
+          u32 resize_max,
+          int mode,
+          char *init_buf,
+          u32 init_buf_size);
+
+extern int
+relay_close(int rchan_id);
+
+extern int
+relay_write(int rchan_id,
+           const void *data_ptr, 
+           size_t count,
+           int td_offset,
+           void **wrote_pos);
+
+extern ssize_t
+relay_read(struct rchan_reader *reader,
+          char *buf,
+          size_t count,
+          int wait,
+          u32 *actual_read_offset);
+
+extern int
+relay_discard_init_buf(int rchan_id);
+
+extern struct rchan_reader *
+add_rchan_reader(int rchan_id, int autoconsume);
+
+extern int
+remove_rchan_reader(struct rchan_reader *reader);
+
+extern struct rchan_reader *
+add_map_reader(int rchan_id);
+
+extern int
+remove_map_reader(struct rchan_reader *reader);
+
+extern int 
+relay_info(int rchan_id, struct rchan_info *rchan_info);
+
+extern void 
+relay_buffers_consumed(struct rchan_reader *reader, u32 buffers_consumed);
+
+extern void
+relay_bytes_consumed(struct rchan_reader *reader, u32 bytes_consumed, u32 read_offset);
+
+extern ssize_t
+relay_bytes_avail(struct rchan_reader *reader);
+
+extern int
+relay_realloc_buffer(int rchan_id, u32 new_nbufs, int in_background);
+
+extern int
+relay_replace_buffer(int rchan_id);
+
+extern int
+rchan_empty(struct rchan_reader *reader);
+
+extern int
+rchan_full(struct rchan_reader *reader);
+
+extern void
+update_readers_consumed(struct rchan *rchan, u32 bufs_consumed, u32 bytes_consumed);
+
+extern int 
+__relay_mmap_buffer(struct rchan *rchan, struct vm_area_struct *vma);
+
+extern struct rchan_reader *
+__add_rchan_reader(struct rchan *rchan, struct file *filp, int auto_consume, int map_reader);
+
+extern void
+__remove_rchan_reader(struct rchan_reader *reader);
+
+/*
+ * Low-level relayfs kernel API, fs/relayfs/relay.c
+ */
+extern struct rchan *
+rchan_get(int rchan_id);
+
+extern void
+rchan_put(struct rchan *rchan);
+
+extern char *
+relay_reserve(struct rchan *rchan,
+             u32 data_len,
+             struct timeval *time_stamp,
+             u32 *time_delta,
+             int *errcode,
+             int *interrupting);
+
+extern void 
+relay_commit(struct rchan *rchan,
+            char *from, 
+            u32 len, 
+            int reserve_code,
+            int interrupting);
+
+extern u32 
+relay_get_offset(struct rchan *rchan, u32 *max_offset);
+
+extern int
+relay_reset(int rchan_id);
+
+/*
+ * VFS functions, fs/relayfs/inode.c
+ */
+extern int 
+relayfs_create_dir(const char *name, 
+                  struct dentry *parent, 
+                  struct dentry **dentry);
+
+extern int
+relayfs_create_file(const char * name,
+                   struct dentry *parent, 
+                   struct dentry **dentry,
+                   void * data,
+                   int mode);
+
+extern int 
+relayfs_remove_file(struct dentry *dentry);
+
+extern int
+reset_index(struct rchan *rchan, u32 old_index);
+
+
+/*
+ * klog functions, fs/relayfs/klog.c
+ */
+extern int
+create_klog_channel(void);
+
+extern int
+remove_klog_channel(void);
+
+/*
+ * Scheme-specific channel ops
+ */
+struct relay_ops
+{
+       char * (*reserve) (struct rchan *rchan,
+                          u32 slot_len,
+                          struct timeval *time_stamp,
+                          u32 *tsc,
+                          int * errcode,
+                          int * interrupting);
+       
+       void (*commit) (struct rchan *rchan,
+                       char *from,
+                       u32 len, 
+                       int deliver, 
+                       int interrupting);
+
+       u32 (*get_offset) (struct rchan *rchan,
+                          u32 *max_offset);
+       
+       void (*resume) (struct rchan *rchan);
+       void (*finalize) (struct rchan *rchan);
+       void (*reset) (struct rchan *rchan,
+                      int init);
+       int (*reset_index) (struct rchan *rchan,
+                           u32 old_index);
+};
+
+#endif /* _LINUX_RELAYFS_FS_H */
+
+
+
+
+
index 9449478..f43560d 100644 (file)
@@ -52,8 +52,11 @@ struct rlimit {
 /*
  * Limit the stack by to some sane default: root can always
  * increase this limit if needed..  8MB seems reasonable.
+ *
+ * (2MB more to cover randomization effects.)
  */
-#define _STK_LIM       (8*1024*1024)
+#define _STK_LIM       (10*1024*1024)
+#define EXEC_STACK_BIAS        (2*1024*1024)
 
 /*
  * Due to binary compatibility, the actual resource numbers
index e752fed..dd50052 100644 (file)
@@ -31,6 +31,9 @@
 #include <linux/percpu.h>
 
 struct exec_domain;
+extern int exec_shield;
+extern int exec_shield_randomize;
+extern int print_fatal_signals;
 
 /*
  * cloning flags:
@@ -91,6 +94,7 @@ extern unsigned long avenrun[];               /* Load averages */
 extern int nr_threads;
 extern int last_pid;
 DECLARE_PER_CPU(unsigned long, process_counts);
+// DECLARE_PER_CPU(struct runqueue, runqueues); -- removed after ckrm cpu v7 merge
 extern int nr_processes(void);
 extern unsigned long nr_running(void);
 extern unsigned long nr_uninterruptible(void);
@@ -102,6 +106,7 @@ extern unsigned long nr_iowait(void);
 #include <linux/timer.h>
 
 #include <asm/processor.h>
+#include <linux/vserver/context.h>
 
 #define TASK_RUNNING           0
 #define TASK_INTERRUPTIBLE     1
@@ -109,6 +114,7 @@ extern unsigned long nr_iowait(void);
 #define TASK_STOPPED           4
 #define TASK_ZOMBIE            8
 #define TASK_DEAD              16
+#define TASK_ONHOLD            32
 
 #define __set_task_state(tsk, state_value)             \
        do { (tsk)->state = (state_value); } while (0)
@@ -133,6 +139,7 @@ struct sched_param {
 
 #ifdef __KERNEL__
 
+#include <linux/taskdelays.h>
 #include <linux/spinlock.h>
 
 /*
@@ -189,10 +196,33 @@ extern int sysctl_max_map_count;
 
 #include <linux/aio.h>
 
+extern unsigned long
+arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
+                      unsigned long, unsigned long);
+
+extern unsigned long
+arch_get_unmapped_exec_area(struct file *, unsigned long, unsigned long,
+                      unsigned long, unsigned long);
+extern unsigned long
+arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
+                         unsigned long len, unsigned long pgoff,
+                         unsigned long flags);
+extern void arch_unmap_area(struct vm_area_struct *area);
+extern void arch_unmap_area_topdown(struct vm_area_struct *area);
+
+
 struct mm_struct {
        struct vm_area_struct * mmap;           /* list of VMAs */
        struct rb_root mm_rb;
        struct vm_area_struct * mmap_cache;     /* last find_vma result */
+       unsigned long (*get_unmapped_area) (struct file *filp,
+                               unsigned long addr, unsigned long len,
+                               unsigned long pgoff, unsigned long flags);
+       unsigned long (*get_unmapped_exec_area) (struct file *filp,
+                               unsigned long addr, unsigned long len,
+                               unsigned long pgoff, unsigned long flags);
+       void (*unmap_area) (struct vm_area_struct *area);
+       unsigned long mmap_base;                /* base of mmap area */
        unsigned long free_area_cache;          /* first hole */
        pgd_t * pgd;
        atomic_t mm_users;                      /* How many users with user space? */
@@ -219,6 +249,11 @@ struct mm_struct {
 
        /* Architecture-specific MM context */
        mm_context_t context;
+       struct vx_info *mm_vx_info;
+
+       /* Token based thrashing protection. */
+       unsigned long swap_token_time;
+       char recent_pagein;
 
        /* coredumping support */
        int core_waiters;
@@ -229,6 +264,11 @@ struct mm_struct {
        struct kioctx           *ioctx_list;
 
        struct kioctx           default_kioctx;
+#ifdef CONFIG_CKRM_RES_MEM
+       struct ckrm_mem_res *memclass;
+       struct list_head        tasklist; /* list of all tasks sharing this address space */
+       spinlock_t              peertask_lock; /* protect above tasklist */
+#endif
 };
 
 extern int mmlist_nr;
@@ -312,13 +352,15 @@ struct user_struct {
        atomic_t sigpending;    /* How many pending signals does this user have? */
        /* protected by mq_lock */
        unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
+       unsigned long locked_shm; /* How many pages of mlocked shm ? */
 
        /* Hash table maintenance information */
        struct list_head uidhash_list;
        uid_t uid;
+       xid_t xid;
 };
 
-extern struct user_struct *find_user(uid_t);
+extern struct user_struct *find_user(xid_t, uid_t);
 
 extern struct user_struct root_user;
 #define INIT_USER (&root_user)
@@ -387,6 +429,25 @@ int set_current_groups(struct group_info *group_info);
 struct audit_context;          /* See audit.c */
 struct mempolicy;
 
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+/**
+ * ckrm_cpu_demand_stat - used to track the cpu demand of a task/class
+ * @run: how much time it has been running since the counter started
+ * @total: total time since the counter started
+ * @last_sleep: the last time it sleeps, last_sleep = 0 when not sleeping
+ * @recalc_interval: how often do we recalculate the cpu_demand
+ * @cpu_demand: moving average of run/total
+ */
+struct ckrm_cpu_demand_stat {
+       unsigned long long run;
+       unsigned long long total;
+       unsigned long long last_sleep;
+       unsigned long long recalc_interval;
+       unsigned long cpu_demand; /*estimated cpu demand */
+};
+#endif
+
+
 struct task_struct {
        volatile long state;    /* -1 unrunnable, 0 runnable, >0 stopped */
        struct thread_info *thread_info;
@@ -486,7 +547,6 @@ struct task_struct {
 /* signal handlers */
        struct signal_struct *signal;
        struct sighand_struct *sighand;
-
        sigset_t blocked, real_blocked;
        struct sigpending pending;
 
@@ -495,10 +555,23 @@ struct task_struct {
        int (*notifier)(void *priv);
        void *notifier_data;
        sigset_t *notifier_mask;
+
+       /* TUX state */
+       void *tux_info;
+       void (*tux_exit)(void);
+
        
        void *security;
        struct audit_context *audit_context;
 
+/* vserver context data */
+       xid_t xid;
+       struct vx_info *vx_info;
+
+/* vserver network data */
+       nid_t nid;
+       struct nx_info *nx_info;
+
 /* Thread group tracking */
        u32 parent_exec_id;
        u32 self_exec_id;
@@ -520,6 +593,8 @@ struct task_struct {
 
        struct io_context *io_context;
 
+       int ioprio;
+
        unsigned long ptrace_message;
        siginfo_t *last_siginfo; /* For ptrace use.  */
 
@@ -527,6 +602,25 @@ struct task_struct {
        struct mempolicy *mempolicy;
        short il_next;          /* could be shared with used_math */
 #endif
+
+#ifdef CONFIG_CKRM
+       spinlock_t  ckrm_tsklock; 
+       void       *ce_data;
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+       // .. Hubertus should change to CONFIG_CKRM_TYPE_TASKCLASS 
+       struct ckrm_task_class *taskclass;
+       struct list_head        taskclass_link;
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+        struct ckrm_cpu_class *cpu_class;
+       //track cpu demand of this task
+       struct ckrm_cpu_demand_stat demand_stat;
+#endif //CONFIG_CKRM_CPU_SCHEDULE
+#endif // CONFIG_CKRM_TYPE_TASKCLASS
+#ifdef CONFIG_CKRM_RES_MEM
+       struct list_head        mm_peers; // list of tasks using same mm_struct
+#endif // CONFIG_CKRM_RES_MEM
+#endif // CONFIG_CKRM
+       struct task_delay_info  delays;
 };
 
 static inline pid_t process_group(struct task_struct *tsk)
@@ -563,6 +657,11 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)
 #define PF_SWAPOFF     0x00080000      /* I am in swapoff */
 #define PF_LESS_THROTTLE 0x00100000    /* Throttle me less: I clean memory */
 #define PF_SYNCWRITE   0x00200000      /* I am doing a sync write */
+#define PF_RELOCEXEC   0x00400000      /* relocate shared libraries */
+
+
+#define PF_MEMIO       0x00400000      /* I am  potentially doing I/O for mem */
+#define PF_IOWAIT       0x00800000      /* I am waiting on disk I/O */
 
 #ifdef CONFIG_SMP
 #define SCHED_LOAD_SCALE       128UL   /* increase resolution of load */
@@ -732,12 +831,13 @@ extern void set_special_pids(pid_t session, pid_t pgrp);
 extern void __set_special_pids(pid_t session, pid_t pgrp);
 
 /* per-UID process charging. */
-extern struct user_struct * alloc_uid(uid_t);
+extern struct user_struct * alloc_uid(xid_t, uid_t);
 static inline struct user_struct *get_uid(struct user_struct *u)
 {
        atomic_inc(&u->__count);
        return u;
 }
+
 extern void free_uid(struct user_struct *);
 extern void switch_uid(struct user_struct *);
 
@@ -843,6 +943,7 @@ static inline int capable(int cap)
 }
 #endif
 
+
 /*
  * Routines for handling mm_structs
  */
@@ -977,7 +1078,6 @@ static inline struct mm_struct * get_task_mm(struct task_struct * task)
        return mm;
 }
  
 /* set thread flags in other task's structures
  * - see asm/thread_info.h for TIF_xxxx flags available
  */
@@ -1027,10 +1127,13 @@ static inline int need_resched(void)
 }
 
 extern void __cond_resched(void);
+
 static inline void cond_resched(void)
 {
-       if (need_resched())
-               __cond_resched();
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+       __might_sleep(__FILE__, __LINE__, 0);
+#endif
+       __cond_resched();
 }
 
 /*
@@ -1041,14 +1144,14 @@ static inline void cond_resched(void)
  * operations here to prevent schedule() from being called twice (once via
  * spin_unlock(), once by hand).
  */
+extern void __cond_resched_lock(spinlock_t * lock);
+
 static inline void cond_resched_lock(spinlock_t * lock)
 {
-       if (need_resched()) {
-               _raw_spin_unlock(lock);
-               preempt_enable_no_resched();
-               __cond_resched();
-               spin_lock(lock);
-       }
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+       __might_sleep(__FILE__, __LINE__, 1);
+#endif
+       __cond_resched_lock(lock);
 }
 
 /* Reevaluate whether the task has signals pending delivery.
@@ -1088,6 +1191,100 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
 
 #endif /* CONFIG_SMP */
 
+
+/* API for registering delay info */
+#ifdef CONFIG_DELAY_ACCT
+
+#define test_delay_flag(tsk,flg)                ((tsk)->flags & (flg))
+#define set_delay_flag(tsk,flg)                 ((tsk)->flags |= (flg))
+#define clear_delay_flag(tsk,flg)               ((tsk)->flags &= ~(flg))
+
+#define def_delay_var(var)                     unsigned long long var
+#define get_delay(tsk,field)                    ((tsk)->delays.field)
+
+#define start_delay(var)                        ((var) = sched_clock())
+#define start_delay_set(var,flg)                (set_delay_flag(current,flg),(var) = sched_clock())
+
+#define inc_delay(tsk,field) (((tsk)->delays.field)++)
+
+/* because of hardware timer drifts in SMPs and task continue on different cpu
+ * then where the start_ts was taken there is a possibility that
+ * end_ts < start_ts by some usecs. In this case we ignore the diff
+ * and add nothing to the total.
+ */
+#ifdef CONFIG_SMP
+#define test_ts_integrity(start_ts,end_ts)  (likely((end_ts) > (start_ts)))
+#else
+#define test_ts_integrity(start_ts,end_ts)  (1)
+#endif
+
+#define add_delay_ts(tsk,field,start_ts,end_ts) \
+       do { if (test_ts_integrity(start_ts,end_ts)) (tsk)->delays.field += ((end_ts)-(start_ts)); } while (0)
+
+#define add_delay_clear(tsk,field,start_ts,flg)        \
+       do {                                           \
+               unsigned long long now = sched_clock();\
+               add_delay_ts(tsk,field,start_ts,now);  \
+               clear_delay_flag(tsk,flg);             \
+        } while (0)
+
+static inline void add_io_delay(unsigned long long dstart) 
+{
+       struct task_struct * tsk = current;
+       unsigned long long now = sched_clock();
+       unsigned long long val;
+
+       if (test_ts_integrity(dstart,now))
+               val = now - dstart;
+       else
+               val = 0;
+       if (test_delay_flag(tsk,PF_MEMIO)) {
+               tsk->delays.mem_iowait_total += val;
+               tsk->delays.num_memwaits++;
+       } else {
+               tsk->delays.iowait_total += val;
+               tsk->delays.num_iowaits++;
+       }
+       clear_delay_flag(tsk,PF_IOWAIT);
+}
+
+inline static void init_delays(struct task_struct *tsk)
+{
+       memset((void*)&tsk->delays,0,sizeof(tsk->delays));
+}
+
+#else
+
+#define test_delay_flag(tsk,flg)                (0)
+#define set_delay_flag(tsk,flg)                 do { } while (0)
+#define clear_delay_flag(tsk,flg)               do { } while (0)
+
+#define def_delay_var(var)                           
+#define get_delay(tsk,field)                    (0)
+
+#define start_delay(var)                        do { } while (0)
+#define start_delay_set(var,flg)                do { } while (0)
+
+#define inc_delay(tsk,field)                    do { } while (0)
+#define add_delay_ts(tsk,field,start_ts,now)    do { } while (0)
+#define add_delay_clear(tsk,field,start_ts,flg) do { } while (0)
+#define add_io_delay(dstart)                   do { } while (0) 
+#define init_delays(tsk)                        do { } while (0)
+#endif
+
+
+
+#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
+extern void arch_pick_mmap_layout(struct mm_struct *mm);
+#else
+static inline void arch_pick_mmap_layout(struct mm_struct *mm)
+{
+       mm->mmap_base = TASK_UNMAPPED_BASE;
+       mm->get_unmapped_area = arch_get_unmapped_area;
+       mm->unmap_area = arch_unmap_area;
+}
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif
index 9a00f5f..1907355 100644 (file)
@@ -84,6 +84,7 @@ struct shmid_kernel /* private to the kernel */
        time_t                  shm_ctim;
        pid_t                   shm_cprid;
        pid_t                   shm_lprid;
+       struct user_struct      *mlock_user;
 };
 
 /* shm_mode upper byte flags */
index f8efcf1..14a6181 100644 (file)
@@ -8,6 +8,9 @@
 
 #define SHMEM_NR_DIRECT 16
 
+#define TMPFS_SUPER_MAGIC      0x01021994
+
+
 struct shmem_inode_info {
        spinlock_t              lock;
        unsigned long           next_index;
index 724d684..111bb73 100644 (file)
@@ -272,6 +272,7 @@ struct sk_buff {
  #endif
 
 #endif
+       xid_t                   xid;                    /* VServer context ID */
 
 
        /* These elements must be at the end, see alloc_skb() for details.  */
@@ -1124,6 +1125,8 @@ extern int skb_iter_next(const struct sk_buff *skb, struct skb_iter *i);
 /* Call this if aborting loop before !skb_iter_next */
 extern void skb_iter_abort(const struct sk_buff *skb, struct skb_iter *i);
 
+struct tux_req_struct;
+
 #ifdef CONFIG_NETFILTER
 static inline void nf_conntrack_put(struct nf_ct_info *nfct)
 {
index 9a20995..803315f 100644 (file)
@@ -5,7 +5,9 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
+#define BKL_DEBUG /* For testing for sleep_on() abuse */
+
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) || defined(BKL_DEBUG)
 
 extern spinlock_t kernel_flag;
 
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
deleted file mode 100644 (file)
index 4db25d5..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Definitions for MIBs
- *
- * Author: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
- */
-
-#ifndef _LINUX_SNMP_H
-#define _LINUX_SNMP_H
-
-/* ipstats mib definitions */
-/*
- * RFC 1213:  MIB-II
- * RFC 2011 (updates 1213):  SNMPv2-MIB-IP
- * RFC 2863:  Interfaces Group MIB
- * RFC 2465:  IPv6 MIB: General Group
- * draft-ietf-ipv6-rfc2011-update-10.txt: MIB for IP: IP Statistics Tables
- */
-enum
-{
-       IPSTATS_MIB_NUM = 0,
-       IPSTATS_MIB_INRECEIVES,                 /* InReceives */
-       IPSTATS_MIB_INHDRERRORS,                /* InHdrErrors */
-       IPSTATS_MIB_INTOOBIGERRORS,             /* InTooBigErrors */
-       IPSTATS_MIB_INNOROUTES,                 /* InNoRoutes */
-       IPSTATS_MIB_INADDRERRORS,               /* InAddrErrors */
-       IPSTATS_MIB_INUNKNOWNPROTOS,            /* InUnknownProtos */
-       IPSTATS_MIB_INTRUNCATEDPKTS,            /* InTruncatedPkts */
-       IPSTATS_MIB_INDISCARDS,                 /* InDiscards */
-       IPSTATS_MIB_INDELIVERS,                 /* InDelivers */
-       IPSTATS_MIB_OUTFORWDATAGRAMS,           /* OutForwDatagrams */
-       IPSTATS_MIB_OUTREQUESTS,                /* OutRequests */
-       IPSTATS_MIB_OUTDISCARDS,                /* OutDiscards */
-       IPSTATS_MIB_OUTNOROUTES,                /* OutNoRoutes */
-       IPSTATS_MIB_REASMTIMEOUT,               /* ReasmTimeout */
-       IPSTATS_MIB_REASMREQDS,                 /* ReasmReqds */
-       IPSTATS_MIB_REASMOKS,                   /* ReasmOKs */
-       IPSTATS_MIB_REASMFAILS,                 /* ReasmFails */
-       IPSTATS_MIB_FRAGOKS,                    /* FragOKs */
-       IPSTATS_MIB_FRAGFAILS,                  /* FragFails */
-       IPSTATS_MIB_FRAGCREATES,                /* FragCreates */
-       IPSTATS_MIB_INMCASTPKTS,                /* InMcastPkts */
-       IPSTATS_MIB_OUTMCASTPKTS,               /* OutMcastPkts */
-       __IPSTATS_MIB_MAX
-};
-
-/* icmp mib definitions */
-/*
- * RFC 1213:  MIB-II ICMP Group
- * RFC 2011 (updates 1213):  SNMPv2 MIB for IP: ICMP group
- */
-enum
-{
-       ICMP_MIB_NUM = 0,
-       ICMP_MIB_INMSGS,                        /* InMsgs */
-       ICMP_MIB_INERRORS,                      /* InErrors */
-       ICMP_MIB_INDESTUNREACHS,                /* InDestUnreachs */
-       ICMP_MIB_INTIMEEXCDS,                   /* InTimeExcds */
-       ICMP_MIB_INPARMPROBS,                   /* InParmProbs */
-       ICMP_MIB_INSRCQUENCHS,                  /* InSrcQuenchs */
-       ICMP_MIB_INREDIRECTS,                   /* InRedirects */
-       ICMP_MIB_INECHOS,                       /* InEchos */
-       ICMP_MIB_INECHOREPS,                    /* InEchoReps */
-       ICMP_MIB_INTIMESTAMPS,                  /* InTimestamps */
-       ICMP_MIB_INTIMESTAMPREPS,               /* InTimestampReps */
-       ICMP_MIB_INADDRMASKS,                   /* InAddrMasks */
-       ICMP_MIB_INADDRMASKREPS,                /* InAddrMaskReps */
-       ICMP_MIB_OUTMSGS,                       /* OutMsgs */
-       ICMP_MIB_OUTERRORS,                     /* OutErrors */
-       ICMP_MIB_OUTDESTUNREACHS,               /* OutDestUnreachs */
-       ICMP_MIB_OUTTIMEEXCDS,                  /* OutTimeExcds */
-       ICMP_MIB_OUTPARMPROBS,                  /* OutParmProbs */
-       ICMP_MIB_OUTSRCQUENCHS,                 /* OutSrcQuenchs */
-       ICMP_MIB_OUTREDIRECTS,                  /* OutRedirects */
-       ICMP_MIB_OUTECHOS,                      /* OutEchos */
-       ICMP_MIB_OUTECHOREPS,                   /* OutEchoReps */
-       ICMP_MIB_OUTTIMESTAMPS,                 /* OutTimestamps */
-       ICMP_MIB_OUTTIMESTAMPREPS,              /* OutTimestampReps */
-       ICMP_MIB_OUTADDRMASKS,                  /* OutAddrMasks */
-       ICMP_MIB_OUTADDRMASKREPS,               /* OutAddrMaskReps */
-       __ICMP_MIB_MAX
-};
-
-/* icmp6 mib definitions */
-/*
- * RFC 2466:  ICMPv6-MIB
- */
-enum
-{
-       ICMP6_MIB_NUM = 0,
-       ICMP6_MIB_INMSGS,                       /* InMsgs */
-       ICMP6_MIB_INERRORS,                     /* InErrors */
-       ICMP6_MIB_INDESTUNREACHS,               /* InDestUnreachs */
-       ICMP6_MIB_INPKTTOOBIGS,                 /* InPktTooBigs */
-       ICMP6_MIB_INTIMEEXCDS,                  /* InTimeExcds */
-       ICMP6_MIB_INPARMPROBLEMS,               /* InParmProblems */
-       ICMP6_MIB_INECHOS,                      /* InEchos */
-       ICMP6_MIB_INECHOREPLIES,                /* InEchoReplies */
-       ICMP6_MIB_INGROUPMEMBQUERIES,           /* InGroupMembQueries */
-       ICMP6_MIB_INGROUPMEMBRESPONSES,         /* InGroupMembResponses */
-       ICMP6_MIB_INGROUPMEMBREDUCTIONS,        /* InGroupMembReductions */
-       ICMP6_MIB_INROUTERSOLICITS,             /* InRouterSolicits */
-       ICMP6_MIB_INROUTERADVERTISEMENTS,       /* InRouterAdvertisements */
-       ICMP6_MIB_INNEIGHBORSOLICITS,           /* InNeighborSolicits */
-       ICMP6_MIB_INNEIGHBORADVERTISEMENTS,     /* InNeighborAdvertisements */
-       ICMP6_MIB_INREDIRECTS,                  /* InRedirects */
-       ICMP6_MIB_OUTMSGS,                      /* OutMsgs */
-       ICMP6_MIB_OUTDESTUNREACHS,              /* OutDestUnreachs */
-       ICMP6_MIB_OUTPKTTOOBIGS,                /* OutPktTooBigs */
-       ICMP6_MIB_OUTTIMEEXCDS,                 /* OutTimeExcds */
-       ICMP6_MIB_OUTPARMPROBLEMS,              /* OutParmProblems */
-       ICMP6_MIB_OUTECHOREPLIES,               /* OutEchoReplies */
-       ICMP6_MIB_OUTROUTERSOLICITS,            /* OutRouterSolicits */
-       ICMP6_MIB_OUTNEIGHBORSOLICITS,          /* OutNeighborSolicits */
-       ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS,    /* OutNeighborAdvertisements */
-       ICMP6_MIB_OUTREDIRECTS,                 /* OutRedirects */
-       ICMP6_MIB_OUTGROUPMEMBRESPONSES,        /* OutGroupMembResponses */
-       ICMP6_MIB_OUTGROUPMEMBREDUCTIONS,       /* OutGroupMembReductions */
-       __ICMP6_MIB_MAX
-};
-
-/* tcp mib definitions */
-/*
- * RFC 1213:  MIB-II TCP group
- * RFC 2012 (updates 1213):  SNMPv2-MIB-TCP
- */
-enum
-{
-       TCP_MIB_NUM = 0,
-       TCP_MIB_RTOALGORITHM,                   /* RtoAlgorithm */
-       TCP_MIB_RTOMIN,                         /* RtoMin */
-       TCP_MIB_RTOMAX,                         /* RtoMax */
-       TCP_MIB_MAXCONN,                        /* MaxConn */
-       TCP_MIB_ACTIVEOPENS,                    /* ActiveOpens */
-       TCP_MIB_PASSIVEOPENS,                   /* PassiveOpens */
-       TCP_MIB_ATTEMPTFAILS,                   /* AttemptFails */
-       TCP_MIB_ESTABRESETS,                    /* EstabResets */
-       TCP_MIB_CURRESTAB,                      /* CurrEstab */
-       TCP_MIB_INSEGS,                         /* InSegs */
-       TCP_MIB_OUTSEGS,                        /* OutSegs */
-       TCP_MIB_RETRANSSEGS,                    /* RetransSegs */
-       TCP_MIB_INERRS,                         /* InErrs */
-       TCP_MIB_OUTRSTS,                        /* OutRsts */
-       __TCP_MIB_MAX
-};
-
-/* udp mib definitions */
-/*
- * RFC 1213:  MIB-II UDP group
- * RFC 2013 (updates 1213):  SNMPv2-MIB-UDP
- */
-enum
-{
-       UDP_MIB_NUM = 0,
-       UDP_MIB_INDATAGRAMS,                    /* InDatagrams */
-       UDP_MIB_NOPORTS,                        /* NoPorts */
-       UDP_MIB_INERRORS,                       /* InErrors */
-       UDP_MIB_OUTDATAGRAMS,                   /* OutDatagrams */
-       __UDP_MIB_MAX
-};
-
-/* sctp mib definitions */
-/*
- * draft-ietf-sigtran-sctp-mib-07.txt
- */
-enum
-{
-       SCTP_MIB_NUM = 0,
-       SCTP_MIB_CURRESTAB,                     /* CurrEstab */
-       SCTP_MIB_ACTIVEESTABS,                  /* ActiveEstabs */
-       SCTP_MIB_PASSIVEESTABS,                 /* PassiveEstabs */
-       SCTP_MIB_ABORTEDS,                      /* Aborteds */
-       SCTP_MIB_SHUTDOWNS,                     /* Shutdowns */
-       SCTP_MIB_OUTOFBLUES,                    /* OutOfBlues */
-       SCTP_MIB_CHECKSUMERRORS,                /* ChecksumErrors */
-       SCTP_MIB_OUTCTRLCHUNKS,                 /* OutCtrlChunks */
-       SCTP_MIB_OUTORDERCHUNKS,                /* OutOrderChunks */
-       SCTP_MIB_OUTUNORDERCHUNKS,              /* OutUnorderChunks */
-       SCTP_MIB_INCTRLCHUNKS,                  /* InCtrlChunks */
-       SCTP_MIB_INORDERCHUNKS,                 /* InOrderChunks */
-       SCTP_MIB_INUNORDERCHUNKS,               /* InUnorderChunks */
-       SCTP_MIB_FRAGUSRMSGS,                   /* FragUsrMsgs */
-       SCTP_MIB_REASMUSRMSGS,                  /* ReasmUsrMsgs */
-       SCTP_MIB_OUTSCTPPACKS,                  /* OutSCTPPacks */
-       SCTP_MIB_INSCTPPACKS,                   /* InSCTPPacks */
-       SCTP_MIB_RTOALGORITHM,                  /* RtoAlgorithm */
-       SCTP_MIB_RTOMIN,                        /* RtoMin */
-       SCTP_MIB_RTOMAX,                        /* RtoMax */
-       SCTP_MIB_RTOINITIAL,                    /* RtoInitial */
-       SCTP_MIB_VALCOOKIELIFE,                 /* ValCookieLife */
-       SCTP_MIB_MAXINITRETR,                   /* MaxInitRetr */
-       __SCTP_MIB_MAX
-};
-
-/* linux mib definitions */
-enum
-{
-       LINUX_MIB_NUM = 0,
-       LINUX_MIB_SYNCOOKIESSENT,               /* SyncookiesSent */
-       LINUX_MIB_SYNCOOKIESRECV,               /* SyncookiesRecv */
-       LINUX_MIB_SYNCOOKIESFAILED,             /* SyncookiesFailed */
-       LINUX_MIB_EMBRYONICRSTS,                /* EmbryonicRsts */
-       LINUX_MIB_PRUNECALLED,                  /* PruneCalled */
-       LINUX_MIB_RCVPRUNED,                    /* RcvPruned */
-       LINUX_MIB_OFOPRUNED,                    /* OfoPruned */
-       LINUX_MIB_OUTOFWINDOWICMPS,             /* OutOfWindowIcmps */
-       LINUX_MIB_LOCKDROPPEDICMPS,             /* LockDroppedIcmps */
-       LINUX_MIB_ARPFILTER,                    /* ArpFilter */
-       LINUX_MIB_TIMEWAITED,                   /* TimeWaited */
-       LINUX_MIB_TIMEWAITRECYCLED,             /* TimeWaitRecycled */
-       LINUX_MIB_TIMEWAITKILLED,               /* TimeWaitKilled */
-       LINUX_MIB_PAWSPASSIVEREJECTED,          /* PAWSPassiveRejected */
-       LINUX_MIB_PAWSACTIVEREJECTED,           /* PAWSActiveRejected */
-       LINUX_MIB_PAWSESTABREJECTED,            /* PAWSEstabRejected */
-       LINUX_MIB_DELAYEDACKS,                  /* DelayedACKs */
-       LINUX_MIB_DELAYEDACKLOCKED,             /* DelayedACKLocked */
-       LINUX_MIB_DELAYEDACKLOST,               /* DelayedACKLost */
-       LINUX_MIB_LISTENOVERFLOWS,              /* ListenOverflows */
-       LINUX_MIB_LISTENDROPS,                  /* ListenDrops */
-       LINUX_MIB_TCPPREQUEUED,                 /* TCPPrequeued */
-       LINUX_MIB_TCPDIRECTCOPYFROMBACKLOG,     /* TCPDirectCopyFromBacklog */
-       LINUX_MIB_TCPDIRECTCOPYFROMPREQUEUE,    /* TCPDirectCopyFromPrequeue */
-       LINUX_MIB_TCPPREQUEUEDROPPED,           /* TCPPrequeueDropped */
-       LINUX_MIB_TCPHPHITS,                    /* TCPHPHits */
-       LINUX_MIB_TCPHPHITSTOUSER,              /* TCPHPHitsToUser */
-       LINUX_MIB_TCPPUREACKS,                  /* TCPPureAcks */
-       LINUX_MIB_TCPHPACKS,                    /* TCPHPAcks */
-       LINUX_MIB_TCPRENORECOVERY,              /* TCPRenoRecovery */
-       LINUX_MIB_TCPSACKRECOVERY,              /* TCPSackRecovery */
-       LINUX_MIB_TCPSACKRENEGING,              /* TCPSACKReneging */
-       LINUX_MIB_TCPFACKREORDER,               /* TCPFACKReorder */
-       LINUX_MIB_TCPSACKREORDER,               /* TCPSACKReorder */
-       LINUX_MIB_TCPRENOREORDER,               /* TCPRenoReorder */
-       LINUX_MIB_TCPTSREORDER,                 /* TCPTSReorder */
-       LINUX_MIB_TCPFULLUNDO,                  /* TCPFullUndo */
-       LINUX_MIB_TCPPARTIALUNDO,               /* TCPPartialUndo */
-       LINUX_MIB_TCPDSACKUNDO,                 /* TCPDSACKUndo */
-       LINUX_MIB_TCPLOSSUNDO,                  /* TCPLossUndo */
-       LINUX_MIB_TCPLOSS,                      /* TCPLoss */
-       LINUX_MIB_TCPLOSTRETRANSMIT,            /* TCPLostRetransmit */
-       LINUX_MIB_TCPRENOFAILURES,              /* TCPRenoFailures */
-       LINUX_MIB_TCPSACKFAILURES,              /* TCPSackFailures */
-       LINUX_MIB_TCPLOSSFAILURES,              /* TCPLossFailures */
-       LINUX_MIB_TCPFASTRETRANS,               /* TCPFastRetrans */
-       LINUX_MIB_TCPFORWARDRETRANS,            /* TCPForwardRetrans */
-       LINUX_MIB_TCPSLOWSTARTRETRANS,          /* TCPSlowStartRetrans */
-       LINUX_MIB_TCPTIMEOUTS,                  /* TCPTimeouts */
-       LINUX_MIB_TCPRENORECOVERYFAIL,          /* TCPRenoRecoveryFail */
-       LINUX_MIB_TCPSACKRECOVERYFAIL,          /* TCPSackRecoveryFail */
-       LINUX_MIB_TCPSCHEDULERFAILED,           /* TCPSchedulerFailed */
-       LINUX_MIB_TCPRCVCOLLAPSED,              /* TCPRcvCollapsed */
-       LINUX_MIB_TCPDSACKOLDSENT,              /* TCPDSACKOldSent */
-       LINUX_MIB_TCPDSACKOFOSENT,              /* TCPDSACKOfoSent */
-       LINUX_MIB_TCPDSACKRECV,                 /* TCPDSACKRecv */
-       LINUX_MIB_TCPDSACKOFORECV,              /* TCPDSACKOfoRecv */
-       LINUX_MIB_TCPABORTONSYN,                /* TCPAbortOnSyn */
-       LINUX_MIB_TCPABORTONDATA,               /* TCPAbortOnData */
-       LINUX_MIB_TCPABORTONCLOSE,              /* TCPAbortOnClose */
-       LINUX_MIB_TCPABORTONMEMORY,             /* TCPAbortOnMemory */
-       LINUX_MIB_TCPABORTONTIMEOUT,            /* TCPAbortOnTimeout */
-       LINUX_MIB_TCPABORTONLINGER,             /* TCPAbortOnLinger */
-       LINUX_MIB_TCPABORTFAILED,               /* TCPAbortFailed */
-       LINUX_MIB_TCPMEMORYPRESSURES,           /* TCPMemoryPressures */
-       __LINUX_MIB_MAX
-};
-
-#endif /* _LINUX_SNMP_H */
index 3a18d6e..602d03b 100644 (file)
@@ -269,6 +269,9 @@ struct ucred {
 #define SOL_NETBEUI    267
 #define SOL_LLC                268
 
+/* PlanetLab PL2525: reset the context ID of an existing socket */
+#define SO_SETXID      SO_PEERCRED
+
 /* IPX options */
 #define IPX_TYPE       1
 
@@ -288,6 +291,11 @@ extern int move_addr_to_user(void *kaddr, int klen, void __user *uaddr, int __us
 extern int move_addr_to_kernel(void __user *uaddr, int ulen, void *kaddr);
 extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
 
+struct socket;
+struct file * sock_map_file(struct socket *sock);
+extern int sock_map_fd(struct socket *sock);
+extern struct socket *sockfd_lookup(int fd, int *err);
+
 #endif
 #endif /* not kernel and not glibc */
 #endif /* _LINUX_SOCKET_H */
index 8ff2a12..289a968 100644 (file)
@@ -63,6 +63,7 @@ struct kstat {
        unsigned int    nlink;
        uid_t           uid;
        gid_t           gid;
+       xid_t           xid;
        dev_t           rdev;
        loff_t          size;
        struct timespec  atime;
index a196e9b..4eea2ac 100644 (file)
@@ -28,6 +28,7 @@
 struct auth_cred {
        uid_t   uid;
        gid_t   gid;
+       xid_t   xid;
        struct group_info *group_info;
 };
 
index 917ec29..62f9705 100644 (file)
@@ -53,7 +53,8 @@ struct rpc_clnt {
                                cl_autobind : 1,/* use getport() */
                                cl_droppriv : 1,/* enable NFS suid hack */
                                cl_oneshot  : 1,/* dispose after use */
-                               cl_dead     : 1;/* abandoned */
+                               cl_dead     : 1,/* abandoned */
+                               cl_tagxid   : 1;/* do xid tagging */
 
        struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
        struct rpc_portmap *    cl_pmap;        /* port mapping */
index b081066..99ecc28 100644 (file)
@@ -204,6 +204,27 @@ extern void free_pages_and_swap_cache(struct page **, int);
 extern struct page * lookup_swap_cache(swp_entry_t);
 extern struct page * read_swap_cache_async(swp_entry_t, struct vm_area_struct *vma,
                                           unsigned long addr);
+/* linux/mm/thrash.c */
+#ifdef CONFIG_SWAP
+extern struct mm_struct * swap_token_mm;
+extern void grab_swap_token(void);
+extern void __put_swap_token(struct mm_struct *);
+
+static inline int has_swap_token(struct mm_struct *mm)
+{
+       return (mm == swap_token_mm);
+}
+
+static inline void put_swap_token(struct mm_struct *mm)
+{
+       if (has_swap_token(mm))
+               __put_swap_token(mm);
+}
+#else /* CONFIG_SWAP */
+#define put_swap_token(x) do { } while(0)
+#define grab_swap_token  do { } while(0)
+#define has_swap_token 0
+#endif /* CONFIG_SWAP */
 
 /* linux/mm/swapfile.c */
 extern long total_swap_pages;
index 70ac59e..8baf21a 100644 (file)
@@ -133,6 +133,8 @@ enum
        KERN_NGROUPS_MAX=63,    /* int: NGROUPS_MAX */
        KERN_SPARC_SCONS_PWROFF=64, /* int: serial console power-off halt */
        KERN_HZ_TIMER=65,       /* int: hz timer on or off */
+       KERN_VSHELPER=66,       /* string: path to vshelper policy agent */
+       KERN_DUMP=67,           /* dir: dump parameters */
 };
 
 
@@ -165,6 +167,7 @@ enum
        VM_BLOCK_DUMP=24,       /* block dump mode */
        VM_HUGETLB_GROUP=25,    /* permitted hugetlb group */
        VM_VFS_CACHE_PRESSURE=26, /* dcache/icache reclaim pressure */
+       VM_LEGACY_VA_LAYOUT=27, /* legacy/compatibility virtual address space layout */
 };
 
 
@@ -188,6 +191,7 @@ enum
        NET_DECNET=15,
        NET_ECONET=16,
        NET_SCTP=17, 
+       NET_TUX=18,
 };
 
 /* /proc/sys/kernel/random */
@@ -339,6 +343,13 @@ enum
        NET_TCP_BIC_LOW_WINDOW=104,
        NET_TCP_DEFAULT_WIN_SCALE=105,
        NET_TCP_MODERATE_RCVBUF=106,
+#ifdef CONFIG_ICMP_IPOD
+       NET_IPV4_ICMP_IPOD_VERSION,
+       NET_IPV4_ICMP_IPOD_ENABLED,
+       NET_IPV4_ICMP_IPOD_HOST,
+       NET_IPV4_ICMP_IPOD_MASK,
+       NET_IPV4_ICMP_IPOD_KEY,
+#endif
 };
 
 enum {
@@ -626,6 +637,55 @@ enum {
        NET_BRIDGE_NF_FILTER_VLAN_TAGGED = 4,
 };
 
+/* /proc/sys/net/tux/ */
+enum {
+       NET_TUX_DOCROOT                 =  1,
+       NET_TUX_LOGFILE                 =  2,
+       NET_TUX_EXTCGI                  =  3,
+       NET_TUX_STOP                    =  4,
+       NET_TUX_CLIENTPORT              =  5,
+       NET_TUX_LOGGING                 =  6,
+       NET_TUX_SERVERPORT              =  7,
+       NET_TUX_THREADS                 =  8,
+       NET_TUX_KEEPALIVE_TIMEOUT       =  9,
+       NET_TUX_MAX_KEEPALIVE_BW        = 10,
+       NET_TUX_DEFER_ACCEPT            = 11,
+       NET_TUX_MAX_FREE_REQUESTS       = 12,
+       NET_TUX_MAX_CONNECT             = 13,
+       NET_TUX_MAX_BACKLOG             = 14,
+       NET_TUX_MODE_FORBIDDEN          = 15,
+       NET_TUX_MODE_ALLOWED            = 16,
+       NET_TUX_MODE_USERSPACE          = 17,
+       NET_TUX_MODE_CGI                = 18,
+       NET_TUX_CGI_UID                 = 19,
+       NET_TUX_CGI_GID                 = 20,
+       NET_TUX_CGIROOT                 = 21,
+       NET_TUX_LOGENTRY_ALIGN_ORDER    = 22,
+       NET_TUX_NONAGLE                 = 23,
+       NET_TUX_ACK_PINGPONG            = 24,
+       NET_TUX_PUSH_ALL                = 25,
+       NET_TUX_ZEROCOPY_PARSE          = 26,
+       NET_CONFIG_TUX_DEBUG_BLOCKING   = 27,
+       NET_TUX_PAGE_AGE_START          = 28,
+       NET_TUX_PAGE_AGE_ADV            = 29,
+       NET_TUX_PAGE_AGE_MAX            = 30,
+       NET_TUX_VIRTUAL_SERVER          = 31,
+       NET_TUX_MAX_OBJECT_SIZE         = 32,
+       NET_TUX_COMPRESSION             = 33,
+       NET_TUX_NOID                    = 34,
+       NET_TUX_CGI_INHERIT_CPU         = 35,
+       NET_TUX_CGI_CPU_MASK            = 36,
+       NET_TUX_ZEROCOPY_HEADER         = 37,
+       NET_TUX_ZEROCOPY_SENDFILE       = 38,
+       NET_TUX_ALL_USERSPACE           = 39,
+       NET_TUX_REDIRECT_LOGGING        = 40,
+       NET_TUX_REFERER_LOGGING         = 41,
+       NET_TUX_MAX_HEADER_LEN          = 42,
+       NET_TUX_404_PAGE                = 43,
+       NET_TUX_MAX_KEEPALIVES          = 44,
+       NET_TUX_IGNORE_QUERY            = 45,
+};
+
 /* CTL_PROC names: */
 
 /* CTL_FS names: */
index f94c7ac..23f7838 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef _SYSFS_H_
 #define _SYSFS_H_
 
+#define SYSFS_SUPER_MAGIC      0x62656572
+
 struct kobject;
 struct module;
 
diff --git a/include/linux/taskdelays.h b/include/linux/taskdelays.h
new file mode 100644 (file)
index 0000000..e5682d8
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _LINUX_TASKDELAYS_H
+#define _LINUX_TASKDELAYS_H
+
+#include <linux/config.h>
+#include <linux/types.h>
+
+struct task_delay_info {
+#if defined CONFIG_DELAY_ACCT 
+       /* delay statistics in usecs */
+       uint64_t waitcpu_total;
+       uint64_t runcpu_total;
+       uint64_t iowait_total;
+       uint64_t mem_iowait_total;
+       uint32_t runs;
+       uint32_t num_iowaits;
+       uint32_t num_memwaits;
+#endif                         
+};
+
+#endif                         // _LINUX_TASKDELAYS_H
index 9c42ac0..9ed5fac 100644 (file)
@@ -128,6 +128,10 @@ enum {
 #define TCP_INFO               11      /* Information about this connection. */
 #define TCP_QUICKACK           12      /* Block/reenable quick acks */
 
+#ifdef CONFIG_ACCEPT_QUEUES
+#define TCP_ACCEPTQ_SHARE      13      /* Set accept queue share */
+#endif
+
 #define TCPI_OPT_TIMESTAMPS    1
 #define TCPI_OPT_SACK          2
 #define TCPI_OPT_WSCALE                4
@@ -188,6 +192,18 @@ struct tcp_info
        __u32   tcpi_rcv_space;
 };
 
+#ifdef CONFIG_ACCEPT_QUEUES
+
+#define NUM_ACCEPT_QUEUES      8       /* Must be power of 2 */
+
+struct tcp_acceptq_info {
+       unsigned char acceptq_shares;
+       unsigned long acceptq_wait_time;
+       unsigned int acceptq_qcount;
+       unsigned int acceptq_count;
+};
+#endif
+
 #ifdef __KERNEL__
 
 #include <linux/config.h>
@@ -368,8 +384,9 @@ struct tcp_opt {
 
        /* FIFO of established children */
        struct open_request     *accept_queue;
+#ifndef CONFIG_ACCEPT_QUEUES
        struct open_request     *accept_queue_tail;
-
+#endif
        unsigned int            keepalive_time;   /* time before keep alive takes place */
        unsigned int            keepalive_intvl;  /* time interval between keep alive probes */
        int                     linger2;
@@ -422,6 +439,21 @@ struct tcp_opt {
                __u32   last_cwnd;      /* the last snd_cwnd */
                __u32   last_stamp;     /* time when updated last_cwnd */
        } bictcp;
+
+#ifdef CONFIG_ACCEPT_QUEUES
+       /* move to listen opt... */
+       char            class_index;
+       struct {
+               struct open_request     *aq_head;
+               struct open_request     *aq_tail;
+               unsigned int             aq_cnt;
+               unsigned int             aq_ratio;
+               unsigned int             aq_count;
+               unsigned int             aq_qcount;
+               unsigned int             aq_backlog;
+               unsigned int             aq_wait_time;
+       } acceptq[NUM_ACCEPT_QUEUES];
+#endif
 };
 
 /* WARNING: don't change the layout of the members in tcp_sock! */
index d24a690..bb9baab 100644 (file)
@@ -41,7 +41,7 @@ struct timezone {
  * Have the 32 bit jiffies value wrap 5 minutes after boot
  * so jiffies wrap bugs show up earlier.
  */
-#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
+#define INITIAL_JIFFIES ((unsigned long)(0))
 
 /*
  * Change timeval to jiffies, trying to avoid the
index 23c414f..dd1505c 100644 (file)
@@ -37,6 +37,10 @@ typedef __kernel_gid32_t     gid_t;
 typedef __kernel_uid16_t        uid16_t;
 typedef __kernel_gid16_t        gid16_t;
 
+/* The following two typedef's are for vserver */
+typedef unsigned int           xid_t;
+typedef unsigned int           nid_t;
+
 #ifdef CONFIG_UID16
 /* This is defined by include/asm-{arch}/posix_types.h */
 typedef __kernel_old_uid_t     old_uid_t;
diff --git a/include/linux/upd4990a.h b/include/linux/upd4990a.h
deleted file mode 100644 (file)
index ad50634..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- *  Constant and architecture independent procedures
- *  for NEC uPD4990A serial I/O real-time clock.
- *
- *  Copyright 2001  TAKAI Kousuke <tak@kmc.kyoto-u.ac.jp>
- *                 Kyoto University Microcomputer Club (KMC).
- *
- *  References:
- *     uPD4990A serial I/O real-time clock users' manual (Japanese)
- *     No. S12828JJ4V0UM00 (4th revision), NEC Corporation, 1999.
- */
-
-#ifndef _LINUX_uPD4990A_H
-#define _LINUX_uPD4990A_H
-
-#include <asm/byteorder.h>
-
-#include <asm/upd4990a.h>
-
-/* Serial commands (4 bits) */
-#define UPD4990A_REGISTER_HOLD                 (0x0)
-#define UPD4990A_REGISTER_SHIFT                        (0x1)
-#define UPD4990A_TIME_SET_AND_COUNTER_HOLD     (0x2)
-#define UPD4990A_TIME_READ                     (0x3)
-#define UPD4990A_TP_64HZ                       (0x4)
-#define UPD4990A_TP_256HZ                      (0x5)
-#define UPD4990A_TP_2048HZ                     (0x6)
-#define UPD4990A_TP_4096HZ                     (0x7)
-#define UPD4990A_TP_1S                         (0x8)
-#define UPD4990A_TP_10S                                (0x9)
-#define UPD4990A_TP_30S                                (0xA)
-#define UPD4990A_TP_60S                                (0xB)
-#define UPD4990A_INTERRUPT_RESET               (0xC)
-#define UPD4990A_INTERRUPT_TIMER_START         (0xD)
-#define UPD4990A_INTERRUPT_TIMER_STOP          (0xE)
-#define UPD4990A_TEST_MODE_SET                 (0xF)
-
-/* Parallel commands (3 bits)
-   0-6 are same with serial commands.  */
-#define UPD4990A_PAR_SERIAL_MODE               7
-
-#ifndef UPD4990A_DELAY
-# include <linux/delay.h>
-# define UPD4990A_DELAY(usec)  udelay((usec))
-#endif
-#ifndef UPD4990A_OUTPUT_DATA
-# define UPD4990A_OUTPUT_DATA(bit)                     \
-       do {                                            \
-               UPD4990A_OUTPUT_DATA_CLK((bit), 0);     \
-               UPD4990A_DELAY(1); /* t-DSU */          \
-               UPD4990A_OUTPUT_DATA_CLK((bit), 1);     \
-               UPD4990A_DELAY(1); /* t-DHLD */ \
-       } while (0)
-#endif
-
-static __inline__ void upd4990a_serial_command(int command)
-{
-       UPD4990A_OUTPUT_DATA(command >> 0);
-       UPD4990A_OUTPUT_DATA(command >> 1);
-       UPD4990A_OUTPUT_DATA(command >> 2);
-       UPD4990A_OUTPUT_DATA(command >> 3);
-       UPD4990A_DELAY(1);      /* t-HLD */
-       UPD4990A_OUTPUT_STROBE(1);
-       UPD4990A_DELAY(1);      /* t-STB & t-d1 */
-       UPD4990A_OUTPUT_STROBE(0);
-       /* 19 microseconds extra delay is needed
-          iff previous mode is TIME READ command  */
-}
-
-struct upd4990a_raw_data {
-       u8      sec;            /* BCD */
-       u8      min;            /* BCD */
-       u8      hour;           /* BCD */
-       u8      mday;           /* BCD */
-#if   defined __LITTLE_ENDIAN_BITFIELD
-       unsigned wday :4;       /* 0-6 */
-       unsigned mon :4;        /* 1-based */
-#elif defined __BIG_ENDIAN_BITFIELD
-       unsigned mon :4;        /* 1-based */
-       unsigned wday :4;       /* 0-6 */
-#else
-# error Unknown bitfield endian!
-#endif
-       u8      year;           /* BCD */
-};
-
-static __inline__ void upd4990a_get_time(struct upd4990a_raw_data *buf,
-                                         int leave_register_hold)
-{
-       int byte;
-
-       upd4990a_serial_command(UPD4990A_TIME_READ);
-       upd4990a_serial_command(UPD4990A_REGISTER_SHIFT);
-       UPD4990A_DELAY(19);     /* t-d2 - t-d1 */
-
-       for (byte = 0; byte < 6; byte++) {
-               u8 tmp;
-               int bit;
-
-               for (tmp = 0, bit = 0; bit < 8; bit++) {
-                       tmp = (tmp | (UPD4990A_READ_DATA() << 8)) >> 1;
-                       UPD4990A_OUTPUT_CLK(1);
-                       UPD4990A_DELAY(1);
-                       UPD4990A_OUTPUT_CLK(0);
-                       UPD4990A_DELAY(1);
-               }
-               ((u8 *) buf)[byte] = tmp;
-       }
-
-       /* The uPD4990A users' manual says that we should issue `Register
-          Hold' command after each data retrieval, or next `Time Read'
-          command may not work correctly.  */
-       if (!leave_register_hold)
-               upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-}
-
-static __inline__ void upd4990a_set_time(const struct upd4990a_raw_data *data,
-                                         int time_set_only)
-{
-       int byte;
-
-       if (!time_set_only)
-               upd4990a_serial_command(UPD4990A_REGISTER_SHIFT);
-
-       for (byte = 0; byte < 6; byte++) {
-               int bit;
-               u8 tmp = ((const u8 *) data)[byte];
-
-               for (bit = 0; bit < 8; bit++, tmp >>= 1)
-                       UPD4990A_OUTPUT_DATA(tmp);
-       }
-
-       upd4990a_serial_command(UPD4990A_TIME_SET_AND_COUNTER_HOLD);
-
-       /* Release counter hold and start the clock.  */
-       if (!time_set_only)
-               upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-}
-
-#endif /* _LINUX_uPD4990A_H */
diff --git a/include/linux/vs_base.h b/include/linux/vs_base.h
new file mode 100644 (file)
index 0000000..52096ed
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef _VX_VS_BASE_H
+#define _VX_VS_BASE_H
+
+#include "vserver/context.h"
+
+
+#define vx_task_xid(t) ((t)->xid)
+
+#define vx_current_xid() vx_task_xid(current)
+
+#define vx_check(c,m)  __vx_check(vx_current_xid(),c,m)
+
+#define vx_weak_check(c,m)     ((m) ? vx_check(c,m) : 1)
+
+
+/*
+ * check current context for ADMIN/WATCH and
+ * optionally agains supplied argument
+ */
+static __inline__ int __vx_check(xid_t cid, xid_t id, unsigned int mode)
+{
+       if (mode & VX_ARG_MASK) {
+               if ((mode & VX_IDENT) &&
+                       (id == cid))
+                       return 1;
+       }
+       if (mode & VX_ATR_MASK) {
+               if ((mode & VX_DYNAMIC) &&
+                       (id >= MIN_D_CONTEXT) &&
+                       (id <= MAX_S_CONTEXT))
+                       return 1;
+               if ((mode & VX_STATIC) &&
+                       (id > 1) && (id < MIN_D_CONTEXT))
+                       return 1;
+       }
+       return (((mode & VX_ADMIN) && (cid == 0)) ||
+               ((mode & VX_WATCH) && (cid == 1)));
+}
+
+
+#define __vx_flags(v,m,f)      (((v) & (m)) ^ (f))
+
+#define        __vx_task_flags(t,m,f) \
+       (((t) && ((t)->vx_info)) ? \
+               __vx_flags((t)->vx_info->vx_flags,(m),(f)) : 0)
+
+#define vx_current_flags() \
+       ((current->vx_info) ? current->vx_info->vx_flags : 0)
+
+#define vx_flags(m,f)  __vx_flags(vx_current_flags(),(m),(f))
+
+
+#define vx_current_ccaps() \
+       ((current->vx_info) ? current->vx_info->vx_ccaps : 0)
+
+#define vx_ccaps(c)    (vx_current_ccaps() & (c))
+
+#define vx_current_bcaps() \
+       (((current->vx_info) && !vx_flags(VXF_STATE_SETUP, 0)) ? \
+       current->vx_info->vx_bcaps : cap_bset)
+
+
+/* generic flag merging */
+
+#define        vx_mask_flags(v,f,m)    (((v) & ~(m)) | ((f) & (m)))
+
+#define        vx_mask_mask(v,f,m)     (((v) & ~(m)) | ((v) & (f) & (m)))
+
+#endif
diff --git a/include/linux/vs_context.h b/include/linux/vs_context.h
new file mode 100644 (file)
index 0000000..541935b
--- /dev/null
@@ -0,0 +1,118 @@
+#ifndef _VX_VS_CONTEXT_H
+#define _VX_VS_CONTEXT_H
+
+
+#include <linux/kernel.h>
+#include <linux/rcupdate.h>
+#include <linux/sched.h>
+
+#include "vserver/context.h"
+#include "vserver/debug.h"
+
+
+extern int proc_pid_vx_info(struct task_struct *, char *);
+
+
+#define get_vx_info(i) __get_vx_info(i,__FILE__,__LINE__)
+
+static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
+       const char *_file, int _line)
+{
+       if (!vxi)
+               return NULL;
+       vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
+               vxi, vxi?vxi->vx_id:0, vxi?atomic_read(&vxi->vx_usecnt):0,
+               _file, _line);
+       atomic_inc(&vxi->vx_usecnt);
+       return vxi;
+}
+
+
+#define        free_vx_info(i) \
+       call_rcu(&i->vx_rcu, rcu_free_vx_info);
+
+#define put_vx_info(i) __put_vx_info(i,__FILE__,__LINE__)
+
+static inline void __put_vx_info(struct vx_info *vxi, const char *_file, int _line)
+{
+       if (!vxi)
+               return;
+       vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
+               vxi, vxi?vxi->vx_id:0, vxi?atomic_read(&vxi->vx_usecnt):0,
+               _file, _line);
+       if (atomic_dec_and_test(&vxi->vx_usecnt))
+               free_vx_info(vxi);
+}
+
+#define set_vx_info(p,i) __set_vx_info(p,i,__FILE__,__LINE__)
+
+static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
+       const char *_file, int _line)
+{
+       BUG_ON(*vxp);
+       if (!vxi)
+               return;
+       vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d.%d])",
+               vxi, vxi?vxi->vx_id:0,
+               vxi?atomic_read(&vxi->vx_usecnt):0,
+               vxi?atomic_read(&vxi->vx_refcnt):0,
+               _file, _line);
+       atomic_inc(&vxi->vx_refcnt);
+       *vxp = __get_vx_info(vxi, _file, _line);
+}
+
+#define        clr_vx_info(p)  __clr_vx_info(p,__FILE__,__LINE__)
+
+static inline void __clr_vx_info(struct vx_info **vxp,
+       const char *_file, int _line)
+{
+       struct vx_info *vxo = *vxp;
+
+       if (!vxo)
+               return;
+       vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d.%d])",
+               vxo, vxo?vxo->vx_id:0,
+               vxo?atomic_read(&vxo->vx_usecnt):0,
+               vxo?atomic_read(&vxo->vx_refcnt):0,
+               _file, _line);
+       *vxp = NULL;
+       wmb();
+       if (vxo && atomic_dec_and_test(&vxo->vx_refcnt))
+               unhash_vx_info(vxo);
+       __put_vx_info(vxo, _file, _line);
+}
+
+
+#define task_get_vx_info(i)    __task_get_vx_info(i,__FILE__,__LINE__)
+
+static __inline__ struct vx_info *__task_get_vx_info(struct task_struct *p,
+       const char *_file, int _line)
+{
+       struct vx_info *vxi;
+       
+       task_lock(p);
+       vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
+               p, _file, _line);
+       vxi = __get_vx_info(p->vx_info, _file, _line);
+       task_unlock(p);
+       return vxi;
+}
+
+
+#define vx_verify_info(p,i)    \
+       __vx_verify_info((p)->vx_info,i,__FILE__,__LINE__)
+
+static __inline__ void __vx_verify_info(
+       struct vx_info *vxa, struct vx_info *vxb,
+       const char *_file, int _line)
+{
+       if (vxa == vxb)
+               return;
+       printk(KERN_ERR "vx bad assumption (%p==%p) at %s:%d\n",
+               vxa, vxb, _file, _line);
+}
+
+
+#else
+#warning duplicate inclusion
+#endif
diff --git a/include/linux/vs_cvirt.h b/include/linux/vs_cvirt.h
new file mode 100644 (file)
index 0000000..07c3e86
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef _VX_VS_CVIRT_H
+#define _VX_VS_CVIRT_H
+
+#include "vserver/cvirt.h"
+#include "vserver/debug.h"
+#include "vs_base.h"
+
+
+/* utsname virtualization */
+
+static inline struct new_utsname *vx_new_utsname(void)
+{
+       if (current->vx_info)
+               return &current->vx_info->cvirt.utsname;
+       return &system_utsname;
+}
+
+#define vx_new_uts(x)          ((vx_new_utsname())->x)
+
+
+/* pid faking stuff */
+
+
+#define vx_map_tgid(v,p) \
+       __vx_map_tgid((v), (p), __FILE__, __LINE__)
+
+static inline int __vx_map_tgid(struct vx_info *vxi, int pid,
+       char *file, int line)
+{
+       if (vxi && __vx_flags(vxi->vx_flags, VXF_INFO_INIT, 0)) {
+               vxlprintk(VXD_CBIT(cvirt, 2),
+                       "vx_map_tgid: %p/%llx: %d -> %d",
+                       vxi, vxi->vx_flags, pid,
+                       (pid == vxi->vx_initpid)?1:pid,
+                       file, line);
+               if (pid == vxi->vx_initpid)
+                       return 1;
+       }
+       return pid;
+}
+
+#define vx_rmap_tgid(v,p) \
+       __vx_rmap_tgid((v), (p), __FILE__, __LINE__)
+
+static inline int __vx_rmap_tgid(struct vx_info *vxi, int pid,
+       char *file, int line)
+{
+       if (vxi && __vx_flags(vxi->vx_flags, VXF_INFO_INIT, 0)) {
+               vxlprintk(VXD_CBIT(cvirt, 2),
+                       "vx_rmap_tgid: %p/%llx: %d -> %d",
+                       vxi, vxi->vx_flags, pid,
+                       (pid == 1)?vxi->vx_initpid:pid,
+                       file, line);
+               if ((pid == 1) && vxi->vx_initpid)
+                       return vxi->vx_initpid;
+       }
+       return pid;
+}
+
+
+#else
+#warning duplicate inclusion
+#endif
diff --git a/include/linux/vs_dlimit.h b/include/linux/vs_dlimit.h
new file mode 100644 (file)
index 0000000..53400ab
--- /dev/null
@@ -0,0 +1,207 @@
+#ifndef _VX_VS_DLIMIT_H
+#define _VX_VS_DLIMIT_H
+
+#include <linux/kernel.h>
+#include <linux/rcupdate.h>
+#include <linux/sched.h>
+
+#include "vserver/context.h"
+#include "vserver/dlimit.h"
+#include "vserver/debug.h"
+
+
+#define get_dl_info(i) __get_dl_info(i,__FILE__,__LINE__)
+
+static inline struct dl_info *__get_dl_info(struct dl_info *dli,
+       const char *_file, int _line)
+{
+       if (!dli)
+               return NULL;
+       vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
+               dli, dli?dli->dl_xid:0, dli?atomic_read(&dli->dl_usecnt):0,
+               _file, _line);
+       atomic_inc(&dli->dl_usecnt);
+       return dli;
+}
+
+
+#define        free_dl_info(i) \
+       call_rcu(&i->dl_rcu, rcu_free_dl_info);
+
+#define put_dl_info(i) __put_dl_info(i,__FILE__,__LINE__)
+
+static inline void __put_dl_info(struct dl_info *dli,
+       const char *_file, int _line)
+{
+       if (!dli)
+               return;
+       vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
+               dli, dli?dli->dl_xid:0, dli?atomic_read(&dli->dl_usecnt):0,
+               _file, _line);
+       if (atomic_dec_and_test(&dli->dl_usecnt))
+               free_dl_info(dli);
+}
+
+
+#define        __dlimit_char(d)        ((d)?'*':' ')
+
+static inline int __dl_alloc_space(struct super_block *sb,
+       xid_t xid, dlsize_t nr, const char *file, int line)
+{
+       struct dl_info *dli = NULL;
+       int ret = 0;
+
+       if (nr == 0)
+               goto out;
+       dli = locate_dl_info(sb, xid);
+       if (!dli)
+               goto out;
+
+       spin_lock(&dli->dl_lock);
+       ret = (dli->dl_space_used + nr > dli->dl_space_total);
+       if (!ret)
+               dli->dl_space_used += nr;
+       spin_unlock(&dli->dl_lock);
+       put_dl_info(dli);
+out:
+       vxlprintk(VXD_CBIT(dlim, 1),
+               "ALLOC (%p,#%d)%c %lld bytes (%d)",
+               sb, xid, __dlimit_char(dli), nr, ret, file, line);
+       return ret;
+}
+
+static inline void __dl_free_space(struct super_block *sb,
+       xid_t xid, dlsize_t nr, const char *_file, int _line)
+{
+       struct dl_info *dli = NULL;
+
+       if (nr == 0)
+               goto out;
+       dli = locate_dl_info(sb, xid);
+       if (!dli)
+               goto out;
+
+       spin_lock(&dli->dl_lock);
+       if (dli->dl_space_used > nr)
+               dli->dl_space_used -= nr;
+       else
+               dli->dl_space_used = 0;
+       spin_unlock(&dli->dl_lock);
+       put_dl_info(dli);
+out:
+       vxlprintk(VXD_CBIT(dlim, 1),
+               "FREE  (%p,#%d)%c %lld bytes",
+               sb, xid, __dlimit_char(dli), nr, _file, _line);
+}
+
+static inline int __dl_alloc_inode(struct super_block *sb,
+       xid_t xid, const char *_file, int _line)
+{
+       struct dl_info *dli;
+       int ret = 0;
+
+       dli = locate_dl_info(sb, xid);
+       if (!dli)
+               goto out;
+
+       spin_lock(&dli->dl_lock);
+       ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
+       if (!ret)
+               dli->dl_inodes_used++;
+#if 0
+       else
+               printk("VSW: DLIMIT hit (%p,#%d), inode %d>=%d @ %s:%d\n",
+                       sb, xid,
+                       dli->dl_inodes_used, dli->dl_inodes_total,
+                       file, line);
+#endif
+       spin_unlock(&dli->dl_lock);
+       put_dl_info(dli);
+out:
+       vxlprintk(VXD_CBIT(dlim, 0),
+               "ALLOC (%p,#%d)%c inode (%d)",
+               sb, xid, __dlimit_char(dli), ret, _file, _line);
+       return ret;
+}
+
+static inline void __dl_free_inode(struct super_block *sb,
+       xid_t xid, const char *_file, int _line)
+{
+       struct dl_info *dli;
+
+       dli = locate_dl_info(sb, xid);
+       if (!dli)
+               goto out;
+
+       spin_lock(&dli->dl_lock);
+       if (dli->dl_inodes_used > 1)
+               dli->dl_inodes_used--;
+       else
+               dli->dl_inodes_used = 0;
+       spin_unlock(&dli->dl_lock);
+       put_dl_info(dli);
+out:
+       vxlprintk(VXD_CBIT(dlim, 0),
+               "FREE  (%p,#%d)%c inode",
+               sb, xid, __dlimit_char(dli), _file, _line);
+}
+
+static inline void __dl_adjust_block(struct super_block *sb, xid_t xid,
+       unsigned int *free_blocks, unsigned int *root_blocks,
+       const char *_file, int _line)
+{
+       struct dl_info *dli;
+       uint64_t broot, bfree;
+
+       dli = locate_dl_info(sb, xid);
+       if (!dli)
+               return;
+
+       spin_lock(&dli->dl_lock);
+       broot = (dli->dl_space_total -
+               (dli->dl_space_total >> 10) * dli->dl_nrlmult)
+               >> sb->s_blocksize_bits;
+       bfree = (dli->dl_space_total - dli->dl_space_used)
+                       >> sb->s_blocksize_bits;
+       spin_unlock(&dli->dl_lock);
+
+       vxlprintk(VXD_CBIT(dlim, 2),
+               "ADJUST: %lld,%lld on %d,%d [mult=%d]",
+               bfree, broot, *free_blocks, *root_blocks,
+               dli->dl_nrlmult, _file, _line);
+       if (free_blocks) {
+               if (*free_blocks > bfree)
+                       *free_blocks = bfree;
+       }
+       if (root_blocks) {
+               if (*root_blocks > broot)
+                       *root_blocks = broot;
+       }
+       put_dl_info(dli);
+}
+
+
+#define DLIMIT_ALLOC_BLOCK(sb, xid, nr) \
+       __dl_alloc_space(sb, xid, \
+               ((dlsize_t)(nr)) << (sb)->s_blocksize_bits, \
+               __FILE__, __LINE__ )
+
+#define DLIMIT_FREE_BLOCK(sb, xid, nr) \
+       __dl_free_space(sb, xid, \
+               ((dlsize_t)(nr)) << (sb)->s_blocksize_bits, \
+               __FILE__, __LINE__ )
+
+#define DLIMIT_ALLOC_INODE(sb, xid) \
+       __dl_alloc_inode(sb, xid, __FILE__, __LINE__ )
+
+#define DLIMIT_FREE_INODE(sb, xid) \
+       __dl_free_inode(sb, xid, __FILE__, __LINE__ )
+
+
+#define        DLIMIT_ADJUST_BLOCK(sb, xid, fb, rb) \
+       __dl_adjust_block(sb, xid, fb, rb, __FILE__, __LINE__ )
+
+
+#else
+#warning duplicate inclusion
+#endif
diff --git a/include/linux/vs_limit.h b/include/linux/vs_limit.h
new file mode 100644 (file)
index 0000000..ce08194
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef _VX_VS_LIMIT_H
+#define _VX_VS_LIMIT_H
+
+#include <linux/kernel.h>
+#include <linux/rcupdate.h>
+#include <linux/sched.h>
+
+#include "vserver/context.h"
+#include "vserver/limit.h"
+#include "vserver/debug.h"
+
+
+/* file limits */
+
+
+static inline void __vx_acc_cres(struct vx_info *vxi,
+       int res, int dir, void *_data, char *_file, int _line)
+{
+       if (VXD_RLIMIT(res, RLIMIT_NOFILE) ||
+               VXD_RLIMIT(res, RLIMIT_NPROC) ||
+               VXD_RLIMIT(res, VLIMIT_NSOCK))
+               vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5d%s (%p)",
+                       (vxi?vxi->vx_id:-1), vlimit_name[res], res,
+                       (vxi?atomic_read(&vxi->limit.rcur[res]):0),
+                       (dir>0)?"++":"--", _data, _file, _line);
+        if (vxi) {
+                if (dir > 0)
+                        atomic_inc(&vxi->limit.rcur[res]);
+                else
+                        atomic_dec(&vxi->limit.rcur[res]);
+        }
+}
+
+#define vx_acc_cres(v,d,p,r) \
+       __vx_acc_cres((v), (r), (d), (p), __FILE__, __LINE__)
+
+#define vx_nproc_inc(p)        \
+       vx_acc_cres(current->vx_info, 1, (p), RLIMIT_NPROC)
+#define vx_nproc_dec(p)        \
+       vx_acc_cres(current->vx_info,-1, (p), RLIMIT_NPROC)
+
+#define vx_files_inc(f)        \
+       vx_acc_cres(current->vx_info, 1, (f), RLIMIT_NOFILE)
+#define vx_files_dec(f)        \
+       vx_acc_cres(current->vx_info,-1, (f), RLIMIT_NOFILE)
+
+/*
+#define vx_openfd_inc(f) do {                                  \
+       vx_acc_cres(current->vx_info, 1, RLIMIT_OPENFD);        \
+       printk("vx_openfd_inc: %d[#%d] in %s:%d\n",             \
+               f, current->xid, __FILE__, __LINE__);           \
+       } while (0)
+
+#define vx_openfd_dec(f) do {                                  \
+       vx_acc_cres(current->vx_info,-1, RLIMIT_OPENFD);        \
+       printk("vx_openfd_dec: %d[#%d] in %s:%d\n",             \
+               f, current->xid, __FILE__, __LINE__);           \
+       } while (0)
+*/
+
+#define vx_cres_avail(v,n,r) \
+        __vx_cres_avail((v), (r), (n), __FILE__, __LINE__)
+
+static inline int __vx_cres_avail(struct vx_info *vxi,
+                int res, int num, char *_file, int _line)
+{
+       unsigned long value;
+
+       if (VXD_RLIMIT(res, RLIMIT_NOFILE) ||
+               VXD_RLIMIT(res, RLIMIT_NPROC) ||
+               VXD_RLIMIT(res, VLIMIT_NSOCK))
+               vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d",
+                        (vxi?vxi->vx_id:-1), vlimit_name[res], res,
+                       (vxi?vxi->limit.rlim[res]:1),
+                        (vxi?atomic_read(&vxi->limit.rcur[res]):0),
+                       num, _file, _line);
+        if (!vxi)
+                return 1;
+       value = atomic_read(&vxi->limit.rcur[res]);     
+       if (value > vxi->limit.rmax[res])
+               vxi->limit.rmax[res] = value;
+        if (vxi->limit.rlim[res] == RLIM_INFINITY)
+                return 1;
+        if (value + num <= vxi->limit.rlim[res])
+                return 1;
+       atomic_inc(&vxi->limit.lhit[res]);
+        return 0;
+}
+
+#define vx_nproc_avail(n) \
+       vx_cres_avail(current->vx_info, (n), RLIMIT_NPROC)
+
+#define vx_files_avail(n) \
+       vx_cres_avail(current->vx_info, (n), RLIMIT_NOFILE)
+
+
+/* socket limits */
+
+#define vx_sock_inc(s) \
+       vx_acc_cres((s)->sk_vx_info, 1, (s), VLIMIT_NSOCK)
+#define vx_sock_dec(s) \
+       vx_acc_cres((s)->sk_vx_info,-1, (s), VLIMIT_NSOCK)
+
+#define vx_sock_avail(n) \
+       vx_cres_avail(current->vx_info, (n), VLIMIT_NSOCK)
+
+#else
+#warning duplicate inclusion
+#endif
diff --git a/include/linux/vs_memory.h b/include/linux/vs_memory.h
new file mode 100644 (file)
index 0000000..3bcfefd
--- /dev/null
@@ -0,0 +1,127 @@
+#ifndef _VX_VS_MEMORY_H
+#define _VX_VS_MEMORY_H
+
+#include <linux/kernel.h>
+#include <linux/rcupdate.h>
+#include <linux/sched.h>
+
+#include "vserver/context.h"
+#include "vserver/limit.h"
+#include "vserver/debug.h"
+
+
+#define vx_acc_page(m, d, v, r) \
+       __vx_acc_page(&(m->v), m->mm_vx_info, r, d, __FILE__, __LINE__)
+
+static inline void __vx_acc_page(unsigned long *v, struct vx_info *vxi,
+                int res, int dir, char *file, int line)
+{
+       if (VXD_RLIMIT(res, RLIMIT_RSS) ||
+               VXD_RLIMIT(res, RLIMIT_AS) ||
+               VXD_RLIMIT(res, RLIMIT_MEMLOCK))
+               vxlprintk(1, "vx_acc_page[%5d,%s,%2d]: %5d%s",
+                       (vxi?vxi->vx_id:-1), vlimit_name[res], res,
+                       (vxi?atomic_read(&vxi->limit.rcur[res]):0),
+                       (dir?"++":"--"), file, line);
+        if (v) {
+                if (dir > 0)
+                        ++(*v);
+                else
+                        --(*v);
+        }
+        if (vxi) {
+                if (dir > 0)
+                        atomic_inc(&vxi->limit.rcur[res]);
+                else
+                        atomic_dec(&vxi->limit.rcur[res]);
+        }
+}
+
+
+#define vx_acc_pages(m, p, v, r) \
+       __vx_acc_pages(&(m->v), m->mm_vx_info, r, p, __FILE__, __LINE__)
+
+static inline void __vx_acc_pages(unsigned long *v, struct vx_info *vxi,
+                int res, int pages, char *_file, int _line)
+{
+       if (VXD_RLIMIT(res, RLIMIT_RSS) ||
+               VXD_RLIMIT(res, RLIMIT_AS) ||
+               VXD_RLIMIT(res, RLIMIT_MEMLOCK))
+               vxlprintk(1, "vx_acc_pages[%5d,%s,%2d]: %5d += %5d",
+                       (vxi?vxi->vx_id:-1), vlimit_name[res], res,
+                       (vxi?atomic_read(&vxi->limit.rcur[res]):0),
+                       pages, _file, _line);
+        if (pages == 0)
+                return;
+        if (v)
+                *v += pages;
+        if (vxi)
+                atomic_add(pages, &vxi->limit.rcur[res]);
+}
+
+
+
+#define vx_acc_vmpage(m,d)     vx_acc_page(m, d, total_vm,  RLIMIT_AS)
+#define vx_acc_vmlpage(m,d)    vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
+#define vx_acc_rsspage(m,d)    vx_acc_page(m, d, rss,      RLIMIT_RSS)
+
+#define vx_acc_vmpages(m,p)    vx_acc_pages(m, p, total_vm,  RLIMIT_AS)
+#define vx_acc_vmlpages(m,p)   vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
+#define vx_acc_rsspages(m,p)   vx_acc_pages(m, p, rss,       RLIMIT_RSS)
+
+#define vx_pages_add(s,r,p)    __vx_acc_pages(0, s, r, p, __FILE__, __LINE__)
+#define vx_pages_sub(s,r,p)    vx_pages_add(s, r, -(p))
+
+#define vx_vmpages_inc(m)      vx_acc_vmpage(m, 1)
+#define vx_vmpages_dec(m)      vx_acc_vmpage(m,-1)
+#define vx_vmpages_add(m,p)    vx_acc_vmpages(m, p)
+#define vx_vmpages_sub(m,p)    vx_acc_vmpages(m,-(p))
+
+#define vx_vmlocked_inc(m)     vx_acc_vmlpage(m, 1)
+#define vx_vmlocked_dec(m)     vx_acc_vmlpage(m,-1)
+#define vx_vmlocked_add(m,p)   vx_acc_vmlpages(m, p)
+#define vx_vmlocked_sub(m,p)   vx_acc_vmlpages(m,-(p))
+
+#define vx_rsspages_inc(m)     vx_acc_rsspage(m, 1)
+#define vx_rsspages_dec(m)     vx_acc_rsspage(m,-1)
+#define vx_rsspages_add(m,p)   vx_acc_rsspages(m, p)
+#define vx_rsspages_sub(m,p)   vx_acc_rsspages(m,-(p))
+
+
+
+#define vx_pages_avail(m, p, r) \
+        __vx_pages_avail((m)->mm_vx_info, (r), (p), __FILE__, __LINE__)
+
+static inline int __vx_pages_avail(struct vx_info *vxi,
+                int res, int pages, char *_file, int _line)
+{
+       unsigned long value;
+
+       if (VXD_RLIMIT(res, RLIMIT_RSS) ||
+               VXD_RLIMIT(res, RLIMIT_AS) ||
+               VXD_RLIMIT(res, RLIMIT_MEMLOCK))
+               vxlprintk(1, "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d",
+                        (vxi?vxi->vx_id:-1), vlimit_name[res], res,
+                       (vxi?vxi->limit.rlim[res]:1),
+                        (vxi?atomic_read(&vxi->limit.rcur[res]):0),
+                       pages, _file, _line);
+        if (!vxi)
+                return 1;
+       value = atomic_read(&vxi->limit.rcur[res]);     
+       if (value > vxi->limit.rmax[res])
+               vxi->limit.rmax[res] = value;
+        if (vxi->limit.rlim[res] == RLIM_INFINITY)
+                return 1;
+        if (value + pages <= vxi->limit.rlim[res])
+                return 1;
+       atomic_inc(&vxi->limit.lhit[res]);
+        return 0;
+}
+
+#define vx_vmpages_avail(m,p)  vx_pages_avail(m, p, RLIMIT_AS)
+#define vx_vmlocked_avail(m,p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
+#define vx_rsspages_avail(m,p) vx_pages_avail(m, p, RLIMIT_RSS)
+
+#else
+#warning duplicate inclusion
+#endif
diff --git a/include/linux/vs_network.h b/include/linux/vs_network.h
new file mode 100644 (file)
index 0000000..915ad17
--- /dev/null
@@ -0,0 +1,145 @@
+#ifndef _NX_VS_NETWORK_H
+#define _NX_VS_NETWORK_H
+
+#include <linux/kernel.h>
+#include <linux/rcupdate.h>
+#include <linux/sched.h>
+
+#include "vserver/network.h"
+#include "vserver/debug.h"
+
+
+extern int proc_pid_nx_info(struct task_struct *, char *);
+
+
+#define get_nx_info(i) __get_nx_info(i,__FILE__,__LINE__)
+
+static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
+       const char *_file, int _line)
+{
+       if (!nxi)
+               return NULL;
+       vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
+               nxi, nxi?nxi->nx_id:0, nxi?atomic_read(&nxi->nx_usecnt):0,
+               _file, _line);
+       atomic_inc(&nxi->nx_usecnt);
+       return nxi;
+}
+
+
+#define        free_nx_info(i) \
+       call_rcu(&i->nx_rcu, rcu_free_nx_info);
+
+#define put_nx_info(i) __put_nx_info(i,__FILE__,__LINE__)
+
+static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
+{
+       if (!nxi)
+               return;
+       vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
+               nxi, nxi?nxi->nx_id:0, nxi?atomic_read(&nxi->nx_usecnt):0,
+               _file, _line);
+       if (atomic_dec_and_test(&nxi->nx_usecnt))
+               free_nx_info(nxi);
+}
+
+
+#define set_nx_info(p,i) __set_nx_info(p,i,__FILE__,__LINE__)
+
+static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
+       const char *_file, int _line)
+{
+       BUG_ON(*nxp);
+       if (!nxi)
+               return;
+       vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d.%d])",
+               nxi, nxi?nxi->nx_id:0,
+               nxi?atomic_read(&nxi->nx_usecnt):0,
+               nxi?atomic_read(&nxi->nx_refcnt):0,
+               _file, _line);
+       atomic_inc(&nxi->nx_refcnt);
+       *nxp = __get_nx_info(nxi, _file, _line);
+}
+
+#define        clr_nx_info(p)  __clr_nx_info(p,__FILE__,__LINE__)
+
+static inline void __clr_nx_info(struct nx_info **nxp,
+       const char *_file, int _line)
+{
+       struct nx_info *nxo = *nxp;
+
+       if (!nxo)
+               return;
+       vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d.%d])",
+               nxo, nxo?nxo->nx_id:0,
+               nxo?atomic_read(&nxo->nx_usecnt):0,
+               nxo?atomic_read(&nxo->nx_refcnt):0,
+               _file, _line);
+       *nxp = NULL;
+       wmb();
+       if (nxo && atomic_dec_and_test(&nxo->nx_refcnt))
+               unhash_nx_info(nxo);
+       __put_nx_info(nxo, _file, _line);
+}
+
+
+#define task_get_nx_info(i)    __task_get_nx_info(i,__FILE__,__LINE__)
+
+static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
+       const char *_file, int _line)
+{
+       struct nx_info *nxi;
+       
+       task_lock(p);
+       nxi = __get_nx_info(p->nx_info, _file, _line);
+       vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
+               p, _file, _line);
+       task_unlock(p);
+       return nxi;
+}
+
+#define nx_verify_info(p,i)    \
+       __nx_verify_info((p)->nx_info,i,__FILE__,__LINE__)
+
+static __inline__ void __nx_verify_info(
+       struct nx_info *ipa, struct nx_info *ipb,
+       const char *_file, int _line)
+{
+       if (ipa == ipb)
+               return;
+       printk(KERN_ERR "ip bad assumption (%p==%p) at %s:%d\n",
+               ipa, ipb, _file, _line);
+}
+
+
+#define nx_task_nid(t) ((t)->nid)
+
+#define nx_current_nid() nx_task_nid(current)
+
+#define nx_check(c,m)  __nx_check(nx_current_nid(),c,m)
+
+#define nx_weak_check(c,m)     ((m) ? nx_check(c,m) : 1)
+
+
+#define __nx_flags(v,m,f)      (((v) & (m)) ^ (f))
+
+#define        __nx_task_flags(t,m,f) \
+       (((t) && ((t)->nx_info)) ? \
+               __nx_flags((t)->nx_info->nx_flags,(m),(f)) : 0)
+
+#define nx_current_flags() \
+       ((current->nx_info) ? current->nx_info->nx_flags : 0)
+
+#define nx_flags(m,f)  __nx_flags(nx_current_flags(),(m),(f))
+
+
+#define nx_current_ncaps() \
+       ((current->nx_info) ? current->nx_info->nx_ncaps : 0)
+
+#define nx_ncaps(c)    (nx_current_ncaps() & (c))
+
+
+
+#else
+#warning duplicate inclusion
+#endif
diff --git a/include/linux/vs_socket.h b/include/linux/vs_socket.h
new file mode 100644 (file)
index 0000000..560f2eb
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef _VX_VS_SOCKET_H
+#define _VX_VS_SOCKET_H
+
+
+// #define VX_DEBUG
+
+#include <linux/kernel.h>
+#include <linux/rcupdate.h>
+#include <linux/sched.h>
+
+#include "vserver/context.h"
+#include "vserver/network.h"
+#include "vserver/debug.h"
+
+
+/* socket accounting */
+
+#include <linux/socket.h>
+
+static inline int vx_sock_type(int family)
+{
+       int type = 4;
+
+       if (family > 0 && family < 3)
+               type = family;
+       else if (family == PF_INET6)
+               type = 3;
+       return type;
+}
+
+#define vx_acc_sock(v,f,p,s) \
+       __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
+
+static inline void __vx_acc_sock(struct vx_info *vxi,
+       int family, int pos, int size, char *file, int line)
+{
+        if (vxi) {
+               int type = vx_sock_type(family);
+
+               atomic_inc(&vxi->cacct.sock[type][pos].count);
+               atomic_add(size, &vxi->cacct.sock[type][pos].total);
+        }
+}
+
+#define vx_sock_recv(sk,s) \
+       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, (s))
+#define vx_sock_send(sk,s) \
+       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, (s))
+#define vx_sock_fail(sk,s) \
+       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
+
+
+#define        sock_vx_init(s)  do {           \
+       (s)->sk_xid = 0;                \
+       (s)->sk_vx_info = NULL;         \
+       } while (0)
+
+#define        sock_nx_init(s)  do {           \
+       (s)->sk_nid = 0;                \
+       (s)->sk_nx_info = NULL;         \
+       } while (0)
+
+
+#else
+#warning duplicate inclusion
+#endif
diff --git a/include/linux/vserver.h b/include/linux/vserver.h
new file mode 100644 (file)
index 0000000..db88b5e
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _LINUX_VSERVER_H
+#define _LINUX_VSERVER_H
+
+#include <linux/vserver/context.h>
+#include <linux/vserver/network.h>
+
+extern long vs_reboot(unsigned int, void *);
+
+#define hlist_for_each_rcu(pos, head) \
+       for (pos = (head)->first; pos && ({ prefetch(pos->next); 1;}); \
+               pos = pos->next, ({ smp_read_barrier_depends(); 0;}))
+
+#endif
diff --git a/include/linux/vserver/context.h b/include/linux/vserver/context.h
new file mode 100644 (file)
index 0000000..434bfba
--- /dev/null
@@ -0,0 +1,181 @@
+#ifndef _VX_CONTEXT_H
+#define _VX_CONTEXT_H
+
+#include <linux/types.h>
+
+#define MAX_S_CONTEXT  65535   /* Arbitrary limit */
+#define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
+
+#define VX_DYNAMIC_ID  ((uint32_t)-1)          /* id for dynamic context */
+
+#ifdef __KERNEL__
+
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/rcupdate.h>
+
+#define _VX_INFO_DEF_
+#include "cvirt.h"
+#include "limit.h"
+#include "sched.h"
+#undef _VX_INFO_DEF_
+
+struct vx_info {
+       struct hlist_node vx_hlist;             /* linked list of contexts */
+       struct rcu_head vx_rcu;                 /* the rcu head */
+       xid_t vx_id;                            /* context id */
+       atomic_t vx_usecnt;                     /* usage count */
+       atomic_t vx_refcnt;                     /* reference count */
+       struct vx_info *vx_parent;              /* parent context */
+
+       struct namespace *vx_namespace;         /* private namespace */
+       struct fs_struct *vx_fs;                /* private namespace fs */
+       uint64_t vx_flags;                      /* VX_INFO_xxx */
+       uint64_t vx_bcaps;                      /* bounding caps (system) */
+       uint64_t vx_ccaps;                      /* context caps (vserver) */
+
+       pid_t vx_initpid;                       /* PID of fake init process */
+
+       struct _vx_limit limit;                 /* vserver limits */
+       struct _vx_sched sched;                 /* vserver scheduler */
+       struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
+       struct _vx_cacct cacct;                 /* context accounting */
+
+       char vx_name[65];                       /* vserver name */
+};
+
+
+#define VX_ADMIN       0x0001
+#define VX_WATCH       0x0002
+#define VX_DUMMY       0x0008
+
+#define VX_IDENT       0x0010
+#define VX_EQUIV       0x0020
+#define VX_PARENT      0x0040
+#define VX_CHILD       0x0080
+
+#define VX_ARG_MASK    0x00F0
+
+#define VX_DYNAMIC     0x0100
+#define VX_STATIC      0x0200
+
+#define VX_ATR_MASK    0x0F00
+
+
+struct rcu_head;
+
+extern void rcu_free_vx_info(struct rcu_head *);
+extern void unhash_vx_info(struct vx_info *);
+
+extern struct vx_info *locate_vx_info(int);
+extern struct vx_info *locate_or_create_vx_info(int);
+
+extern int get_xid_list(int, unsigned int *, int);
+extern int vx_info_is_hashed(xid_t);
+
+extern int vx_migrate_task(struct task_struct *, struct vx_info *);
+
+#endif /* __KERNEL__ */
+
+#include "switch.h"
+
+/* vinfo commands */
+
+#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
+#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
+
+#ifdef __KERNEL__
+extern int vc_task_xid(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
+#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
+
+struct  vcmd_vx_info_v0 {
+       uint32_t xid;
+       uint32_t initpid;
+       /* more to come */      
+};
+
+#ifdef __KERNEL__
+extern int vc_vx_info(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_ctx_create                VC_CMD(VPROC, 1, 0)
+#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 0)
+
+#ifdef __KERNEL__
+extern int vc_ctx_create(uint32_t, void __user *);
+extern int vc_ctx_migrate(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
+#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
+
+struct  vcmd_ctx_flags_v0 {
+       uint64_t flagword;
+       uint64_t mask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_cflags(uint32_t, void __user *);
+extern int vc_set_cflags(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VXF_INFO_LOCK          0x00000001
+#define VXF_INFO_SCHED         0x00000002
+#define VXF_INFO_NPROC         0x00000004
+#define VXF_INFO_PRIVATE       0x00000008
+
+#define VXF_INFO_INIT          0x00000010
+#define VXF_INFO_HIDE          0x00000020
+#define VXF_INFO_ULIMIT                0x00000040
+#define VXF_INFO_NSPACE                0x00000080
+
+#define VXF_SCHED_HARD         0x00000100
+#define VXF_SCHED_PRIO         0x00000200
+#define VXF_SCHED_PAUSE                0x00000400
+
+#define VXF_VIRT_MEM           0x00010000
+#define VXF_VIRT_UPTIME                0x00020000
+#define VXF_VIRT_CPU           0x00040000
+
+#define VXF_HIDE_MOUNT         0x01000000
+#define VXF_HIDE_NETIF         0x02000000
+
+#define VXF_STATE_SETUP                (1ULL<<32)
+#define VXF_STATE_INIT         (1ULL<<33)
+
+#define        VXF_FORK_RSS            (1ULL<<48)
+#define        VXF_PROLIFIC            (1ULL<<49)
+
+#define VXF_ONE_TIME           (0x0003ULL<<32)
+
+#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 0)
+#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 0)
+
+struct  vcmd_ctx_caps_v0 {
+       uint64_t bcaps;
+       uint64_t ccaps;
+       uint64_t cmask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_ccaps(uint32_t, void __user *);
+extern int vc_set_ccaps(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VXC_SET_UTSNAME                0x00000001
+#define VXC_SET_RLIMIT         0x00000002
+
+#define VXC_RAW_ICMP           0x00000100
+
+#define VXC_SECURE_MOUNT       0x00010000
+
+
+#endif /* _VX_CONTEXT_H */
diff --git a/include/linux/vserver/cvirt.h b/include/linux/vserver/cvirt.h
new file mode 100644 (file)
index 0000000..7beeaaa
--- /dev/null
@@ -0,0 +1,146 @@
+/* _VX_CVIRT_H defined below */
+
+#if    defined(__KERNEL__) && defined(_VX_INFO_DEF_)
+
+#include <linux/utsname.h>
+#include <linux/rwsem.h>
+#include <linux/jiffies.h>
+#include <linux/time.h>
+#include <asm/atomic.h>
+
+/* context sub struct */
+
+struct _vx_cvirt {
+       int max_threads;
+
+       struct timespec bias_idle;
+       uint64_t bias_jiffies;
+
+       struct new_utsname utsname;
+};
+
+struct sock_acc {
+       atomic_t count;
+       atomic_t total;
+};
+
+struct _vx_cacct {
+       atomic_t nr_threads;
+       int nr_running;
+
+       unsigned long total_forks;
+
+       struct sock_acc sock[5][3];
+};
+
+
+static inline long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
+{
+       return atomic_read(&cacct->sock[type][pos].count);
+}
+
+
+static inline long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
+{
+       return atomic_read(&cacct->sock[type][pos].total);
+}
+
+
+extern uint64_t vx_idle_jiffies(void);
+
+static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
+{
+       uint64_t idle_jiffies = vx_idle_jiffies();
+
+       cvirt->bias_jiffies = get_jiffies_64();
+       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
+
+       down_read(&uts_sem);
+       cvirt->utsname = system_utsname;
+       up_read(&uts_sem);
+}
+
+static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
+{
+       return;
+}
+
+static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
+{
+       int i,j;
+
+       atomic_set(&cacct->nr_threads, 1);
+       for (i=0; i<5; i++) {
+               for (j=0; j<3; j++) {
+                       atomic_set(&cacct->sock[i][j].count, 0);
+                       atomic_set(&cacct->sock[i][j].total, 0);
+               }
+       }
+}
+
+static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
+{
+       return;
+}
+
+static inline int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
+{
+       int length = 0;
+       length += sprintf(buffer + length,
+               "BiasJiffies:\t%lld\n", (long long int)cvirt->bias_jiffies);
+       length += sprintf(buffer + length,
+               "SysName:\t%.*s\n"
+               "NodeName:\t%.*s\n"
+               "Release:\t%.*s\n"
+               "Version:\t%.*s\n"
+               "Machine:\t%.*s\n"
+               "DomainName:\t%.*s\n"
+               ,__NEW_UTS_LEN, cvirt->utsname.sysname
+               ,__NEW_UTS_LEN, cvirt->utsname.nodename
+               ,__NEW_UTS_LEN, cvirt->utsname.release
+               ,__NEW_UTS_LEN, cvirt->utsname.version
+               ,__NEW_UTS_LEN, cvirt->utsname.machine
+               ,__NEW_UTS_LEN, cvirt->utsname.domainname
+               );
+       return length;
+}
+
+static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
+{
+       int i,j, length = 0;
+       static char *type[] = { "UNSPEC", "UNIX", "INET", "INET6", "OTHER" };
+
+       for (i=0; i<5; i++) {
+               length += sprintf(buffer + length,
+                       "%s:", type[i]);
+               for (j=0; j<3; j++) {
+                       length += sprintf(buffer + length,
+                               "\t%12lu/%-12lu"
+                               ,vx_sock_count(cacct, i, j)
+                               ,vx_sock_total(cacct, i, j)
+                               );
+               }       
+               buffer[length++] = '\n';
+       }
+       return length;
+}
+
+#else  /* _VX_INFO_DEF_ */
+#ifndef _VX_CVIRT_H
+#define _VX_CVIRT_H
+
+#include "switch.h"
+
+/*  cvirt vserver commands */
+
+
+#ifdef __KERNEL__
+
+struct timespec;
+
+void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle);
+
+#endif /* __KERNEL__ */
+
+#endif /* _VX_CVIRT_H */
+#endif
diff --git a/include/linux/vserver/debug.h b/include/linux/vserver/debug.h
new file mode 100644 (file)
index 0000000..15b52c9
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef _VX_DEBUG_H
+#define _VX_DEBUG_H
+
+
+extern unsigned int vx_debug_switch;
+extern unsigned int vx_debug_xid;
+extern unsigned int vx_debug_nid;
+extern unsigned int vx_debug_net;
+extern unsigned int vx_debug_limit;
+extern unsigned int vx_debug_dlim;
+extern unsigned int vx_debug_cvirt;
+
+
+#define        VXD_CBIT(n,m)   (vx_debug_ ## n & (1 << (m)))
+#define        VXD_CMIN(n,m)   (vx_debug_ ## n > (m))
+#define        VXD_MASK(n,m)   (vx_debug_ ## n & (m))
+
+// #define     VXD_HERE        __FILE__, __LINE__
+
+
+#ifdef CONFIG_VSERVER_DEBUG
+
+#define        VX_LOGLEVEL     "vxD: "
+
+#define vxdprintk(c,f,x...)                                    \
+       do {                                                    \
+               if (c)                                          \
+                       printk(VX_LOGLEVEL f "\n", x);          \
+       } while (0)     
+
+#define vxlprintk(c,f,x...)                                    \
+       do {                                                    \
+               if (c)                                          \
+                       printk(VX_LOGLEVEL f " @%s:%d\n", x);   \
+       } while (0)     
+
+#else
+
+#define vxdprintk(x...)        do { } while (0)
+#define vxlprintk(x...)        do { } while (0)
+
+#endif
+
+
+
+#endif /* _VX_DEBUG_H */
diff --git a/include/linux/vserver/dlimit.h b/include/linux/vserver/dlimit.h
new file mode 100644 (file)
index 0000000..c0cfafc
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef _VX_DLIMIT_H
+#define _VX_DLIMIT_H
+
+#include "switch.h"
+#include <linux/spinlock.h>
+
+/*  inode vserver commands */
+
+#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
+#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
+
+#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
+#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
+
+
+struct  vcmd_ctx_dlimit_base_v0 {
+       const char __user *name;
+       uint32_t flags;
+};
+
+struct  vcmd_ctx_dlimit_v0 {
+       const char __user *name;
+       uint32_t space_used;                    /* used space in kbytes */
+       uint32_t space_total;                   /* maximum space in kbytes */
+       uint32_t inodes_used;                   /* used inodes */
+       uint32_t inodes_total;                  /* maximum inodes */
+       uint32_t reserved;                      /* reserved for root in % */
+       uint32_t flags;
+};
+
+#define CDLIM_UNSET             (0ULL)
+#define CDLIM_INFINITY          (~0ULL)
+#define CDLIM_KEEP              (~1ULL)
+
+
+#ifdef __KERNEL__
+
+struct super_block;
+
+struct dl_info {
+       struct hlist_node dl_hlist;             /* linked list of contexts */
+       struct rcu_head dl_rcu;                 /* the rcu head */
+       xid_t dl_xid;                           /* context id */
+       atomic_t dl_usecnt;                     /* usage count */
+       atomic_t dl_refcnt;                     /* reference count */
+
+       struct super_block *dl_sb;              /* associated superblock */
+
+//     struct rw_semaphore dl_sem;             /* protect the values */
+       spinlock_t dl_lock;                     /* protect the values */
+
+       uint64_t dl_space_used;                 /* used space in bytes */
+       uint64_t dl_space_total;                /* maximum space in bytes */
+       uint32_t dl_inodes_used;                /* used inodes */
+       uint32_t dl_inodes_total;               /* maximum inodes */
+
+       unsigned int dl_nrlmult;                /* non root limit mult */
+};
+
+struct rcu_head;
+
+extern void rcu_free_dl_info(struct rcu_head *);
+extern void unhash_dl_info(struct dl_info *);
+
+extern struct dl_info *locate_dl_info(struct super_block *, xid_t);
+
+
+struct kstatfs;
+
+extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
+
+
+extern int vc_add_dlimit(uint32_t, void __user *);
+extern int vc_rem_dlimit(uint32_t, void __user *);
+
+extern int vc_set_dlimit(uint32_t, void __user *);
+extern int vc_get_dlimit(uint32_t, void __user *);
+
+
+typedef        uint64_t dlsize_t;
+
+
+#endif /* __KERNEL__ */
+
+#endif /* _VX_DLIMIT_H */
diff --git a/include/linux/vserver/inode.h b/include/linux/vserver/inode.h
new file mode 100644 (file)
index 0000000..fc49aba
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef _VX_INODE_H
+#define _VX_INODE_H
+
+#include "switch.h"
+
+/*  inode vserver commands */
+
+#define VCMD_get_iattr_v0      VC_CMD(INODE, 1, 0)
+#define VCMD_set_iattr_v0      VC_CMD(INODE, 2, 0)
+
+#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
+#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
+
+struct  vcmd_ctx_iattr_v0 {
+       /* device handle in id */
+       uint64_t ino;
+       uint32_t xid;
+       uint32_t flags;
+       uint32_t mask;
+};
+
+struct  vcmd_ctx_iattr_v1 {
+       const char __user *name;
+       uint32_t xid;
+       uint32_t flags;
+       uint32_t mask;
+};
+
+
+#define IATTR_XID      0x01000000
+
+#define IATTR_ADMIN    0x00000001
+#define IATTR_WATCH    0x00000002
+#define IATTR_HIDE     0x00000004
+#define IATTR_FLAGS    0x00000007
+
+#define IATTR_BARRIER  0x00010000
+#define IATTR_IUNLINK  0x00020000
+#define IATTR_IMMUTABLE        0x00040000
+
+
+#ifdef CONFIG_VSERVER_PROC_SECURE
+#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
+#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
+#else
+#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN )
+#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
+#endif
+
+#ifdef __KERNEL__
+
+#define vx_hide_check(c,m)      (((m) & IATTR_HIDE) ? vx_check(c,m) : 1)
+
+extern int vc_get_iattr_v0(uint32_t, void __user *);
+extern int vc_set_iattr_v0(uint32_t, void __user *);
+
+extern int vc_get_iattr(uint32_t, void __user *);
+extern int vc_set_iattr(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+/* inode ioctls */
+
+#define FIOC_GETXFLG   _IOR('x', 5, long)
+#define FIOC_SETXFLG   _IOW('x', 6, long)
+
+#endif /* _VX_INODE_H */
diff --git a/include/linux/vserver/legacy.h b/include/linux/vserver/legacy.h
new file mode 100644 (file)
index 0000000..1372c0f
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef _VX_LEGACY_H
+#define _VX_LEGACY_H
+
+#include "switch.h"
+#include "network.h"
+
+/*  compatibiliy vserver commands */
+
+#define VCMD_new_s_context     VC_CMD(COMPAT, 1, 1)
+#define VCMD_set_ipv4root      VC_CMD(COMPAT, 2, 3)
+
+#define VCMD_create_context    VC_CMD(VSETUP, 1, 0)
+
+/*  compatibiliy vserver arguments */
+
+struct  vcmd_new_s_context_v1 {
+       uint32_t remove_cap;
+       uint32_t flags;
+};
+
+struct  vcmd_set_ipv4root_v3 {
+       /* number of pairs in id */
+       uint32_t broadcast;
+       struct {
+               uint32_t ip;
+               uint32_t mask;
+       } nx_mask_pair[NB_IPV4ROOT];
+};
+
+
+#define VX_INFO_LOCK           1       /* Can't request a new vx_id */
+#define VX_INFO_NPROC          4       /* Limit number of processes in a context */
+#define VX_INFO_PRIVATE                8       /* Noone can join this security context */
+#define VX_INFO_INIT           16      /* This process wants to become the */
+                                       /* logical process 1 of the security */
+                                       /* context */
+#define VX_INFO_HIDEINFO       32      /* Hide some information in /proc */
+#define VX_INFO_ULIMIT         64      /* Use ulimit of the current process */
+                                       /* to become the global limits */
+                                       /* of the context */
+#define VX_INFO_NAMESPACE      128     /* save private namespace */
+
+       
+#define NB_S_CONTEXT   16
+
+#define NB_IPV4ROOT    16
+
+
+#ifdef __KERNEL__
+extern int vc_new_s_context(uint32_t, void __user *);
+extern int vc_set_ipv4root(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_LEGACY_H */
diff --git a/include/linux/vserver/limit.h b/include/linux/vserver/limit.h
new file mode 100644 (file)
index 0000000..ef9c9fc
--- /dev/null
@@ -0,0 +1,143 @@
+/* _VX_LIMIT_H defined below */
+
+#if    defined(__KERNEL__) && defined(_VX_INFO_DEF_)
+
+#include <asm/atomic.h>
+#include <asm/resource.h>
+
+/* context sub struct */
+
+#define NUM_LIMITS     20
+
+#define VLIMIT_NSOCK   16
+
+extern const char *vlimit_name[NUM_LIMITS];
+
+struct _vx_limit {
+       atomic_t ticks;
+
+       unsigned long rlim[NUM_LIMITS];         /* Context limit */
+       unsigned long rmax[NUM_LIMITS];         /* Context maximum */
+       atomic_t rcur[NUM_LIMITS];              /* Current value */
+       atomic_t lhit[NUM_LIMITS];              /* Limit hits */
+};
+
+static inline void vx_info_init_limit(struct _vx_limit *limit)
+{
+       int lim;
+
+       for (lim=0; lim<NUM_LIMITS; lim++) {
+               limit->rlim[lim] = RLIM_INFINITY;
+               limit->rmax[lim] = 0;
+               atomic_set(&limit->rcur[lim], 0);
+               atomic_set(&limit->lhit[lim], 0);
+       }
+}
+
+static inline void vx_info_exit_limit(struct _vx_limit *limit)
+{
+#ifdef CONFIG_VSERVER_DEBUG
+       unsigned long value;
+       unsigned int lim;
+
+       for (lim=0; lim<NUM_LIMITS; lim++) {
+               value = atomic_read(&limit->rcur[lim]);
+               if (value)
+                       printk("!!! limit: %p[%s,%d] = %ld on exit.\n",
+                               limit, vlimit_name[lim], lim, value);
+       }
+#endif
+}
+
+static inline void vx_limit_fixup(struct _vx_limit *limit)
+{
+       unsigned long value;
+       unsigned int lim;
+       
+        for (lim=0; lim<NUM_LIMITS; lim++) {
+                value = atomic_read(&limit->rcur[lim]);
+                if (value > limit->rmax[lim])
+                       limit->rmax[lim] = value;
+               if (limit->rmax[lim] > limit->rlim[lim])
+                       limit->rmax[lim] = limit->rlim[lim];
+        }
+}
+
+#define        VX_LIMIT_FMT    ":\t%10d\t%10ld\t%10ld\t%6d\n"
+
+#define        VX_LIMIT_ARG(r)                         \
+               ,atomic_read(&limit->rcur[r])   \
+               ,limit->rmax[r]                 \
+               ,limit->rlim[r]                 \
+               ,atomic_read(&limit->lhit[r])
+
+static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
+{
+       vx_limit_fixup(limit);
+       return sprintf(buffer,
+               "PROC"  VX_LIMIT_FMT
+               "VM"    VX_LIMIT_FMT
+               "VML"   VX_LIMIT_FMT
+               "RSS"   VX_LIMIT_FMT
+               "FILES" VX_LIMIT_FMT
+               "SOCK"  VX_LIMIT_FMT
+               VX_LIMIT_ARG(RLIMIT_NPROC)
+               VX_LIMIT_ARG(RLIMIT_AS)
+               VX_LIMIT_ARG(RLIMIT_MEMLOCK)
+               VX_LIMIT_ARG(RLIMIT_RSS)
+               VX_LIMIT_ARG(RLIMIT_NOFILE)
+               VX_LIMIT_ARG(VLIMIT_NSOCK)
+               );
+}
+
+#else  /* _VX_INFO_DEF_ */
+#ifndef _VX_LIMIT_H
+#define _VX_LIMIT_H
+
+#include "switch.h"
+
+#define        VXD_RLIMIT(r,l)         (VXD_CBIT(limit, (l)) && ((r) == (l)))
+
+/*  rlimit vserver commands */
+
+#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
+#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
+#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
+
+struct  vcmd_ctx_rlimit_v0 {
+       uint32_t id;
+       uint64_t minimum;
+       uint64_t softlimit;
+       uint64_t maximum;
+};
+
+struct  vcmd_ctx_rlimit_mask_v0 {
+       uint32_t minimum;
+       uint32_t softlimit;
+       uint32_t maximum;
+};
+
+#define CRLIM_UNSET            (0ULL)
+#define CRLIM_INFINITY         (~0ULL)
+#define CRLIM_KEEP             (~1ULL)
+
+#ifdef __KERNEL__
+
+#include <linux/compiler.h>
+
+extern int vc_get_rlimit(uint32_t, void __user *);
+extern int vc_set_rlimit(uint32_t, void __user *);
+extern int vc_get_rlimit_mask(uint32_t, void __user *);
+
+struct sysinfo;
+
+void vx_vsi_meminfo(struct sysinfo *);
+void vx_vsi_swapinfo(struct sysinfo *);
+
+
+#endif /* __KERNEL__ */
+
+#endif /* _VX_LIMIT_H */
+#endif
+
+
diff --git a/include/linux/vserver/namespace.h b/include/linux/vserver/namespace.h
new file mode 100644 (file)
index 0000000..140fc79
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef _VX_NAMESPACE_H
+#define _VX_NAMESPACE_H
+
+#include <linux/types.h>
+
+       
+/* virtual host info names */
+
+#define VCMD_vx_set_vhi_name   VC_CMD(VHOST, 1, 0)
+#define VCMD_vx_get_vhi_name   VC_CMD(VHOST, 2, 0)
+
+struct  vcmd_vx_vhi_name_v0 {
+       uint32_t field;
+       char name[65];
+};
+
+
+enum vx_vhi_name_field {
+       VHIN_CONTEXT=0,
+       VHIN_SYSNAME,
+       VHIN_NODENAME,
+       VHIN_RELEASE,
+       VHIN_VERSION,
+       VHIN_MACHINE,
+       VHIN_DOMAINNAME,
+};
+
+
+#ifdef __KERNEL__
+
+#include <linux/compiler.h>
+
+extern int vc_set_vhi_name(uint32_t, void __user *);
+extern int vc_get_vhi_name(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_enter_namespace   VC_CMD(PROCALT, 1, 0)
+#define VCMD_cleanup_namespace VC_CMD(PROCALT, 2, 0)
+#define VCMD_set_namespace     VC_CMD(PROCALT, 3, 0)
+
+#ifdef __KERNEL__
+
+struct vx_info;
+struct namespace;
+struct fs_struct;
+
+extern int vx_set_namespace(struct vx_info *, struct namespace *, struct fs_struct *);
+
+extern int vc_enter_namespace(uint32_t, void __user *);
+extern int vc_cleanup_namespace(uint32_t, void __user *);
+extern int vc_set_namespace(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_NAMESPACE_H */
diff --git a/include/linux/vserver/network.h b/include/linux/vserver/network.h
new file mode 100644 (file)
index 0000000..a89265d
--- /dev/null
@@ -0,0 +1,148 @@
+#ifndef _VX_NETWORK_H
+#define _VX_NETWORK_H
+
+#define MAX_N_CONTEXT  65535   /* Arbitrary limit */
+
+#define NX_DYNAMIC_ID  ((uint32_t)-1)          /* id for dynamic context */
+
+#define NB_IPV4ROOT    16
+
+#ifdef __KERNEL__
+
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/utsname.h>
+#include <linux/rcupdate.h>
+#include <asm/resource.h>
+#include <asm/atomic.h>
+
+
+struct nx_info {
+       struct hlist_node nx_hlist;     /* linked list of nxinfos */
+       struct rcu_head nx_rcu;         /* the rcu head */
+       nid_t nx_id;                    /* vnet id */
+       atomic_t nx_usecnt;             /* usage count */
+       atomic_t nx_refcnt;             /* reference count */
+
+       uint64_t nx_flags;              /* network flag word */
+       uint64_t nx_ncaps;              /* network capabilities */
+
+       int nbipv4;
+       __u32 ipv4[NB_IPV4ROOT];        /* Process can only bind to these IPs */
+                                       /* The first one is used to connect */
+                                       /* and for bind any service */
+                                       /* The other must be used explicity */
+       __u32 mask[NB_IPV4ROOT];        /* Netmask for each ipv4 */
+                                       /* Used to select the proper source */
+                                       /* address for sockets */
+       __u32 v4_bcast;                 /* Broadcast address to receive UDP  */
+
+       char nx_name[65];               /* network context name */
+};
+
+
+struct rcu_head;
+
+extern void rcu_free_nx_info(struct rcu_head *);
+extern void unhash_nx_info(struct nx_info *);
+
+extern struct nx_info *locate_nx_info(int);
+extern struct nx_info *locate_or_create_nx_info(int);
+
+extern int get_nid_list(int, unsigned int *, int);
+extern int nx_info_is_hashed(nid_t);
+
+extern int nx_migrate_task(struct task_struct *, struct nx_info *);
+
+struct in_ifaddr;
+struct net_device;
+
+int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
+int dev_in_nx_info(struct net_device *, struct nx_info *);
+
+
+#endif /* __KERNEL__ */
+
+#include "switch.h"
+
+/* vinfo commands */
+
+#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
+
+#ifdef __KERNEL__
+extern int vc_task_nid(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
+
+struct  vcmd_nx_info_v0 {
+       uint32_t nid;
+       /* more to come */      
+};
+
+#ifdef __KERNEL__
+extern int vc_nx_info(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_net_create                VC_CMD(VNET, 1, 0)
+#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
+
+#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
+#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
+
+struct  vcmd_net_nx_v0 {
+       uint16_t type;
+       uint16_t count;
+       uint32_t ip[4];
+       uint32_t mask[4];
+       /* more to come */      
+};
+
+//     IPN_TYPE_IPV4   
+
+
+#ifdef __KERNEL__
+extern int vc_net_create(uint32_t, void __user *);
+extern int vc_net_migrate(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
+#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
+
+struct  vcmd_net_flags_v0 {
+       uint64_t flagword;
+       uint64_t mask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_nflags(uint32_t, void __user *);
+extern int vc_set_nflags(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define IPF_STATE_SETUP                (1ULL<<32)
+
+
+#define IPF_ONE_TIME           (0x0001ULL<<32)
+
+#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
+#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
+
+struct  vcmd_net_caps_v0 {
+       uint64_t ncaps;
+       uint64_t cmask;
+};
+
+#ifdef __KERNEL__
+extern int vc_get_ncaps(uint32_t, void __user *);
+extern int vc_set_ncaps(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+
+#define IPC_WOSSNAME           0x00000001
+
+
+#endif /* _VX_NETWORK_H */
diff --git a/include/linux/vserver/sched.h b/include/linux/vserver/sched.h
new file mode 100644 (file)
index 0000000..fd6bc2a
--- /dev/null
@@ -0,0 +1,141 @@
+/* _VX_SCHED_H defined below */
+
+#if    defined(__KERNEL__) && defined(_VX_INFO_DEF_)
+
+#include <linux/spinlock.h>
+#include <linux/jiffies.h>
+#include <linux/cpumask.h>
+#include <asm/atomic.h>
+#include <asm/param.h>
+
+/* context sub struct */
+
+struct _vx_sched {
+       spinlock_t tokens_lock; /* lock for this structure */
+
+       int fill_rate;          /* Fill rate: add X tokens... */
+       int interval;           /* Divisor:   per Y jiffies   */
+       atomic_t tokens;        /* number of CPU tokens in this context */
+       int tokens_min;         /* Limit:     minimum for unhold */
+       int tokens_max;         /* Limit:     no more than N tokens */
+       uint32_t jiffies;       /* add an integral multiple of Y to this */
+
+       uint64_t ticks;         /* token tick events */
+       cpumask_t cpus_allowed; /* cpu mask for context */
+};
+
+static inline void vx_info_init_sched(struct _vx_sched *sched)
+{
+       /* scheduling; hard code starting values as constants */
+       sched->fill_rate        = 1;
+       sched->interval         = 4;
+       sched->tokens_min       = HZ >> 4;
+       sched->tokens_max       = HZ >> 1;
+       sched->jiffies          = jiffies;
+       sched->tokens_lock      = SPIN_LOCK_UNLOCKED;
+
+       atomic_set(&sched->tokens, HZ >> 2);
+       sched->cpus_allowed     = CPU_MASK_ALL;
+}
+
+static inline void vx_info_exit_sched(struct _vx_sched *sched)
+{
+       return;
+}
+
+static inline int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
+{
+       return sprintf(buffer,
+               "Ticks:\t%16lld\n"
+               "Token:\t\t%8d\n"
+               "FillRate:\t%8d\n"
+               "Interval:\t%8d\n"              
+               "TokensMin:\t%8d\n"
+               "TokensMax:\t%8d\n"
+               ,(unsigned long long)sched->ticks
+               ,atomic_read(&sched->tokens)
+               ,sched->fill_rate
+               ,sched->interval
+               ,sched->tokens_min
+               ,sched->tokens_max
+               );
+}
+
+
+#else  /* _VX_INFO_DEF_ */
+#ifndef _VX_SCHED_H
+#define _VX_SCHED_H
+
+#include "switch.h"
+
+/*  sched vserver commands */
+
+#define VCMD_set_sched         VC_CMD(SCHED, 1, 2)
+
+struct  vcmd_set_sched_v2 {
+       int32_t fill_rate;
+       int32_t interval;
+       int32_t tokens;
+       int32_t tokens_min;
+       int32_t tokens_max;
+       uint64_t cpu_mask;
+};
+
+#define SCHED_KEEP             (-2)
+
+#ifdef __KERNEL__
+
+extern int vc_set_sched_v1(uint32_t, void __user *);
+extern int vc_set_sched(uint32_t, void __user *);
+
+
+#define VAVAVOOM_RATIO         50
+
+#include "context.h"
+
+
+/* scheduling stuff */
+
+int effective_vavavoom(struct task_struct *, int);
+
+int vx_tokens_recalc(struct vx_info *);
+
+/* new stuff ;) */
+
+static inline int vx_tokens_avail(struct vx_info *vxi)
+{
+       return atomic_read(&vxi->sched.tokens);
+}
+
+static inline void vx_consume_token(struct vx_info *vxi)
+{
+       atomic_dec(&vxi->sched.tokens);
+}
+
+static inline int vx_need_resched(struct task_struct *p)
+{
+#ifdef CONFIG_VSERVER_HARDCPU
+       struct vx_info *vxi = p->vx_info;
+
+       if (vxi) {
+               int tokens;
+
+               p->time_slice--;
+               if (atomic_read(&vxi->vx_usecnt) < 1)
+                       printk("need_resched: p=%p, s=%ld, ref=%d, id=%d/%d\n",
+                               p, p->state, atomic_read(&vxi->vx_usecnt),
+                               vxi->vx_id, p->xid);
+               if ((tokens = vx_tokens_avail(vxi)) > 0)
+                       vx_consume_token(vxi);
+               return ((p->time_slice == 0) || (tokens < 1));
+       }
+#endif
+       p->time_slice--;
+       return (p->time_slice == 0);
+}
+
+
+#endif /* __KERNEL__ */
+
+#endif /* _VX_SCHED_H */
+#endif
diff --git a/include/linux/vserver/signal.h b/include/linux/vserver/signal.h
new file mode 100644 (file)
index 0000000..3911127
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef _VX_SIGNAL_H
+#define _VX_SIGNAL_H
+
+#include "switch.h"
+
+/*  context signalling */
+
+#define VCMD_ctx_kill          VC_CMD(PROCTRL, 1, 0)
+
+struct  vcmd_ctx_kill_v0 {
+       int32_t pid;
+       int32_t sig;
+};
+
+#ifdef __KERNEL__
+extern int vc_ctx_kill(uint32_t, void __user *);
+
+#endif /* __KERNEL__ */
+#endif /* _VX_SIGNAL_H */
diff --git a/include/linux/vserver/switch.h b/include/linux/vserver/switch.h
new file mode 100644 (file)
index 0000000..2aecbaf
--- /dev/null
@@ -0,0 +1,96 @@
+#ifndef _VX_SWITCH_H
+#define _VX_SWITCH_H
+
+#include <linux/types.h>
+
+#define VC_CATEGORY(c)         (((c) >> 24) & 0x3F)
+#define VC_COMMAND(c)          (((c) >> 16) & 0xFF)
+#define VC_VERSION(c)          ((c) & 0xFFF)
+
+#define VC_CMD(c,i,v)          ((((VC_CAT_ ## c) & 0x3F) << 24) \
+                               | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
+
+/*
+
+  Syscall Matrix V2.7
+
+         |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
+         |STATS  |DESTROY|ALTER  |CHANGE |LIMIT  |TEST   | |       |       |
+         |INFO   |SETUP  |       |MOVE   |       |       | |       |       |
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+  SYSTEM |VERSION|VSETUP |VHOST  |       |       |       | |DEVICES|       |
+  HOST   |     00|     01|     02|     03|     04|     05| |     06|     07|
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+  CPU    |       |VPROC  |PROCALT|PROCMIG|PROCTRL|       | |SCHED. |       |
+  PROCESS|     08|     09|     10|     11|     12|     13| |     14|     15|
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+  MEMORY |       |       |       |       |       |       | |SWAP   |       |
+         |     16|     17|     18|     19|     20|     21| |     22|     23|
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+  NETWORK|       |VNET   |NETALT |NETMIG |NETCTL |       | |SERIAL |       |
+         |     24|     25|     26|     27|     28|     29| |     30|     31|
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+  DISK   |       |       |       |       |DLIMIT |       | |INODE  |       |
+  VFS    |     32|     33|     34|     35|     36|     37| |     38|     39|
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+  OTHER  |       |       |       |       |       |       | |VINFO  |       |
+         |     40|     41|     42|     43|     44|     45| |     46|     47|
+  =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
+  SPECIAL|       |       |       |       |FLAGS  |       | |       |       |
+         |     48|     49|     50|     51|     52|     53| |     54|     55|
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+  SPECIAL|       |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
+         |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
+  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
+
+*/
+
+#define VC_CAT_VERSION         0
+
+#define VC_CAT_VSETUP          1
+#define VC_CAT_VHOST           2
+       
+#define VC_CAT_VPROC           9
+#define VC_CAT_PROCALT         10
+#define VC_CAT_PROCMIG         11
+#define VC_CAT_PROCTRL         12
+
+#define VC_CAT_SCHED           14
+
+#define VC_CAT_VNET            25
+#define VC_CAT_NETALT          26
+#define VC_CAT_NETMIG          27
+#define VC_CAT_NETCTRL         28
+
+#define VC_CAT_DLIMIT          36
+#define VC_CAT_INODE           38
+
+#define VC_CAT_VINFO           46
+
+#define VC_CAT_FLAGS           52
+#define VC_CAT_RLIMIT          60
+
+#define VC_CAT_SYSTEST         61
+#define VC_CAT_COMPAT          63
+       
+/*  interface version */
+
+#define VCI_VERSION            0x00010020
+
+
+/*  query version */
+
+#define VCMD_get_version       VC_CMD(VERSION, 0, 0)
+
+
+#ifdef __KERNEL__
+
+#include <linux/errno.h>
+
+#define ENOTSUP                -EOPNOTSUPP
+
+#else  /* __KERNEL__ */
+#define __user
+#endif /* __KERNEL__ */
+
+#endif /* _VX_SWITCH_H */
diff --git a/include/linux/vserver/xid.h b/include/linux/vserver/xid.h
new file mode 100644 (file)
index 0000000..3472def
--- /dev/null
@@ -0,0 +1,123 @@
+#ifndef _VX_XID_H
+#define _VX_XID_H
+
+
+#define        XID_TAG(in)     (!(in) || \
+       (((struct inode *)in)->i_sb && \
+       (((struct inode *)in)->i_sb->s_flags & MS_TAGXID)))
+
+
+#ifdef CONFIG_INOXID_NONE
+
+#define MAX_UID                0xFFFFFFFF
+#define MAX_GID                0xFFFFFFFF
+
+#define INOXID_XID(tag, uid, gid, xid) (0)
+
+#define XIDINO_UID(tag, uid, xid)      (uid)
+#define XIDINO_GID(tag, gid, xid)      (gid)
+
+#endif
+
+
+#ifdef CONFIG_INOXID_GID16
+
+#define MAX_UID                0xFFFFFFFF
+#define MAX_GID                0x0000FFFF
+
+#define INOXID_XID(tag, uid, gid, xid) \
+       ((tag) ? (((gid) >> 16) & 0xFFFF) : 0)
+
+#define XIDINO_UID(tag, uid, xid)      (uid)
+#define XIDINO_GID(tag, gid, xid)      \
+       ((tag) ? (((gid) & 0xFFFF) | ((xid) << 16)) : (gid))
+
+#endif
+
+
+#ifdef CONFIG_INOXID_UGID24
+
+#define MAX_UID                0x00FFFFFF
+#define MAX_GID                0x00FFFFFF
+
+#define INOXID_XID(tag, uid, gid, xid) \
+       ((tag) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
+
+#define XIDINO_UID(tag, uid, xid)      \
+       ((tag) ? (((uid) & 0xFFFFFF) | (((xid) & 0xFF00) << 16)) : (uid))
+#define XIDINO_GID(tag, gid, xid)      \
+       ((tag) ? (((gid) & 0xFFFFFF) | (((xid) & 0x00FF) << 24)) : (gid))
+
+#endif
+
+
+#ifdef CONFIG_INOXID_UID16
+
+#define MAX_UID                0x0000FFFF
+#define MAX_GID                0xFFFFFFFF
+
+#define INOXID_XID(tag, uid, gid, xid) \
+       ((tag) ? ((uid) >> 16) & 0xFFFF) : 0)
+
+#define XIDINO_UID(tag, uid, xid)      \
+       ((tag) ? (((uid) & 0xFFFF) | ((xid) << 16)) : (uid))
+#define XIDINO_GID(tag, gid, xid)      (gid)
+
+#endif
+
+
+#ifdef CONFIG_INOXID_INTERN
+
+#define MAX_UID                0xFFFFFFFF
+#define MAX_GID                0xFFFFFFFF
+
+#define INOXID_XID(tag, uid, gid, xid) \
+       ((tag) ? (xid) : 0)
+
+#define XIDINO_UID(tag, uid, xid)      (uid)
+#define XIDINO_GID(tag, gid, xid)      (gid)
+
+#endif
+
+
+#ifdef CONFIG_INOXID_RUNTIME
+
+#define MAX_UID                0xFFFFFFFF
+#define MAX_GID                0xFFFFFFFF
+
+#define INOXID_XID(tag, uid, gid, xid) (0)
+
+#define XIDINO_UID(tag, uid, xid)      (uid)
+#define XIDINO_GID(tag, gid, xid)      (gid)
+
+#endif
+
+
+#define INOXID_UID(tag, uid, gid)      \
+       ((tag) ? ((uid) & MAX_UID) : (uid))
+#define INOXID_GID(tag, uid, gid)      \
+       ((tag) ? ((gid) & MAX_GID) : (gid))
+
+
+static inline uid_t vx_map_uid(uid_t uid)
+{
+       if ((uid > MAX_UID) && (uid != -1))
+               uid = -2;
+       return (uid & MAX_UID);
+}
+
+static inline gid_t vx_map_gid(gid_t gid)
+{
+       if ((gid > MAX_GID) && (gid != -1))
+               gid = -2;
+       return (gid & MAX_GID);
+}
+
+
+#ifdef CONFIG_VSERVER_LEGACY           
+#define FIOC_GETXID    _IOR('x', 1, long)
+#define FIOC_SETXID    _IOW('x', 2, long)
+#define FIOC_SETXIDJ   _IOW('x', 3, long)
+#endif
+
+#endif /* _VX_XID_H */
index e0f2b2f..e51c6bb 100644 (file)
@@ -243,10 +243,10 @@ static inline void remove_wait_queue_locked(wait_queue_head_t *q,
  * They are racy.  DO NOT use them, use the wait_event* interfaces above.  
  * We plan to remove these interfaces during 2.7.
  */
-extern void FASTCALL(sleep_on(wait_queue_head_t *q));
+extern void __deprecated FASTCALL(sleep_on(wait_queue_head_t *q));
 extern long FASTCALL(sleep_on_timeout(wait_queue_head_t *q,
                                      signed long timeout));
-extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q));
+extern void __deprecated FASTCALL(interruptible_sleep_on(wait_queue_head_t *q));
 extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q,
                                                    signed long timeout));
 
index e445007..6f91e4d 100644 (file)
@@ -64,6 +64,7 @@ void sync_inodes(int wait);
 /* writeback.h requires fs.h; it, too, is not included from here. */
 static inline void wait_on_inode(struct inode *inode)
 {
+       might_sleep();
        if (inode->i_state & I_LOCK)
                __wait_on_inode(inode);
 }
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
deleted file mode 100644 (file)
index e872ad7..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * $Id: mtd-abi.h,v 1.5 2004/06/22 09:29:35 gleixner Exp $
- *
- * Portions of MTD ABI definition which are shared by kernel and user space 
- */
-
-#ifndef __MTD_ABI_H__
-#define __MTD_ABI_H__
-
-struct erase_info_user {
-       uint32_t start;
-       uint32_t length;
-};
-
-struct mtd_oob_buf {
-       uint32_t start;
-       uint32_t length;
-       unsigned char __user *ptr;
-};
-
-#define MTD_ABSENT             0
-#define MTD_RAM                        1
-#define MTD_ROM                        2
-#define MTD_NORFLASH           3
-#define MTD_NANDFLASH          4
-#define MTD_PEROM              5
-#define MTD_OTHER              14
-#define MTD_UNKNOWN            15
-
-#define MTD_CLEAR_BITS         1       // Bits can be cleared (flash)
-#define MTD_SET_BITS           2       // Bits can be set
-#define MTD_ERASEABLE          4       // Has an erase function
-#define MTD_WRITEB_WRITEABLE   8       // Direct IO is possible
-#define MTD_VOLATILE           16      // Set for RAMs
-#define MTD_XIP                        32      // eXecute-In-Place possible
-#define MTD_OOB                        64      // Out-of-band data (NAND flash)
-#define MTD_ECC                        128     // Device capable of automatic ECC
-
-// Some common devices / combinations of capabilities
-#define MTD_CAP_ROM            0
-#define MTD_CAP_RAM            (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEB_WRITEABLE)
-#define MTD_CAP_NORFLASH        (MTD_CLEAR_BITS|MTD_ERASEABLE)
-#define MTD_CAP_NANDFLASH       (MTD_CLEAR_BITS|MTD_ERASEABLE|MTD_OOB)
-#define MTD_WRITEABLE          (MTD_CLEAR_BITS|MTD_SET_BITS)
-
-
-// Types of automatic ECC/Checksum available
-#define MTD_ECC_NONE           0       // No automatic ECC available
-#define MTD_ECC_RS_DiskOnChip  1       // Automatic ECC on DiskOnChip
-#define MTD_ECC_SW             2       // SW ECC for Toshiba & Samsung devices
-
-/* ECC byte placement */
-#define MTD_NANDECC_OFF                0       // Switch off ECC (Not recommended)
-#define MTD_NANDECC_PLACE      1       // Use the given placement in the structure (YAFFS1 legacy mode)
-#define MTD_NANDECC_AUTOPLACE  2       // Use the default placement scheme
-#define MTD_NANDECC_PLACEONLY  3       // Use the given placement in the structure (Do not store ecc result on read)
-
-struct mtd_info_user {
-       uint8_t type;
-       uint32_t flags;
-       uint32_t size;   // Total size of the MTD
-       uint32_t erasesize;
-       uint32_t oobblock;  // Size of OOB blocks (e.g. 512)
-       uint32_t oobsize;   // Amount of OOB data per block (e.g. 16)
-       uint32_t ecctype;
-       uint32_t eccsize;
-};
-
-struct region_info_user {
-       uint32_t offset;                /* At which this region starts, 
-                                        * from the beginning of the MTD */
-       uint32_t erasesize;             /* For this region */
-       uint32_t numblocks;             /* Number of blocks in this region */
-       uint32_t regionindex;
-};
-
-#define MEMGETINFO              _IOR('M', 1, struct mtd_info_user)
-#define MEMERASE                _IOW('M', 2, struct erase_info_user)
-#define MEMWRITEOOB             _IOWR('M', 3, struct mtd_oob_buf)
-#define MEMREADOOB              _IOWR('M', 4, struct mtd_oob_buf)
-#define MEMLOCK                 _IOW('M', 5, struct erase_info_user)
-#define MEMUNLOCK               _IOW('M', 6, struct erase_info_user)
-#define MEMGETREGIONCOUNT      _IOR('M', 7, int)
-#define MEMGETREGIONINFO       _IOWR('M', 8, struct region_info_user)
-#define MEMSETOOBSEL           _IOW('M', 9, struct nand_oobinfo)
-#define MEMGETOOBSEL           _IOR('M', 10, struct nand_oobinfo)
-#define MEMGETBADBLOCK         _IOW('M', 11, loff_t)
-#define MEMSETBADBLOCK         _IOW('M', 12, loff_t)
-
-struct nand_oobinfo {
-       uint32_t useecc;
-       uint32_t eccbytes;
-       uint32_t oobfree[8][2];
-       uint32_t eccpos[32];
-};
-
-#endif /* __MTD_ABI_H__ */
index be877d7..79314ff 100644 (file)
@@ -1,5 +1,8 @@
 #ifndef __LINUX_NET_AFUNIX_H
 #define __LINUX_NET_AFUNIX_H
+
+#include <linux/vs_base.h>
+
 extern void unix_inflight(struct file *fp);
 extern void unix_notinflight(struct file *fp);
 extern void unix_gc(void);
@@ -11,9 +14,9 @@ extern rwlock_t unix_table_lock;
 
 extern atomic_t unix_tot_inflight;
 
-static inline struct sock *first_unix_socket(int *i)
+static inline struct sock *next_unix_socket_table(int *i)
 {
-       for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
+       for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
                if (!hlist_empty(&unix_socket_table[*i]))
                        return __sk_head(&unix_socket_table[*i]);
        }
@@ -22,16 +25,19 @@ static inline struct sock *first_unix_socket(int *i)
 
 static inline struct sock *next_unix_socket(int *i, struct sock *s)
 {
-       struct sock *next = sk_next(s);
-       /* More in this chain? */
-       if (next)
-               return next;
-       /* Look for next non-empty chain. */
-       for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
-               if (!hlist_empty(&unix_socket_table[*i]))
-                       return __sk_head(&unix_socket_table[*i]);
-       }
-       return NULL;
+       do {
+               if (s)
+                       s = sk_next(s);
+               if (!s)
+                       s = next_unix_socket_table(i);
+       } while (s && !vx_check(s->sk_xid, VX_IDENT|VX_WATCH));
+       return s;
+}
+
+static inline struct sock *first_unix_socket(int *i)
+{
+       *i = 0;
+       return next_unix_socket(i, NULL);
 }
 
 #define forall_unix_sockets(i, s) \
index a5e9c57..20bfb38 100644 (file)
@@ -33,6 +33,9 @@
 #include <linux/route.h>
 #include <linux/ip.h>
 #include <linux/cache.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_network.h>
 
 #ifndef __KERNEL__
 #warning This file is not supposed to be used outside of kernel.
index b7ba74d..30e9fbb 100644 (file)
@@ -51,13 +51,13 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
 {
        if (!msg->msg_control)
        {
-               if (sock->passcred || scm->fp)
+               if (test_bit(SOCK_PASS_CRED, &sock->flags) || scm->fp)
                        msg->msg_flags |= MSG_CTRUNC;
                scm_destroy(scm);
                return;
        }
 
-       if (sock->passcred)
+       if (test_bit(SOCK_PASS_CRED, &sock->flags))
                put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(scm->creds), &scm->creds);
 
        if (!scm->fp)
index 0b94438..0d3da11 100644 (file)
@@ -62,7 +62,7 @@
  */
 
 /* Define this to get the sk->sk_debug debugging facility. */
-#define SOCK_DEBUGGING
+//#define SOCK_DEBUGGING
 #ifdef SOCK_DEBUGGING
 #define SOCK_DEBUG(sk, msg...) do { if ((sk) && ((sk)->sk_debug)) \
                                        printk(KERN_DEBUG msg); } while (0)
@@ -110,6 +110,10 @@ struct sock_common {
        struct hlist_node       skc_node;
        struct hlist_node       skc_bind_node;
        atomic_t                skc_refcnt;
+       xid_t                   skc_xid;
+       struct vx_info          *skc_vx_info;
+       nid_t                   skc_nid;
+       struct nx_info          *skc_nx_info;
 };
 
 /**
@@ -165,7 +169,7 @@ struct sock_common {
   *    @sk_timer - sock cleanup timer
   *    @sk_stamp - time stamp of last packet received
   *    @sk_socket - Identd and reporting IO signals
-  *    @sk_user_data - RPC layer private data
+  *    @sk_user_data - RPC and Tux layer private data
   *    @sk_owner - module that owns this socket
   *    @sk_sndmsg_page - cached page for sendmsg
   *    @sk_sndmsg_off - cached offset for sendmsg
@@ -176,6 +180,7 @@ struct sock_common {
   *    @sk_data_ready - callback to indicate there is data to be processed
   *    @sk_write_space - callback to indicate there is bf sending space available
   *    @sk_error_report - callback to indicate errors (e.g. %MSG_ERRQUEUE)
+  *    @sk_create_child - callback to get new socket events
   *    @sk_backlog_rcv - callback to process the backlog
   *    @sk_destruct - called at sock freeing time, i.e. when all refcnt == 0
  */
@@ -192,6 +197,10 @@ struct sock {
 #define sk_node                        __sk_common.skc_node
 #define sk_bind_node           __sk_common.skc_bind_node
 #define sk_refcnt              __sk_common.skc_refcnt
+#define sk_xid                 __sk_common.skc_xid
+#define sk_vx_info             __sk_common.skc_vx_info
+#define sk_nid                 __sk_common.skc_nid
+#define sk_nx_info             __sk_common.skc_nx_info
        volatile unsigned char  sk_zapped;
        unsigned char           sk_shutdown;
        unsigned char           sk_use_write_queue;
@@ -251,6 +260,7 @@ struct sock {
        struct timeval          sk_stamp;
        struct socket           *sk_socket;
        void                    *sk_user_data;
+       void                    *sk_ns;        // For use by CKRM
        struct module           *sk_owner;
        struct page             *sk_sndmsg_page;
        __u32                   sk_sndmsg_off;
@@ -265,6 +275,7 @@ struct sock {
        void                    (*sk_error_report)(struct sock *sk);
        int                     (*sk_backlog_rcv)(struct sock *sk,
                                                  struct sk_buff *skb);  
+       void                    (*sk_create_child)(struct sock *sk, struct sock *newsk);
        void                    (*sk_destruct)(struct sock *sk);
 };
 
@@ -410,6 +421,7 @@ static inline int sock_flag(struct sock *sk, enum sock_flags flag)
        return test_bit(flag, &sk->sk_flags);
 }
 
+#ifndef CONFIG_ACCEPT_QUEUES
 static inline void sk_acceptq_removed(struct sock *sk)
 {
        sk->sk_ack_backlog--;
@@ -424,6 +436,7 @@ static inline int sk_acceptq_is_full(struct sock *sk)
 {
        return sk->sk_ack_backlog > sk->sk_max_ack_backlog;
 }
+#endif
 
 /*
  * Compute minimal free write space needed to queue new packets.
@@ -1059,11 +1072,23 @@ extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
 
 extern void sk_stop_timer(struct sock *sk, struct timer_list* timer);
 
+extern struct proto_ops inet_stream_ops;
+
+extern int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
+
 static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 {
        int err = 0;
        int skb_len;
 
+       /* Silently drop if VNET is active (if INET bind() has been
+        * overridden) and the context is not entitled to read the
+        * packet.
+        */
+       if (inet_stream_ops.bind != inet_bind &&
+           (int) sk->sk_xid > 0 && sk->sk_xid != skb->xid)
+               goto out;
+
        /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
           number of warnings when compiling with -W --ANK
         */
index c7d711f..bbdd19e 100644 (file)
@@ -196,6 +196,10 @@ struct tcp_tw_bucket {
 #define tw_node                        __tw_common.skc_node
 #define tw_bind_node           __tw_common.skc_bind_node
 #define tw_refcnt              __tw_common.skc_refcnt
+#define tw_xid                 __tw_common.skc_xid
+#define tw_vx_info             __tw_common.skc_vx_info
+#define tw_nid                 __tw_common.skc_nid
+#define tw_nx_info             __tw_common.skc_nx_info
        volatile unsigned char  tw_substate;
        unsigned char           tw_rcv_wscale;
        __u16                   tw_sport;
@@ -672,6 +676,10 @@ struct open_request {
                struct tcp_v6_open_req v6_req;
 #endif
        } af;
+#ifdef CONFIG_ACCEPT_QUEUES
+       unsigned long acceptq_time_stamp;
+       int           acceptq_class;
+#endif
 };
 
 /* SLAB cache for open requests. */
@@ -959,6 +967,7 @@ extern int  tcp_transmit_skb(struct sock *, struct sk_buff *);
 extern void tcp_push_one(struct sock *, unsigned mss_now);
 extern void tcp_send_ack(struct sock *sk);
 extern void tcp_send_delayed_ack(struct sock *sk);
+extern void cleanup_rbuf(struct sock *sk, int copied);
 
 /* tcp_timer.c */
 extern void tcp_init_xmit_timers(struct sock *);
@@ -1377,8 +1386,9 @@ static __inline__ void tcp_minshall_update(struct tcp_opt *tp, int mss, struct s
 /* Return 0, if packet can be sent now without violation Nagle's rules:
    1. It is full sized.
    2. Or it contains FIN.
-   3. Or TCP_NODELAY was set.
-   4. Or TCP_CORK is not set, and all sent packets are ACKed.
+   3. Or higher layers meant to force a packet boundary, hence the PSH bit.
+   4. Or TCP_NODELAY was set.
+   5. Or TCP_CORK is not set, and all sent packets are ACKed.
       With Minshall's modification: all sent small packets are ACKed.
  */
 
@@ -1772,6 +1782,83 @@ static inline int tcp_full_space( struct sock *sk)
        return tcp_win_from_space(sk->sk_rcvbuf); 
 }
 
+struct tcp_listen_opt
+{
+       u8                      max_qlen_log;   /* log_2 of maximal queued SYNs */
+       int                     qlen;
+#ifdef CONFIG_ACCEPT_QUEUES
+       int                     qlen_young[NUM_ACCEPT_QUEUES];
+#else
+       int                     qlen_young;
+#endif
+       int                     clock_hand;
+       u32                     hash_rnd;
+       struct open_request     *syn_table[TCP_SYNQ_HSIZE];
+};
+
+#ifdef CONFIG_ACCEPT_QUEUES
+static inline void sk_acceptq_removed(struct sock *sk, int class)
+{
+       tcp_sk(sk)->acceptq[class].aq_backlog--;
+}
+
+static inline void sk_acceptq_added(struct sock *sk, int class)
+{
+       tcp_sk(sk)->acceptq[class].aq_backlog++;
+}
+
+static inline int sk_acceptq_is_full(struct sock *sk, int class)
+{
+       return tcp_sk(sk)->acceptq[class].aq_backlog >
+               sk->sk_max_ack_backlog;
+}
+
+static inline void tcp_set_acceptq(struct tcp_opt *tp, struct open_request *req)
+{
+       int class = req->acceptq_class;
+       int prev_class;
+
+       if (!tp->acceptq[class].aq_ratio) {
+               req->acceptq_class = 0;
+               class = 0;
+       }
+
+       tp->acceptq[class].aq_qcount++;
+       req->acceptq_time_stamp = jiffies;
+
+       if (tp->acceptq[class].aq_tail) {
+               req->dl_next = tp->acceptq[class].aq_tail->dl_next;
+               tp->acceptq[class].aq_tail->dl_next = req;
+               tp->acceptq[class].aq_tail = req;
+       } else { /* if first request in the class */
+               tp->acceptq[class].aq_head = req;
+               tp->acceptq[class].aq_tail = req;
+
+               prev_class = class - 1;
+               while (prev_class >= 0) {
+                       if (tp->acceptq[prev_class].aq_tail)
+                               break;
+                       prev_class--;
+               }
+               if (prev_class < 0) {
+                       req->dl_next = tp->accept_queue;
+                       tp->accept_queue = req;
+               }
+               else {
+                       req->dl_next = tp->acceptq[prev_class].aq_tail->dl_next;
+                       tp->acceptq[prev_class].aq_tail->dl_next = req;
+               }
+       }
+}
+static inline void tcp_acceptq_queue(struct sock *sk, struct open_request *req,
+                                        struct sock *child)
+{
+       tcp_set_acceptq(tcp_sk(sk),req);
+       req->sk = child;
+       sk_acceptq_added(sk,req->acceptq_class);
+}
+
+#else
 static inline void tcp_acceptq_queue(struct sock *sk, struct open_request *req,
                                         struct sock *child)
 {
@@ -1789,15 +1876,41 @@ static inline void tcp_acceptq_queue(struct sock *sk, struct open_request *req,
        req->dl_next = NULL;
 }
 
-struct tcp_listen_opt
+#endif
+
+
+#ifdef CONFIG_ACCEPT_QUEUES
+static inline void
+tcp_synq_removed(struct sock *sk, struct open_request *req)
 {
-       u8                      max_qlen_log;   /* log_2 of maximal queued SYNs */
-       int                     qlen;
-       int                     qlen_young;
-       int                     clock_hand;
-       u32                     hash_rnd;
-       struct open_request     *syn_table[TCP_SYNQ_HSIZE];
-};
+       struct tcp_listen_opt *lopt = tcp_sk(sk)->listen_opt;
+
+       if (--lopt->qlen == 0)
+               tcp_delete_keepalive_timer(sk);
+       if (req->retrans == 0)
+               lopt->qlen_young[req->acceptq_class]--;
+}
+
+static inline void tcp_synq_added(struct sock *sk, struct open_request *req)
+{
+       struct tcp_listen_opt *lopt = tcp_sk(sk)->listen_opt;
+
+       if (lopt->qlen++ == 0)
+               tcp_reset_keepalive_timer(sk, TCP_TIMEOUT_INIT);
+       lopt->qlen_young[req->acceptq_class]++;
+}
+
+static inline int tcp_synq_len(struct sock *sk)
+{
+       return tcp_sk(sk)->listen_opt->qlen;
+}
+
+static inline int tcp_synq_young(struct sock *sk, int class)
+{
+       return tcp_sk(sk)->listen_opt->qlen_young[class];
+}
+
+#else
 
 static inline void
 tcp_synq_removed(struct sock *sk, struct open_request *req)
@@ -1828,6 +1941,7 @@ static inline int tcp_synq_young(struct sock *sk)
 {
        return tcp_sk(sk)->listen_opt->qlen_young;
 }
+#endif
 
 static inline int tcp_synq_is_full(struct sock *sk)
 {
diff --git a/include/net/tux.h b/include/net/tux.h
new file mode 100644 (file)
index 0000000..b6d35df
--- /dev/null
@@ -0,0 +1,800 @@
+#ifndef _NET_TUX_H
+#define _NET_TUX_H
+
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * tux.h: main structure definitions and function prototypes
+ */
+
+#define __KERNEL_SYSCALLS__
+
+#include <linux/mm.h>
+#include <linux/net.h>
+#include <linux/wait.h>
+#include <linux/namei.h>
+#include <linux/file.h>
+#include <linux/mman.h>
+#include <linux/swap.h>
+#include <linux/ctype.h>
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/unistd.h>
+#include <linux/sysctl.h>
+#include <linux/proc_fs.h>
+#include <linux/pagemap.h>
+#include <linux/vmalloc.h>
+#include <linux/utsname.h>
+#include <linux/smp_lock.h>
+#include <linux/kernel_stat.h>
+#include <linux/kernel_stat.h>
+#include <linux/time.h>
+#include <asm/div64.h>
+#include <asm/unaligned.h>
+#include <linux/compiler.h>
+#include <linux/mount.h>
+#include <linux/zlib.h>
+
+#include <net/tcp.h>
+#include <net/tux_u.h>
+
+/* Maximum number of threads: */
+#define CONFIG_TUX_NUMTHREADS 8
+
+/* Number of cachemiss/IO threads: */
+#define NR_IO_THREADS 32
+
+/* Maximum number of listen sockets per thread: */
+#define CONFIG_TUX_NUMSOCKETS 16
+
+extern spinlock_t tux_module_lock;
+extern struct module *tux_module;
+extern asmlinkage long (*sys_tux_ptr) (unsigned int action, user_req_t *u_info);
+
+#undef Dprintk
+
+extern int tux_TDprintk;
+extern int tux_Dprintk;
+
+#define TUX_DEBUG CONFIG_TUX_DEBUG
+#if CONFIG_TUX_DEBUG
+# define TUX_BUG() BUG()
+
+# define TUX_DPRINTK 1
+# define TDprintk(x...) do { if (tux_TDprintk) { printk("<%ld:%s:%d>: ", jiffies, __FILE__, __LINE__); printk(x); } } while (0)
+# define Dprintk(x...) do { if (tux_Dprintk == 1) TDprintk(x); } while (0)
+#else
+# define TUX_DPRINTK 0
+# define Dprintk(x...) do { } while (0)
+# define TDprintk(x...) do { } while (0)
+//# define TUX_BUG() BUG()
+# define TUX_BUG() do { } while (0)
+#endif
+
+#if 1
+# define INC_STAT(x) do { } while (0)
+# define DEC_STAT(x) do { } while (0)
+# define ADD_STAT(x,y) do { } while (0)
+# define SUB_STAT(x,y) do { } while (0)
+#else
+# define INC_STAT(x) atomic_inc((atomic_t *)&kstat.x)
+# define DEC_STAT(x) atomic_dec((atomic_t *)&kstat.x)
+# define ADD_STAT(y,x) atomic_add(y,(atomic_t *)&kstat.x)
+# define SUB_STAT(y,x) atomic_sub(y,(atomic_t *)&kstat.x)
+#endif
+
+// lru needs this:
+
+# define DEBUG_DEL_LIST(x...) do { INIT_LIST_HEAD((x)); } while (0)
+
+
+#define LOG_LEN (8*1024*1024UL)
+
+struct tux_req_struct;
+typedef struct tux_req_struct tux_req_t;
+typedef struct tux_threadinfo threadinfo_t;
+
+extern struct address_space_operations url_aops;
+
+typedef struct tcapi_template_s {
+       char *vfs_name;
+       struct list_head modules;
+       int (*query) (tux_req_t *req);
+       struct module *mod;
+       unsigned int userspace_id;
+} tcapi_template_t;
+
+typedef struct mimetype_s {
+       struct list_head list;
+
+       char *ext;
+       unsigned int ext_len;
+       char *type;
+       unsigned int type_len;
+       char *expire_str;
+       unsigned int expire_str_len;
+
+       unsigned int special;
+} mimetype_t;
+
+typedef struct tux_attribute_s {
+       mimetype_t *mime;
+       tcapi_template_t *tcapi;
+} tux_attribute_t;
+
+#define MAX_TUX_ATOMS 8
+
+typedef void (atom_func_t)(tux_req_t *req, int cachemiss);
+
+typedef struct tux_proto_s
+{
+       unsigned int defer_accept;
+       unsigned int can_redirect;
+       void (*got_request) (tux_req_t *req);
+       int (*parse_message) (tux_req_t *req, const int total_len);
+       atom_func_t *illegal_request;
+       atom_func_t *request_timeout;
+       void (*pre_log) (tux_req_t *req);
+       int (*check_req_err) (tux_req_t *req, int cachemiss);
+       char * (*print_dir_line) (tux_req_t *req, char *tmp, char *d_name, int d_len, int d_type, struct dentry *dentry, struct inode *inode);
+       const char *name;
+       struct nameidata main_docroot;
+} tux_proto_t;
+
+typedef struct tux_socket_s {
+       tux_proto_t *proto;
+       unsigned int ip;
+       unsigned short port;
+       struct proc_dir_entry *entry;
+} tux_socket_t;
+
+extern tux_socket_t tux_listen [CONFIG_TUX_NUMTHREADS][CONFIG_TUX_NUMSOCKETS];
+
+
+typedef struct abuf_s {
+       struct page *page;
+       char *buf;
+       unsigned int size;
+       unsigned int max_len;
+       unsigned int offset;
+       unsigned int left;
+       unsigned long flags;
+} abuf_t;
+
+struct linux_dirent64 {
+       u64             d_ino;
+       s64             d_off;
+       unsigned short  d_reclen;
+       unsigned char   d_type;
+       char            d_name[0];
+};
+
+struct getdents_callback64 {
+       struct linux_dirent64 * current_dir;
+       struct linux_dirent64 * previous;
+       int count;
+       int error;
+};
+
+#define TUX_MAGIC 0x12457801
+
+#define MAX_TUX_ATOMS 8
+
+struct tux_req_struct
+{
+       tux_proto_t *proto;
+
+       int atom_idx;
+       atom_func_t *atoms [MAX_TUX_ATOMS];
+       struct list_head work;
+
+       struct list_head all;
+       struct list_head free;
+       struct list_head lru;
+
+       unsigned long idle_input;
+       unsigned long wait_output_space;
+
+       struct socket *sock;
+       struct dentry *dentry;
+       struct vfsmount *mnt;
+       struct dentry *docroot_dentry;
+       struct vfsmount *docroot_mnt;
+       struct dentry *cwd_dentry;
+       struct vfsmount *cwd_mnt;
+
+       struct file in_file;
+       int fd;
+       read_descriptor_t desc;
+       u32 client_addr;
+       u32 client_port;
+       unsigned int virtual;
+
+       loff_t total_file_len;
+       unsigned int lendigits;
+       loff_t offset_start;
+       loff_t offset_end;
+       loff_t output_len;
+
+       loff_t ftp_offset_start;
+
+       time_t mtime;
+       unsigned int etaglen;
+       char etag [40];
+
+       char usermode;
+       unsigned int usermodule_idx;
+       struct dentry *module_dentry;
+       struct vfsmount *module_mnt;
+       char *userbuf;
+       unsigned int userlen;
+
+       tux_attribute_t *attr;
+
+       threadinfo_t *ti;
+       wait_queue_t sleep;
+       wait_queue_t ftp_sleep;
+
+       abuf_t abuf;
+       /*
+        * Parsed request fields. In-line strings are zero-delimited.
+        */
+       const char *headers;
+       unsigned int headers_len;
+
+       unsigned int parsed_len;
+
+       // FTP part
+       ftp_command_t ftp_command;
+       u32 ftp_user_addr;
+       u16 ftp_user_port;
+
+       struct socket *data_sock;
+       unsigned int prev_pos;
+
+       // ls handing:
+       struct linux_dirent64 *dirp0;
+       unsigned int curroff, total;
+
+#define MAX_USERNAME_LEN 16
+       char username[MAX_USERNAME_LEN];
+       unsigned int username_len;
+
+       // HTTP part
+       http_method_t method;
+       const char *method_str;
+       unsigned int method_len;
+
+       http_version_t version;
+       const char *version_str;
+       unsigned int version_len;
+
+       /* requested URI: */
+
+       const char *uri_str;
+       unsigned int uri_len;
+
+       /* Objectname (filename/scriptname) this URI refers to: */
+
+#define MAX_OBJECTNAME_LEN 256
+       char objectname[MAX_OBJECTNAME_LEN + 4]; // space for .gz as well
+       unsigned int objectname_len;
+
+       /* Query string within the URI: */
+
+       const char *query_str;
+       unsigned int query_len;
+
+       /* Cookies: */
+
+       const char *cookies_str;
+       unsigned int cookies_len;
+       unsigned int parse_cookies;
+
+       /* Content-TYpe */
+       const char *content_type_str;
+       unsigned int content_type_len;
+
+       /* Content-Length: */
+
+       const char *contentlen_str;
+       unsigned int contentlen_len;
+       unsigned int content_len;
+
+       /* User-Agent: */
+
+       const char *user_agent_str;
+       unsigned int user_agent_len;
+
+       /* Accept: */
+
+       const char *accept_str;
+       unsigned int accept_len;
+
+       /* Accept-Charset: */
+
+       const char *accept_charset_str;
+       unsigned int accept_charset_len;
+
+       /* Accept-Language: */
+
+       const char *accept_language_str;
+       unsigned int accept_language_len;
+
+       /* Cache-Control: */
+
+       const char *cache_control_str;
+       unsigned int cache_control_len;
+
+       /* If-Modified-Since: */
+
+       const char *if_modified_since_str;
+       unsigned int if_modified_since_len;
+
+       /* If-None-Match: */
+       const char *if_none_match_str;
+       unsigned int if_none_match_len;
+
+       /* If-Range: */
+
+       const char *if_range_str;
+       unsigned int if_range_len;
+
+       /* Negotiate: */
+
+       const char *negotiate_str;
+       unsigned int negotiate_len;
+
+       /* Pragma: */
+
+       const char *pragma_str;
+       unsigned int pragma_len;
+
+       /* Referer: */
+
+       const char *referer_str;
+       unsigned int referer_len;
+
+       /* Accept-Encoding: */
+
+       const char *accept_encoding_str;
+       unsigned int accept_encoding_len;
+       unsigned int may_send_gzip;
+       unsigned int content_gzipped;
+
+       /* Host */
+
+#define MAX_HOST_LEN 128
+       char host[MAX_HOST_LEN];
+       unsigned int host_len;
+
+       /* POSTed data: */
+
+       const char *post_data_str;
+       unsigned int post_data_len;
+
+       unsigned int status;
+
+       /* the file being sent */
+
+       unsigned int bytes_sent;
+#if CONFIG_TUX_DEBUG
+       unsigned int bytes_expected;
+#endif
+       unsigned long first_timestamp;
+       unsigned int body_len;
+
+       unsigned int user_error;
+
+       char error;
+       char postponed;
+
+       char had_cachemiss;
+       char lookup_dir;
+       char lookup_404;
+
+       char keep_alive;
+       struct timer_list keepalive_timer;
+       unsigned int total_bytes;
+       struct timer_list output_timer;
+
+       unsigned int nr_keepalives;
+
+       unsigned int event;
+       u64 private;
+
+       unsigned int magic;
+       void (*real_data_ready)(struct sock *sk, int space);
+       void (*real_state_change)(struct sock *sk);
+       void (*real_write_space)(struct sock *sk);
+       void (*real_error_report)(struct sock *sk);
+       void (*real_destruct)(struct sock *sk);
+
+       void (*ftp_real_data_ready)(struct sock *sk, int space);
+       void (*ftp_real_state_change)(struct sock *sk);
+       void (*ftp_real_write_space)(struct sock *sk);
+       void (*ftp_real_error_report)(struct sock *sk);
+       void (*ftp_real_create_child)(struct sock *sk, struct sock *newsk);
+       void (*ftp_real_destruct)(struct sock *sk);
+
+#if CONFIG_TUX_EXTENDED_LOG
+       unsigned long accept_timestamp;
+       unsigned long parse_timestamp;
+       unsigned long output_timestamp;
+       unsigned long flush_timestamp;
+# define SET_TIMESTAMP(x) do { (x) = jiffies; } while (0)
+#else
+# define SET_TIMESTAMP(x) do { } while (0)
+#endif
+
+};
+
+extern void add_tux_atom (tux_req_t *req, atom_func_t *event_done);
+extern void del_tux_atom (tux_req_t *req);
+extern void tux_schedule_atom (tux_req_t *req, int cachemiss);
+extern void add_req_to_workqueue (tux_req_t *req);
+
+
+typedef struct iothread_s
+{
+       spinlock_t async_lock;
+       threadinfo_t *ti;
+       struct list_head async_queue;
+       wait_queue_head_t async_sleep;
+       unsigned int nr_async_pending;
+       unsigned int threads;
+       unsigned int shutdown;
+       wait_queue_head_t wait_shutdown;
+} iothread_t;
+
+typedef struct tux_listen_s
+{
+       tux_proto_t *proto;
+       struct socket *sock;
+       unsigned int cloned;
+} tux_listen_t;
+
+struct tux_threadinfo
+{
+       tux_req_t *userspace_req;
+       unsigned int started;
+       struct task_struct *thread;
+       iothread_t *iot;
+       wait_queue_t wait_event [CONFIG_TUX_NUMSOCKETS];
+       wait_queue_t stop;
+       unsigned int pid;
+
+       struct page *header_cache;
+       unsigned int header_offset;
+
+       unsigned int nr_requests;
+       struct list_head all_requests;
+
+       unsigned int nr_free_requests;
+       spinlock_t free_requests_lock;
+       struct list_head free_requests;
+
+       spinlock_t work_lock;
+       struct list_head work_pending;
+       struct list_head lru;
+       unsigned int nr_lru;
+
+       unsigned int listen_error;
+       tux_listen_t listen[CONFIG_TUX_NUMSOCKETS];
+
+       struct semaphore gzip_sem;
+       z_stream gzip_state;
+
+       unsigned int cpu;
+       unsigned int __padding[16];
+};
+
+typedef enum special_mimetypes {
+       NORMAL_MIME_TYPE,
+       MIME_TYPE_REDIRECT,
+       MIME_TYPE_CGI,
+       MIME_TYPE_MODULE,
+} special_mimetypes_t;
+
+#if CONFIG_TUX_DEBUG
+#if 0
+extern inline void url_hist_hit (int size)
+{
+       unsigned int idx = size/1024;
+
+       if (idx >= URL_HIST_SIZE)
+               idx = URL_HIST_SIZE-1;
+       kstat.url_hist_hits[idx]++;
+}
+extern inline void url_hist_miss (int size)
+{
+       unsigned int idx = size/1024;
+       if (idx >= URL_HIST_SIZE)
+               idx = URL_HIST_SIZE-1;
+       kstat.url_hist_misses[idx]++;
+}
+#endif
+extern void __check_req_list (tux_req_t *req, struct list_head *list);
+# define check_req_list __check_req_list
+#else
+# define check_req_list(req, list) do { } while (0)
+#endif
+
+#define url_hist_hit(size) do { } while (0)
+#define url_hist_miss(size) do { } while (0)
+
+extern char tux_common_docroot[200];
+extern char tux_http_subdocroot[200];
+extern char tux_ftp_subdocroot[200];
+extern char tux_logfile[200];
+extern char tux_cgiroot[200];
+extern char tux_404_page[200];
+extern char tux_default_vhost[200];
+extern char tux_extra_html_header[600];
+extern unsigned int tux_extra_html_header_size;
+extern int tux_cgi_uid;
+extern int tux_cgi_gid;
+extern unsigned int tux_clientport;
+extern unsigned int tux_logging;
+extern unsigned int tux_threads;
+extern unsigned int tux_keepalive_timeout;
+extern unsigned int tux_max_output_bandwidth;
+extern unsigned int tux_max_backlog;
+extern unsigned int tux_max_connect;
+extern unsigned int tux_mode_forbidden;
+extern unsigned int tux_mode_allowed;
+extern unsigned int tux_logentry_align_order;
+extern unsigned int tux_nonagle;
+extern unsigned int tux_ack_pingpong;
+extern unsigned int tux_push_all;
+extern unsigned int tux_zerocopy_parse;
+extern unsigned int tux_generate_etags;
+extern unsigned int tux_generate_last_mod;
+extern unsigned int tux_generate_cache_control;
+extern unsigned int tux_ip_logging;
+extern unsigned int tux_ftp_wait_close;
+extern unsigned int tux_ftp_log_retr_only;
+extern unsigned int tux_hide_unreadable;
+
+typedef enum virtual_server {
+       TUX_VHOST_NONE,
+       TUX_VHOST_HOST,
+       TUX_VHOST_IP,
+       TUX_VHOST_IP_HOST,
+} virtual_server_t;
+
+extern unsigned int tux_virtual_server;
+extern unsigned int mass_hosting_hash;
+extern unsigned int strip_host_tail;
+extern unsigned int tux_ftp_virtual_server;
+
+extern unsigned int tux_max_object_size;
+extern unsigned int tux_max_free_requests;
+extern unsigned int tux_defer_accept;
+
+extern struct socket * start_listening(tux_socket_t *listen, int nr);
+extern void stop_listening(struct socket **sock);
+extern void start_sysctl(void);
+extern void end_sysctl(void);
+extern void flush_request (tux_req_t *req, int cachemiss);
+extern void unlink_tux_socket (tux_req_t *req);
+extern void unlink_tux_data_socket (tux_req_t *req);
+extern void unlink_tux_listen_socket (tux_req_t *req);
+extern void link_tux_ftp_accept_socket (tux_req_t *req, struct socket *sock);
+extern void link_tux_data_socket (tux_req_t *req, struct socket *sock);
+extern void tux_push_req (tux_req_t *req);
+extern int send_sync_buf (tux_req_t *req, struct socket *sock, const char *buf, const size_t length, unsigned long flags);
+extern void __send_async_message (tux_req_t *req, const char *message, int status, unsigned int size, int push);
+#define send_async_message(req,str,status,push) \
+               __send_async_message(req,str,status,strlen(str),push)
+
+extern void send_success (tux_req_t *req, struct socket *sock);
+extern void send_async_err_not_found (tux_req_t *req);
+extern void send_async_timed_out (tux_req_t *req);
+
+extern void kfree_req (tux_req_t *req);
+extern int accept_requests (threadinfo_t *ti);
+extern int process_requests (threadinfo_t *ti, tux_req_t **user_req);
+extern int flush_freequeue (threadinfo_t * ti);
+extern int tux_flush_workqueue (threadinfo_t *ti);
+extern tux_req_t * pick_userspace_req (threadinfo_t *ti);
+extern atom_func_t redirect_request;
+extern atom_func_t parse_request;
+extern void queue_cachemiss (tux_req_t *req);
+extern int start_cachemiss_threads (threadinfo_t *ti);
+extern void stop_cachemiss_threads (threadinfo_t *ti);
+struct file * tux_open_file(char *filename, int mode);
+extern void start_log_thread (void);
+extern void stop_log_thread (void);
+extern void add_mimetype (char *new_ext, char *new_type, char *new_expire);
+extern void free_mimetypes (void);
+extern int lookup_object (tux_req_t *req, const unsigned int flag);
+extern int handle_gzip_req (tux_req_t *req, unsigned int flags);
+extern struct dentry * tux_lookup (tux_req_t *req, const char *filename, const unsigned int flag, struct vfsmount **mnt);
+extern tcapi_template_t * lookup_tuxmodule (const char *filename);
+extern int register_tuxmodule (tcapi_template_t *tcapi);
+extern tcapi_template_t * unregister_tuxmodule (char *vfs_name);
+extern tcapi_template_t * get_first_usermodule (void);
+extern int user_register_module (user_req_t *u_info);
+extern int user_unregister_module (user_req_t *u_info);
+extern void unregister_all_tuxmodules (void);
+
+typedef struct exec_param_s {
+       char *command;
+       char **argv;
+       char **envp;
+       unsigned int pipe_fds;
+} exec_param_t;
+
+extern pid_t tux_exec_process (char *command, char **argv, char **envp, int pipe_fds, exec_param_t *param, int wait);
+
+extern void start_external_cgi (tux_req_t *req);
+extern tcapi_template_t extcgi_tcapi;
+
+extern void queue_output_req (tux_req_t *req, threadinfo_t *ti);
+extern void queue_userspace_req (tux_req_t *req, threadinfo_t *ti);
+
+
+extern void __log_request (tux_req_t *req);
+extern inline void log_request (tux_req_t *req)
+{
+       if (tux_logging)
+               __log_request(req);
+}
+
+extern int __connection_too_fast (tux_req_t *req);
+
+#define connection_too_fast(req)                               \
+       ({                                                      \
+               int __ret = 1;                                  \
+               if (unlikely(tux_max_output_bandwidth))         \
+                       __ret = __connection_too_fast(req);     \
+               __ret;                                          \
+       })
+
+extern void trunc_headers (tux_req_t *req);
+extern int generic_send_file (tux_req_t *req, struct socket *sock, int cachemiss);
+extern int tux_fetch_file (tux_req_t *req, int nonblock);
+
+extern void postpone_request (tux_req_t *req);
+extern int continue_request (int fd);
+extern void tux_push_pending (struct sock *sk);
+extern void zap_request (tux_req_t *req, int cachemiss);
+extern int add_output_space_event (tux_req_t *req, struct socket *sock);
+
+extern void reap_kids (void);
+extern void unuse_frag (struct sk_buff *skb, skb_frag_t *frag);
+extern skb_frag_t * build_dynbuf_frag (tux_req_t *req, unsigned int size);
+extern int tux_permission (struct inode *inode);
+extern void flush_all_signals (void);
+
+#define D() Dprintk("{%s:%d}\n", __FILE__, __LINE__)
+
+extern int nr_async_io_pending (void);
+
+extern void __add_keepalive_timer (tux_req_t *req);
+#define add_keepalive_timer(req)                                       \
+do {                                                                   \
+       if (tux_keepalive_timeout) {                                    \
+               Dprintk("add_keepalive_timer(%p).\n", (req));           \
+               __add_keepalive_timer(req);                             \
+       }                                                               \
+} while (0)
+extern void __del_keepalive_timer (tux_req_t *req);
+#define del_keepalive_timer(req)                                       \
+do {                                                                   \
+       if (tux_keepalive_timeout) {                                    \
+               Dprintk("del_keepalive_timer(%p).\n", (req));           \
+               __del_keepalive_timer(req);                             \
+       }                                                               \
+} while (0)
+
+extern void del_output_timer (tux_req_t *req);
+extern void output_timeout (tux_req_t *req);
+
+extern void print_req (tux_req_t *req);
+
+extern char tux_date [DATE_LEN];
+
+
+extern int nr_async_io_pending (void);
+extern void tux_exit (void);
+extern char * get_abuf (tux_req_t *req, unsigned int max_size);
+extern void send_abuf (tux_req_t *req, unsigned int size, unsigned long flags);
+
+
+extern int idle_event (tux_req_t *req);
+extern int output_space_event (tux_req_t *req);
+extern unsigned int log_cpu_mask;
+extern unsigned int tux_compression;
+extern unsigned int tux_noid;
+extern unsigned int tux_cgi_inherit_cpu;
+extern unsigned int tux_zerocopy_header;
+extern unsigned int tux_zerocopy_sendfile;
+extern unsigned int tux_cgi_cpu_mask;
+extern tux_proto_t tux_proto_http;
+extern tux_proto_t tux_proto_ftp;
+extern unsigned int tux_all_userspace;
+extern unsigned int tux_ignore_query;
+extern unsigned int tux_redirect_logging;
+extern unsigned int tux_referer_logging;
+extern unsigned int tux_log_incomplete;
+extern unsigned int tux_max_header_len;
+extern unsigned int tux_cpu_offset;
+extern unsigned int tux_ftp_login_message;
+
+extern void drop_permissions (void);
+extern int query_extcgi (tux_req_t *req);
+extern int tux_chroot (char *dir);
+
+extern void install_req_dentry (tux_req_t *req, struct dentry *dentry, struct vfsmount *mnt);
+extern void release_req_dentry (tux_req_t *req);
+extern void unidle_req (tux_req_t *req);
+extern int nr_requests_used (void);
+
+#define req_err(req) do { (req)->error = 1; Dprintk("request %p error at %s:%d.\n", req, __FILE__, __LINE__); } while (0)
+
+#define enough_wspace(sk) (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+#define clear_keepalive(req) do { (req)->keep_alive = 0; Dprintk("keepalive cleared for req %p.\n", req); } while (0)
+
+extern int print_all_requests (threadinfo_t *ti);
+extern unsigned int tux_max_keepalives;
+extern int time_unix2ls (time_t zulu, char *buf);
+extern void last_mod_time(char * curr, const time_t t);
+extern int mdtm_time(char * curr, const time_t t);
+extern time_t parse_time(const char *str, const int str_len);
+
+extern unsigned int nr_tux_threads;
+extern threadinfo_t threadinfo[CONFIG_TUX_NUMTHREADS];
+
+#define switch_docroot(req) do { if (((req)->docroot_dentry != current->fs->root) || ((req)->docroot_mnt != current->fs->rootmnt)) __switch_docroot(req); } while (0)
+extern void __switch_docroot(tux_req_t *req);
+extern void list_directory (tux_req_t *req, int cachemiss);
+extern char * tux_print_path (tux_req_t *req, struct dentry *dentry, struct vfsmount *mnt, char *buf, unsigned int max_len);
+
+extern unsigned int tux_http_dir_indexing;
+
+int tux_gzip_compress (tux_req_t *req, unsigned char *data_in, unsigned char *data_out, __u32 *in_len, __u32 *out_len);
+
+struct dentry * __tux_lookup (tux_req_t *req, const char *filename,
+                         struct nameidata *base, struct vfsmount **mnt);
+
+/* error codes for req->error */
+#define TUX_ERROR_REDIRECT     1
+#define TUX_ERROR_UNUSED       2
+#define TUX_ERROR_CONN_CLOSE   3
+#define TUX_ERROR_CONN_TIMEOUT 4
+
+extern void __put_data_sock (tux_req_t *req);
+
+static inline void put_data_sock (tux_req_t *req)
+{
+       if (req->data_sock)
+               __put_data_sock(req);
+}
+
+#define socket_input(sock) \
+       (!skb_queue_empty(&(sock)->sk->sk_receive_queue) || \
+               !skb_queue_empty(&(sock)->sk->sk_error_queue))
+
+#define tux_kmalloc(size)                                              \
+({                                                                     \
+       void *__ptr;                                                    \
+                                                                       \
+       while (!(__ptr = kmalloc(size, GFP_KERNEL))) {                  \
+               if (net_ratelimit())                                    \
+                       printk(KERN_WARNING "tux: OOM at %s:%d (%d bytes).\n", \
+                               __FILE__, __LINE__, size);              \
+               current->state = TASK_UNINTERRUPTIBLE;                  \
+               schedule_timeout(1);                                    \
+       }                                                               \
+       __ptr;                                                          \
+})
+
+extern long tux_close(unsigned int fd);
+
+#endif
diff --git a/include/net/tux_u.h b/include/net/tux_u.h
new file mode 100644 (file)
index 0000000..24ba401
--- /dev/null
@@ -0,0 +1,163 @@
+#ifndef _NET_TUX_U_H
+#define _NET_TUX_U_H
+
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * tux_u.h: HTTP module API - HTTP interface to user-space
+ */
+
+/*
+ * Different major versions are not compatible.
+ * Different minor versions are only downward compatible.
+ * Different patchlevel versions are downward and upward compatible.
+ */
+#define TUX_MAJOR_VERSION              3
+#define TUX_MINOR_VERSION              0
+#define TUX_PATCHLEVEL_VERSION         0
+
+#define __KERNEL_SYSCALLS__
+
+typedef enum http_versions {
+        HTTP_1_0,
+        HTTP_1_1
+} http_version_t;
+
+/*
+ * Request methods known to HTTP:
+ */
+typedef enum http_methods {
+        METHOD_NONE,
+        METHOD_GET,
+        METHOD_HEAD,
+        METHOD_POST,
+        METHOD_PUT,
+       NR_METHODS
+} http_method_t;
+
+enum user_req {
+       TUX_ACTION_STARTUP = 1,
+       TUX_ACTION_SHUTDOWN = 2,
+       TUX_ACTION_STARTTHREAD = 3,
+       TUX_ACTION_STOPTHREAD = 4,
+       TUX_ACTION_EVENTLOOP = 5,
+       TUX_ACTION_GET_OBJECT = 6,
+       TUX_ACTION_SEND_OBJECT = 7,
+       TUX_ACTION_READ_OBJECT = 8,
+       TUX_ACTION_FINISH_REQ = 9,
+       TUX_ACTION_FINISH_CLOSE_REQ = 10,
+       TUX_ACTION_REGISTER_MODULE = 11,
+       TUX_ACTION_UNREGISTER_MODULE = 12,
+       TUX_ACTION_CURRENT_DATE = 13,
+       TUX_ACTION_REGISTER_MIMETYPE = 14,
+       TUX_ACTION_READ_HEADERS = 15,
+       TUX_ACTION_POSTPONE_REQ = 16,
+       TUX_ACTION_CONTINUE_REQ = 17,
+       TUX_ACTION_REDIRECT_REQ = 18,
+       TUX_ACTION_READ_POST_DATA = 19,
+       TUX_ACTION_SEND_BUFFER = 20,
+       TUX_ACTION_WATCH_PROXY_SOCKET = 21,
+       TUX_ACTION_WAIT_PROXY_SOCKET = 22,
+       TUX_ACTION_QUERY_VERSION = 23,
+       MAX_TUX_ACTION
+};
+
+enum tux_ret {
+       TUX_ERROR = -1,
+       TUX_RETURN_USERSPACE_REQUEST = 0,
+       TUX_RETURN_EXIT = 1,
+       TUX_RETURN_SIGNAL = 2,
+       TUX_CONTINUE_EVENTLOOP = 3,
+};
+
+#define MAX_URI_LEN 256
+#define MAX_COOKIE_LEN 128
+#define MAX_FIELD_LEN 64
+#define DATE_LEN 30
+
+typedef struct user_req_s {
+       u32 version_major;
+       u32 version_minor;
+       u32 version_patch;
+       u32 http_version;
+       u32 http_method;
+       u32 http_status;
+
+       u32 sock;
+       u32 event;
+       u32 error;
+       u32 thread_nr;
+       u32 bytes_sent;
+       u32 client_host;
+       u32 objectlen;
+       u32 module_index;
+       u32 keep_alive;
+       u32 cookies_len;
+
+       u64 id;
+       u64 priv;
+       u64 object_addr;
+
+       u8 query[MAX_URI_LEN];
+       u8 objectname[MAX_URI_LEN];
+       u8 cookies[MAX_COOKIE_LEN];
+       u8 content_type[MAX_FIELD_LEN];
+       u8 user_agent[MAX_FIELD_LEN];
+       u8 accept[MAX_FIELD_LEN];
+       u8 accept_charset[MAX_FIELD_LEN];
+       u8 accept_encoding[MAX_FIELD_LEN];
+       u8 accept_language[MAX_FIELD_LEN];
+       u8 cache_control[MAX_FIELD_LEN];
+       u8 if_modified_since[MAX_FIELD_LEN];
+       u8 negotiate[MAX_FIELD_LEN];
+       u8 pragma[MAX_FIELD_LEN];
+       u8 referer[MAX_FIELD_LEN];
+       u8 new_date[DATE_LEN];
+       u8 pad[2];
+
+} user_req_t;
+
+typedef enum ftp_commands {
+        FTP_COMM_NONE,
+        FTP_COMM_USER,
+        FTP_COMM_PASS,
+        FTP_COMM_ACCT,
+        FTP_COMM_CWD,
+        FTP_COMM_CDUP,
+        FTP_COMM_SMNT,
+        FTP_COMM_QUIT,
+        FTP_COMM_REIN,
+        FTP_COMM_PORT,
+        FTP_COMM_PASV,
+        FTP_COMM_TYPE,
+        FTP_COMM_STRU,
+        FTP_COMM_MODE,
+        FTP_COMM_RETR,
+        FTP_COMM_SIZE,
+        FTP_COMM_MDTM,
+        FTP_COMM_STOR,
+        FTP_COMM_STOU,
+        FTP_COMM_APPE,
+        FTP_COMM_ALLO,
+        FTP_COMM_REST,
+        FTP_COMM_RNFR,
+        FTP_COMM_RNTO,
+        FTP_COMM_ABOR,
+        FTP_COMM_DELE,
+        FTP_COMM_RMD,
+        FTP_COMM_MKD,
+        FTP_COMM_PWD,
+        FTP_COMM_LIST,
+        FTP_COMM_NLST,
+        FTP_COMM_SITE,
+        FTP_COMM_SYST,
+        FTP_COMM_STAT,
+        FTP_COMM_HELP,
+        FTP_COMM_NOOP,
+        FTP_COMM_FEAT,
+        FTP_COMM_CLNT,
+} ftp_command_t;
+
+#endif
index 2d3265c..bb1e2e5 100644 (file)
@@ -524,7 +524,7 @@ struct Scsi_Host {
        container_of(d, struct Scsi_Host, shost_classdev)
 
 extern struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *, int);
-extern int scsi_add_host(struct Scsi_Host *, struct device *);
+extern int __must_check scsi_add_host(struct Scsi_Host *, struct device *);
 extern void scsi_scan_host(struct Scsi_Host *);
 extern void scsi_remove_host(struct Scsi_Host *);
 extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
index 113a656..64ca2fc 100644 (file)
@@ -77,6 +77,8 @@ config SYSVIPC
          you want to run the DOS emulator dosemu under Linux (read the
          DOSEMU-HOWTO, available from <http://www.tldp.org/docs.html#howto>),
          you'll need to say Y here.
+         DOSEMU-HOWTO, available from <http://www.tldp.org/docs.html#howto>),
+         you'll need to say Y here.
 
          You can find documentation about IPC with "info ipc" and also in
          section 6.4 of the Linux Programmer's Guide, available from
@@ -125,6 +127,141 @@ config BSD_PROCESS_ACCT_V3
          for processing it. A preliminary version of these tools is available
          at <http://http://www.de.kernel.org/pub/linux/utils/acct/>.
 
+menu "Class Based Kernel Resource Management"
+
+config CKRM
+       bool "Class Based Kernel Resource Management Core"
+       depends on EXPERIMENTAL
+       help
+         Class-based Kernel Resource Management is a framework for controlling
+         and monitoring resource allocation of user-defined groups of tasks or
+         incoming socket connections. For more information, please visit
+         http://ckrm.sf.net. 
+
+         If you say Y here, enable the Resource Class File System and atleast
+         one of the resource controllers below. Say N if you are unsure. 
+
+config RCFS_FS
+       tristate "Resource Class File System (User API)"
+       depends on CKRM
+       help
+         RCFS is the filesystem API for CKRM. This separate configuration 
+         option is provided only for debugging and will eventually disappear 
+         since rcfs will be automounted whenever CKRM is configured. 
+
+          Say N if unsure, Y if you've enabled CKRM, M to debug rcfs 
+         initialization.
+
+config CKRM_TYPE_TASKCLASS
+       bool "Class Manager for Task Groups"
+       depends on CKRM
+       help
+         TASKCLASS provides the extensions for CKRM to track task classes
+         This is the base to enable task class based resource control for
+         cpu, memory and disk I/O.
+       
+         Say N if unsure 
+
+config CKRM_RES_NUMTASKS
+       tristate "Number of Tasks Resource Manager"
+       depends on CKRM_TYPE_TASKCLASS
+       default m
+       help
+         Provides a Resource Controller for CKRM that allows limiting no of
+         tasks a task class can have.
+       
+         Say N if unsure, Y to use the feature.
+
+config CKRM_CPU_SCHEDULE
+       bool "CKRM CPU scheduler"
+       depends on CKRM_TYPE_TASKCLASS
+       default y
+       help
+         Use CKRM CPU scheduler instead of Linux Scheduler
+       
+         Say N if unsure, Y to use the feature.
+
+config CKRM_RES_BLKIO
+       tristate " Disk I/O Resource Controller"
+       depends on CKRM_TYPE_TASKCLASS && IOSCHED_CFQ
+       default m
+       help
+         Provides a resource controller for best-effort block I/O 
+         bandwidth control. The controller attempts this by proportional 
+         servicing of requests in the I/O scheduler. However, seek
+         optimizations and reordering by device drivers/disk controllers may
+         alter the actual bandwidth delivered to a class.
+       
+         Say N if unsure, Y to use the feature.
+
+config CKRM_RES_MEM
+       bool "Class based physical memory controller"
+       default y
+       depends on CKRM
+       help
+         Provide the basic support for collecting physical memory usage information
+         among classes. Say Y if you want to know the memory usage of each class.
+
+config CKRM_MEM_LRUORDER_CHANGE
+       bool "Change the LRU ordering of scanned pages"
+       default n
+       depends on CKRM_RES_MEM
+       help
+         While trying to free pages, by default(n), scanned pages are left were they
+         are found if they belong to relatively under-used class. In this case the
+         LRU ordering of the memory subsystemis left intact. If this option is chosen,
+         then the scanned pages are moved to the tail of the list(active or inactive).
+         Changing this to yes reduces the checking overhead but violates the approximate
+         LRU order that is maintained by the paging subsystem.
+
+config CKRM_TYPE_SOCKETCLASS
+       bool "Class Manager for socket groups"
+       depends on CKRM
+       help
+         SOCKET provides the extensions for CKRM to track per socket
+         classes.  This is the base to enable socket based resource 
+         control for inbound connection control, bandwidth control etc.
+       
+         Say N if unsure.  
+
+config CKRM_RES_LISTENAQ
+       tristate "Multiple Accept Queues Resource Manager"
+       depends on CKRM_TYPE_SOCKETCLASS && ACCEPT_QUEUES
+       default m
+       help
+         Provides a  resource controller for CKRM to prioritize inbound
+         connection requests. See inbound control description for
+         "IP: TCP Multiple accept queues support". If you choose that
+         option choose this option to control the queue weights.
+         If unsure, say N.
+
+config CKRM_RBCE
+       tristate "Vanilla Rule-based Classification Engine (RBCE)"
+       depends on CKRM && RCFS_FS
+       default m
+       help
+         Provides an optional module to support creation of rules for automatic
+         classification of kernel objects. Rules are created/deleted/modified 
+          through an rcfs interface. RBCE is not required for CKRM. 
+         If unsure, say N.
+
+config CKRM_CRBCE
+       tristate "Enhanced Rule-based Classification Engine (RBCE)"
+       depends on CKRM && RCFS_FS && RELAYFS_FS && DELAY_ACCT
+       default m
+       help
+         Provides an optional module to support creation of rules for automatic
+         classification of kernel objects, just like RBCE above. In addition,
+         CRBCE provides per-process delay data (requires DELAY_ACCT configured)
+         enabled) and makes information on significant kernel events available
+         to userspace tools through relayfs (requires RELAYFS_FS configured). 
+       
+         If unsure, say N.
+
+endmenu
+
 config SYSCTL
        bool "Sysctl support"
        ---help---
@@ -216,6 +353,22 @@ config IKCONFIG_PROC
          This option enables access to the kernel configuration file
          through /proc/config.gz.
 
+config OOM_PANIC
+       bool "OOM Panic"
+       default y
+       ---help---
+         This option enables panic() to be called when a system is out of
+         memory. This feature along with /proc/sys/kernel/panic allows a
+         different behavior on out-of-memory conditions when the standard
+         behavior (killing processes in an attempt to recover) does not
+         make sense.
+
+         If unsure, say N.
+
+config OOM_KILL
+       bool
+       depends on !OOM_PANIC
+       default y
 
 menuconfig EMBEDDED
        bool "Configure standard kernel features (for small systems)"
@@ -225,6 +378,15 @@ menuconfig EMBEDDED
           environments which can tolerate a "non-standard" kernel.
           Only use this if you really know what you are doing.
 
+config DELAY_ACCT
+       bool "Enable delay accounting (EXPERIMENTAL)"
+       help
+         In addition to counting frequency the total delay in ns is also
+         recorded. CPU delays are specified as cpu-wait and cpu-run. 
+         I/O delays are recorded for memory and regular I/O.
+         Information is accessible through /proc/<pid>/delay.
+
+
 config KALLSYMS
         bool "Load all symbols for debugging/kksymoops" if EMBEDDED
         default y
@@ -273,7 +435,7 @@ config EPOLL
 source "drivers/block/Kconfig.iosched"
 
 config CC_OPTIMIZE_FOR_SIZE
-       bool "Optimize for size" if EMBEDDED
+       bool "Optimize for size"
        default y if ARM || H8300
        default n
        help
@@ -349,6 +511,21 @@ config MODVERSIONS
          make them incompatible with the kernel you are running.  If
          unsure, say N.
 
+config MODULE_SIG
+       bool "Module signature verification (EXPERIMENTAL)"
+       depends on MODULES && EXPERIMENTAL
+       select CRYPTO_SHA1
+       select CRYPTO_SIGNATURE
+       help
+         Check modules for valid signatures upon load.
+
+config MODULE_SIG_FORCE
+       bool "Required modules to be validly signed (EXPERIMENTAL)"
+       depends on MODULE_SIG
+       help
+         Reject unsigned modules or signed modules for which we don't have a
+         key.
+
 config KMOD
        bool "Automatic kernel module loading"
        depends on MODULES
index 767b47b..75aa662 100644 (file)
@@ -9,6 +9,9 @@ mounts-$(CONFIG_BLK_DEV_RAM)    += do_mounts_rd.o
 mounts-$(CONFIG_BLK_DEV_INITRD)        += do_mounts_initrd.o
 mounts-$(CONFIG_BLK_DEV_MD)    += do_mounts_md.o
 
+extra-$(subst m,y,$(CONFIG_CRASH_DUMP))        += kerntypes.o
+CFLAGS_kerntypes.o             := -gstabs
+
 # files to be removed upon make clean
 clean-files := ../include/linux/compile.h
 
diff --git a/init/kerntypes.c b/init/kerntypes.c
new file mode 100644 (file)
index 0000000..1c24c0b
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * kerntypes.c
+ *
+ * Copyright (C) 2000 Tom Morano (tjm@sgi.com) and
+ *                    Matt D. Robinson (yakker@alacritech.com)
+ *
+ * Dummy module that includes headers for all kernel types of interest. 
+ * The kernel type information is used by the lcrash utility when 
+ * analyzing system crash dumps or the live system. Using the type 
+ * information for the running system, rather than kernel header files,
+ * makes for a more flexible and robust analysis tool.
+ *
+ * This source code is released under version 2 of the GNU GPL.
+ */
+
+#include <linux/compile.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/config.h>
+#include <linux/utsname.h>
+#include <linux/dump.h>
+
+#ifdef LINUX_COMPILE_VERSION_ID_TYPE
+/* Define version type for version validation of dump and kerntypes */
+LINUX_COMPILE_VERSION_ID_TYPE;
+#endif
+
+void
+kerntypes_dummy(void)
+{
+}
index cafeaeb..6416eab 100644 (file)
 #include <asm/bugs.h>
 #include <asm/setup.h>
 
+#include <linux/ckrm.h>
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+int __init init_ckrm_sched_res(void);
+#else
+#define init_ckrm_sched_res() ((void)0)
+#endif
+//#include <linux/ckrm_sched.h>
+
 /*
  * This is one of the first .c files built. Error out early
  * if we have compiler trouble..
@@ -101,6 +109,16 @@ extern void tc_init(void);
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);
 
+/*
+ * The kernel_magic value represents the address of _end, which allows
+ * namelist tools to "match" each other respectively.  That way a tool
+ * that looks at /dev/mem can verify that it is using the right System.map
+ * file -- if kernel_magic doesn't equal the namelist value of _end,
+ * something's wrong.
+ */
+extern unsigned long _end;
+unsigned long *kernel_magic = &_end;
+
 /*
  * Boot command-line arguments
  */
@@ -399,6 +417,7 @@ static void noinline rest_init(void)
 {
        kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND);
        numa_default_policy();
+       system_state = SYSTEM_BOOTING_SCHEDULER_OK;
        unlock_kernel();
        cpu_idle();
 } 
@@ -478,6 +497,11 @@ asmlinkage void __init start_kernel(void)
        rcu_init();
        init_IRQ();
        pidhash_init();
+       /* MEF: In 2.6.5. ckrm_init was right after pidhash_init() but 
+                before sched_init(). Will leave it after pidhash_init()
+                and cross finger.
+       */
+       ckrm_init();
        init_timers();
        softirq_init();
        time_init();
@@ -528,6 +552,7 @@ asmlinkage void __init start_kernel(void)
 #ifdef CONFIG_PROC_FS
        proc_root_init();
 #endif
+
        check_bugs();
 
        /* 
@@ -666,7 +691,6 @@ static int init(void * unused)
 
        fixup_cpu_present_map();
        smp_init();
-       sched_init_smp();
 
        /*
         * Do this before initcalls, because some drivers want to access
@@ -676,6 +700,10 @@ static int init(void * unused)
 
        do_basic_setup();
 
+       init_ckrm_sched_res();
+
+       sched_init_smp();
+
        /*
         * check if there is an early userspace init.  If yes, let it do all
         * the work
index d8878ae..e027a09 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/uts.h>
 #include <linux/utsname.h>
 #include <linux/version.h>
+#include <linux/stringify.h>
 
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
@@ -31,3 +32,6 @@ EXPORT_SYMBOL(system_utsname);
 const char *linux_banner = 
        "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
        LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
+
+const char *LINUX_COMPILE_VERSION_ID = __stringify(LINUX_COMPILE_VERSION_ID);
+LINUX_COMPILE_VERSION_ID_TYPE;
index 63777b6..c4d3b2a 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -24,6 +24,8 @@
 #include <linux/list.h>
 #include <linux/security.h>
 #include <linux/sched.h>
+#include <linux/vs_base.h>
+
 #include <asm/current.h>
 #include <asm/uaccess.h>
 #include "util.h"
@@ -96,6 +98,7 @@ static int newque (key_t key, int msgflg)
 
        msq->q_perm.mode = (msgflg & S_IRWXUGO);
        msq->q_perm.key = key;
+       msq->q_perm.xid = current->xid;
 
        msq->q_perm.security = NULL;
        retval = security_msg_queue_alloc(msq);
@@ -788,7 +791,11 @@ static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int l
        for(i = 0; i <= msg_ids.max_id; i++) {
                struct msg_queue * msq;
                msq = msg_lock(i);
-               if(msq != NULL) {
+               if (msq) {
+                       if (!vx_check(msq->q_perm.xid, VX_IDENT)) {
+                               msg_unlock(msq);
+                               continue;       
+                       }
                        len += sprintf(buffer + len, "%10d %10d  %4o  %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n",
                                msq->q_perm.key,
                                msg_buildid(i,msq->q_perm.seq),
index 6ed7096..71936c9 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -71,6 +71,8 @@
 #include <linux/time.h>
 #include <linux/smp_lock.h>
 #include <linux/security.h>
+#include <linux/vs_base.h>
+
 #include <asm/uaccess.h>
 #include "util.h"
 
@@ -175,6 +177,7 @@ static int newary (key_t key, int nsems, int semflg)
 
        sma->sem_perm.mode = (semflg & S_IRWXUGO);
        sma->sem_perm.key = key;
+       sma->sem_perm.xid = current->xid;
 
        sma->sem_perm.security = NULL;
        retval = security_sem_alloc(sma);
@@ -1296,7 +1299,11 @@ static int sysvipc_sem_read_proc(char *buffer, char **start, off_t offset, int l
        for(i = 0; i <= sem_ids.max_id; i++) {
                struct sem_array *sma;
                sma = sem_lock(i);
-               if(sma) {
+               if (sma) {
+                       if (!vx_check(sma->sem_perm.xid, VX_IDENT)) {
+                               sem_unlock(sma);
+                               continue;
+                       }
                        len += sprintf(buffer + len, "%10d %10d  %4o %10lu %5u %5u %5u %5u %10lu %10lu\n",
                                sma->sem_perm.key,
                                sem_buildid(i,sma->sem_perm.seq),
index d519c9b..f763a02 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -26,6 +26,8 @@
 #include <linux/proc_fs.h>
 #include <linux/shmem_fs.h>
 #include <linux/security.h>
+#include <linux/vs_base.h>
+
 #include <asm/uaccess.h>
 
 #include "util.h"
@@ -114,7 +116,10 @@ static void shm_destroy (struct shmid_kernel *shp)
        shm_rmid (shp->id);
        shm_unlock(shp);
        if (!is_file_hugepages(shp->shm_file))
-               shmem_lock(shp->shm_file, 0);
+               shmem_lock(shp->shm_file, 0, shp->mlock_user);
+       else
+               user_shm_unlock(shp->shm_file->f_dentry->d_inode->i_size,
+                                               shp->mlock_user);
        fput (shp->shm_file);
        security_shm_free(shp);
        ipc_rcu_free(shp, sizeof(struct shmid_kernel));
@@ -189,7 +194,9 @@ static int newseg (key_t key, int shmflg, size_t size)
                return -ENOMEM;
 
        shp->shm_perm.key = key;
+       shp->shm_perm.xid = current->xid;
        shp->shm_flags = (shmflg & S_IRWXUGO);
+       shp->mlock_user = NULL;
 
        shp->shm_perm.security = NULL;
        error = security_shm_alloc(shp);
@@ -198,9 +205,11 @@ static int newseg (key_t key, int shmflg, size_t size)
                return error;
        }
 
-       if (shmflg & SHM_HUGETLB)
+       if (shmflg & SHM_HUGETLB) {
+               /* hugetlb_zero_setup takes care of mlock user accounting */
                file = hugetlb_zero_setup(size);
-       else {
+               shp->mlock_user = current->user;
+       } else {
                sprintf (name, "SYSV%08x", key);
                file = shmem_file_setup(name, size, VM_ACCOUNT);
        }
@@ -504,14 +513,11 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
        case SHM_LOCK:
        case SHM_UNLOCK:
        {
-/* Allow superuser to lock segment in memory */
-/* Should the pages be faulted in here or leave it to user? */
-/* need to determine interaction with current->swappable */
-               if (!capable(CAP_IPC_LOCK)) {
+               /* Allow superuser to lock segment in memory */
+               if (!can_do_mlock() && cmd == SHM_LOCK) {
                        err = -EPERM;
                        goto out;
                }
-
                shp = shm_lock(shmid);
                if(shp==NULL) {
                        err = -EINVAL;
@@ -526,13 +532,18 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
                        goto out_unlock;
                
                if(cmd==SHM_LOCK) {
-                       if (!is_file_hugepages(shp->shm_file))
-                               shmem_lock(shp->shm_file, 1);
-                       shp->shm_flags |= SHM_LOCKED;
-               } else {
-                       if (!is_file_hugepages(shp->shm_file))
-                               shmem_lock(shp->shm_file, 0);
+                       struct user_struct * user = current->user;
+                       if (!is_file_hugepages(shp->shm_file)) {
+                               err = shmem_lock(shp->shm_file, 1, user);
+                               if (!err) {
+                                       shp->shm_flags |= SHM_LOCKED;
+                                       shp->mlock_user = user;
+                               }
+                       }
+               } else if (!is_file_hugepages(shp->shm_file)) {
+                       shmem_lock(shp->shm_file, 0, shp->mlock_user);
                        shp->shm_flags &= ~SHM_LOCKED;
+                       shp->mlock_user = NULL;
                }
                shm_unlock(shp);
                goto out;
@@ -847,11 +858,15 @@ static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int l
                struct shmid_kernel* shp;
 
                shp = shm_lock(i);
-               if(shp!=NULL) {
+               if (shp) {
 #define SMALL_STRING "%10d %10d  %4o %10u %5u %5u  %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
 #define BIG_STRING   "%10d %10d  %4o %21u %5u %5u  %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
                        char *format;
 
+                       if (!vx_check(shp->shm_perm.xid, VX_IDENT)) {
+                               shm_unlock(shp);
+                               continue;       
+                       }
                        if (sizeof(size_t) <= sizeof(int))
                                format = SMALL_STRING;
                        else
index 727c332..dbaf6d5 100644 (file)
@@ -24,6 +24,9 @@
 #include <linux/security.h>
 #include <linux/rcupdate.h>
 #include <linux/workqueue.h>
+#include <linux/vs_base.h>
+
+#include <asm/unistd.h>
 
 #include <asm/unistd.h>
 
@@ -105,8 +108,10 @@ int ipc_findkey(struct ipc_ids* ids, key_t key)
         */
        for (id = 0; id <= max_id; id++) {
                p = ids->entries[id].p;
-               if(p==NULL)
+               if (p==NULL)
                        continue;
+               if (!vx_check(p->xid, VX_IDENT))
+                       continue;       
                if (key == p->key)
                        return id;
        }
@@ -384,6 +389,8 @@ int ipcperms (struct kern_ipc_perm *ipcp, short flag)
 {      /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */
        int requested_mode, granted_mode;
 
+       if (!vx_check(ipcp->xid, VX_ADMIN|VX_IDENT)) /* maybe just VX_IDENT? */
+               return -1;
        requested_mode = (flag >> 6) | (flag >> 3) | flag;
        granted_mode = ipcp->mode;
        if (current->euid == ipcp->cuid || current->euid == ipcp->uid)
index 47f9859..ec50010 100644 (file)
@@ -7,13 +7,19 @@ obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
            sysctl.o capability.o ptrace.o timer.o user.o \
            signal.o sys.o kmod.o workqueue.o pid.o \
            rcupdate.o intermodule.o extable.o params.o posix-timers.o \
-           kthread.o
+           kthread.o ckrm/
+
+# mod-subdirs := vserver
+
+subdir-y  += vserver
+obj-y    += vserver/vserver.o
 
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o
 obj-$(CONFIG_UID16) += uid16.o
 obj-$(CONFIG_MODULES) += module.o
+obj-$(CONFIG_MODULE_SIG) += module-verify.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_PM) += power/
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
@@ -21,6 +27,7 @@ obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_IKCONFIG) += configs.o
 obj-$(CONFIG_IKCONFIG_PROC) += configs.o
 obj-$(CONFIG_STOP_MACHINE) += stop_machine.o
+obj-$(CONFIG_CKRM_CPU_SCHEDULE) += ckrm_classqueue.o ckrm_sched.o
 obj-$(CONFIG_AUDIT) += audit.o
 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
 
diff --git a/kernel/ckrm/Makefile b/kernel/ckrm/Makefile
new file mode 100644 (file)
index 0000000..b325309
--- /dev/null
@@ -0,0 +1,13 @@
+#
+# Makefile for CKRM
+#
+
+ifeq ($(CONFIG_CKRM),y)
+    obj-y = ckrm.o ckrmutils.o ckrm_numtasks_stub.o rbce/
+endif  
+    obj-$(CONFIG_CKRM_TYPE_TASKCLASS)  += ckrm_tc.o
+    obj-$(CONFIG_CKRM_RES_NUMTASKS)    += ckrm_numtasks.o
+    obj-$(CONFIG_CKRM_TYPE_SOCKETCLASS) += ckrm_sockc.o
+    obj-$(CONFIG_CKRM_RES_LISTENAQ)    += ckrm_laq.o
+    obj-$(CONFIG_CKRM_CPU_SCHEDULE)     += ckrm_cpu_class.o ckrm_cpu_monitor.o
+    obj-$(CONFIG_CKRM_RES_MEM)                 += ckrm_mem.o
diff --git a/kernel/ckrm/ckrm.c b/kernel/ckrm/ckrm.c
new file mode 100644 (file)
index 0000000..f1cfb26
--- /dev/null
@@ -0,0 +1,1033 @@
+/* ckrm.c - Class-based Kernel Resource Management (CKRM)
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003, 2004
+ *           (C) Shailabh Nagar,  IBM Corp. 2003, 2004
+ *           (C) Chandra Seetharaman,  IBM Corp. 2003
+ *          (C) Vivek Kashyap, IBM Corp. 2004
+ * 
+ * 
+ * Provides kernel API of CKRM for in-kernel,per-resource controllers 
+ * (one each for cpu, memory, io, network) and callbacks for 
+ * classification modules.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 28 Aug 2003
+ *        Created.
+ * 06 Nov 2003
+ *        Made modifications to suit the new RBCE module.
+ * 10 Nov 2003
+ *        Fixed a bug in fork and exit callbacks. Added callbacks_active and
+ *        surrounding logic. Added task paramter for all CE callbacks.
+ * 23 Mar 2004
+ *        moved to referenced counted class objects and correct locking
+ * 19 Apr 2004
+ *        Integrated ckrm hooks, classtypes, ...
+ *  
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <asm/uaccess.h>
+#include <linux/mm.h>
+#include <asm/errno.h>
+#include <linux/string.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/ckrm_rc.h>
+#include <linux/rcfs.h>
+#include <net/sock.h>
+#include <linux/ip.h>
+
+rwlock_t ckrm_class_lock = RW_LOCK_UNLOCKED;   // protect classlists 
+
+struct rcfs_functions rcfs_fn;
+EXPORT_SYMBOL(rcfs_fn);
+
+// rcfs state needed by another module
+int rcfs_engine_regd;
+EXPORT_SYMBOL(rcfs_engine_regd);
+
+int rcfs_mounted;
+EXPORT_SYMBOL(rcfs_mounted);
+
+/**************************************************************************
+ *                   Helper Functions                                     *
+ **************************************************************************/
+
+/*
+ * Return TRUE if the given core class pointer is valid.
+ */
+
+/*
+ * Return TRUE if the given resource is registered.
+ */
+inline unsigned int is_res_regd(struct ckrm_classtype *clstype, int resid)
+{
+       return ((resid >= 0) && (resid < clstype->max_resid) &&
+               test_bit(resid, &clstype->bit_res_ctlrs)
+           );
+}
+
+struct ckrm_res_ctlr *ckrm_resctlr_lookup(struct ckrm_classtype *clstype,
+                                         const char *resname)
+{
+       int resid = -1;
+
+       if (!clstype || !resname) {
+               return NULL;
+       }
+       for (resid = 0; resid < clstype->max_resid; resid++) {
+               if (test_bit(resid, &clstype->bit_res_ctlrs)) {
+                       struct ckrm_res_ctlr *rctrl = clstype->res_ctlrs[resid];
+                       if (!strncmp(resname, rctrl->res_name,
+                                    CKRM_MAX_RES_NAME))
+                               return rctrl;
+               }
+       }
+       return NULL;
+}
+
+EXPORT_SYMBOL(ckrm_resctlr_lookup);
+
+/* given a classname return the class handle and its classtype*/
+void *ckrm_classobj(char *classname, int *classTypeID)
+{
+       int i;
+
+       *classTypeID = -1;
+       if (!classname || !*classname) {
+               return NULL;
+       }
+
+       read_lock(&ckrm_class_lock);
+       for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
+               struct ckrm_classtype *ctype = ckrm_classtypes[i];
+               struct ckrm_core_class *core;
+
+               if (ctype == NULL)
+                       continue;
+               list_for_each_entry(core, &ctype->classes, clslist) {
+                       if (core->name && !strcmp(core->name, classname)) {
+                               // FIXME:   should grep reference..
+                               read_unlock(&ckrm_class_lock);
+                               *classTypeID = ctype->typeID;
+                               return core;
+                       }
+               }
+       }
+       read_unlock(&ckrm_class_lock);
+       return NULL;
+}
+
+EXPORT_SYMBOL(is_res_regd);
+EXPORT_SYMBOL(ckrm_classobj);
+
+/**************************************************************************
+ *                   Internal Functions/macros                            *
+ **************************************************************************/
+
+static inline void set_callbacks_active(struct ckrm_classtype *ctype)
+{
+       ctype->ce_cb_active = ((atomic_read(&ctype->ce_regd) > 0) &&
+                              (ctype->ce_callbacks.always_callback
+                               || (ctype->num_classes > 1)));
+}
+
+int ckrm_validate_and_grab_core(struct ckrm_core_class *core)
+{
+       int rc = 0;
+       read_lock(&ckrm_class_lock);
+       if (likely(ckrm_is_core_valid(core))) {
+               ckrm_core_grab(core);
+               rc = 1;
+       }
+       read_unlock(&ckrm_class_lock);
+       return rc;
+}
+
+/****************************************************************************
+ *           Interfaces for classification engine                           *
+ ****************************************************************************/
+
+/*
+ * Registering a callback structure by the classification engine.
+ *
+ * Returns typeId of class on success -errno for failure.
+ */
+int ckrm_register_engine(const char *typename, ckrm_eng_callback_t * ecbs)
+{
+       struct ckrm_classtype *ctype;
+
+       ctype = ckrm_find_classtype_by_name(typename);
+       if (ctype == NULL)
+               return (-ENOENT);
+
+       atomic_inc(&ctype->ce_regd);
+
+       /* another engine registered or trying to register ? */
+       if (atomic_read(&ctype->ce_regd) != 1) {
+               atomic_dec(&ctype->ce_regd);
+               return (-EBUSY);
+       }
+
+       /* One of the following must be set: 
+          classify, class_delete (due to object reference) or 
+          notify (case where notification supported but not classification)
+          The function pointer must be set the momement the mask is non-null
+        */
+
+       if (!(((ecbs->classify) && (ecbs->class_delete)) || (ecbs->notify)) ||
+           (ecbs->c_interest && ecbs->classify == NULL) ||
+           (ecbs->n_interest && ecbs->notify == NULL)) {
+               atomic_dec(&ctype->ce_regd);
+               return (-EINVAL);
+       }
+
+       ctype->ce_callbacks = *ecbs;
+       set_callbacks_active(ctype);
+
+       if (ctype->ce_callbacks.class_add) {
+               struct ckrm_core_class *core;
+
+               read_lock(&ckrm_class_lock);
+
+               list_for_each_entry(core, &ctype->classes, clslist) {
+                       (*ctype->ce_callbacks.class_add) (core->name, core,
+                                                         ctype->typeID);
+               }
+               read_unlock(&ckrm_class_lock);
+       }
+       return ctype->typeID;
+}
+
+/*
+ * Unregistering a callback structure by the classification engine.
+ *
+ * Returns 0 on success -errno for failure.
+ */
+int ckrm_unregister_engine(const char *typename)
+{
+       struct ckrm_classtype *ctype;
+
+       ctype = ckrm_find_classtype_by_name(typename);
+       if (ctype == NULL)
+               return (-ENOENT);
+
+       ctype->ce_cb_active = 0;
+
+       if (atomic_read(&ctype->ce_nr_users) > 1) {
+               // Somebody is currently using the engine, cannot deregister.
+               return (-EAGAIN);
+       }
+
+       atomic_set(&ctype->ce_regd, 0);
+       memset(&ctype->ce_callbacks, 0, sizeof(ckrm_eng_callback_t));
+       return 0;
+}
+
+/****************************************************************************
+ *           Interfaces to manipulate class (core or resource) hierarchies 
+ ****************************************************************************/
+
+/* 
+ */
+static void
+ckrm_add_child(struct ckrm_core_class *parent, struct ckrm_core_class *child)
+{
+       struct ckrm_hnode *cnode = &child->hnode;
+
+       if (!ckrm_is_core_valid(child)) {
+               printk(KERN_ERR "Invalid child %p given in ckrm_add_child\n",
+                      child);
+               return;
+       }
+
+       class_lock(child);
+       INIT_LIST_HEAD(&cnode->children);
+       INIT_LIST_HEAD(&cnode->siblings);
+
+       if (parent) {
+               struct ckrm_hnode *pnode;
+
+               if (!ckrm_is_core_valid(parent)) {
+                       printk(KERN_ERR
+                              "Invalid parent %p given in ckrm_add_child\n",
+                              parent);
+                       parent = NULL;
+               } else {
+                       pnode = &parent->hnode;
+                       write_lock(&parent->hnode_rwlock);
+                       list_add(&cnode->siblings, &pnode->children);
+                       write_unlock(&parent->hnode_rwlock);
+               }
+       }
+       cnode->parent = parent;
+       class_unlock(child);
+       return;
+}
+
+/* 
+ */
+static int ckrm_remove_child(struct ckrm_core_class *child)
+{
+       struct ckrm_hnode *cnode, *pnode;
+       struct ckrm_core_class *parent;
+
+       if (!ckrm_is_core_valid(child)) {
+               printk(KERN_ERR "Invalid child %p given"
+                               " in ckrm_remove_child\n",
+                       child);
+               return 0;
+       }
+
+       cnode = &child->hnode;
+       parent = cnode->parent;
+       if (!ckrm_is_core_valid(parent)) {
+               printk(KERN_ERR "Invalid parent %p in ckrm_remove_child\n",
+                      parent);
+               return 0;
+       }
+
+       pnode = &parent->hnode;
+
+       class_lock(child);
+       /* ensure that the node does not have children */
+       if (!list_empty(&cnode->children)) {
+               class_unlock(child);
+               return 0;
+       }
+       write_lock(&parent->hnode_rwlock);
+       list_del(&cnode->siblings);
+       write_unlock(&parent->hnode_rwlock);
+       cnode->parent = NULL;
+       class_unlock(child);
+       return 1;
+}
+
+void ckrm_lock_hier(struct ckrm_core_class *parent)
+{
+       if (ckrm_is_core_valid(parent)) {
+               read_lock(&parent->hnode_rwlock);
+       }
+}
+
+void ckrm_unlock_hier(struct ckrm_core_class *parent)
+{
+       if (ckrm_is_core_valid(parent)) {
+               read_unlock(&parent->hnode_rwlock);
+       }
+}
+
+/*
+ * hnode_rwlock of the parent core class must held in read mode.
+ * external callers should 've called ckrm_lock_hier before calling this
+ * function.
+ */
+#define hnode_2_core(ptr) \
+((ptr)? container_of(ptr, struct ckrm_core_class, hnode) : NULL)
+
+struct ckrm_core_class *ckrm_get_next_child(struct ckrm_core_class *parent,
+                                           struct ckrm_core_class *child)
+{
+       struct list_head *cnode;
+       struct ckrm_hnode *next_cnode;
+       struct ckrm_core_class *next_childcore;
+
+       if (!ckrm_is_core_valid(parent)) {
+               printk(KERN_ERR "Invalid parent %p in ckrm_get_next_child\n",
+                      parent);
+               return NULL;
+       }
+       if (list_empty(&parent->hnode.children)) {
+               return NULL;
+       }
+
+       if (child) {
+               if (!ckrm_is_core_valid(child)) {
+                       printk(KERN_ERR
+                              "Invalid child %p in ckrm_get_next_child\n",
+                              child);
+                       return NULL;
+               }
+               cnode = child->hnode.siblings.next;
+       } else {
+               cnode = parent->hnode.children.next;
+       }
+
+       if (cnode == &parent->hnode.children) { // back at the anchor
+               return NULL;
+       }
+
+       next_cnode = container_of(cnode, struct ckrm_hnode, siblings);
+       next_childcore = hnode_2_core(next_cnode);
+
+       if (!ckrm_is_core_valid(next_childcore)) {
+               printk(KERN_ERR
+                      "Invalid next child %p in ckrm_get_next_child\n",
+                      next_childcore);
+               return NULL;
+       }
+       return next_childcore;
+}
+
+EXPORT_SYMBOL(ckrm_lock_hier);
+EXPORT_SYMBOL(ckrm_unlock_hier);
+EXPORT_SYMBOL(ckrm_get_next_child);
+
+static void
+ckrm_alloc_res_class(struct ckrm_core_class *core,
+                    struct ckrm_core_class *parent, int resid)
+{
+
+       struct ckrm_classtype *clstype;
+
+       /* 
+        * Allocate a resource class only if the resource controller has
+        * registered with core and the engine requests for the class.
+        */
+
+       if (!ckrm_is_core_valid(core))
+               return;
+
+       clstype = core->classtype;
+       core->res_class[resid] = NULL;
+
+       if (test_bit(resid, &clstype->bit_res_ctlrs)) {
+               ckrm_res_ctlr_t *rcbs;
+
+               atomic_inc(&clstype->nr_resusers[resid]);
+               rcbs = clstype->res_ctlrs[resid];
+
+               if (rcbs && rcbs->res_alloc) {
+                       core->res_class[resid] =
+                           (*rcbs->res_alloc) (core, parent);
+                       if (core->res_class[resid])
+                               return;
+                       printk(KERN_ERR "Error creating res class\n");
+               }
+               atomic_dec(&clstype->nr_resusers[resid]);
+       }
+}
+
+/*
+ * Initialize a core class
+ *
+ */
+
+#define CLS_DEBUG(fmt, args...) \
+do { /* printk("%s: " fmt, __FUNCTION__ , ## args); */ } while (0)
+
+int
+ckrm_init_core_class(struct ckrm_classtype *clstype,
+                    struct ckrm_core_class *dcore,
+                    struct ckrm_core_class *parent, const char *name)
+{
+       // Hubertus   ... should replace name with dentry or add dentry ?
+       int i;
+
+       // Hubertus .. how is this used in initialization 
+
+       CLS_DEBUG("name %s => %p\n", name ? name : "default", dcore);
+
+       if ((dcore != clstype->default_class) && (!ckrm_is_core_valid(parent))){
+               printk(KERN_DEBUG "error not a valid parent %p\n", parent);
+               return -EINVAL;
+       }
+#if 0  
+// Hubertus .. dynamic allocation still breaks when RCs registers. 
+// See def in ckrm_rc.h
+       dcore->res_class = NULL;
+       if (clstype->max_resid > 0) {
+               dcore->res_class =
+                   (void **)kmalloc(clstype->max_resid * sizeof(void *),
+                                    GFP_KERNEL);
+               if (dcore->res_class == NULL) {
+                       printk(KERN_DEBUG "error no mem\n");
+                       return -ENOMEM;
+               }
+       }
+#endif
+
+       dcore->classtype = clstype;
+       dcore->magic = CKRM_CORE_MAGIC;
+       dcore->name = name;
+       dcore->class_lock = SPIN_LOCK_UNLOCKED;
+       dcore->hnode_rwlock = RW_LOCK_UNLOCKED;
+       dcore->delayed = 0;
+
+       atomic_set(&dcore->refcnt, 0);
+       write_lock(&ckrm_class_lock);
+
+       INIT_LIST_HEAD(&dcore->objlist);
+       list_add_tail(&dcore->clslist, &clstype->classes);
+
+       clstype->num_classes++;
+       set_callbacks_active(clstype);
+
+       write_unlock(&ckrm_class_lock);
+       ckrm_add_child(parent, dcore);
+
+       for (i = 0; i < clstype->max_resid; i++)
+               ckrm_alloc_res_class(dcore, parent, i);
+
+       // fix for race condition seen in stress with numtasks
+       if (parent)
+               ckrm_core_grab(parent);
+
+       ckrm_core_grab(dcore);
+       return 0;
+}
+
+static void ckrm_free_res_class(struct ckrm_core_class *core, int resid)
+{
+       /* 
+        * Free a resource class only if the resource controller has
+        * registered with core 
+        */
+       if (core->res_class[resid]) {
+               ckrm_res_ctlr_t *rcbs;
+               struct ckrm_classtype *clstype = core->classtype;
+
+               atomic_inc(&clstype->nr_resusers[resid]);
+               rcbs = clstype->res_ctlrs[resid];
+
+               if (rcbs->res_free) {
+                       (*rcbs->res_free) (core->res_class[resid]);
+                       // compensate inc in alloc
+                       atomic_dec(&clstype->nr_resusers[resid]); 
+               }
+               atomic_dec(&clstype->nr_resusers[resid]);
+       }
+       core->res_class[resid] = NULL;
+}
+
+/*
+ * Free a core class 
+ *   requires that all tasks were previously reassigned to another class
+ *
+ * Returns 0 on success -errno on failure.
+ */
+
+void ckrm_free_core_class(struct ckrm_core_class *core)
+{
+       int i;
+       struct ckrm_classtype *clstype = core->classtype;
+       struct ckrm_core_class *parent = core->hnode.parent;
+
+       CLS_DEBUG("core=%p:%s parent=%p:%s\n", core, core->name, parent,
+                 parent->name);
+       if (core->delayed) {
+               /* this core was marked as late */
+               printk(KERN_DEBUG "class <%s> finally deleted %lu\n", core->name, jiffies);
+       }
+       if (ckrm_remove_child(core) == 0) {
+               printk(KERN_DEBUG "Core class removal failed. Chilren present\n");
+       }
+
+       for (i = 0; i < clstype->max_resid; i++) {
+               ckrm_free_res_class(core, i);
+       }
+
+       write_lock(&ckrm_class_lock);
+
+       // Clear the magic, so we would know if this core is reused.
+       core->magic = 0;
+#if 0                          // Dynamic not yet enabled
+       core->res_class = NULL;
+#endif
+       // Remove this core class from its linked list.
+       list_del(&core->clslist);
+       clstype->num_classes--;
+       set_callbacks_active(clstype);
+       write_unlock(&ckrm_class_lock);
+
+       // fix for race condition seen in stress with numtasks
+       if (parent)
+               ckrm_core_drop(parent);
+
+       kfree(core);
+}
+
+int ckrm_release_core_class(struct ckrm_core_class *core)
+{
+       if (!ckrm_is_core_valid(core)) {
+               // Invalid core
+               return (-EINVAL);
+       }
+
+       if (core == core->classtype->default_class)
+               return 0;
+
+       /* need to make sure that the classgot really dropped */
+       if (atomic_read(&core->refcnt) != 1) {
+               CLS_DEBUG("class <%s> deletion delayed refcnt=%d jif=%ld\n",
+                         core->name, atomic_read(&core->refcnt), jiffies);
+               core->delayed = 1;      /* just so we have a ref point */
+       }
+       ckrm_core_drop(core);
+       return 0;
+}
+
+/****************************************************************************
+ *           Interfaces for the resource controller                         *
+ ****************************************************************************/
+/*
+ * Registering a callback structure by the resource controller.
+ *
+ * Returns the resource id(0 or +ve) on success, -errno for failure.
+ */
+static int
+ckrm_register_res_ctlr_intern(struct ckrm_classtype *clstype,
+                             ckrm_res_ctlr_t * rcbs)
+{
+       int resid, ret, i;
+
+       if (!rcbs)
+               return -EINVAL;
+
+       resid = rcbs->resid;
+
+       spin_lock(&clstype->res_ctlrs_lock);
+
+       printk(KERN_WARNING "resid is %d name is %s %s\n",
+              resid, rcbs->res_name, clstype->res_ctlrs[resid]->res_name);
+
+       if (resid >= 0) {
+               if ((resid < CKRM_MAX_RES_CTLRS)
+                   && (clstype->res_ctlrs[resid] == NULL)) {
+                       clstype->res_ctlrs[resid] = rcbs;
+                       atomic_set(&clstype->nr_resusers[resid], 0);
+                       set_bit(resid, &clstype->bit_res_ctlrs);
+                       ret = resid;
+                       if (resid >= clstype->max_resid) {
+                               clstype->max_resid = resid + 1;
+                       }
+               } else {
+                       ret = -EBUSY;
+               }
+               spin_unlock(&clstype->res_ctlrs_lock);
+               return ret;
+       }
+
+       for (i = clstype->resid_reserved; i < clstype->max_res_ctlrs; i++) {
+               if (clstype->res_ctlrs[i] == NULL) {
+                       clstype->res_ctlrs[i] = rcbs;
+                       rcbs->resid = i;
+                       atomic_set(&clstype->nr_resusers[i], 0);
+                       set_bit(i, &clstype->bit_res_ctlrs);
+                       if (i >= clstype->max_resid) {
+                               clstype->max_resid = i + 1;
+                       }
+                       spin_unlock(&clstype->res_ctlrs_lock);
+                       return i;
+               }
+       }
+
+       spin_unlock(&clstype->res_ctlrs_lock);
+       return (-ENOMEM);
+}
+
+int
+ckrm_register_res_ctlr(struct ckrm_classtype *clstype, ckrm_res_ctlr_t * rcbs)
+{
+       struct ckrm_core_class *core;
+       int resid;
+
+       resid = ckrm_register_res_ctlr_intern(clstype, rcbs);
+
+       if (resid >= 0) {
+               /* run through all classes and create the resource class 
+                * object and if necessary "initialize" class in context 
+                * of this resource 
+                */
+               read_lock(&ckrm_class_lock);
+               list_for_each_entry(core, &clstype->classes, clslist) {
+                       printk(KERN_INFO "CKRM .. create res clsobj for resouce <%s>"
+                              "class <%s> par=%p\n", rcbs->res_name, 
+                              core->name, core->hnode.parent);
+                       ckrm_alloc_res_class(core, core->hnode.parent, resid);
+
+                       if (clstype->add_resctrl) { 
+                               // FIXME: this should be mandatory
+                               (*clstype->add_resctrl) (core, resid);
+                       }
+               }
+               read_unlock(&ckrm_class_lock);
+       }
+       return resid;
+}
+
+/*
+ * Unregistering a callback structure by the resource controller.
+ *
+ * Returns 0 on success -errno for failure.
+ */
+int ckrm_unregister_res_ctlr(struct ckrm_res_ctlr *rcbs)
+{
+       struct ckrm_classtype *clstype = rcbs->classtype;
+       struct ckrm_core_class *core = NULL;
+       int resid = rcbs->resid;
+
+       if ((clstype == NULL) || (resid < 0)) {
+               return -EINVAL;
+       }
+       // FIXME: probably need to also call deregistration function
+
+       read_lock(&ckrm_class_lock);
+       // free up this resource from all the classes
+       list_for_each_entry(core, &clstype->classes, clslist) {
+               ckrm_free_res_class(core, resid);
+       }
+       read_unlock(&ckrm_class_lock);
+
+       if (atomic_read(&clstype->nr_resusers[resid])) {
+               return -EBUSY;
+       }
+
+       spin_lock(&clstype->res_ctlrs_lock);
+       clstype->res_ctlrs[resid] = NULL;
+       clear_bit(resid, &clstype->bit_res_ctlrs);
+       clstype->max_resid = fls(clstype->bit_res_ctlrs);
+       rcbs->resid = -1;
+       spin_unlock(&clstype->res_ctlrs_lock);
+
+       return 0;
+}
+
+/*******************************************************************
+ *   Class Type Registration
+ *******************************************************************/
+
+/* Hubertus ... we got to do some locking here */
+
+
+struct ckrm_classtype *ckrm_classtypes[CKRM_MAX_CLASSTYPES];
+// really should build a better interface for this
+EXPORT_SYMBOL(ckrm_classtypes);        
+
+int ckrm_register_classtype(struct ckrm_classtype *clstype)
+{
+       int tid = clstype->typeID;
+
+       if (tid != -1) {
+               if ((tid < 0) || (tid > CKRM_MAX_CLASSTYPES)
+                   || (ckrm_classtypes[tid]))
+                       return -EINVAL;
+       } else {
+               int i;
+               for (i = CKRM_RESV_CLASSTYPES; i < CKRM_MAX_CLASSTYPES; i++) {
+                       if (ckrm_classtypes[i] == NULL) {
+                               tid = i;
+                               break;
+                       }
+               }
+       }
+       if (tid == -1)
+               return -EBUSY;
+       clstype->typeID = tid;
+       ckrm_classtypes[tid] = clstype;
+
+       /* Hubertus .. we need to call the callbacks of the RCFS client */
+       if (rcfs_fn.register_classtype) {
+               (*rcfs_fn.register_classtype) (clstype);
+               // No error return for now ;
+       }
+
+       return tid;
+}
+
+int ckrm_unregister_classtype(struct ckrm_classtype *clstype)
+{
+       int tid = clstype->typeID;
+
+       if ((tid < 0) || (tid > CKRM_MAX_CLASSTYPES)
+           || (ckrm_classtypes[tid] != clstype))
+               return -EINVAL;
+
+       if (rcfs_fn.deregister_classtype) {
+               (*rcfs_fn.deregister_classtype) (clstype);
+               // No error return for now
+       }
+
+       ckrm_classtypes[tid] = NULL;
+       clstype->typeID = -1;
+       return 0;
+}
+
+struct ckrm_classtype *ckrm_find_classtype_by_name(const char *name)
+{
+       int i;
+       for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
+               struct ckrm_classtype *ctype = ckrm_classtypes[i];
+               if (ctype && !strncmp(ctype->name, name, CKRM_MAX_TYPENAME_LEN))
+                       return ctype;
+       }
+       return NULL;
+}
+
+/*******************************************************************
+ *   Event callback invocation
+ *******************************************************************/
+
+struct ckrm_hook_cb *ckrm_event_callbacks[CKRM_NONLATCHABLE_EVENTS];
+
+/* Registration / Deregistration / Invocation functions */
+
+int ckrm_register_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb)
+{
+       struct ckrm_hook_cb **cbptr;
+
+       if ((ev < CKRM_LATCHABLE_EVENTS) || (ev >= CKRM_NONLATCHABLE_EVENTS))
+               return 1;
+       cbptr = &ckrm_event_callbacks[ev];
+       while (*cbptr != NULL)
+               cbptr = &((*cbptr)->next);
+       *cbptr = cb;
+       return 0;
+}
+
+int ckrm_unregister_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb)
+{
+       struct ckrm_hook_cb **cbptr;
+
+       if ((ev < CKRM_LATCHABLE_EVENTS) || (ev >= CKRM_NONLATCHABLE_EVENTS))
+               return -1;
+       cbptr = &ckrm_event_callbacks[ev];
+       while ((*cbptr != NULL) && (*cbptr != cb))
+               cbptr = &((*cbptr)->next);
+       if (*cbptr)
+               (*cbptr)->next = cb->next;
+       return (*cbptr == NULL);
+}
+
+int ckrm_register_event_set(struct ckrm_event_spec especs[])
+{
+       struct ckrm_event_spec *espec = especs;
+
+       for (espec = especs; espec->ev != -1; espec++)
+               ckrm_register_event_cb(espec->ev, &espec->cb);
+       return 0;
+}
+
+int ckrm_unregister_event_set(struct ckrm_event_spec especs[])
+{
+       struct ckrm_event_spec *espec = especs;
+
+       for (espec = especs; espec->ev != -1; espec++)
+               ckrm_unregister_event_cb(espec->ev, &espec->cb);
+       return 0;
+}
+
+#define ECC_PRINTK(fmt, args...) \
+// printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
+
+void ckrm_invoke_event_cb_chain(enum ckrm_event ev, void *arg)
+{
+       struct ckrm_hook_cb *cb, *anchor;
+
+       ECC_PRINTK("%d %x\n", current, ev, arg);
+       if ((anchor = ckrm_event_callbacks[ev]) != NULL) {
+               for (cb = anchor; cb; cb = cb->next)
+                       (*cb->fct) (arg);
+       }
+}
+
+/*******************************************************************
+ *   Generic Functions that can be used as default functions 
+ *   in almost all classtypes
+ *     (a) function iterator over all resource classes of a class
+ *     (b) function invoker on a named resource
+ *******************************************************************/
+
+int ckrm_class_show_shares(struct ckrm_core_class *core, struct seq_file *seq)
+{
+       int i;
+       struct ckrm_res_ctlr *rcbs;
+       struct ckrm_classtype *clstype = core->classtype;
+       struct ckrm_shares shares;
+
+       for (i = 0; i < clstype->max_resid; i++) {
+               atomic_inc(&clstype->nr_resusers[i]);
+               rcbs = clstype->res_ctlrs[i];
+               if (rcbs && rcbs->get_share_values) {
+                       (*rcbs->get_share_values) (core->res_class[i], &shares);
+                       seq_printf(seq,"res=%s,guarantee=%d,limit=%d,"
+                                  "total_guarantee=%d,max_limit=%d\n",
+                                  rcbs->res_name, shares.my_guarantee,
+                                  shares.my_limit, shares.total_guarantee,
+                                  shares.max_limit);
+               }
+               atomic_dec(&clstype->nr_resusers[i]);
+       }
+       return 0;
+}
+
+int ckrm_class_show_stats(struct ckrm_core_class *core, struct seq_file *seq)
+{
+       int i;
+       struct ckrm_res_ctlr *rcbs;
+       struct ckrm_classtype *clstype = core->classtype;
+
+       for (i = 0; i < clstype->max_resid; i++) {
+               atomic_inc(&clstype->nr_resusers[i]);
+               rcbs = clstype->res_ctlrs[i];
+               if (rcbs && rcbs->get_stats)
+                       (*rcbs->get_stats) (core->res_class[i], seq);
+               atomic_dec(&clstype->nr_resusers[i]);
+       }
+       return 0;
+}
+
+int ckrm_class_show_config(struct ckrm_core_class *core, struct seq_file *seq)
+{
+       int i;
+       struct ckrm_res_ctlr *rcbs;
+       struct ckrm_classtype *clstype = core->classtype;
+
+       for (i = 0; i < clstype->max_resid; i++) {
+               atomic_inc(&clstype->nr_resusers[i]);
+               rcbs = clstype->res_ctlrs[i];
+               if (rcbs && rcbs->show_config)
+                       (*rcbs->show_config) (core->res_class[i], seq);
+               atomic_dec(&clstype->nr_resusers[i]);
+       }
+       return 0;
+}
+
+int ckrm_class_set_config(struct ckrm_core_class *core, const char *resname,
+                         const char *cfgstr)
+{
+       struct ckrm_classtype *clstype = core->classtype;
+       struct ckrm_res_ctlr *rcbs = ckrm_resctlr_lookup(clstype, resname);
+       int rc;
+
+       if (rcbs == NULL || rcbs->set_config == NULL)
+               return -EINVAL;
+       rc = (*rcbs->set_config) (core->res_class[rcbs->resid], cfgstr);
+       return rc;
+}
+
+#define legalshare(a)   \
+         ( ((a) >=0) \
+          || ((a) == CKRM_SHARE_UNCHANGED) \
+          || ((a) == CKRM_SHARE_DONTCARE) )
+
+int ckrm_class_set_shares(struct ckrm_core_class *core, const char *resname,
+                         struct ckrm_shares *shares)
+{
+       struct ckrm_classtype *clstype = core->classtype;
+       struct ckrm_res_ctlr *rcbs;
+       int rc;
+
+       // Check for legal values
+       if (!legalshare(shares->my_guarantee) || !legalshare(shares->my_limit)
+           || !legalshare(shares->total_guarantee)
+           || !legalshare(shares->max_limit))
+               return -EINVAL;
+
+       rcbs = ckrm_resctlr_lookup(clstype, resname);
+       if (rcbs == NULL || rcbs->set_share_values == NULL)
+               return -EINVAL;
+       rc = (*rcbs->set_share_values) (core->res_class[rcbs->resid], shares);
+       return rc;
+}
+
+int ckrm_class_reset_stats(struct ckrm_core_class *core, const char *resname,
+                          const char *unused)
+{
+       struct ckrm_classtype *clstype = core->classtype;
+       struct ckrm_res_ctlr *rcbs = ckrm_resctlr_lookup(clstype, resname);
+       int rc;
+
+       if (rcbs == NULL || rcbs->reset_stats == NULL)
+               return -EINVAL;
+       rc = (*rcbs->reset_stats) (core->res_class[rcbs->resid]);
+       return rc;
+}
+
+/*******************************************************************
+ *   Initialization 
+ *******************************************************************/
+
+void ckrm_cb_newtask(struct task_struct *tsk)
+{
+       tsk->ce_data = NULL;
+       spin_lock_init(&tsk->ckrm_tsklock);
+       ckrm_invoke_event_cb_chain(CKRM_EVENT_NEWTASK, tsk);
+}
+
+void ckrm_cb_exit(struct task_struct *tsk)
+{
+       ckrm_invoke_event_cb_chain(CKRM_EVENT_EXIT, tsk);
+       tsk->ce_data = NULL;
+}
+
+void __init ckrm_init(void)
+{
+       printk(KERN_DEBUG "CKRM Initialization\n");
+
+       // register/initialize the Metatypes
+
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+       {
+               extern void ckrm_meta_init_taskclass(void);
+               ckrm_meta_init_taskclass();
+       }
+#endif
+#ifdef CONFIG_CKRM_TYPE_SOCKETCLASS
+       {
+               extern void ckrm_meta_init_sockclass(void);
+               ckrm_meta_init_sockclass();
+       }
+#endif
+       // prepare init_task and then rely on inheritance of properties
+       ckrm_cb_newtask(&init_task);
+       printk(KERN_DEBUG "CKRM Initialization done\n");
+}
+
+EXPORT_SYMBOL(ckrm_register_engine);
+EXPORT_SYMBOL(ckrm_unregister_engine);
+
+EXPORT_SYMBOL(ckrm_register_res_ctlr);
+EXPORT_SYMBOL(ckrm_unregister_res_ctlr);
+
+EXPORT_SYMBOL(ckrm_init_core_class);
+EXPORT_SYMBOL(ckrm_free_core_class);
+EXPORT_SYMBOL(ckrm_release_core_class);
+
+EXPORT_SYMBOL(ckrm_register_classtype);
+EXPORT_SYMBOL(ckrm_unregister_classtype);
+EXPORT_SYMBOL(ckrm_find_classtype_by_name);
+
+EXPORT_SYMBOL(ckrm_core_grab);
+EXPORT_SYMBOL(ckrm_core_drop);
+EXPORT_SYMBOL(ckrm_is_core_valid);
+EXPORT_SYMBOL(ckrm_validate_and_grab_core);
+
+EXPORT_SYMBOL(ckrm_register_event_set);
+EXPORT_SYMBOL(ckrm_unregister_event_set);
+EXPORT_SYMBOL(ckrm_register_event_cb);
+EXPORT_SYMBOL(ckrm_unregister_event_cb);
+
+EXPORT_SYMBOL(ckrm_class_show_stats);
+EXPORT_SYMBOL(ckrm_class_show_config);
+EXPORT_SYMBOL(ckrm_class_show_shares);
+
+EXPORT_SYMBOL(ckrm_class_set_config);
+EXPORT_SYMBOL(ckrm_class_set_shares);
+
+EXPORT_SYMBOL(ckrm_class_reset_stats);
diff --git a/kernel/ckrm/ckrm_cpu_class.c b/kernel/ckrm/ckrm_cpu_class.c
new file mode 100644 (file)
index 0000000..917875b
--- /dev/null
@@ -0,0 +1,377 @@
+/* kernel/ckrm/ckrm_cpu_class.c - CPU Class resource controller for CKRM
+ *
+ * Copyright (C) Haoqiang Zheng,  IBM Corp. 2004
+ *           (C) Hubertus Franke, IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/errno.h>
+#include <linux/sched.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_rc.h>
+#include <linux/ckrm_tc.h>
+#include <linux/ckrm_sched.h>
+#include <linux/ckrm_classqueue.h>
+#include <linux/seq_file.h>
+
+struct ckrm_res_ctlr cpu_rcbs;
+
+/**
+ * insert_cpu_class - insert a class to active_cpu_class list
+ *
+ * insert the class in decreasing order of class weight
+ */
+static inline void insert_cpu_class(struct ckrm_cpu_class *cls)
+{
+       list_add(&cls->links,&active_cpu_classes);
+}
+
+/*
+ *  initialize a class object and its local queues
+ */
+void init_cpu_class(struct ckrm_cpu_class *cls,ckrm_shares_t* shares) 
+{
+       int i,j,k;      
+       prio_array_t *array;    
+       ckrm_lrq_t* queue;
+
+       cls->shares = *shares;
+       cls->cnt_lock = SPIN_LOCK_UNLOCKED;
+       ckrm_cpu_stat_init(&cls->stat);
+       ckrm_usage_init(&cls->usage);
+       cls->magic = CKRM_CPU_CLASS_MAGIC;
+
+       for (i = 0 ; i < NR_CPUS ; i++) {
+               queue = &cls->local_queues[i];
+               queue->active  = queue->arrays;
+               queue->expired = queue->arrays+1;
+               
+               for (j = 0; j < 2; j++) {
+                       array = queue->arrays + j;
+                       for (k = 0; k < MAX_PRIO; k++) {
+                               INIT_LIST_HEAD(array->queue + k);
+                               __clear_bit(k, array->bitmap);
+                       }
+                       // delimiter for bitsearch
+                       __set_bit(MAX_PRIO, array->bitmap);
+                       array->nr_active = 0;
+               }
+
+               queue->expired_timestamp = 0;
+               
+               queue->cpu_class = cls;
+               queue->classqueue = get_cpu_classqueue(i);
+               queue->top_priority = MAX_PRIO;
+               cq_node_init(&queue->classqueue_linkobj);
+               queue->local_cvt = 0;
+               queue->lrq_load = 0;
+               queue->local_weight = cpu_class_weight(cls);
+               queue->uncounted_ns = 0;
+               queue->savings = 0;
+               queue->magic = 0x43FF43D7;
+       }
+
+       // add to class list
+       write_lock(&class_list_lock);
+       insert_cpu_class(cls);
+       write_unlock(&class_list_lock);
+}
+
+static inline void set_default_share(ckrm_shares_t *shares)
+{
+       shares->my_guarantee     = 0;
+       shares->total_guarantee  = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       shares->unused_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       shares->my_limit         = CKRM_SHARE_DFLT_MAX_LIMIT;
+       shares->max_limit        = CKRM_SHARE_DFLT_MAX_LIMIT;
+       shares->cur_max_limit    = 0;
+}
+
+struct ckrm_cpu_class * ckrm_get_cpu_class(struct ckrm_core_class *core)
+{
+       struct ckrm_cpu_class * cls;
+       cls = ckrm_get_res_class(core, cpu_rcbs.resid, struct ckrm_cpu_class);
+       if (valid_cpu_class(cls))
+               return cls;
+       else
+               return NULL;
+}
+
+
+void* ckrm_alloc_cpu_class(struct ckrm_core_class *core, struct ckrm_core_class *parent) 
+{              
+       struct ckrm_cpu_class *cls;
+
+       if (! parent) /*root class*/
+               cls =  get_default_cpu_class();
+       else
+               cls = (struct ckrm_cpu_class *) kmalloc(sizeof(struct ckrm_cpu_class),GFP_ATOMIC);
+
+       if (cls) {
+               ckrm_shares_t shares;           
+               if ((! parent) && (core)) { 
+                       /*
+                        * the default class is already initialized
+                        * so only update the core structure
+                        */
+                       cls->core = core;                       
+               } else {
+                       set_default_share(&shares);
+                       init_cpu_class(cls,&shares);
+                       cls->core = core;
+                       cls->parent = parent;
+               }
+       } else
+               printk(KERN_ERR"alloc_cpu_class failed\n");
+
+       return cls;
+}              
+
+/*
+ * hzheng: this is not a stable implementation
+ *         need to check race condition issue here
+ */            
+static void ckrm_free_cpu_class(void *my_res) 
+{                      
+       struct ckrm_cpu_class *cls = my_res, *parres, *childres;
+       ckrm_core_class_t *child = NULL;
+       int maxlimit;
+
+       if (!cls) 
+               return;
+
+       /*the default class can't be freed*/
+       if (cls == get_default_cpu_class()) 
+               return;
+
+       // Assuming there will be no children when this function is called
+       parres = ckrm_get_cpu_class(cls->parent);
+
+       // return child's limit/guarantee to parent node
+       spin_lock(&parres->cnt_lock);
+       child_guarantee_changed(&parres->shares, cls->shares.my_guarantee, 0);
+       // run thru parent's children and get the new max_limit of the parent
+       ckrm_lock_hier(parres->core);
+       maxlimit = 0;
+       while ((child = ckrm_get_next_child(parres->core, child)) != NULL) {
+               childres = ckrm_get_cpu_class(child);
+               if (maxlimit < childres->shares.my_limit) {
+                       maxlimit = childres->shares.my_limit;
+               }
+       }
+       ckrm_unlock_hier(parres->core);
+       if (parres->shares.cur_max_limit < maxlimit) {
+               parres->shares.cur_max_limit = maxlimit;
+       }
+
+       spin_unlock(&parres->cnt_lock);
+
+       write_lock(&class_list_lock);
+       list_del(&cls->links);
+       write_unlock(&class_list_lock);
+
+       kfree(cls);
+
+       //call ckrm_cpu_monitor after class removed
+       ckrm_cpu_monitor(0);
+}                              
+
+/*
+ *  the system will adjust to the new share automatically  
+ */                    
+int ckrm_cpu_set_share(void *my_res, struct ckrm_shares *new_share) 
+{      
+        struct ckrm_cpu_class *parres, *cls = my_res;
+        struct ckrm_shares *cur = &cls->shares, *par;
+        int rc = -EINVAL;
+
+        if (!cls) 
+                return rc;
+
+        if (cls->parent) {
+                parres = ckrm_get_cpu_class(cls->parent);
+                spin_lock(&parres->cnt_lock);
+                spin_lock(&cls->cnt_lock);
+                par = &parres->shares;
+        } else {
+                spin_lock(&cls->cnt_lock);
+                par = NULL;
+                parres = NULL;
+        }
+
+       /*
+        * hzheng: CKRM_SHARE_DONTCARE should be handled
+        */
+       if (new_share->my_guarantee == CKRM_SHARE_DONTCARE)
+               new_share->my_guarantee = 0;
+
+       rc = set_shares(new_share, cur, par);
+       if (cur->my_limit == CKRM_SHARE_DONTCARE)
+               cur->my_limit = cur->max_limit;
+
+
+       spin_unlock(&cls->cnt_lock);
+       if (cls->parent) {
+               spin_unlock(&parres->cnt_lock);
+       }
+
+       //call ckrm_cpu_monitor after changes are changed
+       ckrm_cpu_monitor(0);
+
+       return rc;
+}                                                      
+                       
+static int ckrm_cpu_get_share(void *my_res,
+                             struct ckrm_shares *shares)
+{                      
+       struct ckrm_cpu_class *cls = my_res;
+
+       if (!cls) 
+               return -EINVAL;
+       *shares = cls->shares;
+       return 0;
+}                              
+
+int ckrm_cpu_get_stats(void *my_res, struct seq_file * sfile)
+{
+       struct ckrm_cpu_class *cls = my_res;
+       struct ckrm_cpu_class_stat* stat = &cls->stat;
+       ckrm_lrq_t* lrq;
+       int i;
+
+       if (!cls) 
+               return -EINVAL;
+
+       seq_printf(sfile, "-------- CPU Class Status Start---------\n");
+       seq_printf(sfile, "Share:\n\tgrt= %d limit= %d total_grt= %d max_limit= %d\n",
+                  cls->shares.my_guarantee,
+                  cls->shares.my_limit,
+                  cls->shares.total_guarantee,
+                  cls->shares.max_limit);
+       seq_printf(sfile, "\tunused_grt= %d cur_max_limit= %d\n",
+                  cls->shares.unused_guarantee,
+                  cls->shares.cur_max_limit);
+
+       seq_printf(sfile, "Effective:\n\tegrt= %d\n",stat->egrt);
+       seq_printf(sfile, "\tmegrt= %d\n",stat->megrt);
+       seq_printf(sfile, "\tehl= %d\n",stat->ehl);
+       seq_printf(sfile, "\tmehl= %d\n",stat->mehl);
+       seq_printf(sfile, "\teshare= %d\n",stat->eshare);
+       seq_printf(sfile, "\tmeshare= %d\n",cpu_class_weight(cls));
+       seq_printf(sfile, "\tmax_demand= %lu\n",stat->max_demand);
+       seq_printf(sfile, "\ttotal_ns= %llu\n",stat->total_ns);
+       seq_printf(sfile, "\tusage(2,10,60)= %d %d %d\n",
+                  get_ckrm_usage(cls,2*HZ),
+                  get_ckrm_usage(cls,10*HZ),
+                  get_ckrm_usage(cls,60*HZ)
+                  );
+       for_each_online_cpu(i) {
+               lrq = get_ckrm_lrq(cls,i);              
+               seq_printf(sfile, "\tlrq %d demand= %lu weight= %d lrq_load= %lu cvt= %llu sav= %llu\n",i,stat->local_stats[i].cpu_demand,local_class_weight(lrq),lrq->lrq_load,lrq->local_cvt,lrq->savings);
+       }
+
+       seq_printf(sfile, "-------- CPU Class Status END ---------\n");
+
+       return 0;
+}
+
+/*
+ * task will remain in the same cpu but on a different local runqueue
+ */
+void ckrm_cpu_change_class(void *task, void *old, void *new)
+{              
+       struct task_struct *tsk = task;                    
+       struct ckrm_cpu_class *newcls = new;
+
+       /*sanity checking*/
+       if (!task || ! old || !new)
+               return; 
+
+       _ckrm_cpu_change_class(tsk,newcls);
+}                                                      
+
+/*dummy function, not used*/
+static int ckrm_cpu_show_config(void *my_res, struct seq_file *sfile)
+{
+       struct ckrm_cpu_class *cls = my_res;
+
+       if (!cls) 
+               return -EINVAL;
+
+       seq_printf(sfile, "cls=%s,parameter=somevalue\n","ckrm_cpu class");
+       return 0;
+}
+
+/*dummy function, not used*/
+static int ckrm_cpu_set_config(void *my_res, const char *cfgstr)
+{
+       struct ckrm_cpu_class *cls = my_res;
+
+       if (!cls) 
+               return -EINVAL;
+       printk(KERN_DEBUG "ckrm_cpu config='%s'\n",cfgstr);
+       return 0;
+}
+       
+struct ckrm_res_ctlr cpu_rcbs = {
+       .res_name          = "cpu",
+       .res_hdepth        = 1,
+       .resid             = -1,
+       .res_alloc         = ckrm_alloc_cpu_class,
+       .res_free          = ckrm_free_cpu_class,
+       .set_share_values  = ckrm_cpu_set_share,
+       .get_share_values  = ckrm_cpu_get_share,
+       .get_stats         = ckrm_cpu_get_stats,
+       .show_config       = ckrm_cpu_show_config,
+       .set_config        = ckrm_cpu_set_config,
+       .change_resclass   = ckrm_cpu_change_class,
+};
+
+int __init init_ckrm_sched_res(void)
+{
+       struct ckrm_classtype *clstype;
+       int resid = cpu_rcbs.resid;
+
+       clstype = ckrm_find_classtype_by_name("taskclass");
+       if (clstype == NULL) {
+               printk(KERN_INFO" Unknown ckrm classtype<taskclass>");
+               return -ENOENT;
+       }
+
+       if (resid == -1) { /*not registered */
+               resid = ckrm_register_res_ctlr(clstype,&cpu_rcbs);
+               printk(KERN_DEBUG "........init_ckrm_sched_res , resid= %d\n",resid);
+       }
+       return 0;
+}
+
+/*
+ * initialize the class structure
+ * add the default class: class 0
+ */
+void init_cpu_classes(void) 
+{
+       int i;
+
+       //init classqueues for each processor
+       for (i=0; i < NR_CPUS; i++)
+               classqueue_init(get_cpu_classqueue(i)); 
+
+       /*
+        * hzheng: initialize the default cpu class
+        *  required for E14/E15 since ckrm_init is called after sched_init
+        */
+       ckrm_alloc_cpu_class(NULL,NULL);
+}
+
+
+EXPORT_SYMBOL(ckrm_get_cpu_class);
diff --git a/kernel/ckrm/ckrm_cpu_monitor.c b/kernel/ckrm/ckrm_cpu_monitor.c
new file mode 100644 (file)
index 0000000..d8c199a
--- /dev/null
@@ -0,0 +1,1008 @@
+/* ckrm_cpu_monitor.c - Hierarchical CKRM CPU Resource Monitor
+ *
+ * Copyright (C) Haoqiang Zheng,  IBM Corp. 2004
+ *           (C) Hubertus Franke, IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * 
+ * 23 June 2004: Created
+ * 
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <asm/errno.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_rc.h>
+#include <linux/ckrm_tc.h>
+#include <asm/div64.h>
+#include <linux/ckrm_sched.h>
+
+#define CPU_MONITOR_INTERVAL (HZ) /*how often do we adjust the shares*/
+#define CKRM_SHARE_MAX (1<<CKRM_SHARE_ACCURACY)
+
+#define CKRM_CPU_DEMAND_RUN 0
+#define CKRM_CPU_DEMAND_SLEEP 1
+//sample task cpu demand every 64ms
+#define CPU_DEMAND_TASK_RECALC  (64000000LL)
+#define CPU_DEMAND_CLASS_RECALC (256000000LL)
+#define CPU_DEMAND_TP_CLASS 0
+#define CPU_DEMAND_TP_TASK 1
+
+extern struct ckrm_cpu_class *ckrm_get_cpu_class(struct ckrm_core_class *core);
+void update_ckrm_idle(unsigned long surplus);
+
+/*interface to share definition*/
+static inline int get_soft_limit(struct ckrm_cpu_class *cls)
+{
+       return cls->shares.my_limit;
+}
+
+static inline int get_mysoft_limit(struct ckrm_cpu_class *cls)
+{
+       return cls->shares.total_guarantee;
+}
+
+static inline int get_hard_limit(struct ckrm_cpu_class *cls)
+{
+       return cls->shares.total_guarantee;
+}
+
+static inline int get_myhard_limit(struct ckrm_cpu_class *cls)
+{
+       return cls->shares.total_guarantee;
+}
+
+
+static inline void cpu_demand_stat_init(struct ckrm_cpu_demand_stat* local_stat, int type)
+{
+       unsigned long long now = sched_clock();
+
+       local_stat->run = 0;
+       local_stat->total = 0;
+       local_stat->last_sleep = now;
+       switch (type) {
+       case CPU_DEMAND_TP_CLASS:
+               local_stat->recalc_interval = CPU_DEMAND_CLASS_RECALC;
+               local_stat->cpu_demand = 0; 
+               break;
+       case CPU_DEMAND_TP_TASK:
+               local_stat->recalc_interval = CPU_DEMAND_TASK_RECALC;
+               //for task, the init cpu_demand is copied from its parent
+               break;
+       default:
+               BUG();
+       }
+}
+
+void ckrm_cpu_stat_init(struct ckrm_cpu_class_stat *stat)
+{
+       int i;
+
+       stat->stat_lock = SPIN_LOCK_UNLOCKED;
+       stat->total_ns = 0;
+       stat->max_demand = 0;
+
+       for (i=0; i< NR_CPUS; i++) {
+               cpu_demand_stat_init(&stat->local_stats[i],CPU_DEMAND_TP_CLASS);
+       }
+
+       stat->egrt = 0;
+       stat->megrt = 0;
+       stat->ehl = CKRM_SHARE_MAX; /*default: no limit*/
+       stat->mehl = CKRM_SHARE_MAX; /*default: no limit */
+
+       stat->eshare = CKRM_SHARE_MAX;
+       stat->meshare = CKRM_SHARE_MAX;
+}
+
+/**********************************************/
+/*          cpu demand                        */
+/**********************************************/
+
+/*
+ * How CPU demand is calculated:
+ * consider class local runqueue (clr) first
+ * at any time, a clr can at the following three states
+ * -- run: a task belonning to this class is running on this cpu
+ * -- wait: at least one of its task is running, but the class is not running
+ * -- sleep: none of the task of this class is runnable
+ *
+ * cpu_demand(t1,t2) = r(t1,t2)/(r(t1,t2)+s(t1,t2))
+ * 
+ * the cpu_demand of a class = 
+ *    sum of cpu_demand of all the class local runqueues
+ */
+
+/**
+ * update_cpu_demand_stat - 
+ * 
+ * should be called whenever the state of a task/task local queue changes
+ * -- when deschedule : report how much run
+ * -- when enqueue: report how much sleep
+ *
+ * how often should we recalculate the cpu demand
+ * the number is in ns
+ */
+static inline void update_cpu_demand_stat(struct ckrm_cpu_demand_stat* local_stat,int state, unsigned long long len)
+{      
+       local_stat->total += len;
+       if (state == CKRM_CPU_DEMAND_RUN)
+               local_stat->run += len;
+
+       if (local_stat->total >= local_stat->recalc_interval) {
+               local_stat->total >>= CKRM_SHARE_ACCURACY;
+               if (unlikely(local_stat->run > 0xFFFFFFFF))
+                       local_stat->run = 0xFFFFFFFF;
+
+               if (local_stat->total > 0xFFFFFFFF) 
+                       local_stat->total = 0xFFFFFFFF;
+                       
+               do_div(local_stat->run,(unsigned long)local_stat->total);
+
+               if (local_stat->total > 0xFFFFFFFF) //happens after very long sleep
+                       local_stat->cpu_demand = local_stat->run;
+               else {
+                       local_stat->cpu_demand += local_stat->run;
+                       local_stat->cpu_demand >>= 1;
+               }
+               local_stat->total = 0;
+               local_stat->run = 0;
+       }
+}
+
+/**
+ * cpu_demand_event - and cpu_demand event occured
+ * @event: one of the following three events:
+ *   CPU_DEMAND_ENQUEUE: local class enqueue
+ *   CPU_DEMAND_DEQUEUE: local class dequeue
+ *   CPU_DEMAND_DESCHEDULE: one task belong a certain local class deschedule
+ * @len: valid only for CPU_DEMAND_DESCHEDULE, how long the task has been run
+ */
+void cpu_demand_event(struct ckrm_cpu_demand_stat* local_stat, int event, unsigned long long len) 
+{      
+       switch (event) {
+       case CPU_DEMAND_ENQUEUE: 
+               len = sched_clock() - local_stat->last_sleep;
+               local_stat->last_sleep = 0;
+               update_cpu_demand_stat(local_stat,CKRM_CPU_DEMAND_SLEEP,len);
+               break;
+       case CPU_DEMAND_DEQUEUE:
+               if (! local_stat->last_sleep) {
+                       local_stat->last_sleep = sched_clock();
+               }
+               break;
+       case CPU_DEMAND_DESCHEDULE:
+               update_cpu_demand_stat(local_stat,CKRM_CPU_DEMAND_RUN,len);
+               break;
+       case CPU_DEMAND_INIT: //for task init only
+               cpu_demand_stat_init(local_stat,CPU_DEMAND_TP_TASK);
+               break;
+       default:
+               BUG();
+       }
+}
+
+/** 
+ * check all the class local queue
+ * 
+ * to deal with excessive long run/sleep state
+ * -- whenever the the ckrm_cpu_monitor is called, check if the class is in sleep state, if yes, then update sleep record
+ */
+static inline void cpu_demand_check_sleep(struct ckrm_cpu_class_stat *stat, int cpu)
+{
+       struct ckrm_cpu_demand_stat * local_stat = &stat->local_stats[cpu];
+       unsigned long long sleep,now;
+       if (local_stat->last_sleep) {
+               now = sched_clock();
+               sleep = now - local_stat->last_sleep;
+               local_stat->last_sleep = now;
+               update_cpu_demand_stat(local_stat,CKRM_CPU_DEMAND_SLEEP,sleep);
+       }
+}
+
+/**
+ *get_self_cpu_demand - get cpu demand of the class itself (excluding children)
+ *
+ * self_cpu_demand = sum(cpu demand of all local queues) 
+ */
+static inline unsigned long get_self_cpu_demand(struct ckrm_cpu_class_stat *stat)
+{
+       int cpu_demand = 0;
+       int i;
+       int cpuonline = 0;
+
+       for_each_online_cpu(i) {
+               cpu_demand_check_sleep(stat,i);
+               cpu_demand += stat->local_stats[i].cpu_demand;
+               cpuonline ++;
+       }
+
+       return (cpu_demand/cpuonline);
+}
+
+/*
+ * my max demand = min(cpu_demand, my effective hard limit)
+ */
+static inline unsigned long get_mmax_demand(struct ckrm_cpu_class_stat* stat) 
+{
+       unsigned long mmax_demand = get_self_cpu_demand(stat);
+       if (mmax_demand > stat->mehl)
+               mmax_demand = stat->mehl;
+
+       return mmax_demand;
+}
+
+/**
+ * update_max_demand: update effective cpu demand for each class
+ * return -1 on error
+ * 
+ * Assume: the root_core->parent == NULL
+ */
+static int update_max_demand(struct ckrm_core_class *root_core)
+{
+       struct ckrm_core_class *cur_core, *child_core;
+       struct ckrm_cpu_class *cls,*c_cls;
+       int ret = -1;
+
+       cur_core = root_core;
+       child_core = NULL;
+       
+ repeat:
+       if (!cur_core) { //normal exit
+               ret = 0;
+               goto out;
+       }
+
+       cls = ckrm_get_cpu_class(cur_core);
+       if (! cls) //invalid c_cls, abort
+               goto out;
+
+       if (!child_core)        //first child
+               cls->stat.max_demand = get_mmax_demand(&cls->stat);
+       else {
+               c_cls = ckrm_get_cpu_class(child_core);
+               if (c_cls)
+                       cls->stat.max_demand += c_cls->stat.max_demand;
+               else //invalid c_cls, abort
+                       goto out;
+       }
+
+       //check class hard limit
+       if (cls->stat.max_demand > cls->stat.ehl)
+               cls->stat.max_demand = cls->stat.ehl;
+
+       //next child
+       child_core = ckrm_get_next_child(cur_core, child_core);
+       if (child_core) {
+               //go down
+               cur_core = child_core;
+               child_core = NULL;
+               goto repeat;
+       } else {                //no more child, go back
+               child_core = cur_core;
+               cur_core = child_core->hnode.parent;
+       }
+       goto repeat;
+ out:
+       return ret;
+}
+
+/**********************************************/
+/*          effective guarantee & limit       */
+/**********************************************/
+static inline void set_eshare(struct ckrm_cpu_class_stat *stat,
+                                      int new_share)
+{
+       if (!new_share)
+               new_share = 1;
+
+       BUG_ON(new_share < 0);
+       stat->eshare = new_share;
+}
+
+static inline void set_meshare(struct ckrm_cpu_class_stat *stat,
+                                           int new_share)
+{
+       if (!new_share)
+               new_share = 1;
+
+       BUG_ON(new_share < 0);
+       stat->meshare = new_share;
+}
+
+/**
+ *update_child_effective - update egrt, ehl, mehl for all children of parent
+ *@parent: the parent node
+ *return -1 if anything wrong
+ *
+ */
+static int update_child_effective(struct ckrm_core_class *parent)
+{
+       struct ckrm_cpu_class *p_cls = ckrm_get_cpu_class(parent);
+       struct ckrm_core_class *child_core;     
+       int ret = -1;
+
+       if (! p_cls)
+               return ret;
+
+       child_core = ckrm_get_next_child(parent, NULL);
+       while (child_core) {
+               struct ckrm_cpu_class *c_cls = ckrm_get_cpu_class(child_core);
+               if (! c_cls)
+                       return ret;
+
+               c_cls->stat.egrt =
+                   p_cls->stat.egrt *
+                   c_cls->shares.my_guarantee / p_cls->shares.total_guarantee;
+
+               c_cls->stat.megrt = c_cls->stat.egrt * c_cls->shares.unused_guarantee
+                       / c_cls->shares.total_guarantee;
+               
+               c_cls->stat.ehl =
+                   p_cls->stat.ehl *
+                   get_hard_limit(c_cls) / p_cls->shares.total_guarantee;
+
+               c_cls->stat.mehl =
+                   c_cls->stat.ehl *
+                   get_myhard_limit(c_cls) / c_cls->shares.total_guarantee;
+
+               set_eshare(&c_cls->stat,c_cls->stat.egrt);
+               set_meshare(&c_cls->stat,c_cls->stat.megrt);
+
+
+               child_core = ckrm_get_next_child(parent, child_core);
+       };
+       return 0;
+}
+
+/**
+ * update_effectives: update egrt, ehl, mehl for the whole tree
+ * should be called only when class structure changed
+ *
+ * return -1 if anything wrong happened (eg: the structure changed during the process)
+ */
+static int update_effectives(struct ckrm_core_class *root_core)
+{
+       struct ckrm_core_class *cur_core, *child_core;
+       struct ckrm_cpu_class *cls;
+       int ret = -1;
+
+       cur_core = root_core;
+       child_core = NULL;
+       cls = ckrm_get_cpu_class(cur_core);
+
+       //initialize the effectives for root 
+       cls->stat.egrt = CKRM_SHARE_MAX; /*egrt of the root is always 100% */
+       cls->stat.megrt = cls->stat.egrt * cls->shares.unused_guarantee
+               / cls->shares.total_guarantee;
+       cls->stat.ehl = CKRM_SHARE_MAX * get_hard_limit(cls)
+               / cls->shares.total_guarantee;
+       cls->stat.mehl = cls->stat.ehl * get_myhard_limit(cls)
+               / cls->shares.total_guarantee;
+       set_eshare(&cls->stat,cls->stat.egrt);
+       set_meshare(&cls->stat,cls->stat.megrt);
+
+ repeat:
+       //check exit
+       if (!cur_core)
+               return 0;
+
+       //visit this node only once
+       if (! child_core)
+               if (update_child_effective(cur_core) < 0)
+                       return ret; //invalid cur_core node
+       
+       //next child
+       child_core = ckrm_get_next_child(cur_core, child_core);
+
+       if (child_core) {
+               //go down to the next hier
+               cur_core = child_core;
+               child_core = NULL;
+       } else { //no more child, go back
+               child_core = cur_core;
+               cur_core = child_core->hnode.parent;
+       }
+       goto repeat;
+}
+
+/**********************************************/
+/*          surplus allocation                */
+/**********************************************/
+
+/*
+ * surplus = egrt - demand
+ * if surplus < 0, surplus = 0 
+ */
+static inline int get_node_surplus(struct ckrm_cpu_class *cls)
+{
+       int surplus = cls->stat.egrt - cls->stat.max_demand;
+
+       if (surplus < 0)
+               surplus = 0;
+
+       return surplus;
+}
+
+static inline int get_my_node_surplus(struct ckrm_cpu_class *cls)
+{
+       int surplus = cls->stat.megrt - get_mmax_demand(&cls->stat);
+
+       if (surplus < 0)
+               surplus = 0;
+
+       return surplus;
+}
+
+/**
+ * consume_surplus: decides how much surplus a node can consume
+ * @ckeck_sl: if check_sl is set, then check soft_limitx
+ * return how much consumed
+ *
+ * implements all the CKRM Scheduling Requirement
+ * assume c_cls is valid
+ */
+static inline int consume_surplus(int surplus,
+                                      struct ckrm_cpu_class *c_cls,
+                                      struct ckrm_cpu_class *p_cls,
+                                      int check_sl
+                                      )
+{
+       int consumed = 0;
+       int inc_limit;
+       int total_grt = p_cls->shares.total_guarantee;
+
+       BUG_ON(surplus < 0);
+
+       /*can't consume more than demand or hard limit*/
+       if (c_cls->stat.eshare >= c_cls->stat.max_demand)
+               goto out;
+
+       //the surplus allocation is propotional to grt
+       consumed =
+               surplus * c_cls->shares.my_guarantee / total_grt;
+
+       if (! consumed) //no more share
+               goto out;
+
+       //hard limit and demand limit
+       inc_limit = c_cls->stat.max_demand - c_cls->stat.eshare;
+
+       if (check_sl) {
+               int esl = p_cls->stat.eshare * get_soft_limit(c_cls)
+                       /total_grt;
+               if (esl < c_cls->stat.max_demand)
+                       inc_limit = esl - c_cls->stat.eshare;
+       }
+
+       if (consumed > inc_limit)
+               consumed = inc_limit;
+
+        BUG_ON(consumed < 0);
+ out:          
+       return consumed;
+}
+
+/*
+ * how much a node can consume for itself?
+ */
+static inline int consume_self_surplus(int surplus,
+                                      struct ckrm_cpu_class *p_cls,
+                                      int check_sl
+                                      )
+{
+       int consumed = 0;
+       int inc_limit;
+       int total_grt = p_cls->shares.total_guarantee;
+       int max_demand = get_mmax_demand(&p_cls->stat);
+
+       BUG_ON(surplus < 0);
+
+       /*can't consume more than demand or hard limit*/
+       if (p_cls->stat.meshare >= max_demand)
+               goto out;
+
+       //the surplus allocation is propotional to grt
+       consumed =
+               surplus * p_cls->shares.unused_guarantee / total_grt;
+
+       if (! consumed) //no more share
+               goto out;
+
+       //hard limit and demand limit
+       inc_limit = max_demand - p_cls->stat.meshare;
+
+       if (check_sl) {
+               int mesl = p_cls->stat.eshare * get_mysoft_limit(p_cls)
+                       /total_grt;
+               if (mesl < max_demand)
+                       inc_limit = mesl - p_cls->stat.meshare;
+       }
+
+       if (consumed > inc_limit)
+               consumed = inc_limit;
+
+        BUG_ON(consumed < 0);
+ out:          
+       return consumed;
+}
+
+
+/*
+ * allocate surplus to all its children and also its default class
+ */
+static int alloc_surplus_single_round(
+                                     int surplus,
+                                     struct ckrm_core_class *parent,
+                                     struct ckrm_cpu_class *p_cls,
+                                     int check_sl)
+{
+       struct ckrm_cpu_class *c_cls;
+       struct ckrm_core_class *child_core = NULL;
+       int total_consumed = 0,consumed;
+
+       //first allocate to the default class
+       consumed  =
+               consume_self_surplus(surplus,p_cls,check_sl);
+
+       if (consumed > 0) {
+               set_meshare(&p_cls->stat,p_cls->stat.meshare + consumed);
+               total_consumed += consumed;
+       }
+
+       do {
+               child_core = ckrm_get_next_child(parent, child_core);
+               if (child_core)  {
+                       c_cls = ckrm_get_cpu_class(child_core);
+                       if (! c_cls)
+                               return -1;
+
+                       consumed    =
+                               consume_surplus(surplus, c_cls,
+                                                    p_cls,check_sl);
+                       if (consumed > 0) {
+                               set_eshare(&c_cls->stat,c_cls->stat.eshare + consumed);
+                               total_consumed += consumed;
+                       }
+               }
+       } while (child_core);
+
+       return total_consumed;
+}
+
+/**
+ * alloc_surplus_node: re-allocate the shares for children under parent
+ * @parent: parent node
+ * return the remaining surplus
+ *
+ * task:
+ *  1. get total surplus
+ *  2. allocate surplus
+ *  3. set the effective_share of each node
+ */
+static int alloc_surplus_node(struct ckrm_core_class *parent)
+{
+       struct ckrm_cpu_class *p_cls,*c_cls;
+       int total_surplus,consumed;
+       int check_sl;
+       int ret = -1;
+       struct ckrm_core_class *child_core = NULL;
+
+       p_cls = ckrm_get_cpu_class(parent);
+       if (! p_cls)
+               goto realloc_out;
+
+       /*
+        * get total surplus
+        */
+       total_surplus = p_cls->stat.eshare - p_cls->stat.egrt;
+       BUG_ON(total_surplus < 0);
+       total_surplus += get_my_node_surplus(p_cls);
+
+       do {
+               child_core = ckrm_get_next_child(parent, child_core);
+               if (child_core) {
+                       c_cls = ckrm_get_cpu_class(child_core);                         
+                       if (! c_cls)
+                               goto realloc_out;
+
+                       total_surplus += get_node_surplus(c_cls);
+               }
+       } while (child_core);
+
+
+       if (! total_surplus) {
+               ret = 0;
+               goto realloc_out;
+       }
+
+       /* 
+        * distributing the surplus 
+        * first with the check_sl enabled
+        * once all the tasks has research the soft limit, disable check_sl and try again
+        */
+       
+       check_sl = 1;
+       do {
+               consumed = alloc_surplus_single_round(total_surplus,parent,p_cls,check_sl);
+               if (consumed < 0) //something is wrong
+                       goto realloc_out;
+
+               if (! consumed)
+                       check_sl = 0;
+               else
+                       total_surplus -= consumed;
+
+       } while ((total_surplus > 0) && (consumed || check_sl) );
+
+       ret = 0;
+       
+ realloc_out:
+       return ret;
+}
+
+/**
+ * alloc_surplus - reallocate unused shares
+ *
+ * class A's usused share should be allocated to its siblings
+ * the re-allocation goes downward from the top
+ */
+static int alloc_surplus(struct ckrm_core_class *root_core)
+{
+       struct ckrm_core_class *cur_core, *child_core;
+       //      struct ckrm_cpu_class *cls;
+       int ret = -1;
+
+       /*initialize*/
+       cur_core = root_core;
+       child_core = NULL;
+       //      cls = ckrm_get_cpu_class(cur_core);
+
+       /*the ckrm idle tasks get all what's remaining*/
+       /*hzheng: uncomment the following like for hard limit support */
+       //      update_ckrm_idle(CKRM_SHARE_MAX - cls->stat.max_demand);
+       
+ repeat:
+       //check exit
+       if (!cur_core)
+               return 0;
+
+       //visit this node only once
+       if (! child_core) 
+               if ( alloc_surplus_node(cur_core) < 0 )
+                       return ret;
+
+       //next child
+       child_core = ckrm_get_next_child(cur_core, child_core);
+       if (child_core) {
+               //go down
+               cur_core = child_core;
+               child_core = NULL;
+               goto repeat;
+       } else {                //no more child, go back
+               child_core = cur_core;
+               cur_core = child_core->hnode.parent;
+       }
+       goto repeat;
+}
+
+/**********************************************/
+/*           CKRM Idle Tasks                  */
+/**********************************************/
+struct ckrm_cpu_class ckrm_idle_class_obj, *ckrm_idle_class;
+struct task_struct* ckrm_idle_tasks[NR_CPUS];
+
+/*how many ckrm idle tasks should I wakeup*/
+static inline int get_nr_idle(unsigned long surplus)
+{
+       int cpu_online = cpus_weight(cpu_online_map);   
+       int nr_idle = 0; 
+       
+       nr_idle = surplus * cpu_online;
+       nr_idle >>= CKRM_SHARE_ACCURACY;
+
+       if (surplus) 
+               nr_idle ++;
+
+       if (nr_idle > cpu_online)  
+               nr_idle = cpu_online;
+
+       return nr_idle;
+}
+
+/**
+ * update_ckrm_idle: update the status of the idle class according to the new surplus
+ * surplus: new system surplus
+ *
+ * Task:
+ * -- update share of the idle class 
+ * -- wakeup idle tasks according to surplus
+ */
+void update_ckrm_idle(unsigned long surplus)
+{
+       int nr_idle = get_nr_idle(surplus);
+       int i;
+       struct task_struct* idle_task;
+
+       set_eshare(&ckrm_idle_class->stat,surplus);
+       set_meshare(&ckrm_idle_class->stat,surplus);
+       /*wake up nr_idle idle tasks*/
+       for_each_online_cpu(i) {
+               idle_task = ckrm_idle_tasks[i];
+               if (unlikely(idle_task->cpu_class != ckrm_idle_class)) {
+                       ckrm_cpu_change_class(idle_task,
+                                             idle_task->cpu_class,
+                                             ckrm_idle_class);
+               }
+               if (! idle_task)
+                       continue;
+               if (i < nr_idle) {
+                       //activate it
+                       wake_up_process(idle_task);
+               } else {
+                       //deactivate it
+                       idle_task->state = TASK_INTERRUPTIBLE;
+                       set_tsk_need_resched(idle_task);
+               }
+       }
+}
+
+static int ckrm_cpu_idled(void *nothing)
+{
+       set_user_nice(current,19);
+       daemonize("ckrm_idle_task");
+
+       //deactivate it, it will be awakened by ckrm_cpu_monitor
+       current->state = TASK_INTERRUPTIBLE;
+       schedule();             
+
+       /*similar to cpu_idle */
+       while (1) {
+               while (!need_resched()) {
+                       ckrm_cpu_monitor(1);
+                       if (current_cpu_data.hlt_works_ok) {
+                               local_irq_disable();
+                               if (!need_resched()) {
+                                       set_tsk_need_resched(current);
+                                       safe_halt();
+                               } else
+                                       local_irq_enable();
+                       }
+               }
+               schedule();             
+       }
+       return 0;
+}
+
+/**
+ * ckrm_start_ckrm_idle: 
+ *  create the ckrm_idle_class and starts the idle tasks
+ *
+ */
+void ckrm_start_ckrm_idle(void)
+{
+       int i;
+       int ret;
+       ckrm_shares_t shares;
+       
+       ckrm_idle_class = &ckrm_idle_class_obj; 
+       memset(ckrm_idle_class,0,sizeof(shares));
+       /*don't care about the shares */
+       init_cpu_class(ckrm_idle_class,&shares);
+       printk(KERN_INFO"ckrm idle class %x created\n",(int)ckrm_idle_class);
+       
+       for_each_online_cpu(i) {
+               ret = kernel_thread(ckrm_cpu_idled, 0, CLONE_KERNEL);
+               
+               /*warn on error, but the system should still work without it*/
+               if (ret < 0)
+                       printk(KERN_ERR"Warn: can't start ckrm idle tasks\n");
+               else {
+                       ckrm_idle_tasks[i] = find_task_by_pid(ret);
+                       if (!ckrm_idle_tasks[i])
+                               printk(KERN_ERR"Warn: can't find ckrm idle tasks %d\n",ret);
+               }
+       }
+}
+
+/**********************************************/
+/*          Local Weight                      */
+/**********************************************/
+/**
+ * adjust_class_local_weight: adjust the local weight for each cpu
+ *
+ * lrq->weight = lpr->pressure * class->weight / total_pressure
+ */
+static void adjust_lrq_weight(struct ckrm_cpu_class *clsptr, int cpu_online)
+{
+       unsigned long total_pressure = 0;
+       ckrm_lrq_t* lrq;
+       int i;
+       unsigned long class_weight;
+       unsigned long long lw;  
+
+       //get total pressure
+       for_each_online_cpu(i) {
+               lrq = get_ckrm_lrq(clsptr,i);
+               total_pressure += lrq->lrq_load;
+       }
+
+       if (! total_pressure)
+               return;
+       
+       class_weight = cpu_class_weight(clsptr) * cpu_online;
+
+       /*
+        * update weight for each cpu, minimun is 1
+        */
+       for_each_online_cpu(i) {
+               lrq = get_ckrm_lrq(clsptr,i);
+               if (! lrq->lrq_load)
+                       /*give idle class a high share to boost interactiveness */
+                       lw = cpu_class_weight(clsptr); 
+               else {
+                       lw = lrq->lrq_load * class_weight;
+                       do_div(lw,total_pressure);
+                       if (!lw)
+                               lw = 1;
+                       else if (lw > CKRM_SHARE_MAX)
+                               lw = CKRM_SHARE_MAX;
+               }
+               
+               lrq->local_weight = lw;
+       }
+}
+
+/*
+ * assume called with class_list_lock read lock held
+ */
+void adjust_local_weight(void)
+{
+       static spinlock_t lock = SPIN_LOCK_UNLOCKED; 
+       struct ckrm_cpu_class *clsptr;
+       int cpu_online;
+
+       //do nothing if someone already holding the lock
+       if (! spin_trylock(&lock))
+               return;
+
+       cpu_online = cpus_weight(cpu_online_map);       
+
+       //class status: demand, share,total_ns prio, index
+       list_for_each_entry(clsptr,&active_cpu_classes,links) {
+               adjust_lrq_weight(clsptr,cpu_online);
+       }
+
+       spin_unlock(&lock);
+}
+
+/**********************************************/
+/*          Main                              */
+/**********************************************/
+/**
+ *ckrm_cpu_monitor - adjust relative shares of the classes based on their progress
+ *@check_min: if check_min is set, the call can't be within 100ms of last call
+ *
+ * this function is called every CPU_MONITOR_INTERVAL
+ * it computes the cpu demand of each class
+ * and re-allocate the un-used shares to other classes
+ */
+void ckrm_cpu_monitor(int check_min)
+{
+       static spinlock_t lock = SPIN_LOCK_UNLOCKED; 
+       static unsigned long long last_check = 0;
+       struct ckrm_core_class *root_core = get_default_cpu_class()->core;
+       unsigned long long now; 
+#define MIN_CPU_MONITOR_INTERVAL 100000000UL
+
+       if (!root_core)
+               return;
+
+       //do nothing if someone already holding the lock
+       if (! spin_trylock(&lock))
+               return;
+
+       read_lock(&class_list_lock);
+
+       now = sched_clock();
+
+       //consecutive check should be at least 100ms apart
+       if (check_min && ((now - last_check) < MIN_CPU_MONITOR_INTERVAL))
+               goto outunlock;
+
+       last_check = now;
+
+       if (update_effectives(root_core) != 0)
+               goto outunlock;
+       
+       if (update_max_demand(root_core) != 0)
+               goto outunlock;
+       
+#ifndef ALLOC_SURPLUS_SUPPORT
+#warning "MEF taking out alloc_surplus"
+#else
+       if (alloc_surplus(root_core) != 0)
+               goto outunlock;
+#endif
+       
+       adjust_local_weight();
+
+ outunlock:    
+       read_unlock(&class_list_lock);
+       spin_unlock(&lock);
+}
+
+/*****************************************************/
+/*            Supporting Functions                   */
+/*****************************************************/
+static pid_t cpu_monitor_pid = -1;
+static int thread_exit = 0;
+
+static int ckrm_cpu_monitord(void *nothing)
+{
+       daemonize("ckrm_cpu_ctrld");
+       for (;;) {
+               /*sleep for sometime before next try*/
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(CPU_MONITOR_INTERVAL);
+               ckrm_cpu_monitor(1);
+               if (thread_exit) {
+                       break;
+               }
+       }
+       cpu_monitor_pid = -1;
+       thread_exit = 2;
+       printk(KERN_DEBUG "cpu_monitord exit\n");
+       return 0;
+}
+
+void ckrm_start_monitor(void)
+{
+       cpu_monitor_pid = kernel_thread(ckrm_cpu_monitord, 0, CLONE_KERNEL);
+       if (cpu_monitor_pid < 0) {
+               printk(KERN_DEBUG "ckrm_cpu_monitord for failed\n");
+       }
+}
+
+void ckrm_kill_monitor(void)
+{
+       printk(KERN_DEBUG "killing process %d\n", cpu_monitor_pid);
+       if (cpu_monitor_pid > 0) {
+               thread_exit = 1;
+               while (thread_exit != 2) {
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       schedule_timeout(CPU_MONITOR_INTERVAL);
+               }
+       }
+}
+
+int ckrm_cpu_monitor_init(void)
+{
+       ckrm_start_monitor();
+       /*hzheng: uncomment the following like for hard limit support */
+       //      ckrm_start_ckrm_idle();
+       return 0;
+}
+
+void ckrm_cpu_monitor_exit(void)
+{
+       ckrm_kill_monitor();
+}
+
+module_init(ckrm_cpu_monitor_init);
+module_exit(ckrm_cpu_monitor_exit);
+
+MODULE_AUTHOR("Haoqiang Zheng <hzheng@cs.columbia.edu>");
+MODULE_DESCRIPTION("Hierarchical CKRM CPU Resource Monitor");
+MODULE_LICENSE("GPL");
diff --git a/kernel/ckrm/ckrm_laq.c b/kernel/ckrm/ckrm_laq.c
new file mode 100644 (file)
index 0000000..b64205a
--- /dev/null
@@ -0,0 +1,495 @@
+/* ckrm_socketaq.c - accept queue resource controller
+ *
+ * Copyright (C) Vivek Kashyap,      IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * Initial version
+ */
+
+/* Code Description: TBD
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/errno.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_rc.h>
+#include <net/tcp.h>
+
+#include <linux/ckrm_net.h>
+
+#define hnode_2_core(ptr) \
+        ((ptr) ? container_of(ptr, struct ckrm_core_class, hnode) : NULL)
+
+#define CKRM_SAQ_MAX_DEPTH     3       // 0 => /rcfs
+                                 // 1 => socket_aq
+                                 // 2 => socket_aq/listen_class
+                                 // 3 => socket_aq/listen_class/accept_queues
+                                 // 4 => Not allowed
+
+typedef struct ckrm_laq_res {
+       spinlock_t reslock;
+       atomic_t refcnt;
+       struct ckrm_shares shares;
+       struct ckrm_core_class *core;
+       struct ckrm_core_class *pcore;
+       int my_depth;
+       int my_id;
+       unsigned int min_ratio;
+} ckrm_laq_res_t;
+
+static int my_resid = -1;
+
+extern struct ckrm_core_class *rcfs_create_under_netroot(char *, int, int);
+extern struct ckrm_core_class *rcfs_make_core(struct dentry *,
+                                             struct ckrm_core_class *);
+
+void laq_res_hold(struct ckrm_laq_res *res)
+{
+       atomic_inc(&res->refcnt);
+       return;
+}
+
+void laq_res_put(struct ckrm_laq_res *res)
+{
+       if (atomic_dec_and_test(&res->refcnt))
+               kfree(res);
+       return;
+}
+
+/* Initialize rescls values
+ */
+static void laq_res_initcls(void *my_res)
+{
+       ckrm_laq_res_t *res = my_res;
+
+       res->shares.my_guarantee = CKRM_SHARE_DONTCARE;
+       res->shares.my_limit = CKRM_SHARE_DONTCARE;
+       res->shares.total_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.max_limit = CKRM_SHARE_DFLT_MAX_LIMIT;
+       res->shares.unused_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.cur_max_limit = 0;
+}
+
+static int atoi(char *s)
+{
+       int k = 0;
+       while (*s)
+               k = *s++ - '0' + (k * 10);
+       return k;
+}
+
+static char *laq_get_name(struct ckrm_core_class *c)
+{
+       char *p = (char *)c->name;
+
+       while (*p)
+               p++;
+       while (*p != '/' && p != c->name)
+               p--;
+
+       return ++p;
+}
+
+static void *laq_res_alloc(struct ckrm_core_class *core,
+                          struct ckrm_core_class *parent)
+{
+       ckrm_laq_res_t *res, *pres;
+       int pdepth;
+
+       if (parent)
+               pres = ckrm_get_res_class(parent, my_resid, ckrm_laq_res_t);
+       else
+               pres = NULL;
+
+       if (core == core->classtype->default_class)
+               pdepth = 1;
+       else {
+               if (!parent)
+                       return NULL;
+               pdepth = 1 + pres->my_depth;
+       }
+
+       res = kmalloc(sizeof(ckrm_laq_res_t), GFP_ATOMIC);
+       if (res) {
+               memset(res, 0, sizeof(res));
+               spin_lock_init(&res->reslock);
+               laq_res_hold(res);
+               res->my_depth = pdepth;
+               if (pdepth == 2)        // listen class
+                       res->my_id = 0;
+               else if (pdepth == 3)
+                       res->my_id = atoi(laq_get_name(core));
+               res->core = core;
+               res->pcore = parent;
+
+               // rescls in place, now initialize contents other than 
+               // hierarchy pointers
+               laq_res_initcls(res);   // acts as initialising value
+       }
+
+       return res;
+}
+
+static void laq_res_free(void *my_res)
+{
+       ckrm_laq_res_t *res = (ckrm_laq_res_t *) my_res;
+       ckrm_laq_res_t *parent;
+
+       if (!res)
+               return;
+
+       if (res->my_depth != 3) {
+               kfree(res);
+               return;
+       }
+
+       parent = ckrm_get_res_class(res->pcore, my_resid, ckrm_laq_res_t);
+       if (!parent)            // Should never happen
+               return;
+
+       spin_lock(&parent->reslock);
+       spin_lock(&res->reslock);
+
+       // return child's guarantee to parent node
+       // Limits have no meaning for accept queue control
+       child_guarantee_changed(&parent->shares, res->shares.my_guarantee, 0);
+
+       spin_unlock(&res->reslock);
+       laq_res_put(res);
+       spin_unlock(&parent->reslock);
+       return;
+}
+
+/**************************************************************************
+ *                     SHARES                                          ***
+ **************************************************************************/
+
+void laq_set_aq_value(struct ckrm_net_struct *ns, unsigned int *aq_ratio)
+{
+       int i;
+       struct tcp_opt *tp;
+
+       tp = tcp_sk(ns->ns_sk);
+       for (i = 0; i < NUM_ACCEPT_QUEUES; i++)
+               tp->acceptq[i].aq_ratio = aq_ratio[i];
+       return;
+}
+void laq_set_aq_values(ckrm_laq_res_t * parent, unsigned int *aq_ratio)
+{
+
+       struct ckrm_net_struct *ns;
+       struct ckrm_core_class *core = parent->core;
+
+       class_lock(core);
+       list_for_each_entry(ns, &core->objlist, ckrm_link) {
+               laq_set_aq_value(ns, aq_ratio);
+       }
+       class_unlock(core);
+       return;
+}
+
+static void calculate_aq_ratios(ckrm_laq_res_t * res, unsigned int *aq_ratio)
+{
+       struct ckrm_hnode *chnode;
+       ckrm_laq_res_t *child;
+       unsigned int min;
+       int i;
+
+       min = aq_ratio[0] = (unsigned int)res->shares.unused_guarantee;
+
+       list_for_each_entry(chnode, &res->core->hnode.children, siblings) {
+               child = hnode_2_core(chnode)->res_class[my_resid];
+
+               aq_ratio[child->my_id] =
+                   (unsigned int)child->shares.my_guarantee;
+               if (aq_ratio[child->my_id] == CKRM_SHARE_DONTCARE)
+                       aq_ratio[child->my_id] = 0;
+               if (aq_ratio[child->my_id] &&
+                   ((unsigned int)aq_ratio[child->my_id] < min))
+                       min = (unsigned int)child->shares.my_guarantee;
+       }
+
+       if (min == 0) {
+               min = 1;
+               // default takes all if nothing specified
+               aq_ratio[0] = 1;        
+       }
+       res->min_ratio = min;
+
+       for (i = 0; i < NUM_ACCEPT_QUEUES; i++)
+               aq_ratio[i] = aq_ratio[i] / min;
+}
+
+static int laq_set_share_values(void *my_res, struct ckrm_shares *shares)
+{
+       ckrm_laq_res_t *res = my_res;
+       ckrm_laq_res_t *parent;
+       unsigned int aq_ratio[NUM_ACCEPT_QUEUES];
+       int rc = 0;
+
+       if (!res)
+               return -EINVAL;
+
+       if (!res->pcore) {
+               // something is badly wrong
+               printk(KERN_ERR "socketaq internal inconsistency\n");
+               return -EBADF;
+       }
+
+       parent = ckrm_get_res_class(res->pcore, my_resid, ckrm_laq_res_t);
+       if (!parent)            // socketclass does not have a share interface
+               return -EINVAL;
+
+       // Ensure that we ignore limit values
+       shares->my_limit = CKRM_SHARE_DONTCARE;
+       shares->max_limit = CKRM_SHARE_UNCHANGED;
+
+       if (res->my_depth == 0) {
+               printk(KERN_ERR "socketaq bad entry\n");
+               return -EBADF;
+       } else if (res->my_depth == 1) {
+               // can't be written to. This is an internal default.
+               return -EINVAL;
+       } else if (res->my_depth == 2) {
+               //nothin to inherit
+               if (!shares->total_guarantee) {
+                       return -EINVAL;
+               }
+               parent = res;
+               shares->my_guarantee = CKRM_SHARE_DONTCARE;
+       } else if (res->my_depth == 3) {
+               // accept queue itself. 
+               shares->total_guarantee = CKRM_SHARE_UNCHANGED;
+       }
+
+       ckrm_lock_hier(parent->pcore);
+       spin_lock(&parent->reslock);
+       rc = set_shares(shares, &res->shares,
+                       (parent == res) ? NULL : &parent->shares);
+       if (rc) {
+               spin_unlock(&res->reslock);
+               ckrm_unlock_hier(res->pcore);
+               return rc;
+       }
+       calculate_aq_ratios(parent, aq_ratio);
+       laq_set_aq_values(parent, aq_ratio);
+       spin_unlock(&parent->reslock);
+       ckrm_unlock_hier(parent->pcore);
+
+       return rc;
+}
+
+static int laq_get_share_values(void *my_res, struct ckrm_shares *shares)
+{
+       ckrm_laq_res_t *res = my_res;
+
+       if (!res)
+               return -EINVAL;
+       *shares = res->shares;
+       return 0;
+}
+
+/**************************************************************************
+ *                     STATS                                           ***
+ **************************************************************************/
+
+void
+laq_print_aq_stats(struct seq_file *sfile, struct tcp_acceptq_info *taq, int i)
+{
+       seq_printf(sfile, "Class %d connections:\n\taccepted: %u\n\t"
+                  "queued: %u\n\twait_time: %u\n",
+                  i, taq->acceptq_count, taq->acceptq_qcount,
+                  jiffies_to_msecs(taq->acceptq_wait_time));
+
+       if (i)
+               return;
+
+       for (i = 1; i < NUM_ACCEPT_QUEUES; i++) {
+               taq[0].acceptq_wait_time += taq[i].acceptq_wait_time;
+               taq[0].acceptq_qcount += taq[i].acceptq_qcount;
+               taq[0].acceptq_count += taq[i].acceptq_count;
+       }
+
+       seq_printf(sfile, "Totals :\n\taccepted: %u\n\t"
+                  "queued: %u\n\twait_time: %u\n",
+                  taq->acceptq_count, taq->acceptq_qcount,
+                  jiffies_to_msecs(taq->acceptq_wait_time));
+
+       return;
+}
+
+void
+laq_get_aq_stats(ckrm_laq_res_t * pres, ckrm_laq_res_t * mres,
+                struct tcp_acceptq_info *taq)
+{
+       struct ckrm_net_struct *ns;
+       struct ckrm_core_class *core = pres->core;
+       struct tcp_opt *tp;
+       int a = mres->my_id;
+       int z;
+
+       if (a == 0)
+               z = NUM_ACCEPT_QUEUES;
+       else
+               z = a + 1;
+
+       // XXX Instead of holding a  class_lock introduce a rw
+       // lock to be write locked by listen callbacks and read locked here.
+       // - VK
+       class_lock(pres->core);
+       list_for_each_entry(ns, &core->objlist, ckrm_link) {
+               tp = tcp_sk(ns->ns_sk);
+               for (; a < z; a++) {
+                       taq->acceptq_wait_time += tp->acceptq[a].aq_wait_time;
+                       taq->acceptq_qcount += tp->acceptq[a].aq_qcount;
+                       taq->acceptq_count += tp->acceptq[a].aq_count;
+                       taq++;
+               }
+       }
+       class_unlock(pres->core);
+}
+
+static int laq_get_stats(void *my_res, struct seq_file *sfile)
+{
+       ckrm_laq_res_t *res = my_res;
+       ckrm_laq_res_t *parent;
+       struct tcp_acceptq_info taq[NUM_ACCEPT_QUEUES];
+       int rc = 0;
+
+       if (!res)
+               return -EINVAL;
+
+       if (!res->pcore) {
+               // something is badly wrong
+               printk(KERN_ERR "socketaq internal inconsistency\n");
+               return -EBADF;
+       }
+
+       parent = ckrm_get_res_class(res->pcore, my_resid, ckrm_laq_res_t);
+       if (!parent) {          // socketclass does not have a stat interface
+               printk(KERN_ERR "socketaq internal fs inconsistency\n");
+               return -EINVAL;
+       }
+
+       memset(taq, 0, sizeof(struct tcp_acceptq_info) * NUM_ACCEPT_QUEUES);
+
+       switch (res->my_depth) {
+
+       default:
+       case 0:
+               printk(KERN_ERR "socket class bad entry\n");
+               rc = -EBADF;
+               break;
+
+       case 1:         // can't be read from. this is internal default.
+               // return -EINVAL
+               rc = -EINVAL;
+               break;
+
+       case 2:         // return the default and total
+               ckrm_lock_hier(res->core);      // block any deletes
+               laq_get_aq_stats(res, res, &taq[0]);
+               laq_print_aq_stats(sfile, &taq[0], 0);
+               ckrm_unlock_hier(res->core);    // block any deletes
+               break;
+
+       case 3:
+               ckrm_lock_hier(parent->core);   // block any deletes
+               laq_get_aq_stats(parent, res, &taq[res->my_id]);
+               laq_print_aq_stats(sfile, &taq[res->my_id], res->my_id);
+               ckrm_unlock_hier(parent->core); // block any deletes
+               break;
+       }
+
+       return rc;
+}
+
+/*
+ * The network connection is reclassified to this class. Update its shares.
+ * The socket lock is held. 
+ */
+static void laq_change_resclass(void *n, void *old, void *r)
+{
+       struct ckrm_net_struct *ns = (struct ckrm_net_struct *)n;
+       struct ckrm_laq_res *res = (struct ckrm_laq_res *)r;
+       unsigned int aq_ratio[NUM_ACCEPT_QUEUES];
+
+       if (res->my_depth != 2)
+               return;
+
+       // a change to my_depth == 3 ie. the accept classes cannot happen.
+       // there is no target file
+       if (res->my_depth == 2) {       // it is one of the socket classes
+               ckrm_lock_hier(res->pcore);
+               // share rule: hold parent resource lock. then self.
+               // However, since my_depth == 1 is a generic class it is not
+               // needed here. Self lock is enough.
+               spin_lock(&res->reslock);
+               calculate_aq_ratios(res, aq_ratio);
+               class_lock(res->pcore);
+               laq_set_aq_value(ns, aq_ratio);
+               class_unlock(res->pcore);
+               spin_unlock(&res->reslock);
+               ckrm_unlock_hier(res->pcore);
+       }
+
+       return;
+}
+
+struct ckrm_res_ctlr laq_rcbs = {
+       .res_name = "laq",
+       .resid = -1,            // dynamically assigned
+       .res_alloc = laq_res_alloc,
+       .res_free = laq_res_free,
+       .set_share_values = laq_set_share_values,
+       .get_share_values = laq_get_share_values,
+       .get_stats = laq_get_stats,
+       .change_resclass = laq_change_resclass,
+       //.res_initcls       = laq_res_initcls,  //HUBERTUS: unnecessary !!
+};
+
+int __init init_ckrm_laq_res(void)
+{
+       struct ckrm_classtype *clstype;
+       int resid;
+
+       clstype = ckrm_find_classtype_by_name("socketclass");
+       if (clstype == NULL) {
+               printk(KERN_INFO " Unknown ckrm classtype<socketclass>");
+               return -ENOENT;
+       }
+
+       if (my_resid == -1) {
+               resid = ckrm_register_res_ctlr(clstype, &laq_rcbs);
+               if (resid >= 0)
+                       my_resid = resid;
+               printk(KERN_DEBUG "........init_ckrm_listen_aq_res -> %d\n", my_resid);
+       }
+       return 0;
+
+}
+
+void __exit exit_ckrm_laq_res(void)
+{
+       ckrm_unregister_res_ctlr(&laq_rcbs);
+       my_resid = -1;
+}
+
+module_init(init_ckrm_laq_res)
+    module_exit(exit_ckrm_laq_res)
+
+    MODULE_LICENSE("GPL");
diff --git a/kernel/ckrm/ckrm_listenaq.c b/kernel/ckrm/ckrm_listenaq.c
new file mode 100644 (file)
index 0000000..0fe8586
--- /dev/null
@@ -0,0 +1,495 @@
+/* ckrm_socketaq.c - accept queue resource controller
+ *
+ * Copyright (C) Vivek Kashyap,      IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * Initial version
+ */
+
+/* Code Description: TBD
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/errno.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_rc.h>
+#include <net/tcp.h>
+
+#include <linux/ckrm_net.h>
+
+#define hnode_2_core(ptr) \
+        ((ptr) ? container_of(ptr, struct ckrm_core_class, hnode) : NULL)
+
+#define CKRM_SAQ_MAX_DEPTH     3       // 0 => /rcfs
+                                 // 1 => socket_aq
+                                 // 2 => socket_aq/listen_class
+                                 // 3 => socket_aq/listen_class/accept_queues
+                                 // 4 => Not allowed
+
+typedef struct ckrm_laq_res {
+       spinlock_t reslock;
+       atomic_t refcnt;
+       struct ckrm_shares shares;
+       struct ckrm_core_class *core;
+       struct ckrm_core_class *pcore;
+       int my_depth;
+       int my_id;
+       unsigned int min_ratio;
+} ckrm_laq_res_t;
+
+static int my_resid = -1;
+
+extern struct ckrm_core_class *rcfs_create_under_netroot(char *, int, int);
+extern struct ckrm_core_class *rcfs_make_core(struct dentry *,
+                                             struct ckrm_core_class *);
+
+void laq_res_hold(struct ckrm_laq_res *res)
+{
+       atomic_inc(&res->refcnt);
+       return;
+}
+
+void laq_res_put(struct ckrm_laq_res *res)
+{
+       if (atomic_dec_and_test(&res->refcnt))
+               kfree(res);
+       return;
+}
+
+/* Initialize rescls values
+ */
+static void laq_res_initcls(void *my_res)
+{
+       ckrm_laq_res_t *res = my_res;
+
+       res->shares.my_guarantee = CKRM_SHARE_DONTCARE;
+       res->shares.my_limit = CKRM_SHARE_DONTCARE;
+       res->shares.total_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.max_limit = CKRM_SHARE_DFLT_MAX_LIMIT;
+       res->shares.unused_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.cur_max_limit = 0;
+}
+
+static int atoi(char *s)
+{
+       int k = 0;
+       while (*s)
+               k = *s++ - '0' + (k * 10);
+       return k;
+}
+
+static char *laq_get_name(struct ckrm_core_class *c)
+{
+       char *p = (char *)c->name;
+
+       while (*p)
+               p++;
+       while (*p != '/' && p != c->name)
+               p--;
+
+       return ++p;
+}
+
+static void *laq_res_alloc(struct ckrm_core_class *core,
+                          struct ckrm_core_class *parent)
+{
+       ckrm_laq_res_t *res, *pres;
+       int pdepth;
+
+       if (parent)
+               pres = ckrm_get_res_class(parent, my_resid, ckrm_laq_res_t);
+       else
+               pres = NULL;
+
+       if (core == core->classtype->default_class)
+               pdepth = 1;
+       else {
+               if (!parent)
+                       return NULL;
+               pdepth = 1 + pres->my_depth;
+       }
+
+       res = kmalloc(sizeof(ckrm_laq_res_t), GFP_ATOMIC);
+       if (res) {
+               memset(res, 0, sizeof(res));
+               spin_lock_init(&res->reslock);
+               laq_res_hold(res);
+               res->my_depth = pdepth;
+               if (pdepth == 2)        // listen class
+                       res->my_id = 0;
+               else if (pdepth == 3)
+                       res->my_id = atoi(laq_get_name(core));
+               res->core = core;
+               res->pcore = parent;
+
+               // rescls in place, now initialize contents other than 
+               // hierarchy pointers
+               laq_res_initcls(res);   // acts as initialising value
+       }
+
+       return res;
+}
+
+static void laq_res_free(void *my_res)
+{
+       ckrm_laq_res_t *res = (ckrm_laq_res_t *) my_res;
+       ckrm_laq_res_t *parent;
+
+       if (!res)
+               return;
+
+       if (res->my_depth != 3) {
+               kfree(res);
+               return;
+       }
+
+       parent = ckrm_get_res_class(res->pcore, my_resid, ckrm_laq_res_t);
+       if (!parent)            // Should never happen
+               return;
+
+       spin_lock(&parent->reslock);
+       spin_lock(&res->reslock);
+
+       // return child's guarantee to parent node
+       // Limits have no meaning for accept queue control
+       child_guarantee_changed(&parent->shares, res->shares.my_guarantee, 0);
+
+       spin_unlock(&res->reslock);
+       laq_res_put(res);
+       spin_unlock(&parent->reslock);
+       return;
+}
+
+/**************************************************************************
+ *                     SHARES                                          ***
+ **************************************************************************/
+
+void laq_set_aq_value(struct ckrm_net_struct *ns, unsigned int *aq_ratio)
+{
+       int i;
+       struct tcp_opt *tp;
+
+       tp = tcp_sk(ns->ns_sk);
+       for (i = 0; i < NUM_ACCEPT_QUEUES; i++)
+               tp->acceptq[i].aq_ratio = aq_ratio[i];
+       return;
+}
+void laq_set_aq_values(ckrm_laq_res_t * parent, unsigned int *aq_ratio)
+{
+
+       struct ckrm_net_struct *ns;
+       struct ckrm_core_class *core = parent->core;
+
+       class_lock(core);
+       list_for_each_entry(ns, &core->objlist, ckrm_link) {
+               laq_set_aq_value(ns, aq_ratio);
+       }
+       class_unlock(core);
+       return;
+}
+
+static void calculate_aq_ratios(ckrm_laq_res_t * res, unsigned int *aq_ratio)
+{
+       struct ckrm_hnode *chnode;
+       ckrm_laq_res_t *child;
+       unsigned int min;
+       int i;
+
+       min = aq_ratio[0] = (unsigned int)res->shares.unused_guarantee;
+
+       list_for_each_entry(chnode, &res->core->hnode.children, siblings) {
+               child = hnode_2_core(chnode)->res_class[my_resid];
+
+               aq_ratio[child->my_id] =
+                   (unsigned int)child->shares.my_guarantee;
+               if (aq_ratio[child->my_id] == CKRM_SHARE_DONTCARE)
+                       aq_ratio[child->my_id] = 0;
+               if (aq_ratio[child->my_id] &&
+                   ((unsigned int)aq_ratio[child->my_id] < min))
+                       min = (unsigned int)child->shares.my_guarantee;
+       }
+
+       if (min == 0) {
+               min = 1;
+               // default takes all if nothing specified
+               aq_ratio[0] = 1;        
+       }
+       res->min_ratio = min;
+
+       for (i = 0; i < NUM_ACCEPT_QUEUES; i++)
+               aq_ratio[i] = aq_ratio[i] / min;
+}
+
+static int laq_set_share_values(void *my_res, struct ckrm_shares *shares)
+{
+       ckrm_laq_res_t *res = my_res;
+       ckrm_laq_res_t *parent;
+       unsigned int aq_ratio[NUM_ACCEPT_QUEUES];
+       int rc = 0;
+
+       if (!res)
+               return -EINVAL;
+
+       if (!res->pcore) {
+               // something is badly wrong
+               printk(KERN_ERR "socketaq internal inconsistency\n");
+               return -EBADF;
+       }
+
+       parent = ckrm_get_res_class(res->pcore, my_resid, ckrm_laq_res_t);
+       if (!parent)            // socket_class does not have a share interface
+               return -EINVAL;
+
+       // Ensure that we ignore limit values
+       shares->my_limit = CKRM_SHARE_DONTCARE;
+       shares->max_limit = CKRM_SHARE_UNCHANGED;
+
+       if (res->my_depth == 0) {
+               printk(KERN_ERR "socketaq bad entry\n");
+               return -EBADF;
+       } else if (res->my_depth == 1) {
+               // can't be written to. This is an internal default.
+               return -EINVAL;
+       } else if (res->my_depth == 2) {
+               //nothin to inherit
+               if (!shares->total_guarantee) {
+                       return -EINVAL;
+               }
+               parent = res;
+               shares->my_guarantee = CKRM_SHARE_DONTCARE;
+       } else if (res->my_depth == 3) {
+               // accept queue itself. 
+               shares->total_guarantee = CKRM_SHARE_UNCHANGED;
+       }
+
+       ckrm_lock_hier(parent->pcore);
+       spin_lock(&parent->reslock);
+       rc = set_shares(shares, &res->shares,
+                       (parent == res) ? NULL : &parent->shares);
+       if (rc) {
+               spin_unlock(&res->reslock);
+               ckrm_unlock_hier(res->pcore);
+               return rc;
+       }
+       calculate_aq_ratios(parent, aq_ratio);
+       laq_set_aq_values(parent, aq_ratio);
+       spin_unlock(&parent->reslock);
+       ckrm_unlock_hier(parent->pcore);
+
+       return rc;
+}
+
+static int laq_get_share_values(void *my_res, struct ckrm_shares *shares)
+{
+       ckrm_laq_res_t *res = my_res;
+
+       if (!res)
+               return -EINVAL;
+       *shares = res->shares;
+       return 0;
+}
+
+/**************************************************************************
+ *                     STATS                                           ***
+ **************************************************************************/
+
+void
+laq_print_aq_stats(struct seq_file *sfile, struct tcp_acceptq_info *taq, int i)
+{
+       seq_printf(sfile, "Class %d connections:\n\taccepted: %u\n\t"
+                  "queued: %u\n\twait_time: %u\n",
+                  i, taq->acceptq_count, taq->acceptq_qcount,
+                  jiffies_to_msecs(taq->acceptq_wait_time));
+
+       if (i)
+               return;
+
+       for (i = 1; i < NUM_ACCEPT_QUEUES; i++) {
+               taq[0].acceptq_wait_time += taq[i].acceptq_wait_time;
+               taq[0].acceptq_qcount += taq[i].acceptq_qcount;
+               taq[0].acceptq_count += taq[i].acceptq_count;
+       }
+
+       seq_printf(sfile, "Totals :\n\taccepted: %u\n\t"
+                  "queued: %u\n\twait_time: %u\n",
+                  taq->acceptq_count, taq->acceptq_qcount,
+                  jiffies_to_msecs(taq->acceptq_wait_time));
+
+       return;
+}
+
+void
+laq_get_aq_stats(ckrm_laq_res_t * pres, ckrm_laq_res_t * mres,
+                struct tcp_acceptq_info *taq)
+{
+       struct ckrm_net_struct *ns;
+       struct ckrm_core_class *core = pres->core;
+       struct tcp_opt *tp;
+       int a = mres->my_id;
+       int z;
+
+       if (a == 0)
+               z = NUM_ACCEPT_QUEUES;
+       else
+               z = a + 1;
+
+       // XXX Instead of holding a  class_lock introduce a rw
+       // lock to be write locked by listen callbacks and read locked here.
+       // - VK
+       class_lock(pres->core);
+       list_for_each_entry(ns, &core->objlist, ckrm_link) {
+               tp = tcp_sk(ns->ns_sk);
+               for (; a < z; a++) {
+                       taq->acceptq_wait_time += tp->acceptq[a].aq_wait_time;
+                       taq->acceptq_qcount += tp->acceptq[a].aq_qcount;
+                       taq->acceptq_count += tp->acceptq[a].aq_count;
+                       taq++;
+               }
+       }
+       class_unlock(pres->core);
+}
+
+static int laq_get_stats(void *my_res, struct seq_file *sfile)
+{
+       ckrm_laq_res_t *res = my_res;
+       ckrm_laq_res_t *parent;
+       struct tcp_acceptq_info taq[NUM_ACCEPT_QUEUES];
+       int rc = 0;
+
+       if (!res)
+               return -EINVAL;
+
+       if (!res->pcore) {
+               // something is badly wrong
+               printk(KERN_ERR "socketaq internal inconsistency\n");
+               return -EBADF;
+       }
+
+       parent = ckrm_get_res_class(res->pcore, my_resid, ckrm_laq_res_t);
+       if (!parent) {          // socket_class does not have a stat interface
+               printk(KERN_ERR "socketaq internal fs inconsistency\n");
+               return -EINVAL;
+       }
+
+       memset(taq, 0, sizeof(struct tcp_acceptq_info) * NUM_ACCEPT_QUEUES);
+
+       switch (res->my_depth) {
+
+       default:
+       case 0:
+               printk(KERN_ERR "socket class bad entry\n");
+               rc = -EBADF;
+               break;
+
+       case 1:         // can't be read from. this is internal default.
+               // return -EINVAL
+               rc = -EINVAL;
+               break;
+
+       case 2:         // return the default and total
+               ckrm_lock_hier(res->core);      // block any deletes
+               laq_get_aq_stats(res, res, &taq[0]);
+               laq_print_aq_stats(sfile, &taq[0], 0);
+               ckrm_unlock_hier(res->core);    // block any deletes
+               break;
+
+       case 3:
+               ckrm_lock_hier(parent->core);   // block any deletes
+               laq_get_aq_stats(parent, res, &taq[res->my_id]);
+               laq_print_aq_stats(sfile, &taq[res->my_id], res->my_id);
+               ckrm_unlock_hier(parent->core); // block any deletes
+               break;
+       }
+
+       return rc;
+}
+
+/*
+ * The network connection is reclassified to this class. Update its shares.
+ * The socket lock is held. 
+ */
+static void laq_change_resclass(void *n, void *old, void *r)
+{
+       struct ckrm_net_struct *ns = (struct ckrm_net_struct *)n;
+       struct ckrm_laq_res *res = (struct ckrm_laq_res *)r;
+       unsigned int aq_ratio[NUM_ACCEPT_QUEUES];
+
+       if (res->my_depth != 2)
+               return;
+
+       // a change to my_depth == 3 ie. the accept classes cannot happen.
+       // there is no target file
+       if (res->my_depth == 2) {       // it is one of the socket classes
+               ckrm_lock_hier(res->pcore);
+               // share rule: hold parent resource lock. then self.
+               // However, since my_depth == 1 is a generic class it is not
+               // needed here. Self lock is enough.
+               spin_lock(&res->reslock);
+               calculate_aq_ratios(res, aq_ratio);
+               class_lock(res->pcore);
+               laq_set_aq_value(ns, aq_ratio);
+               class_unlock(res->pcore);
+               spin_unlock(&res->reslock);
+               ckrm_unlock_hier(res->pcore);
+       }
+
+       return;
+}
+
+struct ckrm_res_ctlr laq_rcbs = {
+       .res_name = "laq",
+       .resid = -1,            // dynamically assigned
+       .res_alloc = laq_res_alloc,
+       .res_free = laq_res_free,
+       .set_share_values = laq_set_share_values,
+       .get_share_values = laq_get_share_values,
+       .get_stats = laq_get_stats,
+       .change_resclass = laq_change_resclass,
+       //.res_initcls       = laq_res_initcls,  //HUBERTUS: unnecessary !!
+};
+
+int __init init_ckrm_laq_res(void)
+{
+       struct ckrm_classtype *clstype;
+       int resid;
+
+       clstype = ckrm_find_classtype_by_name("socket_class");
+       if (clstype == NULL) {
+               printk(KERN_INFO " Unknown ckrm classtype<socket_class>");
+               return -ENOENT;
+       }
+
+       if (my_resid == -1) {
+               resid = ckrm_register_res_ctlr(clstype, &laq_rcbs);
+               if (resid >= 0)
+                       my_resid = resid;
+               printk("........init_ckrm_listen_aq_res -> %d\n", my_resid);
+       }
+       return 0;
+
+}
+
+void __exit exit_ckrm_laq_res(void)
+{
+       ckrm_unregister_res_ctlr(&laq_rcbs);
+       my_resid = -1;
+}
+
+module_init(init_ckrm_laq_res)
+    module_exit(exit_ckrm_laq_res)
+
+    MODULE_LICENSE("GPL");
diff --git a/kernel/ckrm/ckrm_mem.c b/kernel/ckrm/ckrm_mem.c
new file mode 100644 (file)
index 0000000..c6c594a
--- /dev/null
@@ -0,0 +1,904 @@
+/* ckrm_mem.c - Memory Resource Manager for CKRM
+ *
+ * Copyright (C) Chandra Seetharaman, IBM Corp. 2004
+ *
+ * Provides a Memory Resource controller for CKRM
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Code Description: TBD
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/errno.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/pagemap.h>
+#include <linux/swap.h>
+#include <linux/swapops.h>
+#include <linux/cache.h>
+#include <linux/percpu.h>
+#include <linux/pagevec.h>
+
+#include <linux/ckrm_mem_inline.h>
+
+#include <asm/uaccess.h>
+#include <asm/pgtable.h>
+
+#define MEM_NAME "mem"
+
+#define CKRM_MEM_MAX_HIERARCHY 2 // allows only upto 2 levels - 0, 1 & 2
+
+/* all 1-level memory_share_class are chained together */
+static LIST_HEAD(ckrm_memclass_list);
+LIST_HEAD(ckrm_shrink_list);
+EXPORT_SYMBOL(ckrm_shrink_list);
+spinlock_t ckrm_mem_lock = SPIN_LOCK_UNLOCKED; // protects both lists above
+EXPORT_SYMBOL(ckrm_mem_lock);
+unsigned int ckrm_tot_lru_pages; // total # of pages in the system
+                                                        // currently doesn't handle memory add/remove
+EXPORT_SYMBOL(ckrm_tot_lru_pages);
+
+static ckrm_mem_res_t *ckrm_mem_root_class;
+atomic_t ckrm_mem_real_count = ATOMIC_INIT(0);
+EXPORT_SYMBOL(ckrm_mem_real_count);
+static void ckrm_mem_evaluate_all_pages(void);
+
+/* Initialize rescls values
+ * May be called on each rcfs unmount or as part of error recovery
+ * to make share values sane.
+ * Does not traverse hierarchy reinitializing children.
+ */
+
+static void
+set_ckrm_tot_pages(void)
+{
+       struct zone *zone;
+       int tot_lru_pages = 0;
+
+       for_each_zone(zone) {
+               tot_lru_pages += zone->nr_active;
+               tot_lru_pages += zone->nr_inactive;
+               tot_lru_pages += zone->free_pages;
+       }
+       ckrm_tot_lru_pages = tot_lru_pages;
+}
+
+static void
+mem_res_initcls_one(void *my_res)
+{
+       ckrm_mem_res_t *res = my_res;
+
+       memset(res, 0, sizeof(ckrm_mem_res_t));
+
+       res->shares.my_guarantee     = CKRM_SHARE_DONTCARE;
+       res->shares.my_limit         = CKRM_SHARE_DONTCARE;
+       res->shares.total_guarantee  = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.max_limit        = CKRM_SHARE_DFLT_MAX_LIMIT;
+       res->shares.unused_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.cur_max_limit    = 0;
+
+       res->pg_guar = CKRM_SHARE_DONTCARE;
+       res->pg_limit = CKRM_SHARE_DONTCARE;
+       res->pg_unused = 0;
+}
+
+static void *
+mem_res_alloc(struct ckrm_core_class *core, struct ckrm_core_class *parent)
+{
+       ckrm_mem_res_t *res, *parres;
+
+       if (mem_rcbs.resid == -1) {
+               return NULL;
+       }
+
+       parres = ckrm_get_res_class(parent, mem_rcbs.resid, ckrm_mem_res_t);
+       if (parres && (parres->hier == CKRM_MEM_MAX_HIERARCHY)) {
+               // allows only upto CKRM_MEM_MAX_HIERARCHY
+               return NULL;
+       }
+
+       if (unlikely((parent == NULL) && (ckrm_mem_root_class != NULL))) {
+               printk(KERN_ERR "MEM_RC: Only one root class is allowed\n");
+               return NULL;
+       }
+               
+       if (unlikely((parent != NULL) && (ckrm_mem_root_class == NULL))) {
+               printk(KERN_ERR "MEM_RC: creating child class without root class\n");
+               return NULL;
+       }
+               
+       res = kmalloc(sizeof(ckrm_mem_res_t), GFP_ATOMIC);
+       
+       if (res) {
+               mem_res_initcls_one(res);
+               res->core = core;
+               res->parent = parent;
+               spin_lock(&ckrm_mem_lock);
+               list_add(&res->mcls_list, &ckrm_memclass_list);
+               spin_unlock(&ckrm_mem_lock);
+               if (parent == NULL) {
+                       // I am part of the root class. So, set the max to 
+                       // number of pages available
+                       res->pg_guar = ckrm_tot_lru_pages;
+                       res->pg_unused = ckrm_tot_lru_pages;
+                       res->pg_limit = ckrm_tot_lru_pages;
+                       res->hier = 0;
+                       ckrm_mem_root_class = res;
+               } else {
+                       res->hier = parres->hier + 1;
+               }
+               mem_class_get(res);
+       }
+       else
+               printk(KERN_ERR "mem_res_alloc: failed GFP_ATOMIC alloc\n");
+       return res;
+}
+
+/*
+ * It is the caller's responsibility to make sure that the parent only
+ * has chilren that are to be accounted. i.e if a new child is added
+ * this function should be called after it has been added, and if a
+ * child is deleted this should be called after the child is removed.
+ */
+static void
+child_maxlimit_changed_local(ckrm_mem_res_t *parres)
+{
+       int maxlimit = 0;
+       ckrm_mem_res_t *childres;
+       ckrm_core_class_t *child = NULL;
+
+       // run thru parent's children and get the new max_limit of the parent
+       ckrm_lock_hier(parres->core);
+       while ((child = ckrm_get_next_child(parres->core, child)) != NULL) {
+               childres = ckrm_get_res_class(child, mem_rcbs.resid,
+                               ckrm_mem_res_t);
+               if (maxlimit < childres->shares.my_limit) {
+                       maxlimit = childres->shares.my_limit;
+               }
+       }
+       ckrm_unlock_hier(parres->core);
+       parres->shares.cur_max_limit = maxlimit;
+}
+
+static void
+mem_res_free(void *my_res)
+{
+       ckrm_mem_res_t *res = my_res;
+       ckrm_mem_res_t *parres;
+
+       if (!res) 
+               return;
+
+       res->shares.my_guarantee = 0;
+       res->shares.my_limit = 0;
+       res->pg_guar = 0;
+       res->pg_limit = 0;
+       res->pg_unused = 0;
+
+       parres = ckrm_get_res_class(res->parent, mem_rcbs.resid, ckrm_mem_res_t);
+       // return child's limit/guarantee to parent node
+       if (parres) {
+               child_guarantee_changed(&parres->shares, res->shares.my_guarantee, 0);
+               child_maxlimit_changed_local(parres);
+       }
+       ckrm_mem_evaluate_all_pages();
+       res->core = NULL;
+
+       spin_lock(&ckrm_mem_lock);
+       list_del(&res->mcls_list);
+       spin_unlock(&ckrm_mem_lock);
+       mem_class_put(res);
+       return;
+}
+
+/*
+ * Recalculate the guarantee and limit in # of pages... and propagate the
+ * same to children.
+ * Caller is responsible for protecting res and for the integrity of parres
+ */
+static void
+recalc_and_propagate(ckrm_mem_res_t * res, ckrm_mem_res_t * parres)
+{
+       ckrm_core_class_t *child = NULL;
+       ckrm_mem_res_t *childres;
+       int resid = mem_rcbs.resid;
+       struct ckrm_shares *self = &res->shares;
+
+       if (parres) {
+               struct ckrm_shares *par = &parres->shares;
+
+               // calculate pg_guar and pg_limit
+               //
+               if (parres->pg_guar == CKRM_SHARE_DONTCARE ||
+                               self->my_guarantee == CKRM_SHARE_DONTCARE) {
+                       res->pg_guar = CKRM_SHARE_DONTCARE;
+               } else if (par->total_guarantee) {
+                       u64 temp = (u64) self->my_guarantee * parres->pg_guar;
+                       do_div(temp, par->total_guarantee);
+                       res->pg_guar = (int) temp;
+               } else {
+                       res->pg_guar = 0;
+               }
+
+               if (parres->pg_limit == CKRM_SHARE_DONTCARE ||
+                               self->my_limit == CKRM_SHARE_DONTCARE) {
+                       res->pg_limit = CKRM_SHARE_DONTCARE;
+               } else if (par->max_limit) {
+                       u64 temp = (u64) self->my_limit * parres->pg_limit;
+                       do_div(temp, par->max_limit);
+                       res->pg_limit = (int) temp;
+               } else {
+                       res->pg_limit = 0;
+               }
+       }
+
+       // Calculate unused units
+       if (res->pg_guar == CKRM_SHARE_DONTCARE) {
+               res->pg_unused = CKRM_SHARE_DONTCARE;
+       } else if (self->total_guarantee) {
+               u64 temp = (u64) self->unused_guarantee * res->pg_guar;
+               do_div(temp, self->total_guarantee);
+               res->pg_unused = (int) temp;
+       } else {
+               res->pg_unused = 0;
+       }
+
+       // propagate to children
+       ckrm_lock_hier(res->core);
+       while ((child = ckrm_get_next_child(res->core, child)) != NULL) {
+               childres = ckrm_get_res_class(child, resid, ckrm_mem_res_t);
+               recalc_and_propagate(childres, res);
+       }
+       ckrm_unlock_hier(res->core);
+       return;
+}
+
+static int
+mem_set_share_values(void *my_res, struct ckrm_shares *shares)
+{
+       ckrm_mem_res_t *res = my_res;
+       ckrm_mem_res_t *parres;
+       int rc = EINVAL;
+
+       if (!res) 
+               return -EINVAL;
+
+       parres = ckrm_get_res_class(res->parent, mem_rcbs.resid, ckrm_mem_res_t);
+
+       rc = set_shares(shares, &res->shares, parres ? &parres->shares : NULL);
+
+       if ((rc == 0) && (parres != NULL)) {
+               child_maxlimit_changed_local(parres);
+               recalc_and_propagate(parres, NULL);
+       }
+       return rc;
+}
+
+static int
+mem_get_share_values(void *my_res, struct ckrm_shares *shares)
+{
+       ckrm_mem_res_t *res = my_res;
+
+       if (!res) 
+               return -EINVAL;
+       *shares = res->shares;
+       return 0;
+}
+
+static int  
+mem_get_stats(void *my_res, struct seq_file *sfile)
+{
+       ckrm_mem_res_t *res = my_res;
+
+       if (!res) 
+               return -EINVAL;
+
+#if 0
+       seq_printf(sfile, "tot %6d;gua %6d;lmt %6d;unu %6d;"
+                       "lnt %6d;bor %6d;rlt %6d\n", atomic_read(&res->pg_total),
+                       res->pg_guar, res->pg_limit, res->pg_unused, res->pg_lent,
+                       res->pg_borrowed, atomic_read(&ckrm_mem_real_count));
+#endif
+
+
+       seq_printf(sfile, "----------- Memory Resource stats start -----------\n");
+       seq_printf(sfile, "Number of pages used(including pages lent to children):"
+                       " %d\n", atomic_read(&res->pg_total));
+       seq_printf(sfile, "Number of pages guaranteed: %d\n",
+                       res->pg_guar);
+       seq_printf(sfile, "Maximum limit of pages: %d\n",
+                       res->pg_limit);
+       seq_printf(sfile, "Total number of pages available"
+                       "(after serving guarantees to children): %d\n",
+                       res->pg_unused);
+       seq_printf(sfile, "Number of pages lent to children: %d\n",
+                       res->pg_lent);
+       seq_printf(sfile, "Number of pages borrowed from the parent: %d\n",
+                       res->pg_borrowed);
+       seq_printf(sfile, "----------- Memory Resource stats end -----------\n");
+
+       return 0;
+}
+
+static void
+mem_change_resclass(void *tsk, void *old, void *new)
+{
+       struct mm_struct *mm;
+       struct task_struct *task = tsk, *t1;
+       struct ckrm_mem_res *prev_mmcls;
+       
+       if (!task->mm || (new == old) || (old == (void *) -1))
+               return;
+
+       mm = task->active_mm;
+       spin_lock(&mm->peertask_lock);
+       prev_mmcls = mm->memclass;
+               
+       if (new == NULL) {
+               list_del_init(&task->mm_peers);
+       } else {
+               int found = 0;
+               list_for_each_entry(t1, &mm->tasklist, mm_peers) {
+                       if (t1 == task) {
+                               found++;
+                               break;
+                       }
+               }
+               if (!found) {
+                       list_del_init(&task->mm_peers);
+                       list_add_tail(&task->mm_peers, &mm->tasklist);
+               }
+       }
+
+       spin_unlock(&mm->peertask_lock);
+       ckrm_mem_evaluate_mm(mm);
+       /*
+       printk("chg_cls: task <%s:%d> mm %p oldmm %s newmm %s o %s n %s\n",
+               task->comm, task->pid, mm, prev_mmcls ? prev_mmcls->core->name:
+               "NULL", mm->memclass ? mm->memclass->core->name : "NULL",
+               o ? o->core->name: "NULL", n ? n->core->name: "NULL");  
+       */
+       return;
+}
+
+// config file is available only at the root level,
+// so assuming my_res to be the system level class
+static int
+mem_set_config(void *my_res, const char *cfgstr)
+{
+       ckrm_mem_res_t *res = my_res;
+
+       printk(KERN_INFO "%s class of %s is called with config<%s>\n",
+                       MEM_NAME, res->core->name, cfgstr);
+       return 0;
+}
+
+static int 
+mem_show_config(void *my_res, struct seq_file *sfile)
+{
+       struct zone *zone;
+       ckrm_mem_res_t *res = my_res;
+       int active = 0, inactive = 0, fr = 0;
+
+       if (!res)
+               return -EINVAL;
+
+       for_each_zone(zone) {
+               active += zone->nr_active;
+               inactive += zone->nr_inactive;
+               fr += zone->free_pages;
+       }
+       seq_printf(sfile, "res=%s;tot_pages=%d,active=%d,inactive=%d,free=%d\n",
+                       MEM_NAME, ckrm_tot_lru_pages,active,inactive,fr);
+
+
+       return 0;
+}
+
+static int
+mem_reset_stats(void *my_res)
+{
+       ckrm_mem_res_t *res = my_res;
+       printk(KERN_INFO " memclass of %s called for reset\n", res->core->name);
+       return 0;
+}
+
+struct ckrm_res_ctlr mem_rcbs = {
+       .res_name          = MEM_NAME,
+       .res_hdepth        = CKRM_MEM_MAX_HIERARCHY,
+       .resid             = -1,
+       .res_alloc         = mem_res_alloc,
+       .res_free          = mem_res_free,
+       .set_share_values  = mem_set_share_values,
+       .get_share_values  = mem_get_share_values,
+       .get_stats         = mem_get_stats,
+       .change_resclass   = mem_change_resclass,
+       .show_config       = mem_show_config,
+       .set_config        = mem_set_config,
+       .reset_stats       = mem_reset_stats,
+};
+
+EXPORT_SYMBOL(mem_rcbs);
+
+int __init
+init_ckrm_mem_res(void)
+{
+       struct ckrm_classtype *clstype;
+       int resid = mem_rcbs.resid;
+
+       set_ckrm_tot_pages();
+       clstype = ckrm_find_classtype_by_name("taskclass");
+       if (clstype == NULL) {
+               printk(KERN_INFO " Unknown ckrm classtype<taskclass>");
+               return -ENOENT;
+       }
+
+       if (resid == -1) {
+               resid = ckrm_register_res_ctlr(clstype, &mem_rcbs);
+               if (resid != -1) {
+                       mem_rcbs.classtype = clstype;
+               }
+       }
+       return ((resid < 0) ? resid : 0);
+}      
+
+void __exit
+exit_ckrm_mem_res(void)
+{
+       ckrm_unregister_res_ctlr(&mem_rcbs);
+       mem_rcbs.resid = -1;
+}
+
+module_init(init_ckrm_mem_res)
+module_exit(exit_ckrm_mem_res)
+
+static void
+set_flags_of_children(ckrm_mem_res_t *parres, unsigned int flag)
+{
+       ckrm_mem_res_t *childres;
+       ckrm_core_class_t *child = NULL;
+
+       parres->reclaim_flags |= flag;
+       ckrm_lock_hier(parres->core);
+       while ((child = ckrm_get_next_child(parres->core, child)) != NULL) {
+               childres = ckrm_get_res_class(child, mem_rcbs.resid,
+                               ckrm_mem_res_t);
+               set_flags_of_children(childres, flag);
+       }
+       ckrm_unlock_hier(parres->core);
+       return;
+}
+
+// FIXME: more attention is needed to this function
+static unsigned int
+set_usage_flags(ckrm_mem_res_t *res)
+{
+       int tot_usage, cls_usage, range, guar;
+
+       if (res->pg_limit == CKRM_SHARE_DONTCARE) {
+                       // No limit is set for the class. don't bother it
+                       res->reclaim_flags = 0;
+                       return res->reclaim_flags;
+       }
+
+       tot_usage = atomic_read(&res->pg_total);
+       cls_usage = tot_usage - res->pg_lent;
+       guar = (res->pg_guar > 0) ? res->pg_guar : 0;
+       range = res->pg_limit - guar;
+
+       if ((tot_usage > (guar + ((110 * range) / 100))) &&
+                               (res->pg_lent > (guar + ((25 * range) / 100)))) {
+               set_flags_of_children(res, CLS_PARENT_OVER);
+       }
+
+       if (cls_usage > (guar + ((110 * range) / 100))) {
+               res->reclaim_flags |= CLS_OVER_110;
+       } else if (cls_usage > (guar + range)) {
+               res->reclaim_flags |= CLS_OVER_100;
+       } else if (cls_usage > (guar + ((3 * range) / 4))) {
+               res->reclaim_flags |= CLS_OVER_75;
+       } else if (cls_usage > (guar + (range / 2))) {
+               res->reclaim_flags |= CLS_OVER_50;
+       } else if (cls_usage > (guar + (range / 4))) {
+               res->reclaim_flags |= CLS_OVER_25;
+       } else if (cls_usage > guar) {
+               res->reclaim_flags |= CLS_OVER_GUAR;
+       } else {
+               res->reclaim_flags = 0;
+       }
+       return res->reclaim_flags;
+}
+
+/*
+ * The functions ckrm_setup_reclamation(), ckrm_teardown_reclamation(),
+ * ckrm_get_reclaim_bits() and the macro ckrm_kick_page() along with the 
+ * macros CLS_* define how the pages are reclaimed.
+ * Keeping this logic thru these interface eliminate the necessity to
+ * change the reclaimation code in VM if we want to change the logic.
+ */
+unsigned int
+ckrm_setup_reclamation(void)
+{
+       ckrm_mem_res_t *res;
+       unsigned int ret = 0;
+
+       spin_lock(&ckrm_mem_lock);
+       set_ckrm_tot_pages();
+       ckrm_mem_root_class->pg_guar = ckrm_tot_lru_pages;
+       ckrm_mem_root_class->pg_unused = ckrm_tot_lru_pages;
+       ckrm_mem_root_class->pg_limit = ckrm_tot_lru_pages;
+       recalc_and_propagate(ckrm_mem_root_class, NULL);
+       list_for_each_entry(res, &ckrm_memclass_list, mcls_list) {
+               ret |= set_usage_flags(res);
+       }
+       spin_unlock(&ckrm_mem_lock);
+       return ret;
+}
+
+void
+ckrm_teardown_reclamation(void)
+{
+       ckrm_mem_res_t *res;
+       spin_lock(&ckrm_mem_lock);
+       list_for_each_entry(res, &ckrm_memclass_list, mcls_list) {
+               res->reclaim_flags = 0;
+       }
+       spin_unlock(&ckrm_mem_lock);
+}
+
+void
+ckrm_get_reclaim_bits(unsigned int *flags, unsigned int *extract)
+{
+       int i, j, mask = 0;
+
+       if (*flags == 0) {
+               *extract = 0;
+               return;
+       }
+
+       if (*flags & CLS_SHRINK) {
+               *extract = CLS_SHRINK;
+               *flags = 0;
+               return;
+       }
+
+       i = fls(*flags);
+       for (j = i-1; j > 0; j--) {
+               mask = (mask<<1) | 1;
+       }
+       *extract = (CLS_FLAGS_ALL & ~mask);
+       *flags &= ~*extract;
+       return;
+}
+
+void
+ckrm_at_limit(ckrm_mem_res_t *cls)
+{
+#ifndef AT_LIMIT_SUPPORT
+#warning "ckrm_at_limit disabled due to problems with memory hog tests"
+#else
+       struct zone *zone;
+       unsigned long now = jiffies;
+
+       if (!cls || (cls->pg_limit == CKRM_SHARE_DONTCARE) || 
+                       ((cls->flags & MEM_AT_LIMIT) == MEM_AT_LIMIT)) {
+               return;
+       }
+       if ((cls->last_shrink + (10 * HZ)) < now) { // 10 seconds since last ?
+               cls->last_shrink = now;
+               cls->shrink_count = 0;
+       }
+       cls->shrink_count++;
+       if (cls->shrink_count > 10) {
+               return;
+       }
+       spin_lock(&ckrm_mem_lock);
+       list_add(&cls->shrink_list, &ckrm_shrink_list);
+       spin_unlock(&ckrm_mem_lock);
+       cls->flags |= MEM_AT_LIMIT;
+       for_each_zone(zone) {
+               wakeup_kswapd(zone);
+               break; // only once is enough
+       }
+#endif // AT_LIMIT_SUPPORT
+}
+
+static int unmapped = 0, changed = 0, unchanged = 0, maxnull = 0,
+anovma = 0, fnovma = 0;
+static void
+ckrm_mem_evaluate_page_anon(struct page* page)
+{
+       ckrm_mem_res_t* pgcls = page_class(page);
+       ckrm_mem_res_t* maxshareclass = NULL;
+       struct anon_vma *anon_vma = (struct anon_vma *) page->mapping;
+       struct vm_area_struct *vma;
+       struct mm_struct* mm;
+       int v = 0;
+
+       spin_lock(&anon_vma->lock);
+       BUG_ON(list_empty(&anon_vma->head));
+       list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
+               v++;
+               mm = vma->vm_mm;
+               if (!maxshareclass ||
+                               ckrm_mem_share_compare(maxshareclass, mm->memclass) < 0) {
+                       maxshareclass = mm->memclass;
+               }
+       }
+       spin_unlock(&anon_vma->lock);
+       if (!v)
+               anovma++;
+
+       if (!maxshareclass)
+               maxnull++;
+       if (maxshareclass && (pgcls != maxshareclass)) {
+               ckrm_change_page_class(page, maxshareclass);
+               changed++;
+       } else 
+               unchanged++;
+       return;
+}
+
+static void
+ckrm_mem_evaluate_page_file(struct page* page) 
+{
+       ckrm_mem_res_t* pgcls = page_class(page);
+       ckrm_mem_res_t* maxshareclass = NULL;
+       struct address_space *mapping = page->mapping;
+       struct vm_area_struct *vma = NULL;
+       pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+       struct prio_tree_iter iter;
+       struct mm_struct* mm;
+       int v = 0;
+
+       if (!mapping)
+               return;
+
+       if (!spin_trylock(&mapping->i_mmap_lock))
+               return;
+
+       while ((vma = vma_prio_tree_next(vma, &mapping->i_mmap,
+                                       &iter, pgoff, pgoff)) != NULL) {
+               v++;
+               mm = vma->vm_mm;
+               if (!maxshareclass || ckrm_mem_share_compare(maxshareclass,mm->memclass)<0)
+                       maxshareclass = mm->memclass;
+       }
+       spin_unlock(&mapping->i_mmap_lock);
+
+       if (!v)
+               fnovma++;
+       if (!maxshareclass)
+               maxnull++;
+
+       if (maxshareclass && pgcls != maxshareclass) {
+               ckrm_change_page_class(page, maxshareclass);
+               changed++;
+       } else 
+               unchanged++;
+       return;
+}
+
+static void
+ckrm_mem_evaluate_page(struct page* page) 
+{
+       if (page->mapping) {
+               if (PageAnon(page))
+                       ckrm_mem_evaluate_page_anon(page);
+               else
+                       ckrm_mem_evaluate_page_file(page);
+       } else
+               unmapped++;
+       return;
+}
+
+static void
+ckrm_mem_evaluate_all_pages()
+{
+       struct page *page;
+       struct zone *zone;
+       int active = 0, inactive = 0, cleared = 0;
+       int act_cnt, inact_cnt, idx;
+       ckrm_mem_res_t *res;
+
+       spin_lock(&ckrm_mem_lock);
+       list_for_each_entry(res, &ckrm_memclass_list, mcls_list) {
+               res->tmp_cnt = 0;
+       }
+       spin_unlock(&ckrm_mem_lock);
+
+       for_each_zone(zone) {
+               spin_lock_irq(&zone->lru_lock);
+               list_for_each_entry(page, &zone->inactive_list, lru) {
+                       ckrm_mem_evaluate_page(page);
+                       active++;
+                       page_class(page)->tmp_cnt++;
+                       if (!test_bit(PG_ckrm_account, &page->flags))
+                               cleared++;
+               }
+               list_for_each_entry(page, &zone->active_list, lru) {
+                       ckrm_mem_evaluate_page(page);
+                       inactive++;
+                       page_class(page)->tmp_cnt++;
+                       if (!test_bit(PG_ckrm_account, &page->flags))
+                               cleared++;
+               }
+               spin_unlock_irq(&zone->lru_lock);
+       }
+       printk(KERN_DEBUG "all_pages: active %d inactive %d cleared %d\n", 
+                       active, inactive, cleared);
+       spin_lock(&ckrm_mem_lock);
+       list_for_each_entry(res, &ckrm_memclass_list, mcls_list) {
+               act_cnt = 0; inact_cnt = 0; idx = 0;
+               for_each_zone(zone) {
+                       act_cnt += res->nr_active[idx];
+                       inact_cnt += res->nr_inactive[idx];
+                       idx++;
+               }
+               printk(KERN_DEBUG "all_pages: %s: tmp_cnt %d; act_cnt %d inact_cnt %d\n",
+                       res->core->name, res->tmp_cnt, act_cnt, inact_cnt);
+       }
+       spin_unlock(&ckrm_mem_lock);
+
+       // check all mm's in the system to see which memclass they are attached
+       // to.
+       return;
+}
+
+static /*inline*/ int
+class_migrate_pmd(struct mm_struct* mm, struct vm_area_struct* vma,
+               pmd_t* pmdir, unsigned long address, unsigned long end)
+{
+       pte_t *pte, *orig_pte;
+       unsigned long pmd_end;
+       
+       if (pmd_none(*pmdir))
+               return 0;
+       BUG_ON(pmd_bad(*pmdir));
+       
+       orig_pte = pte = pte_offset_map(pmdir,address);
+       pmd_end = (address+PMD_SIZE)&PMD_MASK;
+       if (end>pmd_end)
+               end = pmd_end;
+       
+       do {
+               if (pte_present(*pte)) {
+                       BUG_ON(mm->memclass == NULL);
+                       ckrm_change_page_class(pte_page(*pte), mm->memclass);
+                       // ckrm_mem_evaluate_page(pte_page(*pte));
+               }
+               address += PAGE_SIZE;
+               pte++;
+       } while(address && (address<end));
+       pte_unmap(orig_pte);
+       return 0;
+}
+
+static /*inline*/ int
+class_migrate_pgd(struct mm_struct* mm, struct vm_area_struct* vma,
+               pgd_t* pgdir, unsigned long address, unsigned long end)
+{
+       pmd_t* pmd;
+       unsigned long pgd_end;
+       
+       if (pgd_none(*pgdir))
+               return 0;
+       BUG_ON(pgd_bad(*pgdir));
+       
+       pmd = pmd_offset(pgdir,address);
+       pgd_end = (address+PGDIR_SIZE)&PGDIR_MASK;
+       
+       if (pgd_end && (end>pgd_end))
+               end = pgd_end;
+       
+       do {
+               class_migrate_pmd(mm,vma,pmd,address,end);
+               address =  (address+PMD_SIZE)&PMD_MASK;
+               pmd++;
+       } while (address && (address<end));
+       return 0;
+}
+
+static /*inline*/ int
+class_migrate_vma(struct mm_struct* mm, struct vm_area_struct* vma)
+{
+       pgd_t* pgdir;
+       unsigned long address, end;
+       
+       address = vma->vm_start;
+       end = vma->vm_end;
+       
+       pgdir = pgd_offset(vma->vm_mm, address);
+       do {
+               class_migrate_pgd(mm,vma,pgdir,address,end);
+               address = (address + PGDIR_SIZE) & PGDIR_MASK;
+               pgdir++;
+       } while(address && (address<end));
+       return 0;
+}
+
+/* this function is called with mm->peertask_lock hold */
+void
+ckrm_mem_evaluate_mm(struct mm_struct* mm)
+{
+       struct task_struct *task;
+       struct ckrm_mem_res *maxshareclass = NULL;
+       struct vm_area_struct *vma;
+       
+       if (list_empty(&mm->tasklist)) {
+               /* We leave the mm->memclass untouched since we believe that one
+                * mm with no task associated will be deleted soon or attach
+                * with another task later.
+                */
+               return; 
+       }
+
+       list_for_each_entry(task, &mm->tasklist, mm_peers) {
+               ckrm_mem_res_t* cls = GET_MEM_CLASS(task);
+               if (!cls)
+                       continue;
+               if (!maxshareclass || ckrm_mem_share_compare(maxshareclass,cls)<0 ) 
+                       maxshareclass = cls;
+       }
+
+       if (maxshareclass && (mm->memclass != (void *)maxshareclass)) {
+               if (mm->memclass)
+                       mem_class_put(mm->memclass);
+               mm->memclass = maxshareclass;
+               mem_class_get(maxshareclass);
+               
+               /* Go through all VMA to migrate pages */
+               down_read(&mm->mmap_sem);
+               vma = mm->mmap;
+               while(vma) {
+                       class_migrate_vma(mm, vma);
+                       vma = vma->vm_next;
+               }
+               up_read(&mm->mmap_sem);
+       }
+       return;
+}
+
+void
+ckrm_init_mm_to_task(struct mm_struct * mm, struct task_struct *task)
+{
+       spin_lock(&mm->peertask_lock);
+       if (!list_empty(&task->mm_peers)) {
+               printk(KERN_ERR "CKRM_MEM: Task list should be empty, but is not!!\n");
+               list_del_init(&task->mm_peers);
+       }
+       list_add_tail(&task->mm_peers, &mm->tasklist);
+       spin_unlock(&mm->peertask_lock);
+       if (mm->memclass != GET_MEM_CLASS(task))
+               ckrm_mem_evaluate_mm(mm);
+       return;
+}
+
+int
+ckrm_memclass_valid(ckrm_mem_res_t *cls)
+{
+       ckrm_mem_res_t *tmp;
+
+       spin_lock(&ckrm_mem_lock);
+       list_for_each_entry(tmp, &ckrm_memclass_list, mcls_list) {
+               if (tmp == cls) {
+                       spin_unlock(&ckrm_mem_lock);
+                       return 1;
+               }
+       }
+       spin_unlock(&ckrm_mem_lock);
+       return 0;
+}
+
+MODULE_LICENSE("GPL");
diff --git a/kernel/ckrm/ckrm_numtasks.c b/kernel/ckrm/ckrm_numtasks.c
new file mode 100644 (file)
index 0000000..61517ae
--- /dev/null
@@ -0,0 +1,530 @@
+/* ckrm_numtasks.c - "Number of tasks" resource controller for CKRM
+ *
+ * Copyright (C) Chandra Seetharaman,  IBM Corp. 2003
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * 
+ * 31 Mar 2004: Created
+ * 
+ */
+
+/*
+ * Code Description: TBD
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <asm/errno.h>
+#include <asm/div64.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_rc.h>
+#include <linux/ckrm_tc.h>
+#include <linux/ckrm_tsk.h>
+
+#define TOTAL_NUM_TASKS (131072)       // 128 K
+#define NUMTASKS_DEBUG
+#define NUMTASKS_NAME "numtasks"
+
+typedef struct ckrm_numtasks {
+       struct ckrm_core_class *core;   // the core i am part of...
+       struct ckrm_core_class *parent; // parent of the core above.
+       struct ckrm_shares shares;
+       spinlock_t cnt_lock;    // always grab parent's lock before child's
+       int cnt_guarantee;      // num_tasks guarantee in local units
+       int cnt_unused;         // has to borrow if more than this is needed
+       int cnt_limit;          // no tasks over this limit.
+       atomic_t cnt_cur_alloc; // current alloc from self
+       atomic_t cnt_borrowed;  // borrowed from the parent
+
+       int over_guarantee;     // turn on/off when cur_alloc goes 
+                               // over/under guarantee
+
+       // internally maintained statictics to compare with max numbers
+       int limit_failures;     // # failures as request was over the limit
+       int borrow_sucesses;    // # successful borrows
+       int borrow_failures;    // # borrow failures
+
+       // Maximum the specific statictics has reached.
+       int max_limit_failures;
+       int max_borrow_sucesses;
+       int max_borrow_failures;
+
+       // Total number of specific statistics
+       int tot_limit_failures;
+       int tot_borrow_sucesses;
+       int tot_borrow_failures;
+} ckrm_numtasks_t;
+
+struct ckrm_res_ctlr numtasks_rcbs;
+
+/* Initialize rescls values
+ * May be called on each rcfs unmount or as part of error recovery
+ * to make share values sane.
+ * Does not traverse hierarchy reinitializing children.
+ */
+static void numtasks_res_initcls_one(ckrm_numtasks_t * res)
+{
+       res->shares.my_guarantee = CKRM_SHARE_DONTCARE;
+       res->shares.my_limit = CKRM_SHARE_DONTCARE;
+       res->shares.total_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.max_limit = CKRM_SHARE_DFLT_MAX_LIMIT;
+       res->shares.unused_guarantee = CKRM_SHARE_DFLT_TOTAL_GUARANTEE;
+       res->shares.cur_max_limit = 0;
+
+       res->cnt_guarantee = CKRM_SHARE_DONTCARE;
+       res->cnt_unused = CKRM_SHARE_DONTCARE;
+       res->cnt_limit = CKRM_SHARE_DONTCARE;
+
+       res->over_guarantee = 0;
+
+       res->limit_failures = 0;
+       res->borrow_sucesses = 0;
+       res->borrow_failures = 0;
+
+       res->max_limit_failures = 0;
+       res->max_borrow_sucesses = 0;
+       res->max_borrow_failures = 0;
+
+       res->tot_limit_failures = 0;
+       res->tot_borrow_sucesses = 0;
+       res->tot_borrow_failures = 0;
+
+       atomic_set(&res->cnt_cur_alloc, 0);
+       atomic_set(&res->cnt_borrowed, 0);
+       return;
+}
+
+#if 0
+static void numtasks_res_initcls(void *my_res)
+{
+       ckrm_numtasks_t *res = my_res;
+
+       /* Write a version which propagates values all the way down 
+          and replace rcbs callback with that version */
+
+}
+#endif
+
+static int numtasks_get_ref_local(void *arg, int force)
+{
+       int rc, resid = numtasks_rcbs.resid;
+       ckrm_numtasks_t *res;
+       ckrm_core_class_t *core = arg;
+
+       if ((resid < 0) || (core == NULL))
+               return 1;
+
+       res = ckrm_get_res_class(core, resid, ckrm_numtasks_t);
+       if (res == NULL)
+               return 1;
+
+       atomic_inc(&res->cnt_cur_alloc);
+
+       rc = 1;
+       if (((res->parent) && (res->cnt_unused == CKRM_SHARE_DONTCARE)) ||
+           (atomic_read(&res->cnt_cur_alloc) > res->cnt_unused)) {
+
+               rc = 0;
+               if (!force && (res->cnt_limit != CKRM_SHARE_DONTCARE) &&
+                   (atomic_read(&res->cnt_cur_alloc) > res->cnt_limit)) {
+                       res->limit_failures++;
+                       res->tot_limit_failures++;
+               } else if (res->parent != NULL) {
+                       if ((rc =
+                            numtasks_get_ref_local(res->parent, force)) == 1) {
+                               atomic_inc(&res->cnt_borrowed);
+                               res->borrow_sucesses++;
+                               res->tot_borrow_sucesses++;
+                               res->over_guarantee = 1;
+                       } else {
+                               res->borrow_failures++;
+                               res->tot_borrow_failures++;
+                       }
+               } else {
+                       rc = force;
+               }
+       } else if (res->over_guarantee) {
+               res->over_guarantee = 0;
+
+               if (res->max_limit_failures < res->limit_failures) {
+                       res->max_limit_failures = res->limit_failures;
+               }
+               if (res->max_borrow_sucesses < res->borrow_sucesses) {
+                       res->max_borrow_sucesses = res->borrow_sucesses;
+               }
+               if (res->max_borrow_failures < res->borrow_failures) {
+                       res->max_borrow_failures = res->borrow_failures;
+               }
+               res->limit_failures = 0;
+               res->borrow_sucesses = 0;
+               res->borrow_failures = 0;
+       }
+
+       if (!rc) {
+               atomic_dec(&res->cnt_cur_alloc);
+       }
+       return rc;
+}
+
+static void numtasks_put_ref_local(void *arg)
+{
+       int resid = numtasks_rcbs.resid;
+       ckrm_numtasks_t *res;
+       ckrm_core_class_t *core = arg;
+
+       if ((resid == -1) || (core == NULL)) {
+               return;
+       }
+
+       res = ckrm_get_res_class(core, resid, ckrm_numtasks_t);
+       if (res == NULL)
+               return;
+       if (unlikely(atomic_read(&res->cnt_cur_alloc) == 0)) {
+               printk(KERN_WARNING "numtasks_put_ref: Trying to decrement "
+                                       "counter below 0\n");
+               return;
+       }
+       atomic_dec(&res->cnt_cur_alloc);
+       if (atomic_read(&res->cnt_borrowed) > 0) {
+               atomic_dec(&res->cnt_borrowed);
+               numtasks_put_ref_local(res->parent);
+       }
+       return;
+}
+
+static void *numtasks_res_alloc(struct ckrm_core_class *core,
+                               struct ckrm_core_class *parent)
+{
+       ckrm_numtasks_t *res;
+
+       res = kmalloc(sizeof(ckrm_numtasks_t), GFP_ATOMIC);
+
+       if (res) {
+               memset(res, 0, sizeof(ckrm_numtasks_t));
+               res->core = core;
+               res->parent = parent;
+               numtasks_res_initcls_one(res);
+               res->cnt_lock = SPIN_LOCK_UNLOCKED;
+               if (parent == NULL) {
+                       // I am part of root class. So set the max tasks 
+                       // to available default
+                       res->cnt_guarantee = TOTAL_NUM_TASKS;
+                       res->cnt_unused = TOTAL_NUM_TASKS;
+                       res->cnt_limit = TOTAL_NUM_TASKS;
+               }
+               try_module_get(THIS_MODULE);
+       } else {
+               printk(KERN_ERR
+                      "numtasks_res_alloc: failed GFP_ATOMIC alloc\n");
+       }
+       return res;
+}
+
+/*
+ * No locking of this resource class object necessary as we are not
+ * supposed to be assigned (or used) when/after this function is called.
+ */
+static void numtasks_res_free(void *my_res)
+{
+       ckrm_numtasks_t *res = my_res, *parres, *childres;
+       ckrm_core_class_t *child = NULL;
+       int i, borrowed, maxlimit, resid = numtasks_rcbs.resid;
+
+       if (!res)
+               return;
+
+       // Assuming there will be no children when this function is called
+
+       parres = ckrm_get_res_class(res->parent, resid, ckrm_numtasks_t);
+
+       if (unlikely(atomic_read(&res->cnt_cur_alloc) < 0)) {
+               printk(KERN_WARNING "numtasks_res: counter below 0\n");
+       }
+       if (unlikely(atomic_read(&res->cnt_cur_alloc) > 0 ||
+                               atomic_read(&res->cnt_borrowed) > 0)) {
+               printk(KERN_WARNING "numtasks_res_free: resource still "
+                      "alloc'd %p\n", res);
+               if ((borrowed = atomic_read(&res->cnt_borrowed)) > 0) {
+                       for (i = 0; i < borrowed; i++) {
+                               numtasks_put_ref_local(parres->core);
+                       }
+               }
+       }
+       // return child's limit/guarantee to parent node
+       spin_lock(&parres->cnt_lock);
+       child_guarantee_changed(&parres->shares, res->shares.my_guarantee, 0);
+
+       // run thru parent's children and get the new max_limit of the parent
+       ckrm_lock_hier(parres->core);
+       maxlimit = 0;
+       while ((child = ckrm_get_next_child(parres->core, child)) != NULL) {
+               childres = ckrm_get_res_class(child, resid, ckrm_numtasks_t);
+               if (maxlimit < childres->shares.my_limit) {
+                       maxlimit = childres->shares.my_limit;
+               }
+       }
+       ckrm_unlock_hier(parres->core);
+       if (parres->shares.cur_max_limit < maxlimit) {
+               parres->shares.cur_max_limit = maxlimit;
+       }
+
+       spin_unlock(&parres->cnt_lock);
+       kfree(res);
+       module_put(THIS_MODULE);
+       return;
+}
+
+/*
+ * Recalculate the guarantee and limit in real units... and propagate the
+ * same to children.
+ * Caller is responsible for protecting res and for the integrity of parres
+ */
+static void
+recalc_and_propagate(ckrm_numtasks_t * res, ckrm_numtasks_t * parres)
+{
+       ckrm_core_class_t *child = NULL;
+       ckrm_numtasks_t *childres;
+       int resid = numtasks_rcbs.resid;
+
+       if (parres) {
+               struct ckrm_shares *par = &parres->shares;
+               struct ckrm_shares *self = &res->shares;
+
+               // calculate cnt_guarantee and cnt_limit
+               //
+               if (parres->cnt_guarantee == CKRM_SHARE_DONTCARE) {
+                       res->cnt_guarantee = CKRM_SHARE_DONTCARE;
+               } else if (par->total_guarantee) {
+                       u64 temp = (u64) self->my_guarantee * parres->cnt_guarantee;
+                       do_div(temp, par->total_guarantee);
+                       res->cnt_guarantee = (int) temp;
+               } else {
+                       res->cnt_guarantee = 0;
+               }
+
+               if (parres->cnt_limit == CKRM_SHARE_DONTCARE) {
+                       res->cnt_limit = CKRM_SHARE_DONTCARE;
+               } else if (par->max_limit) {
+                       u64 temp = (u64) self->my_limit * parres->cnt_limit;
+                       do_div(temp, par->max_limit);
+                       res->cnt_limit = (int) temp;
+               } else {
+                       res->cnt_limit = 0;
+               }
+
+               // Calculate unused units
+               if (res->cnt_guarantee == CKRM_SHARE_DONTCARE) {
+                       res->cnt_unused = CKRM_SHARE_DONTCARE;
+               } else if (self->total_guarantee) {
+                       u64 temp = (u64) self->unused_guarantee * res->cnt_guarantee;
+                       do_div(temp, self->total_guarantee);
+                       res->cnt_unused = (int) temp;
+               } else {
+                       res->cnt_unused = 0;
+               }
+       }
+       // propagate to children
+       ckrm_lock_hier(res->core);
+       while ((child = ckrm_get_next_child(res->core, child)) != NULL) {
+               childres = ckrm_get_res_class(child, resid, ckrm_numtasks_t);
+
+               spin_lock(&childres->cnt_lock);
+               recalc_and_propagate(childres, res);
+               spin_unlock(&childres->cnt_lock);
+       }
+       ckrm_unlock_hier(res->core);
+       return;
+}
+
+static int numtasks_set_share_values(void *my_res, struct ckrm_shares *new)
+{
+       ckrm_numtasks_t *parres, *res = my_res;
+       struct ckrm_shares *cur = &res->shares, *par;
+       int rc = -EINVAL, resid = numtasks_rcbs.resid;
+
+       if (!res)
+               return rc;
+
+       if (res->parent) {
+               parres =
+                   ckrm_get_res_class(res->parent, resid, ckrm_numtasks_t);
+               spin_lock(&parres->cnt_lock);
+               spin_lock(&res->cnt_lock);
+               par = &parres->shares;
+       } else {
+               spin_lock(&res->cnt_lock);
+               par = NULL;
+               parres = NULL;
+       }
+
+       rc = set_shares(new, cur, par);
+
+       if ((rc == 0) && parres) {
+               // Calculate parent's unused units
+               if (parres->cnt_guarantee == CKRM_SHARE_DONTCARE) {
+                       parres->cnt_unused = CKRM_SHARE_DONTCARE;
+               } else if (par->total_guarantee) {
+                       u64 temp = (u64) par->unused_guarantee * parres->cnt_guarantee;
+                       do_div(temp, par->total_guarantee);
+                       parres->cnt_unused = (int) temp;
+               } else {
+                       parres->cnt_unused = 0;
+               }
+               recalc_and_propagate(res, parres);
+       }
+       spin_unlock(&res->cnt_lock);
+       if (res->parent) {
+               spin_unlock(&parres->cnt_lock);
+       }
+       return rc;
+}
+
+static int numtasks_get_share_values(void *my_res, struct ckrm_shares *shares)
+{
+       ckrm_numtasks_t *res = my_res;
+
+       if (!res)
+               return -EINVAL;
+       *shares = res->shares;
+       return 0;
+}
+
+static int numtasks_get_stats(void *my_res, struct seq_file *sfile)
+{
+       ckrm_numtasks_t *res = my_res;
+
+       if (!res)
+               return -EINVAL;
+
+       seq_printf(sfile, "Number of tasks resource:\n");
+       seq_printf(sfile, "Total Over limit failures: %d\n",
+                  res->tot_limit_failures);
+       seq_printf(sfile, "Total Over guarantee sucesses: %d\n",
+                  res->tot_borrow_sucesses);
+       seq_printf(sfile, "Total Over guarantee failures: %d\n",
+                  res->tot_borrow_failures);
+
+       seq_printf(sfile, "Maximum Over limit failures: %d\n",
+                  res->max_limit_failures);
+       seq_printf(sfile, "Maximum Over guarantee sucesses: %d\n",
+                  res->max_borrow_sucesses);
+       seq_printf(sfile, "Maximum Over guarantee failures: %d\n",
+                  res->max_borrow_failures);
+#ifdef NUMTASKS_DEBUG
+       seq_printf(sfile,
+                  "cur_alloc %d; borrowed %d; cnt_guar %d; cnt_limit %d "
+                  "cnt_unused %d, unused_guarantee %d, cur_max_limit %d\n",
+                  atomic_read(&res->cnt_cur_alloc),
+                  atomic_read(&res->cnt_borrowed), res->cnt_guarantee,
+                  res->cnt_limit, res->cnt_unused,
+                  res->shares.unused_guarantee,
+                  res->shares.cur_max_limit);
+#endif
+
+       return 0;
+}
+
+static int numtasks_show_config(void *my_res, struct seq_file *sfile)
+{
+       ckrm_numtasks_t *res = my_res;
+
+       if (!res)
+               return -EINVAL;
+
+       seq_printf(sfile, "res=%s,parameter=somevalue\n", NUMTASKS_NAME);
+       return 0;
+}
+
+static int numtasks_set_config(void *my_res, const char *cfgstr)
+{
+       ckrm_numtasks_t *res = my_res;
+
+       if (!res)
+               return -EINVAL;
+       printk(KERN_DEBUG "numtasks config='%s'\n", cfgstr);
+       return 0;
+}
+
+static void numtasks_change_resclass(void *task, void *old, void *new)
+{
+       ckrm_numtasks_t *oldres = old;
+       ckrm_numtasks_t *newres = new;
+
+       if (oldres != (void *)-1) {
+               struct task_struct *tsk = task;
+               if (!oldres) {
+                       struct ckrm_core_class *old_core =
+                           &(tsk->parent->taskclass->core);
+                       oldres =
+                           ckrm_get_res_class(old_core, numtasks_rcbs.resid,
+                                              ckrm_numtasks_t);
+               }
+               numtasks_put_ref_local(oldres->core);
+       }
+       if (newres) {
+               (void)numtasks_get_ref_local(newres->core, 1);
+       }
+}
+
+struct ckrm_res_ctlr numtasks_rcbs = {
+       .res_name = NUMTASKS_NAME,
+       .res_hdepth = 1,
+       .resid = -1,
+       .res_alloc = numtasks_res_alloc,
+       .res_free = numtasks_res_free,
+       .set_share_values = numtasks_set_share_values,
+       .get_share_values = numtasks_get_share_values,
+       .get_stats = numtasks_get_stats,
+       .show_config = numtasks_show_config,
+       .set_config = numtasks_set_config,
+       .change_resclass = numtasks_change_resclass,
+};
+
+int __init init_ckrm_numtasks_res(void)
+{
+       struct ckrm_classtype *clstype;
+       int resid = numtasks_rcbs.resid;
+
+       clstype = ckrm_find_classtype_by_name("taskclass");
+       if (clstype == NULL) {
+               printk(KERN_INFO " Unknown ckrm classtype<taskclass>");
+               return -ENOENT;
+       }
+
+       if (resid == -1) {
+               resid = ckrm_register_res_ctlr(clstype, &numtasks_rcbs);
+               printk(KERN_DEBUG "........init_ckrm_numtasks_res -> %d\n", resid);
+               if (resid != -1) {
+                       ckrm_numtasks_register(numtasks_get_ref_local,
+                                              numtasks_put_ref_local);
+                       numtasks_rcbs.classtype = clstype;
+               }
+       }
+       return 0;
+}
+
+void __exit exit_ckrm_numtasks_res(void)
+{
+       if (numtasks_rcbs.resid != -1) {
+               ckrm_numtasks_register(NULL, NULL);
+       }
+       ckrm_unregister_res_ctlr(&numtasks_rcbs);
+       numtasks_rcbs.resid = -1;
+}
+
+module_init(init_ckrm_numtasks_res)
+    module_exit(exit_ckrm_numtasks_res)
+
+    MODULE_LICENSE("GPL");
diff --git a/kernel/ckrm/ckrm_numtasks_stub.c b/kernel/ckrm/ckrm_numtasks_stub.c
new file mode 100644 (file)
index 0000000..179e6b5
--- /dev/null
@@ -0,0 +1,59 @@
+/* ckrm_tasks_stub.c - Stub file for ckrm_tasks modules
+ *
+ * Copyright (C) Chandra Seetharaman,  IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * 
+ * 16 May 2004: Created
+ * 
+ */
+
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/ckrm_tsk.h>
+
+static spinlock_t stub_lock = SPIN_LOCK_UNLOCKED;
+
+static get_ref_t real_get_ref = NULL;
+static put_ref_t real_put_ref = NULL;
+
+void ckrm_numtasks_register(get_ref_t gr, put_ref_t pr)
+{
+       spin_lock(&stub_lock);
+       real_get_ref = gr;
+       real_put_ref = pr;
+       spin_unlock(&stub_lock);
+}
+
+int numtasks_get_ref(void *arg, int force)
+{
+       int ret = 1;
+       spin_lock(&stub_lock);
+       if (real_get_ref) {
+               ret = (*real_get_ref) (arg, force);
+       }
+       spin_unlock(&stub_lock);
+       return ret;
+}
+
+void numtasks_put_ref(void *arg)
+{
+       spin_lock(&stub_lock);
+       if (real_put_ref) {
+               (*real_put_ref) (arg);
+       }
+       spin_unlock(&stub_lock);
+}
+
+EXPORT_SYMBOL(ckrm_numtasks_register);
+EXPORT_SYMBOL(numtasks_get_ref);
+EXPORT_SYMBOL(numtasks_put_ref);
diff --git a/kernel/ckrm/ckrm_sockc.c b/kernel/ckrm/ckrm_sockc.c
new file mode 100644 (file)
index 0000000..8ccadfa
--- /dev/null
@@ -0,0 +1,576 @@
+/* ckrm_sock.c - Class-based Kernel Resource Management (CKRM)
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003,2004
+ *           (C) Shailabh Nagar,  IBM Corp. 2003
+ *           (C) Chandra Seetharaman,  IBM Corp. 2003
+ *          (C) Vivek Kashyap, IBM Corp. 2004
+ * 
+ * 
+ * Provides kernel API of CKRM for in-kernel,per-resource controllers 
+ * (one each for cpu, memory, io, network) and callbacks for 
+ * classification modules.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 28 Aug 2003
+ *        Created.
+ * 06 Nov 2003
+ *        Made modifications to suit the new RBCE module.
+ * 10 Nov 2003
+ *        Fixed a bug in fork and exit callbacks. Added callbacks_active and
+ *        surrounding logic. Added task paramter for all CE callbacks.
+ * 23 Mar 2004
+ *        moved to referenced counted class objects and correct locking
+ * 12 Apr 2004
+ *        introduced adopted to emerging classtype interface
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <asm/uaccess.h>
+#include <linux/mm.h>
+#include <asm/errno.h>
+#include <linux/string.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/ckrm_rc.h>
+#include <linux/parser.h>
+#include <net/tcp.h>
+
+#include <linux/ckrm_net.h>
+
+struct ckrm_sock_class {
+       struct ckrm_core_class core;
+};
+
+static struct ckrm_sock_class sockclass_dflt_class = {
+};
+
+#define SOCKET_CLASS_TYPE_NAME  "socketclass"
+
+const char *dflt_sockclass_name = SOCKET_CLASS_TYPE_NAME;
+
+static struct ckrm_core_class *sock_alloc_class(struct ckrm_core_class *parent,
+                                               const char *name);
+static int sock_free_class(struct ckrm_core_class *core);
+
+static int sock_forced_reclassify(ckrm_core_class_t * target,
+                                 const char *resname);
+static int sock_show_members(struct ckrm_core_class *core,
+                            struct seq_file *seq);
+static void sock_add_resctrl(struct ckrm_core_class *core, int resid);
+static void sock_reclassify_class(struct ckrm_sock_class *cls);
+
+struct ckrm_classtype CT_sockclass = {
+       .mfidx = 1,
+       .name = SOCKET_CLASS_TYPE_NAME,
+       .typeID = CKRM_CLASSTYPE_SOCKET_CLASS,
+       .maxdepth = 3,
+       .resid_reserved = 0,
+       .max_res_ctlrs = CKRM_MAX_RES_CTLRS,
+       .max_resid = 0,
+       .bit_res_ctlrs = 0L,
+       .res_ctlrs_lock = SPIN_LOCK_UNLOCKED,
+       .classes = LIST_HEAD_INIT(CT_sockclass.classes),
+
+       .default_class = &sockclass_dflt_class.core,
+
+       // private version of functions 
+       .alloc = &sock_alloc_class,
+       .free = &sock_free_class,
+       .show_members = &sock_show_members,
+       .forced_reclassify = &sock_forced_reclassify,
+
+       // use of default functions 
+       .show_shares = &ckrm_class_show_shares,
+       .show_stats = &ckrm_class_show_stats,
+       .show_config = &ckrm_class_show_config,
+       .set_config = &ckrm_class_set_config,
+       .set_shares = &ckrm_class_set_shares,
+       .reset_stats = &ckrm_class_reset_stats,
+
+       // mandatory private version .. no dflt available
+       .add_resctrl = &sock_add_resctrl,
+};
+
+/* helper functions */
+
+void ckrm_ns_hold(struct ckrm_net_struct *ns)
+{
+       atomic_inc(&ns->ns_refcnt);
+       return;
+}
+
+void ckrm_ns_put(struct ckrm_net_struct *ns)
+{
+       if (atomic_dec_and_test(&ns->ns_refcnt))
+               kfree(ns);
+       return;
+}
+
+/*
+ * Change the class of a netstruct 
+ *
+ * Change the task's task class  to "newcls" if the task's current 
+ * class (task->taskclass) is same as given "oldcls", if it is non-NULL.
+ *
+ */
+
+static void
+sock_set_class(struct ckrm_net_struct *ns, struct ckrm_sock_class *newcls,
+              struct ckrm_sock_class *oldcls, enum ckrm_event event)
+{
+       int i;
+       struct ckrm_res_ctlr *rcbs;
+       struct ckrm_classtype *clstype;
+       void *old_res_class, *new_res_class;
+
+       if ((newcls == oldcls) || (newcls == NULL)) {
+               ns->core = (void *)oldcls;
+               return;
+       }
+
+       class_lock(class_core(newcls));
+       ns->core = newcls;
+       list_add(&ns->ckrm_link, &class_core(newcls)->objlist);
+       class_unlock(class_core(newcls));
+
+       clstype = class_isa(newcls);
+       for (i = 0; i < clstype->max_resid; i++) {
+               atomic_inc(&clstype->nr_resusers[i]);
+               old_res_class =
+                   oldcls ? class_core(oldcls)->res_class[i] : NULL;
+               new_res_class =
+                   newcls ? class_core(newcls)->res_class[i] : NULL;
+               rcbs = clstype->res_ctlrs[i];
+               if (rcbs && rcbs->change_resclass
+                   && (old_res_class != new_res_class))
+                       (*rcbs->change_resclass) (ns, old_res_class,
+                                                 new_res_class);
+               atomic_dec(&clstype->nr_resusers[i]);
+       }
+       return;
+}
+
+static void sock_add_resctrl(struct ckrm_core_class *core, int resid)
+{
+       struct ckrm_net_struct *ns;
+       struct ckrm_res_ctlr *rcbs;
+
+       if ((resid < 0) || (resid >= CKRM_MAX_RES_CTLRS)
+           || ((rcbs = core->classtype->res_ctlrs[resid]) == NULL))
+               return;
+
+       class_lock(core);
+       list_for_each_entry(ns, &core->objlist, ckrm_link) {
+               if (rcbs->change_resclass)
+                       (*rcbs->change_resclass) (ns, NULL,
+                                                 core->res_class[resid]);
+       }
+       class_unlock(core);
+}
+
+/**************************************************************************
+ *                   Functions called from classification points          *
+ **************************************************************************/
+
+static void cb_sockclass_listen_start(struct sock *sk)
+{
+       struct ckrm_net_struct *ns = NULL;
+       struct ckrm_sock_class *newcls = NULL;
+       struct ckrm_res_ctlr *rcbs;
+       struct ckrm_classtype *clstype;
+       int i = 0;
+
+       // XXX - TBD ipv6
+       if (sk->sk_family == AF_INET6)
+               return;
+
+       // to store the socket address
+       ns = (struct ckrm_net_struct *)
+           kmalloc(sizeof(struct ckrm_net_struct), GFP_ATOMIC);
+       if (!ns)
+               return;
+
+       memset(ns, 0, sizeof(*ns));
+       INIT_LIST_HEAD(&ns->ckrm_link);
+       ckrm_ns_hold(ns);
+
+       ns->ns_family = sk->sk_family;
+       if (ns->ns_family == AF_INET6)  // IPv6 not supported yet.
+               return;
+
+       ns->ns_daddrv4 = inet_sk(sk)->rcv_saddr;
+       ns->ns_dport = inet_sk(sk)->num;
+
+       ns->ns_pid = current->pid;
+       ns->ns_tgid = current->tgid;
+       ns->ns_tsk = current;
+       ce_protect(&CT_sockclass);
+       CE_CLASSIFY_RET(newcls, &CT_sockclass, CKRM_EVENT_LISTEN_START, ns,
+                       current);
+       ce_release(&CT_sockclass);
+
+       if (newcls == NULL) {
+               newcls = &sockclass_dflt_class;
+               ckrm_core_grab(class_core(newcls));
+       }
+
+       class_lock(class_core(newcls));
+       list_add(&ns->ckrm_link, &class_core(newcls)->objlist);
+       ns->core = newcls;
+       class_unlock(class_core(newcls));
+
+       // the socket is already locked
+       // take a reference on socket on our behalf
+       sock_hold(sk);
+       sk->sk_ns = (void *)ns;
+       ns->ns_sk = sk;
+
+       // modify its shares
+       clstype = class_isa(newcls);
+       for (i = 0; i < clstype->max_resid; i++) {
+               atomic_inc(&clstype->nr_resusers[i]);
+               rcbs = clstype->res_ctlrs[i];
+               if (rcbs && rcbs->change_resclass) {
+                       (*rcbs->change_resclass) ((void *)ns,
+                                                 NULL,
+                                                 class_core(newcls)->
+                                                 res_class[i]);
+               }
+               atomic_dec(&clstype->nr_resusers[i]);
+       }
+       return;
+}
+
+static void cb_sockclass_listen_stop(struct sock *sk)
+{
+       struct ckrm_net_struct *ns = NULL;
+       struct ckrm_sock_class *newcls = NULL;
+
+       // XXX - TBD ipv6
+       if (sk->sk_family == AF_INET6)
+               return;
+
+       ns = (struct ckrm_net_struct *)sk->sk_ns;
+       if (!ns)     // listen_start called before socket_aq was loaded
+               return;
+
+       newcls = ns->core;
+       if (newcls) {
+               class_lock(class_core(newcls));
+               list_del(&ns->ckrm_link);
+               INIT_LIST_HEAD(&ns->ckrm_link);
+               class_unlock(class_core(newcls));
+               ckrm_core_drop(class_core(newcls));
+       }
+       // the socket is already locked
+       sk->sk_ns = NULL;
+       sock_put(sk);
+
+       // Should be the last count and free it
+       ckrm_ns_put(ns);
+       return;
+}
+
+static struct ckrm_event_spec sock_events_callbacks[] = {
+       CKRM_EVENT_SPEC(LISTEN_START, cb_sockclass_listen_start),
+       CKRM_EVENT_SPEC(LISTEN_STOP, cb_sockclass_listen_stop),
+       {-1}
+};
+
+/**************************************************************************
+ *                  Class Object Creation / Destruction
+ **************************************************************************/
+
+static struct ckrm_core_class *sock_alloc_class(struct ckrm_core_class *parent,
+                                               const char *name)
+{
+       struct ckrm_sock_class *sockcls;
+       sockcls = kmalloc(sizeof(struct ckrm_sock_class), GFP_KERNEL);
+       if (sockcls == NULL)
+               return NULL;
+       memset(sockcls, 0, sizeof(struct ckrm_sock_class));
+
+       ckrm_init_core_class(&CT_sockclass, class_core(sockcls), parent, name);
+
+       ce_protect(&CT_sockclass);
+       if (CT_sockclass.ce_cb_active && CT_sockclass.ce_callbacks.class_add)
+               (*CT_sockclass.ce_callbacks.class_add) (name, sockcls,
+                                                       CT_sockclass.typeID);
+       ce_release(&CT_sockclass);
+
+       return class_core(sockcls);
+}
+
+static int sock_free_class(struct ckrm_core_class *core)
+{
+       struct ckrm_sock_class *sockcls;
+
+       if (!ckrm_is_core_valid(core)) {
+               // Invalid core
+               return (-EINVAL);
+       }
+       if (core == core->classtype->default_class) {
+               // reset the name tag
+               core->name = dflt_sockclass_name;
+               return 0;
+       }
+
+       sockcls = class_type(struct ckrm_sock_class, core);
+
+       ce_protect(&CT_sockclass);
+
+       if (CT_sockclass.ce_cb_active && CT_sockclass.ce_callbacks.class_delete)
+               (*CT_sockclass.ce_callbacks.class_delete) (core->name, sockcls,
+                                                          CT_sockclass.typeID);
+
+       sock_reclassify_class(sockcls);
+
+       ce_release(&CT_sockclass);
+
+       ckrm_release_core_class(core);  
+       // Hubertus .... could just drop the class .. error message
+
+       return 0;
+}
+
+static int sock_show_members(struct ckrm_core_class *core, struct seq_file *seq)
+{
+       struct list_head *lh;
+       struct ckrm_net_struct *ns = NULL;
+
+       class_lock(core);
+       list_for_each(lh, &core->objlist) {
+               ns = container_of(lh, struct ckrm_net_struct, ckrm_link);
+               seq_printf(seq, "%d.%d.%d.%d\\%d\n",
+                          NIPQUAD(ns->ns_daddrv4), ns->ns_dport);
+       }
+       class_unlock(core);
+
+       return 0;
+}
+
+static int
+sock_forced_reclassify_ns(struct ckrm_net_struct *tns,
+                         struct ckrm_core_class *core)
+{
+       struct ckrm_net_struct *ns = NULL;
+       struct sock *sk = NULL;
+       struct ckrm_sock_class *oldcls, *newcls;
+       int rc = -EINVAL;
+
+       if (!ckrm_is_core_valid(core)) {
+               return rc;
+       }
+
+       newcls = class_type(struct ckrm_sock_class, core);
+       // lookup the listening sockets
+       // returns with a reference count set on socket
+       if (tns->ns_family == AF_INET6)
+               return -EOPNOTSUPP;
+
+       sk = tcp_v4_lookup_listener(tns->ns_daddrv4, tns->ns_dport, 0);
+       if (!sk) {
+               printk(KERN_INFO "No such listener 0x%x:%d\n",
+                      tns->ns_daddrv4, tns->ns_dport);
+               return rc;
+       }
+       lock_sock(sk);
+       if (!sk->sk_ns) {
+               goto out;
+       }
+       ns = sk->sk_ns;
+       ckrm_ns_hold(ns);
+       if (!capable(CAP_NET_ADMIN) && (ns->ns_tsk->user != current->user)) {
+               ckrm_ns_put(ns);
+               rc = -EPERM;
+               goto out;
+       }
+
+       oldcls = ns->core;
+       if ((oldcls == NULL) || (oldcls == newcls)) {
+               ckrm_ns_put(ns);
+               goto out;
+       }
+       // remove the net_struct from the current class
+       class_lock(class_core(oldcls));
+       list_del(&ns->ckrm_link);
+       INIT_LIST_HEAD(&ns->ckrm_link);
+       ns->core = NULL;
+       class_unlock(class_core(oldcls));
+
+       sock_set_class(ns, newcls, oldcls, CKRM_EVENT_MANUAL);
+       ckrm_ns_put(ns);
+       rc = 0;
+      out:
+       release_sock(sk);
+       sock_put(sk);
+
+       return rc;
+
+}
+
+enum sock_target_token_t {
+       IPV4, IPV6, SOCKC_TARGET_ERR
+};
+
+static match_table_t sock_target_tokens = {
+       {IPV4, "ipv4=%s"},
+       {IPV6, "ipv6=%s"},
+       {SOCKC_TARGET_ERR, NULL},
+};
+
+char *v4toi(char *s, char c, __u32 * v)
+{
+       unsigned int k = 0, n = 0;
+
+       while (*s && (*s != c)) {
+               if (*s == '.') {
+                       n <<= 8;
+                       n |= k;
+                       k = 0;
+               } else
+                       k = k * 10 + *s - '0';
+               s++;
+       }
+
+       n <<= 8;
+       *v = n | k;
+
+       return s;
+}
+
+static int
+sock_forced_reclassify(struct ckrm_core_class *target, const char *options)
+{
+       char *p, *p2;
+       struct ckrm_net_struct ns;
+       __u32 v4addr, tmp;
+
+       if (!options)
+               return -EINVAL;
+
+       if (target == NULL) {
+               unsigned long id = simple_strtol(options,NULL,0);
+               if (!capable(CAP_NET_ADMIN))
+                       return -EPERM;
+               if (id != 0) 
+                       return -EINVAL;
+               printk(KERN_DEBUG "sock_class: reclassify all not net implemented\n");
+               return 0;
+       }
+
+       while ((p = strsep((char **)&options, ",")) != NULL) {
+               substring_t args[MAX_OPT_ARGS];
+               int token;
+
+               if (!*p)
+                       continue;
+               token = match_token(p, sock_target_tokens, args);
+               switch (token) {
+
+               case IPV4:
+
+                       p2 = p;
+                       while (*p2 && (*p2 != '='))
+                               ++p2;
+                       p2++;
+                       p2 = v4toi(p2, '\\', &(v4addr));
+                       ns.ns_daddrv4 = htonl(v4addr);
+                       ns.ns_family = AF_INET;
+                       p2 = v4toi(++p2, ':', &tmp);
+                       ns.ns_dport = (__u16) tmp;
+                       if (*p2)
+                               p2 = v4toi(++p2, '\0', &ns.ns_pid);
+                       sock_forced_reclassify_ns(&ns, target);
+                       break;
+
+               case IPV6:
+                       printk(KERN_INFO "rcfs: IPV6 not supported yet\n");
+                       return -ENOSYS;
+               default:
+                       return -EINVAL;
+               }
+       }
+       return -EINVAL;
+}
+
+/*
+ * Listen_aq reclassification.
+ */
+static void sock_reclassify_class(struct ckrm_sock_class *cls)
+{
+       struct ckrm_net_struct *ns, *tns;
+       struct ckrm_core_class *core = class_core(cls);
+       LIST_HEAD(local_list);
+
+       if (!cls)
+               return;
+
+       if (!ckrm_validate_and_grab_core(core))
+               return;
+
+       class_lock(core);
+       // we have the core refcnt
+       if (list_empty(&core->objlist)) {
+               class_unlock(core);
+               ckrm_core_drop(core);
+               return;
+       }
+
+       INIT_LIST_HEAD(&local_list);
+       list_splice_init(&core->objlist, &local_list);
+       class_unlock(core);
+       ckrm_core_drop(core);
+
+       list_for_each_entry_safe(ns, tns, &local_list, ckrm_link) {
+               ckrm_ns_hold(ns);
+               list_del(&ns->ckrm_link);
+               if (ns->ns_sk) {
+                       lock_sock(ns->ns_sk);
+                       sock_set_class(ns, &sockclass_dflt_class, NULL,
+                                      CKRM_EVENT_MANUAL);
+                       release_sock(ns->ns_sk);
+               }
+               ckrm_ns_put(ns);
+       }
+       return;
+}
+
+void __init ckrm_meta_init_sockclass(void)
+{
+       printk(KERN_DEBUG "...... Initializing ClassType<%s> ........\n",
+              CT_sockclass.name);
+       // intialize the default class
+       ckrm_init_core_class(&CT_sockclass, class_core(&sockclass_dflt_class),
+                            NULL, dflt_sockclass_name);
+
+       // register classtype and initialize default task class
+       ckrm_register_classtype(&CT_sockclass);
+       ckrm_register_event_set(sock_events_callbacks);
+
+       // note registeration of all resource controllers will be done 
+       // later dynamically as these are specified as modules
+}
+
+#if 1
+
+/*****************************************************************************
+ * Debugging Network Classes:  Utility functions
+ *****************************************************************************/
+
+#endif
diff --git a/kernel/ckrm/ckrm_tc.c b/kernel/ckrm/ckrm_tc.c
new file mode 100644 (file)
index 0000000..af95644
--- /dev/null
@@ -0,0 +1,795 @@
+/* ckrm_tc.c - Class-based Kernel Resource Management (CKRM)
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003,2004
+ *           (C) Shailabh Nagar,  IBM Corp. 2003
+ *           (C) Chandra Seetharaman,  IBM Corp. 2003
+ *          (C) Vivek Kashyap, IBM Corp. 2004
+ * 
+ * 
+ * Provides kernel API of CKRM for in-kernel,per-resource controllers 
+ * (one each for cpu, memory, io, network) and callbacks for 
+ * classification modules.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 28 Aug 2003
+ *        Created.
+ * 06 Nov 2003
+ *        Made modifications to suit the new RBCE module.
+ * 10 Nov 2003
+ *        Fixed a bug in fork and exit callbacks. Added callbacks_active and
+ *        surrounding logic. Added task paramter for all CE callbacks.
+ * 23 Mar 2004
+ *        moved to referenced counted class objects and correct locking
+ * 12 Apr 2004
+ *        introduced adopted to emerging classtype interface
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <asm/uaccess.h>
+#include <linux/mm.h>
+#include <asm/errno.h>
+#include <linux/string.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/ckrm_rc.h>
+
+#include <linux/ckrm_tc.h>
+
+#define TC_DEBUG(fmt, args...) do { \
+/* printk("%s: " fmt, __FUNCTION__ , ## args); */ } while (0)
+
+static struct ckrm_task_class taskclass_dflt_class = {
+};
+
+const char *dflt_taskclass_name = TASK_CLASS_TYPE_NAME;
+
+static struct ckrm_core_class *ckrm_alloc_task_class(struct ckrm_core_class
+                                                    *parent, const char *name);
+static int ckrm_free_task_class(struct ckrm_core_class *core);
+
+static int tc_forced_reclassify(ckrm_core_class_t * target,
+                               const char *resname);
+static int tc_show_members(struct ckrm_core_class *core, struct seq_file *seq);
+static void tc_add_resctrl(struct ckrm_core_class *core, int resid);
+
+struct ckrm_classtype CT_taskclass = {
+       .mfidx = TC_MF_IDX,
+       .name = TASK_CLASS_TYPE_NAME,
+       .typeID = CKRM_CLASSTYPE_TASK_CLASS,
+       .maxdepth = 3,          // Hubertus .. just to start 
+       .resid_reserved = 4,    // Hubertus .. reservation
+       .max_res_ctlrs = CKRM_MAX_RES_CTLRS,
+       .max_resid = 0,
+       .bit_res_ctlrs = 0L,
+       .res_ctlrs_lock = SPIN_LOCK_UNLOCKED,
+       .classes = LIST_HEAD_INIT(CT_taskclass.classes),
+
+       .default_class = &taskclass_dflt_class.core,
+
+       // private version of functions 
+       .alloc = &ckrm_alloc_task_class,
+       .free = &ckrm_free_task_class,
+       .show_members = &tc_show_members,
+       .forced_reclassify = &tc_forced_reclassify,
+
+       // use of default functions 
+       .show_shares = &ckrm_class_show_shares,
+       .show_stats = &ckrm_class_show_stats,
+       .show_config = &ckrm_class_show_config,
+       .set_config = &ckrm_class_set_config,
+       .set_shares = &ckrm_class_set_shares,
+       .reset_stats = &ckrm_class_reset_stats,
+
+       // mandatory private version .. no dflt available
+       .add_resctrl = &tc_add_resctrl,
+};
+
+/**************************************************************************
+ *                   Helper Functions                                     *
+ **************************************************************************/
+
+static inline void ckrm_init_task_lock(struct task_struct *tsk)
+{
+       tsk->ckrm_tsklock = SPIN_LOCK_UNLOCKED;
+}
+
+// Hubertus .. following functions should move to ckrm_rc.h
+
+static inline void ckrm_task_lock(struct task_struct *tsk)
+{
+       spin_lock(&tsk->ckrm_tsklock);
+}
+
+static inline void ckrm_task_unlock(struct task_struct *tsk)
+{
+       spin_unlock(&tsk->ckrm_tsklock);
+}
+
+/*
+ * Change the task class of the given task.
+ *
+ * Change the task's task class  to "newcls" if the task's current 
+ * class (task->taskclass) is same as given "oldcls", if it is non-NULL.
+ *
+ * Caller is responsible to make sure the task structure stays put through
+ * this function.
+ *
+ * This function should be called with the following locks NOT held
+ *     - tsk->ckrm_task_lock
+ *     - core->ckrm_lock, if core is NULL then ckrm_dflt_class.ckrm_lock
+ *     - tsk->taskclass->ckrm_lock 
+ * 
+ * Function is also called with a ckrm_core_grab on the new core, hence
+ * it needs to be dropped if no assignment takes place.
+ */
+static void
+ckrm_set_taskclass(struct task_struct *tsk, ckrm_task_class_t * newcls,
+                  ckrm_task_class_t * oldcls, enum ckrm_event event)
+{
+       int i;
+       ckrm_classtype_t *clstype;
+       ckrm_res_ctlr_t *rcbs;
+       ckrm_task_class_t *curcls;
+       void *old_res_class, *new_res_class;
+       int drop_old_cls;
+
+       ckrm_task_lock(tsk);
+       curcls = tsk->taskclass;
+
+       if ((void *)-1 == curcls) {
+               // task is disassociated from ckrm... don't bother it.
+               ckrm_task_unlock(tsk);
+               ckrm_core_drop(class_core(newcls));
+               return;
+       }
+
+       if ((curcls == NULL) && (newcls == (void *)-1)) {
+               // task need to disassociated from ckrm and has no curcls
+               // just disassociate and return.
+               tsk->taskclass = newcls;
+               ckrm_task_unlock(tsk);
+               return;
+       }
+       // check whether compare_and_exchange should
+       if (oldcls && (oldcls != curcls)) {
+               ckrm_task_unlock(tsk);
+               if (newcls) {
+                       /* compensate for previous grab */
+                       TC_DEBUG("(%s:%d): Race-condition caught <%s> %d\n",
+                                tsk->comm, tsk->pid, class_core(newcls)->name,
+                                event);
+                       ckrm_core_drop(class_core(newcls));
+               }
+               return;
+       }
+       // make sure we have a real destination core
+       if (!newcls) {
+               newcls = &taskclass_dflt_class;
+               ckrm_core_grab(class_core(newcls));
+       }
+       // take out of old class 
+       // remember that we need to drop the oldcore
+       if ((drop_old_cls = (curcls != NULL))) {
+               class_lock(class_core(curcls));
+               if (newcls == curcls) {
+                       // we are already in the destination class.
+                       // we still need to drop oldcore
+                       class_unlock(class_core(curcls));
+                       ckrm_task_unlock(tsk);
+                       goto out;
+               }
+               list_del(&tsk->taskclass_link);
+               INIT_LIST_HEAD(&tsk->taskclass_link);
+               tsk->taskclass = NULL;
+               class_unlock(class_core(curcls));
+               if (newcls == (void *)-1) {
+                       tsk->taskclass = newcls;
+                       ckrm_task_unlock(tsk);
+                       // still need to get out of old class
+                       newcls = NULL;
+                       goto rc_handling;
+               }
+       }
+       // put into new class 
+       class_lock(class_core(newcls));
+       tsk->taskclass = newcls;
+       list_add(&tsk->taskclass_link, &class_core(newcls)->objlist);
+       class_unlock(class_core(newcls));
+
+       if (newcls == curcls) {
+               ckrm_task_unlock(tsk);
+               goto out;
+       }
+
+       CE_NOTIFY(&CT_taskclass, event, newcls, tsk);
+
+       ckrm_task_unlock(tsk);
+
+      rc_handling:
+       clstype = &CT_taskclass;
+       if (clstype->bit_res_ctlrs) {   
+               // avoid running through the entire list if non is registered
+               for (i = 0; i < clstype->max_resid; i++) {
+                       if (clstype->res_ctlrs[i] == NULL)
+                               continue;
+                       atomic_inc(&clstype->nr_resusers[i]);
+                       old_res_class =
+                           curcls ? class_core(curcls)->res_class[i] : NULL;
+                       new_res_class =
+                           newcls ? class_core(newcls)->res_class[i] : NULL;
+                       rcbs = clstype->res_ctlrs[i];
+                       if (rcbs && rcbs->change_resclass
+                           && (old_res_class != new_res_class))
+                               (*rcbs->change_resclass) (tsk, old_res_class,
+                                                         new_res_class);
+                       atomic_dec(&clstype->nr_resusers[i]);
+               }
+       }
+
+      out:
+       if (drop_old_cls)
+               ckrm_core_drop(class_core(curcls));
+       return;
+}
+
+// HF SUGGEST: we could macro-tize this for other types 
+// DEF_FUNC_ADD_RESCTRL(funcname,link)
+//          would DEF_FUNC_ADD_RESCTRL(tc_add_resctrl,taskclass_link)
+
+static void tc_add_resctrl(struct ckrm_core_class *core, int resid)
+{
+       struct task_struct *tsk;
+       struct ckrm_res_ctlr *rcbs;
+
+       if ((resid < 0) || (resid >= CKRM_MAX_RES_CTLRS)
+           || ((rcbs = core->classtype->res_ctlrs[resid]) == NULL))
+               return;
+
+       class_lock(core);
+       list_for_each_entry(tsk, &core->objlist, taskclass_link) {
+               if (rcbs->change_resclass)
+                       (*rcbs->change_resclass) (tsk, (void *)-1,
+                                                 core->res_class[resid]);
+       }
+       class_unlock(core);
+}
+
+/**************************************************************************
+ *                   Functions called from classification points          *
+ **************************************************************************/
+
+#define ECB_PRINTK(fmt, args...)                               \
+// do { if (CT_taskclass.ce_regd)                               
+// printk("%s: " fmt, __FUNCTION__ , ## args); } while (0)
+
+#define CE_CLASSIFY_TASK(event, tsk)                                   \
+do {                                                                   \
+       struct ckrm_task_class *newcls = NULL;                          \
+       struct ckrm_task_class *oldcls = tsk->taskclass;                \
+                                                                       \
+       CE_CLASSIFY_RET(newcls,&CT_taskclass,event,tsk);                \
+       if (newcls) {                                                   \
+               /* called synchrously. no need to get task struct */    \
+               ckrm_set_taskclass(tsk, newcls, oldcls, event);         \
+       }                                                               \
+} while (0)
+
+
+#define CE_CLASSIFY_TASK_PROTECT(event, tsk)   \
+do {                                           \
+       ce_protect(&CT_taskclass);              \
+       CE_CLASSIFY_TASK(event,tsk);            \
+       ce_release(&CT_taskclass);              \
+} while (0)
+
+static void cb_taskclass_newtask(struct task_struct *tsk)
+{
+       tsk->taskclass = NULL;
+       INIT_LIST_HEAD(&tsk->taskclass_link);
+}
+
+static void cb_taskclass_fork(struct task_struct *tsk)
+{
+       struct ckrm_task_class *cls = NULL;
+
+       ECB_PRINTK("%p:%d:%s\n", tsk, tsk->pid, tsk->comm);
+
+       ce_protect(&CT_taskclass);
+       CE_CLASSIFY_RET(cls, &CT_taskclass, CKRM_EVENT_FORK, tsk);
+       if (cls == NULL) {
+               ckrm_task_lock(tsk->parent);
+               cls = tsk->parent->taskclass;
+               ckrm_core_grab(class_core(cls));
+               ckrm_task_unlock(tsk->parent);
+       }
+       if (!list_empty(&tsk->taskclass_link))
+               printk(KERN_WARNING "BUG in cb_fork.. tsk (%s:%d> already linked\n",
+                      tsk->comm, tsk->pid);
+
+       ckrm_set_taskclass(tsk, cls, NULL, CKRM_EVENT_FORK);
+       ce_release(&CT_taskclass);
+}
+
+static void cb_taskclass_exit(struct task_struct *tsk)
+{
+       CE_CLASSIFY_NORET(&CT_taskclass, CKRM_EVENT_EXIT, tsk);
+       ckrm_set_taskclass(tsk, (void *)-1, NULL, CKRM_EVENT_EXIT);
+}
+
+static void cb_taskclass_exec(const char *filename)
+{
+       ECB_PRINTK("%p:%d:%s <%s>\n", current, current->pid, current->comm,
+                  filename);
+       CE_CLASSIFY_TASK_PROTECT(CKRM_EVENT_EXEC, current);
+}
+
+static void cb_taskclass_uid(void)
+{
+       ECB_PRINTK("%p:%d:%s\n", current, current->pid, current->comm);
+       CE_CLASSIFY_TASK_PROTECT(CKRM_EVENT_UID, current);
+}
+
+static void cb_taskclass_gid(void)
+{
+       ECB_PRINTK("%p:%d:%s\n", current, current->pid, current->comm);
+       CE_CLASSIFY_TASK_PROTECT(CKRM_EVENT_GID, current);
+}
+
+static void
+cb_taskclass_xid(struct task_struct *tsk)
+{
+       ECB_PRINTK("%p:%d:%s\n",current,current->pid,current->comm);
+       CE_CLASSIFY_TASK_PROTECT(CKRM_EVENT_XID, tsk);
+}
+
+static struct ckrm_event_spec taskclass_events_callbacks[] = {
+       CKRM_EVENT_SPEC(NEWTASK, cb_taskclass_newtask),
+       CKRM_EVENT_SPEC(EXEC, cb_taskclass_exec),
+       CKRM_EVENT_SPEC(FORK, cb_taskclass_fork),
+       CKRM_EVENT_SPEC(EXIT, cb_taskclass_exit),
+       CKRM_EVENT_SPEC(UID, cb_taskclass_uid),
+       CKRM_EVENT_SPEC(GID, cb_taskclass_gid),
+       CKRM_EVENT_SPEC(XID, cb_taskclass_xid),
+       {-1}
+};
+
+/***********************************************************************
+ *
+ * Asynchronous callback functions   (driven by RCFS)
+ * 
+ *    Async functions force a setting of the task structure
+ *    synchronous callbacks are protected against race conditions 
+ *    by using a cmpxchg on the core before setting it.
+ *    Async calls need to be serialized to ensure they can't 
+ *    race against each other 
+ *
+ ***********************************************************************/
+
+DECLARE_MUTEX(async_serializer);       // serialize all async functions
+
+/*
+ * Go through the task list and reclassify all tasks according to the current
+ * classification rules.
+ *
+ * We have the problem that we can not hold any lock (including the 
+ * tasklist_lock) while classifying. Two methods possible
+ *
+ * (a) go through entire pidrange (0..pidmax) and if a task exists at 
+ *     that pid then reclassify it
+ * (b) go several time through task list and build a bitmap for a particular 
+ *     subrange of pid otherwise the memory requirements ight be too much.
+ * 
+ * We use a hybrid by comparing ratio nr_threads/pidmax
+ */
+
+static int ckrm_reclassify_all_tasks(void)
+{
+       extern int pid_max;
+
+       struct task_struct *proc, *thread;
+       int i;
+       int curpidmax = pid_max;
+       int ratio;
+       int use_bitmap;
+
+       /* Check permissions */
+       if ((!capable(CAP_SYS_NICE)) && (!capable(CAP_SYS_RESOURCE))) {
+               return -EPERM;
+       }
+
+       ratio = curpidmax / nr_threads;
+       if (curpidmax <= PID_MAX_DEFAULT) {
+               use_bitmap = 1;
+       } else {
+               use_bitmap = (ratio >= 2);
+       }
+
+       ce_protect(&CT_taskclass);
+
+      retry:
+
+       if (use_bitmap == 0) {
+               // go through it in one walk
+               read_lock(&tasklist_lock);
+               for (i = 0; i < curpidmax; i++) {
+                       if ((thread = find_task_by_pid(i)) == NULL)
+                               continue;
+                       get_task_struct(thread);
+                       read_unlock(&tasklist_lock);
+                       CE_CLASSIFY_TASK(CKRM_EVENT_RECLASSIFY, thread);
+                       put_task_struct(thread);
+                       read_lock(&tasklist_lock);
+               }
+               read_unlock(&tasklist_lock);
+       } else {
+               unsigned long *bitmap;
+               int bitmapsize;
+               int order = 0;
+               int num_loops;
+               int pid, do_next;
+
+               bitmap = (unsigned long *)__get_free_pages(GFP_KERNEL, order);
+               if (bitmap == NULL) {
+                       use_bitmap = 0;
+                       goto retry;
+               }
+
+               bitmapsize = 8 * (1 << (order + PAGE_SHIFT));
+               num_loops = (curpidmax + bitmapsize - 1) / bitmapsize;
+
+               do_next = 1;
+               for (i = 0; i < num_loops && do_next; i++) {
+                       int pid_start = i * bitmapsize;
+                       int pid_end = pid_start + bitmapsize;
+                       int num_found = 0;
+                       int pos;
+
+                       memset(bitmap, 0, bitmapsize / 8);      // start afresh
+                       do_next = 0;
+
+                       read_lock(&tasklist_lock);
+                       do_each_thread(proc, thread) {
+                               pid = thread->pid;
+                               if ((pid < pid_start) || (pid >= pid_end)) {
+                                       if (pid >= pid_end) {
+                                               do_next = 1;
+                                       }
+                                       continue;
+                               }
+                               pid -= pid_start;
+                               set_bit(pid, bitmap);
+                               num_found++;
+                       }
+                       while_each_thread(proc, thread);
+                       read_unlock(&tasklist_lock);
+
+                       if (num_found == 0)
+                               continue;
+
+                       pos = 0;
+                       for (; num_found--;) {
+                               pos = find_next_bit(bitmap, bitmapsize, pos);
+                               pid = pos + pid_start;
+
+                               read_lock(&tasklist_lock);
+                               if ((thread = find_task_by_pid(pid)) != NULL) {
+                                       get_task_struct(thread);
+                                       read_unlock(&tasklist_lock);
+                                       CE_CLASSIFY_TASK(CKRM_EVENT_RECLASSIFY,
+                                                        thread);
+                                       put_task_struct(thread);
+                               } else {
+                                       read_unlock(&tasklist_lock);
+                               }
+                               pos++;
+                       }
+               }
+
+       }
+       ce_release(&CT_taskclass);
+       return 0;
+}
+
+/*
+ * Reclassify all tasks in the given core class.
+ */
+
+static void ckrm_reclassify_class_tasks(struct ckrm_task_class *cls)
+{
+       int ce_regd;
+       struct ckrm_hnode *cnode;
+       struct ckrm_task_class *parcls;
+       int num = 0;
+
+       if (!ckrm_validate_and_grab_core(&cls->core))
+               return;
+
+       down(&async_serializer);        // protect again race condition
+       TC_DEBUG("start %p:%s:%d:%d\n", cls, cls->core.name,
+                atomic_read(&cls->core.refcnt),
+                atomic_read(&cls->core.hnode.parent->refcnt));
+       // If no CE registered for this classtype, following will be needed 
+       // repeatedly;
+       ce_regd = atomic_read(&class_core(cls)->classtype->ce_regd);
+       cnode = &(class_core(cls)->hnode);
+       parcls = class_type(ckrm_task_class_t, cnode->parent);
+
+      next_task:
+       class_lock(class_core(cls));
+       if (!list_empty(&class_core(cls)->objlist)) {
+               struct ckrm_task_class *newcls = NULL;
+               struct task_struct *tsk =
+                   list_entry(class_core(cls)->objlist.next,
+                              struct task_struct, taskclass_link);
+
+               get_task_struct(tsk);
+               class_unlock(class_core(cls));
+
+               if (ce_regd) {
+                       CE_CLASSIFY_RET(newcls, &CT_taskclass,
+                                       CKRM_EVENT_RECLASSIFY, tsk);
+                       if (cls == newcls) {
+                               // don't allow reclassifying to the same class
+                               // as we are in the process of cleaning up 
+                               // this class
+
+                               // compensate CE's grab
+                               ckrm_core_drop(class_core(newcls));     
+                               newcls = NULL;
+                       }
+               }
+               if (newcls == NULL) {
+                       newcls = parcls;
+                       ckrm_core_grab(class_core(newcls));
+               }
+               ckrm_set_taskclass(tsk, newcls, cls, CKRM_EVENT_RECLASSIFY);
+               put_task_struct(tsk);
+               num++;
+               goto next_task;
+       }
+       TC_DEBUG("stop  %p:%s:%d:%d   %d\n", cls, cls->core.name,
+                atomic_read(&cls->core.refcnt),
+                atomic_read(&cls->core.hnode.parent->refcnt), num);
+       class_unlock(class_core(cls));
+       ckrm_core_drop(class_core(cls));
+
+       up(&async_serializer);
+
+       return;
+}
+
+/*
+ * Change the core class of the given task
+ */
+
+int ckrm_forced_reclassify_pid(pid_t pid, struct ckrm_task_class *cls)
+{
+       struct task_struct *tsk;
+
+       if (cls && !ckrm_validate_and_grab_core(class_core(cls)))
+               return -EINVAL;
+
+       read_lock(&tasklist_lock);
+       if ((tsk = find_task_by_pid(pid)) == NULL) {
+               read_unlock(&tasklist_lock);
+               if (cls) 
+                       ckrm_core_drop(class_core(cls));
+               return -EINVAL;
+       }
+       get_task_struct(tsk);
+       read_unlock(&tasklist_lock);
+
+       /* Check permissions */
+       if ((!capable(CAP_SYS_NICE)) &&
+           (!capable(CAP_SYS_RESOURCE)) && (current->user != tsk->user)) {
+               if (cls) 
+                       ckrm_core_drop(class_core(cls));
+               put_task_struct(tsk);
+               return -EPERM;
+       }
+
+       ce_protect(&CT_taskclass);
+       if (cls == NULL)
+               CE_CLASSIFY_TASK(CKRM_EVENT_RECLASSIFY,tsk);
+       else 
+               ckrm_set_taskclass(tsk, cls, NULL, CKRM_EVENT_MANUAL);
+
+       ce_release(&CT_taskclass);
+       put_task_struct(tsk);
+
+       return 0;
+}
+
+static struct ckrm_core_class *ckrm_alloc_task_class(struct ckrm_core_class
+                                                    *parent, const char *name)
+{
+       struct ckrm_task_class *taskcls;
+       taskcls = kmalloc(sizeof(struct ckrm_task_class), GFP_KERNEL);
+       if (taskcls == NULL)
+               return NULL;
+       memset(taskcls, 0, sizeof(struct ckrm_task_class));
+
+       ckrm_init_core_class(&CT_taskclass, class_core(taskcls), parent, name);
+
+       ce_protect(&CT_taskclass);
+       if (CT_taskclass.ce_cb_active && CT_taskclass.ce_callbacks.class_add)
+               (*CT_taskclass.ce_callbacks.class_add) (name, taskcls,
+                                                       CT_taskclass.typeID);
+       ce_release(&CT_taskclass);
+
+       return class_core(taskcls);
+}
+
+static int ckrm_free_task_class(struct ckrm_core_class *core)
+{
+       struct ckrm_task_class *taskcls;
+
+       if (!ckrm_is_core_valid(core)) {
+               // Invalid core
+               return (-EINVAL);
+       }
+       if (core == core->classtype->default_class) {
+               // reset the name tag
+               core->name = dflt_taskclass_name;
+               return 0;
+       }
+
+       TC_DEBUG("%p:%s:%d\n", core, core->name, atomic_read(&core->refcnt));
+
+       taskcls = class_type(struct ckrm_task_class, core);
+
+       ce_protect(&CT_taskclass);
+
+       if (CT_taskclass.ce_cb_active && CT_taskclass.ce_callbacks.class_delete)
+               (*CT_taskclass.ce_callbacks.class_delete) (core->name, taskcls,
+                                                          CT_taskclass.typeID);
+       ckrm_reclassify_class_tasks(taskcls);
+
+       ce_release(&CT_taskclass);
+
+       ckrm_release_core_class(core);  
+       // Hubertus .... could just drop the class .. error message
+       return 0;
+}
+
+void __init ckrm_meta_init_taskclass(void)
+{
+       printk(KERN_DEBUG "...... Initializing ClassType<%s> ........\n",
+              CT_taskclass.name);
+       // intialize the default class
+       ckrm_init_core_class(&CT_taskclass, class_core(&taskclass_dflt_class),
+                            NULL, dflt_taskclass_name);
+
+       // register classtype and initialize default task class
+       ckrm_register_classtype(&CT_taskclass);
+       ckrm_register_event_set(taskclass_events_callbacks);
+
+       // note registeration of all resource controllers will be done 
+       // later dynamically as these are specified as modules
+}
+
+static int tc_show_members(struct ckrm_core_class *core, struct seq_file *seq)
+{
+       struct list_head *lh;
+       struct task_struct *tsk;
+
+       class_lock(core);
+       list_for_each(lh, &core->objlist) {
+               tsk = container_of(lh, struct task_struct, taskclass_link);
+               seq_printf(seq, "%ld\n", (long)tsk->pid);
+       }
+       class_unlock(core);
+
+       return 0;
+}
+
+static int tc_forced_reclassify(struct ckrm_core_class *target, const char *obj)
+{
+       pid_t pid;
+       int rc = -EINVAL;
+
+       pid = (pid_t) simple_strtol(obj, NULL, 0);
+
+       down(&async_serializer);        // protect again race condition with reclassify_class
+       if (pid < 0) {
+               // do we want to treat this as process group .. TBD
+               rc = -EINVAL;
+       } else if (pid == 0) {
+               rc = (target == NULL) ? ckrm_reclassify_all_tasks() : -EINVAL;
+       } else {
+               struct ckrm_task_class *cls = NULL;
+               if (target) 
+                       cls = class_type(ckrm_task_class_t,target);
+               rc = ckrm_forced_reclassify_pid(pid,cls);
+       }
+       up(&async_serializer);
+       return rc;
+}
+
+#if 0
+
+/******************************************************************************
+ * Debugging Task Classes:  Utility functions
+ ******************************************************************************/
+
+void check_tasklist_sanity(struct ckrm_task_class *cls)
+{
+       struct ckrm_core_class *core = class_core(cls);
+       struct list_head *lh1, *lh2;
+       int count = 0;
+
+       if (core) {
+               class_lock(core);
+               if (list_empty(&core->objlist)) {
+                       class_lock(core);
+                       printk(KERN_DEBUG "check_tasklist_sanity: class %s empty list\n",
+                              core->name);
+                       return;
+               }
+               list_for_each_safe(lh1, lh2, &core->objlist) {
+                       struct task_struct *tsk =
+                           container_of(lh1, struct task_struct,
+                                        taskclass_link);
+                       if (count++ > 20000) {
+                               printk(KERN_WARNING "list is CORRUPTED\n");
+                               break;
+                       }
+                       if (tsk->taskclass != cls) {
+                               const char *tclsname;
+                               tclsname = (tsk->taskclass) ? 
+                                       class_core(tsk->taskclass)->name:"NULL";
+                               printk(KERN_WARNING "sanity: task %s:%d has ckrm_core "
+                                      "|%s| but in list |%s|\n", tsk->comm, 
+                                      tsk->pid, tclsname, core->name);
+                       }
+               }
+               class_unlock(core);
+       }
+}
+
+void ckrm_debug_free_task_class(struct ckrm_task_class *tskcls)
+{
+       struct task_struct *proc, *thread;
+       int count = 0;
+
+       printk(KERN_DEBUG "Analyze Error <%s> %d\n",
+              class_core(tskcls)->name,
+              atomic_read(&(class_core(tskcls)->refcnt)));
+
+       read_lock(&tasklist_lock);
+       class_lock(class_core(tskcls));
+       do_each_thread(proc, thread) {
+               count += (tskcls == thread->taskclass);
+               if ((thread->taskclass == tskcls) || (tskcls == NULL)) {
+                       const char *tclsname;
+                       tclsname = (thread->taskclass) ? 
+                               class_core(thread->taskclass)->name :"NULL";
+                       printk(KERN_DEBUG "%d thread=<%s:%d>  -> <%s> <%lx>\n", count,
+                              thread->comm, thread->pid, tclsname,
+                              thread->flags & PF_EXITING);
+               }
+       } while_each_thread(proc, thread);
+       class_unlock(class_core(tskcls));
+       read_unlock(&tasklist_lock);
+
+       printk(KERN_DEBUG "End Analyze Error <%s> %d\n",
+              class_core(tskcls)->name,
+              atomic_read(&(class_core(tskcls)->refcnt)));
+}
+
+#endif
diff --git a/kernel/ckrm/ckrmutils.c b/kernel/ckrm/ckrmutils.c
new file mode 100644 (file)
index 0000000..d54e7b5
--- /dev/null
@@ -0,0 +1,197 @@
+/* ckrmutils.c - Utility functions for CKRM
+ *
+ * Copyright (C) Chandra Seetharaman,  IBM Corp. 2003
+ *           (C) Hubertus Franke    ,  IBM Corp. 2004
+ * 
+ * Provides simple utility functions for the core module, CE and resource
+ * controllers.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ * 
+ * 13 Nov 2003
+ *        Created
+ */
+
+#include <linux/mm.h>
+#include <linux/err.h>
+#include <linux/mount.h>
+#include <linux/module.h>
+#include <linux/ckrm_rc.h>
+
+int get_exe_path_name(struct task_struct *tsk, char *buf, int buflen)
+{
+       struct vm_area_struct *vma;
+       struct vfsmount *mnt;
+       struct mm_struct *mm = get_task_mm(tsk);
+       struct dentry *dentry;
+       char *lname;
+       int rc = 0;
+
+       *buf = '\0';
+       if (!mm) {
+               return -EINVAL;
+       }
+
+       down_read(&mm->mmap_sem);
+       vma = mm->mmap;
+       while (vma) {
+               if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) {
+                       dentry = dget(vma->vm_file->f_dentry);
+                       mnt = mntget(vma->vm_file->f_vfsmnt);
+                       lname = d_path(dentry, mnt, buf, buflen);
+                       if (!IS_ERR(lname)) {
+                               strncpy(buf, lname, strlen(lname) + 1);
+                       } else {
+                               rc = (int)PTR_ERR(lname);
+                       }
+                       mntput(mnt);
+                       dput(dentry);
+                       break;
+               }
+               vma = vma->vm_next;
+       }
+       up_read(&mm->mmap_sem);
+       mmput(mm);
+       return rc;
+}
+
+/*
+ * must be called with cnt_lock of parres held
+ * Caller is responsible for making sure that the new guarantee doesn't
+ * overflow parent's total guarantee.
+ */
+void child_guarantee_changed(struct ckrm_shares *parent, int cur, int new)
+{
+       if (new == cur || !parent) {
+               return;
+       }
+       if (new != CKRM_SHARE_DONTCARE) {
+               parent->unused_guarantee -= new;
+       }
+       if (cur != CKRM_SHARE_DONTCARE) {
+               parent->unused_guarantee += cur;
+       }
+       return;
+}
+
+/*
+ * must be called with cnt_lock of parres held
+ * Caller is responsible for making sure that the new limit is not more 
+ * than parent's max_limit
+ */
+void child_maxlimit_changed(struct ckrm_shares *parent, int new_limit)
+{
+       if (parent && parent->cur_max_limit < new_limit) {
+               parent->cur_max_limit = new_limit;
+       }
+       return;
+}
+
+/*
+ * Caller is responsible for holding any lock to protect the data
+ * structures passed to this function
+ */
+int
+set_shares(struct ckrm_shares *new, struct ckrm_shares *cur,
+          struct ckrm_shares *par)
+{
+       int rc = -EINVAL;
+       int cur_usage_guar = cur->total_guarantee - cur->unused_guarantee;
+       int increase_by = new->my_guarantee - cur->my_guarantee;
+
+       // Check total_guarantee for correctness
+       if (new->total_guarantee <= CKRM_SHARE_DONTCARE) {
+               goto set_share_err;
+       } else if (new->total_guarantee == CKRM_SHARE_UNCHANGED) {
+               ;               // do nothing
+       } else if (cur_usage_guar > new->total_guarantee) {
+               goto set_share_err;
+       }
+       // Check max_limit for correctness
+       if (new->max_limit <= CKRM_SHARE_DONTCARE) {
+               goto set_share_err;
+       } else if (new->max_limit == CKRM_SHARE_UNCHANGED) {
+               ;               // do nothing
+       } else if (cur->cur_max_limit > new->max_limit) {
+               goto set_share_err;
+       }
+       // Check my_guarantee for correctness
+       if (new->my_guarantee == CKRM_SHARE_UNCHANGED) {
+               ;               // do nothing
+       } else if (new->my_guarantee == CKRM_SHARE_DONTCARE) {
+               ;               // do nothing
+       } else if (par && increase_by > par->unused_guarantee) {
+               goto set_share_err;
+       }
+       // Check my_limit for correctness
+       if (new->my_limit == CKRM_SHARE_UNCHANGED) {
+               ;               // do nothing
+       } else if (new->my_limit == CKRM_SHARE_DONTCARE) {
+               ;               // do nothing
+       } else if (par && new->my_limit > par->max_limit) {
+               // I can't get more limit than my parent's limit
+               goto set_share_err;
+
+       }
+       // make sure guarantee is lesser than limit
+       if (new->my_limit == CKRM_SHARE_DONTCARE) {
+               ;               // do nothing
+       } else if (new->my_limit == CKRM_SHARE_UNCHANGED) {
+               if (new->my_guarantee == CKRM_SHARE_DONTCARE) {
+                       ;       // do nothing
+               } else if (new->my_guarantee == CKRM_SHARE_UNCHANGED) {
+                       ;       // do nothing earlier setting would've 
+                               // taken care of it
+               } else if (new->my_guarantee > cur->my_limit) {
+                       goto set_share_err;
+               }
+       } else {                // new->my_limit has a valid value
+               if (new->my_guarantee == CKRM_SHARE_DONTCARE) {
+                       ;       // do nothing
+               } else if (new->my_guarantee == CKRM_SHARE_UNCHANGED) {
+                       if (cur->my_guarantee > new->my_limit) {
+                               goto set_share_err;
+                       }
+               } else if (new->my_guarantee > new->my_limit) {
+                       goto set_share_err;
+               }
+       }
+
+       if (new->my_guarantee != CKRM_SHARE_UNCHANGED) {
+               child_guarantee_changed(par, cur->my_guarantee,
+                                       new->my_guarantee);
+               cur->my_guarantee = new->my_guarantee;
+       }
+
+       if (new->my_limit != CKRM_SHARE_UNCHANGED) {
+               child_maxlimit_changed(par, new->my_limit);
+               cur->my_limit = new->my_limit;
+       }
+
+       if (new->total_guarantee != CKRM_SHARE_UNCHANGED) {
+               cur->unused_guarantee = new->total_guarantee - cur_usage_guar;
+               cur->total_guarantee = new->total_guarantee;
+       }
+
+       if (new->max_limit != CKRM_SHARE_UNCHANGED) {
+               cur->max_limit = new->max_limit;
+       }
+
+       rc = 0;
+      set_share_err:
+       return rc;
+}
+
+EXPORT_SYMBOL(get_exe_path_name);
+EXPORT_SYMBOL(child_guarantee_changed);
+EXPORT_SYMBOL(child_maxlimit_changed);
+EXPORT_SYMBOL(set_shares);
diff --git a/kernel/ckrm/rbce/Makefile b/kernel/ckrm/rbce/Makefile
new file mode 100644 (file)
index 0000000..6355d0b
--- /dev/null
@@ -0,0 +1,13 @@
+#
+# Makefile for CKRM
+#
+
+obj-$(CONFIG_CKRM_RBCE)        += rbce.o 
+rbce-objs := rbcemod.o rbce_fs.o
+obj-$(CONFIG_CKRM_CRBCE) += crbce.o 
+crbce-objs := crbcemod.o rbce_fs.o
+
+CFLAGS_crbcemod.o += -DRBCE_EXTENSION  # compile rbcemod.c into crbce
+CFLAGS_crbcemod.o += -DRBCE_DO_SAMPLE  # disable if sampling not desired
+CFLAGS_crbcemod.o += -DRBCE_DO_DELAY   # disable if delay info not desired
diff --git a/kernel/ckrm/rbce/bitvector.h b/kernel/ckrm/rbce/bitvector.h
new file mode 100644 (file)
index 0000000..098cc23
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ * 
+ * Bitvector package
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 15 Nov 2003
+ *        Created
+ */
+
+#ifndef BITVECTOR_H
+#define BITVECTOR_H
+
+typedef struct {
+       int size;               // maxsize in longs
+       unsigned long bits[0];  // bit vector
+} bitvector_t;
+
+#define BITS_2_LONGS(sz)  (((sz)+BITS_PER_LONG-1)/BITS_PER_LONG)
+#define BITS_2_BYTES(sz)  (((sz)+7)/8)
+
+#if 0
+#define CHECK_VEC(vec) (vec)   /* check against NULL */
+#else
+#define CHECK_VEC(vec) (1)     /* assume no problem */
+#endif
+
+#define CHECK_VEC_VOID(vec)   do { if (!CHECK_VEC(vec)) return; } while(0)
+#define CHECK_VEC_RC(vec, val) \
+do { if (!CHECK_VEC(vec)) return (val); } while(0)
+
+inline static void bitvector_zero(bitvector_t * bitvec)
+{
+       int sz;
+
+       CHECK_VEC_VOID(bitvec);
+       sz = BITS_2_BYTES(bitvec->size);
+       memset(bitvec->bits, 0, sz);
+       return;
+}
+
+inline static unsigned long bitvector_bytes(unsigned long size)
+{
+       return sizeof(bitvector_t) + BITS_2_BYTES(size);
+}
+
+inline static void bitvector_init(bitvector_t * bitvec, unsigned long size)
+{
+       bitvec->size = size;
+       bitvector_zero(bitvec);
+       return;
+}
+
+inline static bitvector_t *bitvector_alloc(unsigned long size)
+{
+       bitvector_t *vec =
+           (bitvector_t *) kmalloc(bitvector_bytes(size), GFP_KERNEL);
+       if (vec) {
+               vec->size = size;
+               bitvector_zero(vec);
+       }
+       return vec;
+}
+
+inline static void bitvector_free(bitvector_t * bitvec)
+{
+       CHECK_VEC_VOID(bitvec);
+       kfree(bitvec);
+       return;
+}
+
+#define def_bitvec_op(name,mod1,op,mod2)                       \
+inline static int name(bitvector_t *res, bitvector_t *op1,     \
+                      bitvector_t *op2)                        \
+{                                                              \
+       unsigned int i, size;                                   \
+                                                               \
+       CHECK_VEC_RC(res, 0);                                   \
+       CHECK_VEC_RC(op1, 0);                                   \
+       CHECK_VEC_RC(op2, 0);                                   \
+       size = res->size;                                       \
+       if (((size != (op1)->size) || (size != (op2)->size))) { \
+               return 0;                                       \
+       }                                                       \
+       size = BITS_2_LONGS(size);                              \
+       for (i = 0; i < size; i++) {                            \
+               (res)->bits[i] = (mod1 (op1)->bits[i]) op       \
+                                       (mod2 (op2)->bits[i]);  \
+       }                                                       \
+       return 1;                                               \
+}
+
+def_bitvec_op(bitvector_or,, |,);
+def_bitvec_op(bitvector_and,, &,);
+def_bitvec_op(bitvector_xor,, ^,);
+def_bitvec_op(bitvector_or_not,, |, ~);
+def_bitvec_op(bitvector_not_or, ~, |,);
+def_bitvec_op(bitvector_and_not,, &, ~);
+def_bitvec_op(bitvector_not_and, ~, &,);
+
+inline static void bitvector_set(int idx, bitvector_t * vec)
+{
+       set_bit(idx, vec->bits);
+       return;
+}
+
+inline static void bitvector_clear(int idx, bitvector_t * vec)
+{
+       clear_bit(idx, vec->bits);
+       return;
+}
+
+inline static int bitvector_test(int idx, bitvector_t * vec)
+{
+       return test_bit(idx, vec->bits);
+}
+
+#ifdef DEBUG
+inline static void bitvector_print(int flag, bitvector_t * vec)
+{
+       unsigned int i;
+       int sz;
+       extern int rbcedebug;
+
+       if ((rbcedebug & flag) == 0) {
+               return;
+       }
+       if (vec == NULL) {
+               printk(KERN_DEBUG "v<0>-NULL\n");
+               return;
+       }
+       printk(KERN_DEBUG "v<%d>-", sz = vec->size);
+       for (i = 0; i < sz; i++) {
+               printk(KERN_DEBUG "%c", test_bit(i, vec->bits) ? '1' : '0');
+       }
+       return;
+}
+#else
+#define bitvector_print(x, y)
+#endif
+
+#endif                         // BITVECTOR_H
diff --git a/kernel/ckrm/rbce/crbce.h b/kernel/ckrm/rbce/crbce.h
new file mode 100644 (file)
index 0000000..c2967d1
--- /dev/null
@@ -0,0 +1,152 @@
+/* 
+ * crbce.h
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ * 
+ * This files contains the type definition of the record 
+ * created by the CRBCE CKRM classification engine
+ * 
+ * Changes
+ *
+ * 2003-11-11   Created                                        by H.Franke
+ * 2003-12-01   Sanitized for Delivery                  by H.Franke
+ *        
+ */
+
+#ifndef CRBCE_RECORDS_H
+#define CRBCE_RECORDS_H
+
+#include <linux/autoconf.h>    
+#include <linux/types.h>           
+#include <linux/ckrm.h>
+#include <linux/ckrm_ce.h>
+
+#define CRBCE_UKCC_NAME   "crbce_ukcc"
+#define CRBCE_UKCC_PATH   "/mnt/relayfs"
+
+#define CRBCE_UKCC_PATH_NAME   CRBCE_UKCC_PATH"/"CRBCE_UKCC_NAME
+
+#define CRBCE_MAX_CLASS_NAME_LEN  256
+
+/****************************************************************
+ * 
+ *  CRBCE EVENT SET is and extension to the standard CKRM_EVENTS
+ *
+ ****************************************************************/
+enum {
+
+       /* we use the standard CKRM_EVENT_<..> 
+        * to identify reclassification cause actions
+        * and extend by additional ones we need
+        */
+
+       /* up event flow */
+
+       CRBCE_REC_EXIT = CKRM_NUM_EVENTS,
+       CRBCE_REC_DATA_DELIMITER,
+       CRBCE_REC_SAMPLE,
+       CRBCE_REC_TASKINFO,
+       CRBCE_REC_SYS_INFO,
+       CRBCE_REC_CLASS_INFO,
+       CRBCE_REC_KERNEL_CMD_DONE,
+       CRBCE_REC_UKCC_FULL,
+
+       /* down command issueance */
+       CRBCE_REC_KERNEL_CMD,
+
+       CRBCE_NUM_EVENTS
+};
+
+struct task_sample_info {
+       uint32_t cpu_running;
+       uint32_t cpu_waiting;
+       uint32_t io_delayed;
+       uint32_t memio_delayed;
+};
+
+/*********************************************
+ *          KERNEL -> USER  records          *
+ *********************************************/
+
+/* we have records with either a time stamp or not */
+struct crbce_hdr {
+       int type;
+       pid_t pid;
+};
+
+struct crbce_hdr_ts {
+       int type;
+       pid_t pid;
+       uint32_t jiffies;
+       uint64_t cls;
+};
+
+/* individual records */
+
+struct crbce_rec_fork {
+       struct crbce_hdr_ts hdr;
+       pid_t ppid;
+};
+
+struct crbce_rec_data_delim {
+       struct crbce_hdr_ts hdr;
+       int is_stop;            /* 0 start, 1 stop */
+};
+
+struct crbce_rec_task_data {
+       struct crbce_hdr_ts hdr;
+       struct task_sample_info sample;
+       struct task_delay_info delay;
+};
+
+struct crbce_ukcc_full {
+       struct crbce_hdr_ts hdr;
+};
+
+struct crbce_class_info {
+       struct crbce_hdr_ts hdr;
+       int action;
+       int namelen;
+       char name[CRBCE_MAX_CLASS_NAME_LEN];
+};
+
+/*********************************************
+ *           USER -> KERNEL records          *
+ *********************************************/
+
+enum crbce_kernel_cmd {
+       CRBCE_CMD_START,
+       CRBCE_CMD_STOP,
+       CRBCE_CMD_SET_TIMER,
+       CRBCE_CMD_SEND_DATA,
+};
+
+struct crbce_command {
+       int type;               /* we need this for the K->U reflection */
+       int cmd;
+       uint32_t len;   /* added in the kernel for reflection */
+};
+
+#define set_cmd_hdr(rec,tok) \
+((rec).hdr.type=CRBCE_REC_KERNEL_CMD,(rec).hdr.cmd=(tok))
+
+struct crbce_cmd_done {
+       struct crbce_command hdr;
+       int rc;
+};
+
+struct crbce_cmd {
+       struct crbce_command hdr;
+};
+
+struct crbce_cmd_send_data {
+       struct crbce_command hdr;
+       int delta_mode;
+};
+
+struct crbce_cmd_settimer {
+       struct crbce_command hdr;
+       uint32_t interval;      /* in msec .. 0 means stop */
+};
+
+#endif
diff --git a/kernel/ckrm/rbce/crbcemod.c b/kernel/ckrm/rbce/crbcemod.c
new file mode 100644 (file)
index 0000000..3492049
--- /dev/null
@@ -0,0 +1,2 @@
+/* Easiest way to transmit a symbolic link as a patch */
+#include "rbcemod.c"
diff --git a/kernel/ckrm/rbce/info.h b/kernel/ckrm/rbce/info.h
new file mode 100644 (file)
index 0000000..7263b22
--- /dev/null
@@ -0,0 +1,52 @@
+static char *info =
+    "1. Magic files\n"
+    "\t|--rbce_info - read only file detailing how to setup and use RBCE.\n\n"
+    "\t|--rbce_state - determines whether RBCE is currently active"
+       " or inactive.\n"
+    "\tWriting 1 (0) activates (deactivates) the CE. Reading the file\n"
+    "\treturns the current state.\n\n"
+    "\t|--rbce_tag - set tag of the given pid, syntax - \"pid tag\"\n\n"
+    "2. Rules subdirectory: Each rule of the RBCE is represented by a file in\n"
+    "/rcfs/ce/rules.\n\n"
+    "Following are the different attr/value pairs that can be specified.\n\n"
+    "Note: attr/value pairs must be separated by commas(,) with no space"
+    "between them\n\n"
+    "\t<*id> <OP> number      where   <OP>={>,<,=,!}\n"
+    "\t<*id>={uid,euid,gid,egid}\n\n"
+    "\tcmd=\"string\" // basename of the command\n\n"
+    "\tpath=\"/path/to/string\" // full pathname of the command\n\n"
+    "\targs=\"string\" // argv[1] - argv[argc] of command\n\n"
+    "\ttag=\"string\" // application tag of the task\n\n"
+    "\t[+,-]depend=rule_filename\n"
+    "\t\t\t// used to chain a rule's terms with existing rules\n"
+    "\t\t\t// to avoid respecifying the latter's rule terms.\n"
+    "\t\t\t// A rule's dependent rules are evaluated before \n"
+    "\t\t\t// its rule terms get evaluated.\n"
+    "\t\t\t//\n"
+    "\t\t\t// An optional + or - can precede the depend keyword.\n"
+    "\t\t\t// +depend adds a dependent rule to the tail of the\n"
+    "\t\t\t// current chain, -depend removes an existing \n"
+    "\t\t\t// dependent rule\n\n"
+    "\torder=number // order in which this rule is executed relative to\n"
+    "\t\t\t// other independent rules.\n"
+    "\t\t\t// rule with order 1 is checked first and so on.\n"
+    "\t\t\t// As soon as a rule matches, the class of that rule\n"
+    "\t\t\t// is returned to Core. So, order really matters.\n"
+    "\t\t\t// If no order is specified by the user, the next\n"
+    "\t\t\t// highest available order number is assigned to\n"
+    "\t\t\t// the rule.\n\n"
+    "\tclass=\"/rcfs/.../classname\" // target class of this rule.\n"
+    "\t\t\t// /rcfs all by itself indicates the\n"
+    "\t\t\t// systemwide default class\n\n"
+    "\tstate=number // 1 or 0, provides the ability to deactivate a\n"
+    "\t\t\t// specific rule, if needed.\n\n"
+    "\tipv4=\"string\"  // ipv4 address in dotted decimal and port\n"
+    "\t\t\t// e.g. \"127.0.0.1\\80\"\n"
+    "\t\t\t// e.g. \"*\\80\" for CE to match any address\n"
+    "\t\t\t// used in socket accept queue classes\n\n"
+    "\tipv6=\"string\" // ipv6 address in hex and port\n"
+    "\t\t\t// e.g. \"fe80::4567\\80\"\n"
+    "\t\t\t// e.g. \"*\\80\" for CE to match any address \n"
+    "\t\t\t// used in socket accept queue classes\n\n"
+    "\texample:\n"
+    "\techo \"uid=100,euid<200,class=/rcfs\" > /rcfs/ce/rules/rule1\n";
diff --git a/kernel/ckrm/rbce/rbce.h b/kernel/ckrm/rbce/rbce.h
new file mode 100644 (file)
index 0000000..a3af72f
--- /dev/null
@@ -0,0 +1,122 @@
+/* Rule-based Classification Engine (RBCE) module
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ * 
+ * Module for loading of classification policies and providing
+ * a user API for Class-based Kernel Resource Management (CKRM)
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * 25 Mar 2004
+ *        Integrate RBCE and CRBE into a single module
+ */
+
+#ifndef RBCE_H
+#define RBCE_H
+
+// data types defined in main rbcemod.c 
+struct rbce_private_data;
+struct rbce_class;
+struct ckrm_core_class;
+
+#ifndef RBCE_EXTENSION
+
+/****************************************************************************
+ *
+ *   RBCE STANDALONE VERSION, NO CHOICE FOR DATA COLLECTION
+ *
+ ****************************************************************************/
+
+#ifdef RBCE_SHOW_INCL
+#warning " ... RBCE .."
+#endif
+
+#define RBCE_MOD_DESCR "Rule Based Classification Engine Module for CKRM"
+#define RBCE_MOD_NAME  "rbce"
+
+/* extension to private data: NONE */
+struct rbce_ext_private_data {
+       /* empty data */
+};
+static inline void init_ext_private_data(struct rbce_private_data *dst)
+{
+}
+
+/* sending notification to user: NONE */
+
+static void notify_class_action(struct rbce_class *cls, int action)
+{
+}
+static inline void send_fork_notification(struct task_struct *tsk,
+                                         struct ckrm_core_class *cls)
+{
+}
+static inline void send_exit_notification(struct task_struct *tsk)
+{
+}
+static inline void send_manual_notification(struct task_struct *tsk)
+{
+}
+
+/* extension initialization and destruction at module init and exit */
+static inline int init_rbce_ext_pre(void)
+{
+       return 0;
+}
+static inline int init_rbce_ext_post(void)
+{
+       return 0;
+}
+static inline void exit_rbce_ext(void)
+{
+}
+
+#else
+
+/***************************************************************************
+ *
+ *   RBCE with User Level Notification
+ *
+ ***************************************************************************/
+
+#ifdef RBCE_SHOW_INCL
+#warning " ... CRBCE .."
+#ifdef RBCE_DO_SAMPLE
+#warning " ... CRBCE doing sampling ..."
+#endif
+#ifdef RBCE_DO_DELAY
+#warning " ... CRBCE doing delay ..."
+#endif
+#endif
+
+#define RBCE_MOD_DESCR         "Rule Based Classification Engine Module" \
+                       "with Data Sampling/Delivery for CKRM"
+#define RBCE_MOD_NAME  "crbce"
+
+#include "crbce.h"
+
+struct rbce_ext_private_data {
+       struct task_sample_info sample;
+};
+
+static void notify_class_action(struct rbce_class *cls, int action);
+#if 0
+static void send_fork_notification(struct task_struct *tsk,
+                                  struct ckrm_core_class *cls);
+static void send_exit_notification(struct task_struct *tsk);
+static void send_manual_notification(struct task_struct *tsk);
+#endif
+
+#endif
+
+#endif                         // RBCE_H
diff --git a/kernel/ckrm/rbce/rbce_fs.c b/kernel/ckrm/rbce/rbce_fs.c
new file mode 100644 (file)
index 0000000..187e7cd
--- /dev/null
@@ -0,0 +1,490 @@
+/* RCFS API for Rule-based Classification Engine (RBCE) and
+ * Consolidated RBCE module code (combined)
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ *           (C) Vivek Kashyap, IBM Corp. 2004 
+ * 
+ * Module for loading of classification policies and providing
+ * a user API for Class-based Kernel Resource Management (CKRM)
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/ctype.h>
+#include <linux/module.h>
+#include <linux/seq_file.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+#include <linux/string.h>
+#include <linux/smp_lock.h>
+#include <linux/mount.h>
+#include <linux/backing-dev.h>
+#include <asm/uaccess.h>
+#include <linux/rcfs.h>
+
+extern int rbce_enabled;
+extern void get_rule(const char *, char *);
+extern int rule_exists(const char *);
+extern int change_rule(const char *, char *);
+extern int delete_rule(const char *);
+//extern int reclassify_pid(int);
+extern int set_tasktag(int, char *);
+extern int rename_rule(const char *, const char *);
+
+extern int rcfs_register_engine(rbce_eng_callback_t * rcbs);
+extern int rcfs_unregister_engine(rbce_eng_callback_t * rcbs);
+extern int rcfs_mkroot(struct rcfs_magf *, int, struct dentry **);
+extern int rcfs_rmroot(struct dentry *);
+
+static int rbce_unlink(struct inode *, struct dentry *);
+
+#include "info.h"
+static ssize_t
+rbce_write(struct file *file, const char __user * buf,
+          size_t len, loff_t * ppos)
+{
+       char *line, *ptr;
+       int rc = 0, pid;
+
+       line = (char *)kmalloc(len + 1, GFP_KERNEL);
+       if (!line) {
+               return -ENOMEM;
+       }
+       if (copy_from_user(line, buf, len)) {
+               kfree(line);
+               return -EFAULT;
+       }
+       line[len] = '\0';
+       ptr = line + strlen(line) - 1;
+       if (*ptr == '\n') {
+               *ptr = '\0';
+       }
+       if (!strcmp(file->f_dentry->d_name.name, "rbce_tag")) {
+               pid = simple_strtol(line, &ptr, 0);
+               rc = set_tasktag(pid, ptr + 1); // expected syntax "pid tag"
+       } else if (!strcmp(file->f_dentry->d_name.name, "rbce_state")) {
+               rbce_enabled = line[0] - '0';
+       } else if (!strcmp(file->f_dentry->d_name.name, "rbce_info")) {
+               len = -EPERM;
+       } else {
+               rc = change_rule(file->f_dentry->d_name.name, line);
+       }
+       if (rc) {
+               len = rc;
+       }
+       // printk("kernel read |%s|\n", line);
+       // printk("kernel read-2 |%s|\n", line+1000);
+       // printk prints only 1024 bytes once :)
+       //
+       kfree(line);
+       return len;
+}
+
+static int rbce_show(struct seq_file *seq, void *offset)
+{
+       struct file *file = (struct file *)seq->private;
+       char result[256];
+
+       memset(result, 0, 256);
+       if (!strcmp(file->f_dentry->d_name.name, "rbce_tag")) {
+               return -EPERM;
+       }
+       if (!strcmp(file->f_dentry->d_name.name, "rbce_state")) {
+               seq_printf(seq, "%d\n", rbce_enabled);
+               return 0;
+       }
+       if (!strcmp(file->f_dentry->d_name.name, "rbce_info")) {
+               seq_printf(seq, info);
+               return 0;
+       }
+
+       get_rule(file->f_dentry->d_name.name, result);
+       seq_printf(seq, "%s\n", result);
+       return 0;
+}
+
+static int rbce_open(struct inode *inode, struct file *file)
+{
+       //printk("mnt_mountpoint %s\n", 
+       //              file->f_vfsmnt->mnt_mountpoint->d_name.name);
+       //printk("mnt_root %s\n", file->f_vfsmnt->mnt_root->d_name.name);
+       return single_open(file, rbce_show, file);
+}
+
+static int rbce_close(struct inode *ino, struct file *file)
+{
+       const char *name = file->f_dentry->d_name.name;
+
+       if (strcmp(name, "rbce_state") &&
+           strcmp(name, "rbce_tag") && strcmp(name, "rbce_info")) {
+
+               if (!rule_exists(name)) {
+                       // need more stuff to happen in the vfs layer
+                       rbce_unlink(file->f_dentry->d_parent->d_inode,
+                                   file->f_dentry);
+               }
+       }
+       return single_release(ino, file);
+}
+
+#define RCFS_MAGIC 0x4feedbac
+
+static struct file_operations rbce_file_operations;
+static struct inode_operations rbce_file_inode_operations;
+static struct inode_operations rbce_dir_inode_operations;
+
+static struct inode *rbce_get_inode(struct inode *dir, int mode, dev_t dev)
+{
+       struct inode *inode = new_inode(dir->i_sb);
+
+       if (inode) {
+               inode->i_mode = mode;
+               inode->i_uid = current->fsuid;
+               inode->i_gid = current->fsgid;
+               inode->i_blksize = PAGE_CACHE_SIZE;
+               inode->i_blocks = 0;
+               inode->i_mapping->a_ops = dir->i_mapping->a_ops;
+               inode->i_mapping->backing_dev_info =
+                   dir->i_mapping->backing_dev_info;
+               inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+               switch (mode & S_IFMT) {
+               default:
+                       init_special_inode(inode, mode, dev);
+                       break;
+               case S_IFREG:
+                       /* Treat as default assignment */
+                       inode->i_op = &rbce_file_inode_operations;
+                       inode->i_fop = &rbce_file_operations;
+                       break;
+               case S_IFDIR:
+                       inode->i_op = &rbce_dir_inode_operations;
+                       inode->i_fop = &simple_dir_operations;
+
+                       /* directory inodes start off with i_nlink == 2 
+                          (for "." entry) */
+                       inode->i_nlink++;
+                       break;
+               }
+       }
+       return inode;
+}
+
+/*
+ * File creation. Allocate an inode, and we're done..
+ */
+/* SMP-safe */
+static int
+rbce_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
+{
+       struct inode *inode = rbce_get_inode(dir, mode, dev);
+       int error = -ENOSPC;
+
+       if (inode) {
+               if (dir->i_mode & S_ISGID) {
+                       inode->i_gid = dir->i_gid;
+                       if (S_ISDIR(mode))
+                               inode->i_mode |= S_ISGID;
+               }
+               d_instantiate(dentry, inode);
+               dget(dentry);   /* Extra count - pin the dentry in core */
+               error = 0;
+
+       }
+       return error;
+}
+
+static int rbce_unlink(struct inode *dir, struct dentry *dentry)
+{
+       struct inode *inode = dentry->d_inode;
+       int rc;
+
+       rc = delete_rule(dentry->d_name.name);
+       if (rc == 0) {
+               if (dir) {
+                       dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+               }
+               inode->i_ctime = CURRENT_TIME;
+               inode->i_nlink--;
+               dput(dentry);
+       }
+       return rc;
+}
+
+static int
+rbce_rename(struct inode *old_dir, struct dentry *old_dentry,
+           struct inode *new_dir, struct dentry *new_dentry)
+{
+       int rc;
+       struct inode *inode = old_dentry->d_inode;
+       struct dentry *old_d = list_entry(old_dir->i_dentry.next,
+                                         struct dentry, d_alias);
+       struct dentry *new_d = list_entry(new_dir->i_dentry.next,
+                                         struct dentry, d_alias);
+
+       // cannot rename any directory
+       if (S_ISDIR(old_dentry->d_inode->i_mode)) {
+               return -EINVAL;
+       }
+       // cannot rename anything under /ce
+       if (!strcmp(old_d->d_name.name, "ce")) {
+               return -EINVAL;
+       }
+       // cannot move anything to /ce
+       if (!strcmp(new_d->d_name.name, "ce")) {
+               return -EINVAL;
+       }
+
+       rc = rename_rule(old_dentry->d_name.name, new_dentry->d_name.name);
+
+       if (!rc) {
+               old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
+                   new_dir->i_mtime = inode->i_ctime = CURRENT_TIME;
+       }
+       return rc;
+}
+
+// CE allows only the rules directory to be created
+int rbce_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+       int retval = -EINVAL;
+
+       struct dentry *pd =
+           list_entry(dir->i_dentry.next, struct dentry, d_alias);
+
+       // Allow only /rcfs/ce and ce/rules
+       if ((!strcmp(pd->d_name.name, "ce") &&
+            !strcmp(dentry->d_name.name, "rules")) ||
+           (!strcmp(pd->d_name.name, "/") &&
+            !strcmp(dentry->d_name.name, "ce"))) {
+
+               if (!strcmp(dentry->d_name.name, "ce")) {
+                       try_module_get(THIS_MODULE);
+               }
+               retval = rbce_mknod(dir, dentry, mode | S_IFDIR, 0);
+               if (!retval) {
+                       dir->i_nlink++;
+               }
+       }
+
+       return retval;
+}
+
+// CE doesn't allow deletion of directory
+int rbce_rmdir(struct inode *dir, struct dentry *dentry)
+{
+       int rc;
+       // printk("removal of directory %s prohibited\n", dentry->d_name.name);
+       rc = simple_rmdir(dir, dentry);
+
+       if (!rc && !strcmp(dentry->d_name.name, "ce")) {
+               module_put(THIS_MODULE);
+       }
+       return rc;
+}
+
+static int
+rbce_create(struct inode *dir, struct dentry *dentry,
+           int mode, struct nameidata *nd)
+{
+       struct dentry *pd =
+           list_entry(dir->i_dentry.next, struct dentry, d_alias);
+
+       // Under /ce only "rbce_state", "rbce_tag" and "rbce_info" are allowed
+       if (!strcmp(pd->d_name.name, "ce")) {
+               if (strcmp(dentry->d_name.name, "rbce_state") &&
+                   strcmp(dentry->d_name.name, "rbce_tag") &&
+                   strcmp(dentry->d_name.name, "rbce_info")) {
+                       return -EINVAL;
+               }
+       }
+
+       return rbce_mknod(dir, dentry, mode | S_IFREG, 0);
+}
+
+static int rbce_link(struct dentry *old_d, struct inode *dir, struct dentry *d)
+{
+       return -EINVAL;
+}
+
+static int
+rbce_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
+{
+       return -EINVAL;
+}
+
+/******************************* Magic files  ********************/
+
+#define RBCE_NR_MAGF 5
+struct rcfs_magf rbce_magf_files[RBCE_NR_MAGF] = {
+       {
+        .name = "ce",
+        .mode = RCFS_DEFAULT_DIR_MODE,
+        .i_op = &rbce_dir_inode_operations,
+        },
+       {
+        .name = "rbce_tag",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_fop = &rbce_file_operations,
+        },
+       {
+        .name = "rbce_info",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_fop = &rbce_file_operations,
+        },
+       {
+        .name = "rbce_state",
+        .mode = RCFS_DEFAULT_FILE_MODE,
+        .i_fop = &rbce_file_operations,
+        },
+       {
+        .name = "rules",
+        .mode = (RCFS_DEFAULT_DIR_MODE | S_IWUSR),
+        .i_fop = &simple_dir_operations,
+        .i_op = &rbce_dir_inode_operations,
+        }
+};
+
+static struct dentry *ce_root_dentry;
+
+int rbce_create_magic(void)
+{
+       int rc;
+
+       // Make root dentry
+       rc = rcfs_mkroot(rbce_magf_files, RBCE_NR_MAGF, &ce_root_dentry);
+       if ((!ce_root_dentry) || rc)
+               return rc;
+
+       // Create magic files
+       if ((rc = rcfs_create_magic(ce_root_dentry, &rbce_magf_files[1],
+                                   RBCE_NR_MAGF - 1))) {
+               printk(KERN_ERR "Failed to create c/rbce magic files."
+                      " Deleting c/rbce root\n");
+               rcfs_rmroot(ce_root_dentry);
+               return rc;
+       }
+
+       return rc;
+}
+
+int rbce_clear_magic(void)
+{
+       int rc = 0;
+       if (ce_root_dentry)
+               rc = rcfs_rmroot(ce_root_dentry);
+       return rc;
+}
+
+/******************************* File ops ********************/
+
+static struct file_operations rbce_file_operations = {
+       .owner = THIS_MODULE,
+       .open = rbce_open,
+       .llseek = seq_lseek,
+       .read = seq_read,
+       .write = rbce_write,
+       .release = rbce_close,
+};
+
+static struct inode_operations rbce_file_inode_operations = {
+       .getattr = simple_getattr,
+};
+
+static struct inode_operations rbce_dir_inode_operations = {
+       .create = rbce_create,
+       .lookup = simple_lookup,
+       .link = rbce_link,
+       .unlink = rbce_unlink,
+       .symlink = rbce_symlink,
+       .mkdir = rbce_mkdir,
+       .rmdir = rbce_rmdir,
+       .mknod = rbce_mknod,
+       .rename = rbce_rename,
+       .getattr = simple_getattr,
+};
+
+#if 0
+static void rbce_put_super(struct super_block *sb)
+{
+       module_put(THIS_MODULE);
+       printk(KERN_DEBUG "rbce_put_super called\n");
+}
+
+static struct super_operations rbce_ops = {
+       .statfs = simple_statfs,
+       .drop_inode = generic_delete_inode,
+       .put_super = rbce_put_super,
+};
+
+static int rbce_fill_super(struct super_block *sb, void *data, int silent)
+{
+       struct inode *inode;
+       struct dentry *root;
+
+       sb->s_blocksize = PAGE_CACHE_SIZE;
+       sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+       sb->s_magic = RCFS_MAGIC;
+       sb->s_op = &rbce_ops;
+       inode = rbce_get_inode(sb, S_IFDIR | 0755, 0);
+       if (!inode)
+               return -ENOMEM;
+
+       root = d_alloc_root(inode);
+       if (!root) {
+               iput(inode);
+               return -ENOMEM;
+       }
+       sb->s_root = root;
+
+       return 0;
+}
+
+static struct super_block *rbce_get_sb(struct file_system_type *fs_type,
+                                      int flags, const char *dev_name,
+                                      void *data)
+{
+       struct super_block *sb =
+           get_sb_nodev(fs_type, flags, data, rbce_fill_super);
+       if (sb) {
+               try_module_get(THIS_MODULE);
+       }
+       return sb;
+}
+
+static struct file_system_type rbce_fs_type = {
+       .name = "rbce",
+       .get_sb = rbce_get_sb,
+       .kill_sb = kill_litter_super,
+};
+
+static int
+__init init_rbce_fs(void)
+{
+       return register_filesystem(&rbce_fs_type);
+}
+
+static void
+__exit exit_rbce_fs(void)
+{
+       unregister_filesystem(&rbce_fs_type);
+}
+
+module_init(init_rbce_fs)
+    module_exit(exit_rbce_fs)
+    MODULE_LICENSE("GPL");
+#endif
diff --git a/kernel/ckrm/rbce/rbcemod.c b/kernel/ckrm/rbce/rbcemod.c
new file mode 100644 (file)
index 0000000..e0df4d1
--- /dev/null
@@ -0,0 +1,2602 @@
+/* Rule-based Classification Engine (RBCE) and
+ * Consolidated RBCE module code (combined)
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ *           (C) Vivek Kashyap, IBM Corp. 2004 
+ * 
+ * Module for loading of classification policies and providing
+ * a user API for Class-based Kernel Resource Management (CKRM)
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+/* Changes
+ *
+ * 28 Aug 2003
+ *        Created. First cut with much scope for cleanup !
+ * 07 Nov 2003
+ *        Made modifications to suit the new RBCE module.
+ *        Made modifications to address sampling and delivery
+ * 16 Mar 2004
+ *        Integrated changes from original RBCE module
+ * 25 Mar 2004
+ *        Merged RBCE and CRBCE into common code base
+ * 29 Mar 2004
+ *       Incorporated listen call back and IPv4 match support
+ * 23 Apr 2004
+ *        Added Multi-Classtype Support
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/mm.h>
+#include <linux/mount.h>
+#include <linux/proc_fs.h>
+#include <linux/limits.h>
+#include <linux/pid.h>
+#include <linux/sysctl.h>
+
+#include <linux/ckrm_rc.h>
+#include <linux/ckrm_ce.h>
+#include <linux/ckrm_net.h>
+#include "bitvector.h"
+#include <linux/rbce.h>
+
+#define DEBUG
+
+MODULE_DESCRIPTION(RBCE_MOD_DESCR);
+MODULE_AUTHOR("Hubertus Franke, Chandra Seetharaman (IBM)");
+MODULE_LICENSE("GPL");
+
+static char modname[] = RBCE_MOD_NAME;
+
+/* ==================== typedef, global variables etc., ==================== */
+struct named_obj_hdr {
+       struct list_head link;
+       int referenced;
+       char *name;
+};
+
+#define GET_REF(x) ((x)->obj.referenced)
+#define INC_REF(x) (GET_REF(x)++)
+#define DEC_REF(x) (--GET_REF(x))
+struct rbce_class {
+       struct named_obj_hdr obj;
+       int classtype;
+       void *classobj;
+};
+
+typedef enum {
+       RBCE_RULE_CMD_PATH = 1, // full qualified path
+       RBCE_RULE_CMD,          // basename of the command
+       RBCE_RULE_ARGS,         // arguments of the command
+       RBCE_RULE_REAL_UID,     // task's real uid
+       RBCE_RULE_REAL_GID,     // task's real gid
+       RBCE_RULE_EFFECTIVE_UID,        // task's effective uid
+       RBCE_RULE_EFFECTIVE_GID,        // task's effective gid
+       RBCE_RULE_APP_TAG,      // task's application tag
+       RBCE_RULE_IPV4,         // IP address of listen(), ipv4 format
+       RBCE_RULE_IPV6,         // IP address of listen(), ipv6 format
+       RBCE_RULE_XID,          // VSERVER 
+       RBCE_RULE_DEP_RULE,     // dependent rule; must be the first term
+       RBCE_RULE_INVALID,      // invalid, for filler
+       RBCE_RULE_INVALID2,     // invalid, for filler
+} rbce_rule_op_t;
+
+typedef enum {
+       RBCE_EQUAL = 1,
+       RBCE_NOT,
+       RBCE_LESS_THAN,
+       RBCE_GREATER_THAN,
+} rbce_operator_t;
+
+struct rbce_rule_term {
+       rbce_rule_op_t op;
+       rbce_operator_t operator;
+       union {
+               char *string;   // path, cmd, arg, tag, ipv4 and ipv6
+               long id;        // uid, gid, euid, egid
+               struct rbce_rule *deprule;
+       } u;
+};
+
+struct rbce_rule {
+       struct named_obj_hdr obj;
+       struct rbce_class *target_class;
+       int classtype;
+       int num_terms;
+       int *terms;     // vector of indices into the global term vector
+       int index;      // index of this rule into the global term vector
+       int termflag;   // which term ids would require a recalculation
+       int do_opt;     // do we have to consider this rule during optimize
+       char *strtab;   // string table to store the strings of all terms
+       int order;      // order of execution of this rule
+       int state;      // RBCE_RULE_ENABLED/RBCE_RULE_DISABLED
+};
+
+// rules states
+#define RBCE_RULE_DISABLED 0
+#define RBCE_RULE_ENABLED  1
+
+///
+// Data structures and macros used for optimization
+#define RBCE_TERM_CMD   (0)
+#define RBCE_TERM_UID   (1)
+#define RBCE_TERM_GID   (2)
+#define RBCE_TERM_TAG   (3)
+#define RBCE_TERM_IPV4  (4)
+#define RBCE_TERM_IPV6  (5)
+#define RBCE_TERM_XID   (6)
+
+#define NUM_TERM_MASK_VECTOR  (7)     // must be one more the last RBCE_TERM_...
+
+// Rule flags. 1 bit for each type of rule term
+#define RBCE_TERMFLAG_CMD   (1 << RBCE_TERM_CMD)
+#define RBCE_TERMFLAG_UID   (1 << RBCE_TERM_UID)
+#define RBCE_TERMFLAG_GID   (1 << RBCE_TERM_GID)
+#define RBCE_TERMFLAG_TAG   (1 << RBCE_TERM_TAG)
+#define RBCE_TERMFLAG_IPV4  (1 << RBCE_TERM_IPV4)
+#define RBCE_TERMFLAG_IPV6  (1 << RBCE_TERM_IPV6)
+#define RBCE_TERMFLAG_XID   (1 << RBCE_TERM_XID)
+#define RBCE_TERMFLAG_ALL (RBCE_TERMFLAG_CMD | RBCE_TERMFLAG_UID |                     \
+                          RBCE_TERMFLAG_GID | RBCE_TERMFLAG_TAG | RBCE_TERMFLAG_XID |  \
+                          RBCE_TERMFLAG_IPV4 | RBCE_TERMFLAG_IPV6)
+
+int termop_2_vecidx[RBCE_RULE_INVALID] = {
+       [RBCE_RULE_CMD_PATH] = RBCE_TERM_CMD,
+       [RBCE_RULE_CMD] = RBCE_TERM_CMD,
+       [RBCE_RULE_ARGS] = RBCE_TERM_CMD,
+       [RBCE_RULE_REAL_UID] = RBCE_TERM_UID,
+       [RBCE_RULE_REAL_GID] = RBCE_TERM_GID,
+       [RBCE_RULE_EFFECTIVE_UID] = RBCE_TERM_UID,
+       [RBCE_RULE_EFFECTIVE_GID] = RBCE_TERM_GID,
+       [RBCE_RULE_XID] = RBCE_TERM_XID,
+       [RBCE_RULE_APP_TAG] = RBCE_TERM_TAG,
+       [RBCE_RULE_IPV4] = RBCE_TERM_IPV4,
+       [RBCE_RULE_IPV6] = RBCE_TERM_IPV6,
+       [RBCE_RULE_DEP_RULE] = -1
+};
+
+#define TERMOP_2_TERMFLAG(x)   (1 << termop_2_vecidx[x])
+#define TERM_2_TERMFLAG(x)             (1 << x)
+
+#define POLICY_INC_NUMTERMS    (BITS_PER_LONG) // No. of terms added at a time
+#define POLICY_ACTION_NEW_VERSION      0x01    // Force reallocation
+#define POLICY_ACTION_REDO_ALL         0x02    // Recompute all rule flags
+#define POLICY_ACTION_PACK_TERMS       0x04    // Time to pack the terms
+
+const int use_persistent_state = 1;
+
+struct ckrm_eng_callback ckrm_ecbs;
+
+// Term vector state
+//
+static int gl_bitmap_version, gl_action, gl_num_terms;
+static int gl_allocated, gl_released;
+struct rbce_rule_term *gl_terms;
+bitvector_t *gl_mask_vecs[NUM_TERM_MASK_VECTOR];
+
+extern int errno;
+static void optimize_policy(void);
+
+#ifndef CKRM_MAX_CLASSTYPES
+#define CKRM_MAX_CLASSTYPES 32
+#endif
+
+struct list_head rules_list[CKRM_MAX_CLASSTYPES];
+LIST_HEAD(class_list);         // List of classes used
+
+static int gl_num_rules;
+static int gl_rules_version;
+int rbce_enabled = 1;
+static rwlock_t global_rwlock = RW_LOCK_UNLOCKED;
+       /*
+        * One lock to protect them all !!!
+        * Additions, deletions to rules must
+        * happen with this lock being held in write mode.
+        * Access(read/write) to any of the data structures must happen 
+        * with this lock held in read mode.
+        * Since, rule related changes do not happen very often it is ok to
+        * have single rwlock.
+        */
+
+/*
+ * data structure rbce_private_data holds the bit vector 'eval' which 
+ * specifies if rules and terms of rules are evaluated against the task
+ * and if they were evaluated, bit vector 'true' holds the result of that
+ * evaluation.
+ *
+ * This data structure is maintained in a task, and the bitvectors are
+ * updated only when needed.
+ *
+ * Each rule and each term of a rule has a corresponding bit in the vector.
+ *
+ */
+struct rbce_private_data {
+       struct rbce_ext_private_data ext_data;
+       int evaluate;           // whether to evaluate rules or not ?
+       int rules_version;      // whether to evaluate rules or not ?
+       char *app_tag;
+       unsigned long bitmap_version;
+       bitvector_t *eval;
+       bitvector_t *true;
+       char data[0];           // eval points to this variable size data array
+};
+
+#define RBCE_DATA(tsk) ((struct rbce_private_data*)((tsk)->ce_data))
+#define RBCE_DATAP(tsk) ((tsk)->ce_data)
+
+/* ======================= DEBUG  Functions ========================= */
+
+#ifdef DEBUG
+
+int rbcedebug = 0x00;
+
+#define DBG_CLASSIFY_RES     ( 0x01 )
+#define DBG_CLASSIFY_DETAILS ( 0x02 )
+#define DBG_OPTIMIZATION     ( 0x04 )
+#define DBG_SHOW_RESCTL      ( 0x08 )
+#define DBG_CLASS            ( 0x10 )
+#define DBG_RULE             ( 0x20 )
+#define DBG_POLICY           ( 0x40 )
+
+#define DPRINTK(x, y...)   if (rbcedebug & (x)) printk(KERN_DEBUG y)
+       // debugging selectively enabled through /proc/sys/debug/rbce
+
+static void print_context_vectors(void)
+{
+       int i;
+
+       if ((rbcedebug & DBG_OPTIMIZATION) == 0) {
+               return;
+       }
+       for (i = 0; i < NUM_TERM_MASK_VECTOR; i++) {
+               printk(KERN_DEBUG "%d: ", i);
+               bitvector_print(DBG_OPTIMIZATION, gl_mask_vecs[i]);
+               printk(KERN_DEBUG "\n");
+       }
+}
+#else
+
+#define DPRINTK(x, y...)
+#define print_context_vectors(x)
+#endif
+
+/* ====================== VSERVER support ========================== */
+#define CONFIG_VSERVER
+#ifdef CONFIG_VSERVER 
+#include <linux/vs_base.h>
+#else
+typedef unsigned int xid_t;
+#define vx_task_xid(t) (0)
+#endif 
+
+/* ======================= Helper Functions ========================= */
+
+#include "token.c"
+
+static struct ckrm_core_class *rbce_classify(struct task_struct *,
+                                            struct ckrm_net_struct *,
+                                            unsigned long, int classtype);
+
+static inline struct rbce_rule *find_rule_name(const char *name)
+{
+       struct named_obj_hdr *pos;
+       int i;
+
+       for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
+               list_for_each_entry(pos, &rules_list[i], link) {
+                       if (!strcmp(pos->name, name)) {
+                               return ((struct rbce_rule *)pos);
+                       }
+               }
+       }
+       return NULL;
+}
+
+static inline struct rbce_class *find_class_name(const char *name)
+{
+       struct named_obj_hdr *pos;
+
+       list_for_each_entry(pos, &class_list, link) {
+               if (!strcmp(pos->name, name))
+                       return (struct rbce_class *)pos;
+       }
+       return NULL;
+}
+
+/*
+ * Insert the given rule at the specified order
+ *             order = -1 ==> insert at the tail.
+ *
+ * Caller must hold global_rwlock in write mode.
+ */
+static int insert_rule(struct rbce_rule *rule, int order)
+{
+#define ORDER_COUNTER_INCR 10
+       static int order_counter;
+       int old_counter;
+       struct list_head *head = &rules_list[rule->classtype];
+       struct list_head *insert = head;
+       struct rbce_rule *tmp;
+
+       if (gl_num_rules == 0) {
+               order_counter = 0;
+       }
+
+       switch (order) {
+       case -1:
+               rule->order = order_counter;
+               // FIXME: order_counter overflow/wraparound!!
+               order_counter += ORDER_COUNTER_INCR;
+               break;
+       default:
+               old_counter = order_counter;
+               if (order_counter < order) {
+                       order_counter = order;
+               }
+               rule->order = order;
+               order_counter += ORDER_COUNTER_INCR;
+               list_for_each_entry(tmp, head, obj.link) {
+                       if (rule->order == tmp->order) {
+                               order_counter = old_counter;
+                               return -EEXIST;
+                       }
+                       if (rule->order < tmp->order) {
+                               insert = &tmp->obj.link;
+                               break;
+                       }
+               }
+       }
+       list_add_tail(&rule->obj.link, insert);
+       // protect the module from removed when any rule is
+       // defined
+       try_module_get(THIS_MODULE);
+       gl_num_rules++;
+       gl_rules_version++;
+       return 0;
+}
+
+/*
+ * Remove the rule and reinsert at the specified order.
+ *
+ * Caller must hold global_rwlock in write mode.
+ */
+static int reinsert_rule(struct rbce_rule *rule, int order)
+{
+       list_del(&rule->obj.link);
+       gl_num_rules--;
+       gl_rules_version++;
+       module_put(THIS_MODULE);
+       return insert_rule(rule, order);
+}
+
+/*
+ * Get a refernece to the class, create one if it doesn't exist
+ *
+ * Caller need to hold global_rwlock in write mode.
+ * __GFP_WAIT
+ */
+
+static struct rbce_class *create_rbce_class(const char *classname,
+                                           int classtype, void *classobj)
+{
+       struct rbce_class *cls;
+
+       if (classtype >= CKRM_MAX_CLASSTYPES) {
+               printk(KERN_ERR
+                      "ckrm_classobj returned %d as classtype which cannot "
+                      " be handled by RBCE\n", classtype);
+               return NULL;
+       }
+
+       cls = kmalloc(sizeof(struct rbce_class), GFP_ATOMIC);
+       if (!cls) {
+               return NULL;
+       }
+       cls->obj.name = kmalloc(strlen(classname) + 1, GFP_ATOMIC);
+       if (cls->obj.name) {
+               GET_REF(cls) = 1;
+               cls->classobj = classobj;
+               strcpy(cls->obj.name, classname);
+               list_add_tail(&cls->obj.link, &class_list);
+               cls->classtype = classtype;
+       } else {
+               kfree(cls);
+               cls = NULL;
+       }
+       return cls;
+}
+
+static struct rbce_class *get_class(char *classname, int *classtype)
+{
+       struct rbce_class *cls;
+       void *classobj;
+
+       if (!classname) {
+               return NULL;
+       }
+       cls = find_class_name(classname);
+       if (cls) {
+               if (cls->classobj) {
+                       INC_REF(cls);
+                       *classtype = cls->classtype;
+                       return cls;
+               }
+               return NULL;
+       }
+       classobj = ckrm_classobj(classname, classtype);
+       if (!classobj) {
+               return NULL;
+       }
+
+       return create_rbce_class(classname, *classtype, classobj);
+}
+
+/*
+ * Drop a refernece to the class, create one if it doesn't exist
+ *
+ * Caller need to hold global_rwlock in write mode.
+ */
+static void put_class(struct rbce_class *cls)
+{
+       if (cls) {
+               if (DEC_REF(cls) <= 0) {
+                       list_del(&cls->obj.link);
+                       kfree(cls->obj.name);
+                       kfree(cls);
+               }
+       }
+       return;
+}
+
+/*
+ * Callback from core when a class is added
+ */
+
+#ifdef RBCE_EXTENSION
+static void rbce_class_addcb(const char *classname, void *clsobj, int classtype)
+{
+       struct rbce_class *cls;
+
+       write_lock(&global_rwlock);
+       cls = find_class_name((char *)classname);
+       if (cls) {
+               cls->classobj = clsobj;
+       } else {
+               cls = create_rbce_class(classname, classtype, clsobj);
+       }
+       if (cls)
+               notify_class_action(cls, 1);
+       write_unlock(&global_rwlock);
+       return;
+}
+#endif
+
+/*
+ * Callback from core when a class is deleted.
+ */
+static void
+rbce_class_deletecb(const char *classname, void *classobj, int classtype)
+{
+       static struct rbce_class *cls;
+       struct named_obj_hdr *pos;
+       struct rbce_rule *rule;
+
+       write_lock(&global_rwlock);
+       cls = find_class_name(classname);
+       if (cls) {
+               if (cls->classobj != classobj) {
+                       printk(KERN_ERR "rbce: class %s changed identity\n",
+                              classname);
+               }
+               notify_class_action(cls, 0);
+               cls->classobj = NULL;
+               list_for_each_entry(pos, &rules_list[cls->classtype], link) {
+                       rule = (struct rbce_rule *)pos;
+                       if (rule->target_class) {
+                               if (!strcmp
+                                   (rule->target_class->obj.name, classname)) {
+                                       put_class(cls);
+                                       rule->target_class = NULL;
+                                       rule->classtype = -1;
+                               }
+                       }
+               }
+               if ((cls = find_class_name(classname)) != NULL) {
+                       printk(KERN_ERR
+                              "rbce ERROR: class %s exists in rbce after "
+                              "removal in core\n", classname);
+               }
+       }
+       write_unlock(&global_rwlock);
+       return;
+}
+
+/*
+ * Allocate an index in the global term vector
+ * On success, returns the index. On failure returns -errno.
+ * Caller must hold the global_rwlock in write mode as global data is
+ * written onto.
+ */
+static int alloc_term_index(void)
+{
+       int size = gl_allocated;
+
+       if (gl_num_terms >= size) {
+               int i;
+               struct rbce_rule_term *oldv, *newv;
+               int newsize = size + POLICY_INC_NUMTERMS;
+
+               oldv = gl_terms;
+               newv =
+                   kmalloc(newsize * sizeof(struct rbce_rule_term),
+                           GFP_ATOMIC);
+               if (!newv) {
+                       return -ENOMEM;
+               }
+               memcpy(newv, oldv, size * sizeof(struct rbce_rule_term));
+               for (i = size; i < newsize; i++) {
+                       newv[i].op = -1;
+               }
+               gl_terms = newv;
+               gl_allocated = newsize;
+               kfree(oldv);
+
+               gl_action |= POLICY_ACTION_NEW_VERSION;
+               DPRINTK(DBG_OPTIMIZATION,
+                       "alloc_term_index: Expanding size from %d to %d\n",
+                       size, newsize);
+       }
+       return gl_num_terms++;
+}
+
+/*
+ * Release an index in the global term vector
+ *
+ * Caller must hold the global_rwlock in write mode as the global data
+ * is written onto.
+ */
+static void release_term_index(int idx)
+{
+       if ((idx < 0) || (idx > gl_num_terms))
+               return;
+
+       gl_terms[idx].op = -1;
+       gl_released++;
+       if ((gl_released > POLICY_INC_NUMTERMS) &&
+           (gl_allocated >
+            (gl_num_terms - gl_released + POLICY_INC_NUMTERMS))) {
+               gl_action |= POLICY_ACTION_PACK_TERMS;
+       }
+       return;
+}
+
+/*
+ * Release the indices, string memory, and terms associated with the given
+ * rule.
+ *
+ * Caller should be holding global_rwlock
+ */
+static void __release_rule(struct rbce_rule *rule)
+{
+       int i, *terms = rule->terms;
+
+       // remove memory and references from other rules
+       for (i = rule->num_terms; --i >= 0;) {
+               struct rbce_rule_term *term = &gl_terms[terms[i]];
+
+               if (term->op == RBCE_RULE_DEP_RULE) {
+                       DEC_REF(term->u.deprule);
+               }
+               release_term_index(terms[i]);
+       }
+       rule->num_terms = 0;
+       if (rule->strtab) {
+               kfree(rule->strtab);
+               rule->strtab = NULL;
+       }
+       if (rule->terms) {
+               kfree(rule->terms);
+               rule->terms = NULL;
+       }
+       return;
+}
+
+/*
+ * delete the given rule and all memory associated with it.
+ *
+ * Caller is responsible for protecting the global data
+ */
+static inline int __delete_rule(struct rbce_rule *rule)
+{
+       // make sure we are not referenced by other rules
+       if (GET_REF(rule)) {
+               return -EBUSY;
+       }
+       __release_rule(rule);
+       put_class(rule->target_class);
+       release_term_index(rule->index);
+       list_del(&rule->obj.link);
+       gl_num_rules--;
+       gl_rules_version++;
+       module_put(THIS_MODULE);
+       kfree(rule->obj.name);
+       kfree(rule);
+       return 0;
+}
+
+/*
+ * Optimize the rule evaluation logic
+ *
+ * Caller must hold global_rwlock in write mode.
+ */
+static void optimize_policy(void)
+{
+       int i, ii;
+       struct rbce_rule *rule;
+       struct rbce_rule_term *terms;
+       int num_terms;
+       int bsize;
+       bitvector_t **mask_vecs;
+       int pack_terms = 0;
+       int redoall;
+
+       /*
+        * Due to dynamic rule addition/deletion of rules the term
+        * vector can get sparse. As a result the bitvectors grow as we don't
+        * reuse returned indices. If it becomes sparse enough we pack them
+        * closer.
+        */
+
+       pack_terms = (gl_action & POLICY_ACTION_PACK_TERMS);
+       DPRINTK(DBG_OPTIMIZATION,
+               "----- Optimize Policy ----- act=%x pt=%d (a=%d n=%d r=%d)\n",
+               gl_action, pack_terms, gl_allocated, gl_num_terms, gl_released);
+
+       if (pack_terms) {
+               int nsz = ALIGN((gl_num_terms - gl_released),
+                               POLICY_INC_NUMTERMS);
+               int newidx = 0;
+               struct rbce_rule_term *newterms;
+
+               terms = gl_terms;
+               newterms =
+                   kmalloc(nsz * sizeof(struct rbce_rule_term), GFP_ATOMIC);
+               if (newterms) {
+                       for (ii = 0; ii < CKRM_MAX_CLASSTYPES; ii++) {
+                               // FIXME: check only for task class types
+                               list_for_each_entry_reverse(rule,
+                                                           &rules_list[ii],
+                                                           obj.link) {
+                                       rule->index = newidx++;
+                                       for (i = rule->num_terms; --i >= 0;) {
+                                               int idx = rule->terms[i];
+                                               newterms[newidx] = terms[idx];
+                                               rule->terms[i] = newidx++;
+                                       }
+                               }
+                       }
+                       kfree(terms);
+                       gl_allocated = nsz;
+                       gl_released = 0;
+                       gl_num_terms = newidx;
+                       gl_terms = newterms;
+
+                       gl_action &= ~POLICY_ACTION_PACK_TERMS;
+                       gl_action |= POLICY_ACTION_NEW_VERSION;
+               }
+       }
+
+       num_terms = gl_num_terms;
+       bsize = gl_allocated / 8 + sizeof(bitvector_t);
+       mask_vecs = gl_mask_vecs;
+       terms = gl_terms;
+
+       if (gl_action & POLICY_ACTION_NEW_VERSION) {
+               /* allocate new mask vectors */
+               char *temp = kmalloc(NUM_TERM_MASK_VECTOR * bsize, GFP_ATOMIC);
+
+               DPRINTK(DBG_OPTIMIZATION,
+                       "------ allocmasks act=%x -------  ver=%d\n", gl_action,
+                       gl_bitmap_version);
+               if (!temp) {
+                       return;
+               }
+               if (mask_vecs[0]) {// index 0 has the alloc returned address
+                       kfree(mask_vecs[0]);
+               }
+               for (i = 0; i < NUM_TERM_MASK_VECTOR; i++) {
+                       mask_vecs[i] = (bitvector_t *) (temp + i * bsize);
+                       bitvector_init(mask_vecs[i], gl_allocated);
+               }
+               gl_action &= ~POLICY_ACTION_NEW_VERSION;
+               gl_action |= POLICY_ACTION_REDO_ALL;
+               gl_bitmap_version++;
+       }
+
+       /* We do two things here at once
+        * 1) recompute the rulemask for each required rule
+        *      we guarantee proper dependency order during creation time and
+        *      by reversely running through this list. 
+        * 2) recompute the mask for each term and rule, if required
+        */
+
+       redoall = gl_action & POLICY_ACTION_REDO_ALL;
+       gl_action &= ~POLICY_ACTION_REDO_ALL;
+
+       DPRINTK(DBG_OPTIMIZATION, "------- run act=%x --------  redoall=%d\n",
+               gl_action, redoall);
+       for (ii = 0; ii < CKRM_MAX_CLASSTYPES; ii++) {
+               // FIXME: check only for task class types
+               list_for_each_entry_reverse(rule, &rules_list[ii], obj.link) {
+                       unsigned long termflag;
+
+                       if (!redoall && !rule->do_opt)
+                               continue;
+                       termflag = 0;
+                       for (i = rule->num_terms; --i >= 0;) {
+                               int j, idx = rule->terms[i];
+                               struct rbce_rule_term *term = &terms[idx];
+                               int vecidx = termop_2_vecidx[term->op];
+                               
+                               if (vecidx == -1) {
+                                       termflag |= term->u.deprule->termflag;
+                                       /* mark this term belonging to all 
+                                          contexts of deprule */
+                                       for (j = 0; j < NUM_TERM_MASK_VECTOR;
+                                            j++) {
+                                               if (term->u.deprule->termflag 
+                                                   & (1 << j)) {
+                                                       bitvector_set(idx,
+                                                                     mask_vecs
+                                                                     [j]);
+                                               }
+                                       }
+                               } else {
+                                       termflag |= TERM_2_TERMFLAG(vecidx);
+                                       /* mark this term belonging to 
+                                          a particular context */
+                                       bitvector_set(idx, mask_vecs[vecidx]);
+                               }
+                       }
+                       for (i = 0; i < NUM_TERM_MASK_VECTOR; i++) {
+                               if (termflag & (1 << i)) {
+                                       bitvector_set(rule->index,
+                                                     mask_vecs[i]);
+                               }
+                       }
+                       rule->termflag = termflag;
+                       rule->do_opt = 0;
+                       DPRINTK(DBG_OPTIMIZATION, "r-%s: %x %d\n",
+                               rule->obj.name, rule->termflag, rule->index);
+               }
+       }
+       print_context_vectors();
+       return;
+}
+
+/* ======================= Rule related Functions ========================= */
+
+/*
+ * Caller need to hold global_rwlock in write mode.
+ */
+static int
+fill_rule(struct rbce_rule *newrule, struct rbce_rule_term *terms, int nterms)
+{
+       char *class, *strtab;
+       int i, j, order, state, real_nterms, index;
+       int strtablen, rc = 0, counter;
+       struct rbce_rule_term *term = NULL;
+       struct rbce_class *targetcls = NULL;
+       struct rbce_rule *deprule;
+
+       if (!newrule) {
+               return -EINVAL;
+       }
+       // Digest filled terms.
+       real_nterms = 0;
+       strtab = class = NULL;
+       strtablen = 0;
+       state = -1;
+       order = -1;
+       index = -1;
+       for (i = 0; i < nterms; i++) {
+               if (terms[i].op != RBCE_RULE_INVALID) {
+                       real_nterms++;
+
+                       switch (terms[i].op) {
+                       case RBCE_RULE_DEP_RULE:
+                               // check if the depend rule is valid
+                               //
+                               deprule = find_rule_name(terms[i].u.string);
+                               if (!deprule || deprule == newrule) {
+                                       rc = -EINVAL;
+                                       goto out;
+                               } else {
+                                       // make sure _a_ depend rule 
+                                       // appears in only one term.
+                                       for (j = 0; j < i; j++) {
+                                               if (terms[j].op ==
+                                                   RBCE_RULE_DEP_RULE
+                                                   && terms[j].u.deprule ==
+                                                   deprule) {
+                                                       rc = -EINVAL;
+                                                       goto out;
+                                               }
+                                       }
+                                       terms[i].u.deprule = deprule;
+                               }
+
+                               // +depend is acceptable and -depend is not
+                               if (terms[i].operator != TOKEN_OP_DEP_DEL) {
+                                       terms[i].operator = RBCE_EQUAL;
+                               } else {
+                                       rc = -EINVAL;
+                                       goto out;
+                               }
+                               break;
+
+                       case RBCE_RULE_CMD_PATH:
+                       case RBCE_RULE_CMD:
+                       case RBCE_RULE_ARGS:
+                       case RBCE_RULE_APP_TAG:
+                       case RBCE_RULE_IPV4:
+                       case RBCE_RULE_IPV6:
+                               // sum up the string length
+                               strtablen += strlen(terms[i].u.string) + 1;
+                               break;
+                       default:
+                               break;
+
+                       }
+               } else {
+                       switch (terms[i].operator) {
+                       case TOKEN_OP_ORDER:
+                               order = terms[i].u.id;
+                               if (order < 0) {
+                                       rc = -EINVAL;
+                                       goto out;
+                               }
+                               break;
+                       case TOKEN_OP_STATE:
+                               state = terms[i].u.id != 0;
+                               break;
+                       case TOKEN_OP_CLASS:
+                               class = terms[i].u.string;
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
+
+       // Check if class was specified
+       if (class != NULL) {
+               int classtype;
+               if ((targetcls = get_class(class, &classtype)) == NULL) {
+                       rc = -EINVAL;
+                       goto out;
+               }
+               put_class(newrule->target_class);
+
+               newrule->target_class = targetcls;
+               newrule->classtype = classtype;
+       }
+       if (!newrule->target_class) {
+               rc = -EINVAL;
+               goto out;
+       }
+
+       if (state != -1) {
+               newrule->state = state;
+       }
+       if (order != -1) {
+               newrule->order = order;
+       }
+       newrule->terms = kmalloc(real_nterms * sizeof(int), GFP_ATOMIC);
+       if (!newrule->terms) {
+               rc = -ENOMEM;
+               goto out;
+       }
+       newrule->num_terms = real_nterms;
+       if (strtablen && ((strtab = kmalloc(strtablen, GFP_ATOMIC)) == NULL)) {
+               rc = -ENOMEM;
+               goto out;
+       }
+
+       if (newrule->index == -1) {
+               index = alloc_term_index();
+               if (index < 0) {
+                       rc = -ENOMEM;
+                       goto out;
+               }
+               newrule->index = index;
+               term = &gl_terms[newrule->index];
+               term->op = RBCE_RULE_DEP_RULE;
+               term->u.deprule = newrule;
+       }
+       newrule->strtab = strtab;
+       newrule->termflag = 0;
+
+       // Fill the term vector
+       strtablen = 0;
+       counter = 0;
+       for (i = 0; i < nterms; i++) {
+               if (terms[i].op == RBCE_RULE_INVALID) {
+                       continue;
+               }
+
+               newrule->terms[counter] = alloc_term_index();
+               if (newrule->terms[counter] < 0) {
+                       for (j = 0; j < counter; j++) {
+                               release_term_index(newrule->terms[j]);
+                       }
+                       rc = -ENOMEM;
+                       goto out;
+               }
+               term = &gl_terms[newrule->terms[counter]];
+               term->op = terms[i].op;
+               term->operator = terms[i].operator;
+               switch (terms[i].op) {
+               case RBCE_RULE_CMD_PATH:
+               case RBCE_RULE_CMD:
+               case RBCE_RULE_ARGS:
+               case RBCE_RULE_APP_TAG:
+               case RBCE_RULE_IPV4:
+               case RBCE_RULE_IPV6:
+                       term->u.string = &strtab[strtablen];
+                       strcpy(term->u.string, terms[i].u.string);
+                       strtablen = strlen(term->u.string) + 1;
+                       break;
+
+               case RBCE_RULE_REAL_UID:
+               case RBCE_RULE_REAL_GID:
+               case RBCE_RULE_EFFECTIVE_UID:
+               case RBCE_RULE_EFFECTIVE_GID:
+               case RBCE_RULE_XID:
+                       term->u.id = terms[i].u.id;
+                       break;
+
+               case RBCE_RULE_DEP_RULE:
+                       term->u.deprule = terms[i].u.deprule;
+                       INC_REF(term->u.deprule);
+                       break;
+               default:
+                       break;
+               }
+               counter++;
+       }
+
+      out:
+       if (rc) {
+               if (targetcls) {
+                       put_class(targetcls);
+               }
+               if (index >= 0) {
+                       release_term_index(index);
+               }
+               kfree(newrule->terms);
+               kfree(strtab);
+
+       }
+       return rc;
+}
+
+int change_rule(const char *rname, char *rdefn)
+{
+       struct rbce_rule *rule = NULL, *deprule;
+       struct rbce_rule_term *new_terms = NULL, *term, *terms;
+       int nterms, new_term_mask = 0, oterms, tot_terms;
+       int i, j, k, rc, new_order = 0;
+
+       if ((nterms = rules_parse(rdefn, &new_terms, &new_term_mask)) <= 0) {
+               return !nterms ? -EINVAL : nterms;
+       }
+
+       write_lock(&global_rwlock);
+       rule = find_rule_name(rname);
+       if (rule == NULL) {
+               rule = kmalloc(sizeof(struct rbce_rule), GFP_ATOMIC);
+               if (rule) {
+                       rule->obj.name = kmalloc(strlen(rname) + 1, GFP_ATOMIC);
+                       if (rule->obj.name) {
+                               strcpy(rule->obj.name, rname);
+                               GET_REF(rule) = 0;
+                               rule->order = -1;
+                               rule->index = -1;
+                               rule->state = RBCE_RULE_ENABLED;
+                               rule->target_class = NULL;
+                               rule->classtype = -1;
+                               rule->terms = NULL;
+                               rule->do_opt = 1;
+                               INIT_LIST_HEAD(&rule->obj.link);
+                               rc = fill_rule(rule, new_terms, nterms);
+                               if (rc) {
+                                       kfree(rule);
+                               } else {
+                                       if ((rc =
+                                            insert_rule(rule,
+                                                        rule->order)) == 0) {
+                                               if (rbce_enabled) {
+                                                       optimize_policy();
+                                               }
+                                       } else {
+                                               __delete_rule(rule);
+                                       }
+                               }
+                       } else {
+                               kfree(rule);
+                               rc = -ENOMEM;
+                       }
+                       kfree(new_terms);
+               } else {
+                       rc = -ENOMEM;
+               }
+               write_unlock(&global_rwlock);
+               return rc;
+       }
+
+       oterms = rule->num_terms;
+       tot_terms = nterms + oterms;
+
+       terms = kmalloc(tot_terms * sizeof(struct rbce_rule_term), GFP_ATOMIC);
+
+       if (!terms) {
+               kfree(new_terms);
+               write_unlock(&global_rwlock);
+               return -ENOMEM;
+       }
+
+       new_term_mask &= ~(1 << RBCE_RULE_DEP_RULE);
+       //ignore the new deprule terms for the first iteration.
+       // taken care of later.
+       for (i = 0; i < oterms; i++) {
+               term = &gl_terms[rule->terms[i]];       // old term
+
+               if ((1 << term->op) & new_term_mask) {  
+                       // newrule has this attr/value
+                       for (j = 0; j < nterms; j++) {
+                               if (term->op == new_terms[j].op) {
+                                       terms[i].op = new_terms[j].op;
+                                       terms[i].operator = new_terms[j].
+                                           operator;
+                                       terms[i].u.string =
+                                           new_terms[j].u.string;
+                                       new_terms[j].op = RBCE_RULE_INVALID2;
+                                       break;
+                               }
+                       }
+               } else {
+                       terms[i].op = term->op;
+                       terms[i].operator = term->operator;
+                       terms[i].u.string = term->u.string;
+               }
+       }
+
+       i = oterms;             // for readability
+
+       for (j = 0; j < nterms; j++) {
+               // handled in the previous iteration
+               if (new_terms[j].op == RBCE_RULE_INVALID2) {
+                       continue;
+               }
+
+               if (new_terms[j].op == RBCE_RULE_DEP_RULE) {
+                       if (new_terms[j].operator == TOKEN_OP_DEP) {
+                               // "depend=rule" deletes all depends in the 
+                               // original rule so, delete all depend rule 
+                               // terms in the original rule
+                               for (k = 0; k < oterms; k++) {
+                                       if (terms[k].op == RBCE_RULE_DEP_RULE) {
+                                               terms[k].op = RBCE_RULE_INVALID;
+                                       }
+                               }
+                               // must copy the new deprule term
+                       } else {
+                               // delete the depend rule term if was defined 
+                               // in the original rule for both +depend 
+                               // and -depend
+                               deprule = find_rule_name(new_terms[j].u.string);
+                               if (deprule) {
+                                       for (k = 0; k < oterms; k++) {
+                                               if (terms[k].op ==
+                                                   RBCE_RULE_DEP_RULE
+                                                   && terms[k].u.deprule ==
+                                                   deprule) {
+                                                       terms[k].op =
+                                                           RBCE_RULE_INVALID;
+                                                       break;
+                                               }
+                                       }
+                               }
+                               if (new_terms[j].operator == TOKEN_OP_DEP_DEL) {
+                                       // No need to copy the new deprule term
+                                       continue;
+                               }
+                       }
+               } else {
+                       if ((new_terms[j].op == RBCE_RULE_INVALID) &&
+                           (new_terms[j].operator == TOKEN_OP_ORDER)) {
+                               new_order++;
+                       }
+               }
+               terms[i].op = new_terms[j].op;
+               terms[i].operator = new_terms[j].operator;
+               terms[i].u.string = new_terms[j].u.string;
+               i++;
+               new_terms[j].op = RBCE_RULE_INVALID2;
+       }
+
+       tot_terms = i;
+
+       // convert old deprule pointers to name pointers.
+       for (i = 0; i < oterms; i++) {
+               if (terms[i].op != RBCE_RULE_DEP_RULE)
+                       continue;
+               terms[i].u.string = terms[i].u.deprule->obj.name;
+       }
+
+       // release the rule
+       __release_rule(rule);
+
+       rule->do_opt = 1;
+       rc = fill_rule(rule, terms, tot_terms);
+       if (rc == 0 && new_order) {
+               rc = reinsert_rule(rule, rule->order);
+       }
+       if (rc != 0) {          // rule creation/insertion failed
+               __delete_rule(rule);
+       }
+       if (rbce_enabled) {
+               optimize_policy();
+       }
+       write_unlock(&global_rwlock);
+       kfree(new_terms);
+       kfree(terms);
+       return rc;
+}
+
+/*
+ * Delete the specified rule.
+ *
+ */
+int delete_rule(const char *rname)
+{
+       int rc = 0;
+       struct rbce_rule *rule;
+
+       write_lock(&global_rwlock);
+
+       if ((rule = find_rule_name(rname)) == NULL) {
+               write_unlock(&global_rwlock);
+               goto out;
+       }
+       rc = __delete_rule(rule);
+       if (rbce_enabled && (gl_action & POLICY_ACTION_PACK_TERMS)) {
+               optimize_policy();
+       }
+       write_unlock(&global_rwlock);
+      out:
+       DPRINTK(DBG_RULE, "delete rule %s\n", rname);
+       return rc;
+}
+
+/*
+ * copy the rule specified by rname and to the given result string.
+ *
+ */
+void get_rule(const char *rname, char *result)
+{
+       int i;
+       struct rbce_rule *rule;
+       struct rbce_rule_term *term;
+       char *cp = result, oper, idtype[3], str[5];
+
+       read_lock(&global_rwlock);
+
+       rule = find_rule_name(rname);
+       if (rule != NULL) {
+               for (i = 0; i < rule->num_terms; i++) {
+                       term = gl_terms + rule->terms[i];
+                       switch (term->op) {
+                       case RBCE_RULE_REAL_UID:
+                               strcpy(idtype, "u");
+                               goto handleid;
+                       case RBCE_RULE_REAL_GID:
+                               strcpy(idtype, "g");
+                               goto handleid;
+                       case RBCE_RULE_EFFECTIVE_UID:
+                               strcpy(idtype, "eu");
+                               goto handleid;
+                       case RBCE_RULE_EFFECTIVE_GID:
+                               strcpy(idtype, "eg");
+                               goto handleid;
+                       case RBCE_RULE_XID:
+                               strcpy(idtype, "x");
+                             handleid:
+                               if (term->operator == RBCE_LESS_THAN) {
+                                       oper = '<';
+                               } else if (term->operator == RBCE_GREATER_THAN) {
+                                       oper = '>';
+                               } else if (term->operator == RBCE_NOT) {
+                                       oper = '!';
+                               } else {
+                                       oper = '=';
+                               }
+                               cp +=
+                                   sprintf(cp, "%sid%c%ld,", idtype, oper,
+                                           term->u.id);
+                               break;
+                       case RBCE_RULE_CMD_PATH:
+                               strcpy(str, "path");
+                               goto handle_str;
+                       case RBCE_RULE_CMD:
+                               strcpy(str, "cmd");
+                               goto handle_str;
+                       case RBCE_RULE_ARGS:
+                               strcpy(str, "args");
+                               goto handle_str;
+                       case RBCE_RULE_APP_TAG:
+                               strcpy(str, "tag");
+                               goto handle_str;
+                       case RBCE_RULE_IPV4:
+                               strcpy(str, "ipv4");
+                               goto handle_str;
+                       case RBCE_RULE_IPV6:
+                               strcpy(str, "ipv6");
+                             handle_str:
+                               cp +=
+                                   sprintf(cp, "%s=%s,", str, term->u.string);
+                               break;
+                       case RBCE_RULE_DEP_RULE:
+                               cp +=
+                                   sprintf(cp, "depend=%s,",
+                                           term->u.deprule->obj.name);
+                               break;
+                       default:
+                               break;
+                       }
+               }
+               if (!rule->num_terms) {
+                       cp += sprintf(cp, "***** no terms defined ***** ");
+               }
+
+               cp +=
+                   sprintf(cp, "order=%d,state=%d,", rule->order, rule->state);
+               cp +=
+                   sprintf(cp, "class=%s",
+                           rule->target_class ? rule->target_class->obj.
+                           name : "***** REMOVED *****");
+               *cp = '\0';
+       } else {
+               sprintf(result, "***** Rule %s doesn't exist *****", rname);
+       }
+
+       read_unlock(&global_rwlock);
+       return;
+}
+
+/*
+ * Change the name of the given rule "from_rname" to "to_rname"
+ *
+ */
+int rename_rule(const char *from_rname, const char *to_rname)
+{
+       struct rbce_rule *rule;
+       int nlen, rc = -EINVAL;
+
+       if (!to_rname || !*to_rname) {
+               return rc;
+       }
+       write_lock(&global_rwlock);
+
+       rule = find_rule_name(from_rname);
+       if (rule != NULL) {
+               if ((nlen = strlen(to_rname)) > strlen(rule->obj.name)) {
+                       char *name = kmalloc(nlen + 1, GFP_ATOMIC);
+                       if (!name) {
+                               return -ENOMEM;
+                       }
+                       kfree(rule->obj.name);
+                       rule->obj.name = name;
+               }
+               strcpy(rule->obj.name, to_rname);
+               rc = 0;
+       }
+       write_unlock(&global_rwlock);
+       return rc;
+}
+
+/*
+ * Return TRUE if the given rule exists, FALSE otherwise
+ *
+ */
+int rule_exists(const char *rname)
+{
+       struct rbce_rule *rule;
+
+       read_lock(&global_rwlock);
+       rule = find_rule_name(rname);
+       read_unlock(&global_rwlock);
+       return rule != NULL;
+}
+
+/*====================== Magic file handling =======================*/
+/*
+ * Reclassify
+ */
+static struct rbce_private_data *create_private_data(struct rbce_private_data *,
+                                                    int);
+
+static inline
+void reset_evaluation(struct rbce_private_data *pdata,int termflag)
+{
+       /* reset TAG ruleterm evaluation results to pick up 
+        * on next classification event
+        */
+       if (use_persistent_state && gl_mask_vecs[termflag]) {
+               bitvector_and_not( pdata->eval, pdata->eval, 
+                                  gl_mask_vecs[termflag] );
+               bitvector_and_not( pdata->true, pdata->true, 
+                                  gl_mask_vecs[termflag] );
+       }
+}
+  
+int set_tasktag(int pid, char *tag)
+{
+       char *tp;
+       int rc = 0;
+       struct task_struct *tsk;
+       struct rbce_private_data *pdata;
+       int len;
+
+       if (!tag) {
+               return -EINVAL;
+       }
+       len = strlen(tag) + 1;
+       tp = kmalloc(len, GFP_ATOMIC);
+       if (!tp) {
+               return -ENOMEM;
+       }
+       strncpy(tp,tag,len);
+
+       read_lock(&tasklist_lock);
+       if ((tsk = find_task_by_pid(pid)) == NULL) {
+               rc = -EINVAL;
+               goto out;
+       }
+
+       if (unlikely(!RBCE_DATA(tsk))) {
+               RBCE_DATAP(tsk) = create_private_data(NULL, 0);
+               if (!RBCE_DATA(tsk)) {
+                       rc = -ENOMEM;
+                       goto out;
+               }
+       }
+       pdata = RBCE_DATA(tsk);
+       if (pdata->app_tag) {
+               kfree(pdata->app_tag);
+       }
+       pdata->app_tag = tp;
+       reset_evaluation(pdata,RBCE_TERMFLAG_TAG);
+       
+ out:
+       read_unlock(&tasklist_lock);
+       if (rc != 0) 
+               kfree(tp);
+       return rc;
+}
+
+/*====================== Classification Functions =======================*/
+
+/*
+ * Match the given full path name with the command expression.
+ * This function treats the folowing 2 charaters as special if seen in
+ * cmd_exp, all other chanracters are compared as is:
+ *             ? - compares to any one single character
+ *             * - compares to one or more single characters
+ *
+ * If fullpath is 1, tsk_comm is compared in full. otherwise only the command
+ * name (basename(tsk_comm)) is compared.
+ */
+static int match_cmd(const char *tsk_comm, const char *cmd_exp, int fullpath)
+{
+       const char *c, *t, *last_ast, *cmd = tsk_comm;
+       char next_c;
+
+       // get the command name if we don't have to match the fullpath
+       if (!fullpath && ((c = strrchr(tsk_comm, '/')) != NULL)) {
+               cmd = c + 1;
+       }
+
+       /* now faithfully assume the entire pathname is in cmd */
+
+       /* we now have to effectively implement a regular expression 
+        * for now assume 
+        *    '?'   any single character 
+        *    '*'   one or more '?'
+        *    rest  must match
+        */
+
+       c = cmd_exp;
+       t = cmd;
+       if (t == NULL || c == NULL) {
+               return 0;
+       }
+
+       last_ast = NULL;
+       next_c = '\0';
+
+       while (*c && *t) {
+               switch (*c) {
+               case '?':
+                       if (*t == '/') {
+                               return 0;
+                       }
+                       c++;
+                       t++;
+                       continue;
+               case '*':
+                       if (*t == '/') {
+                               return 0;
+                       }
+                       // eat up all '*' in c
+                       while (*(c + 1) == '*')
+                               c++;
+                       next_c = '\0';
+                       last_ast = c;
+                       //t++;  // Add this for matching '*' with "one" 
+                               // or more chars.
+                       while (*t && (*t != *(c + 1)) && *t != '/')
+                               t++;
+                       if (*t == *(c + 1)) {
+                               c++;
+                               if (*c != '/') {
+                                       if (*c == '?') {
+                                               if (*t == '/') {
+                                                       return 0;
+                                               }
+                                               t++;
+                                               c++;
+                                       }
+                                       next_c = *c;
+                                       if (*c) {
+                                               if (*t == '/') {
+                                                       return 0;
+                                               }
+                                               t++;
+                                               c++;
+                                               if (!*c && *t)
+                                                       c = last_ast;
+                                       }
+                               } else {
+                                       last_ast = NULL;
+                               }
+                               continue;
+                       }
+                       return 0;
+               case '/':
+                       next_c = '\0';
+                /*FALLTHRU*/ default:
+                       if (*t == *c && next_c != *t) {
+                               c++, t++;
+                               continue;
+                       } else {
+                               /* reset to last asterix and 
+                                  continue from there */
+                               if (last_ast) {
+                                       c = last_ast;
+                               } else {
+                                       return 0;
+                               }
+                       }
+               }
+       }
+
+       /* check for trailing "*" */
+       while (*c == '*')
+               c++;
+
+       return (!*c && !*t);
+}
+
+static void reverse(char *str, int n)
+{
+       char s;
+       int i, j = n - 1;
+
+       for (i = 0; i < j; i++, j--) {
+               s = str[i];
+               str[i] = str[j];
+               str[j] = s;
+       }
+}
+
+static int itoa(int n, char *str)
+{
+       int i = 0, sz = 0;
+
+       do {
+               str[i++] = n % 10 + '0';
+               sz++;
+               n = n / 10;
+       } while (n > 0);
+
+       (void)reverse(str, sz);
+       return sz;
+}
+
+static int v4toa(__u32 y, char *a)
+{
+       int i;
+       int size = 0;
+
+       for (i = 0; i < 4; i++) {
+               size += itoa(y & 0xff, &a[size]);
+               a[size++] = '.';
+               y >>= 8;
+       }
+       return --size;
+}
+
+int match_ipv4(struct ckrm_net_struct *ns, char **string)
+{
+       char *ptr = *string;
+       int size;
+       char a4[16];
+
+       size = v4toa(ns->ns_daddrv4, a4);
+
+       *string += size;
+       return !strncmp(a4, ptr, size);
+}
+
+int match_port(struct ckrm_net_struct *ns, char *ptr)
+{
+       char a[5];
+       int size = itoa(ns->ns_dport, a);
+
+       return !strncmp(a, ptr, size);
+}
+
+static int __evaluate_rule(struct task_struct *tsk, struct ckrm_net_struct *ns,
+                          struct rbce_rule *rule, bitvector_t * vec_eval,
+                          bitvector_t * vec_true, char **filename);
+/*
+ * evaluate the given task against the given rule with the vec_eval and
+ * vec_true in context. Return 1 if the task satisfies the given rule, 0
+ * otherwise.
+ *
+ * If the bit corresponding to the rule is set in the vec_eval, then the
+ * corresponding bit in vec_true is the result. If it is not set, evaluate
+ * the rule and set the bits in both the vectors accordingly.
+ *
+ * On return, filename will have the pointer to the pathname of the task's
+ * executable, if the rule had any command related terms.
+ *
+ * Caller must hold the global_rwlock atleast in read mode.
+ */
+static inline int
+evaluate_rule(struct task_struct *tsk, struct ckrm_net_struct *ns,
+             struct rbce_rule *rule, bitvector_t * vec_eval,
+             bitvector_t * vec_true, char **filename)
+{
+       int tidx = rule->index;
+
+       if (!bitvector_test(tidx, vec_eval)) {
+               if (__evaluate_rule
+                   (tsk, ns, rule, vec_eval, vec_true, filename)) {
+                       bitvector_set(tidx, vec_true);
+               }
+               bitvector_set(tidx, vec_eval);
+       }
+       return bitvector_test(tidx, vec_true);
+}
+
+/*
+ * evaluate the given task against every term in the given rule with
+ * vec_eval and vec_true in context.
+ *
+ * If the bit corresponding to a rule term is set in the vec_eval, then the
+ * corresponding bit in vec_true is the result for taht particular. If it is
+ * not set, evaluate the rule term and set the bits in both the vectors
+ * accordingly.
+ *
+ * This fucntions returns true only if all terms in the rule evaluate true.
+ *
+ * On return, filename will have the pointer to the pathname of the task's
+ * executable, if the rule had any command related terms.
+ *
+ * Caller must hold the global_rwlock atleast in read mode.
+ */
+static int
+__evaluate_rule(struct task_struct *tsk, struct ckrm_net_struct *ns,
+               struct rbce_rule *rule, bitvector_t * vec_eval,
+               bitvector_t * vec_true, char **filename)
+{
+       int i;
+       int no_ip = 1;
+
+       for (i = rule->num_terms; --i >= 0;) {
+               int rc = 1, tidx = rule->terms[i];
+
+               if (!bitvector_test(tidx, vec_eval)) {
+                       struct rbce_rule_term *term = &gl_terms[tidx];
+
+                       switch (term->op) {
+
+                       case RBCE_RULE_CMD_PATH:
+                       case RBCE_RULE_CMD:
+#if 0
+                               if (!*filename) {       /* get this once */
+                                       if (((*filename =
+                                             kmalloc(NAME_MAX,
+                                                     GFP_ATOMIC)) == NULL)
+                                           ||
+                                           (get_exe_path_name
+                                            (tsk, *filename, NAME_MAX) < 0)) {
+                                               rc = 0;
+                                               break;
+                                       }
+                               }
+                               rc = match_cmd(*filename, term->u.string,
+                                              (term->op ==
+                                               RBCE_RULE_CMD_PATH));
+#else
+                               rc = match_cmd(tsk->comm, term->u.string,
+                                              (term->op ==
+                                               RBCE_RULE_CMD_PATH));
+#endif
+                               break;
+                       case RBCE_RULE_REAL_UID:
+                               if (term->operator == RBCE_LESS_THAN) {
+                                       rc = (tsk->uid < term->u.id);
+                               } else if (term->operator == RBCE_GREATER_THAN){
+                                       rc = (tsk->uid > term->u.id);
+                               } else if (term->operator == RBCE_NOT) {
+                                       rc = (tsk->uid != term->u.id);
+                               } else {
+                                       rc = (tsk->uid == term->u.id);
+                               }
+                               break;
+                       case RBCE_RULE_REAL_GID:
+                               if (term->operator == RBCE_LESS_THAN) {
+                                       rc = (tsk->gid < term->u.id);
+                               } else if (term->operator == RBCE_GREATER_THAN){
+                                       rc = (tsk->gid > term->u.id);
+                               } else if (term->operator == RBCE_NOT) {
+                                       rc = (tsk->gid != term->u.id);
+                               } else {
+                                       rc = (tsk->gid == term->u.id);
+                               }
+                               break;
+                       case RBCE_RULE_EFFECTIVE_UID:
+                               if (term->operator == RBCE_LESS_THAN) {
+                                       rc = (tsk->euid < term->u.id);
+                               } else if (term->operator == RBCE_GREATER_THAN){
+                                       rc = (tsk->euid > term->u.id);
+                               } else if (term->operator == RBCE_NOT) {
+                                       rc = (tsk->euid != term->u.id);
+                               } else {
+                                       rc = (tsk->euid == term->u.id);
+                               }
+                               break;
+                       case RBCE_RULE_EFFECTIVE_GID:
+                               if (term->operator == RBCE_LESS_THAN) {
+                                       rc = (tsk->egid < term->u.id);
+                               } else if (term->operator == RBCE_GREATER_THAN){
+                                       rc = (tsk->egid > term->u.id);
+                               } else if (term->operator == RBCE_NOT) {
+                                       rc = (tsk->egid != term->u.id);
+                               } else {
+                                       rc = (tsk->egid == term->u.id);
+                               }
+                               break;
+                       case RBCE_RULE_APP_TAG:
+                               rc = (RBCE_DATA(tsk)
+                                     && RBCE_DATA(tsk)->
+                                     app_tag) ? !strcmp(RBCE_DATA(tsk)->
+                                                        app_tag,
+                                                        term->u.string) : 0;
+                               break;
+                       case RBCE_RULE_DEP_RULE:
+                               rc = evaluate_rule(tsk, NULL, term->u.deprule,
+                                                  vec_eval, vec_true,
+                                                  filename);
+                               break;
+
+                       case RBCE_RULE_IPV4:
+                               // TBD: add NOT_EQUAL match. At present rbce
+                               // recognises EQUAL matches only.
+                               if (ns && term->operator == RBCE_EQUAL) {
+                                       int ma = 0;
+                                       int mp = 0;
+                                       char *ptr = term->u.string;
+
+                                       if (term->u.string[0] == '*')
+                                               ma = 1;
+                                       else
+                                               ma = match_ipv4(ns, &ptr);
+
+                                       if (*ptr != '\\') {     // error
+                                               rc = 0;
+                                               break;
+                                       } else {
+                                               ++ptr;
+                                               if (*ptr == '*')
+                                                       mp = 1;
+                                               else
+                                                       mp = match_port(ns,
+                                                                       ptr);
+                                       }
+                                       rc = mp && ma;
+                               } else
+                                       rc = 0;
+                               no_ip = 0;
+                               break;
+
+                       case RBCE_RULE_IPV6:    // no support yet
+                               rc = 0;
+                               no_ip = 0;
+                               break;
+
+                       case RBCE_RULE_XID:
+                       {
+                               xid_t xid = vx_task_xid(tsk);
+
+                               if (term->operator == RBCE_LESS_THAN) {
+                                       rc = (xid < term->u.id);
+                               } else if (term->operator == RBCE_GREATER_THAN) {
+                                       rc = (xid > term->u.id);
+                               } else if (term->operator == RBCE_NOT) {
+                                       rc = (xid != term->u.id);
+                               } else {
+                                       rc = (xid == term->u.id);
+                               }
+                               break;
+                       }
+                               
+                       default:
+                               rc = 0;
+                               printk(KERN_ERR "Error evaluate term op=%d\n",
+                                      term->op);
+                               break;
+                       }
+                       if (!rc && no_ip) {
+                               bitvector_clear(tidx, vec_true);
+                       } else {
+                               bitvector_set(tidx, vec_true);
+                       }
+                       bitvector_set(tidx, vec_eval);
+               } else {
+                       rc = bitvector_test(tidx, vec_true);
+               }
+               if (!rc) {
+                       return 0;
+               }
+       }
+       return 1;
+}
+
+//#define PDATA_DEBUG
+#ifdef PDATA_DEBUG
+
+#define MAX_PDATA 10000
+void *pdata_arr[MAX_PDATA];
+int pdata_count, pdata_next;
+static spinlock_t pdata_lock = SPIN_LOCK_UNLOCKED;
+
+static inline int valid_pdata(struct rbce_private_data *pdata)
+{
+       int i;
+
+       if (!pdata) {
+               return 1;
+       }
+       spin_lock(&pdata_lock);
+       for (i = 0; i < MAX_PDATA; i++) {
+               if (pdata_arr[i] == pdata) {
+                       spin_unlock(&pdata_lock);
+                       return 1;
+               }
+       }
+       spin_unlock(&pdata_lock);
+       printk(KERN_WARNING "INVALID/CORRUPT PDATA %p\n", pdata);
+       return 0;
+}
+
+static inline void store_pdata(struct rbce_private_data *pdata)
+{
+       int i = 0;
+
+       if (pdata) {
+               spin_lock(&pdata_lock);
+
+               while (i < MAX_PDATA) {
+                       if (pdata_arr[pdata_next] == NULL) {
+                               printk(KERN_DEBUG "storing %p at %d, count %d\n", pdata,
+                                      pdata_next, pdata_count);
+                               pdata_arr[pdata_next++] = pdata;
+                               if (pdata_next == MAX_PDATA) {
+                                       pdata_next = 0;
+                               }
+                               pdata_count++;
+                               break;
+                       }
+                       pdata_next++;
+                       i++;
+               }
+               spin_unlock(&pdata_lock);
+       }
+       if (i == MAX_PDATA) {
+               printk(KERN_DEBUG "PDATA BUFFER FULL pdata_count %d pdata %p\n",
+                      pdata_count, pdata);
+       }
+}
+
+static inline void unstore_pdata(struct rbce_private_data *pdata)
+{
+       int i;
+       if (pdata) {
+               spin_lock(&pdata_lock);
+               for (i = 0; i < MAX_PDATA; i++) {
+                       if (pdata_arr[i] == pdata) {
+                               printk(KERN_DEBUG "unstoring %p at %d, count %d\n", pdata,
+                                      i, pdata_count);
+                               pdata_arr[i] = NULL;
+                               pdata_count--;
+                               pdata_next = i;
+                               break;
+                       }
+               }
+               spin_unlock(&pdata_lock);
+               if (i == MAX_PDATA) {
+                       printk(KERN_DEBUG "pdata %p not found in the stored array\n",
+                              pdata);
+               }
+       }
+       return;
+}
+
+#else                          // PDATA_DEBUG
+
+#define valid_pdata(pdata) (1)
+#define store_pdata(pdata)
+#define unstore_pdata(pdata)
+
+#endif                         // PDATA_DEBUG
+
+/*
+ * Allocate and initialize a rbce_private_data data structure.
+ *
+ * Caller must hold global_rwlock atleast in read mode.
+ */
+
+static inline void
+copy_ext_private_data(struct rbce_private_data *src,
+                     struct rbce_private_data *dst)
+{
+       if (src)
+               dst->ext_data = src->ext_data;
+       else
+               memset(&dst->ext_data, 0, sizeof(dst->ext_data));
+}
+
+static struct rbce_private_data *create_private_data(struct rbce_private_data
+                                                    *src, int copy_sample)
+{
+       int vsize, psize, bsize;
+       struct rbce_private_data *pdata;
+
+       if (use_persistent_state) {
+               vsize = gl_allocated;
+               bsize = vsize / 8 + sizeof(bitvector_t);
+               psize = sizeof(struct rbce_private_data) + 2 * bsize;
+       } else {
+               psize = sizeof(struct rbce_private_data);
+       }
+
+       pdata = kmalloc(psize, GFP_ATOMIC);
+       if (pdata != NULL) {
+               if (use_persistent_state) {
+                       pdata->bitmap_version = gl_bitmap_version;
+                       pdata->eval = (bitvector_t *) & pdata->data[0];
+                       pdata->true = (bitvector_t *) & pdata->data[bsize];
+                       if (src && (src->bitmap_version == gl_bitmap_version)) {
+                               memcpy(pdata->data, src->data, 2 * bsize);
+                       } else {
+                               bitvector_init(pdata->eval, vsize);
+                               bitvector_init(pdata->true, vsize);
+                       }
+               }
+               copy_ext_private_data(src, pdata);
+               //if (src) { // inherit evaluate and app_tag
+               //      pdata->evaluate = src->evaluate;
+               //      if(src->app_tag) {
+               //              int len = strlen(src->app_tag)+1;
+               //              printk(KERN_DEBUG "CREATE_PRIVATE: apptag %s len %d\n",
+               //                          src->app_tag,len);
+               //              pdata->app_tag = kmalloc(len, GFP_ATOMIC);
+               //              if (pdata->app_tag) {
+               //                      strcpy(pdata->app_tag, src->app_tag);
+               //              }
+               //      }
+               //} else {
+               pdata->evaluate = 1;
+               pdata->rules_version = src ? src->rules_version : 0;
+               pdata->app_tag = NULL;
+               //}
+       }
+       store_pdata(pdata);
+       return pdata;
+}
+
+static inline void free_private_data(struct rbce_private_data *pdata)
+{
+       if (valid_pdata(pdata)) {
+               unstore_pdata(pdata);
+               kfree(pdata);
+       }
+}
+
+static void free_all_private_data(void)
+{
+       struct task_struct *proc, *thread;
+
+       read_lock(&tasklist_lock);
+       do_each_thread(proc, thread) {
+               struct rbce_private_data *pdata;
+
+               pdata = RBCE_DATA(thread);
+               RBCE_DATAP(thread) = NULL;
+               free_private_data(pdata);
+       } while_each_thread(proc, thread);
+       read_unlock(&tasklist_lock);
+       return;
+}
+
+/*
+ * reclassify function, which is called by all the callback functions.
+ *
+ * Takes that task to be reclassified and ruleflags that indicates the
+ * attributes that caused this reclassification request.
+ *
+ * On success, returns the core class pointer to which the given task should
+ * belong to.
+ */
+static struct ckrm_core_class *rbce_classify(struct task_struct *tsk,
+                                            struct ckrm_net_struct *ns,
+                                            unsigned long termflag,
+                                            int classtype)
+{
+       int i;
+       struct rbce_rule *rule;
+       bitvector_t *vec_true = NULL, *vec_eval = NULL;
+       struct rbce_class *tgt = NULL;
+       struct ckrm_core_class *cls = NULL;
+       char *filename = NULL;
+
+       if (!valid_pdata(RBCE_DATA(tsk))) {
+               return NULL;
+       }
+       if (classtype >= CKRM_MAX_CLASSTYPES) {
+               // can't handle more than CKRM_MAX_CLASSTYPES
+               return NULL;
+       }
+       // fast path to avoid locking in case CE is not enabled or if no rules
+       // are defined or if the tasks states that no evaluation is needed.
+       if (!rbce_enabled || !gl_num_rules ||
+           (RBCE_DATA(tsk) && !RBCE_DATA(tsk)->evaluate)) {
+               return NULL;
+       }
+       // FIXME: optimize_policy should be called from here if
+       // gl_action is non-zero. Also, it has to be called with the
+       // global_rwlock held in write mode.
+
+       read_lock(&global_rwlock);
+
+       vec_eval = vec_true = NULL;
+       if (use_persistent_state) {
+               struct rbce_private_data *pdata = RBCE_DATA(tsk);
+
+               if (!pdata
+                   || (pdata
+                       && (gl_bitmap_version != pdata->bitmap_version))) {
+                       struct rbce_private_data *new_pdata =
+                           create_private_data(pdata, 1);
+
+                       if (new_pdata) {
+                               if (pdata) {
+                                       new_pdata->rules_version =
+                                           pdata->rules_version;
+                                       new_pdata->evaluate = pdata->evaluate;
+                                       new_pdata->app_tag = pdata->app_tag;
+                                       free_private_data(pdata);
+                               }
+                               pdata = RBCE_DATAP(tsk) = new_pdata;
+                               termflag = RBCE_TERMFLAG_ALL;   
+                               // need to evaluate them all
+                       } else {
+                               // we shouldn't free the pdata as it has more 
+                               // details than the vectors. But, this 
+                               // reclassification should go thru
+                               pdata = NULL;
+                       }
+               }
+               if (!pdata) {
+                       goto cls_determined;
+               }
+               vec_eval = pdata->eval;
+               vec_true = pdata->true;
+       } else {
+               int bsize = gl_allocated;
+
+               vec_eval = bitvector_alloc(bsize);
+               vec_true = bitvector_alloc(bsize);
+
+               if (vec_eval == NULL || vec_true == NULL) {
+                       goto cls_determined;
+               }
+               termflag = RBCE_TERMFLAG_ALL; 
+               // need to evaluate all of them now
+       }
+
+       /* 
+        * using bit ops invalidate all terms related to this termflag
+        * context (only in per task vec)
+        */
+       DPRINTK(DBG_CLASSIFY_DETAILS, "\nClassify: termflag=%lx\n", termflag);
+       DPRINTK(DBG_CLASSIFY_DETAILS, "     eval before: ");
+       bitvector_print(DBG_CLASSIFY_DETAILS, vec_eval);
+       DPRINTK(DBG_CLASSIFY_DETAILS, "\n     true before: ");
+       bitvector_print(DBG_CLASSIFY_DETAILS, vec_true);
+       DPRINTK(DBG_CLASSIFY_DETAILS, "\n     redo => ");
+
+       if (termflag == RBCE_TERMFLAG_ALL) {
+               DPRINTK(DBG_CLASSIFY_DETAILS, "  redoall ");
+               bitvector_zero(vec_eval);
+       } else {
+               for (i = 0; i < NUM_TERM_MASK_VECTOR; i++) {
+                       if (test_bit(i, &termflag)) {
+                               bitvector_t *maskvec = gl_mask_vecs[i];
+
+                               DPRINTK(DBG_CLASSIFY_DETAILS, "  mask(%d) ", i);
+                               bitvector_print(DBG_CLASSIFY_DETAILS, maskvec);
+                               bitvector_and_not(vec_eval, vec_eval, maskvec);
+                       }
+               }
+       }
+       bitvector_and(vec_true, vec_true, vec_eval);
+
+       DPRINTK(DBG_CLASSIFY_DETAILS, "\n     eval now:    ");
+       bitvector_print(DBG_CLASSIFY_DETAILS, vec_eval);
+       DPRINTK(DBG_CLASSIFY_DETAILS, "\n");
+
+       /* run through the rules in order and see what needs evaluation */
+       list_for_each_entry(rule, &rules_list[classtype], obj.link) {
+               if (rule->state == RBCE_RULE_ENABLED &&
+                   rule->target_class &&
+                   rule->target_class->classobj &&
+                   evaluate_rule(tsk, ns, rule, vec_eval, vec_true,
+                                 &filename)) {
+                       tgt = rule->target_class;
+                       cls = rule->target_class->classobj;
+                       break;
+               }
+       }
+
+      cls_determined:
+       DPRINTK(DBG_CLASSIFY_RES,
+               "==> |%s|; pid %d; euid %d; egid %d; ruid %d; rgid %d;"
+               "tag |%s| ===> class |%s|\n",
+               filename ? filename : tsk->comm,
+               tsk->pid,
+               tsk->euid,
+               tsk->egid,
+               tsk->uid,
+               tsk->gid,
+               RBCE_DATA(tsk) ? RBCE_DATA(tsk)->app_tag : "",
+               tgt ? tgt->obj.name : "");
+       DPRINTK(DBG_CLASSIFY_DETAILS, "     eval after: ");
+       bitvector_print(DBG_CLASSIFY_DETAILS, vec_eval);
+       DPRINTK(DBG_CLASSIFY_DETAILS, "\n     true after: ");
+       bitvector_print(DBG_CLASSIFY_DETAILS, vec_true);
+       DPRINTK(DBG_CLASSIFY_DETAILS, "\n");
+
+       if (!use_persistent_state) {
+               if (vec_eval) {
+                       bitvector_free(vec_eval);
+               }
+               if (vec_true) {
+                       bitvector_free(vec_true);
+               }
+       }
+       ckrm_core_grab(cls);
+       read_unlock(&global_rwlock);
+       if (filename) {
+               kfree(filename);
+       }
+       if (RBCE_DATA(tsk)) {
+               RBCE_DATA(tsk)->rules_version = gl_rules_version;
+       }
+       return cls;
+}
+
+/*****************************************************************************
+ *
+ * Module specific utilization of core RBCE functionality
+ *
+ * Includes support for the various classtypes 
+ * New classtypes will require extensions here
+ * 
+ *****************************************************************************/
+
+/* helper functions that are required in the extended version */
+
+static inline void rbce_tc_manual(struct task_struct *tsk)
+{
+       read_lock(&global_rwlock);
+
+       if (!RBCE_DATA(tsk)) {
+               RBCE_DATAP(tsk) =
+                   (void *)create_private_data(RBCE_DATA(tsk->parent), 0);
+       }
+       if (RBCE_DATA(tsk)) {
+               RBCE_DATA(tsk)->evaluate = 0;
+       }
+       read_unlock(&global_rwlock);
+       return;
+}
+
+/*****************************************************************************
+ *   load any extensions
+ *****************************************************************************/
+
+#ifdef RBCE_EXTENSION
+#include "rbcemod_ext.c"
+#endif
+
+/*****************************************************************************
+ *    VARIOUS CLASSTYPES
+ *****************************************************************************/
+
+// to enable type coercion of the function pointers
+
+/*============================================================================
+ *    TASKCLASS CLASSTYPE
+ *============================================================================*/
+
+int tc_classtype = -1;
+
+/*
+ * fork callback to be registered with core module.
+ */
+inline static void *rbce_tc_forkcb(struct task_struct *tsk)
+{
+       int rule_version_changed = 1;
+       struct ckrm_core_class *cls;
+       read_lock(&global_rwlock);
+       // dup ce_data
+       RBCE_DATAP(tsk) =
+           (void *)create_private_data(RBCE_DATA(tsk->parent), 0);
+       read_unlock(&global_rwlock);
+
+       if (RBCE_DATA(tsk->parent)) {
+               rule_version_changed =
+                   (RBCE_DATA(tsk->parent)->rules_version != gl_rules_version);
+       }
+       cls = rule_version_changed ?
+           rbce_classify(tsk, NULL, RBCE_TERMFLAG_ALL, tc_classtype) : NULL;
+
+       // note the fork notification to any user client will be sent through
+       // the guaranteed fork-reclassification
+       return cls;
+}
+
+/*
+ * exit callback to be registered with core module.
+ */
+static void rbce_tc_exitcb(struct task_struct *tsk)
+{
+       struct rbce_private_data *pdata;
+
+       send_exit_notification(tsk);
+
+       pdata = RBCE_DATA(tsk);
+       RBCE_DATAP(tsk) = NULL;
+       if (pdata) {
+               if (pdata->app_tag) {
+                       kfree(pdata->app_tag);
+               }
+               free_private_data(pdata);
+       }
+       return;
+}
+
+#define AENT(x) [ CKRM_EVENT_##x] = #x
+static const char *event_names[CKRM_NUM_EVENTS] = {
+       AENT(NEWTASK),
+       AENT(FORK),
+       AENT(EXIT),
+       AENT(EXEC),
+       AENT(UID),
+       AENT(GID),
+       AENT(XID),
+       AENT(LOGIN),
+       AENT(USERADD),
+       AENT(USERDEL),
+       AENT(LISTEN_START),
+       AENT(LISTEN_STOP),
+       AENT(APPTAG),
+       AENT(RECLASSIFY),
+       AENT(MANUAL),
+};
+
+void *rbce_tc_classify(enum ckrm_event event, ...)
+{
+       va_list args;
+       void *cls = NULL;
+       struct task_struct *tsk;
+       struct rbce_private_data *pdata;
+
+       va_start(args, event);
+       tsk = va_arg(args, struct task_struct *);
+       va_end(args);
+
+       /* we only have to deal with events between 
+        * [ CKRM_LATCHABLE_EVENTS .. CKRM_NONLATCHABLE_EVENTS ) 
+        */
+
+       // printk(KERN_DEBUG "tc_classify %p:%d:%s '%s'\n",tsk,tsk->pid,
+       //                      tsk->comm,event_names[event]);
+
+       switch (event) {
+
+       case CKRM_EVENT_FORK:
+               cls = rbce_tc_forkcb(tsk);
+               break;
+
+       case CKRM_EVENT_EXIT:
+               rbce_tc_exitcb(tsk);
+               break;
+
+       case CKRM_EVENT_EXEC:
+               cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_CMD |
+                                   RBCE_TERMFLAG_UID | RBCE_TERMFLAG_GID,
+                                   tc_classtype);
+               break;
+
+       case CKRM_EVENT_UID:
+               cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_UID, tc_classtype);
+               break;
+
+       case CKRM_EVENT_GID:
+               cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_GID, tc_classtype);
+               break;
+
+       case CKRM_EVENT_XID:
+               cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_XID, tc_classtype);
+               break;
+
+       case CKRM_EVENT_LOGIN:
+       case CKRM_EVENT_USERADD:
+       case CKRM_EVENT_USERDEL:
+       case CKRM_EVENT_LISTEN_START:
+       case CKRM_EVENT_LISTEN_STOP:
+       case CKRM_EVENT_APPTAG:
+               /* no interest in this events .. */
+               break;
+
+       default:
+               /* catch all */
+               break;
+
+       case CKRM_EVENT_RECLASSIFY:
+               if ((pdata = (RBCE_DATA(tsk)))) {
+                       pdata->evaluate = 1;
+               }
+               cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_ALL, tc_classtype);
+               break;
+
+       }
+       // printk(KERN_DEBUG "tc_classify %p:%d:%s '%s' ==> %p\n",tsk,tsk->pid,
+       //                      tsk->comm,event_names[event],cls);
+
+       return cls;
+}
+
+#ifndef RBCE_EXTENSION
+static void rbce_tc_notify(int event, void *core, struct task_struct *tsk)
+{
+       printk(KERN_DEBUG "tc_manual %p:%d:%s '%s'\n", tsk, tsk->pid, tsk->comm,
+              event_names[event]);
+       if (event != CKRM_EVENT_MANUAL)
+               return;
+       rbce_tc_manual(tsk);
+}
+#endif
+
+static struct ckrm_eng_callback rbce_taskclass_ecbs = {
+       .c_interest = (unsigned long)(-1),      // set whole bitmap
+       .classify = (ce_classify_fct_t) rbce_tc_classify,
+       .class_delete = rbce_class_deletecb,
+#ifndef RBCE_EXTENSION
+       .n_interest = (1 << CKRM_EVENT_MANUAL),
+       .notify = (ce_notify_fct_t) rbce_tc_notify,
+       .always_callback = 0,
+#else
+       .n_interest = (unsigned long)(-1),      // set whole bitmap
+       .notify = (ce_notify_fct_t) rbce_tc_ext_notify,
+       .class_add = rbce_class_addcb,
+       .always_callback = 1,
+#endif
+};
+
+/*============================================================================
+ *    ACCEPTQ CLASSTYPE
+ *============================================================================*/
+
+int sc_classtype = -1;
+
+void *rbce_sc_classify(enum ckrm_event event, ...)
+{
+       // no special consideratation
+       void *result;
+       va_list args;
+       struct task_struct *tsk;
+       struct ckrm_net_struct *ns;
+
+       va_start(args, event);
+       ns = va_arg(args, struct ckrm_net_struct *);
+       tsk = va_arg(args, struct task_struct *);
+       va_end(args);
+
+       result = rbce_classify(tsk, ns, RBCE_TERMFLAG_ALL, sc_classtype);
+
+       DPRINTK(DBG_CLASSIFY_RES,
+               "==>  %d.%d.%d.%d\\%d , %p:%d:%s '%s' => %p\n",
+               NIPQUAD(ns->ns_daddrv4), ns->ns_dport,
+               tsk, tsk ? tsk->pid : 0, tsk ? tsk->comm : "-",
+               event_names[event], result);
+       return result;
+}
+
+static struct ckrm_eng_callback rbce_acceptQclass_ecbs = {
+       .c_interest = (unsigned long)(-1),
+       .always_callback = 0,   // enable during debugging only
+       .classify = (ce_classify_fct_t) & rbce_sc_classify,
+       .class_delete = rbce_class_deletecb,
+};
+
+/*============================================================================
+ *    Module Initialization ...
+ *============================================================================*/
+
+#define TASKCLASS_NAME  "taskclass"
+#define SOCKCLASS_NAME  "socket_class"
+
+struct ce_regtable_struct {
+       const char *name;
+       struct ckrm_eng_callback *cbs;
+       int *clsvar;
+};
+
+struct ce_regtable_struct ce_regtable[] = {
+       {TASKCLASS_NAME, &rbce_taskclass_ecbs, &tc_classtype},
+       {SOCKCLASS_NAME, &rbce_acceptQclass_ecbs, &sc_classtype},
+       {NULL}
+};
+
+static void unregister_classtype_engines(void)
+  {
+       int rc;
+       struct ce_regtable_struct *ceptr = ce_regtable;
+
+       while (ceptr->name) {
+               if (*ceptr->clsvar >= 0) {
+                       printk(KERN_DEBUG "ce unregister with <%s>\n",ceptr->name);
+                       while ((rc = ckrm_unregister_engine(ceptr->name)) == -EAGAIN)
+                               ;
+                       printk(KERN_DEBUG "ce unregister with <%s> rc=%d\n",ceptr->name,rc);
+                       *ceptr->clsvar = -1;
+               }
+               ceptr++;
+       }
+  }
+
+static int register_classtype_engines(void)
+{
+       int rc;
+       struct ce_regtable_struct *ceptr = ce_regtable;
+
+       while (ceptr->name) {
+               rc = ckrm_register_engine(ceptr->name, ceptr->cbs);
+               printk(KERN_DEBUG "ce register with <%s> typeId=%d\n",ceptr->name,rc);
+               if ((rc < 0) && (rc != -ENOENT)) {
+                       unregister_classtype_engines();
+                       return (rc);
+               }
+               if (rc != -ENOENT) 
+                       *ceptr->clsvar = rc;
+               ceptr++;
+       }
+       return 0;
+}
+
+// =========== /proc/sysctl/debug/rbce debug stuff =============
+
+#ifdef DEBUG
+static struct ctl_table_header *rbce_sysctl_table_header;
+
+#define CTL_RBCE_DEBUG (201)   // picked some number.. dont know algo to pick
+static struct ctl_table rbce_entry_table[] = {
+       {
+        .ctl_name = CTL_RBCE_DEBUG,
+        .procname = "rbce",
+        .data = &rbcedebug,
+        .maxlen = sizeof(int),
+        .mode = 0644,
+        .proc_handler = &proc_dointvec,
+        },
+       {0}
+};
+
+static struct ctl_table rbce_root_table[] = {
+       {
+        .ctl_name = CTL_DEBUG,
+        .procname = "debug",
+        .data = NULL,
+        .maxlen = 0,
+        .mode = 0555,
+        .child = rbce_entry_table},
+       {0}
+};
+
+static inline void start_debug(void)
+{
+       rbce_sysctl_table_header = register_sysctl_table(rbce_root_table, 1);
+}
+static inline void stop_debug(void)
+{
+       if (rbce_sysctl_table_header)
+               unregister_sysctl_table(rbce_sysctl_table_header);
+}
+
+#else
+
+static inline void start_debug(void)
+{
+}
+static inline void stop_debug(void)
+{
+}
+
+#endif                         // DEBUG
+
+extern int rbce_mkdir(struct inode *, struct dentry *, int);
+extern int rbce_rmdir(struct inode *, struct dentry *);
+extern int rbce_create_magic(void);
+extern int rbce_clear_magic(void);
+
+rbce_eng_callback_t rcfs_ecbs = {
+       rbce_mkdir,
+       rbce_rmdir,
+       rbce_create_magic,
+       rbce_clear_magic
+};
+
+/* ======================= Module definition Functions ====================== */
+
+int init_rbce(void)
+{
+       int rc, i, line;
+
+       printk(KERN_DEBUG "<1>\nInstalling \'%s\' module\n", modname);
+
+       for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
+               INIT_LIST_HEAD(&rules_list[i]);
+       }
+
+       rc = init_rbce_ext_pre();
+       line = __LINE__;
+       if (rc)
+               goto out;
+
+       rc = register_classtype_engines();
+       line = __LINE__;
+       if (rc)
+               goto out_unreg_ckrm;    // need to remove anyone opened
+
+       /* register any other class type engine here */
+
+       rc = rcfs_register_engine(&rcfs_ecbs);
+       line = __LINE__;
+       if (rc)
+               goto out_unreg_ckrm;
+
+       if (rcfs_mounted) {
+               rc = rbce_create_magic();
+               line = __LINE__;
+               if (rc)
+                       goto out_unreg_rcfs;
+       }
+
+       start_debug();
+
+       rc = init_rbce_ext_post();
+       line = __LINE__;
+       if (rc)
+               goto out_debug;
+
+       return 0;               // SUCCESS
+
+      out_debug:
+       stop_debug();
+
+      out_unreg_rcfs:
+       rcfs_unregister_engine(&rcfs_ecbs);
+      out_unreg_ckrm:
+       unregister_classtype_engines();
+       exit_rbce_ext();
+      out:
+
+       printk(KERN_DEBUG "<1>%s: error installing rc=%d line=%d\n", __FUNCTION__, rc,
+              line);
+       return rc;
+}
+
+void exit_rbce(void)
+{
+       int i;
+
+       printk(KERN_DEBUG "<1>Removing \'%s\' module\n", modname);
+
+       stop_debug();
+       exit_rbce_ext();
+
+       // Print warnings if lists are not empty, which is a bug
+       if (!list_empty(&class_list)) {
+               printk(KERN_DEBUG "exit_rbce: Class list is not empty\n");
+       }
+
+       for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
+               if (!list_empty(&rules_list[i])) {
+                       printk(KERN_DEBUG "exit_rbce: Rules list for classtype %d"
+                            " is not empty\n", i);
+               }
+       }
+
+       if (rcfs_mounted)
+               rbce_clear_magic();
+
+       rcfs_unregister_engine(&rcfs_ecbs);
+       unregister_classtype_engines();
+       free_all_private_data();
+}
+
+EXPORT_SYMBOL(get_rule);
+EXPORT_SYMBOL(rule_exists);
+EXPORT_SYMBOL(change_rule);
+EXPORT_SYMBOL(delete_rule);
+EXPORT_SYMBOL(rename_rule);
+EXPORT_SYMBOL(set_tasktag);
+
+module_init(init_rbce);
+module_exit(exit_rbce);
+
+
diff --git a/kernel/ckrm/rbce/rbcemod_ext.c b/kernel/ckrm/rbce/rbcemod_ext.c
new file mode 100644 (file)
index 0000000..3cae550
--- /dev/null
@@ -0,0 +1,620 @@
+/* Data Collection Extension to Rule-based Classification Engine (RBCE) module
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *
+ * Extension to be included into RBCE to collect delay and sample information
+ * Requires user daemon e.g. crbcedmn to activate.
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+
+/*******************************************************************************
+ *
+ *   User-Kernel Communication Channel (UKCC)
+ *   Protocol and communication handling
+ *
+ ******************************************************************************/
+
+#include <linux/relayfs_fs.h>
+
+#define PSAMPLE(pdata)    (&((pdata)->ext_data.sample))
+#define UKCC_N_SUB_BUFFERS     (4)
+#define UKCC_SUB_BUFFER_SIZE   (1<<15)
+#define UKCC_TOTAL_BUFFER_SIZE (UKCC_N_SUB_BUFFERS * UKCC_SUB_BUFFER_SIZE)
+
+#define CHANNEL_AUTO_CONT  0   /* this is during debugging only. It allows 
+                                  the module to continue sending data through 
+                                  the UKCC if space frees up vs. going into 
+                                  the recovery driven mode
+                                */
+
+enum ukcc_state {
+       UKCC_OK = 0,
+       UKCC_STANDBY = 1,
+       UKCC_FULL = 2
+};
+
+int ukcc_channel = -1;
+static enum ukcc_state chan_state = UKCC_STANDBY;
+
+inline static int ukcc_ok(void)
+{
+       return (chan_state == UKCC_OK);
+}
+
+static void ukcc_cmd_deliver(int rchan_id, char *from, u32 len);
+static void client_attached(void);
+static void client_detached(void);
+
+static int ukcc_fileop_notify(int rchan_id,
+                             struct file *filp, enum relay_fileop fileop)
+{
+       static int readers = 0;
+       if (fileop == RELAY_FILE_OPEN) {
+               // printk(KERN_DEBUG "got fileop_notify RELAY_FILE_OPEN for file %p\n", 
+               //              filp);
+               if (readers) {
+                       printk(KERN_DEBUG "only one client allowed, backoff .... \n");
+                       return -EPERM;
+               }
+               if (!try_module_get(THIS_MODULE))
+                       return -EPERM;
+               readers++;
+               client_attached();
+
+       } else if (fileop == RELAY_FILE_CLOSE) {
+               // printk(KERN_DEBUG "got fileop_notify RELAY_FILE_CLOSE for file %p\n", 
+               //              filp);
+               client_detached();
+               readers--;
+               module_put(THIS_MODULE);
+       }
+       return 0;
+}
+
+static int create_ukcc_channel(void)
+{
+       static struct rchan_callbacks ukcc_callbacks = {
+               .buffer_start = NULL,
+               .buffer_end = NULL,
+               .deliver = NULL,
+               .user_deliver = ukcc_cmd_deliver,
+               .needs_resize = NULL,
+               .fileop_notify = ukcc_fileop_notify,
+       };
+
+       u32 channel_flags =
+           RELAY_USAGE_GLOBAL | RELAY_SCHEME_ANY | RELAY_TIMESTAMP_ANY;
+
+       // notify on subbuffer full (through poll)
+       channel_flags |= RELAY_DELIVERY_BULK;
+       // channel_flags     |= RELAY_DELIVERY_PACKET;
+       // avoid overwrite, otherwise recovery will be nasty...
+       channel_flags |= RELAY_MODE_NO_OVERWRITE;
+
+       ukcc_channel = relay_open(CRBCE_UKCC_NAME,
+                                 UKCC_SUB_BUFFER_SIZE,
+                                 UKCC_N_SUB_BUFFERS,
+                                 channel_flags,
+                                 &ukcc_callbacks, 0, 0, 0, 0, 0, 0, NULL, 0);
+       if (ukcc_channel < 0)
+               printk(KERN_DEBUG "crbce: ukcc creation failed, errcode: %d\n",
+                      ukcc_channel);
+       else
+               printk(KERN_DEBUG "crbce: ukcc created (%u KB)\n",
+                      UKCC_TOTAL_BUFFER_SIZE >> 10);
+       return ukcc_channel;
+}
+
+static inline void close_ukcc_channel(void)
+{
+       if (ukcc_channel >= 0) {
+               relay_close(ukcc_channel);
+               ukcc_channel = -1;
+               chan_state = UKCC_STANDBY;
+       }
+}
+
+#define rec_set_hdr(r,t,p)      ((r)->hdr.type = (t), (r)->hdr.pid = (p))
+#define rec_set_timehdr(r,t,p,c)  (rec_set_hdr(r,t,p), \
+(r)->hdr.jiffies = jiffies, (r)->hdr.cls=(unsigned long)(c) )
+
+#if CHANNEL_AUTO_CONT
+
+/* we only provide this for debugging.. it allows us to send records
+ * based on availability in the channel when the UKCC stalles rather
+ * going through the UKCC recovery protocol
+ */
+
+#define rec_send_len(r,l)                                              \
+       do {                                                            \
+               int chan_wasok = (chan_state == UKCC_OK);               \
+                int chan_isok = (relay_write(ukcc_channel,             \
+                                            (r),(l),-1,NULL) > 0);     \
+               chan_state = chan_isok ? UKCC_OK : UKCC_STANDBY;        \
+               if (chan_wasok && !chan_isok) {                         \
+                       printk(KERN_DEBUG "Channel stalled\n");                 \
+               } else if (!chan_wasok && chan_isok) {                  \
+                       printk(KERN_DEBUG "Channel continues\n");                       \
+               }                                                       \
+       } while (0)
+
+#define rec_send(r)    rec_send_len(r,sizeof(*(r)))
+
+#else
+
+/* Default UKCC channel protocol. 
+ * Though a UKCC buffer overflow should not happen ever, it is possible iff 
+ * the user daemon stops reading for some reason. Hence we provide a simple 
+ * protocol based on 3 states 
+ *     UKCC_OK      :=         channel is active and properly working. When a channel 
+ *                     write fails we move to state CHAN_FULL.
+ *     UKCC_FULL    :=         channel is active, but the last send_rec has failed. As
+ *                      a result we will try to send an indication to the daemon
+ *                             that this has happened. When that succeeds, we move to 
+ *                     state UKCC_STANDBY.
+ *     UKCC_STANDBY :=         we are waiting to be restarted by the user daemon 
+ *
+ */
+
+static void ukcc_full(void)
+{
+       static spinlock_t ukcc_state_lock = SPIN_LOCK_UNLOCKED;
+       /* protect transition from OK -> FULL to ensure only one record is sent,
+          rest we do not need to protect, protocol implies that. we keep the 
+          channel OK until
+       */
+       int send = 0;
+       spin_lock(&ukcc_state_lock);
+       if ((send = (chan_state != UKCC_STANDBY)))
+               chan_state = UKCC_STANDBY;      /* assume we can send */
+       spin_unlock(&ukcc_state_lock);
+
+       if (send) {
+               struct crbce_ukcc_full rec;
+               rec_set_timehdr(&rec, CRBCE_REC_UKCC_FULL, 0, 0);
+               if (relay_write(ukcc_channel, &rec, 
+                               sizeof(rec), -1, NULL) <= 0) {
+                       /* channel is remains full .. try with next one */
+                       chan_state = UKCC_FULL;
+               }
+       }
+}
+
+#define rec_send_len(r,l)                                              \
+       do {                                                            \
+               switch (chan_state) {                                   \
+               case UKCC_OK:                                           \
+                       if (relay_write(ukcc_channel,(r),               \
+                               (l),-1,NULL) > 0)                       \
+                               break;                                  \
+               case UKCC_FULL:                                         \
+                       ukcc_full();                                    \
+                       break;                                          \
+               default:                                                \
+                       break;                                          \
+               }                                                       \
+       } while (0)
+
+#define rec_send(r)    rec_send_len(r,sizeof(*(r)))
+
+#endif
+
+/******************************************************************************
+ *
+ *  Callbacks for the CKRM engine. 
+ *    In each we do the necessary classification and event record generation
+ *    We generate 3 kind of records in the callback 
+ *    (a) FORK                 send the pid, the class and the ppid
+ *    (b) RECLASSIFICATION     send the pid, the class and < sample data + 
+ *                             delay data >
+ *    (b) EXIT                 send the pid
+ *
+ ******************************************************************************/
+
+int delta_mode = 0;
+
+static inline void copy_delay(struct task_delay_info *delay,
+                             struct task_struct *tsk)
+{
+       *delay = tsk->delays;
+}
+
+static inline void zero_delay(struct task_delay_info *delay)
+{
+       memset(delay, 0, sizeof(struct task_delay_info));       
+       /* we need to think about doing this 64-bit atomic */
+}
+
+static inline void zero_sample(struct task_sample_info *sample)
+{
+       memset(sample, 0, sizeof(struct task_sample_info));     
+       /* we need to think about doing this 64-bit atomic */
+}
+
+static inline int check_zero(void *ptr, int len)
+{
+       int iszero = 1;
+       int i;
+       unsigned long *uptr = (unsigned long *)ptr;
+
+       for (i = len / sizeof(unsigned long); i-- && iszero; uptr++)    
+               // assume its rounded 
+               iszero &= (*uptr == 0);
+       return iszero;
+}
+
+static inline int check_not_zero(void *ptr, int len)
+{
+       int i;
+       unsigned long *uptr = (unsigned long *)ptr;
+
+       for (i = len / sizeof(unsigned long); i--; uptr++)      
+               // assume its rounded 
+               if (*uptr)
+                       return 1;
+       return 0;
+}
+
+static inline int sample_changed(struct task_sample_info *s)
+{
+       return check_not_zero(s, sizeof(*s));
+}
+static inline int delay_changed(struct task_delay_info *d)
+{
+       return check_not_zero(d, sizeof(*d));
+}
+
+static inline int
+send_task_record(struct task_struct *tsk, int event,
+                struct ckrm_core_class *core, int send_forced)
+{
+       struct crbce_rec_task_data rec;
+       struct rbce_private_data *pdata;
+       int send = 0;
+
+       if (!ukcc_ok())
+               return 0;
+       pdata = RBCE_DATA(tsk);
+       if (pdata == NULL) {
+               // printk(KERN_DEBUG "send [%d]<%s>: no pdata\n",tsk->pid,tsk->comm);
+               return 0;
+       }
+       if (send_forced || (delta_mode == 0)
+           || sample_changed(PSAMPLE(RBCE_DATA(tsk)))
+           || delay_changed(&tsk->delays)) {
+               rec_set_timehdr(&rec, event, tsk->pid,
+                               core ? core : (struct ckrm_core_class *)tsk->
+                               taskclass);
+               rec.sample = *PSAMPLE(RBCE_DATA(tsk));
+               copy_delay(&rec.delay, tsk);
+               rec_send(&rec);
+               if (delta_mode || send_forced) {
+                       // on reclassify or delta mode reset the counters  
+                       zero_sample(PSAMPLE(RBCE_DATA(tsk)));
+                       zero_delay(&tsk->delays);
+               }
+               send = 1;
+       }
+       return send;
+}
+
+static inline void send_exit_notification(struct task_struct *tsk)
+{
+       send_task_record(tsk, CRBCE_REC_EXIT, NULL, 1);
+}
+
+static inline void
+rbce_tc_ext_notify(int event, void *core, struct task_struct *tsk)
+{
+       struct crbce_rec_fork rec;
+
+       switch (event) {
+       case CKRM_EVENT_FORK:
+               if (ukcc_ok()) {
+                       rec.ppid = tsk->parent->pid;
+                       rec_set_timehdr(&rec, CKRM_EVENT_FORK, tsk->pid, core);
+                       rec_send(&rec);
+               }
+               break;
+       case CKRM_EVENT_MANUAL:
+               rbce_tc_manual(tsk);
+
+       default:
+               send_task_record(tsk, event, (struct ckrm_core_class *)core, 1);
+               break;
+       }
+}
+
+/*====================== end classification engine =======================*/
+
+static void sample_task_data(unsigned long unused);
+
+struct timer_list sample_timer = {.expires = 0,.function = sample_task_data };
+unsigned long timer_interval_length = (250 * HZ) / 1000;
+
+inline void stop_sample_timer(void)
+{
+       if (sample_timer.expires > 0) {
+               del_timer_sync(&sample_timer);
+               sample_timer.expires = 0;
+       }
+}
+
+inline void start_sample_timer(void)
+{
+       if (timer_interval_length > 0) {
+               sample_timer.expires =
+                   jiffies + (timer_interval_length * HZ) / 1000;
+               add_timer(&sample_timer);
+       }
+}
+
+static void send_task_data(void)
+{
+       struct crbce_rec_data_delim limrec;
+       struct task_struct *proc, *thread;
+       int sendcnt = 0;
+       int taskcnt = 0;
+       limrec.is_stop = 0;
+       rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
+       rec_send(&limrec);
+
+       read_lock(&tasklist_lock);
+       do_each_thread(proc, thread) {
+               taskcnt++;
+               task_lock(thread);
+               sendcnt += send_task_record(thread, CRBCE_REC_SAMPLE, NULL, 0);
+               task_unlock(thread);
+       } while_each_thread(proc, thread);
+       read_unlock(&tasklist_lock);
+
+       limrec.is_stop = 1;
+       rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
+       rec_send(&limrec);
+
+       // printk(KERN_DEBUG "send_task_data mode=%d t#=%d s#=%d\n",
+       //              delta_mode,taskcnt,sendcnt);
+}
+
+static void notify_class_action(struct rbce_class *cls, int action)
+{
+       struct crbce_class_info cinfo;
+       int len;
+
+       rec_set_timehdr(&cinfo, CRBCE_REC_CLASS_INFO, 0, cls->classobj);
+       cinfo.action = action;
+       len = strnlen(cls->obj.name, CRBCE_MAX_CLASS_NAME_LEN - 1);
+       memcpy(&cinfo.name, cls->obj.name, len);
+       cinfo.name[len] = '\0';
+       len++;
+       cinfo.namelen = len;
+
+       len += sizeof(cinfo) - CRBCE_MAX_CLASS_NAME_LEN;
+       rec_send_len(&cinfo, len);
+}
+
+static void send_classlist(void)
+{
+       struct rbce_class *cls;
+
+       read_lock(&global_rwlock);
+       list_for_each_entry(cls, &class_list, obj.link) {
+               notify_class_action(cls, 1);
+       }
+       read_unlock(&global_rwlock);
+}
+
+/*
+ *  resend_task_info 
+ * 
+ *  This function resends all essential task information to the client.
+ *  
+ */
+static void resend_task_info(void)
+{
+       struct crbce_rec_data_delim limrec;
+       struct crbce_rec_fork rec;
+       struct task_struct *proc, *thread;
+
+       send_classlist();       // first send available class information
+
+       limrec.is_stop = 2;
+       rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
+       rec_send(&limrec);
+
+       write_lock(&tasklist_lock);     // avoid any mods during this phase 
+       do_each_thread(proc, thread) {
+               if (ukcc_ok()) {
+                       rec.ppid = thread->parent->pid;
+                       rec_set_timehdr(&rec, CRBCE_REC_TASKINFO, thread->pid,
+                                       thread->taskclass);
+                       rec_send(&rec);
+               }
+       }
+       while_each_thread(proc, thread);
+       write_unlock(&tasklist_lock);
+
+       limrec.is_stop = 3;
+       rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
+       rec_send(&limrec);
+}
+
+extern int task_running_sys(struct task_struct *);
+
+static void add_all_private_data(void)
+{
+       struct task_struct *proc, *thread;
+
+       write_lock(&tasklist_lock);
+       do_each_thread(proc, thread) {
+               if (RBCE_DATA(thread) == NULL)
+                       RBCE_DATAP(thread) = create_private_data(NULL, 0);
+       }
+       while_each_thread(proc, thread);
+       write_unlock(&tasklist_lock);
+}
+
+static void sample_task_data(unsigned long unused)
+{
+       struct task_struct *proc, *thread;
+
+       int run = 0;
+       int wait = 0;
+       read_lock(&tasklist_lock);
+       do_each_thread(proc, thread) {
+               struct rbce_private_data *pdata = RBCE_DATA(thread);
+
+               if (pdata == NULL) {
+                       // some wierdo race condition .. simply ignore 
+                       continue;
+               }
+               if (thread->state == TASK_RUNNING) {
+                       if (task_running_sys(thread)) {
+                               atomic_inc((atomic_t *) &
+                                          (PSAMPLE(pdata)->cpu_running));
+                               run++;
+                       } else {
+                               atomic_inc((atomic_t *) &
+                                          (PSAMPLE(pdata)->cpu_waiting));
+                               wait++;
+                       }
+               }
+               /* update IO state */
+               if (thread->flags & PF_IOWAIT) {
+                       if (thread->flags & PF_MEMIO)
+                               atomic_inc((atomic_t *) &
+                                          (PSAMPLE(pdata)->memio_delayed));
+                       else
+                               atomic_inc((atomic_t *) &
+                                          (PSAMPLE(pdata)->io_delayed));
+               }
+       }
+       while_each_thread(proc, thread);
+       read_unlock(&tasklist_lock);
+//      printk(KERN_DEBUG "sample_timer: run=%d wait=%d\n",run,wait);
+       start_sample_timer();
+}
+
+static void ukcc_cmd_deliver(int rchan_id, char *from, u32 len)
+{
+       struct crbce_command *cmdrec = (struct crbce_command *)from;
+       struct crbce_cmd_done cmdret;
+       int rc = 0;
+
+//      printk(KERN_DEBUG "ukcc_cmd_deliver: %d %d len=%d:%d\n",cmdrec->type, 
+//             cmdrec->cmd,cmdrec->len,len);
+
+       cmdrec->len = len;      // add this to reflection so the user doesn't 
+                               // accidently write the wrong length and the 
+                               // protocol is getting screwed up 
+
+       if (cmdrec->type != CRBCE_REC_KERNEL_CMD) {
+               rc = EINVAL;
+               goto out;
+       }
+
+       switch (cmdrec->cmd) {
+       case CRBCE_CMD_SET_TIMER:
+               {
+                       struct crbce_cmd_settimer *cptr =
+                           (struct crbce_cmd_settimer *)cmdrec;
+                       if (len != sizeof(*cptr)) {
+                               rc = EINVAL;
+                               break;
+                       }
+                       stop_sample_timer();
+                       timer_interval_length = cptr->interval;
+                       if ((timer_interval_length > 0)
+                           && (timer_interval_length < 10))
+                               timer_interval_length = 10;   
+                               // anything finer can create problems 
+                       printk(KERN_INFO "CRBCE set sample collect timer %lu\n",
+                              timer_interval_length);
+                       start_sample_timer();
+                       break;
+               }
+       case CRBCE_CMD_SEND_DATA:
+               {
+                       struct crbce_cmd_send_data *cptr =
+                           (struct crbce_cmd_send_data *)cmdrec;
+                       if (len != sizeof(*cptr)) {
+                               rc = EINVAL;
+                               break;
+                       }
+                       delta_mode = cptr->delta_mode;
+                       send_task_data();
+                       break;
+               }
+       case CRBCE_CMD_START:
+               add_all_private_data();
+               chan_state = UKCC_OK;
+               resend_task_info();
+               break;
+
+       case CRBCE_CMD_STOP:
+               chan_state = UKCC_STANDBY;
+               free_all_private_data();
+               break;
+
+       default:
+               rc = EINVAL;
+               break;
+       }
+
+      out:
+       cmdret.hdr.type = CRBCE_REC_KERNEL_CMD_DONE;
+       cmdret.hdr.cmd = cmdrec->cmd;
+       cmdret.rc = rc;
+       rec_send(&cmdret);
+//      printk(KERN_DEBUG "ukcc_cmd_deliver ACK: %d %d rc=%d %d\n",cmdret.hdr.type,
+//                     cmdret.hdr.cmd,rc,sizeof(cmdret));
+}
+
+static void client_attached(void)
+{
+       printk(KERN_DEBUG "client [%d]<%s> attached to UKCC\n", current->pid,
+              current->comm);
+       relay_reset(ukcc_channel);
+}
+
+static void client_detached(void)
+{
+       printk(KERN_DEBUG "client [%d]<%s> detached to UKCC\n", current->pid,
+              current->comm);
+       chan_state = UKCC_STANDBY;
+       stop_sample_timer();
+       relay_reset(ukcc_channel);
+       free_all_private_data();
+}
+
+static int init_rbce_ext_pre(void)
+{
+       int rc;
+
+       rc = create_ukcc_channel();
+       return ((rc < 0) ? rc : 0);
+}
+
+static int init_rbce_ext_post(void)
+{
+       init_timer(&sample_timer);
+       return 0;
+}
+
+static void exit_rbce_ext(void)
+{
+       stop_sample_timer();
+       close_ukcc_channel();
+}
diff --git a/kernel/ckrm/rbce/token.c b/kernel/ckrm/rbce/token.c
new file mode 100644 (file)
index 0000000..32446fb
--- /dev/null
@@ -0,0 +1,301 @@
+/* Tokens for Rule-based Classification Engine (RBCE) and
+ * Consolidated RBCE module code (combined)
+ *
+ * Copyright (C) Hubertus Franke, IBM Corp. 2003
+ *           (C) Chandra Seetharaman, IBM Corp. 2003
+ *           (C) Vivek Kashyap, IBM Corp. 2004 
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 
+ *
+ */
+
+#include <linux/parser.h>
+#include <linux/ctype.h>
+
+enum rule_token_t {
+       TOKEN_PATH,
+       TOKEN_CMD,
+       TOKEN_ARGS,
+       TOKEN_RUID_EQ,
+       TOKEN_RUID_LT,
+       TOKEN_RUID_GT,
+       TOKEN_RUID_NOT,
+       TOKEN_RGID_EQ,
+       TOKEN_RGID_LT,
+       TOKEN_RGID_GT,
+       TOKEN_RGID_NOT,
+       TOKEN_EUID_EQ,
+       TOKEN_EUID_LT,
+       TOKEN_EUID_GT,
+       TOKEN_EUID_NOT,
+       TOKEN_EGID_EQ,
+       TOKEN_EGID_LT,
+       TOKEN_EGID_GT,
+       TOKEN_EGID_NOT,
+       TOKEN_XID_EQ,
+       TOKEN_XID_LT,
+       TOKEN_XID_GT,
+       TOKEN_XID_NOT,
+       TOKEN_TAG,
+       TOKEN_IPV4,
+       TOKEN_IPV6,
+       TOKEN_DEP,
+       TOKEN_DEP_ADD,
+       TOKEN_DEP_DEL,
+       TOKEN_ORDER,
+       TOKEN_CLASS,
+       TOKEN_STATE,
+       TOKEN_INVALID
+};
+
+int token_to_ruleop[TOKEN_INVALID + 1] = {
+       [TOKEN_PATH] = RBCE_RULE_CMD_PATH,
+       [TOKEN_CMD] = RBCE_RULE_CMD,
+       [TOKEN_ARGS] = RBCE_RULE_ARGS,
+       [TOKEN_RUID_EQ] = RBCE_RULE_REAL_UID,
+       [TOKEN_RUID_LT] = RBCE_RULE_REAL_UID,
+       [TOKEN_RUID_GT] = RBCE_RULE_REAL_UID,
+       [TOKEN_RUID_NOT] = RBCE_RULE_REAL_UID,
+       [TOKEN_RGID_EQ] = RBCE_RULE_REAL_GID,
+       [TOKEN_RGID_LT] = RBCE_RULE_REAL_GID,
+       [TOKEN_RGID_GT] = RBCE_RULE_REAL_GID,
+       [TOKEN_RGID_NOT] = RBCE_RULE_REAL_GID,
+       [TOKEN_EUID_EQ] = RBCE_RULE_EFFECTIVE_UID,
+       [TOKEN_EUID_LT] = RBCE_RULE_EFFECTIVE_UID,
+       [TOKEN_EUID_GT] = RBCE_RULE_EFFECTIVE_UID,
+       [TOKEN_EUID_NOT] = RBCE_RULE_EFFECTIVE_UID,
+       [TOKEN_EGID_EQ] = RBCE_RULE_EFFECTIVE_GID,
+       [TOKEN_EGID_LT] = RBCE_RULE_EFFECTIVE_GID,
+       [TOKEN_EGID_GT] = RBCE_RULE_EFFECTIVE_GID,
+       [TOKEN_EGID_NOT] = RBCE_RULE_EFFECTIVE_GID,
+       [TOKEN_XID_EQ]  = RBCE_RULE_XID,
+       [TOKEN_XID_LT]  = RBCE_RULE_XID,
+       [TOKEN_XID_GT]  = RBCE_RULE_XID,
+       [TOKEN_XID_NOT] = RBCE_RULE_XID,
+       [TOKEN_TAG] = RBCE_RULE_APP_TAG,
+       [TOKEN_IPV4] = RBCE_RULE_IPV4,
+       [TOKEN_IPV6] = RBCE_RULE_IPV6,
+       [TOKEN_DEP] = RBCE_RULE_DEP_RULE,
+       [TOKEN_DEP_ADD] = RBCE_RULE_DEP_RULE,
+       [TOKEN_DEP_DEL] = RBCE_RULE_DEP_RULE,
+       [TOKEN_ORDER] = RBCE_RULE_INVALID,
+       [TOKEN_CLASS] = RBCE_RULE_INVALID,
+       [TOKEN_STATE] = RBCE_RULE_INVALID,
+};
+
+enum op_token {
+       TOKEN_OP_EQUAL = RBCE_EQUAL,
+       TOKEN_OP_NOT = RBCE_NOT,
+       TOKEN_OP_LESS_THAN = RBCE_LESS_THAN,
+       TOKEN_OP_GREATER_THAN = RBCE_GREATER_THAN,
+       TOKEN_OP_DEP,
+       TOKEN_OP_DEP_ADD,
+       TOKEN_OP_DEP_DEL,
+       TOKEN_OP_ORDER,
+       TOKEN_OP_CLASS,
+       TOKEN_OP_STATE,
+};
+
+enum op_token token_to_operator[TOKEN_INVALID + 1] = {
+       [TOKEN_PATH] = TOKEN_OP_EQUAL,
+       [TOKEN_CMD] = TOKEN_OP_EQUAL,
+       [TOKEN_ARGS] = TOKEN_OP_EQUAL,
+       [TOKEN_RUID_EQ] = TOKEN_OP_EQUAL,
+       [TOKEN_RUID_LT] = TOKEN_OP_LESS_THAN,
+       [TOKEN_RUID_GT] = TOKEN_OP_GREATER_THAN,
+       [TOKEN_RUID_NOT] = TOKEN_OP_NOT,
+       [TOKEN_RGID_EQ] = TOKEN_OP_EQUAL,
+       [TOKEN_RGID_LT] = TOKEN_OP_LESS_THAN,
+       [TOKEN_RGID_GT] = TOKEN_OP_GREATER_THAN,
+       [TOKEN_RGID_NOT] = TOKEN_OP_NOT,
+       [TOKEN_EUID_EQ] = TOKEN_OP_EQUAL,
+       [TOKEN_EUID_LT] = TOKEN_OP_LESS_THAN,
+       [TOKEN_EUID_GT] = TOKEN_OP_GREATER_THAN,
+       [TOKEN_EUID_NOT] = TOKEN_OP_NOT,
+       [TOKEN_EGID_EQ] = TOKEN_OP_EQUAL,
+       [TOKEN_EGID_LT] = TOKEN_OP_LESS_THAN,
+       [TOKEN_EGID_GT] = TOKEN_OP_GREATER_THAN,
+       [TOKEN_EGID_NOT] = TOKEN_OP_NOT,
+       [TOKEN_XID_EQ]  = TOKEN_OP_EQUAL,
+       [TOKEN_XID_LT]  = TOKEN_OP_LESS_THAN,
+       [TOKEN_XID_GT]  = TOKEN_OP_GREATER_THAN,
+       [TOKEN_XID_NOT] = TOKEN_OP_NOT,
+       [TOKEN_TAG] = TOKEN_OP_EQUAL,
+       [TOKEN_IPV4] = TOKEN_OP_EQUAL,
+       [TOKEN_IPV6] = TOKEN_OP_EQUAL,
+       [TOKEN_DEP] = TOKEN_OP_DEP,
+       [TOKEN_DEP_ADD] = TOKEN_OP_DEP_ADD,
+       [TOKEN_DEP_DEL] = TOKEN_OP_DEP_DEL,
+       [TOKEN_ORDER] = TOKEN_OP_ORDER,
+       [TOKEN_CLASS] = TOKEN_OP_CLASS,
+       [TOKEN_STATE] = TOKEN_OP_STATE
+};
+
+static match_table_t tokens = {
+       {TOKEN_PATH, "path=%s"},
+       {TOKEN_CMD, "cmd=%s"},
+       {TOKEN_ARGS, "args=%s"},
+       {TOKEN_RUID_EQ, "uid=%d"},
+       {TOKEN_RUID_LT, "uid<%d"},
+       {TOKEN_RUID_GT, "uid>%d"},
+       {TOKEN_RUID_NOT, "uid!%d"},
+       {TOKEN_RGID_EQ, "gid=%d"},
+       {TOKEN_RGID_LT, "gid<%d"},
+       {TOKEN_RGID_GT, "gid>%d"},
+       {TOKEN_RGID_NOT, "gid!d"},
+       {TOKEN_EUID_EQ, "euid=%d"},
+       {TOKEN_EUID_LT, "euid<%d"},
+       {TOKEN_EUID_GT, "euid>%d"},
+       {TOKEN_EUID_NOT, "euid!%d"},
+       {TOKEN_EGID_EQ, "egid=%d"},
+       {TOKEN_EGID_LT, "egid<%d"},
+       {TOKEN_EGID_GT, "egid>%d"},
+       {TOKEN_EGID_NOT, "egid!%d"},
+       {TOKEN_XID_EQ,  "xid=%d"},
+       {TOKEN_XID_LT,  "xid<%d"},
+       {TOKEN_XID_GT,  "xid>%d"},
+       {TOKEN_XID_NOT, "xid!%d"},
+       {TOKEN_TAG, "tag=%s"},
+       {TOKEN_IPV4, "ipv4=%s"},
+       {TOKEN_IPV6, "ipv6=%s"},
+       {TOKEN_DEP, "depend=%s"},
+       {TOKEN_DEP_ADD, "+depend=%s"},
+       {TOKEN_DEP_DEL, "-depend=%s"},
+       {TOKEN_ORDER, "order=%d"},
+       {TOKEN_CLASS, "class=%s"},
+       {TOKEN_STATE, "state=%d"},
+       {TOKEN_INVALID, NULL}
+};
+
+/*
+ * return -EINVAL in case of failures
+ * returns number of terms in terms on success.
+ * never returns 0.
+ */
+
+static int
+rules_parse(char *rule_defn, struct rbce_rule_term **rterms, int *term_mask)
+{
+       char *p, *rp = rule_defn;
+       int option, i = 0, nterms;
+       struct rbce_rule_term *terms;
+
+       *rterms = NULL;
+       *term_mask = 0;
+       if (!rule_defn)
+               return -EINVAL;
+
+       nterms = 0;
+       while (*rp++) {
+               if (*rp == '>' || *rp == '<' || *rp == '=' || *rp == '!') {
+                       nterms++;
+               }
+       }
+
+       if (!nterms) {
+               return -EINVAL;
+       }
+
+       terms = kmalloc(nterms * sizeof(struct rbce_rule_term), GFP_KERNEL);
+       if (!terms) {
+               return -ENOMEM;
+       }
+
+       while ((p = strsep(&rule_defn, ",")) != NULL) {
+
+               substring_t args[MAX_OPT_ARGS];
+               int token;
+
+               while (*p && isspace(*p))
+                       p++;
+               if (!*p)
+                       continue;
+
+               token = match_token(p, tokens, args);
+
+               terms[i].op = token_to_ruleop[token];
+               terms[i].operator = token_to_operator[token];
+               switch (token) {
+
+               case TOKEN_PATH:
+               case TOKEN_CMD:
+               case TOKEN_ARGS:
+               case TOKEN_TAG:
+               case TOKEN_IPV4:
+               case TOKEN_IPV6:
+                       // all these tokens can be specified only once
+                       if (*term_mask & (1 << terms[i].op)) {
+                               nterms = -EINVAL;
+                               goto out;
+                       }
+               /*FALLTHRU*/ case TOKEN_CLASS:
+               case TOKEN_DEP:
+               case TOKEN_DEP_ADD:
+               case TOKEN_DEP_DEL:
+                       terms[i].u.string = args->from;
+                       break;
+
+               case TOKEN_RUID_EQ:
+               case TOKEN_RUID_LT:
+               case TOKEN_RUID_GT:
+               case TOKEN_RUID_NOT:
+               case TOKEN_RGID_EQ:
+               case TOKEN_RGID_LT:
+               case TOKEN_RGID_GT:
+               case TOKEN_RGID_NOT:
+               case TOKEN_EUID_EQ:
+               case TOKEN_EUID_LT:
+               case TOKEN_EUID_GT:
+               case TOKEN_EUID_NOT:
+               case TOKEN_EGID_EQ:
+               case TOKEN_EGID_LT:
+               case TOKEN_EGID_GT:
+               case TOKEN_EGID_NOT:
+               case TOKEN_XID_EQ:
+               case TOKEN_XID_LT:
+               case TOKEN_XID_GT:
+               case TOKEN_XID_NOT:
+                       // all these tokens can be specified only once
+                       if (*term_mask & (1 << terms[i].op)) {
+                               nterms = -EINVAL;
+                               goto out;
+                       }
+               /*FALLTHRU*/ case TOKEN_ORDER:
+               case TOKEN_STATE:
+                       if (match_int(args, &option)) {
+                               nterms = -EINVAL;
+                               goto out;
+                       }
+                       terms[i].u.id = option;
+                       break;
+               default:
+                       nterms = -EINVAL;
+                       goto out;
+               }
+               *term_mask |= (1 << terms[i].op);
+               i++;
+       }
+       *rterms = terms;
+
+      out:
+       if (nterms < 0) {
+               kfree(terms);
+               *term_mask = 0;
+       }                       /* else {
+                                  for (i = 0; i < nterms; i++) {
+                                  printk(KERN_DEBUG "token: i %d; op %d, operator %d, str %ld\n",
+                                  i, terms[i].op, terms[i].operator, terms[i].u.id);
+                                  }
+                                  } */
+       return nterms;
+}
diff --git a/kernel/ckrm_classqueue.c b/kernel/ckrm_classqueue.c
new file mode 100644 (file)
index 0000000..0400844
--- /dev/null
@@ -0,0 +1,211 @@
+/* kernel/ckrm_classqueue.c : implements the class queue
+ *
+ * Copyright (C) Haoqiang Zheng, IBM Corp. 2003
+ *           (C) Hubertus Franke, IBM Corp. 2003
+ *
+ * Class queue functionality for CKRM cpu controller
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+/* Changes
+ *
+ * Aug 28, 2003
+ *        Created.
+ * July 08, 2004
+ *        classqueue now has a fixed size
+ *        major clean up
+ *        function/structure names are changed to more intuitive ones
+ */
+#include <linux/sched.h>
+#include <linux/ckrm_classqueue.h>
+
+#define cq_nr_member(cq) (cq->array.nr_active)
+
+/**
+ * get_index - translate the logical priority to the real index in the queue
+ * 
+ * validate the position
+ * a valid prio is [cq->base,cq->base + size -1]
+ */
+static inline unsigned long get_index(struct classqueue_struct *cq, int *prio)
+{
+       unsigned long index;
+       int max_prio;
+
+       if (!cq_nr_member(cq))
+               return 0;
+
+       max_prio = cq->base + (CLASSQUEUE_SIZE - 1);
+       if (*prio > max_prio)
+               *prio = max_prio;
+       if (*prio < cq->base)
+               *prio = cq->base;
+
+               index = (cq->base_offset + (*prio - cq->base)) ;
+       if (index >= CLASSQUEUE_SIZE)
+               index -= CLASSQUEUE_SIZE;
+
+       return index;
+}
+
+/**
+ * initialize a class queue object
+ */
+int classqueue_init(struct classqueue_struct *cq)
+{
+       int i;
+       struct cq_prio_array *array;
+
+       array = &cq->array;
+       for (i = 0; i < CLASSQUEUE_SIZE; i++) {
+               INIT_LIST_HEAD(array->queue + i);
+               __clear_bit(i, array->bitmap);
+       }
+       // delimiter for bitsearch
+       __set_bit(CLASSQUEUE_SIZE, array->bitmap);
+       array->nr_active = 0;
+
+       cq->base = 0;
+       cq->base_offset = -1;   //not valid yet
+
+       return 0;
+}
+
+/**
+ *classqueue_enqueue - add the class to classqueue based on its prio
+ */
+void classqueue_enqueue(struct classqueue_struct *cq,
+                       cq_node_t * node, int prio)
+{
+       int index;
+
+       //get real index
+       if (cq_nr_member(cq)) {
+               index = get_index(cq, &prio);
+       } else {                //the first one
+               cq->base = prio;
+               cq->base_offset = 0;
+               index = 0;
+       }
+
+       //add to the queue
+       list_add(&(node->list), &cq->array.queue[index]);
+       __set_bit(index, cq->array.bitmap);
+       cq->array.nr_active++;
+
+       node->index = index;
+       node->prio = prio;
+}
+
+void classqueue_dequeue(struct classqueue_struct *cq, cq_node_t * node)
+{
+       //delete from queue
+       list_del_init(&(node->list));
+       cq->array.nr_active--;
+
+       //check clear the bitmap
+       if (list_empty(&cq->array.queue[node->index]))
+               __clear_bit(node->index, cq->array.bitmap);
+}
+
+void classqueue_update_prio(struct classqueue_struct *cq,
+                           cq_node_t * node, int new_pos)
+{
+       int index;
+
+       if (! cls_in_classqueue(node)) 
+               return;
+
+       index = get_index(cq, &new_pos);
+       node->prio = new_pos;
+
+       //remove from the original position
+       list_del_init(&(node->list));
+       if (list_empty(&cq->array.queue[node->index]))
+               __clear_bit(node->index, cq->array.bitmap);
+       
+       //add to new positon, round robin for classes with same priority
+       list_add_tail(&(node->list), &cq->array.queue[index]);
+       __set_bit(index, cq->array.bitmap);     
+       node->index = index;
+}
+
+/**
+ *classqueue_get_min_prio: return the priority of the last node in queue
+ *
+ * this function can be called without runqueue lock held
+ */
+static inline int classqueue_get_min_prio(struct classqueue_struct *cq)
+{
+       cq_node_t *result = NULL;
+       int pos;
+
+       /* 
+        * search over the bitmap to get the first class in the queue
+        */
+       pos = find_next_bit(cq->array.bitmap, CLASSQUEUE_SIZE, cq->base_offset);
+       //do circular search from the beginning
+       if (pos >= CLASSQUEUE_SIZE) 
+               pos = find_first_bit(cq->array.bitmap, CLASSQUEUE_SIZE);
+
+       if (pos < CLASSQUEUE_SIZE) {
+               result = list_entry(cq->array.queue[pos].next, cq_node_t, list);
+               if (list_empty(&cq->array.queue[pos]))
+                       result = NULL;
+       }
+       if (result)
+               return result->prio;
+       else 
+               return 0;
+}
+
+/**
+ * this function must be called with runqueue lock held
+ */
+cq_node_t *classqueue_get_head(struct classqueue_struct *cq)
+{
+       cq_node_t *result = NULL;
+       int pos;
+
+       /* 
+        * search over the bitmap to get the first class in the queue
+        */
+       pos = find_next_bit(cq->array.bitmap, CLASSQUEUE_SIZE, cq->base_offset);
+       //do circular search from the beginning
+       if (pos >= CLASSQUEUE_SIZE) 
+               pos = find_first_bit(cq->array.bitmap, CLASSQUEUE_SIZE);
+
+       if (pos < CLASSQUEUE_SIZE) {
+               BUG_ON(list_empty(&cq->array.queue[pos]));
+               result = list_entry(cq->array.queue[pos].next, cq_node_t, list);
+       }
+       return result;
+}
+
+/**
+ * Moving the end of queue forward
+ * the new_base here is logical, we need to translate to the abosule position
+ */
+void classqueue_update_base(struct classqueue_struct *cq)
+{
+       int new_base;
+       
+       if (! cq_nr_member(cq)) {
+               cq->base_offset = -1;   //not defined
+               return;
+       }
+
+       new_base = classqueue_get_min_prio(cq);
+       
+       if (new_base > cq->base) {
+               cq->base_offset = get_index(cq, &new_base);
+               cq->base = new_base;
+       }
+}
diff --git a/kernel/ckrm_sched.c b/kernel/ckrm_sched.c
new file mode 100644 (file)
index 0000000..5142b2e
--- /dev/null
@@ -0,0 +1,216 @@
+/* kernel/ckrm_sched.c - Supporting functions for ckrm scheduling
+ *
+ * Copyright (C) Haoqiang Zheng,  IBM Corp. 2004
+ *           (C) Hubertus Franke, IBM Corp. 2004
+ * 
+ * Latest version, more details at http://ckrm.sf.net
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/ckrm_sched.h>
+
+rwlock_t   class_list_lock = RW_LOCK_UNLOCKED;
+LIST_HEAD(active_cpu_classes);   // list of active cpu classes; anchor
+
+struct ckrm_cpu_class default_cpu_class_obj;
+
+struct ckrm_cpu_class * get_default_cpu_class(void) {
+       return (&default_cpu_class_obj);
+}
+
+/*******************************************************/
+/*                CVT Management                       */
+/*******************************************************/
+
+static inline void check_inactive_class(ckrm_lrq_t * lrq,CVT_t cur_cvt)
+{
+       CVT_t min_cvt;
+       CVT_t bonus;
+
+       //just a safty measure
+       if (unlikely(! cur_cvt))
+               return; 
+
+#ifndef INTERACTIVE_BONUS_SUPPORT
+#warning "ACB taking out interactive bonus calculation"        
+       bonus = 0;
+#else
+       /*
+        * Always leaving a small bonus for inactive classes 
+        * allows them to compete for cycles immediately when the become
+        * active. This should improve interactive behavior
+        */
+       bonus = INTERACTIVE_BONUS(lrq);
+#endif
+
+       //cvt can't be negative
+       if (cur_cvt > bonus)
+               min_cvt = cur_cvt - bonus;
+       else
+               min_cvt = 0;
+       
+       if (lrq->local_cvt < min_cvt) {
+               CVT_t lost_cvt;
+
+               lost_cvt = scale_cvt(min_cvt - lrq->local_cvt,lrq);
+               lrq->local_cvt = min_cvt;
+
+               /* add what the class lost to its savings*/
+               lrq->savings += lost_cvt;
+               if (lrq->savings > MAX_SAVINGS)
+                       lrq->savings = MAX_SAVINGS; 
+       } else if (lrq->savings) {
+               /*
+                *if a class saving and falling behind
+                * then start to use it saving in a leaking bucket way
+                */
+               CVT_t savings_used;
+
+               savings_used = scale_cvt((lrq->local_cvt - min_cvt),lrq);
+               if (savings_used > lrq->savings)
+                       savings_used = lrq->savings;
+               
+               if (savings_used > SAVINGS_LEAK_SPEED)
+                       savings_used = SAVINGS_LEAK_SPEED;
+
+               BUG_ON(lrq->savings < savings_used);
+               lrq->savings -= savings_used;
+               unscale_cvt(savings_used,lrq);
+               BUG_ON(lrq->local_cvt < savings_used);
+#ifndef CVT_SAVINGS_SUPPORT
+#warning "ACB taking out cvt saving"
+#else
+               lrq->local_cvt -= savings_used;
+#endif
+       }               
+}
+
+/*
+ * return the max_cvt of all the classes
+ */
+static inline CVT_t get_max_cvt(int this_cpu)
+{
+        struct ckrm_cpu_class *clsptr;
+        ckrm_lrq_t * lrq;
+        CVT_t max_cvt;
+
+        max_cvt = 0;
+
+        /*update class time, at the same time get max_cvt */
+        list_for_each_entry(clsptr, &active_cpu_classes, links) {
+                lrq = get_ckrm_lrq(clsptr, this_cpu);
+                if (lrq->local_cvt > max_cvt)
+                        max_cvt = lrq->local_cvt;
+        }
+
+       return max_cvt;
+}
+
+/**
+ * update_class_cputime - updates cvt of inactive classes
+ * -- an inactive class shouldn't starve others when it comes back
+ * -- the cpu time it lost when it's inactive should be accumulated
+ * -- its accumulated saving should be compensated (in a leaky bucket fashion)
+ * 
+ * class_list_lock must have been acquired 
+ */
+void update_class_cputime(int this_cpu)
+{
+       struct ckrm_cpu_class *clsptr;
+       ckrm_lrq_t * lrq;
+       CVT_t cur_cvt;
+
+       /*
+        *  a class's local_cvt must not be significantly smaller than min_cvt 
+        *  of active classes otherwise, it will starve other classes when it 
+         *  is reactivated.
+        * 
+        *  Hence we keep all local_cvt's within a range of the min_cvt off
+        *  all active classes (approximated by the local_cvt of the currently
+        *  running class) and account for how many cycles where thus taken
+        *  from an inactive class building a savings (not to exceed a few seconds)
+        *  for a class to gradually make up upon reactivation, without 
+        *  starvation of other classes.
+         *  
+        */
+       cur_cvt = get_local_cur_cvt(this_cpu);
+
+       /*
+        * cur_cvt == 0 means the system is now idle
+        * in this case, we use max_cvt as cur_cvt
+        * max_cvt roughly represents the cvt of the class 
+        * that has just finished running
+        *
+        * fairness wouldn't be a problem since we account for whatever lost in savings
+        * if the system is not busy, the system responsiveness is not a problem.
+        * still fine if the sytem is busy, but happened to be idle at this certain point
+        * since bias toward interactive classes (class priority) is a more important way to improve system responsiveness
+        */
+       if (unlikely(! cur_cvt))  {
+               cur_cvt = get_max_cvt(this_cpu);
+               //return;
+       }
+
+       /* 
+        *  - check the local cvt of all the classes 
+        *  - update total_ns received by the class
+        *  - do a usage sampling for the whole class
+        */
+       list_for_each_entry(clsptr, &active_cpu_classes, links) {
+               lrq = get_ckrm_lrq(clsptr, this_cpu);
+
+               spin_lock(&clsptr->stat.stat_lock);
+               clsptr->stat.total_ns += lrq->uncounted_ns;
+               ckrm_sample_usage(clsptr);
+               spin_unlock(&clsptr->stat.stat_lock);
+               lrq->uncounted_ns = 0;
+
+               check_inactive_class(lrq,cur_cvt);              
+       }
+}
+
+/*******************************************************/
+/*                PID load balancing stuff             */
+/*******************************************************/
+#define PID_SAMPLE_T 32
+#define PID_KP 20
+#define PID_KI 60
+#define PID_KD 20
+
+/**
+ * sample pid load periodically
+ */
+void ckrm_load_sample(ckrm_load_t* pid,int cpu)
+{
+       long load;
+       long err;
+
+       if (jiffies % PID_SAMPLE_T)
+               return;
+
+       adjust_local_weight();  
+
+       load = ckrm_cpu_load(cpu);
+       err = load - pid->load_p;
+       pid->load_d = err;
+       pid->load_p = load;
+       pid->load_i *= 9;
+       pid->load_i += load;
+       pid->load_i /= 10;
+}
+
+long pid_get_pressure(ckrm_load_t* ckrm_load, int local_group)
+{
+       long pressure;
+       pressure = ckrm_load->load_p * PID_KP;
+       pressure += ckrm_load->load_i * PID_KI;
+       pressure += ckrm_load->load_d * PID_KD;
+       pressure /= 100;
+       return pressure;
+}
index 2b2f728..60075cb 100644 (file)
 #include <linux/mount.h>
 #include <linux/proc_fs.h>
 #include <linux/mempolicy.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_tsk.h>
+#include <linux/vs_limit.h>
+#include <linux/ckrm_mem.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -37,6 +41,11 @@ int getrusage(struct task_struct *, int, struct rusage __user *);
 static void __unhash_process(struct task_struct *p)
 {
        nr_threads--;
+       /* tasklist_lock is held, is this sufficient? */
+       if (p->vx_info) {
+               atomic_dec(&p->vx_info->cacct.nr_threads);
+               atomic_dec(&p->vx_info->limit.rcur[RLIMIT_NPROC]);
+       }
        detach_pid(p, PIDTYPE_PID);
        detach_pid(p, PIDTYPE_TGID);
        if (thread_group_leader(p)) {
@@ -99,7 +108,7 @@ repeat:
        sched_exit(p);
        write_unlock_irq(&tasklist_lock);
        spin_unlock(&p->proc_lock);
-       proc_pid_flush(proc_dentry);
+       dput(proc_dentry);
        release_thread(p);
        put_task_struct(p);
 
@@ -236,6 +245,7 @@ void reparent_to_init(void)
        ptrace_unlink(current);
        /* Reparent to init */
        REMOVE_LINKS(current);
+       /* FIXME handle vchild_reaper/initpid */
        current->parent = child_reaper;
        current->real_parent = child_reaper;
        SET_LINKS(current);
@@ -378,8 +388,11 @@ static inline void close_files(struct files_struct * files)
                while (set) {
                        if (set & 1) {
                                struct file * file = xchg(&files->fd[i], NULL);
-                               if (file)
+                               if (file) {
                                        filp_close(file, files);
+                                       cond_resched();
+                               }
+                               // vx_openfd_dec(fd);
                        }
                        i++;
                        set >>= 1;
@@ -511,6 +524,12 @@ static inline void __exit_mm(struct task_struct * tsk)
        task_lock(tsk);
        tsk->mm = NULL;
        up_read(&mm->mmap_sem);
+#ifdef CONFIG_CKRM_RES_MEM
+       spin_lock(&mm->peertask_lock);
+       list_del_init(&tsk->mm_peers);
+       ckrm_mem_evaluate_mm(mm);
+       spin_unlock(&mm->peertask_lock);
+#endif
        enter_lazy_tlb(mm, current);
        task_unlock(tsk);
        mmput(mm);
@@ -600,6 +619,7 @@ static inline void forget_original_parent(struct task_struct * father,
        struct task_struct *p, *reaper = father;
        struct list_head *_p, *_n;
 
+       /* FIXME handle vchild_reaper/initpid */
        reaper = father->group_leader;
        if (reaper == father)
                reaper = child_reaper;
@@ -659,6 +679,8 @@ static void exit_notify(struct task_struct *tsk)
        struct task_struct *t;
        struct list_head ptrace_dead, *_p, *_n;
 
+       ckrm_cb_exit(tsk);
+
        if (signal_pending(tsk) && !tsk->signal->group_exit
            && !thread_group_empty(tsk)) {
                /*
@@ -821,6 +843,13 @@ asmlinkage NORET_TYPE void do_exit(long code)
        }
 
        acct_process(code);
+       if (current->tux_info) {
+#ifdef CONFIG_TUX_DEBUG
+               printk("Possibly unexpected TUX-thread exit(%ld) at %p?\n",
+                       code, __builtin_return_address(0));
+#endif
+               current->tux_exit();
+       }
        __exit_mm(tsk);
 
        exit_sem(tsk);
index 8e28c1f..1953944 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/fs.h>
 #include <linux/cpu.h>
 #include <linux/security.h>
+#include <linux/swap.h>
 #include <linux/syscalls.h>
 #include <linux/jiffies.h>
 #include <linux/futex.h>
 #include <linux/mount.h>
 #include <linux/audit.h>
 #include <linux/rmap.h>
+#include <linux/vs_network.h>
+#include <linux/vs_limit.h>
+#include <linux/vs_memory.h>
+#include <linux/ckrm.h>
+#include <linux/ckrm_tsk.h>
+#include <linux/ckrm_mem_inline.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
@@ -78,6 +85,8 @@ static kmem_cache_t *task_struct_cachep;
 static void free_task(struct task_struct *tsk)
 {
        free_thread_info(tsk->thread_info);
+       clr_vx_info(&tsk->vx_info);
+       clr_nx_info(&tsk->nx_info);
        free_task_struct(tsk);
 }
 
@@ -260,8 +269,12 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
        tsk->thread_info = ti;
        ti->task = tsk;
 
+       ckrm_cb_newtask(tsk);
        /* One for us, one for whoever does the "release_task()" (usually parent) */
        atomic_set(&tsk->usage,2);
+#ifdef CONFIG_CKRM_RES_MEM     
+       INIT_LIST_HEAD(&tsk->mm_peers);
+#endif
        return tsk;
 }
 
@@ -279,7 +292,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
        mm->locked_vm = 0;
        mm->mmap = NULL;
        mm->mmap_cache = NULL;
-       mm->free_area_cache = TASK_UNMAPPED_BASE;
+       mm->free_area_cache = oldmm->mmap_base;
        mm->map_count = 0;
        mm->rss = 0;
        cpus_clear(mm->cpu_vm_mask);
@@ -414,9 +427,14 @@ static struct mm_struct * mm_init(struct mm_struct * mm)
        mm->ioctx_list = NULL;
        mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm);
        mm->free_area_cache = TASK_UNMAPPED_BASE;
+#ifdef CONFIG_CKRM_RES_MEM
+       INIT_LIST_HEAD(&mm->tasklist);
+       mm->peertask_lock = SPIN_LOCK_UNLOCKED;
+#endif
 
        if (likely(!mm_alloc_pgd(mm))) {
                mm->def_flags = 0;
+               set_vx_info(&mm->mm_vx_info, current->vx_info);
                return mm;
        }
        free_mm(mm);
@@ -434,6 +452,10 @@ struct mm_struct * mm_alloc(void)
        if (mm) {
                memset(mm, 0, sizeof(*mm));
                mm = mm_init(mm);
+#ifdef CONFIG_CKRM_RES_MEM
+               mm->memclass = GET_MEM_CLASS(current);
+               mem_class_get(mm->memclass);
+#endif
        }
        return mm;
 }
@@ -448,6 +470,14 @@ void fastcall __mmdrop(struct mm_struct *mm)
        BUG_ON(mm == &init_mm);
        mm_free_pgd(mm);
        destroy_context(mm);
+       clr_vx_info(&mm->mm_vx_info);
+#ifdef CONFIG_CKRM_RES_MEM
+       /* class can be null and mm's tasklist can be empty here */
+       if (mm->memclass) {
+               mem_class_put(mm->memclass);
+               mm->memclass = NULL;
+       }
+#endif
        free_mm(mm);
 }
 
@@ -462,6 +492,7 @@ void mmput(struct mm_struct *mm)
                spin_unlock(&mmlist_lock);
                exit_aio(mm);
                exit_mmap(mm);
+               put_swap_token(mm);
                mmdrop(mm);
        }
 }
@@ -562,6 +593,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct * tsk)
 
        /* Copy the current MM stuff.. */
        memcpy(mm, oldmm, sizeof(*mm));
+       mm->mm_vx_info = NULL;
        if (!mm_init(mm))
                goto fail_nomem;
 
@@ -575,6 +607,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct * tsk)
 good_mm:
        tsk->mm = mm;
        tsk->active_mm = mm;
+       ckrm_init_mm_to_task(mm, tsk);
        return 0;
 
 free_pt:
@@ -873,6 +906,7 @@ struct task_struct *copy_process(unsigned long clone_flags,
 {
        int retval;
        struct task_struct *p = NULL;
+       struct vx_info *vxi;
 
        if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
                return ERR_PTR(-EINVAL);
@@ -900,13 +934,34 @@ struct task_struct *copy_process(unsigned long clone_flags,
        p = dup_task_struct(current);
        if (!p)
                goto fork_out;
+       p->tux_info = NULL;
+
+       p->vx_info = NULL;
+       set_vx_info(&p->vx_info, current->vx_info);
+       p->nx_info = NULL;
+       set_nx_info(&p->nx_info, current->nx_info);
+
+       /* check vserver memory */
+       if (p->mm && !(clone_flags & CLONE_VM)) {
+               if (vx_vmpages_avail(p->mm, p->mm->total_vm))
+                       vx_pages_add(p->mm->mm_vx_info, RLIMIT_AS, p->mm->total_vm);
+               else
+                       goto bad_fork_free;
+       }
+       if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
+               if (!vx_rsspages_avail(p->mm, p->mm->rss))
+                       goto bad_fork_cleanup_vm;
+       }
 
        retval = -EAGAIN;
+        if (!vx_nproc_avail(1))
+                goto bad_fork_cleanup_vm;
+
        if (atomic_read(&p->user->processes) >=
                        p->rlim[RLIMIT_NPROC].rlim_cur) {
                if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
                                p->user != &root_user)
-                       goto bad_fork_free;
+                       goto bad_fork_cleanup_vm;
        }
 
        atomic_inc(&p->user->__count);
@@ -927,6 +982,7 @@ struct task_struct *copy_process(unsigned long clone_flags,
        if (p->binfmt && !try_module_get(p->binfmt->module))
                goto bad_fork_cleanup_put_domain;
 
+       init_delays(p);
        p->did_exec = 0;
        copy_flags(clone_flags, p);
        if (clone_flags & CLONE_IDLETASK)
@@ -1092,7 +1148,14 @@ struct task_struct *copy_process(unsigned long clone_flags,
        } else
                link_pid(p, p->pids + PIDTYPE_TGID, &p->group_leader->pids[PIDTYPE_TGID].pid);
 
+       p->ioprio = current->ioprio;
        nr_threads++;
+       /* p is copy of current */
+       vxi = p->vx_info;
+       if (vxi) {
+               atomic_inc(&vxi->cacct.nr_threads);
+               atomic_inc(&vxi->limit.rcur[RLIMIT_NPROC]);
+       }
        write_unlock_irq(&tasklist_lock);
        retval = 0;
 
@@ -1136,6 +1199,9 @@ bad_fork_cleanup_count:
        put_group_info(p->group_info);
        atomic_dec(&p->user->processes);
        free_uid(p->user);
+bad_fork_cleanup_vm:
+       if (p->mm && !(clone_flags & CLONE_VM))
+               vx_pages_sub(p->mm->mm_vx_info, RLIMIT_AS, p->mm->total_vm);
 bad_fork_free:
        free_task(p);
        goto fork_out;
@@ -1180,6 +1246,12 @@ long do_fork(unsigned long clone_flags,
                        clone_flags |= CLONE_PTRACE;
        }
 
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+       if (numtasks_get_ref(current->taskclass, 0) == 0) {
+               return -ENOMEM;
+       }
+#endif
+
        p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr);
        /*
         * Do this prior waking up the new thread - the thread pointer
@@ -1190,6 +1262,8 @@ long do_fork(unsigned long clone_flags,
        if (!IS_ERR(p)) {
                struct completion vfork;
 
+               ckrm_cb_fork(p);
+
                if (clone_flags & CLONE_VFORK) {
                        p->vfork_done = &vfork;
                        init_completion(&vfork);
@@ -1245,6 +1319,10 @@ long do_fork(unsigned long clone_flags,
                         * COW overhead when the child exec()s afterwards.
                         */
                        set_need_resched();
+       } else {
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+               numtasks_put_ref(current->taskclass);
+#endif
        }
        return pid;
 }
index 74ba3cb..bf19d12 100644 (file)
@@ -307,6 +307,5 @@ int __init kallsyms_init(void)
                entry->proc_fops = &kallsyms_operations;
        return 0;
 }
-__initcall(kallsyms_init);
 
 EXPORT_SYMBOL(__print_symbol);
diff --git a/kernel/module-verify.c b/kernel/module-verify.c
new file mode 100644 (file)
index 0000000..9dacc53
--- /dev/null
@@ -0,0 +1,127 @@
+/* module-verify.c: description
+ *
+ * Written by David Howells (dhowells@redhat.com)
+ * - Derived from GregKH's RSA module signer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+#include <linux/elf.h>
+#include <linux/crypto.h>
+#include <linux/crypto/ksign.h>
+#include <asm/scatterlist.h>
+#include "module-verify.h"
+
+#if 0
+#define _debug(FMT, ...) printk(KERN_DEBUG FMT, ##__VA_ARGS__)
+#else
+#define _debug(FMT, ...) do { ; } while (0)
+#endif
+
+static int signedonly;
+
+/*****************************************************************************/
+/*
+ * verify the signature attached to a module
+ */
+int module_verify_sig(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, const char *secstrings, struct module *mod)
+{
+       struct crypto_tfm *sha1_tfm;
+       unsigned sig_index, sig_size;
+       char *sig;
+       int i;
+
+       /* pull the signature out of the file */
+       sig_index = 0;
+       for (i = 1; i < hdr->e_shnum; i++) {
+               if (strcmp(secstrings + sechdrs[i].sh_name,
+                          "module_sig") == 0) {
+                       sig_index = i;
+                       break;
+               }
+       }
+
+       if (sig_index <= 0)
+               goto no_signature;
+
+       _debug("sig in section %d (size %d)\n",
+              sig_index, sechdrs[sig_index].sh_size);
+
+       sig = (char *) sechdrs[sig_index].sh_addr;
+       sig_size = sechdrs[sig_index].sh_size;
+
+       _debug("");
+
+
+
+
+       /* grab an SHA1 transformation context
+        * - !!! if this tries to load the sha1.ko module, we will deadlock!!!
+        */
+       sha1_tfm = crypto_alloc_tfm2("sha1", 0, 1);
+       if (!sha1_tfm) {
+               printk("Couldn't load module - SHA1 transform unavailable\n");
+               return -EPERM;
+       }
+
+       crypto_digest_init(sha1_tfm);
+
+       for (i = 1; i < hdr->e_shnum; i++) {
+               uint8_t *data;
+               int size;
+               const char *name = secstrings + sechdrs[i].sh_name;
+
+               /* We only care about sections with "text" or "data" in their names */
+               if ((strstr(name, "text") == NULL) &&
+                   (strstr(name, "data") == NULL))
+                       continue;
+
+               /* avoid the ".rel.*" sections too. */
+               if (strstr(name, ".rel.") != NULL)
+                       continue;
+
+               /* avoid the ".rel.*" sections too. */
+               if (strstr(name, ".rela.") != NULL)
+                       continue;
+
+               data = (uint8_t *) sechdrs[i].sh_addr;
+               size = sechdrs[i].sh_size;
+
+               _debug("SHA1ing the %s section, size %d\n", name, size);
+               _debug("idata [ %02x%02x%02x%02x ]\n",
+                      data[0], data[1], data[2], data[3]);
+
+               crypto_digest_update_kernel(sha1_tfm, data, size);
+       }
+
+       /* do the actual signature verification */
+       i = ksign_verify_signature(sig, sig_size, sha1_tfm);
+       if (!i)
+                mod->gpgsig_ok = 1;
+       
+       return i;
+
+       /* deal with the case of an unsigned module */
+ no_signature:
+       if (!signedonly)
+               return 0;
+       printk("An attempt to load unsigned module was rejected\n");
+       return -EPERM;
+} /* end module_verify_sig() */
+
+static int __init sign_setup(char *str)
+{
+       signedonly = 1;
+       return 0;
+}
+__setup("enforcemodulesig", sign_setup);
+                        
diff --git a/kernel/module-verify.h b/kernel/module-verify.h
new file mode 100644 (file)
index 0000000..10efab8
--- /dev/null
@@ -0,0 +1,15 @@
+/* module-verify.h: module verification definitions
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifdef CONFIG_MODULE_SIG
+extern int module_verify_sig(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
+                            const char *secstrings, struct module *mod);
+#endif
index dfe295e..1f94d35 100644 (file)
@@ -37,6 +37,7 @@
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 #include <asm/cacheflush.h>
+#include "module-verify.h"
 
 #if 0
 #define DEBUGP printk
@@ -1624,6 +1625,14 @@ static struct module *load_module(void __user *umod,
                goto free_hdr;
        }
 
+       /* verify the signature on the module */
+#ifdef CONFIG_MODULE_SIG
+       if (module_verify_sig(hdr, sechdrs, secstrings, mod)) {
+               err = -EPERM;
+               goto free_hdr;
+       }
+#endif
+
        /* Now copy in args */
        arglen = strlen_user(uargs);
        if (!arglen) {
@@ -2154,8 +2163,13 @@ void print_modules(void)
        struct module *mod;
 
        printk("Modules linked in:");
-       list_for_each_entry(mod, &modules, list)
+       list_for_each_entry(mod, &modules, list) {
                printk(" %s", mod->name);
+#if CONFIG_MODULE_SIG          
+               if (!mod->gpgsig_ok)
+                       printk("(U)");
+#endif         
+       }
        printk("\n");
 }
 
index 3c1581e..37f3e82 100644 (file)
 #include <linux/syscalls.h>
 #include <linux/interrupt.h>
 #include <linux/nmi.h>
+#ifdef CONFIG_KEXEC
+#include <linux/kexec.h>
+#endif
 
-int panic_timeout;
-int panic_on_oops;
+int panic_timeout = 900;
+int panic_on_oops = 1;
 int tainted;
+void (*dump_function_ptr)(const char *, const struct pt_regs *) = 0;
 
 EXPORT_SYMBOL(panic_timeout);
+EXPORT_SYMBOL(dump_function_ptr);
 
 struct notifier_block *panic_notifier_list;
 
@@ -37,6 +42,9 @@ static int __init panic_setup(char *str)
 }
 __setup("panic=", panic_setup);
 
+int netdump_mode = 0;
+EXPORT_SYMBOL_GPL(netdump_mode);
+
 /**
  *     panic - halt the system
  *     @fmt: The text string to print
@@ -59,7 +67,10 @@ NORET_TYPE void panic(const char * fmt, ...)
        va_start(args, fmt);
        vsnprintf(buf, sizeof(buf), fmt, args);
        va_end(args);
+
        printk(KERN_EMERG "Kernel panic: %s\n",buf);
+       if (netdump_func)
+               BUG();
        if (in_interrupt())
                printk(KERN_EMERG "In interrupt handler - not syncing\n");
        else if (!current->pid)
@@ -68,20 +79,30 @@ NORET_TYPE void panic(const char * fmt, ...)
                sys_sync();
        bust_spinlocks(0);
 
+        notifier_call_chain(&panic_notifier_list, 0, buf);
+       
 #ifdef CONFIG_SMP
        smp_send_stop();
 #endif
 
-       notifier_call_chain(&panic_notifier_list, 0, buf);
-
-       if (panic_timeout > 0)
-       {
+       if (panic_timeout > 0) {
                int i;
                /*
                 * Delay timeout seconds before rebooting the machine. 
                 * We can't use the "normal" timers since we just panicked..
                 */
                printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
+#ifdef CONFIG_KEXEC
+{              
+               struct kimage *image;
+               image = xchg(&kexec_image, 0);
+               if (image) {
+                       printk(KERN_EMERG "by starting a new kernel ..\n");
+                       mdelay(panic_timeout*1000);
+                       machine_kexec(image);
+               }
+ }
+#endif
                for (i = 0; i < panic_timeout; i++) {
                        touch_nmi_watchdog();
                        mdelay(1000);
index 6ed44f5..1803836 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/hash.h>
+#include <linux/vs_cvirt.h>
 
 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
 static struct list_head *pid_hash[PIDTYPE_MAX];
@@ -224,7 +225,8 @@ void fastcall detach_pid(task_t *task, enum pid_type type)
 
 task_t *find_task_by_pid(int nr)
 {
-       struct pid *pid = find_pid(PIDTYPE_PID, nr);
+       struct pid *pid = find_pid(PIDTYPE_PID,
+               vx_rmap_tgid(current->vx_info, nr));
 
        if (!pid)
                return NULL;
@@ -273,7 +275,7 @@ void __init pidhash_init(void)
        int i, j, pidhash_size;
        unsigned long megabytes = max_pfn >> (20 - PAGE_SHIFT);
 
-       pidhash_shift = max(4, fls(megabytes * 4));
+       pidhash_shift = max(10, fls(megabytes * 4));
        pidhash_shift = min(12, pidhash_shift);
        pidhash_size = 1 << pidhash_shift;
 
index 8b28dd2..32452b3 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/smp.h>
 #include <linux/security.h>
 #include <linux/bootmem.h>
+#include <linux/vs_base.h>
 
 #include <asm/uaccess.h>
 
@@ -247,7 +248,10 @@ int do_syslog(int type, char __user * buf, int len)
        unsigned long i, j, limit, count;
        int do_clear = 0;
        char c;
-       int error = 0;
+       int error = -EPERM;
+
+       if (!vx_check(0, VX_ADMIN|VX_WATCH))
+               return error;
 
        error = security_syslog(type);
        if (error)
@@ -280,6 +284,7 @@ int do_syslog(int type, char __user * buf, int len)
                        error = __put_user(c,buf);
                        buf++;
                        i++;
+                       cond_resched();
                        spin_lock_irq(&logbuf_lock);
                }
                spin_unlock_irq(&logbuf_lock);
@@ -321,6 +326,7 @@ int do_syslog(int type, char __user * buf, int len)
                        c = LOG_BUF(j);
                        spin_unlock_irq(&logbuf_lock);
                        error = __put_user(c,&buf[count-1-i]);
+                       cond_resched();
                        spin_lock_irq(&logbuf_lock);
                }
                spin_unlock_irq(&logbuf_lock);
@@ -336,6 +342,7 @@ int do_syslog(int type, char __user * buf, int len)
                                        error = -EFAULT;
                                        break;
                                }
+                               cond_resched();
                        }
                }
                break;
@@ -376,6 +383,20 @@ asmlinkage long sys_syslog(int type, char __user * buf, int len)
        return do_syslog(type, buf, len);
 }
 
+/*
+ * Netdump special routine. Don't print to global log_buf, just to the
+ * actual console device(s).
+ */
+static void netdump_call_console_drivers(const char *buf, unsigned long len)
+{
+       struct console *con;
+
+       for (con = console_drivers; con; con = con->next) {
+               if ((con->flags & CON_ENABLED) && con->write)
+                       con->write(con, buf, len);
+       }
+}
+
 /*
  * Call the console drivers on a range of log_buf
  */
@@ -525,6 +546,12 @@ asmlinkage int printk(const char *fmt, ...)
        printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
        va_end(args);
 
+       if (unlikely(netdump_mode)) {
+               netdump_call_console_drivers(printk_buf, printed_len);
+               spin_unlock_irqrestore(&logbuf_lock, flags);
+               goto out;
+       }
+
        /*
         * Copy the output into log_buf.  If the caller didn't provide
         * appropriate log level tags, we insert them here
index 3e88979..20b0921 100644 (file)
@@ -17,7 +17,6 @@
  *  2003-09-03 Interactivity tuning by Con Kolivas.
  *  2004-04-02 Scheduler domains code by Nick Piggin
  */
-
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/nmi.h>
@@ -25,6 +24,7 @@
 #include <asm/uaccess.h>
 #include <linux/highmem.h>
 #include <linux/smp_lock.h>
+#include <linux/pagemap.h>
 #include <asm/mmu_context.h>
 #include <linux/interrupt.h>
 #include <linux/completion.h>
@@ -40,6 +40,8 @@
 #include <linux/cpu.h>
 #include <linux/percpu.h>
 #include <linux/kthread.h>
+#include <linux/vserver/sched.h>
+#include <linux/vs_base.h>
 #include <asm/tlb.h>
 
 #include <asm/unistd.h>
 #define cpu_to_node_mask(cpu) (cpu_online_map)
 #endif
 
+/* used to soft spin in sched while dump is in progress */
+unsigned long dump_oncpu;
+EXPORT_SYMBOL(dump_oncpu);
+
 /*
  * Convert user-nice values [ -20 ... 0 ... 19 ]
  * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
 #define LOW_CREDIT(p) \
        ((p)->interactive_credit < -CREDIT_LIMIT)
 
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+/*
+ *  if belong to different class, compare class priority
+ *  otherwise compare task priority 
+ */
+#define TASK_PREEMPTS_CURR(p, rq) \
+       ( ((p)->cpu_class != (rq)->curr->cpu_class) \
+         && ((rq)->curr != (rq)->idle) && ((p) != (rq)->idle )) \
+         ? class_preempts_curr((p),(rq)->curr)  \
+         : ((p)->prio < (rq)->curr->prio)
+#else
 #define TASK_PREEMPTS_CURR(p, rq) \
        ((p)->prio < (rq)->curr->prio)
+#endif
 
 /*
  * BASE_TIMESLICE scales user-nice values [ -20 ... 19 ]
                ((MAX_TIMESLICE - MIN_TIMESLICE) * \
                        (MAX_PRIO-1 - (p)->static_prio) / (MAX_USER_PRIO-1)))
 
-static unsigned int task_timeslice(task_t *p)
+unsigned int task_timeslice(task_t *p)
 {
        return BASE_TIMESLICE(p);
 }
@@ -186,15 +204,9 @@ static unsigned int task_timeslice(task_t *p)
  * These are the runqueue data structures:
  */
 
-#define BITMAP_SIZE ((((MAX_PRIO+1+7)/8)+sizeof(long)-1)/sizeof(long))
-
 typedef struct runqueue runqueue_t;
-
-struct prio_array {
-       unsigned int nr_active;
-       unsigned long bitmap[BITMAP_SIZE];
-       struct list_head queue[MAX_PRIO];
-};
+#include <linux/ckrm_classqueue.h>
+#include <linux/ckrm_sched.h>
 
 /*
  * This is the main, per-CPU runqueue data structure.
@@ -211,15 +223,20 @@ struct runqueue {
         * remote CPUs use both these fields when doing load calculation.
         */
        unsigned long nr_running;
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP)
        unsigned long cpu_load;
 #endif
-       unsigned long long nr_switches;
+       unsigned long long nr_switches, nr_preempt;
        unsigned long expired_timestamp, nr_uninterruptible;
        unsigned long long timestamp_last_tick;
        task_t *curr, *idle;
        struct mm_struct *prev_mm;
-       prio_array_t *active, *expired, arrays[2];
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+       struct classqueue_struct classqueue;   
+       ckrm_load_t ckrm_load;
+#else
+        prio_array_t *active, *expired, arrays[2];
+#endif
        int best_expired_prio;
        atomic_t nr_iowait;
 
@@ -233,6 +250,11 @@ struct runqueue {
        task_t *migration_thread;
        struct list_head migration_queue;
 #endif
+
+#ifdef CONFIG_VSERVER_HARDCPU          
+       struct list_head hold_queue;
+       int idle_tokens;
+#endif
 };
 
 static DEFINE_PER_CPU(struct runqueue, runqueues);
@@ -298,6 +320,97 @@ static inline void rq_unlock(runqueue_t *rq)
        spin_unlock_irq(&rq->lock);
 }
 
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+static inline ckrm_lrq_t *rq_get_next_class(struct runqueue *rq)
+{
+       cq_node_t *node = classqueue_get_head(&rq->classqueue);
+       return ((node) ? class_list_entry(node) : NULL);
+}
+
+/*
+ * return the cvt of the current running class
+ * if no current running class, return 0
+ * assume cpu is valid (cpu_online(cpu) == 1)
+ */
+CVT_t get_local_cur_cvt(int cpu)
+{
+       ckrm_lrq_t * lrq = rq_get_next_class(cpu_rq(cpu));
+
+       if (lrq)
+               return lrq->local_cvt;
+       else    
+               return 0;
+}
+
+static inline struct task_struct * rq_get_next_task(struct runqueue* rq) 
+{
+       prio_array_t               *array;
+       struct task_struct         *next;
+       ckrm_lrq_t *queue;
+       int idx;
+       int cpu = smp_processor_id();
+
+       // it is guaranteed be the ( rq->nr_running > 0 ) check in 
+       // schedule that a task will be found.
+
+ retry_next_class:
+       queue = rq_get_next_class(rq);
+       // BUG_ON( !queue );
+
+       array = queue->active;
+       if (unlikely(!array->nr_active)) {
+               queue->active = queue->expired;
+               queue->expired = array;
+               queue->expired_timestamp = 0;
+
+               if (queue->active->nr_active)
+                       set_top_priority(queue,
+                                        find_first_bit(queue->active->bitmap, MAX_PRIO));
+               else {
+                       classqueue_dequeue(queue->classqueue,
+                                          &queue->classqueue_linkobj);
+                       cpu_demand_event(get_rq_local_stat(queue,cpu),CPU_DEMAND_DEQUEUE,0);
+               }
+               goto retry_next_class;                          
+       }
+       // BUG_ON(!array->nr_active);
+
+       idx = queue->top_priority;
+       // BUG_ON (idx == MAX_PRIO);
+       next = task_list_entry(array->queue[idx].next);
+       return next;
+}
+#else /*! CONFIG_CKRM_CPU_SCHEDULE*/
+static inline struct task_struct * rq_get_next_task(struct runqueue* rq) 
+{
+       prio_array_t *array;
+        struct list_head *queue;
+       int idx;
+
+       array = rq->active;
+       if (unlikely(!array->nr_active)) {
+               /*
+                * Switch the active and expired arrays.
+                */
+               rq->active = rq->expired;
+               rq->expired = array;
+               array = rq->active;
+               rq->expired_timestamp = 0;
+               rq->best_expired_prio = MAX_PRIO;
+       }
+
+       idx = sched_find_first_bit(array->bitmap);
+       queue = array->queue + idx;
+       return list_entry(queue->next, task_t, run_list);
+}
+
+static inline void class_enqueue_task(struct task_struct* p, prio_array_t *array) { }
+static inline void class_dequeue_task(struct task_struct* p, prio_array_t *array) { }
+static inline void init_cpu_classes(void) { }
+#define rq_ckrm_load(rq) NULL
+static inline void ckrm_sched_tick(int j,int this_cpu,void* name) {}
+#endif  /* CONFIG_CKRM_CPU_SCHEDULE */
+
 /*
  * Adding/removing a task to/from a priority array:
  */
@@ -307,6 +420,7 @@ static void dequeue_task(struct task_struct *p, prio_array_t *array)
        list_del(&p->run_list);
        if (list_empty(array->queue + p->prio))
                __clear_bit(p->prio, array->bitmap);
+       class_dequeue_task(p,array);
 }
 
 static void enqueue_task(struct task_struct *p, prio_array_t *array)
@@ -315,6 +429,7 @@ static void enqueue_task(struct task_struct *p, prio_array_t *array)
        __set_bit(p->prio, array->bitmap);
        array->nr_active++;
        p->array = array;
+       class_enqueue_task(p,array);
 }
 
 /*
@@ -328,6 +443,7 @@ static inline void enqueue_task_head(struct task_struct *p, prio_array_t *array)
        __set_bit(p->prio, array->bitmap);
        array->nr_active++;
        p->array = array;
+       class_enqueue_task(p,array);
 }
 
 /*
@@ -354,6 +470,9 @@ static int effective_prio(task_t *p)
        bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
 
        prio = p->static_prio - bonus;
+       if (__vx_task_flags(p, VXF_SCHED_PRIO, 0))
+               prio += effective_vavavoom(p, MAX_USER_PRIO);
+
        if (prio < MAX_RT_PRIO)
                prio = MAX_RT_PRIO;
        if (prio > MAX_PRIO-1)
@@ -366,7 +485,7 @@ static int effective_prio(task_t *p)
  */
 static inline void __activate_task(task_t *p, runqueue_t *rq)
 {
-       enqueue_task(p, rq->active);
+       enqueue_task(p, rq_active(p,rq));
        rq->nr_running++;
 }
 
@@ -375,7 +494,7 @@ static inline void __activate_task(task_t *p, runqueue_t *rq)
  */
 static inline void __activate_idle_task(task_t *p, runqueue_t *rq)
 {
-       enqueue_task_head(p, rq->active);
+       enqueue_task_head(p, rq_active(p,rq));
        rq->nr_running++;
 }
 
@@ -881,6 +1000,10 @@ void fastcall sched_fork(task_t *p)
        INIT_LIST_HEAD(&p->run_list);
        p->array = NULL;
        spin_lock_init(&p->switch_lock);
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+       cpu_demand_event(&p->demand_stat,CPU_DEMAND_INIT,0);
+#endif
+
 #ifdef CONFIG_PREEMPT
        /*
         * During context-switch we hold precisely one spinlock, which
@@ -956,6 +1079,7 @@ void fastcall wake_up_forked_process(task_t * p)
                p->array = current->array;
                p->array->nr_active++;
                rq->nr_running++;
+               class_enqueue_task(p,p->array);
        }
        task_rq_unlock(rq, &flags);
 }
@@ -1155,6 +1279,16 @@ static void double_rq_unlock(runqueue_t *rq1, runqueue_t *rq2)
                spin_unlock(&rq2->lock);
 }
 
+unsigned long long nr_preempt(void)
+{
+       unsigned long long i, sum = 0;
+
+       for_each_online_cpu(i)
+               sum += cpu_rq(i)->nr_preempt;
+
+       return sum;
+}
+
 enum idle_type
 {
        IDLE,
@@ -1278,6 +1412,7 @@ lock_again:
                        p->array = current->array;
                        p->array->nr_active++;
                        rq->nr_running++;
+                       class_enqueue_task(p,p->array);
                }
        } else {
                /* Not the local CPU - must adjust timestamp */
@@ -1423,6 +1558,449 @@ int can_migrate_task(task_t *p, runqueue_t *rq, int this_cpu,
        return 1;
 }
 
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+static inline int ckrm_preferred_task(task_t *tmp,long min, long max, 
+                                     int phase, enum idle_type idle)
+{
+       long pressure = task_load(tmp);
+       
+       if (pressure > max) 
+               return 0;
+
+       if ((idle == NOT_IDLE) && ! phase && (pressure <= min))
+               return 0;
+       return 1;
+}
+
+/*
+ * move tasks for a specic local class
+ * return number of tasks pulled
+ */
+static inline int ckrm_cls_move_tasks(ckrm_lrq_t* src_lrq,ckrm_lrq_t*dst_lrq,
+                                     runqueue_t *this_rq,
+                                     runqueue_t *busiest,
+                                     struct sched_domain *sd,
+                                     int this_cpu,
+                                     enum idle_type idle,
+                                     long* pressure_imbalance) 
+{
+       prio_array_t *array, *dst_array;
+       struct list_head *head, *curr;
+       task_t *tmp;
+       int idx;
+       int pulled = 0;
+       int phase = -1;
+       long pressure_min, pressure_max;
+       /*hzheng: magic : 90% balance is enough*/
+       long balance_min = *pressure_imbalance / 10; 
+/*
+ * we don't want to migrate tasks that will reverse the balance
+ *     or the tasks that make too small difference
+ */
+#define CKRM_BALANCE_MAX_RATIO 100
+#define CKRM_BALANCE_MIN_RATIO 1
+ start:
+       phase ++;
+       /*
+        * We first consider expired tasks. Those will likely not be
+        * executed in the near future, and they are most likely to
+        * be cache-cold, thus switching CPUs has the least effect
+        * on them.
+        */
+       if (src_lrq->expired->nr_active) {
+               array = src_lrq->expired;
+               dst_array = dst_lrq->expired;
+       } else {
+               array = src_lrq->active;
+               dst_array = dst_lrq->active;
+       }
+       
+ new_array:
+       /* Start searching at priority 0: */
+       idx = 0;
+ skip_bitmap:
+       if (!idx)
+               idx = sched_find_first_bit(array->bitmap);
+       else
+               idx = find_next_bit(array->bitmap, MAX_PRIO, idx);
+       if (idx >= MAX_PRIO) {
+               if (array == src_lrq->expired && src_lrq->active->nr_active) {
+                       array = src_lrq->active;
+                       dst_array = dst_lrq->active;
+                       goto new_array;
+               }
+               if ((! phase) && (! pulled) && (idle != IDLE))
+                       goto start; //try again
+               else 
+                       goto out; //finished search for this lrq
+       }
+       
+       head = array->queue + idx;
+       curr = head->prev;
+ skip_queue:
+       tmp = list_entry(curr, task_t, run_list);
+       
+       curr = curr->prev;
+       
+       if (!can_migrate_task(tmp, busiest, this_cpu, sd, idle)) {
+               if (curr != head)
+                       goto skip_queue;
+               idx++;
+               goto skip_bitmap;
+       }
+
+       pressure_min = *pressure_imbalance * CKRM_BALANCE_MIN_RATIO/100;
+       pressure_max = *pressure_imbalance * CKRM_BALANCE_MAX_RATIO/100;
+       /*
+        * skip the tasks that will reverse the balance too much
+        */
+       if (ckrm_preferred_task(tmp,pressure_min,pressure_max,phase,idle)) {
+               *pressure_imbalance -= task_load(tmp);
+               pull_task(busiest, array, tmp, 
+                         this_rq, dst_array, this_cpu);
+               pulled++;
+
+               if (*pressure_imbalance <= balance_min)
+                       goto out;
+       }
+               
+       if (curr != head)
+               goto skip_queue;
+       idx++;
+       goto skip_bitmap;
+ out:         
+       return pulled;
+}
+
+static inline long ckrm_rq_imbalance(runqueue_t *this_rq,runqueue_t *dst_rq)
+{
+       long imbalance;
+       /*
+        * make sure after balance, imbalance' > - imbalance/2
+        * we don't want the imbalance be reversed too much
+        */
+       imbalance = pid_get_pressure(rq_ckrm_load(dst_rq),0) 
+               - pid_get_pressure(rq_ckrm_load(this_rq),1);
+       imbalance /= 2;
+       return imbalance;
+}
+
+/*
+ * try to balance the two runqueues
+ *
+ * Called with both runqueues locked.
+ * if move_tasks is called, it will try to move at least one task over
+ */
+static int move_tasks(runqueue_t *this_rq, int this_cpu, runqueue_t *busiest,
+                     unsigned long max_nr_move, struct sched_domain *sd,
+                     enum idle_type idle)
+{
+       struct ckrm_cpu_class *clsptr,*vip_cls = NULL;
+       ckrm_lrq_t* src_lrq,*dst_lrq;
+       long pressure_imbalance, pressure_imbalance_old;
+       int src_cpu = task_cpu(busiest->curr);
+       struct list_head *list;
+       int pulled = 0;
+       long imbalance;
+
+       imbalance =  ckrm_rq_imbalance(this_rq,busiest);
+
+       if ((idle == NOT_IDLE && imbalance <= 0) || busiest->nr_running <= 1)
+               goto out;
+
+       //try to find the vip class
+        list_for_each_entry(clsptr,&active_cpu_classes,links) {
+               src_lrq = get_ckrm_lrq(clsptr,src_cpu);
+
+               if (! lrq_nr_running(src_lrq))
+                       continue;
+
+               if (! vip_cls || cpu_class_weight(vip_cls) < cpu_class_weight(clsptr) )  
+                       {
+                               vip_cls = clsptr;
+                       }
+       }
+
+       /*
+        * do search from the most significant class
+        * hopefully, less tasks will be migrated this way
+        */
+       clsptr = vip_cls;
+
+ move_class:
+       if (! clsptr)
+               goto out;
+       
+
+       src_lrq = get_ckrm_lrq(clsptr,src_cpu);
+       if (! lrq_nr_running(src_lrq))
+               goto other_class;
+       
+       dst_lrq = get_ckrm_lrq(clsptr,this_cpu);
+
+       //how much pressure for this class should be transferred
+       pressure_imbalance = src_lrq->lrq_load * imbalance/src_lrq->local_weight;
+       if (pulled && ! pressure_imbalance) 
+               goto other_class;
+       
+       pressure_imbalance_old = pressure_imbalance;
+       
+       //move tasks
+       pulled += 
+               ckrm_cls_move_tasks(src_lrq,dst_lrq,
+                                   this_rq,
+                                   busiest,
+                                   sd,this_cpu,idle,
+                                   &pressure_imbalance);
+
+       /* 
+        * hzheng: 2 is another magic number
+        * stop balancing if the imbalance is less than 25% of the orig
+        */
+       if (pressure_imbalance <= (pressure_imbalance_old >> 2))
+               goto out;
+               
+       //update imbalance
+       imbalance *= pressure_imbalance / pressure_imbalance_old;
+ other_class:
+       //who is next?
+       list = clsptr->links.next;
+       if (list == &active_cpu_classes)
+               list = list->next;
+       clsptr = list_entry(list, typeof(*clsptr), links);
+       if (clsptr != vip_cls)
+               goto move_class;
+ out:
+       return pulled;
+}
+
+/**
+ * ckrm_check_balance - is load balancing necessary?
+ * return 0 if load balancing is not necessary
+ * otherwise return the average load of the system
+ * also, update nr_group
+ *
+ * heuristics: 
+ *   no load balancing if it's load is over average
+ *   no load balancing if it's load is far more than the min
+ * task:
+ *   read the status of all the runqueues
+ */
+static unsigned long ckrm_check_balance(struct sched_domain *sd, int this_cpu,
+                                            enum idle_type idle, int* nr_group)
+{
+       struct sched_group *group = sd->groups;
+       unsigned long min_load, max_load, avg_load;
+       unsigned long total_load, this_load, total_pwr;
+
+       max_load = this_load = total_load = total_pwr = 0;
+       min_load = 0xFFFFFFFF;
+       *nr_group = 0;
+
+       do {
+               cpumask_t tmp;
+               unsigned long load;
+               int local_group;
+               int i, nr_cpus = 0;
+
+               /* Tally up the load of all CPUs in the group */
+               cpus_and(tmp, group->cpumask, cpu_online_map);
+               if (unlikely(cpus_empty(tmp)))
+                       goto nextgroup;
+
+               avg_load = 0;
+               local_group = cpu_isset(this_cpu, group->cpumask);
+
+               for_each_cpu_mask(i, tmp) {
+                       load = pid_get_pressure(rq_ckrm_load(cpu_rq(i)),local_group);
+                       nr_cpus++;
+                       avg_load += load;
+               }
+
+               if (!nr_cpus)
+                       goto nextgroup;
+
+               total_load += avg_load;
+               total_pwr += group->cpu_power;
+
+               /* Adjust by relative CPU power of the group */
+               avg_load = (avg_load * SCHED_LOAD_SCALE) / group->cpu_power;
+
+               if (local_group) {
+                       this_load = avg_load;
+                       goto nextgroup;
+               } else if (avg_load > max_load) {
+                       max_load = avg_load;
+               }      
+               if (avg_load < min_load) {
+                       min_load = avg_load;
+               }
+nextgroup:
+               group = group->next;
+               *nr_group = *nr_group + 1;
+       } while (group != sd->groups);
+
+       if (!max_load || this_load >= max_load)
+               goto out_balanced;
+
+       avg_load = (SCHED_LOAD_SCALE * total_load) / total_pwr;
+
+       /* hzheng: debugging: 105 is a magic number
+        * 100*max_load <= sd->imbalance_pct*this_load)
+        * should use imbalance_pct instead
+        */
+       if (this_load > avg_load 
+           || 100*max_load < 105*this_load
+           || 100*min_load < 70*this_load
+           )
+               goto out_balanced;
+
+       return avg_load;
+ out_balanced:
+       return 0;
+}
+
+/**
+ * any group that has above average load is considered busy
+ * find the busiest queue from any of busy group
+ */
+static runqueue_t *
+ckrm_find_busy_queue(struct sched_domain *sd, int this_cpu,
+                    unsigned long avg_load, enum idle_type idle,
+                    int nr_group)
+{
+       struct sched_group *group;
+       runqueue_t * busiest=NULL;
+       unsigned long rand;
+       
+       group = sd->groups;
+       rand = get_ckrm_rand(nr_group);
+       nr_group = 0;
+
+       do {
+               unsigned long load,total_load,max_load;
+               cpumask_t tmp;
+               int i;
+               runqueue_t * grp_busiest;
+
+               cpus_and(tmp, group->cpumask, cpu_online_map);
+               if (unlikely(cpus_empty(tmp)))
+                       goto find_nextgroup;
+
+               total_load = 0;
+               max_load = 0;
+               grp_busiest = NULL;
+               for_each_cpu_mask(i, tmp) {
+                       load = pid_get_pressure(rq_ckrm_load(cpu_rq(i)),0);
+                       total_load += load;
+                       if (load > max_load) {
+                               max_load = load;
+                               grp_busiest = cpu_rq(i);
+                       }                               
+               }
+
+               total_load = (total_load * SCHED_LOAD_SCALE) / group->cpu_power;
+               if (total_load > avg_load) {
+                       busiest = grp_busiest;
+                       if (nr_group >= rand)
+                               break;
+               }
+       find_nextgroup:         
+               group = group->next;
+               nr_group ++;
+       } while (group != sd->groups);
+
+       return busiest;
+}
+
+/**
+ * load_balance - pressure based load balancing algorithm used by ckrm
+ */
+static int ckrm_load_balance(int this_cpu, runqueue_t *this_rq,
+                       struct sched_domain *sd, enum idle_type idle)
+{
+       runqueue_t *busiest;
+       unsigned long avg_load;
+       int nr_moved,nr_group;
+
+       avg_load = ckrm_check_balance(sd, this_cpu, idle, &nr_group);
+       if (! avg_load)
+               goto out_balanced;
+
+       busiest = ckrm_find_busy_queue(sd,this_cpu,avg_load,idle,nr_group);
+       if (! busiest)
+               goto out_balanced;
+       /*
+        * This should be "impossible", but since load
+        * balancing is inherently racy and statistical,
+        * it could happen in theory.
+        */
+       if (unlikely(busiest == this_rq)) {
+               WARN_ON(1);
+               goto out_balanced;
+       }
+
+       nr_moved = 0;
+       if (busiest->nr_running > 1) {
+               /*
+                * Attempt to move tasks. If find_busiest_group has found
+                * an imbalance but busiest->nr_running <= 1, the group is
+                * still unbalanced. nr_moved simply stays zero, so it is
+                * correctly treated as an imbalance.
+                */
+               double_lock_balance(this_rq, busiest);
+               nr_moved = move_tasks(this_rq, this_cpu, busiest,
+                                     0,sd, idle);              
+               spin_unlock(&busiest->lock);
+               if (nr_moved) {
+                       adjust_local_weight();
+               }
+       }
+
+       if (!nr_moved) 
+               sd->nr_balance_failed ++;
+       else
+               sd->nr_balance_failed  = 0;             
+
+       /* We were unbalanced, so reset the balancing interval */
+       sd->balance_interval = sd->min_interval;
+
+       return nr_moved;
+
+out_balanced:
+       /* tune up the balancing interval */
+       if (sd->balance_interval < sd->max_interval)
+               sd->balance_interval *= 2;
+
+       return 0;
+}
+
+/*
+ * this_rq->lock is already held
+ */
+static inline int load_balance_newidle(int this_cpu, runqueue_t *this_rq,
+                                      struct sched_domain *sd)
+{
+       int ret;
+       read_lock(&class_list_lock);
+       ret = ckrm_load_balance(this_cpu,this_rq,sd,NEWLY_IDLE);
+       read_unlock(&class_list_lock);
+       return ret;
+}
+
+static inline int load_balance(int this_cpu, runqueue_t *this_rq,
+                       struct sched_domain *sd, enum idle_type idle)
+{
+       int ret;
+
+       spin_lock(&this_rq->lock);
+       read_lock(&class_list_lock);
+       ret= ckrm_load_balance(this_cpu,this_rq,sd,NEWLY_IDLE);
+       read_unlock(&class_list_lock);
+       spin_unlock(&this_rq->lock);
+       return ret;
+}
+#else /*! CONFIG_CKRM_CPU_SCHEDULE */
 /*
  * move_tasks tries to move up to max_nr_move tasks from busiest to this_rq,
  * as part of a balancing operation within "domain". Returns the number of
@@ -1787,6 +2365,8 @@ static int load_balance_newidle(int this_cpu, runqueue_t *this_rq,
 out:
        return nr_moved;
 }
+#endif /* CONFIG_CKRM_CPU_SCHEDULE*/
+
 
 /*
  * idle_balance is called by schedule() if this_cpu is about to become
@@ -1924,7 +2504,7 @@ static void rebalance_tick(int this_cpu, runqueue_t *this_rq,
                }
        }
 }
-#else
+#else /* SMP*/
 /*
  * on UP we do not need to balance between CPUs:
  */
@@ -1952,7 +2532,6 @@ static inline int wake_priority_sleeper(runqueue_t *rq)
 }
 
 DEFINE_PER_CPU(struct kernel_stat, kstat);
-
 EXPORT_PER_CPU_SYMBOL(kstat);
 
 /*
@@ -1965,11 +2544,19 @@ EXPORT_PER_CPU_SYMBOL(kstat);
  * increasing number of running tasks. We also ignore the interactivity
  * if a better static_prio task has expired:
  */
+
+#ifndef CONFIG_CKRM_CPU_SCHEDULE
 #define EXPIRED_STARVING(rq) \
        ((STARVATION_LIMIT && ((rq)->expired_timestamp && \
                (jiffies - (rq)->expired_timestamp >= \
                        STARVATION_LIMIT * ((rq)->nr_running) + 1))) || \
                        ((rq)->curr->static_prio > (rq)->best_expired_prio))
+#else
+#define EXPIRED_STARVING(rq) \
+               (STARVATION_LIMIT && ((rq)->expired_timestamp && \
+               (jiffies - (rq)->expired_timestamp >= \
+                       STARVATION_LIMIT * (lrq_nr_running(rq)) + 1)))
+#endif
 
 /*
  * This function gets called by the timer code, with HZ frequency.
@@ -2000,12 +2587,18 @@ void scheduler_tick(int user_ticks, int sys_ticks)
        }
 
        if (p == rq->idle) {
+#ifdef CONFIG_VSERVER_HARDCPU
+               if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
+                       set_need_resched();     
+#endif
+
                if (atomic_read(&rq->nr_iowait) > 0)
                        cpustat->iowait += sys_ticks;
                else
                        cpustat->idle += sys_ticks;
                if (wake_priority_sleeper(rq))
                        goto out;
+               ckrm_sched_tick(jiffies,cpu,rq_ckrm_load(rq));
                rebalance_tick(cpu, rq, IDLE);
                return;
        }
@@ -2016,7 +2609,7 @@ void scheduler_tick(int user_ticks, int sys_ticks)
        cpustat->system += sys_ticks;
 
        /* Task might have expired already, but not scheduled off yet */
-       if (p->array != rq->active) {
+       if (p->array != rq_active(p,rq)) {
                set_tsk_need_resched(p);
                goto out;
        }
@@ -2039,12 +2632,16 @@ void scheduler_tick(int user_ticks, int sys_ticks)
                        set_tsk_need_resched(p);
 
                        /* put it at the end of the queue: */
-                       dequeue_task(p, rq->active);
-                       enqueue_task(p, rq->active);
+                       dequeue_task(p, rq_active(p,rq));
+                       enqueue_task(p, rq_active(p,rq));
                }
                goto out_unlock;
        }
-       if (!--p->time_slice) {
+       if (vx_need_resched(p)) {
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+               /* Hubertus ... we can abstract this out */
+               ckrm_lrq_t* rq = get_task_lrq(p);
+#endif
                dequeue_task(p, rq->active);
                set_tsk_need_resched(p);
                p->prio = effective_prio(p);
@@ -2055,8 +2652,8 @@ void scheduler_tick(int user_ticks, int sys_ticks)
                        rq->expired_timestamp = jiffies;
                if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
                        enqueue_task(p, rq->expired);
-                       if (p->static_prio < rq->best_expired_prio)
-                               rq->best_expired_prio = p->static_prio;
+                       if (p->static_prio < this_rq()->best_expired_prio)
+                               this_rq()->best_expired_prio = p->static_prio;
                } else
                        enqueue_task(p, rq->active);
        } else {
@@ -2079,17 +2676,18 @@ void scheduler_tick(int user_ticks, int sys_ticks)
                if (TASK_INTERACTIVE(p) && !((task_timeslice(p) -
                        p->time_slice) % TIMESLICE_GRANULARITY(p)) &&
                        (p->time_slice >= TIMESLICE_GRANULARITY(p)) &&
-                       (p->array == rq->active)) {
+                       (p->array == rq_active(p,rq))) {
 
-                       dequeue_task(p, rq->active);
+                       dequeue_task(p, rq_active(p,rq));
                        set_tsk_need_resched(p);
                        p->prio = effective_prio(p);
-                       enqueue_task(p, rq->active);
+                       enqueue_task(p, rq_active(p,rq));
                }
        }
 out_unlock:
        spin_unlock(&rq->lock);
 out:
+       ckrm_sched_tick(jiffies,cpu,rq_ckrm_load(rq));
        rebalance_tick(cpu, rq, NOT_IDLE);
 }
 
@@ -2187,11 +2785,24 @@ asmlinkage void __sched schedule(void)
        task_t *prev, *next;
        runqueue_t *rq;
        prio_array_t *array;
-       struct list_head *queue;
        unsigned long long now;
        unsigned long run_time;
-       int cpu, idx;
+       int cpu;
+#ifdef CONFIG_VSERVER_HARDCPU          
+       struct vx_info *vxi;
+       int maxidle = -HZ;
+#endif
+
+       /*
+        * If crash dump is in progress, this other cpu's
+        * need to wait until it completes.
+        * NB: this code is optimized away for kernels without
+        * dumping enabled.
+        */
+       if (unlikely(dump_oncpu))
+               goto dump_scheduling_disabled;
 
+       //WARN_ON(system_state == SYSTEM_BOOTING);
        /*
         * Test if we are atomic.  Since do_exit() needs to call into
         * schedule() atomically, we ignore that path for now.
@@ -2226,6 +2837,19 @@ need_resched:
 
        spin_lock_irq(&rq->lock);
 
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+       if (prev != rq->idle) {
+               unsigned long long run = now - prev->timestamp;
+               ckrm_lrq_t * lrq = get_task_lrq(prev);
+
+               lrq->lrq_load -= task_load(prev);
+               cpu_demand_event(&prev->demand_stat,CPU_DEMAND_DESCHEDULE,run);
+               lrq->lrq_load += task_load(prev);
+
+               cpu_demand_event(get_task_lrq_stat(prev),CPU_DEMAND_DESCHEDULE,run);
+               update_local_cvt(prev, run);
+       }
+#endif
        /*
         * if entering off of a kernel preemption go straight
         * to picking the next task.
@@ -2241,37 +2865,73 @@ need_resched:
        }
 
        cpu = smp_processor_id();
-       if (unlikely(!rq->nr_running)) {
-               idle_balance(cpu, rq);
-               if (!rq->nr_running) {
-                       next = rq->idle;
-                       rq->expired_timestamp = 0;
-                       wake_sleeping_dependent(cpu, rq);
-                       goto switch_tasks;
-               }
+#ifdef CONFIG_VSERVER_HARDCPU          
+       if (!list_empty(&rq->hold_queue)) {
+               struct list_head *l, *n;
+               int ret;
+
+               vxi = NULL;
+               list_for_each_safe(l, n, &rq->hold_queue) {
+                       next = list_entry(l, task_t, run_list);
+                       if (vxi == next->vx_info)
+                               continue;
+
+                       vxi = next->vx_info;
+                       ret = vx_tokens_recalc(vxi);
+                       // tokens = vx_tokens_avail(next);
+
+                       if (ret > 0) {
+                               list_del(&next->run_list);
+                               next->state &= ~TASK_ONHOLD;
+                               recalc_task_prio(next, now);
+                               __activate_task(next, rq);
+                               // printk("··· unhold %p\n", next);
+                               break;
+                       }
+                       if ((ret < 0) && (maxidle < ret))
+                               maxidle = ret;
+               }       
        }
+       rq->idle_tokens = -maxidle;
 
-       array = rq->active;
-       if (unlikely(!array->nr_active)) {
-               /*
-                * Switch the active and expired arrays.
-                */
-               rq->active = rq->expired;
-               rq->expired = array;
-               array = rq->active;
-               rq->expired_timestamp = 0;
-               rq->best_expired_prio = MAX_PRIO;
+pick_next:
+#endif
+       if (unlikely(!rq->nr_running)) {
+               idle_balance(cpu, rq);
+                if (!rq->nr_running) {
+                        next = rq->idle;
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+                        rq->expired_timestamp = 0;
+#endif
+                        wake_sleeping_dependent(cpu, rq);
+                        goto switch_tasks;
+                }
        }
 
-       idx = sched_find_first_bit(array->bitmap);
-       queue = array->queue + idx;
-       next = list_entry(queue->next, task_t, run_list);
+       next = rq_get_next_task(rq);
 
        if (dependent_sleeper(cpu, rq, next)) {
                next = rq->idle;
                goto switch_tasks;
        }
 
+#ifdef CONFIG_VSERVER_HARDCPU          
+       vxi = next->vx_info;
+       if (vxi && __vx_flags(vxi->vx_flags,
+               VXF_SCHED_PAUSE|VXF_SCHED_HARD, 0)) {
+               int ret = vx_tokens_recalc(vxi);
+
+               if (unlikely(ret <= 0)) {
+                       if (ret && (rq->idle_tokens > -ret))
+                               rq->idle_tokens = -ret;
+                       deactivate_task(next, rq);
+                       list_add_tail(&next->run_list, &rq->hold_queue);
+                       next->state |= TASK_ONHOLD;                     
+                       goto pick_next;
+               }
+       }
+#endif
+
        if (!rt_task(next) && next->activated > 0) {
                unsigned long long delta = now - next->timestamp;
 
@@ -2286,7 +2946,8 @@ need_resched:
        next->activated = 0;
 switch_tasks:
        prefetch(next);
-       clear_tsk_need_resched(prev);
+       if (test_and_clear_tsk_thread_flag(prev,TIF_NEED_RESCHED))
+               rq->nr_preempt++;
        RCU_qsctr(task_cpu(prev))++;
 
        prev->sleep_avg -= run_time;
@@ -2295,9 +2956,12 @@ switch_tasks:
                if (!(HIGH_CREDIT(prev) || LOW_CREDIT(prev)))
                        prev->interactive_credit--;
        }
+       add_delay_ts(prev,runcpu_total,prev->timestamp,now);
        prev->timestamp = now;
 
        if (likely(prev != next)) {
+               add_delay_ts(next,waitcpu_total,next->timestamp,now);
+               inc_delay(next,runs);
                next->timestamp = now;
                rq->nr_switches++;
                rq->curr = next;
@@ -2315,10 +2979,19 @@ switch_tasks:
        preempt_enable_no_resched();
        if (test_thread_flag(TIF_NEED_RESCHED))
                goto need_resched;
+
+       return;
+
+ dump_scheduling_disabled:
+       /* allow scheduling only if this is the dumping cpu */
+       if (dump_oncpu != smp_processor_id()+1) {
+               while (dump_oncpu)
+                       cpu_relax();
+       }
+       return;
 }
 
 EXPORT_SYMBOL(schedule);
-
 #ifdef CONFIG_PREEMPT
 /*
  * this is is the entry point to schedule() from in-kernel preemption
@@ -2501,10 +3174,21 @@ EXPORT_SYMBOL(wait_for_completion);
        __remove_wait_queue(q, &wait);                  \
        spin_unlock_irqrestore(&q->lock, flags);
 
+#define SLEEP_ON_BKLCHECK                              \
+       if (unlikely(!kernel_locked()) &&               \
+           sleep_on_bkl_warnings < 10) {               \
+               sleep_on_bkl_warnings++;                \
+               WARN_ON(1);                             \
+       }
+
+static int sleep_on_bkl_warnings;
+
 void fastcall __sched interruptible_sleep_on(wait_queue_head_t *q)
 {
        SLEEP_ON_VAR
 
+       SLEEP_ON_BKLCHECK
+
        current->state = TASK_INTERRUPTIBLE;
 
        SLEEP_ON_HEAD
@@ -2518,6 +3202,8 @@ long fastcall __sched interruptible_sleep_on_timeout(wait_queue_head_t *q, long
 {
        SLEEP_ON_VAR
 
+       SLEEP_ON_BKLCHECK
+
        current->state = TASK_INTERRUPTIBLE;
 
        SLEEP_ON_HEAD
@@ -2529,23 +3215,12 @@ long fastcall __sched interruptible_sleep_on_timeout(wait_queue_head_t *q, long
 
 EXPORT_SYMBOL(interruptible_sleep_on_timeout);
 
-void fastcall __sched sleep_on(wait_queue_head_t *q)
-{
-       SLEEP_ON_VAR
-
-       current->state = TASK_UNINTERRUPTIBLE;
-
-       SLEEP_ON_HEAD
-       schedule();
-       SLEEP_ON_TAIL
-}
-
-EXPORT_SYMBOL(sleep_on);
-
 long fastcall __sched sleep_on_timeout(wait_queue_head_t *q, long timeout)
 {
        SLEEP_ON_VAR
 
+       SLEEP_ON_BKLCHECK
+
        current->state = TASK_UNINTERRUPTIBLE;
 
        SLEEP_ON_HEAD
@@ -3006,7 +3681,7 @@ asmlinkage long sys_sched_yield(void)
 {
        runqueue_t *rq = this_rq_lock();
        prio_array_t *array = current->array;
-       prio_array_t *target = rq->expired;
+       prio_array_t *target = rq_expired(current,rq);
 
        /*
         * We implement yielding by moving the task into the expired
@@ -3016,7 +3691,7 @@ asmlinkage long sys_sched_yield(void)
         *  array.)
         */
        if (unlikely(rt_task(current)))
-               target = rq->active;
+               target = rq_active(current,rq);
 
        dequeue_task(current, array);
        enqueue_task(current, target);
@@ -3035,12 +3710,34 @@ asmlinkage long sys_sched_yield(void)
 
 void __sched __cond_resched(void)
 {
-       set_current_state(TASK_RUNNING);
-       schedule();
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+       __might_sleep(__FILE__, __LINE__, 0);
+#endif
+       /*
+        * The system_state check is somewhat ugly but we might be
+        * called during early boot when we are not yet ready to reschedule.
+        */
+       if (need_resched() && system_state >= SYSTEM_BOOTING_SCHEDULER_OK) {
+               set_current_state(TASK_RUNNING);
+               schedule();
+       }
 }
 
 EXPORT_SYMBOL(__cond_resched);
 
+void __sched __cond_resched_lock(spinlock_t * lock)
+{
+        if (need_resched()) {
+                _raw_spin_unlock(lock);
+                preempt_enable_no_resched();
+               set_current_state(TASK_RUNNING);
+               schedule();
+                spin_lock(lock);
+        }
+}
+
+EXPORT_SYMBOL(__cond_resched_lock);
+
 /**
  * yield - yield the current processor to other threads.
  *
@@ -3065,10 +3762,13 @@ EXPORT_SYMBOL(yield);
 void __sched io_schedule(void)
 {
        struct runqueue *rq = this_rq();
+       def_delay_var(dstart);
 
+       start_delay_set(dstart,PF_IOWAIT);
        atomic_inc(&rq->nr_iowait);
        schedule();
        atomic_dec(&rq->nr_iowait);
+       add_io_delay(dstart);
 }
 
 EXPORT_SYMBOL(io_schedule);
@@ -3077,10 +3777,13 @@ long __sched io_schedule_timeout(long timeout)
 {
        struct runqueue *rq = this_rq();
        long ret;
+       def_delay_var(dstart);
 
+       start_delay_set(dstart,PF_IOWAIT);
        atomic_inc(&rq->nr_iowait);
        ret = schedule_timeout(timeout);
        atomic_dec(&rq->nr_iowait);
+       add_io_delay(dstart);
        return ret;
 }
 
@@ -3266,6 +3969,8 @@ void show_state(void)
        read_unlock(&tasklist_lock);
 }
 
+EXPORT_SYMBOL_GPL(show_state);
+
 void __devinit init_idle(task_t *idle, int cpu)
 {
        runqueue_t *idle_rq = cpu_rq(cpu), *rq = cpu_rq(task_cpu(idle));
@@ -3387,7 +4092,6 @@ static void __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
        if (!cpu_isset(dest_cpu, p->cpus_allowed))
                goto out;
 
-       set_task_cpu(p, dest_cpu);
        if (p->array) {
                /*
                 * Sync timestamp with rq_dest's before activating.
@@ -3398,10 +4102,12 @@ static void __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
                p->timestamp = p->timestamp - rq_src->timestamp_last_tick
                                + rq_dest->timestamp_last_tick;
                deactivate_task(p, rq_src);
+               set_task_cpu(p, dest_cpu);
                activate_task(p, rq_dest, 0);
                if (TASK_PREEMPTS_CURR(p, rq_dest))
                        resched_task(rq_dest->curr);
-       }
+       } else
+               set_task_cpu(p, dest_cpu);
 
 out:
        double_rq_unlock(rq_src, rq_dest);
@@ -3910,7 +4616,7 @@ int in_sched_functions(unsigned long addr)
 void __init sched_init(void)
 {
        runqueue_t *rq;
-       int i, j, k;
+       int i;
 
 #ifdef CONFIG_SMP
        /* Set up an initial dummy domain for early boot */
@@ -3929,36 +4635,52 @@ void __init sched_init(void)
        sched_group_init.next = &sched_group_init;
        sched_group_init.cpu_power = SCHED_LOAD_SCALE;
 #endif
+       init_cpu_classes();
 
        for (i = 0; i < NR_CPUS; i++) {
+#ifndef CONFIG_CKRM_CPU_SCHEDULE
+               int j, k;
                prio_array_t *array;
 
                rq = cpu_rq(i);
                spin_lock_init(&rq->lock);
+
+               for (j = 0; j < 2; j++) {
+                       array = rq->arrays + j;
+                       for (k = 0; k < MAX_PRIO; k++) {
+                               INIT_LIST_HEAD(array->queue + k);
+                               __clear_bit(k, array->bitmap);
+                       }
+                       // delimiter for bitsearch
+                       __set_bit(MAX_PRIO, array->bitmap);
+               }
+
                rq->active = rq->arrays;
                rq->expired = rq->arrays + 1;
+#else
+               rq = cpu_rq(i);
+               spin_lock_init(&rq->lock);
+#endif
+
                rq->best_expired_prio = MAX_PRIO;
 
 #ifdef CONFIG_SMP
                rq->sd = &sched_domain_init;
                rq->cpu_load = 0;
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+               ckrm_load_init(rq_ckrm_load(rq));
+#endif
                rq->active_balance = 0;
                rq->push_cpu = 0;
                rq->migration_thread = NULL;
                INIT_LIST_HEAD(&rq->migration_queue);
+#endif
+#ifdef CONFIG_VSERVER_HARDCPU          
+               INIT_LIST_HEAD(&rq->hold_queue);
 #endif
                atomic_set(&rq->nr_iowait, 0);
-
-               for (j = 0; j < 2; j++) {
-                       array = rq->arrays + j;
-                       for (k = 0; k < MAX_PRIO; k++) {
-                               INIT_LIST_HEAD(array->queue + k);
-                               __clear_bit(k, array->bitmap);
-                       }
-                       // delimiter for bitsearch
-                       __set_bit(MAX_PRIO, array->bitmap);
-               }
        }
+
        /*
         * We have to do a little magic to get the first
         * thread right in SMP mode.
@@ -3967,6 +4689,11 @@ void __init sched_init(void)
        rq->curr = current;
        rq->idle = current;
        set_task_cpu(current, smp_processor_id());
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+       cpu_demand_event(&(current)->demand_stat,CPU_DEMAND_INIT,0);
+       current->cpu_class = get_default_cpu_class();
+       current->array = NULL;
+#endif
        wake_up_forked_process(current);
 
        /*
@@ -3977,20 +4704,23 @@ void __init sched_init(void)
 }
 
 #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
-void __might_sleep(char *file, int line)
+void __might_sleep(char *file, int line, int atomic_depth)
 {
 #if defined(in_atomic)
        static unsigned long prev_jiffy;        /* ratelimiting */
 
-       if ((in_atomic() || irqs_disabled()) &&
+#ifndef CONFIG_PREEMPT
+       atomic_depth = 0;
+#endif
+       if (((in_atomic() != atomic_depth) || irqs_disabled()) &&
            system_state == SYSTEM_RUNNING) {
                if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
                        return;
                prev_jiffy = jiffies;
                printk(KERN_ERR "Debug: sleeping function called from invalid"
                                " context at %s:%d\n", file, line);
-               printk("in_atomic():%d, irqs_disabled():%d\n",
-                       in_atomic(), irqs_disabled());
+               printk("in_atomic():%d[expected: %d], irqs_disabled():%d\n",
+                       in_atomic(), atomic_depth, irqs_disabled());
                dump_stack();
        }
 #endif
@@ -4043,3 +4773,42 @@ void __sched __preempt_write_lock(rwlock_t *lock)
 
 EXPORT_SYMBOL(__preempt_write_lock);
 #endif /* defined(CONFIG_SMP) && defined(CONFIG_PREEMPT) */
+
+#ifdef CONFIG_DELAY_ACCT
+int task_running_sys(struct task_struct *p)
+{
+       return task_running(task_rq(p),p);
+}
+EXPORT_SYMBOL(task_running_sys);
+#endif
+
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+/**
+ * return the classqueue object of a certain processor
+ */
+struct classqueue_struct * get_cpu_classqueue(int cpu)
+{
+       return (& (cpu_rq(cpu)->classqueue) );
+}
+
+/**
+ * _ckrm_cpu_change_class - change the class of a task
+ */
+void _ckrm_cpu_change_class(task_t *tsk, struct ckrm_cpu_class *newcls)
+{
+       prio_array_t *array;
+       struct runqueue *rq;
+       unsigned long flags;
+
+       rq = task_rq_lock(tsk,&flags); 
+       array = tsk->array;
+       if (array) {
+               dequeue_task(tsk,array);
+               tsk->cpu_class = newcls;
+               enqueue_task(tsk,rq_active(tsk,rq));
+       } else
+               tsk->cpu_class = newcls;
+
+       task_rq_unlock(rq,&flags);
+}
+#endif
index 6ea3d40..b3574b0 100644 (file)
@@ -417,6 +417,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
        }
 }
 
+EXPORT_SYMBOL_GPL(flush_signal_handlers);
 
 /* Notify the system that a driver wants to block all signals for this
  * process, and wants to be notified if any signals at all were to be
@@ -1054,6 +1055,9 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
        unsigned long flags;
        int ret;
 
+       if (!vx_check(vx_task_xid(p), VX_ADMIN|VX_WATCH|VX_IDENT))
+               return -ESRCH;
+
        ret = check_kill_permission(sig, info, p);
        if (!ret && sig && p->sighand) {
                spin_lock_irqsave(&p->sighand->siglock, flags);
@@ -1552,6 +1556,34 @@ do_notify_parent_cldstop(struct task_struct *tsk, struct task_struct *parent)
        spin_unlock_irqrestore(&sighand->siglock, flags);
 }
 
+int print_fatal_signals = 0;
+
+static void print_fatal_signal(struct pt_regs *regs, int signr)
+{
+       int i;
+       unsigned char insn;
+       printk("%s/%d: potentially unexpected fatal signal %d.\n",
+               current->comm, current->pid, signr);
+               
+#ifdef __i386__
+       printk("code at %08lx: ", regs->eip);
+       for (i = 0; i < 16; i++) {
+               __get_user(insn, (unsigned char *)(regs->eip + i));
+               printk("%02x ", insn);
+       }
+#endif 
+       printk("\n");
+       show_regs(regs);
+}
+
+static int __init setup_print_fatal_signals(char *str)
+{
+       get_option (&str, &print_fatal_signals);
+
+       return 1;
+}
+
+__setup("print-fatal-signals=", setup_print_fatal_signals);
 
 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
 
@@ -1743,6 +1775,11 @@ relock:
                if (!signr)
                        break; /* will return 0 */
 
+               if ((signr == SIGSEGV) && print_fatal_signals) {
+                       spin_unlock_irq(&current->sighand->siglock);
+                       print_fatal_signal(regs, signr);
+                       spin_lock_irq(&current->sighand->siglock);
+               }
                if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
                        ptrace_signal_deliver(regs, cookie);
 
@@ -1847,6 +1884,8 @@ relock:
                 * Anything else is fatal, maybe with a core dump.
                 */
                current->flags |= PF_SIGNALED;
+               if (print_fatal_signals)
+                       print_fatal_signal(regs, signr);
                if (sig_kernel_coredump(signr) &&
                    do_coredump((long)signr, signr, regs)) {
                        /*
index 1bbc66a..c69f6ed 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/mman.h>
 #include <linux/smp_lock.h>
 #include <linux/notifier.h>
+#include <linux/kmod.h>
 #include <linux/reboot.h>
 #include <linux/prctl.h>
 #include <linux/init.h>
@@ -23,6 +24,9 @@
 #include <linux/security.h>
 #include <linux/dcookies.h>
 #include <linux/suspend.h>
+#include <linux/ckrm.h>
+#include <linux/vs_base.h>
+#include <linux/vs_cvirt.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -343,7 +347,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
                        if (!who)
                                user = current->user;
                        else
-                               user = find_user(who);
+                               user = find_user(vx_current_xid(), who);
 
                        if (!user)
                                goto out_unlock;
@@ -404,7 +408,7 @@ asmlinkage long sys_getpriority(int which, int who)
                        if (!who)
                                user = current->user;
                        else
-                               user = find_user(who);
+                               user = find_user(vx_current_xid(), who);
 
                        if (!user)
                                goto out_unlock;
@@ -426,6 +430,7 @@ out_unlock:
        return retval;
 }
 
+long vs_reboot(unsigned int, void *);
 
 /*
  * Reboot system call: for obvious reasons only root may call it,
@@ -451,6 +456,9 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
                        magic2 != LINUX_REBOOT_MAGIC2C))
                return -EINVAL;
 
+       if (!vx_check(0, VX_ADMIN|VX_WATCH))
+               return vs_reboot(cmd, arg);
+
        lock_kernel();
        switch (cmd) {
        case LINUX_REBOOT_CMD_RESTART:
@@ -601,6 +609,9 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid)
        current->fsgid = new_egid;
        current->egid = new_egid;
        current->gid = new_rgid;
+
+       ckrm_cb_gid();
+
        return 0;
 }
 
@@ -638,6 +649,9 @@ asmlinkage long sys_setgid(gid_t gid)
        }
        else
                return -EPERM;
+
+       ckrm_cb_gid();
+
        return 0;
 }
   
@@ -645,7 +659,7 @@ static int set_user(uid_t new_ruid, int dumpclear)
 {
        struct user_struct *new_user;
 
-       new_user = alloc_uid(new_ruid);
+       new_user = alloc_uid(vx_current_xid(), new_ruid);
        if (!new_user)
                return -EAGAIN;
 
@@ -726,6 +740,8 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
                current->suid = current->euid;
        current->fsuid = current->euid;
 
+       ckrm_cb_uid();
+
        return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RE);
 }
 
@@ -771,6 +787,8 @@ asmlinkage long sys_setuid(uid_t uid)
        current->fsuid = current->euid = uid;
        current->suid = new_suid;
 
+       ckrm_cb_uid();
+
        return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID);
 }
 
@@ -817,6 +835,8 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
        if (suid != (uid_t) -1)
                current->suid = suid;
 
+       ckrm_cb_uid();
+
        return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RES);
 }
 
@@ -866,6 +886,9 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
                current->gid = rgid;
        if (sgid != (gid_t) -1)
                current->sgid = sgid;
+
+       ckrm_cb_gid();
+
        return 0;
 }
 
@@ -1393,7 +1416,7 @@ asmlinkage long sys_newuname(struct new_utsname __user * name)
        int errno = 0;
 
        down_read(&uts_sem);
-       if (copy_to_user(name,&system_utsname,sizeof *name))
+       if (copy_to_user(name, vx_new_utsname(), sizeof *name))
                errno = -EFAULT;
        up_read(&uts_sem);
        return errno;
@@ -1404,15 +1427,17 @@ asmlinkage long sys_sethostname(char __user *name, int len)
        int errno;
        char tmp[__NEW_UTS_LEN];
 
-       if (!capable(CAP_SYS_ADMIN))
+       if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SET_UTSNAME))
                return -EPERM;
        if (len < 0 || len > __NEW_UTS_LEN)
                return -EINVAL;
        down_write(&uts_sem);
        errno = -EFAULT;
        if (!copy_from_user(tmp, name, len)) {
-               memcpy(system_utsname.nodename, tmp, len);
-               system_utsname.nodename[len] = 0;
+               char *ptr = vx_new_uts(nodename);
+
+               memcpy(ptr, tmp, len);
+               ptr[len] = 0;
                errno = 0;
        }
        up_write(&uts_sem);
@@ -1424,15 +1449,17 @@ asmlinkage long sys_sethostname(char __user *name, int len)
 asmlinkage long sys_gethostname(char __user *name, int len)
 {
        int i, errno;
+       char *ptr;
 
        if (len < 0)
                return -EINVAL;
        down_read(&uts_sem);
-       i = 1 + strlen(system_utsname.nodename);
+       ptr = vx_new_uts(nodename);
+       i = 1 + strlen(ptr);
        if (i > len)
                i = len;
        errno = 0;
-       if (copy_to_user(name, system_utsname.nodename, i))
+       if (copy_to_user(name, ptr, i))
                errno = -EFAULT;
        up_read(&uts_sem);
        return errno;
@@ -1449,7 +1476,7 @@ asmlinkage long sys_setdomainname(char __user *name, int len)
        int errno;
        char tmp[__NEW_UTS_LEN];
 
-       if (!capable(CAP_SYS_ADMIN))
+       if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SET_UTSNAME))
                return -EPERM;
        if (len < 0 || len > __NEW_UTS_LEN)
                return -EINVAL;
@@ -1457,8 +1484,10 @@ asmlinkage long sys_setdomainname(char __user *name, int len)
        down_write(&uts_sem);
        errno = -EFAULT;
        if (!copy_from_user(tmp, name, len)) {
-               memcpy(system_utsname.domainname, tmp, len);
-               system_utsname.domainname[len] = 0;
+               char *ptr = vx_new_uts(domainname);
+
+               memcpy(ptr, tmp, len);
+               ptr[len] = 0;
                errno = 0;
        }
        up_write(&uts_sem);
@@ -1510,7 +1539,7 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
        old_rlim = current->rlim + resource;
        if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
             (new_rlim.rlim_max > old_rlim->rlim_max)) &&
-           !capable(CAP_SYS_RESOURCE))
+           !capable(CAP_SYS_RESOURCE) && !vx_ccaps(VXC_SET_RLIMIT))
                return -EPERM;
        if (resource == RLIMIT_NOFILE) {
                if (new_rlim.rlim_cur > NR_OPEN || new_rlim.rlim_max > NR_OPEN)
index 3905df6..d5c21ca 100644 (file)
@@ -65,6 +65,29 @@ extern int min_free_kbytes;
 extern int printk_ratelimit_jiffies;
 extern int printk_ratelimit_burst;
 
+extern unsigned int vdso_enabled;
+
+int exec_shield = 1;
+int exec_shield_randomize = 1;
+
+static int __init setup_exec_shield(char *str)
+{
+        get_option (&str, &exec_shield);
+
+        return 1;
+}
+
+__setup("exec-shield=", setup_exec_shield);
+
+static int __init setup_exec_shield_randomize(char *str)
+{
+        get_option (&str, &exec_shield_randomize);
+
+        return 1;
+}
+
+__setup("exec-shield-randomize=", setup_exec_shield_randomize);
+
 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
 static int maxolduid = 65535;
 static int minolduid;
@@ -77,6 +100,7 @@ extern char modprobe_path[];
 #ifdef CONFIG_HOTPLUG
 extern char hotplug_path[];
 #endif
+extern char vshelper_path[];
 #ifdef CONFIG_CHR_DEV_SG
 extern int sg_big_buff;
 #endif
@@ -143,6 +167,8 @@ extern ctl_table random_table[];
 extern ctl_table pty_table[];
 #endif
 
+int sysctl_legacy_va_layout;
+
 /* /proc declarations: */
 
 #ifdef CONFIG_PROC_FS
@@ -267,6 +293,40 @@ static ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
+       {
+               .ctl_name       = KERN_PANIC,
+               .procname       = "exec-shield",
+               .data           = &exec_shield,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
+       {
+               .ctl_name       = KERN_PANIC,
+               .procname       = "exec-shield-randomize",
+               .data           = &exec_shield_randomize,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
+       {
+               .ctl_name       = KERN_PANIC,
+               .procname       = "print-fatal-signals",
+               .data           = &print_fatal_signals,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
+#if __i386__
+       {
+               .ctl_name       = KERN_PANIC,
+               .procname       = "vdso",
+               .data           = &vdso_enabled,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
+#endif
        {
                .ctl_name       = KERN_CORE_USES_PID,
                .procname       = "core_uses_pid",
@@ -289,7 +349,7 @@ static ctl_table kern_table[] = {
                .procname       = "tainted",
                .data           = &tainted,
                .maxlen         = sizeof(int),
-               .mode           = 0644,
+               .mode           = 0444,
                .proc_handler   = &proc_dointvec,
        },
        {
@@ -409,6 +469,15 @@ static ctl_table kern_table[] = {
                .strategy       = &sysctl_string,
        },
 #endif
+       {
+               .ctl_name       = KERN_VSHELPER,
+               .procname       = "vshelper",
+               .data           = &vshelper_path,
+               .maxlen         = 256,
+               .mode           = 0644,
+               .proc_handler   = &proc_dostring,
+               .strategy       = &sysctl_string,
+       },
 #ifdef CONFIG_CHR_DEV_SG
        {
                .ctl_name       = KERN_SG_BIG_BUFF,
@@ -722,14 +791,6 @@ static ctl_table vm_table[] = {
                .extra1         = (void *)&hugetlb_zero,
                .extra2         = (void *)&hugetlb_infinity,
         },
-        {
-               .ctl_name       = VM_HUGETLB_GROUP,
-               .procname       = "hugetlb_shm_group",
-               .data           = &sysctl_hugetlb_shm_group,
-               .maxlen         = sizeof(gid_t),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec,
-        },
 #endif
        {
                .ctl_name       = VM_LOWER_ZONE_PROTECTION,
@@ -789,6 +850,16 @@ static ctl_table vm_table[] = {
                .strategy       = &sysctl_intvec,
                .extra1         = &zero,
        },
+       {
+               .ctl_name       = VM_LEGACY_VA_LAYOUT,
+               .procname       = "legacy_va_layout",
+               .data           = &sysctl_legacy_va_layout,
+               .maxlen         = sizeof(sysctl_legacy_va_layout),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &zero,
+       },
        { .ctl_name = 0 }
 };
 
index 4850abb..f7d42e8 100644 (file)
@@ -31,6 +31,9 @@
 #include <linux/time.h>
 #include <linux/jiffies.h>
 #include <linux/cpu.h>
+#include <linux/vs_base.h>
+#include <linux/vs_cvirt.h>
+#include <linux/vserver/sched.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -996,7 +999,7 @@ asmlinkage unsigned long sys_alarm(unsigned int seconds)
  */
 asmlinkage long sys_getpid(void)
 {
-       return current->tgid;
+       return vx_map_tgid(current->vx_info, current->tgid);
 }
 
 /*
@@ -1040,7 +1043,7 @@ asmlinkage long sys_getppid(void)
 #endif
                break;
        }
-       return pid;
+       return vx_map_tgid(current->vx_info, pid);
 }
 
 asmlinkage long sys_getuid(void)
@@ -1249,6 +1252,8 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
                        tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
                        tp.tv_sec++;
                }
+               if (vx_flags(VXF_VIRT_UPTIME, 0))
+                       vx_vsi_uptime(&tp, NULL);
                val.uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
 
                val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
@@ -1258,6 +1263,9 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
                val.procs = nr_threads;
        } while (read_seqretry(&xtime_lock, seq));
 
+/*     if (vx_flags(VXF_VIRT_CPU, 0))
+               vx_vsi_cpu(val);
+*/
        si_meminfo(&val);
        si_swapinfo(&val);
 
index 9f9859e..b5473e9 100644 (file)
@@ -20,8 +20,8 @@
 #define UIDHASH_BITS           8
 #define UIDHASH_SZ             (1 << UIDHASH_BITS)
 #define UIDHASH_MASK           (UIDHASH_SZ - 1)
-#define __uidhashfn(uid)       (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
-#define uidhashentry(uid)      (uidhash_table + __uidhashfn((uid)))
+#define __uidhashfn(xid,uid)   ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
+#define uidhashentry(xid,uid)  (uidhash_table + __uidhashfn((xid),(uid)))
 
 static kmem_cache_t *uid_cachep;
 static struct list_head uidhash_table[UIDHASH_SZ];
@@ -32,7 +32,8 @@ struct user_struct root_user = {
        .processes      = ATOMIC_INIT(1),
        .files          = ATOMIC_INIT(0),
        .sigpending     = ATOMIC_INIT(0),
-       .mq_bytes       = 0
+       .mq_bytes       = 0,
+       .locked_shm     = 0
 };
 
 /*
@@ -48,7 +49,7 @@ static inline void uid_hash_remove(struct user_struct *up)
        list_del(&up->uidhash_list);
 }
 
-static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
+static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
 {
        struct list_head *up;
 
@@ -57,7 +58,7 @@ static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *has
 
                user = list_entry(up, struct user_struct, uidhash_list);
 
-               if(user->uid == uid) {
+               if(user->uid == uid && user->xid == xid) {
                        atomic_inc(&user->__count);
                        return user;
                }
@@ -72,12 +73,12 @@ static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *has
  *
  * If the user_struct could not be found, return NULL.
  */
-struct user_struct *find_user(uid_t uid)
+struct user_struct *find_user(xid_t xid, uid_t uid)
 {
        struct user_struct *ret;
 
        spin_lock(&uidhash_lock);
-       ret = uid_hash_find(uid, uidhashentry(uid));
+       ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
        spin_unlock(&uidhash_lock);
        return ret;
 }
@@ -91,13 +92,13 @@ void free_uid(struct user_struct *up)
        }
 }
 
-struct user_struct * alloc_uid(uid_t uid)
+struct user_struct * alloc_uid(xid_t xid, uid_t uid)
 {
-       struct list_head *hashent = uidhashentry(uid);
+       struct list_head *hashent = uidhashentry(xid, uid);
        struct user_struct *up;
 
        spin_lock(&uidhash_lock);
-       up = uid_hash_find(uid, hashent);
+       up = uid_hash_find(xid, uid, hashent);
        spin_unlock(&uidhash_lock);
 
        if (!up) {
@@ -107,19 +108,21 @@ struct user_struct * alloc_uid(uid_t uid)
                if (!new)
                        return NULL;
                new->uid = uid;
+               new->xid = xid;
                atomic_set(&new->__count, 1);
                atomic_set(&new->processes, 0);
                atomic_set(&new->files, 0);
                atomic_set(&new->sigpending, 0);
 
                new->mq_bytes = 0;
+               new->locked_shm = 0;
 
                /*
                 * Before adding this, check whether we raced
                 * on adding the same user already..
                 */
                spin_lock(&uidhash_lock);
-               up = uid_hash_find(uid, hashent);
+               up = uid_hash_find(xid, uid, hashent);
                if (up) {
                        kmem_cache_free(uid_cachep, new);
                } else {
@@ -161,7 +164,7 @@ static int __init uid_cache_init(void)
 
        /* Insert the root user immediately (init already runs as root) */
        spin_lock(&uidhash_lock);
-       uid_hash_insert(&root_user, uidhashentry(0));
+       uid_hash_insert(&root_user, uidhashentry(0,0));
        spin_unlock(&uidhash_lock);
 
        return 0;
diff --git a/kernel/vserver/Kconfig b/kernel/vserver/Kconfig
new file mode 100644 (file)
index 0000000..5160a01
--- /dev/null
@@ -0,0 +1,86 @@
+#
+# Linux VServer configuration
+#
+
+menu "Linux VServer"
+
+config VSERVER_LEGACY
+       bool    "Enable Legacy Kernel API"
+       default y
+       help
+         This enables the legacy API used in vs1.xx, which allows
+         to use older tools (for migration purposes).
+
+config VSERVER_PROC_SECURE
+       bool    "Enable Proc Security"
+       depends on PROC_FS
+       default y
+       help
+         Hide proc entries by default for xid>1
+
+config VSERVER_HARDCPU
+       bool    "Enable Hard CPU Limits"
+       depends on EXPERIMENTAL
+       default n
+       help
+         Activate the Hard CPU Limits
+
+choice
+       prompt  "Persistent Inode Context Tagging"
+       default INOXID_UGID24
+       help
+         This adds persistent context information to filesystems
+         mounted with the tagxid option. Tagging is a requirement
+         for per context disk limits and per context quota.
+
+
+config INOXID_NONE
+       bool    "Disabled"
+       help
+         no context information is store for inodes
+
+config INOXID_UID16
+       bool    "UID16/GID32"
+       help
+         reduces UID to 16 bit, but leaves GID at 32 bit.
+
+config INOXID_GID16
+       bool    "UID32/GID16"
+       help
+         reduces GID to 16 bit, but leaves UID at 32 bit.
+
+config INOXID_UGID24
+       bool    "UID24/GID24"
+       help
+         uses the upper 8bit from UID and GID for XID tagging
+         which leaves 24bit for UID/GID each, which should be
+         more than sufficient for normal use.
+
+config INOXID_INTERN
+       bool    "UID32/GID32"
+       help
+         this uses otherwise reserved inode fields in the on
+         disk representation, which limits the use to a few
+         filesystems (currently ext2 and ext3)
+
+config INOXID_RUNTIME
+       bool    "Runtime"
+       depends on EXPERIMENTAL
+       help
+         inodes are tagged when first accessed, this doesn't
+         require any persistant information, but might give
+         funny results for mixed access.
+
+endchoice
+
+config VSERVER_DEBUG
+       bool    "Compile Debugging Code"
+       default n
+       help
+         Set this to yes if you want to be able to activate
+         debugging output at runtime. It adds a probably small
+         overhead (~ ??%) to all vserver related functions and
+         increases the kernel size by about 20k.
+
+endmenu
+
diff --git a/kernel/vserver/Makefile b/kernel/vserver/Makefile
new file mode 100644 (file)
index 0000000..577c3ca
--- /dev/null
@@ -0,0 +1,13 @@
+#
+# Makefile for the Linux vserver routines.
+#
+
+
+obj-y          += vserver.o
+
+vserver-y      := switch.o context.o namespace.o sched.o network.o inode.o \
+                  limit.o cvirt.o signal.o proc.o helper.o init.o dlimit.o
+
+vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o
+vserver-$(CONFIG_VSERVER_LEGACY) += legacy.o
+
diff --git a/kernel/vserver/context.c b/kernel/vserver/context.c
new file mode 100644 (file)
index 0000000..a1860ef
--- /dev/null
@@ -0,0 +1,732 @@
+/*
+ *  linux/kernel/vserver/context.c
+ *
+ *  Virtual Server: Context Support
+ *
+ *  Copyright (C) 2003-2004  Herbert Pötzl
+ *
+ *  V0.01  context helper
+ *  V0.02  vx_ctx_kill syscall command
+ *  V0.03  replaced context_info calls
+ *  V0.04  redesign of struct (de)alloc
+ *  V0.05  rlimit basic implementation
+ *  V0.06  task_xid and info commands
+ *  V0.07  context flags and caps
+ *  V0.08  switch to RCU based hash
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/slab.h>
+#include <linux/vserver.h>
+#include <linux/vserver/legacy.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/kernel_stat.h>
+#include <linux/namespace.h>
+#include <linux/rcupdate.h>
+
+#define CKRM_VSERVER_INTEGRATION
+#ifdef CKRM_VSERVER_INTEGRATION
+#include <linux/ckrm.h>
+#endif //CKRM_VSERVER_INTEGRATION
+
+#include <asm/errno.h>
+
+
+/*     __alloc_vx_info()
+
+       * allocate an initialized vx_info struct
+       * doesn't make it visible (hash)                        */
+
+static struct vx_info *__alloc_vx_info(xid_t xid)
+{
+       struct vx_info *new = NULL;
+       
+       vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
+
+       /* would this benefit from a slab cache? */
+       new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
+       if (!new)
+               return 0;
+
+       memset (new, 0, sizeof(struct vx_info));
+       new->vx_id = xid;
+       INIT_RCU_HEAD(&new->vx_rcu);
+       INIT_HLIST_NODE(&new->vx_hlist);
+       atomic_set(&new->vx_refcnt, 0);
+       atomic_set(&new->vx_usecnt, 0);
+
+       /* rest of init goes here */
+       vx_info_init_limit(&new->limit);
+       vx_info_init_sched(&new->sched);
+       vx_info_init_cvirt(&new->cvirt);
+       vx_info_init_cacct(&new->cacct);
+
+       new->vx_flags = VXF_STATE_SETUP|VXF_STATE_INIT;
+       new->vx_bcaps = CAP_INIT_EFF_SET;
+       new->vx_ccaps = 0;
+
+       vxdprintk(VXD_CBIT(xid, 0),
+               "alloc_vx_info(%d) = %p", xid, new);
+       return new;
+}
+
+/*     __dealloc_vx_info()
+
+       * final disposal of vx_info                             */
+
+static void __dealloc_vx_info(struct vx_info *vxi)
+{
+       vxdprintk(VXD_CBIT(xid, 0),
+               "dealloc_vx_info(%p)", vxi);
+
+       vxi->vx_hlist.next = LIST_POISON1;
+       vxi->vx_id = -1;
+
+       if (vxi->vx_namespace)
+               put_namespace(vxi->vx_namespace);
+       if (vxi->vx_fs)
+               put_fs_struct(vxi->vx_fs);
+       
+       vx_info_exit_limit(&vxi->limit);
+       vx_info_exit_sched(&vxi->sched);
+       vx_info_exit_cvirt(&vxi->cvirt);
+       vx_info_exit_cacct(&vxi->cacct);
+       
+       BUG_ON(atomic_read(&vxi->vx_usecnt));
+       BUG_ON(atomic_read(&vxi->vx_refcnt));
+
+       kfree(vxi);
+}
+
+
+/*     hash table for vx_info hash */
+
+#define        VX_HASH_SIZE    13
+
+struct hlist_head vx_info_hash[VX_HASH_SIZE];
+
+static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
+
+
+static inline unsigned int __hashval(xid_t xid)
+{
+       return (xid % VX_HASH_SIZE);
+}
+
+
+
+/*     __hash_vx_info()
+
+       * add the vxi to the global hash table
+       * requires the hash_lock to be held                     */
+
+static inline void __hash_vx_info(struct vx_info *vxi)
+{
+       struct hlist_head *head;
+       
+       vxdprintk(VXD_CBIT(xid, 4),
+               "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
+       get_vx_info(vxi);
+       head = &vx_info_hash[__hashval(vxi->vx_id)];
+       hlist_add_head_rcu(&vxi->vx_hlist, head);
+}
+
+/*     __unhash_vx_info()
+
+       * remove the vxi from the global hash table
+       * requires the hash_lock to be held                     */
+
+static inline void __unhash_vx_info(struct vx_info *vxi)
+{
+       vxdprintk(VXD_CBIT(xid, 4),
+               "__unhash_vx_info: %p[#%d]", vxi, vxi->vx_id);
+       hlist_del_rcu(&vxi->vx_hlist);
+       put_vx_info(vxi);
+}
+
+
+/*     __lookup_vx_info()
+
+       * requires the rcu_read_lock()
+       * doesn't increment the vx_refcnt                       */
+
+static inline struct vx_info *__lookup_vx_info(xid_t xid)
+{
+       struct hlist_head *head = &vx_info_hash[__hashval(xid)];
+       struct hlist_node *pos;
+
+       hlist_for_each_rcu(pos, head) {
+               struct vx_info *vxi =
+                       hlist_entry(pos, struct vx_info, vx_hlist);
+
+               if (vxi->vx_id == xid) {
+                       return vxi;
+               }
+       }
+       return NULL;
+}
+
+
+/*     __vx_dynamic_id()
+
+       * find unused dynamic xid
+       * requires the hash_lock to be held                     */
+
+static inline xid_t __vx_dynamic_id(void)
+{
+       static xid_t seq = MAX_S_CONTEXT;
+       xid_t barrier = seq;
+       
+       do {
+               if (++seq > MAX_S_CONTEXT)
+                       seq = MIN_D_CONTEXT;
+               if (!__lookup_vx_info(seq)) {
+                       vxdprintk(VXD_CBIT(xid, 4),
+                               "__vx_dynamic_id: [#%d]", seq);
+                       return seq;
+               }
+       } while (barrier != seq);
+       return 0;
+}
+
+/*     __loc_vx_info()
+
+       * locate or create the requested context
+       * get() it and if new hash it                           */
+
+static struct vx_info * __loc_vx_info(int id, int *err)
+{
+       struct vx_info *new, *vxi = NULL;
+       
+       vxdprintk(VXD_CBIT(xid, 1), "loc_vx_info(%d)*", id);
+
+       if (!(new = __alloc_vx_info(id))) {
+               *err = -ENOMEM;
+               return NULL;
+       }
+
+       spin_lock(&vx_info_hash_lock);
+
+       /* dynamic context requested */
+       if (id == VX_DYNAMIC_ID) {
+               id = __vx_dynamic_id();
+               if (!id) {
+                       printk(KERN_ERR "no dynamic context available.\n");
+                       goto out_unlock;
+               }
+               new->vx_id = id;
+       }
+       /* existing context requested */
+       else if ((vxi = __lookup_vx_info(id))) {
+               /* context in setup is not available */
+               if (vxi->vx_flags & VXF_STATE_SETUP) {
+                       vxdprintk(VXD_CBIT(xid, 0),
+                               "loc_vx_info(%d) = %p (not available)", id, vxi);
+                       vxi = NULL;
+                       *err = -EBUSY;
+               } else {
+                       vxdprintk(VXD_CBIT(xid, 0),
+                               "loc_vx_info(%d) = %p (found)", id, vxi);
+                       get_vx_info(vxi);
+                       *err = 0;
+               }
+               goto out_unlock;
+       }
+
+       /* new context requested */
+       vxdprintk(VXD_CBIT(xid, 0),
+               "loc_vx_info(%d) = %p (new)", id, new);
+       __hash_vx_info(get_vx_info(new));
+       vxi = new, new = NULL;
+       *err = 1;
+
+out_unlock:
+       spin_unlock(&vx_info_hash_lock);
+       if (new)
+               __dealloc_vx_info(new);
+       return vxi;
+}
+
+
+
+/*     exported stuff                                          */
+
+
+
+void rcu_free_vx_info(struct rcu_head *head)
+{
+       struct vx_info *vxi = container_of(head, struct vx_info, vx_rcu);
+       int usecnt, refcnt;
+
+       BUG_ON(!vxi || !head);
+
+       usecnt = atomic_read(&vxi->vx_usecnt);
+       BUG_ON(usecnt < 0);
+
+       refcnt = atomic_read(&vxi->vx_refcnt);
+       BUG_ON(refcnt < 0);
+
+       vxdprintk(VXD_CBIT(xid, 3),
+               "rcu_free_vx_info(%p): uc=%d", vxi, usecnt);
+       if (!usecnt)
+               __dealloc_vx_info(vxi);
+       else
+               printk("!!! rcu didn't free\n");
+}
+
+void unhash_vx_info(struct vx_info *vxi)
+{
+       spin_lock(&vx_info_hash_lock);
+       __unhash_vx_info(vxi);
+       spin_unlock(&vx_info_hash_lock);
+}
+
+/*     locate_vx_info()
+
+       * search for a vx_info and get() it                     
+       * negative id means current                             */
+
+struct vx_info *locate_vx_info(int id)
+{
+       struct vx_info *vxi;
+       
+       if (id < 0) {
+               vxi = get_vx_info(current->vx_info);
+       } else {
+               rcu_read_lock();
+               vxi = get_vx_info(__lookup_vx_info(id));
+               rcu_read_unlock();
+       }
+       return vxi;
+}
+
+/*     vx_info_is_hashed()
+
+       * verify that xid is still hashed                       */
+
+int vx_info_is_hashed(xid_t xid)
+{
+       int hashed;
+
+       rcu_read_lock();
+       hashed = (__lookup_vx_info(xid) != NULL);
+       rcu_read_unlock();
+       return hashed;
+}
+
+#ifdef CONFIG_VSERVER_LEGACY
+
+#if 0
+struct vx_info *alloc_vx_info(xid_t xid)
+{
+       return __alloc_vx_info(xid);
+}
+#endif
+
+struct vx_info *locate_or_create_vx_info(int id)
+{
+       int err;
+
+       return __loc_vx_info(id, &err);
+}
+
+#endif
+
+#ifdef CONFIG_PROC_FS
+
+#define hlist_for_each_rcu(pos, head) \
+        for (pos = (head)->first; pos && ({ prefetch(pos->next); 1;}); \
+               pos = pos->next, ({ smp_read_barrier_depends(); 0;}))
+
+int get_xid_list(int index, unsigned int *xids, int size)
+{
+       int hindex, nr_xids = 0;
+
+       rcu_read_lock();
+       for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
+               struct hlist_head *head = &vx_info_hash[hindex];
+               struct hlist_node *pos;
+
+               hlist_for_each_rcu(pos, head) {
+                       struct vx_info *vxi;
+
+                       if (--index > 0)
+                               continue;
+
+                       vxi = hlist_entry(pos, struct vx_info, vx_hlist);
+                       xids[nr_xids] = vxi->vx_id;                     
+                       if (++nr_xids >= size)
+                               goto out;
+               }
+       }
+out:
+       rcu_read_unlock();
+       return nr_xids;
+}
+#endif
+
+int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
+{
+       struct user_struct *new_user, *old_user;
+       
+       if (!p || !vxi)
+               BUG();
+       new_user = alloc_uid(vxi->vx_id, p->uid);
+       if (!new_user)
+               return -ENOMEM;
+
+       old_user = p->user;
+       if (new_user != old_user) {
+               atomic_inc(&new_user->processes);
+               atomic_dec(&old_user->processes);
+               p->user = new_user;
+       }
+       free_uid(old_user);
+       return 0;
+}
+
+void vx_mask_bcaps(struct task_struct *p)
+{
+       struct vx_info *vxi = p->vx_info;
+
+       p->cap_effective &= vxi->vx_bcaps;
+       p->cap_inheritable &= vxi->vx_bcaps;
+       p->cap_permitted &= vxi->vx_bcaps;
+}
+
+
+#include <linux/file.h>
+
+static inline int vx_nofiles_task(struct task_struct *tsk)
+{
+       struct files_struct *files = tsk->files;
+       const unsigned long *obptr;
+       int count, total;
+
+       spin_lock(&files->file_lock);
+       obptr = files->open_fds->fds_bits;
+       count = files->max_fds / (sizeof(unsigned long) * 8);
+       for (total = 0; count > 0; count--) {
+               if (*obptr)
+                       total += hweight_long(*obptr);
+               obptr++;
+       }
+       spin_unlock(&files->file_lock);
+       return total;
+}
+
+#if 0
+
+static inline int vx_openfd_task(struct task_struct *tsk)
+{
+       struct files_struct *files = tsk->files;
+       const unsigned long *bptr;
+       int count, total;
+
+       spin_lock(&files->file_lock);
+       bptr = files->open_fds->fds_bits;
+       count = files->max_fds / (sizeof(unsigned long) * 8);
+       for (total = 0; count > 0; count--) {
+               if (*bptr)
+                       total += hweight_long(*bptr);
+               bptr++;
+       }
+       spin_unlock(&files->file_lock);
+       return total;
+}
+
+#endif
+
+/*
+ *     migrate task to new context
+ *     gets vxi, puts old_vxi on change
+ */
+
+int vx_migrate_task(struct task_struct *p, struct vx_info *vxi)
+{
+       struct vx_info *old_vxi;
+       int ret = 0;
+       
+       if (!p || !vxi)
+               BUG();
+
+       old_vxi = task_get_vx_info(p);
+       if (old_vxi == vxi)
+               goto out;
+
+       vxdprintk(VXD_CBIT(xid, 5),
+               "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
+               vxi->vx_id, atomic_read(&vxi->vx_usecnt));
+
+       if (!(ret = vx_migrate_user(p, vxi))) {
+               int nofiles;
+
+               task_lock(p);
+               // openfd = vx_openfd_task(p);
+               nofiles = vx_nofiles_task(p);
+
+               if (old_vxi) {
+                       atomic_dec(&old_vxi->cacct.nr_threads);
+                       atomic_dec(&old_vxi->limit.rcur[RLIMIT_NPROC]);
+                       atomic_sub(nofiles, &old_vxi->limit.rcur[RLIMIT_NOFILE]);
+                       // atomic_sub(openfd, &old_vxi->limit.rcur[RLIMIT_OPENFD]);
+               }               
+               atomic_inc(&vxi->cacct.nr_threads);
+               atomic_inc(&vxi->limit.rcur[RLIMIT_NPROC]);
+               atomic_add(nofiles, &vxi->limit.rcur[RLIMIT_NOFILE]);
+               // atomic_add(openfd, &vxi->limit.rcur[RLIMIT_OPENFD]);
+
+               vxdprintk(VXD_CBIT(xid, 5),
+                       "moved task %p into vxi:%p[#%d]",
+                       p, vxi, vxi->vx_id);
+
+               /* should be handled in set_vx_info !! */
+               if (old_vxi)
+                       clr_vx_info(&p->vx_info);
+               set_vx_info(&p->vx_info, vxi);
+               p->xid = vxi->vx_id;
+               vx_mask_bcaps(p);
+               task_unlock(p);
+
+               /* obsoleted by clr/set */
+               // put_vx_info(old_vxi);
+       }
+out:
+
+
+#ifdef CKRM_VSERVER_INTEGRATION
+       do {
+         ckrm_cb_xid(p);
+       } while (0);
+#endif //CKRM_VSERVER_INTEGRATION
+
+
+       put_vx_info(old_vxi);
+       return ret;
+}
+
+int vx_set_init(struct vx_info *vxi, struct task_struct *p)
+{
+       if (!vxi)
+               return -EINVAL;
+        if (vxi->vx_initpid)
+                return -EPERM;
+
+        vxi->vx_initpid = p->tgid;
+       return 0;
+}
+
+
+/* vserver syscall commands below here */
+
+/* taks xid and vx_info functions */
+
+#include <asm/uaccess.h>
+
+
+int vc_task_xid(uint32_t id, void __user *data)
+{
+        xid_t xid;
+
+        if (id) {
+                struct task_struct *tsk;
+
+                if (!vx_check(0, VX_ADMIN|VX_WATCH))
+                        return -EPERM;
+
+                read_lock(&tasklist_lock);
+                tsk = find_task_by_pid(id);
+                xid = (tsk) ? tsk->xid : -ESRCH;
+                read_unlock(&tasklist_lock);
+        }
+        else
+                xid = current->xid;
+        return xid;
+}
+
+
+int vc_vx_info(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_vx_info_v0 vc_data;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
+               return -EPERM;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       vc_data.xid = vxi->vx_id;
+       vc_data.initpid = vxi->vx_initpid;
+       put_vx_info(vxi);
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+       return 0;
+}
+
+
+/* context functions */
+
+int vc_ctx_create(uint32_t xid, void __user *data)
+{
+       struct vx_info *new_vxi;
+       int ret;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       if ((xid >= MIN_D_CONTEXT) && (xid != VX_DYNAMIC_ID))
+               return -EINVAL;
+
+       if (xid < 1)
+               return -EINVAL;
+
+       new_vxi = __loc_vx_info(xid, &ret);
+       if (!new_vxi)
+               return ret;
+       if (!(new_vxi->vx_flags & VXF_STATE_SETUP)) {
+               ret = -EEXIST;
+               goto out_put;
+       }
+
+       ret = new_vxi->vx_id;
+       vx_migrate_task(current, new_vxi);
+       /* if this fails, we might end up with a hashed vx_info */
+out_put:
+       put_vx_info(new_vxi);
+       return ret;
+}
+
+
+int vc_ctx_migrate(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       /* dirty hack until Spectator becomes a cap */
+       if (id == 1) {
+               current->xid = 1;
+               return 0;
+       }
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+       vx_migrate_task(current, vxi);
+       put_vx_info(vxi);
+       return 0;
+}
+
+
+int vc_get_cflags(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_ctx_flags_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       vc_data.flagword = vxi->vx_flags;
+
+       /* special STATE flag handling */
+       vc_data.mask = vx_mask_flags(~0UL, vxi->vx_flags, VXF_ONE_TIME);
+
+       put_vx_info(vxi);
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+       return 0;
+}
+
+int vc_set_cflags(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_ctx_flags_v0 vc_data;
+       uint64_t mask, trigger;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       /* special STATE flag handling */
+       mask = vx_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
+       trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
+
+       if (trigger & VXF_STATE_SETUP)
+               vx_mask_bcaps(current);
+       if (trigger & VXF_STATE_INIT)
+               if (vxi == current->vx_info)
+                       vx_set_init(vxi, current);
+
+       vxi->vx_flags = vx_mask_flags(vxi->vx_flags,
+               vc_data.flagword, mask);
+       put_vx_info(vxi);
+       return 0;
+}
+
+int vc_get_ccaps(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_ctx_caps_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       vc_data.bcaps = vxi->vx_bcaps;
+       vc_data.ccaps = vxi->vx_ccaps;
+       vc_data.cmask = ~0UL;
+       put_vx_info(vxi);
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+       return 0;
+}
+
+int vc_set_ccaps(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_ctx_caps_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       vxi->vx_bcaps &= vc_data.bcaps;
+       vxi->vx_ccaps = vx_mask_flags(vxi->vx_ccaps,
+               vc_data.ccaps, vc_data.cmask);
+       put_vx_info(vxi);
+       return 0;
+}
+
+#include <linux/module.h>
+
+EXPORT_SYMBOL_GPL(rcu_free_vx_info);
+EXPORT_SYMBOL_GPL(vx_info_hash_lock);
+EXPORT_SYMBOL_GPL(unhash_vx_info);
+
diff --git a/kernel/vserver/cvirt.c b/kernel/vserver/cvirt.c
new file mode 100644 (file)
index 0000000..a519221
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  linux/kernel/vserver/cvirt.c
+ *
+ *  Virtual Server: Context Virtualization
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  broken out from limit.c
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/vserver/cvirt.h>
+#include <linux/vserver/context.h>
+#include <linux/vserver/switch.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_cvirt.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+
+void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
+{
+       struct vx_info *vxi = current->vx_info;
+       struct timeval bias;
+
+       jiffies_to_timeval(vxi->cvirt.bias_jiffies - INITIAL_JIFFIES, &bias);
+
+       set_normalized_timespec(uptime,
+               uptime->tv_sec - bias.tv_sec,
+               uptime->tv_nsec - bias.tv_usec*1000);
+       if (!idle)
+               return;
+       set_normalized_timespec(idle,
+               idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
+               idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
+       return;
+}
+
+uint64_t vx_idle_jiffies()
+{
+       return init_task.utime + init_task.stime;
+}
+
diff --git a/kernel/vserver/dlimit.c b/kernel/vserver/dlimit.c
new file mode 100644 (file)
index 0000000..d9478dd
--- /dev/null
@@ -0,0 +1,455 @@
+/*
+ *  linux/kernel/vserver/dlimit.c
+ *
+ *  Virtual Server: Context Disk Limits
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  initial version
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/fs.h>
+#include <linux/namespace.h>
+#include <linux/namei.h>
+#include <linux/statfs.h>
+#include <linux/vserver/switch.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_dlimit.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+/*     __alloc_dl_info()
+
+       * allocate an initialized dl_info struct
+       * doesn't make it visible (hash)                        */
+
+static struct dl_info *__alloc_dl_info(struct super_block *sb, xid_t xid)
+{
+       struct dl_info *new = NULL;
+       
+       vxdprintk(VXD_CBIT(dlim, 5),
+               "alloc_dl_info(%p,%d)*", sb, xid);
+
+       /* would this benefit from a slab cache? */
+       new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
+       if (!new)
+               return 0;
+
+       memset (new, 0, sizeof(struct dl_info));
+       new->dl_xid = xid;
+       new->dl_sb = sb;
+       INIT_RCU_HEAD(&new->dl_rcu);
+       INIT_HLIST_NODE(&new->dl_hlist);
+       spin_lock_init(&new->dl_lock);
+       atomic_set(&new->dl_refcnt, 0);
+       atomic_set(&new->dl_usecnt, 0);
+
+       /* rest of init goes here */
+
+       vxdprintk(VXD_CBIT(dlim, 4),
+               "alloc_dl_info(%p,%d) = %p", sb, xid, new);
+       return new;
+}
+
+/*     __dealloc_dl_info()
+
+       * final disposal of dl_info                             */
+
+static void __dealloc_dl_info(struct dl_info *dli)
+{
+       vxdprintk(VXD_CBIT(dlim, 4),
+               "dealloc_dl_info(%p)", dli);
+
+       dli->dl_hlist.next = LIST_POISON1;
+       dli->dl_xid = -1;
+       dli->dl_sb = 0;
+
+       BUG_ON(atomic_read(&dli->dl_usecnt));
+       BUG_ON(atomic_read(&dli->dl_refcnt));
+
+       kfree(dli);
+}
+
+
+/*     hash table for dl_info hash */
+
+#define        DL_HASH_SIZE    13
+
+struct hlist_head dl_info_hash[DL_HASH_SIZE];
+
+static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
+
+
+static inline unsigned int __hashval(struct super_block *sb, xid_t xid)
+{
+       return ((xid ^ (unsigned long)sb) % DL_HASH_SIZE);
+}
+
+
+
+/*     __hash_dl_info()
+
+       * add the dli to the global hash table
+       * requires the hash_lock to be held                     */
+
+static inline void __hash_dl_info(struct dl_info *dli)
+{
+       struct hlist_head *head;
+       
+       vxdprintk(VXD_CBIT(dlim, 6),
+               "__hash_dl_info: %p[#%d]", dli, dli->dl_xid);
+       get_dl_info(dli);
+       head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_xid)];
+       hlist_add_head_rcu(&dli->dl_hlist, head);
+}
+
+/*     __unhash_dl_info()
+
+       * remove the dli from the global hash table
+       * requires the hash_lock to be held                     */
+
+static inline void __unhash_dl_info(struct dl_info *dli)
+{
+       vxdprintk(VXD_CBIT(dlim, 6),
+               "__unhash_dl_info: %p[#%d]", dli, dli->dl_xid);
+       hlist_del_rcu(&dli->dl_hlist);
+       put_dl_info(dli);
+}
+
+
+#define hlist_for_each_rcu(pos, head) \
+       for (pos = (head)->first; pos && ({ prefetch(pos->next); 1;}); \
+               pos = pos->next, ({ smp_read_barrier_depends(); 0;}))
+
+
+/*     __lookup_dl_info()
+
+       * requires the rcu_read_lock()
+       * doesn't increment the dl_refcnt                       */
+
+static inline struct dl_info *__lookup_dl_info(struct super_block *sb, xid_t xid)
+{
+       struct hlist_head *head = &dl_info_hash[__hashval(sb, xid)];
+       struct hlist_node *pos;
+
+       hlist_for_each_rcu(pos, head) {
+               struct dl_info *dli =
+                       hlist_entry(pos, struct dl_info, dl_hlist);
+
+               if (dli->dl_xid == xid && dli->dl_sb == sb) {
+                       return dli;
+               }
+       }
+       return NULL;
+}
+
+
+struct dl_info *locate_dl_info(struct super_block *sb, xid_t xid)
+{
+        struct dl_info *dli;
+
+       rcu_read_lock();
+       dli = get_dl_info(__lookup_dl_info(sb, xid));
+       vxdprintk(VXD_CBIT(dlim, 7),
+               "locate_dl_info(%p,#%d) = %p", sb, xid, dli);
+       rcu_read_unlock();
+        return dli;
+}
+
+void rcu_free_dl_info(struct rcu_head *head)
+{
+       struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
+       int usecnt, refcnt;
+
+       BUG_ON(!dli || !head);
+
+       usecnt = atomic_read(&dli->dl_usecnt);
+       BUG_ON(usecnt < 0);
+
+       refcnt = atomic_read(&dli->dl_refcnt);
+       BUG_ON(refcnt < 0);
+
+       vxdprintk(VXD_CBIT(dlim, 3),
+               "rcu_free_dl_info(%p)", dli);
+       if (!usecnt)
+               __dealloc_dl_info(dli);
+       else
+               printk("!!! rcu didn't free\n");
+}
+
+
+
+
+int vc_add_dlimit(uint32_t id, void __user *data)
+{
+       struct nameidata nd;
+       struct vcmd_ctx_dlimit_base_v0 vc_data;
+       int ret;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       ret = user_path_walk_link(vc_data.name, &nd);
+       if (!ret) {
+               struct super_block *sb;
+               struct dl_info *dli;
+
+               ret = -EINVAL;
+               if (!nd.dentry->d_inode)
+                       goto out_release;
+               if (!(sb = nd.dentry->d_inode->i_sb))
+                       goto out_release;       
+               
+               dli = __alloc_dl_info(sb, id);
+               spin_lock(&dl_info_hash_lock);          
+
+               ret = -EEXIST;
+               if (__lookup_dl_info(sb, id))
+                       goto out_unlock;        
+               __hash_dl_info(dli);
+               dli = NULL;
+               ret = 0;
+
+       out_unlock:
+               spin_unlock(&dl_info_hash_lock);                
+               if (dli)
+                       __dealloc_dl_info(dli);
+       out_release:
+               path_release(&nd);
+       }
+       return ret;
+}
+
+
+int vc_rem_dlimit(uint32_t id, void __user *data)
+{
+       struct nameidata nd;
+       struct vcmd_ctx_dlimit_base_v0 vc_data;
+       int ret;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       ret = user_path_walk_link(vc_data.name, &nd);
+       if (!ret) {
+               struct super_block *sb;
+               struct dl_info *dli;
+
+               ret = -EINVAL;
+               if (!nd.dentry->d_inode)
+                       goto out_release;
+               if (!(sb = nd.dentry->d_inode->i_sb))
+                       goto out_release;       
+               
+               spin_lock(&dl_info_hash_lock);          
+               dli = __lookup_dl_info(sb, id);
+
+               ret = -ESRCH;
+               if (!dli)
+                       goto out_unlock;
+               
+               __unhash_dl_info(dli);
+               ret = 0;
+
+       out_unlock:
+               spin_unlock(&dl_info_hash_lock);                
+       out_release:
+               path_release(&nd);
+       }
+       return ret;
+}
+
+
+int vc_set_dlimit(uint32_t id, void __user *data)
+{
+       struct nameidata nd;
+       struct vcmd_ctx_dlimit_v0 vc_data;
+       int ret;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       ret = user_path_walk_link(vc_data.name, &nd);
+       if (!ret) {
+               struct super_block *sb;
+               struct dl_info *dli;
+
+               ret = -EINVAL;
+               if (!nd.dentry->d_inode)
+                       goto out_release;
+               if (!(sb = nd.dentry->d_inode->i_sb))
+                       goto out_release;       
+               if (vc_data.reserved > 100 ||
+                       vc_data.inodes_used > vc_data.inodes_total ||
+                       vc_data.space_used > vc_data.space_total)
+                       goto out_release;
+
+               ret = -ESRCH;
+               dli = locate_dl_info(sb, id);
+               if (!dli)
+                       goto out_release;
+
+               spin_lock(&dli->dl_lock);               
+
+               if (vc_data.inodes_used != (uint32_t)CDLIM_KEEP)
+                       dli->dl_inodes_used = vc_data.inodes_used;
+               if (vc_data.inodes_total != (uint32_t)CDLIM_KEEP)
+                       dli->dl_inodes_total = vc_data.inodes_total;
+               if (vc_data.space_used != (uint32_t)CDLIM_KEEP) {
+                       dli->dl_space_used = vc_data.space_used;
+                       dli->dl_space_used <<= 10;
+               }
+               if (vc_data.space_total == (uint32_t)CDLIM_INFINITY)
+                       dli->dl_space_total = (uint64_t)CDLIM_INFINITY;
+               else if (vc_data.space_total != (uint32_t)CDLIM_KEEP) {
+                       dli->dl_space_total = vc_data.space_total;
+                       dli->dl_space_total <<= 10;
+               }
+               if (vc_data.reserved != (uint32_t)CDLIM_KEEP)
+                       dli->dl_nrlmult = (1 << 10) * (100 - vc_data.reserved) / 100;
+
+               spin_unlock(&dli->dl_lock);             
+               
+               put_dl_info(dli);
+               ret = 0;
+
+       out_release:
+               path_release(&nd);
+       }
+       return ret;
+}
+
+int vc_get_dlimit(uint32_t id, void __user *data)
+{
+       struct nameidata nd;
+       struct vcmd_ctx_dlimit_v0 vc_data;
+       int ret;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       ret = user_path_walk_link(vc_data.name, &nd);
+       if (!ret) {
+               struct super_block *sb;
+               struct dl_info *dli;
+
+               ret = -EINVAL;
+               if (!nd.dentry->d_inode)
+                       goto out_release;
+               if (!(sb = nd.dentry->d_inode->i_sb))
+                       goto out_release;       
+               if (vc_data.reserved > 100 ||
+                       vc_data.inodes_used > vc_data.inodes_total ||
+                       vc_data.space_used > vc_data.space_total)
+                       goto out_release;
+
+               ret = -ESRCH;
+               dli = locate_dl_info(sb, id);
+               if (!dli)
+                       goto out_release;
+
+               spin_lock(&dli->dl_lock);               
+               vc_data.inodes_used = dli->dl_inodes_used;
+               vc_data.inodes_total = dli->dl_inodes_total;
+               vc_data.space_used = dli->dl_space_used >> 10;
+               if (dli->dl_space_total == (uint64_t)CDLIM_INFINITY)
+                       vc_data.space_total = (uint32_t)CDLIM_INFINITY;
+               else
+                       vc_data.space_total = dli->dl_space_total >> 10;
+
+               vc_data.reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
+               spin_unlock(&dli->dl_lock);             
+               
+               put_dl_info(dli);
+               ret = -EFAULT;
+               if (copy_to_user(data, &vc_data, sizeof(vc_data)))
+                       goto out_release;
+
+               ret = 0;
+       out_release:
+               path_release(&nd);
+       }
+       return ret;
+}
+
+
+void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
+{
+       struct dl_info *dli;
+        __u64 blimit, bfree, bavail;
+        __u32 ifree;
+               
+       dli = locate_dl_info(sb, current->xid);
+       if (!dli)
+               return;
+
+       spin_lock(&dli->dl_lock);
+       if (dli->dl_inodes_total == (uint32_t)CDLIM_INFINITY)
+               goto no_ilim;
+
+       /* reduce max inodes available to limit */
+       if (buf->f_files > dli->dl_inodes_total)
+               buf->f_files = dli->dl_inodes_total;
+
+       ifree = dli->dl_inodes_total - dli->dl_inodes_used;
+       /* reduce free inodes to min */
+       if (ifree < buf->f_ffree)
+               buf->f_ffree = ifree;
+
+no_ilim:
+       if (dli->dl_space_total == (uint64_t)CDLIM_INFINITY)
+               goto no_blim;
+
+       blimit = dli->dl_space_total >> sb->s_blocksize_bits;
+
+       if (dli->dl_space_total < dli->dl_space_used)
+               bfree = 0;
+       else
+               bfree = (dli->dl_space_total - dli->dl_space_used)
+                       >> sb->s_blocksize_bits;
+
+       bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
+       if (bavail < dli->dl_space_used)
+               bavail = 0;
+       else
+               bavail = (bavail - dli->dl_space_used)
+                       >> sb->s_blocksize_bits;
+
+       /* reduce max space available to limit */
+       if (buf->f_blocks > blimit)
+               buf->f_blocks = blimit;
+
+       /* reduce free space to min */
+       if (bfree < buf->f_bfree)
+               buf->f_bfree = bfree;
+
+       /* reduce avail space to min */
+       if (bavail < buf->f_bavail)
+               buf->f_bavail = bavail;
+
+no_blim:
+       spin_unlock(&dli->dl_lock);
+       put_dl_info(dli);
+       
+       return; 
+}
+
+#include <linux/module.h>
+
+EXPORT_SYMBOL_GPL(locate_dl_info);
+EXPORT_SYMBOL_GPL(rcu_free_dl_info);
+// EXPORT_SYMBOL_GPL(dl_info_hash_lock);
+// EXPORT_SYMBOL_GPL(unhash_dl_info);
+
diff --git a/kernel/vserver/helper.c b/kernel/vserver/helper.c
new file mode 100644 (file)
index 0000000..880b843
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *  linux/kernel/vserver/helper.c
+ *
+ *  Virtual Context Support
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  basic helper
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/reboot.h>
+#include <linux/kmod.h>
+#include <linux/vserver.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+
+#include <asm/uaccess.h>
+#include <asm/unistd.h>
+
+
+char vshelper_path[255] = "/sbin/vshelper";
+
+
+/*
+ *      vshelper path is set via /proc/sys
+ *      invoked by vserver sys_reboot(), with
+ *      the following arguments
+ *
+ *      argv [0] = vshelper_path;
+ *      argv [1] = action: "restart", "halt", "poweroff", ...
+ *      argv [2] = context identifier
+ *      argv [3] = additional argument (restart2)
+ *
+ *      envp [*] = type-specific parameters
+ */
+
+long vs_reboot(unsigned int cmd, void * arg)
+{
+       char id_buf[8], cmd_buf[32];
+       char uid_buf[32], pid_buf[32];
+       char buffer[256];
+
+       char *argv[] = {vshelper_path, NULL, id_buf, NULL, 0};
+       char *envp[] = {"HOME=/", "TERM=linux",
+                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
+                       uid_buf, pid_buf, cmd_buf, 0};
+
+       snprintf(id_buf, sizeof(id_buf)-1, "%d", vx_current_xid());
+
+       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
+       snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
+       snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
+
+       switch (cmd) {
+       case LINUX_REBOOT_CMD_RESTART:
+               argv[1] = "restart";
+               break;  
+
+       case LINUX_REBOOT_CMD_HALT:
+               argv[1] = "halt";
+               break;  
+
+       case LINUX_REBOOT_CMD_POWER_OFF:
+               argv[1] = "poweroff";
+               break;  
+
+       case LINUX_REBOOT_CMD_SW_SUSPEND:
+               argv[1] = "swsusp";
+               break;  
+
+       case LINUX_REBOOT_CMD_RESTART2:
+               if (strncpy_from_user(&buffer[0], (char *)arg, sizeof(buffer) - 1) < 0)
+                       return -EFAULT;
+               argv[3] = buffer;
+       default:
+               argv[1] = "restart2";
+               break;  
+       }
+
+       /* maybe we should wait ? */
+       if (call_usermodehelper(*argv, argv, envp, 0)) {
+               printk( KERN_WARNING
+                       "vs_reboot(): failed to exec (%s %s %s %s)\n",
+                       vshelper_path, argv[1], argv[2], argv[3]);
+               return -EPERM;
+       }
+       return 0;
+}
+
diff --git a/kernel/vserver/init.c b/kernel/vserver/init.c
new file mode 100644 (file)
index 0000000..22cc818
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  linux/kernel/init.c
+ *
+ *  Virtual Server Init
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  basic structure
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/vserver.h>
+#include <linux/init.h>
+#include <linux/module.h>
+
+int    vserver_register_sysctl(void);
+void   vserver_unregister_sysctl(void);
+
+
+static int __init init_vserver(void)
+{
+       int ret = 0;
+
+#ifdef CONFIG_VSERVER_DEBUG
+       vserver_register_sysctl();
+#endif
+       return ret;
+}
+
+
+static void __exit exit_vserver(void)
+{
+
+#ifdef CONFIG_VSERVER_DEBUG
+       vserver_unregister_sysctl();
+#endif
+       return;
+}
+
+
+module_init(init_vserver);
+module_exit(exit_vserver);
+
diff --git a/kernel/vserver/inode.c b/kernel/vserver/inode.c
new file mode 100644 (file)
index 0000000..dda8818
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ *  linux/kernel/vserver/inode.c
+ *
+ *  Virtual Server: File System Support
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  separated from vcontext V0.05
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/fs.h>
+#include <linux/proc_fs.h>
+#include <linux/namei.h>
+#include <linux/vserver/inode.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+
+static int __vc_get_iattr(struct inode *in, uint32_t *xid, uint32_t *flags, uint32_t *mask)
+{
+       if (!in || !in->i_sb)
+               return -ESRCH;
+
+       *flags = IATTR_XID
+               | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
+               | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
+               | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);     
+       *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
+
+       if (S_ISDIR(in->i_mode))
+               *mask |= IATTR_BARRIER;
+
+       if (in->i_sb->s_flags & MS_TAGXID) {
+               *xid = in->i_xid;
+               *mask |= IATTR_XID;
+       }
+
+       if (in->i_sb->s_magic == PROC_SUPER_MAGIC) {
+               struct proc_dir_entry *entry = PROC_I(in)->pde;
+               
+               // check for specific inodes ?
+               if (entry)
+                       *mask |= IATTR_FLAGS;
+               if (entry)
+                       *flags |= (entry->vx_flags & IATTR_FLAGS);      
+               else
+                       *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
+       }
+       return 0;
+}
+
+int vc_get_iattr(uint32_t id, void __user *data)
+{
+       struct nameidata nd;
+       struct vcmd_ctx_iattr_v1 vc_data;
+       int ret;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       ret = user_path_walk_link(vc_data.name, &nd);
+       if (!ret) {
+               ret = __vc_get_iattr(nd.dentry->d_inode,
+                       &vc_data.xid, &vc_data.flags, &vc_data.mask);
+               path_release(&nd);
+       }
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               ret = -EFAULT;
+       return ret;
+}
+
+static int __vc_set_iattr(struct dentry *de, uint32_t *xid, uint32_t *flags, uint32_t *mask)
+{
+       struct inode *in = de->d_inode;
+       int error = 0, is_proc = 0;
+
+       if (!in || !in->i_sb)
+               return -ESRCH;
+
+       is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
+       if ((*mask & IATTR_FLAGS) && !is_proc)
+               return -EINVAL;
+       if ((*mask & IATTR_XID) && !(in->i_sb->s_flags & MS_TAGXID))
+               return -EINVAL;
+
+       down(&in->i_sem);
+       if (*mask & IATTR_XID)
+               in->i_xid = *xid;
+
+       if (*mask & IATTR_FLAGS) {
+               struct proc_dir_entry *entry = PROC_I(in)->pde;
+               unsigned int iflags = PROC_I(in)->vx_flags;
+
+               iflags = (iflags & ~(*mask & IATTR_FLAGS))
+                       | (*flags & IATTR_FLAGS);
+               PROC_I(in)->vx_flags = iflags;
+               if (entry)
+                       entry->vx_flags = iflags;
+       }
+       
+       if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
+               struct iattr attr;
+
+               attr.ia_valid = ATTR_ATTR_FLAG;
+               attr.ia_attr_flags =
+                       (IS_IMMUTABLE(in) ? ATTR_FLAG_IMMUTABLE : 0) |
+                       (IS_IUNLINK(in) ? ATTR_FLAG_IUNLINK : 0) |
+                       (IS_BARRIER(in) ? ATTR_FLAG_BARRIER : 0);
+
+               if (*mask & IATTR_IMMUTABLE) {
+                       if (*flags & IATTR_IMMUTABLE)
+                               attr.ia_attr_flags |= ATTR_FLAG_IMMUTABLE;
+                       else
+                               attr.ia_attr_flags &= ~ATTR_FLAG_IMMUTABLE;
+               }
+               if (*mask & IATTR_IUNLINK) {
+                       if (*flags & IATTR_IUNLINK)
+                               attr.ia_attr_flags |= ATTR_FLAG_IUNLINK;
+                       else
+                               attr.ia_attr_flags &= ~ATTR_FLAG_IUNLINK;
+               }
+               if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
+                       if (*flags & IATTR_BARRIER)
+                               attr.ia_attr_flags |= ATTR_FLAG_BARRIER;
+                       else
+                               attr.ia_attr_flags &= ~ATTR_FLAG_BARRIER;
+               }
+               if (in->i_op && in->i_op->setattr)
+                       error = in->i_op->setattr(de, &attr);
+               else {
+                       error = inode_change_ok(in, &attr);
+                       if (!error)
+                               error = inode_setattr(in, &attr);
+               }
+       }
+               
+       mark_inode_dirty(in);
+       up(&in->i_sem);
+       return 0;
+}
+
+int vc_set_iattr(uint32_t id, void __user *data)
+{
+       struct nameidata nd;
+       struct vcmd_ctx_iattr_v1 vc_data;
+       int ret;
+
+       if (!capable(CAP_SYS_ADMIN) || !capable(CAP_LINUX_IMMUTABLE))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       ret = user_path_walk_link(vc_data.name, &nd);
+       if (!ret) {
+               ret = __vc_set_iattr(nd.dentry,
+                       &vc_data.xid, &vc_data.flags, &vc_data.mask);
+               path_release(&nd);
+       }
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               ret = -EFAULT;
+       return ret;
+}
+
+
+#ifdef CONFIG_VSERVER_LEGACY           
+#include <linux/proc_fs.h>
+
+#define PROC_DYNAMIC_FIRST 0xF0000000UL
+
+int vx_proc_ioctl(struct inode * inode, struct file * filp,
+       unsigned int cmd, unsigned long arg)
+{
+       struct proc_dir_entry *entry;
+       int error = 0;
+       int flags;
+
+       if (inode->i_ino < PROC_DYNAMIC_FIRST)
+               return -ENOTTY;
+
+       entry = PROC_I(inode)->pde;
+
+       switch(cmd) {
+       case FIOC_GETXFLG: {
+               /* fixme: if stealth, return -ENOTTY */
+               error = -EPERM;
+               flags = entry->vx_flags;
+               if (capable(CAP_CONTEXT))
+                       error = put_user(flags, (int *) arg);
+               break;
+       }
+       case FIOC_SETXFLG: {
+               /* fixme: if stealth, return -ENOTTY */
+               error = -EPERM;
+               if (!capable(CAP_CONTEXT))
+                       break;
+               error = -EROFS;
+               if (IS_RDONLY(inode))
+                       break;
+               error = -EFAULT;
+               if (get_user(flags, (int *) arg))
+                       break;
+               error = 0;
+               entry->vx_flags = flags;
+               break;
+       }
+       default:
+               return -ENOTTY;
+       }
+       return error;
+}
+#endif
+
diff --git a/kernel/vserver/legacy.c b/kernel/vserver/legacy.c
new file mode 100644 (file)
index 0000000..0e78e5e
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ *  linux/kernel/vserver/legacy.c
+ *
+ *  Virtual Server: Legacy Funtions
+ *
+ *  Copyright (C) 2001-2003  Jacques Gelinas
+ *  Copyright (C) 2003-2004  Herbert Pötzl
+ *
+ *  V0.01  broken out from vcontext.c V0.05
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/namespace.h>
+#include <linux/vserver/legacy.h>
+#include <linux/vserver/namespace.h>
+#include <linux/vserver.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_network.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+
+
+static int vx_set_initpid(struct vx_info *vxi, int pid)
+{
+       if (vxi->vx_initpid)
+               return -EPERM;
+
+       vxi->vx_initpid = pid;
+       return 0;
+}
+
+int vc_new_s_context(uint32_t ctx, void __user *data)
+{
+       int ret = -ENOMEM;
+       struct vcmd_new_s_context_v1 vc_data;
+       struct vx_info *new_vxi;
+
+       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       /* legacy hack, will be removed soon */
+       if (ctx == -2) {
+               /* assign flags and initpid */
+               if (!current->vx_info)
+                       return -EINVAL;
+               ret = 0;
+               if (vc_data.flags & VX_INFO_INIT)
+                       ret = vx_set_initpid(current->vx_info, current->tgid);
+               if (ret == 0) {
+                       /* We keep the same vx_id, but lower the capabilities */
+                       current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
+                       // current->cap_bset &= (~vc_data.remove_cap);
+                       ret = vx_current_xid();
+                       current->vx_info->vx_flags |= vc_data.flags;
+               }
+               return ret;
+       }
+       
+       if (!vx_check(0, VX_ADMIN) ||
+               !capable(CAP_SYS_ADMIN) || vx_flags(VX_INFO_LOCK, 0))
+               return -EPERM;
+
+       /* ugly hack for Spectator */
+       if (ctx == 1) {
+               current->xid = 1;
+               return 0;
+       }
+
+       if (((ctx > MAX_S_CONTEXT) && (ctx != VX_DYNAMIC_ID)) ||
+               (ctx == 0))
+               return -EINVAL;
+               
+       if ((ctx == VX_DYNAMIC_ID) || (ctx < MIN_D_CONTEXT))
+               new_vxi = locate_or_create_vx_info(ctx);
+       else
+               new_vxi = locate_vx_info(ctx);
+
+       if (!new_vxi)
+               return -EINVAL;
+       new_vxi->vx_flags &= ~(VXF_STATE_SETUP|VXF_STATE_INIT);
+       
+       ret = vx_migrate_task(current, new_vxi);
+       if (ret == 0) {
+               current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
+               // current->cap_bset &= (~vc_data.remove_cap);
+               new_vxi->vx_flags |= vc_data.flags;
+               if (vc_data.flags & VX_INFO_INIT)
+                       vx_set_initpid(new_vxi, current->tgid);
+               if (vc_data.flags & VX_INFO_NAMESPACE)
+                       vx_set_namespace(new_vxi,
+                               current->namespace, current->fs);
+               if (vc_data.flags & VX_INFO_NPROC)
+                       new_vxi->limit.rlim[RLIMIT_NPROC] =
+                               current->rlim[RLIMIT_NPROC].rlim_max;
+               ret = new_vxi->vx_id;
+       }
+       put_vx_info(new_vxi);
+       return ret;
+}
+
+
+extern struct nx_info *create_nx_info(void);
+
+/*  set ipv4 root (syscall) */
+
+int vc_set_ipv4root(uint32_t nbip, void __user *data)
+{
+       int i, err = -EPERM;
+       struct vcmd_set_ipv4root_v3 vc_data;
+       struct nx_info *new_nxi, *nxi = current->nx_info;
+
+       if (nbip < 0 || nbip > NB_IPV4ROOT)
+               return -EINVAL;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN))
+               // We are allowed to change everything
+               err = 0;
+       else if (nxi) {
+               int found = 0;
+               
+               // We are allowed to select a subset of the currently
+               // installed IP numbers. No new one allowed
+               // We can't change the broadcast address though
+               for (i=0; i<nbip; i++) {
+                       int j;
+                       __u32 nxip = vc_data.nx_mask_pair[i].ip;
+                       for (j=0; j<nxi->nbipv4; j++) {
+                               if (nxip == nxi->ipv4[j]) {
+                                       found++;
+                                       break;
+                               }
+                       }
+               }
+               if ((found == nbip) &&
+                       (vc_data.broadcast == nxi->v4_bcast))
+                       err = 0;
+       }
+       if (err)
+               return err;
+
+       new_nxi = create_nx_info();
+       if (!new_nxi)
+               return -EINVAL;
+
+       new_nxi->nbipv4 = nbip;
+       for (i=0; i<nbip; i++) {
+               new_nxi->ipv4[i] = vc_data.nx_mask_pair[i].ip;
+               new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask;
+       }
+       new_nxi->v4_bcast = vc_data.broadcast;
+       // current->nx_info = new_nxi;
+       if (nxi) {
+               printk("!!! switching nx_info %p->%p\n", nxi, new_nxi);
+               clr_nx_info(&current->nx_info);
+       }
+       nx_migrate_task(current, new_nxi);
+       // set_nx_info(&current->nx_info, new_nxi);
+       // current->nid = new_nxi->nx_id;
+       put_nx_info(new_nxi);
+       return 0;
+}
+
+
diff --git a/kernel/vserver/limit.c b/kernel/vserver/limit.c
new file mode 100644 (file)
index 0000000..99590bb
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ *  linux/kernel/vserver/limit.c
+ *
+ *  Virtual Server: Context Limits
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  broken out from vcontext V0.05
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/vserver/limit.h>
+#include <linux/vserver/context.h>
+#include <linux/vserver/switch.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_limit.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+
+const char *vlimit_name[NUM_LIMITS] = {
+       [RLIMIT_CPU]            = "CPU",
+       [RLIMIT_RSS]            = "RSS",
+       [RLIMIT_NPROC]          = "NPROC",
+       [RLIMIT_NOFILE] = "NOFILE",
+       [RLIMIT_MEMLOCK]        = "VML",
+       [RLIMIT_AS]             = "VM",
+       [RLIMIT_LOCKS]          = "LOCKS",
+       [RLIMIT_MSGQUEUE]       = "MSGQ",
+       [VLIMIT_NSOCK]          = "NSOCK",
+};
+
+
+static int is_valid_rlimit(int id)
+{
+       int valid = 0;
+
+       switch (id) {
+               case RLIMIT_NPROC:
+               case RLIMIT_AS:
+               case RLIMIT_RSS:
+               case RLIMIT_MEMLOCK:
+               case RLIMIT_NOFILE:
+                       valid = 1;
+                       break;
+       }
+       return valid;
+}
+
+static inline uint64_t vc_get_rlim(struct vx_info *vxi, int id)
+{
+       unsigned long limit;
+
+       limit = vxi->limit.rlim[id];
+       if (limit == RLIM_INFINITY)
+               return CRLIM_INFINITY;
+       return limit;   
+}
+
+int vc_get_rlimit(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_ctx_rlimit_v0 vc_data;
+
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+       if (!is_valid_rlimit(vc_data.id))
+               return -ENOTSUPP;
+               
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       vc_data.maximum = vc_get_rlim(vxi, vc_data.id);
+       vc_data.minimum = CRLIM_UNSET;
+       vc_data.softlimit = CRLIM_UNSET;
+       put_vx_info(vxi);
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+       return 0;
+}
+
+int vc_set_rlimit(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_ctx_rlimit_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+       if (!is_valid_rlimit(vc_data.id))
+               return -ENOTSUPP;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       if (vc_data.maximum != CRLIM_KEEP)
+               vxi->limit.rlim[vc_data.id] = vc_data.maximum;
+       printk("setting [%d] = %d\n", vc_data.id, (int)vc_data.maximum);
+       put_vx_info(vxi);
+
+       return 0;
+}
+
+int vc_get_rlimit_mask(uint32_t id, void __user *data)
+{
+       static struct vcmd_ctx_rlimit_mask_v0 mask = {
+                       /* minimum */
+               0
+               ,       /* softlimit */
+               0
+               ,       /* maximum */
+               (1 << RLIMIT_NPROC) |
+               (1 << RLIMIT_NOFILE) |
+               (1 << RLIMIT_MEMLOCK) |
+               (1 << RLIMIT_AS) |
+               (1 << RLIMIT_RSS)
+               };
+
+       if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
+               return -EPERM;
+       if (copy_to_user(data, &mask, sizeof(mask)))
+                return -EFAULT;
+       return 0;
+}
+
+
+void vx_vsi_meminfo(struct sysinfo *val)
+{
+       struct vx_info *vxi = current->vx_info;
+       unsigned long v;
+
+       v = vxi->limit.rlim[RLIMIT_RSS];
+       if (v != RLIM_INFINITY)
+               val->totalram = min(val->totalram, v);
+       v = atomic_read(&vxi->limit.rcur[RLIMIT_RSS]);
+       val->freeram = (v < val->totalram) ? val->totalram - v : 0;
+       val->bufferram = 0;
+        val->totalhigh = 0;
+        val->freehigh = 0;
+       return;
+}
+
+void vx_vsi_swapinfo(struct sysinfo *val)
+{
+       struct vx_info *vxi = current->vx_info;
+       unsigned long w,v;
+
+       v = vxi->limit.rlim[RLIMIT_RSS];
+       w = vxi->limit.rlim[RLIMIT_AS];
+       if (w != RLIM_INFINITY)
+               val->totalswap = min(val->totalswap, w -
+               ((v != RLIM_INFINITY) ? v : 0));
+       w = atomic_read(&vxi->limit.rcur[RLIMIT_AS]);
+       val->freeswap = (w < val->totalswap) ? val->totalswap - w : 0;
+       return;
+}
+
diff --git a/kernel/vserver/namespace.c b/kernel/vserver/namespace.c
new file mode 100644 (file)
index 0000000..3dc0f35
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ *  linux/kernel/vserver/namespace.c
+ *
+ *  Virtual Server: Context Namespace Support
+ *
+ *  Copyright (C) 2003-2004  Herbert Pötzl
+ *
+ *  V0.01  broken out from context.c 0.07
+ *  V0.02  added task locking for namespace
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/utsname.h>
+#include <linux/vserver/namespace.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/namespace.h>
+#include <linux/dcache.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+
+/* virtual host info names */
+
+static char * vx_vhi_name(struct vx_info *vxi, int id)
+{
+       switch (id) {
+               case VHIN_CONTEXT:
+                       return vxi->vx_name;
+               case VHIN_SYSNAME:
+                       return vxi->cvirt.utsname.sysname;
+               case VHIN_NODENAME:
+                       return vxi->cvirt.utsname.nodename;
+               case VHIN_RELEASE:
+                       return vxi->cvirt.utsname.release;
+               case VHIN_VERSION:
+                       return vxi->cvirt.utsname.version;
+               case VHIN_MACHINE:
+                       return vxi->cvirt.utsname.machine;
+               case VHIN_DOMAINNAME:
+                       return vxi->cvirt.utsname.domainname;
+               default:
+                       return NULL;
+       }
+       return NULL;
+}
+
+int vc_set_vhi_name(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_vx_vhi_name_v0 vc_data;
+       char *name;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+       
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+       
+       name = vx_vhi_name(vxi, vc_data.field);
+       if (name)
+               memcpy(name, vc_data.name, 65);
+       put_vx_info(vxi);
+       return (name ? 0 : -EFAULT);
+}
+
+int vc_get_vhi_name(uint32_t id, void __user *data)
+{
+       struct vx_info *vxi;
+       struct vcmd_vx_vhi_name_v0 vc_data;
+       char *name;
+
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       name = vx_vhi_name(vxi, vc_data.field);
+       if (!name)
+               goto out_put;
+                       
+       memcpy(vc_data.name, name, 65);
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+out_put:
+       put_vx_info(vxi);
+       return (name ? 0 : -EFAULT);
+}
+
+/* namespace functions */
+
+#include <linux/namespace.h>
+
+int vx_set_namespace(struct vx_info *vxi, struct namespace *ns, struct fs_struct *fs)
+{
+       struct fs_struct *fs_copy;
+
+       if (vxi->vx_namespace)
+               return -EPERM;
+       if (!ns || !fs)
+               return -EINVAL;
+
+       fs_copy = copy_fs_struct(fs);
+       if (!fs_copy)
+               return -ENOMEM;
+
+       get_namespace(ns);
+       vxi->vx_namespace = ns;
+       vxi->vx_fs = fs_copy;
+       return 0;
+}
+
+int vc_enter_namespace(uint32_t id, void *data)
+{
+       struct vx_info *vxi;
+       struct fs_struct *old_fs, *fs;
+       struct namespace *old_ns;
+       int ret = 0;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       ret = -EINVAL;
+       if (!vxi->vx_namespace)
+               goto out_put;
+
+       ret = -ENOMEM;
+       fs = copy_fs_struct(vxi->vx_fs);
+       if (!fs)
+               goto out_put;
+
+       ret = 0;
+       task_lock(current);
+       old_ns = current->namespace;
+       old_fs = current->fs;
+       get_namespace(vxi->vx_namespace);
+       current->namespace = vxi->vx_namespace; 
+       current->fs = fs;
+       task_unlock(current);
+
+       put_namespace(old_ns);
+       put_fs_struct(old_fs);
+out_put:
+       put_vx_info(vxi);
+       return ret;
+}
+
+int vc_cleanup_namespace(uint32_t id, void *data)
+{
+       down_write(&current->namespace->sem);
+       spin_lock(&vfsmount_lock);
+       umount_unused(current->namespace->root, current->fs);
+       spin_unlock(&vfsmount_lock);
+       up_write(&current->namespace->sem);
+       return 0;
+}
+
+int vc_set_namespace(uint32_t id, void __user *data)
+{
+       struct fs_struct *fs;
+       struct namespace *ns;
+       struct vx_info *vxi;
+       int ret;
+
+       if (vx_check(0, VX_ADMIN|VX_WATCH))
+               return -ENOSYS;
+
+       task_lock(current);
+       vxi = get_vx_info(current->vx_info);
+       fs = current->fs;
+       atomic_inc(&fs->count);
+       ns = current->namespace;
+       get_namespace(current->namespace);
+       task_unlock(current);
+
+       ret = vx_set_namespace(vxi, ns, fs);
+
+       put_namespace(ns);
+       put_fs_struct(fs);
+       put_vx_info(vxi);
+       return ret;
+}
+
diff --git a/kernel/vserver/network.c b/kernel/vserver/network.c
new file mode 100644 (file)
index 0000000..a62d1c4
--- /dev/null
@@ -0,0 +1,664 @@
+/*
+ *  linux/kernel/vserver/network.c
+ *
+ *  Virtual Server: Network Support
+ *
+ *  Copyright (C) 2003-2004  Herbert Pötzl
+ *
+ *  V0.01  broken out from vcontext V0.05
+ *  V0.02  cleaned up implementation
+ *  V0.03  added equiv nx commands
+ *  V0.04  switch to RCU based hash
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/slab.h>
+#include <linux/vserver.h>
+#include <linux/vs_base.h>
+#include <linux/vs_network.h>
+#include <linux/rcupdate.h>
+
+#include <asm/errno.h>
+
+
+/*     __alloc_nx_info()
+
+       * allocate an initialized nx_info struct
+       * doesn't make it visible (hash)                        */
+
+static struct nx_info *__alloc_nx_info(nid_t nid)
+{
+       struct nx_info *new = NULL;
+       
+       vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
+
+       /* would this benefit from a slab cache? */
+       new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
+       if (!new)
+               return 0;
+       
+       memset (new, 0, sizeof(struct nx_info));
+       new->nx_id = nid;
+       INIT_RCU_HEAD(&new->nx_rcu);
+       INIT_HLIST_NODE(&new->nx_hlist);
+       atomic_set(&new->nx_refcnt, 0);
+       atomic_set(&new->nx_usecnt, 0);
+
+       /* rest of init goes here */
+       
+       vxdprintk(VXD_CBIT(nid, 0),
+               "alloc_nx_info() = %p", new);
+       return new;
+}
+
+/*     __dealloc_nx_info()
+
+       * final disposal of nx_info                             */
+
+static void __dealloc_nx_info(struct nx_info *nxi)
+{
+       vxdprintk(VXD_CBIT(nid, 0),
+               "dealloc_nx_info(%p)", nxi);
+
+       nxi->nx_hlist.next = LIST_POISON1;
+       nxi->nx_id = -1;
+       
+       BUG_ON(atomic_read(&nxi->nx_usecnt));
+       BUG_ON(atomic_read(&nxi->nx_refcnt));
+
+       kfree(nxi);
+}
+
+
+/*     hash table for nx_info hash */
+
+#define        NX_HASH_SIZE    13
+
+struct hlist_head nx_info_hash[NX_HASH_SIZE];
+
+static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
+
+
+static inline unsigned int __hashval(nid_t nid)
+{
+       return (nid % NX_HASH_SIZE);
+}
+
+
+
+/*     __hash_nx_info()
+
+       * add the nxi to the global hash table
+       * requires the hash_lock to be held                     */
+
+static inline void __hash_nx_info(struct nx_info *nxi)
+{
+       struct hlist_head *head;
+       
+       vxdprintk(VXD_CBIT(nid, 4),
+               "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
+       get_nx_info(nxi);
+       head = &nx_info_hash[__hashval(nxi->nx_id)];
+       hlist_add_head_rcu(&nxi->nx_hlist, head);
+}
+
+/*     __unhash_nx_info()
+
+       * remove the nxi from the global hash table
+       * requires the hash_lock to be held                     */
+
+static inline void __unhash_nx_info(struct nx_info *nxi)
+{
+       vxdprintk(VXD_CBIT(nid, 4),
+               "__unhash_nx_info: %p[#%d]", nxi, nxi->nx_id);
+       hlist_del_rcu(&nxi->nx_hlist);
+       put_nx_info(nxi);
+}
+
+
+/*     __lookup_nx_info()
+
+       * requires the rcu_read_lock()
+       * doesn't increment the nx_refcnt                       */
+
+static inline struct nx_info *__lookup_nx_info(nid_t nid)
+{
+       struct hlist_head *head = &nx_info_hash[__hashval(nid)];
+       struct hlist_node *pos;
+
+       hlist_for_each_rcu(pos, head) {
+               struct nx_info *nxi =
+                       hlist_entry(pos, struct nx_info, nx_hlist);
+
+               if (nxi->nx_id == nid) {
+                       return nxi;
+               }
+       }
+       return NULL;
+}
+
+
+/*     __nx_dynamic_id()
+
+       * find unused dynamic nid
+       * requires the hash_lock to be held                     */
+
+static inline nid_t __nx_dynamic_id(void)
+{
+       static nid_t seq = MAX_N_CONTEXT;
+       nid_t barrier = seq;
+       
+       do {
+               if (++seq > MAX_N_CONTEXT)
+                       seq = MIN_D_CONTEXT;
+               if (!__lookup_nx_info(seq)) {
+                       vxdprintk(VXD_CBIT(nid, 4),
+                               "__nx_dynamic_id: [#%d]", seq);
+                       return seq;
+               }
+       } while (barrier != seq);
+       return 0;
+}
+
+/*     __loc_nx_info()
+
+       * locate or create the requested context
+       * get() it and if new hash it                           */
+
+static struct nx_info * __loc_nx_info(int id, int *err)
+{
+       struct nx_info *new, *nxi = NULL;
+       
+       vxdprintk(VXD_CBIT(nid, 1), "loc_nx_info(%d)*", id);
+
+       if (!(new = __alloc_nx_info(id))) {
+               *err = -ENOMEM;
+               return NULL;
+       }
+
+       spin_lock(&nx_info_hash_lock);
+
+       /* dynamic context requested */
+       if (id == NX_DYNAMIC_ID) {
+               id = __nx_dynamic_id();
+               if (!id) {
+                       printk(KERN_ERR "no dynamic context available.\n");
+                       goto out_unlock;
+               }
+               new->nx_id = id;
+       }
+       /* existing context requested */
+       else if ((nxi = __lookup_nx_info(id))) {
+               /* context in setup is not available */
+               if (nxi->nx_flags & VXF_STATE_SETUP) {
+                       vxdprintk(VXD_CBIT(nid, 0),
+                               "loc_nx_info(%d) = %p (not available)", id, nxi);
+                       nxi = NULL;
+                       *err = -EBUSY;
+               } else {
+                       vxdprintk(VXD_CBIT(nid, 0),
+                               "loc_nx_info(%d) = %p (found)", id, nxi);
+                       get_nx_info(nxi);
+                       *err = 0;
+               }
+               goto out_unlock;
+       }
+
+       /* new context requested */
+       vxdprintk(VXD_CBIT(nid, 0),
+               "loc_nx_info(%d) = %p (new)", id, new);
+       __hash_nx_info(get_nx_info(new));
+       nxi = new, new = NULL;
+       *err = 1;
+
+out_unlock:
+       spin_unlock(&nx_info_hash_lock);
+       if (new)
+               __dealloc_nx_info(new);
+       return nxi;
+}
+
+
+
+/*     exported stuff                                          */
+
+
+
+
+void rcu_free_nx_info(struct rcu_head *head)
+{
+       struct nx_info *nxi = container_of(head, struct nx_info, nx_rcu);
+       int usecnt, refcnt;
+
+       BUG_ON(!nxi || !head);
+
+       usecnt = atomic_read(&nxi->nx_usecnt);
+       BUG_ON(usecnt < 0);
+
+       refcnt = atomic_read(&nxi->nx_refcnt);
+       BUG_ON(refcnt < 0);
+
+       vxdprintk(VXD_CBIT(nid, 3),
+               "rcu_free_nx_info(%p): uc=%d", nxi, usecnt);
+       if (!usecnt)
+               __dealloc_nx_info(nxi);
+       else
+               printk("!!! rcu didn't free\n");
+}
+
+void unhash_nx_info(struct nx_info *nxi)
+{
+       spin_lock(&nx_info_hash_lock);
+       __unhash_nx_info(nxi);
+       spin_unlock(&nx_info_hash_lock);
+}
+
+/*     locate_nx_info()
+
+       * search for a nx_info and get() it                     
+       * negative id means current                             */
+
+struct nx_info *locate_nx_info(int id)
+{
+       struct nx_info *nxi;
+       
+       if (id < 0) {
+               nxi = get_nx_info(current->nx_info);
+       } else {
+               rcu_read_lock();
+               nxi = get_nx_info(__lookup_nx_info(id));
+               rcu_read_unlock();
+       }
+       return nxi;
+}
+
+/*     nx_info_is_hashed()
+
+       * verify that nid is still hashed                       */
+
+int nx_info_is_hashed(nid_t nid)
+{
+       int hashed;
+
+       rcu_read_lock();
+       hashed = (__lookup_nx_info(nid) != NULL);
+       rcu_read_unlock();
+       return hashed;
+}
+
+#ifdef CONFIG_VSERVER_LEGACY
+
+struct nx_info *locate_or_create_nx_info(int id)
+{
+       int err;
+
+       return __loc_nx_info(id, &err);
+}
+
+struct nx_info *create_nx_info(void)
+{
+       struct nx_info *new;
+       int err;
+       
+       vxdprintk(VXD_CBIT(nid, 5), "create_nx_info(%s)", "void");
+       if (!(new = __loc_nx_info(NX_DYNAMIC_ID, &err)))
+               return NULL;
+       return new;
+}
+
+
+#endif
+
+#ifdef CONFIG_PROC_FS
+
+#define hlist_for_each_rcu(pos, head) \
+        for (pos = (head)->first; pos && ({ prefetch(pos->next); 1;}); \
+               pos = pos->next, ({ smp_read_barrier_depends(); 0;}))
+
+int get_nid_list(int index, unsigned int *nids, int size)
+{
+       int hindex, nr_nids = 0;
+
+       rcu_read_lock();
+       for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
+               struct hlist_head *head = &nx_info_hash[hindex];
+               struct hlist_node *pos;
+
+               hlist_for_each_rcu(pos, head) {
+                       struct nx_info *nxi;
+
+                       if (--index > 0)
+                               continue;
+
+                       nxi = hlist_entry(pos, struct nx_info, nx_hlist);
+                       nids[nr_nids] = nxi->nx_id;                     
+                       if (++nr_nids >= size)
+                               goto out;
+               }
+       }
+out:
+       rcu_read_unlock();
+       return nr_nids;
+}
+#endif
+
+
+/*
+ *     migrate task to new network
+ */
+
+int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
+{
+       struct nx_info *old_nxi;
+       int ret = 0;
+       
+       if (!p || !nxi)
+               BUG();
+
+       vxdprintk(VXD_CBIT(nid, 5),
+               "nx_migrate_task(%p,%p[#%d.%d.%d])",
+               p, nxi, nxi->nx_id,
+               atomic_read(&nxi->nx_usecnt),
+               atomic_read(&nxi->nx_refcnt));
+
+       old_nxi = task_get_nx_info(p);
+       if (old_nxi == nxi)
+               goto out;
+
+       task_lock(p);
+       /* should be handled in set_nx_info !! */
+       if (old_nxi)
+               clr_nx_info(&p->nx_info);
+       set_nx_info(&p->nx_info, nxi);
+       p->nid = nxi->nx_id;
+       task_unlock(p);
+
+       /* obsoleted by clr/set */
+       // put_nx_info(old_nxi);
+out:
+       put_nx_info(old_nxi);
+       return ret;
+}
+
+
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+
+static inline int __addr_in_nx_info(u32 addr, struct nx_info *nxi)
+{
+       int i, nbip;
+
+       nbip = nxi->nbipv4;
+       for (i=0; i<nbip; i++)
+               if (nxi->ipv4[i] == addr)
+                       return 1;
+       return 0;
+}
+
+int ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
+{
+       if (nxi && ifa)
+               return __addr_in_nx_info(ifa->ifa_address, nxi);
+       return 1;
+}
+
+int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
+{
+       struct in_device *in_dev = __in_dev_get(dev);
+       struct in_ifaddr **ifap = NULL;
+       struct in_ifaddr *ifa = NULL;
+
+       if (!nxi)
+               return 1;
+       if (!in_dev)
+               return 0;
+
+       for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
+               ifap = &ifa->ifa_next) {
+               if (__addr_in_nx_info(ifa->ifa_address, nxi))
+                       return 1;
+       }
+       return 0;
+}
+
+
+
+
+/* vserver syscall commands below here */
+
+/* taks nid and nx_info functions */
+
+#include <asm/uaccess.h>
+
+
+int vc_task_nid(uint32_t id, void __user *data)
+{
+        nid_t nid;
+
+        if (id) {
+                struct task_struct *tsk;
+
+                if (!vx_check(0, VX_ADMIN|VX_WATCH))
+                        return -EPERM;
+
+                read_lock(&tasklist_lock);
+                tsk = find_task_by_pid(id);
+                nid = (tsk) ? tsk->nid : -ESRCH;
+                read_unlock(&tasklist_lock);
+        }
+        else
+                nid = current->nid;
+        return nid;
+}
+
+
+int vc_nx_info(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       struct vcmd_nx_info_v0 vc_data;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
+               return -EPERM;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+
+       vc_data.nid = nxi->nx_id;
+       put_nx_info(nxi);
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+       return 0;
+}
+
+
+/* network functions */
+
+int vc_net_create(uint32_t nid, void __user *data)
+{
+        // int ret = -ENOMEM;
+       struct nx_info *new_nxi;
+       int ret;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       if ((nid >= MIN_D_CONTEXT) && (nid != VX_DYNAMIC_ID))
+               return -EINVAL;
+
+       if (nid < 1)
+               return -EINVAL;
+
+       new_nxi = __loc_nx_info(nid, &ret);
+       if (!new_nxi)
+               return ret;
+       if (!(new_nxi->nx_flags & VXF_STATE_SETUP)) {
+               ret = -EEXIST;
+               goto out_put;
+       }
+
+       ret = new_nxi->nx_id;
+       nx_migrate_task(current, new_nxi);
+out_put:
+       put_nx_info(new_nxi);
+       return ret;
+}
+
+
+int vc_net_migrate(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+       nx_migrate_task(current, nxi);
+       put_nx_info(nxi);
+       return 0;
+}
+
+int vc_net_add(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       struct vcmd_net_nx_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+
+       // add ip to net context here
+       put_nx_info(nxi);
+       return 0;
+}
+
+int vc_net_remove(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       struct vcmd_net_nx_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+
+       // rem ip from net context here
+       put_nx_info(nxi);
+       return 0;
+}
+
+
+
+int vc_get_nflags(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       struct vcmd_net_flags_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+
+       vc_data.flagword = nxi->nx_flags;
+
+       /* special STATE flag handling */
+       vc_data.mask = vx_mask_flags(~0UL, nxi->nx_flags, IPF_ONE_TIME);
+
+       put_nx_info(nxi);
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+       return 0;
+}
+
+int vc_set_nflags(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       struct vcmd_net_flags_v0 vc_data;
+       uint64_t mask, trigger;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+
+       /* special STATE flag handling */
+       mask = vx_mask_mask(vc_data.mask, nxi->nx_flags, IPF_ONE_TIME);
+       trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
+       // if (trigger & IPF_STATE_SETUP)
+
+       nxi->nx_flags = vx_mask_flags(nxi->nx_flags,
+               vc_data.flagword, mask);
+       put_nx_info(nxi);
+       return 0;
+}
+
+int vc_get_ncaps(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       struct vcmd_net_caps_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+
+       vc_data.ncaps = nxi->nx_ncaps;
+       vc_data.cmask = ~0UL;
+       put_nx_info(nxi);
+
+       if (copy_to_user (data, &vc_data, sizeof(vc_data)))
+               return -EFAULT;
+       return 0;
+}
+
+int vc_set_ncaps(uint32_t id, void __user *data)
+{
+       struct nx_info *nxi;
+       struct vcmd_net_caps_v0 vc_data;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+
+       nxi = locate_nx_info(id);
+       if (!nxi)
+               return -ESRCH;
+
+       nxi->nx_ncaps = vx_mask_flags(nxi->nx_ncaps,
+               vc_data.ncaps, vc_data.cmask);
+       put_nx_info(nxi);
+       return 0;
+}
+
+
+#include <linux/module.h>
+
+EXPORT_SYMBOL_GPL(rcu_free_nx_info);
+EXPORT_SYMBOL_GPL(nx_info_hash_lock);
+EXPORT_SYMBOL_GPL(unhash_nx_info);
+
diff --git a/kernel/vserver/proc.c b/kernel/vserver/proc.c
new file mode 100644 (file)
index 0000000..e957fd4
--- /dev/null
@@ -0,0 +1,868 @@
+/*
+ *  linux/kernel/vserver/proc.c
+ *
+ *  Virtual Context Support
+ *
+ *  Copyright (C) 2003-2004  Herbert Pötzl
+ *
+ *  V0.01  basic structure
+ *  V0.02  adaptation vs1.3.0
+ *  V0.03  proc permissions
+ *  V0.04  locking/generic
+ *  V0.05  next generation procfs
+ *  V0.06  inode validation
+ *  V0.07  generic rewrite vid
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/vserver.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_network.h>
+
+#include <asm/uaccess.h>
+#include <asm/unistd.h>
+
+
+static struct proc_dir_entry *proc_virtual;
+
+static struct proc_dir_entry *proc_vnet;
+
+
+enum vid_directory_inos {
+       PROC_XID_INO = 32,
+       PROC_XID_INFO,
+       PROC_XID_STATUS,
+       PROC_XID_LIMIT,
+       PROC_XID_SCHED,
+       PROC_XID_CVIRT,
+       PROC_XID_CACCT,
+
+       PROC_NID_INO = 64,
+       PROC_NID_INFO,
+       PROC_NID_STATUS,
+};
+
+#define        PROC_VID_MASK   0x60
+
+
+/* first the actual feeds */
+
+
+static int proc_virtual_info(int vid, char *buffer)
+{
+       return sprintf(buffer,
+               "VCIVersion:\t%04x:%04x\n"
+               "VCISyscall:\t%d\n"
+               ,VCI_VERSION >> 16
+               ,VCI_VERSION & 0xFFFF
+               ,__NR_vserver
+               );
+}
+
+
+int proc_xid_info (int vid, char *buffer)
+{
+       struct vx_info *vxi;
+       int length;
+
+       vxi = locate_vx_info(vid);
+       if (!vxi)
+               return 0;
+       length = sprintf(buffer,
+               "ID:\t%d\n"
+               "Info:\t%p\n"
+               "Init:\t%d\n"
+               ,vxi->vx_id
+               ,vxi
+               ,vxi->vx_initpid
+               );
+       put_vx_info(vxi);
+       return length;
+}
+
+int proc_xid_status (int vid, char *buffer)
+{
+       struct vx_info *vxi;
+       int length;
+
+       vxi = locate_vx_info(vid);
+       if (!vxi)
+               return 0;
+       length = sprintf(buffer,
+               "UseCnt:\t%d\n"         
+               "RefCnt:\t%d\n"         
+               "Flags:\t%016llx\n"
+               "BCaps:\t%016llx\n"
+               "CCaps:\t%016llx\n"
+               "Ticks:\t%d\n"          
+               ,atomic_read(&vxi->vx_usecnt)
+               ,atomic_read(&vxi->vx_refcnt)
+               ,(unsigned long long)vxi->vx_flags
+               ,(unsigned long long)vxi->vx_bcaps
+               ,(unsigned long long)vxi->vx_ccaps
+               ,atomic_read(&vxi->limit.ticks)
+               );
+       put_vx_info(vxi);
+       return length;
+}
+
+int proc_xid_limit (int vid, char *buffer)
+{
+       struct vx_info *vxi;
+       int length;
+
+       vxi = locate_vx_info(vid);
+       if (!vxi)
+               return 0;
+       length = vx_info_proc_limit(&vxi->limit, buffer);
+       put_vx_info(vxi);
+       return length;
+}
+
+int proc_xid_sched (int vid, char *buffer)
+{
+       struct vx_info *vxi;
+       int length;
+
+       vxi = locate_vx_info(vid);
+       if (!vxi)
+               return 0;
+       length = vx_info_proc_sched(&vxi->sched, buffer);
+       put_vx_info(vxi);
+       return length;
+}
+
+int proc_xid_cvirt (int vid, char *buffer)
+{
+       struct vx_info *vxi;
+       int length;
+
+       vxi = locate_vx_info(vid);
+       if (!vxi)
+               return 0;
+       length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
+       put_vx_info(vxi);
+       return length;
+}
+
+int proc_xid_cacct (int vid, char *buffer)
+{
+       struct vx_info *vxi;
+       int length;
+
+       vxi = locate_vx_info(vid);
+       if (!vxi)
+               return 0;
+       length = vx_info_proc_cacct(&vxi->cacct, buffer);
+       put_vx_info(vxi);
+       return length;
+}
+
+
+static int proc_vnet_info(int vid, char *buffer)
+{
+       return sprintf(buffer,
+               "VCIVersion:\t%04x:%04x\n"
+               "VCISyscall:\t%d\n"
+               ,VCI_VERSION >> 16
+               ,VCI_VERSION & 0xFFFF
+               ,__NR_vserver
+               );
+}
+
+#define        atoquad(a) \
+       (((a)>>0) & 0xff), (((a)>>8) & 0xff), \
+       (((a)>>16) & 0xff), (((a)>>24) & 0xff)
+
+int proc_nid_info (int vid, char *buffer)
+{
+       struct nx_info *nxi;
+       int length, i;
+
+       nxi = locate_nx_info(vid);
+       if (!nxi)
+               return 0;
+       length = sprintf(buffer,
+               "ID:\t%d\n"
+               "Info:\t%p\n"
+               ,nxi->nx_id
+               ,nxi
+               );
+       for (i=0; i<nxi->nbipv4; i++) {
+               length += sprintf(buffer + length,
+                       "%d:\t%d.%d.%d.%d/%d.%d.%d.%d\n", i,
+                       atoquad(nxi->ipv4[i]),
+                       atoquad(nxi->mask[i]));
+       }
+       put_nx_info(nxi);
+       return length;
+}
+
+int proc_nid_status (int vid, char *buffer)
+{
+       struct nx_info *nxi;
+       int length;
+
+       nxi = locate_nx_info(vid);
+       if (!nxi)
+               return 0;
+       length = sprintf(buffer,
+               "UseCnt:\t%d\n"         
+               "RefCnt:\t%d\n"         
+               ,atomic_read(&nxi->nx_usecnt)
+               ,atomic_read(&nxi->nx_refcnt)
+               );
+       put_nx_info(nxi);
+       return length;
+}
+
+/* here the inode helpers */
+
+
+
+#define fake_ino(id,ino) (((id)<<16)|(ino))
+
+#define        inode_vid(i)    ((i)->i_ino >> 16)
+#define        inode_type(i)   ((i)->i_ino & 0xFFFF)
+
+#define MAX_MULBY10    ((~0U-9)/10)
+
+
+static struct inode *proc_vid_make_inode(struct super_block * sb,
+       int vid, int ino)
+{
+       struct inode *inode = new_inode(sb);
+
+       if (!inode)
+               goto out;
+
+       inode->i_mtime = inode->i_atime =
+               inode->i_ctime = CURRENT_TIME;
+       inode->i_ino = fake_ino(vid, ino);
+
+       inode->i_uid = 0;
+       inode->i_gid = 0;
+       // inode->i_xid = xid;
+out:
+       return inode;
+}
+
+static int proc_vid_revalidate(struct dentry * dentry, struct nameidata *nd)
+{
+       struct inode * inode = dentry->d_inode;
+       int vid, hashed=0;
+
+       vid = inode_vid(inode);
+       switch (inode_type(inode) & PROC_VID_MASK) {
+               case PROC_XID_INO:
+                       hashed = vx_info_is_hashed(vid);
+                       break;
+               case PROC_NID_INO:
+                       hashed = nx_info_is_hashed(vid);
+                       break;
+       }       
+       if (hashed)
+               return 1;
+       d_drop(dentry);
+       return 0;
+}
+
+/*
+static int proc_vid_delete_dentry(struct dentry * dentry)
+{
+        return 1;
+}
+*/
+
+
+#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
+
+static ssize_t proc_vid_info_read(struct file * file, char * buf,
+                         size_t count, loff_t *ppos)
+{
+       struct inode * inode = file->f_dentry->d_inode;
+       unsigned long page;
+       ssize_t length;
+       ssize_t end;
+       int vid;
+
+       if (count > PROC_BLOCK_SIZE)
+               count = PROC_BLOCK_SIZE;
+       if (!(page = __get_free_page(GFP_KERNEL)))
+               return -ENOMEM;
+
+       vid = inode_vid(inode);
+       length = PROC_I(inode)->op.proc_vid_read(vid, (char*)page);
+
+       if (length < 0) {
+               free_page(page);
+               return length;
+       }
+       /* Static 4kB (or whatever) block capacity */
+       if (*ppos >= length) {
+               free_page(page);
+               return 0;
+       }
+       if (count + *ppos > length)
+               count = length - *ppos;
+       end = count + *ppos;
+       copy_to_user(buf, (char *) page + *ppos, count);
+       *ppos = end;
+       free_page(page);
+       return count;
+}
+
+
+
+
+
+/* here comes the lower level (vid) */
+
+static struct file_operations proc_vid_info_file_operations = {
+       read:           proc_vid_info_read,
+};
+
+static struct dentry_operations proc_vid_dentry_operations = {
+       d_revalidate:   proc_vid_revalidate,
+//     d_delete:       proc_vid_delete_dentry,
+};
+
+
+struct vid_entry {
+       int type;
+       int len;
+       char *name;
+       mode_t mode;
+};
+
+#define E(type,name,mode) {(type),sizeof(name)-1,(name),(mode)}
+
+static struct vid_entry vx_base_stuff[] = {
+       E(PROC_XID_INFO,        "info",         S_IFREG|S_IRUGO),
+       E(PROC_XID_STATUS,      "status",       S_IFREG|S_IRUGO),
+       E(PROC_XID_LIMIT,       "limit",        S_IFREG|S_IRUGO),
+       E(PROC_XID_SCHED,       "sched",        S_IFREG|S_IRUGO),
+       E(PROC_XID_CVIRT,       "cvirt",        S_IFREG|S_IRUGO),
+       E(PROC_XID_CACCT,       "cacct",        S_IFREG|S_IRUGO),
+       {0,0,NULL,0}
+};
+
+static struct vid_entry vn_base_stuff[] = {
+       E(PROC_NID_INFO,        "info",         S_IFREG|S_IRUGO),
+       E(PROC_NID_STATUS,      "status",       S_IFREG|S_IRUGO),
+       {0,0,NULL,0}
+};
+
+
+
+static struct dentry *proc_vid_lookup(struct inode *dir,
+       struct dentry *dentry, struct nameidata *nd)
+{
+       struct inode *inode;
+       struct vid_entry *p;
+       int error;
+
+       error = -ENOENT;
+       inode = NULL;
+
+       switch (inode_type(dir)) {
+               case PROC_XID_INO:
+                       p = vx_base_stuff;      
+                       break;
+               case PROC_NID_INO:
+                       p = vn_base_stuff;      
+                       break;
+               default:
+                       goto out;
+       }
+
+       for (; p->name; p++) {
+               if (p->len != dentry->d_name.len)
+                       continue;
+               if (!memcmp(dentry->d_name.name, p->name, p->len))
+                       break;
+       }
+       if (!p->name)
+               goto out;
+
+       error = -EINVAL;
+       inode = proc_vid_make_inode(dir->i_sb, inode_vid(dir), p->type);
+       if (!inode)
+               goto out;
+
+       switch(p->type) {
+               case PROC_XID_INFO:
+                       PROC_I(inode)->op.proc_vid_read = proc_xid_info;
+                       break;
+               case PROC_XID_STATUS:
+                       PROC_I(inode)->op.proc_vid_read = proc_xid_status;
+                       break;
+               case PROC_XID_LIMIT:
+                       PROC_I(inode)->op.proc_vid_read = proc_xid_limit;
+                       break;
+               case PROC_XID_SCHED:
+                       PROC_I(inode)->op.proc_vid_read = proc_xid_sched;
+                       break;
+               case PROC_XID_CVIRT:
+                       PROC_I(inode)->op.proc_vid_read = proc_xid_cvirt;
+                       break;
+               case PROC_XID_CACCT:
+                       PROC_I(inode)->op.proc_vid_read = proc_xid_cacct;
+                       break;
+
+               case PROC_NID_INFO:
+                       PROC_I(inode)->op.proc_vid_read = proc_nid_info;
+                       break;
+               case PROC_NID_STATUS:
+                       PROC_I(inode)->op.proc_vid_read = proc_nid_status;
+                       break;
+               
+               default:
+                       printk("procfs: impossible type (%d)",p->type);
+                       iput(inode);
+                       return ERR_PTR(-EINVAL);
+       }
+       inode->i_mode = p->mode;
+//     inode->i_op = &proc_vid_info_inode_operations;
+       inode->i_fop = &proc_vid_info_file_operations;
+       inode->i_nlink = 1;
+       inode->i_flags|=S_IMMUTABLE;
+       
+       dentry->d_op = &proc_vid_dentry_operations;
+       d_add(dentry, inode);
+       error = 0;
+out:
+       return ERR_PTR(error);
+}
+
+
+static int proc_vid_readdir(struct file * filp,
+       void * dirent, filldir_t filldir)
+{
+       int i, size;
+       struct inode *inode = filp->f_dentry->d_inode;
+       struct vid_entry *p;
+       
+       i = filp->f_pos;
+       switch (i) {
+               case 0:
+                       if (filldir(dirent, ".", 1, i,
+                               inode->i_ino, DT_DIR) < 0)
+                               return 0;
+                       i++;
+                       filp->f_pos++;
+                       /* fall through */
+               case 1:
+                       if (filldir(dirent, "..", 2, i,
+                               PROC_ROOT_INO, DT_DIR) < 0)
+                               return 0;
+                       i++;
+                       filp->f_pos++;
+                       /* fall through */
+               default:
+                       i -= 2;
+                       switch (inode_type(inode)) {
+                               case PROC_XID_INO:
+                                       size = sizeof(vx_base_stuff);
+                                       p = vx_base_stuff + i;  
+                                       break;
+                               case PROC_NID_INO:
+                                       size = sizeof(vn_base_stuff);
+                                       p = vn_base_stuff + i;  
+                                       break;
+                               default:
+                                       return 1;
+                       }
+                       if (i >= size/sizeof(struct vid_entry))
+                               return 1;
+                       while (p->name) {
+                               if (filldir(dirent, p->name, p->len,
+                                       filp->f_pos, fake_ino(inode_vid(inode),
+                                       p->type), p->mode >> 12) < 0)
+                                       return 0;
+                               filp->f_pos++;
+                               p++;
+                       }
+       }
+       return 1;
+}
+
+
+
+
+/* now the upper level (virtual) */
+
+static struct file_operations proc_vid_file_operations = {
+       read:           generic_read_dir,
+       readdir:        proc_vid_readdir,
+};
+
+static struct inode_operations proc_vid_inode_operations = {
+       lookup:         proc_vid_lookup,
+};
+
+
+
+static __inline__ int atovid(const char *str, int len)
+{
+       int vid, c;
+
+       vid = 0;
+       while (len-- > 0) {
+               c = *str - '0';
+               str++;
+               if (c > 9)
+                       return -1;
+               if (vid >= MAX_MULBY10)
+                       return -1;
+               vid *= 10;
+               vid += c;
+               if (!vid)
+                       return -1;
+       }
+       return vid;
+}
+
+
+struct dentry *proc_virtual_lookup(struct inode *dir,
+       struct dentry * dentry, struct nameidata *nd)
+{
+       int xid, len, ret;
+       struct vx_info *vxi;
+       const char *name;
+       struct inode *inode;
+
+       name = dentry->d_name.name;
+       len = dentry->d_name.len;
+       ret = -ENOMEM;
+
+       if (len == 7 && !memcmp(name, "current", 7)) {
+               inode = new_inode(dir->i_sb);
+               if (!inode)
+                       goto out;
+               inode->i_mtime = inode->i_atime =
+                       inode->i_ctime = CURRENT_TIME;
+               inode->i_ino = fake_ino(1, PROC_XID_INO);
+               inode->i_mode = S_IFLNK|S_IRWXUGO;
+               inode->i_uid = inode->i_gid = 0;
+               inode->i_size = 64;
+//             inode->i_op = &proc_current_inode_operations;
+               d_add(dentry, inode);
+               return NULL;
+       }
+       if (len == 4 && !memcmp(name, "info", 4)) {
+               inode = proc_vid_make_inode(dir->i_sb, 0, PROC_XID_INFO);
+               if (!inode)
+                       goto out;
+               inode->i_fop = &proc_vid_info_file_operations;
+               PROC_I(inode)->op.proc_vid_read = proc_virtual_info;
+               inode->i_mode = S_IFREG|S_IRUGO;
+//             inode->i_size = 64;
+//             inode->i_op = &proc_current_inode_operations;
+               d_add(dentry, inode);
+               return NULL;
+       }
+
+       ret = -ENOENT;
+       xid = atovid(name, len);
+       if (xid < 0)
+               goto out;
+       vxi = locate_vx_info(xid);
+       if (!vxi)
+               goto out;
+
+       inode = NULL;
+       if (vx_check(xid, VX_ADMIN|VX_WATCH|VX_IDENT))
+               inode = proc_vid_make_inode(dir->i_sb,
+                       vxi->vx_id, PROC_XID_INO);
+       if (!inode)
+               goto out_release;
+
+       inode->i_mode = S_IFDIR|S_IRUGO;
+       inode->i_op = &proc_vid_inode_operations;
+       inode->i_fop = &proc_vid_file_operations;
+       inode->i_nlink = 2;
+       inode->i_flags|=S_IMMUTABLE;
+
+       dentry->d_op = &proc_vid_dentry_operations;
+       d_add(dentry, inode);
+       ret = 0;
+       
+out_release:
+       put_vx_info(vxi);
+out:
+       return ERR_PTR(ret);
+}
+
+
+struct dentry *proc_vnet_lookup(struct inode *dir,
+       struct dentry * dentry, struct nameidata *nd)
+{
+       int nid, len, ret;
+       struct nx_info *nxi;
+       const char *name;
+       struct inode *inode;
+
+       name = dentry->d_name.name;
+       len = dentry->d_name.len;
+       ret = -ENOMEM;
+       if (len == 7 && !memcmp(name, "current", 7)) {
+               inode = new_inode(dir->i_sb);
+               if (!inode)
+                       goto out;
+               inode->i_mtime = inode->i_atime =
+                       inode->i_ctime = CURRENT_TIME;
+               inode->i_ino = fake_ino(1, PROC_NID_INO);
+               inode->i_mode = S_IFLNK|S_IRWXUGO;
+               inode->i_uid = inode->i_gid = 0;
+               inode->i_size = 64;
+//             inode->i_op = &proc_current_inode_operations;
+               d_add(dentry, inode);
+               return NULL;
+       }
+       if (len == 4 && !memcmp(name, "info", 4)) {
+               inode = proc_vid_make_inode(dir->i_sb, 0, PROC_NID_INFO);
+               if (!inode)
+                       goto out;
+               inode->i_fop = &proc_vid_info_file_operations;
+               PROC_I(inode)->op.proc_vid_read = proc_vnet_info;
+               inode->i_mode = S_IFREG|S_IRUGO;
+//             inode->i_size = 64;
+//             inode->i_op = &proc_current_inode_operations;
+               d_add(dentry, inode);
+               return NULL;
+       }
+
+       ret = -ENOENT;
+       nid = atovid(name, len);
+       if (nid < 0)
+               goto out;
+       nxi = locate_nx_info(nid);
+       if (!nxi)
+               goto out;
+
+       inode = NULL;
+       if (1)
+               inode = proc_vid_make_inode(dir->i_sb,
+                       nxi->nx_id, PROC_NID_INO);
+       if (!inode)
+               goto out_release;
+
+       inode->i_mode = S_IFDIR|S_IRUGO;
+       inode->i_op = &proc_vid_inode_operations;
+       inode->i_fop = &proc_vid_file_operations;
+       inode->i_nlink = 2;
+       inode->i_flags|=S_IMMUTABLE;
+
+       dentry->d_op = &proc_vid_dentry_operations;
+       d_add(dentry, inode);
+       ret = 0;
+       
+out_release:
+       put_nx_info(nxi);
+out:
+       return ERR_PTR(ret);
+}
+
+
+
+
+#define PROC_NUMBUF 10
+#define PROC_MAXVIDS 32
+
+int proc_virtual_readdir(struct file * filp,
+       void * dirent, filldir_t filldir)
+{
+       unsigned int xid_array[PROC_MAXVIDS];
+       char buf[PROC_NUMBUF];
+       unsigned int nr = filp->f_pos-3;
+       unsigned int nr_xids, i;
+       ino_t ino;
+
+       switch ((long)filp->f_pos) {
+               case 0:
+                       ino = fake_ino(0, PROC_XID_INO);
+                       if (filldir(dirent, ".", 1,
+                               filp->f_pos, ino, DT_DIR) < 0)
+                               return 0;
+                       filp->f_pos++;
+                       /* fall through */
+               case 1:
+                       ino = filp->f_dentry->d_parent->d_inode->i_ino;
+                       if (filldir(dirent, "..", 2,
+                               filp->f_pos, ino, DT_DIR) < 0)
+                               return 0;
+                       filp->f_pos++;
+                       /* fall through */
+               case 2:
+                       ino = fake_ino(0, PROC_XID_INFO);
+                       if (filldir(dirent, "info", 4,
+                               filp->f_pos, ino, DT_LNK) < 0)
+                               return 0;
+                       filp->f_pos++;
+                       /* fall through */
+               case 3:
+                       if (current->xid > 1) {
+                               ino = fake_ino(1, PROC_XID_INO);
+                               if (filldir(dirent, "current", 7,
+                                       filp->f_pos, ino, DT_LNK) < 0)
+                                       return 0;
+                       }
+                       filp->f_pos++;
+       }
+
+       nr_xids = get_xid_list(nr, xid_array, PROC_MAXVIDS);
+       for (i = 0; i < nr_xids; i++) {
+               int xid = xid_array[i];
+               ino_t ino = fake_ino(xid, PROC_XID_INO);
+               unsigned int j = PROC_NUMBUF;
+
+               do buf[--j] = '0' + (xid % 10); while (xid/=10);
+
+               if (filldir(dirent, buf+j, PROC_NUMBUF-j,
+                       filp->f_pos, ino, DT_DIR) < 0)
+                       break;
+               filp->f_pos++;
+       }
+       return 0;
+}
+
+
+static struct file_operations proc_virtual_dir_operations = {
+       read:           generic_read_dir,
+       readdir:        proc_virtual_readdir,
+};
+
+static struct inode_operations proc_virtual_dir_inode_operations = {
+       lookup:         proc_virtual_lookup,
+};
+
+
+int proc_vnet_readdir(struct file * filp,
+       void * dirent, filldir_t filldir)
+{
+       unsigned int nid_array[PROC_MAXVIDS];
+       char buf[PROC_NUMBUF];
+       unsigned int nr = filp->f_pos-3;
+       unsigned int nr_nids, i;
+       ino_t ino;
+
+       switch ((long)filp->f_pos) {
+               case 0:
+                       ino = fake_ino(0, PROC_NID_INO);
+                       if (filldir(dirent, ".", 1,
+                               filp->f_pos, ino, DT_DIR) < 0)
+                               return 0;
+                       filp->f_pos++;
+                       /* fall through */
+               case 1:
+                       ino = filp->f_dentry->d_parent->d_inode->i_ino;
+                       if (filldir(dirent, "..", 2,
+                               filp->f_pos, ino, DT_DIR) < 0)
+                               return 0;
+                       filp->f_pos++;
+                       /* fall through */
+               case 2:
+                       ino = fake_ino(0, PROC_NID_INFO);
+                       if (filldir(dirent, "info", 4,
+                               filp->f_pos, ino, DT_LNK) < 0)
+                               return 0;
+                       filp->f_pos++;
+                       /* fall through */
+               case 3:
+                       if (current->xid > 1) {
+                               ino = fake_ino(1, PROC_NID_INO);
+                               if (filldir(dirent, "current", 7,
+                                       filp->f_pos, ino, DT_LNK) < 0)
+                                       return 0;
+                       }
+                       filp->f_pos++;
+       }
+
+       nr_nids = get_nid_list(nr, nid_array, PROC_MAXVIDS);
+       for (i = 0; i < nr_nids; i++) {
+               int nid = nid_array[i];
+               ino_t ino = fake_ino(nid, PROC_NID_INO);
+               unsigned long j = PROC_NUMBUF;
+
+               do buf[--j] = '0' + (nid % 10); while (nid/=10);
+
+               if (filldir(dirent, buf+j, PROC_NUMBUF-j,
+                       filp->f_pos, ino, DT_DIR) < 0)
+                       break;
+               filp->f_pos++;
+       }
+       return 0;
+}
+
+
+static struct file_operations proc_vnet_dir_operations = {
+       read:           generic_read_dir,
+       readdir:        proc_vnet_readdir,
+};
+
+static struct inode_operations proc_vnet_dir_inode_operations = {
+       lookup:         proc_vnet_lookup,
+};
+
+
+
+void proc_vx_init(void)
+{
+       struct proc_dir_entry *ent;
+
+       ent = proc_mkdir("virtual", 0);
+       if (ent) {
+               ent->proc_fops = &proc_virtual_dir_operations;
+               ent->proc_iops = &proc_virtual_dir_inode_operations;
+       }
+       proc_virtual = ent;
+
+       ent = proc_mkdir("vnet", 0);
+       if (ent) {
+               ent->proc_fops = &proc_vnet_dir_operations;
+               ent->proc_iops = &proc_vnet_dir_inode_operations;
+       }
+       proc_vnet = ent;
+}
+
+
+
+
+/* per pid info */
+
+
+char *task_vx_info(struct task_struct *p, char *buffer)
+{
+       return buffer + sprintf(buffer,
+               "XID:\t%d\n"
+               ,p->xid);
+}
+
+int proc_pid_vx_info(struct task_struct *p, char *buffer)
+{
+       char * orig = buffer;
+
+       buffer = task_vx_info(p, buffer);
+       return buffer - orig;
+}
+
+char *task_nx_info(struct task_struct *p, char *buffer)
+{
+       return buffer + sprintf(buffer,
+               "NID:\t%d\n"
+               ,p->nid);
+}
+
+int proc_pid_nx_info(struct task_struct *p, char *buffer)
+{
+       char * orig = buffer;
+
+       buffer = task_nx_info(p, buffer);
+       return buffer - orig;
+}
+
diff --git a/kernel/vserver/sched.c b/kernel/vserver/sched.c
new file mode 100644 (file)
index 0000000..b2d45c2
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ *  linux/kernel/vserver/sched.c
+ *
+ *  Virtual Server: Scheduler Support
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  adapted Sam Vilains version to 2.6.3
+ *  V0.02  removed legacy interface
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vserver/context.h>
+#include <linux/vserver/sched.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+
+/*
+ * recalculate the context's scheduling tokens
+ *
+ * ret > 0 : number of tokens available
+ * ret = 0 : context is paused
+ * ret < 0 : number of jiffies until new tokens arrive
+ *
+ */
+int vx_tokens_recalc(struct vx_info *vxi)
+{
+       long delta, tokens = 0;
+
+       if (__vx_flags(vxi->vx_flags, VXF_SCHED_PAUSE, 0))
+               /* we are paused */
+               return 0;
+
+       delta = jiffies - vxi->sched.jiffies;
+
+       if (delta >= vxi->sched.interval) {
+               /* lockdown scheduler info */
+               spin_lock(&vxi->sched.tokens_lock);
+
+               /* calc integral token part */
+               delta = jiffies - vxi->sched.jiffies;
+               tokens = delta / vxi->sched.interval;
+               delta = tokens * vxi->sched.interval;
+               tokens *= vxi->sched.fill_rate;
+
+               atomic_add(tokens, &vxi->sched.tokens);
+               vxi->sched.jiffies += delta;
+               tokens = atomic_read(&vxi->sched.tokens);
+       
+               if (tokens > vxi->sched.tokens_max) {
+                       tokens = vxi->sched.tokens_max;
+                       atomic_set(&vxi->sched.tokens, tokens);
+               }
+               spin_unlock(&vxi->sched.tokens_lock);
+       } else {
+               /* no new tokens */
+               if ((tokens = vx_tokens_avail(vxi)) < vxi->sched.tokens_min) {
+                       /* enough tokens will be available in */
+                       if (vxi->sched.tokens_min == 0)
+                               return delta - vxi->sched.interval;
+                       return delta - vxi->sched.interval *
+                               vxi->sched.tokens_min / vxi->sched.fill_rate;
+               }
+       }
+       /* we have some tokens left */
+       return tokens;
+}
+
+/*
+ * effective_prio - return the priority that is based on the static
+ * priority but is modified by bonuses/penalties.
+ *
+ * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
+ * into a -4 ... 0 ... +4 bonus/penalty range.
+ *
+ * Additionally, we scale another amount based on the number of
+ * CPU tokens currently held by the context, if the process is
+ * part of a context (and the appropriate SCHED flag is set).
+ * This ranges from -5 ... 0 ... +15, quadratically.
+ *
+ * So, the total bonus is -9 .. 0 .. +19
+ * We use ~50% of the full 0...39 priority range so that:
+ *
+ * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
+ * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
+ *    unless that context is far exceeding its CPU allocation.
+ *
+ * Both properties are important to certain workloads.
+ */
+int effective_vavavoom(task_t *p, int max_prio)
+{
+       struct vx_info *vxi = p->vx_info;
+       int vavavoom, max;
+
+       /* lots of tokens = lots of vavavoom
+        *      no tokens = no vavavoom      */
+       if ((vavavoom = atomic_read(&vxi->sched.tokens)) >= 0) {
+               max = vxi->sched.tokens_max;
+               vavavoom = max - vavavoom;
+               max = max * max;
+               vavavoom = max_prio * VAVAVOOM_RATIO / 100
+                       * (vavavoom*vavavoom - (max >> 2)) / max;
+               /*  alternative, geometric mapping
+               vavavoom = -( MAX_USER_PRIO*VAVAVOOM_RATIO/100 * vavavoom
+                       / vxi->sched.tokens_max -
+                       MAX_USER_PRIO*VAVAVOOM_RATIO/100/2); */
+       } else
+               vavavoom = 0;
+       /* vavavoom = ( MAX_USER_PRIO*VAVAVOOM_RATIO/100*tokens_left(p) -
+               MAX_USER_PRIO*VAVAVOOM_RATIO/100/2); */
+
+       return vavavoom;
+}
+
+
+int vc_set_sched(uint32_t xid, void __user *data)
+{
+       struct vcmd_set_sched_v2 vc_data;
+       struct vx_info *vxi;
+
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+       
+       vxi = locate_vx_info(xid);
+       if (!vxi)
+               return -EINVAL;
+
+       spin_lock(&vxi->sched.tokens_lock);
+
+       if (vc_data.interval != SCHED_KEEP)
+               vxi->sched.interval = vc_data.interval;
+       if (vc_data.fill_rate != SCHED_KEEP)
+               vxi->sched.fill_rate = vc_data.fill_rate;
+       if (vc_data.tokens_min != SCHED_KEEP)
+               vxi->sched.tokens_min = vc_data.tokens_min;
+       if (vc_data.tokens_max != SCHED_KEEP)
+               vxi->sched.tokens_max = vc_data.tokens_max;
+       if (vc_data.tokens != SCHED_KEEP)
+               atomic_set(&vxi->sched.tokens, vc_data.tokens);
+
+       /* Sanity check the resultant values */
+       if (vxi->sched.fill_rate <= 0)
+               vxi->sched.fill_rate = 1;
+       if (vxi->sched.interval <= 0)
+               vxi->sched.interval = HZ;
+       if (vxi->sched.tokens_max == 0)
+               vxi->sched.tokens_max = 1;
+       if (atomic_read(&vxi->sched.tokens) > vxi->sched.tokens_max)
+               atomic_set(&vxi->sched.tokens, vxi->sched.tokens_max);
+       if (vxi->sched.tokens_min > vxi->sched.tokens_max)
+               vxi->sched.tokens_min = vxi->sched.tokens_max;
+
+       spin_unlock(&vxi->sched.tokens_lock);
+       put_vx_info(vxi);
+       return 0;
+}
+
diff --git a/kernel/vserver/signal.c b/kernel/vserver/signal.c
new file mode 100644 (file)
index 0000000..91d8a3d
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *  linux/kernel/vserver/signal.c
+ *
+ *  Virtual Server: Signal Support
+ *
+ *  Copyright (C) 2003-2004  Herbert Pötzl
+ *
+ *  V0.01  broken out from vcontext V0.05
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+
+#include <asm/errno.h>
+#include <asm/uaccess.h>
+
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vserver/signal.h>
+
+
+int vc_ctx_kill(uint32_t id, void __user *data)
+{
+       int retval, count=0;
+       struct vcmd_ctx_kill_v0 vc_data;
+       struct siginfo info;
+       struct task_struct *p;
+       struct vx_info *vxi;
+
+       if (!vx_check(0, VX_ADMIN))
+               return -ENOSYS;
+       if (copy_from_user (&vc_data, data, sizeof(vc_data)))
+               return -EFAULT;
+       
+       info.si_signo = vc_data.sig;
+       info.si_errno = 0;
+       info.si_code = SI_USER;
+       info.si_pid = current->pid;
+       info.si_uid = current->uid;
+
+       vxi = locate_vx_info(id);
+       if (!vxi)
+               return -ESRCH;
+
+       retval = -ESRCH;
+       read_lock(&tasklist_lock);
+       switch (vc_data.pid) {
+       case -1:
+       case  0:
+               for_each_process(p) {
+                       int err = 0;
+
+                       if (vx_task_xid(p) != id || p->pid <= 1 ||
+                               (vc_data.pid && vxi->vx_initpid == p->pid) ||
+                               !thread_group_leader(p))
+                               continue;
+
+                       err = send_sig_info(vc_data.sig, &info, p);
+                       ++count;
+                       if (err != -EPERM)
+                               retval = err;
+               }
+               break;
+               
+       default:
+       p = find_task_by_pid(vc_data.pid);
+               if (p) {
+                       if (!thread_group_leader(p)) {
+                               struct task_struct *tg;
+                       
+                               tg = find_task_by_pid(p->tgid);
+                               if (tg)
+                                       p = tg;
+                       }
+                       if ((id == -1) || (vx_task_xid(p) == id))
+                               retval = send_sig_info(vc_data.sig, &info, p);
+               }
+               break;
+       }
+       read_unlock(&tasklist_lock);
+       put_vx_info(vxi);
+       return retval;
+}
+
+
diff --git a/kernel/vserver/switch.c b/kernel/vserver/switch.c
new file mode 100644 (file)
index 0000000..f13ee97
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ *  linux/kernel/vserver/switch.c
+ *
+ *  Virtual Server: Syscall Switch
+ *
+ *  Copyright (C) 2003-2004  Herbert Pötzl
+ *
+ *  V0.01  syscall switch
+ *  V0.02  added signal to context
+ *  V0.03  added rlimit functions
+ *  V0.04  added iattr, task/xid functions
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/linkage.h>
+#include <asm/errno.h>
+
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vserver/switch.h>
+
+
+static inline int
+vc_get_version(uint32_t id)
+{
+       return VCI_VERSION;
+}
+
+
+#include <linux/vserver/legacy.h>
+#include <linux/vserver/context.h>
+#include <linux/vserver/network.h>
+#include <linux/vserver/namespace.h>
+#include <linux/vserver/sched.h>
+#include <linux/vserver/limit.h>
+#include <linux/vserver/inode.h>
+#include <linux/vserver/signal.h>
+#include <linux/vserver/dlimit.h>
+
+
+extern asmlinkage long
+sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
+{
+
+       vxdprintk(VXD_CBIT(switch, 0),
+               "vc: VCMD_%02d_%d[%d], %d",
+               VC_CATEGORY(cmd), VC_COMMAND(cmd),
+               VC_VERSION(cmd), id);
+
+       switch (cmd) {
+       case VCMD_get_version:
+               return vc_get_version(id);
+
+#ifdef CONFIG_VSERVER_LEGACY           
+       case VCMD_new_s_context:
+               return vc_new_s_context(id, data);
+       case VCMD_set_ipv4root:
+               return vc_set_ipv4root(id, data);
+#endif
+
+       case VCMD_task_xid:
+               return vc_task_xid(id, data);
+       case VCMD_vx_info:
+               return vc_vx_info(id, data);
+
+       case VCMD_task_nid:
+               return vc_task_nid(id, data);
+       case VCMD_nx_info:
+               return vc_nx_info(id, data);
+
+       case VCMD_set_namespace:
+               return vc_set_namespace(id, data);
+       case VCMD_cleanup_namespace:
+               return vc_cleanup_namespace(id, data);
+       }
+
+       /* those are allowed while in setup too */
+       if (!vx_check(0, VX_ADMIN|VX_WATCH) &&
+               !vx_flags(VXF_STATE_SETUP,0))
+               return -EPERM;
+
+#ifdef CONFIG_VSERVER_LEGACY
+       switch (cmd) {
+       case VCMD_set_cflags:
+       case VCMD_set_ccaps:
+               if (vx_check(0, VX_WATCH))
+                       return 0;
+       }
+#endif
+
+       switch (cmd) {
+       case VCMD_get_rlimit:
+               return vc_get_rlimit(id, data);
+       case VCMD_set_rlimit:
+               return vc_set_rlimit(id, data);
+       case VCMD_get_rlimit_mask:
+               return vc_get_rlimit_mask(id, data);
+               
+       case VCMD_vx_get_vhi_name:
+               return vc_get_vhi_name(id, data);
+       case VCMD_vx_set_vhi_name:
+               return vc_set_vhi_name(id, data);
+
+       case VCMD_set_cflags:
+               return vc_set_cflags(id, data);
+       case VCMD_get_cflags:
+               return vc_get_cflags(id, data);
+
+       case VCMD_set_ccaps:
+               return vc_set_ccaps(id, data);
+       case VCMD_get_ccaps:
+               return vc_get_ccaps(id, data);
+
+       case VCMD_set_nflags:
+               return vc_set_nflags(id, data);
+       case VCMD_get_nflags:
+               return vc_get_nflags(id, data);
+
+       case VCMD_set_ncaps:
+               return vc_set_ncaps(id, data);
+       case VCMD_get_ncaps:
+               return vc_get_ncaps(id, data);
+
+       case VCMD_set_sched:
+               return vc_set_sched(id, data);
+
+       case VCMD_add_dlimit:
+               return vc_add_dlimit(id, data);
+       case VCMD_rem_dlimit:
+               return vc_rem_dlimit(id, data);
+       case VCMD_set_dlimit:
+               return vc_set_dlimit(id, data);
+       case VCMD_get_dlimit:
+               return vc_get_dlimit(id, data);
+       }
+
+       /* below here only with VX_ADMIN */
+       if (!vx_check(0, VX_ADMIN|VX_WATCH))
+               return -EPERM;
+
+       switch (cmd) {
+       case VCMD_ctx_kill:
+               return vc_ctx_kill(id, data);
+
+#ifdef CONFIG_VSERVER_LEGACY           
+       case VCMD_create_context:
+               return vc_ctx_create(id, data);
+#endif
+
+       case VCMD_get_iattr:
+               return vc_get_iattr(id, data);
+       case VCMD_set_iattr:
+               return vc_set_iattr(id, data);
+
+       case VCMD_enter_namespace:
+               return vc_enter_namespace(id, data);
+
+       case VCMD_ctx_create:
+#ifdef CONFIG_VSERVER_LEGACY           
+               if (id == 1) {
+                       current->xid = 1;
+                       return 1;
+               }
+#endif
+               return vc_ctx_create(id, data);
+       case VCMD_ctx_migrate:
+               return vc_ctx_migrate(id, data);
+
+       case VCMD_net_create:
+               return vc_net_create(id, data);
+       case VCMD_net_migrate:
+               return vc_net_migrate(id, data);
+
+       }
+       return -ENOSYS;
+}
+
diff --git a/kernel/vserver/sysctl.c b/kernel/vserver/sysctl.c
new file mode 100644 (file)
index 0000000..e1f2cac
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ *  linux/kernel/sysctl.c
+ *
+ *  Virtual Context Support
+ *
+ *  Copyright (C) 2004  Herbert Pötzl
+ *
+ *  V0.01  basic structure
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/vserver.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/ctype.h>
+#include <linux/sysctl.h>
+#include <linux/fs.h>
+
+#include <asm/uaccess.h>
+#include <asm/unistd.h>
+
+
+#define CTL_VSERVER    4242    /* unused? */
+
+enum {
+        CTL_DEBUG_SWITCH = 1,
+        CTL_DEBUG_XID,
+        CTL_DEBUG_NID,
+        CTL_DEBUG_NET,
+        CTL_DEBUG_LIMIT,
+        CTL_DEBUG_DLIM,
+        CTL_DEBUG_CVIRT,
+};
+
+
+unsigned int vx_debug_switch = 0;
+unsigned int vx_debug_xid = 0;
+unsigned int vx_debug_nid = 0;
+unsigned int vx_debug_net = 0;
+unsigned int vx_debug_limit = 0;
+unsigned int vx_debug_dlim = 0;
+unsigned int vx_debug_cvirt = 0;
+
+
+static struct ctl_table_header *vserver_table_header;
+static ctl_table vserver_table[];
+
+
+void vserver_register_sysctl(void)
+{
+       if (!vserver_table_header) {
+               vserver_table_header = register_sysctl_table(vserver_table, 1);
+#ifdef CONFIG_PROC_FS
+//             if (vserver_table[0].de)
+//                     vserver_table[0].de->owner = THIS_MODULE;
+#endif
+       }
+                       
+}
+
+void vserver_unregister_sysctl(void)
+{
+       if (vserver_table_header) {
+               unregister_sysctl_table(vserver_table_header);
+               vserver_table_header = NULL;
+       }
+}
+
+
+static int proc_dodebug(ctl_table *table, int write,
+       struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       char            tmpbuf[20], *p, c;
+       unsigned int    value;
+       size_t          left, len;
+
+       if ((*ppos && !write) || !*lenp) {
+               *lenp = 0;
+               return 0;
+       }
+
+       left = *lenp;
+
+       if (write) {
+               if (!access_ok(VERIFY_READ, buffer, left))
+                       return -EFAULT;
+               p = (char *) buffer;
+               while (left && __get_user(c, p) >= 0 && isspace(c))
+                       left--, p++;
+               if (!left)
+                       goto done;
+
+               if (left > sizeof(tmpbuf) - 1)
+                       return -EINVAL;
+               if (copy_from_user(tmpbuf, p, left))
+                       return -EFAULT;
+               tmpbuf[left] = '\0';
+
+               for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
+                       value = 10 * value + (*p - '0');
+               if (*p && !isspace(*p))
+                       return -EINVAL;
+               while (left && isspace(*p))
+                       left--, p++;
+               *(unsigned int *) table->data = value;
+       } else {
+               if (!access_ok(VERIFY_WRITE, buffer, left))
+                       return -EFAULT;
+               len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
+               if (len > left)
+                       len = left;
+               if (__copy_to_user(buffer, tmpbuf, len))
+                       return -EFAULT;
+               if ((left -= len) > 0) {
+                       if (put_user('\n', (char *)buffer + len))
+                               return -EFAULT;
+                       left--;
+               }
+       }
+
+done:
+       *lenp -= left;
+       *ppos += *lenp;
+       return 0;
+}
+       
+
+
+static ctl_table debug_table[] = {
+        {
+                .ctl_name       = CTL_DEBUG_SWITCH,
+                .procname       = "debug_switch",
+                .data           = &vx_debug_switch,
+                .maxlen         = sizeof(int),
+                .mode           = 0644,
+                .proc_handler   = &proc_dodebug
+        },
+        {
+                .ctl_name       = CTL_DEBUG_XID,
+                .procname       = "debug_xid",
+                .data           = &vx_debug_xid,
+                .maxlen         = sizeof(int),
+                .mode           = 0644,
+                .proc_handler   = &proc_dodebug
+        },
+        {
+                .ctl_name       = CTL_DEBUG_NID,
+                .procname       = "debug_nid",
+                .data           = &vx_debug_nid,
+                .maxlen         = sizeof(int),
+                .mode           = 0644,
+                .proc_handler   = &proc_dodebug
+        },
+        {
+                .ctl_name       = CTL_DEBUG_NET,
+                .procname       = "debug_net",
+                .data           = &vx_debug_net,
+                .maxlen         = sizeof(int),
+                .mode           = 0644,
+                .proc_handler   = &proc_dodebug
+        },
+        {
+                .ctl_name       = CTL_DEBUG_LIMIT,
+                .procname       = "debug_limit",
+                .data           = &vx_debug_limit,
+                .maxlen         = sizeof(int),
+                .mode           = 0644,
+                .proc_handler   = &proc_dodebug
+        },
+        {
+                .ctl_name       = CTL_DEBUG_DLIM,
+                .procname       = "debug_dlim",
+                .data           = &vx_debug_dlim,
+                .maxlen         = sizeof(int),
+                .mode           = 0644,
+                .proc_handler   = &proc_dodebug
+        },
+        {
+                .ctl_name       = CTL_DEBUG_CVIRT,
+                .procname       = "debug_cvirt",
+                .data           = &vx_debug_cvirt,
+                .maxlen         = sizeof(int),
+                .mode           = 0644,
+                .proc_handler   = &proc_dodebug
+        },
+        { .ctl_name = 0 }
+};
+
+static ctl_table vserver_table[] = {
+        {
+                .ctl_name       = CTL_VSERVER,
+                .procname       = "vserver",
+                .mode           = 0555,
+                .child          = debug_table
+        },
+        { .ctl_name = 0 }
+};
+
+
+EXPORT_SYMBOL_GPL(vx_debug_dlim);
+EXPORT_SYMBOL_GPL(vx_debug_nid);
+EXPORT_SYMBOL_GPL(vx_debug_xid);
+
index d22feb3..60fbbce 100644 (file)
@@ -7,11 +7,15 @@ mmu-$(CONFIG_MMU)     := fremap.o highmem.o madvise.o memory.o mincore.o \
                           mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
                           shmem.o vmalloc.o
 
-obj-y                  := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
+obj-y                  := bootmem.o filemap.o mempool.o fadvise.o \
                           page_alloc.o page-writeback.o pdflush.o prio_tree.o \
                           readahead.o slab.o swap.o truncate.o vmscan.o \
                           $(mmu-y)
 
-obj-$(CONFIG_SWAP)     += page_io.o swap_state.o swapfile.o
+obj-$(CONFIG_OOM_KILL) += oom_kill.o
+obj-$(CONFIG_OOM_PANIC)        += oom_panic.o
+obj-$(CONFIG_SWAP)     += page_io.o swap_state.o swapfile.o thrash.o
+obj-$(CONFIG_X86_4G)   += usercopy.o
 obj-$(CONFIG_HUGETLBFS)        += hugetlb.o
+obj-$(CONFIG_PROC_MM)  += proc_mm.o
 obj-$(CONFIG_NUMA)     += mempolicy.o
index 966135b..1c67737 100644 (file)
@@ -26,6 +26,7 @@
  */
 unsigned long max_low_pfn;
 unsigned long min_low_pfn;
+EXPORT_SYMBOL(min_low_pfn);
 unsigned long max_pfn;
 
 EXPORT_SYMBOL(max_pfn);                /* This is exported so
index ab85dcb..c6d2f66 100644 (file)
@@ -651,7 +651,8 @@ void do_generic_mapping_read(struct address_space *mapping,
                             struct file * filp,
                             loff_t *ppos,
                             read_descriptor_t * desc,
-                            read_actor_t actor)
+                            read_actor_t actor,
+                            int nonblock)
 {
        struct inode *inode = mapping->host;
        unsigned long index, end_index, offset;
@@ -679,11 +680,21 @@ void do_generic_mapping_read(struct address_space *mapping,
 find_page:
                page = find_get_page(mapping, index);
                if (unlikely(page == NULL)) {
+                       if (nonblock) {
+                               desc->error = -EWOULDBLOCKIO;
+                               break;
+                       }
                        handle_ra_miss(mapping, &ra, index);
                        goto no_cached_page;
                }
-               if (!PageUptodate(page))
+               if (!PageUptodate(page)) {
+                       if (nonblock) {
+                               page_cache_release(page);
+                               desc->error = -EWOULDBLOCKIO;
+                               break;
+                       }
                        goto page_not_up_to_date;
+               }
 page_ok:
                /* nr is the maximum number of bytes to copy from this page */
                nr = PAGE_CACHE_SIZE;
@@ -834,7 +845,7 @@ int file_read_actor(read_descriptor_t *desc, struct page *page,
         */
        if (!fault_in_pages_writeable(desc->arg.buf, size)) {
                kaddr = kmap_atomic(page, KM_USER0);
-               left = __copy_to_user(desc->arg.buf, kaddr + offset, size);
+               left = __copy_to_user_inatomic(desc->arg.buf, kaddr + offset, size);
                kunmap_atomic(kaddr, KM_USER0);
                if (left == 0)
                        goto success;
@@ -924,7 +935,7 @@ __generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
                        if (desc.count == 0)
                                continue;
                        desc.error = 0;
-                       do_generic_file_read(filp,ppos,&desc,file_read_actor);
+                       do_generic_file_read(filp,ppos,&desc,file_read_actor,0);
                        retval += desc.written;
                        if (!retval) {
                                retval = desc.error;
@@ -998,7 +1009,7 @@ ssize_t generic_file_sendfile(struct file *in_file, loff_t *ppos,
        desc.arg.data = target;
        desc.error = 0;
 
-       do_generic_file_read(in_file, ppos, &desc, actor);
+       do_generic_file_read(in_file, ppos, &desc, actor, 0);
        if (desc.written)
                return desc.written;
        return desc.error;
@@ -1195,6 +1206,7 @@ no_cached_page:
         * effect.
         */
        error = page_cache_read(file, pgoff);
+       grab_swap_token();
 
        /*
         * The page we want has now been added to the page cache.
@@ -1630,7 +1642,7 @@ filemap_copy_from_user(struct page *page, unsigned long offset,
        int left;
 
        kaddr = kmap_atomic(page, KM_USER0);
-       left = __copy_from_user(kaddr + offset, buf, bytes);
+       left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
        kunmap_atomic(kaddr, KM_USER0);
 
        if (left != 0) {
@@ -1653,7 +1665,7 @@ __filemap_copy_from_user_iovec(char *vaddr,
                int copy = min(bytes, iov->iov_len - base);
 
                base = 0;
-               left = __copy_from_user(vaddr, buf, copy);
+               left = __copy_from_user_inatomic(vaddr, buf, copy);
                copied += copy;
                bytes -= copy;
                vaddr += copy;
@@ -1875,7 +1887,7 @@ generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
        if (err)
                goto out;
 
-       inode_update_time(inode, 1);
+       inode_update_time(inode, file->f_vfsmnt, 1);
 
        /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
        if (unlikely(file->f_flags & O_DIRECT)) {
index dc64dd9..2f211f5 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/swapops.h>
 #include <linux/rmap.h>
 #include <linux/module.h>
+#include <linux/vs_memory.h>
 
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
@@ -38,7 +39,8 @@ static inline void zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
                                        set_page_dirty(page);
                                page_remove_rmap(page);
                                page_cache_release(page);
-                               mm->rss--;
+                               // mm->rss--;
+                               vx_rsspages_dec(mm);
                        }
                }
        } else {
@@ -66,6 +68,9 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
        pgd = pgd_offset(mm, addr);
        spin_lock(&mm->page_table_lock);
 
+       if (!vx_rsspages_avail(mm, 1))
+               goto err_unlock;
+
        pmd = pmd_alloc(mm, pgd, addr);
        if (!pmd)
                goto err_unlock;
@@ -86,7 +91,8 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
 
        zap_pte(mm, vma, addr, pte);
 
-       mm->rss++;
+       // mm->rss++;
+       vx_rsspages_inc(mm);
        flush_icache_page(vma, page);
        set_pte(pte, mk_pte(page, prot));
        page_add_file_rmap(page);
index 05ff499..6c44ecc 100644 (file)
@@ -117,7 +117,8 @@ static inline void free_one_pmd(struct mmu_gather *tlb, pmd_t * dir)
        pte_free_tlb(tlb, page);
 }
 
-static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir)
+static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir,
+                                                       int pgd_idx)
 {
        int j;
        pmd_t * pmd;
@@ -131,8 +132,11 @@ static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir)
        }
        pmd = pmd_offset(dir, 0);
        pgd_clear(dir);
-       for (j = 0; j < PTRS_PER_PMD ; j++)
+       for (j = 0; j < PTRS_PER_PMD ; j++) {
+               if (pgd_idx * PGDIR_SIZE + j * PMD_SIZE >= TASK_SIZE)
+                       break;
                free_one_pmd(tlb, pmd+j);
+       }
        pmd_free_tlb(tlb, pmd);
 }
 
@@ -145,11 +149,13 @@ static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir)
 void clear_page_tables(struct mmu_gather *tlb, unsigned long first, int nr)
 {
        pgd_t * page_dir = tlb->mm->pgd;
+       int pgd_idx = first;
 
        page_dir += first;
        do {
-               free_one_pgd(tlb, page_dir);
+               free_one_pgd(tlb, page_dir, pgd_idx);
                page_dir++;
+               pgd_idx++;
        } while (--nr);
 }
 
@@ -282,6 +288,10 @@ skip_copy_pte_range:
                                struct page *page;
                                unsigned long pfn;
 
+                               if (!vx_rsspages_avail(dst, 1)) {
+                                       spin_unlock(&src->page_table_lock);
+                                       goto nomem;
+                               }
                                /* copy_one_pte */
 
                                if (pte_none(pte))
@@ -325,7 +335,8 @@ skip_copy_pte_range:
                                        pte = pte_mkclean(pte);
                                pte = pte_mkold(pte);
                                get_page(page);
-                               dst->rss++;
+                               // dst->rss++;
+                               vx_rsspages_inc(dst);
                                set_pte(dst_pte, pte);
                                page_dup_rmap(page);
 cont_copy_pte_range_noset:
@@ -441,7 +452,7 @@ static void zap_pmd_range(struct mmu_gather *tlb,
                unsigned long size, struct zap_details *details)
 {
        pmd_t * pmd;
-       unsigned long end;
+       unsigned long end, pgd_boundary;
 
        if (pgd_none(*dir))
                return;
@@ -452,8 +463,9 @@ static void zap_pmd_range(struct mmu_gather *tlb,
        }
        pmd = pmd_offset(dir, address);
        end = address + size;
-       if (end > ((address + PGDIR_SIZE) & PGDIR_MASK))
-               end = ((address + PGDIR_SIZE) & PGDIR_MASK);
+       pgd_boundary = ((address + PGDIR_SIZE) & PGDIR_MASK);
+       if (pgd_boundary && (end > pgd_boundary))
+               end = pgd_boundary;
        do {
                zap_pte_range(tlb, pmd, address, end - address, details);
                address = (address + PMD_SIZE) & PMD_MASK; 
@@ -478,6 +490,10 @@ static void unmap_page_range(struct mmu_gather *tlb,
        tlb_end_vma(tlb, vma);
 }
 
+#ifdef CONFIG_PREEMPT_VOLUNTARY
+# define ZAP_BLOCK_SIZE (128 * PAGE_SIZE)
+#else
+
 /* Dispose of an entire struct mmu_gather per rescheduling point */
 #if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT)
 #define ZAP_BLOCK_SIZE (FREE_PTE_NR * PAGE_SIZE)
@@ -493,6 +509,8 @@ static void unmap_page_range(struct mmu_gather *tlb,
 #define ZAP_BLOCK_SIZE (1024 * PAGE_SIZE)
 #endif
 
+#endif
+
 /**
  * unmap_vmas - unmap a range of memory covered by a list of vma's
  * @tlbp: address of the caller's struct mmu_gather
@@ -565,8 +583,6 @@ int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
 
                        start += block;
                        zap_bytes -= block;
-                       if ((long)zap_bytes > 0)
-                               continue;
                        if (!atomic && need_resched()) {
                                int fullmm = tlb_is_full_mm(*tlbp);
                                tlb_finish_mmu(*tlbp, tlb_start, start);
@@ -574,6 +590,8 @@ int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
                                *tlbp = tlb_gather_mmu(mm, fullmm);
                                tlb_start_valid = 0;
                        }
+                       if ((long)zap_bytes > 0)
+                               continue;
                        zap_bytes = ZAP_BLOCK_SIZE;
                }
        }
@@ -660,6 +678,64 @@ out:
        return NULL;
 }
 
+struct page *
+follow_page_pfn(struct mm_struct *mm, unsigned long address, int write,
+               unsigned long *pfn_ptr)
+{
+       pgd_t *pgd;
+       pmd_t *pmd;
+       pte_t *ptep, pte;
+       unsigned long pfn;
+       struct page *page;
+
+       *pfn_ptr = 0;
+       page = follow_huge_addr(mm, address, write);
+       if (!IS_ERR(page))
+               return page;
+
+       pgd = pgd_offset(mm, address);
+       if (pgd_none(*pgd) || pgd_bad(*pgd))
+               goto out;
+
+       pmd = pmd_offset(pgd, address);
+       if (pmd_none(*pmd))
+               goto out;
+       if (pmd_huge(*pmd))
+               return follow_huge_pmd(mm, address, pmd, write);
+       if (pmd_bad(*pmd))
+               goto out;
+
+       ptep = pte_offset_map(pmd, address);
+       if (!ptep)
+               goto out;
+
+       pte = *ptep;
+       pte_unmap(ptep);
+       if (pte_present(pte)) {
+               if (write && !pte_write(pte))
+                       goto out;
+               if (write && !pte_dirty(pte)) {
+                       struct page *page = pte_page(pte);
+                       if (!PageDirty(page))
+                               set_page_dirty(page);
+               }
+               pfn = pte_pfn(pte);
+               if (pfn_valid(pfn)) {
+                       struct page *page = pfn_to_page(pfn);
+                       
+                       mark_page_accessed(page);
+                       return page;
+               } else {
+                       *pfn_ptr = pfn;
+                       return NULL;
+               }
+       }
+
+out:
+       return NULL;
+}
+
+
 /* 
  * Given a physical address, is there a useful struct page pointing to
  * it?  This may become more complex in the future if we start dealing
@@ -674,6 +750,7 @@ static inline struct page *get_page_map(struct page *page)
 }
 
 
+#ifndef CONFIG_X86_4G
 static inline int
 untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma,
                         unsigned long address)
@@ -698,6 +775,7 @@ untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma,
        /* There is a pte slot for 'address' in 'mm'. */
        return 0;
 }
+#endif
 
 
 int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
@@ -773,12 +851,21 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                                 * insanly big anonymously mapped areas that
                                 * nobody touched so far. This is important
                                 * for doing a core dump for these mappings.
+                                *
+                                * disable this for 4:4 - it prevents
+                                * follow_page() from ever seeing these pages.
+                                *
+                                * (The 'fix' is dubious anyway, there's
+                                * nothing that this code avoids which couldnt
+                                * be triggered from userspace anyway.)
                                 */
+#ifndef CONFIG_X86_4G
                                if (!lookup_write &&
                                    untouched_anonymous_page(mm,vma,start)) {
                                        map = ZERO_PAGE(start);
                                        break;
                                }
+#endif
                                spin_unlock(&mm->page_table_lock);
                                switch (handle_mm_fault(mm,vma,start,write)) {
                                case VM_FAULT_MINOR:
@@ -1096,7 +1183,8 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
        page_table = pte_offset_map(pmd, address);
        if (likely(pte_same(*page_table, pte))) {
                if (PageReserved(old_page))
-                       ++mm->rss;
+                       // ++mm->rss;
+                       vx_rsspages_inc(mm);
                else
                        page_remove_rmap(old_page);
                break_cow(vma, new_page, address, page_table);
@@ -1351,8 +1439,13 @@ static int do_swap_page(struct mm_struct * mm,
                /* Had to read the page from swap area: Major fault */
                ret = VM_FAULT_MAJOR;
                inc_page_state(pgmajfault);
+               grab_swap_token();
        }
 
+       if (!vx_rsspages_avail(mm, 1)) {
+               ret = VM_FAULT_OOM;
+               goto out;
+       }
        mark_page_accessed(page);
        lock_page(page);
 
@@ -1377,7 +1470,8 @@ static int do_swap_page(struct mm_struct * mm,
        if (vm_swap_full())
                remove_exclusive_swap_page(page);
 
-       mm->rss++;
+       // mm->rss++;
+       vx_rsspages_inc(mm);
        pte = mk_pte(page, vma->vm_page_prot);
        if (write_access && can_share_swap_page(page)) {
                pte = maybe_mkwrite(pte_mkdirty(pte), vma);
@@ -1428,6 +1522,9 @@ do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
 
                if (unlikely(anon_vma_prepare(vma)))
                        goto no_mem;
+               if (!vx_rsspages_avail(mm, 1))
+                       goto no_mem;
+
                page = alloc_page_vma(GFP_HIGHUSER, vma, addr);
                if (!page)
                        goto no_mem;
@@ -1442,7 +1539,8 @@ do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
                        spin_unlock(&mm->page_table_lock);
                        goto out;
                }
-               mm->rss++;
+               // mm->rss++;
+               vx_rsspages_inc(mm);
                entry = maybe_mkwrite(pte_mkdirty(mk_pte(page,
                                                         vma->vm_page_prot)),
                                      vma);
@@ -1505,6 +1603,8 @@ retry:
                return VM_FAULT_SIGBUS;
        if (new_page == NOPAGE_OOM)
                return VM_FAULT_OOM;
+       if (!vx_rsspages_avail(mm, 1))
+               return VM_FAULT_OOM;
 
        /*
         * Should we do an early C-O-W break?
@@ -1693,15 +1793,20 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct * vma,
         * We need the page table lock to synchronize with kswapd
         * and the SMP-safe atomic PTE updates.
         */
+       set_delay_flag(current,PF_MEMIO);
        spin_lock(&mm->page_table_lock);
        pmd = pmd_alloc(mm, pgd, address);
 
        if (pmd) {
                pte_t * pte = pte_alloc_map(mm, pmd, address);
-               if (pte)
-                       return handle_pte_fault(mm, vma, address, write_access, pte, pmd);
+               if (pte) {
+                       int rc = handle_pte_fault(mm, vma, address, write_access, pte, pmd);
+                       clear_delay_flag(current,PF_MEMIO);
+                       return rc;
+               }
        }
        spin_unlock(&mm->page_table_lock);
+       clear_delay_flag(current,PF_MEMIO);
        return VM_FAULT_OOM;
 }
 
index a6c1537..8dec877 100644 (file)
@@ -194,6 +194,7 @@ void * mempool_alloc(mempool_t *pool, int gfp_mask)
        DEFINE_WAIT(wait);
        int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO);
 
+       might_sleep_if(gfp_mask & __GFP_WAIT);
 repeat_alloc:
        element = pool->alloc(gfp_nowait|__GFP_NOWARN, pool->pool_data);
        if (likely(element != NULL))
index a9e3716..aa3f047 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/mman.h>
 #include <linux/mm.h>
+#include <linux/vs_memory.h>
 
 
 static int mlock_fixup(struct vm_area_struct * vma, 
@@ -49,7 +50,8 @@ static int mlock_fixup(struct vm_area_struct * vma,
                ret = make_pages_present(start, end);
        }
 
-       vma->vm_mm->locked_vm -= pages;
+       // vma->vm_mm->locked_vm -= pages;
+       vx_vmlocked_sub(vma->vm_mm, pages);
 out:
        return ret;
 }
@@ -60,7 +62,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
        struct vm_area_struct * vma, * next;
        int error;
 
-       if (on && !capable(CAP_IPC_LOCK))
+       if (on && !can_do_mlock())
                return -EPERM;
        len = PAGE_ALIGN(len);
        end = start + len;
@@ -103,7 +105,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
 
 asmlinkage long sys_mlock(unsigned long start, size_t len)
 {
-       unsigned long locked;
+       unsigned long locked, grow;
        unsigned long lock_limit;
        int error = -ENOMEM;
 
@@ -111,15 +113,18 @@ asmlinkage long sys_mlock(unsigned long start, size_t len)
        len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
        start &= PAGE_MASK;
 
-       locked = len >> PAGE_SHIFT;
-       locked += current->mm->locked_vm;
+       grow = len >> PAGE_SHIFT;
+       if (!vx_vmlocked_avail(current->mm, grow))
+               goto out;
+       locked = current->mm->locked_vm + grow;
 
        lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
        lock_limit >>= PAGE_SHIFT;
 
        /* check against resource limits */
-       if (locked <= lock_limit)
+       if ( (locked <= lock_limit) || capable(CAP_IPC_LOCK))
                error = do_mlock(start, len, 1);
+out:
        up_write(&current->mm->mmap_sem);
        return error;
 }
@@ -142,7 +147,7 @@ static int do_mlockall(int flags)
        unsigned int def_flags;
        struct vm_area_struct * vma;
 
-       if (!capable(CAP_IPC_LOCK))
+       if (!can_do_mlock())
                return -EPERM;
 
        def_flags = 0;
@@ -177,7 +182,9 @@ asmlinkage long sys_mlockall(int flags)
        lock_limit >>= PAGE_SHIFT;
 
        ret = -ENOMEM;
-       if (current->mm->total_vm <= lock_limit)
+       if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
+               goto out;
+       if ((current->mm->total_vm <= lock_limit) || capable(CAP_IPC_LOCK))
                ret = do_mlockall(flags);
 out:
        up_write(&current->mm->mmap_sem);
@@ -193,3 +200,36 @@ asmlinkage long sys_munlockall(void)
        up_write(&current->mm->mmap_sem);
        return ret;
 }
+
+/*
+ * Objects with different lifetime than processes (SHM_LOCK and SHM_HUGETLB
+ * shm segments) get accounted against the user_struct instead.
+ */
+static spinlock_t shmlock_user_lock = SPIN_LOCK_UNLOCKED;
+
+int user_shm_lock(size_t size, struct user_struct *user)
+{
+       unsigned long lock_limit, locked;
+       int allowed = 0;
+
+       spin_lock(&shmlock_user_lock);
+       locked = size >> PAGE_SHIFT;
+       lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
+       lock_limit >>= PAGE_SHIFT;
+       if (locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK))
+               goto out;
+       get_uid(user);
+       user->locked_shm += locked;
+       allowed = 1;
+out:
+       spin_unlock(&shmlock_user_lock);
+       return allowed;
+}
+
+void user_shm_unlock(size_t size, struct user_struct *user)
+{
+       spin_lock(&shmlock_user_lock);
+       user->locked_shm -= (size >> PAGE_SHIFT);
+       spin_unlock(&shmlock_user_lock);
+       free_uid(user);
+}
index 68ea8ab..3e11800 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -23,6 +23,7 @@
 #include <linux/mount.h>
 #include <linux/mempolicy.h>
 #include <linux/rmap.h>
+#include <linux/random.h>
 
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
@@ -90,6 +91,7 @@ static void remove_vm_struct(struct vm_area_struct *vma)
 {
        struct file *file = vma->vm_file;
 
+       might_sleep();
        if (file) {
                struct address_space *mapping = file->f_mapping;
                spin_lock(&mapping->i_mmap_lock);
@@ -244,6 +246,8 @@ static inline void
 __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
                struct vm_area_struct *prev, struct rb_node *rb_parent)
 {
+       if (vma->vm_flags & VM_EXEC)
+               arch_add_exec_range(mm, vma->vm_end);
        if (prev) {
                vma->vm_next = prev->vm_next;
                prev->vm_next = vma;
@@ -347,6 +351,8 @@ __vma_unlink(struct mm_struct *mm, struct vm_area_struct *vma,
        rb_erase(&vma->vm_rb, &mm->mm_rb);
        if (mm->mmap_cache == vma)
                mm->mmap_cache = prev;
+       if (vma->vm_flags & VM_EXEC)
+               arch_remove_exec_range(mm, vma->vm_end);
 }
 
 /*
@@ -645,6 +651,8 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
                } else                                  /* cases 2, 5, 7 */
                        vma_adjust(prev, prev->vm_start,
                                end, prev->vm_pgoff, NULL);
+               if (prev->vm_flags & VM_EXEC)
+                       arch_add_exec_range(mm, prev->vm_end);
                return prev;
        }
 
@@ -736,11 +744,11 @@ none:
  * The caller must hold down_write(current->mm->mmap_sem).
  */
 
-unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
-                       unsigned long len, unsigned long prot,
-                       unsigned long flags, unsigned long pgoff)
+unsigned long do_mmap_pgoff(struct mm_struct *mm, struct file * file, 
+                           unsigned long addr, unsigned long len,
+                           unsigned long prot, unsigned long flags,
+                           unsigned long pgoff)
 {
-       struct mm_struct * mm = current->mm;
        struct vm_area_struct * vma, * prev;
        struct inode *inode;
        unsigned int vm_flags;
@@ -788,7 +796,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
        /* Obtain the address to map to. we verify (or select) it and ensure
         * that it represents a valid section of the address space.
         */
-       addr = get_unmapped_area(file, addr, len, pgoff, flags);
+       addr = get_unmapped_area_prot(file, addr, len, pgoff, flags, prot & PROT_EXEC);
        if (addr & ~PAGE_MASK)
                return addr;
 
@@ -800,15 +808,17 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
                        mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
 
        if (flags & MAP_LOCKED) {
-               if (!capable(CAP_IPC_LOCK))
+               if (!can_do_mlock())
                        return -EPERM;
                vm_flags |= VM_LOCKED;
        }
        /* mlock MCL_FUTURE? */
        if (vm_flags & VM_LOCKED) {
-               unsigned long locked = mm->locked_vm << PAGE_SHIFT;
+               unsigned long locked, lock_limit;
+               locked = mm->locked_vm << PAGE_SHIFT;
+               lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
                locked += len;
-               if (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
+               if (locked > lock_limit && !capable(CAP_IPC_LOCK))
                        return -EAGAIN;
        }
 
@@ -881,6 +891,10 @@ munmap_back:
            > current->rlim[RLIMIT_AS].rlim_cur)
                return -ENOMEM;
 
+       /* check context space, maybe only Private writable mapping? */
+       if (!vx_vmpages_avail(mm, len >> PAGE_SHIFT))
+               return -ENOMEM;
+
        if (accountable && (!(flags & MAP_NORESERVE) ||
                        sysctl_overcommit_memory > 1)) {
                if (vm_flags & VM_SHARED) {
@@ -977,9 +991,11 @@ munmap_back:
                kmem_cache_free(vm_area_cachep, vma);
        }
 out:   
-       mm->total_vm += len >> PAGE_SHIFT;
+       // mm->total_vm += len >> PAGE_SHIFT;
+       vx_vmpages_add(mm, len >> PAGE_SHIFT);
        if (vm_flags & VM_LOCKED) {
-               mm->locked_vm += len >> PAGE_SHIFT;
+               // mm->locked_vm += len >> PAGE_SHIFT;
+               vx_vmlocked_add(mm, len >> PAGE_SHIFT);
                make_pages_present(addr, addr + len);
        }
        if (flags & MAP_POPULATE) {
@@ -1020,7 +1036,7 @@ EXPORT_SYMBOL(do_mmap_pgoff);
  * This function "knows" that -ENOMEM has the bits set.
  */
 #ifndef HAVE_ARCH_UNMAPPED_AREA
-static inline unsigned long
+unsigned long
 arch_get_unmapped_area(struct file *filp, unsigned long addr,
                unsigned long len, unsigned long pgoff, unsigned long flags)
 {
@@ -1064,15 +1080,120 @@ full_search:
                addr = vma->vm_end;
        }
 }
-#else
-extern unsigned long
-arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
-                       unsigned long, unsigned long);
 #endif 
 
+void arch_unmap_area(struct vm_area_struct *area)
+{
+       /*
+        * Is this a new hole at the lowest possible address?
+        */
+       if (area->vm_start >= TASK_UNMAPPED_BASE &&
+                       area->vm_start < area->vm_mm->free_area_cache)
+               area->vm_mm->free_area_cache = area->vm_start;
+}
+
+/*
+ * This mmap-allocator allocates new areas top-down from below the
+ * stack's low limit (the base):
+ */
+unsigned long
+arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
+                         const unsigned long len, const unsigned long pgoff,
+                         const unsigned long flags)
+{
+       struct vm_area_struct *vma, *prev_vma;
+       struct mm_struct *mm = current->mm;
+       unsigned long base = mm->mmap_base, addr = addr0;
+       int first_time = 1;
+
+       /* requested length too big for entire address space */
+       if (len > TASK_SIZE)
+               return -ENOMEM;
+
+       /* dont allow allocations above current base */
+       if (mm->free_area_cache > base)
+               mm->free_area_cache = base;
+
+       /* requesting a specific address */
+       if (addr) {
+               addr = PAGE_ALIGN(addr);
+               vma = find_vma(mm, addr);
+               if (TASK_SIZE - len >= addr &&
+                               (!vma || addr + len <= vma->vm_start))
+                       return addr;
+       }
+
+try_again:
+       /* make sure it can fit in the remaining address space */
+       if (mm->free_area_cache < len)
+               goto fail;
+
+       /* either no address requested or cant fit in requested address hole */
+       addr = (mm->free_area_cache - len) & PAGE_MASK;
+       do {
+               /*
+                * Lookup failure means no vma is above this address,
+                * i.e. return with success:
+                */
+               if (!(vma = find_vma_prev(mm, addr, &prev_vma)))
+                       return addr;
+
+               /*
+                * new region fits between prev_vma->vm_end and
+                * vma->vm_start, use it:
+                */
+               if (addr+len <= vma->vm_start &&
+                               (!prev_vma || (addr >= prev_vma->vm_end)))
+                       /* remember the address as a hint for next time */
+                       return (mm->free_area_cache = addr);
+               else
+                       /* pull free_area_cache down to the first hole */
+                       if (mm->free_area_cache == vma->vm_end)
+                               mm->free_area_cache = vma->vm_start;
+
+               /* try just below the current vma->vm_start */
+               addr = vma->vm_start-len;
+       } while (len <= vma->vm_start);
+
+fail:
+       /*
+        * if hint left us with no space for the requested
+        * mapping then try again:
+        */
+       if (first_time) {
+               mm->free_area_cache = base;
+               first_time = 0;
+               goto try_again;
+       }
+       /*
+        * A failed mmap() very likely causes application failure,
+        * so fall back to the bottom-up function here. This scenario
+        * can happen with large stack limits and large mmap()
+        * allocations.
+        */
+       mm->free_area_cache = TASK_UNMAPPED_BASE;
+       addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
+       /*
+        * Restore the topdown base:
+        */
+       mm->free_area_cache = base;
+
+       return addr;
+}
+
+void arch_unmap_area_topdown(struct vm_area_struct *area)
+{
+       /*
+        * Is this a new hole at the highest possible address?
+        */
+       if (area->vm_end > area->vm_mm->free_area_cache)
+               area->vm_mm->free_area_cache = area->vm_end;
+}
+
+
 unsigned long
-get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
-               unsigned long pgoff, unsigned long flags)
+get_unmapped_area_prot(struct file *file, unsigned long addr, unsigned long len,
+               unsigned long pgoff, unsigned long flags, int exec)
 {
        if (flags & MAP_FIXED) {
                unsigned long ret;
@@ -1104,10 +1225,80 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
                return file->f_op->get_unmapped_area(file, addr, len,
                                                pgoff, flags);
 
-       return arch_get_unmapped_area(file, addr, len, pgoff, flags);
+       if (exec && current->mm->get_unmapped_exec_area)
+               return current->mm->get_unmapped_exec_area(file, addr, len, pgoff, flags);
+       else
+               return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);
 }
 
-EXPORT_SYMBOL(get_unmapped_area);
+EXPORT_SYMBOL(get_unmapped_area_prot);
+
+
+#define SHLIB_BASE             0x00111000
+
+unsigned long arch_get_unmapped_exec_area(struct file *filp, unsigned long addr0,
+               unsigned long len0, unsigned long pgoff, unsigned long flags)
+{
+       unsigned long addr = addr0, len = len0;
+       struct mm_struct *mm = current->mm;
+       struct vm_area_struct *vma;
+       unsigned long tmp;
+
+       if (len > TASK_SIZE)
+               return -ENOMEM;
+               
+       if (!addr && !(flags & MAP_FIXED))
+               addr = randomize_range(SHLIB_BASE, 0x01000000, len);
+
+       if (addr) {
+               addr = PAGE_ALIGN(addr);
+               vma = find_vma(mm, addr);
+               if (TASK_SIZE - len >= addr &&
+                   (!vma || addr + len <= vma->vm_start)) {
+                       return addr;
+               }
+       }
+
+       addr = SHLIB_BASE;
+
+       for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
+               /* At this point:  (!vma || addr < vma->vm_end). */
+               if (TASK_SIZE - len < addr) {
+                       return -ENOMEM;
+               }
+               if (!vma || addr + len <= vma->vm_start) {
+                       /*
+                        * Must not let a PROT_EXEC mapping get into the
+                        * brk area:
+                        */
+                       if (addr + len > mm->brk)
+                               goto failed;
+                       
+                       /*
+                        * Up until the brk area we randomize addresses
+                        * as much as possible:
+                        */
+                       if (addr >= 0x01000000) {
+                               tmp = randomize_range(0x01000000, mm->brk, len);
+                               vma = find_vma(mm, tmp);
+                               if (TASK_SIZE - len >= tmp &&
+                                   (!vma || tmp + len <= vma->vm_start))
+                                       return tmp;
+                       }
+                       /*
+                        * Ok, randomization didnt work out - return
+                        * the result of the linear search:
+                        */
+                       return addr;
+               }
+               addr = vma->vm_end;
+       }
+       
+failed:
+       return current->mm->get_unmapped_area(filp, addr0, len0, pgoff, flags);
+}
+
+
 
 /* Look up the first VMA which satisfies  addr < vm_end,  NULL if none. */
 struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr)
@@ -1182,6 +1373,14 @@ out:
        return prev ? prev->vm_next : vma;
 }
 
+
+static int over_stack_limit(unsigned long sz)
+{
+       if (sz < EXEC_STACK_BIAS)
+               return 0;
+       return (sz - EXEC_STACK_BIAS) > current->rlim[RLIMIT_STACK].rlim_cur;
+}
+
 #ifdef CONFIG_STACK_GROWSUP
 /*
  * vma is the first one with address > vma->vm_end.  Have to extend vma.
@@ -1210,13 +1409,14 @@ int expand_stack(struct vm_area_struct * vma, unsigned long address)
        address &= PAGE_MASK;
        grow = (address - vma->vm_end) >> PAGE_SHIFT;
 
-       /* Overcommit.. */
-       if (security_vm_enough_memory(grow)) {
+       /* Overcommit.. vx check first to avoid vm_unacct_memory() */
+       if (!vx_vmpages_avail(vma->vm_mm, grow) ||
+               security_vm_enough_memory(grow)) {
                anon_vma_unlock(vma);
                return -ENOMEM;
        }
        
-       if (address - vma->vm_start > current->rlim[RLIMIT_STACK].rlim_cur ||
+       if (over_stack_limit(address - vma->vm_start) ||
                        ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
                        current->rlim[RLIMIT_AS].rlim_cur) {
                anon_vma_unlock(vma);
@@ -1224,9 +1424,11 @@ int expand_stack(struct vm_area_struct * vma, unsigned long address)
                return -ENOMEM;
        }
        vma->vm_end = address;
-       vma->vm_mm->total_vm += grow;
+       // vma->vm_mm->total_vm += grow;
+       vx_vmpages_add(vma->vm_mm, grow);
        if (vma->vm_flags & VM_LOCKED)
-               vma->vm_mm->locked_vm += grow;
+               // vma->vm_mm->locked_vm += grow;
+               vx_vmlocked_add(vma->vm_mm, grow);
        anon_vma_unlock(vma);
        return 0;
 }
@@ -1271,13 +1473,14 @@ int expand_stack(struct vm_area_struct *vma, unsigned long address)
        address &= PAGE_MASK;
        grow = (vma->vm_start - address) >> PAGE_SHIFT;
 
-       /* Overcommit.. */
-       if (security_vm_enough_memory(grow)) {
+        /* Overcommit.. vx check first to avoid vm_unacct_memory() */
+       if (!vx_vmpages_avail(vma->vm_mm, grow) ||
+               security_vm_enough_memory(grow)) {
                anon_vma_unlock(vma);
                return -ENOMEM;
        }
        
-       if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur ||
+       if (over_stack_limit(vma->vm_end - address) ||
                        ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
                        current->rlim[RLIMIT_AS].rlim_cur) {
                anon_vma_unlock(vma);
@@ -1286,9 +1489,11 @@ int expand_stack(struct vm_area_struct *vma, unsigned long address)
        }
        vma->vm_start = address;
        vma->vm_pgoff -= grow;
-       vma->vm_mm->total_vm += grow;
+       // vma->vm_mm->total_vm += grow;
+       vx_vmpages_add(vma->vm_mm, grow);
        if (vma->vm_flags & VM_LOCKED)
-               vma->vm_mm->locked_vm += grow;
+               // vma->vm_mm->locked_vm += grow;
+               vx_vmlocked_add(vma->vm_mm, grow);
        anon_vma_unlock(vma);
        return 0;
 }
@@ -1391,16 +1596,13 @@ static void unmap_vma(struct mm_struct *mm, struct vm_area_struct *area)
 {
        size_t len = area->vm_end - area->vm_start;
 
-       area->vm_mm->total_vm -= len >> PAGE_SHIFT;
+       // area->vm_mm->total_vm -= len >> PAGE_SHIFT;
+       vx_vmpages_sub(area->vm_mm, len >> PAGE_SHIFT);
+       
        if (area->vm_flags & VM_LOCKED)
-               area->vm_mm->locked_vm -= len >> PAGE_SHIFT;
-       /*
-        * Is this a new hole at the lowest possible address?
-        */
-       if (area->vm_start >= TASK_UNMAPPED_BASE &&
-                               area->vm_start < area->vm_mm->free_area_cache)
-             area->vm_mm->free_area_cache = area->vm_start;
-
+               // area->vm_mm->locked_vm -= len >> PAGE_SHIFT;
+               vx_vmlocked_sub(area->vm_mm, len >> PAGE_SHIFT);
+       area->vm_mm->unmap_area(area);
        remove_vm_struct(area);
 }
 
@@ -1511,10 +1713,14 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
        if (new->vm_ops && new->vm_ops->open)
                new->vm_ops->open(new);
 
-       if (new_below)
+       if (new_below) {
+               unsigned long old_end = vma->vm_end;
+
                vma_adjust(vma, addr, vma->vm_end, vma->vm_pgoff +
                        ((addr - new->vm_start) >> PAGE_SHIFT), new);
-       else
+               if (vma->vm_flags & VM_EXEC)
+                       arch_remove_exec_range(mm, old_end);
+       } else
                vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
 
        return 0;
@@ -1630,10 +1836,14 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
         * mlock MCL_FUTURE?
         */
        if (mm->def_flags & VM_LOCKED) {
-               unsigned long locked = mm->locked_vm << PAGE_SHIFT;
+               unsigned long locked, lock_limit;
+               locked = mm->locked_vm << PAGE_SHIFT;
+               lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
                locked += len;
-               if (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
+               if (locked > lock_limit && !capable(CAP_IPC_LOCK))
                        return -EAGAIN;
+               if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
+                       return -ENOMEM;
        }
 
        /*
@@ -1655,7 +1865,8 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
        if (mm->map_count > sysctl_max_map_count)
                return -ENOMEM;
 
-       if (security_vm_enough_memory(len >> PAGE_SHIFT))
+       if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
+               !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
                return -ENOMEM;
 
        flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
@@ -1683,9 +1894,11 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
        vma->vm_page_prot = protection_map[flags & 0x0f];
        vma_link(mm, vma, prev, rb_link, rb_parent);
 out:
-       mm->total_vm += len >> PAGE_SHIFT;
+       // mm->total_vm += len >> PAGE_SHIFT;
+       vx_vmpages_add(mm, len >> PAGE_SHIFT);
        if (flags & VM_LOCKED) {
-               mm->locked_vm += len >> PAGE_SHIFT;
+               // mm->locked_vm += len >> PAGE_SHIFT;
+               vx_vmlocked_add(mm, len >> PAGE_SHIFT);
                make_pages_present(addr, addr + len);
        }
        return addr;
@@ -1719,9 +1932,13 @@ void exit_mmap(struct mm_struct *mm)
        vma = mm->mmap;
        mm->mmap = mm->mmap_cache = NULL;
        mm->mm_rb = RB_ROOT;
-       mm->rss = 0;
-       mm->total_vm = 0;
-       mm->locked_vm = 0;
+       // mm->rss = 0;
+       vx_rsspages_sub(mm, mm->rss);
+       // mm->total_vm = 0;
+       vx_vmpages_sub(mm, mm->total_vm);
+       // mm->locked_vm = 0;
+       vx_vmlocked_sub(mm, mm->locked_vm);
+       arch_flush_exec_range(mm);
 
        spin_unlock(&mm->page_table_lock);
 
index 88041d4..e978ff3 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
+#include <asm/pgalloc.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
@@ -113,8 +114,9 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
        unsigned long start, unsigned long end, unsigned int newflags)
 {
        struct mm_struct * mm = vma->vm_mm;
-       unsigned long charged = 0;
+       unsigned long charged = 0, old_end = vma->vm_end;
        pgprot_t newprot;
+       unsigned int oldflags;
        pgoff_t pgoff;
        int error;
 
@@ -175,8 +177,11 @@ success:
         * vm_flags and vm_page_prot are protected by the mmap_sem
         * held in write mode.
         */
+       oldflags = vma->vm_flags;
        vma->vm_flags = newflags;
        vma->vm_page_prot = newprot;
+       if (oldflags & VM_EXEC)
+               arch_remove_exec_range(current->mm, old_end);
        change_protection(vma, start, end, newprot);
        return 0;
 
@@ -186,7 +191,8 @@ fail:
 }
 
 asmlinkage long
-sys_mprotect(unsigned long start, size_t len, unsigned long prot)
+do_mprotect(struct mm_struct *mm, unsigned long start, size_t len, 
+            unsigned long prot)
 {
        unsigned long vm_flags, nstart, end, tmp;
        struct vm_area_struct *vma, *prev;
@@ -215,9 +221,9 @@ sys_mprotect(unsigned long start, size_t len, unsigned long prot)
 
        vm_flags = calc_vm_prot_bits(prot);
 
-       down_write(&current->mm->mmap_sem);
+       down_write(&mm->mmap_sem);
 
-       vma = find_vma_prev(current->mm, start, &prev);
+       vma = find_vma_prev(mm, start, &prev);
        error = -ENOMEM;
        if (!vma)
                goto out;
@@ -283,6 +289,11 @@ sys_mprotect(unsigned long start, size_t len, unsigned long prot)
                }
        }
 out:
-       up_write(&current->mm->mmap_sem);
+       up_write(&mm->mmap_sem);
        return error;
 }
+
+asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot)
+{
+        return(do_mprotect(current->mm, start, len, prot));
+}
index 984b8dd..c1cf3c0 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/fs.h>
 #include <linux/highmem.h>
 #include <linux/security.h>
+#include <linux/vs_memory.h>
 
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
@@ -223,9 +224,11 @@ static unsigned long move_vma(struct vm_area_struct *vma,
                        vma->vm_next->vm_flags |= VM_ACCOUNT;
        }
 
-       mm->total_vm += new_len >> PAGE_SHIFT;
+       // mm->total_vm += new_len >> PAGE_SHIFT;
+       vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
        if (vm_flags & VM_LOCKED) {
-               mm->locked_vm += new_len >> PAGE_SHIFT;
+               // mm->locked_vm += new_len >> PAGE_SHIFT;
+               vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
                if (new_len > old_len)
                        make_pages_present(new_addr + old_len,
                                           new_addr + new_len);
@@ -324,16 +327,25 @@ unsigned long do_mremap(unsigned long addr,
                        goto out;
        }
        if (vma->vm_flags & VM_LOCKED) {
-               unsigned long locked = current->mm->locked_vm << PAGE_SHIFT;
+               unsigned long locked, lock_limit;
+               locked = current->mm->locked_vm << PAGE_SHIFT;
+               lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
                locked += new_len - old_len;
                ret = -EAGAIN;
-               if (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
+               if (locked > lock_limit && !capable(CAP_IPC_LOCK))
+                       goto out;
+               ret = -ENOMEM;
+               if (!vx_vmlocked_avail(current->mm,
+                       (new_len - old_len) >> PAGE_SHIFT))
                        goto out;
        }
        ret = -ENOMEM;
        if ((current->mm->total_vm << PAGE_SHIFT) + (new_len - old_len)
            > current->rlim[RLIMIT_AS].rlim_cur)
                goto out;
+       /* check context space, maybe only Private writable mapping? */
+       if (!vx_vmpages_avail(current->mm, (new_len - old_len) >> PAGE_SHIFT))
+               goto out;
 
        if (vma->vm_flags & VM_ACCOUNT) {
                charged = (new_len - old_len) >> PAGE_SHIFT;
@@ -357,9 +369,11 @@ unsigned long do_mremap(unsigned long addr,
                        vma_adjust(vma, vma->vm_start,
                                addr + new_len, vma->vm_pgoff, NULL);
 
-                       current->mm->total_vm += pages;
+                       // current->mm->total_vm += pages;
+                       vx_vmpages_add(current->mm, pages);
                        if (vma->vm_flags & VM_LOCKED) {
-                               current->mm->locked_vm += pages;
+                               // current->mm->locked_vm += pages;
+                               vx_vmlocked_add(vma->vm_mm, pages);
                                make_pages_present(addr + old_len,
                                                   addr + new_len);
                        }
@@ -379,8 +393,8 @@ unsigned long do_mremap(unsigned long addr,
                        if (vma->vm_flags & VM_MAYSHARE)
                                map_flags |= MAP_SHARED;
 
-                       new_addr = get_unmapped_area(vma->vm_file, 0, new_len,
-                                               vma->vm_pgoff, map_flags);
+                       new_addr = get_unmapped_area_prot(vma->vm_file, 0, new_len, 
+                               vma->vm_pgoff, map_flags, vma->vm_flags & VM_EXEC);
                        ret = new_addr;
                        if (new_addr & ~PAGE_MASK)
                                goto out;
index 9bcd259..3de04b6 100644 (file)
@@ -54,6 +54,7 @@ static int badness(struct task_struct *p)
         * The memory size of the process is the basis for the badness.
         */
        points = p->mm->total_vm;
+       /* add vserver badness ;) */
 
        /*
         * CPU time is in seconds and run time is in minutes. There is no
diff --git a/mm/oom_panic.c b/mm/oom_panic.c
new file mode 100644 (file)
index 0000000..b782934
--- /dev/null
@@ -0,0 +1,51 @@
+/* 
+ * Just panic() instead of the default behavior of selecting processes
+ * for death.
+ *
+ * Based on
+ * Modular OOM handlers for 2.6.4 (C) 2003,2004 Tvrtko A. Ursulin
+ * and
+ * linux/mm/oom_kill.c (C) 1998,2000 Rik van Riel.
+ *
+ * Mark Huang <mlhuang@cs.princeton.edu>
+ *
+ * $Id$
+ */
+
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/swap.h>
+
+/**
+ * out_of_memory - is the system out of memory?
+ */
+void out_of_memory(int gfp_mask)
+{
+       /*
+        * oom_lock protects out_of_memory()'s static variables.
+        * It's a global lock; this is not performance-critical.
+        */
+       static spinlock_t oom_lock = SPIN_LOCK_UNLOCKED;
+       static unsigned long count;
+
+       spin_lock(&oom_lock);
+
+       /*
+        * If we have gotten only a few failures,
+        * we're not really oom. 
+        */
+       if (++count < 10)
+               goto out_unlock;
+
+       /*
+        * Ok, really out of memory. Panic.
+        */
+
+       printk("oom-killer: gfp_mask=0x%x\n", gfp_mask);
+       show_free_areas();
+
+       panic("Out Of Memory");
+
+out_unlock:
+       spin_unlock(&oom_lock);
+}
index 6708f4f..675b061 100644 (file)
@@ -31,6 +31,9 @@
 #include <linux/topology.h>
 #include <linux/sysctl.h>
 #include <linux/cpu.h>
+#include <linux/vs_base.h>
+#include <linux/vs_limit.h>
+#include <linux/ckrm_mem_inline.h>
 
 #include <asm/tlbflush.h>
 
@@ -45,6 +48,11 @@ int sysctl_lower_zone_protection = 0;
 EXPORT_SYMBOL(totalram_pages);
 EXPORT_SYMBOL(nr_swap_pages);
 
+#ifdef CONFIG_CRASH_DUMP_MODULE
+/* This symbol has to be exported to use 'for_each_pgdat' macro by modules. */
+EXPORT_SYMBOL(pgdat_list);
+#endif
+
 /*
  * Used by page_zone() to look up the address of the struct zone whose
  * id is encoded in the upper bits of page->flags
@@ -96,7 +104,8 @@ static void bad_page(const char *function, struct page *page)
        page->mapcount = 0;
 }
 
-#ifndef CONFIG_HUGETLB_PAGE
+#if !defined(CONFIG_HUGETLB_PAGE) && !defined(CONFIG_CRASH_DUMP) \
+       && !defined(CONFIG_CRASH_DUMP_MODULE)
 #define prep_compound_page(page, order) do { } while (0)
 #define destroy_compound_page(page, order) do { } while (0)
 #else
@@ -268,6 +277,7 @@ free_pages_bulk(struct zone *zone, int count,
                /* have to delete it as __free_pages_bulk list manipulates */
                list_del(&page->lru);
                __free_pages_bulk(page, base, zone, area, order);
+               ckrm_clear_page_class(page);
                ret++;
        }
        spin_unlock_irqrestore(&zone->lock, flags);
@@ -279,6 +289,8 @@ void __free_pages_ok(struct page *page, unsigned int order)
        LIST_HEAD(list);
        int i;
 
+       arch_free_page(page, order);
+
        mod_page_state(pgfree, 1 << order);
        for (i = 0 ; i < (1 << order) ; ++i)
                free_pages_check(__FUNCTION__, page + i);
@@ -509,6 +521,8 @@ static void fastcall free_hot_cold_page(struct page *page, int cold)
        struct per_cpu_pages *pcp;
        unsigned long flags;
 
+       arch_free_page(page, 0);
+
        kernel_map_pages(page, 1, 0);
        inc_page_state(pgfree);
        free_pages_check(__FUNCTION__, page);
@@ -610,6 +624,10 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
 
        might_sleep_if(wait);
 
+       if (!ckrm_class_limit_ok((GET_MEM_CLASS(current)))) {
+               return NULL;
+       }
+
        zones = zonelist->zones;  /* the list of zones suitable for gfp_mask */
        if (zones[0] == NULL)     /* no zones in the zonelist */
                return NULL;
@@ -739,6 +757,7 @@ nopage:
        return NULL;
 got_pg:
        kernel_map_pages(page, 1 << order, 1);
+       ckrm_set_pages_class(page, 1 << order, GET_MEM_CLASS(current));
        return page;
 }
 
@@ -994,6 +1013,8 @@ void si_meminfo(struct sysinfo *val)
        val->freehigh = 0;
 #endif
        val->mem_unit = PAGE_SIZE;
+       if (vx_flags(VXF_VIRT_MEM, 0))
+               vx_vsi_meminfo(val);
 }
 
 EXPORT_SYMBOL(si_meminfo);
index 1e682be..09e62cf 100644 (file)
@@ -88,6 +88,8 @@ struct pdflush_work {
        unsigned long when_i_went_to_sleep;
 };
 
+void try_to_clip_inodes(void);
+
 static int __pdflush(struct pdflush_work *my_work)
 {
        current->flags |= PF_FLUSHER;
@@ -125,6 +127,8 @@ static int __pdflush(struct pdflush_work *my_work)
                spin_unlock_irq(&pdflush_lock);
 
                (*my_work->fn)(my_work->arg0);
+               
+               try_to_clip_inodes();
 
                /*
                 * Thread creation: For how long have there been zero
index 254cf12..d226b69 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rmap.h>
+#include <linux/vs_memory.h>
 
 #include <asm/tlbflush.h>
 
@@ -230,6 +231,9 @@ static int page_referenced_one(struct page *page,
        if (ptep_clear_flush_young(vma, address, pte))
                referenced++;
 
+       if (mm != current->mm && has_swap_token(mm))
+               referenced++;
+
        (*mapcount)--;
 
 out_unmap:
@@ -512,7 +516,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
                BUG_ON(pte_file(*pte));
        }
 
-       mm->rss--;
+       // mm->rss--;
+       vx_rsspages_dec(mm);
        BUG_ON(!page->mapcount);
        page->mapcount--;
        page_cache_release(page);
@@ -614,7 +619,8 @@ static int try_to_unmap_cluster(unsigned long cursor,
 
                page_remove_rmap(page);
                page_cache_release(page);
-               mm->rss--;
+               // mm->rss--;
+               vx_rsspages_dec(mm);
                (*mapcount)--;
        }
 
index 8ca20e0..74596a4 100644 (file)
@@ -46,7 +46,6 @@
 #include <asm/pgtable.h>
 
 /* This magic number is used in glibc for posix shared memory */
-#define TMPFS_MAGIC    0x01021994
 
 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
@@ -1151,17 +1150,26 @@ shmem_get_policy(struct vm_area_struct *vma, unsigned long addr)
 }
 #endif
 
-void shmem_lock(struct file *file, int lock)
+int shmem_lock(struct file *file, int lock, struct user_struct *user)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct shmem_inode_info *info = SHMEM_I(inode);
+       int retval = -ENOMEM;
 
        spin_lock(&info->lock);
-       if (lock)
+       if (lock && !(info->flags & VM_LOCKED)) {
+               if (!user_shm_lock(inode->i_size, user))
+                       goto out_nomem;
                info->flags |= VM_LOCKED;
-       else
+       }
+       if (!lock && (info->flags & VM_LOCKED) && user) {
+               user_shm_unlock(inode->i_size, user);
                info->flags &= ~VM_LOCKED;
+       }
+       retval = 0;
+out_nomem:
        spin_unlock(&info->lock);
+       return retval;
 }
 
 static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
@@ -1499,7 +1507,7 @@ static int shmem_statfs(struct super_block *sb, struct kstatfs *buf)
 {
        struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 
-       buf->f_type = TMPFS_MAGIC;
+       buf->f_type = TMPFS_SUPER_MAGIC;
        buf->f_bsize = PAGE_CACHE_SIZE;
        spin_lock(&sbinfo->stat_lock);
        buf->f_blocks = sbinfo->max_blocks;
@@ -1829,7 +1837,7 @@ static int shmem_fill_super(struct super_block *sb,
        sb->s_maxbytes = SHMEM_MAX_BYTES;
        sb->s_blocksize = PAGE_CACHE_SIZE;
        sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
-       sb->s_magic = TMPFS_MAGIC;
+       sb->s_magic = TMPFS_SUPER_MAGIC;
        sb->s_op = &shmem_ops;
        inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
        if (!inode)
index 34d9e5b..64485ab 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1337,10 +1337,13 @@ next:
                         * the cache that's used by kmalloc(24), otherwise
                         * the creation of further caches will BUG().
                         */
-                       cachep->array[smp_processor_id()] = &initarray_generic.cache;
+                       cachep->array[smp_processor_id()] =
+                                       &initarray_generic.cache;
                        g_cpucache_up = PARTIAL;
                } else {
-                       cachep->array[smp_processor_id()] = kmalloc(sizeof(struct arraycache_init),GFP_KERNEL);
+                       cachep->array[smp_processor_id()] =
+                               kmalloc(sizeof(struct arraycache_init),
+                                       GFP_KERNEL);
                }
                BUG_ON(!ac_data(cachep));
                ac_data(cachep)->avail = 0;
@@ -1354,7 +1357,7 @@ next:
        } 
 
        cachep->lists.next_reap = jiffies + REAPTIMEOUT_LIST3 +
-                                       ((unsigned long)cachep)%REAPTIMEOUT_LIST3;
+                               ((unsigned long)cachep)%REAPTIMEOUT_LIST3;
 
        /* Need the semaphore to access the chain. */
        down(&cache_chain_sem);
@@ -1367,16 +1370,24 @@ next:
                list_for_each(p, &cache_chain) {
                        kmem_cache_t *pc = list_entry(p, kmem_cache_t, next);
                        char tmp;
-                       /* This happens when the module gets unloaded and doesn't
-                          destroy its slab cache and noone else reuses the vmalloc
-                          area of the module. Print a warning. */
-                       if (__get_user(tmp,pc->name)) { 
-                               printk("SLAB: cache with size %d has lost its name\n", 
-                                       pc->objsize); 
+
+                       /*
+                        * This happens when the module gets unloaded and
+                        * doesn't destroy its slab cache and noone else reuses
+                        * the vmalloc area of the module. Print a warning.
+                        */
+#ifdef CONFIG_X86_UACCESS_INDIRECT
+                       if (__direct_get_user(tmp,pc->name)) {
+#else
+                       if (__get_user(tmp,pc->name)) {
+#endif
+                               printk("SLAB: cache with size %d has lost its "
+                                               "name\n", pc->objsize);
                                continue; 
                        }       
                        if (!strcmp(pc->name,name)) { 
-                               printk("kmem_cache_create: duplicate cache %s\n",name); 
+                               printk("kmem_cache_create: duplicate "
+                                               "cache %s\n",name);
                                up(&cache_chain_sem); 
                                unlock_cpu_hotplug();
                                BUG(); 
index a523ca2..89bc19e 100644 (file)
@@ -29,6 +29,8 @@
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <linux/swapops.h>
+#include <linux/vs_base.h>
+#include <linux/vs_memory.h>
 
 spinlock_t swaplock = SPIN_LOCK_UNLOCKED;
 unsigned int nr_swapfiles;
@@ -430,7 +432,8 @@ static void
 unuse_pte(struct vm_area_struct *vma, unsigned long address, pte_t *dir,
        swp_entry_t entry, struct page *page)
 {
-       vma->vm_mm->rss++;
+       // vma->vm_mm->rss++;
+       vx_rsspages_inc(vma->vm_mm);
        get_page(page);
        set_pte(dir, pte_mkold(mk_pte(page, vma->vm_page_prot)));
        page_add_anon_rmap(page, vma, address);
@@ -1599,6 +1602,8 @@ void si_swapinfo(struct sysinfo *val)
        val->freeswap = nr_swap_pages + nr_to_be_unused;
        val->totalswap = total_swap_pages + nr_to_be_unused;
        swap_list_unlock();
+        if (vx_flags(VXF_VIRT_MEM, 0))
+                vx_vsi_swapinfo(val);
 }
 
 /*
diff --git a/mm/usercopy.c b/mm/usercopy.c
new file mode 100644 (file)
index 0000000..a22b81f
--- /dev/null
@@ -0,0 +1,302 @@
+/*
+ * linux/mm/usercopy.c
+ *
+ * (C) Copyright 2003 Ingo Molnar
+ *
+ * Generic implementation of all the user-VM access functions, without
+ * relying on being able to access the VM directly.
+ */
+
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
+#include <linux/smp_lock.h>
+#include <linux/ptrace.h>
+#include <linux/interrupt.h>
+
+#include <asm/pgtable.h>
+#include <asm/uaccess.h>
+#include <asm/atomic_kmap.h>
+
+/*
+ * Get kernel address of the user page and pin it.
+ */
+static inline struct page *pin_page(unsigned long addr, int write,
+                                       unsigned long *pfn)
+{
+       struct mm_struct *mm = current->mm ? : &init_mm;
+       struct page *page = NULL;
+       int ret;
+
+       /*
+        * Do a quick atomic lookup first - this is the fastpath.
+        */
+retry:
+       page = follow_page_pfn(mm, addr, write, pfn);
+       if (likely(page != NULL)) {
+               if (!PageReserved(page))
+                       get_page(page);
+               return page;
+       }
+       if (*pfn)
+               return NULL;
+       /*
+        * No luck - bad address or need to fault in the page:
+        */
+
+       /* Release the lock so get_user_pages can sleep */
+       spin_unlock(&mm->page_table_lock);
+
+       /*
+        * In the context of filemap_copy_from_user(), we are not allowed
+        * to sleep.  We must fail this usercopy attempt and allow
+        * filemap_copy_from_user() to recover: drop its atomic kmap and use
+        * a sleeping kmap instead.
+        */
+       if (in_atomic()) {
+               spin_lock(&mm->page_table_lock);
+               return NULL;
+       }
+
+       down_read(&mm->mmap_sem);
+       ret = get_user_pages(current, mm, addr, 1, write, 0, NULL, NULL);
+       up_read(&mm->mmap_sem);
+       spin_lock(&mm->page_table_lock);
+
+       if (ret <= 0)
+               return NULL;
+
+       /*
+        * Go try the follow_page again.
+        */
+       goto retry;
+}
+
+static inline void unpin_page(struct page *page)
+{
+       put_page(page);
+}
+
+/*
+ * Access another process' address space.
+ * Source/target buffer must be kernel space,
+ * Do not walk the page table directly, use get_user_pages
+ */
+static int rw_vm(unsigned long addr, void *buf, int len, int write)
+{
+       struct mm_struct *mm = current->mm ? : &init_mm;
+
+       if (!len)
+               return 0;
+
+       spin_lock(&mm->page_table_lock);
+
+       /* ignore errors, just check how much was sucessfully transfered */
+       while (len) {
+               struct page *page = NULL;
+               unsigned long pfn = 0;
+               int bytes, offset;
+               void *maddr;
+
+               page = pin_page(addr, write, &pfn);
+               if (!page && !pfn)
+                       break;
+
+               bytes = len;
+               offset = addr & (PAGE_SIZE-1);
+               if (bytes > PAGE_SIZE-offset)
+                       bytes = PAGE_SIZE-offset;
+
+               if (page)
+                       maddr = kmap_atomic(page, KM_USER_COPY);
+               else
+                       maddr = kmap_atomic_nocache_pfn(pfn, KM_USER_COPY);
+
+#define HANDLE_TYPE(type) \
+       case sizeof(type): *(type *)(maddr+offset) = *(type *)(buf); break;
+
+               if (write) {
+                       switch (bytes) {
+                       HANDLE_TYPE(char);
+                       HANDLE_TYPE(int);
+                       HANDLE_TYPE(long long);
+                       default:
+                               memcpy(maddr + offset, buf, bytes);
+                       }
+               } else {
+#undef HANDLE_TYPE
+#define HANDLE_TYPE(type) \
+       case sizeof(type): *(type *)(buf) = *(type *)(maddr+offset); break;
+                       switch (bytes) {
+                       HANDLE_TYPE(char);
+                       HANDLE_TYPE(int);
+                       HANDLE_TYPE(long long);
+                       default:
+                               memcpy(buf, maddr + offset, bytes);
+                       }
+#undef HANDLE_TYPE
+               }
+               kunmap_atomic(maddr, KM_USER_COPY);
+               if (page)
+                       unpin_page(page);
+               len -= bytes;
+               buf += bytes;
+               addr += bytes;
+       }
+       spin_unlock(&mm->page_table_lock);
+
+       return len;
+}
+
+static int str_vm(unsigned long addr, void *buf0, int len, int copy)
+{
+       struct mm_struct *mm = current->mm ? : &init_mm;
+       struct page *page;
+       void *buf = buf0;
+
+       if (!len)
+               return len;
+
+       spin_lock(&mm->page_table_lock);
+
+       /* ignore errors, just check how much was sucessfully transfered */
+       while (len) {
+               int bytes, offset, left, copied;
+               unsigned long pfn = 0;
+               char *maddr;
+
+               page = pin_page(addr, copy == 2, &pfn);
+               if (!page && !pfn) {
+                       spin_unlock(&mm->page_table_lock);
+                       return -EFAULT;
+               }
+               bytes = len;
+               offset = addr & (PAGE_SIZE-1);
+               if (bytes > PAGE_SIZE-offset)
+                       bytes = PAGE_SIZE-offset;
+
+               if (page)
+                       maddr = kmap_atomic(page, KM_USER_COPY);
+               else
+                       maddr = kmap_atomic_nocache_pfn(pfn, KM_USER_COPY);
+               if (copy == 2) {
+                       memset(maddr + offset, 0, bytes);
+                       copied = bytes;
+                       left = 0;
+               } else if (copy == 1) {
+                       left = strncpy_count(buf, maddr + offset, bytes);
+                       copied = bytes - left;
+               } else {
+                       copied = strnlen(maddr + offset, bytes);
+                       left = bytes - copied;
+               }
+               BUG_ON(bytes < 0 || copied < 0);
+               kunmap_atomic(maddr, KM_USER_COPY);
+               if (page)
+                       unpin_page(page);
+               len -= copied;
+               buf += copied;
+               addr += copied;
+               if (left)
+                       break;
+       }
+       spin_unlock(&mm->page_table_lock);
+
+       return len;
+}
+
+/*
+ * Copies memory from userspace (ptr) into kernelspace (val).
+ *
+ * returns # of bytes not copied.
+ */
+int get_user_size(unsigned int size, void *val, const void *ptr)
+{
+       int ret;
+
+       if (unlikely(segment_eq(get_fs(), KERNEL_DS)))
+               ret = __direct_copy_from_user(val, ptr, size);
+       else
+               ret = rw_vm((unsigned long)ptr, val, size, 0);
+       if (ret)
+               /*
+                * Zero the rest:
+                */
+               memset(val + size - ret, 0, ret);
+       return ret;
+}
+
+/*
+ * Copies memory from kernelspace (val) into userspace (ptr).
+ *
+ * returns # of bytes not copied.
+ */
+int put_user_size(unsigned int size, const void *val, void *ptr)
+{
+       if (unlikely(segment_eq(get_fs(), KERNEL_DS)))
+               return __direct_copy_to_user(ptr, val, size);
+       else
+               return rw_vm((unsigned long)ptr, (void *)val, size, 1);
+}
+
+int copy_str_fromuser_size(unsigned int size, void *val, const void *ptr)
+{
+       int copied, left;
+
+       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
+               left = strncpy_count(val, ptr, size);
+               copied = size - left;
+               BUG_ON(copied < 0);
+
+               return copied;
+       }
+       left = str_vm((unsigned long)ptr, val, size, 1);
+       if (left < 0)
+               return left;
+       copied = size - left;
+       BUG_ON(copied < 0);
+
+       return copied;
+}
+
+int strlen_fromuser_size(unsigned int size, const void *ptr)
+{
+       int copied, left;
+
+       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
+               copied = strnlen(ptr, size) + 1;
+               BUG_ON(copied < 0);
+
+               return copied;
+       }
+       left = str_vm((unsigned long)ptr, NULL, size, 0);
+       if (left < 0)
+               return 0;
+       copied = size - left + 1;
+       BUG_ON(copied < 0);
+
+       return copied;
+}
+
+int zero_user_size(unsigned int size, void *ptr)
+{
+       int left;
+
+       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
+               memset(ptr, 0, size);
+               return 0;
+       }
+       left = str_vm((unsigned long)ptr, NULL, size, 2);
+       if (left < 0)
+               return size;
+       return left;
+}
+
+EXPORT_SYMBOL(get_user_size);
+EXPORT_SYMBOL(put_user_size);
+EXPORT_SYMBOL(zero_user_size);
+EXPORT_SYMBOL(copy_str_fromuser_size);
+EXPORT_SYMBOL(strlen_fromuser_size);
index 8e3b693..e01d5c9 100644 (file)
 #include <asm/div64.h>
 
 #include <linux/swapops.h>
+#include <linux/ckrm_mem.h>
+
+#ifndef AT_LIMIT_SUPPORT
+#warning "ckrm_at_limit disabled due to problems with memory hog tests -- seting ckrm_shrink_list_empty to true"
+#undef ckrm_shrink_list_empty
+#define ckrm_shrink_list_empty()               (1)
+#endif
 
 /* possible outcome of pageout() */
 typedef enum {
@@ -71,6 +78,9 @@ struct scan_control {
        /* This context's GFP mask */
        unsigned int gfp_mask;
 
+       /* Flag used by CKRM */
+       unsigned int ckrm_flags;
+
        int may_writepage;
 };
 
@@ -85,6 +95,11 @@ struct shrinker {
        long                    nr;     /* objs pending delete */
 };
 
+
+
+void try_to_clip_inodes(void);
+
+
 #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
 
 #ifdef ARCH_HAS_PREFETCH
@@ -354,6 +369,8 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc)
                int may_enter_fs;
                int referenced;
 
+               cond_resched();
+
                page = lru_to_page(page_list);
                list_del(&page->lru);
 
@@ -542,19 +559,23 @@ static void shrink_cache(struct zone *zone, struct scan_control *sc)
 {
        LIST_HEAD(page_list);
        struct pagevec pvec;
-       int max_scan = sc->nr_to_scan;
+       int max_scan = sc->nr_to_scan, nr_pass;
+       unsigned int ckrm_flags = sc->ckrm_flags, bit_flag;
 
        pagevec_init(&pvec, 1);
 
        lru_add_drain();
        spin_lock_irq(&zone->lru_lock);
+redo:
+       ckrm_get_reclaim_bits(&ckrm_flags, &bit_flag);
+       nr_pass = zone->nr_inactive;
        while (max_scan > 0) {
                struct page *page;
                int nr_taken = 0;
                int nr_scan = 0;
                int nr_freed;
 
-               while (nr_scan++ < SWAP_CLUSTER_MAX &&
+               while (nr_pass-- && nr_scan++ < SWAP_CLUSTER_MAX &&
                                !list_empty(&zone->inactive_list)) {
                        page = lru_to_page(&zone->inactive_list);
 
@@ -572,15 +593,25 @@ static void shrink_cache(struct zone *zone, struct scan_control *sc)
                                SetPageLRU(page);
                                list_add(&page->lru, &zone->inactive_list);
                                continue;
+                       } else if (bit_flag && !ckrm_kick_page(page, bit_flag)) {
+                               __put_page(page);
+                               SetPageLRU(page);
+#ifdef CONFIG_CKRM_MEM_LRUORDER_CHANGE
+                               list_add_tail(&page->lru, &zone->inactive_list);
+#else
+                               list_add(&page->lru, &zone->inactive_list);
+#endif
+                               continue;
                        }
                        list_add(&page->lru, &page_list);
+                       ckrm_mem_dec_inactive(page);
                        nr_taken++;
                }
                zone->nr_inactive -= nr_taken;
                zone->pages_scanned += nr_taken;
                spin_unlock_irq(&zone->lru_lock);
 
-               if (nr_taken == 0)
+               if ((bit_flag == 0) && (nr_taken == 0))
                        goto done;
 
                max_scan -= nr_scan;
@@ -613,6 +644,9 @@ static void shrink_cache(struct zone *zone, struct scan_control *sc)
                                spin_lock_irq(&zone->lru_lock);
                        }
                }
+               if (ckrm_flags && (nr_pass <= 0)) {
+                       goto redo;
+               }
        }
        spin_unlock_irq(&zone->lru_lock);
 done:
@@ -652,11 +686,17 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc)
        long mapped_ratio;
        long distress;
        long swap_tendency;
+       unsigned int ckrm_flags = sc->ckrm_flags, bit_flag;
+       int nr_pass;
 
        lru_add_drain();
        pgmoved = 0;
        spin_lock_irq(&zone->lru_lock);
-       while (pgscanned < nr_pages && !list_empty(&zone->active_list)) {
+redo:
+       ckrm_get_reclaim_bits(&ckrm_flags, &bit_flag);
+       nr_pass = zone->nr_active;
+       while (pgscanned < nr_pages && !list_empty(&zone->active_list) &&
+                                               nr_pass) {
                page = lru_to_page(&zone->active_list);
                prefetchw_prev_lru_page(page, &zone->active_list, flags);
                if (!TestClearPageLRU(page))
@@ -672,11 +712,24 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc)
                        __put_page(page);
                        SetPageLRU(page);
                        list_add(&page->lru, &zone->active_list);
+                       pgscanned++;
+               } else if (bit_flag && !ckrm_kick_page(page, bit_flag)) {
+                       __put_page(page);
+                       SetPageLRU(page);
+#ifdef CONFIG_CKRM_MEM_LRUORDER_CHANGE
+                       list_add_tail(&page->lru, &zone->active_list);
+#else
+                       list_add(&page->lru, &zone->active_list);
+#endif
                } else {
                        list_add(&page->lru, &l_hold);
+                       ckrm_mem_dec_active(page);
                        pgmoved++;
+                       pgscanned++;
+               }
+               if (!--nr_pass && ckrm_flags) {
+                       goto redo;
                }
-               pgscanned++;
        }
        zone->nr_active -= pgmoved;
        spin_unlock_irq(&zone->lru_lock);
@@ -713,6 +766,7 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc)
                reclaim_mapped = 1;
 
        while (!list_empty(&l_hold)) {
+               cond_resched();
                page = lru_to_page(&l_hold);
                list_del(&page->lru);
                if (page_mapped(page)) {
@@ -750,6 +804,7 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc)
                if (!TestClearPageActive(page))
                        BUG();
                list_move(&page->lru, &zone->inactive_list);
+               ckrm_mem_inc_inactive(page);
                pgmoved++;
                if (!pagevec_add(&pvec, page)) {
                        zone->nr_inactive += pgmoved;
@@ -778,6 +833,7 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc)
                        BUG();
                BUG_ON(!PageActive(page));
                list_move(&page->lru, &zone->active_list);
+               ckrm_mem_inc_active(page);
                pgmoved++;
                if (!pagevec_add(&pvec, page)) {
                        zone->nr_active += pgmoved;
@@ -825,6 +881,7 @@ shrink_zone(struct zone *zone, struct scan_control *sc)
        sc->nr_to_reclaim = SWAP_CLUSTER_MAX;
 
        while (nr_active || nr_inactive) {
+               sc->ckrm_flags = ckrm_setup_reclamation();
                if (nr_active) {
                        sc->nr_to_scan = min(nr_active,
                                        (unsigned long)SWAP_CLUSTER_MAX);
@@ -840,9 +897,118 @@ shrink_zone(struct zone *zone, struct scan_control *sc)
                        if (sc->nr_to_reclaim <= 0)
                                break;
                }
+               ckrm_teardown_reclamation();
+       }
+}
+
+#if defined(CONFIG_CKRM_RES_MEM) && defined(AT_LIMIT_SUPPORT)
+// This function needs to be given more thought.
+// Shrink the class to be at 90% of its limit
+static void
+ckrm_shrink_class(ckrm_mem_res_t *cls)
+{
+       struct scan_control sc;
+       struct zone *zone;
+       int zindex = 0, active_credit = 0, inactive_credit = 0;
+
+       if (ckrm_test_set_shrink(cls)) { // set the SHRINK bit atomically
+               // if it is already set somebody is working on it. so... leave
+               return;
+       }
+       sc.nr_mapped = read_page_state(nr_mapped);
+       sc.nr_scanned = 0;
+       sc.ckrm_flags = ckrm_get_reclaim_flags(cls);
+       sc.nr_reclaimed = 0;
+       sc.priority = 0; // always very high priority
+
+       for_each_zone(zone) {
+               int zone_total, zone_limit, active_limit, inactive_limit;
+               int active_over, inactive_over;
+               unsigned long nr_active, nr_inactive;
+               u64 temp;
+
+               zone->temp_priority = zone->prev_priority;
+               zone->prev_priority = sc.priority;
+
+               zone_total = zone->nr_active + zone->nr_inactive + zone->free_pages;
+
+               temp = (u64) cls->pg_limit * zone_total;
+               do_div(temp, ckrm_tot_lru_pages);
+               zone_limit = (int) temp;
+               active_limit = (6 * zone_limit) / 10; // 2/3rd in active list
+               inactive_limit = (3 * zone_limit) / 10; // 1/3rd in inactive list
+
+               active_over = cls->nr_active[zindex] - active_limit + active_credit;
+               inactive_over = active_over +
+                               (cls->nr_inactive[zindex] - inactive_limit) + inactive_credit;
+
+               if (active_over > 0) {
+                       zone->nr_scan_active += active_over + 1;
+                       nr_active = zone->nr_scan_active;
+                       active_credit = 0;
+               } else {
+                       active_credit += active_over;
+                       nr_active = 0;
+               }
+
+               if (inactive_over > 0) {
+                       zone->nr_scan_inactive += inactive_over;
+                       nr_inactive = zone->nr_scan_inactive;
+                       inactive_credit = 0;
+               } else {
+                       inactive_credit += inactive_over;
+                       nr_inactive = 0;
+               }
+               while (nr_active || nr_inactive) {
+                       if (nr_active) {
+                               sc.nr_to_scan = min(nr_active,
+                                               (unsigned long)SWAP_CLUSTER_MAX);
+                               nr_active -= sc.nr_to_scan;
+                               refill_inactive_zone(zone, &sc);
+                       }
+       
+                       if (nr_inactive) {
+                               sc.nr_to_scan = min(nr_inactive,
+                                               (unsigned long)SWAP_CLUSTER_MAX);
+                               nr_inactive -= sc.nr_to_scan;
+                               shrink_cache(zone, &sc);
+                               if (sc.nr_to_reclaim <= 0)
+                                       break;
+                       }
+               }
+               zone->prev_priority = zone->temp_priority;
+               zindex++;
        }
+       ckrm_clear_shrink(cls);
 }
 
+static void
+ckrm_shrink_classes(void)
+{
+       ckrm_mem_res_t *cls;
+
+       spin_lock(&ckrm_mem_lock);
+       while (!ckrm_shrink_list_empty()) {
+               cls =  list_entry(ckrm_shrink_list.next, ckrm_mem_res_t,
+                               shrink_list);
+               spin_unlock(&ckrm_mem_lock);
+               ckrm_shrink_class(cls);
+               spin_lock(&ckrm_mem_lock);
+               list_del(&cls->shrink_list);
+               cls->flags &= ~MEM_AT_LIMIT;
+       }
+       spin_unlock(&ckrm_mem_lock);
+}
+
+#else
+
+#if defined(CONFIG_CKRM_RES_MEM) && !defined(AT_LIMIT_SUPPORT)
+#warning "disabling ckrm_at_limit -- setting ckrm_shrink_classes to noop "
+#endif
+
+#define ckrm_shrink_classes()  do { } while(0)
+#endif
+
 /*
  * This is the direct reclaim path, for page-allocating processes.  We only
  * try to reclaim pages from zones which will satisfy the caller's allocation
@@ -1147,7 +1313,11 @@ static int kswapd(void *p)
                prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
                schedule();
                finish_wait(&pgdat->kswapd_wait, &wait);
+               try_to_clip_inodes();           
 
+               if (!ckrm_shrink_list_empty())
+                       ckrm_shrink_classes();
+               else
                balance_pgdat(pgdat, 0);
        }
        return 0;
@@ -1158,7 +1328,7 @@ static int kswapd(void *p)
  */
 void wakeup_kswapd(struct zone *zone)
 {
-       if (zone->free_pages > zone->pages_low)
+       if ((zone->free_pages > zone->pages_low) && ckrm_shrink_list_empty())
                return;
        if (!waitqueue_active(&zone->zone_pgdat->kswapd_wait))
                return;
index 37ee31e..e2334b3 100644 (file)
@@ -654,6 +654,8 @@ source "net/irda/Kconfig"
 
 source "net/bluetooth/Kconfig"
 
+source "net/tux/Kconfig"
+
 source "drivers/net/Kconfig"
 
 endmenu
index 61740b4..7e7a957 100644 (file)
@@ -19,6 +19,7 @@ obj-$(CONFIG_UNIX)            += unix/
 ifneq ($(CONFIG_IPV6),)
 obj-y                          += ipv6/
 endif
+obj-$(CONFIG_TUX)              += tux/
 obj-$(CONFIG_PACKET)           += packet/
 obj-$(CONFIG_NET_KEY)          += key/
 obj-$(CONFIG_NET_SCHED)                += sched/
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
deleted file mode 100644 (file)
index ee652ae..0000000
+++ /dev/null
@@ -1,645 +0,0 @@
-/* 
-   HIDP implementation for Linux Bluetooth stack (BlueZ).
-   Copyright (C) 2003-2004 Marcel Holtmann <marcel@holtmann.org>
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License version 2 as
-   published by the Free Software Foundation;
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
-   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
-   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
-   SOFTWARE IS DISCLAIMED.
-*/
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <linux/fcntl.h>
-#include <linux/skbuff.h>
-#include <linux/socket.h>
-#include <linux/ioctl.h>
-#include <linux/file.h>
-#include <linux/init.h>
-#include <net/sock.h>
-
-#include <linux/input.h>
-
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/l2cap.h>
-
-#include "hidp.h"
-
-#ifndef CONFIG_BT_HIDP_DEBUG
-#undef  BT_DBG
-#define BT_DBG(D...)
-#endif
-
-#define VERSION "1.0"
-
-static DECLARE_RWSEM(hidp_session_sem);
-static LIST_HEAD(hidp_session_list);
-
-static unsigned char hidp_keycode[256] = {
-         0,  0,  0,  0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
-        50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44,  2,  3,
-         4,  5,  6,  7,  8,  9, 10, 11, 28,  1, 14, 15, 57, 12, 13, 26,
-        27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
-        65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
-       105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
-        72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,
-       191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,
-       115,114,  0,  0,  0,121,  0, 89, 93,124, 92, 94, 95,  0,  0,  0,
-       122,123, 90, 91, 85,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-        29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
-       150,158,159,128,136,177,178,176,142,152,173,140
-};
-
-static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr)
-{
-       struct hidp_session *session;
-       struct list_head *p;
-
-       BT_DBG("");
-
-       list_for_each(p, &hidp_session_list) {
-               session = list_entry(p, struct hidp_session, list);
-               if (!bacmp(bdaddr, &session->bdaddr))
-                       return session;
-       }
-       return NULL;
-}
-
-static void __hidp_link_session(struct hidp_session *session)
-{
-       __module_get(THIS_MODULE);
-       list_add(&session->list, &hidp_session_list);
-}
-
-static void __hidp_unlink_session(struct hidp_session *session)
-{
-       list_del(&session->list);
-       module_put(THIS_MODULE);
-}
-
-static void __hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci)
-{
-       bacpy(&ci->bdaddr, &session->bdaddr);
-
-       ci->flags = session->flags;
-       ci->state = session->state;
-
-       ci->vendor  = 0x0000;
-       ci->product = 0x0000;
-       ci->version = 0x0000;
-       memset(ci->name, 0, 128);
-
-       if (session->input) {
-               ci->vendor  = session->input->id.vendor;
-               ci->product = session->input->id.product;
-               ci->version = session->input->id.version;
-               if (session->input->name)
-                       strncpy(ci->name, session->input->name, 128);
-               else
-                       strncpy(ci->name, "HID Boot Device", 128);
-       }
-}
-
-static int hidp_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
-{
-       struct hidp_session *session = dev->private;
-       struct sk_buff *skb;
-       unsigned char newleds;
-
-       BT_DBG("session %p hid %p data %p size %d", session, device, data, size);
-
-       if (type != EV_LED)
-               return -1;
-
-       newleds = (!!test_bit(LED_KANA,    dev->led) << 3) |
-                 (!!test_bit(LED_COMPOSE, dev->led) << 3) |
-                 (!!test_bit(LED_SCROLLL, dev->led) << 2) |
-                 (!!test_bit(LED_CAPSL,   dev->led) << 1) |
-                 (!!test_bit(LED_NUML,    dev->led));
-
-       if (session->leds == newleds)
-               return 0;
-
-       session->leds = newleds;
-
-       if (!(skb = alloc_skb(3, GFP_ATOMIC))) {
-               BT_ERR("Can't allocate memory for new frame");
-               return -ENOMEM;
-       }
-
-       *skb_put(skb, 1) = 0xa2;
-       *skb_put(skb, 1) = 0x01;
-       *skb_put(skb, 1) = newleds;
-
-       skb_queue_tail(&session->intr_transmit, skb);
-
-       hidp_schedule(session);
-
-       return 0;
-}
-
-static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
-{
-       struct input_dev *dev = session->input;
-       unsigned char *keys = session->keys;
-       unsigned char *udata = skb->data + 1;
-       signed char *sdata = skb->data + 1;
-       int i, size = skb->len - 1;
-
-       switch (skb->data[0]) {
-       case 0x01:      /* Keyboard report */
-               for (i = 0; i < 8; i++)
-                       input_report_key(dev, hidp_keycode[i + 224], (udata[0] >> i) & 1);
-
-               for (i = 2; i < 8; i++) {
-                       if (keys[i] > 3 && memscan(udata + 2, keys[i], 6) == udata + 8) {
-                               if (hidp_keycode[keys[i]])
-                                       input_report_key(dev, hidp_keycode[keys[i]], 0);
-                               else
-                                       BT_ERR("Unknown key (scancode %#x) released.", keys[i]);
-                       }
-
-                       if (udata[i] > 3 && memscan(keys + 2, udata[i], 6) == keys + 8) {
-                               if (hidp_keycode[udata[i]])
-                                       input_report_key(dev, hidp_keycode[udata[i]], 1);
-                               else
-                                       BT_ERR("Unknown key (scancode %#x) pressed.", udata[i]);
-                       }
-               }
-
-               memcpy(keys, udata, 8);
-               break;
-
-       case 0x02:      /* Mouse report */
-               input_report_key(dev, BTN_LEFT,   sdata[0] & 0x01);
-               input_report_key(dev, BTN_RIGHT,  sdata[0] & 0x02);
-               input_report_key(dev, BTN_MIDDLE, sdata[0] & 0x04);
-               input_report_key(dev, BTN_SIDE,   sdata[0] & 0x08);
-               input_report_key(dev, BTN_EXTRA,  sdata[0] & 0x10);
-
-               input_report_rel(dev, REL_X, sdata[1]);
-               input_report_rel(dev, REL_Y, sdata[2]);
-
-               if (size > 3)
-                       input_report_rel(dev, REL_WHEEL, sdata[3]);
-               break;
-       }
-
-       input_sync(dev);
-}
-
-static void hidp_idle_timeout(unsigned long arg)
-{
-       struct hidp_session *session = (struct hidp_session *) arg;
-
-       atomic_inc(&session->terminate);
-       hidp_schedule(session);
-}
-
-static inline void hidp_set_timer(struct hidp_session *session)
-{
-       if (session->idle_to > 0)
-               mod_timer(&session->timer, jiffies + HZ * session->idle_to);
-}
-
-static inline void hidp_del_timer(struct hidp_session *session)
-{
-       if (session->idle_to > 0)
-               del_timer(&session->timer);
-}
-
-static inline void hidp_send_message(struct hidp_session *session, unsigned char hdr)
-{
-       struct sk_buff *skb;
-
-       BT_DBG("session %p", session);
-
-       if (!(skb = alloc_skb(1, GFP_ATOMIC))) {
-               BT_ERR("Can't allocate memory for message");
-               return;
-       }
-
-       *skb_put(skb, 1) = hdr;
-
-       skb_queue_tail(&session->ctrl_transmit, skb);
-
-       hidp_schedule(session);
-}
-
-static inline int hidp_recv_frame(struct hidp_session *session, struct sk_buff *skb)
-{
-       __u8 hdr;
-
-       BT_DBG("session %p skb %p len %d", session, skb, skb->len);
-
-       hdr = skb->data[0];
-       skb_pull(skb, 1);
-
-       if (hdr == 0xa1) {
-               hidp_set_timer(session);
-
-               if (session->input)
-                       hidp_input_report(session, skb);
-       } else {
-               BT_DBG("Unsupported protocol header 0x%02x", hdr);
-       }
-
-       kfree_skb(skb);
-       return 0;
-}
-
-static int hidp_send_frame(struct socket *sock, unsigned char *data, int len)
-{
-       struct kvec iv = { data, len };
-       struct msghdr msg;
-
-       BT_DBG("sock %p data %p len %d", sock, data, len);
-
-       if (!len)
-               return 0;
-
-       memset(&msg, 0, sizeof(msg));
-
-       return kernel_sendmsg(sock, &msg, &iv, 1, len);
-}
-
-static int hidp_process_transmit(struct hidp_session *session)
-{
-       struct sk_buff *skb;
-
-       BT_DBG("session %p", session);
-
-       while ((skb = skb_dequeue(&session->ctrl_transmit))) {
-               if (hidp_send_frame(session->ctrl_sock, skb->data, skb->len) < 0) {
-                       skb_queue_head(&session->ctrl_transmit, skb);
-                       break;
-               }
-
-               hidp_set_timer(session);
-               kfree_skb(skb);
-       }
-
-       while ((skb = skb_dequeue(&session->intr_transmit))) {
-               if (hidp_send_frame(session->intr_sock, skb->data, skb->len) < 0) {
-                       skb_queue_head(&session->intr_transmit, skb);
-                       break;
-               }
-
-               hidp_set_timer(session);
-               kfree_skb(skb);
-       }
-
-       return skb_queue_len(&session->ctrl_transmit) +
-                               skb_queue_len(&session->intr_transmit);
-}
-
-static int hidp_session(void *arg)
-{
-       struct hidp_session *session = arg;
-       struct sock *ctrl_sk = session->ctrl_sock->sk;
-       struct sock *intr_sk = session->intr_sock->sk;
-       struct sk_buff *skb;
-       int vendor = 0x0000, product = 0x0000;
-       wait_queue_t ctrl_wait, intr_wait;
-       unsigned long timeo = HZ;
-
-       BT_DBG("session %p", session);
-
-       if (session->input) {
-               vendor  = session->input->id.vendor;
-               product = session->input->id.product;
-       }
-
-       daemonize("khidpd_%04x%04x", vendor, product);
-       set_user_nice(current, -15);
-       current->flags |= PF_NOFREEZE;
-
-       init_waitqueue_entry(&ctrl_wait, current);
-       init_waitqueue_entry(&intr_wait, current);
-       add_wait_queue(ctrl_sk->sk_sleep, &ctrl_wait);
-       add_wait_queue(intr_sk->sk_sleep, &intr_wait);
-       while (!atomic_read(&session->terminate)) {
-               set_current_state(TASK_INTERRUPTIBLE);
-
-               if (ctrl_sk->sk_state != BT_CONNECTED || intr_sk->sk_state != BT_CONNECTED)
-                       break;
-
-               while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) {
-                       skb_orphan(skb);
-                       hidp_recv_frame(session, skb);
-               }
-
-               while ((skb = skb_dequeue(&intr_sk->sk_receive_queue))) {
-                       skb_orphan(skb);
-                       hidp_recv_frame(session, skb);
-               }
-
-               hidp_process_transmit(session);
-
-               schedule();
-       }
-       set_current_state(TASK_RUNNING);
-       remove_wait_queue(intr_sk->sk_sleep, &intr_wait);
-       remove_wait_queue(ctrl_sk->sk_sleep, &ctrl_wait);
-
-       down_write(&hidp_session_sem);
-
-       hidp_del_timer(session);
-
-       if (intr_sk->sk_state != BT_CONNECTED) {
-               init_waitqueue_entry(&ctrl_wait, current);
-               add_wait_queue(ctrl_sk->sk_sleep, &ctrl_wait);
-               while (timeo && ctrl_sk->sk_state != BT_CLOSED) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       timeo = schedule_timeout(timeo);
-               }
-               set_current_state(TASK_RUNNING);
-               remove_wait_queue(ctrl_sk->sk_sleep, &ctrl_wait);
-               timeo = HZ;
-       }
-
-       fput(session->ctrl_sock->file);
-
-       init_waitqueue_entry(&intr_wait, current);
-       add_wait_queue(intr_sk->sk_sleep, &intr_wait);
-       while (timeo && intr_sk->sk_state != BT_CLOSED) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               timeo = schedule_timeout(timeo);
-       }
-       set_current_state(TASK_RUNNING);
-       remove_wait_queue(intr_sk->sk_sleep, &intr_wait);
-
-       fput(session->intr_sock->file);
-
-       __hidp_unlink_session(session);
-
-       if (session->input) {
-               input_unregister_device(session->input);
-               kfree(session->input);
-       }
-
-       up_write(&hidp_session_sem);
-
-       kfree(session);
-       return 0;
-}
-
-static inline void hidp_setup_input(struct hidp_session *session, struct hidp_connadd_req *req)
-{
-       struct input_dev *input = session->input;
-       int i;
-
-       input->private = session;
-
-       input->id.bustype = BUS_BLUETOOTH;
-       input->id.vendor  = req->vendor;
-       input->id.product = req->product;
-       input->id.version = req->version;
-
-       if (req->subclass & 0x40) {
-               set_bit(EV_KEY, input->evbit);
-               set_bit(EV_LED, input->evbit);
-               set_bit(EV_REP, input->evbit);
-
-               set_bit(LED_NUML,    input->ledbit);
-               set_bit(LED_CAPSL,   input->ledbit);
-               set_bit(LED_SCROLLL, input->ledbit);
-               set_bit(LED_COMPOSE, input->ledbit);
-               set_bit(LED_KANA,    input->ledbit);
-
-               for (i = 0; i < sizeof(hidp_keycode); i++)
-                       set_bit(hidp_keycode[i], input->keybit);
-               clear_bit(0, input->keybit);
-       }
-
-       if (req->subclass & 0x80) {
-               input->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
-               input->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
-               input->relbit[0] = BIT(REL_X) | BIT(REL_Y);
-               input->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA);
-               input->relbit[0] |= BIT(REL_WHEEL);
-       }
-
-       input->event = hidp_input_event;
-
-       input_register_device(input);
-}
-
-int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
-{
-       struct hidp_session *session, *s;
-       int err;
-
-       BT_DBG("");
-
-       if (bacmp(&bt_sk(ctrl_sock->sk)->src, &bt_sk(intr_sock->sk)->src) ||
-                       bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst))
-               return -ENOTUNIQ;
-
-       session = kmalloc(sizeof(struct hidp_session), GFP_KERNEL);
-       if (!session) 
-               return -ENOMEM;
-       memset(session, 0, sizeof(struct hidp_session));
-
-       session->input = kmalloc(sizeof(struct input_dev), GFP_KERNEL);
-       if (!session->input) {
-               kfree(session);
-               return -ENOMEM;
-       }
-       memset(session->input, 0, sizeof(struct input_dev));
-
-       down_write(&hidp_session_sem);
-
-       s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst);
-       if (s && s->state == BT_CONNECTED) {
-               err = -EEXIST;
-               goto failed;
-       }
-
-       bacpy(&session->bdaddr, &bt_sk(ctrl_sock->sk)->dst);
-
-       session->ctrl_mtu = min_t(uint, l2cap_pi(ctrl_sock->sk)->omtu, l2cap_pi(ctrl_sock->sk)->imtu);
-       session->intr_mtu = min_t(uint, l2cap_pi(intr_sock->sk)->omtu, l2cap_pi(intr_sock->sk)->imtu);
-
-       BT_DBG("ctrl mtu %d intr mtu %d", session->ctrl_mtu, session->intr_mtu);
-
-       session->ctrl_sock = ctrl_sock;
-       session->intr_sock = intr_sock;
-       session->state     = BT_CONNECTED;
-
-       init_timer(&session->timer);
-
-       session->timer.function = hidp_idle_timeout;
-       session->timer.data     = (unsigned long) session;
-
-       skb_queue_head_init(&session->ctrl_transmit);
-       skb_queue_head_init(&session->intr_transmit);
-
-       session->flags   = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID);
-       session->idle_to = req->idle_to;
-
-       if (session->input)
-               hidp_setup_input(session, req);
-
-       __hidp_link_session(session);
-
-       hidp_set_timer(session);
-
-       err = kernel_thread(hidp_session, session, CLONE_KERNEL);
-       if (err < 0)
-               goto unlink;
-
-       if (session->input) {
-               hidp_send_message(session, 0x70);
-               session->flags |= (1 << HIDP_BOOT_PROTOCOL_MODE);
-
-               session->leds = 0xff;
-               hidp_input_event(session->input, EV_LED, 0, 0);
-       }
-
-       up_write(&hidp_session_sem);
-       return 0;
-
-unlink:
-       hidp_del_timer(session);
-
-       __hidp_unlink_session(session);
-
-       if (session->input)
-               input_unregister_device(session->input);
-
-failed:
-       up_write(&hidp_session_sem);
-
-       if (session->input)
-               kfree(session->input);
-
-       kfree(session);
-       return err;
-}
-
-int hidp_del_connection(struct hidp_conndel_req *req)
-{
-       struct hidp_session *session;
-       int err = 0;
-
-       BT_DBG("");
-
-       down_read(&hidp_session_sem);
-
-       session = __hidp_get_session(&req->bdaddr);
-       if (session) {
-               if (req->flags & (1 << HIDP_VIRTUAL_CABLE_UNPLUG)) {
-                       hidp_send_message(session, 0x15);
-               } else {
-                       /* Flush the transmit queues */
-                       skb_queue_purge(&session->ctrl_transmit);
-                       skb_queue_purge(&session->intr_transmit);
-
-                       /* Kill session thread */
-                       atomic_inc(&session->terminate);
-                       hidp_schedule(session);
-               }
-       } else
-               err = -ENOENT;
-
-       up_read(&hidp_session_sem);
-       return err;
-}
-
-int hidp_get_connlist(struct hidp_connlist_req *req)
-{
-       struct list_head *p;
-       int err = 0, n = 0;
-
-       BT_DBG("");
-
-       down_read(&hidp_session_sem);
-
-       list_for_each(p, &hidp_session_list) {
-               struct hidp_session *session;
-               struct hidp_conninfo ci;
-
-               session = list_entry(p, struct hidp_session, list);
-
-               __hidp_copy_session(session, &ci);
-
-               if (copy_to_user(req->ci, &ci, sizeof(ci))) {
-                       err = -EFAULT;
-                       break;
-               }
-
-               if (++n >= req->cnum)
-                       break;
-
-               req->ci++;
-       }
-       req->cnum = n;
-
-       up_read(&hidp_session_sem);
-       return err;
-}
-
-int hidp_get_conninfo(struct hidp_conninfo *ci)
-{
-       struct hidp_session *session;
-       int err = 0;
-
-       down_read(&hidp_session_sem);
-
-       session = __hidp_get_session(&ci->bdaddr);
-       if (session)
-               __hidp_copy_session(session, ci);
-       else
-               err = -ENOENT;
-
-       up_read(&hidp_session_sem);
-       return err;
-}
-
-static int __init hidp_init(void)
-{
-       l2cap_load();
-
-       BT_INFO("HIDP (Human Interface Emulation) ver %s", VERSION);
-
-       return hidp_init_sockets();
-}
-
-static void __exit hidp_exit(void)
-{
-       hidp_cleanup_sockets();
-}
-
-module_init(hidp_init);
-module_exit(hidp_exit);
-
-MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
-MODULE_DESCRIPTION("Bluetooth HIDP ver " VERSION);
-MODULE_VERSION(VERSION);
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bt-proto-6");
diff --git a/net/bluetooth/syms.c b/net/bluetooth/syms.c
deleted file mode 100644 (file)
index 20d8101..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* 
-   BlueZ - Bluetooth protocol stack for Linux
-   Copyright (C) 2000-2001 Qualcomm Incorporated
-
-   Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License version 2 as
-   published by the Free Software Foundation;
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
-   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
-   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
-   SOFTWARE IS DISCLAIMED.
-*/
-
-/*
- * Bluetooth symbols.
- *
- * $Id: syms.c,v 1.1 2002/03/08 21:06:59 maxk Exp $
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/skbuff.h>
-#include <linux/socket.h>
-
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/hci_core.h>
-
-/* HCI Core */
-EXPORT_SYMBOL(hci_alloc_dev);
-EXPORT_SYMBOL(hci_free_dev);
-EXPORT_SYMBOL(hci_register_dev);
-EXPORT_SYMBOL(hci_unregister_dev);
-EXPORT_SYMBOL(hci_suspend_dev);
-EXPORT_SYMBOL(hci_resume_dev);
-
-EXPORT_SYMBOL(hci_register_proto);
-EXPORT_SYMBOL(hci_unregister_proto);
-
-EXPORT_SYMBOL(hci_get_route);
-EXPORT_SYMBOL(hci_connect);
-EXPORT_SYMBOL(hci_dev_get);
-EXPORT_SYMBOL(hci_conn_auth);
-EXPORT_SYMBOL(hci_conn_encrypt);
-
-EXPORT_SYMBOL(hci_send_acl);
-EXPORT_SYMBOL(hci_send_sco);
-EXPORT_SYMBOL(hci_send_cmd);
-EXPORT_SYMBOL(hci_si_event);
-
-/* Bluetooth lib */
-EXPORT_SYMBOL(bt_dump);
-EXPORT_SYMBOL(baswap);
-EXPORT_SYMBOL(batostr);
-EXPORT_SYMBOL(bt_err);
-
-/* Bluetooth sockets */
-EXPORT_SYMBOL(bt_sock_register);
-EXPORT_SYMBOL(bt_sock_unregister);
-EXPORT_SYMBOL(bt_sock_alloc);
-EXPORT_SYMBOL(bt_sock_link);
-EXPORT_SYMBOL(bt_sock_unlink);
-EXPORT_SYMBOL(bt_sock_recvmsg);
-EXPORT_SYMBOL(bt_sock_poll);
-EXPORT_SYMBOL(bt_accept_enqueue);
-EXPORT_SYMBOL(bt_accept_dequeue);
-EXPORT_SYMBOL(bt_sock_wait_state);
-
-EXPORT_SYMBOL(proc_bt);
index 547469d..60af16c 100644 (file)
 #include <net/iw_handler.h>
 #endif /* CONFIG_NET_RADIO */
 #include <asm/current.h>
+#include <linux/vs_network.h>
 
 /* This define, if set, will randomly drop a packet when congestion
  * is more than moderate.  It helps fairness in the multi-interface
@@ -226,6 +227,8 @@ extern void netdev_unregister_sysfs(struct net_device *);
 #define        netdev_unregister_sysfs(dev)    do { } while(0)
 #endif
 
+/* netdump function */
+void (*netdump_func) (struct pt_regs *regs) = NULL;
 
 /*******************************************************************************
 
@@ -1558,7 +1561,7 @@ int netif_rx(struct sk_buff *skb)
        struct softnet_data *queue;
        unsigned long flags;
 
-#ifdef CONFIG_NETPOLL_RX
+#ifdef CONFIG_NETPOLL
        if (skb->dev->netpoll_rx && netpoll_rx(skb)) {
                kfree_skb(skb);
                return NET_RX_DROP;
@@ -1762,7 +1765,7 @@ int netif_receive_skb(struct sk_buff *skb)
        int ret = NET_RX_DROP;
        unsigned short type;
 
-#ifdef CONFIG_NETPOLL_RX
+#ifdef CONFIG_NETPOLL
        if (skb->dev->netpoll_rx && skb->dev->poll && netpoll_rx(skb)) {
                kfree_skb(skb);
                return NET_RX_DROP;
index 58632d1..e5e32b0 100644 (file)
@@ -204,6 +204,9 @@ void nf_dump_skb(int pf, struct sk_buff *skb)
 
                for (opti = 0; opti < (ip->ihl - sizeof(struct iphdr) / 4); opti++)
                        printk(" O=0x%8.8X", *opt++);
+               printk(" MARK=%lu (0x%lu)",
+                      (long unsigned int)skb->nfmark,
+                      (long unsigned int)skb->nfmark);
                printk("\n");
        }
        }
@@ -831,3 +834,6 @@ EXPORT_SYMBOL(nf_setsockopt);
 EXPORT_SYMBOL(nf_unregister_hook);
 EXPORT_SYMBOL(nf_unregister_queue_handler);
 EXPORT_SYMBOL(nf_unregister_sockopt);
+#ifdef CONFIG_NETFILTER_DEBUG
+EXPORT_SYMBOL(nf_dump_skb);
+#endif
index daac168..1ac9932 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/netpoll.h>
 #include <linux/sched.h>
+#include <linux/nmi.h>
 #include <net/tcp.h>
 #include <net/udp.h>
 
@@ -29,6 +30,9 @@
 #define MAX_SKBS 32
 #define MAX_UDP_CHUNK 1460
 
+#define NETPOLL_RX_ENABLED  1
+#define NETPOLL_RX_DROP     2
+
 static spinlock_t skb_list_lock = SPIN_LOCK_UNLOCKED;
 static int nr_skbs;
 static struct sk_buff *skbs;
@@ -38,6 +42,8 @@ static LIST_HEAD(rx_list);
 
 static int trapped;
 
+extern void (*netdump_func) (struct pt_regs *regs);
+
 #define MAX_SKB_SIZE \
                (MAX_UDP_CHUNK + sizeof(struct udphdr) + \
                                sizeof(struct iphdr) + sizeof(struct ethhdr))
@@ -61,7 +67,7 @@ static int checksum_udp(struct sk_buff *skb, struct udphdr *uh,
 
 void netpoll_poll(struct netpoll *np)
 {
-       int budget = 1;
+       int budget = netdump_mode ? 64 : 16;
 
        if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller)
                return;
@@ -70,9 +76,19 @@ void netpoll_poll(struct netpoll *np)
        np->dev->poll_controller(np->dev);
 
        /* If scheduling is stopped, tickle NAPI bits */
-       if(trapped && np->dev->poll &&
-          test_bit(__LINK_STATE_RX_SCHED, &np->dev->state))
-               np->dev->poll(np->dev, &budget);
+       if (np->dev->poll && 
+           test_bit(__LINK_STATE_RX_SCHED, &np->dev->state)) {
+               np->dev->netpoll_rx |= NETPOLL_RX_DROP;
+               if (trapped) {
+                       np->dev->poll(np->dev, &budget);
+               } else {
+                       trapped = 1;
+                       np->dev->poll(np->dev, &budget);
+                       trapped = 0;
+               }
+               np->dev->netpoll_rx &= ~NETPOLL_RX_DROP;
+       }
+
        zap_completion_queue();
 }
 
@@ -115,6 +131,7 @@ static void zap_completion_queue(void)
        }
 
        put_cpu_var(softnet_data);
+       touch_nmi_watchdog();
 }
 
 static struct sk_buff * find_skb(struct netpoll *np, int len, int reserve)
@@ -333,6 +350,9 @@ int netpoll_rx(struct sk_buff *skb)
        struct list_head *p;
        unsigned long flags;
 
+       if (!(skb->dev->netpoll_rx & NETPOLL_RX_ENABLED))
+               return 1;
+
        if (skb->dev->type != ARPHRD_ETHER)
                goto out;
 
@@ -591,15 +611,16 @@ int netpoll_setup(struct netpoll *np)
        if(np->rx_hook) {
                unsigned long flags;
 
-#ifdef CONFIG_NETPOLL_RX
-               np->dev->netpoll_rx = 1;
-#endif
+               np->dev->netpoll_rx = NETPOLL_RX_ENABLED;
 
                spin_lock_irqsave(&rx_list_lock, flags);
                list_add(&np->rx_list, &rx_list);
                spin_unlock_irqrestore(&rx_list_lock, flags);
        }
 
+       if(np->dump_func)
+               netdump_func = np->dump_func;
+
        return 0;
  release:
        dev_put(ndev);
@@ -613,9 +634,7 @@ void netpoll_cleanup(struct netpoll *np)
 
                spin_lock_irqsave(&rx_list_lock, flags);
                list_del(&np->rx_list);
-#ifdef CONFIG_NETPOLL_RX
                np->dev->netpoll_rx = 0;
-#endif
                spin_unlock_irqrestore(&rx_list_lock, flags);
        }
 
@@ -633,6 +652,13 @@ void netpoll_set_trap(int trap)
        trapped = trap;
 }
 
+void netpoll_reset_locks(struct netpoll *np)
+{
+       spin_lock_init(&rx_list_lock);
+       spin_lock_init(&skb_list_lock);
+       spin_lock_init(&np->dev->xmit_lock);
+}
+
 EXPORT_SYMBOL(netpoll_set_trap);
 EXPORT_SYMBOL(netpoll_trap);
 EXPORT_SYMBOL(netpoll_parse_options);
@@ -641,3 +667,4 @@ EXPORT_SYMBOL(netpoll_cleanup);
 EXPORT_SYMBOL(netpoll_send_skb);
 EXPORT_SYMBOL(netpoll_send_udp);
 EXPORT_SYMBOL(netpoll_poll);
+EXPORT_SYMBOL_GPL(netpoll_reset_locks);
index c34a3a9..b797886 100644 (file)
@@ -333,6 +333,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, int gfp_mask)
 #endif
 
 #endif
+       C(xid);
        C(truesize);
        atomic_set(&n->users, 1);
        C(head);
@@ -391,6 +392,7 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 #endif
        new->tc_index   = old->tc_index;
 #endif
+       new->xid        = old->xid;
        atomic_set(&new->users, 1);
 }
 
index 9146be7..2663979 100644 (file)
 #include <linux/ipsec.h>
 
 #include <linux/filter.h>
+#include <linux/vs_socket.h>
 
 #ifdef CONFIG_INET
 #include <net/tcp.h>
@@ -324,7 +325,22 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                        break;
 
                case SO_PASSCRED:
-                       sock->passcred = valbool;
+                       if (valbool)
+                               set_bit(SOCK_PASS_CRED, &sock->flags);
+                       else
+                               clear_bit(SOCK_PASS_CRED, &sock->flags);
+                       break;
+
+               case SO_SETXID:
+                       if (current->xid) {
+                               ret = -EPERM;
+                               break;
+                       }
+                       if (val < 0 || val > MAX_S_CONTEXT) {
+                               ret = -EINVAL;
+                               break;
+                       }
+                       sk->sk_xid = val;
                        break;
 
                case SO_TIMESTAMP:
@@ -548,7 +564,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                        break; 
 
                case SO_PASSCRED:
-                       v.val = sock->passcred;
+                       v.val = test_bit(SOCK_PASS_CRED, &sock->flags)?1:0;
                        break;
 
                case SO_PEERCRED:
@@ -623,6 +639,8 @@ struct sock *sk_alloc(int family, int priority, int zero_it, kmem_cache_t *slab)
                        sock_lock_init(sk);
                }
                sk->sk_slab = slab;
+               sock_vx_init(sk);
+               sock_nx_init(sk);
                
                if (security_sk_alloc(sk, family, priority)) {
                        kmem_cache_free(slab, sk);
@@ -653,6 +671,8 @@ void sk_free(struct sock *sk)
                       __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
 
        security_sk_free(sk);
+       BUG_ON(sk->sk_vx_info);
+       BUG_ON(sk->sk_nx_info);
        kmem_cache_free(sk->sk_slab, sk);
        module_put(owner);
 }
@@ -1195,6 +1215,11 @@ void sock_init_data(struct socket *sock, struct sock *sk)
        sk->sk_stamp.tv_sec     = -1L;
        sk->sk_stamp.tv_usec    = -1L;
 
+       sk->sk_vx_info          =       NULL;
+       sk->sk_xid              =       0;
+       sk->sk_nx_info          =       NULL;
+       sk->sk_nid              =       0;
+
        atomic_set(&sk->sk_refcnt, 1);
 }
 
index de00c66..31e5416 100644 (file)
@@ -359,5 +359,39 @@ config INET_IPCOMP
          
          If unsure, say Y.
 
+config ACCEPT_QUEUES 
+       bool "IP: TCP Multiple accept queues support"
+       depends on INET && NETFILTER
+       ---help---
+         Support multiple accept queues per listening socket. If you say Y
+         here, multiple accept queues will be configured per listening
+         socket.
+         
+         Each queue is mapped to a priority class. Incoming connection 
+         requests can be classified (see iptables(8), MARK target), depending
+         on the packet's src/dest address or other parameters, into one of 
+         the priority classes. The requests are then queued to the relevant
+         accept queue. 
+
+         Each of the queues can be assigned a weight. The accept()ance 
+         of packets is then scheduled in accordance with the weight 
+         assigned to the priority class. 
+         
+         Be sure to enable "Network packet filtering" if you wish
+         to use this feature.
+
+         If unsure, say N.
+
 source "net/ipv4/ipvs/Kconfig"
 
+#
+# Emulab special
+#
+
+config ICMP_IPOD
+       bool "ICMP: ICMP Ping-of-Death (Emulab)"
+       depends on INET && SYSCTL
+       ---help---
+          Support immediately rebooting upon receiving a specially
+         formed ICMP type 6 packet whose payload matches a string
+         configured by the administrator.
index ed29237..eb044e2 100644 (file)
 #ifdef CONFIG_IP_MROUTE
 #include <linux/mroute.h>
 #endif
+#include <linux/vs_limit.h>
 
 DEFINE_SNMP_STAT(struct linux_mib, net_statistics);
 
@@ -158,6 +159,13 @@ void inet_sock_destruct(struct sock *sk)
 
        if (inet->opt)
                kfree(inet->opt);
+       
+       vx_sock_dec(sk);
+       clr_vx_info(&sk->sk_vx_info);
+       sk->sk_xid = -1;
+       clr_nx_info(&sk->sk_nx_info);
+       sk->sk_nid = -1;
+
        dst_release(sk->sk_dst_cache);
 #ifdef INET_REFCNT_DEBUG
        atomic_dec(&inet_sock_nr);
@@ -294,8 +302,11 @@ static int inet_create(struct socket *sock, int protocol)
        if (!answer)
                goto out_sk_free;
        err = -EPERM;
+       if ((protocol == IPPROTO_ICMP) && vx_ccaps(VXC_RAW_ICMP))
+               goto override;
        if (answer->capability > 0 && !capable(answer->capability))
                goto out_sk_free;
+override:
        err = -EPROTONOSUPPORT;
        if (!protocol)
                goto out_sk_free;
@@ -330,6 +341,12 @@ static int inet_create(struct socket *sock, int protocol)
        sk->sk_family      = PF_INET;
        sk->sk_protocol    = protocol;
        sk->sk_backlog_rcv = sk->sk_prot->backlog_rcv;
+       
+       set_vx_info(&sk->sk_vx_info, current->vx_info);
+       sk->sk_xid = vx_current_xid();
+       vx_sock_inc(sk);
+       set_nx_info(&sk->sk_nx_info, current->nx_info);
+       sk->sk_nid = nx_current_nid();
 
        inet->uc_ttl    = -1;
        inet->mc_loop   = 1;
@@ -393,6 +410,11 @@ int inet_release(struct socket *sock)
                    !(current->flags & PF_EXITING))
                        timeout = sk->sk_lingertime;
                sock->sk = NULL;
+               vx_sock_dec(sk);
+               clr_vx_info(&sk->sk_vx_info);
+       sk->sk_xid = -1;
+               clr_nx_info(&sk->sk_nx_info);
+       sk->sk_nid = -1;
                sk->sk_prot->close(sk, timeout);
        }
        return 0;
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
deleted file mode 100644 (file)
index f84e104..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *     common UDP/RAW code
- *     Linux INET implementation
- *
- * Authors:
- *     Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
- *
- *     This program is free software; you can redistribute it and/or
- *     modify it under the terms of the GNU General Public License
- *     as published by the Free Software Foundation; either version
- *     2 of the License, or (at your option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/module.h>
-#include <linux/ip.h>
-#include <linux/in.h>
-#include <net/sock.h>
-#include <net/tcp.h>
-#include <net/route.h>
-
-int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
-{
-       struct inet_opt *inet = inet_sk(sk);
-       struct sockaddr_in *usin = (struct sockaddr_in *) uaddr;
-       struct rtable *rt;
-       u32 saddr;
-       int oif;
-       int err;
-
-       
-       if (addr_len < sizeof(*usin)) 
-               return -EINVAL;
-
-       if (usin->sin_family != AF_INET) 
-               return -EAFNOSUPPORT;
-
-       sk_dst_reset(sk);
-
-       oif = sk->sk_bound_dev_if;
-       saddr = inet->saddr;
-       if (MULTICAST(usin->sin_addr.s_addr)) {
-               if (!oif)
-                       oif = inet->mc_index;
-               if (!saddr)
-                       saddr = inet->mc_addr;
-       }
-       err = ip_route_connect(&rt, usin->sin_addr.s_addr, saddr,
-                              RT_CONN_FLAGS(sk), oif,
-                              sk->sk_protocol,
-                              inet->sport, usin->sin_port, sk);
-       if (err)
-               return err;
-       if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
-               ip_rt_put(rt);
-               return -EACCES;
-       }
-       if (!inet->saddr)
-               inet->saddr = rt->rt_src;       /* Update source address */
-       if (!inet->rcv_saddr)
-               inet->rcv_saddr = rt->rt_src;
-       inet->daddr = rt->rt_dst;
-       inet->dport = usin->sin_port;
-       sk->sk_state = TCP_ESTABLISHED;
-       inet->id = jiffies;
-
-       sk_dst_set(sk, &rt->u.dst);
-       return(0);
-}
-
-EXPORT_SYMBOL(ip4_datagram_connect);
-
index 6926132..e4a4a09 100644 (file)
@@ -910,6 +910,67 @@ static void icmp_address_reply(struct sk_buff *skb)
 out:;
 }
 
+#ifdef CONFIG_ICMP_IPOD
+#include <linux/reboot.h>
+
+int sysctl_icmp_ipod_version = 2;
+int sysctl_icmp_ipod_enabled = 0;
+u32 sysctl_icmp_ipod_host = 0xffffffff;
+u32 sysctl_icmp_ipod_mask = 0xffffffff;
+char sysctl_icmp_ipod_key[32+1] = { "SETMETOSOMETHINGTHIRTYTWOBYTES!!" };
+#define IPOD_CHECK_KEY \
+       (sysctl_icmp_ipod_key[0] != 0)
+#define IPOD_VALID_KEY(d) \
+       (strncmp(sysctl_icmp_ipod_key, (char *)(d), strlen(sysctl_icmp_ipod_key)) == 0)
+
+static void icmp_ping_of_death(struct sk_buff *skb)
+{
+       struct icmphdr *icmph = skb->h.icmph;
+       struct iphdr *iph = skb->nh.iph;
+       int doit = 0;
+
+#if 0
+       printk(KERN_INFO "IPOD: got type=6, code=%d, host=%u.%u.%u.%u\n", icmph->code, ntohs(iph->tot_len), NIPQUAD(iph->saddr));
+#endif
+
+       /*
+        * If IPOD not enabled or wrong ICMP code, ignore.
+        */
+       if (!sysctl_icmp_ipod_enabled || icmph->code != 6)
+               return;
+
+       /*
+        * First check the source address info.
+        * If host not set, ignore.
+        */
+       if (sysctl_icmp_ipod_host != 0xffffffff &&
+           (ntohl(iph->saddr) & sysctl_icmp_ipod_mask) == sysctl_icmp_ipod_host) {
+               /*
+                * Now check the key if enabled.
+                * If packet doesn't contain enough data or key
+                * is otherwise invalid, ignore.
+                */
+               if (IPOD_CHECK_KEY) {
+                       if (pskb_may_pull(skb, sizeof(sysctl_icmp_ipod_key)-1) &&
+                           IPOD_VALID_KEY(skb->data))
+                               doit = 1;
+               } else {
+                       doit = 1;
+               }
+       }
+
+       if (doit) {
+               sysctl_icmp_ipod_enabled = 0;
+               printk(KERN_CRIT "IPOD: reboot forced by %u.%u.%u.%u...\n",
+                      NIPQUAD(iph->saddr));
+               machine_restart(NULL);
+       } else {
+               printk(KERN_WARNING "IPOD: from %u.%u.%u.%u rejected\n",
+                      NIPQUAD(iph->saddr));
+       }
+}
+#endif
+
 static void icmp_discard(struct sk_buff *skb)
 {
 }
@@ -1024,12 +1085,21 @@ static struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = {
                .handler = icmp_redirect,
                .error = 1,
        },
+#ifdef CONFIG_ICMP_IPOD
+       [6] = {
+               .output_entry = ICMP_MIB_DUMMY,
+               .input_entry = ICMP_MIB_DUMMY,
+               .handler = icmp_ping_of_death,
+               .error = 1,
+       },
+#else
        [6] = {
                .output_entry = ICMP_MIB_DUMMY,
                .input_entry = ICMP_MIB_INERRORS,
                .handler = icmp_discard,
                .error = 1,
        },
+#endif
        [7] = {
                .output_entry = ICMP_MIB_DUMMY,
                .input_entry = ICMP_MIB_INERRORS,
index 00a89f4..05fbb43 100644 (file)
@@ -670,8 +670,10 @@ init_conntrack(const struct ip_conntrack_tuple *tuple,
        conntrack->ct_general.destroy = destroy_conntrack;
        conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *tuple;
        conntrack->tuplehash[IP_CT_DIR_ORIGINAL].ctrack = conntrack;
+       conntrack->xid[IP_CT_DIR_ORIGINAL] = -1;
        conntrack->tuplehash[IP_CT_DIR_REPLY].tuple = repl_tuple;
        conntrack->tuplehash[IP_CT_DIR_REPLY].ctrack = conntrack;
+       conntrack->xid[IP_CT_DIR_REPLY] = -1;
        for (i=0; i < IP_CT_NUMBER; i++)
                conntrack->infos[i].master = &conntrack->ct_general;
 
index 80edac9..fd688f4 100644 (file)
@@ -102,11 +102,13 @@ print_conntrack(char *buffer, struct ip_conntrack *conntrack)
        len += print_tuple(buffer + len,
                           &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
                           proto);
+       len += sprintf(buffer + len, "xid=%d ", conntrack->xid[IP_CT_DIR_ORIGINAL]);
        if (!(test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)))
                len += sprintf(buffer + len, "[UNREPLIED] ");
        len += print_tuple(buffer + len,
                           &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
                           proto);
+       len += sprintf(buffer + len, "xid=%d ", conntrack->xid[IP_CT_DIR_REPLY]);
        if (test_bit(IPS_ASSURED_BIT, &conntrack->status))
                len += sprintf(buffer + len, "[ASSURED] ");
        len += sprintf(buffer + len, "use=%u ",
index 06bcb8d..0931c14 100644 (file)
@@ -50,10 +50,12 @@ checkentry(const char *tablename,
                return 0;
        }
 
+#if 0
        if (strcmp(tablename, "mangle") != 0) {
                printk(KERN_WARNING "MARK: can only be called from \"mangle\" table, not \"%s\"\n", tablename);
                return 0;
        }
+#endif
 
        return 1;
 }
index 1cfd749..1f7364a 100644 (file)
@@ -79,6 +79,7 @@
 #include <linux/seq_file.h>
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
+#include <linux/vs_base.h>
 
 struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
 rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED;
@@ -689,7 +690,8 @@ static struct sock *raw_get_first(struct seq_file *seq)
                struct hlist_node *node;
 
                sk_for_each(sk, node, &raw_v4_htable[state->bucket])
-                       if (sk->sk_family == PF_INET)
+                       if (sk->sk_family == PF_INET &&
+                               vx_check(sk->sk_xid, VX_WATCH|VX_IDENT))
                                goto found;
        }
        sk = NULL;
@@ -705,7 +707,8 @@ static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
                sk = sk_next(sk);
 try_again:
                ;
-       } while (sk && sk->sk_family != PF_INET);
+       } while (sk && (sk->sk_family != PF_INET ||
+               !vx_check(sk->sk_xid, VX_WATCH|VX_IDENT)));
 
        if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
                sk = sk_head(&raw_v4_htable[state->bucket]);
index 55cc269..90bb78a 100644 (file)
@@ -23,6 +23,13 @@ extern int sysctl_ip_nonlocal_bind;
 extern int sysctl_icmp_echo_ignore_all;
 extern int sysctl_icmp_echo_ignore_broadcasts;
 extern int sysctl_icmp_ignore_bogus_error_responses;
+#ifdef CONFIG_ICMP_IPOD
+extern int sysctl_icmp_ipod_version;
+extern int sysctl_icmp_ipod_enabled;
+extern u32 sysctl_icmp_ipod_host;
+extern u32 sysctl_icmp_ipod_mask;
+extern char sysctl_icmp_ipod_key[32+1];
+#endif
 
 /* From ip_fragment.c */
 extern int sysctl_ipfrag_low_thresh;
@@ -395,6 +402,49 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
+#ifdef CONFIG_ICMP_IPOD
+       {
+               .ctl_name       = NET_IPV4_ICMP_IPOD_VERSION,
+               .procname       = "icmp_ipod_version",
+               .data           = &sysctl_icmp_ipod_version,
+               .maxlen         = sizeof(sysctl_icmp_ipod_version),
+               .mode           = 0444,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_IPOD_ENABLED,
+               .procname       = "icmp_ipod_enabled",
+               .data           = &sysctl_icmp_ipod_enabled,
+               .maxlen         = sizeof(sysctl_icmp_ipod_enabled),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_IPOD_HOST,
+               .procname       = "icmp_ipod_host",
+               .data           = &sysctl_icmp_ipod_host,
+               .maxlen         = sizeof(sysctl_icmp_ipod_host),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_IPOD_MASK,
+               .procname       = "icmp_ipod_mask",
+               .data           = &sysctl_icmp_ipod_mask,
+               .maxlen         = sizeof(sysctl_icmp_ipod_mask),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_IPOD_KEY,
+               .procname       = "icmp_ipod_key",
+               .data           = &sysctl_icmp_ipod_key,
+               .maxlen         = sizeof(sysctl_icmp_ipod_key),
+               .mode           = 0600,
+               .proc_handler   = &proc_dostring,
+               .strategy       = &sysctl_string
+       },
+#endif
        {
                .ctl_name       = NET_IPV4_ROUTE,
                .procname       = "route",
index 90d8553..c99f5ce 100644 (file)
 #include <linux/fs.h>
 #include <linux/random.h>
 
+#ifdef CONFIG_CKRM
+#include <linux/ckrm.h>
+#endif
+
 #include <net/icmp.h>
 #include <net/tcp.h>
 #include <net/xfrm.h>
@@ -462,13 +466,20 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
 
 int tcp_listen_start(struct sock *sk)
 {
+#ifdef CONFIG_ACCEPT_QUEUES
+       int i = 0;
+#endif
        struct inet_opt *inet = inet_sk(sk);
        struct tcp_opt *tp = tcp_sk(sk);
        struct tcp_listen_opt *lopt;
 
        sk->sk_max_ack_backlog = 0;
        sk->sk_ack_backlog = 0;
+#ifdef CONFIG_ACCEPT_QUEUES
+       tp->accept_queue = NULL;
+#else
        tp->accept_queue = tp->accept_queue_tail = NULL;
+#endif 
        tp->syn_wait_lock = RW_LOCK_UNLOCKED;
        tcp_delack_init(tp);
 
@@ -482,6 +493,23 @@ int tcp_listen_start(struct sock *sk)
                        break;
        get_random_bytes(&lopt->hash_rnd, 4);
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       tp->class_index = 0;
+       for (i=0; i < NUM_ACCEPT_QUEUES; i++) {
+               tp->acceptq[i].aq_tail = NULL;
+               tp->acceptq[i].aq_head = NULL;
+               tp->acceptq[i].aq_wait_time = 0; 
+               tp->acceptq[i].aq_qcount = 0; 
+               tp->acceptq[i].aq_count = 0; 
+               if (i == 0) {
+                       tp->acceptq[i].aq_ratio = 1; 
+               }
+               else {
+                       tp->acceptq[i].aq_ratio = 0; 
+               }
+       }
+#endif
+
        write_lock_bh(&tp->syn_wait_lock);
        tp->listen_opt = lopt;
        write_unlock_bh(&tp->syn_wait_lock);
@@ -498,6 +526,10 @@ int tcp_listen_start(struct sock *sk)
                sk_dst_reset(sk);
                sk->sk_prot->hash(sk);
 
+#ifdef CONFIG_CKRM
+               ckrm_cb_listen_start(sk);
+#endif
+
                return 0;
        }
 
@@ -528,7 +560,18 @@ static void tcp_listen_stop (struct sock *sk)
        write_lock_bh(&tp->syn_wait_lock);
        tp->listen_opt = NULL;
        write_unlock_bh(&tp->syn_wait_lock);
-       tp->accept_queue = tp->accept_queue_tail = NULL;
+
+#ifdef CONFIG_CKRM
+               ckrm_cb_listen_stop(sk);
+#endif
+
+#ifdef CONFIG_ACCEPT_QUEUES
+       for (i = 0; i < NUM_ACCEPT_QUEUES; i++)
+               tp->acceptq[i].aq_head = tp->acceptq[i].aq_tail = NULL;
+#else
+       tp->accept_queue_tail = NULL;
+#endif
+       tp->accept_queue = NULL;
 
        if (lopt->qlen) {
                for (i = 0; i < TCP_SYNQ_HSIZE; i++) {
@@ -574,7 +617,11 @@ static void tcp_listen_stop (struct sock *sk)
                local_bh_enable();
                sock_put(child);
 
+#ifdef CONFIG_ACCEPT_QUEUES
+               sk_acceptq_removed(sk, req->acceptq_class);
+#else
                sk_acceptq_removed(sk);
+#endif
                tcp_openreq_fastfree(req);
        }
        BUG_TRAP(!sk->sk_ack_backlog);
@@ -1050,7 +1097,7 @@ static int tcp_recv_urg(struct sock *sk, long timeo,
  * calculation of whether or not we must ACK for the sake of
  * a window update.
  */
-static void cleanup_rbuf(struct sock *sk, int copied)
+void cleanup_rbuf(struct sock *sk, int copied)
 {
        struct tcp_opt *tp = tcp_sk(sk);
        int time_to_ack = 0;
@@ -1895,6 +1942,10 @@ struct sock *tcp_accept(struct sock *sk, int flags, int *err)
        struct open_request *req;
        struct sock *newsk;
        int error;
+#ifdef CONFIG_ACCEPT_QUEUES    
+       int prev_class = 0;
+       int first;
+#endif
 
        lock_sock(sk);
 
@@ -1908,7 +1959,6 @@ struct sock *tcp_accept(struct sock *sk, int flags, int *err)
        /* Find already established connection */
        if (!tp->accept_queue) {
                long timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
-
                /* If this is a non blocking socket don't sleep */
                error = -EAGAIN;
                if (!timeo)
@@ -1919,12 +1969,46 @@ struct sock *tcp_accept(struct sock *sk, int flags, int *err)
                        goto out;
        }
 
+#ifndef CONFIG_ACCEPT_QUEUES
        req = tp->accept_queue;
        if ((tp->accept_queue = req->dl_next) == NULL)
                tp->accept_queue_tail = NULL;
+       newsk = req->sk;
+       sk_acceptq_removed(sk);
+#else
+       first = tp->class_index;
+       /* We should always have  request queued here. The accept_queue
+        * is already checked for NULL above.
+        */
+       while(!tp->acceptq[first].aq_head) {
+               tp->acceptq[first].aq_cnt = 0;
+               first = (first+1) & ~NUM_ACCEPT_QUEUES; 
+       }
+        req = tp->acceptq[first].aq_head;
+       tp->acceptq[first].aq_qcount--;
+       tp->acceptq[first].aq_count++;
+       tp->acceptq[first].aq_wait_time+=(jiffies - req->acceptq_time_stamp);
 
+       for (prev_class= first-1 ; prev_class >=0; prev_class--)
+               if (tp->acceptq[prev_class].aq_tail)
+                       break;
+       if (prev_class>=0)
+               tp->acceptq[prev_class].aq_tail->dl_next = req->dl_next; 
+       else 
+               tp->accept_queue = req->dl_next;
+
+       if (req == tp->acceptq[first].aq_tail) 
+               tp->acceptq[first].aq_head = tp->acceptq[first].aq_tail = NULL;
+       else
+               tp->acceptq[first].aq_head = req->dl_next;
+
+       if((++(tp->acceptq[first].aq_cnt)) >= tp->acceptq[first].aq_ratio){
+               tp->acceptq[first].aq_cnt = 0;
+               tp->class_index = ++first & (NUM_ACCEPT_QUEUES-1);
+       }       
        newsk = req->sk;
-       sk_acceptq_removed(sk);
+       sk_acceptq_removed(sk, req->acceptq_class);
+#endif
        tcp_openreq_fastfree(req);
        BUG_TRAP(newsk->sk_state != TCP_SYN_RECV);
        release_sock(sk);
@@ -1936,6 +2020,7 @@ out:
        return NULL;
 }
 
+
 /*
  *     Socket option code for TCP.
  */
@@ -2094,7 +2179,54 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
                        }
                }
                break;
+               
+#ifdef CONFIG_ACCEPT_QUEUES
+       case TCP_ACCEPTQ_SHARE:
+#ifdef CONFIG_CKRM
+               // If CKRM is set then the shares are set through rcfs.
+               // Get shares will still succeed.
+               err = -EOPNOTSUPP;
+               break;
+#else          
+               {
+                       char share_wt[NUM_ACCEPT_QUEUES];
+                       int i,j;
 
+                       if (sk->sk_state != TCP_LISTEN)
+                               return -EOPNOTSUPP;
+
+                       if (copy_from_user(share_wt,optval, optlen)) {
+                               err = -EFAULT;
+                               break;
+                       }
+                       j = 0;
+                       for (i = 0; i < NUM_ACCEPT_QUEUES; i++) {
+                               if (share_wt[i]) {
+                                       if (!j)
+                                               j = share_wt[i];
+                                       else if (share_wt[i] < j) {
+                                               j = share_wt[i];
+                                       }
+                               }
+                               else
+                                       tp->acceptq[i].aq_ratio = 0;
+                                       
+                       }
+                       if (j == 0) {
+                               /* Class 0 is always valid. If nothing is 
+                                * specified set class 0 as 1.
+                                */
+                               share_wt[0] = 1;
+                               j = 1;
+                       }
+                       for (i=0; i < NUM_ACCEPT_QUEUES; i++)  {
+                               tp->acceptq[i].aq_ratio = share_wt[i]/j;
+                               tp->acceptq[i].aq_cnt = 0;
+                       }
+               }
+               break;
+#endif
+#endif
        default:
                err = -ENOPROTOOPT;
                break;
@@ -2175,6 +2307,40 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
        case TCP_QUICKACK:
                val = !tp->ack.pingpong;
                break;
+
+#ifdef CONFIG_ACCEPT_QUEUES
+       case TCP_ACCEPTQ_SHARE: 
+       {
+               struct tcp_acceptq_info tinfo[NUM_ACCEPT_QUEUES];
+               int i;
+
+               if (sk->sk_state != TCP_LISTEN)
+                       return -EOPNOTSUPP;
+
+               if (get_user(len, optlen))
+                       return -EFAULT;
+
+               memset(tinfo, 0, sizeof(tinfo));
+
+               for(i=0; i < NUM_ACCEPT_QUEUES; i++) {
+                       tinfo[i].acceptq_wait_time = 
+                            jiffies_to_msecs(tp->acceptq[i].aq_wait_time);
+                       tinfo[i].acceptq_qcount = tp->acceptq[i].aq_qcount;
+                       tinfo[i].acceptq_count = tp->acceptq[i].aq_count;
+                       tinfo[i].acceptq_shares=tp->acceptq[i].aq_ratio;
+               }
+
+               len = min_t(unsigned int, len, sizeof(tinfo));
+               if (put_user(len, optlen)) 
+                       return -EFAULT;
+                       
+               if (copy_to_user(optval, (char *)tinfo, len))
+                       return -EFAULT;
+               
+               return 0;
+       }
+       break;
+#endif
        default:
                return -ENOPROTOOPT;
        };
@@ -2330,3 +2496,4 @@ EXPORT_SYMBOL(tcp_setsockopt);
 EXPORT_SYMBOL(tcp_shutdown);
 EXPORT_SYMBOL(tcp_statistics);
 EXPORT_SYMBOL(tcp_timewait_cachep);
+EXPORT_SYMBOL_GPL(cleanup_rbuf);
index 2cfd74f..70945b4 100644 (file)
@@ -74,6 +74,7 @@
 #include <linux/stddef.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/vserver/debug.h>
 
 extern int sysctl_ip_dynaddr;
 int sysctl_tcp_tw_reuse;
@@ -458,7 +459,6 @@ inline struct sock *tcp_v4_lookup_listener(u32 daddr, unsigned short hnum,
        head = &tcp_listening_hash[tcp_lhashfn(hnum)];
        if (!hlist_empty(head)) {
                struct inet_opt *inet = inet_sk((sk = __sk_head(head)));
-
                if (inet->num == hnum && !sk->sk_node.next &&
                    (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
                    (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
@@ -916,7 +916,11 @@ static void tcp_v4_synq_add(struct sock *sk, struct open_request *req)
        lopt->syn_table[h] = req;
        write_unlock(&tp->syn_wait_lock);
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       tcp_synq_added(sk, req);
+#else
        tcp_synq_added(sk);
+#endif
 }
 
 
@@ -1413,6 +1417,9 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
        __u32 daddr = skb->nh.iph->daddr;
        __u32 isn = TCP_SKB_CB(skb)->when;
        struct dst_entry *dst = NULL;
+#ifdef CONFIG_ACCEPT_QUEUES
+       int class = 0;
+#endif
 #ifdef CONFIG_SYN_COOKIES
        int want_cookie = 0;
 #else
@@ -1437,12 +1444,31 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
                goto drop;
        }
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       class = (skb->nfmark <= 0) ? 0 :
+               ((skb->nfmark >= NUM_ACCEPT_QUEUES) ? 0: skb->nfmark);
+       /*
+        * Accept only if the class has shares set or if the default class
+        * i.e. class 0 has shares
+        */
+       if (!(tcp_sk(sk)->acceptq[class].aq_ratio)) {
+               if (tcp_sk(sk)->acceptq[0].aq_ratio) 
+                       class = 0;
+               else
+                       goto drop;
+       }
+#endif
+
        /* Accept backlog is full. If we have already queued enough
         * of warm entries in syn queue, drop request. It is better than
         * clogging syn queue with openreqs with exponentially increasing
         * timeout.
         */
+#ifdef CONFIG_ACCEPT_QUEUES
+       if (sk_acceptq_is_full(sk, class) && tcp_synq_young(sk, class) > 1)
+#else
        if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1)
+#endif
                goto drop;
 
        req = tcp_openreq_alloc();
@@ -1472,7 +1498,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
        tp.tstamp_ok = tp.saw_tstamp;
 
        tcp_openreq_init(req, &tp, skb);
-
+#ifdef CONFIG_ACCEPT_QUEUES
+       req->acceptq_class = class;
+       req->acceptq_time_stamp = jiffies;
+#endif
        req->af.v4_req.loc_addr = daddr;
        req->af.v4_req.rmt_addr = saddr;
        req->af.v4_req.opt = tcp_v4_save_options(sk, skb);
@@ -1567,7 +1596,11 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
        struct tcp_opt *newtp;
        struct sock *newsk;
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       if (sk_acceptq_is_full(sk, req->acceptq_class))
+#else
        if (sk_acceptq_is_full(sk))
+#endif
                goto exit_overflow;
 
        if (!dst && (dst = tcp_v4_route_req(sk, req)) == NULL)
@@ -1729,6 +1762,10 @@ csum_err:
        goto discard;
 }
 
+extern struct proto_ops inet_stream_ops;
+
+extern int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
+
 /*
  *     From tcp_input.c
  */
@@ -1780,6 +1817,14 @@ int tcp_v4_rcv(struct sk_buff *skb)
                goto no_tcp_socket;
 
 process:
+       /* Silently drop if VNET is active (if INET bind() has been
+        * overridden) and the context is not entitled to read the
+        * packet.
+        */
+       if (inet_stream_ops.bind != inet_bind &&
+           (int) sk->sk_xid > 0 && sk->sk_xid != skb->xid)
+               goto discard_it;
+
        if (sk->sk_state == TCP_TIME_WAIT)
                goto do_time_wait;
 
@@ -2165,6 +2210,11 @@ static void *listening_get_next(struct seq_file *seq, void *cur)
                req = req->dl_next;
                while (1) {
                        while (req) {
+                               vxdprintk(VXD_CBIT(net, 6),
+                                       "sk,req: %p [#%d] (from %d)",
+                                       req->sk, req->sk->sk_xid, current->xid);
+                               if (!vx_check(req->sk->sk_xid, VX_IDENT|VX_WATCH))
+                                       continue;
                                if (req->class->family == st->family) {
                                        cur = req;
                                        goto out;
@@ -2183,6 +2233,10 @@ get_req:
                sk = sk_next(sk);
 get_sk:
        sk_for_each_from(sk, node) {
+               vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
+                       sk, sk->sk_xid, current->xid);
+               if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+                       continue;
                if (sk->sk_family == st->family) {
                        cur = sk;
                        goto out;
@@ -2230,18 +2284,26 @@ static void *established_get_first(struct seq_file *seq)
               
                read_lock(&tcp_ehash[st->bucket].lock);
                sk_for_each(sk, node, &tcp_ehash[st->bucket].chain) {
-                       if (sk->sk_family != st->family) {
+                       vxdprintk(VXD_CBIT(net, 6),
+                               "sk,egf: %p [#%d] (from %d)",
+                               sk, sk->sk_xid, current->xid);
+                       if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+                               continue;
+                       if (sk->sk_family != st->family)
                                continue;
-                       }
                        rc = sk;
                        goto out;
                }
                st->state = TCP_SEQ_STATE_TIME_WAIT;
                tw_for_each(tw, node,
                            &tcp_ehash[st->bucket + tcp_ehash_size].chain) {
-                       if (tw->tw_family != st->family) {
+                       vxdprintk(VXD_CBIT(net, 6),
+                               "tw: %p [#%d] (from %d)",
+                               tw, tw->tw_xid, current->xid);
+                       if (!vx_check(tw->tw_xid, VX_IDENT|VX_WATCH))
+                               continue;
+                       if (tw->tw_family != st->family)
                                continue;
-                       }
                        rc = tw;
                        goto out;
                }
@@ -2265,7 +2327,8 @@ static void *established_get_next(struct seq_file *seq, void *cur)
                tw = cur;
                tw = tw_next(tw);
 get_tw:
-               while (tw && tw->tw_family != st->family) {
+               while (tw && (tw->tw_family != st->family ||
+                       !vx_check(tw->tw_xid, VX_IDENT|VX_WATCH))) {
                        tw = tw_next(tw);
                }
                if (tw) {
@@ -2285,6 +2348,11 @@ get_tw:
                sk = sk_next(sk);
 
        sk_for_each_from(sk, node) {
+               vxdprintk(VXD_CBIT(net, 6),
+                       "sk,egn: %p [#%d] (from %d)",
+                       sk, sk->sk_xid, current->xid);
+               if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+                       continue;
                if (sk->sk_family == st->family)
                        goto found;
        }
index 79c1884..51ac81b 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/module.h>
 #include <linux/sysctl.h>
 #include <linux/workqueue.h>
+#include <linux/vs_limit.h>
+#include <linux/vs_socket.h>
 #include <net/tcp.h>
 #include <net/inet_common.h>
 #include <net/xfrm.h>
@@ -362,6 +364,11 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
                tw->tw_ts_recent_stamp  = tp->ts_recent_stamp;
                tw_dead_node_init(tw);
 
+               tw->tw_xid              = sk->sk_xid;
+               tw->tw_vx_info          = NULL;
+               tw->tw_nid              = sk->sk_nid;
+               tw->tw_nx_info          = NULL;
+               
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
                if (tw->tw_family == PF_INET6) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
@@ -697,6 +704,8 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
                newsk->sk_state = TCP_SYN_RECV;
 
                /* SANITY */
+               sock_vx_init(newsk);
+               sock_nx_init(newsk);
                sk_node_init(&newsk->sk_node);
                tcp_sk(newsk)->bind_hash = NULL;
 
@@ -726,6 +735,9 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
                if ((filter = newsk->sk_filter) != NULL)
                        sk_filter_charge(newsk, filter);
 
+               if (sk->sk_create_child)
+                       sk->sk_create_child(sk, newsk);
+
                if (unlikely(xfrm_sk_clone_policy(newsk))) {
                        /* It is still raw copy of parent, so invalidate
                         * destructor and make plain sk_free() */
@@ -787,7 +799,14 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
                newtp->num_sacks = 0;
                newtp->urg_data = 0;
                newtp->listen_opt = NULL;
+#ifdef CONFIG_ACCEPT_QUEUES
+               newtp->accept_queue = NULL;
+               memset(newtp->acceptq, 0,sizeof(newtp->acceptq));
+               newtp->class_index = 0;
+
+#else
                newtp->accept_queue = newtp->accept_queue_tail = NULL;
+#endif
                /* Deinitialize syn_wait_lock to trap illegal accesses. */
                memset(&newtp->syn_wait_lock, 0, sizeof(newtp->syn_wait_lock));
 
@@ -795,6 +814,12 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
                newsk->sk_err = 0;
                newsk->sk_priority = 0;
                atomic_set(&newsk->sk_refcnt, 2);
+
+               set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
+               newsk->sk_xid = sk->sk_xid;
+               vx_sock_inc(newsk);
+               set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
+               newsk->sk_nid = sk->sk_nid;
 #ifdef INET_REFCNT_DEBUG
                atomic_inc(&inet_sock_nr);
 #endif
index 72a5a50..a57d2d2 100644 (file)
@@ -489,7 +489,16 @@ static void tcp_synack_timer(struct sock *sk)
         * ones are about to clog our table.
         */
        if (lopt->qlen>>(lopt->max_qlen_log-1)) {
+#ifdef CONFIG_ACCEPT_QUEUES
+               int young = 0;
+              
+               for(i=0; i < NUM_ACCEPT_QUEUES; i++) 
+                       young += lopt->qlen_young[i];
+               
+               young <<= 1;
+#else
                int young = (lopt->qlen_young<<1);
+#endif
 
                while (thresh > 2) {
                        if (lopt->qlen < young)
@@ -515,9 +524,12 @@ static void tcp_synack_timer(struct sock *sk)
                                        unsigned long timeo;
 
                                        if (req->retrans++ == 0)
-                                               lopt->qlen_young--;
-                                       timeo = min((TCP_TIMEOUT_INIT << req->retrans),
-                                                   TCP_RTO_MAX);
+#ifdef CONFIG_ACCEPT_QUEUES
+                                               lopt->qlen_young[req->acceptq_class]--;
+#else
+                                               lopt->qlen_young--;
+#endif
+                                       timeo = min((TCP_TIMEOUT_INIT << req->retrans), TCP_RTO_MAX);
                                        req->expires = now + timeo;
                                        reqp = &req->dl_next;
                                        continue;
@@ -529,7 +541,11 @@ static void tcp_synack_timer(struct sock *sk)
                                write_unlock(&tp->syn_wait_lock);
                                lopt->qlen--;
                                if (req->retrans == 0)
-                                       lopt->qlen_young--;
+#ifdef CONFIG_ACCEPT_QUEUES
+                                               lopt->qlen_young[req->acceptq_class]--;
+#else
+                                               lopt->qlen_young--;
+#endif
                                tcp_openreq_free(req);
                                continue;
                        }
index 944830a..23f8f51 100644 (file)
@@ -1332,8 +1332,10 @@ static struct sock *udp_get_first(struct seq_file *seq)
 
        for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
                struct hlist_node *node;
+
                sk_for_each(sk, node, &udp_hash[state->bucket]) {
-                       if (sk->sk_family == state->family)
+                       if (sk->sk_family == state->family &&
+                               vx_check(sk->sk_xid, VX_WATCH|VX_IDENT))
                                goto found;
                }
        }
@@ -1350,7 +1352,8 @@ static struct sock *udp_get_next(struct seq_file *seq, struct sock *sk)
                sk = sk_next(sk);
 try_again:
                ;
-       } while (sk && sk->sk_family != state->family);
+       } while (sk && (sk->sk_family != state->family ||
+               !vx_check(sk->sk_xid, VX_WATCH|VX_IDENT)));
 
        if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
                sk = sk_head(&udp_hash[state->bucket]);
diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
deleted file mode 100644 (file)
index 191cec7..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * xfrm4_output.c - Common IPsec encapsulation code for IPv4.
- * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <linux/skbuff.h>
-#include <linux/spinlock.h>
-#include <net/inet_ecn.h>
-#include <net/ip.h>
-#include <net/xfrm.h>
-#include <net/icmp.h>
-
-/* Add encapsulation header.
- *
- * In transport mode, the IP header will be moved forward to make space
- * for the encapsulation header.
- *
- * In tunnel mode, the top IP header will be constructed per RFC 2401.
- * The following fields in it shall be filled in by x->type->output:
- *     tot_len
- *     check
- *
- * On exit, skb->h will be set to the start of the payload to be processed
- * by x->type->output and skb->nh will be set to the top IP header.
- */
-static void xfrm4_encap(struct sk_buff *skb)
-{
-       struct dst_entry *dst = skb->dst;
-       struct xfrm_state *x = dst->xfrm;
-       struct iphdr *iph, *top_iph;
-
-       iph = skb->nh.iph;
-       skb->h.ipiph = iph;
-
-       skb->nh.raw = skb_push(skb, x->props.header_len);
-       top_iph = skb->nh.iph;
-
-       if (!x->props.mode) {
-               skb->h.raw += iph->ihl*4;
-               memmove(top_iph, iph, iph->ihl*4);
-               return;
-       }
-
-       top_iph->ihl = 5;
-       top_iph->version = 4;
-
-       /* DS disclosed */
-       top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos);
-       if (x->props.flags & XFRM_STATE_NOECN)
-               IP_ECN_clear(top_iph);
-
-       top_iph->frag_off = iph->frag_off & htons(IP_DF);
-       if (!top_iph->frag_off)
-               __ip_select_ident(top_iph, dst, 0);
-
-       /* TTL disclosed */
-       top_iph->ttl = iph->ttl;
-
-       top_iph->saddr = x->props.saddr.a4;
-       top_iph->daddr = x->id.daddr.a4;
-       top_iph->protocol = IPPROTO_IPIP;
-
-       memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
-}
-
-static int xfrm4_tunnel_check_size(struct sk_buff *skb)
-{
-       int mtu, ret = 0;
-       struct dst_entry *dst;
-       struct iphdr *iph = skb->nh.iph;
-
-       if (IPCB(skb)->flags & IPSKB_XFRM_TUNNEL_SIZE)
-               goto out;
-
-       IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE;
-       
-       if (!(iph->frag_off & htons(IP_DF)))
-               goto out;
-
-       dst = skb->dst;
-       mtu = dst_pmtu(dst) - dst->header_len - dst->trailer_len;
-       if (skb->len > mtu) {
-               icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
-               ret = -EMSGSIZE;
-       }
-out:
-       return ret;
-}
-
-int xfrm4_output(struct sk_buff **pskb)
-{
-       struct sk_buff *skb = *pskb;
-       struct dst_entry *dst = skb->dst;
-       struct xfrm_state *x = dst->xfrm;
-       int err;
-       
-       if (skb->ip_summed == CHECKSUM_HW) {
-               err = skb_checksum_help(pskb, 0);
-               skb = *pskb;
-               if (err)
-                       goto error_nolock;
-       }
-
-       spin_lock_bh(&x->lock);
-       err = xfrm_state_check(x, skb);
-       if (err)
-               goto error;
-
-       if (x->props.mode) {
-               err = xfrm4_tunnel_check_size(skb);
-               if (err)
-                       goto error;
-       }
-
-       xfrm4_encap(skb);
-
-       err = x->type->output(pskb);
-       skb = *pskb;
-       if (err)
-               goto error;
-
-       x->curlft.bytes += skb->len;
-       x->curlft.packets++;
-
-       spin_unlock_bh(&x->lock);
-       
-       if (!(skb->dst = dst_pop(dst))) {
-               err = -EHOSTUNREACH;
-               goto error_nolock;
-       }
-       err = NET_XMIT_BYPASS;
-
-out_exit:
-       return err;
-error:
-       spin_unlock_bh(&x->lock);
-error_nolock:
-       kfree_skb(skb);
-       goto out_exit;
-}
index 5a19b3d..0d9554c 100644 (file)
@@ -1156,7 +1156,11 @@ static void tcp_v6_synq_add(struct sock *sk, struct open_request *req)
        lopt->syn_table[h] = req;
        write_unlock(&tp->syn_wait_lock);
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       tcp_synq_added(sk, req);
+#else
        tcp_synq_added(sk);
+#endif
 }
 
 
@@ -1169,6 +1173,9 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        struct tcp_opt tmptp, *tp = tcp_sk(sk);
        struct open_request *req = NULL;
        __u32 isn = TCP_SKB_CB(skb)->when;
+#ifdef CONFIG_ACCEPT_QUEUES
+       int class = 0;
+#endif
 
        if (skb->protocol == htons(ETH_P_IP))
                return tcp_v4_conn_request(sk, skb);
@@ -1176,6 +1183,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        if (!ipv6_unicast_destination(skb))
                goto drop; 
 
+
        /*
         *      There are no SYN attacks on IPv6, yet...        
         */
@@ -1185,9 +1193,27 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
                goto drop;              
        }
 
+#ifdef CONFIG_ACCEPT_QUEUES
+        class = (skb->nfmark <= 0) ? 0 :
+                       ((skb->nfmark >= NUM_ACCEPT_QUEUES) ? 0: skb->nfmark);
+        /*
+        * Accept only if the class has shares set or if the default class
+        * i.e. class 0 has shares
+        */
+        if (!(tcp_sk(sk)->acceptq[class].aq_ratio)) {
+               if (tcp_sk(sk)->acceptq[0].aq_ratio) 
+                       class = 0; 
+               else 
+                       goto drop;
+       }
+
+       if (sk_acceptq_is_full(sk, class) && tcp_synq_young(sk, class) > 1)
+#else
        if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1)
+#endif
                goto drop;
 
+
        req = tcp_openreq_alloc();
        if (req == NULL)
                goto drop;
@@ -1200,7 +1226,10 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
 
        tmptp.tstamp_ok = tmptp.saw_tstamp;
        tcp_openreq_init(req, &tmptp, skb);
-
+#ifdef CONFIG_ACCEPT_QUEUES
+       req->acceptq_class = class;
+       req->acceptq_time_stamp = jiffies;
+#endif
        req->class = &or_ipv6;
        ipv6_addr_copy(&req->af.v6_req.rmt_addr, &skb->nh.ipv6h->saddr);
        ipv6_addr_copy(&req->af.v6_req.loc_addr, &skb->nh.ipv6h->daddr);
@@ -1302,7 +1331,11 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
 
        opt = np->opt;
 
+#ifdef CONFIG_ACCEPT_QUEUES
+       if (sk_acceptq_is_full(sk, req->acceptq_class))
+#else
        if (sk_acceptq_is_full(sk))
+#endif
                goto out_overflow;
 
        if (np->rxopt.bits.srcrt == 2 &&
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
deleted file mode 100644 (file)
index 712856f..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * xfrm6_output.c - Common IPsec encapsulation code for IPv6.
- * Copyright (C) 2002 USAGI/WIDE Project
- * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <linux/skbuff.h>
-#include <linux/spinlock.h>
-#include <linux/icmpv6.h>
-#include <net/inet_ecn.h>
-#include <net/ipv6.h>
-#include <net/xfrm.h>
-
-/* Add encapsulation header.
- *
- * In transport mode, the IP header and mutable extension headers will be moved
- * forward to make space for the encapsulation header.
- *
- * In tunnel mode, the top IP header will be constructed per RFC 2401.
- * The following fields in it shall be filled in by x->type->output:
- *     payload_len
- *
- * On exit, skb->h will be set to the start of the encapsulation header to be
- * filled in by x->type->output and skb->nh will be set to the nextheader field
- * of the extension header directly preceding the encapsulation header, or in
- * its absence, that of the top IP header.  The value of skb->data will always
- * point to the top IP header.
- */
-static void xfrm6_encap(struct sk_buff *skb)
-{
-       struct dst_entry *dst = skb->dst;
-       struct xfrm_state *x = dst->xfrm;
-       struct ipv6hdr *iph, *top_iph;
-
-       skb_push(skb, x->props.header_len);
-       iph = skb->nh.ipv6h;
-
-       if (!x->props.mode) {
-               u8 *prevhdr;
-               int hdr_len;
-
-               hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
-               skb->nh.raw = prevhdr - x->props.header_len;
-               skb->h.raw = skb->data + hdr_len;
-               memmove(skb->data, iph, hdr_len);
-               return;
-       }
-
-       skb->nh.raw = skb->data;
-       top_iph = skb->nh.ipv6h;
-       skb->nh.raw = &top_iph->nexthdr;
-       skb->h.ipv6h = top_iph + 1;
-
-       top_iph->version = 6;
-       top_iph->priority = iph->priority;
-       if (x->props.flags & XFRM_STATE_NOECN)
-               IP6_ECN_clear(top_iph);
-       top_iph->flow_lbl[0] = iph->flow_lbl[0];
-       top_iph->flow_lbl[1] = iph->flow_lbl[1];
-       top_iph->flow_lbl[2] = iph->flow_lbl[2];
-       top_iph->nexthdr = IPPROTO_IPV6; 
-       top_iph->hop_limit = iph->hop_limit;
-       ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);
-       ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr);
-}
-
-static int xfrm6_tunnel_check_size(struct sk_buff *skb)
-{
-       int mtu, ret = 0;
-       struct dst_entry *dst = skb->dst;
-
-       mtu = dst_pmtu(dst) - sizeof(struct ipv6hdr);
-       if (mtu < IPV6_MIN_MTU)
-               mtu = IPV6_MIN_MTU;
-
-       if (skb->len > mtu) {
-               icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev);
-               ret = -EMSGSIZE;
-       }
-
-       return ret;
-}
-
-int xfrm6_output(struct sk_buff **pskb)
-{
-       struct sk_buff *skb = *pskb;
-       struct dst_entry *dst = skb->dst;
-       struct xfrm_state *x = dst->xfrm;
-       int err;
-       
-       if (skb->ip_summed == CHECKSUM_HW) {
-               err = skb_checksum_help(pskb, 0);
-               skb = *pskb;
-               if (err)
-                       goto error_nolock;
-       }
-
-       spin_lock_bh(&x->lock);
-       err = xfrm_state_check(x, skb);
-       if (err)
-               goto error;
-
-       if (x->props.mode) {
-               err = xfrm6_tunnel_check_size(skb);
-               if (err)
-                       goto error;
-       }
-
-       xfrm6_encap(skb);
-
-       err = x->type->output(pskb);
-       skb = *pskb;
-       if (err)
-               goto error;
-
-       x->curlft.bytes += skb->len;
-       x->curlft.packets++;
-
-       spin_unlock_bh(&x->lock);
-
-       skb->nh.raw = skb->data;
-       
-       if (!(skb->dst = dst_pop(dst))) {
-               err = -EHOSTUNREACH;
-               goto error_nolock;
-       }
-       err = NET_XMIT_BYPASS;
-
-out_exit:
-       return err;
-error:
-       spin_unlock_bh(&x->lock);
-error_nolock:
-       kfree_skb(skb);
-       goto out_exit;
-}
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
deleted file mode 100644 (file)
index 5766a13..0000000
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Copyright (C)2003,2004 USAGI/WIDE Project
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Authors     Mitsuru KANDA  <mk@linux-ipv6.org>
- *             YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
- *
- * Based on net/ipv4/xfrm4_tunnel.c
- *
- */
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/xfrm.h>
-#include <linux/list.h>
-#include <net/ip.h>
-#include <net/xfrm.h>
-#include <net/ipv6.h>
-#include <net/protocol.h>
-#include <linux/ipv6.h>
-#include <linux/icmpv6.h>
-
-#ifdef CONFIG_IPV6_XFRM6_TUNNEL_DEBUG
-# define X6TDEBUG      3
-#else
-# define X6TDEBUG      1
-#endif
-
-#define X6TPRINTK(fmt, args...)                printk(fmt, ## args)
-#define X6TNOPRINTK(fmt, args...)      do { ; } while(0)
-
-#if X6TDEBUG >= 1
-# define X6TPRINTK1    X6TPRINTK
-#else
-# define X6TPRINTK1    X6TNOPRINTK
-#endif
-
-#if X6TDEBUG >= 3
-# define X6TPRINTK3    X6TPRINTK
-#else
-# define X6TPRINTK3    X6TNOPRINTK
-#endif
-
-/*
- * xfrm_tunnel_spi things are for allocating unique id ("spi") 
- * per xfrm_address_t.
- */
-struct xfrm6_tunnel_spi {
-       struct hlist_node list_byaddr;
-       struct hlist_node list_byspi;
-       xfrm_address_t addr;
-       u32 spi;
-       atomic_t refcnt;
-#ifdef XFRM6_TUNNEL_SPI_MAGIC
-       u32 magic;
-#endif
-};
-
-#ifdef CONFIG_IPV6_XFRM6_TUNNEL_DEBUG
-# define XFRM6_TUNNEL_SPI_MAGIC 0xdeadbeef
-#endif
-
-static rwlock_t xfrm6_tunnel_spi_lock = RW_LOCK_UNLOCKED;
-
-static u32 xfrm6_tunnel_spi;
-
-#define XFRM6_TUNNEL_SPI_MIN   1
-#define XFRM6_TUNNEL_SPI_MAX   0xffffffff
-
-static kmem_cache_t *xfrm6_tunnel_spi_kmem;
-
-#define XFRM6_TUNNEL_SPI_BYADDR_HSIZE 256
-#define XFRM6_TUNNEL_SPI_BYSPI_HSIZE 256
-
-static struct hlist_head xfrm6_tunnel_spi_byaddr[XFRM6_TUNNEL_SPI_BYADDR_HSIZE];
-static struct hlist_head xfrm6_tunnel_spi_byspi[XFRM6_TUNNEL_SPI_BYSPI_HSIZE];
-
-#ifdef XFRM6_TUNNEL_SPI_MAGIC
-static int x6spi_check_magic(const struct xfrm6_tunnel_spi *x6spi,
-                            const char *name)
-{
-       if (unlikely(x6spi->magic != XFRM6_TUNNEL_SPI_MAGIC)) {
-               X6TPRINTK3(KERN_DEBUG "%s(): x6spi object "
-                                     "at %p has corrupted magic %08x "
-                                     "(should be %08x)\n",
-                          name, x6spi, x6spi->magic, XFRM6_TUNNEL_SPI_MAGIC);
-               return -1;
-       }
-       return 0;
-}
-#else
-static int inline x6spi_check_magic(const struct xfrm6_tunnel_spi *x6spi,
-                                   const char *name)
-{
-       return 0;
-}
-#endif
-
-#define X6SPI_CHECK_MAGIC(x6spi) x6spi_check_magic((x6spi), __FUNCTION__)
-
-
-static unsigned inline xfrm6_tunnel_spi_hash_byaddr(xfrm_address_t *addr)
-{
-       unsigned h;
-
-       X6TPRINTK3(KERN_DEBUG "%s(addr=%p)\n", __FUNCTION__, addr);
-
-       h = addr->a6[0] ^ addr->a6[1] ^ addr->a6[2] ^ addr->a6[3];
-       h ^= h >> 16;
-       h ^= h >> 8;
-       h &= XFRM6_TUNNEL_SPI_BYADDR_HSIZE - 1;
-
-       X6TPRINTK3(KERN_DEBUG "%s() = %u\n", __FUNCTION__, h);
-
-       return h;
-}
-
-static unsigned inline xfrm6_tunnel_spi_hash_byspi(u32 spi)
-{
-       return spi % XFRM6_TUNNEL_SPI_BYSPI_HSIZE;
-}
-
-
-static int xfrm6_tunnel_spi_init(void)
-{
-       int i;
-
-       X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__);
-
-       xfrm6_tunnel_spi = 0;
-       xfrm6_tunnel_spi_kmem = kmem_cache_create("xfrm6_tunnel_spi",
-                                                 sizeof(struct xfrm6_tunnel_spi),
-                                                 0, SLAB_HWCACHE_ALIGN,
-                                                 NULL, NULL);
-       if (!xfrm6_tunnel_spi_kmem) {
-               X6TPRINTK1(KERN_ERR
-                          "%s(): failed to allocate xfrm6_tunnel_spi_kmem\n",
-                          __FUNCTION__);
-               return -ENOMEM;
-       }
-
-       for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++)
-               INIT_HLIST_HEAD(&xfrm6_tunnel_spi_byaddr[i]);
-       for (i = 0; i < XFRM6_TUNNEL_SPI_BYSPI_HSIZE; i++)
-               INIT_HLIST_HEAD(&xfrm6_tunnel_spi_byspi[i]);
-       return 0;
-}
-
-static void xfrm6_tunnel_spi_fini(void)
-{
-       int i;
-
-       X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__);
-
-       for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++) {
-               if (!hlist_empty(&xfrm6_tunnel_spi_byaddr[i]))
-                       goto err;
-       }
-       for (i = 0; i < XFRM6_TUNNEL_SPI_BYSPI_HSIZE; i++) {
-               if (!hlist_empty(&xfrm6_tunnel_spi_byspi[i]))
-                       goto err;
-       }
-       kmem_cache_destroy(xfrm6_tunnel_spi_kmem);
-       xfrm6_tunnel_spi_kmem = NULL;
-       return;
-err:
-       X6TPRINTK1(KERN_ERR "%s(): table is not empty\n", __FUNCTION__);
-       return;
-}
-
-static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr)
-{
-       struct xfrm6_tunnel_spi *x6spi;
-       struct hlist_node *pos;
-
-       X6TPRINTK3(KERN_DEBUG "%s(saddr=%p)\n", __FUNCTION__, saddr);
-
-       hlist_for_each_entry(x6spi, pos,
-                            &xfrm6_tunnel_spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)],
-                            list_byaddr) {
-               if (memcmp(&x6spi->addr, saddr, sizeof(x6spi->addr)) == 0) {
-                       X6SPI_CHECK_MAGIC(x6spi);
-                       X6TPRINTK3(KERN_DEBUG "%s() = %p(%u)\n", __FUNCTION__, x6spi, x6spi->spi);
-                       return x6spi;
-               }
-       }
-
-       X6TPRINTK3(KERN_DEBUG "%s() = NULL(0)\n", __FUNCTION__);
-       return NULL;
-}
-
-u32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr)
-{
-       struct xfrm6_tunnel_spi *x6spi;
-       u32 spi;
-
-       X6TPRINTK3(KERN_DEBUG "%s(saddr=%p)\n", __FUNCTION__, saddr);
-
-       read_lock_bh(&xfrm6_tunnel_spi_lock);
-       x6spi = __xfrm6_tunnel_spi_lookup(saddr);
-       spi = x6spi ? x6spi->spi : 0;
-       read_unlock_bh(&xfrm6_tunnel_spi_lock);
-       return spi;
-}
-
-EXPORT_SYMBOL(xfrm6_tunnel_spi_lookup);
-
-static u32 __xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr)
-{
-       u32 spi;
-       struct xfrm6_tunnel_spi *x6spi;
-       struct hlist_node *pos;
-       unsigned index;
-
-       X6TPRINTK3(KERN_DEBUG "%s(saddr=%p)\n", __FUNCTION__, saddr);
-
-       if (xfrm6_tunnel_spi < XFRM6_TUNNEL_SPI_MIN ||
-           xfrm6_tunnel_spi >= XFRM6_TUNNEL_SPI_MAX)
-               xfrm6_tunnel_spi = XFRM6_TUNNEL_SPI_MIN;
-       else
-               xfrm6_tunnel_spi++;
-
-       for (spi = xfrm6_tunnel_spi; spi <= XFRM6_TUNNEL_SPI_MAX; spi++) {
-               index = xfrm6_tunnel_spi_hash_byspi(spi);
-               hlist_for_each_entry(x6spi, pos, 
-                                    &xfrm6_tunnel_spi_byspi[index], 
-                                    list_byspi) {
-                       if (x6spi->spi == spi)
-                               goto try_next_1;
-               }
-               xfrm6_tunnel_spi = spi;
-               goto alloc_spi;
-try_next_1:;
-       }
-       for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tunnel_spi; spi++) {
-               index = xfrm6_tunnel_spi_hash_byspi(spi);
-               hlist_for_each_entry(x6spi, pos, 
-                                    &xfrm6_tunnel_spi_byspi[index], 
-                                    list_byspi) {
-                       if (x6spi->spi == spi)
-                               goto try_next_2;
-               }
-               xfrm6_tunnel_spi = spi;
-               goto alloc_spi;
-try_next_2:;
-       }
-       spi = 0;
-       goto out;
-alloc_spi:
-       X6TPRINTK3(KERN_DEBUG "%s(): allocate new spi for "
-                             "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", 
-                             __FUNCTION__, 
-                             NIP6(*(struct in6_addr *)saddr));
-       x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, SLAB_ATOMIC);
-       if (!x6spi) {
-               X6TPRINTK1(KERN_ERR "%s(): kmem_cache_alloc() failed\n", 
-                          __FUNCTION__);
-               goto out;
-       }
-#ifdef XFRM6_TUNNEL_SPI_MAGIC
-       x6spi->magic = XFRM6_TUNNEL_SPI_MAGIC;
-#endif
-       memcpy(&x6spi->addr, saddr, sizeof(x6spi->addr));
-       x6spi->spi = spi;
-       atomic_set(&x6spi->refcnt, 1);
-
-       hlist_add_head(&x6spi->list_byspi, &xfrm6_tunnel_spi_byspi[index]);
-
-       index = xfrm6_tunnel_spi_hash_byaddr(saddr);
-       hlist_add_head(&x6spi->list_byaddr, &xfrm6_tunnel_spi_byaddr[index]);
-       X6SPI_CHECK_MAGIC(x6spi);
-out:
-       X6TPRINTK3(KERN_DEBUG "%s() = %u\n", __FUNCTION__, spi);
-       return spi;
-}
-
-u32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr)
-{
-       struct xfrm6_tunnel_spi *x6spi;
-       u32 spi;
-
-       X6TPRINTK3(KERN_DEBUG "%s(saddr=%p)\n", __FUNCTION__, saddr);
-
-       write_lock_bh(&xfrm6_tunnel_spi_lock);
-       x6spi = __xfrm6_tunnel_spi_lookup(saddr);
-       if (x6spi) {
-               atomic_inc(&x6spi->refcnt);
-               spi = x6spi->spi;
-       } else
-               spi = __xfrm6_tunnel_alloc_spi(saddr);
-       write_unlock_bh(&xfrm6_tunnel_spi_lock);
-
-       X6TPRINTK3(KERN_DEBUG "%s() = %u\n", __FUNCTION__, spi);
-
-       return spi;
-}
-
-EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi);
-
-void xfrm6_tunnel_free_spi(xfrm_address_t *saddr)
-{
-       struct xfrm6_tunnel_spi *x6spi;
-       struct hlist_node *pos, *n;
-
-       X6TPRINTK3(KERN_DEBUG "%s(saddr=%p)\n", __FUNCTION__, saddr);
-
-       write_lock_bh(&xfrm6_tunnel_spi_lock);
-
-       hlist_for_each_entry_safe(x6spi, pos, n, 
-                                 &xfrm6_tunnel_spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)],
-                                 list_byaddr)
-       {
-               if (memcmp(&x6spi->addr, saddr, sizeof(x6spi->addr)) == 0) {
-                       X6TPRINTK3(KERN_DEBUG "%s(): x6spi object "
-                                             "for %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x "
-                                             "found at %p\n",
-                                  __FUNCTION__, 
-                                  NIP6(*(struct in6_addr *)saddr),
-                                  x6spi);
-                       X6SPI_CHECK_MAGIC(x6spi);
-                       if (atomic_dec_and_test(&x6spi->refcnt)) {
-                               hlist_del(&x6spi->list_byaddr);
-                               hlist_del(&x6spi->list_byspi);
-                               kmem_cache_free(xfrm6_tunnel_spi_kmem, x6spi);
-                               break;
-                       }
-               }
-       }
-       write_unlock_bh(&xfrm6_tunnel_spi_lock);
-}
-
-EXPORT_SYMBOL(xfrm6_tunnel_free_spi);
-
-static int xfrm6_tunnel_output(struct sk_buff **pskb)
-{
-       struct sk_buff *skb = *pskb;
-       struct ipv6hdr *top_iph;
-
-       top_iph = (struct ipv6hdr *)skb->data;
-       top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
-
-       return 0;
-}
-
-static int xfrm6_tunnel_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_buff *skb)
-{
-       if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) 
-               return -EINVAL;
-
-       skb->mac.raw = skb->nh.raw;
-       skb->nh.raw = skb->data;
-       dst_release(skb->dst);
-       skb->dst = NULL;
-       skb->protocol = htons(ETH_P_IPV6);
-       skb->pkt_type = PACKET_HOST;
-       netif_rx(skb);
-
-       return 0;
-}
-
-static struct xfrm6_tunnel *xfrm6_tunnel_handler;
-static DECLARE_MUTEX(xfrm6_tunnel_sem);
-
-int xfrm6_tunnel_register(struct xfrm6_tunnel *handler)
-{
-       int ret;
-
-       down(&xfrm6_tunnel_sem);
-       ret = 0;
-       if (xfrm6_tunnel_handler != NULL)
-               ret = -EINVAL;
-       if (!ret)
-               xfrm6_tunnel_handler = handler;
-       up(&xfrm6_tunnel_sem);
-
-       return ret;
-}
-
-EXPORT_SYMBOL(xfrm6_tunnel_register);
-
-int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler)
-{
-       int ret;
-
-       down(&xfrm6_tunnel_sem);
-       ret = 0;
-       if (xfrm6_tunnel_handler != handler)
-               ret = -EINVAL;
-       if (!ret)
-               xfrm6_tunnel_handler = NULL;
-       up(&xfrm6_tunnel_sem);
-
-       synchronize_net();
-
-       return ret;
-}
-
-EXPORT_SYMBOL(xfrm6_tunnel_deregister);
-
-static int xfrm6_tunnel_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
-{
-       struct sk_buff *skb = *pskb;
-       struct xfrm6_tunnel *handler = xfrm6_tunnel_handler;
-       struct xfrm_state *x = NULL;
-       struct ipv6hdr *iph = skb->nh.ipv6h;
-       int err = 0;
-       u32 spi;
-
-       /* device-like_ip6ip6_handler() */
-       if (handler) {
-               err = handler->handler(pskb, nhoffp);
-               if (!err)
-                       goto out;
-       }
-
-       spi = xfrm6_tunnel_spi_lookup((xfrm_address_t *)&iph->saddr);
-       x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, 
-                       spi,
-                       IPPROTO_IPV6, AF_INET6);
-
-       if (!x)
-               goto drop;
-
-       spin_lock(&x->lock);
-
-       if (unlikely(x->km.state != XFRM_STATE_VALID))
-               goto drop_unlock;
-
-       err = xfrm6_tunnel_input(x, NULL, skb);
-       if (err)
-               goto drop_unlock;
-
-       x->curlft.bytes += skb->len;
-       x->curlft.packets++; 
-       spin_unlock(&x->lock); 
-       xfrm_state_put(x); 
-
-out:
-       return 0;
-
-drop_unlock:
-       spin_unlock(&x->lock);
-       xfrm_state_put(x);
-drop:
-       kfree_skb(skb);
-       return -1;
-}
-
-static void xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
-                            int type, int code, int offset, __u32 info)
-{
-       struct xfrm6_tunnel *handler = xfrm6_tunnel_handler;
-
-       /* call here first for device-like ip6ip6 err handling */
-       if (handler) {
-               handler->err_handler(skb, opt, type, code, offset, info);
-               return;
-       }
-
-       /* xfrm6_tunnel native err handling */
-       switch (type) {
-       case ICMPV6_DEST_UNREACH: 
-               switch (code) {
-               case ICMPV6_NOROUTE: 
-               case ICMPV6_ADM_PROHIBITED:
-               case ICMPV6_NOT_NEIGHBOUR:
-               case ICMPV6_ADDR_UNREACH:
-               case ICMPV6_PORT_UNREACH:
-               default:
-                       X6TPRINTK3(KERN_DEBUG
-                                  "xfrm6_tunnel: Destination Unreach.\n");
-                       break;
-               }
-               break;
-       case ICMPV6_PKT_TOOBIG:
-                       X6TPRINTK3(KERN_DEBUG 
-                                  "xfrm6_tunnel: Packet Too Big.\n");
-               break;
-       case ICMPV6_TIME_EXCEED:
-               switch (code) {
-               case ICMPV6_EXC_HOPLIMIT:
-                       X6TPRINTK3(KERN_DEBUG
-                                  "xfrm6_tunnel: Too small Hoplimit.\n");
-                       break;
-               case ICMPV6_EXC_FRAGTIME:
-               default: 
-                       break;
-               }
-               break;
-       case ICMPV6_PARAMPROB:
-               switch (code) {
-               case ICMPV6_HDR_FIELD: break;
-               case ICMPV6_UNK_NEXTHDR: break;
-               case ICMPV6_UNK_OPTION: break;
-               }
-               break;
-       default:
-               break;
-       }
-       return;
-}
-
-static int xfrm6_tunnel_init_state(struct xfrm_state *x, void *args)
-{
-       if (!x->props.mode)
-               return -EINVAL;
-
-       x->props.header_len = sizeof(struct ipv6hdr);
-
-       return 0;
-}
-
-static void xfrm6_tunnel_destroy(struct xfrm_state *x)
-{
-       xfrm6_tunnel_free_spi((xfrm_address_t *)&x->props.saddr);
-}
-
-static struct xfrm_type xfrm6_tunnel_type = {
-       .description    = "IP6IP6",
-       .owner          = THIS_MODULE,
-       .proto          = IPPROTO_IPV6,
-       .init_state     = xfrm6_tunnel_init_state,
-       .destructor     = xfrm6_tunnel_destroy,
-       .input          = xfrm6_tunnel_input,
-       .output         = xfrm6_tunnel_output,
-};
-
-static struct inet6_protocol xfrm6_tunnel_protocol = {
-       .handler        = xfrm6_tunnel_rcv,
-       .err_handler    = xfrm6_tunnel_err, 
-       .flags          = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
-};
-
-void __init xfrm6_tunnel_init(void)
-{
-       X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__);
-
-       if (xfrm_register_type(&xfrm6_tunnel_type, AF_INET6) < 0) {
-               X6TPRINTK1(KERN_ERR
-                          "xfrm6_tunnel init: can't add xfrm type\n");
-               return;
-       }
-       if (inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6) < 0) {
-               X6TPRINTK1(KERN_ERR
-                          "xfrm6_tunnel init(): can't add protocol\n");
-               xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
-               return;
-       }
-       if (xfrm6_tunnel_spi_init() < 0) {
-               X6TPRINTK1(KERN_ERR
-                          "xfrm6_tunnel init: failed to initialize spi\n");
-               inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
-               xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
-               return;
-       }
-}
-
-void __exit xfrm6_tunnel_fini(void)
-{
-       X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__);
-
-       xfrm6_tunnel_spi_fini();
-       if (inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6) < 0)
-               X6TPRINTK1(KERN_ERR 
-                          "xfrm6_tunnel close: can't remove protocol\n");
-       if (xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6) < 0)
-               X6TPRINTK1(KERN_ERR
-                          "xfrm6_tunnel close: can't remove xfrm type\n");
-}
diff --git a/net/irda/crc.c b/net/irda/crc.c
deleted file mode 100644 (file)
index b79b59a..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*********************************************************************
- *                
- * Filename:      crc.c
- * Version:       0.1
- * Description:   CRC calculation routines
- * Status:        Experimental.
- * Author:        Dag Brattli <dagb@cs.uit.no>
- * Created at:    Mon Aug  4 20:40:53 1997
- * Modified at:   Sun May  2 20:28:08 1999
- * Modified by:   Dag Brattli <dagb@cs.uit.no>
- * Sources:       ppp.c by Michael Callahan <callahan@maths.ox.ac.uk>
- *                Al Longyear <longyear@netcom.com>
- *
- ********************************************************************/
-
-#include <net/irda/crc.h>
-#include <linux/module.h>
-
-/*
- * This mysterious table is just the CRC of each possible byte.  It can be
- * computed using the standard bit-at-a-time methods.  The polynomial can
- * be seen in entry 128, 0x8408.  This corresponds to x^0 + x^5 + x^12.
- * Add the implicit x^16, and you have the standard CRC-CCITT.
- */
-__u16 const irda_crc16_table[256] =
-{
-       0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-       0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-       0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-       0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-       0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-       0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-       0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-       0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-       0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-       0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-       0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-       0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-       0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-       0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-       0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-       0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-       0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-       0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-       0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-       0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-       0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-       0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-       0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-       0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-       0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-       0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-       0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-       0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-       0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-       0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-       0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-       0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-EXPORT_SYMBOL(irda_crc16_table);
-
-__u16 irda_calc_crc16( __u16 fcs, __u8 const *buf, size_t len) 
-{
-       while (len--)
-                fcs = irda_fcs(fcs, *buf++);
-       return fcs;
-}
-EXPORT_SYMBOL(irda_calc_crc16);
index 93ac3b3..844a087 100644 (file)
@@ -217,6 +217,8 @@ void packet_sock_destruct(struct sock *sk)
 {
        BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc));
        BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc));
+       BUG_ON(sk->sk_nx_info);
+       BUG_ON(sk->sk_vx_info);
 
        if (!sock_flag(sk, SOCK_DEAD)) {
                printk("Attempt to release alive packet socket: %p\n", sk);
@@ -449,6 +451,9 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,  struct packe
        sk = pt->af_packet_priv;
        po = pkt_sk(sk);
 
+       if ((int) sk->sk_xid > 0 && sk->sk_xid != skb->xid)
+               goto drop;
+
        skb->dev = dev;
 
        if (dev->hard_header) {
@@ -819,6 +824,9 @@ static int packet_release(struct socket *sock)
        }
 #endif
 
+       clr_vx_info(&sk->sk_vx_info);
+       clr_nx_info(&sk->sk_nx_info);
+
        /*
         *      Now the socket is dead. No more input will appear.
         */
@@ -994,6 +1002,11 @@ static int packet_create(struct socket *sock, int protocol)
        sk->sk_destruct = packet_sock_destruct;
        atomic_inc(&packet_socks_nr);
 
+       set_vx_info(&sk->sk_vx_info, current->vx_info);
+       sk->sk_xid = vx_current_xid();
+       set_nx_info(&sk->sk_nx_info, current->nx_info);
+       sk->sk_nid = nx_current_nid();
+
        /*
         *      Attach a protocol block
         */
@@ -1779,12 +1792,14 @@ struct proto_ops packet_ops = {
        .mmap =         packet_mmap,
        .sendpage =     sock_no_sendpage,
 };
+EXPORT_SYMBOL(packet_ops);
 
-static struct net_proto_family packet_family_ops = {
+struct net_proto_family packet_family_ops = {
        .family =       PF_PACKET,
        .create =       packet_create,
        .owner  =       THIS_MODULE,
 };
+EXPORT_SYMBOL(packet_family_ops);
 
 static struct notifier_block packet_netdev_notifier = {
        .notifier_call =packet_notifier,
index 1f9bf9d..19ff1b9 100644 (file)
@@ -389,7 +389,8 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
 {
        int err;
        struct rtattr *kind = tca[TCA_KIND-1];
-       struct Qdisc *sch = NULL;
+       void *p = NULL;
+       struct Qdisc *sch;
        struct Qdisc_ops *ops;
        int size;
 
@@ -407,12 +408,18 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
        if (ops == NULL)
                goto err_out;
 
-       size = sizeof(*sch) + ops->priv_size;
+       /* ensure that the Qdisc and the private data are 32-byte aligned */
+       size = ((sizeof(*sch) + QDISC_ALIGN_CONST) & ~QDISC_ALIGN_CONST);
+       size += ops->priv_size + QDISC_ALIGN_CONST;
 
-       sch = kmalloc(size, GFP_KERNEL);
+       p = kmalloc(size, GFP_KERNEL);
        err = -ENOBUFS;
-       if (!sch)
+       if (!p)
                goto err_out;
+       memset(p, 0, size);
+       sch = (struct Qdisc *)(((unsigned long)p + QDISC_ALIGN_CONST)
+                              & ~QDISC_ALIGN_CONST);
+       sch->padded = (char *)sch - (char *)p;
 
        /* Grrr... Resolve race condition with module unload */
 
@@ -420,8 +427,6 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
        if (ops != qdisc_lookup_ops(kind))
                goto err_out;
 
-       memset(sch, 0, size);
-
        INIT_LIST_HEAD(&sch->list);
        skb_queue_head_init(&sch->q);
 
@@ -470,8 +475,8 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
 
 err_out:
        *errp = err;
-       if (sch)
-               kfree(sch);
+       if (p)
+               kfree(p);
        return NULL;
 }
 
diff --git a/net/sched/sch_csz.c b/net/sched/sch_csz.c
deleted file mode 100644 (file)
index 3d9a553..0000000
+++ /dev/null
@@ -1,1057 +0,0 @@
-/*
- * net/sched/sch_csz.c Clark-Shenker-Zhang scheduler.
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- *
- * Authors:    Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/jiffies.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/socket.h>
-#include <linux/sockios.h>
-#include <linux/in.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/if_ether.h>
-#include <linux/inet.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/notifier.h>
-#include <net/ip.h>
-#include <net/route.h>
-#include <linux/skbuff.h>
-#include <net/sock.h>
-#include <net/pkt_sched.h>
-
-
-/*     Clark-Shenker-Zhang algorithm.
-       =======================================
-
-       SOURCE.
-
-       David D. Clark, Scott Shenker and Lixia Zhang
-       "Supporting Real-Time Applications in an Integrated Services Packet
-       Network: Architecture and Mechanism".
-
-       CBQ presents a flexible universal algorithm for packet scheduling,
-       but it has pretty poor delay characteristics.
-       Round-robin scheduling and link-sharing goals
-       apparently contradict minimization of network delay and jitter.
-       Moreover, correct handling of predictive flows seems to be
-       impossible in CBQ.
-
-       CSZ presents a more precise but less flexible and less efficient
-       approach. As I understand it, the main idea is to create
-       WFQ flows for each guaranteed service and to allocate
-       the rest of bandwidth to dummy flow-0. Flow-0 comprises
-       the predictive services and the best effort traffic;
-       it is handled by a priority scheduler with the highest
-       priority band allocated for predictive services, and the rest ---
-       to the best effort packets.
-
-       Note that in CSZ flows are NOT limited to their bandwidth.  It
-       is supposed that the flow passed admission control at the edge
-       of the QoS network and it doesn't need further shaping. Any
-       attempt to improve the flow or to shape it to a token bucket
-       at intermediate hops will introduce undesired delays and raise
-       jitter.
-
-       At the moment CSZ is the only scheduler that provides
-       true guaranteed service. Another schemes (including CBQ)
-       do not provide guaranteed delay and randomize jitter.
-       There is a proof (Sally Floyd), that delay
-       can be estimated by a IntServ compliant formula.
-       This result is true formally, but it is wrong in principle.
-       It takes into account only round-robin delays,
-       ignoring delays introduced by link sharing i.e. overlimiting.
-       Note that temporary overlimits are inevitable because
-       real links are not ideal, and the real algorithm must take this
-       into account.
-
-        ALGORITHM.
-
-       --- Notations.
-
-       $B$ is link bandwidth (bits/sec).
-
-       $I$ is set of all flows, including flow $0$.
-       Every flow $a \in I$ has associated bandwidth slice $r_a < 1$ and
-       $\sum_{a \in I} r_a = 1$.
-
-       --- Flow model.
-
-       Let $m_a$ is the number of backlogged bits in flow $a$.
-       The flow is {\em active}, if $m_a > 0$.
-       This number is a discontinuous function of time;
-       when a packet $i$ arrives:
-       \[
-       m_a(t_i+0) - m_a(t_i-0) = L^i,
-       \]
-       where $L^i$ is the length of the arrived packet.
-       The flow queue is drained continuously until $m_a == 0$:
-       \[
-       {d m_a \over dt} = - { B r_a \over \sum_{b \in A} r_b}.
-       \]
-       I.e. flow rates are their allocated rates proportionally
-       scaled to take all available link bandwidth. Apparently,
-       it is not the only possible policy. F.e. CBQ classes
-       without borrowing would be modelled by:
-       \[
-       {d m_a \over dt} = - B r_a .
-       \]
-       More complicated hierarchical bandwidth allocation
-       policies are possible, but unfortunately, the basic
-       flow equations have a simple solution only for proportional
-       scaling.
-
-       --- Departure times.
-
-       We calculate the time until the last bit of packet is sent:
-       \[
-       E_a^i(t) = { m_a(t_i) - \delta_a(t) \over r_a },
-       \]
-       where $\delta_a(t)$ is number of bits drained since $t_i$.
-       We have to evaluate $E_a^i$ for all queued packets,
-       then find the packet with minimal $E_a^i$ and send it.
-
-       This sounds good, but direct implementation of the algorithm
-       is absolutely infeasible. Luckily, if flow rates
-       are scaled proportionally, the equations have a simple solution.
-       
-       The differential equation for $E_a^i$ is
-       \[
-       {d E_a^i (t) \over dt } = - { d \delta_a(t) \over dt} { 1 \over r_a} =
-       { B \over \sum_{b \in A} r_b}
-       \]
-       with initial condition
-       \[
-       E_a^i (t_i) = { m_a(t_i) \over r_a } .
-       \]
-
-       Let's introduce an auxiliary function $R(t)$:
-
-       --- Round number.
-
-       Consider the following model: we rotate over active flows,
-       sending $r_a B$ bits from every flow, so that we send
-       $B \sum_{a \in A} r_a$ bits per round, that takes
-       $\sum_{a \in A} r_a$ seconds.
-       
-       Hence, $R(t)$ (round number) is a monotonically increasing
-       linear function of time when $A$ is not changed
-       \[
-       { d R(t) \over dt } = { 1 \over \sum_{a \in A} r_a }
-       \]
-       and it is continuous when $A$ changes.
-
-       The central observation is that the quantity
-       $F_a^i = R(t) + E_a^i(t)/B$ does not depend on time at all!
-       $R(t)$ does not depend on flow, so that $F_a^i$ can be
-       calculated only once on packet arrival, and we need not
-       recalculate $E$ numbers and resorting queues.
-       The number $F_a^i$ is called finish number of the packet.
-       It is just the value of $R(t)$ when the last bit of packet
-       is sent out.
-
-       Maximal finish number on flow is called finish number of flow
-       and minimal one is "start number of flow".
-       Apparently, flow is active if and only if $F_a \leq R$.
-
-       When a packet of length $L_i$ bit arrives to flow $a$ at time $t_i$,
-       we calculate $F_a^i$ as:
-
-       If flow was inactive ($F_a < R$):
-       $F_a^i = R(t) + {L_i \over B r_a}$
-       otherwise
-       $F_a^i = F_a + {L_i \over B r_a}$
-
-       These equations complete the algorithm specification.
-
-       It looks pretty hairy, but there is a simple
-       procedure for solving these equations.
-       See procedure csz_update(), that is a generalization of
-       the algorithm from S. Keshav's thesis Chapter 3
-       "Efficient Implementation of Fair Queuing".
-
-       NOTES.
-
-       * We implement only the simplest variant of CSZ,
-       when flow-0 is a explicit 4band priority fifo.
-       This is bad, but we need a "peek" operation in addition
-       to "dequeue" to implement complete CSZ.
-       I do not want to do that, unless it is absolutely
-       necessary.
-       
-       * A primitive support for token bucket filtering
-       presents itself too. It directly contradicts CSZ, but
-       even though the Internet is on the globe ... :-)
-       "the edges of the network" really exist.
-       
-       BUGS.
-
-       * Fixed point arithmetic is overcomplicated, suboptimal and even
-       wrong. Check it later.  */
-
-
-/* This number is arbitrary */
-
-#define CSZ_GUARANTEED         16
-#define CSZ_FLOWS              (CSZ_GUARANTEED+4)
-
-struct csz_head
-{
-       struct csz_head         *snext;
-       struct csz_head         *sprev;
-       struct csz_head         *fnext;
-       struct csz_head         *fprev;
-};
-
-struct csz_flow
-{
-       struct csz_head         *snext;
-       struct csz_head         *sprev;
-       struct csz_head         *fnext;
-       struct csz_head         *fprev;
-
-/* Parameters */
-       struct tc_ratespec      rate;
-       struct tc_ratespec      slice;
-       u32                     *L_tab; /* Lookup table for L/(B*r_a) values */
-       unsigned long           limit;  /* Maximal length of queue */
-#ifdef CSZ_PLUS_TBF
-       struct tc_ratespec      peakrate;
-       __u32                   buffer; /* Depth of token bucket, normalized
-                                          as L/(B*r_a) */
-       __u32                   mtu;
-#endif
-
-/* Variables */
-#ifdef CSZ_PLUS_TBF
-       unsigned long           tokens; /* Tokens number: usecs */
-       psched_time_t           t_tbf;
-       unsigned long           R_tbf;
-       int                     throttled;
-#endif
-       unsigned                peeked;
-       unsigned long           start;  /* Finish number of the first skb */
-       unsigned long           finish; /* Finish number of the flow */
-
-       struct sk_buff_head     q;      /* FIFO queue */
-};
-
-#define L2R(f,L) ((f)->L_tab[(L)>>(f)->slice.cell_log])
-
-struct csz_sched_data
-{
-/* Parameters */
-       unsigned char   rate_log;       /* fixed point position for rate;
-                                        * really we need not it */
-       unsigned char   R_log;          /* fixed point position for round number */
-       unsigned char   delta_log;      /* 1<<delta_log is maximal timeout in usecs;
-                                        * 21 <-> 2.1sec is MAXIMAL value */
-
-/* Variables */
-       struct tcf_proto *filter_list;
-       u8      prio2band[TC_PRIO_MAX+1];
-#ifdef CSZ_PLUS_TBF
-       struct timer_list wd_timer;
-       long            wd_expires;
-#endif
-       psched_time_t   t_c;            /* Time check-point */
-       unsigned long   R_c;            /* R-number check-point */
-       unsigned long   rate;           /* Current sum of rates of active flows */
-       struct csz_head s;              /* Flows sorted by "start" */
-       struct csz_head f;              /* Flows sorted by "finish"     */
-
-       struct sk_buff_head     other[4];/* Predicted (0) and the best efforts
-                                           classes (1,2,3) */
-       struct csz_flow flow[CSZ_GUARANTEED]; /* Array of flows */
-};
-
-/* These routines (csz_insert_finish and csz_insert_start) are
-   the most time consuming part of all the algorithm.
-
-   We insert to sorted list, so that time
-   is linear with respect to number of active flows in the worst case.
-   Note that we have not very large number of guaranteed flows,
-   so that logarithmic algorithms (heap etc.) are useless,
-   they are slower than linear one when length of list <= 32.
-
-   Heap would take sence if we used WFQ for best efforts
-   flows, but SFQ is better choice in this case.
- */
-
-
-/* Insert flow "this" to the list "b" before
-   flow with greater finish number.
- */
-
-#if 0
-/* Scan forward */
-static inline void csz_insert_finish(struct csz_head *b,
-                                    struct csz_flow *this)
-{
-       struct csz_head *f = b->fnext;
-       unsigned long finish = this->finish;
-
-       while (f != b) {
-               if (((struct csz_flow*)f)->finish - finish > 0)
-                       break;
-               f = f->fnext;
-       }
-       this->fnext = f;
-       this->fprev = f->fprev;
-       this->fnext->fprev = this->fprev->fnext = (struct csz_head*)this;
-}
-#else
-/* Scan backward */
-static inline void csz_insert_finish(struct csz_head *b,
-                                    struct csz_flow *this)
-{
-       struct csz_head *f = b->fprev;
-       unsigned long finish = this->finish;
-
-       while (f != b) {
-               if (((struct csz_flow*)f)->finish - finish <= 0)
-                       break;
-               f = f->fprev;
-       }
-       this->fnext = f->fnext;
-       this->fprev = f;
-       this->fnext->fprev = this->fprev->fnext = (struct csz_head*)this;
-}
-#endif
-
-/* Insert flow "this" to the list "b" before
-   flow with greater start number.
- */
-
-static inline void csz_insert_start(struct csz_head *b,
-                                   struct csz_flow *this)
-{
-       struct csz_head *f = b->snext;
-       unsigned long start = this->start;
-
-       while (f != b) {
-               if (((struct csz_flow*)f)->start - start > 0)
-                       break;
-               f = f->snext;
-       }
-       this->snext = f;
-       this->sprev = f->sprev;
-       this->snext->sprev = this->sprev->snext = (struct csz_head*)this;
-}
-
-
-/* Calculate and return current round number.
-   It is another time consuming part, but
-   it is impossible to avoid it.
-
-   It costs O(N) that make all the algorithm useful only
-   to play with closest to ideal fluid model.
-
-   There exist less academic, but more practical modifications,
-   which might have even better characteristics (WF2Q+, HPFQ, HFSC)
- */
-
-static unsigned long csz_update(struct Qdisc *sch)
-{
-       struct csz_sched_data   *q = (struct csz_sched_data*)sch->data;
-       struct csz_flow         *a;
-       unsigned long           F;
-       unsigned long           tmp;
-       psched_time_t           now;
-       unsigned long           delay;
-       unsigned long           R_c;
-
-       PSCHED_GET_TIME(now);
-       delay = PSCHED_TDIFF_SAFE(now, q->t_c, 0, goto do_reset);
-
-       if (delay>>q->delta_log) {
-do_reset:
-               /* Delta is too large.
-                  It is possible if MTU/BW > 1<<q->delta_log
-                  (i.e. configuration error) or because of hardware
-                  fault. We have no choice...
-                */
-               qdisc_reset(sch);
-               return 0;
-       }
-
-       q->t_c = now;
-
-       for (;;) {
-               a = (struct csz_flow*)q->f.fnext;
-
-               /* No more active flows. Reset R and exit. */
-               if (a == (struct csz_flow*)&q->f) {
-#ifdef CSZ_DEBUG
-                       if (q->rate) {
-                               printk("csz_update: rate!=0 on inactive csz\n");
-                               q->rate = 0;
-                       }
-#endif
-                       q->R_c = 0;
-                       return 0;
-               }
-
-               F = a->finish;
-
-#ifdef CSZ_DEBUG
-               if (q->rate == 0) {
-                       printk("csz_update: rate=0 on active csz\n");
-                       goto do_reset;
-               }
-#endif
-
-               /*
-                *           tmp = (t - q->t_c)/q->rate;
-                */
-
-               tmp = ((delay<<(31-q->delta_log))/q->rate)>>(31-q->delta_log+q->R_log);
-
-               tmp += q->R_c;
-
-               /* OK, this flow (and all flows with greater
-                  finish numbers) is still active */
-               if (F - tmp > 0)
-                       break;
-
-               /* It is more not active */
-
-               a->fprev->fnext = a->fnext;
-               a->fnext->fprev = a->fprev;
-
-               /*
-                * q->t_c += (F - q->R_c)*q->rate
-                */
-
-               tmp = ((F-q->R_c)*q->rate)<<q->R_log;
-               R_c = F;
-               q->rate -= a->slice.rate;
-
-               if ((long)(delay - tmp) >= 0) {
-                       delay -= tmp;
-                       continue;
-               }
-               delay = 0;
-       }
-
-       q->R_c = tmp;
-       return tmp;
-}
-
-unsigned csz_classify(struct sk_buff *skb, struct csz_sched_data *q)
-{
-       return CSZ_GUARANTEED;
-}
-
-static int
-csz_enqueue(struct sk_buff *skb, struct Qdisc* sch)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       unsigned flow_id = csz_classify(skb, q);
-       unsigned long R;
-       int prio = 0;
-       struct csz_flow *this;
-
-       if (flow_id >= CSZ_GUARANTEED) {
-               prio = flow_id - CSZ_GUARANTEED;
-               flow_id = 0;
-       }
-
-       this = &q->flow[flow_id];
-       if (this->q.qlen >= this->limit || this->L_tab == NULL) {
-               sch->stats.drops++;
-               kfree_skb(skb);
-               return NET_XMIT_DROP;
-       }
-
-       R = csz_update(sch);
-
-       if ((long)(this->finish - R) >= 0) {
-               /* It was active */
-               this->finish += L2R(this,skb->len);
-       } else {
-               /* It is inactive; activate it */
-               this->finish = R + L2R(this,skb->len);
-               q->rate += this->slice.rate;
-               csz_insert_finish(&q->f, this);
-       }
-
-       /* If this flow was empty, remember start number
-          and insert it into start queue */
-       if (this->q.qlen == 0) {
-               this->start = this->finish;
-               csz_insert_start(&q->s, this);
-       }
-       if (flow_id)
-               skb_queue_tail(&this->q, skb);
-       else
-               skb_queue_tail(&q->other[prio], skb);
-       sch->q.qlen++;
-       sch->stats.bytes += skb->len;
-       sch->stats.packets++;
-       return 0;
-}
-
-static __inline__ struct sk_buff *
-skb_dequeue_best(struct csz_sched_data * q)
-{
-       int i;
-       struct sk_buff *skb;
-
-       for (i=0; i<4; i++) {
-               skb = skb_dequeue(&q->other[i]);
-               if (skb) {
-                       q->flow[0].q.qlen--;
-                       return skb;
-               }
-       }
-       return NULL;
-}
-
-static __inline__ struct sk_buff *
-skb_peek_best(struct csz_sched_data * q)
-{
-       int i;
-       struct sk_buff *skb;
-
-       for (i=0; i<4; i++) {
-               skb = skb_peek(&q->other[i]);
-               if (skb)
-                       return skb;
-       }
-       return NULL;
-}
-
-#ifdef CSZ_PLUS_TBF
-
-static void csz_watchdog(unsigned long arg)
-{
-       struct Qdisc *sch = (struct Qdisc*)arg;
-
-       qdisc_wakeup(sch->dev);
-}
-
-static __inline__ void
-csz_move_queue(struct csz_flow *this, long delta)
-{
-       this->fprev->fnext = this->fnext;
-       this->fnext->fprev = this->fprev;
-
-       this->start += delta;
-       this->finish += delta;
-
-       csz_insert_finish(this);
-}
-
-static __inline__ int csz_enough_tokens(struct csz_sched_data *q,
-                                       struct csz_flow *this,
-                                       struct sk_buff *skb)
-{
-       long toks;
-       long shift;
-       psched_time_t now;
-
-       PSCHED_GET_TIME(now);
-
-       toks = PSCHED_TDIFF(now, t_tbf) + this->tokens - L2R(q,this,skb->len);
-
-       shift = 0;
-       if (this->throttled) {
-               /* Remember aposteriory delay */
-
-               unsigned long R = csz_update(q);
-               shift = R - this->R_tbf;
-               this->R_tbf = R;
-       }
-
-       if (toks >= 0) {
-               /* Now we have enough tokens to proceed */
-
-               this->tokens = toks <= this->depth ? toks : this->depth;
-               this->t_tbf = now;
-       
-               if (!this->throttled)
-                       return 1;
-
-               /* Flow was throttled. Update its start&finish numbers
-                  with delay calculated aposteriori.
-                */
-
-               this->throttled = 0;
-               if (shift > 0)
-                       csz_move_queue(this, shift);
-               return 1;
-       }
-
-       if (!this->throttled) {
-               /* Flow has just been throttled; remember
-                  current round number to calculate aposteriori delay
-                */
-               this->throttled = 1;
-               this->R_tbf = csz_update(q);
-       }
-
-       /* Move all the queue to the time when it will be allowed to send.
-          We should translate time to round number, but it is impossible,
-          so that we made the most conservative estimate i.e. we suppose
-          that only this flow is active and, hence, R = t.
-          Really toks <= R <= toks/r_a.
-
-          This apriory shift in R will be adjusted later to reflect
-          real delay. We cannot avoid it because of:
-          - throttled flow continues to be active from the viewpoint
-            of CSZ, so that it would acquire the highest priority,
-            if you not adjusted start numbers.
-          - Eventually, finish number would become less than round
-            number and flow were declared inactive.
-        */
-
-       toks = -toks;
-
-       /* Remember, that we should start watchdog */
-       if (toks < q->wd_expires)
-               q->wd_expires = toks;
-
-       toks >>= q->R_log;
-       shift += toks;
-       if (shift > 0) {
-               this->R_tbf += toks;
-               csz_move_queue(this, shift);
-       }
-       csz_insert_start(this);
-       return 0;
-}
-#endif
-
-
-static struct sk_buff *
-csz_dequeue(struct Qdisc* sch)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       struct sk_buff *skb;
-       struct csz_flow *this;
-
-#ifdef CSZ_PLUS_TBF
-       q->wd_expires = 0;
-#endif
-       this = (struct csz_flow*)q->s.snext;
-
-       while (this != (struct csz_flow*)&q->s) {
-
-               /* First of all: unlink from start list */
-               this->sprev->snext = this->snext;
-               this->snext->sprev = this->sprev;
-
-               if (this != &q->flow[0]) {      /* Guaranteed flow */
-                       skb = __skb_dequeue(&this->q);
-                       if (skb) {
-#ifdef CSZ_PLUS_TBF
-                               if (this->depth) {
-                                       if (!csz_enough_tokens(q, this, skb))
-                                               continue;
-                               }
-#endif
-                               if (this->q.qlen) {
-                                       struct sk_buff *nskb = skb_peek(&this->q);
-                                       this->start += L2R(this,nskb->len);
-                                       csz_insert_start(&q->s, this);
-                               }
-                               sch->q.qlen--;
-                               return skb;
-                       }
-               } else {        /* Predicted or best effort flow */
-                       skb = skb_dequeue_best(q);
-                       if (skb) {
-                               unsigned peeked = this->peeked;
-                               this->peeked = 0;
-
-                               if (--this->q.qlen) {
-                                       struct sk_buff *nskb;
-                                       unsigned dequeued = L2R(this,skb->len);
-
-                                       /* We got not the same thing that
-                                          peeked earlier; adjust start number
-                                          */
-                                       if (peeked != dequeued && peeked)
-                                               this->start += dequeued - peeked;
-
-                                       nskb = skb_peek_best(q);
-                                       peeked = L2R(this,nskb->len);
-                                       this->start += peeked;
-                                       this->peeked = peeked;
-                                       csz_insert_start(&q->s, this);
-                               }
-                               sch->q.qlen--;
-                               return skb;
-                       }
-               }
-       }
-#ifdef CSZ_PLUS_TBF
-       /* We are about to return no skb.
-          Schedule watchdog timer, if it occurred because of shaping.
-        */
-       if (q->wd_expires) {
-               unsigned long delay = PSCHED_US2JIFFIE(q->wd_expires);
-               if (delay == 0)
-                       delay = 1;
-               mod_timer(&q->wd_timer, jiffies + delay);
-               sch->stats.overlimits++;
-       }
-#endif
-       return NULL;
-}
-
-static void
-csz_reset(struct Qdisc* sch)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       int    i;
-
-       for (i=0; i<4; i++)
-               skb_queue_purge(&q->other[i]);
-
-       for (i=0; i<CSZ_GUARANTEED; i++) {
-               struct csz_flow *this = q->flow + i;
-               skb_queue_purge(&this->q);
-               this->snext = this->sprev =
-               this->fnext = this->fprev = (struct csz_head*)this;
-               this->start = this->finish = 0;
-       }
-       q->s.snext = q->s.sprev = &q->s;
-       q->f.fnext = q->f.fprev = &q->f;
-       q->R_c = 0;
-#ifdef CSZ_PLUS_TBF
-       PSCHED_GET_TIME(&q->t_tbf);
-       q->tokens = q->depth;
-       del_timer(&q->wd_timer);
-#endif
-       sch->q.qlen = 0;
-}
-
-static void
-csz_destroy(struct Qdisc* sch)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       struct tcf_proto *tp;
-
-       while ((tp = q->filter_list) != NULL) {
-               q->filter_list = tp->next;
-               tcf_destroy(tp);
-       }
-}
-
-static int csz_init(struct Qdisc *sch, struct rtattr *opt)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       struct rtattr *tb[TCA_CSZ_PTAB];
-       struct tc_csz_qopt *qopt;
-       int    i;
-
-       rtattr_parse(tb, TCA_CSZ_PTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
-       if (tb[TCA_CSZ_PARMS-1] == NULL ||
-           RTA_PAYLOAD(tb[TCA_CSZ_PARMS-1]) < sizeof(*qopt))
-               return -EINVAL;
-       qopt = RTA_DATA(tb[TCA_CSZ_PARMS-1]);
-
-       q->R_log = qopt->R_log;
-       q->delta_log = qopt->delta_log;
-       for (i=0; i<=TC_PRIO_MAX; i++) {
-               if (qopt->priomap[i] >= CSZ_FLOWS)
-                       return -EINVAL;
-               q->prio2band[i] = qopt->priomap[i];
-       }
-
-       for (i=0; i<4; i++)
-               skb_queue_head_init(&q->other[i]);
-
-       for (i=0; i<CSZ_GUARANTEED; i++) {
-               struct csz_flow *this = q->flow + i;
-               skb_queue_head_init(&this->q);
-               this->snext = this->sprev =
-               this->fnext = this->fprev = (struct csz_head*)this;
-               this->start = this->finish = 0;
-       }
-       q->s.snext = q->s.sprev = &q->s;
-       q->f.fnext = q->f.fprev = &q->f;
-       q->R_c = 0;
-#ifdef CSZ_PLUS_TBF
-       init_timer(&q->wd_timer);
-       q->wd_timer.data = (unsigned long)sch;
-       q->wd_timer.function = csz_watchdog;
-#endif
-       return 0;
-}
-
-static int csz_dump(struct Qdisc *sch, struct sk_buff *skb)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       unsigned char    *b = skb->tail;
-       struct rtattr *rta;
-       struct tc_csz_qopt opt;
-
-       rta = (struct rtattr*)b;
-       RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
-
-       opt.flows = CSZ_FLOWS;
-       memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX+1);
-       RTA_PUT(skb, TCA_CSZ_PARMS, sizeof(opt), &opt);
-       rta->rta_len = skb->tail - b;
-
-       return skb->len;
-
-rtattr_failure:
-       skb_trim(skb, b - skb->data);
-       return -1;
-}
-
-static int csz_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new,
-                    struct Qdisc **old)
-{
-       return -EINVAL;
-}
-
-static struct Qdisc * csz_leaf(struct Qdisc *sch, unsigned long cl)
-{
-       return NULL;
-}
-
-
-static unsigned long csz_get(struct Qdisc *sch, u32 classid)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       unsigned long band = TC_H_MIN(classid) - 1;
-
-       if (band >= CSZ_FLOWS)
-               return 0;
-
-       if (band < CSZ_GUARANTEED && q->flow[band].L_tab == NULL)
-               return 0;
-
-       return band+1;
-}
-
-static unsigned long csz_bind(struct Qdisc *sch, unsigned long parent, u32 classid)
-{
-       return csz_get(sch, classid);
-}
-
-
-static void csz_put(struct Qdisc *sch, unsigned long cl)
-{
-       return;
-}
-
-static int csz_change(struct Qdisc *sch, u32 handle, u32 parent, struct rtattr **tca, unsigned long *arg)
-{
-       unsigned long cl = *arg;
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       struct rtattr *opt = tca[TCA_OPTIONS-1];
-       struct rtattr *tb[TCA_CSZ_PTAB];
-       struct tc_csz_copt *copt;
-
-       rtattr_parse(tb, TCA_CSZ_PTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
-       if (tb[TCA_CSZ_PARMS-1] == NULL ||
-           RTA_PAYLOAD(tb[TCA_CSZ_PARMS-1]) < sizeof(*copt))
-               return -EINVAL;
-       copt = RTA_DATA(tb[TCA_CSZ_PARMS-1]);
-
-       if (tb[TCA_CSZ_RTAB-1] &&
-           RTA_PAYLOAD(tb[TCA_CSZ_RTAB-1]) < 1024)
-               return -EINVAL;
-
-       if (cl) {
-               struct csz_flow *a;
-               cl--;
-               if (cl >= CSZ_FLOWS)
-                       return -ENOENT;
-               if (cl >= CSZ_GUARANTEED || q->flow[cl].L_tab == NULL)
-                       return -EINVAL;
-
-               a = &q->flow[cl];
-
-               spin_lock_bh(&sch->dev->queue_lock);
-#if 0
-               a->rate_log = copt->rate_log;
-#endif
-#ifdef CSZ_PLUS_TBF
-               a->limit = copt->limit;
-               a->rate = copt->rate;
-               a->buffer = copt->buffer;
-               a->mtu = copt->mtu;
-#endif
-
-               if (tb[TCA_CSZ_RTAB-1])
-                       memcpy(a->L_tab, RTA_DATA(tb[TCA_CSZ_RTAB-1]), 1024);
-
-               spin_unlock_bh(&sch->dev->queue_lock);
-               return 0;
-       }
-       /* NI */
-       return 0;
-}
-
-static int csz_delete(struct Qdisc *sch, unsigned long cl)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       struct csz_flow *a;
-
-       cl--;
-
-       if (cl >= CSZ_FLOWS)
-               return -ENOENT;
-       if (cl >= CSZ_GUARANTEED || q->flow[cl].L_tab == NULL)
-               return -EINVAL;
-
-       a = &q->flow[cl];
-
-       spin_lock_bh(&sch->dev->queue_lock);
-       a->fprev->fnext = a->fnext;
-       a->fnext->fprev = a->fprev;
-       a->sprev->snext = a->snext;
-       a->snext->sprev = a->sprev;
-       a->start = a->finish = 0;
-       kfree(xchg(&q->flow[cl].L_tab, NULL));
-       spin_unlock_bh(&sch->dev->queue_lock);
-
-       return 0;
-}
-
-static int csz_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb, struct tcmsg *tcm)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       unsigned char    *b = skb->tail;
-       struct rtattr *rta;
-       struct tc_csz_copt opt;
-
-       tcm->tcm_handle = sch->handle|cl;
-
-       cl--;
-
-       if (cl > CSZ_FLOWS)
-               goto rtattr_failure;
-
-       if (cl < CSZ_GUARANTEED) {
-               struct csz_flow *f = &q->flow[cl];
-
-               if (f->L_tab == NULL)
-                       goto rtattr_failure;
-
-               rta = (struct rtattr*)b;
-               RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
-
-               opt.limit = f->limit;
-               opt.rate = f->rate;
-               opt.slice = f->slice;
-               memset(&opt.peakrate, 0, sizeof(opt.peakrate));
-#ifdef CSZ_PLUS_TBF
-               opt.buffer = f->buffer;
-               opt.mtu = f->mtu;
-#else
-               opt.buffer = 0;
-               opt.mtu = 0;
-#endif
-
-               RTA_PUT(skb, TCA_CSZ_PARMS, sizeof(opt), &opt);
-               rta->rta_len = skb->tail - b;
-       }
-
-       return skb->len;
-
-rtattr_failure:
-       skb_trim(skb, b - skb->data);
-       return -1;
-}
-
-static void csz_walk(struct Qdisc *sch, struct qdisc_walker *arg)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-       int prio = 0;
-
-       if (arg->stop)
-               return;
-
-       for (prio = 0; prio < CSZ_FLOWS; prio++) {
-               if (arg->count < arg->skip) {
-                       arg->count++;
-                       continue;
-               }
-               if (prio < CSZ_GUARANTEED && q->flow[prio].L_tab == NULL) {
-                       arg->count++;
-                       continue;
-               }
-               if (arg->fn(sch, prio+1, arg) < 0) {
-                       arg->stop = 1;
-                       break;
-               }
-               arg->count++;
-       }
-}
-
-static struct tcf_proto ** csz_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
-       struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-
-       if (cl)
-               return NULL;
-
-       return &q->filter_list;
-}
-
-struct Qdisc_class_ops csz_class_ops = {
-       .graft          =       csz_graft,
-       .leaf           =       csz_leaf,
-       .get            =       csz_get,
-       .put            =       csz_put,
-       .change         =       csz_change,
-       .delete         =       csz_delete,
-       .walk           =       csz_walk,
-       .tcf_chain      =       csz_find_tcf,
-       .bind_tcf       =       csz_bind,
-       .unbind_tcf     =       csz_put,
-       .dump           =       csz_dump_class,
-};
-
-static struct Qdisc_ops csz_qdisc_ops = {
-       .next           =       NULL,
-       .cl_ops         =       &csz_class_ops,
-       .id             =       "csz",
-       .priv_size      =       sizeof(struct csz_sched_data),
-       .enqueue        =       csz_enqueue,
-       .dequeue        =       csz_dequeue,
-       .requeue        =       NULL,
-       .drop           =       NULL,
-       .init           =       csz_init,
-       .reset          =       csz_reset,
-       .destroy        =       csz_destroy,
-       .change         =       NULL,
-       .dump           =       csz_dump,
-       .owner          =       THIS_MODULE,
-};
-
-static int __init csz_module_init(void)
-{
-       return register_qdisc(&csz_qdisc_ops);
-}
-static void __exit csz_module_exit(void) 
-{
-       unregister_qdisc(&csz_qdisc_ops);
-}
-module_init(csz_module_init)
-module_exit(csz_module_exit)
-MODULE_LICENSE("GPL");
diff --git a/net/sched/sch_delay.c b/net/sched/sch_delay.c
deleted file mode 100644 (file)
index c1a4210..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * net/sched/sch_delay.c       Simple constant delay
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- *
- * Authors:    Stephen Hemminger <shemminger@osdl.org>
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/socket.h>
-#include <linux/sockios.h>
-#include <linux/in.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/if_ether.h>
-#include <linux/inet.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/notifier.h>
-#include <net/ip.h>
-#include <net/route.h>
-#include <linux/skbuff.h>
-#include <net/sock.h>
-#include <net/pkt_sched.h>
-
-/*     Network delay simulator
-       This scheduler adds a fixed delay to all packets.
-       Similar to NISTnet and BSD Dummynet.
-
-       It uses byte fifo underneath similar to TBF */
-struct dly_sched_data {
-       u32     latency;
-       u32     limit;
-       struct timer_list timer;
-       struct Qdisc *qdisc;
-};
-
-/* Time stamp put into socket buffer control block */
-struct dly_skb_cb {
-       psched_time_t   queuetime;
-};
-
-/* Enqueue packets with underlying discipline (fifo)
- * but mark them with current time first.
- */
-static int dly_enqueue(struct sk_buff *skb, struct Qdisc *sch)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-       struct dly_skb_cb *cb = (struct dly_skb_cb *)skb->cb;
-       int ret;
-
-       PSCHED_GET_TIME(cb->queuetime);
-
-       /* Queue to underlying scheduler */
-       ret = q->qdisc->enqueue(skb, q->qdisc);
-       if (ret)
-               sch->stats.drops++;
-       else {
-               sch->q.qlen++;
-               sch->stats.bytes += skb->len;
-               sch->stats.packets++;
-       }
-       return 0;
-}
-
-/* Requeue packets but don't change time stamp */
-static int dly_requeue(struct sk_buff *skb, struct Qdisc *sch)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-       int ret;
-
-       ret = q->qdisc->ops->requeue(skb, q->qdisc);
-       if (ret == 0)
-               sch->q.qlen++;
-       return ret;
-}
-
-static unsigned int dly_drop(struct Qdisc *sch)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-       unsigned int len;
-
-       len = q->qdisc->ops->drop(q->qdisc);
-       if (len) {
-               sch->q.qlen--;
-               sch->stats.drops++;
-       }
-       return len;
-}
-
-/* Dequeue packet.
- * If packet needs to be held up, then stop the
- * queue and set timer to wakeup later.
- */
-static struct sk_buff *dly_dequeue(struct Qdisc *sch)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-       struct sk_buff *skb = q->qdisc->dequeue(q->qdisc);
-
-       if (skb) {
-               struct dly_skb_cb *cb = (struct dly_skb_cb *)skb->cb;
-               psched_time_t now;
-               long diff;
-
-               PSCHED_GET_TIME(now);
-               diff = q->latency - PSCHED_TDIFF(now, cb->queuetime);
-
-               if (diff <= 0) {
-                       sch->q.qlen--;
-                       sch->flags &= ~TCQ_F_THROTTLED;
-                       return skb;
-               }
-
-               if (!netif_queue_stopped(sch->dev)) {
-                       long delay = PSCHED_US2JIFFIE(diff);
-                       if (delay <= 0)
-                               delay = 1;
-                       mod_timer(&q->timer, jiffies+delay);
-               }
-
-               if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
-                       sch->q.qlen--;
-                       sch->stats.drops++;
-               }
-               sch->flags |= TCQ_F_THROTTLED;
-       }
-       return NULL;
-}
-
-static void dly_reset(struct Qdisc *sch)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-
-       qdisc_reset(q->qdisc);
-       sch->q.qlen = 0;
-       sch->flags &= ~TCQ_F_THROTTLED;
-       del_timer(&q->timer);
-}
-
-static void dly_timer(unsigned long arg)
-{
-       struct Qdisc *sch = (struct Qdisc *)arg;
-
-       sch->flags &= ~TCQ_F_THROTTLED;
-       netif_schedule(sch->dev);
-}
-
-/* Tell Fifo the new limit. */
-static int change_limit(struct Qdisc *q, u32 limit)
-{
-       struct rtattr *rta;
-       int ret;
-
-       rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
-       if (!rta)
-               return -ENOMEM;
-
-       rta->rta_type = RTM_NEWQDISC;
-       rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
-       ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
-       ret = q->ops->change(q, rta);
-       kfree(rta);
-
-       return ret;
-}
-
-/* Setup underlying FIFO discipline */
-static int dly_change(struct Qdisc *sch, struct rtattr *opt)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-       struct tc_dly_qopt *qopt = RTA_DATA(opt);
-       int err;
-
-       if (q->qdisc == &noop_qdisc) {
-               struct Qdisc *child
-                       = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops);
-               if (!child)
-                       return -EINVAL;
-               q->qdisc = child;
-       }
-
-       err = change_limit(q->qdisc, qopt->limit);
-       if (err) {
-               qdisc_destroy(q->qdisc);
-               q->qdisc = &noop_qdisc;
-       } else {
-               q->latency = qopt->latency;
-               q->limit = qopt->limit;
-       }
-       return err;
-}
-
-static int dly_init(struct Qdisc *sch, struct rtattr *opt)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-
-       if (!opt)
-               return -EINVAL;
-
-       init_timer(&q->timer);
-       q->timer.function = dly_timer;
-       q->timer.data = (unsigned long) sch;
-       q->qdisc = &noop_qdisc;
-
-       return dly_change(sch, opt);
-}
-
-static void dly_destroy(struct Qdisc *sch)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-
-       del_timer(&q->timer);
-       qdisc_destroy(q->qdisc);
-       q->qdisc = &noop_qdisc;
-}
-
-static int dly_dump(struct Qdisc *sch, struct sk_buff *skb)
-{
-       struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-       unsigned char    *b = skb->tail;
-       struct tc_dly_qopt qopt;
-
-       qopt.latency = q->latency;
-       qopt.limit = q->limit;
-
-       RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
-
-       return skb->len;
-
-rtattr_failure:
-       skb_trim(skb, b - skb->data);
-       return -1;
-}
-
-static struct Qdisc_ops dly_qdisc_ops = {
-       .id             =       "delay",
-       .priv_size      =       sizeof(struct dly_sched_data),
-       .enqueue        =       dly_enqueue,
-       .dequeue        =       dly_dequeue,
-       .requeue        =       dly_requeue,
-       .drop           =       dly_drop,
-       .init           =       dly_init,
-       .reset          =       dly_reset,
-       .destroy        =       dly_destroy,
-       .change         =       dly_change,
-       .dump           =       dly_dump,
-       .owner          =       THIS_MODULE,
-};
-
-
-static int __init dly_module_init(void)
-{
-       return register_qdisc(&dly_qdisc_ops);
-}
-static void __exit dly_module_exit(void)
-{
-       unregister_qdisc(&dly_qdisc_ops);
-}
-module_init(dly_module_init)
-module_exit(dly_module_exit)
-MODULE_LICENSE("GPL");
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
deleted file mode 100644 (file)
index 4d91d69..0000000
+++ /dev/null
@@ -1,952 +0,0 @@
-/*
- * net/sched/sch_netem.c       Network emulator
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- *
- * Authors:    Stephen Hemminger <shemminger@osdl.org>
- *             Catalin(ux aka Dino) BOIE <catab at umbrella dot ro>
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <asm/bitops.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
-
-#include <net/pkt_sched.h>
-
-/*     Network emulator
- *
- *     This scheduler can alters spacing and order
- *     Similar to NISTnet and BSD Dummynet.
- */
-
-struct netem_sched_data {
-       struct Qdisc    *qdisc;
-       struct sk_buff_head delayed;
-       struct timer_list timer;
-
-       u32 latency;
-       u32 loss;
-       u32 limit;
-       u32 counter;
-       u32 gap;
-       u32 jitter;
-};
-
-/* Time stamp put into socket buffer control block */
-struct netem_skb_cb {
-       psched_time_t   time_to_send;
-};
-
-/* This is the distribution table for the normal distribution produced
- * with NISTnet tools.
- * The entries represent a scaled inverse of the cumulative distribution
- * function.
- */
-#define TABLESIZE      2048
-#define TABLEFACTOR    8192
-
-static const short disttable[TABLESIZE] = {
-       -31473,         -26739,         -25226,         -24269,
-       -23560,         -22993,         -22518,         -22109,
-       -21749,         -21426,         -21133,         -20865,
-       -20618,         -20389,         -20174,         -19972,
-       -19782,         -19601,         -19430,         -19267,
-       -19112,         -18962,         -18819,         -18681,
-       -18549,         -18421,         -18298,         -18178,
-       -18062,         -17950,         -17841,         -17735,
-       -17632,         -17532,         -17434,         -17339,
-       -17245,         -17155,         -17066,         -16979,
-       -16894,         -16811,         -16729,         -16649,
-       -16571,         -16494,         -16419,         -16345,
-       -16272,         -16201,         -16130,         -16061,
-       -15993,         -15926,         -15861,         -15796,
-       -15732,         -15669,         -15607,         -15546,
-       -15486,         -15426,         -15368,         -15310,
-       -15253,         -15196,         -15140,         -15086,
-       -15031,         -14977,         -14925,         -14872,
-       -14821,         -14769,         -14719,         -14669,
-       -14619,         -14570,         -14522,         -14473,
-       -14426,         -14379,         -14332,         -14286,
-       -14241,         -14196,         -14150,         -14106,
-       -14062,         -14019,         -13976,         -13933,
-       -13890,         -13848,         -13807,         -13765,
-       -13724,         -13684,         -13643,         -13604,
-       -13564,         -13525,         -13486,         -13447,
-       -13408,         -13370,         -13332,         -13295,
-       -13258,         -13221,         -13184,         -13147,
-       -13111,         -13075,         -13040,         -13004,
-       -12969,         -12934,         -12899,         -12865,
-       -12830,         -12796,         -12762,         -12729,
-       -12695,         -12662,         -12629,         -12596,
-       -12564,         -12531,         -12499,         -12467,
-       -12435,         -12404,         -12372,         -12341,
-       -12310,         -12279,         -12248,         -12218,
-       -12187,         -12157,         -12127,         -12097,
-       -12067,         -12038,         -12008,         -11979,
-       -11950,         -11921,         -11892,         -11863,
-       -11835,         -11806,         -11778,         -11750,
-       -11722,         -11694,         -11666,         -11639,
-       -11611,         -11584,         -11557,         -11530,
-       -11503,         -11476,         -11450,         -11423,
-       -11396,         -11370,         -11344,         -11318,
-       -11292,         -11266,         -11240,         -11214,
-       -11189,         -11164,         -11138,         -11113,
-       -11088,         -11063,         -11038,         -11013,
-       -10988,         -10964,         -10939,         -10915,
-       -10891,         -10866,         -10843,         -10818,
-       -10794,         -10770,         -10747,         -10723,
-       -10700,         -10676,         -10652,         -10630,
-       -10606,         -10583,         -10560,         -10537,
-       -10514,         -10491,         -10469,         -10446,
-       -10424,         -10401,         -10378,         -10356,
-       -10334,         -10312,         -10290,         -10267,
-       -10246,         -10224,         -10202,         -10180,
-       -10158,         -10137,         -10115,         -10094,
-       -10072,         -10051,         -10030,         -10009,
-       -9988,          -9967,          -9945,          -9925,
-       -9904,          -9883,          -9862,          -9842,
-       -9821,          -9800,          -9780,          -9760,
-       -9739,          -9719,          -9699,          -9678,
-       -9658,          -9638,          -9618,          -9599,
-       -9578,          -9559,          -9539,          -9519,
-       -9499,          -9480,          -9461,          -9441,
-       -9422,          -9402,          -9383,          -9363,
-       -9344,          -9325,          -9306,          -9287,
-       -9268,          -9249,          -9230,          -9211,
-       -9192,          -9173,          -9155,          -9136,
-       -9117,          -9098,          -9080,          -9062,
-       -9043,          -9025,          -9006,          -8988,
-       -8970,          -8951,          -8933,          -8915,
-       -8897,          -8879,          -8861,          -8843,
-       -8825,          -8807,          -8789,          -8772,
-       -8754,          -8736,          -8718,          -8701,
-       -8683,          -8665,          -8648,          -8630,
-       -8613,          -8595,          -8578,          -8561,
-       -8543,          -8526,          -8509,          -8492,
-       -8475,          -8458,          -8441,          -8423,
-       -8407,          -8390,          -8373,          -8356,
-       -8339,          -8322,          -8305,          -8289,
-       -8272,          -8255,          -8239,          -8222,
-       -8206,          -8189,          -8172,          -8156,
-       -8140,          -8123,          -8107,          -8090,
-       -8074,          -8058,          -8042,          -8025,
-       -8009,          -7993,          -7977,          -7961,
-       -7945,          -7929,          -7913,          -7897,
-       -7881,          -7865,          -7849,          -7833,
-       -7817,          -7802,          -7786,          -7770,
-       -7754,          -7739,          -7723,          -7707,
-       -7692,          -7676,          -7661,          -7645,
-       -7630,          -7614,          -7599,          -7583,
-       -7568,          -7553,          -7537,          -7522,
-       -7507,          -7492,          -7476,          -7461,
-       -7446,          -7431,          -7416,          -7401,
-       -7385,          -7370,          -7356,          -7340,
-       -7325,          -7311,          -7296,          -7281,
-       -7266,          -7251,          -7236,          -7221,
-       -7207,          -7192,          -7177,          -7162,
-       -7148,          -7133,          -7118,          -7104,
-       -7089,          -7075,          -7060,          -7046,
-       -7031,          -7016,          -7002,          -6988,
-       -6973,          -6959,          -6944,          -6930,
-       -6916,          -6901,          -6887,          -6873,
-       -6859,          -6844,          -6830,          -6816,
-       -6802,          -6788,          -6774,          -6760,
-       -6746,          -6731,          -6717,          -6704,
-       -6690,          -6675,          -6661,          -6647,
-       -6633,          -6620,          -6606,          -6592,
-       -6578,          -6564,          -6550,          -6537,
-       -6523,          -6509,          -6495,          -6482,
-       -6468,          -6454,          -6441,          -6427,
-       -6413,          -6400,          -6386,          -6373,
-       -6359,          -6346,          -6332,          -6318,
-       -6305,          -6291,          -6278,          -6264,
-       -6251,          -6238,          -6224,          -6211,
-       -6198,          -6184,          -6171,          -6158,
-       -6144,          -6131,          -6118,          -6105,
-       -6091,          -6078,          -6065,          -6052,
-       -6039,          -6025,          -6012,          -5999,
-       -5986,          -5973,          -5960,          -5947,
-       -5934,          -5921,          -5908,          -5895,
-       -5882,          -5869,          -5856,          -5843,
-       -5830,          -5817,          -5804,          -5791,
-       -5779,          -5766,          -5753,          -5740,
-       -5727,          -5714,          -5702,          -5689,
-       -5676,          -5663,          -5650,          -5638,
-       -5625,          -5612,          -5600,          -5587,
-       -5575,          -5562,          -5549,          -5537,
-       -5524,          -5512,          -5499,          -5486,
-       -5474,          -5461,          -5449,          -5436,
-       -5424,          -5411,          -5399,          -5386,
-       -5374,          -5362,          -5349,          -5337,
-       -5324,          -5312,          -5299,          -5287,
-       -5275,          -5263,          -5250,          -5238,
-       -5226,          -5213,          -5201,          -5189,
-       -5177,          -5164,          -5152,          -5140,
-       -5128,          -5115,          -5103,          -5091,
-       -5079,          -5067,          -5055,          -5043,
-       -5030,          -5018,          -5006,          -4994,
-       -4982,          -4970,          -4958,          -4946,
-       -4934,          -4922,          -4910,          -4898,
-       -4886,          -4874,          -4862,          -4850,
-       -4838,          -4826,          -4814,          -4803,
-       -4791,          -4778,          -4767,          -4755,
-       -4743,          -4731,          -4719,          -4708,
-       -4696,          -4684,          -4672,          -4660,
-       -4649,          -4637,          -4625,          -4613,
-       -4601,          -4590,          -4578,          -4566,
-       -4554,          -4543,          -4531,          -4520,
-       -4508,          -4496,          -4484,          -4473,
-       -4461,          -4449,          -4438,          -4427,
-       -4415,          -4403,          -4392,          -4380,
-       -4368,          -4357,          -4345,          -4334,
-       -4322,          -4311,          -4299,          -4288,
-       -4276,          -4265,          -4253,          -4242,
-       -4230,          -4219,          -4207,          -4196,
-       -4184,          -4173,          -4162,          -4150,
-       -4139,          -4128,          -4116,          -4105,
-       -4094,          -4082,          -4071,          -4060,
-       -4048,          -4037,          -4026,          -4014,
-       -4003,          -3992,          -3980,          -3969,
-       -3958,          -3946,          -3935,          -3924,
-       -3913,          -3901,          -3890,          -3879,
-       -3868,          -3857,          -3845,          -3834,
-       -3823,          -3812,          -3801,          -3790,
-       -3779,          -3767,          -3756,          -3745,
-       -3734,          -3723,          -3712,          -3700,
-       -3689,          -3678,          -3667,          -3656,
-       -3645,          -3634,          -3623,          -3612,
-       -3601,          -3590,          -3579,          -3568,
-       -3557,          -3545,          -3535,          -3524,
-       -3513,          -3502,          -3491,          -3480,
-       -3469,          -3458,          -3447,          -3436,
-       -3425,          -3414,          -3403,          -3392,
-       -3381,          -3370,          -3360,          -3348,
-       -3337,          -3327,          -3316,          -3305,
-       -3294,          -3283,          -3272,          -3262,
-       -3251,          -3240,          -3229,          -3218,
-       -3207,          -3197,          -3185,          -3175,
-       -3164,          -3153,          -3142,          -3132,
-       -3121,          -3110,          -3099,          -3088,
-       -3078,          -3067,          -3056,          -3045,
-       -3035,          -3024,          -3013,          -3003,
-       -2992,          -2981,          -2970,          -2960,
-       -2949,          -2938,          -2928,          -2917,
-       -2906,          -2895,          -2885,          -2874,
-       -2864,          -2853,          -2842,          -2832,
-       -2821,          -2810,          -2800,          -2789,
-       -2778,          -2768,          -2757,          -2747,
-       -2736,          -2725,          -2715,          -2704,
-       -2694,          -2683,          -2673,          -2662,
-       -2651,          -2641,          -2630,          -2620,
-       -2609,          -2599,          -2588,          -2578,
-       -2567,          -2556,          -2546,          -2535,
-       -2525,          -2515,          -2504,          -2493,
-       -2483,          -2472,          -2462,          -2451,
-       -2441,          -2431,          -2420,          -2410,
-       -2399,          -2389,          -2378,          -2367,
-       -2357,          -2347,          -2336,          -2326,
-       -2315,          -2305,          -2295,          -2284,
-       -2274,          -2263,          -2253,          -2243,
-       -2232,          -2222,          -2211,          -2201,
-       -2191,          -2180,          -2170,          -2159,
-       -2149,          -2139,          -2128,          -2118,
-       -2107,          -2097,          -2087,          -2076,
-       -2066,          -2056,          -2046,          -2035,
-       -2025,          -2014,          -2004,          -1994,
-       -1983,          -1973,          -1963,          -1953,
-       -1942,          -1932,          -1921,          -1911,
-       -1901,          -1891,          -1880,          -1870,
-       -1860,          -1849,          -1839,          -1829,
-       -1819,          -1808,          -1798,          -1788,
-       -1778,          -1767,          -1757,          -1747,
-       -1736,          -1726,          -1716,          -1706,
-       -1695,          -1685,          -1675,          -1665,
-       -1654,          -1644,          -1634,          -1624,
-       -1613,          -1603,          -1593,          -1583,
-       -1573,          -1563,          -1552,          -1542,
-       -1532,          -1522,          -1511,          -1501,
-       -1491,          -1481,          -1471,          -1461,
-       -1450,          -1440,          -1430,          -1420,
-       -1409,          -1400,          -1389,          -1379,
-       -1369,          -1359,          -1348,          -1339,
-       -1328,          -1318,          -1308,          -1298,
-       -1288,          -1278,          -1267,          -1257,
-       -1247,          -1237,          -1227,          -1217,
-       -1207,          -1196,          -1186,          -1176,
-       -1166,          -1156,          -1146,          -1135,
-       -1126,          -1115,          -1105,          -1095,
-       -1085,          -1075,          -1065,          -1055,
-       -1044,          -1034,          -1024,          -1014,
-       -1004,          -994,           -984,           -974,
-       -964,           -954,           -944,           -933,
-       -923,           -913,           -903,           -893,
-       -883,           -873,           -863,           -853,
-       -843,           -833,           -822,           -812,
-       -802,           -792,           -782,           -772,
-       -762,           -752,           -742,           -732,
-       -722,           -712,           -702,           -691,
-       -682,           -671,           -662,           -651,
-       -641,           -631,           -621,           -611,
-       -601,           -591,           -581,           -571,
-       -561,           -551,           -541,           -531,
-       -521,           -511,           -501,           -491,
-       -480,           -471,           -460,           -451,
-       -440,           -430,           -420,           -410,
-       -400,           -390,           -380,           -370,
-       -360,           -350,           -340,           -330,
-       -320,           -310,           -300,           -290,
-       -280,           -270,           -260,           -250,
-       -240,           -230,           -220,           -210,
-       -199,           -190,           -179,           -170,
-       -159,           -150,           -139,           -129,
-       -119,           -109,           -99,            -89,
-       -79,            -69,            -59,            -49,
-       -39,            -29,            -19,            -9,
-       1,              11,             21,             31,
-       41,             51,             61,             71,
-       81,             91,             101,            111,
-       121,            131,            141,            152,
-       161,            172,            181,            192,
-       202,            212,            222,            232,
-       242,            252,            262,            272,
-       282,            292,            302,            312,
-       322,            332,            342,            352,
-       362,            372,            382,            392,
-       402,            412,            422,            433,
-       442,            453,            462,            473,
-       483,            493,            503,            513,
-       523,            533,            543,            553,
-       563,            573,            583,            593,
-       603,            613,            623,            633,
-       643,            653,            664,            673,
-       684,            694,            704,            714,
-       724,            734,            744,            754,
-       764,            774,            784,            794,
-       804,            815,            825,            835,
-       845,            855,            865,            875,
-       885,            895,            905,            915,
-       925,            936,            946,            956,
-       966,            976,            986,            996,
-       1006,           1016,           1026,           1037,
-       1047,           1057,           1067,           1077,
-       1087,           1097,           1107,           1117,
-       1128,           1138,           1148,           1158,
-       1168,           1178,           1188,           1198,
-       1209,           1219,           1229,           1239,
-       1249,           1259,           1269,           1280,
-       1290,           1300,           1310,           1320,
-       1330,           1341,           1351,           1361,
-       1371,           1381,           1391,           1402,
-       1412,           1422,           1432,           1442,
-       1452,           1463,           1473,           1483,
-       1493,           1503,           1513,           1524,
-       1534,           1544,           1554,           1565,
-       1575,           1585,           1595,           1606,
-       1616,           1626,           1636,           1647,
-       1656,           1667,           1677,           1687,
-       1697,           1708,           1718,           1729,
-       1739,           1749,           1759,           1769,
-       1780,           1790,           1800,           1810,
-       1821,           1831,           1841,           1851,
-       1862,           1872,           1883,           1893,
-       1903,           1913,           1923,           1934,
-       1944,           1955,           1965,           1975,
-       1985,           1996,           2006,           2016,
-       2027,           2037,           2048,           2058,
-       2068,           2079,           2089,           2099,
-       2110,           2120,           2130,           2141,
-       2151,           2161,           2172,           2182,
-       2193,           2203,           2213,           2224,
-       2234,           2245,           2255,           2265,
-       2276,           2286,           2297,           2307,
-       2318,           2328,           2338,           2349,
-       2359,           2370,           2380,           2391,
-       2401,           2412,           2422,           2433,
-       2443,           2454,           2464,           2475,
-       2485,           2496,           2506,           2517,
-       2527,           2537,           2548,           2559,
-       2569,           2580,           2590,           2601,
-       2612,           2622,           2632,           2643,
-       2654,           2664,           2675,           2685,
-       2696,           2707,           2717,           2728,
-       2738,           2749,           2759,           2770,
-       2781,           2791,           2802,           2813,
-       2823,           2834,           2845,           2855,
-       2866,           2877,           2887,           2898,
-       2909,           2919,           2930,           2941,
-       2951,           2962,           2973,           2984,
-       2994,           3005,           3015,           3027,
-       3037,           3048,           3058,           3069,
-       3080,           3091,           3101,           3113,
-       3123,           3134,           3145,           3156,
-       3166,           3177,           3188,           3199,
-       3210,           3220,           3231,           3242,
-       3253,           3264,           3275,           3285,
-       3296,           3307,           3318,           3329,
-       3340,           3351,           3362,           3373,
-       3384,           3394,           3405,           3416,
-       3427,           3438,           3449,           3460,
-       3471,           3482,           3493,           3504,
-       3515,           3526,           3537,           3548,
-       3559,           3570,           3581,           3592,
-       3603,           3614,           3625,           3636,
-       3647,           3659,           3670,           3681,
-       3692,           3703,           3714,           3725,
-       3736,           3747,           3758,           3770,
-       3781,           3792,           3803,           3814,
-       3825,           3837,           3848,           3859,
-       3870,           3881,           3893,           3904,
-       3915,           3926,           3937,           3949,
-       3960,           3971,           3983,           3994,
-       4005,           4017,           4028,           4039,
-       4051,           4062,           4073,           4085,
-       4096,           4107,           4119,           4130,
-       4141,           4153,           4164,           4175,
-       4187,           4198,           4210,           4221,
-       4233,           4244,           4256,           4267,
-       4279,           4290,           4302,           4313,
-       4325,           4336,           4348,           4359,
-       4371,           4382,           4394,           4406,
-       4417,           4429,           4440,           4452,
-       4464,           4475,           4487,           4499,
-       4510,           4522,           4533,           4545,
-       4557,           4569,           4581,           4592,
-       4604,           4616,           4627,           4639,
-       4651,           4663,           4674,           4686,
-       4698,           4710,           4722,           4734,
-       4746,           4758,           4769,           4781,
-       4793,           4805,           4817,           4829,
-       4841,           4853,           4865,           4877,
-       4889,           4900,           4913,           4925,
-       4936,           4949,           4961,           4973,
-       4985,           4997,           5009,           5021,
-       5033,           5045,           5057,           5070,
-       5081,           5094,           5106,           5118,
-       5130,           5143,           5155,           5167,
-       5179,           5191,           5204,           5216,
-       5228,           5240,           5253,           5265,
-       5278,           5290,           5302,           5315,
-       5327,           5340,           5352,           5364,
-       5377,           5389,           5401,           5414,
-       5426,           5439,           5451,           5464,
-       5476,           5489,           5502,           5514,
-       5527,           5539,           5552,           5564,
-       5577,           5590,           5603,           5615,
-       5628,           5641,           5653,           5666,
-       5679,           5691,           5704,           5717,
-       5730,           5743,           5756,           5768,
-       5781,           5794,           5807,           5820,
-       5833,           5846,           5859,           5872,
-       5885,           5897,           5911,           5924,
-       5937,           5950,           5963,           5976,
-       5989,           6002,           6015,           6028,
-       6042,           6055,           6068,           6081,
-       6094,           6108,           6121,           6134,
-       6147,           6160,           6174,           6187,
-       6201,           6214,           6227,           6241,
-       6254,           6267,           6281,           6294,
-       6308,           6321,           6335,           6348,
-       6362,           6375,           6389,           6403,
-       6416,           6430,           6443,           6457,
-       6471,           6485,           6498,           6512,
-       6526,           6540,           6554,           6567,
-       6581,           6595,           6609,           6623,
-       6637,           6651,           6665,           6679,
-       6692,           6706,           6721,           6735,
-       6749,           6763,           6777,           6791,
-       6805,           6819,           6833,           6848,
-       6862,           6876,           6890,           6905,
-       6919,           6933,           6948,           6962,
-       6976,           6991,           7005,           7020,
-       7034,           7049,           7064,           7078,
-       7093,           7107,           7122,           7136,
-       7151,           7166,           7180,           7195,
-       7210,           7225,           7240,           7254,
-       7269,           7284,           7299,           7314,
-       7329,           7344,           7359,           7374,
-       7389,           7404,           7419,           7434,
-       7449,           7465,           7480,           7495,
-       7510,           7526,           7541,           7556,
-       7571,           7587,           7602,           7618,
-       7633,           7648,           7664,           7680,
-       7695,           7711,           7726,           7742,
-       7758,           7773,           7789,           7805,
-       7821,           7836,           7852,           7868,
-       7884,           7900,           7916,           7932,
-       7948,           7964,           7981,           7997,
-       8013,           8029,           8045,           8061,
-       8078,           8094,           8110,           8127,
-       8143,           8160,           8176,           8193,
-       8209,           8226,           8242,           8259,
-       8276,           8292,           8309,           8326,
-       8343,           8360,           8377,           8394,
-       8410,           8428,           8444,           8462,
-       8479,           8496,           8513,           8530,
-       8548,           8565,           8582,           8600,
-       8617,           8634,           8652,           8670,
-       8687,           8704,           8722,           8740,
-       8758,           8775,           8793,           8811,
-       8829,           8847,           8865,           8883,
-       8901,           8919,           8937,           8955,
-       8974,           8992,           9010,           9029,
-       9047,           9066,           9084,           9103,
-       9121,           9140,           9159,           9177,
-       9196,           9215,           9234,           9253,
-       9272,           9291,           9310,           9329,
-       9349,           9368,           9387,           9406,
-       9426,           9445,           9465,           9484,
-       9504,           9524,           9544,           9563,
-       9583,           9603,           9623,           9643,
-       9663,           9683,           9703,           9723,
-       9744,           9764,           9785,           9805,
-       9826,           9846,           9867,           9888,
-       9909,           9930,           9950,           9971,
-       9993,           10013,          10035,          10056,
-       10077,          10099,          10120,          10142,
-       10163,          10185,          10207,          10229,
-       10251,          10273,          10294,          10317,
-       10339,          10361,          10384,          10406,
-       10428,          10451,          10474,          10496,
-       10519,          10542,          10565,          10588,
-       10612,          10635,          10658,          10682,
-       10705,          10729,          10752,          10776,
-       10800,          10824,          10848,          10872,
-       10896,          10921,          10945,          10969,
-       10994,          11019,          11044,          11069,
-       11094,          11119,          11144,          11169,
-       11195,          11221,          11246,          11272,
-       11298,          11324,          11350,          11376,
-       11402,          11429,          11456,          11482,
-       11509,          11536,          11563,          11590,
-       11618,          11645,          11673,          11701,
-       11728,          11756,          11785,          11813,
-       11842,          11870,          11899,          11928,
-       11957,          11986,          12015,          12045,
-       12074,          12104,          12134,          12164,
-       12194,          12225,          12255,          12286,
-       12317,          12348,          12380,          12411,
-       12443,          12475,          12507,          12539,
-       12571,          12604,          12637,          12670,
-       12703,          12737,          12771,          12804,
-       12839,          12873,          12907,          12942,
-       12977,          13013,          13048,          13084,
-       13120,          13156,          13192,          13229,
-       13267,          13304,          13341,          13379,
-       13418,          13456,          13495,          13534,
-       13573,          13613,          13653,          13693,
-       13734,          13775,          13817,          13858,
-       13901,          13943,          13986,          14029,
-       14073,          14117,          14162,          14206,
-       14252,          14297,          14343,          14390,
-       14437,          14485,          14533,          14582,
-       14631,          14680,          14731,          14782,
-       14833,          14885,          14937,          14991,
-       15044,          15099,          15154,          15210,
-       15266,          15324,          15382,          15441,
-       15500,          15561,          15622,          15684,
-       15747,          15811,          15877,          15943,
-       16010,          16078,          16148,          16218,
-       16290,          16363,          16437,          16513,
-       16590,          16669,          16749,          16831,
-       16915,          17000,          17088,          17177,
-       17268,          17362,          17458,          17556,
-       17657,          17761,          17868,          17977,
-       18090,          18207,          18328,          18452,
-       18581,          18715,          18854,          18998,
-       19149,          19307,          19472,          19645,
-       19828,          20021,          20226,          20444,
-       20678,          20930,          21204,          21503,
-       21835,          22206,          22630,          23124,
-       23721,          24478,          25529,          27316,
-};
-
-/* tabledist - return a pseudo-randomly distributed value with mean mu and
- * std deviation sigma.  Uses table lookup to approximate the desired
- * distribution, and a uniformly-distributed pseudo-random source.
- */
-static inline int tabledist(int mu, int sigma)
-{
-       int x;
-       int index;
-       int sigmamod, sigmadiv;
-
-       if (sigma == 0)
-               return mu;
-
-       index = (net_random() & (TABLESIZE-1));
-       sigmamod = sigma%TABLEFACTOR;
-       sigmadiv = sigma/TABLEFACTOR;
-       x = sigmamod*disttable[index];
-
-       if (x >= 0)
-               x += TABLEFACTOR/2;
-       else
-               x -= TABLEFACTOR/2;
-
-       x /= TABLEFACTOR;
-       x += sigmadiv*disttable[index];
-       x += mu;
-       return x;
-}
-
-/* Enqueue packets with underlying discipline (fifo)
- * but mark them with current time first.
- */
-static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-       struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
-       psched_time_t now;
-       long delay;
-
-       pr_debug("netem_enqueue skb=%p @%lu\n", skb, jiffies);
-
-       /* Random packet drop 0 => none, ~0 => all */
-       if (q->loss && q->loss >= net_random()) {
-               sch->stats.drops++;
-               return 0;       /* lie about loss so TCP doesn't know */
-       }
-
-
-       /* If doing simple delay then gap == 0 so all packets
-        * go into the delayed holding queue
-        * otherwise if doing out of order only "1 out of gap"
-        * packets will be delayed.
-        */
-       if (q->counter < q->gap) {
-               int ret;
-
-               ++q->counter;
-               ret = q->qdisc->enqueue(skb, q->qdisc);
-               if (ret)
-                       sch->stats.drops++;
-               return ret;
-       }
-       
-       q->counter = 0;
-       
-       PSCHED_GET_TIME(now);
-       if (q->jitter) 
-               delay = tabledist(q->latency, q->jitter);
-       else
-               delay = q->latency;
-
-       PSCHED_TADD2(now, delay, cb->time_to_send);
-       
-       /* Always queue at tail to keep packets in order */
-       if (likely(q->delayed.qlen < q->limit)) {
-               __skb_queue_tail(&q->delayed, skb);
-               sch->q.qlen++;
-               sch->stats.bytes += skb->len;
-               sch->stats.packets++;
-               return 0;
-       }
-
-       sch->stats.drops++;
-       kfree_skb(skb);
-       return NET_XMIT_DROP;
-}
-
-/* Requeue packets but don't change time stamp */
-static int netem_requeue(struct sk_buff *skb, struct Qdisc *sch)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-       int ret;
-
-       if ((ret = q->qdisc->ops->requeue(skb, q->qdisc)) == 0)
-               sch->q.qlen++;
-
-       return ret;
-}
-
-static unsigned int netem_drop(struct Qdisc* sch)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-       unsigned int len;
-
-       if ((len = q->qdisc->ops->drop(q->qdisc)) != 0) {
-               sch->q.qlen--;
-               sch->stats.drops++;
-       }
-       return len;
-}
-
-/* Dequeue packet.
- *  Move all packets that are ready to send from the delay holding
- *  list to the underlying qdisc, then just call dequeue
- */
-static struct sk_buff *netem_dequeue(struct Qdisc *sch)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-       struct sk_buff *skb;
-       psched_time_t now;
-
-       PSCHED_GET_TIME(now);
-       while ((skb = skb_peek(&q->delayed)) != NULL) {
-               const struct netem_skb_cb *cb
-                       = (const struct netem_skb_cb *)skb->cb;
-               long delay 
-                       = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-               pr_debug("netem_dequeue: delay queue %p@%lu %ld\n",
-                        skb, jiffies, delay);
-
-               /* if more time remaining? */
-               if (delay > 0) {
-                       mod_timer(&q->timer, jiffies + delay);
-                       break;
-               }
-               __skb_unlink(skb, &q->delayed);
-
-               if (q->qdisc->enqueue(skb, q->qdisc))
-                       sch->stats.drops++;
-       }
-
-       skb = q->qdisc->dequeue(q->qdisc);
-       if (skb) 
-               sch->q.qlen--;
-       return skb;
-}
-
-static void netem_watchdog(unsigned long arg)
-{
-       struct Qdisc *sch = (struct Qdisc *)arg;
-
-       pr_debug("netem_watchdog: fired @%lu\n", jiffies);
-       netif_schedule(sch->dev);
-}
-
-static void netem_reset(struct Qdisc *sch)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-
-       qdisc_reset(q->qdisc);
-       skb_queue_purge(&q->delayed);
-
-       sch->q.qlen = 0;
-       del_timer_sync(&q->timer);
-}
-
-static int set_fifo_limit(struct Qdisc *q, int limit)
-{
-        struct rtattr *rta;
-       int ret = -ENOMEM;
-
-       rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
-       if (rta) {
-               rta->rta_type = RTM_NEWQDISC;
-               rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt)); 
-               ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
-               
-               ret = q->ops->change(q, rta);
-               kfree(rta);
-       }
-       return ret;
-}
-
-static int netem_change(struct Qdisc *sch, struct rtattr *opt)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-       struct tc_netem_qopt *qopt = RTA_DATA(opt);
-       struct Qdisc *child;
-       int ret;
-
-       if (opt->rta_len < RTA_LENGTH(sizeof(*qopt)))
-               return -EINVAL;
-
-       child = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
-       if (!child)
-               return -EINVAL;
-
-       ret = set_fifo_limit(child, qopt->limit);
-       if (ret) {
-               qdisc_destroy(child);
-               return ret;
-       }
-
-       sch_tree_lock(sch);
-       if (child) {
-               child = xchg(&q->qdisc, child);
-               if (child != &noop_qdisc)
-                       qdisc_destroy(child);
-       
-               q->latency = qopt->latency;
-               q->jitter = qopt->jitter;
-               q->limit = qopt->limit;
-               q->gap = qopt->gap;
-               q->loss = qopt->loss;
-       }
-       sch_tree_unlock(sch);
-
-       return 0;
-}
-
-static int netem_init(struct Qdisc *sch, struct rtattr *opt)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-
-       if (!opt)
-               return -EINVAL;
-
-       skb_queue_head_init(&q->delayed);
-       q->qdisc = &noop_qdisc;
-
-       init_timer(&q->timer);
-       q->timer.function = netem_watchdog;
-       q->timer.data = (unsigned long) sch;
-       q->counter = 0;
-
-       return netem_change(sch, opt);
-}
-
-static void netem_destroy(struct Qdisc *sch)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-
-       del_timer_sync(&q->timer);
-       qdisc_destroy(q->qdisc);
-}
-
-static int netem_dump(struct Qdisc *sch, struct sk_buff *skb)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-       unsigned char    *b = skb->tail;
-       struct tc_netem_qopt qopt;
-
-       qopt.latency = q->latency;
-       qopt.jitter = q->jitter;
-       qopt.limit = q->limit;
-       qopt.loss = q->loss;
-       qopt.gap = q->gap;
-
-       RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
-
-       return skb->len;
-
-rtattr_failure:
-       skb_trim(skb, b - skb->data);
-       return -1;
-}
-
-static int netem_dump_class(struct Qdisc *sch, unsigned long cl,
-                         struct sk_buff *skb, struct tcmsg *tcm)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-
-       if (cl != 1)    /* only one class */
-               return -ENOENT;
-
-       tcm->tcm_handle |= TC_H_MIN(1);
-       tcm->tcm_info = q->qdisc->handle;
-
-       return 0;
-}
-
-static int netem_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
-                    struct Qdisc **old)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-
-       if (new == NULL)
-               new = &noop_qdisc;
-
-       sch_tree_lock(sch);
-       *old = xchg(&q->qdisc, new);
-       qdisc_reset(*old);
-       sch->q.qlen = 0;
-       sch_tree_unlock(sch);
-
-       return 0;
-}
-
-static struct Qdisc *netem_leaf(struct Qdisc *sch, unsigned long arg)
-{
-       struct netem_sched_data *q = qdisc_priv(sch);
-       return q->qdisc;
-}
-
-static unsigned long netem_get(struct Qdisc *sch, u32 classid)
-{
-       return 1;
-}
-
-static void netem_put(struct Qdisc *sch, unsigned long arg)
-{
-}
-
-static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid, 
-                           struct rtattr **tca, unsigned long *arg)
-{
-       return -ENOSYS;
-}
-
-static int netem_delete(struct Qdisc *sch, unsigned long arg)
-{
-       return -ENOSYS;
-}
-
-static void netem_walk(struct Qdisc *sch, struct qdisc_walker *walker)
-{
-       if (!walker->stop) {
-               if (walker->count >= walker->skip)
-                       if (walker->fn(sch, 1, walker) < 0) {
-                               walker->stop = 1;
-                               return;
-                       }
-               walker->count++;
-       }
-}
-
-static struct tcf_proto **netem_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
-       return NULL;
-}
-
-static struct Qdisc_class_ops netem_class_ops = {
-       .graft          =       netem_graft,
-       .leaf           =       netem_leaf,
-       .get            =       netem_get,
-       .put            =       netem_put,
-       .change         =       netem_change_class,
-       .delete         =       netem_delete,
-       .walk           =       netem_walk,
-       .tcf_chain      =       netem_find_tcf,
-       .dump           =       netem_dump_class,
-};
-
-static struct Qdisc_ops netem_qdisc_ops = {
-       .id             =       "netem",
-       .cl_ops         =       &netem_class_ops,
-       .priv_size      =       sizeof(struct netem_sched_data),
-       .enqueue        =       netem_enqueue,
-       .dequeue        =       netem_dequeue,
-       .requeue        =       netem_requeue,
-       .drop           =       netem_drop,
-       .init           =       netem_init,
-       .reset          =       netem_reset,
-       .destroy        =       netem_destroy,
-       .change         =       netem_change,
-       .dump           =       netem_dump,
-       .owner          =       THIS_MODULE,
-};
-
-
-static int __init netem_module_init(void)
-{
-       return register_qdisc(&netem_qdisc_ops);
-}
-static void __exit netem_module_exit(void)
-{
-       unregister_qdisc(&netem_qdisc_ops);
-}
-module_init(netem_module_init)
-module_exit(netem_module_exit)
-MODULE_LICENSE("GPL");
index 275d8cf..e28ec6a 100644 (file)
@@ -68,6 +68,7 @@
 #include <linux/netdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <net/tux.h>
 #include <linux/wanrouter.h>
 #include <linux/if_bridge.h>
 #include <linux/init.h>
@@ -93,6 +94,8 @@
 
 #include <net/sock.h>
 #include <linux/netfilter.h>
+#include <linux/vs_base.h>
+#include <linux/vs_socket.h>
 
 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
@@ -120,7 +123,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
  *     in the operation structures but are done directly via the socketcall() multiplexor.
  */
 
-static struct file_operations socket_file_ops = {
+struct file_operations socket_file_ops = {
        .owner =        THIS_MODULE,
        .llseek =       no_llseek,
        .aio_read =     sock_aio_read,
@@ -287,7 +290,7 @@ static struct inode *sock_alloc_inode(struct super_block *sb)
        ei->socket.ops = NULL;
        ei->socket.sk = NULL;
        ei->socket.file = NULL;
-       ei->socket.passcred = 0;
+       ei->socket.flags = 0;
 
        return &ei->vfs_inode;
 }
@@ -362,52 +365,63 @@ static struct dentry_operations sockfs_dentry_operations = {
  *     but we take care of internal coherence yet.
  */
 
-int sock_map_fd(struct socket *sock)
+struct file * sock_map_file(struct socket *sock)
 {
-       int fd;
+       struct file *file;
        struct qstr this;
        char name[32];
 
-       /*
-        *      Find a file descriptor suitable for return to the user. 
-        */
+       file = get_empty_filp();
 
-       fd = get_unused_fd();
-       if (fd >= 0) {
-               struct file *file = get_empty_filp();
+       if (!file)
+               return ERR_PTR(-ENFILE);
 
-               if (!file) {
-                       put_unused_fd(fd);
-                       fd = -ENFILE;
-                       goto out;
-               }
+       sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
+       this.name = name;
+       this.len = strlen(name);
+       this.hash = SOCK_INODE(sock)->i_ino;
 
-               sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
-               this.name = name;
-               this.len = strlen(name);
-               this.hash = SOCK_INODE(sock)->i_ino;
+       file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
+       if (!file->f_dentry) {
+               put_filp(file);
+               return ERR_PTR(-ENOMEM);
+       }
+       file->f_dentry->d_op = &sockfs_dentry_operations;
+       d_add(file->f_dentry, SOCK_INODE(sock));
+       file->f_vfsmnt = mntget(sock_mnt);
+file->f_mapping = file->f_dentry->d_inode->i_mapping;
 
-               file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
-               if (!file->f_dentry) {
-                       put_filp(file);
-                       put_unused_fd(fd);
-                       fd = -ENOMEM;
-                       goto out;
-               }
-               file->f_dentry->d_op = &sockfs_dentry_operations;
-               d_add(file->f_dentry, SOCK_INODE(sock));
-               file->f_vfsmnt = mntget(sock_mnt);
-               file->f_mapping = file->f_dentry->d_inode->i_mapping;
+       if (sock->file)
+               BUG();
+       sock->file = file;
+       file->f_op = SOCK_INODE(sock)->i_fop = &socket_file_ops;
+       file->f_mode = FMODE_READ | FMODE_WRITE;
+       file->f_flags = O_RDWR;
+       file->f_pos = 0;
 
-               sock->file = file;
-               file->f_op = SOCK_INODE(sock)->i_fop = &socket_file_ops;
-               file->f_mode = FMODE_READ | FMODE_WRITE;
-               file->f_flags = O_RDWR;
-               file->f_pos = 0;
-               fd_install(fd, file);
-       }
+       return file;
+}
 
-out:
+int sock_map_fd(struct socket *sock)
+{
+       int fd;
+       struct file *file;
+       /*
+        *      Find a file descriptor suitable for return to the user. 
+        */
+  
+       fd = get_unused_fd();
+       if (fd < 0)
+               return fd;
+  
+       file = sock_map_file(sock);
+       if (IS_ERR(file)) {
+               put_unused_fd(fd);
+               return PTR_ERR(file);
+       }
+       fd_install(fd, file);
+  
        return fd;
 }
 
@@ -531,7 +545,7 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
                                 struct msghdr *msg, size_t size)
 {
        struct sock_iocb *si = kiocb_to_siocb(iocb);
-       int err;
+       int err, len;
 
        si->sock = sock;
        si->scm = NULL;
@@ -542,7 +556,21 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
        if (err)
                return err;
 
-       return sock->ops->sendmsg(iocb, sock, msg, size);
+       len = sock->ops->sendmsg(iocb, sock, msg, size);
+       if (sock->sk) {
+               if (len == size)
+                       vx_sock_send(sock->sk, size);
+               else
+                       vx_sock_fail(sock->sk, size);
+       }
+       vxdprintk(VXD_CBIT(net, 7),
+               "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d",
+               sock, sock->sk,
+               (sock->sk)?sock->sk->sk_nx_info:0,
+               (sock->sk)?sock->sk->sk_vx_info:0,
+               (sock->sk)?sock->sk->sk_xid:0,
+               (unsigned int)size, len);
+       return len;
 }
 
 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
@@ -580,7 +608,7 @@ int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock, 
                                 struct msghdr *msg, size_t size, int flags)
 {
-       int err;
+       int err, len;
        struct sock_iocb *si = kiocb_to_siocb(iocb);
 
        si->sock = sock;
@@ -593,7 +621,17 @@ static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
        if (err)
                return err;
 
-       return sock->ops->recvmsg(iocb, sock, msg, size, flags);
+       len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
+       if ((len >= 0) && sock->sk)
+               vx_sock_recv(sock->sk, len);
+       vxdprintk(VXD_CBIT(net, 7),
+               "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d",
+               sock, sock->sk,
+               (sock->sk)?sock->sk->sk_nx_info:0,
+               (sock->sk)?sock->sk->sk_vx_info:0,
+               (sock->sk)?sock->sk->sk_xid:0,
+               (unsigned int)size, len);
+       return len;
 }
 
 int sock_recvmsg(struct socket *sock, struct msghdr *msg, 
@@ -1040,6 +1078,8 @@ static int sock_fasync(int fd, struct file *filp, int on)
        }
 
 out:
+       if (sock->sk != sk)
+               BUG();
        release_sock(sock->sk);
        return 0;
 }
@@ -1085,6 +1125,10 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
        if (type < 0 || type >= SOCK_MAX)
                return -EINVAL;
 
+       /* disable IPv6 inside vservers for now */
+       if (family == PF_INET6 && !vx_check(0, VX_ADMIN))
+               return -EAFNOSUPPORT;
+
        /* Compatibility.
 
           This uglymoron is moved from INET layer to here to avoid
@@ -1193,6 +1237,7 @@ asmlinkage long sys_socket(int family, int type, int protocol)
        if (retval < 0)
                goto out;
 
+       set_bit(SOCK_USER_SOCKET, &sock->flags);
        retval = sock_map_fd(sock);
        if (retval < 0)
                goto out_release;
@@ -1223,10 +1268,12 @@ asmlinkage long sys_socketpair(int family, int type, int protocol, int __user *u
        err = sock_create(family, type, protocol, &sock1);
        if (err < 0)
                goto out;
+       set_bit(SOCK_USER_SOCKET, &sock1->flags);
 
        err = sock_create(family, type, protocol, &sock2);
        if (err < 0)
                goto out_release_1;
+       set_bit(SOCK_USER_SOCKET, &sock2->flags);
 
        err = sock1->ops->socketpair(sock1, sock2);
        if (err < 0) 
@@ -2069,6 +2116,51 @@ void __init sock_init(void)
 #endif
 }
 
+int tux_Dprintk;
+int tux_TDprintk;
+
+#ifdef CONFIG_TUX_MODULE
+
+asmlinkage long (*sys_tux_ptr) (unsigned int action, user_req_t *u_info) = NULL;
+
+struct module *tux_module = NULL;
+spinlock_t tux_module_lock = SPIN_LOCK_UNLOCKED;
+
+asmlinkage long sys_tux (unsigned int action, user_req_t *u_info)
+{
+       int ret;
+
+       if (current->tux_info)
+               return sys_tux_ptr(action, u_info);
+
+       ret = -ENOSYS;
+       spin_lock(&tux_module_lock);
+       if (!tux_module)
+               goto out_unlock;
+       if (!try_module_get(tux_module))
+               goto out_unlock;
+       spin_unlock(&tux_module_lock);
+
+       if (!sys_tux_ptr)
+               TUX_BUG();
+       ret = sys_tux_ptr(action, u_info);
+
+       spin_lock(&tux_module_lock);
+       module_put(tux_module);
+out_unlock:
+       spin_unlock(&tux_module_lock);
+
+       return ret;
+}
+
+EXPORT_SYMBOL_GPL(tux_module);
+EXPORT_SYMBOL_GPL(tux_module_lock);
+EXPORT_SYMBOL_GPL(sys_tux_ptr);
+
+EXPORT_SYMBOL_GPL(tux_Dprintk);
+EXPORT_SYMBOL_GPL(tux_TDprintk);
+
+#endif
 #ifdef CONFIG_PROC_FS
 void socket_seq_show(struct seq_file *seq)
 {
index 315b162..2fd2975 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/socket.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/spinlock.h>
+#include <linux/vserver/xid.h>
 
 #ifdef RPC_DEBUG
 # define RPCDBG_FACILITY       RPCDBG_AUTH
@@ -261,6 +262,7 @@ rpcauth_lookupcred(struct rpc_auth *auth, int taskflags)
        get_group_info(current->group_info);
        acred.uid = current->fsuid;
        acred.gid = current->fsgid;
+       acred.xid = current->xid;
        acred.group_info = current->group_info;
 
        dprintk("RPC:     looking up %s cred\n",
@@ -280,6 +282,7 @@ rpcauth_bindcred(struct rpc_task *task)
        get_group_info(current->group_info);
        acred.uid = current->fsuid;
        acred.gid = current->fsgid;
+       acred.xid = current->xid;
        acred.group_info = current->group_info;
 
        dprintk("RPC: %4d looking up %s cred\n",
index edbe8f8..294875e 100644 (file)
 #include <linux/in.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/auth.h>
+#include <linux/vserver/xid.h>
 
 #define NFS_NGROUPS    16
 
 struct unx_cred {
        struct rpc_cred         uc_base;
        gid_t                   uc_gid;
+       xid_t                   uc_xid;
        uid_t                   uc_puid;                /* process uid */
        gid_t                   uc_pgid;                /* process gid */
+       xid_t                   uc_pxid;                /* process xid */
        gid_t                   uc_gids[NFS_NGROUPS];
 };
 #define uc_uid                 uc_base.cr_uid
@@ -80,6 +83,7 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
        if (flags & RPC_TASK_ROOTCREDS) {
                cred->uc_uid = cred->uc_puid = 0;
                cred->uc_gid = cred->uc_pgid = 0;
+               cred->uc_xid = cred->uc_pxid = current->xid;
                cred->uc_gids[0] = NOGROUP;
        } else {
                int groups = acred->group_info->ngroups;
@@ -88,8 +92,10 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
 
                cred->uc_uid = acred->uid;
                cred->uc_gid = acred->gid;
+               cred->uc_xid = acred->xid;
                cred->uc_puid = current->uid;
                cred->uc_pgid = current->gid;
+               cred->uc_pxid = current->xid;
                for (i = 0; i < groups; i++)
                        cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
                if (i < NFS_NGROUPS)
@@ -122,8 +128,10 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int taskflags)
 
                if (cred->uc_uid != acred->uid
                 || cred->uc_gid != acred->gid
+                || cred->uc_xid != acred->xid
                 || cred->uc_puid != current->uid
-                || cred->uc_pgid != current->gid)
+                || cred->uc_pgid != current->gid
+                || cred->uc_pxid != current->xid)
                        return 0;
 
                groups = acred->group_info->ngroups;
@@ -149,7 +157,7 @@ unx_marshal(struct rpc_task *task, u32 *p, int ruid)
        struct rpc_clnt *clnt = task->tk_client;
        struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
        u32             *base, *hold;
-       int             i;
+       int             i, tagxid;
 
        *p++ = htonl(RPC_AUTH_UNIX);
        base = p++;
@@ -159,14 +167,19 @@ unx_marshal(struct rpc_task *task, u32 *p, int ruid)
         * Copy the UTS nodename captured when the client was created.
         */
        p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
+       tagxid = task->tk_client->cl_tagxid;
 
        /* Note: we don't use real uid if it involves raising privilege */
        if (ruid && cred->uc_puid != 0 && cred->uc_pgid != 0) {
-               *p++ = htonl((u32) cred->uc_puid);
-               *p++ = htonl((u32) cred->uc_pgid);
+               *p++ = htonl((u32) XIDINO_UID(tagxid,
+                       cred->uc_puid, cred->uc_pxid));
+               *p++ = htonl((u32) XIDINO_GID(tagxid,
+                       cred->uc_pgid, cred->uc_pxid));
        } else {
-               *p++ = htonl((u32) cred->uc_uid);
-               *p++ = htonl((u32) cred->uc_gid);
+               *p++ = htonl((u32) XIDINO_UID(tagxid,
+                       cred->uc_uid, cred->uc_xid));
+               *p++ = htonl((u32) XIDINO_GID(tagxid,
+                       cred->uc_gid, cred->uc_xid));
        }
        hold = p++;
        for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
index e065779..441c5de 100644 (file)
@@ -214,17 +214,24 @@ out_no_clnt:
 int
 rpc_shutdown_client(struct rpc_clnt *clnt)
 {
+       wait_queue_t __wait;
+       init_waitqueue_entry(&__wait, current);
        dprintk("RPC: shutting down %s client for %s, tasks=%d\n",
                        clnt->cl_protname, clnt->cl_server,
                        atomic_read(&clnt->cl_users));
 
+       add_wait_queue(&destroy_wait, &__wait);
+       set_current_state(TASK_UNINTERRUPTIBLE);
        while (atomic_read(&clnt->cl_users) > 0) {
                /* Don't let rpc_release_client destroy us */
                clnt->cl_oneshot = 0;
                clnt->cl_dead = 0;
                rpc_killall_tasks(clnt);
-               sleep_on_timeout(&destroy_wait, 1*HZ);
+               schedule_timeout(1*HZ);
+               set_current_state(TASK_UNINTERRUPTIBLE);
        }
+       current->state = TASK_RUNNING;
+       remove_wait_queue(&destroy_wait, &__wait);
 
        if (atomic_read(&clnt->cl_users) < 0) {
                printk(KERN_ERR "RPC: rpc_shutdown_client clnt %p tasks=%d\n",
diff --git a/net/tux/Kconfig b/net/tux/Kconfig
new file mode 100644 (file)
index 0000000..8b6d624
--- /dev/null
@@ -0,0 +1,25 @@
+
+config TUX
+       tristate "TUX: Threaded linUX application protocol accelerator layer"
+       default y if INET=y
+       select ZLIB_DEFLATE
+       help
+         This is the TUX content-accelerator/server
+
+menu "TUX options"
+       depends on TUX
+
+config TUX_EXTCGI
+       bool "External CGI module"
+       default y
+
+config TUX_EXTENDED_LOG
+       bool "extended TUX logging format"
+       default n
+
+config TUX_DEBUG
+       bool "debug TUX"
+       default n
+
+endmenu
+
diff --git a/net/tux/Makefile b/net/tux/Makefile
new file mode 100644 (file)
index 0000000..fc0bbd0
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# Makefile for TUX
+#
+
+obj-$(CONFIG_TUX) += tux.o
+
+tux-y := accept.o input.o userspace.o cachemiss.o output.o \
+       redirect.o postpone.o logger.o proto_http.o proto_ftp.o \
+       proc.o main.o mod.o abuf.o times.o directory.o gzip.o
+
+tux-$(subst m,y,$(CONFIG_TUX_EXTCGI)) += cgi.o extcgi.o
+
diff --git a/net/tux/abuf.c b/net/tux/abuf.c
new file mode 100644 (file)
index 0000000..7447e69
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * abuf.c: async buffer-sending
+ */
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+char * get_abuf (tux_req_t *req, unsigned int max_size)
+{
+       threadinfo_t *ti = req->ti;
+       struct page *page;
+       char *buf;
+       unsigned int offset;
+       unsigned int left;
+
+       if (req->abuf.page || req->abuf.buf || req->abuf.size)
+               TUX_BUG();
+
+       if (max_size > PAGE_SIZE)
+               BUG();
+       offset = ti->header_offset;
+       if (offset > PAGE_SIZE)
+               TUX_BUG();
+       left = PAGE_SIZE - offset;
+       if (!max_size)
+               BUG();
+       page = ti->header_cache;
+       if ((left < max_size) || !page) {
+               while (!(page = alloc_pages(GFP_KERNEL, 0))) {
+                       if (net_ratelimit())
+                               printk(KERN_WARNING "tux: OOM in get_abuf()!\n");
+                       current->state = TASK_UNINTERRUPTIBLE;
+                       schedule_timeout(1);
+               }
+
+               if (ti->header_cache)
+                       __free_page(ti->header_cache);
+               ti->header_cache = page;
+               ti->header_offset = 0;
+               offset = 0;
+       }
+       buf = page_address(page) + offset;
+
+       if (!page)
+               BUG();
+       req->abuf.page = page;
+       req->abuf.buf = buf;
+       req->abuf.size = 0;
+       req->abuf.offset = offset;
+       req->abuf.flags = 0;
+       get_page(req->abuf.page);
+
+       return buf;
+}
+
+static void do_send_abuf (tux_req_t *req, int cachemiss);
+
+void send_abuf (tux_req_t *req, unsigned int size, unsigned long flags)
+{
+       threadinfo_t *ti = req->ti;
+
+       Dprintk("send_abuf(req: %p, sock: %p): %p(%p), size:%d, off:%d, flags:%08lx\n", req, req->sock, req->abuf.page, req->abuf.buf, size, req->abuf.offset, flags);
+
+       ti->header_offset += size;
+       if (ti->header_offset > PAGE_SIZE)
+               TUX_BUG();
+       if (req->abuf.offset + req->abuf.size > PAGE_SIZE)
+               TUX_BUG();
+
+       req->abuf.flags = flags | MSG_NOSIGNAL;
+       req->abuf.size = size;
+
+       add_tux_atom(req, do_send_abuf);
+}
+
+static void do_send_abuf (tux_req_t *req, int cachemiss)
+{
+       int ret;
+
+       if (req->magic != TUX_MAGIC)
+               TUX_BUG();
+       if (!req->sock)
+               TUX_BUG();
+       tcp_sk(req->sock->sk)->nonagle = 2;
+
+repeat:
+       Dprintk("do_send_abuf(%p,%d): %p(%p), size:%d, off:%d, flags:%08lx\n",
+                       req, cachemiss,
+                       req->abuf.page, req->abuf.buf, req->abuf.size,
+                       req->abuf.offset, req->abuf.flags);
+
+       if (tux_zerocopy_header)
+               ret = tcp_sendpage(req->sock, req->abuf.page,
+                       req->abuf.offset, req->abuf.size, req->abuf.flags);
+       else {
+               mm_segment_t oldmm;
+               oldmm = get_fs(); set_fs(KERNEL_DS);
+               ret = send_sync_buf(req, req->sock, req->abuf.buf,
+                       req->abuf.size, req->abuf.flags);
+               set_fs(oldmm);
+       }
+
+
+       Dprintk("do_send_abuf: ret: %d\n", ret);
+       if (!ret)
+               TUX_BUG();
+
+       if (ret < 0) {
+               if (ret != -EAGAIN) {
+                       TDprintk("ret: %d, req->error = TUX_ERROR_CONN_CLOSE.\n", ret);
+                       req->error = TUX_ERROR_CONN_CLOSE;
+                       req->atom_idx = 0;
+                       req->in_file.f_pos = 0;
+                       __free_page(req->abuf.page);
+                       memset(&req->abuf, 0, sizeof(req->abuf));
+                       zap_request(req, cachemiss);
+                       return;
+               }
+               add_tux_atom(req, do_send_abuf);
+               if (add_output_space_event(req, req->sock)) {
+                       del_tux_atom(req);
+                       goto repeat;
+               }
+               return;
+       }
+
+       req->abuf.buf += ret;
+       req->abuf.offset += ret;
+       req->abuf.size -= ret;
+
+       if ((int)req->abuf.size < 0)
+               TUX_BUG();
+       if (req->abuf.size > 0)
+               goto repeat;
+
+       Dprintk("DONE do_send_abuf: %p(%p), size:%d, off:%d, flags:%08lx\n",
+                       req->abuf.page, req->abuf.buf, req->abuf.size,
+                       req->abuf.offset, req->abuf.flags);
+
+       __free_page(req->abuf.page);
+
+       memset(&req->abuf, 0, sizeof(req->abuf));
+
+       add_req_to_workqueue(req);
+}
+
+void __send_async_message (tux_req_t *req, const char *message,
+                               int status, unsigned int size, int push)
+{
+       unsigned int flags;
+       char *buf;
+
+       Dprintk("TUX: sending %d reply (%d bytes)!\n", status, size);
+       Dprintk("request %p, reply: %s\n", req, message);
+       if (!size)
+               TUX_BUG();
+       buf = get_abuf(req, size);
+       memcpy(buf, message, size);
+
+       req->status = status;
+       flags = MSG_DONTWAIT;
+       if (!push)
+               flags |= MSG_MORE;
+       send_abuf(req, size, flags);
+       add_req_to_workqueue(req);
+}
diff --git a/net/tux/accept.c b/net/tux/accept.c
new file mode 100644 (file)
index 0000000..4e6fcc0
--- /dev/null
@@ -0,0 +1,859 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * accept.c: accept new connections, allocate requests
+ */
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+unsigned int tux_ack_pingpong = 1;
+unsigned int tux_push_all = 0;
+unsigned int tux_zerocopy_parse = 1;
+
+static int __idle_event (tux_req_t *req);
+static int __output_space_event (tux_req_t *req);
+
+struct socket * start_listening(tux_socket_t *listen, int nr)
+{
+       struct sockaddr_in sin;
+       struct socket *sock = NULL;
+       struct sock *sk;
+       struct tcp_opt *tp;
+       int err;
+       u16 port = listen->port;
+       u32 addr = listen->ip;
+       tux_proto_t *proto = listen->proto;
+
+       /* Create a listening socket: */
+
+       err = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
+       if (err) {
+               printk(KERN_ERR "TUX: error %d creating socket.\n", err);
+               goto error;
+       }
+
+       /* Bind the socket: */
+
+       sin.sin_family = AF_INET;
+       sin.sin_addr.s_addr = htonl(addr);
+       sin.sin_port = htons(port);
+
+       sk = sock->sk;
+       sk->sk_reuse = 1;
+       sock_set_flag(sk, SOCK_URGINLINE);
+
+       err = sock->ops->bind(sock, (struct sockaddr*)&sin, sizeof(sin));
+       if (err) {
+               printk(KERN_ERR "TUX: error %d binding socket. This means that probably some other process is (or was a short time ago) using addr %s://%d.%d.%d.%d:%d.\n", 
+                       err, proto->name, HIPQUAD(addr), port);
+               goto error;
+       }
+
+       tp = tcp_sk(sk);
+       Dprintk("listen sk accept_queue: %p/%p.\n",
+               tp->accept_queue, tp->accept_queue_tail);
+       tp->ack.pingpong = tux_ack_pingpong;
+
+       sock_reset_flag(sk, SOCK_LINGER);
+       sk->sk_lingertime = 0;
+       tp->linger2 = tux_keepalive_timeout * HZ;
+
+       if (proto->defer_accept && !tux_keepalive_timeout && tux_defer_accept)
+               tp->defer_accept = 1;
+
+       /* Now, start listening on the socket */
+
+       err = sock->ops->listen(sock, tux_max_backlog);
+       if (err) {
+               printk(KERN_ERR "TUX: error %d listening on socket.\n", err);
+               goto error;
+       }
+
+       printk(KERN_NOTICE "TUX: thread %d listens on %s://%d.%d.%d.%d:%d.\n",
+               nr, proto->name, HIPQUAD(addr), port);
+       return sock;
+
+error:
+       if (sock)
+               sock_release(sock);
+       return NULL;
+}
+
+static inline void __kfree_req (tux_req_t *req, threadinfo_t * ti)
+{
+       list_del(&req->all);
+       DEBUG_DEL_LIST(&req->all);
+       ti->nr_requests--;
+       kfree(req);
+}
+
+int flush_freequeue (threadinfo_t * ti)
+{
+       struct list_head *tmp;
+       unsigned long flags;
+       tux_req_t *req;
+       int count = 0;
+
+       spin_lock_irqsave(&ti->free_requests_lock,flags);
+       while (ti->nr_free_requests) {
+               ti->nr_free_requests--;
+               tmp = ti->free_requests.next;
+               req = list_entry(tmp, tux_req_t, free);
+               list_del(tmp);
+               DEBUG_DEL_LIST(tmp);
+               DEC_STAT(nr_free_pending);
+               __kfree_req(req, ti);
+               count++;
+       }
+       spin_unlock_irqrestore(&ti->free_requests_lock,flags);
+
+       return count;
+}
+
+static tux_req_t * kmalloc_req (threadinfo_t * ti)
+{
+       struct list_head *tmp;
+       unsigned long flags;
+       tux_req_t *req;
+
+       spin_lock_irqsave(&ti->free_requests_lock, flags);
+       if (ti->nr_free_requests) {
+               ti->nr_free_requests--;
+               tmp = ti->free_requests.next;
+               req = list_entry(tmp, tux_req_t, free);
+               list_del(tmp);
+               DEBUG_DEL_LIST(tmp);
+               DEC_STAT(nr_free_pending);
+               req->magic = TUX_MAGIC;
+               spin_unlock_irqrestore(&ti->free_requests_lock, flags);
+       } else {
+               spin_unlock_irqrestore(&ti->free_requests_lock, flags);
+               req = tux_kmalloc(sizeof(*req));
+               ti->nr_requests++;
+               memset (req, 0, sizeof(*req));
+               list_add(&req->all, &ti->all_requests);
+       }
+       req->magic = TUX_MAGIC;
+       INC_STAT(nr_allocated);
+       init_waitqueue_entry(&req->sleep, current);
+       init_waitqueue_entry(&req->ftp_sleep, current);
+       INIT_LIST_HEAD(&req->work);
+       INIT_LIST_HEAD(&req->free);
+       INIT_LIST_HEAD(&req->lru);
+       req->ti = ti;
+       req->total_bytes = 0;
+       SET_TIMESTAMP(req->accept_timestamp);
+       req->first_timestamp = jiffies;
+       req->fd = -1;
+       init_timer(&req->keepalive_timer);
+       init_timer(&req->output_timer);
+
+       Dprintk("allocated NEW req %p.\n", req);
+       return req;
+}
+
+void kfree_req (tux_req_t *req)
+{
+       threadinfo_t * ti = req->ti;
+       unsigned long flags;
+
+       Dprintk("freeing req %p.\n", req);
+
+       if (req->magic != TUX_MAGIC)
+               TUX_BUG();
+       spin_lock_irqsave(&ti->free_requests_lock,flags);
+       req->magic = 0;
+       DEC_STAT(nr_allocated);
+       if (req->sock || req->dentry || req->private)
+               TUX_BUG();
+       if (ti->nr_free_requests > tux_max_free_requests)
+               __kfree_req(req, ti);
+       else {
+               req->error = 0;
+               ti->nr_free_requests++;
+
+               // the free requests queue is LIFO
+               list_add(&req->free, &ti->free_requests);
+               INC_STAT(nr_free_pending);
+       }
+       spin_unlock_irqrestore(&ti->free_requests_lock,flags);
+}
+
+static void __add_req_to_workqueue (tux_req_t *req)
+{
+       threadinfo_t *ti = req->ti;
+
+       if (!list_empty(&req->work))
+               TUX_BUG();
+       Dprintk("work-queueing request %p at %p/%p.\n", req, __builtin_return_address(0), __builtin_return_address(1));
+       if (connection_too_fast(req))
+               list_add_tail(&req->work, &ti->work_pending);
+       else
+               list_add(&req->work, &ti->work_pending);
+       INC_STAT(nr_work_pending);
+       wake_up_process(ti->thread);
+       return;
+}
+
+void add_req_to_workqueue (tux_req_t *req)
+{
+       unsigned long flags;
+       threadinfo_t *ti = req->ti;
+
+       spin_lock_irqsave(&ti->work_lock, flags);
+       __add_req_to_workqueue(req);
+       spin_unlock_irqrestore(&ti->work_lock, flags);
+}
+
+void del_output_timer (tux_req_t *req)
+{
+#if CONFIG_SMP
+       if (!spin_is_locked(&req->ti->work_lock))
+               TUX_BUG();
+#endif
+       if (!list_empty(&req->lru)) {
+               list_del(&req->lru);
+               DEBUG_DEL_LIST(&req->lru);
+               req->ti->nr_lru--;
+       }
+       Dprintk("del output timeout for req %p.\n", req);
+       del_timer(&req->output_timer);
+}
+
+static void output_timeout_fn (unsigned long data);
+
+#define OUTPUT_TIMEOUT HZ
+
+static void add_output_timer (tux_req_t *req)
+{
+       struct timer_list *timer = &req->output_timer;
+
+       timer->data = (unsigned long) req;
+       timer->function = &output_timeout_fn;
+       mod_timer(timer, jiffies + OUTPUT_TIMEOUT);
+}
+
+static void output_timeout_fn (unsigned long data)
+{
+       tux_req_t *req = (tux_req_t *)data;
+
+       if (connection_too_fast(req)) {
+               add_output_timer(req);
+//             mod_timer(&req->output_timer, jiffies + OUTPUT_TIMEOUT);
+               return;
+       }
+       output_space_event(req);
+}
+
+void output_timeout (tux_req_t *req)
+{
+       Dprintk("output timeout for req %p.\n", req);
+       if (test_and_set_bit(0, &req->wait_output_space))
+               TUX_BUG();
+       INC_STAT(nr_output_space_pending);
+       add_output_timer(req);
+}
+
+void __del_keepalive_timer (tux_req_t *req)
+{
+#if CONFIG_SMP
+       if (!spin_is_locked(&req->ti->work_lock))
+               TUX_BUG();
+#endif
+       if (!list_empty(&req->lru)) {
+               list_del(&req->lru);
+               DEBUG_DEL_LIST(&req->lru);
+               req->ti->nr_lru--;
+       }
+       Dprintk("del keepalive timeout for req %p.\n", req);
+       del_timer(&req->keepalive_timer);
+}
+
+static void keepalive_timeout_fn (unsigned long data)
+{
+       tux_req_t *req = (tux_req_t *)data;
+
+#if CONFIG_TUX_DEBUG
+       Dprintk("req %p timed out after %d sec!\n", req, tux_keepalive_timeout);
+       if (tux_Dprintk)
+               print_req(req);
+#endif
+       Dprintk("req->error = TUX_ERROR_CONN_TIMEOUT!\n");
+       req->error = TUX_ERROR_CONN_TIMEOUT;
+       if (!idle_event(req))
+               output_space_event(req);
+}
+
+void __add_keepalive_timer (tux_req_t *req)
+{
+       struct timer_list *timer = &req->keepalive_timer;
+
+       if (!tux_keepalive_timeout)
+               TUX_BUG();
+#if CONFIG_SMP
+       if (!spin_is_locked(&req->ti->work_lock))
+               TUX_BUG();
+#endif
+
+       if (!list_empty(&req->lru))
+               TUX_BUG();
+       if (req->ti->nr_lru > tux_max_keepalives) {
+               struct list_head *head, *last;
+               tux_req_t *last_req;
+
+               head = &req->ti->lru;
+               last = head->prev;
+               if (last == head)
+                       TUX_BUG();
+               last_req = list_entry(last, tux_req_t, lru);
+               list_del(last);
+               DEBUG_DEL_LIST(last);
+               req->ti->nr_lru--;
+
+               Dprintk("LRU-aging req %p!\n", last_req);
+               last_req->error = TUX_ERROR_CONN_TIMEOUT;
+               if (!__idle_event(last_req))
+                       __output_space_event(last_req);
+       }
+       list_add(&req->lru, &req->ti->lru);
+       req->ti->nr_lru++;
+
+       timer->expires = jiffies + tux_keepalive_timeout * HZ;
+       timer->data = (unsigned long) req;
+       timer->function = &keepalive_timeout_fn;
+       add_timer(timer);
+}
+
+static int __output_space_event (tux_req_t *req)
+{
+       if (!req || (req->magic != TUX_MAGIC))
+               TUX_BUG();
+
+       if (!test_and_clear_bit(0, &req->wait_output_space)) {
+               Dprintk("output space ready event at <%p>, on non-idle %p.\n", __builtin_return_address(0), req);
+               return 0;
+       }
+
+       Dprintk("output space ready event at <%p>, %p was waiting!\n", __builtin_return_address(0), req);
+       DEC_STAT(nr_output_space_pending);
+
+       del_keepalive_timer(req);
+       del_output_timer(req);
+
+       __add_req_to_workqueue(req);
+       return 1;
+}
+
+int output_space_event (tux_req_t *req)
+{
+       int ret;
+       unsigned long flags;
+
+       spin_lock_irqsave(&req->ti->work_lock, flags);
+       ret = __output_space_event(req);
+       spin_unlock_irqrestore(&req->ti->work_lock, flags);
+
+       return ret;
+}
+
+static int __idle_event (tux_req_t *req)
+{
+       struct tcp_opt *tp;
+       threadinfo_t *ti;
+
+       if (!req || (req->magic != TUX_MAGIC))
+               TUX_BUG();
+       ti = req->ti;
+
+       if (!test_and_clear_bit(0, &req->idle_input)) {
+               Dprintk("data ready event at <%p>, on non-idle %p.\n", __builtin_return_address(0), req);
+               return 0;
+       }
+
+       Dprintk("data ready event at <%p>, %p was idle!\n", __builtin_return_address(0), req);
+       del_keepalive_timer(req);
+       del_output_timer(req);
+       DEC_STAT(nr_idle_input_pending);
+
+       tp = tcp_sk(req->sock->sk);
+
+       tp->ack.pingpong = tux_ack_pingpong;
+       SET_TIMESTAMP(req->accept_timestamp);
+
+       __add_req_to_workqueue(req);
+
+       return 1;
+}
+
+int idle_event (tux_req_t *req)
+{
+       int ret;
+       unsigned long flags;
+
+       spin_lock_irqsave(&req->ti->work_lock, flags);
+       ret = __idle_event(req);
+       spin_unlock_irqrestore(&req->ti->work_lock, flags);
+
+       return ret;
+}
+
+#define HANDLE_CALLBACK_1(callback, tux_name, real_name, param...)     \
+       tux_req_t *req;                                 \
+                                                       \
+       read_lock(&sk->sk_callback_lock);               \
+       req = sk->sk_user_data;                         \
+                                                       \
+       Dprintk("callback "#callback"(%p) req %p.\n",   \
+               sk->sk_##callback, req);                \
+                                                       \
+       if (!req) {                                     \
+               if (sk->sk_##callback == tux_name) {    \
+                       printk("BUG: "#callback" "#tux_name" "#real_name" no req!"); \
+                       TUX_BUG();                      \
+               }                                       \
+               read_unlock(&sk->sk_callback_lock);     \
+               if (sk->sk_##callback)                  \
+                       sk->sk_##callback(param);       \
+               return;                                 \
+       }                                               \
+
+#define HANDLE_CALLBACK_2(callback, tux_name, real_name, param...)     \
+       Dprintk(#tux_name"() on %p.\n", req);           \
+       if (req->magic != TUX_MAGIC)                    \
+               TUX_BUG();                              \
+       if (req->real_name)                             \
+               req->real_name(param);
+
+#define HANDLE_CALLBACK(callback, tux_name, real_name, param...)       \
+       HANDLE_CALLBACK_1(callback,tux_name,real_name,param)    \
+       HANDLE_CALLBACK_2(callback,tux_name,real_name,param)
+
+static void tux_data_ready (struct sock *sk, int len)
+{
+       HANDLE_CALLBACK_1(data_ready, tux_data_ready, real_data_ready, sk, len);
+
+       if (!idle_event(req))
+               output_space_event(req);
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_write_space (struct sock *sk)
+{
+       HANDLE_CALLBACK(write_space, tux_write_space, real_write_space, sk);
+
+       Dprintk("sk->sk_wmem_queued: %d, sk->sk_sndbuf: %d.\n",
+               sk->sk_wmem_queued, sk->sk_sndbuf);
+
+       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
+               clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+               if (!idle_event(req))
+                       output_space_event(req);
+       }
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_error_report (struct sock *sk)
+{
+       HANDLE_CALLBACK(error_report, tux_error_report, real_error_report, sk);
+
+       req->error = TUX_ERROR_CONN_CLOSE;
+       if (!idle_event(req))
+               output_space_event(req);
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_state_change (struct sock *sk)
+{
+       HANDLE_CALLBACK(state_change, tux_state_change, real_state_change, sk);
+
+       if (req->sock && req->sock->sk &&
+                               (req->sock->sk->sk_state > TCP_ESTABLISHED)) {
+               Dprintk("req %p changed to TCP non-established!\n", req);
+               Dprintk("req->sock: %p\n", req->sock);
+               if (req->sock)
+                       Dprintk("req->sock->sk: %p\n", req->sock->sk);
+               if (req->sock && req->sock->sk)
+                       Dprintk("TCP state: %d\n", req->sock->sk->sk_state);
+               Dprintk("req->error = TUX_ERROR_CONN_CLOSE!\n");
+               req->error = TUX_ERROR_CONN_CLOSE;
+       }
+       if (!idle_event(req))
+               output_space_event(req);
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_destruct (struct sock *sk)
+{
+       BUG();
+}
+
+static void tux_ftp_data_ready (struct sock *sk, int len)
+{
+       HANDLE_CALLBACK_1(data_ready, tux_ftp_data_ready,
+                               ftp_real_data_ready, sk, len);
+       if (!idle_event(req))
+               output_space_event(req);
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_ftp_write_space (struct sock *sk)
+{
+       HANDLE_CALLBACK_1(write_space, tux_ftp_write_space,
+                               ftp_real_write_space, sk);
+
+       Dprintk("sk->sk_wmem_queued: %d, sk->sk_sndbuf: %d.\n",
+               sk->sk_wmem_queued, sk->sk_sndbuf);
+
+       if (sk_stream_wspace(sk) >= sk->sk_sndbuf/10*8) {
+               clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+               if (!idle_event(req))
+                       output_space_event(req);
+       }
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_ftp_error_report (struct sock *sk)
+{
+       HANDLE_CALLBACK(error_report, tux_ftp_error_report,
+               ftp_real_error_report, sk);
+
+       TDprintk("req %p sock %p got TCP errors on FTP data connection!\n", req, sk);
+       TDprintk("req->error = TUX_ERROR_CONN_CLOSE!\n");
+       req->error = TUX_ERROR_CONN_CLOSE;
+       if (!idle_event(req))
+               output_space_event(req);
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_ftp_state_change (struct sock *sk)
+{
+       HANDLE_CALLBACK(state_change, tux_ftp_state_change,
+                       ftp_real_state_change, sk);
+
+       if (req->sock && req->sock->sk &&
+                       (req->sock->sk->sk_state > TCP_ESTABLISHED)) {
+               Dprintk("req %p FTP control sock changed to TCP non-established!\n", req);
+               Dprintk("req->sock: %p\n", req->sock);
+               TDprintk("req->error = TUX_ERROR_CONN_CLOSE!\n");
+
+               req->error = TUX_ERROR_CONN_CLOSE;
+       }
+       if (!idle_event(req))
+               output_space_event(req);
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_ftp_create_child (struct sock *sk, struct sock *newsk)
+{
+       HANDLE_CALLBACK(create_child, tux_ftp_create_child,
+                       ftp_real_create_child, sk, newsk);
+
+       newsk->sk_user_data = NULL;
+       newsk->sk_data_ready = req->ftp_real_data_ready;
+       newsk->sk_state_change = req->ftp_real_state_change;
+       newsk->sk_write_space = req->ftp_real_write_space;
+       newsk->sk_error_report = req->ftp_real_error_report;
+       newsk->sk_create_child = req->ftp_real_create_child;
+       newsk->sk_destruct = req->ftp_real_destruct;
+
+       if (!idle_event(req))
+               output_space_event(req);
+       read_unlock(&sk->sk_callback_lock);
+}
+
+static void tux_ftp_destruct (struct sock *sk)
+{
+       BUG();
+}
+
+static void link_tux_socket (tux_req_t *req, struct socket *sock)
+{
+       struct sock *sk = sock->sk;
+
+       if (req->sock)
+               TUX_BUG();
+       if (sk->sk_destruct == tux_destruct)
+               TUX_BUG();
+       /*
+        * (No need to lock the socket, we just want to
+        * make sure that events from now on go through
+        * tux_data_ready())
+        */
+       write_lock_irq(&sk->sk_callback_lock);
+
+       req->sock = sock;
+       sk->sk_user_data = req;
+
+       req->real_data_ready = sk->sk_data_ready;
+       req->real_state_change = sk->sk_state_change;
+       req->real_write_space = sk->sk_write_space;
+       req->real_error_report = sk->sk_error_report;
+       req->real_destruct = sk->sk_destruct;
+
+       sk->sk_data_ready = tux_data_ready;
+       sk->sk_state_change = tux_state_change;
+       sk->sk_write_space = tux_write_space;
+       sk->sk_error_report = tux_error_report;
+       sk->sk_destruct = tux_destruct;
+
+       write_unlock_irq(&sk->sk_callback_lock);
+
+       if (req->real_destruct == tux_destruct)
+               TUX_BUG();
+       req->client_addr = inet_sk(sk)->daddr;
+       req->client_port = inet_sk(sk)->dport;
+
+       add_wait_queue(sk->sk_sleep, &req->sleep);
+}
+
+void __link_data_socket (tux_req_t *req, struct socket *sock,
+                                               struct sock *sk)
+{
+       /*
+        * (No need to lock the socket, we just want to
+        * make sure that events from now on go through
+        * tux_data_ready())
+        */
+       write_lock_irq(&sk->sk_callback_lock);
+
+       req->data_sock = sock;
+       sk->sk_user_data = req;
+
+       req->ftp_real_data_ready = sk->sk_data_ready;
+       req->ftp_real_state_change = sk->sk_state_change;
+       req->ftp_real_write_space = sk->sk_write_space;
+       req->ftp_real_error_report = sk->sk_error_report;
+       req->ftp_real_create_child = sk->sk_create_child;
+       req->ftp_real_destruct = sk->sk_destruct;
+
+       sk->sk_data_ready = tux_ftp_data_ready;
+       sk->sk_state_change = tux_ftp_state_change;
+       sk->sk_write_space = tux_ftp_write_space;
+       sk->sk_error_report = tux_ftp_error_report;
+       sk->sk_create_child = tux_ftp_create_child;
+       sk->sk_destruct = tux_ftp_destruct;
+
+       if (req->ftp_real_destruct == tux_ftp_destruct)
+               TUX_BUG();
+
+       write_unlock_irq(&sk->sk_callback_lock);
+
+       add_wait_queue(sk->sk_sleep, &req->ftp_sleep);
+}
+
+void link_tux_data_socket (tux_req_t *req, struct socket *sock)
+{
+       struct sock *sk = sock->sk;
+
+       if (req->data_sock)
+               TUX_BUG();
+       if (sk->sk_destruct == tux_ftp_destruct)
+               TUX_BUG();
+       __link_data_socket(req, sock, sk);
+}
+
+void unlink_tux_socket (tux_req_t *req)
+{
+       struct sock *sk;
+       
+       if (!req->sock || !req->sock->sk)
+               return;
+       sk = req->sock->sk;
+
+       write_lock_irq(&sk->sk_callback_lock);
+       if (!sk->sk_user_data)
+               TUX_BUG();
+       if (req->real_destruct == tux_destruct)
+               TUX_BUG();
+
+       sk->sk_user_data = NULL;
+
+       sk->sk_data_ready = req->real_data_ready;
+       sk->sk_state_change = req->real_state_change;
+       sk->sk_write_space = req->real_write_space;
+       sk->sk_error_report = req->real_error_report;
+       sk->sk_destruct = req->real_destruct;
+
+       if (sk->sk_destruct == tux_destruct)
+               TUX_BUG();
+
+       req->real_data_ready = NULL;
+       req->real_state_change = NULL;
+       req->real_write_space = NULL;
+       req->real_error_report = NULL;
+       req->real_destruct = NULL;
+
+       write_unlock_irq(&sk->sk_callback_lock);
+
+       remove_wait_queue(sk->sk_sleep, &req->sleep);
+}
+
+void unlink_tux_data_socket (tux_req_t *req)
+{
+       struct sock *sk;
+       
+       if (!req->data_sock || !req->data_sock->sk)
+               return;
+       sk = req->data_sock->sk;
+
+       write_lock_irq(&sk->sk_callback_lock);
+
+       if (req->real_destruct == tux_ftp_destruct)
+               TUX_BUG();
+
+       sk->sk_user_data = NULL;
+       sk->sk_data_ready = req->ftp_real_data_ready;
+       sk->sk_state_change = req->ftp_real_state_change;
+       sk->sk_write_space = req->ftp_real_write_space;
+       sk->sk_error_report = req->ftp_real_error_report;
+       sk->sk_create_child = req->ftp_real_create_child;
+       sk->sk_destruct = req->ftp_real_destruct;
+
+       req->ftp_real_data_ready = NULL;
+       req->ftp_real_state_change = NULL;
+       req->ftp_real_write_space = NULL;
+       req->ftp_real_error_report = NULL;
+       req->ftp_real_create_child = NULL;
+       req->ftp_real_destruct = NULL;
+
+       write_unlock_irq(&sk->sk_callback_lock);
+
+       if (sk->sk_destruct == tux_ftp_destruct)
+               TUX_BUG();
+
+       remove_wait_queue(sk->sk_sleep, &req->ftp_sleep);
+}
+
+void add_tux_atom (tux_req_t *req, atom_func_t *atom)
+{
+       Dprintk("adding TUX atom %p to req %p, atom_idx: %d, at %p/%p.\n",
+               atom, req, req->atom_idx, __builtin_return_address(0), __builtin_return_address(1));
+       if (req->atom_idx == MAX_TUX_ATOMS)
+               TUX_BUG();
+       req->atoms[req->atom_idx] = atom;
+       req->atom_idx++;
+}
+
+void del_tux_atom (tux_req_t *req)
+{
+       if (!req->atom_idx)
+               TUX_BUG();
+       req->atom_idx--;
+       Dprintk("removing TUX atom %p to req %p, atom_idx: %d, at %p.\n",
+               req->atoms[req->atom_idx], req, req->atom_idx, __builtin_return_address(0));
+}
+
+void tux_schedule_atom (tux_req_t *req, int cachemiss)
+{
+       if (!list_empty(&req->work))
+               TUX_BUG();
+       if (!req->atom_idx)
+               TUX_BUG();
+       req->atom_idx--;
+       Dprintk("DOING TUX atom %p, req %p, atom_idx: %d, at %p.\n",
+               req->atoms[req->atom_idx], req, req->atom_idx, __builtin_return_address(0));
+       might_sleep();
+       req->atoms[req->atom_idx](req, cachemiss);
+       might_sleep();
+       Dprintk("DONE TUX atom %p, req %p, atom_idx: %d, at %p.\n",
+               req->atoms[req->atom_idx], req, req->atom_idx, __builtin_return_address(0));
+}
+
+/*
+ * Puts newly accepted connections into the inputqueue. This is the
+ * first step in the life of a TUX request.
+ */
+int accept_requests (threadinfo_t *ti)
+{
+       int count = 0, last_count = 0, error, socknr = 0;
+       struct socket *sock, *new_sock;
+       struct tcp_opt *tp1, *tp2;
+       tux_req_t *req;
+
+       if (ti->nr_requests > tux_max_connect)
+               goto out;
+
+repeat:
+       for (socknr = 0; socknr < CONFIG_TUX_NUMSOCKETS; socknr++) {
+               tux_listen_t *tux_listen;
+
+               tux_listen = ti->listen + socknr;
+               sock = tux_listen->sock;
+               if (!sock)
+                       break;
+               if (unlikely(test_thread_flag(TIF_NEED_RESCHED)))
+                       break;
+
+       tp1 = tcp_sk(sock->sk);
+       /*
+        * Quick test to see if there are connections on the queue.
+        * This is cheaper than accept() itself because this saves us
+        * the allocation of a new socket. (Which doesn't seem to be
+        * used anyway)
+        */
+       if (tp1->accept_queue) {
+               tux_proto_t *proto;
+
+               if (!count++)
+                       __set_task_state(current, TASK_RUNNING);
+
+               new_sock = sock_alloc();
+               if (!new_sock)
+                       goto out;
+
+               new_sock->type = sock->type;
+               new_sock->ops = sock->ops;
+
+               error = sock->ops->accept(sock, new_sock, O_NONBLOCK);
+               if (error < 0)
+                       goto err;
+               if (new_sock->sk->sk_state != TCP_ESTABLISHED)
+                       goto err;
+
+               tp2 = tcp_sk(new_sock->sk);
+               tp2->nonagle = 2;
+               tp2->ack.pingpong = tux_ack_pingpong;
+               new_sock->sk->sk_reuse = 1;
+               sock_set_flag(new_sock->sk, SOCK_URGINLINE);
+
+               /* Allocate a request-entry for the connection */
+               req = kmalloc_req(ti);
+               if (!req)
+                       BUG();
+               link_tux_socket(req, new_sock);
+
+               proto = req->proto = tux_listen->proto;
+
+               proto->got_request(req);
+       }
+       }
+       if (count != last_count) {
+               last_count = count;
+               goto repeat;
+       }
+out:
+       return count;
+err:
+       sock_release(new_sock);
+       goto out;
+}
+
diff --git a/net/tux/cachemiss.c b/net/tux/cachemiss.c
new file mode 100644 (file)
index 0000000..f840583
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * cachemiss.c: handle the 'slow IO path' by queueing not-yet-cached
+ * requests to the IO-thread pool. Dynamic load balancing is done
+ * between IO threads, based on the number of requests they have pending.
+ */
+
+#include <net/tux.h>
+#include <linux/delay.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+void queue_cachemiss (tux_req_t *req)
+{
+       iothread_t *iot = req->ti->iot;
+
+       Dprintk("queueing_cachemiss(req:%p) (req->cwd_dentry: %p) at %p:%p.\n",
+               req, req->cwd_dentry, __builtin_return_address(0), __builtin_return_address(1));
+       if (req->idle_input || req->wait_output_space)
+               TUX_BUG();
+       req->had_cachemiss = 1;
+       if (!list_empty(&req->work))
+               TUX_BUG();
+       spin_lock(&iot->async_lock);
+       if (connection_too_fast(req))
+               list_add_tail(&req->work, &iot->async_queue);
+       else
+               list_add(&req->work, &iot->async_queue);
+       iot->nr_async_pending++;
+       INC_STAT(nr_cachemiss_pending);
+       spin_unlock(&iot->async_lock);
+
+       wake_up(&iot->async_sleep);
+}
+
+static tux_req_t * get_cachemiss (iothread_t *iot)
+{
+       struct list_head *tmp;
+       tux_req_t *req = NULL;
+
+       spin_lock(&iot->async_lock);
+       if (!list_empty(&iot->async_queue)) {
+
+               tmp = iot->async_queue.next;
+               req = list_entry(tmp, tux_req_t, work);
+
+               Dprintk("get_cachemiss(%p): got req %p.\n", iot, req);
+               list_del(tmp);
+               DEBUG_DEL_LIST(tmp);
+               iot->nr_async_pending--;
+               DEC_STAT(nr_cachemiss_pending);
+
+               if (req->ti->iot != iot)
+                       TUX_BUG();
+       }
+       spin_unlock(&iot->async_lock);
+       return req;
+}
+
+struct file * tux_open_file (char *filename, int mode)
+{
+       struct file *filp;
+
+       if (!filename)
+               TUX_BUG();
+
+       /* Rule no. 3 -- Does the file exist ? */
+
+       filp = filp_open(filename, mode, 0600);
+
+       if (IS_ERR(filp) || !filp || !filp->f_dentry)
+               goto err;
+
+out:
+       return filp;
+err:
+       Dprintk("filp_open() error: %d.\n", (int)filp);
+       filp = NULL;
+       goto out;
+}
+
+static int cachemiss_thread (void *data)
+{
+       tux_req_t *req;
+       struct k_sigaction *ka;
+       DECLARE_WAITQUEUE(wait, current);
+       iothread_t *iot = data;
+       int nr = iot->ti->cpu, wake_up;
+
+       Dprintk("iot %p/%p got started.\n", iot, current);
+       drop_permissions();
+
+       spin_lock(&iot->async_lock);
+       iot->threads++;
+       sprintf(current->comm, "async IO %d/%d", nr, iot->threads);
+
+
+       spin_lock_irq(&current->sighand->siglock);
+       ka = current->sighand->action + SIGCHLD-1;
+       ka->sa.sa_handler = SIG_IGN;
+       siginitsetinv(&current->blocked, sigmask(SIGCHLD));
+       recalc_sigpending();
+       spin_unlock_irq(&current->sighand->siglock);
+
+       spin_unlock(&iot->async_lock);
+#if CONFIG_SMP
+       {
+               cpumask_t mask;
+
+               if (cpu_isset(nr, cpu_online_map)) {
+                       cpus_clear(mask);
+                       cpu_set(nr, mask);
+                       set_cpus_allowed(current, mask);
+               }
+
+       }
+#endif
+
+       add_wait_queue_exclusive(&iot->async_sleep, &wait);
+
+       for (;;) {
+               while (!list_empty(&iot->async_queue) &&
+                               (req = get_cachemiss(iot))) {
+
+                       if (!req->atom_idx) {
+                               add_tux_atom(req, flush_request);
+                               add_req_to_workqueue(req);
+                               continue;
+                       }
+                       tux_schedule_atom(req, 1);
+                       if (signal_pending(current))
+                               flush_all_signals();
+               }
+               if (signal_pending(current))
+                       flush_all_signals();
+               if (!list_empty(&iot->async_queue))
+                       continue;
+               if (iot->shutdown) {
+                       Dprintk("iot %p/%p got shutdown!\n", iot, current);
+                       break;
+               }
+               __set_current_state(TASK_INTERRUPTIBLE);
+               if (list_empty(&iot->async_queue)) {
+                       Dprintk("iot %p/%p going to sleep.\n", iot, current);
+                       schedule();
+                       Dprintk("iot %p/%p got woken up.\n", iot, current);
+               }
+               __set_current_state(TASK_RUNNING);
+       }
+
+       remove_wait_queue(&iot->async_sleep, &wait);
+
+       wake_up = 0;
+       spin_lock(&iot->async_lock);
+       if (!--iot->threads)
+               wake_up = 1;
+       spin_unlock(&iot->async_lock);
+       Dprintk("iot %p/%p has finished shutdown!\n", iot, current);
+       if (wake_up) {
+               Dprintk("iot %p/%p waking up master.\n", iot, current);
+               wake_up(&iot->wait_shutdown);
+       }
+
+       return 0;
+}
+
+static void __stop_cachemiss_threads (iothread_t *iot)
+{
+       DECLARE_WAITQUEUE(wait, current);
+
+       Dprintk("stopping async IO threads %p.\n", iot);
+       add_wait_queue(&iot->wait_shutdown, &wait);
+
+       spin_lock(&iot->async_lock);
+       if (iot->shutdown)
+               TUX_BUG();
+       if (!iot->threads)
+               TUX_BUG();
+       iot->shutdown = 1;
+       wake_up_all(&iot->async_sleep);
+       spin_unlock(&iot->async_lock);
+               
+       __set_current_state(TASK_UNINTERRUPTIBLE);
+       Dprintk("waiting for async IO threads %p to exit.\n", iot);
+       schedule();
+       remove_wait_queue(&iot->wait_shutdown, &wait);
+
+       if (iot->threads)
+               TUX_BUG();
+       if (iot->nr_async_pending)
+               TUX_BUG();
+       Dprintk("stopped async IO threads %p.\n", iot);
+}
+
+void stop_cachemiss_threads (threadinfo_t *ti)
+{
+       iothread_t *iot = ti->iot;
+
+       if (!iot)
+               TUX_BUG();
+       if (iot->nr_async_pending)
+               TUX_BUG();
+       __stop_cachemiss_threads(iot);
+       ti->iot = NULL;
+       kfree(iot);
+}
+
+int start_cachemiss_threads (threadinfo_t *ti)
+{
+       int i, pid;
+
+       iothread_t *iot;
+
+       iot = kmalloc(sizeof(*iot), GFP_KERNEL);
+       if (!iot)
+               return -ENOMEM;
+       memset(iot, 0, sizeof(*iot));
+
+       iot->ti = ti;
+       iot->async_lock = SPIN_LOCK_UNLOCKED;
+       iot->nr_async_pending = 0;
+       INIT_LIST_HEAD(&iot->async_queue);
+       init_waitqueue_head(&iot->async_sleep);
+       init_waitqueue_head(&iot->wait_shutdown);
+               
+       for (i = 0; i < NR_IO_THREADS; i++) {
+               pid = kernel_thread(cachemiss_thread, (void *)iot, 0);
+               if (pid < 0) {
+                       printk(KERN_ERR "TUX: error %d creating IO thread!\n",
+                                       pid);
+                       __stop_cachemiss_threads(iot);
+                       kfree(iot);
+                       return pid;
+               }
+       }
+       ti->iot = iot;
+       /*
+        * Wait for all cachemiss threads to start up:
+        */
+       while (iot->threads != NR_IO_THREADS) {
+               __set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ/10);
+       }
+       return 0;
+}
+
diff --git a/net/tux/cgi.c b/net/tux/cgi.c
new file mode 100644 (file)
index 0000000..fda4d38
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * cgi.c: user-space CGI (and other) code execution.
+ */
+
+#define __KERNEL_SYSCALLS__
+#define __KERNEL_SYSCALLS_NO_ERRNO__
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+static int exec_usermode(char *program_path, char *argv[], char *envp[])
+{
+       int i, err;
+
+       err = tux_chroot(tux_cgiroot);
+       if (err) {
+               printk(KERN_ERR "TUX: CGI chroot returned %d, /proc/sys/net/tux/cgiroot is probably set up incorrectly! Aborting CGI execution.\n", err);
+               return err;
+       }
+
+       /* Allow execve args to be in kernel space. */
+       set_fs(KERNEL_DS);
+
+       flush_signals(current);
+       spin_lock_irq(&current->sighand->siglock);
+       flush_signal_handlers(current, 1);
+       spin_unlock_irq(&current->sighand->siglock);
+
+       for (i = 3; i < current->files->max_fds; i++ )
+               if (current->files->fd[i])
+                       tux_close(i);
+
+       err = execve(program_path, argv, envp);
+       if (err < 0)
+               return err;
+       return 0;
+}
+
+static inline long tux_dup(unsigned int fildes)
+{
+       int ret = -EBADF;
+       struct file * file = fget(fildes);
+
+       if (file)
+               ret = dupfd(file, 0);
+       return ret;
+}
+
+static int exec_helper (void * data)
+{
+       exec_param_t *param = data;
+       char **tmp;
+       int ret;
+
+       sprintf(current->comm,"doexec - %d", current->pid);
+#if CONFIG_SMP
+       if (!tux_cgi_inherit_cpu) {
+               
+               cpumask_t cgi_mask, map;
+               
+               mask_to_cpumask(tux_cgi_cpu_mask, &cgi_mask);
+               cpus_and(map, cpu_online_map, cgi_mask);
+       
+               if (!(cpus_empty(map)))
+                       set_cpus_allowed(current, cgi_mask);
+               else
+                       set_cpus_allowed(current, cpu_online_map);
+       }
+#endif
+
+       if (!param)
+               TUX_BUG();
+       Dprintk("doing exec(%s).\n", param->command);
+
+       Dprintk("argv: ");
+       tmp = param->argv;
+       while (*tmp) {
+               Dprintk("{%s} ", *tmp);
+               tmp++;
+       }
+       Dprintk("\n");
+       Dprintk("envp: ");
+       tmp = param->envp;
+       while (*tmp) {
+               Dprintk("{%s} ", *tmp);
+               tmp++;
+       }
+       Dprintk("\n");
+       /*
+        * Set up stdin, stdout and stderr of the external
+        * CGI application.
+        */
+       if (param->pipe_fds) {
+               tux_close(1);
+               tux_close(2);
+               tux_close(4);
+               if (tux_dup(3) != 1)
+                       TUX_BUG();
+               if (tux_dup(5) != 2)
+                       TUX_BUG();
+               tux_close(3);
+               tux_close(5);
+               // do not close on exec.
+#if 0
+               sys_fcntl(0, F_SETFD, 0);
+               sys_fcntl(1, F_SETFD, 0);
+               sys_fcntl(2, F_SETFD, 0);
+#else
+               spin_lock(&current->files->file_lock);
+               FD_CLR(0, current->files->close_on_exec);
+               FD_CLR(1, current->files->close_on_exec);
+               FD_CLR(2, current->files->close_on_exec);
+               spin_unlock(&current->files->file_lock);
+#endif
+       }
+       ret = exec_usermode(param->command, param->argv, param->envp);
+       if (ret < 0)
+               Dprintk("bug: exec() returned %d.\n", ret);
+       else
+               Dprintk("exec()-ed successfully!\n");
+       return 0;
+}
+
+pid_t tux_exec_process (char *command, char **argv,
+                       char **envp, int pipe_fds,
+                               exec_param_t *param, int wait)
+{
+       exec_param_t param_local;
+       pid_t pid;
+       struct k_sigaction *ka;
+
+       ka = current->sighand->action + SIGCHLD-1;
+       ka->sa.sa_handler = SIG_IGN;
+
+       if (!param && wait)
+               param = &param_local;
+
+       param->command = command;
+       param->argv = argv;
+       param->envp = envp;
+       param->pipe_fds = pipe_fds;
+
+repeat_fork:
+       pid = kernel_thread(exec_helper, (void*) param, CLONE_SIGHAND|SIGCHLD);
+       Dprintk("kernel thread created PID %d.\n", pid);
+       if (pid < 0) {
+               printk(KERN_ERR "TUX: could not create new CGI kernel thread due to %d... retrying.\n", pid);
+               current->state = TASK_UNINTERRUPTIBLE;
+               schedule_timeout(HZ);
+               goto repeat_fork;
+       }
+       return pid;
+}
diff --git a/net/tux/directory.c b/net/tux/directory.c
new file mode 100644 (file)
index 0000000..714800e
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * directory.c: directory listing support
+ */
+
+#define __KERNEL_SYSCALLS__
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+char * tux_print_path (tux_req_t *req, struct dentry *dentry, struct vfsmount *mnt, char *buf, unsigned int max_len)
+{
+       char *res;
+       struct dentry *cwd, *root;
+       struct vfsmount *cwd_mnt, *rootmnt;
+
+       cwd = dget(dentry);
+       cwd_mnt = mntget(mnt);
+       root = dget(req->docroot_dentry);
+       rootmnt = mntget(req->docroot_mnt);
+
+       spin_lock(&dcache_lock);
+       res = __d_path(cwd, cwd_mnt, root, rootmnt, buf, max_len);
+       spin_unlock(&dcache_lock);
+
+       dput(cwd);
+       mntput(cwd_mnt);
+       dput(root);
+       mntput(rootmnt);
+
+       return res;
+}
+
+/*
+ * There are filesystems that do not fill in ->d_type correctly.
+ * Determine file-type.
+ */
+static int get_d_type (struct dentry *dentry)
+{
+       unsigned int mode = dentry->d_inode->i_mode;
+
+       if (S_ISREG(mode))
+               return DT_REG;
+       if (S_ISDIR(mode))
+               return DT_DIR;
+       if (S_ISLNK(mode))
+               return DT_LNK;
+       if (S_ISFIFO(mode))
+               return DT_FIFO;
+       if (S_ISSOCK(mode))
+               return DT_SOCK;
+       if (S_ISCHR(mode))
+               return DT_CHR;
+       if (S_ISBLK(mode))
+               return DT_BLK;
+       return 0;
+}
+
+static void do_dir_line (tux_req_t *req, int cachemiss)
+{
+       struct linux_dirent64 *dirp, *dirp0;
+       char string0[MAX_OBJECTNAME_LEN+200], *tmp;
+       int len, curroff, total, str_len = 0;
+       int err, flag = cachemiss ? 0 : LOOKUP_ATOMIC;
+       struct nameidata base;
+       struct dentry *dentry = NULL;
+       struct inode *inode = NULL;
+       struct vfsmount *mnt = NULL;
+
+       if (req->proto->check_req_err(req, cachemiss))
+               return;
+
+       tmp = NULL;
+       dirp0 = req->dirp0;
+       curroff = req->curroff;
+       total = req->total;
+
+       dirp = (struct linux_dirent64 *)((char *)dirp0 + curroff);
+       if (!dirp->d_name || !dirp->d_name[0])
+               goto next_dir;
+       /*
+        * Hide .xxxxx files:
+        */
+       if (dirp->d_name[0] == '.')
+               goto next_dir;
+       Dprintk("<%s T:%d (off:%Ld) (len:%d)>\n", dirp->d_name, dirp->d_type, dirp->d_off, dirp->d_reclen);
+       if (tux_hide_unreadable) {
+               switch (dirp->d_type) {
+                       default:
+                               goto next_dir;
+                       case DT_UNKNOWN:
+                       case DT_REG:
+                       case DT_DIR:
+                       case DT_LNK:
+                       /* valid entries - fall through. */
+                               ;
+               }
+       }
+       len = strlen(dirp->d_name);
+       if (len >= MAX_OBJECTNAME_LEN) {
+               dirp->d_name[MAX_OBJECTNAME_LEN] = 0;
+               len = MAX_OBJECTNAME_LEN-1;
+       }
+
+       if (!req->dentry)
+               TUX_BUG();
+
+       base.flags = flag;
+       base.last_type = LAST_ROOT;
+       base.dentry = dget(req->dentry);
+       base.mnt = mntget(req->cwd_mnt);
+
+       switch_docroot(req);
+       err = path_walk(dirp->d_name, &base);
+
+       Dprintk("path_walk() returned %d.\n", err);
+
+       if (err) {
+               if (err == -EWOULDBLOCKIO) {
+                       add_tux_atom(req, do_dir_line);
+                       queue_cachemiss(req);
+                       return;
+               }
+               goto next_dir;
+       }
+
+       dentry = base.dentry;
+       mnt = base.mnt;
+       if (!dentry)
+               TUX_BUG();
+       if (IS_ERR(dentry))
+               TUX_BUG();
+       inode = dentry->d_inode;
+       if (!inode)
+               TUX_BUG();
+       if (!dirp->d_type)
+               dirp->d_type = get_d_type(dentry);
+       if (tux_hide_unreadable) {
+               umode_t mode;
+
+               mode = inode->i_mode;
+               if (mode & tux_mode_forbidden)
+                       goto out_dput;
+               if (!(mode & tux_mode_allowed))
+                       goto out_dput;
+
+               err = permission(inode, MAY_READ, NULL);
+               if (err)
+                       goto out_dput;
+               if (dirp->d_type == DT_DIR) {
+                       err = permission(inode, MAY_EXEC, NULL);
+                       if (err)
+                               goto out_dput;
+               }
+       }
+
+       tmp = req->proto->print_dir_line(req, string0, dirp->d_name, len, dirp->d_type, dentry, inode);
+       if (tmp)
+               str_len = tmp-string0;
+out_dput:
+       dput(dentry);
+       mntput(mnt);
+next_dir:
+       curroff += dirp->d_reclen;
+
+       if (tmp && (tmp != string0))
+               Dprintk("writing line (len: %d): <%s>\n", strlen(string0), string0);
+
+       if (curroff < total) {
+               req->dirp0 = dirp0;
+               req->curroff = curroff;
+               add_tux_atom(req, do_dir_line);
+       } else {
+               kfree(dirp0);
+               req->dirp0 = NULL;
+               req->curroff = 0;
+               // falls back to the list_directory atom
+       }
+       if (tmp && (tmp != string0))
+               __send_async_message(req, string0, 200, str_len, 0);
+       else
+               add_req_to_workqueue(req);
+}
+
+#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
+#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
+#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
+
+static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
+                    ino_t ino, unsigned int d_type)
+{
+       struct linux_dirent64 * dirent, d;
+       struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf;
+       int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namlen + 1);
+
+       buf->error = -EINVAL;   /* only used if we fail.. */
+       if (reclen > buf->count)
+               return -EINVAL;
+       dirent = buf->previous;
+       if (dirent) {
+               d.d_off = offset;
+               copy_to_user(&dirent->d_off, &d.d_off, sizeof(d.d_off));
+       }
+       dirent = buf->current_dir;
+       buf->previous = dirent;
+       memset(&d, 0, NAME_OFFSET(&d));
+       d.d_ino = ino;
+       d.d_reclen = reclen;
+       d.d_type = d_type;
+       copy_to_user(dirent, &d, NAME_OFFSET(&d));
+       copy_to_user(dirent->d_name, name, namlen);
+       put_user(0, dirent->d_name + namlen);
+       dirent = (void *)dirent + reclen;
+       buf->current_dir = dirent;
+       buf->count -= reclen;
+       return 0;
+}
+#define DIRENT_SIZE 3000
+
+void list_directory (tux_req_t *req, int cachemiss)
+{
+       struct getdents_callback64 buf;
+       struct linux_dirent64 *dirp0;
+       mm_segment_t oldmm;
+       int total;
+
+       Dprintk("list_directory(%p, %d), dentry: %p.\n", req, cachemiss, req->dentry);
+       if (!req->cwd_dentry)
+               TUX_BUG();
+
+       if (!cachemiss) {
+               add_tux_atom(req, list_directory);
+               queue_cachemiss(req);
+               return;
+       }
+
+       dirp0 = tux_kmalloc(DIRENT_SIZE);
+
+       buf.current_dir = dirp0;
+       buf.previous = NULL;
+       buf.count = DIRENT_SIZE;
+       buf.error = 0;
+
+       oldmm = get_fs(); set_fs(KERNEL_DS);
+       set_fs(KERNEL_DS);
+       total = vfs_readdir(&req->in_file, filldir64, &buf);
+       set_fs(oldmm);
+
+       if (buf.previous)
+               total = DIRENT_SIZE - buf.count;
+
+       Dprintk("total: %d (buf.error: %d, buf.previous %p)\n",
+               total, buf.error, buf.previous);
+
+       if (total < 0) {
+               kfree(dirp0);
+               req_err(req);
+               add_req_to_workqueue(req);
+               return;
+       }
+       if (!total) {
+               kfree(dirp0);
+               req->in_file.f_pos = 0;
+               add_req_to_workqueue(req);
+               return;
+       }
+
+       if (!req->cwd_dentry)
+               TUX_BUG();
+       add_tux_atom(req, list_directory);
+
+       req->dirp0 = dirp0;
+       req->curroff = 0;
+       req->total = total;
+       add_tux_atom(req, do_dir_line);
+
+       add_req_to_workqueue(req);
+}
+
diff --git a/net/tux/extcgi.c b/net/tux/extcgi.c
new file mode 100644 (file)
index 0000000..1d1d1d5
--- /dev/null
@@ -0,0 +1,329 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * extcgi.c: dynamic TUX module which forks and starts an external CGI
+ */
+
+#define __KERNEL_SYSCALLS__
+#define __KERNEL_SYSCALLS_NO_ERRNO__
+
+#include <net/tux.h>
+#include "parser.h"
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+#define MAX_ENVLEN 1000
+#define MAX_CGI_METAVARIABLES 32
+#define CGI_CHUNK_SIZE 1024 
+#define MAX_CGI_COMMAND_LEN 256
+
+#if CONFIG_TUX_DEBUG
+#define PRINT_MESSAGE_LEFT \
+       Dprintk("CGI message left at %s:%d:\n--->{%s}<---\n", \
+               __FILE__, __LINE__, curr)
+#else
+#define PRINT_MESSAGE_LEFT do {} while(0)
+#endif
+
+#define GOTO_INCOMPLETE do { Dprintk("invalid CGI reply at %s:%d.\n", __FILE__, __LINE__); goto invalid; } while (0)
+
+/*
+ * Please acknowledge our hard work by not changing this define, or
+ * at least please acknowledge us by leaving "TUX/2.0 (Linux)" in
+ * the ID string. Thanks! :-)
+ */
+#define CGI_SUCCESS2 "HTTP/1.1 200 OK\r\nConnection: close\r\nServer: TUX/2.0 (Linux)\r\n"
+
+static int handle_cgi_reply (tux_req_t *req)
+{
+       int first = 1;
+       int len, left, total;
+       char *buf, *tmp;
+       mm_segment_t oldmm;
+
+       buf = tux_kmalloc(CGI_CHUNK_SIZE+1);
+       tux_close(3);
+       tux_close(4);
+       tux_close(5);
+       oldmm = get_fs(); set_fs(KERNEL_DS);
+       send_sync_buf(NULL, req->sock, CGI_SUCCESS2, sizeof(CGI_SUCCESS2)-1, MSG_MORE);
+       set_fs(oldmm);
+
+       req->bytes_sent = 0;
+       /*
+        * The new process is the new owner of the socket, it will
+        * close it.
+        */
+repeat:
+       left = CGI_CHUNK_SIZE;
+       len = 0;
+       total = 0;
+       tmp = buf;
+       do {
+               mm_segment_t oldmm;
+
+               tmp += len;
+               total += len;
+               left -= len;
+               if (!left)
+                       break;
+repeat_read:
+               Dprintk("reading %d bytes via read().\n", left);
+               oldmm = get_fs(); set_fs(KERNEL_DS);
+               len = read(2, tmp, left);
+               set_fs(oldmm);
+               Dprintk("got %d bytes from read() (total: %d).\n", len, total);
+               if (len > 0)
+                       tmp[len] = 0;
+               Dprintk("CGI reply: (%d bytes, total %d).\n", len, total);
+               if (len == -ERESTARTSYS) {
+                       flush_all_signals();
+                       goto repeat_read;
+               }
+       } while (len > 0);
+       if (total > CGI_CHUNK_SIZE) {
+               printk(KERN_ERR "TUX: CGI weirdness. total: %d, len: %d, left: %d.\n", total, len, left);
+               TUX_BUG();
+       }
+       Dprintk("CGI done reply chunk: (%d bytes last, total %d).\n", len, total);
+       if (total) {
+               mm_segment_t oldmm;
+
+               oldmm = get_fs(); set_fs(KERNEL_DS);
+               if (!len)
+                       send_sync_buf(NULL, req->sock, buf, total, 0);
+               else
+                       send_sync_buf(NULL, req->sock, buf, total, MSG_MORE);
+               set_fs(oldmm);
+               req->bytes_sent += total;
+       }
+
+       Dprintk("bytes_sent: %d\n", req->bytes_sent);
+       if ((total > 0) && first) {
+               first = 0;
+
+               if (buf[total])
+                       TUX_BUG();
+               tmp = strstr(buf, "\n\n");
+               if (tmp) {
+                       req->bytes_sent -= (tmp-buf) + 2;
+                       Dprintk("new bytes_sent: %d\n", req->bytes_sent);
+               } else {
+                       req->bytes_sent = 0;
+                       req_err(req);
+               }
+       }
+       if (len < 0)
+               Dprintk("sys_read returned with %d.\n", len);
+       else {
+               if (total > 0)
+                       goto repeat;
+       }
+       tux_close(2);
+
+       req->status = 200;
+       add_req_to_workqueue(req);
+       kfree(buf);
+
+       return -1;
+}
+
+static int exec_external_cgi (void *data)
+{
+       exec_param_t param;
+       tux_req_t *req = data;
+       char *envp[MAX_CGI_METAVARIABLES+1], **envp_p;
+       char *argv[] = { "extcgi", NULL};
+       char *envstr, *tmp;
+       unsigned int host;
+       struct k_sigaction *ka;
+       int in_pipe_fds[2], out_pipe_fds[2], err_pipe_fds[2], len, err;
+       char *command;
+       pid_t pid;
+
+       len = strlen(tux_common_docroot);
+       if (req->objectname_len + len + 12 > MAX_CGI_COMMAND_LEN)
+               return -ENOMEM;
+       sprintf(current->comm,"cgimain - %d", current->pid);
+       host = inet_sk(req->sock->sk)->daddr;
+
+       envstr = tux_kmalloc(MAX_ENVLEN);
+       command = tux_kmalloc(MAX_CGI_COMMAND_LEN);
+
+       tmp = envstr;
+       envp_p = envp;
+
+#define WRITE_ENV(str...) \
+       if (envp_p >= envp + MAX_CGI_METAVARIABLES) \
+               TUX_BUG(); \
+       len = sprintf(tmp, str); \
+       *envp_p++ = tmp; \
+       tmp += len + 1; \
+       if (tmp >= envstr + MAX_ENVLEN) \
+               TUX_BUG();
+
+       #define WRITE_ENV_STR(str,field,len)                    \
+       do {                                                    \
+               int offset;                                     \
+                                                               \
+               offset = sizeof(str)-1;                         \
+               err = -EFAULT;                                  \
+               if (tmp - envstr + offset + len >= MAX_ENVLEN)  \
+                       goto out;                               \
+               if (envp_p >= envp + MAX_CGI_METAVARIABLES)     \
+                       TUX_BUG();                              \
+               memcpy(tmp, str, offset);                       \
+               memcpy(tmp + offset, field, len);               \
+               offset += len;                                  \
+               tmp[offset] = 0;                                \
+               *envp_p++ = tmp;                                \
+               tmp += offset + 1;                              \
+       } while (0)
+
+       WRITE_ENV("GATEWAY_INTERFACE=CGI/1.1");
+       WRITE_ENV("CONTENT_LENGTH=%d", req->post_data_len);
+       WRITE_ENV("REMOTE_ADDR=%d.%d.%d.%d", NIPQUAD(host));
+       WRITE_ENV("SERVER_PORT=%d", 80);
+       WRITE_ENV("SERVER_SOFTWARE=TUX/2.0 (Linux)");
+
+#if 1
+       WRITE_ENV("DOCUMENT_ROOT=/");
+       WRITE_ENV("PATH_INFO=/");
+#else
+       WRITE_ENV_STR("DOCUMENT_ROOT=", tux_common_docroot, len);
+       WRITE_ENV_STR("PATH_INFO=", tux_common_docroot, len);
+#endif
+       WRITE_ENV_STR("QUERY_STRING=", req->query_str, req->query_len);
+       WRITE_ENV_STR("REQUEST_METHOD=", req->method_str, req->method_len);
+       WRITE_ENV_STR("SCRIPT_NAME=", req->objectname, req->objectname_len);
+       WRITE_ENV_STR("SERVER_PROTOCOL=", req->version_str, req->version_len);
+
+       if (req->content_type_len)
+               WRITE_ENV_STR("CONTENT_TYPE=",
+                       req->content_type_str, req->content_type_len);
+       if (req->cookies_len)
+               WRITE_ENV_STR("HTTP_COOKIE=",
+                       req->cookies_str, req->cookies_len);
+
+       if (req->host_len)
+               WRITE_ENV_STR("SERVER_NAME=", req->host, req->host_len);
+       else {
+               const char *host = "localhost";
+               WRITE_ENV_STR("SERVER_NAME=", host, strlen(host));
+       }
+
+       *envp_p = NULL;
+
+       spin_lock_irq(&current->sighand->siglock);
+       ka = current->sighand->action + SIGPIPE-1;
+       ka->sa.sa_handler = SIG_IGN;
+       siginitsetinv(&current->blocked, sigmask(SIGCHLD));
+       recalc_sigpending();
+       spin_unlock_irq(&current->sighand->siglock);
+
+       tux_close(0); tux_close(1);
+       tux_close(2); tux_close(3);
+       tux_close(4); tux_close(5);
+
+       in_pipe_fds[0] = in_pipe_fds[1] = -1;
+       out_pipe_fds[0] = out_pipe_fds[1] = -1;
+       err_pipe_fds[0] = err_pipe_fds[1] = -1;
+
+       err = -ENFILE;
+       if (do_pipe(in_pipe_fds))
+               goto out;
+       if (do_pipe(out_pipe_fds))
+               goto out;
+       if (do_pipe(err_pipe_fds))
+               goto out;
+
+       if (in_pipe_fds[0] != 0) TUX_BUG();
+       if (in_pipe_fds[1] != 1) TUX_BUG();
+       if (out_pipe_fds[0] != 2) TUX_BUG();
+       if (out_pipe_fds[1] != 3) TUX_BUG();
+       if (err_pipe_fds[0] != 4) TUX_BUG();
+       if (err_pipe_fds[1] != 5) TUX_BUG();
+
+       if (req->virtual && req->host_len)
+               sprintf(command, "/%s/cgi-bin/%s", req->host, req->objectname);
+       else
+               sprintf(command, "/cgi-bin/%s", req->objectname);
+       Dprintk("before CGI exec.\n");
+       pid = tux_exec_process(command, argv, envp, 1, &param, 0);
+       Dprintk("after CGI exec.\n");
+
+       if (req->post_data_len) {
+               mm_segment_t oldmm;
+               int ret;
+
+               Dprintk("POST data to CGI:\n");
+               oldmm = get_fs(); set_fs(KERNEL_DS);
+               ret = write(1, req->post_data_str, req->post_data_len);
+               set_fs(oldmm);
+               Dprintk("write() returned: %d.\n", ret);
+               if (ret != req->post_data_len)
+                       Dprintk("write() returned: %d.\n", ret);
+       }
+
+       tux_close(0);
+       tux_close(1);
+
+       handle_cgi_reply(req);
+       err = 0;
+
+out:
+       kfree(envstr);
+       kfree(command);
+
+       return err;
+}
+
+void start_external_cgi (tux_req_t *req)
+{
+       int pid;
+
+repeat:
+       pid = kernel_thread(exec_external_cgi, (void*) req, SIGCHLD);
+       if (pid == -1)
+               return;
+       if (pid < 0) {
+               printk(KERN_INFO "TUX: Could not fork external CGI process due to %d, retrying!\n", pid);
+               current->state = TASK_UNINTERRUPTIBLE;
+               schedule_timeout(HZ);
+               goto repeat;
+       }
+}
+
+int query_extcgi (tux_req_t *req)
+{
+       clear_keepalive(req);
+       start_external_cgi(req);
+       return -1;
+}
+
+#define EXTCGI_INVALID_HEADER \
+       "HTTP/1.1 503 Service Unavailable\r\n" \
+       "Content-Length: 23\r\n\r\n"
+
+#define EXTCGI_INVALID_BODY \
+       "TUX: invalid CGI reply."
+
+#define EXTCGI_INVALID EXTCGI_INVALID_HEADER EXTCGI_INVALID_BODY
+
diff --git a/net/tux/gzip.c b/net/tux/gzip.c
new file mode 100644 (file)
index 0000000..5476dff
--- /dev/null
@@ -0,0 +1,40 @@
+/*     $Id: zlib.h,v 1.2 1997/12/23 10:47:44 paulus Exp $      */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/zlib.h>
+#include <net/tux.h>
+
+#define STREAM_END_SPACE 12
+
+int tux_gzip_compress (tux_req_t *req, unsigned char *data_in, unsigned char *data_out, __u32 *in_len, __u32 *out_len)
+{
+       z_stream *s = &req->ti->gzip_state;
+       int ret, left;
+
+       down(&req->ti->gzip_sem);
+       if (zlib_deflateReset(s) != Z_OK)
+               BUG();
+
+       s->next_in = data_in;
+       s->next_out = data_out;
+       s->avail_in = *in_len;
+       s->avail_out = *out_len;
+
+       Dprintk("calling zlib_deflate with avail_in %d, avail_out %d\n", s->avail_in, s->avail_out);
+       ret = zlib_deflate(s, Z_FINISH);
+       Dprintk("deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", s->avail_in, s->avail_out, s->total_in, s->total_out);
+
+       if (ret != Z_STREAM_END) {
+               printk("bad: deflate returned with %d! avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", ret, s->avail_in, s->avail_out, s->total_in, s->total_out);
+               BUG();
+       }
+       *in_len = s->avail_in;
+       *out_len = s->avail_out;
+       left = s->avail_in;
+
+       up(&req->ti->gzip_sem);
+
+       return left;
+}
+
diff --git a/net/tux/input.c b/net/tux/input.c
new file mode 100644 (file)
index 0000000..f3e566c
--- /dev/null
@@ -0,0 +1,641 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * input.c: handle requests arriving on accepted connections
+ */
+
+#include <net/tux.h>
+#include <linux/kmod.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+void zap_request (tux_req_t *req, int cachemiss)
+{
+       if (!req->error)
+               TUX_BUG();
+       if (req->error == TUX_ERROR_CONN_TIMEOUT) {
+               if (req->proto->request_timeout) {
+                       clear_keepalive(req);
+                       req->proto->request_timeout(req, cachemiss);
+               } else {
+                       clear_keepalive(req);
+                       if (!cachemiss)
+                               flush_request(req, 0);
+                       else {
+                               add_tux_atom(req, flush_request);
+                               add_req_to_workqueue(req);
+                       }
+               }
+               return;
+       }
+
+       if (!cachemiss && (req->error == TUX_ERROR_CONN_CLOSE)) {
+               /*
+                * Zap connection as fast as possible, there is
+                * no valid client connection anymore:
+                */
+               clear_keepalive(req);
+               flush_request(req, 0);
+       } else {
+               if (req->error == TUX_ERROR_CONN_CLOSE) {
+                       clear_keepalive(req);
+                       add_tux_atom(req, flush_request);
+               } else
+                       /*
+                        * Potentially redirect to the secondary server:
+                        */
+                       add_tux_atom(req, redirect_request);
+               add_req_to_workqueue(req);
+       }
+}
+
+void __switch_docroot(tux_req_t *req)
+{
+       if (!req->docroot_dentry || !req->docroot_mnt)
+               TUX_BUG();
+       set_fs_root(current->fs, req->docroot_mnt, req->docroot_dentry);
+}
+
+struct dentry * __tux_lookup (tux_req_t *req, const char *filename,
+                        struct nameidata *base, struct vfsmount **mnt)
+{
+       int err;
+
+       err = path_walk(filename, base);
+       if (err) {
+               Dprintk("path_walk() returned with %d!\n", err);
+               return ERR_PTR(err);
+       }
+       if (*mnt)
+               TUX_BUG();
+       *mnt = base->mnt;
+
+       return base->dentry;
+}
+
+int tux_permission (struct inode *inode)
+{
+       umode_t mode;
+       int err;
+
+       mode = inode->i_mode;
+       Dprintk("URL inode mode: %08x.\n", mode);
+
+       if (mode & tux_mode_forbidden)
+               return -2;
+       /*
+        * at least one bit in the 'allowed' set has to
+        * be present to allow access.
+        */
+       if (!(mode & tux_mode_allowed))
+               return -3;
+       err = permission(inode,MAY_READ,NULL);
+       return err;
+}
+
+struct dentry * tux_lookup (tux_req_t *req, const char *filename,
+                       const unsigned int flag, struct vfsmount **mnt)
+{
+       struct dentry *dentry;
+       struct nameidata base;
+
+       Dprintk("tux_lookup(%p, %s, %d, virtual: %d, host: %s (%d).)\n", req, filename, flag, req->virtual, req->host, req->host_len);
+
+       base.flags = LOOKUP_FOLLOW|flag;
+       base.last_type = LAST_ROOT;
+       if (req->objectname[0] == '/') {
+               base.dentry = dget(req->docroot_dentry);
+               base.mnt = mntget(req->docroot_mnt);
+       } else {
+               if (!req->cwd_dentry) {
+                       req->cwd_dentry = dget(req->docroot_dentry);
+                       req->cwd_mnt = mntget(req->docroot_mnt);
+               }
+               base.dentry = req->cwd_dentry;
+               dget(base.dentry);
+               base.mnt = mntget(req->cwd_mnt);
+       }
+
+       switch_docroot(req);
+       dentry = __tux_lookup (req, filename, &base, mnt);
+
+       Dprintk("looked up {%s} == dentry %p.\n", filename, dentry);
+
+       if (dentry && !IS_ERR(dentry) && !dentry->d_inode)
+               TUX_BUG();
+       return dentry;
+}
+
+int lookup_object (tux_req_t *req, const unsigned int flag)
+{
+       struct vfsmount *mnt = NULL;
+       struct dentry *dentry = NULL;
+       int perm;
+
+       dentry = tux_lookup(req, req->objectname, flag, &mnt);
+       if (!dentry || IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO)
+                       goto cachemiss;
+               goto abort;
+       }
+       perm = tux_permission(dentry->d_inode);
+       /*
+        * Only regular files allowed.
+        */
+       if ((perm < 0) || !S_ISREG(dentry->d_inode->i_mode)) {
+               req->status = 403;
+               goto abort;
+       }
+       req->total_file_len = dentry->d_inode->i_size;
+out:
+       install_req_dentry(req, dentry, mnt);
+       return 0;
+cachemiss:
+       return 1;
+abort:
+       if (dentry) {
+               if (!IS_ERR(dentry))
+                       dput(dentry);
+               dentry = NULL;
+       }
+       if (mnt) {
+               if (!IS_ERR(mnt))
+                       mntput(mnt);
+               mnt = NULL;
+       }
+       req_err(req);
+       goto out;
+}
+
+void install_req_dentry (tux_req_t *req, struct dentry *dentry, struct vfsmount *mnt)
+{
+       if (req->dentry)
+               TUX_BUG();
+       req->dentry = dentry;
+       if (req->mnt)
+               TUX_BUG();
+       req->mnt = mnt;
+       if (req->in_file.f_dentry)
+               TUX_BUG();
+       if (dentry)
+               open_private_file(&req->in_file, dentry, FMODE_READ);
+}
+
+void release_req_dentry (tux_req_t *req)
+{
+       if (!req->dentry) {
+               if (req->in_file.f_dentry)
+                       TUX_BUG();
+               return;
+       }
+       if (req->in_file.f_op && req->in_file.f_op->release)
+               req->in_file.f_op->release(req->dentry->d_inode, &req->in_file);
+       memset(&req->in_file, 0, sizeof(req->in_file));
+
+       dput(req->dentry);
+       req->dentry = NULL;
+       mntput(req->mnt);
+       req->mnt = NULL;
+}
+
+int __connection_too_fast (tux_req_t *req)
+{
+       unsigned long curr_bw, delta, bytes;
+
+       bytes = req->total_bytes + req->bytes_sent;
+       if (!bytes)
+               return 1;
+
+       delta = jiffies - req->first_timestamp;
+       if (!delta)
+               delta++;
+       curr_bw = bytes * HZ / delta;
+
+       if (curr_bw > tux_max_output_bandwidth)
+               return 2;
+       return 0;
+}
+
+void unidle_req (tux_req_t *req)
+{
+       threadinfo_t *ti = req->ti;
+
+       Dprintk("UNIDLE req %p <%p> (sock %p, sk %p) (keepalive: %d, status: %d)\n", req, __builtin_return_address(0), req->sock, req->sock->sk, req->keep_alive, req->status);
+       spin_lock_irq(&ti->work_lock);
+       if (req->magic != TUX_MAGIC)
+               TUX_BUG();
+       if (!test_and_clear_bit(0, &req->idle_input)) {
+               Dprintk("unidling %p, wasnt idle!\n", req);
+               if (list_empty(&req->work))
+                       TUX_BUG();
+               list_del(&req->work);
+               DEBUG_DEL_LIST(&req->work);
+               DEC_STAT(nr_work_pending);
+       } else {
+               del_keepalive_timer(req);
+               DEC_STAT(nr_idle_input_pending);
+               Dprintk("unidled %p.\n", req);
+       }
+       if (req->idle_input)
+               TUX_BUG();
+       spin_unlock_irq(&ti->work_lock);
+}
+
+#define GOTO_INCOMPLETE do { Dprintk("incomplete at %s:%d.\n", __FILE__, __LINE__); goto incomplete; } while (0)
+#define GOTO_REDIRECT do { TDprintk("redirect at %s:%d.\n", __FILE__, __LINE__); goto redirect; } while (0)
+#define GOTO_REDIRECT_NONIDLE do { TDprintk("redirect at %s:%d.\n", __FILE__, __LINE__); goto redirect_nonidle; } while (0)
+
+static int read_request (struct socket *sock, char *buf, int max_size)
+{
+       mm_segment_t oldmm;
+       struct kiocb iocb;
+       struct msghdr msg;
+       struct iovec iov;
+
+       int len;
+
+       msg.msg_name     = 0;
+       msg.msg_namelen  = 0;
+       msg.msg_iov      = &iov;
+       msg.msg_iovlen   = 1;
+       msg.msg_control  = NULL;
+       msg.msg_controllen = 0;
+       msg.msg_flags    = 0;
+       
+       msg.msg_iov->iov_base = buf;
+       msg.msg_iov->iov_len  = max_size;
+       
+       oldmm = get_fs(); set_fs(KERNEL_DS);
+
+read_again:
+       init_sync_kiocb(&iocb, NULL);
+       len = sock->sk->sk_prot->recvmsg(&iocb, sock->sk, &msg, max_size,
+                                               MSG_DONTWAIT, MSG_PEEK, NULL);
+       if (-EIOCBQUEUED == len)
+               len = wait_on_sync_kiocb(&iocb);
+
+       /*
+        * We must not get a signal inbetween
+        */
+       if ((len == -EAGAIN) || (len == -ERESTARTSYS)) {
+               if (!signal_pending(current)) {
+                       len = 0;
+                       goto out;
+               }
+               flush_all_signals();
+               goto read_again;
+       }
+out:
+       set_fs(oldmm);
+       return len;
+}
+
+/*
+ * We inline URG data so it's at the head of the normal receive queue.
+ */
+static int zap_urg_data (struct socket *sock)
+{
+       mm_segment_t oldmm;
+       struct msghdr msg;
+       struct iovec iov;
+       struct kiocb iocb;
+       int len;
+       char buf[10];
+
+       oldmm = get_fs(); set_fs(KERNEL_DS);
+
+       msg.msg_name            = 0;
+       msg.msg_namelen         = 0;
+       msg.msg_iov             = &iov;
+       msg.msg_iovlen          = 1;
+       msg.msg_control         = NULL;
+       msg.msg_controllen      = 0;
+       msg.msg_flags           = 0;
+       
+       msg.msg_iov->iov_base = buf;
+       msg.msg_iov->iov_len  = 2;
+
+read_again:
+       init_sync_kiocb(&iocb, NULL);
+       len = sock->sk->sk_prot->recvmsg(&iocb, sock->sk, &msg, 2,
+                                               MSG_DONTWAIT, 0, NULL);
+       if (-EIOCBQUEUED == len)
+               len = wait_on_sync_kiocb(&iocb);
+       Dprintk("recvmsg(MSG_OOB) returned %d.\n", len);
+
+       /*
+        * We must not get a signal inbetween
+        */
+       if ((len == -EAGAIN) || (len == -ERESTARTSYS)) {
+               if (!signal_pending(current)) {
+                       len = 0;
+                       goto out;
+               }
+               flush_all_signals();
+               goto read_again;
+       }
+out:
+       set_fs(oldmm);
+
+       Dprintk("in out:.. and will return %d.!\n", len);
+
+       return len;
+}
+
+void trunc_headers (tux_req_t *req)
+{
+       struct sock *sk = req->sock->sk;
+       int len, addr_len = 0;
+       struct kiocb iocb;
+
+       if (!req->parsed_len)
+               TUX_BUG();
+repeat_trunc:
+       init_sync_kiocb(&iocb, NULL);
+       len = sk->sk_prot->recvmsg(&iocb, sk, NULL, req->parsed_len, 1, MSG_TRUNC, &addr_len);
+       if (-EIOCBQUEUED == len)
+               len = wait_on_sync_kiocb(&iocb);
+       if ((len == -ERESTARTSYS) || (len == -EAGAIN)) {
+               flush_all_signals();
+               goto repeat_trunc;
+       }
+       Dprintk("truncated (TRUNC) %d bytes at %p. (wanted: %d.)\n", len, __builtin_return_address(0), req->parsed_len);
+
+
+
+       req->parsed_len = 0;
+}
+
+void print_req (tux_req_t *req)
+{
+       struct sock *sk;
+
+       printk("PRINT req %p <%p>, sock %p\n",
+                       req, __builtin_return_address(0), req->sock);
+       printk("... idx: %d\n", req->atom_idx);
+       if (req->sock) {
+               sk = req->sock->sk;
+               printk("... sock %p, sk %p, sk->state: %d, sk->err: %d\n", req->sock, sk, sk->sk_state, sk->sk_err);
+               printk("... write_queue: %d, receive_queue: %d, error_queue: %d, keepalive: %d, status: %d\n", !skb_queue_empty(&sk->sk_write_queue), !skb_queue_empty(&sk->sk_receive_queue), !skb_queue_empty(&sk->sk_error_queue), req->keep_alive, req->status);
+               printk("...tp->send_head: %p\n", sk->sk_send_head);
+               printk("...tp->snd_una: %08x\n", tcp_sk(sk)->snd_una);
+               printk("...tp->snd_nxt: %08x\n", tcp_sk(sk)->snd_nxt);
+               printk("...tp->packets_out: %08x\n", tcp_sk(sk)->packets_out);
+       }
+       printk("... meth:{%s}, uri:{%s}, query:{%s}, ver:{%s}\n", req->method_str ? req->method_str : "<null>", req->uri_str ? req->uri_str : "<null>", req->query_str ? req->query_str : "<null>", req->version_str ? req->version_str : "<null>");
+       printk("... post_data:{%s}(%d).\n", req->post_data_str, req->post_data_len);
+       printk("... headers: {%s}\n", req->headers);
+}
+/* 
+ * parse_request() reads all available TCP/IP data and prepares
+ * the request if the TUX request is complete. (we can get TUX
+ * requests in several packets.) Invalid requests are redirected
+ * to the secondary server.
+ */
+
+void parse_request (tux_req_t *req, int cachemiss)
+{
+       int len, parsed_len;
+       struct sock *sk = req->sock->sk;
+       struct tcp_opt *tp = tcp_sk(sk);
+       int was_keepalive = req->keep_alive;
+
+       if (req->magic != TUX_MAGIC)
+               TUX_BUG();
+
+       SET_TIMESTAMP(req->parse_timestamp);
+
+       spin_lock_irq(&req->ti->work_lock);
+       add_keepalive_timer(req);
+       if (test_and_set_bit(0, &req->idle_input))
+               TUX_BUG();
+       INC_STAT(nr_idle_input_pending);
+       spin_unlock_irq(&req->ti->work_lock);
+
+       Dprintk("idled request %p.\n", req);
+
+restart:
+
+       if (tp->urg_data && !(tp->urg_data & TCP_URG_READ)) {
+               len = zap_urg_data(req->sock);
+               if (tp->urg_data && !(tp->urg_data & TCP_URG_READ)) {
+                       req->error = TUX_ERROR_CONN_CLOSE;
+                       goto redirect_error;
+               }
+       }
+
+       INC_STAT(input_slowpath);
+
+       if (!req->headers)
+               req->headers = tux_kmalloc(tux_max_header_len);
+
+       /* First, read the data */
+       len = read_request(req->sock, (char *)req->headers, tux_max_header_len-1);
+       if (len < 0) {
+               req->error = TUX_ERROR_CONN_CLOSE;
+               goto redirect_error;
+       }
+       if (!len)
+               GOTO_INCOMPLETE;
+
+       /*
+        * Make it a zero-delimited string to automatically get
+        * protection against various buffer overflow situations.
+        * Then pass it to the TUX application protocol stack.
+        */
+       ((char *)req->headers)[len] = 0;
+       req->headers_len = len;
+
+       parsed_len = req->proto->parse_message(req, len);
+
+       /*
+        * Is the request fully read? (or is there any error)
+        */
+       if (parsed_len < 0)
+               GOTO_REDIRECT;
+       if (!parsed_len) {
+               /*
+                * Push pending ACK which was delayed due to the
+                * pingpong optimization:
+                */
+               if (was_keepalive) {
+                       lock_sock(sk);
+                       tp->ack.pingpong = 0;
+                       tp->ack.pending |= TCP_ACK_PUSHED;
+                       cleanup_rbuf(sk, 1);
+                       release_sock(sk);
+               }
+               if (len >= tux_max_header_len-1)
+                       GOTO_REDIRECT;
+               GOTO_INCOMPLETE;
+       }
+       unidle_req(req);
+
+       tp->nonagle = 2;
+
+       add_req_to_workqueue(req);
+       return;
+
+redirect:
+       TDprintk("req %p will be redirected!\n", req);
+       req_err(req);
+
+redirect_error:
+       unidle_req(req);
+
+       if (len < 0)
+               req->parsed_len = 0;
+       else
+               req->parsed_len = len;
+
+       INC_STAT(parse_static_redirect);
+       if (req->headers)
+               kfree(req->headers);
+       req->headers = NULL;
+       if (req->error)
+               zap_request(req, cachemiss);
+       return;
+
+incomplete:
+       if (req->error)
+               goto redirect_error;
+       if (tp->urg_data && !(tp->urg_data & TCP_URG_READ))
+               goto restart;
+
+       add_tux_atom(req, parse_request);
+       INC_STAT(parse_static_incomplete);
+       tux_push_req(req);
+}
+
+int process_requests (threadinfo_t *ti, tux_req_t **user_req)
+{
+       struct list_head *head, *curr;
+       int count = 0;
+       tux_req_t *req;
+
+       *user_req = NULL;
+
+restart_loop:
+       spin_lock_irq(&ti->work_lock);
+       head = &ti->work_pending;
+       curr = head->next;
+       
+       if (curr != head) {
+               int i;
+
+               req = list_entry(curr, tux_req_t, work);
+               Dprintk("PROCESS req %p <%p>.\n",
+                       req, __builtin_return_address(0));
+               for (i = 0; i < req->atom_idx; i++)
+                       Dprintk("... atom %d: %p\n", i, req->atoms[i]);
+
+               if (req->ti != ti)
+                       TUX_BUG();
+               if (req->magic != TUX_MAGIC)
+                       TUX_BUG();
+
+               if (list_empty(&req->work))
+                       TUX_BUG();
+               list_del(curr);
+               DEBUG_DEL_LIST(&req->work);
+               spin_unlock_irq(&ti->work_lock);
+
+               if (!req->atom_idx) {
+                       if (req->usermode) {
+                               *user_req = req;
+                               return count;
+                       }
+                       /*
+                        * idx == 0 requests are flushed automatically.
+                        */
+                       flush_request(req, 0);
+               } else
+                       tux_schedule_atom(req, 0);
+               count++;
+               goto restart_loop;
+       }
+       spin_unlock_irq(&ti->work_lock);
+
+       return count;
+}
+
+int tux_flush_workqueue (threadinfo_t *ti)
+{
+       struct list_head *head, *curr, *next;
+       tux_req_t *req;
+       int count = 0;
+
+restart:
+       spin_lock_irq(&ti->work_lock);
+       head = &ti->work_pending;
+       curr = head->next;
+
+       if (curr != head) {
+               req = list_entry(curr, tux_req_t, work);
+               next = curr->next;
+               clear_bit(0, &req->idle_input);
+               clear_bit(0, &req->wait_output_space);
+               if (list_empty(&req->work))
+                       TUX_BUG();
+               list_del(curr);
+               DEBUG_DEL_LIST(curr);
+               DEC_STAT(nr_input_pending);
+               spin_unlock_irq(&ti->work_lock);
+#if CONFIG_TUX_DEBUG
+               req->bytes_expected = 0;
+#endif
+               req->in_file.f_pos = 0;
+               req->atom_idx = 0;
+               clear_keepalive(req);
+               req->status = -1;
+               if (req->usermode) {
+                       req->usermode = 0;
+                       req->private = 0;
+               }
+               flush_request(req, 0);
+               count++;
+               goto restart;
+       }
+       spin_unlock_irq(&ti->work_lock);
+
+       return count;
+}
+
+int print_all_requests (threadinfo_t *ti)
+{
+       struct list_head *head, *curr;
+       tux_req_t *req;
+       int count = 0;
+
+       spin_lock_irq(&ti->work_lock);
+       head = &ti->all_requests;
+       curr = head->next;
+
+       while (curr != head) {
+               req = list_entry(curr, tux_req_t, all);
+               curr = curr->next;
+               print_req(req);
+               count++;
+       }
+       spin_unlock_irq(&ti->work_lock);
+
+       return count;
+}
+
diff --git a/net/tux/logger.c b/net/tux/logger.c
new file mode 100644 (file)
index 0000000..5ce80c1
--- /dev/null
@@ -0,0 +1,855 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * Cleaned up logger output for Alpha.
+ * -- Phil Ezolt (Phillip.Ezolt@compaq.com) & Bill Carr (wcarr92@yahoo.com)
+ *
+ * logger.c: log requests finished by TUX.
+ */
+
+#define __KERNEL_SYSCALLS__
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+static spinlock_t log_lock = SPIN_LOCK_UNLOCKED;
+static unsigned int log_head, log_tail;
+static char * log_buffer = NULL;
+static DECLARE_WAIT_QUEUE_HEAD(log_wait);
+static DECLARE_WAIT_QUEUE_HEAD(log_full);
+static int logger_pid = 0;
+
+/*
+ * High-speed TUX logging architecture:
+ *
+ * All fast threads share a common log-ringbuffer. (default size 1MB)
+ * Log entries are binary and are padded to be cacheline aligned, this
+ * ensures that there is no cache-pingpong between fast threads.
+ *
+ * The logger thread writes out pending log entries within 1 second
+ * (buffer-cache writes data out within 5 seconds). The logger thread
+ * gets activated once we have more than 25% of the log ringbuffer
+ * filled - or the 1 second log timeout expires. Fast threads block
+ * if if more than 95% of the ringbuffer is filled and unblock only
+ * if used logbuffer space drops below 90%.
+ *
+ * This architecture guarantees that 1) logging is reliable (no
+ * log entry is ever lost), 2) timely (touches disk within 6 seconds),
+ * 3) in the log-contention case the saturation behavior is still
+ * write-clustered, but 4) if the logger thread can keep up then
+ * the coupling is completely asynchron and parallel.
+ *
+ * The binary log format gives us about 50% saved IO/memory bandwith
+ * and 50% less on-disk used log space than the traditional W3C ASCII
+ * format.
+ *
+ * (We might switch to raw IO though to write the logfile.)
+ */
+
+#define SOFT_LIMIT             (LOG_LEN*25/100)
+#define HARD_LIMIT             (LOG_LEN*95/100)
+#define HARD_RELAX_LIMIT       (LOG_LEN*90/100)
+
+unsigned int tux_logentry_align_order = 5;
+
+#if SMP_CACHE_BYTES == 8
+# define TUX_LOGENTRY_ALIGN 3
+#else
+#if SMP_CACHE_BYTES == 16
+# define TUX_LOGENTRY_ALIGN 4
+#else
+#if SMP_CACHE_BYTES == 32
+# define TUX_LOGENTRY_ALIGN 5
+#else
+#if SMP_CACHE_BYTES == 64
+# define TUX_LOGENTRY_ALIGN 6
+#else
+#if SMP_CACHE_BYTES == 128
+# define TUX_LOGENTRY_ALIGN 7
+#else
+#if SMP_CACHE_BYTES == 256
+# define TUX_LOGENTRY_ALIGN 8
+#else
+#error Add entry!
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif
+
+#define ROUND_UP(x) (((((x)-1) >> TUX_LOGENTRY_ALIGN) + 1) \
+                                       << TUX_LOGENTRY_ALIGN)
+
+static void __throttle_logging (void)
+{
+       DECLARE_WAITQUEUE(wait, current);
+       int pending;
+
+       add_wait_queue(&log_full, &wait);
+       for (;;) {
+               static unsigned long last_warning = 0;
+
+               if (jiffies - last_warning > 10*HZ) {
+                       last_warning = jiffies;
+                       printk(KERN_NOTICE "TUX: log buffer overflow, have to throttle TUX thread!\n");
+               }
+
+               current->state = TASK_INTERRUPTIBLE;
+
+               spin_lock(&log_lock);
+               pending = log_head-log_tail;
+               spin_unlock(&log_lock);
+
+               if ((pending % LOG_LEN) < HARD_LIMIT)
+                       break;
+
+               schedule();
+       }
+       current->state = TASK_RUNNING;
+       remove_wait_queue(&log_full, &wait);
+}
+
+#if CONFIG_TUX_DEBUG
+#define CHECK_LOGPTR(ptr) \
+do { \
+       if ((ptr < log_buffer) || (ptr > log_buffer + LOG_LEN)) { \
+               printk(KERN_ERR "TUX: ouch: log ptr %p > %p + %ld!\n", \
+                       ptr, log_buffer, LOG_LEN); \
+               TUX_BUG(); \
+       } \
+} while (0)
+#else
+#define CHECK_LOGPTR(ptr) do { } while (0)
+#endif
+
+void __log_request (tux_req_t *req)
+{
+       char *str, *next;
+       const char *uri_str;
+       unsigned int inc, len, uri_len, pending, next_head, def_vhost_len = 0;
+       unsigned long flags;
+
+       if (req->proto->pre_log)
+               req->proto->pre_log(req);
+       /*
+        * Log the reply status (success, or type of failure)
+        */
+       if (!tux_log_incomplete && (!req->status || (req->bytes_sent == -1))) {
+               
+               Dprintk("not logging req %p: {%s} [%d/%d]\n", req, req->uri_str, req->status, req->bytes_sent);
+               return;
+       }
+       Dprintk("uri: {%s} [%d]\n", req->uri_str, req->uri_len);
+
+#define NO_URI "<none>"
+       if (req->uri_len) {
+               uri_len = req->uri_len;
+               uri_str = req->uri_str;
+       } else {
+               uri_str = NO_URI;
+               uri_len = sizeof(NO_URI)-1;
+       }
+       len = uri_len + 1;
+
+       if (req->virtual) {
+               if (req->host_len)
+                       len += req->host_len;
+               else {
+                       def_vhost_len = strlen(tux_default_vhost);
+                       len += def_vhost_len;
+               }
+       }
+
+       Dprintk("method_str: {%s} [%d]\n", req->method_str, req->method_len);
+       len += req->method_len + 1;
+
+       Dprintk("version_str: {%s} [%d]\n", req->version_str, req->version_len);
+       len += req->version_len + 1;
+
+#if CONFIG_TUX_EXTENDED_LOG
+       Dprintk("user_agent_str: {%s} [%d]\n", req->user_agent_str, req->user_agent_len);
+       len += req->user_agent_len + 1;
+#endif
+       if (tux_referer_logging) {
+               Dprintk("referer_str: {%s} [%d]\n", req->referer_str, req->referer_len);
+               len += req->referer_len;
+       }
+       len++;
+
+       inc = 5*sizeof(u32) + len;
+#if CONFIG_TUX_EXTENDED_LOG
+       inc += 7*sizeof(u32);
+#endif
+
+       spin_lock_irqsave(&log_lock, flags);
+
+       next_head = ROUND_UP(log_head + inc);
+
+       if (next_head < LOG_LEN) {
+               str = log_buffer + log_head;
+               if (str > log_buffer + LOG_LEN)
+                       TUX_BUG();
+               log_head = next_head;
+       } else {
+               if (log_head < LOG_LEN)
+                       memset(log_buffer+log_head, 0, LOG_LEN-log_head);
+               str = log_buffer;
+               log_head = ROUND_UP(inc);
+       }
+
+       if (str < log_buffer || str+inc >= log_buffer+LOG_LEN)
+               TUX_BUG();
+
+       /*
+        * Log record signature - this makes finding the next entry
+        * easier (since record length is variable), and makes the
+        * binary logfile more robust against potential data corruption
+        * and other damage. The signature also servers as a log format
+        * version identifier.
+        */
+#if CONFIG_TUX_EXTENDED_LOG
+       *(u32 *)str = 0x2223beef;
+#else
+       *(u32 *)str = 0x1112beef;
+#endif
+       str += sizeof(u32);
+       CHECK_LOGPTR(str);
+
+       *(u32 *)str = 0;
+       /*
+        * Log the client IP address:
+        */
+       if (tux_ip_logging)
+               *(u32 *)str = req->client_addr;
+       str += sizeof(u32);
+       CHECK_LOGPTR(str);
+
+#if CONFIG_TUX_EXTENDED_LOG
+       /*
+        * Log the client port number:
+        */
+       *(u32 *)str = 0;
+       if (tux_ip_logging)
+               *(u32 *)str = req->client_port;
+       str += sizeof(u32);
+       CHECK_LOGPTR(str);
+#endif
+
+       /*
+        * Log the request timestamp, in units of 'seconds since 1970'.
+        */
+       *(u32 *)str = CURRENT_TIME.tv_sec;
+       str += sizeof(u32);
+       CHECK_LOGPTR(str);
+
+#if CONFIG_TUX_EXTENDED_LOG
+       *(u32 *)str = req->accept_timestamp; str += sizeof(u32);
+       *(u32 *)str = req->parse_timestamp; str += sizeof(u32);
+       *(u32 *)str = req->output_timestamp; str += sizeof(u32);
+       *(u32 *)str = req->flush_timestamp; str += sizeof(u32);
+       *(u32 *)str = req->had_cachemiss; str += sizeof(u32);
+       *(u32 *)str = req->keep_alive; str += sizeof(u32);
+#endif
+       /*
+        * Log the requested file size (in fact, log actual bytes sent.)
+        */
+       *(u32 *)str = req->bytes_sent;
+       str += sizeof(u32);
+       CHECK_LOGPTR(str);
+
+       *(u32 *)str = req->status;
+       str += sizeof(u32);
+       CHECK_LOGPTR(str);
+
+       /*
+        * Zero-terminated method, (base) URI, query and version string.
+        */
+       if (req->method_len) {
+               memcpy(str, req->method_str, req->method_len);
+               str += req->method_len;
+               CHECK_LOGPTR(str);
+       }
+       *str++ = 0;
+
+       if (req->virtual) {
+               if (req->host_len) {
+                       memcpy(str, req->host, req->host_len);
+                       str += req->host_len;
+               } else {
+                       memcpy(str, tux_default_vhost, def_vhost_len);
+                       str += def_vhost_len;
+               }
+               CHECK_LOGPTR(str);
+       }
+
+       memcpy(str, uri_str, uri_len);
+       str += uri_len;
+       *str++ = 0;
+
+       CHECK_LOGPTR(str);
+
+       if (req->version_len) {
+               memcpy(str, req->version_str, req->version_len);
+               str += req->version_len;
+               CHECK_LOGPTR(str);
+       }
+       *str++ = 0;
+#if CONFIG_TUX_EXTENDED_LOG
+       if (req->user_agent_len) {
+               memcpy(str, req->user_agent_str, req->user_agent_len);
+               str += req->user_agent_len;
+               CHECK_LOGPTR(str);
+       }
+       *str++ = 0;
+#endif
+       CHECK_LOGPTR(str);
+
+       if (tux_referer_logging && req->referer_len) {
+               memcpy(str, req->referer_str, req->referer_len);
+               str += req->referer_len;
+               CHECK_LOGPTR(str);
+       }
+       *str++ = 0;
+       CHECK_LOGPTR(str);
+       /*
+        * pad with spaces to next cacheline, with an ending newline.
+        * (not needed for the user-space log utility, but results in
+        * a more readable binary log file, and reduces the amount
+        * of cache pingpong.)
+        */
+       next = (char *)ROUND_UP((unsigned long)str);
+
+       CHECK_LOGPTR(next);
+       len = next-str;
+       memset(str, ' ', len);
+
+       pending = (log_head-log_tail) % LOG_LEN;
+       spin_unlock_irqrestore(&log_lock, flags);
+
+       if (pending >= SOFT_LIMIT)
+               wake_up(&log_wait);
+
+       if (pending >= HARD_LIMIT)
+               __throttle_logging();
+}
+
+void tux_push_pending (struct sock *sk)
+{
+       struct tcp_opt *tp = tcp_sk(sk);
+
+       Dprintk("pushing pending frames on sock %p.\n", sk);
+       lock_sock(sk);
+       if ((sk->sk_state == TCP_ESTABLISHED) && !sk->sk_err) {
+               tp->ack.pingpong = tux_ack_pingpong;
+               tp->nonagle = 1;
+               __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk, 0), TCP_NAGLE_OFF);
+       }
+       release_sock(sk);
+}
+
+inline void tux_push_req (tux_req_t *req)
+{
+       if (req->sock)
+               tux_push_pending(req->sock->sk);
+       if (req->data_sock)
+               tux_push_pending(req->data_sock->sk);
+}
+
+void __put_data_sock (tux_req_t *req)
+{
+       unlink_tux_data_socket(req);
+       if (req->data_sock->file)
+               fput(req->data_sock->file);
+       else
+               sock_release(req->data_sock);
+       req->data_sock = NULL;
+}
+
+/* open-coded sys_close */
+
+long tux_close(unsigned int fd)
+{
+       struct file * filp;
+       struct files_struct *files = current->files;
+
+       spin_lock(&files->file_lock);
+       if (fd >= files->max_fds)
+               goto out_unlock;
+       filp = files->fd[fd];
+       if (!filp)
+               goto out_unlock;
+       files->fd[fd] = NULL;
+       FD_CLR(fd, files->close_on_exec);
+       /* __put_unused_fd(files, fd); */
+       __FD_CLR(fd, files->open_fds);
+       if (fd < files->next_fd)
+               files->next_fd = fd;
+       spin_unlock(&files->file_lock);
+       return filp_close(filp, files);
+
+out_unlock:
+       spin_unlock(&files->file_lock);
+       return -EBADF;
+}
+
+void flush_request (tux_req_t *req, int cachemiss)
+{
+       struct socket *sock;
+       struct sock *sk;
+       int keep_alive;
+
+       if (cachemiss)
+               TUX_BUG();
+       __set_task_state(current, TASK_RUNNING);
+
+       if (req->magic != TUX_MAGIC)
+               TUX_BUG();
+       if (req->ti->thread != current)
+               TUX_BUG();
+#if CONFIG_TUX_DEBUG
+       if (req->bytes_expected && (req->bytes_sent != req->bytes_expected)) {
+               printk("hm, bytes_expected: %d != bytes_sent: %d!\n",
+                       req->bytes_expected, req->bytes_sent);
+               TUX_BUG();
+       }
+#endif
+       SET_TIMESTAMP(req->flush_timestamp);
+
+       log_request(req);
+       sock = req->sock;
+       sk = NULL;
+       if (sock)
+               sk = sock->sk;
+       Dprintk("FLUSHING req %p <%p> (sock %p, sk %p) (keepalive: %d, status: %d)\n", req, __builtin_return_address(0), sock, sk, req->keep_alive, req->status);
+       if (req->in_file.f_pos)
+               /*TUX_BUG()*/;
+       release_req_dentry(req);
+       req->private = 0;
+
+       if (req->docroot_dentry) {
+               dput(req->docroot_dentry);
+               req->docroot_dentry = NULL;
+               if (!req->docroot_mnt)
+                       TUX_BUG();
+       }
+       if (req->docroot_mnt) {
+               mntput(req->docroot_mnt);
+               req->docroot_mnt = NULL;
+       }
+
+       req->offset_start = 0;
+       req->offset_end = 0;
+       req->output_len = 0;
+       req->total_file_len = 0;
+       req->lendigits = 0;
+       req->mtime = 0;
+       req->etaglen = 0;
+       req->etag[0] = 0;
+       req->ftp_command = 0;
+
+       if (req->postponed)
+               TUX_BUG();
+       if (test_bit(0, &req->idle_input))
+               TUX_BUG();
+       if (test_bit(0, &req->wait_output_space))
+               TUX_BUG();
+       if (req->parsed_len)
+               trunc_headers(req);
+       if (req->parsed_len)
+               TUX_BUG();
+       req->attr = NULL;
+       req->usermode = 0;
+       req->usermodule_idx = 0;
+       req->atom_idx = 0;
+       if (req->module_dentry) {
+               dput(req->module_dentry);
+               req->module_dentry = NULL;
+       }
+       if (req->headers)
+               kfree(req->headers);
+       req->headers = NULL;
+       req->headers_len = 0;
+
+       req->method = METHOD_NONE;
+       req->method_len = 0;
+       req->method_str = NULL;
+       req->version = 0;
+       req->version_str = NULL;
+       req->version_len = 0;
+
+       req->uri_str = NULL;
+       req->uri_len = 0;
+
+       req->objectname[0] = 0;
+       req->objectname_len = 0;
+
+       req->query_str = NULL;
+       req->query_len = 0;
+
+       req->cookies_str = NULL;
+       req->cookies_len = 0;
+       req->parse_cookies = 0;
+
+       req->contentlen_str = NULL;
+       req->contentlen_len = 0;
+       req->content_len = 0;
+
+       req->user_agent_str = NULL;
+       req->user_agent_len = 0;
+
+       req->may_send_gzip = 0;
+       req->content_gzipped = 0;
+
+       req->content_type_str = NULL;
+       req->content_type_len = 0;
+
+       req->accept_str = NULL;
+       req->accept_len = 0;
+
+       req->accept_charset_str = NULL;
+       req->accept_charset_len = 0;
+
+       req->accept_encoding_str = NULL;
+       req->accept_encoding_len = 0;
+
+       req->accept_language_str = NULL;
+       req->accept_language_len = 0;
+
+       req->cache_control_str = NULL;
+       req->cache_control_len = 0;
+
+       req->if_modified_since_str = NULL;
+       req->if_modified_since_len = 0;
+
+       req->if_none_match_str = NULL;
+       req->if_none_match_len = 0;
+
+       req->if_range_str = NULL;
+       req->if_range_len = 0;
+
+       req->negotiate_str = NULL;
+       req->negotiate_len = 0;
+
+       req->pragma_str = NULL;
+       req->pragma_len = 0;
+
+       req->referer_str = NULL;
+       req->referer_len = 0;
+
+       req->post_data_str = NULL;
+       req->post_data_len = 0;
+
+       SET_TIMESTAMP(req->accept_timestamp);
+#if CONFIG_TUX_EXTENDED_LOG
+       req->parse_timestamp = 0;
+       req->output_timestamp = 0;
+       req->flush_timestamp = 0;
+#endif
+       req->status = 0;
+
+       req->total_bytes += req->bytes_sent;
+       req->bytes_sent = 0;
+#if CONFIG_TUX_DEBUG
+       req->bytes_expected = 0;
+#endif
+       req->body_len = 0;
+       keep_alive = req->keep_alive;
+       clear_keepalive(req);
+       req->had_cachemiss = 0;
+       // first_timestamp and total_bytes is kept!
+       req->event = 0;
+       req->lookup_dir = 0;
+       req->lookup_404 = 0;
+
+       req->error = 0;
+       req->user_error = 0;
+
+       if (req->abuf.page)
+               __free_page(req->abuf.page);
+       memset(&req->abuf, 0, sizeof(req->abuf));
+
+       if (sk && keep_alive) {
+               add_tux_atom(req, parse_request);
+               if (skb_queue_empty(&sk->sk_receive_queue)) {
+                       spin_lock_irq(&req->ti->work_lock);
+                       add_keepalive_timer(req);
+                       if (test_and_set_bit(0, &req->idle_input))
+                               TUX_BUG();
+                       /*
+                        * Avoid the race with the event callback:
+                        */
+                       if (skb_queue_empty(&sk->sk_receive_queue) ||
+                                  !test_and_clear_bit(0, &req->idle_input)) {
+                               INC_STAT(nr_idle_input_pending);
+                               spin_unlock_irq(&req->ti->work_lock);
+                               tux_push_req(req);
+                               goto out;
+                       }
+                       del_keepalive_timer(req);
+                       spin_unlock_irq(&req->ti->work_lock);
+               }
+               Dprintk("KEEPALIVE PENDING req %p <%p> (sock %p, sk %p) (keepalive: %d, status: %d)\n", req, __builtin_return_address(0), req->sock, req->sock->sk, req->keep_alive, req->status);
+               add_req_to_workqueue(req);
+               INC_STAT(nr_keepalive_optimized);
+               goto out;
+       }
+
+       del_timer_sync(&req->keepalive_timer);
+       del_timer_sync(&req->output_timer);
+
+       if (timer_pending(&req->keepalive_timer))
+               TUX_BUG();
+       if (timer_pending(&req->output_timer))
+               TUX_BUG();
+       if (!list_empty(&req->lru))
+               TUX_BUG();
+       req->nr_keepalives = 0;
+       req->client_addr = 0;
+       req->client_port = 0;
+       req->virtual = 0;
+       req->ftp_offset_start = 0;
+
+       req->host[0] = 0;
+       req->host_len = 0;
+
+       if (req->cwd_dentry) {
+               dput(req->cwd_dentry);
+               req->cwd_dentry = NULL;
+               if (!req->cwd_mnt)
+                       TUX_BUG();
+       }
+       if (req->cwd_mnt) {
+               mntput(req->cwd_mnt);
+               req->cwd_mnt = NULL;
+       }
+       put_data_sock(req);
+       req->prev_pos = 0;
+       req->curroff = 0;
+       req->total = 0;
+       if (req->dirp0) {
+               kfree(req->dirp0);
+               req->dirp0 = NULL;
+       }
+
+       if (sk)
+               unlink_tux_socket(req);
+       req->sock = NULL;
+       /*
+        * Close potential user-space file descriptors.
+        */
+       {
+               int fd = req->fd, ret;
+
+               if (fd != -1) {
+                       req->fd = -1;
+                       ret = tux_close(fd);
+                       if (ret)
+                               TUX_BUG();
+               } else
+                       if (sock)
+                               sock_release(sock);
+       }
+       kfree_req(req);
+out:
+       ;
+}
+
+static int warn_once = 1;
+
+static unsigned int writeout_log (void)
+{
+       unsigned int len, pending, next_log_tail;
+       mm_segment_t oldmm = get_fs();
+       struct file *log_filp;
+       char * str;
+       unsigned int ret;
+
+       if (tux_logging)
+               Dprintk("TUX logger: opening log file {%s}.\n", tux_logfile);
+       log_filp = tux_open_file(tux_logfile, O_CREAT|O_APPEND|O_WRONLY|O_LARGEFILE);
+       if (!log_filp) {
+               if (warn_once) {
+                       printk(KERN_ERR "TUX: could not open log file {%s}!\n",
+                               tux_logfile);
+                       warn_once = 0;
+               }
+               __set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ);
+               return 0;
+       }
+       spin_lock(&log_lock);
+       str = log_buffer + log_tail;
+       if (log_head < log_tail) {
+               len = LOG_LEN-log_tail;
+               next_log_tail = 0;
+       } else {
+               len = log_head-log_tail;
+               next_log_tail = log_head;
+       }
+       if (!len)
+               goto out;
+       spin_unlock(&log_lock);
+
+       set_fs(KERNEL_DS);
+       ret = log_filp->f_op->write(log_filp, str, len, &log_filp->f_pos);
+       set_fs(oldmm);
+
+       if (len != ret) {
+               if (ret == -ENOSPC) {
+                       printk(KERN_ERR "TUX: trying to write TUX logfile %s, but filesystem is full! Lost %d bytes of log data.\n", tux_logfile, len);
+               } else {
+                       printk(KERN_ERR "TUX: log write %d != %d.\n", ret, len);
+                       printk(KERN_ERR "TUX: log_filp: %p, str: %p, len: %d str[len-1]: %d.\n", log_filp, str, len, str[len-1]);
+               }
+               goto out_lock;
+       }
+
+       /*
+        * Sync log data to disk:
+        */
+       if (log_filp->f_op && log_filp->f_op->fsync) {
+               down(&log_filp->f_dentry->d_inode->i_sem);
+               log_filp->f_op->fsync(log_filp, log_filp->f_dentry, 1);
+               up(&log_filp->f_dentry->d_inode->i_sem);
+       }
+
+       /*
+        * Reduce the cache footprint of the logger file - it's
+        * typically write-once.
+        */
+       invalidate_inode_pages(log_filp->f_dentry->d_inode->i_mapping);
+
+out_lock:
+       spin_lock(&log_lock);
+out:
+       log_tail = next_log_tail;
+       pending = (log_head-log_tail) % LOG_LEN;
+       spin_unlock(&log_lock);
+
+       if (pending < HARD_LIMIT)
+               wake_up(&log_full);
+
+       fput(log_filp);
+       return pending;
+}
+
+static DECLARE_WAIT_QUEUE_HEAD(stop_logger_wait);
+static int stop_logger = 0;
+
+static int logger_thread (void *data)
+{
+       DECLARE_WAITQUEUE(wait, current);
+       mm_segment_t oldmm;
+
+       daemonize("TUX logger");
+
+       oldmm = get_fs();
+       set_fs(KERNEL_DS);
+       printk(KERN_NOTICE "TUX: logger thread started.\n");
+#if CONFIG_SMP
+       {
+               cpumask_t log_mask, map;
+
+               mask_to_cpumask(log_cpu_mask, &log_mask);
+               cpus_and(map, cpu_online_map, log_mask);
+               if(!(cpus_empty(map)))
+                       set_cpus_allowed(current, map);
+
+       }
+#endif
+
+
+       spin_lock_irq(&current->sighand->siglock);
+       siginitsetinv(&current->blocked, 0);
+       recalc_sigpending();
+       spin_unlock_irq(&current->sighand->siglock);
+
+       if (log_buffer)
+               TUX_BUG();
+       log_buffer = vmalloc(LOG_LEN);
+       memset(log_buffer, 0, LOG_LEN);
+       log_head = log_tail = 0;
+
+       current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
+
+       add_wait_queue(&log_wait, &wait);
+       for (;;) {
+               if (tux_logging)
+                       Dprintk("logger does writeout - stop:%d.\n", stop_logger);
+
+               while (writeout_log() >= SOFT_LIMIT) {
+                       if (stop_logger)
+                               break;
+               }
+               if (stop_logger)
+                       break;
+                       /* nothing */;
+
+               if (tux_logging)
+                       Dprintk("logger does sleep - stop:%d.\n", stop_logger);
+               __set_current_state(TASK_INTERRUPTIBLE);
+               if (log_head != log_tail) {
+                       __set_current_state(TASK_RUNNING);
+                       continue;
+               }
+               schedule_timeout(HZ);
+               if (tux_logging)
+                       Dprintk("logger back from sleep - stop:%d.\n", stop_logger);
+               if (signal_pending(current))
+                       flush_all_signals();
+       }
+       remove_wait_queue(&log_wait, &wait);
+
+       vfree(log_buffer);
+       log_buffer = NULL;
+       stop_logger = 0;
+       wake_up(&stop_logger_wait);
+
+       set_fs(oldmm);
+
+       return 0;
+}
+
+void start_log_thread (void)
+{
+       warn_once = 1;
+
+       logger_pid = kernel_thread(logger_thread, NULL, 0);
+       if (logger_pid < 0)
+               TUX_BUG();
+}
+
+void stop_log_thread (void)
+{
+       DECLARE_WAITQUEUE(wait, current);
+
+       Dprintk("stopping logger thread %d ...\n", logger_pid);
+
+       __set_current_state(TASK_UNINTERRUPTIBLE);
+       add_wait_queue(&stop_logger_wait, &wait);
+       stop_logger = 1;
+       wake_up(&log_wait);
+       schedule();
+       __set_current_state(TASK_RUNNING);
+       remove_wait_queue(&stop_logger_wait, &wait);
+
+       Dprintk("logger thread stopped!\n");
+}
diff --git a/net/tux/main.c b/net/tux/main.c
new file mode 100644 (file)
index 0000000..e33241f
--- /dev/null
@@ -0,0 +1,1413 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * main.c: main management and initialization routines
+ */
+
+#define __KERNEL_SYSCALLS__
+#define __KERNEL_SYSCALLS_NO_ERRNO__
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+/*
+ * Threads information.
+ */
+unsigned int nr_tux_threads;
+static atomic_t nr_tux_threads_running = ATOMIC_INIT(0);
+static int stop_threads = 0;
+
+threadinfo_t threadinfo[CONFIG_TUX_NUMTHREADS];
+
+static void flush_all_requests (threadinfo_t *ti);
+
+void flush_all_signals (void)
+{
+       spin_lock_irq(&current->sighand->siglock);
+       flush_signals(current);
+       recalc_sigpending();
+       spin_unlock_irq(&current->sighand->siglock);
+}
+
+int nr_requests_used (void)
+{
+       unsigned int i, nr = 0;
+
+       for (i = 0; i < nr_tux_threads; i++) {
+               threadinfo_t *ti = threadinfo + i;
+               nr += ti->nr_requests - ti->nr_free_requests;
+       }
+
+       return nr;
+}
+
+static inline int accept_pending (threadinfo_t *ti)
+{
+       int j;
+
+       for (j = 0; j < CONFIG_TUX_NUMSOCKETS; j++) {
+               if (!ti->listen[j].proto)
+                       break;
+               if (!ti->listen[j].sock)
+                       break;
+               if (tcp_sk(ti->listen[j].sock->sk)->accept_queue)
+                       return 1;
+       }
+       return 0;
+}
+
+static inline int requests_pending (threadinfo_t *ti)
+{
+       if (!list_empty(&ti->work_pending))
+               return 1;
+       return 0;
+}
+
+static int event_loop (threadinfo_t *ti)
+{
+       tux_req_t *req;
+       int work_done;
+
+repeat_accept:
+       if (ti->thread != current)
+               TUX_BUG();
+
+       /*
+        * Any (relevant) event on the socket will change this
+        * thread to TASK_RUNNING because we add it to both
+        * the main listening and the connection request socket
+        * waitqueues. Thus we can do 'lazy checking' of work
+        * to be done and schedule away only if the thread is
+        * still TASK_INTERRUPTIBLE. This makes TUX fully
+        * event driven.
+        */
+       set_task_state(current, TASK_INTERRUPTIBLE);
+       current->flags |= PF_MEMALLOC;
+       work_done = 0;
+       if (accept_pending(ti))
+               work_done = accept_requests(ti);
+
+       if (requests_pending(ti)) {
+               work_done = process_requests(ti, &req);
+               if (req)
+                       goto handle_userspace_req;
+       }
+
+       /*
+        * Be nice to other processes:
+        */
+       if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) {
+               __set_task_state(current, TASK_RUNNING);
+               schedule();
+               goto repeat_accept;
+       }
+
+       if (ti->userspace_req)
+               TUX_BUG();
+       if (unlikely(stop_threads))
+               goto handle_stop;
+
+       /* Any signals? */
+       if (unlikely(signal_pending(current)))
+               goto handle_signal;
+
+       if (work_done)
+               goto repeat_accept;
+       /*
+        * Any socket event either on the listen socket
+        * or on the request sockets will wake us up:
+        */
+       if ((current->state != TASK_RUNNING) &&
+                       !requests_pending(ti) && !accept_pending(ti)) {
+               Dprintk("fast thread: no work to be done, sleeping.\n");
+               schedule();
+               Dprintk("fast thread: back from sleep!\n");
+               goto repeat_accept;
+       }
+       goto repeat_accept;
+
+handle_userspace_req:
+       if (req->attr)
+               TUX_BUG();
+       switch_docroot(req);
+       ti->userspace_req = req;
+       __set_task_state(current, TASK_RUNNING);
+       return TUX_RETURN_USERSPACE_REQUEST;
+
+handle_signal:
+       __set_task_state(current, TASK_RUNNING);
+       return TUX_RETURN_SIGNAL;
+
+handle_stop:
+       __set_task_state(current, TASK_RUNNING);
+       return TUX_RETURN_EXIT;
+}
+
+static int init_queues (int nr_tux_threads)
+{
+       int i;
+
+       for (i = 0; i < nr_tux_threads; i++) {
+               threadinfo_t *ti = threadinfo + i;
+
+               INIT_LIST_HEAD(&ti->all_requests);
+
+               ti->free_requests_lock = SPIN_LOCK_UNLOCKED;
+               INIT_LIST_HEAD(&ti->free_requests);
+
+               ti->work_lock = SPIN_LOCK_UNLOCKED;
+               INIT_LIST_HEAD(&ti->work_pending);
+               INIT_LIST_HEAD(&ti->lru);
+
+       }
+       return 0;
+}
+
+int tux_chroot (char *dir)
+{
+       kernel_cap_t saved_cap = current->cap_effective;
+       mm_segment_t oldmm;
+       int err;
+
+       /* Allow chroot dir to be in kernel space. */
+       oldmm = get_fs(); set_fs(KERNEL_DS);
+       set_fs(KERNEL_DS);
+       cap_raise (current->cap_effective, CAP_SYS_CHROOT);
+
+       err = chroot(dir);
+       if (!err)
+               chdir("/");
+
+       current->cap_effective = saved_cap;
+       set_fs(oldmm);
+
+       return err;
+}
+
+/*
+ * Right now this is not fully SMP-safe against multiple TUX
+ * managers. It's just a rudimentary protection against typical
+ * mistakes.
+ */
+static int initialized = 0;
+
+#define MAX_DOCROOTLEN 500
+
+static int lookup_docroot(struct nameidata *docroot, const char *name)
+{
+       int err;
+
+       docroot->mnt = mntget(current->fs->rootmnt);
+       docroot->dentry = dget(current->fs->root);
+       docroot->last.len = 0;
+       docroot->flags = LOOKUP_FOLLOW;
+
+       err = path_walk(name, docroot);
+       if (err) {
+               mntput(docroot->mnt);
+               docroot->mnt = NULL;
+               return err;
+       }
+       return 0;
+}
+
+static int user_req_startup (void)
+{
+       char name[MAX_DOCROOTLEN];
+       struct nameidata *docroot;
+       unsigned int i;
+       int err;
+
+       if (initialized)
+               return -EINVAL;
+       initialized = 1;
+
+       /*
+        * Look up the HTTP and FTP document root.
+        * (typically they are shared, but can be 
+        * different directories.)
+        */
+       docroot = &tux_proto_http.main_docroot;
+       if (docroot->mnt)
+               TUX_BUG();
+       strcpy(name, tux_common_docroot);
+       strcat(name, tux_http_subdocroot);
+
+       err = lookup_docroot(docroot, name);
+       if (err) {
+               initialized = 0;
+               printk(KERN_ERR "TUX: could not look up HTTP documentroot: \"%s\"\n", name);
+               return err;
+       }
+
+       docroot = &tux_proto_ftp.main_docroot;
+       if (docroot->mnt)
+               TUX_BUG();
+       strcpy(name, tux_common_docroot);
+       strcat(name, tux_ftp_subdocroot);
+
+       err = lookup_docroot(docroot, name);
+       if (err) {
+abort:
+               docroot = &tux_proto_http.main_docroot;
+               path_release(docroot);
+               memset(docroot, 0, sizeof(*docroot));
+               initialized = 0;
+               printk(KERN_ERR "TUX: could not look up FTP documentroot: \"%s\"\n", name);
+               return err;
+       }
+
+       /*
+        * Start up the logger thread. (which opens the logfile)
+        */
+       start_log_thread();
+
+       nr_tux_threads = tux_threads;
+       if (nr_tux_threads < 1) 
+               nr_tux_threads = 1;
+       if (nr_tux_threads > CONFIG_TUX_NUMTHREADS) 
+               nr_tux_threads = CONFIG_TUX_NUMTHREADS;
+       tux_threads = nr_tux_threads;
+
+       /*
+        * Set up per-thread work-queues:
+        */
+       memset(threadinfo, 0, CONFIG_TUX_NUMTHREADS*sizeof(threadinfo_t));
+       init_queues(nr_tux_threads);
+
+       /*
+        * Prepare the worker thread structures.
+        */
+       for (i = 0; i < nr_tux_threads; i++) {
+               threadinfo_t *ti = threadinfo + i;
+               ti->cpu = i;
+               ti->gzip_state.workspace =
+                       vmalloc(zlib_deflate_workspacesize());
+               if (!ti->gzip_state.workspace ||
+                           (zlib_deflateInit(&ti->gzip_state, 6) != Z_OK)) {
+                       stop_log_thread();
+                       goto abort;
+               }
+               init_MUTEX(&ti->gzip_sem);
+       }
+
+       __module_get(tux_module);
+
+       return 0;
+}
+
+static DECLARE_WAIT_QUEUE_HEAD(wait_stop);
+static DECLARE_WAIT_QUEUE_HEAD(thread_stopped);
+
+static int user_req_shutdown (void)
+{
+       DECLARE_WAITQUEUE(wait, current);
+       struct nameidata *docroot;
+       int i, err = -EINVAL;
+
+       lock_kernel();
+       if (!initialized) {
+               Dprintk("TUX is not up - cannot shut down.\n");
+               goto err;
+       }
+       initialized = 0;
+       stop_threads = 1;
+       add_wait_queue(&thread_stopped, &wait);
+
+wait_more:
+       /*
+        * Wake up all the worker threads so they notice
+        * that we are being stopped.
+        */
+       set_task_state(current, TASK_UNINTERRUPTIBLE);
+       if (atomic_read(&nr_tux_threads_running)) {
+               Dprintk("TUX: shutdown, %d threads still running.\n",
+                       atomic_read(&nr_tux_threads_running));
+               wake_up(&wait_stop);
+               schedule();
+               goto wait_more;
+       }
+       set_task_state(current, TASK_RUNNING);
+       stop_threads = 0;
+       remove_wait_queue(&thread_stopped, &wait);
+
+       if (nr_async_io_pending())
+               TUX_BUG();
+
+       stop_log_thread();
+
+       docroot = &tux_proto_http.main_docroot;
+       path_release(docroot);
+       memset(docroot, 0, sizeof(*docroot));
+       docroot = &tux_proto_ftp.main_docroot;
+       path_release(docroot);
+       memset(docroot, 0, sizeof(*docroot));
+       err = 0;
+
+       flush_dentry_attributes();
+       free_mimetypes();
+       unregister_all_tuxmodules();
+
+       for (i = 0; i < nr_tux_threads; i++) {
+               threadinfo_t *ti = threadinfo + i;
+               vfree(ti->gzip_state.workspace);
+       }
+
+       module_put(tux_module);
+
+err:
+       unlock_kernel();
+       return err;
+}
+
+void drop_permissions (void)
+{
+       /*
+        * Userspace drops privileges already, and group
+        * membership is important to keep.
+        */
+       /* Give the new process no privileges.. */
+       current->uid = current->euid =
+               current->suid = current->fsuid = tux_cgi_uid;
+       current->gid = current->egid =
+               current->sgid = current->fsgid = tux_cgi_gid;
+       cap_clear(current->cap_permitted);
+       cap_clear(current->cap_inheritable);
+       cap_clear(current->cap_effective);
+}
+
+static int wait_for_others (void)
+{
+       threadinfo_t *ti;
+       unsigned int cpu;
+
+repeat:
+       if (signal_pending(current))
+               return -1;
+       set_current_state(TASK_INTERRUPTIBLE);
+       schedule_timeout(HZ/10);
+
+       for (cpu = 0; cpu < nr_tux_threads; cpu++) {
+               ti = threadinfo + cpu;
+               if (ti->listen_error)
+                       return -1;
+               if (!ti->started)
+                       goto repeat;
+       }
+       /* ok, all threads have started up. */
+       return 0;
+}
+
+static void zap_listen_sockets (threadinfo_t *ti)
+{
+       struct socket *sock;
+       int i;
+
+       for (i = 0; i < CONFIG_TUX_NUMSOCKETS; i++) {
+               if (!ti->listen[i].proto)
+                       break;
+               sock = ti->listen[i].sock;
+               if (!ti->listen[i].cloned && sock) {
+                       while (waitqueue_active(sock->sk->sk_sleep))
+                               yield();
+                       sock_release(sock);
+               }
+               ti->listen[i].sock = NULL;
+               ti->listen[i].proto = NULL;
+               ti->listen[i].cloned = 0;
+       }
+}
+
+static DECLARE_MUTEX(serialize_startup);
+
+static int user_req_start_thread (threadinfo_t *ti)
+{
+       unsigned int err, cpu, i, j, k;
+       struct k_sigaction *ka;
+
+       cpu = ti->cpu;
+#if CONFIG_SMP
+       {
+               unsigned int mask;
+               cpumask_t cpu_mask, map;
+
+               mask = 1 << ((cpu + tux_cpu_offset) % num_online_cpus());
+
+               mask_to_cpumask(mask, &cpu_mask);
+               cpus_and(map, cpu_mask, cpu_online_map);
+               if(!(cpus_empty(map)))
+                       set_cpus_allowed(current, map);         
+       }
+#endif
+       ti->thread = current;
+       atomic_inc(&nr_tux_threads_running);
+
+       err = start_cachemiss_threads(ti);
+       if (err)
+               goto out;
+
+       init_waitqueue_entry(&ti->stop, current);
+       for (j = 0; j < CONFIG_TUX_NUMSOCKETS; j++)
+               init_waitqueue_entry(ti->wait_event + j, current);
+
+       ka = current->sighand->action + SIGCHLD-1;
+       ka->sa.sa_handler = SIG_IGN;
+
+       /* Block all signals except SIGKILL, SIGSTOP, SIGHUP and SIGCHLD */
+       spin_lock_irq(&current->sighand->siglock);
+       siginitsetinv(&current->blocked, sigmask(SIGKILL) |
+                       sigmask(SIGSTOP)| sigmask(SIGHUP) | sigmask(SIGCHLD));
+       recalc_sigpending();
+       spin_unlock_irq(&current->sighand->siglock);
+
+       if (!tux_listen[cpu][0].proto) {
+               printk(KERN_ERR "no listen socket specified for TUX thread %d, in /proc/net/tux/%d/listen/, aborting.\n", cpu, cpu);
+               goto error;
+       }
+
+       /*
+        * Serialize startup so that listen sockets can be
+        * created race-free.
+        */
+       down(&serialize_startup);
+
+       Dprintk("thread %d initializing sockets.\n", cpu);
+
+       for (k = 0; k < CONFIG_TUX_NUMSOCKETS; k++) {
+               tux_socket_t *e1, *e2;
+
+               e1 = tux_listen[cpu] + k;
+               if (!e1->proto)
+                       break;
+               for (i = 0; i < CONFIG_TUX_NUMTHREADS; i++) {
+                       if (i == cpu)
+                               continue;
+                       for (j = 0; j < CONFIG_TUX_NUMSOCKETS; j++) {
+                               e2 = tux_listen[i] + j;
+                               if (!e2->proto)
+                                       continue;
+                               if ((e1->ip == e2->ip) && (e1->port == e2->port) && (e1->proto == e2->proto) && threadinfo[i].listen[j].proto) {
+                                       ti->listen[k] = threadinfo[i].listen[j];
+                                       ti->listen[k].cloned = 1;
+                                       Dprintk("cloned socket %d from thread %d's socket %d.\n", k, i, j);
+                                       goto next_socket;
+                               }
+                       }
+               }
+
+               ti->listen[k].sock = start_listening(tux_listen[cpu] + k, cpu);
+               if (!ti->listen[k].sock)
+                       goto error_unlock;
+               ti->listen[k].cloned = 0;
+               ti->listen[k].proto = tux_listen[cpu][k].proto;
+               Dprintk("thread %d got sock %p (%d), proto %s.\n", cpu, ti->listen[k].sock, k, ti->listen[k].proto->name);
+next_socket:
+               ;
+       }
+       Dprintk("thread %d done initializing sockets.\n", cpu);
+       up(&serialize_startup);
+
+       if (wait_for_others())
+               goto error_nomsg;
+
+       if (!ti->listen[0].proto) {
+               printk("hm, socket 0 has no protocol.\n");
+               goto error;
+       }
+
+       add_wait_queue(&wait_stop, &ti->stop);
+       for (j = 0; j < CONFIG_TUX_NUMSOCKETS; j++)
+               if (ti->listen[j].proto)
+                       add_wait_queue_exclusive(ti->listen[j].sock->sk->sk_sleep,
+                               ti->wait_event + j);
+       drop_permissions();
+
+       __module_get(tux_module);
+       return 0;
+
+error_unlock:
+       up(&serialize_startup);
+error:
+       printk(KERN_NOTICE "TUX: could not start worker thread %d.\n", ti->cpu);
+
+error_nomsg:
+       ti->listen_error = 1;
+       ti->started = 0;
+
+       zap_listen_sockets(ti);
+       flush_all_requests(ti);
+       stop_cachemiss_threads(ti);
+
+       err = -EINVAL;
+
+out:
+       /*
+        * Last thread close the door:
+        */
+       if (atomic_dec_and_test(&nr_tux_threads_running))
+               user_req_shutdown();
+
+       return -err;
+}
+
+static int flush_idleinput (threadinfo_t * ti)
+{
+       struct list_head *head, *tmp;
+       tux_req_t *req;
+       int count = 0;
+
+       head = &ti->all_requests;
+       tmp = head->next;
+
+       while (tmp != head) {
+               req = list_entry(tmp, tux_req_t, all);
+               tmp = tmp->next;
+               if (test_bit(0, &req->idle_input)) {
+                       idle_event(req);
+                       count++;
+               }
+       }
+       return count;
+}
+
+static int flush_waitoutput (threadinfo_t * ti)
+{
+       struct list_head *head, *tmp;
+       tux_req_t *req;
+       int count = 0;
+
+       head = &ti->all_requests;
+       tmp = head->next;
+
+       while (tmp != head) {
+               req = list_entry(tmp, tux_req_t, all);
+               tmp = tmp->next;
+               if (test_bit(0, &req->wait_output_space)) {
+                       output_space_event(req);
+                       count++;
+               }
+       }
+       return count;
+}
+
+static void flush_all_requests (threadinfo_t *ti)
+{
+       for (;;) {
+               int count;
+
+               count = flush_idleinput(ti);
+               count += flush_waitoutput(ti);
+               count += tux_flush_workqueue(ti);
+               count += flush_freequeue(ti);
+               if (!ti->nr_requests)
+                       break;
+               /*
+                * Go through again if we advanced:
+                */
+               if (count)
+                       continue;
+               Dprintk("flush_all_requests: %d requests still waiting.\n", ti->nr_requests);
+#if TUX_DEBUG
+               count = print_all_requests(ti);
+               Dprintk("flush_all_requests: printed %d requests.\n", count);
+#endif
+               current->state = TASK_UNINTERRUPTIBLE;
+               schedule_timeout(HZ/10);
+       }
+}
+
+int nr_async_io_pending (void)
+{
+       unsigned int i, sum = 0;
+
+       for (i = 0; i < nr_tux_threads; i++) {
+               threadinfo_t *ti = threadinfo + i;
+               if (ti->iot)
+                       sum += ti->iot->nr_async_pending;
+       }
+       return sum;
+}
+
+static int user_req_stop_thread (threadinfo_t *ti)
+{
+       int j;
+
+       printk(KERN_NOTICE "TUX: thread %d stopping ...\n",
+               (int)(ti-threadinfo));
+
+       if (!ti->started)
+               TUX_BUG();
+       for (j = 0; j < CONFIG_TUX_NUMSOCKETS; j++)
+               if (ti->listen[j].proto)
+                       remove_wait_queue(ti->listen[j].sock->sk->sk_sleep,
+                               ti->wait_event + j);
+       remove_wait_queue(&wait_stop, &ti->stop);
+
+       Dprintk(KERN_NOTICE "TUX: thread %d waiting for sockets to go inactive ...\n", (int)(ti-threadinfo));
+       zap_listen_sockets(ti);
+
+       Dprintk(KERN_NOTICE "TUX: thread %d has all sockets inactive.\n", (int)(ti-threadinfo));
+
+       flush_all_requests(ti);
+       stop_cachemiss_threads(ti);
+
+       if (ti->nr_requests)
+               TUX_BUG();
+       ti->started = 0;
+
+       printk(KERN_INFO "TUX: thread %d stopped.\n", ti->cpu);
+
+       ti->thread = NULL;
+       current->tux_info = NULL;
+       current->tux_exit = NULL;
+       atomic_dec(&nr_tux_threads_running);
+       wake_up(&thread_stopped);
+
+       module_put(tux_module);
+
+       return 0;
+}
+
+#define COPY_INT(u_field, k_field)                                     \
+do {                                                                   \
+       if (__copy_to_user(&u_info->u_field, &req->k_field,             \
+                                       sizeof(req->k_field)))          \
+               return_EFAULT;                                          \
+} while (0)
+
+#define GETLEN(k_field, maxlen)                                                \
+               ((req->k_field##_len < maxlen) ?                        \
+               req->k_field##_len : maxlen-1)
+
+#define COPY_STR(u_field, k_field, maxlen)                             \
+do {                                                                   \
+       if (__copy_to_user(u_info->u_field, req->k_field##_str,         \
+               GETLEN(k_field, maxlen)))                               \
+                       return_EFAULT;                                  \
+} while (0)
+
+#define COPY_COND_STR(u_field,k_field,maxlen)                          \
+do {                                                                   \
+       if (req->k_field##_len)                                         \
+               COPY_STR(u_field, k_field, maxlen);                     \
+       if (__put_user((char)0, u_info->u_field +                       \
+                       GETLEN(k_field, maxlen)))                       \
+               return_EFAULT;                                          \
+} while (0)
+
+static void finish_userspace_req (tux_req_t *req)
+{
+       threadinfo_t *ti = req->ti;
+
+       ti->userspace_req = NULL;
+       req->usermode = 0;
+       req->private = 0;
+       req->error = 0;
+       DEC_STAT(nr_userspace_pending);
+       flush_request(req, 0);
+}
+
+static void zap_userspace_req (tux_req_t *req)
+{
+       clear_keepalive(req);
+       finish_userspace_req(req);
+}
+
+/*
+ * Fills in the user-space request structure:
+ */
+static int prepare_userspace_req (threadinfo_t *ti, user_req_t *u_info)
+{
+       u64 u_req;
+       tux_req_t *req = ti->userspace_req;
+       unsigned int tmp;
+       int filelen;
+       int fd;
+
+       Dprintk("prepare_userspace_req(%p).\n", req);
+       if (!req)
+               TUX_BUG();
+       if (req->error) {
+               TDprintk("userspace request has error %d.\n", req->error);
+               return -1;
+       }
+       fd = req->fd;
+       if (fd == -1) {
+               fd = sock_map_fd(req->sock);
+               Dprintk("sock_map_fd(%p) :%d.\n", req, fd);
+               if (fd < 0) {
+                       Dprintk("sock_map_fd() returned %d.\n", fd);
+                       return -EMFILE;
+               }
+               req->fd = fd;
+       }
+
+#define return_EFAULT do { Dprintk("-EFAULT at %d:%s.\n", __LINE__, __FILE__); return -EFAULT; } while (0)
+
+       if (!access_ok(VERIFY_WRITE, u_info, sizeof(*u_info)))
+               return_EFAULT;
+       if (__copy_to_user(&u_info->sock, &fd, sizeof(fd)))
+               return_EFAULT;
+       if (req->attr)
+               TUX_BUG();
+
+       COPY_INT(module_index, usermodule_idx);
+
+       COPY_COND_STR(query, query, MAX_URI_LEN);
+
+       COPY_INT(event, event);
+       Dprintk("prepare userspace, user error: %d, event %d.\n", req->user_error, req->event);
+       COPY_INT(error, user_error);
+       req->user_error = 0;
+
+       filelen = req->total_file_len;
+       if (filelen < 0)
+               filelen = 0;
+       if (__copy_to_user(&u_info->objectlen, &filelen, sizeof(filelen)))
+               return_EFAULT;
+       if ((req->method == METHOD_POST) && !filelen)
+               if (__copy_to_user(&u_info->objectlen,
+                       &req->content_len, sizeof(filelen)))
+               return_EFAULT;
+       if (req->objectname_len) {
+               if (req->objectname[req->objectname_len])
+                       TUX_BUG();
+               if (__copy_to_user(u_info->objectname, req->objectname,
+                               req->objectname_len + 1))
+                       return_EFAULT;
+       } else
+               if (__put_user((char)0, u_info->objectname))
+                       return_EFAULT;
+
+       COPY_INT(http_version, version);
+       COPY_INT(http_method, method);
+       COPY_INT(keep_alive, keep_alive);
+
+       COPY_INT(cookies_len, cookies_len);
+       if (req->cookies_len)
+               COPY_STR(cookies, cookies, MAX_COOKIE_LEN);
+       if (__put_user((char)0, u_info->cookies + req->cookies_len))
+               return_EFAULT;
+
+       u_req = (u64)(unsigned long)req;
+       if (__copy_to_user(&u_info->id, &u_req, sizeof(u_req)))
+               return_EFAULT;
+       COPY_INT(priv, private);
+       COPY_INT(bytes_sent, bytes_sent);
+
+       tmp = inet_sk(req->sock->sk)->daddr;
+       if (__copy_to_user(&u_info->client_host, &tmp, sizeof(tmp)))
+               return_EFAULT;
+
+       COPY_COND_STR(content_type, content_type, MAX_FIELD_LEN);
+       COPY_COND_STR(user_agent, user_agent, MAX_FIELD_LEN);
+       COPY_COND_STR(accept, accept, MAX_FIELD_LEN);
+       COPY_COND_STR(accept_charset, accept_charset, MAX_FIELD_LEN);
+       COPY_COND_STR(accept_encoding, accept_encoding, MAX_FIELD_LEN);
+       COPY_COND_STR(accept_language, accept_language, MAX_FIELD_LEN);
+       COPY_COND_STR(cache_control, cache_control, MAX_FIELD_LEN);
+       COPY_COND_STR(if_modified_since, if_modified_since, MAX_FIELD_LEN);
+       COPY_COND_STR(negotiate, negotiate, MAX_FIELD_LEN);
+       COPY_COND_STR(pragma, pragma, MAX_FIELD_LEN);
+       COPY_COND_STR(referer, referer, MAX_FIELD_LEN);
+
+       return TUX_RETURN_USERSPACE_REQUEST;
+}
+
+#define GOTO_ERR_no_unlock do { Dprintk("sys_tux() ERR at %s:%d.\n", __FILE__, __LINE__); goto err_no_unlock; } while (0)
+#define GOTO_ERR_unlock do { Dprintk("sys_tux() ERR at %s:%d.\n", __FILE__, __LINE__); goto err_unlock; } while (0)
+
+static int register_mimetype(user_req_t *u_info)
+{
+       char extension[MAX_URI_LEN], mimetype[MAX_URI_LEN], expires[MAX_URI_LEN];
+       u64 u_addr;
+       char *addr;
+       int ret;
+
+       ret = strncpy_from_user(extension, u_info->objectname, MAX_URI_LEN);
+       if (ret <= 0)
+               GOTO_ERR_no_unlock;
+       extension[ret] = 0;
+       Dprintk("got MIME extension: %s.\n", extension);
+       ret = copy_from_user(&u_addr, &u_info->object_addr, sizeof(u_addr));
+       if (ret)
+               GOTO_ERR_no_unlock;
+       addr = (char *)(unsigned long)u_addr;
+       ret = strncpy_from_user(mimetype, addr, MAX_URI_LEN);
+       if (ret <= 0)
+               GOTO_ERR_no_unlock;
+       mimetype[ret] = 0;
+       Dprintk("got MIME type: %s.\n", mimetype);
+        ret = strncpy_from_user(expires, u_info->cache_control, MAX_URI_LEN);
+        if (ret >= 0)
+               expires[ret] = 0;
+       else
+               expires[0] = 0;
+        Dprintk("got expires header: %s.\n", expires);
+
+       add_mimetype(extension, mimetype, expires);
+       ret = 0;
+err_no_unlock:
+       return ret;
+}
+
+void user_send_buffer (tux_req_t *req, int cachemiss)
+{
+       int ret;
+
+
+       SET_TIMESTAMP(req->output_timestamp);
+
+repeat:
+       ret = send_sync_buf(req, req->sock, req->userbuf, req->userlen, MSG_DONTWAIT | MSG_MORE);
+       switch (ret) {
+               case -EAGAIN:
+                       add_tux_atom(req, user_send_buffer);
+                       if (add_output_space_event(req, req->sock)) {
+                               del_tux_atom(req);
+                               goto repeat;
+                       }
+                       INC_STAT(user_sendbuf_write_misses);
+                       break;
+               default:
+                       if (ret <= 0) {
+                               req_err(req);
+                               req->usermode = 0;
+                               req->private = 0;
+                               add_req_to_workqueue(req);
+                               break;
+                       }
+                       req->userbuf += ret;
+                       req->userlen -= ret;
+                       if ((int)req->userlen < 0)
+                               TUX_BUG();
+                       if (req->userlen)
+                               goto repeat;
+                       add_req_to_workqueue(req);
+                       break;
+       }
+}
+
+void user_send_object (tux_req_t *req, int cachemiss)
+{
+       int ret;
+
+
+       SET_TIMESTAMP(req->output_timestamp);
+
+repeat:
+       ret = generic_send_file(req, req->sock, cachemiss);
+       switch (ret) {
+               case -5:
+                       add_tux_atom(req, user_send_object);
+                       output_timeout(req);
+                       break;
+               case -4:
+                       add_tux_atom(req, user_send_object);
+                       if (add_output_space_event(req, req->sock)) {
+                               del_tux_atom(req);
+                               goto repeat;
+                       }
+                       INC_STAT(user_sendobject_write_misses);
+                       break;
+               case -3:
+                       INC_STAT(user_sendobject_cachemisses);
+                       add_tux_atom(req, user_send_object);
+                       queue_cachemiss(req);
+                       break;
+               case -1:
+                       break;
+               default:
+                       req->in_file.f_pos = 0;
+                       add_req_to_workqueue(req);
+                       break;
+       }
+}
+
+void user_get_object (tux_req_t *req, int cachemiss)
+{
+       int missed;
+
+       if (!req->dentry) {
+               req->usermode = 0;
+               missed = lookup_object(req, cachemiss ? 0 : LOOKUP_ATOMIC);
+               if (req->usermode)
+                       TUX_BUG();
+               req->usermode = 1;
+               if (!missed && !req->dentry) {
+                       req->error = 0;
+                       req->user_error = -ENOENT;
+                       add_req_to_workqueue(req);
+                       return;
+               }
+               if (missed) {
+                       if (cachemiss)
+                               TUX_BUG();
+                       INC_STAT(user_lookup_cachemisses);
+fetch_missed:
+                       req->ti->userspace_req = NULL;
+                       DEC_STAT(nr_userspace_pending);
+                       add_tux_atom(req, user_get_object);
+                       queue_cachemiss(req);
+                       return;
+               }
+       }
+       req->total_file_len = req->dentry->d_inode->i_size;
+       if (!req->output_len)
+               req->output_len = req->total_file_len;
+       if (tux_fetch_file(req, !cachemiss)) {
+               INC_STAT(user_fetch_cachemisses);
+               goto fetch_missed;
+       }
+       req->in_file.f_pos = 0;
+       add_req_to_workqueue(req);
+}
+
+asmlinkage long __sys_tux (unsigned int action, user_req_t *u_info)
+{
+       int ret = -1;
+       threadinfo_t *ti;
+       tux_req_t *req;
+
+       if (action != TUX_ACTION_CURRENT_DATE)
+               Dprintk("got sys_tux(%d, %p).\n", action, u_info);
+
+       if (action >= MAX_TUX_ACTION)
+               GOTO_ERR_no_unlock;
+
+       ti = (threadinfo_t *) current->tux_info;
+       if (ti)
+               if (ti->thread != current)
+                       TUX_BUG();
+
+       if (!capable(CAP_SYS_ADMIN)
+                       && (action != TUX_ACTION_CONTINUE_REQ) &&
+                               (action != TUX_ACTION_STOPTHREAD))
+               goto userspace_actions;
+
+       switch (action) {
+               case TUX_ACTION_CONTINUE_REQ:
+                       ret = continue_request((int)(long)u_info);
+                       goto out;
+
+               case TUX_ACTION_STARTUP:
+                       lock_kernel();
+                       ret = user_req_startup();
+                       unlock_kernel();
+                       goto out;
+
+               case TUX_ACTION_SHUTDOWN:
+                       lock_kernel();
+                       ret = user_req_shutdown();
+                       unlock_kernel();
+                       goto out;
+
+               case TUX_ACTION_REGISTER_MODULE:
+                       ret = user_register_module(u_info);
+                       goto out;
+
+               case TUX_ACTION_UNREGISTER_MODULE:
+                       ret = user_unregister_module(u_info);
+                       goto out;
+
+               case TUX_ACTION_STARTTHREAD:
+               {
+                       unsigned int nr;
+
+                       ret = copy_from_user(&nr, &u_info->thread_nr,
+                                               sizeof(int));
+                       if (ret)
+                               GOTO_ERR_no_unlock;
+                       if (nr >= nr_tux_threads)
+                               GOTO_ERR_no_unlock;
+                       ti = threadinfo + nr;
+                       if (ti->started)
+                               GOTO_ERR_unlock;
+                       ti->started = 1;
+                       current->tux_info = ti;
+                       current->tux_exit = tux_exit;
+                       if (ti->thread)
+                               TUX_BUG();
+                       Dprintk("TUX: current open files limit for TUX%d: %ld.\n", nr, current->rlim[RLIMIT_NOFILE].rlim_cur);
+                       lock_kernel();
+                       ret = user_req_start_thread(ti);
+                       unlock_kernel();
+                       if (ret) {
+                               current->tux_info = NULL;
+                               current->tux_exit = NULL;
+                       } else {
+                               if (ti->thread != current)
+                                       TUX_BUG();
+                       }
+                       goto out_userreq;
+               }
+
+               case TUX_ACTION_STOPTHREAD:
+                       if (!ti)
+                               GOTO_ERR_no_unlock;
+                       if (!ti->started)
+                               GOTO_ERR_unlock;
+                       req = ti->userspace_req;
+                       if (req)
+                               zap_userspace_req(req);
+                       
+                       lock_kernel();
+                       ret = user_req_stop_thread(ti);
+                       unlock_kernel();
+                       goto out_userreq;
+
+               case TUX_ACTION_CURRENT_DATE:
+                       ret = strncpy_from_user(tux_date, u_info->new_date,
+                               DATE_LEN);
+                       if (ret <= 0)
+                               GOTO_ERR_no_unlock;
+                       goto out;
+
+               case TUX_ACTION_REGISTER_MIMETYPE:
+                       ret = register_mimetype(u_info);
+                       if (ret)
+                               GOTO_ERR_no_unlock;
+                       goto out;
+
+               case TUX_ACTION_QUERY_VERSION:
+                       ret = (TUX_MAJOR_VERSION << 24) | (TUX_MINOR_VERSION << 16) | TUX_PATCHLEVEL_VERSION;
+                       goto out;
+               default:
+                       ;
+       }
+
+userspace_actions:
+
+       if (!ti)
+               GOTO_ERR_no_unlock;
+
+       if (!ti->started)
+               GOTO_ERR_unlock;
+
+       req = ti->userspace_req;
+       if (!req) {
+               if (action == TUX_ACTION_EVENTLOOP)
+                       goto eventloop;
+               GOTO_ERR_unlock;
+       }
+       if (!req->usermode)
+               TUX_BUG();
+
+       ret = copy_from_user(&req->event, &u_info->event, sizeof(int));
+       if (ret)
+               GOTO_ERR_unlock;
+       ret = copy_from_user(&req->status, &u_info->http_status, sizeof(int));
+       if (ret)
+               GOTO_ERR_unlock;
+       ret = copy_from_user(&req->bytes_sent, &u_info->bytes_sent, sizeof(int));
+       if (ret)
+               GOTO_ERR_unlock;
+       ret = copy_from_user(&req->private, &u_info->priv, sizeof(req->private));
+       if (ret)
+               GOTO_ERR_unlock;
+
+       switch (action) {
+
+               case TUX_ACTION_EVENTLOOP:
+eventloop:
+                       req = ti->userspace_req;
+                       if (req)
+                               zap_userspace_req(req);
+                       ret = event_loop(ti);
+                       goto out_userreq;
+
+               /*
+                * Module forces keepalive off, server will close
+                * the connection.
+                */
+               case TUX_ACTION_FINISH_CLOSE_REQ:
+                       clear_keepalive(req);
+
+               case TUX_ACTION_FINISH_REQ:
+                       finish_userspace_req(req);
+                       goto eventloop;
+
+               case TUX_ACTION_REDIRECT_REQ:
+
+                       ti->userspace_req = NULL;
+                       req->usermode = 0;
+                       req->private = 0;
+                       req->error = TUX_ERROR_REDIRECT;
+                       DEC_STAT(nr_userspace_pending);
+                       add_tux_atom(req, redirect_request);
+                       add_req_to_workqueue(req);
+
+                       goto eventloop;
+
+               case TUX_ACTION_POSTPONE_REQ:
+
+                       postpone_request(req);
+                       ti->userspace_req = NULL;
+                       ret = TUX_RETURN_USERSPACE_REQUEST;
+                       break;
+
+               case TUX_ACTION_GET_OBJECT:
+                       release_req_dentry(req);
+                       ret = strncpy_from_user(req->objectname,
+                               u_info->objectname, MAX_URI_LEN-1);
+                       if (ret <= 0) {
+                               req->objectname[0] = 0;
+                               req->objectname_len = 0;
+                               GOTO_ERR_unlock;
+                       }
+                       req->objectname[ret] = 0; // string delimit
+                       req->objectname_len = ret;
+
+                       Dprintk("got objectname {%s} (%d) from user-space req %p (req: %p).\n", req->objectname, req->objectname_len, u_info, req);
+                       req->ti->userspace_req = NULL;
+                       DEC_STAT(nr_userspace_pending);
+                       user_get_object(req, 0);
+                       goto eventloop;
+
+               case TUX_ACTION_READ_OBJECT:
+               {
+                       u64 u_addr;
+                       char *addr;
+                       loff_t ppos = 0;
+                       struct file *filp;
+
+                       if (!req->dentry)
+                               GOTO_ERR_unlock;
+                       
+                       ret = copy_from_user(&u_addr, &u_info->object_addr,
+                                       sizeof(u_addr));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       addr = (char *)(unsigned long)u_addr;
+                       filp = dentry_open(req->dentry, O_RDONLY, 0);
+                       dget(req->dentry);
+                       generic_file_read(filp, addr, req->total_file_len, &ppos);
+                       fput(filp);
+                       ret = TUX_RETURN_USERSPACE_REQUEST;
+                       break;
+               }
+
+               case TUX_ACTION_SEND_OBJECT:
+                       if (!req->dentry)
+                               GOTO_ERR_unlock;
+                       req->ti->userspace_req = NULL;
+                       DEC_STAT(nr_userspace_pending);
+                       user_send_object(req, 0);
+                       goto eventloop;
+
+               case TUX_ACTION_SEND_BUFFER:
+               {
+                       u64 u_addr;
+                       char *addr;
+                       unsigned int len;
+
+                       ret = copy_from_user(&u_addr,
+                                       &u_info->object_addr, sizeof(u_addr));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       addr = (char *)(unsigned long)u_addr;
+                       ret = copy_from_user(&len,
+                                       &u_info->objectlen, sizeof(addr));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       if ((int)len <= 0)
+                               GOTO_ERR_unlock;
+
+                       ret = -EFAULT;
+                       if (!access_ok(VERIFY_READ, addr, len))
+                               GOTO_ERR_unlock;
+                       req->userbuf = addr;
+                       req->userlen = len;
+
+                       req->ti->userspace_req = NULL;
+                       DEC_STAT(nr_userspace_pending);
+                       user_send_buffer(req, 0);
+                       ret = 0;
+                       goto eventloop;
+               }
+
+               case TUX_ACTION_READ_HEADERS:
+               {
+                       char *addr;
+                       u64 u_addr;
+
+                       ret = copy_from_user(&u_addr, &u_info->object_addr,
+                                       sizeof(u_addr));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       addr = (char *)(unsigned long)u_addr;
+                       ret = copy_to_user(&u_info->objectlen,
+                                &req->headers_len, sizeof(req->headers_len));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       ret = copy_to_user(addr,req->headers, req->headers_len);
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       break;
+               }
+
+               case TUX_ACTION_READ_POST_DATA:
+               {
+                       char *addr;
+                       unsigned int size;
+                       u64 u_addr;
+
+                       ret = copy_from_user(&u_addr, &u_info->object_addr,
+                                       sizeof(u_addr));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       addr = (char *)(unsigned long)u_addr;
+
+                       ret = copy_from_user(&size, &u_info->objectlen,
+                                       sizeof(size));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       Dprintk("READ_POST_DATA: got %p(%d).\n", addr, size);
+                       if (req->post_data_len < size)
+                               size = req->post_data_len;
+                       Dprintk("READ_POST_DATA: writing %d.\n", size);
+                       ret = copy_to_user(&u_info->objectlen,
+                                               &size, sizeof(size));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       ret = copy_to_user(addr, req->post_data_str, size);
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       goto out;
+               }
+
+               case TUX_ACTION_WATCH_PROXY_SOCKET:
+               {
+                       struct socket *sock;
+                       int err;
+                       long fd;
+                       u64 u_addr;
+
+                       ret = copy_from_user(&u_addr, &u_info->object_addr,
+                                       sizeof(u_addr));
+                       if (ret)
+                               GOTO_ERR_unlock;
+                       fd = (int)(unsigned long)u_addr;
+
+                       sock = sockfd_lookup(fd, &err);
+                       if (!sock)
+                               GOTO_ERR_unlock;
+                       put_data_sock(req);
+                       link_tux_data_socket(req, sock);
+
+                       ret = 0;
+                       goto out;
+               }
+
+               case TUX_ACTION_WAIT_PROXY_SOCKET:
+               {
+                       if (!req->data_sock)
+                               GOTO_ERR_unlock;
+                       if (socket_input(req->data_sock)) {
+                               ret = TUX_RETURN_USERSPACE_REQUEST;
+                               goto out_userreq;
+                       }
+                       spin_lock_irq(&req->ti->work_lock);
+                       add_keepalive_timer(req);
+                       if (test_and_set_bit(0, &req->idle_input))
+                               TUX_BUG();
+                       spin_unlock_irq(&req->ti->work_lock);
+                       if (socket_input(req->data_sock)) {
+                               unidle_req(req);
+                               ret = TUX_RETURN_USERSPACE_REQUEST;
+                               goto out_userreq;
+                       }
+                       req->ti->userspace_req = NULL;
+                       goto eventloop;
+               }
+
+               default:
+                       GOTO_ERR_unlock;
+       }
+
+out_userreq:
+       req = ti->userspace_req;
+       if (req) {
+               ret = prepare_userspace_req(ti, u_info);
+               if (ret < 0) {
+                       TDprintk("hm, user req %p returned %d, zapping.\n",
+                               req, ret);
+                       zap_userspace_req(req);
+                       goto eventloop;
+               }
+       }
+out:
+       if (action != TUX_ACTION_CURRENT_DATE)
+               Dprintk("sys_tux(%d, %p) returning %d.\n", action, u_info, ret);
+       while (unlikely(test_thread_flag(TIF_NEED_RESCHED))) {
+               __set_task_state(current, TASK_RUNNING);
+               schedule();
+       }
+       return ret;
+err_unlock:
+err_no_unlock:
+       Dprintk("sys_tux(%d, %p) returning -EINVAL (ret:%d)!\n", action, u_info, ret);
+       while (unlikely(test_thread_flag(TIF_NEED_RESCHED))) {
+               __set_task_state(current, TASK_RUNNING);
+               schedule();
+       }
+       return -EINVAL;
+}
+
+/*
+ * This gets called if a TUX thread does an exit().
+ */
+void tux_exit (void)
+{
+       __sys_tux(TUX_ACTION_STOPTHREAD, NULL);
+}
+
+int tux_init(void)
+{
+       start_sysctl();
+
+#if CONFIG_TUX_MODULE
+       spin_lock(&tux_module_lock);
+       sys_tux_ptr = __sys_tux;
+       tux_module = THIS_MODULE;
+       spin_unlock(&tux_module_lock);
+#endif
+
+       return 0;
+}
+
+void tux_cleanup (void)
+{
+#if CONFIG_TUX_MODULE
+       spin_lock(&tux_module_lock);
+       tux_module = NULL;
+       sys_tux_ptr = NULL;
+       spin_unlock(&tux_module_lock);
+#endif
+
+       end_sysctl();
+}
+
+module_init(tux_init)
+module_exit(tux_cleanup)
+
+MODULE_LICENSE("GPL");
+
diff --git a/net/tux/mod.c b/net/tux/mod.c
new file mode 100644 (file)
index 0000000..1489114
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * mod.c: loading/registering of dynamic TUX modules
+ */
+
+#include <net/tux.h>
+#include <linux/kmod.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+spinlock_t tuxmodules_lock = SPIN_LOCK_UNLOCKED;
+static LIST_HEAD(tuxmodules_list);
+
+tcapi_template_t * get_first_usermodule (void)
+{
+       tcapi_template_t *tcapi;
+       struct list_head *head, *curr, *next;
+
+       spin_lock(&tuxmodules_lock);
+       head = &tuxmodules_list;
+       next = head->next;
+
+       while ((curr = next) != head) {
+               tcapi = list_entry(curr, tcapi_template_t, modules);
+               next = curr->next;
+               if (tcapi->userspace_id) {
+                       spin_unlock(&tuxmodules_lock);
+                       return tcapi;
+               }
+       }
+       spin_unlock(&tuxmodules_lock);
+       return NULL;
+}
+
+static tcapi_template_t * lookup_module (const char *vfs_name)
+{
+       tcapi_template_t *tcapi;
+       struct list_head *head, *curr, *next;
+
+       while (*vfs_name == '/')
+               vfs_name++;
+       Dprintk("looking up TUX module {%s}.\n", vfs_name);
+       head = &tuxmodules_list;
+       next = head->next;
+
+       while ((curr = next) != head) {
+               tcapi = list_entry(curr, tcapi_template_t, modules);
+               next = curr->next;
+               Dprintk("checking module {%s} == {%s}?\n", vfs_name, tcapi->vfs_name);
+               if (!strcmp(tcapi->vfs_name, vfs_name))
+                       return tcapi;
+       }
+       return NULL;
+}
+
+/*
+ * Attempt to load a TUX application module.
+ * This is the slow path, we cache ('link') the module's
+ * API vector to the inode.
+ * The module loading path is serialized, and we handshake
+ * with the loaded module and fetch its API vector.
+ */
+tcapi_template_t * lookup_tuxmodule (const char *filename)
+{
+       tcapi_template_t *tcapi;
+
+       spin_lock(&tuxmodules_lock);
+       tcapi = lookup_module(filename);
+       if (!tcapi)
+               Dprintk("did not find module vfs:{%s}\n", filename);
+       spin_unlock(&tuxmodules_lock);
+       return tcapi;
+}
+
+
+int register_tuxmodule (tcapi_template_t *tcapi)
+{
+       int ret = -EEXIST;
+
+       spin_lock(&tuxmodules_lock);
+
+       if (lookup_module(tcapi->vfs_name)) {
+               Dprintk("module with VFS binding '%s' already registered!\n",
+                                                tcapi->vfs_name);
+               goto out;
+       } 
+
+       list_add(&tcapi->modules, &tuxmodules_list);
+       ret = 0;
+       Dprintk("TUX module %s registered.\n", tcapi->vfs_name);
+out:
+       spin_unlock(&tuxmodules_lock);
+
+       return ret;
+}
+
+void unregister_all_tuxmodules (void)
+{
+       tcapi_template_t *tcapi;
+       struct list_head *curr;
+
+       spin_lock(&tuxmodules_lock);
+       while (((curr = tuxmodules_list.next)) != &tuxmodules_list) {
+               tcapi = list_entry(curr, tcapi_template_t, modules);
+               list_del(curr);
+               kfree(tcapi->vfs_name);
+               kfree(tcapi);
+       }
+       spin_unlock(&tuxmodules_lock);
+}
+
+tcapi_template_t * unregister_tuxmodule (char *vfs_name)
+{
+       tcapi_template_t *tcapi;
+       int err = 0;
+
+       spin_lock(&tuxmodules_lock);
+       tcapi = lookup_module(vfs_name);
+       if (!tcapi) {
+               Dprintk("huh, module %s not registered??\n", vfs_name);
+               err = -1;
+       } else {
+               list_del(&tcapi->modules);
+               Dprintk("TUX module %s unregistered.\n", vfs_name);
+       }
+       spin_unlock(&tuxmodules_lock);
+
+       return tcapi;
+}
+
+static int check_module_version (user_req_t *u_info)
+{
+       int major, minor, patch, ret;
+
+       ret = copy_from_user(&major, &u_info->version_major, sizeof(int));
+       ret += copy_from_user(&minor, &u_info->version_minor, sizeof(int));
+       ret += copy_from_user(&patch, &u_info->version_patch, sizeof(int));
+       if (ret)
+               return -EFAULT;
+
+       if ((major != TUX_MAJOR_VERSION) || (minor > TUX_MINOR_VERSION)) {
+
+               printk(KERN_ERR "TUX: module version %d:%d incompatible with kernel version %d:%d!\n", major, minor, TUX_MAJOR_VERSION, TUX_MINOR_VERSION);
+               return -EINVAL;
+       }
+       return 0;
+}
+
+int user_register_module (user_req_t *u_info)
+{
+       int idx, len, ret;
+       tcapi_template_t *tcapi;
+       char modulename [MAX_URI_LEN+1];
+
+       ret = check_module_version(u_info);
+       if (ret)
+               return ret;
+
+       /*
+        * Check module name length.
+        */
+       ret = strnlen_user(u_info->objectname, MAX_URI_LEN+2);
+       if (ret < 0)
+               goto out;
+       ret = -EINVAL;
+       if (ret >= MAX_URI_LEN)
+               goto out;
+
+       Dprintk("register user-module, %p.\n", u_info);
+       ret = strncpy_from_user(modulename, u_info->objectname, MAX_URI_LEN);
+       if (ret < 0)
+               goto out;
+       modulename[ret] = 0;
+       Dprintk("... user-module is: {%s}.\n", modulename);
+       len = strlen(modulename);
+       if (!len)
+               printk(KERN_ERR "no module name provided: please upgrade your TUX user-space utilities!\n");
+       if (!len || (len > MAX_URI_LEN))
+               return -EINVAL;
+       Dprintk("... user-module len is: %d.\n", len);
+
+       ret = copy_from_user(&idx, &u_info->module_index, sizeof(int));
+       if (ret || !idx)
+               goto out;
+       Dprintk("... user-module index is: %d.\n", idx);
+
+       ret = -ENOMEM;
+       tcapi = (tcapi_template_t *) kmalloc(sizeof(*tcapi), GFP_KERNEL);
+       if (!tcapi)
+               goto out;
+       memset(tcapi, 0, sizeof(*tcapi));
+
+       tcapi->vfs_name = (char *) kmalloc(len+1, GFP_KERNEL);
+       if (!tcapi->vfs_name) {
+               kfree(tcapi);
+               goto out;
+       }
+       strcpy(tcapi->vfs_name, modulename);
+       tcapi->userspace_id = idx;
+
+       Dprintk("... registering module {%s}.\n", tcapi->vfs_name);
+       ret = register_tuxmodule(tcapi);
+out:
+       return ret;
+}
+
+int user_unregister_module (user_req_t *u_info)
+{
+       int len, ret;
+       tcapi_template_t *tcapi;
+       char modulename [MAX_URI_LEN+1];
+
+       /*
+        * Check module name length.
+        */
+       ret = strnlen_user(u_info->objectname, MAX_URI_LEN+2);
+       if (ret < 0)
+               goto out;
+       ret = -EINVAL;
+       if (ret >= MAX_URI_LEN)
+               goto out;
+       Dprintk("unregister user-module, %p.\n", u_info);
+       ret = strncpy_from_user(modulename, u_info->objectname, MAX_URI_LEN);
+       if (ret <= 0)
+               goto out;
+       modulename[ret] = 0;
+       Dprintk("... user-module is: {%s}.\n", modulename);
+       len = strlen(modulename);
+       if (!len || (len > MAX_URI_LEN))
+               return -EINVAL;
+       Dprintk("... user-module len is: %d.\n", len);
+
+       Dprintk("... unregistering module {%s}.\n", modulename);
+       tcapi = unregister_tuxmodule(modulename);
+       ret = -EINVAL;
+       if (tcapi) {
+               ret = 0;
+               kfree(tcapi->vfs_name);
+               kfree(tcapi);
+       }
+out:
+       return ret;
+}
+
diff --git a/net/tux/output.c b/net/tux/output.c
new file mode 100644 (file)
index 0000000..0ac39b2
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * output.c: Send data to clients
+ */
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+int send_sync_buf (tux_req_t *req, struct socket *sock, const char *buf, const size_t length, unsigned long flags)
+{
+       struct msghdr msg;
+       struct iovec iov;
+       int len, written = 0, left = length;
+       struct tcp_opt *tp = tcp_sk(sock->sk);
+
+       tp->nonagle = 2;
+
+       msg.msg_name     = 0;
+       msg.msg_namelen  = 0;
+       msg.msg_iov      = &iov;
+       msg.msg_iovlen   = 1;
+       msg.msg_control  = NULL;
+       msg.msg_controllen = 0;
+       msg.msg_flags    = flags | MSG_NOSIGNAL;
+repeat_send:
+       msg.msg_iov->iov_len = left;
+       msg.msg_iov->iov_base = (char *) buf + written;
+
+       len = sock_sendmsg(sock, &msg, left);
+
+       Dprintk("sendmsg ret: %d, written: %d, left: %d.\n", len,written,left);
+       if ((len == -ERESTARTSYS) || (!(flags & MSG_DONTWAIT) &&
+                        (len == -EAGAIN))) {
+               flush_all_signals();
+               goto repeat_send;
+       }
+       if (len > 0) {
+               written += len;
+               left -= len;
+               if (left)
+                       goto repeat_send;
+       }
+       if (len >= 0) {
+               if (written != length)
+                       TUX_BUG();
+               if (left)
+                       TUX_BUG();
+       }
+       if (req && (written > 0))
+               req->bytes_sent += written;
+       Dprintk("sendmsg FINAL ret: %d, written: %d, left: %d.\n", len,written,left);
+       return written ? written : len;
+}
+
+unsigned int tux_zerocopy_sendfile = 1;
+
+typedef struct sock_send_desc
+{
+       struct socket *sock;
+       tux_req_t *req;
+} sock_send_desc_t;
+
+static int sock_send_actor (read_descriptor_t * desc, struct page *page,
+                               unsigned long offset, unsigned long orig_size)
+{
+       sock_send_desc_t *sock_desc = (sock_send_desc_t *)desc->arg.buf;
+       struct socket *sock = sock_desc->sock;
+       tux_req_t *req = sock_desc->req;
+       unsigned int flags;
+       ssize_t written;
+       char *buf = NULL;
+       unsigned int size;
+
+       flags = MSG_DONTWAIT | MSG_NOSIGNAL;
+       if (desc->count < orig_size)
+               orig_size = desc->count;
+       if (desc->count > orig_size)
+               flags |= MSG_MORE;
+       Dprintk("sock_send_actor(), page: %p, offset: %ld, orig_size: %ld, sock: %p, desc->count: %d, desc->written: %d, MSG_MORE: %d.\n", page, offset, orig_size, sock, desc->count, desc->written, flags & MSG_MORE);
+
+       if (req->content_gzipped >= 2) {
+               unsigned int gzip_left;
+               struct msghdr msg;
+               struct iovec iov;
+               mm_segment_t oldmm;
+               char *kaddr = kmap(page);
+               __u32 in_len, out_len;
+               out_len = orig_size*101/100 + 12;
+               buf = tux_kmalloc(out_len);
+               in_len = orig_size;
+               size = out_len;
+               gzip_left = 0;
+// 8b1f 0808 fdc4 3bd8 0300 79
+buf[1] = 0x8b; buf[0] = 0x1f; buf[3] = 0x08; buf[2] = 0x08;
+buf[5] = 0xfd; buf[4] = 0xc4; buf[7] = 0x3b; buf[6] = 0xd8;
+buf[9] = 0x03; buf[8] = 0x00; buf[10] = 0x79;
+               size += 11;
+               Dprintk("pre-compress: in_len: %d, out_len: %d, gzip_left: %d, uncompressed size: %d.\n", in_len, out_len, gzip_left, size);
+               gzip_left = tux_gzip_compress(req, kaddr, buf+11, &in_len, &out_len);
+               size -= out_len;
+ buf[11] = 0x79; buf[12] = 0x00;
+
+               Dprintk("post-compress: in_len: %d, out_len: %d, gzip_left: %d, compressed size: %d.\n", in_len, out_len, gzip_left, size);
+               kunmap(page);
+               msg.msg_name = NULL;
+               msg.msg_namelen = 0;
+               msg.msg_iov = &iov;
+               msg.msg_iovlen = 1;
+               msg.msg_control = NULL;
+               msg.msg_controllen = 0;
+               flags &= ~MSG_DONTWAIT;
+               msg.msg_flags = flags;
+               iov.iov_base = buf;
+               iov.iov_len = size;
+
+               oldmm = get_fs(); set_fs(KERNEL_DS);
+               written = sock_sendmsg(sock, &msg, size);
+               set_fs(oldmm);
+
+               Dprintk("buf: %p, offset: %ld, size: %d, written: %d.\n", buf, offset, size, written);
+               if (written == size)
+                       written = orig_size;
+               else
+                       written = size;
+                       
+       } else {
+               size = orig_size;
+               if (tux_zerocopy_sendfile && sock->ops->sendpage &&
+                   (sock->sk->sk_route_caps&NETIF_F_SG)) {
+                       written = sock->ops->sendpage(sock, page, offset, size, flags);
+               } else {
+                       struct msghdr msg;
+                       struct iovec iov;
+                       char *kaddr;
+                       mm_segment_t oldmm;
+       
+                       if (offset+size > PAGE_SIZE)
+                               return -EFAULT;
+
+                       kaddr = kmap(page);
+       
+                       msg.msg_name = NULL;
+                       msg.msg_namelen = 0;
+                       msg.msg_iov = &iov;
+                       msg.msg_iovlen = 1;
+                       msg.msg_control = NULL;
+                       msg.msg_controllen = 0;
+                       msg.msg_flags = flags;
+                       iov.iov_base = kaddr + offset;
+                       iov.iov_len = size;
+
+                       oldmm = get_fs(); set_fs(KERNEL_DS);
+                       written = sock_sendmsg(sock, &msg, size);
+                       set_fs(oldmm);
+
+                       Dprintk("kaddr: %p, offset: %ld, size: %d, written: %d.\n", kaddr, offset, size, written);
+                       kunmap(page);
+               }
+       }
+       if (written < 0) {
+               desc->error = written;
+               written = 0;
+       }
+       Dprintk("desc->count: %d, desc->written: %d, written: %d.\n", desc->count, desc->written, written);
+       desc->count -= written;
+       if ((int)desc->count < 0)
+               TUX_BUG();
+       desc->written += written;
+
+       if (buf)
+               kfree(buf);
+
+       return written;
+}
+
+/*
+ * Return 1 if the output space condition went away
+ * before adding the handler.
+ */
+int add_output_space_event (tux_req_t *req, struct socket *sock)
+{
+       struct sock *sk = sock->sk;
+       /*
+        * blocked due to socket IO?
+        */
+       spin_lock_irq(&req->ti->work_lock);
+       add_keepalive_timer(req);
+       if (test_and_set_bit(0,&req->wait_output_space))
+               TUX_BUG();
+       INC_STAT(nr_output_space_pending);
+
+       if ((sk->sk_state == TCP_ESTABLISHED) && enough_wspace(sk)) {
+               if (test_and_clear_bit(0, &req->wait_output_space)) {
+                       DEC_STAT(nr_output_space_pending);
+                       del_keepalive_timer(req);
+                       spin_unlock_irq(&req->ti->work_lock);
+                       return 1;
+               }
+       }
+       spin_unlock_irq(&req->ti->work_lock);
+
+       return 0;
+}
+
+#define SEND_BLOCKSIZE (164*1024)
+
+int generic_send_file (tux_req_t *req, struct socket *sock, int cachemiss)
+{
+       sock_send_desc_t sock_desc;
+       int len, want, nonblock = !cachemiss;
+       struct tcp_opt *tp = tcp_sk(sock->sk);
+
+       tp->nonagle = 2;
+
+       sock_desc.sock = sock;
+       sock_desc.req = req;
+
+repeat:
+       Dprintk("generic_send_file(%p,%d,%p) called, f_pos: %Ld, output_len: %Ld.\n", req, nonblock, sock, req->in_file.f_pos, req->output_len);
+
+       if (req->proto->check_req_err(req, cachemiss))
+               return -1;
+       if (connection_too_fast(req) == 2) {
+               len = -5;
+               goto out;
+       }
+       if (req->total_file_len < req->in_file.f_pos)
+               TUX_BUG();
+
+       req->desc.written = 0;
+       /*
+        * Careful, output_len can be 64-bit, while 'want' can be 32-bit.
+        */
+       if (req->output_len > SEND_BLOCKSIZE)
+               want = SEND_BLOCKSIZE;
+       else
+               want = req->output_len;
+       req->desc.count = want;
+       req->desc.arg.buf = (char *) &sock_desc;
+       req->desc.error = 0;
+       Dprintk("sendfile(), desc.count: %d.\n", req->desc.count);
+       do_generic_file_read(&req->in_file, &req->in_file.f_pos, &req->desc, sock_send_actor, nonblock);
+       if (req->desc.written > 0) {
+               req->bytes_sent += req->desc.written;
+               req->output_len -= req->desc.written;
+       }
+       if (!nonblock && (req->desc.error == -EWOULDBLOCKIO))
+               TUX_BUG();
+       Dprintk("sendfile() wrote: %d bytes.\n", req->desc.written);
+       if (req->output_len && !req->desc.written && !req->desc.error) {
+#if CONFIG_TUX_DEBUG
+               req->bytes_expected = 0;
+#endif
+               req->in_file.f_pos = 0;
+               req->error = TUX_ERROR_CONN_CLOSE;
+               zap_request(req, cachemiss);
+               return -1;
+       }
+
+       switch (req->desc.error) {
+
+       case -EWOULDBLOCKIO:
+               len = -3;
+               break;
+       case -EAGAIN:
+no_write_space:
+               Dprintk("sk->wmem_queued: %d, sk->sndbuf: %d.\n",
+                       sock->sk->sk_wmem_queued, sock->sk->sk_sndbuf);
+               len = -4;
+               break;
+       default:
+               len = req->desc.written;
+#if CONFIG_TUX_DEBUG
+               if (req->desc.error)
+                       TDprintk("TUX: sendfile() returned error %d (signals pending: %08lx)!\n", req->desc.error, current->pending.signal.sig[0]);
+#endif
+               if (!req->desc.error) {
+                       if (req->output_len < 0)
+                               BUG();
+                       if (req->output_len) {
+                               if (test_bit(SOCK_NOSPACE, &sock->flags))
+                                       goto no_write_space;
+                               goto repeat;
+                       }
+               }
+#if CONFIG_TUX_DEBUG
+               if (req->desc.written != want)
+                       TDprintk("TUX: sendfile() wrote %d bytes, wanted %d! (pos %Ld) (signals pending: %08lx).\n", req->desc.written, want, req->in_file.f_pos, current->pending.signal.sig[0]);
+               else
+                       Dprintk("TUX: sendfile() FINISHED for req %p, wrote %d bytes.\n", req, req->desc.written);
+               req->bytes_expected = 0;
+#endif
+               break;
+       }
+
+out:
+       Dprintk("sendfile() wrote %d bytes.\n", len);
+
+       return len;
+}
+
+static int file_fetch_actor (read_descriptor_t * desc, struct page *page,
+                               unsigned long offset, unsigned long size)
+{
+       if (desc->count < size)
+               size = desc->count;
+
+       desc->count -= size;
+       desc->written += size;
+
+       return size;
+}
+
+int tux_fetch_file (tux_req_t *req, int nonblock)
+{
+       int len;
+
+       req->desc.written = 0;
+       req->desc.count = req->output_len;
+       req->desc.arg.buf = NULL;
+       req->desc.error = 0;
+
+       do_generic_file_read(&req->in_file, &req->in_file.f_pos, &req->desc,
+                                       file_fetch_actor, nonblock);
+       if (nonblock && (req->desc.error == -EWOULDBLOCKIO))
+               return 1;
+       len = req->desc.written;
+       if (req->desc.error)
+               Dprintk("fetchfile() returned %d error!\n", req->desc.error);
+       Dprintk("fetchfile() fetched %d bytes.\n", len);
+       return 0;
+}
+
diff --git a/net/tux/parser.h b/net/tux/parser.h
new file mode 100644 (file)
index 0000000..f355c1e
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, Ingo Molnar <mingo@redhat.com>
+ *
+ * parser.h: generic parsing routines
+ */
+
+#define get_c(ptr,left)                                                \
+({                                                             \
+       char __ret;                                     \
+                                                               \
+       if (!left)                                              \
+               GOTO_INCOMPLETE;                                \
+       left--;                                                 \
+       __ret = *((ptr)++);                                     \
+       if (!__ret)                                             \
+               GOTO_REDIR;                                     \
+       __ret;                                                  \
+})
+
+#define PARSE_TOKEN(ptr,str,left)                              \
+       ({                                                      \
+               int __ret;                                      \
+                                                               \
+               if (!left)                                      \
+                       GOTO_INCOMPLETE;                        \
+               if (sizeof(str)-1 > left) {                     \
+                       if (memcmp(ptr, str, left))             \
+                               GOTO_REDIR;                     \
+                       GOTO_INCOMPLETE;                        \
+               }                                               \
+                                                               \
+               if (memcmp(ptr, str, sizeof(str)-1))            \
+                       __ret = 0;                              \
+               else {                                          \
+                       ptr += sizeof(str)-1;                   \
+                       left -= sizeof(str)-1;                  \
+                       __ret = 1;                              \
+               }                                               \
+               __ret;                                          \
+       })
+
+#define PARSE_METHOD(req,ptr,name,left)                                \
+       ({                                                      \
+               int __ret;                                      \
+                                                               \
+               if (PARSE_TOKEN(ptr,#name" ",left)) {           \
+                       req->method = METHOD_##name;            \
+                       __ret = 1;                              \
+               } else                                          \
+                       __ret = 0;                              \
+               __ret;                                          \
+       })
+
+#define COPY_LINE(ptr,target,left)                             \
+       do {                                                    \
+               char prev_c = 0, c;                             \
+               while (((c = get_c(ptr,left))) != '\n') \
+                       *target++ = prev_c = c;                 \
+               if (prev_c != '\r')                             \
+                       GOTO_REDIR;                             \
+       } while (0)
+
+#define COPY_LINE_TOLOWER(ptr,target,left,limit)               \
+       do {                                                    \
+               char prev_c = 0, c;                             \
+               while (((c = get_c(ptr,left))) != '\n') {       \
+                       if ((c >= 'A') && (c <= 'Z'))           \
+                               c -= 'A'-'a';                   \
+                       *target++ = prev_c = c;                 \
+                       if (target == (limit))                  \
+                               GOTO_REDIR;                     \
+               }                                               \
+               if (prev_c != '\r')                             \
+                       GOTO_REDIR;                             \
+       } while (0)
+
+#define COPY_FIELD(ptr,target,left)                            \
+       do {                                                    \
+               char c;                                         \
+               while ((c = get_c(ptr,left)) != ' ')            \
+                       *target++ = c;                          \
+       } while (0)
+
+#define SKIP_LINE(ptr,left)                                    \
+       do {                                                    \
+               char prev_c = 0, c;                             \
+               while (((c = get_c(ptr,left))) != '\n')         \
+                       prev_c = c;                             \
+               if (prev_c != '\r')                             \
+                       GOTO_REDIR;                             \
+       } while (0)
+
+#define SKIP_WHITESPACE(curr,left)             \
+do {                                           \
+       while ((left) && (*(curr) == ' '))      \
+               (curr)++, (left)--;             \
+       if (!(left))                            \
+               GOTO_REDIR;                     \
+} while (0)
+
diff --git a/net/tux/postpone.c b/net/tux/postpone.c
new file mode 100644 (file)
index 0000000..d4a693b
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * postpone.c: postpone/continue userspace requests
+ */
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+void postpone_request (tux_req_t *req)
+{
+       if (!req->usermode)
+               TUX_BUG();
+       INC_STAT(nr_postpone_pending);
+       req->postponed = 1;
+}
+
+/*
+ * Continue a postponed request. The request will show up in the
+ * userspace queue and will be handled by the fast thread.
+ * A request can only be postponed in a TUX process, but can be
+ * continued from any process that has access to the socket file
+ * descriptor.
+ */
+int continue_request (int fd)
+{
+       threadinfo_t *ti;
+       struct socket *sock;
+       tux_req_t *req;
+       int err;
+
+       sock = sockfd_lookup(fd, &err);
+       if (!sock || !sock->sk)
+               goto out;
+       req = sock->sk->sk_user_data;
+
+       err = -EINVAL;
+       if (!req)
+               goto out_put;
+       ti = req->ti;
+       if (!req->postponed)
+               goto out_unlock_put;
+       if (!req->usermode)
+               TUX_BUG();
+
+       req->postponed = 0;
+       DEC_STAT(nr_postpone_pending);
+
+       Dprintk("continuing postponed req %p.\n", req);
+       add_req_to_workqueue(req);
+
+out_unlock_put:
+       err = 0;
+out_put:
+       fput(sock->file);
+out:
+       return err;
+}
+
diff --git a/net/tux/proc.c b/net/tux/proc.c
new file mode 100644 (file)
index 0000000..2973a48
--- /dev/null
@@ -0,0 +1,1190 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * proc.c: /proc/sys/tux handling
+ */
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+char tux_common_docroot[200] = "/var/www/tux/";
+char tux_http_subdocroot[200] = "";
+char tux_ftp_subdocroot[200] = "";
+char tux_logfile[200] = "/var/log/tux";
+char tux_cgiroot[200] = "/var/www/tux/cgiroot/";
+char tux_404_page[200] = "404.html";
+char tux_default_vhost[200] = "default";
+char tux_extra_html_header[600];
+unsigned int tux_extra_html_header_size = 0;
+
+int tux_cgi_uid = -1;
+int tux_cgi_gid = -1;
+unsigned int tux_clientport = 8080;
+unsigned int tux_logging = 0;
+unsigned int tux_threads = 2;
+unsigned int tux_max_connect = 10000;
+unsigned int tux_max_keepalives = 10000;
+unsigned int tux_max_backlog = 2048;
+unsigned int tux_keepalive_timeout = 0;
+unsigned int tux_max_output_bandwidth = 0;
+unsigned int tux_defer_accept = 1;
+unsigned int tux_mode_forbidden = 0 /*S_IXUGO*/; /* do not allow executable (CGI) files */
+unsigned int tux_mode_allowed = S_IROTH; /* allow access if read-other is set */
+unsigned int tux_virtual_server = 0;
+unsigned int tux_ftp_virtual_server = 0;
+unsigned int mass_hosting_hash = 0;
+unsigned int strip_host_tail = 0;
+unsigned int tux_max_object_size = 0;
+unsigned int log_cpu_mask = ~0;
+unsigned int tux_compression = 0;
+unsigned int tux_noid = 0;
+unsigned int tux_cgi_inherit_cpu = 0;
+unsigned int tux_cgi_cpu_mask = ~0;
+unsigned int tux_zerocopy_header = 1;
+unsigned int tux_max_free_requests = 1000;
+unsigned int tux_ignore_query = 0;
+unsigned int tux_all_userspace = 0;
+unsigned int tux_redirect_logging = 1;
+unsigned int tux_max_header_len = 3000;
+unsigned int tux_referer_logging = 0;
+unsigned int tux_generate_etags = 1;
+unsigned int tux_generate_last_mod = 1;
+unsigned int tux_generate_cache_control = 1;
+unsigned int tux_ip_logging = 1;
+unsigned int tux_ftp_wait_close = 1;
+unsigned int tux_ftp_log_retr_only = 0;
+unsigned int tux_hide_unreadable = 1;
+unsigned int tux_http_dir_indexing = 0;
+unsigned int tux_log_incomplete = 0;
+unsigned int tux_cpu_offset = 0;
+unsigned int tux_ftp_login_message = 0;
+
+static struct ctl_table_header *tux_table_header;
+
+static ctl_table tux_table[] = {
+       {       NET_TUX_DOCROOT,
+               "documentroot",
+               &tux_common_docroot,
+               sizeof(tux_common_docroot),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_DOCROOT,
+               "http_subdocroot",
+               &tux_http_subdocroot,
+               sizeof(tux_http_subdocroot),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_DOCROOT,
+               "ftp_subdocroot",
+               &tux_ftp_subdocroot,
+               sizeof(tux_ftp_subdocroot),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_LOGFILE,
+               "logfile",
+               &tux_logfile,
+               sizeof(tux_logfile),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_THREADS,
+               "threads",
+               &tux_threads,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_KEEPALIVE_TIMEOUT,
+               "keepalive_timeout",
+               &tux_keepalive_timeout,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MAX_KEEPALIVE_BW,
+               "max_output_bandwidth",
+               &tux_max_output_bandwidth,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_DEFER_ACCEPT,
+               "defer_accept",
+               &tux_defer_accept,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MAX_BACKLOG,
+               "max_backlog",
+               &tux_max_backlog,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MAX_CONNECT,
+               "max_connect",
+               &tux_max_connect,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MAX_KEEPALIVES,
+               "max_keepalives",
+               &tux_max_keepalives,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MODE_FORBIDDEN,
+               "mode_forbidden",
+               &tux_mode_forbidden,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MODE_ALLOWED,
+               "mode_allowed",
+               &tux_mode_allowed,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CGI_UID,
+               "cgi_uid",
+               &tux_cgi_uid,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CGI_GID,
+               "cgi_gid",
+               &tux_cgi_gid,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CGIROOT,
+               "cgiroot",
+               &tux_cgiroot,
+               sizeof(tux_cgiroot),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_404_PAGE,
+               "404_page",
+               &tux_404_page,
+               sizeof(tux_404_page),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_404_PAGE,
+               "default_vhost",
+               &tux_default_vhost,
+               sizeof(tux_default_vhost),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_404_PAGE,
+               "extra_html_header",
+               &tux_extra_html_header,
+               sizeof(tux_extra_html_header),
+               0644,
+               NULL,
+               proc_dostring,
+               &sysctl_string,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "extra_html_header_size",
+               &tux_extra_html_header_size,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "clientport",
+               &tux_clientport,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "generate_etags",
+               &tux_generate_etags,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+        {       NET_TUX_CLIENTPORT,
+                "generate_last_mod",
+                &tux_generate_last_mod,
+                sizeof(int),
+                0644,
+                NULL,
+                proc_dointvec,
+                &sysctl_intvec,
+                NULL,
+                NULL,
+                NULL
+        },
+        {       NET_TUX_CLIENTPORT,
+                "generate_cache_control",
+                &tux_generate_cache_control,
+                sizeof(int),
+                0644,
+                NULL,
+                proc_dointvec,
+                &sysctl_intvec,
+                NULL,
+                NULL,
+                NULL
+        },
+       {       NET_TUX_CLIENTPORT,
+               "ip_logging",
+               &tux_ip_logging,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "ftp_wait_close",
+               &tux_ftp_wait_close,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "ftp_log_retr_only",
+               &tux_ftp_log_retr_only,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "http_dir_indexing",
+               &tux_http_dir_indexing,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "hide_unreadable",
+               &tux_hide_unreadable,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CLIENTPORT,
+               "log_incomplete",
+               &tux_log_incomplete,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_LOGGING,
+               "TDprintk",
+               &tux_TDprintk,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_LOGGING,
+               "Dprintk",
+               &tux_Dprintk,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+#if TUX_DPRINTK
+#endif
+       {       NET_TUX_LOGGING,
+               "logging",
+               &tux_logging,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_LOGENTRY_ALIGN_ORDER,
+               "logentry_align_order",
+               &tux_logentry_align_order,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_ACK_PINGPONG,
+               "ack_pingpong",
+               &tux_ack_pingpong,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_PUSH_ALL,
+               "push_all",
+               &tux_push_all,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_ZEROCOPY_PARSE,
+               "zerocopy_parse",
+               &tux_zerocopy_parse,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_VIRTUAL_SERVER,
+               "virtual_server",
+               &tux_virtual_server,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_VIRTUAL_SERVER,
+               "mass_hosting_hash",
+               &mass_hosting_hash,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_VIRTUAL_SERVER,
+               "strip_host_tail",
+               &strip_host_tail,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_VIRTUAL_SERVER,
+               "ftp_virtual_server",
+               &tux_ftp_virtual_server,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MAX_OBJECT_SIZE,
+               "max_object_size",
+               &tux_max_object_size,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_COMPRESSION,
+               "compression",
+               &tux_compression,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_NOID,
+               "noid",
+               &tux_noid,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CGI_INHERIT_CPU,
+               "cgi_inherit_cpu",
+               &tux_cgi_inherit_cpu,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_CGI_CPU_MASK,
+               "cgi_cpu_mask",
+               &tux_cgi_cpu_mask,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_ZEROCOPY_HEADER,
+               "zerocopy_header",
+               &tux_zerocopy_header,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_ZEROCOPY_SENDFILE,
+               "zerocopy_sendfile",
+               &tux_zerocopy_sendfile,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MAX_FREE_REQUESTS,
+               "max_free_requests",
+               &tux_max_free_requests,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_ALL_USERSPACE,
+               "all_userspace",
+               &tux_all_userspace,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_REDIRECT_LOGGING,
+               "redirect_logging",
+               &tux_redirect_logging,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_IGNORE_QUERY,
+               "ignore_query",
+               &tux_ignore_query,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_REFERER_LOGGING,
+               "referer_logging",
+               &tux_referer_logging,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_REFERER_LOGGING,
+               "cpu_offset",
+               &tux_cpu_offset,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_REFERER_LOGGING,
+               "ftp_login_message",
+               &tux_ftp_login_message,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {       NET_TUX_MAX_HEADER_LEN,
+               "max_header_len",
+               &tux_max_header_len,
+               sizeof(int),
+               0644,
+               NULL,
+               proc_dointvec,
+               &sysctl_intvec,
+               NULL,
+               NULL,
+               NULL
+       },
+       {0,0,0,0,0,0,0,0,0,0,0} };
+       
+       
+static ctl_table tux_dir_table[] = {
+       {NET_TUX, "tux", NULL, 0, 0555, tux_table,0,0,0,0,0},
+       {0,0,0,0,0,0,0,0,0,0,0}
+};
+
+static ctl_table tux_root_table[] = {
+       {CTL_NET, "net", NULL, 0, 0555, tux_dir_table,0,0,0,0,0},
+       {0,0,0,0,0,0,0,0,0,0,0}
+};
+
+
+static struct proc_dir_entry * root_tux_dir;
+static struct proc_dir_entry * log_cpu_mask_entry;
+static struct proc_dir_entry * stat_entry;
+static struct proc_dir_entry * tux_dir [CONFIG_TUX_NUMTHREADS];
+static struct proc_dir_entry * listen_dir [CONFIG_TUX_NUMTHREADS];
+
+tux_socket_t tux_listen [CONFIG_TUX_NUMTHREADS][CONFIG_TUX_NUMSOCKETS] =
+ { [0 ... CONFIG_TUX_NUMTHREADS-1] = { {&tux_proto_http, 0, 80, NULL}, } };
+
+#define HEX_DIGITS 8
+
+static int hex_read_proc (char *page, char **start, off_t off,
+                       int count, int *eof, void *data)
+{
+       if (count < HEX_DIGITS+1)
+               return -EINVAL;
+       return sprintf (page, "%08x\n", *(unsigned int *)data);
+}
+
+static int hex_write_proc (struct file *file, const char *buffer,
+                                       unsigned long count, void *data)
+{
+       char hexnum [HEX_DIGITS];
+       unsigned int new_value;
+       unsigned int i, full_count = count;
+
+       if (!count)
+               return -EINVAL;
+       if (count > HEX_DIGITS)
+               count = HEX_DIGITS;
+       if (copy_from_user(hexnum, buffer, count))
+               return -EFAULT;
+
+       /*
+        * Parse the first 8 characters as a hex string, any non-hex char
+        * is end-of-string. '00e1', 'e1', '00E1', 'E1' are the same.
+        */
+       new_value = 0;
+
+       for (i = 0; i < count; i++) {
+               unsigned int c = hexnum[i];
+
+               switch (c) {
+                       case '0' ... '9': c -= '0'; break;
+                       case 'a' ... 'f': c -= 'a'-10; break;
+                       case 'A' ... 'F': c -= 'A'-10; break;
+               default:
+                       goto out;
+               }
+               new_value = (new_value << 4) | c;
+       }
+out:
+       *(int *)data = new_value;
+
+       return full_count;
+}
+
+#define LINE_SIZE 1024
+#define LINE_MASK (LINE_SIZE-1)
+
+static int print_request_stats (threadinfo_t *ti, char *page, unsigned int skip_count, unsigned int max_count)
+{
+       struct list_head *head, *curr;
+       tux_req_t *req;
+       unsigned int count = 0, size, line_off, len;
+       char stat_line [LINE_SIZE];
+
+       if (!max_count)
+               BUG();
+
+       head = &ti->all_requests;
+       curr = head->next;
+
+       while (curr != head) {
+               req = list_entry(curr, tux_req_t, all);
+               curr = curr->next;
+               count++;
+               if (count <= skip_count)
+                       continue;
+               line_off = 0;
+#define SP(x...) \
+       line_off += sprintf(stat_line + line_off, x)
+
+               if (req->proto == &tux_proto_http)
+                       SP("0 ");
+               else
+                       SP("1 ");
+       
+               SP("%p ", req);
+               SP("%d ", req->atom_idx);
+               if (req->atom_idx >= 1)
+                       SP("%p ", req->atoms[0]);
+               else
+                       SP("........ ");
+               if (req->atom_idx >= 2)
+                       SP("%p ", req->atoms[1]);
+               else
+                       SP("........ ");
+               if (!list_empty(&req->work))    SP("W");        else SP(".");
+               if (!list_empty(&req->free))    SP("F");        else SP(".");
+               if (!list_empty(&req->lru))     SP("L");        else SP(".");
+               if (req->keep_alive)            SP("K");        else SP(".");
+               if (req->idle_input)            SP("I");        else SP(".");
+               if (timer_pending(&req->keepalive_timer))
+                                               SP("T(%lu/%lu)",jiffies,req->keepalive_timer.expires);  else SP(".");
+               if (req->wait_output_space)     SP("O");        else SP(".");
+               if (timer_pending(&req->output_timer))
+                                               SP("T");        else SP(".");
+               SP(" %d ", req->error);
+               SP(" %d ", req->status);
+
+#define SP_HOST(ip,port) \
+               SP("%d.%d.%d.%d:%d ",NIPQUAD(ip),port)
+
+               if (req->sock) {
+                       if (req->sock->sk)
+                               SP("%d:", req->sock->sk->sk_state);
+                       else
+                               SP("-2:");
+               } else
+                       SP("-1:");
+               SP_HOST(req->client_addr, req->client_port);
+
+               SP("%Ld ", req->total_file_len);
+               SP("%Ld ", req->in_file.f_pos);
+               if (req->proto == &tux_proto_http) {
+                       SP("%d ", req->method);
+                       SP("%d ", req->version);
+               }
+               if (req->proto == &tux_proto_ftp) {
+                       SP("%d ", req->ftp_command);
+                       if (req->data_sock) {
+                               if (req->data_sock->sk)
+                                       SP("%d:",req->data_sock->sk->sk_state);
+                               else
+                                       SP("-2:");
+                               if (req->data_sock->sk)
+                                       SP_HOST(inet_sk(req->data_sock->sk)->daddr,
+                                               inet_sk(req->data_sock->sk)->dport);
+                               else
+                                       SP("-1:-1 ");
+                       } else
+                               SP("-1 ");
+               }
+               SP("%p/%p %p/%p ", req->sock, req->sock ? req->sock->sk : (void *)-1, req->data_sock, req->data_sock ? req->data_sock->sk : (void *)-1);
+
+               SP("%d\n", req->parsed_len);
+               len = req->headers_len;
+               if (len > 500)
+                       len = 500;
+               SP("\n%d\n", len);
+               memcpy(stat_line + line_off, req->headers, len);
+               line_off += len;
+               len = req->objectname_len;
+               if (len > 100)
+                       len = 100;
+               SP("\n%d\n", len);
+               memcpy(stat_line + line_off, req->objectname, len);
+               line_off += len;
+               SP("\n\n<END>");
+               if (line_off >= LINE_SIZE)
+                       BUG();
+               Dprintk("printing req %p, count %d, page %p: {%s}.\n", req, count, page, stat_line);
+               size = sprintf(page, "%-*s\n", LINE_SIZE-1, stat_line);
+               if (size != LINE_SIZE)
+                       BUG();
+               page += LINE_SIZE;
+               if (count-skip_count >= max_count)
+                       break;
+       }
+
+       Dprintk("count: %d.\n", count-skip_count);
+       return count - skip_count;
+}
+
+static int stat_read_proc (char *page, char **start, off_t off,
+                       int max_size, int *eof, void *data)
+{
+       unsigned int i, nr_total = 0, nr, nr_off, nr_skip, size = 0, nr_wanted;
+
+       Dprintk("START, page: %p, max_size: %d, off: %ld.\n", page, max_size, off);
+       *eof = 1;
+       if (max_size & LINE_MASK)
+               return 0;
+       if (off & LINE_MASK)
+               return 0;
+       if (!max_size)
+               return 0;
+
+       nr_off = off/LINE_SIZE;
+
+       for (i = 0; i < nr_tux_threads; i++) {
+               threadinfo_t *ti = threadinfo + i;
+               spin_lock_irq(&ti->work_lock);
+               nr = ti->nr_requests;
+               Dprintk("ti: %p, nr: %d, nr_total: %d, nr_off: %d.\n", ti, nr, nr_total, nr_off);
+               nr_total += nr;
+               if (nr_off >= nr_total) {
+                       spin_unlock_irq(&ti->work_lock);
+                       continue;
+               }
+               nr_skip = nr_off - (nr_total - nr);
+               nr_wanted = (max_size-size) / LINE_SIZE;
+               Dprintk("nr_skip: %d, nr_wanted: %d.\n", nr_skip, nr_wanted);
+               nr = print_request_stats(ti, page + size, nr_skip, nr_wanted);
+               spin_unlock_irq(&ti->work_lock);
+               nr_off += nr;
+               size += nr * LINE_SIZE;
+               Dprintk("ret: %d requests, size: %d.\n", nr, size);
+               if (size > max_size)
+                       BUG();
+               if (size == max_size)
+                       break;
+       }
+       Dprintk("DONE: size: %d.\n", size);
+
+       *start = page;
+
+       if (size)
+               *eof = 0;
+       return size;
+}
+
+static int stat_write_proc (struct file *file, const char *buffer,
+                                       unsigned long count, void *data)
+{
+       return -EINVAL;
+}
+
+#define MAX_STRING "http://255.255.255.255:65535"
+#define MAX_STRINGLEN (sizeof(MAX_STRING))
+
+#define INACTIVE_1 "[inactive]\n"
+#define INACTIVE_2 "0\n"
+
+static int listen_read_proc (char *page, char **start, off_t off,
+                       int count, int *eof, void *data)
+{
+       tux_socket_t *listen = data;
+
+       if (count < MAX_STRINGLEN)
+               return -EINVAL;
+
+       if (!listen->proto)
+               return sprintf(page, INACTIVE_1);
+
+       return sprintf (page, "%s://%u.%u.%u.%u:%hu\n", listen->proto->name,
+                       HIPQUAD(listen->ip), listen->port);
+}
+
+static int listen_write_proc (struct file *file, const char *buffer,
+                                       unsigned long count, void *data)
+{
+       char string [MAX_STRINGLEN];
+       unsigned int d1, d2, d3, d4;
+       unsigned short port;
+       tux_socket_t *listen = data;
+
+       if (!count)
+               return -EINVAL;
+       if (count > MAX_STRINGLEN)
+               count = MAX_STRINGLEN;
+       if (copy_from_user(string, buffer, count))
+               return -EFAULT;
+       string[count] = 0;
+
+       if (!strcmp(string, INACTIVE_1) || !strcmp(string, INACTIVE_2)) {
+               listen->proto = NULL;
+               listen->ip = 0;
+               listen->port = 0;
+               return count;
+       }
+
+#define MK_IP(a,b,c,d) ((a << 24) | (b << 16) | (c << 8) | d)
+
+        if (sscanf(string, "http://%u.%u.%u.%u:%hu\n",
+                                       &d1, &d2, &d3, &d4, &port) == 5) {
+               listen->ip = MK_IP(d1,d2,d3,d4);
+               listen->port = port;
+               listen->proto = &tux_proto_http;
+               return count;
+       }
+               
+        if (sscanf(string, "ftp://%u.%u.%u.%u:%hu\n",
+                                       &d1, &d2, &d3, &d4, &port) == 5) {
+               listen->ip = MK_IP(d1,d2,d3,d4);
+               listen->port = port;
+               listen->proto = &tux_proto_ftp;
+               return count;
+       }
+       printk(KERN_ERR "tux: invalid listen-socket parameters: %s\n", string);
+       return -EINVAL;
+}
+
+#define MAX_NAMELEN 10
+
+static void register_tux_proc (unsigned int nr)
+{
+       struct proc_dir_entry *entry;
+       char name [MAX_NAMELEN];
+       int i;
+
+       if (!root_tux_dir)
+               TUX_BUG();
+
+       sprintf(name, "%d", nr);
+
+       /* create /proc/net/tux/1234/ */
+       tux_dir[nr] = proc_mkdir(name, root_tux_dir);
+
+       /* create /proc/net/tux/1234/listen/ */
+       listen_dir[nr] = proc_mkdir("listen", tux_dir[nr]);
+
+       /* create /proc/net/tux/1234/listen/ */
+       for (i = 0; i < CONFIG_TUX_NUMSOCKETS; i++) {
+               sprintf(name, "%d", i);
+               entry = create_proc_entry(name, 0700, listen_dir[nr]);
+
+               entry->nlink = 1;
+               entry->data = (void *)(tux_listen[nr] + i);
+               entry->read_proc = listen_read_proc;
+               entry->write_proc = listen_write_proc;
+               tux_listen[nr][i].entry = entry;
+       }
+}
+
+static void unregister_tux_proc (unsigned int nr)
+{
+       int i;
+
+       for (i = 0; i < CONFIG_TUX_NUMSOCKETS; i++) {
+               remove_proc_entry(tux_listen[nr][i].entry->name,listen_dir[nr]);
+               tux_listen[nr][i].entry = NULL;
+       }
+
+       remove_proc_entry(listen_dir[nr]->name, tux_dir[nr]);
+
+       remove_proc_entry(tux_dir[nr]->name, root_tux_dir);
+}
+
+static void cleanup_tux_proc (void)
+{
+       int i;
+
+       Dprintk("cleaning up /proc/net/tux/\n");
+
+       for (i = 0; i < CONFIG_TUX_NUMTHREADS; i++)
+               unregister_tux_proc(i);
+       remove_proc_entry(stat_entry->name, root_tux_dir);
+       remove_proc_entry(log_cpu_mask_entry->name, root_tux_dir);
+       remove_proc_entry(root_tux_dir->name, proc_net);
+}
+
+static void init_tux_proc (void)
+{
+       struct proc_dir_entry *entry;
+       int i;
+
+       if (root_tux_dir)
+               return;
+
+       /* create /proc/net/tux */
+       root_tux_dir = proc_mkdir("tux", proc_net);
+
+       entry = create_proc_entry("log_cpu_mask", 0700, root_tux_dir);
+
+       entry->nlink = 1;
+       entry->data = (void *)&log_cpu_mask;
+       entry->read_proc = hex_read_proc;
+       entry->write_proc = hex_write_proc;
+
+       log_cpu_mask_entry = entry;
+
+       entry = create_proc_entry("stat", 0700, root_tux_dir);
+
+       entry->nlink = 1;
+       entry->data = NULL;
+       entry->read_proc = stat_read_proc;
+       entry->write_proc = stat_write_proc;
+
+       stat_entry = entry;
+
+       /*
+        * Create entries for all existing threads.
+        */
+       for (i = 0; i < CONFIG_TUX_NUMTHREADS; i++)
+               register_tux_proc(i);
+}
+
+void start_sysctl(void)
+{
+       init_tux_proc();
+       tux_table_header = register_sysctl_table(tux_root_table,1);
+}
+
+void end_sysctl(void)
+{
+       cleanup_tux_proc();
+       unregister_sysctl_table(tux_table_header);
+}
+
+#if CONFIG_SMP
+void mask_to_cpumask(unsigned int mask, cpumask_t *cpu_mask)
+{
+
+       unsigned int bit_mask, i;
+
+       bit_mask = 1 << 31;
+
+       for (i=NR_CPUS-1; i--; i >= 0) {
+               if(mask & bit_mask)
+                       cpu_set(i, *cpu_mask);
+               else
+                       cpu_clear(i, *cpu_mask);
+               mask <<= 1;
+       }
+
+}
+#endif
+
diff --git a/net/tux/proto_ftp.c b/net/tux/proto_ftp.c
new file mode 100644 (file)
index 0000000..fbb9d8e
--- /dev/null
@@ -0,0 +1,1549 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * ftp_proto.c: FTP application protocol support
+ */
+
+#define __KERNEL_SYSCALLS__
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+#define HELLO          "220 Linux/TUX 3.0 FTP server welcomes you!\r\n"
+#define WRITE_DONE     "226 Transfer complete.\r\n"
+#define BAD_FILENAME   "550 No such file or directory.\r\n"
+#define GOOD_DIR       "250 CWD command successful.\r\n"
+#define LIST_ERR       "503 LIST without PORT! Closing connection.\r\n"
+#define LIST_ERR_MEM   "503 LIST could not allocate memory! Closing connection.\r\n"
+#define WRITE_FILE     "150 Opening BINARY mode data connection.\r\n"
+#define WRITE_LIST     "150 Opening ASCII mode data connection.\r\n"
+#define RETR_ERR       "503 RETR without PORT! Closing connection.\r\n"
+#define PORT_OK                "200 PORT command successful.\r\n"
+#define LOGIN_OK       "230-There are currently %d users logged in, out of %d maximum.\r\n230-Bandwidth served by TUX currently: %d KB/sec\r\n230 TUX Guest login ok.\r\n"
+#define LOGIN_OK_ONE   "230-There is currently 1 user logged in, out of %d maximum.\r\n230-Bandwidth served by TUX currently: %d KB/sec\r\n230 TUX Guest login ok.\r\n"
+#define LOGIN_OK_PASS  "230 TUX Guest login ok.\r\n"
+#define LOGIN_FORBIDDEN        "530 Sorry, Login Denied!\r\n"
+#define TYPE_OK                "200 Type set to I.\r\n"
+#define BYE            "221 Thank You for using TUX!\r\n"
+#define NOT_IMPLEMENTED        "502 Command not implemented.\r\n"
+#define CLOSE_2                "221 Cannot handle request, closing connection!\r\n"
+#define CLOSE          "500 Unknown command.\r\n"
+#define CLOSE_TIMEOUT  "421 Timeout, closing connection!\r\n"
+#define LINUX_SYST     "215 UNIX Type: L8, Linux/TUX/3.0\r\n"
+#define COMMAND_OK     "200 Command OK.\r\n"
+#define REST_OK                "350 Restart offset OK.\r\n"
+#define WRITE_ABORTED  "426 Transfer aborted, data connection closed.\r\n"
+#define SITE           "214 No SITE commands are recognized.\r\n"
+
+#define INTERVAL 10
+
+unsigned long last_measurement;
+unsigned int ftp_bytes_sent;
+unsigned int ftp_bandwidth;
+
+static void __update_bandwidth (tux_req_t *req, unsigned int bytes)
+{
+       /*
+        * Bandwidth measurement. Not completely accurate,
+        * but it's good enough and lightweight enough.
+        */
+       if (jiffies >= last_measurement + INTERVAL*HZ) {
+               ftp_bandwidth = (ftp_bytes_sent + 1023)/INTERVAL/1024;
+               ftp_bytes_sent = 0;
+               last_measurement = jiffies;
+       }
+       if (bytes)
+               atomic_add(bytes, (atomic_t *)&ftp_bytes_sent);
+       Dprintk("update_bandwidth(%p,%d), bytes_sent: %d, bandwidth: %d.\n",
+               req, bytes, ftp_bytes_sent, ftp_bandwidth);
+}
+
+#define update_bandwidth(req,bytes)                            \
+       do {                                                    \
+               if (unlikely(tux_ftp_login_message))            \
+                       __update_bandwidth(req, bytes);         \
+       } while (0)
+
+static inline void __ftp_send_async_message (tux_req_t *req,
+                const char *message, int status, unsigned int size)
+{
+       update_bandwidth(req, size);
+       __send_async_message(req, message, status, size, 1);
+}
+
+#define ftp_send_async_message(req,str,status) \
+               __ftp_send_async_message(req,str,status,sizeof(str)-1)
+
+
+static void ftp_flush_req (tux_req_t *req, int cachemiss)
+{
+       tux_push_pending(req->sock->sk);
+       add_req_to_workqueue(req);
+}
+
+static void ftp_execute_command (tux_req_t *req, int cachemiss);
+
+static void ftp_lookup_vhost (tux_req_t *req, int cachemiss)
+{
+       struct dentry *dentry;
+       struct nameidata base;
+       struct vfsmount *mnt = NULL;
+       unsigned int flag = cachemiss ? 0 : LOOKUP_ATOMIC;
+       char ip[3+1+3+1+3+1+3 + 2];
+
+       sprintf(ip, "%d.%d.%d.%d", NIPQUAD(inet_sk(req->sock->sk)->rcv_saddr));
+       Dprintk("ftp_lookup_vhost(%p, %d, virtual: %d, host: %s.)\n", 
+               req, flag, req->virtual, ip);
+
+       base.flags = LOOKUP_FOLLOW|flag;
+       base.last_type = LAST_ROOT;
+       base.dentry = dget(req->proto->main_docroot.dentry);
+       base.mnt = mntget(req->proto->main_docroot.mnt);
+
+       dentry = __tux_lookup(req, ip, &base, &mnt);
+
+       Dprintk("looked up dentry %p.\n", dentry);
+       if (dentry && !IS_ERR(dentry) && !dentry->d_inode)
+               TUX_BUG();
+
+       if (!dentry || IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO) {
+                       add_tux_atom(req, ftp_lookup_vhost);
+                       queue_cachemiss(req);
+                       return;
+               }
+               goto abort;
+       }
+
+       req->docroot_dentry = dentry;
+       req->docroot_mnt = mnt;
+
+       add_tux_atom(req, ftp_execute_command);
+       add_req_to_workqueue(req);
+       return;
+abort:
+       if (dentry) {
+               if (!IS_ERR(dentry))
+                       dput(dentry);
+               dentry = NULL;
+       }
+       if (mnt) {
+               if (!IS_ERR(mnt))
+                       mntput(mnt);
+               mnt = NULL;
+       }
+       req_err(req);
+       add_req_to_workqueue(req);
+}
+
+static void ftp_got_request (tux_req_t *req)
+{
+       add_tux_atom(req, parse_request);
+       add_tux_atom(req, ftp_flush_req);
+       ftp_send_async_message(req, HELLO, 220);
+}
+
+#define GOTO_ERR { TDprintk("FTP protocol error at: %s:%d\n", \
+                       __FILE__, __LINE__); goto error; }
+
+static void zap_data_socket (tux_req_t *req)
+{
+       if (!req->data_sock)
+               return;
+       Dprintk("zapping req %p's data socket %p.\n", req, req->data_sock);
+
+       unlink_tux_data_socket(req);
+       sock_release(req->data_sock);
+       req->data_sock = NULL;
+}
+
+static int parse_ftp_message (tux_req_t *req, const int total_len)
+{
+       int comm, comm1 = 0, comm2 = 0, comm3 = 0, comm4 = 0;
+       int newline_pos, i;
+       const char *mess, *curr;
+
+       curr = mess = req->headers;
+
+       Dprintk("FTP parser got %d bytes: --->{%s}<---\n", total_len, curr);
+
+       newline_pos = -1;
+       for (i = 0; i < total_len; i++, curr++) {
+               if (!*curr)
+                       GOTO_ERR;
+               if (!(*curr == '\r') || !(*(curr+1) == '\n'))
+                       continue;
+               newline_pos = i;
+               break;
+       }
+       Dprintk("Newline pos: %d\n", newline_pos);
+       if (newline_pos == -1) {
+               Dprintk("incomplete mess on req %p!\n", req);
+               return 0;
+       }
+       if (newline_pos < 3)
+               GOTO_ERR;
+
+#define toup(c) ((((c) >= 'a') && ((c) <= 'z')) ? ((c) + 'A' - 'a') : (c))
+
+#define STRING_VAL(c1,c2,c3,c4) \
+       (toup(c1) + (toup(c2) << 8) + (toup(c3) << 16) + (toup(c4) << 24))
+
+#define STRING_VAL_STR(str) \
+               STRING_VAL(str[0], str[1], str[2], str[3])
+
+       Dprintk("string val (%c%c%c%c): %08x\n",
+               mess[0], mess[1], mess[2], mess[3],
+               STRING_VAL_STR(mess));
+
+#define PARSE_FTP_COMM(c1,c2,c3,c4,name,num)                   \
+       if (STRING_VAL_STR(mess) == STRING_VAL(c1,c2,c3,c4))    \
+       {                                                       \
+               Dprintk("parsed "#name".\n");                   \
+               comm##num = FTP_COMM_##name;                    \
+       }
+
+       PARSE_FTP_COMM('A','C','C','T', ACCT,2);
+       PARSE_FTP_COMM('C','D','U','P', CDUP,3);
+       PARSE_FTP_COMM('S','M','N','T', SMNT,4);
+       PARSE_FTP_COMM('Q','U','I','T', QUIT,1);
+       PARSE_FTP_COMM('R','E','I','N', REIN,2);
+       PARSE_FTP_COMM('P','A','S','V', PASV,3);
+       PARSE_FTP_COMM('S','T','R','U', STRU,4); 
+       PARSE_FTP_COMM('S','T','O','R', STOR,2); 
+       PARSE_FTP_COMM('S','T','O','U', STOU,3); 
+       PARSE_FTP_COMM('A','P','P','E', APPE,4); 
+       PARSE_FTP_COMM('A','L','L','O', ALLO,1); 
+       PARSE_FTP_COMM('R','N','F','R', RNFR,2); 
+       PARSE_FTP_COMM('R','N','T','O', RNTO,3); 
+       PARSE_FTP_COMM('A','B','O','R', ABOR,4); 
+       PARSE_FTP_COMM('D','E','L','E', DELE,1); 
+       PARSE_FTP_COMM('R','M','D',' ', RMD, 2); 
+       PARSE_FTP_COMM('M','K','D',' ', MKD, 3); 
+       PARSE_FTP_COMM('P','W','D',' ', PWD, 4); 
+       PARSE_FTP_COMM('S','Y','S','T', SYST,2); 
+       PARSE_FTP_COMM('N','O','O','P', NOOP,3); 
+       PARSE_FTP_COMM('F','E','A','T', FEAT,4); 
+
+       comm = comm1 | comm2 | comm3 | comm4;
+
+       if (comm) {
+               if (newline_pos != 4)
+                       GOTO_ERR;
+               req->ftp_command = comm;
+               goto out;
+       }
+       
+       switch (STRING_VAL(mess[0], mess[1], mess[2], mess[3])) {
+
+#define PARSE_FTP_COMM_3CHAR(c1,c2,c3,name)                            \
+               case STRING_VAL(c1,c2,c3,'\r'):                         \
+               {                                                       \
+                       Dprintk("parsed "#name".\n");                   \
+                       req->ftp_command = FTP_COMM_##name;             \
+                       if (newline_pos != 3)                           \
+                               GOTO_ERR;                               \
+               }
+
+#define PARSE_FTP_3CHAR_COMM_IGNORE(c1,c2,c3,name)                     \
+               case STRING_VAL(c1,c2,c3,' '):                          \
+               {                                                       \
+                       Dprintk("parsed "#name".\n");                   \
+                       req->ftp_command = FTP_COMM_##name;             \
+               }
+
+#define PARSE_FTP_COMM_IGNORE(c1,c2,c3,c4,name)                                \
+               case STRING_VAL(c1,c2,c3,c4):                           \
+               {                                                       \
+                       Dprintk("parsed "#name".\n");                   \
+                       req->ftp_command = FTP_COMM_##name;             \
+               }
+
+#define PARSE_FTP_3CHAR_COMM_1_FIELD(c1,c2,c3,name,field,field_len,max)        \
+               case STRING_VAL(c1,c2,c3,' '):                          \
+               {                                                       \
+                       Dprintk("parsed "#name".\n");                   \
+                       req->ftp_command = FTP_COMM_##name;             \
+                       if (newline_pos == 4)                           \
+                               GOTO_ERR;                               \
+                       if (newline_pos >= 5) {                         \
+                               curr = mess + 3;                        \
+                               if (*curr++ != ' ')                     \
+                                       GOTO_ERR;                       \
+                               *(field_len) = newline_pos-4;           \
+                               if (*(field_len) >= max)                \
+                                       GOTO_ERR;                       \
+                               memcpy(field, curr, *(field_len));      \
+                               (field)[*(field_len)] = 0;              \
+                       }                                               \
+               }
+
+#define PARSE_FTP_COMM_1_FIELD(c1,c2,c3,c4,name,field,field_len,max)   \
+               case STRING_VAL(c1,c2,c3,c4):                           \
+               {                                                       \
+                       Dprintk("parsed "#name".\n");                   \
+                       req->ftp_command = FTP_COMM_##name;             \
+                       if (newline_pos < 4)                            \
+                               GOTO_ERR;                               \
+                       if (newline_pos == 4)                           \
+                               *(field_len) = 0;                       \
+                       else {                                          \
+                               curr = mess + 4;                        \
+                               if (*curr++ != ' ')                     \
+                                       GOTO_ERR;                       \
+                               *(field_len) = newline_pos-5;           \
+                               if (*(field_len) >= max)                \
+                                       GOTO_ERR;                       \
+                               memcpy(field, curr, *(field_len));      \
+                               (field)[*(field_len)] = 0;              \
+                       }                                               \
+               }
+
+               PARSE_FTP_COMM_1_FIELD('U','S','E','R', USER,
+                       req->username, &req->username_len,
+                       MAX_USERNAME_LEN-1);
+               if (!req->username_len)
+                       GOTO_ERR;
+               break;
+
+               {
+                       #define MAX_PASS_LEN 100
+                       char pass[MAX_PASS_LEN];
+                       unsigned int pass_len;
+                       PARSE_FTP_COMM_1_FIELD('P','A','S','S', PASS,
+                               pass, &pass_len,
+                               MAX_PASS_LEN-1);
+                       if (!pass_len)
+                               GOTO_ERR;
+                       break;
+               }
+
+               PARSE_FTP_3CHAR_COMM_1_FIELD('C','W','D', CWD,
+                       req->objectname, &req->objectname_len,
+                       MAX_OBJECTNAME_LEN-1);
+               if (!req->objectname_len)
+                       GOTO_ERR;
+               req->uri_str = req->objectname;
+               req->uri_len = req->objectname_len;
+               break;
+
+               PARSE_FTP_COMM_3CHAR('P','W','D', PWD); break;
+
+               {
+                       char type[3];
+                       unsigned int type_len;
+
+                       PARSE_FTP_COMM_1_FIELD('T','Y','P','E', TYPE,
+                               type, &type_len, 2);
+                       if (!type_len)
+                               GOTO_ERR;
+                       if ((type[0] != 'I') && (type[0] != 'A'))
+                               GOTO_ERR;
+               }
+               break;
+
+               PARSE_FTP_COMM_1_FIELD('R','E','T','R', RETR,
+                       req->objectname, &req->objectname_len,
+                       MAX_OBJECTNAME_LEN-1);
+               if (!req->objectname_len) {
+                       zap_data_socket(req);
+                       req->ftp_command = FTP_COMM_NONE;
+               }
+               req->uri_str = req->objectname;
+               req->uri_len = req->objectname_len;
+               break;
+
+               PARSE_FTP_COMM_1_FIELD('S','I','Z','E', SIZE,
+                       req->objectname, &req->objectname_len,
+                       MAX_OBJECTNAME_LEN-1);
+               if (!req->objectname_len)
+                       req->ftp_command = FTP_COMM_NONE;
+               req->uri_str = req->objectname;
+               req->uri_len = req->objectname_len;
+               break;
+
+               PARSE_FTP_COMM_1_FIELD('M','D','T','M', MDTM,
+                       req->objectname, &req->objectname_len,
+                       MAX_OBJECTNAME_LEN-1);
+               if (!req->objectname_len)
+                       req->ftp_command = FTP_COMM_NONE;
+               req->uri_str = req->objectname;
+               req->uri_len = req->objectname_len;
+               break;
+
+               PARSE_FTP_COMM_IGNORE('M','O','D','E', MODE);
+               break;
+
+               PARSE_FTP_COMM_IGNORE('S','T','A','T', STAT);
+               break;
+
+               PARSE_FTP_COMM_IGNORE('S','I','T','E', SITE);
+               break;
+
+               PARSE_FTP_COMM_1_FIELD('L','I','S','T', LIST,
+                       req->objectname, &req->objectname_len,
+                       MAX_OBJECTNAME_LEN-1);
+               if (req->objectname[0] == '-') {
+                       req->objectname_len = 0;
+                       req->objectname[0] = 0;
+               }
+               if (req->objectname_len) {
+                       req->uri_str = req->objectname;
+                       req->uri_len = req->objectname_len;
+               }
+               break;
+
+               PARSE_FTP_COMM_1_FIELD('N','L','S','T', NLST,
+                       req->objectname, &req->objectname_len,
+                       MAX_OBJECTNAME_LEN-1);
+               if (req->objectname[0] == '-') {
+                       req->objectname_len = 0;
+                       req->objectname[0] = 0;
+               }
+               if (req->objectname_len) {
+                       req->uri_str = req->objectname;
+                       req->uri_len = req->objectname_len;
+               }
+               break;
+
+               PARSE_FTP_COMM_IGNORE('H','E','L','P', HELP);
+               break;
+
+               PARSE_FTP_COMM_IGNORE('C','L','N','T', CLNT);
+               break;
+
+#define IS_NUM(n) (((n) >= '0') && ((n) <= '9'))
+
+#define GET_DIGIT(curr,n)                              \
+       n += (*curr) - '0';                             \
+       curr++;                                         \
+       if (IS_NUM(*curr)) {                            \
+               n *= 10;
+
+#define PARSE_PORTNUM(curr,n)                          \
+do {                                                   \
+       Dprintk("PORT NUM parser:--->{%s}<---\n", curr);\
+       if (!IS_NUM(*curr))                             \
+               GOTO_ERR;                               \
+       n = 0;                                          \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       }}}                                             \
+       if (n > 255)                                    \
+               GOTO_ERR;                               \
+       Dprintk("PORT NUM parser:--->{%s}<---\n", curr);\
+       Dprintk("PORT NUM parser parsed %d.\n", n);     \
+} while (0)
+
+#define PARSE_NUM(curr,n)                              \
+do {                                                   \
+       Dprintk("NUM parser:--->{%s}<---\n", curr);     \
+       if (!IS_NUM(*curr))                             \
+               GOTO_ERR;                               \
+       n = 0;                                          \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       GET_DIGIT(curr,n);                              \
+       }}}}}}}}}}                                      \
+       Dprintk("NUM parser:--->{%s}<---\n", curr);     \
+       Dprintk("NUM parser parsed %d.\n", n);          \
+} while (0)
+
+               case STRING_VAL('P','O','R','T'):
+               {
+                       unsigned int h1, h2, h3, h4, p1, p2;
+                       if (req->data_sock)
+                               zap_data_socket(req);
+                       /*
+                        * Minimum size: "PORT 0,0,0,0,0,0", 16 bytes.
+                        */
+                       if (newline_pos < 16)
+                               GOTO_ERR;
+                       Dprintk("parsed PORT.\n");
+                       if (req->data_sock)
+                               GOTO_ERR;
+                       curr = mess + 4;
+                       if (*curr++ != ' ')
+                               GOTO_ERR;
+                       PARSE_PORTNUM(curr,h1);
+                       if (*curr++ != ',')
+                               GOTO_ERR;
+                       PARSE_PORTNUM(curr,h2);
+                       if (*curr++ != ',')
+                               GOTO_ERR;
+                       PARSE_PORTNUM(curr,h3);
+                       if (*curr++ != ',')
+                               GOTO_ERR;
+                       PARSE_PORTNUM(curr,h4);
+                       if (*curr++ != ',')
+                               GOTO_ERR;
+                       PARSE_PORTNUM(curr,p1);
+                       if (*curr++ != ',')
+                               GOTO_ERR;
+                       PARSE_PORTNUM(curr,p2);
+                       if (curr-mess != newline_pos)
+                               GOTO_ERR;
+                       req->ftp_command = FTP_COMM_PORT;
+                       req->ftp_user_addr = (h1<<24) + (h2<<16) + (h3<<8) + h4;
+                       req->ftp_user_port = (p1<<8) + p2;
+                       Dprintk("FTP PORT got: %d.%d.%d.%d:%d.\n",
+                               h1, h2, h3, h4, req->ftp_user_port);
+                       Dprintk("FTP user-addr: %08x (htonl: %08x), socket: %08x.\n",
+                               req->ftp_user_addr, htonl(req->ftp_user_addr),
+                               inet_sk(req->sock->sk)->daddr);
+                       /*
+                        * Do not allow redirection of connections, and do
+                        * not allow reserved ports to be accessed.
+                        */
+                       if (inet_sk(req->sock->sk)->daddr != htonl(req->ftp_user_addr))
+                               GOTO_ERR;
+                       if (req->ftp_user_port < 1024)
+                               GOTO_ERR;
+                       break;
+               }
+               case STRING_VAL('R','E','S','T'):
+               {
+                       unsigned int offset;
+
+                       /*
+                        * Minimum size: "REST 0", 6 bytes.
+                        */
+                       if (newline_pos < 6)
+                               GOTO_ERR;
+                       Dprintk("parsed REST.\n");
+                       curr = mess + 4;
+                       if (*curr++ != ' ')
+                               GOTO_ERR;
+                       PARSE_NUM(curr,offset);
+                       if (curr-mess != newline_pos)
+                               GOTO_ERR;
+                       req->ftp_command = FTP_COMM_REST;
+                       req->ftp_offset_start = offset;
+                       Dprintk("FTP REST got: %d bytes offset.\n", offset);
+
+                       break;
+               }
+               default:
+                       req->ftp_command = FTP_COMM_NONE;
+                       break;
+       }
+
+out:
+       req->parsed_len = newline_pos + 2;
+
+       req->virtual = tux_ftp_virtual_server;
+       if (req->virtual)
+               add_tux_atom(req, ftp_lookup_vhost);
+       else {
+               req->docroot_dentry = dget(req->proto->main_docroot.dentry);
+               req->docroot_mnt = mntget(req->proto->main_docroot.mnt);
+               add_tux_atom(req, ftp_execute_command);
+       }
+
+       return req->parsed_len;
+error:
+       clear_keepalive(req);
+       TDprintk("rejecting FTP session!\n");
+       TDprintk("mess     :--->{%s}<---\n", mess);
+       TDprintk("mess left:--->{%s}<---\n", curr);
+       req_err(req);
+       return -1;
+}
+
+static void ftp_wait_close (tux_req_t *req, int cachemiss);
+static void ftp_wait_syn (tux_req_t *req, int cachemiss);
+
+static int ftp_check_req_err (tux_req_t *req, int cachemiss)
+{
+       int state = req->sock->sk->sk_state;
+       int err = req->sock->sk->sk_err | req->error;
+       int urg = tcp_sk(req->sock->sk)->urg_data;
+
+       if (req->data_sock) {
+               urg |= tcp_sk(req->data_sock->sk)->urg_data;
+               state |= req->data_sock->sk->sk_state;
+               err |= req->data_sock->sk->sk_err;
+       }
+
+       if ((state <= TCP_SYN_RECV) && !err) {
+               if (!urg)
+                       return 0;
+               req->in_file.f_pos = 0;
+               add_tux_atom(req, flush_request);
+               zap_data_socket(req);
+               ftp_send_async_message(req, WRITE_ABORTED, 426);
+               return 1;
+       }
+#if CONFIG_TUX_DEBUG
+       req->bytes_expected = 0;
+       if (tux_TDprintk)
+               dump_stack();
+#endif
+       req->in_file.f_pos = 0;
+       TDprintk("zapping, data sock state: %d (err: %d, urg: %d)\n",
+               state, err, urg);
+       /*
+        * We are in the middle of a file transfer,
+        * zap it immediately:
+        */
+       req->error = TUX_ERROR_CONN_CLOSE;
+       zap_request(req, cachemiss);
+       return 1;
+}
+
+void ftp_send_file (tux_req_t *req, int cachemiss)
+{
+       int ret;
+
+       SET_TIMESTAMP(req->output_timestamp);
+repeat:
+       ret = generic_send_file(req, req->data_sock, cachemiss);
+       update_bandwidth(req, req->in_file.f_pos - req->prev_pos);
+       req->prev_pos = req->in_file.f_pos;
+
+       switch (ret) {
+               case -5:
+                       add_tux_atom(req, ftp_send_file);
+                       output_timeout(req);
+                       break;
+               case -4:
+                       add_tux_atom(req, ftp_send_file);
+                       if (add_output_space_event(req, req->data_sock)) {
+                               del_tux_atom(req);
+                               goto repeat;
+                       }
+                       break;
+               case -3:
+                       add_tux_atom(req, ftp_send_file);
+                       queue_cachemiss(req);
+                       break;
+               case -1:
+                       break;
+               default:
+                       req->in_file.f_pos = 0;
+
+                       if (tux_ftp_wait_close) {
+                               req->data_sock->ops->shutdown(req->data_sock, SEND_SHUTDOWN);
+                               add_tux_atom(req, ftp_wait_close);
+                               add_req_to_workqueue(req);
+                               return;
+                       }
+                       Dprintk("FTP send file req %p finished!\n", req);
+                       zap_data_socket(req);
+                       add_tux_atom(req, ftp_flush_req);
+                       if (req->error)
+                               ftp_send_async_message(req, BAD_FILENAME, 200);
+                       else
+                               ftp_send_async_message(req, WRITE_DONE, 200);
+                       break;
+       }
+}
+
+#define sk_syn(sk) \
+       (!(sk)->sk_err && ((1 << (sk)->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)))
+#define req_syn(req) \
+       (!(req)->error && sk_syn((req)->data_sock->sk))
+
+static void ftp_wait_syn (tux_req_t *req, int cachemiss)
+{
+       Dprintk("ftp_wait_syn in: data socket state %d.\n", req->data_sock->state);
+       if (req_syn(req)) {
+               spin_lock_irq(&req->ti->work_lock);
+               add_keepalive_timer(req);
+               if (test_and_set_bit(0, &req->idle_input))
+                       TUX_BUG();
+               spin_unlock_irq(&req->ti->work_lock);
+               if (req_syn(req)) {
+                       add_tux_atom(req, ftp_wait_syn);
+                       return;
+               }
+               unidle_req(req);
+       }
+       Dprintk("ftp_wait_syn out: data socket state %d.\n", req->data_sock->state);
+       add_req_to_workqueue(req);
+}
+
+static void ftp_wait_close (tux_req_t *req, int cachemiss)
+{
+       struct sock *sk = req->data_sock->sk;
+
+       Dprintk("ftp_wait_close: data socket state %d.\n", sk->sk_state);
+
+       if (!req->error && (sk->sk_state <= TCP_FIN_WAIT1) && !sk->sk_err) {
+               spin_lock_irq(&req->ti->work_lock);
+               add_keepalive_timer(req);
+               if (test_and_set_bit(0, &req->idle_input))
+                       TUX_BUG();
+               spin_unlock_irq(&req->ti->work_lock);
+               if (!req->error && (sk->sk_state <= TCP_FIN_WAIT1) && !sk->sk_err) {
+                       add_tux_atom(req, ftp_wait_close);
+                       return;
+               }
+               unidle_req(req);
+       }
+       zap_data_socket(req);
+       add_tux_atom(req, ftp_flush_req);
+       if (req->error)
+               ftp_send_async_message(req, BAD_FILENAME, 200);
+       else
+               ftp_send_async_message(req, WRITE_DONE, 200);
+}
+
+void ftp_get_size (tux_req_t *req, int cachemiss)
+{
+       char file_size[200];
+       int missed, len;
+
+       if (!req->dentry) {
+               missed = lookup_object(req, cachemiss ? 0 : LOOKUP_ATOMIC);
+               if (!missed && !req->dentry) {
+                       ftp_send_async_message(req, BAD_FILENAME, 200);
+                       return;
+               }
+               if (missed) {
+                       if (cachemiss)
+                               TUX_BUG();
+                       add_tux_atom(req, ftp_get_size);
+                       queue_cachemiss(req);
+                       return;
+               }
+       }
+       req->in_file.f_pos = 0;
+       len = sprintf(file_size, "213 %Li\r\n", req->dentry->d_inode->i_size);
+       __ftp_send_async_message(req, file_size, 200, len);
+}
+
+void ftp_get_mdtm (tux_req_t *req, int cachemiss)
+{
+       unsigned int flag = cachemiss ? 0 : LOOKUP_ATOMIC;
+       struct dentry *dentry;
+       struct vfsmount *mnt = NULL;
+       char file_mdtm[200];
+       unsigned int len;
+       int err;
+
+       dentry = tux_lookup(req, req->objectname, flag, &mnt);
+       if (!dentry || IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO) {
+                       if (cachemiss)
+                               TUX_BUG();
+                       add_tux_atom(req, ftp_get_mdtm);
+                       queue_cachemiss(req);
+                       return;
+               }
+               goto out_err;
+       }
+       err = permission(dentry->d_inode, MAY_READ, NULL);
+       if (err)
+               goto out_err_put;
+
+       req->in_file.f_pos = 0;
+       len = mdtm_time (file_mdtm, dentry->d_inode->i_mtime.tv_sec);
+       dput(dentry);
+       mntput(mnt);
+       __ftp_send_async_message(req, file_mdtm, 200, len);
+       return;
+
+out_err_put:
+       dput(dentry);
+       mntput(mnt);
+out_err:
+       ftp_send_async_message(req, BAD_FILENAME, 550);
+}
+
+static void ftp_get_file (tux_req_t *req, int cachemiss)
+{
+       int missed;
+
+       if (!req->dentry) {
+               missed = lookup_object(req, cachemiss ? 0 : LOOKUP_ATOMIC);
+               if (!missed && !req->dentry) {
+                       ftp_send_async_message(req, BAD_FILENAME, 200);
+                       return;
+               }
+               if (missed) {
+                       if (cachemiss)
+                               TUX_BUG();
+                       add_tux_atom(req, ftp_get_file);
+                       queue_cachemiss(req);
+                       return;
+               }
+       }
+       Dprintk("ftp_send_file %p, ftp_offset: %Ld, total_len: %Ld.\n", req, req->ftp_offset_start, req->total_file_len);
+       req->in_file.f_pos = 0;
+       if (req->ftp_offset_start) {
+               if (req->ftp_offset_start <= req->total_file_len) {
+                       req->offset_start = req->ftp_offset_start;
+                       req->in_file.f_pos = req->offset_start;
+               }
+               req->ftp_offset_start = 0;
+       }
+       req->output_len = req->total_file_len - req->offset_start;
+       req->prev_pos = req->in_file.f_pos;
+       Dprintk("ftp_send_file %p, f_pos: %Ld (out_len: %Ld).\n", req, req->in_file.f_pos, req->output_len);
+       add_tux_atom(req, ftp_send_file);
+       add_tux_atom(req, ftp_wait_syn);
+       add_tux_atom(req, ftp_flush_req);
+       ftp_send_async_message(req, WRITE_FILE, 200);
+}
+
+static void __exchange_sockets (tux_req_t *req)
+{
+       struct socket *tmp;
+
+       tmp = req->data_sock;
+       req->data_sock = req->sock;
+       req->sock = tmp;
+
+       req->in_file.f_pos = 0;
+}
+
+static void ftp_do_ls_start (tux_req_t *req, int cachemiss)
+{
+       Dprintk("ftp_do_ls_start(%p, %d).\n", req, cachemiss);
+       if (!req->cwd_dentry)
+               TUX_BUG();
+       __exchange_sockets(req);
+       queue_cachemiss(req);
+}
+
+static void ftp_do_ls_end (tux_req_t *req, int cachemiss)
+{
+       Dprintk("ftp_do_ls_end(%p, %d).\n", req, cachemiss);
+       __exchange_sockets(req);
+       if (tux_ftp_wait_close) {
+               req->data_sock->ops->shutdown(req->data_sock, SEND_SHUTDOWN);
+               add_tux_atom(req, ftp_wait_close);
+               add_req_to_workqueue(req);
+               return;
+       }
+       zap_data_socket(req);
+       add_tux_atom(req, ftp_flush_req);
+       if (req->error)
+               ftp_send_async_message(req, BAD_FILENAME, 200);
+       else
+               ftp_send_async_message(req, WRITE_DONE, 200);
+}
+
+static void ftp_chdir (tux_req_t *req, int cachemiss)
+{
+       unsigned int flag = cachemiss ? 0 : LOOKUP_ATOMIC;
+       struct dentry *dentry;
+       struct vfsmount *mnt = NULL;
+       int err;
+
+       Dprintk("ftp_chdir(%p, %d, {%s})\n", req, cachemiss, req->objectname);
+       dentry = tux_lookup(req, req->objectname, flag, &mnt);
+       if (!dentry || IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO) {
+                       if (cachemiss)
+                               TUX_BUG();
+                       add_tux_atom(req, ftp_chdir);
+                       queue_cachemiss(req);
+                       return;
+               }
+               goto out_err;
+       }
+       err = permission(dentry->d_inode, MAY_EXEC, NULL);
+       if (err)
+               goto out_err_put;
+       req->cwd_dentry = dentry;
+       req->cwd_mnt = mnt;
+       ftp_send_async_message(req, GOOD_DIR, 200);
+       return;
+
+out_err_put:
+       dput(dentry);
+       mntput(mnt);
+out_err:
+       ftp_send_async_message(req, BAD_FILENAME, 550);
+}
+
+void ftp_accept_pasv (tux_req_t *req, int cachemiss)
+{
+       struct socket *sock, *new_sock = NULL;
+       struct tcp_opt *tp1, *tp2;
+       int err;
+
+       tp1 = tcp_sk(req->data_sock->sk);
+
+       Dprintk("PASV accept on req %p, accept_queue: %p.\n",
+                       req, tp1->accept_queue);
+       if (req->error || (req->data_sock->sk->sk_state != TCP_LISTEN))
+               goto error;
+new_socket:
+       if (!tp1->accept_queue) {
+               spin_lock_irq(&req->ti->work_lock);
+               add_keepalive_timer(req);
+               if (test_and_set_bit(0, &req->idle_input))
+                       TUX_BUG();
+               spin_unlock_irq(&req->ti->work_lock);
+               if (!tp1->accept_queue) {
+                       add_tux_atom(req, ftp_accept_pasv);
+                       return;
+               }
+               unidle_req(req);
+       }
+       new_sock = sock_alloc();
+       if (!new_sock)
+               goto error;
+       sock = req->data_sock;
+       new_sock->type = sock->type;
+       new_sock->ops = sock->ops;
+
+       err = sock->ops->accept(sock, new_sock, O_NONBLOCK);
+       Dprintk("PASV accept() returned %d (state %d).\n", err, new_sock->sk->sk_state);
+       if (err < 0)
+               goto error;
+       if (new_sock->sk->sk_state != TCP_ESTABLISHED)
+               goto error;
+       /*
+        * Do not allow other clients to steal the FTP connection!
+        */
+       if (inet_sk(new_sock->sk)->daddr != inet_sk(req->sock->sk)->daddr) {
+               Dprintk("PASV: ugh, unauthorized connect?\n");
+               sock_release(new_sock);
+               new_sock = NULL;
+               goto new_socket;
+       }
+       /*
+        * Zap the listen socket:
+        */
+       zap_data_socket(req);
+
+       tp2 = tcp_sk(new_sock->sk);
+       tp2->nonagle = 2;
+       tp2->ack.pingpong = tux_ack_pingpong;
+       new_sock->sk->sk_reuse = 1;
+       sock_set_flag(new_sock->sk, SOCK_URGINLINE);
+       sock_reset_flag(new_sock->sk, SOCK_LINGER);
+
+       link_tux_data_socket(req, new_sock);
+       add_req_to_workqueue(req);
+       return;
+
+error:
+       if (new_sock)
+               sock_release(new_sock);
+       req_err(req);
+       zap_data_socket(req);
+       ftp_send_async_message(req, CLOSE, 500);
+}
+
+static char * ftp_print_dir_line (tux_req_t *req, char *tmp, char *d_name, int d_len, int d_type, struct dentry *dentry, struct inode *inode)
+{
+       char *string0 = tmp;
+       unsigned int size;
+
+       if (req->ftp_command == FTP_COMM_NLST) {
+               memcpy(tmp, d_name, d_len);
+               tmp += d_len;
+               *tmp++ = '\r';
+               *tmp++ = '\n';
+               *tmp = 0;
+               return tmp;
+       }
+       switch (d_type) {
+               default:
+               case DT_UNKNOWN:
+               case DT_WHT:
+                       if (tux_hide_unreadable)
+                               goto out_dput;
+                       *tmp++ = '?';
+                       break;
+
+               case DT_FIFO:
+                       if (tux_hide_unreadable)
+                               goto out_dput;
+                       *tmp++ = 'p';
+                       break;
+
+               case DT_CHR:
+                       if (tux_hide_unreadable)
+                               goto out_dput;
+                       *tmp++ = 'c';
+                       break;
+
+               case DT_DIR:
+                       *tmp++ = 'd';
+                       break;
+
+               case DT_BLK:
+                       if (tux_hide_unreadable)
+                               goto out_dput;
+                       *tmp++ = 'b';
+                       break;
+
+               case DT_REG:
+                       *tmp++ = '-';
+                       break;
+
+               case DT_LNK:
+                       *tmp++ = 'l';
+                       break;
+
+               case DT_SOCK:
+                       if (tux_hide_unreadable)
+                               goto out_dput;
+                       *tmp++ = 's';
+                       break;
+       }
+
+       if (inode->i_mode & S_IRUSR) *tmp++ = 'r'; else *tmp++ = '-';
+       if (inode->i_mode & S_IWUSR) *tmp++ = 'w'; else *tmp++ = '-';
+       if (inode->i_mode & S_IXUSR) *tmp++ = 'x'; else *tmp++ = '-';
+       if (inode->i_mode & S_IRGRP) *tmp++ = 'r'; else *tmp++ = '-';
+       if (inode->i_mode & S_IWGRP) *tmp++ = 'w'; else *tmp++ = '-';
+       if (inode->i_mode & S_IXGRP) *tmp++ = 'x'; else *tmp++ = '-';
+       if (inode->i_mode & S_IROTH) *tmp++ = 'r'; else *tmp++ = '-';
+       if (inode->i_mode & S_IWOTH) *tmp++ = 'w'; else *tmp++ = '-';
+       if (inode->i_mode & S_IXOTH) *tmp++ = 'x'; else *tmp++ = '-';
+
+       *tmp++ = ' ';
+
+       size = sprintf(tmp, "%4i %d", inode->i_nlink, inode->i_uid);
+       tmp += size;
+
+       size = 14 - size;
+       if (size <= 0)
+               size = 1;
+       memset(tmp, ' ', size);
+       tmp += size;
+
+       size = sprintf(tmp, "%d", inode->i_gid);
+       tmp += size;
+
+       size = 9 - size;
+       if (size <= 0)
+               size = 1;
+       memset(tmp, ' ', size);
+       tmp += size;
+
+       tmp += sprintf(tmp, "%8Li", inode->i_size);
+       *tmp++ = ' ';
+
+       tmp += time_unix2ls(inode->i_mtime.tv_sec, tmp);
+       *tmp++ = ' ';
+
+       memcpy(tmp, d_name, d_len);
+       tmp += d_len;
+
+       if (d_type == DT_LNK) {
+               int len = 0, max_len;
+               #define ARROW " -> "
+
+               memcpy(tmp, ARROW, sizeof(ARROW)-1);
+               tmp += sizeof(ARROW)-1;
+               max_len = MAX_OBJECTNAME_LEN-(tmp-string0);
+               if (inode->i_op && inode->i_op->readlink) {
+                       mm_segment_t oldmm;
+
+                       oldmm = get_fs(); set_fs(KERNEL_DS);
+                       set_fs(KERNEL_DS);
+                       len = inode->i_op->readlink(dentry, tmp, max_len);
+                       set_fs(oldmm);
+               }
+               if (len > 0)
+                       tmp += len;
+               else
+                       Dprintk("hm, readlink() returned %d.\n", len);
+       }
+       *tmp++ = '\r';
+       *tmp++ = '\n';
+       *tmp = 0;
+
+       return tmp;
+out_dput:
+       return NULL;
+}
+
+static void ftp_do_ls_onefile (tux_req_t *req, int cachemiss)
+{
+       char string0[MAX_OBJECTNAME_LEN+200], *tmp;
+
+       tmp = ftp_print_dir_line(req, string0, req->objectname, req->objectname_len,
+DT_REG, req->dentry, req->dentry->d_inode);
+       if (!tmp) {
+               req_err(req);
+               add_req_to_workqueue(req);
+               return;
+       }
+       if (tmp - string0 >= MAX_OBJECTNAME_LEN+200)
+               BUG();
+       __ftp_send_async_message(req, string0, 200, tmp - string0);
+}
+
+static void ftp_lookup_listfile (tux_req_t *req, int cachemiss)
+{
+       unsigned int flag = cachemiss ? 0 : LOOKUP_ATOMIC;
+       struct dentry *dentry;
+       struct vfsmount *mnt = NULL;
+       int err;
+
+       Dprintk("ftp_lookup_listfile(%p, %d, {%s})\n", req, cachemiss, req->objectname);
+       dentry = tux_lookup(req, req->objectname, flag, &mnt);
+       if (!dentry || IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO) {
+                       if (cachemiss)
+                               TUX_BUG();
+                       add_tux_atom(req, ftp_lookup_listfile);
+                       queue_cachemiss(req);
+                       return;
+               }
+               goto out_err;
+       }
+
+       if (S_ISDIR(dentry->d_inode->i_mode)) {
+               err = permission(dentry->d_inode, MAY_EXEC, NULL);
+               if (err) {
+                       Dprintk("Directory permission error: %d.\n", err);
+                       goto out_err_put;
+               }
+               install_req_dentry(req, dentry, mnt);
+
+               add_tux_atom(req, ftp_do_ls_end);
+               if (!req->cwd_dentry)
+                       TUX_BUG();
+               add_tux_atom(req, list_directory);
+       } else {
+               install_req_dentry(req, dentry, mnt);
+
+               add_tux_atom(req, ftp_do_ls_end);
+               add_tux_atom(req, ftp_do_ls_onefile);
+       }
+
+       add_tux_atom(req, ftp_do_ls_start);
+       add_tux_atom(req, ftp_wait_syn);
+       add_tux_atom(req, ftp_flush_req);
+       ftp_send_async_message(req, WRITE_LIST, 200);
+       return;
+
+out_err_put:
+       dput(dentry);
+       mntput(mnt);
+out_err:
+       ftp_send_async_message(req, BAD_FILENAME, 550);
+}
+
+static void ftp_execute_command (tux_req_t *req, int cachemiss)
+{
+       if (!req->parsed_len)
+               TUX_BUG();
+       trunc_headers(req);
+       req->keep_alive = 1;
+
+       switch (req->ftp_command) {
+
+#define ABORTED \
+       "226 Abort successful.\r\n"
+
+       case FTP_COMM_ABOR:
+       {
+               zap_data_socket(req);
+               ftp_send_async_message(req, ABORTED, 226);
+               break;
+       }
+
+       case FTP_COMM_PWD:
+       {
+               unsigned int str_len;
+               char *buf, *path;
+
+               buf = (char *)__get_free_page(GFP_KERNEL);
+               if (!buf) {
+                       req_err(req);
+                       ftp_send_async_message(req, LIST_ERR_MEM, 200);
+                       GOTO_ERR;
+               }
+
+               if (!req->cwd_dentry) {
+                       req->cwd_dentry = dget(req->docroot_dentry);
+                       req->cwd_mnt = mntget(req->docroot_mnt);
+               }
+
+// "257 "/" is current directory.\r\n"
+
+#define PART_1 "257 \""
+#define PART_1_LEN (sizeof(PART_1)-1)
+
+#define PART_3 "\" is current directory.\r\n"
+#define PART_3_LEN sizeof(PART_3)
+
+               path = tux_print_path(req, req->cwd_dentry, req->cwd_mnt,
+                       buf+PART_1_LEN, PAGE_SIZE - PART_3_LEN - PART_1_LEN);
+
+               if (path < buf + PART_1_LEN)
+                       BUG();
+
+               memcpy(path - PART_1_LEN, PART_1, PART_1_LEN);
+               memcpy(buf + PAGE_SIZE-PART_3_LEN-1, PART_3, PART_3_LEN);
+               str_len = buf + PAGE_SIZE-1 - (path - PART_1_LEN) - 1;
+
+               __ftp_send_async_message(req, path - PART_1_LEN, 226, str_len);
+               free_page((unsigned long)buf);
+               break;
+       }
+
+       case FTP_COMM_CDUP:
+       {
+               memcpy(req->objectname, "..", 3);
+               req->objectname_len = 2;
+               req->uri_str = req->objectname;
+               req->uri_len = req->objectname_len;
+
+               // fall through to CWD:
+       }
+       case FTP_COMM_CWD:
+       {
+               ftp_chdir(req, cachemiss);
+               break;
+       }
+
+       case FTP_COMM_NLST:
+       case FTP_COMM_LIST:
+       {
+               if (!req->data_sock) {
+                       req_err(req);
+                       ftp_send_async_message(req, LIST_ERR, 200);
+                       GOTO_ERR;
+               }
+               if (req->dentry)
+                       TUX_BUG();
+               if (!req->cwd_dentry) {
+                       req->cwd_dentry = dget(req->docroot_dentry);
+                       req->cwd_mnt = mntget(req->docroot_mnt);
+               }
+               if (req->objectname_len)
+                       ftp_lookup_listfile(req, cachemiss);
+               else {
+                       dget(req->cwd_dentry);
+                       mntget(req->cwd_mnt);
+                       install_req_dentry(req, req->cwd_dentry, req->cwd_mnt);
+                       if (!req->dentry)
+                               TUX_BUG();
+                       add_tux_atom(req, ftp_do_ls_end);
+                       if (!req->cwd_dentry)
+                               TUX_BUG();
+                       add_tux_atom(req, list_directory);
+                       add_tux_atom(req, ftp_do_ls_start);
+                       add_tux_atom(req, ftp_wait_syn);
+                       add_tux_atom(req, ftp_flush_req);
+                       ftp_send_async_message(req, WRITE_LIST, 200);
+               }
+               break;
+       }
+
+       case FTP_COMM_RETR:
+       {
+               if (!req->data_sock) {
+                       req_err(req);
+                       ftp_send_async_message(req, RETR_ERR, 200);
+                       GOTO_ERR;
+               }
+               ftp_get_file(req, cachemiss);
+               break;
+       }
+
+       case FTP_COMM_SIZE:
+       {
+               ftp_get_size(req, cachemiss);
+               break;
+       }
+
+       case FTP_COMM_MDTM:
+       {
+               ftp_get_mdtm(req, cachemiss);
+               break;
+       }
+
+       case FTP_COMM_PASV:
+       {
+               char buf [36 + 4*3 + 5 + 10];
+               struct socket *data_sock;
+               struct sockaddr_in addr;
+               unsigned int str_len;
+               struct tcp_opt *tp;
+               u32 local_addr;
+               int err;
+
+               if (req->data_sock)
+                       zap_data_socket(req);
+               /*
+                * Create FTP data connection to client:
+                */
+               err = sock_create(AF_INET, SOCK_STREAM, IPPROTO_IP, &data_sock);
+               if (err < 0) {
+                       Dprintk("sock create err: %d\n", err);
+                       req_err(req);
+                       ftp_send_async_message(req, CLOSE, 500);
+                       GOTO_ERR;
+               }
+                       
+               local_addr = inet_sk(req->sock->sk)->rcv_saddr;
+               addr.sin_family = AF_INET;
+               addr.sin_port = 0;
+               addr.sin_addr.s_addr = local_addr;
+               Dprintk("client address: (%d,%d,%d,%d).\n", 
+                       NIPQUAD(inet_sk(req->sock->sk)->daddr));
+
+               data_sock->sk->sk_reuse = 1;
+               sock_set_flag(data_sock->sk, SOCK_URGINLINE);
+               sock_reset_flag(data_sock->sk, SOCK_LINGER);
+
+               err = data_sock->ops->bind(data_sock,
+                               (struct sockaddr*)&addr, sizeof(addr));
+               tp = tcp_sk(data_sock->sk);
+               tp->nonagle = 2;
+               Dprintk("PASV bind() ret: %d.\n", err);
+               if (err < 0) {
+                       req_err(req);
+                       sock_release(data_sock);
+                       ftp_send_async_message(req, CLOSE, 500);
+                       GOTO_ERR;
+               }
+
+               tp->ack.pingpong = tux_ack_pingpong;
+
+               if (!tux_keepalive_timeout)
+                       tp->linger2 = 0;
+               else
+                       tp->linger2 = tux_keepalive_timeout * HZ;
+
+               err = data_sock->ops->listen(data_sock, 1);
+               Dprintk("PASV listen() ret: %d\n", err);
+               if (err) {
+                       req_err(req);
+                       sock_release(data_sock);
+                       ftp_send_async_message(req, CLOSE, 500);
+                       GOTO_ERR;
+               }
+               link_tux_data_socket(req, data_sock);
+
+               Dprintk("FTP PASV listen sock state: %d, sk state: %d\n",
+                       data_sock->state, data_sock->sk->sk_state);
+
+               str_len = sprintf(buf,
+                       "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n",
+                               NIPQUAD(local_addr),
+                               ntohs(inet_sk(data_sock->sk)->sport) / 256,
+                               ntohs(inet_sk(data_sock->sk)->sport) & 255 );
+               Dprintk("PASV mess: {%s}\n", buf);
+
+               add_tux_atom(req, ftp_accept_pasv);
+               add_tux_atom(req, ftp_flush_req);
+               __ftp_send_async_message(req, buf, 227, str_len);
+               break;
+       }
+
+       case FTP_COMM_PORT:
+       {
+               struct socket *data_sock;
+               struct sockaddr_in addr;
+               kernel_cap_t saved_cap;
+               u32 local_addr;
+               int err;
+
+               /*
+                * Create FTP data connection to client:
+                */
+               err = sock_create(AF_INET, SOCK_STREAM, IPPROTO_IP, &data_sock);
+               if (err < 0) {
+                       Dprintk("sock create err: %d\n", err);
+                       req_err(req);
+                       ftp_send_async_message(req, CLOSE, 500);
+                       GOTO_ERR;
+               }
+
+               local_addr = inet_sk(req->sock->sk)->rcv_saddr;
+               addr.sin_family = AF_INET;
+               addr.sin_port = htons(20);
+               addr.sin_addr.s_addr = local_addr;
+
+               Dprintk("data socket address: (%d,%d,%d,%d).\n",
+                       NIPQUAD(local_addr));
+
+               data_sock->sk->sk_reuse = 1;
+               sock_set_flag(data_sock->sk, SOCK_URGINLINE);
+               sock_reset_flag(data_sock->sk, SOCK_LINGER);
+
+               saved_cap = current->cap_effective;
+               cap_raise (current->cap_effective, CAP_NET_BIND_SERVICE);
+               err = data_sock->ops->bind(data_sock,
+                               (struct sockaddr*)&addr, sizeof(addr));
+               current->cap_effective = saved_cap;
+
+               Dprintk("ACTIVE bind() ret: %d.\n", err);
+               if (err) {
+                       sock_release(data_sock);
+                       req_err(req);
+                       ftp_send_async_message(req, CLOSE, 500);
+                       GOTO_ERR;
+               }
+               tcp_sk(data_sock->sk)->nonagle = 2;
+
+               link_tux_data_socket(req, data_sock);
+
+               addr.sin_family = AF_INET;
+               addr.sin_port = htons(req->ftp_user_port);
+               addr.sin_addr.s_addr = htonl(req->ftp_user_addr);
+
+               err = data_sock->ops->connect(data_sock, (struct sockaddr *) &addr, sizeof(addr), O_RDWR|O_NONBLOCK);
+               if (err && (err != -EINPROGRESS)) {
+                       Dprintk("connect error: %d\n", err);
+                       zap_data_socket(req);
+                       req_err(req);
+                       ftp_send_async_message(req, CLOSE, 500);
+                       GOTO_ERR;
+               }
+               Dprintk("FTP data sock state: %d, sk state: %d\n", data_sock->state, data_sock->sk->sk_state);
+               ftp_send_async_message(req, PORT_OK, 200);
+               break;
+       }
+
+       case FTP_COMM_USER:
+       {
+               if (!strcmp(req->username, "ftp")
+                        || !strcmp(req->username, "FTP")
+                        || !strcmp(req->username, "anonymous")
+                        || !strcmp(req->username, "ANONYMOUS")) {
+                       unsigned int str_len;
+                       char login_ok [200];
+
+                       if (!tux_ftp_login_message) {
+                               ftp_send_async_message(req, LOGIN_OK_PASS, 230);
+                               break;
+                       }
+                       update_bandwidth(req, 0); /* get current bandwidth */
+                       if (nr_requests_used() == 1)
+                               str_len = sprintf(login_ok, LOGIN_OK_ONE,
+                                       tux_max_connect, ftp_bandwidth);
+                       else
+                               str_len = sprintf(login_ok, LOGIN_OK,
+                                       nr_requests_used(), tux_max_connect, ftp_bandwidth);
+                       __ftp_send_async_message(req, login_ok, 200, str_len);
+               } else {
+                       clear_keepalive(req);
+                       ftp_send_async_message(req, LOGIN_FORBIDDEN, 530);
+               }
+               break;
+       }
+       case FTP_COMM_PASS:
+       {
+               ftp_send_async_message(req, LOGIN_OK_PASS, 230);
+               break;
+       }
+       case FTP_COMM_SITE:
+       {
+               ftp_send_async_message(req, SITE, 214);
+               break;
+       }
+       case FTP_COMM_SYST:
+       {
+               ftp_send_async_message(req, LINUX_SYST, 200);
+               break;
+       }
+       case FTP_COMM_TYPE:
+       {
+               ftp_send_async_message(req, TYPE_OK, 200);
+               break;
+       }
+#define EXTRA_FEATURES "211-Extensions supported:\r\n SIZE\r\n MDTM\r\n211 End\r\n"
+
+       case FTP_COMM_FEAT:
+       {
+               ftp_send_async_message(req, EXTRA_FEATURES, 211);
+               break;
+       }
+       case FTP_COMM_HELP:
+       case FTP_COMM_CLNT:
+       case FTP_COMM_NOOP:
+       {
+               ftp_send_async_message(req, COMMAND_OK, 200);
+               break;
+       }
+       case FTP_COMM_REST:
+       {
+               ftp_send_async_message(req, REST_OK, 200);
+               break;
+       }
+       case FTP_COMM_QUIT:
+       {
+               clear_keepalive(req);
+               ftp_send_async_message(req, BYE, 200);
+               break;
+       }
+
+       default:
+       {
+               req->keep_alive = 1;
+               ftp_send_async_message(req, CLOSE, 500);
+               break;
+       }
+       }
+       return;
+error:
+       Dprintk("rejecting FTP session!\n");
+       return;
+}
+
+
+static void ftp_timeout (tux_req_t *req, int cachemiss)
+{
+       Dprintk("called ftp_timeout(%p)\n", req);
+       if (req->error != TUX_ERROR_CONN_TIMEOUT)
+               TUX_BUG();
+       ftp_send_async_message(req, CLOSE_TIMEOUT, 421);
+}
+
+static void ftp_close (tux_req_t *req, int cachemiss)
+{
+       Dprintk("called ftp_close(%p)\n", req);
+       ftp_send_async_message(req, CLOSE, 500);
+}
+
+static void ftp_pre_log (tux_req_t *req)
+{
+       if (tux_ftp_log_retr_only && (req->ftp_command != FTP_COMM_RETR))
+               req->status = 0;
+       else
+               req->status = req->ftp_command;
+}
+
+tux_proto_t tux_proto_ftp = {
+       defer_accept: 0,
+       can_redirect: 0,
+       got_request: ftp_got_request,
+       parse_message: parse_ftp_message,
+       illegal_request: ftp_close,
+       request_timeout: ftp_timeout,
+       pre_log: ftp_pre_log,
+       check_req_err: ftp_check_req_err,
+       print_dir_line: ftp_print_dir_line,
+       name: "ftp",
+};
+
diff --git a/net/tux/proto_http.c b/net/tux/proto_http.c
new file mode 100644 (file)
index 0000000..192dd4f
--- /dev/null
@@ -0,0 +1,2199 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * proto_http.c: HTTP application protocol support
+ *
+ * Right now we detect simple GET headers, anything more
+ * subtle gets redirected to secondary server port.
+ */
+
+#include <net/tux.h>
+#include "parser.h"
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+/* 
+ * Parse the HTTP message and put results into the request structure.
+ * CISAPI extensions do not see the actual message buffer.
+ *
+ * Any perceived irregularity is honored with a redirect to the
+ * secondary server - which in most cases should be Apache. So
+ * if TUX gets confused by some strange request we fall back
+ * to Apache to be RFC-correct.
+ *
+ * The parser is 'optimistic', ie. it's optimized for the case where
+ * the whole message is available and correct. The parser is also
+ * supposed to be 'robust', ie. it can be called multiple times with
+ * an incomplete message, as new packets arrive.
+ */
+
+static inline int TOHEX (char c)
+{
+       switch (c) {
+               case '0' ... '9': c -= '0'; break;
+               case 'a' ... 'f': c -= 'a'-10; break;
+               case 'A' ... 'F': c -= 'A'-10; break;
+       default:
+               c = -1;
+       }
+       return c;
+}
+
+/*
+ * This function determines whether the client supports
+ * gzip-type content-encoding.
+ */
+static int may_gzip (const char *str, int len)
+{
+       const char *tmp, *curr;
+       int i;
+
+       if (len <= 4)
+               return 0;
+       tmp = str;
+       for (i = 0; i <= len-6; i++) {
+               Dprintk("gzip-checking: {%s}\n", tmp);
+               if (memcmp(tmp, " gzip", 5)) {
+                       tmp++;
+                       continue;
+               }
+               curr = tmp + 5;
+
+               if (*curr == ',' || *curr == '\r')
+                       return 1;
+               if (memcmp(curr, ";q=", 3))
+                       return 0;
+               curr += 3;
+               /*
+                * Every qvalue except explicitly zero is accepted.
+                * Zero values are "q=0.0", "q=0.00", "q=0.000".
+                * Parsing is optimized.
+                */
+               if (*curr == '0') {
+                       curr += 2;
+                       if (*curr == '0') {
+                               curr++;
+                               if (*curr == ' ' || *curr == '\r')
+                                       return 0;
+                               if (*curr == '0') {
+                                       curr++;
+                                       if (*curr == ' ' || *curr == '\r')
+                                               return 0;
+                                       if (*curr == '0') {
+                                               curr++;
+                                               if (*curr == ' ' ||
+                                                               *curr == '\r')
+                                                       return 0;
+                                       }
+                               }
+                       }
+               }
+               return 1;
+       }
+       return 0;
+}
+
+/*
+ * This function strips off 'strip_host_tail' number of hostname
+ * components from the tail of the hostname.
+ *
+ * Eg. with a value of '1', the "somesite.hosting.com" hostname gets
+ * transformed into the "somesite" string.
+ */
+static void strip_hostname(tux_req_t *req)
+{
+       int strip = strip_host_tail;
+       int left = req->host_len;
+       int component = 0;
+
+       if (!strip || !left)
+               return;
+
+       while (--left) {
+               if (req->host[left] != '.')
+                       continue;
+               if (++component == strip)
+                       break;
+       }
+       if (!left)
+               return;
+       req->host[left] = 0;
+       req->host_len = left;
+}
+
+static void http_lookup_vhost (tux_req_t *req, int cachemiss);
+static void http_process_message (tux_req_t *req, int cachemiss);
+
+int parse_http_message (tux_req_t *req, const int total_len)
+{
+       int hexhex = 0, hex_val_0 = 0, hex_val_1 = 0;
+       const char *curr, *uri, *message;
+       unsigned int objectname_len, left;
+       unsigned int have_r = 0;
+       char c;
+
+       left = total_len;
+       message = req->headers;
+       Dprintk("parsing request:\n---\n%s\n---\n", message);
+/*
+ * RFC 2616, 5.1:
+ *
+ *      Request-Line   = Method SP Request-URI SP HTTP-Version CRLF
+ */
+
+       if (!total_len)
+               TUX_BUG();
+
+       curr = message;
+
+#define GOTO_INCOMPLETE do { Dprintk("incomplete at %s:%d.\n", __FILE__, __LINE__); goto incomplete_message; } while (0)
+#define GOTO_REDIR do { TDprintk("redirect secondary at %s:%d.\n", __FILE__, __LINE__); goto error; } while (0)
+
+#define PRINT_MESSAGE_LEFT \
+    Dprintk("message left (%d) at %s:%d:\n--->{%s}<---\n", left, __FILE__, __LINE__, curr)
+
+       switch (*curr) {
+               case 'G':
+                       if (PARSE_METHOD(req,curr,GET,left))
+                               break;
+                       GOTO_REDIR;
+
+               case 'H':
+                       if (PARSE_METHOD(req,curr,HEAD,left))
+                               break;
+                       GOTO_REDIR;
+
+               case 'P':
+                       if (PARSE_METHOD(req,curr,POST,left))
+                               break;
+                       if (PARSE_METHOD(req,curr,PUT,left))
+                               break;
+                       GOTO_REDIR;
+
+               default:
+                       GOTO_REDIR;
+       }
+
+       req->method_str = message;
+       req->method_len = curr-message-1;
+
+       Dprintk("got method %d\n", req->method);
+
+       PRINT_MESSAGE_LEFT;
+
+       /*
+        * Ok, we got one of the methods we can handle, parse
+        * the URI:
+        */
+
+       {
+               // Do not allow leading "../" and intermediate "/../"
+               int dotdot = 1;
+               char *tmp = req->objectname;
+               int slashcheck = 1;
+
+               req->uri_str = uri = curr;
+
+               for (;;) {
+                       c = get_c(curr,left);
+                       if (slashcheck) {
+                               if (c == '/')
+                                       continue;
+                               slashcheck = 0;
+                       }
+
+                       PRINT_MESSAGE_LEFT;
+                       if (c == ' ' || ((c == '?') && (tux_ignore_query != 1)) || c == '\r' || c == '\n')
+                               break;
+                       if (c == '#')
+                               GOTO_REDIR;
+
+                       Dprintk("hexhex: %d.\n", hexhex);
+                       /*
+                        * First handle HEX HEX encoding
+                        */
+                       switch (hexhex) {
+                               case 0:
+                                       if (c == '%') {
+                                               hexhex = 1;
+                                               goto continue_parsing;
+                                       }
+                                       break;
+                               case 1:
+                                       hex_val_0 = TOHEX(c);
+                                       if (hex_val_0 < 0)
+                                               GOTO_REDIR;
+                                       hexhex = 2;
+                                       goto continue_parsing;
+                               case 2:
+                                       hex_val_1 = TOHEX(c);
+                                       if (hex_val_1 < 0)
+                                               GOTO_REDIR;
+                                       c = (hex_val_0 << 4) | hex_val_1;
+                                       if (!c)
+                                               GOTO_REDIR;
+                                       hexhex = 0;
+                                       break;
+                               default:
+                                       TUX_BUG();
+                       }
+                       if (hexhex)
+                               TUX_BUG();
+
+                       switch (dotdot) {
+                               case 0:
+                                       break;
+                               case 1:
+                                       if (c == '.')
+                                               dotdot = 2;
+                                       else
+                                               dotdot = 0;
+                                       break;
+                               case 2:
+                                       if (c == '.')
+                                               dotdot = 3;
+                                       else
+                                               dotdot = 0;
+                                       break;
+                               case 3:
+                                       if (c == '/')
+                                               GOTO_REDIR;
+                                       else
+                                               dotdot = 0;
+                                       break;
+                               default:
+                                       TUX_BUG();
+                       }
+                       if (!dotdot && (c == '/'))
+                               dotdot = 1;
+
+                       *(tmp++) = c;
+continue_parsing:
+                       if (curr - uri >= MAX_OBJECTNAME_LEN)
+                               GOTO_REDIR;
+               }
+               PRINT_MESSAGE_LEFT;
+               *tmp = 0;
+
+               // handle trailing "/.."
+               if (dotdot == 3)
+                       GOTO_REDIR;
+
+               objectname_len = tmp - req->objectname;
+               req->objectname_len = objectname_len;
+       }
+       Dprintk("got filename %s (%d)\n", req->objectname, req->objectname_len);
+
+       PRINT_MESSAGE_LEFT;
+
+       /*
+        * Parse optional query string. Copy until end-of-string or space.
+        */
+       if (c == '?') {
+               int query_len;
+               const char *query;
+
+               req->query_str = query = curr;
+
+               for (;;) {
+                       c = get_c(curr,left);
+                       if (c == ' ')
+                               break;
+                       if (c == '#')
+                               GOTO_REDIR;
+               }
+               if (unlikely(tux_ignore_query == 2))
+                       req->query_str = NULL;
+               else {
+                       query_len = curr-query-1;
+                       req->query_len = query_len;
+               }
+       }
+       if (req->query_len)
+               Dprintk("got query string %s (%d)\n", req->query_str, req->query_len);
+       req->uri_len = curr-uri-1;
+       if (!req->uri_len)
+               GOTO_REDIR;
+       Dprintk("got URI %s (%d)\n", req->uri_str, req->uri_len);
+
+       PRINT_MESSAGE_LEFT;
+       /*
+        * Parse the HTTP version field:
+        */
+       req->version_str = curr;
+       if (!PARSE_TOKEN(curr,"HTTP/1.",left))
+               GOTO_REDIR;
+
+       switch (get_c(curr,left)) {
+               case '0':
+                       req->version = HTTP_1_0;
+                       break;
+               case '1':
+                       req->version = HTTP_1_1;
+                       break;
+               default:
+                       GOTO_REDIR;
+       }
+       /*
+        * We default to keepalive in the HTTP/1.1 case and default
+        * to non-keepalive in the HTTP/1.0 case. If max_keepalives
+        * is 0 then we do no keepalives.
+        */
+       clear_keepalive(req);
+       if (tux_max_keepalives && (req->version == HTTP_1_1))
+               req->keep_alive = 1;
+       req->version_len = curr - req->version_str;
+
+       if (get_c(curr,left) != '\r')
+               GOTO_REDIR;
+       if (get_c(curr,left) != '\n')
+               GOTO_REDIR;
+
+       Dprintk("got version %d [%d]\n", req->version, req->version_len);
+       PRINT_MESSAGE_LEFT;
+
+       /*
+        * Now parse (optional) request header fields:
+        */
+       for (;;) {
+               char c;
+
+               c = get_c(curr,left);
+               switch (c) {
+               case '\r':
+                       if (have_r)
+                               GOTO_REDIR;
+                       have_r = 1;
+                       continue;
+               case '\n':
+                       if (!have_r)
+                               GOTO_REDIR;
+                       goto out;
+               default:
+                       if (have_r)
+                               GOTO_REDIR;
+               }
+
+#define PARSE_STR_FIELD(char,field,str,len)                            \
+       if (PARSE_TOKEN(curr,field,left)) {                             \
+               req->str = curr;                                        \
+               SKIP_LINE(curr,left);                                   \
+               req->len = curr - req->str - 2;                         \
+               Dprintk(char field "field: %s.\n", req->str);           \
+               break;                                                  \
+       }
+
+#define ALLOW_UNKNOWN_FIELDS 1
+#ifdef ALLOW_UNKNOWN_FIELDS
+# define UNKNOWN_FIELD { SKIP_LINE(curr,left); break; }
+#else
+# define UNKNOWN_FIELD GOTO_REDIR
+#endif
+
+               switch (c) {
+               case 'A':
+                       PARSE_STR_FIELD("A","ccept: ",
+                               accept_str,accept_len);
+                       if (PARSE_TOKEN(curr,"ccept-Encoding: ",left)) {
+                               const char *str = curr-1;
+
+                               req->accept_encoding_str = curr;
+                               SKIP_LINE(curr,left);
+                               req->accept_encoding_len = curr - req->accept_encoding_str - 2;
+                               Dprintk("Accept-Encoding field: {%s}.\n", str);
+
+                               if (tux_compression && may_gzip(str,curr-str)) {
+                                       Dprintk("client accepts gzip!.\n");
+                                       req->may_send_gzip = 1;
+                               }
+                               break;
+                       }
+                       PARSE_STR_FIELD("A","ccept-Charset: ",
+                               accept_charset_str,accept_charset_len);
+                       PARSE_STR_FIELD("A","ccept-Language: ",
+                               accept_language_str,accept_language_len);
+                       UNKNOWN_FIELD;
+
+               case 'C':
+                       if (PARSE_TOKEN(curr,"onnection: ",left)) {
+next_token:
+                       switch (get_c(curr,left)) {
+                       case 'K':
+                               if (!PARSE_TOKEN(curr,"eep-Alive",left))
+                                       GOTO_REDIR;
+                               if (tux_max_keepalives)
+                                       req->keep_alive = 1;
+                               break;
+
+                       case 'C':
+                       case 'c':
+                               if (!PARSE_TOKEN(curr,"lose",left))
+                                       GOTO_REDIR;
+                               clear_keepalive(req);
+                               break;
+
+                       case 'k':
+                               if (!PARSE_TOKEN(curr,"eep-alive",left))
+                                       GOTO_REDIR;
+                               if (tux_max_keepalives)
+                                       req->keep_alive = 1;
+                               break;
+                       case 'T':
+                               if (PARSE_TOKEN(curr,"E",left))
+                                       break;
+                               if (PARSE_TOKEN(curr,"railers",left))
+                                       break;
+                               if (PARSE_TOKEN(curr,"ransfer-Encoding",left))
+                                       break;
+                               GOTO_REDIR;
+                       case 'P':
+                               if (PARSE_TOKEN(curr,"roxy-Authenticate",left))
+                                       break;
+                               if (PARSE_TOKEN(curr,"roxy-Authorization",left))
+                                       break;
+                               GOTO_REDIR;
+                       case 'U':
+                               if (!PARSE_TOKEN(curr,"pgrade",left))
+                                       GOTO_REDIR;
+                               break;
+                       case ' ':
+                               PRINT_MESSAGE_LEFT;
+                               goto next_token;
+                       case ',':
+                               PRINT_MESSAGE_LEFT;
+                               goto next_token;
+                       default:
+                               GOTO_REDIR;
+                       }
+                       PRINT_MESSAGE_LEFT;
+                       if (*curr != '\r')
+                               goto next_token;
+                       // allow other tokens.
+                       SKIP_LINE(curr,left);
+                       break;
+                       }
+
+                       PARSE_STR_FIELD("C","ookie: ",
+                               cookies_str,cookies_len);
+                       PARSE_STR_FIELD("C","ontent-Type: ",
+                               content_type_str,content_type_len);
+
+                       if (PARSE_TOKEN(curr,"ontent-Length: ",left) ||
+                           PARSE_TOKEN(curr,"ontent-length: ",left)) {
+                               const char *tmp;
+                               req->contentlen_str = curr;
+                               SKIP_LINE(curr,left);
+                               req->contentlen_len = curr - req->contentlen_str - 2;
+                               if (req->contentlen_len) {
+                                       tmp = req->contentlen_str;
+                                       req->content_len = simple_strtoul(tmp, NULL, 10);
+                               }
+                               Dprintk("Content-Length field: %s [%d].\n", req->contentlen_str, req->contentlen_len);
+                               Dprintk("Content-Length value: %d.\n", req->content_len);
+                               break;
+                       }
+                       PARSE_STR_FIELD("C","ache-Control: ",
+                               cache_control_str,cache_control_len);
+                       UNKNOWN_FIELD;
+
+               case 'H':
+                       if (PARSE_TOKEN(curr,"ost: ",left)) {
+                               const char *tmp = curr;
+                               char *tmp2 = req->host;
+
+                               /*
+                                * canonize the hostname:
+                                *
+                                * 1) strip off preceding 'www.' variants,
+                                * 2) transform it to lowercase.
+                                * 3) strip trailing dots
+                                * 4) potentially strip off tail
+                                */
+                               
+#define is_w(n) ((curr[n] == 'w') || (curr[n] == 'W'))
+
+                               if ((left > 4) && is_w(0) && is_w(1) &&
+                                               is_w(2) && curr[3] == '.') {
+                                       curr += 4;
+                                       left -= 4;
+                                       tmp = curr;
+                               }
+                        
+                               COPY_LINE_TOLOWER(curr, tmp2, left, req->host+MAX_HOST_LEN-2);
+                               req->host_len = curr - tmp - 2;
+                               while (req->host[req->host_len] == '.') {
+                                       if (!req->host_len)
+                                               break;
+                                       req->host_len--;
+                               }
+                               req->host[req->host_len] = 0;
+                               if (strip_host_tail)
+                                       strip_hostname(req);
+                               Dprintk("Host field: %s [%d].\n", req->host, req->host_len);
+                               break;
+                       }
+                       UNKNOWN_FIELD;
+
+               case 'I':
+                       PARSE_STR_FIELD("I","f-None-Match: ",
+                               if_none_match_str,if_none_match_len);
+                       PARSE_STR_FIELD("I","f-Modified-Since: ",
+                               if_modified_since_str,if_modified_since_len);
+                       PARSE_STR_FIELD("I","f-Range: ",
+                               if_range_str,if_range_len);
+                       UNKNOWN_FIELD;
+
+               case 'N':
+                       PARSE_STR_FIELD("N","egotiate: ",
+                               negotiate_str,negotiate_len);
+                       UNKNOWN_FIELD;
+
+               case 'P':
+                       PARSE_STR_FIELD("P","ragma: ",
+                               pragma_str,pragma_len);
+                       UNKNOWN_FIELD;
+
+               case 'R':
+
+                       PARSE_STR_FIELD("R","eferer: ",
+                               referer_str,referer_len);
+                       if (!PARSE_TOKEN(curr,"ange: bytes=",left))
+                               UNKNOWN_FIELD;
+               {
+                       const char *tmp = curr;
+                       char *tmp2 = (char *)curr;
+                       unsigned int offset_start = 0, offset_end = 0;
+
+                       if (*tmp2 != '-')
+                               offset_start = simple_strtoul(tmp2, &tmp2, 10);
+                       if (*tmp2 == '-') {
+                               tmp2++;
+                               if (*tmp2 != '\r')
+                                       offset_end = simple_strtoul(tmp2, &tmp2, 10) +1;
+                       }
+                       curr = tmp2;
+                       left -= tmp2-tmp;
+
+                       req->offset_start = offset_start;
+                       req->offset_end = offset_end;
+
+                       SKIP_LINE(curr,left);
+                       Dprintk("Range field: %s [%d] (%d-%d).\n", tmp, curr-tmp, offset_start, offset_end);
+                       break;
+               }
+
+               case 'U':
+                       PARSE_STR_FIELD("U","ser-Agent: ",
+                               user_agent_str,user_agent_len);
+                       UNKNOWN_FIELD;
+
+               default:
+                       UNKNOWN_FIELD;
+               }
+               PRINT_MESSAGE_LEFT;
+       }
+out:
+       /*
+        * POST data.
+        */
+       if ((req->method == METHOD_POST) && req->content_len) {
+               PRINT_MESSAGE_LEFT;
+               if (curr + req->content_len > message + total_len)
+                       GOTO_INCOMPLETE;
+               req->post_data_str = curr;
+               req->post_data_len = req->content_len;
+               curr += req->content_len;
+               left -= req->content_len;
+               Dprintk("POST-ed data: {%s}\n", req->post_data_str);
+       }
+
+       switch (req->method) {
+               default:
+                       GOTO_REDIR;
+               case METHOD_GET:
+               case METHOD_HEAD:
+               case METHOD_POST:
+               case METHOD_PUT:
+                       ;
+       }
+
+#define TUX_SCHEME "http://"
+#define TUX_SCHEME_LEN (sizeof(TUX_SCHEME)-1)
+
+       if (!memcmp(req->objectname, TUX_SCHEME, TUX_SCHEME_LEN)) {
+
+               /* http://user:password@host:port/object */
+
+               const char *head, *tail, *end, *host, *port;
+               int host_len, objectname_len;
+
+               head = req->objectname + TUX_SCHEME_LEN;
+               end = req->objectname + req->objectname_len;
+
+               tail = memchr(head, '/', end - head);
+               if (!tail)
+                       GOTO_REDIR;
+               host = memchr(head, '@', tail - head);
+               if (!host)
+                       host = head;
+               else
+                       host++;
+               if (!*host)
+                       GOTO_REDIR;
+               port = memchr(host, ':', tail - host);
+               if (port)
+                       host_len = port - host;
+               else
+                       host_len = tail - host;
+               if (host_len >= MAX_HOST_LEN)
+                       GOTO_REDIR;
+               memcpy(req->host, host, host_len);
+               req->host_len = host_len;
+               req->host[host_len] = 0;
+
+               if (*tail != '/')
+                       TUX_BUG();
+
+               req->uri_str = tail;
+               req->uri_len = end - tail;
+
+               tail++;
+               while (*tail == '/')
+                       tail++;
+
+               objectname_len = end - tail;
+               memcpy(req->objectname, tail, objectname_len);
+               req->objectname_len = objectname_len;
+               req->objectname[objectname_len] = 0;
+       } else
+               if (req->uri_str[0] != '/')
+                       GOTO_REDIR;
+
+       if ((req->version == HTTP_1_1) && !req->host_len)
+               GOTO_REDIR;
+       if (req->objectname[0] == '/')
+               GOTO_REDIR;
+       /*
+        * Lets make sure nobody plays games with the host
+        * header in a virtual hosting environment:
+        */
+       if (req->virtual && req->host_len) {
+               if (memchr(req->host, '/', req->host_len))
+                       GOTO_REDIR;
+               if (req->host[0] == '.') {
+                       if (req->host_len == 1)
+                               GOTO_REDIR;
+                       if ((req->host_len == 2) && (req->host[0] == '.'))
+                               GOTO_REDIR;
+               }
+       }
+       /*
+        * From this point on the request is for the main TUX engine:
+        */
+       Dprintk("ok, request accepted.\n");
+
+       if (req->keep_alive) {
+               req->nr_keepalives++;
+               if (req->nr_keepalives == -1)
+                       req->nr_keepalives--;
+               INC_STAT(nr_keepalive_reqs);
+       } else
+               INC_STAT(nr_nonkeepalive_reqs);
+       INC_STAT(keepalive_hist[req->nr_keepalives]);
+
+       PRINT_MESSAGE_LEFT;
+       req->parsed_len = curr-message;
+       if (req->dentry)
+               TUX_BUG();
+       req->virtual = tux_virtual_server;
+       if (req->virtual)
+               add_tux_atom(req, http_lookup_vhost);
+       else {
+               req->docroot_dentry = dget(req->proto->main_docroot.dentry);
+               req->docroot_mnt = mntget(req->proto->main_docroot.mnt);
+               add_tux_atom(req, http_process_message);
+       }
+
+       return req->parsed_len;
+
+incomplete_message:
+       Dprintk("incomplete message!\n");
+       PRINT_MESSAGE_LEFT;
+
+       return 0;
+
+error:
+       if (total_len > 0)
+               req->parsed_len = total_len;
+       else
+               req->parsed_len = 0;
+       PRINT_MESSAGE_LEFT;
+       if (tux_TDprintk) {
+               TDprintk("redirecting message to secondary server.\n");
+               print_req(req);
+       }
+       return -1;
+}
+
+static int lookup_url (tux_req_t *req, const unsigned int flag)
+{
+       /*
+        * -1 : no previous checks made
+        *  0 : previous check failed, do not check farther, 
+        *  1 : previous check successed, check farther
+        */
+       int not_modified = -1;
+       int perm = 0, i;
+       struct dentry *dentry = NULL;
+       struct vfsmount *mnt = NULL;
+       struct inode *inode;
+       const char *filename;
+
+       /*
+        * Do not do any etag or last_modified header checking
+        * if both unset.
+        */
+       if (!tux_generate_etags && !tux_generate_last_mod)
+               not_modified = 0;
+
+repeat_lookup:
+       if (req->dentry)
+               TUX_BUG();
+
+       filename = req->objectname;
+       Dprintk("will look up {%s} (%d)\n", filename, req->objectname_len);
+       Dprintk("current->fsuid: %d, current->fsgid: %d, ngroups: %d\n",
+               current->fsuid, current->fsgid, current->group_info->ngroups);
+       for (i = 0; i < current->group_info->ngroups; i++)
+               Dprintk(".. group #%d: %d.\n", i, current->groups[i]);
+
+       dentry = tux_lookup(req, filename, flag, &mnt);
+
+#define INDEX "/index.html"
+
+       if (!dentry || IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO)
+                       goto cachemiss;
+
+               if (tux_http_dir_indexing && (req->lookup_dir == 1)) {
+                       // undo the index.html appending:
+                       req->objectname_len -= sizeof(INDEX)-1;
+                       req->objectname[req->objectname_len] = 0;
+                       req->lookup_dir = 2;
+                       goto repeat_lookup;
+               }
+               if (!req->lookup_404) {
+                       int len = strlen(tux_404_page);
+                       memcpy(req->objectname, tux_404_page, len);
+                       req->objectname[len] = 0;
+                       req->objectname_len = len;
+                       req->lookup_404 = 1;
+                       req->status = 404;
+                       goto repeat_lookup;
+               }
+               TDprintk("abort - lookup error.\n");
+               goto abort;
+       }
+
+       Dprintk("SUCCESS, looked up {%s} == dentry %p (inode %p, count %d.)\n", filename, dentry, dentry->d_inode, atomic_read(&dentry->d_count));
+       inode = dentry->d_inode;
+
+       /*
+        * At this point we have a real, non-negative dentry.
+        */
+       perm = tux_permission(inode);
+
+       if ((perm < 0) || (!S_ISDIR(dentry->d_inode->i_mode)
+                               && !S_ISREG(dentry->d_inode->i_mode))) {
+               Dprintk("FAILED trusted dentry %p permission %d.\n", dentry, perm);
+               req->status = 403;
+               goto abort;
+       }
+       if ((req->lookup_dir != 2) && S_ISDIR(dentry->d_inode->i_mode)) {
+               if (req->lookup_dir || (req->objectname_len +
+                                sizeof(INDEX) >= MAX_OBJECTNAME_LEN)) {
+                       req->status = 403;
+                       goto abort;
+               }
+               if (req->objectname_len && (req->objectname[req->objectname_len-1] != '/')) {
+                       dput(dentry);
+                       mntput(mnt);
+                       req->lookup_dir = 0;
+                       return 2;
+               }
+               memcpy(req->objectname + req->objectname_len,
+                                               INDEX, sizeof(INDEX));
+               req->objectname_len += sizeof(INDEX)-1;
+               req->lookup_dir = 1;
+               dput(dentry);
+               mntput(mnt);
+               mnt = NULL;
+               dentry = NULL;
+               goto repeat_lookup;
+       }
+       if (tux_max_object_size && (inode->i_size > tux_max_object_size)) {
+               TDprintk("too big object, %Ld bytes.\n", inode->i_size);
+               req->status = 403;
+               goto abort;
+       }
+       req->total_file_len = inode->i_size;
+       req->mtime = inode->i_mtime.tv_sec;
+
+       {
+               loff_t num = req->total_file_len;
+               int nr_digits = 0;
+               unsigned long modulo;
+               char * etag_p = req->etag;
+               char digits [30];
+
+               do {
+                       modulo = do_div(num, 10);
+                       digits[nr_digits++] = '0' + modulo;
+               } while (num);
+
+               req->lendigits = nr_digits;
+               req->etaglen = nr_digits;
+
+               while (nr_digits)
+                       *etag_p++ = digits[--nr_digits];
+
+               *etag_p++ = '-';
+               num = req->mtime;
+               nr_digits = 0;
+
+               do {
+                       digits[nr_digits++] = 'a' + num % 16;
+                               num /= 16;
+               } while (num);
+               req->etaglen += nr_digits+1;
+               while (nr_digits)
+                       *etag_p++ = digits[--nr_digits];
+               *etag_p = 0;
+       }
+
+       if ((req->if_none_match_len >= req->etaglen) && (abs(not_modified) == 1)) {
+
+               char * etag_p = req->etag;
+               const char * match_p = req->if_none_match_str;
+               int pos = req->etaglen - 1;
+               int matchpos = req->etaglen - 1;
+
+               do {
+                       while (etag_p[matchpos--] == match_p[pos--])
+                               if (matchpos < 0)
+                                       break;
+                       if (matchpos < 0)
+                               pos = req->if_none_match_len;
+                       else {
+                               if (match_p[pos+1] == ',')
+                                       pos += req->etaglen + 2;
+                               else
+                                       pos += req->etaglen-matchpos;
+                               matchpos = req->etaglen - 1;
+                       }
+               } while (pos < req->if_none_match_len);
+
+               if (matchpos < 0) {
+                       not_modified = 1;
+                       TDprintk("Etag matched.\n");
+               } else
+                       not_modified = 0; 
+       }
+
+        if ((req->if_modified_since_len >= 24) && (abs(not_modified) == 1)) {
+                if (parse_time(req->if_modified_since_str, req->if_modified_since_len) >= req->mtime ) {
+                       not_modified = 1;
+                        Dprintk("Last-Modified matched.\n");
+                } else
+                       not_modified = 0;
+        }
+
+       if (not_modified == 1) {
+               req->status = 304;
+               goto abort;
+       }
+
+       Dprintk("looked up cached dentry %p, (count %d.)\n", dentry, dentry ? atomic_read(&dentry->d_count) : -1 );
+
+       url_hist_hit(req->total_file_len);
+out:
+       install_req_dentry(req, dentry, mnt);
+       req->lookup_dir = 0;
+       return 0;
+
+cachemiss:
+       return 1;
+
+abort:
+       if (dentry) {
+               if (!IS_ERR(dentry))
+                       dput(dentry);
+               dentry = NULL;
+       }
+       if (mnt) {
+               if (!IS_ERR(mnt))
+                       mntput(mnt);
+               mnt = NULL;
+       }
+#if CONFIG_TUX_DEBUG
+       if (!not_modified) {
+               TDprintk("req %p has lookup errors!\n", req);
+               if (tux_TDprintk)
+                       print_req(req);
+       }
+#endif
+       req_err(req);
+       goto out;
+}
+
+int handle_gzip_req (tux_req_t *req, unsigned int flags)
+{
+       char *curr = req->objectname + req->objectname_len;
+       struct dentry *dentry;
+       struct vfsmount *mnt = NULL;
+       struct inode *inode, *orig_inode;
+       loff_t size, orig_size;
+
+       *curr++ = '.';
+       *curr++ = 'g';
+       *curr++ = 'z';
+       *curr++ = 0;
+       req->objectname_len += 3;
+
+       dentry = tux_lookup(req, req->objectname, flags, &mnt);
+
+       req->objectname_len -= 3;
+       req->objectname[req->objectname_len] = 0;
+
+       if (!dentry)
+               return 0;
+       if (IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO) {
+                       release_req_dentry(req);
+                       return 1;
+               }
+               return 0;
+       }
+
+       inode = dentry->d_inode;
+       size = inode->i_size;
+       orig_inode = req->dentry->d_inode;
+       orig_size = orig_inode->i_size;
+
+       if (!tux_permission(inode)
+                       && (size < orig_size)
+                       && (inode->i_mtime.tv_sec >= orig_inode->i_mtime.tv_sec)) {
+
+               release_req_dentry(req);
+               install_req_dentry(req, dentry, mnt);
+               req->total_file_len = req->output_len = size;
+               Dprintk("content WILL be gzipped!\n");
+               req->content_gzipped = 1;
+       } else {
+               dput(dentry);
+               mntput(mnt);
+       }
+
+       return 0;
+}
+
+static spinlock_t mimetypes_lock = SPIN_LOCK_UNLOCKED;
+
+static LIST_HEAD(mimetypes_head);
+
+static mimetype_t default_mimetype = { type: "text/plain", type_len: 10, expire_str: "", expire_str_len: 0 };
+
+#define MAX_MIMETYPE_LEN 128
+#define MAX_CACHE_CONTROL_AGE_LEN 30
+
+void add_mimetype (char *new_ext, char *new_type, char *new_expire)
+{
+       int type_len = strlen(new_type);
+       int ext_len = strlen(new_ext);
+       int expire_len = strlen(new_expire);
+       mimetype_t *mime;
+       char *ext, *type, *expire;
+
+        if (type_len > MAX_MIMETYPE_LEN)
+                type_len = MAX_MIMETYPE_LEN;
+        if (ext_len > MAX_URI_LEN)
+                ext_len = MAX_URI_LEN;
+        if (expire_len > MAX_CACHE_CONTROL_AGE_LEN)
+                expire_len = MAX_CACHE_CONTROL_AGE_LEN;
+
+       mime = tux_kmalloc(sizeof(*mime));
+       memset(mime, 0, sizeof(*mime));
+       ext = tux_kmalloc(ext_len + 1);
+       type = tux_kmalloc(type_len + 1);
+       expire = tux_kmalloc(expire_len + 1);
+
+       strncpy(ext, new_ext, ext_len);
+       strncpy(type, new_type, type_len);
+       strncpy(expire, new_expire, expire_len);
+       
+       // in case one of the above parameters was too long :
+
+       ext[ext_len] = '\0';
+       type[type_len] = '\0';
+       expire[expire_len] = '\0';
+
+       mime->ext = ext;
+       mime->ext_len = ext_len;
+
+       mime->type = type;
+       mime->type_len = type_len;
+
+       mime->expire_str = expire;
+       mime->expire_str_len = expire_len;
+
+       mime->special = NORMAL_MIME_TYPE;
+       if (!strcmp(type, "TUX/redirect"))
+               mime->special = MIME_TYPE_REDIRECT;
+       if (!strcmp(type, "TUX/CGI"))
+               mime->special = MIME_TYPE_CGI;
+       if (!strcmp(type, "TUX/module"))
+               mime->special = MIME_TYPE_MODULE;
+
+       spin_lock(&mimetypes_lock);
+       list_add(&mime->list, &mimetypes_head);
+       spin_unlock(&mimetypes_lock);
+}
+
+static inline int ext_matches (char *file, int len, char *ext, int extlen)
+{
+       int i;
+       char *tmp = file + len-1;
+       char *tmp2 = ext + extlen-1;
+
+       if (len < extlen)
+               return 0;
+
+       for (i = 0; i < extlen; i++) {
+               if (*tmp != *tmp2)
+                       return 0;
+               tmp--;
+               tmp2--;
+       }
+       return 1;
+}
+
+/*
+ * Overhead is not a problem, we cache the MIME type
+ * in the dentry.
+ */
+static mimetype_t * lookup_mimetype (tux_req_t *req)
+{
+       char *objectname = req->objectname;
+       int len = req->objectname_len;
+       mimetype_t *mime = NULL;
+       struct list_head *head, *tmp, *tmp1, *tmp2, *tmp3;
+
+       if (!memchr(objectname, '.', len))
+               goto out;
+
+       spin_lock(&mimetypes_lock);
+       head = &mimetypes_head;
+       tmp = head->next;
+
+       while (tmp != head) {
+               mime = list_entry(tmp, mimetype_t, list);
+               if (ext_matches(objectname, len, mime->ext, mime->ext_len)) {
+                       /*
+                        * Percolate often-used mimetypes up:
+                        */
+                       if (tmp->prev != &mimetypes_head) {
+                               tmp1 = tmp;
+                               tmp2 = tmp->prev;
+                               tmp3 = tmp->prev->prev;
+                               list_del(tmp1);
+                               list_del(tmp2);
+                               list_add(tmp, tmp3);
+                               list_add(tmp2, tmp);
+                       }
+                       break;
+               } else
+                       mime = NULL;
+               tmp = tmp->next;
+       }
+       spin_unlock(&mimetypes_lock);
+
+out:
+       if (!mime)
+               mime = &default_mimetype;
+       return mime;
+}
+
+void free_mimetypes (void)
+{
+       struct list_head *head, *tmp, *next;
+       mimetype_t *mime;
+
+       spin_lock(&mimetypes_lock);
+       head = &mimetypes_head;
+       tmp = head->next;
+
+       while (tmp != head) {
+               next = tmp->next;
+               mime = list_entry(tmp, mimetype_t, list);
+               list_del(tmp);
+
+               kfree(mime->ext);
+               mime->ext = NULL;
+               kfree(mime->type);
+               mime->type = NULL;
+               kfree(mime);
+
+               tmp = next;
+       }
+       spin_unlock(&mimetypes_lock);
+}
+
+/*
+ * Various constant HTTP responses:
+ */
+
+static const char forbidden[] =
+       "HTTP/1.1 403 Forbidden\r\n"
+       "Connection: Keep-Alive\r\n" \
+       "Content-Length: 24\r\n\r\n"
+       "<HTML> Forbidden </HTML>";
+
+static const char not_found[] =
+       "HTTP/1.1 404 Not Found\r\n"
+       "Connection: Keep-Alive\r\n" \
+       "Content-Length: 29\r\n\r\n"
+       "<HTML> Page Not Found </HTML>";
+
+#define NOTMODIFIED_1 \
+       "HTTP/1.1 304 Not Modified\r\n" \
+       "Connection: Keep-Alive\r\n" \
+       "Date: "
+
+#define NOTMODIFIED_1_LEN (sizeof(NOTMODIFIED_1) - 1)
+
+#define NOTMODIFIED_2 \
+       "\r\nETag: \""
+
+#define NOTMODIFIED_2_LEN (sizeof(NOTMODIFIED_2) - 1)
+
+#define NOTMODIFIED_3 \
+       "\"\r\n\r\n"
+
+#define NOTMODIFIED_3_LEN (sizeof(NOTMODIFIED_3) - 1)
+
+#define REDIRECT_1 \
+       "HTTP/1.1 301 Moved Permanently\r\n" \
+       "Location: http://"
+
+#define REDIRECT_1_LEN (sizeof(REDIRECT_1) - 1)
+
+#define REDIRECT_2 \
+       "/\r\nContent-Length: 36\r\n" \
+       "Connection: Keep-Alive\r\n" \
+       "Content-Type: text/html\r\n\r\n" \
+       "<HTML> 301 Moved Permanently </HTML>"
+
+#define REDIRECT_2_LEN (sizeof(REDIRECT_2) - 1)
+
+void send_async_err_forbidden (tux_req_t *req)
+{
+       send_async_message(req, forbidden, 403, 1);
+}
+
+void send_async_err_not_found (tux_req_t *req)
+{
+       send_async_message(req, not_found, 404, 1);
+}
+
+static void send_ret_notmodified (tux_req_t *req)
+{
+       char *buf;
+       int size;
+
+       size = NOTMODIFIED_1_LEN + DATE_LEN - 1 + NOTMODIFIED_2_LEN + req->etaglen + NOTMODIFIED_3_LEN;
+       buf = get_abuf(req, size); 
+       memcpy(buf, NOTMODIFIED_1, NOTMODIFIED_1_LEN);
+       buf += NOTMODIFIED_1_LEN;
+       memcpy(buf, tux_date, DATE_LEN-1);
+       buf += DATE_LEN-1; 
+       memcpy(buf, NOTMODIFIED_2, NOTMODIFIED_2_LEN);
+       buf += NOTMODIFIED_2_LEN;
+       memcpy(buf, &req->etag, req->etaglen);
+       buf += req->etaglen;
+       memcpy(buf, NOTMODIFIED_3, NOTMODIFIED_3_LEN);
+       buf += NOTMODIFIED_3_LEN;
+
+       req->status = 304;
+       send_abuf(req, size, MSG_DONTWAIT);
+       add_req_to_workqueue(req);
+}
+
+static void send_ret_redirect (tux_req_t *req, int cachemiss)
+{
+       char *buf;
+       unsigned int size;
+       unsigned int uts_len = 0;
+
+       size = REDIRECT_1_LEN;
+       if (req->host_len)
+               size += req->host_len;
+       else {
+               down_read(&uts_sem);
+               uts_len = strlen(system_utsname.nodename);
+               size += uts_len;
+       }
+       if (req->objectname[0] != '/')
+               size++;
+       size += req->objectname_len;
+       size += REDIRECT_2_LEN;
+
+       if (size > PAGE_SIZE) {
+               req->error = TUX_ERROR_CONN_CLOSE;
+               zap_request(req, cachemiss);
+               return;
+       }
+
+       buf = get_abuf(req, size);
+
+       memcpy(buf, REDIRECT_1, REDIRECT_1_LEN);
+       buf += REDIRECT_1_LEN;
+
+       Dprintk("req %p, host: %s, host_len: %d.\n", req, req->host, req->host_len);
+       if (req->host_len) {
+               memcpy(buf, req->host, req->host_len);
+               buf += req->host_len;
+       } else {
+               memcpy(buf, system_utsname.nodename, uts_len);
+               up_read(&uts_sem);
+               buf += uts_len;
+       }
+       if (req->objectname[0] != '/') {
+               buf[0] = '/';
+               buf++;
+       }
+
+       memcpy(buf, req->objectname, req->objectname_len);
+       buf += req->objectname_len;
+
+       memcpy(buf, REDIRECT_2, REDIRECT_2_LEN);
+       buf += REDIRECT_2_LEN;
+
+       req->status = 301;
+       send_abuf(req, size, MSG_DONTWAIT);
+       add_req_to_workqueue(req);
+}
+
+static void http_got_request (tux_req_t *req)
+{
+       req->host[0] = 0;
+       req->host_len = 0;
+       add_tux_atom(req, parse_request);
+       add_req_to_workqueue(req);
+}
+
+
+tux_attribute_t * lookup_tux_attribute (tux_req_t *req)
+{
+       tux_attribute_t *attr;
+       struct inode *inode;
+       mimetype_t *mime;
+
+       attr = tux_kmalloc(sizeof(*attr));
+       memset(attr, 0, sizeof(*attr));
+
+       mime = lookup_mimetype(req);
+
+       inode = req->dentry->d_inode;
+       if (!inode->i_uid && !inode->i_gid) {
+               if (mime->special == MIME_TYPE_MODULE) {
+                       attr->tcapi = lookup_tuxmodule(req->objectname);
+                       if (!attr->tcapi) {
+                               req_err(req);
+                               mime = &default_mimetype;
+                       }
+               }
+       } else {
+               if (mime->special && (mime->special != MIME_TYPE_REDIRECT))
+                       mime = &default_mimetype;
+       }
+       attr->mime = mime;
+
+       return attr;
+}
+
+static void handle_range(tux_req_t *req)
+{
+       if (req->if_range_len) {
+               time_t range_time;
+
+               range_time = parse_time(req->if_range_str, req->if_range_len);
+
+               /*
+                * If the file is newer then we send the whole file.
+                */
+               if (range_time < req->mtime )
+                       goto out_no_range;
+       }
+       /* if no offset_end was specified then default to 'end of file': */
+       if (!req->offset_end)
+               req->offset_end = req->total_file_len;
+       /*
+        * Sanity checks:
+        *
+        *  - is the range between 0...file_len-1 ?
+        *  - is offset_end after offset_start?
+        *
+        * (note that offset_end is higher by 1)
+        */
+       if ((req->offset_end > req->total_file_len) ||
+                       (req->offset_start >= req->total_file_len) ||
+                       (req->offset_end <= req->offset_start))
+               goto out_no_range;
+       /*
+        * If the range is 0...file_len-1 then send the whole file:
+        */
+       if (!req->offset_start && (req->offset_end == req->total_file_len))
+               goto out_no_range;
+
+       /* ok, the range is valid, use it: */
+
+       req->output_len = req->offset_end - req->offset_start;
+       req->in_file.f_pos = req->offset_start;
+       return;
+
+out_no_range:
+       req->offset_start = 0;
+       req->offset_end = 0;
+}
+
+static void http_pre_header (tux_req_t *req, int push);
+static void http_post_header (tux_req_t *req, int cachemiss);
+static void http_send_body (tux_req_t *req, int cachemiss);
+
+#define DIRLIST_HEAD_1 "\
+<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\
+<HTML><HEAD><TITLE>Index of %s</TITLE></HEAD><BODY>\
+<H1>Index of %s </H1><PRE><HR>\n%s"
+
+#define DIRLIST_HEAD_2 "\
+<IMG SRC=\"/icons/back.gif\"ALT=\"[DIR]\"> <A HREF=\"../\">Parent Directory</A>\n"
+
+#define DIRLIST_HEAD_SIZE (sizeof(DIRLIST_HEAD_1) + sizeof(DIRLIST_HEAD_2))
+
+static void http_dirlist_head (tux_req_t *req, int cachemiss)
+{
+       char *buf1, *buf2, *path;
+       int len;
+
+       buf1 = (char *)__get_free_page(GFP_KERNEL);
+       buf2 = (char *)__get_free_page(GFP_KERNEL);
+       if (!buf1 || !buf2)
+               goto out;
+       path = tux_print_path(req, req->dentry, req->mnt, buf1, PAGE_SIZE);
+       if (path[0] == '/' && path[1] == '/' && !path[3])
+               path = "/";
+       if (2*strlen(path) + DIRLIST_HEAD_SIZE >= PAGE_SIZE)
+               goto out;
+       len = sprintf(buf2, DIRLIST_HEAD_1, path, path, req->dentry == req->docroot_dentry ? "" : DIRLIST_HEAD_2);
+       __send_async_message(req, buf2, 200, len, 0);
+
+out:
+       if (buf1)
+               free_page((unsigned long)buf1);
+       if (buf2)
+               free_page((unsigned long)buf2);
+}
+
+#define DIRLIST_TAIL "\
+</PRE><HR><ADDRESS><IMG SRC=\"/icons/tuxlogo.gif\"ALIGN=\"MIDDLE\"ALT=\"[TUX]\">Powered by Linux/TUX 3.0</ADDRESS>\n</BODY></HTML>"
+
+static void http_dirlist_tail (tux_req_t *req, int cachemiss)
+{
+       __send_async_message(req, DIRLIST_TAIL, 200, sizeof(DIRLIST_TAIL)-1, 1);
+}
+
+static void http_dirlist (tux_req_t *req, int cachemiss)
+{
+       int head = (req->method == METHOD_HEAD);
+
+       req->lookup_dir = 3;
+       clear_keepalive(req);
+       if (!head) {
+               add_tux_atom(req, http_dirlist_tail);
+               add_tux_atom(req, list_directory);
+               add_tux_atom(req, http_dirlist_head);
+       }
+       http_pre_header(req, head);
+       add_req_to_workqueue(req);
+}
+
+static char *host_path_hash(tux_req_t *req, char *tmp)
+{
+       if (req->host_len < 2)
+               return NULL;
+
+       switch (mass_hosting_hash) {
+               default:
+               case 0:
+                       return req->host;
+               case 1:
+
+                       // www.ABCDEFG.com => A/ABCDEFG.com
+
+                       tmp[0] = req->host[0];
+                       tmp[1] = '/';
+                       memcpy(tmp + 2, req->host, req->host_len);
+                       tmp[req->host_len + 2] = 0;
+
+                       return tmp;
+               case 2:
+                       // www.ABCDEFG.com => A/AB/ABCDEFG.com
+
+                       tmp[0] = req->host[0];
+                       tmp[1] = '/';
+                       tmp[2] = req->host[0];
+                       tmp[3] = req->host[1];
+                       tmp[4] = '/';
+                       memcpy(tmp + 5, req->host, req->host_len);
+                       tmp[req->host_len + 5] = 0;
+
+                       return tmp;
+               case 3:
+                       // www.ABCDEFG.com => A/AB/ABC/ABCDEFG.com
+
+                       tmp[0] = req->host[0];
+                       tmp[1] = '/';
+                       tmp[2] = req->host[0];
+                       tmp[3] = req->host[1];
+                       tmp[4] = '/';
+                       tmp[5] = req->host[0];
+                       tmp[6] = req->host[1];
+                       tmp[7] = req->host[2];
+                       tmp[8] = '/';
+                       memcpy(tmp + 9, req->host, req->host_len);
+                       tmp[req->host_len + 9] = 0;
+
+                       return tmp;
+       }
+}
+
+static struct dentry * vhost_lookup (tux_req_t *req, struct nameidata* base, struct vfsmount **mnt)
+{
+       struct dentry *dentry = NULL;
+       // 255.255.255.255
+       char ip [3+1+3+1+3+1+3 + 2];
+
+       if (req->virtual >= TUX_VHOST_IP) {
+               sprintf(ip, "%d.%d.%d.%d",
+                               NIPQUAD(inet_sk(req->sock->sk)->rcv_saddr));
+               dentry = __tux_lookup (req, ip, base, mnt);
+               if (!dentry || IS_ERR(dentry)) {
+                       if (PTR_ERR(dentry) == -EWOULDBLOCKIO)
+                               return dentry;
+                       base->dentry = dget(req->proto->main_docroot.dentry);
+                       base->mnt = mntget(req->proto->main_docroot.mnt);
+                       goto lookup_default;
+               }
+               if (req->virtual == TUX_VHOST_IP)
+                       goto done;
+
+               // fall through in mixed mode:
+       }
+
+       if (!req->host_len) {
+lookup_default:
+               *mnt = NULL;
+               dentry = __tux_lookup (req, tux_default_vhost, base, mnt);
+       } else {
+               char tmp [MAX_HOST_LEN*2];
+               char *host_path;
+
+               host_path = host_path_hash(req, tmp);
+               Dprintk("host path hash returned: {%s}\n", host_path);
+
+               dentry = NULL;
+               if (host_path) {
+                       *mnt = NULL;
+                       dentry = __tux_lookup (req, host_path, base, mnt);
+               }
+               if (!dentry || IS_ERR(dentry)) {
+                       if (PTR_ERR(dentry) == -EWOULDBLOCKIO)
+                               return dentry;
+                       base->dentry = dget(req->proto->main_docroot.dentry);
+                       base->mnt = mntget(req->proto->main_docroot.mnt);
+                       if (req->virtual >= TUX_VHOST_IP) {
+                               *mnt = NULL;
+                               dentry = __tux_lookup (req, ip, base, mnt);
+                               if (!dentry || IS_ERR(dentry)) {
+                                       if (PTR_ERR(dentry) == -EWOULDBLOCKIO)
+                                               return dentry;
+                                       base->dentry = dget(req->proto->main_docroot.dentry);
+                                       base->mnt = mntget(req->proto->main_docroot.mnt);
+                               }
+                       }
+                       goto lookup_default;
+               }
+       }
+done:
+       return dentry;
+}
+
+static void http_lookup_vhost (tux_req_t *req, int cachemiss)
+{
+       struct dentry *dentry;
+       struct nameidata base;
+       struct vfsmount *mnt = NULL;
+       unsigned int flag = cachemiss ? 0 : LOOKUP_ATOMIC;
+       
+       Dprintk("http_lookup_vhost(%p, %d, virtual: %d, host: %s (%d).)\n", req, flag, req->virtual, req->host, req->host_len);
+
+       base.flags = LOOKUP_FOLLOW|flag;
+       base.last_type = LAST_ROOT;
+       base.dentry = dget(req->proto->main_docroot.dentry);
+       base.mnt = mntget(req->proto->main_docroot.mnt);
+
+       dentry = vhost_lookup(req, &base, &mnt);
+
+       Dprintk("looked up dentry %p.\n", dentry);
+
+       if (dentry && !IS_ERR(dentry) && !dentry->d_inode)
+               TUX_BUG();
+
+       if (!dentry || IS_ERR(dentry)) {
+               if (PTR_ERR(dentry) == -EWOULDBLOCKIO) {
+                       add_tux_atom(req, http_lookup_vhost);
+                       queue_cachemiss(req);
+                       return;
+               }
+               goto abort;
+       }
+
+       req->docroot_dentry = dentry;
+       req->docroot_mnt = mnt;
+
+       add_tux_atom(req, http_process_message);
+       add_req_to_workqueue(req);
+       return;
+abort:
+       if (dentry) {
+               if (!IS_ERR(dentry))
+                       dput(dentry);
+               dentry = NULL;
+       }
+       if (mnt) {
+               if (!IS_ERR(mnt))
+                       mntput(mnt);
+               mnt = NULL;
+       }
+       req_err(req);
+       add_req_to_workqueue(req);
+}
+
+static void http_process_message (tux_req_t *req, int cachemiss)
+{
+       tux_attribute_t *attr;
+       int missed;
+       unsigned int lookup_flag = cachemiss ? 0 : LOOKUP_ATOMIC;
+
+       Dprintk("handling req %p, cachemiss: %d.\n", req, cachemiss);
+
+       /*
+        * URL redirection support - redirect all valid requests
+        * to the first userspace module.
+        */
+       if (tux_all_userspace) {
+               tcapi_template_t *tcapi = get_first_usermodule();
+               if (tcapi) {
+                       req->usermode = 1;
+                       req->usermodule_idx = tcapi->userspace_id;
+                       goto usermode;
+               }
+       }
+       missed = lookup_url(req, lookup_flag);
+       if (missed == 2) {
+               if (req->query_str) {
+                       req->error = TUX_ERROR_REDIRECT;
+                       goto error;
+               }
+               send_ret_redirect(req, cachemiss);
+               return;
+       }
+       if (req->error)
+               goto error;
+       if (missed) {
+cachemiss:
+               if (cachemiss)
+                       TUX_BUG();
+               Dprintk("uncached request.\n");
+               INC_STAT(static_lookup_cachemisses);
+               if (req->dentry)
+                       TUX_BUG();
+               add_tux_atom(req, http_process_message);
+               queue_cachemiss(req);
+               return;
+       }
+       /*
+        * HTML directory indexing.
+        */
+       if (S_ISDIR(req->dentry->d_inode->i_mode))
+               return http_dirlist(req, cachemiss);
+       if (!S_ISREG(req->dentry->d_inode->i_mode))
+               TUX_BUG();
+
+
+       attr = req->dentry->d_extra_attributes;
+       if (!attr) {
+               attr = lookup_tux_attribute(req);
+               if (!attr)
+                       TUX_BUG();
+               req->dentry->d_extra_attributes = attr;
+       }
+       if (attr->mime)
+               Dprintk("using MIME type %s:%s, %d.\n", attr->mime->type, attr->mime->ext, attr->mime->special);
+       if (attr->tcapi) {
+               req->usermode = 1;
+               req->usermodule_idx = attr->tcapi->userspace_id;
+               if (req->module_dentry)
+                       TUX_BUG();
+               req->module_dentry = dget(req->dentry);
+               release_req_dentry(req);
+               goto usermode;
+       }
+
+       switch (attr->mime->special) {
+               case MIME_TYPE_MODULE:
+                       req->usermode = 1;
+                       goto usermode;
+
+               case MIME_TYPE_REDIRECT:
+                       req->error = TUX_ERROR_REDIRECT;
+                       goto error;
+
+               case MIME_TYPE_CGI:
+#if CONFIG_TUX_EXTCGI
+                       Dprintk("CGI request %p.\n", req);
+                       query_extcgi(req);
+                       return;
+#endif
+
+               default:
+                       if (req->query_str) {
+                               req->error = TUX_ERROR_REDIRECT;
+                               goto error;
+                       }
+       }
+       req->attr = attr;
+       switch (req->method) {
+               case METHOD_GET:
+               case METHOD_HEAD:
+                       break;
+               default:
+                       req->error = TUX_ERROR_REDIRECT;
+                       goto error;
+       }
+       if (req->usermode)
+               TUX_BUG();
+
+       req->output_len = req->total_file_len;
+       /*
+        * Do range calculations.
+        */
+       if (req->offset_end || req->offset_start)
+               handle_range(req);
+
+       if (req->may_send_gzip && !req->offset_start && !req->offset_end) {
+               if (handle_gzip_req(req, lookup_flag))
+                       goto cachemiss;
+               if ((tux_compression >= 2) && !req->content_gzipped)
+                       req->content_gzipped = 2;
+       }
+       if (req->parsed_len)
+               trunc_headers(req);
+
+       if (req->error)
+               goto error;
+
+       add_tux_atom(req, http_send_body);
+       add_tux_atom(req, http_post_header);
+
+       http_pre_header(req, req->method == METHOD_HEAD);
+
+       add_req_to_workqueue(req);
+       return;
+
+error:
+       if (req->error)
+               zap_request(req, cachemiss);
+       return;
+
+usermode:
+       add_req_to_workqueue(req);
+}
+
+static void http_post_header (tux_req_t *req, int cachemiss)
+{
+#if CONFIG_TUX_DEBUG
+       req->bytes_expected = req->output_len;
+#endif
+       req->bytes_sent = 0; // data comes now.
+
+       add_req_to_workqueue(req);
+}
+
+static void http_send_body (tux_req_t *req, int cachemiss)
+{
+       int ret;
+
+       Dprintk("SEND req %p <%p> (sock %p, sk %p) (keepalive: %d, status: %d)\n", req, __builtin_return_address(0), req->sock, req->sock->sk, req->keep_alive, req->status);
+
+       SET_TIMESTAMP(req->output_timestamp);
+
+       if (req->error) {
+#if CONFIG_TUX_DEBUG
+               req->bytes_expected = 0;
+#endif
+               req->in_file.f_pos = 0;
+               /*
+                * We are in the middle of a file transfer,
+                * zap it immediately:
+                */
+               TDprintk("req->error = TUX_ERROR_CONN_CLOSE.\n");
+               req->error = TUX_ERROR_CONN_CLOSE;
+               zap_request(req, cachemiss);
+               return;
+       }
+
+repeat:
+       ret = 0;
+       if (!req->status)
+               req->status = 200;
+       if (req->method != METHOD_HEAD) {
+               ret = generic_send_file(req, req->sock, cachemiss);
+               Dprintk("body send-file returned: %d.\n", ret);
+       } else {
+#if CONFIG_TUX_DEBUG
+               req->bytes_expected = 0;
+#endif
+       }
+
+       switch (ret) {
+               case -5:
+                       add_tux_atom(req, http_send_body);
+                       output_timeout(req);
+                       break;
+               case -4:
+                       add_tux_atom(req, http_send_body);
+                       if (add_output_space_event(req, req->sock)) {
+                               del_tux_atom(req);
+                               goto repeat;
+                       }
+                       break;
+               case -3:
+                       INC_STAT(static_sendfile_cachemisses);
+                       add_tux_atom(req, http_send_body);
+                       queue_cachemiss(req);
+                       break;
+               case -1:
+                       break;
+               default:
+                       req->in_file.f_pos = 0;
+                       add_req_to_workqueue(req);
+                       break;
+       }
+}
+
+#define DEFAULT_DATE "Wed, 01 Jan 1970 00:00:01 GMT"
+
+char tux_date [DATE_LEN] = DEFAULT_DATE;
+
+/*
+ * HTTP header
+ */
+
+#define HEADER_PART1A \
+               "HTTP/1.1 200 OK\r\n" \
+               "Content-Type: "
+
+#define HEADER_PART1B \
+               "HTTP/1.1 200 OK" 
+
+#define HEADER_PART1AP \
+               "HTTP/1.1 206 Partial Content\r\n" \
+               "Content-Type: "
+
+#define HEADER_PART1BP \
+               "HTTP/1.1 206 Partial Content" 
+
+#define HEADER_PART1C \
+               "HTTP/1.1 404 Page Not Found\r\n" \
+               "Content-Type: "
+
+#define HEADER_PART1D \
+               "HTTP/1.1 200 OK\r\n" \
+               "Content-Type: text/html\r\n" \
+               "Connection: close\r\n"
+
+#define HEADER_PART2_keepalive "\r\nConnection: Keep-Alive\r\nDate: "
+
+#define HEADER_PART2_close "\r\nConnection: close\r\nDate: "
+
+#define HEADER_PART2_none "\r\nDate: "
+
+// date "%s"
+
+#define HEADER_PART3A "\r\nContent-Encoding: gzip"
+#define HEADER_PART3BX "\r\nContent-Length: "
+
+/*
+ * Please acknowledge our hard work by not changing this define, or
+ * at least please acknowledge us by leaving "TUX/2.0 (Linux)" in
+ * the ID string. Thanks! :-)
+ */
+#define HEADER_PART3BY "\r\nServer: TUX/2.0 (Linux)\r\nContent-Length: "
+#define HEADER_PART3C "\r\nETag: \""
+#define HEADER_PART3ACC "\r\nAccept-Ranges: bytes"
+#define HEADER_PART3L "\r\nLast-Modified: "
+#define HEADER_PART3P "\r\nContent-Range: bytes "
+#define HEADER_PART3CA "\r\nCache-Control: max-age="
+#define HEADER_PART4 "\r\n\r\n"
+
+#define MAX_OUT_HEADER_LEN (sizeof(HEADER_PART1AP) + MAX_MIMETYPE_LEN + \
+               sizeof(HEADER_PART2_keepalive) + DATE_LEN + \
+               sizeof(HEADER_PART3A) + sizeof(HEADER_PART3BY) + \
+               12 + sizeof(HEADER_PART3C) + 21 + sizeof(HEADER_PART3L) + \
+               sizeof(HEADER_PART3P) + 32 + \
+               DATE_LEN + sizeof(HEADER_PART4) + sizeof(tux_extra_html_header) \
+               + sizeof(HEADER_PART3CA) + MAX_CACHE_CONTROL_AGE_LEN)
+
+static void http_pre_header (tux_req_t *req, int head)
+{
+       int partial = req->offset_start | req->offset_end;
+       unsigned long flags;
+       char *buf, *curr;
+       mimetype_t *mime = NULL;
+       int size;
+
+
+       if (MAX_OUT_HEADER_LEN > PAGE_SIZE)
+               TUX_BUG();
+       if ((req->attr && req->attr->tcapi) || req->usermode)
+               TUX_BUG();
+
+#define COPY_STATIC_PART(nr,curr)                                      \
+       do {    \
+               memcpy(curr, HEADER_PART##nr, sizeof(HEADER_PART##nr)-1); \
+               curr += sizeof(HEADER_PART##nr)-1;                      \
+       } while (0)
+
+       buf = curr = get_abuf(req, MAX_OUT_HEADER_LEN);
+
+       if (req->lookup_dir) {
+               COPY_STATIC_PART(1D, curr);
+               goto dir_next;
+       }
+       mime = req->attr->mime;
+       if (!mime)
+               TUX_BUG();
+
+       if (req->status == 404) {
+               COPY_STATIC_PART(1C, curr);
+               memcpy(curr, mime->type, mime->type_len);
+               curr += mime->type_len;
+       } else {
+               if (tux_noid && (mime == &default_mimetype)) {
+                       if (partial)
+                               COPY_STATIC_PART(1BP, curr);
+                       else
+                               COPY_STATIC_PART(1B, curr);
+               } else {
+                       if (partial)
+                               COPY_STATIC_PART(1AP, curr);
+                       else
+                               COPY_STATIC_PART(1A, curr);
+                       memcpy(curr, mime->type, mime->type_len);
+                       curr += mime->type_len;
+               }
+       }
+
+       if (tux_generate_cache_control && mime->expire_str_len) {
+               COPY_STATIC_PART(3CA, curr);
+               memcpy(curr, mime->expire_str, mime->expire_str_len);
+               curr += mime->expire_str_len;
+       }
+
+       if (req->keep_alive /* && (req->version == HTTP_1_0) */)
+               COPY_STATIC_PART(2_keepalive, curr);
+       else if (!req->keep_alive && (req->version == HTTP_1_1))
+               COPY_STATIC_PART(2_close, curr);
+       else
+               // HTTP/1.0 default means close
+               COPY_STATIC_PART(2_none, curr);
+
+dir_next:
+       memcpy(curr, tux_date, DATE_LEN-1);
+       curr += DATE_LEN-1;
+
+       if (req->content_gzipped)
+               COPY_STATIC_PART(3A, curr);
+
+       /*
+        * Content-Length:
+        */
+       if (!req->lookup_dir) {
+               if (tux_noid)
+                       COPY_STATIC_PART(3BX, curr);
+               else
+                       COPY_STATIC_PART(3BY, curr);
+
+               if (partial)
+                       curr += sprintf(curr, "%Ld", req->output_len);
+               else {
+                       if (req->content_gzipped)
+                               curr += sprintf(curr, "%Ld",
+                                                       req->total_file_len);
+                       else {
+                               memcpy(curr, &req->etag, req->lendigits);
+                               curr += req->lendigits;
+                       }
+               }
+               if (tux_generate_etags && (req->status != 404)) {
+                       COPY_STATIC_PART(3C, curr);
+                       memcpy(curr, &req->etag, req->etaglen);
+                       curr += req->etaglen;
+                       curr[0] = '"';
+                       curr++;
+               }
+               if (tux_generate_last_mod || tux_generate_etags)
+                       COPY_STATIC_PART(3ACC, curr);
+       }
+        if (tux_generate_last_mod && (req->status != 404)) {
+                COPY_STATIC_PART(3L, curr);
+               last_mod_time(curr, req->mtime);
+               curr += DATE_LEN-1;
+        }
+       if (partial) {
+               COPY_STATIC_PART(3P, curr);
+               curr += sprintf(curr, "%Ld-%Ld/%Ld", req->offset_start,
+                               req->offset_end-1, req->total_file_len);
+       }
+       COPY_STATIC_PART(4, curr);
+       /*
+        * Possibly add an extra HTML header:
+        */
+       if (tux_extra_html_header_size && mime && !strcmp(mime->type, "text/html")) {
+               unsigned int len = tux_extra_html_header_size;
+
+               memcpy(curr, tux_extra_html_header, len);
+               curr += len;
+       }
+
+       size = curr-buf;
+
+#if CONFIG_TUX_DEBUG
+       *curr = 0;
+       Dprintk("{%s} [%d/%d]\n", buf, size, strlen(buf));
+#endif
+
+       flags = MSG_DONTWAIT;
+       if (!head)
+               flags |= MSG_MORE;
+       send_abuf(req, size, flags);
+}
+
+void http_illegal_request (tux_req_t *req, int cachemiss)
+{
+       if (req->status == 304)
+               send_ret_notmodified(req);
+       else {
+               if (req->status == 403)
+                       send_async_err_forbidden(req);
+               else
+                       send_async_err_not_found(req);
+       }
+}
+
+static int http_check_req_err (tux_req_t *req, int cachemiss)
+{
+       if ((req->sock->sk->sk_state <= TCP_SYN_RECV) &&
+               !tcp_sk(req->sock->sk)->urg_data)
+                       return 0;
+       Dprintk("http_check_req_err(%p,%d): 1 (state: %d, urg: %d)\n",
+               req, cachemiss, req->sock->sk->sk_state,
+               tcp_sk(req->sock->sk)->urg_data);
+#if CONFIG_TUX_DEBUG
+       req->bytes_expected = 0;
+#endif
+       req->in_file.f_pos = 0;
+       req->error = TUX_ERROR_CONN_CLOSE;
+       zap_request(req, cachemiss);
+
+       return 1;
+}
+
+#define COPY_STR(str) \
+       do { memcpy(tmp, str, sizeof(str)-1); \
+       tmp += sizeof(str)-1; } while (0)
+
+static char * http_print_dir_line (tux_req_t *req, char *tmp, char *d_name, int d_len, int d_type, struct dentry *dentry, struct inode *inode)
+{
+       int len, spaces;
+       loff_t size;
+
+       switch (d_type) {
+       case DT_DIR:
+               COPY_STR("<IMG SRC=\"/icons/dir.gif\" ALT=\"[DIR]\">");
+               break;
+       case DT_REG:
+               if ((d_len >= 3) &&
+                       (d_name[d_len-3] == '.') &&
+                       (d_name[d_len-2] == 'g') &&
+                       (d_name[d_len-1] == 'z'))
+                       COPY_STR("<IMG SRC=\"/icons/compressed.gif\" ALT=\"[   ]\">");
+               else
+               if ((d_len >= 4) &&
+                       (d_name[d_len-4] == '.') &&
+                       (d_name[d_len-3] == 't') &&
+                       (d_name[d_len-2] == 'g') &&
+                       (d_name[d_len-1] == 'z'))
+                       COPY_STR("<IMG SRC=\"/icons/compressed.gif\" ALT=\"[   ]\">");
+               else
+               if ((d_len >= 4) &&
+                       (d_name[d_len-4] == '.') &&
+                       (d_name[d_len-3] == 't') &&
+                       (d_name[d_len-2] == 'x') &&
+                       (d_name[d_len-1] == 't'))
+                       COPY_STR("<IMG SRC=\"/icons/text.gif\" ALT=\"[   ]\">");
+               else
+               if ((d_len >= 4) &&
+                       (d_name[d_len-4] == '.') &&
+                       (d_name[d_len-3] == 'b') &&
+                       (d_name[d_len-2] == 'z') &&
+                       (d_name[d_len-1] == '2'))
+                       COPY_STR("<IMG SRC=\"/icons/compressed.gif\" ALT=\"[   ]\">");
+               else
+               if ((d_len >= 4) &&
+                       (d_name[d_len-4] == '.') &&
+                       (d_name[d_len-3] == 'z') &&
+                       (d_name[d_len-2] == 'i') &&
+                       (d_name[d_len-1] == 'p'))
+                       COPY_STR("<IMG SRC=\"/icons/compressed.gif\" ALT=\"[   ]\">");
+               else
+                       COPY_STR("<IMG SRC=\"/icons/file.gif\" ALT=\"[   ]\">");
+               break;
+       case DT_LNK:
+               COPY_STR("<IMG SRC=\"/icons/link.gif\" ALT=\"[LNK]\">");
+               break;
+       default:
+               if (tux_hide_unreadable)
+                       goto out_dput;
+               COPY_STR("<IMG SRC=\"/icons/unknown.gif\" ALT=\"[   ]\">");
+               break;
+       }
+
+#define LIST_1 " <A HREF=\""
+#define LIST_2 "\">"
+#define LIST_2_DIR "/\">"
+#define LIST_3 "</A> "
+
+       COPY_STR(LIST_1);
+       memcpy(tmp, d_name, d_len);
+       tmp += d_len;
+       if (d_type == DT_DIR)
+               COPY_STR(LIST_2_DIR);
+       else
+               COPY_STR(LIST_2);
+       spaces = 0;
+       len = d_len;
+
+       if (len > 25)
+               len = 25;
+       memcpy(tmp, d_name, len);
+       tmp += len;
+       if (len != d_len) {
+               *tmp++ = '.';
+               *tmp++ = '.';
+       } else {
+               if (d_type == DT_DIR)
+                       *tmp++ = '/';
+               else
+                       spaces++;
+               spaces++;
+       }
+       COPY_STR(LIST_3);
+       while (spaces) {
+               *tmp++ = ' ';
+               spaces--;
+       }
+#define FILL 25
+       if (d_len < FILL) {
+               memset(tmp, ' ', FILL-d_len);
+               tmp += FILL-d_len;
+       }
+
+       tmp += time_unix2ls(inode->i_mtime.tv_sec, tmp);
+       *tmp++ = ' ';
+
+       if (d_type != DT_REG) {
+               COPY_STR("        - ");
+               goto out_size;
+       }
+       size = inode->i_size >> 10;
+       if (size < 1024) {
+               tmp += sprintf(tmp, "%8Lik ", size);
+               goto out_size;
+       }
+       size >>= 10;
+       if (size < 1024) {
+               tmp += sprintf(tmp, "%8LiM ", size);
+               goto out_size;
+       }
+       size >>= 10;
+       if (size < 1024) {
+               tmp += sprintf(tmp, "%8LiG ", size);
+               goto out_size;
+       }
+       size >>= 10;
+       if (size < 1024) {
+               tmp += sprintf(tmp, "%8LiT ", size);
+               goto out_size;
+       }
+       size >>= 10;
+       tmp += sprintf(tmp, "%8LiT ", size);
+
+out_size:
+       *tmp++ = '\n';
+       *tmp = 0;
+
+       return tmp;
+out_dput:
+       return NULL;
+}
+
+tux_proto_t tux_proto_http = {
+       defer_accept: 1,
+       can_redirect: 1,
+       got_request: http_got_request,
+       parse_message: parse_http_message,
+       illegal_request: http_illegal_request,
+       check_req_err: http_check_req_err,
+       print_dir_line: http_print_dir_line,
+       name: "http",
+};
+
diff --git a/net/tux/redirect.c b/net/tux/redirect.c
new file mode 100644 (file)
index 0000000..86b5300
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * redirect.c: redirect requests to other server sockets (such as Apache).
+ */
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+static void dummy_destructor(struct open_request *req)
+{
+}
+
+static struct or_calltable dummy = 
+{
+       0,
+       NULL,
+       NULL,
+       &dummy_destructor,
+       NULL
+};
+
+static int redirect_sock (tux_req_t *req, const int port)
+{
+       struct socket *sock = req->sock;
+       struct open_request *tcpreq;
+       struct sock *sk, *oldsk;
+       int err = -1;
+
+       /*
+        * Look up (optional) listening user-space socket.
+        */
+       local_bh_disable();
+       sk = tcp_v4_lookup_listener(INADDR_ANY, port, 0);
+       /*
+        * Look up localhost listeners as well.
+        */
+       if (!sk) {
+               u32 daddr;
+               ((unsigned char *)&daddr)[0] = 127;
+               ((unsigned char *)&daddr)[1] = 0;
+               ((unsigned char *)&daddr)[2] = 0;
+               ((unsigned char *)&daddr)[3] = 1;
+               sk = tcp_v4_lookup_listener(daddr, port, 0);
+       }
+       local_bh_enable();
+
+       /* No secondary server found */
+       if (!sk)
+               goto out;
+
+       /*
+        * Requeue the 'old' socket as an accept-socket of
+        * the listening socket. This way we can shuffle
+        * a socket around. Since we've read the input data
+        * via the non-destructive MSG_PEEK, the secondary
+        * server can be used transparently.
+        */
+       oldsk = sock->sk;
+       lock_sock(sk);
+
+       if (sk->sk_state != TCP_LISTEN)
+               goto out_unlock;
+
+       tcpreq = tcp_openreq_alloc();
+       if (!tcpreq)
+               goto out_unlock;
+
+       unlink_tux_socket(req);
+
+       sock->sk = NULL;
+       sock->state = SS_UNCONNECTED;
+
+       tcpreq->class = &dummy;
+       write_lock_irq(&oldsk->sk_callback_lock);
+       oldsk->sk_socket = NULL;
+        oldsk->sk_sleep = NULL;
+       write_unlock_irq(&oldsk->sk_callback_lock);
+
+       tcp_sk(oldsk)->nonagle = 0;
+
+       tcp_acceptq_queue(sk, tcpreq, oldsk);
+
+       sk->sk_data_ready(sk, 0);
+
+       /*
+        * It's now completely up to the secondary
+        * server to handle this request.
+        */
+       sock_release(req->sock);
+       req->sock = NULL;
+       req->parsed_len = 0;
+       err = 0;
+       Dprintk("req %p redirected to secondary server!\n", req);
+
+out_unlock:
+       release_sock(sk);
+       sock_put(sk);
+out:
+       if (err)
+               Dprintk("NO secondary server for req %p!\n", req);
+       return err;
+}
+
+void redirect_request (tux_req_t *req, int cachemiss)
+{
+       if (tux_TDprintk && (req->status != 304)) {
+               TDprintk("trying to redirect req %p, req->error: %d, req->status: %d.\n", req, req->error, req->status);
+               print_req(req);
+       }
+
+       if (cachemiss)
+               TUX_BUG();
+       if (req->error == TUX_ERROR_CONN_CLOSE)
+               goto out_flush;
+       if (!req->sock)
+               TUX_BUG();
+
+       if (!req->status)
+               req->status = -1;
+       if (!req->proto->can_redirect || (req->status == 304) || redirect_sock(req, tux_clientport)) {
+               if (req->parsed_len)
+                       trunc_headers(req);
+               req->proto->illegal_request(req, cachemiss);
+               return;
+       } else {
+               if (req->data_sock)
+                       BUG();
+       }
+out_flush:
+       clear_keepalive(req);
+       if (!tux_redirect_logging)
+               req->status = 0;
+       flush_request(req, cachemiss);
+}
+
diff --git a/net/tux/times.c b/net/tux/times.c
new file mode 100644 (file)
index 0000000..3388f63
--- /dev/null
@@ -0,0 +1,392 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * times.c: time conversion routines.
+ *
+ * Original time convserion code Copyright (C) 1999 by Arjan van de Ven
+ */
+
+/****************************************************************
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2, or (at your option)
+ *     any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+#include <linux/time.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/ctype.h>
+
+
+#include "times.h"
+
+char *dayName[7] = {
+       "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+
+static char *monthName[12] = {
+       "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+char itoa_h[60]={'0','0','0','0','0','0','0','0','0','0',
+                '1','1','1','1','1','1','1','1','1','1',
+                '2','2','2','2','2','2','2','2','2','2',
+                '3','3','3','3','3','3','3','3','3','3',
+                '4','4','4','4','4','4','4','4','4','4',
+                '5','5','5','5','5','5','5','5','5','5'};
+               
+char itoa_l[60]={'0','1','2','3','4','5','6','7','8','9',
+                '0','1','2','3','4','5','6','7','8','9',
+                '0','1','2','3','4','5','6','7','8','9',
+                '0','1','2','3','4','5','6','7','8','9',
+                '0','1','2','3','4','5','6','7','8','9',
+                '0','1','2','3','4','5','6','7','8','9'};
+
+int time_unix2ls(time_t zulu, char *buf)
+{
+       int Y=0,M=0,D=0;
+       int H=0,Min=0,S=0,WD=0;
+       int I,I2;
+       time_t rest, delta;
+
+       if (zulu > xtime.tv_sec)
+               zulu = xtime.tv_sec;
+
+       I=0;
+       while (I<TUX_NUMYEARS) {
+               if (TimeDays[I][0]>zulu) 
+                  break;
+               I++;
+       }
+       
+       Y=--I;
+       if (I<0) {
+               Y=0;
+               goto BuildYear;
+       }
+       I2=0;
+       while (I2<=12) {
+               if (TimeDays[I][I2]>zulu) 
+                  break;
+               I2++;
+       }                          
+       
+       M=I2-1;
+       
+       rest=zulu - TimeDays[Y][M];
+       WD=WeekDays[Y][M];
+       D=rest/86400;
+       rest=rest%86400;
+       WD+=D;
+       WD=WD%7;
+       H=rest/3600;
+       rest=rest%3600;
+       Min=rest/60;
+       rest=rest%60;
+       S=rest;
+       
+BuildYear:
+       Y+=TUX_YEAROFFSET;
+       
+       
+       /* Format:  Day, 01 Mon 1999 01:01:01 GMT */
+
+       delta = xtime.tv_sec - zulu;
+       if (delta > 6*30*24*60)
+               //               "May 23   2000"
+               return sprintf( buf, "%s %02i  %04i", monthName[M], D+1, Y);
+       else
+               //                "May 23 10:14"
+               return sprintf( buf, "%s %02i %02i:%02i",
+                       monthName[M], D+1, H, Min);
+}
+
+static int MonthHash[32] =
+       {0,0,7,0,0,0,0,0,0,0,0,3,0,0,0,2,6,0,5,0,9,8,4,0,0,11,1,10,0,0,0,0};
+
+#define is_digit(c)    ((c) >= '0' && (c) <= '9')
+
+static inline int skip_atoi(char **s)
+{
+       int i=0;
+
+       while (is_digit(**s))
+               i = i*10 + *((*s)++) - '0';
+       return i;
+}
+
+time_t mimetime_to_unixtime(char *Q)
+{
+       int Y,M,D,H,Min,S;
+       unsigned int Hash;
+       time_t Temp;
+       char *s,**s2;
+       
+       s=Q;
+       s2=&s;
+       
+       if (strlen(s)<30) return 0;
+       if (s[3]!=',') return 0;
+       if (s[19]!=':') return 0;
+       
+       s+=5; /* Skip day of week */
+       D = skip_atoi(s2);  /*  Day of month */
+       s++;
+       Hash = (char)s[0]+(char)s[2];
+       Hash = (Hash<<1) + (char)s[1];
+       Hash = (Hash&63)>>1;
+       M = MonthHash[Hash];
+       s+=4;
+       Y = skip_atoi(s2); /* Year */
+       s++;
+       H = skip_atoi(s2); /* Hour */
+       s++;
+       Min = skip_atoi(s2); /* Minutes */
+       s++;
+       S = skip_atoi(s2); /* Seconds */
+       s++;
+       if ((s[0]!='G')||(s[1]!='M')||(s[2]!='T')) 
+       {       
+               return 0; /* No GMT */
+       }
+
+       if (Y<TUX_YEAROFFSET) Y = TUX_YEAROFFSET;
+       if (Y>TUX_YEAROFFSET+9) Y = TUX_YEAROFFSET+9;
+       
+       Temp =  TimeDays[Y-TUX_YEAROFFSET][M];
+       Temp += D*86400+H*3600+Min*60+S;
+       
+       return Temp;  
+}
+
+// writes the full http date, corresponding to time_t received
+
+void last_mod_time(char * curr, const time_t t)
+{
+       int day, tod, year, wday, mon, hour, min, sec;
+       tod = t % 86400;
+       day = t / 86400;
+       if (tod < 0) {
+               tod += 86400;
+               --day;
+       }
+       hour = tod / 3600;
+       tod %= 3600;
+       min = tod / 60;
+       sec = tod % 60;
+       wday = (day + 4) % 7;
+       if (wday < 0)
+               wday += 7;
+       day -= 11017;
+       /* day 0 is march 1, 2000 */
+       year = 5 + day / 146097;
+       day = day % 146097;
+       if (day < 0) {
+               day += 146097;
+               --year;
+       }
+       /* from now on, day is nonnegative */
+       year *= 4;
+       if (day == 146096) {
+               year += 3;
+               day = 36524;
+       } else {
+               year += day / 36524;
+               day %= 36524;
+       }
+       year *= 25;
+       year += day / 1461;
+       day %= 1461;
+       year *= 4;
+       if (day == 1460) {
+               year += 3;
+               day = 365;
+       } else {
+               year += day / 365;
+               day %= 365;
+       }
+       day *= 10;
+       mon = (day + 5) / 306;
+       day = day + 5 - 306 * mon;
+       day /= 10;
+       if (mon >= 10) {
+               ++year;
+               mon -= 10;
+       } else
+               mon += 2;
+       sprintf(curr, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", dayName[wday],
+               day+1, monthName[mon], year, hour, min, sec);
+}
+
+// writes the full date in ISO8601 format,
+// corresponding to time_t received
+// example: 20011126224910
+
+int mdtm_time(char * curr, const time_t t)
+{
+       int day, tod, year, wday, mon, hour, min, sec;
+       tod = t % 86400;
+       day = t / 86400;
+       if (tod < 0) {
+               tod += 86400;
+               --day;
+       }
+       hour = tod / 3600;
+       tod %= 3600;
+       min = tod / 60;
+       sec = tod % 60;
+       wday = (day + 4) % 7;
+       if (wday < 0)
+               wday += 7;
+       day -= 11017;
+       /* day 0 is march 1, 2000 */
+       year = 5 + day / 146097;
+       day = day % 146097;
+       if (day < 0) {
+               day += 146097;
+               --year;
+       }
+       /* from now on, day is nonnegative */
+       year *= 4;
+       if (day == 146096) {
+               year += 3;
+               day = 36524;
+       } else {
+               year += day / 36524;
+               day %= 36524;
+       }
+       year *= 25;
+       year += day / 1461;
+       day %= 1461;
+       year *= 4;
+       if (day == 1460) {
+               year += 3;
+               day = 365;
+       } else {
+               year += day / 365;
+               day %= 365;
+       }
+       day *= 10;
+       mon = (day + 5) / 306;
+       day = day + 5 - 306 * mon;
+       day /= 10;
+       if (mon >= 10) {
+               ++year;
+               mon -= 10;
+       } else
+               mon += 2;
+       return sprintf(curr, "213 %.4d%.2d%.2d%.2d%.2d%.2d\r\n",
+               year, mon+1, day+1, hour, min, sec);
+}
+
+static inline int make_num(const char *s)
+{
+       if (*s >= '0' && *s <= '9')
+               return 10 * (*s - '0') + *(s + 1) - '0';
+       else
+               return *(s + 1) - '0';
+}
+
+static inline int make_month(const char *s)
+{
+       int i;
+
+       for (i = 0; i < 12; i++)
+               if (!strncmp(monthName[i], s, 3))
+                       return i+1;
+       return 0;
+}
+
+time_t parse_time(const char *str, const int str_len)
+{
+       int hour;
+       int min;
+       int sec;
+       int mday;
+       int mon;
+       int year;
+
+       if (str[3] == ',') {
+               /* Thu, 09 Jan 1993 01:29:59 GMT */
+
+               if (str_len < 29) 
+                       return -1;
+
+               mday = make_num(str+5);
+               mon = make_month(str + 8);
+               year = 100 * make_num(str + 12) + make_num(str + 14);
+               hour = make_num(str + 17);
+               min = make_num(str + 20);
+               sec = make_num(str + 23);
+       }
+       else {
+               const char *s;
+               s = strchr(str, ',');
+               if (!s || (str_len - (s - str) < 24)) {
+                       /* Wed Jun  9 01:29:59 1993 */
+
+                       if (str_len < 24)
+                               return -1;
+
+                       mon = make_month(str+4);
+                       mday = make_num(str+8);
+                       hour = make_num(str+11);
+                       min = make_num(str+14);
+                       sec = make_num(str+17);
+                       year = make_num(str+20)*100 + make_num(str+22);
+               }
+               else {
+                       /* Thursday, 10-Jun-93 01:29:59 GMT */
+
+                       mday = make_num(s + 2);
+                       mon = make_month(s + 5);
+                       year = make_num(s + 9) + 1900;
+                       if (year < 1970)
+                               year += 100;
+                       hour = make_num(s + 12);
+                       min = make_num(s + 15);
+                       sec = make_num(s + 18);
+               }
+       }
+
+       if (sec < 0 || sec > 59)
+               return -1;
+       if (min < 0 || min > 59)
+               return -1;
+       if (hour < 0 || hour > 23)
+               return -1;
+       if (mday < 1 || mday > 31)
+               return -1;
+       if (mon < 1 || mon > 12)
+               return -1;
+       if (year < 1970 || year > 2020)
+               return -1;
+
+       return mktime(year, mon, mday, hour, min, sec);
+}
diff --git a/net/tux/times.h b/net/tux/times.h
new file mode 100644 (file)
index 0000000..09c389f
--- /dev/null
@@ -0,0 +1,26 @@
+static time_t TimeDays[10][13] = { 
+ { 852073200,  854751600,      857170800,      859849200,      862441200,      865119600,      867711600,      870390000,      873068400,      875660400,      878338800,      880930800,      883609200 } ,
+ { 883609200,  886287600,      888706800,      891385200,      893977200,      896655600,      899247600,      901926000,      904604400,      907196400,      909874800,      912466800,      915145200 } ,
+ { 915145200,  917823600,      920242800,      922921200,      925513200,      928191600,      930783600,      933462000,      936140400,      938732400,      941410800,      944002800,      946681200 } ,
+ { 946681200,  949359600,      951865200,      954543600,      957135600,      959814000,      962406000,      965084400,      967762800,      970354800,      973033200,      975625200,      978303600 } ,
+ { 978303600,  980982000,      983401200,      986079600,      988671600,      991350000,      993942000,      996620400,      999298800,      1001890800,     1004569200,     1007161200,     1009839600 } ,
+ { 1009839600, 1012518000,     1014937200,     1017615600,     1020207600,     1022886000,     1025478000,     1028156400,     1030834800,     1033426800,     1036105200,     1038697200,     1041375600 } ,
+ { 1041375600, 1044054000,     1046473200,     1049151600,     1051743600,     1054422000,     1057014000,     1059692400,     1062370800,     1064962800,     1067641200,     1070233200,     1072911600 } ,
+ { 1072911600, 1075590000,     1078095600,     1080774000,     1083366000,     1086044400,     1088636400,     1091314800,     1093993200,     1096585200,     1099263600,     1101855600,     1104534000 } ,
+ { 1104534000, 1107212400,     1109631600,     1112310000,     1114902000,     1117580400,     1120172400,     1122850800,     1125529200,     1128121200,     1130799600,     1133391600,     1136070000 } ,
+ { 1136070000, 1138748400,     1141167600,     1143846000,     1146438000,     1149116400,     1151708400,     1154386800,     1157065200,     1159657200,     1162335600,     1164927600,     1167606000 } 
+};
+static int WeekDays[10][13] = { 
+ { 3,  6,      6,      2,      4,      0,      2,      5,      1,      3,      6,      1,      4 } ,
+ { 4,  0,      0,      3,      5,      1,      3,      6,      2,      4,      0,      2,      5 } ,
+ { 5,  1,      1,      4,      6,      2,      4,      0,      3,      5,      1,      3,      6 } ,
+ { 6,  2,      3,      6,      1,      4,      6,      2,      5,      0,      3,      5,      1 } ,
+ { 1,  4,      4,      0,      2,      5,      0,      3,      6,      1,      4,      6,      2 } ,
+ { 2,  5,      5,      1,      3,      6,      1,      4,      0,      2,      5,      0,      3 } ,
+ { 3,  6,      6,      2,      4,      0,      2,      5,      1,      3,      6,      1,      4 } ,
+ { 4,  0,      1,      4,      6,      2,      4,      0,      3,      5,      1,      3,      6 } ,
+ { 6,  2,      2,      5,      0,      3,      5,      1,      4,      6,      2,      4,      0 } ,
+ { 0,  3,      3,      6,      1,      4,      6,      2,      5,      0,      3,      5,      1 } 
+};
+#define TUX_YEAROFFSET   1997
+#define TUX_NUMYEARS     10
diff --git a/net/tux/userspace.c b/net/tux/userspace.c
new file mode 100644 (file)
index 0000000..effd45d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * TUX - Integrated Application Protocols Layer and Object Cache
+ *
+ * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
+ *
+ * userspace.c: handle userspace-module requests
+ */
+
+#include <net/tux.h>
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
index c266bd6..08432ce 100644 (file)
 #include <linux/mount.h>
 #include <net/checksum.h>
 #include <linux/security.h>
+#include <linux/vs_context.h>
+#include <linux/vs_network.h>
+#include <linux/vs_limit.h>
 
 int sysctl_unix_max_dgram_qlen = 10;
 
@@ -405,6 +408,9 @@ static int unix_release_sock (struct sock *sk, int embrion)
                mntput(mnt);
        }
 
+       vx_sock_dec(sk);
+       clr_vx_info(&sk->sk_vx_info);
+       clr_nx_info(&sk->sk_nx_info);
        sock_put(sk);
 
        /* ---- Socket is dead now and most probably destroyed ---- */
@@ -559,6 +565,11 @@ static struct sock * unix_create1(struct socket *sock)
        sock_init_data(sock,sk);
        sk_set_owner(sk, THIS_MODULE);
 
+       set_vx_info(&sk->sk_vx_info, current->vx_info);
+       sk->sk_xid = vx_current_xid();
+       vx_sock_inc(sk);
+       set_nx_info(&sk->sk_nx_info, current->nx_info);
+
        sk->sk_write_space      = unix_write_space;
        sk->sk_max_ack_backlog  = sysctl_unix_max_dgram_qlen;
        sk->sk_destruct         = unix_sock_destructor;
@@ -870,7 +881,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
                        goto out;
                alen = err;
 
-               if (sock->passcred && !unix_sk(sk)->addr &&
+               if (test_bit(SOCK_PASS_CRED, &sock->flags) && !unix_sk(sk)->addr &&
                    (err = unix_autobind(sock)) != 0)
                        goto out;
 
@@ -961,7 +972,8 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
                goto out;
        addr_len = err;
 
-       if (sock->passcred && !u->addr && (err = unix_autobind(sock)) != 0)
+       if (test_bit(SOCK_PASS_CRED, &sock->flags)
+               && !u->addr && (err = unix_autobind(sock)) != 0)
                goto out;
 
        timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
@@ -1295,7 +1307,8 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
                        goto out;
        }
 
-       if (sock->passcred && !u->addr && (err = unix_autobind(sock)) != 0)
+       if (test_bit(SOCK_PASS_CRED, &sock->flags)
+               && !u->addr && (err = unix_autobind(sock)) != 0)
                goto out;
 
        err = -EMSGSIZE;
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
deleted file mode 100644 (file)
index ae72dfd..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* 
- * generic xfrm output routines
- *
- * Copyright (c) 2003 James Morris <jmorris@intercode.com.au>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option) 
- * any later version.
- */
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/skbuff.h>
-#include <net/xfrm.h>
-
-int xfrm_check_output(struct xfrm_state *x,
-                      struct sk_buff *skb, unsigned short family)
-{
-       int err;
-       
-       err = xfrm_state_check_expire(x);
-       if (err)
-               goto out;
-               
-       if (x->props.mode) {
-               switch (family) {
-               case AF_INET:
-                       err = xfrm4_tunnel_check_size(skb);
-                       break;
-                       
-               case AF_INET6:
-                       err = xfrm6_tunnel_check_size(skb);
-                       break;
-                       
-               default:
-                       err = -EINVAL;
-               }
-               
-               if (err)
-                       goto out;
-       }
-
-       err = xfrm_state_check_space(x, skb);
-out:
-       return err;
-}
diff --git a/scripts/empty.c b/scripts/empty.c
deleted file mode 100644 (file)
index 49839cc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/* empty file to figure out endianness / word size */
diff --git a/scripts/file2alias.c b/scripts/file2alias.c
deleted file mode 100644 (file)
index fa8fd16..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/* Simple code to turn various tables in an ELF file into alias definitions.
- * This deals with kernel datastructures where they should be
- * dealt with: in the kernel source.
- *
- * Copyright 2002-2003  Rusty Russell, IBM Corporation
- *           2003       Kai Germaschewski
- *           
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- */
-
-#include "modpost.h"
-
-/* We use the ELF typedefs, since we can't rely on stdint.h being present. */
-
-#if KERNEL_ELFCLASS == ELFCLASS32
-typedef Elf32_Addr     kernel_ulong_t;
-#else
-typedef Elf64_Addr     kernel_ulong_t;
-#endif
-
-typedef Elf32_Word     __u32;
-typedef Elf32_Half     __u16;
-typedef unsigned char  __u8;
-
-/* Big exception to the "don't include kernel headers into userspace, which
- * even potentially has different endianness and word sizes, since 
- * we handle those differences explicitly below */
-#include "../include/linux/mod_devicetable.h"
-
-#define ADD(str, sep, cond, field)                              \
-do {                                                            \
-        strcat(str, sep);                                       \
-        if (cond)                                               \
-                sprintf(str + strlen(str),                      \
-                        sizeof(field) == 1 ? "%02X" :           \
-                        sizeof(field) == 2 ? "%04X" :           \
-                        sizeof(field) == 4 ? "%08X" : "",       \
-                        field);                                 \
-        else                                                    \
-                sprintf(str + strlen(str), "*");                \
-} while(0)
-
-/* Looks like "usb:vNpNdlNdhNdcNdscNdpNicNiscNipN" */
-static int do_usb_entry(const char *filename,
-                       struct usb_device_id *id, char *alias)
-{
-       id->match_flags = TO_NATIVE(id->match_flags);
-       id->idVendor = TO_NATIVE(id->idVendor);
-       id->idProduct = TO_NATIVE(id->idProduct);
-       id->bcdDevice_lo = TO_NATIVE(id->bcdDevice_lo);
-       id->bcdDevice_hi = TO_NATIVE(id->bcdDevice_hi);
-
-       /*
-        * Some modules (visor) have empty slots as placeholder for
-        * run-time specification that results in catch-all alias
-        */
-       if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
-               return 1;
-
-       strcpy(alias, "usb:");
-       ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
-           id->idVendor);
-       ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
-           id->idProduct);
-       ADD(alias, "dl", id->match_flags&USB_DEVICE_ID_MATCH_DEV_LO,
-           id->bcdDevice_lo);
-       ADD(alias, "dh", id->match_flags&USB_DEVICE_ID_MATCH_DEV_HI,
-           id->bcdDevice_hi);
-       ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
-           id->bDeviceClass);
-       ADD(alias, "dsc",
-           id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
-           id->bDeviceSubClass);
-       ADD(alias, "dp",
-           id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
-           id->bDeviceProtocol);
-       ADD(alias, "ic",
-           id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
-           id->bInterfaceClass);
-       ADD(alias, "isc",
-           id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
-           id->bInterfaceSubClass);
-       ADD(alias, "ip",
-           id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
-           id->bInterfaceProtocol);
-       return 1;
-}
-
-/* Looks like: ieee1394:venNmoNspNverN */
-static int do_ieee1394_entry(const char *filename,
-                            struct ieee1394_device_id *id, char *alias)
-{
-       id->match_flags = TO_NATIVE(id->match_flags);
-       id->vendor_id = TO_NATIVE(id->vendor_id);
-       id->model_id = TO_NATIVE(id->model_id);
-       id->specifier_id = TO_NATIVE(id->specifier_id);
-       id->version = TO_NATIVE(id->version);
-
-       strcpy(alias, "ieee1394:");
-       ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
-           id->vendor_id);
-       ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
-           id->model_id);
-       ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
-           id->specifier_id);
-       ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
-           id->version);
-
-       return 1;
-}
-
-/* Looks like: pci:vNdNsvNsdNbcNscNiN. */
-static int do_pci_entry(const char *filename,
-                       struct pci_device_id *id, char *alias)
-{
-       /* Class field can be divided into these three. */
-       unsigned char baseclass, subclass, interface,
-               baseclass_mask, subclass_mask, interface_mask;
-
-       id->vendor = TO_NATIVE(id->vendor);
-       id->device = TO_NATIVE(id->device);
-       id->subvendor = TO_NATIVE(id->subvendor);
-       id->subdevice = TO_NATIVE(id->subdevice);
-       id->class = TO_NATIVE(id->class);
-       id->class_mask = TO_NATIVE(id->class_mask);
-
-       strcpy(alias, "pci:");
-       ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
-       ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
-       ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
-       ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
-
-       baseclass = (id->class) >> 16;
-       baseclass_mask = (id->class_mask) >> 16;
-       subclass = (id->class) >> 8;
-       subclass_mask = (id->class_mask) >> 8;
-       interface = id->class;
-       interface_mask = id->class_mask;
-
-       if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
-           || (subclass_mask != 0 && subclass_mask != 0xFF)
-           || (interface_mask != 0 && interface_mask != 0xFF)) {
-               fprintf(stderr,
-                       "*** Warning: Can't handle masks in %s:%04X\n",
-                       filename, id->class_mask);
-               return 0;
-       }
-
-       ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
-       ADD(alias, "sc", subclass_mask == 0xFF, subclass);
-       ADD(alias, "i", interface_mask == 0xFF, interface);
-       return 1;
-}
-
-/* looks like: "ccw:tNmNdtNdmN" */ 
-static int do_ccw_entry(const char *filename,
-                       struct ccw_device_id *id, char *alias)
-{
-       id->match_flags = TO_NATIVE(id->match_flags);
-       id->cu_type = TO_NATIVE(id->cu_type);
-       id->cu_model = TO_NATIVE(id->cu_model);
-       id->dev_type = TO_NATIVE(id->dev_type);
-       id->dev_model = TO_NATIVE(id->dev_model);
-
-       strcpy(alias, "ccw:");
-       ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
-           id->cu_type);
-       ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
-           id->cu_model);
-       ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
-           id->dev_type);
-       ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
-           id->dev_model);
-       return 1;
-}
-
-/* looks like: "pnp:dD" */
-static int do_pnp_entry(const char *filename,
-                       struct pnp_device_id *id, char *alias)
-{
-       sprintf(alias, "pnp:d%s", id->id);
-       return 1;
-}
-
-/* looks like: "pnp:cCdD..." */
-static int do_pnp_card_entry(const char *filename,
-                       struct pnp_card_device_id *id, char *alias)
-{
-       int i;
-
-       sprintf(alias, "pnp:c%s", id->id);
-       for (i = 0; i < PNP_MAX_DEVICES; i++) {
-               if (! *id->devs[i].id)
-                       break;
-               sprintf(alias + strlen(alias), "d%s", id->devs[i].id);
-       }
-       return 1;
-}
-
-/* Ignore any prefix, eg. v850 prepends _ */
-static inline int sym_is(const char *symbol, const char *name)
-{
-       const char *match;
-
-       match = strstr(symbol, name);
-       if (!match)
-               return 0;
-       return match[strlen(symbol)] == '\0';
-}
-
-static void do_table(void *symval, unsigned long size,
-                    unsigned long id_size,
-                    void *function,
-                    struct module *mod)
-{
-       unsigned int i;
-       char alias[500];
-       int (*do_entry)(const char *, void *entry, char *alias) = function;
-
-       if (size % id_size || size < id_size) {
-               fprintf(stderr, "*** Warning: %s ids %lu bad size "
-                       "(each on %lu)\n", mod->name, size, id_size);
-       }
-       /* Leave last one: it's the terminator. */
-       size -= id_size;
-
-       for (i = 0; i < size; i += id_size) {
-               if (do_entry(mod->name, symval+i, alias)) {
-                       /* Always end in a wildcard, for future extension */
-                       if (alias[strlen(alias)-1] != '*')
-                               strcat(alias, "*");
-                       buf_printf(&mod->dev_table_buf,
-                                  "MODULE_ALIAS(\"%s\");\n", alias);
-               }
-       }
-}
-
-/* Create MODULE_ALIAS() statements.
- * At this time, we cannot write the actual output C source yet,
- * so we write into the mod->dev_table_buf buffer. */
-void handle_moddevtable(struct module *mod, struct elf_info *info,
-                       Elf_Sym *sym, const char *symname)
-{
-       void *symval;
-
-       /* We're looking for a section relative symbol */
-       if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
-               return;
-
-       symval = (void *)info->hdr
-               + info->sechdrs[sym->st_shndx].sh_offset
-               + sym->st_value;
-
-       if (sym_is(symname, "__mod_pci_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct pci_device_id),
-                        do_pci_entry, mod);
-       else if (sym_is(symname, "__mod_usb_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct usb_device_id),
-                        do_usb_entry, mod);
-       else if (sym_is(symname, "__mod_ieee1394_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id),
-                        do_ieee1394_entry, mod);
-       else if (sym_is(symname, "__mod_ccw_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct ccw_device_id),
-                        do_ccw_entry, mod);
-       else if (sym_is(symname, "__mod_pnp_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
-                        do_pnp_entry, mod);
-       else if (sym_is(symname, "__mod_pnp_card_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id),
-                        do_pnp_card_entry, mod);
-}
-
-/* Now add out buffered information to the generated C source */
-void add_moddevtable(struct buffer *buf, struct module *mod)
-{
-       buf_printf(buf, "\n");
-       buf_write(buf, mod->dev_table_buf.p, mod->dev_table_buf.pos);
-       free(mod->dev_table_buf.p);
-}
index 89b986a..bb91382 100644 (file)
@@ -2,6 +2,8 @@
 # Kernel configuration targets
 # These targets are used from top-level makefile
 
+export LD_LIBRARY_PATH = scripts/kconfig
+
 .PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig
 
 xconfig: $(obj)/qconf
@@ -23,6 +25,10 @@ oldconfig: $(obj)/conf
 silentoldconfig: $(obj)/conf
        $< -s arch/$(ARCH)/Kconfig
 
+nonint_oldconfig: scripts/kconfig/conf
+       ./scripts/kconfig/conf -b arch/$(ARCH)/Kconfig
+
+
 .PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
 
 randconfig: $(obj)/conf
@@ -68,7 +74,7 @@ help:
 libkconfig-objs := zconf.tab.o
 
 host-progs     := conf mconf qconf gconf
-conf-objs      := conf.o  libkconfig.so
+conf-objs      := conf.o
 mconf-objs     := mconf.o libkconfig.so
 
 ifeq ($(MAKECMDGOALS),xconfig)
@@ -95,13 +101,15 @@ clean-files        := libkconfig.so lkc_defs.h qconf.moc .tmp_qtcheck \
 HOSTCFLAGS_lex.zconf.o := -I$(src)
 HOSTCFLAGS_zconf.tab.o := -I$(src)
 
+HOSTLOADLIBES_conf     = -Wl,-rpath,\$$ORIGIN -Lscripts/kconfig -lkconfig
+
 HOSTLOADLIBES_qconf    = -L$(QTLIBPATH) -Wl,-rpath,$(QTLIBPATH) -l$(QTLIB) -ldl
 HOSTCXXFLAGS_qconf.o   = -I$(QTDIR)/include 
 
 HOSTLOADLIBES_gconf    = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --libs`
 HOSTCFLAGS_gconf.o     = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags`
 
-$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o: $(obj)/zconf.tab.h
+$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o: $(obj)/zconf.tab.h $(obj)/libkconfig.so
 
 $(obj)/qconf.o: $(obj)/.tmp_qtcheck
 
@@ -112,7 +120,7 @@ QTLIBPATH = $(QTDIR)/lib
 
 # QT needs some extra effort...
 $(obj)/.tmp_qtcheck:
-       @set -e; for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
+       @set -e; for d in $$QTDIR /usr/share/qt* /usr/lib/qt* /usr/lib64/qt* ; do \
          if [ -f $$d/include/qconfig.h ]; then DIR=$$d; break; fi; \
        done; \
        if [ -z "$$DIR" ]; then \
index cdc7201..a1032aa 100644 (file)
@@ -20,6 +20,7 @@ enum {
        ask_all,
        ask_new,
        ask_silent,
+       dont_ask,
        set_default,
        set_yes,
        set_mod,
@@ -36,6 +37,8 @@ static struct menu *rootEntry;
 
 static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
 
+static int return_value = 0;
+
 static void strip(char *str)
 {
        char *p = str;
@@ -93,6 +96,12 @@ static void conf_askvalue(struct symbol *sym, const char *def)
                fflush(stdout);
                fgets(line, 128, stdin);
                return;
+       case dont_ask:
+               if (!sym_has_value(sym)) {
+                       fprintf(stderr,"CONFIG_%s\n",sym->name);
+                       return_value++;
+               }
+               return;
        case set_default:
                printf("%s\n", def);
                return;
@@ -337,6 +346,10 @@ static int conf_choice(struct menu *menu)
                        printf("?");
                printf("]: ");
                switch (input_mode) {
+               case dont_ask:
+                       cnt = def;
+                       printf("%d\n", cnt);
+                       break;
                case ask_new:
                case ask_silent:
                        if (!is_new) {
@@ -472,7 +485,10 @@ static void check_conf(struct menu *menu)
                        if (!conf_cnt++)
                                printf("*\n* Restart config...\n*\n");
                        rootEntry = menu_get_parent_menu(menu);
-                       conf(rootEntry);
+                       if (input_mode == dont_ask)
+                               fprintf(stderr,"CONFIG_%s\n",sym->name);
+                       else
+                               conf(rootEntry);
                }
                if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod)
                        return;
@@ -493,6 +509,9 @@ int main(int ac, char **av)
                case 'o':
                        input_mode = ask_new;
                        break;
+               case 'b':
+                       input_mode = dont_ask;
+                       break;
                case 's':
                        input_mode = ask_silent;
                        valid_stdin = isatty(0) && isatty(1) && isatty(2);
@@ -557,6 +576,7 @@ int main(int ac, char **av)
                }
        case ask_all:
        case ask_new:
+       case dont_ask:
                conf_read(NULL);
                break;
        default:
@@ -574,10 +594,10 @@ int main(int ac, char **av)
        do {
                conf_cnt = 0;
                check_conf(&rootmenu);
-       } while (conf_cnt);
+       } while ((conf_cnt) && (input_mode != dont_ask));
        if (conf_write(NULL)) {
                fprintf(stderr, "\n*** Error during writing of the kernel configuration.\n\n");
                return 1;
        }
-       return 0;
+       return return_value;
 }
diff --git a/scripts/kernel-2.6-planetlab.spec b/scripts/kernel-2.6-planetlab.spec
new file mode 100644 (file)
index 0000000..2b58d6e
--- /dev/null
@@ -0,0 +1,829 @@
+Summary: The Linux kernel (the core of the Linux operating system)
+
+# What parts do we want to build?  We must build at least one kernel.
+# These are the kernels that are built IF the architecture allows it.
+
+%define buildup 1
+%define buildsmp 0
+%define builduml 0
+%define buildsource 0
+%define builddoc 0
+
+
+# Versions of various parts
+
+#
+# Polite request for people who spin their own kernel rpms:
+# please modify the "release" field in a way that identifies
+# that the kernel isn't the stock distribution kernel, for example by
+# adding some text to the end of the version number.
+#
+%define sublevel 8
+%define kversion 2.6.%{sublevel}
+%define rpmversion 2.6.%{sublevel}
+%define rhbsys  %([ -r /etc/beehive-root ] && echo  || echo .`whoami`)
+%define release 1.521.2.planetlab%{?date:.%{date}}
+%define signmodules 0
+
+%define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE}
+
+# Override generic defaults with per-arch defaults 
+
+%define image_install_path boot
+
+#
+# Three sets of minimum package version requirements in the form of Conflicts:
+# to versions below the minimum
+#
+
+#
+# First the general kernel 2.6 required versions as per
+# Documentation/Changes
+#
+%define kernel_dot_org_conflicts  ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 1.0.3, e2fsprogs < 1.29, util-linux < 2.10, jfsutils < 1.0.14, reiserfsprogs < 3.6.3, xfsprogs < 2.1.0, procps < 2.0.9, oprofile < 0.5.3
+
+# 
+# Then a series of requirements that are distribution specific, either 
+# because we add patches for something, or the older versions have 
+# problems with the newer kernel or lack certain things that make 
+# integration in the distro harder than needed.
+#
+%define package_conflicts  cipe < 1.4.5, tux < 2.1.0, kudzu <= 0.92, initscripts < 7.23, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0
+
+#
+# Several packages had bugs in them that became obvious when the NPTL
+# threading code got integrated. 
+#
+%define nptl_conflicts SysVinit < 2.84-13, pam < 0.75-48, vixie-cron < 3.0.1-73, privoxy < 3.0.0-8, spamassassin < 2.44-4.8.x,  cups < 1.1.17-13
+
+#
+# Packages that need to be installed before the kernel is, because the %post
+# scripts use them.
+#
+%define kernel_prereq  fileutils, module-init-tools, initscripts >= 5.83, mkinitrd >= 3.5.5
+
+Vendor: PlanetLab
+Packager: PlanetLab Central <support@planet-lab.org>
+Distribution: PlanetLab 3.0
+URL: http://cvs.planet-lab.org/cvs/linux-2.6
+
+Name: kernel
+Group: System Environment/Kernel
+License: GPLv2
+Version: %{rpmversion}
+Release: %{release}
+ExclusiveOS: Linux
+Provides: kernel = %{version}
+Provides: kernel-drm = 4.3.0
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_dot_org_conflicts}
+Conflicts: %{package_conflicts}
+Conflicts: %{nptl_conflicts}
+# We can't let RPM do the dependencies automatic because it'll then pick up
+# a correct but undesirable perl dependency from the module headers which
+# isn't required for the kernel proper to function
+AutoReqProv: no
+
+#
+# List the packages used during the kernel build
+#
+BuildPreReq: module-init-tools, patch >= 2.5.4, bash >= 2.03, sh-utils, tar
+BuildPreReq: bzip2, findutils, gzip, m4, perl, make >= 3.78, gnupg
+#BuildPreReq: kernel-utils >= 1:2.4-12.1.142
+BuildRequires: gcc >= 2.96-98, binutils >= 2.12, redhat-rpm-config
+BuildConflicts: rhbuildsys(DiskFree) < 500Mb
+BuildArchitectures: i686
+
+
+
+Source0: ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-%{kversion}.tar.bz2
+
+BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
+
+%description 
+The kernel package contains the Linux kernel (vmlinuz), the core of any
+Linux operating system.  The kernel handles the basic functions
+of the operating system:  memory allocation, process allocation, device
+input and output, etc.
+
+
+%package sourcecode
+Summary: The source code for the Linux kernel.
+Group: Development/System
+Prereq: fileutils
+Requires: make >= 3.78
+Requires: gcc >= 3.2
+Requires: /usr/bin/strip
+# for xconfig and gconfig
+Requires: qt-devel, gtk2-devel readline-devel ncurses-devel
+Provides: kernel-source
+Obsoletes: kernel-source <= 2.6.6
+
+%description sourcecode
+The kernel-sourcecode package contains the source code files for the Linux
+kernel. The source files can be used to build a custom kernel that is
+smaller by virtue of only including drivers for your particular hardware, if
+you are so inclined (and you know what you're doing). The customisation
+guide in the documentation describes in detail how to do this. This package
+is neither needed nor usable for building external kernel modules for
+linking such modules into the default operating system kernels.
+
+%package doc
+Summary: Various documentation bits found in the kernel source.
+Group: Documentation
+%if !%{buildsource}
+Obsoletes: kernel-source <= 2.6.6
+Obsoletes: kernel-sourcecode <= 2.6.6
+%endif
+
+%description doc
+This package contains documentation files from the kernel
+source. Various bits of information about the Linux kernel and the
+device drivers shipped with it are documented in these files. 
+
+You'll want to install this package if you need a reference to the
+options that can be passed to Linux kernel modules at load time.
+
+
+%package smp
+Summary: The Linux kernel compiled for SMP machines.
+
+Group: System Environment/Kernel
+Provides: kernel = %{version}
+Provides: kernel-drm = 4.3.0
+Prereq: %{kernel_prereq}
+Conflicts: %{kernel_dot_org_conflicts}
+Conflicts: %{package_conflicts}
+Conflicts: %{nptl_conflicts}
+# upto and including kernel 2.4.9 rpms, the 4Gb+ kernel was called kernel-enterprise
+# now that the smp kernel offers this capability, obsolete the old kernel
+Obsoletes: kernel-enterprise < 2.4.10
+# We can't let RPM do the dependencies automatic because it'll then pick up
+# a correct but undesirable perl dependency from the module headers which
+# isn't required for the kernel proper to function
+AutoReqProv: no
+
+%description smp
+This package includes a SMP version of the Linux kernel. It is
+required only on machines with two or more CPUs as well as machines with
+hyperthreading technology.
+
+Install the kernel-smp package if your machine uses two or more CPUs.
+
+%package uml
+Summary: The Linux kernel compiled for use in user mode (User Mode Linux).
+
+Group: System Environment/Kernel
+
+%description uml
+This package includes a user mode version of the Linux kernel.
+
+%package vserver
+Summary: A placeholder RPM that provides kernel and kernel-drm
+
+Group: System Environment/Kernel
+Provides: kernel = %{version}
+Provides: kernel-drm = 4.3.0
+
+%description vserver
+VServers do not require and cannot use kernels, but some RPMs have
+implicit or explicit dependencies on the "kernel" package
+(e.g. tcpdump). This package installs no files but provides the
+necessary dependencies to make rpm and yum happy.
+
+%prep
+
+%setup -n linux-%{kversion}
+
+# make sure the kernel has the sublevel we know it has. This looks weird
+# but for -pre and -rc versions we need it since we only want to use
+# the higher version when the final kernel is released.
+perl -p -i -e "s/^SUBLEVEL.*/SUBLEVEL = %{sublevel}/" Makefile
+perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -prep/" Makefile
+
+# get rid of unwanted files resulting from patch fuzz
+find . -name "*.orig" -exec rm -fv {} \;
+find . -name "*~" -exec rm -fv {} \;
+
+###
+### build
+###
+%build
+
+BuildKernel() {
+
+    # Pick the right config file for the kernel we're building
+    if [ -n "$1" ] ; then
+       Config=kernel-%{kversion}-%{_target_cpu}-$1-planetlab.config
+    else
+       Config=kernel-%{kversion}-%{_target_cpu}-planetlab.config
+    fi
+
+    KernelVer=%{version}-%{release}$1
+    echo BUILDING A KERNEL FOR $1 %{_target_cpu}...
+
+    # make sure EXTRAVERSION says what we want it to say
+    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}$1/" Makefile
+
+    # override ARCH in the case of UML
+    if [ "$1" = "uml" ] ; then
+        export ARCH=um
+    fi
+
+    # and now to start the build process
+
+    make -s mrproper
+    cp configs/$Config .config
+
+    make -s nonint_oldconfig > /dev/null
+    make -s include/linux/version.h 
+
+    make -s %{?_smp_mflags} bzImage 
+    make -s %{?_smp_mflags} modules || exit 1
+    make buildcheck
+    
+    # Start installing the results
+
+    mkdir -p $RPM_BUILD_ROOT/usr/lib/debug/boot
+    mkdir -p $RPM_BUILD_ROOT/%{image_install_path}
+    install -m 644 System.map $RPM_BUILD_ROOT/usr/lib/debug/boot/System.map-$KernelVer
+    objdump -t vmlinux | grep ksymtab | cut -f2 | cut -d" " -f2 | cut -c11- | sort -u  > exported
+    echo "_stext" >> exported
+    echo "_end" >> exported
+    touch $RPM_BUILD_ROOT/boot/System.map-$KernelVer
+    for i in `cat exported` 
+    do 
+        grep " $i\$" System.map >> $RPM_BUILD_ROOT/boot/System.map-$KernelVer || :
+        grep "tab_$i\$" System.map >> $RPM_BUILD_ROOT/boot/System.map-$KernelVer || :
+        grep "__crc_$i\$" System.map >> $RPM_BUILD_ROOT/boot/System.map-$KernelVer ||:
+    done
+    rm -f exported
+#    install -m 644 init/kerntypes.o $RPM_BUILD_ROOT/boot/Kerntypes-$KernelVer
+    install -m 644 .config $RPM_BUILD_ROOT/boot/config-$KernelVer
+    rm -f System.map
+    cp arch/*/boot/bzImage $RPM_BUILD_ROOT/%{image_install_path}/vmlinuz-$KernelVer
+
+    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer
+    make -s INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer
+    # And save the headers/makefiles etc for building modules against
+    #
+    # This all looks scary, but the end result is supposed to be:
+    # * all arch relevant include/ files
+    # * all Makefile/Kconfig files
+    # * all script/ files 
+
+    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+    # first copy everything
+    cp --parents `find  -type f -name Makefile -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build 
+    cp Module.symvers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+    # then drop all but the needed Makefiles/Kconfig files
+    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Documentation
+    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts
+    rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
+    cp arch/%{_arch}/kernel/asm-offsets.s $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/kernel || :
+    cp .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+    cp -a scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+    cp -a arch/%{_arch}/scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch} || :
+    cp -a arch/%{_arch}/*lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/ || :
+    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*.o
+    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*/*.o
+    mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
+    cd include
+    cp -a acpi config linux math-emu media net pcmcia rxrpc scsi sound video asm asm-generic $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
+    cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
+    # Make sure the Makefile and version.h have a matching timestamp so that
+    # external modules can be built
+    touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Makefile $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/version.h
+    touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/autoconf.h
+    cd .. 
+
+    #
+    # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm
+    #
+    mkdir -p $RPM_BUILD_ROOT/usr/lib/debug/lib/modules/$KernelVer
+    cp vmlinux $RPM_BUILD_ROOT/usr/lib/debug/lib/modules/$KernelVer
+
+    # mark modules executable so that strip-to-file can strip them
+    find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" -type f  | xargs chmod u+x
+
+    # detect missing or incorrect license tags
+    for i in `find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" ` ; do echo -n "$i " ; /sbin/modinfo -l $i >> modinfo ; done
+    cat modinfo | grep -v "^GPL" | grep -v "^Dual BSD/GPL" | grep -v "^Dual MPL/GPL" | grep -v "^GPL and additional rights" | grep -v "^GPL v2" && exit 1 
+    rm -f modinfo
+    # remove files that will be auto generated by depmod at rpm -i time
+    rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.*
+
+}
+
+###
+# DO it...
+###
+
+# prepare directories
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/boot
+
+%if %{buildup}
+BuildKernel
+%endif
+
+%if %{buildsmp}
+BuildKernel smp
+%endif
+
+%if %{builduml}
+BuildKernel uml
+%endif
+
+###
+### install
+###
+
+%install
+
+# architectures that don't get kernel-source (i586/i686/athlon) dont need
+# much of an install because the build phase already copied the needed files
+
+%if %{builddoc}
+mkdir -p $RPM_BUILD_ROOT/usr/share/doc/kernel-doc-%{kversion}/Documentation
+
+# sometimes non-world-readable files sneak into the kernel source tree
+chmod -R a+r *
+# copy the source over
+tar cf - Documentation | tar xf - -C $RPM_BUILD_ROOT/usr/share/doc/kernel-doc-%{kversion}
+%endif
+
+%if %{buildsource}
+
+mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+chmod -R a+r *
+
+# clean up the source tree so that it is ready for users to build their own
+# kernel
+make -s mrproper
+# copy the source over
+tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+
+# set the EXTRAVERSION to <version>custom, so that people who follow a kernel building howto
+# don't accidentally overwrite their currently working moduleset and hose
+# their system
+perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
+
+# some config options may be appropriate for an rpm kernel build but are less so for custom user builds,
+# change those to values that are more appropriate as defeault for people who build their own kernel.
+perl -p -i -e "s/^CONFIG_DEBUG_INFO.*/# CONFIG_DEBUG_INFO is not set/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs/*
+perl -p -i -e "s/^.*CONFIG_DEBUG_PAGEALLOC.*/# CONFIG_DEBUG_PAGEALLOC is not set/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs/*
+perl -p -i -e "s/^.*CONFIG_DEBUG_SLAB.*/# CONFIG_DEBUG_SLAB is not set/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs/*
+perl -p -i -e "s/^.*CONFIG_DEBUG_SPINLOCK.*/# CONFIG_DEBUG_SPINLOCK is not set/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs/*
+perl -p -i -e "s/^.*CONFIG_DEBUG_HIGHMEM.*/# CONFIG_DEBUG_HIGHMEM is not set/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs/*
+perl -p -i -e "s/^.*CONFIG_MODULE_SIG.*/# CONFIG_MODULE_SIG is not set/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs/*
+
+install -m 644 %{SOURCE10}  $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
+%endif
+
+###
+### clean
+###
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+###
+### scripts
+###
+
+# load the loop module for upgrades...in case the old modules get removed we have
+# loopback in the kernel so that mkinitrd will work.
+%pre 
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+exit 0
+
+%pre smp
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+exit 0
+
+%post 
+# trick mkinitrd in case the current environment does not have device mapper
+rootdev=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' /etc/fstab)
+if echo $rootdev |grep -q /dev/mapper 2>/dev/null ; then
+    if [ ! -f $rootdev ]; then
+       fake_root_lvm=1
+       mkdir -p $(dirname $rootdev)
+       touch $rootdev
+    fi
+fi
+[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}
+if [ -n "$fake_root_lvm" ]; then
+    rm -f $rootdev
+fi
+if [ -x /usr/sbin/hardlink ] ; then
+pushd /lib/modules/%{KVERREL}/build > /dev/null ; {
+       cd /lib/modules/%{KVERREL}/build
+       find . -type f | while read f; do hardlink -c /lib/modules/*/build/$f $f ; done
+}
+popd
+fi
+
+# make some useful links
+pushd /boot > /dev/null ; {
+       ln -sf System.map-%{KVERREL} System.map
+#      ln -sf Kerntypes-%{KVERREL} Kerntypes
+       ln -sf config-%{KVERREL} config
+       ln -sf initrd-%{KVERREL}.img initrd-boot
+       ln -sf vmlinuz-%{KVERREL} kernel-boot
+}
+popd
+
+# ask for a reboot
+mkdir -p /etc/planetlab
+touch /etc/planetlab/update-reboot
+
+%post smp
+[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}smp
+if [ -x /usr/sbin/hardlink ] ; then
+pushd /lib/modules/%{KVERREL}smp/build > /dev/null ; {
+       cd /lib/modules/%{KVERREL}smp/build
+       find . -type f | while read f; do hardlink -c /lib/modules/*/build/$f $f ; done
+}
+popd
+fi
+
+
+%preun 
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}
+
+%preun smp
+/sbin/modprobe loop 2> /dev/null > /dev/null  || :
+[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}smp
+
+
+###
+### file lists
+###
+
+%if %{buildup}
+%files 
+%defattr(-,root,root)
+/%{image_install_path}/vmlinuz-%{KVERREL}
+#/boot/Kerntypes-%{KVERREL}
+/boot/System.map-%{KVERREL}
+/boot/config-%{KVERREL}
+%dir /lib/modules/%{KVERREL}
+/lib/modules/%{KVERREL}/kernel
+%verify(not mtime) /lib/modules/%{KVERREL}/build
+
+%endif
+
+%if %{buildsmp}
+%files smp
+%defattr(-,root,root)
+/%{image_install_path}/vmlinuz-%{KVERREL}smp
+#/boot/Kerntypes-%{KVERREL}smp
+/boot/System.map-%{KVERREL}smp
+/boot/config-%{KVERREL}smp
+%dir /lib/modules/%{KVERREL}smp
+/lib/modules/%{KVERREL}smp/kernel
+%verify(not mtime) /lib/modules/%{KVERREL}smp/build
+
+%endif
+
+%if %{builduml}
+%files uml
+%defattr(-,root,root)
+
+%endif
+
+# only some architecture builds need kernel-source and kernel-doc
+
+%if %{buildsource}
+%files sourcecode
+%defattr(-,root,root)
+/usr/src/linux-%{KVERREL}/
+%endif
+
+
+%if %{builddoc}
+%files doc
+%defattr(-,root,root)
+/usr/share/doc/kernel-doc-%{kversion}/Documentation/*
+%endif
+
+
+%files vserver
+%defattr(-,root,root)
+# no files
+
+%changelog
+* Thu Sep 16 2004 Mark Huang <mlhuang@cs.princeton.edu>
+- merge to Fedora Core 2 2.6.8-1.521
+
+* Tue Aug 31 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix execshield buglet with legacy binaries
+- 2.6.9-rc1-bk7
+
+* Mon Aug 30 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.9-rc1-bk6
+
+* Sat Aug 28 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.9-rc1-bk4, now with i915 DRM driver
+
+* Fri Aug 27 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.9-rc1-bk2 
+
+* Mon Aug 23 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.8.1-bk2
+
+* Sat Aug 21 2004 Arjan van de Ven <arjanv@redhat.com>
+- attempt to fix early-udev bug
+
+* Fri Aug 13 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.8-rc4-bk3
+- split execshield up some more
+
+* Fri Aug 13 2004 Dave Jones <davej@redhat.com>
+- Update SCSI whitelist again with some more card readers.
+
+* Mon Aug 9 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.8-rc3-bk3
+
+* Thu Aug  5 2004 Mark Huang <mlhuang@cs.princeton.edu>
+- adapt for Fedora Core 2 based PlanetLab 3.0 (remove Source and Patch
+  sections, most non-x86 sections, and GPG sections)
+
+* Wed Aug 4 2004 Arjan van de Ven <arjanv@redhat.com>
+- Add the flex-mmap bits for s390/s390x (Pete Zaitcev)
+- Add flex-mmap for x86-64 32 bit emulation
+- 2.6.8-rc3
+
+* Mon Aug 2 2004 Arjan van de Ven <arjanv@redhat.com>
+- Add Rik's token trashing control patch
+
+* Sun Aug 1 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.8-rc2-bk11
+
+* Fri Jul 30 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.8-rc2-bk8
+
+* Wed Jul 28 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.8-rc2-bk6
+- make a start at splitting up the execshield patchkit
+
+* Fri Jul 16 2004 Arjan van de Ven <arjanv@redhat.com>
+- ppc32 embedded updates
+
+* Thu Jul 15 2004 Arjan van de Ven <arjanv@redhat.com>
+- make USB modules again and add Alan's real fix for the SMM-meets-USB bug
+- 2.6.8-rc1-bk4
+
+* Wed Jul 14 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.8-rc1-bk3
+
+* Tue Jul 13 2004 Arjan van de Ven <arjanv@redhat.com>
+- add "enforcemodulesig" boot option to make the kernel load signed modules only
+
+* Mon Jul 12 2004 Arjan van de Ven <arjanv@redhat.com>
+- updated voluntary preempt
+- 2.6.8-rc1
+
+* Wed Jul 7 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix boot breakage that was hitting lots of people (Dave Jones)
+
+* Tue Jul 6 2004 Arjan van de Ven <arjanv@redhat.com>
+- add voluntary preemption patch from Ingo
+- 2.6.7-bk19
+
+* Tue Jun 29 2004 Arjan van de Ven <arjanv@redhat.com>
+- make a start at gpg signed modules support
+
+* Sat Jun 27 2004 Arjan van de Ven <arjanv@redhat.com>
+- experiment with making the hardlink call in post more efficient
+- 2.6.7-bk9
+
+* Thu Jun 24 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.7-bk7
+- Add wli's patch to allocate memory bottom up not top down
+- change some config options in the kernel-sourcecode package that are
+  good for rpm kernel builds but not for custom user builds to more appropriate 
+  default values.
+- reenable kernel-sourcecode again for a few builds 
+
+* Wed Jun 23 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.7-bk5
+- fix tux unresolved symbols (#126532)
+
+* Mon Jun 21 2004 Arjan van de Ven <arjanv@redhat.com>
+- make kernel-doc and kernel-sourcecode builds independent of eachother
+- disable kernel-sourcecode builds entirely, we'll be replacing it with documentation
+  on how to use the src.rpm instead for building your own kernel.
+
+* Sat Jun 19 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.7-bk2
+
+* Sun Jun 13 2004 Arjan van de Ven <arjanv@redhat.com>
+- add patch from DaveM to fix the ppp-keeps-iface-busy bug
+
+* Sat Jun 12 2004 Arjan van de Ven <arjanv@redhat.com>
+- add fix from Andi Kleen/Linus for the fpu-DoS
+
+* Thu Jun 10 2004 Arjan van de Ven <arjanv@redhat.com>
+- disable mlock-uses-rlimit patch, it has a security hole and needs more thought
+- revert airo driver to the FC2 one since the new one breaks
+
+* Tue Jun 8 2004 Dave Jones <davej@redhat.com>
+- Update to 2.6.7rc3
+
+* Fri Jun 4 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix the mlock-uses-rlimit patch
+
+* Wed Jun 2 2004 David Woodhouse <dwmw2@redhat.com>
+- Add ppc64 (Mac G5)
+
+* Wed Jun 2 2004 Arjan van de Ven <arjanv@redhat.com>
+- add a forward port of the mlock-uses-rlimit patch
+- add NX support for x86 (Intel, Ingo)
+
+* Tue Jun 1 2004 Arjan van de Ven <arjanv@redhat.com>
+- refresh ext3 reservation patch
+
+* Sun May 30 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.7-rc2
+- set the ACPI OS name to "Microsoft Windows XP" for better compatibility
+
+* Thu May 27 2004 Pete Zaitcev <zaitcev@redhat.com>
+- Fix qeth and zfcp (s390 drivers): align qib by 256, embedded into qdio_irq.
+
+* Thu May 27 2004 Dave Jones <davej@redhat.com>
+- Fix the crashes on boot on Asus P4P800 boards. (#121819)
+
+* Wed May 26 2004 Dave Jones <davej@redhat.com>
+- Lots more updates to the SCSI whitelist for various
+  USB card readers. (#112778, among others..)
+
+* Wed May 26 2004 Arjan van de Ven <arjanv@redhat.com>
+- back out ehci suspend/resume patch, it breaks
+- add fix for 3c59x-meets-kudzu bug from Alan
+
+* Tue May 25 2004 Arjan van de Ven <arjanv@redhat.com>
+- try improving suspend/resume by restoring more PCI state
+- 2.6.7-rc1-bk1
+
+* Mon May 24 2004 Dave Jones <davej@redhat.com>
+- Add yet another multi-card reader to the whitelist (#85851)
+
+* Sun May 23 2004 Dave Jones <davej@redhat.com>
+- Add another multi-card reader to the whitelist (#124048)
+
+* Wed May 19 2004 Arjan van de Ven <arjanv@redhat.com>
+- put firewire race fix in (datacorruptor)
+
+* Tue May 18 2004 Dave Jones <davej@redhat.com>
+- Fix typo in ibmtr driver preventing compile (#123391)
+
+* Mon May 17 2004 Arjan van de Ven <arjanv@redhat.com>
+- update to 2.6.6-bk3
+- made kernel-source and kernel-doc noarch.rpm's since they are not
+  architecture specific.
+
+* Sat May 08 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix non-booting on Transmeta cpus (Peter Anvin)
+- fix count leak in message queues
+
+* Fri May 07 2004 Arjan van de Ven <arjanv@redhat.com>
+- more ide cache flush work
+- patch from scsi-bk to fix sd refcounting
+
+* Thu May 06 2004 Arjan van de Ven <arjanv@redhat.com>
+- some more ide cache flush fixes 
+
+* Wed May 05 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix bug 122504
+- convert b44 to ethtool ops (jgarzik)
+- make IDE do a cache-flush on shutdown (me/Alan)
+
+* Tue May 04 2004 Arjan van de Ven <arjanv@redhat.com>
+- work around i810/i830 DRM issue
+
+* Fri Apr 30 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.6-rc3-bk1
+- make amd64 boot again
+- fix vm86-vs-4g4g interaction (Ingo)
+
+* Thu Apr 22 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.6-rc2
+* Tue Apr 20 2004 Arjan van de Ven <arjanv@redhat.com>
+- add the ext3 online resize patch
+
+* Mon Apr 19 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.6-rc1-bk3
+- add the objrmap vm from the -mm tree; it needs testing
+
+* Thu Apr 15 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-bk2
+- disable DISCONTIGMEM on ia64 for performance
+- fix sleep_on use in reiserfs (Chris Mason)
+
+* Tue Apr 13 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-mc4
+- reenable sg driver for scsi tape changers and such
+- the sk98lin driver oopses on module unload, preven that
+
+* Mon Apr 12 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix "bad pmd" bug with patch from Ingo
+
+* Fri Apr 09 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-mc3
+- finish up the -mc2 merge
+- latest 4g/4g patch from Ingo
+- latest execshield patch from Ingo
+- fix a few framebuffer bugs
+
+* Thu Apr 08 2004 Arjan van de Ven <arjanv@redhat.com>
+- first attempt at a 2.6.5-mc2 merge
+
+* Thu Apr 08 2004 Dave Jones <davej@redhat.com>
+- Add in missing SiS AGP fix.
+
+* Tue Apr 06 2004 Dave Jones <davej@redhat.com>
+- More agpgart fixes.
+
+* Fri Apr 02 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix another 4g/4g-vs-resume bug
+
+* Tue Mar 30 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-rc3
+- fix PCI posting bug in i830 DRM
+
+* Mon Mar 29 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-rc2-bk8
+
+* Mon Mar 29 2004 Dave Jones <davej@redhat.com>
+- Include latest agpgart fixes.
+
+* Thu Mar 25 2004 Arjan van de Ven <arjanv@redhat.com>
+- more DRM fixes
+- add the fsync patches from akpm
+
+* Tue Mar 23 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-rc2-bk3
+- fix direct userspace memory access in i830 drm driver
+
+* Mon Mar 22 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-rc2-bk2
+- some stackbloat reductions from Dave and me
+
+* Sat Mar 20 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.5-rc2
+
+* Tue Mar 16 2004 Dave Jones <davej@redhat.com>
+- 2.6.5-rc1
+
+* Mon Mar 15 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.4-bk3
+- fix oops in toshiba_acpi (Barry K. Nathan)
+
+* Sat Mar 13 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.4-bk2 merge 
+
+* Thu Mar 11 2004 Arjan van de Ven <arjanv@redhat.com>
+- renable sonypi driver that was off accidentally
+- 2.6.4-final 
+- fix the oops on alsa module unloads
+
+* Wed Mar 10 2004 Arjan van de Ven <arjanv@redhat.com>
+- add ppc64/iseries, ppc32 (powermac/ibook) and ia64 architectures
+- 2.6.4-rc3 
+
+* Tue Mar 09 2004 Arjan van de Ven <arjanv@redhat.com>
+- 2.6.4-rc2-bk5
+- fix nfs-vs-selinux issue
+- fix typo in URL as per #117849
+
+* Mon Mar 08 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix race in lp.c (#117710)
+- 2.6.4-rc2-bk3
+- attempt to fix S3 suspend-to-ram with 4g/4g split
+
+* Sat Mar 06 2004 Arjan van de Ven <arjanv@redhat.com>
+- fix reiserfs
+- set HZ to 1000 again for some tests
+
+* Wed Feb 25 2004 Arjan van de Ven <arjanv@redhat.com>
+- merge back a bunch of fedora fixes
+- disable audit
+
+* Tue Feb 24 2004 Arjan van de Ven <arjanv@redhat.com>
+- audit bugfixes
+- update tux to a working version
+- 2.6.3-bk5 merge
+
+* Fri Feb 20 2004 Arjan van de Ven <arjanv@redhat.com>
+- re-add and enable the Auditing patch
+- switch several cpufreq modules to built in since detecting in userspace
+  which to use is unpleasant
+* Thu Jul 03 2003 Arjan van de Ven <arjanv@redhat.com>
+- 2.6 start 
diff --git a/scripts/mk_elfconfig.c b/scripts/mk_elfconfig.c
deleted file mode 100644 (file)
index de2aabf..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <elf.h>
-
-int
-main(int argc, char **argv)
-{
-       unsigned char ei[EI_NIDENT];    
-       union { short s; char c[2]; } endian_test;
-
-       if (argc != 2) {
-               fprintf(stderr, "Error: no arch\n");
-       }
-       if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
-               fprintf(stderr, "Error: input truncated\n");
-               return 1;
-       }
-       if (memcmp(ei, ELFMAG, SELFMAG) != 0) {
-               fprintf(stderr, "Error: not ELF\n");
-               return 1;
-       }
-       switch (ei[EI_CLASS]) {
-       case ELFCLASS32:
-               printf("#define KERNEL_ELFCLASS ELFCLASS32\n");
-               break;
-       case ELFCLASS64:
-               printf("#define KERNEL_ELFCLASS ELFCLASS64\n");
-               break;
-       default:
-               abort();
-       }
-       switch (ei[EI_DATA]) {
-       case ELFDATA2LSB:
-               printf("#define KERNEL_ELFDATA ELFDATA2LSB\n");
-               break;
-       case ELFDATA2MSB:
-               printf("#define KERNEL_ELFDATA ELFDATA2MSB\n");
-               break;
-       default:
-               abort();
-       }
-
-       if (sizeof(unsigned long) == 4) {
-               printf("#define HOST_ELFCLASS ELFCLASS32\n");
-       } else if (sizeof(unsigned long) == 8) {
-               printf("#define HOST_ELFCLASS ELFCLASS64\n");
-       }
-
-       endian_test.s = 0x0102;
-       if (memcmp(endian_test.c, "\x01\x02", 2) == 0)
-               printf("#define HOST_ELFDATA ELFDATA2MSB\n");
-       else if (memcmp(endian_test.c, "\x02\x01", 2) == 0)
-               printf("#define HOST_ELFDATA ELFDATA2LSB\n");
-       else
-               abort();
-
-       if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0))
-               printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
-       else 
-               printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
-
-       return 0;
-}
-
index 8d118d1..1357c29 100755 (executable)
@@ -33,7 +33,7 @@ UTS_VERSION="$UTS_VERSION `LC_ALL=C LANG=C date`"
 
 UTS_LEN=64
 UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"
-
+LINUX_COMPILE_VERSION_ID="__linux_compile_version_id__`hostname | tr -c '[0-9A-Za-z\n]' '__'`_`LANG=C date | tr -c '[0-9A-Za-z\n]' '_'`"
 # Generate a temporary compile.h
 
 ( echo /\* This file is auto generated, version $VERSION \*/
@@ -43,8 +43,8 @@ UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"
   echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
 
   echo \#define LINUX_COMPILE_TIME \"`LC_ALL=C LANG=C date +%T`\"
-  echo \#define LINUX_COMPILE_BY \"`whoami`\"
-  echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
+  echo \#define LINUX_COMPILE_BY \"support\"
+  echo \#define LINUX_COMPILE_HOST \"planet-lab.org\"
 
   if [ -x /bin/dnsdomainname ]; then
     echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\"
@@ -55,6 +55,8 @@ UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"
   fi
 
   echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
+  echo \#define LINUX_COMPILE_VERSION_ID $LINUX_COMPILE_VERSION_ID
+  echo \#define LINUX_COMPILE_VERSION_ID_TYPE typedef char* "$LINUX_COMPILE_VERSION_ID""_t"
 ) > .tmpcompile
 
 # Only replace the real compile.h if the new one is different,
diff --git a/scripts/mkconfigs b/scripts/mkconfigs
deleted file mode 100755 (executable)
index a316627..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2002 Khalid Aziz <khalid_aziz@hp.com>
-# Copyright (C) 2002 Randy Dunlap <rddunlap@osdl.org>
-# Copyright (C) 2002 Al Stone <ahs3@fc.hp.com>
-# Copyright (C) 2002 Hewlett-Packard Company
-#
-#   This program is free software; you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this program; if not, write to the Free Software
-#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# 
-# Rules to generate ikconfig.h from linux/.config:
-#      - Retain lines that begin with "CONFIG_"
-#      - Retain lines that begin with "# CONFIG_"
-#      - lines that use double-quotes must \\-escape-quote them
-
-if [ $# -lt 2 ]
-then
-       echo "Usage: `basename $0` <configuration_file> <Makefile>"
-       exit 1
-fi
-
-config=$1
-makefile=$2
-
-echo "#ifndef _IKCONFIG_H"
-echo "#define _IKCONFIG_H"
-echo \
-"/*
- * 
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- * 
- * This file is generated automatically by scripts/mkconfigs. Do not edit.
- *
- */"
-
-echo "static char const ikconfig_config[] __attribute__((unused)) = "
-echo "\"CONFIG_BEGIN=n\\n\\"
-echo "`cat $config | sed 's/\"/\\\\\"/g' | grep "^#\? \?CONFIG_" | awk '{ print $0 "\\\\n\\\\" }' `"
-echo "CONFIG_END=n\\n\";"
-echo "#endif /* _IKCONFIG_H */"
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
deleted file mode 100644 (file)
index c4d621b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-# Generates a small Makefile used in the root of the output
-# directory, to allow make to be started from there.
-# The Makefile also allow for more convinient build of external modules
-
-# Usage
-# $1 - Kernel src directory
-# $2 - Output directory
-# $3 - version
-# $4 - patchlevel
-
-
-cat << EOF
-# Automatically generated by $0: don't edit
-
-VERSION = $3
-PATCHLEVEL = $4
-
-KERNELSRC    := $1
-KERNELOUTPUT := $2
-
-MAKEFLAGS += --no-print-directory
-
-all:
-       \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
-
-%::
-       \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
-
-EOF
-
diff --git a/scripts/mkspec b/scripts/mkspec
deleted file mode 100755 (executable)
index e644296..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-#
-#      Output a simple RPM spec file that uses no fancy features requring
-#      RPM v4. This is intended to work with any RPM distro.
-#
-#      The only gothic bit here is redefining install_post to avoid 
-#      stripping the symbols from files in the kernel which we want
-#
-#      Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
-#
-# That's the voodoo to see if it's a x86.
-ISX86=`echo ${ARCH:=\`arch\`} | grep -ie i.86`
-if [ ! -z $ISX86 ]; then
-       PC=1
-else
-       PC=0
-fi
-# starting to output the spec
-if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
-       PROVIDES=kernel-drm
-fi
-
-PROVIDES="$PROVIDES kernel-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-
-echo "Name: kernel"
-echo "Summary: The Linux Kernel"
-echo "Version: "$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION | sed -e "s/-//g"
-# we need to determine the NEXT version number so that uname and
-# rpm -q will agree
-echo "Release: `. $srctree/scripts/mkversion`"
-echo "License: GPL"
-echo "Group: System Environment/Kernel"
-echo "Vendor: The Linux Community"
-echo "URL: http://www.kernel.org"
-echo -n "Source: kernel-$VERSION.$PATCHLEVEL.$SUBLEVEL"
-echo "$EXTRAVERSION.tar.gz" | sed -e "s/-//g"
-echo "BuildRoot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root"
-echo "Provides: $PROVIDES"
-echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
-echo "%define debug_package %{nil}"
-echo ""
-echo "%description"
-echo "The Linux Kernel, the operating system core itself"
-echo ""
-echo "%prep"
-echo "%setup -q"
-echo ""
-echo "%build"
-echo "make clean all"
-echo ""
-echo "%install"
-echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'
-echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make modules_install'
-# This is the first disagreement between i386 and most others
-if [ $PC = 1 ]; then
-       echo 'cp arch/i386/boot/bzImage $RPM_BUILD_ROOT'"/boot/vmlinuz-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-else
-       echo 'cp vmlinux $RPM_BUILD_ROOT'"/boot/vmlinux-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-fi
-# Back on track
-echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo ""
-echo "%clean"
-echo '#echo -rf $RPM_BUILD_ROOT'
-echo ""
-echo "%files"
-echo '%defattr (-, root, root)'
-echo "%dir /lib/modules"
-echo "/lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo "/boot/*"
-echo ""
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
deleted file mode 100644 (file)
index f66bf52..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-host-progs     := modpost mk_elfconfig
-always         := $(host-progs) empty.o
-
-modpost-objs   := modpost.o file2alias.o sumversion.o
-
-# dependencies on generated files need to be listed explicitly
-
-$(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
-
-quiet_cmd_elfconfig = MKELF   $@
-      cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
-
-$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
-       $(call if_changed,elfconfig)
-
-targets += elfconfig.h
diff --git a/scripts/mod/empty.c b/scripts/mod/empty.c
deleted file mode 100644 (file)
index 49839cc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/* empty file to figure out endianness / word size */
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
deleted file mode 100644 (file)
index f38c6d7..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/* Simple code to turn various tables in an ELF file into alias definitions.
- * This deals with kernel datastructures where they should be
- * dealt with: in the kernel source.
- *
- * Copyright 2002-2003  Rusty Russell, IBM Corporation
- *           2003       Kai Germaschewski
- *           
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- */
-
-#include "modpost.h"
-
-/* We use the ELF typedefs, since we can't rely on stdint.h being present. */
-
-#if KERNEL_ELFCLASS == ELFCLASS32
-typedef Elf32_Addr     kernel_ulong_t;
-#else
-typedef Elf64_Addr     kernel_ulong_t;
-#endif
-
-typedef Elf32_Word     __u32;
-typedef Elf32_Half     __u16;
-typedef unsigned char  __u8;
-
-/* Big exception to the "don't include kernel headers into userspace, which
- * even potentially has different endianness and word sizes, since 
- * we handle those differences explicitly below */
-#include "../../include/linux/mod_devicetable.h"
-
-#define ADD(str, sep, cond, field)                              \
-do {                                                            \
-        strcat(str, sep);                                       \
-        if (cond)                                               \
-                sprintf(str + strlen(str),                      \
-                        sizeof(field) == 1 ? "%02X" :           \
-                        sizeof(field) == 2 ? "%04X" :           \
-                        sizeof(field) == 4 ? "%08X" : "",       \
-                        field);                                 \
-        else                                                    \
-                sprintf(str + strlen(str), "*");                \
-} while(0)
-
-/* Looks like "usb:vNpNdlNdhNdcNdscNdpNicNiscNipN" */
-static int do_usb_entry(const char *filename,
-                       struct usb_device_id *id, char *alias)
-{
-       id->match_flags = TO_NATIVE(id->match_flags);
-       id->idVendor = TO_NATIVE(id->idVendor);
-       id->idProduct = TO_NATIVE(id->idProduct);
-       id->bcdDevice_lo = TO_NATIVE(id->bcdDevice_lo);
-       id->bcdDevice_hi = TO_NATIVE(id->bcdDevice_hi);
-
-       /*
-        * Some modules (visor) have empty slots as placeholder for
-        * run-time specification that results in catch-all alias
-        */
-       if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
-               return 1;
-
-       strcpy(alias, "usb:");
-       ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
-           id->idVendor);
-       ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
-           id->idProduct);
-       ADD(alias, "dl", id->match_flags&USB_DEVICE_ID_MATCH_DEV_LO,
-           id->bcdDevice_lo);
-       ADD(alias, "dh", id->match_flags&USB_DEVICE_ID_MATCH_DEV_HI,
-           id->bcdDevice_hi);
-       ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
-           id->bDeviceClass);
-       ADD(alias, "dsc",
-           id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
-           id->bDeviceSubClass);
-       ADD(alias, "dp",
-           id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
-           id->bDeviceProtocol);
-       ADD(alias, "ic",
-           id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
-           id->bInterfaceClass);
-       ADD(alias, "isc",
-           id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
-           id->bInterfaceSubClass);
-       ADD(alias, "ip",
-           id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
-           id->bInterfaceProtocol);
-       return 1;
-}
-
-/* Looks like: ieee1394:venNmoNspNverN */
-static int do_ieee1394_entry(const char *filename,
-                            struct ieee1394_device_id *id, char *alias)
-{
-       id->match_flags = TO_NATIVE(id->match_flags);
-       id->vendor_id = TO_NATIVE(id->vendor_id);
-       id->model_id = TO_NATIVE(id->model_id);
-       id->specifier_id = TO_NATIVE(id->specifier_id);
-       id->version = TO_NATIVE(id->version);
-
-       strcpy(alias, "ieee1394:");
-       ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
-           id->vendor_id);
-       ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
-           id->model_id);
-       ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
-           id->specifier_id);
-       ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
-           id->version);
-
-       return 1;
-}
-
-/* Looks like: pci:vNdNsvNsdNbcNscNiN. */
-static int do_pci_entry(const char *filename,
-                       struct pci_device_id *id, char *alias)
-{
-       /* Class field can be divided into these three. */
-       unsigned char baseclass, subclass, interface,
-               baseclass_mask, subclass_mask, interface_mask;
-
-       id->vendor = TO_NATIVE(id->vendor);
-       id->device = TO_NATIVE(id->device);
-       id->subvendor = TO_NATIVE(id->subvendor);
-       id->subdevice = TO_NATIVE(id->subdevice);
-       id->class = TO_NATIVE(id->class);
-       id->class_mask = TO_NATIVE(id->class_mask);
-
-       strcpy(alias, "pci:");
-       ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
-       ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
-       ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
-       ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
-
-       baseclass = (id->class) >> 16;
-       baseclass_mask = (id->class_mask) >> 16;
-       subclass = (id->class) >> 8;
-       subclass_mask = (id->class_mask) >> 8;
-       interface = id->class;
-       interface_mask = id->class_mask;
-
-       if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
-           || (subclass_mask != 0 && subclass_mask != 0xFF)
-           || (interface_mask != 0 && interface_mask != 0xFF)) {
-               fprintf(stderr,
-                       "*** Warning: Can't handle masks in %s:%04X\n",
-                       filename, id->class_mask);
-               return 0;
-       }
-
-       ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
-       ADD(alias, "sc", subclass_mask == 0xFF, subclass);
-       ADD(alias, "i", interface_mask == 0xFF, interface);
-       return 1;
-}
-
-/* looks like: "ccw:tNmNdtNdmN" */ 
-static int do_ccw_entry(const char *filename,
-                       struct ccw_device_id *id, char *alias)
-{
-       id->match_flags = TO_NATIVE(id->match_flags);
-       id->cu_type = TO_NATIVE(id->cu_type);
-       id->cu_model = TO_NATIVE(id->cu_model);
-       id->dev_type = TO_NATIVE(id->dev_type);
-       id->dev_model = TO_NATIVE(id->dev_model);
-
-       strcpy(alias, "ccw:");
-       ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
-           id->cu_type);
-       ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
-           id->cu_model);
-       ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
-           id->dev_type);
-       ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
-           id->dev_model);
-       return 1;
-}
-
-/* looks like: "pnp:dD" */
-static int do_pnp_entry(const char *filename,
-                       struct pnp_device_id *id, char *alias)
-{
-       sprintf(alias, "pnp:d%s", id->id);
-       return 1;
-}
-
-/* looks like: "pnp:cCdD..." */
-static int do_pnp_card_entry(const char *filename,
-                       struct pnp_card_device_id *id, char *alias)
-{
-       int i;
-
-       sprintf(alias, "pnp:c%s", id->id);
-       for (i = 0; i < PNP_MAX_DEVICES; i++) {
-               if (! *id->devs[i].id)
-                       break;
-               sprintf(alias + strlen(alias), "d%s", id->devs[i].id);
-       }
-       return 1;
-}
-
-/* Ignore any prefix, eg. v850 prepends _ */
-static inline int sym_is(const char *symbol, const char *name)
-{
-       const char *match;
-
-       match = strstr(symbol, name);
-       if (!match)
-               return 0;
-       return match[strlen(symbol)] == '\0';
-}
-
-static void do_table(void *symval, unsigned long size,
-                    unsigned long id_size,
-                    void *function,
-                    struct module *mod)
-{
-       unsigned int i;
-       char alias[500];
-       int (*do_entry)(const char *, void *entry, char *alias) = function;
-
-       if (size % id_size || size < id_size) {
-               fprintf(stderr, "*** Warning: %s ids %lu bad size "
-                       "(each on %lu)\n", mod->name, size, id_size);
-       }
-       /* Leave last one: it's the terminator. */
-       size -= id_size;
-
-       for (i = 0; i < size; i += id_size) {
-               if (do_entry(mod->name, symval+i, alias)) {
-                       /* Always end in a wildcard, for future extension */
-                       if (alias[strlen(alias)-1] != '*')
-                               strcat(alias, "*");
-                       buf_printf(&mod->dev_table_buf,
-                                  "MODULE_ALIAS(\"%s\");\n", alias);
-               }
-       }
-}
-
-/* Create MODULE_ALIAS() statements.
- * At this time, we cannot write the actual output C source yet,
- * so we write into the mod->dev_table_buf buffer. */
-void handle_moddevtable(struct module *mod, struct elf_info *info,
-                       Elf_Sym *sym, const char *symname)
-{
-       void *symval;
-
-       /* We're looking for a section relative symbol */
-       if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
-               return;
-
-       symval = (void *)info->hdr
-               + info->sechdrs[sym->st_shndx].sh_offset
-               + sym->st_value;
-
-       if (sym_is(symname, "__mod_pci_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct pci_device_id),
-                        do_pci_entry, mod);
-       else if (sym_is(symname, "__mod_usb_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct usb_device_id),
-                        do_usb_entry, mod);
-       else if (sym_is(symname, "__mod_ieee1394_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id),
-                        do_ieee1394_entry, mod);
-       else if (sym_is(symname, "__mod_ccw_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct ccw_device_id),
-                        do_ccw_entry, mod);
-       else if (sym_is(symname, "__mod_pnp_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
-                        do_pnp_entry, mod);
-       else if (sym_is(symname, "__mod_pnp_card_device_table"))
-               do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id),
-                        do_pnp_card_entry, mod);
-}
-
-/* Now add out buffered information to the generated C source */
-void add_moddevtable(struct buffer *buf, struct module *mod)
-{
-       buf_printf(buf, "\n");
-       buf_write(buf, mod->dev_table_buf.p, mod->dev_table_buf.pos);
-       free(mod->dev_table_buf.p);
-}
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c
deleted file mode 100644 (file)
index de2aabf..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <elf.h>
-
-int
-main(int argc, char **argv)
-{
-       unsigned char ei[EI_NIDENT];    
-       union { short s; char c[2]; } endian_test;
-
-       if (argc != 2) {
-               fprintf(stderr, "Error: no arch\n");
-       }
-       if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
-               fprintf(stderr, "Error: input truncated\n");
-               return 1;
-       }
-       if (memcmp(ei, ELFMAG, SELFMAG) != 0) {
-               fprintf(stderr, "Error: not ELF\n");
-               return 1;
-       }
-       switch (ei[EI_CLASS]) {
-       case ELFCLASS32:
-               printf("#define KERNEL_ELFCLASS ELFCLASS32\n");
-               break;
-       case ELFCLASS64:
-               printf("#define KERNEL_ELFCLASS ELFCLASS64\n");
-               break;
-       default:
-               abort();
-       }
-       switch (ei[EI_DATA]) {
-       case ELFDATA2LSB:
-               printf("#define KERNEL_ELFDATA ELFDATA2LSB\n");
-               break;
-       case ELFDATA2MSB:
-               printf("#define KERNEL_ELFDATA ELFDATA2MSB\n");
-               break;
-       default:
-               abort();
-       }
-
-       if (sizeof(unsigned long) == 4) {
-               printf("#define HOST_ELFCLASS ELFCLASS32\n");
-       } else if (sizeof(unsigned long) == 8) {
-               printf("#define HOST_ELFCLASS ELFCLASS64\n");
-       }
-
-       endian_test.s = 0x0102;
-       if (memcmp(endian_test.c, "\x01\x02", 2) == 0)
-               printf("#define HOST_ELFDATA ELFDATA2MSB\n");
-       else if (memcmp(endian_test.c, "\x02\x01", 2) == 0)
-               printf("#define HOST_ELFDATA ELFDATA2LSB\n");
-       else
-               abort();
-
-       if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0))
-               printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
-       else 
-               printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
-
-       return 0;
-}
-
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
deleted file mode 100644 (file)
index 662e75b..0000000
+++ /dev/null
@@ -1,739 +0,0 @@
-/* Postprocess module symbol versions
- *
- * Copyright 2003       Kai Germaschewski
- *           2002-2003  Rusty Russell, IBM Corporation
- *
- * Based in part on module-init-tools/depmod.c,file2alias
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- * Usage: modpost vmlinux module1.o module2.o ...
- */
-
-#include <ctype.h>
-#include "modpost.h"
-
-/* Are we using CONFIG_MODVERSIONS? */
-int modversions = 0;
-/* Warn about undefined symbols? (do so if we have vmlinux) */
-int have_vmlinux = 0;
-
-void
-fatal(const char *fmt, ...)
-{
-       va_list arglist;
-
-       fprintf(stderr, "FATAL: ");
-
-       va_start(arglist, fmt);
-       vfprintf(stderr, fmt, arglist);
-       va_end(arglist);
-
-       exit(1);
-}
-
-void
-warn(const char *fmt, ...)
-{
-       va_list arglist;
-
-       fprintf(stderr, "WARNING: ");
-
-       va_start(arglist, fmt);
-       vfprintf(stderr, fmt, arglist);
-       va_end(arglist);
-}
-
-void *do_nofail(void *ptr, const char *file, int line, const char *expr)
-{
-       if (!ptr) {
-               fatal("Memory allocation failure %s line %d: %s.\n",
-                     file, line, expr);
-       }
-       return ptr;
-}
-
-/* A list of all modules we processed */
-
-static struct module *modules;
-
-struct module *
-find_module(char *modname)
-{
-       struct module *mod;
-
-       for (mod = modules; mod; mod = mod->next)
-               if (strcmp(mod->name, modname) == 0)
-                       break;
-       return mod;
-}
-
-struct module *
-new_module(char *modname)
-{
-       struct module *mod;
-       char *p, *s;
-       
-       mod = NOFAIL(malloc(sizeof(*mod)));
-       memset(mod, 0, sizeof(*mod));
-       p = NOFAIL(strdup(modname));
-
-       /* strip trailing .o */
-       if ((s = strrchr(p, '.')) != NULL)
-               if (strcmp(s, ".o") == 0)
-                       *s = '\0';
-
-       /* add to list */
-       mod->name = p;
-       mod->next = modules;
-       modules = mod;
-
-       return mod;
-}
-
-/* A hash of all exported symbols,
- * struct symbol is also used for lists of unresolved symbols */
-
-#define SYMBOL_HASH_SIZE 1024
-
-struct symbol {
-       struct symbol *next;
-       struct module *module;
-       unsigned int crc;
-       int crc_valid;
-       char name[0];
-};
-
-static struct symbol *symbolhash[SYMBOL_HASH_SIZE];
-
-/* This is based on the hash agorithm from gdbm, via tdb */
-static inline unsigned int tdb_hash(const char *name)
-{
-       unsigned value; /* Used to compute the hash value.  */
-       unsigned   i;   /* Used to cycle through random values. */
-
-       /* Set the initial value from the key size. */
-       for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++)
-               value = (value + (((unsigned char *)name)[i] << (i*5 % 24)));
-
-       return (1103515243 * value + 12345);
-}
-
-/* Allocate a new symbols for use in the hash of exported symbols or
- * the list of unresolved symbols per module */
-
-struct symbol *
-alloc_symbol(const char *name, struct symbol *next)
-{
-       struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
-
-       memset(s, 0, sizeof(*s));
-       strcpy(s->name, name);
-       s->next = next;
-       return s;
-}
-
-/* For the hash of exported symbols */
-
-void
-new_symbol(const char *name, struct module *module, unsigned int *crc)
-{
-       unsigned int hash;
-       struct symbol *new;
-
-       hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
-       new = symbolhash[hash] = alloc_symbol(name, symbolhash[hash]);
-       new->module = module;
-       if (crc) {
-               new->crc = *crc;
-               new->crc_valid = 1;
-       }
-}
-
-struct symbol *
-find_symbol(const char *name)
-{
-       struct symbol *s;
-
-       /* For our purposes, .foo matches foo.  PPC64 needs this. */
-       if (name[0] == '.')
-               name++;
-
-       for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) {
-               if (strcmp(s->name, name) == 0)
-                       return s;
-       }
-       return NULL;
-}
-
-/* Add an exported symbol - it may have already been added without a
- * CRC, in this case just update the CRC */
-void
-add_exported_symbol(const char *name, struct module *module, unsigned int *crc)
-{
-       struct symbol *s = find_symbol(name);
-
-       if (!s) {
-               new_symbol(name, module, crc);
-               return;
-       }
-       if (crc) {
-               s->crc = *crc;
-               s->crc_valid = 1;
-       }
-}
-
-void *
-grab_file(const char *filename, unsigned long *size)
-{
-       struct stat st;
-       void *map;
-       int fd;
-
-       fd = open(filename, O_RDONLY);
-       if (fd < 0 || fstat(fd, &st) != 0)
-               return NULL;
-
-       *size = st.st_size;
-       map = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
-       close(fd);
-
-       if (map == MAP_FAILED)
-               return NULL;
-       return map;
-}
-
-/*
-   Return a copy of the next line in a mmap'ed file.
-   spaces in the beginning of the line is trimmed away.
-   Return a pointer to a static buffer.
-*/
-char*
-get_next_line(unsigned long *pos, void *file, unsigned long size)
-{
-       static char line[4096];
-       int skip = 1;
-       size_t len = 0;
-       char *p = (char *)file + *pos;
-       char *s = line;
-
-       for (; *pos < size ; (*pos)++)
-       {
-               if (skip && isspace(*p)) {
-                       p++;
-                       continue;
-               }
-               skip = 0;
-               if (*p != '\n' && (*pos < size)) {
-                       len++;
-                       *s++ = *p++;
-                       if (len > 4095)
-                               break; /* Too long, stop */
-               } else {
-                       /* End of string */
-                       *s = '\0';
-                       return line;
-               }
-       }
-       /* End of buffer */
-       return NULL;
-}
-
-void
-release_file(void *file, unsigned long size)
-{
-       munmap(file, size);
-}
-
-void
-parse_elf(struct elf_info *info, const char *filename)
-{
-       unsigned int i;
-       Elf_Ehdr *hdr = info->hdr;
-       Elf_Shdr *sechdrs;
-       Elf_Sym  *sym;
-
-       hdr = grab_file(filename, &info->size);
-       if (!hdr) {
-               perror(filename);
-               abort();
-       }
-       info->hdr = hdr;
-       if (info->size < sizeof(*hdr))
-               goto truncated;
-
-       /* Fix endianness in ELF header */
-       hdr->e_shoff    = TO_NATIVE(hdr->e_shoff);
-       hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx);
-       hdr->e_shnum    = TO_NATIVE(hdr->e_shnum);
-       hdr->e_machine  = TO_NATIVE(hdr->e_machine);
-       sechdrs = (void *)hdr + hdr->e_shoff;
-       info->sechdrs = sechdrs;
-
-       /* Fix endianness in section headers */
-       for (i = 0; i < hdr->e_shnum; i++) {
-               sechdrs[i].sh_type   = TO_NATIVE(sechdrs[i].sh_type);
-               sechdrs[i].sh_offset = TO_NATIVE(sechdrs[i].sh_offset);
-               sechdrs[i].sh_size   = TO_NATIVE(sechdrs[i].sh_size);
-               sechdrs[i].sh_link   = TO_NATIVE(sechdrs[i].sh_link);
-               sechdrs[i].sh_name   = TO_NATIVE(sechdrs[i].sh_name);
-       }
-       /* Find symbol table. */
-       for (i = 1; i < hdr->e_shnum; i++) {
-               const char *secstrings
-                       = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
-
-               if (sechdrs[i].sh_offset > info->size)
-                       goto truncated;
-               if (strcmp(secstrings+sechdrs[i].sh_name, ".modinfo") == 0) {
-                       info->modinfo = (void *)hdr + sechdrs[i].sh_offset;
-                       info->modinfo_len = sechdrs[i].sh_size;
-               }
-               if (sechdrs[i].sh_type != SHT_SYMTAB)
-                       continue;
-
-               info->symtab_start = (void *)hdr + sechdrs[i].sh_offset;
-               info->symtab_stop  = (void *)hdr + sechdrs[i].sh_offset 
-                                                + sechdrs[i].sh_size;
-               info->strtab       = (void *)hdr + 
-                                    sechdrs[sechdrs[i].sh_link].sh_offset;
-       }
-       if (!info->symtab_start) {
-               fprintf(stderr, "modpost: %s no symtab?\n", filename);
-               abort();
-       }
-       /* Fix endianness in symbols */
-       for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
-               sym->st_shndx = TO_NATIVE(sym->st_shndx);
-               sym->st_name  = TO_NATIVE(sym->st_name);
-               sym->st_value = TO_NATIVE(sym->st_value);
-               sym->st_size  = TO_NATIVE(sym->st_size);
-       }
-       return;
-
- truncated:
-       fprintf(stderr, "modpost: %s is truncated.\n", filename);
-       abort();
-}
-
-void
-parse_elf_finish(struct elf_info *info)
-{
-       release_file(info->hdr, info->size);
-}
-
-#define CRC_PFX     MODULE_SYMBOL_PREFIX "__crc_"
-#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
-
-void
-handle_modversions(struct module *mod, struct elf_info *info,
-                  Elf_Sym *sym, const char *symname)
-{
-       unsigned int crc;
-
-       switch (sym->st_shndx) {
-       case SHN_COMMON:
-               fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n",
-                       symname, mod->name);
-               break;
-       case SHN_ABS:
-               /* CRC'd symbol */
-               if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
-                       crc = (unsigned int) sym->st_value;
-                       add_exported_symbol(symname + strlen(CRC_PFX),
-                                           mod, &crc);
-                       modversions = 1;
-               }
-               break;
-       case SHN_UNDEF:
-               /* undefined symbol */
-               if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL)
-                       break;
-               /* ignore global offset table */
-               if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
-                       break;
-               /* ignore __this_module, it will be resolved shortly */
-               if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
-                       break;
-#ifdef STT_REGISTER
-               if (info->hdr->e_machine == EM_SPARC ||
-                   info->hdr->e_machine == EM_SPARCV9) {
-                       /* Ignore register directives. */
-                       if (ELF_ST_TYPE(sym->st_info) == STT_REGISTER)
-                               break;
-               }
-#endif
-               
-               if (memcmp(symname, MODULE_SYMBOL_PREFIX,
-                          strlen(MODULE_SYMBOL_PREFIX)) == 0)
-                       mod->unres = alloc_symbol(symname +
-                                                 strlen(MODULE_SYMBOL_PREFIX),
-                                                 mod->unres);
-               break;
-       default:
-               /* All exported symbols */
-               if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
-                       add_exported_symbol(symname + strlen(KSYMTAB_PFX),
-                                           mod, NULL);
-               }
-               break;
-       }
-}
-
-int
-is_vmlinux(const char *modname)
-{
-       const char *myname;
-
-       if ((myname = strrchr(modname, '/')))
-               myname++;
-       else
-               myname = modname;
-
-       return strcmp(myname, "vmlinux") == 0;
-}
-
-void
-read_symbols(char *modname)
-{
-       const char *symname;
-       struct module *mod;
-       struct elf_info info = { };
-       Elf_Sym *sym;
-
-       parse_elf(&info, modname);
-
-       mod = new_module(modname);
-
-       /* When there's no vmlinux, don't print warnings about
-        * unresolved symbols (since there'll be too many ;) */
-       if (is_vmlinux(modname)) {
-               unsigned int fake_crc = 0;
-               have_vmlinux = 1;
-               /* May not have this if !CONFIG_MODULE_UNLOAD: fake it.
-                  If it appears, we'll get the real CRC. */
-               add_exported_symbol("cleanup_module", mod, &fake_crc);
-               add_exported_symbol("struct_module", mod, &fake_crc);
-               mod->skip = 1;
-       }
-
-       for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
-               symname = info.strtab + sym->st_name;
-
-               handle_modversions(mod, &info, sym, symname);
-               handle_moddevtable(mod, &info, sym, symname);
-       }
-       maybe_frob_version(modname, info.modinfo, info.modinfo_len,
-                          (void *)info.modinfo - (void *)info.hdr);
-       parse_elf_finish(&info);
-
-       /* Our trick to get versioning for struct_module - it's
-        * never passed as an argument to an exported function, so
-        * the automatic versioning doesn't pick it up, but it's really
-        * important anyhow */
-       if (modversions) {
-               mod->unres = alloc_symbol("struct_module", mod->unres);
-
-               /* Always version init_module and cleanup_module, in
-                * case module doesn't have its own. */
-               mod->unres = alloc_symbol("init_module", mod->unres);
-               mod->unres = alloc_symbol("cleanup_module", mod->unres);
-       }
-}
-
-#define SZ 500
-
-/* We first write the generated file into memory using the
- * following helper, then compare to the file on disk and
- * only update the later if anything changed */
-
-void __attribute__((format(printf, 2, 3)))
-buf_printf(struct buffer *buf, const char *fmt, ...)
-{
-       char tmp[SZ];
-       int len;
-       va_list ap;
-       
-       va_start(ap, fmt);
-       len = vsnprintf(tmp, SZ, fmt, ap);
-       if (buf->size - buf->pos < len + 1) {
-               buf->size += 128;
-               buf->p = realloc(buf->p, buf->size);
-       }
-       strncpy(buf->p + buf->pos, tmp, len + 1);
-       buf->pos += len;
-       va_end(ap);
-}
-
-void
-buf_write(struct buffer *buf, const char *s, int len)
-{
-       if (buf->size - buf->pos < len) {
-               buf->size += len;
-               buf->p = realloc(buf->p, buf->size);
-       }
-       strncpy(buf->p + buf->pos, s, len);
-       buf->pos += len;
-}
-
-/* Header for the generated file */
-
-void
-add_header(struct buffer *b)
-{
-       buf_printf(b, "#include <linux/module.h>\n");
-       buf_printf(b, "#include <linux/vermagic.h>\n");
-       buf_printf(b, "#include <linux/compiler.h>\n");
-       buf_printf(b, "\n");
-       buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
-       buf_printf(b, "\n");
-       buf_printf(b, "#undef unix\n"); /* We have a module called "unix" */
-       buf_printf(b, "struct module __this_module\n");
-       buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
-       buf_printf(b, " .name = __stringify(KBUILD_MODNAME),\n");
-       buf_printf(b, " .init = init_module,\n");
-       buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n");
-       buf_printf(b, " .exit = cleanup_module,\n");
-       buf_printf(b, "#endif\n");
-       buf_printf(b, "};\n");
-}
-
-/* Record CRCs for unresolved symbols */
-
-void
-add_versions(struct buffer *b, struct module *mod)
-{
-       struct symbol *s, *exp;
-
-       for (s = mod->unres; s; s = s->next) {
-               exp = find_symbol(s->name);
-               if (!exp || exp->module == mod) {
-                       if (have_vmlinux)
-                               fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
-                               "undefined!\n", s->name, mod->name);
-                       continue;
-               }
-               s->module = exp->module;
-               s->crc_valid = exp->crc_valid;
-               s->crc = exp->crc;
-       }
-
-       if (!modversions)
-               return;
-
-       buf_printf(b, "\n");
-       buf_printf(b, "static const struct modversion_info ____versions[]\n");
-       buf_printf(b, "__attribute_used__\n");
-       buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n");
-
-       for (s = mod->unres; s; s = s->next) {
-               if (!s->module) {
-                       continue;
-               }
-               if (!s->crc_valid) {
-                       fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
-                               "has no CRC!\n",
-                               s->name, mod->name);
-                       continue;
-               }
-               buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name);
-       }
-
-       buf_printf(b, "};\n");
-}
-
-void
-add_depends(struct buffer *b, struct module *mod, struct module *modules)
-{
-       struct symbol *s;
-       struct module *m;
-       int first = 1;
-
-       for (m = modules; m; m = m->next) {
-               m->seen = is_vmlinux(m->name);
-       }
-
-       buf_printf(b, "\n");
-       buf_printf(b, "static const char __module_depends[]\n");
-       buf_printf(b, "__attribute_used__\n");
-       buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
-       buf_printf(b, "\"depends=");
-       for (s = mod->unres; s; s = s->next) {
-               if (!s->module)
-                       continue;
-
-               if (s->module->seen)
-                       continue;
-
-               s->module->seen = 1;
-               buf_printf(b, "%s%s", first ? "" : ",",
-                          strrchr(s->module->name, '/') + 1);
-               first = 0;
-       }
-       buf_printf(b, "\";\n");
-}
-
-void
-write_if_changed(struct buffer *b, const char *fname)
-{
-       char *tmp;
-       FILE *file;
-       struct stat st;
-
-       file = fopen(fname, "r");
-       if (!file)
-               goto write;
-
-       if (fstat(fileno(file), &st) < 0)
-               goto close_write;
-
-       if (st.st_size != b->pos)
-               goto close_write;
-
-       tmp = NOFAIL(malloc(b->pos));
-       if (fread(tmp, 1, b->pos, file) != b->pos)
-               goto free_write;
-
-       if (memcmp(tmp, b->p, b->pos) != 0)
-               goto free_write;
-
-       free(tmp);
-       fclose(file);
-       return;
-
- free_write:
-       free(tmp);
- close_write:
-       fclose(file);
- write:
-       file = fopen(fname, "w");
-       if (!file) {
-               perror(fname);
-               exit(1);
-       }
-       if (fwrite(b->p, 1, b->pos, file) != b->pos) {
-               perror(fname);
-               exit(1);
-       }
-       fclose(file);
-}
-
-void
-read_dump(const char *fname)
-{
-       unsigned long size, pos = 0;
-       void *file = grab_file(fname, &size);
-       char *line;
-
-        if (!file)
-               /* No symbol versions, silently ignore */
-               return;
-
-       while ((line = get_next_line(&pos, file, size))) {
-               char *symname, *modname, *d;
-               unsigned int crc;
-               struct module *mod;
-
-               if (!(symname = strchr(line, '\t')))
-                       goto fail;
-               *symname++ = '\0';
-               if (!(modname = strchr(symname, '\t')))
-                       goto fail;
-               *modname++ = '\0';
-               if (strchr(modname, '\t'))
-                       goto fail;
-               crc = strtoul(line, &d, 16);
-               if (*symname == '\0' || *modname == '\0' || *d != '\0')
-                       goto fail;
-
-               if (!(mod = find_module(modname))) {
-                       if (is_vmlinux(modname)) {
-                               modversions = 1;
-                               have_vmlinux = 1;
-                       }
-                       mod = new_module(NOFAIL(strdup(modname)));
-                       mod->skip = 1;
-               }
-               add_exported_symbol(symname, mod, &crc);
-       }
-       return;
-fail:
-       fatal("parse error in symbol dump file\n");
-}
-
-void
-write_dump(const char *fname)
-{
-       struct buffer buf = { };
-       struct symbol *symbol;
-       int n;
-
-       for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
-               symbol = symbolhash[n];
-               while (symbol) {
-                       symbol = symbol->next;
-               }
-       }
-
-       for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
-               symbol = symbolhash[n];
-               while (symbol) {
-                       buf_printf(&buf, "0x%08x\t%s\t%s\n", symbol->crc,
-                               symbol->name, symbol->module->name);
-                       symbol = symbol->next;
-               }
-       }
-       write_if_changed(&buf, fname);
-}
-
-int
-main(int argc, char **argv)
-{
-       struct module *mod;
-       struct buffer buf = { };
-       char fname[SZ];
-       char *dump_read = NULL, *dump_write = NULL;
-       int opt;
-
-       while ((opt = getopt(argc, argv, "i:o:")) != -1) {
-               switch(opt) {
-                       case 'i':
-                               dump_read = optarg;
-                               break;
-                       case 'o':
-                               dump_write = optarg;
-                               break;
-                       default:
-                               exit(1);
-               }
-       }
-
-       if (dump_read)
-               read_dump(dump_read);
-
-       while (optind < argc) {
-               read_symbols(argv[optind++]);
-       }
-
-       for (mod = modules; mod; mod = mod->next) {
-               if (mod->skip)
-                       continue;
-
-               buf.pos = 0;
-
-               add_header(&buf);
-               add_versions(&buf, mod);
-               add_depends(&buf, mod, modules);
-               add_moddevtable(&buf, mod);
-
-               sprintf(fname, "%s.mod.c", mod->name);
-               write_if_changed(&buf, fname);
-       }
-
-       if (dump_write)
-               write_dump(dump_write);
-
-       return 0;
-}
-
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
deleted file mode 100644 (file)
index ddb013d..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <elf.h>
-
-#include "elfconfig.h"
-
-#if KERNEL_ELFCLASS == ELFCLASS32
-
-#define Elf_Ehdr    Elf32_Ehdr 
-#define Elf_Shdr    Elf32_Shdr 
-#define Elf_Sym     Elf32_Sym
-#define ELF_ST_BIND ELF32_ST_BIND
-#define ELF_ST_TYPE ELF32_ST_TYPE
-
-#else
-
-#define Elf_Ehdr    Elf64_Ehdr 
-#define Elf_Shdr    Elf64_Shdr 
-#define Elf_Sym     Elf64_Sym
-#define ELF_ST_BIND ELF64_ST_BIND
-#define ELF_ST_TYPE ELF64_ST_TYPE
-
-#endif
-
-#if KERNEL_ELFDATA != HOST_ELFDATA
-
-static inline void __endian(const void *src, void *dest, unsigned int size)
-{
-       unsigned int i;
-       for (i = 0; i < size; i++)
-               ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1];
-}
-
-
-
-#define TO_NATIVE(x)                                           \
-({                                                             \
-       typeof(x) __x;                                          \
-       __endian(&(x), &(__x), sizeof(__x));                    \
-       __x;                                                    \
-})
-
-#else /* endianness matches */
-
-#define TO_NATIVE(x) (x)
-
-#endif
-
-#define NOFAIL(ptr)   do_nofail((ptr), __FILE__, __LINE__, #ptr)
-void *do_nofail(void *ptr, const char *file, int line, const char *expr);
-
-struct buffer {
-       char *p;
-       int pos;
-       int size;
-};
-
-void __attribute__((format(printf, 2, 3)))
-buf_printf(struct buffer *buf, const char *fmt, ...);
-
-void
-buf_write(struct buffer *buf, const char *s, int len);
-
-struct module {
-       struct module *next;
-       const char *name;
-       struct symbol *unres;
-       int seen;
-       int skip;
-       struct buffer dev_table_buf;
-};
-
-struct elf_info {
-       unsigned long size;
-       Elf_Ehdr     *hdr;
-       Elf_Shdr     *sechdrs;
-       Elf_Sym      *symtab_start;
-       Elf_Sym      *symtab_stop;
-       const char   *strtab;
-       char         *modinfo;
-       unsigned int modinfo_len;
-};
-
-void handle_moddevtable(struct module *mod, struct elf_info *info,
-                       Elf_Sym *sym, const char *symname);
-
-void add_moddevtable(struct buffer *buf, struct module *mod);
-
-void maybe_frob_version(const char *modfilename,
-                       void *modinfo,
-                       unsigned long modinfo_len,
-                       unsigned long modinfo_offset);
-
-void *grab_file(const char *filename, unsigned long *size);
-char* get_next_line(unsigned long *pos, void *file, unsigned long size);
-void release_file(void *file, unsigned long size);
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
deleted file mode 100644 (file)
index b41b718..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-#include <netinet/in.h>
-#include <stdint.h>
-#include <ctype.h>
-#include <errno.h>
-#include <string.h>
-#include "modpost.h"
-
-/* Parse tag=value strings from .modinfo section */
-static char *next_string(char *string, unsigned long *secsize)
-{
-       /* Skip non-zero chars */
-       while (string[0]) {
-               string++;
-               if ((*secsize)-- <= 1)
-                       return NULL;
-       }
-
-       /* Skip any zero padding. */
-       while (!string[0]) {
-               string++;
-               if ((*secsize)-- <= 1)
-                       return NULL;
-       }
-       return string;
-}
-
-static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
-                        const char *tag)
-{
-       char *p;
-       unsigned int taglen = strlen(tag);
-       unsigned long size = modinfo_len;
-
-       for (p = modinfo; p; p = next_string(p, &size)) {
-               if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
-                       return p + taglen + 1;
-       }
-       return NULL;
-}
-
-/*
- * Stolen form Cryptographic API.
- *
- * MD4 Message Digest Algorithm (RFC1320).
- *
- * Implementation derived from Andrew Tridgell and Steve French's
- * CIFS MD4 implementation, and the cryptoapi implementation
- * originally based on the public domain implementation written
- * by Colin Plumb in 1993.
- *
- * Copyright (c) Andrew Tridgell 1997-1998.
- * Modified by Steve French (sfrench@us.ibm.com) 2002
- * Copyright (c) Cryptoapi developers.
- * Copyright (c) 2002 David S. Miller (davem@redhat.com)
- * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- */
-#define MD4_DIGEST_SIZE                16
-#define MD4_HMAC_BLOCK_SIZE    64
-#define MD4_BLOCK_WORDS                16
-#define MD4_HASH_WORDS         4
-
-struct md4_ctx {
-       uint32_t hash[MD4_HASH_WORDS];
-       uint32_t block[MD4_BLOCK_WORDS];
-       uint64_t byte_count;
-};
-
-static inline uint32_t lshift(uint32_t x, unsigned int s)
-{
-       x &= 0xFFFFFFFF;
-       return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
-}
-
-static inline uint32_t F(uint32_t x, uint32_t y, uint32_t z)
-{
-       return (x & y) | ((~x) & z);
-}
-
-static inline uint32_t G(uint32_t x, uint32_t y, uint32_t z)
-{
-       return (x & y) | (x & z) | (y & z);
-}
-
-static inline uint32_t H(uint32_t x, uint32_t y, uint32_t z)
-{
-       return x ^ y ^ z;
-}
-
-#define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s))
-#define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (uint32_t)0x5A827999,s))
-#define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (uint32_t)0x6ED9EBA1,s))
-
-/* XXX: this stuff can be optimized */
-static inline void le32_to_cpu_array(uint32_t *buf, unsigned int words)
-{
-       while (words--) {
-               *buf = ntohl(*buf);
-               buf++;
-       }
-}
-
-static inline void cpu_to_le32_array(uint32_t *buf, unsigned int words)
-{
-       while (words--) {
-               *buf = htonl(*buf);
-               buf++;
-       }
-}
-
-static void md4_transform(uint32_t *hash, uint32_t const *in)
-{
-       uint32_t a, b, c, d;
-
-       a = hash[0];
-       b = hash[1];
-       c = hash[2];
-       d = hash[3];
-
-       ROUND1(a, b, c, d, in[0], 3);
-       ROUND1(d, a, b, c, in[1], 7);
-       ROUND1(c, d, a, b, in[2], 11);
-       ROUND1(b, c, d, a, in[3], 19);
-       ROUND1(a, b, c, d, in[4], 3);
-       ROUND1(d, a, b, c, in[5], 7);
-       ROUND1(c, d, a, b, in[6], 11);
-       ROUND1(b, c, d, a, in[7], 19);
-       ROUND1(a, b, c, d, in[8], 3);
-       ROUND1(d, a, b, c, in[9], 7);
-       ROUND1(c, d, a, b, in[10], 11);
-       ROUND1(b, c, d, a, in[11], 19);
-       ROUND1(a, b, c, d, in[12], 3);
-       ROUND1(d, a, b, c, in[13], 7);
-       ROUND1(c, d, a, b, in[14], 11);
-       ROUND1(b, c, d, a, in[15], 19);
-
-       ROUND2(a, b, c, d,in[ 0], 3);
-       ROUND2(d, a, b, c, in[4], 5);
-       ROUND2(c, d, a, b, in[8], 9);
-       ROUND2(b, c, d, a, in[12], 13);
-       ROUND2(a, b, c, d, in[1], 3);
-       ROUND2(d, a, b, c, in[5], 5);
-       ROUND2(c, d, a, b, in[9], 9);
-       ROUND2(b, c, d, a, in[13], 13);
-       ROUND2(a, b, c, d, in[2], 3);
-       ROUND2(d, a, b, c, in[6], 5);
-       ROUND2(c, d, a, b, in[10], 9);
-       ROUND2(b, c, d, a, in[14], 13);
-       ROUND2(a, b, c, d, in[3], 3);
-       ROUND2(d, a, b, c, in[7], 5);
-       ROUND2(c, d, a, b, in[11], 9);
-       ROUND2(b, c, d, a, in[15], 13);
-
-       ROUND3(a, b, c, d,in[ 0], 3);
-       ROUND3(d, a, b, c, in[8], 9);
-       ROUND3(c, d, a, b, in[4], 11);
-       ROUND3(b, c, d, a, in[12], 15);
-       ROUND3(a, b, c, d, in[2], 3);
-       ROUND3(d, a, b, c, in[10], 9);
-       ROUND3(c, d, a, b, in[6], 11);
-       ROUND3(b, c, d, a, in[14], 15);
-       ROUND3(a, b, c, d, in[1], 3);
-       ROUND3(d, a, b, c, in[9], 9);
-       ROUND3(c, d, a, b, in[5], 11);
-       ROUND3(b, c, d, a, in[13], 15);
-       ROUND3(a, b, c, d, in[3], 3);
-       ROUND3(d, a, b, c, in[11], 9);
-       ROUND3(c, d, a, b, in[7], 11);
-       ROUND3(b, c, d, a, in[15], 15);
-
-       hash[0] += a;
-       hash[1] += b;
-       hash[2] += c;
-       hash[3] += d;
-}
-
-static inline void md4_transform_helper(struct md4_ctx *ctx)
-{
-       le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(uint32_t));
-       md4_transform(ctx->hash, ctx->block);
-}
-
-static void md4_init(struct md4_ctx *mctx)
-{
-       mctx->hash[0] = 0x67452301;
-       mctx->hash[1] = 0xefcdab89;
-       mctx->hash[2] = 0x98badcfe;
-       mctx->hash[3] = 0x10325476;
-       mctx->byte_count = 0;
-}
-
-static void md4_update(struct md4_ctx *mctx,
-                      const unsigned char *data, unsigned int len)
-{
-       const uint32_t avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
-
-       mctx->byte_count += len;
-
-       if (avail > len) {
-               memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-                      data, len);
-               return;
-       }
-
-       memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-              data, avail);
-
-       md4_transform_helper(mctx);
-       data += avail;
-       len -= avail;
-
-       while (len >= sizeof(mctx->block)) {
-               memcpy(mctx->block, data, sizeof(mctx->block));
-               md4_transform_helper(mctx);
-               data += sizeof(mctx->block);
-               len -= sizeof(mctx->block);
-       }
-
-       memcpy(mctx->block, data, len);
-}
-
-static void md4_final_ascii(struct md4_ctx *mctx, char *out, unsigned int len)
-{
-       const unsigned int offset = mctx->byte_count & 0x3f;
-       char *p = (char *)mctx->block + offset;
-       int padding = 56 - (offset + 1);
-
-       *p++ = 0x80;
-       if (padding < 0) {
-               memset(p, 0x00, padding + sizeof (uint64_t));
-               md4_transform_helper(mctx);
-               p = (char *)mctx->block;
-               padding = 56;
-       }
-
-       memset(p, 0, padding);
-       mctx->block[14] = mctx->byte_count << 3;
-       mctx->block[15] = mctx->byte_count >> 29;
-       le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
-                         sizeof(uint64_t)) / sizeof(uint32_t));
-       md4_transform(mctx->hash, mctx->block);
-       cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(uint32_t));
-
-       snprintf(out, len, "%08X%08X%08X%08X",
-                mctx->hash[0], mctx->hash[1], mctx->hash[2], mctx->hash[3]);
-}
-
-static inline void add_char(unsigned char c, struct md4_ctx *md)
-{
-       md4_update(md, &c, 1);
-}
-
-static int parse_string(const char *file, unsigned long len,
-                       struct md4_ctx *md)
-{
-       unsigned long i;
-
-       add_char(file[0], md);
-       for (i = 1; i < len; i++) {
-               add_char(file[i], md);
-               if (file[i] == '"' && file[i-1] != '\\')
-                       break;
-       }
-       return i;
-}
-
-static int parse_comment(const char *file, unsigned long len)
-{
-       unsigned long i;
-
-       for (i = 2; i < len; i++) {
-               if (file[i-1] == '*' && file[i] == '/')
-                       break;
-       }
-       return i;
-}
-
-/* FIXME: Handle .s files differently (eg. # starts comments) --RR */
-static int parse_file(const char *fname, struct md4_ctx *md)
-{
-       char *file;
-       unsigned long i, len;
-
-       file = grab_file(fname, &len);
-       if (!file)
-               return 0;
-
-       for (i = 0; i < len; i++) {
-               /* Collapse and ignore \ and CR. */
-               if (file[i] == '\\' && (i+1 < len) && file[i+1] == '\n') {
-                       i++;
-                       continue;
-               }
-
-               /* Ignore whitespace */
-               if (isspace(file[i]))
-                       continue;
-
-               /* Handle strings as whole units */
-               if (file[i] == '"') {
-                       i += parse_string(file+i, len - i, md);
-                       continue;
-               }
-
-               /* Comments: ignore */
-               if (file[i] == '/' && file[i+1] == '*') {
-                       i += parse_comment(file+i, len - i);
-                       continue;
-               }
-
-               add_char(file[i], md);
-       }
-       release_file(file, len);
-       return 1;
-}
-
-/* We have dir/file.o.  Open dir/.file.o.cmd, look for deps_ line to
- * figure out source file. */
-static int parse_source_files(const char *objfile, struct md4_ctx *md)
-{
-       char *cmd, *file, *line, *dir;
-       const char *base;
-       unsigned long flen, pos = 0;
-       int dirlen, ret = 0, check_files = 0;
-
-       cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd")));
-
-       base = strrchr(objfile, '/');
-       if (base) {
-               base++;
-               dirlen = base - objfile;
-               sprintf(cmd, "%.*s.%s.cmd", dirlen, objfile, base);
-       } else {
-               dirlen = 0;
-               sprintf(cmd, ".%s.cmd", objfile);
-       }
-       dir = NOFAIL(malloc(dirlen + 1));
-       strncpy(dir, objfile, dirlen);
-       dir[dirlen] = '\0';
-
-       file = grab_file(cmd, &flen);
-       if (!file) {
-               fprintf(stderr, "Warning: could not find %s for %s\n",
-                       cmd, objfile);
-               goto out;
-       }
-
-       /* There will be a line like so:
-               deps_drivers/net/dummy.o := \
-                 drivers/net/dummy.c \
-                   $(wildcard include/config/net/fastroute.h) \
-                 include/linux/config.h \
-                   $(wildcard include/config/h.h) \
-                 include/linux/module.h \
-
-          Sum all files in the same dir or subdirs.
-       */
-       while ((line = get_next_line(&pos, file, flen)) != NULL) {
-               char* p = line;
-               if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
-                       check_files = 1;
-                       continue;
-               }
-               if (!check_files)
-                       continue;
-
-               /* Continue until line does not end with '\' */
-               if ( *(p + strlen(p)-1) != '\\')
-                       break;
-               /* Terminate line at first space, to get rid of final ' \' */
-               while (*p) {
-                       if (isspace(*p)) {
-                               *p = '\0';
-                               break;
-                       }
-                       p++;
-               }
-
-               /* Check if this file is in same dir as objfile */
-               if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
-                       if (!parse_file(line, md)) {
-                               fprintf(stderr,
-                                       "Warning: could not open %s: %s\n",
-                                       line, strerror(errno));
-                               goto out_file;
-                       }
-
-               }
-
-       }
-
-       /* Everyone parsed OK */
-       ret = 1;
-out_file:
-       release_file(file, flen);
-out:
-       free(dir);
-       free(cmd);
-       return ret;
-}
-
-static int get_version(const char *modname, char sum[])
-{
-       void *file;
-       unsigned long len;
-       int ret = 0;
-       struct md4_ctx md;
-       char *sources, *end, *fname;
-       const char *basename;
-       char filelist[sizeof(".tmp_versions/%s.mod") + strlen(modname)];
-
-       /* Source files for module are in .tmp_versions/modname.mod,
-          after the first line. */
-       if (strrchr(modname, '/'))
-               basename = strrchr(modname, '/') + 1;
-       else
-               basename = modname;
-       sprintf(filelist, ".tmp_versions/%s", basename);
-       /* Truncate .o, add .mod */
-       strcpy(filelist + strlen(filelist)-2, ".mod");
-
-       file = grab_file(filelist, &len);
-       if (!file) {
-               fprintf(stderr, "Warning: could not find versions for %s\n",
-                       filelist);
-               return 0;
-       }
-
-       sources = strchr(file, '\n');
-       if (!sources) {
-               fprintf(stderr, "Warning: malformed versions file for %s\n",
-                       modname);
-               goto release;
-       }
-
-       sources++;
-       end = strchr(sources, '\n');
-       if (!end) {
-               fprintf(stderr, "Warning: bad ending versions file for %s\n",
-                       modname);
-               goto release;
-       }
-       *end = '\0';
-
-       md4_init(&md);
-       for (fname = strtok(sources, " "); fname; fname = strtok(NULL, " ")) {
-               if (!parse_source_files(fname, &md))
-                       goto release;
-       }
-
-       /* sum is of form \0<padding>. */
-       md4_final_ascii(&md, sum, 1 + strlen(sum+1));
-       ret = 1;
-release:
-       release_file(file, len);
-       return ret;
-}
-
-static void write_version(const char *filename, const char *sum,
-                         unsigned long offset)
-{
-       int fd;
-
-       fd = open(filename, O_RDWR);
-       if (fd < 0) {
-               fprintf(stderr, "Warning: changing sum in %s failed: %s\n",
-                       filename, strerror(errno));
-               return;
-       }
-
-       if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
-               fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n",
-                       filename, offset, strerror(errno));
-               goto out;
-       }
-
-       if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
-               fprintf(stderr, "Warning: writing sum in %s failed: %s\n",
-                       filename, strerror(errno));
-               goto out;
-       }
-out:
-       close(fd);
-}
-
-void strip_rcs_crap(char *version)
-{
-       unsigned int len, full_len;
-
-       if (strncmp(version, "$Revision", strlen("$Revision")) != 0)
-               return;
-
-       /* Space for version string follows. */
-       full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2;
-
-       /* Move string to start with version number: prefix will be
-        * $Revision$ or $Revision: */
-       len = strlen("$Revision");
-       if (version[len] == ':' || version[len] == '$')
-               len++;
-       while (isspace(version[len]))
-               len++;
-       memmove(version, version+len, full_len-len);
-       full_len -= len;
-
-       /* Preserve up to next whitespace. */
-       len = 0;
-       while (version[len] && !isspace(version[len]))
-               len++;
-       memmove(version + len, version + strlen(version),
-               full_len - strlen(version));
-}
-
-/* If the modinfo contains a "version" value, then set this. */
-void maybe_frob_version(const char *modfilename,
-                       void *modinfo,
-                       unsigned long modinfo_len,
-                       unsigned long modinfo_offset)
-{
-       char *version, *csum;
-
-       version = get_modinfo(modinfo, modinfo_len, "version");
-       if (!version)
-               return;
-
-       /* RCS $Revision gets stripped out. */
-       strip_rcs_crap(version);
-
-       /* Check against double sumversion */
-       if (strchr(version, ' '))
-               return;
-
-       /* Version contains embedded NUL: second half has space for checksum */
-       csum = version + strlen(version);
-       *(csum++) = ' ';
-       if (get_version(modfilename, csum))
-               write_version(modfilename, version,
-                             modinfo_offset + (version - (char *)modinfo));
-}
diff --git a/scripts/modpost.c b/scripts/modpost.c
deleted file mode 100644 (file)
index 662e75b..0000000
+++ /dev/null
@@ -1,739 +0,0 @@
-/* Postprocess module symbol versions
- *
- * Copyright 2003       Kai Germaschewski
- *           2002-2003  Rusty Russell, IBM Corporation
- *
- * Based in part on module-init-tools/depmod.c,file2alias
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- * Usage: modpost vmlinux module1.o module2.o ...
- */
-
-#include <ctype.h>
-#include "modpost.h"
-
-/* Are we using CONFIG_MODVERSIONS? */
-int modversions = 0;
-/* Warn about undefined symbols? (do so if we have vmlinux) */
-int have_vmlinux = 0;
-
-void
-fatal(const char *fmt, ...)
-{
-       va_list arglist;
-
-       fprintf(stderr, "FATAL: ");
-
-       va_start(arglist, fmt);
-       vfprintf(stderr, fmt, arglist);
-       va_end(arglist);
-
-       exit(1);
-}
-
-void
-warn(const char *fmt, ...)
-{
-       va_list arglist;
-
-       fprintf(stderr, "WARNING: ");
-
-       va_start(arglist, fmt);
-       vfprintf(stderr, fmt, arglist);
-       va_end(arglist);
-}
-
-void *do_nofail(void *ptr, const char *file, int line, const char *expr)
-{
-       if (!ptr) {
-               fatal("Memory allocation failure %s line %d: %s.\n",
-                     file, line, expr);
-       }
-       return ptr;
-}
-
-/* A list of all modules we processed */
-
-static struct module *modules;
-
-struct module *
-find_module(char *modname)
-{
-       struct module *mod;
-
-       for (mod = modules; mod; mod = mod->next)
-               if (strcmp(mod->name, modname) == 0)
-                       break;
-       return mod;
-}
-
-struct module *
-new_module(char *modname)
-{
-       struct module *mod;
-       char *p, *s;
-       
-       mod = NOFAIL(malloc(sizeof(*mod)));
-       memset(mod, 0, sizeof(*mod));
-       p = NOFAIL(strdup(modname));
-
-       /* strip trailing .o */
-       if ((s = strrchr(p, '.')) != NULL)
-               if (strcmp(s, ".o") == 0)
-                       *s = '\0';
-
-       /* add to list */
-       mod->name = p;
-       mod->next = modules;
-       modules = mod;
-
-       return mod;
-}
-
-/* A hash of all exported symbols,
- * struct symbol is also used for lists of unresolved symbols */
-
-#define SYMBOL_HASH_SIZE 1024
-
-struct symbol {
-       struct symbol *next;
-       struct module *module;
-       unsigned int crc;
-       int crc_valid;
-       char name[0];
-};
-
-static struct symbol *symbolhash[SYMBOL_HASH_SIZE];
-
-/* This is based on the hash agorithm from gdbm, via tdb */
-static inline unsigned int tdb_hash(const char *name)
-{
-       unsigned value; /* Used to compute the hash value.  */
-       unsigned   i;   /* Used to cycle through random values. */
-
-       /* Set the initial value from the key size. */
-       for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++)
-               value = (value + (((unsigned char *)name)[i] << (i*5 % 24)));
-
-       return (1103515243 * value + 12345);
-}
-
-/* Allocate a new symbols for use in the hash of exported symbols or
- * the list of unresolved symbols per module */
-
-struct symbol *
-alloc_symbol(const char *name, struct symbol *next)
-{
-       struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
-
-       memset(s, 0, sizeof(*s));
-       strcpy(s->name, name);
-       s->next = next;
-       return s;
-}
-
-/* For the hash of exported symbols */
-
-void
-new_symbol(const char *name, struct module *module, unsigned int *crc)
-{
-       unsigned int hash;
-       struct symbol *new;
-
-       hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
-       new = symbolhash[hash] = alloc_symbol(name, symbolhash[hash]);
-       new->module = module;
-       if (crc) {
-               new->crc = *crc;
-               new->crc_valid = 1;
-       }
-}
-
-struct symbol *
-find_symbol(const char *name)
-{
-       struct symbol *s;
-
-       /* For our purposes, .foo matches foo.  PPC64 needs this. */
-       if (name[0] == '.')
-               name++;
-
-       for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) {
-               if (strcmp(s->name, name) == 0)
-                       return s;
-       }
-       return NULL;
-}
-
-/* Add an exported symbol - it may have already been added without a
- * CRC, in this case just update the CRC */
-void
-add_exported_symbol(const char *name, struct module *module, unsigned int *crc)
-{
-       struct symbol *s = find_symbol(name);
-
-       if (!s) {
-               new_symbol(name, module, crc);
-               return;
-       }
-       if (crc) {
-               s->crc = *crc;
-               s->crc_valid = 1;
-       }
-}
-
-void *
-grab_file(const char *filename, unsigned long *size)
-{
-       struct stat st;
-       void *map;
-       int fd;
-
-       fd = open(filename, O_RDONLY);
-       if (fd < 0 || fstat(fd, &st) != 0)
-               return NULL;
-
-       *size = st.st_size;
-       map = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
-       close(fd);
-
-       if (map == MAP_FAILED)
-               return NULL;
-       return map;
-}
-
-/*
-   Return a copy of the next line in a mmap'ed file.
-   spaces in the beginning of the line is trimmed away.
-   Return a pointer to a static buffer.
-*/
-char*
-get_next_line(unsigned long *pos, void *file, unsigned long size)
-{
-       static char line[4096];
-       int skip = 1;
-       size_t len = 0;
-       char *p = (char *)file + *pos;
-       char *s = line;
-
-       for (; *pos < size ; (*pos)++)
-       {
-               if (skip && isspace(*p)) {
-                       p++;
-                       continue;
-               }
-               skip = 0;
-               if (*p != '\n' && (*pos < size)) {
-                       len++;
-                       *s++ = *p++;
-                       if (len > 4095)
-                               break; /* Too long, stop */
-               } else {
-                       /* End of string */
-                       *s = '\0';
-                       return line;
-               }
-       }
-       /* End of buffer */
-       return NULL;
-}
-
-void
-release_file(void *file, unsigned long size)
-{
-       munmap(file, size);
-}
-
-void
-parse_elf(struct elf_info *info, const char *filename)
-{
-       unsigned int i;
-       Elf_Ehdr *hdr = info->hdr;
-       Elf_Shdr *sechdrs;
-       Elf_Sym  *sym;
-
-       hdr = grab_file(filename, &info->size);
-       if (!hdr) {
-               perror(filename);
-               abort();
-       }
-       info->hdr = hdr;
-       if (info->size < sizeof(*hdr))
-               goto truncated;
-
-       /* Fix endianness in ELF header */
-       hdr->e_shoff    = TO_NATIVE(hdr->e_shoff);
-       hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx);
-       hdr->e_shnum    = TO_NATIVE(hdr->e_shnum);
-       hdr->e_machine  = TO_NATIVE(hdr->e_machine);
-       sechdrs = (void *)hdr + hdr->e_shoff;
-       info->sechdrs = sechdrs;
-
-       /* Fix endianness in section headers */
-       for (i = 0; i < hdr->e_shnum; i++) {
-               sechdrs[i].sh_type   = TO_NATIVE(sechdrs[i].sh_type);
-               sechdrs[i].sh_offset = TO_NATIVE(sechdrs[i].sh_offset);
-               sechdrs[i].sh_size   = TO_NATIVE(sechdrs[i].sh_size);
-               sechdrs[i].sh_link   = TO_NATIVE(sechdrs[i].sh_link);
-               sechdrs[i].sh_name   = TO_NATIVE(sechdrs[i].sh_name);
-       }
-       /* Find symbol table. */
-       for (i = 1; i < hdr->e_shnum; i++) {
-               const char *secstrings
-                       = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
-
-               if (sechdrs[i].sh_offset > info->size)
-                       goto truncated;
-               if (strcmp(secstrings+sechdrs[i].sh_name, ".modinfo") == 0) {
-                       info->modinfo = (void *)hdr + sechdrs[i].sh_offset;
-                       info->modinfo_len = sechdrs[i].sh_size;
-               }
-               if (sechdrs[i].sh_type != SHT_SYMTAB)
-                       continue;
-
-               info->symtab_start = (void *)hdr + sechdrs[i].sh_offset;
-               info->symtab_stop  = (void *)hdr + sechdrs[i].sh_offset 
-                                                + sechdrs[i].sh_size;
-               info->strtab       = (void *)hdr + 
-                                    sechdrs[sechdrs[i].sh_link].sh_offset;
-       }
-       if (!info->symtab_start) {
-               fprintf(stderr, "modpost: %s no symtab?\n", filename);
-               abort();
-       }
-       /* Fix endianness in symbols */
-       for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
-               sym->st_shndx = TO_NATIVE(sym->st_shndx);
-               sym->st_name  = TO_NATIVE(sym->st_name);
-               sym->st_value = TO_NATIVE(sym->st_value);
-               sym->st_size  = TO_NATIVE(sym->st_size);
-       }
-       return;
-
- truncated:
-       fprintf(stderr, "modpost: %s is truncated.\n", filename);
-       abort();
-}
-
-void
-parse_elf_finish(struct elf_info *info)
-{
-       release_file(info->hdr, info->size);
-}
-
-#define CRC_PFX     MODULE_SYMBOL_PREFIX "__crc_"
-#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
-
-void
-handle_modversions(struct module *mod, struct elf_info *info,
-                  Elf_Sym *sym, const char *symname)
-{
-       unsigned int crc;
-
-       switch (sym->st_shndx) {
-       case SHN_COMMON:
-               fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n",
-                       symname, mod->name);
-               break;
-       case SHN_ABS:
-               /* CRC'd symbol */
-               if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
-                       crc = (unsigned int) sym->st_value;
-                       add_exported_symbol(symname + strlen(CRC_PFX),
-                                           mod, &crc);
-                       modversions = 1;
-               }
-               break;
-       case SHN_UNDEF:
-               /* undefined symbol */
-               if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL)
-                       break;
-               /* ignore global offset table */
-               if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
-                       break;
-               /* ignore __this_module, it will be resolved shortly */
-               if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
-                       break;
-#ifdef STT_REGISTER
-               if (info->hdr->e_machine == EM_SPARC ||
-                   info->hdr->e_machine == EM_SPARCV9) {
-                       /* Ignore register directives. */
-                       if (ELF_ST_TYPE(sym->st_info) == STT_REGISTER)
-                               break;
-               }
-#endif
-               
-               if (memcmp(symname, MODULE_SYMBOL_PREFIX,
-                          strlen(MODULE_SYMBOL_PREFIX)) == 0)
-                       mod->unres = alloc_symbol(symname +
-                                                 strlen(MODULE_SYMBOL_PREFIX),
-                                                 mod->unres);
-               break;
-       default:
-               /* All exported symbols */
-               if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
-                       add_exported_symbol(symname + strlen(KSYMTAB_PFX),
-                                           mod, NULL);
-               }
-               break;
-       }
-}
-
-int
-is_vmlinux(const char *modname)
-{
-       const char *myname;
-
-       if ((myname = strrchr(modname, '/')))
-               myname++;
-       else
-               myname = modname;
-
-       return strcmp(myname, "vmlinux") == 0;
-}
-
-void
-read_symbols(char *modname)
-{
-       const char *symname;
-       struct module *mod;
-       struct elf_info info = { };
-       Elf_Sym *sym;
-
-       parse_elf(&info, modname);
-
-       mod = new_module(modname);
-
-       /* When there's no vmlinux, don't print warnings about
-        * unresolved symbols (since there'll be too many ;) */
-       if (is_vmlinux(modname)) {
-               unsigned int fake_crc = 0;
-               have_vmlinux = 1;
-               /* May not have this if !CONFIG_MODULE_UNLOAD: fake it.
-                  If it appears, we'll get the real CRC. */
-               add_exported_symbol("cleanup_module", mod, &fake_crc);
-               add_exported_symbol("struct_module", mod, &fake_crc);
-               mod->skip = 1;
-       }
-
-       for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
-               symname = info.strtab + sym->st_name;
-
-               handle_modversions(mod, &info, sym, symname);
-               handle_moddevtable(mod, &info, sym, symname);
-       }
-       maybe_frob_version(modname, info.modinfo, info.modinfo_len,
-                          (void *)info.modinfo - (void *)info.hdr);
-       parse_elf_finish(&info);
-
-       /* Our trick to get versioning for struct_module - it's
-        * never passed as an argument to an exported function, so
-        * the automatic versioning doesn't pick it up, but it's really
-        * important anyhow */
-       if (modversions) {
-               mod->unres = alloc_symbol("struct_module", mod->unres);
-
-               /* Always version init_module and cleanup_module, in
-                * case module doesn't have its own. */
-               mod->unres = alloc_symbol("init_module", mod->unres);
-               mod->unres = alloc_symbol("cleanup_module", mod->unres);
-       }
-}
-
-#define SZ 500
-
-/* We first write the generated file into memory using the
- * following helper, then compare to the file on disk and
- * only update the later if anything changed */
-
-void __attribute__((format(printf, 2, 3)))
-buf_printf(struct buffer *buf, const char *fmt, ...)
-{
-       char tmp[SZ];
-       int len;
-       va_list ap;
-       
-       va_start(ap, fmt);
-       len = vsnprintf(tmp, SZ, fmt, ap);
-       if (buf->size - buf->pos < len + 1) {
-               buf->size += 128;
-               buf->p = realloc(buf->p, buf->size);
-       }
-       strncpy(buf->p + buf->pos, tmp, len + 1);
-       buf->pos += len;
-       va_end(ap);
-}
-
-void
-buf_write(struct buffer *buf, const char *s, int len)
-{
-       if (buf->size - buf->pos < len) {
-               buf->size += len;
-               buf->p = realloc(buf->p, buf->size);
-       }
-       strncpy(buf->p + buf->pos, s, len);
-       buf->pos += len;
-}
-
-/* Header for the generated file */
-
-void
-add_header(struct buffer *b)
-{
-       buf_printf(b, "#include <linux/module.h>\n");
-       buf_printf(b, "#include <linux/vermagic.h>\n");
-       buf_printf(b, "#include <linux/compiler.h>\n");
-       buf_printf(b, "\n");
-       buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
-       buf_printf(b, "\n");
-       buf_printf(b, "#undef unix\n"); /* We have a module called "unix" */
-       buf_printf(b, "struct module __this_module\n");
-       buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
-       buf_printf(b, " .name = __stringify(KBUILD_MODNAME),\n");
-       buf_printf(b, " .init = init_module,\n");
-       buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n");
-       buf_printf(b, " .exit = cleanup_module,\n");
-       buf_printf(b, "#endif\n");
-       buf_printf(b, "};\n");
-}
-
-/* Record CRCs for unresolved symbols */
-
-void
-add_versions(struct buffer *b, struct module *mod)
-{
-       struct symbol *s, *exp;
-
-       for (s = mod->unres; s; s = s->next) {
-               exp = find_symbol(s->name);
-               if (!exp || exp->module == mod) {
-                       if (have_vmlinux)
-                               fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
-                               "undefined!\n", s->name, mod->name);
-                       continue;
-               }
-               s->module = exp->module;
-               s->crc_valid = exp->crc_valid;
-               s->crc = exp->crc;
-       }
-
-       if (!modversions)
-               return;
-
-       buf_printf(b, "\n");
-       buf_printf(b, "static const struct modversion_info ____versions[]\n");
-       buf_printf(b, "__attribute_used__\n");
-       buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n");
-
-       for (s = mod->unres; s; s = s->next) {
-               if (!s->module) {
-                       continue;
-               }
-               if (!s->crc_valid) {
-                       fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
-                               "has no CRC!\n",
-                               s->name, mod->name);
-                       continue;
-               }
-               buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name);
-       }
-
-       buf_printf(b, "};\n");
-}
-
-void
-add_depends(struct buffer *b, struct module *mod, struct module *modules)
-{
-       struct symbol *s;
-       struct module *m;
-       int first = 1;
-
-       for (m = modules; m; m = m->next) {
-               m->seen = is_vmlinux(m->name);
-       }
-
-       buf_printf(b, "\n");
-       buf_printf(b, "static const char __module_depends[]\n");
-       buf_printf(b, "__attribute_used__\n");
-       buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
-       buf_printf(b, "\"depends=");
-       for (s = mod->unres; s; s = s->next) {
-               if (!s->module)
-                       continue;
-
-               if (s->module->seen)
-                       continue;
-
-               s->module->seen = 1;
-               buf_printf(b, "%s%s", first ? "" : ",",
-                          strrchr(s->module->name, '/') + 1);
-               first = 0;
-       }
-       buf_printf(b, "\";\n");
-}
-
-void
-write_if_changed(struct buffer *b, const char *fname)
-{
-       char *tmp;
-       FILE *file;
-       struct stat st;
-
-       file = fopen(fname, "r");
-       if (!file)
-               goto write;
-
-       if (fstat(fileno(file), &st) < 0)
-               goto close_write;
-
-       if (st.st_size != b->pos)
-               goto close_write;
-
-       tmp = NOFAIL(malloc(b->pos));
-       if (fread(tmp, 1, b->pos, file) != b->pos)
-               goto free_write;
-
-       if (memcmp(tmp, b->p, b->pos) != 0)
-               goto free_write;
-
-       free(tmp);
-       fclose(file);
-       return;
-
- free_write:
-       free(tmp);
- close_write:
-       fclose(file);
- write:
-       file = fopen(fname, "w");
-       if (!file) {
-               perror(fname);
-               exit(1);
-       }
-       if (fwrite(b->p, 1, b->pos, file) != b->pos) {
-               perror(fname);
-               exit(1);
-       }
-       fclose(file);
-}
-
-void
-read_dump(const char *fname)
-{
-       unsigned long size, pos = 0;
-       void *file = grab_file(fname, &size);
-       char *line;
-
-        if (!file)
-               /* No symbol versions, silently ignore */
-               return;
-
-       while ((line = get_next_line(&pos, file, size))) {
-               char *symname, *modname, *d;
-               unsigned int crc;
-               struct module *mod;
-
-               if (!(symname = strchr(line, '\t')))
-                       goto fail;
-               *symname++ = '\0';
-               if (!(modname = strchr(symname, '\t')))
-                       goto fail;
-               *modname++ = '\0';
-               if (strchr(modname, '\t'))
-                       goto fail;
-               crc = strtoul(line, &d, 16);
-               if (*symname == '\0' || *modname == '\0' || *d != '\0')
-                       goto fail;
-
-               if (!(mod = find_module(modname))) {
-                       if (is_vmlinux(modname)) {
-                               modversions = 1;
-                               have_vmlinux = 1;
-                       }
-                       mod = new_module(NOFAIL(strdup(modname)));
-                       mod->skip = 1;
-               }
-               add_exported_symbol(symname, mod, &crc);
-       }
-       return;
-fail:
-       fatal("parse error in symbol dump file\n");
-}
-
-void
-write_dump(const char *fname)
-{
-       struct buffer buf = { };
-       struct symbol *symbol;
-       int n;
-
-       for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
-               symbol = symbolhash[n];
-               while (symbol) {
-                       symbol = symbol->next;
-               }
-       }
-
-       for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
-               symbol = symbolhash[n];
-               while (symbol) {
-                       buf_printf(&buf, "0x%08x\t%s\t%s\n", symbol->crc,
-                               symbol->name, symbol->module->name);
-                       symbol = symbol->next;
-               }
-       }
-       write_if_changed(&buf, fname);
-}
-
-int
-main(int argc, char **argv)
-{
-       struct module *mod;
-       struct buffer buf = { };
-       char fname[SZ];
-       char *dump_read = NULL, *dump_write = NULL;
-       int opt;
-
-       while ((opt = getopt(argc, argv, "i:o:")) != -1) {
-               switch(opt) {
-                       case 'i':
-                               dump_read = optarg;
-                               break;
-                       case 'o':
-                               dump_write = optarg;
-                               break;
-                       default:
-                               exit(1);
-               }
-       }
-
-       if (dump_read)
-               read_dump(dump_read);
-
-       while (optind < argc) {
-               read_symbols(argv[optind++]);
-       }
-
-       for (mod = modules; mod; mod = mod->next) {
-               if (mod->skip)
-                       continue;
-
-               buf.pos = 0;
-
-               add_header(&buf);
-               add_versions(&buf, mod);
-               add_depends(&buf, mod, modules);
-               add_moddevtable(&buf, mod);
-
-               sprintf(fname, "%s.mod.c", mod->name);
-               write_if_changed(&buf, fname);
-       }
-
-       if (dump_write)
-               write_dump(dump_write);
-
-       return 0;
-}
-
diff --git a/scripts/modpost.h b/scripts/modpost.h
deleted file mode 100644 (file)
index ddb013d..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <elf.h>
-
-#include "elfconfig.h"
-
-#if KERNEL_ELFCLASS == ELFCLASS32
-
-#define Elf_Ehdr    Elf32_Ehdr 
-#define Elf_Shdr    Elf32_Shdr 
-#define Elf_Sym     Elf32_Sym
-#define ELF_ST_BIND ELF32_ST_BIND
-#define ELF_ST_TYPE ELF32_ST_TYPE
-
-#else
-
-#define Elf_Ehdr    Elf64_Ehdr 
-#define Elf_Shdr    Elf64_Shdr 
-#define Elf_Sym     Elf64_Sym
-#define ELF_ST_BIND ELF64_ST_BIND
-#define ELF_ST_TYPE ELF64_ST_TYPE
-
-#endif
-
-#if KERNEL_ELFDATA != HOST_ELFDATA
-
-static inline void __endian(const void *src, void *dest, unsigned int size)
-{
-       unsigned int i;
-       for (i = 0; i < size; i++)
-               ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1];
-}
-
-
-
-#define TO_NATIVE(x)                                           \
-({                                                             \
-       typeof(x) __x;                                          \
-       __endian(&(x), &(__x), sizeof(__x));                    \
-       __x;                                                    \
-})
-
-#else /* endianness matches */
-
-#define TO_NATIVE(x) (x)
-
-#endif
-
-#define NOFAIL(ptr)   do_nofail((ptr), __FILE__, __LINE__, #ptr)
-void *do_nofail(void *ptr, const char *file, int line, const char *expr);
-
-struct buffer {
-       char *p;
-       int pos;
-       int size;
-};
-
-void __attribute__((format(printf, 2, 3)))
-buf_printf(struct buffer *buf, const char *fmt, ...);
-
-void
-buf_write(struct buffer *buf, const char *s, int len);
-
-struct module {
-       struct module *next;
-       const char *name;
-       struct symbol *unres;
-       int seen;
-       int skip;
-       struct buffer dev_table_buf;
-};
-
-struct elf_info {
-       unsigned long size;
-       Elf_Ehdr     *hdr;
-       Elf_Shdr     *sechdrs;
-       Elf_Sym      *symtab_start;
-       Elf_Sym      *symtab_stop;
-       const char   *strtab;
-       char         *modinfo;
-       unsigned int modinfo_len;
-};
-
-void handle_moddevtable(struct module *mod, struct elf_info *info,
-                       Elf_Sym *sym, const char *symname);
-
-void add_moddevtable(struct buffer *buf, struct module *mod);
-
-void maybe_frob_version(const char *modfilename,
-                       void *modinfo,
-                       unsigned long modinfo_len,
-                       unsigned long modinfo_offset);
-
-void *grab_file(const char *filename, unsigned long *size);
-char* get_next_line(unsigned long *pos, void *file, unsigned long size);
-void release_file(void *file, unsigned long size);
diff --git a/scripts/modsign/Makefile b/scripts/modsign/Makefile
new file mode 100644 (file)
index 0000000..947f5f9
--- /dev/null
@@ -0,0 +1,27 @@
+# Set the following to `true' to make a debuggable build.
+# Leave this set to `false' for production use.
+DEBUG = true
+
+
+ROOT =         mod-extract
+VERSION =      0.1
+INSTALL_DIR =  /usr/local/bin
+RELEASE_NAME = $(ROOT)-$(VERSION)
+
+CC = gcc
+
+INCLUDES = 
+CFLAGS = -g -O -Wall
+
+OBJS = mod-extract.o
+
+all: $(ROOT)
+
+$(ROOT): $(OBJS)
+       $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) -lbfd -liberty $(LIB_OBJS) $(ARCH_LIB_OBJS)
+
+.c.o:
+       $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
+
+clean:
+       -rm $(OBJS) $(ROOT)
diff --git a/scripts/modsign/mod-extract.c b/scripts/modsign/mod-extract.c
new file mode 100644 (file)
index 0000000..f8502e7
--- /dev/null
@@ -0,0 +1,109 @@
+
+
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <bfd.h>
+
+/* This should be set in a Makefile somehow */
+#define TARGET "i686-pc-linux-gnu"
+
+static FILE *out;
+
+static void dump_data(bfd *abfd)
+{
+       asection *section;
+       bfd_byte *data = 0;
+       bfd_size_type size;
+       bfd_size_type addr_offset;
+       bfd_size_type stop_offset;
+       unsigned int opb = bfd_octets_per_byte(abfd);
+       unsigned int cksum;
+
+       for (section = abfd->sections; section != NULL; section = section->next) {
+               if (section->flags & SEC_HAS_CONTENTS) {
+                       if (bfd_section_size(abfd, section) == 0)
+                               continue;
+
+                       /* We only care about sections with "text" or "data" in their names */
+                       if ((strstr(section->name, "text") == NULL) &&
+                           (strstr(section->name, "data") == NULL))
+                               continue;
+
+                       cksum = 0;
+
+                       size = bfd_section_size(abfd, section) / opb;
+
+                       printf("Contents of section %s size %lu", section->name, size);
+
+                       data = (bfd_byte *) malloc(size);
+
+                       bfd_get_section_contents(abfd, section, (PTR) data, 0, size);
+
+                       stop_offset = size;
+
+                       printf(" idata %02x%02x%02x%02x", data[0], data[1], data[2], data[3]);
+
+                       for (addr_offset = 0; addr_offset < stop_offset; ++addr_offset) {
+                               cksum += (unsigned int) data[addr_offset];
+                               fputc(data[addr_offset], out);
+                       }
+                       free (data);
+
+                       printf(" checksum %08x\n", cksum);
+               }
+       }
+}
+
+void set_default_bfd_target(void)
+{
+       const char *target = TARGET;
+
+       if (!bfd_set_default_target(target))
+               fprintf(stderr, "can't set BFD default target to `%s': %s", target, bfd_errmsg (bfd_get_error ()));
+}
+
+int main (int argc, char *argv[])
+{
+       char *in_file;
+       char *out_file;
+       bfd *file;
+       char **matching;
+
+       if (argc != 3) {
+               fprintf(stderr, "%s [infile] [outfile]\n", argv[0]);
+               exit(1);
+       }
+
+       in_file = argv[1];
+       out_file = argv[2];
+
+       bfd_init();
+       set_default_bfd_target();
+
+
+//     file = bfd_openr(in_file, "elf32-i386");
+       file = bfd_openr(in_file, NULL);
+       if (file == NULL) {
+               fprintf(stderr, "error \"%s\" trying to open %s\n", strerror(errno), in_file);
+               exit(1);
+       }
+
+       out = fopen(out_file, "w");
+       if (out == NULL) {
+               fprintf(stderr, "error \"%s\" trying to create %s\n", strerror(errno), out_file);
+               exit(1);
+       }
+
+       if (bfd_check_format_matches(file, bfd_object, &matching)) {
+               dump_data (file);
+       }
+
+       fclose(out);
+
+       return 0;
+}
diff --git a/scripts/modsign/mod-extract.sh b/scripts/modsign/mod-extract.sh
new file mode 100644 (file)
index 0000000..a08cb08
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+sections=`objdump -h $1 |
+egrep \(text\|data\) |
+    while read sid sname stuff
+do
+  echo $sname
+done`
+
+echo $sections
+
+#objcopy -O binary $sections $1 x.raw
+objcopy -O binary -j .text $1 x.raw
+
+echo -n >x.raw
+for i in $sections
+do
+  objcopy -O binary -j $i $1 x.raw.part
+  cat x.raw.part >>x.raw
+done
+rm x.raw.part
+mv x.raw $2
diff --git a/scripts/modsign/modsign.sh b/scripts/modsign/modsign.sh
new file mode 100644 (file)
index 0000000..4d3eaa2
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+
+if [ $# = "0" ] ; then
+       echo
+#      echo "usage: $0 <module_to_sign> <key_name>"
+       echo "usage: $0 <module_to_sign>"
+       echo
+       exit 1
+fi
+
+module=$1
+#key=$2
+
+# strip out only the sections that we care about
+sh scripts/modsign/mod-extract.sh $module $module.out
+
+# sign the sections
+#gpg --no-greeting --default-key $key -b $module.out
+gpg --no-greeting --no-default-keyring --secret-keyring ../kernel.sec --keyring ../kernel.pub -b $module.out
+
+# check the signature
+#gpg --verify rxrpc.ko.out.sig rxrpc.ko.out
+
+## sha1 the sections
+#sha1sum $module.out | awk "{print \$1}" > $module.sha1
+#
+## encrypt the sections
+#gpg --no-greeting -e -o - -r $key $module.sha1 > $module.crypt
+
+# add the encrypted data to the module
+#objcopy --add-section module_sig=$module.crypt $module $module.signed
+objcopy --add-section module_sig=$module.out.sig $module $module.signed
+objcopy --set-section-flags module_sig=alloc $module.signed
+rm -f $module.out*
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
deleted file mode 100644 (file)
index 48f89e1..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-# Makefile for the different targets used to generate full packages of a kernel
-# It uses the generic clean infrastructure of kbuild
-
-# Ignore the following files/directories during tar operation
-TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
-
-
-# RPM target
-# ---------------------------------------------------------------------------
-# The rpm target generates two rpm files:
-# /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm
-# /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm
-# The src.rpm files includes all source for the kernel being built
-# The <arch>.rpm includes kernel configuration, modules etc.
-#
-# Process to create the rpm files
-# a) clean the kernel
-# b) Generate .spec file
-# c) Build a tar ball, using symlink to make kernel version
-#    first entry in the path
-# d) and pack the result to a tar.gz file
-# e) generate the rpm files, based on kernel.spec
-# - Use /. to avoid tar packing just the symlink
-
-# Do we have rpmbuild, otherwise fall back to the older rpm
-RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
-                  else echo rpm; fi)
-
-# Remove hyphens since they have special meaning in RPM filenames
-KERNELPATH := kernel-$(subst -,,$(KERNELRELEASE))
-MKSPEC     := $(srctree)/scripts/package/mkspec
-PREV       := set -e; cd ..;
-
-# rpm-pkg
-.PHONY: rpm-pkg rpm
-
-$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
-       $(CONFIG_SHELL) $(MKSPEC) > $@
-
-rpm-pkg rpm: $(objtree)/kernel.spec
-       $(MAKE) clean
-       $(PREV) ln -sf $(srctree) $(KERNELPATH)
-       $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
-       $(PREV) rm $(KERNELPATH)
-
-       set -e; \
-       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
-       set -e; \
-       mv -f $(objtree)/.tmp_version $(objtree)/.version
-
-       $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz
-       rm ../$(KERNELPATH).tar.gz
-
-clean-rule +=  rm -f $(objtree)/kernel.spec
-
-# binrpm-pkg
-.PHONY: binrpm-pkg
-$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
-       $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
-       
-binrpm-pkg: $(objtree)/binkernel.spec
-       $(MAKE)
-       set -e; \
-       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
-       set -e; \
-       mv -f $(objtree)/.tmp_version $(objtree)/.version
-
-       $(RPM) --define "_builddir $(srctree)" --target $(UTS_MACHINE) -bb $<
-
-clean-rule += rm -f $(objtree)/binkernel.spec
-
-# Deb target
-# ---------------------------------------------------------------------------
-#
-.PHONY: deb-pkg
-deb-pkg:
-       $(MAKE)
-       $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
-
-clean-rule += && rm -rf $(objtree)/debian/
-
-
-# Help text displayed when executing 'make help'
-# ---------------------------------------------------------------------------
-help:
-       @echo  '  rpm-pkg         - Build the kernel as an RPM package'
-       @echo  '  binrpm-pkg      - Build an rpm package containing the compiled kernel & modules'
-       @echo  '  deb-pkg         - Build the kernel as an deb package'
-
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
deleted file mode 100644 (file)
index 5d94e45..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-#
-#      Output a simple RPM spec file that uses no fancy features requring
-#      RPM v4. This is intended to work with any RPM distro.
-#
-#      The only gothic bit here is redefining install_post to avoid
-#      stripping the symbols from files in the kernel which we want
-#
-#      Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
-#
-
-# how we were called determines which rpms we build and how we build them
-if [ "$1" = "prebuilt" ]; then
-       PREBUILT=true
-else
-       PREBUILT=false
-fi
-
-# starting to output the spec
-if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
-       PROVIDES=kernel-drm
-fi
-
-PROVIDES="$PROVIDES kernel-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-
-echo "Name: kernel"
-echo "Summary: The Linux Kernel"
-echo "Version: "$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION | sed -e "s/-//g"
-# we need to determine the NEXT version number so that uname and
-# rpm -q will agree
-echo "Release: `. $srctree/scripts/mkversion`"
-echo "License: GPL"
-echo "Group: System Environment/Kernel"
-echo "Vendor: The Linux Community"
-echo "URL: http://www.kernel.org"
-
-if ! $PREBUILT; then
-echo -n "Source: kernel-$VERSION.$PATCHLEVEL.$SUBLEVEL"
-echo "$EXTRAVERSION.tar.gz" | sed -e "s/-//g"
-fi
-
-echo "BuildRoot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root"
-echo "Provides: $PROVIDES"
-echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
-echo "%define debug_package %{nil}"
-echo ""
-echo "%description"
-echo "The Linux Kernel, the operating system core itself"
-echo ""
-
-if ! $PREBUILT; then
-echo "%prep"
-echo "%setup -q"
-echo ""
-fi
-
-echo "%build"
-
-if ! $PREBUILT; then
-echo "make clean && make"
-echo ""
-fi
-
-echo "%install"
-echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'
-
-echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make modules_install'
-echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-
-echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-
-echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo ""
-echo "%clean"
-echo '#echo -rf $RPM_BUILD_ROOT'
-echo ""
-echo "%files"
-echo '%defattr (-, root, root)'
-echo "%dir /lib/modules"
-echo "/lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo "/boot/*"
-echo ""
index 8f80364..9d01ec5 100644 (file)
@@ -106,4 +106,4 @@ foreach $object (keys(%object)) {
 }
 # printf("Done\n");
 
-exit(0);
+exit($errorcount);
index b4e37dc..5f33311 100644 (file)
@@ -90,6 +90,7 @@ foreach $object (sort(keys(%object))) {
                if (($line =~ /\.init$/ || $line =~ /\.init\./) &&
                    ($from !~ /\.init$/ &&
                     $from !~ /\.init\./ &&
+                    $from !~ /\.eh_frame$/ &&
                     $from !~ /\.stab$/ &&
                     $from !~ /\.rodata$/ &&
                     $from !~ /\.text\.lock$/ &&
diff --git a/scripts/sumversion.c b/scripts/sumversion.c
deleted file mode 100644 (file)
index b41b718..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-#include <netinet/in.h>
-#include <stdint.h>
-#include <ctype.h>
-#include <errno.h>
-#include <string.h>
-#include "modpost.h"
-
-/* Parse tag=value strings from .modinfo section */
-static char *next_string(char *string, unsigned long *secsize)
-{
-       /* Skip non-zero chars */
-       while (string[0]) {
-               string++;
-               if ((*secsize)-- <= 1)
-                       return NULL;
-       }
-
-       /* Skip any zero padding. */
-       while (!string[0]) {
-               string++;
-               if ((*secsize)-- <= 1)
-                       return NULL;
-       }
-       return string;
-}
-
-static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
-                        const char *tag)
-{
-       char *p;
-       unsigned int taglen = strlen(tag);
-       unsigned long size = modinfo_len;
-
-       for (p = modinfo; p; p = next_string(p, &size)) {
-               if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
-                       return p + taglen + 1;
-       }
-       return NULL;
-}
-
-/*
- * Stolen form Cryptographic API.
- *
- * MD4 Message Digest Algorithm (RFC1320).
- *
- * Implementation derived from Andrew Tridgell and Steve French's
- * CIFS MD4 implementation, and the cryptoapi implementation
- * originally based on the public domain implementation written
- * by Colin Plumb in 1993.
- *
- * Copyright (c) Andrew Tridgell 1997-1998.
- * Modified by Steve French (sfrench@us.ibm.com) 2002
- * Copyright (c) Cryptoapi developers.
- * Copyright (c) 2002 David S. Miller (davem@redhat.com)
- * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- */
-#define MD4_DIGEST_SIZE                16
-#define MD4_HMAC_BLOCK_SIZE    64
-#define MD4_BLOCK_WORDS                16
-#define MD4_HASH_WORDS         4
-
-struct md4_ctx {
-       uint32_t hash[MD4_HASH_WORDS];
-       uint32_t block[MD4_BLOCK_WORDS];
-       uint64_t byte_count;
-};
-
-static inline uint32_t lshift(uint32_t x, unsigned int s)
-{
-       x &= 0xFFFFFFFF;
-       return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
-}
-
-static inline uint32_t F(uint32_t x, uint32_t y, uint32_t z)
-{
-       return (x & y) | ((~x) & z);
-}
-
-static inline uint32_t G(uint32_t x, uint32_t y, uint32_t z)
-{
-       return (x & y) | (x & z) | (y & z);
-}
-
-static inline uint32_t H(uint32_t x, uint32_t y, uint32_t z)
-{
-       return x ^ y ^ z;
-}
-
-#define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s))
-#define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (uint32_t)0x5A827999,s))
-#define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (uint32_t)0x6ED9EBA1,s))
-
-/* XXX: this stuff can be optimized */
-static inline void le32_to_cpu_array(uint32_t *buf, unsigned int words)
-{
-       while (words--) {
-               *buf = ntohl(*buf);
-               buf++;
-       }
-}
-
-static inline void cpu_to_le32_array(uint32_t *buf, unsigned int words)
-{
-       while (words--) {
-               *buf = htonl(*buf);
-               buf++;
-       }
-}
-
-static void md4_transform(uint32_t *hash, uint32_t const *in)
-{
-       uint32_t a, b, c, d;
-
-       a = hash[0];
-       b = hash[1];
-       c = hash[2];
-       d = hash[3];
-
-       ROUND1(a, b, c, d, in[0], 3);
-       ROUND1(d, a, b, c, in[1], 7);
-       ROUND1(c, d, a, b, in[2], 11);
-       ROUND1(b, c, d, a, in[3], 19);
-       ROUND1(a, b, c, d, in[4], 3);
-       ROUND1(d, a, b, c, in[5], 7);
-       ROUND1(c, d, a, b, in[6], 11);
-       ROUND1(b, c, d, a, in[7], 19);
-       ROUND1(a, b, c, d, in[8], 3);
-       ROUND1(d, a, b, c, in[9], 7);
-       ROUND1(c, d, a, b, in[10], 11);
-       ROUND1(b, c, d, a, in[11], 19);
-       ROUND1(a, b, c, d, in[12], 3);
-       ROUND1(d, a, b, c, in[13], 7);
-       ROUND1(c, d, a, b, in[14], 11);
-       ROUND1(b, c, d, a, in[15], 19);
-
-       ROUND2(a, b, c, d,in[ 0], 3);
-       ROUND2(d, a, b, c, in[4], 5);
-       ROUND2(c, d, a, b, in[8], 9);
-       ROUND2(b, c, d, a, in[12], 13);
-       ROUND2(a, b, c, d, in[1], 3);
-       ROUND2(d, a, b, c, in[5], 5);
-       ROUND2(c, d, a, b, in[9], 9);
-       ROUND2(b, c, d, a, in[13], 13);
-       ROUND2(a, b, c, d, in[2], 3);
-       ROUND2(d, a, b, c, in[6], 5);
-       ROUND2(c, d, a, b, in[10], 9);
-       ROUND2(b, c, d, a, in[14], 13);
-       ROUND2(a, b, c, d, in[3], 3);
-       ROUND2(d, a, b, c, in[7], 5);
-       ROUND2(c, d, a, b, in[11], 9);
-       ROUND2(b, c, d, a, in[15], 13);
-
-       ROUND3(a, b, c, d,in[ 0], 3);
-       ROUND3(d, a, b, c, in[8], 9);
-       ROUND3(c, d, a, b, in[4], 11);
-       ROUND3(b, c, d, a, in[12], 15);
-       ROUND3(a, b, c, d, in[2], 3);
-       ROUND3(d, a, b, c, in[10], 9);
-       ROUND3(c, d, a, b, in[6], 11);
-       ROUND3(b, c, d, a, in[14], 15);
-       ROUND3(a, b, c, d, in[1], 3);
-       ROUND3(d, a, b, c, in[9], 9);
-       ROUND3(c, d, a, b, in[5], 11);
-       ROUND3(b, c, d, a, in[13], 15);
-       ROUND3(a, b, c, d, in[3], 3);
-       ROUND3(d, a, b, c, in[11], 9);
-       ROUND3(c, d, a, b, in[7], 11);
-       ROUND3(b, c, d, a, in[15], 15);
-
-       hash[0] += a;
-       hash[1] += b;
-       hash[2] += c;
-       hash[3] += d;
-}
-
-static inline void md4_transform_helper(struct md4_ctx *ctx)
-{
-       le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(uint32_t));
-       md4_transform(ctx->hash, ctx->block);
-}
-
-static void md4_init(struct md4_ctx *mctx)
-{
-       mctx->hash[0] = 0x67452301;
-       mctx->hash[1] = 0xefcdab89;
-       mctx->hash[2] = 0x98badcfe;
-       mctx->hash[3] = 0x10325476;
-       mctx->byte_count = 0;
-}
-
-static void md4_update(struct md4_ctx *mctx,
-                      const unsigned char *data, unsigned int len)
-{
-       const uint32_t avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
-
-       mctx->byte_count += len;
-
-       if (avail > len) {
-               memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-                      data, len);
-               return;
-       }
-
-       memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-              data, avail);
-
-       md4_transform_helper(mctx);
-       data += avail;
-       len -= avail;
-
-       while (len >= sizeof(mctx->block)) {
-               memcpy(mctx->block, data, sizeof(mctx->block));
-               md4_transform_helper(mctx);
-               data += sizeof(mctx->block);
-               len -= sizeof(mctx->block);
-       }
-
-       memcpy(mctx->block, data, len);
-}
-
-static void md4_final_ascii(struct md4_ctx *mctx, char *out, unsigned int len)
-{
-       const unsigned int offset = mctx->byte_count & 0x3f;
-       char *p = (char *)mctx->block + offset;
-       int padding = 56 - (offset + 1);
-
-       *p++ = 0x80;
-       if (padding < 0) {
-               memset(p, 0x00, padding + sizeof (uint64_t));
-               md4_transform_helper(mctx);
-               p = (char *)mctx->block;
-               padding = 56;
-       }
-
-       memset(p, 0, padding);
-       mctx->block[14] = mctx->byte_count << 3;
-       mctx->block[15] = mctx->byte_count >> 29;
-       le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
-                         sizeof(uint64_t)) / sizeof(uint32_t));
-       md4_transform(mctx->hash, mctx->block);
-       cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(uint32_t));
-
-       snprintf(out, len, "%08X%08X%08X%08X",
-                mctx->hash[0], mctx->hash[1], mctx->hash[2], mctx->hash[3]);
-}
-
-static inline void add_char(unsigned char c, struct md4_ctx *md)
-{
-       md4_update(md, &c, 1);
-}
-
-static int parse_string(const char *file, unsigned long len,
-                       struct md4_ctx *md)
-{
-       unsigned long i;
-
-       add_char(file[0], md);
-       for (i = 1; i < len; i++) {
-               add_char(file[i], md);
-               if (file[i] == '"' && file[i-1] != '\\')
-                       break;
-       }
-       return i;
-}
-
-static int parse_comment(const char *file, unsigned long len)
-{
-       unsigned long i;
-
-       for (i = 2; i < len; i++) {
-               if (file[i-1] == '*' && file[i] == '/')
-                       break;
-       }
-       return i;
-}
-
-/* FIXME: Handle .s files differently (eg. # starts comments) --RR */
-static int parse_file(const char *fname, struct md4_ctx *md)
-{
-       char *file;
-       unsigned long i, len;
-
-       file = grab_file(fname, &len);
-       if (!file)
-               return 0;
-
-       for (i = 0; i < len; i++) {
-               /* Collapse and ignore \ and CR. */
-               if (file[i] == '\\' && (i+1 < len) && file[i+1] == '\n') {
-                       i++;
-                       continue;
-               }
-
-               /* Ignore whitespace */
-               if (isspace(file[i]))
-                       continue;
-
-               /* Handle strings as whole units */
-               if (file[i] == '"') {
-                       i += parse_string(file+i, len - i, md);
-                       continue;
-               }
-
-               /* Comments: ignore */
-               if (file[i] == '/' && file[i+1] == '*') {
-                       i += parse_comment(file+i, len - i);
-                       continue;
-               }
-
-               add_char(file[i], md);
-       }
-       release_file(file, len);
-       return 1;
-}
-
-/* We have dir/file.o.  Open dir/.file.o.cmd, look for deps_ line to
- * figure out source file. */
-static int parse_source_files(const char *objfile, struct md4_ctx *md)
-{
-       char *cmd, *file, *line, *dir;
-       const char *base;
-       unsigned long flen, pos = 0;
-       int dirlen, ret = 0, check_files = 0;
-
-       cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd")));
-
-       base = strrchr(objfile, '/');
-       if (base) {
-               base++;
-               dirlen = base - objfile;
-               sprintf(cmd, "%.*s.%s.cmd", dirlen, objfile, base);
-       } else {
-               dirlen = 0;
-               sprintf(cmd, ".%s.cmd", objfile);
-       }
-       dir = NOFAIL(malloc(dirlen + 1));
-       strncpy(dir, objfile, dirlen);
-       dir[dirlen] = '\0';
-
-       file = grab_file(cmd, &flen);
-       if (!file) {
-               fprintf(stderr, "Warning: could not find %s for %s\n",
-                       cmd, objfile);
-               goto out;
-       }
-
-       /* There will be a line like so:
-               deps_drivers/net/dummy.o := \
-                 drivers/net/dummy.c \
-                   $(wildcard include/config/net/fastroute.h) \
-                 include/linux/config.h \
-                   $(wildcard include/config/h.h) \
-                 include/linux/module.h \
-
-          Sum all files in the same dir or subdirs.
-       */
-       while ((line = get_next_line(&pos, file, flen)) != NULL) {
-               char* p = line;
-               if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
-                       check_files = 1;
-                       continue;
-               }
-               if (!check_files)
-                       continue;
-
-               /* Continue until line does not end with '\' */
-               if ( *(p + strlen(p)-1) != '\\')
-                       break;
-               /* Terminate line at first space, to get rid of final ' \' */
-               while (*p) {
-                       if (isspace(*p)) {
-                               *p = '\0';
-                               break;
-                       }
-                       p++;
-               }
-
-               /* Check if this file is in same dir as objfile */
-               if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
-                       if (!parse_file(line, md)) {
-                               fprintf(stderr,
-                                       "Warning: could not open %s: %s\n",
-                                       line, strerror(errno));
-                               goto out_file;
-                       }
-
-               }
-
-       }
-
-       /* Everyone parsed OK */
-       ret = 1;
-out_file:
-       release_file(file, flen);
-out:
-       free(dir);
-       free(cmd);
-       return ret;
-}
-
-static int get_version(const char *modname, char sum[])
-{
-       void *file;
-       unsigned long len;
-       int ret = 0;
-       struct md4_ctx md;
-       char *sources, *end, *fname;
-       const char *basename;
-       char filelist[sizeof(".tmp_versions/%s.mod") + strlen(modname)];
-
-       /* Source files for module are in .tmp_versions/modname.mod,
-          after the first line. */
-       if (strrchr(modname, '/'))
-               basename = strrchr(modname, '/') + 1;
-       else
-               basename = modname;
-       sprintf(filelist, ".tmp_versions/%s", basename);
-       /* Truncate .o, add .mod */
-       strcpy(filelist + strlen(filelist)-2, ".mod");
-
-       file = grab_file(filelist, &len);
-       if (!file) {
-               fprintf(stderr, "Warning: could not find versions for %s\n",
-                       filelist);
-               return 0;
-       }
-
-       sources = strchr(file, '\n');
-       if (!sources) {
-               fprintf(stderr, "Warning: malformed versions file for %s\n",
-                       modname);
-               goto release;
-       }
-
-       sources++;
-       end = strchr(sources, '\n');
-       if (!end) {
-               fprintf(stderr, "Warning: bad ending versions file for %s\n",
-                       modname);
-               goto release;
-       }
-       *end = '\0';
-
-       md4_init(&md);
-       for (fname = strtok(sources, " "); fname; fname = strtok(NULL, " ")) {
-               if (!parse_source_files(fname, &md))
-                       goto release;
-       }
-
-       /* sum is of form \0<padding>. */
-       md4_final_ascii(&md, sum, 1 + strlen(sum+1));
-       ret = 1;
-release:
-       release_file(file, len);
-       return ret;
-}
-
-static void write_version(const char *filename, const char *sum,
-                         unsigned long offset)
-{
-       int fd;
-
-       fd = open(filename, O_RDWR);
-       if (fd < 0) {
-               fprintf(stderr, "Warning: changing sum in %s failed: %s\n",
-                       filename, strerror(errno));
-               return;
-       }
-
-       if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
-               fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n",
-                       filename, offset, strerror(errno));
-               goto out;
-       }
-
-       if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
-               fprintf(stderr, "Warning: writing sum in %s failed: %s\n",
-                       filename, strerror(errno));
-               goto out;
-       }
-out:
-       close(fd);
-}
-
-void strip_rcs_crap(char *version)
-{
-       unsigned int len, full_len;
-
-       if (strncmp(version, "$Revision", strlen("$Revision")) != 0)
-               return;
-
-       /* Space for version string follows. */
-       full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2;
-
-       /* Move string to start with version number: prefix will be
-        * $Revision$ or $Revision: */
-       len = strlen("$Revision");
-       if (version[len] == ':' || version[len] == '$')
-               len++;
-       while (isspace(version[len]))
-               len++;
-       memmove(version, version+len, full_len-len);
-       full_len -= len;
-
-       /* Preserve up to next whitespace. */
-       len = 0;
-       while (version[len] && !isspace(version[len]))
-               len++;
-       memmove(version + len, version + strlen(version),
-               full_len - strlen(version));
-}
-
-/* If the modinfo contains a "version" value, then set this. */
-void maybe_frob_version(const char *modfilename,
-                       void *modinfo,
-                       unsigned long modinfo_len,
-                       unsigned long modinfo_offset)
-{
-       char *version, *csum;
-
-       version = get_modinfo(modinfo, modinfo_len, "version");
-       if (!version)
-               return;
-
-       /* RCS $Revision gets stripped out. */
-       strip_rcs_crap(version);
-
-       /* Check against double sumversion */
-       if (strchr(version, ' '))
-               return;
-
-       /* Version contains embedded NUL: second half has space for checksum */
-       csum = version + strlen(version);
-       *(csum++) = ' ';
-       if (get_version(modfilename, csum))
-               write_version(modfilename, version,
-                             modinfo_offset + (version - (char *)modinfo));
-}
index 2895693..5f629be 100644 (file)
@@ -120,7 +120,7 @@ void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
        /* Derived from fs/exec.c:compute_creds. */
        kernel_cap_t new_permitted, working;
 
-       new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
+       new_permitted = cap_intersect (bprm->cap_permitted, vx_current_bcaps());
        working = cap_intersect (bprm->cap_inheritable,
                                 current->cap_inheritable);
        new_permitted = cap_combine (new_permitted, working);
index e6d5a04..714b1a6 100644 (file)
@@ -3,6 +3,7 @@
 # Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
 #
 
+CFLAGS_pcm_plugin.o += -g0
 snd-mixer-oss-objs := mixer_oss.o
 
 snd-pcm-oss-objs := pcm_oss.o pcm_plugin.o \
index 099d230..86e50e5 100644 (file)
@@ -1807,6 +1807,13 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
        snd_pcm_oss_setup_t *psetup = NULL, *csetup = NULL;
        int nonblock;
        wait_queue_t wait;
+       static char printed_comm[16];
+
+       if (strncmp(printed_comm, current->comm, 16)) {
+               printk("application %s uses obsolete OSS audio interface\n",
+                      current->comm);
+               memcpy(printed_comm, current->comm, 16);
+       }
 
        snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
        device = SNDRV_MINOR_OSS_DEVICE(minor) == SNDRV_MINOR_OSS_PCM1 ?
diff --git a/sound/isa/cs423x/pc98.c b/sound/isa/cs423x/pc98.c
deleted file mode 100644 (file)
index ec0b4cc..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- *  Driver for CS4232 on NEC PC9800 series
- *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
- *                   Osamu Tomita <tomita@cinet.co.jp>
- *                   Takashi Iwai <tiwai@suse.de>
- *                   Hideaki Okubo <okubo@msh.biglobe.ne.jp>
- *
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- */
-
-#include <sound/driver.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/moduleparam.h>
-#include <sound/core.h>
-#include <sound/cs4231.h>
-#include <sound/mpu401.h>
-#include <sound/opl3.h>
-#include <sound/initval.h>
-#include "sound_pc9800.h"
-
-#define chip_t cs4231_t
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DESCRIPTION("NEC PC9800 CS4232");
-MODULE_DEVICES("{{NEC,PC9800}}");
-
-#define IDENT "PC98-CS4232"
-
-static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
-static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
-static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
-static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;    /* PnP setup */
-#if 0 /* NOT USED */
-static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;   /* PnP setup */
-#endif
-static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* PnP setup */
-static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
-static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;       /* 5,7,9,11,12,15 */
-static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;   /* 9,11,12,15 */
-static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;      /* 0,1,3,5,6,7 */
-static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;      /* 0,1,3,5,6,7 */
-static int pc98ii[SNDRV_CARDS];                                /* PC98II */
-static int boot_devs;
-
-module_param_array(index, int, boot_devs, 0444);
-MODULE_PARM_DESC(index, "Index value for " IDENT " soundcard.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
-module_param_array(id, charp, boot_devs, 0444);
-MODULE_PARM_DESC(id, "ID string for " IDENT " soundcard.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
-module_param_array(enable, bool, boot_devs, 0444);
-MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
-module_param_array(port, long, boot_devs, 0444);
-MODULE_PARM_DESC(port, "Port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(port, SNDRV_PORT12_DESC);
-#if 0 /* NOT USED */
-module_param_array(cport, long, boot_devs, 0444);
-MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(cport, SNDRV_PORT12_DESC);
-#endif
-module_param_array(mpu_port, long, boot_devs, 0444);
-MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT12_DESC);
-module_param_array(fm_port, long, boot_devs, 0444);
-MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(fm_port, SNDRV_PORT12_DESC);
-module_param_array(irq, int, boot_devs, 0444);
-MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(irq, SNDRV_IRQ_DESC);
-module_param_array(mpu_irq, int, boot_devs, 0444);
-MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(mpu_irq, SNDRV_IRQ_DESC);
-module_param_array(dma1, int, boot_devs, 0444);
-MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(dma1, SNDRV_DMA_DESC);
-module_param_array(dma2, int, boot_devs, 0444);
-MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(dma2, SNDRV_DMA_DESC);
-module_param_array(pc98ii, bool, boot_devs, 0444);
-MODULE_PARM_DESC(pc98ii, "Roland MPU-PC98II support.");
-MODULE_PARM_SYNTAX(pc98ii, SNDRV_BOOLEAN_FALSE_DESC);
-
-
-static snd_card_t *snd_pc98_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
-
-/*
- * initialize MPU401-UART
- */
-
-static int __init pc98_mpu401_init(int irq)
-{
-#include "pc9801_118_magic.h"
-#define outp118(reg,data) outb((reg),0x148e);outb((data),0x148f)
-#define WAIT118 outb(0x00,0x5f)
-       int     mpu_intr, count;
-#ifdef OOKUBO_ORIGINAL
-       int     err = 0;
-#endif /* OOKUBO_ORIGINAL */
-
-       switch (irq) {
-       case 3:
-               mpu_intr = 3;
-               break;
-       case 5:
-               mpu_intr = 2;
-               break;
-       case 6:
-               mpu_intr = 1;
-               break;
-       case 10:
-               mpu_intr = 0;
-               break;
-       default:
-               snd_printk(KERN_ERR IDENT ": Bad IRQ %d\n", irq);
-               return -EINVAL;
-       }
-
-       outp118(0x21, mpu_intr);
-       WAIT118;
-       outb(0x00, 0x148e);
-       if (inb(0x148f) & 0x08) {
-               snd_printk(KERN_INFO IDENT ": No MIDI daughter board found\n");
-               return 0;
-       }
-
-       outp118(0x20, 0x00);
-       outp118(0x05, 0x04);
-       for (count = 0; count < 35000; count ++)
-               WAIT118;
-       outb(0x05, 0x148e);
-       for (count = 0; count < 65000; count ++)
-               if (inb(0x148f) == 0x04)
-                       goto set_mode_118;
-       snd_printk(KERN_ERR IDENT ": MIDI daughter board initialize failed at stage1\n\n");
-       return -EINVAL;
-
- set_mode_118:
-       outp118(0x05, 0x0c);
-       outb(0xaa, 0x485);
-       outb(0x99, 0x485);
-       outb(0x2a, 0x485);
-       for (count = 0; count < sizeof(Data0485_99); count ++) {
-               outb(Data0485_99[count], 0x485);
-               WAIT118;
-       }
-
-       outb(0x00, 0x486);
-       outb(0xaa, 0x485);
-       outb(0x9e, 0x485);
-       outb(0x2a, 0x485);
-       for (count = 0; count < sizeof(Data0485_9E); count ++)
-               if (inb(0x485) != Data0485_9E[count]) {
-#ifdef OOKUBO_ORIGINAL
-                       err = 1;
-#endif /* OOKUBO_ORIGINAL */
-                       break;
-               }
-       outb(0x00, 0x486);
-       for (count = 0; count < 2000; count ++)
-               WAIT118;
-#ifdef OOKUBO_ORIGINAL
-       if (!err) {
-               outb(0xaa, 0x485);
-               outb(0x36, 0x485);
-               outb(0x28, 0x485);
-               for (count = 0; count < sizeof(Data0485_36); count ++)
-                       outb(Data0485_36[count], 0x485);
-               outb(0x00, 0x486);
-               for (count = 0; count < 1500; count ++)
-                       WAIT118;
-               outp118(0x05, inb(0x148f) | 0x08);
-               outb(0xff, 0x148c);
-               outp118(0x05, inb(0x148f) & 0xf7);
-               for (count = 0; count < 1500; count ++)
-                       WAIT118;
-       }
-#endif /* OOKUBO_ORIGINAL */
-
-       outb(0xaa, 0x485);
-       outb(0xa9, 0x485);
-       outb(0x21, 0x485);
-       for (count = 0; count < sizeof(Data0485_A9); count ++) {
-               outb(Data0485_A9[count], 0x485);
-               WAIT118;
-       }
-
-       outb(0x00, 0x486);
-       outb(0xaa, 0x485);
-       outb(0x0c, 0x485);
-       outb(0x20, 0x485);
-       for (count = 0; count < sizeof(Data0485_0C); count ++) {
-               outb(Data0485_0C[count], 0x485);
-               WAIT118;
-       }
-
-       outb(0x00, 0x486);
-       outb(0xaa, 0x485);
-       outb(0x66, 0x485);
-       outb(0x20, 0x485);
-       for (count = 0; count < sizeof(Data0485_66); count ++) {
-               outb(Data0485_66[count], 0x485);
-               WAIT118;
-       }
-
-       outb(0x00, 0x486);
-       outb(0xaa, 0x485);
-       outb(0x60, 0x485);
-       outb(0x20, 0x485);
-       for (count = 0; count < sizeof(Data0485_60); count ++) {
-               outb(Data0485_60[count], 0x485);
-               WAIT118;
-       }
-
-       outb(0x00, 0x486);
-       outp118(0x05, 0x04);
-       outp118(0x05, 0x00);
-       for (count = 0; count < 35000; count ++)
-               WAIT118;
-       outb(0x05, 0x148e);
-       for (count = 0; count < 65000; count ++)
-               if (inb(0x148f) == 0x00)
-                       goto end_mode_118;
-       snd_printk(KERN_ERR IDENT ": MIDI daughter board initialize failed at stage2\n");
-       return -EINVAL;
-
- end_mode_118:
-       outb(0x3f, 0x148d);
-       snd_printk(KERN_INFO IDENT ": MIDI daughter board initialized\n");
-       return 0;
-}
-
-static int __init pc98_cs4231_chip_init(int dev)
-{
-       int intr_bits, intr_bits2, dma_bits;
-
-       switch (irq[dev]) {
-       case 3:
-               intr_bits = 0x08;
-               intr_bits2 = 0x03;
-               break;
-       case 5:
-               intr_bits = 0x10;
-               intr_bits2 = 0x08;
-               break;
-       case 10:
-               intr_bits = 0x18;
-               intr_bits2 = 0x02;
-               break;
-       case 12:
-               intr_bits = 0x20;
-               intr_bits2 = 0x00;
-               break;
-       default:
-               snd_printk(KERN_ERR IDENT ": Bad IRQ %d\n", irq[dev]);
-               return -EINVAL;
-       }
-
-       switch (dma1[dev]) {
-       case 0:
-               dma_bits = 0x01;
-               break;
-       case 1:
-               dma_bits = 0x02;
-               break;
-       case 3:
-               dma_bits = 0x03;
-               break;
-       default:
-               snd_printk(KERN_ERR IDENT ": Bad DMA %d\n", dma1[dev]);
-               return -EINVAL;
-       }
-
-       if (dma2[dev] >= 2) {
-               snd_printk(KERN_ERR IDENT ": Bad DMA %d\n", dma2[dev]);
-               return -EINVAL;
-       }
-
-       outb(dma1[dev], 0x29);          /* dma1 boundary 64KB */
-       if (dma1[dev] != dma2[dev] && dma2[dev] >= 0) {
-               outb(0, 0x5f);          /* wait */
-               outb(dma2[dev], 0x29);  /* dma2 boundary 64KB */
-               intr_bits |= 0x04;
-       }
-
-       if (PC9800_SOUND_ID() == PC9800_SOUND_ID_118) {
-               /* Set up CanBe control registers. */
-               snd_printd(KERN_INFO "Setting up CanBe Sound System\n");
-               outb(inb(PC9800_SOUND_IO_ID) | 0x03, PC9800_SOUND_IO_ID);
-               outb(0x01, 0x0f4a);
-               outb(intr_bits2, 0x0f4b);
-       }
-
-       outb(intr_bits | dma_bits, 0xf40);
-       return 0;
-}
-
-
-static int __init snd_card_pc98_probe(int dev)
-{
-       snd_card_t *card;
-       snd_pcm_t *pcm = NULL;
-       cs4231_t *chip;
-       opl3_t *opl3;
-       int err;
-
-       if (port[dev] == SNDRV_AUTO_PORT) {
-               snd_printk(KERN_ERR IDENT ": specify port\n");
-               return -EINVAL;
-       }
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
-       if (card == NULL)
-               return -ENOMEM;
-
-       if ((err = pc98_cs4231_chip_init(dev)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
-
-       if ((err = snd_cs4231_create(card,
-                                    port[dev],
-                                    -1,
-                                    irq[dev],
-                                    dma1[dev],
-                                    dma2[dev],
-                                    CS4231_HW_DETECT,
-                                    0,
-                                    &chip)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
-       if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
-       if ((err = snd_cs4231_mixer(chip)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
-
-       if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
-
-       if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
-               /* ??? */
-               outb(0x00, fm_port[dev] + 6);
-               inb(fm_port[dev] + 7);
-               /* Enable OPL-3 Function */
-               outb(inb(PC9800_SOUND_IO_ID) | 0x03, PC9800_SOUND_IO_ID);
-               if (snd_opl3_create(card,
-                                   fm_port[dev], fm_port[dev] + 2,
-                                   OPL3_HW_OPL3_PC98, 0, &opl3) < 0) {
-                       printk(KERN_ERR IDENT ": OPL3 not detected\n");
-               } else {
-                       if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
-                               snd_card_free(card);
-                               return err;
-                       }
-               }
-       }
-
-       if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
-               err = pc98_mpu401_init(mpu_irq[dev]);
-               if (! err) {
-                       err = snd_mpu401_uart_new(card, 0,
-                                                 pc98ii[dev] ? MPU401_HW_PC98II : MPU401_HW_MPU401,
-                                                 mpu_port[dev], 0,
-                                                 mpu_irq[dev], SA_INTERRUPT, NULL);
-                       if (err < 0)
-                               snd_printk(KERN_INFO IDENT ": MPU401 not detected\n");
-               }
-       }
-
-       strcpy(card->driver, pcm->name);
-       strcpy(card->shortname, pcm->name);
-       sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",
-               pcm->name,
-               chip->port,
-               irq[dev],
-               dma1[dev]);
-       if (dma2[dev] >= 0)
-               sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
-       if ((err = snd_card_register(card)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
-       snd_pc98_cards[dev] = card;
-       return 0;
-}
-
-static int __init alsa_card_pc98_init(void)
-{
-       int dev, cards = 0;
-
-       for (dev = 0; dev < SNDRV_CARDS; dev++) {
-               if (!enable[dev])
-                       continue;
-               if (snd_card_pc98_probe(dev) >= 0)
-                       cards++;
-       }
-       if (!cards) {
-#ifdef MODULE
-               printk(KERN_ERR IDENT " soundcard not found or device busy\n");
-#endif
-               return -ENODEV;
-       }
-       return 0;
-}
-
-static void __exit alsa_card_pc98_exit(void)
-{
-       int idx;
-
-       for (idx = 0; idx < SNDRV_CARDS; idx++)
-               snd_card_free(snd_pc98_cards[idx]);
-}
-
-module_init(alsa_card_pc98_init)
-module_exit(alsa_card_pc98_exit)
diff --git a/sound/isa/cs423x/pc9801_118_magic.h b/sound/isa/cs423x/pc9801_118_magic.h
deleted file mode 100644 (file)
index 2452127..0000000
+++ /dev/null
@@ -1,411 +0,0 @@
-               static unsigned char    Data0485_A9[] = {
-               0x12, 0x03, 0x90, 0xc2, 0x2a, 0x75, 0x1e, 0x20,
-               0xe4, 0x12, 0x2b, 0x9b, 0x22, 0xa9, 0x16, 0x77,
-               0x33, 0xe9, 0x04, 0x54, 0x03, 0x44, 0xa8, 0xf5,
-               0x16, 0xc2, 0x2f, 0x22, 0xa9, 0x16, 0x77, 0x42,
-               0xe9, 0x04, 0x54, 0x03, 0x44, 0xa8, 0xf9, 0x77,
-               0xf8, 0x04, 0x54, 0x03, 0x44, 0xa8, 0xf5, 0x16,
-               0xc2, 0x2f, 0x22, 0x90, 0x25, 0x9f, 0x30, 0x04,
-               0x05, 0xc2, 0x04, 0x12, 0x1f, 0x62, 0x30, 0x00,
-               0x05, 0xc2, 0x00, 0x12, 0x15, 0xe6, 0x30, 0x01,
-               0x05, 0xc2, 0x01, 0x12, 0x29, 0xaf, 0x30, 0x02,
-               0x05, 0xc2, 0x02, 0x12, 0x29, 0xaf, 0x30, 0x05,
-               0x05, 0xc2, 0x05, 0x12, 0x16, 0x65, 0x30, 0x06,
-               0x08, 0xc2, 0x06, 0x12, 0x16, 0xb1, 0x12, 0x29,
-               0xaf, 0x30, 0x07, 0x08, 0xc2, 0x07, 0x12, 0x16,
-               0xe9, 0x12, 0x29, 0xaf, 0x22, 0x20, 0x97, 0x09,
-               0x53, 0xa8, 0xfb, 0x12, 0x04, 0x2c, 0x43, 0xa8,
-               0x04, 0x22, 0x71, 0xb8, 0x71, 0xb8, 0x71, 0xb8,
-               0x22, 0x20, 0x4b, 0x04, 0x75, 0x4e, 0x02, 0x22,
-               0xe5, 0x35, 0x24, 0xff, 0xf5, 0x35, 0xe5, 0x36,
-               0x34, 0xff, 0xf5, 0x36, 0x75, 0x4e, 0x02, 0x22,
-               0x10, 0x19, 0x02, 0x80, 0x08, 0x78, 0x00, 0xe2,
-               0x78, 0x07, 0xf2, 0x61, 0x9b, 0x78, 0x11, 0xe2,
-               0xc0, 0x01, 0xc0, 0xf0, 0xc0, 0xd0, 0xc0, 0x02,
-               0x71, 0x14, 0xe5, 0x30, 0xb4, 0x01, 0x02, 0x61,
-               0x93, 0x43, 0x08, 0x40, 0x12, 0x2a, 0x53, 0x61,
-               0x93, 0x79, 0x03, 0xe3, 0xa2, 0xe2, 0x92, 0x26,
-               0xa2, 0xe3, 0x92, 0x27, 0x22, 0xad, 0x2b, 0xbd,
-               0x04, 0x07, 0xf5, 0x72, 0x78, 0x27, 0x02, 0x11,
-               0x76, 0x02, 0x11, 0x30, 0x00, 0x00, 0x00, 0x12,
-               0x28, 0xba, 0x79, 0x01, 0xe3, 0x75, 0x21, 0x3f,
-               0x75, 0x49, 0x11, 0x75, 0x4c, 0x11, 0x31, 0xdc,
-               0x75, 0x1a, 0x80, 0x51, 0x72, 0x75, 0x81, 0xe3,
-               0x12, 0x25, 0xc9, 0x43, 0xa8, 0x01, 0x00, 0x53,
-               0xa8, 0xfe, 0x10, 0x50, 0x02, 0x80, 0x03, 0x12,
-               0x1a, 0x8d, 0xd1, 0x28, 0x12, 0x03, 0xd9, 0xd1,
-               0xf2, 0x12, 0x2d, 0xf0, 0xb0, 0x11, 0x92, 0xe0,
-               0xa2, 0x2a, 0xa0, 0xb5, 0x82, 0xe0, 0x50, 0x03,
-               0x79, 0x0f, 0xe3, 0x71, 0xca, 0x51, 0x1e, 0x91,
-               0xe4, 0x53, 0xa8, 0xfb, 0x10, 0x10, 0x02, 0x80,
-               0x26, 0xc2, 0x8e, 0xd2, 0xab, 0xa2, 0x1c, 0x40,
-               0x13, 0xa2, 0x1d, 0x50, 0x0a, 0x43, 0x08, 0x40,
-               0x12, 0x1a, 0x01, 0xd1, 0xd7, 0x80, 0x0b, 0x12,
-               0x26, 0x04, 0x61, 0x08, 0x43, 0x08, 0x40, 0x12,
-               0x1a, 0x01, 0xd2, 0x1f, 0x12, 0x17, 0x7f, 0x43,
-               0xa8, 0x04, 0x51, 0x1e, 0x91, 0xe4, 0x12, 0x13,
-               0x34, 0x80, 0x98, 0xa2, 0x17, 0x72, 0x16, 0x72,
-               0x15, 0x72, 0x2d, 0x50, 0x06, 0xfa, 0x12, 0x13,
-               0x66, 0x80, 0x25, 0xc2, 0x13, 0x30, 0x28, 0x05,
-               0x12, 0x02, 0xbe, 0x80, 0x1b, 0xb4, 0x10, 0x12,
-               0x78, 0x00, 0xf2, 0xe5, 0x30, 0xb4, 0x01, 0x06,
-               0x12, 0x03, 0x90, 0xd2, 0x19, 0x22, 0x12, 0x00,
-               0xdd, 0x22, 0x75, 0x30, 0x00, 0x12, 0x00, 0xa1,
-               0x22, 0x00, 0x00, 0x75, 0x1e, 0x00, 0x74, 0x0c,
-               0x12, 0x2b, 0x9b, 0x74, 0x40, 0x79, 0x05, 0xf3,
-               0x74, 0x49, 0x12, 0x2b, 0x9b, 0x74, 0x04, 0x79,
-               0x05, 0xf3, 0x75, 0x15, 0x04, 0x74, 0x10, 0x12,
-               0x2b, 0x9b, 0x74, 0x00, 0x79, 0x05, 0xf3, 0x74,
-               0x17, 0x12, 0x2b, 0x9b, 0x74, 0x00, 0x79, 0x05,
-               0xf3, 0x74, 0x1a, 0x12, 0x2b, 0x9b, 0x74, 0x00,
-               0x79, 0x05, 0xf3, 0x74, 0x0a, 0x12, 0x2b, 0x9b,
-               0x74, 0x20, 0x79, 0x05, 0xf3, 0x79, 0xe0, 0x77,
-               0x20, 0x22, 0xd0, 0x02, 0xd0, 0xd0, 0xd0, 0xf0,
-               0xd0, 0x01, 0xe5, 0x5f, 0xd0, 0xa8, 0x22, 0x00,
-               0x00, 0x90, 0x25, 0x9f, 0x75, 0x26, 0xff, 0x75,
-               0x27, 0xff, 0x75, 0x28, 0x03, 0x75, 0x13, 0xff,
-               0x75, 0x1f, 0x00, 0x75, 0x14, 0xff, 0x22, 0x79,
-               0x06, 0xe5, 0x29, 0x60, 0x0b, 0xe3, 0x30, 0xe1,
-               0xf8, 0xe5, 0x4f, 0x64, 0x80, 0x79, 0x07, 0xf3,
-               0x22, 0x10, 0x4c, 0x01, 0x22, 0x30, 0x4b, 0x0a,
-               0xc2, 0x4b, 0xe5, 0x4d, 0x64, 0x80, 0xf5, 0x4f,
-               0x80, 0x1d, 0xe5, 0x15, 0xa2, 0xe0, 0x82, 0xe6,
-               0x40, 0x02, 0x80, 0x35, 0x30, 0x4a, 0x04, 0xb1,
-               0xe6, 0x80, 0x0c, 0x30, 0x49, 0x04, 0x51, 0x2b,
-               0x80, 0x05, 0x30, 0x48, 0x24, 0x91, 0x7e, 0x79,
-               0x06, 0xe3, 0x30, 0xe0, 0x1a, 0x79, 0x06, 0xf3,
-               0xe5, 0x4e, 0x24, 0xff, 0x50, 0x04, 0xf5, 0x4e,
-               0x80, 0x0d, 0x79, 0x0f, 0xf3, 0x20, 0x2a, 0x07,
-               0x12, 0x2b, 0x32, 0x75, 0x29, 0x00, 0x22, 0x91,
-               0x1b, 0x22, 0x79, 0x0f, 0xe3, 0xc0, 0xa8, 0x75,
-               0xa8, 0x00, 0x30, 0x2b, 0x03, 0xd0, 0xa8, 0x22,
-               0x79, 0x0e, 0xf3, 0xd0, 0xa8, 0x22, 0x8a, 0xf0,
-               0xe5, 0x50, 0x10, 0xf3, 0x10, 0x23, 0x23, 0x23,
-               0x25, 0xf0, 0x12, 0x2c, 0xb8, 0xa2, 0xe7, 0x92,
-               0xe4, 0xc2, 0xe7, 0x80, 0x08, 0x23, 0x23, 0x23,
-               0x25, 0xf0, 0x12, 0x2c, 0x19, 0x25, 0x4f, 0x20,
-               0xd2, 0x04, 0xf5, 0x4f, 0x80, 0x0a, 0x40, 0x05,
-               0x75, 0x4f, 0x7f, 0x80, 0x03, 0x75, 0x4f, 0xff,
-               0xea, 0x12, 0x2c, 0x3c, 0x25, 0x50, 0x20, 0xe7,
-               0x05, 0xb4, 0x03, 0x07, 0x80, 0x0c, 0x75, 0x50,
-               0x00, 0x80, 0x09, 0x40, 0x05, 0x75, 0x50, 0x03,
-               0x80, 0x02, 0xf5, 0x50, 0x22, 0xe5, 0x4d, 0xc4,
-               0x54, 0x0c, 0x03, 0x03, 0xfa, 0x91, 0xa9, 0x71,
-               0xb8, 0xe5, 0x4d, 0xc4, 0x54, 0x03, 0xfa, 0x91,
-               0xa9, 0x71, 0xb8, 0xe5, 0x4d, 0x54, 0x0c, 0x03,
-               0x03, 0xfa, 0x91, 0xa9, 0x71, 0xb8, 0xe5, 0x4d,
-               0x54, 0x03, 0xfa, 0x91, 0xa9, 0x71, 0xb8, 0x22,
-               0x8a, 0xf0, 0xe5, 0x50, 0x23, 0x23, 0x25, 0xf0,
-               0x12, 0x2b, 0xf6, 0x25, 0x4f, 0x20, 0xd2, 0x04,
-               0xf5, 0x4f, 0x80, 0x0a, 0x40, 0x05, 0x75, 0x4f,
-               0x7f, 0x80, 0x03, 0x75, 0x4f, 0xff, 0xea, 0x12,
-               0x2c, 0x40, 0x25, 0x50, 0x20, 0xe7, 0x05, 0xb4,
-               0x05, 0x07, 0x80, 0x0c, 0x75, 0x50, 0x00, 0x80,
-               0x09, 0x40, 0x05, 0x75, 0x50, 0x05, 0x80, 0x02,
-               0xf5, 0x50, 0x22, 0x30, 0x26, 0x03, 0x12, 0x1e,
-               0xf5, 0x30, 0x27, 0x03, 0x12, 0x1f, 0x37, 0x30,
-               0x25, 0x09, 0x12, 0x1f, 0x4e, 0x30, 0x23, 0x03,
-               0x12, 0x1f, 0x1e, 0x10, 0x22, 0x02, 0x80, 0x0a,
-               0xe5, 0x3b, 0xb4, 0xff, 0x02, 0xc2, 0x20, 0x12,
-               0x1e, 0x79, 0x22, 0x78, 0x11, 0xe2, 0x20, 0xe0,
-               0x07, 0xc0, 0x01, 0x12, 0x28, 0xba, 0xd0, 0x01,
-               0x78, 0x00, 0xf2, 0x61, 0x9b, 0x12, 0x2b, 0x32,
-               0x12, 0x17, 0x7f, 0x78, 0x00, 0xf2, 0xaa, 0x35,
-               0xab, 0x36, 0xea, 0x24, 0xff, 0xfa, 0xeb, 0x34,
-               0xff, 0xfb, 0x50, 0x03, 0xd2, 0x10, 0x22, 0x75,
-               0x37, 0x01, 0x75, 0x38, 0x00, 0x75, 0x39, 0x00,
-               0x12, 0x04, 0x04, 0xd2, 0x8e, 0x22, 0xa8, 0x2b,
-               0xb8, 0x00, 0x02, 0x80, 0x03, 0x02, 0x11, 0xbd,
-               0xf5, 0x74, 0x78, 0x2a, 0x12, 0x11, 0xec, 0xe5,
-               0x74, 0x78, 0x29, 0x12, 0x11, 0xec, 0x22, 0xfa,
-               0xe5, 0x2b, 0x60, 0x01, 0x22, 0xea, 0x78, 0x2b,
-               0xf5, 0x75, 0x12, 0x11, 0xec, 0x22, 0x74, 0x10,
-               0x12, 0x2b, 0x9b, 0x74, 0x20, 0x78, 0x05, 0xf2,
-               0x74, 0x09, 0x12, 0x17, 0x75, 0xe5, 0x15, 0x44,
-               0x80, 0x79, 0x05, 0xf3, 0xf5, 0x15, 0x12, 0x17,
-               0x7f, 0x22, 0x12, 0x03, 0x84, 0x79, 0x0f, 0xe3,
-               0x78, 0x00, 0xf2, 0x12, 0x2b, 0x28, 0xe5, 0x81,
-               0x24, 0xfc, 0xf5, 0x81, 0x61, 0x93, 0xd2, 0x07,
-               0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5, 0x4c, 0xc2,
-               0x0f, 0x12, 0x29, 0xa3, 0x61, 0x93, 0x02, 0x1b,
-               0x77, 0x00, 0xe1, 0x81, 0xe1, 0x9a, 0xd2, 0x2c,
-               0xa1, 0x0c, 0x20, 0x20, 0x02, 0xd2, 0x26, 0x02,
-               0x1e, 0x35, 0x02, 0x1e, 0x61, 0x02, 0x1d, 0x8f,
-               0xc2, 0x8e, 0x75, 0xa8, 0x9e, 0x22, 0x41, 0x49,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x02, 0x29, 0x91, 0x00, 0x00, 0x00, 0xa1, 0xbb,
-               0xa1, 0xc3, 0x02, 0x1e, 0x6b, 0xe5, 0x4d, 0xc4,
-               0x54, 0x0f, 0xfa, 0x91, 0x2f, 0x71, 0xb8, 0xe5,
-               0x4d, 0x54, 0x0f, 0xfa, 0x91, 0x2f, 0x71, 0xb8,
-               0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa1, 0xc6,
-               0x02, 0x1d, 0x8f, 0xc2, 0x8e, 0xd2, 0xab, 0xc2,
-               0x10, 0x79, 0x0f, 0xf3, 0x22, 0x00, 0x02, 0x2a,
-               0x84, 0x00, 0xe1, 0xbc, 0xe1, 0xc8, 0x02, 0x1e,
-               0x27, 0x00, 0x78, 0x00, 0xf2, 0x78, 0x0b, 0xe2,
-               0xf4, 0xf5, 0x4d, 0xd2, 0x4c, 0x61, 0x9b, 0x30,
-               0xb5, 0x02, 0xc2, 0x11, 0x22, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x79, 0xbd, 0xf1, 0x3d, 0x83,
-               0x22, 0xdd, 0xbd, 0xbd, 0xbd, 0x61, 0xbd, 0x8d,
-               0x7a, 0xbd, 0xbd, 0xbd, 0xbd, 0x30, 0xbd, 0xbd,
-               0xbd, 0x55, 0xbd, 0xbd, 0xbd, 0x52, 0xbd, 0xb6,
-               0xb6, 0xbd, 0xbd, 0xbd, 0xbd, 0x00, 0xbd, 0xbd,
-               0xbd, 0xe8, 0xda, 0xbd, 0xbd, 0xcf, 0xb9, 0xbd,
-               0xc4, 0xf1, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
-               0xbd, 0x7b, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
-               0xbd, 0x70, 0x6a, 0x57, 0x47, 0x34, 0xbd, 0xbd,
-               0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x29, 0xbd,
-               0xbd, 0xbd, 0xb6, 0xb6, 0xbd, 0xbd, 0xbd, 0xbd,
-               0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x2e, 0x25,
-               0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xfe, 0xf5,
-               0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x19, 0xbd,
-               0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x21, 0x8f,
-               0x09, 0xbd, 0xf9, 0x86, 0xbd, 0xbd, 0xbd, 0xd7,
-               0xbd, 0xa9, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x9b,
-               0xd1, 0x9d, 0xbd, 0xae, 0xbd, 0xbd, 0xbd, 0xcb,
-               0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
-               0xb6, 0xa5, 0xbd, 0xc5, 0xbd, 0xbd, 0xbd, 0xc3,
-               0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x74, 0x10,
-               0x12, 0x2b, 0x9b, 0xe4, 0x78, 0x05, 0xf2, 0x74,
-               0x09, 0x12, 0x17, 0x75, 0xe5, 0x15, 0x54, 0x7f,
-               0x79, 0x05, 0xf3, 0xf5, 0x15, 0x12, 0x17, 0x7f,
-               0x22, 0x30, 0x51, 0x01, 0x22, 0x53, 0xa8, 0xfb,
-               0x12, 0x2d, 0xf0, 0x50, 0x22, 0x79, 0x03, 0xe3,
-               0x20, 0xe4, 0x1c, 0xaa, 0x35, 0xab, 0x36, 0xea,
-               0x24, 0xf0, 0xfa, 0xeb, 0x34, 0xff, 0xfb, 0x50,
-               0x0e, 0x10, 0x1f, 0x02, 0x80, 0x09, 0x20, 0x2a,
-               0x03, 0x12, 0x2b, 0x32, 0x12, 0x2d, 0xd6, 0x43,
-               0xa8, 0x04, 0x22, 0xa2, 0x1c, 0x72, 0x1d, 0x40,
-               0x07, 0x53, 0x08, 0xbf, 0x78, 0x00, 0xf2, 0x22,
-               0xb1, 0x1e, 0x22, 0x00, 0x79, 0x02, 0x12, 0x27,
-               0x3d, 0x02, 0x2d, 0x37, 0x14, 0x54, 0xf0, 0x60,
-               0x21, 0xe5, 0xf0, 0x24, 0xb6, 0xe5, 0xf0, 0x50,
-               0x16, 0x24, 0x8b, 0x50, 0x15, 0xe5, 0xf0, 0x24,
-               0x56, 0xe5, 0xf0, 0x50, 0x08, 0x24, 0x2f, 0x50,
-               0x09, 0xe5, 0xf0, 0x24, 0xd9, 0x24, 0xd5, 0x24,
-               0xf0, 0x22, 0x15, 0x81, 0x15, 0x81, 0xe9, 0x22,
-               0x78, 0x13, 0x74, 0x00, 0xf2, 0x75, 0x2e, 0x01,
-               0xd2, 0x6a, 0xc2, 0x69, 0xc2, 0x68, 0xc2, 0x6c,
-               0x90, 0x25, 0x9f, 0x75, 0xb8, 0x07, 0x41, 0xa4,
-               0xc0, 0x01, 0xc0, 0xf0, 0xc0, 0xd0, 0xc0, 0x02,
-               0xe5, 0x3d, 0x54, 0x7d, 0x03, 0x10, 0xe5, 0x05,
-               0x90, 0x28, 0x4b, 0x80, 0x03, 0x90, 0x2b, 0x7c,
-               0x73, 0xe5, 0x3d, 0x30, 0xe5, 0x07, 0x74, 0xfd,
-               0x78, 0x00, 0xf2, 0x61, 0x9b, 0x90, 0x1a, 0x97,
-               0x74, 0xb6, 0xc0, 0xe0, 0x74, 0x27, 0xc0, 0xe0,
-               0xc0, 0xa8, 0x02, 0x1b, 0xab, 0x90, 0x25, 0x9f,
-               0xd0, 0xa8, 0x22, 0x90, 0x27, 0xb6, 0xc0, 0x82,
-               0xc0, 0x83, 0xc0, 0xa8, 0x02, 0x1d, 0xa6, 0x90,
-               0x27, 0xb6, 0xc0, 0x82, 0xc0, 0x83, 0xc0, 0xa8,
-               0x02, 0x1e, 0x0a, 0xea, 0x24, 0xf0, 0xfa, 0xeb,
-               0x34, 0xff, 0xfb, 0x50, 0x2e, 0x20, 0x0b, 0x05,
-               0x85, 0x44, 0xe0, 0x80, 0x03, 0x75, 0xe0, 0x00,
-               0x30, 0xe1, 0x20, 0xe5, 0x35, 0x24, 0xff, 0xf5,
-               0x35, 0xe5, 0x36, 0x34, 0xff, 0xf5, 0x36, 0xc3,
-               0xe5, 0x36, 0x13, 0xf5, 0x36, 0xe5, 0x35, 0x13,
-               0xf5, 0x35, 0x75, 0x3a, 0x10, 0x12, 0x1a, 0x77,
-               0x02, 0x18, 0x77, 0x75, 0x3a, 0x00, 0x12, 0x1a,
-               0x77, 0x02, 0x18, 0x1b, 0x20, 0x4b, 0x04, 0x75,
-               0x4e, 0x03, 0x22, 0xe5, 0x35, 0x24, 0xff, 0xf5,
-               0x35, 0xe5, 0x36, 0x34, 0xff, 0xf5, 0x36, 0x75,
-               0x4e, 0x03, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x02, 0x2c,
-               0x70, 0xd2, 0x00, 0x78, 0x11, 0xe2, 0x44, 0x11,
-               0xf5, 0x3f, 0xc2, 0x08, 0x12, 0x29, 0xa3, 0x02,
-               0x23, 0x93, 0x21, 0x62, 0x61, 0x40, 0x01, 0x3a,
-               0x01, 0x73, 0x21, 0x76, 0x61, 0xa8, 0x21, 0x39,
-               0x21, 0x4a, 0x02, 0x2a, 0x7b, 0x79, 0x06, 0xf3,
-               0xc0, 0xd0, 0x12, 0x03, 0xd9, 0x78, 0x00, 0xf2,
-               0xd0, 0xd0, 0x22, 0x00, 0x00, 0x00, 0x00, 0x02,
-               0x2c, 0xb4, 0x78, 0x11, 0xe2, 0x44, 0x11, 0x54,
-               0x0f, 0xf8, 0xc4, 0x48, 0xd2, 0x05, 0xf5, 0x48,
-               0xc2, 0x0d, 0x31, 0xa3, 0x02, 0x23, 0x93, 0x20,
-               0x4b, 0x04, 0x75, 0x4e, 0x01, 0x22, 0xe5, 0x35,
-               0x24, 0xff, 0xf5, 0x35, 0xe5, 0x36, 0x34, 0xff,
-               0xf5, 0x36, 0x75, 0x4e, 0x01, 0x22, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x79, 0xd0, 0x77, 0x1b, 0x79, 0xd1, 0x77, 0x18,
-               0x79, 0xd2, 0x77, 0x77, 0x79, 0xd3, 0x77, 0x18,
-               0x22, 0x75, 0x29, 0x00, 0x75, 0x25, 0x00, 0x75,
-               0x34, 0x03, 0x75, 0x22, 0x00, 0x75, 0x23, 0x05,
-               0x75, 0x4f, 0x00, 0x75, 0x50, 0x00, 0x75, 0x30,
-               0x00, 0x79, 0xdc, 0x77, 0x03, 0xc2, 0x8e, 0x75,
-               0x17, 0xa8, 0x75, 0x16, 0xa8, 0x74, 0xaa, 0x79,
-               0x01, 0xf3, 0x79, 0xd7, 0x77, 0x74, 0x79, 0xd8,
-               0x77, 0xff, 0x79, 0xd9, 0x77, 0x07, 0x79, 0xda,
-               0x77, 0x00, 0x12, 0x25, 0x6f, 0x43, 0x08, 0x40,
-               0x71, 0x32, 0x79, 0x0e, 0xe3, 0x10, 0x51, 0x1c,
-               0x74, 0x06, 0x71, 0x9b, 0xe5, 0x11, 0x44, 0x80,
-               0x79, 0x05, 0xf3, 0xf5, 0x11, 0x74, 0x07, 0x71,
-               0x9b, 0xe5, 0x12, 0x44, 0x80, 0x79, 0x05, 0xf3,
-               0xf5, 0x12, 0x80, 0x18, 0x53, 0x27, 0xa0, 0x53,
-               0x28, 0x01, 0x75, 0x20, 0xf7, 0x12, 0x23, 0x4c,
-               0x75, 0x11, 0x80, 0x75, 0x12, 0x80, 0x12, 0x1f,
-               0xc0, 0x12, 0x21, 0xdc, 0x79, 0x06, 0xf3, 0x22,
-               0xd2, 0x02, 0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5,
-               0x43, 0xc2, 0x0a, 0x12, 0x29, 0xa3, 0x02, 0x23,
-               0x93, 0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5, 0x44,
-               0xc2, 0x0b, 0x12, 0x29, 0xa3, 0x02, 0x23, 0x93,
-               0x78, 0x00, 0xe2, 0x90, 0x25, 0x9f, 0x02, 0x23,
-               0x93, 0x78, 0x11, 0xe2, 0x75, 0x20, 0xf7, 0x75,
-               0x21, 0x3f, 0x75, 0x49, 0x11, 0x75, 0x4c, 0x11,
-               0x31, 0xa3, 0x02, 0x23, 0x93, 0x78, 0x11, 0xe2,
-               0x44, 0x11, 0x54, 0x0f, 0xf8, 0xc4, 0x48, 0xf8,
-               0xe5, 0x49, 0x45, 0x3f, 0x58, 0xf5, 0x49, 0xd2,
-               0x06, 0xc2, 0x0e, 0x31, 0xa3, 0x02, 0x23, 0x93,
-               0xc0, 0x01, 0x20, 0x2a, 0x04, 0x71, 0x32, 0xc2,
-               0x11, 0x11, 0x5e, 0xc2, 0x1f, 0xd0, 0x01, 0x02,
-               0x23, 0x9b, 0x12, 0x21, 0xdc, 0x78, 0x00, 0xf2,
-               0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0xda,
-               0xe7, 0x70, 0x2b, 0x20, 0x0a, 0x05, 0x85, 0x43,
-               0xe0, 0x80, 0x03, 0x75, 0xe0, 0x00, 0x30, 0xe1,
-               0x1d, 0x20, 0xe2, 0x1f, 0x74, 0xe0, 0xca, 0x74,
-               0x00, 0x71, 0x9b, 0xca, 0x79, 0x05, 0xf3, 0xf5,
-               0x09, 0xca, 0x74, 0x01, 0x71, 0x9b, 0xca, 0x79,
-               0x05, 0xf3, 0xf5, 0x0a, 0x80, 0x43, 0x12, 0x15,
-               0x3e, 0x80, 0x3e, 0xe5, 0x0b, 0xb4, 0x17, 0x02,
-               0x80, 0x0b, 0x50, 0x09, 0x74, 0x17, 0xc3, 0x95,
-               0x0b, 0x44, 0x60, 0x80, 0x02, 0x74, 0x60, 0xca,
-               0x74, 0x00, 0x71, 0x9b, 0xca, 0x79, 0x05, 0xf3,
-               0xf5, 0x09, 0xe5, 0x0c, 0xb4, 0x17, 0x02, 0x80,
-               0x0b, 0x50, 0x09, 0x74, 0x17, 0xc3, 0x95, 0x0c,
-               0x44, 0x60, 0x80, 0x02, 0x74, 0x60, 0xca, 0x74,
-               0x01, 0x71, 0x9b, 0xca, 0x79, 0x05, 0xf3, 0xf5,
-               0x0a, 0x22, 0xd2, 0x04, 0x78, 0x11, 0xe2, 0x44,
-               0x11, 0xf5, 0x46, 0xc2, 0x0c, 0x31, 0xa3, 0x02,
-               0x23, 0x93, 0xd2, 0x05, 0x78, 0x11, 0xe2, 0x44,
-               0x11, 0xf5, 0x48, 0xc2, 0x0d, 0x31, 0xa3, 0x02,
-               0x23, 0x93, 0xd2, 0x06, 0x78, 0x11, 0xe2, 0x44,
-               0x11, 0xf5, 0x49, 0xc2, 0x0e, 0x31, 0xa3, 0x02,
-               0x23, 0x93, 0x30, 0x1c, 0x21, 0x20, 0x4d, 0x1e,
-               0xe5, 0x29, 0x60, 0x1a, 0xc2, 0x1c, 0x12, 0x19,
-               0xec, 0x12, 0x13, 0xcf, 0xd2, 0x4d, 0x12, 0x17,
-               0x7f, 0x78, 0x00, 0xf2, 0x79, 0x06, 0xf3, 0x43,
-               0xa8, 0x04, 0x12, 0x24, 0x1b, 0x22, 0x12, 0x27,
-               0x24, 0x22, 0x78, 0x00, 0xe2, 0x90, 0x25, 0x9f,
-               0x02, 0x23, 0x93, 0x78, 0x00, 0xe2, 0xa2, 0xe7,
-               0x72, 0xe3, 0x92, 0xe7, 0x02, 0x1d, 0x85, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x79, 0x04, 0xe3, 0x54, 0x80, 0x70, 0xf9, 0x22,
-               0xe5, 0x29, 0x79, 0xde, 0xf7, 0x75, 0x29, 0x00,
-               0x70, 0x12, 0xe5, 0x15, 0x79, 0xdd, 0xf7, 0x12,
-               0x2d, 0xf0, 0x40, 0x08, 0x20, 0x1c, 0x07, 0x20,
-               0x1d, 0x04, 0x80, 0x02, 0x71, 0x32, 0x30, 0xb5,
-               0x0c, 0x79, 0x06, 0xf3, 0x20, 0x2a, 0x06, 0x79,
-               0xdd, 0xe7, 0x54, 0xfc, 0xf7, 0xd2, 0x2b, 0x12,
-               0x25, 0x6f, 0x22, 0x00, 0x00, 0x00, 0x00, 0xe5,
-               0x15, 0xa2, 0xe0, 0xb0, 0xe6, 0x40, 0x31, 0xa2,
-               0xe1, 0xb0, 0xe7, 0x40, 0x38, 0x10, 0x2b, 0x02,
-               0x80, 0x26, 0x79, 0xde, 0xe7, 0x70, 0x0b, 0x79,
-               0xdd, 0xe7, 0x20, 0xe0, 0x12, 0x20, 0xe1, 0x28,
-               0x80, 0x16, 0xf5, 0x29, 0x30, 0x4d, 0x11, 0x20,
-               0x4c, 0x0e, 0x12, 0x24, 0x1b, 0x80, 0x09, 0x43,
-               0x08, 0x40, 0x12, 0x13, 0xcf, 0x12, 0x17, 0x7f,
-               0xe5, 0x13, 0x20, 0xe4, 0x05, 0x12, 0x18, 0x1b,
-               0x80, 0x03, 0x12, 0x18, 0x77, 0xc2, 0x2b, 0x22,
-               0x12, 0x26, 0xd7, 0x12, 0x13, 0xb7, 0x22, 0x78,
-               0x04, 0x79, 0x00, 0xd9, 0xfe, 0xd8, 0xfa, 0x22,
-               0x00, 0x74, 0x09, 0x71, 0x9b, 0xe5, 0x15, 0x54,
-               0xfc, 0x79, 0x05, 0xf3, 0xf5, 0x15, 0x22, 0x78,
-               0x11, 0xe2, 0x44, 0x11, 0x54, 0x0f, 0xf8, 0xc4,
-               0x48, 0xf5, 0x46, 0xc2, 0x0c, 0xd2, 0x04, 0x31,
-               0xa3, 0x02, 0x23, 0x93, 0x12, 0x26, 0xd7, 0x12,
-               0x00, 0xb7, 0x22, 0x00, 0x79, 0x06, 0xf3, 0x74,
-               0x0a, 0x71, 0x9b, 0x79, 0xe0, 0xe7, 0x44, 0x02,
-               0xf7, 0x79, 0x05, 0xf3, 0x22, 0x74, 0x0a, 0x71,
-               0x9b, 0x79, 0xe0, 0xe7, 0x54, 0xfd, 0xf7, 0x79,
-               0x05, 0xf3, 0x22, 0x21, 0x59, 0x41, 0x23, 0x21,
-               0x59, 0x41, 0x33, 0x41, 0x43, 0x21, 0x59, 0x21,
-               0x59, 0x02, 0x25, 0x9f, 0x00, 0x74, 0x0d, 0x71,
-               0x9b, 0x74, 0x4d, 0x79, 0x05, 0xf3, 0xd2, 0x52,
-               0x22, 0x00, 0x53, 0x08, 0x40, 0x45, 0x08, 0x45,
-               0x1e, 0x79, 0x04, 0xf3, 0xf5, 0x08, 0x22, 0xd2,
-               0x01, 0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5, 0x42,
-               0xc2, 0x09, 0x31, 0xa3, 0x02, 0x23, 0x93, 0x00,
-               0x00, 0x00, 0x00, 0x71, 0x6e, 0x74, 0x09, 0x12,
-               0x17, 0x75, 0xe5, 0x15, 0x44, 0x40, 0x79, 0x05,
-               0xf3, 0xf5, 0x15, 0x75, 0x3a, 0x00, 0x12, 0x1a,
-               0x77, 0x02, 0x18, 0x1b, 0xf5, 0x38, 0xe5, 0x37,
-               0x24, 0x01, 0xf5, 0x37, 0xe5, 0x38, 0x34, 0x00,
-               0xf5, 0x38, 0x40, 0x05, 0x75, 0x39, 0x00, 0x80,
-               0x03, 0x75, 0x39, 0x01, 0x12, 0x04, 0x04, 0xd2,
-               0x8e, 0x02, 0x03, 0x8d, 0x00, 0xb4, 0x0d, 0x03,
-               0x74, 0x14, 0x22, 0x04, 0x83, 0x22, 0x00, 0x02,
-               0xff, 0x01, 0x00, 0x05, 0xfe, 0xff, 0x00, 0x0a,
-               0xfc, 0xfe, 0x00, 0xc0, 0xf8, 0xfc, 0x00, 0x28,
-               0xf0, 0xf8, 0x00, 0x30, 0xe0, 0xd0, 0x01, 0x88,
-               0x04, 0x83, 0x22, 0x00, 0xff, 0xfe, 0xfd, 0xfc,
-               0xfc, 0xfb, 0xfa, 0xfe, 0xfd, 0xfb, 0xf9, 0xf7,
-               0xf7, 0xf5, 0xf3, 0xfc, 0xfa, 0xf6, 0xf2, 0xee,
-               0xee, 0xea, 0xe6, 0xf8, 0xf4, 0xec, 0xe4, 0xdc,
-               0xd4, 0xcc, 0xc4, 0x24, 0x21, 0x83, 0x22, 0x04,
-               0x83, 0x22, 0xff, 0x01, 0xff, 0x01, 0x00, 0x00,
-               0x00, 0x02, 0x22, 0x32, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
-               0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0xff,
-               0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x83,
-               0x22, 0x8a, 0x01, 0x20, 0x01, 0x0b, 0xea, 0xf3,
-               0xf9, 0x8b, 0x7e, 0x6b, 0xd5, 0x01, 0x00, 0x01,
-               0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x01, 0x3a, 0x01, 0x38, 0x01, 0x4b, 0x01,
-               0x49, 0x01, 0x5c, 0x01, 0x5a, 0x01, 0x08, 0x08,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x01, 0x15, 0x24, 0x48, 0x83, 0x22, 0x04,
-               0x83, 0x22, 0x00, 0x01, 0x02, 0x03, 0x04, 0x06,
-               0x07, 0x08, 0x00, 0x03, 0x05, 0x07, 0x09, 0x0d,
-               0x0f, 0x81, 0x00, 0x06, 0x0a, 0x0e, 0x82, 0x8a,
-               0x8e, 0x22, 0x00, 0x0c, 0x84, 0x8c, 0x24, 0x2c,
-               0xa4, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0xaa, 0x35, 0xab, 0x36,
-               0x02, 0x27, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
-               0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x25,
-               0x03, 0x03, 0x2b, 0x03, 0x00, 0x03, 0x00, 0x03,
-               0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
-               0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
-               0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x22,
-               0x00, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
-               0x2b, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
-               0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01,
-               0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
-               0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
-               0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02,
-               0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02,
-               0x21, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00,
-               0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x21,
-               0x01, 0x02, 0x21, 0x02, 0x02, 0x02, 0x00, 0x02,
-               0x02, 0x02, 0x02, 0x02, 0x02, 0x20, 0xb5, 0x05,
-               0x79, 0x0f, 0xf3, 0xc2, 0x11, 0x22, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5,
-               0x15, 0xa2, 0xe0, 0xb0, 0xe6, 0x50, 0x01, 0x22,
-               0xa2, 0xe1, 0xb0, 0xe7, 0x22, 0x02, 0x00};
-               static unsigned char    Data0485_0C[] = {
-               0x02, 0x27, 0x69};
-               static unsigned char    Data0485_66[] = {
-               0x02, 0x25, 0x47, 0x02, 0x25, 0x60};
-               static unsigned char    Data0485_60[] = {
-               0x02, 0x22, 0x7e};
-               static unsigned char    Data0485_99[] = {
-               0xc2, 0x53, 0x02, 0x12, 0x86};
-               static unsigned char    Data0485_9E[] = {
-               0x70, 0xf9, 0x22};
-#ifdef OOKUBO_ORIGINAL
-               static unsigned char    Data0485_36[] = {
-               0x78, 0x00, 0xf2, 0xc2, 0x53, 0x74, 0x86, 0xc0,
-               0xe0, 0x74, 0x12, 0xc0, 0xe0, 0x32};
-#endif /* OOKUBO_ORIGINAL */
diff --git a/sound/isa/cs423x/sound_pc9800.h b/sound/isa/cs423x/sound_pc9800.h
deleted file mode 100644 (file)
index 7ae310a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _SOUND_PC9800_H_
-#define _SOUND_PC9800_H_
-
-#include <asm/io.h>
-
-#define PC9800_SOUND_IO_ID     0xa460
-
-/* Sound Functions ID. */
-#define PC9800_SOUND_ID()      ((inb(PC9800_SOUND_IO_ID) >> 4) & 0x0f)
-
-#define PC9800_SOUND_ID_DO     0x0     /* PC-98DO+ Internal */
-#define PC9800_SOUND_ID_GS     0x1     /* PC-98GS Internal */
-#define PC9800_SOUND_ID_73     0x2     /* PC-9801-73 (base 0x18x) */
-#define PC9800_SOUND_ID_73A    0x3     /* PC-9801-73/76 (base 0x28x) */
-#define PC9800_SOUND_ID_86     0x4     /* PC-9801-86 and compatible (base 0x18x) */
-#define PC9800_SOUND_ID_86A    0x5     /* PC-9801-86 (base 0x28x) */
-#define PC9800_SOUND_ID_NF     0x6     /* PC-9821Nf/Np Internal */
-#define PC9800_SOUND_ID_XMATE  0x7     /* X-Mate Internal and compatible */
-#define PC9800_SOUND_ID_118    0x8     /* PC-9801-118 and compatible(CanBe Internal, etc.) */
-
-#define PC9800_SOUND_ID_UNKNOWN        0xf     /* Unknown (No Sound System or PC-9801-26) */
-
-#endif
diff --git a/sound/pci/ice1712/prodigy.c b/sound/pci/ice1712/prodigy.c
deleted file mode 100644 (file)
index eee13e6..0000000
+++ /dev/null
@@ -1,663 +0,0 @@
-/*
- *   ALSA driver for ICEnsemble VT1724 (Envy24HT)
- *
- *   Lowlevel functions for AudioTrak Prodigy 7.1 (and possibly 192) cards
- *      Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
- *     based on the aureon.c code (c) 2003 by Takashi Iwai <tiwai@suse.de>
- *
- *   version 0.82: Stable / not all features work yet (no communication with AC97 secondary)
- *       added 64x/128x oversampling switch (should be 64x only for 96khz)
- *       fixed some recording labels (still need to check the rest)
- *       recording is working probably thanks to correct wm8770 initialization
- *
- *   version 0.5: Initial release:
- *           working: analog output, mixer, headphone amplifier switch
- *       not working: prety much everything else, at least i could verify that
- *                    we have no digital output, no capture, pretty bad clicks and poops
- *                    on mixer switch and other coll stuff.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- *
- * NOTES:
- *
- *
- *
- * - we reuse the akm4xxx_t record for storing the wm8770 codec data.
- *   both wm and akm codecs are pretty similar, so we can integrate
- *   both controls in the future, once if wm codecs are reused in
- *   many boards.
- *
- * - writing over SPI is implemented but reading is not yet.
- *   the SPDIF-in channel status, etc. can be read from CS chip.
- *
- * - DAC digital volumes are not implemented in the mixer.
- *   if they show better response than DAC analog volumes, we can use them
- *   instead.
- *
- * - Prodigy boards are equipped with AC97 STAC9744 chip , too.  it's used to do
- *   the analog mixing but not easily controllable (it's not connected
- *   directly from envy24ht chip).  so let's leave it as it is.
- *
- */
-
-#define REVISION 0.82b
-
-#include <sound/driver.h>
-#include <asm/io.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <sound/core.h>
-
-#include "ice1712.h"
-#include "envy24ht.h"
-#include "prodigy.h"
-
-
-static int prodigy_set_headphone_amp(ice1712_t *ice, int enable)
-{
-       unsigned int tmp, tmp2;
-
-       tmp2 = tmp = snd_ice1712_gpio_read(ice);
-       if (enable)
-               tmp |= PRODIGY_HP_AMP_EN;
-       else
-               tmp &= ~ PRODIGY_HP_AMP_EN;
-       if (tmp != tmp2) {
-               snd_ice1712_gpio_write(ice, tmp);
-               return 1;
-       }
-       return 0;
-}
-
-
-static int prodigy_get_headphone_amp(ice1712_t *ice)
-{
-       unsigned int tmp = snd_ice1712_gpio_read(ice);
-
-       return ( tmp & PRODIGY_HP_AMP_EN )!= 0;
-}
-
-
-/*
- * write data in the SPI mode
- */
-static void prodigy_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data, int bits)
-{
-       unsigned int tmp;
-       int i;
-
-       tmp = snd_ice1712_gpio_read(ice);
-
-       snd_ice1712_gpio_set_mask(ice, ~(PRODIGY_WM_RW|PRODIGY_WM_DATA|PRODIGY_WM_CLK|
-                                        PRODIGY_WM_CS|PRODIGY_CS8415_CS|PRODIGY_HP_AMP_EN));
-       tmp |= PRODIGY_WM_RW;
-       tmp &= ~cs;
-       snd_ice1712_gpio_write(ice, tmp);
-       udelay(1);
-
-       for (i = bits - 1; i >= 0; i--) {
-               tmp &= ~PRODIGY_WM_CLK;
-               snd_ice1712_gpio_write(ice, tmp);
-               udelay(1);
-               if (data & (1 << i))
-                       tmp |= PRODIGY_WM_DATA;
-               else
-                       tmp &= ~PRODIGY_WM_DATA;
-               snd_ice1712_gpio_write(ice, tmp);
-               udelay(1);
-               tmp |= PRODIGY_WM_CLK;
-               snd_ice1712_gpio_write(ice, tmp);
-               udelay(1);
-       }
-
-       tmp &= ~PRODIGY_WM_CLK;
-       tmp |= cs;
-       snd_ice1712_gpio_write(ice, tmp);
-       udelay(1);
-       tmp |= PRODIGY_WM_CLK;
-       snd_ice1712_gpio_write(ice, tmp);
-       udelay(1);
-}
-
-
-/*
- * get the current register value of WM codec
- */
-static unsigned short wm_get(ice1712_t *ice, int reg)
-{
-       reg <<= 1;
-       return ((unsigned short)ice->akm[0].images[reg] << 8) |
-               ice->akm[0].images[reg + 1];
-}
-
-/*
- * set the register value of WM codec and remember it
- */
-static void wm_put(ice1712_t *ice, int reg, unsigned short val)
-{
-       prodigy_spi_write(ice, PRODIGY_WM_CS, (reg << 9) | (val & 0x1ff), 16);
-       reg <<= 1;
-       ice->akm[0].images[reg] = val >> 8;
-       ice->akm[0].images[reg + 1] = val;
-}
-
-
-/*********************************
- ********* Controls section ******
- *********************************/
-
-#define PRODIGY_CON_HPAMP \
-        {                                            \
-                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,      \
-                .name =  "Headphone Amplifier", \
-                .info =  prodigy_hpamp_info,         \
-                .get =   prodigy_hpamp_get, \
-                .put =   prodigy_hpamp_put  \
-        }
-
-static int prodigy_hpamp_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
-{
-       static char *texts[2] = {
-               "Off", "On"
-       };
-
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 1;
-       uinfo->value.enumerated.items = 2;
-
-       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
-               uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
-       strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
-
-        return 0;
-}
-
-
-static int prodigy_hpamp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-
-       ucontrol->value.integer.value[0] = prodigy_get_headphone_amp(ice);
-       return 0;
-}
-
-
-static int prodigy_hpamp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-
-       return prodigy_set_headphone_amp(ice,ucontrol->value.integer.value[0]);
-}
-
-
-
-#define PRODIGY_CON_DEEMP \
-        {                                            \
-                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,      \
-                .name =  "DAC De-emphasis", \
-                .info =  prodigy_deemp_info,         \
-                .get =   prodigy_deemp_get, \
-                .put =   prodigy_deemp_put  \
-        }
-
-static int prodigy_deemp_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
-{
-       static char *texts[2] = { "Off", "On" };
-
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 1;
-       uinfo->value.enumerated.items = 2;
-
-       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
-               uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
-       strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
-
-        return 0;
-}
-
-static int prodigy_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       ucontrol->value.integer.value[0] = (wm_get(ice, 0x15) & 0xf) == 0xf;
-       return 0;
-}
-
-static int prodigy_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       int temp, temp2;
-       temp2 = temp = wm_get(ice, 0x15);
-       temp = (temp & ~0xf) | ((ucontrol->value.integer.value[0])*0xf);
-       if (temp != temp2) {
-               wm_put(ice,0x15,temp);
-               return 1;
-       }
-       return 0;
-}
-
-
-#define PRODIGY_CON_OVERSAMPLING \
-        {                                            \
-                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,      \
-                .name =  "ADC Oversampling", \
-                .info =  prodigy_oversampling_info,         \
-                .get =   prodigy_oversampling_get, \
-                .put =   prodigy_oversampling_put  \
-        }
-
-static int prodigy_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
-{
-       static char *texts[2] = { "128x", "64x" };
-
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 1;
-       uinfo->value.enumerated.items = 2;
-
-       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
-               uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
-       strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
-
-        return 0;
-}
-
-static int prodigy_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       ucontrol->value.integer.value[0] = (wm_get(ice, 0x17) & 0x8) == 0x8;
-       return 0;
-}
-
-static int prodigy_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       int temp, temp2;
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-
-       temp2 = temp = wm_get(ice, 0x17);
-
-       if( ucontrol->value.integer.value[0] ) {
-               temp |= 0x8;
-       } else {
-               temp &= ~0x8;
-       }
-
-       if (temp != temp2) {
-               wm_put(ice,0x17,temp);
-               return 1;
-       }
-       return 0;
-}
-
-
-
-
-/*
- * DAC volume attenuation mixer control
- */
-static int wm_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;           /* mute */
-       uinfo->value.integer.max = 101;         /* 0dB */
-       return 0;
-}
-
-static int wm_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       int idx;
-       unsigned short vol;
-
-       down(&ice->gpio_mutex);
-       if (kcontrol->private_value)
-               idx = WM_DAC_MASTER_ATTEN;
-       else
-               idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_DAC_ATTEN;
-       vol = wm_get(ice, idx) & 0x7f;
-       if (vol <= 0x1a)
-               ucontrol->value.integer.value[0] = 0;
-       else
-               ucontrol->value.integer.value[0] = vol - 0x1a;
-       up(&ice->gpio_mutex);
-
-       return 0;
-}
-
-static int wm_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       int idx;
-       unsigned short ovol, nvol;
-       int change;
-
-       snd_ice1712_save_gpio_status(ice);
-       if (kcontrol->private_value)
-               idx = WM_DAC_MASTER_ATTEN;
-       else
-               idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_DAC_ATTEN;
-       nvol = ucontrol->value.integer.value[0] + 0x1a;
-       ovol = wm_get(ice, idx) & 0x7f;
-       change = (ovol != nvol);
-       if (change) {
-               if (nvol <= 0x1a && ovol <= 0x1a)
-                       change = 0;
-               else
-                       wm_put(ice, idx, nvol | 0x180); /* update on zero detect */
-       }
-       snd_ice1712_restore_gpio_status(ice);
-       return change;
-}
-
-/*
- * ADC gain mixer control
- */
-static int wm_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;           /* -12dB */
-       uinfo->value.integer.max = 0x1f;        /* 19dB */
-       return 0;
-}
-
-static int wm_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       int idx;
-       unsigned short vol;
-
-       down(&ice->gpio_mutex);
-       idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_ADC_GAIN;
-       vol = wm_get(ice, idx) & 0x1f;
-       ucontrol->value.integer.value[0] = vol;
-       up(&ice->gpio_mutex);
-       return 0;
-}
-
-static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       int idx;
-       unsigned short ovol, nvol;
-       int change;
-
-       snd_ice1712_save_gpio_status(ice);
-       idx  = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_ADC_GAIN;
-       nvol = ucontrol->value.integer.value[0];
-       ovol = wm_get(ice, idx) & 0x1f;
-       change = (ovol != nvol);
-       if (change)
-               wm_put(ice, idx, nvol);
-       snd_ice1712_restore_gpio_status(ice);
-       return change;
-}
-
-/*
- * ADC input mux mixer control
- */
-static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
-{
-       static char *texts[] = {
-               "CD Left",
-               "CD Right",
-               "Line Left",
-               "Line Right",
-               "Aux Left",
-               "Aux Right",
-               "Mic Left",
-               "Mic Right",
-       };
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 2;
-       uinfo->value.enumerated.items = 8;
-       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
-               uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
-       strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
-       return 0;
-}
-
-static int wm_adc_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       unsigned short val;
-
-       down(&ice->gpio_mutex);
-       val = wm_get(ice, WM_ADC_MUX);
-       ucontrol->value.integer.value[0] = val & 7;
-       ucontrol->value.integer.value[1] = (val >> 4) & 7;
-       up(&ice->gpio_mutex);
-       return 0;
-}
-
-static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-       unsigned short oval, nval;
-       int change;
-
-       snd_ice1712_save_gpio_status(ice);
-       oval = wm_get(ice, WM_ADC_MUX);
-       nval = oval & ~0x77;
-       nval |= ucontrol->value.integer.value[0] & 7;
-       nval |= (ucontrol->value.integer.value[1] & 7) << 4;
-       change = (oval != nval);
-       if (change)
-               wm_put(ice, WM_ADC_MUX, nval);
-       snd_ice1712_restore_gpio_status(ice);
-       return 0;
-}
-
-/*
- * mixers
- */
-
-static snd_kcontrol_new_t prodigy71_dac_control __devinitdata = {
-       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-       .name = "DAC Volume",
-       .count = 8,
-       .info = wm_dac_vol_info,
-       .get = wm_dac_vol_get,
-       .put = wm_dac_vol_put,
-};
-
-static snd_kcontrol_new_t wm_controls[] __devinitdata = {
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Master Playback Volume",
-               .info = wm_dac_vol_info,
-               .get = wm_dac_vol_get,
-               .put = wm_dac_vol_put,
-               .private_value = 1,
-       },
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "ADC Volume",
-               .count = 2,
-               .info = wm_adc_vol_info,
-               .get = wm_adc_vol_get,
-               .put = wm_adc_vol_put,
-       },
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Capture Route",
-               .info = wm_adc_mux_info,
-               .get = wm_adc_mux_get,
-               .put = wm_adc_mux_put,
-       },
-       PRODIGY_CON_HPAMP ,
-       PRODIGY_CON_DEEMP ,
-       PRODIGY_CON_OVERSAMPLING
-};
-
-
-static int __devinit prodigy_add_controls(ice1712_t *ice)
-{
-       unsigned int i;
-       int err;
-
-       err = snd_ctl_add(ice->card, snd_ctl_new1(&prodigy71_dac_control, ice));
-       if (err < 0)
-               return err;
-
-       for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
-               err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));
-               if (err < 0)
-                       return err;
-       }
-       return 0;
-}
-
-
-/*
- * initialize the chip
- */
-static int __devinit prodigy_init(ice1712_t *ice)
-{
-       static unsigned short wm_inits[] = {
-
-               /* These come first to reduce init pop noise */
-               0x1b, 0x000,            /* ADC Mux */
-               0x1c, 0x009,            /* Out Mux1 */
-               0x1d, 0x009,            /* Out Mux2 */
-
-               0x18, 0x000,            /* All power-up */
-
-               0x16, 0x022,            /* I2S, normal polarity, 24bit, high-pass on */
-               0x17, 0x006,            /* 128fs, slave mode */
-
-               0x00, 0,                /* DAC1 analog mute */
-               0x01, 0,                /* DAC2 analog mute */
-               0x02, 0,                /* DAC3 analog mute */
-               0x03, 0,                /* DAC4 analog mute */
-               0x04, 0,                /* DAC5 analog mute */
-               0x05, 0,                /* DAC6 analog mute */
-               0x06, 0,                /* DAC7 analog mute */
-               0x07, 0,                /* DAC8 analog mute */
-               0x08, 0x100,            /* master analog mute */
-
-               0x09, 0x7f,             /* DAC1 digital full */
-               0x0a, 0x7f,             /* DAC2 digital full */
-               0x0b, 0x7f,             /* DAC3 digital full */
-               0x0c, 0x7f,             /* DAC4 digital full */
-               0x0d, 0x7f,             /* DAC5 digital full */
-               0x0e, 0x7f,             /* DAC6 digital full */
-               0x0f, 0x7f,             /* DAC7 digital full */
-               0x10, 0x7f,             /* DAC8 digital full */
-               0x11, 0x1FF,            /* master digital full */
-
-               0x12, 0x000,            /* phase normal */
-               0x13, 0x090,            /* unmute DAC L/R */
-               0x14, 0x000,            /* all unmute */
-               0x15, 0x000,            /* no deemphasis, no ZFLG */
-
-               0x19, 0x000,            /* -12dB ADC/L */
-               0x1a, 0x000             /* -12dB ADC/R */
-
-       };
-
-       static unsigned short cs_inits[] = {
-               0x0441, /* RUN */
-               0x0100, /* no mute */
-               0x0200, /* */
-               0x0600, /* slave, 24bit */
-       };
-
-       unsigned int tmp;
-       unsigned int i;
-
-       printk(KERN_INFO "ice1724: AudioTrak Prodigy 7.1 driver rev. 0.82b\n");
-       printk(KERN_INFO "ice1724:   This driver is in beta stage. Forsuccess/failure reporting contact\n");
-       printk(KERN_INFO "ice1724:   Apostolos Dimitromanolakis <apostol@cs.utoronto.ca>\n");
-
-       ice->num_total_dacs = 8;
-       ice->num_total_adcs = 8;
-
-       /* to remeber the register values */
-       ice->akm = snd_kcalloc(sizeof(akm4xxx_t), GFP_KERNEL);
-       if (! ice->akm)
-               return -ENOMEM;
-       ice->akm_codecs = 1;
-
-       snd_ice1712_gpio_set_dir(ice, 0xbfffff); /* fix this for the time being */
-
-       /* reset the wm codec as the SPI mode */
-       snd_ice1712_save_gpio_status(ice);
-       snd_ice1712_gpio_set_mask(ice,~( PRODIGY_WM_RESET|PRODIGY_WM_CS|
-               PRODIGY_CS8415_CS|PRODIGY_HP_AMP_EN ));
-
-       tmp = snd_ice1712_gpio_read(ice);
-       tmp &= ~PRODIGY_WM_RESET;
-       snd_ice1712_gpio_write(ice, tmp);
-       udelay(1);
-       tmp |= PRODIGY_WM_CS | PRODIGY_CS8415_CS;
-       snd_ice1712_gpio_write(ice, tmp);
-       udelay(1);
-       tmp |= PRODIGY_WM_RESET;
-       snd_ice1712_gpio_write(ice, tmp);
-       udelay(1);
-
-       /* initialize WM8770 codec */
-       for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
-               wm_put(ice, wm_inits[i], wm_inits[i+1]);
-
-       /* initialize CS8415A codec */
-       for (i = 0; i < ARRAY_SIZE(cs_inits); i++)
-               prodigy_spi_write(ice, PRODIGY_CS8415_CS,
-                                cs_inits[i] | 0x200000, 24);
-
-
-       prodigy_set_headphone_amp(ice, 1);
-
-       snd_ice1712_restore_gpio_status(ice);
-
-       return 0;
-}
-
-/*
- * Prodigy boards don't provide the EEPROM data except for the vendor IDs.
- * hence the driver needs to sets up it properly.
- */
-
-static unsigned char prodigy71_eeprom[] __devinitdata = {
-       0x2b,   /* SYSCONF: clock 512, mpu401, spdif-in/ADC, 4DACs */
-       0x80,   /* ACLINK: I2S */
-       0xf8,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0xff,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0xbf,   /* GPIO_DIR2 */
-       0x00,   /* GPIO_MASK */
-       0x00,   /* GPIO_MASK1 */
-       0x00,   /* GPIO_MASK2 */
-       0x00,   /* GPIO_STATE */
-       0x00,   /* GPIO_STATE1 */
-       0x00,   /* GPIO_STATE2 */
-};
-
-/* entry point */
-struct snd_ice1712_card_info snd_vt1724_prodigy_cards[] __devinitdata = {
-       {
-               .subvendor = VT1724_SUBDEVICE_PRODIGY71,
-               .name = "Audiotrak Prodigy 7.1",
-               .chip_init = prodigy_init,
-               .build_controls = prodigy_add_controls,
-               .eeprom_size = sizeof(prodigy71_eeprom),
-               .eeprom_data = prodigy71_eeprom,
-       },
-       { } /* terminator */
-};
diff --git a/sound/pci/ice1712/prodigy.h b/sound/pci/ice1712/prodigy.h
deleted file mode 100644 (file)
index 1ff29fe..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef __SOUND_PRODIGY_H
-#define __SOUND_PRODIGY_H
-
-/*
- *   ALSA driver for VIA VT1724 (Envy24HT)
- *
- *   Lowlevel functions for Terratec PRODIGY cards
- *
- *     Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- */      
-
-#define  PRODIGY_DEVICE_DESC          "{AudioTrak,Prodigy 7.1},"
-
-#define VT1724_SUBDEVICE_PRODIGY71     0x33495345      /* PRODIGY 7.1 */
-
-extern struct snd_ice1712_card_info  snd_vt1724_prodigy_cards[];
-
-/* GPIO bits */
-#define PRODIGY_CS8415_CS      (1 << 23)
-#define PRODIGY_CS8415_CDTO    (1 << 22)
-#define PRODIGY_WM_RESET       (1 << 20)
-#define PRODIGY_WM_CLK         (1 << 19)
-#define PRODIGY_WM_DATA                (1 << 18)
-#define PRODIGY_WM_RW          (1 << 17)
-#define PRODIGY_AC97_RESET     (1 << 16)
-#define PRODIGY_DIGITAL_SEL1   (1 << 15)
-// #define PRODIGY_HP_SEL              (1 << 14)
-#define PRODIGY_WM_CS          (1 << 12)
-
-#define PRODIGY_HP_AMP_EN      (1 << 14)
-
-
-/* WM8770 registers */
-#define WM_DAC_ATTEN           0x00    /* DAC1-8 analog attenuation */
-#define WM_DAC_MASTER_ATTEN    0x08    /* DAC master analog attenuation */
-#define WM_DAC_DIG_ATTEN       0x09    /* DAC1-8 digital attenuation */
-#define WM_DAC_DIG_MATER_ATTEN 0x11    /* DAC master digital attenuation */
-#define WM_PHASE_SWAP          0x12    /* DAC phase */
-#define WM_DAC_CTRL1           0x13    /* DAC control bits */
-#define WM_MUTE                        0x14    /* mute controls */
-#define WM_DAC_CTRL2           0x15    /* de-emphasis and zefo-flag */
-#define WM_INT_CTRL            0x16    /* interface control */
-#define WM_MASTER              0x17    /* master clock and mode */
-#define WM_POWERDOWN           0x18    /* power-down controls */
-#define WM_ADC_GAIN            0x19    /* ADC gain L(19)/R(1a) */
-#define WM_ADC_MUX             0x1b    /* input MUX */
-#define WM_OUT_MUX1            0x1c    /* output MUX */
-#define WM_OUT_MUX2            0x1e    /* output MUX */
-#define WM_RESET               0x1f    /* software reset */
-
-
-#endif /* __SOUND_PRODIGY_H */
index 5637e0b..0e42f2f 100644 (file)
@@ -1188,7 +1188,7 @@ snd_nm256_ac97_reset(ac97_t *ac97)
        /* Reset the mixer.  'Tis magic!  */
        snd_nm256_writeb(chip, 0x6c0, 1);
        if (chip->latitude_workaround) {
-               /* Dell latitude LS will lock up by this */
+               /* Dell Latitude LS will lock up on this */
                snd_nm256_writeb(chip, 0x6cc, 0x87);
        }
        snd_nm256_writeb(chip, 0x6cc, 0x80);
@@ -1505,8 +1505,10 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci,
        chip->latitude_workaround = 1;
        pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
        pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device);
-       if (subsystem_vendor == 0x104d && subsystem_device == 0x8041) {
+       if (   (subsystem_vendor == 0x104d && subsystem_device == 0x8041)
+           || (subsystem_vendor == 0x1028 && subsystem_device == 0x0080)) {
                /* this workaround will cause lock-up after suspend/resume on Sony PCG-F305 */
+               /* It will also cause a lock-up on Latitude LS (PP01S Rev A2) whenever sound devices are accessed */
                chip->latitude_workaround = 0;
        }
        if (subsystem_vendor == 0x1028 && subsystem_device == 0x0080) {